QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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 : blazek@itc.it
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 
47 class GUI_EXPORT QgsComposerView: public QGraphicsView
48 {
49  Q_OBJECT
50 
51  public:
52 
54  enum Tool
55  {
56  Select = 0, // Select/Move item
57  AddArrow, //add arrow
59  AddMap, // add new map
60  AddLegend, // add vector legend
61  AddLabel, // add label
62  AddScalebar, // add scalebar
63  AddPicture, // add raster/vector picture
67  AddTable, //add 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:
181  QgsComposerView::Tool mCurrentTool;
183  QgsComposerView::Tool mPreviousTool;
184 
186  QGraphicsRectItem* mRubberBandItem;
188  QGraphicsLineItem* mRubberBandLineItem;
190  QgsComposerItem* mMoveContentItem;
192  QPointF mMoveContentStartPos;
194  QPointF mRubberBandStartPos;
195 
197  bool mMarqueeSelect;
199  bool mMarqueeZoom;
201  QgsComposerView::ToolStatus mTemporaryZoomStatus;
202 
203  bool mPaintingEnabled;
204 
205  QgsComposerRuler* mHorizontalRuler;
206  QgsComposerRuler* mVerticalRuler;
207 
209  void addShape( Tool currentTool );
210 
212  bool mToolPanning;
214  bool mMousePanning;
216  bool mKeyPanning;
217 
219  bool mMovingItemContent;
220 
221  QPoint mMouseLastXY;
222  QPoint mMouseCurrentXY;
223  QPoint mMousePressStartPos;
224 
225  QgsPreviewEffect* mPreviewEffect;
226 
228  QCursor defaultCursorForTool( Tool currentTool );
229 
231  void wheelZoom( QWheelEvent * event );
233  void updateRubberBandRect( QPointF & pos, const bool constrainSquare = false, const bool fromCenter = false );
235  void updateRubberBandLine( const QPointF & pos, const bool constrainAngles = false );
237  void removeRubberBand();
238 
240  void startMarqueeSelect( QPointF & scenePoint );
242  void endMarqueeSelect( QMouseEvent* e );
244  void startMarqueeZoom( QPointF & scenePoint );
246  void endMarqueeZoom( QMouseEvent* e );
247 
248  //void connectAddRemoveCommandSignals( QgsAddRemoveItemCommand* c );
249 
250  signals:
252  void selectedItemChanged( QgsComposerItem* selected );
254  void itemRemoved( QgsComposerItem* );
257  void actionFinished();
259  void cursorPosChanged( QPointF );
261  void zoomLevelChanged();
262 
264  void composerViewShow( QgsComposerView* );
266  void composerViewHide( QgsComposerView* );
267 
269  void compositionSet( QgsComposition* );
270 };
271 
272 #endif
A scale bar item that can be added to a map composition.
Definition: qgscomposerscalebar.h:30
An item that draws an arrow between to points.
Definition: qgscomposerarrow.h:28
Definition: qgscomposerview.h:70
void setPaintingEnabled(bool enabled)
Definition: qgscomposerview.h:134
Definition: qgscomposerview.h:66
Definition: qgscomposerview.h:89
A item that forms part of a map composition.
Definition: qgscomposeritem.h:38
ToolStatus
Definition: qgscomposerview.h:87
Definition: qgscomposerview.h:61
Definition: qgscomposerview.h:64
A table that displays attributes from a vector layer.
Definition: qgscomposerattributetablev2.h:51
void setVerticalRuler(QgsComposerRuler *r)
Definition: qgscomposerview.h:141
A graphics effect which can be applied to a widget to simulate various printing and color blindness m...
Definition: qgsprevieweffect.h:28
A composer class that displays svg files or raster format (jpg, png, ...)
Definition: qgscomposerpicture.h:31
Tool
Current tool.
Definition: qgscomposerview.h:54
Definition: qgscomposerview.h:58
Definition: qgscomposerview.h:60
Definition: qgscomposerview.h:59
Widget to display the composer items.
Definition: qgscomposerview.h:47
Definition: qgscomposerview.h:63
Definition: qgscomposerview.h:62
bool paintingEnabled() const
Definition: qgscomposerview.h:135
Definition: qgscomposerview.h:90
Graphics scene for map printing.
Definition: qgscomposition.h:72
Object representing map window.
Definition: qgscomposermap.h:46
A class to show paper scale and the current cursor position.
Definition: qgscomposerruler.h:10
Definition: qgscomposerview.h:57
Definition: qgscomposerview.h:83
Definition: qgscomposerview.h:82
A composer items that draws common shapes (ellipse, triangle, rectangle)
Definition: qgscomposershape.h:28
void setHorizontalRuler(QgsComposerRuler *r)
Definition: qgscomposerview.h:140
PasteMode
Definition: qgscomposerview.h:80
PreviewMode
Definition: qgsprevieweffect.h:33
ClipboardMode
Definition: qgscomposerview.h:74
Definition: qgscomposerview.h:76
A label that can be placed onto a map composition.
Definition: qgscomposerlabel.h:29
Definition: qgscomposerview.h:68
Definition: qgscomposerview.h:65
A legend that can be placed onto a map composition.
Definition: qgscomposerlegend.h:56
QgsComposerView::Tool currentTool() const
Definition: qgscomposerview.h:120
Definition: qgscomposerview.h:67
Definition: qgscomposerview.h:69