mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#395) Hide master view in property view, use view icons in tree view
This commit is contained in:
@@ -52,6 +52,7 @@ ${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicWellPathsDeleteAllFeature.h
|
||||
|
||||
${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeatureUi.h
|
||||
|
||||
|
||||
# General delete of any object in a child array field
|
||||
@@ -107,6 +108,7 @@ ${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicWellPathsDeleteAllFeature.cpp
|
||||
|
||||
${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeatureUi.cpp
|
||||
|
||||
# General delete of any object in a child array field
|
||||
${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.cpp
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
|
||||
#include <QAction>
|
||||
#include <QTreeView>
|
||||
#include "RicLinkVisibleViewsFeatureUi.h"
|
||||
#include "cafPdmUiPropertyViewDialog.h"
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicLinkVisibleViewsFeature, "RicLinkVisibleViewsFeature");
|
||||
|
||||
@@ -58,17 +60,25 @@ void RicLinkVisibleViewsFeature::onActionTriggered(bool isChecked)
|
||||
std::vector<RimView*> views;
|
||||
proj->allVisibleViews(views);
|
||||
CVF_ASSERT(views.size() > 1);
|
||||
|
||||
RimView* masterView = views[0];
|
||||
RimLinkedViews* linkedViews = new RimLinkedViews;
|
||||
linkedViews->mainView = masterView;
|
||||
|
||||
for (size_t i = 1; i < views.size(); i++)
|
||||
RicLinkVisibleViewsFeatureUi featureUi;
|
||||
featureUi.setViews(views);
|
||||
|
||||
caf::PdmUiPropertyViewDialog propertyDialog(NULL, &featureUi, "New View Group", "");
|
||||
propertyDialog.setWindowIcon(QIcon(":/chain.png"));
|
||||
if (propertyDialog.exec() != QDialog::Accepted) return;
|
||||
|
||||
RimView* masterView = featureUi.masterView();
|
||||
RimLinkedViews* linkedViews = new RimLinkedViews;
|
||||
linkedViews->setMainView(masterView);
|
||||
|
||||
for (size_t i = 0; i < views.size(); i++)
|
||||
{
|
||||
RimView* rimView = views[i];
|
||||
if (rimView == masterView) continue;
|
||||
|
||||
RimManagedViewConfig* viewConfig = new RimManagedViewConfig;
|
||||
viewConfig->managedView = rimView;
|
||||
viewConfig->setManagedView(rimView);
|
||||
|
||||
linkedViews->viewConfigs.push_back(viewConfig);
|
||||
|
||||
|
||||
89
ApplicationCode/Commands/RicLinkVisibleViewsFeatureUi.cpp
Normal file
89
ApplicationCode/Commands/RicLinkVisibleViewsFeatureUi.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicLinkVisibleViewsFeatureUi.h"
|
||||
|
||||
#include "cafPdmUiTextEditor.h"
|
||||
#include "cafPdmObjectGroup.h"
|
||||
|
||||
#include "RimView.h"
|
||||
#include "RimLinkedViews.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RicLinkVisibleViewsFeatureUi, "RicLinkVisibleViewsFeatureUi");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicLinkVisibleViewsFeatureUi::RicLinkVisibleViewsFeatureUi(void)
|
||||
{
|
||||
CAF_PDM_InitObject("Link Visible Views Feature UI", ":/chain.png", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_allViewsAsText, "VisibleViews", "Visible Views", "", "", "");
|
||||
m_allViewsAsText.uiCapability()->setUiEditorTypeName(caf::PdmUiTextEditor::uiEditorTypeName());
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_masterView, "MasterView", "Master View", "", "", "");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicLinkVisibleViewsFeatureUi::setViews(const std::vector<RimView*>& allViews)
|
||||
{
|
||||
m_allViews = allViews;
|
||||
|
||||
QString viewNames;
|
||||
for (int i = 0; i < m_allViews.size(); i++)
|
||||
{
|
||||
viewNames += RimLinkedViews::displayNameForView(m_allViews[i]);
|
||||
viewNames += "\n";
|
||||
}
|
||||
m_allViewsAsText = viewNames;
|
||||
|
||||
if (allViews.size() > 0)
|
||||
{
|
||||
m_masterView = allViews[0];
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimView* RicLinkVisibleViewsFeatureUi::masterView()
|
||||
{
|
||||
return m_masterView;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo> RicLinkVisibleViewsFeatureUi::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> optionList;
|
||||
|
||||
if (fieldNeedingOptions == &m_masterView)
|
||||
{
|
||||
for (int i = 0; i < m_allViews.size(); i++)
|
||||
{
|
||||
optionList.push_back(caf::PdmOptionItemInfo(RimLinkedViews::displayNameForView(m_allViews[i]),
|
||||
QVariant::fromValue(caf::PdmPointer<PdmObjectHandle>(m_allViews[i]))));
|
||||
}
|
||||
}
|
||||
|
||||
return optionList;
|
||||
}
|
||||
51
ApplicationCode/Commands/RicLinkVisibleViewsFeatureUi.h
Normal file
51
ApplicationCode/Commands/RicLinkVisibleViewsFeatureUi.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimView;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicLinkVisibleViewsFeatureUi : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RicLinkVisibleViewsFeatureUi(void);
|
||||
|
||||
void setViews(const std::vector<RimView*>& allViews);
|
||||
RimView* masterView();
|
||||
|
||||
protected:
|
||||
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly);
|
||||
|
||||
private:
|
||||
caf::PdmField<QString> m_allViewsAsText;
|
||||
caf::PdmPtrField<RimView*> m_masterView;
|
||||
|
||||
std::vector<RimView*> m_allViews;
|
||||
};
|
||||
Reference in New Issue
Block a user