2018-11-27 11:25:25 +01:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
2019-01-09 15:21:38 +01:00
|
|
|
// Copyright (C) 2018- Equinor ASA
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2018-11-27 11:25:25 +01:00
|
|
|
// 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.
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2018-11-27 11:25:25 +01:00
|
|
|
// 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.
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2018-11-27 11:25:25 +01:00
|
|
|
// for more details.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "cvfObject.h"
|
|
|
|
|
|
|
|
|
|
#include "cvfCollection.h"
|
|
|
|
|
#include "cvfColor4.h"
|
2019-09-06 10:40:57 +02:00
|
|
|
#include "cvfVector3.h"
|
2018-11-27 11:25:25 +01:00
|
|
|
|
2019-11-06 10:30:05 +01:00
|
|
|
#include <map>
|
|
|
|
|
|
2018-11-27 11:25:25 +01:00
|
|
|
namespace cvf
|
|
|
|
|
{
|
|
|
|
|
class ModelBasicList;
|
|
|
|
|
class Part;
|
|
|
|
|
class DrawableGeo;
|
|
|
|
|
class Ray;
|
|
|
|
|
class HitItem;
|
|
|
|
|
class String;
|
|
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
template <typename>
|
|
|
|
|
class Array;
|
2021-08-13 16:48:33 +02:00
|
|
|
using Vec3fArray = Array<Vec3f>;
|
|
|
|
|
using UIntArray = Array<uint>;
|
2018-11-27 11:25:25 +01:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
} // namespace cvf
|
2018-11-27 11:25:25 +01:00
|
|
|
|
|
|
|
|
class RicPointTangentManipulatorPartMgr : public cvf::Object
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-08-13 16:48:33 +02:00
|
|
|
enum class HandleType
|
2018-11-27 11:25:25 +01:00
|
|
|
{
|
|
|
|
|
HORIZONTAL_PLANE,
|
|
|
|
|
VERTICAL_AXIS,
|
2021-08-13 16:48:33 +02:00
|
|
|
PRESCRIBED_POLYLINE,
|
2019-09-06 10:40:57 +02:00
|
|
|
AZIMUTH,
|
2019-11-06 10:30:05 +01:00
|
|
|
INCLINATION,
|
|
|
|
|
NONE
|
2018-11-27 11:25:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
RicPointTangentManipulatorPartMgr();
|
|
|
|
|
~RicPointTangentManipulatorPartMgr() override;
|
|
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
void setOrigin( const cvf::Vec3d& origin );
|
|
|
|
|
void setTangent( const cvf::Vec3d& tangent );
|
|
|
|
|
void setHandleSize( double handleSize );
|
|
|
|
|
void originAndTangent( cvf::Vec3d* origin, cvf::Vec3d* tangent );
|
2021-08-13 16:48:33 +02:00
|
|
|
void setPolyline( const std::vector<cvf::Vec3d>& polyline );
|
2018-11-27 11:25:25 +01:00
|
|
|
|
|
|
|
|
bool isManipulatorActive() const;
|
2019-09-06 10:40:57 +02:00
|
|
|
void tryToActivateManipulator( const cvf::HitItem* hitItem );
|
|
|
|
|
void updateManipulatorFromRay( const cvf::Ray* ray );
|
2018-11-27 11:25:25 +01:00
|
|
|
void endManipulator();
|
|
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
void appendPartsToModel( cvf::ModelBasicList* model );
|
2018-11-27 11:25:25 +01:00
|
|
|
|
|
|
|
|
private:
|
2019-11-06 10:30:05 +01:00
|
|
|
void createGeometryOnly();
|
2018-11-27 11:25:25 +01:00
|
|
|
void recreateAllGeometryAndParts();
|
|
|
|
|
|
2019-11-06 10:30:05 +01:00
|
|
|
void createHorizontalPlaneHandle();
|
|
|
|
|
cvf::ref<cvf::DrawableGeo> createHorizontalPlaneGeo();
|
|
|
|
|
|
|
|
|
|
void createVerticalAxisHandle();
|
2019-11-06 11:08:20 +01:00
|
|
|
cvf::ref<cvf::DrawableGeo> createVerticalAxisGeo();
|
2018-11-27 11:25:25 +01:00
|
|
|
|
2021-08-13 16:48:33 +02:00
|
|
|
void createPolylineHandle();
|
|
|
|
|
cvf::ref<cvf::DrawableGeo> createPolylineGeo();
|
|
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
void addHandlePart( cvf::DrawableGeo* geo, const cvf::Color4f& color, HandleType handleId, const cvf::String& partName );
|
2018-11-27 11:25:25 +01:00
|
|
|
|
2020-02-12 11:43:15 +01:00
|
|
|
void addActiveModePart( cvf::DrawableGeo* geo, const cvf::Color4f& color, HandleType handleId, const cvf::String& partName );
|
2018-11-27 11:25:25 +01:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
static cvf::ref<cvf::DrawableGeo> createTriangelDrawableGeo( cvf::Vec3fArray* triangleVertexArray );
|
2023-02-26 10:48:40 +01:00
|
|
|
static cvf::ref<cvf::DrawableGeo> createIndexedTriangelDrawableGeo( cvf::Vec3fArray* triangleVertexArray, cvf::UIntArray* triangleIndices );
|
2023-04-13 07:05:53 +02:00
|
|
|
static cvf::ref<cvf::Part> createPart( cvf::DrawableGeo* geo, const cvf::Color4f& color, const cvf::String& partName );
|
2018-11-27 11:25:25 +01:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
private:
|
2019-11-06 10:30:05 +01:00
|
|
|
std::map<HandleType, cvf::ref<cvf::Part>> m_handleParts; // These arrays have the same length
|
|
|
|
|
cvf::Collection<cvf::Part> m_activeDragModeParts;
|
2019-11-06 11:08:20 +01:00
|
|
|
|
|
|
|
|
cvf::Vec3d m_origin;
|
|
|
|
|
cvf::Vec3d m_tangent;
|
|
|
|
|
double m_handleSize;
|
|
|
|
|
bool m_isGeometryUpdateNeeded;
|
|
|
|
|
|
2021-08-13 16:48:33 +02:00
|
|
|
std::vector<cvf::Vec3d> m_polyline;
|
|
|
|
|
|
2019-11-06 11:08:20 +01:00
|
|
|
HandleType m_activeHandle;
|
|
|
|
|
cvf::Vec3d m_initialPickPoint;
|
|
|
|
|
cvf::Vec3d m_tangentOnStartManipulation;
|
|
|
|
|
cvf::Vec3d m_originOnStartManipulation;
|
2019-09-06 10:40:57 +02:00
|
|
|
};
|