Open Inventor Release 2024.1.0
 
Loading...
Searching...
No Matches
SoQtMaterialPalette.h
Go to the documentation of this file.
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-2017 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_
28#include <Inventor/SbBasic.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
65typedef void SoQtMaterialPaletteCB(void *userData, const SoMaterial *mtl);
66
67#ifndef _WIN32
68# include <sys/param.h>
69# if defined MAXPATHLEN
70# define MAX_PATH MAXPATHLEN
71# else
72# define MAX_PATH 256
73# endif
74#endif
75
77//
78// Class: SoQtMaterialPalette
79//
80// This editor lets you interactively edit a material
81//
83
85
86 Q_OBJECT
87
88 public:
89
91 QWidget *parent = NULL,
92 const char *name = NULL,
93 SbBool buildInsideParent = TRUE);
95
96 // attach the editor to the given node and edits the material
97 // of the given index (default is the first material)
98 void attach(SoMaterial *material, int index = 0);
99 void detach();
100 SbBool isAttached() { return (material != NULL); }
101
102 //
103 // Additional way of using the material editor, by registering a callback
104 // and setting the material. At the time dictated by setUpdateFrequency
105 // the callbacks will be called with the new material.
106 //
108 void *userData = NULL);
110 void *userData = NULL);
111
112 // Redefine these since there are multiple windows -
113 // the color editor, directional light editor, and this component
114 virtual void show();
115 virtual void hide();
116
117 // Set new values for the material editor, or get current values
118 void setMaterial(const SoMaterial &mtl);
119 const SoMaterial & getMaterial() const { return (*material); }
120 public:
122
124 static void staticLocation2EventCB(void *userData,
125 SoEventCallback *node);
127
128 // @UNICODE_WARNING
129 SoNONUNICODE void setPaletteBaseDir(const char * newBaseDir);
130
131 void setPaletteBaseDir( const SbString newBaseDir );
132
133 long getMaxDirCount() { return m_nMaxPathId; };
134 private:
135 void makePaletteMenuList(QMenuBar* menuBar);
136
137 // This constructor takes a boolean whether to build the widget now.
138 // Subclasses can pass FALSE, then call SoQtMaterialPalette::buildWidget()
139 // when they are ready for it to be built.
142 QWidget *parent,
143 const char *name,
144 SbBool buildInsideParent,
145 SbBool buildNow);
146
147 // redefine these
148 virtual SbString getDefaultWidgetName() const;
149 virtual SbString getDefaultTitle() const;
150 virtual SbString getDefaultIconTitle() const;
151
152 private:
153#ifndef _WIN32
154 SbString materialDir;
155#endif
156
157 unsigned long nCurrEditId ;
158 QMenuBar* menubar;
159
160 // attach vars
161 SoMaterial *material; // material we are editing
162 int index; // material index number
163 SoCallbackList *callbackList;
164
165 // widgets to edit the material
166 QPointer<QWidget> mgrWidget;
167
168
169 SbBool ignoreCallback; // TRUE while callback should be ignored
170 SbBool openMaterialList;
171
172 //local palette vars
173 SoQtPlaneViewer *paletteRenderArea;
174 SoSelection *paletteRoot;
175 SoOrthographicCamera * m_pCamera;
176 static void staticSelectionCB(void *userData, SoPath *path);
177 void selectionCB(SoPath * path);
178
179 SoSelection *makePalette();
180 void resetPalette();
181 SoSeparator *makeRow(SoNode * SO_UNUSED_PARAM(aShape), long * SO_UNUSED_PARAM(nodeCnt), SbBool SO_UNUSED_PARAM(reset) = FALSE);
182 char currentMaterialPath[MAX_PATH];
183 SbString getMaterialDir();
184 void setMaterialDir(const SbString& dirPath);
185 SbBool saveMaterial(const SbString& fName);
186 void changeMaterialPath( QAction* id );
187
188 QPointer<QScrollBar> m_hScrollBar;
189 QPointer<QLabel> m_hStatusText;
190 QPointer<QLabel> m_hPaletteName;
191 int m_nMaxPathId;
192 void adjustVScrollInfo(long rows);
193
194 SoBoxHighlightRenderAction * m_pHighlightAction;
195
196
197 SoQtMaterialEditor *m_pMaterialEditor;
198 SoQtColorEditor *m_pColorEditor;
199 // keep the menu items around so we can update them before menu display
200 QWidget* *menuItemsList;
201
202 long activeColor; // field which color editor edits
203
204 // copies mat2 onto mat1
205 void copyMaterial(SoMaterial *mat1, int index1,
206 const SoMaterial *mat2, int index2);
207
208 // copy/paste support
209 //static void pasteDone(void *userData, SoPathList *pathList);
210
211 // Callback routines from components
212 static void materialListCB(void *, const SoMaterial *);
213 static void dialogCloseCB(void*, SoQtComponent*);
214 static void colorEditorCloseCB(void*, SoQtComponent*);
215 // Callback routines from Xt/Motif
216 void menuPick(QWidget*, int, void *);
217 void menuDisplay(QWidget*, SoQtMaterialPalette *, XtPointer);
218
219 // Build routines
220 QWidget* buildWidget(QWidget *parent);
221 QMenuBar* buildPulldownMenu(QWidget *parent);
222
223 // this is called by both constructors
224 void constructorCommon(SbBool buildNow);
225
226 //special qt stuffs
227 QPointer<QMenu> palette;
228 QAction* acPal;
229 std::map<int, QAction*> m_paletteMenuIdsMap;
230 QDialog * materialPath;
231 QLineEdit *line;
232
233 private Q_SLOTS:
234
235 void slot_color();
236 void slot_mat();
237 void slot_palette( QAction* id );
238 void slot_scroll_view(int);
239 void browsePalletteBaseDir();
240 void slot_ok();
241 void slot_browse();
242 void slot_help();
243 void slot_copy();
244
245};
246
247// Inline functions
248void
250 void *userData)
251{ callbackList->addCallback((SoCallbackListCB *) f, userData); }
252
253void
257
258#endif // _SO_QT_MATERIAL_PALETTE_
259
260
#define SoEXTENDER
#define TRUE
Possible value of SbBool.
Definition SbBase.h:77
#define FALSE
Possible value of SbBool.
Definition SbBase.h:75
void * XtPointer
Definition SoQtDef.h:118
#define MAX_PATH
void SoQtMaterialPaletteCB(void *userData, const SoMaterial *mtl)
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 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:97
Group node that saves and restores traversal state.
int SbBool
Boolean type.
Definition SbBase.h:87
void SoCallbackListCB(void *userData, void *callbackData)
void reset()