Open Inventor Release 2024.1.1
 
Loading...
Searching...
No Matches
SoWinColorWheel.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_WHEEL_
26#define _SO_WIN_COLOR_WHEEL_
27
28#include <Inventor/Win/SoWinBeginStrict.h>
29#include <Inventor/SbColor.h>
30#include <Inventor/SbLinear.h>
31#include <Inventor/misc/SoCallbackList.h>
32#include <Inventor/Win/SoWinGLWidget.h>
33
34class SoWinMouse;
35
36// callback function prototypes
37typedef void SoWinColorWheelCB(void *userData, const float hsv[3]);
38
40//
41// Class: SoWinColorWheel
42//
43// Lets you interactively select colors using a color wheel. User register
44// callback(s) to be notified when a new color has been selected. There is
45// also a call to tell the color wheel what the current color is when it is
46// changed externally.
47//
49
50{
51
52 public:
53
54 SoWinColorWheel(
55 SoWidget parent = NULL,
56 const char *name = NULL,
57 SbBool buildInsideParent = TRUE);
58 ~SoWinColorWheel();
59
60 //
61 // Routine to tell the color wheel what the current HSV color is.
62 //
63 // NOTE: if calling setBaseColor() changes the marker position the
64 // valueChanged callbacks will be called with the new hsv color.
65 //
66 void setBaseColor(const float hsv[3]);
67 const float *getBaseColor() { return hsvColor; }
68
69 //
70 // This routine sets the WYSIWYG (What You See Is What You Get) mode.
71 // When WYSIWYG is on the colors on the wheel will reflect the current
72 // color intensity (i.e. get darker and brighter)
73 //
74 void setWYSIWYG(SbBool trueOrFalse); // default FALSE
75 SbBool isWYSIWYG() { return WYSIWYGmode; }
76
77 //
78 // Those routines are used to register callbacks for the different
79 // color wheel actions.
80 //
81 // NOTE: the start and finish callbacks are only to signal when the mouse
82 // goes down and up. No valid callback data is passed (NULL passed).
83 //
84 void addStartCallback(
85 SoWinColorWheelCB *f,
86 void *userData = NULL)
87 { startCallbacks->addCallback((SoCallbackListCB *) f, userData); }
88
89 void addValueChangedCallback(
90 SoWinColorWheelCB *f,
91 void *userData = NULL)
92 { changedCallbacks->addCallback((SoCallbackListCB *) f, userData); }
93
94 void addFinishCallback(
95 SoWinColorWheelCB *f,
96 void *userData = NULL)
97 { finishCallbacks->addCallback((SoCallbackListCB *) f, userData); }
98
99 void removeStartCallback(
100 SoWinColorWheelCB *f,
101 void *userData = NULL)
102 { startCallbacks->removeCallback((SoCallbackListCB *) f, userData); }
103
104 void removeValueChangedCallback(
105 SoWinColorWheelCB *f,
106 void *userData = NULL)
107 { changedCallbacks->removeCallback((SoCallbackListCB *) f, userData); }
108
109 void removeFinishCallback(
110 SoWinColorWheelCB *f,
111 void *userData = NULL)
112 { finishCallbacks->removeCallback((SoCallbackListCB *) f, userData); }
113
114
115 // true while the color is changing interactively
116 SbBool isInteractive() { return interactive; }
117
118 private:
119
120 // This constructor takes a boolean whether to build the widget now.
121 // Subclasses can pass FALSE, then call SoWinColorWheel::buildWidget()
122 // when they are ready for it to be built.
123 SoEXTENDER
124 SoWinColorWheel(
125 SoWidget parent,
126 const char *name,
127 SbBool buildInsideParent,
128 SbBool buildNow);
129
130 SoWidget buildWidget(SoWidget parent);
131
132 private:
133
134 // redefine these to do color wheel specific things
135 virtual void redraw();
136 virtual void redrawOverlay();
137 virtual void processEvent(XAnyEvent *anyevent);
138 virtual void sizeChanged(const SbVec2s &newSize);
139
140 // color wheels local variables
141 SbBool WYSIWYGmode;
142 SbBool blackMarker;
143 float hsvColor[3];
144 short cx, cy, radius;
145 SbColor *defaultColors, *colors;
146 SbVec2f *geometry;
147 SoWinMouse *mouse;
148
149 // callback variables
150 SoCallbackList *startCallbacks;
151 SoCallbackList *changedCallbacks;
152 SoCallbackList *finishCallbacks;
153 SbBool interactive;
154
155 // routines to make the wheel geometry, colors, draw it....
156 void makeWheelGeometry();
157 void makeWheelColors(SbColor *col, float intensity);
158 void drawWheelSurrounding();
159 void drawWheelColors();
160 void checkMarkerColor();
161 void drawWheelMarker();
162 void moveWheelMarker(short x, short y);
163
164 // this is called by both constructors
165 void constructorCommon(SbBool buildNow);
166#ifdef _WIN32
167 void SaveUnder(short x,short y);
168 void RestoreUnder();
169
170 SbBool nSaved;
171 int nMarkR,nMarkG,nMarkB;
172 short nSaveX,nSaveY;
173#ifndef GDISAVE
174 unsigned long *pSaveBuf;
175#else
176 HBITMAP hSaveBits;
177 HDC hSaveDC;
178#endif
179#endif
180};
181
182#include <Inventor/Win/SoWinEndStrict.h>
183
184#endif /* _SO_WIN_COLOR_WHEEL_ */
185
186
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.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Translates and r...
Definition SoWinMouse.h:56
int SbBool
Boolean type.
Definition SbBase.h:87