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 <osl/diagnose.h>
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
;
46 PlotterBase::~PlotterBase()
50 void PlotterBase::setScales( std::vector
< ExplicitScaleData
>&& rScales
, bool bSwapXAndYAxis
)
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
)
64 OSL_PRECOND(m_nDimension
==2,"Set this transformation only in case of 2D");
67 m_pPosHelper
->setTransformationSceneToScreen( rMatrix
);
70 rtl::Reference
<SvxShapeGroupAnyD
> PlotterBase::createGroupShape(
71 const rtl::Reference
<SvxShapeGroupAnyD
>& xTarget
72 , const OUString
& rName
)
76 //create and add to target
77 return ShapeFactory::createGroup2D( xTarget
, rName
);
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
) )
90 if( std::isnan(rPos
.PositionY
) )
92 if( std::isnan(rPos
.PositionZ
) )
94 if( std::isinf(rPos
.PositionX
) )
96 if( std::isinf(rPos
.PositionY
) )
98 if( std::isinf(rPos
.PositionZ
) )
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */