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 #ifdef SOQT
00051 # include <Inventor/Qt/SoQtMaterialEditor.h>
00052 #elif defined _WIN32
00053 # include <Inventor/Win/SoWinMaterialEditor.h>
00054 #else // _WIN32
00055
00056 #ifndef _SO_XT_MATERIAL_EDITOR_
00057 #define _SO_XT_MATERIAL_EDITOR_
00058
00059 #include <Xm/Xm.h>
00060 #include <Inventor/SbBasic.h>
00061 #include <Inventor/misc/SoCallbackList.h>
00062 #include <Inventor/Xt/SoXtComponent.h>
00063
00064 class SoBaseColor;
00065 class SoXtClipboard;
00066 class SoXtColorEditor;
00067 class SoNodeSensor;
00068 class SoSensor;
00069 class SoDirectionalLight;
00070 class SoMaterial;
00071 class SoXtMaterialList;
00072 class SoPathList;
00073 class SoXtRenderArea;
00074 class SoSelection;
00075 class SoXtColorSlider;
00076 class SoMFColor;
00077 class SbColor;
00078 class SoBase;
00079 class SoSeparator;
00080 class SoNode;
00081 class SoSFColor;
00082
00083
00084 typedef void SoXtMaterialEditorCB(void *userData, const SoMaterial *mtl);
00085
00087
00088
00089
00090
00091
00093
00156 class SoXtMaterialEditor : public SoXtComponent {
00157 public:
00162 enum UpdateFrequency {
00166 CONTINUOUS,
00170 AFTER_ACCEPT
00171 };
00172
00176 SoXtMaterialEditor(
00177 SoWidget parent = NULL,
00178 const char *name = NULL,
00179 SbBool buildInsideParent = TRUE);
00183 ~SoXtMaterialEditor();
00184
00189 void attach(SoMaterial *material, int index = 0);
00190
00194 void detach();
00198 SbBool isAttached() { return (material != NULL); }
00199
00205 inline void addMaterialChangedCallback(
00206 SoXtMaterialEditorCB *f,
00207 void *userData = NULL);
00211 inline void removeMaterialChangedCallback(
00212 SoXtMaterialEditorCB *f,
00213 void *userData = NULL);
00214
00218 void setUpdateFrequency(SoXtMaterialEditor::UpdateFrequency freq);
00222 SoXtMaterialEditor::UpdateFrequency getUpdateFrequency()
00223 { return updateFreq; }
00224
00225
00226
00227 virtual void show();
00228 virtual void hide();
00229
00233 void setMaterial(const SoMaterial &mtl);
00234
00238 const SoMaterial & getMaterial() const { return *localMaterial; }
00239
00240 private:
00241
00242
00243
00244
00245 SoEXTENDER
00246 SoXtMaterialEditor(
00247 SoWidget parent,
00248 const char *name,
00249 SbBool buildInsideParent,
00250 SbBool buildNow);
00251
00252 SoWidget buildWidget(SoWidget parent);
00253
00254
00255 virtual SbString getDefaultWidgetName() const;
00256 virtual SbString getDefaultTitle() const;
00257 virtual SbString getDefaultIconTitle() const;
00258
00259 private:
00260
00261 SoMaterial *material;
00262 SoMaterial *imat;
00263 int index;
00264 SoNodeSensor *sensor;
00265 SoCallbackList *callbackList;
00266 SoWidget acceptButton, diamondButtons[4], radioButtons[4];
00267 SoXtMaterialEditor::UpdateFrequency updateFreq;
00268
00269
00270 SoWidget mgrWidget;
00271 SoXtColorEditor *colorEditor;
00272 SoXtColorSlider *sliders[6];
00273 SbBool changedIt[6];
00274 SoXtMaterialList *materialList;
00275 SbBool ignoreCallback;
00276 SbBool openMaterialList;
00277 static void colorEditorCloseCB(void *, SoXtComponent *);
00278 static void materialListCloseCB(void *, SoXtComponent *);
00279
00280
00281 SoXtClipboard *clipboard;
00282
00283
00284 SoXtRenderArea *renderArea;
00285 SoMaterial *localMaterial;
00286 SoDirectionalLight *light0;
00287 SoDirectionalLight *light1;
00288 SoBaseColor *tileColor;
00289 SoSeparator *root;
00290
00291
00292 SoWidget *menuItemsList;
00293
00294 int32_t activeColor;
00295
00296
00297 void updateLocalComponents();
00298
00299
00300 void updateColorEditor(SbBool updateTitle = FALSE);
00301
00302
00303
00304 void updateColorSlider(SoXtColorSlider *, const float rgb[3]);
00305
00306
00307 void updateMaterialColor(
00308 SoMFColor *editMtlColor,
00309 SoMFColor *localMtlColor,
00310 const float *rgb,
00311 float intensity);
00312 void updateMaterialColor(
00313 SoSFColor *editMtlColor,
00314 SoMFColor *localMtlColor,
00315 const float *rgb,
00316 float intensity);
00317
00318
00319 void copyMaterial(SoMaterial *mat1, int index1,
00320 const SoMaterial *mat2, int index2);
00321
00322
00323
00324 void undoIgnoresIfChanged();
00325
00326
00327 static void pasteDone(void *userData, SoPathList *pathList);
00328
00329
00330 static void materialListCB(void *, const SoMaterial *);
00331 static void colorEditorCB(void *, const SbColor *);
00332 static void ambientSliderCB(void *, float);
00333 static void diffuseSliderCB(void *, float);
00334 static void specularSliderCB(void *, float);
00335 static void emissiveSliderCB(void *, float);
00336 static void shininessSliderCB(void *, float);
00337 static void transparencySliderCB(void *, float);
00338
00339
00340 static void menuPick(SoWidget, int, XmAnyCallbackStruct *);
00341 static void menuDisplay(SoWidget, SoXtMaterialEditor *, XtPointer);
00342 static void radioButtonPick(SoWidget, int, XtPointer);
00343 static void diamondButtonPick(SoWidget, int, XtPointer);
00344 static void acceptButtonCB(SoWidget, SoXtMaterialEditor *, XtPointer);
00345
00346
00347 static void sensorCB(void *, SoSensor *);
00348
00349
00350 SoWidget buildPulldownMenu(SoWidget parent);
00351 SoWidget buildControls(SoWidget parent);
00352 SoWidget buildSlidersForm(SoWidget parent);
00353
00354 static void visibilityChangeCB(void *pt, SbBool visible);
00355 void activate();
00356 void deactivate();
00357
00358
00359 void constructorCommon(SbBool buildNow);
00360
00361 };
00362
00363
00364
00365 void
00366 SoXtMaterialEditor::addMaterialChangedCallback(
00367 SoXtMaterialEditorCB *f,
00368 void *userData)
00369 { callbackList->addCallback((SoCallbackListCB *) f, userData); }
00370
00371 void
00372 SoXtMaterialEditor::removeMaterialChangedCallback(
00373 SoXtMaterialEditorCB *f,
00374 void *userData)
00375 { callbackList->removeCallback((SoCallbackListCB *) f, userData); }
00376
00377 #endif // _SO_XT_MATERIAL_EDITOR_
00378
00379 #endif // _WIN32
00380
00381
00382