QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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:
183 
185  QGraphicsRectItem* mRubberBandItem;
187  QGraphicsLineItem* mRubberBandLineItem;
194 
201 
203 
206 
208  void addShape( Tool currentTool );
209 
216 
219 
220  QPoint mMouseLastXY;
223 
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.
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.
Tool
Current 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.
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.