QGIS/python/gui/qgscomposerview.sip

169 lines
4.8 KiB
Plaintext
Raw Normal View History

/** \ingroup MapComposer
* \ingroup gui
* Widget to display the composer items. Manages the composer tools and the
* mouse/key events.
* Creates the composer items according to the current map tools and keeps track
* of the rubber band item.
*/
2014-01-26 18:35:21 +01:00
class QgsComposerView : QGraphicsView
{
%TypeHeaderCode
#include "qgscomposerview.h"
%End
%ConvertToSubClassCode
if (sipCpp->inherits("QgsComposerView"))
sipClass = sipClass_QgsComposerView;
else
sipClass = NULL;
%End
public:
2015-07-29 11:52:14 +02:00
/** Current tool*/
enum Tool
{
2014-06-02 21:00:51 +02:00
Select, // Select/Move item
AddArrow, // add arrow
AddHtml,
AddMap, // add new map
2014-06-02 21:00:51 +02:00
AddLegend, // add vector legend
AddLabel, // add label
AddScalebar, // add scalebar
2014-06-02 21:00:51 +02:00
AddPicture, // add raster/vector picture
AddRectangle,
AddEllipse,
AddTriangle,
2014-06-02 21:00:51 +02:00
AddTable, // add attribute table
AddAttributeTable,
2014-06-02 21:00:51 +02:00
MoveItemContent, // move content of item (e.g. content of map)
2014-01-26 18:35:21 +01:00
Pan,
Zoom
};
enum ClipboardMode
{
ClipboardModeCut,
ClipboardModeCopy
};
enum PasteMode
{
PasteModeCursor,
PasteModeCenter,
PasteModeInPlace
};
enum ToolStatus
{
Inactive,
Active,
ActiveUntilMouseRelease
};
QgsComposerView( QWidget* parent /TransferThis/ = 0, const char* name = 0, Qt::WindowFlags f = 0 );
2015-07-29 11:52:14 +02:00
/** Add an item group containing the selected items*/
void groupItems();
2015-07-29 11:52:14 +02:00
/** Ungroups the selected items*/
void ungroupItems();
2015-07-29 11:52:14 +02:00
/** Cuts or copies the selected items*/
2014-01-26 18:35:21 +01:00
void copyItems( ClipboardMode mode );
2015-07-29 11:52:14 +02:00
/** Pastes items from clipboard*/
2014-01-26 18:35:21 +01:00
void pasteItems( PasteMode mode );
2015-07-29 11:52:14 +02:00
/** Deletes selected items*/
2014-01-26 18:35:21 +01:00
void deleteSelectedItems();
2015-07-29 11:52:14 +02:00
/** Selects all items*/
2014-01-26 18:35:21 +01:00
void selectAll();
2015-07-29 11:52:14 +02:00
/** Deselects all items*/
2014-01-26 18:35:21 +01:00
void selectNone();
2015-07-29 11:52:14 +02:00
/** Inverts current selection*/
2014-01-26 18:35:21 +01:00
void selectInvert();
QgsComposerView::Tool currentTool() const;
void setCurrentTool( QgsComposerView::Tool t );
2015-07-29 11:52:14 +02:00
/** Sets the composition for the view. If the composition is being set manually and not by a QgsComposer, then this must
* be set BEFORE adding any items to the composition.
*/
void setComposition( QgsComposition* c /KeepReference/ );
2014-08-17 13:37:26 +02:00
2015-07-29 11:52:14 +02:00
/** Returns the composition or 0 in case of error*/
QgsComposition* composition();
2015-07-29 11:52:14 +02:00
/** Returns the composer main window*/
QMainWindow* composerWindow();
void setPaintingEnabled( bool enabled );
bool paintingEnabled() const;
2015-07-29 11:52:14 +02:00
/** Update rulers with current scene rect*/
2013-06-23 16:00:16 +02:00
void updateRulers();
void setHorizontalRuler( QgsComposerRuler* r );
void setVerticalRuler( QgsComposerRuler* r );
2015-07-29 11:52:14 +02:00
/** Set zoom level, where a zoom level of 1.0 corresponds to 100%*/
2014-01-26 18:35:21 +01:00
void setZoomLevel( double zoomLevel );
2015-07-29 11:52:14 +02:00
/** Sets whether a preview effect should be used to alter the view's appearance
* @param enabled Set to true to enable the preview effect on the view
* @note added in 2.3
* @see setPreviewMode
*/
void setPreviewModeEnabled( bool enabled );
2015-07-29 11:52:14 +02:00
/** Sets the preview mode which should be used to modify the view's appearance. Preview modes are only used
* if setPreviewMode is set to true.
* @param mode PreviewMode to be used to draw the view
* @note added in 2.3
* @see setPreviewModeEnabled
*/
void setPreviewMode( QgsPreviewEffect::PreviewMode mode );
protected:
void mousePressEvent( QMouseEvent* );
void mouseReleaseEvent( QMouseEvent* );
void mouseMoveEvent( QMouseEvent* );
void mouseDoubleClickEvent( QMouseEvent* e );
void keyPressEvent( QKeyEvent * e );
2014-01-26 18:35:21 +01:00
void keyReleaseEvent( QKeyEvent * e );
void wheelEvent( QWheelEvent* event );
void paintEvent( QPaintEvent* event );
void hideEvent( QHideEvent* e );
void showEvent( QShowEvent* e );
2013-06-23 16:00:16 +02:00
void resizeEvent( QResizeEvent* event );
void scrollContentsBy( int dx, int dy );
signals:
2015-07-29 11:52:14 +02:00
/** Is emitted when selected item changed. If 0, no item is selected*/
void selectedItemChanged( QgsComposerItem* selected );
2015-07-29 11:52:14 +02:00
/** Is emitted when a composer item has been removed from the scene*/
void itemRemoved( QgsComposerItem* );
2015-07-29 11:52:14 +02:00
/** Current action (e.g. adding composer map) has been finished. The purpose of this signal is that
QgsComposer may set the selection tool again*/
void actionFinished();
2015-07-29 11:52:14 +02:00
/** Is emitted when mouse cursor coordinates change*/
2014-01-27 09:22:24 +01:00
void cursorPosChanged( QPointF );
2015-07-29 11:52:14 +02:00
/** Is emitted when the view zoom changes*/
2014-01-27 09:22:24 +01:00
void zoomLevelChanged();
2015-07-29 11:52:14 +02:00
/** Emitted before composerview is shown*/
void composerViewShow( QgsComposerView* );
2015-07-29 11:52:14 +02:00
/** Emitted before composerview is hidden*/
void composerViewHide( QgsComposerView* );
2014-08-17 13:37:26 +02:00
2015-07-29 11:52:14 +02:00
/** Emitted when the composition is set for the view*/
2014-08-17 13:37:26 +02:00
void compositionSet( QgsComposition* );
};