MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
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
34
36
38{
39public:
42 {
43 color = SbColor(1, 1, 1);
44 line_width = 1.0f;
45 stipple = 0xffff;
46 };
47
50 {
51 *this = li;
52 };
53
56 {
57 color = li.color;
58 line_width = li.line_width;
59 stipple = li.stipple;
60 text = li.text;
61
62 return *this;
63 };
64
70 unsigned short stipple;
73};
74
76
78{
79 SO_NODE_HEADER(SoView2DLegend);
80
81public:
89
93 LINE_TEXT
94 };
95
105
122
123 static void initClass();
124
125 // Constructor
127
128 // toggle legend display
130
131protected:
133 void draw(View2DSliceList* dsl, View2DSlice* dslice, int slice) override;
134
135 // evaluates keyboard and mouse events
136 bool evalEvent(SoView2D* view2d, View2DSliceList* slicelist, View2DEvent* ec, View2DEventPhase phase) override;
137
139 virtual bool implementsManagedInteraction() const
140 {
141 return true;
142 }
143
147 {
148 return true;
149 }
150
153
154private:
156 void parseString(const SbString& string);
157
159 void drawLegend(View2DSlice* slice, const float dx1, const float dy1, const float dx2, const float dy2,
160 const int width, const int height, View2DFont* font, const int fontSize, const int pos,
161 const bool drawBox = FALSE);
162
164 int getFontSize(const int fontGroup) const;
165
167 std::vector<LegendItem> _legendVector;
168
170 long _lastEventSecs;
172 long _lastEventUSecs;
173
174 SoCommandAction* _toggleLegendAction;
175};
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.