Files
ResInsight/Fwk/AppFwk/cafVizExtensions/cafBoxManipulatorPartManager.h
T

118 lines
3.2 KiB
C++
Raw Normal View History

#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfVector3.h"
#include "cvfCollection.h"
#include "cvfMatrix4.h"
namespace cvf {
class ModelBasicList;
class Part;
class DrawableGeo;
2016-09-29 11:43:47 +02:00
class Ray;
class HitItem;
}
namespace caf {
class BoxManipulatorGeometryGenerator;
};
namespace caf {
//==================================================================================================
//
//
//==================================================================================================
class BoxManipulatorPartManager : public cvf::Object
{
public:
2016-09-30 13:16:00 +02:00
enum BoxFace
{
2016-09-29 11:43:47 +02:00
BCF_X_POS,
BCF_X_NEG,
BCF_Y_POS,
BCF_Y_NEG,
BCF_Z_POS,
BCF_Z_NEG
};
2016-09-30 13:16:00 +02:00
enum HandleType
{
2016-09-29 11:43:47 +02:00
BCFI_NONE,
BCFI_CENTER
};
public:
BoxManipulatorPartManager();
2019-01-10 22:13:19 +01:00
~BoxManipulatorPartManager() override;
2016-09-29 11:43:47 +02:00
void setOrigin(const cvf::Vec3d& origin);
void setSize(const cvf::Vec3d& size);
void originAndSize(cvf::Vec3d* origin, cvf::Vec3d* size);
bool isManipulatorActive() const;
void tryToActivateManipulator(const cvf::HitItem* hitItem);
void updateManipulatorFromRay(const cvf::Ray* ray);
void endManipulator();
2016-09-29 11:43:47 +02:00
void appendPartsToModel(cvf::ModelBasicList* model);
private:
2016-09-30 13:16:00 +02:00
cvf::Vec3d normalFromFace(BoxFace face);
2016-09-29 11:43:47 +02:00
void navCubeCornerPoints(cvf::Vec3f points[8]);
2016-09-30 13:16:00 +02:00
void createBoundingBoxPart();
void createAllHandleParts();
void createCubeFaceHandlePart(BoxFace face, cvf::Vec3f p1, cvf::Vec3f p2, cvf::Vec3f p3, cvf::Vec3f p4);
2016-09-29 11:43:47 +02:00
void clearAllGeometryAndParts();
void recreateAllGeometryAndParts();
static cvf::ref<cvf::DrawableGeo> createHandleGeo(const cvf::Vec3f& v1,
const cvf::Vec3f& v2,
const cvf::Vec3f& v3,
const cvf::Vec3f& v4,
const cvf::Vec3f& v5);
private:
std::vector< std::pair<BoxFace, HandleType> > m_handleIds; // These arrays have the same length
cvf::Collection<cvf::Part> m_handleParts; // These arrays have the same length
2016-09-29 11:43:47 +02:00
cvf::ref<cvf::Part> m_boundingBoxPart;
2016-09-29 11:43:47 +02:00
cvf::Vec3d m_origin;
cvf::Vec3d m_size;
2016-09-29 11:43:47 +02:00
cvf::Vec3d m_initialPickPoint;
cvf::Vec3d m_sizeOnStartManipulation;
cvf::Vec3d m_originOnStartManipulation;
size_t m_currentHandleIndex;
2016-09-29 11:43:47 +02:00
};
2016-09-29 11:43:47 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class BoxManipulatorSourceInfo : public cvf::Object
{
public:
2016-09-30 13:16:00 +02:00
BoxManipulatorSourceInfo(BoxManipulatorPartManager::BoxFace cubeFace, BoxManipulatorPartManager::HandleType cubeFaceItem)
: m_cubeFace(cubeFace),
2016-09-30 13:16:00 +02:00
m_cubeHandle(cubeFaceItem)
{
}
2016-09-30 13:16:00 +02:00
BoxManipulatorPartManager::BoxFace m_cubeFace;
BoxManipulatorPartManager::HandleType m_cubeHandle;
};
}