mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-26 00:02:08 -05:00
Splits the rendering component of annotations out from map canvas item component. A new core abstract base class QgsAnnotation handles the management of the common properties associated with an annotation, and handles rendering the annotation onto a QgsRenderContext destination. Existing annotation classes have been ported to this, and with the exception of the form annotation moved into core. Form annotations are dependant on editor widgets and must remain in GUI. A new QgsMapCanvasAnnotationItem item class implements a QgsMapCanvasItem which draws an annotation inside the canvas, and handles synchronising the position and size of the canvas item with the QgsAnnotation position/size. This allows annotations to be safely used in a multi-canvas environment, with a single QgsAnnotation being displayed in multiple canvases (even if the canvases have different extent/crs/etc). Additionally it allows annotations to be directly rendered to a map (eg in composer) without going through the gui based Qt graphics scene framework. Also removes lots of duplicate code, and adds some basic unit tests for annotations.
47 lines
1.1 KiB
Plaintext
47 lines
1.1 KiB
Plaintext
class QgsMapCanvasAnnotationItem : public QObject, public QgsMapCanvasItem
|
|
{
|
|
%TypeHeaderCode
|
|
#include <qgsmapcanvasannotationitem.h>
|
|
%End
|
|
|
|
public:
|
|
|
|
enum MouseMoveAction
|
|
{
|
|
NoAction,
|
|
MoveMapPosition,
|
|
MoveFramePosition,
|
|
ResizeFrameUp,
|
|
ResizeFrameDown,
|
|
ResizeFrameLeft,
|
|
ResizeFrameRight,
|
|
ResizeFrameLeftUp,
|
|
ResizeFrameRightUp,
|
|
ResizeFrameLeftDown,
|
|
ResizeFrameRightDown,
|
|
};
|
|
|
|
QgsMapCanvasAnnotationItem( QgsAnnotation* annotation /Transfer/, QgsMapCanvas* mapCanvas /TransferThis/ );
|
|
~QgsMapCanvasAnnotationItem();
|
|
|
|
//const QgsAnnotation* annotation() const { return mAnnotation; }
|
|
QgsAnnotation* annotation();
|
|
|
|
void updatePosition();
|
|
|
|
QRectF boundingRect() const;
|
|
|
|
void paint( QPainter * painter );
|
|
|
|
/**
|
|
* Returns the mouse move behavior for a given position in scene coordinates
|
|
*/
|
|
MouseMoveAction moveActionForPosition( QPointF pos ) const;
|
|
|
|
/**
|
|
* Returns matching cursor shape for a mouse move action.
|
|
*/
|
|
Qt::CursorShape cursorShapeForAction( MouseMoveAction moveAction ) const;
|
|
|
|
};
|