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 #ifndef _SO_QT_MATERIAL_PALETTE_
00026 #define _SO_QT_MATERIAL_PALETTE_
00027 #include <Inventor/Qt/OivQtCompat.h>
00028 #include <Inventor/SbBasic.h>
00029 #include <Inventor/misc/SoCallbackList.h>
00030 #include <Inventor/Qt/SoQtComponent.h>
00031
00032 #include <Inventor/STL/map>
00033
00034 #include <QPointer>
00035 class QScrollBar;
00036 class QMenuBar;
00037 class QLabel;
00038 class QMenu;
00039 class QAction;
00040 class QLineEdit;
00041
00042 class SoBaseColor;
00043 class SoQtColorEditor;
00044 class SoNodeSensor;
00045 class SoSensor;
00046 class SoDirectionalLight;
00047 class SoMaterial;
00048 class SoPathList;
00049 class SoQtPlaneViewer;
00050 class SoSelection;
00051 class SoMFColor;
00052 class SbColor;
00053 class SoBase;
00054 class SoSeparator;
00055 class SoOrthographicCamera;
00056 class SoNode;
00057 class SoSelection;
00058 class SoPath;
00059 class SoEventCallback;
00060 class SoQtMaterialEditor;
00061 class SoQtColorEditor;
00062 class SoBoxHighlightRenderAction;
00063
00064
00065 typedef void SoQtMaterialPaletteCB(void *userData, const SoMaterial *mtl);
00066
00067 #ifndef _WIN32
00068 # include <sys/param.h>
00069 # if defined MAXPATHLEN
00070 # define MAX_PATH MAXPATHLEN
00071 # else
00072 # define MAX_PATH 256
00073 # endif
00074 #endif
00075
00077
00078
00079
00080
00081
00083
00084 class SoQtMaterialPalette : public SoQtComponent {
00085
00086 Q_OBJECT
00087
00088 public:
00089
00090 SoQtMaterialPalette(
00091 QWidget *parent = NULL,
00092 const char *name = NULL,
00093 SbBool buildInsideParent = TRUE);
00094 ~SoQtMaterialPalette();
00095
00096
00097
00098 void attach(SoMaterial *material, int index = 0);
00099 void detach();
00100 SbBool isAttached() { return (material != NULL); }
00101
00102
00103
00104
00105
00106
00107 inline void addMaterialChangedCallback(SoQtMaterialPaletteCB *f,
00108 void *userData = NULL);
00109 inline void removeMaterialChangedCallback(SoQtMaterialPaletteCB *f,
00110 void *userData = NULL);
00111
00112
00113
00114 virtual void show();
00115 virtual void hide();
00116
00117
00118 void setMaterial(const SoMaterial &mtl);
00119 const SoMaterial & getMaterial() const { return (*material); }
00120 public:
00121 void windowsPalette();
00122
00123 SbBool alwaysOnTop;
00124 static void staticLocation2EventCB(void *userData,
00125 SoEventCallback *node);
00126 void location2Event(SoEventCallback *node);
00127
00128
00129 SoNONUNICODE void setPaletteBaseDir(const char * newBaseDir);
00130
00131 void setPaletteBaseDir( const SbString newBaseDir );
00132
00133 long getMaxDirCount() { return m_nMaxPathId; };
00134 private:
00135 void makePaletteMenuList(QMenuBar* menuBar);
00136
00137
00138
00139
00140 SoEXTENDER
00141 SoQtMaterialPalette(
00142 QWidget *parent,
00143 const char *name,
00144 SbBool buildInsideParent,
00145 SbBool buildNow);
00146
00147
00148 virtual SbString getDefaultWidgetName() const;
00149 virtual SbString getDefaultTitle() const;
00150 virtual SbString getDefaultIconTitle() const;
00151
00152 private:
00153 #ifndef _WIN32
00154 SbString materialDir;
00155 #endif
00156
00157 unsigned long nCurrEditId ;
00158 QMenuBar* menubar;
00159
00160
00161 SoMaterial *material;
00162 int index;
00163 SoCallbackList *callbackList;
00164
00165
00166 QPointer<QWidget> mgrWidget;
00167
00168
00169 SbBool ignoreCallback;
00170 SbBool openMaterialList;
00171
00172
00173 SoQtPlaneViewer *paletteRenderArea;
00174 SoSelection *paletteRoot;
00175 SoOrthographicCamera * m_pCamera;
00176 static void staticSelectionCB(void *userData, SoPath *path);
00177 void selectionCB(SoPath * path);
00178
00179 SoSelection *makePalette();
00180 void resetPalette();
00181 SoSeparator *makeRow(SoNode * SO_UNUSED_PARAM(aShape), long * SO_UNUSED_PARAM(nodeCnt), SbBool SO_UNUSED_PARAM(reset) = FALSE);
00182 char currentMaterialPath[MAX_PATH];
00183 SbString getMaterialDir();
00184 void setMaterialDir(const SbString& dirPath);
00185 SbBool saveMaterial(const SbString& fName);
00186 void changeMaterialPath( QAction* id );
00187
00188 QPointer<QScrollBar> m_hScrollBar;
00189 QPointer<QLabel> m_hStatusText;
00190 QPointer<QLabel> m_hPaletteName;
00191 int m_nMaxPathId;
00192 void adjustVScrollInfo(long rows);
00193
00194 SoBoxHighlightRenderAction * m_pHighlightAction;
00195
00196
00197 SoQtMaterialEditor *m_pMaterialEditor;
00198 SoQtColorEditor *m_pColorEditor;
00199
00200 QWidget* *menuItemsList;
00201
00202 long activeColor;
00203
00204
00205 void copyMaterial(SoMaterial *mat1, int index1,
00206 const SoMaterial *mat2, int index2);
00207
00208
00209
00210
00211
00212 static void materialListCB(void *, const SoMaterial *);
00213 static void dialogCloseCB(void*, SoQtComponent*);
00214 static void colorEditorCloseCB(void*, SoQtComponent*);
00215
00216 void menuPick(QWidget*, int, void *);
00217 void menuDisplay(QWidget*, SoQtMaterialPalette *, XtPointer);
00218
00219
00220 QWidget* buildWidget(QWidget *parent);
00221 QMenuBar* buildPulldownMenu(QWidget *parent);
00222
00223
00224 void constructorCommon(SbBool buildNow);
00225
00226
00227 QPointer<QMenu> palette;
00228 QAction* acPal;
00229 std::map<int, QAction*> m_paletteMenuIdsMap;
00230 QDialog * materialPath;
00231 QLineEdit *line;
00232
00233 private Q_SLOTS:
00234
00235 void slot_color();
00236 void slot_mat();
00237 void slot_palette( QAction* id );
00238 void slot_scroll_view(int);
00239 void browsePalletteBaseDir();
00240 void slot_ok();
00241 void slot_browse();
00242 void slot_help();
00243 void slot_copy();
00244
00245 };
00246
00247
00248 void
00249 SoQtMaterialPalette::addMaterialChangedCallback(SoQtMaterialPaletteCB *f,
00250 void *userData)
00251 { callbackList->addCallback((SoCallbackListCB *) f, userData); }
00252
00253 void
00254 SoQtMaterialPalette::removeMaterialChangedCallback(SoQtMaterialPaletteCB *f,
00255 void *userData)
00256 { callbackList->removeCallback((SoCallbackListCB *) f, userData); }
00257
00258 #endif // _SO_QT_MATERIAL_PALETTE_
00259
00260
00261