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
00051
00052
00053
00054
00055
00056
00057
00058 #ifndef _MY_MATERIAL_EDITOR_
00059 #define _MY_MATERIAL_EDITOR_
00060
00061 #include <X11/Intrinsic.h>
00062 #include <Xm/Xm.h>
00063 #include <Inventor/Xt/SoXtComponent.h>
00064 #include <Inventor/misc/SoCallbackList.h>
00065 #include <Inventor/SbColor.h>
00066
00067 class SoMaterial;
00068 class SoXtRenderArea;
00069 class MyColorWheel;
00070 class MyColorSlider;
00071 class SoXtClipboard;
00072 class SoPathList;
00073 class MySimpleMaterialEditor;
00074
00075
00076
00077 typedef void MySimpleMaterialEditorCB(void *userData,
00078 MySimpleMaterialEditor *editor);
00079
00081
00082
00083
00084
00085
00087
00088
00089 class MySimpleMaterialEditor : public SoXtComponent {
00090 public:
00091 MySimpleMaterialEditor(
00092 Widget parent = NULL,
00093 const char *name = NULL,
00094 SbBool buildInsideParent = TRUE,
00095 SbBool showMaterialName = FALSE);
00096 ~MySimpleMaterialEditor();
00097
00098
00099
00100 void setMaterial(const SoMaterial *mtl);
00101
00102 const SoMaterial * getMaterial() const { return material; }
00103
00104
00105
00106
00107
00108
00109
00110 SbBool isMaterialNameVisible() { return nameVisible; }
00111
00112
00113
00114
00115 void setMaterialName(const char *name);
00116
00117 const char * getMaterialName() const { return materialName; }
00118
00119
00120
00121
00122 void addCallback(
00123 MySimpleMaterialEditorCB *f,
00124 void *userData = NULL)
00125 { callbackList.addCallback((SoCallbackListCB *) f, userData);}
00126
00127
00128 void removeCallback(
00129 MySimpleMaterialEditorCB *f,
00130 void *userData = NULL)
00131 { callbackList.removeCallback((SoCallbackListCB *) f, userData); }
00132
00133 protected:
00134
00135
00136
00137
00138 SoEXTENDER
00139 MySimpleMaterialEditor(
00140 Widget parent,
00141 const char *name,
00142 SbBool buildInsideParent,
00143 SbBool showMaterialName,
00144 SbBool buildNow);
00145
00146
00147 virtual const char * getDefaultWidgetName() const;
00148 virtual const char * getDefaultTitle() const;
00149 virtual const char * getDefaultIconTitle() const;
00150
00151
00152 Widget buildWidget(Widget parent);
00153
00154 private:
00155 SoCallbackList callbackList;
00156 SbBool ignoreCallback;
00157 SbBool fieldChanged;
00158 SoMaterial *material, *savedMaterial;
00159 char *materialName, *savedMaterialName;
00160 SoXtRenderArea *renderArea;
00161 MyColorWheel *colWheel;
00162 MyColorSlider *colSlider;
00163 Widget sldWidgets[3], nameField;
00164 float metalness, savedMetalness, smoothness, savedSmoothness;
00165 SbColor baseColor, savedBaseColor;
00166 SoXtClipboard *clipboard;
00167 SbBool nameVisible;
00168
00169 void copyMaterial(SoMaterial *mat1, const SoMaterial *mat2);
00170 void updateMaterial();
00171 void calculateMaterialFactors();
00172 void updateMaterialUI();
00173 void saveMaterialFactors();
00174
00175 static void colWheelCB(void *, const float hsv[3]);
00176 static void colSliderCB(void *, float v);
00177 static void nameFieldCB(Widget, MySimpleMaterialEditor *, void *);
00178 static void fieldChangedCB(Widget, MySimpleMaterialEditor *, void *);
00179 static void sldWidgetsCB(Widget, MySimpleMaterialEditor *, void *);
00180 static void applyCB(Widget, MySimpleMaterialEditor *, void *);
00181 static void resetCB(Widget, MySimpleMaterialEditor *, void *);
00182 static void copyCB(Widget, MySimpleMaterialEditor *, XmAnyCallbackStruct *);
00183 static void pasteCB(Widget, MySimpleMaterialEditor *, XmAnyCallbackStruct *);
00184 static void pasteDone(void *, SoPathList *);
00185
00186
00187 void constructorCommon(SbBool showMaterialName, SbBool buildNow);
00188 };
00189
00190
00191 #endif // _MY_MATERIAL_EDITOR_