1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
22 #include <sfx2/dispatch.hxx>
23 #include <sfx2/module.hxx>
24 #include <sfx2/viewfrm.hxx>
25 #include <svl/eitem.hxx>
26 #include <svl/intitem.hxx>
27 #include <svl/itempool.hxx>
28 #include <svtools/colrdlg.hxx>
29 #include <svx/colorbox.hxx>
30 #include <svx/f3dchild.hxx>
31 #include <svx/xfillit0.hxx>
32 #include <svx/xflclit.hxx>
33 #include <svx/xlineit0.hxx>
34 #include <svx/fmmodel.hxx>
35 #include <svx/dlgutil.hxx>
36 #include <svx/obj3d.hxx>
37 #include <svx/sdshitm.hxx>
38 #include <svx/svx3ditems.hxx>
40 #include <svx/dialmgr.hxx>
41 #include <svx/viewpt3d.hxx>
43 #include <svx/svxids.hrc>
44 #include <svx/strings.hrc>
46 #include <editeng/colritem.hxx>
47 #include <osl/diagnose.h>
48 #include <svx/e3ditem.hxx>
49 #include <svl/whiter.hxx>
50 #include <svtools/unitconv.hxx>
52 #include <svx/float3d.hxx>
53 #include <com/sun/star/drawing/TextureKind2.hpp>
55 #include <bitmaps.hlst>
57 using namespace com::sun::star
;
59 SFX_IMPL_DOCKINGWINDOW_WITHID( Svx3DChildWindow
, SID_3D_WIN
)
67 /** Get the dispatcher from the current view frame, or, if that is not
68 available, from the given bindings.
71 @returns NULL when both the current view frame is NULL and the given
74 SfxDispatcher
* LocalGetDispatcher (const SfxBindings
* pBindings
)
76 SfxDispatcher
* pDispatcher
= nullptr;
78 if (SfxViewFrame
* pViewFrame
= SfxViewFrame::Current())
79 pDispatcher
= pViewFrame
->GetDispatcher();
80 else if (pBindings
!= nullptr)
81 pDispatcher
= pBindings
->GetDispatcher();
87 Svx3DWin::Svx3DWin(SfxBindings
* pInBindings
, SfxChildWindow
*pCW
, vcl::Window
* pParent
)
88 : SfxDockingWindow(pInBindings
, pCW
, pParent
,
89 u
"Docking3DEffects"_ustr
, u
"svx/ui/docking3deffects.ui"_ustr
)
91 , m_xBtnGeo(m_xBuilder
->weld_toggle_button(u
"geometry"_ustr
))
92 , m_xBtnRepresentation(m_xBuilder
->weld_toggle_button(u
"representation"_ustr
))
93 , m_xBtnLight(m_xBuilder
->weld_toggle_button(u
"light"_ustr
))
94 , m_xBtnTexture(m_xBuilder
->weld_toggle_button(u
"texture"_ustr
))
95 , m_xBtnMaterial(m_xBuilder
->weld_toggle_button(u
"material"_ustr
))
96 , m_xBtnUpdate(m_xBuilder
->weld_toggle_button(u
"update"_ustr
))
97 , m_xBtnAssign(m_xBuilder
->weld_button(u
"assign"_ustr
))
99 , m_xFLGeometrie(m_xBuilder
->weld_container(u
"geoframe"_ustr
))
100 , m_xFtPercentDiagonal(m_xBuilder
->weld_label(u
"diagonalft"_ustr
))
101 , m_xMtrPercentDiagonal(m_xBuilder
->weld_metric_spin_button(u
"diagonal"_ustr
, FieldUnit::PERCENT
))
102 , m_xFtBackscale(m_xBuilder
->weld_label(u
"scaleddepthft"_ustr
))
103 , m_xMtrBackscale(m_xBuilder
->weld_metric_spin_button(u
"scaleddepth"_ustr
, FieldUnit::PERCENT
))
104 , m_xFtEndAngle(m_xBuilder
->weld_label(u
"angleft"_ustr
))
105 , m_xMtrEndAngle(m_xBuilder
->weld_metric_spin_button(u
"angle"_ustr
, FieldUnit::DEGREE
))
106 , m_xFtDepth(m_xBuilder
->weld_label(u
"depthft"_ustr
))
107 , m_xMtrDepth(m_xBuilder
->weld_metric_spin_button(u
"depth"_ustr
, FieldUnit::CM
))
109 , m_xFLSegments(m_xBuilder
->weld_container(u
"segmentsframe"_ustr
))
110 , m_xNumHorizontal(m_xBuilder
->weld_spin_button(u
"hori"_ustr
))
111 , m_xNumVertical(m_xBuilder
->weld_spin_button(u
"veri"_ustr
))
113 , m_xFLNormals(m_xBuilder
->weld_container(u
"normals"_ustr
))
114 , m_xBtnNormalsObj(m_xBuilder
->weld_toggle_button(u
"objspecific"_ustr
))
115 , m_xBtnNormalsFlat(m_xBuilder
->weld_toggle_button(u
"flat"_ustr
))
116 , m_xBtnNormalsSphere(m_xBuilder
->weld_toggle_button(u
"spherical"_ustr
))
117 , m_xBtnNormalsInvert(m_xBuilder
->weld_toggle_button(u
"invertnormals"_ustr
))
118 , m_xBtnTwoSidedLighting(m_xBuilder
->weld_toggle_button(u
"doublesidedillum"_ustr
))
119 , m_xBtnDoubleSided(m_xBuilder
->weld_toggle_button(u
"doublesided"_ustr
))
121 , m_xFLRepresentation(m_xBuilder
->weld_container(u
"shadingframe"_ustr
))
122 , m_xLbShademode(m_xBuilder
->weld_combo_box(u
"mode"_ustr
))
124 , m_xFLShadow(m_xBuilder
->weld_container(u
"shadowframe"_ustr
))
125 , m_xBtnShadow3d(m_xBuilder
->weld_toggle_button(u
"shadow"_ustr
))
126 , m_xFtSlant(m_xBuilder
->weld_label(u
"slantft"_ustr
))
127 , m_xMtrSlant(m_xBuilder
->weld_metric_spin_button(u
"slant"_ustr
, FieldUnit::DEGREE
))
129 , m_xFLCamera(m_xBuilder
->weld_container(u
"cameraframe"_ustr
))
130 , m_xMtrDistance(m_xBuilder
->weld_metric_spin_button(u
"distance"_ustr
, FieldUnit::CM
))
131 , m_xMtrFocalLength(m_xBuilder
->weld_metric_spin_button(u
"focal"_ustr
, FieldUnit::CM
))
133 , m_xFLLight(m_xBuilder
->weld_container(u
"illumframe"_ustr
))
134 , m_xBtnLight1(new LightButton(m_xBuilder
->weld_toggle_button(u
"light1"_ustr
)))
135 , m_xBtnLight2(new LightButton(m_xBuilder
->weld_toggle_button(u
"light2"_ustr
)))
136 , m_xBtnLight3(new LightButton(m_xBuilder
->weld_toggle_button(u
"light3"_ustr
)))
137 , m_xBtnLight4(new LightButton(m_xBuilder
->weld_toggle_button(u
"light4"_ustr
)))
138 , m_xBtnLight5(new LightButton(m_xBuilder
->weld_toggle_button(u
"light5"_ustr
)))
139 , m_xBtnLight6(new LightButton(m_xBuilder
->weld_toggle_button(u
"light6"_ustr
)))
140 , m_xBtnLight7(new LightButton(m_xBuilder
->weld_toggle_button(u
"light7"_ustr
)))
141 , m_xBtnLight8(new LightButton(m_xBuilder
->weld_toggle_button(u
"light8"_ustr
)))
142 , m_xLbLight1(new ColorListBox(m_xBuilder
->weld_menu_button(u
"lightcolor1"_ustr
), [this]{ return GetFrameWeld(); }))
143 , m_xLbLight2(new ColorListBox(m_xBuilder
->weld_menu_button(u
"lightcolor2"_ustr
), [this]{ return GetFrameWeld(); }))
144 , m_xLbLight3(new ColorListBox(m_xBuilder
->weld_menu_button(u
"lightcolor3"_ustr
), [this]{ return GetFrameWeld(); }))
145 , m_xLbLight4(new ColorListBox(m_xBuilder
->weld_menu_button(u
"lightcolor4"_ustr
), [this]{ return GetFrameWeld(); }))
146 , m_xLbLight5(new ColorListBox(m_xBuilder
->weld_menu_button(u
"lightcolor5"_ustr
), [this]{ return GetFrameWeld(); }))
147 , m_xLbLight6(new ColorListBox(m_xBuilder
->weld_menu_button(u
"lightcolor6"_ustr
), [this]{ return GetFrameWeld(); }))
148 , m_xLbLight7(new ColorListBox(m_xBuilder
->weld_menu_button(u
"lightcolor7"_ustr
), [this]{ return GetFrameWeld(); }))
149 , m_xLbLight8(new ColorListBox(m_xBuilder
->weld_menu_button(u
"lightcolor8"_ustr
), [this]{ return GetFrameWeld(); }))
150 , m_xBtnLightColor(m_xBuilder
->weld_button(u
"colorbutton1"_ustr
))
151 , m_xLbAmbientlight(new ColorListBox(m_xBuilder
->weld_menu_button(u
"ambientcolor"_ustr
), [this]{ return GetFrameWeld(); }))
152 , m_xBtnAmbientColor(m_xBuilder
->weld_button(u
"colorbutton2"_ustr
))
154 , m_xFLTexture(m_xBuilder
->weld_container(u
"textureframe"_ustr
))
155 , m_xBtnTexLuminance(m_xBuilder
->weld_toggle_button(u
"textype"_ustr
))
156 , m_xBtnTexColor(m_xBuilder
->weld_toggle_button(u
"texcolor"_ustr
))
157 , m_xBtnTexReplace(m_xBuilder
->weld_toggle_button(u
"texreplace"_ustr
))
158 , m_xBtnTexModulate(m_xBuilder
->weld_toggle_button(u
"texmodulate"_ustr
))
159 , m_xBtnTexObjectX(m_xBuilder
->weld_toggle_button(u
"texobjx"_ustr
))
160 , m_xBtnTexParallelX(m_xBuilder
->weld_toggle_button(u
"texparallelx"_ustr
))
161 , m_xBtnTexCircleX(m_xBuilder
->weld_toggle_button(u
"texcirclex"_ustr
))
162 , m_xBtnTexObjectY(m_xBuilder
->weld_toggle_button(u
"texobjy"_ustr
))
163 , m_xBtnTexParallelY(m_xBuilder
->weld_toggle_button(u
"texparallely"_ustr
))
164 , m_xBtnTexCircleY(m_xBuilder
->weld_toggle_button(u
"texcircley"_ustr
))
165 , m_xBtnTexFilter(m_xBuilder
->weld_toggle_button(u
"texfilter"_ustr
))
167 , m_xFLMaterial(m_xBuilder
->weld_container(u
"materialframe"_ustr
))
168 , m_xLbMatFavorites(m_xBuilder
->weld_combo_box(u
"favorites"_ustr
))
169 , m_xLbMatColor(new ColorListBox(m_xBuilder
->weld_menu_button(u
"objcolor"_ustr
), [this]{ return GetFrameWeld(); }))
170 , m_xBtnMatColor(m_xBuilder
->weld_button(u
"colorbutton3"_ustr
))
171 , m_xLbMatEmission(new ColorListBox(m_xBuilder
->weld_menu_button(u
"illumcolor"_ustr
), [this]{ return GetFrameWeld(); }))
172 , m_xBtnEmissionColor(m_xBuilder
->weld_button(u
"colorbutton4"_ustr
))
174 , m_xFLMatSpecular(m_xBuilder
->weld_container(u
"specframe"_ustr
))
175 , m_xLbMatSpecular(new ColorListBox(m_xBuilder
->weld_menu_button(u
"speccolor"_ustr
), [this]{ return GetFrameWeld(); }))
176 , m_xBtnSpecularColor(m_xBuilder
->weld_button(u
"colorbutton5"_ustr
))
177 , m_xMtrMatSpecularIntensity(m_xBuilder
->weld_metric_spin_button(u
"intensity"_ustr
, FieldUnit::PERCENT
))
179 , m_xCtlPreview(new Svx3DPreviewControl
)
180 , m_xCtlPreviewWin(new weld::CustomWeld(*m_xBuilder
, u
"preview"_ustr
, *m_xCtlPreview
))
182 , m_xLightPreviewGrid(m_xBuilder
->weld_container(u
"lightpreviewgrid"_ustr
))
183 , m_xHoriScale(m_xBuilder
->weld_scale(u
"horiscale"_ustr
))
184 , m_xVertScale(m_xBuilder
->weld_scale(u
"vertscale"_ustr
))
185 , m_xBtn_Corner(m_xBuilder
->weld_button(u
"corner"_ustr
))
186 , m_xLightPreview(new Svx3DLightControl
)
187 , m_xCtlLightPreviewWin(new weld::CustomWeld(*m_xBuilder
, u
"lightpreview"_ustr
, *m_xLightPreview
))
188 , m_xCtlLightPreview(new SvxLightCtl3D(*m_xLightPreview
, *m_xHoriScale
, *m_xVertScale
, *m_xBtn_Corner
)) // TODO might be other body widget as arg 1
190 , m_xBtnConvertTo3D(m_xBuilder
->weld_button(u
"to3d"_ustr
))
191 , m_xBtnLatheObject(m_xBuilder
->weld_button(u
"tolathe"_ustr
))
192 , m_xBtnPerspective(m_xBuilder
->weld_toggle_button(u
"perspective"_ustr
))
195 , eViewType(ViewType3D::Geo
)
196 , pBindings(pInBindings
)
197 , mpImpl(new Svx3DWinImpl
)
198 , ePoolUnit(MapUnit::MapMM
)
200 SetText(SvxResId(RID_SVXDLG_FLOAT3D_STR_TITLE
));
202 weld::DrawingArea
* pDrawingArea
= m_xCtlPreview
->GetDrawingArea();
203 Size
aSize(pDrawingArea
->get_ref_device().LogicToPixel(Size(83, 76), MapMode(MapUnit::MapAppFont
)));
204 pDrawingArea
->set_size_request(aSize
.Width(), aSize
.Height());
205 m_xCtlPreview
->SetOutputSizePixel(aSize
);
207 m_xLightPreviewGrid
->set_size_request(aSize
.Width(), aSize
.Height());
208 pDrawingArea
= m_xLightPreview
->GetDrawingArea();
209 pDrawingArea
->set_size_request(42, 42); // small to fit to m_xLightPreviewGrid
211 mpImpl
->pPool
= nullptr;
214 eFUnit
= pInBindings
->GetDispatcher()->GetModule()->GetFieldUnit();
216 m_xMtrDepth
->set_unit( eFUnit
);
217 m_xMtrDistance
->set_unit( eFUnit
);
218 m_xMtrFocalLength
->set_unit( eFUnit
);
220 pControllerItem
.reset( new Svx3DCtrlItem(SID_3D_STATE
, pBindings
) );
221 pConvertTo3DItem
.reset( new SvxConvertTo3DItem(SID_CONVERT_TO_3D
, pBindings
) );
222 pConvertTo3DLatheItem
.reset( new SvxConvertTo3DItem(SID_CONVERT_TO_3D_LATHE_FAST
, pBindings
) );
224 m_xBtnAssign
->connect_clicked( LINK( this, Svx3DWin
, ClickAssignHdl
) );
225 m_xBtnUpdate
->connect_toggled( LINK( this, Svx3DWin
, ClickUpdateHdl
) );
227 Link
<weld::Button
&,void> aLink( LINK( this, Svx3DWin
, ClickViewTypeHdl
) );
228 m_xBtnGeo
->connect_clicked( aLink
);
229 m_xBtnRepresentation
->connect_clicked( aLink
);
230 m_xBtnLight
->connect_clicked( aLink
);
231 m_xBtnTexture
->connect_clicked( aLink
);
232 m_xBtnMaterial
->connect_clicked( aLink
);
234 aLink
= LINK( this, Svx3DWin
, ClickHdl
);
235 m_xBtnPerspective
->connect_clicked( aLink
);
236 m_xBtnConvertTo3D
->connect_clicked( aLink
);
237 m_xBtnLatheObject
->connect_clicked( aLink
);
240 m_xBtnNormalsObj
->connect_clicked( aLink
);
241 m_xBtnNormalsFlat
->connect_clicked( aLink
);
242 m_xBtnNormalsSphere
->connect_clicked( aLink
);
243 m_xBtnTwoSidedLighting
->connect_clicked( aLink
);
244 m_xBtnNormalsInvert
->connect_clicked( aLink
);
245 m_xBtnDoubleSided
->connect_clicked( aLink
);
248 m_xBtnShadow3d
->connect_clicked( aLink
);
251 m_xBtnLight1
->connect_clicked( aLink
);
252 m_xBtnLight2
->connect_clicked( aLink
);
253 m_xBtnLight3
->connect_clicked( aLink
);
254 m_xBtnLight4
->connect_clicked( aLink
);
255 m_xBtnLight5
->connect_clicked( aLink
);
256 m_xBtnLight6
->connect_clicked( aLink
);
257 m_xBtnLight7
->connect_clicked( aLink
);
258 m_xBtnLight8
->connect_clicked( aLink
);
261 m_xBtnTexLuminance
->connect_clicked( aLink
);
262 m_xBtnTexColor
->connect_clicked( aLink
);
263 m_xBtnTexReplace
->connect_clicked( aLink
);
264 m_xBtnTexModulate
->connect_clicked( aLink
);
265 m_xBtnTexParallelX
->connect_clicked( aLink
);
266 m_xBtnTexCircleX
->connect_clicked( aLink
);
267 m_xBtnTexObjectX
->connect_clicked( aLink
);
268 m_xBtnTexParallelY
->connect_clicked( aLink
);
269 m_xBtnTexCircleY
->connect_clicked( aLink
);
270 m_xBtnTexObjectY
->connect_clicked( aLink
);
271 m_xBtnTexFilter
->connect_clicked( aLink
);
274 aLink
= LINK( this, Svx3DWin
, ClickColorHdl
);
275 m_xBtnLightColor
->connect_clicked( aLink
);
276 m_xBtnAmbientColor
->connect_clicked( aLink
);
277 m_xBtnMatColor
->connect_clicked( aLink
);
278 m_xBtnEmissionColor
->connect_clicked( aLink
);
279 m_xBtnSpecularColor
->connect_clicked( aLink
);
282 Link
<weld::ComboBox
&,void> aLink2
= LINK( this, Svx3DWin
, SelectHdl
);
283 Link
<ColorListBox
&,void> aLink4
= LINK( this, Svx3DWin
, SelectColorHdl
);
284 m_xLbMatFavorites
->connect_changed( aLink2
);
285 m_xLbMatColor
->SetSelectHdl( aLink4
);
286 m_xLbMatEmission
->SetSelectHdl( aLink4
);
287 m_xLbMatSpecular
->SetSelectHdl( aLink4
);
288 m_xLbLight1
->SetSelectHdl( aLink4
);
289 m_xLbLight2
->SetSelectHdl( aLink4
);
290 m_xLbLight3
->SetSelectHdl( aLink4
);
291 m_xLbLight4
->SetSelectHdl( aLink4
);
292 m_xLbLight5
->SetSelectHdl( aLink4
);
293 m_xLbLight6
->SetSelectHdl( aLink4
);
294 m_xLbLight7
->SetSelectHdl( aLink4
);
295 m_xLbLight8
->SetSelectHdl( aLink4
);
296 m_xLbAmbientlight
->SetSelectHdl( aLink4
);
297 m_xLbShademode
->connect_changed( aLink2
);
299 Link
<weld::MetricSpinButton
&,void> aLink3
= LINK( this, Svx3DWin
, ModifyMetricHdl
);
300 Link
<weld::SpinButton
&,void> aLink5
= LINK( this, Svx3DWin
, ModifySpinHdl
);
301 m_xMtrMatSpecularIntensity
->connect_value_changed( aLink3
);
302 m_xNumHorizontal
->connect_value_changed( aLink5
);
303 m_xNumVertical
->connect_value_changed( aLink5
);
304 m_xMtrSlant
->connect_value_changed( aLink3
);
307 m_xCtlLightPreview
->SetUserSelectionChangeCallback(LINK( this, Svx3DWin
, ChangeSelectionCallbackHdl
));
309 aSize
= GetOutputSizePixel();
310 SetMinOutputSizePixel( aSize
);
314 // Initiation of the initialization of the ColorLBs
315 SfxDispatcher
* pDispatcher
= LocalGetDispatcher(pBindings
);
316 if (pDispatcher
!= nullptr)
318 SfxBoolItem
aItem( SID_3D_INIT
, true );
319 pDispatcher
->ExecuteList(SID_3D_INIT
,
320 SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
, { &aItem
});
325 //lock down the size of the initial largest default mode as the permanent size
326 aSize
= get_preferred_size();
327 set_width_request(aSize
.Width());
328 set_height_request(aSize
.Height());
331 Svx3DWin::~Svx3DWin()
336 void Svx3DWin::dispose()
340 pControllerItem
.reset();
341 pConvertTo3DItem
.reset();
342 pConvertTo3DLatheItem
.reset();
347 m_xBtnRepresentation
.reset();
349 m_xBtnTexture
.reset();
350 m_xBtnMaterial
.reset();
351 m_xBtnUpdate
.reset();
352 m_xBtnAssign
.reset();
353 m_xFLGeometrie
.reset();
354 m_xFtPercentDiagonal
.reset();
355 m_xMtrPercentDiagonal
.reset();
356 m_xFtBackscale
.reset();
357 m_xMtrBackscale
.reset();
358 m_xFtEndAngle
.reset();
359 m_xMtrEndAngle
.reset();
362 m_xFLSegments
.reset();
363 m_xNumHorizontal
.reset();
364 m_xNumVertical
.reset();
365 m_xFLNormals
.reset();
366 m_xBtnNormalsObj
.reset();
367 m_xBtnNormalsFlat
.reset();
368 m_xBtnNormalsSphere
.reset();
369 m_xBtnNormalsInvert
.reset();
370 m_xBtnTwoSidedLighting
.reset();
371 m_xBtnDoubleSided
.reset();
372 m_xFLRepresentation
.reset();
373 m_xLbShademode
.reset();
375 m_xBtnShadow3d
.reset();
379 m_xMtrDistance
.reset();
380 m_xMtrFocalLength
.reset();
382 m_xBtnLight1
.reset();
383 m_xBtnLight2
.reset();
384 m_xBtnLight3
.reset();
385 m_xBtnLight4
.reset();
386 m_xBtnLight5
.reset();
387 m_xBtnLight6
.reset();
388 m_xBtnLight7
.reset();
389 m_xBtnLight8
.reset();
398 m_xBtnLightColor
.reset();
399 m_xLbAmbientlight
.reset();
400 m_xBtnAmbientColor
.reset();
401 m_xFLTexture
.reset();
402 m_xBtnTexLuminance
.reset();
403 m_xBtnTexColor
.reset();
404 m_xBtnTexReplace
.reset();
405 m_xBtnTexModulate
.reset();
406 m_xBtnTexObjectX
.reset();
407 m_xBtnTexParallelX
.reset();
408 m_xBtnTexCircleX
.reset();
409 m_xBtnTexObjectY
.reset();
410 m_xBtnTexParallelY
.reset();
411 m_xBtnTexCircleY
.reset();
412 m_xBtnTexFilter
.reset();
413 m_xFLMaterial
.reset();
414 m_xLbMatFavorites
.reset();
415 m_xLbMatColor
.reset();
416 m_xBtnMatColor
.reset();
417 m_xLbMatEmission
.reset();
418 m_xBtnEmissionColor
.reset();
419 m_xFLMatSpecular
.reset();
420 m_xLbMatSpecular
.reset();
421 m_xBtnSpecularColor
.reset();
422 m_xMtrMatSpecularIntensity
.reset();
423 m_xCtlPreviewWin
.reset();
424 m_xCtlPreview
.reset();
426 m_xCtlLightPreview
.reset();
427 m_xCtlLightPreviewWin
.reset();
428 m_xLightPreview
.reset();
429 m_xBtn_Corner
.reset();
430 m_xVertScale
.reset();
431 m_xHoriScale
.reset();
432 m_xLightPreviewGrid
.reset();
434 m_xBtnConvertTo3D
.reset();
435 m_xBtnLatheObject
.reset();
436 m_xBtnPerspective
.reset();
438 SfxDockingWindow::dispose();
441 void Svx3DWin::Construct()
443 m_xBtnGeo
->set_active(true);
444 ClickViewTypeHdl(*m_xBtnGeo
);
445 m_xLightPreviewGrid
->hide();
448 void Svx3DWin::Reset()
450 // Various initializations, default is AllAttributes
451 m_xLbShademode
->set_active( 0 );
452 m_xMtrMatSpecularIntensity
->set_value( 50, FieldUnit::PERCENT
);
454 m_xBtnLight1
->set_active(true);
455 m_xBtnUpdate
->set_active(true);
456 ClickUpdateHdl(*m_xBtnUpdate
);
458 // Select nothing, to avoid errors when selecting the first
459 m_xCtlLightPreview
->GetSvx3DLightControl().SelectLight(0);
460 m_xCtlLightPreview
->CheckSelection();
463 void Svx3DWin::Update( SfxItemSet
const & rAttrs
)
465 // remember 2d attributes
466 if(mpRemember2DAttributes
)
467 mpRemember2DAttributes
->ClearItem();
469 mpRemember2DAttributes
= std::make_unique
<SfxItemSetFixed
470 <SDRATTR_START
, SDRATTR_SHADOW_LAST
,
471 SDRATTR_3D_FIRST
, SDRATTR_3D_LAST
>>(*rAttrs
.GetPool());
473 SfxWhichIter
aIter(*mpRemember2DAttributes
);
474 sal_uInt16
nWhich(aIter
.FirstWhich());
478 SfxItemState eState
= rAttrs
.GetItemState(nWhich
, false);
479 if(SfxItemState::INVALID
== eState
)
480 mpRemember2DAttributes
->InvalidateItem(nWhich
);
481 else if(SfxItemState::SET
== eState
)
482 mpRemember2DAttributes
->Put(rAttrs
.Get(nWhich
, false));
484 nWhich
= aIter
.NextWhich();
487 // construct field values
488 const SfxPoolItem
* pItem
;
490 // Possible determine PoolUnit
493 mpImpl
->pPool
= rAttrs
.GetPool();
494 DBG_ASSERT( mpImpl
->pPool
, "Where is the Pool? ");
495 ePoolUnit
= mpImpl
->pPool
->GetMetric( SID_ATTR_LINE_WIDTH
);
497 eFUnit
= GetModuleFieldUnit( rAttrs
);
500 // Segment Number Can be changed? and other states
501 SfxItemState eState
= rAttrs
.GetItemState( SID_ATTR_3D_INTERN
, false, &pItem
);
502 if( SfxItemState::SET
== eState
)
504 sal_uInt32 nState
= static_cast<const SfxUInt32Item
*>(pItem
)->GetValue();
505 bool bExtrude
= ( nState
& 2 );
506 bool bSphere
= ( nState
& 4 );
507 bool bCube
= ( nState
& 8 );
509 bool bChart
= ( nState
& 32 ); // Chart
513 // For cube objects are no segments set
514 m_xFLSegments
->set_sensitive(!bCube
);
516 m_xFtPercentDiagonal
->set_sensitive( !bCube
&& !bSphere
);
517 m_xMtrPercentDiagonal
->set_sensitive( !bCube
&& !bSphere
);
518 m_xFtBackscale
->set_sensitive( !bCube
&& !bSphere
);
519 m_xMtrBackscale
->set_sensitive( !bCube
&& !bSphere
);
520 m_xFtDepth
->set_sensitive( !bCube
&& !bSphere
);
521 m_xMtrDepth
->set_sensitive( !bCube
&& !bSphere
);
524 m_xNumHorizontal
->set_text(u
""_ustr
);
525 m_xNumVertical
->set_text(u
""_ustr
);
527 if( bCube
|| bSphere
)
529 m_xMtrPercentDiagonal
->set_text(u
""_ustr
);
530 m_xMtrBackscale
->set_text(u
""_ustr
);
531 m_xMtrDepth
->set_text(u
""_ustr
);
534 // There is a final angle only for Lathe objects.
535 m_xFtEndAngle
->set_sensitive( !bExtrude
&& !bCube
&& !bSphere
);
536 m_xMtrEndAngle
->set_sensitive( !bExtrude
&& !bCube
&& !bSphere
);
537 if( bExtrude
|| bCube
|| bSphere
)
538 m_xMtrEndAngle
->set_text(u
""_ustr
);
543 m_xNumHorizontal
->set_text(u
""_ustr
);
544 m_xNumVertical
->set_text(u
""_ustr
);
545 m_xFLSegments
->set_sensitive( false );
546 m_xFtEndAngle
->set_sensitive( false );
547 m_xMtrEndAngle
->set_sensitive( false );
548 m_xMtrEndAngle
->set_text(u
""_ustr
);
549 m_xFtDepth
->set_sensitive( false );
550 m_xMtrDepth
->set_sensitive( false );
551 m_xMtrDepth
->set_text(u
""_ustr
);
554 m_xFLShadow
->set_sensitive(false);
556 m_xMtrDistance
->set_text(u
""_ustr
);
557 m_xMtrFocalLength
->set_text(u
""_ustr
);
558 m_xFLCamera
->set_sensitive( false );
561 m_xBtnConvertTo3D
->set_sensitive( false );
562 m_xBtnLatheObject
->set_sensitive( false );
565 // Bitmap fill ? -> Status
567 eState
= rAttrs
.GetItemState(XATTR_FILLSTYLE
);
568 if(eState
!= SfxItemState::INVALID
)
570 drawing::FillStyle eXFS
= rAttrs
.Get(XATTR_FILLSTYLE
).GetValue();
571 bBitmap
= (eXFS
== drawing::FillStyle_BITMAP
|| eXFS
== drawing::FillStyle_GRADIENT
|| eXFS
== drawing::FillStyle_HATCH
);
574 m_xFLTexture
->set_sensitive(bBitmap
);
577 // Number of segments (horizontal)
578 if( m_xNumHorizontal
->get_sensitive() )
580 eState
= rAttrs
.GetItemState(SDRATTR_3DOBJ_HORZ_SEGS
);
581 if(eState
!= SfxItemState::INVALID
)
583 sal_uInt32 nValue
= rAttrs
.Get(SDRATTR_3DOBJ_HORZ_SEGS
).GetValue();
584 if (nValue
!= static_cast<sal_uInt32
>(m_xNumHorizontal
->get_value()))
586 m_xNumHorizontal
->set_value( nValue
);
589 else if( m_xNumHorizontal
->get_text().isEmpty() )
590 m_xNumHorizontal
->set_value( nValue
);
594 if( !m_xNumHorizontal
->get_text().isEmpty() )
596 m_xNumHorizontal
->set_text(u
""_ustr
);
602 //Number of segments (vertical)
603 if( m_xNumVertical
->get_sensitive() )
605 eState
= rAttrs
.GetItemState(SDRATTR_3DOBJ_VERT_SEGS
);
606 if( eState
!= SfxItemState::INVALID
)
608 sal_uInt32 nValue
= rAttrs
.Get(SDRATTR_3DOBJ_VERT_SEGS
).GetValue();
609 if( nValue
!= static_cast<sal_uInt32
>(m_xNumVertical
->get_value()) )
611 m_xNumVertical
->set_value( nValue
);
614 else if( m_xNumVertical
->get_text().isEmpty() )
615 m_xNumVertical
->set_value( nValue
);
619 if( !m_xNumVertical
->get_text().isEmpty() )
621 m_xNumVertical
->set_text(u
""_ustr
);
628 if( m_xMtrDepth
->get_sensitive() )
630 eState
= rAttrs
.GetItemState(SDRATTR_3DOBJ_DEPTH
);
631 if( eState
!= SfxItemState::INVALID
)
633 sal_uInt32 nValue
= rAttrs
.Get(SDRATTR_3DOBJ_DEPTH
).GetValue();
634 sal_uInt32 nValue2
= GetCoreValue(*m_xMtrDepth
, ePoolUnit
);
635 if( nValue
!= nValue2
)
637 if( eFUnit
!= m_xMtrDepth
->get_unit() )
638 SetFieldUnit(*m_xMtrDepth
, eFUnit
);
640 SetMetricValue(*m_xMtrDepth
, nValue
, ePoolUnit
);
643 else if( m_xMtrDepth
->get_text().isEmpty() )
644 m_xMtrDepth
->set_value(m_xMtrDepth
->get_value(FieldUnit::NONE
), FieldUnit::NONE
);
648 if( !m_xMtrDepth
->get_text().isEmpty() )
650 m_xMtrDepth
->set_text(u
""_ustr
);
656 // Double walled / Double sided
657 eState
= rAttrs
.GetItemState(SDRATTR_3DOBJ_DOUBLE_SIDED
);
658 if( eState
!= SfxItemState::INVALID
)
660 bool bValue
= rAttrs
.Get(SDRATTR_3DOBJ_DOUBLE_SIDED
).GetValue();
661 if( bValue
!= m_xBtnDoubleSided
->get_active() )
663 m_xBtnDoubleSided
->set_active( bValue
);
666 else if( m_xBtnDoubleSided
->get_state() == TRISTATE_INDET
)
667 m_xBtnDoubleSided
->set_active( bValue
);
671 if( m_xBtnDoubleSided
->get_state() != TRISTATE_INDET
)
673 m_xBtnDoubleSided
->set_state( TRISTATE_INDET
);
679 if( m_xMtrPercentDiagonal
->get_sensitive() )
681 eState
= rAttrs
.GetItemState(SDRATTR_3DOBJ_PERCENT_DIAGONAL
);
682 if( eState
!= SfxItemState::INVALID
)
684 sal_uInt16 nValue
= rAttrs
.Get(SDRATTR_3DOBJ_PERCENT_DIAGONAL
).GetValue();
685 if( nValue
!= m_xMtrPercentDiagonal
->get_value(FieldUnit::PERCENT
) )
687 m_xMtrPercentDiagonal
->set_value(nValue
, FieldUnit::PERCENT
);
690 else if( m_xMtrPercentDiagonal
->get_text().isEmpty() )
691 m_xMtrPercentDiagonal
->set_value(nValue
, FieldUnit::PERCENT
);
695 if( !m_xMtrPercentDiagonal
->get_text().isEmpty() )
697 m_xMtrPercentDiagonal
->set_text(u
""_ustr
);
704 if( m_xMtrBackscale
->get_sensitive() )
706 eState
= rAttrs
.GetItemState(SDRATTR_3DOBJ_BACKSCALE
);
707 if( eState
!= SfxItemState::INVALID
)
709 sal_uInt16 nValue
= rAttrs
.Get(SDRATTR_3DOBJ_BACKSCALE
).GetValue();
710 if( nValue
!= m_xMtrBackscale
->get_value(FieldUnit::PERCENT
) )
712 m_xMtrBackscale
->set_value(nValue
, FieldUnit::PERCENT
);
715 else if( m_xMtrBackscale
->get_text().isEmpty() )
716 m_xMtrBackscale
->set_value(nValue
, FieldUnit::PERCENT
);
720 if( !m_xMtrBackscale
->get_text().isEmpty() )
722 m_xMtrBackscale
->set_text(u
""_ustr
);
729 if( m_xMtrEndAngle
->get_sensitive() )
731 eState
= rAttrs
.GetItemState(SDRATTR_3DOBJ_END_ANGLE
);
732 if( eState
!= SfxItemState::INVALID
)
734 sal_Int32 nValue
= rAttrs
.Get(SDRATTR_3DOBJ_END_ANGLE
).GetValue();
735 if( nValue
!= m_xMtrEndAngle
->get_value(FieldUnit::DEGREE
) )
737 m_xMtrEndAngle
->set_value(nValue
, FieldUnit::DEGREE
);
743 if( !m_xMtrEndAngle
->get_text().isEmpty() )
745 m_xMtrEndAngle
->set_text(u
""_ustr
);
752 eState
= rAttrs
.GetItemState(SDRATTR_3DOBJ_NORMALS_KIND
);
753 if( eState
!= SfxItemState::INVALID
)
755 sal_uInt16 nValue
= rAttrs
.Get(SDRATTR_3DOBJ_NORMALS_KIND
).GetValue();
757 if( ( !m_xBtnNormalsObj
->get_active() && nValue
== 0 ) ||
758 ( !m_xBtnNormalsFlat
->get_active() && nValue
== 1 ) ||
759 ( !m_xBtnNormalsSphere
->get_active() && nValue
== 2 ) )
761 m_xBtnNormalsObj
->set_active( nValue
== 0 );
762 m_xBtnNormalsFlat
->set_active( nValue
== 1 );
763 m_xBtnNormalsSphere
->set_active( nValue
== 2 );
769 if( m_xBtnNormalsObj
->get_active() ||
770 m_xBtnNormalsFlat
->get_active() ||
771 m_xBtnNormalsSphere
->get_active() )
773 m_xBtnNormalsObj
->set_active( false );
774 m_xBtnNormalsFlat
->set_active( false );
775 m_xBtnNormalsSphere
->set_active( false );
781 eState
= rAttrs
.GetItemState(SDRATTR_3DOBJ_NORMALS_INVERT
);
782 if( eState
!= SfxItemState::INVALID
)
784 bool bValue
= rAttrs
.Get(SDRATTR_3DOBJ_NORMALS_INVERT
).GetValue();
785 if( bValue
!= m_xBtnNormalsInvert
->get_active() )
787 m_xBtnNormalsInvert
->set_active( bValue
);
790 else if( m_xBtnNormalsInvert
->get_state() == TRISTATE_INDET
)
791 m_xBtnNormalsInvert
->set_active( bValue
);
795 if( m_xBtnNormalsInvert
->get_state() != TRISTATE_INDET
)
797 m_xBtnNormalsInvert
->set_state( TRISTATE_INDET
);
803 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_TWO_SIDED_LIGHTING
);
804 if( eState
!= SfxItemState::INVALID
)
806 bool bValue
= rAttrs
.Get(SDRATTR_3DSCENE_TWO_SIDED_LIGHTING
).GetValue();
807 if( bValue
!= m_xBtnTwoSidedLighting
->get_active() )
809 m_xBtnTwoSidedLighting
->set_active( bValue
);
812 else if( m_xBtnTwoSidedLighting
->get_state() == TRISTATE_INDET
)
813 m_xBtnTwoSidedLighting
->set_active( bValue
);
817 if( m_xBtnTwoSidedLighting
->get_state() != TRISTATE_INDET
)
819 m_xBtnTwoSidedLighting
->set_state( TRISTATE_INDET
);
826 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_SHADE_MODE
);
827 if( eState
!= SfxItemState::INVALID
)
829 sal_uInt16 nValue
= rAttrs
.Get(SDRATTR_3DSCENE_SHADE_MODE
).GetValue();
830 if( nValue
!= m_xLbShademode
->get_active() )
832 m_xLbShademode
->set_active( nValue
);
838 if( m_xLbShademode
->get_active() != 0 )
840 m_xLbShademode
->set_active(-1);
846 eState
= rAttrs
.GetItemState(SDRATTR_3DOBJ_SHADOW_3D
);
847 if( eState
!= SfxItemState::INVALID
)
849 bool bValue
= rAttrs
.Get(SDRATTR_3DOBJ_SHADOW_3D
).GetValue();
850 if( bValue
!= m_xBtnShadow3d
->get_active() )
852 m_xBtnShadow3d
->set_active( bValue
);
853 m_xFtSlant
->set_sensitive( bValue
);
854 m_xMtrSlant
->set_sensitive( bValue
);
857 else if( m_xBtnShadow3d
->get_state() == TRISTATE_INDET
)
858 m_xBtnShadow3d
->set_active( bValue
);
862 if( m_xBtnShadow3d
->get_state() != TRISTATE_INDET
)
864 m_xBtnShadow3d
->set_state( TRISTATE_INDET
);
869 // Inclination (Shadow)
870 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_SHADOW_SLANT
);
871 if( eState
!= SfxItemState::INVALID
)
873 sal_uInt16 nValue
= rAttrs
.Get(SDRATTR_3DSCENE_SHADOW_SLANT
).GetValue();
874 if( nValue
!= m_xMtrSlant
->get_value(FieldUnit::DEGREE
) )
876 m_xMtrSlant
->set_value(nValue
, FieldUnit::DEGREE
);
882 if( !m_xMtrSlant
->get_text().isEmpty() )
884 m_xMtrSlant
->set_text(u
""_ustr
);
890 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_DISTANCE
);
891 if( eState
!= SfxItemState::INVALID
)
893 sal_uInt32 nValue
= rAttrs
.Get(SDRATTR_3DSCENE_DISTANCE
).GetValue();
894 sal_uInt32 nValue2
= GetCoreValue(*m_xMtrDistance
, ePoolUnit
);
895 if( nValue
!= nValue2
)
897 if( eFUnit
!= m_xMtrDistance
->get_unit() )
898 SetFieldUnit(*m_xMtrDistance
, eFUnit
);
900 SetMetricValue(*m_xMtrDistance
, nValue
, ePoolUnit
);
906 if( !m_xMtrDepth
->get_text().isEmpty() )
908 m_xMtrDepth
->set_text(u
""_ustr
);
914 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_FOCAL_LENGTH
);
915 if( eState
!= SfxItemState::INVALID
)
917 sal_uInt32 nValue
= rAttrs
.Get(SDRATTR_3DSCENE_FOCAL_LENGTH
).GetValue();
918 sal_uInt32 nValue2
= GetCoreValue(*m_xMtrFocalLength
, ePoolUnit
);
919 if( nValue
!= nValue2
)
921 if( eFUnit
!= m_xMtrFocalLength
->get_unit() )
922 SetFieldUnit(*m_xMtrFocalLength
, eFUnit
);
924 SetMetricValue(*m_xMtrFocalLength
, nValue
, ePoolUnit
);
930 if( !m_xMtrFocalLength
->get_text().isEmpty() )
932 m_xMtrFocalLength
->set_text(u
""_ustr
);
940 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_1
);
941 if( eState
!= SfxItemState::INVALID
)
943 aColor
= rAttrs
.Get(SDRATTR_3DSCENE_LIGHTCOLOR_1
).GetValue();
944 ColorListBox
* pLb
= m_xLbLight1
.get();
945 if( aColor
!= pLb
->GetSelectEntryColor() )
947 LBSelectColor( pLb
, aColor
);
953 if (!m_xLbLight1
->IsNoSelection())
955 m_xLbLight1
->SetNoSelection();
960 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_LIGHTON_1
);
961 if( eState
!= SfxItemState::INVALID
)
963 bool bOn
= rAttrs
.Get(SDRATTR_3DSCENE_LIGHTON_1
).GetValue();
964 if (bOn
!= m_xBtnLight1
->isLightOn())
966 m_xBtnLight1
->switchLightOn(bOn
);
969 if( m_xBtnLight1
->get_state() == TRISTATE_INDET
)
970 m_xBtnLight1
->set_active( m_xBtnLight1
->get_active() );
974 if( m_xBtnLight1
->get_state() != TRISTATE_INDET
)
976 m_xBtnLight1
->set_state( TRISTATE_INDET
);
980 // Light 1 (direction)
981 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_1
);
982 if( eState
!= SfxItemState::INVALID
)
988 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_2
);
989 if( eState
!= SfxItemState::INVALID
)
991 aColor
= rAttrs
.Get(SDRATTR_3DSCENE_LIGHTCOLOR_2
).GetValue();
992 ColorListBox
* pLb
= m_xLbLight2
.get();
993 if( aColor
!= pLb
->GetSelectEntryColor() )
995 LBSelectColor( pLb
, aColor
);
1001 if (!m_xLbLight2
->IsNoSelection())
1003 m_xLbLight2
->SetNoSelection();
1008 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_LIGHTON_2
);
1009 if( eState
!= SfxItemState::INVALID
)
1011 bool bOn
= rAttrs
.Get(SDRATTR_3DSCENE_LIGHTON_2
).GetValue();
1012 if (bOn
!= m_xBtnLight2
->isLightOn())
1014 m_xBtnLight2
->switchLightOn(bOn
);
1017 if( m_xBtnLight2
->get_state() == TRISTATE_INDET
)
1018 m_xBtnLight2
->set_active( m_xBtnLight2
->get_active() );
1022 if( m_xBtnLight2
->get_state() != TRISTATE_INDET
)
1024 m_xBtnLight2
->set_state( TRISTATE_INDET
);
1028 //Light 2 (Direction)
1029 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_2
);
1030 if( eState
!= SfxItemState::INVALID
)
1036 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_3
);
1037 if( eState
!= SfxItemState::INVALID
)
1039 aColor
= rAttrs
.Get(SDRATTR_3DSCENE_LIGHTCOLOR_3
).GetValue();
1040 ColorListBox
* pLb
= m_xLbLight3
.get();
1041 if( aColor
!= pLb
->GetSelectEntryColor() )
1043 LBSelectColor( pLb
, aColor
);
1049 if (!m_xLbLight3
->IsNoSelection())
1051 m_xLbLight3
->SetNoSelection();
1056 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_LIGHTON_3
);
1057 if( eState
!= SfxItemState::INVALID
)
1059 bool bOn
= rAttrs
.Get(SDRATTR_3DSCENE_LIGHTON_3
).GetValue();
1060 if (bOn
!= m_xBtnLight3
->isLightOn())
1062 m_xBtnLight3
->switchLightOn(bOn
);
1065 if( m_xBtnLight3
->get_state() == TRISTATE_INDET
)
1066 m_xBtnLight3
->set_active( m_xBtnLight3
->get_active() );
1070 if( m_xBtnLight3
->get_state() != TRISTATE_INDET
)
1072 m_xBtnLight3
->set_state( TRISTATE_INDET
);
1076 // Light 3 (Direction)
1077 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_3
);
1078 if( eState
!= SfxItemState::INVALID
)
1084 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_4
);
1085 if( eState
!= SfxItemState::INVALID
)
1087 aColor
= rAttrs
.Get(SDRATTR_3DSCENE_LIGHTCOLOR_4
).GetValue();
1088 ColorListBox
* pLb
= m_xLbLight4
.get();
1089 if( aColor
!= pLb
->GetSelectEntryColor() )
1091 LBSelectColor( pLb
, aColor
);
1097 if (!m_xLbLight4
->IsNoSelection())
1099 m_xLbLight4
->SetNoSelection();
1104 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_LIGHTON_4
);
1105 if( eState
!= SfxItemState::INVALID
)
1107 bool bOn
= rAttrs
.Get(SDRATTR_3DSCENE_LIGHTON_4
).GetValue();
1108 if (bOn
!= m_xBtnLight4
->isLightOn())
1110 m_xBtnLight4
->switchLightOn(bOn
);
1113 if( m_xBtnLight4
->get_state() == TRISTATE_INDET
)
1114 m_xBtnLight4
->set_active( m_xBtnLight4
->get_active() );
1118 if( m_xBtnLight4
->get_state() != TRISTATE_INDET
)
1120 m_xBtnLight4
->set_state( TRISTATE_INDET
);
1124 // Light 4 (direction)
1125 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_4
);
1126 if( eState
!= SfxItemState::INVALID
)
1132 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_5
);
1133 if( eState
!= SfxItemState::INVALID
)
1135 aColor
= rAttrs
.Get(SDRATTR_3DSCENE_LIGHTCOLOR_5
).GetValue();
1136 ColorListBox
* pLb
= m_xLbLight5
.get();
1137 if( aColor
!= pLb
->GetSelectEntryColor() )
1139 LBSelectColor( pLb
, aColor
);
1145 if (!m_xLbLight5
->IsNoSelection())
1147 m_xLbLight5
->SetNoSelection();
1152 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_LIGHTON_5
);
1153 if( eState
!= SfxItemState::INVALID
)
1155 bool bOn
= rAttrs
.Get(SDRATTR_3DSCENE_LIGHTON_5
).GetValue();
1156 if (bOn
!= m_xBtnLight5
->isLightOn())
1158 m_xBtnLight5
->switchLightOn(bOn
);
1161 if( m_xBtnLight5
->get_state() == TRISTATE_INDET
)
1162 m_xBtnLight5
->set_active( m_xBtnLight5
->get_active() );
1166 if( m_xBtnLight5
->get_state() != TRISTATE_INDET
)
1168 m_xBtnLight5
->set_state( TRISTATE_INDET
);
1172 // Light 5 (direction)
1173 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_5
);
1174 if( eState
!= SfxItemState::INVALID
)
1180 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_6
);
1181 if( eState
!= SfxItemState::INVALID
)
1183 aColor
= rAttrs
.Get(SDRATTR_3DSCENE_LIGHTCOLOR_6
).GetValue();
1184 ColorListBox
* pLb
= m_xLbLight6
.get();
1185 if( aColor
!= pLb
->GetSelectEntryColor() )
1187 LBSelectColor( pLb
, aColor
);
1193 if (!m_xLbLight6
->IsNoSelection())
1195 m_xLbLight6
->SetNoSelection();
1200 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_LIGHTON_6
);
1201 if( eState
!= SfxItemState::INVALID
)
1203 bool bOn
= rAttrs
.Get(SDRATTR_3DSCENE_LIGHTON_6
).GetValue();
1204 if (bOn
!= m_xBtnLight6
->isLightOn())
1206 m_xBtnLight6
->switchLightOn(bOn
);
1209 if( m_xBtnLight6
->get_state() == TRISTATE_INDET
)
1210 m_xBtnLight6
->set_active( m_xBtnLight6
->get_active() );
1214 if( m_xBtnLight6
->get_state() != TRISTATE_INDET
)
1216 m_xBtnLight6
->set_state( TRISTATE_INDET
);
1220 // Light 6 (direction)
1221 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_6
);
1222 if( eState
!= SfxItemState::INVALID
)
1228 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_7
);
1229 if( eState
!= SfxItemState::INVALID
)
1231 aColor
= rAttrs
.Get(SDRATTR_3DSCENE_LIGHTCOLOR_7
).GetValue();
1232 ColorListBox
* pLb
= m_xLbLight7
.get();
1233 if( aColor
!= pLb
->GetSelectEntryColor() )
1235 LBSelectColor( pLb
, aColor
);
1241 if (!m_xLbLight7
->IsNoSelection())
1243 m_xLbLight7
->SetNoSelection();
1248 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_LIGHTON_7
);
1249 if( eState
!= SfxItemState::INVALID
)
1251 bool bOn
= rAttrs
.Get(SDRATTR_3DSCENE_LIGHTON_7
).GetValue();
1252 if (bOn
!= m_xBtnLight7
->isLightOn())
1254 m_xBtnLight7
->switchLightOn(bOn
);
1257 if( m_xBtnLight7
->get_state() == TRISTATE_INDET
)
1258 m_xBtnLight7
->set_active( m_xBtnLight7
->get_active() );
1262 if( m_xBtnLight7
->get_state() != TRISTATE_INDET
)
1264 m_xBtnLight7
->set_state( TRISTATE_INDET
);
1268 // Light 7 (direction)
1269 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_7
);
1270 if( eState
!= SfxItemState::INVALID
)
1276 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_8
);
1277 if( eState
!= SfxItemState::INVALID
)
1279 aColor
= rAttrs
.Get(SDRATTR_3DSCENE_LIGHTCOLOR_8
).GetValue();
1280 ColorListBox
* pLb
= m_xLbLight8
.get();
1281 if( aColor
!= pLb
->GetSelectEntryColor() )
1283 LBSelectColor( pLb
, aColor
);
1289 if (!m_xLbLight8
->IsNoSelection())
1291 m_xLbLight8
->SetNoSelection();
1296 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_LIGHTON_8
);
1297 if( eState
!= SfxItemState::INVALID
)
1299 bool bOn
= rAttrs
.Get(SDRATTR_3DSCENE_LIGHTON_8
).GetValue();
1300 if (bOn
!= m_xBtnLight8
->isLightOn())
1302 m_xBtnLight8
->switchLightOn(bOn
);
1305 if( m_xBtnLight8
->get_state() == TRISTATE_INDET
)
1306 m_xBtnLight8
->set_active( m_xBtnLight8
->get_active() );
1310 if( m_xBtnLight8
->get_state() != TRISTATE_INDET
)
1312 m_xBtnLight8
->set_state( TRISTATE_INDET
);
1316 // Light 8 (direction)
1317 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_8
);
1318 if( eState
!= SfxItemState::INVALID
)
1324 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_AMBIENTCOLOR
);
1325 if( eState
!= SfxItemState::INVALID
)
1327 aColor
= rAttrs
.Get(SDRATTR_3DSCENE_AMBIENTCOLOR
).GetValue();
1328 ColorListBox
* pLb
= m_xLbAmbientlight
.get();
1329 if( aColor
!= pLb
->GetSelectEntryColor() )
1331 LBSelectColor( pLb
, aColor
);
1337 if (!m_xLbAmbientlight
->IsNoSelection())
1339 m_xLbAmbientlight
->SetNoSelection();
1349 eState
= rAttrs
.GetItemState(SDRATTR_3DOBJ_TEXTURE_KIND
);
1350 if( eState
!= SfxItemState::INVALID
)
1352 sal_uInt16 nValue
= rAttrs
.Get(SDRATTR_3DOBJ_TEXTURE_KIND
).GetValue();
1353 drawing::TextureKind2 objTextKind
= static_cast<drawing::TextureKind2
>(nValue
);
1355 if( ( !m_xBtnTexLuminance
->get_active() && objTextKind
== css::drawing::TextureKind2_LUMINANCE
) ||
1356 ( !m_xBtnTexColor
->get_active() && objTextKind
== css::drawing::TextureKind2_COLOR
) )
1358 m_xBtnTexLuminance
->set_active( objTextKind
== css::drawing::TextureKind2_LUMINANCE
);
1359 m_xBtnTexColor
->set_active( objTextKind
== css::drawing::TextureKind2_COLOR
);
1365 if( m_xBtnTexLuminance
->get_active() ||
1366 m_xBtnTexColor
->get_active() )
1368 m_xBtnTexLuminance
->set_active( false );
1369 m_xBtnTexColor
->set_active( false );
1375 eState
= rAttrs
.GetItemState(SDRATTR_3DOBJ_TEXTURE_MODE
);
1376 if( eState
!= SfxItemState::INVALID
)
1378 sal_uInt16 nValue
= rAttrs
.Get(SDRATTR_3DOBJ_TEXTURE_MODE
).GetValue();
1380 if( ( !m_xBtnTexReplace
->get_active() && nValue
== 1 ) ||
1381 ( !m_xBtnTexModulate
->get_active() && nValue
== 2 ) )
1383 m_xBtnTexReplace
->set_active( nValue
== 1 );
1384 m_xBtnTexModulate
->set_active( nValue
== 2 );
1390 if( m_xBtnTexReplace
->get_active() ||
1391 m_xBtnTexModulate
->get_active() )
1393 m_xBtnTexReplace
->set_active( false );
1394 m_xBtnTexModulate
->set_active( false );
1400 eState
= rAttrs
.GetItemState(SDRATTR_3DOBJ_TEXTURE_PROJ_X
);
1401 if( eState
!= SfxItemState::INVALID
)
1403 sal_uInt16 nValue
= rAttrs
.Get(SDRATTR_3DOBJ_TEXTURE_PROJ_X
).GetValue();
1405 if( ( !m_xBtnTexObjectX
->get_active() && nValue
== 0 ) ||
1406 ( !m_xBtnTexParallelX
->get_active() && nValue
== 1 ) ||
1407 ( !m_xBtnTexCircleX
->get_active() && nValue
== 2 ) )
1409 m_xBtnTexObjectX
->set_active( nValue
== 0 );
1410 m_xBtnTexParallelX
->set_active( nValue
== 1 );
1411 m_xBtnTexCircleX
->set_active( nValue
== 2 );
1417 if( m_xBtnTexObjectX
->get_active() ||
1418 m_xBtnTexParallelX
->get_active() ||
1419 m_xBtnTexCircleX
->get_active() )
1421 m_xBtnTexObjectX
->set_active( false );
1422 m_xBtnTexParallelX
->set_active( false );
1423 m_xBtnTexCircleX
->set_active( false );
1429 eState
= rAttrs
.GetItemState(SDRATTR_3DOBJ_TEXTURE_PROJ_Y
);
1430 if( eState
!= SfxItemState::INVALID
)
1432 sal_uInt16 nValue
= rAttrs
.Get(SDRATTR_3DOBJ_TEXTURE_PROJ_Y
).GetValue();
1434 if( ( !m_xBtnTexObjectY
->get_active() && nValue
== 0 ) ||
1435 ( !m_xBtnTexParallelY
->get_active() && nValue
== 1 ) ||
1436 ( !m_xBtnTexCircleY
->get_active() && nValue
== 2 ) )
1438 m_xBtnTexObjectY
->set_active( nValue
== 0 );
1439 m_xBtnTexParallelY
->set_active( nValue
== 1 );
1440 m_xBtnTexCircleY
->set_active( nValue
== 2 );
1446 if( m_xBtnTexObjectY
->get_active() ||
1447 m_xBtnTexParallelY
->get_active() ||
1448 m_xBtnTexCircleY
->get_active() )
1450 m_xBtnTexObjectY
->set_active( false );
1451 m_xBtnTexParallelY
->set_active( false );
1452 m_xBtnTexCircleY
->set_active( false );
1458 eState
= rAttrs
.GetItemState(SDRATTR_3DOBJ_TEXTURE_FILTER
);
1459 if( eState
!= SfxItemState::INVALID
)
1461 bool bValue
= rAttrs
.Get(SDRATTR_3DOBJ_TEXTURE_FILTER
).GetValue();
1462 if( bValue
!= m_xBtnTexFilter
->get_active() )
1464 m_xBtnTexFilter
->set_active( bValue
);
1467 if( m_xBtnTexFilter
->get_state() == TRISTATE_INDET
)
1468 m_xBtnTexFilter
->set_active( bValue
);
1472 if( m_xBtnTexFilter
->get_state() != TRISTATE_INDET
)
1474 m_xBtnTexFilter
->set_state( TRISTATE_INDET
);
1481 // Material Favorites
1482 m_xLbMatFavorites
->set_active( 0 );
1485 eState
= rAttrs
.GetItemState(XATTR_FILLCOLOR
);
1486 if( eState
!= SfxItemState::INVALID
)
1488 aColor
= rAttrs
.Get(XATTR_FILLCOLOR
).GetColorValue();
1489 ColorListBox
* pLb
= m_xLbMatColor
.get();
1490 if( aColor
!= pLb
->GetSelectEntryColor() )
1492 LBSelectColor( pLb
, aColor
);
1498 if (!m_xLbMatColor
->IsNoSelection())
1500 m_xLbMatColor
->SetNoSelection();
1505 // Self-luminous color
1506 eState
= rAttrs
.GetItemState(SDRATTR_3DOBJ_MAT_EMISSION
);
1507 if( eState
!= SfxItemState::INVALID
)
1509 aColor
= rAttrs
.Get(SDRATTR_3DOBJ_MAT_EMISSION
).GetValue();
1510 ColorListBox
* pLb
= m_xLbMatEmission
.get();
1511 if( aColor
!= pLb
->GetSelectEntryColor() )
1513 LBSelectColor( pLb
, aColor
);
1519 if (!m_xLbMatEmission
->IsNoSelection())
1521 m_xLbMatEmission
->SetNoSelection();
1527 eState
= rAttrs
.GetItemState(SDRATTR_3DOBJ_MAT_SPECULAR
);
1528 if( eState
!= SfxItemState::INVALID
)
1530 aColor
= rAttrs
.Get(SDRATTR_3DOBJ_MAT_SPECULAR
).GetValue();
1531 ColorListBox
* pLb
= m_xLbMatSpecular
.get();
1532 if( aColor
!= pLb
->GetSelectEntryColor() )
1534 LBSelectColor( pLb
, aColor
);
1540 if (!m_xLbMatSpecular
->IsNoSelection())
1542 m_xLbMatSpecular
->SetNoSelection();
1547 // Specular Intensity
1548 eState
= rAttrs
.GetItemState(SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY
);
1549 if( eState
!= SfxItemState::INVALID
)
1551 sal_uInt16 nValue
= rAttrs
.Get(SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY
).GetValue();
1552 if( nValue
!= m_xMtrMatSpecularIntensity
->get_value(FieldUnit::PERCENT
) )
1554 m_xMtrMatSpecularIntensity
->set_value(nValue
, FieldUnit::PERCENT
);
1560 if( !m_xMtrMatSpecularIntensity
->get_text().isEmpty() )
1562 m_xMtrMatSpecularIntensity
->set_text(u
""_ustr
);
1570 eState
= rAttrs
.GetItemState(SDRATTR_3DSCENE_PERSPECTIVE
);
1571 if( eState
!= SfxItemState::INVALID
)
1573 ProjectionType ePT
= static_cast<ProjectionType
>(rAttrs
.Get(SDRATTR_3DSCENE_PERSPECTIVE
).GetValue());
1574 if( ( !m_xBtnPerspective
->get_active() && ePT
== ProjectionType::Perspective
) ||
1575 ( m_xBtnPerspective
->get_active() && ePT
== ProjectionType::Parallel
) )
1577 m_xBtnPerspective
->set_active( ePT
== ProjectionType::Perspective
);
1580 if( m_xBtnPerspective
->get_state() == TRISTATE_INDET
)
1581 m_xBtnPerspective
->set_active( ePT
== ProjectionType::Perspective
);
1585 if( m_xBtnPerspective
->get_state() != TRISTATE_INDET
)
1587 m_xBtnPerspective
->set_state( TRISTATE_INDET
);
1594 // however the 2D attributes may be different. Compare these and decide
1600 SfxItemSet
aSet(rAttrs
);
1602 // set LineStyle hard to drawing::LineStyle_NONE when it's not set so that
1603 // the default (drawing::LineStyle_SOLID) is not used for 3d preview
1604 if(SfxItemState::SET
!= aSet
.GetItemState(XATTR_LINESTYLE
, false))
1605 aSet
.Put(XLineStyleItem(drawing::LineStyle_NONE
));
1607 // set FillColor hard to WHITE when it's SfxItemState::INVALID so that
1608 // the default (Blue7) is not used for 3d preview
1609 if(SfxItemState::INVALID
== aSet
.GetItemState(XATTR_FILLCOLOR
, false))
1610 aSet
.Put(XFillColorItem(OUString(), COL_WHITE
));
1612 m_xCtlPreview
->Set3DAttributes(aSet
);
1613 m_xCtlLightPreview
->GetSvx3DLightControl().Set3DAttributes(aSet
);
1615 // try to select light corresponding to active button
1616 sal_uInt32
nNumber(0xffffffff);
1618 if(m_xBtnLight1
->get_active())
1620 else if(m_xBtnLight2
->get_active())
1622 else if(m_xBtnLight3
->get_active())
1624 else if(m_xBtnLight4
->get_active())
1626 else if(m_xBtnLight5
->get_active())
1628 else if(m_xBtnLight6
->get_active())
1630 else if(m_xBtnLight7
->get_active())
1632 else if(m_xBtnLight8
->get_active())
1635 if(nNumber
!= 0xffffffff)
1637 m_xCtlLightPreview
->GetSvx3DLightControl().SelectLight(nNumber
);
1640 // handle state of converts possible
1641 m_xBtnConvertTo3D
->set_sensitive(pConvertTo3DItem
->GetState());
1642 m_xBtnLatheObject
->set_sensitive(pConvertTo3DLatheItem
->GetState());
1646 void Svx3DWin::GetAttr( SfxItemSet
& rAttrs
)
1648 // get remembered 2d attributes from the dialog
1649 if(mpRemember2DAttributes
)
1651 SfxWhichIter
aIter(*mpRemember2DAttributes
);
1652 sal_uInt16
nWhich(aIter
.FirstWhich());
1656 SfxItemState eState
= aIter
.GetItemState(false);
1657 if(SfxItemState::INVALID
== eState
)
1658 rAttrs
.InvalidateItem(nWhich
);
1659 else if(SfxItemState::SET
== eState
)
1660 rAttrs
.Put(mpRemember2DAttributes
->Get(nWhich
, false));
1662 nWhich
= aIter
.NextWhich();
1666 //Others must stand as the front on all sides
1668 if( m_xBtnPerspective
->get_state() != TRISTATE_INDET
)
1670 ProjectionType nValue
;
1671 if( m_xBtnPerspective
->get_active() )
1672 nValue
= ProjectionType::Perspective
;
1674 nValue
= ProjectionType::Parallel
;
1675 rAttrs
.Put(Svx3DPerspectiveItem(nValue
));
1678 rAttrs
.InvalidateItem(SDRATTR_3DSCENE_PERSPECTIVE
);
1681 // Possible determine PoolUnit (in this case this has not happened in Update() )
1682 if( !mpImpl
->pPool
)
1684 OSL_FAIL( "No Pool in GetAttr()! May be incompatible to drviewsi.cxx ?" );
1685 mpImpl
->pPool
= rAttrs
.GetPool();
1686 DBG_ASSERT( mpImpl
->pPool
, "Where is the Pool?" );
1687 ePoolUnit
= mpImpl
->pPool
->GetMetric( SID_ATTR_LINE_WIDTH
);
1689 eFUnit
= GetModuleFieldUnit( rAttrs
);
1692 // Number of segments (horizontal)
1693 if( !m_xNumHorizontal
->get_text().isEmpty() )
1695 sal_uInt32 nValue
= static_cast<sal_uInt32
>(m_xNumHorizontal
->get_value());
1696 rAttrs
.Put(makeSvx3DHorizontalSegmentsItem(nValue
));
1699 rAttrs
.InvalidateItem(SDRATTR_3DOBJ_HORZ_SEGS
);
1701 // Number of segments (vertical)
1702 if( !m_xNumVertical
->get_text().isEmpty() )
1704 sal_uInt32 nValue
= static_cast<sal_uInt32
>(m_xNumVertical
->get_value());
1705 rAttrs
.Put(makeSvx3DVerticalSegmentsItem(nValue
));
1708 rAttrs
.InvalidateItem(SDRATTR_3DOBJ_VERT_SEGS
);
1711 if( !m_xMtrDepth
->get_text().isEmpty() )
1713 sal_uInt32 nValue
= GetCoreValue(*m_xMtrDepth
, ePoolUnit
);
1714 rAttrs
.Put(makeSvx3DDepthItem(nValue
));
1717 rAttrs
.InvalidateItem(SDRATTR_3DOBJ_DEPTH
);
1720 TriState eState
= m_xBtnDoubleSided
->get_state();
1721 if( eState
!= TRISTATE_INDET
)
1723 bool bValue
= TRISTATE_TRUE
== eState
;
1724 rAttrs
.Put(makeSvx3DDoubleSidedItem(bValue
));
1727 rAttrs
.InvalidateItem(SDRATTR_3DOBJ_DOUBLE_SIDED
);
1730 if( !m_xMtrPercentDiagonal
->get_text().isEmpty() )
1732 sal_uInt16 nValue
= static_cast<sal_uInt16
>(m_xMtrPercentDiagonal
->get_value(FieldUnit::PERCENT
));
1733 rAttrs
.Put(makeSvx3DPercentDiagonalItem(nValue
));
1736 rAttrs
.InvalidateItem(SDRATTR_3DOBJ_PERCENT_DIAGONAL
);
1739 if( !m_xMtrBackscale
->get_text().isEmpty() )
1741 sal_uInt16 nValue
= static_cast<sal_uInt16
>(m_xMtrBackscale
->get_value(FieldUnit::PERCENT
));
1742 rAttrs
.Put(makeSvx3DBackscaleItem(nValue
));
1745 rAttrs
.InvalidateItem(SDRATTR_3DOBJ_BACKSCALE
);
1748 if( !m_xMtrEndAngle
->get_text().isEmpty() )
1750 sal_uInt16 nValue
= static_cast<sal_uInt16
>(m_xMtrEndAngle
->get_value(FieldUnit::DEGREE
));
1751 rAttrs
.Put(makeSvx3DEndAngleItem(nValue
));
1754 rAttrs
.InvalidateItem(SDRATTR_3DOBJ_END_ANGLE
);
1757 sal_uInt16 nValue
= 99;
1758 if( m_xBtnNormalsObj
->get_active() )
1760 else if( m_xBtnNormalsFlat
->get_active() )
1762 else if( m_xBtnNormalsSphere
->get_active() )
1766 rAttrs
.Put(Svx3DNormalsKindItem(nValue
));
1768 rAttrs
.InvalidateItem(SDRATTR_3DOBJ_NORMALS_KIND
);
1771 eState
= m_xBtnNormalsInvert
->get_state();
1772 if( eState
!= TRISTATE_INDET
)
1774 bool bValue
= TRISTATE_TRUE
== eState
;
1775 rAttrs
.Put(makeSvx3DNormalsInvertItem(bValue
));
1778 rAttrs
.InvalidateItem(SDRATTR_3DOBJ_NORMALS_INVERT
);
1781 eState
= m_xBtnTwoSidedLighting
->get_state();
1782 if( eState
!= TRISTATE_INDET
)
1784 bool bValue
= TRISTATE_TRUE
== eState
;
1785 rAttrs
.Put(makeSvx3DTwoSidedLightingItem(bValue
));
1788 rAttrs
.InvalidateItem(SDRATTR_3DSCENE_TWO_SIDED_LIGHTING
);
1792 if( m_xLbShademode
->get_active() != -1 )
1794 nValue
= m_xLbShademode
->get_active();
1795 rAttrs
.Put(Svx3DShadeModeItem(nValue
));
1798 rAttrs
.InvalidateItem(SDRATTR_3DSCENE_SHADE_MODE
);
1801 eState
= m_xBtnShadow3d
->get_state();
1802 if( eState
!= TRISTATE_INDET
)
1804 bool bValue
= TRISTATE_TRUE
== eState
;
1805 rAttrs
.Put(makeSvx3DShadow3DItem(bValue
));
1806 rAttrs
.Put(makeSdrShadowItem(bValue
));
1810 rAttrs
.InvalidateItem(SDRATTR_3DOBJ_SHADOW_3D
);
1811 rAttrs
.InvalidateItem(SDRATTR_SHADOW
);
1815 if( !m_xMtrSlant
->get_text().isEmpty() )
1817 sal_uInt16 nValue2
= static_cast<sal_uInt16
>(m_xMtrSlant
->get_value(FieldUnit::DEGREE
));
1818 rAttrs
.Put(makeSvx3DShadowSlantItem(nValue2
));
1821 rAttrs
.InvalidateItem(SDRATTR_3DSCENE_SHADOW_SLANT
);
1824 if( !m_xMtrDistance
->get_text().isEmpty() )
1826 sal_uInt32 nValue2
= GetCoreValue(*m_xMtrDistance
, ePoolUnit
);
1827 rAttrs
.Put(makeSvx3DDistanceItem(nValue2
));
1830 rAttrs
.InvalidateItem(SDRATTR_3DSCENE_DISTANCE
);
1833 if( !m_xMtrFocalLength
->get_text().isEmpty() )
1835 sal_uInt32 nValue2
= GetCoreValue(*m_xMtrFocalLength
, ePoolUnit
);
1836 rAttrs
.Put(makeSvx3DFocalLengthItem(nValue2
));
1839 rAttrs
.InvalidateItem(SDRATTR_3DSCENE_FOCAL_LENGTH
);
1843 const SfxItemSet
aLightItemSet(m_xCtlLightPreview
->GetSvx3DLightControl().Get3DAttributes());
1846 if (!m_xLbLight1
->IsNoSelection())
1848 aColor
= m_xLbLight1
->GetSelectEntryColor();
1849 rAttrs
.Put(makeSvx3DLightcolor1Item(aColor
));
1852 rAttrs
.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_1
);
1854 eState
= m_xBtnLight1
->get_state();
1855 if( eState
!= TRISTATE_INDET
)
1857 bool bValue
= m_xBtnLight1
->isLightOn();
1858 rAttrs
.Put(makeSvx3DLightOnOff1Item(bValue
));
1860 // Light 1 (direction)
1863 rAttrs
.Put(aLightItemSet
.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_1
));
1867 rAttrs
.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_1
);
1871 if (!m_xLbLight2
->IsNoSelection())
1873 aColor
= m_xLbLight2
->GetSelectEntryColor();
1874 rAttrs
.Put(makeSvx3DLightcolor2Item(aColor
));
1877 rAttrs
.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_2
);
1879 eState
= m_xBtnLight2
->get_state();
1880 if( eState
!= TRISTATE_INDET
)
1882 bool bValue
= m_xBtnLight2
->isLightOn();
1883 rAttrs
.Put(makeSvx3DLightOnOff2Item(bValue
));
1885 // Light 2 (direction)
1888 rAttrs
.Put(aLightItemSet
.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_2
));
1892 rAttrs
.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_2
);
1895 if (!m_xLbLight3
->IsNoSelection())
1897 aColor
= m_xLbLight3
->GetSelectEntryColor();
1898 rAttrs
.Put(makeSvx3DLightcolor3Item(aColor
));
1901 rAttrs
.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_3
);
1903 eState
= m_xBtnLight3
->get_state();
1904 if( eState
!= TRISTATE_INDET
)
1906 bool bValue
= m_xBtnLight3
->isLightOn();
1907 rAttrs
.Put(makeSvx3DLightOnOff3Item(bValue
));
1909 // Light 3 (direction)
1912 rAttrs
.Put(aLightItemSet
.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_3
));
1916 rAttrs
.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_3
);
1919 if (!m_xLbLight4
->IsNoSelection())
1921 aColor
= m_xLbLight4
->GetSelectEntryColor();
1922 rAttrs
.Put(makeSvx3DLightcolor4Item(aColor
));
1925 rAttrs
.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_4
);
1927 eState
= m_xBtnLight4
->get_state();
1928 if( eState
!= TRISTATE_INDET
)
1930 bool bValue
= m_xBtnLight4
->isLightOn();
1931 rAttrs
.Put(makeSvx3DLightOnOff4Item(bValue
));
1933 // Light 4 (direction)
1936 rAttrs
.Put(aLightItemSet
.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_4
));
1940 rAttrs
.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_4
);
1943 if (!m_xLbLight5
->IsNoSelection())
1945 aColor
= m_xLbLight5
->GetSelectEntryColor();
1946 rAttrs
.Put(makeSvx3DLightcolor5Item(aColor
));
1949 rAttrs
.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_5
);
1951 eState
= m_xBtnLight5
->get_state();
1952 if( eState
!= TRISTATE_INDET
)
1954 bool bValue
= m_xBtnLight5
->isLightOn();
1955 rAttrs
.Put(makeSvx3DLightOnOff5Item(bValue
));
1957 // Light 5 (direction)
1960 rAttrs
.Put(aLightItemSet
.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_5
));
1964 rAttrs
.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_5
);
1967 if (!m_xLbLight6
->IsNoSelection())
1969 aColor
= m_xLbLight6
->GetSelectEntryColor();
1970 rAttrs
.Put(makeSvx3DLightcolor6Item(aColor
));
1973 rAttrs
.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_6
);
1975 eState
= m_xBtnLight6
->get_state();
1976 if( eState
!= TRISTATE_INDET
)
1978 bool bValue
= m_xBtnLight6
->isLightOn();
1979 rAttrs
.Put(makeSvx3DLightOnOff6Item(bValue
));
1981 // Light 6 (direction)
1984 rAttrs
.Put(aLightItemSet
.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_6
));
1988 rAttrs
.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_6
);
1991 if (!m_xLbLight7
->IsNoSelection())
1993 aColor
= m_xLbLight7
->GetSelectEntryColor();
1994 rAttrs
.Put(makeSvx3DLightcolor7Item(aColor
));
1997 rAttrs
.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_7
);
1999 eState
= m_xBtnLight7
->get_state();
2000 if( eState
!= TRISTATE_INDET
)
2002 bool bValue
= m_xBtnLight7
->isLightOn();
2003 rAttrs
.Put(makeSvx3DLightOnOff7Item(bValue
));
2005 // Light 7 (direction)
2008 rAttrs
.Put(aLightItemSet
.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_7
));
2012 rAttrs
.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_7
);
2015 if (!m_xLbLight8
->IsNoSelection())
2017 aColor
= m_xLbLight8
->GetSelectEntryColor();
2018 rAttrs
.Put(makeSvx3DLightcolor8Item(aColor
));
2021 rAttrs
.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_8
);
2023 eState
= m_xBtnLight8
->get_state();
2024 if( eState
!= TRISTATE_INDET
)
2026 bool bValue
= m_xBtnLight8
->isLightOn();
2027 rAttrs
.Put(makeSvx3DLightOnOff8Item(bValue
));
2029 // Light 8 (direction)
2032 rAttrs
.Put(aLightItemSet
.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_8
));
2036 rAttrs
.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_8
);
2039 if (!m_xLbAmbientlight
->IsNoSelection())
2041 aColor
= m_xLbAmbientlight
->GetSelectEntryColor();
2042 rAttrs
.Put(makeSvx3DAmbientcolorItem(aColor
));
2045 rAttrs
.InvalidateItem(SDRATTR_3DSCENE_AMBIENTCOLOR
);
2049 drawing::TextureKind2 objTextKind
= css::drawing::TextureKind2_LUMINANCE
;
2051 if( m_xBtnTexLuminance
->get_active() )
2053 objTextKind
= css::drawing::TextureKind2_LUMINANCE
;
2056 else if( m_xBtnTexColor
->get_active() )
2058 objTextKind
= css::drawing::TextureKind2_COLOR
;
2063 rAttrs
.Put(Svx3DTextureKindItem(static_cast<sal_uInt16
>(objTextKind
)));
2065 rAttrs
.InvalidateItem(SDRATTR_3DOBJ_TEXTURE_KIND
);
2070 if( m_xBtnTexReplace
->get_active() )
2072 else if( m_xBtnTexModulate
->get_active() )
2075 if( nValue
== 1 || nValue
== 2 )
2076 rAttrs
.Put(Svx3DTextureModeItem(nValue
));
2078 rAttrs
.InvalidateItem(SDRATTR_3DOBJ_TEXTURE_MODE
);
2082 if( m_xBtnTexObjectX
->get_active() )
2084 else if( m_xBtnTexParallelX
->get_active() )
2086 else if( m_xBtnTexCircleX
->get_active() )
2090 rAttrs
.Put(Svx3DTextureProjectionXItem(nValue
));
2092 rAttrs
.InvalidateItem(SDRATTR_3DOBJ_TEXTURE_PROJ_X
);
2096 if( m_xBtnTexObjectY
->get_active() )
2098 else if( m_xBtnTexParallelY
->get_active() )
2100 else if( m_xBtnTexCircleY
->get_active() )
2104 rAttrs
.Put(Svx3DTextureProjectionYItem(nValue
));
2106 rAttrs
.InvalidateItem(SDRATTR_3DOBJ_TEXTURE_PROJ_Y
);
2110 eState
= m_xBtnTexFilter
->get_state();
2111 if( eState
!= TRISTATE_INDET
)
2113 bool bValue
= TRISTATE_TRUE
== eState
;
2114 rAttrs
.Put(makeSvx3DTextureFilterItem(bValue
));
2117 rAttrs
.InvalidateItem(SDRATTR_3DOBJ_TEXTURE_FILTER
);
2122 if (!m_xLbMatColor
->IsNoSelection())
2124 aColor
= m_xLbMatColor
->GetSelectEntryColor();
2125 rAttrs
.Put( XFillColorItem( u
""_ustr
, aColor
) );
2129 rAttrs
.InvalidateItem( XATTR_FILLCOLOR
);
2133 if (!m_xLbMatEmission
->IsNoSelection())
2135 aColor
= m_xLbMatEmission
->GetSelectEntryColor();
2136 rAttrs
.Put(makeSvx3DMaterialEmissionItem(aColor
));
2139 rAttrs
.InvalidateItem(SDRATTR_3DOBJ_MAT_EMISSION
);
2142 if (!m_xLbMatSpecular
->IsNoSelection())
2144 aColor
= m_xLbMatSpecular
->GetSelectEntryColor();
2145 rAttrs
.Put(makeSvx3DMaterialSpecularItem(aColor
));
2148 rAttrs
.InvalidateItem(SDRATTR_3DOBJ_MAT_SPECULAR
);
2150 // Specular intensity
2151 if( !m_xMtrMatSpecularIntensity
->get_text().isEmpty() )
2153 sal_uInt16 nValue2
= static_cast<sal_uInt16
>(m_xMtrMatSpecularIntensity
->get_value(FieldUnit::PERCENT
));
2154 rAttrs
.Put(makeSvx3DMaterialSpecularIntensityItem(nValue2
));
2157 rAttrs
.InvalidateItem(SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY
);
2160 void Svx3DWin::Resize()
2162 Size
aWinSize( GetOutputSizePixel() ); // why rSize in Resizing()?
2164 if( aWinSize
.Height() >= GetMinOutputSizePixel().Height() &&
2165 aWinSize
.Width() >= GetMinOutputSizePixel().Width() )
2168 m_xBtnUpdate
->hide();
2169 m_xBtnAssign
->hide();
2171 m_xBtnConvertTo3D
->hide();
2172 m_xBtnLatheObject
->hide();
2173 m_xBtnPerspective
->hide();
2175 m_xCtlPreview
->Hide();
2176 m_xLightPreviewGrid
->hide();
2178 m_xFLGeometrie
->hide();
2179 m_xFLRepresentation
->hide();
2181 m_xFLTexture
->hide();
2182 m_xFLMaterial
->hide();
2185 m_xBtnUpdate
->show();
2186 m_xBtnAssign
->show();
2188 m_xBtnConvertTo3D
->show();
2189 m_xBtnLatheObject
->show();
2190 m_xBtnPerspective
->show();
2192 if( m_xBtnGeo
->get_active() )
2193 ClickViewTypeHdl(*m_xBtnGeo
);
2194 if( m_xBtnRepresentation
->get_active() )
2195 ClickViewTypeHdl(*m_xBtnRepresentation
);
2196 if( m_xBtnLight
->get_active() )
2197 ClickViewTypeHdl(*m_xBtnLight
);
2198 if( m_xBtnTexture
->get_active() )
2199 ClickViewTypeHdl(*m_xBtnTexture
);
2200 if( m_xBtnMaterial
->get_active() )
2201 ClickViewTypeHdl(*m_xBtnMaterial
);
2204 SfxDockingWindow::Resize();
2207 IMPL_LINK_NOARG(Svx3DWin
, ClickUpdateHdl
, weld::Toggleable
&, void)
2209 bUpdate
= m_xBtnUpdate
->get_active();
2213 SfxDispatcher
* pDispatcher
= LocalGetDispatcher(pBindings
);
2214 if (pDispatcher
!= nullptr)
2216 SfxBoolItem
aItem( SID_3D_STATE
, true );
2217 pDispatcher
->ExecuteList(SID_3D_STATE
,
2218 SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
, { &aItem
});
2223 // Controls can be disabled during certain circumstances
2227 IMPL_LINK_NOARG(Svx3DWin
, ClickAssignHdl
, weld::Button
&, void)
2229 SfxDispatcher
* pDispatcher
= LocalGetDispatcher(pBindings
);
2230 if (pDispatcher
!= nullptr)
2232 SfxBoolItem
aItem( SID_3D_ASSIGN
, true );
2233 pDispatcher
->ExecuteList(SID_3D_ASSIGN
,
2234 SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
, { &aItem
});
2238 IMPL_LINK( Svx3DWin
, ClickViewTypeHdl
, weld::Button
&, rBtn
, void )
2240 // Since the permanent updating of the preview would be too expensive
2241 bool bUpdatePreview
= m_xBtnLight
->get_active();
2243 m_xBtnGeo
->set_active(m_xBtnGeo
.get() == &rBtn
);
2244 m_xBtnRepresentation
->set_active(m_xBtnRepresentation
.get() == &rBtn
);
2245 m_xBtnLight
->set_active(m_xBtnLight
.get() == &rBtn
);
2246 m_xBtnTexture
->set_active(m_xBtnTexture
.get() == &rBtn
);
2247 m_xBtnMaterial
->set_active(m_xBtnMaterial
.get() == &rBtn
);
2249 if( m_xBtnGeo
->get_active() )
2250 eViewType
= ViewType3D::Geo
;
2251 if( m_xBtnRepresentation
->get_active() )
2252 eViewType
= ViewType3D::Representation
;
2253 if( m_xBtnLight
->get_active() )
2254 eViewType
= ViewType3D::Light
;
2255 if( m_xBtnTexture
->get_active() )
2256 eViewType
= ViewType3D::Texture
;
2257 if( m_xBtnMaterial
->get_active() )
2258 eViewType
= ViewType3D::Material
;
2261 if( eViewType
== ViewType3D::Geo
)
2263 m_xFLSegments
->show();
2264 m_xFLGeometrie
->show();
2265 m_xFLNormals
->show();
2269 m_xFLSegments
->hide();
2270 m_xFLGeometrie
->hide();
2271 m_xFLNormals
->hide();
2275 if( eViewType
== ViewType3D::Representation
)
2277 m_xFLShadow
->show();
2278 m_xFLCamera
->show();
2279 m_xFLRepresentation
->show();
2283 m_xFLShadow
->hide();
2284 m_xFLCamera
->hide();
2285 m_xFLRepresentation
->hide();
2289 if( eViewType
== ViewType3D::Light
)
2293 ColorListBox
* pLb
= GetCLbByButton();
2297 m_xLightPreviewGrid
->show();
2298 m_xCtlPreview
->Hide();
2304 if( !m_xCtlPreview
->IsVisible() )
2306 m_xCtlPreview
->Show();
2307 m_xLightPreviewGrid
->hide();
2312 if (eViewType
== ViewType3D::Texture
)
2313 m_xFLTexture
->show();
2315 m_xFLTexture
->hide();
2318 if( eViewType
== ViewType3D::Material
)
2320 m_xFLMatSpecular
->show();
2321 m_xFLMaterial
->show();
2325 m_xFLMatSpecular
->hide();
2326 m_xFLMaterial
->hide();
2328 if( bUpdatePreview
&& !m_xBtnLight
->get_active() )
2332 IMPL_LINK( Svx3DWin
, ClickHdl
, weld::Button
&, rBtn
, void )
2334 bool bUpdatePreview
= false;
2335 sal_uInt16 nSId
= 0;
2337 if( &rBtn
== m_xBtnConvertTo3D
.get() )
2339 nSId
= SID_CONVERT_TO_3D
;
2341 else if( &rBtn
== m_xBtnLatheObject
.get() )
2343 nSId
= SID_CONVERT_TO_3D_LATHE_FAST
;
2346 else if( &rBtn
== m_xBtnNormalsObj
.get() ||
2347 &rBtn
== m_xBtnNormalsFlat
.get() ||
2348 &rBtn
== m_xBtnNormalsSphere
.get() )
2350 m_xBtnNormalsObj
->set_active( &rBtn
== m_xBtnNormalsObj
.get() );
2351 m_xBtnNormalsFlat
->set_active( &rBtn
== m_xBtnNormalsFlat
.get() );
2352 m_xBtnNormalsSphere
->set_active( &rBtn
== m_xBtnNormalsSphere
.get() );
2353 bUpdatePreview
= true;
2355 else if( &rBtn
== m_xBtnLight1
->get_widget() ||
2356 &rBtn
== m_xBtnLight2
->get_widget() ||
2357 &rBtn
== m_xBtnLight3
->get_widget() ||
2358 &rBtn
== m_xBtnLight4
->get_widget() ||
2359 &rBtn
== m_xBtnLight5
->get_widget() ||
2360 &rBtn
== m_xBtnLight6
->get_widget() ||
2361 &rBtn
== m_xBtnLight7
->get_widget() ||
2362 &rBtn
== m_xBtnLight8
->get_widget() )
2365 LightButton
* pToggleBtn
= GetLbByButton(&rBtn
);
2367 ColorListBox
* pLb
= GetCLbByButton(pToggleBtn
);
2370 bool bIsChecked
= pToggleBtn
->get_prev_active();
2372 if (pToggleBtn
!= m_xBtnLight1
.get() && m_xBtnLight1
->get_active())
2374 m_xBtnLight1
->set_active( false );
2375 m_xBtnLight1
->set_prev_active(false);
2376 m_xLbLight1
->hide();
2378 if (pToggleBtn
!= m_xBtnLight2
.get() && m_xBtnLight2
->get_active())
2380 m_xBtnLight2
->set_active( false );
2381 m_xBtnLight2
->set_prev_active(false);
2382 m_xLbLight2
->hide();
2384 if( pToggleBtn
!= m_xBtnLight3
.get() && m_xBtnLight3
->get_active() )
2386 m_xBtnLight3
->set_active( false );
2387 m_xBtnLight3
->set_prev_active(false);
2388 m_xLbLight3
->hide();
2390 if( pToggleBtn
!= m_xBtnLight4
.get() && m_xBtnLight4
->get_active() )
2392 m_xBtnLight4
->set_active( false );
2393 m_xBtnLight4
->set_prev_active(false);
2394 m_xLbLight4
->hide();
2396 if( pToggleBtn
!= m_xBtnLight5
.get() && m_xBtnLight5
->get_active() )
2398 m_xBtnLight5
->set_active( false );
2399 m_xBtnLight5
->set_prev_active(false);
2400 m_xLbLight5
->hide();
2402 if( pToggleBtn
!= m_xBtnLight6
.get() && m_xBtnLight6
->get_active() )
2404 m_xBtnLight6
->set_active( false );
2405 m_xBtnLight6
->set_prev_active(false);
2406 m_xLbLight6
->hide();
2408 if( pToggleBtn
!= m_xBtnLight7
.get() && m_xBtnLight7
->get_active() )
2410 m_xBtnLight7
->set_active( false );
2411 m_xBtnLight7
->set_prev_active(false);
2412 m_xLbLight7
->hide();
2414 if( pToggleBtn
!= m_xBtnLight8
.get() && m_xBtnLight8
->get_active() )
2416 m_xBtnLight8
->set_active( false );
2417 m_xBtnLight8
->set_prev_active(false);
2418 m_xLbLight8
->hide();
2421 //update light button
2422 pToggleBtn
->set_active(true);
2423 pToggleBtn
->set_prev_active(true);
2425 pToggleBtn
->switchLightOn(!pToggleBtn
->isLightOn());
2427 bool bEnable
= pToggleBtn
->isLightOn();
2428 m_xBtnLightColor
->set_sensitive( bEnable
);
2429 pLb
->set_sensitive( bEnable
);
2431 ClickLight(*pToggleBtn
);
2432 bUpdatePreview
= true;
2435 else if( &rBtn
== m_xBtnTexLuminance
.get() ||
2436 &rBtn
== m_xBtnTexColor
.get() )
2438 m_xBtnTexLuminance
->set_active( &rBtn
== m_xBtnTexLuminance
.get() );
2439 m_xBtnTexColor
->set_active( &rBtn
== m_xBtnTexColor
.get() );
2440 bUpdatePreview
= true;
2442 else if( &rBtn
== m_xBtnTexReplace
.get() ||
2443 &rBtn
== m_xBtnTexModulate
.get() )
2445 m_xBtnTexReplace
->set_active( &rBtn
== m_xBtnTexReplace
.get() );
2446 m_xBtnTexModulate
->set_active( &rBtn
== m_xBtnTexModulate
.get() );
2447 bUpdatePreview
= true;
2449 else if( &rBtn
== m_xBtnTexParallelX
.get() ||
2450 &rBtn
== m_xBtnTexCircleX
.get() ||
2451 &rBtn
== m_xBtnTexObjectX
.get() )
2453 m_xBtnTexParallelX
->set_active( &rBtn
== m_xBtnTexParallelX
.get() );
2454 m_xBtnTexCircleX
->set_active( &rBtn
== m_xBtnTexCircleX
.get() );
2455 m_xBtnTexObjectX
->set_active( &rBtn
== m_xBtnTexObjectX
.get() );
2456 bUpdatePreview
= true;
2458 else if( &rBtn
== m_xBtnTexParallelY
.get() ||
2459 &rBtn
== m_xBtnTexCircleY
.get() ||
2460 &rBtn
== m_xBtnTexObjectY
.get() )
2462 m_xBtnTexParallelY
->set_active( &rBtn
== m_xBtnTexParallelY
.get() );
2463 m_xBtnTexCircleY
->set_active( &rBtn
== m_xBtnTexCircleY
.get() );
2464 m_xBtnTexObjectY
->set_active( &rBtn
== m_xBtnTexObjectY
.get() );
2465 bUpdatePreview
= true;
2467 else if (&rBtn
== m_xBtnShadow3d
.get())
2469 m_xFtSlant
->set_sensitive( m_xBtnShadow3d
->get_active() );
2470 m_xMtrSlant
->set_sensitive( m_xBtnShadow3d
->get_active() );
2471 bUpdatePreview
= true;
2473 // Other (no groups)
2476 bUpdatePreview
= true;
2481 SfxDispatcher
* pDispatcher
= LocalGetDispatcher(pBindings
);
2482 if (pDispatcher
!= nullptr)
2484 SfxBoolItem
aItem( nSId
, true );
2485 pDispatcher
->ExecuteList(nSId
,
2486 SfxCallMode::ASYNCHRON
| SfxCallMode::RECORD
, { &aItem
});
2489 else if( bUpdatePreview
)
2493 IMPL_LINK( Svx3DWin
, ClickColorHdl
, weld::Button
&, rBtn
, void)
2495 SvColorDialog aColorDlg
;
2498 if( &rBtn
== m_xBtnLightColor
.get() )
2499 pLb
= GetCLbByButton();
2500 else if( &rBtn
== m_xBtnAmbientColor
.get() )
2501 pLb
= m_xLbAmbientlight
.get();
2502 else if( &rBtn
== m_xBtnMatColor
.get() )
2503 pLb
= m_xLbMatColor
.get();
2504 else if( &rBtn
== m_xBtnEmissionColor
.get() )
2505 pLb
= m_xLbMatEmission
.get();
2506 else // if( &rBtn == m_xBtnSpecularColor.get() )
2507 pLb
= m_xLbMatSpecular
.get();
2509 Color aColor
= pLb
->GetSelectEntryColor();
2511 aColorDlg
.SetColor( aColor
);
2512 if( aColorDlg
.Execute(GetFrameWeld()) == RET_OK
)
2514 aColor
= aColorDlg
.GetColor();
2515 LBSelectColor(pLb
, aColor
);
2516 SelectColorHdl(*pLb
);
2520 IMPL_LINK( Svx3DWin
, SelectHdl
, weld::ComboBox
&, rListBox
, void )
2522 bool bUpdatePreview
= false;
2525 if (&rListBox
== m_xLbMatFavorites
.get())
2527 Color
aColObj( COL_WHITE
);
2528 Color
aColEmis( COL_BLACK
);
2529 Color
aColSpec( COL_WHITE
);
2530 sal_uInt16 nSpecIntens
= 20;
2532 switch( m_xLbMatFavorites
->get_active() )
2536 aColObj
= Color(230,230,255);
2537 aColEmis
= Color(10,10,30);
2538 aColSpec
= Color(200,200,200);
2545 aColObj
= Color(230,255,0);
2546 aColEmis
= Color(51,0,0);
2547 aColSpec
= Color(255,255,240);
2554 aColObj
= Color(36,117,153);
2555 aColEmis
= Color(18,30,51);
2556 aColSpec
= Color(230,230,255);
2563 aColObj
= Color(255,48,57);
2564 aColEmis
= Color(35,0,0);
2565 aColSpec
= Color(179,202,204);
2572 aColObj
= Color(153,71,1);
2573 aColEmis
= Color(21,22,0);
2574 aColSpec
= Color(255,255,153);
2579 LBSelectColor( m_xLbMatColor
.get(), aColObj
);
2580 LBSelectColor( m_xLbMatEmission
.get(), aColEmis
);
2581 LBSelectColor( m_xLbMatSpecular
.get(), aColSpec
);
2582 m_xMtrMatSpecularIntensity
->set_value(nSpecIntens
, FieldUnit::PERCENT
);
2584 bUpdatePreview
= true;
2586 else if (&rListBox
== m_xLbShademode
.get())
2587 bUpdatePreview
= true;
2589 if( bUpdatePreview
)
2593 IMPL_LINK( Svx3DWin
, SelectColorHdl
, ColorListBox
&, rListBox
, void )
2595 bool bUpdatePreview
= false;
2597 if( &rListBox
== m_xLbMatColor
.get() ||
2598 &rListBox
== m_xLbMatEmission
.get() ||
2599 &rListBox
== m_xLbMatSpecular
.get() )
2601 m_xLbMatFavorites
->set_active( 0 );
2602 bUpdatePreview
= true;
2605 else if( &rListBox
== m_xLbAmbientlight
.get() )
2607 bUpdatePreview
= true;
2609 else if( &rListBox
== m_xLbLight1
.get() ||
2610 &rListBox
== m_xLbLight2
.get() ||
2611 &rListBox
== m_xLbLight3
.get() ||
2612 &rListBox
== m_xLbLight4
.get() ||
2613 &rListBox
== m_xLbLight5
.get() ||
2614 &rListBox
== m_xLbLight6
.get() ||
2615 &rListBox
== m_xLbLight7
.get() ||
2616 &rListBox
== m_xLbLight8
.get() )
2618 bUpdatePreview
= true;
2621 if( bUpdatePreview
)
2625 IMPL_LINK_NOARG( Svx3DWin
, ModifyMetricHdl
, weld::MetricSpinButton
&, void )
2630 IMPL_LINK_NOARG( Svx3DWin
, ModifySpinHdl
, weld::SpinButton
&, void )
2635 void Svx3DWin::ClickLight(const LightButton
& rBtn
)
2637 sal_uInt16 nLightSource
= GetLightSource( &rBtn
);
2638 ColorListBox
* pLb
= GetCLbByButton( &rBtn
);
2639 Color
aColor( pLb
->GetSelectEntryColor() );
2640 SfxItemSet
aLightItemSet(m_xCtlLightPreview
->GetSvx3DLightControl().Get3DAttributes());
2641 const bool bOnOff(rBtn
.isLightOn());
2643 switch(nLightSource
)
2645 case 0: aLightItemSet
.Put(makeSvx3DLightcolor1Item(aColor
)); aLightItemSet
.Put(makeSvx3DLightOnOff1Item(bOnOff
)); break;
2646 case 1: aLightItemSet
.Put(makeSvx3DLightcolor2Item(aColor
)); aLightItemSet
.Put(makeSvx3DLightOnOff2Item(bOnOff
)); break;
2647 case 2: aLightItemSet
.Put(makeSvx3DLightcolor3Item(aColor
)); aLightItemSet
.Put(makeSvx3DLightOnOff3Item(bOnOff
)); break;
2648 case 3: aLightItemSet
.Put(makeSvx3DLightcolor4Item(aColor
)); aLightItemSet
.Put(makeSvx3DLightOnOff4Item(bOnOff
)); break;
2649 case 4: aLightItemSet
.Put(makeSvx3DLightcolor5Item(aColor
)); aLightItemSet
.Put(makeSvx3DLightOnOff5Item(bOnOff
)); break;
2650 case 5: aLightItemSet
.Put(makeSvx3DLightcolor6Item(aColor
)); aLightItemSet
.Put(makeSvx3DLightOnOff6Item(bOnOff
)); break;
2651 case 6: aLightItemSet
.Put(makeSvx3DLightcolor7Item(aColor
)); aLightItemSet
.Put(makeSvx3DLightOnOff7Item(bOnOff
)); break;
2653 case 7: aLightItemSet
.Put(makeSvx3DLightcolor8Item(aColor
)); aLightItemSet
.Put(makeSvx3DLightOnOff8Item(bOnOff
)); break;
2656 m_xCtlLightPreview
->GetSvx3DLightControl().Set3DAttributes(aLightItemSet
);
2657 m_xCtlLightPreview
->GetSvx3DLightControl().SelectLight(nLightSource
);
2658 m_xCtlLightPreview
->CheckSelection();
2661 IMPL_LINK_NOARG(Svx3DWin
, ChangeSelectionCallbackHdl
, SvxLightCtl3D
*, void)
2663 const sal_uInt32
nLight(m_xCtlLightPreview
->GetSvx3DLightControl().GetSelectedLight());
2664 weld::Button
* pBtn
= nullptr;
2668 case 0: pBtn
= m_xBtnLight1
->get_widget(); break;
2669 case 1: pBtn
= m_xBtnLight2
->get_widget(); break;
2670 case 2: pBtn
= m_xBtnLight3
->get_widget(); break;
2671 case 3: pBtn
= m_xBtnLight4
->get_widget(); break;
2672 case 4: pBtn
= m_xBtnLight5
->get_widget(); break;
2673 case 5: pBtn
= m_xBtnLight6
->get_widget(); break;
2674 case 6: pBtn
= m_xBtnLight7
->get_widget(); break;
2675 case 7: pBtn
= m_xBtnLight8
->get_widget(); break;
2683 // Status: No lamp selected
2684 if( m_xBtnLight1
->get_active() )
2686 m_xBtnLight1
->set_active( false );
2687 m_xLbLight1
->set_sensitive( false );
2689 else if( m_xBtnLight2
->get_active() )
2691 m_xBtnLight2
->set_active( false );
2692 m_xLbLight2
->set_sensitive( false );
2694 else if( m_xBtnLight3
->get_active() )
2696 m_xBtnLight3
->set_active( false );
2697 m_xLbLight3
->set_sensitive( false );
2699 else if( m_xBtnLight4
->get_active() )
2701 m_xBtnLight4
->set_active( false );
2702 m_xLbLight4
->set_sensitive( false );
2704 else if( m_xBtnLight5
->get_active() )
2706 m_xBtnLight5
->set_active( false );
2707 m_xLbLight5
->set_sensitive( false );
2709 else if( m_xBtnLight6
->get_active() )
2711 m_xBtnLight6
->set_active( false );
2712 m_xLbLight6
->set_sensitive( false );
2714 else if( m_xBtnLight7
->get_active() )
2716 m_xBtnLight7
->set_active( false );
2717 m_xLbLight7
->set_sensitive( false );
2719 else if( m_xBtnLight8
->get_active() )
2721 m_xBtnLight8
->set_active( false );
2722 m_xLbLight8
->set_sensitive( false );
2724 m_xBtnLightColor
->set_sensitive( false );
2730 OUString
lcl_makeColorName(const Color
& rColor
)
2732 OUString aStr
= SvxResId(RID_SVXFLOAT3D_FIX_R
) +
2733 OUString::number(rColor
.GetRed()) +
2735 SvxResId(RID_SVXFLOAT3D_FIX_G
) +
2736 OUString::number(rColor
.GetGreen()) +
2738 SvxResId(RID_SVXFLOAT3D_FIX_B
) +
2739 OUString::number(rColor
.GetBlue());
2744 // Method to ensure that the LB is also associated with a color
2745 void Svx3DWin::LBSelectColor( ColorListBox
* pLb
, const Color
& rColor
)
2747 pLb
->SetNoSelection();
2748 pLb
->SelectEntry({rColor
, lcl_makeColorName(rColor
)});
2751 void Svx3DWin::UpdatePreview()
2755 pModel
.reset(new FmFormModel());
2759 SfxItemSetFixed
<SDRATTR_START
, SDRATTR_END
> aSet( pModel
->GetItemPool() );
2761 // Get Attributes and set the preview
2763 m_xCtlPreview
->Set3DAttributes( aSet
);
2764 m_xCtlLightPreview
->GetSvx3DLightControl().Set3DAttributes( aSet
);
2768 // document is to be reloaded, destroy remembered ItemSet
2769 void Svx3DWin::DocumentReload()
2771 mpRemember2DAttributes
.reset();
2774 void Svx3DWin::InitColorLB()
2777 Color
aColWhite( COL_WHITE
);
2778 Color
aColBlack( COL_BLACK
);
2779 m_xLbLight1
->SelectEntry( aColWhite
);
2780 m_xLbLight2
->SelectEntry( aColWhite
);
2781 m_xLbLight3
->SelectEntry( aColWhite
);
2782 m_xLbLight4
->SelectEntry( aColWhite
);
2783 m_xLbLight5
->SelectEntry( aColWhite
);
2784 m_xLbLight6
->SelectEntry( aColWhite
);
2785 m_xLbLight7
->SelectEntry( aColWhite
);
2786 m_xLbLight8
->SelectEntry( aColWhite
);
2787 m_xLbAmbientlight
->SelectEntry( aColBlack
);
2788 m_xLbMatColor
->SelectEntry( aColWhite
);
2789 m_xLbMatEmission
->SelectEntry( aColBlack
);
2790 m_xLbMatSpecular
->SelectEntry( aColWhite
);
2793 sal_uInt16
Svx3DWin::GetLightSource( const LightButton
* pBtn
) const
2795 sal_uInt16 nLight
= 8;
2797 if (pBtn
== m_xBtnLight1
.get())
2799 else if (pBtn
== m_xBtnLight2
.get())
2801 else if( pBtn
== m_xBtnLight3
.get() )
2803 else if( pBtn
== m_xBtnLight4
.get() )
2805 else if( pBtn
== m_xBtnLight5
.get() )
2807 else if( pBtn
== m_xBtnLight6
.get() )
2809 else if( pBtn
== m_xBtnLight7
.get() )
2811 else if( pBtn
== m_xBtnLight8
.get() )
2817 ColorListBox
* Svx3DWin::GetCLbByButton( const LightButton
* pBtn
)
2819 ColorListBox
* pLb
= nullptr;
2821 if( pBtn
== nullptr )
2823 if( m_xBtnLight1
->get_active() )
2824 pLb
= m_xLbLight1
.get();
2825 else if( m_xBtnLight2
->get_active() )
2826 pLb
= m_xLbLight2
.get();
2827 else if( m_xBtnLight3
->get_active() )
2828 pLb
= m_xLbLight3
.get();
2829 else if( m_xBtnLight4
->get_active() )
2830 pLb
= m_xLbLight4
.get();
2831 else if( m_xBtnLight5
->get_active() )
2832 pLb
= m_xLbLight5
.get();
2833 else if( m_xBtnLight6
->get_active() )
2834 pLb
= m_xLbLight6
.get();
2835 else if( m_xBtnLight7
->get_active() )
2836 pLb
= m_xLbLight7
.get();
2837 else if( m_xBtnLight8
->get_active() )
2838 pLb
= m_xLbLight8
.get();
2842 if( pBtn
== m_xBtnLight1
.get() )
2843 pLb
= m_xLbLight1
.get();
2844 else if (pBtn
== m_xBtnLight2
.get())
2845 pLb
= m_xLbLight2
.get();
2846 else if( pBtn
== m_xBtnLight3
.get() )
2847 pLb
= m_xLbLight3
.get();
2848 else if( pBtn
== m_xBtnLight4
.get() )
2849 pLb
= m_xLbLight4
.get();
2850 else if( pBtn
== m_xBtnLight5
.get() )
2851 pLb
= m_xLbLight5
.get();
2852 else if( pBtn
== m_xBtnLight6
.get() )
2853 pLb
= m_xLbLight6
.get();
2854 else if( pBtn
== m_xBtnLight7
.get() )
2855 pLb
= m_xLbLight7
.get();
2856 else if( pBtn
== m_xBtnLight8
.get() )
2857 pLb
= m_xLbLight8
.get();
2862 LightButton
* Svx3DWin::GetLbByButton( const weld::Button
* pBtn
)
2864 LightButton
* pLb
= nullptr;
2866 if( pBtn
== m_xBtnLight1
->get_widget() )
2867 pLb
= m_xBtnLight1
.get();
2868 else if (pBtn
== m_xBtnLight2
->get_widget() )
2869 pLb
= m_xBtnLight2
.get();
2870 else if( pBtn
== m_xBtnLight3
->get_widget() )
2871 pLb
= m_xBtnLight3
.get();
2872 else if( pBtn
== m_xBtnLight4
->get_widget() )
2873 pLb
= m_xBtnLight4
.get();
2874 else if( pBtn
== m_xBtnLight5
->get_widget() )
2875 pLb
= m_xBtnLight5
.get();
2876 else if( pBtn
== m_xBtnLight6
->get_widget() )
2877 pLb
= m_xBtnLight6
.get();
2878 else if( pBtn
== m_xBtnLight7
->get_widget() )
2879 pLb
= m_xBtnLight7
.get();
2880 else if( pBtn
== m_xBtnLight8
->get_widget() )
2881 pLb
= m_xBtnLight8
.get();
2886 // Derivation from SfxChildWindow as "containers" for effects
2887 Svx3DChildWindow::Svx3DChildWindow( vcl::Window
* _pParent
,
2889 SfxBindings
* pBindings
,
2890 SfxChildWinInfo
* pInfo
) :
2891 SfxChildWindow( _pParent
, nId
)
2893 VclPtr
<Svx3DWin
> pWin
= VclPtr
<Svx3DWin
>::Create( pBindings
, this, _pParent
);
2896 pWin
->Initialize( pInfo
);
2899 Svx3DCtrlItem::Svx3DCtrlItem( sal_uInt16 _nId
,
2900 SfxBindings
* _pBindings
) :
2901 SfxControllerItem( _nId
, *_pBindings
)
2906 void Svx3DCtrlItem::StateChangedAtToolBoxControl( sal_uInt16
/*nSId*/,
2907 SfxItemState
/*eState*/, const SfxPoolItem
* /*pItem*/ )
2911 // ControllerItem for Status Slot SID_CONVERT_TO_3D
2913 SvxConvertTo3DItem::SvxConvertTo3DItem(sal_uInt16 _nId
, SfxBindings
* _pBindings
)
2914 : SfxControllerItem(_nId
, *_pBindings
),
2919 void SvxConvertTo3DItem::StateChangedAtToolBoxControl(sal_uInt16
/*_nId*/, SfxItemState eState
, const SfxPoolItem
* /*pState*/)
2921 bool bNewState
= (eState
!= SfxItemState::DISABLED
);
2922 if(bNewState
!= bState
)
2925 SfxDispatcher
* pDispatcher
= LocalGetDispatcher(&GetBindings());
2926 if (pDispatcher
!= nullptr)
2928 SfxBoolItem
aItem( SID_3D_STATE
, true );
2929 pDispatcher
->ExecuteList(SID_3D_STATE
,
2930 SfxCallMode::ASYNCHRON
|SfxCallMode::RECORD
, { &aItem
});
2935 LightButton::LightButton(std::unique_ptr
<weld::ToggleButton
> xButton
)
2936 : m_xButton(std::move(xButton
))
2938 , m_bButtonPrevActive(false)
2940 m_xButton
->set_from_icon_name(RID_SVXBMP_LAMP_OFF
);
2943 void LightButton::switchLightOn(bool bOn
)
2945 if (m_bLightOn
== bOn
)
2949 m_xButton
->set_from_icon_name(RID_SVXBMP_LAMP_ON
);
2951 m_xButton
->set_from_icon_name(RID_SVXBMP_LAMP_OFF
);
2954 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */