2018-08-16 08:38:34 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// 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 <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "cvfBase.h"
|
|
|
|
#include "cvfObject.h"
|
|
|
|
#include "cvfMatrix4.h"
|
|
|
|
#include "cvfVector3.h"
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QPointer>
|
|
|
|
|
|
|
|
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);
|
2018-08-17 03:35:42 -05:00
|
|
|
void setHandleSize(double handleSize);
|
2018-08-16 08:38:34 -05:00
|
|
|
|
|
|
|
void appendPartsToModel(cvf::ModelBasicList* model);
|
|
|
|
|
|
|
|
signals:
|
2018-08-31 08:13:58 -05:00
|
|
|
void notifySelected();
|
2018-09-12 06:18:48 -05:00
|
|
|
void notifyDragFinished();
|
2018-08-16 08:38:34 -05:00
|
|
|
void notifyUpdate(const cvf::Vec3d& origin, const cvf::Vec3d& tangent);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool eventFilter(QObject *obj, QEvent *event);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QPointer<caf::Viewer> m_viewer;
|
|
|
|
|
|
|
|
cvf::ref<RicPointTangentManipulatorPartMgr> 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 <typename> class Array;
|
|
|
|
typedef Array<Vec3f> Vec3fArray;
|
2018-08-17 03:35:42 -05:00
|
|
|
typedef Array<uint> UIntArray;
|
|
|
|
|
2018-08-16 08:38:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2018-08-17 03:35:42 -05:00
|
|
|
void setHandleSize(double handleSize);
|
2018-08-16 08:38:34 -05:00
|
|
|
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();
|
2018-08-17 03:35:42 -05:00
|
|
|
void createVerticalAxisHandle();
|
2018-08-16 08:38:34 -05:00
|
|
|
|
|
|
|
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<cvf::DrawableGeo> createTriangelDrawableGeo(cvf::Vec3fArray* triangleVertexArray);
|
2018-08-17 03:35:42 -05:00
|
|
|
static cvf::ref<cvf::DrawableGeo> createIndexedTriangelDrawableGeo(cvf::Vec3fArray* triangleVertexArray,
|
|
|
|
cvf::UIntArray* triangleIndices);
|
2018-08-16 08:38:34 -05:00
|
|
|
static cvf::ref<cvf::Part> createPart(cvf::DrawableGeo* geo,
|
|
|
|
const cvf::Color4f& color,
|
|
|
|
const cvf::String& partName);
|
|
|
|
private:
|
2018-08-21 09:37:03 -05:00
|
|
|
size_t m_currentHandleIndex;
|
2018-08-16 08:38:34 -05:00
|
|
|
std::vector< HandleType > m_handleIds; // These arrays have the same length
|
|
|
|
cvf::Collection<cvf::Part> m_handleParts; // These arrays have the same length
|
|
|
|
cvf::Collection<cvf::Part> m_activeDragModeParts;
|
|
|
|
|
|
|
|
cvf::Vec3d m_origin;
|
|
|
|
cvf::Vec3d m_tangent;
|
2018-08-17 03:35:42 -05:00
|
|
|
double m_handleSize;
|
2018-08-16 08:38:34 -05:00
|
|
|
|
|
|
|
cvf::Vec3d m_initialPickPoint;
|
|
|
|
cvf::Vec3d m_tangentOnStartManipulation;
|
|
|
|
cvf::Vec3d m_originOnStartManipulation;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//==================================================================================================
|
|
|
|
///
|
|
|
|
///
|
|
|
|
///
|
|
|
|
//==================================================================================================
|
|
|
|
|
|
|
|
|
|
|
|
#include "cafSelectionChangedReceiver.h"
|
|
|
|
#include "cafPdmUiObjectEditorHandle.h"
|
|
|
|
#include "cafFactory.h"
|
2018-08-27 09:21:38 -05:00
|
|
|
// PdmUiObjectEditorHandle -<| PdmUiWidgetObjectEditorHandle --<| PdmUiFormLayoutObjectEditor
|
|
|
|
// -<| PdmUi3dObjectEditorHandle
|
2018-08-16 08:38:34 -05:00
|
|
|
namespace caf
|
|
|
|
{
|
|
|
|
|
|
|
|
//==================================================================================================
|
|
|
|
/// Macros helping in development of PDM UI 3d editors
|
|
|
|
//==================================================================================================
|
|
|
|
|
2018-08-27 09:21:38 -05:00
|
|
|
/// CAF_PDM_UI_3D_OBJECT_EDITOR_HEADER_INIT assists the factory used when creating editors
|
2018-08-16 08:38:34 -05:00
|
|
|
/// Place this in the header file inside the class definition of your PdmUiEditor
|
|
|
|
|
2018-08-27 09:21:38 -05:00
|
|
|
#define CAF_PDM_UI_3D_OBJECT_EDITOR_HEADER_INIT \
|
2018-08-16 08:38:34 -05:00
|
|
|
public: \
|
|
|
|
static QString uiEditorTypeName()
|
|
|
|
|
2018-08-27 09:21:38 -05:00
|
|
|
/// CAF_PDM_UI_3D_OBJECT_EDITOR_SOURCE_INIT implements editorTypeName() and registers the field editor in the field editor factory
|
2018-08-16 08:38:34 -05:00
|
|
|
/// Place this in the cpp file, preferably above the constructor
|
|
|
|
|
2018-08-27 09:21:38 -05:00
|
|
|
#define CAF_PDM_UI_3D_OBJECT_EDITOR_SOURCE_INIT(EditorClassName) \
|
2018-08-16 08:38:34 -05:00
|
|
|
QString EditorClassName::uiEditorTypeName() { return #EditorClassName; } \
|
2018-08-27 09:21:38 -05:00
|
|
|
CAF_FACTORY_REGISTER(caf::PdmUi3dObjectEditorHandle, EditorClassName, QString, EditorClassName::uiEditorTypeName())
|
2018-08-16 08:38:34 -05:00
|
|
|
|
|
|
|
|
2018-08-27 09:21:38 -05:00
|
|
|
class PdmUi3dObjectEditorHandle : public caf::PdmUiObjectEditorHandle
|
2018-08-16 08:38:34 -05:00
|
|
|
{
|
|
|
|
public:
|
2018-08-27 09:21:38 -05:00
|
|
|
PdmUi3dObjectEditorHandle();
|
|
|
|
~PdmUi3dObjectEditorHandle() override;
|
2018-08-16 08:38:34 -05:00
|
|
|
|
|
|
|
void setViewer(caf::Viewer* ownerViewer);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// To be removed when splitting the PdmUiObjectEditorHandle
|
|
|
|
virtual QWidget* createWidget(QWidget* parent) override { return nullptr;}
|
|
|
|
|
|
|
|
QPointer<caf::Viewer> m_ownerViewer;
|
|
|
|
};
|
|
|
|
|
|
|
|
//==================================================================================================
|
|
|
|
///
|
|
|
|
///
|
|
|
|
///
|
|
|
|
//==================================================================================================
|
|
|
|
|
|
|
|
|
|
|
|
// Selected object 3D editor visualizer
|
|
|
|
class PdmUiSelectionVisualizer3d : public QObject, caf::SelectionChangedReceiver
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
PdmUiSelectionVisualizer3d(caf::Viewer* ownerViewer);
|
|
|
|
~PdmUiSelectionVisualizer3d();
|
2018-10-02 09:29:58 -05:00
|
|
|
|
|
|
|
void updateVisibleEditors();
|
2018-08-16 08:38:34 -05:00
|
|
|
protected:
|
2018-08-31 08:13:58 -05:00
|
|
|
virtual void onSelectionManagerSelectionChanged( const std::set<int>& changedSelectionLevels ) override;
|
2018-08-16 08:38:34 -05:00
|
|
|
|
2018-08-27 09:21:38 -05:00
|
|
|
std::vector< QPointer<PdmUi3dObjectEditorHandle> > m_active3DEditors;
|
2018-08-16 08:38:34 -05:00
|
|
|
|
|
|
|
QPointer<caf::Viewer> m_ownerViewer;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//==================================================================================================
|
|
|
|
///
|
|
|
|
///
|
|
|
|
///
|
|
|
|
//==================================================================================================
|
|
|
|
|
|
|
|
class RicWellTarget3dEditor;
|
|
|
|
|
2018-08-27 09:21:38 -05:00
|
|
|
class RicWellPathGeometry3dEditor : public caf::PdmUi3dObjectEditorHandle
|
2018-08-16 08:38:34 -05:00
|
|
|
{
|
2018-08-27 09:21:38 -05:00
|
|
|
CAF_PDM_UI_3D_OBJECT_EDITOR_HEADER_INIT;
|
2018-08-16 08:38:34 -05:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
RicWellPathGeometry3dEditor();
|
|
|
|
~RicWellPathGeometry3dEditor() override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void configureAndUpdateUi(const QString& uiConfigName) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
std::vector<RicWellTarget3dEditor*> m_targetEditors;
|
|
|
|
};
|
|
|
|
|
|
|
|
//==================================================================================================
|
|
|
|
///
|
|
|
|
///
|
|
|
|
///
|
|
|
|
//==================================================================================================
|
|
|
|
|
|
|
|
|
2018-08-27 09:21:38 -05:00
|
|
|
class RicWellTarget3dEditor : public caf::PdmUi3dObjectEditorHandle
|
2018-08-16 08:38:34 -05:00
|
|
|
{
|
2018-08-27 09:21:38 -05:00
|
|
|
CAF_PDM_UI_3D_OBJECT_EDITOR_HEADER_INIT;
|
2018-08-16 08:38:34 -05:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
RicWellTarget3dEditor();
|
|
|
|
~RicWellTarget3dEditor() override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void configureAndUpdateUi(const QString& uiConfigName) override;
|
|
|
|
virtual void cleanupBeforeSettingPdmObject() override;
|
|
|
|
|
2018-08-21 09:02:50 -05:00
|
|
|
private slots:
|
|
|
|
void slotUpdated(const cvf::Vec3d& origin, const cvf::Vec3d& tangent);
|
2018-08-31 08:13:58 -05:00
|
|
|
void slotSelectedIn3D();
|
2018-09-12 06:18:48 -05:00
|
|
|
void slotDragFinished();
|
2018-08-16 08:38:34 -05:00
|
|
|
private:
|
|
|
|
QPointer<RicPointTangentManipulator> m_manipulator;
|
|
|
|
cvf::ref<cvf::ModelBasicList> m_cvfModel;
|
|
|
|
};
|
|
|
|
|
|
|
|
class RiuViewer;
|
|
|
|
|
|
|
|
// 3D editor manager
|