1 #ifndef PLOT2D_VIEWFRAME_H
2 #define PLOT2D_VIEWFRAME_H
4 #include "Plot2d_Curve.h"
11 typedef QIntDict<Plot2d_Curve> CurveDict;
13 class PLOT2D_EXPORT Plot2d_ViewFrame : public QWidget
17 enum { NoOpId, FitAreaId, ZoomId, PanId, GlPanId, DumpId,
18 ModeXLinearId, ModeXLogarithmicId, ModeYLinearId, ModeYLogarithmicId,
19 LegendId, CurvePointsId, CurveLinesId, CurveSplinesId };
21 /* Construction/destruction */
22 Plot2d_ViewFrame( QWidget* parent, const QString& title = "" );
23 virtual ~Plot2d_ViewFrame();
25 enum ObjectType { MainTitle, XTitle, YTitle, Y2Title, XAxis, YAxis, Y2Axis };
28 QWidget* getViewWidget();
35 void Display( const Plot2d_Prs* );
36 void Erase( const Plot2d_Prs*, const bool = false );
37 Plot2d_Prs* CreatePrs( const char* entry = 0 );
40 void setTitle( const QString& title );
41 QString getTitle() const { return myTitle; }
42 void displayCurve( Plot2d_Curve* curve, bool update = false );
43 void displayCurves( const curveList& curves, bool update = false );
44 void eraseCurve( Plot2d_Curve* curve, bool update = false );
45 void eraseCurves( const curveList& curves, bool update = false );
46 int getCurves( curveList& clist );
47 const CurveDict& getCurves() { return myCurves; }
48 int hasCurve( Plot2d_Curve* curve );
49 bool isVisible( Plot2d_Curve* curve );
50 void updateCurve( Plot2d_Curve* curve, bool update = false );
51 void updateLegend( const Plot2d_Prs* prs );
53 void fitArea( const QRect& area );
54 void fitData(const int mode,
55 const double xMin, const double xMax,
56 const double yMin, const double yMax,
57 const double y2Min = 0, const double y2Max = 0);
59 void getFitRanges(double& xMin, double& xMax,
60 double& yMin, double& yMax,
61 double& y2Min, double& y2Max);
64 void copyPreferences( Plot2d_ViewFrame* );
65 void setCurveType( int curveType, bool update = true );
66 int getCurveType() const { return myCurveType; }
67 void setCurveTitle( int curveKey, const QString& title );
68 void showLegend( bool show, bool update = true );
69 void setLegendPos( int pos );
70 int getLegendPos() const { return myLegendPos; }
71 void setMarkerSize( const int size, bool update = true );
72 int getMarkerSize() const { return myMarkerSize; }
73 void setBackgroundColor( const QColor& color );
74 QColor backgroundColor() const;
75 void setXGrid( bool xMajorEnabled, const int xMajorMax,
76 bool xMinorEnabled, const int xMinorMax, bool update = true );
77 void setYGrid( bool yMajorEnabled, const int yMajorMax,
78 bool yMinorEnabled, const int yMinorMax,
79 bool y2MajorEnabled, const int y2MajorMax,
80 bool y2MinorEnabled, const int y2MinorMax, bool update = true );
81 void setTitle( bool enabled, const QString& title, ObjectType type, bool update = true );
82 QString getTitle( ObjectType type ) const;
84 void setFont( const QFont& font, ObjectType type, bool update = true );
85 void setHorScaleMode( const int mode, bool update = true );
86 int getHorScaleMode() const { return myXMode; }
87 void setVerScaleMode( const int mode, bool update = true );
88 int getVerScaleMode() const { return myYMode; }
90 bool isModeHorLinear();
91 bool isModeVerLinear();
92 bool isLegendShow() { return myShowLegend; };
95 int testOperation( const QMouseEvent& );
96 void readPreferences();
97 void writePreferences();
98 QString getInfo( const QPoint& pnt );
99 virtual void wheelEvent( QWheelEvent* );
105 void onViewFitArea();
106 void onViewGlobalPan();
109 void onChangeBackground();
112 void plotMousePressed( const QMouseEvent& );
113 void plotMouseMoved( const QMouseEvent& );
114 void plotMouseReleased( const QMouseEvent& );
117 void vpModeHorChanged();
118 void vpModeVerChanged();
119 void vpCurveChanged();
120 void contextMenuRequested( QContextMenuEvent *e );
123 Plot2d_Plot2d* myPlot;
133 QString myTitle, myXTitle, myYTitle, myY2Title;
134 bool myTitleEnabled, myXTitleEnabled, myYTitleEnabled, myY2TitleEnabled;
135 bool myXGridMajorEnabled, myYGridMajorEnabled, myY2GridMajorEnabled;
136 bool myXGridMinorEnabled, myYGridMinorEnabled, myY2GridMinorEnabled;
137 int myXGridMaxMajor, myYGridMaxMajor, myY2GridMaxMajor;
138 int myXGridMaxMinor, myYGridMaxMinor, myY2GridMaxMinor;
139 int myXMode, myYMode;
140 double myXDistance, myYDistance, myYDistance2;
144 class Plot2d_Plot2d : public QwtPlot
147 Plot2d_Plot2d( QWidget* parent );
150 void getNextMarker( QwtSymbol::Style& typeMarker, QColor& color, Qt::PenStyle& typeLine );
151 QwtLegend* getLegend() {
152 #if QWT_VERSION < 0x040200
155 return legend(); /* mpv: porting to the Qwt 4.2.0 */
158 virtual QSize sizeHint() const;
159 virtual QSizePolicy sizePolicy() const;
160 virtual QSize minimumSizeHint() const;
163 bool existMarker( const QwtSymbol::Style typeMarker, const QColor& color, const Qt::PenStyle typeLine );
166 QValueList<QColor> myColors;