1 change: 1 addition & 0 deletions src/core/composer/qgscomposertable.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define QGSCOMPOSERTABLE_H

#include "qgscomposeritem.h"
#include "qgscomposition.h"
#include "qgsfeature.h"
#include <QSet>

Expand Down
165 changes: 164 additions & 1 deletion src/core/composer/qgscomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <stdexcept>

#include "qgscomposition.h"
#include "qgscomposeritem.h"
#include "qgscomposerarrow.h"
#include "qgscomposerframe.h"
#include "qgscomposerhtml.h"
Expand Down Expand Up @@ -355,6 +354,19 @@ bool QgsComposition::writeXML( QDomElement& composerElem, QDomDocument& doc )
compositionElem.setAttribute( "snapGridOffsetX", QString::number( mSnapGridOffsetX ) );
compositionElem.setAttribute( "snapGridOffsetY", QString::number( mSnapGridOffsetY ) );

//custom snap lines
QList< QGraphicsLineItem* >::const_iterator snapLineIt = mSnapLines.constBegin();
for ( ; snapLineIt != mSnapLines.constEnd(); ++snapLineIt )
{
QDomElement snapLineElem = doc.createElement( "SnapLine" );
QLineF line = ( *snapLineIt )->line();
snapLineElem.setAttribute( "x1", QString::number( line.x1() ) );
snapLineElem.setAttribute( "y1", QString::number( line.y1() ) );
snapLineElem.setAttribute( "x2", QString::number( line.x2() ) );
snapLineElem.setAttribute( "y2", QString::number( line.y2() ) );
compositionElem.appendChild( snapLineElem );
}

compositionElem.setAttribute( "printResolution", mPrintResolution );
compositionElem.setAttribute( "printAsRaster", mPrintAsRaster );

