LCOV - code coverage report
Current view: top level - graphics/GenericPlotter - PlotAnnotation.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 1 0.0 %
Date: 2024-10-04 18:58:15 Functions: 0 5 0.0 %

          Line data    Source code
       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: casa-feedback@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             : 
      30             : #include <graphics/GenericPlotter/PlotItem.h>
      31             : 
      32             : #include <casacore/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.
      41             :     PlotAnnotation() { }
      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,
     132             :             PlotAreaFill::Pattern pattern = PlotAreaFill::FILL) {
     133             :         PlotAreaFillPtr bg = background();
     134             :         bg->setColor(color);
     135             :         bg->setPattern(pattern);
     136             :         setBackground(*bg);
     137             :     }
     138             :     // </group>
     139             : };
     140           0 : INHERITANCE_POINTER2(PlotAnnotation, PlotAnnotationPtr, PlotItem, PlotItemPtr)
     141             : 
     142             : }
     143             : 
     144             : #endif /*PLOTANNOTATION_H_*/

Generated by: LCOV version 1.16