Skip to content
Permalink
Browse files
Merge composer ruler branch
  • Loading branch information
mhugent committed Mar 24, 2013
2 parents 920036e + 56b55a0 commit eb95e5036afb9e1c01c0094081624caf6598be14
Showing with 619 additions and 26 deletions.
  1. +40 −21 src/app/composer/qgscomposer.cpp
  2. +9 −0 src/app/composer/qgscomposer.h
  3. +1 −0 src/app/composer/qgscomposerhtmlwidget.cpp
  4. +1 −0 src/app/composer/qgscomposerlabelwidget.cpp
  5. +1 −0 src/app/composer/qgscomposerlegendwidget.cpp
  6. +1 −0 src/app/composer/qgscomposermanager.cpp
  7. +1 −0 src/app/composer/qgscomposermapwidget.cpp
  8. +1 −0 src/app/composer/qgscomposerpicturewidget.cpp
  9. +1 −0 src/app/composer/qgscomposerscalebarwidget.cpp
  10. +7 −0 src/app/qgisapp.cpp
  11. +1 −0 src/core/composer/qgsaddremoveitemcommand.cpp
  12. +1 −0 src/core/composer/qgsatlascomposition.cpp
  13. +1 −0 src/core/composer/qgscomposerarrow.cpp
  14. +2 −0 src/core/composer/qgscomposerarrow.h
  15. +1 −0 src/core/composer/qgscomposerframe.cpp
  16. +2 −3 src/core/composer/qgscomposeritem.h
  17. +1 −0 src/core/composer/qgscomposerlabel.cpp
  18. +1 −0 src/core/composer/qgscomposerlabel.h
  19. +1 −0 src/core/composer/qgscomposerlegend.cpp
  20. +1 −0 src/core/composer/qgscomposermap.cpp
  21. +1 −0 src/core/composer/qgscomposermap.h
  22. +1 −0 src/core/composer/qgscomposermultiframe.cpp
  23. +1 −0 src/core/composer/qgscomposerpicture.cpp
  24. +2 −0 src/core/composer/qgscomposerpicture.h
  25. +1 −0 src/core/composer/qgscomposerscalebar.cpp
  26. +1 −0 src/core/composer/qgscomposerscalebar.h
  27. +2 −0 src/core/composer/qgscomposershape.h
  28. +1 −0 src/core/composer/qgscomposertable.h
  29. +164 −1 src/core/composer/qgscomposition.cpp
  30. +15 −1 src/core/composer/qgscomposition.h
  31. +1 −0 src/core/composer/qgspaperitem.cpp
  32. +1 −0 src/gui/CMakeLists.txt
  33. +245 −0 src/gui/qgscomposerruler.cpp
  34. +48 −0 src/gui/qgscomposerruler.h
  35. +47 −0 src/gui/qgscomposerview.cpp
  36. +13 −0 src/gui/qgscomposerview.h
@@ -20,6 +20,7 @@

#include "qgisapp.h"
#include "qgsapplication.h"
#include "qgscomposerruler.h"
#include "qgscomposerview.h"
#include "qgscomposition.h"
#include "qgscompositionwidget.h"
@@ -269,8 +270,22 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
setMouseTracking( true );
mViewFrame->setMouseTracking( true );

//create composer view
mView = new QgsComposerView( mViewFrame );
//create composer view and layout with rulers
mView = 0;
mViewLayout = new QGridLayout();
mViewLayout->setSpacing( 0 );
mViewLayout->setMargin( 0 );
mHorizontalRuler = new QgsComposerRuler( QgsComposerRuler::Horizontal );
mVerticalRuler = new QgsComposerRuler( QgsComposerRuler::Vertical );
QWidget* fake = new QWidget();
fake->setAttribute( Qt::WA_NoMousePropagation );
fake->setBackgroundRole( QPalette::Window );
fake->setFixedSize( 20, 20 );
mViewLayout->addWidget( fake, 0, 0 );
mViewLayout->addWidget( mHorizontalRuler, 0, 1 );
mViewLayout->addWidget( mVerticalRuler, 1, 0 );
createComposerView();
mViewFrame->setLayout( mViewLayout );