Expand Down Expand Up @@ -424,6 +436,19 @@ bool QgsComposition::readXML( const QDomElement& compositionElem, const QDomDocu
mSnapGridOffsetX = compositionElem.attribute( "snapGridOffsetX" ).toDouble();
mSnapGridOffsetY = compositionElem.attribute( "snapGridOffsetY" ).toDouble();

//custom snap lines
QDomNodeList snapLineNodes = compositionElem.elementsByTagName( "SnapLine" );
for ( int i = 0; i < snapLineNodes.size(); ++i )
{
QDomElement snapLineElem = snapLineNodes.at( i ).toElement();
QGraphicsLineItem* snapItem = addSnapLine();
double x1 = snapLineElem.attribute( "x1" ).toDouble();
double y1 = snapLineElem.attribute( "y1" ).toDouble();
double x2 = snapLineElem.attribute( "x2" ).toDouble();
double y2 = snapLineElem.attribute( "y2" ).toDouble();
snapItem->setLine( x1, y1, x2, y2 );
}

mAlignmentSnap = compositionElem.attribute( "alignmentSnap", "1" ).toInt() == 0 ? false : true;
mAlignmentSnapTolerance = compositionElem.attribute( "alignmentSnapTolerance", "2.0" ).toDouble();

Expand Down Expand Up @@ -1199,6 +1224,126 @@ QPointF QgsComposition::alignPos( const QPointF& pos, const QgsComposerItem* exc
return result;
}

QGraphicsLineItem* QgsComposition::addSnapLine()
{
QGraphicsLineItem* item = new QGraphicsLineItem();
QPen linePen( Qt::SolidLine );
linePen.setColor( Qt::red );
linePen.setWidthF( 0.5 );
item->setPen( linePen );
item->setZValue( 100 );
addItem( item );
mSnapLines.push_back( item );
return item;
}

void QgsComposition::removeSnapLine( QGraphicsLineItem* line )
{
removeItem( line );
mSnapLines.removeAll( line );
delete line;
}

void QgsComposition::setSnapLinesVisible( bool visible )
{
QList< QGraphicsLineItem* >::iterator it = mSnapLines.begin();
for ( ; it != mSnapLines.end(); ++it )
{
if ( visible )
{
( *it )->show();
}
else
{
( *it )->hide();
}
}
}

QGraphicsLineItem* QgsComposition::nearestSnapLine( bool horizontal, double x, double y, double tolerance,
QList< QPair< QgsComposerItem*, QgsComposerItem::ItemPositionMode> >& snappedItems )
{
double minSqrDist = DBL_MAX;
QGraphicsLineItem* item = 0;
double currentXCoord = 0;
double currentYCoord = 0;
double currentSqrDist = 0;
double sqrTolerance = tolerance * tolerance;

snappedItems.clear();

QList< QGraphicsLineItem* >::const_iterator it = mSnapLines.constBegin();
for ( ; it != mSnapLines.constEnd(); ++it )
{
bool itemHorizontal = doubleNear(( *it )->line().y2() - ( *it )->line().y1(), 0 );
if ( horizontal && itemHorizontal )
{
currentYCoord = ( *it )->line().y1();
currentSqrDist = ( y - currentYCoord ) * ( y - currentYCoord );
}
else if ( !itemHorizontal )
{
currentXCoord = ( *it )->line().x1();
currentSqrDist = ( x - currentXCoord ) * ( x - currentXCoord );
}

if ( currentSqrDist < minSqrDist && currentSqrDist < sqrTolerance )
{
item = *it;
minSqrDist = currentSqrDist;
}
}

double itemTolerance = 0.0000001;
if ( item )
{
//go through all the items to find items snapped to this snap line
QList<QGraphicsItem *> itemList = items();
QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
for ( ; itemIt != itemList.end(); ++itemIt )
{
QgsComposerItem* currentItem = dynamic_cast<QgsComposerItem*>( *itemIt );
if ( !currentItem || currentItem->type() == QgsComposerItem::ComposerPaper )
{
continue;
}

if ( horizontal )
{
if ( doubleNear( currentYCoord, currentItem->transform().dy() + currentItem->rect().top(), itemTolerance ) )
{
snappedItems.append( qMakePair( currentItem, QgsComposerItem::UpperMiddle ) );
}
else if ( doubleNear( currentYCoord, currentItem->transform().dy() + currentItem->rect().center().y(), itemTolerance ) )
{
snappedItems.append( qMakePair( currentItem, QgsComposerItem::Middle ) );
}
else if ( doubleNear( currentYCoord, currentItem->transform().dy() + currentItem->rect().bottom(), itemTolerance ) )
{
snappedItems.append( qMakePair( currentItem, QgsComposerItem::LowerMiddle ) );
}
}
else
{
if ( doubleNear( currentXCoord, currentItem->transform().dx(), itemTolerance ) )
{
snappedItems.append( qMakePair( currentItem, QgsComposerItem::MiddleLeft ) );
}
else if ( doubleNear( currentXCoord, currentItem->transform().dx() + currentItem->rect().center().x(), itemTolerance ) )
{
snappedItems.append( qMakePair( currentItem, QgsComposerItem::Middle ) );
}
else if ( doubleNear( currentXCoord, currentItem->transform().dx() + currentItem->rect().width(), itemTolerance ) )
{
snappedItems.append( qMakePair( currentItem, QgsComposerItem::MiddleRight ) );
}
}
}
}

return item;
}

int QgsComposition::boundingRectOfSelectedItems( QRectF& bRect )
{
QList<QgsComposerItem*> selectedItems = selectedComposerItems();
Expand Down Expand Up @@ -1841,7 +1986,9 @@ void QgsComposition::renderPage( QPainter* p, int page )
QgsComposition::PlotStyle savedPlotStyle = mPlotStyle;
mPlotStyle = QgsComposition::Print;

setSnapLinesVisible( false );
render( p, QRectF( 0, 0, paintDevice->width(), paintDevice->height() ), paperRect );
setSnapLinesVisible( true );

mPlotStyle = savedPlotStyle;
}
Expand Down Expand Up @@ -1882,6 +2029,22 @@ void QgsComposition::collectAlignCoordinates( QMap< double, const QgsComposerIte
alignCoordsY.insert( currentItem->transform().dy() + currentItem->rect().bottom(), currentItem );
}
}

//arbitrary snap lines
QList< QGraphicsLineItem* >::const_iterator sIt = mSnapLines.constBegin();
for ( ; sIt != mSnapLines.constEnd(); ++sIt )
{
double x = ( *sIt )->line().x1();
double y = ( *sIt )->line().y1();
if ( doubleNear( y, 0.0 ) )
{
alignCoordsX.insert( x, 0 );
}
else
{
alignCoordsY.insert( y, 0 );
}
}
}

