QPShape.h

Go to the documentation of this file.
00001 //# QPShape.h: Qwt implementation of generic PlotShape classes.
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 QPSHAPE_H_
00028 #define QPSHAPE_H_
00029 
00030 #ifdef AIPS_HAS_QWT
00031 
00032 #include <graphics/GenericPlotter/PlotShape.h>
00033 #include <casaqt/QwtPlotter/QPOptions.h>
00034 #include <casaqt/QwtPlotter/QPPlotItem.qo.h>
00035 
00036 #include <qwt_plot_item.h>
00037 #include <qwt_plot_marker.h>
00038 
00039 namespace casa {
00040 
00041 // QPShape is the abstract superclass for any qwt-based shapes.  It handles the
00042 // common functionality like changing the QPen and QBrush.
00043 class QPShape : public QPPlotItem, public virtual PlotShape {
00044 public:
00045     // Static //
00046     
00047     // Makes a copy of the given generic PlotShape into its Qwt-specific
00048     // subclass and returns it, or NULL for an error (shouldn't happen).
00049     static QPShape* clone(const PlotShape& copy);
00050     
00051     
00052     // Non-Static //
00053     
00054     // Constructor.
00055     QPShape();
00056     
00057     // Copy constructor which takes generic PlotShape.  Will be called by copy
00058     // constructors of children.
00059     QPShape(const PlotShape& copy);
00060     
00061     // Destructor.
00062     virtual ~QPShape();
00063     
00064     
00065     // Include overloaded methods.
00066     using PlotShape::setLine;
00067     using PlotShape::setAreaFill;
00068   
00069     
00070     // QPPlotItem Methods //
00071     
00072 #if QWT_VERSION < 0x060000 
00073     // Overrides QwtPlotItem::legendItem().
00074     virtual QWidget* legendItem() const;
00075 #endif    
00076     
00077     // PlotShape Methods //
00078     
00079     // Implements PlotShape::lineShown().
00080     bool lineShown() const;
00081     
00082     // Implements PlotShape::setLineShown().
00083     void setLineShown(bool line = true);
00084     
00085     // Implements PlotShape::line().
00086     PlotLinePtr line() const;
00087     
00088     // Implements PlotShape::setLine().
00089     void setLine(const PlotLine& line);
00090     
00091     // Implements PlotShape::areaFilled().
00092     bool areaFilled() const;
00093     
00094     // Implements PlotShape::setAreaFilled().
00095     void setAreaFilled(bool area = true);
00096     
00097     // Implements PlotShape::areaFill().
00098     PlotAreaFillPtr areaFill() const;
00099     
00100     // Implements PlotShape::setAreaFill().
00101     void setAreaFill(const PlotAreaFill& fill);
00102 
00103 protected:
00104     QPLine m_line;     // Line
00105     QPAreaFill m_area; // Area fill
00106     
00107     
00108     // Used for creating legend items.
00109     virtual QwtSymbol::Style legendStyle() const = 0;
00110 };
00111 
00112 
00113 // Implementation of PlotShapeRectangle for Qwt plotter.
00114 class QPRectangle : public QPShape, public PlotShapeRectangle {
00115 public:
00116     // Static //
00117     
00118     // Convenient access to class name (QPRectangle).
00119     static const String CLASS_NAME;
00120     
00121     
00122     // Non-Static //
00123     
00124     // Constructor which takes the upper-left and lower-right coordinates.
00125     QPRectangle(const PlotCoordinate& upperLeft,
00126                 const PlotCoordinate& lowerRight);
00127     
00128     // Constructor which takes a QwtDoubleRect in world coordinates.
00129     QPRectangle(const QwtDoubleRect& r);
00130     
00131     // Copy constructor for generic PlotShapeRectangle.
00132     QPRectangle(const PlotShapeRectangle& copy);
00133     
00134     // Destructor.
00135     ~QPRectangle();
00136     
00137     
00138     // QPShape Methods //
00139     
00140     // Implements PlotItem::isValid().
00141     bool isValid() const;
00142     
00143     // Overrides QwtPlotItem::boundingRect().
00144     QwtDoubleRect boundingRect() const;
00145     
00146     
00147     // PlotShapeRectangle Methods //
00148     
00149     // Implements PlotShape::coordinates().
00150     vector<PlotCoordinate> coordinates() const;
00151     
00152     // Implements PlotShape::setCoordinates().
00153     void setCoordinates(const vector<PlotCoordinate>& coords);
00154     
00155     // Implements PlotShapeRectangle::setRectCoordinates().
00156     void setRectCoordinates(const PlotCoordinate& upperLeft,
00157                             const PlotCoordinate& lowerRight);
00158     
00159 protected:
00160     // Implements QPPlotItem::className().
00161     const String& className() const { return CLASS_NAME; }
00162     
00163     // Implements QPLayerItem::draw_().  Ignores draw index and count.
00164 #if QWT_VERSION >= 0x060000
00165     void draw_(QPainter* painter, const QwtScaleMap& xMap,
00166               const QwtScaleMap& yMap, const QRectF& canvasRect,
00167               unsigned int drawIndex, unsigned int drawCount) const;
00168 #else
00169     void draw_(QPainter* painter, const QwtScaleMap& xMap,
00170               const QwtScaleMap& yMap, const QRect& canvasRect,
00171               unsigned int drawIndex, unsigned int drawCount) const;
00172 #endif
00173 
00174     // Implements QPShape::legendStyle().
00175     QwtSymbol::Style legendStyle() const { return QwtSymbol::Rect; }
00176     
00177     
00178 private:
00179     PlotCoordinate m_upperLeft;  // upper left coordinate
00180     PlotCoordinate m_lowerRight; // lower right coordinate
00181 };
00182 
00183 
00184 // Implementation of PlotShapeEllipse for Qwt plotter.
00185 class QPEllipse : public QPShape, public PlotShapeEllipse {
00186 public:
00187     // Static //
00188     
00189     // Convenient access to class name (QPEllipse).
00190     static const String CLASS_NAME;
00191     
00192     
00193     // Non-Static //
00194     
00195     // Constructor which takes the center and radii as PlotCoordinates.
00196     QPEllipse(const PlotCoordinate& center, const PlotCoordinate& radii);
00197     
00198     // Constructor which uses the given QwtDoubleRect in world coordinates.
00199     QPEllipse(const QwtDoubleRect& r);
00200     
00201     // Copy constructor for generic PlotShapeEllipse.
00202     QPEllipse(const PlotShapeEllipse& copy);
00203     
00204     // Destructor.
00205     ~QPEllipse();
00206     
00207     
00208     // QPShape Methods //
00209     
00210     // Implements PlotItem::isValid().
00211     bool isValid() const;
00212     
00213     // Overrides QwtPlotItem::boundingRect().
00214     QwtDoubleRect boundingRect() const;
00215     
00216     
00217     // PlotShapeEllipse Methods //
00218     
00219     // Implements PlotShape::coordinates().
00220     vector<PlotCoordinate> coordinates() const;
00221     
00222     // Implements PlotShape::setCoordinates().
00223     void setCoordinates(const vector<PlotCoordinate>& coords);
00224     
00225     // Implements PlotShapeEllipse::setEllipseCoordinates().
00226     void setEllipseCoordinates(const PlotCoordinate& center,
00227                                const PlotCoordinate& radii);
00228     
00229     // Implements PlotShapeEllipse::radii().
00230     PlotCoordinate radii() const;
00231     
00232     // Implements PlotShapeEllipse::setRadii().
00233     void setRadii(const PlotCoordinate& radii);
00234     
00235     // Implements PlotShapeEllipse::center().
00236     PlotCoordinate center() const;
00237     
00238     // Implements PlotShapeEllipse::setCenter().
00239     void setCenter(const PlotCoordinate& center);
00240     
00241 protected:
00242     // Implements QPPlotItem::className().
00243     const String& className() const { return CLASS_NAME; }
00244     
00245     // Implements QPLayerItem::draw_().  Ignores draw index and count.
00246 #if QWT_VERSION >= 0x060000
00247     void draw_(QPainter* painter, const QwtScaleMap& xMap,
00248               const QwtScaleMap& yMap, const QRectF& canvasRect,
00249               unsigned int drawIndex, unsigned int drawCount) const;
00250 #else
00251     void draw_(QPainter* painter, const QwtScaleMap& xMap,
00252               const QwtScaleMap& yMap, const QRect& canvasRect,
00253               unsigned int drawIndex, unsigned int drawCount) const;
00254 #endif
00255  
00256     // Implements QPShape::legendStyle().
00257     QwtSymbol::Style legendStyle() const { return QwtSymbol::Ellipse; }
00258     
00259 private:
00260     PlotCoordinate m_center; // Center
00261     PlotCoordinate m_radii;  // Radii
00262 };
00263 
00264 
00265 // Implementation of PlotShapePolygon for Qwt plotter.
00266 class QPPolygon : public QPShape, public PlotShapePolygon {
00267 public:
00268     // Static //
00269     
00270     // Convenient access to class name (QPPolygon).
00271     static const String CLASS_NAME;
00272     
00273     
00274     // Non-Static //
00275     
00276     // Constructor which takes list of coordinates.
00277     QPPolygon(const vector<PlotCoordinate>& coords);
00278     
00279     // Copy constructor for generic PlotShapePolygon.
00280     QPPolygon(const PlotShapePolygon& copy);
00281     
00282     // Destructor.
00283     ~QPPolygon();
00284     
00285     
00286     // QPShape Methods //
00287     
00288     // Implements PlotItem::isValid().
00289     bool isValid() const;
00290     
00291     // Overrides QwtPlotItem::boundingRect().
00292     QwtDoubleRect boundingRect() const;
00293     
00294     
00295     // PlotShapePolygon Methods //
00296     
00297     // Implements PlotShape::coordinates().
00298     vector<PlotCoordinate> coordinates() const;
00299     
00300     // Implements PlotShape::setCoordinates().
00301     void setCoordinates(const vector<PlotCoordinate>& coords);
00302     
00303 protected:
00304     // Implements QPPlotItem::className().
00305     const String& className() const { return CLASS_NAME; }
00306     
00307     // Implements QPLayerItem::draw_().
00308 #if QWT_VERSION >= 0x060000
00309     void draw_(QPainter* painter, const QwtScaleMap& xMap,
00310               const QwtScaleMap& yMap, const QRectF& canvasRect,
00311               unsigned int drawIndex, unsigned int drawCount) const;
00312 #else
00313     void draw_(QPainter* painter, const QwtScaleMap& xMap,
00314               const QwtScaleMap& yMap, const QRect& canvasRect,
00315               unsigned int drawIndex, unsigned int drawCount) const;
00316 #endif
00317     
00318     // Implements QPShape::legendStyle().
00319     QwtSymbol::Style legendStyle() const { return QwtSymbol::Hexagon; }
00320     
00321 private:
00322     vector<PlotCoordinate> m_coords; // Coordinates
00323 };
00324 
00325 
00326 // Implementation of PlotShapeLine for Qwt plotter.
00327 class QPLineShape : public QPShape, public PlotShapeLine {
00328 public:
00329     // Static //
00330     
00331     // Convenient access to class name (QPLineShape).
00332     static const String CLASS_NAME;
00333     
00334     
00335     // Non-Static //
00336     
00337     // Constructor which takes location in world coordinates and axis.
00338     QPLineShape(double location, PlotAxis axis);
00339     
00340     // Copy constructor for generic PlotShapeLine.
00341     QPLineShape(const PlotShapeLine& copy);
00342     
00343     // Destructor.
00344     ~QPLineShape();
00345     
00346     
00347     // QPShape Methods //
00348     
00349     // Implements PlotItem::isValid().
00350     bool isValid() const;
00351  
00352     // Overrides QwtPlotItem::boundingRect().
00353     QwtDoubleRect boundingRect() const;
00354     
00355     
00356     // PlotShapeLine Methods //
00357     
00358     // Implements PlotShape::coordinates().
00359     vector<PlotCoordinate> coordinates() const;
00360     
00361     // Implements PlotShape::setCoordinates().
00362     void setCoordinates(const vector<PlotCoordinate>& coords);
00363     
00364     // Implements PlotShapeLine::setLineCoordinates().
00365     void setLineCoordinates(double location, PlotAxis axis);
00366     
00367     // Implements PlotShapeLine::location().
00368     double location() const;
00369     
00370     // Implements PlotShapeLine::axis().
00371     PlotAxis axis() const;
00372     
00373 protected:
00374     // Implements QPPlotItem::className().
00375     const String& className() const { return CLASS_NAME; }
00376     
00377     // Implements QPLayerItem::draw_().  Ignores draw index and count.
00378 #if QWT_VERSION >= 0x060000
00379     void draw_(QPainter* painter, const QwtScaleMap& xMap,
00380               const QwtScaleMap& yMap, const QRectF& canvasRect,
00381               unsigned int drawIndex, unsigned int drawCount) const;
00382 #else
00383     void draw_(QPainter* painter, const QwtScaleMap& xMap,
00384               const QwtScaleMap& yMap, const QRect& canvasRect,
00385               unsigned int drawIndex, unsigned int drawCount) const;
00386 #endif
00387  
00388     // Implements QPShape::legendStyle().
00389     QwtSymbol::Style legendStyle() const { return QwtSymbol::HLine; }
00390     
00391 private:
00392     QwtPlotMarker m_marker; // Marker
00393     PlotAxis m_axis;        // Axis
00394 };
00395 
00396 
00397 // Implementation of PlotShapeArrow for Qwt plotter.
00398 class QPArrow : public QPShape, public PlotShapeArrow {
00399 public:
00400     // Static //
00401     
00402     // Convenient access to class name (QPArrow).
00403     static const String CLASS_NAME;
00404     
00405     // Returns the two points necessary to make an arrow shape from the given
00406     // point to the given point, with the given length.  The two arrow points
00407     // are at a 45 degree angle from the "from" point and the line between the
00408     // point and the "from" point is equal to "length".
00409     // <group>
00410     static std::pair<QPointF, QPointF> arrowPoints(QPointF from, QPointF to,
00411                                               double length);    
00412     static void arrowPoints(double x1, double y1, double x2, double y2,
00413                             double length, double& resX1, double& resY1,
00414                             double& resX2, double& resY2);
00415     // </group>
00416     
00417     
00418     // Non-Static //
00419     
00420     // Constructor which takes the two coordinates.
00421     QPArrow(const PlotCoordinate& from, const PlotCoordinate& to);
00422     
00423     // Copy constructor for generic PlotshapeArrow.
00424     QPArrow(const PlotShapeArrow& copy);
00425     
00426     // Destructor.
00427     ~QPArrow();
00428     
00429     
00430     // QPShape Methods //
00431     
00432     // Implements PlotItem::isValid().
00433     bool isValid() const;
00434     
00435     // Overrides QwtPlotItem::boundingRect().
00436     QwtDoubleRect boundingRect() const;
00437     
00438     
00439     // PlotShapeArrow Methods //
00440     
00441     // Implements PlotShape::coordinates().
00442     vector<PlotCoordinate> coordinates() const;
00443     
00444     // Implements PlotShape::setCoordinates().
00445     void setCoordinates(const vector<PlotCoordinate>& coords);    
00446     
00447     // Implements PlotShapeArrow::setArrowCoordinates().
00448     void setArrowCoordinates(const PlotCoordinate& from,
00449                              const PlotCoordinate& to);
00450     
00451     // Implements PlotShapeArrow::arrowStyleFrom().
00452     Style arrowStyleFrom() const;
00453     
00454     // Implements PlotShapeArrow::arrowStyleTo().
00455     Style arrowStyleTo() const;
00456     
00457     // Implements PlotShapeArrow::setArrowStyleFrom().
00458     void setArrowStyleFrom(Style style) { setArrowStyles(style, m_toStyle); }
00459     
00460     // Implements PlotShapeArrow::setArrowStyleTo().
00461     void setArrowStyleTo(Style style) { setArrowStyles(m_fromStyle, style); }
00462     
00463     // Overrides PlotShapeArrow::setArrowStyles().
00464     void setArrowStyles(Style from, Style to);
00465     
00466     // Implements PlotShapeArrow::arrowSize().
00467     double arrowSize() const;
00468     
00469     // Implements PlotShapeArrow::setArrowSize().
00470     void setArrowSize(double size);
00471     
00472 protected:
00473     // Implements QPPlotItem::className().
00474     const String& className() const { return CLASS_NAME; }
00475     
00476     // Implements QPLayerItem::draw_().  Ignores draw index and count.
00477 #if QWT_VERSION >= 0x060000
00478     void draw_(QPainter* painter, const QwtScaleMap& xMap,
00479               const QwtScaleMap& yMap, const QRectF& canvasRect,
00480               unsigned int drawIndex, unsigned int drawCount) const;
00481 #else
00482     void draw_(QPainter* painter, const QwtScaleMap& xMap,
00483               const QwtScaleMap& yMap, const QRect& canvasRect,
00484               unsigned int drawIndex, unsigned int drawCount) const;
00485 #endif
00486     
00487     // Implements QPShape::legendStyle().
00488     QwtSymbol::Style legendStyle() const { return QwtSymbol::HLine; }
00489     
00490 private:
00491     PlotCoordinate m_from;        // From point
00492     PlotCoordinate m_to;          // To point
00493     Style m_fromStyle, m_toStyle; // Arrow styles
00494     double m_size;                // Arrow size
00495     
00496     
00497     // Static //
00498     
00499     // Helper for arrowPoints.  Calculates the points under the assumption that
00500     // the arrow is pointing in an assumed direction, and then lets arrowPoints
00501     // rotate/transform the results as needed.
00502     static std::pair<QPointF, QPointF> arrowPointsHelper(QPointF p1, QPointF p2,
00503                                                     double length);
00504 };
00505 
00506 
00507 // Implementation of PlotShapePath for Qwt plotter.
00508 class QPPath : public QPShape, public PlotShapePath {
00509 public:
00510     // Static //
00511     
00512     // Convenient access to class name (QPPath).
00513     static const String CLASS_NAME;
00514     
00515     
00516     // Non-Static //
00517     
00518     // Constructor which takes the points.
00519     QPPath(const vector<PlotCoordinate>& points);
00520     
00521     // Copy constructor for generic PlotShapePath.
00522     QPPath(const PlotShapePath& copy);
00523     
00524     // Destructor.
00525     ~QPPath();
00526     
00527     
00528     // QPShape Methods //
00529     
00530     // Implements PlotItem::isValid().
00531     bool isValid() const;
00532     
00533     // Overrides QwtPlotItem::boundingRect().
00534     QwtDoubleRect boundingRect() const;
00535     
00536     
00537     // PlotShapePath Methods //
00538     
00539     // Implements PlotShape::coordinates().
00540     vector<PlotCoordinate> coordinates() const;
00541     
00542     // Implements PlotShape::setCoordinates().
00543     void setCoordinates(const vector<PlotCoordinate>& coords);
00544     
00545 protected:
00546     // Implements QPPlotItem::className().
00547     const String& className() const { return CLASS_NAME; }
00548     
00549     // Implements QPLayerItem::draw_().
00550 #if QWT_VERSION >= 0x060000
00551     void draw_(QPainter* painter, const QwtScaleMap& xMap,
00552               const QwtScaleMap& yMap, const QRectF& canvasRect,
00553               unsigned int drawIndex, unsigned int drawCount) const;
00554 #else
00555     void draw_(QPainter* painter, const QwtScaleMap& xMap,
00556               const QwtScaleMap& yMap, const QRect& canvasRect,
00557               unsigned int drawIndex, unsigned int drawCount) const;
00558 #endif
00559     
00560     // Implements QPShape::legendStyle().
00561     QwtSymbol::Style legendStyle() const { return QwtSymbol::HLine; }
00562     
00563 private:
00564     vector<PlotCoordinate> m_coords; // Coordinates
00565 };
00566 
00567 
00568 // Implementation of PlotShapeArc for Qwt plotter.
00569 class QPArc : public QPShape, public PlotShapeArc {
00570 public:
00571     // Static //
00572     
00573     // Convenient access to class name (QPArc).
00574     static const String CLASS_NAME;
00575     
00576     
00577     // Non-Static //
00578     
00579     // Constructor which takes the start coordinate, width, height, start
00580     // angle, and span angle.
00581     QPArc(const PlotCoordinate& start, const PlotCoordinate& widthHeight,
00582           int startAngle, int spanAngle);
00583     
00584     // Copy constructor for generic PlotShapeArc.
00585     QPArc(const PlotShapeArc& copy);
00586     
00587     // Destructor.
00588     ~QPArc();
00589     
00590     
00591     // Include overloaded methods.
00592     using PlotShapeArc::setWidthHeight;
00593     
00594     
00595     // QPShape Methods //
00596     
00597     // Implements PlotItem::isValid().
00598     bool isValid() const;
00599     
00600     // Overrides QwtPlotItem::boundingRect().
00601     QwtDoubleRect boundingRect() const;
00602     
00603     
00604     // PlotShapeArc Methods //
00605     
00606     // Implements PlotShape::coordinates().
00607     vector<PlotCoordinate> coordinates() const;
00608     
00609     // Implements PlotShape::coordinates().
00610     void setCoordinates(const vector<PlotCoordinate>& coords);
00611     
00612     // Implements PlotShapeArc::startCoordinate().
00613     PlotCoordinate startCoordinate() const;
00614     
00615     // Implements PlotShapeArc::setStartCoordinate().
00616     void setStartCoordinate(const PlotCoordinate& coord);
00617     
00618     // Implements PlotShapeArc::widthHeight().
00619     PlotCoordinate widthHeight() const;
00620     
00621     // Implements PlotShapeArc::setWidthHeight().
00622     void setWidthHeight(const PlotCoordinate& widthHeight);
00623     
00624     // Implements PlotShapeArc::startAngle().
00625     int startAngle() const;
00626     
00627     // Implements PlotShapeArc::setStartAngle().
00628     void setStartAngle(int startAngle);
00629     
00630     // Implements PlotShapeArc::spanAngle().
00631     int spanAngle() const;
00632     
00633     // Implements PlotShapeArc::setSpanAngle().
00634     void setSpanAngle(int spanAngle);
00635     
00636     // Implements PlotShapeArc::orientation().
00637     int orientation() const;
00638     
00639     // Implements PlotShapeArc::setOrientation().
00640     void setOrientation(int o);
00641     
00642 protected:
00643     // Implements QPPlotItem::className().
00644     const String& className() const { return CLASS_NAME; }
00645     
00646     // Implements QPLayerItem::draw_().  Ignores draw index and count.
00647 #if QWT_VERSION >= 0x060000
00648     void draw_(QPainter* painter, const QwtScaleMap& xMap,
00649               const QwtScaleMap& yMap, const QRectF& canvasRect,
00650               unsigned int drawIndex, unsigned int drawCount) const;
00651 #else
00652     void draw_(QPainter* painter, const QwtScaleMap& xMap,
00653               const QwtScaleMap& yMap, const QRect& canvasRect,
00654               unsigned int drawIndex, unsigned int drawCount) const;
00655 #endif
00656     
00657     // Implements QPShape::legendStyle().
00658     QwtSymbol::Style legendStyle() const { return QwtSymbol::HLine; }
00659     
00660 private:
00661     PlotCoordinate m_start; // Start coordinate
00662     PlotCoordinate m_size;  // Width and height
00663     int m_startAngle;       // Start angle
00664     int m_spanAngle;        // Span angle
00665     int m_orient;           // Orientation
00666 };
00667 
00668 
00669 // Implementation of PlotPoint for Qwt plotter.
00670 class QPPoint : public QPPlotItem, public PlotPoint {
00671 public:
00672     // Static //
00673     
00674     // Convenient access to class name (QPPoint).
00675     static const String CLASS_NAME;
00676     
00677     
00678     // Non-Static //
00679     
00680     // Constructors which take the location and symbol.
00681     // <group>
00682     QPPoint(const PlotCoordinate& coordinate, const PlotSymbol& symbol);
00683     QPPoint(const PlotCoordinate& coordinate, const PlotSymbolPtr symbol);    
00684     QPPoint(const PlotCoordinate& coordinate,
00685             PlotSymbol::Symbol symbol = PlotSymbol::DIAMOND);
00686     // </group>
00687     
00688     // Copy constructor for generic PlotPoint.
00689     QPPoint(const PlotPoint& copy);
00690     
00691     // Destructor.
00692     ~QPPoint();
00693     
00694     
00695     // Include overloaded methods.
00696     using PlotPoint::setSymbol;
00697     
00698     
00699     // QPPlotItem Methods //
00700     
00701     // Implements PlotItem::isValid().
00702     bool isValid() const { return true; }
00703 
00704     // Overrides QwtPlotItem::boundingRect();
00705     QwtDoubleRect boundingRect() const;
00706 
00707 #if QWT_VERSION < 0x060000 
00708     // Overrides QwtPlotItem::legendItem().
00709     QWidget* legendItem() const;
00710 #endif 
00711     
00712     // PlotPoint Methods //
00713     
00714     // Implements PlotPoint::coordinate().
00715     PlotCoordinate coordinate() const;
00716     
00717     // Implements PlotPoint::setCoordinate().
00718     void setCoordinate(const PlotCoordinate& coordinate);
00719     
00720     // Implements PlotPoint::symbol().
00721     PlotSymbolPtr symbol() const;
00722     
00723     // Implements PlotPoint::setSymbol().
00724     void setSymbol(const PlotSymbol& symbol);
00725     
00726 protected:
00727     // Implements QPPlotItem::className().
00728     const String& className() const { return CLASS_NAME; }
00729     
00730     // Implements QPLayerItem::draw_().  Ignores draw index and count.
00731 #if QWT_VERSION >= 0x060000
00732     void draw_(QPainter* painter, const QwtScaleMap& xMap,
00733               const QwtScaleMap& yMap, const QRectF& canvasRect,
00734               unsigned int drawIndex, unsigned int drawCount) const;
00735 #else
00736     void draw_(QPainter* painter, const QwtScaleMap& xMap,
00737               const QwtScaleMap& yMap, const QRect& canvasRect,
00738               unsigned int drawIndex, unsigned int drawCount) const;
00739 #endif
00740     
00741 private:
00742     QPSymbol m_symbol;      // symbol
00743     PlotCoordinate m_coord; // location
00744 };
00745 
00746 }
00747 
00748 #else
00749 
00750 #include <QPointF>
00751 #include <utility>
00752 
00753 using namespace std;
00754 
00755 namespace casa {
00756 
00757 // Used by the viewer's region shapes, so have it outside the ifdefs in case
00758 // the flag isn't on.
00759 class QPArrow {
00760 public:
00761     static std::pair<QPointF, QPointF> arrowPoints(QPointF from, QPointF to,
00762                                               double length);
00763     
00764     static void arrowPoints(double x1, double y1, double x2, double y2,
00765                             double length, double& resX1, double& resY1,
00766                             double& resX2, double& resY2);
00767     
00768 private:
00769     static std::pair<QPointF, QPointF> arrowPointsHelper(QPointF p1, QPointF p2,
00770                                                     double length);
00771 };
00772 
00773 }
00774 
00775 #endif
00776 
00777 #endif /*QPSHAPE_H_*/
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1