casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MakeRegion.qo.h
Go to the documentation of this file.
00001 //# MakeRegion.qo.h: Qt implementation of viewer region maker 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 MAKEREGION_H
00031 #define MAKEREGION_H
00032 
00033 #include <casa/aips.h>
00034 #include <casa/Containers/Record.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 <QList>
00042 #include <QPushButton>
00043 #include <QComboBox>
00044 #include <graphics/X11/X_exit.h>
00045  
00046 namespace casa { 
00047 
00048 class RSComposite;
00049 class WCUnion;
00050 
00051 class MakeRegion : public QWidget {
00052 
00053   Q_OBJECT
00054 
00055  public:
00056   
00057   MakeRegion(QtDisplayPanel* qdp);
00058   ~MakeRegion() {}
00059   
00060  public slots:
00061 
00062   //handle double click that announces a box is ready
00063   void drawRegion(Record mousereg, WorldCanvasHolder *wch);
00064 
00065   //React to new region creation in display panel.
00066   void newRegion_(String imgFilename);
00067 
00068   //handle switch display axis
00069   void changeAxis(String, String, String, int);
00070 
00071   //handle single click to select a box
00072   void activate(Record);
00073 
00074   //this is not used, it emits for any wc change, too often
00075   void wcChanged(const String,
00076                  const Vector<Double>, const Vector<Double>);
00077 
00078   virtual void closeEvent(QCloseEvent* event);
00079 
00080  signals:
00081   void hideRegionInImage();
00082 
00083  protected slots:
00084 
00085   //load masks from the image
00086   void loadRegionFromImage();
00087 
00088   //save masks to the image
00089   void saveRegionToImage();
00090 
00091   //delete region from the image
00092   void deleteRegionFromImage();
00093 
00094   //delete all masks
00095   void deleteAll();
00096 
00097   //toggle show or hide, but does not delete any
00098   void showHideAll();
00099 
00100   //toggle show or hide, but does not delete any
00101   void showHideGroup();
00102 
00103   //use a different color
00104   void colorAll(const QString&);
00105 
00106   //the work horse for all the edit commands
00107   void doIt();
00108 
00109   //show help text
00110   void showHelp();
00111 
00112   //create new box of this shape
00113   void reShape(const QString&);
00114  
00115   void zPlaneChanged();
00116   void pPlaneChanged();
00117  protected:
00118 
00119   void rotateBox(int cb);
00120   void addBox(RegionShape*);
00121   void deleteBox(RegionShape*);
00122   void reDraw();
00123 
00124   void addRegionsToShape(RSComposite*& theShapes,
00125                          const WCRegion*& wcreg);
00126 
00127   WCUnion* unfoldCompositeRegionToSimpleUnion(const WCRegion*& wcreg);
00128   void unfoldIntoSimpleRegionPtrs(PtrBlock<const WCRegion*>& outRegPtrs, 
00129                                   const WCRegion*& wcreg);
00130 
00131   //convert region to shape
00132   RSComposite *regionToShape(
00133         QtDisplayData* qdd, const ImageRegion* wcreg);
00134 
00135   bool planeAllowed(String, String);
00136 
00137  private:
00138 
00139   QtDisplayPanel* qdp_;
00140 
00141   PtrBlock<const ImageRegion*> unionRegions_p;
00142   DisplayData* regData;
00143 
00144   RegionShape* activeShape;
00145 
00146   QTimer* timer;
00147   bool flash;
00148 
00149   int cb;
00150   int zIndex;
00151   int pIndex;
00152   String zAxis;
00153 
00154   QGroupBox* tGroup;
00155   QPushButton* removeAll;
00156   QMenu *showHideMenu;
00157   QPushButton* showHide;
00158   QComboBox* color;
00159   
00160   QLineEdit* chan;
00161   QLineEdit* corr;
00162   QLineEdit* name;
00163   QPushButton* load;
00164   QPushButton* save;
00165 
00166   /*
00167   QGroupBox* eGroup;
00168   QComboBox* shape; 
00169   QPushButton* remove;
00170   QPushButton* rotateL;
00171   QPushButton* rotateR;
00172   QPushButton* left;
00173   QPushButton* right;
00174   QPushButton* up;
00175   QPushButton* down;
00176   QPushButton* wider;
00177   QPushButton* narrower;
00178   QPushButton* taller;
00179   QPushButton* shorter;
00180   */
00181   
00182 };
00183 
00184 
00185 }
00186 
00187 #endif