casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlotAnnotation.h
Go to the documentation of this file.
1 //# PlotAnnotation.h: Annotation class 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 PLOTANNOTATION_H_
28 #define PLOTANNOTATION_H_
29 
31 
32 #include <casa/BasicSL/String.h>
33 
34 namespace casa {
35 
36 // PlotAnnotation is an abstraction of text written directly on the canvas. An
37 // annotation has text, font, orientation, outline, and background properties.
38 class PlotAnnotation : public virtual PlotItem {
39 public:
40  // Constructor.
42 
43  // Destructor.
44  virtual ~PlotAnnotation() { }
45 
46 
47  // Implements PlotItem::drawCount(). Provides default implementation that
48  // returns 1.
49  virtual unsigned int drawCount() const { return 1; }
50 
51  // ABSTRACT METHODS //
52 
53  // Returns the text of the annotation.
54  virtual casacore::String text() const = 0;
55 
56  // Sets the text of the annotation.
57  virtual void setText(const casacore::String& newText) = 0;
58 
59  // Returns a copy of the font used in the annotation.
60  virtual PlotFontPtr font() const = 0;
61 
62  // Sets the annotation font to the given.
63  virtual void setFont(const PlotFont& font) = 0;
64 
65  // Returns orientation in counterclockwise degrees (between 0 and 360).
66  virtual int orientation() const = 0;
67 
68  // Sets the orientation in counterclockwise degrees (between 0 and 360).
69  virtual void setOrientation(int orientation) = 0;
70 
71  // Returns the coordinate where the annotation is located on the canvas it
72  // is attached to.
73  virtual PlotCoordinate coordinate() const = 0;
74 
75  // Sets the location of the annotation to the given.
76  virtual void setCoordinate(const PlotCoordinate& coord) = 0;
77 
78  // Returns true if an outline is shown around the annotation, false
79  // otherwise.
80  virtual bool outlineShown() const = 0;
81 
82  // Sets whether an outline is shown around the annotation.
83  virtual void setOutlineShown(bool show = true) = 0;
84 
85  // Returns a copy of the line used to draw the outline for this annotation.
86  virtual PlotLinePtr outline() const = 0;
87 
88  // Sets the outline to the given line.
89  virtual void setOutline(const PlotLine& line) = 0;
90 
91  // Returns a copy of the area fill used for the annotation's background.
92  virtual PlotAreaFillPtr background() const = 0;
93 
94  // Sets the annotation's background to the given.
95  virtual void setBackground(const PlotAreaFill& area) = 0;
96 
97 
98  // IMPLEMENTED METHODS //
99 
100  // Convenience methods for setting font.
101  // <group>
102  virtual void setFont(const PlotFontPtr font) {
103  if(!font.null()) setFont(*font); }
104  virtual void setFontColor(const casacore::String& color) {
105  PlotFontPtr f = font();
106  f->setColor(color);
107  setFont(*f);
108  }
109  // </group>
110 
111  // Convenience methods for setting the outline.
112  // <group>
113  virtual void setOutline(const PlotLinePtr line) {
114  if(!line.null()) setOutline(*line);
115  else setOutlineShown(false);
116  }
117  virtual void setOutline(const casacore::String& color,
118  PlotLine::Style style = PlotLine::SOLID, double width = 1.0) {
119  PlotLinePtr line = outline();
120  line->setColor(color);
121  line->setStyle(style);
122  line->setWidth(width);
123  setOutline(*line);
124  }
125  // </group>
126 
127  // Convenience methods for setting the background.
128  // <group>
129  virtual void setBackground(const PlotAreaFillPtr area) {
130  if(!area.null()) setBackground(*area); }
131  virtual void setBackground(const casacore::String& color,
134  bg->setColor(color);
135  bg->setPattern(pattern);
136  setBackground(*bg);
137  }
138  // </group>
139 };
140 INHERITANCE_POINTER2(PlotAnnotation, PlotAnnotationPtr, PlotItem, PlotItemPtr)
141 
142 }
143 
144 #endif /*PLOTANNOTATION_H_*/
Bool null() const
Check to see if this CountedPtr is un-initialized, null.
Definition: CountedPtr.h:237
virtual void setFont(const PlotFont &font)=0
Sets the annotation font to the given.
virtual PlotAreaFillPtr background() const =0
Returns a copy of the area fill used for the annotation&#39;s background.
PlotAnnotation is an abstraction of text written directly on the canvas.
virtual PlotLinePtr outline() const =0
Returns a copy of the line used to draw the outline for this annotation.
virtual void setOutlineShown(bool show=true)=0
Sets whether an outline is shown around the annotation.
virtual PlotCoordinate coordinate() const =0
Returns the coordinate where the annotation is located on the canvas it is attached to...
virtual void setOutline(const PlotLine &line)=0
Sets the outline to the given line.
virtual void setOutline(const casacore::String &color, PlotLine::Style style=PlotLine::SOLID, double width=1.0)
Abstract class for area fill.
Definition: PlotOptions.h:296
virtual void setBackground(const PlotAreaFillPtr area)
Convenience methods for setting the background.
Pattern
Pattern enum, similar in spirit to http://doc.trolltech.com/4.3/qt.html#BrushStyle-enum.
Definition: PlotOptions.h:300
void show(const variant &v)
TableExprNode pattern(const TableExprNode &node)
Definition: ExprNode.h:1444
virtual casacore::String text() const =0
ABSTRACT METHODS //.
virtual void setBackground(const PlotAreaFill &area)=0
Sets the annotation&#39;s background to the given.
Abstract class for a line.
Definition: PlotOptions.h:368
virtual unsigned int drawCount() const
Implements PlotItem::drawCount().
PlotItem
Definition: Plot.h:598
Style
Static //.
Definition: PlotOptions.h:373
virtual void setFont(const PlotFontPtr font)
IMPLEMENTED METHODS //.
PlotItem is the superclass of any object that is meant to be placed on the canvas (plots...
Definition: PlotItem.h:40
virtual void setCoordinate(const PlotCoordinate &coord)=0
Sets the location of the annotation to the given.
INHERITANCE_POINTER2(PlotLayoutSingle, PlotLayoutSinglePtr, PlotCanvasLayout, PlotCanvasLayoutPtr) INHERITANCE_POINTER2(PlotLayoutGrid
virtual void setOrientation(int orientation)=0
Sets the orientation in counterclockwise degrees (between 0 and 360).
casacore::CountedPtr< PlotItem > PlotItemPtr
Definition: PlotItem.h:98
virtual ~PlotAnnotation()
Destructor.
PlotAnnotation()
Constructor.
virtual int orientation() const =0
Returns orientation in counterclockwise degrees (between 0 and 360).
virtual void setFontColor(const casacore::String &color)
virtual void setBackground(const casacore::String &color, PlotAreaFill::Pattern pattern=PlotAreaFill::FILL)
String: the storage and methods of handling collections of characters.
Definition: String.h:223
virtual bool outlineShown() const =0
Returns true if an outline is shown around the annotation, false otherwise.
virtual void setText(const casacore::String &newText)=0
Sets the text of the annotation.
Abstract class for fonts.
Definition: PlotOptions.h:200
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the color(i.e.,"000000"for black) and
virtual void setOutline(const PlotLinePtr line)
Convenience methods for setting the outline.
virtual PlotFontPtr font() const =0
Returns a copy of the font used in the annotation.