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
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00040
00041 #ifndef _SO_QT_MATERIAL_EDITOR_
00042 #define _SO_QT_MATERIAL_EDITOR_
00043
00044 #include <Inventor/Qt/OivQtCompat.h>
00045 #include <Inventor/SbBasic.h>
00046 #include <Inventor/misc/SoCallbackList.h>
00047 #include <Inventor/Qt/SoQtComponent.h>
00048
00049 #include <QPointer>
00050 class QMenu;
00051 class QAction;
00052 class SoBaseColor;
00053 class SoQtColorEditor;
00054 class QLabel;
00055 class QRadioButton;
00056 class QMenuBar;
00057 class SoNodeSensor;
00058 class SoSensor;
00059 class SoDirectionalLight;
00060 class SoMaterial;
00061 class SoPathList;
00062 class SoQtRenderArea;
00063 class SoSelection;
00064 class SoQtColorSlider;
00065 class SoMFColor;
00066 class SbColor;
00067 class SoBase;
00068 class SoSeparator;
00069 class SoQtMaterialPalette;
00070
00071 class SoVRMLMaterial;
00072 class SoNode;
00073 class SoSFColor;
00074
00075
00076 typedef void SoQtMaterialEditorCB(void *userData, const SoMaterial *mtl);
00077
00079
00080
00081
00082
00083
00085
00114 class SoQtMaterialEditor : public SoQtComponent {
00115
00116 Q_OBJECT
00117
00118 public:
00123 enum UpdateFrequency {
00127 CONTINUOUS,
00131 AFTER_ACCEPT
00132 };
00133
00137 SoQtMaterialEditor( QWidget *parent = qApp->activeWindow(),
00138 const char *name = NULL,
00139 SbBool buildInsideParent = TRUE );
00143 ~SoQtMaterialEditor();
00144
00149 void attach( SoMaterial *material, int index = 0 );
00150
00154 void attach( SoVRMLMaterial *material );
00155
00159 void detach();
00160
00164 SbBool isAttached() { return (material != NULL); }
00165
00171 inline void addMaterialChangedCallback(
00172 SoQtMaterialEditorCB *f,
00173 void *userData = NULL);
00177 inline void removeMaterialChangedCallback(
00178 SoQtMaterialEditorCB *f,
00179 void *userData = NULL);
00180
00184 void setUpdateFrequency(SoQtMaterialEditor::UpdateFrequency freq);
00185
00189 SoQtMaterialEditor::UpdateFrequency getUpdateFrequency()
00190 { return updateFreq; }
00191
00192
00193
00194 virtual void show();
00195 virtual void hide();
00196
00200 void setMaterial(const SoMaterial &mtl);
00201
00205 void setMaterial(const SoVRMLMaterial &mtl);
00206
00210 const SoMaterial & getMaterial() const { return *localMaterial; }
00211 #ifdef NOTYET
00212 const SoVRMLMaterial & getVRMLMaterial() const
00213 { copyMaterial( localVRMLMaterial,0,localMaterial,0);
00214 return *localVRMLMaterial; }
00215 #endif
00216
00220 SbBool isAttachedVRML() { return (isVRMLMaterial); }
00221
00225 SbBool alwaysOnTop;
00226
00230 SoQtMaterialPalette * m_pMaterialPalette;
00231
00232 private:
00233
00234
00235
00236
00237
00238 SoEXTENDER
00239 SoQtMaterialEditor(
00240 QWidget *parent,
00241 const char *name,
00242 SbBool buildInsideParent,
00243 SbBool buildNow);
00244
00245
00246 virtual SbString getDefaultWidgetName() const;
00247 virtual SbString getDefaultTitle() const;
00248 virtual SbString getDefaultIconTitle() const;
00249
00250 virtual bool eventFilter(QObject * object,QEvent *event);
00251
00252 private:
00253 unsigned long nCurrEditId ;
00254
00255
00256 QMenuBar *menubar ;
00257
00258
00259
00260
00261 SoNode *material;
00262 SoMaterial *imat;
00263 SoVRMLMaterial *vmat;
00264 int index;
00265 SoNodeSensor *sensor;
00266 SoCallbackList *callbackList;
00267 QPointer<QRadioButton> diamondButtons[4], radioButtons[4];
00268 QPointer<SoQtButton> acceptButton;
00269 SoQtMaterialEditor::UpdateFrequency updateFreq;
00270
00271 SbBool isVRMLMaterial;
00272
00273
00274 QPointer<QWidget> mgrWidget;
00275 SoQtColorEditor *colorEditor;
00276 SoQtColorSlider *sliders[6];
00277 SbBool changedIt[6];
00278 #ifdef NOTYET
00279 SoQtMaterialList *materialList;
00280 #endif
00281 SbBool ignoreCallback;
00282 SbBool openMaterialList;
00283
00284
00285
00286
00287
00288 SoQtRenderArea *renderArea;
00289 SoMaterial *localMaterial;
00290 SoVRMLMaterial *localVRMLMaterial;
00291 SoDirectionalLight *light0;
00292 SoDirectionalLight *light1;
00293 SoBaseColor *tileColor;
00294 SoSeparator *root;
00295
00296 long activeColor;
00297
00298
00299 void updateLocalComponents();
00300
00301
00302 void updateColorEditor(SbBool updateTitle = FALSE);
00303
00304
00305
00306 void updateColorSlider(SoQtColorSlider *, const float rgb[3]);
00307
00308
00309 void updateMaterialColor(
00310 SoMFColor *editMtlColor,
00311 SoMFColor *localMtlColor,
00312 const float *rgb,
00313 float intensity);
00314 void updateMaterialColor(
00315 SoSFColor *editMtlColor,
00316 SoMFColor *localMtlColor,
00317 const float *rgb,
00318 float intensity);
00319
00320
00321
00322
00323 void copyMaterial(SoNode *mat1, int index1,
00324 const SoNode *mat2, int index2);
00325
00326
00327
00328 void undoIgnoresIfChanged();
00329
00330
00331
00332
00333
00334 static void materialListCB(void *, const SoMaterial *);
00335 static void colorEditorCB(void *, const SbColor *);
00336 static void ambientSliderCB(void *, float);
00337 static void diffuseSliderCB(void *, float);
00338 static void specularSliderCB(void *, float);
00339 static void emissiveSliderCB(void *, float);
00340 static void shininessSliderCB(void *, float);
00341 static void transparencySliderCB(void *, float);
00342 static void paletteEditorClosedCB(void*, SoQtComponent*);
00343 static void colorEditorCloseCB(void* userData, SoQtComponent*);
00344 static void dialogCloseCB(void* userData, SoQtComponent*);
00345
00346
00347 void menuPick(int id);
00348 void menuDisplay(QWidget*, SoQtMaterialEditor *, XtPointer);
00349 void radioButtonPick(QWidget*, int, XtPointer);
00350 void diamondButtonPick(QWidget*, int, XtPointer);
00351
00352
00353 static void sensorCB(void *, SoSensor *);
00354
00355
00356 QWidget* buildWidget(QWidget* parent);
00357 QMenuBar* buildPulldownMenu(QWidget* parent);
00358 QWidget* buildControls(QWidget* parent);
00359 QWidget* buildSlidersForm(QWidget* parent);
00360
00361 void activate();
00362 void deactivate();
00363
00364
00365 void constructorCommon(SbBool buildNow);
00366
00367 QPointer<QMenu> edit;
00368 QAction* acCon, *acMan;
00369
00370 private Q_SLOTS:
00371
00372 void visibilityChangeCB(SbBool visible);
00373
00374 void slot_mat_pal();
00375 void slot_continuous();
00376 void slot_manual();
00377
00378 void slot_radioButton0();
00379 void slot_radioButton1();
00380 void slot_radioButton2();
00381 void slot_radioButton3();
00382
00383 void slot_diamondButton0();
00384 void slot_diamondButton1();
00385 void slot_diamondButton2();
00386 void slot_diamondButton3();
00387
00388 void acceptButtonCB();
00389
00390 void slot_help();
00391
00392 };
00393
00394
00395 void
00396 SoQtMaterialEditor::addMaterialChangedCallback(
00397 SoQtMaterialEditorCB *f,
00398 void *userData)
00399 { callbackList->addCallback((SoCallbackListCB *) f, userData); }
00400
00401 void
00402 SoQtMaterialEditor::removeMaterialChangedCallback(
00403 SoQtMaterialEditorCB *f,
00404 void *userData)
00405 { callbackList->removeCallback((SoCallbackListCB *) f, userData); }
00406
00407
00408 #endif // _SO_QT_MATERIAL_EDITOR_
00409
00410