/src/libreoffice/include/svx/dlgctl3d.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #ifndef INCLUDED_SVX_DLGCTL3D_HXX |
21 | | #define INCLUDED_SVX_DLGCTL3D_HXX |
22 | | |
23 | | #include <vcl/customweld.hxx> |
24 | | #include <vcl/weld.hxx> |
25 | | #include <svl/itemset.hxx> |
26 | | #include <svx/svxdllapi.h> |
27 | | #include <svx/obj3d.hxx> |
28 | | #include <basegfx/vector/b3dvector.hxx> |
29 | | #include <memory> |
30 | | |
31 | | class FmFormModel; |
32 | | class FmFormPage; |
33 | | class E3dView; |
34 | | class E3dObject; |
35 | | class E3dScene; |
36 | | |
37 | | enum class SvxPreviewObjectType { SPHERE, CUBE }; |
38 | | |
39 | | class SAL_WARN_UNUSED UNLESS_MERGELIBS(SVX_DLLPUBLIC) Svx3DPreviewControl : public weld::CustomWidgetController |
40 | | { |
41 | | protected: |
42 | | std::unique_ptr<FmFormModel> mpModel; |
43 | | rtl::Reference<FmFormPage> mxFmPage; |
44 | | std::unique_ptr<E3dView> mp3DView; |
45 | | rtl::Reference<E3dScene> mpScene; |
46 | | rtl::Reference<E3dObject> mp3DObj; |
47 | | SvxPreviewObjectType mnObjectType; |
48 | | |
49 | | void Construct(); |
50 | | |
51 | | public: |
52 | | Svx3DPreviewControl(); |
53 | | virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; |
54 | | virtual ~Svx3DPreviewControl() override; |
55 | | |
56 | | virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; |
57 | | virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override; |
58 | | virtual void Resize() override; |
59 | | |
60 | | virtual void SetObjectType(SvxPreviewObjectType nType); |
61 | 0 | SvxPreviewObjectType GetObjectType() const { return mnObjectType; } |
62 | | SfxItemSet const & Get3DAttributes() const; |
63 | | virtual void Set3DAttributes(const SfxItemSet& rAttr); |
64 | | void ClearPageView(); |
65 | | }; |
66 | | |
67 | | class SAL_WARN_UNUSED UNLESS_MERGELIBS(SVX_DLLPUBLIC) Svx3DLightControl final : public Svx3DPreviewControl |
68 | | { |
69 | | // Callback for interactive changes |
70 | | Link<Svx3DLightControl*,void> maChangeCallback; |
71 | | Link<Svx3DLightControl*,void> maSelectionChangeCallback; |
72 | | |
73 | | // lights |
74 | | sal_uInt32 maSelectedLight; |
75 | | |
76 | | // extra objects for light control |
77 | | rtl::Reference<E3dObject> mpExpansionObject; |
78 | | rtl::Reference<E3dObject> mpLampBottomObject; |
79 | | rtl::Reference<E3dObject> mpLampShaftObject; |
80 | | std::vector< E3dObject* > maLightObjects; |
81 | | |
82 | | // 3d rotations of object |
83 | | double mfRotateX; |
84 | | double mfRotateY; |
85 | | double mfRotateZ; |
86 | | |
87 | | // interaction parameters |
88 | | Point maActionStartPoint; |
89 | | double mfSaveActionStartHor; |
90 | | double mfSaveActionStartVer; |
91 | | double mfSaveActionStartRotZ; |
92 | | |
93 | | bool mbMouseMoved : 1; |
94 | | bool mbMouseCaptured : 1; |
95 | | bool mbGeometrySelected : 1; |
96 | | |
97 | | void Construct2(); |
98 | | void ConstructLightObjects(); |
99 | | void AdaptToSelectedLight(); |
100 | | void TrySelection(Point aPosPixel); |
101 | | |
102 | | public: |
103 | | Svx3DLightControl(); |
104 | | |
105 | | virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; |
106 | | virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; |
107 | | virtual tools::Rectangle GetFocusRect() override; |
108 | | virtual bool MouseButtonDown(const MouseEvent& rMEvt) override; |
109 | | virtual bool MouseMove( const MouseEvent& rMEvt ) override; |
110 | | virtual bool MouseButtonUp( const MouseEvent& rMEvt ) override; |
111 | | virtual void Resize() override; |
112 | | |
113 | | virtual void SetObjectType(SvxPreviewObjectType nType) override; |
114 | | |
115 | | // register user callback |
116 | 0 | void SetChangeCallback(Link<Svx3DLightControl*,void> aNew) { maChangeCallback = aNew; } |
117 | 0 | void SetSelectionChangeCallback(Link<Svx3DLightControl*,void> aNew) { maSelectionChangeCallback = aNew; } |
118 | | |
119 | | // selection checks |
120 | | bool IsSelectionValid(); |
121 | 0 | bool IsGeometrySelected() const { return mbGeometrySelected; } |
122 | | |
123 | | // get/set position of selected lamp in polar coordinates, Hor:[0..360.0[ and Ver:[-90..90] degrees |
124 | | void GetPosition(double& rHor, double& rVer); |
125 | | void SetPosition(double fHor, double fVer); |
126 | | |
127 | | // get/set rotation of 3D object |
128 | | void SetRotation(double fRotX, double fRotY, double fRotZ); |
129 | | void GetRotation(double& rRotX, double& rRotY, double& rRotZ); |
130 | | |
131 | | void SelectLight(sal_uInt32 nLightNumber); |
132 | | virtual void Set3DAttributes(const SfxItemSet& rAttr) override; |
133 | 0 | sal_uInt32 GetSelectedLight() const { return maSelectedLight; } |
134 | | |
135 | | // light data access |
136 | | bool GetLightOnOff(sal_uInt32 nNum) const; |
137 | | Color GetLightColor(sal_uInt32 nNum) const; |
138 | | basegfx::B3DVector GetLightDirection(sal_uInt32 nNum) const; |
139 | | }; |
140 | | |
141 | | class SAL_WARN_UNUSED UNLESS_MERGELIBS(SVX_DLLPUBLIC) SvxLightCtl3D |
142 | | { |
143 | | // local controls |
144 | | Svx3DLightControl& mrLightControl; |
145 | | weld::Scale& mrHorScroller; |
146 | | weld::Scale& mrVerScroller; |
147 | | weld::Button& mrSwitcher; |
148 | | |
149 | | // callback for interactive changes |
150 | | Link<SvxLightCtl3D*,void> maUserInteractiveChangeCallback; |
151 | | Link<SvxLightCtl3D*,void> maUserSelectionChangeCallback; |
152 | | |
153 | | public: |
154 | | SvxLightCtl3D(Svx3DLightControl& rLightControl, weld::Scale& rHori, |
155 | | weld::Scale& rVert, weld::Button& rButton); |
156 | | |
157 | | // check the selection for validity |
158 | | void CheckSelection(); |
159 | | |
160 | | // bring further settings to the outside world |
161 | 0 | Svx3DLightControl& GetSvx3DLightControl() { return mrLightControl; } |
162 | | |
163 | | // register user callback |
164 | 0 | void SetUserInteractiveChangeCallback(Link<SvxLightCtl3D*,void> aNew) { maUserInteractiveChangeCallback = aNew; } |
165 | 0 | void SetUserSelectionChangeCallback(Link<SvxLightCtl3D*,void> aNew) { maUserSelectionChangeCallback = aNew; } |
166 | | |
167 | | private: |
168 | | |
169 | | DECL_DLLPRIVATE_LINK(InternalInteractiveChange, Svx3DLightControl*, void); |
170 | | DECL_DLLPRIVATE_LINK(InternalSelectionChange, Svx3DLightControl*, void); |
171 | | DECL_DLLPRIVATE_LINK(ScrollBarMove, weld::Scale&, void); |
172 | | DECL_DLLPRIVATE_LINK(ButtonPress, weld::Button&, void); |
173 | | DECL_DLLPRIVATE_LINK(KeyInput, const KeyEvent&, bool); |
174 | | DECL_DLLPRIVATE_LINK(FocusIn, weld::Widget&, void); |
175 | | |
176 | | // initialize local parameters |
177 | | void Init(); |
178 | | |
179 | | void move( double fDeltaHor, double fDeltaVer ); |
180 | | }; |
181 | | |
182 | | |
183 | | #endif // _SCH_DLGCTL3D_HXX |
184 | | |
185 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |