QGIS API Documentation  2.0.1-Dufour
 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 : 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 
23 class QDomDocument;
24 class QDomElement;
25 class QKeyEvent;
26 class QMainWindow;
27 class QMouseEvent;
28 class QgsComposition;
29 class QgsComposerArrow;
30 class QgsComposerItem;
31 class QgsComposerLabel;
32 class QgsComposerLegend;
33 class QgsComposerMap;
34 class QgsComposerPicture;
35 class QgsComposerRuler;
37 class QgsComposerShape;
39 
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  };
70 
71  QgsComposerView( QWidget* parent = 0, const char* name = 0, Qt::WFlags f = 0 );
72 
74  void groupItems();
75 
77  void ungroupItems();
78 
79  QgsComposerView::Tool currentTool() const {return mCurrentTool;}
80  void setCurrentTool( QgsComposerView::Tool t ) {mCurrentTool = t;}
81 
83  void setComposition( QgsComposition* c );
85  QgsComposition* composition();
86 
88  QMainWindow* composerWindow();
89 
90  void setPaintingEnabled( bool enabled ) { mPaintingEnabled = enabled; }
91  bool paintingEnabled() const { return mPaintingEnabled; }
92 
94  void updateRulers();
95 
96  void setHorizontalRuler( QgsComposerRuler* r ) { mHorizontalRuler = r; }
97  void setVerticalRuler( QgsComposerRuler* r ) { mVerticalRuler = r; }
98 
99  protected:
100  void mousePressEvent( QMouseEvent* );
101  void mouseReleaseEvent( QMouseEvent* );
102  void mouseMoveEvent( QMouseEvent* );
103  void mouseDoubleClickEvent( QMouseEvent* e );
104 
105  void keyPressEvent( QKeyEvent * e );
106 
107  void wheelEvent( QWheelEvent* event );
108 
109  void paintEvent( QPaintEvent* event );
110 
111  void hideEvent( QHideEvent* e );
112  void showEvent( QShowEvent* e );
113 
114  void resizeEvent( QResizeEvent* event );
115  void scrollContentsBy( int dx, int dy );
116 
117  private:
121  QGraphicsRectItem* mRubberBandItem;
123  QGraphicsLineItem* mRubberBandLineItem;
130 
132 
135 
137  void addShape( Tool currentTool );
138 
139  //void connectAddRemoveCommandSignals( QgsAddRemoveItemCommand* c );
140 
141  signals:
143  void selectedItemChanged( QgsComposerItem* selected );
145  void itemRemoved( QgsComposerItem* );
148  void actionFinished();
149 
151  void composerViewShow( QgsComposerView* );
153  void composerViewHide( QgsComposerView* );
154 };
155 
156 #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.
QgsComposerView::Tool mCurrentTool
Current composer tool.
void setPaintingEnabled(bool enabled)
A item that forms part of a map composition.
void setCurrentTool(QgsComposerView::Tool t)
QGraphicsLineItem * mRubberBandLineItem
Rubber band item for arrows.
void setVerticalRuler(QgsComposerRuler *r)
A composer class that displays svg files or raster format (jpg, png, ...)
Widget to display the composer items.
QPointF mRubberBandStartPos
Start of rubber band creation.
bool paintingEnabled() const
Graphics scene for map printing.
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.
QgsComposerRuler * mHorizontalRuler
A legend that can be placed onto a map composition.
QgsComposerView::Tool currentTool() const
QGraphicsRectItem * mRubberBandItem
Rubber band item.