QGIS API Documentation  2.4.0-Chugiak
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgscomposerview.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposerview.h
3  -------------------
4  begin : January 2005
5  copyright : (C) 2005 by Radim Blazek
6  email : [email protected]
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 #ifndef QGSCOMPOSERVIEW_H
18 #define QGSCOMPOSERVIEW_H
19 
20 #include <QGraphicsView>
22 #include "qgsprevieweffect.h" // for QgsPreviewEffect::PreviewMode
23 
24 class QDomDocument;
25 class QDomElement;
26 class QKeyEvent;
27 class QMainWindow;
28 class QMouseEvent;
29 class QgsComposition;
30 class QgsComposerArrow;
31 class QgsComposerItem;
32 class QgsComposerLabel;
33 class QgsComposerLegend;
34 class QgsComposerMap;
35 class QgsComposerPicture;
36 class QgsComposerRuler;
38 class QgsComposerShape;
40 
48 class GUI_EXPORT QgsComposerView: public QGraphicsView
49 {
50  Q_OBJECT
51 
52  public:
53 
55  enum Tool
56  {
57  Select = 0, // Select/Move item
58  AddArrow, //add arrow
60  AddMap, // add new map
61  AddLegend, // add vector legend
62  AddLabel, // add label
63  AddScalebar, // add scalebar
64  AddPicture, // add raster/vector picture
68  AddTable, //add attribute table
69  MoveItemContent, //move content of item (e.g. content of map)
70  Pan,
71  Zoom
72  };
73 
75  {
77  ClipboardModeCopy
78  };
79 
80  enum PasteMode
81  {
84  PasteModeInPlace
85  };
86 
88  {
91  ActiveUntilMouseRelease
92  };
93 
94  QgsComposerView( QWidget* parent = 0, const char* name = 0, Qt::WindowFlags f = 0 );
95 
97  void groupItems();
98 
100  void ungroupItems();
101 
103  void copyItems( ClipboardMode mode );
104 
106  void pasteItems( PasteMode mode );
107 
109  void deleteSelectedItems();
110 
112  void selectAll();
113 
115  void selectNone();
116 
118  void selectInvert();
119 
120  QgsComposerView::Tool currentTool() const {return mCurrentTool;}
121  void setCurrentTool( QgsComposerView::Tool t );
122 
126  void setComposition( QgsComposition* c );
127 
129  QgsComposition* composition();
130 
132  QMainWindow* composerWindow();
133 
134  void setPaintingEnabled( bool enabled ) { mPaintingEnabled = enabled; }
135  bool paintingEnabled() const { return mPaintingEnabled; }
136 
138  void updateRulers();
139 
140  void setHorizontalRuler( QgsComposerRuler* r ) { mHorizontalRuler = r; }
141  void setVerticalRuler( QgsComposerRuler* r ) { mVerticalRuler = r; }
142 
144  void setZoomLevel( double zoomLevel );
145 
151  void setPreviewModeEnabled( bool enabled );
158  void setPreviewMode( QgsPreviewEffect::PreviewMode mode );
159 
160  protected:
161  void mousePressEvent( QMouseEvent* );
162  void mouseReleaseEvent( QMouseEvent* );
163  void mouseMoveEvent( QMouseEvent* );
164  void mouseDoubleClickEvent( QMouseEvent* e );
165 
166  void keyPressEvent( QKeyEvent * e );
167  void keyReleaseEvent( QKeyEvent * e );
168 
169  void wheelEvent( QWheelEvent* event );
170 
171  void paintEvent( QPaintEvent* event );
172 
173  void hideEvent( QHideEvent* e );
174  void showEvent( QShowEvent* e );
175 
176  void resizeEvent( QResizeEvent* event );
177  void scrollContentsBy( int dx, int dy );
178 
179  private:
184 
186  QGraphicsRectItem* mRubberBandItem;
188  QGraphicsLineItem* mRubberBandLineItem;
195 
202 
204 
207 
209  void addShape( Tool currentTool );
210 
217 
220 
221  QPoint mMouseLastXY;
224 
226 
228  QCursor defaultCursorForTool( Tool currentTool );
229 
231  void wheelZoom( QWheelEvent * event );
233  void updateRubberBand( QPointF & pos );
235  void removeRubberBand();
236 
238  void startMarqueeSelect( QPointF & scenePoint );
240  void endMarqueeSelect( QMouseEvent* e );
242  void startMarqueeZoom( QPointF & scenePoint );
244  void endMarqueeZoom( QMouseEvent* e );
245 
246  //void connectAddRemoveCommandSignals( QgsAddRemoveItemCommand* c );
247 
248  signals:
250  void selectedItemChanged( QgsComposerItem* selected );
252  void itemRemoved( QgsComposerItem* );
255  void actionFinished();
257  void cursorPosChanged( QPointF );
259  void zoomLevelChanged();
260 
262  void composerViewShow( QgsComposerView* );
264  void composerViewHide( QgsComposerView* );
265 
267  void compositionSet( QgsComposition* );
268 };
269 
270 #endif
A scale bar item that can be added to a map composition.
QPointF mMoveContentStartPos
Start position of content move.
QgsComposerRuler * mVerticalRuler
An item that draws an arrow between to points.
QPoint mMousePressStartPos
bool mToolPanning
True if user is currently panning by clicking and dragging with the pan tool.
QgsComposerView::Tool mCurrentTool
Current composer tool.
void setPaintingEnabled(bool enabled)
A item that forms part of a map composition.
bool mKeyPanning
True if user is currently panning by holding the space key.
QGraphicsLineItem * mRubberBandLineItem
Rubber band item for arrows.
void setVerticalRuler(QgsComposerRuler *r)
A graphics effect which can be applied to a widget to simulate various printing and color blindness m...
A composer class that displays svg files or raster format (jpg, png, ...)
QgsComposerView::Tool mPreviousTool
Previous composer tool.
QgsPreviewEffect * mPreviewEffect
bool mMousePanning
True if user is currently panning by holding the middle mouse button.
Widget to display the composer items.
QPointF mRubberBandStartPos
Start of rubber band creation.
bool paintingEnabled() const
Graphics scene for map printing.
bool mMovingItemContent
True if user is currently dragging with the move item content tool.
Object representing map window.
Tool
Current tool.
QgsComposerItem * mMoveContentItem
Item to move content.
A class to show paper scale and the current cursor position.
A table class that displays a vector attribute table.
A composer items that draws common shapes (ellipse, triangle, rectangle)
void setHorizontalRuler(QgsComposerRuler *r)
A label that can be placed onto a map composition.
bool mMarqueeZoom
True if user is currently zooming by marquee.
QgsComposerRuler * mHorizontalRuler
QgsComposerView::ToolStatus mTemporaryZoomStatus
True if user is currently temporarily activating the zoom tool by holding control+space.
A legend that can be placed onto a map composition.
bool mMarqueeSelect
True if user is currently selecting by marquee.
QgsComposerView::Tool currentTool() const
QGraphicsRectItem * mRubberBandItem
Rubber band item.