1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
28 using namespace ::com::sun::star
;
29 using namespace ::com::sun::star::chart2
;
31 PlotterBase::PlotterBase( sal_Int32 nDimensionCount
)
32 : m_pShapeFactory(nullptr)
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
);
53 PlotterBase::~PlotterBase()
57 void PlotterBase::setScales( const std::vector
< ExplicitScaleData
>& rScales
, bool bSwapXAndYAxis
)
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
)
71 OSL_PRECOND(m_nDimension
==2,"Set this transformation only in case of 2D");
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())
86 //create and add to target
87 return m_pShapeFactory
->createGroup2D( xTarget
, rName
);
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
) )
100 if( ::rtl::math::isNan(rPos
.PositionY
) )
102 if( ::rtl::math::isNan(rPos
.PositionZ
) )
104 if( ::rtl::math::isInf(rPos
.PositionX
) )
106 if( ::rtl::math::isInf(rPos
.PositionY
) )
108 if( ::rtl::math::isInf(rPos
.PositionZ
) )
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */