|
From: <hba...@us...> - 2009-05-20 03:45:36
|
Revision: 9983
http://plplot.svn.sourceforge.net/plplot/?rev=9983&view=rev
Author: hbabcock
Date: 2009-05-20 03:45:25 +0000 (Wed, 20 May 2009)
Log Message:
-----------
Initial commit of a new PyQt binding based on the qt driver.
Added Paths:
-----------
trunk/examples/python/plplot_pyqt/
trunk/examples/python/plplot_pyqt/config.py
trunk/examples/python/plplot_pyqt/plplot_pyqt.sip
trunk/examples/python/plplot_pyqt/test.py
Added: trunk/examples/python/plplot_pyqt/config.py
===================================================================
--- trunk/examples/python/plplot_pyqt/config.py (rev 0)
+++ trunk/examples/python/plplot_pyqt/config.py 2009-05-20 03:45:25 UTC (rev 9983)
@@ -0,0 +1,63 @@
+import os
+import sipconfig
+from PyQt4 import pyqtconfig
+
+# The name of the SIP build file generated by SIP and used by the build
+# system.
+build_file = "plplot_pyqt.sbf"
+
+# Get the PyQt configuration information.
+config = pyqtconfig.Configuration()
+
+# Get the extra SIP flags needed by the imported qt module. Note that
+# this normally only includes those flags (-x and -t) that relate to SIP's
+# versioning system.
+qt_sip_flags = config.pyqt_sip_flags
+
+# Run SIP to generate the code. Note that we tell SIP where to find the qt
+# module's specification files using the -I flag.
+os.system(" ".join([config.sip_bin, "-c", ".", "-b", build_file, "-I", config.pyqt_sip_dir, qt_sip_flags, "plplot_pyqt.sip"]))
+
+# We are going to install the SIP specification file for this module and
+# its configuration module.
+installs = []
+
+installs.append(["plplot_pyqt.sip", os.path.join(config.default_sip_dir, "plplot_pyqt")])
+
+installs.append(["plplot_pyqtconfig.py", config.default_mod_dir])
+
+# Create the Makefile. The QtModuleMakefile class provided by the
+# pyqtconfig module takes care of all the extra preprocessor, compiler and
+# linker flags needed by the Qt library.
+makefile = pyqtconfig.QtGuiModuleMakefile(
+ configuration=config,
+ build_file=build_file,
+ installs=installs
+)
+
+# Add the library we are wrapping. The name doesn't include any platform
+# specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the
+# ".dll" extension on Windows).
+makefile.extra_libs = ["plplotd", "qt"]
+
+# Generate the Makefile itself.
+makefile.generate()
+
+# Now we create the configuration module. This is done by merging a Python
+# dictionary (whose values are normally determined dynamically) with a
+# (static) template.
+content = {
+ # Publish where the SIP specifications for this module will be
+ # installed.
+ "plplot_pyqt_sip_dir": config.default_sip_dir,
+
+ # Publish the set of SIP flags needed by this module. As these are the
+ # same flags needed by the qt module we could leave it out, but this
+ # allows us to change the flags at a later date without breaking
+ # scripts that import the configuration module.
+ "plplot_pyqt_sip_flags": qt_sip_flags
+}
+
+# This creates the qtermwidgetconfig.py module from the qtermwidgetconfig.py.in
+# template and the dictionary.
+sipconfig.create_config_module("plplot_pyqtconfig.py", "config.py.in", content)
Added: trunk/examples/python/plplot_pyqt/plplot_pyqt.sip
===================================================================
--- trunk/examples/python/plplot_pyqt/plplot_pyqt.sip (rev 0)
+++ trunk/examples/python/plplot_pyqt/plplot_pyqt.sip 2009-05-20 03:45:25 UTC (rev 9983)
@@ -0,0 +1,63 @@
+
+%Module plplot_pyqt 0
+
+%Import QtCore/QtCoremod.sip
+%Import QtGui/QtGuimod.sip
+
+class QtPLDriver {
+
+%TypeHeaderCode
+#include "plplot/my_qt.h"
+%End
+
+ public:
+ QtPLDriver(int i_iWidth=QT_DEFAULT_X, int i_iHeight=QT_DEFAULT_Y);
+ virtual ~QtPLDriver();
+};
+
+class QtPLWidget: QWidget, QtPLDriver {
+
+%TypeHeaderCode
+#include "plplot/my_qt.h"
+%End
+
+ public:
+ QtPLWidget(int i_iWidth=QT_DEFAULT_X, int i_iHeight=QT_DEFAULT_Y, QWidget* parent=0);
+ virtual ~QtPLWidget();
+
+ void clearWidget();
+
+ protected:
+ void mouseReleaseEvent(QMouseEvent *event);
+ void keyPressEvent(QKeyEvent *event);
+ void closeEvent(QCloseEvent *event);
+ void nextPage();
+ void resizeEvent(QResizeEvent *);
+ void paintEvent(QPaintEvent *);
+ void getPlotParameters(double &io_dXFact, double &io_dYFact, double &io_dXOffset, double &io_dYOffset);
+
+
+
+};
+
+class QtExtWidget: QtPLWidget {
+
+%TypeHeaderCode
+#include "plplot/my_qt.h"
+%End
+
+ public:
+ QtExtWidget(int i_iWidth=QT_DEFAULT_X, int i_iHeight=QT_DEFAULT_Y, QWidget* parent=0);
+ virtual ~QtExtWidget();
+
+ void captureMousePlotCoords(double *x, double *y);
+ void mouseMoveEvent(QMouseEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
+
+ protected:
+ void paintEvent(QPaintEvent *event);
+};
+
+void plsetqtdev(QtExtWidget* widget);
+void plfreeqtdev();
Added: trunk/examples/python/plplot_pyqt/test.py
===================================================================
--- trunk/examples/python/plplot_pyqt/test.py (rev 0)
+++ trunk/examples/python/plplot_pyqt/test.py 2009-05-20 03:45:25 UTC (rev 9983)
@@ -0,0 +1,43 @@
+#!/usr/bin/python
+#
+# PLplot / PyQt test.
+#
+# Hazen 5/09
+#
+
+import sys
+from PyQt4 import QtCore, QtGui
+import plplot
+import plplot_pyqt
+
+class QPlot(QtGui.QMainWindow):
+ def __init__(self):
+ print "init"
+ QtGui.QMainWindow.__init__(self, None)
+
+ self.plot = plplot_pyqt.QtExtWidget(800, 800, self)
+ self.setCentralWidget(self.plot)
+
+ plplot_pyqt.plsetqtdev(self.plot)
+ plplot.plsdev("extqt")
+ plplot.plinit()
+
+ self.resize(400,400)
+
+ def cleanup(self):
+ plplot.plend()
+ plplot_pyqt.plfreeqtdev()
+
+ def paintEvent(self, event):
+ plplot.pladv(0)
+ plplot.plenv(0, 10, 0, 10, 0, 0)
+ plplot.pllab("X", "Y", "X vs Y")
+ self.plot.show()
+
+
+app = QtGui.QApplication(sys.argv)
+plot = QPlot()
+plot.show()
+app.exec_()
+plot.cleanup()
+
Property changes on: trunk/examples/python/plplot_pyqt/test.py
___________________________________________________________________
Added: svn:executable
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|