diff --git a/ApplicationCode/Commands/RicNewWellLogPlotCurveFeature.cpp b/ApplicationCode/Commands/RicNewWellLogPlotCurveFeature.cpp index bc6a73273b..bf787367c1 100644 --- a/ApplicationCode/Commands/RicNewWellLogPlotCurveFeature.cpp +++ b/ApplicationCode/Commands/RicNewWellLogPlotCurveFeature.cpp @@ -79,19 +79,7 @@ void RicNewWellLogPlotCurveFeature::onActionTriggered(bool isChecked) RimWellLogPlotTrace* wellLogPlotTrace = selectedWellLogPlotTrace(); if (wellLogPlotTrace) { - size_t curveIndex = wellLogPlotTrace->curveCount(); - - RimWellLogPlotCurve* curve = new RimWellLogExtractionCurve(); - wellLogPlotTrace->addCurve(curve); - - QColor curveColorQt = sg_curveColorFromIndex(curveIndex); - cvf::Color3f curveColor(curveColorQt.redF(), curveColorQt.greenF(), curveColorQt.blueF()); - curve->setColor(curveColor); - - curve->setDescription(QString("Curve %1").arg(wellLogPlotTrace->curveCount())); - - wellLogPlotTrace->updateConnectedEditors(); - RiuMainWindow::instance()->setCurrentObjectInTreeView(curve); + addCurve(wellLogPlotTrace); } } @@ -112,3 +100,25 @@ RimWellLogPlotTrace* RicNewWellLogPlotCurveFeature::selectedWellLogPlotTrace() caf::SelectionManager::instance()->objectsByType(&selection); return selection.size() > 0 ? selection[0] : NULL; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewWellLogPlotCurveFeature::addCurve(RimWellLogPlotTrace* plotTrace) +{ + CVF_ASSERT(plotTrace); + + size_t curveIndex = plotTrace->curveCount(); + + RimWellLogPlotCurve* curve = new RimWellLogExtractionCurve(); + plotTrace->addCurve(curve); + + QColor curveColorQt = sg_curveColorFromIndex(curveIndex); + cvf::Color3f curveColor(curveColorQt.redF(), curveColorQt.greenF(), curveColorQt.blueF()); + curve->setColor(curveColor); + + curve->setDescription(QString("Curve %1").arg(plotTrace->curveCount())); + + plotTrace->updateConnectedEditors(); + RiuMainWindow::instance()->setCurrentObjectInTreeView(curve); +} diff --git a/ApplicationCode/Commands/RicNewWellLogPlotCurveFeature.h b/ApplicationCode/Commands/RicNewWellLogPlotCurveFeature.h index 42f7ba1ec9..cb6d4bcb99 100644 --- a/ApplicationCode/Commands/RicNewWellLogPlotCurveFeature.h +++ b/ApplicationCode/Commands/RicNewWellLogPlotCurveFeature.h @@ -30,6 +30,10 @@ class RicNewWellLogPlotCurveFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; +public: + static void addCurve(RimWellLogPlotTrace* plotTrace); + + protected: // Overrides virtual bool isCommandEnabled(); diff --git a/ApplicationCode/Commands/RicNewWellLogPlotFeature.cpp b/ApplicationCode/Commands/RicNewWellLogPlotFeature.cpp index 4606b3f168..7bb1d88b04 100644 --- a/ApplicationCode/Commands/RicNewWellLogPlotFeature.cpp +++ b/ApplicationCode/Commands/RicNewWellLogPlotFeature.cpp @@ -24,6 +24,8 @@ #include "RimWellLogPlotCollection.h" #include "RimWellLogPlot.h" #include "RimWellLogPlotTrace.h" +#include "RimWellLogPlotCurve.h" +#include "RicNewWellLogPlotCurveFeature.h" #include "RiaApplication.h" #include "RiuMainWindow.h" @@ -54,14 +56,15 @@ void RicNewWellLogPlotFeature::onActionTriggered(bool isChecked) RimWellLogPlot* plot = new RimWellLogPlot(); wellLogPlotColl->wellLogPlots().push_back(plot); - RimWellLogPlotTrace* plotrace = new RimWellLogPlotTrace(); - plot->addTrace(plotrace); - + RimWellLogPlotTrace* plotTrace = new RimWellLogPlotTrace(); + plot->addTrace(plotTrace); + plot->setDescription(QString("Well Log Plot %1").arg(wellLogPlotCollection()->wellLogPlots.size())); plot->loadDataAndUpdate(); RiaApplication::instance()->project()->updateConnectedEditors(); - RiuMainWindow::instance()->setCurrentObjectInTreeView(plot); + + RicNewWellLogPlotCurveFeature::addCurve(plotTrace); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/RicNewWellLogPlotTraceFeature.cpp b/ApplicationCode/Commands/RicNewWellLogPlotTraceFeature.cpp index 897096ccf9..4a8eb91ef0 100644 --- a/ApplicationCode/Commands/RicNewWellLogPlotTraceFeature.cpp +++ b/ApplicationCode/Commands/RicNewWellLogPlotTraceFeature.cpp @@ -20,12 +20,15 @@ #include "RicNewWellLogPlotTraceFeature.h" #include "RimWellLogPlot.h" +#include "RimWellLogPlotTrace.h" + +#include "RiuMainWindow.h" + +#include "RicNewWellLogPlotCurveFeature.h" #include "cafSelectionManager.h" #include -#include "RimWellLogPlotTrace.h" -#include "RiuMainWindow.h" CAF_CMD_SOURCE_INIT(RicNewWellLogPlotTraceFeature, "RicNewWellLogPlotTraceFeature"); @@ -46,12 +49,12 @@ void RicNewWellLogPlotTraceFeature::onActionTriggered(bool isChecked) RimWellLogPlot* wellLogPlot = selectedWellLogPlot(); if (wellLogPlot) { - RimWellLogPlotTrace* trace = new RimWellLogPlotTrace; - wellLogPlot->addTrace(trace); - trace->setUiName(QString("Trace %1").arg(wellLogPlot->traceCount())); + RimWellLogPlotTrace* plotTrace = new RimWellLogPlotTrace; + wellLogPlot->addTrace(plotTrace); + plotTrace->setUiName(QString("Trace %1").arg(wellLogPlot->traceCount())); wellLogPlot->updateConnectedEditors(); - RiuMainWindow::instance()->setCurrentObjectInTreeView(trace); + RicNewWellLogPlotCurveFeature::addCurve(plotTrace); } }