xref: /AOO41X/main/svx/inc/svx/dlgctl3d.hxx (revision 3334a7e6acdae9820fa1a6f556bb10129a8de6b2)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SVX_DLGCTL3D_HXX
25 #define _SVX_DLGCTL3D_HXX
26 
27 #include <vcl/ctrl.hxx>
28 #include <vcl/scrbar.hxx>
29 #include <vcl/button.hxx>
30 #include <svl/itemset.hxx>
31 #include "svx/svxdllapi.h"
32 #include <basegfx/vector/b3dvector.hxx>
33 
34 //////////////////////////////////////////////////////////////////////////////
35 
36 class FmFormModel;
37 class FmFormPage;
38 class E3dView;
39 class E3dPolyScene;
40 class E3dObject;
41 
42 //////////////////////////////////////////////////////////////////////////////
43 
44 #define PREVIEW_OBJECTTYPE_SPHERE           0x0000
45 #define PREVIEW_OBJECTTYPE_CUBE             0x0001
46 
47 //////////////////////////////////////////////////////////////////////////////
48 
49 class SVX_DLLPUBLIC Svx3DPreviewControl : public Control
50 {
51 protected:
52     FmFormModel*            mpModel;
53     FmFormPage*             mpFmPage;
54     E3dView*                mp3DView;
55     E3dPolyScene*           mpScene;
56     E3dObject*              mp3DObj;
57     sal_uInt16              mnObjectType;
58 
59     void Construct();
60 
61 public:
62     Svx3DPreviewControl(Window* pParent, const ResId& rResId);
63     Svx3DPreviewControl(Window* pParent, WinBits nStyle = 0);
64     ~Svx3DPreviewControl();
65 
66     virtual void Paint( const Rectangle& rRect );
67     virtual void MouseButtonDown( const MouseEvent& rMEvt );
68     virtual void Resize();
69 
70     void Reset();
71     virtual void SetObjectType(sal_uInt16 nType);
GetObjectType() const72     sal_uInt16 GetObjectType() const { return( mnObjectType ); }
73     SfxItemSet Get3DAttributes() const;
74     virtual void Set3DAttributes(const SfxItemSet& rAttr);
75 };
76 
77 //////////////////////////////////////////////////////////////////////////////
78 
79 class SVX_DLLPUBLIC Svx3DLightControl : public Svx3DPreviewControl
80 {
81     // Callback for interactive changes
82     Link                        maUserInteractiveChangeCallback;
83     Link                        maUserSelectionChangeCallback;
84     Link                        maChangeCallback;
85     Link                        maSelectionChangeCallback;
86 
87     // lights
88     sal_uInt32                  maSelectedLight;
89 
90     // extra objects for light control
91     E3dObject*                  mpExpansionObject;
92     E3dObject*                  mpLampBottomObject;
93     E3dObject*                  mpLampShaftObject;
94     std::vector< E3dObject* >   maLightObjects;
95 
96     // 3d rotations of object
97     double                      mfRotateX;
98     double                      mfRotateY;
99     double                      mfRotateZ;
100 
101     // interaction parameters
102     Point                       maActionStartPoint;
103     sal_Int32                   mnInteractionStartDistance;
104     double                      mfSaveActionStartHor;
105     double                      mfSaveActionStartVer;
106     double                      mfSaveActionStartRotZ;
107 
108     // bitfield
109     unsigned                    mbMouseMoved : 1;
110     unsigned                    mbGeometrySelected : 1;
111 
112     void Construct2();
113     void ConstructLightObjects();
114     void AdaptToSelectedLight();
115     void TrySelection(Point aPosPixel);
116 
117 public:
118     Svx3DLightControl(Window* pParent, const ResId& rResId);
119     Svx3DLightControl(Window* pParent, WinBits nStyle = 0);
120     ~Svx3DLightControl();
121 
122     virtual void Paint(const Rectangle& rRect);
123     virtual void MouseButtonDown(const MouseEvent& rMEvt);
124     virtual void Tracking( const TrackingEvent& rTEvt );
125     virtual void Resize();
126 
127     virtual void SetObjectType(sal_uInt16 nType);
128 
129     // User Callback eintragen
SetUserInteractiveChangeCallback(Link aNew)130     void SetUserInteractiveChangeCallback(Link aNew) { maUserInteractiveChangeCallback = aNew; }
SetUserSelectionChangeCallback(Link aNew)131     void SetUserSelectionChangeCallback(Link aNew) { maUserSelectionChangeCallback = aNew; }
SetChangeCallback(Link aNew)132     void SetChangeCallback(Link aNew) { maChangeCallback = aNew; }
SetSelectionChangeCallback(Link aNew)133     void SetSelectionChangeCallback(Link aNew) { maSelectionChangeCallback = aNew; }
134 
135     // selection checks
136     bool IsSelectionValid();
IsGeometrySelected()137     bool IsGeometrySelected() { return mbGeometrySelected; }
138 
139     // get/set position of selected lamp in polar coordinates, Hor:[0..360.0[ and Ver:[-90..90] degrees
140     void GetPosition(double& rHor, double& rVer);
141     void SetPosition(double fHor, double fVer);
142 
143     // get/set rotation of 3D object
144     void SetRotation(double fRotX, double fRotY, double fRotZ);
145     void GetRotation(double& rRotX, double& rRotY, double& rRotZ);
146 
147     void SelectLight(sal_uInt32 nLightNumber);
148     virtual void Set3DAttributes(const SfxItemSet& rAttr);
GetSelectedLight()149     sal_uInt32 GetSelectedLight() { return maSelectedLight; }
150 
151     // light data access
152     bool GetLightOnOff(sal_uInt32 nNum) const;
153     Color GetLightColor(sal_uInt32 nNum) const;
154     basegfx::B3DVector GetLightDirection(sal_uInt32 nNum) const;
155 };
156 
157 //////////////////////////////////////////////////////////////////////////////
158 
159 class SVX_DLLPUBLIC SvxLightCtl3D : public Control
160 {
161 private:
162     // local controls
163     Svx3DLightControl       maLightControl;
164     ScrollBar               maHorScroller;
165     ScrollBar               maVerScroller;
166     PushButton              maSwitcher;
167 
168     // Callback bei interaktiven Aenderungen
169     Link                    maUserInteractiveChangeCallback;
170     Link                    maUserSelectionChangeCallback;
171 
172 public:
173     SvxLightCtl3D( Window* pParent, const ResId& rResId);
174     SvxLightCtl3D( Window* pParent, WinBits nStyle = 0);
175     ~SvxLightCtl3D();
176 
177     // Reagiere auf Groessenaenderungen
178     virtual void Resize();
179     void NewLayout();
180 
181     // Selektion auf Gueltigkeit pruefen
182     void CheckSelection();
183 
184     // Um weitere Einstellungen nach Aussen zu bringen...
GetSvx3DLightControl()185     Svx3DLightControl& GetSvx3DLightControl() { return maLightControl; }
186 
187     // User Callback eintragen
SetUserInteractiveChangeCallback(Link aNew)188     void SetUserInteractiveChangeCallback(Link aNew) { maUserInteractiveChangeCallback = aNew; }
SetUserSelectionChangeCallback(Link aNew)189     void SetUserSelectionChangeCallback(Link aNew) { maUserSelectionChangeCallback = aNew; }
190 
191     virtual void KeyInput( const KeyEvent& rKEvt );
192     virtual void GetFocus();
193     virtual void LoseFocus();
194 
195 protected:
196 
197     DECL_LINK( InternalInteractiveChange, void*);
198     DECL_LINK( InternalSelectionChange, void*);
199     DECL_LINK( ScrollBarMove, void*);
200     DECL_LINK( ButtonPress, void*);
201 
202     // Lokale Parameter Initialisieren
203     void Init();
204 
205     void move( double fDeltaHor, double fDeltaVer );
206 };
207 
208 #endif // _SCH_DLGCTL3D_HXX
209 
210 //////////////////////////////////////////////////////////////////////////////
211 // eof
212