Line data Source code
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 _SVX_DLGCTL3D_HXX
21 : #define _SVX_DLGCTL3D_HXX
22 :
23 : #include <vcl/ctrl.hxx>
24 : #include <vcl/scrbar.hxx>
25 : #include <vcl/button.hxx>
26 : #include <svl/itemset.hxx>
27 : #include "svx/svxdllapi.h"
28 : #include <basegfx/vector/b3dvector.hxx>
29 :
30 : //////////////////////////////////////////////////////////////////////////////
31 :
32 : class FmFormModel;
33 : class FmFormPage;
34 : class E3dView;
35 : class E3dPolyScene;
36 : class E3dObject;
37 :
38 : //////////////////////////////////////////////////////////////////////////////
39 :
40 : #define PREVIEW_OBJECTTYPE_SPHERE 0x0000
41 : #define PREVIEW_OBJECTTYPE_CUBE 0x0001
42 :
43 : //////////////////////////////////////////////////////////////////////////////
44 :
45 : class SVX_DLLPUBLIC Svx3DPreviewControl : public Control
46 : {
47 : protected:
48 : FmFormModel* mpModel;
49 : FmFormPage* mpFmPage;
50 : E3dView* mp3DView;
51 : E3dPolyScene* mpScene;
52 : E3dObject* mp3DObj;
53 : sal_uInt16 mnObjectType;
54 :
55 : void Construct();
56 :
57 : public:
58 : Svx3DPreviewControl(Window* pParent, const ResId& rResId);
59 : Svx3DPreviewControl(Window* pParent, WinBits nStyle = 0);
60 : ~Svx3DPreviewControl();
61 :
62 : virtual void Paint( const Rectangle& rRect );
63 : virtual void MouseButtonDown( const MouseEvent& rMEvt );
64 : virtual void Resize();
65 :
66 : void Reset();
67 : virtual void SetObjectType(sal_uInt16 nType);
68 0 : sal_uInt16 GetObjectType() const { return( mnObjectType ); }
69 : SfxItemSet Get3DAttributes() const;
70 : virtual void Set3DAttributes(const SfxItemSet& rAttr);
71 : };
72 :
73 : //////////////////////////////////////////////////////////////////////////////
74 :
75 : class SVX_DLLPUBLIC Svx3DLightControl : public Svx3DPreviewControl
76 : {
77 : // Callback for interactive changes
78 : Link maUserInteractiveChangeCallback;
79 : Link maUserSelectionChangeCallback;
80 : Link maChangeCallback;
81 : Link maSelectionChangeCallback;
82 :
83 : // lights
84 : sal_uInt32 maSelectedLight;
85 :
86 : // extra objects for light control
87 : E3dObject* mpExpansionObject;
88 : E3dObject* mpLampBottomObject;
89 : E3dObject* mpLampShaftObject;
90 : std::vector< E3dObject* > maLightObjects;
91 :
92 : // 3d rotations of object
93 : double mfRotateX;
94 : double mfRotateY;
95 : double mfRotateZ;
96 :
97 : // interaction parameters
98 : Point maActionStartPoint;
99 : sal_Int32 mnInteractionStartDistance;
100 : double mfSaveActionStartHor;
101 : double mfSaveActionStartVer;
102 : double mfSaveActionStartRotZ;
103 :
104 : // bitfield
105 : unsigned mbMouseMoved : 1;
106 : unsigned mbGeometrySelected : 1;
107 :
108 : void Construct2();
109 : void ConstructLightObjects();
110 : void AdaptToSelectedLight();
111 : void TrySelection(Point aPosPixel);
112 :
113 : public:
114 : Svx3DLightControl(Window* pParent, WinBits nStyle = 0);
115 : ~Svx3DLightControl();
116 :
117 : virtual void Paint(const Rectangle& rRect);
118 : virtual void MouseButtonDown(const MouseEvent& rMEvt);
119 : virtual void Tracking( const TrackingEvent& rTEvt );
120 : virtual void Resize();
121 :
122 : virtual void SetObjectType(sal_uInt16 nType);
123 :
124 : // register user callback
125 : void SetUserInteractiveChangeCallback(Link aNew) { maUserInteractiveChangeCallback = aNew; }
126 : void SetUserSelectionChangeCallback(Link aNew) { maUserSelectionChangeCallback = aNew; }
127 0 : void SetChangeCallback(Link aNew) { maChangeCallback = aNew; }
128 0 : void SetSelectionChangeCallback(Link aNew) { maSelectionChangeCallback = aNew; }
129 :
130 : // selection checks
131 : bool IsSelectionValid();
132 0 : bool IsGeometrySelected() { return mbGeometrySelected; }
133 :
134 : // get/set position of selected lamp in polar coordinates, Hor:[0..360.0[ and Ver:[-90..90] degrees
135 : void GetPosition(double& rHor, double& rVer);
136 : void SetPosition(double fHor, double fVer);
137 :
138 : // get/set rotation of 3D object
139 : void SetRotation(double fRotX, double fRotY, double fRotZ);
140 : void GetRotation(double& rRotX, double& rRotY, double& rRotZ);
141 :
142 : void SelectLight(sal_uInt32 nLightNumber);
143 : virtual void Set3DAttributes(const SfxItemSet& rAttr);
144 0 : sal_uInt32 GetSelectedLight() { return maSelectedLight; }
145 :
146 : // light data access
147 : bool GetLightOnOff(sal_uInt32 nNum) const;
148 : Color GetLightColor(sal_uInt32 nNum) const;
149 : basegfx::B3DVector GetLightDirection(sal_uInt32 nNum) const;
150 : };
151 :
152 : //////////////////////////////////////////////////////////////////////////////
153 :
154 : class SVX_DLLPUBLIC SvxLightCtl3D : public Control
155 : {
156 : private:
157 : // local controls
158 : Svx3DLightControl maLightControl;
159 : ScrollBar maHorScroller;
160 : ScrollBar maVerScroller;
161 : PushButton maSwitcher;
162 :
163 : // callback for interactive changes
164 : Link maUserInteractiveChangeCallback;
165 : Link maUserSelectionChangeCallback;
166 :
167 : public:
168 : SvxLightCtl3D( Window* pParent, const ResId& rResId);
169 : ~SvxLightCtl3D();
170 :
171 : // react to size changes
172 : virtual void Resize();
173 : void NewLayout();
174 :
175 : // check the selection for validity
176 : void CheckSelection();
177 :
178 : // bring further settings to the outside world
179 0 : Svx3DLightControl& GetSvx3DLightControl() { return maLightControl; }
180 :
181 : // register user callback
182 0 : void SetUserInteractiveChangeCallback(Link aNew) { maUserInteractiveChangeCallback = aNew; }
183 0 : void SetUserSelectionChangeCallback(Link aNew) { maUserSelectionChangeCallback = aNew; }
184 :
185 : virtual void KeyInput( const KeyEvent& rKEvt );
186 : virtual void GetFocus();
187 : virtual void LoseFocus();
188 :
189 : protected:
190 :
191 : DECL_LINK( InternalInteractiveChange, void*);
192 : DECL_LINK( InternalSelectionChange, void*);
193 : DECL_LINK( ScrollBarMove, void*);
194 : DECL_LINK( ButtonPress, void*);
195 :
196 : // initialize local parameters
197 : void Init();
198 :
199 : void move( double fDeltaHor, double fDeltaVer );
200 : };
201 :
202 : #endif // _SCH_DLGCTL3D_HXX
203 :
204 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|