PlotMSPlotParameters.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef PLOTMSPLOTPARAMETERS_H_
00028 #define PLOTMSPLOTPARAMETERS_H_
00029
00030 #include <casa/Containers/Record.h>
00031 #include <graphics/GenericPlotter/PlotFactory.h>
00032 #include <plotms/PlotMS/PlotMSWatchedParameters.h>
00033
00034 namespace casa {
00035
00036
00037 class PlotMSApp;
00038
00039
00040
00041
00042
00043 class PlotMSPlotParameters : public PlotMSWatchedParameters {
00044
00045 public:
00046
00047
00048
00049
00050 class Group {
00051
00052
00053 friend class PlotMSPlotParameters;
00054
00055 public:
00056
00057 Group(PlotFactoryPtr factory);
00058
00059
00060 Group(const Group& copy);
00061
00062
00063 virtual ~Group();
00064
00065
00066
00067
00068
00069 virtual Group* clone() const = 0;
00070
00071
00072
00073 virtual const String& name() const = 0;
00074
00075
00076 virtual Record toRecord() const = 0;
00077
00078
00079
00080 virtual void fromRecord(const Record& record) = 0;
00081
00082
00083
00084 virtual bool requiresRedrawOnChange() const = 0;
00085
00086
00087
00088
00089
00090
00091 virtual Group& operator=(const Group& other);
00092
00093
00094
00095 virtual bool operator==(const Group& other) const;
00096 virtual bool operator!=(const Group& other) const {
00097 return !(operator==(other)); }
00098
00099 protected:
00100
00101
00102
00103 void updated() { updated(requiresRedrawOnChange()); }
00104 void updated(bool requiresRedraw);
00105
00106
00107
00108
00109 PlotMSPlotParameters* parent() { return itsParent_; }
00110 const PlotMSPlotParameters* parent() const { return itsParent_; }
00111
00112
00113
00114
00115 PlotFactoryPtr factory() { return itsFactory_; }
00116 const PlotFactoryPtr factory() const { return itsFactory_; }
00117
00118
00119 private:
00120
00121 PlotMSPlotParameters* itsParent_;
00122
00123
00124 PlotFactoryPtr itsFactory_;
00125
00126
00127
00128
00129 public:
00130 static void
00131 notifyWatchers (void *obj, bool wasCanceled)
00132 {
00133 Group *cobj = static_cast < Group * >(obj);
00134 if (cobj != NULL)
00135 cobj->notifyWatchers_ (wasCanceled);
00136 }
00137 private:
00138 void notifyWatchers_ (bool wasCanceled);
00139
00140
00141 };
00142
00143
00144 friend class PlotMSPlotParameters::Group;
00145
00146
00147
00148
00149
00150 PlotMSPlotParameters(PlotFactoryPtr factory);
00151
00152
00153 PlotMSPlotParameters(const PlotMSPlotParameters& copy);
00154
00155
00156 ~PlotMSPlotParameters();
00157
00158
00159
00160
00161 bool equals(const PlotMSWatchedParameters& other, int updateFlags) const;
00162
00163
00164
00165
00166 const Group* group(const String& name) const;
00167 Group* group(const String& name);
00168
00169
00170
00171
00172 template <class T>
00173 const T* typedGroup() const {
00174 const T* g = NULL;
00175 for(unsigned int i = 0; i < itsGroups_.size(); i++)
00176 if((g = dynamic_cast<const T*>(itsGroups_[i])) != NULL) return g;
00177 return NULL;
00178 }
00179 template <class T>
00180 T* typedGroup() {
00181 T* g = NULL;
00182 for(unsigned int i = 0; i < itsGroups_.size(); i++){
00183 if((g = dynamic_cast<T*>(itsGroups_[i])) != NULL) return g;
00184 }
00185 return NULL;
00186 }
00187
00188
00189
00190
00191 void setGroup(const Group& group);
00192
00193
00194
00195 template <class T>
00196 void setGroup() { setGroup(T(itsFactory_)); }
00197
00198
00199
00200 PlotMSPlotParameters& operator=(const PlotMSPlotParameters& copy);
00201
00202
00203 protected:
00204
00205 PlotFactoryPtr itsFactory_;
00206
00207
00208
00209
00210 void notifyWatchers(int updateFlags,
00211 PlotMSParametersWatcher* updater = NULL);
00212 void notifyWatchers(const String& updateName,
00213 PlotMSParametersWatcher* updater = NULL) {
00214 notifyWatchers(UPDATE_FLAG(updateName), updater); }
00215
00216
00217 private:
00218
00219 vector<Group*> itsGroups_;
00220
00221
00222
00223 void groupUpdated(Group* group, bool requiresRedraw);
00224 };
00225
00226
00227
00228 #define PMS_PP_CALL(PARAMS, GROUP, METHOD, ...) \
00229 if( PARAMS .typedGroup< GROUP >() != NULL) \
00230 PARAMS .typedGroup< GROUP >()-> METHOD ( __VA_ARGS__ );
00231
00232 #define PMS_PP_RETCALL(PARAMS, GROUP, METHOD, DEFAULT, ...) \
00233 (PARAMS .typedGroup< GROUP >() == NULL ? DEFAULT : \
00234 PARAMS .typedGroup< GROUP >()-> METHOD ( __VA_ARGS__ ))
00235
00236
00237 }
00238
00239 #endif