1 /*
2  * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB.  All rights reserved.
3  *
4  * This file is part of the KD Chart library.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef KCHARTLINEATTRIBUTES_H
21 #define KCHARTLINEATTRIBUTES_H
22 
23 #include <QMetaType>
24 #include "KChartGlobal.h"
25 
26 namespace KChart {
27 
28 /**
29   * @brief Set of attributes for changing the appearance of line charts
30   */
31 class KCHART_EXPORT LineAttributes
32 {
33 public:
34     /**
35       \brief MissingValuesPolicy specifies how a missing value will be shown in a line diagram.
36 
37       Missing value is assumed if the data cell contains a QVariant that can not be
38       interpreted as a qreal, or if the data cell is hidden while its dataset is not hidden.
39 
40       \li \c MissingValuesAreBridged the default: No markers will be shown for missing values
41       but the line will be bridged if there is at least one valid cell before and after
42       the missing value(s), otherwise the segment will be hidden.
43       \li \c MissingValuesHideSegments Line segments starting with a missing value will
44       not be shown, and no markers will be shown for missing values, so this will look like
45       a piece of the line is missing.
46       \li \c MissingValuesShownAsZero Missing value(s) will be treated like normal zero values,
47       and markers will shown for them too, so there will be no visible difference between a
48       zero value and a missing value.
49       \li \c MissingValuesPolicyIgnored (internal value, do not use)
50 
51       */
52     enum MissingValuesPolicy {
53         MissingValuesAreBridged,
54         MissingValuesHideSegments,
55         MissingValuesShownAsZero,
56         MissingValuesPolicyIgnored };
57 
58     LineAttributes();
59     LineAttributes( const LineAttributes& );
60     LineAttributes &operator= ( const LineAttributes& );
61 
62     ~LineAttributes();
63 
64     /* line chart and area chart - all types */
65     void setMissingValuesPolicy( MissingValuesPolicy policy );
66     MissingValuesPolicy missingValuesPolicy() const;
67 
68     /* area chart - all types */
69     /**
70      * Sets the lower or upper (depending on the displayed value being positive or
71      * negative, resp.) bounding line (i.e., the dataset with the line data). The area
72      * is then drawn between this line and the line of the specified dataset.
73      * Pass -1 to draw the area between this line and the zero line.
74      */
75     void setAreaBoundingDataset( int dataset );
76     int areaBoundingDataset() const;
77 
78     /**
79      * Determines if lines are to be drawn or not. This property does not
80      * effect visibility of markers and text labels.
81      *
82      * This is useful for e.g. bubble charts where you need circular markers
83      * but want no connecting lines to be drawn.
84      *
85      * By default lines are drawn, i.e. this property is true.
86      */
87     void setVisible( bool visible );
88     bool isVisible() const;
89 
90     void setDisplayArea( bool display );
91     bool displayArea() const;
92     /*allows viewing the covered areas*/
93     void setTransparency( uint alpha );
94     uint transparency() const;
95 
96     bool operator==( const LineAttributes& ) const;
97     inline bool operator!=( const LineAttributes& other ) const { return !operator==(other); }
98 
99 private:
100     KCHART_DECLARE_PRIVATE_BASE_VALUE( LineAttributes )
101 }; // End of class LineAttributes
102 
103 }
104 
105 #if !defined(QT_NO_DEBUG_STREAM)
106 KCHART_EXPORT QDebug operator<<(QDebug, const KChart::LineAttributes& );
107 #endif /* QT_NO_DEBUG_STREAM */
108 
109 KCHART_DECLARE_SWAP_SPECIALISATION( KChart::LineAttributes )
110 
111 QT_BEGIN_NAMESPACE
112 Q_DECLARE_TYPEINFO( KChart::LineAttributes, Q_MOVABLE_TYPE );
113 QT_END_NAMESPACE
114 
115 Q_DECLARE_METATYPE( KChart::LineAttributes )
116 
117 #endif // KCHARTLINEATTRIBUTES_H
118