mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
(#417) Added togglebutton controls to View group
This commit is contained in:
parent
3ca5406bb4
commit
5ce0f6988d
@ -27,6 +27,7 @@
|
||||
#include "RimProject.h"
|
||||
#include "RimView.h"
|
||||
#include "RimViewLinker.h"
|
||||
#include "RimViewLinkerCollection.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
@ -95,8 +96,9 @@ void RicLinkVisibleViewsFeature::onActionTriggered(bool isChecked)
|
||||
viewConfig->updateViewChanged();
|
||||
}
|
||||
|
||||
proj->linkedViews.push_back(linkedViews);
|
||||
proj->linkedViews.uiCapability()->updateConnectedEditors();
|
||||
proj->viewLinkerCollection()->viewLinkers().push_back(linkedViews);
|
||||
linkedViews->updateUiIcon();
|
||||
proj->viewLinkerCollection.uiCapability()->updateConnectedEditors();
|
||||
|
||||
linkedViews->applyAllOperations();
|
||||
proj->updateConnectedEditors();
|
||||
@ -124,9 +126,9 @@ void RicLinkVisibleViewsFeature::setupActionLook(QAction* actionToSetup)
|
||||
void RicLinkVisibleViewsFeature::allLinkedViews(std::vector<RimView*>& views)
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
for (size_t i = 0; i < proj->linkedViews().size(); i++)
|
||||
for (size_t i = 0; i < proj->viewLinkerCollection()->viewLinkers().size(); i++)
|
||||
{
|
||||
RimViewLinker* linkedViews = proj->linkedViews()[i];
|
||||
RimViewLinker* linkedViews = proj->viewLinkerCollection()->viewLinkers()[i];
|
||||
linkedViews->allViews(views);
|
||||
}
|
||||
}
|
||||
|
@ -66,6 +66,7 @@ ${CEE_CURRENT_LIST_DIR}RimWellLogPlot.h
|
||||
${CEE_CURRENT_LIST_DIR}RimWellLogPlotTrace.h
|
||||
${CEE_CURRENT_LIST_DIR}RimWellLogPlotCurve.h
|
||||
${CEE_CURRENT_LIST_DIR}RimViewLinker.h
|
||||
${CEE_CURRENT_LIST_DIR}RimViewLinkerCollection.h
|
||||
${CEE_CURRENT_LIST_DIR}RimWellLogExtractionCurve.h
|
||||
)
|
||||
|
||||
@ -131,6 +132,7 @@ ${CEE_CURRENT_LIST_DIR}RimWellLogPlot.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimWellLogPlotTrace.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimWellLogPlotCurve.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimViewLinker.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimViewLinkerCollection.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimWellLogExtractionCurve.cpp
|
||||
)
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "RimOilField.h"
|
||||
#include "RimScriptCollection.h"
|
||||
#include "RimViewLinker.h"
|
||||
#include "RimViewLinkerCollection.h"
|
||||
#include "RimWellLogPlot.h"
|
||||
#include "RimWellLogPlotCollection.h"
|
||||
#include "RimWellPath.h"
|
||||
@ -92,8 +93,9 @@ RimProject::RimProject(void)
|
||||
CAF_PDM_InitFieldNoDefault(&mainPlotCollection, "MainPlotCollection", "Plots", ":/Default.png", "", "");
|
||||
mainPlotCollection.uiCapability()->setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&linkedViews, "LinkedViews", "Linked Views", ":/chain.png", "", "");
|
||||
linkedViews.uiCapability()->setUiHidden(true);
|
||||
CAF_PDM_InitFieldNoDefault(&viewLinkerCollection, "LinkedViews", "Linked Views (field in RimProject", ":/chain.png", "", "");
|
||||
viewLinkerCollection.uiCapability()->setUiHidden(true);
|
||||
viewLinkerCollection = new RimViewLinkerCollection;
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&commandObjects, "CommandObjects", "CommandObjects", "", "", "");
|
||||
//wellPathImport.uiCapability()->setUiHidden(true);
|
||||
@ -153,7 +155,7 @@ void RimProject::close()
|
||||
|
||||
commandObjects.deleteAllChildObjects();
|
||||
|
||||
linkedViews.deleteAllChildObjects();
|
||||
viewLinkerCollection->viewLinkers().deleteAllChildObjects();
|
||||
|
||||
fileName = "";
|
||||
|
||||
@ -473,9 +475,9 @@ void RimProject::allNotLinkedViews(std::vector<RimView*>& views)
|
||||
allCases(cases);
|
||||
|
||||
std::vector<RimView*> alreadyLinkedViews;
|
||||
for (size_t i = 0; i < linkedViews().size(); i++)
|
||||
for (size_t i = 0; i < viewLinkerCollection->viewLinkers().size(); i++)
|
||||
{
|
||||
RimViewLinker* viewLinker = linkedViews()[i];
|
||||
RimViewLinker* viewLinker = viewLinkerCollection->viewLinkers()[i];
|
||||
viewLinker->allViews(alreadyLinkedViews);
|
||||
}
|
||||
|
||||
@ -930,9 +932,10 @@ void RimProject::appendScriptItems(QMenu* menu, RimScriptCollection* scriptColle
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/)
|
||||
{
|
||||
if (linkedViews.size() > 0)
|
||||
if (viewLinkerCollection()->viewLinkers().size() > 0)
|
||||
{
|
||||
uiTreeOrdering.add(&linkedViews);
|
||||
// Use object instead of field to avoid duplicate entries in the tree view
|
||||
uiTreeOrdering.add(viewLinkerCollection());
|
||||
}
|
||||
|
||||
RimOilField* oilField = activeOilField();
|
||||
@ -964,9 +967,9 @@ void RimProject::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QS
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimViewLinker* RimProject::findViewLinkerFromView(RimView* view)
|
||||
{
|
||||
for (size_t i = 0; i < linkedViews.size(); i++)
|
||||
for (size_t i = 0; i < viewLinkerCollection()->viewLinkers().size(); i++)
|
||||
{
|
||||
RimViewLinker* group = linkedViews[i];
|
||||
RimViewLinker* group = viewLinkerCollection()->viewLinkers()[i];
|
||||
if (view == group->mainView()) return group;
|
||||
|
||||
for (size_t j = 0; j < group->linkedViews.size(); j++)
|
||||
|
@ -34,6 +34,7 @@ class RimCommandObject;
|
||||
class RimEclipseCase;
|
||||
class RimIdenticalGridCaseGroup;
|
||||
class RimViewLinker;
|
||||
class RimViewLinkerCollection;
|
||||
class RimMainPlotCollection;
|
||||
class RimOilField;
|
||||
class RimScriptCollection;
|
||||
@ -65,7 +66,7 @@ public:
|
||||
caf::PdmChildField<RimScriptCollection*> scriptCollection;
|
||||
caf::PdmChildField<RimWellPathImport*> wellPathImport;
|
||||
caf::PdmChildField<RimMainPlotCollection*> mainPlotCollection;
|
||||
caf::PdmChildArrayField<RimViewLinker*> linkedViews;
|
||||
caf::PdmChildField<RimViewLinkerCollection*> viewLinkerCollection;
|
||||
caf::PdmChildArrayField<RimCommandObject*> commandObjects;
|
||||
caf::PdmField<QString> treeViewState;
|
||||
caf::PdmField<QString> currentModelIndexPath;
|
||||
|
@ -23,14 +23,18 @@
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "RimEclipseInputCase.h"
|
||||
#include "RimEclipseResultCase.h"
|
||||
#include "RimEclipseResultDefinition.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RimGeoMechCellColors.h"
|
||||
#include "RimGeoMechResultDefinition.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimLinkedView.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimView.h"
|
||||
#include "RimViewLinkerCollection.h"
|
||||
|
||||
#include "RiuViewer.h"
|
||||
|
||||
@ -335,7 +339,7 @@ void RimViewLinker::setMainView(RimView* view)
|
||||
{
|
||||
m_mainView = view;
|
||||
|
||||
initAfterRead();
|
||||
setNameAndIcon();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -367,18 +371,8 @@ void RimViewLinker::allViews(std::vector<RimView*>& views)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimViewLinker::initAfterRead()
|
||||
{
|
||||
m_name = displayNameForView(m_mainView);
|
||||
|
||||
QIcon icon;
|
||||
if (m_mainView)
|
||||
{
|
||||
RimCase* rimCase = NULL;
|
||||
m_mainView->firstAnchestorOrThisOfType(rimCase);
|
||||
|
||||
icon = rimCase->uiCapability()->uiIcon();
|
||||
}
|
||||
|
||||
this->setUiIcon(icon);
|
||||
setNameAndIcon();
|
||||
updateUiIcon();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -401,6 +395,67 @@ void RimViewLinker::updateScaleZ(RimView* source, double scaleZ)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimViewLinker::isActive()
|
||||
{
|
||||
RimViewLinkerCollection* viewLinkerCollection = NULL;
|
||||
this->firstAnchestorOrThisOfType(viewLinkerCollection);
|
||||
|
||||
if (!viewLinkerCollection->isActive()) return false;
|
||||
|
||||
return m_isActive;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimViewLinker::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
updateUiIcon();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Hande icon update locally as PdmUiItem::updateUiIconFromState works only for static icons
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimViewLinker::updateUiIcon()
|
||||
{
|
||||
QPixmap icPixmap;
|
||||
icPixmap = m_originalIcon.pixmap(16, 16, QIcon::Normal);
|
||||
|
||||
if (!m_isActive)
|
||||
{
|
||||
QIcon temp(icPixmap);
|
||||
icPixmap = temp.pixmap(16, 16, QIcon::Disabled);
|
||||
}
|
||||
|
||||
QIcon newIcon(icPixmap);
|
||||
this->setUiIcon(newIcon);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimViewLinker::setNameAndIcon()
|
||||
{
|
||||
m_name = displayNameForView(m_mainView);
|
||||
|
||||
QIcon icon;
|
||||
if (m_mainView)
|
||||
{
|
||||
RimCase* rimCase = NULL;
|
||||
m_mainView->firstAnchestorOrThisOfType(rimCase);
|
||||
|
||||
if (dynamic_cast<RimGeoMechCase*>(rimCase))
|
||||
{
|
||||
icon = QIcon(":/GeoMechCase48x48.png");
|
||||
}
|
||||
else if (dynamic_cast<RimEclipseResultCase*>(rimCase))
|
||||
{
|
||||
icon = QIcon(":/Case48x48.png");
|
||||
}
|
||||
else if (dynamic_cast<RimEclipseInputCase*>(rimCase))
|
||||
{
|
||||
icon = QIcon(":/EclipseInput48x48.png");
|
||||
}
|
||||
}
|
||||
|
||||
m_originalIcon = icon;
|
||||
}
|
||||
|
||||
|
@ -61,21 +61,28 @@ public:
|
||||
void allViewsForCameraSync(RimView* source, std::vector<RimView*>& views);
|
||||
void allViews(std::vector<RimView*>& views);
|
||||
|
||||
void updateUiIcon();
|
||||
|
||||
public:
|
||||
static QString displayNameForView(RimView* view);
|
||||
RimLinkedView* linkedViewFromView(RimView* view);
|
||||
|
||||
protected:
|
||||
virtual caf::PdmFieldHandle* userDescriptionField() { return &m_name; }
|
||||
virtual caf::PdmFieldHandle* objectToggleField() { return &m_active; }
|
||||
virtual caf::PdmFieldHandle* objectToggleField() { return &m_isActive; }
|
||||
virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "");
|
||||
virtual void initAfterRead();
|
||||
|
||||
void setNameAndIcon();
|
||||
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
|
||||
|
||||
private:
|
||||
bool isActive();
|
||||
|
||||
private:
|
||||
caf::PdmField<bool> m_active;
|
||||
caf::PdmField<bool> m_isActive;
|
||||
caf::PdmPtrField<RimView*> m_mainView;
|
||||
caf::PdmField<QString> m_name;
|
||||
QIcon m_originalIcon;
|
||||
};
|
||||
|
84
ApplicationCode/ProjectDataModel/RimViewLinkerCollection.cpp
Normal file
84
ApplicationCode/ProjectDataModel/RimViewLinkerCollection.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RimViewLinkerCollection.h"
|
||||
|
||||
#include "RimViewLinker.h"
|
||||
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
|
||||
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimViewLinkerCollection, "RimViewLinkerCollection");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimViewLinkerCollection::RimViewLinkerCollection(void)
|
||||
{
|
||||
CAF_PDM_InitObject("Linked Views", ":/chain.png", "", "");
|
||||
|
||||
CAF_PDM_InitField(&isActive, "Active", true, "Active", "", "", "");
|
||||
isActive.uiCapability()->setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&viewLinkers, "ViewLinkers", "View Linkers", "", "", "");
|
||||
viewLinkers.uiCapability()->setUiHidden(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimViewLinkerCollection::~RimViewLinkerCollection(void)
|
||||
{
|
||||
viewLinkers.deleteAllChildObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimViewLinkerCollection::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/)
|
||||
{
|
||||
for (size_t cIdx = 0; cIdx < viewLinkers.size(); ++cIdx)
|
||||
{
|
||||
PdmObjectHandle* childObject = viewLinkers[cIdx];
|
||||
if (childObject)
|
||||
{
|
||||
uiTreeOrdering.add(childObject);
|
||||
}
|
||||
}
|
||||
|
||||
uiTreeOrdering.setForgetRemainingFields(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimViewLinkerCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
this->updateUiIconFromToggleField();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimViewLinkerCollection::initAfterRead()
|
||||
{
|
||||
this->updateUiIconFromToggleField();
|
||||
}
|
||||
|
50
ApplicationCode/ProjectDataModel/RimViewLinkerCollection.h
Normal file
50
ApplicationCode/ProjectDataModel/RimViewLinkerCollection.h
Normal file
@ -0,0 +1,50 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RimDefines.h"
|
||||
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
class RimViewLinker;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimViewLinkerCollection : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimViewLinkerCollection(void);
|
||||
virtual ~RimViewLinkerCollection(void);
|
||||
|
||||
caf::PdmField<bool> isActive;
|
||||
caf::PdmChildArrayField<RimViewLinker*> viewLinkers;
|
||||
|
||||
protected:
|
||||
virtual caf::PdmFieldHandle* objectToggleField() { return &isActive; }
|
||||
virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "");
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
|
||||
virtual void initAfterRead();
|
||||
};
|
Loading…
Reference in New Issue
Block a user