Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / svx / source / engine3d / float3d.cxx
blob035ca293faa693c7df7037ef70c77dce4708d95c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
54 #include <bitmaps.hlst>
56 using namespace com::sun::star;
58 SFX_IMPL_DOCKINGWINDOW_WITHID( Svx3DChildWindow, SID_3D_WIN )
60 struct Svx3DWinImpl
62 SfxItemPool* pPool;
65 namespace {
66 /** Get the dispatcher from the current view frame, or, if that is not
67 available, from the given bindings.
68 @param pBindings
69 May be NULL.
70 @returns NULL when both the current view frame is NULL and the given
71 bindings are NULL.
73 SfxDispatcher* LocalGetDispatcher (const SfxBindings* pBindings)
75 SfxDispatcher* pDispatcher = nullptr;
77 if (SfxViewFrame* pViewFrame = SfxViewFrame::Current())
78 pDispatcher = pViewFrame->GetDispatcher();
79 else if (pBindings != nullptr)
80 pDispatcher = pBindings->GetDispatcher();
82 return pDispatcher;
86 Svx3DWin::Svx3DWin(SfxBindings* pInBindings, SfxChildWindow *pCW, vcl::Window* pParent)
87 : SfxDockingWindow(pInBindings, pCW, pParent,
88 "Docking3DEffects", "svx/ui/docking3deffects.ui")
90 , m_xBtnGeo(m_xBuilder->weld_toggle_button("geometry"))
91 , m_xBtnRepresentation(m_xBuilder->weld_toggle_button("representation"))
92 , m_xBtnLight(m_xBuilder->weld_toggle_button("light"))
93 , m_xBtnTexture(m_xBuilder->weld_toggle_button("texture"))
94 , m_xBtnMaterial(m_xBuilder->weld_toggle_button("material"))
95 , m_xBtnUpdate(m_xBuilder->weld_toggle_button("update"))
96 , m_xBtnAssign(m_xBuilder->weld_button("assign"))
98 , m_xFLGeometrie(m_xBuilder->weld_container("geoframe"))
99 , m_xFtPercentDiagonal(m_xBuilder->weld_label("diagonalft"))
100 , m_xMtrPercentDiagonal(m_xBuilder->weld_metric_spin_button("diagonal", FieldUnit::PERCENT))
101 , m_xFtBackscale(m_xBuilder->weld_label("scaleddepthft"))
102 , m_xMtrBackscale(m_xBuilder->weld_metric_spin_button("scaleddepth", FieldUnit::PERCENT))
103 , m_xFtEndAngle(m_xBuilder->weld_label("angleft"))
104 , m_xMtrEndAngle(m_xBuilder->weld_metric_spin_button("angle", FieldUnit::DEGREE))
105 , m_xFtDepth(m_xBuilder->weld_label("depthft"))
106 , m_xMtrDepth(m_xBuilder->weld_metric_spin_button("depth", FieldUnit::CM))
108 , m_xFLSegments(m_xBuilder->weld_container("segmentsframe"))
109 , m_xNumHorizontal(m_xBuilder->weld_spin_button("hori"))
110 , m_xNumVertical(m_xBuilder->weld_spin_button("veri"))
112 , m_xFLNormals(m_xBuilder->weld_container("normals"))
113 , m_xBtnNormalsObj(m_xBuilder->weld_toggle_button("objspecific"))
114 , m_xBtnNormalsFlat(m_xBuilder->weld_toggle_button("flat"))
115 , m_xBtnNormalsSphere(m_xBuilder->weld_toggle_button("spherical"))
116 , m_xBtnNormalsInvert(m_xBuilder->weld_toggle_button("invertnormals"))
117 , m_xBtnTwoSidedLighting(m_xBuilder->weld_toggle_button("doublesidedillum"))
118 , m_xBtnDoubleSided(m_xBuilder->weld_toggle_button("doublesided"))
120 , m_xFLRepresentation(m_xBuilder->weld_container("shadingframe"))
121 , m_xLbShademode(m_xBuilder->weld_combo_box("mode"))
123 , m_xFLShadow(m_xBuilder->weld_container("shadowframe"))
124 , m_xBtnShadow3d(m_xBuilder->weld_toggle_button("shadow"))
125 , m_xFtSlant(m_xBuilder->weld_label("slantft"))
126 , m_xMtrSlant(m_xBuilder->weld_metric_spin_button("slant", FieldUnit::DEGREE))
128 , m_xFLCamera(m_xBuilder->weld_container("cameraframe"))
129 , m_xMtrDistance(m_xBuilder->weld_metric_spin_button("distance", FieldUnit::CM))
130 , m_xMtrFocalLength(m_xBuilder->weld_metric_spin_button("focal", FieldUnit::CM))
132 , m_xFLLight(m_xBuilder->weld_container("illumframe"))
133 , m_xBtnLight1(new LightButton(m_xBuilder->weld_toggle_button("light1")))
134 , m_xBtnLight2(new LightButton(m_xBuilder->weld_toggle_button("light2")))
135 , m_xBtnLight3(new LightButton(m_xBuilder->weld_toggle_button("light3")))
136 , m_xBtnLight4(new LightButton(m_xBuilder->weld_toggle_button("light4")))
137 , m_xBtnLight5(new LightButton(m_xBuilder->weld_toggle_button("light5")))
138 , m_xBtnLight6(new LightButton(m_xBuilder->weld_toggle_button("light6")))
139 , m_xBtnLight7(new LightButton(m_xBuilder->weld_toggle_button("light7")))
140 , m_xBtnLight8(new LightButton(m_xBuilder->weld_toggle_button("light8")))
141 , m_xLbLight1(new ColorListBox(m_xBuilder->weld_menu_button("lightcolor1"), [this]{ return GetFrameWeld(); }))
142 , m_xLbLight2(new ColorListBox(m_xBuilder->weld_menu_button("lightcolor2"), [this]{ return GetFrameWeld(); }))
143 , m_xLbLight3(new ColorListBox(m_xBuilder->weld_menu_button("lightcolor3"), [this]{ return GetFrameWeld(); }))
144 , m_xLbLight4(new ColorListBox(m_xBuilder->weld_menu_button("lightcolor4"), [this]{ return GetFrameWeld(); }))
145 , m_xLbLight5(new ColorListBox(m_xBuilder->weld_menu_button("lightcolor5"), [this]{ return GetFrameWeld(); }))
146 , m_xLbLight6(new ColorListBox(m_xBuilder->weld_menu_button("lightcolor6"), [this]{ return GetFrameWeld(); }))
147 , m_xLbLight7(new ColorListBox(m_xBuilder->weld_menu_button("lightcolor7"), [this]{ return GetFrameWeld(); }))
148 , m_xLbLight8(new ColorListBox(m_xBuilder->weld_menu_button("lightcolor8"), [this]{ return GetFrameWeld(); }))
149 , m_xBtnLightColor(m_xBuilder->weld_button("colorbutton1"))
150 , m_xLbAmbientlight(new ColorListBox(m_xBuilder->weld_menu_button("ambientcolor"), [this]{ return GetFrameWeld(); }))
151 , m_xBtnAmbientColor(m_xBuilder->weld_button("colorbutton2"))
153 , m_xFLTexture(m_xBuilder->weld_container("textureframe"))
154 , m_xBtnTexLuminance(m_xBuilder->weld_toggle_button("textype"))
155 , m_xBtnTexColor(m_xBuilder->weld_toggle_button("texcolor"))
156 , m_xBtnTexReplace(m_xBuilder->weld_toggle_button("texreplace"))
157 , m_xBtnTexModulate(m_xBuilder->weld_toggle_button("texmodulate"))
158 , m_xBtnTexObjectX(m_xBuilder->weld_toggle_button("texobjx"))
159 , m_xBtnTexParallelX(m_xBuilder->weld_toggle_button("texparallelx"))
160 , m_xBtnTexCircleX(m_xBuilder->weld_toggle_button("texcirclex"))
161 , m_xBtnTexObjectY(m_xBuilder->weld_toggle_button("texobjy"))
162 , m_xBtnTexParallelY(m_xBuilder->weld_toggle_button("texparallely"))
163 , m_xBtnTexCircleY(m_xBuilder->weld_toggle_button("texcircley"))
164 , m_xBtnTexFilter(m_xBuilder->weld_toggle_button("texfilter"))
166 , m_xFLMaterial(m_xBuilder->weld_container("materialframe"))
167 , m_xLbMatFavorites(m_xBuilder->weld_combo_box("favorites"))
168 , m_xLbMatColor(new ColorListBox(m_xBuilder->weld_menu_button("objcolor"), [this]{ return GetFrameWeld(); }))
169 , m_xBtnMatColor(m_xBuilder->weld_button("colorbutton3"))
170 , m_xLbMatEmission(new ColorListBox(m_xBuilder->weld_menu_button("illumcolor"), [this]{ return GetFrameWeld(); }))
171 , m_xBtnEmissionColor(m_xBuilder->weld_button("colorbutton4"))
173 , m_xFLMatSpecular(m_xBuilder->weld_container("specframe"))
174 , m_xLbMatSpecular(new ColorListBox(m_xBuilder->weld_menu_button("speccolor"), [this]{ return GetFrameWeld(); }))
175 , m_xBtnSpecularColor(m_xBuilder->weld_button("colorbutton5"))
176 , m_xMtrMatSpecularIntensity(m_xBuilder->weld_metric_spin_button("intensity", FieldUnit::PERCENT))
178 , m_xCtlPreview(new Svx3DPreviewControl)
179 , m_xCtlPreviewWin(new weld::CustomWeld(*m_xBuilder, "preview", *m_xCtlPreview))
181 , m_xLightPreviewGrid(m_xBuilder->weld_container("lightpreviewgrid"))
182 , m_xHoriScale(m_xBuilder->weld_scale("horiscale"))
183 , m_xVertScale(m_xBuilder->weld_scale("vertscale"))
184 , m_xBtn_Corner(m_xBuilder->weld_button("corner"))
185 , m_xLightPreview(new Svx3DLightControl)
186 , m_xCtlLightPreviewWin(new weld::CustomWeld(*m_xBuilder, "lightpreview", *m_xLightPreview))
187 , m_xCtlLightPreview(new SvxLightCtl3D(*m_xLightPreview, *m_xHoriScale, *m_xVertScale, *m_xBtn_Corner)) // TODO might be other body widget as arg 1
189 , m_xBtnConvertTo3D(m_xBuilder->weld_button("to3d"))
190 , m_xBtnLatheObject(m_xBuilder->weld_button("tolathe"))
191 , m_xBtnPerspective(m_xBuilder->weld_toggle_button("perspective"))
193 , bUpdate(false)
194 , eViewType(ViewType3D::Geo)
195 , pBindings(pInBindings)
196 , mpImpl(new Svx3DWinImpl)
197 , ePoolUnit(MapUnit::MapMM)
199 SetText(SvxResId(RID_SVXDLG_FLOAT3D_STR_TITLE));
201 weld::DrawingArea* pDrawingArea = m_xCtlPreview->GetDrawingArea();
202 Size aSize(pDrawingArea->get_ref_device().LogicToPixel(Size(83, 76), MapMode(MapUnit::MapAppFont)));
203 pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
204 m_xCtlPreview->SetOutputSizePixel(aSize);
206 m_xLightPreviewGrid->set_size_request(aSize.Width(), aSize.Height());
207 pDrawingArea = m_xLightPreview->GetDrawingArea();
208 pDrawingArea->set_size_request(42, 42); // small to fit to m_xLightPreviewGrid
210 mpImpl->pPool = nullptr;
212 // Set Metric
213 eFUnit = pInBindings->GetDispatcher()->GetModule()->GetFieldUnit();
215 m_xMtrDepth->set_unit( eFUnit );
216 m_xMtrDistance->set_unit( eFUnit );
217 m_xMtrFocalLength->set_unit( eFUnit );
219 pControllerItem.reset( new Svx3DCtrlItem(SID_3D_STATE, pBindings) );
220 pConvertTo3DItem.reset( new SvxConvertTo3DItem(SID_CONVERT_TO_3D, pBindings) );
221 pConvertTo3DLatheItem.reset( new SvxConvertTo3DItem(SID_CONVERT_TO_3D_LATHE_FAST, pBindings) );
223 m_xBtnAssign->connect_clicked( LINK( this, Svx3DWin, ClickAssignHdl ) );
224 m_xBtnUpdate->connect_toggled( LINK( this, Svx3DWin, ClickUpdateHdl ) );
226 Link<weld::Button&,void> aLink( LINK( this, Svx3DWin, ClickViewTypeHdl ) );
227 m_xBtnGeo->connect_clicked( aLink );
228 m_xBtnRepresentation->connect_clicked( aLink );
229 m_xBtnLight->connect_clicked( aLink );
230 m_xBtnTexture->connect_clicked( aLink );
231 m_xBtnMaterial->connect_clicked( aLink );
233 aLink = LINK( this, Svx3DWin, ClickHdl );
234 m_xBtnPerspective->connect_clicked( aLink );
235 m_xBtnConvertTo3D->connect_clicked( aLink );
236 m_xBtnLatheObject->connect_clicked( aLink );
238 // Geometry
239 m_xBtnNormalsObj->connect_clicked( aLink );
240 m_xBtnNormalsFlat->connect_clicked( aLink );
241 m_xBtnNormalsSphere->connect_clicked( aLink );
242 m_xBtnTwoSidedLighting->connect_clicked( aLink );
243 m_xBtnNormalsInvert->connect_clicked( aLink );
244 m_xBtnDoubleSided->connect_clicked( aLink );
246 // Representation
247 m_xBtnShadow3d->connect_clicked( aLink );
249 // Lighting
250 m_xBtnLight1->connect_clicked( aLink );
251 m_xBtnLight2->connect_clicked( aLink );
252 m_xBtnLight3->connect_clicked( aLink );
253 m_xBtnLight4->connect_clicked( aLink );
254 m_xBtnLight5->connect_clicked( aLink );
255 m_xBtnLight6->connect_clicked( aLink );
256 m_xBtnLight7->connect_clicked( aLink );
257 m_xBtnLight8->connect_clicked( aLink );
259 // Textures
260 m_xBtnTexLuminance->connect_clicked( aLink );
261 m_xBtnTexColor->connect_clicked( aLink );
262 m_xBtnTexReplace->connect_clicked( aLink );
263 m_xBtnTexModulate->connect_clicked( aLink );
264 m_xBtnTexParallelX->connect_clicked( aLink );
265 m_xBtnTexCircleX->connect_clicked( aLink );
266 m_xBtnTexObjectX->connect_clicked( aLink );
267 m_xBtnTexParallelY->connect_clicked( aLink );
268 m_xBtnTexCircleY->connect_clicked( aLink );
269 m_xBtnTexObjectY->connect_clicked( aLink );
270 m_xBtnTexFilter->connect_clicked( aLink );
272 // Material
273 aLink = LINK( this, Svx3DWin, ClickColorHdl );
274 m_xBtnLightColor->connect_clicked( aLink );
275 m_xBtnAmbientColor->connect_clicked( aLink );
276 m_xBtnMatColor->connect_clicked( aLink );
277 m_xBtnEmissionColor->connect_clicked( aLink );
278 m_xBtnSpecularColor->connect_clicked( aLink );
281 Link<weld::ComboBox&,void> aLink2 = LINK( this, Svx3DWin, SelectHdl );
282 Link<ColorListBox&,void> aLink4 = LINK( this, Svx3DWin, SelectColorHdl );
283 m_xLbMatFavorites->connect_changed( aLink2 );
284 m_xLbMatColor->SetSelectHdl( aLink4 );
285 m_xLbMatEmission->SetSelectHdl( aLink4 );
286 m_xLbMatSpecular->SetSelectHdl( aLink4 );
287 m_xLbLight1->SetSelectHdl( aLink4 );
288 m_xLbLight2->SetSelectHdl( aLink4 );
289 m_xLbLight3->SetSelectHdl( aLink4 );
290 m_xLbLight4->SetSelectHdl( aLink4 );
291 m_xLbLight5->SetSelectHdl( aLink4 );
292 m_xLbLight6->SetSelectHdl( aLink4 );
293 m_xLbLight7->SetSelectHdl( aLink4 );
294 m_xLbLight8->SetSelectHdl( aLink4 );
295 m_xLbAmbientlight->SetSelectHdl( aLink4 );
296 m_xLbShademode->connect_changed( aLink2 );
298 Link<weld::MetricSpinButton&,void> aLink3 = LINK( this, Svx3DWin, ModifyMetricHdl );
299 Link<weld::SpinButton&,void> aLink5 = LINK( this, Svx3DWin, ModifySpinHdl );
300 m_xMtrMatSpecularIntensity->connect_value_changed( aLink3 );
301 m_xNumHorizontal->connect_value_changed( aLink5 );
302 m_xNumVertical->connect_value_changed( aLink5 );
303 m_xMtrSlant->connect_value_changed( aLink3 );
305 // Preview callback
306 m_xCtlLightPreview->SetUserSelectionChangeCallback(LINK( this, Svx3DWin, ChangeSelectionCallbackHdl ));
308 aSize = GetOutputSizePixel();
309 SetMinOutputSizePixel( aSize );
311 Construct();
313 // Initiation of the initialization of the ColorLBs
314 SfxDispatcher* pDispatcher = LocalGetDispatcher(pBindings);
315 if (pDispatcher != nullptr)
317 SfxBoolItem aItem( SID_3D_INIT, true );
318 pDispatcher->ExecuteList(SID_3D_INIT,
319 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, { &aItem });
322 Reset();
324 //lock down the size of the initial largest default mode as the permanent size
325 aSize = get_preferred_size();
326 set_width_request(aSize.Width());
327 set_height_request(aSize.Height());
330 Svx3DWin::~Svx3DWin()
332 disposeOnce();
335 void Svx3DWin::dispose()
337 pModel.reset();
339 pControllerItem.reset();
340 pConvertTo3DItem.reset();
341 pConvertTo3DLatheItem.reset();
343 mpImpl.reset();
345 m_xBtnGeo.reset();
346 m_xBtnRepresentation.reset();
347 m_xBtnLight.reset();
348 m_xBtnTexture.reset();
349 m_xBtnMaterial.reset();
350 m_xBtnUpdate.reset();
351 m_xBtnAssign.reset();
352 m_xFLGeometrie.reset();
353 m_xFtPercentDiagonal.reset();
354 m_xMtrPercentDiagonal.reset();
355 m_xFtBackscale.reset();
356 m_xMtrBackscale.reset();
357 m_xFtEndAngle.reset();
358 m_xMtrEndAngle.reset();
359 m_xFtDepth.reset();
360 m_xMtrDepth.reset();
361 m_xFLSegments.reset();
362 m_xNumHorizontal.reset();
363 m_xNumVertical.reset();
364 m_xFLNormals.reset();
365 m_xBtnNormalsObj.reset();
366 m_xBtnNormalsFlat.reset();
367 m_xBtnNormalsSphere.reset();
368 m_xBtnNormalsInvert.reset();
369 m_xBtnTwoSidedLighting.reset();
370 m_xBtnDoubleSided.reset();
371 m_xFLRepresentation.reset();
372 m_xLbShademode.reset();
373 m_xFLShadow.reset();
374 m_xBtnShadow3d.reset();
375 m_xFtSlant.reset();
376 m_xMtrSlant.reset();
377 m_xFLCamera.reset();
378 m_xMtrDistance.reset();
379 m_xMtrFocalLength.reset();
380 m_xFLLight.reset();
381 m_xBtnLight1.reset();
382 m_xBtnLight2.reset();
383 m_xBtnLight3.reset();
384 m_xBtnLight4.reset();
385 m_xBtnLight5.reset();
386 m_xBtnLight6.reset();
387 m_xBtnLight7.reset();
388 m_xBtnLight8.reset();
389 m_xLbLight1.reset();
390 m_xLbLight2.reset();
391 m_xLbLight3.reset();
392 m_xLbLight4.reset();
393 m_xLbLight5.reset();
394 m_xLbLight6.reset();
395 m_xLbLight7.reset();
396 m_xLbLight8.reset();
397 m_xBtnLightColor.reset();
398 m_xLbAmbientlight.reset();
399 m_xBtnAmbientColor.reset();
400 m_xFLTexture.reset();
401 m_xBtnTexLuminance.reset();
402 m_xBtnTexColor.reset();
403 m_xBtnTexReplace.reset();
404 m_xBtnTexModulate.reset();
405 m_xBtnTexObjectX.reset();
406 m_xBtnTexParallelX.reset();
407 m_xBtnTexCircleX.reset();
408 m_xBtnTexObjectY.reset();
409 m_xBtnTexParallelY.reset();
410 m_xBtnTexCircleY.reset();
411 m_xBtnTexFilter.reset();
412 m_xFLMaterial.reset();
413 m_xLbMatFavorites.reset();
414 m_xLbMatColor.reset();
415 m_xBtnMatColor.reset();
416 m_xLbMatEmission.reset();
417 m_xBtnEmissionColor.reset();
418 m_xFLMatSpecular.reset();
419 m_xLbMatSpecular.reset();
420 m_xBtnSpecularColor.reset();
421 m_xMtrMatSpecularIntensity.reset();
422 m_xCtlPreviewWin.reset();
423 m_xCtlPreview.reset();
425 m_xCtlLightPreview.reset();
426 m_xCtlLightPreviewWin.reset();
427 m_xLightPreview.reset();
428 m_xBtn_Corner.reset();
429 m_xVertScale.reset();
430 m_xHoriScale.reset();
431 m_xLightPreviewGrid.reset();
433 m_xBtnConvertTo3D.reset();
434 m_xBtnLatheObject.reset();
435 m_xBtnPerspective.reset();
437 SfxDockingWindow::dispose();
440 void Svx3DWin::Construct()
442 m_xBtnGeo->set_active(true);
443 ClickViewTypeHdl(*m_xBtnGeo);
444 m_xLightPreviewGrid->hide();
447 void Svx3DWin::Reset()
449 // Various initializations, default is AllAttributes
450 m_xLbShademode->set_active( 0 );
451 m_xMtrMatSpecularIntensity->set_value( 50, FieldUnit::PERCENT );
453 m_xBtnLight1->set_active(true);
454 m_xBtnUpdate->set_active(true);
455 ClickUpdateHdl(*m_xBtnUpdate);
457 // Select nothing, to avoid errors when selecting the first
458 m_xCtlLightPreview->GetSvx3DLightControl().SelectLight(0);
459 m_xCtlLightPreview->CheckSelection();
462 void Svx3DWin::Update( SfxItemSet const & rAttrs )
464 // remember 2d attributes
465 if(mpRemember2DAttributes)
466 mpRemember2DAttributes->ClearItem();
467 else
468 mpRemember2DAttributes = std::make_unique<SfxItemSetFixed
469 <SDRATTR_START, SDRATTR_SHADOW_LAST,
470 SDRATTR_3D_FIRST, SDRATTR_3D_LAST>>(*rAttrs.GetPool());
472 SfxWhichIter aIter(*mpRemember2DAttributes);
473 sal_uInt16 nWhich(aIter.FirstWhich());
475 while(nWhich)
477 SfxItemState eState = rAttrs.GetItemState(nWhich, false);
478 if(SfxItemState::DONTCARE == eState)
479 mpRemember2DAttributes->InvalidateItem(nWhich);
480 else if(SfxItemState::SET == eState)
481 mpRemember2DAttributes->Put(rAttrs.Get(nWhich, false));
483 nWhich = aIter.NextWhich();
486 // construct field values
487 const SfxPoolItem* pItem;
489 // Possible determine PoolUnit
490 if( !mpImpl->pPool )
492 mpImpl->pPool = rAttrs.GetPool();
493 DBG_ASSERT( mpImpl->pPool, "Where is the Pool? ");
494 ePoolUnit = mpImpl->pPool->GetMetric( SID_ATTR_LINE_WIDTH );
496 eFUnit = GetModuleFieldUnit( rAttrs );
499 // Segment Number Can be changed? and other states
500 SfxItemState eState = rAttrs.GetItemState( SID_ATTR_3D_INTERN, false, &pItem );
501 if( SfxItemState::SET == eState )
503 sal_uInt32 nState = static_cast<const SfxUInt32Item*>(pItem)->GetValue();
504 bool bExtrude = ( nState & 2 );
505 bool bSphere = ( nState & 4 );
506 bool bCube = ( nState & 8 );
508 bool bChart = ( nState & 32 ); // Chart
510 if( !bChart )
512 // For cube objects are no segments set
513 m_xFLSegments->set_sensitive(!bCube);
515 m_xFtPercentDiagonal->set_sensitive( !bCube && !bSphere );
516 m_xMtrPercentDiagonal->set_sensitive( !bCube && !bSphere );
517 m_xFtBackscale->set_sensitive( !bCube && !bSphere );
518 m_xMtrBackscale->set_sensitive( !bCube && !bSphere );
519 m_xFtDepth->set_sensitive( !bCube && !bSphere );
520 m_xMtrDepth->set_sensitive( !bCube && !bSphere );
521 if( bCube )
523 m_xNumHorizontal->set_text("");
524 m_xNumVertical->set_text("");
526 if( bCube || bSphere )
528 m_xMtrPercentDiagonal->set_text("");
529 m_xMtrBackscale->set_text("");
530 m_xMtrDepth->set_text("");
533 // There is a final angle only for Lathe objects.
534 m_xFtEndAngle->set_sensitive( !bExtrude && !bCube && !bSphere );
535 m_xMtrEndAngle->set_sensitive( !bExtrude && !bCube && !bSphere );
536 if( bExtrude || bCube || bSphere )
537 m_xMtrEndAngle->set_text("");
539 else
541 // Geometry
542 m_xNumHorizontal->set_text("");
543 m_xNumVertical->set_text("");
544 m_xFLSegments->set_sensitive( false );
545 m_xFtEndAngle->set_sensitive( false );
546 m_xMtrEndAngle->set_sensitive( false );
547 m_xMtrEndAngle->set_text("");
548 m_xFtDepth->set_sensitive( false );
549 m_xMtrDepth->set_sensitive( false );
550 m_xMtrDepth->set_text("");
552 // Representation
553 m_xFLShadow->set_sensitive(false);
555 m_xMtrDistance->set_text("");
556 m_xMtrFocalLength->set_text("");
557 m_xFLCamera->set_sensitive( false );
559 //Lower Range
560 m_xBtnConvertTo3D->set_sensitive( false );
561 m_xBtnLatheObject->set_sensitive( false );
564 // Bitmap fill ? -> Status
565 bool bBitmap(false);
566 eState = rAttrs.GetItemState(XATTR_FILLSTYLE);
567 if(eState != SfxItemState::DONTCARE)
569 drawing::FillStyle eXFS = rAttrs.Get(XATTR_FILLSTYLE).GetValue();
570 bBitmap = (eXFS == drawing::FillStyle_BITMAP || eXFS == drawing::FillStyle_GRADIENT || eXFS == drawing::FillStyle_HATCH);
573 m_xFLTexture->set_sensitive(bBitmap);
575 // Geometry
576 // Number of segments (horizontal)
577 if( m_xNumHorizontal->get_sensitive() )
579 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_HORZ_SEGS);
580 if(eState != SfxItemState::DONTCARE)
582 sal_uInt32 nValue = rAttrs.Get(SDRATTR_3DOBJ_HORZ_SEGS).GetValue();
583 if (nValue != static_cast<sal_uInt32>(m_xNumHorizontal->get_value()))
585 m_xNumHorizontal->set_value( nValue );
586 bUpdate = true;
588 else if( m_xNumHorizontal->get_text().isEmpty() )
589 m_xNumHorizontal->set_value( nValue );
591 else
593 if( !m_xNumHorizontal->get_text().isEmpty() )
595 m_xNumHorizontal->set_text("");
596 bUpdate = true;
601 //Number of segments (vertical)
602 if( m_xNumVertical->get_sensitive() )
604 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_VERT_SEGS);
605 if( eState != SfxItemState::DONTCARE )
607 sal_uInt32 nValue = rAttrs.Get(SDRATTR_3DOBJ_VERT_SEGS).GetValue();
608 if( nValue != static_cast<sal_uInt32>(m_xNumVertical->get_value()) )
610 m_xNumVertical->set_value( nValue );
611 bUpdate = true;
613 else if( m_xNumVertical->get_text().isEmpty() )
614 m_xNumVertical->set_value( nValue );
616 else
618 if( !m_xNumVertical->get_text().isEmpty() )
620 m_xNumVertical->set_text("");
621 bUpdate = true;
626 // Depth
627 if( m_xMtrDepth->get_sensitive() )
629 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_DEPTH);
630 if( eState != SfxItemState::DONTCARE )
632 sal_uInt32 nValue = rAttrs.Get(SDRATTR_3DOBJ_DEPTH).GetValue();
633 sal_uInt32 nValue2 = GetCoreValue(*m_xMtrDepth, ePoolUnit);
634 if( nValue != nValue2 )
636 if( eFUnit != m_xMtrDepth->get_unit() )
637 SetFieldUnit(*m_xMtrDepth, eFUnit);
639 SetMetricValue(*m_xMtrDepth, nValue, ePoolUnit);
640 bUpdate = true;
642 else if( m_xMtrDepth->get_text().isEmpty() )
643 m_xMtrDepth->set_value(m_xMtrDepth->get_value(FieldUnit::NONE), FieldUnit::NONE);
645 else
647 if( !m_xMtrDepth->get_text().isEmpty() )
649 m_xMtrDepth->set_text("");
650 bUpdate = true;
655 // Double walled / Double sided
656 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_DOUBLE_SIDED);
657 if( eState != SfxItemState::DONTCARE )
659 bool bValue = rAttrs.Get(SDRATTR_3DOBJ_DOUBLE_SIDED).GetValue();
660 if( bValue != m_xBtnDoubleSided->get_active() )
662 m_xBtnDoubleSided->set_active( bValue );
663 bUpdate = true;
665 else if( m_xBtnDoubleSided->get_state() == TRISTATE_INDET )
666 m_xBtnDoubleSided->set_active( bValue );
668 else
670 if( m_xBtnDoubleSided->get_state() != TRISTATE_INDET )
672 m_xBtnDoubleSided->set_state( TRISTATE_INDET );
673 bUpdate = true;
677 // Edge rounding
678 if( m_xMtrPercentDiagonal->get_sensitive() )
680 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_PERCENT_DIAGONAL);
681 if( eState != SfxItemState::DONTCARE )
683 sal_uInt16 nValue = rAttrs.Get(SDRATTR_3DOBJ_PERCENT_DIAGONAL).GetValue();
684 if( nValue != m_xMtrPercentDiagonal->get_value(FieldUnit::PERCENT) )
686 m_xMtrPercentDiagonal->set_value(nValue, FieldUnit::PERCENT);
687 bUpdate = true;
689 else if( m_xMtrPercentDiagonal->get_text().isEmpty() )
690 m_xMtrPercentDiagonal->set_value(nValue, FieldUnit::PERCENT);
692 else
694 if( !m_xMtrPercentDiagonal->get_text().isEmpty() )
696 m_xMtrPercentDiagonal->set_text("");
697 bUpdate = true;
702 // Depth scaling
703 if( m_xMtrBackscale->get_sensitive() )
705 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_BACKSCALE);
706 if( eState != SfxItemState::DONTCARE )
708 sal_uInt16 nValue = rAttrs.Get(SDRATTR_3DOBJ_BACKSCALE).GetValue();
709 if( nValue != m_xMtrBackscale->get_value(FieldUnit::PERCENT) )
711 m_xMtrBackscale->set_value(nValue, FieldUnit::PERCENT);
712 bUpdate = true;
714 else if( m_xMtrBackscale->get_text().isEmpty() )
715 m_xMtrBackscale->set_value(nValue, FieldUnit::PERCENT);
717 else
719 if( !m_xMtrBackscale->get_text().isEmpty() )
721 m_xMtrBackscale->set_text("");
722 bUpdate = true;
727 // End angle
728 if( m_xMtrEndAngle->get_sensitive() )
730 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_END_ANGLE);
731 if( eState != SfxItemState::DONTCARE )
733 sal_Int32 nValue = rAttrs.Get(SDRATTR_3DOBJ_END_ANGLE).GetValue();
734 if( nValue != m_xMtrEndAngle->get_value(FieldUnit::DEGREE) )
736 m_xMtrEndAngle->set_value(nValue, FieldUnit::DEGREE);
737 bUpdate = true;
740 else
742 if( !m_xMtrEndAngle->get_text().isEmpty() )
744 m_xMtrEndAngle->set_text("");
745 bUpdate = true;
750 // Normal type
751 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_NORMALS_KIND);
752 if( eState != SfxItemState::DONTCARE )
754 sal_uInt16 nValue = rAttrs.Get(SDRATTR_3DOBJ_NORMALS_KIND).GetValue();
756 if( ( !m_xBtnNormalsObj->get_active() && nValue == 0 ) ||
757 ( !m_xBtnNormalsFlat->get_active() && nValue == 1 ) ||
758 ( !m_xBtnNormalsSphere->get_active() && nValue == 2 ) )
760 m_xBtnNormalsObj->set_active( nValue == 0 );
761 m_xBtnNormalsFlat->set_active( nValue == 1 );
762 m_xBtnNormalsSphere->set_active( nValue == 2 );
763 bUpdate = true;
766 else
768 if( m_xBtnNormalsObj->get_active() ||
769 m_xBtnNormalsFlat->get_active() ||
770 m_xBtnNormalsSphere->get_active() )
772 m_xBtnNormalsObj->set_active( false );
773 m_xBtnNormalsFlat->set_active( false );
774 m_xBtnNormalsSphere->set_active( false );
775 bUpdate = true;
779 // Normal inverted
780 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_NORMALS_INVERT);
781 if( eState != SfxItemState::DONTCARE )
783 bool bValue = rAttrs.Get(SDRATTR_3DOBJ_NORMALS_INVERT).GetValue();
784 if( bValue != m_xBtnNormalsInvert->get_active() )
786 m_xBtnNormalsInvert->set_active( bValue );
787 bUpdate = true;
789 else if( m_xBtnNormalsInvert->get_state() == TRISTATE_INDET )
790 m_xBtnNormalsInvert->set_active( bValue );
792 else
794 if( m_xBtnNormalsInvert->get_state() != TRISTATE_INDET )
796 m_xBtnNormalsInvert->set_state( TRISTATE_INDET );
797 bUpdate = true;
801 // 2-sided lighting
802 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_TWO_SIDED_LIGHTING);
803 if( eState != SfxItemState::DONTCARE )
805 bool bValue = rAttrs.Get(SDRATTR_3DSCENE_TWO_SIDED_LIGHTING).GetValue();
806 if( bValue != m_xBtnTwoSidedLighting->get_active() )
808 m_xBtnTwoSidedLighting->set_active( bValue );
809 bUpdate = true;
811 else if( m_xBtnTwoSidedLighting->get_state() == TRISTATE_INDET )
812 m_xBtnTwoSidedLighting->set_active( bValue );
814 else
816 if( m_xBtnTwoSidedLighting->get_state() != TRISTATE_INDET )
818 m_xBtnTwoSidedLighting->set_state( TRISTATE_INDET );
819 bUpdate = true;
823 // Representation
824 // Shademode
825 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_SHADE_MODE);
826 if( eState != SfxItemState::DONTCARE )
828 sal_uInt16 nValue = rAttrs.Get(SDRATTR_3DSCENE_SHADE_MODE).GetValue();
829 if( nValue != m_xLbShademode->get_active() )
831 m_xLbShademode->set_active( nValue );
832 bUpdate = true;
835 else
837 if( m_xLbShademode->get_active() != 0 )
839 m_xLbShademode->set_active(-1);
840 bUpdate = true;
844 // 3D-Shadow
845 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_SHADOW_3D);
846 if( eState != SfxItemState::DONTCARE )
848 bool bValue = rAttrs.Get(SDRATTR_3DOBJ_SHADOW_3D).GetValue();
849 if( bValue != m_xBtnShadow3d->get_active() )
851 m_xBtnShadow3d->set_active( bValue );
852 m_xFtSlant->set_sensitive( bValue );
853 m_xMtrSlant->set_sensitive( bValue );
854 bUpdate = true;
856 else if( m_xBtnShadow3d->get_state() == TRISTATE_INDET )
857 m_xBtnShadow3d->set_active( bValue );
859 else
861 if( m_xBtnShadow3d->get_state() != TRISTATE_INDET )
863 m_xBtnShadow3d->set_state( TRISTATE_INDET );
864 bUpdate = true;
868 // Inclination (Shadow)
869 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_SHADOW_SLANT);
870 if( eState != SfxItemState::DONTCARE )
872 sal_uInt16 nValue = rAttrs.Get(SDRATTR_3DSCENE_SHADOW_SLANT).GetValue();
873 if( nValue != m_xMtrSlant->get_value(FieldUnit::DEGREE) )
875 m_xMtrSlant->set_value(nValue, FieldUnit::DEGREE);
876 bUpdate = true;
879 else
881 if( !m_xMtrSlant->get_text().isEmpty() )
883 m_xMtrSlant->set_text("");
884 bUpdate = true;
888 // Distance
889 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_DISTANCE);
890 if( eState != SfxItemState::DONTCARE )
892 sal_uInt32 nValue = rAttrs.Get(SDRATTR_3DSCENE_DISTANCE).GetValue();
893 sal_uInt32 nValue2 = GetCoreValue(*m_xMtrDistance, ePoolUnit);
894 if( nValue != nValue2 )
896 if( eFUnit != m_xMtrDistance->get_unit() )
897 SetFieldUnit(*m_xMtrDistance, eFUnit);
899 SetMetricValue(*m_xMtrDistance, nValue, ePoolUnit);
900 bUpdate = true;
903 else
905 if( !m_xMtrDepth->get_text().isEmpty() )
907 m_xMtrDepth->set_text("");
908 bUpdate = true;
912 // Focal length
913 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_FOCAL_LENGTH);
914 if( eState != SfxItemState::DONTCARE )
916 sal_uInt32 nValue = rAttrs.Get(SDRATTR_3DSCENE_FOCAL_LENGTH).GetValue();
917 sal_uInt32 nValue2 = GetCoreValue(*m_xMtrFocalLength, ePoolUnit);
918 if( nValue != nValue2 )
920 if( eFUnit != m_xMtrFocalLength->get_unit() )
921 SetFieldUnit(*m_xMtrFocalLength, eFUnit);
923 SetMetricValue(*m_xMtrFocalLength, nValue, ePoolUnit);
924 bUpdate = true;
927 else
929 if( !m_xMtrFocalLength->get_text().isEmpty() )
931 m_xMtrFocalLength->set_text("");
932 bUpdate = true;
936 // Lighting
937 Color aColor;
938 // Light 1 (Color)
939 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_1);
940 if( eState != SfxItemState::DONTCARE )
942 aColor = rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_1).GetValue();
943 ColorListBox* pLb = m_xLbLight1.get();
944 if( aColor != pLb->GetSelectEntryColor() )
946 LBSelectColor( pLb, aColor );
947 bUpdate = true;
950 else
952 if (!m_xLbLight1->IsNoSelection())
954 m_xLbLight1->SetNoSelection();
955 bUpdate = true;
958 // Light 1 (on/off)
959 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_1);
960 if( eState != SfxItemState::DONTCARE )
962 bool bOn = rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_1).GetValue();
963 if (bOn != m_xBtnLight1->isLightOn())
965 m_xBtnLight1->switchLightOn(bOn);
966 bUpdate = true;
968 if( m_xBtnLight1->get_state() == TRISTATE_INDET )
969 m_xBtnLight1->set_active( m_xBtnLight1->get_active() );
971 else
973 if( m_xBtnLight1->get_state() != TRISTATE_INDET )
975 m_xBtnLight1->set_state( TRISTATE_INDET );
976 bUpdate = true;
979 // Light 1 (direction)
980 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_1);
981 if( eState != SfxItemState::DONTCARE )
983 bUpdate = true;
986 //Light 2 (color)
987 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_2);
988 if( eState != SfxItemState::DONTCARE )
990 aColor = rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_2).GetValue();
991 ColorListBox* pLb = m_xLbLight2.get();
992 if( aColor != pLb->GetSelectEntryColor() )
994 LBSelectColor( pLb, aColor );
995 bUpdate = true;
998 else
1000 if (!m_xLbLight2->IsNoSelection())
1002 m_xLbLight2->SetNoSelection();
1003 bUpdate = true;
1006 // Light 2 (on/off)
1007 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_2);
1008 if( eState != SfxItemState::DONTCARE )
1010 bool bOn = rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_2).GetValue();
1011 if (bOn != m_xBtnLight2->isLightOn())
1013 m_xBtnLight2->switchLightOn(bOn);
1014 bUpdate = true;
1016 if( m_xBtnLight2->get_state() == TRISTATE_INDET )
1017 m_xBtnLight2->set_active( m_xBtnLight2->get_active() );
1019 else
1021 if( m_xBtnLight2->get_state() != TRISTATE_INDET )
1023 m_xBtnLight2->set_state( TRISTATE_INDET );
1024 bUpdate = true;
1027 //Light 2 (Direction)
1028 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_2);
1029 if( eState != SfxItemState::DONTCARE )
1031 bUpdate = true;
1034 //Light 3 (color)
1035 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_3);
1036 if( eState != SfxItemState::DONTCARE )
1038 aColor = rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_3).GetValue();
1039 ColorListBox* pLb = m_xLbLight3.get();
1040 if( aColor != pLb->GetSelectEntryColor() )
1042 LBSelectColor( pLb, aColor );
1043 bUpdate = true;
1046 else
1048 if (!m_xLbLight3->IsNoSelection())
1050 m_xLbLight3->SetNoSelection();
1051 bUpdate = true;
1054 // Light 3 (on/off)
1055 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_3);
1056 if( eState != SfxItemState::DONTCARE )
1058 bool bOn = rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_3).GetValue();
1059 if (bOn != m_xBtnLight3->isLightOn())
1061 m_xBtnLight3->switchLightOn(bOn);
1062 bUpdate = true;
1064 if( m_xBtnLight3->get_state() == TRISTATE_INDET )
1065 m_xBtnLight3->set_active( m_xBtnLight3->get_active() );
1067 else
1069 if( m_xBtnLight3->get_state() != TRISTATE_INDET )
1071 m_xBtnLight3->set_state( TRISTATE_INDET );
1072 bUpdate = true;
1075 // Light 3 (Direction)
1076 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_3);
1077 if( eState != SfxItemState::DONTCARE )
1079 bUpdate = true;
1082 // Light 4 (Color)
1083 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_4);
1084 if( eState != SfxItemState::DONTCARE )
1086 aColor = rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_4).GetValue();
1087 ColorListBox* pLb = m_xLbLight4.get();
1088 if( aColor != pLb->GetSelectEntryColor() )
1090 LBSelectColor( pLb, aColor );
1091 bUpdate = true;
1094 else
1096 if (!m_xLbLight4->IsNoSelection())
1098 m_xLbLight4->SetNoSelection();
1099 bUpdate = true;
1102 // Light 4 (on/off)
1103 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_4);
1104 if( eState != SfxItemState::DONTCARE )
1106 bool bOn = rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_4).GetValue();
1107 if (bOn != m_xBtnLight4->isLightOn())
1109 m_xBtnLight4->switchLightOn(bOn);
1110 bUpdate = true;
1112 if( m_xBtnLight4->get_state() == TRISTATE_INDET )
1113 m_xBtnLight4->set_active( m_xBtnLight4->get_active() );
1115 else
1117 if( m_xBtnLight4->get_state() != TRISTATE_INDET )
1119 m_xBtnLight4->set_state( TRISTATE_INDET );
1120 bUpdate = true;
1123 // Light 4 (direction)
1124 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_4);
1125 if( eState != SfxItemState::DONTCARE )
1127 bUpdate = true;
1130 // Light 5 (color)
1131 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_5);
1132 if( eState != SfxItemState::DONTCARE )
1134 aColor = rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_5).GetValue();
1135 ColorListBox* pLb = m_xLbLight5.get();
1136 if( aColor != pLb->GetSelectEntryColor() )
1138 LBSelectColor( pLb, aColor );
1139 bUpdate = true;
1142 else
1144 if (!m_xLbLight5->IsNoSelection())
1146 m_xLbLight5->SetNoSelection();
1147 bUpdate = true;
1150 // Light 5 (on/off)
1151 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_5);
1152 if( eState != SfxItemState::DONTCARE )
1154 bool bOn = rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_5).GetValue();
1155 if (bOn != m_xBtnLight5->isLightOn())
1157 m_xBtnLight5->switchLightOn(bOn);
1158 bUpdate = true;
1160 if( m_xBtnLight5->get_state() == TRISTATE_INDET )
1161 m_xBtnLight5->set_active( m_xBtnLight5->get_active() );
1163 else
1165 if( m_xBtnLight5->get_state() != TRISTATE_INDET )
1167 m_xBtnLight5->set_state( TRISTATE_INDET );
1168 bUpdate = true;
1171 // Light 5 (direction)
1172 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_5);
1173 if( eState != SfxItemState::DONTCARE )
1175 bUpdate = true;
1178 // Light 6 (color)
1179 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_6);
1180 if( eState != SfxItemState::DONTCARE )
1182 aColor = rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_6).GetValue();
1183 ColorListBox* pLb = m_xLbLight6.get();
1184 if( aColor != pLb->GetSelectEntryColor() )
1186 LBSelectColor( pLb, aColor );
1187 bUpdate = true;
1190 else
1192 if (!m_xLbLight6->IsNoSelection())
1194 m_xLbLight6->SetNoSelection();
1195 bUpdate = true;
1198 // Light 6 (on/off)
1199 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_6);
1200 if( eState != SfxItemState::DONTCARE )
1202 bool bOn = rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_6).GetValue();
1203 if (bOn != m_xBtnLight6->isLightOn())
1205 m_xBtnLight6->switchLightOn(bOn);
1206 bUpdate = true;
1208 if( m_xBtnLight6->get_state() == TRISTATE_INDET )
1209 m_xBtnLight6->set_active( m_xBtnLight6->get_active() );
1211 else
1213 if( m_xBtnLight6->get_state() != TRISTATE_INDET )
1215 m_xBtnLight6->set_state( TRISTATE_INDET );
1216 bUpdate = true;
1219 // Light 6 (direction)
1220 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_6);
1221 if( eState != SfxItemState::DONTCARE )
1223 bUpdate = true;
1226 // Light 7 (color)
1227 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_7);
1228 if( eState != SfxItemState::DONTCARE )
1230 aColor = rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_7).GetValue();
1231 ColorListBox* pLb = m_xLbLight7.get();
1232 if( aColor != pLb->GetSelectEntryColor() )
1234 LBSelectColor( pLb, aColor );
1235 bUpdate = true;
1238 else
1240 if (!m_xLbLight7->IsNoSelection())
1242 m_xLbLight7->SetNoSelection();
1243 bUpdate = true;
1246 // Light 7 (on/off)
1247 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_7);
1248 if( eState != SfxItemState::DONTCARE )
1250 bool bOn = rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_7).GetValue();
1251 if (bOn != m_xBtnLight7->isLightOn())
1253 m_xBtnLight7->switchLightOn(bOn);
1254 bUpdate = true;
1256 if( m_xBtnLight7->get_state() == TRISTATE_INDET )
1257 m_xBtnLight7->set_active( m_xBtnLight7->get_active() );
1259 else
1261 if( m_xBtnLight7->get_state() != TRISTATE_INDET )
1263 m_xBtnLight7->set_state( TRISTATE_INDET );
1264 bUpdate = true;
1267 // Light 7 (direction)
1268 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_7);
1269 if( eState != SfxItemState::DONTCARE )
1271 bUpdate = true;
1274 // Light 8 (color)
1275 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_8);
1276 if( eState != SfxItemState::DONTCARE )
1278 aColor = rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_8).GetValue();
1279 ColorListBox* pLb = m_xLbLight8.get();
1280 if( aColor != pLb->GetSelectEntryColor() )
1282 LBSelectColor( pLb, aColor );
1283 bUpdate = true;
1286 else
1288 if (!m_xLbLight8->IsNoSelection())
1290 m_xLbLight8->SetNoSelection();
1291 bUpdate = true;
1294 // Light 8 (on/off)
1295 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_8);
1296 if( eState != SfxItemState::DONTCARE )
1298 bool bOn = rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_8).GetValue();
1299 if (bOn != m_xBtnLight8->isLightOn())
1301 m_xBtnLight8->switchLightOn(bOn);
1302 bUpdate = true;
1304 if( m_xBtnLight8->get_state() == TRISTATE_INDET )
1305 m_xBtnLight8->set_active( m_xBtnLight8->get_active() );
1307 else
1309 if( m_xBtnLight8->get_state() != TRISTATE_INDET )
1311 m_xBtnLight8->set_state( TRISTATE_INDET );
1312 bUpdate = true;
1315 // Light 8 (direction)
1316 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_8);
1317 if( eState != SfxItemState::DONTCARE )
1319 bUpdate = true;
1322 // Ambient light
1323 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_AMBIENTCOLOR);
1324 if( eState != SfxItemState::DONTCARE )
1326 aColor = rAttrs.Get(SDRATTR_3DSCENE_AMBIENTCOLOR).GetValue();
1327 ColorListBox* pLb = m_xLbAmbientlight.get();
1328 if( aColor != pLb->GetSelectEntryColor() )
1330 LBSelectColor( pLb, aColor );
1331 bUpdate = true;
1334 else
1336 if (!m_xLbAmbientlight->IsNoSelection())
1338 m_xLbAmbientlight->SetNoSelection();
1339 bUpdate = true;
1344 // Textures
1345 // Art
1346 if( bBitmap )
1348 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_TEXTURE_KIND);
1349 if( eState != SfxItemState::DONTCARE )
1351 sal_uInt16 nValue = rAttrs.Get(SDRATTR_3DOBJ_TEXTURE_KIND).GetValue();
1353 if( ( !m_xBtnTexLuminance->get_active() && nValue == 1 ) ||
1354 ( !m_xBtnTexColor->get_active() && nValue == 3 ) )
1356 m_xBtnTexLuminance->set_active( nValue == 1 );
1357 m_xBtnTexColor->set_active( nValue == 3 );
1358 bUpdate = true;
1361 else
1363 if( m_xBtnTexLuminance->get_active() ||
1364 m_xBtnTexColor->get_active() )
1366 m_xBtnTexLuminance->set_active( false );
1367 m_xBtnTexColor->set_active( false );
1368 bUpdate = true;
1372 // Mode
1373 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_TEXTURE_MODE);
1374 if( eState != SfxItemState::DONTCARE )
1376 sal_uInt16 nValue = rAttrs.Get(SDRATTR_3DOBJ_TEXTURE_MODE).GetValue();
1378 if( ( !m_xBtnTexReplace->get_active() && nValue == 1 ) ||
1379 ( !m_xBtnTexModulate->get_active() && nValue == 2 ) )
1381 m_xBtnTexReplace->set_active( nValue == 1 );
1382 m_xBtnTexModulate->set_active( nValue == 2 );
1383 bUpdate = true;
1386 else
1388 if( m_xBtnTexReplace->get_active() ||
1389 m_xBtnTexModulate->get_active() )
1391 m_xBtnTexReplace->set_active( false );
1392 m_xBtnTexModulate->set_active( false );
1393 bUpdate = true;
1397 // Projection X
1398 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_TEXTURE_PROJ_X);
1399 if( eState != SfxItemState::DONTCARE )
1401 sal_uInt16 nValue = rAttrs.Get(SDRATTR_3DOBJ_TEXTURE_PROJ_X).GetValue();
1403 if( ( !m_xBtnTexObjectX->get_active() && nValue == 0 ) ||
1404 ( !m_xBtnTexParallelX->get_active() && nValue == 1 ) ||
1405 ( !m_xBtnTexCircleX->get_active() && nValue == 2 ) )
1407 m_xBtnTexObjectX->set_active( nValue == 0 );
1408 m_xBtnTexParallelX->set_active( nValue == 1 );
1409 m_xBtnTexCircleX->set_active( nValue == 2 );
1410 bUpdate = true;
1413 else
1415 if( m_xBtnTexObjectX->get_active() ||
1416 m_xBtnTexParallelX->get_active() ||
1417 m_xBtnTexCircleX->get_active() )
1419 m_xBtnTexObjectX->set_active( false );
1420 m_xBtnTexParallelX->set_active( false );
1421 m_xBtnTexCircleX->set_active( false );
1422 bUpdate = true;
1426 // Projection Y
1427 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_TEXTURE_PROJ_Y);
1428 if( eState != SfxItemState::DONTCARE )
1430 sal_uInt16 nValue = rAttrs.Get(SDRATTR_3DOBJ_TEXTURE_PROJ_Y).GetValue();
1432 if( ( !m_xBtnTexObjectY->get_active() && nValue == 0 ) ||
1433 ( !m_xBtnTexParallelY->get_active() && nValue == 1 ) ||
1434 ( !m_xBtnTexCircleY->get_active() && nValue == 2 ) )
1436 m_xBtnTexObjectY->set_active( nValue == 0 );
1437 m_xBtnTexParallelY->set_active( nValue == 1 );
1438 m_xBtnTexCircleY->set_active( nValue == 2 );
1439 bUpdate = true;
1442 else
1444 if( m_xBtnTexObjectY->get_active() ||
1445 m_xBtnTexParallelY->get_active() ||
1446 m_xBtnTexCircleY->get_active() )
1448 m_xBtnTexObjectY->set_active( false );
1449 m_xBtnTexParallelY->set_active( false );
1450 m_xBtnTexCircleY->set_active( false );
1451 bUpdate = true;
1455 // Filter
1456 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_TEXTURE_FILTER);
1457 if( eState != SfxItemState::DONTCARE )
1459 bool bValue = rAttrs.Get(SDRATTR_3DOBJ_TEXTURE_FILTER).GetValue();
1460 if( bValue != m_xBtnTexFilter->get_active() )
1462 m_xBtnTexFilter->set_active( bValue );
1463 bUpdate = true;
1465 if( m_xBtnTexFilter->get_state() == TRISTATE_INDET )
1466 m_xBtnTexFilter->set_active( bValue );
1468 else
1470 if( m_xBtnTexFilter->get_state() != TRISTATE_INDET )
1472 m_xBtnTexFilter->set_state( TRISTATE_INDET );
1473 bUpdate = true;
1479 // Material Favorites
1480 m_xLbMatFavorites->set_active( 0 );
1482 // Object color
1483 eState = rAttrs.GetItemState(XATTR_FILLCOLOR);
1484 if( eState != SfxItemState::DONTCARE )
1486 aColor = rAttrs.Get(XATTR_FILLCOLOR).GetColorValue();
1487 ColorListBox* pLb = m_xLbMatColor.get();
1488 if( aColor != pLb->GetSelectEntryColor() )
1490 LBSelectColor( pLb, aColor );
1491 bUpdate = true;
1494 else
1496 if (!m_xLbMatColor->IsNoSelection())
1498 m_xLbMatColor->SetNoSelection();
1499 bUpdate = true;
1503 // Self-luminous color
1504 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_MAT_EMISSION);
1505 if( eState != SfxItemState::DONTCARE )
1507 aColor = rAttrs.Get(SDRATTR_3DOBJ_MAT_EMISSION).GetValue();
1508 ColorListBox* pLb = m_xLbMatEmission.get();
1509 if( aColor != pLb->GetSelectEntryColor() )
1511 LBSelectColor( pLb, aColor );
1512 bUpdate = true;
1515 else
1517 if (!m_xLbMatEmission->IsNoSelection())
1519 m_xLbMatEmission->SetNoSelection();
1520 bUpdate = true;
1524 // Specular
1525 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_MAT_SPECULAR);
1526 if( eState != SfxItemState::DONTCARE )
1528 aColor = rAttrs.Get(SDRATTR_3DOBJ_MAT_SPECULAR).GetValue();
1529 ColorListBox* pLb = m_xLbMatSpecular.get();
1530 if( aColor != pLb->GetSelectEntryColor() )
1532 LBSelectColor( pLb, aColor );
1533 bUpdate = true;
1536 else
1538 if (!m_xLbMatSpecular->IsNoSelection())
1540 m_xLbMatSpecular->SetNoSelection();
1541 bUpdate = true;
1545 // Specular Intensity
1546 eState = rAttrs.GetItemState(SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY);
1547 if( eState != SfxItemState::DONTCARE )
1549 sal_uInt16 nValue = rAttrs.Get(SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY).GetValue();
1550 if( nValue != m_xMtrMatSpecularIntensity->get_value(FieldUnit::PERCENT) )
1552 m_xMtrMatSpecularIntensity->set_value(nValue, FieldUnit::PERCENT);
1553 bUpdate = true;
1556 else
1558 if( !m_xMtrMatSpecularIntensity->get_text().isEmpty() )
1560 m_xMtrMatSpecularIntensity->set_text("");
1561 bUpdate = true;
1566 // Other
1567 // Perspective
1568 eState = rAttrs.GetItemState(SDRATTR_3DSCENE_PERSPECTIVE);
1569 if( eState != SfxItemState::DONTCARE )
1571 ProjectionType ePT = static_cast<ProjectionType>(rAttrs.Get(SDRATTR_3DSCENE_PERSPECTIVE).GetValue());
1572 if( ( !m_xBtnPerspective->get_active() && ePT == ProjectionType::Perspective ) ||
1573 ( m_xBtnPerspective->get_active() && ePT == ProjectionType::Parallel ) )
1575 m_xBtnPerspective->set_active( ePT == ProjectionType::Perspective );
1576 bUpdate = true;
1578 if( m_xBtnPerspective->get_state() == TRISTATE_INDET )
1579 m_xBtnPerspective->set_active( ePT == ProjectionType::Perspective );
1581 else
1583 if( m_xBtnPerspective->get_state() != TRISTATE_INDET )
1585 m_xBtnPerspective->set_state( TRISTATE_INDET );
1586 bUpdate = true;
1590 if( !bUpdate )
1592 // however the 2D attributes may be different. Compare these and decide
1594 bUpdate = true;
1597 // Update preview
1598 SfxItemSet aSet(rAttrs);
1600 // set LineStyle hard to drawing::LineStyle_NONE when it's not set so that
1601 // the default (drawing::LineStyle_SOLID) is not used for 3d preview
1602 if(SfxItemState::SET != aSet.GetItemState(XATTR_LINESTYLE, false))
1603 aSet.Put(XLineStyleItem(drawing::LineStyle_NONE));
1605 // set FillColor hard to WHITE when it's SfxItemState::DONTCARE so that
1606 // the default (Blue7) is not used for 3d preview
1607 if(SfxItemState::DONTCARE == aSet.GetItemState(XATTR_FILLCOLOR, false))
1608 aSet.Put(XFillColorItem(OUString(), COL_WHITE));
1610 m_xCtlPreview->Set3DAttributes(aSet);
1611 m_xCtlLightPreview->GetSvx3DLightControl().Set3DAttributes(aSet);
1613 // try to select light corresponding to active button
1614 sal_uInt32 nNumber(0xffffffff);
1616 if(m_xBtnLight1->get_active())
1617 nNumber = 0;
1618 else if(m_xBtnLight2->get_active())
1619 nNumber = 1;
1620 else if(m_xBtnLight3->get_active())
1621 nNumber = 2;
1622 else if(m_xBtnLight4->get_active())
1623 nNumber = 3;
1624 else if(m_xBtnLight5->get_active())
1625 nNumber = 4;
1626 else if(m_xBtnLight6->get_active())
1627 nNumber = 5;
1628 else if(m_xBtnLight7->get_active())
1629 nNumber = 6;
1630 else if(m_xBtnLight8->get_active())
1631 nNumber = 7;
1633 if(nNumber != 0xffffffff)
1635 m_xCtlLightPreview->GetSvx3DLightControl().SelectLight(nNumber);
1638 // handle state of converts possible
1639 m_xBtnConvertTo3D->set_sensitive(pConvertTo3DItem->GetState());
1640 m_xBtnLatheObject->set_sensitive(pConvertTo3DLatheItem->GetState());
1644 void Svx3DWin::GetAttr( SfxItemSet& rAttrs )
1646 // get remembered 2d attributes from the dialog
1647 if(mpRemember2DAttributes)
1649 SfxWhichIter aIter(*mpRemember2DAttributes);
1650 sal_uInt16 nWhich(aIter.FirstWhich());
1652 while(nWhich)
1654 SfxItemState eState = aIter.GetItemState(false);
1655 if(SfxItemState::DONTCARE == eState)
1656 rAttrs.InvalidateItem(nWhich);
1657 else if(SfxItemState::SET == eState)
1658 rAttrs.Put(mpRemember2DAttributes->Get(nWhich, false));
1660 nWhich = aIter.NextWhich();
1664 //Others must stand as the front on all sides
1665 // Perspective
1666 if( m_xBtnPerspective->get_state() != TRISTATE_INDET )
1668 ProjectionType nValue;
1669 if( m_xBtnPerspective->get_active() )
1670 nValue = ProjectionType::Perspective;
1671 else
1672 nValue = ProjectionType::Parallel;
1673 rAttrs.Put(Svx3DPerspectiveItem(nValue));
1675 else
1676 rAttrs.InvalidateItem(SDRATTR_3DSCENE_PERSPECTIVE);
1678 // Geometry
1679 // Possible determine PoolUnit (in this case this has not happened in Update() )
1680 if( !mpImpl->pPool )
1682 OSL_FAIL( "No Pool in GetAttr()! May be incompatible to drviewsi.cxx ?" );
1683 mpImpl->pPool = rAttrs.GetPool();
1684 DBG_ASSERT( mpImpl->pPool, "Where is the Pool?" );
1685 ePoolUnit = mpImpl->pPool->GetMetric( SID_ATTR_LINE_WIDTH );
1687 eFUnit = GetModuleFieldUnit( rAttrs );
1690 // Number of segments (horizontal)
1691 if( !m_xNumHorizontal->get_text().isEmpty() )
1693 sal_uInt32 nValue = static_cast<sal_uInt32>(m_xNumHorizontal->get_value());
1694 rAttrs.Put(makeSvx3DHorizontalSegmentsItem(nValue));
1696 else
1697 rAttrs.InvalidateItem(SDRATTR_3DOBJ_HORZ_SEGS);
1699 // Number of segments (vertical)
1700 if( !m_xNumVertical->get_text().isEmpty() )
1702 sal_uInt32 nValue = static_cast<sal_uInt32>(m_xNumVertical->get_value());
1703 rAttrs.Put(makeSvx3DVerticalSegmentsItem(nValue));
1705 else
1706 rAttrs.InvalidateItem(SDRATTR_3DOBJ_VERT_SEGS);
1708 // Depth
1709 if( !m_xMtrDepth->get_text().isEmpty() )
1711 sal_uInt32 nValue = GetCoreValue(*m_xMtrDepth, ePoolUnit);
1712 rAttrs.Put(makeSvx3DDepthItem(nValue));
1714 else
1715 rAttrs.InvalidateItem(SDRATTR_3DOBJ_DEPTH);
1717 // Double-sided
1718 TriState eState = m_xBtnDoubleSided->get_state();
1719 if( eState != TRISTATE_INDET )
1721 bool bValue = TRISTATE_TRUE == eState;
1722 rAttrs.Put(makeSvx3DDoubleSidedItem(bValue));
1724 else
1725 rAttrs.InvalidateItem(SDRATTR_3DOBJ_DOUBLE_SIDED);
1727 // Edge rounding
1728 if( !m_xMtrPercentDiagonal->get_text().isEmpty() )
1730 sal_uInt16 nValue = static_cast<sal_uInt16>(m_xMtrPercentDiagonal->get_value(FieldUnit::PERCENT));
1731 rAttrs.Put(makeSvx3DPercentDiagonalItem(nValue));
1733 else
1734 rAttrs.InvalidateItem(SDRATTR_3DOBJ_PERCENT_DIAGONAL);
1736 // Depth scale
1737 if( !m_xMtrBackscale->get_text().isEmpty() )
1739 sal_uInt16 nValue = static_cast<sal_uInt16>(m_xMtrBackscale->get_value(FieldUnit::PERCENT));
1740 rAttrs.Put(makeSvx3DBackscaleItem(nValue));
1742 else
1743 rAttrs.InvalidateItem(SDRATTR_3DOBJ_BACKSCALE);
1745 // End angle
1746 if( !m_xMtrEndAngle->get_text().isEmpty() )
1748 sal_uInt16 nValue = static_cast<sal_uInt16>(m_xMtrEndAngle->get_value(FieldUnit::DEGREE));
1749 rAttrs.Put(makeSvx3DEndAngleItem(nValue));
1751 else
1752 rAttrs.InvalidateItem(SDRATTR_3DOBJ_END_ANGLE);
1754 // Normal type
1755 sal_uInt16 nValue = 99;
1756 if( m_xBtnNormalsObj->get_active() )
1757 nValue = 0;
1758 else if( m_xBtnNormalsFlat->get_active() )
1759 nValue = 1;
1760 else if( m_xBtnNormalsSphere->get_active() )
1761 nValue = 2;
1763 if( nValue <= 2 )
1764 rAttrs.Put(Svx3DNormalsKindItem(nValue));
1765 else
1766 rAttrs.InvalidateItem(SDRATTR_3DOBJ_NORMALS_KIND);
1768 // Normal inverted
1769 eState = m_xBtnNormalsInvert->get_state();
1770 if( eState != TRISTATE_INDET )
1772 bool bValue = TRISTATE_TRUE == eState;
1773 rAttrs.Put(makeSvx3DNormalsInvertItem(bValue));
1775 else
1776 rAttrs.InvalidateItem(SDRATTR_3DOBJ_NORMALS_INVERT);
1778 // 2-sided lighting
1779 eState = m_xBtnTwoSidedLighting->get_state();
1780 if( eState != TRISTATE_INDET )
1782 bool bValue = TRISTATE_TRUE == eState;
1783 rAttrs.Put(makeSvx3DTwoSidedLightingItem(bValue));
1785 else
1786 rAttrs.InvalidateItem(SDRATTR_3DSCENE_TWO_SIDED_LIGHTING);
1788 // Representation
1789 // Shade mode
1790 if( m_xLbShademode->get_active() != -1 )
1792 nValue = m_xLbShademode->get_active();
1793 rAttrs.Put(Svx3DShadeModeItem(nValue));
1795 else
1796 rAttrs.InvalidateItem(SDRATTR_3DSCENE_SHADE_MODE);
1798 // 3D-Shadow
1799 eState = m_xBtnShadow3d->get_state();
1800 if( eState != TRISTATE_INDET )
1802 bool bValue = TRISTATE_TRUE == eState;
1803 rAttrs.Put(makeSvx3DShadow3DItem(bValue));
1804 rAttrs.Put(makeSdrShadowItem(bValue));
1806 else
1808 rAttrs.InvalidateItem(SDRATTR_3DOBJ_SHADOW_3D);
1809 rAttrs.InvalidateItem(SDRATTR_SHADOW);
1812 // Slant (Shadow)
1813 if( !m_xMtrSlant->get_text().isEmpty() )
1815 sal_uInt16 nValue2 = static_cast<sal_uInt16>(m_xMtrSlant->get_value(FieldUnit::DEGREE));
1816 rAttrs.Put(makeSvx3DShadowSlantItem(nValue2));
1818 else
1819 rAttrs.InvalidateItem(SDRATTR_3DSCENE_SHADOW_SLANT);
1821 // Distance
1822 if( !m_xMtrDistance->get_text().isEmpty() )
1824 sal_uInt32 nValue2 = GetCoreValue(*m_xMtrDistance, ePoolUnit);
1825 rAttrs.Put(makeSvx3DDistanceItem(nValue2));
1827 else
1828 rAttrs.InvalidateItem(SDRATTR_3DSCENE_DISTANCE);
1830 // Focal length
1831 if( !m_xMtrFocalLength->get_text().isEmpty() )
1833 sal_uInt32 nValue2 = GetCoreValue(*m_xMtrFocalLength, ePoolUnit);
1834 rAttrs.Put(makeSvx3DFocalLengthItem(nValue2));
1836 else
1837 rAttrs.InvalidateItem(SDRATTR_3DSCENE_FOCAL_LENGTH);
1839 // Lighting
1840 Color aColor;
1841 const SfxItemSet aLightItemSet(m_xCtlLightPreview->GetSvx3DLightControl().Get3DAttributes());
1843 // Light 1 color
1844 if (!m_xLbLight1->IsNoSelection())
1846 aColor = m_xLbLight1->GetSelectEntryColor();
1847 rAttrs.Put(makeSvx3DLightcolor1Item(aColor));
1849 else
1850 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_1);
1851 // Light 1 (on/off)
1852 eState = m_xBtnLight1->get_state();
1853 if( eState != TRISTATE_INDET )
1855 bool bValue = m_xBtnLight1->isLightOn();
1856 rAttrs.Put(makeSvx3DLightOnOff1Item(bValue));
1858 // Light 1 (direction)
1859 if( bValue )
1861 rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_1));
1864 else
1865 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_1);
1868 // Light 2 color
1869 if (!m_xLbLight2->IsNoSelection())
1871 aColor = m_xLbLight2->GetSelectEntryColor();
1872 rAttrs.Put(makeSvx3DLightcolor2Item(aColor));
1874 else
1875 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_2);
1876 // Light 2 (on/off)
1877 eState = m_xBtnLight2->get_state();
1878 if( eState != TRISTATE_INDET )
1880 bool bValue = m_xBtnLight2->isLightOn();
1881 rAttrs.Put(makeSvx3DLightOnOff2Item(bValue));
1883 // Light 2 (direction)
1884 if( bValue )
1886 rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_2));
1889 else
1890 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_2);
1892 // Light 3 color
1893 if (!m_xLbLight3->IsNoSelection())
1895 aColor = m_xLbLight3->GetSelectEntryColor();
1896 rAttrs.Put(makeSvx3DLightcolor3Item(aColor));
1898 else
1899 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_3);
1900 // Light 3 (on/off)
1901 eState = m_xBtnLight3->get_state();
1902 if( eState != TRISTATE_INDET )
1904 bool bValue = m_xBtnLight3->isLightOn();
1905 rAttrs.Put(makeSvx3DLightOnOff3Item(bValue));
1907 // Light 3 (direction)
1908 if( bValue )
1910 rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_3));
1913 else
1914 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_3);
1916 // Light 4 color
1917 if (!m_xLbLight4->IsNoSelection())
1919 aColor = m_xLbLight4->GetSelectEntryColor();
1920 rAttrs.Put(makeSvx3DLightcolor4Item(aColor));
1922 else
1923 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_4);
1924 // Light 4 (on/off)
1925 eState = m_xBtnLight4->get_state();
1926 if( eState != TRISTATE_INDET )
1928 bool bValue = m_xBtnLight4->isLightOn();
1929 rAttrs.Put(makeSvx3DLightOnOff4Item(bValue));
1931 // Light 4 (direction)
1932 if( bValue )
1934 rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_4));
1937 else
1938 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_4);
1940 // Light 5 color
1941 if (!m_xLbLight5->IsNoSelection())
1943 aColor = m_xLbLight5->GetSelectEntryColor();
1944 rAttrs.Put(makeSvx3DLightcolor5Item(aColor));
1946 else
1947 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_5);
1948 // Light 5 (on/off)
1949 eState = m_xBtnLight5->get_state();
1950 if( eState != TRISTATE_INDET )
1952 bool bValue = m_xBtnLight5->isLightOn();
1953 rAttrs.Put(makeSvx3DLightOnOff5Item(bValue));
1955 // Light 5 (direction)
1956 if( bValue )
1958 rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_5));
1961 else
1962 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_5);
1964 // Light 6 color
1965 if (!m_xLbLight6->IsNoSelection())
1967 aColor = m_xLbLight6->GetSelectEntryColor();
1968 rAttrs.Put(makeSvx3DLightcolor6Item(aColor));
1970 else
1971 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_6);
1972 // Light 6 (on/off)
1973 eState = m_xBtnLight6->get_state();
1974 if( eState != TRISTATE_INDET )
1976 bool bValue = m_xBtnLight6->isLightOn();
1977 rAttrs.Put(makeSvx3DLightOnOff6Item(bValue));
1979 // Light 6 (direction)
1980 if( bValue )
1982 rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_6));
1985 else
1986 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_6);
1988 // Light 7 color
1989 if (!m_xLbLight7->IsNoSelection())
1991 aColor = m_xLbLight7->GetSelectEntryColor();
1992 rAttrs.Put(makeSvx3DLightcolor7Item(aColor));
1994 else
1995 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_7);
1996 // Light 7 (on/off)
1997 eState = m_xBtnLight7->get_state();
1998 if( eState != TRISTATE_INDET )
2000 bool bValue = m_xBtnLight7->isLightOn();
2001 rAttrs.Put(makeSvx3DLightOnOff7Item(bValue));
2003 // Light 7 (direction)
2004 if( bValue )
2006 rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_7));
2009 else
2010 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_7);
2012 // Light 8 color
2013 if (!m_xLbLight8->IsNoSelection())
2015 aColor = m_xLbLight8->GetSelectEntryColor();
2016 rAttrs.Put(makeSvx3DLightcolor8Item(aColor));
2018 else
2019 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_8);
2020 // Light 8 (on/off)
2021 eState = m_xBtnLight8->get_state();
2022 if( eState != TRISTATE_INDET )
2024 bool bValue = m_xBtnLight8->isLightOn();
2025 rAttrs.Put(makeSvx3DLightOnOff8Item(bValue));
2027 // Light 8 (direction)
2028 if( bValue )
2030 rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_8));
2033 else
2034 rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_8);
2036 // Ambient light
2037 if (!m_xLbAmbientlight->IsNoSelection())
2039 aColor = m_xLbAmbientlight->GetSelectEntryColor();
2040 rAttrs.Put(makeSvx3DAmbientcolorItem(aColor));
2042 else
2043 rAttrs.InvalidateItem(SDRATTR_3DSCENE_AMBIENTCOLOR);
2045 // Textures
2046 // Art
2047 nValue = 99;
2048 if( m_xBtnTexLuminance->get_active() )
2049 nValue = 1;
2050 else if( m_xBtnTexColor->get_active() )
2051 nValue = 3;
2053 if( nValue == 1 || nValue == 3 )
2054 rAttrs.Put(Svx3DTextureKindItem(nValue));
2055 else
2056 rAttrs.InvalidateItem(SDRATTR_3DOBJ_TEXTURE_KIND);
2059 // Mode
2060 nValue = 99;
2061 if( m_xBtnTexReplace->get_active() )
2062 nValue = 1;
2063 else if( m_xBtnTexModulate->get_active() )
2064 nValue = 2;
2066 if( nValue == 1 || nValue == 2 )
2067 rAttrs.Put(Svx3DTextureModeItem(nValue));
2068 else
2069 rAttrs.InvalidateItem(SDRATTR_3DOBJ_TEXTURE_MODE);
2071 // X projection
2072 nValue = 99;
2073 if( m_xBtnTexObjectX->get_active() )
2074 nValue = 0;
2075 else if( m_xBtnTexParallelX->get_active() )
2076 nValue = 1;
2077 else if( m_xBtnTexCircleX->get_active() )
2078 nValue = 2;
2080 if( nValue <= 2 )
2081 rAttrs.Put(Svx3DTextureProjectionXItem(nValue));
2082 else
2083 rAttrs.InvalidateItem(SDRATTR_3DOBJ_TEXTURE_PROJ_X);
2085 // Y projection
2086 nValue = 99;
2087 if( m_xBtnTexObjectY->get_active() )
2088 nValue = 0;
2089 else if( m_xBtnTexParallelY->get_active() )
2090 nValue = 1;
2091 else if( m_xBtnTexCircleY->get_active() )
2092 nValue = 2;
2094 if( nValue <= 2 )
2095 rAttrs.Put(Svx3DTextureProjectionYItem(nValue));
2096 else
2097 rAttrs.InvalidateItem(SDRATTR_3DOBJ_TEXTURE_PROJ_Y);
2100 // Filter
2101 eState = m_xBtnTexFilter->get_state();
2102 if( eState != TRISTATE_INDET )
2104 bool bValue = TRISTATE_TRUE == eState;
2105 rAttrs.Put(makeSvx3DTextureFilterItem(bValue));
2107 else
2108 rAttrs.InvalidateItem(SDRATTR_3DOBJ_TEXTURE_FILTER);
2111 // Material
2112 // Object color
2113 if (!m_xLbMatColor->IsNoSelection())
2115 aColor = m_xLbMatColor->GetSelectEntryColor();
2116 rAttrs.Put( XFillColorItem( "", aColor) );
2118 else
2120 rAttrs.InvalidateItem( XATTR_FILLCOLOR );
2123 // luminous color
2124 if (!m_xLbMatEmission->IsNoSelection())
2126 aColor = m_xLbMatEmission->GetSelectEntryColor();
2127 rAttrs.Put(makeSvx3DMaterialEmissionItem(aColor));
2129 else
2130 rAttrs.InvalidateItem(SDRATTR_3DOBJ_MAT_EMISSION);
2132 // Specular
2133 if (!m_xLbMatSpecular->IsNoSelection())
2135 aColor = m_xLbMatSpecular->GetSelectEntryColor();
2136 rAttrs.Put(makeSvx3DMaterialSpecularItem(aColor));
2138 else
2139 rAttrs.InvalidateItem(SDRATTR_3DOBJ_MAT_SPECULAR);
2141 // Specular intensity
2142 if( !m_xMtrMatSpecularIntensity->get_text().isEmpty() )
2144 sal_uInt16 nValue2 = static_cast<sal_uInt16>(m_xMtrMatSpecularIntensity->get_value(FieldUnit::PERCENT));
2145 rAttrs.Put(makeSvx3DMaterialSpecularIntensityItem(nValue2));
2147 else
2148 rAttrs.InvalidateItem(SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY);
2151 void Svx3DWin::Resize()
2153 Size aWinSize( GetOutputSizePixel() ); // why rSize in Resizing()?
2155 if( aWinSize.Height() >= GetMinOutputSizePixel().Height() &&
2156 aWinSize.Width() >= GetMinOutputSizePixel().Width() )
2158 // Hide
2159 m_xBtnUpdate->hide();
2160 m_xBtnAssign->hide();
2162 m_xBtnConvertTo3D->hide();
2163 m_xBtnLatheObject->hide();
2164 m_xBtnPerspective->hide();
2166 m_xCtlPreview->Hide();
2167 m_xLightPreviewGrid->hide();
2169 m_xFLGeometrie->hide();
2170 m_xFLRepresentation->hide();
2171 m_xFLLight->hide();
2172 m_xFLTexture->hide();
2173 m_xFLMaterial->hide();
2175 // Show
2176 m_xBtnUpdate->show();
2177 m_xBtnAssign->show();
2179 m_xBtnConvertTo3D->show();
2180 m_xBtnLatheObject->show();
2181 m_xBtnPerspective->show();
2183 if( m_xBtnGeo->get_active() )
2184 ClickViewTypeHdl(*m_xBtnGeo);
2185 if( m_xBtnRepresentation->get_active() )
2186 ClickViewTypeHdl(*m_xBtnRepresentation);
2187 if( m_xBtnLight->get_active() )
2188 ClickViewTypeHdl(*m_xBtnLight);
2189 if( m_xBtnTexture->get_active() )
2190 ClickViewTypeHdl(*m_xBtnTexture);
2191 if( m_xBtnMaterial->get_active() )
2192 ClickViewTypeHdl(*m_xBtnMaterial);
2195 SfxDockingWindow::Resize();
2198 IMPL_LINK_NOARG(Svx3DWin, ClickUpdateHdl, weld::Toggleable&, void)
2200 bUpdate = m_xBtnUpdate->get_active();
2202 if( bUpdate )
2204 SfxDispatcher* pDispatcher = LocalGetDispatcher(pBindings);
2205 if (pDispatcher != nullptr)
2207 SfxBoolItem aItem( SID_3D_STATE, true );
2208 pDispatcher->ExecuteList(SID_3D_STATE,
2209 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, { &aItem });
2212 else
2214 // Controls can be disabled during certain circumstances
2218 IMPL_LINK_NOARG(Svx3DWin, ClickAssignHdl, weld::Button&, void)
2220 SfxDispatcher* pDispatcher = LocalGetDispatcher(pBindings);
2221 if (pDispatcher != nullptr)
2223 SfxBoolItem aItem( SID_3D_ASSIGN, true );
2224 pDispatcher->ExecuteList(SID_3D_ASSIGN,
2225 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, { &aItem });
2229 IMPL_LINK( Svx3DWin, ClickViewTypeHdl, weld::Button&, rBtn, void )
2231 // Since the permanent updating of the preview would be too expensive
2232 bool bUpdatePreview = m_xBtnLight->get_active();
2234 m_xBtnGeo->set_active(m_xBtnGeo.get() == &rBtn);
2235 m_xBtnRepresentation->set_active(m_xBtnRepresentation.get() == &rBtn);
2236 m_xBtnLight->set_active(m_xBtnLight.get() == &rBtn);
2237 m_xBtnTexture->set_active(m_xBtnTexture.get() == &rBtn);
2238 m_xBtnMaterial->set_active(m_xBtnMaterial.get() == &rBtn);
2240 if( m_xBtnGeo->get_active() )
2241 eViewType = ViewType3D::Geo;
2242 if( m_xBtnRepresentation->get_active() )
2243 eViewType = ViewType3D::Representation;
2244 if( m_xBtnLight->get_active() )
2245 eViewType = ViewType3D::Light;
2246 if( m_xBtnTexture->get_active() )
2247 eViewType = ViewType3D::Texture;
2248 if( m_xBtnMaterial->get_active() )
2249 eViewType = ViewType3D::Material;
2251 // Geometry
2252 if( eViewType == ViewType3D::Geo )
2254 m_xFLSegments->show();
2255 m_xFLGeometrie->show();
2256 m_xFLNormals->show();
2258 else
2260 m_xFLSegments->hide();
2261 m_xFLGeometrie->hide();
2262 m_xFLNormals->hide();
2265 // Representation
2266 if( eViewType == ViewType3D::Representation )
2268 m_xFLShadow->show();
2269 m_xFLCamera->show();
2270 m_xFLRepresentation->show();
2272 else
2274 m_xFLShadow->hide();
2275 m_xFLCamera->hide();
2276 m_xFLRepresentation->hide();
2279 // Lighting
2280 if( eViewType == ViewType3D::Light )
2282 m_xFLLight->show();
2284 ColorListBox* pLb = GetCLbByButton();
2285 if( pLb )
2286 pLb->show();
2288 m_xLightPreviewGrid->show();
2289 m_xCtlPreview->Hide();
2291 else
2293 m_xFLLight->hide();
2295 if( !m_xCtlPreview->IsVisible() )
2297 m_xCtlPreview->Show();
2298 m_xLightPreviewGrid->hide();
2302 // Textures
2303 if (eViewType == ViewType3D::Texture)
2304 m_xFLTexture->show();
2305 else
2306 m_xFLTexture->hide();
2308 // Material
2309 if( eViewType == ViewType3D::Material )
2311 m_xFLMatSpecular->show();
2312 m_xFLMaterial->show();
2314 else
2316 m_xFLMatSpecular->hide();
2317 m_xFLMaterial->hide();
2319 if( bUpdatePreview && !m_xBtnLight->get_active() )
2320 UpdatePreview();
2323 IMPL_LINK( Svx3DWin, ClickHdl, weld::Button&, rBtn, void )
2325 bool bUpdatePreview = false;
2326 sal_uInt16 nSId = 0;
2328 if( &rBtn == m_xBtnConvertTo3D.get() )
2330 nSId = SID_CONVERT_TO_3D;
2332 else if( &rBtn == m_xBtnLatheObject.get() )
2334 nSId = SID_CONVERT_TO_3D_LATHE_FAST;
2336 // Geometry
2337 else if( &rBtn == m_xBtnNormalsObj.get() ||
2338 &rBtn == m_xBtnNormalsFlat.get() ||
2339 &rBtn == m_xBtnNormalsSphere.get() )
2341 m_xBtnNormalsObj->set_active( &rBtn == m_xBtnNormalsObj.get() );
2342 m_xBtnNormalsFlat->set_active( &rBtn == m_xBtnNormalsFlat.get() );
2343 m_xBtnNormalsSphere->set_active( &rBtn == m_xBtnNormalsSphere.get() );
2344 bUpdatePreview = true;
2346 else if( &rBtn == m_xBtnLight1->get_widget() ||
2347 &rBtn == m_xBtnLight2->get_widget() ||
2348 &rBtn == m_xBtnLight3->get_widget() ||
2349 &rBtn == m_xBtnLight4->get_widget() ||
2350 &rBtn == m_xBtnLight5->get_widget() ||
2351 &rBtn == m_xBtnLight6->get_widget() ||
2352 &rBtn == m_xBtnLight7->get_widget() ||
2353 &rBtn == m_xBtnLight8->get_widget() )
2355 // Lighting
2356 LightButton* pToggleBtn = GetLbByButton(&rBtn);
2358 ColorListBox* pLb = GetCLbByButton(pToggleBtn);
2359 pLb->show();
2361 bool bIsChecked = pToggleBtn->get_prev_active();
2363 if (pToggleBtn != m_xBtnLight1.get() && m_xBtnLight1->get_active())
2365 m_xBtnLight1->set_active( false );
2366 m_xBtnLight1->set_prev_active(false);
2367 m_xLbLight1->hide();
2369 if (pToggleBtn != m_xBtnLight2.get() && m_xBtnLight2->get_active())
2371 m_xBtnLight2->set_active( false );
2372 m_xBtnLight2->set_prev_active(false);
2373 m_xLbLight2->hide();
2375 if( pToggleBtn != m_xBtnLight3.get() && m_xBtnLight3->get_active() )
2377 m_xBtnLight3->set_active( false );
2378 m_xBtnLight3->set_prev_active(false);
2379 m_xLbLight3->hide();
2381 if( pToggleBtn != m_xBtnLight4.get() && m_xBtnLight4->get_active() )
2383 m_xBtnLight4->set_active( false );
2384 m_xBtnLight4->set_prev_active(false);
2385 m_xLbLight4->hide();
2387 if( pToggleBtn != m_xBtnLight5.get() && m_xBtnLight5->get_active() )
2389 m_xBtnLight5->set_active( false );
2390 m_xBtnLight5->set_prev_active(false);
2391 m_xLbLight5->hide();
2393 if( pToggleBtn != m_xBtnLight6.get() && m_xBtnLight6->get_active() )
2395 m_xBtnLight6->set_active( false );
2396 m_xBtnLight6->set_prev_active(false);
2397 m_xLbLight6->hide();
2399 if( pToggleBtn != m_xBtnLight7.get() && m_xBtnLight7->get_active() )
2401 m_xBtnLight7->set_active( false );
2402 m_xBtnLight7->set_prev_active(false);
2403 m_xLbLight7->hide();
2405 if( pToggleBtn != m_xBtnLight8.get() && m_xBtnLight8->get_active() )
2407 m_xBtnLight8->set_active( false );
2408 m_xBtnLight8->set_prev_active(false);
2409 m_xLbLight8->hide();
2412 //update light button
2413 pToggleBtn->set_active(true);
2414 pToggleBtn->set_prev_active(true);
2415 if (bIsChecked)
2416 pToggleBtn->switchLightOn(!pToggleBtn->isLightOn());
2418 bool bEnable = pToggleBtn->isLightOn();
2419 m_xBtnLightColor->set_sensitive( bEnable );
2420 pLb->set_sensitive( bEnable );
2422 ClickLight(*pToggleBtn);
2423 bUpdatePreview = true;
2425 // Textures
2426 else if( &rBtn == m_xBtnTexLuminance.get() ||
2427 &rBtn == m_xBtnTexColor.get() )
2429 m_xBtnTexLuminance->set_active( &rBtn == m_xBtnTexLuminance.get() );
2430 m_xBtnTexColor->set_active( &rBtn == m_xBtnTexColor.get() );
2431 bUpdatePreview = true;
2433 else if( &rBtn == m_xBtnTexReplace.get() ||
2434 &rBtn == m_xBtnTexModulate.get() )
2436 m_xBtnTexReplace->set_active( &rBtn == m_xBtnTexReplace.get() );
2437 m_xBtnTexModulate->set_active( &rBtn == m_xBtnTexModulate.get() );
2438 bUpdatePreview = true;
2440 else if( &rBtn == m_xBtnTexParallelX.get() ||
2441 &rBtn == m_xBtnTexCircleX.get() ||
2442 &rBtn == m_xBtnTexObjectX.get() )
2444 m_xBtnTexParallelX->set_active( &rBtn == m_xBtnTexParallelX.get() );
2445 m_xBtnTexCircleX->set_active( &rBtn == m_xBtnTexCircleX.get() );
2446 m_xBtnTexObjectX->set_active( &rBtn == m_xBtnTexObjectX.get() );
2447 bUpdatePreview = true;
2449 else if( &rBtn == m_xBtnTexParallelY.get() ||
2450 &rBtn == m_xBtnTexCircleY.get() ||
2451 &rBtn == m_xBtnTexObjectY.get() )
2453 m_xBtnTexParallelY->set_active( &rBtn == m_xBtnTexParallelY.get() );
2454 m_xBtnTexCircleY->set_active( &rBtn == m_xBtnTexCircleY.get() );
2455 m_xBtnTexObjectY->set_active( &rBtn == m_xBtnTexObjectY.get() );
2456 bUpdatePreview = true;
2458 else if (&rBtn == m_xBtnShadow3d.get())
2460 m_xFtSlant->set_sensitive( m_xBtnShadow3d->get_active() );
2461 m_xMtrSlant->set_sensitive( m_xBtnShadow3d->get_active() );
2462 bUpdatePreview = true;
2464 // Other (no groups)
2465 else
2467 bUpdatePreview = true;
2470 if( nSId > 0 )
2472 SfxDispatcher* pDispatcher = LocalGetDispatcher(pBindings);
2473 if (pDispatcher != nullptr)
2475 SfxBoolItem aItem( nSId, true );
2476 pDispatcher->ExecuteList(nSId,
2477 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, { &aItem });
2480 else if( bUpdatePreview )
2481 UpdatePreview();
2484 IMPL_LINK( Svx3DWin, ClickColorHdl, weld::Button&, rBtn, void)
2486 SvColorDialog aColorDlg;
2487 ColorListBox* pLb;
2489 if( &rBtn == m_xBtnLightColor.get() )
2490 pLb = GetCLbByButton();
2491 else if( &rBtn == m_xBtnAmbientColor.get() )
2492 pLb = m_xLbAmbientlight.get();
2493 else if( &rBtn == m_xBtnMatColor.get() )
2494 pLb = m_xLbMatColor.get();
2495 else if( &rBtn == m_xBtnEmissionColor.get() )
2496 pLb = m_xLbMatEmission.get();
2497 else // if( &rBtn == m_xBtnSpecularColor.get() )
2498 pLb = m_xLbMatSpecular.get();
2500 Color aColor = pLb->GetSelectEntryColor();
2502 aColorDlg.SetColor( aColor );
2503 if( aColorDlg.Execute(GetFrameWeld()) == RET_OK )
2505 aColor = aColorDlg.GetColor();
2506 LBSelectColor(pLb, aColor);
2507 SelectColorHdl(*pLb);
2511 IMPL_LINK( Svx3DWin, SelectHdl, weld::ComboBox&, rListBox, void )
2513 bool bUpdatePreview = false;
2515 // Material
2516 if (&rListBox == m_xLbMatFavorites.get())
2518 Color aColObj( COL_WHITE );
2519 Color aColEmis( COL_BLACK );
2520 Color aColSpec( COL_WHITE );
2521 sal_uInt16 nSpecIntens = 20;
2523 switch( m_xLbMatFavorites->get_active() )
2525 case 1: // Metall
2527 aColObj = Color(230,230,255);
2528 aColEmis = Color(10,10,30);
2529 aColSpec = Color(200,200,200);
2530 nSpecIntens = 20;
2532 break;
2534 case 2: // Gold
2536 aColObj = Color(230,255,0);
2537 aColEmis = Color(51,0,0);
2538 aColSpec = Color(255,255,240);
2539 nSpecIntens = 20;
2541 break;
2543 case 3: // Chrome
2545 aColObj = Color(36,117,153);
2546 aColEmis = Color(18,30,51);
2547 aColSpec = Color(230,230,255);
2548 nSpecIntens = 2;
2550 break;
2552 case 4: // Plastic
2554 aColObj = Color(255,48,57);
2555 aColEmis = Color(35,0,0);
2556 aColSpec = Color(179,202,204);
2557 nSpecIntens = 60;
2559 break;
2561 case 5: // Wood
2563 aColObj = Color(153,71,1);
2564 aColEmis = Color(21,22,0);
2565 aColSpec = Color(255,255,153);
2566 nSpecIntens = 75;
2568 break;
2570 LBSelectColor( m_xLbMatColor.get(), aColObj );
2571 LBSelectColor( m_xLbMatEmission.get(), aColEmis );
2572 LBSelectColor( m_xLbMatSpecular.get(), aColSpec );
2573 m_xMtrMatSpecularIntensity->set_value(nSpecIntens, FieldUnit::PERCENT);
2575 bUpdatePreview = true;
2577 else if (&rListBox == m_xLbShademode.get())
2578 bUpdatePreview = true;
2580 if( bUpdatePreview )
2581 UpdatePreview();
2584 IMPL_LINK( Svx3DWin, SelectColorHdl, ColorListBox&, rListBox, void )
2586 bool bUpdatePreview = false;
2588 if( &rListBox == m_xLbMatColor.get() ||
2589 &rListBox == m_xLbMatEmission.get() ||
2590 &rListBox == m_xLbMatSpecular.get() )
2592 m_xLbMatFavorites->set_active( 0 );
2593 bUpdatePreview = true;
2595 // Lighting
2596 else if( &rListBox == m_xLbAmbientlight.get() )
2598 bUpdatePreview = true;
2600 else if( &rListBox == m_xLbLight1.get() ||
2601 &rListBox == m_xLbLight2.get() ||
2602 &rListBox == m_xLbLight3.get() ||
2603 &rListBox == m_xLbLight4.get() ||
2604 &rListBox == m_xLbLight5.get() ||
2605 &rListBox == m_xLbLight6.get() ||
2606 &rListBox == m_xLbLight7.get() ||
2607 &rListBox == m_xLbLight8.get() )
2609 bUpdatePreview = true;
2612 if( bUpdatePreview )
2613 UpdatePreview();
2616 IMPL_LINK_NOARG( Svx3DWin, ModifyMetricHdl, weld::MetricSpinButton&, void )
2618 UpdatePreview();
2621 IMPL_LINK_NOARG( Svx3DWin, ModifySpinHdl, weld::SpinButton&, void )
2623 UpdatePreview();
2626 void Svx3DWin::ClickLight(const LightButton& rBtn)
2628 sal_uInt16 nLightSource = GetLightSource( &rBtn );
2629 ColorListBox* pLb = GetCLbByButton( &rBtn );
2630 Color aColor( pLb->GetSelectEntryColor() );
2631 SfxItemSet aLightItemSet(m_xCtlLightPreview->GetSvx3DLightControl().Get3DAttributes());
2632 const bool bOnOff(rBtn.isLightOn());
2634 switch(nLightSource)
2636 case 0: aLightItemSet.Put(makeSvx3DLightcolor1Item(aColor)); aLightItemSet.Put(makeSvx3DLightOnOff1Item(bOnOff)); break;
2637 case 1: aLightItemSet.Put(makeSvx3DLightcolor2Item(aColor)); aLightItemSet.Put(makeSvx3DLightOnOff2Item(bOnOff)); break;
2638 case 2: aLightItemSet.Put(makeSvx3DLightcolor3Item(aColor)); aLightItemSet.Put(makeSvx3DLightOnOff3Item(bOnOff)); break;
2639 case 3: aLightItemSet.Put(makeSvx3DLightcolor4Item(aColor)); aLightItemSet.Put(makeSvx3DLightOnOff4Item(bOnOff)); break;
2640 case 4: aLightItemSet.Put(makeSvx3DLightcolor5Item(aColor)); aLightItemSet.Put(makeSvx3DLightOnOff5Item(bOnOff)); break;
2641 case 5: aLightItemSet.Put(makeSvx3DLightcolor6Item(aColor)); aLightItemSet.Put(makeSvx3DLightOnOff6Item(bOnOff)); break;
2642 case 6: aLightItemSet.Put(makeSvx3DLightcolor7Item(aColor)); aLightItemSet.Put(makeSvx3DLightOnOff7Item(bOnOff)); break;
2643 default:
2644 case 7: aLightItemSet.Put(makeSvx3DLightcolor8Item(aColor)); aLightItemSet.Put(makeSvx3DLightOnOff8Item(bOnOff)); break;
2647 m_xCtlLightPreview->GetSvx3DLightControl().Set3DAttributes(aLightItemSet);
2648 m_xCtlLightPreview->GetSvx3DLightControl().SelectLight(nLightSource);
2649 m_xCtlLightPreview->CheckSelection();
2652 IMPL_LINK_NOARG(Svx3DWin, ChangeSelectionCallbackHdl, SvxLightCtl3D*, void)
2654 const sal_uInt32 nLight(m_xCtlLightPreview->GetSvx3DLightControl().GetSelectedLight());
2655 weld::Button* pBtn = nullptr;
2657 switch( nLight )
2659 case 0: pBtn = m_xBtnLight1->get_widget(); break;
2660 case 1: pBtn = m_xBtnLight2->get_widget(); break;
2661 case 2: pBtn = m_xBtnLight3->get_widget(); break;
2662 case 3: pBtn = m_xBtnLight4->get_widget(); break;
2663 case 4: pBtn = m_xBtnLight5->get_widget(); break;
2664 case 5: pBtn = m_xBtnLight6->get_widget(); break;
2665 case 6: pBtn = m_xBtnLight7->get_widget(); break;
2666 case 7: pBtn = m_xBtnLight8->get_widget(); break;
2667 default: break;
2670 if (pBtn)
2671 ClickHdl(*pBtn);
2672 else
2674 // Status: No lamp selected
2675 if( m_xBtnLight1->get_active() )
2677 m_xBtnLight1->set_active( false );
2678 m_xLbLight1->set_sensitive( false );
2680 else if( m_xBtnLight2->get_active() )
2682 m_xBtnLight2->set_active( false );
2683 m_xLbLight2->set_sensitive( false );
2685 else if( m_xBtnLight3->get_active() )
2687 m_xBtnLight3->set_active( false );
2688 m_xLbLight3->set_sensitive( false );
2690 else if( m_xBtnLight4->get_active() )
2692 m_xBtnLight4->set_active( false );
2693 m_xLbLight4->set_sensitive( false );
2695 else if( m_xBtnLight5->get_active() )
2697 m_xBtnLight5->set_active( false );
2698 m_xLbLight5->set_sensitive( false );
2700 else if( m_xBtnLight6->get_active() )
2702 m_xBtnLight6->set_active( false );
2703 m_xLbLight6->set_sensitive( false );
2705 else if( m_xBtnLight7->get_active() )
2707 m_xBtnLight7->set_active( false );
2708 m_xLbLight7->set_sensitive( false );
2710 else if( m_xBtnLight8->get_active() )
2712 m_xBtnLight8->set_active( false );
2713 m_xLbLight8->set_sensitive( false );
2715 m_xBtnLightColor->set_sensitive( false );
2719 namespace
2721 OUString lcl_makeColorName(const Color& rColor)
2723 OUString aStr = SvxResId(RID_SVXFLOAT3D_FIX_R) +
2724 OUString::number(rColor.GetRed()) +
2725 " " +
2726 SvxResId(RID_SVXFLOAT3D_FIX_G) +
2727 OUString::number(rColor.GetGreen()) +
2728 " " +
2729 SvxResId(RID_SVXFLOAT3D_FIX_B) +
2730 OUString::number(rColor.GetBlue());
2731 return aStr;
2735 // Method to ensure that the LB is also associated with a color
2736 void Svx3DWin::LBSelectColor( ColorListBox* pLb, const Color& rColor )
2738 pLb->SetNoSelection();
2739 pLb->SelectEntry({rColor, lcl_makeColorName(rColor)});
2742 void Svx3DWin::UpdatePreview()
2744 if(!pModel)
2746 pModel.reset(new FmFormModel());
2749 // Get Itemset
2750 SfxItemSetFixed<SDRATTR_START, SDRATTR_END> aSet( pModel->GetItemPool() );
2752 // Get Attributes and set the preview
2753 GetAttr( aSet );
2754 m_xCtlPreview->Set3DAttributes( aSet );
2755 m_xCtlLightPreview->GetSvx3DLightControl().Set3DAttributes( aSet );
2759 // document is to be reloaded, destroy remembered ItemSet
2760 void Svx3DWin::DocumentReload()
2762 mpRemember2DAttributes.reset();
2765 void Svx3DWin::InitColorLB()
2767 // First...
2768 Color aColWhite( COL_WHITE );
2769 Color aColBlack( COL_BLACK );
2770 m_xLbLight1->SelectEntry( aColWhite );
2771 m_xLbLight2->SelectEntry( aColWhite );
2772 m_xLbLight3->SelectEntry( aColWhite );
2773 m_xLbLight4->SelectEntry( aColWhite );
2774 m_xLbLight5->SelectEntry( aColWhite );
2775 m_xLbLight6->SelectEntry( aColWhite );
2776 m_xLbLight7->SelectEntry( aColWhite );
2777 m_xLbLight8->SelectEntry( aColWhite );
2778 m_xLbAmbientlight->SelectEntry( aColBlack );
2779 m_xLbMatColor->SelectEntry( aColWhite );
2780 m_xLbMatEmission->SelectEntry( aColBlack );
2781 m_xLbMatSpecular->SelectEntry( aColWhite );
2784 sal_uInt16 Svx3DWin::GetLightSource( const LightButton* pBtn ) const
2786 sal_uInt16 nLight = 8;
2788 if (pBtn == m_xBtnLight1.get())
2789 nLight = 0;
2790 else if (pBtn == m_xBtnLight2.get())
2791 nLight = 1;
2792 else if( pBtn == m_xBtnLight3.get() )
2793 nLight = 2;
2794 else if( pBtn == m_xBtnLight4.get() )
2795 nLight = 3;
2796 else if( pBtn == m_xBtnLight5.get() )
2797 nLight = 4;
2798 else if( pBtn == m_xBtnLight6.get() )
2799 nLight = 5;
2800 else if( pBtn == m_xBtnLight7.get() )
2801 nLight = 6;
2802 else if( pBtn == m_xBtnLight8.get() )
2803 nLight = 7;
2805 return nLight;
2808 ColorListBox* Svx3DWin::GetCLbByButton( const LightButton* pBtn )
2810 ColorListBox* pLb = nullptr;
2812 if( pBtn == nullptr )
2814 if( m_xBtnLight1->get_active() )
2815 pLb = m_xLbLight1.get();
2816 else if( m_xBtnLight2->get_active() )
2817 pLb = m_xLbLight2.get();
2818 else if( m_xBtnLight3->get_active() )
2819 pLb = m_xLbLight3.get();
2820 else if( m_xBtnLight4->get_active() )
2821 pLb = m_xLbLight4.get();
2822 else if( m_xBtnLight5->get_active() )
2823 pLb = m_xLbLight5.get();
2824 else if( m_xBtnLight6->get_active() )
2825 pLb = m_xLbLight6.get();
2826 else if( m_xBtnLight7->get_active() )
2827 pLb = m_xLbLight7.get();
2828 else if( m_xBtnLight8->get_active() )
2829 pLb = m_xLbLight8.get();
2831 else
2833 if( pBtn == m_xBtnLight1.get() )
2834 pLb = m_xLbLight1.get();
2835 else if (pBtn == m_xBtnLight2.get())
2836 pLb = m_xLbLight2.get();
2837 else if( pBtn == m_xBtnLight3.get() )
2838 pLb = m_xLbLight3.get();
2839 else if( pBtn == m_xBtnLight4.get() )
2840 pLb = m_xLbLight4.get();
2841 else if( pBtn == m_xBtnLight5.get() )
2842 pLb = m_xLbLight5.get();
2843 else if( pBtn == m_xBtnLight6.get() )
2844 pLb = m_xLbLight6.get();
2845 else if( pBtn == m_xBtnLight7.get() )
2846 pLb = m_xLbLight7.get();
2847 else if( pBtn == m_xBtnLight8.get() )
2848 pLb = m_xLbLight8.get();
2850 return pLb;
2853 LightButton* Svx3DWin::GetLbByButton( const weld::Button* pBtn )
2855 LightButton* pLb = nullptr;
2857 if( pBtn == m_xBtnLight1->get_widget() )
2858 pLb = m_xBtnLight1.get();
2859 else if (pBtn == m_xBtnLight2->get_widget() )
2860 pLb = m_xBtnLight2.get();
2861 else if( pBtn == m_xBtnLight3->get_widget() )
2862 pLb = m_xBtnLight3.get();
2863 else if( pBtn == m_xBtnLight4->get_widget() )
2864 pLb = m_xBtnLight4.get();
2865 else if( pBtn == m_xBtnLight5->get_widget() )
2866 pLb = m_xBtnLight5.get();
2867 else if( pBtn == m_xBtnLight6->get_widget() )
2868 pLb = m_xBtnLight6.get();
2869 else if( pBtn == m_xBtnLight7->get_widget() )
2870 pLb = m_xBtnLight7.get();
2871 else if( pBtn == m_xBtnLight8->get_widget() )
2872 pLb = m_xBtnLight8.get();
2874 return pLb;
2877 // Derivation from SfxChildWindow as "containers" for effects
2878 Svx3DChildWindow::Svx3DChildWindow( vcl::Window* _pParent,
2879 sal_uInt16 nId,
2880 SfxBindings* pBindings,
2881 SfxChildWinInfo* pInfo ) :
2882 SfxChildWindow( _pParent, nId )
2884 VclPtr<Svx3DWin> pWin = VclPtr<Svx3DWin>::Create( pBindings, this, _pParent );
2885 SetWindow(pWin);
2887 pWin->Initialize( pInfo );
2890 Svx3DCtrlItem::Svx3DCtrlItem( sal_uInt16 _nId,
2891 SfxBindings* _pBindings) :
2892 SfxControllerItem( _nId, *_pBindings )
2897 void Svx3DCtrlItem::StateChangedAtToolBoxControl( sal_uInt16 /*nSId*/,
2898 SfxItemState /*eState*/, const SfxPoolItem* /*pItem*/ )
2902 // ControllerItem for Status Slot SID_CONVERT_TO_3D
2904 SvxConvertTo3DItem::SvxConvertTo3DItem(sal_uInt16 _nId, SfxBindings* _pBindings)
2905 : SfxControllerItem(_nId, *_pBindings),
2906 bState(false)
2910 void SvxConvertTo3DItem::StateChangedAtToolBoxControl(sal_uInt16 /*_nId*/, SfxItemState eState, const SfxPoolItem* /*pState*/)
2912 bool bNewState = (eState != SfxItemState::DISABLED);
2913 if(bNewState != bState)
2915 bState = bNewState;
2916 SfxDispatcher* pDispatcher = LocalGetDispatcher(&GetBindings());
2917 if (pDispatcher != nullptr)
2919 SfxBoolItem aItem( SID_3D_STATE, true );
2920 pDispatcher->ExecuteList(SID_3D_STATE,
2921 SfxCallMode::ASYNCHRON|SfxCallMode::RECORD, { &aItem });
2926 LightButton::LightButton(std::unique_ptr<weld::ToggleButton> xButton)
2927 : m_xButton(std::move(xButton))
2928 , m_bLightOn(false)
2929 , m_bButtonPrevActive(false)
2931 m_xButton->set_from_icon_name(RID_SVXBMP_LAMP_OFF);
2934 void LightButton::switchLightOn(bool bOn)
2936 if (m_bLightOn == bOn)
2937 return;
2938 m_bLightOn = bOn;
2939 if (m_bLightOn)
2940 m_xButton->set_from_icon_name(RID_SVXBMP_LAMP_ON);
2941 else
2942 m_xButton->set_from_icon_name(RID_SVXBMP_LAMP_OFF);
2945 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */