casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DSPoly.h
Go to the documentation of this file.
1 //# DSPoly.h: Polygon 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 #ifndef TRIALDISPLAY_DSPOLY_H
28 #define TRIALDISPLAY_DSPOLY_H
29 
30 #include <casa/aips.h>
31 
33 #include <casa/Arrays/Matrix.h>
34 #include <casa/Arrays/Vector.h>
35 
36 namespace casa { //# NAMESPACE CASA - BEGIN
37 
38 // <summary>
39 // Implementation of a Polygon.
40 // </summary>
41 //
42 // <prerequisite>
43 // <li> <linkto class="DSClosed">DSClosed</linkto>
44 // <li> <linkto class="DisplayShape">DisplayShape</linkto>
45 // </prerequisite>
46 //
47 // <etymology>
48 // DSPoly is a method of managing the drawing of a polygon onto a PixelCanvas.
49 // </etymology>
50 //
51 // <synopsis>
52 // DSPoly allows for the management of a polygon, including the addition and
53 // deletion of points.
54 //
55 // There are generally two ways to make DisplayShape(s); To create them in
56 // "one hit" by providing arguments to the constructor, or by using the
57 // default constructor and then the "setOptions" method. A simple interface
58 // for all classes inheriting from the
59 // <linkto class="DisplayShape">DisplayShape</linkto> class is provided
60 // by <linkto class="DisplayShapeInterface">DisplayShapeInterface</linkto>.
61 // </synopsis>
62 //
63 // <motivation>
64 // To enable display of circles onto a pixel canvas.
65 // </motivation>
66 //
67 // <example>
68 // <srcblock>
69 // </srcblock>
70 // </example>
71 
72 
73  class DSPoly : public DSClosed {
74 
75  public:
76 
77  // Constructors and destructor
78  // <group>
79  DSPoly();
80  DSPoly(const DSPoly& other);
81  DSPoly(const casacore::Matrix<casacore::Float>& points, const casacore::Bool& handles = false,
82  const casacore::Bool& drawHandles = false);
83 
84  virtual ~DSPoly();
85  // </group>
86 
87  // General DisplayShape functions
88  // <group>
89  virtual void draw(PixelCanvas *pc);
90  virtual void rotate(const casacore::Float& angle);
91  virtual casacore::Bool inObject(const casacore::Float& xPos, const casacore::Float& yPos);
92  virtual void scale(const casacore::Float& scale);
93  virtual void move (const casacore::Float& dX, const casacore::Float& dY);
94  virtual void changePoint(const casacore::Vector<casacore::Float>& newLocation);
95  virtual void changePoint(const casacore::Vector<casacore::Float>& newLocation, const casacore::Int point);
96  virtual void setCenter(const casacore::Float& xPos, const casacore::Float& yPos);
98  virtual void rotateAbout(const casacore::Float& angle, const casacore::Float& aboutX,
99  const casacore::Float& aboutY);
100  // </group>
101 
102  // Polygon specific functions, add, delete and set points, all in pixels.
103  // Add point decides the best place in the array to insert the new point.
104  // Similarly, deletePoints(const casacore::Vector<casacore::Float>& remove) deletes the point
105  // closest to that provided.
106  // <group>
107  virtual void addPoint(const casacore::Vector<casacore::Float>& newPoint);
108  virtual void deletePoint(const casacore::Vector<casacore::Float>& removePoint);
109  virtual void deletePoint(const casacore::Int nPoint);
110  virtual void setPoints(const casacore::Matrix<casacore::Float>& newPoints);
111  // </group>
112 
113 
114  // Get and set options
115  // <group>
116  virtual casacore::Record getOptions();
117  virtual casacore::Bool setOptions(const casacore::Record& settings);
118  // </group>
119 
120  private:
121 
122  // Points used to draw (with scaling + rotation)
127 
128  virtual void setDefaultOptions();
129  virtual casacore::Float getArea();
130 
131  protected:
133 
134  };
135 
136 } //# NAMESPACE CASA - END
137 
138 #endif
int Int
Definition: aipstype.h:50
virtual void addPoint(const casacore::Vector< casacore::Float > &newPoint)
Polygon specific functions, add, delete and set points, all in pixels.
virtual casacore::Bool setOptions(const casacore::Record &settings)
virtual void setCenter(const casacore::Float &xPos, const casacore::Float &yPos)
Sets the center of the DisplayShape.
casacore::Bool itsValidCenter
Definition: DSPoly.h:126
virtual casacore::Vector< casacore::Float > getCenter()
Returns the center of the DisplayShape (x,y).
casacore::Bool itsValidPoints
Definition: DSPoly.h:125
virtual casacore::Bool inObject(const casacore::Float &xPos, const casacore::Float &yPos)
Is the supplied point within the DisplayShape?
casacore::Vector< casacore::Float > itsPolyCenter
Definition: DSPoly.h:124
virtual void rotateAbout(const casacore::Float &angle, const casacore::Float &aboutX, const casacore::Float &aboutY)
Base class defining interface to pixel-based output devices.
Definition: PixelCanvas.h:161
virtual void scale(const casacore::Float &scale)
Scale the shape about its center by the scaleFactor.
virtual casacore::Matrix< casacore::Float > getPoints()
virtual void changePoint(const casacore::Vector< casacore::Float > &newLocation)
Changes the closest point to the supplied location to that location.
Implementation of a Polygon.
Definition: DSPoly.h:73
virtual void move(const casacore::Float &dX, const casacore::Float &dY)
virtual void deletePoint(const casacore::Vector< casacore::Float > &removePoint)
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
virtual void rotate(const casacore::Float &angle)
Rotate the shape about its center by a set angle (angle in degrees).
float Float
Definition: aipstype.h:54
casacore::Matrix< casacore::Float > itsPoints
Points used to draw (with scaling + rotation)
Definition: DSPoly.h:123
DSClosed provides common functionality for all &quot;closed&quot; shapes.
Definition: DSClosed.h:64
virtual void draw(PixelCanvas *pc)
General DisplayShape functions.
virtual ~DSPoly()
virtual void setDefaultOptions()
Used to set up the class when default constructor called.
virtual void setPoints(const casacore::Matrix< casacore::Float > &newPoints)
virtual casacore::Float getArea()
DSPoly()
Constructors and destructor.
virtual casacore::Record getOptions()
Get and set options.