LibreOffice Module chart2 (master) 1
MinimumAndMaximumSupplier.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
21
22#include <com/sun/star/chart/TimeUnit.hpp>
23
24#include <cmath>
25#include <limits>
26
27namespace chart
28{
29using namespace ::com::sun::star;
30
32{
33}
34
36{
37}
38
40{
41 m_aMinimumAndMaximumSupplierList.insert( pMinimumAndMaximumSupplier );
42}
43
45{
46 return m_aMinimumAndMaximumSupplierList.count( pMinimumAndMaximumSupplier ) != 0;
47}
48
50{
51 double fGlobalExtremum = std::numeric_limits<double>::infinity();
52 for (auto const& elem : m_aMinimumAndMaximumSupplierList)
53 {
54 double fLocalExtremum = elem->getMinimumX();
55 if(fLocalExtremum<fGlobalExtremum)
56 fGlobalExtremum=fLocalExtremum;
57 }
58 if(std::isinf(fGlobalExtremum))
59 return std::numeric_limits<double>::quiet_NaN();
60 return fGlobalExtremum;
61}
62
64{
65 double fGlobalExtremum = -std::numeric_limits<double>::infinity();
66 for (auto const& elem : m_aMinimumAndMaximumSupplierList)
67 {
68 double fLocalExtremum = elem->getMaximumX();
69 if(fLocalExtremum>fGlobalExtremum)
70 fGlobalExtremum=fLocalExtremum;
71 }
72 if(std::isinf(fGlobalExtremum))
73 return std::numeric_limits<double>::quiet_NaN();
74 return fGlobalExtremum;
75}
76
77double MergedMinimumAndMaximumSupplier::getMinimumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex )
78{
79 double fGlobalExtremum = std::numeric_limits<double>::infinity();
80 for (auto const& elem : m_aMinimumAndMaximumSupplierList)
81 {
82 double fLocalExtremum = elem->getMinimumYInRange( fMinimumX, fMaximumX, nAxisIndex );
83 if(fLocalExtremum<fGlobalExtremum)
84 fGlobalExtremum=fLocalExtremum;
85 }
86 if(std::isinf(fGlobalExtremum))
87 return std::numeric_limits<double>::quiet_NaN();
88 return fGlobalExtremum;
89}
90
91double MergedMinimumAndMaximumSupplier::getMaximumYInRange( double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex )
92{
93 double fGlobalExtremum = -std::numeric_limits<double>::infinity();
94 for (auto const& elem : m_aMinimumAndMaximumSupplierList)
95 {
96 double fLocalExtremum = elem->getMaximumYInRange( fMinimumX, fMaximumX, nAxisIndex );
97 if(fLocalExtremum>fGlobalExtremum)
98 fGlobalExtremum=fLocalExtremum;
99 }
100 if(std::isinf(fGlobalExtremum))
101 return std::numeric_limits<double>::quiet_NaN();
102 return fGlobalExtremum;
103}
104
106{
107 double fGlobalExtremum = std::numeric_limits<double>::infinity();
108 for (auto const& elem : m_aMinimumAndMaximumSupplierList)
109 {
110 double fLocalExtremum = elem->getMinimumZ();
111 if(fLocalExtremum<fGlobalExtremum)
112 fGlobalExtremum=fLocalExtremum;
113 }
114 if(std::isinf(fGlobalExtremum))
115 return std::numeric_limits<double>::quiet_NaN();
116 return fGlobalExtremum;
117}
118
120{
121 double fGlobalExtremum = -std::numeric_limits<double>::infinity();
122 for (auto const& elem : m_aMinimumAndMaximumSupplierList)
123 {
124 double fLocalExtremum = elem->getMaximumZ();
125 if(fLocalExtremum>fGlobalExtremum)
126 fGlobalExtremum=fLocalExtremum;
127 }
128 if(std::isinf(fGlobalExtremum))
129 return std::numeric_limits<double>::quiet_NaN();
130 return fGlobalExtremum;
131}
132
134{
135 // only return true, if *all* suppliers want to scale to the main tick marks
136 for (auto const& elem : m_aMinimumAndMaximumSupplierList)
137 if( !elem->isExpandBorderToIncrementRhythm( nDimensionIndex ) )
138 return false;
139 return true;
140}
141
143{
144 // only return true, if *all* suppliers want to expand the range
145 for (auto const& elem : m_aMinimumAndMaximumSupplierList)
146 if( !elem->isExpandIfValuesCloseToBorder( nDimensionIndex ) )
147 return false;
148 return true;
149}
150
152{
153 // already return true, if at least one supplier wants to expand the range
154 for (auto const& elem : m_aMinimumAndMaximumSupplierList)
155 if( elem->isExpandWideValuesToZero( nDimensionIndex ) )
156 return true;
157 return false;
158}
159
161{
162 // already return true, if at least one supplier wants to expand the range
163 for (auto const& elem : m_aMinimumAndMaximumSupplierList)
164 if( elem->isExpandNarrowValuesTowardZero( nDimensionIndex ) )
165 return true;
166 return false;
167}
168
170{
171 // should not be called
172 for (auto const& elem : m_aMinimumAndMaximumSupplierList)
173 if( elem->isSeparateStackingForDifferentSigns( nDimensionIndex ) )
174 return true;
175 return false;
176}
177
179{
181}
182
184{
185 tools::Long nRet = css::chart::TimeUnit::YEAR;
186 for (auto const& elem : m_aMinimumAndMaximumSupplierList)
187 {
188 tools::Long nCurrent = elem->calculateTimeResolutionOnXAxis();
189 if(nRet>nCurrent)
190 nRet=nCurrent;
191 }
192 return nRet;
193}
194
196{
197 for (auto const& elem : m_aMinimumAndMaximumSupplierList)
198 elem->setTimeResolutionOnXAxis( nTimeResolution, rNullDate );
199}
200
201} //namespace chart
202
203/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual double getMaximumYInRange(double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex) override
MinimumAndMaximumSupplierSet m_aMinimumAndMaximumSupplierList
bool hasMinimumAndMaximumSupplier(MinimumAndMaximumSupplier *pMinimumAndMaximumSupplier)
void addMinimumAndMaximumSupplier(MinimumAndMaximumSupplier *pMinimumAndMaximumSupplier)
virtual bool isExpandIfValuesCloseToBorder(sal_Int32 nDimensionIndex) override
virtual double getMinimumYInRange(double fMinimumX, double fMaximumX, sal_Int32 nAxisIndex) override
virtual bool isSeparateStackingForDifferentSigns(sal_Int32 nDimensionIndex) override
virtual bool isExpandBorderToIncrementRhythm(sal_Int32 nDimensionIndex) 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
long Long