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 _SO_XT_MATERIAL_PALETTE_GIZMO_H_
00059 #define _SO_XT_MATERIAL_PALETTE_GIZMO_H_
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/SbPList.h>
00066
00067 class SoMaterial;
00068 class SoSwitch;
00069 class SoXtRenderArea;
00070 class SoNode;
00071 class MySimpleMaterialEditor;
00072 class SoAction;
00073 class SoXtInputFocus;
00074 class SoXtClipboard;
00075 class SoTranslation;
00076 class SoPathList;
00077
00078 struct MaterialNameStruct;
00079
00080
00081 typedef void MyMaterialPaletteCB(void *userData, const SoMaterial *mtl);
00082
00084
00085
00086
00087
00089
00090
00091 class MyMaterialPalette : public SoXtComponent {
00092 public:
00093
00094 MyMaterialPalette(
00095 Widget parent = NULL,
00096 const char *name = NULL,
00097 SbBool buildInsideParent = TRUE,
00098 const char *dir = NULL);
00099 ~MyMaterialPalette();
00100
00101
00102
00103
00104
00105 void deselectCurrentItem();
00106
00107
00108
00109
00110
00111 void addCallback(
00112 MyMaterialPaletteCB *f,
00113 void *userData = NULL)
00114 { callbackList.addCallback((SoCallbackListCB *) f, userData);}
00115
00116
00117 void removeCallback(
00118 MyMaterialPaletteCB *f,
00119 void *userData = NULL)
00120 { callbackList.removeCallback((SoCallbackListCB *) f, userData); }
00121
00122
00123 virtual void show();
00124 virtual void hide();
00125
00126 protected:
00127
00128
00129
00130
00131 SoEXTENDER
00132 MyMaterialPalette(
00133 Widget parent,
00134 const char *name,
00135 SbBool buildInsideParent,
00136 const char *dir,
00137 SbBool buildNow);
00138
00139
00140 virtual const char * getDefaultWidgetName() const;
00141 virtual const char * getDefaultTitle() const;
00142 virtual const char * getDefaultIconTitle() const;
00143
00144 private:
00145 char *paletteDir;
00146 SoCallbackList callbackList;
00147 SoXtRenderArea *ra;
00148 Widget *widgetList;
00149 SbPList paletteList;
00150 MaterialNameStruct *mtlNames;
00151 int curPalette;
00152 SoSwitch *itemSwitch;
00153 int selectedItem, currentItem;
00154 MySimpleMaterialEditor *matEditor;
00155 SoXtInputFocus *focus;
00156 Time prevTime;
00157 SoTranslation *overlayTrans1, *overlayTrans2;
00158
00159 void createSceneGraph();
00160 void getPaletteNamesAndLoad();
00161 void loadPaletteItems();
00162 SoNode *getMaterialFromFile(char *file);
00163 SbBool handleEvent(XAnyEvent *);
00164 void updateMaterialName();
00165 void updateFileMenu();
00166 void updateEditMenu();
00167 void findCurrentItem(int x, int y);
00168 void updateOverlayFeedback();
00169 void updateWindowTitle();
00170 void createNewPalette(char *name);
00171 void savePalette();
00172 void savePaletteAs(char *name);
00173 void switchPalette();
00174
00175
00176 SbBool paletteChanged;
00177 int whatToDoNext, nextPalette;
00178 void createSaveDialog();
00179 void createDeleteDialog(char *title, char *str1, char *str2);
00180 void createPromptDialog(char *title, char *str);
00181 static void saveDialogCB(Widget, MyMaterialPalette *, XmAnyCallbackStruct *);
00182 static void promptDialogCB(Widget, MyMaterialPalette *, XmAnyCallbackStruct *);
00183 static void deleteDialogCB(Widget, MyMaterialPalette *, XmAnyCallbackStruct *);
00184
00185
00186 static SbBool raEventCB(void *, XAnyEvent *);
00187 static void matEditorCB(void *pt, MySimpleMaterialEditor *ed);
00188
00189
00190 static void menuCB(Widget, int, XmAnyCallbackStruct *);
00191 static void paletteMenuCB(Widget, int, void *);
00192
00193 protected:
00194
00195 Widget buildWidget(Widget parent);
00196 Widget buildMenu(Widget parent);
00197 void buildPaletteSubMenu();
00198 Widget buildPaletteMenuEntry(int id);
00199
00200 private:
00201
00202 SoXtClipboard *clipboard;
00203 void deleteCurrentMaterial();
00204 static void pasteDone(void *, SoPathList *);
00205
00206
00207 void constructorCommon(const char *dir, SbBool buildNow);
00208 };
00209
00210 #endif // _SO_XT_MATERIAL_PALETTE_GIZMO_H_