QGIS API Documentation  master-3f58142
src/core/composer/qgscomposershape.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                          qgscomposershape.h
00003                          ----------------------
00004     begin                : November 2009
00005     copyright            : (C) 2009 by Marco Hugentobler
00006     email                : marco@hugis.net
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef QGSCOMPOSERSHAPE_H
00019 #define QGSCOMPOSERSHAPE_H
00020 
00021 #include "qgscomposeritem.h"
00022 #include <QBrush>
00023 #include <QPen>
00024 
00026 class CORE_EXPORT QgsComposerShape: public QgsComposerItem
00027 {
00028     Q_OBJECT
00029   public:
00030 
00031     enum Shape
00032     {
00033       Ellipse,
00034       Rectangle,
00035       Triangle
00036     };
00037 
00038     QgsComposerShape( QgsComposition* composition );
00039     QgsComposerShape( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition );
00040     ~QgsComposerShape();
00041 
00043     virtual int type() const { return ComposerShape; }
00044 
00046     void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
00047 
00052     bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
00053 
00058     bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
00059 
00060     //setters and getters
00061     QgsComposerShape::Shape shapeType() const {return mShape;}
00062     void setShapeType( QgsComposerShape::Shape s ) {mShape = s;}
00063 
00066     void setSceneRect( const QRectF& rectangle );
00067 
00068   public slots:
00070     virtual void setRotation( double r );
00071 
00072 
00073   protected:
00074     /* reimplement drawFrame, since it's not a rect, but a custom shape */
00075     virtual void drawFrame( QPainter* p );
00076     /* reimplement drawBackground, since it's not a rect, but a custom shape */
00077     virtual void drawBackground( QPainter* p );
00078 
00079 
00080   private:
00082     Shape mShape;
00083 
00084     /* draws the custom shape */
00085     void drawShape( QPainter* p );
00086 
00087 
00089     QPointF pointOnLineWithDistance( const QPointF& startPoint, const QPointF& directionPoint, double distance ) const;
00090 };
00091 
00092 #endif // QGSCOMPOSERSHAPEITEM_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines