00001 //# DDDPolygon.h: declaration of DDDPolygon 00002 //# Copyright (C) 1999,2000,2001,2002 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id$ 00027 00028 00029 #ifndef TRIALDISPLAY_DDDPOLYGON_H 00030 #define TRIALDISPLAY_DDDPOLYGON_H 00031 00032 #include <casa/aips.h> 00033 #include <casa/Arrays/Vector.h> 00034 #include <casa/Arrays/Matrix.h> 00035 #include <casa/Containers/Record.h> 00036 #include <casa/Containers/Block.h> 00037 #include <casa/Logging/LogIO.h> 00038 #include <casa/Quanta/Quantum.h> 00039 #include <casa/Quanta/Unit.h> 00040 #include <display/Display/DisplayCoordinateSystem.h> 00041 #include <display/DisplayDatas/DDDObject.h> 00042 #include <display/DisplayDatas/DDDHandle.h> 00043 00044 namespace casa { //# NAMESPACE CASA - BEGIN 00045 00046 class LogIO; 00047 00048 // <summary> 00049 // Implementation of aan ellipse object for DrawingDisplayData class. 00050 // </summary> 00051 00052 // <synopsis> 00053 // This class implements the interface defined by DDDObject, to provide 00054 // a polygon object for registration with DrawingDisplayData objects. 00055 // </synopsis> 00056 // 00057 // <todo> 00058 // Allow vertices to be edited. 00059 // </todo> 00060 // 00061 00062 class DDDPolygon : public DDDObject { 00063 00064 public: 00065 00066 // Constructor taking a Record description. Fields in the record, 00067 // on top of what is consumed by the DDDObject constructor, are: 00068 // Required : <src>x</src> (quantum of vector double) and 00069 // <src>y</src> (quantum of vector double). 00070 // Other, not required fields are <src>outline & editable</src> 00071 // which default to <src>True</src>. When <src>editable=False</src> 00072 // the object can be moved but not reshaped, when <src>True</src> 00073 // it can be moved and reshaped. When <src>outline=False</src> 00074 // the ellipse is filled. 00075 DDDPolygon(const Record &description, DrawingDisplayData *owner); 00076 00077 // Destructor. 00078 virtual ~DDDPolygon(); 00079 00080 // Draw this rectangle object for the given reason on the provided 00081 // WorldCanvas. 00082 virtual void draw(const Display::RefreshReason &reason, 00083 WorldCanvas *worldcanvas); 00084 00085 // Return a record describing this object. Presently returns 00086 // only construction description. 00087 virtual Record description(); 00088 00089 // Update this object based on the information in the provided 00090 // Record. 00091 virtual void setDescription(const Record &rec); 00092 00093 // Event handlers. The parent DrawingDisplayData will distribute 00094 // events as necessary to the various DDDObjects which comprise it. 00095 // <group> 00096 virtual void operator()(const WCRefreshEvent &/*ev*/) { 00097 ; 00098 }; 00099 virtual void operator()(const WCPositionEvent &ev); 00100 virtual void operator()(const WCMotionEvent &ev); 00101 // </group> 00102 00103 00104 00105 00106 protected: 00107 00108 // (Required) default constructor. 00109 DDDPolygon(); 00110 00111 // (Required) copy constructor. 00112 DDDPolygon(const DDDPolygon &other); 00113 00114 // (Required) copy assignment. 00115 void operator=(const DDDPolygon &other); 00116 00117 private: 00118 00119 // Fill style 00120 Bool itsOutline; 00121 00122 // Define x and y 00123 Quantum<Vector<Double> > itsWorldX, itsWorldY; 00124 Vector<Double> itsPixelX, itsPixelY; 00125 uInt itsNPoints; 00126 00127 // Rotated Rectangle Corners to draw in screen pixel 00128 Matrix<Double> itsCorners; 00129 00130 // List of handles 00131 00132 Block<DDDHandle> itsHandles; 00133 00134 // Mode. 00135 00136 DDDObject::Mode itsMode; 00137 00138 // Store for movement bases. 00139 00140 Double itsBaseMoveX, itsBaseMoveY; 00141 00142 // In function draw(), recompute all pixel coordinates when true 00143 // else use what is currently set 00144 00145 Bool itsRecompute; 00146 00147 // LOgger 00148 00149 LogIO itsLogger; 00150 00151 // DisplayCoordinateSystem in screen pixel coordinates 00152 DisplayCoordinateSystem itsCoordinateSystem; 00153 00154 // pointer to world canvas (shallow copy) 00155 WorldCanvas* itsWorldCanvasPtr; 00156 00157 // Fractional indicators 00158 Bool itsFracX, itsFracY; 00159 00160 // COnvert parameters from world to pixel 00161 void convertToPixel (); 00162 00163 // Update private world parameters from current pixel values 00164 void updateWorldValues (); 00165 00166 // Decode record into private data 00167 void decode(const RecordInterface& description, Bool required); 00168 00169 // Encode private data into record 00170 void encode(RecordInterface& description) const; 00171 00172 // compute corners of rectangle of bounding box of polygon 00173 void createCorners(); 00174 00175 // create handles, one per vertex 00176 void createHandles(); 00177 00178 00179 // Debugging routines 00180 00181 void listWorld(); 00182 void listPixel(); 00183 00184 }; 00185 00186 00187 } //# NAMESPACE CASA - END 00188 00189 #endif 00190