37#include <com/sun/star/chart/TimeUnit.hpp>
38#include <com/sun/star/chart2/AxisType.hpp>
40#include <rtl/math.hxx>
51using ::com::sun::star::uno::Reference;
52using ::com::sun::star::uno::Sequence;
57 if( !xCooSysModel.is() )
60 OUString aViewServiceName = xCooSysModel->getViewServiceName();
63 std::unique_ptr<VCoordinateSystem> pRet;
74 : m_xCooSysModel(
std::move(xCooSys))
78 , m_aExplicitScales(3)
79 , m_aExplicitIncrements(3)
96 OSL_PRECOND(xLogicTarget.is()&&xFinalTarget.is(),
"no proper initialization parameters");
101 if(nDimensionCount==2)
124 const drawing::HomogenMatrix& rMatrix )
142 const awt::Size& rPageSize,
const awt::Size& rPageResolution )
146 auto aResolutionRange = asNonConstRange(aResolution);
147 for(
auto&
i : aResolutionRange )
157 double fPageWidth = rPageSize.Width;
158 double fPageHeight = rPageSize.Height;
161 sal_Int32 nXResolution =
static_cast<sal_Int32
>(2.0*
static_cast<double>(rPageResolution.Width)*fCoosysWidth/fPageWidth);
162 sal_Int32 nYResolution =
static_cast<sal_Int32
>(2.0*
static_cast<double>(rPageResolution.Height)*fCoosysHeight/fPageHeight);
164 if( nXResolution < 10 )
166 if( nYResolution < 10 )
170 std::swap(nXResolution,nYResolution);
173 if( aResolution.getLength() == 2 )
175 aResolutionRange[0]=nXResolution;
176 aResolutionRange[1]=nYResolution;
181 sal_Int32 nMaxResolution = std::max( nXResolution, nYResolution );
183 for(
auto&
i : asNonConstRange(aResolution) )
193 return m_xCooSysModel->getAxisByDimension2( nDimensionIndex, nAxisIndex );
199 std::vector< rtl::Reference< ::chart::GridProperties > > aRet;
203 aRet.push_back( xAxis->getGridProperties2() );
204 std::vector<rtl::Reference<::chart::GridProperties>> aSubGrids = xAxis->getSubGridProperties2();
205 aRet.insert( aRet.end(), aSubGrids.begin(), aSubGrids.end() );
213 rDimensionIndex = std::clamp<sal_Int32>(rDimensionIndex, 0, 2);
316 if(elem.first.first==nDimensionIndex)
318 sal_Int32 nLocalIdx = elem.first.second;
319 if( nRet < nLocalIdx )
329 const awt::Rectangle& ,
331 std::vector<std::unique_ptr<VSeriesPlotter>>& ,
345 bool bDateAxisX = (rScaleAutomatism.
getScale().AxisType == AxisType::DATE) && (nDimIndex == 0);
349 sal_Int32 nTimeResolution = css::chart::TimeUnit::MONTH;
350 if( !(rScaleAutomatism.
getScale().TimeIncrement.TimeResolution >>= nTimeResolution) )
358 double fMin = std::numeric_limits<double>::infinity();
359 double fMax = -std::numeric_limits<double>::infinity();
366 else if( nDimIndex == 1 )
370 double fMaximum = aScale.
Maximum;
376 aMaxDate.
AddDays(::rtl::math::approxFloor(fMaximum));
379 case css::chart::TimeUnit::MONTH:
382 case css::chart::TimeUnit::YEAR:
386 fMaximum = aMaxDate - aScale.
NullDate;
391 else if( nDimIndex == 2 )
421 tVAxisMap::const_iterator aIt =
m_aAxisMap.find( aFullAxisIndex );
423 pRet = aIt->second.get();
429 sal_Int32 nDimensionIndex
430 , sal_Int32 nAxisIndex
458 for (
auto const&[unused, pVAxis] :
m_aAxisMap)
463 if (pVAxis->getDimensionCount() == 2)
465 pVAxis->createMaximumLabels();
471 for (
auto const&[unused, pVAxis] :
m_aAxisMap)
476 if (pVAxis->getDimensionCount() == 2)
478 pVAxis->createLabels();
485 for (
auto const&[unused, pVAxis] :
m_aAxisMap)
490 if (pVAxis->getDimensionCount() == 2)
492 pVAxis->updatePositions();
499 for (
auto const&[aFullAxisIndex, pVAxis] :
m_aAxisMap)
503 auto const&[nDimensionIndex, nAxisIndex] = aFullAxisIndex;
505 if (pVAxis->getDimensionCount() == 2)
510 if (nDimensionIndex == 0)
513 pVAxis->setExtraLinePositionAtOtherAxis(
516 else if (nDimensionIndex == 1)
519 pVAxis->setExtraLinePositionAtOtherAxis(
524 pVAxis->createShapes();
548 bool bSwapXAndY =
false;
551 m_xCooSysModel->getPropertyValue(
"SwapXAndYAxis" ) >>= bSwapXAndY;
553 catch(
const uno::Exception& )
573 return ExplicitValueProvider::getExplicitNumberFormatKeyForAxis(
void AddDays(sal_Int32 nAddDays)
static Date GetDateSomeYearsAway(const Date &rD, sal_Int32 nYearDistance)
static Date GetDateSomeMonthsAway(const Date &rD, sal_Int32 nMonthDistance)
virtual double getMaximumZ() override
virtual double getMaximumYInRange(double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex) override
bool hasMinimumAndMaximumSupplier(MinimumAndMaximumSupplier *pMinimumAndMaximumSupplier)
void addMinimumAndMaximumSupplier(MinimumAndMaximumSupplier *pMinimumAndMaximumSupplier)
virtual bool isExpandIfValuesCloseToBorder(sal_Int32 nDimensionIndex) override
virtual double getMaximumX() override
virtual double getMinimumX() override
virtual double getMinimumYInRange(double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex) override
virtual bool isExpandBorderToIncrementRhythm(sal_Int32 nDimensionIndex) override
virtual double getMinimumZ() override
virtual tools::Long calculateTimeResolutionOnXAxis() override
virtual void setTimeResolutionOnXAxis(tools::Long nTimeResolution, const Date &rNullDate) override
virtual bool isExpandNarrowValuesTowardZero(sal_Int32 nDimensionIndex) override
virtual bool isExpandWideValuesToZero(sal_Int32 nDimensionIndex) override
void clearMinimumAndMaximumSupplierList()
static OUString createClassifiedIdentifierForParticles(std::u16string_view rParentParticle, std::u16string_view rChildParticle, std::u16string_view rDragMethodServiceName=std::u16string_view(), std::u16string_view rDragParameterString=std::u16string_view())
static OUString createParticleForAxis(sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex)
static OUString createParticleForGrid(sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex)
This class implements the calculation of automatic axis limits.
const css::chart2::ScaleData & getScale() const
void setAutoScalingOptions(bool bExpandBorderToIncrementRhythm, bool bExpandIfValuesCloseToBorder, bool bExpandWideValuesToZero, bool bExpandNarrowValuesTowardZero)
Sets additional auto scaling options.
void setMaximumAutoMainIncrementCount(sal_Int32 nMaximumAutoMainIncrementCount)
Sets the maximum allowed number of automatic main increments.
const Date & getNullDate() const
void setAutomaticTimeResolution(sal_Int32 nTimeResolution)
Sets the time resolution to be used in case it is not set explicitly within the scale.
void expandValueRange(double fMinimum, double fMaximum)
Expands own value range with the passed minimum and maximum.
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())
virtual sal_Int32 estimateMaximumAutoMainIncrementCount()
sal_Int32 getDimensionCount() const
Return the number of dimensions the diagram has.
virtual void setTransformationSceneToScreen(const css::drawing::HomogenMatrix &rMatrix) override
ExplicitCategoriesProvider * getExplicitCategoriesProvider()
virtual void updateScalesAndIncrementsOnAxes()
std::vector< ExplicitIncrementData > getExplicitIncrements(sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex) const
bool needSeriesNamesForAxis() const
MergedMinimumAndMaximumSupplier m_aMergedMinMaxSupplier
Collection of min-max suppliers which are basically different chart types present in the same coordin...
virtual void createVAxisList(const rtl::Reference<::chart::ChartModel > &xChartDoc, const css::awt::Size &rFontReferenceSize, const css::awt::Rectangle &rMaximumSpaceForLabels, bool bLimitSpaceForLabels, std::vector< std::unique_ptr< VSeriesPlotter > > &rSeriesPlotterList, css::uno::Reference< css::uno::XComponentContext > const &rComponentContext)
Create "view" axis objects 'VAxis' from the coordinate system model.
void setParticle(const OUString &rCooSysParticle)
static std::vector< rtl::Reference< ::chart::GridProperties > > getGridListFromAxis(const rtl::Reference< ::chart::Axis > &xAxis)
void clearMinimumAndMaximumSupplierList()
std::unique_ptr< ExplicitCategoriesProvider > m_apExplicitCategoriesProvider
void addMinimumAndMaximumSupplier(MinimumAndMaximumSupplier *pMinimumAndMaximumSupplier)
sal_Int32 getMaximumAxisIndexByDimension(sal_Int32 nDimensionIndex) const
rtl::Reference< SvxShapeGroupAnyD > m_xLogicTargetForGrids
void setExplicitScaleAndIncrement(sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex, const ExplicitScaleData &rExplicitScale, const ExplicitIncrementData &rExplicitIncrement)
void setExplicitCategoriesProvider(ExplicitCategoriesProvider *)
VAxisBase * getVAxis(sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex)
std::vector< ExplicitScaleData > getExplicitScales(sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex) const
virtual ~VCoordinateSystem()
OUString createCIDForGrid(sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex)
static void impl_adjustDimension(sal_Int32 &rDimensionIndex)
void impl_adjustDimensionAndIndex(sal_Int32 &rDimensionIndex, sal_Int32 &rAxisIndex) const
void setSeriesNamesForAxis(const css::uno::Sequence< OUString > &rSeriesNames)
css::uno::Sequence< OUString > m_aSeriesNamesForZAxis
void set3DWallPositions(CuboidPlanePosition eLeftWallPos, CuboidPlanePosition eBackWallPos, CuboidPlanePosition eBottomPos)
void initPlottingTargets(const rtl::Reference< SvxShapeGroupAnyD > &xLogicTarget, const rtl::Reference< SvxShapeGroupAnyD > &xFinalTarget, rtl::Reference< SvxShapeGroupAnyD > &xLogicTargetForSeriesBehindAxis)
VCoordinateSystem(rtl::Reference< ::chart::BaseCoordinateSystem > xCooSys)
virtual void initVAxisInList()
ExplicitScaleData getExplicitScale(sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex) const
ExplicitIncrementData getExplicitIncrement(sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex) const
sal_Int32 getNumberFormatKeyForAxis(const rtl::Reference< ::chart::Axis > &xAxis, const rtl::Reference<::chart::ChartModel > &xChartDoc)
void prepareAutomaticAxisScaling(ScaleAutomatism &rScaleAutomatism, sal_Int32 nDimIndex, sal_Int32 nAxisIndex)
It sets the scaling parameters for the passed ScaleAutomatism object.
CuboidPlanePosition m_eLeftWallPos
OUString createCIDForAxis(sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex)
rtl::Reference< ::chart::Axis > getAxisByDimension(sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex) const
std::vector< ExplicitIncrementData > m_aExplicitIncrements
virtual void createGridShapes()
bool hasMinimumAndMaximumSupplier(MinimumAndMaximumSupplier *pMinimumAndMaximumSupplier)
bool getPropertySwapXAndYAxis() const
tFullExplicitScaleMap m_aSecondaryExplicitScales
std::pair< sal_Int32, sal_Int32 > tFullAxisIndex
rtl::Reference< SvxShapeGroupAnyD > m_xLogicTargetForAxes
void createMaximumAxesLabels()
static std::unique_ptr< VCoordinateSystem > createCoordinateSystem(const rtl::Reference< ::chart::BaseCoordinateSystem > &xCooSysModel)
void setTransformationSceneToScreen(const css::drawing::HomogenMatrix &rMatrix)
OUString m_aCooSysParticle
virtual css::uno::Sequence< sal_Int32 > getCoordinateSystemResolution(const css::awt::Size &rPageSize, const css::awt::Size &rPageResolution)
css::drawing::HomogenMatrix m_aMatrixSceneToScreen
std::vector< ExplicitScaleData > m_aExplicitScales
rtl::Reference< ::chart::BaseCoordinateSystem > m_xCooSysModel
CuboidPlanePosition m_eBackWallPos
rtl::Reference< SvxShapeGroupAnyD > m_xFinalTarget
tFullExplicitIncrementMap m_aSecondaryExplicitIncrements
CuboidPlanePosition m_eBottomPos
constexpr double FIXED_SIZE_FOR_3D_CHART_VOLUME
#define TOOLS_WARN_EXCEPTION(area, stream)
OOO_DLLPUBLIC_CHARTTOOLS::basegfx::B3DHomMatrix HomogenMatrixToB3DHomMatrix(const css::drawing::HomogenMatrix &rHomogenMatrix)
OOO_DLLPUBLIC_CHARTTOOLS::basegfx::B3DTuple GetScaleFromMatrix(const ::basegfx::B3DHomMatrix &rB3DMatrix)
@ CuboidPlanePosition_Left
@ CuboidPlanePosition_Back
@ CuboidPlanePosition_Bottom
constexpr OUStringLiteral CHART2_COOSYSTEM_CARTESIAN_VIEW_SERVICE_NAME
constexpr OUStringLiteral CHART2_COOSYSTEM_POLAR_VIEW_SERVICE_NAME
describes how tickmarks are positioned on the scale of an axis.
This structure contains the explicit values for a scale like Minimum and Maximum.
bool m_bShiftedCategoryPosition