MeVisLab Toolbox Reference
SoView2DLegend.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, 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
18#include "SoView2DSystem.h"
19#include "SoView2DExtension.h"
20
21#include <Inventor/fields/SoFields.h>
22#include <vector>
23
24class SoView2D;
25class View2DFont;
26
35
37
39{
40public:
43 line_width=1.0f;
44 stipple = 0xffff;
45 };
46
48 LegendItem(const LegendItem &li){*this = li;};
49
52 color = li.color;
53 line_width = li.line_width;
54 stipple = li.stipple;
55 text = li.text;
56
57 return *this;
58 };
59
65 unsigned short stipple;
68};
69
71
73{
74 SO_NODE_HEADER(SoView2DLegend);
75
76public:
84
88 LINE_TEXT
89 };
90
100
117
118 static void initClass();
119
120 // Constructor
122
123 // toggle legend display
125
126protected:
128 void draw(View2DSliceList *dsl, View2DSlice* dslice, int slice) override;
129
130 // evaluates keyboard and mouse events
131 bool evalEvent(SoView2D* view2d, View2DSliceList* slicelist, View2DEvent* ec, View2DEventPhase phase) override;
132
134 virtual bool implementsManagedInteraction() const { return true; }
135
138 bool implementsManagedInteractionAndClassicEventHandling() const override { return true; }
139
142
143private:
145 void parseString(const SbString &string);
146
148 void drawLegend(View2DSlice* slice, const float dx1, const float dy1, const float dx2, const float dy2, const int width, const int height,
149 View2DFont *font, const int fontSize, const int pos, const bool drawBox=FALSE);
150
152 int getFontSize(const int fontGroup) const;
153
155 std::vector<LegendItem>_legendVector;
156
158 long _lastEventSecs;
160 long _lastEventUSecs;
161
162 SoCommandAction* _toggleLegendAction;
163};
View2DEventPhase
event phase for simple extensions that grab the focus, do something (motion) and are released afterwa...
LegendFontSize
font sizes
@ LARGE_LEGEND
@ AUTO_SIZE_LEGEND
@ MEDIUM_LEGEND
@ SMALL_LEGEND
#define SOVIEW2D_API
File to resolve system dependencies in View2D library.
class holds legend item information
const LegendItem & operator=(const LegendItem &li)
assignemt operator
unsigned short stipple
line stipple
LegendItem()
defaut constructor
float line_width
line width
LegendItem(const LegendItem &li)
copy constructor
SbString text
text as a string
SbColor color
color
SoCommandAction is the base class for instantaneous actions.
SoView2DExtension Base class for all View2DExtensions used for drawing and event handling on the View...
SoView2DLegend allows to draw legends on SoView2D.
SoSFBool drawTheBox
draw the box?
SoSFEnum legendAlignment
set the alignment
SoSFEnum legendFormat
text <-> line
SoSFString legendString
the string to be parsed the format for one entry (item) is: $(item rr gg bb line_width line_stipple "...
bool evalEvent(SoView2D *view2d, View2DSliceList *slicelist, View2DEvent *ec, View2DEventPhase phase) override
Called by the SoView2D for each event that happens on the viewer.
SoSFEnum legendFontSize
set the font size (or set it to 'automatic')
void toggleLegend()
SoSFColor boxColor
the color of the box
SoSFFloat margin
the margin of the legend relative to the nearest border
void editingOnChanged(SoField *field) override
called when editingOn field is touched:
SoSFBool showLegend
show legend?
LegendFormat
text/line format.. draw a line or the text first?
LegendAlignPosition
enumeration for alignment
virtual bool implementsManagedInteraction() const
also implements managed interactions
bool implementsManagedInteractionAndClassicEventHandling() const override
this node is a hybrid module providing managed interaction and classic event handling
static void initClass()
SoSFBool textShadow
text shadow?
void draw(View2DSliceList *dsl, View2DSlice *dslice, int slice) override
inherited draw method.. parses the string and draws the legend
SoView2D is a 2D viewer for image data.
Definition SoView2D.h:62
View2DEvent stores all information on an event on a SoView2D.
Abstract GL font drawing using FTGL.
Definition View2DFont.h:30
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
Definition View2DSlice.h:48
Target mlrange_cast(Source arg)
Generic version of checked ML casts.