diff --git a/ApplicationCode/Commands/CMakeLists_files.cmake b/ApplicationCode/Commands/CMakeLists_files.cmake index 32ca46060c..58a1c7ff19 100644 --- a/ApplicationCode/Commands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CMakeLists_files.cmake @@ -39,7 +39,10 @@ ${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceJ.h ${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceK.h ${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputProperty.h ${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.h + ${CEE_CURRENT_LIST_DIR}RicImportWellPathsSsihubFeature.h +${CEE_CURRENT_LIST_DIR}RicImportWellPathsFileFeature.h +${CEE_CURRENT_LIST_DIR}RicImportWellPathsDeleteAllFeature.h # General delete of any object in a child array field ${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.h @@ -81,7 +84,10 @@ ${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceJ.cpp ${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceK.cpp ${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputProperty.cpp ${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.cpp + ${CEE_CURRENT_LIST_DIR}RicImportWellPathsSsihubFeature.cpp +${CEE_CURRENT_LIST_DIR}RicImportWellPathsFileFeature.cpp +${CEE_CURRENT_LIST_DIR}RicImportWellPathsDeleteAllFeature.cpp # General delete of any object in a child array field ${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.cpp diff --git a/ApplicationCode/Commands/RicImportWellPathsDeleteAllFeature.cpp b/ApplicationCode/Commands/RicImportWellPathsDeleteAllFeature.cpp new file mode 100644 index 0000000000..abf0f482ac --- /dev/null +++ b/ApplicationCode/Commands/RicImportWellPathsDeleteAllFeature.cpp @@ -0,0 +1,90 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2013 Ceetron AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at <> +// for more details. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU Lesser General Public License at <> +// for more details. +// +//################################################################################################## + +#include "RicImportWellPathsDeleteAllFeature.h" + +#include "RimWellPathCollection.h" + +#include "cafSelectionManager.h" + +#include + +namespace caf +{ + +CAF_CMD_SOURCE_INIT(RicWellPathsDeleteAllFeature, "RicWellPathsDeleteAllFeature"); + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicWellPathsDeleteAllFeature::isCommandEnabled() +{ + std::vector objects; + caf::SelectionManager::instance()->objectsByType(&objects); + + if (objects.size() == 1) + { + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathsDeleteAllFeature::onActionTriggered(bool isChecked) +{ + std::vector objects; + caf::SelectionManager::instance()->objectsByType(&objects); + + RimWellPathCollection* wellPathCollection = objects[0]; + + wellPathCollection->wellPaths.deleteAllChildObjects(); + uiObj(wellPathCollection)->updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathsDeleteAllFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Delete All Well Paths"); + //actionToSetup->setIcon(QIcon(":/WellCollection.png")); +} + +} // end namespace caf diff --git a/ApplicationCode/Commands/RicImportWellPathsDeleteAllFeature.h b/ApplicationCode/Commands/RicImportWellPathsDeleteAllFeature.h new file mode 100644 index 0000000000..76fa568777 --- /dev/null +++ b/ApplicationCode/Commands/RicImportWellPathsDeleteAllFeature.h @@ -0,0 +1,61 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2013 Ceetron AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at <> +// for more details. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU Lesser General Public License at <> +// for more details. +// +//################################################################################################## + + +#pragma once + +#include "cafCmdFeature.h" + +namespace caf +{ + +//================================================================================================== +/// +//================================================================================================== +class RicWellPathsDeleteAllFeature : public CmdFeature +{ + CAF_CMD_HEADER_INIT; +protected: + + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook( QAction* actionToSetup ); +}; + + + +} // end namespace caf diff --git a/ApplicationCode/Commands/RicImportWellPathsFileFeature.cpp b/ApplicationCode/Commands/RicImportWellPathsFileFeature.cpp new file mode 100644 index 0000000000..7ae9e6a81c --- /dev/null +++ b/ApplicationCode/Commands/RicImportWellPathsFileFeature.cpp @@ -0,0 +1,90 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2013 Ceetron AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at <> +// for more details. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU Lesser General Public License at <> +// for more details. +// +//################################################################################################## + +#include "RicImportWellPathsFileFeature.h" + +#include "RiaApplication.h" +#include "RimProject.h" +#include "RiuMainWindow.h" + +#include +#include + +namespace caf +{ + CAF_CMD_SOURCE_INIT(RicImportWellPathsFileFeature, "RicImportWellPathsFileFeature"); + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicImportWellPathsFileFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportWellPathsFileFeature::onActionTriggered(bool isChecked) +{ + // Open dialog box to select well path files + RiaApplication* app = RiaApplication::instance(); + QString defaultDir = app->defaultFileDialogDirectory("WELLPATH_DIR"); + QStringList wellPathFilePaths = QFileDialog::getOpenFileNames(RiuMainWindow::instance(), "Import Well Paths", defaultDir, "Well Paths (*.json *.asc *.asci *.ascii *.dev);;All Files (*.*)"); + + if (wellPathFilePaths.size() < 1) return; + + // Remember the path to next time + app->setDefaultFileDialogDirectory("WELLPATH_DIR", QFileInfo(wellPathFilePaths.last()).absolutePath()); + + app->addWellPathsToModel(wellPathFilePaths); + if (app->project()) + { + app->project()->createDisplayModelAndRedrawAllViews(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportWellPathsFileFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Import &Well Paths from File"); + actionToSetup->setIcon(QIcon(":/Well.png")); +} + +} // end namespace caf diff --git a/ApplicationCode/Commands/RicImportWellPathsFileFeature.h b/ApplicationCode/Commands/RicImportWellPathsFileFeature.h new file mode 100644 index 0000000000..f7c18fa917 --- /dev/null +++ b/ApplicationCode/Commands/RicImportWellPathsFileFeature.h @@ -0,0 +1,61 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2013 Ceetron AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at <> +// for more details. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU Lesser General Public License at <> +// for more details. +// +//################################################################################################## + + +#pragma once + +#include "cafCmdFeature.h" + +namespace caf +{ + +//================================================================================================== +/// +//================================================================================================== +class RicImportWellPathsFileFeature : public CmdFeature +{ + CAF_CMD_HEADER_INIT; +protected: + + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook( QAction* actionToSetup ); +}; + + + +} // end namespace caf diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index a79a975109..8a67082846 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -36,6 +36,7 @@ #include "RimIdenticalGridCaseGroup.h" #include "RimOilField.h" #include "RimScriptCollection.h" +#include "RimWellPath.h" #include "RimWellPathCollection.h" #include "RimWellPathImport.h" @@ -602,6 +603,12 @@ void RimProject::actionsBasedOnSelection(std::vector& actions) else if (dynamic_cast(uiItem)) { actions.push_back(commandManager->action("RicImportWellPathsSsihubFeature")); + actions.push_back(commandManager->action("RicImportWellPathsFileFeature")); + actions.push_back(commandManager->action("RicWellPathsDeleteAllFeature")); + } + else if (dynamic_cast(uiItem)) + { + actions.push_back(commandManager->action("RicDeleteItemFeature")); } } diff --git a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp index d048f7c9f8..5d030a10f6 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp @@ -26,6 +26,7 @@ #include "RimWellPath.h" #include "RivWellPathCollectionPartMgr.h" +#include "cafPdmUiEditorHandle.h" #include "cafProgressInfo.h" #include @@ -45,6 +46,30 @@ namespace caf } } +class RimWellPathCollectionEditorHandle : public caf::PdmUiEditorHandle +{ +public: + RimWellPathCollectionEditorHandle(caf::PdmFieldHandle* a) + { + this->bindToPdmItem(a->uiCapability()); + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + virtual void configureAndUpdateUi(const QString& uiConfigName) + { + caf::PdmUiFieldHandle* uiFieldHandle = dynamic_cast(this->pdmItem()); + RimWellPathCollection* wellPathColl = dynamic_cast(uiFieldHandle->fieldHandle()->ownerObject()); + + wellPathColl->scheduleGeometryRegenAndRedrawViews(); + + // This will update UI editors related to tree view (and others), as there is no tree view entity for editor for + // the property filters childarrayfield (this field is hidden) + uiObj(wellPathColl)->updateConnectedEditors(); + } +}; + CAF_PDM_SOURCE_INIT(RimWellPathCollection, "WellPaths"); @@ -80,6 +105,8 @@ RimWellPathCollection::RimWellPathCollection() m_project = NULL; m_asciiFileReader = new RimWellPathAsciiFileReader; + + wellPaths.uiCapability()->addFieldEditor(new RimWellPathCollectionEditorHandle(&wellPaths)); } diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 44758a4e81..d2d970fbaa 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -1000,18 +1000,9 @@ void RiuMainWindow::slotOpenLastUsedProject() //-------------------------------------------------------------------------------------------------- void RiuMainWindow::slotImportWellPathsFromFile() { - // Open dialog box to select well path files - RiaApplication* app = RiaApplication::instance(); - QString defaultDir = app->defaultFileDialogDirectory("WELLPATH_DIR"); - QStringList wellPathFilePaths = QFileDialog::getOpenFileNames(this, "Import Well Paths", defaultDir, "Well Paths (*.json *.asc *.asci *.ascii *.dev);;All Files (*.*)"); + caf::CmdFeatureManager* commandManager = caf::CmdFeatureManager::instance(); - if (wellPathFilePaths.size() < 1) return; - - // Remember the path to next time - app->setDefaultFileDialogDirectory("WELLPATH_DIR", QFileInfo(wellPathFilePaths.last()).absolutePath()); - - app->addWellPathsToModel(wellPathFilePaths); - if (app->project()) app->project()->createDisplayModelAndRedrawAllViews(); + commandManager->action("RicImportWellPathsFileFeature")->trigger(); } //--------------------------------------------------------------------------------------------------