casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
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 
00032 #include <map>
00033 
00034 #include <casa/namespace.h>
00035 using namespace std;
00036 
00037 namespace casa {
00038 
00039 //# Forward declarations
00040 class PlotMSApp;
00041 class PlotMSPlot;
00042 
00043 
00044 // ABSTRACT CLASSES //
00045 
00046 // Class that implements actions that operate on PlotMS.  Actions get their
00047 // type from the Type enum and their parameters (if needed) from mappings from
00048 // Strings to values.  Current parameter value types are: PlotMSPlot*, bool,
00049 // String, int, and vector<PMS::Axis>.
00050 class PlotMSAction {
00051 public:
00052     // Static //
00053 
00054     // Enum for implemented actions.
00055     enum Type {
00056         // Selection actions //
00057 
00058         // Flag the selected regions.   Operates on all visible canvases AT THE
00059         // TIME of the call to doAction().
00060         // No required parameters.
00061         SEL_FLAG,
00062 
00063         // Unflag the selected regions.   Operates on all visible canvases AT
00064         // THE TIME of the call to doAction().
00065         // No required parameters.
00066         SEL_UNFLAG,
00067 
00068         // Locate on the selected regions.   Operates on all visible canvases
00069         // AT THE TIME of the call to doAction().
00070         // No required parameters.
00071         SEL_LOCATE,
00072 
00073         // Get metadata of points in the selected regions.  Operates on all 
00074         // visible canvases AT THE TIME of the call to doAction().
00075         // No required parameters.
00076         SEL_INFO,
00077 
00078         // Clear the selected regions.   Operates on all visible canvases AT
00079         // THE TIME of the call to doAction().
00080         // No required parameters.
00081         SEL_CLEAR_REGIONS,
00082 
00083 
00084         // Iteration actions //
00085 
00086         // Go to the first page of iteration.
00087         // No required parameters.
00088         // NOT IMPLEMENTED.
00089         ITER_FIRST,
00090 
00091         // Go to the previous page of iteration.
00092         // No required parameters.
00093         // NOT IMPLEMENTED.
00094         ITER_PREV,
00095 
00096         // Go to the next page of iteration.
00097         // No required parameters.
00098         // NOT IMPLEMENTED.
00099         ITER_NEXT,
00100 
00101         // Go to the last page of iteration.
00102         // No required parameters.
00103         // NOT IMPLEMENTED.
00104         ITER_LAST,
00105 
00106 
00107         // Tool actions //
00108 
00109         // Turns on/off the mark regions tool.  Operates on all canvases of all
00110         // plots AT THE TIME of the call to doAction().  Only one of the mark
00111         // regions, zoom, pan, and annotate tools can be turned on at one time.
00112         // Required parameters: P_ON_OFF.
00113         TOOL_MARK_REGIONS,
00114         
00115         // Turns on/off the subtract regions tool.  
00116         // works like MARK REGIONS, but where user drags, all regions within are deleted.
00117         // (note: CAS-1971 DSW)
00118         TOOL_SUBTRACT_REGIONS,
00119 
00120         // Turns on/off the zoom tool.  Operates on all canvases of all plots
00121         // AT THE TIME of the call to doAction().  Only one of the mark
00122         // regions, zoom, pan, and annotate tools can be turned on at one time.
00123         // Required parameters: P_ON_OFF.
00124         TOOL_ZOOM,
00125 
00126         // Turns on/off the pan tool.  Operates on all canvases of all plots AT
00127         // THE TIME of the call to doAction().  Only one of the mark regions,
00128         // zoom, pan, and annotate tools can be turned on at one time.
00129         // Required parameters: P_ON_OFF.
00130         TOOL_PAN,
00131         
00132         // Turns on/off the annotator tool's different modes.  Operates on all
00133         // canvases of all plots AT THE TIME of the call to doAction().  Only
00134         // one of the mark regions, zoom, pan, and annotate tools can be turned
00135         // on at one time.
00136         // Required parameters: P_ON_OFF.
00137         // <group>
00138         TOOL_ANNOTATE_TEXT,
00139         TOOL_ANNOTATE_RECTANGLE,
00140         // </group>
00141         
00142         // Turns on/off the tracker tool hover function.  Operates on all
00143         // canvases of all plots AT THE TIME of the call to doAction().
00144         // Required parameters: P_ON_OFF.
00145         TRACKER_ENABLE_HOVER,
00146 
00147         // Turns on/off the tracker tool display function.  Operates on all
00148         // canvases of all plots AT THE TIME of the call to doAction().
00149         // Required parameters: P_ON_OFF.
00150         TRACKER_ENABLE_DISPLAY,
00151 
00152 
00153         // Stack actions //
00154 
00155         // Goes back in the zoom/pan stack.  Operates on all visible canvases
00156         // AT THE TIME of the call to doAction().
00157         // No required parameters.
00158         STACK_BACK,
00159 
00160         // Goes to the base of the zoom/pan stack.  Operates on all visible
00161         // canvases AT THE TIME of the call to doAction().
00162         // No required parameters.
00163         STACK_BASE,
00164 
00165         // Goes forward in the zoom/pan stack.  Operates on all visible
00166         // canvases AT THE TIME of the call to doAction().
00167         // No required parameters.
00168         STACK_FORWARD,
00169 
00170 
00171         // Cache actions //
00172 
00173         // Loads axes into the cache.  Operates on a single PlotMSPlot.
00174         // Required parameters: P_PLOT, P_AXES.
00175         CACHE_LOAD,
00176 
00177         // Releases axes from the cache.  Operates on a single PlotMSPlot.
00178         // Required parameters: P_PLOT, P_AXES.
00179         // NOT IMPLEMENTED.
00180         CACHE_RELEASE,
00181 
00182 
00183         // Plot actions //
00184         
00185         // Display MS summary info for the current plot.
00186         // Required parameters: P_PLOT.
00187         MS_SUMMARY,
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 
00201         // Plotter actions //
00202 
00203         // Holds/releases drawing for all canvases in the PlotMSPlotter.
00204         // Required parameters: P_ON_OFF.
00205         HOLD_RELEASE_DRAWING,
00206 
00207         // Clears all plots and canvases from the PlotMSPlotter.
00208         // No required parameters.
00209         CLEAR_PLOTTER,
00210 
00211         // Quits PlotMS.
00212         // No required parameters.
00213         QUIT
00214     };
00215 
00216     // Parameter names.
00217     // <group>
00218     static const String P_PLOT;    // Type: PlotMSPlot*
00219     static const String P_ON_OFF;  // Type: bool
00220     static const String P_AXES;    // Type: vector<PMS::Axis>
00221     static const String P_FILE;    // Type: String
00222     static const String P_FORMAT;  // Type: String
00223     static const String P_HIGHRES; // Type: bool
00224     static const String P_DPI;     // Type: int
00225     static const String P_WIDTH;   // Type: int
00226     static const String P_HEIGHT;  // Type: int
00227     static const String P_INTERACTIVE;  // Type: bool
00228 
00229     // </group>
00230     
00231     
00232     // Returns true if the given type requires the given parameter, false
00233     // otherwise.
00234     static bool requires(Type type, const String& parameter);
00235 
00236 
00237     // Non-Static //
00238 
00239     // Constructor.
00240     PlotMSAction(Type type);
00241 
00242     // Destructor.
00243     ~PlotMSAction();
00244 
00245 
00246     // Returns the action type.
00247     Type type() const;
00248 
00249     // Returns true if the action is valid or not.  Invalid actions should not
00250     // be executed.
00251     bool isValid() const;
00252 
00253     // Sets the given parameter to the given value.
00254     // <group>
00255     void setParameter(const String& parameter, PlotMSPlot* value);
00256     void setParameter(const String& parameter, bool value);
00257     void setParameter(const String& parameter, const String& value);
00258     void setParameter(const String& parameter, int value);
00259     void setParameter(const String& parameter, const vector<PMS::Axis>& value);
00260     // </group>
00261 
00262     // Performs the action, using the given PlotMSApp, and returns true for
00263     // success or false or failure.
00264     bool doAction(PlotMSApp* plotms);
00265     bool doActionWithResponse(PlotMSApp* plotms, Record &retval);
00266 
00267     // Returns the result of doAction(), if applicable.  Usually this is used
00268     // to return the error/reason why the action failed.
00269         const String& doActionResult() const;
00270 
00271 private:
00272         // Action type.
00273         Type itsType_;
00274 
00275         // Action parameters.
00276         // <group>
00277         map<String, PlotMSPlot*> itsPlotValues_;
00278         map<String, bool> itsBoolValues_;
00279         map<String, String> itsStringValues_;
00280         map<String, int> itsIntValues_;
00281         map<String, vector<PMS::Axis> > itsAxesValues_;
00282         // </group>
00283 
00284         // Result of doAction, if applicable.
00285         String itsDoActionResult_;
00286 
00287 
00288         // Returns true if the given parameter is defined for the given type, false
00289         // otherwise.
00290         // <group>
00291         bool isDefinedPlot(const String& parameter) const;
00292         bool isDefinedBool(const String& parameter) const;
00293         bool isDefinedString(const String& parameter) const;
00294         bool isDefinedInt(const String& parameter) const;
00295         bool isDefinedAxes(const String& parameter) const;
00296         // </group>
00297 
00298         // Returns the value for the given parameter.  Not valid if the proper
00299         // isDefined method returns false.
00300         // <group>
00301         PlotMSPlot* valuePlot(const String& parameter);
00302         const PlotMSPlot* valuePlot(const String& parameter) const;
00303         bool valueBool(const String& parameter) const;
00304         const String& valueString(const String& parameter) const;
00305         int valueInt(const String& parameter) const;
00306         const vector<PMS::Axis>& valueAxes(const String& parameter) const;
00307         // </group>
00308 };
00309 
00310 }
00311 
00312 #endif /* PLOTMSACTION_H_ */