Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SoWinColorSlider.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 _SO_WIN_COLOR_SLIDER_
26#define _SO_WIN_COLOR_SLIDER_
27
28#include <Inventor/Win/SoWinBeginStrict.h>
29
30#include <Inventor/Win/SoWinSlider.h>
31
32class SbColor;
33class SbVec2f;
34
35
37//
38// Class: SoWinColorSlider
39//
40// This class defines the color slider which is a set of predefined
41// sliders (R, G, B, H, S, V,..) with special behaviors.
42//
44
45
46{
47
48 public:
49
50 //
51 // list of color sliders types
52 //
53 enum Type {
54 RED_SLIDER,
55 GREEN_SLIDER,
56 BLUE_SLIDER,
57 HUE_SLIDER,
58 SATURATION_SLIDER,
59 VALUE_SLIDER,
60 INTENSITY_SLIDER // independent of the slider value
61 };
62
63 // Constructor/Destructor
64 SoWinColorSlider(SoWidget parent = NULL,
65 const char *name = NULL,
66 SbBool buildInsideParent = TRUE,
67 Type type = INTENSITY_SLIDER);
68
69 ~SoWinColorSlider();
70
71 //
72 // Routine used to specify the slider value and also the top region
73 // color (WYSIWYGmode in most cases). Users should call this routine
74 // instead of the base class setValue() routine if they want the color
75 // slider top region to correctly reflect the current color.
76 // (code is optimized for WYSIWYGmode off)
77 //
78 // NOTE: routine expects
79 // an rgb color for R, G or B slider type
80 // an hsv color for H, S, or V slider type
81 // an rgb color for Intensity slider type
82 //
83 // NOTE: if calling setBaseColor() changes the thumb position the
84 // valueChanged callbacks will be called with the new value.
85 //
86 void setBaseColor(const float rgbOrHsv[3], SbBool updateText = TRUE);
87 const float *getBaseColor() { return color; }
88
89 //
90 // This routine sets the WYSIWYG (What You See Is What You Get) mode
91 // to be true or false (default FALSE). Immediate mode.
92 // This has no effect on monochrome sliders.
93 //
94 void setWYSIWYG(SbBool trueOrFalse); // default FALSE
95 SbBool isWYSIWYG() { return WYSIWYGmode; }
96
97 // returns the type of the slider
98 SoWinColorSlider::Type getType() { return type; }
99
100 private:
101
102 // This constructor takes a boolean whether to build the widget now.
103 // Subclasses can pass FALSE, then call SoWinSlider::buildWidget()
104 // when they are ready for it to be built.
105 SoEXTENDER
106 SoWinColorSlider(SoWidget parent,
107 const char *name,
108 SbBool buildInsideParent,
109 Type type,
110 SbBool buildNow);
111
112 // redefine this routine to cache slider top geometry
113 virtual void sizeChanged(const SbVec2s &newSize);
114
115 // redefine this routine to do the actual slider top region drawing.
116 // This routine is automatically called by the SoWinSlider::redraw() routine.
117 virtual void drawSliderTopRegion();
118
119 private:
120
121 // local vars
122 Boolean WYSIWYGmode;
123 Type type;
124 float color[3];
125 SbColor *defaultColors, *colors;
126 SbVec2f *geometry;
127
128 // routine that make the default and WYSIWYG colors
129 void makeDefaultColors();
130 void makeWYSIWYGcolors();
131
132 static void sliderChangedCB(void *, float val);
133
134 // this is called by both constructors
135 void constructorCommon(SoWinColorSlider::Type type, SbBool buildNow);
136};
137
138#include <Inventor/Win/SoWinEndStrict.h>
139
140
141#endif /* _SO_WIN_COLOR_SLIDER_ */
142
143
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
char Boolean
Definition SoQtDef.h:124