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

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1