casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DisplayShape.h
Go to the documentation of this file.
1 //# DisplayShape.h: Abstract base class for all shapes/annotations objects
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_DISPLAYSHAPE_H
29 #define TRIALDISPLAY_DISPLAYSHAPE_H
30 
31 #include <casa/aips.h>
32 #include <casa/Arrays/Matrix.h>
33 #include <casa/Containers/Record.h>
34 
35 namespace casa { //# NAMESPACE CASA - BEGIN
36 
37  class DSShape;
38  class DSClosed;
39  class DisplayEnums;
40  class PixelCanvas;
41  class DParameterColorChoice;
42 
43 
44 // <summary>
45 // The abstract base class for all "DisplayShapes".
46 // </summary>
47 //
48 // <prerequisite>
49 // </prerequisite>
50 //
51 // <etymology>
52 // DisplayShape is a way of providing a consistant interface to a large number
53 // of different shapes.
54 // </etymology>
55 //
56 // <synopsis>
57 // DisplayShape provides a framework from which a large number of different
58 // shapes can be made, all with the same interface. Any new DisplayShape
59 // should inherit from this class, or higher level classes
60 // (see <linkto class="DSPoly">DSPoly</linkto> etc).
61 //
62 // There are generally two ways to make DisplayShape(s); To create them in
63 // "one hit" by providing arguments to the constructor, or by using the
64 // default constructor and then the "setOptions" method. A simple interface
65 // for all classes inheriting from the
66 // <linkto class="DisplayShape">DisplayShape</linkto> class is provided
67 // by <linkto class="DisplayShapeInterface">DisplayShapeInterface</linkto>.
68 // </synopsis>
69 //
70 // <motivation>
71 // A common interface to a large number of shapes was desired.
72 // </motivation>
73 //
74 // <example>
75 // </example>
76 
77  class DisplayShape {
78 
79  public:
80  // Handle style
83  };
84 
85 
86  // Default constructor. Creates shape with default options set
87  DisplayShape();
88  // Copy constructor
89  DisplayShape(const DisplayShape& other);
90  // Destructor
91  virtual ~DisplayShape();
92 
93  // These functions contol behaviour of handles during a call
94  // to the display shape object.
95  // (These calls should be propogated up through the class tree).
96  // <group>
97  virtual void draw(PixelCanvas* pc);
98  virtual void rotateAbout(const casacore::Float& relAngle, const casacore::Float& aboutX,
99  const casacore::Float& aboutY) ;
100  virtual void move(const casacore::Float& dX, const casacore::Float& dY);
101  // </group>
102 
103 
104  // Rotate the supplied polygon (column 1 - x values, column 2 - y values)
105  // about the supplied point by the supplied angle. NB Angle in radians
107  const casacore::Float& angle,
108  const casacore::Float& aboutX,
109  const casacore::Float& aboutY);
110 
111  // Rotates a point around the point specified. NB Angle in radians.
113  const casacore::Float& angle,
114  const casacore::Float& aboutX, const casacore::Float& aboutY);
115 
116  // Translate an entire matrix by the specified dx / dy amounts.
118  const casacore::Float& dx, const casacore::Float& dy);
119 
120  // Is xPos, YPos inside the supplied points (column 1 - x values,
121  // clolumn 2 - y values)
123  const casacore::Float& yPos);
124 
125  // Determine the two vertices (firstVert, secondVert) which join the line
126  // closest to the xPos, yPos point supplied. If closedPoly is left as
127  // true, the points supplied are treated as a polygon, if not as a poly
128  // line.
130  const casacore::Float& yPos,
131  casacore::Int& firstVert, casacore::Int& secondVert,
132  const casacore::Bool& closedPoly = true);
133 
134  // For a specified set of points, find the closest to xPos,YPos. out
135  // relates the matrix index (row number) of the closest point.
137  const casacore::Float& xPos, const casacore::Float& yPos,
138  casacore::Int& out);
139 
140  // Find the closest two Points from a casacore::Matrix to the specified point.
142  const casacore::Float& xPos, const casacore::Float& yPos,
143  casacore::Int& outClosest, casacore::Int& outSecond);
144 
145  // Is the supplied point within the DisplayShape?
146  virtual casacore::Bool inObject(const casacore::Float& xPos, const casacore::Float& yPos) = 0;
147 
148  // Convert degrees to radians
149  virtual casacore::Float toRadians(const casacore::Float& degrees);
150 
151  // Conver radians to degree
152  virtual casacore::Float toDegrees(const casacore::Float& radians);
153 
154  // Sets the center of the DisplayShape
155  virtual void setCenter(const casacore::Float& xPos, const casacore::Float& yPos) = 0;
156 
157  // Returns the center of the DisplayShape (x,y).
159 
160  // Changes the closest point to the supplied location to that location
161  virtual void changePoint(const casacore::Vector<casacore::Float>& newPos) = 0;
162 
163  // Changes the nth point making up the DisplayShape ot the specified
164  // location.
165  virtual void changePoint(const casacore::Vector<casacore::Float>& newPoint,
166  const casacore::Int nPoint) = 0;
167 
168  // If applicable, this function will add a point to the shape in the
169  // most meaningful location.
170  virtual void addPoint(const casacore::Vector<casacore::Float>& /*newPoint*/) { };
171 
172  // Rotate the shape about its center by a set angle (angle in degrees).
173  virtual void rotate(const casacore::Float& angle) = 0;
174 
175  // Scale the shape about its center by the scaleFactor
176  virtual void scale(const casacore::Float& scaleFactor) = 0;
177 
178  // Allow locking of other shapes onto this one. When a shape is locked,
179  // if the current shape is moved, so to will the locked shape.
180  virtual void addLocked(DisplayShape* toLock);
181 
182  // Removes a lock from the specified shape.
183  virtual void removeLocked(DisplayShape* removeLock);
184 
185  // Handle management.
186  // <group>
187  virtual void buildHandles(const casacore::Matrix<casacore::Float>& startPoints);
189  virtual void setHandlePositions(const casacore::Matrix<casacore::Float>& newPoints);
190  virtual DSClosed* makeHandle(const casacore::Vector<casacore::Float>& newHandlePos);
191  virtual void addHandle(const casacore::Vector<casacore::Float>& newHandlePos,
192  const casacore::Bool& atEnd = true
193  , const casacore::Int position = 0);
195  virtual casacore::Bool removeHandle(const casacore::Int nHandle);
196 
197  virtual casacore::Bool onHandles(const casacore::Float& xPos, const casacore::Float& yPos);
198  virtual casacore::Bool whichHandle(const casacore::Float& xPos, const casacore::Float& yPos, casacore::Int& out);
199 
200  virtual void setDrawHandles(const casacore::Bool& shouldIDraw);
202  return itsDrawHandles;
203  }
204  virtual void setHasHandles(const casacore::Bool& hasHandles);
205  virtual void setHandleShape(const DisplayShape::HandleShape& shape);
206  virtual void setHandleSize(const casacore::Int pixelSize);
207  virtual void setHandleColor(const casacore::String& handleColor);
208  virtual casacore::uInt nHandles();
209  // </group>
210 
211  // Manage the color of object. (Does not include handles)
212  // <group>
213  virtual void setColor(const casacore::String& newColor);
214  virtual casacore::String getColor();
215  // </group>
216 
217  // Settings
218  // <group>
219  virtual casacore::Record getOptions();
220  virtual casacore::Bool setOptions(const casacore::Record& settings);
221  // </group>
222 
223  virtual void recalculateScreenPosition() {}
224 
225  private:
226  // Set default options
227  virtual void setDefaultOptions();
228 
229 
230  // Object
232 
233  // Handles
235 
236  // Locks
238 
239  // Do I have handles / can a user resize me?
240  // i.e. Do I *ever* want to draw handles (e.g. will be false for an object
241  // which IS a handle!)
243 
244  // Should handles be shown if they exist
246 
247  // Have valid handles been made/supplied yet?
249 
250  // Handle settings
251  // <group>
255  // </group>
256 
257  };
258 
259 } //# NAMESPACE CASA - END
260 
261 #endif
262 
263 
264 
265 
Implementation of DParameterChoice to store color selection parameters.
DParameterColorChoice * itsColor
Object.
Definition: DisplayShape.h:231
int Int
Definition: aipstype.h:50
DisplayShape()
Default constructor.
virtual casacore::Bool whichHandle(const casacore::Float &xPos, const casacore::Float &yPos, casacore::Int &out)
virtual void addPoint(const casacore::Vector< casacore::Float > &)
If applicable, this function will add a point to the shape in the most meaningful location...
Definition: DisplayShape.h:170
virtual void setHandlePositions(const casacore::Matrix< casacore::Float > &newPoints)
virtual DSClosed * makeHandle(const casacore::Vector< casacore::Float > &newHandlePos)
virtual void removeLocked(DisplayShape *removeLock)
Removes a lock from the specified shape.
virtual casacore::Vector< casacore::Float > rotatePoint(const casacore::Vector< casacore::Float > &toRotate, const casacore::Float &angle, const casacore::Float &aboutX, const casacore::Float &aboutY)
Rotates a point around the point specified.
virtual casacore::Float toRadians(const casacore::Float &degrees)
Convert degrees to radians.
virtual void setHandleSize(const casacore::Int pixelSize)
virtual casacore::Bool onHandles(const casacore::Float &xPos, const casacore::Float &yPos)
virtual casacore::uInt nHandles()
virtual ~DisplayShape()
Destructor.
virtual casacore::Bool closestPoints(const casacore::Matrix< casacore::Float > &points, const casacore::Float &xPos, const casacore::Float &yPos, casacore::Int &outClosest, casacore::Int &outSecond)
Find the closest two Points from a casacore::Matrix to the specified point.
virtual casacore::Vector< casacore::Float > getCenter()=0
Returns the center of the DisplayShape (x,y).
virtual void recalculateScreenPosition()
Definition: DisplayShape.h:223
casacore::String itsHandleColor
Handle settings.
Definition: DisplayShape.h:252
virtual casacore::Matrix< casacore::Float > getHandleLocations()
casacore::Bool itsHasHandles
Do I have handles / can a user resize me? i.e.
Definition: DisplayShape.h:242
virtual casacore::Bool removeHandle(const casacore::Vector< casacore::Float > &getRidOf)
Base class defining interface to pixel-based output devices.
Definition: PixelCanvas.h:161
virtual void rotateAbout(const casacore::Float &relAngle, const casacore::Float &aboutX, const casacore::Float &aboutY)
virtual void setColor(const casacore::String &newColor)
Manage the color of object.
virtual casacore::Record getOptions()
Settings.
HandleShape
Handle style.
Definition: DisplayShape.h:81
casacore::Int itsHandleSize
Definition: DisplayShape.h:254
virtual casacore::Bool inObject(const casacore::Float &xPos, const casacore::Float &yPos)=0
Is the supplied point within the DisplayShape?
virtual void setDefaultOptions()
Set default options.
The abstract base class for all &quot;DisplayShapes&quot;.
Definition: DisplayShape.h:77
virtual casacore::String getColor()
virtual void setHandleColor(const casacore::String &handleColor)
virtual casacore::Float toDegrees(const casacore::Float &radians)
Conver radians to degree.
virtual casacore::Matrix< casacore::Float > translateMatrix(const casacore::Matrix< casacore::Float > &points, const casacore::Float &dx, const casacore::Float &dy)
Translate an entire matrix by the specified dx / dy amounts.
virtual void draw(PixelCanvas *pc)
These functions contol behaviour of handles during a call to the display shape object.
virtual void scale(const casacore::Float &scaleFactor)=0
Scale the shape about its center by the scaleFactor.
virtual void addLocked(DisplayShape *toLock)
Allow locking of other shapes onto this one.
virtual void setCenter(const casacore::Float &xPos, const casacore::Float &yPos)=0
Sets the center of the DisplayShape.
casacore::Bool itsDrawHandles
Should handles be shown if they exist.
Definition: DisplayShape.h:245
virtual void addHandle(const casacore::Vector< casacore::Float > &newHandlePos, const casacore::Bool &atEnd=true, const casacore::Int position=0)
virtual void move(const casacore::Float &dX, const casacore::Float &dY)
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
DisplayShape::HandleShape itsHandleShape
Definition: DisplayShape.h:253
virtual void setHasHandles(const casacore::Bool &hasHandles)
casacore::PtrBlock< DSClosed * > itsHandles
Handles.
Definition: DisplayShape.h:234
virtual casacore::Matrix< casacore::Float > rotatePolygon(const casacore::Matrix< casacore::Float > &toRotate, const casacore::Float &angle, const casacore::Float &aboutX, const casacore::Float &aboutY)
Rotate the supplied polygon (column 1 - x values, column 2 - y values) about the supplied point by th...
virtual casacore::Bool setOptions(const casacore::Record &settings)
virtual void setDrawHandles(const casacore::Bool &shouldIDraw)
float Float
Definition: aipstype.h:54
A drop-in replacement for Block&lt;T*&gt;.
Definition: WProjectFT.h:54
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:1944
DSClosed provides common functionality for all &quot;closed&quot; shapes.
Definition: DSClosed.h:64
virtual casacore::Bool inPolygon(const casacore::Matrix< casacore::Float > &points, const casacore::Float &xPos, const casacore::Float &yPos)
Is xPos, YPos inside the supplied points (column 1 - x values, clolumn 2 - y values) ...
virtual void setHandleShape(const DisplayShape::HandleShape &shape)
casacore::PtrBlock< DisplayShape * > itsLocks
Locks.
Definition: DisplayShape.h:237
String: the storage and methods of handling collections of characters.
Definition: String.h:223
virtual void changePoint(const casacore::Vector< casacore::Float > &newPos)=0
Changes the closest point to the supplied location to that location.
virtual casacore::Bool closestLine(const casacore::Matrix< casacore::Float > &points, const casacore::Float &xPos, const casacore::Float &yPos, casacore::Int &firstVert, casacore::Int &secondVert, const casacore::Bool &closedPoly=true)
Determine the two vertices (firstVert, secondVert) which join the line closest to the xPos...
virtual void rotate(const casacore::Float &angle)=0
Rotate the shape about its center by a set angle (angle in degrees).
virtual void buildHandles(const casacore::Matrix< casacore::Float > &startPoints)
Handle management.
virtual casacore::Bool drawingHandles()
Definition: DisplayShape.h:201
unsigned int uInt
Definition: aipstype.h:51
virtual casacore::Bool closestPoint(const casacore::Matrix< casacore::Float > &points, const casacore::Float &xPos, const casacore::Float &yPos, casacore::Int &out)
For a specified set of points, find the closest to xPos,YPos.
casacore::Bool itsValidHandles
Have valid handles been made/supplied yet?
Definition: DisplayShape.h:248