diff --git a/ApplicationCode/Commands/RicExportToLasFileFeature.cpp b/ApplicationCode/Commands/RicExportToLasFileFeature.cpp index 52ffc1b8d9..e9ae4a7759 100644 --- a/ApplicationCode/Commands/RicExportToLasFileFeature.cpp +++ b/ApplicationCode/Commands/RicExportToLasFileFeature.cpp @@ -39,7 +39,7 @@ CAF_CMD_SOURCE_INIT(RicExportToLasFileFeature, "RicExportToLasFileFeature"); //-------------------------------------------------------------------------------------------------- bool RicExportToLasFileFeature::isCommandEnabled() { - return selectedWellLogPlotCurves().size() > 0; + return selectedWellLogCurves().size() > 0; } //-------------------------------------------------------------------------------------------------- @@ -47,7 +47,7 @@ bool RicExportToLasFileFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicExportToLasFileFeature::onActionTriggered(bool isChecked) { - std::vector curves = selectedWellLogPlotCurves(); + std::vector curves = selectedWellLogCurves(); if (curves.size() == 0) return; RiaApplication* app = RiaApplication::instance(); @@ -82,17 +82,42 @@ void RicExportToLasFileFeature::onActionTriggered(bool isChecked) //-------------------------------------------------------------------------------------------------- void RicExportToLasFileFeature::setupActionLook(QAction* actionToSetup) { - actionToSetup->setText("Export To LAS File..."); + actionToSetup->setText("Export To LAS Files..."); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RicExportToLasFileFeature::selectedWellLogPlotCurves() const +std::vector RicExportToLasFileFeature::selectedWellLogCurves() const { - std::vector selection; - caf::SelectionManager::instance()->objectsByType(&selection); + std::set curveSet; - return selection; + { + std::vector selectedItems; + caf::SelectionManager::instance()->selectedItems(selectedItems); + + for (auto selectedItem : selectedItems) + { + caf::PdmObjectHandle* objHandle = dynamic_cast(selectedItem); + if (objHandle) + { + std::vector childCurves; + objHandle->descendantsIncludingThisOfType(childCurves); + + for (auto curve : childCurves) + { + curveSet.insert(curve); + } + } + } + } + + std::vector allCurves; + for (auto curve : curveSet) + { + allCurves.push_back(curve); + } + + return allCurves; } diff --git a/ApplicationCode/Commands/RicExportToLasFileFeature.h b/ApplicationCode/Commands/RicExportToLasFileFeature.h index 399a7529d4..a3d5526e53 100644 --- a/ApplicationCode/Commands/RicExportToLasFileFeature.h +++ b/ApplicationCode/Commands/RicExportToLasFileFeature.h @@ -39,6 +39,6 @@ protected: virtual void setupActionLook( QAction* actionToSetup ); private: - std::vector selectedWellLogPlotCurves() const; + std::vector selectedWellLogCurves() const; }; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index e73eec20b1..8388fd53d1 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -351,7 +351,10 @@ QStringList RimContextCommandBuilder::commandsFromSelection() { commandIds << "RicExecuteScriptForCasesFeature"; } - else if (dynamic_cast(uiItem)) + else if (dynamic_cast(uiItem) || + dynamic_cast(uiItem) || + dynamic_cast(uiItem) || + dynamic_cast(uiItem)) { commandIds << "RicExportToLasFileFeature"; }