18 #include <QApplication> 19 #include <QMainWindow> 20 #include <QMouseEvent> 24 #include <QGridLayout> 26 #include <QDesktopWidget> 51 #define MIN_VIEW_SCALE 0.05 52 #define MAX_VIEW_SCALE 1000.0 56 , mCurrentTool( Select )
57 , mPreviousTool( Select )
58 , mRubberBandItem( nullptr )
59 , mRubberBandLineItem( nullptr )
60 , mMoveContentItem( nullptr )
61 , mMarqueeSelect( false )
62 , mMarqueeZoom( false )
64 , mPaintingEnabled( true )
65 , mHorizontalRuler( nullptr )
66 , mVerticalRuler( nullptr )
67 , mMoveContentSearchRadius( 25 )
68 , mNodesItem( nullptr )
69 , mNodesItemIndex( -1 )
70 , mToolPanning( false )
71 , mMousePanning( false )
72 , mKeyPanning( false )
73 , mMovingItemContent( false )
74 , mPreviewEffect( nullptr )
100 mNodesItem =
nullptr;
101 mPolygonItem.
reset();
102 mPolylineItem.
reset();
103 displayNodes(
false );
170 if ( mRubberBandItem || mRubberBandLineItem || mKeyPanning || mMousePanning || mToolPanning || mMovingItemContent )
184 mMousePressStartPos = e->
pos();
186 if ( e->
button() == Qt::RightButton )
192 else if ( e->
button() == Qt::MidButton )
195 mMousePanning =
true;
196 mMouseLastXY = e->
pos();
206 switch ( mCurrentTool )
228 if ( e->
modifiers() & Qt::ControlModifier )
233 if ( !selectedItems.
isEmpty() )
235 previousSelectedItem = selectedItems.
at( 0 );
239 if ( previousSelectedItem )
260 startMarqueeSelect( scenePoint );
264 if (( !selectedItem->
selected() ) &&
265 !( e->
modifiers() & Qt::ShiftModifier ) )
277 if ( !selectedItems.
isEmpty() )
293 if ( !( e->
modifiers() & Qt::ShiftModifier ) )
296 startMarqueeZoom( scenePoint );
301 double scaleFactor = 2;
309 visibleRect.
scale( scaleFactor, scenePoint.
x(), scenePoint.
y() );
313 fitInView( boundsRect, Qt::KeepAspectRatio );
322 mMouseLastXY = e->
pos();
331 if ( itemsAtCursorPos.
isEmpty() )
340 for ( ; itemIter != itemsAtCursorPos.
end(); ++itemIter )
346 mMoveContentStartPos = scenePoint;
347 mMoveContentItem = item;
348 mMovingItemContent =
true;
360 mMoveContentSearchRadius,
361 mMoveContentSearchRadius );
362 if ( itemsAtCursorPos.
isEmpty() )
365 mNodesItemIndex = -1;
366 mNodesItem =
nullptr;
369 for ( ; itemIter != itemsAtCursorPos.
end(); ++itemIter )
382 mNodesItemIndex =
index;
384 mMoveContentStartPos = scenePoint;
389 if ( mNodesItemIndex != -1 )
392 setSelectedNode( mNodesItem, mNodesItemIndex );
403 mRubberBandStartPos =
QPointF( snappedScenePoint.x(), snappedScenePoint.y() );
404 mRubberBandLineItem =
new QGraphicsLineItem( snappedScenePoint.x(), snappedScenePoint.y(), snappedScenePoint.x(), snappedScenePoint.y() );
405 mRubberBandLineItem->setPen(
QPen(
QBrush(
QColor( 227, 22, 22, 200 ) ), 0 ) );
406 mRubberBandLineItem->setZValue( 1000 );
426 mRubberBandItem->
setBrush( Qt::NoBrush );
428 mRubberBandStartPos =
QPointF( snappedScenePoint.x(), snappedScenePoint.y() );
429 t.
translate( snappedScenePoint.x(), snappedScenePoint.y() );
441 newScaleBar->
setSceneRect(
QRectF( snappedScenePoint.x(), snappedScenePoint.y(), 20, 20 ) );
461 if ( mPolygonItem.
isNull() )
464 mPolygonItem.
data()->setBrush( Qt::NoBrush );
466 mPolygonItem.
data()->setZValue( 1000 );
483 mPolylineItem.
data()->setZValue( 1000 );
496 switch ( currentTool )
499 return Qt::ArrowCursor;
504 return QCursor( myZoomQPixmap, 7, 7 );
508 return Qt::OpenHandCursor;
511 return Qt::ArrowCursor;
514 return Qt::CrossCursor;
532 return QCursor( myCrosshairQPixmap, 8, 8 );
535 return Qt::ArrowCursor;
547 if ( !mRubberBandItem || ( mRubberBandItem->
rect().
width() < 0.1 && mRubberBandItem->
rect().
height() < 0.1 ) )
572 if ( mHorizontalRuler )
576 if ( mVerticalRuler )
582 void QgsComposerView::removeRubberBand()
584 if ( mRubberBandItem )
587 delete mRubberBandItem;
588 mRubberBandItem =
nullptr;
592 void QgsComposerView::startMarqueeSelect(
QPointF & scenePoint )
594 mMarqueeSelect =
true;
600 mRubberBandStartPos =
QPointF( scenePoint.
x(), scenePoint.
y() );
608 void QgsComposerView::endMarqueeSelect(
QMouseEvent* e )
610 mMarqueeSelect =
false;
612 bool subtractingSelection =
false;
613 if ( e->
modifiers() & Qt::ShiftModifier )
617 else if ( e->
modifiers() & Qt::ControlModifier )
620 subtractingSelection =
true;
628 if ( !mRubberBandItem || ( mRubberBandItem->
rect().
width() < 0.1 && mRubberBandItem->
rect().
height() < 0.1 ) )
639 Qt::ItemSelectionMode selectionMode = Qt::IntersectsItemShape;
643 selectionMode = Qt::ContainsItemShape;
649 for ( ; itemIt != itemList.
end(); ++itemIt )
653 if ( mypItem && !paperItem )
657 if ( subtractingSelection )
672 if ( !selectedItemList.
isEmpty() )
678 void QgsComposerView::startMarqueeZoom(
QPointF & scenePoint )
686 mRubberBandStartPos =
QPointF( scenePoint.
x(), scenePoint.
y() );
694 void QgsComposerView::endMarqueeZoom(
QMouseEvent* e )
696 mMarqueeZoom =
false;
700 if ( !mRubberBandItem || ( mRubberBandItem->
rect().
width() < 0.1 && mRubberBandItem->
rect().
height() < 0.1 ) )
703 double scaleFactor = 0.5;
711 visibleRect.
scale( scaleFactor, scenePoint.
x(), scenePoint.
y() );
712 boundsRect = visibleRect.
toRectF();
724 fitInView( boundsRect, Qt::KeepAspectRatio );
742 if ( e->
button() != Qt::LeftButton &&
750 int diffX = mousePressStopPoint.
x() - mMousePressStartPos.
x();
751 int diffY = mousePressStopPoint.
y() - mMousePressStartPos.
y();
754 bool clickOnly =
false;
755 if ( qAbs( diffX ) < 2 && qAbs( diffY ) < 2 )
762 if ( mMousePanning || mToolPanning )
764 mMousePanning =
false;
765 mToolPanning =
false;
767 if ( clickOnly && e->
button() == Qt::MidButton )
774 visibleRect.
scale( 1, scenePoint.
x(), scenePoint.
y() );
778 fitInView( boundsRect, Qt::KeepAspectRatio );
782 if ( mCurrentTool !=
Pan )
793 if ( e->
button() == Qt::RightButton )
795 switch ( mCurrentTool )
799 if ( ! mPolygonItem.
isNull() )
805 if ( poly.
size() >= 3 )
807 mPolygonItem.
data()->setPolygon( poly );
823 mPolygonItem.
reset();
831 if ( ! mPolygonItem.
isNull() && ! mPolylineItem.
isNull() )
838 if ( poly.
size() >= 2 )
840 mPolygonItem.
data()->setPolygon( poly );
856 mPolygonItem.
reset();
857 mPolylineItem.
reset();
870 if ( e->
button() != Qt::LeftButton )
875 if ( mMarqueeSelect )
877 endMarqueeSelect( e );
881 switch ( mCurrentTool )
900 if ( mMoveContentItem )
909 double moveX = scenePoint.
x() - mMoveContentStartPos.
x();
910 double moveY = scenePoint.
y() - mMoveContentStartPos.
y();
915 mMoveContentItem =
nullptr;
916 mMovingItemContent =
false;
923 if ( mNodesItemIndex != -1 )
925 if ( scenePoint != mMoveContentStartPos )
938 delete mRubberBandLineItem;
939 mRubberBandLineItem =
nullptr;
952 delete mRubberBandLineItem;
953 mRubberBandLineItem =
nullptr;
962 addShape( mCurrentTool );
967 if ( ! mPolygonItem.
isNull() )
968 addPolygonNode( scenePoint );
975 if ( ! mPolygonItem.
isNull() && ! mPolylineItem.
isNull() )
977 addPolygonNode( scenePoint );
982 mPolylineItem.
data()->setPath( path );
1047 double labelWidth = qMax( mRubberBandItem->
rect().
width(), newLabelItem->
rect().
width() );
1191 bool shiftModifier =
false;
1192 bool altModifier =
false;
1193 if ( e->
modifiers() & Qt::ShiftModifier )
1196 shiftModifier =
true;
1204 mMouseCurrentXY = e->
pos();
1209 if ( mHorizontalRuler )
1213 if ( mVerticalRuler )
1218 if ( mToolPanning || mMousePanning || mKeyPanning )
1223 mMouseLastXY = e->
pos();
1226 else if (( e->
buttons() == Qt::NoButton ) && ( mPolygonItem.
isNull() ) )
1228 if ( mCurrentTool ==
Select )
1237 if ( mMarqueeSelect || mMarqueeZoom )
1239 updateRubberBandRect( scenePoint );
1243 switch ( mCurrentTool )
1251 updateRubberBandLine( scenePoint, shiftModifier );
1267 updateRubberBandRect( scenePoint, shiftModifier, altModifier );
1273 if ( ! mPolygonItem.
isNull() )
1274 movePolygonNode( scenePoint );
1281 if ( ! mPolygonItem.
isNull() && ! mPolylineItem.
isNull() )
1283 movePolygonNode( scenePoint );
1288 mPolylineItem.
data()->setPath( path );
1300 composerMap->
setOffset( scenePoint.
x() - mMoveContentStartPos.
x(), scenePoint.
y() - mMoveContentStartPos.
y() );
1308 if ( mNodesItemIndex != -1 )
1311 mNodesItem->
moveNode( mNodesItemIndex, scenePoint );
1324 void QgsComposerView::updateRubberBandRect(
QPointF &
pos,
const bool constrainSquare,
const bool fromCenter )
1326 if ( !mRubberBandItem )
1336 double dx = pos.
x() - mRubberBandStartPos.
x();
1337 double dy = pos.
y() - mRubberBandStartPos.
y();
1339 if ( constrainSquare )
1341 if ( fabs( dx ) > fabs( dy ) )
1348 height = fabs( dy );
1352 x = mRubberBandStartPos.
x() - (( dx < 0 ) ? width : 0 );
1353 y = mRubberBandStartPos.
y() - (( dy < 0 ) ? height : 0 );
1365 x = mRubberBandStartPos.
x();
1376 y = mRubberBandStartPos.
y();
1383 x = mRubberBandStartPos.
x() -
width;
1384 y = mRubberBandStartPos.
y() -
height;
1389 mRubberBandItem->
setRect( 0, 0, width, height );
1395 void QgsComposerView::updateRubberBandLine(
QPointF pos,
const bool constrainAngles )
1397 if ( !mRubberBandLineItem )
1405 QLineF newLine =
QLineF( mRubberBandStartPos, snappedScenePoint );
1407 if ( constrainAngles )
1414 mRubberBandLineItem->
setLine( newLine );
1421 switch ( mCurrentTool )
1426 if ( mNodesItemIndex != -1 )
1428 mNodesItem =
nullptr;
1429 mNodesItemIndex = -1;
1435 mMoveContentSearchRadius,
1436 mMoveContentSearchRadius );
1437 if ( itemsAtCursorPos.
isEmpty() )
1442 for ( ; itemIter != itemsAtCursorPos.
end(); ++itemIter )
1454 rc = itemP->
addNode( scenePoint );
1473 setSelectedNode( mNodesItem, mNodesItemIndex );
1497 for ( ; itemIt != composerItemList.
end(); ++itemIt )
1505 for ( ; it != groupedItems.
end(); ++it )
1507 ( *it )->writeXML( documentElement, doc );
1510 ( *itemIt )->writeXML( documentElement, doc );
1523 for (
int i = 0; i < composerItemsNodes.
count(); ++i )
1525 QDomNode composerItemNode = composerItemsNodes.
at( i );
1551 if ( docElem.
tagName() ==
"ComposerItemClipboard" )
1585 if ( mNodesItemIndex != -1 )
1588 if ( mNodesItem->
removeNode( mNodesItemIndex ) )
1598 mNodesItemIndex = -1;
1599 mNodesItem =
nullptr;
1615 for ( ; itemIt != composerItemList.
end(); ++itemIt )
1635 for ( ; itemIt != itemList.
end(); ++itemIt )
1639 if ( mypItem && !paperItem )
1675 for ( ; itemIt != itemList.
end(); ++itemIt )
1679 if ( mypItem && !paperItem )
1703 if ( mKeyPanning || mMousePanning || mToolPanning || mMovingItemContent ||
1718 if ( !( e->
modifiers() & Qt::ControlModifier ) && !mMarqueeZoom )
1724 else if ( !( e->
modifiers() & Qt::ControlModifier ) && mMarqueeZoom )
1749 if ( !( e->
modifiers() & Qt::ControlModifier ) )
1753 mMouseLastXY = mMouseCurrentXY;
1766 mPreviousTool = mCurrentTool;
1792 double increment = 1.0;
1793 if ( e->
modifiers() & Qt::ShiftModifier )
1798 else if ( e->
modifiers() & Qt::AltModifier )
1802 if ( viewScale > 0 )
1804 increment = 1 / viewScale;
1808 if ( e->
key() == Qt::Key_Left )
1812 if ( mNodesItemIndex != -1 )
1816 if ( mNodesItem->
nodePosition( mNodesItemIndex, currentPos ) )
1818 currentPos.
setX( currentPos.
x() - increment );
1821 mNodesItem->
moveNode( mNodesItemIndex, currentPos );
1830 for ( ; itemIt != composerItemList.
end(); ++itemIt )
1833 ( *itemIt )->move( -1 * increment, 0.0 );
1834 ( *itemIt )->endCommand();
1838 else if ( e->
key() == Qt::Key_Right )
1842 if ( mNodesItemIndex != -1 )
1846 if ( mNodesItem->
nodePosition( mNodesItemIndex, currentPos ) )
1848 currentPos.
setX( currentPos.
x() + increment );
1851 mNodesItem->
moveNode( mNodesItemIndex, currentPos );
1860 for ( ; itemIt != composerItemList.
end(); ++itemIt )
1863 ( *itemIt )->move( increment, 0.0 );
1864 ( *itemIt )->endCommand();
1868 else if ( e->
key() == Qt::Key_Down )
1872 if ( mNodesItemIndex != -1 )
1876 if ( mNodesItem->
nodePosition( mNodesItemIndex, currentPos ) )
1878 currentPos.
setY( currentPos.
y() + increment );
1881 mNodesItem->
moveNode( mNodesItemIndex, currentPos );
1890 for ( ; itemIt != composerItemList.
end(); ++itemIt )
1893 ( *itemIt )->move( 0.0, increment );
1894 ( *itemIt )->endCommand();
1898 else if ( e->
key() == Qt::Key_Up )
1902 if ( mNodesItemIndex != -1 )
1906 if ( mNodesItem->
nodePosition( mNodesItemIndex, currentPos ) )
1908 currentPos.
setY( currentPos.
y() - increment );
1911 mNodesItem->
moveNode( mNodesItemIndex, currentPos );
1920 for ( ; itemIt != composerItemList.
end(); ++itemIt )
1923 ( *itemIt )->move( 0.0, -1 * increment );
1924 ( *itemIt )->endCommand();
1935 mKeyPanning =
false;
1938 if ( mCurrentTool !=
Pan )
1980 if ( mRubberBandItem || mRubberBandLineItem )
1986 if (
composition()->selectionHandles()->isDragging() ||
composition()->selectionHandles()->isResizing() )
2001 if ( theItem->isSelected() )
2012 double zoomFactor = settings.
value(
"/qgis/zoom_factor", 2.0 ).
toDouble();
2013 if ( event->
modifiers() & Qt::ControlModifier )
2016 zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 20.0;
2018 zoomFactor =
event->delta() > 0 ? zoomFactor : 1 / zoomFactor;
2020 QPointF itemPoint = theItem->mapFromScene( scenePoint );
2022 theItem->zoomContent( zoomFactor, itemPoint, zoomMode );
2023 theItem->endCommand();
2038 double zoomFactor = mySettings.
value(
"/qgis/zoom_factor", 2 ).
toDouble();
2040 if ( event->
modifiers() & Qt::ControlModifier )
2043 zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 10.0;
2047 bool zoomIn =
event->delta() > 0;
2048 double scaleFactor = ( zoomIn ? 1 / zoomFactor : zoomFactor );
2059 QgsPoint newCenter( scenePoint.
x() + (( oldCenter.x() - scenePoint.
x() ) * scaleFactor ),
2060 scenePoint.
y() + (( oldCenter.y() - scenePoint.
y() ) * scaleFactor ) );
2061 centerOn( newCenter.x(), newCenter.y() );
2080 for ( ; itemIt != itemList.
end(); ++itemIt )
2094 if (( dpi < 60 ) || ( dpi > 250 ) )
2109 scale *= currentScale;
2116 if ( !mPreviewEffect )
2126 if ( !mPreviewEffect )
2131 mPreviewEffect->
setMode( mode );
2136 if ( mPaintingEnabled )
2175 if ( mHorizontalRuler )
2179 if ( mVerticalRuler )
2232 for ( ; itemIter != selectionList.
end(); ++itemIter )
2246 if ( !currentObject )
2248 return qobject_cast<
QMainWindow *>( currentObject );
2253 composerObject = qobject_cast<
QMainWindow*>( currentObject );
2254 if ( composerObject || !currentObject->
parent() )
2256 return composerObject;
2258 currentObject = currentObject->
parent();
2264 void QgsComposerView::addPolygonNode(
const QPointF & scenePoint )
2269 if ( polygon.
size() == 1 )
2272 mPolygonItem.
data()->setPolygon( polygon );
2275 void QgsComposerView::movePolygonNode(
const QPointF & scenePoint )
2279 if ( polygon.
size() > 0 )
2281 polygon.
replace( polygon.
size() - 1, scenePoint );
2282 mPolygonItem.
data()->setPolygon( polygon );
2286 void QgsComposerView::displayNodes(
const bool display )
2292 for ( ; it != nodesShapes.
end(); ++it )
2293 ( *it )->setDisplayNodes( display );
2305 for ( ; it != nodesShapes.
end(); ++it )
2307 if (( *it ) == shape )
2309 ( *it )->setSelectedNode( index );
2311 ( *it )->setSelected(
true );
2315 ( *it )->unselectNode();
2321 void QgsComposerView::unselectNode()
2327 for ( ; it != nodesShapes.
end(); ++it )
2328 ( *it )->unselectNode();
bool moveNode(const int index, const QPointF &node)
Move a node to a new position.
QgsComposerMouseHandles::MouseAction mouseActionForScenePos(QPointF sceneCoordPos)
Finds out which mouse move action to choose depending on the scene cursor position.
virtual void mouseMoveEvent(QMouseEvent *event)
int selectedNode()
Returns the currently selected node.
void setSceneRect(const QRectF &rectangle) override
Adapts mMaximumNumberOfFeatures depending on the rectangle height.
void setShapeType(QgsComposerShape::Shape s)
Item representing the paper.
An abstract composer item that provides generic methods for nodes based shapes such as polygon or pol...
A scale bar item that can be added to a map composition.
QUndoStack * undoStack()
Returns pointer to undo/redo command storage.
QgsComposerItemGroup * groupItems(QList< QgsComposerItem *> items)
Creates a new group from a list of composer items and adds it to the composition. ...
A rectangle specified with double values.
Qt::KeyboardModifiers modifiers() const
QgsPoint center() const
Center point of the rectangle.
void setAllUnselected()
Clears any selected items in the composition.
QByteArray data(const QString &mimeType) const
Composer item for polylines.
QMainWindow * composerWindow()
Returns the composer main window.
void composerItems(QList< T *> &itemList)
Return composer items of a specific type.
bool removeNode(const int index)
Remove a node from the shape.
int nodeAtPosition(QPointF node, const bool searchInRadius=true, const double radius=10)
Search the nearest node in shape within a maximal area.
An item that draws an arrow between two points.
const char * zoom_in[]
Bitmap cursors for map operations.
QList< QGraphicsItem * > items() const
const QMimeData * mimeData(Mode mode) const
QDomNode appendChild(const QDomNode &newChild)
void addItemsFromXML(const QDomElement &elem, const QDomDocument &doc, QMap< QgsComposerMap *, int > *mapsToRestore=nullptr, bool addUndoCommands=false, QPointF *pos=nullptr, bool pasteInPlace=false)
Add items from XML representation to the graphics scene (for project file reading, pasting items from clipboard)
void centerOn(const QPointF &pos)
void append(const T &value)
void keyPressEvent(QKeyEvent *e) override
void zoomLevelChanged()
Is emitted when the view zoom changes.
void selectAll()
Selects all items.
void setOffset(double xOffset, double yOffset)
Sets offset values to shift image (useful for live updates when moving item content) ...
QList< QGraphicsItem * > items() const
void setFrameShape(Shape)
void selectInvert()
Inverts current selection.
ZoomMode
Modes for zooming item content.
void setComposerMap(const QgsComposerMap *map)
Sets the composer map to use to limit the extent of features shown in the attribute table...
void updateRulers()
Update rulers with current scene rect.
void applyDefaultSize(ScaleBarUnits u=Meters)
Apply default size (scale bar 1/5 of map item width)
QgsComposerMouseHandles * selectionHandles()
Returns pointer to selection handles.
QPointF mapToScene(const QPoint &point) const
void mousePressEvent(QMouseEvent *) override
const T & at(int i) const
void mouseReleaseEvent(QMouseEvent *) override
void addComposerScaleBar(QgsComposerScaleBar *scaleBar)
Adds scale bar to the graphics scene and advises composer to create a widget for it (through signal) ...
A item that forms part of a map composition.
void scale(double scaleFactor, const QgsPoint *c=nullptr)
Scale the rectangle around its center point.
void pushAddRemoveCommand(QgsComposerItem *item, const QString &text, const QgsAddRemoveItemCommand::State state=QgsAddRemoveItemCommand::Added)
Convenience function to create a QgsAddRemoveItemCommand, connect its signals and push it to the undo...
void setZoomLevel(double zoomLevel)
Set zoom level, where a zoom level of 1.0 corresponds to 100%.
virtual void mouseReleaseEvent(QMouseEvent *event)
A container for grouping several QgsComposerItems.
void deleteSelectedItems()
Deletes selected items.
virtual void setSelected(bool s)
Set selected, selected item should be highlighted.
bool isDragging()
Returns true is user is currently dragging the handles.
void setComposition(QgsComposition *c)
MouseAction
Describes the action (move or resize in different directon) to be done during mouse move...
QDomElement documentElement() const
void updateCachedImage()
Forces an update of the cached map image.
void setComposerMap(const QgsComposerMap *map)
Sets the composer map to use to limit the extent of features shown in the attribute table...
void setCurrentTool(QgsComposerView::Tool t)
void groupItems()
Add an item group containing the selected items.
bool isAutoRepeat() const
const QPoint & pos() const
QGraphicsScene * scene() const
void updateLegend()
Updates the model and all legend entries.
void selectNone()
Deselects all items.
void setEnabled(bool enable)
QString tr(const char *sourceText, const char *disambiguation, int n)
QList< const QgsComposerMap * > composerMapItems() const
Returns pointers to all composer maps in the scene.
void update(const QRectF &rect)
A table that displays attributes from a vector layer.
void composerViewHide(QgsComposerView *)
Emitted before composerview is hidden.
A graphics effect which can be applied to a widget to simulate various printing and color blindness m...
void setRect(const QRectF &rectangle)
void compositionSet(QgsComposition *)
Emitted when the composition is set for the view.
A composer class that displays svg files or raster format (jpg, png, ...)
bool isResizing()
Returns true is user is currently resizing with the handles.
void endMultiFrameCommand()
QSet< QgsComposerItem * > items()
QDomElement toElement() const
void addComposerShape(QgsComposerShape *shape)
Adds a composer shape to the graphics scene and advises composer to create a widget for it (through s...
void scale(qreal sx, qreal sy)
virtual void moveContent(double dx, double dy)
Move Content of item.
void showEvent(QShowEvent *e) override
void wheelEvent(QWheelEvent *event) override
void addPolygon(const QPolygonF &polygon)
void paintEvent(QPaintEvent *event) override
int toInt(bool *ok) const
void removeItem(QGraphicsItem *item)
void cancelCommand()
Deletes current command.
void setPreventCursorChange(const bool preventChange)
If true, prevents any mouse cursor changes by the composition or by any composer items Used by QgsCom...
bool addNode(const QPointF &pt, const bool checkArea=true, const double radius=10)
Add a node in current shape.
virtual bool event(QEvent *event)
void setUseSymbolV2(bool useSymbolV2)
Controls whether the shape should be drawn using a QgsFillSymbolV2.
void endCommand()
Saves end state of item and pushes command to the undo history.
virtual bool selected() const
Is selected.
void setResizeAnchor(ViewportAnchor anchor)
void setAngle(qreal angle)
bool nodePosition(const int index, QPointF &position)
Gets the position of a node in scene coordinate.
QDomNodeList elementsByTagName(const QString &tagname) const
void addFrame(QgsComposerFrame *frame, bool recalcFrameSizes=true) override
Adds a frame to the multiframe.
void selectedItemChanged(QgsComposerItem *selected)
Is emitted when selected item changed.
void scaleSafe(double scale)
Scales the view in a safe way, by limiting the acceptable range of the scale applied.
void setLine(const QLineF &line)
void setSceneTransform(const QTransform &transform)
void setComposerMap(const QgsComposerMap *map)
QList< QgsComposerItem * > ungroupItems(QgsComposerItemGroup *group)
Ungroups items by removing them from an item group and removing the group from the composition...
Widget to display the composer items.
void setScene(QGraphicsScene *scene)
void removeComposerItem(QgsComposerItem *item, const bool createCommand=true, const bool removeGroupItems=true)
Remove item from the graphics scene.
void setPreviewModeEnabled(bool enabled)
Sets whether a preview effect should be used to alter the view's appearance.
void setMimeData(QMimeData *src, Mode mode)
void pasteItems(PasteMode mode)
Pastes items from clipboard.
void setMode(PreviewMode mode)
Sets the mode for the preview effect, which controls how the effect modifies a widgets appearance...
A class to represent a point.
Graphics scene for map printing.
Object representing map window.
Frame item for a composer multiframe item.
QgsComposerItem * composerItemAt(QPointF position, const bool ignoreLocked=false) const
Returns the topmost composer item at a specified position.
QgsComposerView(QWidget *parent=nullptr, const char *name=nullptr, const Qt::WindowFlags &f=nullptr)
double ANALYSIS_EXPORT angle(Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
void setComposerMap(const QgsComposerMap *map)
void ungroupItems()
Ungroups the selected items.
virtual void mousePressEvent(QMouseEvent *event)
void copyItems(ClipboardMode mode)
Cuts or copies the selected items.
virtual void paintEvent(QPaintEvent *event)
void addComposerPolyline(QgsComposerPolyline *polyline)
Adds a composer polyline and advises composer to create a widget for it (through signal) ...
QVariant value(const QString &key, const QVariant &defaultValue) const
virtual void addFrame(QgsComposerFrame *frame, bool recalcFrameSizes=true) override
Adds a frame to the multiframe.
A table class that displays a vector attribute table.
void setPreviewMode(QgsPreviewEffect::PreviewMode mode)
Sets the preview mode which should be used to modify the view's appearance.
QRectF toRectF() const
returns a QRectF with same coordinates.
A composer items that draws common shapes (ellipse, triangle, rectangle)
void setPen(const QPen &pen)
Composer item for polygons.
QDesktopWidget * desktop()
PreviewMode previewMode() const
void resizeEvent(QResizeEvent *event) override
QPointF snapPointToGrid(QPointF scenePoint) const
Snaps a scene coordinate point to grid.
void cursorPosChanged(QPointF)
Is emitted when mouse cursor coordinates change.
void setComposition(QgsComposition *c)
Sets the composition for the view.
void addComposerMap(QgsComposerMap *map, const bool setDefaultPreviewStyle=true)
Adds map to the graphics scene and advises composer to create a widget for it (through signal) ...
void update(qreal x, qreal y, qreal w, qreal h)
virtual void setSceneRect(const QRectF &rectangle)
Sets this items bound in scene coordinates such that 1 item size units corresponds to 1 scene size un...
void keyReleaseEvent(QKeyEvent *e) override
int count(const T &value) const
int nodesSize()
Returns the number of nodes in the shape.
void setText(const QString &text)
void setSceneRect(const QRectF &rectangle) override
Sets this items bound in scene coordinates such that 1 item size units corresponds to 1 scene size un...
void replace(int i, const T &value)
A label that can be placed onto a map composition.
static double snappedAngle(const double angle)
Snaps an angle to its closest 45 degree angle.
void addComposerPicture(QgsComposerPicture *picture)
Adds picture to the graphics scene and advises composer to create a widget for it (through signal) ...
double toDouble(bool *ok) const
void hideEvent(QHideEvent *e) override
void addComposerTable(QgsComposerAttributeTable *table)
Adds a composer table to the graphics scene and advises composer to create a widget for it (through s...
void removeAttribute(const QString &name)
QgsComposerView::Tool currentTool() const
void updateMarker(QPointF pos)
void setSceneRect(const QRectF &rectangle) override
Sets this items bound in scene coordinates such that 1 item size units corresponds to 1 scene size un...
void setData(const QString &mimeType, const QByteArray &data)
QgsComposition * composition()
Returns the composition or 0 in case of error.
const QPoint & pos() const
void setBrush(const QBrush &brush)
QDomElement createElement(const QString &tagName)
bool positionLock() const
Returns whether position lock for mouse drags is enabled returns true if item is locked for mouse mov...
void addComposerPolygon(QgsComposerPolygon *polygon)
Adds a composer polygon and advises composer to create a widget for it (through signal) ...
void addItem(QGraphicsItem *item)
const char * cross_hair_cursor[]
void actionFinished()
Current action (e.g.
void mouseMoveEvent(QMouseEvent *) override
A legend that can be placed onto a map composition.
void addComposerLabel(QgsComposerLabel *label)
Adds label to the graphics scene and advises composer to create a widget for it (through signal) ...
void addComposerArrow(QgsComposerArrow *arrow)
Adds an arrow item to the graphics scene and advises composer to create a widget for it (through sign...
void addComposerLegend(QgsComposerLegend *legend)
Adds legend to the graphics scene and advises composer to create a widget for it (through signal) ...
virtual void scrollContentsBy(int dx, int dy)
void push(QUndoCommand *cmd)
void adjustSizeToText()
Resizes the widget such that the text fits to the item.
QByteArray toByteArray(int indent) const
virtual int type() const override
Return correct graphics item type.
bool setContent(const QByteArray &data, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn)
QDomNode at(int index) const
void fitInView(const QRectF &rect, Qt::AspectRatioMode aspectRatioMode)
void composerViewShow(QgsComposerView *)
Emitted before composerview is shown.
void beginCommand(QgsComposerItem *item, const QString &commandText, const QgsComposerMergeCommand::Context c=QgsComposerMergeCommand::Unknown)
Allocates new item command and saves initial state in it.
void scrollContentsBy(int dx, int dy) override
QList< QgsComposerItem * > selectedComposerItems(const bool includeLockedItems=true)
Returns list of selected composer items.
void mouseDoubleClickEvent(QMouseEvent *e) override
virtual void resizeEvent(QResizeEvent *event)
void beginMultiFrameCommand(QgsComposerMultiFrame *multiFrame, const QString &text, const QgsComposerMultiFrameMergeCommand::Context c=QgsComposerMultiFrameMergeCommand::Unknown)