mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#446) Added feature "Set master view" to context menu in 3D and in project tree
This commit is contained in:
@@ -12,6 +12,7 @@ ${CEE_CURRENT_LIST_DIR}RicLinkViewFeature.h
|
|||||||
${CEE_CURRENT_LIST_DIR}RicUnLinkViewFeature.h
|
${CEE_CURRENT_LIST_DIR}RicUnLinkViewFeature.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicShowLinkOptionsFeature.h
|
${CEE_CURRENT_LIST_DIR}RicShowLinkOptionsFeature.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicDeleteAllLinkedViewsFeature.h
|
${CEE_CURRENT_LIST_DIR}RicDeleteAllLinkedViewsFeature.h
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicSetMasterViewFeature.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set (SOURCE_GROUP_SOURCE_FILES
|
set (SOURCE_GROUP_SOURCE_FILES
|
||||||
@@ -22,6 +23,7 @@ ${CEE_CURRENT_LIST_DIR}RicLinkViewFeature.cpp
|
|||||||
${CEE_CURRENT_LIST_DIR}RicUnLinkViewFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicUnLinkViewFeature.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicShowLinkOptionsFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicShowLinkOptionsFeature.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicDeleteAllLinkedViewsFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicDeleteAllLinkedViewsFeature.cpp
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicSetMasterViewFeature.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND CODE_HEADER_FILES
|
list(APPEND CODE_HEADER_FILES
|
||||||
|
|||||||
127
ApplicationCode/Commands/ViewLink/RicSetMasterViewFeature.cpp
Normal file
127
ApplicationCode/Commands/ViewLink/RicSetMasterViewFeature.cpp
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 "RicSetMasterViewFeature.h"
|
||||||
|
|
||||||
|
#include "RiaApplication.h"
|
||||||
|
#include "RimProject.h"
|
||||||
|
#include "RimView.h"
|
||||||
|
#include "RimViewLink.h"
|
||||||
|
#include "RimViewLinker.h"
|
||||||
|
#include "RimViewLinkerCollection.h"
|
||||||
|
#include "RiuMainWindow.h"
|
||||||
|
|
||||||
|
#include "cafPdmUiTreeView.h"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
#include <QTreeView>
|
||||||
|
|
||||||
|
CAF_CMD_SOURCE_INIT(RicSetMasterViewFeature, "RicSetMasterViewFeature");
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RicSetMasterViewFeature::isCommandEnabled()
|
||||||
|
{
|
||||||
|
RimView* activeView = RiaApplication::instance()->activeReservoirView();
|
||||||
|
if (!activeView) return false;
|
||||||
|
|
||||||
|
RimProject* proj = RiaApplication::instance()->project();
|
||||||
|
RimViewLinker* viewLinker = proj->findViewLinkerFromView(activeView);
|
||||||
|
if (viewLinker && viewLinker->mainView() == activeView)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!proj->viewLinkerCollection()->viewLinker())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicSetMasterViewFeature::onActionTriggered(bool isChecked)
|
||||||
|
{
|
||||||
|
RimView* activeView = RiaApplication::instance()->activeReservoirView();
|
||||||
|
if (!activeView) return;
|
||||||
|
|
||||||
|
RimProject* proj = RiaApplication::instance()->project();
|
||||||
|
RimViewLinker* viewLinker = proj->viewLinkerCollection()->viewLinker();
|
||||||
|
|
||||||
|
RimView* previousMasterView = viewLinker->mainView();
|
||||||
|
|
||||||
|
RimViewLink* previousViewLink = viewLinker->viewLinkFromView(activeView);
|
||||||
|
if (previousViewLink)
|
||||||
|
{
|
||||||
|
size_t indexToErase = cvf::UNDEFINED_SIZE_T;
|
||||||
|
for (size_t i = 0; i < viewLinker->viewLinks.size(); i++)
|
||||||
|
{
|
||||||
|
if (viewLinker->viewLinks()[i] == previousViewLink)
|
||||||
|
{
|
||||||
|
indexToErase = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (indexToErase != cvf::UNDEFINED_SIZE_T)
|
||||||
|
{
|
||||||
|
viewLinker->viewLinks().erase(indexToErase);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete previousViewLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
viewLinker->removeOverrides();
|
||||||
|
viewLinker->setMainView(activeView);
|
||||||
|
|
||||||
|
if (previousMasterView)
|
||||||
|
{
|
||||||
|
RimViewLink* viewLink = new RimViewLink;
|
||||||
|
viewLink->setManagedView(previousMasterView);
|
||||||
|
|
||||||
|
viewLinker->viewLinks.push_back(viewLink);
|
||||||
|
|
||||||
|
viewLink->initAfterReadRecursively();
|
||||||
|
viewLink->updateOptionSensitivity();
|
||||||
|
viewLink->updateUiIconFromActiveState();
|
||||||
|
}
|
||||||
|
|
||||||
|
viewLinker->applyAllOperations();
|
||||||
|
proj->viewLinkerCollection.uiCapability()->updateConnectedEditors();
|
||||||
|
proj->updateConnectedEditors();
|
||||||
|
|
||||||
|
// Set managed view collection to selected and expanded in project tree
|
||||||
|
caf::PdmUiTreeView* projTreeView = RiuMainWindow::instance()->projectTreeView();
|
||||||
|
QModelIndex modIndex = projTreeView->findModelIndex(viewLinker);
|
||||||
|
projTreeView->treeView()->setCurrentIndex(modIndex);
|
||||||
|
|
||||||
|
projTreeView->treeView()->setExpanded(modIndex, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicSetMasterViewFeature::setupActionLook(QAction* actionToSetup)
|
||||||
|
{
|
||||||
|
actionToSetup->setText("Set As Master View");
|
||||||
|
}
|
||||||
|
|
||||||
38
ApplicationCode/Commands/ViewLink/RicSetMasterViewFeature.h
Normal file
38
ApplicationCode/Commands/ViewLink/RicSetMasterViewFeature.h
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
class RicSetMasterViewFeature : public caf::CmdFeature
|
||||||
|
{
|
||||||
|
CAF_CMD_HEADER_INIT;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Overrides
|
||||||
|
virtual bool isCommandEnabled();
|
||||||
|
virtual void onActionTriggered( bool isChecked );
|
||||||
|
virtual void setupActionLook(QAction* actionToSetup);
|
||||||
|
};
|
||||||
@@ -666,17 +666,16 @@ void RimProject::actionsBasedOnSelection(QMenu& contextMenu)
|
|||||||
commandIds << "RicNewViewFeature";
|
commandIds << "RicNewViewFeature";
|
||||||
commandIds << "RicCopyReferencesToClipboardFeature";
|
commandIds << "RicCopyReferencesToClipboardFeature";
|
||||||
commandIds << "RicPasteGeoMechViewsFeature";
|
commandIds << "RicPasteGeoMechViewsFeature";
|
||||||
commandIds << "Separator";
|
|
||||||
commandIds << "RicDeleteItemFeature";
|
commandIds << "RicDeleteItemFeature";
|
||||||
|
commandIds << "Separator";
|
||||||
}
|
}
|
||||||
else if (dynamic_cast<RimEclipseView*>(uiItem))
|
else if (dynamic_cast<RimEclipseView*>(uiItem))
|
||||||
{
|
{
|
||||||
commandIds << "RicNewViewFeature";
|
commandIds << "RicNewViewFeature";
|
||||||
|
|
||||||
commandIds << "RicCopyReferencesToClipboardFeature";
|
commandIds << "RicCopyReferencesToClipboardFeature";
|
||||||
commandIds << "RicPasteEclipseViewsFeature";
|
commandIds << "RicPasteEclipseViewsFeature";
|
||||||
commandIds << "Separator";
|
|
||||||
commandIds << "RicDeleteItemFeature";
|
commandIds << "RicDeleteItemFeature";
|
||||||
|
commandIds << "Separator";
|
||||||
}
|
}
|
||||||
else if (dynamic_cast<RimCaseCollection*>(uiItem))
|
else if (dynamic_cast<RimCaseCollection*>(uiItem))
|
||||||
{
|
{
|
||||||
@@ -685,9 +684,6 @@ void RimProject::actionsBasedOnSelection(QMenu& contextMenu)
|
|||||||
}
|
}
|
||||||
else if (dynamic_cast<RimEclipseStatisticsCase*>(uiItem))
|
else if (dynamic_cast<RimEclipseStatisticsCase*>(uiItem))
|
||||||
{
|
{
|
||||||
//menu.addAction(QString("New View"), this, SLOT(slotAddView()));
|
|
||||||
//menu.addAction(QString("Compute"), this, SLOT(slotComputeStatistics()));
|
|
||||||
//menu.addAction(QString("Close"), this, SLOT(slotCloseCase()));
|
|
||||||
commandIds << "RicNewViewFeature";
|
commandIds << "RicNewViewFeature";
|
||||||
commandIds << "RicComputeStatisticsFeature";
|
commandIds << "RicComputeStatisticsFeature";
|
||||||
commandIds << "RicCloseCaseFeature";
|
commandIds << "RicCloseCaseFeature";
|
||||||
@@ -829,6 +825,11 @@ void RimProject::actionsBasedOnSelection(QMenu& contextMenu)
|
|||||||
{
|
{
|
||||||
commandIds << "RicAddWellLogToPlotFeature";
|
commandIds << "RicAddWellLogToPlotFeature";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dynamic_cast<RimView*>(uiItem))
|
||||||
|
{
|
||||||
|
commandIds << "RicSetMasterViewFeature";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RicToggleItemsFeatureImpl::isToggleCommandsAvailable())
|
if (RicToggleItemsFeatureImpl::isToggleCommandsAvailable())
|
||||||
|
|||||||
@@ -207,6 +207,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
|
|||||||
commandIds << "RicLinkViewFeature";
|
commandIds << "RicLinkViewFeature";
|
||||||
commandIds << "RicUnLinkViewFeature";
|
commandIds << "RicUnLinkViewFeature";
|
||||||
commandIds << "RicShowLinkOptionsFeature";
|
commandIds << "RicShowLinkOptionsFeature";
|
||||||
|
commandIds << "RicSetMasterViewFeature";
|
||||||
|
|
||||||
bool firstLinkAction = true;
|
bool firstLinkAction = true;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user