ImFusion SDK 4.3
GlSpline Class Reference

#include <ImFusion/GL/GlSpline.h>

Spline annotation. More...

+ Inheritance diagram for GlSpline:

Detailed Description

Spline annotation.

Renders a spline. Splines are parameterized in the range [0,1].

Public Types

enum class  RenderMode2d { Line , Tube , TubeHollow , Xray }
 
enum class  RenderMode3d { Line , Tube , TubeHollow , Xray }
 
- Public Types inherited from GlObject
enum  RenderingOrderGroup { RenderingGroupRest , RenderingGroupMesh , RenderingGroupManipulator }
 Enumeration to determine rendering order of GlObjects in GlSliceView and GlVolumeView. More...
 

Public Member Functions

 GlSpline ()
 Creates the spline.
 
 GlSpline (Spline *spline, bool takeOwnership=false)
 Create the GL spline fron an existing Spline (may take ownership)
 
 ~GlSpline () override
 Destroy the spline.
 
const Splinespline () const
 Returns encapsulated Spline instance.
 
void draw (const GlView &view) override
 Render annotation.
 
std::string typeName () const override
 Return unique identifier for this object class used for serialization.
 
void setLengthAsLabel (bool val)
 
bool lengthAsLabel () const
 
void setShowControlPoints (const std::vector< bool > &vec)
 
void convertToLabelMap (unsigned char *&buffer, int width, int height, const vec3 &spacing, unsigned char inValue=1, unsigned char outValue=0)
 
void configure (const Properties *p) override
 Set one or multiple properties.
 
void configuration (Properties *p) const override
 Retrieve the properties of this object.
 
bool hitTestLine2D (int x, int y, const GlView &view) const override
 Checks whether the line between handles gets hit (if not a straight line, override this in the annotation)
 
int hitTestHandles2D (int x, int y, const GlView &view) const override
 Returns the index of the handle being hit, or -1 when missing.
 
void setClosed (bool v)
 
bool closed () const
 
RenderMode2d renderMode2d () const
 
RenderMode3d renderMode3d () const
 
void setRenderMode (RenderMode2d mode2d)
 
void setRenderMode (RenderMode3d mode3d)
 
double tubeThickness () const
 
void setTubeThickness (double value)
 
double tubeEndT () const
 
void setTubeEndT (double value)
 
bool drawStartCap () const
 
void setDrawStartCap (bool value)
 
bool drawEndCap () const
 
void setDrawEndCap (bool value)
 
bool renderMPRIntersections () const
 
void setRenderMPRIntersections (bool b)
 
void setInterpolationRate (unsigned int v)
 
unsigned int interpolationRate () const
 
const std::vector< vec3 > & interpolatedPoints () const
 
size_t findClosestControlPoint (const vec3 &pos) const
 Returns index of the control point closest to a given position.
 
virtual double enclosedArea ()
 For closed loops, this returns the enclosed area in physical units used by the dataset.
 
vec3 normal () const
 
void updateNormal ()
 
void setNormal (const vec3 &newNormal, const vec3 *rotationCenter=nullptr)
 This will rotate the whole spline.
 
void setPoints (const std::vector< vec3 > &points) override
 Sets the annotation points.
 
void applyMatrix (const mat4 &matrix)
 
void addPoint (const vec3 &x, int index)
 
void removePoint (int index)
 
bool sampleRenderPath (int samples, std::vector< vec3 > &out) const override
 For annotations where the rendered shape differs from the stored points, this method returns true and a set of points on the rendered curve.
 
void setXrayTubeInnerRadius (double val)
 
double xrayTubeInnerRadius () const
 
virtual bool addPoint (const vec3 &p)
 Add point to annotation.
 
- Public Member Functions inherited from GlPointBasedAnnotation
void setView (const GlView *view) override
 Set the view through which this annotation is currently being manipulated.
 
bool hitTest (int x, int y, const GlView &view) const override
 Perform hit test at screen coordinates (x,y) (OpenGL screen coordinate system) for the specified view.
 
virtual int hitTestHandles3D (int x, int y, const GlView &view) const
 
virtual bool hitTestLabel (int x, int y, const GlView &view) const
 
