Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
SoWinMaterialPalette.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-2023 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : VSG (MMM YYYY)
22**=======================================================================*/
23
24
25
26#ifndef _SO_WIN_MATERIAL_PALETTE_
27#define _SO_WIN_MATERIAL_PALETTE_
28
30#include <Inventor/sys/port.h>
31#include <Inventor/SbBasic.h>
34
35class SoBaseColor;
36class SoWinClipboard;
38class SoNodeSensor;
39class SoSensor;
41class SoMaterial;
42class SoPathList;
43class SoWinRenderArea;
44class SoSelection;
46class SoMFColor;
47class SbColor;
48class SoBase;
49class SoSeparator;
52class SoNode;
53class SoSelection;
54class SoPath;
55class SoEventCallback;
59#include <winbase.h>
60
61// callback function prototypes
62typedef void SoWinMaterialPaletteCB(void *userData, const SoMaterial *mtl);
63
65//
66// Class: SoWinMaterialPalette
67//
68// This editor lets you interactively edit a material
69//
71
72{
73 public:
74
75 SoWinMaterialPalette(
76 SoWidget parent = NULL,
77 const char *name = NULL,
78 SbBool buildInsideParent = TRUE);
80
81 // attach the editor to the given node and edits the material
82 // of the given index (default is the first material)
83 void attach(SoMaterial *material, int index = 0);
84 void detach();
85 SbBool isAttached() { return (material != NULL); }
86
87 //
88 // Additional way of using the material editor, by registering a callback
89 // and setting the material. At the time dictated by setUpdateFrequency
90 // the callbacks will be called with the new material.
91 //
94 void *userData = NULL);
97 void *userData = NULL);
98
99 // Redefine these since there are multiple windows -
100 // the color editor, directional light editor, and this component
101 virtual void show();
102 virtual void hide();
103
104 // Set new values for the material editor, or get current values
105 void setMaterial(const SoMaterial &mtl);
106 const SoMaterial & getMaterial() const { return (*material); }
107 public:
109
111 static void staticLocation2EventCB(void *userData,
112 SoEventCallback *node);
114
116 void setPaletteBaseDir(LPCTSTR newBaseDir);
117 long getMaxDirCount() { return m_nMaxPathId; };
118 private:
119 HWND m_fileBrowser;
120
121 static HKEY tgsRegKey;
122
123 void makePaletteMenuList(HMENU menuBar);
124
125 // This constructor takes a boolean whether to build the widget now.
126 // Subclasses can pass FALSE, then call SoWinMaterialPalette::buildWidget()
127 // when they are ready for it to be built.
129 SoWinMaterialPalette(
130 SoWidget parent,
131 const char *name,
132 SbBool buildInsideParent,
133 SbBool buildNow);
134
135 // redefine these
136 virtual SbString getDefaultWidgetName() const;
137 virtual SbString getDefaultTitle() const;
138 virtual SbString getDefaultIconTitle() const;
139
140 private:
141 unsigned long nCurrEditId ;
142 HMENU menubar ;
143
144
145 static WBOOL CALLBACK mgrDlgProc( Hwnd hdlg, UINT message,
146 WPARAM wParam, LPARAM lParam );
147 static void onCommand(
148 Hwnd hdlg,
149 int id,
150 Hwnd hCtrl,
151 UINT codeNotify ) ;
152
153 void handleMenu(SoWinMaterialPalette *p,
154 int id ) ;
155
156 void initPlacement() ;
157 // attach vars
158 SoMaterial *material; // material we are editing
159 int index; // material index number
160 SoCallbackList *callbackList;
161
162 // widgets to edit the material
163 SoWidget mgrWidget; // topmost widget
164
165
166 SbBool ignoreCallback; // TRUE while callback should be ignored
167 SbBool openMaterialList;
168
169 // copy/paste support
170 SoWinClipboard *clipboard;
171
172 //local palette vars
173 SoWinPlaneViewer *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 * aShape,long * nodeCnt,SbBool reset = FALSE);
182 LPCTSTR getMaterialDir();
183 void setMaterialDir(LPCTSTR dirPath);
184 SbBool saveMaterial(LPCTSTR fName);
185 char currentMaterialPath[MAX_PATH];
186 char* m_materialPath;
187 void changeMaterialPath(UINT id);
188 SoWidget m_hScrollBar;
189 SoWidget m_hStatusText;
190 SoWidget m_hPaletteName;
191 int m_nMaxPathId;
192 void adjustVScrollInfo(long rows);
193 void scrollCamera(int nScrollCode, short int nPos);
194
195 SoBoxHighlightRenderAction * m_pHighlightAction;
196
197
198 SoWinMaterialEditor *m_pMaterialEditor;
199 SoWinColorEditor *m_pColorEditor;
200 // keep the menu items around so we can update them before menu display
201 SoWidget *menuItemsList;
202
203 long activeColor; // field which color editor edits
204
205 // copies mat2 onto mat1
206 void copyMaterial(SoMaterial *mat1, int index1,
207 const SoMaterial *mat2, int index2);
208
209 // copy/paste support
210 static void pasteDone(void *userData, SoPathList *pathList);
211
212 // Callback routines from components
213 static void materialListCB(void *, const SoMaterial *);
214 // Callback routines from Xt/Motif
215 void menuPick(SoWidget, int, XmAnyCallbackStruct *);
216 void menuDisplay(SoWidget, SoWinMaterialPalette *, XtPointer);
217
218 // Build routines
219 SoWidget buildWidget(SoWidget parent);
220 SoWidget buildPulldownMenu(SoWidget parent);
221
222 // this is called by both constructors
223 void constructorCommon(SbBool buildNow);
224};
225
227void
228SoWinMaterialPalette::addMaterialChangedCallback(
230 void *userData)
231{ callbackList->addCallback((SoCallbackListCB *) f, userData); }
232
233void
234SoWinMaterialPalette::removeMaterialChangedCallback(
236 void *userData)
237{ callbackList->removeCallback((SoCallbackListCB *) f, userData); }
239
241
242#endif // _SO_WIN_MATERIAL_PALETTE_
243
244
#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
#define MAX_PATH
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
SbBool isAttached()
void SoWinMaterialPaletteCB(void *userData, const SoMaterial *mtl)
static void staticLocation2EventCB(void *userData, SoEventCallback *node)
void windowsPalette()
virtual void show()
void setPaletteBaseDir(LPCTSTR newBaseDir)
void browsePalletteBaseDir()
void attach(SoMaterial *material, int index=0)
void addMaterialChangedCallback(SoWinMaterialPaletteCB *f, void *userData=NULL)
void location2Event(SoEventCallback *node)
~SoWinMaterialPalette()
long getMaxDirCount()
SbBool alwaysOnTop
void removeMaterialChangedCallback(SoWinMaterialPaletteCB *f, void *userData=NULL)
void detach()
virtual void hide()
void setMaterial(const SoMaterial &mtl)
const SoMaterial & getMaterial() const
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.
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:186
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
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> Component which ...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Viewer 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)
void reset()
unsigned int UINT
Definition port.h:357
#define CALLBACK
Definition port.h:345