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