const std::vector< vec3 > & points () const
 Return points making up the annotation.
 
int maxPoints () const
 Return maximum number of points allowed for annotation. -1 means no limit.
 
int minPoints () const
 Return minimum number of points required for annotation. -1 means no limit.
 
void setEditable (bool editable) override
 Set annotation to be editable, i.e.
 
virtual void setPointColor (const vec3 &color)
 Set point color.
 
vec3 pointColor () const
 Get point color.
 
Geometry::AlignedBox bounds () const override
 Get the axis-aligned bounding box of this GlObject in world space.
 
virtual void rotate (float angle)
 Change the GlObject matrix to reflect a rotation around the current m_rotationPoint Since this matrix is ignored by most renderers at the moment, this does not currently rotate anything.
 
virtual void rotateNoMatrix (float angle)
 Rotate the annotation by changing the handle positions instead of the matrix.
 
virtual void setRotationPoint (vec3 &point)
 Set the axis for rotation.
 
virtual void setPointSize (float s)
 Set the point size.
 
virtual void setLabelPixelOffset (const vec2 &offset)
 Set the label's pixel offset.
 
float pointSize () const
 Retrieve the point size.
 
virtual void setShowPointsAsCrosses (bool flag)
 Set the rendering of points.
 
virtual void setSelected (bool v) override
 When a GlAnnotation is selected, it may be rendered differently to distinguish it from non-selected annotations.
 
virtual void setMatrix (const mat4 &m) override
 Overwritten method to update points in world coordinates if the matrix has changed.
 
virtual void setMatrixWithoutMoving (const mat4 &m) override
 Change the matrix witout moving the annotation, e.g. for linking it with an image transformation.
 
virtual void setLineWidth (float value) override
 Set annotation line width.
 
void copyStyle (const GlPointBasedAnnotation &other)
 
virtual std::optional< vec3 > labelPosition (const GL::ViewState &state) const
 Position of the label If there is no valid position for the label, returns an empty optional.
 
- Public Member Functions inherited from GlAnnotation
virtual const GlViewview () const
 Get the view through which this annotation is currently being manipulated.
 
virtual bool editable () const
 When a GlAnnotation is editable it may alter its visualization and render UI elements for its manipulation.
 
virtual void setColor (const vec3 &color)
 Set annotation color.
 
virtual vec3 color () const
 Return annotation color.
 
virtual void setAlpha (double v)
 Set alpha channel.
 
virtual double alpha () const
 Get alpha channel.
 
virtual float lineWidth () const
 Return annotation line width.
 
virtual void setLabelVisible (bool visible)
 Set annotation label visibility.
 
virtual bool labelVisible () const
 Return annotation label visibility.
 
virtual void setLabelBackgroundVisible (bool visible)
 Set annotation label background visibility.
 
virtual bool labelBackgroundVisible () const
 Return annotation label background visibility.
 
virtual void setLabelBackgroundColor (vec4 color)
 Set annotation label background color.
 
virtual vec4 labelBackgroundColor () const
 Return annotation label background color.
 
virtual void setLabelBackgroundMargin (int margin)
 Set annotation label background margin in pixels.
 
virtual int labelBackgroundMargin () const
 Return annotation label background margin in pixels.
 
virtual void setLabelDepthTest (bool depthTest)
 Set annotation label depth test flag.
 
virtual bool labelDepthTest () const
 Return annotation label depth test flag.
 
virtual void setLabelColor (const vec3 &color)
 Set annotation label color.
 
virtual vec3 labelColor () const
 Return annotation label color.
 
virtual void setLabelText (const std::string &label)
 Set annotation label text.
 
virtual std::string labelText () const
 Return annotation label text.
 
virtual void setLabelTextPrefix (const std::string &labelPrefix)
 Set annotation label text prefix.
 
std::string labelTextPrefix () const
 Return annotation label text prefix.
 
virtual void setLabelTextSuffix (const std::string &labelSuffix)
 Set annotation label text suffix.
 
std::string labelTextSuffix () const
 Return annotation label text suffix.
 
virtual void setName (const std::string &name)
 Set annotation name.
 
virtual std::string name () const
 Return annotation name.
 
