casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlotPanel.h
Go to the documentation of this file.
1 //# PlotPanel.h: Custom plot panels and buttons.
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 PLOTPANEL_H_
28 #define PLOTPANEL_H_
29 
31 
32 namespace casa {
33 
34 // Abstract superclass for any widget that goes on a PlotPanel.
35 class PlotWidget {
36 public:
37  // Constructor.
38  PlotWidget() { }
39 
40  // Destructor.
41  virtual ~PlotWidget() { }
42 
43  // Returns true if the widget is currently enabled, false otherwise.
44  // A widget button should be grayed out or not interact-able.
45  virtual bool isEnabled() const = 0;
46 
47  // Enables/disables the widget.
48  virtual void setEnabled(bool enabled = true) = 0;
49 
50  // Returns true if the widget is currently visible.
51  virtual bool isVisible() const = 0;
52 
53  // Show/hide the widget.
54  virtual void setVisible(bool visible = true) = 0;
55 
56  // Returns the tooltip for this widget.
57  virtual casacore::String tooltip() const = 0;
58 
59  // Sets the tooltip for this widget.
60  virtual void setTooltip(const casacore::String& text) = 0;
61 };
63 
64 
65 // Generic class for a button that goes on a PlotPanel. A button has
66 // properties that can be set, as well as registration for event
67 // handlers. A button can only be seen/interacted with on a PlotPanel.
68 class PlotButton : public virtual PlotWidget {
69 public:
70  // Constructor.
71  PlotButton() { }
72 
73  // Destructor.
74  virtual ~PlotButton() { }
75 
76  // Returns true if text is being shown on the button, false otherwise.
77  virtual bool textShown() const = 0;
78 
79  // Show/hide the set text on the button.
80  virtual void showText(bool show = true) = 0;
81 
82  // Currently set button text. (May not be displayed.)
83  virtual casacore::String text() const = 0;
84 
85  // Sets the button text.
86  virtual void setText(const casacore::String& text) = 0;
87 
88  // Returns true if an image is being shown on the button, false otherwise.
89  virtual bool imageShown() const = 0;
90 
91  // Show/hide the set image on the button.
92  virtual void showImage(bool show = true) = 0;
93 
94  // Set the image path to be shown on the button.
95  virtual void setImagePath(const casacore::String& imgPath) = 0;
96 
97  // Returns true if the button is "toggleable", false otherwise. A button
98  // that is toggleable sticks down when pushed, then comes back up when
99  // pushed again. The state can be determined with isToggled().
100  virtual bool isToggleable() const = 0;
101 
102  // Sets whether this button is "toggleable" or not.
103  virtual void setToggleable(bool toggleable = true) = 0;
104 
105  // Returns whether this button is in a toggled state or not.
106  virtual bool isToggled() const = 0;
107 
108  // Sets whether this button is in a toggled state or not. (Does not
109  // affect buttons that are not toggleable.)
110  virtual void setToggled(bool toggled = true) = 0;
111 
112  // Register the given event handler for this button.
113  virtual void registerHandler(PlotButtonEventHandlerPtr handler) = 0;
114 
115  // Returns all event handlers currently registered on this button.
116  virtual std::vector<PlotButtonEventHandlerPtr> allHandlers() const = 0;
117 
118  // Unregisters the given event handler.
119  virtual void unregisterHandler(PlotButtonEventHandlerPtr handler) = 0;
120 };
121 
122 
123 // Generic class for a checkbox that goes on a PlotPanel. A checkbox has
124 // properties that can be set, as well as registration for event
125 // handlers. A checkbox can only be seen/interacted with on a PlotPanel.
126 class PlotCheckbox : public virtual PlotWidget {
127 public:
128  // Constructor.
130 
131  // Destructor.
132  virtual ~PlotCheckbox() { }
133 
134  // Returns the text for this checkbox.
135  virtual casacore::String text() const = 0;
136 
137  // Sets the text for this checkbox.
138  virtual void setText(const casacore::String& text) = 0;
139 
140  // Returns true if the checkbox is currently checked, false otherwise.
141  virtual bool isChecked() const = 0;
142 
143  // Sets whether the checkbox is checked or not.
144  virtual void setChecked(bool checked = true) = 0;
145 
146  // Register the given event handler for this checkbox.
147  virtual void registerHandler(PlotCheckboxEventHandlerPtr handler) = 0;
148 
149  // Returns all event handlers currently registered on this button.
150  virtual std::vector<PlotCheckboxEventHandlerPtr> allHandlers() const = 0;
151 
152  // Unregisters the given event handler.
153  virtual void unregisterHandler(PlotCheckboxEventHandlerPtr handler) = 0;
154 };
155 
156 
157 // A PlotPanel is a panel that goes on the bottom of the plot window. A
158 // single panel can contain multiple widgets.
159 class PlotPanel {
160 public:
161  PlotPanel() { }
162 
163  virtual ~PlotPanel() { }
164 
165  // Returns all PlotWidgets currently on the panel.
166  virtual std::vector<PlotWidgetPtr> widgets() const = 0;
167 
168  // Adds the given widget to this panel.
169  virtual int addWidget(PlotWidgetPtr widget) = 0;
170 
171  // Clears all widgets on the panel.
172  virtual void clearWidgets() = 0;
173 
174  // Removes the given widget from this panel.
175  virtual void removeWidget(PlotWidgetPtr widget) = 0;
176 
177  // Removes the widget at the given index from this panel.
178  virtual void removeWidget(int index) = 0;
179 };
180 
181 
183 // SMART POINTER DEFINITIONS //
185 
186 INHERITANCE_POINTER2(PlotButton, PlotButtonPtr, PlotWidget, PlotWidgetPtr)
187 INHERITANCE_POINTER2(PlotCheckbox, PlotCheckboxPtr, PlotWidget, PlotWidgetPtr)
189 
190 }
191 
192 #endif /*PLOTPANEL_H_*/
virtual bool isChecked() const =0
Returns true if the checkbox is currently checked, false otherwise.
virtual bool imageShown() const =0
Returns true if an image is being shown on the button, false otherwise.
PlotCheckbox()
Constructor.
Definition: PlotPanel.h:129
virtual std::vector< PlotButtonEventHandlerPtr > allHandlers() const =0
Returns all event handlers currently registered on this button.
virtual void registerHandler(PlotCheckboxEventHandlerPtr handler)=0
Register the given event handler for this checkbox.
PlotWidget()
Constructor.
Definition: PlotPanel.h:38
virtual void setText(const casacore::String &text)=0
Sets the text for this checkbox.
virtual void clearWidgets()=0
Clears all widgets on the panel.
Abstract superclass for any widget that goes on a PlotPanel.
Definition: PlotPanel.h:35
virtual bool textShown() const =0
Returns true if text is being shown on the button, false otherwise.
virtual void removeWidget(PlotWidgetPtr widget)=0
Removes the given widget from this panel.
virtual casacore::String text() const =0
Returns the text for this checkbox.
Generic class for a button that goes on a PlotPanel.
Definition: PlotPanel.h:68
virtual ~PlotPanel()
Definition: PlotPanel.h:163
casacore::CountedPtr< PlotWidget > PlotWidgetPtr
Definition: PlotPanel.h:62
virtual void unregisterHandler(PlotButtonEventHandlerPtr handler)=0
Unregisters the given event handler.
void show(const variant &v)
virtual void setToggleable(bool toggleable=true)=0
Sets whether this button is &quot;toggleable&quot; or not.
Generic class for a checkbox that goes on a PlotPanel.
Definition: PlotPanel.h:126
virtual ~PlotCheckbox()
Destructor.
Definition: PlotPanel.h:132
virtual void showImage(bool show=true)=0
Show/hide the set image on the button.
virtual void setEnabled(bool enabled=true)=0
Enables/disables the widget.
virtual casacore::String text() const =0
Currently set button text.
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
virtual ~PlotWidget()
Destructor.
Definition: PlotPanel.h:41
SMART POINTER DEFINITIONS *typedef casacore::CountedPtr< PlotPanel > PlotPanelPtr
Definition: PlotPanel.h:188
virtual std::vector< PlotWidgetPtr > widgets() const =0
Returns all PlotWidgets currently on the panel.
virtual std::vector< PlotCheckboxEventHandlerPtr > allHandlers() const =0
Returns all event handlers currently registered on this button.
virtual void setImagePath(const casacore::String &imgPath)=0
Set the image path to be shown on the button.
PlotButton()
Constructor.
Definition: PlotPanel.h:71
virtual void setTooltip(const casacore::String &text)=0
Sets the tooltip for this widget.
virtual casacore::String tooltip() const =0
Returns the tooltip for this widget.
virtual void showText(bool show=true)=0
Show/hide the set text on the button.
virtual bool isToggled() const =0
Returns whether this button is in a toggled state or not.
A PlotPanel is a panel that goes on the bottom of the plot window.
Definition: PlotPanel.h:159
INHERITANCE_POINTER2(PlotLayoutSingle, PlotLayoutSinglePtr, PlotCanvasLayout, PlotCanvasLayoutPtr) INHERITANCE_POINTER2(PlotLayoutGrid
virtual ~PlotButton()
Destructor.
Definition: PlotPanel.h:74
virtual void setText(const casacore::String &text)=0
Sets the button text.
virtual bool isToggleable() const =0
Returns true if the button is &quot;toggleable&quot;, false otherwise.
virtual bool isEnabled() const =0
Returns true if the widget is currently enabled, false otherwise.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
virtual void setToggled(bool toggled=true)=0
Sets whether this button is in a toggled state or not.
virtual int addWidget(PlotWidgetPtr widget)=0
Adds the given widget to this panel.
virtual bool isVisible() const =0
Returns true if the widget is currently visible.
virtual void setVisible(bool visible=true)=0
Show/hide the widget.
virtual void unregisterHandler(PlotCheckboxEventHandlerPtr handler)=0
Unregisters the given event handler.
virtual void registerHandler(PlotButtonEventHandlerPtr handler)=0
Register the given event handler for this button.
virtual void setChecked(bool checked=true)=0
Sets whether the checkbox is checked or not.
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42