DDDObject.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef TRIALDISPLAY_DDDOBJECT_H
00029 #define TRIALDISPLAY_DDDOBJECT_H
00030
00031 #include <casa/aips.h>
00032 #include <casa/Containers/Record.h>
00033 #include <casa/Containers/Block.h>
00034 #include <casa/Arrays/Matrix.h>
00035 #include <display/Display/DisplayEnums.h>
00036 #include <display/DisplayEvents/WCRefreshEH.h>
00037 #include <display/DisplayEvents/WCMotionEH.h>
00038 #include <display/DisplayEvents/WCPositionEH.h>
00039 #include <display/DisplayDatas/DDDHandle.h>
00040
00041 namespace casa {
00042
00043 class WorldCanvas;
00044 class WCPositionEvent;
00045 class DrawingDisplayData;
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 class DDDObject : public WCRefreshEH, public WCMotionEH,
00063 public WCPositionEH {
00064
00065 public:
00066
00067 enum Mode {
00068 None,
00069 Handle,
00070 Move,
00071 Rotate
00072 };
00073
00074
00075
00076 DDDObject(const Record &description, DrawingDisplayData *owner);
00077
00078
00079 virtual ~DDDObject();
00080
00081
00082
00083 virtual void draw(const Display::RefreshReason &reason,
00084 WorldCanvas *worldcanvas) = 0;
00085
00086
00087
00088
00089
00090
00091
00092 virtual void showHandles(const Bool show, const Bool tellOwner = True);
00093
00094
00095 virtual Bool showingHandles() {
00096 return itsShowHandles;
00097 }
00098
00099
00100 virtual Record description();
00101
00102
00103
00104 virtual void setDescription(const Record &rec);
00105
00106
00107
00108
00109
00110 virtual Bool storeClick(const DisplayEvent &ev);
00111
00112
00113 virtual void clearClickBuffer();
00114
00115
00116 Int objectID() const {
00117 return itsObjectID;
00118 }
00119
00120
00121
00122
00123 virtual void operator()(const WCRefreshEvent &ev) = 0;
00124 virtual void operator()(const WCPositionEvent &ev) = 0;
00125 virtual void operator()(const WCMotionEvent &ev) = 0;
00126
00127
00128 protected:
00129
00130
00131 DrawingDisplayData *owner() {
00132 return itsOwner;
00133 }
00134
00135
00136 String color() const {
00137 return itsColor;
00138 }
00139
00140
00141 String label() const {
00142 return itsLabel;
00143 }
00144
00145
00146 Int lineWidth() const {
00147 return itsLineWidth;
00148 }
00149
00150 Bool isEditable() const {
00151 return itsEditable;
00152 }
00153
00154 Bool isMovable() const {
00155 return itsMovable;
00156 }
00157
00158 Bool isFixed() const {
00159 return !itsMovable && !itsEditable;
00160 }
00161
00162
00163 DDDObject();
00164
00165
00166 DDDObject(const DDDObject &other);
00167
00168
00169 void operator=(const DDDObject &other);
00170
00171
00172 void translateMatrix(Matrix<Double>& points, Double dx, Double dy);
00173
00174
00175 Matrix<Double> rotateMatrix(const Matrix<Double>& points, Double angle);
00176
00177
00178
00179 Bool inPolygon(const Matrix<Double>& points, Double x, Double y);
00180 Bool inPolygon(const Vector<Double>& xP, const Vector<Double>& yP,
00181 Double x, Double y);
00182
00183
00184
00185 void convertCoordinateSystem (DisplayCoordinateSystem& cSys, WorldCanvas* wcPtr) const;
00186
00187
00188 Bool onHandle(const Block<DDDHandle>& handles,
00189 Double x, Double y);
00190
00191 private:
00192
00193
00194 DrawingDisplayData *itsOwner;
00195
00196
00197
00198 Bool itsShowHandles;
00199
00200
00201 Bool itsEditable;
00202
00203 Bool itsMovable;
00204
00205
00206 Double itsLastClickTime, its2ndLastClickTime;
00207
00208
00209 String itsColor;
00210
00211
00212 Int itsLineWidth;
00213
00214
00215 String itsLabel;
00216
00217
00218 Int itsObjectID;
00219
00220 };
00221
00222
00223 }
00224
00225 #endif