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
00087 class SoQtColorEditor : public SoQtComponent {
00088
00089 Q_OBJECT
00090
00091 public:
00092
00097 enum Sliders
00098 {
00102 NONE,
00106 INTENSITY,
00110 RGB,
00114 HSV,
00118 RGB_V,
00122 RGB_HSV
00123 };
00124
00129 enum UpdateFrequency
00130 {
00134 CONTINUOUS,
00138 AFTER_ACCEPT
00139 };
00140
00144 SoQtColorEditor( QWidget *parent = qApp->activeWindow(),
00145 const char *name = NULL,
00146 SbBool buildInsideParent = TRUE );
00150 ~SoQtColorEditor();
00151
00166 void attach(SoSFColor *color, SoBase *node);
00171 void attach(SoMFColor *color, int index, SoBase *node);
00172
00177 void attach(SoMFUInt32 *color, int index, SoBase *node);
00178
00184 void detach();
00188 SbBool isAttached() { return attached; }
00189
00195 inline void addColorChangedCallback( SoQtColorEditorCB *f,
00196 void *userData = NULL );
00200 inline void removeColorChangedCallback( SoQtColorEditorCB *f,
00201 void *userData = NULL );
00202
00207 void setColor(const SbColor &color);
00211 const SbColor & getColor() { return baseRGB; }
00212
00227 void setWYSIWYG(SbBool trueOrFalse);
00231 SbBool isWYSIWYG() { return WYSIWYGmode; }
00232
00236 void setCurrentSliders(SoQtColorEditor::Sliders whichSliders);
00240 SoQtColorEditor::Sliders getCurrentSliders() { return whichSliders; }
00241
00245 void setUpdateFrequency(SoQtColorEditor::UpdateFrequency freq);
00249 SoQtColorEditor::UpdateFrequency getUpdateFrequency()
00250 { return updateFreq; }
00251
00255 virtual void show();
00256
00260 virtual void hide();
00261
00265 SbBool alwaysOnTop;
00266
00267 private:
00268
00269
00270
00271
00272 SoEXTENDER
00273 SoQtColorEditor(
00274 QWidget *parent,
00275 const char *name,
00276 SbBool buildInsideParent,
00277 SbBool buildNow);
00278
00279
00280 virtual SbString getDefaultWidgetName() const;
00281 virtual SbString getDefaultTitle() const;
00282 virtual SbString getDefaultIconTitle() const;
00283
00284 private:
00285
00286 QMenuBar* menubar ;
00287
00288 int nCurrSliderId;
00289 QPointer<QMenu> menu_sliders, edit;
00290 QPointer<SoQtButton> lpleftButton ;
00291 QPointer<SoQtButton> lprightButton ;
00292 QPointer<SoQtButton> lpswitchButton ;
00293
00294 QAction* edAcCon, *edAcMan, *edAcWy;
00295 QAction* msAcNone, *msAcInt, *msAcRGB, *msAcHSV, *msAcRGB_V, *msAcRGB_HSV;
00296
00297
00298 QWidget* buildWidget(QWidget *parent);
00299
00300
00301 QPointer<QWidget> mgrWidget;
00302 SbBool WYSIWYGmode;
00303 Sliders whichSliders;
00304 SbColor baseRGB;
00305 float baseHSV[3];
00306 SbBool ignoreCallback;
00307 SoQtColorSlider *sliders[6];
00308 SoQtColorWheel *wheel;
00309 SoQtColorPatch *current, *previous;
00310 ColorEditorCBData *dataId;
00311 SbPList menuItems;
00312 SoQtColorEditor::UpdateFrequency updateFreq;
00313
00314
00315 SbBool attached;
00316 SoBase *editNode;
00317 SoSFColor *colorSF;
00318 SoMFColor *colorMF;
00319 SoNodeSensor *colorSensor;
00320 SoCallbackList *callbackList;
00321 int index;
00322
00323
00324 SoMFUInt32 *colorUInt32MF;
00325 float transparency;
00326
00327
00328 QPointer<SoQtButton> acceptButton;
00329 QWidget *wheelForm;
00330
00331
00332 QMenuBar* buildPulldownMenu(QWidget *parent);
00333 void buildControls(QWidget *parent);
00334 void buildSlidersForm(QWidget *parent);
00335
00336 void doSliderLayout();
00337 void doDynamicTopLevelLayout();
00338 int numberOfSliders(SoQtColorEditor::Sliders slider);
00339
00340
00341
00342 void doUpdates();
00343
00344
00345 void fieldChanged();
00346 static void fieldChangedCB(void *, SoSensor *);
00347
00348
00349
00350 static void wheelCallback(void *, const float hsv[3]);
00351 static void wheelCloseCB(void *userData, SoQtComponent *);
00352
00353 void wheelChanged(const float hsv[3]);
00354
00355 static void sliderCallback(void *, float);
00356 void sliderChanged(short id, float value);
00357
00358 void buttonPressed(short id);
00359
00360 void sliderMenuCallback(int id);
00361 void editMenuCallback(int id);
00362
00363
00364 void constructorCommon(SbBool buildNow);
00365
00366 private Q_SLOTS:
00367
00368 void slot_none();
00369 void slot_intensity();
00370 void slot_rgb();
00371 void slot_hsv();
00372 void slot_rgb_v();
00373 void slot_rgb_hsv();
00374
00375 void slot_continuous();
00376 void slot_manual();
00377 void slot_wysiwyg();
00378
00379 void slot_leftButton();
00380 void slot_rightButton();
00381 void slot_switchButton();
00382 void slot_acceptButton();
00383 void slot_help();
00384
00385 void visibilityChangeCB(SbBool visible);
00386
00387 };
00388
00389
00390 void
00391 SoQtColorEditor::addColorChangedCallback(SoQtColorEditorCB *f,
00392 void *userData)
00393 { callbackList->addCallback((SoCallbackListCB *) f, userData); }
00394
00395 void
00396 SoQtColorEditor::removeColorChangedCallback(SoQtColorEditorCB *f,
00397 void *userData)
00398 { callbackList->removeCallback((SoCallbackListCB *) f, userData); }
00399
00400
00401 #endif
00402
00403