Skip to content
Permalink
Browse files

Add composer frame class

  • Loading branch information
mhugent committed Jul 25, 2012
1 parent 5135fe8 commit d413a20174360796f2256de416271eb714190499
@@ -113,6 +113,7 @@ SET(QGIS_CORE_SRCS

composer/qgsaddremoveitemcommand.cpp
composer/qgscomposerarrow.cpp
composer/qgscomposerframe.cpp
composer/qgscomposeritem.cpp
composer/qgscomposeritemcommand.cpp
composer/qgscomposeritemgroup.cpp
@@ -0,0 +1,43 @@
/***************************************************************************
qgscomposerframe.cpp
------------------------------------------------------------
begin : July 2012
copyright : (C) 2012 by Marco Hugentobler
email : marco dot hugentobler at sourcepole 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 "qgscomposerframe.h"
#include "qgscomposermultiframe.h"

QgsComposerFrame::QgsComposerFrame( QgsComposition* c, QgsComposerMultiFrame* mf ): QgsComposerItem( c ), mMultiFrame( mf )
{
}

QgsComposerFrame::~QgsComposerFrame()
{
}

bool QgsComposerFrame::writeXML( QDomElement& elem, QDomDocument & doc ) const
{
return false; //_writeXML( element, doc );
}

bool QgsComposerFrame::readXML( const QDomElement& itemElem, const QDomDocument& doc )
{
return false; //_readXML( element, doc )
}

void QgsComposerFrame::paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
{
if ( mMultiFrame && painter )
{
mMultiFrame->render( painter, mSection );
}
}
@@ -0,0 +1,47 @@
/***************************************************************************
qgscomposerframe.h
------------------------------------------------------------
begin : July 2012
copyright : (C) 2012 by Marco Hugentobler
email : marco dot hugentobler at sourcepole 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 QGSCOMPOSERFRAME_H
#define QGSCOMPOSERFRAME_H

#include "qgscomposeritem.h"

class QgsComposition;
class QgsComposerMultiFrame;

/**Frame for html, table, text which can be divided onto several frames*/
class QgsComposerFrame: public QgsComposerItem
{
public:
QgsComposerFrame( QgsComposition* c, QgsComposerMultiFrame* mf );
~QgsComposerFrame();

/**Sets the part of this frame (relative to the total multiframe extent in mm)*/
void setContentSection( const QRectF& section ) { mSection = section; }

void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );

bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
bool readXML( const QDomElement& itemElem, const QDomDocument& doc );

private:
QgsComposerFrame(); //forbidden

QgsComposition* mComposition;
QgsComposerMultiFrame* mMultiFrame;
QRectF mSection;
};

#endif // QGSCOMPOSERFRAME_H
@@ -1,7 +1,7 @@
/***************************************************************************
qgscomposerhtml.cpp
------------------------------------------------------------
begin : Julli 2012
begin : July 2012
copyright : (C) 2012 by Marco Hugentobler
email : marco dot hugentobler at sourcepole dot ch
***************************************************************************
@@ -14,7 +14,10 @@
***************************************************************************/

#include "qgscomposerhtml.h"
#include "qgscomposition.h"
#include <QCoreApplication>
#include <QImage>
#include <QPainter>
#include <QWebFrame>
#include <QWebPage>

@@ -66,10 +69,12 @@ void QgsComposerHtml::render( QPainter* p, const QRectF& renderExtent )
return;
}

QImage img; //dummy image to find out assumed screen dpi

double pixelPerMM = mComposition->printResolution() / 25.4;
double painterScale = 1.0 / ( pixelPerMM / (( double )mImage->dotsPerMeterX() / 1000.0 ) );
painter->save();
painter->scale( painterScale, painterScale );
double painterScale = 1.0 / ( pixelPerMM / (( double )img.dotsPerMeterX() / 1000.0 ) );
p->save();
p->scale( painterScale, painterScale );
mWebPage->mainFrame()->render( p, QRegion( renderExtent.left(), renderExtent.top(), renderExtent.width(), renderExtent.height() ) );
painter->restore();
p->restore();
}
@@ -1,7 +1,7 @@
/***************************************************************************
qgscomposerhtml.h
------------------------------------------------------------
begin : Julli 2012
begin : July 2012
copyright : (C) 2012 by Marco Hugentobler
email : marco dot hugentobler at sourcepole dot ch
***************************************************************************
@@ -1,7 +1,7 @@
/***************************************************************************
qgscomposermultiframe.cpp
------------------------------------------------------------
begin : Julli 2012
begin : July 2012
copyright : (C) 2012 by Marco Hugentobler
email : marco dot hugentobler at sourcepole dot ch
***************************************************************************
@@ -1,7 +1,7 @@
/***************************************************************************
qgscomposermultiframe.h
------------------------------------------------------------
begin : Julli 2012
begin : July 2012
copyright : (C) 2012 by Marco Hugentobler
email : marco dot hugentobler at sourcepole dot ch
***************************************************************************

0 comments on commit d413a20

Please sign in to comment.
You can’t perform that action at this time.