Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
PoLegend.h
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2014 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : VSG (MMM YYYY)
22**=======================================================================*/
23
24
25#ifndef _PO_LEGEND_
26#define _PO_LEGEND_
27
28#include <MeshViz/graph/PoGraphMaster.h>
29
30#include <Inventor/fields/SoSFEnum.h>
31#include <Inventor/fields/SoSFFloat.h>
32#include <Inventor/fields/SoSFBool.h>
33#include <Inventor/fields/SoSFUShort.h>
34#include <Inventor/fields/SoSFString.h>
35
36class PbMiscTextAttr ;
37class PiText ;
38
55class PoLegend : public PoGraphMaster {
56
57 SO_KIT_HEADER(PoLegend) ;
58
59 /* Define fields for new parts */
60 SO_KIT_CATALOG_ENTRY_HEADER(backgroundSep) ;
61 SO_KIT_CATALOG_ENTRY_HEADER(backgroundApp) ;
62 SO_KIT_CATALOG_ENTRY_HEADER(background) ;
63
64 SO_KIT_CATALOG_ENTRY_HEADER(backgroundBorderSep) ;
65 SO_KIT_CATALOG_ENTRY_HEADER(backgroundBorderApp) ;
66 SO_KIT_CATALOG_ENTRY_HEADER(backgroundBorder) ;
67
68 SO_KIT_CATALOG_ENTRY_HEADER(boxSep) ;
69 SO_KIT_CATALOG_ENTRY_HEADER(boxApp) ;
70 SO_KIT_CATALOG_ENTRY_HEADER(box) ;
71
72 SO_KIT_CATALOG_ENTRY_HEADER(boxBorderSep) ;
73 SO_KIT_CATALOG_ENTRY_HEADER(boxBorderApp) ;
74 SO_KIT_CATALOG_ENTRY_HEADER(boxBorder) ;
75
76 SO_KIT_CATALOG_ENTRY_HEADER(titleSep) ;
77 SO_KIT_CATALOG_ENTRY_HEADER(titleApp) ;
78 SO_KIT_CATALOG_ENTRY_HEADER(title) ;
79
80 SO_KIT_CATALOG_ENTRY_HEADER(valueTextSep) ;
81 SO_KIT_CATALOG_ENTRY_HEADER(valueTextApp) ;
82 SO_KIT_CATALOG_ENTRY_HEADER(valueText) ;
83
84
85 public:
86
100
122
144
158
172
173
174
175 /* Fields */
176
177 /* title attributes */
178
183
188
194
199
206
211
212 /* values attributes */
213
218
223
230
235
240
241 /* margin attributes */
242
247
252
257
262
267
268
269
275
280
281
282
287
288
289
290 /* Methods */
291
299
304
305 /*----------------------------------------------------------------------------*/
306 private:
307 static void initClass() ;
308 static void exitClass() ;
309
310 private:
311 struct LegendAttr {
312 float titleFontSize ;
313 SbString titleFontName ;
314
315 float valueFontSize ;
316 SbString valueFontName ;
317 } ;
318
319 // Methods
320 virtual void setDefaultOnNonWritingFields() ;
321 virtual SbBool setUpConnections(SbBool onOff, SbBool doItAlways = FALSE) ;
322
323 // Manage the connection with PbBase objects
324 virtual void basicObjectChange(PbBase *basicObj) ;
325
326 //******************* Methods for automatic legends *************************
327
328 // Compute margin for auto legend
329 void computeMarginA(const SbVec2f &ptBoxOrig, float boxWidth,
330 float boxHeight, SbVec2f &ptLegendOrig,
331 float &legendWidth, float &legendHeight) ;
332
333 // Compute title font size for auto legend
334 void computeTitleSizeA(float legendWidth, float legendHeight,
335 float &titleWidth, float &titleHeight) ;
336
337 // Draw background for auto legend
338 void drawBackgroundA(const SbVec2f &ptBoxOrig, float boxWidth, float boxHeight) ;
339
340 // Draw title for auto legend
341 void drawTitleA(float titleHeight, float titleWidth, Plimit &limit) ;
342
343 // Draw boxes for auto legend constitued of several boxes
344 void drawBoxesLegendBoxesA(SbBool isBoxVisible, float boxWidth, float boxHeight,
345 int nb_lines, int nb_columns,
346 int numItems, const float *maxTextSizePerCol,
347 const SbVec2f &space_box, const Plimit &limit) ;
348
349 // Draw a box with an interior color
350 virtual void drawBoxLegendBoxesA(SoGroup *boxBorderGroup, SoGroup *boxGroup,
351 const SbVec2f &topLeftCorner, float width,
352 float height, int repIndex) ;
353
354 // Draw values for auto legend constitued of several boxes
355 void drawValuesLegendBoxesA(int nb_lines, int nb_columns, int numStrings,
356 const SbString *strings, const float *maxTextSizePerCol,
357 const SbVec2f &space_box, const Plimit &limit,
358 PiText &valText) ;
359
360 // Compute graphic size use to draw values in auto legend constitued
361 // of several boxes
362 virtual void computeGraphicSizeForValues(float &width, float &height,
363 float &text_space) ;
364
365 // Determines if the legend must be reverted or not.
366 virtual void setRevertOrder(float startY, float endY)
367 { m_revertOrder = (startY <= endY ? FALSE : TRUE) ; }
368 SbBool isRevertOrder() const
369 { return m_revertOrder ; }
370
371 // Indicate if the values and boxes are
372 // drawn from down to up (FALSE)
373 // or from up to down (TRUE)
374 SbBool m_revertOrder ;
375 //****************** Methods for non automatic legend ************************
376
377 // Set default attributes
378 void setDefaultAttr() ;
379
380 // Constructor
381 PoLegend() ;
382
383 // Destructor
384 virtual ~PoLegend() ;
385
386 // Overloaded methods
387 virtual void addElementsAllCaches() ;
388 virtual void preRebuild() ;
389
390 // Attributes computed
391 LegendAttr m_legendAttr ;
392
393 private:
394 // Miscellaneous text attribute
395 PbMiscTextAttr *m_miscTextAttr, *m_defaultMiscTextAttr ;
396
397 // Sensors
398 FieldSensorList m_fieldSensorList ;
399
400 // List of fields defined in this class
401 SoFieldList m_fieldList ;
402
403} ;
404
405/*----------------------------------------------------------------------------*/
406
407#endif /* _PO_LEGEND_ */
408
409
410
<a href="IconLegend.html"><img src="extMV.gif" alt="MeshViz" border="0"></a> Abstract class for all b...
Definition PbBase.h:49
<a href="IconLegend.html"><img src="extMV.gif" alt="MeshViz" border="0"></a> Class to define a numeri...
<a href="IconLegend.html"><img src="extMV.gif" alt="MeshViz" border="0"></a> Abstract base class for ...
<a href="IconLegend.html"><img src="extMV.gif" alt="MeshViz" border="0"></a> Abstract class for legen...
Definition PoLegend.h:55
SoSFFloat marginLeft
Left margin.
Definition PoLegend.h:251
SoSFEnum titlePath
Title path.
Definition PoLegend.h:193
SoSFFloat titleFontSize
Font size of the title.
Definition PoLegend.h:198
const PbMiscTextAttr * getMiscTextAttr() const
Gets a reference to a PbMiscTextAttr for miscellaneous text attributes.
SoSFEnum valuePosition
Values positions.
Definition PoLegend.h:222
IncrementType
Type of values incrementation.
Definition PoLegend.h:162
@ VERTICAL_INCREMENT
Values of the legend are vertically incremented.
Definition PoLegend.h:166
@ HORIZONTAL_INCREMENT
Values of the legend are horizontally incremented.
Definition PoLegend.h:170
SoSFFloat marginTop
Top margin.
Definition PoLegend.h:266
SoSFEnum marginType
Margin type.
Definition PoLegend.h:246
Position
Type of position.
Definition PoLegend.h:126
@ POS_TOP
Top position.
Definition PoLegend.h:134
@ POS_BOTTOM
Bottom position.
Definition PoLegend.h:130
@ POS_LEFT
Left position.
Definition PoLegend.h:142
@ POS_RIGHT
Right position.
Definition PoLegend.h:138
SoSFFloat marginBottom
Bottom margin.
Definition PoLegend.h:261
SoSFEnum valueVisibility
Values visibility.
Definition PoLegend.h:217
SoSFString valueFontName
Font name of values.
Definition PoLegend.h:229
SoSFString titleFontName
Font name of the title.
Definition PoLegend.h:205
Visibility
Type of visibility.
Definition PoLegend.h:90
@ VISIBILITY_OFF
Invisible.
Definition PoLegend.h:94
@ VISIBILITY_ON
Visible.
Definition PoLegend.h:98
SoSFUShort numColumns
Number of columns of the legend.
Definition PoLegend.h:279
SoSFFloat boxRatio
Ratio between width and height of the colored boxes in the legend.
Definition PoLegend.h:286
SoSFString valueAddString
String to be concatenated.
Definition PoLegend.h:239
SoSFString titleString
Title string.
Definition PoLegend.h:210
SoSFBool valueAddStringVisibility
Visibility of a string concatenated to the values.
Definition PoLegend.h:234
TextPath
Text path.
Definition PoLegend.h:104
@ PATH_RIGHT
Writing from left to right.
Definition PoLegend.h:108
@ PATH_LEFT
Writing from right to left.
Definition PoLegend.h:112
@ PATH_UP
Writing from bottom to top.
Definition PoLegend.h:116
@ PATH_DOWN
Writing from top to bottom.
Definition PoLegend.h:120
SoSFEnum titlePosition
Title position.
Definition PoLegend.h:187
void setMiscTextAttr(PbMiscTextAttr *textAttr)
Sets a reference to a PbMiscTextAttr for miscellaneous text attributes of all legend texts.
SoSFEnum titleVisibility
Title visibility.
Definition PoLegend.h:182
MarginType
Type of margins.
Definition PoLegend.h:148
@ FIXED_MARGIN
Absolute margin.
Definition PoLegend.h:156
@ REL_MARGIN
Relative margin.
Definition PoLegend.h:152
SoSFEnum incrementType
Increment type for the values of legend.
Definition PoLegend.h:274
SoSFFloat marginRight
Right margin.
Definition PoLegend.h:256
Class for smart character strings.
Definition SbString.h:202
2D vector class.
Definition SbVec.h:76
Maintains a list of pointers to fields.
Definition SoFieldList.h:72
Base class for all group nodes.
Definition SoGroup.h:122
Field containing a single Boolean value.
Definition SoSFBool.h:79
Field containing an enumerated value.
Definition SoSFEnum.h:89
Field containing a floating-point value.
Definition SoSFFloat.h:78
Field containing a string.
Definition SoSFString.h:117
Field containing an unsigned short integer.
Definition SoSFUShort.h:79
int SbBool
Boolean type.
Definition SbBase.h:87