casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DSArrow.h
Go to the documentation of this file.
1 //# DSArrow.h: Arrow implementation for "DisplayShapes"
2 //# Copyright (C) 1998,1999,2000,2001,2002
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_DSARROW_H
29 #define TRIALDISPLAY_DSARROW_H
30 
31 #include <casa/aips.h>
32 
35 
36 #include <casa/Arrays/Matrix.h>
37 #include <casa/Arrays/Vector.h>
38 
39 namespace casa { //# NAMESPACE CASA - BEGIN
40 
41  class PixelCanvas;
42  template <class T> class DParameterRange;
43 
44 // <summary>
45 // Arrow implementation;adds a polygon to a DSLine to represent the arrow head
46 // </summary>
47 //
48 // <prerequisite>
49 // <li> <linkto class="DSLine">DSLine</linkto>
50 // <li> <linkto class="DSPoly">DSPoly</linkto>
51 // <li> <linkto class="DisplayShape">DisplayShape</linkto>
52 // </prerequisite>
53 //
54 // <etymology>
55 // DSArrow is a method of managing the drawing of a line and polygon onto a
56 // PixelCanvas.
57 // </etymology>
58 //
59 // <synopsis>
60 // DSArrow simply extends from DSLine, and adds the management of a polygon
61 // to it. The polygon is used to represent the arrow head, and various options
62 // regarding its apppearance can be changed.
63 //
64 // There are generally two ways to make DisplayShape(s); To create them in
65 // "one hit" by providing arguments to the constructor, or by using the
66 // default constructor and then the "setOptions" method. A simple interface
67 // for all classes inheriting from the
68 // <linkto class="DisplayShape">DisplayShape</linkto> class is provided by
69 // <linkto class="DisplayShapeInterface">DisplayShapeInterface</linkto>.
70 // </synopsis>
71 //
72 // <motivation>
73 // It was thought, especially in an annotations context, that an Arrow would be
74 // a usefull drawing tool.
75 // </motivation>
76 //
77 // <example>
78 // <srcblock>
79 // casacore::Vector<casacore::Float> startPoint(2); startPoint[0] = 100; startPoint[1] = 100;
80 // casacore::Vector<casacore::Float> endPoint(2); endPoint[0] = 200; endPoint[1] = 200;
81 //
82 // DSArrow* myArrow =
83 // new DSArrow(startPoint, endPoint, DSArrow::Filled_Triangle, 10);
84 //
85 // myArrow->move(10,10);
86 //
87 // casacore::Vector<casacore::Float> newStart(2); newStart[0] = 50; newStart[1] = 50;
88 // myArrow->setStartPoint(newStart);
89 //
90 // casacore::Record newArrow;
91 // newArrow.define("arrowheadsize", 6);
92 //
93 // myArrow->setOptions(newArrow);
94 // myArrow->draw(myPixelCanvas);
95 // etc..
96 // </srcblock>
97 // </example>
98 
99  class DSArrow : public DSLine {
100 
101  public:
102 
103  // Supported arrow head types
105 
106  // For checking setoptions(arrowheadstyle = ?)
107  static const int numArrowHeads = 3;
108 
109 
110  // Default constructor. In order to make the arrow "valid", it must
111  // be supplied with a valid start and end point.
112  DSArrow();
113 
114  // The start and end point are in pixel co-ordinates.
117  const casacore::Int arrowHeadSize = 8);
118 
119  // Copy constructor
120  DSArrow(const DSArrow& other);
121 
122  // Destructor
123  virtual ~DSArrow();
124 
125  // Standard Display Shape functions
126  // <group>
127  virtual void draw(PixelCanvas *pc);
128  virtual void move(const casacore::Float& dX, const casacore::Float& dY);
129  virtual void rotate(const casacore::Float& angle);
130  virtual void scale(const casacore::Float& scaleFactor);
131  virtual void setCenter(const casacore::Float& xPos, const casacore::Float& yPos);
132  // </group>
133 
134  // Does nothing currently
135  virtual void rotateAbout(const casacore::Float& angle, const casacore::Float& aboutX,
136  const casacore::Float& aboutY);
137 
138  // Standard (changePoint) and specific funtions for altering the arrow. the
139  // changePoint method with only one argument will move the closest point to
140  // the specified new point. When speciffyin 'n', in this case only 0 or
141  // 1 are valid. The 'startpoint' is the one with the arrow head on it.
142  // <group>
143  virtual void setStartPoint(const casacore::Vector<casacore::Float>& startPoint);
144  virtual void setEndPoint(const casacore::Vector<casacore::Float>& endPoint);
145  virtual void changePoint(const casacore::Vector<casacore::Float>&pos, const casacore::Int n);
146  virtual void changePoint(const casacore::Vector<casacore::Float>& pos);
147  // </group>
148 
149  // These are to enable the use of arrows more easily in vector plots
150  // <group>
151  virtual void setLength(const casacore::Float& pixelLength);
152  virtual void setAngle(const casacore::Float& angle);
153  // </group>
154 
155  // Return an option record describing the shape
156  virtual casacore::Record getOptions();
157 
158  // Set options.
159  virtual casacore::Bool setOptions(const casacore::Record& newSettings);
160 
161  protected:
162 
163  private:
164  // If someone calls "setLength" before "setCenter", we can store our
165  // length until they DO call setLength;
167 
168  // Make a new arrow head (which is simply a DSPoly)
169  virtual void buildArrowHead();
170 
171  // Caluclate angle etc.
172  virtual void updateArrowHead();
173 
174  // Set default options
175  virtual void setDefaultOptions();
176 
177  // Construct the line segment of the arrow when we have
178  // valid start / end points
179  virtual void make();
180 
182 
184 
185  // Temp storage while I am being set up
186  // <group>
189  // </group>
190 
191  // A casacore::Matrix of the unRotated arrow head
193 
194  // Offset needed to make sure the tip of the arrow is at the end of
195  // the line.
197 
198  // Style of arrow head
200 
201  // Have I been supplied with valid points yet
203  };
204 
205 
206 } //# NAMESPACE CASA - END
207 
208 #endif
209 
210 
211 
212 
213 
214 
215 
216 
217 
218 
219 
220 
221 
DSPoly * itsArrowHead
Definition: DSArrow.h:183
int Int
Definition: aipstype.h:50
DParameterRange< casacore::Int > * itsHeadSize
Definition: DSArrow.h:181
virtual void setLength(const casacore::Float &pixelLength)
These are to enable the use of arrows more easily in vector plots.
virtual void move(const casacore::Float &dX, const casacore::Float &dY)
casacore::Matrix< casacore::Float > itsUnrotatedHead
A casacore::Matrix of the unRotated arrow head.
Definition: DSArrow.h:192
DSArrow::ArrowHead itsArrowHeadStyle
Style of arrow head.
Definition: DSArrow.h:199
virtual void updateArrowHead()
Caluclate angle etc.
Arrow implementation;adds a polygon to a DSLine to represent the arrow head.
Definition: DSArrow.h:99
virtual void setDefaultOptions()
Set default options.
virtual void setCenter(const casacore::Float &xPos, const casacore::Float &yPos)
This does nothing, it&#39;s so arrow and other inheriting classes can take note of new centers...
virtual void setAngle(const casacore::Float &angle)
DSArrow()
Default constructor.
Base class defining interface to pixel-based output devices.
Definition: PixelCanvas.h:161
virtual void setEndPoint(const casacore::Vector< casacore::Float > &endPoint)
Implementation of a line.
Definition: DSLine.h:94
virtual ~DSArrow()
Destructor.
casacore::Vector< casacore::Float > itsStartPoint
Temp storage while I am being set up.
Definition: DSArrow.h:187
casacore::Vector< casacore::Float > itsEndPoint
Definition: DSArrow.h:188
ArrowHead
Supported arrow head types.
Definition: DSArrow.h:104
virtual void scale(const casacore::Float &scaleFactor)
Scale the shape about its center by the scaleFactor.
Implementation of a Polygon.
Definition: DSPoly.h:73
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
casacore::Bool itsValidEnd
Definition: DSArrow.h:202
float Float
Definition: aipstype.h:54
virtual void draw(PixelCanvas *pc)
Standard Display Shape functions.
casacore::Float itsOffset
Offset needed to make sure the tip of the arrow is at the end of the line.
Definition: DSArrow.h:196
virtual void changePoint(const casacore::Vector< casacore::Float > &pos, const casacore::Int n)
Changes the nth point making up the DisplayShape ot the specified location.
virtual void setStartPoint(const casacore::Vector< casacore::Float > &startPoint)
Standard (changePoint) and specific funtions for altering the arrow.
virtual void rotateAbout(const casacore::Float &angle, const casacore::Float &aboutX, const casacore::Float &aboutY)
Does nothing currently.
casacore::Float itsLength
If someone calls &quot;setLength&quot; before &quot;setCenter&quot;, we can store our length until they DO call setLength...
Definition: DSArrow.h:166
virtual void buildArrowHead()
Make a new arrow head (which is simply a DSPoly)
virtual void rotate(const casacore::Float &angle)
Rotate the shape about its center by a set angle (angle in degrees).
virtual casacore::Bool setOptions(const casacore::Record &newSettings)
Set options.
virtual void make()
Construct the line segment of the arrow when we have valid start / end points.
static const int numArrowHeads
For checking setoptions(arrowheadstyle = ?)
Definition: DSArrow.h:107
casacore::Bool itsValidStart
Have I been supplied with valid points yet.
Definition: DSArrow.h:202
virtual casacore::Record getOptions()
Return an option record describing the shape.