4 #include <QDragEnterEvent>
5 #include <QGraphicsLineItem>
13 setMouseTracking(
true );
38 double pixelDiff1 =
mTransform.map( QPointF( 1, 0 ) ).x() -
mTransform.map( QPointF( 0, 0 ) ).x();
39 double pixelDiff10 =
mTransform.map( QPointF( 10, 0 ) ).x() -
mTransform.map( QPointF( 0, 0 ) ).x();
42 double mmDisplay = 50.0;
43 if ( pixelDiff1 > 25 )
47 else if ( pixelDiff10 > 25 )
60 double startX = t.map( QPointF( 0, 0 ) ).x();
61 double endX = t.map( QPointF( width(), 0 ) ).x();
63 double markerPos = ( floor( startX / mmDisplay ) + 1 ) * mmDisplay;
64 while ( markerPos <= endX )
66 if ( markerPos >= 0 && markerPos <= mComposition->paperWidth() )
68 double pixelCoord =
mTransform.map( QPointF( markerPos, 0 ) ).x();
70 p.drawText( QPointF( pixelCoord + 2,
RULER_MIN_SIZE / 2.0 ), QString::number((
int )( markerPos ) ) );
72 markerPos += mmDisplay;
75 p.setPen( QColor( Qt::red ) );
85 double startY = t.map( QPointF( 0, 0 ) ).y();
86 double endY = t.map( QPointF( 0, height() ) ).y();
98 for (
int i = startPage; i <= endPage; ++i )
100 double pageCoord = 0;
103 while ( pageCoord < mComposition->paperHeight() )
105 if ( totalCoord > endY )
109 double pixelCoord =
mTransform.map( QPointF( 0, totalCoord ) ).y();
111 p.drawText( QPointF( 0, pixelCoord - 2.0 ), QString::number( pageCoord ) );
112 pageCoord += mmDisplay;
113 totalCoord += mmDisplay;
117 p.setPen( QColor( Qt::red ) );
124 QString debug = QString::number( transform.dx() ) +
"," + QString::number( transform.dy() ) +
","
125 + QString::number( transform.m11() ) +
"," + QString::number( transform.m22() );
142 QPointF pos =
mTransform.inverted().map( event->pos() );
143 bool removeItem =
false;
146 removeItem = pos.x() < 0 ?
true :
false;
150 removeItem = pos.y() < 0 ?
true :
false;
167 x =
mTransform.inverted().map( event->pos() ).x();
171 y =
mTransform.inverted().map( event->pos() ).y();
194 QPointF transformedPt =
mTransform.inverted().map( pos );
203 mLineSnapItem->setLine( QLineF( transformedPt.x(), 0, transformedPt.x(), lineHeight ) );
211 QList< QPair< QgsComposerItem*, QgsComposerItem::ItemPositionMode > >::iterator itemIt =
mSnappedItems.begin();