///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2018- Statoil 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 // 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 // for more details. // ///////////////////////////////////////////////////////////////////////////////// #pragma once #include "cvfBase.h" #include "cvfObject.h" #include "cvfMatrix4.h" #include "cvfVector3.h" #include #include namespace cvf { class Model; class ModelBasicList; }; namespace caf { class Viewer; }; class QMouseEvent; class RicPointTangentManipulatorPartMgr; //================================================================================================== // // //================================================================================================== class RicPointTangentManipulator : public QObject { Q_OBJECT public: explicit RicPointTangentManipulator(caf::Viewer* viewer); ~RicPointTangentManipulator(); void setOrigin(const cvf::Vec3d& origin); void setTangent(const cvf::Vec3d& tangent); void appendPartsToModel(cvf::ModelBasicList* model); signals: void notifyRedraw(); void notifyUpdate(const cvf::Vec3d& origin, const cvf::Vec3d& tangent); protected: bool eventFilter(QObject *obj, QEvent *event); private: QPointer m_viewer; cvf::ref m_partManager; }; #pragma once #include "cvfBase.h" #include "cvfObject.h" #include "cvfVector3.h" #include "cvfCollection.h" #include "cvfMatrix4.h" #include "cvfString.h" #include "cvfColor4.h" namespace cvf { class ModelBasicList; class Part; class DrawableGeo; class Ray; class HitItem; template class Array; typedef Array Vec3fArray; } class RicPointTangentManipulatorPartMgr : public cvf::Object { public: enum HandleType { HORIZONTAL_PLANE, VERTICAL_AXIS, AZIMUTH, INCLINATION }; public: RicPointTangentManipulatorPartMgr(); ~RicPointTangentManipulatorPartMgr(); void setOrigin(const cvf::Vec3d& origin); void setTangent(const cvf::Vec3d& tangent); void originAndTangent(cvf::Vec3d* origin, cvf::Vec3d* tangent); bool isManipulatorActive() const; void tryToActivateManipulator(const cvf::HitItem* hitItem); void updateManipulatorFromRay(const cvf::Ray* ray); void endManipulator(); void appendPartsToModel(cvf::ModelBasicList* model); private: void createAllHandleParts(); void clearAllGeometryAndParts(); void recreateAllGeometryAndParts(); void createHorizontalPlaneHandle(); void addHandlePart(cvf::DrawableGeo* geo, const cvf::Color4f& color, HandleType handleId, const cvf::String& partName); void addActiveModePart(cvf::DrawableGeo* geo, const cvf::Color4f& color, HandleType handleId, const cvf::String& partName); static cvf::ref createTriangelDrawableGeo(cvf::Vec3fArray* triangleVertexArray); static cvf::ref createPart(cvf::DrawableGeo* geo, const cvf::Color4f& color, const cvf::String& partName); private: std::vector< HandleType > m_handleIds; // These arrays have the same length cvf::Collection m_handleParts; // These arrays have the same length cvf::Collection m_activeDragModeParts; cvf::Vec3d m_origin; cvf::Vec3d m_tangent; cvf::Vec3d m_initialPickPoint; cvf::Vec3d m_tangentOnStartManipulation; cvf::Vec3d m_originOnStartManipulation; size_t m_currentHandleIndex; }; //================================================================================================== /// /// /// //================================================================================================== #include "cafSelectionChangedReceiver.h" #include "cafPdmUiObjectEditorHandle.h" #include "cafFactory.h" namespace caf { //================================================================================================== /// Macros helping in development of PDM UI 3d editors //================================================================================================== /// CAF_PDM_UI_FIELD_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_OBJECT_3D_EDITOR_HEADER_INIT \ public: \ static QString uiEditorTypeName() /// CAF_PDM_UI_OBJECT_3D_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_OBJECT_3D_EDITOR_SOURCE_INIT(EditorClassName) \ QString EditorClassName::uiEditorTypeName() { return #EditorClassName; } \ CAF_FACTORY_REGISTER(caf::PdmUiObject3dEditorHandle, EditorClassName, QString, EditorClassName::uiEditorTypeName()) class PdmUiObject3dEditorHandle : public caf::PdmUiObjectEditorHandle { public: PdmUiObject3dEditorHandle(); ~PdmUiObject3dEditorHandle() override; void setViewer(caf::Viewer* ownerViewer); protected: // To be removed when splitting the PdmUiObjectEditorHandle virtual QWidget* createWidget(QWidget* parent) override { return nullptr;} QPointer m_ownerViewer; }; //================================================================================================== /// /// /// //================================================================================================== // Selected object 3D editor visualizer class PdmUiSelectionVisualizer3d : public QObject, caf::SelectionChangedReceiver { Q_OBJECT public: PdmUiSelectionVisualizer3d(caf::Viewer* ownerViewer); ~PdmUiSelectionVisualizer3d(); protected: virtual void onSelectionManagerSelectionChanged() override; std::vector< QPointer > m_active3DEditors; QPointer m_ownerViewer; }; } //================================================================================================== /// /// /// //================================================================================================== class RicWellTarget3dEditor; class RicWellPathGeometry3dEditor : public caf::PdmUiObject3dEditorHandle { CAF_PDM_UI_OBJECT_3D_EDITOR_HEADER_INIT; Q_OBJECT public: RicWellPathGeometry3dEditor(); ~RicWellPathGeometry3dEditor() override; protected: virtual void configureAndUpdateUi(const QString& uiConfigName) override; private: std::vector m_targetEditors; }; //================================================================================================== /// /// /// //================================================================================================== class RicWellTarget3dEditor : public caf::PdmUiObject3dEditorHandle { CAF_PDM_UI_OBJECT_3D_EDITOR_HEADER_INIT; Q_OBJECT public: RicWellTarget3dEditor(); ~RicWellTarget3dEditor() override; protected: virtual void configureAndUpdateUi(const QString& uiConfigName) override; virtual void cleanupBeforeSettingPdmObject() override; private: QPointer m_manipulator; cvf::ref m_cvfModel; }; class RiuViewer; // 3D editor manager