[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/kexi/plugins/reportspgz/backend/renderer
From:       Adam Pigg <adam () piggz ! co ! uk>
Date:       2008-04-30 20:52:36
Message-ID: 1209588756.136671.14927.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 802841 by piggz:

Added OROPicture to allow charts to be renderd as a vector
Made appropriate changes to the pre, print and screen renderers.

 M  +8 -0      krscreenrender.cpp  
 M  +31 -5     orprerender.cpp  
 M  +1 -0      orprerender.h  
 M  +8 -0      orprintrender.cpp  
 M  +21 -0     renderobjects.cpp  
 M  +19 -0     renderobjects.h  
 M  +11 -4     scripting/krscripthandler.cpp  


--- trunk/koffice/kexi/plugins/reportspgz/backend/renderer/krscreenrender.cpp \
#802840:802841 @@ -145,6 +145,14 @@
 			QRectF sr = QRectF ( QPointF ( 0.0, 0.0 ), rc.size().boundedTo ( img.size() ) );
 			_painter->drawImage ( rc.topLeft(), img, sr );
 		}
+		else if ( prim->type() == OROPicture::Picture )
+		{
+			OROPicture * im = ( OROPicture* ) prim;
+			QPointF ps = im->position();
+			QSizeF sz = im->size();
+			QRectF rc = QRectF (ps.x(),ps.y(), sz.width(),sz.height());
+			_painter->drawPicture ( rc.topLeft(), *(im->picture()) );
+		}
 		else
 		{
 			kDebug() << "unrecognized primitive type" << endl;
--- trunk/koffice/kexi/plugins/reportspgz/backend/renderer/orprerender.cpp \
#802840:802841 @@ -47,7 +47,13 @@
 #include "scripting/krscripthandler.h"
 #include <krreportdata.h>
 #include <krdetailsectiondata.h>
+#include <QResizeEvent>
+#include <QApplication>
 
+#include <KDChartAbstractDiagram>
+#include <KDChartAbstractCoordinatePlane>
+#include <KDChartChart>
+
 //
 // ORPreRenderPrivate
 // This class is the private class that houses all the internal
@@ -104,7 +110,7 @@
 		///Scripting Stuff
 		KRScriptHandler *_handler;
 		void initEngine();
-	
+		static void sendResizeEvents(QWidget *target);
 	signals:
 		void enteredGroup(const QString&, const QVariant&);
 		void exitedGroup(const QString&, const QVariant&);
@@ -820,7 +826,6 @@
 			
 			QImage img;
 			img.loadFromData ( imgdata );
-
 			OROImage * id = new OROImage();
 			id->setImage ( img );
 			if ( im->mode().toLower() == "stretch" )
@@ -845,9 +850,17 @@
 			ch->populateData();
 			if ( ch->widget() )
 			{
-				OROImage * id = new OROImage();
+				OROPicture * id = new OROPicture();
 				ch->widget()->setFixedSize(ch->_size.toScene().toSize());
-				id->setImage ( QPixmap::grabWidget ( ch->widget() ).toImage() );
+				//Get the widget the correct size
+				
+				sendResizeEvents(ch->widget());
+				
+				QPainter p(id->picture());
+				
+				ch->widget()->diagram()->coordinatePlane()->parent()->paint(&p, \
QRect(QPoint(0,0), ch->_size.toScene().toSize())); \
+				//ch->widget()->render(id->picture(), QPoint(), QRect(), \
QWidget::DrawWindowBackground | QWidget::DrawChildren | QWidget::IgnoreMask); +
 				QPointF pos = ch->_pos.toScene();
 				QSizeF size = ch->_size.toScene();
 			
@@ -1162,7 +1175,7 @@
 
 	_internal->_handler->displayErrors();
 	
-	delete _internal->_handler;
+	//delete _internal->_handler;
 	delete _internal->_query;
 	_internal->_postProcText.clear();
 
@@ -1209,4 +1222,17 @@
 	return false;
 }
 