//init undo/redo buttons
mComposition = new QgsComposition( mQgis->mapCanvas()->mapRenderer() );
@@ -340,10 +355,6 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )

mGeneralDock->raise();

QGridLayout *l = new QGridLayout( mViewFrame );
l->setMargin( 0 );
l->addWidget( mView, 0, 0 );

// Create size grip (needed by Mac OS X for QMainWindow if QStatusBar is not visible)
mSizeGrip = new QSizeGrip( this );
mSizeGrip->resize( mSizeGrip->sizeHint() );
@@ -455,6 +466,10 @@ void QgsComposer::open( void )
mFirstTime = false;
show();
zoomFull(); // zoomFull() does not work properly until we have called show()
if ( mView )
{
mView->updateRulers();
}
}

else
@@ -578,20 +593,23 @@ void QgsComposer::zoomFull( void )
void QgsComposer::on_mActionZoomAll_triggered()
{
zoomFull();
mView->updateRulers();
mView->update();
emit zoomLevelChanged();
}

void QgsComposer::on_mActionZoomIn_triggered()
{
mView->scale( 2, 2 );
mView->updateRulers();
mView->update();
emit zoomLevelChanged();
}

void QgsComposer::on_mActionZoomOut_triggered()
{
mView->scale( .5, .5 );
mView->updateRulers();
mView->update();
emit zoomLevelChanged();
}
@@ -1781,21 +1799,11 @@ void QgsComposer::readXML( const QDomElement& composerElem, const QDomDocument&
}
}

//delete composer view and composition
delete mView;
mView = 0;
//delete every child of mViewFrame
QObjectList viewFrameChildren = mViewFrame->children();
QObjectList::iterator it = viewFrameChildren.begin();
for ( ; it != viewFrameChildren.end(); ++it )
{
delete( *it );
}
//delete composition widget
QgsCompositionWidget* oldCompositionWidget = qobject_cast<QgsCompositionWidget *>( mGeneralDock->widget() );
delete oldCompositionWidget;

mView = new QgsComposerView( mViewFrame );
createComposerView();

//read composition settings
mComposition = new QgsComposition( mQgis->mapCanvas()->mapRenderer() );
@@ -1808,10 +1816,6 @@ void QgsComposer::readXML( const QDomElement& composerElem, const QDomDocument&

connectSlots();

QGridLayout *l = new QGridLayout( mViewFrame );
l->setMargin( 0 );
l->addWidget( mView, 0, 0 );

//create compositionwidget
QgsCompositionWidget* compositionWidget = new QgsCompositionWidget( mGeneralDock, mComposition );
QObject::connect( mComposition, SIGNAL( paperSizeChanged() ), compositionWidget, SLOT( displayCompositionWidthHeight() ) );
@@ -2179,3 +2183,18 @@ QMenu* QgsComposer::mirrorOtherMenu( QMenu* otherMenu )
}
return newMenu;
}

void QgsComposer::createComposerView()
{
if ( !mViewLayout )
{
return;
}

delete mView;
mView = new QgsComposerView();
mView->setContentsMargins( 0, 0, 0, 0 );
mView->setHorizontalRuler( mHorizontalRuler );
mView->setVerticalRuler( mVerticalRuler );
mViewLayout->addWidget( mView, 1, 1 );
}
@@ -24,10 +24,13 @@

class QgisApp;
class QgsComposerArrow;
class QgsComposerFrame;
class QgsComposerHtml;
class QgsComposerLabel;
class QgsComposerLegend;
class QgsComposerPicture;
class QgsComposerPictureWidget;
class QgsComposerRuler;
class QgsComposerScaleBar;
class QgsComposerShape;
class QgsComposerAttributeTable;
@@ -331,11 +334,17 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
//! To make loading from project faster, the previews are generated when the composer becomes visible.
void initialiseComposerPicturePreviews();

//! Create composer view and rulers
void createComposerView();

