Quantum GIS API Documentation
1.7.4
|
00001 /*************************************************************************** 00002 qgscomposerview.h 00003 ------------------- 00004 begin : January 2005 00005 copyright : (C) 2005 by Radim Blazek 00006 email : blazek@itc.it 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 /* $Id$ */ 00018 #ifndef QGSCOMPOSERVIEW_H 00019 #define QGSCOMPOSERVIEW_H 00020 00021 #include <QGraphicsView> 00022 #include "qgsaddremoveitemcommand.h" 00023 00024 class QKeyEvent; 00025 class QMainWindow; 00026 class QMouseEvent; 00027 class QgsComposition; 00028 class QgsComposerArrow; 00029 class QgsComposerItem; 00030 class QgsComposerLabel; 00031 class QgsComposerLegend; 00032 class QgsComposerMap; 00033 class QgsComposerPicture; 00034 class QgsComposerScaleBar; 00035 class QgsComposerShape; 00036 class QgsComposerAttributeTable; 00037 00045 class GUI_EXPORT QgsComposerView: public QGraphicsView 00046 { 00047 Q_OBJECT 00048 00049 public: 00050 00052 enum Tool 00053 { 00054 Select = 0, // Select/Move item 00055 AddArrow, //add arrow 00056 AddMap, // add new map 00057 AddLegend, // add vector legend 00058 AddLabel, // add label 00059 AddScalebar, // add scalebar 00060 AddPicture, // add raster/vector picture 00061 AddShape, //add shape item (ellipse, rectangle, triangle) 00062 AddTable, //add attribute table 00063 MoveItemContent //move content of item (e.g. content of map) 00064 }; 00065 00066 QgsComposerView( QWidget* parent = 0, const char* name = 0, Qt::WFlags f = 0 ); 00067 00069 void groupItems(); 00070 00072 void ungroupItems(); 00073 00074 QgsComposerView::Tool currentTool() const {return mCurrentTool;} 00075 void setCurrentTool( QgsComposerView::Tool t ) {mCurrentTool = t;} 00076 00078 void setComposition( QgsComposition* c ); 00080 QgsComposition* composition(); 00081 00083 void addComposerArrow( QgsComposerArrow* arrow ); 00085 void addComposerLabel( QgsComposerLabel* label ); 00087 void addComposerMap( QgsComposerMap* map ); 00089 void addComposerScaleBar( QgsComposerScaleBar* scaleBar ); 00091 void addComposerLegend( QgsComposerLegend* legend ); 00093 void addComposerPicture( QgsComposerPicture* picture ); 00095 void addComposerShape( QgsComposerShape* shape ); 00097 void addComposerTable( QgsComposerAttributeTable* table ); 00098 00100 QMainWindow* composerWindow(); 00101 00102 void setPaintingEnabled( bool enabled ) { mPaintingEnabled = enabled; } 00103 bool paintingEnabled() const { return mPaintingEnabled; } 00104 00106 void pushAddRemoveCommand( QgsComposerItem* item, const QString& text, QgsAddRemoveItemCommand::State state = QgsAddRemoveItemCommand::Added ); 00107 00108 protected: 00109 void mousePressEvent( QMouseEvent* ); 00110 void mouseReleaseEvent( QMouseEvent* ); 00111 void mouseMoveEvent( QMouseEvent* ); 00112 void mouseDoubleClickEvent( QMouseEvent* e ); 00113 00114 void keyPressEvent( QKeyEvent * e ); 00115 void keyReleaseEvent( QKeyEvent * e ); 00116 00117 void wheelEvent( QWheelEvent* event ); 00118 00119 void paintEvent( QPaintEvent* event ); 00120 00121 00122 private: 00124 bool mShiftKeyPressed; 00126 QgsComposerView::Tool mCurrentTool; 00128 QGraphicsRectItem* mRubberBandItem; 00130 QGraphicsLineItem* mRubberBandLineItem; 00132 QgsComposerItem* mMoveContentItem; 00134 QPointF mMoveContentStartPos; 00136 QPointF mRubberBandStartPos; 00137 00138 bool mPaintingEnabled; 00139 00140 void connectAddRemoveCommandSignals( QgsAddRemoveItemCommand* c ); 00141 00142 00143 public slots: 00145 void sendItemAddedSignal( QgsComposerItem* item ); 00146 00147 signals: 00149 void selectedItemChanged( QgsComposerItem* selected ); 00151 void composerArrowAdded( QgsComposerArrow* arrow ); 00153 void composerLabelAdded( QgsComposerLabel* label ); 00155 void composerMapAdded( QgsComposerMap* map ); 00157 void composerScaleBarAdded( QgsComposerScaleBar* scalebar ); 00159 void composerLegendAdded( QgsComposerLegend* legend ); 00161 void composerPictureAdded( QgsComposerPicture* picture ); 00163 void composerShapeAdded( QgsComposerShape* shape ); 00165 void composerTableAdded( QgsComposerAttributeTable* table ); 00167 void itemRemoved( QgsComposerItem* ); 00170 void actionFinished(); 00171 }; 00172 00173 #endif