MeVisLabToolboxReference
|
00001 // **InsertLicense** code 00002 //---------------------------------------------------------------------------------- 00004 00009 //---------------------------------------------------------------------------------- 00010 00011 #ifndef __SoView2DCSOEditor_H 00012 #define __SoView2DCSOEditor_H 00013 00014 #include "SoView2DCSOEditorBase.h" 00015 00016 #include <SoView2DExtension.h> 00017 00018 #include "CSOProcessor/CSOProcessorData.h" 00019 #include "CSOProcessor/CSOProcessor.h" 00020 00021 00022 class SoCSOTransform; 00023 00025 00026 struct CrossingPoint { 00027 CrossingPoint(){x=y=-1;} 00028 double x,y; 00029 }; 00030 00032 00033 const int KEY_CODE_SPACE = 32; 00034 const int KEY_CODE_ENTER = 65293; 00035 const int KEY_CODE_DELETE = 65535; 00036 const int KEY_CODE_BCKSPC = 65288; 00037 00039 00041 enum INTERACTIVE_MODE { 00042 INTERACTIVE_MODE_START_CSO = 0, 00043 INTERACTIVE_MODE_EDIT_CSO = 1, 00044 INTERACTIVE_MODE_MOVE_CSO = 2, 00045 INTERACTIVE_MODE_INSERT_SEED = 3, 00046 INTERACTIVE_MODE_SELECT_CSO = 4, 00047 INTERACTIVE_MODE_CLOSE_CSO = 5 00048 }; 00049 00051 00053 class SOCSO_EXPORT SoView2DCSOEditor : public SoView2DExtension, SoView2DCSOEditorBase 00054 { 00055 public: 00056 00058 SoView2DCSOEditor(); 00060 static void initClass(); 00061 00063 SoSFMLBase inCSOList; 00067 SoSFMLBase inProcessor; 00069 SoSFMLBase inStylePalette; 00070 00071 00073 // INTERACTION 00075 00077 enum INTERACTION_MODES { 00078 INTERACTION_MODE_EDIT = 0, 00079 INTERACTION_MODE_MOVE = 1 00080 }; 00081 00083 enum TOGGLE_MODE_KEYS { 00084 TOGGLE_MODE_NONE = 0, 00085 TOGGLE_MODE_ALT = 1, 00086 TOGGLE_MODE_CONTROL = 2, 00087 TOGGLE_MODE_SHIFT = 3 00088 }; 00089 00091 00093 enum EDITING_OPERATION_KEYBOARD_MODIFIERS { 00094 EDIT_OP_KEY_MOD_NONE = 0, 00095 EDIT_OP_KEY_MOD_ALT = 1, 00096 EDIT_OP_KEY_MOD_CONTROL = 2, 00097 EDIT_OP_KEY_MOD_SHIFT = 3 00098 }; 00099 00101 enum EDITING_OPERATION_KEYS { 00102 EDIT_OP_KEY_A, EDIT_OP_KEY_B, EDIT_OP_KEY_C, EDIT_OP_KEY_D, EDIT_OP_KEY_E, EDIT_OP_KEY_F, 00103 EDIT_OP_KEY_G, EDIT_OP_KEY_H, EDIT_OP_KEY_I, EDIT_OP_KEY_J, EDIT_OP_KEY_K, EDIT_OP_KEY_L, 00104 EDIT_OP_KEY_M, EDIT_OP_KEY_N, EDIT_OP_KEY_O, EDIT_OP_KEY_P, EDIT_OP_KEY_Q, EDIT_OP_KEY_R, 00105 EDIT_OP_KEY_S, EDIT_OP_KEY_T, EDIT_OP_KEY_U, EDIT_OP_KEY_V, EDIT_OP_KEY_W, EDIT_OP_KEY_X, 00106 EDIT_OP_KEY_Y, EDIT_OP_KEY_Z, 00107 00108 EDIT_OP_KEY_SPACE, 00109 EDIT_OP_KEY_ENTER, 00110 EDIT_OP_KEY_DELETE, 00111 EDIT_OP_KEY_BCKSPC 00112 }; 00113 00115 SoSFEnum generalInteractionMode; 00117 SoSFEnum generalInteractionModeToggleKey; 00119 SoSFBool movingOn; 00121 SoSFBool selectGroupsParsProToto; 00124 SoSFBool setPastedCSOsSelected; 00126 SoSFBool combinePastedCSOsToGroupsOfOriginalCSOs; 00129 SoSFEnum forceStartNewCSOKeyModifier; 00132 SoSFEnum forceStartNewCSOKey; 00134 SoSFBool shouldNotifyItself; 00136 SoSFBool shouldListenToRepaintEvents; 00138 SoSFBool shouldListenToSelectionChangedEvents; 00140 SoSFBool shouldListenToFinishedEvents; 00142 SoSFBool shouldLimitCSOMovement; 00145 SoSFFloat moveRatio; 00146 00147 00149 // DISPLAY 00151 00153 SoSFBool useAntiAliasing; 00155 SoSFBool useInterpolationTargetColor; 00157 SoSFColor interpolationTargetColor; 00159 SoSFBool showCSOsOnAllTimePoints; 00161 SoSFBool overwriteCurrentTimePoint; 00163 SoSFInt32 newCurrentTimePoint; 00165 SoSFBool showBoundingBox; 00167 SoSFFloat boundingBoxAlpha; 00169 SoSFColor boundingBoxColor; 00171 SoSFBool showOnlyParallelCSOs; 00174 SoSFFloat showParallelThickness; 00176 SoSFBool shouldLevelCSO; 00178 SoSFEnum ghostMode; 00180 SoSFEnum ghostUnitMode; 00182 SoSFBool ghostStyleAlpha; 00184 SoSFBool ghostStyleStipple; 00186 SoSFBool ghostStyleLineWidth; 00188 SoSFBool ghostStyleBrighten; 00190 SoSFFloat ghostDepth; 00192 SoSFFloat ghostFadeOutAlpha; 00194 SoSFBool useTessellation; 00196 SoSFBool showSeedPoints; 00197 00199 SoSFBool usePathPointColorForSeedPoints; 00200 00202 SoSFBool useHoleCorrection; 00204 SoSFBool useHoleCorrectionForGroupsOnly; 00206 SoSFEnum tessellationColorMode; 00208 SoSFColor tessellationColor; 00210 SoSFFloat tessellationAlpha; 00212 SoSFEnum tessellationWindingRule; 00214 SoSFFloat globalAlphaFactor; 00216 SoSFBool useFillingFromSide; 00219 SoSFEnum fillingFromSideLineWidthMode; 00221 SoSFFloat fillingFromSideManualLineWidthX; 00223 SoSFFloat fillingFromSideManualLineWidthY; 00224 00226 SoSFBool overwriteSelectionVisualizationSettings; 00228 SoSFEnum selectionColoringMode; 00230 SoSFColor selectionFixedColor; 00232 SoSFFloat selectionBrightenColor; 00234 SoSFEnum selectionLineWidthMode; 00236 SoSFFloat selectionFixedLineWidth; 00238 SoSFFloat selectionWidenLineWidth; 00239 00241 SoSFEnum selectedSeedPointColoringMode; 00243 SoSFColor selectedSeedPointFixedColor; 00245 SoSFFloat selectedSeedPointBrightenColor; 00247 SoSFFloat selectedSeedPointAlpha; 00249 SoSFEnum selectedSeedPointSizeMode; 00251 SoSFFloat selectedSeedPointSize; 00253 SoSFFloat selectedSeedPointEnlargeSize; 00254 00255 SoSFBool shouldOnlyInteractWithSelectedCSO; 00256 00257 enum WINDING_RULES { 00258 WR_ODD = GLU_TESS_WINDING_ODD, 00259 WR_NONZERO = GLU_TESS_WINDING_NONZERO, 00260 WR_POSITIVE = GLU_TESS_WINDING_POSITIVE, 00261 WR_NEGATIVE = GLU_TESS_WINDING_NEGATIVE, 00262 WR_ABS_GEQ_TWO = GLU_TESS_WINDING_ABS_GEQ_TWO 00263 }; 00264 00266 SoSFBool enableMouseOverHighlighting; 00268 SoSFEnum mouseOverColorMode; 00270 SoSFFloat mouseOverColorBrightenValue; 00272 SoSFColor mouseOverColorColor; 00274 SoSFEnum mouseOverLineWidthMode; 00276 SoSFFloat mouseOverLineWidthWidenValue; 00278 SoSFFloat mouseOverLineWidthLineWidth; 00280 SoSFInt32 currentlyUnderMouseCursorCSOId; 00281 00283 SoSFBool highlightSelectedGroups; 00284 00286 SoSFBool useStylePalette; 00288 SoSFEnum stylePaletteUseIndexAs; 00289 00291 enum LABEL_SHOW_MODES { 00292 LABEL_SHOW_NONE = 0, 00293 LABEL_SHOW_CSO_LABEL = 1, 00294 LABEL_SHOW_CSO_DESCRIPTION = 2, 00295 LABEL_SHOW_CSO_ID = 3, 00296 LABEL_SHOW_CSO_INDEX = 4, 00297 LABEL_SHOW_GROUP_LABEL = 5, 00298 LABEL_SHOW_GROUP_DESCRIPTION = 6, 00299 LABEL_SHOW_GROUP_ID = 7, 00300 LABEL_SHOW_GROUP_INDEX = 8, 00301 LABEL_SHOW_CSO_LENGTH = 9, 00302 LABEL_SHOW_CSO_AREA = 10 00303 }; 00304 00306 SoSFEnum labelShowMode; 00307 00310 SoSFBool combineLabelsForGroupsOnSlice; 00311 00313 enum LABEL_ALIGNMENT_MODES { 00314 LABEL_ALIGN_TOP_LEFT = 0, 00315 LABEL_ALIGN_TOP_RIGHT = 1, 00316 LABEL_ALIGN_BOTTOM_LEFT = 2, 00317 LABEL_ALIGN_BOTTOM_RIGHT = 3, 00318 LABEL_ALIGN_TOP = 4, 00319 LABEL_ALIGN_BOTTOM = 5, 00320 LABEL_ALIGN_LEFT = 6, 00321 LABEL_ALIGN_RIGHT = 7, 00322 LABEL_ALIGN_CENTER = 8 00323 }; 00324 00326 enum LABEL_UNITS_SCALES { 00327 LABEL_UNIT_SCALE_MM = 0, 00328 LABEL_UNIT_SCALE_CM = 1, 00329 LABEL_UNIT_SCALE_M = 2 00330 }; 00331 00333 SoSFEnum labelUnitScale; 00335 SoSFBool showLabelUnits; 00337 SoSFEnum labelAlignmentMode; 00339 SoSFFloat labelFontSize; 00341 SoSFBool labelUseTextShadow; 00343 SoSFFloat labelMarginX; 00345 SoSFFloat labelMarginY; 00347 SoSFColor generalLabelColor; 00349 SoSFFloat generalLabelAlpha; 00351 SoSFEnum labelColorMode; 00353 SoSFBool useIconFile; 00355 SoSFString iconFile; 00357 SoSFString internalIconFile; 00358 00360 // Edit Operations 00362 00364 SoSFEnum cutCopyKeyModifier; 00366 SoSFEnum copyKeyModifier; 00368 SoSFEnum pasteKeyModifier; 00370 SoSFEnum undoKeyModifier; 00372 SoSFEnum redoKeyModifier; 00374 SoSFEnum deleteSeedPointKeyModifier; 00376 SoSFEnum deleteCSOKeyModifier; 00378 SoSFEnum multiSelectionKeyModifier; 00380 SoSFBool enableMultiSelection; 00382 SoSFEnum cutCopyKey; 00384 SoSFEnum copyKey; 00386 SoSFEnum pasteKey; 00388 SoSFEnum undoKey; 00390 SoSFEnum redoKey; 00392 SoSFEnum deleteSeedPointKey; 00394 SoSFEnum deleteCSOKey; 00395 00397 SoSFTrigger triggerCutCopy; 00399 SoSFTrigger triggerCopy; 00401 SoSFTrigger triggerPaste; 00402 00404 SoSFString keyConfigurationStatus; 00405 00408 SoSFBool shouldUpdateInteractionStateAndCSOId; 00410 SoSFBool shouldTouchItselfInEvalEvent; 00411 00413 SoSFEnum nextInteractionStatus; 00414 00416 00417 00418 protected: 00419 00421 ~SoView2DCSOEditor(); 00423 virtual void draw(View2DSliceList* slicelist, View2DSlice* /* slice */, int z); 00424 00426 virtual bool evalEvent(SoView2D* view2d, View2DSliceList* slicelist, 00427 View2DEvent* ec, View2DEventPhase phase); 00428 00429 private: 00430 00431 /* DATA STRUCTURES*/ 00432 00433 struct CSOCrossings { 00434 CSOCrossings() {cso=NULL;sorted=false;needsFilling=false;} 00435 std::vector < CrossingPoint > crossingPoints; 00436 ml::CSO* cso; 00437 bool sorted; 00438 bool needsFilling; 00439 }; 00440 std::vector<CSOCrossings> crossings; 00441 00442 struct GroupBoundingBox { 00443 GroupBoundingBox() { group = NULL; firstCSOInGroup = NULL; } 00444 ml::CSOGroup* group; 00445 ml::CSO* firstCSOInGroup; 00446 ml::CSOBoundingBox boundingBox; 00447 }; 00448 std::vector<GroupBoundingBox> groupBoundingBoxes; 00449 00450 00451 /* NODE SENSOR */ 00452 00454 SoNodeSensor* _nodeSensor; 00456 static void _nodeChangedCB(void *data, SoDataSensor* a); 00458 void _nodeChanged(SoDataSensor* sensor); 00459 00460 /* MEMBER VARIABLES */ 00461 00463 View2DSliceList* _interactionSliceList; 00466 bool _isInNotificationCB; 00468 bool _isNotifyingMyselfRepaint; 00470 ml::CSOList* _csoList; 00472 ml::CSOProcessorData* _csoProcessorData; 00474 ml::CSOProcessorData* _lastValidProcessorData; 00476 ml::CSO* _recentlySelectedCSO; 00478 ml::CSOSeedPoint* _recentlySelectedSeedPoint; 00480 ml::CSOPathPoints* _recentlySelectedPathPoints; 00482 ml::CSO* _currentlyUnderMouseCursorCSO; 00484 std::vector<ml::CSO*>_copiedCSOs; 00486 ml::Vector3 _startingHitPoint; 00488 ml::Vector3 _lastCurrentHitPoint; 00490 int _startingTimePoint; 00492 bool _isCurrentlyMovingCSOs; 00494 bool _hasMovedCSOs; 00496 float* _imageSlice; 00498 int _imageSliceExtX; 00500 int _imageSliceExtY; 00502 int _imageSlicePosZ; 00504 SbVec3f _startWorldPositionCutCopy; 00506 SbVec3f _currentWorldPosition; 00509 SbVec3f _offsetVectorWorld; 00511 bool _hasValidStylePalette; 00513 int _lastInteractionMode; 00515 ml::CSOBoundingBox _slabBB; 00517 SoCSOTransform* _pCSOTransform; 00519 ml::CSOProcessorData* _defaultProcessorData; 00521 bool _isMultiSelectionEnabled; 00522 00524 unsigned int _imageSerialNumber; 00525 00527 std::map <int, std::vector<int> > _csoGroupIds; 00528 00529 /* METHODS */ 00530 00531 virtual bool getShouldOnlyInteractWithSelectedCSO() const { return shouldOnlyInteractWithSelectedCSO.getValue() == 1; } 00532 virtual float getSelectionTolerance() const { return selectionTolerance.getValue(); } 00533 virtual bool getShowOnlyParallelCSOs() const { return showOnlyParallelCSOs.getValue() == 1; } 00534 virtual bool getShowCSOsOnAllTimePoints() const { return showCSOsOnAllTimePoints.getValue() == 1; } 00535 virtual bool getOverwriteCurrentTimePoint() const { return overwriteCurrentTimePoint.getValue() == 1; } 00536 virtual int getNewCurrentTimePoint() const { return newCurrentTimePoint.getValue(); } 00537 00538 virtual float getShowParallelThickness() const { return showParallelThickness.getValue(); } 00539 virtual bool getUseStylePalette() const { return useStylePalette.getValue() == 1; } 00540 virtual float getGlobalAlphaFactor() const { return globalAlphaFactor.getValue(); } 00541 virtual int getStylePaletteUseIndexAs() const { return stylePaletteUseIndexAs.getValue(); } 00542 virtual bool getUseIconFile() const { return useIconFile.getValue() == 1; } 00543 virtual SbString getIconFile() const { return iconFile.getValue(); } 00544 virtual SbString getInternalIconFile() const { return internalIconFile.getValue(); } 00545 virtual bool getHighlightSelectedGroups() const { return highlightSelectedGroups.getValue() == 1; } 00546 00547 virtual bool getOverwriteSelectionVisualizationSettings() const { return overwriteSelectionVisualizationSettings.getValue() == 1; } 00548 virtual int getSelectionColoringMode() const { return selectionColoringMode.getValue(); } 00549 virtual float getSelectionBrightenColor() const { return selectionBrightenColor.getValue(); } 00550 virtual SbColor getSelectionFixedColor() const { return selectionFixedColor.getValue(); } 00551 virtual int getSelectionLineWidthMode() const { return selectionLineWidthMode.getValue(); } 00552 virtual float getSelectionWidenLineWidth() const { return selectionWidenLineWidth.getValue(); } 00553 virtual float getSelectionFixedLineWidth() const { return selectionFixedLineWidth.getValue(); } 00554 virtual int getSelectedSeedPointSizeMode() const { return selectedSeedPointSizeMode.getValue(); } 00555 virtual float getSelectedSeedPointBrightenColor() const { return selectedSeedPointBrightenColor.getValue(); } 00556 virtual float getSelectedSeedPointAlpha() const { return selectedSeedPointAlpha.getValue(); } 00557 virtual int getSelectedSeedPointColoringMode() const { return selectedSeedPointColoringMode.getValue(); } 00558 virtual SbColor getSelectedSeedPointFixedColor() const { return selectedSeedPointFixedColor.getValue(); } 00559 virtual float getSelectedSeedPointEnlargeSize() const { return selectedSeedPointEnlargeSize.getValue(); } 00560 virtual float getSelectedSeedPointSize() const { return selectedSeedPointSize.getValue(); } 00561 00562 virtual bool getEnableMouseOverHighlighting() const { return enableMouseOverHighlighting.getValue() == 1; } 00563 virtual int getMouseOverColorMode() const { return mouseOverColorMode.getValue(); } 00564 virtual SbColor getMouseOverColorColor() const { return mouseOverColorColor.getValue(); } 00565 virtual float getMouseOverColorBrightenValue() const { return mouseOverColorBrightenValue.getValue(); } 00566 virtual int getMouseOverLineWidthMode() const { return mouseOverLineWidthMode.getValue(); } 00567 virtual float getMouseOverLineWidthLineWidth() const { return mouseOverLineWidthLineWidth.getValue(); } 00568 virtual float getMouseOverLineWidthWidenValue() const { return mouseOverLineWidthWidenValue.getValue(); } 00569 virtual bool getUsePathPointColorForSeedPoints() const {return usePathPointColorForSeedPoints.getValue() == 1; } 00570 virtual bool getShowSeedPoints() const { return showSeedPoints.getValue() == 1; } 00571 00573 virtual int getLabelColorMode() const { return labelColorMode.getValue(); } 00574 virtual SbColor getGeneralLabelColor() const { return generalLabelColor.getValue(); } 00575 virtual float getGeneralLabelAlpha() const { return generalLabelAlpha.getValue(); } 00577 00578 00581 bool _evaluateKeyboardOperation(View2DEvent* ec, bool& deleteSeedPressed); 00583 void _performCutCopySelected(); 00585 void _performCopySelected(); 00587 void _performPasteSelected(View2DSliceList* slicelist); 00589 bool _evaluateForceStartNewCSO(View2DEvent* ec); 00591 void _storeCopiedCSOGroupInformation(); 00593 void _resetInteractionClasses(); 00596 void _checkUniqueEditingOperationKeys(); 00598 static void _csoListNotificationCB(void* userData, int notificationFlag); 00600 virtual void doAction(SoAction *action); 00601 00603 void _setMouseCursor(SoView2D* view2D, int mouseCursorShape); 00604 00606 ml::Vector3 _getPathPointColor(const ml::CSO* cso) const; 00607 00609 bool _intersectionSegmentPlane(const ml::Vector3& segmentPoint1, const ml::Vector3& segmentPoint2, 00610 const ml::Vector3& planePoint, const ml::Vector3& planeNormal, 00611 SbVec3f& intersectionPoint); 00612 00614 void _tessellateAllCSOsOnSlice(View2DSliceList* slicelist, View2DSlice* slice, int z); 00615 00617 void _glPathPointSettings(const ml::CSO* cso); 00619 void _glTessellationColor(const ml::CSO* cso); 00620 00622 void _drawLabel(View2DSliceList* slicelist, View2DSlice* slice, int z); 00624 void _renderLabelText( const std::string &labelText, ml::CSOBoundingBox& bb, View2DSlice* slice, const float vz, CSOVisualParameters &visualParameters ); 00625 00627 void _computeDeviceCoordinatesForLabel(const std::string &labelText, View2DFont* font, float lblFontSize, ml::CSOBoundingBox &csoVoxelBB, View2DSlice* slice, const float vz, float& devX, float& devY); 00628 00630 void _drawBoundBox(ml::CSO* cso, View2DSliceList* slicelist); 00632 void _drawCSOsFromSide(View2DSliceList* slicelist, View2DSlice* slice, int z); 00634 void _glDrawRect(float startX, float startY, float endX, float endY, float lineWidth); 00635 00636 00637 SO_NODE_HEADER(SoView2DCSOEditor); 00638 }; 00639 00641 00642 00643 #endif //__SoView2DCSOEditor_H 00644