Branch data Line data Source code
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 : : #ifndef _CHART2_SCALEAUTOMATISM_HXX
20 : : #define _CHART2_SCALEAUTOMATISM_HXX
21 : :
22 : : #include "chartview/ExplicitScaleValues.hxx"
23 : : #include <com/sun/star/chart2/ScaleData.hpp>
24 : :
25 : : #include <tools/date.hxx>
26 : :
27 : : //.............................................................................
28 : : namespace chart
29 : : {
30 : : //.............................................................................
31 : :
32 : : //-----------------------------------------------------------------------------
33 : :
34 : : /** This class implements the calculation of automatic axis limits.
35 : : */
36 : 5976 : class ScaleAutomatism
37 : : {
38 : : public:
39 : : explicit ScaleAutomatism(
40 : : const ::com::sun::star::chart2::ScaleData& rSourceScale, const Date& rNullDate );
41 : : virtual ~ScaleAutomatism();
42 : :
43 : : /** Expands own value range with the passed minimum and maximum. */
44 : : void expandValueRange( double fMinimum, double fMaximum );
45 : :
46 : : /** Sets additional auto scaling options.
47 : : @param bExpandBorderToIncrementRhythm If true, expands automatic
48 : : borders to the fixed or calculated increment rhythm.
49 : : @param bExpandIfValuesCloseToBorder If true, expands automatic borders
50 : : if values are too close (closer than 1/21 of visible area).
51 : : @param bExpandWideValuesToZero If true, expands automatic border to
52 : : zero, if source values are positive only or negative only, and if
53 : : the absolute values are wide spread (at least one value is less
54 : : than 5/6 of absolute maximum), or if all values are equal.
55 : : @param bExpandNarrowValuesTowardZero If true, expands automatic border
56 : : toward zero (50% of the visible range), if source values are
57 : : positive only or negative only, and if the absolute values are
58 : : close to the absolute maximum (no value is less than 5/6 of
59 : : absolute maximum). */
60 : : void setAutoScalingOptions(
61 : : bool bExpandBorderToIncrementRhythm,
62 : : bool bExpandIfValuesCloseToBorder,
63 : : bool bExpandWideValuesToZero,
64 : : bool bExpandNarrowValuesTowardZero );
65 : :
66 : : /** Sets the maximum allowed number of automatic main increments.
67 : : @descr The number of main increments may be limited e.g. by the length
68 : : of the axis and the font size of the axis caption text. */
69 : : void setMaximumAutoMainIncrementCount( sal_Int32 nMaximumAutoMainIncrementCount );
70 : :
71 : : /** Sets the time resolution to be used in case it is not set explicitly within the scale
72 : : */
73 : : void setAutomaticTimeResolution( sal_Int32 nTimeResolution );
74 : :
75 : : /** Fills the passed scale data and increment data according to the own settings. */
76 : : void calculateExplicitScaleAndIncrement(
77 : : ExplicitScaleData& rExplicitScale,
78 : : ExplicitIncrementData& rExplicitIncrement ) const;
79 : :
80 : : ::com::sun::star::chart2::ScaleData getScale() const;
81 : : Date getNullDate() const;
82 : :
83 : : private:
84 : : /** Fills the passed scale data and increment data for category scaling. */
85 : : void calculateExplicitIncrementAndScaleForCategory(
86 : : ExplicitScaleData& rExplicitScale,
87 : : ExplicitIncrementData& rExplicitIncrement,
88 : : bool bAutoMinimum, bool bAutoMaximum ) const;
89 : :
90 : : /** Fills the passed scale data and increment data for logarithmic scaling. */
91 : : void calculateExplicitIncrementAndScaleForLogarithmic(
92 : : ExplicitScaleData& rExplicitScale,
93 : : ExplicitIncrementData& rExplicitIncrement,
94 : : bool bAutoMinimum, bool bAutoMaximum ) const;
95 : :
96 : : /** Fills the passed scale data and increment data for linear scaling. */
97 : : void calculateExplicitIncrementAndScaleForLinear(
98 : : ExplicitScaleData& rExplicitScale,
99 : : ExplicitIncrementData& rExplicitIncrement,
100 : : bool bAutoMinimum, bool bAutoMaximum ) const;
101 : :
102 : : /** Fills the passed scale data and increment data for date-time axis. */
103 : : void calculateExplicitIncrementAndScaleForDateTimeAxis(
104 : : ExplicitScaleData& rExplicitScale,
105 : : ExplicitIncrementData& rExplicitIncrement,
106 : : bool bAutoMinimum, bool bAutoMaximum ) const;
107 : :
108 : : private:
109 : : ::com::sun::star::chart2::ScaleData m_aSourceScale;
110 : :
111 : : double m_fValueMinimum; /// Minimum of all source values.
112 : : double m_fValueMaximum; /// Maximum of all source values.
113 : : sal_Int32 m_nMaximumAutoMainIncrementCount; /// Maximum number of automatic main increments.
114 : : bool m_bExpandBorderToIncrementRhythm; /// true = Expand to main increments.
115 : : bool m_bExpandIfValuesCloseToBorder; /// true = Expand if values are too close to the borders.
116 : : bool m_bExpandWideValuesToZero; /// true = Expand wide spread values to zero.
117 : : bool m_bExpandNarrowValuesTowardZero; /// true = Expand narrow range toward zero (add half of range).
118 : : sal_Int32 m_nTimeResolution;// a constant out of ::com::sun::star::chart::TimeUnit
119 : :
120 : : Date m_aNullDate;
121 : : };
122 : :
123 : : //.............................................................................
124 : : } //namespace chart
125 : : //.............................................................................
126 : : #endif
127 : :
128 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|