Open Inventor Release 2024.1.0
 
Loading...
Searching...
No Matches
SoQtMaterialEditor.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 : Alain Dumesny (MMM yyyy)
22** Modified by : David Mott (MMM yyyy)
23**=======================================================================*/
24
25
26#ifndef _SO_QT_MATERIAL_EDITOR_
27#define _SO_QT_MATERIAL_EDITOR_
28
30#include <Inventor/SbBasic.h>
33
34#include <QPointer>
35class QMenu;
36class QAction;
37class SoBaseColor;
38class SoQtColorEditor;
39class QLabel;
40class QRadioButton;
41class QMenuBar;
42class SoNodeSensor;
43class SoSensor;
45class SoMaterial;
46class SoPathList;
47class SoQtRenderArea;
48class SoSelection;
49class SoQtColorSlider;
50class SoMFColor;
51class SbColor;
52class SoBase;
53class SoSeparator;
55
56class SoNode; //ditto
57class SoSFColor; //ditto
58
59// callback function prototypes
60typedef void SoQtMaterialEditorCB(void *userData, const SoMaterial *mtl);
61
63//
64// Class: SoQtMaterialEditor
65//
66// This editor lets you interactively edit a material
67//
69
98
99 Q_OBJECT
100
101public:
116
120 SoQtMaterialEditor( QWidget *parent = qApp->activeWindow(),
121 const char *name = NULL,
122 SbBool buildInsideParent = TRUE );
127
132 void attach( SoMaterial *material, int index = 0 );
133
137 void detach();
138
142 SbBool isAttached() { return (material != NULL); }
143
149 inline void addMaterialChangedCallback(
151 void *userData = NULL);
157 void *userData = NULL);
158
163
169
170 // Redefine these since there are multiple windows -
171 // the color editor, directional light editor, and this component
172 virtual void show();
173 virtual void hide();
174
178 void setMaterial(const SoMaterial &mtl);
179
183 const SoMaterial & getMaterial() const { return *localMaterial; }
184
189
194
195 private:
196
197
198 // This constructor takes a boolean whether to build the widget now.
199 // Subclasses can pass FALSE, then call SoQtMaterialEditor::buildWidget()
200 // when they are ready for it to be built.
203 QWidget *parent,
204 const char *name,
205 SbBool buildInsideParent,
206 SbBool buildNow);
207
208 // redefine these
209 virtual SbString getDefaultWidgetName() const;
210 virtual SbString getDefaultTitle() const;
211 virtual SbString getDefaultIconTitle() const;
212
213 virtual bool eventFilter(QObject * object,QEvent *event);
214
215 private:
216 unsigned long nCurrEditId ;
217 //unsigned long diamondButtonId[4];
218 //unsigned long radioButtonId[4];
219 QMenuBar *menubar ;
220
221
222 // attach vars
223 //SoMaterial *material; // material we are editing
224 SoNode *material; // material we are editing
225 SoMaterial *imat; // ditto
226 int index; // material index number
227 SoNodeSensor *sensor;
228 SoCallbackList *callbackList;
229 QPointer<QRadioButton> diamondButtons[4], radioButtons[4];
230 QPointer<SoQtButton> acceptButton;
232
233 // widgets to edit the material
234 QPointer<QWidget> mgrWidget; // topmost widget
235 SoQtColorEditor *colorEditor;
236 SoQtColorSlider *sliders[6];
237 SbBool changedIt[6];
238#ifdef NOTYET
239 SoQtMaterialList *materialList;
240#endif
241 SbBool ignoreCallback; // TRUE while callback should be ignored
242 SbBool openMaterialList;
243
244 // copy/paste support
245 //SoQtClipboard *clipboard;
246
247 // local scene vars
248 SoQtRenderArea *renderArea;
249 SoMaterial *localMaterial; // local copy of the material
250 SoDirectionalLight *light0;
251 SoDirectionalLight *light1;
252 SoBaseColor *tileColor;
253 SoSeparator *root;
254
255 long activeColor; // field which color editor edits
256
257 // update the sliders/colorEditor based on the local material
258 void updateLocalComponents();
259
260 // update the colorEditor based on the activeColor flag
261 void updateColorEditor(SbBool updateTitle = FALSE);
262
263 // update a color slider (amb/diff/spec/emiss) based of a material color
264 // (split the base color from the intensity).
265 void updateColorSlider(SoQtColorSlider *, const float rgb[3]);
266
267 // update a material field when a color slider changes.
268 void updateMaterialColor(
269 SoMFColor *editMtlColor,
270 SoMFColor *localMtlColor,
271 const float *rgb,
272 float intensity);
273 void updateMaterialColor(
274 SoSFColor *editMtlColor,
275 SoMFColor *localMtlColor,
276 const float *rgb,
277 float intensity);
278
279 // copies mat2 onto mat1
280 //void copyMaterial(SoMaterial *mat1, int index1,
281 // const SoMaterial *mat2, int index2);
282 void copyMaterial(SoNode *mat1, int index1,
283 const SoNode *mat2, int index2);
284
285 // For each of the 6 sliders (or sets of sliders) sets the ignore flag of
286 // the material node being editted to FALSE if it has been changed.
287 void undoIgnoresIfChanged();
288
289 // copy/paste support
290 //static void pasteDone(void *userData, SoPathList *pathList);
291
292 // Callback routines from components
293 static void materialListCB(void *, const SoMaterial *);
294 static void colorEditorCB(void *, const SbColor *);
295 static void ambientSliderCB(void *, float);
296 static void diffuseSliderCB(void *, float);
297 static void specularSliderCB(void *, float);
298 static void emissiveSliderCB(void *, float);
299 static void shininessSliderCB(void *, float);
300 static void transparencySliderCB(void *, float);
301 static void paletteEditorClosedCB(void*, SoQtComponent*);
302 static void colorEditorCloseCB(void* userData, SoQtComponent*);
303 static void dialogCloseCB(void* userData, SoQtComponent*);
304
305 // Callback routines from Xt/Motif
306 void menuPick(int id);
307 void menuDisplay(QWidget*, SoQtMaterialEditor *, XtPointer);
308 void radioButtonPick(QWidget*, int, XtPointer);
309 void diamondButtonPick(QWidget*, int, XtPointer);
310
311 // Sensor callbacks
312 static void sensorCB(void *, SoSensor *);
313
314 // Build routines
315 QWidget* buildWidget(QWidget* parent);
316 QMenuBar* buildPulldownMenu(QWidget* parent);
317 QWidget* buildControls(QWidget* parent);
318 QWidget* buildSlidersForm(QWidget* parent);
319
320 void activate(); // connects the sensor
321 void deactivate(); // disconnects the sensor
322
323 // this is called by both constructors
324 void constructorCommon(SbBool buildNow);
325
326 QPointer<QMenu> edit;
327 QAction* acCon, *acMan;
328
329 private Q_SLOTS:
330
331 void visibilityChangeCB(SbBool visible);
332
333 void slot_mat_pal();
334 void slot_continuous();
335 void slot_manual();
336
337 void slot_radioButton0();
338 void slot_radioButton1();
339 void slot_radioButton2();
340 void slot_radioButton3();
341
342 void slot_diamondButton0();
343 void slot_diamondButton1();
344 void slot_diamondButton2();
345 void slot_diamondButton3();
346
347 void acceptButtonCB();
348
349 void slot_help();
350
351};
352
353// Inline functions
354void
357 void *userData)
358{ callbackList->addCallback((SoCallbackListCB *) f, userData); }
359
360void
363 void *userData)
364{ callbackList->removeCallback((SoCallbackListCB *) f, userData); }
365
366
367#endif // _SO_QT_MATERIAL_EDITOR_
368
#define SoEXTENDER
#define TRUE
Possible value of SbBool.
Definition SbBase.h:77
#define FALSE
Possible value of SbBool.
Definition SbBase.h:75
SoQtColorSlider(QWidget *parent=NULL, const char *name=NULL, SbBool buildInsideParent=TRUE, Type type=INTENSITY_SLIDER)
void * XtPointer
Definition SoQtDef.h:118
void SoQtMaterialEditorCB(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.
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.
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 ...
const SoMaterial & getMaterial() const
Gets the current material value.
void removeMaterialChangedCallback(SoQtMaterialEditorCB *f, void *userData=NULL)
Removes the material changed callback.
void setUpdateFrequency(SoQtMaterialEditor::UpdateFrequency freq)
Sets the update frequency.
SoQtMaterialEditor(QWidget *parent=qApp->activeWindow(), const char *name=NULL, SbBool buildInsideParent=TRUE)
Constructor.
void attach(SoMaterial *material, int index=0)
Attaches the editor to a material node and edits the material of the given index.
virtual void hide()
This hides the component.
virtual void show()
This shows the component.
SoQtMaterialPalette * m_pMaterialPalette
Pointer to a material palette editor.
void detach()
Detaches the editor from the material node.
SbBool alwaysOnTop
Boolean indicating if the editor should be always on top of the other windows.
void setMaterial(const SoMaterial &mtl)
Sets a new material value.
~SoQtMaterialEditor()
Destructor.
SoQtMaterialEditor::UpdateFrequency getUpdateFrequency()
Gets the update frequency.
UpdateFrequency
Update frequency.
@ CONTINUOUS
Send updates with every mouse motion.
@ AFTER_ACCEPT
Only send updates after user hits accept button.
SbBool isAttached()
Returns TRUE if the editor is attached.
void addMaterialChangedCallback(SoQtMaterialEditorCB *f, void *userData=NULL)
Additional way of using the material editor, by registering a callback which will be called whenever ...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Component for re...
Field containing an RGB color.
Definition SoSFColor.h:82
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)