Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
SoWinMaterialEditor.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-2014 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
28#include <Inventor/sys/port.h>
29#include <Inventor/SbBasic.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;
47class SoMFColor;
48class SbColor;
49class SoBase;
50class SoSeparator;
51class SoWinMaterialPalette;
52
53class SoNode; //ditto
54class SoSFColor; //ditto
55
56// callback function prototypes
60typedef void SoWinMaterialEditorCB(void *userData, const SoMaterial *mtl);
61
63//
64// Class: SoWinMaterialEditor
65//
66// This editor lets you interactively edit a material
67//
69
98 public:
113
118 SoWidget parent = NULL,
119 const char *name = NULL,
120 SbBool buildInsideParent = TRUE);
125
130 void attach( SoMaterial *material, int index = 0 );
131
135 void detach();
139 SbBool isAttached() { return (material != NULL); }
140
147 inline void addMaterialChangedCallback(
149 void *userData = NULL);
156 void *userData = NULL);
157
167
168 // Redefine these since there are multiple windows -
169 // the color editor, directional light editor, and this component
170 virtual void show();
171 virtual void hide();
172
176 void setMaterial(const SoMaterial &mtl);
180 const SoMaterial & getMaterial() const { return *localMaterial; }
181
183 SoWinMaterialPalette * m_pMaterialPalette;
184 private:
185
186
187 // This constructor takes a boolean whether to build the widget now.
188 // Subclasses can pass FALSE, then call SoWinMaterialEditor::buildWidget()
189 // when they are ready for it to be built.
192 SoWidget parent,
193 const char *name,
194 SbBool buildInsideParent,
195 SbBool buildNow);
196
197 // redefine these
198 virtual SbString getDefaultWidgetName() const;
199 virtual SbString getDefaultTitle() const;
200 virtual SbString getDefaultIconTitle() const;
201
202 private:
203 unsigned long nCurrEditId ;
204 unsigned long diamondButtonId[4] ;
205 unsigned long radioButtonId[4] ;
206 HMENU menubar ;
207
208 void layoutAccept() ;
209
210 static WBOOL CALLBACK mgrDlgProc( Hwnd hdlg, UINT message,
211 WPARAM wParam, LPARAM lParam );
212 static void onCommand(
213 Hwnd hdlg,
214 int id,
215 Hwnd hCtrl,
216 UINT codeNotify ) ;
217
218 void handleEdit(
219 int nSlider,
220 Hwnd hEdit,
221 UINT codeNotify) ;
222
223 void handleButtons(SoWinMaterialEditor *p,
224 SoWidget hCtrl,
225 int id,
226 UINT codeNotify) ;
227
228 void handleMenu(SoWinMaterialEditor *p,
229 int id ) ;
230
231 void initPlacement() ;
232
233
234 // attach vars
235 //SoMaterial *material; // material we are editing
236 SoNode *material; // material we are editing
237 SoMaterial *imat; // ditto
238 int index; // material index number
239 SoNodeSensor *sensor;
240 SoCallbackList *callbackList;
241 SoWidget acceptButton, diamondButtons[4], radioButtons[4];
243
244 // widgets to edit the material
245 SoWidget mgrWidget; // topmost widget
246 SoWinColorEditor *colorEditor;
247 SoWinColorSlider *sliders[6];
248 SbBool changedIt[6];
249#ifdef NOTYET
250 SoWinMaterialList *materialList;
251#endif
252 SbBool ignoreCallback; // TRUE while callback should be ignored
253 SbBool openMaterialList;
254 static void colorEditorCloseCB(void *, SoWinComponent *);
255 static void materialListCloseCB(void *, SoWinComponent *);
256
257 // copy/paste support
258 SoWinClipboard *clipboard;
259
260 // local scene vars
261 SoWinRenderArea *renderArea;
262 SoMaterial *localMaterial; // local copy of the material
263
264 SoDirectionalLight *light0;
265 SoDirectionalLight *light1;
266 SoBaseColor *tileColor;
267 SoSeparator *root;
268
269 long activeColor; // field which color editor edits
270
271 // update the sliders/colorEditor based on the local material
272 void updateLocalComponents();
273
274 // update the colorEditor based on the activeColor flag
275 void updateColorEditor(SbBool updateTitle = FALSE);
276
277 // update a color slider (amb/diff/spec/emiss) based of a material color
278 // (split the base color from the intensity).
279 void updateColorSlider(SoWinColorSlider *, const float rgb[3]);
280
281 // update a material field when a color slider changes.
282 void updateMaterialColor(
283 SoMFColor *editMtlColor,
284 SoMFColor *localMtlColor,
285 const float *rgb,
286 float intensity);
287 void updateMaterialColor(
288 SoSFColor *editMtlColor,
289 SoMFColor *localMtlColor,
290 const float *rgb,
291 float intensity);
292
293 // copies mat2 onto mat1
294 //void copyMaterial(SoMaterial *mat1, int index1,
295 // const SoMaterial *mat2, int index2);
296 void copyMaterial(SoNode *mat1, int index1,
297 const SoNode *mat2, int index2);
298
299 // For each of the 6 sliders (or sets of sliders) sets the ignore flag of
300 // the material node being editted to FALSE if it has been changed.
301 void undoIgnoresIfChanged();
302
303 // copy/paste support
304 static void pasteDone(void *userData, SoPathList *pathList);
305
306 // Callback routines from components
307 static void materialListCB(void *, const SoMaterial *);
308 static void colorEditorCB(void *, const SbColor *);
309 static void ambientSliderCB(void *, float);
310 static void diffuseSliderCB(void *, float);
311 static void specularSliderCB(void *, float);
312 static void emissiveSliderCB(void *, float);
313 static void shininessSliderCB(void *, float);
314 static void transparencySliderCB(void *, float);
315
316 // Callback routines from Xt/Motif
317 void menuPick(SoWidget, int, XmAnyCallbackStruct *);
318 void menuDisplay(SoWidget, SoWinMaterialEditor *, XtPointer);
319 void radioButtonPick(SoWidget, int, XtPointer);
320 void diamondButtonPick(SoWidget, int, XtPointer);
321
322 static void acceptButtonCB(SoWidget, SoWinMaterialEditor *, XtPointer);
323
324 // Sensor callbacks
325 static void sensorCB(void *, SoSensor *);
326
327 // Build routines
328 SoWidget buildWidget(SoWidget parent);
329 SoWidget buildPulldownMenu(SoWidget parent);
330 SoWidget buildControls(SoWidget parent);
331 SoWidget buildSlidersForm(SoWidget parent);
332
333 static void visibilityChangeCB(void *pt, SbBool visible);
334 void activate(); // connects the sensor
335 void deactivate(); // disconnects the sensor
336
337 // this is called by both constructors
338 void constructorCommon(SbBool buildNow);
339
340};
341
342
343// Inline functions
344 void
347 void *userData)
348{ callbackList->addCallback((SoCallbackListCB *) f, userData); }
349
350 void
353 void *userData)
354{ callbackList->removeCallback((SoCallbackListCB *) f, userData); }
355
357
358#endif // _SO_WIN_MATERIAL_EDITOR_
359
#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 SoWidget
Definition SoQtDef.h:40
SoWinColorSlider(SoWidget parent=NULL, const char *name=NULL, SbBool buildInsideParent=TRUE, Type type=INTENSITY_SLIDER)
#define WBOOL
Definition SoWinDef.h:38
#define Hwnd
Definition SoWinDef.h:83
#define XmAnyCallbackStruct
Definition SoWinDef.h:127
void SoWinMaterialEditorCB(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:95
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:186
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:97
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 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 SoCallbackListCB(void *userData, void *callbackData)
unsigned int UINT
Definition port.h:357
#define CALLBACK
Definition port.h:345