Debian Codegraph @

libSoXt/include/Inventor/Xt/SoXtMaterialEditor.h

raw symbols SCIP
1 /*
2 *
3 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 * Mountain View, CA 94043, or:
28 *
29 * http://www.sgi.com
30 *
31 * For further information regarding this notice, see:
32 *
33 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34 *
35 */
36
37 // -*- C++ -*-
38
39 /*
40 * Copyright (C) 1991-93 Silicon Graphics, Inc.
41 *
42 _______________________________________________________________________
43 ______________ S I L I C O N G R A P H I C S I N C . ____________
44 |
45 | $Revision: 1.1.1.1 $
46 |
47 | Description:
48 | Component for editing materials.
49 |
50 | Classes : SoXtMaterialEditor
51 |
52 | Author(s) : Alain Dumesny, David Mott
53 |
54 ______________ S I L I C O N G R A P H I C S I N C . ____________
55 _______________________________________________________________________
56 */
57
58 #ifndef _SO_XT_MATERIAL_EDITOR_
59 #define _SO_XT_MATERIAL_EDITOR_cxx . . $ `libSoXt/include/Inventor/Xt/SoXtMaterialEditor.h:59:9`!
60
61 #include <X11/Intrinsic.h>
62 #include <Xm/Xm.h>
63 #include <Inventor/SbBasic.h>cxx . . $ `<file>/lib/database/include/Inventor/SbBasic.h`/
64 #include <Inventor/misc/SoCallbackList.h>cxx . . $ `<file>/lib/database/include/Inventor/misc/SoCallbackList.h`/
65 #include <Inventor/Xt/SoXtComponent.h>cxx . . $ `<file>/libSoXt/include/Inventor/Xt/SoXtComponent.h`/
66
67 class SoBaseColorcxx . . $ SoBaseColor#;
68 class SoXtClipboardcxx . . $ SoXtClipboard#;
69 class _SoXtColorEditorcxx . . $ _SoXtColorEditor#;
70 class SoNodeSensorcxx . . $ SoNodeSensor#;
71 class SoSensorcxx . . $ SoSensor#;
72 class SoDirectionalLightcxx . . $ SoDirectionalLight#;
73 class SoMaterialcxx . . $ SoMaterial#;
74 class SoXtMaterialListcxx . . $ SoXtMaterialList#;
75 class SoPathListcxx . . $ SoPathList#;
76 class SoXtRenderAreacxx . . $ SoXtRenderArea#;
77 class SoSelectioncxx . . $ SoSelection#;
78 class _SoXtColorSlidercxx . . $ _SoXtColorSlider#;
79 class SoMFColorcxx . . $ SoMFColor#;
80 class SbColorcxx . . $ SbColor#;
81 class SoBasecxx . . $ SoBase#;
82 class SoSeparatorcxx . . $ SoSeparator#;
83
84 // callback function prototypes
85 typedef void SoXtMaterialEditorCBcxx . . $ SoXtMaterialEditorCB#(void *userData, const SoMaterialcxx . . $ SoMaterial# *mtl);
86
87 //////////////////////////////////////////////////////////////////////////////
88 //
89 // Class: SoXtMaterialEditor
90 //
91 // This editor lets you interactively edit a material
92 //
93 //////////////////////////////////////////////////////////////////////////////
94
95 // C-api: prefix=SoXtMtlEd
96 class SoXtMaterialEditorcxx . . $ SoXtMaterialEditor# : public SoXtComponentcxx . . $ SoXtComponent# {
97 public:
98 // UpdateFrequency is how often new values should be sent
99 // to the node or the callback routine.
100 enum UpdateFrequencycxx . . $ SoXtMaterialEditor#UpdateFrequency# {
101 CONTINUOUScxx . . $ SoXtMaterialEditor#CONTINUOUS., // send updates with every mouse motion
102 AFTER_ACCEPTcxx . . $ SoXtMaterialEditor#AFTER_ACCEPT. // only send updates after user hits accept button
103 };
104
105 SoXtMaterialEditorcxx . . $ SoXtMaterialEditor#SoXtMaterialEditor(13a1a66a4f5d094a).(
106 Widgetcxx . . $ Widget# parent = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!,
107 const char *name = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!,
108 SbBoolcxx . . $ SbBool# buildInsideParent = TRUEcxx . . $ `<external>/3673480128541058774/Intrinsic.h:111:9`!);
109 ~cxx . . $ SoXtMaterialEditor#`~SoXtMaterialEditor`(49f6e7a06ebc5aa8).SoXtMaterialEditorcxx . . $ SoXtMaterialEditor#();
110
111 // attach the editor to the given node and edits the material
112 // of the given index (default is the first material)
113 void attachcxx . . $ SoXtMaterialEditor#attach(d2826ff8cb0d2d29).(SoMaterialcxx . . $ SoMaterial# *material, int index = 0);
114 void detachcxx . . $ SoXtMaterialEditor#detach(49f6e7a06ebc5aa8).();
115 SbBoolcxx . . $ SbBool# isAttachedcxx . . $ SoXtMaterialEditor#isAttached(b126dc7c1de90089).() { return (materialcxx . . $ SoXtMaterialEditor#material. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); }
116
117 //
118 // Additional way of using the material editor, by registering a callback
119 // and setting the material. At the time dictated by setUpdateFrequency
120 // the callbacks will be called with the new material.
121 //
122 // C-api: name=addMtlChangedCB
123 inline void addMaterialChangedCallbackcxx . . $ SoXtMaterialEditor#addMaterialChangedCallback(872871bff6745a36).(
124 SoXtMaterialEditorCBcxx . . $ SoXtMaterialEditorCB# *f,
125 void *userData = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
126 // C-api: name=removeMtlChangedCB
127 inline void removeMaterialChangedCallbackcxx . . $ SoXtMaterialEditor#removeMaterialChangedCallback(872871bff6745a36).(
128 SoXtMaterialEditorCBcxx . . $ SoXtMaterialEditorCB# *f,
129 void *userData = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
130
131 //
132 // Set/get the update frequency of when materialChanged callbacks should
133 // be called. (default CONTINUOUS).
134 //
135 // C-api: name=setUpdateFreq
136 void setUpdateFrequencycxx . . $ SoXtMaterialEditor#setUpdateFrequency(89c388a96c446037).(SoXtMaterialEditorcxx . . $ SoXtMaterialEditor#::UpdateFrequencycxx . . $ SoXtMaterialEditor#UpdateFrequency# freq);
137 // C-api: name=getUpdateFreq
138 SoXtMaterialEditorcxx . . $ SoXtMaterialEditor#::UpdateFrequencycxx . . $ SoXtMaterialEditor#UpdateFrequency# getUpdateFrequencycxx . . $ SoXtMaterialEditor#getUpdateFrequency(b2957258046aa93d).()
139 { return updateFreqcxx . . $ SoXtMaterialEditor#updateFreq.; }
140
141 // Redefine these since there are multiple windows -
142 // the color editor, directional light editor, and this component
143 virtual void showcxx . . $ SoXtMaterialEditor#show(49f6e7a06ebc5aa8).();
144 virtual void hidecxx . . $ SoXtMaterialEditor#hide(49f6e7a06ebc5aa8).();
145
146 // Set new values for the material editor, or get current values
147 // C-api: name=setMtl
148 void setMaterialcxx . . $ SoXtMaterialEditor#setMaterial(5f2e023eafee305e).(const SoMaterialcxx . . $ SoMaterial# &mtl);
149 // C-api: name=getMtl
150 const SoMaterialcxx . . $ SoMaterial# & getMaterialcxx . . $ SoXtMaterialEditor#getMaterial(79f12edc8d32d221).() const { return *localMaterialcxx . . $ SoXtMaterialEditor#localMaterial.; }
151
152 protected:
153
154 // This constructor takes a boolean whether to build the widget now.
155 // Subclasses can pass FALSE, then call SoXtMaterialEditor::buildWidget()
156 // when they are ready for it to be built.
157 SoEXTENDERcxx . . $ `lib/database/include/Inventor/SbBasic.h:112:9`!
158 SoXtMaterialEditorcxx . . $ SoXtMaterialEditor#SoXtMaterialEditor(d778020db9c00467).(
159 Widgetcxx . . $ Widget# parent,
160 const char *name,
161 SbBoolcxx . . $ SbBool# buildInsideParent,
162 SbBoolcxx . . $ SbBool# buildNow);
163
164 Widgetcxx . . $ Widget# buildWidgetcxx . . $ SoXtMaterialEditor#buildWidget(a686be44a4028679).(Widgetcxx . . $ Widget# parent);
165
166 // redefine these
167 virtual const char * getDefaultWidgetNamecxx . . $ SoXtMaterialEditor#getDefaultWidgetName(a9f41ea0e82d88cf).() const;
168 virtual const char * getDefaultTitlecxx . . $ SoXtMaterialEditor#getDefaultTitle(a9f41ea0e82d88cf).() const;
169 virtual const char * getDefaultIconTitlecxx . . $ SoXtMaterialEditor#getDefaultIconTitle(a9f41ea0e82d88cf).() const;
170
171 private:
172 // attach vars
173 SoMaterialcxx . . $ SoMaterial# *materialcxx . . $ SoXtMaterialEditor#material.; // material we are editing
174 int indexcxx . . $ SoXtMaterialEditor#index.; // material index number
175 SoNodeSensorcxx . . $ SoNodeSensor# *sensorcxx . . $ SoXtMaterialEditor#sensor.;
176 SoCallbackListcxx . . $ SoCallbackList# *callbackListcxx . . $ SoXtMaterialEditor#callbackList.;
177 Widgetcxx . . $ Widget# acceptButtoncxx . . $ SoXtMaterialEditor#acceptButton., diamondButtonscxx . . $ SoXtMaterialEditor#diamondButtons.[4], radioButtonscxx . . $ SoXtMaterialEditor#radioButtons.[4];
178 SoXtMaterialEditorcxx . . $ SoXtMaterialEditor#::UpdateFrequencycxx . . $ SoXtMaterialEditor#UpdateFrequency# updateFreqcxx . . $ SoXtMaterialEditor#updateFreq.;
179
180 // widgets to edit the material
181 Widgetcxx . . $ Widget# mgrWidgetcxx . . $ SoXtMaterialEditor#mgrWidget.; // topmost widget
182 _SoXtColorEditorcxx . . $ _SoXtColorEditor# *colorEditorcxx . . $ SoXtMaterialEditor#colorEditor.;
183 _SoXtColorSlidercxx . . $ _SoXtColorSlider# *sliderscxx . . $ SoXtMaterialEditor#sliders.[6];
184 SbBoolcxx . . $ SbBool# changedItcxx . . $ SoXtMaterialEditor#changedIt.[6];
185 SoXtMaterialListcxx . . $ SoXtMaterialList# *materialListcxx . . $ SoXtMaterialEditor#materialList.;
186 SbBoolcxx . . $ SbBool# ignoreCallbackcxx . . $ SoXtMaterialEditor#ignoreCallback.; // TRUE while callback should be ignored
187 SbBoolcxx . . $ SbBool# openMaterialListcxx . . $ SoXtMaterialEditor#openMaterialList.;
188 static void colorEditorCloseCBcxx . . $ SoXtMaterialEditor#colorEditorCloseCB(60bcb984018fbd9d).(void *, SoXtComponentcxx . . $ SoXtComponent# *);
189 static void materialListCloseCBcxx . . $ SoXtMaterialEditor#materialListCloseCB(60bcb984018fbd9d).(void *, SoXtComponentcxx . . $ SoXtComponent# *);
190
191 // copy/paste support
192 SoXtClipboardcxx . . $ SoXtClipboard# *clipboardcxx . . $ SoXtMaterialEditor#clipboard.;
193
194 // local scene vars
195 SoXtRenderAreacxx . . $ SoXtRenderArea# *renderAreacxx . . $ SoXtMaterialEditor#renderArea.;
196 SoMaterialcxx . . $ SoMaterial# *localMaterialcxx . . $ SoXtMaterialEditor#localMaterial.; // local copy of the material
197 SoDirectionalLightcxx . . $ SoDirectionalLight# *light0cxx . . $ SoXtMaterialEditor#light0.;
198 SoDirectionalLightcxx . . $ SoDirectionalLight# *light1cxx . . $ SoXtMaterialEditor#light1.;
199 SoBaseColorcxx . . $ SoBaseColor# *tileColorcxx . . $ SoXtMaterialEditor#tileColor.;
200 SoSeparatorcxx . . $ SoSeparator# *rootcxx . . $ SoXtMaterialEditor#root.;
201
202 // keep the menu items around so we can update them before menu display
203 Widgetcxx . . $ Widget# *menuItemsListcxx . . $ SoXtMaterialEditor#menuItemsList.;
204
205 int32_tcxx . . $ int32_t# activeColorcxx . . $ SoXtMaterialEditor#activeColor.; // field which color editor edits
206
207 // update the sliders/colorEditor based on the local material
208 void updateLocalComponentscxx . . $ SoXtMaterialEditor#updateLocalComponents(49f6e7a06ebc5aa8).();
209
210 // update the colorEditor based on the activeColor flag
211 void updateColorEditorcxx . . $ SoXtMaterialEditor#updateColorEditor(d4f767463ce0a6b3).(SbBoolcxx . . $ SbBool# updateTitle = FALSEcxx . . $ `<external>/3673480128541058774/Intrinsic.h:110:9`!);
212
213 // update a color slider (amb/diff/spec/emiss) based of a material color
214 // (split the base color from the intensity).
215 void updateColorSlidercxx . . $ SoXtMaterialEditor#updateColorSlider(966de2f575736941).(_SoXtColorSlidercxx . . $ _SoXtColorSlider# *, const float rgb[3]);
216
217 // update a material field when a color slider changes.
218 void updateMaterialColorcxx . . $ SoXtMaterialEditor#updateMaterialColor(9334d2017a37cf34).(
219 SoMFColorcxx . . $ SoMFColor# *editMtlColor,
220 SoMFColorcxx . . $ SoMFColor# *localMtlColor,
221 const float *rgb,
222 float intensity);
223
224 // copies mat2 onto mat1
225 void copyMaterialcxx . . $ SoXtMaterialEditor#copyMaterial(20c8ff4be243a5cd).(SoMaterialcxx . . $ SoMaterial# *mat1, int index1,
226 const SoMaterialcxx . . $ SoMaterial# *mat2, int index2);
227
228 // For each of the 6 sliders (or sets of sliders) sets the ignore flag of
229 // the material node being editted to FALSE if it has been changed.
230 void undoIgnoresIfChangedcxx . . $ SoXtMaterialEditor#undoIgnoresIfChanged(49f6e7a06ebc5aa8).();
231
232 // copy/paste support
233 static void pasteDonecxx . . $ SoXtMaterialEditor#pasteDone(b9152ec4638eb195).(void *userData, SoPathListcxx . . $ SoPathList# *pathList);
234
235 // Callback routines from components
236 static void materialListCBcxx . . $ SoXtMaterialEditor#materialListCB(5da98f53a69d8a1d).(void *, const SoMaterialcxx . . $ SoMaterial# *);
237 static void colorEditorCBcxx . . $ SoXtMaterialEditor#colorEditorCB(a23719629555fa40).(void *, const SbColorcxx . . $ SbColor# *);
238 static void ambientSliderCBcxx . . $ SoXtMaterialEditor#ambientSliderCB(314e3af8753aac9e).(void *, float);
239 static void diffuseSliderCBcxx . . $ SoXtMaterialEditor#diffuseSliderCB(314e3af8753aac9e).(void *, float);
240 static void specularSliderCBcxx . . $ SoXtMaterialEditor#specularSliderCB(314e3af8753aac9e).(void *, float);
241 static void emissiveSliderCBcxx . . $ SoXtMaterialEditor#emissiveSliderCB(314e3af8753aac9e).(void *, float);
242 static void shininessSliderCBcxx . . $ SoXtMaterialEditor#shininessSliderCB(314e3af8753aac9e).(void *, float);
243 static void transparencySliderCBcxx . . $ SoXtMaterialEditor#transparencySliderCB(314e3af8753aac9e).(void *, float);
244
245 // Callback routines from Xt/Motif
246 static void menuPickcxx . . $ SoXtMaterialEditor#menuPick(4bf45020cef8cfbc).(Widgetcxx . . $ Widget#, int, XmAnyCallbackStruct *);
247 static void menuDisplaycxx . . $ SoXtMaterialEditor#menuDisplay(82d2b878c1a25bd).(Widgetcxx . . $ Widget#, SoXtMaterialEditorcxx . . $ SoXtMaterialEditor# *, XtPointercxx . . $ XtPointer#);
248 static void radioButtonPickcxx . . $ SoXtMaterialEditor#radioButtonPick(bfaf57085674df68).(Widgetcxx . . $ Widget#, int, XtPointercxx . . $ XtPointer#);
249 static void diamondButtonPickcxx . . $ SoXtMaterialEditor#diamondButtonPick(bfaf57085674df68).(Widgetcxx . . $ Widget#, int, XtPointercxx . . $ XtPointer#);
250 static void acceptButtonCBcxx . . $ SoXtMaterialEditor#acceptButtonCB(82d2b878c1a25bd).(Widgetcxx . . $ Widget#, SoXtMaterialEditorcxx . . $ SoXtMaterialEditor# *, XtPointercxx . . $ XtPointer#);
251
252 // Sensor callbacks
253 static void sensorCBcxx . . $ SoXtMaterialEditor#sensorCB(c8d298b3e215c027).(void *, SoSensorcxx . . $ SoSensor# *);
254
255 // Build routines
256 Widgetcxx . . $ Widget# buildPulldownMenucxx . . $ SoXtMaterialEditor#buildPulldownMenu(a686be44a4028679).(Widgetcxx . . $ Widget# parent);
257 Widgetcxx . . $ Widget# buildControlscxx . . $ SoXtMaterialEditor#buildControls(a686be44a4028679).(Widgetcxx . . $ Widget# parent);
258 Widgetcxx . . $ Widget# buildSlidersFormcxx . . $ SoXtMaterialEditor#buildSlidersForm(a686be44a4028679).(Widgetcxx . . $ Widget# parent);
259
260 static void visibilityChangeCBcxx . . $ SoXtMaterialEditor#visibilityChangeCB(d0320739773070f2).(void *pt, SbBoolcxx . . $ SbBool# visible);
261 void activatecxx . . $ SoXtMaterialEditor#activate(49f6e7a06ebc5aa8).(); // connects the sensor
262 void deactivatecxx . . $ SoXtMaterialEditor#deactivate(49f6e7a06ebc5aa8).(); // disconnects the sensor
263
264 // this is called by both constructors
265 void constructorCommoncxx . . $ SoXtMaterialEditor#constructorCommon(d4f767463ce0a6b3).(SbBoolcxx . . $ SbBool# buildNow);
266 };
267
268
269 // Inline functions
270 void
271 SoXtMaterialEditorcxx . . $ SoXtMaterialEditor#::addMaterialChangedCallbackcxx . . $ SoXtMaterialEditor#addMaterialChangedCallback(872871bff6745a36).(
272 SoXtMaterialEditorCBcxx . . $ SoXtMaterialEditorCB# *f,
273 void *userData)
274 { callbackListcxx . . $ SoXtMaterialEditor#callbackList.->addCallbackcxx . . $ SoCallbackList#addCallback(b3eab75dfcd7f474).((SoCallbackListCBcxx . . $ SoCallbackListCB# *) f, userData); }
275
276 void
277 SoXtMaterialEditorcxx . . $ SoXtMaterialEditor#::removeMaterialChangedCallbackcxx . . $ SoXtMaterialEditor#removeMaterialChangedCallback(872871bff6745a36).(
278 SoXtMaterialEditorCBcxx . . $ SoXtMaterialEditorCB# *f,
279 void *userData)
280 { callbackListcxx . . $ SoXtMaterialEditor#callbackList.->removeCallbackcxx . . $ SoCallbackList#removeCallback(b3eab75dfcd7f474).((SoCallbackListCBcxx . . $ SoCallbackListCB# *) f, userData); }
281
282 #endif // _SO_XT_MATERIAL_EDITOR_
283
284