(#446) Added link view commands to context menu in 3D view

This commit is contained in:
Magne Sjaastad
2015-09-15 16:28:17 +02:00
parent 0fd5638c6b
commit 708e34045d
10 changed files with 573 additions and 140 deletions

View File

@@ -8,12 +8,18 @@ set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeature.h
${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeatureUi.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
${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeatureUi.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

View 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"));
}

View 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);
};

View File

@@ -60,11 +60,72 @@ bool RicLinkVisibleViewsFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicLinkVisibleViewsFeature::onActionTriggered(bool isChecked)
{
RimProject* proj = RiaApplication::instance()->project();
std::vector<RimView*> 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;
if (proj->viewLinkerCollection->viewLinkers().size() > 0)
@@ -139,56 +200,3 @@ void RicLinkVisibleViewsFeature::onActionTriggered(bool isChecked)
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]);
}
}
}

View File

@@ -32,6 +32,9 @@ class RicLinkVisibleViewsFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static void linkViews(std::vector<RimView*> &views);
protected:
// Overrides
virtual bool isCommandEnabled();

View File

@@ -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");
}

View 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 RicShowLinkOptionsFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook(QAction* actionToSetup);
};

View 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");
}

View 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);
};