Go to the documentation of this file.00001 #ifndef DragableWidget_H
00002 #define DragableWidget_H
00003
00004 #include <map>
00005 #include <QObject>
00006 #include <QTextEdit>
00007 #include <qwt_plot.h>
00008 #include <qwt_plot_curve.h>
00009 #include <qwt_plot_grid.h>
00010 #include <qwt_symbol.h>
00011 #include <qwt_legend.h>
00012 #include <deque>
00013 #include <QMessageBox>
00014 #include <QTime>
00015 #include "plotmagnifier.h"
00016 #include "plotzoomer.h"
00017 #include <qwt_plot_panner.h>
00018 #include <QDomDocument>
00019 #include "timeseries_qwt.h"
00020 #include "customtracker.h"
00021 #include "axis_limits_dialog.h"
00022 #include <qwt_plot_legenditem.h>
00023
00024 class PlotWidget : public QwtPlot
00025 {
00026 Q_OBJECT
00027
00028 public:
00029
00030 PlotWidget(PlotDataMap& datamap, QWidget *parent=0);
00031 virtual ~PlotWidget();
00032
00033 bool addCurve(const QString& name, bool do_replot );
00034
00035 bool isEmpty() const;
00036
00037 const std::map<QString, std::shared_ptr<QwtPlotCurve> > &curveList() const;
00038
00039 QDomElement xmlSaveState(QDomDocument &doc) const;
00040
00041 bool xmlLoadState(QDomElement &element, QMessageBox::StandardButton* answer);
00042
00043 QRectF currentBoundingRect() const;
00044
00045 PlotData::RangeTime getMaximumRangeX() const;
00046
00047 PlotData::RangeValue getMaximumRangeY( PlotData::RangeTime range_X, bool absolute_time ) const;
00048
00049 void setScale( QRectF rect, bool emit_signal );
00050
00051 void reloadPlotData( );
00052
00053 void changeAxisX(QString curve_name);
00054
00055 bool isXYPlot() const;
00056
00057 protected:
00058 virtual void dragEnterEvent(QDragEnterEvent *event) ;
00059 virtual void dragMoveEvent(QDragMoveEvent *event) ;
00060 virtual void dropEvent(QDropEvent *event) ;
00061 virtual bool eventFilter(QObject *obj, QEvent *event);
00062
00063
00064 signals:
00065 void swapWidgetsRequested(PlotWidget* source, PlotWidget* destination);
00066 void rectChanged(PlotWidget* self, QRectF rect );
00067 void undoableChange();
00068 void trackerMoved(QPointF pos);
00069
00070 public slots:
00071
00072 void updateCurves(bool force);
00073
00074 void replot() ;
00075
00076 void detachAllCurves();
00077
00078 void zoomOut(bool emit_signal);
00079
00080 void on_zoomOutHorizontal_triggered(bool emit_signal = true);
00081
00082 void on_zoomOutVertical_triggered(bool emit_signal = true);
00083
00084 void removeCurve(const QString& name);
00085
00086 void activateLegent(bool activate);
00087
00088 void activateGrid(bool activate);
00089
00090 void configureTracker(CurveTracker::Parameter val);
00091
00092 void enableTracker(bool enable);
00093
00094 void setTrackerPosition(double abs_time);
00095
00096 void on_changeTimeOffset(double offset);
00097
00098 private slots:
00099
00100 void on_noTransform_triggered(bool checked );
00101
00102 void on_1stDerivativeTransform_triggered(bool checked);
00103
00104 void on_2ndDerivativeTransform_triggered(bool checked);
00105
00106 void on_convertToXY_triggered(bool checked);
00107
00108 void on_savePlotToFile();
00109
00110 void on_editAxisLimits_triggered();
00111
00112 private slots:
00113 void launchRemoveCurveDialog();
00114 void canvasContextMenuTriggered(const QPoint &pos);
00115 void on_changeColorsDialog_triggered();
00116 void on_changeColor(QString curve_name, QColor new_color);
00117 void on_showPoints_triggered(bool checked);
00118 void on_externallyResized(const QRectF &new_rect);
00119
00120
00121 private:
00122 std::map<QString, std::shared_ptr<QwtPlotCurve> > _curve_list;
00123 std::map<QString, QwtPlotMarker*> _point_marker;
00124
00125 QAction *_action_removeCurve;
00126 QAction *_action_removeAllCurves;
00127 QAction *_action_changeColorsDialog;
00128 QAction *_action_showPoints;
00129 QAction *_action_zoomOutHorizontally;
00130 QAction *_action_zoomOutVertically;
00131 QAction *_action_noTransform;
00132 QAction *_action_1stDerivativeTransform;
00133 QAction *_action_2ndDerivativeTransform;
00134 QAction *_action_phaseXY;
00135 QAction *_action_saveToFile;
00136 QAction *_action_editLimits;
00137
00138 PlotZoomer* _zoomer;
00139 PlotMagnifier* _magnifier;
00140 QwtPlotPanner* _panner;
00141
00142 CurveTracker* _tracker;
00143 QwtPlotLegendItem* _legend;
00144 QwtPlotGrid* _grid;
00145
00146 PlotDataMap& _mapped_data;
00147 TimeseriesQwt::Transform _current_transform;
00148
00149 void buildActions();
00150 void buildLegend();
00151
00152 int _fps_counter;
00153 QTime _fps_timeStamp;
00154 bool _show_line_and_points;
00155
00156 void setDefaultRangeX();
00157
00158 PlotDataPtr _axisX;
00159
00160 double _time_offset;
00161
00162 PlotData::RangeValue _custom_Y_limits;
00163
00164 AxisLimitsDialog* _axis_limits_dialog;
00165
00166 };
00167
00168 #endif