/**Composer title*/
QString mTitle;

//! Pointer to composer view
QgsComposerView *mView;
QGridLayout* mViewLayout;
QgsComposerRuler* mHorizontalRuler;
QgsComposerRuler* mVerticalRuler;

//! Current composition
QgsComposition *mComposition;
@@ -17,6 +17,7 @@
#include "qgscomposeritemwidget.h"
#include "qgscomposermultiframecommand.h"
#include "qgscomposerhtml.h"
#include "qgscomposition.h"
#include <QFileDialog>
#include <QSettings>

@@ -18,6 +18,7 @@
#include "qgscomposerlabelwidget.h"
#include "qgscomposerlabel.h"
#include "qgscomposeritemwidget.h"
#include "qgscomposition.h"
#include "qgsexpressionbuilderdialog.h"

#include <QColorDialog>
@@ -22,6 +22,7 @@
#include "qgscomposerlegendlayersdialog.h"
#include "qgscomposeritemwidget.h"
#include "qgscomposermap.h"
#include "qgscomposition.h"
#include <QFontDialog>
#include <QColorDialog>

@@ -18,6 +18,7 @@
#include "qgisapp.h"
#include "qgsapplication.h"
#include "qgscomposer.h"
#include "qgscomposition.h"
#include "qgslogger.h"

#include <QDesktopServices>
@@ -17,6 +17,7 @@

#include "qgscomposermapwidget.h"
#include "qgscomposeritemwidget.h"
#include "qgscomposition.h"
#include "qgsmaprenderer.h"
#include "qgsstylev2.h"
#include "qgssymbolv2.h"
@@ -20,6 +20,7 @@
#include "qgscomposermap.h"
#include "qgscomposerpicture.h"
#include "qgscomposeritemwidget.h"
#include "qgscomposition.h"
#include <QDoubleValidator>
#include <QFileDialog>
#include <QFileInfo>
@@ -18,6 +18,7 @@
#include "qgscomposeritemwidget.h"
#include "qgscomposermap.h"
#include "qgscomposerscalebar.h"
#include "qgscomposition.h"
#include <QColorDialog>
#include <QFontDialog>
#include <QWidget>
@@ -69,6 +69,7 @@

#include <qgsnetworkaccessmanager.h>
#include <qgsapplication.h>
#include <qgscomposition.h>

