casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DSRectangle.h
Go to the documentation of this file.
1 //# DSRectangle.h: Rectangle 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_DSRECTANGLE_H
29 #define TRIALDISPLAY_DSRECTANGLE_H
30 
31 #include <casa/aips.h>
32 
34 
35 namespace casa { //# NAMESPACE CASA - BEGIN
36 
37 // <summary>
38 // Implementation of a rectangle.
39 // </summary>
40 //
41 // <prerequisite>
42 // <li> <linkto class="DSPoly">DSPoly</linkto>
43 // <li> <linkto class="DisplayShape">DisplayShape</linkto>
44 // </prerequisite>
45 //
46 // <etymology>
47 // DSRectangle is a method of managing the drawing of a rectangle onto a
48 // PixelCanvas.
49 // </etymology>
50 //
51 // <synopsis>
52 // DSRectangle is simply a DSPoly with only four points. It has overloaded
53 // certain functions however, which cause it to behave as a rectangle when
54 // having its points moved etc. It calculates its width and height from
55 // points returned from DSPoly when needed.
56 //
57 // There are generally two ways to make DisplayShape(s); To create them in
58 // "one hit" by providing arguments to the constructor, or by using the
59 // default constructor and then the "setOptions" method. A simple interface
60 // for all classes inheriting from the
61 // <linkto class="DisplayShape">DisplayShape</linkto> class is provided by
62 // <linkto class="DisplayShapeInterface">DisplayShapeInterface</linkto>.
63 // </synopsis>
64 //
65 // <motivation>
66 // The need to draw rectangles on screen.
67 // </motivation>
68 //
69 // <example>
70 // <srcblock>
71 // </srcblock>
72 // </example>
73 //
74 // <todo asof="2002/05/13">
75 // <li> Modify functions like 'changePoint' to allow a special case when
76 // angle = 0 for speed reasons.
77 // </todo>
78 
79 
80  class DSRectangle : public DSPoly {
81 
82  public:
83 
84  // Constructors and Destructors
85  // <group>
86  DSRectangle();
87  DSRectangle(const casacore::Float& xPos, const casacore::Float& yPos, const casacore::Float& width,
88  const casacore::Float& height, const casacore::Bool& handles = false,
89  const casacore::Bool& drawHandles = false);
90  DSRectangle(const DSRectangle& other);
91  virtual ~DSRectangle();
92  // </group>
93 
94  // Standard DisplayShape functions
95  // <group>
96  virtual void move(const casacore::Float& dX, const casacore::Float& dY);
97  virtual void rotate(const casacore::Float& angle);
98  virtual void rotateAbout(const casacore::Float& angle, const casacore::Float& aboutX,
99  const casacore::Float& aboutY);
100  virtual void setCenter(const casacore::Float& xPos, const casacore::Float& yPos);
101  virtual void changePoint(const casacore::Vector<casacore::Float>& pos);
102  virtual void changePoint(const casacore::Vector<casacore::Float>& newPoints, const casacore::Int whichOne);
103  virtual void addPoint(const casacore::Vector<casacore::Float>& toAdd);
104  // </group>
105 
106 
107  // Rectangle specific. Get / set width and height in pixels.
108  // <group>
109  virtual void setHeight(const casacore::Float& height);
110  virtual void setWidth(const casacore::Float& width);
111  virtual casacore::Float getHeight();
112  virtual casacore::Float getWidth();
113  // </group>
114 
115  // Get and set options
116  // <group>
117  virtual casacore::Bool setOptions(const casacore::Record& settings);
118  virtual casacore::Record getOptions();
119  // </group>
120 
121  // Using supplied parameters, make a polygon of four points representing the
122  // rectangle. This can then be used to create / alter a DSPoly.
124  const casacore::Float& width, const casacore::Float& height);
125 
126  private:
127 
128  // Always valid
131 
132  //Ony used during the set-up period
134 
135  virtual void setDefaultOptions();
136  virtual void setAngle(const casacore::Float& newAngle);
137 
138  protected:
139  virtual casacore::Float getAngle();
140  };
141 
142 
143 } //# NAMESPACE CASA - END
144 
145 #endif
146 
147 
148 
149 
casacore::Float itsAngle
Always valid.
Definition: DSRectangle.h:129
int Int
Definition: aipstype.h:50
virtual void setHeight(const casacore::Float &height)
Rectangle specific.
Implementation of a rectangle.
Definition: DSRectangle.h:80
virtual void addPoint(const casacore::Vector< casacore::Float > &toAdd)
Polygon specific functions, add, delete and set points, all in pixels.
virtual void rotateAbout(const casacore::Float &angle, const casacore::Float &aboutX, const casacore::Float &aboutY)
virtual casacore::Bool setOptions(const casacore::Record &settings)
Get and set options.
virtual void changePoint(const casacore::Vector< casacore::Float > &pos)
Changes the closest point to the supplied location to that location.
virtual void setWidth(const casacore::Float &width)
casacore::Float itsHeight
Definition: DSRectangle.h:133
virtual casacore::Float getHeight()
DSRectangle()
Constructors and Destructors.
virtual void move(const casacore::Float &dX, const casacore::Float &dY)
Standard DisplayShape functions.
virtual void setDefaultOptions()
Used to set up the class when default constructor called.
Implementation of a Polygon.
Definition: DSPoly.h:73
virtual casacore::Float getWidth()
virtual void setAngle(const casacore::Float &newAngle)
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
float Float
Definition: aipstype.h:54
virtual casacore::Record getOptions()
Get and set options.
casacore::Bool itsValid
Definition: DSRectangle.h:130
virtual ~DSRectangle()
casacore::Float itsWidth
Definition: DSRectangle.h:133
virtual void setCenter(const casacore::Float &xPos, const casacore::Float &yPos)
Sets the center of the DisplayShape.
virtual void rotate(const casacore::Float &angle)
Rotate the shape about its center by a set angle (angle in degrees).
virtual casacore::Matrix< casacore::Float > makeAsPoly(const casacore::Float &xPos, const casacore::Float &yPos, const casacore::Float &width, const casacore::Float &height)
Using supplied parameters, make a polygon of four points representing the rectangle.
virtual casacore::Float getAngle()
casacore::Float itsCenter
Ony used during the set-up period.
Definition: DSRectangle.h:133