QPPlotter.qo.h

Go to the documentation of this file.
00001 //# QPPlotter.qo.h: Qwt implementation of generic Plotter class.
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 QPPLOTTER_QO_H_
00028 #define QPPLOTTER_QO_H_
00029 
00030 #ifdef AIPS_HAS_QWT
00031 
00032 #include <graphics/GenericPlotter/Plotter.h>
00033 #include <casaqt/QwtPlotter/QPPlotter.ui.h>
00034 
00035 #include <QtGui>
00036 
00037 namespace casa {
00038 
00039 //# Forward Declarations
00040 class QPExportCanvas;
00041 class QPCanvas;
00042 class QPAxis;
00043 class PlotFactory;
00044 
00045 // Implementation of Plotter for Qwt plotter.  A QWidget that can be used as a
00046 // main window.
00047 class QPPlotter : public QWidget, Ui::PlotterUI, public Plotter {
00048     Q_OBJECT
00049     
00050     friend class QPCanvas;
00051     friend class QPAxis;
00052     
00053 public:
00054     // Static //
00055 
00056     // Provides access to a global list of Qt colors.
00057     static QStringList GLOBAL_COLORS;
00058     
00059     // Convenient access to class name (QPPlotter).
00060     static const String CLASS_NAME;
00061 
00062     
00063     // Non-Static //
00064     
00065     // Constructor that creates a plotter with a single canvas (or none for
00066     // NULL).  Uses the given log event flags (see PlotLogger::Event) if given,
00067     // and the parent QWidget if given.
00068     QPPlotter(QPCanvas* canvas = NULL,
00069               int logEventFlags = PlotLogger::NO_EVENTS,
00070               QWidget* parent = NULL);
00071     
00072     // Constructor that creates a plotter with the given layout (or none for
00073     // null).  Uses the given log event flags (see PlotLogger::Event) if given,
00074     // and the parent QWidget if given.
00075     QPPlotter(PlotCanvasLayoutPtr layout,
00076               int logEventFlags = PlotLogger::NO_EVENTS,
00077               QWidget* parent = NULL);
00078     
00079     // Destructor.
00080     ~QPPlotter();
00081     
00082     
00083 
00084     // Plotter Methods //
00085    
00086     // Implements Plotter::showGUI().
00087     void showGUI(bool showGUI = true);
00088     bool isGuiShown() const;
00089     
00090     //Kludge for updating the plot when we are in Non-GUI mode.
00091     void updateScriptGui();
00092     
00093     // Implements Plotter::size().
00094     std::pair<int, int> size() const;
00095     
00096     // Implements Plotter::setSize().
00097     void setSize(int width, int height);
00098     
00099     // Implements Plotter::windowTitle().
00100     String windowTitle() const;
00101     
00102     // Implements Plotter::setWindowTitle().
00103     void setWindowTitle(const String& newTitle);
00104     
00105     // Implements Plotter::canvasAreaSize().
00106     std::pair<int, int> canvasAreaSize() const;
00107         
00108     // Implements Plotter::setCanvasSize().
00109     void setCanvasSize(int width, int height, bool resizeWindow = true);
00110     
00111     // Implements Plotter::displayDPI().
00112     int displayDPI() const;
00113 
00114     // Implements Plotter::isQWidget().
00115     bool isQWidget() const { return true; }
00116     
00117     // Implements Plotter::cursor().
00118     PlotCursor cursor() const;
00119     
00120     // Implements Plotter::setCursor().
00121     void setCursor(PlotCursor cursor);
00122     
00123     // Implements Plotter::refresh().
00124     void refresh();
00125     
00126     // Implements Plotter::close().
00127     void close();
00128     
00129     vector<QPExportCanvas*> getGridComponents();
00130     
00131     // Implements Plotter::canvasLayout().
00132     PlotCanvasLayoutPtr canvasLayout();
00133     
00134     // Implements Plotter::setCanvasLayout().
00135     void setCanvasLayout(PlotCanvasLayoutPtr layout);
00136     
00137     // Implements Plotter::canvasLayoutChanged().
00138     void canvasLayoutChanged(PlotCanvasLayout& layout);
00139     
00140     // Implements Plotter::dateFormat().
00141     const String& dateFormat() const;
00142     
00143     // Implements Plotter::setDateFormat().
00144     void setDateFormat(const String& dateFormat);
00145     
00146     // Implements Plotter::relativeDateFormat().
00147     const String& relativeDateFormat() const;
00148     
00149     // Implements Plotter::setRelativeDateFormat().
00150     void setRelativeDateFormat(const String& dateFormat);
00151     
00152     
00153     // Implements Plotter::defaultPanelShown().
00154     bool defaultPanelShown(DefaultPanel panel);
00155     
00156     // Implements Plotter::showDefaultPanel().
00157     void showDefaultPanel(DefaultPanel panel, bool show = true);
00158     
00159     // Implements Plotter::addPanel().
00160     int addPanel(PlotPanelPtr panel);
00161     
00162     // Implements Plotter::allPanels().
00163     vector<PlotPanelPtr> allPanels();
00164     
00165     // Implements Plotter::numPanels().
00166     unsigned int numPanels();
00167     
00168     // Implements Plotter::getPanel().
00169     PlotPanelPtr getPanel(int index);
00170     
00171     // Implements Plotter::panelIndex().
00172     int panelIndex(PlotPanelPtr panel);
00173     
00174     // Implements Plotter::clearPanels().
00175     void clearPanels();
00176     
00177     // Implements Plotter::removePanel().
00178     void removePanel(PlotPanelPtr annotation);
00179     
00180     // Implements Plotter::removePanel().
00181     void removePanel(int id);
00182     
00183     // Implements Plotter::removeLastPanel().
00184     void removeLastPanel();
00185     
00186     
00187     // Implements Plotter::implementation().
00188     Implementation implementation() const { return QWT; }
00189     
00190     // Implements Plotter::implementationFactory().
00191     PlotFactory* implementationFactory() const;
00192     
00193     // Implements Plotter::exportToFile().
00194     bool exportToFile(const PlotExportFormat& format);
00195     
00196     // Implements Plotter::fileChooserDialog().
00197     String fileChooserDialog(const String& title = "File Chooser",
00198                              const String& directory = "");
00199 
00200     
00201     // Implements Plotter::registerResizeHandler().
00202     void registerResizeHandler(PlotResizeEventHandlerPtr handler);
00203     
00204     // Implements Plotter::allResizeHandlers().
00205     vector<PlotResizeEventHandlerPtr> allResizeHandlers() const;
00206     
00207     // Implements Plotter::unregisterResizeHandlers().
00208     void unregisterResizeHandler(PlotResizeEventHandlerPtr handler);
00209     
00210     
00211     // Returns the frame used to hold the canvases.
00212     // <group>
00213     const QWidget* canvasWidget() const;
00214     QWidget* canvasWidget();
00215     // </group>
00216     
00217     // Overrides QWidget::sizeHint() to return an invalid size.
00218     QSize sizeHint() const;
00219     
00220     // Overrides QWidget::minimumSizeHint() to return an invalid size.
00221     QSize minimumSizeHint() const;
00222     
00223     virtual bool exportPlot(const PlotExportFormat& format );
00224 
00225         //Return the number of rows and columns in the current grid.
00226     int getRowCount();
00227     int getColCount();
00228 protected:
00229     // For catching resize events.
00230     void resizeEvent(QResizeEvent* event);
00231     
00232     // Logs the given object creation/destruction event, if needed.
00233     void logObject(const String& className, void* address, bool creation,
00234             const String& message = String());
00235     
00236     // Logs the given method enter/exit event, if needed.
00237     void logMethod(const String& className, const String& methodName,
00238             bool entering, const String& message = String());
00239     
00240 private:
00241     // Canvas layout.
00242     PlotCanvasLayoutPtr m_layout;
00243     
00244     // Standard tools for canvases.
00245     vector<PlotStandardMouseToolGroupPtr> m_canvasTools;
00246     
00247     // Registered handlers.
00248     vector<PlotResizeEventHandlerPtr> m_resizeHandlers;
00249     
00250     // Panels.
00251     vector<PlotPanelPtr> m_panels;
00252     
00253     // Flag for whether a resize event should be emitted.
00254     bool m_emitResize;
00255     bool m_guiShown;
00256     
00257     // Date formats.
00258     // <group>
00259     String m_dateFormat;
00260     String m_relativeDateFormat;
00261     // </group>
00262     
00263     QList<QPAxis*> externalAxes;
00264     
00265     // Sets up the canvas QFrame for the current layout.
00266     void setupCanvasFrame();
00267     
00268     // Initializes GUI (to be called from constructors).
00269     void initialize();
00270     
00271     void clearExternalAxes();
00272     void emptyLayout();
00273 
00274     // Static //
00275     
00276     // Used to initialize GLOBAL_COLORS.
00277     // <group>
00278     static bool __initColors;    
00279     static bool initColors();
00280     // </group>
00281     
00282     //Returns true if the given axis is drawn by the Qwt plot; false if
00283     //the drawing is external and custom.
00284     // <group>
00285     bool isLeftAxisInternal() const;
00286     bool isBottomAxisInternal() const;
00287     bool isRightAxisInternal() const;
00288     bool isTopAxisInternal() const;
00289     // </group>
00290 
00291     //Reset the size hints of the canvases this plotter holds based on its current size.
00292     void resetCanvasMinSizeHints();
00293 private slots:
00294     // Default panel: hand tool changed.
00295     void handToolChanged(bool on);
00296     
00297     // Default panel: tracker toggled.
00298     void trackerTurned(bool on);
00299     
00300     // Default panel: legend toggled.
00301     void legendTurned(bool on);
00302     
00303     // Default panel: legend position changed.
00304     void legendPositionChanged() { legendTurned(legendBox->isChecked()); }
00305     
00306     // Default panel: export button pushed.
00307     void exportCanvases();
00308 };
00309 
00310 }
00311 
00312 #endif
00313 
00314 #endif /*QPPLOTTER_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