Added commands for well path features

This commit is contained in:
Magne Sjaastad 2015-08-12 20:59:38 +02:00
parent 9f16c859c6
commit 9bee1b81fc
8 changed files with 344 additions and 11 deletions

View File

@ -39,7 +39,10 @@ ${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceJ.h
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceK.h ${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceK.h
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputProperty.h ${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputProperty.h
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.h ${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.h
${CEE_CURRENT_LIST_DIR}RicImportWellPathsSsihubFeature.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 # General delete of any object in a child array field
${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.h ${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}RicRangeFilterNewSliceK.cpp
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputProperty.cpp ${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputProperty.cpp
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.cpp ${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.cpp
${CEE_CURRENT_LIST_DIR}RicImportWellPathsSsihubFeature.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 # General delete of any object in a child array field
${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.cpp ${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.cpp

View File

@ -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 <<http://www.gnu.org/licenses/gpl.html>>
// 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 <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "RicImportWellPathsDeleteAllFeature.h"
#include "RimWellPathCollection.h"
#include "cafSelectionManager.h"
#include <QAction>
namespace caf
{
CAF_CMD_SOURCE_INIT(RicWellPathsDeleteAllFeature, "RicWellPathsDeleteAllFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicWellPathsDeleteAllFeature::isCommandEnabled()
{
std::vector<RimWellPathCollection*> objects;
caf::SelectionManager::instance()->objectsByType(&objects);
if (objects.size() == 1)
{
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellPathsDeleteAllFeature::onActionTriggered(bool isChecked)
{
std::vector<RimWellPathCollection*> 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

View File

@ -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 <<http://www.gnu.org/licenses/gpl.html>>
// 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 <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// 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

View File

@ -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 <<http://www.gnu.org/licenses/gpl.html>>
// 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 <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "RicImportWellPathsFileFeature.h"
#include "RiaApplication.h"
#include "RimProject.h"
#include "RiuMainWindow.h"
#include <QAction>
#include <QFileDialog>
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

View File

@ -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 <<http://www.gnu.org/licenses/gpl.html>>
// 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 <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// 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

View File

@ -36,6 +36,7 @@
#include "RimIdenticalGridCaseGroup.h" #include "RimIdenticalGridCaseGroup.h"
#include "RimOilField.h" #include "RimOilField.h"
#include "RimScriptCollection.h" #include "RimScriptCollection.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h" #include "RimWellPathCollection.h"
#include "RimWellPathImport.h" #include "RimWellPathImport.h"
@ -602,6 +603,12 @@ void RimProject::actionsBasedOnSelection(std::vector<QAction*>& actions)
else if (dynamic_cast<RimWellPathCollection*>(uiItem)) else if (dynamic_cast<RimWellPathCollection*>(uiItem))
{ {
actions.push_back(commandManager->action("RicImportWellPathsSsihubFeature")); actions.push_back(commandManager->action("RicImportWellPathsSsihubFeature"));
actions.push_back(commandManager->action("RicImportWellPathsFileFeature"));
actions.push_back(commandManager->action("RicWellPathsDeleteAllFeature"));
}
else if (dynamic_cast<RimWellPath*>(uiItem))
{
actions.push_back(commandManager->action("RicDeleteItemFeature"));
} }
} }

View File

@ -26,6 +26,7 @@
#include "RimWellPath.h" #include "RimWellPath.h"
#include "RivWellPathCollectionPartMgr.h" #include "RivWellPathCollectionPartMgr.h"
#include "cafPdmUiEditorHandle.h"
#include "cafProgressInfo.h" #include "cafProgressInfo.h"
#include <QFile> #include <QFile>
@ -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<caf::PdmUiFieldHandle*>(this->pdmItem());
RimWellPathCollection* wellPathColl = dynamic_cast<RimWellPathCollection*>(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"); CAF_PDM_SOURCE_INIT(RimWellPathCollection, "WellPaths");
@ -80,6 +105,8 @@ RimWellPathCollection::RimWellPathCollection()
m_project = NULL; m_project = NULL;
m_asciiFileReader = new RimWellPathAsciiFileReader; m_asciiFileReader = new RimWellPathAsciiFileReader;
wellPaths.uiCapability()->addFieldEditor(new RimWellPathCollectionEditorHandle(&wellPaths));
} }

View File

@ -1000,18 +1000,9 @@ void RiuMainWindow::slotOpenLastUsedProject()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuMainWindow::slotImportWellPathsFromFile() void RiuMainWindow::slotImportWellPathsFromFile()
{ {
// Open dialog box to select well path files caf::CmdFeatureManager* commandManager = caf::CmdFeatureManager::instance();
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 (*.*)");
if (wellPathFilePaths.size() < 1) return; commandManager->action("RicImportWellPathsFileFeature")->trigger();
// Remember the path to next time
app->setDefaultFileDialogDirectory("WELLPATH_DIR", QFileInfo(wellPathFilePaths.last()).absolutePath());
app->addWellPathsToModel(wellPathFilePaths);
if (app->project()) app->project()->createDisplayModelAndRedrawAllViews();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------