casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlotItem.h
Go to the documentation of this file.
1 //# PlotItem.h: Top of hierarchy for objects that can be drawn on a canvas.
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 PLOTITEM_H_
28 #define PLOTITEM_H_
29 
31 
32 namespace casa {
33 
34 //# Forward Declarations
35 class PlotCanvas;
36 
37 // PlotItem is the superclass of any object that is meant to be placed on the
38 // canvas (plots, annotations, shapes, etc.). A PlotItem is assumed to have an
39 // x and y axis for drawing on the canvas.
40 class PlotItem {
41 public:
42  // Constructor.
43  PlotItem();
44 
45  // Destructor.
46  virtual ~PlotItem();
47 
48 
49  // Returns the canvas this item is currently attached to, or NULL for none.
50  virtual PlotCanvas* canvas() const = 0;
51 
52  // Returns a human-readable title for identification. Doesn't have to
53  // be unique. Used for (for example) legends and other user-interactions.
54  // Note: PlotItems that have no titles should not be shown on the legend.
55  virtual casacore::String title() const = 0;
56 
57  // Sets this items's title to the given.
58  virtual void setTitle(const casacore::String& newTitle) = 0;
59 
60  // Returns true if this item is valid, false otherwise. Although validity
61  // varies between items, canvases should NOT draw items which are invalid.
62  virtual bool isValid() const = 0;
63 
64  // Returns whether this item can be directly casted to a QWidget or not.
65  virtual bool isQWidget() const = 0;
66 
67  // Returns the item's axes.
68  // <group>
69  virtual PlotAxis xAxis() const = 0;
70  virtual PlotAxis yAxis() const = 0;
71  // </group>
72 
73  // Sets the item's axes.
74  // <group>
75  virtual void setXAxis(PlotAxis x) = 0;
76  virtual void setYAxis(PlotAxis y) = 0;
77  // </group>
78 
79  // Sets both the item's axes at once.
80  // DEFAULT IMPLEMENTATION.
81  virtual void setAxes(PlotAxis x, PlotAxis y);
82 
83  // Returns the "draw count" for this item, which subjectively means how
84  // many indexed draw operations this item needs to make. This is used to
85  // make comparative judgments about how long each item will take to draw,
86  // and to possibly divide up the work for larger items. For example, a
87  // plot with 1000 data points might return 1000, while a square might
88  // return 1. Whatever number is returned, the item should expect to be
89  // able to draw given two indexes; for example, a plot should be able to
90  // draw from index 0 to index 100.
91  virtual unsigned int drawCount() const = 0;
92 
93  // Returns the number of draw segments for this item, using the given
94  // segment threshold. See DrawCount().
95  // DEFAULT IMPLEMENTATION.
96  virtual unsigned int drawSegments(unsigned int segmentThreshold) const;
97 };
99 
100 }
101 
102 #endif /*PLOTITEM_H_*/
virtual void setYAxis(PlotAxis y)=0
virtual casacore::String title() const =0
Returns a human-readable title for identification.
virtual PlotAxis yAxis() const =0
virtual void setXAxis(PlotAxis x)=0
Sets the item&#39;s axes.
PlotItem()
Constructor.
virtual unsigned int drawSegments(unsigned int segmentThreshold) const
Returns the number of draw segments for this item, using the given segment threshold.
virtual bool isValid() const =0
Returns true if this item is valid, false otherwise.
virtual PlotAxis xAxis() const =0
Returns the item&#39;s axes.
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
virtual ~PlotItem()
Destructor.
PlotAxis
Enum for the four plot axes.
Definition: PlotOptions.h:62
virtual unsigned int drawCount() const =0
Returns the &quot;draw count&quot; for this item, which subjectively means how many indexed draw operations thi...
PlotItem is the superclass of any object that is meant to be placed on the canvas (plots...
Definition: PlotItem.h:40
virtual void setTitle(const casacore::String &newTitle)=0
Sets this items&#39;s title to the given.
virtual PlotCanvas * canvas() const =0
Returns the canvas this item is currently attached to, or NULL for none.
PlotCanvas is an area for different PlotItems to be attached and drawn.
Definition: PlotCanvas.h:83
casacore::CountedPtr< PlotItem > PlotItemPtr
Definition: PlotItem.h:98
virtual bool isQWidget() const =0
Returns whether this item can be directly casted to a QWidget or not.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
virtual void setAxes(PlotAxis x, PlotAxis y)
Sets both the item&#39;s axes at once.