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