casa
$Rev:20696$
|
00001 //# QPTool.qo.h: Qwt implementations of PlotTools. 00002 //# Copyright (C) 2008 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 #ifndef QPTOOL_QO_H_ 00028 #define QPTOOL_QO_H_ 00029 00030 #ifdef AIPS_HAS_QWT 00031 #include <graphics/GenericPlotter/PlotTool.h> 00032 00033 #include <casaqt/QwtPlotter/QPAnnotation.h> 00034 00035 #include <qwt_plot_picker.h> 00036 #include <qwt_plot_panner.h> 00037 00038 #include <casa/namespace.h> 00039 00040 namespace casa { 00041 00042 //# Forward Declarations 00043 class QPTracker; 00044 00045 00046 // Subclass of PlotSelectTool specific to Qwt plotter. Currently isn't 00047 // specialized. 00048 class QPSelectTool : public PlotSelectTool { 00049 public: 00050 // Constructor which takes the tool's coordinate system. 00051 QPSelectTool(PlotCoordinate::System sys = PlotCoordinate::WORLD); 00052 00053 // Constructor which takes the tool's axes and coordinate system. 00054 QPSelectTool(PlotAxis xAxis, PlotAxis yAxis, 00055 PlotCoordinate::System sys = PlotCoordinate::WORLD); 00056 00057 // Destructor. 00058 ~QPSelectTool(); 00059 }; 00060 00061 00062 // Subclass of PlotZoomTool specific to Qwt plotter. Currently isn't 00063 // specialized. 00064 class QPZoomTool : public PlotZoomTool { 00065 public: 00066 // Constructor which takes the tool's coordinate system. 00067 QPZoomTool(PlotCoordinate::System sys = PlotCoordinate::WORLD); 00068 00069 // Constructor which takes the tool's axes and coordinate system. 00070 QPZoomTool(PlotAxis xAxis, PlotAxis yAxis, 00071 PlotCoordinate::System sys = PlotCoordinate::WORLD); 00072 00073 // Destructor. 00074 ~QPZoomTool(); 00075 }; 00076 00077 00078 // Subclass of PlotPanTool specific to Qwt plotter. Uses a QwtPlotPanner to 00079 // manage some behavior. 00080 class QPPanTool : public QObject, public PlotPanTool { 00081 Q_OBJECT 00082 00083 public: 00084 // Constructor which takes the tool's coordinate system. 00085 QPPanTool(PlotCoordinate::System sys = PlotCoordinate::WORLD); 00086 00087 // Constructor which takes the tool's axes and coordinate system. 00088 QPPanTool(PlotAxis xAxis, PlotAxis yAxis, 00089 PlotCoordinate::System sys = PlotCoordinate::WORLD); 00090 00091 // Destructor. 00092 ~QPPanTool(); 00093 00094 00095 // PlotTool Methods // 00096 00097 // Overrides PlotTool::setActive(). 00098 void setActive(bool isActive = true); 00099 00100 00101 // PlotMouseTool Methods // 00102 00103 // Implements PlotMouseTool::handleMouseEvent() to handle wheel and right 00104 // click. 00105 void handleMouseEvent(const PlotEvent& event); 00106 00107 protected: 00108 // PlotTool Methods // 00109 00110 // Overrides PlotTool::attach(). 00111 void attach(PlotCanvas* canvas); 00112 00113 // Overrides PlotTool::detach(). 00114 void detach(); 00115 00116 private: 00117 QwtPlotPanner* m_panner; // Panner 00118 00119 private slots: 00120 // For when the pan window changes (to update the stack). 00121 void panned(int dx, int dy); 00122 }; 00123 00124 00125 // Subclass of PlotTrackerTool specific to Qwt plotter, using a QPTracker. 00126 class QPTrackerTool : public PlotTrackerTool { 00127 public: 00128 // Constructor which takes the tool's coordinate system. 00129 QPTrackerTool(PlotCoordinate::System sys = PlotCoordinate::WORLD); 00130 00131 // Constructor which takes the tool's axes and coordinate system. 00132 QPTrackerTool(PlotAxis xAxis, PlotAxis yAxis, 00133 PlotCoordinate::System sys = PlotCoordinate::WORLD); 00134 00135 // Destructor. 00136 ~QPTrackerTool(); 00137 00138 // PlotTool Methods // 00139 00140 // Overrides PlotTool::setActive(). 00141 void setActive(bool isActive = true); 00142 00143 00144 // PlotMouseTool Methods // 00145 00146 // Implements PlotMouseTool::handleMouseEvent() to update PlotTrackerTool's 00147 // annotation with that of the QPTracker. 00148 void handleMouseEvent(const PlotEvent& event); 00149 00150 // PlotTrackerTool Methods // 00151 00152 // Overrides PlotTrackerTool::setDrawText(). 00153 void setDrawText(bool draw = true); 00154 00155 protected: 00156 // PlotTool Methods // 00157 00158 // Overrides PlotTool::attach(). 00159 void attach(PlotCanvas* canvas); 00160 00161 // Overrides PlotTool::detach(). 00162 void detach(); 00163 00164 private: 00165 QPTracker* m_tracker; // Tracker. 00166 }; 00167 00168 00169 // Subclass of QwtPlotPicker to be more compatible with PlotTrackerTool. 00170 class QPTracker : public QwtPlotPicker { 00171 Q_OBJECT 00172 00173 public: 00174 // Constructor which takes the tracker and the canvas to be installed on. 00175 QPTracker(QPTrackerTool& tracker, QwtPlotCanvas* canvas); 00176 00177 // Destructor. 00178 ~QPTracker(); 00179 00180 00181 // Returns the annotation which holds the current position and tracker 00182 // text. 00183 PlotAnnotationPtr getAnnotation() { 00184 return PlotAnnotationPtr(&m_annotation, false); } 00185 00186 00187 // QwtPlotPicker Methods // 00188 00189 // Overrides QwtPlotPicker::trackerText() to take font and format into 00190 // account. 00191 // <group> 00192 QwtText trackerText(const QPoint& pos) const { 00193 return trackerText(invTransform(pos)); } 00194 QwtText trackerText(const QwtDoublePoint& pos) const; 00195 // </group> 00196 00197 private: 00198 QPTrackerTool& m_tracker; // Tracker tool 00199 QPAnnotation m_annotation; // Current annotation 00200 }; 00201 00202 } 00203 00204 #endif 00205 00206 #endif /* QPTOOL_QO_H_ */