casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Profile2dDD.h
Go to the documentation of this file.
1 //# Profile2dDD.h: 2D Profile DisplayData
2 //# Copyright (C) 2003,2004
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 
28 #ifndef TRIALDISPLAY_PROFILE2DDD_H
29 #define TRIALDISPLAY_PROFILE2DDD_H
30 
31 #include <casa/aips.h>
32 #include <casa/Arrays/Array.h>
33 #include <casa/Arrays/Vector.h>
34 #include <casa/Arrays/Matrix.h>
44 
45 namespace casa { //# NAMESPACE CASA - BEGIN
46 
47  template <class T> class LatticePADisplayData;
48  template <class T> class DParameterRange;
49 
50  class WorldCanvas;
51  class Profile2dDM;
52  class DParameterColorChoice;
53  class DParameterMapKeyChoice;
54  class DParameterSwitch;
55 
56 // <summary>
57 // A DisplayData to draw Profiles
58 // </summary>
59 //
60 // <use visibility=export>
61 //
62 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
63 // </reviewed>
64 //
65 // <prerequisite>
66 // <li> DisplayData
67 // <li> CachingDisplayData
68 // <li> ActiveCaching2dDD
69 // </prerequisite>
70 //
71 // <etymology> </etymology>
72 
73 // <synopsis> This Display casacore::Data attaches to itself, another Display
74 // casacore::Data whos profile (at a point) is to be extracted and drawn. The
75 // Display casacore::Data attached to Profile2dDD must have atleast 3 world Axes
76 // and atleast 2 pixels on it's profile axis (3rd axis). An axis from
77 // a Linear casacore::Coordinate or casacore::Stokes casacore::Coordinate presently can not be on
78 // the profile axis. All other AIPS++ coordinate types are supported.
79 //
80 // Profile2dDD is an implements WCMotionEH and WCPositionEH and
81 // listens to motion and position events generated by the attached
82 // Display Data. A motion event comes with a new world position on
83 // the attached Display Data. Profile2dDD uses this world position to
84 // extract and draw a profile on its world canvas. A Position event
85 // (key press) switches the profiling on and off. The default switch
86 // is the space bar.
87 //
88 // Profile2dDD is a DisplayEH (all DisplayDatas are) and listens to
89 // DisplayEvents sent out by the attached DisplayData. This is so it
90 // can listen for Tool events such as Crosshair event.
91 //
92 // Each time the profile is refreshed (with new data), Profile2dDD
93 // sends out a DDModEvent to all listening DisplayEHs, to indicate
94 // that the data has been modified.
95 //
96 // Since Profile2dDD inherit's from ActiveCaching2dDD and uses
97 // WCCSNLAxisLabeller, all the options such as position tracking and
98 // axis labelling are available. Options specific to Profilng, such
99 // as profile color, line width, line style and autoscaling are also
100 // available. </synopsis>
101 //
102 // <example>
103 // </example>
104 //
105 // <motivation>
106 // Existing Glish implementation is too slow and limited.
107 // </motivation>
108 //
109 // <todo>
110 // <li> Mixed axes sometimes result in slow and messy axis labelling
111 // <li> Update Profile2dDD in real time when axis of attached dd
112 // changes
113 // <li> Option to start Profile from a specific channel.
114 // <li> Add support for Display Datas with profile of a linear
115 // coordinate axis.
116 // <li> Flux and integrated flux calculations
117 // <li> Ability to add multiple display datas and overlay their
118 // profiles
119 
120 // </todo>
121 
122  class Profile2dDD : public ActiveCaching2dDD, public WCMotionEH,
123  public WCPositionEH {
124 
125  public:
126  // <group>
127  // (Required) default constructor.
128  Profile2dDD();
129 
130  // Constructor taking a pointer to an already constructed
131  // ImageInterface.The Display casacore::Data dd must have atleast 3 World Axes
132  // and atleast 2 elements in the profile (3rd) world axis.
134 
135  // Destructor.
136  virtual ~Profile2dDD();
137  // </group>
138 
139  // <group>
140  // Attach a Display casacore::Data to this Profile2dDD. The Display casacore::Data dd
141  // must have atleast 3 World Axes and atleast 2 elements in the
142  // profile (3rd) world axis. If any of the above conditions are not
143  // met or a Display casacore::Data is already attached, false is
144  // returned. Otherwise true is returned.
146 
147  // Detach the currently attached Display Data.
148  virtual void detachDD();
149  // </group>
150 
151  // Overloading ActiveCaching2dDD::sizeControl. Zooming is modified
152  // for autoscaling feature.
153  virtual casacore::Bool sizeControl(WorldCanvasHolder &wcHolder,
154  AttributeBuffer &holderBuf);
155 
156  // <group>
157  // Store the data to be drawn in the data Matrix. If world is false,
158  // pixel coordinates are used. If world is true, then world
159  // coordinates are used.
161  const casacore::Bool world=false);
162 
163  // Store the mask in mask vector
165 
166  // Store the details of the current profile in rec
167  // casacore::Record structure similar to position event structure.
168  virtual void getProfileAsRecord(casacore::Record &rec);
169  // </group>
170 
171 
172  // Return the data unit.
173  virtual const casacore::Unit dataUnit();
174 
175  // Returns an empty string.
177 
178  // Motion Event Handler
179  virtual void operator()(const WCMotionEvent &ev);
180 
181  // Position Event Handler
182  virtual void operator()(const WCPositionEvent &ev);
183 
184  // Display Event Handler
185  virtual void handleEvent(DisplayEvent &ev);
186 
187  // Send out DDModEvents to all DisplayEHs listening
188  virtual void sendDDModEvent();
189 
190  // Draws and labels the axes based on the refresh event
191  virtual casacore::Bool labelAxes(const WCRefreshEvent &ev);
192  virtual casacore::Bool canLabelAxes() const;
193 
194  // <group>
195  // Install the default options for this DisplayData.
196  virtual void setDefaultOptions();
197 
198  // Apply options stored in <src>rec</src> to the DisplayData. A
199  // return value of <src>true</src> means a refresh is needed.
200  // <src>recOut</src> contains any fields which were implicitly
201  // changed as a result of the call to this function.
203 
204  // Retrieve the current and default options and parameter types.
205  virtual casacore::Record getOptions( bool scrub=false ) const;
206  // </group>
207 
208  // Return the type of this DisplayData.
210  return Display::Vector;
211  }
212 
213  // Create a new CachingDisplayMethod for drawing on the given
214  // WorldCanvas when the AttributeBuffers are suitably matched to the
215  // current state of this DisplayData and of the WorldCanvas/Holder.
216  // The tag is a unique number used to identify the age of the newly
217  // constructed CachingDisplayMethod.
218  virtual CachingDisplayMethod *newDisplayMethod(WorldCanvas *worldCanvas,
219  AttributeBuffer *wchAttributes,
220  AttributeBuffer *ddAttributes,
221  CachingDisplayData *dd);
222 
223  // Return the current options of this DisplayData as an
224  // AttributeBuffer.
226 
227  // Take actions on removal from WC[H] (notably, deletion of drawlists).
228  virtual void notifyUnregister(WorldCanvasHolder& wcHolder,
229  casacore::Bool ignoreRefresh = false);
230 
231  // <group>
232  // Return Profile Color
233  virtual casacore::String profileColor() const {
234  return itsParamColor->value();
235  }
236  // Return Profile Line Width
238  return itsParamLineWidth->value();
239  }
240  // Return Profile LineStyle
242  return static_cast<Display::LineStyle>(itsParamLineStyle->keyValue());
243  }
244 
245  // Return true if the last requested profile was for a
246  // region. Return false if the last requested profile was for a
247  // single point
248  virtual casacore::Bool isRegionProfile() const {
249  return itsIsRegionProfile;
250  }
251 
252  // get the region dimensions, in pixels, of the last region
253  // submitted to Profile2dDD.
256 
257  // Return Minimum Y value
258  virtual casacore::Double profileYMin() const {
259  return itsCurrentBlc(1);
260  }
261  // Return Maximum Y value
262  virtual casacore::Double profileYMax() const {
263  return itsCurrentTrc(1);
264  }
265  // Return Minimum X value
266  virtual casacore::Double profileXMin() const {
267  return itsCurrentBlc(0);
268  }
269  // Return Maximum X value
270  virtual casacore::Double profileXMax() const {
271  return itsCurrentTrc(0);
272  }
273  // Return the autoscale status (On or Off)
275  return itsParamAutoscale->value();
276  }
277  // Return the rest frequency display status (to draw or not to draw)
280  }
281  // Return rest frequency.
282  virtual casacore::Double restFrequency() const {
283  return itsRestFrequency;
284  }
285 
286  // Return the statistics used for region calculations.
290  }
291 
292  // Return the x value added to the pixel at a pixel position to
293  // create a region
294  virtual casacore::Int regionXRadius() const {
295  return itsParamRegionXRadius->value();
296  }
297 
298  // Return the y value added to the pixel at a pixel position to
299  // create a region
300  virtual casacore::Int regionYRadius() const {
301  return itsParamRegionYRadius->value();
302  }
303  // Return the profile axis number (from the original image)
304  virtual casacore::Int profileAxis();
305 
306  // </group>
307 
308  protected:
309 
310  friend class Profile2dDM;
311 
312  // (Required) copy constructor.
313  Profile2dDD(const Profile2dDD &other);
314 
315  // (Required) copy assignment.
316  void operator=(const Profile2dDD &other);
317 
318  private:
319 
320  // Helper function. Initialise Profile2dDD with a DisplayCoordinateSystem
321  // put together from the parent DD
323 
324  // Update the coordinate system of this Display casacore::Data and the axis
325  // labeller. Set new minimum and maximum Y values if necessary
327 
328  // Extract the profile data from the provided pixel region and place
329  // it into itsData. The statistics used is determined by the
330  // options. Return true if new profile data has been extracted
331  // (i.e. a refresh is needed) otherwise return false
334 
335  // Extract the profile data from the provided world position and
336  // place it into itsData. Also extract the Mask data (if it exists)
337  // and place it into itsMask. Return true if new profile data has
338  // been extracted (i.e. a refresh is needed) otherwise return false
340 
341  // Crop the region so that it does not define areas outside the
342  // data. Returns false if the entire region is outside image data
345 
346  // Construct the parameters for getOptions and setOptions
347  virtual void constructParameters();
348  // Delete the parameters for getOptions() and setOptions()
349  virtual void destructParameters();
350 
351  // A pointer to the attached DisplayData
353 
354  // Flag to indicate whether the last drawn profile was for a region
355  // or for a single point.
357 
358  // A flag to indicate whether tracking is on. If true, a new profile
359  // is extracted each time a new motion event is received.
361 
362  // The dependent (world) axis of itsDD. For example, if a RA axis is
363  // the profile axis, then the DEC axis will be the dependent axis.
365 
366  // Increment value for the linear coordinate on the Y axis
368 
369  // Rest Frequency
371 
372  // Minimum and maximum X/Y values
375 
376  // <group> The pixel position on the world canvas when the last
377  // motion' event was received. This position is in the format of
378  // itsDD, NOT the original image.
380  // The world position on the world canvas when the last motion'
381  // event was received. This position is in the format of
382  // itsDD, NOT the original image.
384 
385  // The region dimensions, in pixels, of the last region event
386  // received by Profile2dDD
389 
390  // </group>
391  // The Profile Data
393  // The Mask Data
395 
396  // The axis map between input DD's casacore::Coordinate system and
397  // itsCompleteCS
400 
401  // The choices for region calculations. eg, mean, median, etc
403 
404  // The default x and y axis labels. The x and y labels change to
405  // indicate region profiles.
407 
408  // The Axis Labeller used to draw Axes
410 
411  // Display Parameters for
420  };
421 
422 } //# NAMESPACE CASA - END
423 
424 #endif
virtual casacore::Double profileXMin() const
Return Minimum X value.
Definition: Profile2dDD.h:266
casacore::Int itsDependentAxis
The dependent (world) axis of itsDD.
Definition: Profile2dDD.h:364
Implementation of DParameterChoice to store color selection parameters.
virtual casacore::Bool isRegionProfile() const
Return true if the last requested profile was for a region.
Definition: Profile2dDD.h:248
virtual casacore::Bool showRestFrequency() const
Return the rest frequency display status (to draw or not to draw)
Definition: Profile2dDD.h:278
casacore::Vector< casacore::Double > itsRegionTrc
Definition: Profile2dDD.h:388
int Int
Definition: aipstype.h:50
casacore::Bool getRegionProfile(casacore::Vector< casacore::Double > &fpixelBlc, casacore::Vector< casacore::Double > &fpixelTrc)
Extract the profile data from the provided pixel region and place it into itsData.
Class providing active behaviour for 2d CachingDisplayDatas.
Assistance class for auto-caching of DisplayData objects.
LatticePADisplayData< casacore::Float > * itsDD
A pointer to the attached DisplayData.
Definition: Profile2dDD.h:352
DParameterRange< casacore::Float > * itsParamLineWidth
Definition: Profile2dDD.h:413
Class which stores WorldCanvas refresh event information.
casacore::Bool getPointProfile(const casacore::Vector< casacore::Double > &world)
Extract the profile data from the provided world position and place it into itsData.
casacore::Bool cropRegion(casacore::Vector< casacore::Double > &fpixelBlc, casacore::Vector< casacore::Double > &fpixelTrc)
Crop the region so that it does not define areas outside the data.
Profile2dDD()
(Required) default constructor.
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
virtual void operator()(const WCMotionEvent &ev)
Motion Event Handler.
virtual casacore::Bool attachDD(LatticePADisplayData< casacore::Float > *dd)
Attach a Display casacore::Data to this Profile2dDD.
virtual casacore::Bool profileAutoscale() const
Return the autoscale status (On or Off)
Definition: Profile2dDD.h:274
casacore::Bool itsIsRegionProfile
Flag to indicate whether the last drawn profile was for a region or for a single point.
Definition: Profile2dDD.h:356
DisplayDataType
WorldCanvasHolder - what type of DisplayData is this, need to know for drawing order.
Definition: DisplayEnums.h:355
Buffer for storing Attributes.
casacore::Bool itsTrackingState
A flag to indicate whether tracking is on.
Definition: Profile2dDD.h:360
Base class for handling WorldCanvas motion events.
Definition: WCMotionEH.h:70
casacore::Vector< casacore::String > itsRegionCalcChoices
The choices for region calculations.
Definition: Profile2dDD.h:402
virtual void detachDD()
Detach the currently attached Display Data.
DParameterColorChoice * itsParamColor
Display Parameters for.
Definition: Profile2dDD.h:412
casacore::Vector< casacore::Double > itsPixelPosition
The pixel position on the world canvas when the last motion&#39; event was received. ...
Definition: Profile2dDD.h:379
A DisplayData to draw Profiles.
Definition: Profile2dDD.h:122
virtual casacore::Double restFrequency() const
Return rest frequency.
Definition: Profile2dDD.h:282
virtual casacore::Bool sizeControl(WorldCanvasHolder &wcHolder, AttributeBuffer &holderBuf)
Overloading ActiveCaching2dDD::sizeControl.
casacore::Vector< casacore::Double > itsCurrentTrc
Definition: Profile2dDD.h:374
virtual AttributeBuffer optionsAsAttributes()
Return the current options of this DisplayData as an AttributeBuffer.
DParameterSwitch * itsParamShowRestFrequency
Definition: Profile2dDD.h:416
DParameterSwitch * itsParamAutoscale
Definition: Profile2dDD.h:415
casacore::Double itsRestFrequency
Rest Frequency.
Definition: Profile2dDD.h:370
casacore::Bool createCoordinateSystem()
Helper function.
ABSTRACT CLASSES Deliberately vague to be general enough to allow for many different types of data
Definition: PlotData.h:48
defines physical units
Definition: Unit.h:189
virtual ~Profile2dDD()
Destructor.
casacore::Bool value() const
Return the current value of this parameter.
DParameterRange< casacore::Int > * itsParamRegionYRadius
Definition: Profile2dDD.h:419
virtual CachingDisplayMethod * newDisplayMethod(WorldCanvas *worldCanvas, AttributeBuffer *wchAttributes, AttributeBuffer *ddAttributes, CachingDisplayData *dd)
Create a new CachingDisplayMethod for drawing on the given WorldCanvas when the AttributeBuffers are ...
Class which stores WorldCanvas motion event information.
Definition: WCMotionEvent.h:79
Base class for auto-caching DisplayData objects.
DParameterMapKeyChoice * itsParamRegionStatType
Definition: Profile2dDD.h:417
double Double
Definition: aipstype.h:55
Class describing the most basic event information in the display classes.
Definition: DisplayEvent.h:82
virtual casacore::String showValue(const casacore::Vector< casacore::Double > &world)
Returns an empty string.
virtual void sendDDModEvent()
Send out DDModEvents to all DisplayEHs listening.
Class which provides non-linear axis labelling using a DisplayCoordinateSystem.
WCCSNLAxisLabeller itsAxisLabeller
The Axis Labeller used to draw Axes.
Definition: Profile2dDD.h:409
casacore::Vector< casacore::Double > itsWorldPosition
The world position on the world canvas when the last motion&#39; event was received.
Definition: Profile2dDD.h:383
virtual casacore::Bool labelAxes(const WCRefreshEvent &ev)
Draws and labels the axes based on the refresh event.
virtual void regionDimensions(casacore::Vector< casacore::Double > &regionBlc, casacore::Vector< casacore::Double > &regionTrc)
get the region dimensions, in pixels, of the last region submitted to Profile2dDD.
virtual casacore::Float profileLineWidth() const
Return Profile Line Width.
Definition: Profile2dDD.h:237
casacore::Double itsYAxisInc
Increment value for the linear coordinate on the Y axis.
Definition: Profile2dDD.h:367
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
StatisticsTypes
This enum StatisticTypes is provided for use with the LatticeStatistics&lt;T&gt;::setPlotting function...
float Float
Definition: aipstype.h:54
virtual void setDefaultOptions()
Install the default options for this DisplayData.
virtual casacore::Int regionYRadius() const
Return the y value added to the pixel at a pixel position to create a region.
Definition: Profile2dDD.h:300
virtual casacore::Double profileYMin() const
Return Minimum Y value.
Definition: Profile2dDD.h:258
virtual void getMaskData(casacore::Vector< casacore::Bool > &mask)
Store the mask in mask vector.
virtual casacore::LatticeStatsBase::StatisticsTypes regionStatType() const
Return the statistics used for region calculations.
Definition: Profile2dDD.h:287
casacore::Vector< casacore::Bool > itsMask
The Mask Data.
Definition: Profile2dDD.h:394
Implementation of DParameterChoice to store parameter and associated key.
casacore::Int keyValue()
Return the current value of this parameter.
virtual Display::LineStyle profileLineStyle()
Return Profile LineStyle.
Definition: Profile2dDD.h:241
virtual Display::DisplayDataType classType()
Return the type of this DisplayData.
Definition: Profile2dDD.h:209
virtual casacore::String profileColor() const
Return Profile Color.
Definition: Profile2dDD.h:233
T value()
Return the current value of this parameter.
A DisplayMethod to draw Profiles.
Definition: Profile2dDM.h:58
Class which stores WorldCanvas position event information.
virtual casacore::Int regionXRadius() const
Return the x value added to the pixel at a pixel position to create a region.
Definition: Profile2dDD.h:294
A holder to interface between DisplayDatas and a WorldCanvas.
Implementation of drawing in world coordinates on top of a PixelCanvas.
Definition: WorldCanvas.h:204
virtual void notifyUnregister(WorldCanvasHolder &wcHolder, casacore::Bool ignoreRefresh=false)
Take actions on removal from WC[H] (notably, deletion of drawlists).
virtual casacore::Int profileAxis()
Return the profile axis number (from the original image)
virtual const casacore::Unit dataUnit()
Return the data unit.
DParameterRange< casacore::Int > * itsParamRegionXRadius
Definition: Profile2dDD.h:418
casacore::Vector data - can go next
Definition: DisplayEnums.h:359
virtual casacore::Record getOptions(bool scrub=false) const
Retrieve the current and default options and parameter types.
casacore::String value()
Return the current value of this parameter.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
virtual casacore::Double profileYMax() const
Return Maximum Y value.
Definition: Profile2dDD.h:262
casacore::Vector< casacore::Double > itsRegionBlc
The region dimensions, in pixels, of the last region event received by Profile2dDD.
Definition: Profile2dDD.h:387
virtual void getDrawData(casacore::Matrix< casacore::Double > &data, const casacore::Bool world=false)
Store the data to be drawn in the data Matrix.
virtual casacore::Bool canLabelAxes() const
casacore::Vector< casacore::Double > itsCurrentBlc
Minimum and maximum X/Y values.
Definition: Profile2dDD.h:373
Base class for handling WorldCanvas position events.
Definition: WCPositionEH.h:75
casacore::Vector< casacore::Int > itsWorldAxisMap
The axis map between input DD&#39;s casacore::Coordinate system and itsCompleteCS.
Definition: Profile2dDD.h:398
casacore::Vector< casacore::String > itsDefaultAxisLabels
The default x and y axis labels.
Definition: Profile2dDD.h:406
virtual casacore::Double profileXMax() const
Return Maximum X value.
Definition: Profile2dDD.h:270
virtual void constructParameters()
Construct the parameters for getOptions and setOptions.
casacore::Matrix< casacore::Double > itsData
The Profile Data.
Definition: Profile2dDD.h:392
Implementation of DisplayParameter to store choice parameters.
casacore::Bool updateCoordinateSys(DisplayCoordinateSystem &cs)
Update the coordinate system of this Display casacore::Data and the axis labeller.
virtual void handleEvent(DisplayEvent &ev)
Display Event Handler.
DParameterMapKeyChoice * itsParamLineStyle
Definition: Profile2dDD.h:414
virtual casacore::Bool setOptions(casacore::Record &rec, casacore::Record &recOut)
Apply options stored in rec to the DisplayData.
void operator=(const Profile2dDD &other)
(Required) copy assignment.
casacore::Vector< casacore::Int > itsPixelAxisMap
Definition: Profile2dDD.h:399
LineStyle
Style of line to use.
Definition: DisplayEnums.h:119
virtual void destructParameters()
Delete the parameters for getOptions() and setOptions()
virtual void getProfileAsRecord(casacore::Record &rec)
Store the details of the current profile in rec casacore::Record structure similar to position event ...