mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-23 23:13:39 -06:00
AppFwk: Make PdmUiSelection3dEditorVisualizer generic, ready to be moved to a separate file
This commit is contained in:
parent
9297c5888c
commit
fb93ad7ca7
@ -614,7 +614,7 @@ namespace caf
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
PdmUiSelectionVisualizer3d::PdmUiSelectionVisualizer3d(caf::Viewer* ownerViewer)
|
||||
PdmUiSelection3dEditorVisualizer::PdmUiSelection3dEditorVisualizer(caf::Viewer* ownerViewer)
|
||||
: m_ownerViewer(ownerViewer)
|
||||
{
|
||||
this->setParent(ownerViewer); // Makes this owned by the viewer.
|
||||
@ -623,7 +623,7 @@ PdmUiSelectionVisualizer3d::PdmUiSelectionVisualizer3d(caf::Viewer* ownerViewer)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
PdmUiSelectionVisualizer3d::~PdmUiSelectionVisualizer3d()
|
||||
PdmUiSelection3dEditorVisualizer::~PdmUiSelection3dEditorVisualizer()
|
||||
{
|
||||
for (auto editor: m_active3DEditors)
|
||||
{
|
||||
@ -634,7 +634,7 @@ PdmUiSelectionVisualizer3d::~PdmUiSelectionVisualizer3d()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiSelectionVisualizer3d::updateVisibleEditors()
|
||||
void PdmUiSelection3dEditorVisualizer::updateVisibleEditors()
|
||||
{
|
||||
for (auto editor: m_active3DEditors)
|
||||
{
|
||||
@ -645,7 +645,7 @@ void PdmUiSelectionVisualizer3d::updateVisibleEditors()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiSelectionVisualizer3d::onSelectionManagerSelectionChanged( const std::set<int>& changedSelectionLevels )
|
||||
void PdmUiSelection3dEditorVisualizer::onSelectionManagerSelectionChanged( const std::set<int>& changedSelectionLevels )
|
||||
{
|
||||
if (!changedSelectionLevels.count(0)) return;
|
||||
|
||||
@ -658,23 +658,34 @@ void PdmUiSelectionVisualizer3d::onSelectionManagerSelectionChanged( const std::
|
||||
|
||||
if (!m_ownerViewer) return;
|
||||
|
||||
// Todo: How do we deduce the editor from the selected object ?
|
||||
// Alt 1: Register the rim object type name as key in the factory as well
|
||||
// Alt 2: Set the editor type name as PdmUiItem::setUiEditorTypeName
|
||||
// Alt 3: Use a specific config-name in alt 2.
|
||||
// Alt 4: Introduce a PdmUiItem::editorTypeName3d
|
||||
|
||||
std::vector<RimWellPathGeometryDef*> wellPathGeomDefs;
|
||||
caf::SelectionManager::instance()->objectsByType(&wellPathGeomDefs);
|
||||
|
||||
for (auto geomDef: wellPathGeomDefs)
|
||||
std::set<PdmUiItem*> totalSelection;
|
||||
for ( int selLevel: changedSelectionLevels )
|
||||
{
|
||||
auto editor = new RicWellPathGeometry3dEditor();
|
||||
editor->setViewer(m_ownerViewer);
|
||||
editor->setPdmObject(geomDef);
|
||||
m_active3DEditors.push_back(editor);
|
||||
editor->updateUi();
|
||||
std::vector<PdmUiItem*> items;
|
||||
caf::SelectionManager::instance()->selectedItems(items, selLevel );
|
||||
totalSelection.insert(items.begin(), items.end());
|
||||
}
|
||||
|
||||
for (PdmUiItem* item: totalSelection)
|
||||
{
|
||||
QString editor3dTypeName = item->ui3dEditorTypeName(m_configName);
|
||||
if (!editor3dTypeName.isEmpty())
|
||||
{
|
||||
PdmObjectHandle* itemObject = dynamic_cast<PdmObjectHandle*>(item);
|
||||
if (itemObject)
|
||||
{
|
||||
PdmUi3dObjectEditorHandle* editor3d = caf::Factory<PdmUi3dObjectEditorHandle, QString>::instance()->create(editor3dTypeName);
|
||||
editor3d->setViewer(m_ownerViewer);
|
||||
editor3d->setPdmObject(itemObject);
|
||||
m_active3DEditors.push_back(editor3d);
|
||||
editor3d->updateUi();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_ownerViewer->update();
|
||||
}
|
||||
|
||||
|
@ -223,20 +223,22 @@ protected:
|
||||
|
||||
|
||||
// Selected object 3D editor visualizer
|
||||
class PdmUiSelectionVisualizer3d : public QObject, caf::SelectionChangedReceiver
|
||||
class PdmUiSelection3dEditorVisualizer : public QObject, caf::SelectionChangedReceiver
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PdmUiSelectionVisualizer3d(caf::Viewer* ownerViewer);
|
||||
~PdmUiSelectionVisualizer3d() override;
|
||||
PdmUiSelection3dEditorVisualizer(caf::Viewer* ownerViewer);
|
||||
~PdmUiSelection3dEditorVisualizer() override;
|
||||
|
||||
void setConfigName(const QString& configName) { m_configName = configName; }
|
||||
|
||||
void updateVisibleEditors();
|
||||
protected:
|
||||
void onSelectionManagerSelectionChanged( const std::set<int>& changedSelectionLevels ) override;
|
||||
|
||||
std::vector< QPointer<PdmUi3dObjectEditorHandle> > m_active3DEditors;
|
||||
|
||||
QPointer<caf::Viewer> m_ownerViewer;
|
||||
QString m_configName;
|
||||
};
|
||||
|
||||
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "cafPdmUiTableViewEditor.h"
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
#include "cvfGeometryTools.h"
|
||||
#include "WellPathCommands/PointTangentManipulator/RicPointTangentManipulator.h"
|
||||
|
||||
|
||||
namespace caf
|
||||
@ -64,6 +65,7 @@ RimWellPathGeometryDef::RimWellPathGeometryDef()
|
||||
{
|
||||
CAF_PDM_InitObject("Well Targets", ":/WellTargets.png", "", "");
|
||||
|
||||
this->setUi3dEditorTypeName(RicWellPathGeometry3dEditor::uiEditorTypeName());
|
||||
CAF_PDM_InitField(&m_referencePointUtmXyd, "ReferencePosUtmXyd", cvf::Vec3d(0,0,0), "UTM Reference Point", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&m_mdrkbAtFirstTarget, "MdrkbAtFirstTarget", 0.0, "MDRKB at First Target", "", "", "");
|
||||
|
@ -189,7 +189,7 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent)
|
||||
m_windowEdgeAxisOverlay = new RivWindowEdgeAxesOverlayItem(standardFont);
|
||||
m_showWindowEdgeAxes = false;
|
||||
|
||||
m_selectionVisualizerManager = new caf::PdmUiSelectionVisualizer3d(this);
|
||||
m_selectionVisualizerManager = new caf::PdmUiSelection3dEditorVisualizer(this);
|
||||
|
||||
m_scaleLegend = new caf::OverlayScaleLegend(standardFont);
|
||||
m_scaleLegend->setOrientation(caf::OverlayScaleLegend::HORIZONTAL);
|
||||
|
@ -46,7 +46,7 @@ namespace caf
|
||||
{
|
||||
class OverlayScaleLegend;
|
||||
class TitledOverlayFrame;
|
||||
class PdmUiSelectionVisualizer3d;
|
||||
class PdmUiSelection3dEditorVisualizer;
|
||||
}
|
||||
|
||||
namespace cvf
|
||||
@ -172,7 +172,7 @@ private:
|
||||
cvf::ref<RivWindowEdgeAxesOverlayItem> m_windowEdgeAxisOverlay;
|
||||
bool m_showWindowEdgeAxes;
|
||||
|
||||
caf::PdmUiSelectionVisualizer3d* m_selectionVisualizerManager;
|
||||
caf::PdmUiSelection3dEditorVisualizer* m_selectionVisualizerManager;
|
||||
|
||||
cvf::Vec3d m_cursorPositionDomainCoords;
|
||||
bool m_isNavigationRotationEnabled;
|
||||
|
@ -418,6 +418,30 @@ void PdmUiItem::setUiEditorTypeName(const QString& editorTypeName, const QString
|
||||
m_configItemInfos[uiConfigName].m_editorTypeName = editorTypeName;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString PdmUiItem::ui3dEditorTypeName(const QString& uiConfigName) const
|
||||
{
|
||||
const PdmUiItemInfo* conInfo = configInfo(uiConfigName);
|
||||
const PdmUiItemInfo* defInfo = defaultInfo();
|
||||
const PdmUiItemInfo* sttInfo = m_staticItemInfo;
|
||||
|
||||
if (conInfo && !(conInfo->m_3dEditorTypeName.isEmpty())) return conInfo->m_3dEditorTypeName;
|
||||
if (defInfo && !(defInfo->m_3dEditorTypeName.isEmpty())) return defInfo->m_3dEditorTypeName;
|
||||
if (sttInfo && !(sttInfo->m_3dEditorTypeName.isEmpty())) return sttInfo->m_3dEditorTypeName;
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiItem::setUi3dEditorTypeName(const QString& editorTypeName, const QString& uiConfigName /*= ""*/)
|
||||
{
|
||||
m_configItemInfos[uiConfigName].m_3dEditorTypeName = editorTypeName;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -56,12 +56,26 @@ class PdmUiItemInfo
|
||||
{
|
||||
public:
|
||||
PdmUiItemInfo()
|
||||
: m_editorTypeName(""), m_isHidden(-1), m_isTreeChildrenHidden(-1), m_isReadOnly(-1), m_labelAlignment(LEFT), m_isCustomContextMenuEnabled(-1)
|
||||
: m_editorTypeName("")
|
||||
, m_isHidden(-1)
|
||||
, m_isTreeChildrenHidden(-1)
|
||||
, m_isReadOnly(-1)
|
||||
, m_labelAlignment(LEFT)
|
||||
, m_isCustomContextMenuEnabled(-1)
|
||||
{}
|
||||
|
||||
PdmUiItemInfo(const QString& uiName, QIcon icon = QIcon(), QString toolTip = "", QString whatsThis = "", QString extraDebugText = "")
|
||||
: m_uiName(uiName), m_icon(icon), m_toolTip(toolTip), m_whatsThis(whatsThis), m_extraDebugText(extraDebugText),
|
||||
m_editorTypeName(""), m_isHidden(false), m_isTreeChildrenHidden(false), m_isReadOnly(false), m_labelAlignment(LEFT), m_isCustomContextMenuEnabled(false)
|
||||
: m_uiName(uiName)
|
||||
, m_icon(icon)
|
||||
, m_toolTip(toolTip)
|
||||
, m_whatsThis(whatsThis)
|
||||
, m_extraDebugText(extraDebugText)
|
||||
, m_editorTypeName("")
|
||||
, m_isHidden(false)
|
||||
, m_isTreeChildrenHidden(false)
|
||||
, m_isReadOnly(false)
|
||||
, m_labelAlignment(LEFT)
|
||||
, m_isCustomContextMenuEnabled(false)
|
||||
{ }
|
||||
|
||||
enum LabelPosType { LEFT, TOP, HIDDEN };
|
||||
@ -75,6 +89,7 @@ private:
|
||||
QString m_whatsThis;
|
||||
QString m_extraDebugText;
|
||||
QString m_editorTypeName; ///< Use this exact type of editor to edit this UiItem
|
||||
QString m_3dEditorTypeName; ///< If set, use this editor type to edit this UiItem in 3D
|
||||
int m_isHidden; ///< UiItem should be hidden. -1 means not set
|
||||
int m_isTreeChildrenHidden; ///< Children of UiItem should be hidden. -1 means not set
|
||||
int m_isReadOnly; ///< UiItem should be insensitive, or read only. -1 means not set.
|
||||
@ -236,6 +251,9 @@ public:
|
||||
QString uiEditorTypeName(const QString& uiConfigName) const;
|
||||
void setUiEditorTypeName(const QString& editorTypeName, const QString& uiConfigName = "");
|
||||
|
||||
QString ui3dEditorTypeName(const QString& uiConfigName) const;
|
||||
void setUi3dEditorTypeName(const QString& editorTypeName, const QString& uiConfigName = "");
|
||||
|
||||
virtual bool isUiGroup() const;
|
||||
|
||||
/// Intended to be called when fields in an object has been changed
|
||||
|
Loading…
Reference in New Issue
Block a user