tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / chart2 / source / view / main / PlotterBase.cxx
blobd09bba64aeef9af0ff502bbbcb703f60217a917c
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 <osl/diagnose.h>
25 namespace chart
27 using namespace ::com::sun::star;
29 PlotterBase::PlotterBase( sal_Int32 nDimensionCount )
30 : m_nDimension(nDimensionCount)
31 , m_pPosHelper(nullptr)
35 void PlotterBase::initPlotter( const rtl::Reference<SvxShapeGroupAnyD>& xLogicTarget
36 , const rtl::Reference<SvxShapeGroupAnyD>& xFinalTarget
37 , const OUString& rCID )
39 OSL_PRECOND(xLogicTarget.is()&&xFinalTarget.is(),"no proper initialization parameters");
40 //is only allowed to be called once
41 m_xLogicTarget = xLogicTarget;
42 m_xFinalTarget = xFinalTarget;
43 m_aCID = rCID;
46 PlotterBase::~PlotterBase()
50 void PlotterBase::setScales( std::vector< ExplicitScaleData >&& rScales, bool bSwapXAndYAxis )
52 if (!m_pPosHelper)
53 return;
55 OSL_PRECOND(m_nDimension<=static_cast<sal_Int32>(rScales.size()),"Dimension of Plotter does not fit two dimension of given scale sequence");
56 m_pPosHelper->setScales( std::move(rScales), bSwapXAndYAxis );
59 void PlotterBase::setTransformationSceneToScreen( const drawing::HomogenMatrix& rMatrix)
61 if (!m_pPosHelper)
62 return;
64 OSL_PRECOND(m_nDimension==2,"Set this transformation only in case of 2D");
65 if(m_nDimension!=2)
66 return;
67 m_pPosHelper->setTransformationSceneToScreen( rMatrix );
70 rtl::Reference<SvxShapeGroupAnyD> PlotterBase::createGroupShape(
71 const rtl::Reference<SvxShapeGroupAnyD>& xTarget
72 , const OUString& rName )
74 if(m_nDimension==2)
76 //create and add to target
77 return ShapeFactory::createGroup2D( xTarget, rName );
79 else
81 //create and added to target
82 return ShapeFactory::createGroup3D( xTarget, rName );
86 bool PlotterBase::isValidPosition( const drawing::Position3D& rPos )
88 if( std::isnan(rPos.PositionX) )
89 return false;
90 if( std::isnan(rPos.PositionY) )
91 return false;
92 if( std::isnan(rPos.PositionZ) )
93 return false;
94 if( std::isinf(rPos.PositionX) )
95 return false;
96 if( std::isinf(rPos.PositionY) )
97 return false;
98 if( std::isinf(rPos.PositionZ) )
99 return false;
100 return true;
103 } //namespace chart
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */