casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
QtPoint.qo.h
Go to the documentation of this file.
00001 //# QtPoint.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_QTPOINT_H_
00030 #define REGION_QTPOINT_H_
00031 
00032 #include <display/Display/MouseToolState.h>
00033 #include <display/region/QtRegion.qo.h>
00034 #include <display/region/Point.h>
00035 
00036 namespace casa {
00037     namespace viewer {
00038 
00039         // All regions are specified in "linear coordinates", not "pixel coordinates". This is necessary
00040         // because "linear coordinates" scale with zooming whereas "pixel coordinates" do not. Unfortunately,
00041         // this means that coordinate transformation is required each time the region is drawn.
00042         //
00043         // Key points:
00044         //    <ul>
00045         //        <li> regions are produced by a factory to permit the creation of gui specific regions </li>
00046         //    </ul>
00047         class QtPoint : public QtRegion, public Point {
00048             Q_OBJECT
00049             public:
00050                 ~QtPoint( );
00051 
00052                 const std::string name( ) const { return QtRegion::name( ); }
00053                 QtMouseToolNames::PointRegionSymbols marker( ) const { return Point::marker_; }
00054                 bool setMarker( QtMouseToolNames::PointRegionSymbols sym ) { return Point::setMarker(sym); }
00055 
00056                 std::string lineColor( )   const { return QtRegion::lineColor( ); }
00057                 std::string centerColor( ) const { return QtRegion::centerColor( ); }
00058                 int lineWidth( ) const { return QtRegion::lineWidth( ); }
00059                 Region::LineStyle lineStyle( ) const { return QtRegion::lineStyle( ); }
00060 
00061                 std::string textColor( ) const { return QtRegion::textColor( ); }
00062                 std::string textFont( ) const { return QtRegion::textFont( ); }
00063                 int textFontSize( ) const { return QtRegion::textFontSize( ); }
00064                 int textFontStyle( ) const { return QtRegion::textFontStyle( ); }
00065                 std::string textValue( ) const { return QtRegion::textValue( ); }
00066                 Region::TextPosition textPosition( ) const { return QtRegion::textPosition( ); }
00067                 void textPositionDelta( int &x, int &y ) const { QtRegion::textPositionDelta( x, y ); }
00068 
00069                 void getCoordinatesAndUnits( Region::Coord &c, Region::Units &x_units, Region::Units &y_units, std::string &width_height_units ) const
00070                         { Region::getCoordinatesAndUnits( c, x_units, y_units, width_height_units ); }
00071                 void getPositionString( std::string &x, std::string &y, std::string &angle,
00072                                         double &bounding_width, double &bounding_height,
00073                                         Region::Coord coord = Region::DefaultCoord,
00074                                         Region::Units x_units = Region::DefaultUnits,
00075                                         Region::Units y_units = Region::DefaultUnits,
00076                                         const std::string &bounding_units = "rad" ) const
00077                         { Region::getPositionString( x, y, angle, bounding_width, bounding_height, coord, x_units, y_units, bounding_units ); }
00078 
00079                 bool translateX( const std::string &x, const std::string &x_units, const std::string &coordsys )
00080                         { return Region::translateX( x, x_units, coordsys ); }
00081                 bool translateY( const std::string &y, const std::string &y_units, const std::string &coordsys )
00082                         { return Region::translateY( y, y_units, coordsys ); }
00083                 bool resizeX( const std::string &x, const std::string &x_units, const std::string &coordsys )
00084                         { return Region::resizeX( x, x_units, coordsys ); }
00085                 bool resizeY( const std::string &y, const std::string &y_units, const std::string &coordsys )
00086                         { return Region::resizeY( y, y_units, coordsys ); }
00087 
00088                 int numFrames( ) const { return QtRegion::numFrames( ); }
00089                 void zRange( int &min, int &max ) const { QtRegion::zRange(min,max); }
00090                 int zIndex( ) const { return Region::zIndex( ); }
00091 
00092                 bool regionVisible( ) const { return Region::regionVisible( ); }
00093                 void linearCenter( double &x, double &y ) const { Point::linearCenter( x, y ); }
00094                 void pixelCenter( double &x, double &y ) const { Point::pixelCenter( x, y ); }
00095 
00096                 QtPoint( QtRegionSourceKernel *factory, WorldCanvas *wc, double x, double y, QtMouseToolNames::PointRegionSymbols sym, bool hold_signals=false );
00097 
00098                 // qt-event -> QtRegion -> QtPoint -> Region::refresh( )
00099                 void refresh( ) { Point::refresh( ); }
00100                 AnnotationBase *annotation( ) const { return Point::annotation( ); }
00101 
00102                 // indicates that the user has selected this point...
00103                 void selectedInCanvas( ) { QtRegion::selectedInCanvas( ); }
00104                 // is this region weakly or temporarily selected?
00105                 bool weaklySelected( ) const { return QtRegion::weaklySelected( ); }
00106                 void weaklySelect( ) { QtRegion::weaklySelect( ); }
00107                 void weaklyUnselect( ) { QtRegion::weaklyUnselect( ); }
00108 
00109                 // indicates that region movement requires that the statistcs be updated...
00110                 void updateStateInfo( bool region_modified, Region::RegionChanges change ) { QtRegion::updateStateInfo( region_modified, change ); }
00111 
00112                 // indicates that the center info is no longer valid
00113                 void invalidateCenterInfo( ) {QtRegion::invalidateCenterInfo();};
00114 
00115                 void clearStatistics( ) { QtRegion::clearStatistics( ); }
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=Region::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                 int markerScale( ) const { return QtRegion::markerScale( ); }
00133 
00134                 void status( const std::string &msg, const std::string &type="info" ) { QtRegion::status(msg,type); }
00135 
00136                 bool markCenter() const { return QtRegion::markCenter( ); }
00137 
00138                 bool skyComponent() const { return QtRegion::skyComponent( ); }
00139 
00140                 void output( ds9writer &out ) const;
00141 
00142                 void emitUpdate( ) { QtRegion::emitUpdate( ); }
00143 
00144 
00145             public slots:
00146                     void adjustCorners( double, double, double, double );
00147 
00148             protected:
00149                 std::list<RegionInfo> *generate_dds_statistics( ) { return Point::generate_dds_statistics( ); }
00150                 ImageRegion *get_image_region( DisplayData *dd ) const { return Point::get_image_region( dd ); }
00151                 const std::list<Region*> &get_selected_regions( ) { return QtRegion::get_selected_regions( ); }
00152                 size_t selected_region_count( ) { return QtRegion::selected_region_count( ); }
00153                 size_t marked_region_count( ) { return QtRegion::marked_region_count( ); }
00154                 virtual Region *fetch_my_region( ) { return (Region*) this; }
00155 
00156                 virtual void fetch_region_details( Region::RegionTypes &type, std::vector<std::pair<int,int> > &pixel_pts, 
00157                                                    std::vector<std::pair<double,double> > &world_pts ) const 
00158                                 { return Point::fetch_region_details( type, pixel_pts, world_pts ); }
00159                 std::list<RegionInfo> *generate_dds_centers(bool skycomp) { return Point::generate_dds_centers(skycomp); };
00160 
00161 
00162         };
00163     }
00164 }
00165 
00166 #endif