00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _SO_QT_MATERIAL_EDITOR_
00027 #define _SO_QT_MATERIAL_EDITOR_
00028
00029 #include <Inventor/Qt/OivQtCompat.h>
00030 #include <Inventor/SbBasic.h>
00031 #include <Inventor/misc/SoCallbackList.h>
00032 #include <Inventor/Qt/SoQtComponent.h>
00033
00034 #include <QPointer>
00035 class QMenu;
00036 class QAction;
00037 class SoBaseColor;
00038 class SoQtColorEditor;
00039 class QLabel;
00040 class QRadioButton;
00041 class QMenuBar;
00042 class SoNodeSensor;
00043 class SoSensor;
00044 class SoDirectionalLight;
00045 class SoMaterial;
00046 class SoPathList;
00047 class SoQtRenderArea;
00048 class SoSelection;
00049 class SoQtColorSlider;
00050 class SoMFColor;
00051 class SbColor;
00052 class SoBase;
00053 class SoSeparator;
00054 class SoQtMaterialPalette;
00055
00056 class SoNode;
00057 class SoSFColor;
00058
00059
00060 typedef void SoQtMaterialEditorCB(void *userData, const SoMaterial *mtl);
00061
00063
00064
00065
00066
00067
00069
00097 class SoQtMaterialEditor : public SoQtComponent {
00098
00099 Q_OBJECT
00100
00101 public:
00106 enum UpdateFrequency {
00110 CONTINUOUS,
00114 AFTER_ACCEPT
00115 };
00116
00120 SoQtMaterialEditor( QWidget *parent = qApp->activeWindow(),
00121 const char *name = NULL,
00122 SbBool buildInsideParent = TRUE );
00126 ~SoQtMaterialEditor();
00127
00132 void attach( SoMaterial *material, int index = 0 );
00133
00137 void detach();
00138
00142 SbBool isAttached() { return (material != NULL); }
00143
00149 inline void addMaterialChangedCallback(
00150 SoQtMaterialEditorCB *f,
00151 void *userData = NULL);
00155 inline void removeMaterialChangedCallback(
00156 SoQtMaterialEditorCB *f,
00157 void *userData = NULL);
00158
00162 void setUpdateFrequency(SoQtMaterialEditor::UpdateFrequency freq);
00163
00167 SoQtMaterialEditor::UpdateFrequency getUpdateFrequency()
00168 { return updateFreq; }
00169
00170
00171
00172 virtual void show();
00173 virtual void hide();
00174
00178 void setMaterial(const SoMaterial &mtl);
00179
00183 const SoMaterial & getMaterial() const { return *localMaterial; }
00184
00188 SbBool alwaysOnTop;
00189
00193 SoQtMaterialPalette * m_pMaterialPalette;
00194
00195 private:
00196
00197
00198
00199
00200
00201 SoEXTENDER
00202 SoQtMaterialEditor(
00203 QWidget *parent,
00204 const char *name,
00205 SbBool buildInsideParent,
00206 SbBool buildNow);
00207
00208
00209 virtual SbString getDefaultWidgetName() const;
00210 virtual SbString getDefaultTitle() const;
00211 virtual SbString getDefaultIconTitle() const;
00212
00213 virtual bool eventFilter(QObject * object,QEvent *event);
00214
00215 private:
00216 unsigned long nCurrEditId ;
00217
00218
00219 QMenuBar *menubar ;
00220
00221
00222
00223
00224 SoNode *material;
00225 SoMaterial *imat;
00226 int index;
00227 SoNodeSensor *sensor;
00228 SoCallbackList *callbackList;
00229 QPointer<QRadioButton> diamondButtons[4], radioButtons[4];
00230 QPointer<SoQtButton> acceptButton;
00231 SoQtMaterialEditor::UpdateFrequency updateFreq;
00232
00233
00234 QPointer<QWidget> mgrWidget;
00235 SoQtColorEditor *colorEditor;
00236 SoQtColorSlider *sliders[6];
00237 SbBool changedIt[6];
00238 #ifdef NOTYET
00239 SoQtMaterialList *materialList;
00240 #endif
00241 SbBool ignoreCallback;
00242 SbBool openMaterialList;
00243
00244
00245
00246
00247
00248 SoQtRenderArea *renderArea;
00249 SoMaterial *localMaterial;
00250 SoDirectionalLight *light0;
00251 SoDirectionalLight *light1;
00252 SoBaseColor *tileColor;
00253 SoSeparator *root;
00254
00255 long activeColor;
00256
00257
00258 void updateLocalComponents();
00259
00260
00261 void updateColorEditor(SbBool updateTitle = FALSE);
00262
00263
00264
00265 void updateColorSlider(SoQtColorSlider *, const float rgb[3]);
00266
00267
00268 void updateMaterialColor(
00269 SoMFColor *editMtlColor,
00270 SoMFColor *localMtlColor,
00271 const float *rgb,
00272 float intensity);
00273 void updateMaterialColor(
00274 SoSFColor *editMtlColor,
00275 SoMFColor *localMtlColor,
00276 const float *rgb,
00277 float intensity);
00278
00279
00280
00281
00282 void copyMaterial(SoNode *mat1, int index1,
00283 const SoNode *mat2, int index2);
00284
00285
00286
00287 void undoIgnoresIfChanged();
00288
00289
00290
00291
00292
00293 static void materialListCB(void *, const SoMaterial *);
00294 static void colorEditorCB(void *, const SbColor *);
00295 static void ambientSliderCB(void *, float);
00296 static void diffuseSliderCB(void *, float);
00297 static void specularSliderCB(void *, float);
00298 static void emissiveSliderCB(void *, float);
00299 static void shininessSliderCB(void *, float);
00300 static void transparencySliderCB(void *, float);
00301 static void paletteEditorClosedCB(void*, SoQtComponent*);
00302 static void colorEditorCloseCB(void* userData, SoQtComponent*);
00303 static void dialogCloseCB(void* userData, SoQtComponent*);
00304
00305
00306 void menuPick(int id);
00307 void menuDisplay(QWidget*, SoQtMaterialEditor *, XtPointer);
00308 void radioButtonPick(QWidget*, int, XtPointer);
00309 void diamondButtonPick(QWidget*, int, XtPointer);
00310
00311
00312 static void sensorCB(void *, SoSensor *);
00313
00314
00315 QWidget* buildWidget(QWidget* parent);
00316 QMenuBar* buildPulldownMenu(QWidget* parent);
00317 QWidget* buildControls(QWidget* parent);
00318 QWidget* buildSlidersForm(QWidget* parent);
00319
00320 void activate();
00321 void deactivate();
00322
00323
00324 void constructorCommon(SbBool buildNow);
00325
00326 QPointer<QMenu> edit;
00327 QAction* acCon, *acMan;
00328
00329 private Q_SLOTS:
00330
00331 void visibilityChangeCB(SbBool visible);
00332
00333 void slot_mat_pal();
00334 void slot_continuous();
00335 void slot_manual();
00336
00337 void slot_radioButton0();
00338 void slot_radioButton1();
00339 void slot_radioButton2();
00340 void slot_radioButton3();
00341
00342 void slot_diamondButton0();
00343 void slot_diamondButton1();
00344 void slot_diamondButton2();
00345 void slot_diamondButton3();
00346
00347 void acceptButtonCB();
00348
00349 void slot_help();
00350
00351 };
00352
00353
00354 void
00355 SoQtMaterialEditor::addMaterialChangedCallback(
00356 SoQtMaterialEditorCB *f,
00357 void *userData)
00358 { callbackList->addCallback((SoCallbackListCB *) f, userData); }
00359
00360 void
00361 SoQtMaterialEditor::removeMaterialChangedCallback(
00362 SoQtMaterialEditorCB *f,
00363 void *userData)
00364 { callbackList->removeCallback((SoCallbackListCB *) f, userData); }
00365
00366
00367 #endif // _SO_QT_MATERIAL_EDITOR_
00368
00369