casa
$Rev:20696$
|
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 <coordinates/Coordinates/CoordinateSystem.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 virtual void operator()(const WCPositionEvent &ev); 00098 virtual void operator()(const WCMotionEvent &ev); 00099 // </group> 00100 00101 00102 00103 00104 protected: 00105 00106 // (Required) default constructor. 00107 DDDPolygon(); 00108 00109 // (Required) copy constructor. 00110 DDDPolygon(const DDDPolygon &other); 00111 00112 // (Required) copy assignment. 00113 void operator=(const DDDPolygon &other); 00114 00115 private: 00116 00117 // Fill style 00118 Bool itsOutline; 00119 00120 // Define x and y 00121 Quantum<Vector<Double> > itsWorldX, itsWorldY; 00122 Vector<Double> itsPixelX, itsPixelY; 00123 uInt itsNPoints; 00124 00125 // Rotated Rectangle Corners to draw in screen pixel 00126 Matrix<Double> itsCorners; 00127 00128 // List of handles 00129 00130 Block<DDDHandle> itsHandles; 00131 00132 // Mode. 00133 00134 DDDObject::Mode itsMode; 00135 00136 // Store for movement bases. 00137 00138 Double itsBaseMoveX, itsBaseMoveY; 00139 00140 // In function draw(), recompute all pixel coordinates when true 00141 // else use what is currently set 00142 00143 Bool itsRecompute; 00144 00145 // LOgger 00146 00147 LogIO itsLogger; 00148 00149 // CoordinateSystem in screen pixel coordinates 00150 CoordinateSystem itsCoordinateSystem; 00151 00152 // pointer to world canvas (shallow copy) 00153 WorldCanvas* itsWorldCanvasPtr; 00154 00155 // Fractional indicators 00156 Bool itsFracX, itsFracY; 00157 00158 // COnvert parameters from world to pixel 00159 void convertToPixel (); 00160 00161 // Update private world parameters from current pixel values 00162 void updateWorldValues (); 00163 00164 // Decode record into private data 00165 void decode(const RecordInterface& description, Bool required); 00166 00167 // Encode private data into record 00168 void encode(RecordInterface& description) const; 00169 00170 // compute corners of rectangle of bounding box of polygon 00171 void createCorners(); 00172 00173 // create handles, one per vertex 00174 void createHandles(); 00175 00176 00177 // Debugging routines 00178 00179 void listWorld(); 00180 void listPixel(); 00181 00182 }; 00183 00184 00185 } //# NAMESPACE CASA - END 00186 00187 #endif 00188