Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / svx / source / engine3d / float3d.cxx
blobb6cfd4b5188fcf17cb1c40b06bfd29dfbd2a93e3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <sfx2/dispatch.hxx>
30 #include <sfx2/module.hxx>
31 #include <sfx2/viewfrm.hxx>
32 #include <svl/eitem.hxx>
33 #include <svtools/colrdlg.hxx>
34 #include <vcl/msgbox.hxx>
35 #include <sfx2/viewsh.hxx>
36 #include <tools/shl.hxx>
37 #include <svx/xflclit.hxx>
38 #include <svx/svdmodel.hxx>
39 #include <svx/globl3d.hxx>
40 #include <svx/view3d.hxx>
41 #include <svx/obj3d.hxx>
42 #include <svx/sphere3d.hxx>
43 #include <svx/scene3d.hxx>
44 #include <svx/camera3d.hxx>
45 #include <svx/fmmodel.hxx>
46 #include <svx/fmpage.hxx>
47 #include <svx/polysc3d.hxx>
48 #include <editeng/eeitem.hxx>
49 #include <svl/style.hxx>
50 #include <svx/dlgutil.hxx>
52 #include <svx/dialmgr.hxx>
53 #include <svx/viewpt3d.hxx> // Projection Type
55 #include <svx/svxids.hrc>
56 #include <svx/dialogs.hrc>
58 #include <editeng/colritem.hxx>
59 #include <svx/e3ditem.hxx>
61 #include <svx/gallery.hxx>
62 #define GALLERY_THEME "3D"
63 #include <svl/whiter.hxx>
65 #include <svx/float3d.hxx>
66 #include "float3d.hrc"
68 SFX_IMPL_DOCKINGWINDOW( Svx3DChildWindow, SID_3D_WIN )
70 struct Svx3DWinImpl
72 SfxItemPool* pPool;
75 namespace {
76 /** Get the dispatcher from the current view frame, or, if that is not
77 available, from the given bindings.
78 @param pBindings
79 May be NULL.
80 @returns NULL when both the current view frame is NULL and the given
81 bindings are NULL.
83 SfxDispatcher* LocalGetDispatcher (const SfxBindings* pBindings)
85 SfxDispatcher* pDispatcher = NULL;
87 if (SfxViewFrame::Current() != NULL)
88 pDispatcher = SfxViewFrame::Current()->GetDispatcher();
89 else if (pBindings != NULL)
90 pDispatcher = pBindings->GetDispatcher();
92 return pDispatcher;
97 /*************************************************************************
98 |* Svx3DWin - FloatingWindow
99 \************************************************************************/
100 Svx3DWin::Svx3DWin( SfxBindings* pInBindings,
101 SfxChildWindow *pCW, Window* pParent ) :
102 SfxDockingWindow ( pInBindings, pCW, pParent,
103 SVX_RES( RID_SVXFLOAT_3D ) ),
104 aBtnGeo ( this, SVX_RES( BTN_GEO ) ),
105 aBtnRepresentation ( this, SVX_RES( BTN_REPRESENTATION ) ),
106 aBtnLight ( this, SVX_RES( BTN_LIGHT ) ),
107 aBtnTexture ( this, SVX_RES( BTN_TEXTURE ) ),
108 aBtnMaterial ( this, SVX_RES( BTN_MATERIAL ) ),
109 aBtnUpdate ( this, SVX_RES( BTN_UPDATE ) ),
110 aBtnAssign ( this, SVX_RES( BTN_ASSIGN ) ),
111 aFLGeometrie ( this, SVX_RES( FL_GEOMETRIE ) ),
113 // Geometry
114 aFtPercentDiagonal ( this, SVX_RES( FT_PERCENT_DIAGONAL ) ),
115 aMtrPercentDiagonal ( this, SVX_RES( MTR_PERCENT_DIAGONAL ) ),
116 aFtBackscale ( this, SVX_RES( FT_BACKSCALE ) ),
117 aMtrBackscale ( this, SVX_RES( MTR_BACKSCALE ) ),
118 aFtEndAngle ( this, SVX_RES( FT_END_ANGLE ) ),
119 aMtrEndAngle ( this, SVX_RES( MTR_END_ANGLE ) ),
120 aFtDepth ( this, SVX_RES( FT_DEPTH ) ),
121 aMtrDepth ( this, SVX_RES( MTR_DEPTH ) ),
122 aFLSegments ( this, SVX_RES( FL_SEGMENTS ) ),
124 aFtHorizontal ( this, SVX_RES( FT_HORIZONTAL ) ),
125 aNumHorizontal ( this, SVX_RES( NUM_HORIZONTAL ) ),
126 aFtVertical ( this, SVX_RES( FT_VERTICAL ) ),
127 aNumVertical ( this, SVX_RES( NUM_VERTICAL ) ),
129 aFLNormals ( this, SVX_RES( FL_NORMALS ) ),
130 aBtnNormalsObj ( this, SVX_RES( BTN_NORMALS_OBJ ) ),
131 aBtnNormalsFlat ( this, SVX_RES( BTN_NORMALS_FLAT ) ),
132 aBtnNormalsSphere ( this, SVX_RES( BTN_NORMALS_SPHERE ) ),
133 aBtnNormalsInvert ( this, SVX_RES( BTN_NORMALS_INVERT ) ),
134 aBtnTwoSidedLighting( this, SVX_RES( BTN_TWO_SIDED_LIGHTING ) ),
136 aBtnDoubleSided ( this, SVX_RES( BTN_DOUBLE_SIDED ) ),
138 // Representation
139 aFLRepresentation ( this, SVX_RES( FL_REPRESENTATION ) ),
140 aFtShademode ( this, SVX_RES( FT_SHADEMODE ) ),
141 aLbShademode ( this, SVX_RES( LB_SHADEMODE ) ),
142 aFLShadow ( this, SVX_RES( FL_SHADOW ) ),
143 aBtnShadow3d ( this, SVX_RES( BTN_SHADOW_3D ) ),
144 aFtSlant ( this, SVX_RES( FT_SLANT ) ),
145 aMtrSlant ( this, SVX_RES( MTR_SLANT ) ),
146 aFtDistance ( this, SVX_RES( FT_DISTANCE ) ),
147 aMtrDistance ( this, SVX_RES( MTR_DISTANCE ) ),
148 aFtFocalLeng ( this, SVX_RES( FT_FOCAL_LENGTH ) ),
149 aMtrFocalLength ( this, SVX_RES( MTR_FOCAL_LENGTH ) ),
150 aFLCamera ( this, SVX_RES( FL_CAMERA ) ),
151 aFLLight ( this, SVX_RES( FL_LIGHT ) ),
153 // Lighting
154 aBtnLight1 ( this, SVX_RES( BTN_LIGHT_1 ) ),
155 aBtnLight2 ( this, SVX_RES( BTN_LIGHT_2 ) ),
156 aBtnLight3 ( this, SVX_RES( BTN_LIGHT_3 ) ),
157 aBtnLight4 ( this, SVX_RES( BTN_LIGHT_4 ) ),
158 aBtnLight5 ( this, SVX_RES( BTN_LIGHT_5 ) ),
159 aBtnLight6 ( this, SVX_RES( BTN_LIGHT_6 ) ),
160 aBtnLight7 ( this, SVX_RES( BTN_LIGHT_7 ) ),
161 aBtnLight8 ( this, SVX_RES( BTN_LIGHT_8 ) ),
162 aFTLightsource ( this, SVX_RES( FT_LIGHTSOURCE ) ),
163 aLbLight1 ( this, SVX_RES( LB_LIGHT_1 ) ),
164 aLbLight2 ( this, SVX_RES( LB_LIGHT_2 ) ),
165 aLbLight3 ( this, SVX_RES( LB_LIGHT_3 ) ),
166 aLbLight4 ( this, SVX_RES( LB_LIGHT_4 ) ),
167 aLbLight5 ( this, SVX_RES( LB_LIGHT_5 ) ),
168 aLbLight6 ( this, SVX_RES( LB_LIGHT_6 ) ),
169 aLbLight7 ( this, SVX_RES( LB_LIGHT_7 ) ),
170 aLbLight8 ( this, SVX_RES( LB_LIGHT_8 ) ),
172 aBtnLightColor ( this, SVX_RES( BTN_LIGHT_COLOR ) ),
174 // Keyboard shortcuts activate the next control, so the
175 // order needed to be changed here
176 aFTAmbientlight ( this, SVX_RES( FT_AMBIENTLIGHT ) ), // Text label
177 aLbAmbientlight ( this, SVX_RES( LB_AMBIENTLIGHT ) ), // ListBox
178 aBtnAmbientColor ( this, SVX_RES( BTN_AMBIENT_COLOR ) ), // color button
179 aFLTexture ( this, SVX_RES( FL_TEXTURE ) ),
181 // Textures
182 aFtTexKind ( this, SVX_RES( FT_TEX_KIND ) ),
183 aBtnTexLuminance ( this, SVX_RES( BTN_TEX_LUMINANCE ) ),
184 aBtnTexColor ( this, SVX_RES( BTN_TEX_COLOR ) ),
185 aFtTexMode ( this, SVX_RES( FT_TEX_MODE ) ),
186 aBtnTexReplace ( this, SVX_RES( BTN_TEX_REPLACE ) ),
187 aBtnTexModulate ( this, SVX_RES( BTN_TEX_MODULATE ) ),
188 aBtnTexBlend ( this, SVX_RES( BTN_TEX_BLEND ) ),
189 aFtTexProjectionX ( this, SVX_RES( FT_TEX_PROJECTION_X ) ),
190 aBtnTexObjectX ( this, SVX_RES( BTN_TEX_OBJECT_X ) ),
191 aBtnTexParallelX ( this, SVX_RES( BTN_TEX_PARALLEL_X ) ),
192 aBtnTexCircleX ( this, SVX_RES( BTN_TEX_CIRCLE_X ) ),
193 aFtTexProjectionY ( this, SVX_RES( FT_TEX_PROJECTION_Y ) ),
194 aBtnTexObjectY ( this, SVX_RES( BTN_TEX_OBJECT_Y ) ),
195 aBtnTexParallelY ( this, SVX_RES( BTN_TEX_PARALLEL_Y ) ),
196 aBtnTexCircleY ( this, SVX_RES( BTN_TEX_CIRCLE_Y ) ),
197 aFtTexFilter ( this, SVX_RES( FT_TEX_FILTER ) ),
198 aBtnTexFilter ( this, SVX_RES( BTN_TEX_FILTER ) ),
199 aFLMaterial ( this, SVX_RES( FL_MATERIAL ) ),
201 // Material
202 aFtMatFavorites ( this, SVX_RES( FT_MAT_FAVORITES ) ),
203 aLbMatFavorites ( this, SVX_RES( LB_MAT_FAVORITES ) ),
204 aFtMatColor ( this, SVX_RES( FT_MAT_COLOR ) ),
205 aLbMatColor ( this, SVX_RES( LB_MAT_COLOR ) ),
206 aBtnMatColor ( this, SVX_RES( BTN_MAT_COLOR ) ),
207 aFtMatEmission ( this, SVX_RES( FT_MAT_EMISSION ) ),
208 aLbMatEmission ( this, SVX_RES( LB_MAT_EMISSION ) ),
209 aBtnEmissionColor ( this, SVX_RES( BTN_EMISSION_COLOR ) ),
210 aFLMatSpecular ( this, SVX_RES( FL_MAT_SPECULAR ) ),
211 aFtMatSpecular ( this, SVX_RES( FT_MAT_SPECULAR ) ),
212 aLbMatSpecular ( this, SVX_RES( LB_MAT_SPECULAR ) ),
213 aBtnSpecularColor ( this, SVX_RES( BTN_SPECULAR_COLOR ) ),
214 aFtMatSpecularIntensity( this, SVX_RES( FT_MAT_SPECULAR_INTENSITY ) ),
215 aMtrMatSpecularIntensity( this, SVX_RES( MTR_MAT_SPECULAR_INTENSITY ) ),
216 aCtlPreview ( this, SVX_RES( CTL_PREVIEW ) ),
217 aCtlLightPreview ( this, SVX_RES( CTL_LIGHT_PREVIEW ) ),
219 // Lower Range
220 aBtnConvertTo3D ( this, SVX_RES( BTN_CHANGE_TO_3D ) ),
221 aBtnLatheObject ( this, SVX_RES( BTN_LATHE_OBJ ) ),
222 aBtnPerspective ( this, SVX_RES( BTN_PERSPECTIVE ) ),
224 aImgLightOn ( SVX_RES( RID_SVXIMAGE_LIGHT_ON ) ),
225 aImgLightOff ( SVX_RES( RID_SVXIMAGE_LIGHT_OFF ) ),
227 bUpdate ( sal_False ),
228 eViewType ( VIEWTYPE_GEO ),
230 pModel ( NULL ),
231 pFmPage ( NULL ),
232 pVDev ( NULL ),
233 p3DView ( NULL ),
235 pBindings ( pInBindings ),
236 pControllerItem(0L),
237 pConvertTo3DItem(0L),
238 pConvertTo3DLatheItem(0L),
239 mpImpl ( new Svx3DWinImpl() ),
240 mpRemember2DAttributes(NULL),
241 bOnly3DChanged ( sal_False )
243 String accname(SVX_RES(RID_SVXFLOAT3D_COLOR_LIGHT_PRE));
244 aCtlLightPreview.SetAccessibleName(accname);
245 aCtlPreview.SetAccessibleName(accname);
246 aLbAmbientlight.SetAccessibleName(aFTAmbientlight.GetDisplayText());
248 mpImpl->pPool = NULL;
249 FreeResource();
251 // Set Metric
252 eFUnit = pInBindings->GetDispatcher()->GetModule()->GetFieldUnit();
254 aMtrDepth.SetUnit( eFUnit );
255 aMtrDistance.SetUnit( eFUnit );
256 aMtrFocalLength.SetUnit( eFUnit );
258 pControllerItem = new Svx3DCtrlItem(SID_3D_STATE, this, pBindings);
259 pConvertTo3DItem = new SvxConvertTo3DItem(SID_CONVERT_TO_3D, pBindings);
260 pConvertTo3DLatheItem = new SvxConvertTo3DItem(SID_CONVERT_TO_3D_LATHE_FAST, pBindings);
262 aBtnAssign.SetClickHdl( LINK( this, Svx3DWin, ClickAssignHdl ) );
263 aBtnUpdate.SetClickHdl( LINK( this, Svx3DWin, ClickUpdateHdl ) );
265 Link aLink( LINK( this, Svx3DWin, ClickViewTypeHdl ) );
266 aBtnGeo.SetClickHdl( aLink );
267 aBtnRepresentation.SetClickHdl( aLink );
268 aBtnLight.SetClickHdl( aLink );
269 aBtnTexture.SetClickHdl( aLink );
270 aBtnMaterial.SetClickHdl( aLink );
272 aLink = LINK( this, Svx3DWin, ClickHdl );
273 aBtnPerspective.SetClickHdl( aLink );
274 aBtnConvertTo3D.SetClickHdl( aLink );
275 aBtnLatheObject.SetClickHdl( aLink );
277 // Geometry
278 aBtnNormalsObj.SetClickHdl( aLink );
279 aBtnNormalsFlat.SetClickHdl( aLink );
280 aBtnNormalsSphere.SetClickHdl( aLink );
281 aBtnTwoSidedLighting.SetClickHdl( aLink );
282 aBtnNormalsInvert.SetClickHdl( aLink );
283 aBtnDoubleSided.SetClickHdl( aLink );
285 // Representation
286 aBtnShadow3d.SetClickHdl( aLink );
288 // Lighting
289 aBtnLight1.SetClickHdl( aLink );
290 aBtnLight2.SetClickHdl( aLink );
291 aBtnLight3.SetClickHdl( aLink );
292 aBtnLight4.SetClickHdl( aLink );
293 aBtnLight5.SetClickHdl( aLink );
294 aBtnLight6.SetClickHdl( aLink );
295 aBtnLight7.SetClickHdl( aLink );
296 aBtnLight8.SetClickHdl( aLink );
298 // Textures
299 aBtnTexLuminance.SetClickHdl( aLink );
300 aBtnTexColor.SetClickHdl( aLink );
301 aBtnTexReplace.SetClickHdl( aLink );
302 aBtnTexModulate.SetClickHdl( aLink );
303 aBtnTexParallelX.SetClickHdl( aLink );
304 aBtnTexCircleX.SetClickHdl( aLink );
305 aBtnTexObjectX.SetClickHdl( aLink );
306 aBtnTexParallelY.SetClickHdl( aLink );
307 aBtnTexCircleY.SetClickHdl( aLink );
308 aBtnTexObjectY.SetClickHdl( aLink );
309 aBtnTexFilter.SetClickHdl( aLink );
311 // Material
312 aLink = LINK( this, Svx3DWin, ClickColorHdl );
313 aBtnLightColor.SetClickHdl( aLink );
314 aBtnAmbientColor.SetClickHdl( aLink );
315 aBtnMatColor.SetClickHdl( aLink );
316 aBtnEmissionColor.SetClickHdl( aLink );
317 aBtnSpecularColor.SetClickHdl( aLink );
320 aLink = LINK( this, Svx3DWin, SelectHdl );
321 aLbMatFavorites.SetSelectHdl( aLink );
322 aLbMatColor.SetSelectHdl( aLink );
323 aLbMatEmission.SetSelectHdl( aLink );
324 aLbMatSpecular.SetSelectHdl( aLink );
325 aLbLight1.SetSelectHdl( aLink );
326 aLbLight2.SetSelectHdl( aLink );
327 aLbLight3.SetSelectHdl( aLink );
328 aLbLight4.SetSelectHdl( aLink );
329 aLbLight5.SetSelectHdl( aLink );
330 aLbLight6.SetSelectHdl( aLink );
331 aLbLight7.SetSelectHdl( aLink );
332 aLbLight8.SetSelectHdl( aLink );
333 aLbAmbientlight.SetSelectHdl( aLink );
334 aLbShademode.SetSelectHdl( aLink );
336 aLink = LINK( this, Svx3DWin, ModifyHdl );
337 aMtrMatSpecularIntensity.SetModifyHdl( aLink );
338 aNumHorizontal.SetModifyHdl( aLink );
339 aNumVertical.SetModifyHdl( aLink );
340 aMtrSlant.SetModifyHdl( aLink );
342 // Preview callback
343 aLink = LINK( this, Svx3DWin, ChangeLightCallbackHdl );
344 aCtlLightPreview.SetUserInteractiveChangeCallback(aLink);
345 aLink = LINK( this, Svx3DWin, ChangeSelectionCallbackHdl );
346 aCtlLightPreview.SetUserSelectionChangeCallback(aLink);
348 aSize = GetOutputSizePixel();
349 SetMinOutputSizePixel( aSize );
351 Construct();
353 // Initiation of the initialization of the ColorLBs
354 SfxDispatcher* pDispatcher = LocalGetDispatcher(pBindings);
355 if (pDispatcher != NULL)
357 SfxBoolItem aItem( SID_3D_INIT, sal_True );
358 pDispatcher->Execute(
359 SID_3D_INIT, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
362 Reset();
364 aBtnNormalsObj.SetAccessibleRelationMemberOf( &aFLNormals );
365 aBtnNormalsFlat.SetAccessibleRelationMemberOf( &aFLNormals );
366 aBtnNormalsSphere.SetAccessibleRelationMemberOf( &aFLNormals );
367 aBtnNormalsInvert.SetAccessibleRelationMemberOf( &aFLNormals );
368 aBtnTwoSidedLighting.SetAccessibleRelationMemberOf( &aFLNormals );
369 aBtnDoubleSided.SetAccessibleRelationMemberOf( &aFLNormals );
371 aBtnLight1.SetAccessibleRelationMemberOf( &aFLLight );
372 aBtnLight2.SetAccessibleRelationMemberOf( &aFLLight );
373 aBtnLight3.SetAccessibleRelationMemberOf( &aFLLight );
374 aBtnLight4.SetAccessibleRelationMemberOf( &aFLLight );
375 aBtnLight5.SetAccessibleRelationMemberOf( &aFLLight );
376 aBtnLight6.SetAccessibleRelationMemberOf( &aFLLight );
377 aBtnLight7.SetAccessibleRelationMemberOf( &aFLLight );
378 aBtnLight8.SetAccessibleRelationMemberOf( &aFLLight );
380 aBtnLight1.SetAccessibleRelationLabeledBy( &aFTLightsource );
381 aBtnLight2.SetAccessibleRelationLabeledBy( &aFTLightsource );
382 aBtnLight3.SetAccessibleRelationLabeledBy( &aFTLightsource );
383 aBtnLight4.SetAccessibleRelationLabeledBy( &aFTLightsource );
384 aBtnLight5.SetAccessibleRelationLabeledBy( &aFTLightsource );
385 aBtnLight6.SetAccessibleRelationLabeledBy( &aFTLightsource );
386 aBtnLight7.SetAccessibleRelationLabeledBy( &aFTLightsource );
387 aBtnLight8.SetAccessibleRelationLabeledBy( &aFTLightsource );
388 aBtnLightColor.SetAccessibleRelationMemberOf( &aFLLight );
389 aBtnLightColor.SetAccessibleRelationLabeledBy( &aFTLightsource );
390 aBtnAmbientColor.SetAccessibleRelationMemberOf( &aFLLight );
391 aBtnAmbientColor.SetAccessibleRelationLabeledBy( &aFTAmbientlight );
393 aBtnSpecularColor.SetAccessibleRelationLabeledBy( &aFtMatSpecular );
394 aBtnMatColor.SetAccessibleRelationLabeledBy( &aFtMatColor );
395 aBtnEmissionColor.SetAccessibleRelationLabeledBy( &aFtMatEmission );
396 aBtnTexLuminance.SetAccessibleRelationLabeledBy( &aFtTexKind );
397 aBtnTexColor.SetAccessibleRelationLabeledBy( &aFtTexKind );
398 aBtnTexReplace.SetAccessibleRelationLabeledBy( &aFtTexMode );
399 aBtnTexModulate.SetAccessibleRelationLabeledBy( &aFtTexMode );
400 aBtnTexBlend.SetAccessibleRelationLabeledBy( &aFtTexMode );
401 aBtnTexObjectX.SetAccessibleRelationLabeledBy( &aFtTexProjectionX );
402 aBtnTexParallelX.SetAccessibleRelationLabeledBy( &aFtTexProjectionX );
403 aBtnTexCircleX.SetAccessibleRelationLabeledBy( &aFtTexProjectionX );
404 aBtnTexObjectY.SetAccessibleRelationLabeledBy( &aFtTexProjectionY );
405 aBtnTexParallelY.SetAccessibleRelationLabeledBy( &aFtTexProjectionY );
406 aBtnTexCircleY.SetAccessibleRelationLabeledBy( &aFtTexProjectionY );
407 aBtnTexFilter.SetAccessibleRelationLabeledBy( &aFtTexFilter );
408 aCtlLightPreview.SetAccessibleRelationLabeledBy( &aCtlLightPreview );
409 aBtnNormalsObj.SetAccessibleRelationMemberOf(&aFLNormals);
410 aBtnNormalsFlat.SetAccessibleRelationMemberOf(&aFLNormals);
411 aBtnNormalsSphere.SetAccessibleRelationMemberOf(&aFLNormals);
412 aBtnNormalsInvert.SetAccessibleRelationMemberOf(&aFLNormals);
413 aBtnTwoSidedLighting.SetAccessibleRelationMemberOf(&aFLNormals);
415 aBtnShadow3d.SetAccessibleRelationMemberOf(&aFLShadow);
417 aBtnLight1.SetAccessibleRelationMemberOf(&aFLLight);
418 aBtnLight2.SetAccessibleRelationMemberOf(&aFLLight);
419 aBtnLight3.SetAccessibleRelationMemberOf(&aFLLight);
420 aBtnLight4.SetAccessibleRelationMemberOf(&aFLLight);
421 aBtnLight5.SetAccessibleRelationMemberOf(&aFLLight);
422 aBtnLight6.SetAccessibleRelationMemberOf(&aFLLight);
423 aBtnLight7.SetAccessibleRelationMemberOf(&aFLLight);
424 aBtnLight8.SetAccessibleRelationMemberOf(&aFLLight);
426 aBtnTexLuminance.SetAccessibleRelationMemberOf(&aFLTexture);
427 aBtnTexColor.SetAccessibleRelationMemberOf(&aFLTexture);
428 aBtnTexReplace.SetAccessibleRelationMemberOf(&aFLTexture);
429 aBtnTexModulate.SetAccessibleRelationMemberOf(&aFLTexture);
430 aBtnTexBlend.SetAccessibleRelationMemberOf(&aFLTexture);
431 aBtnTexObjectX.SetAccessibleRelationMemberOf(&aFLTexture);
432 aBtnTexParallelX.SetAccessibleRelationMemberOf(&aFLTexture);
433 aBtnTexCircleX.SetAccessibleRelationMemberOf(&aFLTexture);
434 aBtnTexObjectY.SetAccessibleRelationMemberOf(&aFLTexture);
435 aBtnTexParallelY.SetAccessibleRelationMemberOf(&aFLTexture);
436 aBtnTexCircleY.SetAccessibleRelationMemberOf(&aFLTexture);
437 aBtnTexFilter.SetAccessibleRelationMemberOf(&aFLTexture);
439 aBtnMatColor.SetAccessibleRelationMemberOf(&aFLMaterial);
440 aBtnEmissionColor.SetAccessibleRelationMemberOf(&aFLMaterial);
442 aBtnSpecularColor.SetAccessibleRelationMemberOf(&aFLMatSpecular);
445 // -----------------------------------------------------------------------
446 Svx3DWin::~Svx3DWin()
448 delete p3DView;
449 delete pVDev;
450 delete pModel;
452 delete pControllerItem;
453 delete pConvertTo3DItem;
454 delete pConvertTo3DLatheItem;
456 delete mpRemember2DAttributes;
458 delete mpImpl;
461 // -----------------------------------------------------------------------
462 void Svx3DWin::Construct()
464 aBtnGeo.Check();
465 Link aLink( LINK( this, Svx3DWin, ClickViewTypeHdl ) );
466 aLink.Call( &aBtnGeo );
467 aCtlLightPreview.Hide();
470 // -----------------------------------------------------------------------
471 void Svx3DWin::Reset()
473 // Various initializations, default is AllAttributes
474 aLbShademode.SelectEntryPos( 0 );
475 aMtrMatSpecularIntensity.SetValue( 50 );
477 aBtnLight1.Check();
478 ClickUpdateHdl( NULL );
480 // Select nothing, to avoid errors when selecting the first
481 aCtlLightPreview.GetSvx3DLightControl().SelectLight(0);
484 bool Svx3DWin::GetUILightState( const ImageButton& rBtn ) const
486 return (rBtn.GetModeImage() == aImgLightOn);
489 void Svx3DWin::SetUILightState( ImageButton& aBtn, bool bState )
491 aBtn.SetModeImage( bState ? aImgLightOn : aImgLightOff );
494 // -----------------------------------------------------------------------
495 void Svx3DWin::Update( SfxItemSet& rAttrs )
497 // remember 2d attributes
498 if(mpRemember2DAttributes)
499 mpRemember2DAttributes->ClearItem();
500 else
501 mpRemember2DAttributes = new SfxItemSet(*rAttrs.GetPool(),
502 SDRATTR_START, SDRATTR_SHADOW_LAST,
503 SDRATTR_3D_FIRST, SDRATTR_3D_LAST,
504 0, 0);
506 SfxWhichIter aIter(*mpRemember2DAttributes);
507 sal_uInt16 nWhich(aIter.FirstWhich());
509 while(nWhich)
511 SfxItemState eState = rAttrs.GetItemState(nWhich, sal_False);
512 if(SFX_ITEM_DONTCARE == eState)
513 mpRemember2DAttributes->InvalidateItem(nWhich);
514 else if(SFX_ITEM_SET == eState)
515 mpRemember2DAttributes->Put(rAttrs.Get(nWhich, sal_False));
517 nWhich = aIter.NextWhich();
520 // construct field values
521 const SfxPoolItem* pItem;
523 // Possible determine PoolUnit
524 if( !mpImpl->pPool )
526 mpImpl->pPool = rAttrs.GetPool();
527 DBG_ASSERT( mpImpl->pPool, "Where is the Pool? ");
528 ePoolUnit = mpImpl->pPool->GetMetric( SID_ATTR_LINE_WIDTH );
530 eFUnit = GetModuleFieldUnit( rAttrs );
533 // Segment Number Can be changed? and other states
534 SfxItemState eState = rAttrs.GetItemState( SID_ATTR_3D_INTERN, sal_False, &pItem );
535 if( SFX_ITEM_SET == eState )
537 sal_uInt32 nState = ( ( const SfxUInt32Item* )pItem )->GetValue();
538 sal_Bool bExtrude = (sal_Bool) ( nState & 2 );
539 sal_Bool bSphere = (sal_Bool) ( nState & 4 );
540 sal_Bool bCube = (sal_Bool) ( nState & 8 );
542 sal_Bool bChart = (sal_Bool) ( nState & 32 ); // Chart
544 if( !bChart )
546 // For cube objects are no segments set
547 aFtHorizontal.Enable( !bCube );
548 aNumHorizontal.Enable( !bCube );
549 aFtVertical.Enable( !bCube );
550 aNumVertical.Enable( !bCube );
551 aFLSegments.Enable( !bCube );
553 aFtPercentDiagonal.Enable( !bCube && !bSphere );
554 aMtrPercentDiagonal.Enable( !bCube && !bSphere );
555 aFtBackscale.Enable( !bCube && !bSphere );
556 aMtrBackscale.Enable( !bCube && !bSphere );
557 aFtDepth.Enable( !bCube && !bSphere );
558 aMtrDepth.Enable( !bCube && !bSphere );
559 if( bCube )
561 aNumHorizontal.SetEmptyFieldValue();
562 aNumVertical.SetEmptyFieldValue();
564 if( bCube || bSphere )
566 aMtrPercentDiagonal.SetEmptyFieldValue();
567 aMtrBackscale.SetEmptyFieldValue();
568 aMtrDepth.SetEmptyFieldValue();
571 // There is a final angle only for Lathe objects.
572 aFtEndAngle.Enable( !bExtrude && !bCube && !bSphere );
573 aMtrEndAngle.Enable( !bExtrude && !bCube && !bSphere );
574 if( bExtrude || bCube || bSphere )
575 aMtrEndAngle.SetEmptyFieldValue();
577 else
579 // Geometry
580 aFtHorizontal.Enable( sal_False );
581 aNumHorizontal.Enable( sal_False );
582 aNumHorizontal.SetEmptyFieldValue();
583 aFtVertical.Enable( sal_False );
584 aNumVertical.Enable( sal_False );
585 aNumVertical.SetEmptyFieldValue();
586 aFLSegments.Enable( sal_False );
587 aFtEndAngle.Enable( sal_False );
588 aMtrEndAngle.Enable( sal_False );
589 aMtrEndAngle.SetEmptyFieldValue();
590 aFtDepth.Enable( sal_False );
591 aMtrDepth.Enable( sal_False );
592 aMtrDepth.SetEmptyFieldValue();
594 // Representation
595 aBtnShadow3d.Enable( sal_False );
596 aFtSlant.Enable( sal_False );
597 aMtrSlant.Enable( sal_False );
598 aFLShadow.Enable( sal_False );
600 aFtDistance.Enable( sal_False );
601 aMtrDistance.Enable( sal_False );
602 aMtrDistance.SetEmptyFieldValue();
603 aFtFocalLeng.Enable( sal_False );
604 aMtrFocalLength.Enable( sal_False );
605 aMtrFocalLength.SetEmptyFieldValue();
606 aFLCamera.Enable( sal_False );
608 //Lower Range
609 aBtnConvertTo3D.Enable( sal_False );
610 aBtnLatheObject.Enable( sal_False );
613 // Bitmap fill ? -> Status
614 sal_Bool bBitmap(sal_False);
615 eState = rAttrs.GetItemState(XATTR_FILLSTYLE);
616 if(eState != SFX_ITEM_DONTCARE)
618 XFillStyle eXFS = (XFillStyle)((const XFillStyleItem&)rAttrs.Get(XATTR_FILLSTYLE)).GetValue();
619 bBitmap = (eXFS == XFILL_BITMAP || eXFS == XFILL_GRADIENT || eXFS == XFILL_HATCH);
622 aFtTexKind.Enable( bBitmap );
623 aBtnTexLuminance.Enable( bBitmap );
624 aBtnTexColor.Enable( bBitmap );
625 aFtTexMode.Enable( bBitmap );
626 aBtnTexReplace.Enable( bBitmap );
627 aBtnTexModulate.Enable( bBitmap );
628 aBtnTexBlend.Enable( bBitmap );
629 aFtTexProjectionX.Enable( bBitmap );
630 aBtnTexParallelX.Enable( bBitmap );
631 aBtnTexCircleX.Enable( bBitmap );
632 aBtnTexObjectX.Enable( bBitmap );
633 aFtTexProjectionY.Enable( bBitmap );
634 aBtnTexParallelY.Enable( bBitmap );
635 aBtnTexCircleY.Enable( bBitmap );
636 aBtnTexObjectY.Enable( bBitmap );
637 aFtTexFilter.Enable( bBitmap );
638 aBtnTexFilter.Enable( bBitmap );
639 aFLTexture.Enable( bBitmap );
642 // Geometry
643 // Number of segments (horizontal)
644 if( aNumHorizontal.IsEnabled() )
646 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_HORZ_SEGS);
647 if(eState != SFX_ITEM_DONTCARE)
649 sal_uInt32 nValue = ((const Svx3DHorizontalSegmentsItem&)rAttrs.Get(SDRATTR_3DOBJ_HORZ_SEGS)).GetValue();
650 if(nValue != (sal_uInt32 )aNumHorizontal.GetValue())
652 aNumHorizontal.SetValue( nValue );
653 bUpdate = sal_True;
655 else if( aNumHorizontal.IsEmptyFieldValue() )
656 aNumHorizontal.SetValue( nValue );
658 else
660 if( !aNumHorizontal.IsEmptyFieldValue() )
662 aNumHorizontal.SetEmptyFieldValue();
663 bUpdate = sal_True;
668 //Number of segments (vertical)
669 if( aNumVertical.IsEnabled() )
671 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_VERT_SEGS);
672 if( eState != SFX_ITEM_DONTCARE )
674 sal_uInt32 nValue = ((const Svx3DVerticalSegmentsItem&)rAttrs.Get(SDRATTR_3DOBJ_VERT_SEGS)).GetValue();
675 if( nValue != (sal_uInt32) aNumVertical.GetValue() )
677 aNumVertical.SetValue( nValue );
678 bUpdate = sal_True;
680 else if( aNumVertical.IsEmptyFieldValue() )
681 aNumVertical.SetValue( nValue );
683 else
685 if( !aNumVertical.IsEmptyFieldValue() )
687 aNumVertical.SetEmptyFieldValue();
688 bUpdate = sal_True;
693 // Depth
694 if( aMtrDepth.IsEnabled() )
696 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_DEPTH);
697 if( eState != SFX_ITEM_DONTCARE )
699 sal_uInt32 nValue = ((const Svx3DDepthItem&)rAttrs.Get(SDRATTR_3DOBJ_DEPTH)).GetValue();
700 sal_uInt32 nValue2 = GetCoreValue( aMtrDepth, ePoolUnit );
701 if( nValue != nValue2 )
703 if( eFUnit != aMtrDepth.GetUnit() )
704 SetFieldUnit( aMtrDepth, eFUnit );
706 SetMetricValue( aMtrDepth, nValue, ePoolUnit );
707 bUpdate = sal_True;
709 else if( aMtrDepth.IsEmptyFieldValue() )
710 aMtrDepth.SetValue( aMtrDepth.GetValue() );
712 else
714 if( !aMtrDepth.IsEmptyFieldValue() )
716 aMtrDepth.SetEmptyFieldValue();
717 bUpdate = sal_True;
722 // Double walled / Double sided
723 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_DOUBLE_SIDED);
724 if( eState != SFX_ITEM_DONTCARE )
726 sal_Bool bValue = ((const Svx3DDoubleSidedItem&)rAttrs.Get(SDRATTR_3DOBJ_DOUBLE_SIDED)).GetValue();
727 if( bValue != aBtnDoubleSided.IsChecked() )
729 aBtnDoubleSided.Check( bValue );
730 bUpdate = sal_True;
732 else if( aBtnDoubleSided.GetState() == STATE_DONTKNOW )
733 aBtnDoubleSided.Check( bValue );
735 else
737 if( aBtnDoubleSided.GetState() != STATE_DONTKNOW )
739 aBtnDoubleSided.SetState( STATE_DONTKNOW );
740 bUpdate = sal_True;
744 // Edge rounding
745 if( aMtrPercentDiagonal.IsEnabled() )
747 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_PERCENT_DIAGONAL);
748 if( eState != SFX_ITEM_DONTCARE )
750 sal_uInt16 nValue = ((const Svx3DPercentDiagonalItem&)rAttrs.Get(SDRATTR_3DOBJ_PERCENT_DIAGONAL)).GetValue();
751 if( nValue != aMtrPercentDiagonal.GetValue() )
753 aMtrPercentDiagonal.SetValue( nValue );
754 bUpdate = sal_True;
756 else if( aMtrPercentDiagonal.IsEmptyFieldValue() )
757 aMtrPercentDiagonal.SetValue( nValue );
759 else
761 if( !aMtrPercentDiagonal.IsEmptyFieldValue() )
763 aMtrPercentDiagonal.SetEmptyFieldValue();
764 bUpdate = sal_True;
769 // Depth scaling
770 if( aMtrBackscale.IsEnabled() )
772 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_BACKSCALE);
773 if( eState != SFX_ITEM_DONTCARE )
775 sal_uInt16 nValue = ((const Svx3DBackscaleItem&)rAttrs.Get(SDRATTR_3DOBJ_BACKSCALE)).GetValue();
776 if( nValue != aMtrBackscale.GetValue() )
778 aMtrBackscale.SetValue( nValue );
779 bUpdate = sal_True;
781 else if( aMtrBackscale.IsEmptyFieldValue() )
782 aMtrBackscale.SetValue( nValue );
784 else
786 if( !aMtrBackscale.IsEmptyFieldValue() )
788 aMtrBackscale.SetEmptyFieldValue();
789 bUpdate = sal_True;
794 // End angle
795 if( aMtrEndAngle.IsEnabled() )
797 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_END_ANGLE);
798 if( eState != SFX_ITEM_DONTCARE )
800 sal_Int32 nValue = ((const Svx3DEndAngleItem&)rAttrs.Get(SDRATTR_3DOBJ_END_ANGLE)).GetValue();
801 if( nValue != aMtrEndAngle.GetValue() )
803 aMtrEndAngle.SetValue( nValue );
804 bUpdate = sal_True;
807 else
809 if( !aMtrEndAngle.IsEmptyFieldValue() )
811 aMtrEndAngle.SetEmptyFieldValue();
812 bUpdate = sal_True;
817 // Normal type
818 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_NORMALS_KIND);
819 if( eState != SFX_ITEM_DONTCARE )
821 sal_uInt16 nValue = ((const Svx3DNormalsKindItem&)rAttrs.Get(SDRATTR_3DOBJ_NORMALS_KIND)).GetValue();
823 if( ( !aBtnNormalsObj.IsChecked() && nValue == 0 ) ||
824 ( !aBtnNormalsFlat.IsChecked() && nValue == 1 ) ||
825 ( !aBtnNormalsSphere.IsChecked() && nValue == 2 ) )
827 aBtnNormalsObj.Check( nValue == 0 );
828 aBtnNormalsFlat.Check( nValue == 1 );
829 aBtnNormalsSphere.Check( nValue == 2 );
830 bUpdate = sal_True;
833 else
835 if( aBtnNormalsObj.IsChecked() ||
836 aBtnNormalsFlat.IsChecked() ||
837 aBtnNormalsSphere.IsChecked() )
839 aBtnNormalsObj.Check( sal_False );
840 aBtnNormalsFlat.Check( sal_False );
841 aBtnNormalsSphere.Check( sal_False );
842 bUpdate = sal_True;
846 // Normal inverted
847 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_NORMALS_INVERT);
848 if( eState != SFX_ITEM_DONTCARE )
850 sal_Bool bValue = ((const Svx3DNormalsInvertItem&)rAttrs.Get(SDRATTR_3DOBJ_NORMALS_INVERT)).GetValue();
851 if( bValue != aBtnNormalsInvert.IsChecked() )
853 aBtnNormalsInvert.Check( bValue );
854 bUpdate = sal_True;
856 else if( aBtnNormalsInvert.GetState() == STATE_DONTKNOW )
857 aBtnNormalsInvert.Check( bValue );
859 else
861 if( aBtnNormalsInvert.GetState() != STATE_DONTKNOW )
863 aBtnNormalsInvert.SetState( STATE_DONTKNOW );
864 bUpdate = sal_True;
868 // 2-sided lighting
869 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_TWO_SIDED_LIGHTING);
870 if( eState != SFX_ITEM_DONTCARE )
872 sal_Bool bValue = ((const Svx3DTwoSidedLightingItem&)rAttrs.Get(SDRATTR_3DSCENE_TWO_SIDED_LIGHTING)).GetValue();
873 if( bValue != aBtnTwoSidedLighting.IsChecked() )
875 aBtnTwoSidedLighting.Check( bValue );
876 bUpdate = sal_True;
878 else if( aBtnTwoSidedLighting.GetState() == STATE_DONTKNOW )
879 aBtnTwoSidedLighting.Check( bValue );
881 else
883 if( aBtnTwoSidedLighting.GetState() != STATE_DONTKNOW )
885 aBtnTwoSidedLighting.SetState( STATE_DONTKNOW );
886 bUpdate = sal_True;
890 // Representation
891 // Shademode
892 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_SHADE_MODE);
893 if( eState != SFX_ITEM_DONTCARE )
895 sal_uInt16 nValue = ((const Svx3DShadeModeItem&)rAttrs.Get(SDRATTR_3DSCENE_SHADE_MODE)).GetValue();
896 if( nValue != aLbShademode.GetSelectEntryPos() )
898 aLbShademode.SelectEntryPos( nValue );
899 bUpdate = sal_True;
902 else
904 if( aLbShademode.GetSelectEntryCount() != 0 )
906 aLbShademode.SetNoSelection();
907 bUpdate = sal_True;
911 // 3D-Shadow
912 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_SHADOW_3D);
913 if( eState != SFX_ITEM_DONTCARE )
915 sal_Bool bValue = ((const Svx3DShadow3DItem&)rAttrs.Get(SDRATTR_3DOBJ_SHADOW_3D)).GetValue();
916 if( bValue != aBtnShadow3d.IsChecked() )
918 aBtnShadow3d.Check( bValue );
919 aFtSlant.Enable( bValue );
920 aMtrSlant.Enable( bValue );
921 bUpdate = sal_True;
923 else if( aBtnShadow3d.GetState() == STATE_DONTKNOW )
924 aBtnShadow3d.Check( bValue );
926 else
928 if( aBtnShadow3d.GetState() != STATE_DONTKNOW )
930 aBtnShadow3d.SetState( STATE_DONTKNOW );
931 bUpdate = sal_True;
935 // Inclination (Shadow)
936 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_SHADOW_SLANT);
937 if( eState != SFX_ITEM_DONTCARE )
939 sal_uInt16 nValue = ((const Svx3DShadowSlantItem&)rAttrs.Get(SDRATTR_3DSCENE_SHADOW_SLANT)).GetValue();
940 if( nValue != aMtrSlant.GetValue() )
942 aMtrSlant.SetValue( nValue );
943 bUpdate = sal_True;
946 else
948 if( !aMtrSlant.IsEmptyFieldValue() )
950 aMtrSlant.SetEmptyFieldValue();
951 bUpdate = sal_True;
955 // Distance
956 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_DISTANCE);
957 if( eState != SFX_ITEM_DONTCARE )
959 sal_uInt32 nValue = ((const Svx3DDistanceItem&)rAttrs.Get(SDRATTR_3DSCENE_DISTANCE)).GetValue();
960 sal_uInt32 nValue2 = GetCoreValue( aMtrDistance, ePoolUnit );
961 if( nValue != nValue2 )
963 if( eFUnit != aMtrDistance.GetUnit() )
964 SetFieldUnit( aMtrDistance, eFUnit );
966 SetMetricValue( aMtrDistance, nValue, ePoolUnit );
967 bUpdate = sal_True;
970 else
972 if( !aMtrDepth.IsEmptyFieldValue() )
974 aMtrDepth.SetEmptyFieldValue();
975 bUpdate = sal_True;
979 // Focal length
980 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_FOCAL_LENGTH);
981 if( eState != SFX_ITEM_DONTCARE )
983 sal_uInt32 nValue = ((const Svx3DFocalLengthItem&)rAttrs.Get(SDRATTR_3DSCENE_FOCAL_LENGTH)).GetValue();
984 sal_uInt32 nValue2 = GetCoreValue( aMtrFocalLength, ePoolUnit );
985 if( nValue != nValue2 )
987 if( eFUnit != aMtrFocalLength.GetUnit() )
988 SetFieldUnit( aMtrFocalLength, eFUnit );
990 SetMetricValue( aMtrFocalLength, nValue, ePoolUnit );
991 bUpdate = sal_True;
994 else
996 if( !aMtrFocalLength.IsEmptyFieldValue() )
998 aMtrFocalLength.SetEmptyFieldValue();
999 bUpdate = sal_True;
1003 // Lighting
1004 Color aColor;
1005 basegfx::B3DVector aVector;
1006 // Light 1 (Color)
1007 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_1);
1008 if( eState != SFX_ITEM_DONTCARE )
1010 aColor = ((const Svx3DLightcolor1Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_1)).GetValue();
1011 ColorLB* pLb = &aLbLight1;
1012 if( aColor != pLb->GetSelectEntryColor() )
1014 LBSelectColor( pLb, aColor );
1015 bUpdate = sal_True;
1018 else
1020 if( aLbLight1.GetSelectEntryCount() != 0 )
1022 aLbLight1.SetNoSelection();
1023 bUpdate = sal_True;
1026 // Light 1 (on/off)
1027 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_1);
1028 if( eState != SFX_ITEM_DONTCARE )
1030 bool bOn = ((const Svx3DLightOnOff1Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_1)).GetValue() != 0;
1031 if( ( bOn && !GetUILightState( aBtnLight1 )) ||
1032 ( !bOn && GetUILightState( aBtnLight1 )) )
1034 SetUILightState( aBtnLight1, bOn );
1035 bUpdate = sal_True;
1037 if( aBtnLight1.GetState() == STATE_DONTKNOW )
1038 aBtnLight1.Check( aBtnLight1.IsChecked() );
1040 else
1042 if( aBtnLight1.GetState() != STATE_DONTKNOW )
1044 aBtnLight1.SetState( STATE_DONTKNOW );
1045 bUpdate = sal_True;
1048 // Light 1 (direction)
1049 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_1);
1050 if( eState != SFX_ITEM_DONTCARE )
1052 bUpdate = sal_True;
1055 //Light 2 (color)
1056 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_2);
1057 if( eState != SFX_ITEM_DONTCARE )
1059 aColor = ((const Svx3DLightcolor2Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_2)).GetValue();
1060 ColorLB* pLb = &aLbLight2;
1061 if( aColor != pLb->GetSelectEntryColor() )
1063 LBSelectColor( pLb, aColor );
1064 bUpdate = sal_True;
1067 else
1069 if( aLbLight2.GetSelectEntryCount() != 0 )
1071 aLbLight2.SetNoSelection();
1072 bUpdate = sal_True;
1075 // Light 2 (on/off)
1076 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_2);
1077 if( eState != SFX_ITEM_DONTCARE )
1079 bool bOn = ((const Svx3DLightOnOff2Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_2)).GetValue() != 0;
1080 if( ( bOn && !GetUILightState( aBtnLight2 )) ||
1081 ( !bOn && GetUILightState( aBtnLight2 )) )
1083 SetUILightState( aBtnLight2, bOn );
1084 bUpdate = sal_True;
1086 if( aBtnLight2.GetState() == STATE_DONTKNOW )
1087 aBtnLight2.Check( aBtnLight2.IsChecked() );
1089 else
1091 if( aBtnLight2.GetState() != STATE_DONTKNOW )
1093 aBtnLight2.SetState( STATE_DONTKNOW );
1094 bUpdate = sal_True;
1097 //Light 2 (Direction)
1098 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_2);
1099 if( eState != SFX_ITEM_DONTCARE )
1101 bUpdate = sal_True;
1104 //Light 3 (color)
1105 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_3);
1106 if( eState != SFX_ITEM_DONTCARE )
1108 aColor = ((const Svx3DLightcolor3Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_3)).GetValue();
1109 ColorLB* pLb = &aLbLight3;
1110 if( aColor != pLb->GetSelectEntryColor() )
1112 LBSelectColor( pLb, aColor );
1113 bUpdate = sal_True;
1116 else
1118 if( aLbLight3.GetSelectEntryCount() != 0 )
1120 aLbLight3.SetNoSelection();
1121 bUpdate = sal_True;
1124 // Ligh 3 (on/off)
1125 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_3);
1126 if( eState != SFX_ITEM_DONTCARE )
1128 bool bOn = ((const Svx3DLightOnOff3Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_3)).GetValue() != 0;
1129 if( ( bOn && !GetUILightState( aBtnLight3)) ||
1130 ( !bOn && GetUILightState( aBtnLight3)) )
1132 SetUILightState( aBtnLight3, bOn );
1133 bUpdate = sal_True;
1135 if( aBtnLight3.GetState() == STATE_DONTKNOW )
1136 aBtnLight3.Check( aBtnLight3.IsChecked() );
1138 else
1140 if( aBtnLight3.GetState() != STATE_DONTKNOW )
1142 aBtnLight3.SetState( STATE_DONTKNOW );
1143 bUpdate = sal_True;
1146 // Light 3 (Direction)
1147 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_3);
1148 if( eState != SFX_ITEM_DONTCARE )
1150 bUpdate = sal_True;
1153 // Light 4 (Color)
1154 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_4);
1155 if( eState != SFX_ITEM_DONTCARE )
1157 aColor = ((const Svx3DLightcolor4Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_4)).GetValue();
1158 ColorLB* pLb = &aLbLight4;
1159 if( aColor != pLb->GetSelectEntryColor() )
1161 LBSelectColor( pLb, aColor );
1162 bUpdate = sal_True;
1165 else
1167 if( aLbLight4.GetSelectEntryCount() != 0 )
1169 aLbLight4.SetNoSelection();
1170 bUpdate = sal_True;
1173 // Light 4 (on/off)
1174 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_4);
1175 if( eState != SFX_ITEM_DONTCARE )
1177 bool bOn = ((const Svx3DLightOnOff4Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_4)).GetValue() != 0;
1178 if( ( bOn && !GetUILightState( aBtnLight4 )) ||
1179 ( !bOn && GetUILightState( aBtnLight4 )) )
1181 SetUILightState( aBtnLight4, bOn );
1182 bUpdate = sal_True;
1184 if( aBtnLight4.GetState() == STATE_DONTKNOW )
1185 aBtnLight4.Check( aBtnLight4.IsChecked() );
1187 else
1189 if( aBtnLight4.GetState() != STATE_DONTKNOW )
1191 aBtnLight4.SetState( STATE_DONTKNOW );
1192 bUpdate = sal_True;
1195 // Light 4 (direction)
1196 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_4);
1197 if( eState != SFX_ITEM_DONTCARE )
1199 bUpdate = sal_True;
1202 // Light 5 (color)
1203 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_5);
1204 if( eState != SFX_ITEM_DONTCARE )
1206 aColor = ((const Svx3DLightcolor5Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_5)).GetValue();
1207 ColorLB* pLb = &aLbLight5;
1208 if( aColor != pLb->GetSelectEntryColor() )
1210 LBSelectColor( pLb, aColor );
1211 bUpdate = sal_True;
1214 else
1216 if( aLbLight5.GetSelectEntryCount() != 0 )
1218 aLbLight5.SetNoSelection();
1219 bUpdate = sal_True;
1222 // Light 5 (on/off)
1223 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_5);
1224 if( eState != SFX_ITEM_DONTCARE )
1226 bool bOn = ((const Svx3DLightOnOff5Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_5)).GetValue() != 0;
1227 if( ( bOn && !GetUILightState( aBtnLight5 )) ||
1228 ( !bOn && GetUILightState( aBtnLight5 )) )
1230 SetUILightState( aBtnLight5, bOn );
1231 bUpdate = sal_True;
1233 if( aBtnLight5.GetState() == STATE_DONTKNOW )
1234 aBtnLight5.Check( aBtnLight5.IsChecked() );
1236 else
1238 if( aBtnLight5.GetState() != STATE_DONTKNOW )
1240 aBtnLight5.SetState( STATE_DONTKNOW );
1241 bUpdate = sal_True;
1244 // Light 5 (direction)
1245 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_5);
1246 if( eState != SFX_ITEM_DONTCARE )
1248 bUpdate = sal_True;
1251 // Light 6 (color)
1252 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_6);
1253 if( eState != SFX_ITEM_DONTCARE )
1255 aColor = ((const Svx3DLightcolor6Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_6)).GetValue();
1256 ColorLB* pLb = &aLbLight6;
1257 if( aColor != pLb->GetSelectEntryColor() )
1259 LBSelectColor( pLb, aColor );
1260 bUpdate = sal_True;
1263 else
1265 if( aLbLight6.GetSelectEntryCount() != 0 )
1267 aLbLight6.SetNoSelection();
1268 bUpdate = sal_True;
1271 // Light 6 (on/off)
1272 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_6);
1273 if( eState != SFX_ITEM_DONTCARE )
1275 bool bOn = ((const Svx3DLightOnOff6Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_6)).GetValue() != 0;
1276 if( ( bOn && !GetUILightState( aBtnLight6 )) ||
1277 ( !bOn && GetUILightState( aBtnLight6 )) )
1279 SetUILightState( aBtnLight6, bOn );
1280 bUpdate = sal_True;
1282 if( aBtnLight6.GetState() == STATE_DONTKNOW )
1283 aBtnLight6.Check( aBtnLight6.IsChecked() );
1285 else
1287 if( aBtnLight6.GetState() != STATE_DONTKNOW )
1289 aBtnLight6.SetState( STATE_DONTKNOW );
1290 bUpdate = sal_True;
1293 // Light 6 (direction)
1294 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_6);
1295 if( eState != SFX_ITEM_DONTCARE )
1297 bUpdate = sal_True;
1300 // Light 7 (color)
1301 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_7);
1302 if( eState != SFX_ITEM_DONTCARE )
1304 aColor = ((const Svx3DLightcolor7Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_7)).GetValue();
1305 ColorLB* pLb = &aLbLight7;
1306 if( aColor != pLb->GetSelectEntryColor() )
1308 LBSelectColor( pLb, aColor );
1309 bUpdate = sal_True;
1312 else
1314 if( aLbLight7.GetSelectEntryCount() != 0 )
1316 aLbLight7.SetNoSelection();
1317 bUpdate = sal_True;
1320 // Light 7 (on/off)
1321 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_7);
1322 if( eState != SFX_ITEM_DONTCARE )
1324 bool bOn = ((const Svx3DLightOnOff7Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_7)).GetValue() != 0;
1325 if( ( bOn && !GetUILightState( aBtnLight7 )) ||
1326 ( !bOn && GetUILightState( aBtnLight7 )) )
1328 SetUILightState( aBtnLight7 , bOn );
1329 bUpdate = sal_True;
1331 if( aBtnLight7.GetState() == STATE_DONTKNOW )
1332 aBtnLight7.Check( aBtnLight7.IsChecked() );
1334 else
1336 if( aBtnLight7.GetState() != STATE_DONTKNOW )
1338 aBtnLight7.SetState( STATE_DONTKNOW );
1339 bUpdate = sal_True;
1342 // Light 7 (direction)
1343 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_7);
1344 if( eState != SFX_ITEM_DONTCARE )
1346 bUpdate = sal_True;
1349 // Light 8 (color)
1350 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_8);
1351 if( eState != SFX_ITEM_DONTCARE )
1353 aColor = ((const Svx3DLightcolor8Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_8)).GetValue();
1354 ColorLB* pLb = &aLbLight8;
1355 if( aColor != pLb->GetSelectEntryColor() )
1357 LBSelectColor( pLb, aColor );
1358 bUpdate = sal_True;
1361 else
1363 if( aLbLight8.GetSelectEntryCount() != 0 )
1365 aLbLight8.SetNoSelection();
1366 bUpdate = sal_True;
1369 // Light 8 (on/off)
1370 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_8);
1371 if( eState != SFX_ITEM_DONTCARE )
1373 bool bOn = ((const Svx3DLightOnOff8Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_8)).GetValue() != 0;
1374 if( ( bOn && !GetUILightState( aBtnLight8 )) ||
1375 ( !bOn && GetUILightState( aBtnLight8 )) )
1377 SetUILightState( aBtnLight8, bOn );
1378 bUpdate = sal_True;
1380 if( aBtnLight8.GetState() == STATE_DONTKNOW )
1381 aBtnLight8.Check( aBtnLight8.IsChecked() );
1383 else
1385 if( aBtnLight8.GetState() != STATE_DONTKNOW )
1387 aBtnLight8.SetState( STATE_DONTKNOW );
1388 bUpdate = sal_True;
1391 // Light 8 (direction)
1392 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_8);
1393 if( eState != SFX_ITEM_DONTCARE )
1395 bUpdate = sal_True;
1398 // Ambient light
1399 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_AMBIENTCOLOR);
1400 if( eState != SFX_ITEM_DONTCARE )
1402 aColor = ((const Svx3DAmbientcolorItem&)rAttrs.Get(SDRATTR_3DSCENE_AMBIENTCOLOR)).GetValue();
1403 ColorLB* pLb = &aLbAmbientlight;
1404 if( aColor != pLb->GetSelectEntryColor() )
1406 LBSelectColor( pLb, aColor );
1407 bUpdate = sal_True;
1410 else
1412 if( aLbAmbientlight.GetSelectEntryCount() != 0 )
1414 aLbAmbientlight.SetNoSelection();
1415 bUpdate = sal_True;
1420 // Textures
1421 // Art
1422 if( bBitmap )
1424 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_TEXTURE_KIND);
1425 if( eState != SFX_ITEM_DONTCARE )
1427 sal_uInt16 nValue = ((const Svx3DTextureKindItem&)rAttrs.Get(SDRATTR_3DOBJ_TEXTURE_KIND)).GetValue();
1429 if( ( !aBtnTexLuminance.IsChecked() && nValue == 1 ) ||
1430 ( !aBtnTexColor.IsChecked() && nValue == 3 ) )
1432 aBtnTexLuminance.Check( nValue == 1 );
1433 aBtnTexColor.Check( nValue == 3 );
1434 bUpdate = sal_True;
1437 else
1439 if( aBtnTexLuminance.IsChecked() ||
1440 aBtnTexColor.IsChecked() )
1442 aBtnTexLuminance.Check( sal_False );
1443 aBtnTexColor.Check( sal_False );
1444 bUpdate = sal_True;
1448 // Mode
1449 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_TEXTURE_MODE);
1450 if( eState != SFX_ITEM_DONTCARE )
1452 sal_uInt16 nValue = ((const Svx3DTextureModeItem&)rAttrs.Get(SDRATTR_3DOBJ_TEXTURE_MODE)).GetValue();
1454 if( ( !aBtnTexReplace.IsChecked() && nValue == 1 ) ||
1455 ( !aBtnTexModulate.IsChecked() && nValue == 2 ) )
1457 aBtnTexReplace.Check( nValue == 1 );
1458 aBtnTexModulate.Check( nValue == 2 );
1459 bUpdate = sal_True;
1462 else
1464 if( aBtnTexReplace.IsChecked() ||
1465 aBtnTexModulate.IsChecked() )
1467 aBtnTexReplace.Check( sal_False );
1468 aBtnTexModulate.Check( sal_False );
1469 bUpdate = sal_True;
1473 // Projection X
1474 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_TEXTURE_PROJ_X);
1475 if( eState != SFX_ITEM_DONTCARE )
1477 sal_uInt16 nValue = ((const Svx3DTextureProjectionXItem&)rAttrs.Get(SDRATTR_3DOBJ_TEXTURE_PROJ_X)).GetValue();
1479 if( ( !aBtnTexObjectX.IsChecked() && nValue == 0 ) ||
1480 ( !aBtnTexParallelX.IsChecked() && nValue == 1 ) ||
1481 ( !aBtnTexCircleX.IsChecked() && nValue == 2 ) )
1483 aBtnTexObjectX.Check( nValue == 0 );
1484 aBtnTexParallelX.Check( nValue == 1 );
1485 aBtnTexCircleX.Check( nValue == 2 );
1486 bUpdate = sal_True;
1489 else
1491 if( aBtnTexObjectX.IsChecked() ||
1492 aBtnTexParallelX.IsChecked() ||
1493 aBtnTexCircleX.IsChecked() )
1495 aBtnTexObjectX.Check( sal_False );
1496 aBtnTexParallelX.Check( sal_False );
1497 aBtnTexCircleX.Check( sal_False );
1498 bUpdate = sal_True;
1502 // Projection Y
1503 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_TEXTURE_PROJ_Y);
1504 if( eState != SFX_ITEM_DONTCARE )
1506 sal_uInt16 nValue = ((const Svx3DTextureProjectionYItem&)rAttrs.Get(SDRATTR_3DOBJ_TEXTURE_PROJ_Y)).GetValue();
1508 if( ( !aBtnTexObjectY.IsChecked() && nValue == 0 ) ||
1509 ( !aBtnTexParallelY.IsChecked() && nValue == 1 ) ||
1510 ( !aBtnTexCircleY.IsChecked() && nValue == 2 ) )
1512 aBtnTexObjectY.Check( nValue == 0 );
1513 aBtnTexParallelY.Check( nValue == 1 );
1514 aBtnTexCircleY.Check( nValue == 2 );
1515 bUpdate = sal_True;
1518 else
1520 if( aBtnTexObjectY.IsChecked() ||
1521 aBtnTexParallelY.IsChecked() ||
1522 aBtnTexCircleY.IsChecked() )
1524 aBtnTexObjectY.Check( sal_False );
1525 aBtnTexParallelY.Check( sal_False );
1526 aBtnTexCircleY.Check( sal_False );
1527 bUpdate = sal_True;
1531 // Filter
1532 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_TEXTURE_FILTER);
1533 if( eState != SFX_ITEM_DONTCARE )
1535 sal_Bool bValue = ((const Svx3DTextureFilterItem&)rAttrs.Get(SDRATTR_3DOBJ_TEXTURE_FILTER)).GetValue();
1536 if( bValue != aBtnTexFilter.IsChecked() )
1538 aBtnTexFilter.Check( bValue );
1539 bUpdate = sal_True;
1541 if( aBtnTexFilter.GetState() == STATE_DONTKNOW )
1542 aBtnTexFilter.Check( bValue );
1544 else
1546 if( aBtnTexFilter.GetState() != STATE_DONTKNOW )
1548 aBtnTexFilter.SetState( STATE_DONTKNOW );
1549 bUpdate = sal_True;
1555 // Material Favorites
1556 aLbMatFavorites.SelectEntryPos( 0 );
1558 // Object color
1559 eState = rAttrs.GetItemState(XATTR_FILLCOLOR);
1560 if( eState != SFX_ITEM_DONTCARE )
1562 aColor = ((const XFillColorItem&)rAttrs.Get(XATTR_FILLCOLOR)).GetColorValue();
1563 ColorLB* pLb = &aLbMatColor;
1564 if( aColor != pLb->GetSelectEntryColor() )
1566 LBSelectColor( pLb, aColor );
1567 bUpdate = sal_True;
1570 else
1572 if( aLbMatColor.GetSelectEntryCount() != 0 )
1574 aLbMatColor.SetNoSelection();
1575 bUpdate = sal_True;
1579 // Self-luminous color
1580 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_MAT_EMISSION);
1581 if( eState != SFX_ITEM_DONTCARE )
1583 aColor = ((const Svx3DMaterialEmissionItem&)rAttrs.Get(SDRATTR_3DOBJ_MAT_EMISSION)).GetValue();
1584 ColorLB* pLb = &aLbMatEmission;
1585 if( aColor != pLb->GetSelectEntryColor() )
1587 LBSelectColor( pLb, aColor );
1588 bUpdate = sal_True;
1591 else
1593 if( aLbMatEmission.GetSelectEntryCount() != 0 )
1595 aLbMatEmission.SetNoSelection();
1596 bUpdate = sal_True;
1600 // Specular
1601 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_MAT_SPECULAR);
1602 if( eState != SFX_ITEM_DONTCARE )
1604 aColor = ((const Svx3DMaterialSpecularItem&)rAttrs.Get(SDRATTR_3DOBJ_MAT_SPECULAR)).GetValue();
1605 ColorLB* pLb = &aLbMatSpecular;
1606 if( aColor != pLb->GetSelectEntryColor() )
1608 LBSelectColor( pLb, aColor );
1609 bUpdate = sal_True;
1612 else
1614 if( aLbMatSpecular.GetSelectEntryCount() != 0 )
1616 aLbMatSpecular.SetNoSelection();
1617 bUpdate = sal_True;
1621 // Specular Intensity
1622 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY);
1623 if( eState != SFX_ITEM_DONTCARE )
1625 sal_uInt16 nValue = ((const Svx3DMaterialSpecularIntensityItem&)rAttrs.Get(SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY)).GetValue();
1626 if( nValue != aMtrMatSpecularIntensity.GetValue() )
1628 aMtrMatSpecularIntensity.SetValue( nValue );
1629 bUpdate = sal_True;
1632 else
1634 if( !aMtrMatSpecularIntensity.IsEmptyFieldValue() )
1636 aMtrMatSpecularIntensity.SetEmptyFieldValue();
1637 bUpdate = sal_True;
1642 // Other
1643 // Perspective
1644 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_PERSPECTIVE);
1645 if( eState != SFX_ITEM_DONTCARE )
1647 ProjectionType ePT = (ProjectionType)((const Svx3DPerspectiveItem&)rAttrs.Get(SDRATTR_3DSCENE_PERSPECTIVE)).GetValue();
1648 if( ( !aBtnPerspective.IsChecked() && ePT == PR_PERSPECTIVE ) ||
1649 ( aBtnPerspective.IsChecked() && ePT == PR_PARALLEL ) )
1651 aBtnPerspective.Check( ePT == PR_PERSPECTIVE );
1652 bUpdate = sal_True;
1654 if( aBtnPerspective.GetState() == STATE_DONTKNOW )
1655 aBtnPerspective.Check( ePT == PR_PERSPECTIVE );
1657 else
1659 if( aBtnPerspective.GetState() != STATE_DONTKNOW )
1661 aBtnPerspective.SetState( STATE_DONTKNOW );
1662 bUpdate = sal_True;
1666 if( !bUpdate && !bOnly3DChanged )
1668 // however the 2D attributes may be different. Compare these and decide
1670 bUpdate = sal_True;
1673 if( bUpdate || bOnly3DChanged )
1675 // Update preview
1676 SfxItemSet aSet(rAttrs);
1678 // set LineStyle hard to XLINE_NONE when it's not set so that
1679 // the default (XLINE_SOLID) is not used for 3d preview
1680 if(SFX_ITEM_SET != aSet.GetItemState(XATTR_LINESTYLE, sal_False))
1681 aSet.Put(XLineStyleItem(XLINE_NONE));
1683 // set FillColor hard to WHITE when it's SFX_ITEM_DONTCARE so that
1684 // the default (Blue7) is not used for 3d preview
1685 if(SFX_ITEM_DONTCARE == aSet.GetItemState(XATTR_FILLCOLOR, sal_False))
1686 aSet.Put(XFillColorItem(String(), Color(COL_WHITE)));
1688 aCtlPreview.Set3DAttributes(aSet);
1689 aCtlLightPreview.GetSvx3DLightControl().Set3DAttributes(aSet);
1691 // try to select light corresponding to active button
1692 sal_uInt32 nNumber(0xffffffff);
1694 if(aBtnLight1.IsChecked())
1695 nNumber = 0;
1696 else if(aBtnLight2.IsChecked())
1697 nNumber = 1;
1698 else if(aBtnLight3.IsChecked())
1699 nNumber = 2;
1700 else if(aBtnLight4.IsChecked())
1701 nNumber = 3;
1702 else if(aBtnLight5.IsChecked())
1703 nNumber = 4;
1704 else if(aBtnLight6.IsChecked())
1705 nNumber = 5;
1706 else if(aBtnLight7.IsChecked())
1707 nNumber = 6;
1708 else if(aBtnLight8.IsChecked())
1709 nNumber = 7;
1711 if(nNumber != 0xffffffff)
1713 aCtlLightPreview.GetSvx3DLightControl().SelectLight(nNumber);
1717 // handle state of converts possible
1718 aBtnConvertTo3D.Enable(pConvertTo3DItem->GetState());
1719 aBtnLatheObject.Enable(pConvertTo3DLatheItem->GetState());
1722 // -----------------------------------------------------------------------
1723 void Svx3DWin::GetAttr( SfxItemSet& rAttrs )
1725 // get remembered 2d attributes from the dialog
1726 if(mpRemember2DAttributes)
1728 SfxWhichIter aIter(*mpRemember2DAttributes);
1729 sal_uInt16 nWhich(aIter.FirstWhich());
1731 while(nWhich)
1733 SfxItemState eState = mpRemember2DAttributes->GetItemState(nWhich, sal_False);
1734 if(SFX_ITEM_DONTCARE == eState)
1735 rAttrs.InvalidateItem(nWhich);
1736 else if(SFX_ITEM_SET == eState)
1737 rAttrs.Put(mpRemember2DAttributes->Get(nWhich, sal_False));
1739 nWhich = aIter.NextWhich();
1743 //Others must stand as the front on all sides
1744 // Perspective
1745 if( aBtnPerspective.GetState() != STATE_DONTKNOW )
1747 sal_uInt16 nValue;
1748 if( aBtnPerspective.IsChecked() )
1749 nValue = PR_PERSPECTIVE;
1750 else
1751 nValue = PR_PARALLEL;
1752 rAttrs.Put(Svx3DPerspectiveItem(nValue));
1754 else
1755 rAttrs.InvalidateItem(SDRATTR_3DSCENE_PERSPECTIVE);
1757 // Geometry
1758 // Possible determine PoolUnit (in this case this haas not happend in Update() )
1759 if( !mpImpl->pPool )
1761 OSL_FAIL( "No Pool in GetAttr()! May be incompatible to drviewsi.cxx ?" );
1762 mpImpl->pPool = rAttrs.GetPool();
1763 DBG_ASSERT( mpImpl->pPool, "Where is the Pool?" );
1764 ePoolUnit = mpImpl->pPool->GetMetric( SID_ATTR_LINE_WIDTH );
1766 eFUnit = GetModuleFieldUnit( rAttrs );
1769 // Number of segments (horizontal)
1770 if( !aNumHorizontal.IsEmptyFieldValue() )
1772 sal_uInt32 nValue = static_cast<sal_uInt32>(aNumHorizontal.GetValue());
1773 rAttrs.Put(Svx3DHorizontalSegmentsItem(nValue));
1775 else
1776 rAttrs.InvalidateItem(SDRATTR_3DOBJ_HORZ_SEGS);
1778 // Number of segments (vertical)
1779 if( !aNumVertical.IsEmptyFieldValue() )
1781 sal_uInt32 nValue = static_cast<sal_uInt32>(aNumVertical.GetValue());
1782 rAttrs.Put(Svx3DVerticalSegmentsItem(nValue));
1784 else
1785 rAttrs.InvalidateItem(SDRATTR_3DOBJ_VERT_SEGS);
1787 // Depth
1788 if( !aMtrDepth.IsEmptyFieldValue() )
1790 sal_uInt32 nValue = GetCoreValue( aMtrDepth, ePoolUnit );
1791 rAttrs.Put(Svx3DDepthItem(nValue));
1793 else
1794 rAttrs.InvalidateItem(SDRATTR_3DOBJ_DEPTH);
1796 // Double-sided
1797 TriState eState = aBtnDoubleSided.GetState();
1798 if( eState != STATE_DONTKNOW )
1800 sal_Bool bValue = STATE_CHECK == eState;
1801 rAttrs.Put(Svx3DDoubleSidedItem(bValue));
1803 else
1804 rAttrs.InvalidateItem(SDRATTR_3DOBJ_DOUBLE_SIDED);
1806 // Edge rounding
1807 if( !aMtrPercentDiagonal.IsEmptyFieldValue() )
1809 sal_uInt16 nValue = (sal_uInt16) aMtrPercentDiagonal.GetValue();
1810 rAttrs.Put(Svx3DPercentDiagonalItem(nValue));
1812 else
1813 rAttrs.InvalidateItem(SDRATTR_3DOBJ_PERCENT_DIAGONAL);
1815 // Depth scale
1816 if( !aMtrBackscale.IsEmptyFieldValue() )
1818 sal_uInt16 nValue = (sal_uInt16)aMtrBackscale.GetValue();
1819 rAttrs.Put(Svx3DBackscaleItem(nValue));
1821 else
1822 rAttrs.InvalidateItem(SDRATTR_3DOBJ_BACKSCALE);
1824 // End angle
1825 if( !aMtrEndAngle.IsEmptyFieldValue() )
1827 sal_uInt16 nValue = (sal_uInt16)aMtrEndAngle.GetValue();
1828 rAttrs.Put(Svx3DEndAngleItem(nValue));
1830 else
1831 rAttrs.InvalidateItem(SDRATTR_3DOBJ_END_ANGLE);
1833 // Normal type
1834 sal_uInt16 nValue = 99;
1835 if( aBtnNormalsObj.IsChecked() )
1836 nValue = 0;
1837 else if( aBtnNormalsFlat.IsChecked() )
1838 nValue = 1;
1839 else if( aBtnNormalsSphere.IsChecked() )
1840 nValue = 2;
1842 if( nValue <= 2 )
1843 rAttrs.Put(Svx3DNormalsKindItem(nValue));
1844 else
1845 rAttrs.InvalidateItem(SDRATTR_3DOBJ_NORMALS_KIND);
1847 // Normal inverted
1848 eState = aBtnNormalsInvert.GetState();
1849 if( eState != STATE_DONTKNOW )
1851 sal_Bool bValue = STATE_CHECK == eState;
1852 rAttrs.Put(Svx3DNormalsInvertItem(bValue));
1854 else
1855 rAttrs.InvalidateItem(SDRATTR_3DOBJ_NORMALS_INVERT);
1857 // 2-sided lighting
1858 eState = aBtnTwoSidedLighting.GetState();
1859 if( eState != STATE_DONTKNOW )
1861 sal_Bool bValue = STATE_CHECK == eState;
1862 rAttrs.Put(Svx3DTwoSidedLightingItem(bValue));
1864 else
1865 rAttrs.InvalidateItem(SDRATTR_3DSCENE_TWO_SIDED_LIGHTING);
1867 // Representation
1868 // Shade mode
1869 if( aLbShademode.GetSelectEntryCount() )
1871 nValue = aLbShademode.GetSelectEntryPos();
1872 rAttrs.Put(Svx3DShadeModeItem(nValue));
1874 else
1875 rAttrs.InvalidateItem(SDRATTR_3DSCENE_SHADE_MODE);
1877 // 3D-Shadow
1878 eState = aBtnShadow3d.GetState();
1879 if( eState != STATE_DONTKNOW )
1881 sal_Bool bValue = STATE_CHECK == eState;
1882 rAttrs.Put(Svx3DShadow3DItem(bValue));
1883 rAttrs.Put(SdrShadowItem(bValue));
1885 else
1887 rAttrs.InvalidateItem(SDRATTR_3DOBJ_SHADOW_3D);
1888 rAttrs.InvalidateItem(SDRATTR_SHADOW);
1891 // Slant (Shadow)
1892 if( !aMtrSlant.IsEmptyFieldValue() )
1894 sal_uInt16 nValue2 = (sal_uInt16) aMtrSlant.GetValue();
1895 rAttrs.Put(Svx3DShadowSlantItem(nValue2));
1897 else
1898 rAttrs.InvalidateItem(SDRATTR_3DSCENE_SHADOW_SLANT);
1900 // Distance
1901 if( !aMtrDistance.IsEmptyFieldValue() )
1903 sal_uInt32 nValue2 = GetCoreValue( aMtrDistance, ePoolUnit );
1904 rAttrs.Put(Svx3DDistanceItem(nValue2));
1906 else
1907 rAttrs.InvalidateItem(SDRATTR_3DSCENE_DISTANCE);
1909 // Focal length
1910 if( !aMtrFocalLength.IsEmptyFieldValue() )
1912 sal_uInt32 nValue2 = GetCoreValue( aMtrFocalLength, ePoolUnit );
1913 rAttrs.Put(Svx3DFocalLengthItem(nValue2));
1915 else
1916 rAttrs.InvalidateItem(SDRATTR_3DSCENE_FOCAL_LENGTH);
1918 // Lighting
1919 Image aImg;
1920 basegfx::B3DVector aVector;
1921 Color aColor;
1922 const SfxItemSet aLightItemSet(aCtlLightPreview.GetSvx3DLightControl().Get3DAttributes());
1924 // Light 1 color
1925 if( aLbLight1.GetSelectEntryCount() )
1927 aColor = aLbLight1.GetSelectEntryColor();
1928 rAttrs.Put(Svx3DLightcolor1Item(aColor));
1930 else
1931 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_1);
1932 // Light 1 (on/off)
1933 eState = aBtnLight1.GetState();
1934 if( eState != STATE_DONTKNOW )
1936 sal_Bool bValue = GetUILightState( aBtnLight1 );
1937 rAttrs.Put(Svx3DLightOnOff1Item(bValue));
1939 // Light 1 (direction)
1940 if( bValue )
1942 rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_1));
1945 else
1946 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_1);
1949 // Light 2 color
1950 if( aLbLight2.GetSelectEntryCount() )
1952 aColor = aLbLight2.GetSelectEntryColor();
1953 rAttrs.Put(Svx3DLightcolor2Item(aColor));
1955 else
1956 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_2);
1957 // Light 2 (on/off)
1958 eState = aBtnLight2.GetState();
1959 if( eState != STATE_DONTKNOW )
1961 sal_Bool bValue = GetUILightState( aBtnLight2 );
1962 rAttrs.Put(Svx3DLightOnOff2Item(bValue));
1964 // Light 2 (direction)
1965 if( bValue )
1967 rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_2));
1970 else
1971 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_2);
1973 // Light 3 color
1974 if( aLbLight3.GetSelectEntryCount() )
1976 aColor = aLbLight3.GetSelectEntryColor();
1977 rAttrs.Put(Svx3DLightcolor3Item(aColor));
1979 else
1980 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_3);
1981 // Light 3 (on/off)
1982 eState = aBtnLight3.GetState();
1983 if( eState != STATE_DONTKNOW )
1985 sal_Bool bValue = GetUILightState( aBtnLight3 );
1986 rAttrs.Put(Svx3DLightOnOff3Item(bValue));
1988 // Light 3 (direction)
1989 if( bValue )
1991 rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_3));
1994 else
1995 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_3);
1997 // Light 4 color
1998 if( aLbLight4.GetSelectEntryCount() )
2000 aColor = aLbLight4.GetSelectEntryColor();
2001 rAttrs.Put(Svx3DLightcolor4Item(aColor));
2003 else
2004 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_4);
2005 // Light 4 (on/off)
2006 eState = aBtnLight4.GetState();
2007 if( eState != STATE_DONTKNOW )
2009 sal_Bool bValue = GetUILightState( aBtnLight4 );
2010 rAttrs.Put(Svx3DLightOnOff4Item(bValue));
2012 // Light 4 (direction)
2013 if( bValue )
2015 rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_4));
2018 else
2019 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_4);
2021 // Light 5 color
2022 if( aLbLight5.GetSelectEntryCount() )
2024 aColor = aLbLight5.GetSelectEntryColor();
2025 rAttrs.Put(Svx3DLightcolor5Item(aColor));
2027 else
2028 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_5);
2029 // Light 5 (on/off)
2030 eState = aBtnLight5.GetState();
2031 if( eState != STATE_DONTKNOW )
2033 sal_Bool bValue = GetUILightState( aBtnLight5 );
2034 rAttrs.Put(Svx3DLightOnOff5Item(bValue));
2036 // Light 5 (direction)
2037 if( bValue )
2039 rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_5));
2042 else
2043 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_5);
2045 // Light 6 color
2046 if( aLbLight6.GetSelectEntryCount() )
2048 aColor = aLbLight6.GetSelectEntryColor();
2049 rAttrs.Put(Svx3DLightcolor6Item(aColor));
2051 else
2052 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_6);
2053 // Light 6 (on/off)
2054 eState = aBtnLight6.GetState();
2055 if( eState != STATE_DONTKNOW )
2057 sal_Bool bValue = GetUILightState( aBtnLight6 );
2058 rAttrs.Put(Svx3DLightOnOff6Item(bValue));
2060 // Light 6 (direction)
2061 if( bValue )
2063 rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_6));
2066 else
2067 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_6);
2069 // Light 7 color
2070 if( aLbLight7.GetSelectEntryCount() )
2072 aColor = aLbLight7.GetSelectEntryColor();
2073 rAttrs.Put(Svx3DLightcolor7Item(aColor));
2075 else
2076 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_7);
2077 // Light 7 (on/off)
2078 eState = aBtnLight7.GetState();
2079 if( eState != STATE_DONTKNOW )
2081 sal_Bool bValue = GetUILightState( aBtnLight7 );
2082 rAttrs.Put(Svx3DLightOnOff7Item(bValue));
2084 // Light 7 (direction)
2085 if( bValue )
2087 rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_7));
2090 else
2091 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_7);
2093 // Light 8 color
2094 if( aLbLight8.GetSelectEntryCount() )
2096 aColor = aLbLight8.GetSelectEntryColor();
2097 rAttrs.Put(Svx3DLightcolor8Item(aColor));
2099 else
2100 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_8);
2101 // Light 8 (on/off)
2102 eState = aBtnLight8.GetState();
2103 if( eState != STATE_DONTKNOW )
2105 sal_Bool bValue = GetUILightState( aBtnLight8 );
2106 rAttrs.Put(Svx3DLightOnOff8Item(bValue));
2108 // Light 8 (direction)
2109 if( bValue )
2111 rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_8));
2114 else
2115 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_8);
2117 // Ambient light
2118 if( aLbAmbientlight.GetSelectEntryCount() )
2120 aColor = aLbAmbientlight.GetSelectEntryColor();
2121 rAttrs.Put(Svx3DAmbientcolorItem(aColor));
2123 else
2124 rAttrs.InvalidateItem(SDRATTR_3DSCENE_AMBIENTCOLOR);
2126 // Textures
2127 // Art
2128 nValue = 3;
2129 if( aBtnTexLuminance.IsChecked() )
2130 nValue = 1;
2131 else if( aBtnTexColor.IsChecked() )
2132 nValue = 3;
2134 if( nValue == 1 || nValue == 3 )
2135 rAttrs.Put(Svx3DTextureKindItem(nValue));
2136 else
2137 rAttrs.InvalidateItem(SDRATTR_3DOBJ_TEXTURE_KIND);
2140 // Mode
2141 nValue = 99;
2142 if( aBtnTexReplace.IsChecked() )
2143 nValue = 1;
2144 else if( aBtnTexModulate.IsChecked() )
2145 nValue = 2;
2147 if( nValue == 1 || nValue == 2 )
2148 rAttrs.Put(Svx3DTextureModeItem(nValue));
2149 else
2150 rAttrs.InvalidateItem(SDRATTR_3DOBJ_TEXTURE_MODE);
2152 // X projection
2153 nValue = 99;
2154 if( aBtnTexObjectX.IsChecked() )
2155 nValue = 0;
2156 else if( aBtnTexParallelX.IsChecked() )
2157 nValue = 1;
2158 else if( aBtnTexCircleX.IsChecked() )
2159 nValue = 2;
2161 if( nValue <= 2 )
2162 rAttrs.Put(Svx3DTextureProjectionXItem(nValue));
2163 else
2164 rAttrs.InvalidateItem(SDRATTR_3DOBJ_TEXTURE_PROJ_X);
2166 // Y projection
2167 nValue = 99;
2168 if( aBtnTexObjectY.IsChecked() )
2169 nValue = 0;
2170 else if( aBtnTexParallelY.IsChecked() )
2171 nValue = 1;
2172 else if( aBtnTexCircleY.IsChecked() )
2173 nValue = 2;
2175 if( nValue <= 2 )
2176 rAttrs.Put(Svx3DTextureProjectionYItem(nValue));
2177 else
2178 rAttrs.InvalidateItem(SDRATTR_3DOBJ_TEXTURE_PROJ_Y);
2181 // Filter
2182 eState = aBtnTexFilter.GetState();
2183 if( eState != STATE_DONTKNOW )
2185 sal_Bool bValue = STATE_CHECK == eState;
2186 rAttrs.Put(Svx3DTextureFilterItem(bValue));
2188 else
2189 rAttrs.InvalidateItem(SDRATTR_3DOBJ_TEXTURE_FILTER);
2192 // Material
2193 // Object color
2194 if( aLbMatColor.GetSelectEntryCount() )
2196 aColor = aLbMatColor.GetSelectEntryColor();
2197 rAttrs.Put( XFillColorItem( String(), aColor) );
2199 else
2201 rAttrs.InvalidateItem( XATTR_FILLCOLOR );
2204 // luminous color
2205 if( aLbMatEmission.GetSelectEntryCount() )
2207 aColor = aLbMatEmission.GetSelectEntryColor();
2208 rAttrs.Put(Svx3DMaterialEmissionItem(aColor));
2210 else
2211 rAttrs.InvalidateItem(SDRATTR_3DOBJ_MAT_EMISSION);
2213 // Specular
2214 if( aLbMatSpecular.GetSelectEntryCount() )
2216 aColor = aLbMatSpecular.GetSelectEntryColor();
2217 rAttrs.Put(Svx3DMaterialSpecularItem(aColor));
2219 else
2220 rAttrs.InvalidateItem(SDRATTR_3DOBJ_MAT_SPECULAR);
2222 // Specular intensity
2223 if( !aMtrMatSpecularIntensity.IsEmptyFieldValue() )
2225 sal_uInt16 nValue2 = (sal_uInt16) aMtrMatSpecularIntensity.GetValue();
2226 rAttrs.Put(Svx3DMaterialSpecularIntensityItem(nValue2));
2228 else
2229 rAttrs.InvalidateItem(SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY);
2232 // -----------------------------------------------------------------------
2233 void Svx3DWin::Resize()
2235 if ( !IsFloatingMode() ||
2236 !GetFloatingWindow()->IsRollUp() )
2238 Size aWinSize( GetOutputSizePixel() ); // why rSize in Resizing()?
2240 if( aWinSize.Height() >= GetMinOutputSizePixel().Height() &&
2241 aWinSize.Width() >= GetMinOutputSizePixel().Width() )
2243 Size aDiffSize;
2244 aDiffSize.Width() = aWinSize.Width() - aSize.Width();
2245 aDiffSize.Height() = aWinSize.Height() - aSize.Height();
2247 Point aXPt;
2248 Point aYPt;
2249 aXPt.X() = aDiffSize.Width();
2250 aYPt.Y() = aDiffSize.Height();
2252 Size aObjSize;
2254 // Hide
2255 aBtnUpdate.Hide();
2256 aBtnAssign.Hide();
2258 aBtnConvertTo3D.Hide();
2259 aBtnLatheObject.Hide();
2260 aBtnPerspective.Hide();
2262 aCtlPreview.Hide();
2263 aCtlLightPreview.Hide();
2265 aFLGeometrie.Hide();
2266 aFLRepresentation.Hide();
2267 aFLLight.Hide();
2268 aFLTexture.Hide();
2269 aFLMaterial.Hide();
2271 // Moving / resizing
2272 aBtnUpdate.SetPosPixel( aBtnUpdate.GetPosPixel() + aXPt );
2273 aBtnAssign.SetPosPixel( aBtnAssign.GetPosPixel() + aXPt );
2275 // Preview controls
2276 aObjSize = aCtlPreview.GetOutputSizePixel();
2277 aObjSize.Width() += aDiffSize.Width();
2278 aObjSize.Height() += aDiffSize.Height();
2279 aCtlPreview.SetOutputSizePixel( aObjSize );
2280 aCtlLightPreview.SetOutputSizePixel( aObjSize );
2282 // Groups
2283 aObjSize = aFLGeometrie.GetOutputSizePixel();
2284 aObjSize.Width() += aDiffSize.Width();
2285 aFLGeometrie.SetOutputSizePixel( aObjSize );
2286 aFLSegments.SetOutputSizePixel( aObjSize );
2287 aFLShadow.SetOutputSizePixel( aObjSize );
2288 aFLCamera.SetOutputSizePixel( aObjSize );
2289 aFLRepresentation.SetOutputSizePixel( aObjSize );
2290 aFLLight.SetOutputSizePixel( aObjSize );
2291 aFLTexture.SetOutputSizePixel( aObjSize );
2292 aFLMaterial.SetOutputSizePixel( aObjSize );
2294 // Y-position of the lower buttons
2295 aBtnConvertTo3D.SetPosPixel( aBtnConvertTo3D.GetPosPixel() + aYPt );
2296 aBtnLatheObject.SetPosPixel( aBtnLatheObject.GetPosPixel() + aYPt );
2297 aBtnPerspective.SetPosPixel( aBtnPerspective.GetPosPixel() + aYPt );
2299 // Show
2300 aBtnUpdate.Show();
2301 aBtnAssign.Show();
2303 aBtnConvertTo3D.Show();
2304 aBtnLatheObject.Show();
2305 aBtnPerspective.Show();
2307 if( aBtnGeo.IsChecked() )
2308 ClickViewTypeHdl( &aBtnGeo );
2309 if( aBtnRepresentation.IsChecked() )
2310 ClickViewTypeHdl( &aBtnRepresentation );
2311 if( aBtnLight.IsChecked() )
2312 ClickViewTypeHdl( &aBtnLight );
2313 if( aBtnTexture.IsChecked() )
2314 ClickViewTypeHdl( &aBtnTexture );
2315 if( aBtnMaterial.IsChecked() )
2316 ClickViewTypeHdl( &aBtnMaterial );
2318 aSize = aWinSize;
2322 SfxDockingWindow::Resize();
2325 // -----------------------------------------------------------------------
2326 IMPL_LINK_NOARG(Svx3DWin, ClickUpdateHdl)
2328 bUpdate = !aBtnUpdate.IsChecked();
2329 aBtnUpdate.Check( bUpdate );
2331 if( bUpdate )
2333 SfxDispatcher* pDispatcher = LocalGetDispatcher(pBindings);
2334 if (pDispatcher != NULL)
2336 SfxBoolItem aItem( SID_3D_STATE, sal_True );
2337 pDispatcher->Execute(
2338 SID_3D_STATE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
2341 else
2343 // Controls can be disabled during certain circumstances
2346 return( 0L );
2349 // -----------------------------------------------------------------------
2350 IMPL_LINK_NOARG(Svx3DWin, ClickAssignHdl)
2352 SfxDispatcher* pDispatcher = LocalGetDispatcher(pBindings);
2353 if (pDispatcher != NULL)
2355 SfxBoolItem aItem( SID_3D_ASSIGN, sal_True );
2356 pDispatcher->Execute(
2357 SID_3D_ASSIGN, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
2360 return( 0L );
2363 // -----------------------------------------------------------------------
2365 IMPL_LINK( Svx3DWin, ClickViewTypeHdl, void *, pBtn )
2368 if( pBtn )
2370 // Since the permanent updating of the preview would be too expensive
2371 sal_Bool bUpdatePreview = aBtnLight.IsChecked();
2373 aBtnGeo.Check( &aBtnGeo == pBtn );
2374 aBtnRepresentation.Check( &aBtnRepresentation == pBtn );
2375 aBtnLight.Check( &aBtnLight == pBtn );
2376 aBtnTexture.Check( &aBtnTexture == pBtn );
2377 aBtnMaterial.Check( &aBtnMaterial == pBtn );
2379 if( aBtnGeo.IsChecked() )
2380 eViewType = VIEWTYPE_GEO;
2381 if( aBtnRepresentation.IsChecked() )
2382 eViewType = VIEWTYPE_REPRESENTATION;
2383 if( aBtnLight.IsChecked() )
2384 eViewType = VIEWTYPE_LIGHT;
2385 if( aBtnTexture.IsChecked() )
2386 eViewType = VIEWTYPE_TEXTURE;
2387 if( aBtnMaterial.IsChecked() )
2388 eViewType = VIEWTYPE_MATERIAL;
2390 // Geometry
2391 if( eViewType == VIEWTYPE_GEO )
2393 aFtHorizontal.Show();
2394 aNumHorizontal.Show();
2395 aFtVertical.Show();
2396 aNumVertical.Show();
2397 aFLSegments.Show();
2398 aFtPercentDiagonal.Show();
2399 aMtrPercentDiagonal.Show();
2400 aFtBackscale.Show();
2401 aMtrBackscale.Show();
2402 aFtEndAngle.Show();
2403 aMtrEndAngle.Show();
2404 aFtDepth.Show();
2405 aMtrDepth.Show();
2406 aFLGeometrie.Show();
2408 aBtnNormalsObj.Show();
2409 aBtnNormalsFlat.Show();
2410 aBtnNormalsSphere.Show();
2411 aBtnTwoSidedLighting.Show();
2412 aBtnNormalsInvert.Show();
2413 aFLNormals.Show();
2414 aBtnDoubleSided.Show();
2416 else
2418 aFtHorizontal.Hide();
2419 aNumHorizontal.Hide();
2420 aFtVertical.Hide();
2421 aNumVertical.Hide();
2422 aFLSegments.Hide();
2423 aFtPercentDiagonal.Hide();
2424 aMtrPercentDiagonal.Hide();
2425 aFtBackscale.Hide();
2426 aMtrBackscale.Hide();
2427 aFtEndAngle.Hide();
2428 aMtrEndAngle.Hide();
2429 aFtDepth.Hide();
2430 aMtrDepth.Hide();
2431 aFLGeometrie.Hide();
2433 aBtnNormalsObj.Hide();
2434 aBtnNormalsFlat.Hide();
2435 aBtnNormalsSphere.Hide();
2436 aBtnTwoSidedLighting.Hide();
2437 aBtnNormalsInvert.Hide();
2438 aFLNormals.Hide();
2439 aBtnDoubleSided.Hide();
2442 // Representation
2443 if( eViewType == VIEWTYPE_REPRESENTATION )
2445 aFtShademode.Show();
2446 aLbShademode.Show();
2447 aBtnShadow3d.Show();
2448 aFtSlant.Show();
2449 aMtrSlant.Show();
2450 aFLShadow.Show();
2451 aFtDistance.Show();
2452 aMtrDistance.Show();
2453 aFtFocalLeng.Show();
2454 aMtrFocalLength.Show();
2455 aFLCamera.Show();
2456 aFLRepresentation.Show();
2458 else
2460 aFtShademode.Hide();
2461 aLbShademode.Hide();
2462 aBtnShadow3d.Hide();
2463 aFtSlant.Hide();
2464 aMtrSlant.Hide();
2465 aFLShadow.Hide();
2466 aFtDistance.Hide();
2467 aMtrDistance.Hide();
2468 aFtFocalLeng.Hide();
2469 aMtrFocalLength.Hide();
2470 aFLCamera.Hide();
2471 aFLRepresentation.Hide();
2474 // Lighting
2475 if( eViewType == VIEWTYPE_LIGHT )
2477 aBtnLight1.Show();
2478 aBtnLight2.Show();
2479 aBtnLight3.Show();
2480 aBtnLight4.Show();
2481 aBtnLight5.Show();
2482 aBtnLight6.Show();
2483 aBtnLight7.Show();
2484 aBtnLight8.Show();
2485 aBtnLightColor.Show();
2486 aFTLightsource.Show();
2487 aLbAmbientlight.Show();
2488 aBtnAmbientColor.Show();
2489 aFTAmbientlight.Show();
2490 aFLLight.Show();
2492 ColorLB* pLb = GetLbByButton();
2493 if( pLb )
2494 pLb->Show();
2496 aCtlLightPreview.Show();
2497 aCtlPreview.Hide();
2499 else
2501 aBtnLight1.Hide();
2502 aBtnLight2.Hide();
2503 aBtnLight3.Hide();
2504 aBtnLight4.Hide();
2505 aBtnLight5.Hide();
2506 aBtnLight6.Hide();
2507 aBtnLight7.Hide();
2508 aBtnLight8.Hide();
2509 aLbLight1.Hide();
2510 aLbLight2.Hide();
2511 aLbLight3.Hide();
2512 aLbLight4.Hide();
2513 aLbLight5.Hide();
2514 aLbLight6.Hide();
2515 aLbLight7.Hide();
2516 aLbLight8.Hide();
2517 aBtnLightColor.Hide();
2518 aFTLightsource.Hide();
2519 aLbAmbientlight.Hide();
2520 aBtnAmbientColor.Hide();
2521 aFTAmbientlight.Hide();
2522 aFLLight.Hide();
2524 if( !aCtlPreview.IsVisible() )
2526 aCtlPreview.Show();
2527 aCtlLightPreview.Hide();
2531 // Textures
2532 if( eViewType == VIEWTYPE_TEXTURE )
2534 aFtTexKind.Show();
2535 aBtnTexLuminance.Show();
2536 aBtnTexColor.Show();
2537 aFtTexMode.Show();
2538 aBtnTexReplace.Show();
2539 aBtnTexModulate.Show();
2540 aFtTexProjectionX.Show();
2541 aBtnTexParallelX.Show();
2542 aBtnTexCircleX.Show();
2543 aBtnTexObjectX.Show();
2544 aFtTexProjectionY.Show();
2545 aBtnTexParallelY.Show();
2546 aBtnTexCircleY.Show();
2547 aBtnTexObjectY.Show();
2548 aFtTexFilter.Show();
2549 aBtnTexFilter.Show();
2550 aFLTexture.Show();
2552 else
2554 aFtTexKind.Hide();
2555 aBtnTexLuminance.Hide();
2556 aBtnTexColor.Hide();
2557 aFtTexMode.Hide();
2558 aBtnTexReplace.Hide();
2559 aBtnTexModulate.Hide();
2560 aBtnTexBlend.Hide();
2561 aFtTexProjectionX.Hide();
2562 aBtnTexParallelX.Hide();
2563 aBtnTexCircleX.Hide();
2564 aBtnTexObjectX.Hide();
2565 aFtTexProjectionY.Hide();
2566 aBtnTexParallelY.Hide();
2567 aBtnTexCircleY.Hide();
2568 aBtnTexObjectY.Hide();
2569 aFtTexFilter.Hide();
2570 aBtnTexFilter.Hide();
2571 aFLTexture.Hide();
2574 // Material
2575 if( eViewType == VIEWTYPE_MATERIAL )
2577 aFtMatFavorites.Show();
2578 aLbMatFavorites.Show();
2579 aFtMatColor.Show();
2580 aLbMatColor.Show();
2581 aBtnMatColor.Show();
2582 aFtMatEmission.Show();
2583 aLbMatEmission.Show();
2584 aBtnEmissionColor.Show();
2585 aFtMatSpecular.Show();
2586 aLbMatSpecular.Show();
2587 aBtnSpecularColor.Show();
2588 aFtMatSpecularIntensity.Show();
2589 aMtrMatSpecularIntensity.Show();
2590 aFLMatSpecular.Show();
2591 aFLMaterial.Show();
2593 else
2595 aFtMatFavorites.Hide();
2596 aLbMatFavorites.Hide();
2597 aFtMatColor.Hide();
2598 aLbMatColor.Hide();
2599 aBtnMatColor.Hide();
2600 aFtMatEmission.Hide();
2601 aLbMatEmission.Hide();
2602 aBtnEmissionColor.Hide();
2603 aFtMatSpecular.Hide();
2604 aLbMatSpecular.Hide();
2605 aBtnSpecularColor.Hide();
2606 aFtMatSpecularIntensity.Hide();
2607 aMtrMatSpecularIntensity.Hide();
2608 aFLMatSpecular.Hide();
2609 aFLMaterial.Hide();
2611 if( bUpdatePreview && !aBtnLight.IsChecked() )
2612 UpdatePreview();
2615 else
2617 aBtnGeo.Check( eViewType == VIEWTYPE_GEO );
2618 aBtnRepresentation.Check( eViewType == VIEWTYPE_REPRESENTATION );
2619 aBtnLight.Check( eViewType == VIEWTYPE_LIGHT );
2620 aBtnTexture.Check( eViewType == VIEWTYPE_TEXTURE );
2621 aBtnMaterial.Check( eViewType == VIEWTYPE_MATERIAL );
2623 return( 0L );
2626 // -----------------------------------------------------------------------
2627 IMPL_LINK( Svx3DWin, ClickHdl, PushButton *, pBtn )
2629 sal_Bool bUpdatePreview = sal_False;
2631 if( pBtn )
2633 sal_uInt16 nSId = 0;
2635 if( pBtn == &aBtnConvertTo3D )
2637 nSId = SID_CONVERT_TO_3D;
2639 else if( pBtn == &aBtnLatheObject )
2641 nSId = SID_CONVERT_TO_3D_LATHE_FAST;
2643 // Geometry
2644 else if( pBtn == &aBtnNormalsObj ||
2645 pBtn == &aBtnNormalsFlat ||
2646 pBtn == &aBtnNormalsSphere )
2648 aBtnNormalsObj.Check( pBtn == &aBtnNormalsObj );
2649 aBtnNormalsFlat.Check( pBtn == &aBtnNormalsFlat );
2650 aBtnNormalsSphere.Check( pBtn == &aBtnNormalsSphere );
2651 bUpdatePreview = sal_True;
2653 else if( pBtn == &aBtnLight1 ||
2654 pBtn == &aBtnLight2 ||
2655 pBtn == &aBtnLight3 ||
2656 pBtn == &aBtnLight4 ||
2657 pBtn == &aBtnLight5 ||
2658 pBtn == &aBtnLight6 ||
2659 pBtn == &aBtnLight7 ||
2660 pBtn == &aBtnLight8 )
2662 // Lighting
2663 ColorLB* pLb = GetLbByButton( pBtn );
2664 pLb->Show();
2666 if( pBtn->IsChecked() )
2668 SetUILightState( *(ImageButton*)pBtn, !GetUILightState( *(ImageButton*)pBtn ) );
2670 else
2672 pBtn->Check();
2674 if( pBtn != &aBtnLight1 && aBtnLight1.IsChecked() )
2676 aBtnLight1.Check( sal_False );
2677 aLbLight1.Hide();
2679 if( pBtn != &aBtnLight2 && aBtnLight2.IsChecked() )
2681 aBtnLight2.Check( sal_False );
2682 aLbLight2.Hide();
2684 if( pBtn != &aBtnLight3 && aBtnLight3.IsChecked() )
2686 aBtnLight3.Check( sal_False );
2687 aLbLight3.Hide();
2689 if( pBtn != &aBtnLight4 && aBtnLight4.IsChecked() )
2691 aBtnLight4.Check( sal_False );
2692 aLbLight4.Hide();
2694 if( pBtn != &aBtnLight5 && aBtnLight5.IsChecked() )
2696 aBtnLight5.Check( sal_False );
2697 aLbLight5.Hide();
2699 if( pBtn != &aBtnLight6 && aBtnLight6.IsChecked() )
2701 aBtnLight6.Check( sal_False );
2702 aLbLight6.Hide();
2704 if( pBtn != &aBtnLight7 && aBtnLight7.IsChecked() )
2706 aBtnLight7.Check( sal_False );
2707 aLbLight7.Hide();
2709 if( pBtn != &aBtnLight8 && aBtnLight8.IsChecked() )
2711 aBtnLight8.Check( sal_False );
2712 aLbLight8.Hide();
2715 sal_Bool bEnable = GetUILightState( *(ImageButton*)pBtn );
2716 aBtnLightColor.Enable( bEnable );
2717 pLb->Enable( bEnable );
2719 ClickLight(*pBtn);
2720 bUpdatePreview = sal_True;
2722 // Textures
2723 else if( pBtn == &aBtnTexLuminance ||
2724 pBtn == &aBtnTexColor )
2726 aBtnTexLuminance.Check( pBtn == &aBtnTexLuminance );
2727 aBtnTexColor.Check( pBtn == &aBtnTexColor );
2728 bUpdatePreview = sal_True;
2730 else if( pBtn == &aBtnTexReplace ||
2731 pBtn == &aBtnTexModulate )
2733 aBtnTexReplace.Check( pBtn == &aBtnTexReplace );
2734 aBtnTexModulate.Check( pBtn == &aBtnTexModulate );
2735 bUpdatePreview = sal_True;
2737 else if( pBtn == &aBtnTexParallelX ||
2738 pBtn == &aBtnTexCircleX ||
2739 pBtn == &aBtnTexObjectX )
2741 aBtnTexParallelX.Check( pBtn == &aBtnTexParallelX );
2742 aBtnTexCircleX.Check( pBtn == &aBtnTexCircleX );
2743 aBtnTexObjectX.Check( pBtn == &aBtnTexObjectX );
2744 bUpdatePreview = sal_True;
2746 else if( pBtn == &aBtnTexParallelY ||
2747 pBtn == &aBtnTexCircleY ||
2748 pBtn == &aBtnTexObjectY )
2750 aBtnTexParallelY.Check( pBtn == &aBtnTexParallelY );
2751 aBtnTexCircleY.Check( pBtn == &aBtnTexCircleY );
2752 aBtnTexObjectY.Check( pBtn == &aBtnTexObjectY );
2753 bUpdatePreview = sal_True;
2755 else if( pBtn == &aBtnShadow3d )
2757 pBtn->Check( !pBtn->IsChecked() );
2758 aFtSlant.Enable( pBtn->IsChecked() );
2759 aMtrSlant.Enable( pBtn->IsChecked() );
2760 bUpdatePreview = sal_True;
2762 // Other (no groups)
2763 else if( pBtn != NULL )
2765 pBtn->Check( !pBtn->IsChecked() );
2766 bUpdatePreview = sal_True;
2769 if( nSId > 0 )
2771 SfxDispatcher* pDispatcher = LocalGetDispatcher(pBindings);
2772 if (pDispatcher != NULL)
2774 SfxBoolItem aItem( nSId, sal_True );
2775 pDispatcher->Execute(
2776 nSId, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
2779 else if( bUpdatePreview == sal_True )
2780 UpdatePreview();
2782 return( 0L );
2785 //------------------------------------------------------------------------
2787 IMPL_LINK( Svx3DWin, ClickColorHdl, PushButton *, pBtn )
2789 SvColorDialog aColorDlg( this );
2790 ColorLB* pLb;
2792 if( pBtn == &aBtnLightColor )
2793 pLb = GetLbByButton();
2794 else if( pBtn == &aBtnAmbientColor )
2795 pLb = &aLbAmbientlight;
2796 else if( pBtn == &aBtnMatColor )
2797 pLb = &aLbMatColor;
2798 else if( pBtn == &aBtnEmissionColor )
2799 pLb = &aLbMatEmission;
2800 else // if( pBtn == &aBtnSpecularColor )
2801 pLb = &aLbMatSpecular;
2803 Color aColor = pLb->GetSelectEntryColor();
2805 aColorDlg.SetColor( aColor );
2806 if( aColorDlg.Execute() == RET_OK )
2808 aColor = aColorDlg.GetColor();
2809 if( LBSelectColor( pLb, aColor ) )
2810 SelectHdl( pLb );
2812 return( 0L );
2815 // -----------------------------------------------------------------------
2816 IMPL_LINK( Svx3DWin, SelectHdl, void *, p )
2818 if( p )
2820 Color aColor;
2821 sal_Bool bUpdatePreview = sal_False;
2823 // Material
2824 if( p == &aLbMatFavorites )
2826 Color aColObj( COL_WHITE );
2827 Color aColEmis( COL_BLACK );
2828 Color aColSpec( COL_WHITE );
2829 sal_uInt16 nSpecIntens = 20;
2831 sal_uInt16 nPos = aLbMatFavorites.GetSelectEntryPos();
2832 switch( nPos )
2834 case 1: // Metall
2836 aColObj = Color(230,230,255);
2837 aColEmis = Color(10,10,30);
2838 aColSpec = Color(200,200,200);
2839 nSpecIntens = 20;
2841 break;
2843 case 2: // Gold
2845 aColObj = Color(230,255,0);
2846 aColEmis = Color(51,0,0);
2847 aColSpec = Color(255,255,240);
2848 nSpecIntens = 20;
2850 break;
2852 case 3: // Chrome
2854 aColObj = Color(36,117,153);
2855 aColEmis = Color(18,30,51);
2856 aColSpec = Color(230,230,255);
2857 nSpecIntens = 2;
2859 break;
2861 case 4: // Plastic
2863 aColObj = Color(255,48,57);
2864 aColEmis = Color(35,0,0);
2865 aColSpec = Color(179,202,204);
2866 nSpecIntens = 60;
2868 break;
2870 case 5: // Wood
2872 aColObj = Color(153,71,1);
2873 aColEmis = Color(21,22,0);
2874 aColSpec = Color(255,255,153);
2875 nSpecIntens = 75;
2877 break;
2879 LBSelectColor( &aLbMatColor, aColObj );
2880 LBSelectColor( &aLbMatEmission, aColEmis );
2881 LBSelectColor( &aLbMatSpecular, aColSpec );
2882 aMtrMatSpecularIntensity.SetValue( nSpecIntens );
2884 bUpdatePreview = sal_True;
2886 else if( p == &aLbMatColor ||
2887 p == &aLbMatEmission ||
2888 p == &aLbMatSpecular )
2890 aLbMatFavorites.SelectEntryPos( 0 );
2891 bUpdatePreview = sal_True;
2893 // Lighting
2894 else if( p == &aLbAmbientlight )
2896 bUpdatePreview = sal_True;
2898 else if( p == &aLbLight1 ||
2899 p == &aLbLight2 ||
2900 p == &aLbLight3 ||
2901 p == &aLbLight4 ||
2902 p == &aLbLight5 ||
2903 p == &aLbLight6 ||
2904 p == &aLbLight7 ||
2905 p == &aLbLight8 )
2907 bUpdatePreview = sal_True;
2909 else if( p == &aLbShademode )
2910 bUpdatePreview = sal_True;
2912 if( bUpdatePreview == sal_True )
2913 UpdatePreview();
2915 return( 0L );
2918 // -----------------------------------------------------------------------
2919 IMPL_LINK( Svx3DWin, ModifyHdl, void*, pField )
2921 if( pField )
2923 sal_Bool bUpdatePreview = sal_False;
2925 // Material
2926 if( pField == &aMtrMatSpecularIntensity )
2928 bUpdatePreview = sal_True;
2930 else if( pField == &aNumHorizontal )
2932 bUpdatePreview = sal_True;
2934 else if( pField == &aNumVertical )
2936 bUpdatePreview = sal_True;
2938 else if( pField == &aMtrSlant )
2940 bUpdatePreview = sal_True;
2943 if( bUpdatePreview == sal_True )
2944 UpdatePreview();
2946 return( 0L );
2949 // -----------------------------------------------------------------------
2951 void Svx3DWin::ClickLight(PushButton& rBtn)
2953 sal_uInt16 nLightSource = GetLightSource( &rBtn );
2954 ColorLB* pLb = GetLbByButton( &rBtn );
2955 Color aColor( pLb->GetSelectEntryColor() );
2956 SfxItemSet aLightItemSet(aCtlLightPreview.GetSvx3DLightControl().Get3DAttributes());
2957 const bool bOnOff(GetUILightState( (const ImageButton&)rBtn ));
2959 switch(nLightSource)
2961 case 0: aLightItemSet.Put(Svx3DLightcolor1Item(aColor)); aLightItemSet.Put(Svx3DLightOnOff1Item(bOnOff)); break;
2962 case 1: aLightItemSet.Put(Svx3DLightcolor2Item(aColor)); aLightItemSet.Put(Svx3DLightOnOff2Item(bOnOff)); break;
2963 case 2: aLightItemSet.Put(Svx3DLightcolor3Item(aColor)); aLightItemSet.Put(Svx3DLightOnOff3Item(bOnOff)); break;
2964 case 3: aLightItemSet.Put(Svx3DLightcolor4Item(aColor)); aLightItemSet.Put(Svx3DLightOnOff4Item(bOnOff)); break;
2965 case 4: aLightItemSet.Put(Svx3DLightcolor5Item(aColor)); aLightItemSet.Put(Svx3DLightOnOff5Item(bOnOff)); break;
2966 case 5: aLightItemSet.Put(Svx3DLightcolor6Item(aColor)); aLightItemSet.Put(Svx3DLightOnOff6Item(bOnOff)); break;
2967 case 6: aLightItemSet.Put(Svx3DLightcolor7Item(aColor)); aLightItemSet.Put(Svx3DLightOnOff7Item(bOnOff)); break;
2968 default:
2969 case 7: aLightItemSet.Put(Svx3DLightcolor8Item(aColor)); aLightItemSet.Put(Svx3DLightOnOff8Item(bOnOff)); break;
2972 aCtlLightPreview.GetSvx3DLightControl().Set3DAttributes(aLightItemSet);
2973 aCtlLightPreview.GetSvx3DLightControl().SelectLight(nLightSource);
2974 aCtlLightPreview.CheckSelection();
2977 // -----------------------------------------------------------------------
2979 IMPL_LINK_NOARG(Svx3DWin, ChangeLightCallbackHdl)
2981 return( 0L );
2985 // -----------------------------------------------------------------------
2987 IMPL_LINK_NOARG(Svx3DWin, ChangeSelectionCallbackHdl)
2989 const sal_uInt32 nLight(aCtlLightPreview.GetSvx3DLightControl().GetSelectedLight());
2990 PushButton* pBtn = 0;
2992 switch( nLight )
2994 case 0: pBtn = &aBtnLight1; break;
2995 case 1: pBtn = &aBtnLight2; break;
2996 case 2: pBtn = &aBtnLight3; break;
2997 case 3: pBtn = &aBtnLight4; break;
2998 case 4: pBtn = &aBtnLight5; break;
2999 case 5: pBtn = &aBtnLight6; break;
3000 case 6: pBtn = &aBtnLight7; break;
3001 case 7: pBtn = &aBtnLight8; break;
3002 default: break;
3005 if( pBtn )
3006 ClickHdl( pBtn );
3007 else
3009 // Status: No lamp selected
3010 if( aBtnLight1.IsChecked() )
3012 aBtnLight1.Check( sal_False );
3013 aLbLight1.Enable( sal_False );
3015 else if( aBtnLight2.IsChecked() )
3017 aBtnLight2.Check( sal_False );
3018 aLbLight2.Enable( sal_False );
3020 else if( aBtnLight3.IsChecked() )
3022 aBtnLight3.Check( sal_False );
3023 aLbLight3.Enable( sal_False );
3025 else if( aBtnLight4.IsChecked() )
3027 aBtnLight4.Check( sal_False );
3028 aLbLight4.Enable( sal_False );
3030 else if( aBtnLight5.IsChecked() )
3032 aBtnLight5.Check( sal_False );
3033 aLbLight5.Enable( sal_False );
3035 else if( aBtnLight6.IsChecked() )
3037 aBtnLight6.Check( sal_False );
3038 aLbLight6.Enable( sal_False );
3040 else if( aBtnLight7.IsChecked() )
3042 aBtnLight7.Check( sal_False );
3043 aLbLight7.Enable( sal_False );
3045 else if( aBtnLight8.IsChecked() )
3047 aBtnLight8.Check( sal_False );
3048 aLbLight8.Enable( sal_False );
3050 aBtnLightColor.Enable( sal_False );
3053 return( 0L );
3056 // -----------------------------------------------------------------------
3057 // Method to ensure that the LB is also associated with a color
3058 // returns true if color was added
3059 // -----------------------------------------------------------------------
3060 sal_Bool Svx3DWin::LBSelectColor( ColorLB* pLb, const Color& rColor )
3062 sal_Bool bRet = sal_False;
3064 pLb->SetNoSelection();
3065 pLb->SelectEntry( rColor );
3066 if( pLb->GetSelectEntryCount() == 0 )
3068 String aStr(SVX_RES(RID_SVXFLOAT3D_FIX_R));
3070 aStr += String::CreateFromInt32((sal_Int32)rColor.GetRed());
3071 aStr += sal_Unicode(' ');
3072 aStr += String(SVX_RES(RID_SVXFLOAT3D_FIX_G));
3073 aStr += String::CreateFromInt32((sal_Int32)rColor.GetGreen());
3074 aStr += sal_Unicode(' ');
3075 aStr += String(SVX_RES(RID_SVXFLOAT3D_FIX_B));
3076 aStr += String::CreateFromInt32((sal_Int32)rColor.GetBlue());
3078 sal_uInt16 nPos = pLb->InsertEntry( rColor, aStr );
3079 pLb->SelectEntryPos( nPos );
3080 bRet = sal_True;
3082 return( bRet );
3085 // -----------------------------------------------------------------------
3086 void Svx3DWin::UpdatePreview()
3088 if( pModel == NULL )
3089 pModel = new FmFormModel();
3091 if(bOnly3DChanged)
3093 // Execute slot
3094 SfxDispatcher* pDispatcher = LocalGetDispatcher(pBindings);
3095 if (pDispatcher != NULL)
3097 SfxBoolItem aItem( SID_3D_STATE, sal_True );
3098 pDispatcher->Execute(
3099 SID_3D_STATE, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
3101 // Reset Flag
3102 bOnly3DChanged = sal_False;
3105 // Get Itemset
3106 SfxItemSet aSet( pModel->GetItemPool(), SDRATTR_START, SDRATTR_END);
3108 // Get Attributes and set the preview
3109 GetAttr( aSet );
3110 aCtlPreview.Set3DAttributes( aSet );
3111 aCtlLightPreview.GetSvx3DLightControl().Set3DAttributes( aSet );
3114 //////////////////////////////////////////////////////////////////////////////
3115 // document is to be reloaded, destroy remembered ItemSet
3116 void Svx3DWin::DocumentReload()
3118 delete mpRemember2DAttributes;
3119 mpRemember2DAttributes = 0L;
3122 // -----------------------------------------------------------------------
3123 void Svx3DWin::InitColorLB( const SdrModel* pDoc )
3125 aLbLight1.Fill( pDoc->GetColorList() );
3126 aLbLight2.CopyEntries( aLbLight1 );
3127 aLbLight3.CopyEntries( aLbLight1 );
3128 aLbLight4.CopyEntries( aLbLight1 );
3129 aLbLight5.CopyEntries( aLbLight1 );
3130 aLbLight6.CopyEntries( aLbLight1 );
3131 aLbLight7.CopyEntries( aLbLight1 );
3132 aLbLight8.CopyEntries( aLbLight1 );
3133 aLbAmbientlight.CopyEntries( aLbLight1 );
3134 aLbMatColor.CopyEntries( aLbLight1 );
3135 aLbMatEmission.CopyEntries( aLbLight1 );
3136 aLbMatSpecular.CopyEntries( aLbLight1 );
3138 // First...
3139 Color aColWhite( COL_WHITE );
3140 Color aColBlack( COL_BLACK );
3141 aLbLight1.SelectEntry( aColWhite );
3142 aLbLight2.SelectEntry( aColWhite );
3143 aLbLight3.SelectEntry( aColWhite );
3144 aLbLight4.SelectEntry( aColWhite );
3145 aLbLight5.SelectEntry( aColWhite );
3146 aLbLight6.SelectEntry( aColWhite );
3147 aLbLight7.SelectEntry( aColWhite );
3148 aLbLight8.SelectEntry( aColWhite );
3149 aLbAmbientlight.SelectEntry( aColBlack );
3150 aLbMatColor.SelectEntry( aColWhite );
3151 aLbMatEmission.SelectEntry( aColBlack );
3152 aLbMatSpecular.SelectEntry( aColWhite );
3155 // -----------------------------------------------------------------------
3156 sal_uInt16 Svx3DWin::GetLightSource( const PushButton* pBtn )
3158 sal_uInt16 nLight = 8;
3160 if( pBtn == NULL )
3162 if( aBtnLight1.IsChecked() )
3163 nLight = 0;
3164 else if( aBtnLight2.IsChecked() )
3165 nLight = 1;
3166 else if( aBtnLight3.IsChecked() )
3167 nLight = 2;
3168 else if( aBtnLight4.IsChecked() )
3169 nLight = 3;
3170 else if( aBtnLight5.IsChecked() )
3171 nLight = 4;
3172 else if( aBtnLight6.IsChecked() )
3173 nLight = 5;
3174 else if( aBtnLight7.IsChecked() )
3175 nLight = 6;
3176 else if( aBtnLight8.IsChecked() )
3177 nLight = 7;
3179 else
3181 if( pBtn == &aBtnLight1 )
3182 nLight = 0;
3183 else if( pBtn == &aBtnLight2 )
3184 nLight = 1;
3185 else if( pBtn == &aBtnLight3 )
3186 nLight = 2;
3187 else if( pBtn == &aBtnLight4 )
3188 nLight = 3;
3189 else if( pBtn == &aBtnLight5 )
3190 nLight = 4;
3191 else if( pBtn == &aBtnLight6 )
3192 nLight = 5;
3193 else if( pBtn == &aBtnLight7 )
3194 nLight = 6;
3195 else if( pBtn == &aBtnLight8 )
3196 nLight = 7;
3198 return( nLight );
3201 // -----------------------------------------------------------------------
3202 ColorLB* Svx3DWin::GetLbByButton( const PushButton* pBtn )
3204 ColorLB* pLb = NULL;
3206 if( pBtn == NULL )
3208 if( aBtnLight1.IsChecked() )
3209 pLb = &aLbLight1;
3210 else if( aBtnLight2.IsChecked() )
3211 pLb = &aLbLight2;
3212 else if( aBtnLight3.IsChecked() )
3213 pLb = &aLbLight3;
3214 else if( aBtnLight4.IsChecked() )
3215 pLb = &aLbLight4;
3216 else if( aBtnLight5.IsChecked() )
3217 pLb = &aLbLight5;
3218 else if( aBtnLight6.IsChecked() )
3219 pLb = &aLbLight6;
3220 else if( aBtnLight7.IsChecked() )
3221 pLb = &aLbLight7;
3222 else if( aBtnLight8.IsChecked() )
3223 pLb = &aLbLight8;
3225 else
3227 if( pBtn == &aBtnLight1 )
3228 pLb = &aLbLight1;
3229 else if( pBtn == &aBtnLight2 )
3230 pLb = &aLbLight2;
3231 else if( pBtn == &aBtnLight3 )
3232 pLb = &aLbLight3;
3233 else if( pBtn == &aBtnLight4 )
3234 pLb = &aLbLight4;
3235 else if( pBtn == &aBtnLight5 )
3236 pLb = &aLbLight5;
3237 else if( pBtn == &aBtnLight6 )
3238 pLb = &aLbLight6;
3239 else if( pBtn == &aBtnLight7 )
3240 pLb = &aLbLight7;
3241 else if( pBtn == &aBtnLight8 )
3242 pLb = &aLbLight8;
3244 return( pLb );
3247 // Derivation from SfxChildWindow as "containers" for effects
3249 Svx3DChildWindow::Svx3DChildWindow( Window* _pParent,
3250 sal_uInt16 nId,
3251 SfxBindings* pBindings,
3252 SfxChildWinInfo* pInfo ) :
3253 SfxChildWindow( _pParent, nId )
3255 Svx3DWin* pWin = new Svx3DWin( pBindings, this, _pParent );
3256 pWindow = pWin;
3258 eChildAlignment = SFX_ALIGN_NOALIGNMENT;
3260 pWin->Initialize( pInfo );
3263 Svx3DCtrlItem::Svx3DCtrlItem( sal_uInt16 _nId,
3264 Svx3DWin* pWin,
3265 SfxBindings* _pBindings) :
3266 SfxControllerItem( _nId, *_pBindings ),
3267 p3DWin( pWin )
3271 // -----------------------------------------------------------------------
3272 void Svx3DCtrlItem::StateChanged( sal_uInt16 /*nSId*/,
3273 SfxItemState /*eState*/, const SfxPoolItem* /*pItem*/ )
3277 // ControllerItem for Status Slot SID_CONVERT_TO_3D
3279 SvxConvertTo3DItem::SvxConvertTo3DItem(sal_uInt16 _nId, SfxBindings* _pBindings)
3280 : SfxControllerItem(_nId, *_pBindings),
3281 bState(sal_False)
3285 void SvxConvertTo3DItem::StateChanged(sal_uInt16 /*_nId*/, SfxItemState eState, const SfxPoolItem* /*pState*/)
3287 sal_Bool bNewState = (eState != SFX_ITEM_DISABLED);
3288 if(bNewState != bState)
3290 bState = bNewState;
3291 SfxDispatcher* pDispatcher = LocalGetDispatcher(&GetBindings());
3292 if (pDispatcher != NULL)
3294 SfxBoolItem aItem( SID_3D_STATE, sal_True );
3295 pDispatcher->Execute(
3296 SID_3D_STATE, SFX_CALLMODE_ASYNCHRON|SFX_CALLMODE_RECORD, &aItem, 0L);
3302 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */