Bump version to 6.4-15
[LibreOffice.git] / include / svx / dlgctl3d.hxx
blob73cb8680a53c0957759bfeeb7a0cc2e0b817a3e5
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 #ifndef INCLUDED_SVX_DLGCTL3D_HXX
21 #define INCLUDED_SVX_DLGCTL3D_HXX
23 #include <vcl/ctrl.hxx>
24 #include <vcl/scrbar.hxx>
25 #include <vcl/button.hxx>
26 #include <vcl/customweld.hxx>
27 #include <vcl/weld.hxx>
28 #include <svl/itemset.hxx>
29 #include <svx/svxdllapi.h>
30 #include <basegfx/vector/b3dvector.hxx>
31 #include <memory>
33 class FmFormModel;
34 class FmFormPage;
35 class E3dView;
36 class E3dObject;
37 class E3dScene;
39 enum class SvxPreviewObjectType { SPHERE, CUBE };
41 class SAL_WARN_UNUSED Svx3DPreviewControl : public Control
43 protected:
44 std::unique_ptr<FmFormModel> mpModel;
45 FmFormPage* mpFmPage;
46 std::unique_ptr<E3dView> mp3DView;
47 E3dScene* mpScene;
48 E3dObject* mp3DObj;
49 SvxPreviewObjectType mnObjectType;
51 void Construct();
53 public:
54 Svx3DPreviewControl(vcl::Window* pParent, WinBits nStyle = 0);
55 virtual ~Svx3DPreviewControl() override;
56 virtual void dispose() override;
58 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
59 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
60 virtual void Resize() override;
61 virtual Size GetOptimalSize() const override;
63 virtual void SetObjectType(SvxPreviewObjectType nType);
64 SvxPreviewObjectType GetObjectType() const { return mnObjectType; }
65 SfxItemSet const & Get3DAttributes() const;
66 virtual void Set3DAttributes(const SfxItemSet& rAttr);
69 class SAL_WARN_UNUSED SVX_DLLPUBLIC PreviewControl3D : public weld::CustomWidgetController
71 protected:
72 std::unique_ptr<FmFormModel> mpModel;
73 FmFormPage* mpFmPage;
74 std::unique_ptr<E3dView> mp3DView;
75 E3dScene* mpScene;
76 E3dObject* mp3DObj;
77 SvxPreviewObjectType mnObjectType;
79 void Construct();
81 public:
82 PreviewControl3D();
83 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
84 virtual ~PreviewControl3D() override;
86 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
87 virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override;
88 virtual void Resize() override;
90 virtual void SetObjectType(SvxPreviewObjectType nType);
91 SvxPreviewObjectType GetObjectType() const { return mnObjectType; }
92 SfxItemSet const & Get3DAttributes() const;
93 virtual void Set3DAttributes(const SfxItemSet& rAttr);
97 class SAL_WARN_UNUSED Svx3DLightControl final : public Svx3DPreviewControl
99 // Callback for interactive changes
100 Link<Svx3DLightControl*,void> maChangeCallback;
101 Link<Svx3DLightControl*,void> maSelectionChangeCallback;
103 // lights
104 sal_uInt32 maSelectedLight;
106 // extra objects for light control
107 E3dObject* mpExpansionObject;
108 E3dObject* mpLampBottomObject;
109 E3dObject* mpLampShaftObject;
110 std::vector< E3dObject* > maLightObjects;
112 // 3d rotations of object
113 double mfRotateX;
114 double mfRotateY;
115 double mfRotateZ;
117 // interaction parameters
118 Point maActionStartPoint;
119 double mfSaveActionStartHor;
120 double mfSaveActionStartVer;
121 double mfSaveActionStartRotZ;
123 bool mbMouseMoved : 1;
124 bool mbGeometrySelected : 1;
126 void Construct2();
127 void ConstructLightObjects();
128 void AdaptToSelectedLight();
129 void TrySelection(Point aPosPixel);
131 public:
132 Svx3DLightControl(vcl::Window* pParent, WinBits nStyle);
134 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
135 virtual void MouseButtonDown(const MouseEvent& rMEvt) override;
136 virtual void Tracking( const TrackingEvent& rTEvt ) override;
137 virtual void Resize() override;
139 virtual void SetObjectType(SvxPreviewObjectType nType) override;
141 // register user callback
142 void SetChangeCallback(Link<Svx3DLightControl*,void> aNew) { maChangeCallback = aNew; }
143 void SetSelectionChangeCallback(Link<Svx3DLightControl*,void> aNew) { maSelectionChangeCallback = aNew; }
145 // selection checks
146 bool IsSelectionValid();
147 bool IsGeometrySelected() const { return mbGeometrySelected; }
149 // get/set position of selected lamp in polar coordinates, Hor:[0..360.0[ and Ver:[-90..90] degrees
150 void GetPosition(double& rHor, double& rVer);
151 void SetPosition(double fHor, double fVer);
153 // get/set rotation of 3D object
154 void SetRotation(double fRotX, double fRotY, double fRotZ);
155 void GetRotation(double& rRotX, double& rRotY, double& rRotZ);
157 void SelectLight(sal_uInt32 nLightNumber);
158 virtual void Set3DAttributes(const SfxItemSet& rAttr) override;
159 sal_uInt32 GetSelectedLight() const { return maSelectedLight; }
161 // light data access
162 bool GetLightOnOff(sal_uInt32 nNum) const;
163 Color GetLightColor(sal_uInt32 nNum) const;
164 basegfx::B3DVector GetLightDirection(sal_uInt32 nNum) const;
167 class SAL_WARN_UNUSED SVX_DLLPUBLIC LightControl3D final : public PreviewControl3D
169 // Callback for interactive changes
170 Link<LightControl3D*,void> maChangeCallback;
171 Link<LightControl3D*,void> maSelectionChangeCallback;
173 // lights
174 sal_uInt32 maSelectedLight;
176 // extra objects for light control
177 E3dObject* mpExpansionObject;
178 E3dObject* mpLampBottomObject;
179 E3dObject* mpLampShaftObject;
180 std::vector< E3dObject* > maLightObjects;
182 // 3d rotations of object
183 double mfRotateX;
184 double mfRotateY;
185 double mfRotateZ;
187 // interaction parameters
188 Point maActionStartPoint;
189 double mfSaveActionStartHor;
190 double mfSaveActionStartVer;
191 double mfSaveActionStartRotZ;
193 bool mbMouseMoved : 1;
194 bool mbMouseCaptured : 1;
195 bool mbGeometrySelected : 1;
197 void Construct2();
198 void ConstructLightObjects();
199 void AdaptToSelectedLight();
200 void TrySelection(Point aPosPixel);
202 public:
203 LightControl3D();
205 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
206 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
207 virtual tools::Rectangle GetFocusRect() override;
208 virtual bool MouseButtonDown(const MouseEvent& rMEvt) override;
209 virtual bool MouseMove( const MouseEvent& rMEvt ) override;
210 virtual bool MouseButtonUp( const MouseEvent& rMEvt ) override;
211 virtual void Resize() override;
213 virtual void SetObjectType(SvxPreviewObjectType nType) override;
215 // register user callback
216 void SetChangeCallback(Link<LightControl3D*,void> aNew) { maChangeCallback = aNew; }
217 void SetSelectionChangeCallback(Link<LightControl3D*,void> aNew) { maSelectionChangeCallback = aNew; }
219 // selection checks
220 bool IsSelectionValid();
221 bool IsGeometrySelected() const { return mbGeometrySelected; }
223 // get/set position of selected lamp in polar coordinates, Hor:[0..360.0[ and Ver:[-90..90] degrees
224 void GetPosition(double& rHor, double& rVer);
225 void SetPosition(double fHor, double fVer);
227 // get/set rotation of 3D object
228 void SetRotation(double fRotX, double fRotY, double fRotZ);
229 void GetRotation(double& rRotX, double& rRotY, double& rRotZ);
231 void SelectLight(sal_uInt32 nLightNumber);
232 virtual void Set3DAttributes(const SfxItemSet& rAttr) override;
233 sal_uInt32 GetSelectedLight() const { return maSelectedLight; }
235 // light data access
236 bool GetLightOnOff(sal_uInt32 nNum) const;
237 Color GetLightColor(sal_uInt32 nNum) const;
238 basegfx::B3DVector GetLightDirection(sal_uInt32 nNum) const;
241 class SAL_WARN_UNUSED SvxLightCtl3D final : public Control
243 // local controls
244 VclPtr<Svx3DLightControl> maLightControl;
245 VclPtr<ScrollBar> maHorScroller;
246 VclPtr<ScrollBar> maVerScroller;
247 VclPtr<PushButton> maSwitcher;
249 // callback for interactive changes
250 Link<SvxLightCtl3D*,void> maUserSelectionChangeCallback;
252 public:
253 SvxLightCtl3D(vcl::Window* pParent);
254 virtual ~SvxLightCtl3D() override;
255 virtual void dispose() override;
257 // react to size changes
258 virtual void Resize() override;
259 void NewLayout();
261 // check the selection for validity
262 void CheckSelection();
264 // bring further settings to the outside world
265 Svx3DLightControl& GetSvx3DLightControl() { return *maLightControl; }
267 // register user callback
268 void SetUserSelectionChangeCallback(Link<SvxLightCtl3D*,void> aNew) { maUserSelectionChangeCallback = aNew; }
270 virtual void KeyInput( const KeyEvent& rKEvt ) override;
271 virtual void GetFocus() override;
272 virtual void LoseFocus() override;
274 virtual Size GetOptimalSize() const override;
276 private:
278 DECL_LINK( InternalInteractiveChange, Svx3DLightControl*, void);
279 DECL_LINK( InternalSelectionChange, Svx3DLightControl*, void);
280 DECL_LINK( ScrollBarMove, ScrollBar*, void);
281 DECL_LINK( ButtonPress, Button*, void);
283 // initialize local parameters
284 void Init();
286 void move( double fDeltaHor, double fDeltaVer );
289 class SAL_WARN_UNUSED SVX_DLLPUBLIC LightCtl3D
291 // local controls
292 LightControl3D& mrLightControl;
293 weld::Scale& mrHorScroller;
294 weld::Scale& mrVerScroller;
295 weld::Button& mrSwitcher;
297 // callback for interactive changes
298 Link<LightCtl3D*,void> maUserInteractiveChangeCallback;
299 Link<LightCtl3D*,void> maUserSelectionChangeCallback;
301 public:
302 LightCtl3D(LightControl3D& rLightControl, weld::Scale& rHori,
303 weld::Scale& rVert, weld::Button& rButton);
304 ~LightCtl3D();
306 // check the selection for validity
307 void CheckSelection();
309 // bring further settings to the outside world
310 LightControl3D& GetSvx3DLightControl() { return mrLightControl; }
312 // register user callback
313 void SetUserInteractiveChangeCallback(Link<LightCtl3D*,void> aNew) { maUserInteractiveChangeCallback = aNew; }
314 void SetUserSelectionChangeCallback(Link<LightCtl3D*,void> aNew) { maUserSelectionChangeCallback = aNew; }
316 private:
318 DECL_LINK(InternalInteractiveChange, LightControl3D*, void);
319 DECL_LINK(InternalSelectionChange, LightControl3D*, void);
320 DECL_LINK(ScrollBarMove, weld::Scale&, void);
321 DECL_LINK(ButtonPress, weld::Button&, void);
322 DECL_LINK(KeyInput, const KeyEvent&, bool);
323 DECL_LINK(FocusIn, weld::Widget&, void);
325 // initialize local parameters
326 void Init();
328 void move( double fDeltaHor, double fDeltaVer );
332 #endif // _SCH_DLGCTL3D_HXX
334 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */