PlotMSAction.h

Go to the documentation of this file.
00001 //# PlotMSAction.h: Actions on plotms that can be triggered.
00002 //# Copyright (C) 2009
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 PLOTMSACTION_H_
00028 #define PLOTMSACTION_H_
00029 
00030 #include <plotms/PlotMS/PlotMSConstants.h>
00031 #include <plotms/Threads/ThreadController.h>
00032 
00033 namespace casa {
00034 
00035 //# Forward declarations
00036 class PlotMSApp;
00037 class PlotMSPlot;
00038 class Client;
00039 class BackgroundThread;
00040 
00041 // ABSTRACT CLASSES //
00042 
00043 // Class that implements actions that operate on PlotMS.  Actions get their
00044 // type from the Type enum and their parameters (if needed) from mappings from
00045 // Strings to values.  Current parameter value types are: PlotMSPlot*, bool,
00046 // String, int, and vector<PMS::Axis>.
00047 class PlotMSAction {
00048 public:
00049     // Static //
00050         // Enum for implemented actions.
00051                 enum Type {
00052                         // Selection actions //
00053 
00054                         // Flag the selected regions.   Operates on all visible canvases AT THE
00055                         // TIME of the call to doAction().
00056                         // No required parameters.
00057                         SEL_FLAG,
00058 
00059                         // Unflag the selected regions.   Operates on all visible canvases AT
00060                         // THE TIME of the call to doAction().
00061                         // No required parameters.
00062                         SEL_UNFLAG,
00063 
00064                         // Locate on the selected regions.   Operates on all visible canvases
00065                         // AT THE TIME of the call to doAction().
00066                         // No required parameters.
00067                         SEL_LOCATE,
00068 
00069                         // Get metadata of points in the selected regions.  Operates on all
00070                         // visible canvases AT THE TIME of the call to doAction().
00071                         // No required parameters.
00072                         SEL_INFO,
00073 
00074                         // Clear the selected regions.   Operates on all visible canvases AT
00075                         // THE TIME of the call to doAction().
00076                         // No required parameters.
00077                         SEL_CLEAR_REGIONS,
00078 
00079 
00080                         // Iteration actions //
00081 
00082                         // Go to the first page of iteration.
00083                         // No required parameters.
00084                         // NOT IMPLEMENTED.
00085                         ITER_FIRST,
00086 
00087                         // Go to the previous page of iteration.
00088                         // No required parameters.
00089                         // NOT IMPLEMENTED.
00090                         ITER_PREV,
00091 
00092                         // Go to the next page of iteration.
00093                         // No required parameters.
00094                         // NOT IMPLEMENTED.
00095                         ITER_NEXT,
00096 
00097                         // Go to the last page of iteration.
00098                         // No required parameters.
00099                         // NOT IMPLEMENTED.
00100                         ITER_LAST,
00101 
00102 
00103                         // Tool actions //
00104 
00105                         // Turns on/off the mark regions tool.  Operates on all canvases of all
00106                         // plots AT THE TIME of the call to doAction().  Only one of the mark
00107                         // regions, zoom, pan, and annotate tools can be turned on at one time.
00108                         // Required parameters: P_ON_OFF.
00109                         TOOL_MARK_REGIONS,
00110 
00111                         // Turns on/off the subtract regions tool.
00112                         // works like MARK REGIONS, but where user drags, all regions within are deleted.
00113                         // (note: CAS-1971 DSW)
00114                         TOOL_SUBTRACT_REGIONS,
00115 
00116                         // Turns on/off the zoom tool.  Operates on all canvases of all plots
00117                         // AT THE TIME of the call to doAction().  Only one of the mark
00118                         // regions, zoom, pan, and annotate tools can be turned on at one time.
00119                         // Required parameters: P_ON_OFF.
00120                         TOOL_ZOOM,
00121 
00122                         // Turns on/off the pan tool.  Operates on all canvases of all plots AT
00123                         // THE TIME of the call to doAction().  Only one of the mark regions,
00124                         // zoom, pan, and annotate tools can be turned on at one time.
00125                         // Required parameters: P_ON_OFF.
00126                         TOOL_PAN,
00127 
00128                         // Turns on/off the annotator tool's different modes.  Operates on all
00129                         // canvases of all plots AT THE TIME of the call to doAction().  Only
00130                         // one of the mark regions, zoom, pan, and annotate tools can be turned
00131                         // on at one time.
00132                         // Required parameters: P_ON_OFF.
00133                         // <group>
00134                         TOOL_ANNOTATE_TEXT,
00135                         TOOL_ANNOTATE_RECTANGLE,
00136                         // </group>
00137 
00138                         // Turns on/off the tracker tool hover function.  Operates on all
00139                         // canvases of all plots AT THE TIME of the call to doAction().
00140                         // Required parameters: P_ON_OFF.
00141                         TRACKER_ENABLE_HOVER,
00142 
00143                         // Turns on/off the tracker tool display function.  Operates on all
00144                         // canvases of all plots AT THE TIME of the call to doAction().
00145                         // Required parameters: P_ON_OFF.
00146                         TRACKER_ENABLE_DISPLAY,
00147 
00148 
00149                         // Stack actions //
00150 
00151                         // Goes back in the zoom/pan stack.  Operates on all visible canvases
00152                         // AT THE TIME of the call to doAction().
00153                         // No required parameters.
00154                         STACK_BACK,
00155 
00156                         // Goes to the base of the zoom/pan stack.  Operates on all visible
00157                         // canvases AT THE TIME of the call to doAction().
00158                         // No required parameters.
00159                         STACK_BASE,
00160 
00161                         // Goes forward in the zoom/pan stack.  Operates on all visible
00162                         // canvases AT THE TIME of the call to doAction().
00163                         // No required parameters.
00164                         STACK_FORWARD,
00165 
00166 
00167                         // Cache actions //
00168 
00169                         // Loads axes into the cache.  Operates on a single PlotMSPlot.
00170                         // Required parameters: P_PLOT, P_AXES.
00171                         CACHE_LOAD,
00172 
00173                         // Releases axes from the cache.  Operates on a single PlotMSPlot.
00174                         // Required parameters: P_PLOT, P_AXES.
00175                         // NOT IMPLEMENTED.
00176                         CACHE_RELEASE,
00177 
00178 
00179                         // Plot actions //
00180 
00181                         // Display MS summary info for a specific file.
00182                         // Required parameters: P_PLOT.
00183                         MS_SUMMARY,
00184 
00185                         //Show the summary dialog for the plot that allows the user
00186                         //to set up parameters for MS_SUMMARY
00187                         SUMMARY_DIALOG,
00188 
00189                         // Updates any set parameters, which updates the plots.
00190                         // No required parameters.
00191                         PLOT,
00192 
00193                         // Exports a single PlotMSPlot to a file.  If format isn't given, it is
00194                         // set using the file name.  If DPI, width, or height aren't set or are
00195                         // < 0, the default is used.
00196                         // Required parameters: P_PLOT, P_FILE.
00197                         // Optional parameters: P_FORMAT, P_HIGHRES, P_DPI, P_WIDTH, P_HEIGHT.
00198                         PLOT_EXPORT,
00199 
00200                         //Show a dialog that allows the client to set up export parameters.
00201                         EXPORT_DIALOG,
00202 
00203 
00204                         // Plotter actions //
00205 
00206                         // Holds/releases drawing for all canvases in the PlotMSPlotter.
00207                         // Required parameters: P_ON_OFF.
00208                         HOLD_RELEASE_DRAWING,
00209 
00210                         // Clears all plots and canvases from the PlotMSPlotter.
00211                         // No required parameters.
00212                         CLEAR_PLOTTER,
00213 
00214                         // Quits PlotMS.
00215                         // No required parameters.
00216                         QUIT,
00217 
00218                         //Open an ms or cal table for plotting.
00219                         OPEN
00220                 };
00221 
00222     // Non-Static //
00223 
00224     // Constructor.
00225     PlotMSAction( Client * client, PMSPTMethod postThreadMethod = NULL,
00226                 vector<PlotMSPlot*> postThreadObject = vector<PlotMSPlot*>());
00227 
00228     // Destructor.
00229     virtual ~PlotMSAction();
00230 
00231     // Performs the action, using the given PlotMSApp, and returns true for
00232     // success or false or failure.
00233     bool doAction(PlotMSApp* plotms);
00234 
00235     void setUseThreading( bool useThread );
00236 
00237     virtual bool doActionWithResponse(PlotMSApp* plotms, Record &retval);
00238 
00239     // Returns the result of doAction(), if applicable.  Usually this is used
00240     // to return the error/reason why the action failed.
00241         const String& doActionResult() const;
00242 
00243 protected:
00244          bool useThreading;
00245          virtual bool loadParameters();
00246          virtual bool doActionSpecific( PlotMSApp* plotms ) = 0;
00247          void setUpClientCommunication( BackgroundThread* thread, int index );
00248          bool initiateWork( BackgroundThread* thread );
00249          Client* client;
00250          // Action type.
00251          Type itsType_;
00252 
00253          // Result of doAction, if applicable.
00254          String itsDoActionResult_;
00255          ThreadController* threadController;
00256 
00257          vector<PlotMSPlot*> postThreadObject;
00258          PMSPTMethod* postThreadMethod;
00259 private:
00260         // Returns true if the action is valid or not.  Invalid actions should not
00261         // be executed.
00262         bool isValid();
00263 
00264 
00265         PlotMSAction( const PlotMSAction& other );
00266 
00267 };
00268 
00269 }
00270 
00271 #endif /* PLOTMSACTION_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1