xref: /trunk/main/svx/inc/svx/view3d.hxx (revision 3334a7e6)
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 _E3D_VIEW3D_HXX
25 #define _E3D_VIEW3D_HXX
26 
27 #include <svx/svdview.hxx>
28 #include <svx/def3d.hxx>
29 #include <svx/deflt3d.hxx>
30 #include <basegfx/point/b2dpoint.hxx>
31 #include "svx/svxdllapi.h"
32 
33 //************************************************************
34 //   Vorausdeklarationen
35 //************************************************************
36 
37 class E3dObject;
38 class E3dScene;
39 class SceneList;
40 class Impl3DMirrorConstructOverlay;
41 
42 /*************************************************************************
43 |*
44 |* Ableitung von SdrView zur Bearbeitung von 3D-Objekten
45 |*
46 \************************************************************************/
47 
48 class SVX_DLLPUBLIC E3dView : public SdrView
49 {
50 protected:
51 	E3dDefaultAttributes		a3DDefaultAttr;
52 	MouseEvent					aMouseEvent;					// Die Parameter der letzten Events (Mouse, Keyboard)
53 	Color						aDefaultLightColor;             // dito mit den Farben
54 	Color						aDefaultAmbientColor;
55 
56 	double						fDefaultScaleX;                 // Verzerrungen
57 	double						fDefaultScaleY;
58 	double						fDefaultScaleZ;
59 	double						fDefaultRotateX;                // und Drehungen
60 	double						fDefaultRotateY;
61 	double						fDefaultRotateZ;
62 	double						fDefaultExtrusionDeepth;        // Extrusionstiefe
63 	double						fDefaultLightIntensity;         // Intensitaeten der beiden (notwendigen) Licht-
64 	double						fDefaultAmbientIntensity;       // quellen
65 	long						nHDefaultSegments;              // wieviele HSegmente braucht mein Lathe-Ojekt
66 	long						nVDefaultSegments;              // wieviele VSegmente braucht mein Lathe-Ojekt
67 
68 	E3dDragConstraint			eDragConstraint;
69 
70 	// Migrate selections
71 	Impl3DMirrorConstructOverlay*					mpMirrorOverlay;
72 
73 	sal_Bool						bDoubleSided;
74 
75 	void InitView();
76 
77 	void ImpCreate3DObject(E3dScene* pScene, SdrObject* pObj, sal_Bool bExtrude, double fDepth, basegfx::B2DHomMatrix& rLatheMat);
78 	void ImpCreateSingle3DObjectFlat(E3dScene* pScene, SdrObject* pObj, sal_Bool bExtrude, double fDepth, basegfx::B2DHomMatrix& rLatheMat);
79 	void ImpChangeSomeAttributesFor3DConversion(SdrObject* pObj);
80 	void ImpChangeSomeAttributesFor3DConversion2(SdrObject* pObj);
81 
82 	void InitScene(E3dScene* pScene, double fW, double fH, double fCamZ);
83 	void ImpIsConvertTo3DPossible(SdrObject* pObj, sal_Bool& rAny3D, sal_Bool& rGroupSelected) const;
84 	void BreakSingle3DObj(E3dObject* pObj);
85 
86 public:
87 	TYPEINFO();
88 	E3dView(SdrModel* pModel, OutputDevice* pOut = 0L);
89 	virtual ~E3dView();
90 
91 	// Alle markierten Objekte auf dem angegebenen OutputDevice ausgeben.
92 	virtual void DrawMarkedObj(OutputDevice& rOut) const;
93 
94 	// Zugriff auf die Default-Attribute
Get3DDefaultAttributes()95 	E3dDefaultAttributes& Get3DDefaultAttributes() { return a3DDefaultAttr; }
96 	virtual sal_Bool BegDragObj(const Point& rPnt, OutputDevice* pOut = NULL, SdrHdl* pHdl = NULL, short nMinMov = -3, SdrDragMethod* pForcedMeth = NULL);
97 	virtual	void CheckPossibilities();
98 
99 	// Event setzen/rausruecken
SetMouseEvent(const MouseEvent & rNew)100 	void SetMouseEvent(const MouseEvent& rNew) { aMouseEvent = rNew; }
GetMouseEvent()101 	const MouseEvent& GetMouseEvent() { return aMouseEvent; }
102 
103 	// Model holen ueberladen, da bei einzelnen 3D Objekten noch eine Szene
104 	// untergeschoben werden muss
105 	virtual SdrModel* GetMarkedObjModel() const;
106 
107 	// Bei Paste muss - falls in eine Scene eingefuegt wird - die
108 	// Objekte der Szene eingefuegt werden, die Szene selbst aber nicht
109 	using SdrView::Paste;
110 	virtual sal_Bool Paste(const SdrModel& rMod, const Point& rPos, SdrObjList* pLst=NULL, sal_uInt32 nOptions=0);
111 
112 	// #83403# Service routine used from local Clone() and from SdrCreateView::EndCreateObj(...)
113 	sal_Bool ImpCloneAll3DObjectsToDestScene(E3dScene* pSrcScene, E3dScene* pDstScene, Point aOffset);
114 
115 	sal_Bool HasMarkedScene();
116 	E3dScene* GetMarkedScene();
117 
118 	sal_Bool IsConvertTo3DObjPossible() const;
119 	void ConvertMarkedObjTo3D(sal_Bool bExtrude=sal_True, basegfx::B2DPoint aPnt1 = basegfx::B2DPoint(0.0, 0.0), basegfx::B2DPoint aPnt2 = basegfx::B2DPoint(0.0, 1.0));
120 
121 	// Nachtraeglichhe Korrekturmoeglichkeit um alle Extrudes in einer
122 	// bestimmten Tiefensortierung anzulegen
123 	void DoDepthArrange(E3dScene* pScene, double fDepth);
124 	void ConvertMarkedToPolyObj(sal_Bool bLineToArea);
125 	E3dScene* SetCurrent3DObj(E3dObject* p3DObj);
126 	void Start3DCreation();
127 
128 	// migration of overlay
Is3DRotationCreationActive() const129 	sal_Bool Is3DRotationCreationActive() const { return (0L != mpMirrorOverlay); }
130 
131 	virtual void MovAction(const Point& rPnt);
132 	void End3DCreation(sal_Bool bUseDefaultValuesForMirrorAxes=sal_False);
133 	void ResetCreationActive();
134 
135 	double GetDefaultCamPosZ();
136 
DefaultScaleX()137 	double &DefaultScaleX ()
138 	{
139 		return fDefaultScaleX;
140 	}
141 
DefaultScaleX() const142 	double DefaultScaleX () const
143 	{
144 		return fDefaultScaleX;
145 	}
146 
DefaultScaleY()147 	double &DefaultScaleY ()
148 	{
149 		return fDefaultScaleY;
150 	}
151 
DefaultScaleY() const152 	double DefaultScaleY () const
153 	{
154 		return fDefaultScaleY;
155 	}
156 
DefaultScaleZ()157 	double &DefaultScaleZ ()
158 	{
159 		return fDefaultScaleZ;
160 	}
161 
DefaultScaleZ() const162 	double DefaultScaleZ () const
163 	{
164 		return fDefaultScaleZ;
165 	}
166 
DefaultRotateX()167 	double &DefaultRotateX ()
168 	{
169 		return fDefaultRotateX;
170 	}
171 
DefaultRotateX() const172 	double DefaultRotateX () const
173 	{
174 		return fDefaultRotateX;
175 	}
176 
DefaultRotateY()177 	double &DefaultRotateY ()
178 	{
179 		return fDefaultRotateY;
180 	}
181 
DefaultRotateY() const182 	double DefaultRotateY () const
183 	{
184 		return fDefaultRotateY;
185 	}
186 
DefaultRotateZ()187 	double &DefaultRotateZ ()
188 	{
189 		return fDefaultRotateZ;
190 	}
191 
DefaultRotateZ() const192 	double DefaultRotateZ () const
193 	{
194 		return fDefaultRotateZ;
195 	}
196 
DefaultExtrusionDeepth()197 	double &DefaultExtrusionDeepth ()
198 	{
199 		return fDefaultExtrusionDeepth;
200 	}
201 
DefaultExtrusionDeepth() const202 	double DefaultExtrusionDeepth () const
203 	{
204 		return fDefaultExtrusionDeepth;
205 	}
206 
207 	double GetDefaultCamFocal();
208 
DefaultLightIntensity()209 	double &DefaultLightIntensity ()
210 	{
211 		return fDefaultLightIntensity;
212 	}
213 
DefaultLightIntensity() const214 	double DefaultLightIntensity () const
215 	{
216 		return fDefaultLightIntensity;
217 	}
218 
DefaultAmbientIntensity()219 	double &DefaultAmbientIntensity ()
220 	{
221 		return fDefaultAmbientIntensity;
222 	}
223 
DefaultAmbientIntensity() const224 	double DefaultAmbientIntensity () const
225 	{
226 		return fDefaultAmbientIntensity;
227 	}
228 
DefaultLightColor() const229 	const Color &DefaultLightColor () const
230 	{
231 		return aDefaultLightColor;
232 	}
233 
DefaultLightColor()234 	Color DefaultLightColor ()
235 	{
236 		return aDefaultLightColor;
237 	}
238 
DefaultAmbientColor() const239 	const Color &DefaultAmbientColor () const
240 	{
241 		return aDefaultAmbientColor;
242 	}
243 
DefaultAmbientColor()244 	Color DefaultAmbientColor ()
245 	{
246 		return aDefaultAmbientColor;
247 	}
248 
GetHDefaultSegments() const249 	long GetHDefaultSegments() const { return nHDefaultSegments; }
SetHDefaultSegments(long nSegs)250 	void SetHDefaultSegments(long nSegs) { nHDefaultSegments = nSegs; }
251 
GetVDefaultSegments() const252 	long GetVDefaultSegments() const { return nVDefaultSegments; }
SetVDefaultSegments(long nSegs)253 	void SetVDefaultSegments(long nSegs) { nVDefaultSegments = nSegs; }
254 
255 	sal_Bool IsBreak3DObjPossible() const;
256 	void Break3DObj();
257 
DoubleSided() const258 	sal_Bool DoubleSided () const
259 	{
260 		return bDoubleSided;
261 	}
262 
DoubleSided()263 	sal_Bool &DoubleSided ()
264 	{
265 		return bDoubleSided;
266 	}
267 
268 	void MergeScenes();
269 	SfxItemSet Get3DAttributes(E3dScene* pInScene = NULL, sal_Bool bOnly3DAttr=sal_False) const;
270 	void Set3DAttributes(const SfxItemSet& rAttr, E3dScene* pInScene = NULL, sal_Bool bOnly3DAttr=sal_False);
271 };
272 
273 #endif			// _E3D_VIEW3D_HXX
274