Avogadro
1.1.0
|
00001 /********************************************************************** 00002 PlotObject -- Part of the Avogadro 2D plotting interface 00003 00004 Copyright (C) 2003 Jason Harris <[email protected]> (KDE) 00005 Copyright (C) 2008 David Lonie <[email protected]> (Avogadro) 00006 00007 This file is part of the Avogadro molecular editor project. 00008 For more information, see <http://avogadro.openmolecules.net/> 00009 00010 This file is based on KPlotWidget from the KDE library. For more 00011 information see <http://www.kde.org/> 00012 00013 Avogadro is free software; you can redistribute it and/or modify 00014 it under the terms of the GNU General Public License as published by 00015 the Free Software Foundation; either version 2 of the License, or 00016 (at your option) any later version. 00017 00018 Avogadro is distributed in the hope that it will be useful, 00019 but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 GNU General Public License for more details. 00022 00023 You should have received a copy of the GNU General Public License 00024 along with this program; if not, write to the Free Software 00025 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00026 02110-1301, USA. 00027 **********************************************************************/ 00028 00029 #ifndef PLOTOBJECT_H 00030 #define PLOTOBJECT_H 00031 00032 #include <QtCore/QString> 00033 #include <QtGui/QColor> 00034 00035 #include <avogadro/global.h> 00036 00037 class QBrush; 00038 class QPainter; 00039 class QPen; 00040 class QPointF; 00041 class QRect; 00042 class QRectF; 00043 00044 namespace Avogadro { 00045 00046 class PlotWidget; 00047 class PlotPoint; 00048 00066 class A_EXPORT PlotObject{ 00067 public: 00077 enum PlotType 00078 { 00079 UnknownType = 0, 00080 Points = 1, 00081 Lines = 2, 00082 Bars = 4 00083 }; 00084 Q_DECLARE_FLAGS( PlotTypes, PlotType ) 00085 00086 00089 enum PointStyle 00090 { 00091 NoPoints = 0, 00092 Circle = 1, 00093 Letter = 2, 00094 Triangle = 3, 00095 Square = 4, 00096 Pentagon = 5, 00097 Hexagon = 6, 00098 Asterisk = 7, 00099 Star = 8, 00100 UnknownPoint 00101 }; 00102 00112 explicit PlotObject( const QColor &color = Qt::white, PlotType otype = Points, double size = 2, PointStyle ps = Circle ); 00113 00117 ~PlotObject(); 00118 00122 PlotTypes plotTypes() const; 00123 00128 void setShowPoints( bool b ); 00129 00134 void setShowLines( bool b ); 00135 00140 void setShowBars( bool b ); 00141 00145 double size() const; 00146 00151 void setSize( double s ); 00152 00156 PointStyle pointStyle() const; 00157 00162 void setPointStyle( PointStyle p ); 00163 00169 const QPen& pen() const; 00170 00175 void setPen( const QPen &p ); 00176 00180 const QPen& linePen() const; 00181 00186 void setLinePen( const QPen &p ); 00187 00191 const QPen& barPen() const; 00192 00197 void setBarPen( const QPen &p ); 00198 00202 const QPen& labelPen() const; 00203 00208 void setLabelPen( const QPen &p ); 00209 00213 const QBrush brush() const; 00214 00219 void setBrush( const QBrush &b ); 00220 00224 const QBrush barBrush() const; 00225 00230 void setBarBrush( const QBrush &b ); 00231 00235 QList< PlotPoint* > points() const; 00236 00246 PlotPoint* addPoint( const QPointF &p, const QString &label = QString(), double barWidth = 0.0 ); 00247 00254 PlotPoint* addPoint( PlotPoint *p ); 00255 00267 PlotPoint* addPoint( double x, double y, const QString &label = QString(), double barWidth = 0.0 ); 00268 00273 void removePoint( int index ); 00274 00279 PlotPoint* at( int index ); 00280 00284 void clearPoints(); 00285 00292 void draw( QPainter *p, PlotWidget *pw ); 00293 00301 void drawImage( QPainter *painter, QRect *pixRect, QRectF *dataRect); 00302 00303 private: 00304 class Private; 00305 Private * const d; 00306 00307 Q_DISABLE_COPY( PlotObject ) 00308 }; 00309 Q_DECLARE_OPERATORS_FOR_FLAGS( PlotObject::PlotTypes ) 00310 00311 } 00312 #endif