Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
SoQtMaterialPalette.h
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2024 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : John Gambale (MMM yyyy)
22**=======================================================================*/
23
24
25#ifndef _SO_QT_MATERIAL_PALETTE_
26#define _SO_QT_MATERIAL_PALETTE_
27#include <Inventor/Qt/OivQtCompat.h>
28#include <Inventor/SbBasic.h>
29#include <Inventor/misc/SoCallbackList.h>
30#include <Inventor/Qt/SoQtComponent.h>
31
32#include <Inventor/STL/map>
33
34#include <QPointer>
35class QScrollBar;
36class QMenuBar;
37class QLabel;
38class QMenu;
39class QAction;
40class QLineEdit;
41
42class SoBaseColor;
43class SoQtColorEditor;
44class SoNodeSensor;
45class SoSensor;
47class SoMaterial;
48class SoPathList;
49class SoQtPlaneViewer;
50class SoSelection;
51class SoMFColor;
52class SbColor;
53class SoBase;
54class SoSeparator;
56class SoNode;
57class SoSelection;
58class SoPath;
59class SoEventCallback;
61class SoQtColorEditor;
63
64// callback function prototypes
66typedef void SoQtMaterialPaletteCB(void *userData, const SoMaterial *mtl);
67
68#ifndef _WIN32
69# include <sys/param.h>
70# if defined MAXPATHLEN
71# define MAX_PATH MAXPATHLEN
72# else
73# define MAX_PATH 256
74# endif
75#endif
76
78//
79// Class: SoQtMaterialPalette
80//
81// This editor lets you interactively edit a material
82//
84
86
87 Q_OBJECT
88
89 public:
90
92 QWidget *parent = NULL,
93 const char *name = NULL,
94 SbBool buildInsideParent = TRUE);
96
97 // attach the editor to the given node and edits the material
98 // of the given index (default is the first material)
99 void attach(SoMaterial *material, int index = 0);
100 void detach();
101 SbBool isAttached() { return (material != NULL); }
102
103 //
104 // Additional way of using the material editor, by registering a callback
105 // and setting the material. At the time dictated by setUpdateFrequency
106 // the callbacks will be called with the new material.
107 //
109 void *userData = NULL);
111 void *userData = NULL);
112
113 // Redefine these since there are multiple windows -
114 // the color editor, directional light editor, and this component
115 virtual void show();
116 virtual void hide();
117
118 // Set new values for the material editor, or get current values
119 void setMaterial(const SoMaterial &mtl);
120 const SoMaterial & getMaterial() const { return (*material); }
121 public:
123
125 static void staticLocation2EventCB(void *userData,
126 SoEventCallback *node);
128
129 // @UNICODE_WARNING
130 SoNONUNICODE void setPaletteBaseDir(const char * newBaseDir);
131
132 void setPaletteBaseDir( const SbString newBaseDir );
133
134 long getMaxDirCount() { return m_nMaxPathId; };
135 private:
136 void makePaletteMenuList(QMenuBar* menuBar);
137
138 // This constructor takes a boolean whether to build the widget now.
139 // Subclasses can pass FALSE, then call SoQtMaterialPalette::buildWidget()
140 // when they are ready for it to be built.
141 SoEXTENDER
143 QWidget *parent,
144 const char *name,
145 SbBool buildInsideParent,
146 SbBool buildNow);
147
148 // redefine these
149 virtual SbString getDefaultWidgetName() const;
150 virtual SbString getDefaultTitle() const;
151 virtual SbString getDefaultIconTitle() const;
152
153 private:
154#ifndef _WIN32
155 SbString materialDir;
156#endif
157
158 unsigned long nCurrEditId ;
159 QMenuBar* menubar;
160
161 // attach vars
162 SoMaterial *material; // material we are editing
163 int index; // material index number
164 SoCallbackList *callbackList;
165
166 // widgets to edit the material
167 QPointer<QWidget> mgrWidget;
168
169
170 SbBool ignoreCallback; // TRUE while callback should be ignored
171 SbBool openMaterialList;
172
173 //local palette vars
174 SoQtPlaneViewer *paletteRenderArea;
175 SoSelection *paletteRoot;
176 SoOrthographicCamera * m_pCamera;
177 static void staticSelectionCB(void *userData, SoPath *path);
178 void selectionCB(SoPath * path);
179
180 SoSelection *makePalette();
181 void resetPalette();
182 SoSeparator *makeRow(SoNode * SO_UNUSED_PARAM(aShape), long * SO_UNUSED_PARAM(nodeCnt), SbBool SO_UNUSED_PARAM(reset) = FALSE);
183 char currentMaterialPath[MAX_PATH];
184 SbString getMaterialDir();
185 void setMaterialDir(const SbString& dirPath);
186 SbBool saveMaterial(const SbString& fName);
187 void changeMaterialPath( QAction* id );
188
189 QPointer<QScrollBar> m_hScrollBar;
190 QPointer<QLabel> m_hStatusText;
191 QPointer<QLabel> m_hPaletteName;
192 int m_nMaxPathId;
193 void adjustVScrollInfo(long rows);
194
195 SoBoxHighlightRenderAction * m_pHighlightAction;
196
197
198 SoQtMaterialEditor *m_pMaterialEditor;
199 SoQtColorEditor *m_pColorEditor;
200 // keep the menu items around so we can update them before menu display
201 QWidget* *menuItemsList;
202
203 long activeColor; // field which color editor edits
204
205 // copies mat2 onto mat1
206 void copyMaterial(SoMaterial *mat1, int index1,
207 const SoMaterial *mat2, int index2);
208
209 // copy/paste support
210 //static void pasteDone(void *userData, SoPathList *pathList);
211
212 // Callback routines from components
213 static void materialListCB(void *, const SoMaterial *);
214 static void dialogCloseCB(void*, SoQtComponent*);
215 static void colorEditorCloseCB(void*, SoQtComponent*);
216 // Callback routines from Xt/Motif
217 void menuPick(QWidget*, int, void *);
218 void menuDisplay(QWidget*, SoQtMaterialPalette *, XtPointer);
219
220 // Build routines
221 QWidget* buildWidget(QWidget *parent);
222 QMenuBar* buildPulldownMenu(QWidget *parent);
223
224 // this is called by both constructors
225 void constructorCommon(SbBool buildNow);
226
227 //special qt stuffs
228 QPointer<QMenu> palette;
229 QAction* acPal;
230 std::map<int, QAction*> m_paletteMenuIdsMap;
231 QDialog * materialPath;
232 QLineEdit *line;
233
234 private Q_SLOTS:
235
236 void slot_color();
237 void slot_mat();
238 void slot_palette( QAction* id );
239 void slot_scroll_view(int);
240 void browsePalletteBaseDir();
241 void slot_ok();
242 void slot_browse();
243 void slot_help();
244 void slot_copy();
245
246};
247
248// Inline functions
249void
251 void *userData)
252{ callbackList->addCallback((SoCallbackListCB *) f, userData); }
253
254void
256 void *userData)
257{ callbackList->removeCallback((SoCallbackListCB *) f, userData); }
258
259#endif // _SO_QT_MATERIAL_PALETTE_
260
261
Color vector class.
Definition SbColor.h:82
Class for smart character strings.
Definition SbString.h:202
Node that defines an object's base color.
Definition SoBaseColor.h:91
Base class for all nodes, paths, and engines.
Definition SoBase.h:111
Manages a list of callbacks and associated data.
void addCallback(SoCallbackListCB *f, void *userData=NULL)
Adds a function to the list of callback functions.
void removeCallback(SoCallbackListCB *f, void *userData=NULL)
Removes a function from the list of callback functions.
Node representing a directional light source.
Node which invokes callbacks for events.
Multiple-value field containing any number of RGB colors stored as three floats.
Definition SoMFColor.h:98
Surface material definition node.
Definition SoMaterial.h:173
Abstract base class for all database nodes.
Definition SoNode.h:145
Sensor class that can be attached to Open Inventor nodes.
Orthographic camera node.
Path that points to a list of hierarchical nodes.
Definition SoPath.h:187
Maintains a list of pointers to paths.
Definition SoPathList.h:81
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Component that l...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Abstract base cl...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Component which ...
void location2Event(SoEventCallback *node)
virtual void hide()
This hides the component.
SoQtMaterialPalette(QWidget *parent=NULL, const char *name=NULL, SbBool buildInsideParent=TRUE)
void removeMaterialChangedCallback(SoQtMaterialPaletteCB *f, void *userData=NULL)
void setPaletteBaseDir(const SbString newBaseDir)
virtual void show()
This shows the component.
void addMaterialChangedCallback(SoQtMaterialPaletteCB *f, void *userData=NULL)
static void staticLocation2EventCB(void *userData, SoEventCallback *node)
void attach(SoMaterial *material, int index=0)
SoNONUNICODE void setPaletteBaseDir(const char *newBaseDir)
const SoMaterial & getMaterial() const
void SoQtMaterialPaletteCB(void *userData, const SoMaterial *mtl)
void setMaterial(const SoMaterial &mtl)
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Viewer component...
Manages a list of selected objects.
Abstract base class for Open Inventor sensors.
Definition SoSensor.h:100
Group node that saves and restores traversal state.
int SbBool
Boolean type.
Definition SbBase.h:87
void * XtPointer
Definition SoQtDef.h:122