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