Quantum GIS API Documentation  1.8
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 
00024 class CORE_EXPORT QgsComposerShape: public QgsComposerItem
00025 {
00026     Q_OBJECT
00027   public:
00028 
00029     enum Shape
00030     {
00031       Ellipse,
00032       Rectangle,
00033       Triangle
00034     };
00035 
00036     QgsComposerShape( QgsComposition* composition );
00037     QgsComposerShape( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition );
00038     ~QgsComposerShape();
00039 
00041     virtual int type() const { return ComposerShape; }
00042 
00044     void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
00045 
00050     bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
00051 
00056     bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
00057 
00058     //setters and getters
00059     void setLineWidth( double width );
00060     double lineWidth() const;
00061     void setOutlineColor( const QColor& color );
00062     QColor outlineColor() const;
00063     void setFillColor( const QColor& color );
00064     QColor fillColor() const;
00065     QgsComposerShape::Shape shapeType() const {return mShape;}
00066     void setShapeType( QgsComposerShape::Shape s ) {mShape = s;}
00067     bool transparentFill() const;
00068     void setTransparentFill( bool transparent );
00069 
00072     void setSceneRect( const QRectF& rectangle );
00073 
00074   public slots:
00076     virtual void setRotation( double r );
00077 
00078 
00079   private:
00081     Shape mShape;
00083     QPen mPen;
00085     QBrush mBrush;
00086     double mShapeWidth;
00087     double mShapeHeight;
00088 
00090     void initGraphicsSettings();
00091 
00093     QPointF pointOnLineWithDistance( const QPointF& startPoint, const QPointF& directionPoint, double distance ) const;
00094 };
00095 
00096 #endif // QGSCOMPOSERSHAPEITEM_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines