18 #include <QApplication> 19 #include <QMainWindow> 20 #include <QMouseEvent> 24 #include <QGridLayout> 26 #include <QDesktopWidget> 51 : QGraphicsView( parent )
52 , mCurrentTool( Select )
53 , mPreviousTool( Select )
54 , mRubberBandItem( 0 )
55 , mRubberBandLineItem( 0 )
56 , mMoveContentItem( 0 )
57 , mMarqueeSelect( false )
58 , mMarqueeZoom( false )
60 , mPaintingEnabled( true )
61 , mHorizontalRuler( 0 )
63 , mToolPanning( false )
64 , mMousePanning( false )
65 , mKeyPanning( false )
66 , mMovingItemContent( false )
72 setResizeAnchor( QGraphicsView::AnchorViewCenter );
73 setMouseTracking(
true );
74 viewport()->setMouseTracking(
true );
75 setFrameShape( QFrame::NoFrame );
78 viewport()->setGraphicsEffect( mPreviewEffect );
96 viewport()->setCursor( defaultCursorForTool(
Pan ) );
104 viewport()->setCursor( defaultCursorForTool(
Zoom ) );
123 viewport()->setCursor( defaultCursorForTool( mCurrentTool ) );
130 viewport()->setCursor( Qt::ArrowCursor );
142 if ( mRubberBandItem || mRubberBandLineItem || mKeyPanning || mMousePanning || mToolPanning || mMovingItemContent )
154 QPointF scenePoint = mapToScene( e->pos() );
156 mMousePressStartPos = e->pos();
158 if ( e->button() == Qt::RightButton )
164 else if ( e->button() == Qt::MidButton )
167 mMousePanning =
true;
168 mMouseLastXY = e->pos();
174 viewport()->setCursor( Qt::ClosedHandCursor );
178 switch ( mCurrentTool )
184 if (
composition()->selectionHandles()->isVisible() )
192 QGraphicsView::mousePressEvent( e );
200 if ( e->modifiers() & Qt::ControlModifier )
205 if ( selectedItems.size() > 0 )
207 previousSelectedItem = selectedItems.at( 0 );
211 if ( previousSelectedItem )
232 startMarqueeSelect( scenePoint );
236 if (( !selectedItem->
selected() ) &&
237 !( e->modifiers() & Qt::ShiftModifier ) )
242 if (( e->modifiers() & Qt::ShiftModifier ) && ( selectedItem->
selected() ) )
249 if ( selectedItems.size() > 0 )
257 QGraphicsView::mousePressEvent( e );
265 if ( !( e->modifiers() & Qt::ShiftModifier ) )
268 startMarqueeZoom( scenePoint );
273 double scaleFactor = 2;
275 QRect viewportRect( 0, 0, viewport()->width(), viewport()->height() );
279 QPointF scenePoint = mapToScene( e->pos() );
281 visibleRect.
scale( scaleFactor, scenePoint.x(), scenePoint.y() );
282 QRectF boundsRect = visibleRect.
toRectF();
285 fitInView( boundsRect, Qt::KeepAspectRatio );
294 mMouseLastXY = e->pos();
295 viewport()->setCursor( Qt::ClosedHandCursor );
302 QList<QGraphicsItem *> itemsAtCursorPos = items( e->pos() );
303 if ( itemsAtCursorPos.size() == 0 )
311 QList<QGraphicsItem*>::iterator itemIter = itemsAtCursorPos.begin();
312 for ( ; itemIter != itemsAtCursorPos.end(); ++itemIter )
318 mMoveContentStartPos = scenePoint;
319 mMoveContentItem = item;
320 mMovingItemContent =
true;
332 mRubberBandStartPos = QPointF( snappedScenePoint.x(), snappedScenePoint.y() );
333 mRubberBandLineItem =
new QGraphicsLineItem( snappedScenePoint.x(), snappedScenePoint.y(), snappedScenePoint.x(), snappedScenePoint.y() );
334 mRubberBandLineItem->setPen( QPen( QBrush( QColor( 227, 22, 22, 200 ) ), 0 ) );
335 mRubberBandLineItem->setZValue( 1000 );
336 scene()->addItem( mRubberBandLineItem );
354 mRubberBandItem =
new QGraphicsRectItem( 0, 0, 0, 0 );
355 mRubberBandItem->setBrush( Qt::NoBrush );
356 mRubberBandItem->setPen( QPen( QBrush( QColor( 227, 22, 22, 200 ) ), 0 ) );
357 mRubberBandStartPos = QPointF( snappedScenePoint.x(), snappedScenePoint.y() );
358 t.translate( snappedScenePoint.x(), snappedScenePoint.y() );
359 mRubberBandItem->setTransform( t );
360 mRubberBandItem->setZValue( 1000 );
361 scene()->addItem( mRubberBandItem );
370 newScaleBar->
setSceneRect( QRectF( snappedScenePoint.x(), snappedScenePoint.y(), 20, 20 ) );
373 if ( mapItemList.size() > 0 )
395 switch ( currentTool )
398 return Qt::ArrowCursor;
402 QPixmap myZoomQPixmap = QPixmap((
const char ** )(
zoom_in ) );
403 return QCursor( myZoomQPixmap, 7, 7 );
407 return Qt::OpenHandCursor;
410 return Qt::ArrowCursor;
426 return QCursor( myCrosshairQPixmap, 8, 8 );
429 return Qt::ArrowCursor;
441 if ( !mRubberBandItem || ( mRubberBandItem->rect().width() < 0.1 && mRubberBandItem->rect().height() < 0.1 ) )
466 if ( mHorizontalRuler )
470 if ( mVerticalRuler )
476 void QgsComposerView::removeRubberBand()
478 if ( mRubberBandItem )
480 scene()->removeItem( mRubberBandItem );
481 delete mRubberBandItem;
486 void QgsComposerView::startMarqueeSelect( QPointF & scenePoint )
488 mMarqueeSelect =
true;
491 mRubberBandItem =
new QGraphicsRectItem( 0, 0, 0, 0 );
492 mRubberBandItem->setBrush( QBrush( QColor( 224, 178, 76, 63 ) ) );
493 mRubberBandItem->setPen( QPen( QBrush( QColor( 254, 58, 29, 100 ) ), 0, Qt::DotLine ) );
494 mRubberBandStartPos = QPointF( scenePoint.x(), scenePoint.y() );
495 t.translate( scenePoint.x(), scenePoint.y() );
496 mRubberBandItem->setTransform( t );
497 mRubberBandItem->setZValue( 1000 );
498 scene()->addItem( mRubberBandItem );
502 void QgsComposerView::endMarqueeSelect( QMouseEvent* e )
504 mMarqueeSelect =
false;
506 bool subtractingSelection =
false;
507 if ( e->modifiers() & Qt::ShiftModifier )
511 else if ( e->modifiers() & Qt::ControlModifier )
514 subtractingSelection =
true;
522 if ( !mRubberBandItem || ( mRubberBandItem->rect().width() < 0.1 && mRubberBandItem->rect().height() < 0.1 ) )
529 QRectF boundsRect = QRectF( mRubberBandItem->transform().dx(), mRubberBandItem->transform().dy(),
530 mRubberBandItem->rect().width(), mRubberBandItem->rect().height() );
533 Qt::ItemSelectionMode selectionMode = Qt::IntersectsItemShape;
534 if ( e->modifiers() & Qt::AltModifier )
537 selectionMode = Qt::ContainsItemShape;
541 QList<QGraphicsItem *> itemList =
composition()->items( boundsRect, selectionMode );
542 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
543 for ( ; itemIt != itemList.end(); ++itemIt )
547 if ( mypItem && !paperItem )
551 if ( subtractingSelection )
566 if ( selectedItemList.size() > 0 )
572 void QgsComposerView::startMarqueeZoom( QPointF & scenePoint )
577 mRubberBandItem =
new QGraphicsRectItem( 0, 0, 0, 0 );
578 mRubberBandItem->setBrush( QBrush( QColor( 70, 50, 255, 25 ) ) );
579 mRubberBandItem->setPen( QPen( QColor( 70, 50, 255, 100 ) ) );
580 mRubberBandStartPos = QPointF( scenePoint.x(), scenePoint.y() );
581 t.translate( scenePoint.x(), scenePoint.y() );
582 mRubberBandItem->setTransform( t );
583 mRubberBandItem->setZValue( 1000 );
584 scene()->addItem( mRubberBandItem );
588 void QgsComposerView::endMarqueeZoom( QMouseEvent* e )
590 mMarqueeZoom =
false;
594 if ( !mRubberBandItem || ( mRubberBandItem->rect().width() < 0.1 && mRubberBandItem->rect().height() < 0.1 ) )
597 double scaleFactor = 0.5;
599 QRect viewportRect( 0, 0, viewport()->width(), viewport()->height() );
603 QPointF scenePoint = mapToScene( e->pos() );
605 visibleRect.
scale( scaleFactor, scenePoint.x(), scenePoint.y() );
606 boundsRect = visibleRect.
toRectF();
612 boundsRect = QRectF( mRubberBandItem->transform().dx(), mRubberBandItem->transform().dy(),
613 mRubberBandItem->rect().width(), mRubberBandItem->rect().height() );
618 fitInView( boundsRect, Qt::KeepAspectRatio );
636 if ( e->button() != Qt::LeftButton &&
643 QPoint mousePressStopPoint = e->pos();
644 int diffX = mousePressStopPoint.x() - mMousePressStartPos.x();
645 int diffY = mousePressStopPoint.y() - mMousePressStartPos.y();
648 bool clickOnly =
false;
649 if ( qAbs( diffX ) < 2 && qAbs( diffY ) < 2 )
654 QPointF scenePoint = mapToScene( e->pos() );
656 if ( mMousePanning || mToolPanning )
658 mMousePanning =
false;
659 mToolPanning =
false;
661 if ( clickOnly && e->button() == Qt::MidButton )
666 QRect viewportRect( 0, 0, viewport()->width(), viewport()->height() );
668 visibleRect.
scale( 1, scenePoint.x(), scenePoint.y() );
669 QRectF boundsRect = visibleRect.
toRectF();
672 fitInView( boundsRect, Qt::KeepAspectRatio );
676 if ( mCurrentTool !=
Pan )
684 viewport()->setCursor( defaultCursorForTool( mCurrentTool ) );
688 if ( e->button() != Qt::LeftButton )
693 if ( mMarqueeSelect )
695 endMarqueeSelect( e );
699 switch ( mCurrentTool )
703 QGraphicsView::mouseReleaseEvent( e );
718 if ( mMoveContentItem )
727 double moveX = scenePoint.x() - mMoveContentStartPos.x();
728 double moveY = scenePoint.y() - mMoveContentStartPos.y();
733 mMoveContentItem = 0;
734 mMovingItemContent =
false;
741 scene()->removeItem( mRubberBandLineItem );
742 delete mRubberBandLineItem;
743 mRubberBandLineItem = 0;
755 scene()->removeItem( mRubberBandLineItem );
756 delete mRubberBandLineItem;
757 mRubberBandLineItem = 0;
766 addShape( mCurrentTool );
770 if ( !
composition() || !mRubberBandItem || ( mRubberBandItem->rect().width() < 0.1 && mRubberBandItem->rect().height() < 0.1 ) )
777 QgsComposerMap* composerMap =
new QgsComposerMap(
composition(), mRubberBandItem->transform().dx(), mRubberBandItem->transform().dy(), mRubberBandItem->rect().width(), mRubberBandItem->rect().height() );
791 if ( !
composition() || !mRubberBandItem || ( mRubberBandItem->rect().width() < 0.1 && mRubberBandItem->rect().height() < 0.1 ) )
799 newPicture->
setSceneRect( QRectF( mRubberBandItem->transform().dx(), mRubberBandItem->transform().dy(), mRubberBandItem->rect().width(), mRubberBandItem->rect().height() ) );
825 double labelWidth = qMax( mRubberBandItem->rect().width(), newLabelItem->rect().width() );
826 double labelHeight = qMax( mRubberBandItem->rect().height(), newLabelItem->rect().height() );
827 newLabelItem->
setSceneRect( QRectF( mRubberBandItem->transform().dx(), mRubberBandItem->transform().dy(), labelWidth, labelHeight ) );
851 if ( mapItemList.size() > 0 )
855 newLegend->
setSceneRect( QRectF( mRubberBandItem->transform().dx(), mRubberBandItem->transform().dy(), mRubberBandItem->rect().width(), mRubberBandItem->rect().height() ) );
879 if ( mapItemList.size() > 0 )
883 newTable->
setSceneRect( QRectF( mRubberBandItem->transform().dx(), mRubberBandItem->transform().dy(), mRubberBandItem->rect().width(), mRubberBandItem->rect().height() ) );
907 if ( mapItemList.size() > 0 )
915 mRubberBandItem->transform().dy(), mRubberBandItem->rect().width(),
916 mRubberBandItem->rect().height() );
931 if ( !
composition() || !mRubberBandItem || ( mRubberBandItem->rect().width() < 0.1 && mRubberBandItem->rect().height() < 0.1 ) )
943 mRubberBandItem->transform().dy(), mRubberBandItem->rect().width(),
944 mRubberBandItem->rect().height() );
968 bool shiftModifier =
false;
969 bool altModifier =
false;
970 if ( e->modifiers() & Qt::ShiftModifier )
973 shiftModifier =
true;
975 if ( e->modifiers() & Qt::AltModifier )
981 mMouseCurrentXY = e->pos();
986 if ( mHorizontalRuler )
990 if ( mVerticalRuler )
995 if ( mToolPanning || mMousePanning || mKeyPanning )
998 horizontalScrollBar()->setValue( horizontalScrollBar()->value() - ( e->x() - mMouseLastXY.x() ) );
999 verticalScrollBar()->setValue( verticalScrollBar()->value() - ( e->y() - mMouseLastXY.y() ) );
1000 mMouseLastXY = e->pos();
1003 else if ( e->buttons() == Qt::NoButton )
1005 if ( mCurrentTool ==
Select )
1007 QGraphicsView::mouseMoveEvent( e );
1012 QPointF scenePoint = mapToScene( e->pos() );
1014 if ( mMarqueeSelect || mMarqueeZoom )
1016 updateRubberBandRect( scenePoint );
1020 switch ( mCurrentTool )
1023 QGraphicsView::mouseMoveEvent( e );
1028 updateRubberBandLine( scenePoint, shiftModifier );
1044 updateRubberBandRect( scenePoint, shiftModifier, altModifier );
1054 composerMap->
setOffset( scenePoint.x() - mMoveContentStartPos.x(), scenePoint.y() - mMoveContentStartPos.y() );
1055 composerMap->update();
1065 void QgsComposerView::updateRubberBandRect( QPointF & pos,
const bool constrainSquare,
const bool fromCenter )
1067 if ( !mRubberBandItem )
1077 double dx = pos.x() - mRubberBandStartPos.x();
1078 double dy = pos.y() - mRubberBandStartPos.y();
1080 if ( constrainSquare )
1082 if ( fabs( dx ) > fabs( dy ) )
1089 height = fabs( dy );
1093 x = mRubberBandStartPos.x() - (( dx < 0 ) ? width : 0 );
1094 y = mRubberBandStartPos.y() - (( dy < 0 ) ? height : 0 );
1106 x = mRubberBandStartPos.x();
1117 y = mRubberBandStartPos.y();
1124 x = mRubberBandStartPos.x() - width;
1125 y = mRubberBandStartPos.y() - height;
1130 mRubberBandItem->setRect( 0, 0, width, height );
1132 t.translate( x, y );
1133 mRubberBandItem->setTransform( t );
1136 void QgsComposerView::updateRubberBandLine(
const QPointF &pos,
const bool constrainAngles )
1138 if ( !mRubberBandLineItem )
1146 QLineF newLine = QLineF( mRubberBandStartPos, snappedScenePoint );
1148 if ( constrainAngles )
1152 newLine.setAngle( angle );
1155 mRubberBandLineItem->setLine( newLine );
1171 QList<QgsComposerItem*>::iterator itemIt = composerItemList.begin();
1174 QDomElement documentElement = doc.createElement(
"ComposerItemClipboard" );
1175 for ( ; itemIt != composerItemList.end(); ++itemIt )
1181 QSet<QgsComposerItem*> groupedItems = itemGroup->
items();
1182 QSet<QgsComposerItem*>::iterator it = groupedItems.begin();
1183 for ( ; it != groupedItems.end(); ++it )
1185 ( *it )->writeXML( documentElement, doc );
1188 ( *itemIt )->writeXML( documentElement, doc );
1194 doc.appendChild( documentElement );
1200 QDomNodeList composerItemsNodes = doc.elementsByTagName(
"ComposerItem" );
1201 for (
int i = 0; i < composerItemsNodes.count(); ++i )
1203 QDomNode composerItemNode = composerItemsNodes.at( i );
1204 if ( composerItemNode.isElement() )
1206 composerItemNode.toElement().removeAttribute(
"uuid" );
1211 QMimeData *mimeData =
new QMimeData;
1212 mimeData->setData(
"text/xml", doc.toByteArray() );
1213 QClipboard *clipboard = QApplication::clipboard();
1214 clipboard->setMimeData( mimeData );
1225 QClipboard *clipboard = QApplication::clipboard();
1226 if ( doc.setContent( clipboard->mimeData()->data(
"text/xml" ) ) )
1228 QDomElement docElem = doc.documentElement();
1229 if ( docElem.tagName() ==
"ComposerItemClipboard" )
1237 pt = mapToScene( mapFromGlobal( QCursor::pos() ) );
1242 pt = mapToScene( viewport()->rect().center() );
1262 QList<QgsComposerItem*>::iterator itemIt = composerItemList.begin();
1265 for ( ; itemIt != composerItemList.end(); ++itemIt )
1282 QList<QGraphicsItem *> itemList =
composition()->items();
1283 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
1284 for ( ; itemIt != itemList.end(); ++itemIt )
1288 if ( mypItem && !paperItem )
1322 QList<QGraphicsItem *> itemList =
composition()->items();
1323 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
1324 for ( ; itemIt != itemList.end(); ++itemIt )
1328 if ( mypItem && !paperItem )
1352 if ( mKeyPanning || mMousePanning || mToolPanning || mMovingItemContent ||
1361 if ( e->isAutoRepeat() )
1367 if ( !( e->modifiers() & Qt::ControlModifier ) && !mMarqueeZoom )
1373 else if ( !( e->modifiers() & Qt::ControlModifier ) && mMarqueeZoom )
1383 QPixmap myZoomQPixmap = QPixmap((
const char ** )( e->modifiers() & Qt::ShiftModifier ?
zoom_out :
zoom_in ) );
1384 QCursor zoomCursor = QCursor( myZoomQPixmap, 7, 7 );
1385 viewport()->setCursor( zoomCursor );
1396 if ( e->key() == Qt::Key_Space && ! e->isAutoRepeat() )
1398 if ( !( e->modifiers() & Qt::ControlModifier ) )
1402 mMouseLastXY = mMouseCurrentXY;
1408 viewport()->setCursor( Qt::ClosedHandCursor );
1415 mPreviousTool = mCurrentTool;
1418 QPixmap myZoomQPixmap = QPixmap((
const char ** )( e->modifiers() & Qt::ShiftModifier ?
zoom_out :
zoom_in ) );
1419 QCursor zoomCursor = QCursor( myZoomQPixmap, 7, 7 );
1420 viewport()->setCursor( zoomCursor );
1428 if ( ! e->isAutoRepeat() )
1430 QPixmap myZoomQPixmap = QPixmap((
const char ** )( e->modifiers() & Qt::ShiftModifier ?
zoom_out :
zoom_in ) );
1431 QCursor zoomCursor = QCursor( myZoomQPixmap, 7, 7 );
1432 viewport()->setCursor( zoomCursor );
1438 QList<QgsComposerItem*>::iterator itemIt = composerItemList.begin();
1441 double increment = 1.0;
1442 if ( e->modifiers() & Qt::ShiftModifier )
1447 else if ( e->modifiers() & Qt::AltModifier )
1450 double viewScale = transform().m11();
1451 if ( viewScale > 0 )
1453 increment = 1 / viewScale;
1457 if ( e->key() == Qt::Key_Left )
1459 for ( ; itemIt != composerItemList.end(); ++itemIt )
1462 ( *itemIt )->move( -1 * increment, 0.0 );
1463 ( *itemIt )->endCommand();
1466 else if ( e->key() == Qt::Key_Right )
1468 for ( ; itemIt != composerItemList.end(); ++itemIt )
1471 ( *itemIt )->move( increment, 0.0 );
1472 ( *itemIt )->endCommand();
1475 else if ( e->key() == Qt::Key_Down )
1477 for ( ; itemIt != composerItemList.end(); ++itemIt )
1480 ( *itemIt )->move( 0.0, increment );
1481 ( *itemIt )->endCommand();
1484 else if ( e->key() == Qt::Key_Up )
1486 for ( ; itemIt != composerItemList.end(); ++itemIt )
1489 ( *itemIt )->move( 0.0, -1 * increment );
1490 ( *itemIt )->endCommand();
1497 if ( e->key() == Qt::Key_Space && !e->isAutoRepeat() && mKeyPanning )
1500 mKeyPanning =
false;
1503 if ( mCurrentTool !=
Pan )
1511 viewport()->setCursor( defaultCursorForTool( mCurrentTool ) );
1533 if ( ! e->isAutoRepeat() )
1535 QPixmap myZoomQPixmap = QPixmap((
const char ** )( e->modifiers() & Qt::ShiftModifier ?
zoom_out :
zoom_in ) );
1536 QCursor zoomCursor = QCursor( myZoomQPixmap, 7, 7 );
1537 viewport()->setCursor( zoomCursor );
1545 if ( mRubberBandItem || mRubberBandLineItem )
1551 if (
composition()->selectionHandles()->isDragging() ||
composition()->selectionHandles()->isResizing() )
1561 QPointF scenePoint = mapToScene( event->pos() );
1566 if ( theItem->isSelected() )
1577 double zoomFactor = settings.value(
"/qgis/zoom_factor", 2.0 ).toDouble();
1578 if ( event->modifiers() & Qt::ControlModifier )
1581 zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 20.0;
1583 zoomFactor =
event->delta() > 0 ? zoomFactor : 1 / zoomFactor;
1585 QPointF itemPoint = theItem->mapFromScene( scenePoint );
1587 theItem->zoomContent( zoomFactor, itemPoint, zoomMode );
1588 theItem->endCommand();
1599 void QgsComposerView::wheelZoom( QWheelEvent * event )
1602 QSettings mySettings;
1603 int wheelAction = mySettings.value(
"/qgis/wheel_action", 2 ).toInt();
1604 double zoomFactor = mySettings.value(
"/qgis/zoom_factor", 2 ).toDouble();
1611 if ( event->modifiers() & Qt::ControlModifier )
1614 zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 10.0;
1618 bool zoomIn =
event->delta() > 0;
1619 double scaleFactor = ( zoomIn ? 1 / zoomFactor : zoomFactor );
1622 QRect viewportRect( 0, 0, viewport()->width(), viewport()->height() );
1626 QPointF scenePoint = mapToScene( event->pos() );
1633 centerOn( scenePoint.x(), scenePoint.y() );
1640 QgsPoint newCenter( scenePoint.x() + (( oldCenter.x() - scenePoint.x() ) * scaleFactor ),
1641 scenePoint.y() + (( oldCenter.y() - scenePoint.y() ) * scaleFactor ) );
1642 centerOn( newCenter.x(), newCenter.y() );
1653 scale( zoomFactor, zoomFactor );
1657 scale( 1 / zoomFactor, 1 / zoomFactor );
1665 QList<QGraphicsItem *> itemList =
composition()->items();
1666 QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
1667 for ( ; itemIt != itemList.end(); ++itemIt )
1679 double dpi = QgsApplication::desktop()->logicalDpiX();
1681 if (( dpi < 60 ) || ( dpi > 250 ) )
1685 double scale = zoomLevel * dpi / 25.4;
1686 setTransform( QTransform::fromScale( scale, scale ) );
1695 if ( !mPreviewEffect )
1700 mPreviewEffect->setEnabled( enabled );
1705 if ( !mPreviewEffect )
1710 mPreviewEffect->
setMode( mode );
1715 if ( mPaintingEnabled )
1717 QGraphicsView::paintEvent( event );
1740 QGraphicsView::resizeEvent( event );
1747 QGraphicsView::scrollContentsBy( dx, dy );
1754 if ( mHorizontalRuler )
1758 if ( mVerticalRuler )
1810 QList<QgsComposerItem*>::iterator itemIter = selectionList.begin();
1811 for ( ; itemIter != selectionList.end(); ++itemIter )
1823 QMainWindow* composerObject = 0;
1824 QObject* currentObject = parent();
1825 if ( !currentObject )
1827 return qobject_cast<QMainWindow *>( currentObject );
1832 composerObject = qobject_cast<QMainWindow*>( currentObject );
1833 if ( composerObject || currentObject->parent() == 0 )
1835 return composerObject;
1837 currentObject = currentObject->parent();
bool positionLock() const
Returns whether position lock for mouse drags is enabled returns true if item is locked for mouse mov...
void setSceneRect(const QRectF &rectangle) override
Adapts mMaximumNumberOfFeatures depending on the rectangle height.
void setShapeType(QgsComposerShape::Shape s)
Item representing the paper.
A scale bar item that can be added to a map composition.
QUndoStack * undoStack()
Returns pointer to undo/redo command storage.
QgsComposerItem * composerItemAt(const QPointF &position, const bool ignoreLocked=false) const
Returns the topmost composer item at a specified position.
A rectangle specified with double values.
void setAllUnselected()
Clears any selected items in the composition.
QRectF toRectF() const
returns a QRectF with same coordinates.
QMainWindow * composerWindow()
Returns the composer main window.
An item that draws an arrow between to points.
const char * zoom_in[]
Bitmap cursors for map operations.
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) ...
virtual bool selected() const
Is selected.
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.
void mousePressEvent(QMouseEvent *) override
void mouseReleaseEvent(QMouseEvent *) override
QgsComposerItemGroup * groupItems(QList< QgsComposerItem * > items)
Creates a new group from a list of composer items and adds it to the composition. ...
QList< const QgsComposerMap * > composerMapItems() const
Returns pointers to all composer maps in the scene.
void addComposerScaleBar(QgsComposerScaleBar *scaleBar)
Adds scale bar to the graphics scene and advices composer to create a widget for it (through signal) ...
A item that forms part of a map composition.
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%.
void updateMarker(const QPointF &pos)
QPointF snapPointToGrid(const QPointF &scenePoint) const
Snaps a scene coordinate point to grid.
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...
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.
void updateLegend()
Updates the model and all legend entries.
void selectNone()
Deselects all items.
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 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()
void addComposerShape(QgsComposerShape *shape)
Adds a composer shape to the graphics scene and advices composer to create a widget for it (through s...
virtual void moveContent(double dx, double dy)
Move Content of item.
void showEvent(QShowEvent *e) override
void wheelEvent(QWheelEvent *event) override
void paintEvent(QPaintEvent *event) override
void setPreventCursorChange(const bool preventChange)
If true, prevents any mouse cursor changes by the composition or by any composer items Used by QgsCom...
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.
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 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 removeComposerItem(QgsComposerItem *item, const bool createCommand=true, const bool removeGroupItems=true)
Remove item from the graphics scene.
void beginCommand(const QString &commandText, QgsComposerMergeCommand::Context c=QgsComposerMergeCommand::Unknown)
Starts new composer undo command.
void setPreviewModeEnabled(bool enabled)
Sets whether a preview effect should be used to alter the view's appearance.
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.
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 addItemsFromXML(const QDomElement &elem, const QDomDocument &doc, QMap< QgsComposerMap *, int > *mapsToRestore=0, bool addUndoCommands=false, QPointF *pos=0, bool pasteInPlace=false)
Add items from XML representation to the graphics scene (for project file reading, pasting items from clipboard)
void setComposerMap(const QgsComposerMap *map)
void ungroupItems()
Ungroups the selected items.
PreviewMode previewMode() const
void copyItems(ClipboardMode mode)
Cuts or copies the selected items.
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.
A composer items that draws common shapes (ellipse, triangle, rectangle)
QgsComposerView(QWidget *parent=0, const char *name=0, Qt::WindowFlags f=0)
void resizeEvent(QResizeEvent *event) override
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 advices composer to create a widget for it (through signal) ...
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
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...
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 advices composer to create a widget for it (through signal) ...
void hideEvent(QHideEvent *e) override
void addComposerTable(QgsComposerAttributeTable *table)
Adds a composer table to the graphics scene and advices composer to create a widget for it (through s...
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...
QgsComposition * composition()
Returns the composition or 0 in case of error.
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 advices composer to create a widget for it (through signal) ...
QgsPoint center() const
Center point of the rectangle.
QgsComposerMouseHandles::MouseAction mouseActionForScenePos(const QPointF &sceneCoordPos)
Finds out which mouse move action to choose depending on the scene cursor position.
void addComposerArrow(QgsComposerArrow *arrow)
Adds an arrow item to the graphics scene and advices composer to create a widget for it (through sign...
QgsComposerView::Tool currentTool() const
void addComposerLegend(QgsComposerLegend *legend)
Adds legend to the graphics scene and advices composer to create a widget for it (through signal) ...
void adjustSizeToText()
resizes the widget such that the text fits to the item.
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
void scale(double scaleFactor, const QgsPoint *c=0)
Scale the rectangle around its center point.
void beginMultiFrameCommand(QgsComposerMultiFrame *multiFrame, const QString &text, const QgsComposerMultiFrameMergeCommand::Context c=QgsComposerMultiFrameMergeCommand::Unknown)