23 class CSOLabelRenderer;
211 DeviceOffset() { xOffset = yOffset = 0; }
217 std::map < int, std::string > _csoLabelStrings;
219 std::map < int, std::string > _csoLabelNames;
221 std::map < int, std::string > _csoLabelCaptions;
223 std::map < int, DeviceOffset > _csoDeviceOffsets;
225 std::map < int, bool > _shouldRenderLabel;
228 std::multimap < std::string, CSOLabelRenderInformation > _viewerLabelRenderInformation;
230 void filterCSOLabelsForLayout(
const std::vector<CSODrawCSOInfos>& drawCSOInfos,
232 std::vector<CSODrawCSOInfos>& filteredDrawCSOInfos);
235 void clearInternalStructures();
237 void buildAllLabelStringsThatNeedUpdate(
ml::CSOList* csoList);
243 bool getLabelRenderInformation(
const std::string& viewerId,
unsigned int csoId,
CSOLabelRenderInformation& labelRenderInfo);
247 void removeLabelRenderInformation(
const std::string& viewerId,
ml::CSO* cso);
249 void removeAllLabelRenderInformationForCSOId(
int id,
bool removeAll=
false);
265 void buildLabelString(
ml::CSO* cso);
269 void drawResizeHandlers(
const SbVec2f& upperLeft,
const SbVec2f& size);
274 const SbVec2f& upperLeft,
const SbVec2f& size);
278 const SbVec2f& labelMidPoint,
float& lineX1,
float& lineY1);
281 bool isMouseOverLabelOrCSOForInteraction(
ml::CSO* cso);
283 bool isMouseOverLabelOrCSOForHighlighting(
ml::CSO* cso);
288 void getCSOPoints(
const CSODrawCSOInfos& csoInfos, std::vector< ml::Vector3 >& csoPoints );
291 void ensureLabelIsVisible(
View2DSlice* slice, SbVec2f& labelUpperLeft, SbVec2f& labelSize);
293 bool isLabelInsideViewer(
View2DSlice* slice, SbVec2f& labelUpperLeft, SbVec2f& labelSize);
295 float fitFontSizeToBox(
const CSOLabelRenderInformation& labelRenderInformation,
const std::string& labelString,
float originalFontSize);
298 void moveLabelRelative(
const std::string& viewerId,
ml::CSO* cso,
const SoPointerPosition& pos,
const SbVec2f& relativeMovementOffset);
301 void setLabelRelative(
const std::string& viewerId,
ml::CSO* cso,
const SbVec2f relativePosition);
303 SbVec2f getRelativePositionOfCSOInViewer(
const std::string& viewerId,
ml::CSO* cso);
305 float getResizeDelta(
const SbVec2f& currentDevicePosition,
int resizeHandlerCode );
307 void drawGLRectangle(
const SbVec2f& upperLeft,
const SbVec2f& lowerRight,
float offset=0,
float lineWidth=1)
const;
309 bool isInRectangle(
const SbVec2f& rectUpperLeft,
const SbVec2f& rectLowerRight,
const SbVec2f& position)
const;
312 float distance(
float x0,
float y0,
float x1,
float y1)
const;
314 void clipLineToRectangle(
float& lineX0,
float& lineY0,
float& lineX1,
float& lineY1,
float rectMinX,
float rectMinY,
float rectMaxX,
float rectMaxY)
const;
316 int outcode(
float lineX,
float lineY,
float rectMinX,
float rectMinY,
float rectMaxX,
float rectMaxY)
const;
319 void getLabelSize(
float fontSize,
const std::string& labelString,
int& labelWidth,
int& labelHeight);
327 void computeLabelBoxes(
const std::vector<CSODrawCSOInfos>& filteredDrawCSOInfos,
const CSODrawView2DInfos& view2DInfos, std::map < int, SbVec2f >& labelBoxes);
341 SbVec2f computeNewDetachedLabelPositionWhileInteracting(
const SbVec2f& lastRelativeLabelPosition,
const SbVec2f& relativeMovementOffset,
const CSOLabelRenderInformation& labelRenderInfo,
ml::CSO* cso,
View2DSlice* slice );
347 void getFreePosition(
float& deviceX,
float& deviceY,
const std::string& viewerId,
float labelWidth,
float labelHeight,
View2DSlice* slice);
349 bool boundingBoxesIntersect(
const CSOLabelRenderInformation& labelRenderInfo,
float deviceX,
float deviceY,
float labelWidth,
float labelHeight);
351 static void baseEventCB(
void* userData,
ml::BaseEvent* event);
354 bool needsUpdate(
ml::CSO* cso);
362 bool shouldRenderLabelString(
unsigned int csoId,
const std::string& viewerId);
369 std::set<int> _needsUpdateCSOIds;
372 SbVec2f _startDragDevicePosition;
374 SbVec2f _startDragOffsetToCenter;
376 SbVec2f _currentFrameUpperLeft;
378 SbVec2f _currentFrameLowerRight;
380 SbVec2f _relativeLabelPosition;
382 ml::CSO* _csoLabelUnderMouseForInteraction;
384 ml::CSO* _csoLabelUnderMouseForHighlighting;
387 float _minimumFontSize;
389 float _maximumFontSize;
ResizeHotSpot
Enumeration of hot spots for resizing the label.
#define SOCSO_EXPORT
Header file for system independent resolution.
Base class for an editor extension for the SoView2DCSOExtensibleEditor.
Extension for rendering labels for CSOs.
int cursorShape() const override
Returns the cursor shape that indicates the next creation.
SoPointingAction * labelResizeEndPress(ml::CSO *cso, int clickCount)
void setVisibleCSOs(const std::vector< CSODrawCSOInfos > &drawCSOInformation, const CSODrawView2DInfos &view2DInfos, SoView2DCSOExtensibleEditor *editor) override
Set information about all the CSOs that are to be rendered.
void labelResizeStartPressAt(ml::CSO *cso, const SoPointerPosition &pos)
SoPointingAction * labelMoveEndPress(ml::CSO *cso, int clickCount)
SoSFEnum viewerBorderHandling
Handling of labels that move over the viewer's border.
SoSFString outputInfoLabelCaption
Output of the label's caption.
void drawOverlay(const CSODrawCSOInfos &csoInfos, const CSODrawView2DInfos &view2DInfos, const CSODrawSliceInformation &drawSliceInfo, SoView2DCSOExtensibleEditor *editor) override
Routine for drawing after the main routine has drawn.
void selectAndMoveStartPressAt(const SoPointerPosition &) override
void labelMoveStartPressAt(ml::CSO *cso, const SoPointerPosition &pos)
SoSFBool shouldDrawResizeHandlers
Shall resize handlers be drawn?
void createStartPressAt(const SoPointerPosition &) override
SoSFBool outputInfoIsValid
Flag to indicate whether the output info is valid.
ml::CSO * getLabelCSO(const std::string ¤tViewerId, const SoPointerPosition &pos)
Returns the pointer to a CSO whose label is on the given viewer under the given position.
SoSFInt32 labelBorderMarginY
Sets the inner margin of the label border in y-direction.
bool createEndPress(int) override
void setLabelUnderMouseForHighlighting(ml::CSO *cso)
Sets the label for the given CSO as being under the mouse for highlighting.
void labelMoveDragMoveTo(ml::CSO *cso, const SoPointerPosition &pos)
void pointerPosition(const SoPointerPosition &pos) override
Called when the mouse moves over a viewer.
~SoCSOLabelRenderer() override
Destructor.
bool isModificationEditor() const override
Returns whether the editor is a modification editor.
SoSFTrigger repaintTrigger
Just a dummy field to trigger a repaint.
SoSFInt32 labelBorderMarginX
Sets the inner margin of the label border in x-direction.
void drawSecondPass(const CSODrawCSOInfos &csoInfos, const CSODrawView2DInfos &view2DInfos, const CSODrawSliceInformation &drawSliceInfo, SoView2DCSOExtensibleEditor *editor) override
Drawing routine that comes between 'main' and 'overlay'.
static void initClass()
init class in inventor runtime
SoSFEnum detachedLabelPlacement
Positioning strategy for detached (manually moved) labels.
SoSFEnum movePossibleCursor
SoSFEnum movePerformCursor
void createDragMoveTo(const SoPointerPosition &) override
ml::CSO * getHitResizeHandler(const std::string ¤tViewerId, const SoPointerPosition &pos, int &resizeHandlerCode)
Returns the pointer to a CSO whose label is on the given viewer under the given position....
void computeOutputInformation()
Fills output information fields for a CSO on a viewer.
SoSFInt32 minConnectingLineLength
The minimum length of a connecting line to get drawn (in pixel).
SoSFVec2f outputInfoLabelBoundingBoxStart
Output of the upper left corner of the label's bounding box.
void labelResizeDragMoveTo(ml::CSO *cso, const SoPointerPosition &pos, int resizeHandlerCode)
SoSFMLBase inLabelPlacement
Option input of label placement.
SoSFBool shouldRenderLabelName
Shall the label name be rendered at the CSO when the label has been moved away?
SoSFVec2f outputInfoLabelBoundingBoxEnd
Output of the lower right corner of the label's bounding box.
SoSFBool shouldDrawConnectingLine
Shall a connecting line between the label and the CSO be drawn?
SoCSOLabelRenderer()
Standard constructor.
void pointerLeftWindow() override
Called when mouse pointer leaves the window.
SoSFFloat connectingLineAlpha
Global alpha factor that is multiplied to the local alpha factor of connecting lines.
SoSFBool shouldShowLabelStringOfOutputInfoLabel
Should the label string be hidden for the label.
SoSFBool allowLabelResize
Shall the user be allowed to resize a label?
SoSFInt32 fontSize
Sets the font size of the text.
void setOuterModule(ml::CSOLabelRenderer *labelRendererModule)
Sets a pointer to the 'outer' module.
SoSFInt32 outputInfoLabelCaptionWidth
Output of the x-offset value of the label's string.
SoSFBool tryToPlaceLabelsWithoutOverlap
Should the renderer attempt to place a label without overlapping other labels?
SoPointingAction * selectAndMoveEndPress(int) override
SoSFBool drawLabelBorderForSelectedCSO
Shall a border be drawn around the label of a selected CSO?
void selectAndMoveDragMoveTo(const SoPointerPosition &) override
void resetCache() override
Resets the internal label string cache.
SoSFString inputInfoViewerId
Input of the viewer id string.
void pointerPositionIfAllowedAt(const SoPointerPosition &) override
Sets seed points while moving the mouse – but not while dragging.
void updateStringsInCache()
Updates all label strings in the cache.
SoSFBool drawConnectingLineToCenterOfCSO
Shall the connecting line be drawn to th center of a CSO? Or to the nearest point on the CSO?
void setLabelUnderMouseForInteraction(ml::CSO *cso)
Sets the label for the given CSO as being under the mouse for interaction (select,...
void startDrawing(View2DSliceList *slicelist) override
Is called before drawing.
SoSFBool shouldHighlightBorderOnMouseOver
Shall the label's border be highlighted on mouse over?
void draw(const CSODrawCSOInfos &csoInfos, const CSODrawView2DInfos &view2DInfos, const CSODrawSliceInformation &drawSliceInfo, SoView2DCSOExtensibleEditor *editor) override
Drawing routine.
bool shouldRenderGeneral(ml::CSO *) const override
Returns whether a given CSO should be rendered by this general extension.
SoSFInt32 inputInfoCSOId
Trade interface for retrieving the device position (and other information) of a label on a certain vi...
SoSFString outputInfoLabelString
Output of the label's string.
SoPointerPosition manages the current position of the mouse cursor.
SoPointingAction is the base class for any mouse based interaction.
The SoSFMLBase field is the interface used by Inventor nodes to output ML Base objects to the outside...
SoView2D is a 2D viewer for image data.
a list that holds all View2DSlice objects (lazily created) of a SoView2D
a single slice that is stored in a View2DSliceList, typically created by a View2DSliceList
BaseEvent is the base class for all events emitted from EventSourceBase.
Base module for providing custom label placement strategies.
Module encapsulation the SoView2D extension for rendering labels for CSOs.
A CSOList comprises a number of CSOs and CSOGroups and is the central object for contour segmentation...
The CSO represents a contour segmentation object.