Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
PoAxis.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#ifndef _PO_AXIS_
25#define _PO_AXIS_
26
27#include <Inventor/fields/SoSFEnum.h>
28#include <Inventor/fields/SoSFFloat.h>
29#include <Inventor/fields/SoSFString.h>
30#include <Inventor/fields/SoSFUShort.h>
31#include <Inventor/fields/SoSFBool.h>
32
33#include <MeshViz/graph/PoBaseAxis.h>
34#include <MeshViz/graph/PbMiscTextAttr.h>
35
36#include <Inventor/STL/vector>
37
38class PiText ;
39
40
58class PoAxis : public PoBaseAxis {
59
60 SO_KIT_HEADER(PoAxis) ;
61
62 // Define fields for new parts
63 SO_KIT_CATALOG_ENTRY_HEADER(transform) ;
64
65 SO_KIT_CATALOG_ENTRY_HEADER(bodySep) ;
66 SO_KIT_CATALOG_ENTRY_HEADER(bodyApp) ;
67 SO_KIT_CATALOG_ENTRY_HEADER(body) ;
68
69 SO_KIT_CATALOG_ENTRY_HEADER(arrowSep) ;
70 SO_KIT_CATALOG_ENTRY_HEADER(arrowApp) ;
71 SO_KIT_CATALOG_ENTRY_HEADER(arrow) ;
72
73 SO_KIT_CATALOG_ENTRY_HEADER(titleSep) ;
74 SO_KIT_CATALOG_ENTRY_HEADER(titleApp) ;
75 SO_KIT_CATALOG_ENTRY_HEADER(title) ;
76
77 SO_KIT_CATALOG_ENTRY_HEADER(subGradTickSep) ;
78 SO_KIT_CATALOG_ENTRY_HEADER(subGradTickApp) ;
79 SO_KIT_CATALOG_ENTRY_HEADER(subGradTick) ;
80
81 SO_KIT_CATALOG_ENTRY_HEADER(subGradGridSep) ;
82 SO_KIT_CATALOG_ENTRY_HEADER(subGradGridApp) ;
83 SO_KIT_CATALOG_ENTRY_HEADER(subGradGrid) ;
84
85 SO_KIT_CATALOG_ENTRY_HEADER(mainGradTickSep) ;
86 SO_KIT_CATALOG_ENTRY_HEADER(mainGradTickApp) ;
87 SO_KIT_CATALOG_ENTRY_HEADER(mainGradTick) ;
88
89 SO_KIT_CATALOG_ENTRY_HEADER(mainGradGridSep) ;
90 SO_KIT_CATALOG_ENTRY_HEADER(mainGradGridApp) ;
91 SO_KIT_CATALOG_ENTRY_HEADER(mainGradGrid) ;
92
93 SO_KIT_CATALOG_ENTRY_HEADER(mainGradTextSep) ;
94 SO_KIT_CATALOG_ENTRY_HEADER(mainGradTextApp) ;
95 SO_KIT_CATALOG_ENTRY_HEADER(mainGradText) ;
96
97
98 public:
99
121
122
123
149
150
151
169
170
171
185
186
187
205
206
207
225
226
227
241
242
243
261
262
263
264 /* Fields */
265
266
267
268 /* Graduations attributes */
269
275
281
287
295
306
315
321
327
328
329
330 /* Margins attributes */
331
337
343
349
350
351
352 /* Title attributes */
353
359
365
371
378
387
394
400
401
402
403 /* Grid lines attributes */
404
410
416
422
423
424
425 /* Arrow attributes */
426
432
439
446
447
448
449 /* Tick mark attributes */
450
456
462
470
478
486
493
499
505
511
512
513
514
515
516 /* Methods */
517
525
530
531 /* Get axis attributes methods */
532
538 void getGrad(Visibility &visibility, GradPosition &position, TextPath &path,
539 SbString &fontName, float &fontSize, float &distAxis, SbBool
540 &addStringVisibility, SbString &addString) const ;
541
547 void getMargin(MarginType &type, float &start, float &end) const ;
548
554 void getTitle(Visibility &visibility, TitlePosition &position, TextPath
555 &path,SbString &fontName, float &fontSize, float &distAxis,
556 SbString &string) const ;
557
563 void getGrid(Visibility &visibility, float &lengthGradSide, float
564 &lengthGradOtherSide) const ;
565
571 void getArrow(Visibility &visibility, float &height, float &length) const ;
572
578 void getTick(Visibility &visibility, TickPosition &position, float &mainLength,
579 float &subLength, TickSubDef &def, unsigned short &numOrPeriod,
580 unsigned short &firstGrad, unsigned short &lastGrad) const ;
581
587
588 /*----------------------------------------------------------------------------*/
589 private:
590 static void initClass() ;
591 static void exitClass() ;
592
593 struct GradAttr {
594 Visibility visibility ;
595 GradPosition position ;
596 TextPath path ;
597 float fontSize ;
598 SbString fontName ;
599 float distAxis ;
600 } ;
601 // Grad attributes
602
603 // Margin attributes
604 struct MarginAttr {
605 MarginType type ;
606 float start ;
607 float end ;
608 } ;
609
610 // Title attributes
611 struct TitleAttr {
612 Visibility visibility ;
613 TitlePosition position ;
614 TextPath path ;
615 float fontSize ;
616 SbString fontName ;
617 float distAxis ;
618 } ;
619
620 // Grid line attributes
621 struct GridAttr {
622 Visibility visibility ;
623 float lenGradSide ;
624 float lenGradOtherSide ;
625 } ;
626
627 // Arrow attibutes
628 struct ArrowAttr {
629 Visibility visibility ;
630 float height ;
631 float length ;
632 } ;
633
634 // Tick mark attributes
635 struct TickAttr {
636 Visibility visibility ;
637 TickPosition position ;
638 float mainLength ;
639 float subLength ;
640 TickSubDef subDef ;
641 int numOrPeriod ;
642 int firstGrad ;
643 int lastGrad ;
644 } ;
645
646 // Miscellaneous attributes
647 struct MiscAttr {
648 float deltaX ;
649 float deltaY ;
650 Plimit limit ;
651 char endLineChar ;
652 int lineLength ;
653 std::vector<float> mainGradCoords;
654 std::vector<float> subGradCoords;
655 } ;
656
657 enum Plane {
658 XY,
659 XZ,
660 YX,
661 YZ,
662 ZX,
663 ZY
664 } ;
665
666 // Return main graduation coordinates and its number
667 // For the moment available only for linear, log and gen axis
668 int getMainGradCoords(const float* &coords) const ;
669
670 // Return sub graduation coordinates and its number
671 // For the moment available only for linear, log and gen axis
672 int getSubGradCoords(const float* &coords) const ;
673
674 private:
675 // Constructor
676 PoAxis() ;
677 // Destructor
678 virtual ~PoAxis() ;
679
680 // Axis attributes
681 struct AxisAttr {
682 GradAttr grad ;
683 MarginAttr margin ;
684 TitleAttr title ;
685 GridAttr grid ;
686 ArrowAttr arrow ;
687 TickAttr tick ;
688 AxisReverse reverseFlag ;
689 MiscAttr misc ;
690 } ;
691
692 // Methods
693 virtual SbBool setUpConnections(SbBool onOff, SbBool doItAlways = FALSE) ;
694 virtual void setDefaultOnNonWritingFields() ;
695
696 // Manage the connection with PbBase objects
697 virtual void basicObjectChange(PbBase *basicObj) ;
698
699 // Save all axis attributes which can be modified by MeshViz.
700 virtual void saveAxisAttr() ;
701
702 // Set Default attributes
703 virtual void setDefaultAttr(Plane plane = XY) ;
704
705 // Compute limit coordinate for display graduation
706 virtual void computeGradLimit(float xOrig, float xExtr, float &xmOrig, float &xmExtr) ;
707
708 // Compute tick length
709 virtual void computeTickLen(size_t numGrad, float &mainTickLen, float &secdTickLen) ;
710
711 // Build arrow - The arrow is built under the node "group"
712 virtual void buildArrow(float orig, float extr, SoGroup *group) ;
713
714 // Build tick - The ticks are built under the node "group"
715 virtual void buildTick(const std::vector<float>& xGrad, float tickLen,
716 SoGroup *group) ;
717
718 // Build grid lines - The grid lines are built under the node "group"
719 virtual void buildGridLines(const std::vector<float>& xGrad, SoGroup *group) ;
720
721 // Build title - The title is built under the node "group"
722 void buildTitle(float xOrig, float xExtr, SoGroup *group) ;
723
724 // Build graduations - The graduations are built under the node "group"
725 // (used only by generalised, linear and polar linear axis)
726 virtual void buildGrads(const std::vector<float>& xGrad, const char **gradStr,
727 SoGroup *group) ;
728
729 // Build multiplicative facot - The multiplicative factor is built under the node "group"
730 // (used by log, linear, polar linear and polar log axis)
731 void buildMultFactorAtExtr(int tenPower, float xOrig, float xExtr, float &distAxis,
732 SoGroup *group) ;
733
734 // Compute axis grad list
735 // (used by linear, angular, generalised, polar linear axis)
736 void computeGradList(float xOrig, float xExtr, float step, size_t numAllGrad,
737 const char** allGradStr, const std::vector<float>& allGradX,
738 char **mainGradStr,
739 std::vector<float> &mainGradX, std::vector<float> &secondaryGradX) ;
740
741 // Allocate strings for graduations.
742 static char **allocGradString(size_t numStr) ;
743
744 // Overloaded methods
745 virtual void addElementsAllCaches() ;
746 virtual void preRebuild() ;
747
748 //----------- These methods, types and vars are used ---------------------
749 //--------------- only by log and polar log axis -------------------------
750
751 enum LogGradType {
752 TDECIMAL_TYPE,
753 TDIGIT_TYPE,
754 TPOWER_TYPE
755 } ;
756
757 struct SecondaryLogGrad
758 {
759 float coord;
760 int powerOfTen;
761 int decade;
762 };
763
764 // Convert log grad to string
765 static void convertLogGradToStr(SbBool isMainGrad, LogGradType grad_type, int grad,
766 int ten_pow, char *string1, char *string2) ;
767
768 // Compute min distance betwwen log graduations.
769 static void computeLogGradMinDist(const std::vector<float>& mainGradX,
770 const std::vector<float>& secdGradX,
771 float &min_grad_dist);
772
773 // Compute decade list
774 static void computeDecadeGradList(size_t numMainGrad, int **decades,
775 size_t &numDecades) ;
776
777 // Compute width for a log grad text
778 void computeLogGradWidth(const char *str, const char *tenPowStr,
779 float fontSize, float &width) ;
780
781 // Compute max width for a list of log grad text
782 void computeLogGradsMaxWidth(const char **strs, const char **tenPowStrs,
783 size_t numStr, float fontSize, float &width,
784 int &indexMaxWidth) ;
785
786 // Draw a list of log graduations
787 void drawLogGrad(float pyAtMax, float pyAtMin, float fontSize,
788 LogGradType gradType, const std::vector<float>& gradX,
789 const char **gradStr, const char **tenPowStr,
790 SoGroup *group) ;
791
792 static char *PStringToConcat ;
793 static PiText *PLogGradText ;
794
795 //--------------------------- End log axis ------------------------------------
796
797 // Computed axis attributes
798 AxisAttr axisAttr ;
799
800 private:
801 // Methods
802 void buildTitleP(SbBool isTitleBuild, float xOrig, float xExtr,
803 SoGroup *group, Plimit &limit) ;
804
805 // Miscellaneous text attribute
806 PbMiscTextAttr *m_miscTextAttr, m_defaultMiscTextAttr ;
807
808 // Sensors
809 FieldSensorList fieldSensorList ;
810
811 // List of fields defined in this class
812 SoFieldList fieldList ;
813
814} ;
815
816/*----------------------------------------------------------------------------*/
817
818#endif /* _PO_AXIS_ */
819
<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 class for axis ...
Definition PoAxis.h:58
AxisReverse
Axis reverse type.
Definition PoAxis.h:247
@ AXIS_NO_REVERSE
Texts of the axis are no reversed.
Definition PoAxis.h:251
@ AXIS_REVERSE
Texts of the axis are reversed (mirror effect).
Definition PoAxis.h:255
@ AXIS_REVERSE_DEPEND
Depends on the axis type.
Definition PoAxis.h:259
void getMargin(MarginType &type, float &start, float &end) const
Gets the margin axis attributes computed by the last axis rebuilding.
void getTick(Visibility &visibility, TickPosition &position, float &mainLength, float &subLength, TickSubDef &def, unsigned short &numOrPeriod, unsigned short &firstGrad, unsigned short &lastGrad) const
Gets the tick axis attributes computed by the last axis rebuilding.
SoSFFloat gridLengthGradSide
Grid lines length side graduation texts.
Definition PoAxis.h:415
SoSFFloat titleFontSize
Font size of the title.
Definition PoAxis.h:386
SoSFEnum gradPosition
Graduations position.
Definition PoAxis.h:280
SoSFEnum titlePosition
Position of the title.
Definition PoAxis.h:364
SoSFEnum tickSubDef
Secondary graduations tick definition.
Definition PoAxis.h:485
SoSFFloat marginStart
Margin at the start of the axis.
Definition PoAxis.h:342
Visibility
Enumerations.
Definition PoAxis.h:107
@ VISIBILITY_OFF
Invisible.
Definition PoAxis.h:111
@ VISIBILITY_ON
Visible.
Definition PoAxis.h:115
@ VISIBILITY_DEPEND
Depends on the type of the axis.
Definition PoAxis.h:119
void getArrow(Visibility &visibility, float &height, float &length) const
Gets the arrow axis attributes computed by the last axis rebuilding.
void setMiscTextAttr(PbMiscTextAttr *textAttr)
Sets a reference to PbMiscTextAttr object for miscellaneous text attributes.
SoSFFloat gradDistAxis
Distance from the graduations to the axis.
Definition PoAxis.h:314
SoSFUShort tickFirstGrad
First graduation to display.
Definition PoAxis.h:498
SoSFEnum titleVisibility
Visibility of the title.
Definition PoAxis.h:358
SoSFString gradAddString
String to be concatenated.
Definition PoAxis.h:326
SoSFFloat arrowLength
Arrow length.
Definition PoAxis.h:445
SoSFString gradFontName
Graduations font name.
Definition PoAxis.h:294
SoSFFloat marginEnd
Margin at the end of the axis.
Definition PoAxis.h:348
SoSFUShort tickNumOrPeriod
Number of secondary graduations (tickSubDef = NUM_SUB_TICK), or period of texts of graduations (tickS...
Definition PoAxis.h:492
SoSFString titleFontName
Title font name.
Definition PoAxis.h:377
SoSFEnum tickVisibility
Tick marks visibility.
Definition PoAxis.h:455
SoSFEnum gradPath
Graduations path.
Definition PoAxis.h:286
SoSFFloat gridLengthGradOtherSide
Grid lines length other side graduation texts.
Definition PoAxis.h:421
SoSFUShort tickLastGrad
Last graduation to display (number starting with the ending one).
Definition PoAxis.h:504
void getTitle(Visibility &visibility, TitlePosition &position, TextPath &path, SbString &fontName, float &fontSize, float &distAxis, SbString &string) const
Gets the title axis attributes computed by the last axis rebuilding.
GradPosition
Graduation position type.
Definition PoAxis.h:155
@ GRAD_DEPEND
Depends on the type of the axis.
Definition PoAxis.h:167
@ GRAD_BELOW
Graduations are below the axis.
Definition PoAxis.h:163
@ GRAD_ABOVE
Graduations are above the axis.
Definition PoAxis.h:159
SoSFEnum gradVisibility
Graduations visibility.
Definition PoAxis.h:274
TitlePosition
Title position type.
Definition PoAxis.h:211
@ TITLE_MIDDLE
Title is at the middle of the axis.
Definition PoAxis.h:215
@ TITLE_DEPEND
Depends on the axis type.
Definition PoAxis.h:223
@ TITLE_END
Title is at the end of the axis.
Definition PoAxis.h:219
void getGrad(Visibility &visibility, GradPosition &position, TextPath &path, SbString &fontName, float &fontSize, float &distAxis, SbBool &addStringVisibility, SbString &addString) const
Gets the graduations axis attributes computed by the last axis rebuilding.
TextPath
Text path type.
Definition PoAxis.h:127
@ PATH_LEFT
Writing from right to left.
Definition PoAxis.h:135
@ PATH_DOWN
Writing from top to bottom.
Definition PoAxis.h:143
@ PATH_UP
Writing from bottom to top.
Definition PoAxis.h:139
@ PATH_RIGHT
Writing from left to right.
Definition PoAxis.h:131
@ PATH_DEPEND
Depends on the type of the axis.
Definition PoAxis.h:147
TickSubDef
Sub-tick type.
Definition PoAxis.h:231
@ NUM_SUB_TICK
Number of secondary graduations.
Definition PoAxis.h:235
@ PERIOD_MAIN_TICK
or period of texts of graduations
Definition PoAxis.h:239
SoSFEnum reverseFlag
Allow to reverse the writing path of all axis texts.
Definition PoAxis.h:510
SoSFFloat titleDistAxis
Distance from the title to the axis.
Definition PoAxis.h:393
SoSFString titleString
Title string.
Definition PoAxis.h:399
TickPosition
Tick position type.
Definition PoAxis.h:191
@ TICK_GRAD_OTHER_SIDE
Ticks are on the other side of graduations.
Definition PoAxis.h:199
@ TICK_ACROSS_AXIS
Ticks across the axis.
Definition PoAxis.h:203
@ TICK_GRAD_SIDE
Ticks are on the same side of graduations.
Definition PoAxis.h:195
SoSFEnum arrowVisibility
Arrow visibility.
Definition PoAxis.h:431
SoSFEnum titlePath
Path of the title.
Definition PoAxis.h:370
SoSFFloat arrowHeight
Arrow height.
Definition PoAxis.h:438
SoSFFloat gradFontSize
Font size of the graduations.
Definition PoAxis.h:305
SoSFEnum tickPosition
Position of the tick marks.
Definition PoAxis.h:461
SoSFEnum marginType
Relative or absolute margin.
Definition PoAxis.h:336
AxisReverse getReverseFlag() const
Gets the reverse flag axis attributes computed by the last axis rebuilding.
void getGrid(Visibility &visibility, float &lengthGradSide, float &lengthGradOtherSide) const
Gets the grid axis attributes computed by the last axis rebuilding.
const PbMiscTextAttr * getMiscTextAttr() const
Gets a reference to PbMiscTextAttr object for miscellaneous text attributes.
SoSFFloat tickSubLength
Secondary graduations ticks length.
Definition PoAxis.h:477
MarginType
Margin type.
Definition PoAxis.h:175
@ REL_MARGIN
Relative margin on the axis.
Definition PoAxis.h:179
@ FIXED_MARGIN
Absolute margin on the axis.
Definition PoAxis.h:183
SoSFEnum gridVisibility
Grid lines visibility.
Definition PoAxis.h:409
SoSFBool gradAddStringVisibility
Specify the visibility of a string concatenated with the graduations.
Definition PoAxis.h:320
SoSFFloat tickMainLength
Main graduations ticks length.
Definition PoAxis.h:469
<a href="IconLegend.html"><img src="extMV.gif" alt="MeshViz" border="0"></a> Base class for all axis ...
Definition PoBaseAxis.h:37
Class for smart character strings.
Definition SbString.h:202
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