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 attribute table
68  MoveItemContent, //move content of item (e.g. content of map)
69  Pan,
70  Zoom
71  };
72 
74  {
76  ClipboardModeCopy
77  };
78 
79  enum PasteMode
80  {
83  PasteModeInPlace
84  };
85 
87  {
90  ActiveUntilMouseRelease
91  };
92 
93  QgsComposerView( QWidget* parent = 0, const char* name = 0, Qt::WindowFlags f = 0 );
94 
96  void groupItems();
97 
99  void ungroupItems();
100 
102  void copyItems( ClipboardMode mode );
103 
105  void pasteItems( PasteMode mode );
106 
108  void deleteSelectedItems();
109 
111  void selectAll();
112 
114  void selectNone();
115 
117  void selectInvert();
118 
119  QgsComposerView::Tool currentTool() const {return mCurrentTool;}
120  void setCurrentTool( QgsComposerView::Tool t );
121 
125  void setComposition( QgsComposition* c );
126 
128  QgsComposition* composition();
129 
131  QMainWindow* composerWindow();
132 
133  void setPaintingEnabled( bool enabled ) { mPaintingEnabled = enabled; }
134  bool paintingEnabled() const { return mPaintingEnabled; }
135 
137  void updateRulers();
138 
139  void setHorizontalRuler( QgsComposerRuler* r ) { mHorizontalRuler = r; }
140  void setVerticalRuler( QgsComposerRuler* r ) { mVerticalRuler = r; }
141 
143  void setZoomLevel( double zoomLevel );
144 
150  void setPreviewModeEnabled( bool enabled );
157  void setPreviewMode( QgsPreviewEffect::PreviewMode mode );
158 
159  protected:
160  void mousePressEvent( QMouseEvent* );
161  void mouseReleaseEvent( QMouseEvent* );
162  void mouseMoveEvent( QMouseEvent* );
163  void mouseDoubleClickEvent( QMouseEvent* e );
164 
165  void keyPressEvent( QKeyEvent * e );
166  void keyReleaseEvent( QKeyEvent * e );
167 
168  void wheelEvent( QWheelEvent* event );
169 
170  void paintEvent( QPaintEvent* event );
171 
172  void hideEvent( QHideEvent* e );
173  void showEvent( QShowEvent* e );
174 
175  void resizeEvent( QResizeEvent* event );
176  void scrollContentsBy( int dx, int dy );
177 
178  private:
180  QgsComposerView::Tool mCurrentTool;
182  QgsComposerView::Tool mPreviousTool;
183 
185  QGraphicsRectItem* mRubberBandItem;
187  QGraphicsLineItem* mRubberBandLineItem;
189  QgsComposerItem* mMoveContentItem;
191  QPointF mMoveContentStartPos;
193  QPointF mRubberBandStartPos;
194 
196  bool mMarqueeSelect;
198  bool mMarqueeZoom;
200  QgsComposerView::ToolStatus mTemporaryZoomStatus;
201 
202  bool mPaintingEnabled;
203 
204  QgsComposerRuler* mHorizontalRuler;
205  QgsComposerRuler* mVerticalRuler;
206 
208  void addShape( Tool currentTool );
209 
211  bool mToolPanning;
213  bool mMousePanning;
215  bool mKeyPanning;
216 
218  bool mMovingItemContent;
219 
220  QPoint mMouseLastXY;
221  QPoint mMouseCurrentXY;
222  QPoint mMousePressStartPos;
223 
224  QgsPreviewEffect* mPreviewEffect;
225 
227  QCursor defaultCursorForTool( Tool currentTool );
228 
230  void wheelZoom( QWheelEvent * event );
232  void updateRubberBandRect( QPointF & pos, const bool constrainSquare = false, const bool fromCenter = false );
234  void updateRubberBandLine( const QPointF & pos, const bool constrainAngles = false );
236  void removeRubberBand();
237 
239  void startMarqueeSelect( QPointF & scenePoint );
241  void endMarqueeSelect( QMouseEvent* e );
243  void startMarqueeZoom( QPointF & scenePoint );
245  void endMarqueeZoom( QMouseEvent* e );
246 
247  //void connectAddRemoveCommandSignals( QgsAddRemoveItemCommand* c );
248 
249  signals:
251  void selectedItemChanged( QgsComposerItem* selected );
253  void itemRemoved( QgsComposerItem* );
256  void actionFinished();
258  void cursorPosChanged( QPointF );
260  void zoomLevelChanged();
261 
263  void composerViewShow( QgsComposerView* );
265  void composerViewHide( QgsComposerView* );
266 
268  void compositionSet( QgsComposition* );
269 };
270 
271 #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:69
void setPaintingEnabled(bool enabled)
Definition: qgscomposerview.h:133
Definition: qgscomposerview.h:66
Definition: qgscomposerview.h:88
A item that forms part of a map composition.
Definition: qgscomposeritem.h:38
ToolStatus
Definition: qgscomposerview.h:86
Definition: qgscomposerview.h:61
Definition: qgscomposerview.h:64
void setVerticalRuler(QgsComposerRuler *r)
Definition: qgscomposerview.h:140
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:134
Definition: qgscomposerview.h:89
Graphics scene for map printing.
Definition: qgscomposition.h:70
Object representing map window.
Definition: qgscomposermap.h:45
A class to show paper scale and the current cursor position.
Definition: qgscomposerruler.h:10
Definition: qgscomposerview.h:57
Definition: qgscomposerview.h:82
Definition: qgscomposerview.h:81
A table class that displays a vector attribute table.
Definition: qgscomposerattributetable.h:49
A composer items that draws common shapes (ellipse, triangle, rectangle)
Definition: qgscomposershape.h:28
void setHorizontalRuler(QgsComposerRuler *r)
Definition: qgscomposerview.h:139
PasteMode
Definition: qgscomposerview.h:79
PreviewMode
Definition: qgsprevieweffect.h:33
ClipboardMode
Definition: qgscomposerview.h:73
Definition: qgscomposerview.h:75
A label that can be placed onto a map composition.
Definition: qgscomposerlabel.h:29
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:119
Definition: qgscomposerview.h:67
Definition: qgscomposerview.h:68