PlotMSPlotter.qo.h

Go to the documentation of this file.
00001 //# PlotMSPlotter.qo.h: GUI for plotms.
00002 //# Copyright (C) 2008
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: $
00027 #ifndef PLOTMSPLOTTER_QO_H_
00028 #define PLOTMSPLOTTER_QO_H_
00029 
00030 #include <plotms/Gui/PlotMSPlotter.ui.h>
00031 
00032 #include <casaqt/QtUtilities/QtActionGroup.qo.h>
00033 #include <graphics/GenericPlotter/PlotFactory.h>
00034 #include <plotms/Actions/PlotMSAction.h>
00035 #include <plotms/Gui/PlotMSAnnotator.h>
00036 #include <plotms/Client/Client.h>
00037 #include <plotms/PlotMS/PlotMSConstants.h>
00038 
00039 #include <QMainWindow>
00040 #include <QToolButton>
00041 
00042 namespace casa {
00043 
00044 //# Forward Declarations
00045 class QtProgressWidget;
00046 class PlotMSApp;
00047 class PlotMSAnnotatorTab;
00048 class PlotMSFlaggingTab;
00049 class PlotMSOptionsTab;
00050 class PlotMSPlotTab;
00051 class PlotMSExportTab;
00052 class PlotMSThread;
00053 class PlotMSToolsTab;
00054 class PlotMSDataSummaryTab;
00055 
00056 
00057 // High(ish)-level plotter class that manages the GUI (semi-) transparently to
00058 // the rest of PlotMS.
00059 class PlotMSPlotter : public QMainWindow, Ui::PlotterWindow,
00060                       public PlotDrawWatcher, public Client {
00061     Q_OBJECT
00062     
00063 public:
00064 
00065     //Methods from the client interface
00066     virtual bool isActionEnabled( PlotMSAction::Type type ) const;
00067 
00068     virtual vector<PlotMSPlot*> getCurrentPlots() const;
00069     virtual bool plot();
00070     virtual vector<vector<PMS::Axis> > getSelectedLoadAxes() const;
00071     virtual vector<vector<PMS::Axis> > getSelectedReleaseAxes() const;
00072     virtual PlotMSFlagging getFlagging() const;
00073     virtual bool isInteractive() const;
00074         virtual void canvasAdded( PlotCanvasPtr& canvas );
00075         virtual void setAnnotationModeActive( PlotMSAction::Type type, bool active );
00076         virtual vector<String> getFiles() const;
00077 
00078 
00079         // Static //
00080     
00081     // Returns "about" text for the given implementation, using HTML or not.
00082     static String aboutText(Plotter::Implementation implementation,
00083                             bool useHTML = true);
00084     
00085     
00086     // Non-Static //
00087     
00088     // Constructor that creates a plotter with the given parent using the given
00089     // implementation.
00090     PlotMSPlotter(PlotMSApp* parent,
00091                   Plotter::Implementation impl = Plotter::DEFAULT);
00092     
00093     // Destructor.
00094     ~PlotMSPlotter();
00095     
00096     
00097     // Accessor methods.
00098     // <group>
00099     PlotMSApp* getParent() { return itsParent_; }
00100 
00101     QtProgressWidget* getProgressWidget() { return itsThreadProgress_; }
00102 
00103     PlotMSAnnotator& getAnnotator() { return itsAnnotator_; }
00104     // </group>
00105 
00106     virtual bool isDrawing() const;
00107     virtual bool isClosed() const;
00108 
00109     // Execution Methods //
00110     void setShowProgress( bool showProgressDialog);
00111     // Shows/hides the GUI.
00112     virtual void showGUI(bool show = true);
00113     
00114     // Returns true if the GUI is currently visible, false otherwise.
00115     virtual bool guiShown() const;
00116     
00117     // Enters the plotter's execution loop, and returns its return value.
00118     // Only during this execution loops will GUI windows be shown and
00119     // GUI events be handled.  The execution loop ends when the user clicks
00120     // the "close" or "quit" buttons.  This method can be called multiple
00121     // times.
00122     virtual int execLoop();
00123     
00124 
00125     
00126     // Runs the given operation thread, keeping GUI and progress information
00127     // synchronized as necessary.  The given thread will be deleted upon
00128     // completion.
00129     virtual void doThreadedOperation(/*PlotMSThread**/ThreadController* thread);
00130     
00131     // Implements PlotDrawWatcher::canvasDrawBeginning().
00132     bool canvasDrawBeginning(PlotOperationPtr drawOperation,
00133                 bool drawingIsThreaded, int drawnLayersFlag);
00134     virtual ThreadController* getThreadController( PlotMSAction::Type type,
00135                 PMSPTMethod postThreadMethod = NULL, PlotMSPlot* plot = NULL,
00136                 int index = -1 );
00137     
00138     // GUI Methods //
00139     
00140     // Shows/Hides the "iteration" widgets and actions on the GUI.
00141     void showIterationButtons(bool show);
00142     
00143     // Pops up a dialog to ask the user the given question with the given
00144     // window title.  Returns true if the user says "Yes"; false for "No" or
00145     // otherwise rejecting the dialog.
00146     bool showQuestion(const String& message, const String& title);
00147     
00148 
00149 
00150     
00151     
00152     // Plotter Customization Methods //
00153     
00154     // Sets the window title to the given.
00155     void setWindowTitle(const String& windowTitle);
00156     
00157     // Sets the status bar text to the given.
00158     void setStatusText(const String& statusText);
00159     
00160     // Clears the status bar text.
00161     void clearStatusText() { setStatusText(""); }
00162     
00163     // Overrides QMainWindow::setToolButtonStyle().
00164     void setToolButtonStyle(Qt::ToolButtonStyle style);
00165     
00166     
00167     // Action Methods //
00168     
00169     // Returns a map between PlotMSApp actions and the QActions associated with
00170     // them in the GUI.  Triggering the QActions will trigger the proper PlotMSApp
00171     // action, and the QAction will be kept properly checked as needed.
00172     const QMap<PlotMSAction::Type, QAction*>& plotActionMap() const;
00173     
00174     // Synchronizes the given button with the given action type.  (See
00175     // QtActionSynchronizer class.)
00176     void synchronizeAction(PlotMSAction::Type action, QAbstractButton* button);
00177     
00178     // Gets/Sets the text for the QAction associated with the given PlotMSApp
00179     // action.
00180     // <group>
00181     String actionText(PlotMSAction::Type type);
00182     void setActionText(PlotMSAction::Type type, const String& text);
00183     // </group>
00184     
00185     // Gets/Sets whether the QAction associated with the given PlotMSApp action
00186     // is checked.  Has no effect on actions that are not checkable.
00187     // <group>
00188     bool actionIsChecked(PlotMSAction::Type type) const;
00189     void setActionIsChecked(PlotMSAction::Type type, bool checked,
00190             bool alsoTriggerAction = false);
00191     // </group>
00192     
00193     // export a plot to a file
00194     virtual bool exportPlot(const PlotExportFormat& format, const bool async);
00195     virtual void setFlagging(PlotMSFlagging flag);
00196     virtual void gridSizeChanged( int rowCount, int colCount );
00197 
00198 public slots:
00199     // Shows the given error/warning message in a GUI window.
00200     virtual void showError(const String& message, const String& title, bool isWarning);
00201     
00202     // Shows the given informational message in a GUI window.
00203     virtual void showMessage(const String& message, const String& title, bool warning = false);
00204    
00205     // Clears the message in a GUI window.
00206     virtual void clearMessage() { clearStatusText(); }
00207  
00208     // Slot for showing an "about" dialog.
00209     void showAbout();
00210     
00211     // Take any clean-up actions before a Plot is made
00212     // 1) unclick any zoom, pan, etc buttons to avoid bug in zoom stack
00213     // 2) ... anything else needed in the future ...
00214     void prepareForPlotting();
00215     
00216     virtual bool close();
00217 
00218     
00219 protected:
00220     // Overrides QWidget::closeEvent(), in case we're dealing with a plotter
00221     // that isn't Qt and thus is in its own window (and possibly its own
00222     // execution loop).
00223     void closeEvent(QCloseEvent* event);
00224     
00225 
00226 
00227 private:
00228     // PlotMSApp parent.
00229     PlotMSApp* itsParent_;
00230     
00231     // Flag for whether the underlying Plotter is Qt-based or not.
00232     bool isQt_;
00233 
00234     // Flag for whether the widget is open or not
00235     bool isClosed_;
00236     
00237 
00238     
00239 
00240     // Widgets to be enabled/disabled during threading.
00241     QList<QWidget*> itsEnableWidgets_;
00242     
00243     //Plot tab
00244     PlotMSDataSummaryTab* itsPlotTab_;
00245 
00246     // Flagging tab (on the plot tab).
00247     PlotMSFlaggingTab* itsFlaggingTab_;
00248     
00249     // Tools tab.
00250     PlotMSToolsTab* itsToolsTab_;
00251     
00252     // Annotator tab.
00253     PlotMSAnnotatorTab* itsAnnotatorTab_;
00254     
00255     // Options tab.
00256     PlotMSOptionsTab* itsOptionsTab_;
00257 
00258     // Tool buttons on the tabs.
00259     QList<QToolButton*> itsToolButtons_;
00260     
00261     // Widget for displaying thread progress.
00262     QtProgressWidget* itsThreadProgress_;
00263 
00264     // Current thread (or NULL for none).
00265     PlotMSThread* itsCurrentThread_;
00266     
00267     // Waiting threads.
00268     vector<PlotMSThread*> itsWaitingThreads_;
00269     
00270     // Map between PlotMSApp actions and QActions.
00271     QMap<PlotMSAction::Type, QAction*> itsActionMap_;
00272     
00273     // Action synchronizer.
00274     QtActionSynchronizer itsActionSynchronizer_;
00275     
00276     // Annotator tool.
00277     PlotMSAnnotator itsAnnotator_;
00278     
00279     // "About" string.
00280     QString itsAboutString_;
00281     
00282     bool showProgressWidget;
00283 
00284     QTabWidget* tabWidget;
00285 
00286     
00287     bool _triggerAction(/*PlotMSAction& action*/PlotMSAction::Type type);
00288     
00289     // Initializes the plotter with the given implementation.  MUST be called
00290     // from constructors.
00291     void initialize(Plotter::Implementation impl);
00292     
00293 private slots:    
00294     // Method for when an action has been triggered.
00295     void action_() { action(dynamic_cast<QAction*>(sender())); }
00296     
00297     // Method for when the given action has been triggered.
00298     void action(QAction* which);
00299 
00300     // Slot for when the currently running thread is finished.  Performs
00301     // cleanup and starts next waiting thread if applicable.
00302     void currentThreadFinished();
00303 
00304     //Summarize an MS
00305         void summarize();
00306 
00307         //Export the current plots
00308         void exportPlots();
00309 
00310         void tabChanged( );
00311 };
00312 typedef CountedPtr<PlotMSPlotter> PlotMSPlotterPtr;
00313 
00314 }
00315 
00316 #endif /* PLOTMSPLOTTER_QO_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1