mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Added LinkVisibleViewsFeature, and added action to draw toolbar
This commit is contained in:
parent
e5d5543cd9
commit
3f09c1bc66
@ -51,6 +51,9 @@ ${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicWellPathsDeleteAllFeature.h
|
||||
|
||||
${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeature.h
|
||||
|
||||
|
||||
# General delete of any object in a child array field
|
||||
${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.h
|
||||
${CEE_CURRENT_LIST_DIR}RicDeleteItemExecData.h
|
||||
@ -103,6 +106,8 @@ ${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicWellPathsDeleteAllFeature.cpp
|
||||
|
||||
${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeature.cpp
|
||||
|
||||
# General delete of any object in a child array field
|
||||
${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicDeleteItemExecData.cpp
|
||||
|
95
ApplicationCode/Commands/RicLinkVisibleViewsFeature.cpp
Normal file
95
ApplicationCode/Commands/RicLinkVisibleViewsFeature.cpp
Normal file
@ -0,0 +1,95 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicLinkVisibleViewsFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RimManagedViewCollection.h"
|
||||
#include "RimManagedViewConfig.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimView.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "cafPdmUiTreeView.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QTreeView>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicLinkVisibleViewsFeature, "RicLinkVisibleViewsFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicLinkVisibleViewsFeature::isCommandEnabled()
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
std::vector<RimView*> views;
|
||||
proj->allVisibleViews(views);
|
||||
|
||||
if (views.size() > 1) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicLinkVisibleViewsFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
std::vector<RimView*> views;
|
||||
proj->allVisibleViews(views);
|
||||
|
||||
CVF_ASSERT(views.size() > 1);
|
||||
|
||||
RimView* masterView = views[0];
|
||||
|
||||
RimManagedViewCollection* managedViewCollection = masterView->managedViewCollection();
|
||||
for (size_t i = 1; i < views.size(); i++)
|
||||
{
|
||||
RimView* rimView = views[i];
|
||||
RimManagedViewConfig* viewConfig = new RimManagedViewConfig;
|
||||
viewConfig->managedView = rimView;
|
||||
managedViewCollection->managedViews.push_back(viewConfig);
|
||||
|
||||
viewConfig->initAfterReadRecursively();
|
||||
}
|
||||
|
||||
managedViewCollection->applyAllOperations();
|
||||
managedViewCollection->updateConnectedEditors();
|
||||
|
||||
// Set managed view collection to selected and expanded in project tree
|
||||
caf::PdmUiTreeView* projTreeView = RiuMainWindow::instance()->projectTreeView();
|
||||
QModelIndex modIndex = projTreeView->findModelIndex(managedViewCollection);
|
||||
projTreeView->treeView()->setCurrentIndex(modIndex);
|
||||
|
||||
projTreeView->treeView()->setExpanded(modIndex, true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicLinkVisibleViewsFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Link Visible Views");
|
||||
actionToSetup->setIcon(QIcon(":/chain.png"));
|
||||
}
|
||||
|
37
ApplicationCode/Commands/RicLinkVisibleViewsFeature.h
Normal file
37
ApplicationCode/Commands/RicLinkVisibleViewsFeature.h
Normal file
@ -0,0 +1,37 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 RicLinkVisibleViewsFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled();
|
||||
virtual void onActionTriggered( bool isChecked );
|
||||
virtual void setupActionLook( QAction* actionToSetup );
|
||||
|
||||
};
|
@ -44,7 +44,6 @@ RimManagedViewCollection::RimManagedViewCollection(void)
|
||||
CAF_PDM_InitObject("Managed Views", ":/chain.png", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&managedViews, "ManagedViews", "Managed Views", "", "", "");
|
||||
managedViews.push_back(new RimManagedViewConfig);
|
||||
managedViews.uiCapability()->setUiHidden(true);
|
||||
}
|
||||
|
||||
@ -234,3 +233,19 @@ void RimManagedViewCollection::allManagedViews(std::vector<RimView*>& views)
|
||||
managedViews[i]->allManagedViews(views);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimManagedViewCollection::applyAllOperations()
|
||||
{
|
||||
RimView* masterView = NULL;
|
||||
firstAnchestorOrThisOfType(masterView);
|
||||
|
||||
configureOverrides();
|
||||
|
||||
updateCellResult();
|
||||
updateTimeStep(masterView->currentTimeStep());
|
||||
updateRangeFilters();
|
||||
updatePropertyFilters();
|
||||
}
|
||||
|
@ -41,7 +41,9 @@ public:
|
||||
RimManagedViewCollection(void);
|
||||
virtual ~RimManagedViewCollection(void);
|
||||
|
||||
caf::PdmChildArrayField<RimManagedViewConfig*> managedViews;
|
||||
caf::PdmChildArrayField<RimManagedViewConfig*> managedViews;
|
||||
|
||||
void applyAllOperations();
|
||||
|
||||
void updateTimeStep(int timeStep);
|
||||
void updateCellResult();
|
||||
@ -51,6 +53,5 @@ public:
|
||||
|
||||
void configureOverrides();
|
||||
|
||||
void allManagedViews(std::vector<RimView*>& views);
|
||||
|
||||
void allManagedViews(std::vector<RimView*>& views);
|
||||
};
|
||||
|
@ -73,12 +73,19 @@ QList<caf::PdmOptionItemInfo> RimManagedViewConfig::calculateValueOptions(const
|
||||
|
||||
if (fieldNeedingOptions == &managedView)
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
std::vector<RimView*> views;
|
||||
allVisibleViews(views);
|
||||
proj->allVisibleViews(views);
|
||||
|
||||
RimView* masterView = NULL;
|
||||
firstAnchestorOrThisOfType(masterView);
|
||||
|
||||
for (size_t i = 0; i< views.size(); i++)
|
||||
{
|
||||
optionList.push_back(caf::PdmOptionItemInfo(displayNameForView(views[i]), QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(views[i]))));
|
||||
if (views[i] != masterView)
|
||||
{
|
||||
optionList.push_back(caf::PdmOptionItemInfo(displayNameForView(views[i]), QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(views[i]))));
|
||||
}
|
||||
}
|
||||
|
||||
if (optionList.size() > 0)
|
||||
@ -90,36 +97,6 @@ QList<caf::PdmOptionItemInfo> RimManagedViewConfig::calculateValueOptions(const
|
||||
return optionList;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimManagedViewConfig::allVisibleViews(std::vector<RimView*>& views)
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
|
||||
RimView* masterView = NULL;
|
||||
firstAnchestorOrThisOfType(masterView);
|
||||
|
||||
if (proj)
|
||||
{
|
||||
std::vector<RimCase*> cases;
|
||||
proj->allCases(cases);
|
||||
for (size_t caseIdx = 0; caseIdx < cases.size(); caseIdx++)
|
||||
{
|
||||
RimCase* rimCase = cases[caseIdx];
|
||||
|
||||
std::vector<RimView*> caseViews = rimCase->views();
|
||||
for (size_t viewIdx = 0; viewIdx < caseViews.size(); viewIdx++)
|
||||
{
|
||||
if (caseViews[viewIdx]->viewer() && caseViews[viewIdx] != masterView)
|
||||
{
|
||||
views.push_back(caseViews[viewIdx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -49,8 +49,7 @@ public:
|
||||
caf::PdmField<bool> syncRangeFilters;
|
||||
caf::PdmField<bool> syncPropertyFilters;
|
||||
|
||||
void configureOverrides();
|
||||
|
||||
void configureOverrides();
|
||||
void allManagedViews(std::vector<RimView*>& views);
|
||||
|
||||
protected:
|
||||
@ -62,7 +61,6 @@ protected:
|
||||
|
||||
|
||||
private:
|
||||
void allVisibleViews(std::vector<RimView*>& views);
|
||||
void configureOverridesUpdateDisplayModel();
|
||||
|
||||
RimEclipseView* managedEclipseView();
|
||||
|
@ -458,6 +458,29 @@ void RimProject::allCases(std::vector<RimCase*>& cases)
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::allVisibleViews(std::vector<RimView*>& views)
|
||||
{
|
||||
std::vector<RimCase*> cases;
|
||||
allCases(cases);
|
||||
|
||||
for (size_t caseIdx = 0; caseIdx < cases.size(); caseIdx++)
|
||||
{
|
||||
RimCase* rimCase = cases[caseIdx];
|
||||
if (!rimCase) continue;
|
||||
|
||||
std::vector<RimView*> caseViews = rimCase->views();
|
||||
for (size_t viewIdx = 0; viewIdx < caseViews.size(); viewIdx++)
|
||||
{
|
||||
if (caseViews[viewIdx] && caseViews[viewIdx]->viewer())
|
||||
{
|
||||
views.push_back(caseViews[viewIdx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
|
@ -37,6 +37,7 @@ class RimOilField;
|
||||
class RimScriptCollection;
|
||||
class RimWellPathImport;
|
||||
class RimMainPlotCollection;
|
||||
class RimView;
|
||||
|
||||
namespace caf
|
||||
{
|
||||
@ -77,7 +78,9 @@ public:
|
||||
void assignCaseIdToCase(RimCase* reservoirCase);
|
||||
void assignIdToCaseGroup(RimIdenticalGridCaseGroup* caseGroup);
|
||||
|
||||
void allCases(std::vector<RimCase*>& cases);
|
||||
void allCases(std::vector<RimCase*>& cases);
|
||||
void allVisibleViews(std::vector<RimView*>& views);
|
||||
|
||||
void createDisplayModelAndRedrawAllViews();
|
||||
|
||||
void computeUtmAreaOfInterest();
|
||||
|
@ -525,6 +525,8 @@ void RiuMainWindow::createToolBars()
|
||||
m_viewToolBar->addAction(m_drawStyleToggleFaultsAction);
|
||||
m_viewToolBar->addAction(m_toggleFaultsLabelAction);
|
||||
m_viewToolBar->addAction(m_addWellCellsToRangeFilterAction);
|
||||
m_viewToolBar->addSeparator();
|
||||
m_viewToolBar->addAction(cmdFeatureMgr->action("RicLinkVisibleViewsFeature"));
|
||||
|
||||
QLabel* scaleLabel = new QLabel(m_viewToolBar);
|
||||
scaleLabel->setText("Scale");
|
||||
@ -542,6 +544,8 @@ void RiuMainWindow::createToolBars()
|
||||
|
||||
refreshAnimationActions();
|
||||
refreshDrawStyleActions();
|
||||
|
||||
cmdFeatureMgr->refreshEnabledState(QStringList() << "RicLinkVisibleViewsFeature");
|
||||
}
|
||||
|
||||
|
||||
@ -1184,6 +1188,8 @@ void RiuMainWindow::removeViewer(RiuViewer* viewer)
|
||||
#else
|
||||
m_mdiArea->removeSubWindow( findMdiSubWindow(viewer));
|
||||
#endif
|
||||
|
||||
caf::CmdFeatureManager::instance()->refreshEnabledState(QStringList() << "RicLinkVisibleViewsFeature");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1207,6 +1213,8 @@ void RiuMainWindow::addViewer(RiuViewer* viewer)
|
||||
subWin->show();
|
||||
}
|
||||
#endif
|
||||
|
||||
caf::CmdFeatureManager::instance()->refreshEnabledState(QStringList() << "RicLinkVisibleViewsFeature");
|
||||
}
|
||||
|
||||
|
||||
|
@ -504,27 +504,22 @@ void RiuViewer::update()
|
||||
|
||||
if (m_reservoirView)
|
||||
{
|
||||
viewsToUpdate.push_back(m_reservoirView);
|
||||
|
||||
// All downstreams views
|
||||
m_reservoirView->managedViewCollection()->allManagedViews(viewsToUpdate);
|
||||
|
||||
// All upstreams views
|
||||
|
||||
RimView* rimView = m_reservoirView;
|
||||
|
||||
|
||||
std::vector<caf::PdmObjectHandle*> objects;
|
||||
rimView->objectsWithReferringPtrFields(objects);
|
||||
|
||||
|
||||
while (objects.size() > 0)
|
||||
{
|
||||
RimManagedViewConfig* viewConfig = dynamic_cast<RimManagedViewConfig*>(objects[0]);
|
||||
viewConfig->firstAnchestorOrThisOfType(rimView);
|
||||
viewsToUpdate.push_back(rimView);
|
||||
|
||||
|
||||
objects.clear();
|
||||
rimView->objectsWithReferringPtrFields(objects);
|
||||
}
|
||||
|
||||
viewsToUpdate.push_back(rimView);
|
||||
rimView->managedViewCollection()->allManagedViews(viewsToUpdate);
|
||||
}
|
||||
|
||||
// Propagate view matrix to all relevant views
|
||||
|
Loading…
Reference in New Issue
Block a user