PlotAnnotation.h

Go to the documentation of this file.
00001 //# PlotAnnotation.h: Annotation class that can be drawn on a canvas.
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 PLOTANNOTATION_H_
00028 #define PLOTANNOTATION_H_
00029 
00030 #include <graphics/GenericPlotter/PlotItem.h>
00031 
00032 #include <casa/BasicSL/String.h>
00033 
00034 namespace casa {
00035 
00036 // PlotAnnotation is an abstraction of text written directly on the canvas.  An
00037 // annotation has text, font, orientation, outline, and background properties.
00038 class PlotAnnotation : public virtual PlotItem {
00039 public:
00040     // Constructor.
00041     PlotAnnotation() { }
00042     
00043     // Destructor.
00044     virtual ~PlotAnnotation() { }
00045     
00046     
00047     // Implements PlotItem::drawCount().  Provides default implementation that
00048     // returns 1.
00049     virtual unsigned int drawCount() const { return 1; }
00050     
00051     // ABSTRACT METHODS //
00052     
00053     // Returns the text of the annotation.
00054     virtual String text() const = 0;
00055     
00056     // Sets the text of the annotation.
00057     virtual void setText(const String& newText) = 0;
00058     
00059     // Returns a copy of the font used in the annotation.
00060     virtual PlotFontPtr font() const = 0;
00061     
00062     // Sets the annotation font to the given.
00063     virtual void setFont(const PlotFont& font) = 0;
00064     
00065     // Returns orientation in counterclockwise degrees (between 0 and 360).
00066     virtual int orientation() const = 0;
00067     
00068     // Sets the orientation in counterclockwise degrees (between 0 and 360).
00069     virtual void setOrientation(int orientation) = 0;
00070     
00071     // Returns the coordinate where the annotation is located on the canvas it
00072     // is attached to.
00073     virtual PlotCoordinate coordinate() const = 0;
00074     
00075     // Sets the location of the annotation to the given.
00076     virtual void setCoordinate(const PlotCoordinate& coord) = 0;
00077     
00078     // Returns true if an outline is shown around the annotation, false
00079     // otherwise.
00080     virtual bool outlineShown() const = 0;
00081     
00082     // Sets whether an outline is shown around the annotation.
00083     virtual void setOutlineShown(bool show = true) = 0;
00084     
00085     // Returns a copy of the line used to draw the outline for this annotation.
00086     virtual PlotLinePtr outline() const = 0;
00087     
00088     // Sets the outline to the given line.
00089     virtual void setOutline(const PlotLine& line) = 0;
00090     
00091     // Returns a copy of the area fill used for the annotation's background.
00092     virtual PlotAreaFillPtr background() const = 0;
00093     
00094     // Sets the annotation's background to the given.
00095     virtual void setBackground(const PlotAreaFill& area) = 0;
00096     
00097     
00098     // IMPLEMENTED METHODS //
00099     
00100     // Convenience methods for setting font.
00101     // <group>
00102     virtual void setFont(const PlotFontPtr font) {
00103         if(!font.null()) setFont(*font); }
00104     virtual void setFontColor(const String& color) {
00105         PlotFontPtr f = font();
00106         f->setColor(color);
00107         setFont(*f);
00108     }
00109     // </group>
00110     
00111     // Convenience methods for setting the outline.
00112     // <group>
00113     virtual void setOutline(const PlotLinePtr line) {
00114         if(!line.null()) setOutline(*line);
00115         else             setOutlineShown(false);
00116     }
00117     virtual void setOutline(const String& color,
00118             PlotLine::Style style = PlotLine::SOLID, double width = 1.0) {
00119         PlotLinePtr line = outline();
00120         line->setColor(color);
00121         line->setStyle(style);
00122         line->setWidth(width);
00123         setOutline(*line);
00124     }
00125     // </group>
00126     
00127     // Convenience methods for setting the background.
00128     // <group>
00129     virtual void setBackground(const PlotAreaFillPtr area) {
00130         if(!area.null()) setBackground(*area); }
00131     virtual void setBackground(const String& color,
00132             PlotAreaFill::Pattern pattern = PlotAreaFill::FILL) {
00133         PlotAreaFillPtr bg = background();
00134         bg->setColor(color);
00135         bg->setPattern(pattern);
00136         setBackground(*bg);
00137     }
00138     // </group>
00139 };
00140 INHERITANCE_POINTER2(PlotAnnotation, PlotAnnotationPtr, PlotItem, PlotItemPtr)
00141 
00142 }
00143 
00144 #endif /*PLOTANNOTATION_H_*/
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1