casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Region.qo.h
Go to the documentation of this file.
00001 //# Region.qo.h: base class for statistical regions
00002 //# Copyright (C) 2011
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_REGION_H_
00030 #define REGION_REGION_H_
00031 
00032 #include <set>
00033 #include <map>
00034 #include <list>
00035 #include <string>
00036 #include <images/Images/ImageStatistics.h>
00037 #include <measures/Measures/MDirection.h>
00038 #include <display/region/RegionInfo.h>
00039 #include <display/Utilities/dtor.h>
00040 #include <display/Display/MouseToolState.h>
00041 #include <display/Utilities/VOID.h>
00042 #include <casaqt/QtUtilities/QtId.h>
00043 #include <stdexcept>
00044 #include <QObject>
00045 
00046 #include <display/region/QtRegionState.qo.h>
00047 #include <display/region/RegionEnums.h>
00048 #include <casadbus/types/nullptr.h>
00049 
00050 #include <casa/Arrays/Vector.h>
00051 
00052 extern "C" void casa_viewer_pure_virtual( const char *file, int line, const char *func );
00053 #define DISPLAY_PURE_VIRTUAL(FUNCTION,RESULT) \
00054   { casa_viewer_pure_virtual( __FILE__, __LINE__, #FUNCTION ); return RESULT; }
00055 
00056 namespace casa {
00057 
00058         class WorldCanvas;
00059         class PrincipalAxesDD;
00060         template <class T> class ImageInterface;
00061         class ImageRegion;
00062         class DisplayData;
00063         class HistogramTab;
00064 
00065         class RegionTextList;
00066         class AnnotationBase;
00067 
00068         namespace viewer {
00069 
00070                 class ds9writer;
00071                 class QtRegionDock;
00072 
00073                 // convert linear coordinates to viewer screen coordinates...
00074                 void linear_to_screen( WorldCanvas *wc_, double, double, int &, int & );
00075                 void linear_to_screen( WorldCanvas *wc_, double, double, double, double, int &, int &, int &, int & );
00076                 // convert linear coordinates to casa pixel coordinates...
00077                 void linear_to_pixel( WorldCanvas *wc_, double, double, double &, double & );
00078                 void linear_to_pixel( WorldCanvas *wc_, double, double, double, double, double &, double &, double &, double & );
00079                 // convert viewer screen coordinates to linear coordinates...
00080                 void screen_to_linear( WorldCanvas *wc_, int, int, double &, double & );
00081                 void screen_to_linear( WorldCanvas *wc_, int, int, int, int, double &, double &, double &, double & );
00082                 // convert linear coordinates to world coordinates...
00083                 void linear_to_world( WorldCanvas *wc_, double, double, double &, double & );
00084                 void linear_to_world( WorldCanvas *wc_, double, double, double, double, double &, double &, double &, double & );
00085                 // convert world coordinates to linear coordinates...
00086                 void world_to_linear( WorldCanvas *wc_, double, double, double &, double & );
00087                 void world_to_linear( WorldCanvas *wc_, double, double, double, double, double &, double &, double &, double& );
00088                 // convert casa pixel coordinates to world coordinates...
00089                 void pixel_to_world( WorldCanvas *wc_, double, double, double &, double & );
00090                 void pixel_to_world( WorldCanvas *wc_, double, double, double, double, double &, double &, double &, double & );
00091                 // convert casa pixel coordinates to linear coordinates...
00092                 void pixel_to_linear( WorldCanvas *wc_, double, double, double &, double & );
00093                 void pixel_to_linear( WorldCanvas *wc_, double, double, double, double, double &, double &, double &, double & );
00094 
00095                 // convert linear coordinates to specific coordinate systems...
00096                 void linear_to_j2000( WorldCanvas *wc_, double, double, double &, double & );
00097                 void linear_to_j2000( WorldCanvas *wc_, double, double, double, double, double &, double &, double &, double & );
00098                 void linear_to_b1950( WorldCanvas *wc_, double, double, double &, double & );
00099                 void linear_to_b1950( WorldCanvas *wc_, double, double, double, double, double &, double &, double &, double & );
00100                 void linear_to_galactic( WorldCanvas *wc_, double, double, double &, double & );
00101                 void linear_to_galactic( WorldCanvas *wc_, double, double, double, double, double &, double &, double &, double & );
00102                 void linear_to_ecliptic( WorldCanvas *wc_, double, double, double &, double & );
00103                 void linear_to_ecliptic( WorldCanvas *wc_, double, double, double, double, double &, double &, double &, double & );
00104 
00105                 void to_linear( WorldCanvas *, MDirection::Types in_type, double, double, double &, double & );
00106                 void to_linear( WorldCanvas *, MDirection::Types in_type, double, double, double, double, double &, double &, double &, double & );
00107                 void to_linear_offset( WorldCanvas *, MDirection::Types in_type, double, double, double &, double & );
00108 
00109                 void screen_offset_to_linear_offset( WorldCanvas *wc_, int, int, double &, double & );
00110                 void pixel_offset_to_linear_offset( WorldCanvas *wc_, double, double, double &, double & );
00111                 void linear_offset_to_pixel_offset( WorldCanvas *wc_, double, double, double &, double & );
00112 
00113                 MDirection::Types get_coordinate_type( const CoordinateSystem &wc );
00114 
00115                 class ImageRegion_state {
00116                 public:
00117                         ImageRegion_state( ) : count_(0) { }
00118                         ImageRegion_state( ImageRegion *ir, size_t region_count ) : imageregion(ir), count_(region_count) { }
00119                         ImageRegion_state( const ImageRegion_state &other ) : imageregion(other.imageregion), count_(other.count_) { }
00120                         operator std::tr1::shared_ptr<ImageRegion>( ) {
00121                                 return imageregion;
00122                         }
00123                         size_t regionCount( ) const {
00124                                 return count_;
00125                         }
00126                 private:
00127                         void* operator new (std::size_t) throw (std::logic_error)
00128                         {
00129                                 throw std::logic_error("allocating an object not intended for dynamic allocation");
00130                         }
00131                         std::tr1::shared_ptr<ImageRegion> imageregion;
00132                         size_t count_;
00133                 };
00134 
00135                 // All regions are specified in "linear coordinates", not "pixel coordinates". This is necessary
00136                 // because "linear coordinates" scale with zooming whereas "pixel coordinates" do not. Unfortunately,
00137                 // this means that coordinate transformation is required each time the region is drawn.
00138                 class Region : public QObject, public dtorNotifier {
00139                         Q_OBJECT
00140                 public:
00141 
00142                         // functions to query results from mouse functions...
00143                         static bool refreshNeeded( int v ) {
00144                                 return v & region::MouseRefresh ? true : false;
00145                         }
00146                         static bool regionSelected( int v ) {
00147                                 return v & region::MouseSelected ? true : false;
00148                         }
00149                         static bool handleSelected( int v ) {
00150                                 return v & region::MouseHandle ? true : false;
00151                         }
00152 
00153                         // user specified name
00154                         const std::string name( ) const {
00155                                 return name_;
00156                         }
00157 
00158                         std::string lineColor( ) const {
00159                                 return mystate->lineColor( );
00160                         }
00161                         std::string centerColor( ) const {
00162                                 return mystate->centerColor( );
00163                         }
00164                         int lineWidth( ) const {
00165                                 return mystate->lineWidth( );
00166                         }
00167                         region::LineStyle lineStyle( ) const {
00168                                 return mystate->lineStyle( );
00169                         }
00170 
00171                         std::string textColor( ) const {
00172                                 return mystate->textColor( );
00173                         }
00174                         std::string textFont( ) const {
00175                                 return mystate->textFont( );
00176                         }
00177                         int textFontSize( ) const {
00178                                 return mystate->textFontSize( );
00179                         }
00180                         int textFontStyle( ) const {
00181                                 return mystate->textFontStyle( );
00182                         }
00183                         std::string textValue( ) const {
00184                                 return mystate->textValue( );
00185                         }
00186                         region::TextPosition textPosition( ) const {
00187                                 return mystate->textPosition( );
00188                         }
00189                         void textPositionDelta( int &x, int &y ) const {
00190                                 return mystate->textPositionDelta( x, y );
00191                         }
00192 
00193                         virtual void setLabel( const std::string &l );
00194                         virtual void setLabelPosition( region::TextPosition );
00195                         virtual void setLabelDelta( const std::vector<int> & );
00196                         virtual void setFont( const std::string &font="", int font_size=-1, int font_style=0, const std::string &font_color="" );
00197                         virtual void setLine( const std::string &line_color="", region::LineStyle line_style=region::SolidLine, unsigned int line_width=1 );
00198                         virtual void setAnnotation(bool);
00199 
00200                         void getCoordinatesAndUnits( region::Coord &c, region::Units &x_units, region::Units &y_units,
00201                                                      std::string &width_height_units ) const;
00202                         void getPositionString( std::string &x, std::string &y, std::string &angle,
00203                                                 double &bounding_width, double &bounding_height,
00204                                                 region::Coord coord = region::DefaultCoord,
00205                                                 region::Units x_units = region::DefaultUnits,
00206                                                 region::Units y_units = region::DefaultUnits,
00207                                                 const std::string &bounding_units = "rad" ) const;
00208 
00209                         bool translateX( const std::string &/*x*/, const std::string &/*x_units*/, const std::string &/*coordsys*/ );
00210                         bool translateY( const std::string &/*x*/, const std::string &/*y_units*/, const std::string &/*coordsys*/ );
00211                         bool resizeX( const std::string &/*x*/, const std::string &/*x_units*/, const std::string &/*coordsys*/ );
00212                         bool resizeY( const std::string &/*x*/, const std::string &/*y_units*/, const std::string &/*coordsys*/ );
00213 
00214                         int numFrames( ) const;
00215                         void zRange( int &x, int &y ) const;
00216                         int zIndex( ) const;
00217                         bool regionVisible( ) const {
00218                                 return visible_;
00219                         }
00220 
00221                         bool worldBoundingRectangle( double &, double &, const std::string & ) const;
00222 
00223                         virtual ~Region( );
00224 
00225                         Region( ) : dock_(0), id_(QtId::get_id( )), wc_(0), selected_(false), visible_(true),
00226                                 mouse_in_region(false), z_index_within_range(true) { }
00227                         Region( const std::string &name, WorldCanvas *wc,  QtRegionDock *, bool hold_signals_=false,
00228                                 QtMouseToolNames::PointRegionSymbols sym=QtMouseToolNames::SYM_UNKNOWN );
00229                         Region( const std::string &name, WorldCanvas *wc,  QtRegionDock *,
00230                                 QtRegionState *supplied_state, bool hold_signals_=false );
00231 
00232                         // is this region degenerate?
00233                         virtual bool degenerate( ) const;
00234 
00235                         void setDrawingEnv( );
00236                         void resetDrawingEnv( );
00237                         void setTextEnv( );
00238                         void resetTextEnv( );
00239                         void pushDrawingEnv( region::LineStyle ls, int thickness=-1 );
00240                         void popDrawingEnv( );
00241 
00242                         void setDrawCenter(bool draw_center) {
00243                                 draw_center_=draw_center;
00244                         };
00245                         bool getDrawCenter() {
00246                                 return draw_center_;
00247                         };
00248 
00249                         // duplicate of MultiWCTool::refresh( )
00250                         void refresh( );
00251 
00252                         virtual region::PointInfo checkPoint( double x, double y ) const = 0;
00253 
00254                         // returns OR'ed set of MouseState...
00255                         virtual unsigned int mouseMovement( double /*x*/, double /*y*/, bool /*other_selected*/ )
00256                         DISPLAY_PURE_VIRTUAL(Region::mouseMovement,0);
00257 
00258                         virtual void draw( bool other_selected );
00259 
00260                         // indicates that the center info is no longer valid
00261                         void invalidateCenterInfo( );
00262 
00263                         bool selected( ) const {
00264                                 return selected_;
00265                         }
00266 
00267                         // is this region weakly or temporarily selected?
00268                         virtual bool weaklySelected( ) const;
00269                         virtual void weaklySelect( bool scroll_dock=true );
00270                         // weaklyUnselectLimited( ) plus extra processing...
00271                         virtual void weaklyUnselect( );
00272                         // just unmark this region (called from RegionToolManager); do not
00273                         // do the rest of the reorganization that weaklyUnselect( ) does...
00274                         virtual void weaklyUnselectLimited( );
00275 
00276                         // indicates that the user has selected this rectangle...
00277                         // ...may need to scroll region dock
00278                         virtual void selectedInCanvas( );
00279                         virtual bool clickWithin( double /*x*/, double /*y*/ ) const DISPLAY_PURE_VIRTUAL(Region::clickWithin,false);
00280                         virtual int clickHandle( double /*x*/, double /*y*/ ) const DISPLAY_PURE_VIRTUAL(Region::clickHandle,0);
00281                         // return value indicates if any data was flagged...
00282                         virtual bool doubleClick( double /*x*/, double /*y*/ );
00283                         // for rectangles, resizing can change the handle...
00284                         // for rectangles, moving a handle is resizing...
00285                         virtual int moveHandle( int handle, double /*x*/, double /*y*/ ) DISPLAY_PURE_VIRTUAL(Region::moveHandle,handle);
00286                         virtual void move( double /*dx*/, double /*dy*/ ) DISPLAY_PURE_VIRTUAL(Region::move,);
00287                         virtual void resize( double /*width_delta*/, double /*height_delta*/ ) = 0;
00288                         virtual bool valid_translation( double dx, double dy, double width_delta, double height_delta ) = 0;
00289 
00290                         // functions added with the introduction of RegionToolManager and the
00291                         // unified selection and manipulation of the various region types...
00292                         virtual void mark( bool set=true );
00293                         virtual bool marked( ) const {
00294                                 return mystate->marked( );
00295                         }
00296                         // returns the new state...
00297                         virtual bool mark_toggle( );
00298                         size_t selected_region_count( );
00299                         size_t marked_region_count( );
00300 
00301                         void clearMouseInRegion( ) {
00302                                 mouse_in_region = false;
00303                         }
00304 
00305                         // update status information...
00306                         virtual void status( const std::string &msg, const std::string &type="info" );
00307 
00308                         virtual bool markCenter( ) const { return mystate->markCenter( ); }
00309 
00310                         virtual bool skyComponent( ) const DISPLAY_PURE_VIRTUAL(Region::skyComponent,true);
00311 
00312                         virtual void output( ds9writer &out ) const = 0;
00313 
00314                         // in "linear" coordinates...
00315                         virtual void boundingRectangle (double &/*blc_x*/, double &/*blc_y*/, double &/*trc_x*/, double &/*trc_y*/) const
00316                         DISPLAY_PURE_VIRTUAL(Region::boundingRectangle,);
00317 
00318                         void emitUpdate( );
00319 
00320                         // postpone signal processing (important for signals generated during construction)...
00321                         void holdSignals( ) {
00322                                 hold_signals++;
00323                         }
00324                         virtual void releaseSignals( ) {
00325                                 if ( --hold_signals == 0 ) process_held_signals( );
00326                                 if ( hold_signals < 0 ) hold_signals = 0;
00327                         }
00328 
00329                         virtual std::list<std::tr1::shared_ptr<RegionInfo> > *statistics( ) {
00330                                 return generate_dds_statistics( );
00331                         }
00332 
00333                         // called when creating regions to allow suppression of corner-handle drawing...
00334                         static std::tr1::shared_ptr<viewer::Region> creatingRegion( )
00335                         {
00336                                 return creating_region;
00337                         }
00338                         static void creatingRegionBegin( std::tr1::shared_ptr<viewer::Region> r )
00339                         {
00340                                 creating_region = r;
00341                         }
00342                         static void creatingRegionEnd( )
00343                         {
00344                                 creating_region = memory::nullptr;
00345                         }
00346 
00347                         //Histogram functionality
00348                         int getId() const {
00349                                 return id_;
00350                         }
00351                         ImageRegion *getImageRegion( DisplayData* dd ) const {
00352                                 return get_image_region( dd );
00353                         }
00354 
00355 // --------------------==================== from old QtRegion ====================--------------------
00356 
00357                         // query region type... to avoid dynamic cast ladder...
00358                         virtual region::RegionTypes type( ) const = 0;
00359 
00360                         virtual void pixelCenter( double &/*x*/, double &/*y*/ ) const = 0;
00361                         // DISPLAY_PURE_VIRTUAL(Region::pixelCenter,);
00362 
00363                         // needed for writing out a list of regions (CASA or DS9 format) because the
00364                         // output is based upon QtRegionState pointers (because that is what is available
00365                         // to the QtRegionDock... this should be rectified to use a list of QtRegion
00366                         // pointers for region output...
00367                         QtRegionState *state( ) {
00368                                 return mystate;
00369                         }
00370 
00371                         // how much to scale the symbol used to mark point regions...
00372                         // assumed to go from 0 to 9...
00373                         int markerScale( ) const {
00374                                 return mystate->markerScale( );
00375                         }
00376                         void setMarkerScale( int v ) {
00377                                 mystate->setMarkerScale(v);
00378                         }
00379 
00380                         // indicates that region movement requires the update of state information...
00381                         void updateStateInfo( bool region_modified, region::RegionChanges );
00382                         void refresh_state_gui( );
00383                         // blank out the statistics for this region
00384                         void clearStatistics( );
00385                         void statisticsUpdateNeeded( ) {
00386                                 statistics_update_needed = true;
00387                         }
00388 
00389                         // used to synchronize the default color for all of the RegionDock's RegionState objects...
00390                         int &colorIndex( );
00391                         // used to synchronize all of the RegionDock's RegionState tab configuration...
00392                         std::pair<int,int> &tabState( );
00393                         // used to synchronize all of the RegionDock's RegionState coordinate configuration...
00394                         std::map<std::string,int> &coordState( );
00395 
00396                         // forward state update information to the dock wherere a count of selected regions, information
00397                         // is maintained. This is used to determine the corner treatment when drawing regions...
00398                         void selectedCountUpdateNeeded( );
00399 
00400                         // used to synchronize all region directories per QtDisplayPanelGUI...
00401                         QString getSaveDir( );
00402                         void putSaveDir( QString );
00403                         QString getLoadDir( );
00404                         void putLoadDir( QString );
00405 
00406                         virtual bool setMarker( QtMouseToolNames::PointRegionSymbols )
00407                         {
00408                                 return false;
00409                         }
00410 
00411                         virtual AnnotationBase *annotation( ) const DISPLAY_PURE_VIRTUAL(Region::annotation,0);
00412 
00413                         static Quantum< ::casa::Vector<double> > convert_angle( double x, const std::string &xunits, double y, const std::string &yunits,
00414                                 MDirection::Types original_coordsys, MDirection::Types new_coordsys, const std::string &new_units="rad" );
00415 
00416                 signals:
00417                         void selectionChanged(viewer::Region*,bool);
00418 
00419                         void regionCreated( int, const QString &shape, const QString &name, const QList<double> &world_x,
00420                                             const QList<double> &world_y, const QList<int> &pixel_x, const QList<int> &pixel_y,
00421                                             const QString &linecolor, const QString &text, const QString &font, int fontsize, int fontstyle );
00422                         void regionUpdate( int, viewer::region::RegionChanges, const QList<double> &world_x, const QList<double> &world_y,
00423                                            const QList<int> &pixel_x, const QList<int> &pixel_y );
00424                         void regionChange( viewer::Region *, std::string );
00425 
00426                         // generated by emitUpdate( )...
00427                         void regionUpdateResponse( int, const QString &shape, const QString &name,
00428                                                    const QList<double> &world_x, const QList<double> &world_y,
00429                                                    const QList<int> &pixel_x, const QList<int> &pixel_y,
00430                                                    const QString &linecolor, const QString &text, const QString &font, int fontsize, int fontstyle );
00431 
00432                 protected slots:
00433                         void refresh_canvas_event( );
00434                         void refresh_statistics_event( bool );
00435                         void refresh_position_event( bool );
00436 
00437                         void translate_x( const QString &/*x*/, const QString &/*x_units*/, const QString &/*coordsys*/ );
00438                         void translate_y( const QString &/*y*/, const QString &/*y_units*/, const QString &/*coordsys*/ );
00439                         void resize_x( const QString &/*x*/, const QString &/*x_units*/, const QString &/*coordsys*/ );
00440                         void resize_y( const QString &/*y*/, const QString &/*y_units*/, const QString &/*coordsys*/ );
00441                         void updateCenterInfo( );
00442                         void adjustCorners( double, double, double, double);
00443                         void refresh_zrange_event(int,int);
00444 
00445                         // revoke...
00446                         void revoke_region( );
00447                         // revoke if our state matches parameter...
00448                         void revoke_region(QtRegionState*);
00449 
00450                         void reload_statistics_event( );
00451 
00452                         void output(std::list<QtRegionState*>,RegionTextList&);
00453                         void output(std::list<QtRegionState*>,ds9writer&);
00454 
00455                 protected:
00456 
00457                         static const int SEXAGPREC;
00458 
00459                         QtRegionDock *dock_;
00460                         QtRegionState *mystate;
00461                         HistogramTab* histogram;
00462 
00463                         bool statistics_update_needed;
00464                         bool position_visible;
00465                         bool position_update_needed;
00466 
00467                         int id_;
00468                         bool statistics_visible;
00469 
00470                         int hold_signals;
00471                         std::map<region::RegionChanges,bool> held_signals;
00472 
00473                         void fetch_details( region::RegionTypes &type, QList<int> &pixelx,
00474                                             QList<int> &pixely, QList<double> &worldx, QList<double> &worldy );
00475                         virtual void fetch_region_details( region::RegionTypes &type,
00476                                                            std::vector<std::pair<int,int> > &pixel_pts,
00477                                                            std::vector<std::pair<double,double> > &world_pts ) const {
00478                                 type = region::NonRegion;
00479                                 pixel_pts.clear( );
00480                                 world_pts.clear( );
00481                                 DISPLAY_PURE_VIRTUAL(Region::fetch_region_details,);
00482                         }
00483 
00484                         void signal_region_change( region::RegionChanges );
00485 
00486                         // --------------------==================== from old QtRegion ====================--------------------
00487 
00488                 protected:
00489                         void initHistogram();
00490                         virtual std::list<std::tr1::shared_ptr<RegionInfo> > *generate_dds_statistics( );
00491 
00492                         // hook to allow generate_dds_statistics( ) to generate statistics
00493                         // for rectangular measurement set regions...
00494                         virtual void generate_nonimage_statistics( DisplayData*, std::list<std::tr1::shared_ptr<RegionInfo> > * ) { }
00495                         // newInfoObject(...) is currently only used for PVLine regions, but it should be used for
00496                         // other regions to allow for specialized creation of the region info objects for display
00497                         // in "statistics"...
00498                         virtual RegionInfo *newInfoObject( ImageInterface<Float> *, PrincipalAxesDD * ) { return 0; }
00499 
00500                         virtual ImageRegion *get_image_region( DisplayData* ) const
00501                         DISPLAY_PURE_VIRTUAL(Region::get_image_region,0);
00502 
00503                         virtual const std::set<Region*> &get_selected_regions( );
00504                         virtual ImageRegion_state get_image_selected_region( DisplayData* );
00505 
00506                         virtual std::list<std::tr1::shared_ptr<RegionInfo> > *generate_dds_centers( ) = 0;
00507 
00508                         static Int getAxisIndex( ImageInterface<Float> *image, std::string axtype );
00509 
00510                         inline double linear_average( double a, double b ) const {
00511                                 return (a + b) / 2.0;
00512                         }
00513                         RegionInfo::center_t *getLayerCenter( PrincipalAxesDD *padd, ImageInterface<Float> *image, ImageRegion& imgReg);
00514                         RegionInfo::stats_t  *getLayerStats( PrincipalAxesDD *padd, ImageInterface<Float> *image, ImageRegion& imgReg );
00515 
00516                         region::Units current_xunits( ) const;
00517                         region::Units current_yunits( ) const;
00518                         region::Coord current_region_coordsys( ) const;
00519                         MDirection::Types current_casa_coordsys( ) const;
00520 
00521                         virtual void drawRegion( bool /*selected*/ ) = 0; //DISPLAY_PURE_VIRTUAL(Region::drawRegion,);
00522                         virtual void drawText( );
00523 
00524                         virtual void setCenter(double &, double &, double &, double &) DISPLAY_PURE_VIRTUAL(Region::setCenter,);
00525 
00526                         virtual void drawCenter(double &x, double &y );
00527                         virtual void drawCenter(double &x, double &y, double &deltx, double &delty);
00528 
00529 
00530                         virtual bool within_drawing_area( );
00531 
00532                         region::LineStyle current_ls;
00533                         typedef std::pair<region::LineStyle,int> ls_ele;
00534                         std::list<ls_ele> ls_stack;
00535                         WorldCanvas *wc_;
00536 
00537                         int last_z_index;
00538                         bool selected_;
00539 
00540                         bool visible_;
00541 
00542                         // Should this region be considered complete?
00543                         // Set to true by derived classes...
00544                         bool complete;
00545 
00546                         // Derived classes set this to true and clear it when the mouse
00547                         // enters and exits this regions bounding box...
00548                         bool mouse_in_region;
00549 
00550                         // Holds a pointer to the region currently being created...
00551                         static std::tr1::shared_ptr<Region> creating_region;
00552 
00553                 private slots:
00554                                                 //Called when the histogram stack needs to be changed due
00555                                                 //to the add/removal of an image.
00556                                                 void update_histogram_event();
00557 
00558                 private:
00559                         // common state-setup for constructors...
00560                         void init( );
00561 
00562                         void updateHistogramRegion();
00563                         void clearHistograms();
00564                         void process_held_signals( );
00565                         void clear_signal_cache( );
00566                         bool z_index_within_range;
00567                         void set_line_style(const ls_ele&);
00568                         bool draw_center_;
00569                         std::string name_;
00570                 };
00571 
00572                 // used to pass point specific marker information (marker type and scaling)
00573                 // to generic region creation routines RegionTool::create(...)
00574                 class PointMarkerState : public VOID {
00575                 public:
00576                         PointMarkerState( QtMouseToolNames::PointRegionSymbols t, int s ) : VOID("viewer.PointMarkerState"), type_(t), scale_(s) { }
00577                         QtMouseToolNames::PointRegionSymbols type( ) const {
00578                                 return type_;
00579                         }
00580                         int scale( ) const {
00581                                 return scale_;
00582                         }
00583                 private:
00584                         QtMouseToolNames::PointRegionSymbols type_;
00585                         int scale_;
00586                 };
00587         }
00588 }
00589 
00590 #endif