Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / chart2 / source / view / main / PlotterBase.cxx
blobea40338f6a2201c3d0d923e301e4e1a380b2c00d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <PlotterBase.hxx>
21 #include <PlottingPositionHelper.hxx>
22 #include <ShapeFactory.hxx>
23 #include <rtl/math.hxx>
24 #include <osl/diagnose.h>
26 namespace chart
28 using namespace ::com::sun::star;
29 using namespace ::com::sun::star::chart2;
31 PlotterBase::PlotterBase( sal_Int32 nDimensionCount )
32 : m_pShapeFactory(nullptr)
33 , m_aCID()
34 , m_nDimension(nDimensionCount)
35 , m_pPosHelper(nullptr)
39 void PlotterBase::initPlotter( const uno::Reference< drawing::XShapes >& xLogicTarget
40 , const uno::Reference< drawing::XShapes >& xFinalTarget
41 , const uno::Reference< lang::XMultiServiceFactory >& xShapeFactory
42 , const OUString& rCID )
44 OSL_PRECOND(xLogicTarget.is()&&xFinalTarget.is()&&xShapeFactory.is(),"no proper initialization parameters");
45 //is only allowed to be called once
46 m_xLogicTarget = xLogicTarget;
47 m_xFinalTarget = xFinalTarget;
48 m_xShapeFactory = xShapeFactory;
49 m_pShapeFactory = ShapeFactory::getOrCreateShapeFactory(xShapeFactory);
50 m_aCID = rCID;
53 PlotterBase::~PlotterBase()
57 void PlotterBase::setScales( const std::vector< ExplicitScaleData >& rScales, bool bSwapXAndYAxis )
59 if (!m_pPosHelper)
60 return;
62 OSL_PRECOND(m_nDimension<=static_cast<sal_Int32>(rScales.size()),"Dimension of Plotter does not fit two dimension of given scale sequence");
63 m_pPosHelper->setScales( rScales, bSwapXAndYAxis );
66 void PlotterBase::setTransformationSceneToScreen( const drawing::HomogenMatrix& rMatrix)
68 if (!m_pPosHelper)
69 return;
71 OSL_PRECOND(m_nDimension==2,"Set this transformation only in case of 2D");
72 if(m_nDimension!=2)
73 return;
74 m_pPosHelper->setTransformationSceneToScreen( rMatrix );
77 uno::Reference< drawing::XShapes > PlotterBase::createGroupShape(
78 const uno::Reference< drawing::XShapes >& xTarget
79 , const OUString& rName )
81 if(!m_xShapeFactory.is())
82 return nullptr;
84 if(m_nDimension==2)
86 //create and add to target
87 return m_pShapeFactory->createGroup2D( xTarget, rName );
89 else
91 //create and added to target
92 return m_pShapeFactory->createGroup3D( xTarget, rName );
96 bool PlotterBase::isValidPosition( const drawing::Position3D& rPos )
98 if( ::rtl::math::isNan(rPos.PositionX) )
99 return false;
100 if( ::rtl::math::isNan(rPos.PositionY) )
101 return false;
102 if( ::rtl::math::isNan(rPos.PositionZ) )
103 return false;
104 if( ::rtl::math::isInf(rPos.PositionX) )
105 return false;
106 if( ::rtl::math::isInf(rPos.PositionY) )
107 return false;
108 if( ::rtl::math::isInf(rPos.PositionZ) )
109 return false;
110 return true;
113 } //namespace chart
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */