Open Inventor Release 2024.1.0
 
Loading...
Searching...
No Matches
SoXtColorEditor.h
Go to the documentation of this file.
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#ifdef SOQT
26#elif defined(_WIN32)
28#else // _WIN32
29
30#ifndef _SO_XT_COLOR_EDITOR_
31#define _SO_XT_COLOR_EDITOR_
32
33#include <Xm/Xm.h>
34#include <Inventor/SbColor.h>
37
38class SoBase;
39class SoNodeSensor;
40class SoMFColor;
41class SoPathList;
42class SoSFColor;
43class SoSensor;
44class SoXtClipboard;
45class SoXtColorPatch;
46class SoXtColorWheel;
47class SoXtColorSlider;
48
49class SoMFUInt32;
50
51struct _ColorEditorCBData;
52
53// callback function prototypes
54typedef void SoXtColorEditorCB(void *userData, const SbColor *color);
55
57//
58// Class: SoXtColorEditor
59//
60// SoXtColorEditor class which lets you interactively edit a color.
61//
63
86
87 public:
88
119
134
139 const char *name = NULL,
140 SbBool buildInsideParent = TRUE);
145
160 void attach(SoSFColor *color, SoBase *node);
165 void attach(SoMFColor *color, int index, SoBase *node);
170 void attach(SoMFUInt32 *color, int index, SoBase *node);
171
177 void detach();
181 SbBool isAttached() { return attached; }
182
188 inline void addColorChangedCallback(SoXtColorEditorCB *f, void *userData = NULL);
192 inline void removeColorChangedCallback(SoXtColorEditorCB *f, void *userData = NULL);
193
198 void setColor(const SbColor &color);
202 const SbColor & getColor() { return baseRGB; }
203
218 void setWYSIWYG(SbBool trueOrFalse);
222 SbBool isWYSIWYG() { return WYSIWYGmode; }
223
227 void setCurrentSliders(SoXtColorEditor::Sliders whichSliders);
232
236 void setUpdateFrequency(SoXtColorEditor::UpdateFrequency freq);
241
242 private:
243
244 // This constructor takes a boolean whether to build the widget now.
245 // Subclasses can pass FALSE, then call SoXtColorEditor::buildWidget()
246 // when they are ready for it to be built.
249 const char *name,
250 SbBool buildInsideParent,
251 SbBool buildNow);
252
253 // redefine these
254 virtual SbString getDefaultWidgetName() const;
255 virtual SbString getDefaultTitle() const;
256 virtual SbString getDefaultIconTitle() const;
257
258 private:
259
260 // redefine these to do colorEditor specific things
261 SoWidget buildWidget(SoWidget parent);
262 static void visibilityChangeCB(void *pt, SbBool visible);
263
264 // local variables
265 SoWidget mgrWidget; // form manages all child widgets
266 SbBool WYSIWYGmode;
267 Sliders whichSliders;
268 SbColor baseRGB;
269 float baseHSV[3];
270 SbBool ignoreCallback;
271 SoXtColorSlider *sliders[6];
272 SoXtColorWheel *wheel;
273 SoXtColorPatch *current, *previous;
274 _ColorEditorCBData *dataId;
275 SbPList menuItems; // Widgets
276 SoXtColorEditor::UpdateFrequency updateFreq;
277
278 // attach/detach variables
279 SbBool attached;
280 SoBase *editNode;
281 SoSFColor *colorSF;
282 SoMFColor *colorMF;
283 SoNodeSensor *colorSensor;
284 SoCallbackList *callbackList;
285 int index;
286
287 // Extension (mmh)
288 // additional attach variables for handling "orderedRGBA" fields
289 SoMFUInt32 *colorUInt32MF;
290 float transparency;
291
292 // copy/paste support
293 SoXtClipboard *clipboard;
294 void copy(Time eventTime);
295 void paste(Time eventTime);
296 void pasteDone(SoPathList *pathList);
297 static void pasteDoneCB(void *userData, SoPathList *pathList);
298
299 // list of widgets which need to be accessed
300 SoWidget acceptButton, slidersForm, buttonsForm, wheelForm;
301
302 // build/destroy routines
303 SoWidget buildPulldownMenu(SoWidget parent);
304 SoWidget buildControls(SoWidget parent);
305 SoWidget buildSlidersForm(SoWidget parent);
306
307 void doSliderLayout();
308 void doDynamicTopLevelLayout();
309 int numberOfSliders(SoXtColorEditor::Sliders slider);
310
311 // do the updates - if attached, update the node; if callback, call it.
312 void doUpdates();
313
314 // color field sensor callback and routine
315 void fieldChanged();
316 static void fieldChangedCB(void *, SoSensor *);
317
318 // callbacks and actual routine from sliders, wheel, buttons, menu...
319 static void wheelCallback(void *, const float hsv[3]);
320 void wheelChanged(const float hsv[3]);
321 static void sliderCallback(void *, float);
322 void sliderChanged(short id, float value);
323 static void buttonsCallback(SoWidget, _ColorEditorCBData *, XtPointer);
324 void buttonPressed(short id);
325 static void editMenuCallback(SoWidget, _ColorEditorCBData *, XmAnyCallbackStruct *);
326 static void sliderMenuCallback(SoWidget, _ColorEditorCBData *, XtPointer);
327
328 static void menuDisplay(SoWidget, SoXtColorEditor *editor, XtPointer);
329
330 // this is called by both constructors
331 void constructorCommon(SbBool buildNow);
332 // Function used to create strings in motif buttons/menus.
333 void initStrings( void );
334
335};
336
337// Inline functions
338void
340{
341 callbackList->addCallback((SoCallbackListCB *)f, userData);
342}
343
344void
346{
347 callbackList->removeCallback((SoCallbackListCB *)f, userData);
348}
349
350#endif /* _SO_XT_COLOR_EDITOR_ */
351
352#endif // _WIN32
353
354
#define SoEXTENDER
#define TRUE
Possible value of SbBool.
Definition SbBase.h:77
void * XtPointer
Definition SoQtDef.h:118
#define SoWidget
Definition SoQtDef.h:40
#define XmAnyCallbackStruct
Definition SoWinDef.h:127
#define Time
Definition SoWinDef.h:93
#define SoXtColorEditor
Definition SoXt2SoQt.h:172
#define SoXtColorWheel
Definition SoXt2SoQt.h:176
#define SoXtColorSlider
Definition SoXt2SoQt.h:175
#define SoXtColorEditorCB
Definition SoXt2SoQt.h:173
#define SoXtColorPatch
Definition SoXt2SoQt.h:174
void SoXtColorEditorCB(void *userData, const SbColor *color)
Color vector class.
Definition SbColor.h:82
List of generic (void *) pointers.
Definition SbPList.h:77
Class for smart character strings.
Definition SbString.h:202
Base class for all nodes, paths, and engines.
Definition SoBase.h:111
Manages a list of callbacks and associated data.
void addCallback(SoCallbackListCB *f, void *userData=NULL)
Adds a function to the list of callback functions.
void removeCallback(SoCallbackListCB *f, void *userData=NULL)
Removes a function from the list of callback functions.
Multiple-value field containing any number of RGB colors stored as three floats.
Definition SoMFColor.h:98
Multiple-value field containing any number of uint32_t integers.
Definition SoMFUInt32.h:90
Sensor class that can be attached to Open Inventor nodes.
Maintains a list of pointers to paths.
Definition SoPathList.h:81
Field containing an RGB color.
Definition SoSFColor.h:82
Abstract base class for Open Inventor sensors.
Definition SoSensor.h:97
Supports copy/paste for Open Inventor using the Xt clipboard.
Component that lets you edit a color interactively.
const SbColor & getColor()
Gets the current color value.
void attach(SoMFColor *color, int index, SoBase *node)
Attaches the editor to a color node and edits the color of the given index.
SoXtColorEditor::UpdateFrequency getUpdateFrequency()
Gets the update frequency.
Sliders
list of possible slider combinations, which is used to specify which sliders should be displayed at a...
@ INTENSITY
Display intensity slider (default)
@ RGB_V
Display RGB and value sliders.
@ RGB
Display RGB sliders.
@ HSV
Display HSV sliders.
@ NONE
Display no sliders.
@ RGB_HSV
Display RGB and HSV sliders.
void attach(SoMFUInt32 *color, int index, SoBase *node)
Attaches the editor to a color node and edits the color of the given index.
SoXtColorEditor::Sliders getCurrentSliders()
Gets which slider(s) should be displayed.
void setWYSIWYG(SbBool trueOrFalse)
Sets the WYSIWYG (what-you-see-is-what-you-get) mode on/off for the colored backgrounds of the slider...
void setUpdateFrequency(SoXtColorEditor::UpdateFrequency freq)
Sets the update frequency.
void attach(SoSFColor *color, SoBase *node)
Attaches the editor to a color node and edits the specified color.
SbBool isWYSIWYG()
Gets the WYSIWYG mode.
~SoXtColorEditor()
Destructor.
void removeColorChangedCallback(SoXtColorEditorCB *f, void *userData=NULL)
Removes colorChanged callback.
void setCurrentSliders(SoXtColorEditor::Sliders whichSliders)
Sets which slider(s) should be displayed.
SbBool isAttached()
Returns TRUE if the editor is attached.
void detach()
Detaches the editor from a color node.
SoXtColorEditor(SoWidget parent=NULL, const char *name=NULL, SbBool buildInsideParent=TRUE)
Constructor.
UpdateFrequency
UpdateFrequency is how often new values should be sent to the node or the callback routine.
@ CONTINUOUS
Send updates with every mouse motion.
@ AFTER_ACCEPT
Only send updates after user hits accept button.
void setColor(const SbColor &color)
Sets a new color value.
void addColorChangedCallback(SoXtColorEditorCB *f, void *userData=NULL)
Additional way of using the color editor, by registering a callback which will be called whenever the...
Abstract base class for all Open Inventor components.
int SbBool
Boolean type.
Definition SbBase.h:87
void SoCallbackListCB(void *userData, void *callbackData)