Open Inventor Release 2024.1.0
 
Loading...
Searching...
No Matches
SoQtColorEditor.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-2017 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : Alain Dumesny (MMM yyyy)
22**=======================================================================*/
23
24#ifndef _SO_QT_COLOR_EDITOR_
25#define _SO_QT_COLOR_EDITOR_
27#include <Inventor/SbColor.h>
30
31#include <qglobal.h>
32#include <QPointer>
33
34class SoBase;
35class SoNodeSensor;
36class SoMFColor;
37class SoPathList;
38class SoSFColor;
39class SoSensor;
40class SoQtColorPatch;
41class SoQtColorWheel;
42class SoQtColorSlider;
43class QMenuBar;
44class QMenu;
45class QAction;
46class QSlider;
47
48class SoMFUInt32;
49
50struct ColorEditorCBData;
51
55typedef void SoQtColorEditorCB( void* userData, const SbColor* color );
56
57
59//
60// Class: SoQtColorEditor
61//
62// SoQtColorEditor class which lets you interactively edit a color.
63//
65
88
89 Q_OBJECT
90
91public:
92
124
140
144 SoQtColorEditor( QWidget *parent = qApp->activeWindow(),
145 const char *name = NULL, // a QDialog even if he has no direct parent
146 SbBool buildInsideParent = TRUE );
151
166 void attach(SoSFColor *color, SoBase *node);
171 void attach(SoMFColor *color, int index, SoBase *node);
172
177 void attach(SoMFUInt32 *color, int index, SoBase *node);
178
184 void detach();
188 SbBool isAttached() { return attached; }
189
196 void *userData = NULL );
201 void *userData = NULL );
202
207 void setColor(const SbColor &color);
211 const SbColor & getColor() { return baseRGB; }
212
227 void setWYSIWYG(SbBool trueOrFalse);
231 SbBool isWYSIWYG() { return WYSIWYGmode; }
232
241
251
255 virtual void show();
256
260 virtual void hide();
261
266
267private:
268
269 // This constructor takes a boolean whether to build the widget now.
270 // Subclasses can pass FALSE, then call SoQtColorEditor::buildWidget()
271 // when they are ready for it to be built.
274 QWidget *parent,
275 const char *name,
276 SbBool buildInsideParent,
277 SbBool buildNow);
278
279 // redefine these
280 virtual SbString getDefaultWidgetName() const;
281 virtual SbString getDefaultTitle() const;
282 virtual SbString getDefaultIconTitle() const;
283
284private:
285
286 QMenuBar* menubar ;
287
288 int nCurrSliderId;
289 QPointer<QMenu> menu_sliders, edit;
290 QPointer<SoQtButton> lpleftButton ;
291 QPointer<SoQtButton> lprightButton ;
292 QPointer<SoQtButton> lpswitchButton ;
293
294 QAction* edAcCon, *edAcMan, *edAcWy;
295 QAction* msAcNone, *msAcInt, *msAcRGB, *msAcHSV, *msAcRGB_V, *msAcRGB_HSV;
296
297 // redefine these to do colorEditor specific things
298 QWidget* buildWidget(QWidget *parent);
299
300 // local variables
301 QPointer<QWidget> mgrWidget;
302 SbBool WYSIWYGmode;
303 Sliders whichSliders;
304 SbColor baseRGB;
305 float baseHSV[3];
306 SbBool ignoreCallback;
307 SoQtColorSlider *sliders[6];
308 SoQtColorWheel *wheel;
309 SoQtColorPatch *current, *previous;
310 ColorEditorCBData *dataId;
311 SbPList menuItems; // Widgets
313
314 // attach/detach variables
315 SbBool attached;
316 SoBase *editNode;
317 SoSFColor *colorSF;
318 SoMFColor *colorMF;
319 SoNodeSensor *colorSensor;
320 SoCallbackList *callbackList;
321 int index;
322
323 // additional attach variables for handling "orderedRGBA" fields
324 SoMFUInt32 *colorUInt32MF;
325 float transparency;
326
327 // list of widgets which need to be accessed
328 QPointer<SoQtButton> acceptButton;
329 QWidget *wheelForm;
330
331 // build/destroy routines
332 QMenuBar* buildPulldownMenu(QWidget *parent);
333 void buildControls(QWidget *parent);
334 void buildSlidersForm(QWidget *parent);
335
336 void doSliderLayout();
337 void doDynamicTopLevelLayout();
338 int numberOfSliders(SoQtColorEditor::Sliders slider);
339
340
341 // do the updates - if attached, update the node; if callback, call it.
342 void doUpdates();
343
344 // color field sensor callback and routine
345 void fieldChanged();
346 static void fieldChangedCB(void *, SoSensor *);
347
348
349 // callbacks and actual routine from sliders, wheel, buttons, menu...
350 static void wheelCallback(void *, const float hsv[3]);
351 static void wheelCloseCB(void *userData, SoQtComponent *);
352
353 void wheelChanged(const float hsv[3]);
354
355 static void sliderCallback(void *, float);
356 void sliderChanged(short id, float value);
357
358 void buttonPressed(short id);
359
360 void sliderMenuCallback(int id);
361 void editMenuCallback(int id);
362
363 // this is called by both constructors
364 void constructorCommon(SbBool buildNow);
365
366private Q_SLOTS:
367
368void slot_none();
369 void slot_intensity();
370 void slot_rgb();
371 void slot_hsv();
372 void slot_rgb_v();
373 void slot_rgb_hsv();
374
375 void slot_continuous();
376 void slot_manual();
377 void slot_wysiwyg();
378
379 void slot_leftButton();
380 void slot_rightButton();
381 void slot_switchButton();
382 void slot_acceptButton();
383 void slot_help();
384
385 void visibilityChangeCB(SbBool visible);
386
387};
388
389// Inline functions
390void
392 void *userData)
393{ callbackList->addCallback((SoCallbackListCB *) f, userData); }
394
395void
397 void *userData)
398{ callbackList->removeCallback((SoCallbackListCB *) f, userData); }
399
400
401#endif /* _SO_QT_COLOR_EDITOR_ */
402
#define SoEXTENDER
#define TRUE
Possible value of SbBool.
Definition SbBase.h:77
void SoQtColorEditorCB(void *userData, const SbColor *color)
External change callback functions registered with the color editor should be of this type.
SoQtColorSlider(QWidget *parent=NULL, const char *name=NULL, SbBool buildInsideParent=TRUE, Type type=INTENSITY_SLIDER)
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
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Component that l...
UpdateFrequency
Update frequency.
@ CONTINUOUS
Send updates with every mouse motion.
@ AFTER_ACCEPT
Only send updates after user hits accept button.
void setUpdateFrequency(SoQtColorEditor::UpdateFrequency freq)
Sets the update frequency.
void addColorChangedCallback(SoQtColorEditorCB *f, void *userData=NULL)
Additional way of using the color editor, by registering a callback which will be called whenever the...
virtual void hide()
Hide the color editor.
void attach(SoMFUInt32 *color, int index, SoBase *node)
Attaches the editor to a color node and edits the color of the given index.
void attach(SoSFColor *color, SoBase *node)
Attaches the editor to a color node and edits the specified color.
void setColor(const SbColor &color)
Sets a new color value.
const SbColor & getColor()
Gets the current color value.
SbBool isAttached()
Returns TRUE if the editor is attached.
SoQtColorEditor::Sliders getCurrentSliders()
Gets which slider(s) should be displayed.
SoQtColorEditor(QWidget *parent=qApp->activeWindow(), const char *name=NULL, SbBool buildInsideParent=TRUE)
Constructor.
SbBool isWYSIWYG()
Gets the WYSIWYG mode.
void attach(SoMFColor *color, int index, SoBase *node)
Attaches the editor to a color node and edits the specified color.
SbBool alwaysOnTop
Boolean indicating if the editor should be always on top of the other windows.
@ NONE
Display no sliders.
@ RGB
Display RGB sliders.
@ HSV
Display HSV sliders.
@ RGB_HSV
Display RGB and HSV sliders.
@ INTENSITY
Display intensity slider (default)
@ RGB_V
Display RGB and value sliders.
void setCurrentSliders(SoQtColorEditor::Sliders whichSliders)
Sets which slider(s) should be displayed.
~SoQtColorEditor()
Destructor.
SoQtColorEditor::UpdateFrequency getUpdateFrequency()
Gets the update frequency.
virtual void show()
Make the color editor visible.
void detach()
Detaches the editor from a color node.
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 removeColorChangedCallback(SoQtColorEditorCB *f, void *userData=NULL)
Removes colorChanged callback.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Abstract base cl...
Field containing an RGB color.
Definition SoSFColor.h:82
Abstract base class for Open Inventor sensors.
Definition SoSensor.h:97
int SbBool
Boolean type.
Definition SbBase.h:87
void SoCallbackListCB(void *userData, void *callbackData)