1 #ifndef PLOT2D_VIEWFRAME_H
2 #define PLOT2D_VIEWFRAME_H
4 #include "Plot2d_Prs.h"
5 #include "Plot2d_Curve.h"
11 #include <qwt_legend.h>
15 typedef QIntDict<Plot2d_Curve> CurveDict;
17 class PLOT2D_EXPORT Plot2d_ViewFrame : public QWidget
21 enum { NoOpId, FitAreaId, ZoomId, PanId, GlPanId, DumpId,
22 ModeXLinearId, ModeXLogarithmicId, ModeYLinearId, ModeYLogarithmicId,
23 LegendId, CurvePointsId, CurveLinesId, CurveSplinesId };
25 /* Construction/destruction */
26 Plot2d_ViewFrame( QWidget* parent, const QString& title = "" );
27 virtual ~Plot2d_ViewFrame();
29 enum ObjectType { MainTitle, XTitle, YTitle, Y2Title, XAxis, YAxis, Y2Axis };
32 QWidget* getViewWidget();
39 void Display( const Plot2d_Prs* );
40 void Erase( const Plot2d_Prs*, const bool = false );
41 Plot2d_Prs* CreatePrs( const char* entry = 0 );
44 void setTitle( const QString& title );
45 QString getTitle() const { return myTitle; }
46 void displayCurve( Plot2d_Curve* curve, bool update = false );
47 void displayCurves( curveList curves, bool update = false );
48 void eraseCurve( Plot2d_Curve* curve, bool update = false );
49 void eraseCurves( curveList& curves, bool update = false );
50 int getCurves( QList<Plot2d_Curve>& clist );
51 const CurveDict& getCurves() { return myCurves; }
52 int hasCurve( Plot2d_Curve* curve );
53 bool isVisible( Plot2d_Curve* curve );
54 void updateCurve( Plot2d_Curve* curve, bool update = false );
55 void updateLegend( const Plot2d_Prs* prs );
57 void fitArea( const QRect& area );
60 void setCurveType( int curveType, bool update = true );
61 int getCurveType() const { return myCurveType; }
62 void setCurveTitle( int curveKey, const QString& title );
63 void showLegend( bool show, bool update = true );
64 void setLegendPos( int pos );
65 int getLegendPos() const { return myLegendPos; }
66 void setMarkerSize( const int size, bool update = true );
67 int getMarkerSize() const { return myMarkerSize; }
68 void setBackgroundColor( const QColor& color );
69 QColor backgroundColor() const;
70 void setXGrid( bool xMajorEnabled, const int xMajorMax,
71 bool xMinorEnabled, const int xMinorMax, bool update = true );
72 void setYGrid( bool yMajorEnabled, const int yMajorMax,
73 bool yMinorEnabled, const int yMinorMax,
74 bool y2MajorEnabled, const int y2MajorMax,
75 bool y2MinorEnabled, const int y2MinorMax, bool update = true );
76 void setTitle( bool enabled, const QString& title, ObjectType type, bool update = true );
77 QString getTitle( ObjectType type ) const;
79 void setFont( const QFont& font, ObjectType type, bool update = true );
80 void setHorScaleMode( const int mode, bool update = true );
81 int getHorScaleMode() const { return myXMode; }
82 void setVerScaleMode( const int mode, bool update = true );
83 int getVerScaleMode() const { return myYMode; }
85 bool isModeHorLinear();
86 bool isModeVerLinear();
87 bool isLegendShow() { return myShowLegend; };
90 int testOperation( const QMouseEvent& );
91 void readPreferences();
92 void writePreferences();
93 QString getInfo( const QPoint& pnt );
94 virtual void wheelEvent( QWheelEvent* );
100 void onViewFitArea();
101 void onViewGlobalPan();
104 void onChangeBackground();
107 void plotMousePressed( const QMouseEvent& );
108 void plotMouseMoved( const QMouseEvent& );
109 void plotMouseReleased( const QMouseEvent& );
112 void vpModeHorChanged();
113 void vpModeVerChanged();
114 void vpCurveChanged();
115 void contextMenuRequested( QContextMenuEvent *e );
118 Plot2d_Plot2d* myPlot;
128 QString myTitle, myXTitle, myYTitle, myY2Title;
129 bool myTitleEnabled, myXTitleEnabled, myYTitleEnabled, myY2TitleEnabled;
130 bool myXGridMajorEnabled, myYGridMajorEnabled, myY2GridMajorEnabled;
131 bool myXGridMinorEnabled, myYGridMinorEnabled, myY2GridMinorEnabled;
132 int myXGridMaxMajor, myYGridMaxMajor, myY2GridMaxMajor;
133 int myXGridMaxMinor, myYGridMaxMinor, myY2GridMaxMinor;
134 int myXMode, myYMode;
135 double myXDistance, myYDistance, myYDistance2;
139 class Plot2d_Plot2d : public QwtPlot
142 Plot2d_Plot2d( QWidget* parent );
145 void getNextMarker( QwtSymbol::Style& typeMarker, QColor& color, Qt::PenStyle& typeLine );
146 QwtLegend* getLegend() {
147 #if QWT_VERSION < 0x040200
150 return legend(); /* mpv: porting to the Qwt 4.2.0 */
153 virtual QSize sizeHint() const;
154 virtual QSizePolicy sizePolicy() const;
155 virtual QSize minimumSizeHint() const;
158 bool existMarker( const QwtSymbol::Style typeMarker, const QColor& color, const Qt::PenStyle typeLine );
161 QValueList<QColor> myColors;