[QGIS Commit] r9531 -
branches/advanced_printing_branch2/src/core/composer
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Fri Oct 24 07:49:51 EDT 2008
Author: mhugent
Date: 2008-10-24 07:49:51 -0400 (Fri, 24 Oct 2008)
New Revision: 9531
Added:
branches/advanced_printing_branch2/src/core/composer/qgspaperitem.cpp
branches/advanced_printing_branch2/src/core/composer/qgspaperitem.h
Log:
Add missing files to svn
Added: branches/advanced_printing_branch2/src/core/composer/qgspaperitem.cpp
===================================================================
--- branches/advanced_printing_branch2/src/core/composer/qgspaperitem.cpp (rev 0)
+++ branches/advanced_printing_branch2/src/core/composer/qgspaperitem.cpp 2008-10-24 11:49:51 UTC (rev 9531)
@@ -0,0 +1,88 @@
+/***************************************************************************
+ qgspaperitem.cpp
+ -------------------
+ begin : September 2008
+ copyright : (C) 2008 by Marco Hugentobler
+ email : marco dot hugentobler at karto dot baug dot ethz dot ch
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "qgspaperitem.h"
+#include <QPainter>
+
+QgsPaperItem::QgsPaperItem(QgsComposition* c): QgsComposerItem(c, false)
+{
+ setZValue(0);
+}
+
+QgsPaperItem::QgsPaperItem( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition ): QgsComposerItem(x, y, width, height, composition, false)
+{
+ setZValue(0);
+}
+
+QgsPaperItem::QgsPaperItem(): QgsComposerItem(0, false)
+{
+
+}
+
+QgsPaperItem::~QgsPaperItem()
+{
+
+}
+
+void QgsPaperItem::paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
+{
+ if ( !painter )
+ {
+ return;
+ }
+
+ drawBackground( painter );
+
+ //draw grid
+
+ if(mComposition)
+ {
+ if(mComposition->snapToGridEnabled() && mComposition->plotStyle() == QgsComposition::Preview
+ && mComposition->snapGridResolution() > 0)
+ {
+ QPen pen(QColor(100, 100, 100));
+ pen.setWidthF(0.3);
+ painter->setPen(pen);
+
+ //draw vertical lines
+ int gridMultiplyX = (int)(mComposition->snapGridOffsetX() / mComposition->snapGridResolution());
+ double currentXCoord = mComposition->snapGridOffsetX() - gridMultiplyX * mComposition->snapGridResolution();
+ for(; currentXCoord <= rect().width(); currentXCoord += mComposition->snapGridResolution())
+ {
+ painter->drawLine(QPointF(currentXCoord, 0), QPointF(currentXCoord, rect().height()));
+ }
+
+ //draw horizontal lines
+ int gridMultiplyY = (int)(mComposition->snapGridOffsetY() / mComposition->snapGridResolution());
+ double currentYCoord = mComposition->snapGridOffsetY() - gridMultiplyY * mComposition->snapGridResolution();
+ for(; currentYCoord <= rect().height(); currentYCoord += mComposition->snapGridResolution())
+ {
+ painter->drawLine(QPointF(0, currentYCoord), QPointF(rect().width(), currentYCoord));
+ }
+ }
+ }
+}
+
+bool QgsPaperItem::writeXML( QDomElement& elem, QDomDocument & doc )
+{
+ return true;
+}
+
+bool QgsPaperItem::readXML( const QDomElement& itemElem, const QDomDocument& doc )
+{
+ return true;
+}
Added: branches/advanced_printing_branch2/src/core/composer/qgspaperitem.h
===================================================================
--- branches/advanced_printing_branch2/src/core/composer/qgspaperitem.h (rev 0)
+++ branches/advanced_printing_branch2/src/core/composer/qgspaperitem.h 2008-10-24 11:49:51 UTC (rev 9531)
@@ -0,0 +1,50 @@
+/***************************************************************************
+ qgspaperitem.h
+ -------------------
+ begin : September 2008
+ copyright : (C) 2008 by Marco Hugentobler
+ email : marco dot hugentobler at karto dot baug dot ethz dot ch
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef QGSPAPERITEM_H
+#define QGSPAPERITEM_H
+
+#include "qgscomposeritem.h"
+
+/**Item representing the paper. May draw the snapping grid lines if composition is in
+ preview mode*/
+class QgsPaperItem: public QgsComposerItem
+{
+ public:
+ QgsPaperItem(QgsComposition* c);
+ QgsPaperItem( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition );
+ ~QgsPaperItem();
+
+ /** \brief Reimplementation of QCanvasItem::paint*/
+ void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
+
+ /** stores state in Dom node
+ * @param node is Dom node corresponding to 'Composer' tag
+ * @param temp write template file
+ */
+ bool writeXML( QDomElement& elem, QDomDocument & doc );
+
+ /** sets state from Dom document
+ * @param itemElem is Dom node corresponding to item tag
+ */
+ bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
+
+ private:
+ QgsPaperItem();
+};
+
+#endif
More information about the QGIS-commit
mailing list