Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
SoWinMaterialEditor.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 : VSG (MMM YYYY)
22**=======================================================================*/
23
24#ifndef _SO_WIN_MATERIAL_EDITOR_
25#define _SO_WIN_MATERIAL_EDITOR_
26
27#include <Inventor/Win/SoWinBeginStrict.h>
28#include <Inventor/sys/port.h>
29#include <Inventor/SbBasic.h>
30#include <Inventor/misc/SoCallbackList.h>
31#include <Inventor/Win/SoWinComponent.h>
32
33class SoBaseColor;
34class SoWinClipboard;
36class SoNodeSensor;
37class SoSensor;
39class SoMaterial;
40#ifdef NOTYET
41class SoWinMaterialList;
42#endif
43class SoPathList;
44class SoWinRenderArea;
45class SoSelection;
46class SoWinColorSlider;
47class SoMFColor;
48class SbColor;
49class SoBase;
50class SoSeparator;
51class SoWinMaterialPalette;
52
53class SoNode; //ditto
54class SoSFColor; //ditto
55
56// callback function prototypes
62typedef void SoWinMaterialEditorCB(void *userData, const SoMaterial *mtl);
63
65//
66// Class: SoWinMaterialEditor
67//
68// This editor lets you interactively edit a material
69//
71
100 public:
115
120 SoWidget parent = NULL,
121 const char *name = NULL,
122 SbBool buildInsideParent = TRUE);
127
132 void attach( SoMaterial *material, int index = 0 );
133
137 void detach();
141 SbBool isAttached() { return (material != NULL); }
142
149 inline void addMaterialChangedCallback(
151 void *userData = NULL);
158 void *userData = NULL);
159
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);
182 const SoMaterial & getMaterial() const { return *localMaterial; }
183
185 SoWinMaterialPalette * m_pMaterialPalette;
186 private:
187
188
189 // This constructor takes a boolean whether to build the widget now.
190 // Subclasses can pass FALSE, then call SoWinMaterialEditor::buildWidget()
191 // when they are ready for it to be built.
192 SoEXTENDER
194 SoWidget parent,
195 const char *name,
196 SbBool buildInsideParent,
197 SbBool buildNow);
198
199 // redefine these
200 virtual SbString getDefaultWidgetName() const;
201 virtual SbString getDefaultTitle() const;
202 virtual SbString getDefaultIconTitle() const;
203
204 private:
205 unsigned long nCurrEditId ;
206 unsigned long diamondButtonId[4] ;
207 unsigned long radioButtonId[4] ;
208 HMENU menubar ;
209
210 void layoutAccept() ;
211
212 static WBOOL CALLBACK mgrDlgProc( Hwnd hdlg, UINT message,
213 WPARAM wParam, LPARAM lParam );
214 static void onCommand(
215 Hwnd hdlg,
216 int id,
217 Hwnd hCtrl,
218 UINT codeNotify ) ;
219
220 void handleEdit(
221 int nSlider,
222 Hwnd hEdit,
223 UINT codeNotify) ;
224
225 void handleButtons(SoWinMaterialEditor *p,
226 SoWidget hCtrl,
227 int id,
228 UINT codeNotify) ;
229
230 void handleMenu(SoWinMaterialEditor *p,
231 int id ) ;
232
233 void initPlacement() ;
234
235
236 // attach vars
237 //SoMaterial *material; // material we are editing
238 SoNode *material; // material we are editing
239 SoMaterial *imat; // ditto
240 int index; // material index number
241 SoNodeSensor *sensor;
242 SoCallbackList *callbackList;
243 SoWidget acceptButton, diamondButtons[4], radioButtons[4];
245
246 // widgets to edit the material
247 SoWidget mgrWidget; // topmost widget
248 SoWinColorEditor *colorEditor;
249 SoWinColorSlider *sliders[6];
250 SbBool changedIt[6];
251#ifdef NOTYET
252 SoWinMaterialList *materialList;
253#endif
254 SbBool ignoreCallback; // TRUE while callback should be ignored
255 SbBool openMaterialList;
256 static void colorEditorCloseCB(void *, SoWinComponent *);
257 static void materialListCloseCB(void *, SoWinComponent *);
258
259 // copy/paste support
260 SoWinClipboard *clipboard;
261
262 // local scene vars
263 SoWinRenderArea *renderArea;
264 SoMaterial *localMaterial; // local copy of the material
265
266 SoDirectionalLight *light0;
267 SoDirectionalLight *light1;
268 SoBaseColor *tileColor;
269 SoSeparator *root;
270
271 long activeColor; // field which color editor edits
272
273 // update the sliders/colorEditor based on the local material
274 void updateLocalComponents();
275
276 // update the colorEditor based on the activeColor flag
277 void updateColorEditor(SbBool updateTitle = FALSE);
278
279 // update a color slider (amb/diff/spec/emiss) based of a material color
280 // (split the base color from the intensity).
281 void updateColorSlider(SoWinColorSlider *, const float rgb[3]);
282
283 // update a material field when a color slider changes.
284 void updateMaterialColor(
285 SoMFColor *editMtlColor,
286 SoMFColor *localMtlColor,
287 const float *rgb,
288 float intensity);
289 void updateMaterialColor(
290 SoSFColor *editMtlColor,
291 SoMFColor *localMtlColor,
292 const float *rgb,
293 float intensity);
294
295 // copies mat2 onto mat1
296 //void copyMaterial(SoMaterial *mat1, int index1,
297 // const SoMaterial *mat2, int index2);
298 void copyMaterial(SoNode *mat1, int index1,
299 const SoNode *mat2, int index2);
300
301 // For each of the 6 sliders (or sets of sliders) sets the ignore flag of
302 // the material node being editted to FALSE if it has been changed.
303 void undoIgnoresIfChanged();
304
305 // copy/paste support
306 static void pasteDone(void *userData, SoPathList *pathList);
307
308 // Callback routines from components
309 static void materialListCB(void *, const SoMaterial *);
310 static void colorEditorCB(void *, const SbColor *);
311 static void ambientSliderCB(void *, float);
312 static void diffuseSliderCB(void *, float);
313 static void specularSliderCB(void *, float);
314 static void emissiveSliderCB(void *, float);
315 static void shininessSliderCB(void *, float);
316 static void transparencySliderCB(void *, float);
317
318 // Callback routines from Xt/Motif
319 void menuPick(SoWidget, int, XmAnyCallbackStruct *);
320 void menuDisplay(SoWidget, SoWinMaterialEditor *, XtPointer);
321 void radioButtonPick(SoWidget, int, XtPointer);
322 void diamondButtonPick(SoWidget, int, XtPointer);
323
324 static void acceptButtonCB(SoWidget, SoWinMaterialEditor *, XtPointer);
325
326 // Sensor callbacks
327 static void sensorCB(void *, SoSensor *);
328
329 // Build routines
330 SoWidget buildWidget(SoWidget parent);
331 SoWidget buildPulldownMenu(SoWidget parent);
332 SoWidget buildControls(SoWidget parent);
333 SoWidget buildSlidersForm(SoWidget parent);
334
335 static void visibilityChangeCB(void *pt, SbBool visible);
336 void activate(); // connects the sensor
337 void deactivate(); // disconnects the sensor
338
339 // this is called by both constructors
340 void constructorCommon(SbBool buildNow);
341
342};
343
344
345// Inline functions
346 void
348 SoWinMaterialEditorCB *f,
349 void *userData)
350{ callbackList->addCallback((SoCallbackListCB *) f, userData); }
351
352 void
354 SoWinMaterialEditorCB *f,
355 void *userData)
356{ callbackList->removeCallback((SoCallbackListCB *) f, userData); }
357
358#include <Inventor/Win/SoWinEndStrict.h>
359
360#endif // _SO_WIN_MATERIAL_EDITOR_
361
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
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.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Supports copy/pa...
<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 ...
virtual void show()
This shows the component.
void setMaterial(const SoMaterial &mtl)
Sets a new material value.
SoWinMaterialEditor(SoWidget parent=NULL, const char *name=NULL, SbBool buildInsideParent=TRUE)
Constructor.
void addMaterialChangedCallback(SoWinMaterialEditorCB *f, void *userData=NULL)
Additional way of using the material editor, by registering a callback which will be called whenever ...
SoWinMaterialEditor::UpdateFrequency getUpdateFrequency()
Gets the update frequency.
void attach(SoMaterial *material, int index=0)
Attaches the editor to a material node and edits the material of the given index.
const SoMaterial & getMaterial() const
Gets the current material value.
void SoWinMaterialEditorCB(void *userData, const SoMaterial *mtl)
void removeMaterialChangedCallback(SoWinMaterialEditorCB *f, void *userData=NULL)
Removes the material changed callback.
UpdateFrequency
UpdateFrequency is how often new values should be sent to the node or the callback routine.
@ AFTER_ACCEPT
Only send updates after user hits accept button.
@ CONTINUOUS
Send updates with every mouse motion.
SbBool isAttached()
Returns TRUE if the editor is attached.
void setUpdateFrequency(SoWinMaterialEditor::UpdateFrequency freq)
Sets the update frequency.
SoWinMaterialPalette * m_pMaterialPalette
virtual ~SoWinMaterialEditor()
Destructor.
void detach()
Detaches the editor from the material node.
virtual void hide()
This hides the component.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Component for re...
int SbBool
Boolean type.
Definition SbBase.h:87
void * XtPointer
Definition SoQtDef.h:122