#include <QNetworkReply>
#include <QNetworkProxy>
@@ -109,6 +110,7 @@
#include "qgsclipboard.h"
#include "qgscomposer.h"
#include "qgscomposermanager.h"
#include "qgscomposerview.h"
#include "qgsconfigureshortcutsdialog.h"
#include "qgscoordinatetransform.h"
#include "qgscredentialdialog.h"
@@ -4787,6 +4789,11 @@ bool QgisApp::loadComposersFromProject( const QDomDocument& doc )
composer->show();
#endif
composer->zoomFull();
QgsComposerView* composerView = composer->view();
if ( composerView )
{
composerView->updateRulers();
}
if ( composerNodes.at( i ).toElement().attribute( "visible", "1" ).toInt() < 1 )
{
composer->close();
@@ -17,6 +17,7 @@

#include "qgsaddremoveitemcommand.h"
#include "qgscomposeritem.h"
#include "qgscomposition.h"

QgsAddRemoveItemCommand::QgsAddRemoveItemCommand( State s, QgsComposerItem* item, QgsComposition* c, const QString& text, QUndoCommand* parent ):
QUndoCommand( text, parent ), mItem( item ), mComposition( c ), mState( s ), mFirstRun( true )
@@ -19,6 +19,7 @@
#include "qgsatlascomposition.h"
#include "qgsvectorlayer.h"
#include "qgscomposermap.h"
#include "qgscomposition.h"
#include "qgsvectordataprovider.h"
#include "qgsexpression.h"
#include "qgsgeometry.h"
@@ -16,6 +16,7 @@
***************************************************************************/

#include "qgscomposerarrow.h"
#include "qgscomposition.h"
#include <QPainter>
#include <QSvgRenderer>

@@ -19,6 +19,8 @@
#define QGSCOMPOSERARROW_H

#include "qgscomposeritem.h"
#include <QBrush>
#include <QPen>

/**An item that draws an arrow between to points*/
class CORE_EXPORT QgsComposerArrow: public QgsComposerItem
@@ -15,6 +15,7 @@

#include "qgscomposerframe.h"
#include "qgscomposermultiframe.h"
#include "qgscomposition.h"

QgsComposerFrame::QgsComposerFrame( QgsComposition* c, QgsComposerMultiFrame* mf, qreal x, qreal y, qreal width, qreal height )
: QgsComposerItem( x, y, width, height, c )
@@ -17,17 +17,16 @@
#ifndef QGSCOMPOSERITEM_H
#define QGSCOMPOSERITEM_H

#include "qgscomposition.h"
#include "qgscomposeritemcommand.h"
#include <QGraphicsRectItem>
#include <QObject>

class QgsComposition;
class QWidget;
class QDomDocument;
class QDomElement;
class QGraphicsLineItem;

class QqsComposition;

/** \ingroup MapComposer
* A item that forms part of a map composition.
*/
@@ -16,6 +16,7 @@
***************************************************************************/

#include "qgscomposerlabel.h"
#include "qgscomposition.h"
#include "qgsexpression.h"
#include <QCoreApplication>
#include <QDate>
@@ -18,6 +18,7 @@
#define QGSCOMPOSERLABEL_H

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

class QgsVectorLayer;
class QgsFeature;
@@ -19,6 +19,7 @@
#include "qgscomposerlegend.h"
#include "qgscomposerlegenditem.h"
#include "qgscomposermap.h"
#include "qgscomposition.h"
#include "qgslogger.h"
#include "qgsmaplayer.h"
#include "qgsmaplayerregistry.h"
@@ -16,6 +16,7 @@
***************************************************************************/

#include "qgscomposermap.h"
#include "qgscomposition.h"
#include "qgscoordinatetransform.h"
#include "qgslogger.h"
#include "qgsmaprenderer.h"
@@ -20,6 +20,7 @@
//#include "ui_qgscomposermapbase.h"
#include "qgscomposeritem.h"
#include "qgsrectangle.h"
#include <QFont>
#include <QGraphicsRectItem>

class QgsComposition;
@@ -15,6 +15,7 @@

#include "qgscomposermultiframe.h"
#include "qgscomposerframe.h"
#include "qgscomposition.h"

QgsComposerMultiFrame::QgsComposerMultiFrame( QgsComposition* c, bool createUndoCommands ): mComposition( c ), mResizeMode( UseExistingFrames ), mCreateUndoCommands( createUndoCommands )
{
@@ -17,6 +17,7 @@

#include "qgscomposerpicture.h"
#include "qgscomposermap.h"
#include "qgscomposition.h"
#include "qgsproject.h"
#include <QDomDocument>
#include <QDomElement>
@@ -22,6 +22,8 @@
#include <QImage>
#include <QSvgRenderer>

class QgsComposerMap;

/** \ingroup MapComposer
* A composer class that displays svg files or raster format (jpg, png, ...)
* */
@@ -16,6 +16,7 @@

#include "qgscomposerscalebar.h"
#include "qgscomposermap.h"
#include "qgscomposition.h"
#include "qgsdistancearea.h"
#include "qgsscalebarstyle.h"
#include "qgsdoubleboxscalebarstyle.h"
@@ -17,6 +17,7 @@
#define QGSCOMPOSERSCALEBAR_H

#include "qgscomposeritem.h"
#include <QFont>
#include <QPen>
#include <QColor>

@@ -19,6 +19,8 @@
#define QGSCOMPOSERSHAPE_H

#include "qgscomposeritem.h"
#include <QBrush>
#include <QPen>

/**A composer items that draws common shapes (ellipse, triangle, rectangle)*/
class CORE_EXPORT QgsComposerShape: public QgsComposerItem

0 comments on commit eb95e50

Please sign in to comment.