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

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1