1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library 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 GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : Plot2d_HistogramItem.h
23 // Author : Natalia ERMOLAEVA, Open CASCADE S.A.S. (natalia.donis@opencascade.com)
25 #ifndef PLOT2D_PLOTITEMS_H
26 #define PLOT2D_PLOTITEMS_H
30 #include <qwt_legend_item.h>
31 #include <qwt_plot_item.h>
32 #include <qwt_plot_curve.h>
33 #include <qwt_interval_data.h>
36 class PLOT2D_EXPORT Plot2d_QwtLegendItem : public QwtLegendItem
39 enum YAxisIdentifierMode { IM_None = 0, IM_Left, IM_Right };
42 Plot2d_QwtLegendItem( QWidget* = 0 );
43 virtual ~Plot2d_QwtLegendItem();
46 void setYAxisIdentifierMode( const int );
48 void setSelected(const bool on);
49 bool isSelected() const;
50 QColor getColorFromPalette(QPalette::ColorRole role);
53 virtual void drawIdentifier( QPainter*, const QRect& ) const;
54 virtual void drawText(QPainter *, const QRect &);
59 int myYAxisIdentifierMode;
60 QPixmap myYAxisLeftIcon;
61 QPixmap myYAxisRightIcon;
62 int mySpacingCollapsed;
63 int mySpacingExpanded;
67 class PLOT2D_EXPORT Plot2d_SelectableItem {
69 Plot2d_SelectableItem();
70 ~Plot2d_SelectableItem();
72 void setSelected( const bool );
73 bool isSelected() const;
75 void setLegendPen( const QPen & );
76 QPen legendPen() const;
78 void setLegendSymbol( const QwtSymbol& );
79 QwtSymbol legendSymbol() const;
84 QwtSymbol myLegendSymbol;
87 class PLOT2D_EXPORT Plot2d_QwtPlotCurve : public QwtPlotCurve, public Plot2d_SelectableItem
90 Plot2d_QwtPlotCurve( const QString&, QwtPlot::Axis = QwtPlot::yLeft );
91 virtual ~Plot2d_QwtPlotCurve();
94 virtual void setYAxisIdentifierEnabled( const bool );
95 virtual void draw(QPainter *p,
96 const QwtScaleMap &xMap,
97 const QwtScaleMap &yMap,
98 int from, int to) const;
100 void setDeviationData(const double* min, const double* max, const QList<int> &idx);
101 bool hasDeviationData() const;
102 void clearDeviationData();
106 virtual void updateLegend( QwtLegend* ) const;
107 virtual QWidget* legendItem() const;
109 QColor deviationMarkerColor() const;
110 int deviationMarkerLineWidth() const;
111 int deviationMarkerTickSize() const;
114 QwtPlot::Axis myYAxis;
115 bool myYAxisIdentifierEnabled;
117 class Plot2d_DeviationData;
118 Plot2d_DeviationData* myDeviationData;
121 class PLOT2D_EXPORT Plot2d_HistogramQwtItem: public QwtPlotItem
124 enum HistogramAttribute
130 explicit Plot2d_HistogramQwtItem( const QString& = QString() );
131 explicit Plot2d_HistogramQwtItem( const QwtText& );
132 virtual ~Plot2d_HistogramQwtItem();
134 void setData( const QwtIntervalData& );
135 const QwtIntervalData& data() const;
137 void setColor( const QColor& );
138 QColor color() const;
140 virtual QwtDoubleRect boundingRect() const;
141 virtual int rtti() const;
142 virtual void draw( QPainter*, const QwtScaleMap&,
143 const QwtScaleMap&, const QRect& ) const;
145 void setBaseline( double );
146 double baseline() const;
148 void setHistogramAttribute( HistogramAttribute, bool = true );
149 bool testHistogramAttribute( HistogramAttribute ) const;
152 virtual void drawBar( QPainter*, Qt::Orientation, const QRect& ) const;
159 QwtIntervalData myData;
164 class PLOT2D_EXPORT Plot2d_HistogramItem : public Plot2d_HistogramQwtItem, public Plot2d_SelectableItem
167 explicit Plot2d_HistogramItem( const QString& = QString() );
168 explicit Plot2d_HistogramItem( const QwtText& );
169 virtual ~Plot2d_HistogramItem();
171 QList<QRect> getBars() const;
173 virtual void updateLegend( QwtLegend* ) const;
174 virtual void draw( QPainter*, const QwtScaleMap&,
175 const QwtScaleMap&, const QRect& ) const;
177 void setCrossItems( bool theCross );
178 bool isCrossItems() const;
181 void drawRectAndLowers( QPainter*, Qt::Orientation,
182 const QRect& ) const;
183 int getCrossedTop( const QRect& ) const;
185 virtual QWidget* legendItem() const;
188 QList<QRect> myBarItems;
192 #endif // PLOT2D_PLOTITEMS_H