AppFwk: Moved PdmUi3dObjectEditorHandle and PdmUiSelection3dEditorVisualizer into correct place in PdmUiCore

This commit is contained in:
Jacob Støren
2018-11-27 10:31:54 +01:00
parent 318cd76b64
commit 3c32595e25
8 changed files with 376 additions and 209 deletions

View File

@@ -566,129 +566,8 @@ cvf::ref<cvf::Part> RicPointTangentManipulatorPartMgr::createPart(cvf::DrawableG
return part;
}
//==================================================================================================
///
///
///
//==================================================================================================
namespace caf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PdmUi3dObjectEditorHandle::PdmUi3dObjectEditorHandle()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PdmUi3dObjectEditorHandle::~PdmUi3dObjectEditorHandle()
{
}
//--------------------------------------------------------------------------------------------------
/// Not allowed to change viewer. Should be constructor argument, but makes factory stuff difficult.
//--------------------------------------------------------------------------------------------------
void PdmUi3dObjectEditorHandle::setViewer(QWidget* ownerViewer)
{
CAF_ASSERT(m_ownerViewer.isNull());
m_ownerViewer = ownerViewer;
}
}
//==================================================================================================
///
///
///
//==================================================================================================
#include "cafSelectionManager.h"
#include "RimWellPathGeometryDef.h"
namespace caf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PdmUiSelection3dEditorVisualizer::PdmUiSelection3dEditorVisualizer(QWidget* ownerViewer)
: m_ownerViewer(ownerViewer)
{
this->setParent(ownerViewer); // Makes this owned by the viewer.
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PdmUiSelection3dEditorVisualizer::~PdmUiSelection3dEditorVisualizer()
{
for (auto editor: m_active3DEditors)
{
delete editor;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiSelection3dEditorVisualizer::updateVisibleEditors()
{
for (auto editor: m_active3DEditors)
{
if (editor) editor->updateUi();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiSelection3dEditorVisualizer::onSelectionManagerSelectionChanged( const std::set<int>& changedSelectionLevels )
{
if (!changedSelectionLevels.count(0)) return;
for (auto editor: m_active3DEditors)
{
delete editor;
}
m_active3DEditors.clear();
if (!m_ownerViewer) return;
std::vector<RimWellPathGeometryDef*> wellPathGeomDefs;
caf::SelectionManager::instance()->objectsByType(&wellPathGeomDefs);
std::set<PdmUiItem*> totalSelection;
for ( int selLevel: changedSelectionLevels )
{
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();
}
} // caf
//==================================================================================================
///
@@ -697,6 +576,7 @@ void PdmUiSelection3dEditorVisualizer::onSelectionManagerSelectionChanged( const
//==================================================================================================
#include "RimWellPathTarget.h"
#include "RimWellPathGeometryDef.h"
CAF_PDM_UI_3D_OBJECT_EDITOR_SOURCE_INIT(RicWellPathGeometry3dEditor);

View File

@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- Statoil ASA
// Copyright (C) 2018- equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -171,88 +171,7 @@ private:
///
///
//==================================================================================================
#include "cafSelectionChangedReceiver.h"
#include "cafPdmUiObjectEditorHandle.h"
#include "cafFactory.h"
#include <QWidget>
// PdmUiObjectEditorHandle -<| PdmUiWidgetObjectEditorHandle --<| PdmUiFormLayoutObjectEditor
// -<| PdmUi3dObjectEditorHandle
namespace caf
{
//==================================================================================================
/// Macros helping in development of PDM UI 3d editors
//==================================================================================================
/// CAF_PDM_UI_3D_OBJECT_EDITOR_HEADER_INIT assists the factory used when creating editors
/// Place this in the header file inside the class definition of your PdmUiEditor
#define CAF_PDM_UI_3D_OBJECT_EDITOR_HEADER_INIT \
public: \
static QString uiEditorTypeName()
/// CAF_PDM_UI_3D_OBJECT_EDITOR_SOURCE_INIT implements editorTypeName() and registers the field editor in the field editor factory
/// Place this in the cpp file, preferably above the constructor
#define CAF_PDM_UI_3D_OBJECT_EDITOR_SOURCE_INIT(EditorClassName) \
QString EditorClassName::uiEditorTypeName() { return #EditorClassName; } \
CAF_FACTORY_REGISTER(caf::PdmUi3dObjectEditorHandle, EditorClassName, QString, EditorClassName::uiEditorTypeName())
class PdmUi3dObjectEditorHandle : public caf::PdmUiObjectEditorHandle
{
public:
PdmUi3dObjectEditorHandle();
~PdmUi3dObjectEditorHandle() override;
void setViewer(QWidget* ownerViewer);
protected:
QWidget* ownerViewer() { return m_ownerViewer;}
private:
QPointer<QWidget> m_ownerViewer;
};
//==================================================================================================
///
///
///
//==================================================================================================
// Selected object 3D editor visualizer
class PdmUiSelection3dEditorVisualizer : public QObject, caf::SelectionChangedReceiver
{
Q_OBJECT
public:
PdmUiSelection3dEditorVisualizer(QWidget* ownerViewer);
~PdmUiSelection3dEditorVisualizer() override;
void setConfigName(const QString& configName) { m_configName = configName; }
void updateVisibleEditors();
private:
void onSelectionManagerSelectionChanged( const std::set<int>& changedSelectionLevels ) override;
std::vector< QPointer<PdmUi3dObjectEditorHandle> > m_active3DEditors;
QPointer<QWidget> m_ownerViewer;
QString m_configName;
};
}
//==================================================================================================
///
///
///
//==================================================================================================
#include "cafPdmUi3dObjectEditorHandle.h"
class RicWellTarget3dEditor;
@@ -277,6 +196,7 @@ private:
///
///
//==================================================================================================
#include "cafPdmUi3dObjectEditorHandle.h"
class RicWellTarget3dEditor : public caf::PdmUi3dObjectEditorHandle
@@ -299,7 +219,3 @@ private:
QPointer<RicPointTangentManipulator> m_manipulator;
cvf::ref<cvf::ModelBasicList> m_cvfModel;
};
class RiuViewer;
// 3D editor manager