casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DDDObject.h
Go to the documentation of this file.
1 //# DDDObject.h: base object interface for DrawingDisplayData
2 //# Copyright (C) 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_DDDOBJECT_H
29 #define TRIALDISPLAY_DDDOBJECT_H
30 
31 #include <casa/aips.h>
32 #include <casa/Containers/Record.h>
33 #include <casa/Containers/Block.h>
34 #include <casa/Arrays/Matrix.h>
40 
41 namespace casa { //# NAMESPACE CASA - BEGIN
42 
43  class WorldCanvas;
44  class WCPositionEvent;
45  class DrawingDisplayData;
46 
47 
48 // <summary>
49 // Base class describing interface for objects supported by DrawingDisplayData
50 // </summary>
51 
52 // <synopsis>
53 // This class defines the interface which objects that are drawable
54 // by the DrawingDisplayData class must provide.
55 //
56 // World units of 'pix' and 'frac' are defined. 'pix' units are in
57 // screen pixel units. They are not very useful once the display
58 // has been zoomed. 'frac' units have range [0,0] -> [1,1]
59 // mapping to the display part of the pixel canvas.
60 // </synopsis>
61 
62  class DDDObject : public WCRefreshEH, public WCMotionEH,
63  public WCPositionEH {
64 
65  public:
66 
67  enum Mode {
72  };
73 
74  // Constructor taking a casacore::Record description. Fields in the record
75  // are: <src>color</src> and <src>label</src>.
77 
78  // Destructor.
79  virtual ~DDDObject();
80 
81  // Draw this DrawingDisplayData object for the given reason on the
82  // provided WorldCanvas.
83  virtual void draw(const Display::RefreshReason &reason,
84  WorldCanvas *worldcanvas) = 0;
85 
86  // Indicate whether the object should show its handles or not. The
87  // parent DrawingDisplayData will control this, and either ask all
88  // DDDObjects to show their handles or not, via the user setting an
89  // option. This actually controls the state of whether this
90  // DDDObject is editable, so the parent DrawingDisplayData could
91  // also allow editing of only one DDDObject at a time.
92  virtual void showHandles(const casacore::Bool show, const casacore::Bool tellOwner = true);
93 
94  // Query whether the object is showing its handles.
96  return itsShowHandles;
97  }
98 
99  // Return a record describing this object.
100  virtual casacore::Record description();
101 
102  // Update this object based on the information in the provided
103  // Record.
104  virtual void setDescription(const casacore::Record &rec);
105 
106  // Store a click in the buffer and look for a double-click event.
107  // If one is found, then call the doubleClick function in the
108  // owning DisplayData. Returns <src>true</src> if a double click
109  // was detected.
110  virtual casacore::Bool storeClick(const DisplayEvent &ev);
111 
112  // Clear the click buffer.
113  virtual void clearClickBuffer();
114 
115  // Return the unique id of this object.
117  return itsObjectID;
118  }
119 
120  // Event handlers. The parent DrawingDisplayData will distribute
121  // events as necessary to the various DDDObjects which comprise it.
122  // <group>
123  virtual void operator()(const WCRefreshEvent &ev) = 0;
124  virtual void operator()(const WCPositionEvent &ev) = 0;
125  virtual void operator()(const WCMotionEvent &ev) = 0;
126  // </group>
127 
128  protected:
129 
130  // Return the owner of this object.
132  return itsOwner;
133  }
134 
135  // Return the color to use to draw this object.
137  return itsColor;
138  }
139 
140  // Return the label of this object.
142  return itsLabel;
143  }
144 
145  // Return the line width of this object.
147  return itsLineWidth;
148  }
149 
151  return itsEditable;
152  }
153 
155  return itsMovable;
156  }
157 
159  return !itsMovable && !itsEditable;
160  }
161 
162  // (Required) default constructor.
163  DDDObject();
164 
165  // (Required) copy constructor.
166  DDDObject(const DDDObject &other);
167 
168  // (Required) copy assignment.
169  void operator=(const DDDObject &other);
170 
171  // Translate Matrix
173 
174  // Rotate Matrix
176 
177  // Is point inside the polygon
178  // <group>
182  // </group>
183 
184  // Convert DisplayCoordinateSystem to screen pixels
186 
187  // Is the point on a handle
190 
191  private:
192 
193  // DrawingDisplayData which owns this DDDObject.
195 
196  // Whether the handles are showing, and therefore whether this
197  // DDDObject is presently editable.
199 
200  // Is this object editable
202  // Is it movable
204 
205  // Timing for double clicks.
207 
208  // Color of this object.
210 
211  // Line width of the lines drawn
213 
214  // Label for this object.
216 
217  // Unique identification for this object.
219 
220  };
221 
222 
223 } //# NAMESPACE CASA - END
224 
225 #endif
virtual void draw(const Display::RefreshReason &reason, WorldCanvas *worldcanvas)=0
Draw this DrawingDisplayData object for the given reason on the provided WorldCanvas.
casacore::Bool isEditable() const
Definition: DDDObject.h:150
DrawingDisplayData * owner()
Return the owner of this object.
Definition: DDDObject.h:131
int Int
Definition: aipstype.h:50
Class which stores WorldCanvas refresh event information.
DisplayData which provides interactive drawing capabilities.
virtual ~DDDObject()
Destructor.
casacore::String itsLabel
Label for this object.
Definition: DDDObject.h:215
casacore::Bool inPolygon(const casacore::Matrix< casacore::Double > &points, casacore::Double x, casacore::Double y)
Is point inside the polygon.
Base class for handling WorldCanvas motion events.
Definition: WCMotionEH.h:70
casacore::Int objectID() const
Return the unique id of this object.
Definition: DDDObject.h:116
virtual void clearClickBuffer()
Clear the click buffer.
casacore::String label() const
Return the label of this object.
Definition: DDDObject.h:141
casacore::Bool isMovable() const
Definition: DDDObject.h:154
virtual void setDescription(const casacore::Record &rec)
Update this object based on the information in the provided Record.
void show(const variant &v)
virtual casacore::Bool showingHandles()
Query whether the object is showing its handles.
Definition: DDDObject.h:95
casacore::Bool isFixed() const
Definition: DDDObject.h:158
DrawingDisplayData * itsOwner
DrawingDisplayData which owns this DDDObject.
Definition: DDDObject.h:194
Base class for handling WorldCanvas refresh events.
Definition: WCRefreshEH.h:95
casacore::Matrix< casacore::Double > rotateMatrix(const casacore::Matrix< casacore::Double > &points, casacore::Double angle)
Rotate Matrix.
Class which stores WorldCanvas motion event information.
Definition: WCMotionEvent.h:79
casacore::Int itsObjectID
Unique identification for this object.
Definition: DDDObject.h:218
void convertCoordinateSystem(DisplayCoordinateSystem &cSys, WorldCanvas *wcPtr) const
Convert DisplayCoordinateSystem to screen pixels.
casacore::String color() const
Return the color to use to draw this object.
Definition: DDDObject.h:136
casacore::Bool onHandle(const casacore::Block< DDDHandle > &handles, casacore::Double x, casacore::Double y)
Is the point on a handle.
double Double
Definition: aipstype.h:55
casacore::Bool itsShowHandles
Whether the handles are showing, and therefore whether this DDDObject is presently editable...
Definition: DDDObject.h:198
casacore::Bool itsMovable
Is it movable.
Definition: DDDObject.h:203
Class describing the most basic event information in the display classes.
Definition: DisplayEvent.h:82
Base class describing interface for objects supported by DrawingDisplayData.
Definition: DDDObject.h:62
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
void translateMatrix(casacore::Matrix< casacore::Double > &points, casacore::Double dx, casacore::Double dy)
Translate Matrix.
void operator=(const DDDObject &other)
(Required) copy assignment.
simple 1-D array
casacore::Int lineWidth() const
Return the line width of this object.
Definition: DDDObject.h:146
RefreshReason
Callback reasons for PCRefreshEvent and WCRefreshEvent.
Definition: DisplayEnums.h:267
Class which stores WorldCanvas position event information.
virtual casacore::Bool storeClick(const DisplayEvent &ev)
Store a click in the buffer and look for a double-click event.
Implementation of drawing in world coordinates on top of a PixelCanvas.
Definition: WorldCanvas.h:204
casacore::String itsColor
Color of this object.
Definition: DDDObject.h:209
virtual void showHandles(const casacore::Bool show, const casacore::Bool tellOwner=true)
Indicate whether the object should show its handles or not.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
Base class for handling WorldCanvas position events.
Definition: WCPositionEH.h:75
virtual void operator()(const WCRefreshEvent &ev)=0
Event handlers.
casacore::Int itsLineWidth
Line width of the lines drawn.
Definition: DDDObject.h:212
casacore::Double its2ndLastClickTime
Definition: DDDObject.h:206
casacore::Bool itsEditable
Is this object editable.
Definition: DDDObject.h:201
casacore::Double itsLastClickTime
Timing for double clicks.
Definition: DDDObject.h:206
DDDObject()
(Required) default constructor.
virtual casacore::Record description()
Return a record describing this object.