Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
SoQtMaterialEditor.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 : 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
29#include <Inventor/Qt/OivQtCompat.h>
30#include <Inventor/SbBasic.h>
31#include <Inventor/misc/SoCallbackList.h>
32#include <Inventor/Qt/SoQtComponent.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
61typedef void SoQtMaterialEditorCB(void *userData, const SoMaterial *mtl);
62
64//
65// Class: SoQtMaterialEditor
66//
67// This editor lets you interactively edit a material
68//
70
99
100 Q_OBJECT
101
102public:
117
121 SoQtMaterialEditor( QWidget *parent = qApp->activeWindow(),
122 const char *name = NULL,
123 SbBool buildInsideParent = TRUE );
128
133 void attach( SoMaterial *material, int index = 0 );
134
138 void detach();
139
143 SbBool isAttached() { return (material != NULL); }
144
150 inline void addMaterialChangedCallback(
152 void *userData = NULL);
158 void *userData = NULL);
159
164
170
171 // Redefine these since there are multiple windows -
172 // the color editor, directional light editor, and this component
173 virtual void show();
174 virtual void hide();
175
179 void setMaterial(const SoMaterial &mtl);
180
184 const SoMaterial & getMaterial() const { return *localMaterial; }
185
190
195
196 private:
197
198
199 // This constructor takes a boolean whether to build the widget now.
200 // Subclasses can pass FALSE, then call SoQtMaterialEditor::buildWidget()
201 // when they are ready for it to be built.
202 SoEXTENDER
204 QWidget *parent,
205 const char *name,
206 SbBool buildInsideParent,
207 SbBool buildNow);
208
209 // redefine these
210 virtual SbString getDefaultWidgetName() const;
211 virtual SbString getDefaultTitle() const;
212 virtual SbString getDefaultIconTitle() const;
213
214 virtual bool eventFilter(QObject * object,QEvent *event);
215
216 private:
217 unsigned long nCurrEditId ;
218 //unsigned long diamondButtonId[4];
219 //unsigned long radioButtonId[4];
220 QMenuBar *menubar ;
221
222
223 // attach vars
224 //SoMaterial *material; // material we are editing
225 SoNode *material; // material we are editing
226 SoMaterial *imat; // ditto
227 int index; // material index number
228 SoNodeSensor *sensor;
229 SoCallbackList *callbackList;
230 QPointer<QRadioButton> diamondButtons[4], radioButtons[4];
231 QPointer<SoQtButton> acceptButton;
233
234 // widgets to edit the material
235 QPointer<QWidget> mgrWidget; // topmost widget
236 SoQtColorEditor *colorEditor;
237 SoQtColorSlider *sliders[6];
238 SbBool changedIt[6];
239#ifdef NOTYET
240 SoQtMaterialList *materialList;
241#endif
242 SbBool ignoreCallback; // TRUE while callback should be ignored
243 SbBool openMaterialList;
244
245 // copy/paste support
246 //SoQtClipboard *clipboard;
247
248 // local scene vars
249 SoQtRenderArea *renderArea;
250 SoMaterial *localMaterial; // local copy of the material
251 SoDirectionalLight *light0;
252 SoDirectionalLight *light1;
253 SoBaseColor *tileColor;
254 SoSeparator *root;
255
256 long activeColor; // field which color editor edits
257
258 // update the sliders/colorEditor based on the local material
259 void updateLocalComponents();
260
261 // update the colorEditor based on the activeColor flag
262 void updateColorEditor(SbBool updateTitle = FALSE);
263
264 // update a color slider (amb/diff/spec/emiss) based of a material color
265 // (split the base color from the intensity).
266 void updateColorSlider(SoQtColorSlider *, const float rgb[3]);
267
268 // update a material field when a color slider changes.
269 void updateMaterialColor(
270 SoMFColor *editMtlColor,
271 SoMFColor *localMtlColor,
272 const float *rgb,
273 float intensity);
274 void updateMaterialColor(
275 SoSFColor *editMtlColor,
276 SoMFColor *localMtlColor,
277 const float *rgb,
278 float intensity);
279
280 // copies mat2 onto mat1
281 //void copyMaterial(SoMaterial *mat1, int index1,
282 // const SoMaterial *mat2, int index2);
283 void copyMaterial(SoNode *mat1, int index1,
284 const SoNode *mat2, int index2);
285
286 // For each of the 6 sliders (or sets of sliders) sets the ignore flag of
287 // the material node being editted to FALSE if it has been changed.
288 void undoIgnoresIfChanged();
289
290 // copy/paste support
291 //static void pasteDone(void *userData, SoPathList *pathList);
292
293 // Callback routines from components
294 static void materialListCB(void *, const SoMaterial *);
295 static void colorEditorCB(void *, const SbColor *);
296 static void ambientSliderCB(void *, float);
297 static void diffuseSliderCB(void *, float);
298 static void specularSliderCB(void *, float);
299 static void emissiveSliderCB(void *, float);
300 static void shininessSliderCB(void *, float);
301 static void transparencySliderCB(void *, float);
302 static void paletteEditorClosedCB(void*, SoQtComponent*);
303 static void colorEditorCloseCB(void* userData, SoQtComponent*);
304 static void dialogCloseCB(void* userData, SoQtComponent*);
305
306 // Callback routines from Xt/Motif
307 void menuPick(int id);
308 void menuDisplay(QWidget*, SoQtMaterialEditor *, XtPointer);
309 void radioButtonPick(QWidget*, int, XtPointer);
310 void diamondButtonPick(QWidget*, int, XtPointer);
311
312 // Sensor callbacks
313 static void sensorCB(void *, SoSensor *);
314
315 // Build routines
316 QWidget* buildWidget(QWidget* parent);
317 QMenuBar* buildPulldownMenu(QWidget* parent);
318 QWidget* buildControls(QWidget* parent);
319 QWidget* buildSlidersForm(QWidget* parent);
320
321 void activate(); // connects the sensor
322 void deactivate(); // disconnects the sensor
323
324 // this is called by both constructors
325 void constructorCommon(SbBool buildNow);
326
327 QPointer<QMenu> edit;
328 QAction* acCon, *acMan;
329
330 private Q_SLOTS:
331
332 void visibilityChangeCB(SbBool visible);
333
334 void slot_mat_pal();
335 void slot_continuous();
336 void slot_manual();
337
338 void slot_radioButton0();
339 void slot_radioButton1();
340 void slot_radioButton2();
341 void slot_radioButton3();
342
343 void slot_diamondButton0();
344 void slot_diamondButton1();
345 void slot_diamondButton2();
346 void slot_diamondButton3();
347
348 void acceptButtonCB();
349
350 void slot_help();
351
352};
353
354// Inline functions
355void
357 SoQtMaterialEditorCB *f,
358 void *userData)
359{ callbackList->addCallback((SoCallbackListCB *) f, userData); }
360
361void
363 SoQtMaterialEditorCB *f,
364 void *userData)
365{ callbackList->removeCallback((SoCallbackListCB *) f, userData); }
366
367
368#endif // _SO_QT_MATERIAL_EDITOR_
369
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 SoQtMaterialEditorCB(void *userData, const SoMaterial *mtl)
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:100
Group node that saves and restores traversal state.
int SbBool
Boolean type.
Definition SbBase.h:87
void * XtPointer
Definition SoQtDef.h:122