QtRegionDock.qo.h

Go to the documentation of this file.
00001 //# QtRegionDock.qo.h: dockable Qt implementation of viewer region management
00002 //# Copyright (C) 2011, 2012
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id$
00027 
00028 #ifndef REGION_QTREGIONDOCK_H_
00029 #define REGION_QTREGIONDOCK_H_
00030 #include <map>
00031 #include <list>
00032 #include <iostream>
00033 #include <display/region/QtRegionDock.ui.h>
00034 #include <display/QtViewer/InActiveDock.qo.h>
00035 #include <imageanalysis/Annotations/AnnRegion.h>
00036 #include <imageanalysis/Annotations/RegionTextList.h>
00037 #include <display/region/Region.qo.h>
00038 
00039 namespace casa {
00040 
00041         class QtDisplayData;
00042         class QtDisplayPanelGui;
00043 
00044         namespace viewer {
00045 
00046                 class Region;
00047                 class QtRegionState;
00048                 class ds9writer;
00049                 class Region;
00050 
00051                 class QtRegionDock : public InActiveDock, protected Ui::QtRegionDock {
00052                         Q_OBJECT
00053                 public:
00054 
00055                         QtRegionDock( QtDisplayPanelGui *, QWidget* parent=0 );
00056                         ~QtRegionDock();
00057 
00058                         void addRegion(Region *,QtRegionState*,int index = -1);
00059                         int indexOf(QtRegionState*) const;
00060                         void removeRegion(QtRegionState*);
00061                         void selectRegion(QtRegionState*,bool scroll=true);
00062                         void updateFrameCount( int count );
00063                         void status( const std::string &msg, const std::string &type="info" );
00064 
00065                         QtDisplayPanelGui *panel( ) {
00066                                 return dpg;
00067                         }
00068 
00069                         /* QStackedWidget *regionStack( ) { return regions; } */
00070 
00071                         /* void showStats( const QString &stats ); */
00072 
00073                         std::pair<int,int> &tabState( ) {
00074                                 return current_tab_state;
00075                         }
00076                         std::map<std::string,int> &coordState( ) {
00077                                 return current_coord_state;
00078                         }
00079                         QString &saveDir( ) {
00080                                 return current_save_dir;
00081                         }
00082                         QString &loadDir( ) {
00083                                 return current_load_dir;
00084                         }
00085                         int &colorIndex( ) {
00086                                 return current_color_index;
00087                         }
00088 
00089                         // called to signal that selected region state needs to be updated...
00090                         void selectedCountUpdateNeeded( );
00091                         // retrieve the selected region state...
00092                         size_t selectedRegionCount( ) {
00093                                 return selected_region_set_.size( );
00094                         }
00095                         const region::region_list_type &selectedRegionSet( ) {
00096                                 return selected_region_set_;
00097                         }
00098                         size_t markedRegionCount( ) {
00099                                 return marked_region_set_.size( );
00100                         }
00101                         const region::region_list_type &markedRegionSet( ) {
00102                                 return marked_region_set_;
00103                         }
00104                         const region::region_list_type &weaklySelectedRegionSet( ) {
00105                                 return weakly_selected_region_set_;
00106                         }
00107                         void clearWeaklySelectedRegionSet( );
00108                         bool isWeaklySelectedRegion( const Region * ) const;
00109                         void addWeaklySelectedRegion( Region * );
00110                         void removeWeaklySelectedRegion( Region * );
00111 
00112                         void dismiss( );
00113 
00114                         std::list<Region*> regions( ) const {
00115                                 return region_list;
00116                         }
00117                         // zero length string indicates OK!
00118                         std::string outputRegions( std::list<viewer::QtRegionState*> regions, std::string file,
00119                                                    std::string format, std::string ds9_csys="pixel" );
00120 
00121                         void updateRegionStats( );
00126                         void updateStackOrder( int topIndex );
00127                         void emitCreate( Region * );
00128 
00129                         int numFrames( ) const;
00130                         void deleteRegions( const region::region_list_type & );
00131                         void revokeRegion( Region *r );
00132 
00133                 signals:
00134                         // triggers deletion elsewhere of Region containing this QtRegionState
00135                         // which then causes the removal of this QtRegionState...
00136                         void deleteRegion(QtRegionState*);
00137                         // notice sent after QtRegionState is removed from QStackWidget,
00138                         // *and* after Region has already been deleted...
00139                         // also sent when a region is created (see std::string arg)...
00140                         void regionChange( viewer::Region *, std::string );
00141                         void deleteAllRegions();
00142                         void regionSelected( int id );
00143                         void saveRegions( std::list<QtRegionState*>, RegionTextList & );
00144                         void saveRegions( std::list<QtRegionState*>, ds9writer & );
00145                         void loadRegions( const QString &path, const QString &type );
00146 
00147                         void region_stack_change(QWidget*);
00148                         void showHistogramTool();
00149 
00150                 public slots:
00151                         void updateRegionState(QtDisplayData*);
00152                         void delete_all_regions( bool );
00153                 private slots:
00154                         void stack_changed(int);
00155                         void change_stack(int);
00156                         void delete_current_region(bool);
00157 
00158                         void output_region_event(const QString &what, const QString &where, const QString &type, const QString &csys );
00159                         void handle_visibility(bool);
00160                         void emit_region_stack_change( int );
00161 
00162                 protected:
00163                         void enterEvent( QEvent* );
00164                         void leaveEvent( QEvent* );
00165                         void closeEvent ( QCloseEvent * event );
00166 
00167                 private:
00168                         QtDisplayPanelGui *dpg;
00169                         QtDisplayData *current_dd;
00170                         std::pair<int,int> current_tab_state;
00171                         std::map<std::string,int> current_coord_state;
00172                         int current_color_index;
00173                         QString current_save_dir;
00174                         QString current_load_dir;
00175                         bool dismissed;
00176                         bool mouse_in_dock;
00177 
00178                         typedef std::list<Region*> region_list_t;
00179                         region_list_t region_list;
00180                         typedef std::map<QtRegionState*,Region*> region_map_t;
00181                         region_map_t region_map;
00182 
00183                         // maintain a count of selected regions, information which is used
00184                         // to determine the corner treatment when drawing regions...
00185                         region::region_list_type selected_region_set_;
00186                         region::region_list_type weakly_selected_region_set_;
00187                         region::region_list_type marked_region_set_;
00188                         void update_region_statistics( );
00189 
00190                 };
00191         }
00192 }
00193 
00194 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1