Open Inventor Release 2024.1.2
 
Loading...
Searching...
No Matches
SoXtColorWheel.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-2020 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : VSG (MMM YYYY)
22**=======================================================================*/
23
24#ifdef SOQT
25# include <Inventor/Qt/SoQtColorWheel.h>
26#elif defined(_WIN32)
27# include <Inventor/Win/SoWinColorWheel.h>
28#else // _WIN32
29
30#ifndef _SO_XT_COLOR_WHEEL_
31#define _SO_XT_COLOR_WHEEL_
32
33#include <Inventor/SbColor.h>
34#include <Inventor/SbLinear.h>
35#include <Inventor/misc/SoCallbackList.h>
36#include <Inventor/Xt/SoXtGLWidget.h>
37
38class SoXtMouse;
39
40// callback function prototypes
41typedef void SoXtColorWheelCB(void *userData, const float hsv[3]);
42
44//
45// Class: SoXtColorWheel
46//
47// Lets you interactively select colors using a color wheel. User register
48// callback(s) to be notified when a new color has been selected. There is
49// also a call to tell the color wheel what the current color is when it is
50// changed externally.
51//
53
54{
55
56public:
57
58 SoXtColorWheel(
59 SoWidget parent = NULL,
60 const char *name = NULL,
61 SbBool buildInsideParent = TRUE);
62 ~SoXtColorWheel();
63
64 //
65 // Routine to tell the color wheel what the current HSV color is.
66 //
67 // NOTE: if calling setBaseColor() changes the marker position the
68 // valueChanged callbacks will be called with the new hsv color.
69 //
70 void setBaseColor(const float hsv[3]);
71 const float *getBaseColor() { return hsvColor; }
72
73 //
74 // This routine sets the WYSIWYG (What You See Is What You Get) mode.
75 // When WYSIWYG is on the colors on the wheel will reflect the current
76 // color intensity (i.e. get darker and brighter)
77 //
78 void setWYSIWYG(SbBool trueOrFalse); // default FALSE
79 SbBool isWYSIWYG() { return WYSIWYGmode; }
80
81 //
82 // Those routines are used to register callbacks for the different
83 // color wheel actions.
84 //
85 // NOTE: the start and finish callbacks are only to signal when the mouse
86 // goes down and up. No valid callback data is passed (NULL passed).
87 //
88 void addStartCallback(
89 SoXtColorWheelCB *f,
90 void *userData = NULL)
91 { startCallbacks->addCallback((SoCallbackListCB *) f, userData); }
92
93 void addValueChangedCallback(
94 SoXtColorWheelCB *f,
95 void *userData = NULL)
96 { changedCallbacks->addCallback((SoCallbackListCB *) f, userData); }
97
98 void addFinishCallback(
99 SoXtColorWheelCB *f,
100 void *userData = NULL)
101 { finishCallbacks->addCallback((SoCallbackListCB *) f, userData); }
102
103 void removeStartCallback(
104 SoXtColorWheelCB *f,
105 void *userData = NULL)
106 { startCallbacks->removeCallback((SoCallbackListCB *) f, userData); }
107
108 void removeValueChangedCallback(
109 SoXtColorWheelCB *f,
110 void *userData = NULL)
111 { changedCallbacks->removeCallback((SoCallbackListCB *) f, userData); }
112
113 void removeFinishCallback(
114 SoXtColorWheelCB *f,
115 void *userData = NULL)
116 { finishCallbacks->removeCallback((SoCallbackListCB *) f, userData); }
117
118
119 // true while the color is changing interactively
120 SbBool isInteractive() { return interactive; }
121
122private:
123
124 // This constructor takes a boolean whether to build the widget now.
125 // Subclasses can pass FALSE, then call SoXtColorWheel::buildWidget()
126 // when they are ready for it to be built.
127 SoEXTENDER
128 SoXtColorWheel( SoWidget parent,
129 const char *name,
130 SbBool buildInsideParent,
131 SbBool buildNow);
132
133 SoWidget buildWidget(SoWidget parent);
134
135private:
136
137 // redefine these to do color wheel specific things
138 virtual void redraw();
139 virtual void processEvent(XAnyEvent *anyevent);
140 virtual void sizeChanged(const SbVec2s &newSize);
141
142 // color wheels local variables
143 SbBool WYSIWYGmode;
144 SbBool blackMarker;
145 float hsvColor[3];
146 short cx, cy, radius;
147 SbColor *defaultColors, *colors;
148 SbVec2f *geometry;
149 SoXtMouse *mouse;
150
151 // callback variables
152 SoCallbackList *startCallbacks;
153 SoCallbackList *changedCallbacks;
154 SoCallbackList *finishCallbacks;
155 SbBool interactive;
156
157 // routines to make the wheel geometry, colors, draw it....
158 void makeWheelGeometry();
159 void makeWheelColors(SbColor *col, float intensity);
160 void drawWheelSurrounding();
161 void drawWheelColors();
162 void moveWheelMarker(short x, short y);
163
164 // this is called by both constructors
165 void constructorCommon(SbBool buildNow);
166};
167
168#endif /* _SO_XT_COLOR_WHEEL_ */
169
170#endif // _WIN32
Color vector class.
Definition SbColor.h:82
2D vector class.
Definition SbVec.h:76
2D vector class.
Definition SbVec.h:700
Manages a list of callbacks and associated data.
Translates and reports events for the mouse device.
Definition SoXtMouse.h:87
int SbBool
Boolean type.
Definition SbBase.h:87