void QgsComposition::checkNearestItem( double checkCoord, const QMap< double, const QgsComposerItem* >& alignCoords, double& smallestDiff,
Expand Down
16 changes: 15 additions & 1 deletion src/core/composer/qgscomposition.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@
#ifndef QGSCOMPOSITION_H
#define QGSCOMPOSITION_H

#include "qgscomposeritem.h"
#include <memory>

#include <QDomDocument>
#include <QGraphicsScene>
#include <QLinkedList>
#include <QList>
#include <QPair>
#include <QSet>
#include <QUndoStack>
#include <QPrinter>
Expand All @@ -32,7 +35,6 @@

class QgisApp;
class QgsComposerFrame;
class QgsComposerItem;
class QgsComposerMap;
class QgsPaperItem;
class QGraphicsRectItem;
Expand Down Expand Up @@ -273,6 +275,15 @@ class CORE_EXPORT QgsComposition: public QGraphicsScene
@return snapped position or original position if no snap*/
QPointF alignPos( const QPointF& pos, const QgsComposerItem* excludeItem, double& alignX, double& alignY );

/**Add a custom snap line (can be horizontal or vertical)*/
QGraphicsLineItem* addSnapLine();
/**Remove custom snap line (and delete the object)*/
void removeSnapLine( QGraphicsLineItem* line );
/**Get nearest snap line*/
QGraphicsLineItem* nearestSnapLine( bool horizontal, double x, double y, double tolerance, QList< QPair< QgsComposerItem*, QgsComposerItem::ItemPositionMode > >& snappedItems );
/**Hides / shows custom snap lines*/
void setSnapLinesVisible( bool visible );

/**Allocates new item command and saves initial state in it
@param item target item
@param commandText descriptive command text
Expand Down Expand Up @@ -383,6 +394,9 @@ class CORE_EXPORT QgsComposition: public QGraphicsScene
bool mAlignmentSnap;
double mAlignmentSnapTolerance;

/**Arbitraty snap lines (horizontal and vertical)*/
QList< QGraphicsLineItem* > mSnapLines;

QUndoStack mUndoStack;

QgsComposerItemCommand* mActiveItemCommand;
Expand Down
1 change: 1 addition & 0 deletions src/core/composer/qgspaperitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
***************************************************************************/

#include "qgspaperitem.h"
#include "qgscomposition.h"
#include <QPainter>

QgsPaperItem::QgsPaperItem( QgsComposition* c ): QgsComposerItem( c, false )
Expand Down
1 change: 1 addition & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ qgscharacterselectdialog.cpp
qgscolorbutton.cpp
qgscolordialog.cpp
qgscomposerview.cpp
qgscomposerruler.cpp
qgscursors.cpp
qgsdetaileditemdelegate.cpp
qgsdetaileditemwidget.cpp
Expand Down
245 changes: 245 additions & 0 deletions src/gui/qgscomposerruler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
#include "qgscomposerruler.h"
#include "qgscomposition.h"
#include "qgis.h"
#include <QDragEnterEvent>
#include <QGraphicsLineItem>
#include <QPainter>
#include <cmath>

const int RULER_MIN_SIZE = 20;

QgsComposerRuler::QgsComposerRuler( QgsComposerRuler::Direction d ): QWidget( 0 ), mDirection( d ), mComposition( 0 ), mLineSnapItem( 0 )
{
setMouseTracking( true );
}

QgsComposerRuler::~QgsComposerRuler()
{
}

QSize QgsComposerRuler::minimumSizeHint() const
{
return QSize( RULER_MIN_SIZE, RULER_MIN_SIZE );
}

void QgsComposerRuler::paintEvent( QPaintEvent* event )
{
Q_UNUSED( event );
if ( !mComposition )
{
return;
}

QPainter p( this );

QTransform t = mTransform.inverted();

//find optimal ruler display scale (steps of 1, 10 or 50)
double pixelDiff1 = mTransform.map( QPointF( 1, 0 ) ).x() - mTransform.map( QPointF( 0, 0 ) ).x();
double pixelDiff10 = mTransform.map( QPointF( 10, 0 ) ).x() - mTransform.map( QPointF( 0, 0 ) ).x();
//double pixelDiff50 = mTransform.map( QPointF( 50, 0 ) ).x() - mTransform.map( QPointF( 5, 0 ) ).x();

double mmDisplay = 50.0;
if ( pixelDiff1 > 25 )
{
mmDisplay = 1.0;
}
else if ( pixelDiff10 > 25 )
{
mmDisplay = 10.0;
}

if ( mDirection == Horizontal )
{
if ( doubleNear( width(), 0 ) )
{
return;
}

//start x-coordinate
double startX = t.map( QPointF( 0, 0 ) ).x();
double endX = t.map( QPointF( width(), 0 ) ).x();

double markerPos = ( floor( startX / mmDisplay ) + 1 ) * mmDisplay; //marker position in mm
while ( markerPos <= endX )
{
if ( markerPos >= 0 && markerPos <= mComposition->paperWidth() ) //todo: need to know paper size
{
double pixelCoord = mTransform.map( QPointF( markerPos, 0 ) ).x();
p.drawLine( pixelCoord, 0, pixelCoord, RULER_MIN_SIZE );
p.drawText( QPointF( pixelCoord + 2, RULER_MIN_SIZE / 2.0 ), QString::number(( int )( markerPos ) ) );
}
markerPos += mmDisplay;
}

p.setPen( QColor( Qt::red ) );
p.drawLine( mMarkerPos.x(), 0, mMarkerPos.x(), RULER_MIN_SIZE );
}
else //vertical
{
if ( doubleNear( height(), 0 ) )
{
return;
}

double startY = t.map( QPointF( 0, 0 ) ).y(); //start position in mm (total including space between pages)
double endY = t.map( QPointF( 0, height() ) ).y(); //stop position in mm (total including space between pages)
int startPage = ( int )( startY / ( mComposition->paperHeight() + mComposition->spaceBetweenPages() ) );
if ( startPage < 0 )
{
startPage = 0;
}
int endPage = ( int )( endY / ( mComposition->paperHeight() + mComposition->spaceBetweenPages() ) );
if ( endPage > ( mComposition->numPages() - 1 ) )
{
endPage = mComposition->numPages() - 1;
}

for ( int i = startPage; i <= endPage; ++i )
{
double pageCoord = 0; //page coordinate in mm
//total (composition) coordinate in mm, including space between pages
double totalCoord = i * ( mComposition->paperHeight() + mComposition->spaceBetweenPages() );
while ( pageCoord < mComposition->paperHeight() )
{
if ( totalCoord > endY )
{
break;
}
double pixelCoord = mTransform.map( QPointF( 0, totalCoord ) ).y();
p.drawLine( 0, pixelCoord, RULER_MIN_SIZE, pixelCoord );
p.drawText( QPointF( 0, pixelCoord - 2.0 ), QString::number( pageCoord ) );
pageCoord += mmDisplay;
totalCoord += mmDisplay;
}
}

p.setPen( QColor( Qt::red ) );
p.drawLine( 0, mMarkerPos.y(), RULER_MIN_SIZE, mMarkerPos.y() );
}
}

void QgsComposerRuler::setSceneTransform( const QTransform& transform )
{
QString debug = QString::number( transform.dx() ) + "," + QString::number( transform.dy() ) + ","
+ QString::number( transform.m11() ) + "," + QString::number( transform.m22() );
mTransform = transform;
update();
}

void QgsComposerRuler::mouseMoveEvent( QMouseEvent* event )
{
//qWarning( "QgsComposerRuler::mouseMoveEvent" );
updateMarker( event->posF() );
setSnapLinePosition( event->posF() );
}

void QgsComposerRuler::mouseReleaseEvent( QMouseEvent* event )
{
Q_UNUSED( event );

//remove snap line if coordinate under 0
QPointF pos = mTransform.inverted().map( event->pos() );
bool removeItem = false;
if ( mDirection == Horizontal )
{
removeItem = pos.x() < 0 ? true : false;
}
else
{
removeItem = pos.y() < 0 ? true : false;
}

if ( removeItem )
{
mComposition->removeSnapLine( mLineSnapItem );
mSnappedItems.clear();
}
mLineSnapItem = 0;
}

void QgsComposerRuler::mousePressEvent( QMouseEvent* event )
{
double x = 0;
double y = 0;
if ( mDirection == Horizontal )
{
x = mTransform.inverted().map( event->pos() ).x();
}
else //vertical
{
y = mTransform.inverted().map( event->pos() ).y();
}

//horizontal ruler means vertical snap line
QGraphicsLineItem* line = mComposition->nearestSnapLine( mDirection != Horizontal, x, y, 10.0, mSnappedItems );
if ( !line )
{
//create new snap line
mLineSnapItem = mComposition->addSnapLine();
}
else
{
mLineSnapItem = line;
}
}

void QgsComposerRuler::setSnapLinePosition( const QPointF& pos )
{
if ( !mLineSnapItem || !mComposition )
{
return;
}

QPointF transformedPt = mTransform.inverted().map( pos );
if ( mDirection == Horizontal )
{
int numPages = mComposition->numPages();
double lineHeight = numPages * mComposition->paperHeight();
if ( numPages > 1 )
{
lineHeight += ( numPages - 1 ) * mComposition->spaceBetweenPages();
}
mLineSnapItem->setLine( QLineF( transformedPt.x(), 0, transformedPt.x(), lineHeight ) );
}
else //vertical
{
mLineSnapItem->setLine( QLineF( 0, transformedPt.y(), mComposition->paperWidth(), transformedPt.y() ) );
}

//move snapped items together with the snap line
QList< QPair< QgsComposerItem*, QgsComposerItem::ItemPositionMode > >::iterator itemIt = mSnappedItems.begin();
for ( ; itemIt != mSnappedItems.end(); ++itemIt )
{
if ( mDirection == Horizontal )
{
if ( itemIt->second == QgsComposerItem::MiddleLeft )
{
itemIt->first->setItemPosition( transformedPt.x(), itemIt->first->transform().dy(), QgsComposerItem::UpperLeft );
}
else if ( itemIt->second == QgsComposerItem::Middle )
{
itemIt->first->setItemPosition( transformedPt.x(), itemIt->first->transform().dy(), QgsComposerItem::UpperMiddle );
}
else
{
itemIt->first->setItemPosition( transformedPt.x(), itemIt->first->transform().dy(), QgsComposerItem::UpperRight );
}
}
else
{
if ( itemIt->second == QgsComposerItem::UpperMiddle )
{
itemIt->first->setItemPosition( itemIt->first->transform().dx(), transformedPt.y(), QgsComposerItem::UpperLeft );
}
else if ( itemIt->second == QgsComposerItem::Middle )
{
itemIt->first->setItemPosition( itemIt->first->transform().dx(), transformedPt.y(), QgsComposerItem::MiddleLeft );
}
else
{
itemIt->first->setItemPosition( itemIt->first->transform().dx(), transformedPt.y(), QgsComposerItem::LowerLeft );
}
}
}
}
48 changes: 48 additions & 0 deletions src/gui/qgscomposerruler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#ifndef QGSCOMPOSERRULER_H
#define QGSCOMPOSERRULER_H

#include "qgscomposeritem.h"
#include <QWidget>
class QgsComposition;
class QGraphicsLineItem;

/**A class to show paper scale and the current cursor position*/
class QgsComposerRuler: public QWidget
{
public:
enum Direction
{
Horizontal = 0,
Vertical
};

QgsComposerRuler( QgsComposerRuler::Direction d );
~QgsComposerRuler();

QSize minimumSizeHint() const;

void setSceneTransform( const QTransform& transform );
void updateMarker( const QPointF& pos ) { mMarkerPos = pos; repaint(); }

void setComposition( QgsComposition* c ) { mComposition = c; }
QgsComposition* composition() { return mComposition; }

protected:
void paintEvent( QPaintEvent* event );
void mouseMoveEvent( QMouseEvent* event );
void mouseReleaseEvent( QMouseEvent* event );
void mousePressEvent( QMouseEvent* event );

private:
Direction mDirection;
QTransform mTransform;
QPointF mMarkerPos;
QgsComposition* mComposition; //reference to composition for paper size, nPages
QGraphicsLineItem* mLineSnapItem;
//items snapped to the current snap line
QList< QPair< QgsComposerItem*, QgsComposerItem::ItemPositionMode > > mSnappedItems;

void setSnapLinePosition( const QPointF& pos );
};

#endif // QGSCOMPOSERRULER_H
47 changes: 47 additions & 0 deletions src/gui/qgscomposerview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <QKeyEvent>
#include <QClipboard>
#include <QMimeData>
#include <QGridLayout>

#include "qgscomposerview.h"
#include "qgscomposerarrow.h"
Expand All @@ -31,6 +32,7 @@
#include "qgscomposermap.h"
#include "qgscomposeritemgroup.h"
#include "qgscomposerpicture.h"
#include "qgscomposerruler.h"
#include "qgscomposerscalebar.h"
#include "qgscomposershape.h"
#include "qgscomposerattributetable.h"
Expand All @@ -43,13 +45,16 @@ QgsComposerView::QgsComposerView( QWidget* parent, const char* name, Qt::WFlags
, mRubberBandLineItem( 0 )
, mMoveContentItem( 0 )
, mPaintingEnabled( true )
, mHorizontalRuler( 0 )
, mVerticalRuler( 0 )
{
Q_UNUSED( f );
Q_UNUSED( name );

setResizeAnchor( QGraphicsView::AnchorViewCenter );
setMouseTracking( true );
viewport()->setMouseTracking( true );
setFrameShape( QFrame::NoFrame );
}

void QgsComposerView::mousePressEvent( QMouseEvent* e )
Expand Down Expand Up @@ -238,6 +243,18 @@ void QgsComposerView::addShape( Tool currentTool )
}
}

