casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
QtRectangle.qo.h
Go to the documentation of this file.
00001 //# QtRectangle.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_QTRECTANGLE_H_
00030 #define REGION_QTRECTANGLE_H_
00031 
00032 #include <display/region/QtRegion.qo.h>
00033 #include <display/region/Rectangle.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 QtRectangle : public QtRegion, public Rectangle {
00047             Q_OBJECT
00048             public:
00049                 ~QtRectangle( );
00050 
00051                 const std::string name( ) const { return QtRegion::name( ); }
00052 
00053                 std::string lineColor( ) const   { return QtRegion::lineColor( ); }
00054                 std::string centerColor( ) const { return QtRegion::centerColor( ); }
00055                 int lineWidth( ) const { return QtRegion::lineWidth( ); }
00056                 Region::LineStyle lineStyle( ) const { return QtRegion::lineStyle( ); }
00057 
00058 
00059                 std::string textColor( ) const { return QtRegion::textColor( ); }
00060                 std::string textFont( ) const { return QtRegion::textFont( ); }
00061                 int textFontSize( ) const { return QtRegion::textFontSize( ); }
00062                 int textFontStyle( ) const { return QtRegion::textFontStyle( ); }
00063                 std::string textValue( ) const { return QtRegion::textValue( ); }
00064                 Region::TextPosition textPosition( ) const { return QtRegion::textPosition( ); }
00065                 void textPositionDelta( int &x, int &y ) const { QtRegion::textPositionDelta( x, y ); }
00066 
00067                 void getCoordinatesAndUnits( Region::Coord &c, Region::Units &x_units, Region::Units &y_units, std::string &width_height_units ) const
00068                         { Region::getCoordinatesAndUnits( c, x_units, y_units, width_height_units ); }
00069                 void getPositionString( std::string &x, std::string &y, std::string &angle,
00070                                         double &bounding_width, double &bounding_height,
00071                                         Region::Coord coord = Region::DefaultCoord,
00072                                         Region::Units x_units = Region::DefaultUnits,
00073                                         Region::Units y_units = Region::DefaultUnits,
00074                                         const std::string &bounding_units = "rad" ) const
00075                         { Region::getPositionString( x, y, angle, bounding_width, bounding_height, coord, x_units, y_units, bounding_units ); }
00076 
00077                 bool translateX( const std::string &x, const std::string &x_units, const std::string &coordsys )
00078                         { return Region::translateX( x, x_units, coordsys ); }
00079                 bool translateY( const std::string &y, const std::string &y_units, const std::string &coordsys )
00080                         { return Region::translateY( y, y_units, coordsys ); }
00081                 bool resizeX( const std::string &x, const std::string &x_units, const std::string &coordsys )
00082                         { return Region::resizeX( x, x_units, coordsys ); }
00083                 bool resizeY( const std::string &y, const std::string &y_units, const std::string &coordsys )
00084                         { return Region::resizeY( y, y_units, coordsys ); }
00085 
00086                 int numFrames( ) const { return QtRegion::numFrames( ); }
00087                 void zRange( int &min, int &max ) const { QtRegion::zRange(min,max); }
00088                 int zIndex( ) const { return Region::zIndex( ); }
00089 
00090                 bool regionVisible( ) const { return Region::regionVisible( ); }
00091                 void linearCenter( double &x, double &y ) const { Rectangle::linearCenter( x, y ); }
00092                 void pixelCenter( double &x, double &y ) const { Rectangle::pixelCenter( x, y ); }
00093 
00094                 QtRectangle( QtRegionSourceKernel *factory, WorldCanvas *wc, double blc_x, double blc_y, double trc_x, double trc_y, bool hold_signals=false );
00095 
00096                 // qt-event -> QtRegion -> QtRectangle -> Region::refresh( )
00097                 void refresh( ) { Rectangle::refresh( ); }
00098                 AnnotationBase *annotation( ) const { return Rectangle::annotation( ); }
00099 
00100                 // indicates that the user has selected this rectangle...
00101                 void selectedInCanvas( ) { QtRegion::selectedInCanvas( ); }
00102                 // is this region weakly or temporarily selected?
00103                 bool weaklySelected( ) const { return QtRegion::weaklySelected( ); }
00104                 void weaklySelect( ) { QtRegion::weaklySelect( ); }
00105                 void weaklyUnselect( ) { QtRegion::weaklyUnselect( ); }
00106 
00107                 // indicates that region movement requires that the statistcs be updated...
00108                 void updateStateInfo( bool region_modified, Region::RegionChanges change ) { QtRegion::updateStateInfo( region_modified, change ); }
00109 
00110                 // indicates that the center info is no longer valid
00111                 void invalidateCenterInfo( ) {QtRegion::invalidateCenterInfo();};
00112 
00113                 void clearStatistics( ) { QtRegion::clearStatistics( ); }
00114 
00115                 void setLabel( const std::string &l ) { QtRegion::setLabel(l); }
00116                 void setLabelPosition( TextPosition pos ) { QtRegion::setLabelPosition(pos); }
00117                 void setLabelDelta( const std::vector<int> &delta ) { QtRegion::setLabelDelta(delta); }
00118                 void setFont( const std::string &font="", int font_size=-1, int font_style=0, const std::string &font_color="" )
00119                                 { QtRegion::setFont( font, font_size, font_style, font_color ); }
00120                 void setLine( const std::string &line_color="", Region::LineStyle line_style=SolidLine, unsigned int line_width=1 )
00121                                 { QtRegion::setLine( line_color, line_style, line_width ); }
00122                 void setAnnotation(bool ann) { QtRegion::setAnnotation(ann); }
00123 
00124                 // functions added with the introduction of RegionToolManager and the
00125                 // unified selection and manipulation of the various region types...
00126                 void mark( bool set=true ) { QtRegion::mark( set ); }
00127                 bool marked( ) const { return QtRegion::marked( ); }
00128                 bool mark_toggle( ) { return QtRegion::mark_toggle( ); }
00129 
00130                 void status( const std::string &msg, const std::string &type="info" ) { QtRegion::status(msg,type); }
00131 
00132                 bool markCenter() const { return QtRegion::markCenter( ); }
00133 
00134                 bool skyComponent() const { return QtRegion::skyComponent( ); }
00135 
00136                 void output( ds9writer &out ) const;
00137 
00138                 void emitUpdate( ) { QtRegion::emitUpdate( ); }
00139 
00140                 public slots:
00141                         void adjustCorners( double, double, double, double );
00142 
00143             protected:
00144                 std::list<RegionInfo> *generate_dds_statistics( ) { return Rectangle::generate_dds_statistics( ); }
00145                 ImageRegion *get_image_region( DisplayData *dd ) const { return Rectangle::get_image_region( dd ); }
00146                 const std::list<Region*> &get_selected_regions( ) { return QtRegion::get_selected_regions( ); }
00147                 size_t selected_region_count( ) { return QtRegion::selected_region_count( ); }
00148                 size_t marked_region_count( ) { return QtRegion::marked_region_count( ); }
00149                 virtual Region *fetch_my_region( ) { return (Region*) this; }
00150                 virtual void fetch_region_details( RegionTypes &type, std::vector<std::pair<int,int> > &pixel_pts, 
00151                                                    std::vector<std::pair<double,double> > &world_pts ) const 
00152                                 { return Rectangle::fetch_region_details( type, pixel_pts, world_pts ); }
00153                 std::list<RegionInfo> *generate_dds_centers( ) { return Rectangle::generate_dds_centers( ); };
00154 
00155         };
00156     }
00157 }
00158 
00159 #endif