QtRegionState.qo.h

Go to the documentation of this file.
00001 //# QtRegionState.h: region properties, populates region dock
00002 //# Copyright (C) 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_QTREGIONSTATE_H_
00030 #define REGION_QTREGIONSTATE_H_
00031 
00032 #include <casa/BasicSL/String.h>
00033 #include <display/region/RegionEnums.h>
00034 #include <display/region/QtRegionState.ui.h>
00035 #include <display/region/QtRegionStats.qo.h>
00036 #include <display/Display/MouseToolState.h>
00037 
00038 namespace casa {
00039 
00040         class HistogramTab;
00041         namespace viewer {
00042 
00043                 class Region;
00044 
00045 
00046                 class QtRegionState : public QFrame, protected Ui::QtRegionState {
00047                         Q_OBJECT
00048                 public:
00049                         // initializing the display depends upon having signals & slots connected
00050                         // which cannot happen until after the ctor of QtRegionState...
00051                         void init( );
00052 
00053 
00054                         QtRegionState( const QString &name,
00055                                        QtMouseToolNames::PointRegionSymbols sym=QtMouseToolNames::SYM_UNKNOWN,
00056                                        Region *region=0, QWidget *parent=0 );
00057                         ~QtRegionState( );
00058 
00059                         bool statisticsIsVisible( ) {
00060                                 return categories->tabText(categories->currentIndex( )) == "stats";
00061                         }
00062 
00063                         Region *region( ) {
00064                                 return region_;
00065                         }
00066                         void setRegion( Region *r );
00067 
00068                         void updateCoord( );
00069                         void updateStatistics(  );
00070                         void updateStatistics( std::list<SHARED_PTR<RegionInfo> > *stats );
00071                         void updateFrameInformation( int count );
00072                         void reloadStatistics( );
00073                         void updateCenters( std::list<SHARED_PTR<RegionInfo> > *centers );
00074                         void setCenterBackground(QString background);
00075                         void clearStatistics( );
00076                         void addHistogram(QWidget* histogram);
00077                         void updateStackOrder( int firstImage );
00078                         int getStackIndex() const;
00079 
00080                         std::string lineColor( ) const;
00081                         std::string centerColor( ) const;
00082                         int lineWidth( ) const {
00083                                 return line_width->value( );
00084                         }
00085                         region::LineStyle lineStyle( ) const;
00086 
00087                         int markerScale( ) const {
00088                                 return marker_scale->value( );
00089                         }
00090                         void setMarkerScale( int v );
00091 
00092                         std::string textColor( ) const;
00093                         std::string textFont( ) const;
00094                         int textFontSize( ) const {
00095                                 return font_size->value( );
00096                         }
00097                         int textFontStyle( ) const;
00098                         std::string textValue( ) const;
00099                         region::TextPosition textPosition( ) const;
00100                         void textPositionDelta( int &x, int &y ) const;
00101 
00102                         void setTextValue( const std::string &l );
00103                         void setTextPosition( region::TextPosition );
00104                         void setTextDelta( const std::vector<int> & );
00105                         void setTextFont( const std::string &f );
00106                         void setTextFontSize( int s );
00107                         void setTextFontStyle( int s );
00108                         void setTextColor( const std::string & );
00109                         void setLineColor( const std::string & );
00110                         void setLineStyle( region::LineStyle );
00111                         void setLineWidth( unsigned int );
00112                         void setAnnotation( bool );
00113                         void disableAnnotation( bool );
00114 
00115                         int zMin( ) const;
00116                         int zMax( ) const;
00117                         int numFrames( ) const;
00118 
00119                         bool isAnnotation( ) const;
00120 
00121                         // reset the widget to its original state...
00122                         void reset( const QString &name, Region *r );
00123 
00124                         /* QString getRegionCategory( ) const { return categories->tabText(categories->currentIndex( )); } */
00125                         /* void justExposed( ); */
00126 
00127                         void getCoordinatesAndUnits( region::Coord &c, region::Units &xu, region::Units &yu, std::string &bounding_units ) const;
00128                         void setCoordinatesAndUnits( region::Coord c, region::Units x_units, region::Units y_units, const std::string &bounding_units );
00129                         void updatePosition( const QString &x, const QString &y, const QString &angle,
00130                                              const QString &bounding_width, const QString &bounding_height );
00131 
00132                         // may be called after "outputRegions" signal to notify the
00133                         // user that no regions were selected for output...
00134                         void noOutputNotify( );
00135 
00136                         // functions added with the introduction of RegionToolManager and the
00137                         // unified selection and manipulation of the various region types...
00138                         /* void mark( bool set=true ) { region_mark->setCheckState( set ? Qt::Checked : Qt::Unchecked ); } */
00139                         /* bool marked( ) const { return region_mark->checkState( ) == Qt::Checked ? true : false; } */
00140                         void mark( bool set=true );
00141                         bool marked( ) const {
00142                                 return region_mark->isChecked( );
00143                         }
00144                         bool markCenter( ) const {
00145                                 return (markcenter_chk->checkState()==Qt::Checked);
00146                         }
00147                         bool skyComponent() const {
00148                                 return (skycomp_chk->checkState()==Qt::Checked);
00149                         };
00150                         bool mark_toggle( );
00151 
00152                         void nowVisible( );
00153                         QPushButton *getFitButton() {
00154                                 return imfit_fit;
00155                         };
00156 
00157                         void emitRefresh( ) {
00158                                 emit refreshCanvas( );
00159                         }
00160 
00161                         // return the current information mode of the region state, e.g. position, statistics, etc.
00162                         std::string mode( ) const;
00163                         const std::string LINE_COLOR_CHANGE;
00164 
00165                         virtual QString HISTOGRAM_MODE( ) const {
00166                                 return "Histogram";
00167                         }
00168                         virtual QString STATISTICS_MODE( ) const {
00169                                 return "Statistics";
00170                         }
00171                         virtual QString FILE_MODE( ) const {
00172                                 return "File";
00173                         }
00174                         virtual QString FIT_MODE( ) const {
00175                                 return "Fit";
00176                         }
00177                         virtual QString PROPERTIES_MODE( ) const {
00178                                 return "Properties";
00179                         }
00180 
00181                 signals:
00182                         void regionChange( viewer::Region *, std::string );
00183                         void refreshCanvas( );
00184                         void statisticsVisible( bool );
00185                         void collectStatistics( );
00186                         void updateHistogram();
00187                         void positionVisible( bool );
00188                         void translateX( const QString &/*x*/, const QString &/*x_units*/, const QString &/*coordsys*/ );
00189                         void translateY( const QString &/*y*/, const QString &/*y_units*/, const QString &/*coordsys*/ );
00190                         void resizeX( const QString &/*x*/, const QString &/*x_units*/, const QString &/*coordsys*/ );
00191                         void resizeY( const QString &/*y*/, const QString &/*y_units*/, const QString &/*coordsys*/ );
00192 
00193                         void zRange( int z_min, int z_max );
00194                         /* void regionCategoryChange( QString ); */
00195                         void outputRegions( const QString &what, const QString &name, const QString &type, const QString &csys );
00196                         void loadRegions( const QString &path, const QString &type );
00197 
00198                 public slots:
00199                         void stackChange(QWidget*);
00200 
00201                 protected slots:
00202                         // updates canvas with any line changes
00203                         void state_change( int );
00204                         void state_change_region_mark( int );
00205                         void color_state_change( int );
00206                         void state_change( bool );
00207                         void state_change( const QString & );
00208                         void states_change( int );
00209                         void states_val_change( int );
00210                         void coordsys_change( const QString &text );
00211                         void translate_x( );
00212                         void translate_y( );
00213                         void resize_x( );
00214                         void resize_y( );
00215                         void category_change( int );
00216                         void filetab_change( int );
00217                         // keeps text color in sync with line color (if they were the same before)
00218                         void line_color_change(const QString & );
00219                         QString default_extension( const QString & );
00220 
00221                         void update_default_file_extension(const QString&);
00222                         void update_save_type(const QString &);
00223                         void save_region(bool);
00224 
00225                         void update_load_type(const QString &);
00226                         void load_regions( bool );
00227 
00228                         void frame_min_change(int);
00229                         void frame_max_change(int);
00230 
00231                         void save_browser(bool);
00232                         void load_browser(bool);
00233 
00234                         void set_point_region_marker( int );
00235 
00236                 protected:
00237                         // keep track of which set of statistics
00238                         // where selected when refreshing all...
00239                         int selected_statistics;
00240                         typedef std::list<QtRegionStats*> freestat_list;
00241                         static freestat_list *freestats;
00242                         static freestat_list *freecenters;
00243                         QString last_line_color;
00244                         Region *region_;
00245 
00246                         std::string bounding_index_to_string( int index ) const;
00247 
00248                         friend class Region;
00249                         void clearRegion( ) {
00250                                 region_ = 0;
00251                         }
00252 
00253                 private:
00254                         void initRegionState( );
00255                         void statisticsUpdate( QtRegionStats *regionStats, SHARED_PTR<casa::viewer::RegionInfo> regionInfo );
00256                         unsigned int setting_combo_box;
00257                         int pre_dd_change_statistics_count;
00258                         HistogramTab* histogramTab;
00259 
00260                 };
00261 
00262                 class QtPVLineState : public QtRegionState {
00263                         Q_OBJECT
00264                 public:
00265                         QtPVLineState( const QString &name,
00266                                        QtMouseToolNames::PointRegionSymbols sym=QtMouseToolNames::SYM_UNKNOWN,
00267                                        Region *region=0, QWidget *parent=0 );
00268                         QString STATISTICS_MODE( ) const {
00269                                 return "pV";
00270                         }
00271 
00272                 };
00273 
00274                 class QtSliceCutState : public QtRegionState {
00275                         Q_OBJECT
00276                 public:
00277                         QtSliceCutState( const QString &name,
00278                                          QtMouseToolNames::PointRegionSymbols sym=QtMouseToolNames::SYM_UNKNOWN,
00279                                          Region *region=0, QWidget *parent=0 );
00280                         QString STATISTICS_MODE( ) const {
00281                                 return "Spatial Profile";
00282                         }
00283 
00284                 };
00285 
00286                 class QtPointState : public QtRegionState {
00287                         Q_OBJECT
00288                 public:
00289                         QtPointState( const QString &name,
00290                                        QtMouseToolNames::PointRegionSymbols sym=QtMouseToolNames::SYM_UNKNOWN,
00291                                        Region *region=0, QWidget *parent=0 );
00292                 };
00293 
00294         }
00295 }
00296 
00297 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1