1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
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_label.h>
31 #include <qwt_legend.h>
32 #include <qwt_plot_item.h>
33 #include <qwt_plot_curve.h>
35 #include <qwt_series_data.h>
36 #include <qwt_compat.h>
38 class PLOT2D_EXPORT Plot2d_QwtLegendLabel : public QwtLegendLabel
41 enum YAxisIdentifierMode { IM_None = 0, IM_Left, IM_Right };
44 Plot2d_QwtLegendLabel( QWidget* = 0 );
45 virtual ~Plot2d_QwtLegendLabel();
48 void setYAxisIdentifierMode( const int );
50 void setSelected( const bool on );
51 bool isSelected() const;
52 QColor getColorFromPalette( QPalette::ColorRole role );
53 void drawIdentifier( QPainter*, const QRect& );
54 void setSymbol( const QwtSymbol* );
55 void setSymbolType( const int );
56 void setPen( const QPen& );
59 virtual void drawText( QPainter*, const QRectF& );
60 virtual void paintEvent( QPaintEvent* );
65 int myYAxisIdentifierMode;
66 QPixmap myYAxisLeftIcon;
67 QPixmap myYAxisRightIcon;
68 int mySpacingCollapsed;
69 int mySpacingExpanded;
76 class PLOT2D_EXPORT Plot2d_SelectableItem {
78 Plot2d_SelectableItem();
79 ~Plot2d_SelectableItem();
81 void setSelected( const bool );
82 bool isSelected() const;
84 void setLegendPen( const QPen& );
85 QPen legendPen() const;
87 void setLegendSymbol( const QwtSymbol* );
88 QwtSymbol* legendSymbol() const;
93 QwtSymbol* myLegendSymbol;
96 class PLOT2D_EXPORT Plot2d_QwtPlotCurve : public QwtPlotCurve, public Plot2d_SelectableItem
99 Plot2d_QwtPlotCurve( const QString&, QwtPlot::Axis = QwtPlot::yLeft );
100 virtual ~Plot2d_QwtPlotCurve();
103 virtual void setYAxisIdentifierEnabled( const bool );
104 virtual void drawSeries( QPainter* p,
105 const QwtScaleMap& xMap,
106 const QwtScaleMap& yMap,
107 const QRectF& canvasRect,
108 int from, int to) const;
110 void setDeviationData( const double* min, const double* max, const QList<int>& idx );
111 bool hasDeviationData() const;
112 void clearDeviationData();
115 virtual void updateLegend( const QwtPlotItem*,
116 const QList<QwtLegendData>& );
117 virtual void itemChanged();
119 QColor deviationMarkerColor() const;
120 int deviationMarkerLineWidth() const;
121 int deviationMarkerTickSize() const;
124 QwtPlot::Axis myYAxis;
125 bool myYAxisIdentifierEnabled;
127 class Plot2d_DeviationData;
128 Plot2d_DeviationData* myDeviationData;
131 class PLOT2D_EXPORT Plot2d_HistogramQwtItem: public QwtPlotItem
134 enum HistogramAttribute
140 explicit Plot2d_HistogramQwtItem( const QString& = QString() );
141 explicit Plot2d_HistogramQwtItem( const QwtText& );
142 virtual ~Plot2d_HistogramQwtItem();
144 void setData( const QwtIntervalSeriesData& );
145 const QwtIntervalSeriesData& data() const;
147 void setColor( const QColor& );
148 QColor color() const;
150 virtual QwtDoubleRect boundingRect() const;
151 virtual int rtti() const;
152 virtual void draw( QPainter*, const QwtScaleMap&,
153 const QwtScaleMap&, const QRectF& ) const;
155 void setBaseline( double );
156 double baseline() const;
158 void setHistogramAttribute( HistogramAttribute, bool = true );
159 bool testHistogramAttribute( HistogramAttribute ) const;
162 virtual void drawBar( QPainter*, Qt::Orientation, const QRect& ) const;
169 QwtIntervalSeriesData myData;
174 class PLOT2D_EXPORT Plot2d_HistogramItem : public Plot2d_HistogramQwtItem, public Plot2d_SelectableItem
177 explicit Plot2d_HistogramItem( const QString& = QString() );
178 explicit Plot2d_HistogramItem( const QwtText& );
179 virtual ~Plot2d_HistogramItem();
181 QList<QRect> getBars() const;
183 virtual void updateLegend( QwtPlotItem*,
184 QList<QwtLegendData>& );
185 virtual void draw( QPainter*, const QwtScaleMap&,
186 const QwtScaleMap&, const QRectF& ) const;
188 void setCrossItems( bool theCross );
189 bool isCrossItems() const;
192 void drawRectAndLowers( QPainter*, Qt::Orientation,
193 const QRect& ) const;
194 int getCrossedTop( const QRect& ) const;
197 QList<QRect> myBarItems;
201 class PLOT2D_EXPORT Plot2d_QwtLegend : public QwtLegend
204 explicit Plot2d_QwtLegend( QWidget *parent = NULL );
205 virtual ~Plot2d_QwtLegend();
208 virtual QWidget* createWidget( const QwtLegendData& ) const;
211 #endif // PLOT2D_PLOTITEMS_H