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