mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#339) Added RicNewViewFeature
TODO: Expand new view in treeview when inserted
This commit is contained in:
@@ -21,7 +21,7 @@ ${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterInsertFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterInsertExec.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewExec.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipseViewNewFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicNewViewFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipseViewPasteFeature.h
|
||||
#${CEE_CURRENT_LIST_DIR}RicGridModelsCreateCaseGroupFromFiles.h
|
||||
#${CEE_CURRENT_LIST_DIR}RicGridModelsImport.h
|
||||
@@ -64,7 +64,7 @@ ${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterInsertFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterInsertExec.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewExec.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipseViewNewFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicNewViewFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicEclipseViewPasteFeature.cpp
|
||||
#${CEE_CURRENT_LIST_DIR}RicGridModelsCreateCaseGroupFromFiles.cpp
|
||||
#${CEE_CURRENT_LIST_DIR}RicGridModelsImport.cpp
|
||||
|
||||
@@ -19,7 +19,11 @@
|
||||
|
||||
#include "RicEclipseViewNewFeature.h"
|
||||
|
||||
#include "RimView.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
@@ -32,17 +36,10 @@ CAF_CMD_SOURCE_INIT(RicEclipseViewNewFeature, "RicEclipseViewNewFeature");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicEclipseViewNewFeature::isCommandEnabled()
|
||||
{
|
||||
std::vector<RimEclipseView*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
|
||||
if (selection.size() > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return selectedEclipseCase() != NULL
|
||||
|| selectedEclipseView() != NULL
|
||||
|| selectedGeoMechCase() != NULL
|
||||
|| selectedGeoMechView() != NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -50,7 +47,7 @@ bool RicEclipseViewNewFeature::isCommandEnabled()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicEclipseViewNewFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
// MODTODO
|
||||
addReservoirView();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -60,3 +57,109 @@ void RicEclipseViewNewFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("New View");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimView* RicEclipseViewNewFeature::addReservoirView()
|
||||
{
|
||||
// Establish type of selected object
|
||||
RimEclipseCase* eclipseCase = selectedEclipseCase();
|
||||
RimGeoMechCase* geomCase = selectedGeoMechCase();
|
||||
RimGeoMechView* geoMechView = selectedGeoMechView();
|
||||
RimEclipseView* reservoirView = selectedEclipseView();
|
||||
|
||||
// Find case to insert into
|
||||
if (geoMechView) geomCase = geoMechView->geoMechCase();
|
||||
if (reservoirView) eclipseCase = reservoirView->eclipseCase();
|
||||
|
||||
RimView* insertedView = NULL;
|
||||
|
||||
if (eclipseCase)
|
||||
{
|
||||
insertedView = eclipseCase->createAndAddReservoirView();
|
||||
}
|
||||
else if (geomCase)
|
||||
{
|
||||
insertedView = geomCase->createAndAddReservoirView();
|
||||
}
|
||||
|
||||
// Must be run before buildViewItems, as wells are created in this function
|
||||
insertedView->loadDataAndUpdate();
|
||||
|
||||
if (eclipseCase)
|
||||
{
|
||||
eclipseCase->updateConnectedEditors();
|
||||
}
|
||||
|
||||
if (geomCase)
|
||||
{
|
||||
geomCase->updateConnectedEditors();
|
||||
}
|
||||
|
||||
return insertedView;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseCase* RicEclipseViewNewFeature::selectedEclipseCase() const
|
||||
{
|
||||
std::vector<RimEclipseCase*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
|
||||
if (selection.size() > 0)
|
||||
{
|
||||
return selection[0];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGeoMechCase* RicEclipseViewNewFeature::selectedGeoMechCase() const
|
||||
{
|
||||
std::vector<RimGeoMechCase*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
|
||||
if (selection.size() > 0)
|
||||
{
|
||||
return selection[0];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseView* RicEclipseViewNewFeature::selectedEclipseView() const
|
||||
{
|
||||
std::vector<RimEclipseView*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
|
||||
if (selection.size() > 0)
|
||||
{
|
||||
return selection[0];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGeoMechView* RicEclipseViewNewFeature::selectedGeoMechView() const
|
||||
{
|
||||
std::vector<RimGeoMechView*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
|
||||
if (selection.size() > 0)
|
||||
{
|
||||
return selection[0];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,11 @@
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
class RimView;
|
||||
class RimEclipseCase;
|
||||
class RimEclipseView;
|
||||
class RimGeoMechCase;
|
||||
class RimGeoMechView;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@@ -34,6 +39,12 @@ protected:
|
||||
virtual bool isCommandEnabled();
|
||||
virtual void onActionTriggered( bool isChecked );
|
||||
virtual void setupActionLook( QAction* actionToSetup );
|
||||
|
||||
private:
|
||||
RimView* addReservoirView();
|
||||
|
||||
RimEclipseCase* selectedEclipseCase() const;
|
||||
RimGeoMechCase* selectedGeoMechCase() const;
|
||||
RimEclipseView* selectedEclipseView() const;
|
||||
RimGeoMechView* selectedGeoMechView() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
167
ApplicationCode/Commands/RicNewViewFeature.cpp
Normal file
167
ApplicationCode/Commands/RicNewViewFeature.cpp
Normal file
@@ -0,0 +1,167 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight 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.
|
||||
//
|
||||
// ResInsight 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicNewViewFeature.h"
|
||||
|
||||
#include "RimView.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicNewViewFeature, "RicNewViewFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicNewViewFeature::isCommandEnabled()
|
||||
{
|
||||
return selectedEclipseCase() != NULL
|
||||
|| selectedEclipseView() != NULL
|
||||
|| selectedGeoMechCase() != NULL
|
||||
|| selectedGeoMechView() != NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewViewFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
addReservoirView();
|
||||
|
||||
// MODTODO: expand new view when inserted
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewViewFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("New View");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimView* RicNewViewFeature::addReservoirView()
|
||||
{
|
||||
// Establish type of selected object
|
||||
RimEclipseCase* eclipseCase = selectedEclipseCase();
|
||||
RimGeoMechCase* geomCase = selectedGeoMechCase();
|
||||
RimGeoMechView* geoMechView = selectedGeoMechView();
|
||||
RimEclipseView* reservoirView = selectedEclipseView();
|
||||
|
||||
// Find case to insert into
|
||||
if (geoMechView) geomCase = geoMechView->geoMechCase();
|
||||
if (reservoirView) eclipseCase = reservoirView->eclipseCase();
|
||||
|
||||
RimView* insertedView = NULL;
|
||||
|
||||
if (eclipseCase)
|
||||
{
|
||||
insertedView = eclipseCase->createAndAddReservoirView();
|
||||
}
|
||||
else if (geomCase)
|
||||
{
|
||||
insertedView = geomCase->createAndAddReservoirView();
|
||||
}
|
||||
|
||||
// Must be run before buildViewItems, as wells are created in this function
|
||||
insertedView->loadDataAndUpdate();
|
||||
|
||||
if (eclipseCase)
|
||||
{
|
||||
eclipseCase->updateConnectedEditors();
|
||||
}
|
||||
|
||||
if (geomCase)
|
||||
{
|
||||
geomCase->updateConnectedEditors();
|
||||
}
|
||||
|
||||
return insertedView;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseCase* RicNewViewFeature::selectedEclipseCase() const
|
||||
{
|
||||
std::vector<RimEclipseCase*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
|
||||
if (selection.size() > 0)
|
||||
{
|
||||
return selection[0];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGeoMechCase* RicNewViewFeature::selectedGeoMechCase() const
|
||||
{
|
||||
std::vector<RimGeoMechCase*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
|
||||
if (selection.size() > 0)
|
||||
{
|
||||
return selection[0];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseView* RicNewViewFeature::selectedEclipseView() const
|
||||
{
|
||||
std::vector<RimEclipseView*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
|
||||
if (selection.size() > 0)
|
||||
{
|
||||
return selection[0];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGeoMechView* RicNewViewFeature::selectedGeoMechView() const
|
||||
{
|
||||
std::vector<RimGeoMechView*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
|
||||
if (selection.size() > 0)
|
||||
{
|
||||
return selection[0];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
50
ApplicationCode/Commands/RicNewViewFeature.h
Normal file
50
ApplicationCode/Commands/RicNewViewFeature.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight 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.
|
||||
//
|
||||
// ResInsight 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
class RimView;
|
||||
class RimEclipseCase;
|
||||
class RimEclipseView;
|
||||
class RimGeoMechCase;
|
||||
class RimGeoMechView;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicNewViewFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled();
|
||||
virtual void onActionTriggered( bool isChecked );
|
||||
virtual void setupActionLook( QAction* actionToSetup );
|
||||
|
||||
private:
|
||||
RimView* addReservoirView();
|
||||
|
||||
RimEclipseCase* selectedEclipseCase() const;
|
||||
RimGeoMechCase* selectedGeoMechCase() const;
|
||||
RimEclipseView* selectedEclipseView() const;
|
||||
RimGeoMechView* selectedGeoMechView() const;
|
||||
};
|
||||
@@ -554,7 +554,7 @@ void RimProject::actionsBasedOnSelection(QMenu& contextMenu)
|
||||
|
||||
if (dynamic_cast<RimGeoMechView*>(uiItem))
|
||||
{
|
||||
//commandIds << "RicEclipseViewNew";
|
||||
commandIds << "RicNewViewFeature";
|
||||
commandIds << "RicCopyReferencesToClipboardFeature";
|
||||
commandIds << "RicPasteGeoMechViewsFeature";
|
||||
//commandIds << "RicEclipseViewDelete";
|
||||
@@ -564,7 +564,7 @@ void RimProject::actionsBasedOnSelection(QMenu& contextMenu)
|
||||
commandIds << "RicCopyReferencesToClipboardFeature";
|
||||
commandIds << "RicPasteEclipseViewsFeature";
|
||||
|
||||
//commandIds << "RicEclipseViewNew";
|
||||
commandIds << "RicNewViewFeature";
|
||||
//commandIds << "RicEclipseViewDelete";
|
||||
}
|
||||
else if (dynamic_cast<RimEclipseCase*>(uiItem))
|
||||
@@ -575,7 +575,7 @@ void RimProject::actionsBasedOnSelection(QMenu& contextMenu)
|
||||
commandIds << "RicPasteEclipseViewsFeature";
|
||||
|
||||
//commandIds << "RicEclipseCaseClose";
|
||||
//commandIds << "RicEclipseCaseNewView";
|
||||
commandIds << "RicNewViewFeature";
|
||||
commandIds << "RicEclipseCaseNewGroupFeature";
|
||||
//commandIds << "RicEclipseCaseExecuteScript";
|
||||
}
|
||||
@@ -583,11 +583,11 @@ void RimProject::actionsBasedOnSelection(QMenu& contextMenu)
|
||||
{
|
||||
commandIds << "RicPasteGeoMechViewsFeature";
|
||||
//commandIds << "RicEclipseCaseClose";
|
||||
//commandIds << "RicEclipseCaseNewView";
|
||||
commandIds << "RicNewViewFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimIdenticalGridCaseGroup*>(uiItem))
|
||||
{
|
||||
//commandIds << "RicEclipseCaseNewView";
|
||||
commandIds << "RicNewViewFeature";
|
||||
commandIds << "RicPasteEclipseCasesFeature";
|
||||
commandIds << "RicPasteEclipseViewsFeature";
|
||||
}
|
||||
|
||||
@@ -693,6 +693,7 @@ void RimUiTreeView::slotExecuteScriptForSelectedCases()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// OBSOLETE - see RicNewViewFeature
|
||||
void RimUiTreeView::slotAddView()
|
||||
{
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
|
||||
Reference in New Issue
Block a user