void QgsComposerView::updateRulers()
{
if ( mHorizontalRuler )
{
mHorizontalRuler->setSceneTransform( viewportTransform() );
}
if ( mVerticalRuler )
{
mVerticalRuler->setSceneTransform( viewportTransform() );
}
}

void QgsComposerView::mouseReleaseEvent( QMouseEvent* e )
{
if ( !composition() )
Expand Down Expand Up @@ -350,6 +367,16 @@ void QgsComposerView::mouseMoveEvent( QMouseEvent* e )
return;
}

updateRulers();
if ( mHorizontalRuler )
{
mHorizontalRuler->updateMarker( e->posF() );
}
if ( mVerticalRuler )
{
mVerticalRuler->updateMarker( e->posF() );
}

if ( e->buttons() == Qt::NoButton )
{
if ( mCurrentTool == Select )
Expand Down Expand Up @@ -616,9 +643,29 @@ void QgsComposerView::showEvent( QShowEvent* e )
e->ignore();
}

void QgsComposerView::resizeEvent( QResizeEvent* event )
{
QGraphicsView::resizeEvent( event );
updateRulers();
}

void QgsComposerView::scrollContentsBy( int dx, int dy )
{
QGraphicsView::scrollContentsBy( dx, dy );
updateRulers();
}