+void ORPreRenderPrivate::sendResizeEvents(QWidget *target)
+{
+	QResizeEvent e(target->size(), QSize());
+	QApplication::sendEvent(target, &e);
+
+	const QObjectList children = target->children();
+	for (int i = 0; i < children.size(); ++i) {
+		QWidget *child = static_cast<QWidget*>(children.at(i));
+		if (child->isWidgetType() && !child->isWindow() && \
child->testAttribute(Qt::WA_PendingResizeEvent)) +			sendResizeEvents(child);
+	}
+}
+
 #include <orprerenderprivate.moc>
\ No newline at end of file
--- trunk/koffice/kexi/plugins/reportspgz/backend/renderer/orprerender.h \
#802840:802841 @@ -58,6 +58,7 @@
 
   private:
     ORPreRenderPrivate* _internal;
+    
 };
 
 
--- trunk/koffice/kexi/plugins/reportspgz/backend/renderer/orprintrender.cpp \
#802840:802841 @@ -206,6 +206,14 @@
 					_painter->drawEllipse ( rc );
 					_painter->restore();
 				}
+				else if ( prim->type() == OROPicture::Picture )
+				{
+					OROPicture * im = ( OROPicture* ) prim;
+					QPointF ps = im->position();
+					QSizeF sz = im->size();
+					QRectF rc = QRectF (ps.x(),ps.y(), sz.width(),sz.height());
+					_painter->drawPicture ( rc.topLeft(), *(im->picture()) );
+				}
 				else
 				{
 					qDebug ( "unrecognized primitive type" );
--- trunk/koffice/kexi/plugins/reportspgz/backend/renderer/renderobjects.cpp \
#802840:802841 @@ -271,6 +271,27 @@
 }
 
 //
+// OROPicture
+//
+const int OROPicture::Picture = 6;
+
+OROPicture::OROPicture()
+	: OROPrimitive(OROPicture::Picture)
+{
+	
+}
+
+OROPicture::~OROPicture()
+{
+}
+
+void OROPicture::setSize(const QSizeF & sz)
+{
+	_size = sz;
+}
+
+
+//
 // ORORect
 //
 const int ORORect::Rect = 4;
--- trunk/koffice/kexi/plugins/reportspgz/backend/renderer/renderobjects.h \
#802840:802841 @@ -31,6 +31,7 @@
 #include <QBrush>
 #include <parsexmlutils.h>
 #include <reportpageoptions.h>
+#include <QPicture>
 
 class ORODocument;
 class OROPage;
@@ -226,6 +227,24 @@
     int _aspectFlags;
 };
 
+class OROPicture: public OROPrimitive
+{
+	public:
+		OROPicture();
+		virtual ~OROPicture();
+
+		QPicture* picture() { return &_picture; };
+
+		QSizeF size() const { return _size; };
+		void setSize(const QSizeF &);
+
+		static const int Picture;
+
+	protected:
+		QPicture _picture;
+		QSizeF _size;
+
+};
 //
 // ORORect
 // This primitive defines a drawn rectangle
--- trunk/koffice/kexi/plugins/reportspgz/backend/renderer/scripting/krscripthandler.cpp \
#802840:802841 @@ -43,6 +43,12 @@
 	_data = d;
 	_curs = cu;
 	
+	_action = 0;
+	_functions = 0;
+	_constants = 0;
+	_debug = 0;
+	_draw = 0;
+	
 	// Create the Kross::Action instance .
 	_action = new Kross::Action(this, "ReportScript");
 	
@@ -92,10 +98,11 @@
  
 KRScriptHandler::~KRScriptHandler()
 {
- delete _action;
- delete _functions;
- delete _constants;
- delete _debug;
+ if (_action) delete _action;
+ if (_functions) delete _functions;
+ if (_constants) delete _constants;
+ if (_debug) delete _debug;
+ if (_draw) delete _draw;
 }
 
 void KRScriptHandler::setSource(const QString &s)


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic