00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _SO_QT_COLOR_EDITOR_
00025 #define _SO_QT_COLOR_EDITOR_
00026 #include <Inventor/Qt/OivQtCompat.h>
00027 #include <Inventor/SbColor.h>
00028 #include <Inventor/misc/SoCallbackList.h>
00029 #include <Inventor/Qt/SoQtComponent.h>
00030
00031 #include <qglobal.h>
00032 #include <QPointer>
00033
00034 class SoBase;
00035 class SoNodeSensor;
00036 class SoMFColor;
00037 class SoPathList;
00038 class SoSFColor;
00039 class SoSensor;
00040 class SoQtColorPatch;
00041 class SoQtColorWheel;
00042 class SoQtColorSlider;
00043 class QMenuBar;
00044 class QMenu;
00045 class QAction;
00046 class QSlider;
00047
00048 class SoMFUInt32;
00049
00050 struct ColorEditorCBData;
00051
00055 typedef void SoQtColorEditorCB( void* userData, const SbColor* color );
00056
00057
00059
00060
00061
00062
00063
00065
00088 class SoQtColorEditor : public SoQtComponent {
00089
00090 Q_OBJECT
00091
00092 public:
00093
00098 enum Sliders
00099 {
00103 NONE,
00107 INTENSITY,
00111 RGB,
00115 HSV,
00119 RGB_V,
00123 RGB_HSV
00124 };
00125
00130 enum UpdateFrequency
00131 {
00135 CONTINUOUS,
00139 AFTER_ACCEPT
00140 };
00141
00145 SoQtColorEditor( QWidget *parent = qApp->activeWindow(),
00146 const char *name = NULL,
00147 SbBool buildInsideParent = TRUE );
00151 ~SoQtColorEditor();
00152
00167 void attach(SoSFColor *color, SoBase *node);
00172 void attach(SoMFColor *color, int index, SoBase *node);
00173
00178 void attach(SoMFUInt32 *color, int index, SoBase *node);
00179
00185 void detach();
00189 SbBool isAttached() { return attached; }
00190
00196 inline void addColorChangedCallback( SoQtColorEditorCB *f,
00197 void *userData = NULL );
00201 inline void removeColorChangedCallback( SoQtColorEditorCB *f,
00202 void *userData = NULL );
00203
00208 void setColor(const SbColor &color);
00212 const SbColor & getColor() { return baseRGB; }
00213
00228 void setWYSIWYG(SbBool trueOrFalse);
00232 SbBool isWYSIWYG() { return WYSIWYGmode; }
00233
00237 void setCurrentSliders(SoQtColorEditor::Sliders whichSliders);
00241 SoQtColorEditor::Sliders getCurrentSliders() { return whichSliders; }
00242
00246 void setUpdateFrequency(SoQtColorEditor::UpdateFrequency freq);
00250 SoQtColorEditor::UpdateFrequency getUpdateFrequency()
00251 { return updateFreq; }
00252
00256 virtual void show();
00257
00261 virtual void hide();
00262
00266 SbBool alwaysOnTop;
00267
00268 private:
00269
00270
00271
00272
00273 SoEXTENDER
00274 SoQtColorEditor(
00275 QWidget *parent,
00276 const char *name,
00277 SbBool buildInsideParent,
00278 SbBool buildNow);
00279
00280
00281 virtual SbString getDefaultWidgetName() const;
00282 virtual SbString getDefaultTitle() const;
00283 virtual SbString getDefaultIconTitle() const;
00284
00285 private:
00286
00287 QMenuBar* menubar ;
00288
00289 int nCurrSliderId;
00290 QPointer<QMenu> menu_sliders, edit;
00291 QPointer<SoQtButton> lpleftButton ;
00292 QPointer<SoQtButton> lprightButton ;
00293 QPointer<SoQtButton> lpswitchButton ;
00294
00295 QAction* edAcCon, *edAcMan, *edAcWy;
00296 QAction* msAcNone, *msAcInt, *msAcRGB, *msAcHSV, *msAcRGB_V, *msAcRGB_HSV;
00297
00298
00299 QWidget* buildWidget(QWidget *parent);
00300
00301
00302 QPointer<QWidget> mgrWidget;
00303 SbBool WYSIWYGmode;
00304 Sliders whichSliders;
00305 SbColor baseRGB;
00306 float baseHSV[3];
00307 SbBool ignoreCallback;
00308 SoQtColorSlider *sliders[6];
00309 SoQtColorWheel *wheel;
00310 SoQtColorPatch *current, *previous;
00311 ColorEditorCBData *dataId;
00312 SbPList menuItems;
00313 SoQtColorEditor::UpdateFrequency updateFreq;
00314
00315
00316 SbBool attached;
00317 SoBase *editNode;
00318 SoSFColor *colorSF;
00319 SoMFColor *colorMF;
00320 SoNodeSensor *colorSensor;
00321 SoCallbackList *callbackList;
00322 int index;
00323
00324
00325 SoMFUInt32 *colorUInt32MF;
00326 float transparency;
00327
00328
00329 QPointer<SoQtButton> acceptButton;
00330 QWidget *wheelForm;
00331
00332
00333 QMenuBar* buildPulldownMenu(QWidget *parent);
00334 void buildControls(QWidget *parent);
00335 void buildSlidersForm(QWidget *parent);
00336
00337 void doSliderLayout();
00338 void doDynamicTopLevelLayout();
00339 int numberOfSliders(SoQtColorEditor::Sliders slider);
00340
00341
00342
00343 void doUpdates();
00344
00345
00346 void fieldChanged();
00347 static void fieldChangedCB(void *, SoSensor *);
00348
00349
00350
00351 static void wheelCallback(void *, const float hsv[3]);
00352 static void wheelCloseCB(void *userData, SoQtComponent *);
00353
00354 void wheelChanged(const float hsv[3]);
00355
00356 static void sliderCallback(void *, float);
00357 void sliderChanged(short id, float value);
00358
00359 void buttonPressed(short id);
00360
00361 void sliderMenuCallback(int id);
00362 void editMenuCallback(int id);
00363
00364
00365 void constructorCommon(SbBool buildNow);
00366
00367 private Q_SLOTS:
00368
00369 void slot_none();
00370 void slot_intensity();
00371 void slot_rgb();
00372 void slot_hsv();
00373 void slot_rgb_v();
00374 void slot_rgb_hsv();
00375
00376 void slot_continuous();
00377 void slot_manual();
00378 void slot_wysiwyg();
00379
00380 void slot_leftButton();
00381 void slot_rightButton();
00382 void slot_switchButton();
00383 void slot_acceptButton();
00384 void slot_help();
00385
00386 void visibilityChangeCB(SbBool visible);
00387
00388 };
00389
00390
00391 void
00392 SoQtColorEditor::addColorChangedCallback(SoQtColorEditorCB *f,
00393 void *userData)
00394 { callbackList->addCallback((SoCallbackListCB *) f, userData); }
00395
00396 void
00397 SoQtColorEditor::removeColorChangedCallback(SoQtColorEditorCB *f,
00398 void *userData)
00399 { callbackList->removeCallback((SoCallbackListCB *) f, userData); }
00400
00401
00402 #endif
00403
00404