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 "AbstractShapeFactory.hxx"
23 #include <rtl/math.hxx>
24 #include <osl/diagnose.h>
25 #include <com/sun/star/chart2/DataPointLabel.hpp>
29 using namespace ::com::sun::star
;
30 using namespace ::com::sun::star::chart2
;
32 PlotterBase::PlotterBase( sal_Int32 nDimensionCount
)
33 : m_xLogicTarget(NULL
)
34 , m_xFinalTarget(NULL
)
35 , m_xShapeFactory(NULL
)
36 , m_pShapeFactory(NULL
)
38 , m_nDimension(nDimensionCount
)
43 void PlotterBase::initPlotter( const uno::Reference
< drawing::XShapes
>& xLogicTarget
44 , const uno::Reference
< drawing::XShapes
>& xFinalTarget
45 , const uno::Reference
< lang::XMultiServiceFactory
>& xShapeFactory
46 , const OUString
& rCID
)
47 throw (uno::RuntimeException
)
49 OSL_PRECOND(xLogicTarget
.is()&&xFinalTarget
.is()&&xShapeFactory
.is(),"no proper initialization parameters");
50 //is only allowed to be called once
51 m_xLogicTarget
= xLogicTarget
;
52 m_xFinalTarget
= xFinalTarget
;
53 m_xShapeFactory
= xShapeFactory
;
54 m_pShapeFactory
= AbstractShapeFactory::getOrCreateShapeFactory(xShapeFactory
);
58 PlotterBase::~PlotterBase()
62 void PlotterBase::setScales( const std::vector
< ExplicitScaleData
>& rScales
, bool bSwapXAndYAxis
)
67 OSL_PRECOND(m_nDimension
<=static_cast<sal_Int32
>(rScales
.size()),"Dimension of Plotter does not fit two dimension of given scale sequence");
68 m_pPosHelper
->setScales( rScales
, bSwapXAndYAxis
);
71 void PlotterBase::setTransformationSceneToScreen( const drawing::HomogenMatrix
& rMatrix
)
76 OSL_PRECOND(m_nDimension
==2,"Set this transformation only in case of 2D");
79 m_pPosHelper
->setTransformationSceneToScreen( rMatrix
);
82 uno::Reference
< drawing::XShapes
> PlotterBase::createGroupShape(
83 const uno::Reference
< drawing::XShapes
>& xTarget
84 , const OUString
& rName
)
86 if(!m_xShapeFactory
.is())
91 //create and add to target
92 return m_pShapeFactory
->createGroup2D( xTarget
, rName
);
96 //create and added to target
97 return m_pShapeFactory
->createGroup3D( xTarget
, rName
);
101 bool PlotterBase::isValidPosition( const drawing::Position3D
& rPos
)
103 if( ::rtl::math::isNan(rPos
.PositionX
) )
105 if( ::rtl::math::isNan(rPos
.PositionY
) )
107 if( ::rtl::math::isNan(rPos
.PositionZ
) )
109 if( ::rtl::math::isInf(rPos
.PositionX
) )
111 if( ::rtl::math::isInf(rPos
.PositionY
) )
113 if( ::rtl::math::isInf(rPos
.PositionZ
) )
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */