casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
QPPanel.qo.h
Go to the documentation of this file.
00001 //# QPPanel.h: Qwt implementation of generic PlotPanel and PlotWidget classes.
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 QPPANEL_H_
00028 #define QPPANEL_H_
00029 
00030 #ifdef AIPS_HAS_QWT
00031 
00032 #include <graphics/GenericPlotter/PlotPanel.h>
00033 
00034 #include <QCheckBox>
00035 #include <QFrame>
00036 #include <QPushButton>
00037 
00038 #include <casa/namespace.h>
00039 
00040 namespace casa {
00041 
00042 // Implementation of QPButton for Qwt plotter, using a QPushButton.
00043 class QPButton : public QObject, public PlotButton {
00044     Q_OBJECT
00045     
00046 public:
00047     // Constructor which takes the button text and whether or not the button
00048     // should be toggleable.
00049     QPButton(const String& text, bool toggleable = false);
00050     
00051     // Destructor.
00052     ~QPButton();
00053     
00054     
00055     // PlotWidget Methods //
00056     
00057     // Implements PlotWidget::isEnabled().
00058     bool isEnabled() const;
00059     
00060     // Implements PlotWidget::setEnabled().
00061     void setEnabled(bool enabled = true);
00062     
00063     // Implements PlotWidget::isVisible().
00064     bool isVisible() const;
00065     
00066     // Implements PlotWidget::setVisible().
00067     void setVisible(bool visible = true);
00068     
00069     // Implements PlotWidget::tooltip().
00070     String tooltip() const;
00071     
00072     // Implements PlotWidget::setTooltip().
00073     void setTooltip(const String& text);
00074     
00075     
00076     // PlotButton Methods //
00077     
00078     // Implements PlotButton::textShown().
00079     bool textShown() const;
00080     
00081     // Implements PlotButton::showText().
00082     void showText(bool show = true);
00083     
00084     // Implements PlotButton::text().
00085     String text() const;
00086     
00087     // Implements PlotButton::setText().
00088     void setText(const String& text);
00089     
00090     // Implements PlotButton::imageShown().
00091     bool imageShown() const;
00092     
00093     // Implements PlotButton::showImage().
00094     void showImage(bool show = true);
00095     
00096     // Implements PlotButton::setImagePath().
00097     void setImagePath(const String& imgPath);
00098     
00099     // Implements PlotButton::isToggleable().
00100     bool isToggleable() const;
00101     
00102     // Implements PlotButton::setToggleable().
00103     void setToggleable(bool toggleable = true);
00104     
00105     // Implements PlotButton::isToggled().
00106     bool isToggled() const;
00107     
00108     // Implements PlotButton::setToggled().
00109     void setToggled(bool toggled = true);
00110     
00111     // Implements PlotButton::registerHandler().
00112     void registerHandler(PlotButtonEventHandlerPtr handler);
00113     
00114     // Implements PlotButton::allHandlers().
00115     vector<PlotButtonEventHandlerPtr> allHandlers() const;
00116     
00117     // Implements PlotButton::unregisterHandler().
00118     void unregisterHandler(PlotButtonEventHandlerPtr handler);
00119     
00120     
00121     // QPButton Methods //
00122     
00123     // Provides access to the underlying QPushButton.
00124     // <group>
00125     QPushButton* asQPushButton();
00126     const QPushButton* asQPushButton() const;
00127     // </group>
00128     
00129 private:
00130     QPushButton* m_button; // Button
00131     String m_text;         // Text
00132     String m_imageLoc;     // Image location
00133     
00134     vector<PlotButtonEventHandlerPtr> m_handlers; // Event handlers
00135     
00136 private slots:
00137     // For when the button is pushed/toggled.
00138     void buttonPushed();
00139     
00140     // For when the button is deleted.
00141     void buttonDeleted();
00142 };
00143 
00144 
00145 // Implementation of PlotCheckbox for Qwt plotter, using a QCheckBox.
00146 class QPCheckbox : public QObject, public PlotCheckbox {
00147     Q_OBJECT
00148     
00149 public:
00150     // Constructor that takes the checkbox text.
00151     QPCheckbox(const String& text);
00152     
00153     // Destructor.
00154     ~QPCheckbox();
00155 
00156     
00157     // PlotWidget Methods //
00158     
00159     // Implements PlotWidget::isEnabled().
00160     bool isEnabled() const;
00161     
00162     // Implements PlotWidget::setEnabled().
00163     void setEnabled(bool enabled = true);
00164     
00165     // Implements PlotWidget::isVisible().
00166     bool isVisible() const;
00167     
00168     // Implements PlotWidget::setVisible().
00169     void setVisible(bool visible = true);
00170     
00171     // Implements PlotWidget::tooltip().
00172     String tooltip() const;
00173     
00174     // Implements PlotWidget::setTooltip().
00175     void setTooltip(const String& text);
00176     
00177     
00178     // PlotCheckbox Methods //
00179     
00180     // Implements PlotCheckbox::text().
00181     String text() const;
00182     
00183     // Implements PlotCheckbox::setText().
00184     void setText(const String& text);
00185     
00186     // Implements PlotCheckbox::isChecked().
00187     bool isChecked() const;
00188     
00189     // Implements PlotCheckbox::setChecked().
00190     void setChecked(bool checked = true);
00191     
00192     // Implements PlotCheckbox::registerHandler().
00193     void registerHandler(PlotCheckboxEventHandlerPtr handler);
00194     
00195     // Implements PlotCheckbox::allHandlers().
00196     vector<PlotCheckboxEventHandlerPtr> allHandlers() const;
00197     
00198     // Implements PlotCheckbox::unregisterHandler().
00199     void unregisterHandler(PlotCheckboxEventHandlerPtr handler);
00200     
00201     
00202     // QPCheckbox Methods //
00203     
00204     // Provides access to the underlying QCheckBox.
00205     // <group>
00206     QCheckBox* asQCheckBox();
00207     const QCheckBox* asQCheckBox() const;
00208     // </group>
00209     
00210 private:
00211     QCheckBox* m_checkbox; // Checkbox
00212     vector<PlotCheckboxEventHandlerPtr> m_handlers; // Event handlers
00213     
00214 private slots:
00215     // For when the checkbox has been toggled.
00216     void checkboxToggled();
00217     
00218     // For when the checkbox has been deleted.
00219     void checkboxDeleted();
00220 };
00221 
00222 
00223 // Implementation of PlotPanel for Qwt plotter, using a QFrame.
00224 class QPPanel : public QObject, public PlotPanel {
00225     Q_OBJECT
00226     
00227 public:
00228     // Constructor.
00229     QPPanel();
00230     
00231     // Destructor.
00232     ~QPPanel();
00233 
00234     
00235     // PlotPanel Methods //
00236     
00237     // Implements PlotPanel::widgets().
00238     vector<PlotWidgetPtr> widgets() const;
00239     
00240     // Implements PlotPanel::addWidget().
00241     int addWidget(PlotWidgetPtr widget);
00242     
00243     // Implements PlotPanel::clearWidgets().
00244     void clearWidgets();
00245     
00246     // Implements PlotPanel::removeWidget().
00247     // <group>
00248     void removeWidget(PlotWidgetPtr widget);
00249     void removeWidget(int index);
00250     // </group>
00251     
00252     
00253     // QPPanel Methods //
00254     
00255     // Provides access to the underlying QFrame.
00256     // <group>
00257     QFrame* asQFrame();    
00258     const QFrame* asQFrame() const;
00259     // </group>
00260     
00261 private:
00262     QFrame* m_frame;                 // Frame
00263     vector<PlotWidgetPtr> m_widgets; // Widgets
00264     
00265 private slots:
00266     // For when the frame is deleted.
00267     void frameDeleted();
00268 };
00269 
00270 }
00271 
00272 #endif
00273 
00274 #endif /*QPPANEL_H_*/