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
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00065
00066 #ifdef SOQT
00067 # include <Inventor/Qt/SoQtMaterialEditor.h>
00068 #elif defined _WIN32
00069 # include <Inventor/Win/SoWinMaterialEditor.h>
00070 #else // _WIN32
00071
00072 #ifndef _SO_XT_MATERIAL_EDITOR_
00073 #define _SO_XT_MATERIAL_EDITOR_
00074
00075 #include <Xm/Xm.h>
00076 #include <Inventor/SbBasic.h>
00077 #include <Inventor/misc/SoCallbackList.h>
00078 #include <Inventor/Xt/SoXtComponent.h>
00079
00080 class SoBaseColor;
00081 class SoXtClipboard;
00082 class SoXtColorEditor;
00083 class SoNodeSensor;
00084 class SoSensor;
00085 class SoDirectionalLight;
00086 class SoMaterial;
00087 class SoXtMaterialList;
00088 class SoPathList;
00089 class SoXtRenderArea;
00090 class SoSelection;
00091 class SoXtColorSlider;
00092 class SoMFColor;
00093 class SbColor;
00094 class SoBase;
00095 class SoSeparator;
00096 class SoVRMLMaterial;
00097 class SoNode;
00098 class SoSFColor;
00099
00100
00101 typedef void SoXtMaterialEditorCB(void *userData, const SoMaterial *mtl);
00102
00104
00105
00106
00107
00108
00110
00174 class SoXtMaterialEditor : public SoXtComponent {
00175 public:
00180 enum UpdateFrequency {
00184 CONTINUOUS,
00188 AFTER_ACCEPT
00189 };
00190
00194 SoXtMaterialEditor(
00195 SoWidget parent = NULL,
00196 const char *name = NULL,
00197 SbBool buildInsideParent = TRUE);
00201 ~SoXtMaterialEditor();
00202
00207 void attach(SoMaterial *material, int index = 0);
00208
00212 void attach(SoVRMLMaterial *material);
00213
00217 void detach();
00221 SbBool isAttached() { return (material != NULL); }
00222
00228 inline void addMaterialChangedCallback(
00229 SoXtMaterialEditorCB *f,
00230 void *userData = NULL);
00234 inline void removeMaterialChangedCallback(
00235 SoXtMaterialEditorCB *f,
00236 void *userData = NULL);
00237
00241 void setUpdateFrequency(SoXtMaterialEditor::UpdateFrequency freq);
00245 SoXtMaterialEditor::UpdateFrequency getUpdateFrequency()
00246 { return updateFreq; }
00247
00248
00249
00250 virtual void show();
00251 virtual void hide();
00252
00256 void setMaterial(const SoMaterial &mtl);
00257
00261 void setMaterial(const SoVRMLMaterial &mtl);
00262
00266 const SoMaterial & getMaterial() const { return *localMaterial; }
00267
00271 SbBool isAttachedVRML() { return (isVRMLMaterial); }
00272
00273 private:
00274
00275
00276
00277
00278 SoEXTENDER
00279 SoXtMaterialEditor(
00280 SoWidget parent,
00281 const char *name,
00282 SbBool buildInsideParent,
00283 SbBool buildNow);
00284
00285 SoWidget buildWidget(SoWidget parent);
00286
00287
00288 virtual SbString getDefaultWidgetName() const;
00289 virtual SbString getDefaultTitle() const;
00290 virtual SbString getDefaultIconTitle() const;
00291
00292 private:
00293
00294 SoNode *material;
00295 SoMaterial *imat;
00296 SoVRMLMaterial *vmat;
00297 SbBool isVRMLMaterial;
00298 int index;
00299 SoNodeSensor *sensor;
00300 SoCallbackList *callbackList;
00301 SoWidget acceptButton, diamondButtons[4], radioButtons[4];
00302 SoXtMaterialEditor::UpdateFrequency updateFreq;
00303
00304
00305 SoWidget mgrWidget;
00306 SoXtColorEditor *colorEditor;
00307 SoXtColorSlider *sliders[6];
00308 SbBool changedIt[6];
00309 SoXtMaterialList *materialList;
00310 SbBool ignoreCallback;
00311 SbBool openMaterialList;
00312 static void colorEditorCloseCB(void *, SoXtComponent *);
00313 static void materialListCloseCB(void *, SoXtComponent *);
00314
00315
00316 SoXtClipboard *clipboard;
00317
00318
00319 SoXtRenderArea *renderArea;
00320 SoMaterial *localMaterial;
00321 SoDirectionalLight *light0;
00322 SoDirectionalLight *light1;
00323 SoBaseColor *tileColor;
00324 SoSeparator *root;
00325
00326
00327 SoWidget *menuItemsList;
00328
00329 int32_t activeColor;
00330
00331
00332 void updateLocalComponents();
00333
00334
00335 void updateColorEditor(SbBool updateTitle = FALSE);
00336
00337
00338
00339 void updateColorSlider(SoXtColorSlider *, const float rgb[3]);
00340
00341
00342 void updateMaterialColor(
00343 SoMFColor *editMtlColor,
00344 SoMFColor *localMtlColor,
00345 const float *rgb,
00346 float intensity);
00347 void updateMaterialColor(
00348 SoSFColor *editMtlColor,
00349 SoMFColor *localMtlColor,
00350 const float *rgb,
00351 float intensity);
00352
00353
00354 void copyMaterial(SoNode *mat1, int index1,
00355 const SoNode *mat2, int index2);
00356
00357
00358
00359 void undoIgnoresIfChanged();
00360
00361
00362 static void pasteDone(void *userData, SoPathList *pathList);
00363
00364
00365 static void materialListCB(void *, const SoMaterial *);
00366 static void colorEditorCB(void *, const SbColor *);
00367 static void ambientSliderCB(void *, float);
00368 static void diffuseSliderCB(void *, float);
00369 static void specularSliderCB(void *, float);
00370 static void emissiveSliderCB(void *, float);
00371 static void shininessSliderCB(void *, float);
00372 static void transparencySliderCB(void *, float);
00373
00374
00375 static void menuPick(SoWidget, int, XmAnyCallbackStruct *);
00376 static void menuDisplay(SoWidget, SoXtMaterialEditor *, XtPointer);
00377 static void radioButtonPick(SoWidget, int, XtPointer);
00378 static void diamondButtonPick(SoWidget, int, XtPointer);
00379 static void acceptButtonCB(SoWidget, SoXtMaterialEditor *, XtPointer);
00380
00381
00382 static void sensorCB(void *, SoSensor *);
00383
00384
00385 SoWidget buildPulldownMenu(SoWidget parent);
00386 SoWidget buildControls(SoWidget parent);
00387 SoWidget buildSlidersForm(SoWidget parent);
00388
00389 static void visibilityChangeCB(void *pt, SbBool visible);
00390 void activate();
00391 void deactivate();
00392
00393
00394 void constructorCommon(SbBool buildNow);
00395
00396 };
00397
00398
00399
00400 void
00401 SoXtMaterialEditor::addMaterialChangedCallback(
00402 SoXtMaterialEditorCB *f,
00403 void *userData)
00404 { callbackList->addCallback((SoCallbackListCB *) f, userData); }
00405
00406 void
00407 SoXtMaterialEditor::removeMaterialChangedCallback(
00408 SoXtMaterialEditorCB *f,
00409 void *userData)
00410 { callbackList->removeCallback((SoCallbackListCB *) f, userData); }
00411
00412 #endif // _SO_XT_MATERIAL_EDITOR_
00413
00414 #endif // _WIN32
00415
00416
00417