casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DisplayShapeInterface.h
Go to the documentation of this file.
1 //# DisplayShapeInterface.h: Simple wrapper 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_DISPLAYSHAPEINTERFACE_H
29 #define TRIALDISPLAY_DISPLAYSHAPEINTERFACE_H
30 
31 
32 #include <casa/aips.h>
33 
37 #include <casa/Containers/Record.h>
38 
39 namespace casa { //# NAMESPACE CASA - BEGIN
40 
41 //class PixelCanvas;
42 //class WorldCanvas;
43 
44 // <summary>
45 // Wrapper for DisplayShapes;provides easier/unified constr. of DisplayShapes
46 // </summary>
47 //
48 // <prerequisite>
49 // <li> <linkto class="DisplayShape">DisplayShape</linkto>
50 // </prerequisite>
51 //
52 // <etymology>
53 // DisplayShapeInterface makes it easier to work with DisplayShapes.
54 // </etymology>
55 //
56 // <synopsis>
57 // DisplayShapeInterface simply contains a pointer to a DisplayShape object.
58 // It allows all DisplayShapes to be constructed via a single constructor. i.e.
59 // the DisplayShapeInterface constructor actually decides which shape to
60 // create based on the information in the casacore::Record passed to it. It makes
61 // creating new shapes look a little nice, since:
62 // <srcblock>
63 // record1.define("type", "square");
64 // and
65 // record2.define("type", "circle");
66 // </srcblock>
67 // can both be simply made into a new DisplayShapeInterface, e.g.
68 // <srcblock>
69 // DisplayShapeInterface* myShape = new DisplayShapeInterface(record1);
70 // or
71 // DisplayShapeInterface* myShape = new DisplayShapeInterface(record2);
72 // </srcblock>
73 // It also guarantees consistant interfaces between shapes.
74 // </synopsis>
75 //
76 // <motivation>
77 // The creation of an interface to DisplayShapes makes use of the simpler.
78 // </motivation>
79 //
80 // <example>
81 // </example>
82 
83 
84 
85 
87 
88  public:
90 
91  // Constructor for a standard shape. The shape will be totally based on
92  // pixel sizes, both for it's position and sizes.
93  DisplayShapeInterface(const casacore::Record& shapeInfo);
94 
95  // Constructor for shape based on relative screen positions. if
96  // scaled is true, relative screen positions will be used for
97  // height etc also. If not, positions only will be based on relative
98  // screen pos, heights will be based on an absolute pixel value.
99  DisplayShapeInterface(const casacore::Record& shapeInfo, const PixelCanvas* pc,
100  const casacore::Bool scale = true);
101 
102  // Constructor for shape based on world co-ordinates (NYI)
103  DisplayShapeInterface(const casacore::Record shapeInfo, const WorldCanvas* wc);
104 
105  // Copy cons
107 
108  virtual ~DisplayShapeInterface();
109 
110 
111  // DisplayShape functionality. All of these functions simply wrap those
112  // of the underlying DisplayShape (and add conversion functionality).
113  // Please see <linkto class="DisplayShape">DisplayShape</linkto>
114  // for a full description of these functions.
115  // <group>
116  virtual casacore::Bool inObject(const casacore::Float xPos, const casacore::Float yPos);
117  virtual casacore::Bool onHandles(const casacore::Float xPos, const casacore::Float yPos);
119  virtual void setCenter(const casacore::Float xPos, const casacore::Float yPos);
120  virtual casacore::Bool whichHandle(const casacore::Float xPos, const casacore::Float yPos, casacore::Int& out);
121  virtual void changePoint(const casacore::Vector<casacore::Float>& newPos);
122  virtual void changePoint(const casacore::Vector<casacore::Float>& newPoint, const casacore::Int nPoint);
123  virtual void addPoint(const casacore::Vector<casacore::Float>& newPoint);
124  virtual void rotate(const casacore::Float angle);
125  virtual void scale(const casacore::Float angle);
126  virtual void draw(PixelCanvas* toDrawTo);
127  virtual void move(const casacore::Float dX, const casacore::Float dY);
128  virtual void addLocked(DisplayShapeInterface* toLock);
129  virtual void removeLocked(DisplayShapeInterface* removeLock);
130  virtual void setDrawHandles(const casacore::Bool& draw);
131  virtual casacore::Bool setOptions(const casacore::Record& newOptions);
132  virtual casacore::Record getOptions() ;
133  // </group>
134 
135  // Update the pixel location of this shape, based on the stored information
136  // on its location. If the shape is being used in pixel mode this will do
137  // nothing. If being used in relative screen mode or WC mode, this will
138  // update its location. Returns false if a conversion to pixels fail.
140 
141  // If the shape is being used in absolute pixel co-ordinates, this will do
142  // nothing. If being used in relative screen or WC mode, this will update
143  // the position based on its current pixel location. Returns false if the
144  // conversion to the other co-ord type fails.
146 
147  // Returns the pointer to the underlying object
148  virtual DisplayShape* getObject();
149 
150  // If the shape is a PolyLine, this function will change it to a polygon.
151  // This is designed for use in the creation of polygon by the user clicking
152  // out a polyline, for example.
153  virtual void toPolygon();
154 
155 
156  private:
158 
159  // Will return an option set with whatever the current
160  // coords method is.
162 
167 
174 
179 
180  void makeShape(const casacore::Record& shapeInfo);
181 
182  // Scale widths and heights in relative mode?
184 
185  // Copy of shape, however in its alternate coord form
187  };
188 
189 
190 
191 } //# NAMESPACE CASA - END
192 
193 #endif
int Int
Definition: aipstype.h:50
virtual void setCenter(const casacore::Float xPos, const casacore::Float yPos)
virtual void rotate(const casacore::Float angle)
virtual casacore::Bool inObject(const casacore::Float xPos, const casacore::Float yPos)
DisplayShape functionality.
virtual casacore::Record getOptions()
casacore::Record pixToWorldOpts(const casacore::Record &pix)
virtual DisplayShape * getObject()
Returns the pointer to the underlying object.
void makeShape(const casacore::Record &shapeInfo)
virtual void toPolygon()
If the shape is a PolyLine, this function will change it to a polygon.
virtual casacore::Bool updatePixelPosition()
Update the pixel location of this shape, based on the stored information on its location.
casacore::Vector< casacore::Float > relToPix(const casacore::Vector< casacore::Float > &rel)
casacore::Bool itsScale
Scale widths and heights in relative mode?
Base class defining interface to pixel-based output devices.
Definition: PixelCanvas.h:161
virtual void move(const casacore::Float dX, const casacore::Float dY)
virtual void draw(PixelCanvas *toDrawTo)
casacore::Record worldToPixOpts(const casacore::Record &world)
virtual casacore::Bool onHandles(const casacore::Float xPos, const casacore::Float yPos)
casacore::Record toPixOpts(const casacore::Record &notPix)
casacore::Float pixToRelHeight(const casacore::Float pix)
casacore::Float relToPixHeight(const casacore::Float rel)
The abstract base class for all &quot;DisplayShapes&quot;.
Definition: DisplayShape.h:77
class PixelCanvas; class WorldCanvas;
virtual void addPoint(const casacore::Vector< casacore::Float > &newPoint)
casacore::Vector< casacore::Float > pixToRel(const casacore::Vector< casacore::Float > &pix)
casacore::Record altCoords
Copy of shape, however in its alternate coord form.
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 changePoint(const casacore::Vector< casacore::Float > &newPos)
float Float
Definition: aipstype.h:54
virtual void scale(const casacore::Float angle)
casacore::Record pixToRelOpts(const casacore::Record &pixel)
casacore::Record relToPixOpts(const casacore::Record &relative)
Implementation of drawing in world coordinates on top of a PixelCanvas.
Definition: WorldCanvas.h:204
casacore::Float pixToRelWidth(const casacore::Float pix)
virtual casacore::Bool whichHandle(const casacore::Float xPos, const casacore::Float yPos, casacore::Int &out)
DisplayShapeInterface::Coord itsCoords
virtual void setDrawHandles(const casacore::Bool &draw)
casacore::Float relToPixWidth(const casacore::Float rel)
virtual void removeLocked(DisplayShapeInterface *removeLock)
virtual casacore::Bool setOptions(const casacore::Record &newOptions)
virtual void addLocked(DisplayShapeInterface *toLock)
casacore::Record fromPixOpts(const casacore::Record &pix)
Will return an option set with whatever the current coords method is.
DisplayShapeInterface(const casacore::Record &shapeInfo)
Constructor for a standard shape.
virtual casacore::Vector< casacore::Float > getCenter() const
virtual casacore::Bool updateNonPixelPosition()
If the shape is being used in absolute pixel co-ordinates, this will do nothing.