casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QPPanel.qo.h
Go to the documentation of this file.
1 //# QPPanel.h: Qwt implementation of generic PlotPanel and PlotWidget classes.
2 //# Copyright (C) 2008
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id: $
27 #ifndef QPPANEL_H_
28 #define QPPANEL_H_
29 
30 #ifdef AIPS_HAS_QWT
31 
33 
34 #include <QCheckBox>
35 #include <QFrame>
36 #include <QPushButton>
37 
38 #include <vector>
39 
40 namespace casa {
41 
42 // Implementation of QPButton for Qwt plotter, using a QPushButton.
43 class QPButton : public QObject, public PlotButton {
44  Q_OBJECT
45 
46 public:
47  // Constructor which takes the button text and whether or not the button
48  // should be toggleable.
49  QPButton(const casacore::String& text, bool toggleable = false);
50 
51  // Destructor.
52  ~QPButton();
53 
54 
55  // PlotWidget Methods //
56 
57  // Implements PlotWidget::isEnabled().
58  bool isEnabled() const;
59 
60  // Implements PlotWidget::setEnabled().
61  void setEnabled(bool enabled = true);
62 
63  // Implements PlotWidget::isVisible().
64  bool isVisible() const;
65 
66  // Implements PlotWidget::setVisible().
67  void setVisible(bool visible = true);
68 
69  // Implements PlotWidget::tooltip().
70  casacore::String tooltip() const;
71 
72  // Implements PlotWidget::setTooltip().
73  void setTooltip(const casacore::String& text);
74 
75 
76  // PlotButton Methods //
77 
78  // Implements PlotButton::textShown().
79  bool textShown() const;
80 
81  // Implements PlotButton::showText().
82  void showText(bool show = true);
83 
84  // Implements PlotButton::text().
85  casacore::String text() const;
86 
87  // Implements PlotButton::setText().
88  void setText(const casacore::String& text);
89 
90  // Implements PlotButton::imageShown().
91  bool imageShown() const;
92 
93  // Implements PlotButton::showImage().
94  void showImage(bool show = true);
95 
96  // Implements PlotButton::setImagePath().
97  void setImagePath(const casacore::String& imgPath);
98 
99  // Implements PlotButton::isToggleable().
100  bool isToggleable() const;
101 
102  // Implements PlotButton::setToggleable().
103  void setToggleable(bool toggleable = true);
104 
105  // Implements PlotButton::isToggled().
106  bool isToggled() const;
107 
108  // Implements PlotButton::setToggled().
109  void setToggled(bool toggled = true);
110 
111  // Implements PlotButton::registerHandler().
112  void registerHandler(PlotButtonEventHandlerPtr handler);
113 
114  // Implements PlotButton::allHandlers().
115  std::vector<PlotButtonEventHandlerPtr> allHandlers() const;
116 
117  // Implements PlotButton::unregisterHandler().
118  void unregisterHandler(PlotButtonEventHandlerPtr handler);
119 
120 
121  // QPButton Methods //
122 
123  // Provides access to the underlying QPushButton.
124  // <group>
125  QPushButton* asQPushButton();
126  const QPushButton* asQPushButton() const;
127  // </group>
128 
129 private:
130  QPushButton* m_button; // Button
131  casacore::String m_text; // Text
132  casacore::String m_imageLoc; // Image location
133 
134  std::vector<PlotButtonEventHandlerPtr> m_handlers; // Event handlers
135 
136 private slots:
137  // For when the button is pushed/toggled.
138  void buttonPushed();
139 
140  // For when the button is deleted.
141  void buttonDeleted();
142 };
143 
144 
145 // Implementation of PlotCheckbox for Qwt plotter, using a QCheckBox.
146 class QPCheckbox : public QObject, public PlotCheckbox {
147  Q_OBJECT
148 
149 public:
150  // Constructor that takes the checkbox text.
151  QPCheckbox(const casacore::String& text);
152 
153  // Destructor.
154  ~QPCheckbox();
155 
156 
157  // PlotWidget Methods //
158 
159  // Implements PlotWidget::isEnabled().
160  bool isEnabled() const;
161 
162  // Implements PlotWidget::setEnabled().
163  void setEnabled(bool enabled = true);
164 
165  // Implements PlotWidget::isVisible().
166  bool isVisible() const;
167 
168  // Implements PlotWidget::setVisible().
169  void setVisible(bool visible = true);
170 
171  // Implements PlotWidget::tooltip().
172  casacore::String tooltip() const;
173 
174  // Implements PlotWidget::setTooltip().
175  void setTooltip(const casacore::String& text);
176 
177 
178  // PlotCheckbox Methods //
179 
180  // Implements PlotCheckbox::text().
181  casacore::String text() const;
182 
183  // Implements PlotCheckbox::setText().
184  void setText(const casacore::String& text);
185 
186  // Implements PlotCheckbox::isChecked().
187  bool isChecked() const;
188 
189  // Implements PlotCheckbox::setChecked().
190  void setChecked(bool checked = true);
191 
192  // Implements PlotCheckbox::registerHandler().
193  void registerHandler(PlotCheckboxEventHandlerPtr handler);
194 
195  // Implements PlotCheckbox::allHandlers().
196  std::vector<PlotCheckboxEventHandlerPtr> allHandlers() const;
197 
198  // Implements PlotCheckbox::unregisterHandler().
199  void unregisterHandler(PlotCheckboxEventHandlerPtr handler);
200 
201 
202  // QPCheckbox Methods //
203 
204  // Provides access to the underlying QCheckBox.
205  // <group>
206  QCheckBox* asQCheckBox();
207  const QCheckBox* asQCheckBox() const;
208  // </group>
209 
210 private:
211  QCheckBox* m_checkbox; // Checkbox
212  std::vector<PlotCheckboxEventHandlerPtr> m_handlers; // Event handlers
213 
214 private slots:
215  // For when the checkbox has been toggled.
216  void checkboxToggled();
217 
218  // For when the checkbox has been deleted.
219  void checkboxDeleted();
220 };
221 
222 
223 // Implementation of PlotPanel for Qwt plotter, using a QFrame.
224 class QPPanel : public QObject, public PlotPanel {
225  Q_OBJECT
226 
227 public:
228  // Constructor.
229  QPPanel();
230 
231  // Destructor.
232  ~QPPanel();
233 
234 
235  // PlotPanel Methods //
236 
237  // Implements PlotPanel::widgets().
238  std::vector<PlotWidgetPtr> widgets() const;
239 
240  // Implements PlotPanel::addWidget().
241  int addWidget(PlotWidgetPtr widget);
242 
243  // Implements PlotPanel::clearWidgets().
244  void clearWidgets();
245 
246  // Implements PlotPanel::removeWidget().
247  // <group>
248  void removeWidget(PlotWidgetPtr widget);
249  void removeWidget(int index);
250  // </group>
251 
252 
253  // QPPanel Methods //
254 
255  // Provides access to the underlying QFrame.
256  // <group>
257  QFrame* asQFrame();
258  const QFrame* asQFrame() const;
259  // </group>
260 
261 private:
262  QFrame* m_frame; // Frame
263  std::vector<PlotWidgetPtr> m_widgets; // Widgets
264 
265 private slots:
266  // For when the frame is deleted.
267  void frameDeleted();
268 };
269 
270 }
271 
272 #endif
273 
274 #endif /*QPPANEL_H_*/
casacore::CountedPtr< PlotButtonEventHandler > PlotButtonEventHandlerPtr
casacore::CountedPtr< PlotWidget > PlotWidgetPtr
Definition: PlotPanel.h:62
void show(const variant &v)
casacore::CountedPtr< PlotCheckboxEventHandler > PlotCheckboxEventHandlerPtr
String: the storage and methods of handling collections of characters.
Definition: String.h:223