MeVisLab Toolbox Reference
SoCSOModifyEditor.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 
22 
25 {
26  SO_NODE_HEADER(SoCSOModifyEditor);
27 
28 public:
29 
32 
48 
49  SoSFEnum defaultCursor;
50 
52  static void initClass();
53 
54  void createStartPressAt(const SoPointerPosition& pos) override;
55  void createDragMoveTo(const SoPointerPosition& pos) override;
56  bool createEndPress(int clickCount) override;
58 
59  bool isCreationAllowed() const override;
60  bool isModificationEditor() const override { return true; }
61 
62  void drawAdditionalGeometry(const CSODrawView2DInfos& view2DInfos, SoView2DCSOExtensibleEditor* editor) override;
63  // This editor does not actually create CSOs but otherwise the mouse events would not reach this.
64  bool canCreateCSOs() const override { return true; }
66  bool shouldRenderSpecific(ml::CSO*) const override { return false; }
68  bool shouldRenderGeneral(ml::CSO*) const override { return false; }
69 
70  // just overload the methods below because they are purely virtual but not used in here
72  void selectAndMoveDragMoveTo(const SoPointerPosition&) override {}
73  SoPointingAction* selectAndMoveEndPress(int) override { return nullptr; }
74 
75  int cursorShape() const override { return defaultCursor.getValue(); }
76 
82  ml::CSOPathPoints*& , float& ) override
83  {
84  return false;
85  }
86 
87  void cancel() override;
88 
89 protected:
90 
91  void initMembers() override;
92 
93 
94 private:
95 
97  ml::CSO* getModifyCandidate();
99  bool isEligibleForModification(ml::CSO* cso);
102  void fillPreCandidatesList(std::vector < ml::CSO* >& candidates);
105  void fillCandidatesOnSameSlice(const std::vector < ml::CSO* >& candidates, std::vector < ml::CSO* >& candidatesOnSameSlice);
108  void fillCandidatesCrossedVoxelBoundingBox(const std::vector < ml::CSO* >& candidatesOnSameSlice, std::vector < ml::CSO* >& candidatesCrossedBoundingBox);
111  void fillCandidatesPointInsideTrailBoundingBox(const std::vector < ml::CSO* >&candidatesCrossedBoundingBox, std::vector < ml::CSO* >& candidatesPointInsideTrailBoundingBox);
114  void fillCandidatesCrossedByTrail(const std::vector < ml::CSO* >& candidatesPointInsideTrailBoundingBox, std::vector < ml::CSO* >& candidatesCrossingTrail);
115 
117  void modifyCandidate(ml::CSO* candidate);
118 
120  void reverseOrder(std::vector < ml::Vector3 >& positions );
121 
124  void fillUpTrail(const std::vector < ml::Vector3 >& inputPositions, std::vector < ml::Vector3 >& filledOutputPositions);
125 
126  void setupGLForTrail();
127  void setBackGLForTrail();
128 
131  void floorCeilCSOBoundingBox(ml::CSOBoundingBox& boundingBox);
132 
134  bool _isUNIONModification;
135 
136  CSOTrailRenderer _trailRenderer;
137 
138  std::string viewerName;
139 
140  std::map < ml::CSO* , std::vector < ml::Vector3> > _csoPathPointsVoxelSpace;
141 
143  bool contains(const std::vector< ml::CSO* >& csoVector, ml::CSO* cso) const;
144 
145  bool _wasCanceled;
146 
147  ml::Matrix4 _worldToVoxelMatrix;
148 };
149 
#define SOCSO_EXPORT
Header file for system independent resolution.
Definition: SoCSOSystem.h:21
Base class for an editor extension for the SoView2DCSOExtensibleEditor.
Extension for modifying an existing CSO.
bool shouldRenderSpecific(ml::CSO *) const override
Does not render specific CSOs but only its own temporary trail.
bool isModificationEditor() const override
Returns whether the editor is a modification editor.
void selectAndMoveStartPressAt(const SoPointerPosition &) override
SoSFBool shouldCheckCSOForSelfIntersection
If checked, the module tests a candidate CSO whether it is self-intersection before attempting to mod...
static void initClass()
init class in inventor runtime
SoCSOModifyEditor()
Standard constructor.
SoSFTrigger notifyTrailIsSelfIntersecting
Button is triggered from the inside if the modification trail is intersecting itself.
void drawAdditionalGeometry(const CSODrawView2DInfos &view2DInfos, SoView2DCSOExtensibleEditor *editor) override
Routine for drawing additional geometry of the extension.
void createStartPressAt(const SoPointerPosition &pos) override
bool createEndPress(int clickCount) override
void createDragMoveTo(const SoPointerPosition &pos) override
void selectAndMoveDragMoveTo(const SoPointerPosition &) override
bool shouldRenderGeneral(ml::CSO *) const override
Returns true so we can use the general render code.
void cancel() override
Cancels an action like generating a CSO. Depends on concrete editor.
SoSFTrigger notifyRejectModification
Button is triggered from the inside if the modification has been rejected because it would have cause...
void initMembers() override
SoSFColor selfIntersectionColor
Color for the trail in case it intersects itself.
bool evaluateHitPoint(const ml::Vector3 &, View2DSliceList *, ml::CSOList *, const ml::CSOBoundingBox &, SoView2DCSOExtensibleEditor *, ml::CSO *&, ml::CSOSeedPoint *&, ml::CSOPathPoints *&, float &) override
a modification interaction can start anywhere, so overload this and always return 'false'.
int cursorShape() const override
Returns the cursor shape that indicates the next creation.
bool isCreationAllowed() const override
Returns whether the editor is allowed to create a new CSO.
SoPointingAction * selectAndMoveEndPress(int) override
SoSFBool shouldSetModifiedCSOSelected
If checked, the modified CSO gets selected, otherwise the selection remains unchanged.
bool canCreateCSOs() const override
Returns whether the editor can create a CSO.
void pointerPositionIfAllowedAt(const SoPointerPosition &) override
Sets seed points while moving the mouse – but not while dragging.
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
The CSOBoundingBox defines an axis parallel bounding box with double precision.
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...
Definition: CSOPathPoints.h:37
The CSOSeedPoint can be interactively set and modified and is the framework for contours.
Definition: CSOSeedPoint.h:35
The CSO represents a contour segmentation object.
Definition: CSO.h:44