casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
QtPolygon.qo.h
Go to the documentation of this file.
00001 //# QtPolygon.h: base class for statistical regions
00002 //# Copyright (C) 2011, 2012
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 REGION_QTPOLYGON_H_
00030 #define REGION_QTPOLYGON_H_
00031 
00032 #include <display/region/QtRegion.qo.h>
00033 #include <display/region/Polygon.h>
00034 
00035 namespace casa {
00036     namespace viewer {
00037 
00038         // All regions are specified in "linear coordinates", not "pixel coordinates". This is necessary
00039         // because "linear coordinates" scale with zooming whereas "pixel coordinates" do not. Unfortunately,
00040         // this means that coordinate transformation is required each time the region is drawn.
00041         //
00042         // Key points:
00043         //    <ul>
00044         //        <li> regions are produced by a factory to permit the creation of gui specific regions </li>
00045         //    </ul>
00046         class QtPolygon : public QtRegion, public Polygon {
00047             Q_OBJECT
00048             public:
00049 
00050                 const std::string name( ) const { return QtRegion::name( ); }
00051 
00052                 std::string lineColor( )   const { return QtRegion::lineColor( ); }
00053                 std::string centerColor( ) const { return QtRegion::centerColor( ); }
00054                 int lineWidth( ) const { return QtRegion::lineWidth( ); }
00055                 Region::LineStyle lineStyle( ) const { return QtRegion::lineStyle( ); }
00056 
00057                 std::string textColor( ) const { return QtRegion::textColor( ); }
00058                 std::string textFont( ) const { return QtRegion::textFont( ); }
00059                 int textFontSize( ) const { return QtRegion::textFontSize( ); }
00060                 int textFontStyle( ) const { return QtRegion::textFontStyle( ); }
00061                 std::string textValue( ) const { return QtRegion::textValue( ); }
00062                 Region::TextPosition textPosition( ) const { return QtRegion::textPosition( ); }
00063                 void textPositionDelta( int &x, int &y ) const { QtRegion::textPositionDelta( x, y ); }
00064 
00065                 void getCoordinatesAndUnits( Region::Coord &c, Region::Units &x_units, Region::Units &y_units, std::string &width_height_units ) const
00066                         { Region::getCoordinatesAndUnits( c, x_units, y_units, width_height_units ); }
00067                 void getPositionString( std::string &x, std::string &y, std::string &angle,
00068                                         double &bounding_width, double &bounding_height,
00069                                         Region::Coord coord = Region::DefaultCoord,
00070                                         Region::Units x_units = Region::DefaultUnits,
00071                                         Region::Units y_units = Region::DefaultUnits,
00072                                         const std::string &bounding_units = "rad" ) const
00073                         { Region::getPositionString( x, y, angle, bounding_width, bounding_height, coord, x_units, y_units, bounding_units ); }
00074 
00075                 bool translateX( const std::string &x, const std::string &x_units, const std::string &coordsys )
00076                         { return Region::translateX( x, x_units, coordsys ); }
00077                 bool translateY( const std::string &y, const std::string &y_units, const std::string &coordsys )
00078                         { return Region::translateY( y, y_units, coordsys ); }
00079                 bool resizeX( const std::string &x, const std::string &x_units, const std::string &coordsys )
00080                         { return Region::resizeX( x, x_units, coordsys ); }
00081                 bool resizeY( const std::string &y, const std::string &y_units, const std::string &coordsys )
00082                         { return Region::resizeY( y, y_units, coordsys ); }
00083 
00084                 int numFrames( ) const { return QtRegion::numFrames( ); }
00085                 void zRange( int &min, int &max ) const { QtRegion::zRange(min,max); }
00086                 int zIndex( ) const { return Region::zIndex( ); }
00087 
00088                 // indicates that region movement requires that the statistcs be updated...
00089                 void updateStateInfo( bool region_modified, RegionChanges change ) { QtRegion::updateStateInfo( region_modified, change ); }
00090 
00091                 // indicates that the center info is no longer valid
00092                 void invalidateCenterInfo( ) {QtRegion::invalidateCenterInfo();};
00093 
00094                 void clearStatistics( ) { QtRegion::clearStatistics( ); }
00095 
00096                 QtPolygon( QtRegionSourceKernel *factory, WorldCanvas *wc, double x1, double y1, bool hold_signals=false );
00097                 QtPolygon( QtRegionSourceKernel *factory, WorldCanvas *wc, const std::vector<std::pair<double,double> > &pts, bool hold_signals=false );
00098 
00099                 bool regionVisible( ) const { return Region::regionVisible( ); }
00100                 void linearCenter( double &x, double &y ) const { Polygon::linearCenter( x, y ); }
00101                 void pixelCenter( double &x, double &y ) const { Polygon::pixelCenter( x, y ); }
00102 
00103                 // qt-event -> QtRegion -> QtPolygon -> Region::refresh( )
00104                 void refresh( ) { Polygon::refresh( ); }
00105                 AnnotationBase *annotation( ) const { return Polygon::annotation( ); }
00106                 // called when polygon region is completely specified...
00107                 // used to trigger related region events, e.g. displaying spectra...
00108                 void polygonComplete( );
00109 
00110                 // indicates that the user has selected this rectangle...
00111                 void selectedInCanvas( ) { QtRegion::selectedInCanvas( ); }
00112                 // is this region weakly or temporarily selected?
00113                 bool weaklySelected( ) const { return QtRegion::weaklySelected( ); }
00114                 void weaklySelect( ) { QtRegion::weaklySelect( ); }
00115                 void weaklyUnselect( ) { QtRegion::weaklyUnselect( ); }
00116 
00117                 void setLabel( const std::string &l ) { QtRegion::setLabel(l); }
00118                 void setLabelPosition( TextPosition pos ) { QtRegion::setLabelPosition(pos); }
00119                 void setLabelDelta( const std::vector<int> &delta ) { QtRegion::setLabelDelta(delta); }
00120                 void setFont( const std::string &font="", int font_size=-1, int font_style=0, const std::string &font_color="" )
00121                                 { QtRegion::setFont( font, font_size, font_style, font_color ); }
00122                 void setLine( const std::string &line_color="", Region::LineStyle line_style=SolidLine, unsigned int line_width=1 )
00123                                 { QtRegion::setLine( line_color, line_style, line_width ); }
00124                 void setAnnotation(bool ann) { QtRegion::setAnnotation(ann); }
00125 
00126                 // functions added with the introduction of RegionToolManager and the
00127                 // unified selection and manipulation of the various region types...
00128                 void mark( bool set=true ) { QtRegion::mark( set ); }
00129                 bool marked( ) const { return QtRegion::marked( ); }
00130                 bool mark_toggle( ) { return QtRegion::mark_toggle( ); }
00131 
00132                 void status( const std::string &msg, const std::string &type="info" ) { QtRegion::status(msg,type); }
00133 
00134                 bool markCenter() const { return QtRegion::markCenter( ); }
00135 
00136                 bool skyComponent() const { return QtRegion::skyComponent( ); }
00137 
00138                 void output( ds9writer &out ) const;
00139 
00140                 void emitUpdate( ) { QtRegion::emitUpdate( ); }
00141 
00142             protected:
00143                 std::list<RegionInfo> *generate_dds_statistics( ) { return Polygon::generate_dds_statistics( ); }
00144                 ImageRegion *get_image_region( DisplayData *dd ) const { return Polygon::get_image_region( dd ); }
00145                 const std::list<Region*> &get_selected_regions( ) { return QtRegion::get_selected_regions( ); }
00146                 size_t selected_region_count( ) { return QtRegion::selected_region_count( ); }
00147                 size_t marked_region_count( ) { return QtRegion::marked_region_count( ); }
00148                 virtual Region *fetch_my_region( ) { return (Region*) this; }
00149                 virtual void fetch_region_details( RegionTypes &type, std::vector<std::pair<int,int> > &pixel_pts, 
00150                                                    std::vector<std::pair<double,double> > &world_pts ) const 
00151                                 { return Polygon::fetch_region_details( type, pixel_pts, world_pts ); }
00152                 std::list<RegionInfo> *generate_dds_centers( ) { return Polygon::generate_dds_centers( ); };
00153 
00154         };
00155     }
00156 }
00157 
00158 #endif