void QgsComposerView::setComposition( QgsComposition* c )
{
setScene( c );
if ( mHorizontalRuler )
{
mHorizontalRuler->setComposition( c );
}
if ( mVerticalRuler )
{
mVerticalRuler->setComposition( c );
}
}

QgsComposition* QgsComposerView::composition()
Expand Down
13 changes: 13 additions & 0 deletions src/gui/qgscomposerview.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class QgsComposerLabel;
class QgsComposerLegend;
class QgsComposerMap;
class QgsComposerPicture;
class QgsComposerRuler;
class QgsComposerScaleBar;
class QgsComposerShape;
class QgsComposerAttributeTable;
Expand Down Expand Up @@ -89,6 +90,12 @@ class GUI_EXPORT QgsComposerView: public QGraphicsView
void setPaintingEnabled( bool enabled ) { mPaintingEnabled = enabled; }
bool paintingEnabled() const { return mPaintingEnabled; }

/**Update rulers with current scene rect*/
void updateRulers();

void setHorizontalRuler( QgsComposerRuler* r ){ mHorizontalRuler = r; }
void setVerticalRuler( QgsComposerRuler* r ){ mVerticalRuler = r; }

protected:
void mousePressEvent( QMouseEvent* );
void mouseReleaseEvent( QMouseEvent* );
Expand All @@ -104,6 +111,9 @@ class GUI_EXPORT QgsComposerView: public QGraphicsView
void hideEvent( QHideEvent* e );
void showEvent( QShowEvent* e );

void resizeEvent( QResizeEvent* event );
void scrollContentsBy( int dx, int dy );

private:
/**Current composer tool*/
QgsComposerView::Tool mCurrentTool;
Expand All @@ -120,6 +130,9 @@ class GUI_EXPORT QgsComposerView: public QGraphicsView

bool mPaintingEnabled;

QgsComposerRuler* mHorizontalRuler;
QgsComposerRuler* mVerticalRuler;

/** Draw a shape on the canvas */
void addShape( Tool currentTool );

Expand Down