bool selected () const
 When a GlAnnotation is selected, it may be rendered differently to distinguish it from non-selected annotations.
 
void copyStyle (const GlAnnotation &other)
 Copies the settable parameters from another GlAnnotation.
 
- Public Member Functions inherited from GlObject
virtual Geometry::AlignedBox boundsSpherical () const
 Get the spherical bounds of this GlObject in world space.
 
virtual const mat4 & matrix () const
 Return the modelview matrix.
 
virtual void setVisible (bool visible)
 Set object visibility.
 
virtual bool visible () const
 Return object visibility.
 
virtual void setAlwaysVisible (bool alwaysVisible)
 Set if object is always visible.
 
virtual bool alwaysVisible () const
 Return if object is always visible.
 
RenderingOrderGroup renderingOrder () const
 Return current rendering order value for this GlObject.
 
void setRenderingOrder (RenderingOrderGroup group)
 Set rendering order value for this GlObject.
 
void setDraw3DIn2DView (bool draw3DIn2DView)
 
- Public Member Functions inherited from Configurable
virtual void configureDefaults ()
 Retrieve the properties of this object, replaces values with their defaults and sets it again.
 
void registerParameter (ParameterBase *param)
 Register the given Parameter or SubProperty, so that it will be configured during configure()/configuration().
 
void unregisterParameter (const ParameterBase *param)
 Remove the given Parameter or SubProperty from the list of registered parameters.
 
 Configurable (const Configurable &rhs)
 
 Configurable (Configurable &&rhs) noexcept
 
Configurableoperator= (const Configurable &)
 
Configurableoperator= (Configurable &&) noexcept
 

Protected Member Functions

void updatePoints () override
 Update the internal point structure.
 
void updateTubeBuffers ()
 
void drawTube (const GlView &view, const std::optional< Geometry::Plane > &plane)
 
- Protected Member Functions inherited from GlPointBasedAnnotation
void renderLabel (const GlView &view) const
 
void renderPoints (const GlView &view) const
 Render points.
 
void renderPoint (const GlView &view, int index) const
 Render point with the given index. Use -1 to render all points.
 
bool viewIsMetric () const
 
void renderLabel (const GlView &view, const vec3 &positionWorld) const
 Render the label of the annotation at the given position.
 
- Protected Member Functions inherited from GlAnnotation
void renderLabel (const GlView &view, const vec3 &positionWorld) const
 Render the label of the annotation at the given position.
 
vec2i labelSize () const
 

Protected Attributes

std::unique_ptr< Splinem_spline
 
std::unique_ptr< GL::Programm_tubeShader2D
 
std::unique_ptr< GL::Programm_tubeShader3D
 
std::unique_ptr< GL::VertexBufferm_tubeVbo
 
std::unique_ptr< GL::VertexBufferm_splineVbo
 
std::vector< vec3 > m_interpolatedPoints
 
vec3 m_planeNormal
 
double m_length
 
bool m_lengthAsLabel
 
std::vector< bool > m_showControlPoints
 
unsigned int m_interpolationRate
 
RenderMode2d m_renderMode2d = RenderMode2d::Line
 
RenderMode3d m_renderMode3d = RenderMode3d::Line
 
double m_tubeThickness = 1.0
 
double m_tubeEndT = 1.0
 
bool m_drawEndCap = false
 
bool m_drawStartCap = false
 
bool m_tubeBuffersDirty = false
 
bool m_tubeShader2dDirty = false
 
bool m_tubeShader3dDirty = false
 
double m_xrayTubeInnerRadius = 0.7
 
bool m_renderMPRIntersections = false
 
bool m_ownSpline = true
 
- Protected Attributes inherited from GlPointBasedAnnotation
std::unique_ptr< GL::VertexBufferm_vbo
 Vertex buffer that can be used for rendering.
 
std::vector< vec3 > m_points
 Control points which define the form of the annotation.
 
std::vector< vec3 > m_worldPoints
 Points in world coordinates if object matrix differs from identity.
 
bool m_wpDirty = false
 True if the world point vector has to be updated.
 
bool m_showPointsAsCrosses = false
 
int m_maxPoints = -1
 
int m_minPoints = -1
 
float m_pointSize = 5.f
 
vec2 m_labelPixelOffset = vec2(6.0, 0.0)
 
vec4 m_pointColor = vec4(1, 1, 0, 1)
 
vec3 m_rotationPoint = vec3::Zero()
 
double m_hitTest2DMinSize = 4.0
 
double m_hitTest3DMinSize = 6.0
 
- Protected Attributes inherited from GlAnnotation
bool m_editable = true
 
vec4 m_color {1, 1, 0, 1}
 
float m_lineWidth = 1
 
bool m_labelVisible = true
 
bool m_labelBackgroundVisible = false
 
vec4 m_labelBackgroundColor {0.3, 0.3, 0.3, 0.7}
 
int m_labelBackgroundMargin = 3
 
bool m_labelDepthTest = true
 
bool m_selected = false
 
vec3 m_labelColor {0, 1, 1}
 
std::string m_labelText
 
std::string m_labelTextPrefix
 
std::string m_labelTextSuffix
 
const GlViewm_view = nullptr
 
std::string m_name
 
- Protected Attributes inherited from GlObject
mat4 m_matrix = mat4::Identity()
 Modelview transformation matrix of this object.
 
bool m_visible = true
 Object visibility.
 
bool m_alwaysVisible = false
 Object always visible.
 
bool m_draw3DIn2DView
 Draw 3D objects in 2D views. This is to render 3D objects in projective 2D views. Property is not serialized.
 
RenderingOrderGroup m_renderingOrder = RenderingGroupRest
 
- Protected Attributes inherited from Configurable
std::vector< Paramm_params
 List of all registered Parameter and SubProperty instances.
 

Additional Inherited Members

- Public Attributes inherited from GlPointBasedAnnotation
Signal< const GlPointBasedAnnotation * > signalPointsChanged
 
- Public Attributes inherited from Configurable
Signal signalParametersChanged
 Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted.
 

Member Function Documentation

◆ draw()

void draw ( const GlView & view)
overridevirtual

Render annotation.

Implements GlObject.

◆ typeName()

std::string typeName ( ) const
inlineoverridevirtual

Return unique identifier for this object class used for serialization.

Implements GlObject.

◆ configure()

void configure ( const Properties * p)
overridevirtual

Set one or multiple properties.

Reimplemented from GlPointBasedAnnotation.

◆ configuration()

void configuration ( Properties * p) const
overridevirtual

Retrieve the properties of this object.

Reimplemented from GlPointBasedAnnotation.

◆ hitTestLine2D()

bool hitTestLine2D ( int x,
int y,
const GlView & view ) const
overridevirtual

Checks whether the line between handles gets hit (if not a straight line, override this in the annotation)

Reimplemented from GlPointBasedAnnotation.

◆ hitTestHandles2D()

int hitTestHandles2D ( int x,
int y,
const GlView & view ) const
overridevirtual

Returns the index of the handle being hit, or -1 when missing.

Reimplemented from GlPointBasedAnnotation.

◆ enclosedArea()

virtual double enclosedArea ( )
virtual

For closed loops, this returns the enclosed area in physical units used by the dataset.

Ignores curvature (assumes planar spline), requires ordered vertices.

◆ setPoints()

void setPoints ( const std::vector< vec3 > & points)
overridevirtual

Sets the annotation points.

Clears previous points.

Parameters
pointspoints

Reimplemented from GlPointBasedAnnotation.

◆ sampleRenderPath()

bool sampleRenderPath ( int samples,
std::vector< vec3 > & out ) const
overridevirtual

For annotations where the rendered shape differs from the stored points, this method returns true and a set of points on the rendered curve.

Otherwise it returns false and the control points.

Reimplemented from GlPointBasedAnnotation.

◆ updatePoints()

void updatePoints ( )
overrideprotectedvirtual

Update the internal point structure.

Should be implemented by subtypes which have custom data depending on the point data. Derived implementation needs to call base class implementation.

Reimplemented from GlPointBasedAnnotation.

◆ addPoint()

virtual bool addPoint ( const vec3 & p)
virtual

Add point to annotation.

Parameters
ppoint to add

Reimplemented from GlPointBasedAnnotation.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close