LibreOffice Module chart2 (master) 1
ThreeDHelper.cxx
Go to the documentation of this file.
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 <ThreeDHelper.hxx>
21#include <Diagram.hxx>
22#include <DiagramHelper.hxx>
23#include <ChartTypeHelper.hxx>
24#include <ChartType.hxx>
25#include <BaseGFXHelper.hxx>
26#include <DataSeries.hxx>
27#include <DataSeriesHelper.hxx>
28#include <defines.hxx>
29
30#include <editeng/unoprnms.hxx>
31#include <com/sun/star/drawing/LineStyle.hpp>
32#include <com/sun/star/drawing/ShadeMode.hpp>
34#include <tools/helpers.hxx>
35#include <rtl/math.hxx>
36
37namespace chart
38{
39using namespace ::com::sun::star;
40using namespace ::com::sun::star::chart2;
41
42using ::com::sun::star::uno::Reference;
43using ::rtl::math::cos;
44using ::rtl::math::sin;
45using ::rtl::math::tan;
46
47namespace
48{
49
51{
52 if( xDiagram.is() )
53 {
54 bool bRightAngledAxes = false;
55 xDiagram->getPropertyValue( "RightAngledAxes") >>= bRightAngledAxes;
56 if(bRightAngledAxes)
57 {
59 xDiagram->getChartTypeByIndex( 0 ) ) )
60 {
61 return true;
62 }
63 }
64 }
65 return false;
66}
67
68} //end anonymous namespace
69
70drawing::CameraGeometry ThreeDHelper::getDefaultCameraGeometry( bool bPie )
71{
72 // ViewReferencePoint (Point on the View plane)
73 drawing::Position3D vrp(17634.6218373783, 10271.4823817647, 24594.8639082739);
74 // ViewPlaneNormal (Normal to the View Plane)
75 drawing::Direction3D vpn(0.416199821709347, 0.173649045905254, 0.892537795986984);
76 // ViewUpVector (determines the v-axis direction on the view plane as
77 // projection of VUP parallel to VPN onto th view pane)
78 drawing::Direction3D vup(-0.0733876362771618, 0.984807599917971, -0.157379306090273);
79
80 if( bPie )
81 {
82 vrp = drawing::Position3D( 0.0, 0.0, 87591.2408759124 );//--> 5 percent perspective
83 vpn = drawing::Direction3D( 0.0, 0.0, 1.0 );
84 vup = drawing::Direction3D( 0.0, 1.0, 0.0 );
85 }
86
87 return drawing::CameraGeometry( vrp, vpn, vup );
88}
89
90namespace
91{
92void lcl_ensureIntervalMinus1To1( double& rSinOrCos )
93{
94 if (rSinOrCos < -1.0)
95 rSinOrCos = -1.0;
96 else if (rSinOrCos > 1.0)
97 rSinOrCos = 1.0;
98}
99
100bool lcl_isSinZero( double fAngleRad )
101{
102 return ::basegfx::fTools::equalZero( sin(fAngleRad), 0.0000001 );
103}
104bool lcl_isCosZero( double fAngleRad )
105{
106 return ::basegfx::fTools::equalZero( cos(fAngleRad), 0.0000001 );
107}
108
109}
110
112 sal_Int32 nElevationDeg, sal_Int32 nRotationDeg,
113 double& rfXAngleRad, double& rfYAngleRad, double& rfZAngleRad)
114{
115 // for a description of the algorithm see issue 72994
116 //https://bz.apache.org/ooo/show_bug.cgi?id=72994
117 //https://bz.apache.org/ooo/attachment.cgi?id=50608
118
119 nElevationDeg = NormAngle360(nElevationDeg);
120 nRotationDeg = NormAngle360(nRotationDeg);
121
122 double& x = rfXAngleRad;
123 double& y = rfYAngleRad;
124 double& z = rfZAngleRad;
125
126 double E = basegfx::deg2rad(nElevationDeg); //elevation in Rad
127 double R = basegfx::deg2rad(nRotationDeg); //rotation in Rad
128
129 if( (nRotationDeg == 0 || nRotationDeg == 180 )
130 && ( nElevationDeg == 90 || nElevationDeg == 270 ) )
131 {
132 //sR==0 && cE==0
133 z = 0.0;
134 //element 23
135 double f23 = cos(R)*sin(E);
136 if(f23>0)
137 x = M_PI_2;
138 else
139 x = -M_PI_2;
140 y = R;
141 }
142 else if( ( nRotationDeg == 90 || nRotationDeg == 270 )
143 && ( nElevationDeg == 90 || nElevationDeg == 270 ) )
144 {
145 //cR==0 && cE==0
146 z = M_PI_2;
147 if( sin(R)>0 )
148 x = M_PI_2;
149 else
150 x = -M_PI_2;
151
152 if( (sin(R)*sin(E))>0 )
153 y = 0.0;
154 else
155 y = M_PI;
156 }
157 else if( (nRotationDeg == 0 || nRotationDeg == 180 )
158 && ( nElevationDeg == 0 || nElevationDeg == 180 ) )
159 {
160 //sR==0 && sE==0
161 z = 0.0;
162 y = R;
163 x = E;
164 }
165 else if( ( nRotationDeg == 90 || nRotationDeg == 270 )
166 && ( nElevationDeg == 0 || nElevationDeg == 180 ) )
167 {
168 //cR==0 && sE==0
169 z = 0.0;
170
171 if( (sin(R)/cos(E))>0 )
172 y = M_PI_2;
173 else
174 y = -M_PI_2;
175
176 if( (cos(E))>0 )
177 x = 0;
178 else
179 x = M_PI;
180 }
181 else if ( nElevationDeg == 0 || nElevationDeg == 180 )
182 {
183 //sR!=0 cR!=0 sE==0
184 z = 0.0;
185 x = E;
186 y = R;
187 //use element 13 for sign
188 if((cos(x)*sin(y)*sin(R))<0.0)
189 y *= -1.0;
190 }
191 else if ( nElevationDeg == 90 || nElevationDeg == 270 )
192 {
193 //sR!=0 cR!=0 cE==0
194 //element 12 + 22 --> y=0 or M_PI and x=+-M_PI/2
195 //-->element 13/23:
196 z = atan(sin(R)/(cos(R)*sin(E)));
197 //use element 13 for sign for x
198 if( (sin(R)*sin(z))>0.0 )
199 x = M_PI_2;
200 else
201 x = -M_PI_2;
202 //use element 21 for y
203 if( (sin(R)*sin(E)*sin(z))>0.0)
204 y = 0.0;
205 else
206 y = M_PI;
207 }
208 else if ( nRotationDeg == 0 || nRotationDeg == 180 )
209 {
210 //sE!=0 cE!=0 sR==0
211 z = 0.0;
212 x = E;
213 y = R;
214 double f23 = cos(R)*sin(E);
215 if( (f23 * sin(x)) < 0.0 )
216 x *= -1.0; //todo ??
217 }
218 else if (nRotationDeg == 90 || nRotationDeg == 270)
219 {
220 //sE!=0 cE!=0 cR==0
221 //z = +- M_PI/2;
222 //x = +- M_PI/2;
223 z = M_PI_2;
224 x = M_PI_2;
225 double sR = sin(R);
226 if( sR<0.0 )
227 x *= -1.0; //different signs for x and z
228
229 //use element 21:
230 double cy = sR*sin(E)/sin(z);
231 lcl_ensureIntervalMinus1To1(cy);
232 y = acos(cy);
233
234 //use element 22 for sign:
235 if( (sin(x)*sin(y)*sin(z)*cos(E))<0.0)
236 y *= -1.0;
237 }
238 else
239 {
240 z = atan(tan(R) * sin(E));
241 if(cos(z)==0.0)
242 {
243 OSL_FAIL("calculation error in ThreeDHelper::convertElevationRotationDegToXYZAngleRad");
244 return;
245 }
246 double cy = cos(R)/cos(z);
247 lcl_ensureIntervalMinus1To1(cy);
248 y = acos(cy);
249
250 //element 12 in 23
251 double fDenominator = cos(z)*(1.0-pow(sin(y),2));
252 if(fDenominator==0.0)
253 {
254 OSL_FAIL("calculation error in ThreeDHelper::convertElevationRotationDegToXYZAngleRad");
255 return;
256 }
257 double sx = cos(R)*sin(E)/fDenominator;
258 lcl_ensureIntervalMinus1To1(sx);
259 x = asin( sx );
260
261 //use element 13 for sign:
262 double f13a = cos(x)*cos(z)*sin(y);
263 double f13b = sin(R)-sx*sin(z);
264 if( (f13b*f13a)<0.0 )
265 {
266 //change x or y
267 //use element 22 for further investigations:
268 //try
269 y *= -1;
270 double f22a = cos(x)*cos(z);
271 double f22b = cos(E)-(sx*sin(y)*sin(z));
272 if( (f22a*f22b)<0.0 )
273 {
274 y *= -1;
275 x=(M_PI-x);
276 }
277 }
278 else
279 {
280 //change nothing or both
281 //use element 22 for further investigations:
282 double f22a = cos(x)*cos(z);
283 double f22b = cos(E)-(sx*sin(y)*sin(z));
284 if( (f22a*f22b)<0.0 )
285 {
286 y *= -1;
287 x=(M_PI-x);
288 }
289 }
290 }
291}
292
294 sal_Int32& rnElevationDeg, sal_Int32& rnRotationDeg,
295 double fXRad, double fYRad, double fZRad)
296{
297 // for a description of the algorithm see issue 72994
298 //https://bz.apache.org/ooo/show_bug.cgi?id=72994
299 //https://bz.apache.org/ooo/attachment.cgi?id=50608
300
301 double R = 0.0; //Rotation in Rad
302 double E = 0.0; //Elevation in Rad
303
304 double& x = fXRad;
305 double& y = fYRad;
306 double& z = fZRad;
307
308 double f11 = cos(y)*cos(z);
309
310 if( lcl_isSinZero(y) )
311 {
312 //siny == 0
313
314 if( lcl_isCosZero(x) )
315 {
316 //siny == 0 && cosx == 0
317
318 if( lcl_isSinZero(z) )
319 {
320 //siny == 0 && cosx == 0 && sinz == 0
321 //example: x=+-90 y=0oder180 z=0(oder180)
322
323 //element 13+11
324 if( f11 > 0 )
325 R = 0.0;
326 else
327 R = M_PI;
328
329 //element 23
330 double f23 = cos(z)*sin(x) / cos(R);
331 if( f23 > 0 )
332 E = M_PI_2;
333 else
334 E = -M_PI_2;
335 }
336 else if( lcl_isCosZero(z) )
337 {
338 //siny == 0 && cosx == 0 && cosz == 0
339 //example: x=+-90 y=0oder180 z=+-90
340
341 double f13 = sin(x)*sin(z);
342 //element 13+11
343 if( f13 > 0 )
344 R = M_PI_2;
345 else
346 R = -M_PI_2;
347
348 //element 21
349 double f21 = cos(y)*sin(z) / sin(R);
350 if( f21 > 0 )
351 E = M_PI_2;
352 else
353 E = -M_PI_2;
354 }
355 else
356 {
357 //siny == 0 && cosx == 0 && cosz != 0 && sinz != 0
358 //element 11 && 13
359 double f13 = sin(x)*sin(z);
360 R = atan( f13/f11 );
361
362 if(f11<0)
363 R+=M_PI;
364
365 //element 23
366 double f23 = cos(z)*sin(x);
367 if( f23/cos(R) > 0 )
368 E = M_PI_2;
369 else
370 E = -M_PI_2;
371 }
372 }
373 else if( lcl_isSinZero(x) )
374 {
375 //sinY==0 sinX==0
376 //element 13+11
377 if( f11 > 0 )
378 R = 0.0;
379 else
380 R = M_PI;
381
382 double f22 = cos(x)*cos(z);
383 if( f22 > 0 )
384 E = 0.0;
385 else
386 E = M_PI;
387 }
388 else if( lcl_isSinZero(z) )
389 {
390 //sinY==0 sinZ==0 sinx!=0 cosx!=0
391 //element 13+11
392 if( f11 > 0 )
393 R = 0.0;
394 else
395 R = M_PI;
396
397 //element 22 && 23
398 double f22 = cos(x)*cos(z);
399 double f23 = cos(z)*sin(x);
400 E = atan( f23/(f22*cos(R)) );
401 if( (f22*cos(E))<0 )
402 E+=M_PI;
403 }
404 else if( lcl_isCosZero(z) )
405 {
406 //sinY == 0 && cosZ == 0 && cosx != 0 && sinx != 0
407 double f13 = sin(x)*sin(z);
408 //element 13+11
409 if( f13 > 0 )
410 R = M_PI_2;
411 else
412 R = -M_PI_2;
413
414 //element 21+22
415 double f21 = cos(y)*sin(z);
416 if( f21/sin(R) > 0 )
417 E = M_PI_2;
418 else
419 E = -M_PI_2;
420 }
421 else
422 {
423 //sinY == 0 && all other !=0
424 double f13 = sin(x)*sin(z);
425 R = atan( f13/f11 );
426 if( (f11*cos(R))<0.0 )
427 R+=M_PI;
428
429 double f22 = cos(x)*cos(z);
430 if( !lcl_isCosZero(R) )
431 E = atan( cos(z)*sin(x) /( f22*cos(R) ) );
432 else
433 E = atan( cos(y)*sin(z) /( f22*sin(R) ) );
434 if( (f22*cos(E))<0 )
435 E+=M_PI;
436 }
437 }
438 else if( lcl_isCosZero(y) )
439 {
440 //cosY==0
441
442 double f13 = sin(x)*sin(z)+cos(x)*cos(z)*sin(y);
443 if( f13 >= 0 )
444 R = M_PI_2;
445 else
446 R = -M_PI_2;
447
448 double f22 = cos(x)*cos(z)+sin(x)*sin(y)*sin(z);
449 if( f22 >= 0 )
450 E = 0.0;
451 else
452 E = M_PI;
453 }
454 else if( lcl_isSinZero(x) )
455 {
456 //cosY!=0 sinY!=0 sinX=0
457 if( lcl_isSinZero(z) )
458 {
459 //cosY!=0 sinY!=0 sinX=0 sinZ=0
460 double f13 = cos(x)*cos(z)*sin(y);
461 R = atan( f13/f11 );
462 //R = asin(f13);
463 if( f11<0 )
464 R+=M_PI;
465
466 double f22 = cos(x)*cos(z);
467 if( f22>0 )
468 E = 0.0;
469 else
470 E = M_PI;
471 }
472 else if( lcl_isCosZero(z) )
473 {
474 //cosY!=0 sinY!=0 sinX=0 cosZ=0
475 R = x;
476 E = y;//or -y
477 //use 23 for 'signs'
478 double f23 = -1.0*cos(x)*sin(y)*sin(z);
479 if( (f23*cos(R)*sin(E))<0.0 )
480 {
481 //change R or E
482 E = -y;
483 }
484 }
485 else
486 {
487 //cosY!=0 sinY!=0 sinX=0 sinZ!=0 cosZ!=0
488 double f13 = cos(x)*cos(z)*sin(y);
489 R = atan( f13/f11 );
490
491 if( f11<0 )
492 R+=M_PI;
493
494 double f21 = cos(y)*sin(z);
495 double f22 = cos(x)*cos(z);
496 E = atan(f21/(f22*sin(R)) );
497
498 if( (f22*cos(E))<0.0 )
499 E+=M_PI;
500 }
501 }
502 else if( lcl_isCosZero(x) )
503 {
504 //cosY!=0 sinY!=0 cosX=0
505
506 if( lcl_isSinZero(z) )
507 {
508 //cosY!=0 sinY!=0 cosX=0 sinZ=0
509 R=0;//13 -> R=0 or M_PI
510 if( f11<0.0 )
511 R=M_PI;
512 E=M_PI_2;//22 -> E=+-M_PI/2
513 //use element 11 and 23 for sign
514 double f23 = cos(z)*sin(x);
515 if( (f11*f23*sin(E))<0.0 )
516 E=-M_PI_2;
517 }
518 else if( lcl_isCosZero(z) )
519 {
520 //cosY!=0 sinY!=0 cosX=0 cosZ=0
521 //element 11 & 13:
522 if( (sin(x)*sin(z))>0.0 )
523 R=M_PI_2;
524 else
525 R=-M_PI_2;
526 //element 22:
527 E=acos( sin(x)*sin(y)*sin(z));
528 //use element 21 for sign:
529 if( (cos(y)*sin(z)*sin(R)*sin(E))<0.0 )
530 E*=-1.0;
531 }
532 else
533 {
534 //cosY!=0 sinY!=0 cosX=0 sinZ!=0 cosZ!=0
535 //element 13/11
536 R = atan( sin(x)*sin(z)/(cos(y)*cos(z)) );
537 //use 13 for 'sign'
538 if( (sin(x)*sin(z))<0.0 )
539 R += M_PI;
540 //element 22
541 E = acos(sin(x)*sin(y)*sin(z) );
542 //use 21 for sign
543 if( (cos(y)*sin(z)*sin(R)*sin(E))<0.0 )
544 E*=-1.0;
545 }
546 }
547 else if( lcl_isSinZero(z) )
548 {
549 //cosY!=0 sinY!=0 sinX!=0 cosX!=0 sinZ=0
550 //element 11
551 R=y;
552 //use element 13 for sign
553 if( (cos(x)*cos(z)*sin(y)*sin(R))<0.0 )
554 R*=-1.0;
555 //element 22
556 E = acos( cos(x)*cos(z) );
557 //use element 23 for sign
558 if( (cos(z)*sin(x)*cos(R)*sin(E))<0.0 )
559 E*=-1.0;
560 }
561 else if( lcl_isCosZero(z) )
562 {
563 //cosY!=0 sinY!=0 sinX!=0 cosX!=0 cosZ=0
564 //element 21/23
565 R=atan(-cos(y)/(cos(x)*sin(y)));
566 //use element 13 for 'sign'
567 if( (sin(x)*sin(z)*sin(R))<0.0 )
568 R+=M_PI;
569 //element 21/22
570 E=atan( cos(y)*sin(z)/(sin(R)*sin(x)*sin(y)*sin(z)) );
571 //use element 23 for 'sign'
572 if( (-cos(x)*sin(y)*sin(z)*cos(R)*sin(E))<0.0 )
573 E+=M_PI;
574 }
575 else
576 {
577 //cosY!=0 sinY!=0 sinX!=0 cosX!=0 sinZ!=0 cosZ!=0
578 //13/11:
579 double f13 = sin(x)*sin(z)+cos(x)*cos(z)*sin(y);
580 R = atan( f13/ f11 );
581 if(f11<0.0)
582 R+=M_PI;
583 double f22 = cos(x)*cos(z)+sin(x)*sin(y)*sin(z);
584 double f23 = cos(x)*sin(y)*sin(z)-cos(z)*sin(x);
585 //23/22:
586 E = atan( -1.0*f23/(f22*cos(R)) );
587 if(f22<0.0)
588 E+=M_PI;
589 }
590
591 rnElevationDeg = basegfx::fround(basegfx::rad2deg(E));
592 rnRotationDeg = basegfx::fround(basegfx::rad2deg(R));
593}
594
595double ThreeDHelper::getValueClippedToRange( double fAngle, const double& fPositivLimit )
596{
597 if( fAngle<-1*fPositivLimit )
598 fAngle=-1*fPositivLimit;
599 else if( fAngle>fPositivLimit )
600 fAngle=fPositivLimit;
601 return fAngle;
602}
603
604void ThreeDHelper::adaptRadAnglesForRightAngledAxes( double& rfXAngleRad, double& rfYAngleRad )
605{
608}
609
610
611void ThreeDHelper::getCameraDistanceRange( double& rfMinimumDistance, double& rfMaximumDistance )
612{
613 rfMinimumDistance = 3.0/4.0*FIXED_SIZE_FOR_3D_CHART_VOLUME;//empiric value
614 rfMaximumDistance = 20.0*FIXED_SIZE_FOR_3D_CHART_VOLUME;//empiric value
615}
616
617void ThreeDHelper::ensureCameraDistanceRange( double& rfCameraDistance )
618{
619 double fMin, fMax;
620 getCameraDistanceRange( fMin, fMax );
621 if( rfCameraDistance < fMin )
622 rfCameraDistance = fMin;
623 if( rfCameraDistance > fMax )
624 rfCameraDistance = fMax;
625}
626
627double ThreeDHelper::CameraDistanceToPerspective( double fCameraDistance )
628{
629 double fMin, fMax;
631 //fMax <-> 0; fMin <->100
632 //a/x + b = y
633 double a = 100.0*fMax*fMin/(fMax-fMin);
634 double b = -a/fMax;
635
636 double fRet = a/fCameraDistance + b;
637
638 return fRet;
639}
640
641double ThreeDHelper::PerspectiveToCameraDistance( double fPerspective )
642{
643 double fMin, fMax;
645 //fMax <-> 0; fMin <->100
646 //a/x + b = y
647 double a = 100.0*fMax*fMin/(fMax-fMin);
648 double b = -a/fMax;
649
650 double fRet = a/(fPerspective - b);
651
652 return fRet;
653}
654
656 const rtl::Reference< Diagram > & xDiagram
657 , sal_Int32& rnRoundedEdges, sal_Int32& rnObjectLines )
658{
659 rnRoundedEdges = -1;
660 rnObjectLines = -1;
661 try
662 {
663 bool bDifferentRoundedEdges = false;
664 bool bDifferentObjectLines = false;
665
666 drawing::LineStyle aLineStyle( drawing::LineStyle_SOLID );
667
668 std::vector< rtl::Reference< DataSeries > > aSeriesList =
669 xDiagram->getDataSeries();
670 sal_Int32 nSeriesCount = static_cast<sal_Int32>( aSeriesList.size() );
671
672 OUString aPercentDiagonalPropertyName( "PercentDiagonal" );
673 OUString aBorderStylePropertyName( "BorderStyle" );
674
675 for( sal_Int32 nS = 0; nS < nSeriesCount; ++nS )
676 {
677 rtl::Reference< DataSeries > xSeries( aSeriesList[nS] );
678 if(!nS)
679 {
680 rnRoundedEdges = 0;
681 try
682 {
683 sal_Int16 nPercentDiagonal = 0;
684
685 xSeries->getPropertyValue( aPercentDiagonalPropertyName ) >>= nPercentDiagonal;
686 rnRoundedEdges = static_cast< sal_Int32 >( nPercentDiagonal );
687
689 , aPercentDiagonalPropertyName, uno::Any(nPercentDiagonal) ) )
690 bDifferentRoundedEdges = true;
691 }
692 catch( const uno::Exception& )
693 {
694 TOOLS_WARN_EXCEPTION("chart2", "" );
695 bDifferentRoundedEdges = true;
696 }
697 try
698 {
699 xSeries->getPropertyValue( aBorderStylePropertyName ) >>= aLineStyle;
700
702 , aBorderStylePropertyName, uno::Any(aLineStyle) ) )
703 bDifferentObjectLines = true;
704 }
705 catch( const uno::Exception& )
706 {
707 TOOLS_WARN_EXCEPTION("chart2", "" );
708 bDifferentObjectLines = true;
709 }
710 }
711 else
712 {
713 if( !bDifferentRoundedEdges )
714 {
715 sal_Int16 nPercentDiagonal = 0;
716 xSeries->getPropertyValue( aPercentDiagonalPropertyName ) >>= nPercentDiagonal;
717 sal_Int32 nCurrentRoundedEdges = static_cast< sal_Int32 >( nPercentDiagonal );
718 if(nCurrentRoundedEdges!=rnRoundedEdges
720 , aPercentDiagonalPropertyName, uno::Any( static_cast< sal_Int16 >(rnRoundedEdges) ) ) )
721 {
722 bDifferentRoundedEdges = true;
723 }
724 }
725
726 if( !bDifferentObjectLines )
727 {
728 drawing::LineStyle aCurrentLineStyle;
729 xSeries->getPropertyValue( aBorderStylePropertyName ) >>= aCurrentLineStyle;
730 if(aCurrentLineStyle!=aLineStyle
732 , aBorderStylePropertyName, uno::Any(aLineStyle) ) )
733 bDifferentObjectLines = true;
734 }
735 }
736 if( bDifferentRoundedEdges && bDifferentObjectLines )
737 break;
738 }
739
740 //set rnObjectLines
741 rnObjectLines = 0;
742 if( bDifferentObjectLines )
743 rnObjectLines = -1;
744 else if( aLineStyle == drawing::LineStyle_SOLID )
745 rnObjectLines = 1;
746 }
747 catch( const uno::Exception& )
748 {
749 TOOLS_WARN_EXCEPTION("chart2", "" );
750 }
751}
752
754 const rtl::Reference< Diagram > & xDiagram
755 , sal_Int32 nRoundedEdges, sal_Int32 nObjectLines )
756{
757 if( (nRoundedEdges<0||nRoundedEdges>100) && nObjectLines!=0 && nObjectLines!=1 )
758 return;
759
760 drawing::LineStyle aLineStyle( drawing::LineStyle_NONE );
761 if(nObjectLines==1)
762 aLineStyle = drawing::LineStyle_SOLID;
763
764 uno::Any aALineStyle( aLineStyle);
765 uno::Any aARoundedEdges( static_cast< sal_Int16 >( nRoundedEdges ));
766
767 std::vector< rtl::Reference< DataSeries > > aSeriesList =
768 xDiagram->getDataSeries();
769 for( auto const& xSeries : aSeriesList)
770 {
771 if( nRoundedEdges>=0 && nRoundedEdges<=100 )
772 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "PercentDiagonal", aARoundedEdges );
773
774 if( nObjectLines==0 || nObjectLines==1 )
775 DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "BorderStyle", aALineStyle );
776 }
777}
778
780{
782
783 double fXAngleRad=0.0; double fYAngleRad=0.0; double fZAngleRad=0.0;
784 xDiagram->getRotationAngle( fXAngleRad, fYAngleRad, fZAngleRad );
786 {
787 ThreeDHelper::adaptRadAnglesForRightAngledAxes( fXAngleRad, fYAngleRad );
788 }
789 if( sin(fYAngleRad)>0.0 )
791 return eRet;
792}
793
795{
797
798 double fXAngleRad=0.0; double fYAngleRad=0.0; double fZAngleRad=0.0;
799 xDiagram->getRotationAngle( fXAngleRad, fYAngleRad, fZAngleRad );
801 {
802 ThreeDHelper::adaptRadAnglesForRightAngledAxes( fXAngleRad, fYAngleRad );
803 }
804 if( cos(fXAngleRad)*cos(fYAngleRad)<0.0 )
806 return eRet;
807}
808
810{
812
813 double fXAngleRad=0.0; double fYAngleRad=0.0; double fZAngleRad=0.0;
814 xDiagram->getRotationAngle( fXAngleRad, fYAngleRad, fZAngleRad );
816 {
817 ThreeDHelper::adaptRadAnglesForRightAngledAxes( fXAngleRad, fYAngleRad );
818 }
819 if( sin(fXAngleRad)*cos(fYAngleRad)<0.0 )
821 return eRet;
822}
823
824} //namespace chart
825
826/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool isSupportingRightAngledAxes(const rtl::Reference< ::chart::ChartType > &xChartType)
static SAL_DLLPRIVATE void getCameraDistanceRange(double &rfMinimumDistance, double &rfMaximumDistance)
static void setRoundedEdgesAndObjectLines(const rtl::Reference< ::chart::Diagram > &xDiagram, sal_Int32 nRoundedEdges, sal_Int32 nObjectLines)
static double getValueClippedToRange(double fValue, const double &fPositivLimit)
static void getRoundedEdgesAndObjectLines(const rtl::Reference< ::chart::Diagram > &xDiagram, sal_Int32 &rnRoundedEdges, sal_Int32 &rnObjectLines)
static css::drawing::CameraGeometry getDefaultCameraGeometry(bool bPie=false)
Returns the default camera geometry that is set in the Diagram CTOR.
static void adaptRadAnglesForRightAngledAxes(double &rfXAngleRad, double &rfYAngleRad)
static double getYDegreeAngleLimitForRightAngledAxes()
static double CameraDistanceToPerspective(double fCameraDistance)
static CuboidPlanePosition getAutomaticCuboidPlanePositionForStandardBackWall(const rtl::Reference< ::chart::Diagram > &xDiagram)
static double PerspectiveToCameraDistance(double fPerspective)
static SAL_DLLPRIVATE void convertXYZAngleRadToElevationRotationDeg(sal_Int32 &rnElevationDeg, sal_Int32 &rnRotationDeg, double fXRad, double fYRad, double fZRad)
static double getXDegreeAngleLimitForRightAngledAxes()
static CuboidPlanePosition getAutomaticCuboidPlanePositionForStandardLeftWall(const rtl::Reference< ::chart::Diagram > &xDiagram)
static CuboidPlanePosition getAutomaticCuboidPlanePositionForStandardBottom(const rtl::Reference< ::chart::Diagram > &xDiagram)
static void convertElevationRotationDegToXYZAngleRad(sal_Int32 nElevationDeg, sal_Int32 nRotationDeg, double &rfXAngleRad, double &rfYAngleRad, double &rfZAngleRad)
static SAL_DLLPRIVATE void ensureCameraDistanceRange(double &rfCameraDistance)
constexpr double FIXED_SIZE_FOR_3D_CHART_VOLUME
Definition: defines.hxx:22
#define TOOLS_WARN_EXCEPTION(area, stream)
float y
float x
float z
T NormAngle360(T angle)
uno_Any a
constexpr double rad2deg(double v)
B2IRange fround(const B2DRange &rRange)
constexpr double deg2rad(double v)
OOO_DLLPUBLIC_CHARTTOOLS void setPropertyAlsoToAllAttributedDataPoints(const rtl::Reference< ::chart::DataSeries > &xSeries, const OUString &rPropertyName, const css::uno::Any &rPropertyValue)
OOO_DLLPUBLIC_CHARTTOOLS bool hasAttributedDataPointDifferentValue(const rtl::Reference< ::chart::DataSeries > &xSeries, const OUString &rPropertyName, const css::uno::Any &rPropertyValue)
static bool lcl_isRightAngledAxesSetAndSupported(Diagram &rDiagram)
Definition: Diagram.cxx:1832
CuboidPlanePosition
@ CuboidPlanePosition_Left
@ CuboidPlanePosition_Back
@ CuboidPlanePosition_Right
@ CuboidPlanePosition_Front
@ CuboidPlanePosition_Top
@ CuboidPlanePosition_Bottom
const sal_uInt8 R