mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#446) Added link view commands to context menu in 3D view
This commit is contained in:
parent
0fd5638c6b
commit
708e34045d
@ -8,12 +8,18 @@ set (SOURCE_GROUP_HEADER_FILES
|
|||||||
${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeature.h
|
${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeature.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeatureUi.h
|
${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeatureUi.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicShowAllLinkedViewsFeature.h
|
${CEE_CURRENT_LIST_DIR}RicShowAllLinkedViewsFeature.h
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicLinkViewFeature.h
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicUnLinkViewFeature.h
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicShowLinkOptionsFeature.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set (SOURCE_GROUP_SOURCE_FILES
|
set (SOURCE_GROUP_SOURCE_FILES
|
||||||
${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeature.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeatureUi.cpp
|
${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeatureUi.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicShowAllLinkedViewsFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicShowAllLinkedViewsFeature.cpp
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicLinkViewFeature.cpp
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicUnLinkViewFeature.cpp
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicShowLinkOptionsFeature.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND CODE_HEADER_FILES
|
list(APPEND CODE_HEADER_FILES
|
||||||
|
74
ApplicationCode/Commands/ViewLink/RicLinkViewFeature.cpp
Normal file
74
ApplicationCode/Commands/ViewLink/RicLinkViewFeature.cpp
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 "RicLinkViewFeature.h"
|
||||||
|
|
||||||
|
#include "RiaApplication.h"
|
||||||
|
|
||||||
|
#include "RicLinkVisibleViewsFeature.h"
|
||||||
|
|
||||||
|
#include "RimProject.h"
|
||||||
|
#include "RimView.h"
|
||||||
|
|
||||||
|
#include "cafSelectionManager.h"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
|
||||||
|
CAF_CMD_SOURCE_INIT(RicLinkViewFeature, "RicLinkViewFeature");
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RicLinkViewFeature::isCommandEnabled()
|
||||||
|
{
|
||||||
|
RimView* activeView = RiaApplication::instance()->activeReservoirView();
|
||||||
|
if (!activeView) return false;
|
||||||
|
|
||||||
|
RimProject* proj = RiaApplication::instance()->project();
|
||||||
|
if (!proj->findViewLinkerFromView(activeView))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicLinkViewFeature::onActionTriggered(bool isChecked)
|
||||||
|
{
|
||||||
|
RimView* activeView = RiaApplication::instance()->activeReservoirView();
|
||||||
|
if (!activeView) return;
|
||||||
|
|
||||||
|
std::vector<RimView*> views;
|
||||||
|
views.push_back(activeView);
|
||||||
|
|
||||||
|
RicLinkVisibleViewsFeature::linkViews(views);
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicLinkViewFeature::setupActionLook(QAction* actionToSetup)
|
||||||
|
{
|
||||||
|
actionToSetup->setText("Link View");
|
||||||
|
actionToSetup->setIcon(QIcon(":/chain.png"));
|
||||||
|
}
|
||||||
|
|
38
ApplicationCode/Commands/ViewLink/RicLinkViewFeature.h
Normal file
38
ApplicationCode/Commands/ViewLink/RicLinkViewFeature.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 RicLinkViewFeature : public caf::CmdFeature
|
||||||
|
{
|
||||||
|
CAF_CMD_HEADER_INIT;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Overrides
|
||||||
|
virtual bool isCommandEnabled();
|
||||||
|
virtual void onActionTriggered( bool isChecked );
|
||||||
|
virtual void setupActionLook(QAction* actionToSetup);
|
||||||
|
};
|
@ -60,11 +60,72 @@ bool RicLinkVisibleViewsFeature::isCommandEnabled()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RicLinkVisibleViewsFeature::onActionTriggered(bool isChecked)
|
void RicLinkVisibleViewsFeature::onActionTriggered(bool isChecked)
|
||||||
{
|
{
|
||||||
RimProject* proj = RiaApplication::instance()->project();
|
|
||||||
|
|
||||||
std::vector<RimView*> views;
|
std::vector<RimView*> views;
|
||||||
findNotLinkedVisibleViews(views);
|
findNotLinkedVisibleViews(views);
|
||||||
|
|
||||||
|
linkViews(views);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicLinkVisibleViewsFeature::setupActionLook(QAction* actionToSetup)
|
||||||
|
{
|
||||||
|
actionToSetup->setText("Link Visible Views");
|
||||||
|
actionToSetup->setIcon(QIcon(":/chain.png"));
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicLinkVisibleViewsFeature::allLinkedViews(std::vector<RimView*>& views)
|
||||||
|
{
|
||||||
|
RimProject* proj = RiaApplication::instance()->project();
|
||||||
|
for (size_t i = 0; i < proj->viewLinkerCollection()->viewLinkers().size(); i++)
|
||||||
|
{
|
||||||
|
RimViewLinker* linkedViews = proj->viewLinkerCollection()->viewLinkers()[i];
|
||||||
|
linkedViews->allViews(views);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicLinkVisibleViewsFeature::findNotLinkedVisibleViews(std::vector<RimView*> &views)
|
||||||
|
{
|
||||||
|
RimProject* proj = RiaApplication::instance()->project();
|
||||||
|
|
||||||
|
std::vector<RimView*> alreadyLinkedViews;
|
||||||
|
allLinkedViews(alreadyLinkedViews);
|
||||||
|
|
||||||
|
std::vector<RimView*> visibleViews;
|
||||||
|
proj->allVisibleViews(visibleViews);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < visibleViews.size(); i++)
|
||||||
|
{
|
||||||
|
bool isLinked = false;
|
||||||
|
for (size_t j = 0; j < alreadyLinkedViews.size(); j++)
|
||||||
|
{
|
||||||
|
if (visibleViews[i] == alreadyLinkedViews[j])
|
||||||
|
{
|
||||||
|
isLinked = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isLinked)
|
||||||
|
{
|
||||||
|
views.push_back(visibleViews[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicLinkVisibleViewsFeature::linkViews(std::vector<RimView*>& views)
|
||||||
|
{
|
||||||
|
RimProject* proj = RiaApplication::instance()->project();
|
||||||
RimViewLinker* viewLinker = NULL;
|
RimViewLinker* viewLinker = NULL;
|
||||||
|
|
||||||
if (proj->viewLinkerCollection->viewLinkers().size() > 0)
|
if (proj->viewLinkerCollection->viewLinkers().size() > 0)
|
||||||
@ -139,56 +200,3 @@ void RicLinkVisibleViewsFeature::onActionTriggered(bool isChecked)
|
|||||||
projTreeView->treeView()->setExpanded(modIndex, true);
|
projTreeView->treeView()->setExpanded(modIndex, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RicLinkVisibleViewsFeature::setupActionLook(QAction* actionToSetup)
|
|
||||||
{
|
|
||||||
actionToSetup->setText("Link Visible Views");
|
|
||||||
actionToSetup->setIcon(QIcon(":/chain.png"));
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RicLinkVisibleViewsFeature::allLinkedViews(std::vector<RimView*>& views)
|
|
||||||
{
|
|
||||||
RimProject* proj = RiaApplication::instance()->project();
|
|
||||||
for (size_t i = 0; i < proj->viewLinkerCollection()->viewLinkers().size(); i++)
|
|
||||||
{
|
|
||||||
RimViewLinker* linkedViews = proj->viewLinkerCollection()->viewLinkers()[i];
|
|
||||||
linkedViews->allViews(views);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RicLinkVisibleViewsFeature::findNotLinkedVisibleViews(std::vector<RimView*> &views)
|
|
||||||
{
|
|
||||||
RimProject* proj = RiaApplication::instance()->project();
|
|
||||||
|
|
||||||
std::vector<RimView*> alreadyLinkedViews;
|
|
||||||
allLinkedViews(alreadyLinkedViews);
|
|
||||||
|
|
||||||
std::vector<RimView*> visibleViews;
|
|
||||||
proj->allVisibleViews(visibleViews);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < visibleViews.size(); i++)
|
|
||||||
{
|
|
||||||
bool isLinked = false;
|
|
||||||
for (size_t j = 0; j < alreadyLinkedViews.size(); j++)
|
|
||||||
{
|
|
||||||
if (visibleViews[i] == alreadyLinkedViews[j])
|
|
||||||
{
|
|
||||||
isLinked = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isLinked)
|
|
||||||
{
|
|
||||||
views.push_back(visibleViews[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -32,6 +32,9 @@ class RicLinkVisibleViewsFeature : public caf::CmdFeature
|
|||||||
{
|
{
|
||||||
CAF_CMD_HEADER_INIT;
|
CAF_CMD_HEADER_INIT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static void linkViews(std::vector<RimView*> &views);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Overrides
|
// Overrides
|
||||||
virtual bool isCommandEnabled();
|
virtual bool isCommandEnabled();
|
||||||
|
@ -0,0 +1,93 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 "RicShowLinkOptionsFeature.h"
|
||||||
|
|
||||||
|
#include "RiaApplication.h"
|
||||||
|
#include "RimProject.h"
|
||||||
|
#include "RimView.h"
|
||||||
|
#include "RimViewLink.h"
|
||||||
|
#include "RimViewLinker.h"
|
||||||
|
#include "RiuMainWindow.h"
|
||||||
|
|
||||||
|
#include "cafSelectionManager.h"
|
||||||
|
#include "cafPdmUiTreeView.h"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
|
||||||
|
|
||||||
|
CAF_CMD_SOURCE_INIT(RicShowLinkOptionsFeature, "RicShowLinkOptionsFeature");
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RicShowLinkOptionsFeature::isCommandEnabled()
|
||||||
|
{
|
||||||
|
RimView* activeView = RiaApplication::instance()->activeReservoirView();
|
||||||
|
if (!activeView) return false;
|
||||||
|
|
||||||
|
RimProject* proj = RiaApplication::instance()->project();
|
||||||
|
if (proj->findViewLinkerFromView(activeView))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicShowLinkOptionsFeature::onActionTriggered(bool isChecked)
|
||||||
|
{
|
||||||
|
RimView* activeView = RiaApplication::instance()->activeReservoirView();
|
||||||
|
if (!activeView) return;
|
||||||
|
|
||||||
|
RimProject* proj = RiaApplication::instance()->project();
|
||||||
|
RimViewLinker* viewLinker = proj->findViewLinkerFromView(activeView);
|
||||||
|
if (viewLinker)
|
||||||
|
{
|
||||||
|
if (viewLinker->mainView() == activeView)
|
||||||
|
{
|
||||||
|
RiuMainWindow::instance()->projectTreeView()->selectAsCurrentItem(viewLinker);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < viewLinker->viewLinks.size(); i++)
|
||||||
|
{
|
||||||
|
RimViewLink* viewLink = viewLinker->viewLinks[i];
|
||||||
|
if (viewLink->managedView() == activeView)
|
||||||
|
{
|
||||||
|
RiuMainWindow::instance()->projectTreeView()->selectAsCurrentItem(viewLink);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicShowLinkOptionsFeature::setupActionLook(QAction* actionToSetup)
|
||||||
|
{
|
||||||
|
actionToSetup->setText("Show Link Options");
|
||||||
|
}
|
||||||
|
|
@ -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 RicShowLinkOptionsFeature : public caf::CmdFeature
|
||||||
|
{
|
||||||
|
CAF_CMD_HEADER_INIT;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Overrides
|
||||||
|
virtual bool isCommandEnabled();
|
||||||
|
virtual void onActionTriggered( bool isChecked );
|
||||||
|
virtual void setupActionLook(QAction* actionToSetup);
|
||||||
|
};
|
96
ApplicationCode/Commands/ViewLink/RicUnLinkViewFeature.cpp
Normal file
96
ApplicationCode/Commands/ViewLink/RicUnLinkViewFeature.cpp
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 "RicUnLinkViewFeature.h"
|
||||||
|
|
||||||
|
#include "RimViewLink.h"
|
||||||
|
#include "RimView.h"
|
||||||
|
#include "RimViewLinker.h"
|
||||||
|
|
||||||
|
#include "cafSelectionManager.h"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
#include "RiaApplication.h"
|
||||||
|
#include "RimProject.h"
|
||||||
|
#include "cafCmdFeatureManager.h"
|
||||||
|
|
||||||
|
CAF_CMD_SOURCE_INIT(RicUnLinkViewFeature, "RicUnLinkViewFeature");
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RicUnLinkViewFeature::isCommandEnabled()
|
||||||
|
{
|
||||||
|
RimView* activeView = RiaApplication::instance()->activeReservoirView();
|
||||||
|
if (!activeView) return false;
|
||||||
|
|
||||||
|
RimProject* proj = RiaApplication::instance()->project();
|
||||||
|
RimViewLinker* viewLinker = proj->findViewLinkerFromView(activeView);
|
||||||
|
if (viewLinker)
|
||||||
|
{
|
||||||
|
if (viewLinker->mainView() == activeView)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicUnLinkViewFeature::onActionTriggered(bool isChecked)
|
||||||
|
{
|
||||||
|
RimView* activeView = RiaApplication::instance()->activeReservoirView();
|
||||||
|
if (!activeView) return;
|
||||||
|
|
||||||
|
RimProject* proj = RiaApplication::instance()->project();
|
||||||
|
RimViewLinker* viewLinker = proj->findViewLinkerFromView(activeView);
|
||||||
|
if (viewLinker)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < viewLinker->viewLinks.size(); i++)
|
||||||
|
{
|
||||||
|
RimViewLink* viewLink = viewLinker->viewLinks[i];
|
||||||
|
if (viewLink->managedView() == activeView)
|
||||||
|
{
|
||||||
|
caf::SelectionManager::instance()->setSelectedItem(viewLink);
|
||||||
|
|
||||||
|
caf::CmdFeature* feature = caf::CmdFeatureManager::instance()->getCommandFeature("RicDeleteItemFeature");
|
||||||
|
if (feature)
|
||||||
|
{
|
||||||
|
feature->action()->trigger();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicUnLinkViewFeature::setupActionLook(QAction* actionToSetup)
|
||||||
|
{
|
||||||
|
actionToSetup->setText("Unlink View");
|
||||||
|
}
|
||||||
|
|
38
ApplicationCode/Commands/ViewLink/RicUnLinkViewFeature.h
Normal file
38
ApplicationCode/Commands/ViewLink/RicUnLinkViewFeature.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 RicUnLinkViewFeature : public caf::CmdFeature
|
||||||
|
{
|
||||||
|
CAF_CMD_HEADER_INIT;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Overrides
|
||||||
|
virtual bool isCommandEnabled();
|
||||||
|
virtual void onActionTriggered( bool isChecked );
|
||||||
|
virtual void setupActionLook(QAction* actionToSetup);
|
||||||
|
};
|
@ -18,52 +18,59 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "RiuViewerCommands.h"
|
#include "RiuViewerCommands.h"
|
||||||
#include "RiuViewer.h"
|
|
||||||
|
#include "RiaApplication.h"
|
||||||
|
|
||||||
|
#include "RicEclipsePropertyFilterNewExec.h"
|
||||||
|
#include "RicGeoMechPropertyFilterNewExec.h"
|
||||||
|
#include "RicRangeFilterNewExec.h"
|
||||||
|
|
||||||
|
#include "RigCaseData.h"
|
||||||
|
#include "RigFemPartCollection.h"
|
||||||
|
#include "RigFemPartGrid.h"
|
||||||
|
#include "RigGeoMechCaseData.h"
|
||||||
|
|
||||||
#include "RimCellRangeFilter.h"
|
#include "RimCellRangeFilter.h"
|
||||||
#include "RimView.h"
|
|
||||||
#include "RimCellRangeFilterCollection.h"
|
#include "RimCellRangeFilterCollection.h"
|
||||||
#include "RimEclipseCase.h"
|
#include "RimEclipseCase.h"
|
||||||
#include "RimEclipseView.h"
|
|
||||||
#include "RimGeoMechView.h"
|
|
||||||
#include "RimFaultCollection.h"
|
|
||||||
#include "RimEclipseCellColors.h"
|
#include "RimEclipseCellColors.h"
|
||||||
#include "RimEclipsePropertyFilter.h"
|
#include "RimEclipsePropertyFilter.h"
|
||||||
#include "RimEclipsePropertyFilterCollection.h"
|
#include "RimEclipsePropertyFilterCollection.h"
|
||||||
#include "RimGeoMechView.h"
|
#include "RimEclipseView.h"
|
||||||
|
#include "RimFaultCollection.h"
|
||||||
|
#include "RimGeoMechCase.h"
|
||||||
|
#include "RimGeoMechCellColors.h"
|
||||||
#include "RimGeoMechPropertyFilter.h"
|
#include "RimGeoMechPropertyFilter.h"
|
||||||
#include "RimGeoMechPropertyFilterCollection.h"
|
#include "RimGeoMechPropertyFilterCollection.h"
|
||||||
#include "RimGeoMechCellColors.h"
|
#include "RimGeoMechView.h"
|
||||||
#include "RimProject.h"
|
#include "RimGeoMechView.h"
|
||||||
#include "RimOilField.h"
|
#include "RimOilField.h"
|
||||||
#include "RimWellPathCollection.h"
|
#include "RimProject.h"
|
||||||
|
#include "RimView.h"
|
||||||
#include "RimWellPath.h"
|
#include "RimWellPath.h"
|
||||||
|
#include "RimWellPathCollection.h"
|
||||||
|
|
||||||
|
#include "RiuFemResultTextBuilder.h"
|
||||||
|
#include "RiuMainWindow.h"
|
||||||
|
#include "RiuResultTextBuilder.h"
|
||||||
|
#include "RiuViewer.h"
|
||||||
|
|
||||||
|
#include "RivFemPartGeometryGenerator.h"
|
||||||
|
#include "RivFemPickSourceInfo.h"
|
||||||
#include "RivSourceInfo.h"
|
#include "RivSourceInfo.h"
|
||||||
#include "RivWellPathSourceInfo.h"
|
#include "RivWellPathSourceInfo.h"
|
||||||
#include "RivFemPickSourceInfo.h"
|
|
||||||
#include "RivFemPartGeometryGenerator.h"
|
#include "cafCmdExecCommandManager.h"
|
||||||
#include "RigCaseData.h"
|
#include "cafCmdFeature.h"
|
||||||
#include "RiuMainWindow.h"
|
#include "cafCmdFeatureManager.h"
|
||||||
#include "RiaApplication.h"
|
|
||||||
#include "RiuResultTextBuilder.h"
|
|
||||||
#include "RigGeoMechCaseData.h"
|
|
||||||
#include "RimGeoMechCase.h"
|
|
||||||
#include "RigFemPartCollection.h"
|
|
||||||
#include "RigFemPartGrid.h"
|
|
||||||
|
|
||||||
#include "cvfDrawableGeo.h"
|
#include "cvfDrawableGeo.h"
|
||||||
#include "cvfPart.h"
|
|
||||||
#include "cvfHitItemCollection.h"
|
#include "cvfHitItemCollection.h"
|
||||||
|
#include "cvfPart.h"
|
||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
|
||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
#include "RiuFemResultTextBuilder.h"
|
|
||||||
#include "RicRangeFilterNewExec.h"
|
|
||||||
#include "cafCmdExecCommandManager.h"
|
|
||||||
#include "RicGeoMechPropertyFilterNewExec.h"
|
|
||||||
#include "RicEclipsePropertyFilterNewExec.h"
|
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
//
|
//
|
||||||
@ -107,6 +114,8 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
|
|||||||
int winPosX = event->x();
|
int winPosX = event->x();
|
||||||
int winPosY = event->y();
|
int winPosY = event->y();
|
||||||
|
|
||||||
|
QMenu menu;
|
||||||
|
|
||||||
uint faceIndex = cvf::UNDEFINED_UINT;
|
uint faceIndex = cvf::UNDEFINED_UINT;
|
||||||
cvf::Vec3d localIntersectionPoint(cvf::Vec3d::ZERO);
|
cvf::Vec3d localIntersectionPoint(cvf::Vec3d::ZERO);
|
||||||
|
|
||||||
@ -120,77 +129,107 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
|
|||||||
extractIntersectionData(hitItems, &localIntersectionPoint, &firstHitPart, &faceIndex, &nncFirstHitPart, NULL);
|
extractIntersectionData(hitItems, &localIntersectionPoint, &firstHitPart, &faceIndex, &nncFirstHitPart, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!firstHitPart) return;
|
if (firstHitPart && faceIndex != cvf::UNDEFINED_UINT)
|
||||||
|
|
||||||
if (faceIndex == cvf::UNDEFINED_UINT) return;
|
|
||||||
|
|
||||||
if (!firstHitPart->sourceInfo()) return;
|
|
||||||
|
|
||||||
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>(firstHitPart->sourceInfo());
|
|
||||||
const RivFemPickSourceInfo* femSourceInfo = dynamic_cast<const RivFemPickSourceInfo*>(firstHitPart->sourceInfo());
|
|
||||||
|
|
||||||
if (!(rivSourceInfo || femSourceInfo) ) return;
|
|
||||||
|
|
||||||
if (rivSourceInfo)
|
|
||||||
{
|
{
|
||||||
if (!rivSourceInfo->hasCellFaceMapping()) return;
|
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>(firstHitPart->sourceInfo());
|
||||||
|
const RivFemPickSourceInfo* femSourceInfo = dynamic_cast<const RivFemPickSourceInfo*>(firstHitPart->sourceInfo());
|
||||||
|
|
||||||
// Set the data regarding what was hit
|
if (rivSourceInfo || femSourceInfo)
|
||||||
|
|
||||||
m_currentGridIdx = rivSourceInfo->gridIndex();
|
|
||||||
m_currentCellIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellIndex(faceIndex);
|
|
||||||
m_currentFaceIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellFace(faceIndex);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_currentGridIdx = femSourceInfo->femPartIndex();
|
|
||||||
m_currentCellIndex = femSourceInfo->triangleToElmMapper()->elementIndex(faceIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
// IJK -slice commands
|
|
||||||
|
|
||||||
QMenu menu;
|
|
||||||
|
|
||||||
menu.addAction(QString("I-slice range filter"), this, SLOT(slotRangeFilterI()));
|
|
||||||
menu.addAction(QString("J-slice range filter"), this, SLOT(slotRangeFilterJ()));
|
|
||||||
menu.addAction(QString("K-slice range filter"), this, SLOT(slotRangeFilterK()));
|
|
||||||
|
|
||||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
|
|
||||||
if (eclipseView)
|
|
||||||
{
|
|
||||||
RimEclipseCellColors* cellColors = eclipseView->cellResult().p();
|
|
||||||
if (cellColors)
|
|
||||||
{
|
{
|
||||||
QAction* propertyAction = new QAction(QString("Add property filter"), this);
|
if (rivSourceInfo)
|
||||||
connect(propertyAction, SIGNAL(triggered()), SLOT(slotAddEclipsePropertyFilter()));
|
|
||||||
|
|
||||||
bool isPerCellFaceResult = RimDefines::isPerCellFaceResult(cellColors->resultVariable());
|
|
||||||
if (isPerCellFaceResult)
|
|
||||||
{
|
{
|
||||||
propertyAction->setEnabled(false);
|
if (!rivSourceInfo->hasCellFaceMapping()) return;
|
||||||
|
|
||||||
|
// Set the data regarding what was hit
|
||||||
|
|
||||||
|
m_currentGridIdx = rivSourceInfo->gridIndex();
|
||||||
|
m_currentCellIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellIndex(faceIndex);
|
||||||
|
m_currentFaceIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellFace(faceIndex);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_currentGridIdx = femSourceInfo->femPartIndex();
|
||||||
|
m_currentCellIndex = femSourceInfo->triangleToElmMapper()->elementIndex(faceIndex);
|
||||||
}
|
}
|
||||||
menu.addAction(propertyAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hide faults command
|
// IJK -slice commands
|
||||||
const RigCaseData* reservoir = eclipseView->eclipseCase()->reservoirData();
|
|
||||||
const RigFault* fault = reservoir->mainGrid()->findFaultFromCellIndexAndCellFace(m_currentCellIndex, m_currentFaceIndex);
|
menu.addAction(QString("I-slice range filter"), this, SLOT(slotRangeFilterI()));
|
||||||
if (fault)
|
menu.addAction(QString("J-slice range filter"), this, SLOT(slotRangeFilterJ()));
|
||||||
{
|
menu.addAction(QString("K-slice range filter"), this, SLOT(slotRangeFilterK()));
|
||||||
menu.addSeparator();
|
|
||||||
|
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
|
||||||
|
if (eclipseView)
|
||||||
|
{
|
||||||
|
RimEclipseCellColors* cellColors = eclipseView->cellResult().p();
|
||||||
|
if (cellColors)
|
||||||
|
{
|
||||||
|
QAction* propertyAction = new QAction(QString("Add property filter"), this);
|
||||||
|
connect(propertyAction, SIGNAL(triggered()), SLOT(slotAddEclipsePropertyFilter()));
|
||||||
|
|
||||||
|
bool isPerCellFaceResult = RimDefines::isPerCellFaceResult(cellColors->resultVariable());
|
||||||
|
if (isPerCellFaceResult)
|
||||||
|
{
|
||||||
|
propertyAction->setEnabled(false);
|
||||||
|
}
|
||||||
|
menu.addAction(propertyAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hide faults command
|
||||||
|
const RigCaseData* reservoir = eclipseView->eclipseCase()->reservoirData();
|
||||||
|
const RigFault* fault = reservoir->mainGrid()->findFaultFromCellIndexAndCellFace(m_currentCellIndex, m_currentFaceIndex);
|
||||||
|
if (fault)
|
||||||
|
{
|
||||||
|
menu.addSeparator();
|
||||||
|
|
||||||
|
QString faultName = fault->name();
|
||||||
|
menu.addAction(QString("Hide ") + faultName, this, SLOT(slotHideFault()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RimGeoMechView* geoMechView = dynamic_cast<RimGeoMechView*>(m_reservoirView.p());
|
||||||
|
if (geoMechView)
|
||||||
|
{
|
||||||
|
RimGeoMechCellColors* cellColors = geoMechView->cellResult().p();
|
||||||
|
if (cellColors)
|
||||||
|
{
|
||||||
|
menu.addAction(QString("Add property filter"), this, SLOT(slotAddGeoMechPropertyFilter()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString faultName = fault->name();
|
|
||||||
menu.addAction(QString("Hide ") + faultName, this, SLOT(slotHideFault()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RimGeoMechView* geoMechView = dynamic_cast<RimGeoMechView*>(m_reservoirView.p());
|
// View Link commands
|
||||||
if (geoMechView)
|
|
||||||
{
|
{
|
||||||
RimGeoMechCellColors* cellColors = geoMechView->cellResult().p();
|
QStringList commandIds;
|
||||||
if (cellColors)
|
|
||||||
|
commandIds << "RicLinkViewFeature";
|
||||||
|
commandIds << "RicUnLinkViewFeature";
|
||||||
|
commandIds << "RicShowLinkOptionsFeature";
|
||||||
|
|
||||||
|
bool firstLinkAction = true;
|
||||||
|
|
||||||
|
caf::CmdFeatureManager* commandManager = caf::CmdFeatureManager::instance();
|
||||||
|
for (int i = 0; i < commandIds.size(); i++)
|
||||||
{
|
{
|
||||||
menu.addAction(QString("Add property filter"), this, SLOT(slotAddGeoMechPropertyFilter()));
|
caf::CmdFeature* feature = commandManager->getCommandFeature(commandIds[i].toStdString());
|
||||||
|
if (feature->canFeatureBeExecuted())
|
||||||
|
{
|
||||||
|
QAction* act = commandManager->action(commandIds[i]);
|
||||||
|
CVF_ASSERT(act);
|
||||||
|
|
||||||
|
if (firstLinkAction)
|
||||||
|
{
|
||||||
|
if (menu.actions().size() > 0)
|
||||||
|
{
|
||||||
|
menu.addSeparator();
|
||||||
|
}
|
||||||
|
firstLinkAction = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
menu.addAction(act);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user