USGS

Isis 3.0 Developer's Reference (API)

Home

PlotWindow.h

Go to the documentation of this file.
00001 #ifndef PlotWindow_h
00002 #define PlotWindow_h
00003 
00027 // This is needed for the QVariant macro
00028 #include <QMetaType>
00029 
00030 // This is the parent
00031 #include "MainWindow.h"
00032 
00033 // This is for an enum inside of plot curve
00034 #include "PlotCurve.h"
00035 
00036 class QwtPlot;
00037 class QwtPlotGrid;
00038 class QwtPlotSpectrogram;
00039 class QwtPlotZoomer;
00040 
00041 class QDockWidget;
00042 class QListWidgetItem;
00043 class QLineEdit;
00044 class QComboBox;
00045 
00046 template <typename A, typename B> class QPair;
00047 
00048 namespace Isis {
00049   class MdiCubeViewport;
00050   class CubePlotCurve;
00051   class PvlKeyword;
00052   class TableMainWindow;
00053 
00072   class PlotWindow : public MainWindow {
00073       Q_OBJECT
00074 
00075     public:
00080       enum MenuOptions {
00082         ShowHideMarkersMenuOption  = 1,
00087         ShowHideCurvesMenuOption   = 2,
00092         ShowTableMenuOption        = 4,
00098         SaveMenuOption             = 8,
00102         PrintMenuOption            = 16,
00108         TrackMenuOption            = 32,
00113         BackgroundSwitchMenuOption = 64,
00118         ShowHideGridMenuOption     = 128,
00123         RenameLabelsMenuOption     = 256,
00127         SetDisplayRangeMenuOption  = 512,
00131         ResetScaleMenuOption       = 1024,
00137         ClearPlotMenuOption        = 2048,
00141         DefaultHelpMenuOption      = 4096,
00147         LineFitMenuOption          = 8192,
00151         AllMenuOptions = ShowHideMarkersMenuOption | ShowHideCurvesMenuOption |
00152                          ShowTableMenuOption | SaveMenuOption |
00153                          PrintMenuOption | TrackMenuOption |
00154                          BackgroundSwitchMenuOption | ShowHideGridMenuOption |
00155                          RenameLabelsMenuOption | SetDisplayRangeMenuOption |
00156                          ResetScaleMenuOption | ClearPlotMenuOption |
00157                          DefaultHelpMenuOption | LineFitMenuOption
00158       };
00159 
00160       PlotWindow(QString title, PlotCurve::Units xAxisUnits,
00161                  PlotCurve::Units yAxisUnits, QWidget *parent,
00162                  MenuOptions optionsToProvide = AllMenuOptions);
00163       ~PlotWindow();
00164       virtual void add(CubePlotCurve *pc);
00165       virtual void clearPlotCurves();
00166 
00167       bool canAdd(CubePlotCurve *curveToTest) const;
00168       QColor plotBackgroundColor() const;
00169       QList<CubePlotCurve *> plotCurves();
00170       QList<const CubePlotCurve *> plotCurves() const;
00171       QList<QwtPlotSpectrogram *> plotSpectrograms();
00172       QList<const QwtPlotSpectrogram *> plotSpectrograms() const;
00173       QString plotTitle() const;
00174       bool userCanAddCurves() const;
00175       PlotCurve::Units xAxisUnits() const;
00176       PlotCurve::Units yAxisUnits() const;
00177 
00178       virtual void paint(MdiCubeViewport *vp, QPainter *painter);
00179       void replot();
00180       void setAxisLabel(int axisId, QString title);
00181       void setPlotBackground(QColor c);
00182       void setPlotTitle(QString pt);
00183       void setUserCanAddCurves(bool);
00184       void showWindow();
00185       virtual void update(MdiCubeViewport *activeViewport);
00186 
00187       static QString defaultWindowTitle();
00188 
00189 
00190     signals:
00195       void closed();
00197       void plotChanged();
00198 
00199       void requestFillTable();
00200 
00201     public slots:
00202       void clearPlot();
00203       void createBestFitLine();
00204       void printPlot();
00205       void changePlotLabels();
00206       void savePlot();
00207       void setDefaultRange();
00208       void setLabels();
00209       void setUserValues();
00210       void showHideAllMarkers();
00211       void showHideAllCurves();
00212       void resetScale();
00213       void showHideGrid();
00214       void showHelp();
00215       void showTable();
00216       void switchBackground();
00217       void trackerEnabled();
00218 
00219       void scheduleFillTable();
00220       void fillTable();
00221 
00222     protected:
00223       void createWidgets(MenuOptions optionsToProvide);
00224       void disableAxisAutoScale();
00225       virtual void dragEnterEvent(QDragEnterEvent *event);
00226       virtual void dropEvent(QDropEvent *event);
00227       virtual bool eventFilter(QObject *o, QEvent *e);
00228       void mousePressEvent(QObject *object, QMouseEvent *e);
00229 
00230       QwtPlot *plot();
00231       void setMenus(QList<QMenu *> menus, QList<QAction *> actions);
00232       QwtPlotZoomer *zoomer();
00233 
00234     private slots:
00235       void autoScaleCheckboxToggled();
00236       void onClipboardChanged();
00237       void pasteCurve();
00238 
00239     private:
00240       QPair<double, double> findDataRange(int axisId) const;
00241       static bool numericStringLessThan(QString left, QString right);
00242       bool userCanAddCurve(const QMimeData *curve);
00243       void updateVisibility(PlotCurve *curve);
00244       void setupDefaultMenu(MenuOptions optionsToProvide);
00245 
00247       QWidget       *m_parent;
00249       QwtPlotZoomer *m_zoomer;
00251       QwtPlotGrid   *m_grid;
00253       QCheckBox     *m_autoScaleCheckBox;
00255       QCheckBox     *m_xLogCheckBox;
00257       QCheckBox     *m_yLogCheckBox;
00259       QLineEdit     *m_xMinEdit;
00261       QLineEdit     *m_xMaxEdit;
00263       QLineEdit     *m_yMinEdit;
00265       QLineEdit     *m_yMaxEdit;
00267       QLineEdit     *m_xAxisText;
00269       QLineEdit     *m_yAxisText;
00271       QLineEdit     *m_plotTitleText;
00272 
00274       QMenuBar      *m_menubar;
00275 
00281       QAction       *m_pasteAct;
00282 
00284       QPointer<QAction> m_action;
00286       QPointer<QAction> m_showHideAllCurves;
00288       QPointer<QAction> m_showHideAllMarkers;
00290       QPointer<QAction> m_showHideGrid;
00291 
00293       PlotCurve::Units m_xAxisUnits;
00295       PlotCurve::Units m_yAxisUnits;
00296 
00298       bool m_allowUserToAddCurves;
00300       bool m_autoscaleAxes;
00301 
00302       QwtPlot *m_plot;
00303       TableMainWindow *m_tableWindow;
00304       QToolBar *m_toolBar;
00305 
00306       bool m_scheduledFillTable;
00307    };
00308 };
00309 
00311 Q_DECLARE_METATYPE(Isis::PlotWindow *);
00312 
00313 // There isn't a great place to put this currently since it's not a class we
00314 //   can manage the header for.
00316 Q_DECLARE_METATYPE(QwtPlotSpectrogram *);
00317 
00318 #endif
00319