casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
QPAnnotation.h
Go to the documentation of this file.
00001 //# QPAnnotation.h: Qwt implementation of generic PlotAnnotation class.
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 QPANNOTATION_H_
00028 #define QPANNOTATION_H_
00029 
00030 #ifdef AIPS_HAS_QWT
00031 
00032 #include <graphics/GenericPlotter/PlotAnnotation.h>
00033 #include <casaqt/QwtPlotter/QPPlotItem.qo.h>
00034 
00035 #include <qwt_text.h>
00036 
00037 #include <casa/namespace.h>
00038 
00039 namespace casa {
00040 
00041 //# Forward Declarations
00042 class QPCanvas;
00043 
00044 // Implementation of PlotAnnotation for Qwt plotter.
00045 class QPAnnotation : public QPPlotItem, public PlotAnnotation {
00046 public:
00047     // Static //
00048     
00049     // Convenient access to class name (QPAnnotation).
00050     static const String CLASS_NAME;
00051     
00052     
00053     // Non-Static //
00054     
00055     // Constructor which takes text and location.
00056     QPAnnotation(const String& text, const PlotCoordinate& coord);
00057     
00058     // Constructor which takes text, location, font, and (optional) orientation
00059     // in counterclockwise degrees.
00060     QPAnnotation(const String& text, const PlotCoordinate& coord,
00061                  const PlotFont& font, int orientation = 0);
00062     
00063     // Constructor which copies the given generic PlotAnnotation.
00064     QPAnnotation(const PlotAnnotation& copy);
00065     
00066     // Destructor.
00067     ~QPAnnotation();
00068     
00069     
00070     // Include overloaded methods.
00071     using PlotAnnotation::setFont;
00072     using PlotAnnotation::setOutline;
00073     using PlotAnnotation::setBackground;
00074     
00075     
00076     // PlotItem Methods //
00077     
00078     // Implements PlotItem::isValid().
00079     bool isValid() const { return true; }
00080     
00081     
00082     // QPPlotItem Methods //
00083     
00084     // Overrides QwtPlotItem::boundingRect().
00085     QwtDoubleRect boundingRect() const;
00086     
00087     // Overrides QwtPlotItem::legendItem().
00088     QWidget* legendItem() const;
00089     
00090     
00091     // PlotAnnotation Methods //
00092     
00093     // Implements PlotAnnotation::text().
00094     String text() const;
00095     
00096     // Implements PlotAnnotation::setText().
00097     void setText(const String& newText);
00098     
00099     // Implements PlotAnnotation::font().
00100     PlotFontPtr font() const;
00101     
00102     // Implements PlotAnnotation::setFont().
00103     void setFont(const PlotFont& font);
00104     
00105     // Implements PlotAnnotation::orientation().
00106     int orientation() const;
00107     
00108     // Implements PlotAnnotation::setOrientation().
00109     void setOrientation(int orientation);
00110     
00111     // Implements PlotAnnotation::coordinate().
00112     PlotCoordinate coordinate() const;
00113     
00114     // Implements PlotAnnotation::setCoordinate().
00115     void setCoordinate(const PlotCoordinate& coord);
00116     
00117     // Implements PlotAnnotation::outlineShown().
00118     bool outlineShown() const;
00119     
00120     // Implements PlotAnnotation::setOutlineShown().
00121     void setOutlineShown(bool show = true);
00122     
00123     // Implements PlotAnnotation::outline().
00124     PlotLinePtr outline() const;
00125     
00126     // Implements PlotAnnotation::setOutline().
00127     void setOutline(const PlotLine& line);
00128     
00129     // Implements PlotAnnotation::background().
00130     PlotAreaFillPtr background() const;
00131     
00132     // Implements PlotAnnotation::setBackground().
00133     void setBackground(const PlotAreaFill& area);
00134     
00135     
00136     // QPAnnotation Methods //
00137     
00138     // Provides access to the underlying QwtText object.
00139     // <group>
00140     QwtText& asQwtText();
00141     const QwtText& asQwtText() const;
00142     // </group>
00143     
00144 protected:
00145     // Implements QPPlotItem::className().
00146     const String& className() const { return CLASS_NAME; }
00147     
00148     // Implements QPLayerItem::draw_().  Ignores draw index and count.
00149     void draw_(QPainter* painter, const QwtScaleMap& xMap,
00150               const QwtScaleMap& yMap, const QRect& canvasRect,
00151               unsigned int drawIndex, unsigned int drawCount) const;
00152     
00153 private:
00154     QwtText m_label;        // text, font, outline, and background
00155     PlotCoordinate m_coord; // location
00156     int m_orient;           // orientation
00157 };
00158 
00159 }
00160 
00161 #endif
00162 
00163 #endif /*QPANNOTATION_H_*/