QPTool.qo.h

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

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1