Quantum GIS API Documentation
1.8
|
00001 /*************************************************************************** 00002 qgsannotationitem.h 00003 ------------------------ 00004 begin : February 9, 2010 00005 copyright : (C) 2010 by Marco Hugentobler 00006 email : marco dot hugentobler at hugis dot 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 QGSANNOTATIONITEM_H 00019 #define QGSANNOTATIONITEM_H 00020 00021 #include "qgsmapcanvasitem.h" 00022 00023 class QDomDocument; 00024 class QDomElement; 00025 class QDialog; 00026 class QgsVectorLayer; 00027 class QgsMarkerSymbolV2; 00028 00031 class GUI_EXPORT QgsAnnotationItem: public QgsMapCanvasItem 00032 { 00033 public: 00034 enum MouseMoveAction 00035 { 00036 NoAction, 00037 MoveMapPosition, 00038 MoveFramePosition, 00039 ResizeFrameUp, 00040 ResizeFrameDown, 00041 ResizeFrameLeft, 00042 ResizeFrameRight, 00043 ResizeFrameLeftUp, 00044 ResizeFrameRightUp, 00045 ResizeFrameLeftDown, 00046 ResizeFrameRightDown 00047 }; 00048 00049 QgsAnnotationItem( QgsMapCanvas* mapCanvas ); 00050 virtual ~QgsAnnotationItem(); 00051 00052 void updatePosition(); 00053 00054 QRectF boundingRect() const; 00055 00056 virtual QSizeF minimumFrameSize() const; 00057 00060 QgsAnnotationItem::MouseMoveAction moveActionForPosition( const QPointF& pos ) const; 00062 Qt::CursorShape cursorShapeForAction( MouseMoveAction moveAction ) const; 00063 00064 //setters and getters 00065 void setMapPositionFixed( bool fixed ); 00066 bool mapPositionFixed() const { return mMapPositionFixed; } 00067 00068 virtual void setMapPosition( const QgsPoint& pos ); 00069 QgsPoint mapPosition() const { return mMapPosition; } 00070 00071 void setFrameSize( const QSizeF& size ); 00072 QSizeF frameSize() const { return mFrameSize; } 00073 00074 void setOffsetFromReferencePoint( const QPointF& offset ); 00075 QPointF offsetFromReferencePoint() const { return mOffsetFromReferencePoint; } 00076 00078 void setMarkerSymbol( QgsMarkerSymbolV2* symbol ); 00079 const QgsMarkerSymbolV2* markerSymbol() const {return mMarkerSymbol;} 00080 00081 void setFrameBorderWidth( double w ) { mFrameBorderWidth = w; } 00082 double frameBorderWidth() const { return mFrameBorderWidth; } 00083 00084 void setFrameColor( const QColor& c ) { mFrameColor = c; } 00085 QColor frameColor() const { return mFrameColor; } 00086 00087 void setFrameBackgroundColor( const QColor& c ) { mFrameBackgroundColor = c; } 00088 QColor frameBackgroundColor() const { return mFrameBackgroundColor; } 00089 00090 virtual void writeXML( QDomDocument& doc ) const = 0; 00091 virtual void readXML( const QDomDocument& doc, const QDomElement& itemElem ) = 0; 00092 00093 void _writeXML( QDomDocument& doc, QDomElement& itemElem ) const; 00094 void _readXML( const QDomDocument& doc, const QDomElement& annotationElem ); 00095 00096 protected: 00098 bool mMapPositionFixed; 00100 QgsPoint mMapPosition; 00102 QPointF mOffsetFromReferencePoint; 00103 00105 QSizeF mFrameSize; 00107 QRectF mBoundingRect; 00108 00110 QgsMarkerSymbolV2* mMarkerSymbol; 00112 double mFrameBorderWidth; 00114 QColor mFrameColor; 00115 QColor mFrameBackgroundColor; 00116 00118 int mBalloonSegment; 00120 QPointF mBalloonSegmentPoint1; 00122 QPointF mBalloonSegmentPoint2; 00123 00124 void updateBoundingRect(); 00126 void updateBalloon(); 00127 00128 void drawFrame( QPainter* p ); 00129 void drawMarkerSymbol( QPainter* p ); 00130 void drawSelectionBoxes( QPainter* p ); 00132 //double scaledFrameWidth( QPainter* p) const; 00134 QLineF segment( int index ); 00136 QPointF pointOnLineWithDistance( const QPointF& startPoint, const QPointF& directionPoint, double distance ) const; 00138 double scaledSymbolSize() const; 00139 }; 00140 00141 #endif // QGSANNOTATIONITEM_H