MeVisLab Toolbox Reference
SoCSOBulgeEditor.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2013, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13
15
16#pragma once
17
20
21#include <ThirdPartyWarningsDisable.h>
22#include <boost/unordered_set.hpp>
23#include <ThirdPartyWarningsRestore.h>
24
26
29{
30 SO_NODE_HEADER(SoCSOBulgeEditor);
31
32public:
33
36
39
41 static void initClass();
42
47
52
55
56 void setVisibleCSOs(const std::vector<CSODrawCSOInfos>& drawCSOInformation,
57 const CSODrawView2DInfos& view2DInfos,
59
60 void createStartPressAt(const SoPointerPosition& ) override {}
61 void createDragMoveTo(const SoPointerPosition& ) override {}
62 bool createEndPress(int ) override { return false; }
64
67 SoPointingAction* selectAndMoveEndPress(int ) override { return nullptr; }
68
69 void bulgeStartPressAt(const SoPointerPosition& pos) override;
70 void bulgeDragMoveTo(const SoPointerPosition& pos) override;
71 SoPointingAction* bulgeEndPress(int clickCount) override;
72
73 void pointerPosition(const SoPointerPosition&) override;
74
75 void cancel() override;
76 bool isModificationEditor() const override { return true; }
77
78 bool shouldRenderSpecific(ml::CSO*) const override { return false; }
79 bool shouldRenderGeneral(ml::CSO*) const override { return true; }
80
81 bool isCSOWithIdVisible(int id);
82
83 void showInfluence(bool state);
84 void setBulgeInformation(ml::CSOList* csoList, ml::CSO* cso, ml::CSOPathPoints* pathPoints, unsigned int pathPointIndex, float distance);
85
86protected:
87
88 void initMembers() override;
89
90
91private:
92
93 struct PositionOnPath
94 {
95 PositionOnPath()
96 {
97 bulgeFactor = 0;
98 }
99 ml::Vector3 position;
100 float bulgeFactor;
101 };
102
103 void getDeviceCoordinates(View2DSliceList* slicelist, const ml::Vector3& position, float& deviceX, float& deviceY);
104 void getDeviceCoordinates(View2DSliceList* slicelist, const SbVec3f& position, float& deviceX, float& deviceY);
105
106 void fillPositionsOnPath(View2DSliceList* slicelist);
107 void fillPositionsOnPath(View2DSliceList* slicelist, std::vector <PositionOnPath>& positions, bool searchUpwards);
108
109 void draw(View2DSliceList* slicelist, const std::vector <PositionOnPath> & positions, float startX, float startY);
110
111 float getSquaredDistance(float x1, float y1, float x2, float y2) const;
112
113 void initializePositionsInteractive(const std::vector <PositionOnPath> & positionsInitial, std::vector <PositionOnPath> & positionsInteractive);
114
115 void movePositions(const std::vector <PositionOnPath> & source, std::vector <PositionOnPath> & destination, const SbVec3f& moveDelta);
116
117 void fillBulgedClosedCSO();
118 void fillBulgedOpenCSO();
119
120 std::vector <PositionOnPath> _positionsUpInitial;
121 std::vector <PositionOnPath> _positionsDownInitial;
122
123 std::vector <PositionOnPath> _positionsUpInteractive;
124 std::vector <PositionOnPath> _positionsDownInteractive;
125
126 ml::CSOPathPointIterator _endUpIter;
127 ml::CSOPathPointIterator _endDownIter;
128
129 unsigned int _hitPathPointIndex;
130 bool _shouldShowInfluence;
131 SbVec3f _startPosition;
132 bool _isBulging;
133 bool _wasCanceled;
134
135 boost::unordered_set < int > _visibleCSOIds;
136};
137
#define SOCSO_EXPORT
Header file for system independent resolution.
Definition SoCSOSystem.h:21
Extension for bulging any type of CSO in an influence radius.
void bulgeStartPressAt(const SoPointerPosition &pos) override
SoSFColor previewColor
The preview color.
SoPointingAction * bulgeEndPress(int clickCount) override
void bulgeDragMoveTo(const SoPointerPosition &pos) override
void selectAndMoveStartPressAt(const SoPointerPosition &) override
SoSFFloat previewWidth
The preview width.
void setVisibleCSOs(const std::vector< CSODrawCSOInfos > &drawCSOInformation, const CSODrawView2DInfos &view2DInfos, SoView2DCSOExtensibleEditor *editor) override
Sets visible CSOs that have been determined in the extensible editor.
bool shouldRenderGeneral(ml::CSO *) const override
Returns whether a given CSO should be rendered by this general extension.
void pointerPositionIfAllowedAt(const SoPointerPosition &) override
Sets seed points while moving the mouse – but not while dragging.
SoSFEnum interactionPossibleCursor
static void initClass()
init class in inventor runtime
void selectAndMoveDragMoveTo(const SoPointerPosition &) override
SoSFInt32 pathInfluenceLength
The influence along the path in pixel.
void setBulgeInformation(ml::CSOList *csoList, ml::CSO *cso, ml::CSOPathPoints *pathPoints, unsigned int pathPointIndex, float distance)
bool isCSOWithIdVisible(int id)
bool createEndPress(int) override
SoPointingAction * selectAndMoveEndPress(int) override
SoCSOBulgeEditor()
Standard constructor.
void draw(const CSODrawCSOInfos &csoInfos, const CSODrawView2DInfos &view2DInfos, const CSODrawSliceInformation &drawSliceInfo, SoView2DCSOExtensibleEditor *editor) override
Drawing routine.
void initMembers() override
void showInfluence(bool state)
bool shouldRenderSpecific(ml::CSO *) const override
Returns whether a given CSO should be rendered by this specific extension.
void createDragMoveTo(const SoPointerPosition &) override
SoSFEnum interactionPerformCursor
SoSFInt32 selectionDistance
The selection distance in pixel.
void cancel() override
Cancels an action like generating a CSO. Depends on concrete editor.
bool isModificationEditor() const override
Returns whether the editor is a modification editor.
void pointerPosition(const SoPointerPosition &) override
Is called when the mouse moves over a viewer.
void createStartPressAt(const SoPointerPosition &) override
Base class for an editor extension for the SoView2DCSOExtensibleEditor.
virtual void draw(const CSODrawCSOInfos &csoInfos, const CSODrawView2DInfos &view2DInfos, const CSODrawSliceInformation &sliceInfo, SoView2DCSOExtensibleEditor *editor)
Main routine for drawing a CSO.
SoPointerPosition manages the current position of the mouse cursor.
SoPointingAction is the base class for any mouse based interaction.
a list that holds all View2DSlice objects (lazily created) of a SoView2D
A CSOList comprises a number of CSOs and CSOGroups and is the central object for contour segmentation...
Definition CSOList.h:61
The CSOPathPoints is a list of world coordinates which are interpolated by a certain interpolation sc...
The CSO represents a contour segmentation object.
Definition CSO.h:44
Target mlrange_cast(Source arg)
Generic version of checked ML casts.