casa
$Rev:20696$
|
00001 //# QtRegionManager.qo.h: Qt implementation of viewer region manager window. 00002 //# (This is the gui part only; it connects to region functions within 00003 //# QtDisplayPanel). 00004 //# Copyright (C) 2005 00005 //# Associated Universities, Inc. Washington DC, USA. 00006 //# 00007 //# This library is free software; you can redistribute it and/or modify it 00008 //# under the terms of the GNU Library General Public License as published by 00009 //# the Free Software Foundation; either version 2 of the License, or (at your 00010 //# option) any later version. 00011 //# 00012 //# This library is distributed in the hope that it will be useful, but WITHOUT 00013 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00015 //# License for more details. 00016 //# 00017 //# You should have received a copy of the GNU Library General Public License 00018 //# along with this library; if not, write to the Free Software Foundation, 00019 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00020 //# 00021 //# Correspondence concerning AIPS++ should be addressed as follows: 00022 //# Internet email: aips2-request@nrao.edu. 00023 //# Postal address: AIPS++ Project Office 00024 //# National Radio Astronomy Observatory 00025 //# 520 Edgemont Road 00026 //# Charlottesville, VA 22903-2475 USA 00027 //# 00028 //# $Id$ 00029 00030 #ifndef QTREGIONMANAGER_H 00031 #define QTREGIONMANAGER_H 00032 00033 #include <casa/aips.h> 00034 #include <casa/Containers/List.h> 00035 #include <display/QtViewer/QtDisplayPanel.qo.h> 00036 #include <display/DisplayDatas/DisplayData.h> 00037 00038 #include <graphics/X11/X_enter.h> 00039 #include <QtCore> 00040 #include <QtGui> 00041 #include <QHash> 00042 //#dk Be careful to put *.ui.h within X_enter/exit bracket too, 00043 //# because they'll have Qt includes. 00044 //# E.g. <QApplication> needs the X11 definition of 'Display' 00045 #include <display/QtViewer/QtRegionMgr.ui.h> 00046 #include <graphics/X11/X_exit.h> 00047 00048 00049 namespace casa { //# NAMESPACE CASA - BEGIN 00050 00051 class QtViewer; 00052 class ImageRegion; 00053 class Record; 00054 class RSComposite; 00055 class WCUnion; 00056 template <class T> class PtrBlock; 00057 00058 00059 class QtRegionManager : public QWidget, protected Ui::QtRegionMgr { 00060 00061 Q_OBJECT 00062 00063 00064 public: 00065 00066 QtRegionManager(QtDisplayPanel* qdp, QWidget* parent=0); 00067 00068 ~QtRegionManager() { } 00069 00070 public slots: 00071 void changeAxis(String, String, String); 00072 void activate(Record); 00073 00074 protected slots: 00075 //draw region on viewer 00076 void drawRegion(Record mousereg, WorldCanvasHolder *wch); 00077 // React to new region creation in display panel. 00078 void newRegion_(String imgFilename); 00079 00080 // Load region from current displayed image 00081 void loadRegionFromImage(); 00082 // Load region from ds9 or aipsbox or rgn file 00083 void loadRegionFromFile(); 00084 00085 //save region into image 00086 void saveRegionInImage(); 00087 // react to SaveRgnn, save region to file 00088 void saveRegionInFile(); 00089 //remove region from image 00090 void removeRegion(); 00091 00092 void toggleImageRegion(); 00093 void zPlaneChanged(); 00094 void currentRegionChanged(const QString &); 00095 void showHelp(); 00096 void showHelpActive(); 00097 00098 //convert region to shape 00099 RSComposite *regionToShape( 00100 QtDisplayData* qdd, const ImageRegion* wcreg); 00101 00102 // Cleanup on destruction 00103 void cleanup(); 00104 00105 void deleteActiveBox(); 00106 void insertActiveBox(); 00107 00108 // set up plane only or extending by channel and pol 00109 void singlePlane(); 00110 void extendChan(); 00111 void extendPol(); 00112 00113 void resetRegionExtension(); 00114 00115 void loadRegionsImageFromFile(); 00116 DisplayData* getImageData(QString); 00117 DisplayData* getBoundingBoxData(QString); 00118 00119 //delete region from image 00120 void deleteRegion(); 00121 //show/hide region 00122 void showHideRegion(); 00123 00124 void flashActive(); 00125 void exportRegions(); 00126 00127 public: 00128 bool planeAllowed(int, String&, String&); 00129 00130 protected: 00131 void addRegionsToShape(RSComposite*& theShapes, 00132 const WCRegion*& wcreg); 00133 WCUnion* unfoldCompositeRegionToSimpleUnion(const WCRegion*& wcreg); 00134 void displaySelectedRegion(); 00135 void showRegion(const String& regName); 00136 00137 bool deleteBox(QString&, int); 00138 bool insertBox(QString&); 00139 void rotateBox(int); 00140 00141 void addRegionToMenu(const QString&, const QString&); 00142 00143 QtDisplayPanel* qdp_; 00144 QWidget* parent_; 00145 00146 private: 00147 PtrBlock<const ImageRegion * > unionRegions_p; 00148 List<RegionShape*> regShapes_p; 00149 void unfoldIntoSimpleRegionPtrs(PtrBlock<const WCRegion*>& outRegPtrs, const WCRegion*& wcreg); 00150 QHash<QString, DisplayData*> regData; 00151 QHash<QString, bool> regState; 00152 QMenu *showHideMenu; 00153 QMenu *deleteMenu; 00154 00155 QString activeGroup; 00156 int activeBox; 00157 RegionShape* activeShape; 00158 QTimer* timer; 00159 bool flash; 00160 00161 int cb; 00162 00163 signals: 00164 void extendRegion(String, String); 00165 00166 }; 00167 00168 00169 } //# NAMESPACE CASA - END 00170 00171 #endif