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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_chart2.hxx"
26 #include "PlotterBase.hxx"
27 #include "PlottingPositionHelper.hxx"
28 #include "ShapeFactory.hxx"
29 #include <rtl/math.hxx>
30 #include <com/sun/star/chart2/DataPointLabel.hpp>
31 #include <tools/debug.hxx>
32
33 //.............................................................................
34 namespace chart
35 {
36 //.............................................................................
37 using namespace ::com::sun::star;
38 using namespace ::com::sun::star::chart2;
39
40 //-----------------------------------------------------------------------------
41 //-----------------------------------------------------------------------------
42 //-----------------------------------------------------------------------------
43
PlotterBase(sal_Int32 nDimensionCount)44 PlotterBase::PlotterBase( sal_Int32 nDimensionCount )
45 : m_xLogicTarget(NULL)
46 , m_xFinalTarget(NULL)
47 , m_xShapeFactory(NULL)
48 , m_pShapeFactory(NULL)
49 , m_aCID()
50 , m_nDimension(nDimensionCount)
51 , m_pPosHelper(NULL)
52 {
53 }
54
initPlotter(const uno::Reference<drawing::XShapes> & xLogicTarget,const uno::Reference<drawing::XShapes> & xFinalTarget,const uno::Reference<lang::XMultiServiceFactory> & xShapeFactory,const rtl::OUString & rCID)55 void PlotterBase::initPlotter( const uno::Reference< drawing::XShapes >& xLogicTarget
56 , const uno::Reference< drawing::XShapes >& xFinalTarget
57 , const uno::Reference< lang::XMultiServiceFactory >& xShapeFactory
58 , const rtl::OUString& rCID )
59 throw (uno::RuntimeException)
60 {
61 DBG_ASSERT(xLogicTarget.is()&&xFinalTarget.is()&&xShapeFactory.is(),"no proper initialization parameters");
62 //is only allowed to be called once
63 m_xLogicTarget = xLogicTarget;
64 m_xFinalTarget = xFinalTarget;
65 m_xShapeFactory = xShapeFactory;
66 m_pShapeFactory = new ShapeFactory(xShapeFactory);
67 m_aCID = rCID;
68 }
69
~PlotterBase()70 PlotterBase::~PlotterBase()
71 {
72 delete m_pShapeFactory;
73 }
74
setScales(const std::vector<ExplicitScaleData> & rScales,bool bSwapXAndYAxis)75 void PlotterBase::setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis )
76 {
77 DBG_ASSERT(m_nDimension<=static_cast<sal_Int32>(rScales.size()),"Dimension of Plotter does not fit two dimension of given scale sequence");
78 m_pPosHelper->setScales( rScales, bSwapXAndYAxis );
79 }
80
81
setTransformationSceneToScreen(const drawing::HomogenMatrix & rMatrix)82 void PlotterBase::setTransformationSceneToScreen( const drawing::HomogenMatrix& rMatrix)
83 {
84 DBG_ASSERT(m_nDimension==2,"Set this transformation only in case of 2D");
85 if(m_nDimension!=2)
86 return;
87 m_pPosHelper->setTransformationSceneToScreen( rMatrix );
88 }
89
createGroupShape(const uno::Reference<drawing::XShapes> & xTarget,::rtl::OUString rName)90 uno::Reference< drawing::XShapes > PlotterBase::createGroupShape(
91 const uno::Reference< drawing::XShapes >& xTarget
92 , ::rtl::OUString rName )
93 {
94 if(!m_xShapeFactory.is())
95 return NULL;
96
97 if(m_nDimension==2)
98 {
99 //create and add to target
100 return m_pShapeFactory->createGroup2D( xTarget, rName );
101 }
102 else
103 {
104 //create and added to target
105 return m_pShapeFactory->createGroup3D( xTarget, rName );
106 }
107 }
108
isValidPosition(const drawing::Position3D & rPos)109 bool PlotterBase::isValidPosition( const drawing::Position3D& rPos )
110 {
111 if( ::rtl::math::isNan(rPos.PositionX) )
112 return false;
113 if( ::rtl::math::isNan(rPos.PositionY) )
114 return false;
115 if( ::rtl::math::isNan(rPos.PositionZ) )
116 return false;
117 if( ::rtl::math::isInf(rPos.PositionX) )
118 return false;
119 if( ::rtl::math::isInf(rPos.PositionY) )
120 return false;
121 if( ::rtl::math::isInf(rPos.PositionZ) )
122 return false;
123 return true;
124 }
125
126 //.............................................................................
127 } //namespace chart
128 //.............................................................................
129