casa
$Rev:20696$
|
00001 //# qtregionsource.qo.h: qtregionsource producing persistent regions used within the casa viewer 00002 //# Copyright (C) 2011 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_QTREGIONSOURCE_H_ 00030 #define REGION_QTREGIONSOURCE_H_ 00031 00032 #include <map> 00033 #include <QObject> 00034 #include <display/region/RegionSource.h> 00035 #include <display/region/Region.qo.h> 00036 00037 class QStackedWidget; 00038 00039 namespace casa { 00040 00041 class QtDisplayPanelGui; 00042 class QtDisplayData; 00043 00044 class AnnRectBox; 00045 class AnnEllipse; 00046 class AnnSymbol; 00047 class AnnPolygon; 00048 class AnnPolyline; 00049 00050 namespace viewer { 00051 00052 class QtRegion; 00053 class QtRegionDock; 00054 00055 class QtRegionSourceKernel : public QObject, public RegionSourceKernel { 00056 Q_OBJECT 00057 public: 00058 QtRegionSourceKernel( QtDisplayPanelGui *panel ); 00059 00060 QtRegionDock *dock( ); 00061 int numFrames( ) const; 00062 00063 ~QtRegionSourceKernel( ); 00064 00065 void revokeRegion( Region *r ); 00066 00067 // inherited pure-virtual from dtorNotifiee, removes deleted regions... 00068 void dtorCalled( const dtorNotifier * ); 00069 00070 signals: 00071 void regionCreated( int, const QString &shape, const QString &name, 00072 const QList<double> &world_x, const QList<double> &world_y, 00073 const QList<int> &pixel_x, const QList<int> &pixel_y, 00074 const QString &linecolor, const QString &text, const QString &font, int fontsize, int fontstyle ); 00075 void regionUpdate( int, viewer::region::RegionChanges, const QList<double> &world_x, const QList<double> &world_y, 00076 const QList<int> &pixel_x, const QList<int> &pixel_y ); 00077 void regionUpdateResponse( int, const QString &shape, const QString &name, 00078 const QList<double> &world_x, const QList<double> &world_y, 00079 const QList<int> &pixel_x, const QList<int> &pixel_y, 00080 const QString &linecolor, const QString &text, const QString &font, int fontsize, int fontstyle ); 00081 void newCorners( double, double, double, double); 00082 void show1DSliceTool(); 00083 00084 public slots: 00085 //Used to change the position of the source. 00086 void adjustPosition( double blcx, double blcy, double trcx, double trcy ); 00087 00088 protected: 00089 friend class QtRegionSource; 00090 00091 /* std::tr1::shared_ptr<Rectangle> rectangle( int blc_x, int blc_y, int trc_x, int trc_y ); */ 00092 std::tr1::shared_ptr<Rectangle> rectangle( RegionCreator *rc, WorldCanvas *wc, double blc_x, double blc_y, double trc_x, double trc_y ); 00093 std::tr1::shared_ptr<Polygon> polygon( RegionCreator *rc, WorldCanvas *wc, double x1, double y1 ); 00094 std::tr1::shared_ptr<Polygon> polygon( RegionCreator *rc, WorldCanvas *wc, const std::vector<std::pair<double,double> > &pts ); 00095 std::tr1::shared_ptr<Polyline> polyline( RegionCreator *rc, WorldCanvas *wc, double x1, double y1 ); 00096 std::tr1::shared_ptr<Polyline> polyline( RegionCreator *rc, WorldCanvas *wc, const std::vector<std::pair<double,double> > &pts ); 00097 std::tr1::shared_ptr<PVLine> pvline( RegionCreator *rc, WorldCanvas *wc, double blc_x, double blc_y, double trc_x, double trc_y ); 00098 00099 // ellipse is derived from rectangle... so while this should be "std::tr1::shared_ptr<Ellipse>" this would preclude 00100 // the direct reuse of the Rectangle code (which only differs by region creation)... perhaps a case where 00101 // smart pointers are not so smart (in not mirroring the inheritance hiearchy)... though perhaps it can be 00102 // generalized to "std::tr1::shared_ptr<Region>"... 00103 std::tr1::shared_ptr<Rectangle> ellipse( RegionCreator *rc, WorldCanvas *wc, double blc_x, double blc_y, double trc_x, double trc_y ); 00104 std::tr1::shared_ptr<Rectangle> point( RegionCreator *rc, WorldCanvas *wc, double x, double y, QtMouseToolNames::PointRegionSymbols sym, int size ); 00105 00106 QtMouseToolNames::PointRegionSymbols currentPointSymbolType( ) const; 00107 00108 00109 protected slots: 00110 void loadRegions( const QString &path, const QString &type ); 00111 void updateRegionState(QtDisplayData*); 00112 00113 00114 00115 private: 00116 00117 void load_crtf_regions( WorldCanvas *, const QString &path ); 00118 void load_crtf_rectangle( WorldCanvas *wc, MDirection::Types cstype, const AnnRectBox *box ); 00119 void load_crtf_ellipse( WorldCanvas *wc, MDirection::Types cstype, const AnnEllipse *ellipse ); 00120 void load_crtf_point( WorldCanvas *wc, MDirection::Types cstype, const AnnSymbol *symbol ); 00121 void load_crtf_polygon( WorldCanvas *wc, MDirection::Types cstype, const AnnPolygon *polygon ); 00122 void load_crtf_polyline( WorldCanvas *wc, MDirection::Types cstype, const AnnPolyline *polyline ); 00123 00124 QtDisplayPanelGui *panel_; 00125 00126 std::map<Region*,RegionCreator*> creator_of_region; 00127 00128 }; 00129 00130 class QtRegionSource : public RegionSource { 00131 public: 00132 QtRegionSource( RegionCreator *rc, QtDisplayPanelGui *panel ); 00133 protected: 00134 friend class QtRegionSourceFactory; 00135 QtRegionSource( RegionCreator *rc, QtDisplayPanelGui *panel, const shared_kernel_ptr_type &kernel ); 00136 }; 00137 00138 } 00139 } 00140 00141 #endif