LibreOffice Module chart2 (master) 1
PlotterBase.cxx
Go to the documentation of this file.
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>
22#include <ShapeFactory.hxx>
23#include <osl/diagnose.h>
24
25namespace chart
26{
27using namespace ::com::sun::star;
28using namespace ::com::sun::star::chart2;
29
30PlotterBase::PlotterBase( sal_Int32 nDimensionCount )
31 : m_nDimension(nDimensionCount)
32 , m_pPosHelper(nullptr)
33{
34}
35
37 , const rtl::Reference<SvxShapeGroupAnyD>& xFinalTarget
38 , const OUString& rCID )
39{
40 OSL_PRECOND(xLogicTarget.is()&&xFinalTarget.is(),"no proper initialization parameters");
41 //is only allowed to be called once
42 m_xLogicTarget = xLogicTarget;
43 m_xFinalTarget = xFinalTarget;
44 m_aCID = rCID;
45}
46
48{
49}
50
51void PlotterBase::setScales( std::vector< ExplicitScaleData >&& rScales, bool bSwapXAndYAxis )
52{
53 if (!m_pPosHelper)
54 return;
55
56 OSL_PRECOND(m_nDimension<=static_cast<sal_Int32>(rScales.size()),"Dimension of Plotter does not fit two dimension of given scale sequence");
57 m_pPosHelper->setScales( std::move(rScales), bSwapXAndYAxis );
58}
59
60void PlotterBase::setTransformationSceneToScreen( const drawing::HomogenMatrix& rMatrix)
61{
62 if (!m_pPosHelper)
63 return;
64
65 OSL_PRECOND(m_nDimension==2,"Set this transformation only in case of 2D");
66 if(m_nDimension!=2)
67 return;
69}
70
73 , const OUString& rName )
74{
75 if(m_nDimension==2)
76 {
77 //create and add to target
78 return ShapeFactory::createGroup2D( xTarget, rName );
79 }
80 else
81 {
82 //create and added to target
83 return ShapeFactory::createGroup3D( xTarget, rName );
84 }
85}
86
87bool PlotterBase::isValidPosition( const drawing::Position3D& rPos )
88{
89 if( std::isnan(rPos.PositionX) )
90 return false;
91 if( std::isnan(rPos.PositionY) )
92 return false;
93 if( std::isnan(rPos.PositionZ) )
94 return false;
95 if( std::isinf(rPos.PositionX) )
96 return false;
97 if( std::isinf(rPos.PositionY) )
98 return false;
99 if( std::isinf(rPos.PositionZ) )
100 return false;
101 return true;
102}
103
104} //namespace chart
105
106/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void setTransformationSceneToScreen(const css::drawing::HomogenMatrix &rMatrix)
Definition: PlotterBase.cxx:60
rtl::Reference< SvxShapeGroupAnyD > m_xLogicTarget
Definition: PlotterBase.hxx:69
PlotterBase(sal_Int32 nDimension)
Definition: PlotterBase.cxx:30
static bool isValidPosition(const css::drawing::Position3D &rPos)
Definition: PlotterBase.cxx:87
PlottingPositionHelper * m_pPosHelper
Definition: PlotterBase.hxx:75
rtl::Reference< SvxShapeGroupAnyD > m_xFinalTarget
Definition: PlotterBase.hxx:70
const sal_Int32 m_nDimension
Definition: PlotterBase.hxx:73
virtual void setScales(std::vector< ExplicitScaleData > &&rScales, bool bSwapXAndYAxis)
Definition: PlotterBase.cxx:51
virtual void initPlotter(const rtl::Reference< SvxShapeGroupAnyD > &xLogicTarget, const rtl::Reference< SvxShapeGroupAnyD > &xFinalTarget, const OUString &rCID)
Definition: PlotterBase.cxx:36
rtl::Reference< SvxShapeGroupAnyD > createGroupShape(const rtl::Reference< SvxShapeGroupAnyD > &xTarget, const OUString &rName=OUString())
Definition: PlotterBase.cxx:71
virtual ~PlotterBase()
Definition: PlotterBase.cxx:47
virtual void setScales(std::vector< ExplicitScaleData > &&rScales, bool bSwapXAndYAxis)
virtual void setTransformationSceneToScreen(const css::drawing::HomogenMatrix &rMatrix)
static rtl::Reference< Svx3DSceneObject > createGroup3D(const rtl::Reference< SvxShapeGroupAnyD > &xTarget, const OUString &aName=OUString())
static rtl::Reference< SvxShapeGroup > createGroup2D(const rtl::Reference< SvxShapeGroupAnyD > &xTarget, const OUString &aName=OUString())
Reference< XInterface > xTarget