Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SoQtBasicSlider.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 _SO_QT_BASIC_SLIDER_
25#define _SO_QT_BASIC_SLIDER_
26#include <Inventor/Qt/OivQtCompat.h>
27#include <Inventor/Qt/SoQtGLWidget.h>
28
29class SbColor;
30class SoFloatCallbackList;
31
32// callback function prototypes
33typedef void SoQtBasicSliderCB(void *userData, float val);
34
36// Class: SoQtBasicSlider
37
38{
39 Q_OBJECT
40
41 public:
42 // Type of slider
43 enum Type {
44 RED_SLIDER,
45 GREEN_SLIDER,
46 BLUE_SLIDER,
47 HUE_SLIDER,
48 SATURATION_SLIDER,
49 VALUE_SLIDER,
50 INTENSITY_SLIDER, // independent of the slider value
51 PLAIN_SLIDER
52 };
53
54 // Constructor / Destructor
55 SoQtBasicSlider (QWidget *parent, Type t);
56 ~SoQtBasicSlider ();
57
58 // value management
59 void setValue(float v);
60 float getValue() const
61 { return value; }
62
63 // Routine used to specify the slider value and also the top region
64 // color (WYSIWYGmode in most cases). Users should call this routine
65 // instead of the base class setValue() routine if they want the color
66 // slider top region to correctly reflect the current color.
67 // (code is optimized for WYSIWYGmode off)
68 //
69 // NOTE: routine expects
70 // an rgb color for R, G or B slider type
71 // an hsv color for H, S, or V slider type
72 // an rgb color for Intensity slider type
73 //
74 // NOTE: if calling setBaseColor() changes the thumb position the
75 // valueChanged callbacks will be called with the new value.
76 void setBaseColor(const float rgbOrHsv[3]);
77 const float *getBaseColor() { return color; }
78
79 // This routine sets the WYSIWYG (What You See Is What You Get) mode
80 // to be true or false (default FALSE). Immediate mode.
81 // This has no effect on monochrome sliders.
82 void setWYSIWYG(SbBool trueOrFalse); // default FALSE
83 SbBool isWYSIWYG() { return WYSIWYGmode; }
84
85 // Those routines are used to register callbacks for the different slider
86 // actions.
87 // NOTE: the start and finish callbacks are only to signal when the mouse
88 // goes down and up. No valid callback data is passed (0.0 passed).
89 void addStartCallback (SoQtBasicSliderCB *f, void *userData = NULL);
90 void addValueChangedCallback (SoQtBasicSliderCB *f, void *userData = NULL);
91 void addFinishCallback (SoQtBasicSliderCB *f, void *userData = NULL);
92 void removeStartCallback (SoQtBasicSliderCB *f, void *userData = NULL);
93 void removeValueChangedCallback (SoQtBasicSliderCB *f, void *userData = NULL);
94 void removeFinishCallback (SoQtBasicSliderCB *f, void *userData = NULL);
95
96 // true while the value is changing interactively
97 void interactivity( SbBool flag ) { interactive = flag; }
98 SbBool isInteractive() { return interactive; }
99
100 private:
101
102 // drawing
103 virtual void redraw();
104 virtual void drawSliderTopRegion();
105
106 // Slider geometry values
107 short slx1, sly1, slx2, sly2;
108 short thumx1, thumy1, thumx2, thumy2;
109
110 private:
111
112 // Slider core values
113 float value;
114 short position;
115 short posdiff;
116 SbBool interactive;
117 SbBool leftButtonPressed;
118
119 // Colors values
120 SbBool WYSIWYGmode;
121 SbColor *defaultColors;
122 SbColor *colors;
123 SbVec2f *geometry;
124 Type type;
125 float color[3];
126
127 // Colors management
128 void makeDefaultColors();
129 void makeWYSIWYGcolors();
130
131
132 // callback variables
133 SoFloatCallbackList *startCallbacks;
134 SoFloatCallbackList *changedCallbacks;
135 SoFloatCallbackList *finishCallbacks;
136
137 // Events
138 virtual void sizeChanged(const SbVec2s &newSize);
139 void processEvent(QEvent *anyevent);
140 static void sliderChangedCB(void *, float val);
141};
142
143#endif // _SO_QT_BASIC_SLIDER_
144
145
Color vector class.
Definition SbColor.h:82
2D vector class.
Definition SbVec.h:76
2D vector class.
Definition SbVec.h:700
int SbBool
Boolean type.
Definition SbBase.h:87