From 8667b6baa001fe1765ce1a28dc841af37fb6a991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l=20Hagen?= Date: Mon, 21 Sep 2015 14:02:33 +0200 Subject: [PATCH] (#468) Added context menu item in 3D view for plotting of logs from LAS files --- .../RicNewWellLogFileCurveFeature.cpp | 43 +++++++++++++++++-- .../RicNewWellLogFileCurveFeature.h | 5 ++- .../RicNewWellLogPlotFeature.cpp | 16 +++---- .../RicNewWellLogPlotFeatureImpl.cpp | 19 ++++++++ .../RicNewWellLogPlotFeatureImpl.h | 2 + .../UserInterface/RiuViewerCommands.cpp | 27 +++++++++++- 6 files changed, 95 insertions(+), 17 deletions(-) diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp index b6c6fc79f6..827f2d674b 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp @@ -20,9 +20,13 @@ #include "RicNewWellLogFileCurveFeature.h" #include "RicWellLogPlotCurveFeatureImpl.h" +#include "RicNewWellLogPlotFeatureImpl.h" #include "RimWellLogFileCurve.h" #include "RimWellLogPlotTrack.h" +#include "RimWellLogFile.h" +#include "RimWellPath.h" +#include "RimWellPathCollection.h" #include "RiuMainWindow.h" @@ -40,7 +44,7 @@ CAF_CMD_SOURCE_INIT(RicNewWellLogFileCurveFeature, "RicNewWellLogFileCurveFeatur //-------------------------------------------------------------------------------------------------- bool RicNewWellLogFileCurveFeature::isCommandEnabled() { - return selectedWellLogPlotTrack() != NULL; + return selectedWellLogPlotTrack() != NULL || selectedWellLogPlotTrackWithLogFile() != NULL; } //-------------------------------------------------------------------------------------------------- @@ -53,6 +57,17 @@ void RicNewWellLogFileCurveFeature::onActionTriggered(bool isChecked) { addCurve(wellLogPlotTrack); } + else + { + RimWellPath* wellPath = selectedWellLogPlotTrackWithLogFile(); + if (wellPath) + { + RimWellLogPlotTrack* wellLogPlotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack(); + RimWellLogFileCurve* plotCurve = addCurve(wellLogPlotTrack); + plotCurve->setWellPath(wellPath); + plotCurve->updateConnectedEditors(); + } + } } //-------------------------------------------------------------------------------------------------- @@ -76,13 +91,33 @@ RimWellLogPlotTrack* RicNewWellLogFileCurveFeature::selectedWellLogPlotTrack() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicNewWellLogFileCurveFeature::addCurve(RimWellLogPlotTrack* plotTrack) +RimWellPath* RicNewWellLogFileCurveFeature::selectedWellLogPlotTrackWithLogFile() +{ + std::vector selection; + caf::SelectionManager::instance()->objectsByType(&selection); + if (selection.size() > 0) + { + RimWellPath* wellPath = selection[0]; + if (wellPath->m_wellLogFile()) + { + return wellPath; + } + } + + return NULL; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLogFileCurve* RicNewWellLogFileCurveFeature::addCurve(RimWellLogPlotTrack* plotTrack) { CVF_ASSERT(plotTrack); size_t curveIndex = plotTrack->curveCount(); - RimWellLogPlotCurve* curve = new RimWellLogFileCurve(); + RimWellLogFileCurve* curve = new RimWellLogFileCurve(); plotTrack->addCurve(curve); cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromIndex(curveIndex); @@ -91,4 +126,6 @@ void RicNewWellLogFileCurveFeature::addCurve(RimWellLogPlotTrack* plotTrack) plotTrack->updateConnectedEditors(); RiuMainWindow::instance()->setCurrentObjectInTreeView(curve); + + return curve; } diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.h b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.h index cd133fb00c..d6e9dd9deb 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.h +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.h @@ -22,6 +22,8 @@ #include "cafCmdFeature.h" class RimWellLogPlotTrack; +class RimWellLogFileCurve; +class RimWellPath; //================================================================================================== /// @@ -31,7 +33,7 @@ class RicNewWellLogFileCurveFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; public: - static void addCurve(RimWellLogPlotTrack* plotTrack); + static RimWellLogFileCurve* addCurve(RimWellLogPlotTrack* plotTrack); protected: @@ -42,4 +44,5 @@ protected: private: RimWellLogPlotTrack* selectedWellLogPlotTrack(); + RimWellPath* selectedWellLogPlotTrackWithLogFile(); }; diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotFeature.cpp index fbe1be9789..5fc487545c 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotFeature.cpp @@ -20,11 +20,14 @@ #include "RicNewWellLogPlotFeature.h" #include "RicNewWellLogPlotFeatureImpl.h" +#include "RicNewWellLogFileCurveFeature.h" +#include "RicNewWellLogCurveExtractionFeature.h" #include "RimProject.h" #include "RimWellLogPlot.h" #include "RimWellLogPlotTrack.h" -#include "RicNewWellLogCurveExtractionFeature.h" +#include "RimWellLogPlotCurve.h" + #include "RiaApplication.h" #include @@ -47,16 +50,7 @@ bool RicNewWellLogPlotFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicNewWellLogPlotFeature::onActionTriggered(bool isChecked) { - RimWellLogPlot* plot = RicNewWellLogPlotFeatureImpl::createWellLogPlot(); - - RimWellLogPlotTrack* plotTrack = new RimWellLogPlotTrack(); - plot->addTrack(plotTrack); - plotTrack->setDescription(QString("Track %1").arg(plot->trackCount())); - - plot->loadDataAndUpdate(); - plot->updateConnectedEditors(); - RiaApplication::instance()->project()->updateConnectedEditors(); - + RimWellLogPlotTrack* plotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack(); RicNewWellLogCurveExtractionFeature::addCurve(plotTrack); } diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.cpp index cdd0494658..bc5cf34067 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.cpp @@ -23,6 +23,7 @@ #include "RimMainPlotCollection.h" #include "RimWellLogPlotCollection.h" #include "RimWellLogPlot.h" +#include "RimWellLogPlotTrack.h" #include "RiaApplication.h" @@ -78,3 +79,21 @@ RimWellLogPlot* RicNewWellLogPlotFeatureImpl::createWellLogPlot() return plot; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLogPlotTrack* RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack() +{ + RimWellLogPlot* plot = createWellLogPlot(); + + RimWellLogPlotTrack* plotTrack = new RimWellLogPlotTrack(); + plot->addTrack(plotTrack); + plotTrack->setDescription(QString("Track %1").arg(plot->trackCount())); + + plot->loadDataAndUpdate(); + plot->updateConnectedEditors(); + RiaApplication::instance()->project()->updateConnectedEditors(); + + return plotTrack; +} diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.h b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.h index e1c2bc84ad..f681dc1998 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.h +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.h @@ -22,6 +22,7 @@ class RimMainPlotCollection; class RimWellLogPlotCollection; class RimWellLogPlot; +class RimWellLogPlotTrack; //================================================================================================== /// @@ -33,4 +34,5 @@ public: static RimMainPlotCollection* mainPlotCollection(); static RimWellLogPlotCollection* wellLogPlotCollection(); static RimWellLogPlot* createWellLogPlot(); + static RimWellLogPlotTrack* createWellLogPlotTrack(); }; diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 404f54be50..5f3231a2db 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -24,6 +24,7 @@ #include "RicEclipsePropertyFilterNewExec.h" #include "RicGeoMechPropertyFilterNewExec.h" #include "RicRangeFilterNewExec.h" +#include "Commands/WellLogCommands/RicNewWellLogFileCurveFeature.h" #include "RigCaseData.h" #include "RigFemPartCollection.h" @@ -49,6 +50,7 @@ #include "RimView.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" +#include "RimWellLogFile.h" #include "RiuFemResultTextBuilder.h" #include "RiuMainWindow.h" @@ -63,6 +65,7 @@ #include "cafCmdExecCommandManager.h" #include "cafCmdFeature.h" #include "cafCmdFeatureManager.h" +#include "cafSelectionManager.h" #include "cvfDrawableGeo.h" #include "cvfHitItemCollection.h" @@ -200,6 +203,28 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) } } + if (firstHitPart && firstHitPart->sourceInfo()) + { + const RivWellPathSourceInfo* wellPathSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); + if (wellPathSourceInfo) + { + RimWellPath* wellPath = wellPathSourceInfo->wellPath(); + if (wellPath) + { + // TODO: Handle selection through mouse events outside this method, or after ray picking above + caf::SelectionManager::instance()->setSelectedItem(wellPath); + RiaApplication::instance()->project()->updateConnectedEditors(); + + RicNewWellLogFileCurveFeature* newWellLogFileCurveFeature = dynamic_cast(caf::CmdFeatureManager::instance()->getCommandFeature("RicNewWellLogFileCurveFeature")); + CVF_ASSERT(newWellLogFileCurveFeature); + + menu.addAction(newWellLogFileCurveFeature->action()); + } + } + } + + if (firstHitPart) + // View Link commands { QStringList commandIds; @@ -604,5 +629,3 @@ void RiuViewerCommands::ijkFromCellIndex(size_t gridIdx, size_t cellIndex, size geomView->geoMechCase()->geoMechData()->femParts()->part(gridIdx)->structGrid()->ijkFromCellIndex(cellIndex, i, j, k); } } - -