Branch data 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 : : #include "Stripe.hxx"
21 : : #include "CommonConverters.hxx"
22 : : #include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
23 : : #include <com/sun/star/drawing/DoubleSequence.hpp>
24 : : #include <basegfx/polygon/b3dpolygon.hxx>
25 : : #include <basegfx/polygon/b3dpolygontools.hxx>
26 : :
27 : : using namespace ::com::sun::star;
28 : :
29 : : //.............................................................................
30 : : namespace chart
31 : : {
32 : : //.............................................................................
33 : :
34 : 42 : Stripe::Stripe( const drawing::Position3D& rPoint1
35 : : , const drawing::Direction3D& rDirectionToPoint2
36 : : , const drawing::Direction3D& rDirectionToPoint4 )
37 : : : m_aPoint1(rPoint1)
38 : : , m_aPoint2(rPoint1+rDirectionToPoint2)
39 : 42 : , m_aPoint3(m_aPoint2+rDirectionToPoint4)
40 : : , m_aPoint4(rPoint1+rDirectionToPoint4)
41 : : , m_bInvertNormal(false)
42 : 42 : , m_bManualNormalSet(false)
43 : : {
44 : 42 : }
45 : :
46 : 792 : Stripe::Stripe( const drawing::Position3D& rPoint1
47 : : , const drawing::Position3D& rPoint2
48 : : , double fDepth )
49 : : : m_aPoint1(rPoint1)
50 : : , m_aPoint2(rPoint2)
51 : : , m_aPoint3(rPoint2)
52 : : , m_aPoint4(rPoint1)
53 : : , m_bInvertNormal(false)
54 : 792 : , m_bManualNormalSet(false)
55 : : {
56 : 792 : m_aPoint3.PositionZ += fDepth;
57 : 792 : m_aPoint4.PositionZ += fDepth;
58 : 792 : }
59 : :
60 : 0 : Stripe::Stripe( const drawing::Position3D& rPoint1
61 : : , const drawing::Position3D& rPoint2
62 : : , const drawing::Position3D& rPoint3
63 : : , const drawing::Position3D& rPoint4 )
64 : : : m_aPoint1(rPoint1)
65 : : , m_aPoint2(rPoint2)
66 : : , m_aPoint3(rPoint3)
67 : : , m_aPoint4(rPoint4)
68 : : , m_bInvertNormal(false)
69 : 0 : , m_bManualNormalSet(false)
70 : : {
71 : 0 : }
72 : :
73 : 0 : void Stripe::SetManualNormal( const drawing::Direction3D& rNormal )
74 : : {
75 : 0 : m_aManualNormal = rNormal;
76 : 0 : m_bManualNormalSet = true;
77 : 0 : }
78 : :
79 : 42 : void Stripe::InvertNormal( bool bInvertNormal )
80 : : {
81 : 42 : m_bInvertNormal = bInvertNormal;
82 : 42 : }
83 : :
84 : 438 : uno::Any Stripe::getPolyPolygonShape3D() const
85 : : {
86 [ + - ]: 438 : drawing::PolyPolygonShape3D aPP;
87 : :
88 [ + - ]: 438 : aPP.SequenceX.realloc(1);
89 [ + - ]: 438 : aPP.SequenceY.realloc(1);
90 [ + - ]: 438 : aPP.SequenceZ.realloc(1);
91 : :
92 [ + - ]: 438 : drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray();
93 [ + - ]: 438 : drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray();
94 [ + - ]: 438 : drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray();
95 : :
96 [ + - ]: 438 : pOuterSequenceX->realloc(4);
97 [ + - ]: 438 : pOuterSequenceY->realloc(4);
98 [ + - ]: 438 : pOuterSequenceZ->realloc(4);
99 : :
100 [ + - ]: 438 : double* pInnerSequenceX = pOuterSequenceX->getArray();
101 [ + - ]: 438 : double* pInnerSequenceY = pOuterSequenceY->getArray();
102 [ + - ]: 438 : double* pInnerSequenceZ = pOuterSequenceZ->getArray();
103 : :
104 : 438 : *pInnerSequenceX++ = m_aPoint1.PositionX;
105 : 438 : *pInnerSequenceY++ = m_aPoint1.PositionY;
106 : 438 : *pInnerSequenceZ++ = m_aPoint1.PositionZ;
107 : :
108 : 438 : *pInnerSequenceX++ = m_aPoint2.PositionX;
109 : 438 : *pInnerSequenceY++ = m_aPoint2.PositionY;
110 : 438 : *pInnerSequenceZ++ = m_aPoint2.PositionZ;
111 : :
112 : 438 : *pInnerSequenceX++ = m_aPoint3.PositionX;
113 : 438 : *pInnerSequenceY++ = m_aPoint3.PositionY;
114 : 438 : *pInnerSequenceZ++ = m_aPoint3.PositionZ;
115 : :
116 : 438 : *pInnerSequenceX++ = m_aPoint4.PositionX;
117 : 438 : *pInnerSequenceY++ = m_aPoint4.PositionY;
118 : 438 : *pInnerSequenceZ++ = m_aPoint4.PositionZ;
119 : :
120 [ + - ][ + - ]: 438 : return uno::Any( &aPP, ::getCppuType((const drawing::PolyPolygonShape3D*)0) );
121 : : }
122 : :
123 : 438 : drawing::Direction3D Stripe::getNormal() const
124 : : {
125 : 438 : drawing::Direction3D aRet(1.0,0.0,0.0);
126 : :
127 [ - + ]: 438 : if( m_bManualNormalSet )
128 : 0 : aRet = m_aManualNormal;
129 : : else
130 : : {
131 [ + - ]: 438 : ::basegfx::B3DPolygon aPolygon3D;
132 [ + - ][ + - ]: 438 : aPolygon3D.append(Position3DToB3DPoint( m_aPoint1 ));
133 [ + - ][ + - ]: 438 : aPolygon3D.append(Position3DToB3DPoint( m_aPoint2 ));
134 [ + - ][ + - ]: 438 : aPolygon3D.append(Position3DToB3DPoint( m_aPoint3 ));
135 [ + - ][ + - ]: 438 : aPolygon3D.append(Position3DToB3DPoint( m_aPoint4 ));
136 [ + - ]: 438 : ::basegfx::B3DVector aNormal(::basegfx::tools::getNormal(aPolygon3D));
137 [ + - ][ + - ]: 438 : aRet = B3DVectorToDirection3D(aNormal);
138 : : }
139 : :
140 [ + + ]: 438 : if( m_bInvertNormal )
141 : : {
142 : 42 : aRet.DirectionX *= -1.0;
143 : 42 : aRet.DirectionY *= -1.0;
144 : 42 : aRet.DirectionZ *= -1.0;
145 : : }
146 : 438 : return aRet;
147 : : }
148 : :
149 : 438 : uno::Any Stripe::getNormalsPolygon() const
150 : : {
151 [ + - ]: 438 : drawing::PolyPolygonShape3D aPP;
152 : :
153 [ + - ]: 438 : aPP.SequenceX.realloc(1);
154 [ + - ]: 438 : aPP.SequenceY.realloc(1);
155 [ + - ]: 438 : aPP.SequenceZ.realloc(1);
156 : :
157 [ + - ]: 438 : drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray();
158 [ + - ]: 438 : drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray();
159 [ + - ]: 438 : drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray();
160 : :
161 [ + - ]: 438 : pOuterSequenceX->realloc(4);
162 [ + - ]: 438 : pOuterSequenceY->realloc(4);
163 [ + - ]: 438 : pOuterSequenceZ->realloc(4);
164 : :
165 [ + - ]: 438 : double* pInnerSequenceX = pOuterSequenceX->getArray();
166 [ + - ]: 438 : double* pInnerSequenceY = pOuterSequenceY->getArray();
167 [ + - ]: 438 : double* pInnerSequenceZ = pOuterSequenceZ->getArray();
168 : :
169 [ + - ]: 438 : drawing::Direction3D aNormal( getNormal() );
170 : :
171 [ + + ]: 1752 : for(sal_Int32 nN=4; --nN; )
172 : : {
173 : 1314 : *pInnerSequenceX++ = aNormal.DirectionX;
174 : 1314 : *pInnerSequenceY++ = aNormal.DirectionY;
175 : 1314 : *pInnerSequenceZ++ = aNormal.DirectionZ;
176 : : }
177 [ + - ][ + - ]: 438 : return uno::Any( &aPP, ::getCppuType((const drawing::PolyPolygonShape3D*)0) );
178 : : }
179 : :
180 : 438 : uno::Any Stripe::getTexturePolygon( short nRotatedTexture ) const
181 : : {
182 [ + - ]: 438 : drawing::PolyPolygonShape3D aPP;
183 : :
184 [ + - ]: 438 : aPP.SequenceX.realloc(1);
185 [ + - ]: 438 : aPP.SequenceY.realloc(1);
186 [ + - ]: 438 : aPP.SequenceZ.realloc(1);
187 : :
188 [ + - ]: 438 : drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray();
189 [ + - ]: 438 : drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray();
190 [ + - ]: 438 : drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray();
191 : :
192 [ + - ]: 438 : pOuterSequenceX->realloc(4);
193 [ + - ]: 438 : pOuterSequenceY->realloc(4);
194 [ + - ]: 438 : pOuterSequenceZ->realloc(4);
195 : :
196 [ + - ]: 438 : double* pInnerSequenceX = pOuterSequenceX->getArray();
197 [ + - ]: 438 : double* pInnerSequenceY = pOuterSequenceY->getArray();
198 [ + - ]: 438 : double* pInnerSequenceZ = pOuterSequenceZ->getArray();
199 : :
200 [ + + ]: 438 : if( nRotatedTexture==0 )
201 : : {
202 : 28 : *pInnerSequenceX++ = 0.0;
203 : 28 : *pInnerSequenceY++ = 0.0;
204 : 28 : *pInnerSequenceZ++ = 0.0;
205 : :
206 : 28 : *pInnerSequenceX++ = 0.0;
207 : 28 : *pInnerSequenceY++ = 1.0;
208 : 28 : *pInnerSequenceZ++ = 0.0;
209 : :
210 : 28 : *pInnerSequenceX++ = 1.0;
211 : 28 : *pInnerSequenceY++ = 1.0;
212 : 28 : *pInnerSequenceZ++ = 0.0;
213 : :
214 : 28 : *pInnerSequenceX++ = 1.0;
215 : 28 : *pInnerSequenceY++ = 0.0;
216 : 28 : *pInnerSequenceZ++ = 0.0;
217 : : }
218 [ + - ]: 410 : else if( nRotatedTexture==1 )
219 : : {
220 : 410 : *pInnerSequenceX++ = 1.0;
221 : 410 : *pInnerSequenceY++ = 0.0;
222 : 410 : *pInnerSequenceZ++ = 0.0;
223 : :
224 : 410 : *pInnerSequenceX++ = 0.0;
225 : 410 : *pInnerSequenceY++ = 0.0;
226 : 410 : *pInnerSequenceZ++ = 0.0;
227 : :
228 : 410 : *pInnerSequenceX++ = 0.0;
229 : 410 : *pInnerSequenceY++ = 1.0;
230 : 410 : *pInnerSequenceZ++ = 0.0;
231 : :
232 : 410 : *pInnerSequenceX++ = 1.0;
233 : 410 : *pInnerSequenceY++ = 1.0;
234 : 410 : *pInnerSequenceZ++ = 0.0;
235 : : }
236 [ # # ]: 0 : else if( nRotatedTexture==2 )
237 : : {
238 : 0 : *pInnerSequenceX++ = 1.0;
239 : 0 : *pInnerSequenceY++ = 1.0;
240 : 0 : *pInnerSequenceZ++ = 0.0;
241 : :
242 : 0 : *pInnerSequenceX++ = 1.0;
243 : 0 : *pInnerSequenceY++ = 0.0;
244 : 0 : *pInnerSequenceZ++ = 0.0;
245 : :
246 : 0 : *pInnerSequenceX++ = 0.0;
247 : 0 : *pInnerSequenceY++ = 0.0;
248 : 0 : *pInnerSequenceZ++ = 0.0;
249 : :
250 : 0 : *pInnerSequenceX++ = 0.0;
251 : 0 : *pInnerSequenceY++ = 1.0;
252 : 0 : *pInnerSequenceZ++ = 0.0;
253 : : }
254 [ # # ]: 0 : else if( nRotatedTexture==3 )
255 : : {
256 : 0 : *pInnerSequenceX++ = 0.0;
257 : 0 : *pInnerSequenceY++ = 1.0;
258 : 0 : *pInnerSequenceZ++ = 0.0;
259 : :
260 : 0 : *pInnerSequenceX++ = 1.0;
261 : 0 : *pInnerSequenceY++ = 1.0;
262 : 0 : *pInnerSequenceZ++ = 0.0;
263 : :
264 : 0 : *pInnerSequenceX++ = 1.0;
265 : 0 : *pInnerSequenceY++ = 0.0;
266 : 0 : *pInnerSequenceZ++ = 0.0;
267 : :
268 : 0 : *pInnerSequenceX++ = 0.0;
269 : 0 : *pInnerSequenceY++ = 0.0;
270 : 0 : *pInnerSequenceZ++ = 0.0;
271 : : }
272 [ # # ]: 0 : else if( nRotatedTexture==4 )
273 : : {
274 : 0 : *pInnerSequenceX++ = 1.0;
275 : 0 : *pInnerSequenceY++ = 0.0;
276 : 0 : *pInnerSequenceZ++ = 0.0;
277 : :
278 : 0 : *pInnerSequenceX++ = 1.0;
279 : 0 : *pInnerSequenceY++ = 1.0;
280 : 0 : *pInnerSequenceZ++ = 0.0;
281 : :
282 : 0 : *pInnerSequenceX++ = 0.0;
283 : 0 : *pInnerSequenceY++ = 1.0;
284 : 0 : *pInnerSequenceZ++ = 0.0;
285 : :
286 : 0 : *pInnerSequenceX++ = 0.0;
287 : 0 : *pInnerSequenceY++ = 0.0;
288 : 0 : *pInnerSequenceZ++ = 0.0;
289 : : }
290 [ # # ]: 0 : else if( nRotatedTexture==5 )
291 : : {
292 : 0 : *pInnerSequenceX++ = 0.0;
293 : 0 : *pInnerSequenceY++ = 0.0;
294 : 0 : *pInnerSequenceZ++ = 0.0;
295 : :
296 : 0 : *pInnerSequenceX++ = 1.0;
297 : 0 : *pInnerSequenceY++ = 0.0;
298 : 0 : *pInnerSequenceZ++ = 0.0;
299 : :
300 : 0 : *pInnerSequenceX++ = 1.0;
301 : 0 : *pInnerSequenceY++ = 1.0;
302 : 0 : *pInnerSequenceZ++ = 0.0;
303 : :
304 : 0 : *pInnerSequenceX++ = 0.0;
305 : 0 : *pInnerSequenceY++ = 1.0;
306 : 0 : *pInnerSequenceZ++ = 0.0;
307 : : }
308 [ # # ]: 0 : else if( nRotatedTexture==6 )
309 : : {
310 : 0 : *pInnerSequenceX++ = 0.0;
311 : 0 : *pInnerSequenceY++ = 1.0;
312 : 0 : *pInnerSequenceZ++ = 0.0;
313 : :
314 : 0 : *pInnerSequenceX++ = 0.0;
315 : 0 : *pInnerSequenceY++ = 0.0;
316 : 0 : *pInnerSequenceZ++ = 0.0;
317 : :
318 : 0 : *pInnerSequenceX++ = 1.0;
319 : 0 : *pInnerSequenceY++ = 0.0;
320 : 0 : *pInnerSequenceZ++ = 0.0;
321 : :
322 : 0 : *pInnerSequenceX++ = 1.0;
323 : 0 : *pInnerSequenceY++ = 1.0;
324 : 0 : *pInnerSequenceZ++ = 0.0;
325 : : }
326 [ # # ]: 0 : else if( nRotatedTexture==7 )
327 : : {
328 : 0 : *pInnerSequenceX++ = 1.0;
329 : 0 : *pInnerSequenceY++ = 1.0;
330 : 0 : *pInnerSequenceZ++ = 0.0;
331 : :
332 : 0 : *pInnerSequenceX++ = 0.0;
333 : 0 : *pInnerSequenceY++ = 1.0;
334 : 0 : *pInnerSequenceZ++ = 0.0;
335 : :
336 : 0 : *pInnerSequenceX++ = 0.0;
337 : 0 : *pInnerSequenceY++ = 0.0;
338 : 0 : *pInnerSequenceZ++ = 0.0;
339 : :
340 : 0 : *pInnerSequenceX++ = 1.0;
341 : 0 : *pInnerSequenceY++ = 0.0;
342 : 0 : *pInnerSequenceZ++ = 0.0;
343 : : }
344 : :
345 [ + - ][ + - ]: 438 : return uno::Any( &aPP, ::getCppuType((const drawing::PolyPolygonShape3D*)0) );
346 : : }
347 : :
348 : : //.............................................................................
349 : : } //namespace chart
350 : : //.............................................................................
351 : :
352 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|