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 );
56 void copyPreferences( Plot2d_ViewFrame* );
57 void setCurveType( int curveType, bool update = true );
58 int getCurveType() const { return myCurveType; }
59 void setCurveTitle( int curveKey, const QString& title );
60 void showLegend( bool show, bool update = true );
61 void setLegendPos( int pos );
62 int getLegendPos() const { return myLegendPos; }
63 void setMarkerSize( const int size, bool update = true );
64 int getMarkerSize() const { return myMarkerSize; }
65 void setBackgroundColor( const QColor& color );
66 QColor backgroundColor() const;
67 void setXGrid( bool xMajorEnabled, const int xMajorMax,
68 bool xMinorEnabled, const int xMinorMax, bool update = true );
69 void setYGrid( bool yMajorEnabled, const int yMajorMax,
70 bool yMinorEnabled, const int yMinorMax,
71 bool y2MajorEnabled, const int y2MajorMax,
72 bool y2MinorEnabled, const int y2MinorMax, bool update = true );
73 void setTitle( bool enabled, const QString& title, ObjectType type, bool update = true );
74 QString getTitle( ObjectType type ) const;
76 void setFont( const QFont& font, ObjectType type, bool update = true );
77 void setHorScaleMode( const int mode, bool update = true );
78 int getHorScaleMode() const { return myXMode; }
79 void setVerScaleMode( const int mode, bool update = true );
80 int getVerScaleMode() const { return myYMode; }
82 bool isModeHorLinear();
83 bool isModeVerLinear();
84 bool isLegendShow() { return myShowLegend; };
87 int testOperation( const QMouseEvent& );
88 void readPreferences();
89 void writePreferences();
90 QString getInfo( const QPoint& pnt );
91 virtual void wheelEvent( QWheelEvent* );
98 void onViewGlobalPan();
101 void onChangeBackground();
104 void plotMousePressed( const QMouseEvent& );
105 void plotMouseMoved( const QMouseEvent& );
106 void plotMouseReleased( const QMouseEvent& );
109 void vpModeHorChanged();
110 void vpModeVerChanged();
111 void vpCurveChanged();
112 void contextMenuRequested( QContextMenuEvent *e );
115 Plot2d_Plot2d* myPlot;
125 QString myTitle, myXTitle, myYTitle, myY2Title;
126 bool myTitleEnabled, myXTitleEnabled, myYTitleEnabled, myY2TitleEnabled;
127 bool myXGridMajorEnabled, myYGridMajorEnabled, myY2GridMajorEnabled;
128 bool myXGridMinorEnabled, myYGridMinorEnabled, myY2GridMinorEnabled;
129 int myXGridMaxMajor, myYGridMaxMajor, myY2GridMaxMajor;
130 int myXGridMaxMinor, myYGridMaxMinor, myY2GridMaxMinor;
131 int myXMode, myYMode;
132 double myXDistance, myYDistance, myYDistance2;
136 class Plot2d_Plot2d : public QwtPlot
139 Plot2d_Plot2d( QWidget* parent );
142 void getNextMarker( QwtSymbol::Style& typeMarker, QColor& color, Qt::PenStyle& typeLine );
143 QwtLegend* getLegend() {
144 #if QWT_VERSION < 0x040200
147 return legend(); /* mpv: porting to the Qwt 4.2.0 */
150 virtual QSize sizeHint() const;
151 virtual QSizePolicy sizePolicy() const;
152 virtual QSize minimumSizeHint() const;
155 bool existMarker( const QwtSymbol::Style typeMarker, const QColor& color, const Qt::PenStyle typeLine );
158 QValueList<QColor> myColors;