Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SVX_DLGCTL3D_HXX
30 : : #define _SVX_DLGCTL3D_HXX
31 : :
32 : : #include <vcl/ctrl.hxx>
33 : : #include <vcl/scrbar.hxx>
34 : : #include <vcl/button.hxx>
35 : : #include <svl/itemset.hxx>
36 : : #include "svx/svxdllapi.h"
37 : : #include <basegfx/vector/b3dvector.hxx>
38 : :
39 : : //////////////////////////////////////////////////////////////////////////////
40 : :
41 : : class FmFormModel;
42 : : class FmFormPage;
43 : : class E3dView;
44 : : class E3dPolyScene;
45 : : class E3dObject;
46 : :
47 : : //////////////////////////////////////////////////////////////////////////////
48 : :
49 : : #define PREVIEW_OBJECTTYPE_SPHERE 0x0000
50 : : #define PREVIEW_OBJECTTYPE_CUBE 0x0001
51 : :
52 : : //////////////////////////////////////////////////////////////////////////////
53 : :
54 : : class SVX_DLLPUBLIC Svx3DPreviewControl : public Control
55 : : {
56 : : protected:
57 : : FmFormModel* mpModel;
58 : : FmFormPage* mpFmPage;
59 : : E3dView* mp3DView;
60 : : E3dPolyScene* mpScene;
61 : : E3dObject* mp3DObj;
62 : : sal_uInt16 mnObjectType;
63 : :
64 : : void Construct();
65 : :
66 : : public:
67 : : Svx3DPreviewControl(Window* pParent, const ResId& rResId);
68 : : Svx3DPreviewControl(Window* pParent, WinBits nStyle = 0);
69 : : ~Svx3DPreviewControl();
70 : :
71 : : virtual void Paint( const Rectangle& rRect );
72 : : virtual void MouseButtonDown( const MouseEvent& rMEvt );
73 : : virtual void Resize();
74 : :
75 : : void Reset();
76 : : virtual void SetObjectType(sal_uInt16 nType);
77 : : sal_uInt16 GetObjectType() const { return( mnObjectType ); }
78 : : SfxItemSet Get3DAttributes() const;
79 : : virtual void Set3DAttributes(const SfxItemSet& rAttr);
80 : : };
81 : :
82 : : //////////////////////////////////////////////////////////////////////////////
83 : :
84 : : class SVX_DLLPUBLIC Svx3DLightControl : public Svx3DPreviewControl
85 : : {
86 : : // Callback for interactive changes
87 : : Link maUserInteractiveChangeCallback;
88 : : Link maUserSelectionChangeCallback;
89 : : Link maChangeCallback;
90 : : Link maSelectionChangeCallback;
91 : :
92 : : // lights
93 : : sal_uInt32 maSelectedLight;
94 : :
95 : : // extra objects for light control
96 : : E3dObject* mpExpansionObject;
97 : : E3dObject* mpLampBottomObject;
98 : : E3dObject* mpLampShaftObject;
99 : : std::vector< E3dObject* > maLightObjects;
100 : :
101 : : // 3d rotations of object
102 : : double mfRotateX;
103 : : double mfRotateY;
104 : : double mfRotateZ;
105 : :
106 : : // interaction parameters
107 : : Point maActionStartPoint;
108 : : sal_Int32 mnInteractionStartDistance;
109 : : double mfSaveActionStartHor;
110 : : double mfSaveActionStartVer;
111 : : double mfSaveActionStartRotZ;
112 : :
113 : : // bitfield
114 : : unsigned mbMouseMoved : 1;
115 : : unsigned mbGeometrySelected : 1;
116 : :
117 : : void Construct2();
118 : : void ConstructLightObjects();
119 : : void AdaptToSelectedLight();
120 : : void TrySelection(Point aPosPixel);
121 : :
122 : : public:
123 : : Svx3DLightControl(Window* pParent, WinBits nStyle = 0);
124 : : ~Svx3DLightControl();
125 : :
126 : : virtual void Paint(const Rectangle& rRect);
127 : : virtual void MouseButtonDown(const MouseEvent& rMEvt);
128 : : virtual void Tracking( const TrackingEvent& rTEvt );
129 : : virtual void Resize();
130 : :
131 : : virtual void SetObjectType(sal_uInt16 nType);
132 : :
133 : : // register user callback
134 : : void SetUserInteractiveChangeCallback(Link aNew) { maUserInteractiveChangeCallback = aNew; }
135 : : void SetUserSelectionChangeCallback(Link aNew) { maUserSelectionChangeCallback = aNew; }
136 : : void SetChangeCallback(Link aNew) { maChangeCallback = aNew; }
137 : : void SetSelectionChangeCallback(Link aNew) { maSelectionChangeCallback = aNew; }
138 : :
139 : : // selection checks
140 : : bool IsSelectionValid();
141 : : bool IsGeometrySelected() { return mbGeometrySelected; }
142 : :
143 : : // get/set position of selected lamp in polar coordinates, Hor:[0..360.0[ and Ver:[-90..90] degrees
144 : : void GetPosition(double& rHor, double& rVer);
145 : : void SetPosition(double fHor, double fVer);
146 : :
147 : : // get/set rotation of 3D object
148 : : void SetRotation(double fRotX, double fRotY, double fRotZ);
149 : : void GetRotation(double& rRotX, double& rRotY, double& rRotZ);
150 : :
151 : : void SelectLight(sal_uInt32 nLightNumber);
152 : : virtual void Set3DAttributes(const SfxItemSet& rAttr);
153 : 0 : sal_uInt32 GetSelectedLight() { return maSelectedLight; }
154 : :
155 : : // light data access
156 : : bool GetLightOnOff(sal_uInt32 nNum) const;
157 : : Color GetLightColor(sal_uInt32 nNum) const;
158 : : basegfx::B3DVector GetLightDirection(sal_uInt32 nNum) const;
159 : : };
160 : :
161 : : //////////////////////////////////////////////////////////////////////////////
162 : :
163 : : class SVX_DLLPUBLIC SvxLightCtl3D : public Control
164 : : {
165 : : private:
166 : : // local controls
167 : : Svx3DLightControl maLightControl;
168 : : ScrollBar maHorScroller;
169 : : ScrollBar maVerScroller;
170 : : PushButton maSwitcher;
171 : :
172 : : // callback for interactive changes
173 : : Link maUserInteractiveChangeCallback;
174 : : Link maUserSelectionChangeCallback;
175 : :
176 : : public:
177 : : SvxLightCtl3D( Window* pParent, const ResId& rResId);
178 : : ~SvxLightCtl3D();
179 : :
180 : : // react to size changes
181 : : virtual void Resize();
182 : : void NewLayout();
183 : :
184 : : // check the selection for validity
185 : : void CheckSelection();
186 : :
187 : : // bring further settings to the outside world
188 : 0 : Svx3DLightControl& GetSvx3DLightControl() { return maLightControl; }
189 : :
190 : : // register user callback
191 : 0 : void SetUserInteractiveChangeCallback(Link aNew) { maUserInteractiveChangeCallback = aNew; }
192 : 0 : void SetUserSelectionChangeCallback(Link aNew) { maUserSelectionChangeCallback = aNew; }
193 : :
194 : : virtual void KeyInput( const KeyEvent& rKEvt );
195 : : virtual void GetFocus();
196 : : virtual void LoseFocus();
197 : :
198 : : protected:
199 : :
200 : : DECL_LINK( InternalInteractiveChange, void*);
201 : : DECL_LINK( InternalSelectionChange, void*);
202 : : DECL_LINK( ScrollBarMove, void*);
203 : : DECL_LINK( ButtonPress, void*);
204 : :
205 : : // initialize local parameters
206 : : void Init();
207 : :
208 : : void move( double fDeltaHor, double fDeltaVer );
209 : : };
210 : :
211 : : #endif // _SCH_DLGCTL3D_HXX
212 : :
213 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|