casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlotMS.h
Go to the documentation of this file.
1 //# PlotMS.h: Main controller for plotms.
2 //# Copyright (C) 2008
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id: $
27 #ifndef PLOTMS_H_
28 #define PLOTMS_H_
29 
36 #if defined(WITHOUT_DBUS)
38 #endif
39 
40 namespace casa {
41 
42 // Version definitions.
43 // <group>
44 #define PLOTMS_VERSION 0x002250;
45 #define PLOTMS_VERSION_STR "2.25";
46 // </group>
47 
48 
49 //# Forward declarations.
50 class PlotMSDBusApp;
51 class Client;
52 
53 
54 // Controller class for plotms. Handles interactions between the UI and plots.
56 public:
57  // Default constructor that uses default options. If connectToDBus is
58  // true, then the application registers itself with CASA's DBus server
59  // using the PlotMSDBusApp::dbusName() with the current process ID.
60  PlotMSApp(bool connectToDBus = false, bool userGui = true
61 #if defined(WITHOUT_DBUS)
62  , const casacore::String &casapy_address = ""
63 #endif
64  );
65 
66  // Constructor which takes the given parameters. If connectToDBus is true,
67  // then the application registers itself with CASA's DBus server using the
68  // PlotMSDBusApp::dbusName() with the current process ID.
69  PlotMSApp(const PlotMSParameters& params, bool connectToDBus = false, bool userGui = true
70 #if defined(WITHOUT_DBUS)
71  , const casacore::String &casapy_address = ""
72 #endif
73  );
74 
75  // Destructor
76  ~PlotMSApp();
77 
78 
79  // Plotter Methods //
80 
81  // See PlotMSPlotter::showGUI().
82  virtual void showGUI(bool show = true);
83 
84  // See PlotMSPlotter::guiShown().
85  virtual bool guiShown() const;
86 
87  // See PlotMSPlotter::execLoop().
88  int execLoop();
89 
90  // See PlotMSPlotter::showAndExec().
91  int showAndExec(bool show= true);
92 
93  // See PlotMSPlotter::close().
94  void close();
95 
96  //Remove existing plots.
97  virtual void clearPlots();
98 
99  // See PlotMSPlotter::showError().
100  // <group>
101  void showError(const casacore::String& message, const casacore::String& title = "PlotMS Error",
102  bool isWarning = false);
103  void showWarning(const casacore::String& message,
104  const casacore::String& title = "PlotMS Warning");
105  void clearMessage();
106  // </group>
107 
108  // See PlotMSPlotter::showMessage().
109  void showMessage(const casacore::String& message,
110  const casacore::String& title = "PlotMS Message");
111 
112  // Enable/disable annotations in the client
113  void setAnnotationModeActive( PlotMSAction::Type type, bool active );
114 
115  //Enables/disables tool settings on the canvases based
116  //on GUI settings.
117  void resetTools();
118 
119  // Parameter Methods //
120 
121  // Gets/Sets the parameters for this PlotMS.
122  // <group>
123  virtual PlotMSParameters& getParameters();
124  void setParameters(const PlotMSParameters& params);
125  // </group>
126 
127  // Gets/Sets the export parameters for this PlotMS.
128  // <group>
130  void setExportParameters(const PlotMSExportParam& params);
132  void setExportFormat( const PlotExportFormat format );
133  // </group>
134 
135  // Implements PlotMSParametersWatcher::parametersHaveChanged().
137  int updateFlag);
138  virtual PlotSymbolPtr createSymbol (const casacore::String& descriptor,
140  const casacore::String& fillPattern, bool outline );
142  // Logger Methods //
143 
144  // Gets the logger associated with this PlotMS.
145  virtual PlotLoggerPtr getLogger();
146 
147 
148  // Plot Management Methods //
149 
150  // Returns the PlotMSPlotManager associated with this PlotMS.
152 
153 
154  // See PlotMSPlotManager::addOverPlot();
155  PlotMSPlot* addOverPlot(const PlotMSPlotParameters* p = NULL);
156 
157  virtual bool isDrawing() const;
158  bool isClosed() const;
159  // Set whether the latest plot update was successful completed. This
160  // may not be the case if an invalid selection was made.
161  void setOperationCompleted( bool completed );
162 
163 
164  // save plot to file using specified format.
165  bool save(const PlotExportFormat& format);
166 
170  virtual PlotFactoryPtr getPlotFactory();
171  virtual void quitApplication();
172  virtual PlotMSFlagging getFlagging() const;
173  virtual void setFlagging(PlotMSFlagging flag);
174  void canvasAdded( PlotCanvasPtr canvas );
175  bool isVisible(PlotCanvasPtr& canvas );
176  bool exportToFormat(const PlotExportFormat& format);
177  virtual casacore::Record locateInfo( casacore::Bool& success, casacore::String& errorMessage );
178  //Returns whether or not the latest plot update completed successfully.
179  //For example, if an invalid selection was made, the return value may be false.
180  bool isOperationCompleted() const;
182 
183  // To allow normal error/warning/info popups, which block execution,
184  // or, if not, prevent blocking by writing to the Logger and posting
185  // text to a status bar (or other visible gui element TBD)
186  inline virtual void allowPopups(bool allow=true) {
187  allow_popups = allow; };
188  inline bool popupsAllowed() { return allow_popups; };
189  bool updateCachePlot( PlotMSPlot* plot, void (*f)(void*, bool), bool setupPlot);
190  void setCommonAxes(bool commonX, bool commonY );
191  bool isCommonAxisX() const;
192  bool isCommonAxisY() const;
193  void setAxisLocation( PlotAxis locationX, PlotAxis locationY );
194  PlotAxis getAxisLocationX() const;
195  PlotAxis getAxisLocationY() const;
196  std::vector<casacore::String> getFiles() const;
197 
198 
199 private:
200  // Plotter, Script or GUI
203  bool isGUI_;
205 
206  // Current parameters.
210 
211  // Logger.
213 
214  // Plot manager.
216 #if ! defined(WITHOUT_DBUS)
217  // DBus application, or NULL if one is not needed.
219 #else
220  std::shared_ptr<grpcPlotMSState> grpc_;
221 #endif
222 
223  //Whether the most recent plot updated was successfully
224  //completed. A null selection, for example, could result
225  //in an unsuccessful update.
227 
228  // Initializes a new PlotMS object, to be called from constructor.
229  void initialize(bool connectToDBus, bool userGui
230 #if defined(WITHOUT_DBUS)
231  , const casacore::String &casapy_address=""
232 #endif
233  );
234 
235  // Disable copy constructor and operator for now.
236  // <group>
237  PlotMSApp(const PlotMSApp& copy);
238  PlotMSApp& operator=(const PlotMSApp& copy);
239  // </group>
240 
241 };
242 
243 /*
244 // Temporary class for polarization selection, until I understand it better.
245 // (Not currently used.)
246 class PlotMSPolSelection {
247 public:
248  PlotMSPolSelection(const casacore::String& polselstr = DEFAULT_POLSELSTR);
249 
250  ~PlotMSPolSelection();
251 
252  void setPolSelection(const casacore::String& polselstr);
253 
254  const casacore::String& polselstr() const;
255  unsigned int npols() const;
256  int pol_selection(unsigned int index) const;
257 
258  int operator()(unsigned int index) const { return pol_selection(index); }
259 
260 private:
261  casacore::String itsPolSelStr_;
262  vector<int> itsPolSel_;
263 
264  static const casacore::String DEFAULT_POLSELSTR;
265 };
266  */
267 
268 }
269 
270 #endif /* PLOTMS_H_ */
void setExportFormat(const PlotExportFormat format)
virtual PlotFactoryPtr getPlotFactory()
PlotEngine methods.
virtual casacore::Record locateInfo(casacore::Bool &success, casacore::String &errorMessage)
PlotExportFormat getExportFormat()
int Int
Definition: aipstype.h:50
void showWarning(const casacore::String &message, const casacore::String &title="PlotMS Warning")
virtual PlotMSExportParam & getExportParameters()
Gets/Sets the export parameters for this PlotMS.
StatsData< AccumType > copy(const StatsData< AccumType > &stats)
int showAndExec(bool show=true)
See PlotMSPlotter::showAndExec().
PlotLoggerPtr itsLogger_
Logger.
Definition: PlotMS.h:212
virtual bool isDrawing() const
PlotMSPlot * addOverPlot(const PlotMSPlotParameters *p=NULL)
See PlotMSPlotManager::addOverPlot();.
void showError(const casacore::String &message, const casacore::String &title="PlotMS Error", bool isWarning=false)
See PlotMSPlotter::showError().
int execLoop()
See PlotMSPlotter::execLoop().
virtual void allowPopups(bool allow=true)
To allow normal error/warning/info popups, which block execution, or, if not, prevent blocking by wri...
Definition: PlotMS.h:186
PlotterPtr getPlotter()
virtual bool guiShown() const
See PlotMSPlotter::guiShown().
virtual Type type()
Return the type enum.
PlotAxis getAxisLocationY() const
virtual PlotSymbolPtr createSymbol(const casacore::String &descriptor, casacore::Int size, const casacore::String &color, const casacore::String &fillPattern, bool outline)
Symbols.
bool allow_popups
Definition: PlotMS.h:204
Parameters for a PlotMSPlot.
bool exportToFormat(const PlotExportFormat &format)
Subclass of PlotMSWatchedParameters that hold parameters for the whole plotter.
bool popupsAllowed()
Definition: PlotMS.h:188
bool isVisible(PlotCanvasPtr &canvas)
Client * itsLastPlotter_
Definition: PlotMS.h:202
PlotMSExportParam itsExportParameters_
Definition: PlotMS.h:208
size_t size() const
void show(const variant &v)
Abstract class for parameters that may be watched by one or more interested classes.
void close()
See PlotMSPlotter::close().
PlotMSParameters itsParameters_
Current parameters.
Definition: PlotMS.h:207
Controller class for plotms.
Definition: PlotMS.h:55
virtual PlotMSFlagging getFlagging() const
class PlotEngine;
Definition: PlotMSDBusApp.h:42
virtual PlotMSParameters & getParameters()
Parameter Methods //.
void showMessage(const casacore::String &message, const casacore::String &title="PlotMS Message")
See PlotMSPlotter::showMessage().
virtual void showGUI(bool show=true)
Plotter Methods //.
Specifies flagging parameters (including possibly flag extension) for an MS.
bool save(const PlotExportFormat &format)
save plot to file using specified format.
Type
Static // Enum for implemented actions.
Definition: PlotMSAction.h:51
void setAxisLocation(PlotAxis locationX, PlotAxis locationY)
Class for a single &quot;plot&quot; concept.
Definition: PlotMSPlot.h:57
virtual PlotMSPlotManager & getPlotManager()
Plot Management Methods //.
Client * itsPlotter_
Plotter, Script or GUI.
Definition: PlotMS.h:201
void parametersHaveChanged(const PlotMSWatchedParameters &params, int updateFlag)
Implements PlotMSParametersWatcher::parametersHaveChanged().
virtual void setFlagging(PlotMSFlagging flag)
bool isCommonAxisX() const
std::vector< casacore::String > getFiles() const
PlotAxis
Enum for the four plot axes.
Definition: PlotOptions.h:62
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
PlotExportFormat contains parameters for exporting a canvas to a file.
Definition: PlotOptions.h:817
Abstraction for the interface between the client (possibly a GUI) and the model (plot engine) that is...
Definition: Client.h:45
bool operationCompleted
Whether the most recent plot updated was successfully completed.
Definition: PlotMS.h:226
PlotMSDBusApp * itsDBus_
DBus application, or NULL if one is not needed.
Definition: PlotMS.h:218
void setAnnotationModeActive(PlotMSAction::Type type, bool active)
Enable/disable annotations in the client.
PlotMSPlotManager itsPlotManager_
Plot manager.
Definition: PlotMS.h:215
Specifies export parameters for plotms.
virtual void quitApplication()
void setExportParameters(const PlotMSExportParam &params)
bool isCommonAxisY() const
void resetTools()
Enables/disables tool settings on the canvases based on GUI settings.
PlotMSApp & operator=(const PlotMSApp &copy)
PlotMSApp(bool connectToDBus=false, bool userGui=true)
Default constructor that uses default options.
Interface for classes that wish to be notified when PlotMSWatchedParameters have changed.
virtual PlotLoggerPtr getLogger()
Logger Methods //.
void setOperationCompleted(bool completed)
Set whether the latest plot update was successful completed.
bool updateCachePlot(PlotMSPlot *plot, void(*f)(void *, bool), bool setupPlot)
String: the storage and methods of handling collections of characters.
Definition: String.h:223
void canvasAdded(PlotCanvasPtr canvas)
void initialize(bool connectToDBus, bool userGui)
Initializes a new PlotMS object, to be called from constructor.
Abstracts the interface DBUS uses to talk to the main PlotMS application.
Definition: PlotEngine.h:45
Class which manages PlotMSPlots for plotms.
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the color(i.e.,"000000"for black) and
PlotExportFormat itsExportFormat
Definition: PlotMS.h:209
void setCommonAxes(bool commonX, bool commonY)
~PlotMSApp()
Destructor.
void setParameters(const PlotMSParameters &params)
PlotAxis getAxisLocationX() const
bool isClosed() const
virtual void clearPlots()
Remove existing plots.
bool isOperationCompleted() const
Returns whether or not the latest plot update completed successfully.