From: <hba...@us...> - 2009-06-06 23:24:28
|
Revision: 10043 http://plplot.svn.sourceforge.net/plplot/?rev=10043&view=rev Author: hbabcock Date: 2009-06-06 23:24:06 +0000 (Sat, 06 Jun 2009) Log Message: ----------- Move the pyqt4 bindings into bindings/python/pyqt4. Initial progress on adding these bindings to the PLplot build process. Modified Paths: -------------- trunk/bindings/python/CMakeLists.txt trunk/cmake/modules/drivers.cmake trunk/cmake/modules/plplot.cmake Added Paths: ----------- trunk/bindings/python/pyqt4/ trunk/bindings/python/pyqt4/CMakeLists.txt trunk/bindings/python/pyqt4/config.py trunk/bindings/python/pyqt4/plplot_pyqt.sip trunk/cmake/modules/pyqt4.cmake Removed Paths: ------------- trunk/examples/python/plplot_pyqt/config.py trunk/examples/python/plplot_pyqt/plplot_pyqt.sip Modified: trunk/bindings/python/CMakeLists.txt =================================================================== --- trunk/bindings/python/CMakeLists.txt 2009-06-06 19:19:49 UTC (rev 10042) +++ trunk/bindings/python/CMakeLists.txt 2009-06-06 23:24:06 UTC (rev 10043) @@ -115,4 +115,7 @@ DESTINATION ${PYTHON_INSTDIR} ) +# This is for building the pyqt4 bindings to plplot +add_subdirectory(pyqt4) + endif(ENABLE_python) Added: trunk/bindings/python/pyqt4/CMakeLists.txt =================================================================== --- trunk/bindings/python/pyqt4/CMakeLists.txt (rev 0) +++ trunk/bindings/python/pyqt4/CMakeLists.txt 2009-06-06 23:24:06 UTC (rev 10043) @@ -0,0 +1,29 @@ +# bindings/python/CMakeLists.txt +### Process this file with cmake to produce Makefile +### +# Copyright (C) 2009 Hazen Babcock +# +# This file is part of PLplot. +# +# PLplot is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as published +# by the Free Software Foundation; version 2 of the License. +# +# PLplot is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with PLplot; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +if(ENABLE_pyqt4) + message(" ENABLE_pyqt4") + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/config.py.in "") + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ + COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/config.py + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) +endif(ENABLE_pyqt4) Copied: trunk/bindings/python/pyqt4/config.py (from rev 10042, trunk/examples/python/plplot_pyqt/config.py) =================================================================== --- trunk/bindings/python/pyqt4/config.py (rev 0) +++ trunk/bindings/python/pyqt4/config.py 2009-06-06 23:24:06 UTC (rev 10043) @@ -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) Property changes on: trunk/bindings/python/pyqt4/config.py ___________________________________________________________________ Added: svn:mergeinfo + Copied: trunk/bindings/python/pyqt4/plplot_pyqt.sip (from rev 10042, trunk/examples/python/plplot_pyqt/plplot_pyqt.sip) =================================================================== --- trunk/bindings/python/pyqt4/plplot_pyqt.sip (rev 0) +++ trunk/bindings/python/pyqt4/plplot_pyqt.sip 2009-06-06 23:24:06 UTC (rev 10043) @@ -0,0 +1,60 @@ + +%Module plplot_pyqt 0 + +%Import QtCore/QtCoremod.sip +%Import QtGui/QtGuimod.sip + +class QtPLDriver { + +%TypeHeaderCode +#include "plplot/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/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/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(); Property changes on: trunk/bindings/python/pyqt4/plplot_pyqt.sip ___________________________________________________________________ Added: svn:mergeinfo + Modified: trunk/cmake/modules/drivers.cmake =================================================================== --- trunk/cmake/modules/drivers.cmake 2009-06-06 19:19:49 UTC (rev 10042) +++ trunk/cmake/modules/drivers.cmake 2009-06-06 23:24:06 UTC (rev 10043) @@ -92,6 +92,7 @@ include(aqt) include(wxwidgets) include(pdf) +include(pyqt4) # Finalize device options. include(drivers-finish) Modified: trunk/cmake/modules/plplot.cmake =================================================================== --- trunk/cmake/modules/plplot.cmake 2009-06-06 19:19:49 UTC (rev 10042) +++ trunk/cmake/modules/plplot.cmake 2009-06-06 23:24:06 UTC (rev 10043) @@ -423,3 +423,5 @@ # ======================================================================= include(docbook) include(summary) + + Added: trunk/cmake/modules/pyqt4.cmake =================================================================== --- trunk/cmake/modules/pyqt4.cmake (rev 0) +++ trunk/cmake/modules/pyqt4.cmake 2009-06-06 23:24:06 UTC (rev 10043) @@ -0,0 +1,38 @@ +# bindings/python/CMakeLists.txt +### Process this file with cmake to produce Makefile +### +# Copyright (C) 2009 Hazen Babcock +# +# This file is part of PLplot. +# +# PLplot is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as published +# by the Free Software Foundation; version 2 of the License. +# +# PLplot is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with PLplot; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +# Options to enable PyQt4 bindings +if(DEFAULT_NO_BINDINGS) + option(ENABLE_pyqt4 "Enable PyQt4 bindings" OFF) +else(DEFAULT_NO_BINDINGS) + option(ENABLE_pyqt4 "Enable PyQt4 bindings" ON) +endif(DEFAULT_NO_BINDINGS) + +if(NOT ENABLE_python AND NOT PLD_extqt) + set(ENABLE_pyqt4 OFF CACHE BOOL "Enable PyQt4 bindings" FORCE) +endif(NOT ENABLE_python AND NOT PLD_extqt) + +set(ENABLE_pyqt4 OFF CACHE BOOL "Enable PyQt4 bindings" FORCE) + +if(ENABLE_pyqt4) + message(STATUS "Checking for PyQt4") +endif(ENABLE_pyqt4) + + Deleted: trunk/examples/python/plplot_pyqt/config.py =================================================================== --- trunk/examples/python/plplot_pyqt/config.py 2009-06-06 19:19:49 UTC (rev 10042) +++ trunk/examples/python/plplot_pyqt/config.py 2009-06-06 23:24:06 UTC (rev 10043) @@ -1,63 +0,0 @@ -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) Deleted: trunk/examples/python/plplot_pyqt/plplot_pyqt.sip =================================================================== --- trunk/examples/python/plplot_pyqt/plplot_pyqt.sip 2009-06-06 19:19:49 UTC (rev 10042) +++ trunk/examples/python/plplot_pyqt/plplot_pyqt.sip 2009-06-06 23:24:06 UTC (rev 10043) @@ -1,63 +0,0 @@ - -%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(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-06-16 07:33:56
|
Revision: 10047 http://plplot.svn.sourceforge.net/plplot/?rev=10047&view=rev Author: airwin Date: 2009-06-16 07:33:55 +0000 (Tue, 16 Jun 2009) Log Message: ----------- Process bindings/python/pyqt4 in correct order (so that qt target will have been defined by the time bindings/python/pyqt4/CMakeLists.txt is processed by cmake). Modified Paths: -------------- trunk/CMakeLists.txt trunk/bindings/python/CMakeLists.txt Modified: trunk/CMakeLists.txt =================================================================== --- trunk/CMakeLists.txt 2009-06-16 07:31:49 UTC (rev 10046) +++ trunk/CMakeLists.txt 2009-06-16 07:33:55 UTC (rev 10047) @@ -137,9 +137,10 @@ add_subdirectory(data) add_subdirectory(bindings) add_subdirectory(drivers) -# Must be processed after drivers since depends on qt target created by -# drivers. +# qt_gui and pyqt4 subdirectories must be processed after drivers since they +# depend on qt target created by drivers. add_subdirectory(bindings/qt_gui) +add_subdirectory(bindings/python/pyqt4) add_subdirectory(examples) add_subdirectory(utils) add_subdirectory(plplot_test) Modified: trunk/bindings/python/CMakeLists.txt =================================================================== --- trunk/bindings/python/CMakeLists.txt 2009-06-16 07:31:49 UTC (rev 10046) +++ trunk/bindings/python/CMakeLists.txt 2009-06-16 07:33:55 UTC (rev 10047) @@ -115,7 +115,8 @@ DESTINATION ${PYTHON_INSTDIR} ) -# This is for building the pyqt4 bindings to plplot -add_subdirectory(pyqt4) +# Processing the subdirectory below must be done from the top-level +# CMakeLists.txt (see comment there). +# add_subdirectory(pyqt4) endif(ENABLE_python) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-06-16 17:20:16
|
Revision: 10050 http://plplot.svn.sourceforge.net/plplot/?rev=10050&view=rev Author: airwin Date: 2009-06-16 17:19:36 +0000 (Tue, 16 Jun 2009) Log Message: ----------- Implement libplotqt. This library has the same source code as the dynamically loaded device driver (and cmake module) qt.so, but building this source code into a cmake library sorts out a number of nagging CMake issues with the the external qt "device". For example, with this change, a clean build of plplot_pyqt goes smoothly now on Linux. Also, libplplotqt.so and plplot_pyqt.so created in the build tree on Linux pass the ldd -r test. N.B. Implementing libplplotqt appears to sort out the build-tree issues with anything having to do with the external qt device, but there are still install-tree issues that need to be addressed. Modified Paths: -------------- trunk/CMakeLists.txt trunk/bindings/CMakeLists.txt trunk/bindings/python/CMakeLists.txt trunk/bindings/python/pyqt4/CMakeLists.txt trunk/bindings/qt_gui/CMakeLists.txt trunk/cmake/modules/plplot_version.cmake trunk/drivers/CMakeLists.txt Modified: trunk/CMakeLists.txt =================================================================== --- trunk/CMakeLists.txt 2009-06-16 07:40:53 UTC (rev 10049) +++ trunk/CMakeLists.txt 2009-06-16 17:19:36 UTC (rev 10050) @@ -137,10 +137,6 @@ add_subdirectory(data) add_subdirectory(bindings) add_subdirectory(drivers) -# qt_gui and pyqt4 subdirectories must be processed after drivers since they -# depend on qt target created by drivers. -add_subdirectory(bindings/qt_gui) -add_subdirectory(bindings/python/pyqt4) add_subdirectory(examples) add_subdirectory(utils) add_subdirectory(plplot_test) Modified: trunk/bindings/CMakeLists.txt =================================================================== --- trunk/bindings/CMakeLists.txt 2009-06-16 07:40:53 UTC (rev 10049) +++ trunk/bindings/CMakeLists.txt 2009-06-16 17:19:36 UTC (rev 10050) @@ -34,6 +34,7 @@ add_subdirectory(d) add_subdirectory(ocaml) add_subdirectory(lua) +add_subdirectory(qt_gui) set(index) if(ENABLE_tcl) Modified: trunk/bindings/python/CMakeLists.txt =================================================================== --- trunk/bindings/python/CMakeLists.txt 2009-06-16 07:40:53 UTC (rev 10049) +++ trunk/bindings/python/CMakeLists.txt 2009-06-16 17:19:36 UTC (rev 10050) @@ -115,8 +115,6 @@ DESTINATION ${PYTHON_INSTDIR} ) -# Processing the subdirectory below must be done from the top-level -# CMakeLists.txt (see comment there). -# add_subdirectory(pyqt4) +add_subdirectory(pyqt4) endif(ENABLE_python) Modified: trunk/bindings/python/pyqt4/CMakeLists.txt =================================================================== --- trunk/bindings/python/pyqt4/CMakeLists.txt 2009-06-16 07:40:53 UTC (rev 10049) +++ trunk/bindings/python/pyqt4/CMakeLists.txt 2009-06-16 17:19:36 UTC (rev 10050) @@ -67,24 +67,22 @@ set_target_properties(plplot_pyqt PROPERTIES PREFIX "") if(ENABLE_DYNDRIVERS) - get_target_property(qt_LOCATION qt LOCATION) - #message("DEBUG: qt_LOCATION = ${qt_LOCATION}") - target_link_libraries( plplot_pyqt - ${qt_LOCATION} + plplotqt${LIB_TAG} plplot${LIB_TAG} ${QT_LIBRARIES} + ${PYTHON_LIBRARIES} ) - add_dependencies(plplot_pyqt generate_pyqt_source qt) else(ENABLE_DYNDRIVERS) target_link_libraries( plplot_pyqt plplot${LIB_TAG} - ${QT_LIBRARIES} + ${QT_LIBRARIES} + ${PYTHON_LIBRARIES} ) - add_dependencies(plplot_pyqt generate_pyqt_source) endif(ENABLE_DYNDRIVERS) + add_dependencies(plplot_pyqt generate_pyqt_source) #message(${PYTHON_INSTDIR}) Modified: trunk/bindings/qt_gui/CMakeLists.txt =================================================================== --- trunk/bindings/qt_gui/CMakeLists.txt 2009-06-16 07:40:53 UTC (rev 10049) +++ trunk/bindings/qt_gui/CMakeLists.txt 2009-06-16 17:19:36 UTC (rev 10050) @@ -1,4 +1,4 @@ -# bindings/qt/CMakeLists.txt +# bindings/qt_gui/CMakeLists.txt ### Process this file with cmake to produce Makefile ### # Copyright (C) 2006 Alan W. Irwin @@ -19,7 +19,112 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA if(PLD_extqt) + include_directories( + ${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/lib/qsastime + ${CMAKE_SOURCE_DIR}/lib/nistcd + ${CMAKE_SOURCE_DIR}/drivers + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/include + ) + if(qt_COMPILE_FLAGS) + set_source_files_properties( + ${qt_SOURCE} + PROPERTIES COMPILE_FLAGS "${qt_COMPILE_FLAGS} -DUSINGDLL" + ) + #message("qt_COMPILE_FLAGS = ${qt_COMPILE_FLAGS}") + else(qt_COMPILE_FLAGS) + set_source_files_properties( + ${qt_SOURCE} + PROPERTIES COMPILE_FLAGS "-DUSINGDLL" + ) + endif(qt_COMPILE_FLAGS) + set(MOC_OPTIONS) + if(PLD_bmpqt) + list(APPEND MOC_OPTIONS -DPLD_bmpqt) + endif(PLD_bmpqt) + if(PLD_jpgqt) + list(APPEND MOC_OPTIONS -DPLD_jpgqt) + endif(PLD_jpgqt) + if(PLD_pngqt) + list(APPEND MOC_OPTIONS -DPLD_pngqt) + endif(PLD_pngqt) + if(PLD_ppmqt) + list(APPEND MOC_OPTIONS -DPLD_ppmqt) + endif(PLD_ppmqt) + if(PLD_tiffqt) + list(APPEND MOC_OPTIONS -DPLD_tiffqt) + endif(PLD_tiffqt) + if(PLD_svgqt) + list(APPEND MOC_OPTIONS -DPLD_svgqt) + endif(PLD_svgqt) + if(PLD_epsqt) + list(APPEND MOC_OPTIONS -DPLD_epsqt) + endif(PLD_epsqt) + if(PLD_pdfqt) + list(APPEND MOC_OPTIONS -DPLD_pdfqt) + endif(PLD_pdfqt) + if(PLD_qtwidget) + list(APPEND MOC_OPTIONS -DPLD_qtwidget) + endif(PLD_qtwidget) + if(PLD_extqt) + list(APPEND MOC_OPTIONS -DPLD_extqt) + endif(PLD_extqt) + if(MOC_OPTIONS) + qt4_wrap_cpp( + QT_MOC_OUTFILES + ${CMAKE_SOURCE_DIR}/drivers/qt.h + OPTIONS ${MOC_OPTIONS} + ) + # message("QT_MOC_OUTFILES = ${QT_MOC_OUTFILES}") + set_source_files_properties( + ${QT_MOC_OUTFILES} + PROPERTIES GENERATED "ON" + ) + add_library(plplotqt${LIB_TAG} ${qt_SOURCE} ${QT_MOC_OUTFILES}) + else(MOC_OPTIONS) + add_library(plplotqt${LIB_TAG} ${qt_SOURCE}) + endif(MOC_OPTIONS) + #message("qt_LINK_FLAGS = ${qt_LINK_FLAGS}") + target_link_libraries( + plplotqt${LIB_TAG} + plplot${LIB_TAG} + ${MATH_LIB} + ${qt_LINK_FLAGS} + ) + # qt_RPATH originally set in cmake/modules files for + # each driver in ${DRIVERS_LIST}. This is only used for the + # install-tree rpath since cmake handles the build-tree rpath + # automatically (so long as full pathnames to libraries are used). + #message("qt_RPATH = ${qt_RPATH}") + if(USE_RPATH) + get_target_property(LIB_INSTALL_RPATH plplot${LIB_TAG} INSTALL_RPATH) + list(APPEND LIB_INSTALL_RPATH ${qt_RPATH}) + set_target_properties(plplotqt${LIB_TAG} + PROPERTIES + SOVERSION ${plplotqt_SOVERSION} + VERSION ${plplotqt_VERSION} + INSTALL_RPATH "${LIB_INSTALL_RPATH}" + INSTALL_NAME_DIR "${LIB_DIR}" + ) + else(USE_RPATH) + set_target_properties(plplotqt${LIB_TAG} + PROPERTIES + SOVERSION ${plplotqt_SOVERSION} + VERSION ${plplotqt_VERSION} + INSTALL_NAME_DIR "${LIB_DIR}" + ) + endif(USE_RPATH) + install(TARGETS plplotqt${LIB_TAG} + EXPORT export_plplot + DESTINATION ${DRV_DIR} + ) + install(EXPORT export_plplot + DESTINATION ${DATA_DIR}/examples/cmake/modules + FILE export_plplotqt.cmake + ) + # Transform "${qt_LINK_FLAGS}" to the # standard pkg-config form. pkg_config_link_flags( @@ -57,15 +162,7 @@ string(REGEX REPLACE "^.*:(.*):.*:.*$" "\\1" PC_SHORT_NAME ${PC_DATA}) string(REGEX REPLACE "^.*:.*:(.*):.*$" "\\1" PC_LONG_NAME ${PC_DATA}) string(REGEX REPLACE "^.*:.*:.*:(.*)$" "\\1" PC_LIBRARY_NAME ${PC_DATA}) - if(ENABLE_DYNDRIVERS) - get_target_property(qt_LOCATION qt LOCATION) - get_filename_component(qt_LOCATION ${qt_LOCATION} NAME) - set(qt_LOCATION "\${drvdir}/${qt_LOCATION}") - #message("qt_LOCATION = ${qt_LOCATION}") - else(ENABLE_DYNDRIVERS) - set(qt_LOCATION) - endif(ENABLE_DYNDRIVERS) - set(PC_LINK_FLAGS "${qt_LOCATION} ${lib${PC_LIBRARY_NAME}_LINK_FLAGS}") + set(PC_LINK_FLAGS "${lib${PC_LIBRARY_NAME}_LINK_FLAGS}") set(PC_COMPILE_FLAGS "-DPLD_extqt ${qt_COMPILE_FLAGS}") set(PC_CONFIGURED_FILE ${CMAKE_BINARY_DIR}/pkgcfg/plplot${LIB_TAG}${PC_FILE_SUFFIX}.pc Modified: trunk/cmake/modules/plplot_version.cmake =================================================================== --- trunk/cmake/modules/plplot_version.cmake 2009-06-16 07:40:53 UTC (rev 10049) +++ trunk/cmake/modules/plplot_version.cmake 2009-06-16 17:19:36 UTC (rev 10050) @@ -27,6 +27,9 @@ # (4) If there are no library source code changes at all, then leave all # library version numbers the same for the release. +set(plplotqt_SOVERSION 0) +set(plplotqt_VERSION ${plplotqt_SOVERSION}.0.1) + set(nistcd_SOVERSION 0) set(nistcd_VERSION ${nistcd_SOVERSION}.0.1) Modified: trunk/drivers/CMakeLists.txt =================================================================== --- trunk/drivers/CMakeLists.txt 2009-06-16 07:40:53 UTC (rev 10049) +++ trunk/drivers/CMakeLists.txt 2009-06-16 17:19:36 UTC (rev 10050) @@ -223,18 +223,7 @@ list(APPEND test_dyndrivers_TDEPENDS ${SOURCE_ROOT_NAME}) endif(TEST_DYNDRIVERS AND NOT CMAKE_CROSSCOMPILING) - if(SOURCE_ROOT_NAME STREQUAL "qt") - install(TARGETS ${SOURCE_ROOT_NAME} - EXPORT export_plplot - DESTINATION ${DRV_DIR} - ) - install(EXPORT export_plplot - DESTINATION ${DATA_DIR}/examples/cmake/modules - FILE export_plplotqt.cmake - ) - else(SOURCE_ROOT_NAME STREQUAL "qt") - install(TARGETS ${SOURCE_ROOT_NAME} DESTINATION ${DRV_DIR}) - endif(SOURCE_ROOT_NAME STREQUAL "qt") + install(TARGETS ${SOURCE_ROOT_NAME} DESTINATION ${DRV_DIR}) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_ROOT_NAME}.rc DESTINATION ${DRV_DIR} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-06-22 21:05:23
|
Revision: 10061 http://plplot.svn.sourceforge.net/plplot/?rev=10061&view=rev Author: airwin Date: 2009-06-22 21:04:47 +0000 (Mon, 22 Jun 2009) Log Message: ----------- Implement visibility of the plplotqt library. This takes care of most but not all visibility issues on Linux so, for the moment, the "ldd -r" test on the plplot_pyqt4 Python extension module shows some undefined symbols that are not exported properly from the plplotqt library. Modified Paths: -------------- trunk/drivers/qt.h trunk/include/pldll.h.in Modified: trunk/drivers/qt.h =================================================================== --- trunk/drivers/qt.h 2009-06-22 21:00:30 UTC (rev 10060) +++ trunk/drivers/qt.h 2009-06-22 21:04:47 UTC (rev 10061) @@ -140,7 +140,7 @@ }; // Basic class, offering the common interface to all Qt plplot devices -class QtPLDriver +class PLDLLIMPEXP_DRIVER QtPLDriver { public: // Constructor, taking the device size as arguments Modified: trunk/include/pldll.h.in =================================================================== --- trunk/include/pldll.h.in 2009-06-22 21:00:30 UTC (rev 10060) +++ trunk/include/pldll.h.in 2009-06-22 21:04:47 UTC (rev 10061) @@ -46,6 +46,8 @@ but dyanmic drivers disabled, the driver dll macros are the same as the plplot dll macros */ #ifdef ENABLE_DYNDRIVERS + /* Treat plplotqt library just like the qt device since the same source code + is used. */ #if defined(aqt_EXPORTS) || defined(cairo_EXPORTS) || defined(cgm_EXPORTS) || \ defined(dg300_EXPORTS) || defined(gd_EXPORTS) || defined(gcw_EXPORTS) || \ defined(hpgl_EXPORTS) || defined(impress_EXPORTS) || defined(linuxvga_EXPORTS) || \ @@ -55,7 +57,7 @@ defined(pstex_EXPORTS) || defined(psttf_EXPORTS) || defined(svg_EXPORTS) || \ defined(tek_EXPORTS) || defined(tk_EXPORTS) || defined(tkwin_EXPORTS) || \ defined(wingcc_EXPORTS) || defined(wxwidgets_EXPORTS) || defined(xfig_EXPORTS) || \ - defined(xwin_EXPORTS) || defined(qt_EXPORTS) + defined(xwin_EXPORTS) || defined(qt_EXPORTS) || defined(plplotqt${LIB_TAG}_EXPORTS) #define PLDLLIMPEXP_DRIVER PLDLLEXPORT #define PLDLLIMPEXP_DRIVER_DATA(type) PLDLLEXPORT type #else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fu...@us...> - 2009-06-26 05:13:29
|
Revision: 10070 http://plplot.svn.sourceforge.net/plplot/?rev=10070&view=rev Author: furnish Date: 2009-06-26 05:13:22 +0000 (Fri, 26 Jun 2009) Log Message: ----------- Getting started on an organizational structure for svn-to-git transition aides. Added Paths: ----------- trunk/git/ trunk/git/README Added: trunk/git/README =================================================================== --- trunk/git/README (rev 0) +++ trunk/git/README 2009-06-26 05:13:22 UTC (rev 10070) @@ -0,0 +1,9 @@ +This directory contains scripts, documentation, and assorted miscellany +intended to aide in the process of transitioning PLplot to git. + + +Subdir Description +------------ -------------------------------------------------------- +case-1 Use git-svn to establish a git gateway to the PLplot svn + repository. + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-06-26 18:21:18
|
Revision: 10073 http://plplot.svn.sourceforge.net/plplot/?rev=10073&view=rev Author: airwin Date: 2009-06-26 18:20:32 +0000 (Fri, 26 Jun 2009) Log Message: ----------- Split former qt.cpp into device driver part (qt.cpp) and library part plqt.cpp). Much thanks to Dmitri Gribenko for the patch splitting the code this way. Add CMake infrastructure to support this source-code split between the qt device driver and libplplotqt. Running an example (30 in this case) for qtwidget, epsqt, pngqt, and svgqt (the four kinds of qt devices) under valgrind showed 0 errors. qt_example was valgrind clean as well. N.B. The above tests were done for default CMake configuration (ENABLE_DYNDRIVERS ON, ENABLE_qt ON) and with the new build system for the installed examples and more testing for other configurations should be done. Modified Paths: -------------- trunk/bindings/qt_gui/CMakeLists.txt trunk/cmake/modules/qt.cmake trunk/drivers/qt.cpp Added Paths: ----------- trunk/bindings/qt_gui/plqt.cpp Modified: trunk/bindings/qt_gui/CMakeLists.txt =================================================================== --- trunk/bindings/qt_gui/CMakeLists.txt 2009-06-26 18:06:32 UTC (rev 10072) +++ trunk/bindings/qt_gui/CMakeLists.txt 2009-06-26 18:20:32 UTC (rev 10073) @@ -19,6 +19,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA if(ENABLE_qt) + set(qt_SOURCE plqt.cpp) include_directories( ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/lib/qsastime Added: trunk/bindings/qt_gui/plqt.cpp =================================================================== --- trunk/bindings/qt_gui/plqt.cpp (rev 0) +++ trunk/bindings/qt_gui/plqt.cpp 2009-06-26 18:20:32 UTC (rev 10073) @@ -0,0 +1,1028 @@ +/* + + This software is provided under the LGPL in March 2009 by the + Cluster Science Centre + QSAS team, + Imperial College, London + + Copyright (C) 2009 Imperial College, London + Copyright (C) 2009 Alan W. Irwin + + This is free software; you can redistribute it and/or modify + it under the terms of the GNU General Lesser Public License as published + by the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This software is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + To received a copy of the GNU Library General Public License + write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + History: + + + March 2009: v1.00 + Initial release. + +*/ + + +#include "qt.h" + +// Global variables for Qt driver. +int vectorize = 0; +MasterHandler handler; + +///////////// Generic Qt driver class ///////////////// +QMutex QtPLDriver::mutex; + +QtPLDriver::QtPLDriver(PLINT i_iWidth, PLINT i_iHeight) +{ + m_dWidth=i_iWidth; + m_dHeight=i_iHeight; +} + +QtPLDriver::~QtPLDriver() +{ +} + +void QtPLDriver::drawLine(short x1, short y1, short x2, short y2) +{ + if(!m_painterP->isActive()) return; + QLineF line( (PLFLT)x1*downscale, + m_dHeight-(PLFLT)y1*downscale, + (PLFLT)x2*downscale, + m_dHeight-(PLFLT)y2*downscale + ); + + m_painterP->drawLine(line); +} + +void QtPLDriver::drawPolyline(short * x, short * y, PLINT npts) +{ + if(!m_painterP->isActive()) return; + QPointF * polyline=new QPointF[npts]; + for(int i=0; i<npts; ++i) + { + polyline[i].setX((PLFLT)x[i]*downscale); + polyline[i].setY(m_dHeight-(PLFLT)y[i]*downscale); + } + m_painterP->drawPolyline(polyline, npts); + delete[] polyline; +} + +void QtPLDriver::drawPolygon(short * x, short * y, PLINT npts) +{ + if(!m_painterP->isActive()) return; + QPointF * polygon=new QPointF[npts]; + for(int i=0; i<npts; ++i) + { + polygon[i].setX((PLFLT)x[i]*downscale); + polygon[i].setY(m_dHeight-(PLFLT)y[i]*downscale); + } + m_painterP->drawPolygon(polygon, npts); + delete[] polygon; +} + + +QFont QtPLDriver::getFont(PLUNICODE unicode) +{ + // Get new font parameters + unsigned char fontFamily, fontStyle, fontWeight; + + plP_fci2hex(unicode, &fontFamily, PL_FCI_FAMILY); + plP_fci2hex(unicode, &fontStyle, PL_FCI_STYLE); + plP_fci2hex(unicode, &fontWeight, PL_FCI_WEIGHT); + + QFont f; + + f.setPointSizeF(currentFontSize*currentFontScale<4 ? 4 : currentFontSize*currentFontScale); + + switch(fontFamily) { + case 1: + f.setStyleHint(QFont::Serif); +// f.setFamily("Times"); + break; + case 2: + f.setStyleHint(QFont::TypeWriter); +// f.setFamily("Courier"); + break; + case 0: case 3: case 4:default: + f.setStyleHint(QFont::SansSerif); +// f.setFamily("Helvetica"); + break; + } + f.setFamily(""); // no family name, forcing Qt to find an appropriate font by itself + + if(fontStyle) f.setItalic(true); + if(fontWeight) f.setWeight(QFont::Bold); + else f.setWeight(QFont::Normal); + + f.setUnderline(underlined); + f.setOverline(overlined); + + return f; +} + +void QtPLDriver::drawTextInPicture(QPainter* p, const QString& text) +{ +// if(!m_painterP->isActive()) return; + + QRectF rect(0., 0., 0., 0.); + QRectF bounding; + QPicture tempPic; + QPainter tempPainter(&tempPic); + tempPainter.setFont(p->font()); + + if(vectorize) + { + bounding=tempPainter.boundingRect(rect, Qt::AlignHCenter|Qt::AlignVCenter|Qt::TextDontClip, text); + + QPen savePen=tempPainter.pen(); + QPen pen=savePen; + pen.setStyle(Qt::NoPen); + tempPainter.setPen(pen); + + double offset=QFontMetrics(tempPainter.font(), &tempPic).boundingRect(text).top(); // Distance between the baseline and the top of the bounding box + + QPainterPath path; + path.addText(QPointF(bounding.left(), bounding.top()-offset), tempPainter.font(), text); + tempPainter.drawPath(path); + tempPainter.setPen(pen); + } + else + { + tempPainter.drawText(rect, Qt::AlignHCenter|Qt::AlignVCenter|Qt::TextDontClip, text, &bounding); + } + + tempPainter.end(); + + p->drawPicture((int)(xOffset+bounding.width()/2.), -yOffset, tempPic); + + xOffset+=bounding.width(); +} + +QPicture QtPLDriver::getTextPicture(PLUNICODE fci, PLUNICODE* text, int len, PLFLT chrht) +{ + char plplotEsc; + plgesc( &plplotEsc ); + + double old_fontScale; + + QPicture res; + QPainter p(&res); + + QString currentString; + + yOffset=0.; + xOffset=0.; + + // Scaling factor of 1.6 determined empirically to make all qt results + // have the same character size as cairo results (taking into account + // the slightly different actual glyph sizes for the different + // default fonts found by cairo and qt). + currentFontSize=chrht*POINTS_PER_INCH/25.4*1.45; + currentFontScale=1.; + underlined=false; + overlined=false; + + p.setFont(getFont(fci)); + + int i=0; + while(i < len) + { + if(text[i]<PL_FCI_MARK) // Not a font change + { + if(text[i]!=(PLUNICODE)plplotEsc) + { + currentString.append(QString((QChar*)&(text[i]), 1)); + ++i; + continue; + } + ++i; // Now analyse the escaped character + switch(text[i]) + { + case 'd': + drawTextInPicture(&p, currentString); + + currentString.clear(); + old_fontScale=currentFontScale; + if( yOffset>0.0 ) + currentFontScale *= 1.25; /* Subscript scaling parameter */ + else + currentFontScale *= 0.8; /* Subscript scaling parameter */ + + yOffset -= currentFontSize * old_fontScale / 2.; + + p.setFont(getFont(fci)); + break; + case 'u': + drawTextInPicture(&p, currentString); + + currentString.clear(); + if( yOffset<0.0 ) + currentFontScale *= 1.25; /* Subscript scaling parameter */ + else + currentFontScale *= 0.8; /* Subscript scaling parameter */ + + yOffset += currentFontSize * currentFontScale / 2.; + p.setFont(getFont(fci)); + break; + case '-': + drawTextInPicture(&p, currentString); + + currentString.clear(); + underlined=!underlined; + p.setFont(getFont(fci)); + break; + case '+': + drawTextInPicture(&p, currentString); + + currentString.clear(); + overlined=!overlined; + p.setFont(getFont(fci)); + break; + case '#': + currentString.append(QString((QChar*)&(text[i]), 1)); + break; + default : + std::cout << "unknown escape char " << ((QChar)text[i]).toLatin1() << std::endl; + break; + } + } + else // Font change + { + drawTextInPicture(&p, currentString); + + currentString.clear(); + fci=text[i]; + p.setFont(getFont(fci)); + } + ++i; + } + drawTextInPicture(&p, currentString); + + p.end(); + return res; +} + +void QtPLDriver::drawText(PLStream* pls, EscText* txt) +{ + if(!m_painterP->isActive()) return; + + /* Check that we got unicode, warning message and return if not */ + if( txt->unicode_array_len == 0 ) { + printf( "Non unicode string passed to a Qt driver, ignoring\n" ); + return; + } + + /* Check that unicode string isn't longer then the max we allow */ + if( txt->unicode_array_len >= 500 ) { + printf( "Sorry, the Qt drivers only handle strings of length < %d\n", 500 ); + return; + } + + PLFLT rotation, shear, stride; + plRotationShear( txt->xform, &rotation, &shear, &stride); + + double picDpi; + PLUNICODE fci; + plgfci( &fci ); + QPicture picText=getTextPicture(fci, txt->unicode_array, txt->unicode_array_len, pls->chrht); + picDpi=picText.logicalDpiY(); + + m_painterP->setClipping(true); + m_painterP->setClipRect(QRect((int)(pls->clpxmi*downscale), (int)(m_dHeight-pls->clpyma*downscale), (int)((pls->clpxma-pls->clpxmi)*downscale), (int)((pls->clpyma-pls->clpymi)*downscale)), Qt::ReplaceClip); + + rotation -= pls->diorot * M_PI / 2.0; + m_painterP->translate(txt->x*downscale, m_dHeight-txt->y*downscale); + QMatrix rotShearMatrix(cos(rotation)*stride, -sin(rotation)*stride, cos(rotation)*sin(shear)+sin(rotation)*cos(shear), -sin(rotation)*sin(shear)+cos(rotation)*cos(shear), 0., 0.); + + m_painterP->setWorldMatrix(rotShearMatrix, true); + + m_painterP->translate(-txt->just*xOffset*m_painterP->device()->logicalDpiY()/picDpi, 0.); + + m_painterP->drawPicture(0, 0, picText); + + m_painterP->setWorldMatrix(QMatrix()); + m_painterP->setClipping(false); +} + +void QtPLDriver::setColor(int r, int g, int b, double alpha) +{ + if(!m_painterP->isActive()) return; + + QPen p=m_painterP->pen(); + p.setColor(QColor(r, g, b, (int)(alpha*255))); + m_painterP->setPen(p); + + QBrush B=m_painterP->brush(); + B.setColor(QColor(r, g, b, (int)(alpha*255))); + B.setStyle(Qt::SolidPattern); + m_painterP->setBrush(B); +} + +void QtPLDriver::setWidth(PLINT w) +{ + if(!m_painterP->isActive()) return; + + QPen p=m_painterP->pen(); + p.setWidth(w); + m_painterP->setPen(p); +} + +void QtPLDriver::setDashed(PLINT nms, PLINT* mark, PLINT* space) +{ + if(!m_painterP->isActive()) return; + + QVector<qreal> vect; + for(int i=0; i<nms; ++i) + { + vect << (PLFLT)mark[i]*m_painterP->device()->logicalDpiX()/25400.; + vect << (PLFLT)space[i]*m_painterP->device()->logicalDpiX()/25400.; + } + QPen p=m_painterP->pen(); + p.setDashPattern(vect); + m_painterP->setPen(p); +} + +void QtPLDriver::setSolid() +{ + if(!m_painterP->isActive()) return; + + QPen p=m_painterP->pen(); + p.setStyle(Qt::SolidLine); + m_painterP->setPen(p); +} + +////////////////// Raster driver-specific definitions: class and interface functions ///////// +#if defined (PLD_bmpqt) || defined(PLD_jpgqt) || defined (PLD_pngqt) || defined(PLD_ppmqt) || defined(PLD_tiffqt) +QtRasterDevice::QtRasterDevice(int i_iWidth, int i_iHeight): + QtPLDriver(i_iWidth, i_iHeight), + QImage(i_iWidth, i_iHeight, QImage::Format_RGB32) +{ + // Painter initialised in the constructor contrary + // to buffered drivers, which paint only in doPlot(). + m_painterP=new QPainter(this); + QBrush b=m_painterP->brush(); + b.setStyle(Qt::SolidPattern); + m_painterP->setBrush(b); + m_painterP->setRenderHint(QPainter::Antialiasing, true); + + // Let's fill the background + m_painterP->fillRect(0, 0, width(), height(), QBrush(Qt::black)); + +// fontScalingFactor=1.; +} + +QtRasterDevice::~QtRasterDevice() +{ + if(m_painterP!=NULL) delete m_painterP; +} + +void QtRasterDevice::definePlotName(const char* fileName, const char* format) +{ + // Avoid buffer overflows + strncpy(this->format, format, 4); + this->format[4]='\0'; + + this->fileName=QString(fileName); +} + +void QtRasterDevice::savePlot() +{ + m_painterP->end(); + save(fileName, format, 85); + + m_painterP->begin(this); + m_painterP->setRenderHint(QPainter::Antialiasing, true); + QBrush b=m_painterP->brush(); + b.setStyle(Qt::SolidPattern); + m_painterP->setBrush(b); + m_painterP->fillRect(0, 0, width(), height(), QBrush(Qt::black)); +} +#endif + +#if defined(PLD_svgqt) && QT_VERSION >= 0x040300 +QtSVGDevice::QtSVGDevice(int i_iWidth, int i_iHeight): + QtPLDriver(i_iWidth, i_iHeight) +{ + m_painterP=NULL; + +// fontScalingFactor=1.; +} + +QtSVGDevice::~QtSVGDevice() +{ + if(m_painterP!=NULL) delete m_painterP; +} + +void QtSVGDevice::definePlotName(const char* fileName) +{ + setFileName(QString(fileName)); + setResolution(POINTS_PER_INCH); + setSize(QSize((int)m_dWidth, (int)m_dHeight)); +#if QT_VERSION >= 0x040500 + setViewBox(QRect(0, 0, (int)m_dWidth, (int)m_dHeight)); +#endif + + m_painterP=new QPainter(this); + m_painterP->fillRect(0, 0, (int)m_dWidth, (int)m_dHeight, QBrush(Qt::black)); +} + +void QtSVGDevice::savePlot() +{ + m_painterP->end(); +} +#endif + +#if defined (PLD_epsqt) || defined(PLD_pdfqt) +QtEPSDevice::QtEPSDevice(int i_iWidth, int i_iHeight) +{ +#if QT_VERSION < 0x040400 + setPageSize(QPrinter::A4); +#else + setFullPage(true); + setPaperSize(QSizeF(i_iHeight, i_iWidth), QPrinter::Point); +#endif + setResolution(POINTS_PER_INCH); + setColorMode(QPrinter::Color); + setOrientation(QPrinter::Landscape); + setPrintProgram(QString("lpr")); + + if(i_iWidth<=0 || i_iHeight<=0) + { + m_dWidth=pageRect().width(); + m_dHeight=pageRect().height(); + } + else + { + m_dWidth=i_iWidth; + m_dHeight=i_iHeight; + } + m_painterP=NULL; + +// fontScalingFactor=1.; +} + +QtEPSDevice::~QtEPSDevice() +{ + if(m_painterP!=NULL) delete m_painterP; +} + +void QtEPSDevice::definePlotName(const char* fileName, int ifeps) +{ + setOutputFileName(QString(fileName)); + if(ifeps) + { + setOutputFormat(QPrinter::PostScriptFormat); + } + else + { + setOutputFormat(QPrinter::PdfFormat); + } + + m_painterP=new QPainter(this); + m_painterP->fillRect(0, 0, (int)m_dWidth, (int)m_dHeight, QBrush(Qt::black)); +} + +void QtEPSDevice::savePlot() +{ + m_painterP->end(); +} +#endif + +#if defined (PLD_qtwidget) || defined(PLD_extqt) +QtPLWidget::QtPLWidget(int i_iWidth, int i_iHeight, QWidget* parent): + QWidget(parent), QtPLDriver(i_iWidth, i_iHeight) +{ + m_painterP=new QPainter; + + m_dAspectRatio=m_dWidth/m_dHeight; + + m_pixPixmap=NULL; + m_iOldSize=0; + pageNumber=0; + resize(i_iWidth, i_iHeight); +} + +QtPLWidget::~QtPLWidget() +{ + clearBuffer(); + if(m_pixPixmap!=NULL) delete m_pixPixmap; +} + +void QtPLWidget::clearWidget() +{ + clearBuffer(); + m_bAwaitingRedraw=true; + update(); +} + +void QtPLWidget::clearBuffer() +{ + for(QLinkedList<BufferElement>::iterator i=m_listBuffer.begin(); i!=m_listBuffer.end(); ++i) + { + switch(i->Element) + { + case POLYLINE: + case POLYGON: + delete[] i->Data.PolylineStruct->x; + delete[] i->Data.PolylineStruct->y; + delete i->Data.PolylineStruct; + break; + + case LINE: + delete i->Data.LineStruct; + break; + + case SET_COLOUR: + delete i->Data.ColourStruct; + break; + + case TEXT: + delete[] i->Data.TextStruct->text; + delete i->Data.TextStruct; + break; + default: + break; + } + } + + m_listBuffer.clear(); +} + +void QtPLWidget::drawLine(short x1, short y1, short x2, short y2) +{ + BufferElement el; + el.Element=LINE; + el.Data.LineStruct=new struct LineStruct_; + el.Data.LineStruct->x1=(PLFLT)x1*downscale; + el.Data.LineStruct->y1=m_dHeight-(PLFLT)y1*downscale; + el.Data.LineStruct->x2=(PLFLT)x2*downscale; + el.Data.LineStruct->y2=m_dHeight-(PLFLT)y2*downscale; + + m_listBuffer.append(el); +} + +void QtPLWidget::drawPolyline(short * x, short * y, PLINT npts) +{ + BufferElement el; + el.Element=POLYLINE; + el.Data.PolylineStruct=new struct PolylineStruct_; + el.Data.PolylineStruct->npts=(PLINT)npts; + el.Data.PolylineStruct->x=new PLFLT[npts]; + el.Data.PolylineStruct->y=new PLFLT[npts]; + for(int i=0; i<npts; ++i) + { + el.Data.PolylineStruct->x[i]=(PLFLT)x[i]*downscale; + el.Data.PolylineStruct->y[i]=m_dHeight-(PLFLT)y[i]*downscale; + } + + m_listBuffer.append(el); +} + +void QtPLWidget::drawPolygon(short * x, short * y, PLINT npts) +{ + BufferElement el; + el.Element=POLYGON; + el.Data.PolylineStruct=new struct PolylineStruct_; + el.Data.PolylineStruct->npts=(PLINT)npts; + el.Data.PolylineStruct->x=new PLFLT[npts]; + el.Data.PolylineStruct->y=new PLFLT[npts]; + for(int i=0; i<npts; ++i) + { + el.Data.PolylineStruct->x[i]=(PLFLT)x[i]*downscale; + el.Data.PolylineStruct->y[i]=m_dHeight-(PLFLT)y[i]*downscale; + } + + m_listBuffer.append(el); +} + +void QtPLWidget::setColor(int r, int g, int b, double alpha) +{ + BufferElement el; + el.Element=SET_COLOUR; + el.Data.ColourStruct=new struct ColourStruct_; + el.Data.ColourStruct->R=r; + el.Data.ColourStruct->G=g; + el.Data.ColourStruct->B=b; + el.Data.ColourStruct->A=alpha*255.; + + m_listBuffer.append(el); +} + +void QtPLWidget::setSolid() +{ + BufferElement el; + el.Element=SET_SOLID; + m_listBuffer.append(el); +} + +void QtPLWidget::setWidth(PLINT w) +{ + BufferElement el; + el.Element=SET_WIDTH; + el.Data.intParam=w; + m_listBuffer.append(el); +} + +void QtPLWidget::drawText(PLStream* pls, EscText* txt) +{ + BufferElement el; + el.Element=TEXT; + el.Data.TextStruct=new struct TextStruct_; + el.Data.TextStruct->x=txt->x*downscale; + el.Data.TextStruct->y=m_dHeight-txt->y*downscale; + el.Data.TextStruct->clipxmin=pls->clpxmi*downscale; + el.Data.TextStruct->clipymin=m_dHeight-pls->clpymi*downscale; + el.Data.TextStruct->clipxmax=pls->clpxma*downscale; + el.Data.TextStruct->clipymax=m_dHeight-pls->clpyma*downscale; + PLUNICODE fci; + plgfci(&fci); + el.Data.TextStruct->fci=fci; + PLFLT rotation, shear, stride; + plRotationShear( txt->xform, &rotation, &shear, &stride); + rotation -= pls->diorot * M_PI / 2.0; + el.Data.TextStruct->rotation=rotation; + el.Data.TextStruct->shear=shear; + el.Data.TextStruct->stride=stride; + el.Data.TextStruct->just=txt->just; + el.Data.TextStruct->text=new PLUNICODE[txt->unicode_array_len]; + memcpy(el.Data.TextStruct->text, txt->unicode_array, txt->unicode_array_len*sizeof(PLUNICODE)); + el.Data.TextStruct->len=txt->unicode_array_len; + el.Data.TextStruct->chrht=pls->chrht; + + m_listBuffer.append(el); + +} + +void QtPLWidget::drawTextInPicture(QPainter* p, const QString& text) +{ + QRectF rect(0., 0., 0., 0.); + QRectF bounding; + QPicture tempPic; + QPainter tempPainter(&tempPic); + tempPainter.setFont(p->font()); + + if(vectorize) + { + bounding=tempPainter.boundingRect(rect, Qt::AlignHCenter|Qt::AlignVCenter|Qt::TextDontClip, text); + + QPen savePen=tempPainter.pen(); + QPen pen=savePen; + pen.setStyle(Qt::NoPen); + tempPainter.setPen(pen); + + double offset=QFontMetrics(tempPainter.font(), &tempPic).boundingRect(text).top(); // Distance between the baseline and the top of the bounding box + + QPainterPath path; + path.addText(QPointF(bounding.left(), bounding.top()-offset), tempPainter.font(), text); + tempPainter.drawPath(path); + tempPainter.setPen(pen); + } + else + { + tempPainter.drawText(rect, Qt::AlignHCenter|Qt::AlignVCenter|Qt::TextDontClip, text, &bounding); + + } + + tempPainter.end(); + + p->drawPicture((int)(xOffset+bounding.width()/2.), -yOffset, tempPic); + xOffset+=bounding.width(); +} + +void QtPLWidget::renderText(QPainter* p, struct TextStruct_* s, double x_fact, double x_offset, double y_fact, double y_offset) +{ + if(s->len<=0 || s->len>=500) return; + QPicture picText=getTextPicture(s->fci, s->text, s->len, s->chrht*y_fact); + + double picDpi=picText.logicalDpiY(); + + p->setClipping(true); + p->setClipRect(QRectF(s->clipxmin*x_fact+x_offset, s->clipymax*y_fact+y_offset, (s->clipxmax-s->clipxmin)*x_fact, (-s->clipymax+s->clipymin)*y_fact), Qt::ReplaceClip); + + p->translate(s->x*x_fact+x_offset, s->y*y_fact+y_offset); + QMatrix rotShearMatrix(cos(s->rotation)*s->stride, -sin(s->rotation)*s->stride, cos(s->rotation)*sin(s->shear)+sin(s->rotation)*cos(s->shear), -sin(s->rotation)*sin(s->shear)+cos(s->rotation)*cos(s->shear), 0.,0.); + p->setWorldMatrix(rotShearMatrix, true); + + p->translate(-s->just*xOffset*p->device()->logicalDpiY()/picDpi, 0.); + + p->drawPicture(0., 0., picText); + + p->setWorldMatrix(QMatrix()); + + p->setClipping(false); +} + +void QtPLWidget::mouseReleaseEvent ( QMouseEvent * event ) +{ + if(event->button()==Qt::RightButton) + { + handler.DeviceChangedPage(this); + } +} + +void QtPLWidget::keyPressEvent(QKeyEvent* event) +{ + if(event->key()==Qt::Key_Enter || event->key()==Qt::Key_Return) + { + handler.DeviceChangedPage(this); + } +} + +void QtPLWidget::closeEvent(QCloseEvent* event) +{ + handler.DeviceClosed(this); + event->ignore(); +} + +void QtPLWidget::nextPage() +{ + clearWidget(); + pageNumber++; +} + +void QtPLWidget::resizeEvent( QResizeEvent * ) +{ + m_bAwaitingRedraw=true; + if(m_pixPixmap!=NULL) + { + delete m_pixPixmap; + m_pixPixmap=NULL; + } +} + +void QtPLWidget::paintEvent( QPaintEvent * ) +{ + double x_fact, y_fact, x_offset(0.), y_offset(0.); //Parameters to scale and center the plot on the widget + + getPlotParameters(x_fact, y_fact, x_offset, y_offset); + if(m_bAwaitingRedraw || m_pixPixmap==NULL || m_listBuffer.size()!=m_iOldSize) // If must regenerate image, draw it in the pixmap + { + if(m_pixPixmap!=NULL) delete m_pixPixmap; + m_pixPixmap=new QPixmap(width(), height()); + QPainter* painter=new QPainter; + painter->begin(m_pixPixmap); + + // Draw the margins and the background + painter->fillRect(0, 0, width(), height(), QBrush(Qt::white)); + painter->fillRect(0, 0, width(), height(), QBrush(Qt::gray, Qt::Dense4Pattern)); + painter->fillRect((int)x_offset, (int)y_offset, (int)floor(x_fact*m_dWidth+0.5), (int)floor(y_fact*m_dHeight+0.5), QBrush(Qt::black)); + + // Draw the plot + doPlot(painter, x_fact, y_fact, x_offset, y_offset); + painter->end(); + + m_bAwaitingRedraw=false; + m_iOldSize=m_listBuffer.size(); + + delete painter; + } + + // draw the current pixmap + m_painterP->begin(this); + + m_painterP->drawPixmap(0, 0, *m_pixPixmap); + + m_painterP->end(); +} + +void QtPLWidget::doPlot(QPainter* p, double x_fact, double y_fact, double x_offset, double y_offset) +{ + QLineF line; + QPointF * polyline; + PLINT npts; + QVector<qreal> vect; + QPen pen=p->pen(); + QBrush brush=p->brush(); + brush.setStyle(Qt::SolidPattern); + p->setBrush(brush); + p->setRenderHints(QPainter::Antialiasing, true); + + if(m_listBuffer.empty()) + { + p->fillRect(0, 0, (int)(x_fact+2.*x_offset), (int)(y_fact+2.*y_offset), QBrush()); + return; + } + // unrolls the buffer and draws each element accordingly + for(QLinkedList<BufferElement>::const_iterator i=m_listBuffer.begin(); i!=m_listBuffer.end(); ++i) + { + switch(i->Element) + { + case LINE: + line=QLineF(i->Data.LineStruct->x1*x_fact+x_offset, i->Data.LineStruct->y1*y_fact+y_offset, i->Data.LineStruct->x2*x_fact+x_offset, i->Data.LineStruct->y2*y_fact+y_offset); + p->drawLine(line); + break; + + case POLYLINE: + npts=i->Data.PolylineStruct->npts; + polyline=new QPointF[npts]; + for(int j=0; j<npts; ++j) + { + polyline[j].setX(i->Data.PolylineStruct->x[j]*x_fact+x_offset); + polyline[j].setY(i->Data.PolylineStruct->y[j]*y_fact+y_offset); + } + p->drawPolyline(polyline, npts); + delete[] polyline; + break; + + case POLYGON: + npts=i->Data.PolylineStruct->npts; + polyline=new QPointF[npts]; + for(int j=0; j<npts; ++j) + { + polyline[j].setX(i->Data.PolylineStruct->x[j]*x_fact+x_offset); + polyline[j].setY(i->Data.PolylineStruct->y[j]*y_fact+y_offset); + } + p->drawPolygon(polyline, npts); + delete[] polyline; + break; + + case TEXT: + renderText(p, i->Data.TextStruct, x_fact, x_offset, y_fact, y_offset); + break; + + case SET_WIDTH: + pen.setWidth(i->Data.intParam); + p->setPen(pen); + break; + + case SET_COLOUR: + pen.setColor(QColor(i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A)); + p->setPen(pen); + brush.setColor(QColor(i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A)); + p->setBrush(brush); + break; + + case SET_SOLID: + pen.setStyle(Qt::SolidLine); + p->setPen(pen); + break; + + default: + break; + } + } +} + +void QtPLWidget::getPlotParameters(double & io_dXFact, double & io_dYFact, double & io_dXOffset, double & io_dYOffset) +{ + double w=(double)width(); + double h=(double)height(); + if(w/h>m_dAspectRatio) //Too wide, h is the limitating factor + { + io_dYFact=h/m_dHeight; + io_dXFact=h*m_dAspectRatio/m_dWidth; + io_dYOffset=0.; + io_dXOffset=(w-io_dXFact*m_dWidth)/2.; + } + else + { + io_dXFact=w/m_dWidth; + io_dYFact=w/m_dAspectRatio/m_dHeight; + io_dXOffset=0.; + io_dYOffset=(h-io_dYFact*m_dHeight)/2.; + } +} +#endif + +#if defined(PLD_extqt) +QtExtWidget::QtExtWidget(int i_iWidth, int i_iHeight, QWidget* parent): + QtPLWidget(i_iWidth, i_iHeight, parent) +{ + cursorParameters.isTracking=false; + cursorParameters.cursor_x=-1.0; + cursorParameters.cursor_y=-1.0; + killed=false; +} + +QtExtWidget::~QtExtWidget() +{ + killed=true; + QCoreApplication::processEvents(QEventLoop::AllEvents, 10); + if(m_pixPixmap!=NULL) delete m_pixPixmap; + if(m_painterP!=NULL) delete m_painterP; +// if(pic!=NULL) delete pic; + m_pixPixmap=NULL; + m_painterP=NULL; +// pic=NULL; +} + +void QtExtWidget::captureMousePlotCoords(PLFLT* x, PLFLT* y) +{ + setMouseTracking(true); + cursorParameters.isTracking=true; + cursorParameters.cursor_x= + cursorParameters.cursor_y=-1.; + do + { + QCoreApplication::processEvents(QEventLoop::AllEvents, 10); + } while(cursorParameters.isTracking && !killed); + + *x=cursorParameters.cursor_x; + *y=cursorParameters.cursor_y; +} + +void QtExtWidget::mouseMoveEvent(QMouseEvent* event) +{ + if(!cursorParameters.isTracking) return; + + double x_fact, y_fact, x_offset, y_offset; //Parameters to scale and center the plot on the widget + + getPlotParameters(x_fact, y_fact, x_offset, y_offset); + + cursorParameters.cursor_x=(PLFLT)event->x(); + cursorParameters.cursor_y=(PLFLT)event->y(); + + double ratio_x; + double ratio_y; + ratio_x=(cursorParameters.cursor_x-x_offset)/(width()-2.*x_offset); + ratio_y=(cursorParameters.cursor_y-y_offset)/(height()-2.*y_offset); + + PLFLT a,b; + PLINT c; + plcalc_world(ratio_x, 1.-ratio_y, &a, &b, &c); + + if(c<0) + { + cursorParameters.cursor_x=-1.; + cursorParameters.cursor_y=-1.; + } + + update(); +} + +void QtExtWidget::mousePressEvent(QMouseEvent* event) +{ +} + +void QtExtWidget::mouseReleaseEvent(QMouseEvent* event) +{ + if(!cursorParameters.isTracking) return; + + double x_fact, y_fact, x_offset, y_offset; //Parameters to scale and center the plot on the widget + + getPlotParameters(x_fact, y_fact, x_offset, y_offset); + + cursorParameters.cursor_x=(PLFLT)event->x(); + cursorParameters.cursor_y=(PLFLT)event->y(); + cursorParameters.isTracking=false; + setMouseTracking(false); + + double ratio_x; + double ratio_y; + ratio_x=(cursorParameters.cursor_x-x_offset)/(width()-2.*x_offset); + ratio_y=(cursorParameters.cursor_y-y_offset)/(height()-2.*y_offset); + + PLFLT a,b; + PLINT c; + plcalc_world(ratio_x, 1.-ratio_y, &a, &b, &c); + + if(c<0) + { + cursorParameters.cursor_x=-1.; + cursorParameters.cursor_y=-1.; + } + else + { + cursorParameters.cursor_x=a; + cursorParameters.cursor_y=b; + } + + update(); +} + +void QtExtWidget::paintEvent(QPaintEvent* event) +{ + QtPLWidget::paintEvent(event); + + if(!cursorParameters.isTracking || cursorParameters.cursor_x<0) return; + + QPainter p(this); + + p.setPen(QPen(Qt::white)); + + p.drawLine((int)cursorParameters.cursor_x, 0, (int)cursorParameters.cursor_x, height()); + p.drawLine(0, (int)cursorParameters.cursor_y, width(), (int)cursorParameters.cursor_y); + + p.end(); +} + +void plsetqtdev(QtExtWidget* widget) +{ + plsc->dev = (void*)widget; +} + +void plfreeqtdev() +{ + delete ((QtExtWidget*)plsc->dev); + plsc->dev=NULL; +} +#endif + Property changes on: trunk/bindings/qt_gui/plqt.cpp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/cmake/modules/qt.cmake =================================================================== --- trunk/cmake/modules/qt.cmake 2009-06-26 18:06:32 UTC (rev 10072) +++ trunk/cmake/modules/qt.cmake 2009-06-26 18:20:32 UTC (rev 10073) @@ -34,10 +34,15 @@ # qt_COMPILE_FLAGS - individual COMPILE_FLAGS required to compile wxwidgets # device. # qt_LINK_FLAGS - list of full path names of libraries and +# qt_TARGETS - list of targets which the qt dynamic device +# depends on. # linker flags for dynamic wxwidgets device driver. # qt_RPATH - RPATH directory list for qt device driver. -# DRIVERS_LINK_FLAGS - list of device LINK_FLAGS for case -# when ENABLE_DYNDRIVERS OFF. +# DRIVERS_LINK_FLAGS - list of device LINK_FLAGS for case when +# ENABLE_DYNDRIVERS OFF. (qt_TARGETS not included +# since source code used instead of this target +# for ENABLE_DYNDRIVERS OFF.) +# qt_SOURCE - list of source files to be appended to qt.cpp. # ENABLE_qt - ON means the plplot_qt library is enabled. # ENABLE_pyqt4 - ON means the plplot_pyqt4 Python extension module # is enabled. @@ -47,6 +52,10 @@ find_package(Qt4) if(PLD_bmpqt OR PLD_jpgqt OR PLD_pngqt OR PLD_ppmqt OR PLD_tiffqt OR PLD_epsqt OR PLD_pdfqt OR PLD_qtwidget OR PLD_svgqt OR PLD_extqt) + set(ANY_QT_DEVICE ON) +endif(PLD_bmpqt OR PLD_jpgqt OR PLD_pngqt OR PLD_ppmqt OR PLD_tiffqt OR PLD_epsqt OR PLD_pdfqt OR PLD_qtwidget OR PLD_svgqt OR PLD_extqt) + +if(ANY_QT_DEVICE) if(QT4_FOUND) if(PLD_svgqt AND ${QT_VERSION_MINOR} GREATER 2) set(QT_USE_QTSVG 1) @@ -65,7 +74,6 @@ #message("qt_LINK_FLAGS = ${qt_LINK_FLAGS}") set(qt_RPATH ${QT_LIBRARY_DIR}) #message("qt_LIBRARY_DIR = ${qt_LIBRARY_DIR}") - set(DRIVERS_LINK_FLAGS ${DRIVERS_LINK_FLAGS} ${qt_LINK_FLAGS}) else(QT4_FOUND AND QT_LIBRARIES) message(STATUS "QT_LIBRARIES not found so disabling all qt devices") set(PLD_bmpqt OFF CACHE BOOL "Enable Qt Windows bmp device" FORCE) @@ -79,7 +87,7 @@ set(PLD_svgqt OFF CACHE BOOL "Enable Qt SVG device" FORCE) set(PLD_extqt OFF CACHE BOOL "Enable Qt ext device" FORCE) endif(QT4_FOUND AND QT_LIBRARIES) -endif(PLD_bmpqt OR PLD_jpgqt OR PLD_pngqt OR PLD_ppmqt OR PLD_tiffqt OR PLD_epsqt OR PLD_pdfqt OR PLD_qtwidget OR PLD_svgqt OR PLD_extqt) +endif(ANY_QT_DEVICE) if(DEFAULT_NO_BINDINGS) option(ENABLE_qt "Enable Qt bindings" OFF) @@ -111,6 +119,24 @@ set(qt_gui_true "#") endif(ENABLE_qt) +if(ANY_QT_DEVICE) + if(ENABLE_DYNDRIVERS) + if(ENABLE_qt) + set(qt_SOURCE) + set(qt_TARGETS plplotqt${LIB_TAG}) + else(ENABLE_qt) + # if qt disabled, then must include full source and forget + # qt_TARGETS for this dynamic device. + set(qt_SOURCE ${CMAKE_SOURCE_DIR}/bindings/qt_gui/plqt.cpp) + endif(ENABLE_qt) + else(ENABLE_DYNDRIVERS) + # N.B. no qt_TARGETS here since use appropriate source code (see below) + # instead to break circular linking. + set(DRIVERS_LINK_FLAGS ${DRIVERS_LINK_FLAGS} ${qt_LINK_FLAGS}) + set(qt_SOURCE ${CMAKE_SOURCE_DIR}/bindings/qt_gui/plqt.cpp) + endif(ENABLE_DYNDRIVERS) +endif(ANY_QT_DEVICE) + if(ENABLE_pyqt4) find_program(SIP_EXECUTABLE sip) if(NOT SIP_EXECUTABLE) Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2009-06-26 18:06:32 UTC (rev 10072) +++ trunk/drivers/qt.cpp 2009-06-26 18:20:32 UTC (rev 10073) @@ -34,11 +34,14 @@ #include "qt.h" #include <QMutexLocker> +extern int vectorize; +extern MasterHandler handler; + // global variables initialised in init(), used in tidy() // QApplication* app=NULL; -int argc; // argc and argv have to exist when tidy() is used, thus they are made global -char ** argv; -int appCounter=0; // to be rigorous, all uses should be placed between mutexes +static int argc; // argc and argv have to exist when tidy() is used, thus they are made global +static char **argv; +static int appCounter = 0; // to be rigorous, all uses should be placed between mutexes // Drivers declaration PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_qt = @@ -74,13 +77,9 @@ #endif ; -static int vectorize=0; - static DrvOpt qt_options[]={ {"text_vectorize", DRV_INT, &vectorize, "Vectorize fonts on output (0|1)"}, {NULL, DRV_INT, NULL, NULL}}; -MasterHandler handler; - bool initQtApp(bool isGUI) { QMutexLocker locker(&QtPLDriver::mutex); @@ -212,329 +211,7 @@ void plD_state_qt(PLStream *, PLINT); void plD_esc_qt(PLStream *, PLINT, void*); -///////////// Generic Qt driver class ///////////////// -QMutex QtPLDriver::mutex; - -QtPLDriver::QtPLDriver(PLINT i_iWidth, PLINT i_iHeight) -{ - m_dWidth=i_iWidth; - m_dHeight=i_iHeight; -} - -QtPLDriver::~QtPLDriver() -{ -} - -void QtPLDriver::drawLine(short x1, short y1, short x2, short y2) -{ - if(!m_painterP->isActive()) return; - QLineF line( (PLFLT)x1*downscale, - m_dHeight-(PLFLT)y1*downscale, - (PLFLT)x2*downscale, - m_dHeight-(PLFLT)y2*downscale - ); - - m_painterP->drawLine(line); -} - -void QtPLDriver::drawPolyline(short * x, short * y, PLINT npts) -{ - if(!m_painterP->isActive()) return; - QPointF * polyline=new QPointF[npts]; - for(int i=0; i<npts; ++i) - { - polyline[i].setX((PLFLT)x[i]*downscale); - polyline[i].setY(m_dHeight-(PLFLT)y[i]*downscale); - } - m_painterP->drawPolyline(polyline, npts); - delete[] polyline; -} - -void QtPLDriver::drawPolygon(short * x, short * y, PLINT npts) -{ - if(!m_painterP->isActive()) return; - QPointF * polygon=new QPointF[npts]; - for(int i=0; i<npts; ++i) - { - polygon[i].setX((PLFLT)x[i]*downscale); - polygon[i].setY(m_dHeight-(PLFLT)y[i]*downscale); - } - m_painterP->drawPolygon(polygon, npts); - delete[] polygon; -} - - -QFont QtPLDriver::getFont(PLUNICODE unicode) -{ - // Get new font parameters - unsigned char fontFamily, fontStyle, fontWeight; - - plP_fci2hex(unicode, &fontFamily, PL_FCI_FAMILY); - plP_fci2hex(unicode, &fontStyle, PL_FCI_STYLE); - plP_fci2hex(unicode, &fontWeight, PL_FCI_WEIGHT); - - QFont f; - - f.setPointSizeF(currentFontSize*currentFontScale<4 ? 4 : currentFontSize*currentFontScale); - - switch(fontFamily) { - case 1: - f.setStyleHint(QFont::Serif); -// f.setFamily("Times"); - break; - case 2: - f.setStyleHint(QFont::TypeWriter); -// f.setFamily("Courier"); - break; - case 0: case 3: case 4:default: - f.setStyleHint(QFont::SansSerif); -// f.setFamily("Helvetica"); - break; - } - f.setFamily(""); // no family name, forcing Qt to find an appropriate font by itself - - if(fontStyle) f.setItalic(true); - if(fontWeight) f.setWeight(QFont::Bold); - else f.setWeight(QFont::Normal); - - f.setUnderline(underlined); - f.setOverline(overlined); - - return f; -} - -void QtPLDriver::drawTextInPicture(QPainter* p, const QString& text) -{ -// if(!m_painterP->isActive()) return; - - QRectF rect(0., 0., 0., 0.); - QRectF bounding; - QPicture tempPic; - QPainter tempPainter(&tempPic); - tempPainter.setFont(p->font()); - - if(vectorize) - { - bounding=tempPainter.boundingRect(rect, Qt::AlignHCenter|Qt::AlignVCenter|Qt::TextDontClip, text); - - QPen savePen=tempPainter.pen(); - QPen pen=savePen; - pen.setStyle(Qt::NoPen); - tempPainter.setPen(pen); - - double offset=QFontMetrics(tempPainter.font(), &tempPic).boundingRect(text).top(); // Distance between the baseline and the top of the bounding box - - QPainterPath path; - path.addText(QPointF(bounding.left(), bounding.top()-offset), tempPainter.font(), text); - tempPainter.drawPath(path); - tempPainter.setPen(pen); - } - else - { - tempPainter.drawText(rect, Qt::AlignHCenter|Qt::AlignVCenter|Qt::TextDontClip, text, &bounding); - } - - tempPainter.end(); - - p->drawPicture((int)(xOffset+bounding.width()/2.), -yOffset, tempPic); - - xOffset+=bounding.width(); -} - -QPicture QtPLDriver::getTextPicture(PLUNICODE fci, PLUNICODE* text, int len, PLFLT chrht) -{ - char plplotEsc; - plgesc( &plplotEsc ); - - double old_fontScale; - - QPicture res; - QPainter p(&res); - - QString currentString; - - yOffset=0.; - xOffset=0.; - - // Scaling factor of 1.6 determined empirically to make all qt results - // have the same character size as cairo results (taking into account - // the slightly different actual glyph sizes for the different - // default fonts found by cairo and qt). - currentFontSize=chrht*POINTS_PER_INCH/25.4*1.45; - currentFontScale=1.; - underlined=false; - overlined=false; - - p.setFont(getFont(fci)); - - int i=0; - while(i < len) - { - if(text[i]<PL_FCI_MARK) // Not a font change - { - if(text[i]!=(PLUNICODE)plplotEsc) - { - currentString.append(QString((QChar*)&(text[i]), 1)); - ++i; - continue; - } - ++i; // Now analyse the escaped character - switch(text[i]) - { - case 'd': - drawTextInPicture(&p, currentString); - - currentString.clear(); - old_fontScale=currentFontScale; - if( yOffset>0.0 ) - currentFontScale *= 1.25; /* Subscript scaling parameter */ - else - currentFontScale *= 0.8; /* Subscript scaling parameter */ - - yOffset -= currentFontSize * old_fontScale / 2.; - - p.setFont(getFont(fci)); - break; - case 'u': - drawTextInPicture(&p, currentString); - - currentString.clear(); - if( yOffset<0.0 ) - currentFontScale *= 1.25; /* Subscript scaling parameter */ - else - currentFontScale *= 0.8; /* Subscript scaling parameter */ - - yOffset += currentFontSize * currentFontScale / 2.; - p.setFont(getFont(fci)); - break; - case '-': - drawTextInPicture(&p, currentString); - - currentString.clear(); - underlined=!underlined; - p.setFont(getFont(fci)); - break; - case '+': - drawTextInPicture(&p, currentString); - - currentString.clear(); - overlined=!overlined; - p.setFont(getFont(fci)); - break; - case '#': - currentString.append(QString((QChar*)&(text[i]), 1)); - break; - default : - std::cout << "unknown escape char " << ((QChar)text[i]).toLatin1() << std::endl; - break; - } - } - else // Font change - { - drawTextInPicture(&p, currentString); - - currentString.clear(); - fci=text[i]; - p.setFont(getFont(fci)); - } - ++i; - } - drawTextInPicture(&p, currentString); - - p.end(); - return res; -} - -void QtPLDriver::drawText(PLStream* pls, EscText* txt) -{ - if(!m_painterP->isActive()) return; - - /* Check that we got unicode, warning message and return if not */ - if( txt->unicode_array_len == 0 ) { - printf( "Non unicode string passed to a Qt driver, ignoring\n" ); - return; - } - - /* Check that unicode string isn't longer then the max we allow */ - if( txt->unicode_array_len >= 500 ) { - printf( "Sorry, the Qt drivers only handle strings of length < %d\n", 500 ); - return; - } - - PLFLT rotation, shear, stride; - plRotationShear( txt->xform, &rotation, &shear, &stride); - - double picDpi; - PLUNICODE fci; - plgfci( &fci ); - QPicture picText=getTextPicture(fci, txt->unicode_array, txt->unicode_array_len, pls->chrht); - picDpi=picText.logicalDpiY(); - - m_painterP->setClipping(true); - m_painterP->setClipRect(QRect((int)(pls->clpxmi*downscale), (int)(m_dHeight-pls->clpyma*downscale), (int)((pls->clpxma-pls->clpxmi)*downscale), (int)((pls->clpyma-pls->clpymi)*downscale)), Qt::ReplaceClip); - - rotation -= pls->diorot * M_PI / 2.0; - m_painterP->translate(txt->x*downscale, m_dHeight-txt->y*downscale); - QMatrix rotShearMatrix(cos(rotation)*stride, -sin(rotation)*stride, cos(rotation)*sin(shear)+sin(rotation)*cos(shear), -sin(rotation)*sin(shear)+cos(rotation)*cos(shear), 0., 0.); - - m_painterP->setWorldMatrix(rotShearMatrix, true); - - m_painterP->translate(-txt->just*xOffset*m_painterP->device()->logicalDpiY()/picDpi, 0.); - - m_painterP->drawPicture(0, 0, picText); - - m_painterP->setWorldMatrix(QMatrix()); - m_painterP->setClipping(false); -} - -void QtPLDriver::setColor(int r, int g, int b, double alpha) -{ - if(!m_painterP->isActive()) return; - - QPen p=m_painterP->pen(); - p.setColor(QColor(r, g, b, (int)(alpha*255))); - m_painterP->setPen(p); - - QBrush B=m_painterP->brush(); - B.setColor(QColor(r, g, b, (int)(alpha*255))); - B.setStyle(Qt::SolidPattern); - m_painterP->setBrush(B); -} - -void QtPLDriver::setWidth(PLINT w) -{ - if(!m_painterP->isActive()) return; - - QPen p=m_painterP->pen(); - p.setWidth(w); - m_painterP->setPen(p); -} - -void QtPLDriver::setDashed(PLINT nms, PLINT* mark, PLINT* space) -{ - if(!m_painterP->isActive()) return; - - QVector<qreal> vect; - for(int i=0; i<nms; ++i) - { - vect << (PLFLT)mark[i]*m_painterP->device()->logicalDpiX()/25400.; - vect << (PLFLT)space[i]*m_painterP->device()->logicalDpiX()/25400.; - } - QPen p=m_painterP->pen(); - p.setDashPattern(vect); - m_painterP->setPen(p); -} - -void QtPLDriver::setSolid() -{ - if(!m_painterP->isActive()) return; - - QPen p=m_painterP->pen(); - p.setStyle(Qt::SolidLine); - m_painterP->setPen(p); -} - // Generic driver interface void plD_line_qt(PLStream * pls, short x1a, short y1a, short x2a, short y2a) @@ -713,53 +390,7 @@ } ////////////////// Raster driver-specific definitions: class and interface functions ///////// - #if defined (PLD_bmpqt) || defined(PLD_jpgqt) || defined (PLD_pngqt) || defined(PLD_ppmqt) || defined(PLD_tiffqt) -QtRasterDevice::QtRasterDevice(int i_iWidth, int i_iHeight): - QtPLDriver(i_iWidth, i_iHeight), - QImage(i_iWidth, i_iHeight, QImage::Format_RGB32) -{ - // Painter initialised in the constructor contrary - // to buffered drivers, which paint only in doPlot(). - m_painterP=new QPainter(this); - QBrush b=m_painterP->brush(); - b.setStyle(Qt::SolidPattern); - m_painterP->setBrush(b); - m_painterP->setRenderHint(QPainter::Antialiasing, true); - - // Let's fill the background - m_painterP->fillRect(0, 0, width(), height(), QBrush(Qt::black)); - -// fontScalingFactor=1.; -} - -QtRasterDevice::~QtRasterDevice() -{ - if(m_painterP!=NULL) delete m_painterP; -} - -void QtRasterDevice::definePlotName(const char* fileName, const char* format) -{ - // Avoid buffer overflows - strncpy(this->format, format, 4); - this->format[4]='\0'; - - this->fileName=QString(fileName); -} - -void QtRasterDevice::savePlot() -{ - m_painterP->end(); - save(fileName, format, 85); - - m_painterP->begin(this); - m_painterP->setRenderHint(QPainter::Antialiasing, true); - QBrush b=m_painterP->brush(); - b.setStyle(Qt::SolidPattern); - m_painterP->setBrush(b); - m_painterP->fillRect(0, 0, width(), height(), QBrush(Qt::black)); -} - void plD_init_rasterqt(PLStream * pls) { double dpi; @@ -831,7 +462,6 @@ ((QtRasterDevice *)pls->dev)->savePlot(); handler.DeviceChangedPage((QtRasterDevice *)pls->dev); } - #endif #if defined(PLD_bmpqt) @@ -989,39 +619,7 @@ } #endif - #if defined(PLD_svgqt) && QT_VERSION >= 0x040300 -QtSVGDevice::QtSVGDevice(int i_iWidth, int i_iHeight): - QtPLDriver(i_iWidth, i_iHeight) -{ - m_painterP=NULL; - -// fontScalingFactor=1.; -} - -QtSVGDevice::~QtSVGDevice() -{ - if(m_painterP!=NULL) delete m_painterP; -} - -void QtSVGDevice::definePlotName(const char* fileName) -{ - setFileName(QString(fileName)); - setResolution(POINTS_PER_INCH); - setSize(QSize((int)m_dWidth, (int)m_dHeight)); -#if QT_VERSION >= 0x040500 - setViewBox(QRect(0, 0, (int)m_dWidth, (int)m_dHeight)); -#endif - - m_painterP=new QPainter(this); - m_painterP->fillRect(0, 0, (int)m_dWidth, (int)m_dHeight, QBrush(Qt::black)); -} - -void QtSVGDevice::savePlot() -{ - m_painterP->end(); -} - void plD_dispatch_init_svgqt(PLDispatchTable *pdt) { #ifndef ENABLE_DYNDRIVERS @@ -1123,64 +721,8 @@ if(isMaster) handler.setMasterDevice((QtSVGDevice *)pls->dev); handler.DeviceChangedPage((QtSVGDevice *)pls->dev); } - #endif -#if defined (PLD_epsqt) || defined(PLD_pdfqt) -QtEPSDevice::QtEPSDevice(int i_iWidth, int i_iHeight) -{ -#if QT_VERSION < 0x040400 - setPageSize(QPrinter::A4); -#else - setFullPage(true); - setPaperSize(QSizeF(i_iHeight, i_iWidth), QPrinter::Point); -#endif - setResolution(POINTS_PER_INCH); - setColorMode(QPrinter::Color); - setOrientation(QPrinter::Landscape); - setPrintProgram(QString("lpr")); - - if(i_iWidth<=0 || i_iHeight<=0) - { - m_dWidth=pageRect().width(); - m_dHeight=pageRect().height(); - } - else - { - m_dWidth=i_iWidth; - m_dHeight=i_iHeight; - } - m_painterP=NULL; - -// fontScalingFactor=1.; -} - -QtEPSDevice::~QtEPSDevice() -{ - if(m_painterP!=NULL) delete m_painterP; -} - -void QtEPSDevice::definePlotName(const char* fileName, int ifeps) -{ - setOutputFileName(QString(fileName)); - if(ifeps) - { - setOutputFormat(QPrinter::PostScriptFormat); - } - else - { - setOutputFormat(QPrinter::PdfFormat); - } - - m_painterP=new QPainter(this); - m_painterP->fillRect(0, 0, (int)m_dWidth, (int)m_dHeight, QBrush(Qt::black)); -} - -void QtEPSDevice::savePlot() -{ - m_painterP->end(); -} - #if defined(PLD_epsqt) void plD_dispatch_init_epsqt(PLDispatchTable *pdt) { @@ -1221,6 +763,7 @@ } #endif +#if defined(PLD_epsqt) || defined(PLD_pdfqt) void plD_init_epspdfqt(PLStream * pls) { vectorize=0; @@ -1306,6 +849,7 @@ if(isMaster) handler.setMasterDevice((QtEPSDevice *)pls->dev); handler.DeviceChangedPage((QtEPSDevice *)pls->dev); } +#endif #if defined(PLD_epsqt) void plD_bop_epsqt(PLStream *pls) @@ -1321,407 +865,6 @@ } #endif -#endif - -#if defined (PLD_qtwidget) || defined(PLD_extqt) - -QtPLWidget::QtPLWidget(int i_iWidth, int i_iHeight, QWidget* parent): - QWidget(parent), QtPLDriver(i_iWidth, i_iHeight) -{ - m_painterP=new QPainter; - - m_dAspectRatio=m_dWidth/m_dHeight; - - m_pixPixmap=NULL; - m_iOldSize=0; - pageNumber=0; - resize(i_iWidth, i_iHeight); -} - -QtPLWidget::~QtPLWidget() -{ - clearBuffer(); - if(m_pixPixmap!=NULL) delete m_pixPixmap; -} - -void QtPLWidget::clearWidget() -{ - clearBuffer(); - m_bAwaitingRedraw=true; - update(); -} - -void QtPLWidget::clearBuffer() -{ - for(QLinkedList<BufferElement>::iterator i=m_listBuffer.begin(); i!=m_listBuffer.end(); ++i) - { - switch(i->Element) - { - case POLYLINE: - case POLYGON: - delete[] i->Data.PolylineStruct->x; - delete[] i->Data.PolylineStruct->y; - delete i->Data.PolylineStruct; - break; - - case LINE: - delete i->Data.LineStruct; - break; - - case SET_COLOUR: - delete i->Data.ColourStruct; - break; - - case TEXT: - delete[] i->Data.TextStruct->text; - delete i->Data.TextStruct; - break; - default: - break; - } - } - - m_listBuffer.clear(); -} - -void QtPLWidget::drawLine(short x1, short y1, short x2, short y2) -{ - BufferElement el; - el.Element=LINE; - el.Data.LineStruct=new struct LineStruct_; - el.Data.LineStruct->x1=(PLFLT)x1*downscale; - el.Data.LineStruct->y1=m_dHeight-(PLFLT)y1*downscale; - el.Data.LineStruct->x2=(PLFLT)x2*downscale; - el.Data.LineStruct->y2=m_dHeight-(PLFLT)y2*downscale; - - m_listBuffer.append(el); -} - -void QtPLWidget::drawPolyline(short * x, short * y, PLINT npts) -{ - BufferElement el; - el.Element=POLYLINE; - el.Data.PolylineStruct=new struct PolylineStruct_; - el.Data.PolylineStruct->npts=(PLINT)npts; - el.Data.PolylineStruct->x=new PLFLT[npts]; - el.Data.PolylineStruct->y=new PLFLT[npts]; - for(int i=0; i<npts; ++i) - { - el.Data.PolylineStruct->x[i]=(PLFLT)x[i]*downscale; - el.Data.PolylineStruct->y[i]=m_dHeight-(PLFLT)y[i]*downscale; - } - - m_listBuffer.append(el); -} - -void QtPLWidget::drawPolygon(short * x, short * y, PLINT npts) -{ - BufferElement el; - el.Element=POLYGON; - el.Data.PolylineStruct=new struct PolylineStruct_; - el.Data.PolylineStruct->npts=(PLINT)npts; - el.Data.PolylineStruct->x=new PLFLT[npts]; - el.Data.PolylineStruct->y=new PLFLT[npts]; - for(int i=0; i<npts; ++i) - { - el.Data.PolylineStruct->x[i]=(PLFLT)x[i]*downscale; - el.Data.PolylineStruct->y[i]=m_dHeight-(PLFLT)y[i]*downscale; - } - - m_listBuffer.append(el); -} - -void QtPLWidget::setColor(int r, int g, int b, double alpha) -{ - BufferElement el; - el.Element=SET_COLOUR; - el.Data.ColourStruct=new struct ColourStruct_; - el.Data.ColourStruct->R=r; - el.Data.ColourStruct->G=g; - el.Data.ColourStruct->B=b; - el.Data.ColourStruct->A=alpha*255.; - - m_listBuffer.append(el); -} - -void QtPLWidget::setSolid() -{ - BufferElement el; - el.Element=SET_SOLID; - m_listBuffer.append(el); -} - -void QtPLWidget::setWidth(PLINT w) -{ - BufferElement el; - el.Element=SET_WIDTH; - el.Data.intParam=w; - m_listBuffer.append(el); -} - -void QtPLWidget::drawText(PLStream* pls, EscText* txt) -{ - BufferElement el; - el.Element=TEXT; - el.Data.TextStruct=new struct TextStruct_; - el.Data.TextStruct->x=txt->x*downscale; - el.Data.TextStruct->y=m_dHeight-txt->y*downscale; - el.Data.TextStruct->clipxmin=pls->clpxmi*downscale; - el.Data.TextStruct->clipymin=m_dHeight-pls->clpymi*downscale; - el.Data.TextStruct->clipxmax=pls->clpxma*downscale; - el.Data.TextStruct->clipymax=m_dHeight-pls->clpyma*downscale; - PLUNICODE fci; - plgfci(&fci); - el.Data.TextStruct->fci=fci; - PLFLT rotation, shear, stride; - plRotationShear( txt->xform, &rotation, &shear, &stride); - rotation -= pls->diorot * M_PI / 2.0; - el.Data.TextStruct->rotation=rotation; - el.Data.TextStruct->shear=shear; - el.Data.TextStruct->stride=stride; - el.Data.TextStruct->just=txt->just; - el.Data.TextStruct->text=new PLUNICODE[txt->unicode_array_len]; - memcpy(el.Data.TextStruct->text, txt->unicode_array, txt->unicode_array_len*sizeof(PLUNICODE)); - el.Data.TextStruct->len=txt->unicode_array_len; - el.Data.TextStruct->chrht=pls->chrht; - - m_listBuffer.append(el); - -} - -void QtPLWidget::drawTextInPicture(QPainter* p, const QString& text) -{ - QRectF rect(0., 0., 0., 0.); - QRectF bounding; - QPicture tempPic; - QPainter tempPainter(&tempPic); - tempPainter.setFont(p->font()); - - if(vectorize) - { - bounding=tempPainter.boundingRect(rect, Qt::AlignHCenter|Qt::AlignVCenter|Qt::TextDontClip, text); - - QPen savePen=tempPainter.pen(); - QPen pen=savePen; - pen.setStyle(Qt::NoPen); - tempPainter.setPen(pen); - - double offset=QFontMetrics(tempPainter.font(), &tempPic).boundingRect(text).top(); // Distance between the baseline and the top of the bounding box - - QPainterPath path; - path.addText(QPointF(bounding.left(), bounding.top()-offset), tempPainter.font(), text); - tempPainter.drawPath(path); - tempPainter.setPen(pen); - } - else - { - tempPainter.drawText(rect, Qt::AlignHCenter|Qt::AlignVCenter|Qt::TextDontClip, text, &bounding); - - } - - tempPainter.end(); - - p->drawPicture((int)(xOffset+bounding.width()/2.), -yOffset, tempPic); - xOffset+=bounding.width(); -} - -void QtPLWidget::renderText(QPainter* p, struct TextStruct_* s, double x_fact, double x_offset, double y_fact, double y_offset) -{ - if(s->len<=0 || s->len>=500) return; - QPicture picText=getTextPicture(s->fci, s->text, s->len, s->chrht*y_fact); - - double picDpi=picText.logicalDpiY(); - - p->setClipping(true); - p->setClipRect(QRectF(s->clipxmin*x_fact+x_offset, s->clipymax*y_fact+y_offset, (s->clipxmax-s->clipxmin)*x_fact, (-s->clipymax+s->clipymin)*y_fact), Qt::ReplaceClip); - - p->translate(s->x*x_fact+x_offset, s->y*y_fact+y_offset); - QMatrix rotShearMatrix(cos(s->rotation)*s->stride, -sin(s->rotation)*s->stride, cos(s->rotation)*sin(s->shear)+sin(s->rotation)*cos(s->shear), -sin(s->rotation)*sin(s->shear)+cos(s->rotation)*cos(s->shear), 0.,0.); - p->setWorldMatrix(rotShearMatrix, true); - - p->translate(-s->just*xOffset*p->device()->logicalDpiY()/picDpi, 0.); - - p->drawPicture(0., 0., picText); - - p->setWorldMatrix(QMatrix()); - - p->setClipping(false); -} - -void QtPLWidget::mouseReleaseEvent ( QMouseEvent * event ) -{ - if(event->button()==Qt::RightButton) - { - handler.DeviceChangedPage(this); - } -} - -void QtPLWidget::keyPressEvent(QKeyEvent* event) -{ - if(event->key()==Qt::Key_Enter || event->key()==Qt::Key_Return) - { - handler.DeviceChangedPage(this); - } -} - -void QtPLWidget::closeEvent(QCloseEvent* event) -{ - handler.DeviceClosed(this); - event->ignore(); -} - -void QtPLWidget::nextPage() -{ - clearWidget(); - pageNumber++; -} - -void QtPLWidget::resizeEvent( QResizeEvent * ) -{ - m_bAwaitingRedraw=true; - if(m_pixPixmap!=NULL) - { - delete m_pixPixmap; - m_pixPixmap=NULL; - } -} - -void QtPLWidget::paintEvent( QPaintEvent * ) -{ - double x_fact, y_fact, x_offset(0.), y_offset(0.); //Parameters to scale and center the plot on the widget - - getPlotParameters(x_fact, y_fact, x_offset, y_offset); - if(m_bAwaitingRedraw || m_pixPixmap==NULL || m_listBuffer.size()!=m_iOldSize) // If must regenerate image, draw it in the pixmap - { - if(m_pixPixmap!=NULL) delete m_pixPixmap; - m_pixPixmap=new QPixmap(width(), height()); - QPainter* painter=new QPainter; - painter->begin(m_pixPixmap); - - // Draw the margins and the background - painter->fillRect(0, 0, width(), height(), QBrush(Qt::white)); - painter->fillRect(0, 0, width(), height(), QBrush(Qt::gray, Qt::Dense4Pattern)); - painter->fillRect((int)x_offset, (int)y_offset, (int)floor(x_fact*m_dWidth+0.5), (int)floor(y_fact*m_dHeight+0.5), QBrush(Qt::black)); - - // Draw the plot - doPlot(painter, x_fact, y_fact, x_offset, y_offset); - painter->end(); - - m_bAwaitingRedraw=false; - m_iOldSize=m_listBuffer.size(); - - delete painter; - } - - // draw the current pixmap - m_painterP->begin(this); - - m_painterP->drawPixmap(0, 0, *m_pixPixmap); - - m_painterP->end(); -} - -void QtPLWidget::doPlot(QPainter* p, double x_fact, double y_fact, double x_offset, double y_offset) -{ - QLineF line; - QPointF * polyline; - PLINT npts; - QVector<qreal> vect; - QPen pen=p->pen(); - QBrush brush=p->brush(); - brush.setStyle(Qt::SolidPattern); - p->setBrush(brush); - p->setRenderHints(QPainter::Antialiasing, true); - - if(m_listBuffer.empty()) - { - p->fillRect(0, 0, (int)(x_fact+2.*x_offset), (int)(y_fact+2.*y_offset), QBrush()); - return; - } - // unrolls the buffer and draws each element accordingly - for(QLinkedList<BufferElement>::const_iterator i=m_listBuffer.begin(); i!=m_listBuffer.end(); ++i) - { - switch(i->Element) - { - case LINE: - line=QLineF(i->Data.LineStruct->x1*x_fact+x_offset, i->Data.LineStruct->y1*y_fact+y_offset, i->Data.LineStruct->x2*x_fact+x_offset, i->Data.LineStruct->y2*y_fact+y_offset); - p->drawLine(line); - break; - - case POLYLINE: - npts=i->Data.PolylineStruct->npts; - polyline=new QPointF[npts]; - for(int j=0; j<npts; ++j) - { - polyline[j].setX(i->Data.PolylineStruct->x[j]*x_fact+x_offset); - polyline[j].setY(i->Data.PolylineStruct->y[j]*y_fact+y_offset); - } - p->drawPolyline(polyline, npts); - delete[] polyline; - break; - - case POLYGON: - npts=i->Data.PolylineStruct->npts; - polyline=new QPointF[npts]; - for(int j=0; j<npts; ++j) - { - polyline[j].setX(i->Data.PolylineStruct->x[j]*x_fact+x_offset); - polyline[j].setY(i->Data.PolylineStruct->y[j]*y_fact+y_offset); - } - p->drawPolygon(polyline, npts); - delete[] polyline; - break; - - case TEXT: - renderText(p, i->Data.TextStruct, x_fact, x_offset, y_fact, y_offset); - break; - - case SET_WIDTH: - pen.setWidth(i->Data.intParam); - p->setPen(pen); - break; - - case SET_COLOUR: - pen.setColor(QColor(i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A)); - p->setPen(pen); - brush.setColor(QColor(i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A)); - p->setBrush(brush); - break; - - case SET_SOLID: - pen.setStyle(Qt::SolidLine); - p->setPen(pen); - break; - - default: - break; - } - } -} - -void QtPLWidget::getPlotParameters(double & io_dXFact, double & io_dYFact, double & io_dXOffset, double & io_dYOffset) -{ - double w=(double)width(); - double h=(double)height(); - if(w/h>m_dAspectRatio) //Too wide, h is the limitating factor - { - io_dYFact=h/m_dHeight; - io_dXFact=h*m_dAspectRatio/m_dWidth; - io_dYOffset=0.; - io_dXOffset=(w-io_dXFact*m_dWidth)/2.; - } - else - { - io_dXFact=w/m_dWidth; - io_dYFact=w/m_dAspectRatio/m_dHeight; - io_dXOffset=0.; - io_dYOffset=(h-io_dYFact*m_dHeight)/2.; - } -} - - -#endif - #if defined (PLD_qtwidget) void plD_dispatch_init_qtwidget(PLDispatchTable *pdt) { @@ -1810,131 +953,9 @@ qApp->processEvents(QEventLoop::WaitForMoreEvents); } } - #endif #if defined(PLD_extqt) -QtExtWidget::QtExtWidget(int i_iWidth, int i_iHeight, QWidget* parent): - QtPLWidget(i_iWidth, i_iHeight, parent) -{ - cursorParameters.isTracking=false; - cursorParameters.cursor_x=-1.0; - cursorParameters.cursor_y=-1.0; - killed=false; -} - -QtExtWidget::~QtExtWidget() -{ - killed=true; - QCoreApplication::processEvents(QEventLoop::AllEvents, 10); - if(m_pixPixmap!=NULL) delete m_pixPixmap; - if(m_painterP!=NULL) delete m_painterP; -// if(pic!=NULL) delete pic; - m_pixPixmap=NULL; - m_painterP=NULL; -// pic=NULL; -} - -void QtExtWidget::captureMousePlotCoords(PLFLT* x, PLFLT* y) -{ - setMouseTracking(true); - cursorParameters.isTracking=true; - cursorParameters.cursor_x= - cursorParameters.cursor_y=-1.; - do - { - QCoreApplication::processEvents(QEventLoop::AllEvents, 10); - } while(cursorParameters.isTracking && !killed); - - *x=cursorParameters.cursor_x; - *y=cursorParameters.cursor_y; -} - -void QtExtWidget::mouseMoveEvent(QMouseEvent* event) -{ - if(!cursorParameters.isTracking) return; - - double x_fact, y_fact, x_offset, y_offset; //Parameters to scale and center the plot on the widget - - getPlotParameters(x_fact, y_fact, x_offset, y_offset); - - cursorParameters.cursor_x=(PLFLT)event->x(); - cursorParameters.cursor_y=(PLFLT)event->y(); - - double ratio_x; - double ratio_y; - ratio_x=(cursorParameters.cursor_x-x_offset)/(width()-2.*x_offset); - ratio_y=(cursorParameters.cursor_y-y_offset)/(height()-2.*y_offset); - - PLFLT a,b; - PLINT c; - plcalc_world(ratio_x, 1.-ratio_y, &a, &b, &c); - - if(c<0) - { - cursorParameters.cursor_x=-1.; - cursorParameters.cursor_y=-1.; - } - - update(); -} - -void QtExtWidget::mousePressEvent(QMouseEvent* event) -{ -} - -void QtExtWidget::mouseReleaseEvent(QMouseEvent* event) -{ - if(!cursorParameters.isTracking) return; - - double x_fact, y_fact, x_offset, y_offset; //Parameters to scale and center the plot on the widget - - getPlotParameters(x_fact, y_fact, x_offset, y_offset); - - cursorParameters.cursor_x=(PLFLT)event->x(); - cursorParameters.cursor_y=(PLFLT)event->y(); - cursorParameters.isTracking=false; - setMouseTracking(false); - - double ratio_x; - double ratio_y; - ratio_x=(cursorParameters.cursor_x-x_offset)/(width()-2.*x_offset); - ratio_y=(cursorParameters.cursor_y-y_offset)/(height()-2.*y_offset); - - PLFLT a,b; - PLINT c; - plcalc_world(ratio_x, 1.-ratio_y, &a, &b, &c); - - if(c<0) - { - cursorParameters.cursor_x=-1.; - cursorParameters.cursor_y=-1.; - } - else - { - cursorParameters.cursor_x=a; - cursorParameters.cursor_y=b; - } - - update(); -} - -void QtExtWidget::paintEvent(QPaintEvent* event) -{ - QtPLWidget::paintEvent(event); - - if(!cursorParameters.isTracking || cursorParameters.cursor_x<0) return; - - QPainter p(this); - - p.setPen(QPen(Qt::white)); - - p.drawLine((int)cursorParameters.cursor_x, 0, (int)cursorParameters.cursor_x, height()); - p.drawLine(0, (int)cursorParameters.cursor_y, width(), (int)cursorParameters.cursor_y); - - p.end(); -} - void plD_dispatch_init_extqt(PLDispatchTable *pdt) { #ifndef ENABLE_DYNDRIVERS @@ -1992,23 +1013,10 @@ pls->dev_clear=0; pls->dev_text = 1; // want to draw text pls->dev_unicode... [truncated message content] |
From: <ai...@us...> - 2009-06-28 01:02:03
|
Revision: 10081 http://plplot.svn.sourceforge.net/plplot/?rev=10081&view=rev Author: airwin Date: 2009-06-28 01:01:56 +0000 (Sun, 28 Jun 2009) Log Message: ----------- Change plplot-test.sh so that the front-end name "perl" is replaced by "pdl" to be consistent with our cmake usage (e.g., ENABLE_pdl, rather than ENABLE_perl). This makes the new build system logic for the installed examples a bit more straightforward. Modified Paths: -------------- trunk/examples/Makefile.examples.in trunk/plplot_test/CMakeLists.txt trunk/plplot_test/plplot-test.sh.cmake Added Paths: ----------- trunk/plplot_test/test_pdl.sh.in Removed Paths: ------------- trunk/plplot_test/test_perl.sh.in Modified: trunk/examples/Makefile.examples.in =================================================================== --- trunk/examples/Makefile.examples.in 2009-06-28 00:56:41 UTC (rev 10080) +++ trunk/examples/Makefile.examples.in 2009-06-28 01:01:56 UTC (rev 10081) @@ -141,7 +141,7 @@ @PSC...@x0...c: perl/x01.pl @PSC_PERL_COMMENT@ @echo Generate Perl/PDL results for psc device -@PSC_PERL_COMMENT@ ./plplot-test.sh --verbose --front-end=perl --device=psc +@PSC_PERL_COMMENT@ ./plplot-test.sh --verbose --front-end=pdl --device=psc @PSC_PERL_COMMENT@test_noninteractive: x01pdl.psc @PSC_PERL_COMMENT@@COMPARE_COMMENT@compare: x01pdl.psc Modified: trunk/plplot_test/CMakeLists.txt =================================================================== --- trunk/plplot_test/CMakeLists.txt 2009-06-28 00:56:41 UTC (rev 10080) +++ trunk/plplot_test/CMakeLists.txt 2009-06-28 01:01:56 UTC (rev 10081) @@ -136,13 +136,13 @@ if(ENABLE_pdl) configure_file( - test_perl.sh.in - ${CMAKE_CURRENT_BINARY_DIR}/test_perl.sh + test_pdl.sh.in + ${CMAKE_CURRENT_BINARY_DIR}/test_pdl.sh @ONLY ) - list(APPEND SCRIPTS test_perl.sh) - add_test(examples_perl - ${SH_EXECUTABLE} -c "${TEST_ENVIRONMENT} ${TEST_SCRIPT_DEVICE} --front-end=perl" + list(APPEND SCRIPTS test_pdl.sh) + add_test(examples_pdl + ${SH_EXECUTABLE} -c "${TEST_ENVIRONMENT} ${TEST_SCRIPT_DEVICE} --front-end=pdl" ) endif(ENABLE_pdl) Modified: trunk/plplot_test/plplot-test.sh.cmake =================================================================== --- trunk/plplot_test/plplot-test.sh.cmake 2009-06-28 00:56:41 UTC (rev 10080) +++ trunk/plplot_test/plplot-test.sh.cmake 2009-06-28 01:01:56 UTC (rev 10081) @@ -47,7 +47,7 @@ Options: [--device=DEVICE] (DEVICE = any cmake-enabled device. psc is the default) - [--front-end=FE] (FE = one of c, cxx, f77, f95 java, octave, python, tcl, perl, ada, ocaml, lua or d) + [--front-end=FE] (FE = one of c, cxx, f77, f95 java, octave, python, tcl, pdl, ada, ocaml, lua or d) If this option is not specified, then all front-ends will be tested. More than one front-end may be given, like this --front-end="c cxx" @@ -111,7 +111,7 @@ -o $i = "octave" \ -o $i = "python" \ -o $i = "tcl" \ - -o $i = "perl" \ + -o $i = "pdl" \ -o $i = "ada" \ -o $i = "ocaml" \ -o $i = "lua" \ @@ -302,7 +302,7 @@ test "@ENABLE_octave@" = "ON" && FRONT_END="$FRONT_END octave" test "@ENABLE_python@" = "ON" && FRONT_END="$FRONT_END python" test "@ENABLE_tcl@" = "ON" && FRONT_END="$FRONT_END tcl" - test "@ENABLE_pdl@" = "ON" && FRONT_END="$FRONT_END perl" + test "@ENABLE_pdl@" = "ON" && FRONT_END="$FRONT_END pdl" test "@ENABLE_ada@" = "ON" && FRONT_END="$FRONT_END ada" test "@ENABLE_ocaml@" = "ON" && FRONT_END="$FRONT_END ocaml" test "@ENABLE_lua@" = "ON" && FRONT_END="$FRONT_END lua" Copied: trunk/plplot_test/test_pdl.sh.in (from rev 10066, trunk/plplot_test/test_perl.sh.in) =================================================================== --- trunk/plplot_test/test_pdl.sh.in (rev 0) +++ trunk/plplot_test/test_pdl.sh.in 2009-06-28 01:01:56 UTC (rev 10081) @@ -0,0 +1,70 @@ +#!@SH_EXECUTABLE@ +# Test suite for perl examples. +# +# Copyright (C) 2004 Alan W. Irwin +# +# This file is part of PLplot. +# +# PLplot is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Library Public License as published +# by the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# PLplot is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with PLplot; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +# This is called from plplot-test.sh with $perldir, $device, $dsuffix, +# $options, and possibly $verbose_test defined. + +# To build the c examples before running this script do the following: +# pushd $cdir; make; popd + +# Do the standard non-interactive examples. + +# Ensure correct version of the libraries are picked up in both the build +# tree and install tree. +lang="pdl" +if [ "$LD_LIBRARY_PATH" = "" ] ; then + export LD_LIBRARY_PATH=../src:@LIB_DIR@ +else + export LD_LIBRARY_PATH=../src:@LIB_DIR@:$LD_LIBRARY_PATH +fi + +if [ "@HAVE_PDL_GRAPHICS_PLPLOT_40@" = "ON" ] ; then + INDEX_LIST="01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31" +else + # Examples 02, 20, 21, 23, 24, 28, 29, and 30 require PDL::Graphics::PLplot + # version 0.46 or later. + INDEX_LIST="01 03 04 05 06 07 08 09 10 11 12 13 15 16 18 19 22 25 26 27" +fi + +for index in $INDEX_LIST ; do + if [ "$verbose_test" ] ; then + echo "x${index}.pl" + fi + if [ "$index" = "14" ] ; then + echo ${OUTPUT_DIR}/x${index}a${lang}%n.$dsuffix | \ + $perldir/x${index}.pl -dev $device -o ${OUTPUT_DIR}/x${index}${lang}%n.$dsuffix \ + $options 2> test.error >| ${OUTPUT_DIR}/x${index}${lang}_${dsuffix}.txt + status_code=$? + else + $perldir/x${index}.pl -dev $device -o ${OUTPUT_DIR}/x${index}${lang}%n.$dsuffix $options 2> test.error >| ${OUTPUT_DIR}/x${index}${lang}_${dsuffix}.txt + status_code=$? + fi + cat test.error + if [ "$status_code" -ne 0 ] ; then + exit $status_code + fi + # Look for any PLPLOT ERROR messages from plwarn that do not result in an + # exit code. + is_error=`grep -l 'PLPLOT ERROR' test.error` + if [ -n "$is_error" ] ; then + exit 1 + fi +done Property changes on: trunk/plplot_test/test_pdl.sh.in ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native Deleted: trunk/plplot_test/test_perl.sh.in =================================================================== --- trunk/plplot_test/test_perl.sh.in 2009-06-28 00:56:41 UTC (rev 10080) +++ trunk/plplot_test/test_perl.sh.in 2009-06-28 01:01:56 UTC (rev 10081) @@ -1,70 +0,0 @@ -#!@SH_EXECUTABLE@ -# Test suite for perl examples. -# -# Copyright (C) 2004 Alan W. Irwin -# -# This file is part of PLplot. -# -# PLplot is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Library Public License as published -# by the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# PLplot is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public License -# along with PLplot; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -# This is called from plplot-test.sh with $perldir, $device, $dsuffix, -# $options, and possibly $verbose_test defined. - -# To build the c examples before running this script do the following: -# pushd $cdir; make; popd - -# Do the standard non-interactive examples. - -# Ensure correct version of the libraries are picked up in both the build -# tree and install tree. -lang="pdl" -if [ "$LD_LIBRARY_PATH" = "" ] ; then - export LD_LIBRARY_PATH=../src:@LIB_DIR@ -else - export LD_LIBRARY_PATH=../src:@LIB_DIR@:$LD_LIBRARY_PATH -fi - -if [ "@HAVE_PDL_GRAPHICS_PLPLOT_40@" = "ON" ] ; then - INDEX_LIST="01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31" -else - # Examples 02, 20, 21, 23, 24, 28, 29, and 30 require PDL::Graphics::PLplot - # version 0.46 or later. - INDEX_LIST="01 03 04 05 06 07 08 09 10 11 12 13 15 16 18 19 22 25 26 27" -fi - -for index in $INDEX_LIST ; do - if [ "$verbose_test" ] ; then - echo "x${index}.pl" - fi - if [ "$index" = "14" ] ; then - echo ${OUTPUT_DIR}/x${index}a${lang}%n.$dsuffix | \ - $perldir/x${index}.pl -dev $device -o ${OUTPUT_DIR}/x${index}${lang}%n.$dsuffix \ - $options 2> test.error >| ${OUTPUT_DIR}/x${index}${lang}_${dsuffix}.txt - status_code=$? - else - $perldir/x${index}.pl -dev $device -o ${OUTPUT_DIR}/x${index}${lang}%n.$dsuffix $options 2> test.error >| ${OUTPUT_DIR}/x${index}${lang}_${dsuffix}.txt - status_code=$? - fi - cat test.error - if [ "$status_code" -ne 0 ] ; then - exit $status_code - fi - # Look for any PLPLOT ERROR messages from plwarn that do not result in an - # exit code. - is_error=`grep -l 'PLPLOT ERROR' test.error` - if [ -n "$is_error" ] ; then - exit 1 - fi -done This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-06-28 08:47:59
|
Revision: 10088 http://plplot.svn.sourceforge.net/plplot/?rev=10088&view=rev Author: airwin Date: 2009-06-28 08:46:58 +0000 (Sun, 28 Jun 2009) Log Message: ----------- Change qt.h location from drivers subdirectory to include subdirectory. Modified Paths: -------------- trunk/bindings/qt_gui/CMakeLists.txt trunk/bindings/qt_gui/pyqt4/CMakeLists.txt trunk/drivers/CMakeLists.txt trunk/include/CMakeLists.txt Added Paths: ----------- trunk/include/qt.h Removed Paths: ------------- trunk/drivers/qt.h Modified: trunk/bindings/qt_gui/CMakeLists.txt =================================================================== --- trunk/bindings/qt_gui/CMakeLists.txt 2009-06-28 08:46:21 UTC (rev 10087) +++ trunk/bindings/qt_gui/CMakeLists.txt 2009-06-28 08:46:58 UTC (rev 10088) @@ -74,7 +74,7 @@ if(MOC_OPTIONS) qt4_wrap_cpp( QT_MOC_OUTFILES - ${CMAKE_SOURCE_DIR}/drivers/qt.h + ${CMAKE_SOURCE_DIR}/include/qt.h OPTIONS ${MOC_OPTIONS} ) # message("QT_MOC_OUTFILES = ${QT_MOC_OUTFILES}") Modified: trunk/bindings/qt_gui/pyqt4/CMakeLists.txt =================================================================== --- trunk/bindings/qt_gui/pyqt4/CMakeLists.txt 2009-06-28 08:46:21 UTC (rev 10087) +++ trunk/bindings/qt_gui/pyqt4/CMakeLists.txt 2009-06-28 08:46:58 UTC (rev 10088) @@ -56,7 +56,6 @@ # Assume sip.h can be found in PYTHON_INCLUDE_PATH include_directories( - ${CMAKE_SOURCE_DIR}/drivers ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/lib/qsastime ${CMAKE_BINARY_DIR} Modified: trunk/drivers/CMakeLists.txt =================================================================== --- trunk/drivers/CMakeLists.txt 2009-06-28 08:46:21 UTC (rev 10087) +++ trunk/drivers/CMakeLists.txt 2009-06-28 08:46:58 UTC (rev 10088) @@ -24,14 +24,6 @@ DESTINATION ${DOC_DIR} ) -#qt.h only useful if anyone wants to build a Qt application with the Qt widget driver -if(PLD_qtwidget OR PLD_extqt) - install( - FILES qt.h - DESTINATION ${INCLUDE_DIR} - ) -endif(PLD_qtwidget OR PLD_extqt) - if(ENABLE_DYNDRIVERS) include_directories( ${CMAKE_SOURCE_DIR}/include @@ -125,7 +117,7 @@ if(MOC_OPTIONS) qt4_wrap_cpp( QT_MOC_OUTFILES - ${CMAKE_CURRENT_SOURCE_DIR}/qt.h + ${CMAKE_SOURCE_DIR}/include/qt.h OPTIONS ${MOC_OPTIONS} ) # message("QT_MOC_OUTFILES = ${QT_MOC_OUTFILES}") Deleted: trunk/drivers/qt.h =================================================================== --- trunk/drivers/qt.h 2009-06-28 08:46:21 UTC (rev 10087) +++ trunk/drivers/qt.h 2009-06-28 08:46:58 UTC (rev 10088) @@ -1,428 +0,0 @@ -/* - - This software is provided under the LGPL in March 2009 by the - Cluster Science Centre - QSAS team, - Imperial College, London - - Copyright (C) 2009 Imperial College, London - Copyright (C) 2009 Alan W. Irwin - - This is free software; you can redistribute it and/or modify - it under the terms of the GNU General Lesser Public License as published - by the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This software is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - To received a copy of the GNU Library General Public License - write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - History: - - - March 2009: v1.00 - Initial release. - -*/ - -/* -Interpretation of the -geometry XSIZExYSIZE option (or the third and fourth - parameters of plspage if those are specified by the user instead) for - the various devices: -- the raster devices (bmpqt, jpgqt, pngqt, ppmqt, tiffqt): - XSIZE and YSIZE define the x and y size in pixels -- qtwidget: - XSIZE and YSIZE define the default x and y size of the widget in - pixels, as well as its aspect ratio, which is kept when the widget is - resized. -- svgqt, epsqt, pdfqt: - XSIZE and YSIZE define the x and y size in points (1/72 of inches). - EPS and PDF files will be drawn in A4 pages for Qt versions before 4.4 - -Interpretation of the -dpi DPI option (or the first parameter of - plspage if that is specified by the user instead). - DPI is ignored for all but the raster devices. For those devices - DPI should be set to the DPI value of the monitor being used to view - the results if exact character sizes are desired. Otherwise, DEFAULT_DPI - (set to an average value for modern monitors) is used instead. - */ - -#ifndef QT_H -#define QT_H - -#include <iostream> -#include <QImage> -#include <QPainter> -#include <QLinkedList> -#include <QPrinter> -#include <QApplication> -#include <QWidget> -#include <QMouseEvent> -#include <QTabWidget> -#include <QMainWindow> -#include <QPicture> -#include <QMutex> - -#include "plplotP.h" -#include "drivers.h" - -// Used for devices (epsqt, pdfqt, svgqt) with known physical size in points. -#define POINTS_PER_INCH 72 - -// Average value of dots per inch assumed for modern monitors if the user -// does not specify a value appropriate to their monitor with plspage or -// the -dpi option. Used only for devices with size specified in pixels -// but not qtwidget since it has independent access to information (e.g., -// delivered by X) about the DPI of the monitor. So this value is only -// used for the raster devices (bmpqt, jpgqt, pngqt, ppmqt, tiffqt). -#define DEFAULT_DPI 72 - -// These values are in units of pixels (the raster devices and qtwidget) -// or points (epsqt, pdfqt, svgqt). In the points case, this corresponds -// to the A4 paper size. -#define QT_DEFAULT_X 842 -#define QT_DEFAULT_Y 595 - -class QtPLDriver; - -// Master Device Handler for multiple streams -// Only handles multiple Qt devices -class MasterHandler:public QObject -{ - Q_OBJECT - - public: - MasterHandler():QObject() - { - masterDevice=NULL; - } - - ~MasterHandler(){} - - bool isMasterDevice(QtPLDriver* d) - { - return d==masterDevice; - } - - void setMasterDevice(QtPLDriver* d) - { - masterDevice=d; - } - - void DeviceChangedPage(QtPLDriver* d) - { - if(d==masterDevice) - { - emit MasterChangedPage(); - } - } - - void DeviceClosed(QtPLDriver* d) - { - if(d==masterDevice) - { - emit MasterClosed(); - masterDevice=NULL; - } - } - signals: - void MasterChangedPage(); - - void MasterClosed(); - - protected: - QtPLDriver* masterDevice; -}; - -// Basic class, offering the common interface to all Qt plplot devices -class PLDLLIMPEXP_DRIVER QtPLDriver -{ - public: - // Constructor, taking the device size as arguments - QtPLDriver(PLINT i_iWidth=QT_DEFAULT_X, PLINT i_iHeight=QT_DEFAULT_Y); - - virtual ~QtPLDriver(); // does not delete emitter! - - // Draws a line from (x1, y1) to (x2, y2) in internal plplot coordinates - virtual void drawLine(short x1, short y1, short x2, short y2); - - virtual void drawPolyline(short * x, short * y, PLINT npts); - - virtual void drawPolygon(short * x, short * y, PLINT npts); - - virtual void drawText(PLStream* pls, EscText* txt); - - virtual void setColor(int r, int g, int b, double alpha); - - virtual void setWidth(PLINT w); - - virtual void setDashed(PLINT nms, PLINT* mark, PLINT* space); - - // Set pen to draw solid strokes (called after drawing dashed strokes) - virtual void setSolid(); - - // Conversion factor from internal plplot coordinates to device coordinates - double downscale; - double m_dWidth, m_dHeight; - - static QMutex mutex; // All-purpose mutex - - protected: - - // Returns font with the good size for a QPicture's resolution - QFont getFont(PLUNICODE code); - // Draws text in a QPicture using a sub-QPicture (!), updates the current xOffset - void drawTextInPicture(QPainter*, const QString&); - // Gets the QPicture displaying text, with the base chrht char height - QPicture getTextPicture(PLUNICODE fci, PLUNICODE* text, int len, PLFLT chrht); - - // Text-related variables - bool underlined; - bool overlined; - double currentFontScale; - double currentFontSize; - double yOffset; - double xOffset; - -// double fontScalingFactor;// To have a nice font size on qtwidget - - QPainter* m_painterP; -}; - -#if defined (PLD_bmpqt) || defined(PLD_jpgqt) || defined (PLD_pngqt) || defined(PLD_ppmqt) || defined(PLD_tiffqt) -// Driver painting whatever raster format Qt can save -class QtRasterDevice: public QtPLDriver, public QImage -{ - public: - QtRasterDevice(int i_iWidth=QT_DEFAULT_X, - int i_iHeight=QT_DEFAULT_Y); - - virtual ~QtRasterDevice(); - - void definePlotName(const char* fileName, const char* format); - - void savePlot(); - - virtual void setResolution(double dotsPerInch) - { - setDotsPerMeterX((int)((dotsPerInch/25.4)*1000.)); - setDotsPerMeterY((int)((dotsPerInch/25.4)*1000.)); - } - - protected: - char format[5]; - QString fileName; - -}; -#endif - -#if defined(PLD_svgqt) && QT_VERSION >= 0x040300 -#include <QSvgGenerator> -// Driver painting on an SVG device -class QtSVGDevice: public QtPLDriver, public QSvgGenerator -{ - public: - QtSVGDevice(int i_iWidth=QT_DEFAULT_X, - int i_iHeight=QT_DEFAULT_Y); - - virtual ~QtSVGDevice(); - - void definePlotName(const char* fileName); - - void savePlot(); - protected: -}; -#endif - -#if defined (PLD_epsqt) || defined (PLD_pdfqt) -// Driver painting on an EPS or PDF device, uses QPrinter -// A (possibly dummy) QApplication must be declared before use -class QtEPSDevice: public QtPLDriver, public QPrinter -{ - public: -#if QT_VERSION < 0x040400 - QtEPSDevice(int i_iWidth=-1, int i_iHeight=-1); -#else - QtEPSDevice(int i_iWidth=QT_DEFAULT_X, int i_iHeight=QT_DEFAULT_Y); -#endif - - virtual ~QtEPSDevice(); - - void definePlotName(const char* fileName, int ifeps); - - void savePlot(); - - protected: - -}; -#endif - -#if defined (PLD_qtwidget) || defined (PLD_extqt) - -typedef enum ElementType_ -{ - LINE, - POLYLINE, - POLYGON, - SET_WIDTH, - SET_COLOUR, - SET_SOLID, - TEXT -} ElementType; // Identifiers for elements of the buffer - -struct LineStruct_ -{ - PLFLT x1; - PLFLT x2; - PLFLT y1; - PLFLT y2; -}; - -struct PolylineStruct_ -{ - PLINT npts; - PLFLT* x; - PLFLT* y; -}; - -struct ColourStruct_ -{ - PLINT R, G, B, A; -}; - -struct TextStruct_ -{ - PLFLT x; - PLFLT y; - PLFLT clipxmin; - PLFLT clipymin; - PLFLT clipxmax; - PLFLT clipymax; - PLFLT rotation; - PLFLT shear; - PLFLT stride; - PLFLT just; - PLUNICODE* text; - PLUNICODE fci; - PLINT len; - PLFLT chrht; -}; - -class BufferElement -{ - public: - - ElementType Element; - - union DataType - { - struct LineStruct_* LineStruct; - - struct PolylineStruct_* PolylineStruct; - - struct ColourStruct_* ColourStruct; - - struct TextStruct_* TextStruct; - - PLINT intParam; - } Data; -}; - -// This widget allows to use plplot as a plotting engine in a Qt Application -// The aspect ratio of the plotted data is constant, so gray strips are used -// to delimit the page when the widget aspect ratio is not the one of the plotted page -class PLDLLIMPEXP_DRIVER QtPLWidget: public QWidget, public QtPLDriver -{ - Q_OBJECT - - public: - // Parameters are the actual size of the page, NOT the size of the widget - // Call QWidget::resize for that - QtPLWidget(int i_iWidth=QT_DEFAULT_X, int i_iHeight=QT_DEFAULT_Y, QWidget* parent=0); - - virtual ~QtPLWidget(); - - void clearWidget(); - void clearBuffer(); - - int pageNumber; - - void drawLine(short x1, short y1, short x2, short y2); - void drawPolyline(short * x, short * y, PLINT npts); - void drawPolygon(short * x, short * y, PLINT npts); - void setColor(int r, int g, int b, double alpha); - void setWidth(PLINT r); - void setSolid(); - void drawText(PLStream* pls, EscText* txt); - - protected: - - void resizeEvent(QResizeEvent*); - void paintEvent(QPaintEvent*); - - void getPlotParameters(double & io_dXFact, double & io_dYFact, double & io_dXOffset, double & io_dYOffset); // gives the parameters to scale and center the plot on the page - void doPlot(QPainter* p, double x_fact, double y_fact, double x_offset, double y_offset); // Actually draws the plot. Deported in a function for readability - void drawTextInPicture(QPainter* p, const QString& text); - void renderText(QPainter* p, struct TextStruct_* s, double x_fact, double x_offset, double y_fact, double y_offset); - - double m_dAspectRatio; // Is kept constant during resizes - QPixmap * m_pixPixmap; // stores the drawn image as long as it does not have to be regenerated - - QLinkedList<BufferElement> m_listBuffer; // Buffer holding the draw instructions - bool m_bAwaitingRedraw; - int m_iOldSize; // Holds the size of the buffer. Modified => image has to be redrawn - - - protected slots: - void mouseReleaseEvent ( QMouseEvent * event ); - void keyPressEvent(QKeyEvent* event); - void closeEvent(QCloseEvent* event); - void nextPage(); - - -}; - -#endif - -#if defined (PLD_extqt) -class PLDLLIMPEXP_DRIVER QtExtWidget: public QtPLWidget -{ - Q_OBJECT - - public: - QtExtWidget(int i_iWidth=QT_DEFAULT_X, int i_iHeight=QT_DEFAULT_Y, QWidget* parent=0); - - virtual ~QtExtWidget(); - - void captureMousePlotCoords(PLFLT* x, PLFLT* y); - - public slots: - - void mouseMoveEvent(QMouseEvent* event); - void mouseReleaseEvent(QMouseEvent* event); - void mousePressEvent(QMouseEvent* event); - - protected: - void paintEvent(QPaintEvent*); - - struct - { - bool isTracking; - double cursor_x, cursor_y; - } cursorParameters; - - bool killed; -}; - -PLDLLIMPEXP_DRIVER void plsetqtdev(QtExtWidget* widget); // Registers the widget as plot device, as the widget has to be created in the Qt application GUI, prior to any plplot call. Must be called before plinit(). - -PLDLLIMPEXP_DRIVER void plfreeqtdev(); // Deletes and unregisters the device. - -#endif - -#endif Modified: trunk/include/CMakeLists.txt =================================================================== --- trunk/include/CMakeLists.txt 2009-06-28 08:46:21 UTC (rev 10087) +++ trunk/include/CMakeLists.txt 2009-06-28 08:46:58 UTC (rev 10088) @@ -81,4 +81,11 @@ ${CMAKE_CURRENT_BINARY_DIR}/plConfig.h ${CMAKE_CURRENT_BINARY_DIR}/plDevs.h ) + +#qt.h only useful if anyone wants to build a Qt application with the Qt widget driver +if(PLD_qtwidget OR PLD_extqt) + list(APPEND include_INSTALLED_HEADERS qt.h) +endif(PLD_qtwidget OR PLD_extqt) + + install(FILES ${include_INSTALLED_HEADERS} DESTINATION ${INCLUDE_DIR}) Copied: trunk/include/qt.h (from rev 10066, trunk/drivers/qt.h) =================================================================== --- trunk/include/qt.h (rev 0) +++ trunk/include/qt.h 2009-06-28 08:46:58 UTC (rev 10088) @@ -0,0 +1,428 @@ +/* + + This software is provided under the LGPL in March 2009 by the + Cluster Science Centre + QSAS team, + Imperial College, London + + Copyright (C) 2009 Imperial College, London + Copyright (C) 2009 Alan W. Irwin + + This is free software; you can redistribute it and/or modify + it under the terms of the GNU General Lesser Public License as published + by the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This software is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + To received a copy of the GNU Library General Public License + write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + History: + + + March 2009: v1.00 + Initial release. + +*/ + +/* +Interpretation of the -geometry XSIZExYSIZE option (or the third and fourth + parameters of plspage if those are specified by the user instead) for + the various devices: +- the raster devices (bmpqt, jpgqt, pngqt, ppmqt, tiffqt): + XSIZE and YSIZE define the x and y size in pixels +- qtwidget: + XSIZE and YSIZE define the default x and y size of the widget in + pixels, as well as its aspect ratio, which is kept when the widget is + resized. +- svgqt, epsqt, pdfqt: + XSIZE and YSIZE define the x and y size in points (1/72 of inches). + EPS and PDF files will be drawn in A4 pages for Qt versions before 4.4 + +Interpretation of the -dpi DPI option (or the first parameter of + plspage if that is specified by the user instead). + DPI is ignored for all but the raster devices. For those devices + DPI should be set to the DPI value of the monitor being used to view + the results if exact character sizes are desired. Otherwise, DEFAULT_DPI + (set to an average value for modern monitors) is used instead. + */ + +#ifndef QT_H +#define QT_H + +#include <iostream> +#include <QImage> +#include <QPainter> +#include <QLinkedList> +#include <QPrinter> +#include <QApplication> +#include <QWidget> +#include <QMouseEvent> +#include <QTabWidget> +#include <QMainWindow> +#include <QPicture> +#include <QMutex> + +#include "plplotP.h" +#include "drivers.h" + +// Used for devices (epsqt, pdfqt, svgqt) with known physical size in points. +#define POINTS_PER_INCH 72 + +// Average value of dots per inch assumed for modern monitors if the user +// does not specify a value appropriate to their monitor with plspage or +// the -dpi option. Used only for devices with size specified in pixels +// but not qtwidget since it has independent access to information (e.g., +// delivered by X) about the DPI of the monitor. So this value is only +// used for the raster devices (bmpqt, jpgqt, pngqt, ppmqt, tiffqt). +#define DEFAULT_DPI 72 + +// These values are in units of pixels (the raster devices and qtwidget) +// or points (epsqt, pdfqt, svgqt). In the points case, this corresponds +// to the A4 paper size. +#define QT_DEFAULT_X 842 +#define QT_DEFAULT_Y 595 + +class QtPLDriver; + +// Master Device Handler for multiple streams +// Only handles multiple Qt devices +class MasterHandler:public QObject +{ + Q_OBJECT + + public: + MasterHandler():QObject() + { + masterDevice=NULL; + } + + ~MasterHandler(){} + + bool isMasterDevice(QtPLDriver* d) + { + return d==masterDevice; + } + + void setMasterDevice(QtPLDriver* d) + { + masterDevice=d; + } + + void DeviceChangedPage(QtPLDriver* d) + { + if(d==masterDevice) + { + emit MasterChangedPage(); + } + } + + void DeviceClosed(QtPLDriver* d) + { + if(d==masterDevice) + { + emit MasterClosed(); + masterDevice=NULL; + } + } + signals: + void MasterChangedPage(); + + void MasterClosed(); + + protected: + QtPLDriver* masterDevice; +}; + +// Basic class, offering the common interface to all Qt plplot devices +class PLDLLIMPEXP_DRIVER QtPLDriver +{ + public: + // Constructor, taking the device size as arguments + QtPLDriver(PLINT i_iWidth=QT_DEFAULT_X, PLINT i_iHeight=QT_DEFAULT_Y); + + virtual ~QtPLDriver(); // does not delete emitter! + + // Draws a line from (x1, y1) to (x2, y2) in internal plplot coordinates + virtual void drawLine(short x1, short y1, short x2, short y2); + + virtual void drawPolyline(short * x, short * y, PLINT npts); + + virtual void drawPolygon(short * x, short * y, PLINT npts); + + virtual void drawText(PLStream* pls, EscText* txt); + + virtual void setColor(int r, int g, int b, double alpha); + + virtual void setWidth(PLINT w); + + virtual void setDashed(PLINT nms, PLINT* mark, PLINT* space); + + // Set pen to draw solid strokes (called after drawing dashed strokes) + virtual void setSolid(); + + // Conversion factor from internal plplot coordinates to device coordinates + double downscale; + double m_dWidth, m_dHeight; + + static QMutex mutex; // All-purpose mutex + + protected: + + // Returns font with the good size for a QPicture's resolution + QFont getFont(PLUNICODE code); + // Draws text in a QPicture using a sub-QPicture (!), updates the current xOffset + void drawTextInPicture(QPainter*, const QString&); + // Gets the QPicture displaying text, with the base chrht char height + QPicture getTextPicture(PLUNICODE fci, PLUNICODE* text, int len, PLFLT chrht); + + // Text-related variables + bool underlined; + bool overlined; + double currentFontScale; + double currentFontSize; + double yOffset; + double xOffset; + +// double fontScalingFactor;// To have a nice font size on qtwidget + + QPainter* m_painterP; +}; + +#if defined (PLD_bmpqt) || defined(PLD_jpgqt) || defined (PLD_pngqt) || defined(PLD_ppmqt) || defined(PLD_tiffqt) +// Driver painting whatever raster format Qt can save +class QtRasterDevice: public QtPLDriver, public QImage +{ + public: + QtRasterDevice(int i_iWidth=QT_DEFAULT_X, + int i_iHeight=QT_DEFAULT_Y); + + virtual ~QtRasterDevice(); + + void definePlotName(const char* fileName, const char* format); + + void savePlot(); + + virtual void setResolution(double dotsPerInch) + { + setDotsPerMeterX((int)((dotsPerInch/25.4)*1000.)); + setDotsPerMeterY((int)((dotsPerInch/25.4)*1000.)); + } + + protected: + char format[5]; + QString fileName; + +}; +#endif + +#if defined(PLD_svgqt) && QT_VERSION >= 0x040300 +#include <QSvgGenerator> +// Driver painting on an SVG device +class QtSVGDevice: public QtPLDriver, public QSvgGenerator +{ + public: + QtSVGDevice(int i_iWidth=QT_DEFAULT_X, + int i_iHeight=QT_DEFAULT_Y); + + virtual ~QtSVGDevice(); + + void definePlotName(const char* fileName); + + void savePlot(); + protected: +}; +#endif + +#if defined (PLD_epsqt) || defined (PLD_pdfqt) +// Driver painting on an EPS or PDF device, uses QPrinter +// A (possibly dummy) QApplication must be declared before use +class QtEPSDevice: public QtPLDriver, public QPrinter +{ + public: +#if QT_VERSION < 0x040400 + QtEPSDevice(int i_iWidth=-1, int i_iHeight=-1); +#else + QtEPSDevice(int i_iWidth=QT_DEFAULT_X, int i_iHeight=QT_DEFAULT_Y); +#endif + + virtual ~QtEPSDevice(); + + void definePlotName(const char* fileName, int ifeps); + + void savePlot(); + + protected: + +}; +#endif + +#if defined (PLD_qtwidget) || defined (PLD_extqt) + +typedef enum ElementType_ +{ + LINE, + POLYLINE, + POLYGON, + SET_WIDTH, + SET_COLOUR, + SET_SOLID, + TEXT +} ElementType; // Identifiers for elements of the buffer + +struct LineStruct_ +{ + PLFLT x1; + PLFLT x2; + PLFLT y1; + PLFLT y2; +}; + +struct PolylineStruct_ +{ + PLINT npts; + PLFLT* x; + PLFLT* y; +}; + +struct ColourStruct_ +{ + PLINT R, G, B, A; +}; + +struct TextStruct_ +{ + PLFLT x; + PLFLT y; + PLFLT clipxmin; + PLFLT clipymin; + PLFLT clipxmax; + PLFLT clipymax; + PLFLT rotation; + PLFLT shear; + PLFLT stride; + PLFLT just; + PLUNICODE* text; + PLUNICODE fci; + PLINT len; + PLFLT chrht; +}; + +class BufferElement +{ + public: + + ElementType Element; + + union DataType + { + struct LineStruct_* LineStruct; + + struct PolylineStruct_* PolylineStruct; + + struct ColourStruct_* ColourStruct; + + struct TextStruct_* TextStruct; + + PLINT intParam; + } Data; +}; + +// This widget allows to use plplot as a plotting engine in a Qt Application +// The aspect ratio of the plotted data is constant, so gray strips are used +// to delimit the page when the widget aspect ratio is not the one of the plotted page +class PLDLLIMPEXP_DRIVER QtPLWidget: public QWidget, public QtPLDriver +{ + Q_OBJECT + + public: + // Parameters are the actual size of the page, NOT the size of the widget + // Call QWidget::resize for that + QtPLWidget(int i_iWidth=QT_DEFAULT_X, int i_iHeight=QT_DEFAULT_Y, QWidget* parent=0); + + virtual ~QtPLWidget(); + + void clearWidget(); + void clearBuffer(); + + int pageNumber; + + void drawLine(short x1, short y1, short x2, short y2); + void drawPolyline(short * x, short * y, PLINT npts); + void drawPolygon(short * x, short * y, PLINT npts); + void setColor(int r, int g, int b, double alpha); + void setWidth(PLINT r); + void setSolid(); + void drawText(PLStream* pls, EscText* txt); + + protected: + + void resizeEvent(QResizeEvent*); + void paintEvent(QPaintEvent*); + + void getPlotParameters(double & io_dXFact, double & io_dYFact, double & io_dXOffset, double & io_dYOffset); // gives the parameters to scale and center the plot on the page + void doPlot(QPainter* p, double x_fact, double y_fact, double x_offset, double y_offset); // Actually draws the plot. Deported in a function for readability + void drawTextInPicture(QPainter* p, const QString& text); + void renderText(QPainter* p, struct TextStruct_* s, double x_fact, double x_offset, double y_fact, double y_offset); + + double m_dAspectRatio; // Is kept constant during resizes + QPixmap * m_pixPixmap; // stores the drawn image as long as it does not have to be regenerated + + QLinkedList<BufferElement> m_listBuffer; // Buffer holding the draw instructions + bool m_bAwaitingRedraw; + int m_iOldSize; // Holds the size of the buffer. Modified => image has to be redrawn + + + protected slots: + void mouseReleaseEvent ( QMouseEvent * event ); + void keyPressEvent(QKeyEvent* event); + void closeEvent(QCloseEvent* event); + void nextPage(); + + +}; + +#endif + +#if defined (PLD_extqt) +class PLDLLIMPEXP_DRIVER QtExtWidget: public QtPLWidget +{ + Q_OBJECT + + public: + QtExtWidget(int i_iWidth=QT_DEFAULT_X, int i_iHeight=QT_DEFAULT_Y, QWidget* parent=0); + + virtual ~QtExtWidget(); + + void captureMousePlotCoords(PLFLT* x, PLFLT* y); + + public slots: + + void mouseMoveEvent(QMouseEvent* event); + void mouseReleaseEvent(QMouseEvent* event); + void mousePressEvent(QMouseEvent* event); + + protected: + void paintEvent(QPaintEvent*); + + struct + { + bool isTracking; + double cursor_x, cursor_y; + } cursorParameters; + + bool killed; +}; + +PLDLLIMPEXP_DRIVER void plsetqtdev(QtExtWidget* widget); // Registers the widget as plot device, as the widget has to be created in the Qt application GUI, prior to any plplot call. Must be called before plinit(). + +PLDLLIMPEXP_DRIVER void plfreeqtdev(); // Deletes and unregisters the device. + +#endif + +#endif Property changes on: trunk/include/qt.h ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-06-29 02:22:14
|
Revision: 10094 http://plplot.svn.sourceforge.net/plplot/?rev=10094&view=rev Author: airwin Date: 2009-06-29 01:48:32 +0000 (Mon, 29 Jun 2009) Log Message: ----------- Move to model where the CMake build system should recover from most broken compilers by eliminating the appropriate bindings and examples. Of course, a build of the most fundamental components of PLplot demands a working C compiler. Furthermore, it turns out that check_prototype_exists, one of our preliminary checks, requires a working C++ compiler. However, at this time it appears all other compilers can be optional. N.B. these changes have only been tested for a system where all compilers (Ada, C, C++, D, Fortran, and Java) work. The result was a default PLplot build (except for the -DENABLE_d=ON option) worked without obvious errors. Warning: the "safety net" aspect of these changes (when an attempt is made to build PLplot for a platform with broken compilers) should work but has not been tested. Modified Paths: -------------- trunk/CMakeLists.txt trunk/cmake/modules/ada.cmake trunk/cmake/modules/c++.cmake trunk/cmake/modules/d.cmake trunk/cmake/modules/fortran.cmake trunk/cmake/modules/java.cmake trunk/cmake/modules/plplot.cmake trunk/cmake/modules/qt.cmake trunk/cmake/modules/wxwidgets.cmake Modified: trunk/CMakeLists.txt =================================================================== --- trunk/CMakeLists.txt 2009-06-28 22:42:13 UTC (rev 10093) +++ trunk/CMakeLists.txt 2009-06-29 01:48:32 UTC (rev 10094) @@ -30,7 +30,12 @@ ${CMAKE_SOURCE_DIR}/cmake/UserOverride.cmake ) -project(plplot) +# It is a fatal error if no working C compiler is available to build +# the PLplot core C library and core C examples. All other compilers +# required by our bindings are optional in that if no working compiler +# of the kind needed is available, the associated bindings and +# examples are disabled. +project(plplot C) # For use under MSYS version 2.6.3 or above of cmake is required! # The variable MSYS is first known at this point in the build process Modified: trunk/cmake/modules/ada.cmake =================================================================== --- trunk/cmake/modules/ada.cmake 2009-06-28 22:42:13 UTC (rev 10093) +++ trunk/cmake/modules/ada.cmake 2009-06-29 01:48:32 UTC (rev 10094) @@ -26,6 +26,22 @@ endif(DEFAULT_NO_BINDINGS) if(ENABLE_ada) + # Find and check Ada compiler + enable_language(Ada OPTIONAL) + if(NOT CMAKE_Ada_COMPILER_WORKS) + message(STATUS "WARNING: no working Ada compiler so disabling Ada bindings and examples.") + set(ENABLE_ada OFF CACHE BOOL "Enable Ada bindings" FORCE) + endif(NOT CMAKE_Ada_COMPILER_WORKS) +endif(ENABLE_ada) + +if(ENABLE_ada) + if(NOT CMAKE_Ada_COMPILER) + message(STATUS "WARNING: Ada compiler not found so disabling Ada bindings and examples.") + set(ENABLE_ada OFF CACHE BOOL "Enable Ada bindings" FORCE) + endif(NOT CMAKE_Ada_COMPILER) +endif(ENABLE_ada) + +if(ENABLE_ada) find_library(GNAT_LIB NAMES gnat gnat-4.1 gnat-4.2 gnat-4.3 gnat-4.4) if(NOT GNAT_LIB) message(STATUS "WARNING: " @@ -36,12 +52,8 @@ endif(NOT GNAT_LIB) endif(ENABLE_ada) -if(ENABLE_ada) - enable_language(Ada) -endif(ENABLE_ada) - # New stuff by Jerry for source modifications for Ada 2007 or not Ada 2007. option(HAVE_ADA_2007 "Ada 2007?" OFF) Modified: trunk/cmake/modules/c++.cmake =================================================================== --- trunk/cmake/modules/c++.cmake 2009-06-28 22:42:13 UTC (rev 10093) +++ trunk/cmake/modules/c++.cmake 2009-06-29 01:48:32 UTC (rev 10094) @@ -30,8 +30,25 @@ # Always carry out C++ checks, since some drivers also use these as # well as the C++ bindings -# IF (ENABLE_cxx) +# Find and check C++ compiler. +enable_language(CXX OPTIONAL) + +if(NOT CMAKE_CXX_COMPILER_WORKS) + # This is fatal error message rather than a warning because C++ absolutely + # required for check_prototype_exists test (and perhaps other preliminary + # tests as well). + message(FATAL_ERROR "No working C++ compiler found so PLplot cannot be built.") + set(ENABLE_cxx OFF CACHE BOOL "Enable C++ bindings" FORCE) +endif(NOT CMAKE_CXX_COMPILER_WORKS) + +if(ENABLE_cxx) + if(NOT CMAKE_CXX_COMPILER) + message(STATUS "WARNING: C++ compiler not found so disabling C++ bindings and examples.") + set(ENABLE_cxx OFF CACHE BOOL "Enable C++ bindings" FORCE) + endif(NOT CMAKE_CXX_COMPILER) +endif(ENABLE_cxx) + # Check if "using namespace std;" works INCLUDE(TestForNamespace) @@ -47,5 +64,3 @@ # Need to add check if stdint.h can be used from c++ (HAVE_CXX_STDINT_H) INCLUDE(TestForStdintCXX) - -# ENDIF(ENABLE_cxx) Modified: trunk/cmake/modules/d.cmake =================================================================== --- trunk/cmake/modules/d.cmake 2009-06-28 22:42:13 UTC (rev 10093) +++ trunk/cmake/modules/d.cmake 2009-06-29 01:48:32 UTC (rev 10094) @@ -29,17 +29,18 @@ endif(DEFAULT_NO_BINDINGS) if(ENABLE_d) - # Check for gdc or dmd compiler - include(CMakeDetermineDCompiler) + # Find and check D compiler + enable_language(D OPTIONAL) + if(NOT CMAKE_D_COMPILER_WORKS) + message(STATUS "WARNING: no working D compiler so disabling D bindings and examples.") + set(ENABLE_d OFF CACHE BOOL "Enable D bindings" FORCE) + endif(NOT CMAKE_D_COMPILER_WORKS) +endif(ENABLE_d) + +if(ENABLE_d) if(NOT CMAKE_D_COMPILER) - message(STATUS "WARNING: " - "D compiler not found. Disabling D bindings" - ) + message(STATUS "WARNING: D compiler not found so disabling D bindings and examples.") set(ENABLE_d OFF CACHE BOOL "Enable D bindings" FORCE) endif(NOT CMAKE_D_COMPILER) endif(ENABLE_d) -if(ENABLE_d) - # Enable D language - enable_language(D) -endif(ENABLE_d) Modified: trunk/cmake/modules/fortran.cmake =================================================================== --- trunk/cmake/modules/fortran.cmake 2009-06-28 22:42:13 UTC (rev 10093) +++ trunk/cmake/modules/fortran.cmake 2009-06-29 01:48:32 UTC (rev 10094) @@ -31,21 +31,24 @@ endif(DEFAULT_NO_BINDINGS) if(ENABLE_f77 OR ENABLE_f95) - # Check for fortran compiler - include(CMakeDetermineFortranCompiler) + # Find and check Fortran compiler. + enable_language(Fortran OPTIONAL) + if(NOT CMAKE_Fortran_COMPILER_WORKS) + message(STATUS "WARNING: no working Fortran compiler so disabling Fortran bindings and examples.") + set(ENABLE_f77 OFF CACHE BOOL "Enable f77 bindings" FORCE) + set(ENABLE_f95 OFF CACHE BOOL "Enable f95 bindings" FORCE) + endif(NOT CMAKE_Fortran_COMPILER_WORKS) +endif(ENABLE_f77 OR ENABLE_f95) + +if(ENABLE_f77 OR ENABLE_f95) if(NOT CMAKE_Fortran_COMPILER) - message(STATUS "WARNING: " - "fortran compiler not found. Disabling f77/f95 bindings" - ) + message(STATUS "WARNING: Fortran compiler not found so disabling Fortran bindings and examples.") set(ENABLE_f77 OFF CACHE BOOL "Enable f77 bindings" FORCE) set(ENABLE_f95 OFF CACHE BOOL "Enable f95 bindings" FORCE) endif(NOT CMAKE_Fortran_COMPILER) -endif (ENABLE_f77 OR ENABLE_f95) +endif(ENABLE_f77 OR ENABLE_f95) if(ENABLE_f77 OR ENABLE_f95) - # Enable fortran language - enable_language(Fortran) - # Don't compile Fortran 95 binding if compiler doesn't support it if(ENABLE_f95 AND NOT CMAKE_Fortran_COMPILER_SUPPORTS_F90) message(STATUS "WARNING: " Modified: trunk/cmake/modules/java.cmake =================================================================== --- trunk/cmake/modules/java.cmake 2009-06-28 22:42:13 UTC (rev 10093) +++ trunk/cmake/modules/java.cmake 2009-06-29 01:48:32 UTC (rev 10094) @@ -41,23 +41,30 @@ endif(ENABLE_java AND NOT SWIG_FOUND) if(ENABLE_java) - # Check for java compiler - include(CMakeDetermineJavaCompiler) + # Find and check Java compiler. + enable_language(Java OPTIONAL) + if(NOT CMAKE_Java_COMPILER_WORKS) + message(STATUS "WARNING: no working Java compiler so disabling Java bindings and examples.") + set(ENABLE_java OFF CACHE BOOL "Enable java bindings" FORCE) + endif(NOT CMAKE_Java_COMPILER_WORKS) +endif(ENABLE_java) + +if(ENABLE_java) if(NOT CMAKE_Java_COMPILER) - message(STATUS "WARNING: " - "java compiler not found. Disabling java bindings") + message(STATUS "WARNING: Java compiler not found so disabling Java bindings and examples.") set(ENABLE_java OFF CACHE BOOL "Enable Java bindings" FORCE) endif(NOT CMAKE_Java_COMPILER) +endif(ENABLE_java) + +if(ENABLE_java) if(NOT CMAKE_Java_ARCHIVE) - message(STATUS "WARNING: " - "java archiver (jar) not found. Disabling java bindings") + message(STATUS "WARNING: java archiver (jar) not found. Disabling java bindings") set(ENABLE_java OFF CACHE BOOL "Enable Java bindings" FORCE) endif(NOT CMAKE_Java_ARCHIVE) endif(ENABLE_java) if(ENABLE_java) # Check for java environment - enable_language(Java) find_package(JNI) # If CMake doesn't find jni.h you need set CMAKE_INCLUDE_PATH if(NOT JAVA_INCLUDE_PATH) Modified: trunk/cmake/modules/plplot.cmake =================================================================== --- trunk/cmake/modules/plplot.cmake 2009-06-28 22:42:13 UTC (rev 10093) +++ trunk/cmake/modules/plplot.cmake 2009-06-29 01:48:32 UTC (rev 10094) @@ -123,6 +123,9 @@ # the ctype.h' macros work on characters with the high bit set, as # ANSI C requires. +# check_prototype_exists requires C++ +include(c++) + message(STATUS "Checking whether system has ANSI C header files") check_include_files("stdlib.h;stdarg.h;string.h;float.h" StandardHeadersExist) if(StandardHeadersExist) @@ -380,7 +383,7 @@ OFF ) # Load language specific files -include(c++) +# C++ done much earlier because check_prototype_exists macro requires it. include(fortran) include(java) include(python) Modified: trunk/cmake/modules/qt.cmake =================================================================== --- trunk/cmake/modules/qt.cmake 2009-06-28 22:42:13 UTC (rev 10093) +++ trunk/cmake/modules/qt.cmake 2009-06-29 01:48:32 UTC (rev 10094) @@ -55,6 +55,25 @@ endif(PLD_bmpqt OR PLD_jpgqt OR PLD_pngqt OR PLD_ppmqt OR PLD_tiffqt OR PLD_epsqt OR PLD_pdfqt OR PLD_qtwidget OR PLD_svgqt OR PLD_extqt) if(ANY_QT_DEVICE) + if(NOT CMAKE_CXX_COMPILER_WORKS) + message(STATUS "WARNING: no working C++ compiler so " + "disabling all qt devices." + ) + set(PLD_bmpqt OFF CACHE BOOL "Enable Qt Windows bmp device" FORCE) + set(PLD_jpgqt OFF CACHE BOOL "Enable Qt jpg device" FORCE) + set(PLD_pngqt OFF CACHE BOOL "Enable Qt png device" FORCE) + set(PLD_ppmqt OFF CACHE BOOL "Enable Qt ppm device" FORCE) + set(PLD_tiffqt OFF CACHE BOOL "Enable Qt tiff device" FORCE) + set(PLD_epsqt OFF CACHE BOOL "Enable Qt EPS device" FORCE) + set(PLD_pdfqt OFF CACHE BOOL "Enable Qt PDF device" FORCE) + set(PLD_qtwidget OFF CACHE BOOL "Enable Qt interactive device" FORCE) + set(PLD_svgqt OFF CACHE BOOL "Enable Qt SVG device" FORCE) + set(PLD_extqt OFF CACHE BOOL "Enable Qt ext device" FORCE) + set(ANY_QT_DEVICE OFF) + endif(NOT CMAKE_CXX_COMPILER_WORKS) +endif(ANY_QT_DEVICE) + +if(ANY_QT_DEVICE) find_package(Qt4) if(QT4_FOUND) if(PLD_svgqt AND ${QT_VERSION_MINOR} GREATER 2) Modified: trunk/cmake/modules/wxwidgets.cmake =================================================================== --- trunk/cmake/modules/wxwidgets.cmake 2009-06-28 22:42:13 UTC (rev 10093) +++ trunk/cmake/modules/wxwidgets.cmake 2009-06-29 01:48:32 UTC (rev 10094) @@ -29,12 +29,23 @@ # when ENABLE_DYNDRIVERS OFF. # Find wxWidgets needed for driver and bindings + if(PLD_wxwidgets OR PLD_wxpng) + if(NOT CMAKE_CXX_COMPILER_WORKS) + message(STATUS "WARNING: no working C++ compiler so " + "setting all wxwidgets devices to OFF." + ) + set(PLD_wxwidgets OFF CACHE BOOL "Enable wxwidgets device" FORCE) + set(PLD_wxpng OFF CACHE BOOL "Enable wxwidgets png device" FORCE) + endif(NOT CMAKE_CXX_COMPILER_WORKS) +endif(PLD_wxwidgets OR PLD_wxpng) + +if(PLD_wxwidgets OR PLD_wxpng) find_package(wxWidgets COMPONENTS base core QUIET) if(NOT wxWidgets_FOUND) message(STATUS "WARNING: wxWidgets not found so " - "setting PLD_wxwidgets to OFF." + "setting all wxwidgets devices to OFF." ) set(PLD_wxwidgets OFF CACHE BOOL "Enable wxwidgets device" FORCE) set(PLD_wxpng OFF CACHE BOOL "Enable wxwidgets png device" FORCE) @@ -43,6 +54,7 @@ include(TestForStdintCXX) endif(NOT wxWidgets_FOUND) endif(PLD_wxwidgets OR PLD_wxpng) + if(PLD_wxwidgets OR PLD_wxpng) string(REGEX REPLACE ";" " -I" wxwidgets_COMPILE_FLAGS @@ -88,6 +100,7 @@ ${wxwidgets_LINK_FLAGS} ) endif(PLD_wxwidgets OR PLD_wxpng) + if(DEFAULT_NO_BINDINGS) option(ENABLE_wxwidgets "Enable wxwidgets bindings" OFF) else(DEFAULT_NO_BINDINGS) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-06-30 01:03:39
|
Revision: 10096 http://plplot.svn.sourceforge.net/plplot/?rev=10096&view=rev Author: airwin Date: 2009-06-30 01:03:14 +0000 (Tue, 30 Jun 2009) Log Message: ----------- Work around CMake enable_language(<language> OPTIONAL) bug (where it errors out for missing or bad compilers rather than returning with CMAKE_<languageName>_COMPILER_WORKS as a status). The idea of the workaround is to first search for the compiler. If it does not exist then disable the appropriate component of PLplot with a WARNING message. Only if the compiler exists is there an attempt made to run the CMake enable_language language command to check the compiler. N.B. This workaround only works if the compiler is completely missing. Ada is ideosyncratic so this workaround does not solve the issue in that case. Also, this workaround does not solve the issue for existing but bad compilers that give results that fail for the try_compile that is run by the enable_language command. Modified Paths: -------------- trunk/cmake/modules/ada.cmake trunk/cmake/modules/c++.cmake trunk/cmake/modules/d.cmake trunk/cmake/modules/fortran.cmake trunk/cmake/modules/java.cmake trunk/examples/plplot_configure.cmake_installed_examples.in Modified: trunk/cmake/modules/ada.cmake =================================================================== --- trunk/cmake/modules/ada.cmake 2009-06-29 20:23:11 UTC (rev 10095) +++ trunk/cmake/modules/ada.cmake 2009-06-30 01:03:14 UTC (rev 10096) @@ -25,7 +25,17 @@ option(ENABLE_ada "Enable Ada bindings" ON) endif(DEFAULT_NO_BINDINGS) +# OPTIONAL below currently does not work properly with CMake so attempt +# to deal with a possibly missing compiler first as a workaround. if(ENABLE_ada) + include(CMakeDetermineAdaCompiler) + if(NOT CMAKE_Ada_COMPILER) + message(STATUS "WARNING: Ada compiler not found so disabling Ada bindings and examples.") + set(ENABLE_ada OFF CACHE BOOL "Enable Ada bindings" FORCE) + endif(NOT CMAKE_Ada_COMPILER) +endif(ENABLE_ada) + +if(ENABLE_ada) # Find and check Ada compiler enable_language(Ada OPTIONAL) if(NOT CMAKE_Ada_COMPILER_WORKS) @@ -35,13 +45,6 @@ endif(ENABLE_ada) if(ENABLE_ada) - if(NOT CMAKE_Ada_COMPILER) - message(STATUS "WARNING: Ada compiler not found so disabling Ada bindings and examples.") - set(ENABLE_ada OFF CACHE BOOL "Enable Ada bindings" FORCE) - endif(NOT CMAKE_Ada_COMPILER) -endif(ENABLE_ada) - -if(ENABLE_ada) find_library(GNAT_LIB NAMES gnat gnat-4.1 gnat-4.2 gnat-4.3 gnat-4.4) if(NOT GNAT_LIB) message(STATUS "WARNING: " Modified: trunk/cmake/modules/c++.cmake =================================================================== --- trunk/cmake/modules/c++.cmake 2009-06-29 20:23:11 UTC (rev 10095) +++ trunk/cmake/modules/c++.cmake 2009-06-30 01:03:14 UTC (rev 10096) @@ -28,27 +28,38 @@ OPTION(ENABLE_cxx "Enable C++ bindings" ON) endif(DEFAULT_NO_BINDINGS) -# Always carry out C++ checks, since some drivers also use these as -# well as the C++ bindings +# Always carry out C++ checks, since C++ used for more than just +# C++ bindings. +set(alwayscxx ON) -# Find and check C++ compiler. -enable_language(CXX OPTIONAL) - -if(NOT CMAKE_CXX_COMPILER_WORKS) - # This is fatal error message rather than a warning because C++ absolutely - # required for check_prototype_exists test (and perhaps other preliminary - # tests as well). - message(FATAL_ERROR "No working C++ compiler found so PLplot cannot be built.") - set(ENABLE_cxx OFF CACHE BOOL "Enable C++ bindings" FORCE) -endif(NOT CMAKE_CXX_COMPILER_WORKS) - -if(ENABLE_cxx) +# OPTIONAL below currently does not work properly with CMake so attempt +# to deal with a possibly missing compiler first as a workaround. +if(alwayscxx OR ENABLE_cxx) + include(CMakeDetermineCXXCompiler) if(NOT CMAKE_CXX_COMPILER) + # This is FATAL_ERROR rather than STATUS message because C++ absolutely + # required for check_prototype_exists test (and perhaps other preliminary + # tests as well). + message(FATAL_ERROR "C++ compiler absolutely required to build this project.") message(STATUS "WARNING: C++ compiler not found so disabling C++ bindings and examples.") set(ENABLE_cxx OFF CACHE BOOL "Enable C++ bindings" FORCE) endif(NOT CMAKE_CXX_COMPILER) -endif(ENABLE_cxx) +endif(alwayscxx OR ENABLE_cxx) +if(alwayscxx OR ENABLE_cxx) + # Find and check C++ compiler. + enable_language(CXX OPTIONAL) + + if(NOT CMAKE_CXX_COMPILER_WORKS) + # This is FATAL_ERROR rather than STATUS message because C++ absolutely + # required for check_prototype_exists test (and perhaps other preliminary + # tests as well). + message(FATAL_ERROR "C++ compiler absolutely required to build this project.") + message(STATUS "No working C++ compiler found so PLplot cannot be built.") + set(ENABLE_cxx OFF CACHE BOOL "Enable C++ bindings" FORCE) + endif(NOT CMAKE_CXX_COMPILER_WORKS) +endif(alwayscxx OR ENABLE_cxx) + # Check if "using namespace std;" works INCLUDE(TestForNamespace) Modified: trunk/cmake/modules/d.cmake =================================================================== --- trunk/cmake/modules/d.cmake 2009-06-29 20:23:11 UTC (rev 10095) +++ trunk/cmake/modules/d.cmake 2009-06-30 01:03:14 UTC (rev 10096) @@ -28,7 +28,17 @@ option(ENABLE_d "Enable D bindings" OFF) endif(DEFAULT_NO_BINDINGS) +# OPTIONAL below currently does not work properly with CMake so attempt +# to deal with a possibly missing compiler first as a workaround. if(ENABLE_d) + include(CMakeDetermineDCompiler) + if(NOT CMAKE_D_COMPILER) + message(STATUS "WARNING: D compiler not found so disabling D bindings and examples.") + set(ENABLE_d OFF CACHE BOOL "Enable D bindings" FORCE) + endif(NOT CMAKE_D_COMPILER) +endif(ENABLE_d) + +if(ENABLE_d) # Find and check D compiler enable_language(D OPTIONAL) if(NOT CMAKE_D_COMPILER_WORKS) @@ -37,10 +47,3 @@ endif(NOT CMAKE_D_COMPILER_WORKS) endif(ENABLE_d) -if(ENABLE_d) - if(NOT CMAKE_D_COMPILER) - message(STATUS "WARNING: D compiler not found so disabling D bindings and examples.") - set(ENABLE_d OFF CACHE BOOL "Enable D bindings" FORCE) - endif(NOT CMAKE_D_COMPILER) -endif(ENABLE_d) - Modified: trunk/cmake/modules/fortran.cmake =================================================================== --- trunk/cmake/modules/fortran.cmake 2009-06-29 20:23:11 UTC (rev 10095) +++ trunk/cmake/modules/fortran.cmake 2009-06-30 01:03:14 UTC (rev 10096) @@ -30,7 +30,18 @@ option(ENABLE_f95 "Enable f95 bindings" ON) endif(DEFAULT_NO_BINDINGS) +# OPTIONAL below currently does not work properly with CMake so attempt +# to deal with a possibly missing compiler first as a workaround. if(ENABLE_f77 OR ENABLE_f95) + include(CMakeDetermineFortranCompiler) + if(NOT CMAKE_Fortran_COMPILER) + message(STATUS "WARNING: Fortran compiler not found so disabling Fortran bindings and examples.") + set(ENABLE_f77 OFF CACHE BOOL "Enable f77 bindings" FORCE) + set(ENABLE_f95 OFF CACHE BOOL "Enable f95 bindings" FORCE) + endif(NOT CMAKE_Fortran_COMPILER) +endif(ENABLE_f77 OR ENABLE_f95) + +if(ENABLE_f77 OR ENABLE_f95) # Find and check Fortran compiler. enable_language(Fortran OPTIONAL) if(NOT CMAKE_Fortran_COMPILER_WORKS) @@ -41,14 +52,6 @@ endif(ENABLE_f77 OR ENABLE_f95) if(ENABLE_f77 OR ENABLE_f95) - if(NOT CMAKE_Fortran_COMPILER) - message(STATUS "WARNING: Fortran compiler not found so disabling Fortran bindings and examples.") - set(ENABLE_f77 OFF CACHE BOOL "Enable f77 bindings" FORCE) - set(ENABLE_f95 OFF CACHE BOOL "Enable f95 bindings" FORCE) - endif(NOT CMAKE_Fortran_COMPILER) -endif(ENABLE_f77 OR ENABLE_f95) - -if(ENABLE_f77 OR ENABLE_f95) # Don't compile Fortran 95 binding if compiler doesn't support it if(ENABLE_f95 AND NOT CMAKE_Fortran_COMPILER_SUPPORTS_F90) message(STATUS "WARNING: " Modified: trunk/cmake/modules/java.cmake =================================================================== --- trunk/cmake/modules/java.cmake 2009-06-29 20:23:11 UTC (rev 10095) +++ trunk/cmake/modules/java.cmake 2009-06-30 01:03:14 UTC (rev 10096) @@ -40,7 +40,17 @@ set(ENABLE_java OFF CACHE BOOL "Enable Java bindings" FORCE) endif(ENABLE_java AND NOT SWIG_FOUND) +# OPTIONAL below currently does not work properly with CMake so attempt +# to deal with a possibly missing compiler first as a workaround. if(ENABLE_java) + include(CMakeDetermineJavaCompiler) + if(NOT CMAKE_Java_COMPILER) + message(STATUS "WARNING: Java compiler not found so disabling Java bindings and examples.") + set(ENABLE_java OFF CACHE BOOL "Enable Java bindings" FORCE) + endif(NOT CMAKE_Java_COMPILER) +endif(ENABLE_java) + +if(ENABLE_java) # Find and check Java compiler. enable_language(Java OPTIONAL) if(NOT CMAKE_Java_COMPILER_WORKS) @@ -50,13 +60,6 @@ endif(ENABLE_java) if(ENABLE_java) - if(NOT CMAKE_Java_COMPILER) - message(STATUS "WARNING: Java compiler not found so disabling Java bindings and examples.") - set(ENABLE_java OFF CACHE BOOL "Enable Java bindings" FORCE) - endif(NOT CMAKE_Java_COMPILER) -endif(ENABLE_java) - -if(ENABLE_java) if(NOT CMAKE_Java_ARCHIVE) message(STATUS "WARNING: java archiver (jar) not found. Disabling java bindings") set(ENABLE_java OFF CACHE BOOL "Enable Java bindings" FORCE) Modified: trunk/examples/plplot_configure.cmake_installed_examples.in =================================================================== --- trunk/examples/plplot_configure.cmake_installed_examples.in 2009-06-29 20:23:11 UTC (rev 10095) +++ trunk/examples/plplot_configure.cmake_installed_examples.in 2009-06-30 01:03:14 UTC (rev 10096) @@ -78,28 +78,63 @@ foreach(language_info tk:? gnome2:? wxwidgets:? qt:? ${language_info_LIST}) string(REGEX REPLACE "^(.*):.*$" "\\1" language ${language_info}) #message("DEBUG: language = ${language}") - if(CORE_ENABLE_${language}) - if(NOT PRESET_DEFAULT) - set(DEFAULT ${CORE_ENABLE_${language}}) - endif(NOT PRESET_DEFAULT) - option(ENABLE_${language} "Enable ${language} bindings" ${DEFAULT}) - else(CORE_ENABLE_${language}) - set(ENABLE_${language} OFF CACHE BOOL "Enable ${language} bindings" FORCE) - endif(CORE_ENABLE_${language}) + if(language STREQUAL "c") + #special case where the build system requires C. + set(ENABLE_${language} ON CACHE BOOL "Enable ${language} bindings" FORCE) + else(language STREQUAL "c") + if(CORE_ENABLE_${language}) + if(NOT PRESET_DEFAULT) + set(DEFAULT ${CORE_ENABLE_${language}}) + endif(NOT PRESET_DEFAULT) + option(ENABLE_${language} "Enable ${language} bindings" ${DEFAULT}) + else(CORE_ENABLE_${language}) + set(ENABLE_${language} OFF CACHE BOOL "Enable ${language} bindings" FORCE) + endif(CORE_ENABLE_${language}) + endif(language STREQUAL "c") endforeach(language_info ${language_info_LIST}) -if(ENABLE_c) +# Always carry out C checks because build system requires a C compiler +# for some of the automatic checking that is done. +set(alwaysc ON) + +# OPTIONAL below currently does not work properly with CMake so attempt +# to deal with a possibly missing compiler first as a workaround. +if(alwaysc OR ENABLE_c) + include(CMakeDetermineCCompiler) + if(NOT CMAKE_C_COMPILER) + # This is a FATAL_ERROR rather than STATUS message because C compiler + # absolutely required for some of the automatic checking that is done. + message(FATAL_ERROR "C compiler absolutely required to build this project.") + message(STATUS "WARNING: C compiler not found so disabling C examples.") + set(ENABLE_c OFF CACHE BOOL "Enable c bindings" FORCE) + endif(NOT CMAKE_C_COMPILER) +endif(alwaysc OR ENABLE_c) + +if(alwaysc OR ENABLE_c) enable_language(C OPTIONAL) if(NOT CMAKE_C_COMPILER_WORKS) - message(STATUS: "WARNING: C compiler does not work so disabling C examples.") + # This is a FATAL_ERROR rather than STATUS message because C compiler + # absolutely required for some of the automatic checking that is done. + message(FATAL_ERROR "C compiler absolutely required to build this project.") + message(STATUS "WARNING: C compiler does not work so disabling C examples.") set(ENABLE_c OFF CACHE BOOL "Enable c bindings" FORCE) endif(NOT CMAKE_C_COMPILER_WORKS) -endif(ENABLE_c) +endif(alwaysc OR ENABLE_c) +# OPTIONAL below currently does not work properly with CMake so attempt +# to deal with a possibly missing compiler first as a workaround. if(ENABLE_ada) + include(CMakeDetermineAdaCompiler) + if(NOT CMAKE_Ada_COMPILER) + message(STATUS "WARNING: Ada compiler not found so disabling Ada examples.") + set(ENABLE_ada OFF CACHE BOOL "Enable ada bindings" FORCE) + endif(NOT CMAKE_Ada_COMPILER) +endif(ENABLE_ada) + +if(ENABLE_ada) enable_language(Ada OPTIONAL) if(NOT CMAKE_Ada_COMPILER_WORKS) - message(STATUS: "WARNING: Ada compiler does not work so disabling Ada examples.") + message(STATUS "WARNING: Ada compiler does not work so disabling Ada examples.") set(ENABLE_ada OFF CACHE BOOL "Enable ada bindings" FORCE) endif(NOT CMAKE_Ada_COMPILER_WORKS) endif(ENABLE_ada) @@ -109,43 +144,84 @@ set(ADA_LIB_DIR @ADA_LIB_DIR@) endif(ENABLE_ada) +# OPTIONAL below currently does not work properly with CMake so attempt +# to deal with a possibly missing compiler first as a workaround. if(ENABLE_cxx) + include(CMakeDetermineCXXCompiler) + if(NOT CMAKE_CXX_COMPILER) + message(STATUS "WARNING: C++ compiler not found so disabling C++ examples.") + set(ENABLE_cxx OFF CACHE BOOL "Enable cxx bindings" FORCE) + endif(NOT CMAKE_CXX_COMPILER) +endif(ENABLE_cxx) + +if(ENABLE_cxx) enable_language(CXX OPTIONAL) if(NOT CMAKE_CXX_COMPILER_WORKS) - message(STATUS: "WARNING: C++ compiler does not work so disabling C++ examples.") + message(STATUS "WARNING: C++ compiler does not work so disabling C++ examples.") set(ENABLE_cxx OFF CACHE BOOL "Enable cxx bindings" FORCE) endif(NOT CMAKE_CXX_COMPILER_WORKS) endif(ENABLE_cxx) +# OPTIONAL below currently does not work properly with CMake so attempt +# to deal with a possibly missing compiler first as a workaround. if(ENABLE_d) + include(CMakeDetermineDCompiler) + if(NOT CMAKE_D_COMPILER) + message(STATUS "WARNING: D compiler not found so disabling D examples.") + set(ENABLE_d OFF CACHE BOOL "Enable d bindings" FORCE) + endif(NOT CMAKE_D_COMPILER) +endif(ENABLE_d) + +if(ENABLE_d) enable_language(D OPTIONAL) if(NOT CMAKE_D_COMPILER_WORKS) - message(STATUS: "WARNING: D compiler does not work so disabling D examples.") + message(STATUS "WARNING: D compiler does not work so disabling D examples.") set(ENABLE_d OFF CACHE BOOL "Enable d bindings" FORCE) endif(NOT CMAKE_D_COMPILER_WORKS) endif(ENABLE_d) +# OPTIONAL below currently does not work properly with CMake so attempt +# to deal with a possibly missing compiler first as a workaround. if(ENABLE_f77 OR ENABLE_f95) - set(STATIC_OPTS @STATIC_OPTS@) + include(CMakeDetermineFortranCompiler) + if(NOT CMAKE_Fortran_COMPILER) + message(STATUS "WARNING: Fortran compiler not found so disabling Fortran examples.") + set(ENABLE_f77 OFF CACHE BOOL "Enable f77 bindings" FORCE) + set(ENABLE_f95 OFF CACHE BOOL "Enable f95 bindings" FORCE) + endif(NOT CMAKE_Fortran_COMPILER) endif(ENABLE_f77 OR ENABLE_f95) if(ENABLE_f77 OR ENABLE_f95) enable_language(Fortran OPTIONAL) if(NOT CMAKE_Fortran_COMPILER_WORKS) - message(STATUS: "WARNING: Fortran compiler does not work so disabling Fortran examples.") + message(STATUS "WARNING: Fortran compiler does not work so disabling Fortran examples.") set(ENABLE_f77 OFF CACHE BOOL "Enable f77 bindings" FORCE) set(ENABLE_f95 OFF CACHE BOOL "Enable f95 bindings" FORCE) endif(NOT CMAKE_Fortran_COMPILER_WORKS) endif(ENABLE_f77 OR ENABLE_f95) +if(ENABLE_f77 OR ENABLE_f95) + set(STATIC_OPTS @STATIC_OPTS@) +endif(ENABLE_f77 OR ENABLE_f95) + if(ENABLE_f95) set(F95_MOD_DIR @F95_MOD_DIR@) endif(ENABLE_f95) +# OPTIONAL below currently does not work properly with CMake so attempt +# to deal with a possibly missing compiler first as a workaround. if(ENABLE_java) + include(CMakeDetermineJavaCompiler) + if(NOT CMAKE_Java_COMPILER) + message(STATUS "WARNING: Java compiler not found so disabling Java examples.") + set(ENABLE_java OFF CACHE BOOL "Enable java bindings" FORCE) + endif(NOT CMAKE_Java_COMPILER) +endif(ENABLE_java) + +if(ENABLE_java) enable_language(Java OPTIONAL) if(NOT CMAKE_Java_COMPILER_WORKS) - message(STATUS: "WARNING: Java compiler does not work so disabling Java examples.") + message(STATUS "WARNING: Java compiler does not work so disabling Java examples.") set(ENABLE_java OFF CACHE BOOL "Enable java bindings" FORCE) endif(NOT CMAKE_Java_COMPILER_WORKS) endif(ENABLE_java) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2009-07-06 01:22:12
|
Revision: 10118 http://plplot.svn.sourceforge.net/plplot/?rev=10118&view=rev Author: hbabcock Date: 2009-07-06 00:29:07 +0000 (Mon, 06 Jul 2009) Log Message: ----------- Added functions plspal0 and plspal1 (set cmap0 palette and set cmap1 palette) to the API. plspal0 takes the name of a cmap0.pal format file and sets the colors in color map 0 based on the data in the file. plspal1 takes the name name of a cmap1.pal format file and sets the colors in color map 1 based on the data in the file. Modified Paths: -------------- trunk/include/plplot.h trunk/src/plctrl.c Modified: trunk/include/plplot.h =================================================================== --- trunk/include/plplot.h 2009-07-05 16:12:27 UTC (rev 10117) +++ trunk/include/plplot.h 2009-07-06 00:29:07 UTC (rev 10118) @@ -672,6 +672,8 @@ #define plsmin c_plsmin #define plsori c_plsori #define plspage c_plspage +#define plspal0 c_plspal0 +#define plspal1 c_plspal1 #define plspause c_plspause #define plsstrm c_plsstrm #define plssub c_plssub @@ -1497,6 +1499,16 @@ c_plspage(PLFLT xp, PLFLT yp, PLINT xleng, PLINT yleng, PLINT xoff, PLINT yoff); +/* Set the colors for color table 0 from a cmap0 file */ + +PLDLLIMPEXP void +c_plspal0(const char *filename); + +/* Set the colors for color table 1 from a cmap1 file */ + +PLDLLIMPEXP void +c_plspal1(const char *filename); + /* Set the pause (on end-of-page) status */ PLDLLIMPEXP void Modified: trunk/src/plctrl.c =================================================================== --- trunk/src/plctrl.c 2009-07-05 16:12:27 UTC (rev 10117) +++ trunk/src/plctrl.c 2009-07-06 00:29:07 UTC (rev 10118) @@ -1210,6 +1210,112 @@ } /*--------------------------------------------------------------------------*\ + * void c_plspal0(filename) + * + * Set the palette for color map 0 using a cmap0*.pal format file. + * filename: the name of the cmap0*.pal file to use. +\*--------------------------------------------------------------------------*/ + +void +c_plspal0(const char *filename) +{ + int i, r, g, b, a; + int number_colors; + char color_info[30]; + FILE *fp; + + fp = fopen(filename, "r"); + fscanf(fp, "%d\n", &number_colors); + for(i=0;i<number_colors;i++){ + fgets(color_info, 30, fp); + color_info[strlen(color_info)-1] = '\0'; /* remove return character */ + if(strlen(color_info) == 7){ + sscanf(color_info, "#%2x%2x%2x", &r, &g, &b); + c_plscol0(i, r, g, b); + } + else if(strlen(color_info) == 9){ + sscanf(color_info, "#%2x%2x%2x%2x", &r, &g, &b, &a); + c_plscol0a(i, r, g, b, a); + } + else{ + printf("Unrecognized cmap0 format %s\n", color_info); + } + + } + fclose(fp); +} + +/*--------------------------------------------------------------------------*\ + * void c_plspal1(filename) + * + * Set the palette for color map 1 using a cmap1*.pal format file. + * filename: the name of the cmap1*.pal file to use. +\*--------------------------------------------------------------------------*/ + +void +c_plspal1(const char *filename) +{ + int i; + int number_colors; + int have_alpha; + char color_info[30]; + int r_i, g_i, b_i, a_i, pos_i; + PLFLT *r, *g, *b, *a, *pos; + FILE *fp; + + have_alpha = 1; + fp = fopen(filename, "r"); + fscanf(fp, "%d\n", &number_colors); + r = (PLFLT *)malloc(number_colors * sizeof(PLFLT)); + g = (PLFLT *)malloc(number_colors * sizeof(PLFLT)); + b = (PLFLT *)malloc(number_colors * sizeof(PLFLT)); + a = (PLFLT *)malloc(number_colors * sizeof(PLFLT)); + pos = (PLFLT *)malloc(number_colors * sizeof(PLFLT)); + + for(i=0;i<number_colors;i++){ + fgets(color_info, 30, fp); + color_info[strlen(color_info)-1] = '\0'; + if(color_info[7] == ' '){ + have_alpha = 0; + sscanf(color_info, "#%2x%2x%2x %d", &r_i, &g_i, &b_i, &pos_i); + r[i] = (PLFLT)r_i; + g[i] = (PLFLT)g_i; + b[i] = (PLFLT)b_i; + pos[i] = 0.01 * (PLFLT)pos_i; + } + else if(color_info[9] == ' '){ + sscanf(color_info, "#%2x%2x%2x%2x %d", &r_i, &g_i, &b_i, &a_i, &pos_i); + r[i] = (PLFLT)r_i; + g[i] = (PLFLT)g_i; + b[i] = (PLFLT)b_i; + a[i] = (PLFLT)a_i; + pos[i] = 0.01 * (PLFLT)pos_i; + } + else{ + printf("Unrecognized cmap1 format %s\n", color_info); + } + } + fclose(fp); + + /* Set the first control point position to 0.0 and the last */ + /* to 1.0 to deal with any possible round off errors. */ + pos[0] = 0.0; + pos[number_colors-1] = 1.0; + + if (have_alpha == 1){ + c_plscmap1la(1, number_colors, pos, r, g, b, a, NULL); + } else { + c_plscmap1l(1, number_colors, pos, r, g, b, NULL); + } + + free(r); + free(g); + free(b); + free(a); + free(pos); +} + +/*--------------------------------------------------------------------------*\ * A grab-bag of various control routines. \*--------------------------------------------------------------------------*/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-07-06 02:09:17
|
Revision: 10120 http://plplot.svn.sourceforge.net/plplot/?rev=10120&view=rev Author: airwin Date: 2009-07-06 02:09:13 +0000 (Mon, 06 Jul 2009) Log Message: ----------- We have an actively maintained pyqt4 interface to PLplot and corresponding example. Therefore, remove pyqt3 interface to PLplot and pyqt3 example since those are unmaintained and not understood that well. Modified Paths: -------------- trunk/README.release trunk/bindings/python/README.pythonbuild trunk/bindings/python/plplot_widgetmodule.c trunk/examples/python/CMakeLists.txt trunk/examples/python/README.pythondemos Removed Paths: ------------- trunk/examples/python/prova.py trunk/examples/python/qplplot.py Modified: trunk/README.release =================================================================== --- trunk/README.release 2009-07-06 01:01:53 UTC (rev 10119) +++ trunk/README.release 2009-07-06 02:09:13 UTC (rev 10120) @@ -92,11 +92,30 @@ pbm device) has been deprecated as of release 5.9.4 because glibc detects a catastrophic double free. +XI. This is official notice that we have removed pyqt3 access to PLplot and +replaced it by pyqt4 access to PLplot as of PLplot-5.9.5. + INDEX 1. Changes relative to PLplot 5.9.4 (the previous development release) +1.1 pyqt changes +1.1 pyqt changes + +Years ago we got a donation of a hand-crafted pyqt3 interface to PLplot +(some of the functions in plplot_widgetmodule.c in bindings/python) and a +proof-of-concept example (prova.py and qplplot.py in examples/python), but +this code did not gain any developer interest and was therefore not +understood or maintained. Recently one of our core developers has +implemented a sip-generated pyqt4 interface to PLplot (controlled by +plplot_pyqt4.sip in bindings/qt_gui/pyqt4) that builds without problems as a +python extension module, and a good-looking pyqt4 example (pyqt4_example.py +in examples/python) that works well. Since this pyqt4 approach is +maintained by a PLplot developer it appears to have a good future, and we +have therefore decided to concentrate on pyqt4 and remove the pyqt3 PLplot +interface and example completely. + 2. Changes relative to PLplot 5.8.0 (the previous stable release) 2.1 All autotools-related files have now been removed @@ -108,7 +127,7 @@ 2.6 Date / time labels for axes 2.7 Alpha value support 2.8 New PLplot functions -2.9 External libLASi library improvements affecting our psttf device. +2.9 External libLASi library improvements affecting our psttf device 2.10 Improvements to the cairo driver family. 2.11 wxWidgets driver improvements 2.12 pdf driver improvements @@ -132,6 +151,7 @@ 2.30 NaN / Inf support for some PLplot functions 2.31 Various bug fixes 2.32 Cairo driver improvements +2.33 pyqt changes 2. Changes relative to PLplot 5.8.0 (the previous stable release) @@ -239,7 +259,7 @@ the library. plrandd will return a PLFLT random number in the range 0.0-1.0. plseed will allow the random number generator to be seeded. -2.9 External libLASi library improvements affecting our psttf device. +2.9 External libLASi library improvements affecting our psttf device Our psttf device depends on the libLASi library. libLASi-1.1.0 has just been released at http://sourceforge.net/svn/?group_id=187113 . We recommend @@ -563,3 +583,19 @@ Improvements to the cairo driver to give better results for bitmap formats when used with anti-aliasing file viewers. + +2.33 pyqt changes + +Years ago we got a donation of a hand-crafted pyqt3 interface to PLplot +(some of the functions in plplot_widgetmodule.c in bindings/python) and a +proof-of-concept example (prova.py and qplplot.py in examples/python), but +this code did not gain any developer interest and was therefore not +understood or maintained. Recently one of our core developers has +implemented a sip-generated pyqt4 interface to PLplot (controlled by +plplot_pyqt4.sip in bindings/qt_gui/pyqt4) that builds without problems as a +python extension module, and a good-looking pyqt4 example (pyqt4_example.py +in examples/python) that works well. Since this pyqt4 approach is +maintained by a PLplot developer it appears to have a good future, and we +have therefore decided to concentrate on pyqt4 and remove the pyqt3 PLplot +interface and example completely. + Modified: trunk/bindings/python/README.pythonbuild =================================================================== --- trunk/bindings/python/README.pythonbuild 2009-07-06 01:01:53 UTC (rev 10119) +++ trunk/bindings/python/README.pythonbuild 2009-07-06 02:09:13 UTC (rev 10120) @@ -24,12 +24,9 @@ II. plplot_widgetmodule.so This extension module is built and installed directly by our build system -from the hand-crafted plplot_widgetmodule.c. That source code originally -just implemented pyqt3 support for PLplot (demonstrated by prova.py in -examples/python), but since then it has also included other functionality -such as the 2009-06 addition of support for loading plframe from python -(demonstrated by pytkdemo in examples/python and supported by Plframe.py and -TclSup.py). +from the hand-crafted plplot_widgetmodule.c. That source code supports +loading plframe from python (demonstrated by pytkdemo in examples/python and +supported by Plframe.py and TclSup.py). III. plplot_pyqt4.so Modified: trunk/bindings/python/plplot_widgetmodule.c =================================================================== --- trunk/bindings/python/plplot_widgetmodule.c 2009-07-06 01:01:53 UTC (rev 10119) +++ trunk/bindings/python/plplot_widgetmodule.c 2009-07-06 02:09:13 UTC (rev 10120) @@ -14,69 +14,6 @@ #define TRY(E) if(! (E)) return NULL -/* ##############################################################################*/ -static char doc_partialInitXw[]="Partially init a new device (X Window) "; - -#ifndef WIN32 -#include "plxwd.h" -static PyObject * pl_partialInitXw(PyObject *self, PyObject *args) -{ - PLINT ipls; - PLStream *pls; - TRY (PyArg_ParseTuple(args, ":pl_partialInitXw")); - ipls=0; - - plmkstrm(&ipls); - printf(" ipls=%d\n",ipls); - plgpls(&pls); /* pls points directly to a structure PLStream */ - printf(" pls OK \n"); - - /* Partially initialize X driver. */ - - pllib_init(); - - plsdev("xwin"); - pllib_devinit(); - plP_esc(PLESC_DEVINIT, NULL); - - printf("devinit OK \n"); - - return Py_BuildValue("i", ipls); -} -#endif - - -static char doc_resize[]="resize the window"; - -static PyObject * pl_resize(PyObject *self, PyObject *args) -{ - int width, height ; - PLDisplay pldis; - TRY (PyArg_ParseTuple(args, "ii:resize", &width, &height)); - - pldis.width=width; - pldis.height=height; - pl_cmd(PLESC_RESIZE, (void *) &(pldis)); - pl_cmd(PLESC_EXPOSE, (void *) NULL); - - Py_INCREF(Py_None); - return Py_None; - -} - -static char doc_expose[]="expose the whole window"; - -static PyObject * pl_expose(PyObject *self, PyObject *args) -{ - TRY (PyArg_ParseTuple(args, ":expose")); - - pl_cmd(PLESC_EXPOSE, (void *) NULL); - - Py_INCREF(Py_None); - return Py_None; - -} - #ifdef ENABLE_tk static char doc_Pltk_init[] = "Initialize the Pltk Tcl extension."; @@ -121,19 +58,7 @@ /* ##############################################################################*/ static PyMethodDef plplot_widget_methods[] = { - /* These are a few functions that I found I needed - to call in order to initialise the pyqt widget */ -#ifndef WIN32 - {"plpartialInitXw", pl_partialInitXw, 1, doc_partialInitXw}, -#endif - - /* These are a few functions that I found I needed - to filtering events in pyqt widget */ - - {"plresize", pl_resize, METH_VARARGS, doc_resize}, - {"plexpose", pl_expose, METH_VARARGS, doc_expose}, - #ifdef ENABLE_tk {"Pltk_init", pl_Pltk_init, METH_VARARGS, doc_Pltk_init}, #endif Modified: trunk/examples/python/CMakeLists.txt =================================================================== --- trunk/examples/python/CMakeLists.txt 2009-07-06 01:01:53 UTC (rev 10119) +++ trunk/examples/python/CMakeLists.txt 2009-07-06 02:09:13 UTC (rev 10120) @@ -66,7 +66,6 @@ x14 x17 x31 - prova.py xw14.py xw17.py xw31.py @@ -139,7 +138,6 @@ README.pythondemos README.logo svg_760x120_gradient.patch - qplplot.py ) if(ENABLE_pygcw) Modified: trunk/examples/python/README.pythondemos =================================================================== --- trunk/examples/python/README.pythondemos 2009-07-06 01:01:53 UTC (rev 10119) +++ trunk/examples/python/README.pythondemos 2009-07-06 02:09:13 UTC (rev 10120) @@ -1,46 +1,18 @@ The Status of the Python Examples -We have now moved to a new default method of building and installing the -python interface to PLplot. For details see +For details of how we build PLplot access from Python please consult ../../bindings/python/README.pythonbuild. The principal module is plplot.py. This make all the common PLplot API available to python in a user-friendly way. plplot.py wraps the swig-generated plplotc.py which in turn wraps the _plplotc extension module (built with the aid of swig). The -extension module, plplot_widget contains some functions that are useful for -prova.py, a rudimentary pyqt GUI for PLplot, and I am also told that these -functions are useful in a Tkinter environment as well. +extension module, plplot_widget contains support for loading plframe +from python. This functionality is demonstrated with pytkdemo which +uses the old x??.py examples. Plans are afoot (2009-07-05) to drop using +those old, limited and buggy examples, and instead use the modern xw??.py +examples. Once that works, we will remove all the old examples and +rename all the modern xw??.py examples as x??.py (which is a better +namespace). Stay tuned. -A drawback of the present approach is we are not supporting x??.py examples -and pytkdemo which uses those examples because we have not yet figured out a -way to access plframe from the python Tkinter environment. The stumbling -block before was plplot itself was not dynamically loadable from tcl/tk, but -that option is now available so there is hope that eventually we will be -able to support x??.py and pytkdemo in the future using Tkinter. - -We *are* however supporting the xw??.py demos which were created initially -from their x??.py equivalents and modified to work non-interactively from -the command line using the pythondemos.py script. Furthermore, if you need a -widget you might want to try out and improve the prova.py rudimentary pyqt -widget. - To try out the xw??.py examples without a widget simply run pythondemos.py -in the installed directory. It imports the plplot_python_start module which -does all that is necessary to find the location of the installed plplot -modules. Thus, there should be no need to specify the location of the -installed plplot modules using the environment variable PYTHONPATH. -Furthermore, the location of the installed fonts and maps is also hardcoded -into libplplot so there should be no necessity of setting the environment -variable PLPLOT_LIB unless you want to use some other alternative. - -To try out the xw??.py examples with the pyqt widget simply execute -./prova.py from the installed directory and open any one of the xw??.py -examples and run it. Note that prova.py requires the qt.py extension module -(part of the python-pyqt package) as well as libsip to work. Furthermore, -pyqt uses the qt library, but there is a bug in that package so that if -libqt is installed in a non-standard place you must use LD_LIBRARY_PATH to -help pyqt find the qt library. The bug has been reported, and hopefully -this issue will disappear in the future. - -All these xw??.py examples have been thoroughly tested under Linux and -should also work under Unix systems according to the python team comments on -dynamic loading, but that is yet to be tested as of 2002 December. +in the installed directory to run all of them, or alternatively run them +one at at time by executing x??. Deleted: trunk/examples/python/prova.py =================================================================== --- trunk/examples/python/prova.py 2009-07-06 01:01:53 UTC (rev 10119) +++ trunk/examples/python/prova.py 2009-07-06 02:09:13 UTC (rev 10120) @@ -1,104 +0,0 @@ -#!/usr/bin/env python - -# Qt tutorial 1. - -# Append to effective python path so that can find plplot modules. -from plplot_python_start import * - -import sys -from qt import * -from plplot_py_demos import * -import math -import qplplot -from qt import * -import threading - -class MenuExample(QWidget): - - def __init__( self, parent=None , name=None ): - QWidget.__init__(self,parent,name) - self.file = QPopupMenu(); - self.file.insertItem( "&Open", self.open ) - self.file.insertItem( "&Run", self.Run ) - - menu = QMenuBar( self ); - menu.insertItem( "&File", self.file ) - - self.mle=QMultiLineEdit(self) - - self.mle.show() - - self.qpl= qplplot.qplplot(self) - self.resize(500,700) - - # self.resizeQUIET() - - self.show() - - self.qpl.attiva() - - - - def Run(self): - self.qpl.set_stream() - exec(str(self.mle.text()), globals(),globals()) - - - -# p.rotate( -ang ) - - -# p.drawRect( QRect(33, -4, 15, 8) ) - - def mouseMoveEvent ( qmev ) : - print "MOVE IN PYTHON" - - def resizeQUIET(self): - self.mle.resize(self.width(), self.height()/3 ) - self.qpl.move(0,self.mle.y()+self.mle.height() +10) - self.qpl.resize(self.width(), (2*self.height())/3-20 ) - print "FINE " - - def resizeEvent(self,qrev): - print "resize in python" - timer = QTimer( self ) - self.connect( timer, SIGNAL("timeout()"), self.resizeQUIET ) - timer.start( 0, 1) - - - - - - def open(self): - self.command=str((QFileDialog.getOpenFileName(".","*.py",))) - print self.command - f=open(self.command,"r") - self.command=f.read() - print self.command - self.mle.setText(self.command) - - -#plplot.semaphore=threading.Semaphore() -#plplot.owner=None - -a = QApplication(sys.argv) - -w=MenuExample() - -# graph=qplplot.qplplot() - -a.setMainWidget(w) -# graph.ciao() -# disegna(graph) -# graph.show() - - -a.exec_loop() - - - - - - - - Deleted: trunk/examples/python/qplplot.py =================================================================== --- trunk/examples/python/qplplot.py 2009-07-06 01:01:53 UTC (rev 10119) +++ trunk/examples/python/qplplot.py 2009-07-06 02:09:13 UTC (rev 10120) @@ -1,166 +0,0 @@ -import qt -from qt import QWidget -import plplot_py_demos -import plplot -import plplot_widget - -class qplplot(QWidget): - - def __init__(self,parent=None,name=None ): - qt.QWidget.__init__(self,parent,name) - print " QWidget OK" -# self.setMouseTracking (1 ) - self.is_created=0 - self.count=1 - print " ??????" - self.ipls=plplot_widget.plpartialInitXw() - print " ??????" - print self.ipls - self.isactive=0 - - def __getattr__(self,attr): - print attr - attr="pl"+attr - print "pl+++",attr - self.__attr = getattr(plplot,attr) - if(self.isactive==0): - return self.message - print "AAA",self.__attr ,"AAA" - return self.__wrap - - def __wrap(self, *args): - print " wrap " - - if(hasattr(plplot,"semaphore")): - if(plplot.owner is not self): - plplot.semaphore.acquire() - plplot.owner=self - self.set_stream() -# self.__attr(*args) - if(hasattr(plplot,"semaphore")): - plplot.semaphore.release() - - def resize(self, w,h): - qt.QWidget.resize(self,w,h) - print " OK " - - def attiva(self): - self.isactive=1 - self.installEventFilter(self) - self.show() - - def message(self,*args): - print "active this widget first " - - def mousePressEvent(self, qmev): - self.xstart=qmev.x() - self.ystart=qmev.y() - - def mouseMoveEvent (self, qmev ) : - print "MOVE IN PYTHON" - if(hasattr(plplot,"semaphore")): - if(plplot.owner is not self): - plplot.semaphore.acquire() - plplot.owner=self - self.set_stream() - - - if(qmev.state()==1): - x=qmev.x() - y=qmev.y() - (xa,ya)=plplot.plPixel2U(self.xstart,self.ystart ) - (xb,yb)=plplot.plPixel2U(x, y) - plplot.plmoveimage(xb-xa,yb-ya) - plplot.plNoBufferNoPixmap() - plplot.plRestoreWrite2BufferPixmap() - - - else: - plplot.plNoBufferNoPixmap() - - (xu,yu)=plplot.plPixel2U(qmev.x(), qmev.y()) - (xmin,xmax,ymin,ymax)=plplot.plPgvpw() - plplot.plline( [xmin,xmax],[yu,yu]) - plplot.plline( [xu,xu],[ymin, ymax]) - - - plplot.plRestoreWrite2BufferPixmap() - - - - if(hasattr(plplot,"semaphore")): - plplot.semaphore.release() - - - def set_stream(self): - plplot.plsstrm(self.ipls) - - def resizeQUIET(self): - if(hasattr(plplot,"semaphore")): - if(plplot.owner is not self): - plplot.semaphore.acquire() - plplot.owner=self - plplot.plsstrm(self.ipls) - plplot_widget.plresize(self.width(), self.height()) - if(hasattr(plplot,"semaphore")): - plplot.semaphore.release() - - def exposeQUIET(self): - if(hasattr(plplot,"semaphore")): - if(plplot.owner is not self): - plplot.semaphore.acquire() - plplot.owner=self - plplot.plsstrm(self.ipls) - plplot_widget.plexpose() - if(hasattr(plplot,"semaphore")): - plplot.semaphore.release() - - def eventFilter(self,ob,ev): - - if(hasattr(plplot,"semaphore")): - if(plplot.owner is not self): - plplot.semaphore.acquire() - plplot.owner=self - plplot.plsstrm(self.ipls) - - print " intercettato event ", ev.type() - - if(self.count==1): - self.Init() - self.is_created=1 - self.count=2 - - if(self.is_created): - print " EVENTO = ",ev.type() , " ", qt.QEvent.Resize - if(ev.type()==qt.QEvent.Paint): - plplot_widget.plexpose() - timer = qt.QTimer( self ) - self.connect( timer, qt.SIGNAL("timeout()"), self.exposeQUIET) - timer.start( 0, 1) - return 1 - elif(ev.type()==qt.QEvent.Resize): - print " RESIZE " - self.resizeQUIET() - return 1 - else: - if(ev.type()==12) : - plplot_widget.plexpose(); - if(hasattr(plplot,"semaphore")): - plplot.semaphore.release() - - return 0 - - def Init(self): - print " init \n" - - if(hasattr(plplot,"semaphore")): - if(plplot.owner is not self): - plplot.semaphore.acquire() - plplot.owner=self - plplot.plsdev("xwin") - plplot.plsxwin(self.winId()) - plplot.plspause(0) - plplot.plinit() - plplot.plbop() - if(hasattr(plplot,"semaphore")): - plplot.semaphore.release() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2009-07-09 09:15:18
|
Revision: 10125 http://plplot.svn.sourceforge.net/plplot/?rev=10125&view=rev Author: andrewross Date: 2009-07-09 09:14:55 +0000 (Thu, 09 Jul 2009) Log Message: ----------- Update support for loading user cmap0 and cmap1 palettes. Add additional error checking for file handling. Add support for a new floating point file format for cmap1 palettes which supports floating point values for r, g, b and position. Additionally it supports rgb / hls colour spaces, alpha transparencies and the rev parameter. This means that loaded palettes support exactly the same options and resolutions as the plplot plscmap1la function. A sample palette using the new file format is included in the data directory for testing. Modified Paths: -------------- trunk/data/CMakeLists.txt trunk/src/plctrl.c Added Paths: ----------- trunk/data/cmap1_blue_yellow.pal Modified: trunk/data/CMakeLists.txt =================================================================== --- trunk/data/CMakeLists.txt 2009-07-08 23:50:09 UTC (rev 10124) +++ trunk/data/CMakeLists.txt 2009-07-09 09:14:55 UTC (rev 10125) @@ -26,6 +26,7 @@ plxtnd5.fnt usa.map usaglobe.map +cmap1_blue_yellow.pal ) install(FILES ${data_DATAFILES} DESTINATION ${DATA_DIR}) Added: trunk/data/cmap1_blue_yellow.pal =================================================================== --- trunk/data/cmap1_blue_yellow.pal (rev 0) +++ trunk/data/cmap1_blue_yellow.pal 2009-07-09 09:14:55 UTC (rev 10125) @@ -0,0 +1,10 @@ +v2 rgb +7 +0.0 1.0 1.0 1.0 1.0 0 +0.001 0.001 0.998 1.0 1.0 0 +0.25 0.25 0.50 1.0 1.0 0 +0.5 0.5 0.5 0.5 1.0 0 +0.75 1.0 0.5 0.25 1.0 0 +0.999 1.0 0.998 0.001 1.0 0 +1.0 0.0 0.0 0.0 1.0 0 + Modified: trunk/src/plctrl.c =================================================================== --- trunk/src/plctrl.c 2009-07-08 23:50:09 UTC (rev 10124) +++ trunk/src/plctrl.c 2009-07-09 09:14:55 UTC (rev 10125) @@ -1223,22 +1223,43 @@ int number_colors; char color_info[30]; FILE *fp; + char msgbuf[1024]; - fp = (FILE *)plLibOpen(filename); - fscanf(fp, "%d\n", &number_colors); + fp = plLibOpen(filename); + if (fp == NULL) { + snprintf(msgbuf,1024,"Unable to open cmap1 file %s\n",filename); + plwarn(msgbuf); + return; + } + if (fscanf(fp, "%d\n", &number_colors) != 1) { + snprintf(msgbuf,1024,"Unrecognized cmap1 header\n"); + plwarn(msgbuf); + fclose(fp); + return; + } for(i=0;i<number_colors;i++){ fgets(color_info, 30, fp); color_info[strlen(color_info)-1] = '\0'; /* remove return character */ if(strlen(color_info) == 7){ - sscanf(color_info, "#%2x%2x%2x", &r, &g, &b); + if (sscanf(color_info, "#%2x%2x%2x", &r, &g, &b) != 3) { + snprintf(msgbuf,1024,"Unrecognized cmap0 format %s\n", color_info); + plwarn(msgbuf); + break; + } c_plscol0(i, r, g, b); } else if(strlen(color_info) == 9){ - sscanf(color_info, "#%2x%2x%2x%2x", &r, &g, &b, &a); + if (sscanf(color_info, "#%2x%2x%2x%2x", &r, &g, &b, &a) != 4) { + snprintf(msgbuf,1024,"Unrecognized cmap0 format %s\n", color_info); + plwarn(msgbuf); + break; + } c_plscol0a(i, r, g, b, a); } else{ - printf("Unrecognized cmap0 format %s\n", color_info); + snprintf(msgbuf,1024,"Unrecognized cmap0 format %s\n", color_info); + plwarn(msgbuf); + break; } } @@ -1257,55 +1278,105 @@ { int i; int number_colors; - int have_alpha; - char color_info[30]; - int r_i, g_i, b_i, a_i, pos_i; + int format_version, err; + PLBOOL rgb; + char color_info[160]; + int r_i, g_i, b_i, pos_i, rev_i; + double r_d, g_d, b_d, a_d, pos_d; PLFLT *r, *g, *b, *a, *pos; + PLBOOL *rev; FILE *fp; + char msgbuf[1024]; - have_alpha = 1; - fp = (FILE *)plLibOpen(filename); - fscanf(fp, "%d\n", &number_colors); + rgb = TRUE; + rev = NULL; + err = 0; + format_version = 0; + fp = plLibOpen(filename); + if (fp == NULL) { + snprintf(msgbuf,1024,"Unable to open cmap1 .pal file %s\n",filename); + plwarn(msgbuf); + return; + } + + /* Check for new file format */ + fgets(color_info, 160, fp); + if (strncmp(color_info,"v2 ",2) == 0) { + format_version = 1; + if (strncmp(&color_info[3],"hls",3) == 0) + rgb = FALSE; + else if (strncmp(&color_info[3],"rgb",3) == 0) + rgb = TRUE; + else { + snprintf(msgbuf,1024,"Invalid color space %s - assuming RGB\n",&color_info[3]); + plwarn(msgbuf); + rgb = TRUE; + } + fgets(color_info, 160, fp); + } + + if (sscanf(color_info, "%d\n", &number_colors) != 1) { + snprintf(msgbuf,1024,"Unrecognized cmap1 format %s\n", color_info); + plwarn(msgbuf); + fclose(fp); + return; + } + r = (PLFLT *)malloc(number_colors * sizeof(PLFLT)); g = (PLFLT *)malloc(number_colors * sizeof(PLFLT)); b = (PLFLT *)malloc(number_colors * sizeof(PLFLT)); a = (PLFLT *)malloc(number_colors * sizeof(PLFLT)); pos = (PLFLT *)malloc(number_colors * sizeof(PLFLT)); + if (format_version > 0) { + rev = (PLBOOL *)malloc(number_colors * sizeof(PLBOOL)); + } - for(i=0;i<number_colors;i++){ - fgets(color_info, 30, fp); - color_info[strlen(color_info)-1] = '\0'; - if(color_info[7] == ' '){ - have_alpha = 0; - sscanf(color_info, "#%2x%2x%2x %d", &r_i, &g_i, &b_i, &pos_i); + if (format_version == 0) { + /* Old tk file format */ + for(i=0;i<number_colors;i++){ + fgets(color_info, 160, fp); + /* Ensure string is null terminated if > 160 characters */ + color_info[159] = '\0'; + if (sscanf(color_info, "#%2x%2x%2x %d", &r_i, &g_i, &b_i, &pos_i) < 4) { + snprintf(msgbuf,1024,"Unrecognized cmap1 format %s\n", color_info); + plwarn(msgbuf); + err = 1; + break; + } r[i] = (PLFLT)r_i; g[i] = (PLFLT)g_i; b[i] = (PLFLT)b_i; - pos[i] = 0.01 * (PLFLT)pos_i; + a[i] = 1.0; + pos[i] = 0.01*(PLFLT)pos_i; } - else if(color_info[9] == ' '){ - sscanf(color_info, "#%2x%2x%2x%2x %d", &r_i, &g_i, &b_i, &a_i, &pos_i); - r[i] = (PLFLT)r_i; - g[i] = (PLFLT)g_i; - b[i] = (PLFLT)b_i; - a[i] = (PLFLT)a_i; - pos[i] = 0.01 * (PLFLT)pos_i; + } + else { + /* New floating point file version with support for alpha and rev values */ + for(i=0;i<number_colors;i++){ + fgets(color_info, 160, fp); + if (sscanf(color_info, "%lf %lf %lf %lf %lf %d", &pos_d, &r_d, &g_d, &b_d, &a_d, &rev_i) < 6) { + snprintf(msgbuf,1024,"Unrecognized cmap1 format %s\n", color_info); + plwarn(msgbuf); + err = 1; + break; + } + r[i] = (PLFLT)r_d; + g[i] = (PLFLT)g_d; + b[i] = (PLFLT)b_d; + a[i] = (PLFLT)a_d; + rev[i] = (PLBOOL)rev_i; + pos[i] = (PLFLT)pos_d; } - else{ - printf("Unrecognized cmap1 format %s\n", color_info); - } } fclose(fp); - /* Set the first control point position to 0.0 and the last */ - /* to 1.0 to deal with any possible round off errors. */ - pos[0] = 0.0; - pos[number_colors-1] = 1.0; + if (err == 0) { + /* Set the first control point position to 0.0 and the last */ + /* to 1.0 to deal with any possible round off errors. */ + pos[0] = 0.0; + pos[number_colors-1] = 1.0; - if (have_alpha == 1){ - c_plscmap1la(1, number_colors, pos, r, g, b, a, NULL); - } else { - c_plscmap1l(1, number_colors, pos, r, g, b, NULL); + c_plscmap1la(rgb, number_colors, pos, r, g, b, a, rev); } free(r); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2009-07-09 14:47:20
|
Revision: 10126 http://plplot.svn.sourceforge.net/plplot/?rev=10126&view=rev Author: andrewross Date: 2009-07-09 14:47:16 +0000 (Thu, 09 Jul 2009) Log Message: ----------- Fix up warning messages for cmap0 palette reading code. Alter so that alpha (if present) is a floating point number, consistent with plscol0. Add an example of a cmap0 palette to the data directory - this is default palette with black and white swapped to give a white background. Modified Paths: -------------- trunk/data/CMakeLists.txt trunk/src/plctrl.c Added Paths: ----------- trunk/data/cmap0_white_bg.pal Modified: trunk/data/CMakeLists.txt =================================================================== --- trunk/data/CMakeLists.txt 2009-07-09 09:14:55 UTC (rev 10125) +++ trunk/data/CMakeLists.txt 2009-07-09 14:47:16 UTC (rev 10126) @@ -26,6 +26,7 @@ plxtnd5.fnt usa.map usaglobe.map +cmap0_white_bg.pal cmap1_blue_yellow.pal ) Added: trunk/data/cmap0_white_bg.pal =================================================================== --- trunk/data/cmap0_white_bg.pal (rev 0) +++ trunk/data/cmap0_white_bg.pal 2009-07-09 14:47:16 UTC (rev 10126) @@ -0,0 +1,17 @@ +16 +#ffffff 1.0 +#ff0000 1.0 +#ffff00 1.0 +#00ff00 1.0 +#7fffd4 1.0 +#ffc0cb 1.0 +#f5deb3 1.0 +#bebebe 1.0 +#a52a2a 1.0 +#0000ff 1.0 +#8a2be2 1.0 +#00ffff 1.0 +#40e0d0 1.0 +#ff00ff 1.0 +#fa8072 1.0 +#000000 1.0 Modified: trunk/src/plctrl.c =================================================================== --- trunk/src/plctrl.c 2009-07-09 09:14:55 UTC (rev 10125) +++ trunk/src/plctrl.c 2009-07-09 14:47:16 UTC (rev 10126) @@ -1219,7 +1219,8 @@ void c_plspal0(const char *filename) { - int i, r, g, b, a; + int i, r, g, b, nread; + double a; int number_colors; char color_info[30]; FILE *fp; @@ -1227,12 +1228,12 @@ fp = plLibOpen(filename); if (fp == NULL) { - snprintf(msgbuf,1024,"Unable to open cmap1 file %s\n",filename); + snprintf(msgbuf,1024,"Unable to open cmap0 file %s\n",filename); plwarn(msgbuf); return; } if (fscanf(fp, "%d\n", &number_colors) != 1) { - snprintf(msgbuf,1024,"Unrecognized cmap1 header\n"); + snprintf(msgbuf,1024,"Unrecognized cmap0 header\n"); plwarn(msgbuf); fclose(fp); return; @@ -1248,13 +1249,13 @@ } c_plscol0(i, r, g, b); } - else if(strlen(color_info) == 9){ - if (sscanf(color_info, "#%2x%2x%2x%2x", &r, &g, &b, &a) != 4) { + else if(strlen(color_info) > 9){ + if (sscanf(color_info, "#%2x%2x%2x %lf", &r, &g, &b, &a) != 4) { snprintf(msgbuf,1024,"Unrecognized cmap0 format %s\n", color_info); plwarn(msgbuf); break; } - c_plscol0a(i, r, g, b, a); + c_plscol0a(i, r, g, b, (PLFLT) a); } else{ snprintf(msgbuf,1024,"Unrecognized cmap0 format %s\n", color_info); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2009-07-10 18:56:49
|
Revision: 10136 http://plplot.svn.sourceforge.net/plplot/?rev=10136&view=rev Author: andrewross Date: 2009-07-10 18:56:45 +0000 (Fri, 10 Jul 2009) Log Message: ----------- plLibOpenPdfstrm should look in the data directory in the source tree not the build tree when run from the build tree. Data files (fonts, maps, colour maps) are source files and not generated. Modified Paths: -------------- trunk/config.h.cmake trunk/src/plctrl.c Modified: trunk/config.h.cmake =================================================================== --- trunk/config.h.cmake 2009-07-10 06:21:20 UTC (rev 10135) +++ trunk/config.h.cmake 2009-07-10 18:56:45 UTC (rev 10136) @@ -462,6 +462,9 @@ /* Define as the return type of signal handlers (`int' or `void'). */ #define RETSIGTYPE ${RETSIGTYPE} +/* Location of Source tree */ +#define SOURCE_DIR "${SOURCE_DIR}" + /* Define to 1 if you have the ANSI C header files. */ #cmakedefine STDC_HEADERS 1 Modified: trunk/src/plctrl.c =================================================================== --- trunk/src/plctrl.c 2009-07-10 06:21:20 UTC (rev 10135) +++ trunk/src/plctrl.c 2009-07-10 18:56:45 UTC (rev 10136) @@ -1736,7 +1736,7 @@ /**** search build tree ****/ if (plInBuildTree() == 1) { - plGetName(BUILD_DIR, "data", fn, &fs); + plGetName(SOURCE_DIR, "data", fn, &fs); if ((file = pdf_fopen(fs, "rb")) != NULL) goto done; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2009-07-10 19:58:10
|
Revision: 10137 http://plplot.svn.sourceforge.net/plplot/?rev=10137&view=rev Author: andrewross Date: 2009-07-10 19:58:03 +0000 (Fri, 10 Jul 2009) Log Message: ----------- Move the bindings/octave/demos directory to examples/octave consistent with all other languages. Modified Paths: -------------- trunk/bindings/octave/CMakeLists.txt trunk/bindings/octave/octaverc.in trunk/examples/CMakeLists.txt trunk/examples/octave/CMakeLists.txt trunk/examples/octave/x27c.m trunk/examples/octave/x28c.m trunk/examples/octave/x30c.m trunk/plplot_test/CMakeLists.txt Added Paths: ----------- trunk/examples/octave/ Removed Paths: ------------- trunk/bindings/octave/demos/ Modified: trunk/bindings/octave/CMakeLists.txt =================================================================== --- trunk/bindings/octave/CMakeLists.txt 2009-07-10 18:56:45 UTC (rev 10136) +++ trunk/bindings/octave/CMakeLists.txt 2009-07-10 19:58:03 UTC (rev 10137) @@ -23,7 +23,6 @@ if(ENABLE_octave) add_subdirectory(PLplot) -add_subdirectory(demos) add_subdirectory(misc) # Install renamed documentation files. Modified: trunk/bindings/octave/octaverc.in =================================================================== --- trunk/bindings/octave/octaverc.in 2009-07-10 18:56:45 UTC (rev 10136) +++ trunk/bindings/octave/octaverc.in 2009-07-10 19:58:03 UTC (rev 10137) @@ -1,4 +1,4 @@ -addpath("@CMAKE_SOURCE_DIR@/bindings/octave/PLplot/","@CMAKE_SOURCE_DIR@/bindings/octave/PLplot/support/","@CMAKE_SOURCE_DIR@/bindings/octave/demos/","@CMAKE_SOURCE_DIR@/bindings/octave/misc/","@CMAKE_BINARY_DIR@/bindings/octave/","@CMAKE_BINARY_DIR@/bindings/octave/PLplot"); +addpath("@CMAKE_SOURCE_DIR@/bindings/octave/PLplot/","@CMAKE_SOURCE_DIR@/bindings/octave/PLplot/support/","@CMAKE_SOURCE_DIR@/examples/octave/","@CMAKE_SOURCE_DIR@/bindings/octave/misc/","@CMAKE_BINARY_DIR@/bindings/octave/","@CMAKE_BINARY_DIR@/bindings/octave/PLplot"); putenv("PLPLOT_LIB","@CMAKE_SOURCE_DIR@/data/"); global pl_automatic_replot pl_automatic_replot=1; Modified: trunk/examples/CMakeLists.txt =================================================================== --- trunk/examples/CMakeLists.txt 2009-07-10 18:56:45 UTC (rev 10136) +++ trunk/examples/CMakeLists.txt 2009-07-10 19:58:03 UTC (rev 10137) @@ -95,6 +95,9 @@ if(ENABLE_lua) add_subdirectory(lua) endif(ENABLE_lua) +if(ENABLE_octave) + add_subdirectory(octave) +endif(ENABLE_octave) # Configure Makefile.examples with some specific variables Property changes on: trunk/examples/octave ___________________________________________________________________ Added: svn:ignore + *.flc Makefile Makefile.in .deps .libs *.la *.lo Added: svn:mergeinfo + Modified: trunk/examples/octave/CMakeLists.txt =================================================================== --- trunk/bindings/octave/demos/CMakeLists.txt 2009-07-10 06:21:20 UTC (rev 10135) +++ trunk/examples/octave/CMakeLists.txt 2009-07-10 19:58:03 UTC (rev 10137) @@ -1,4 +1,4 @@ -# bindings/octave/demos/CMakeLists.txt for PLplot +# examples/octave/CMakeLists.txt for PLplot ### ### Process this file with cmake to produce Makefile ### Modified: trunk/examples/octave/x27c.m =================================================================== --- trunk/bindings/octave/demos/x27c.m 2009-07-10 06:21:20 UTC (rev 10135) +++ trunk/examples/octave/x27c.m 2009-07-10 19:58:03 UTC (rev 10137) @@ -1,4 +1,4 @@ -## $Id:$ +## $Id$ ## ## Drawing "spirograph" curves - epitrochoids, cycolids, roulettes ## Modified: trunk/examples/octave/x28c.m =================================================================== --- trunk/bindings/octave/demos/x28c.m 2009-07-10 06:21:20 UTC (rev 10135) +++ trunk/examples/octave/x28c.m 2009-07-10 19:58:03 UTC (rev 10137) @@ -1,4 +1,4 @@ -## $Id:$ +## $Id$ ## ## plmtex3, plptex3 demo ## Modified: trunk/examples/octave/x30c.m =================================================================== --- trunk/bindings/octave/demos/x30c.m 2009-07-10 06:21:20 UTC (rev 10135) +++ trunk/examples/octave/x30c.m 2009-07-10 19:58:03 UTC (rev 10137) @@ -1,4 +1,4 @@ -## $Id:$ +## $Id$ ## ## Alpha color values demonstration. ## Modified: trunk/plplot_test/CMakeLists.txt =================================================================== --- trunk/plplot_test/CMakeLists.txt 2009-07-10 18:56:45 UTC (rev 10136) +++ trunk/plplot_test/CMakeLists.txt 2009-07-10 19:58:03 UTC (rev 10137) @@ -340,9 +340,9 @@ add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lena.img COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_SOURCE_DIR}/bindings/octave/demos/lena.img + ${CMAKE_SOURCE_DIR}/examples/octave/lena.img ${CMAKE_CURRENT_BINARY_DIR}/lena.img - DEPENDS ${CMAKE_SOURCE_DIR}/bindings/octave/demos/lena.img + DEPENDS ${CMAKE_SOURCE_DIR}/examples/octave/lena.img ) add_custom_target(lena_octave_file ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/lena.img) endif(ENABLE_octave) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2009-07-20 01:47:49
|
Revision: 10165 http://plplot.svn.sourceforge.net/plplot/?rev=10165&view=rev Author: hbabcock Date: 2009-07-20 01:47:47 +0000 (Mon, 20 Jul 2009) Log Message: ----------- Added the routine difilt_clip to PLplot core which will appropriately transform the coordinates of the text clipping rectangle for the benefit of those drivers that render their own text. Changed the svg driver and the cairo driver to use this new core routine for their text clipping. Modified Paths: -------------- trunk/drivers/cairo.c trunk/drivers/svg.c trunk/include/plplotP.h trunk/src/plcore.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2009-07-20 01:15:20 UTC (rev 10164) +++ trunk/drivers/cairo.c 2009-07-20 01:47:47 UTC (rev 10165) @@ -596,6 +596,7 @@ PangoLayout *layout; PangoFontDescription *fontDescription; PLCairo *aStream; + PLINT rcx[4], rcy[4]; aStream = (PLCairo *)pls->dev; @@ -617,25 +618,37 @@ pango_layout_context_changed(layout); cairo_font_options_destroy(cairoFontOptions); + /* Save current transform matrix & clipping region */ + cairo_save(aStream->cairoContext); + /* Set up the clipping region if we are doing text clipping */ if(aStream->text_clipping){ - cairo_save(aStream->cairoContext); - diorot_rad = pls->diorot * PI/2.0; - rotate_cairo_surface(pls, - cos(diorot_rad), - sin(diorot_rad), - -sin(diorot_rad), - cos(diorot_rad), - 0.5 * pls->xlength, - 0.5 * pls->ylength); - cairo_rectangle(aStream->cairoContext, aStream->downscale * pls->clpxmi, aStream->downscale * pls->clpymi, aStream->downscale * (pls->clpxma - pls->clpxmi), aStream->downscale * (pls->clpyma - pls->clpymi)); + + /* Use PLplot core routine to get the corners of the clipping rectangle */ + difilt_clip(rcx, rcy); + + /* Layout the bounds of the clipping region */ + /* Should we convert PLINT to short and use the polyline routine? */ + cairo_move_to(aStream->cairoContext, + aStream->downscale * (double) rcx[0], + aStream->downscale * (double) rcy[0]); + cairo_line_to(aStream->cairoContext, + aStream->downscale * (double) rcx[1], + aStream->downscale * (double) rcy[1]); + cairo_line_to(aStream->cairoContext, + aStream->downscale * (double) rcx[2], + aStream->downscale * (double) rcy[2]); + cairo_line_to(aStream->cairoContext, + aStream->downscale * (double) rcx[3], + aStream->downscale * (double) rcy[3]); + cairo_line_to(aStream->cairoContext, + aStream->downscale * (double) rcx[0], + aStream->downscale * (double) rcy[0]); + + /* Set the clipping region */ cairo_clip(aStream->cairoContext); - cairo_restore(aStream->cairoContext); } - /* Save current transform matrix & clipping region */ - cairo_save(aStream->cairoContext); - /* Move to the string reference point */ cairo_move_to(aStream->cairoContext, aStream->downscale * (double) args->x, aStream->downscale * (double) args->y); Modified: trunk/drivers/svg.c =================================================================== --- trunk/drivers/svg.c 2009-07-20 01:15:20 UTC (rev 10164) +++ trunk/drivers/svg.c 2009-07-20 01:47:47 UTC (rev 10165) @@ -465,7 +465,6 @@ short lastOffset; double ftHt; PLUNICODE fci; - PLINT x1c, y1c, x2c, y2c; PLINT rcx[4], rcy[4]; PLFLT rotation, shear, stride, cos_rot, sin_rot, sin_shear, cos_shear; PLFLT t[4]; @@ -495,21 +494,9 @@ svg_attr_values(aStream, "id","text-clipping%d", which_clip); svg_general(aStream, ">\n"); - /* Use PLplot core routine to appropriately transform the - coordinates of the clipping rectangle */ - x1c = pls->clpxmi; - y1c = pls->clpymi; - x2c = pls->clpxma; - y2c = pls->clpyma; - rcx[0] = x1c; - rcx[1] = x1c; - rcx[2] = x2c; - rcx[3] = x2c; - rcy[0] = y1c; - rcy[1] = y2c; - rcy[2] = y2c; - rcy[3] = y1c; - difilt(rcx, rcy, 4, &x1c, &x2c, &y1c, &y2c); + /* Use PLplot core routine difilt_clip to appropriately + transform the coordinates of the clipping rectangle */ + difilt_clip(rcx, rcy); /* Output a polygon to represent the clipping region. */ svg_open(aStream, "polygon"); @@ -536,6 +523,7 @@ /* This draws the clipping region on the screen which can be very helpful for debugging. */ + /* svg_open(aStream, "polygon"); svg_attr_values(aStream, Modified: trunk/include/plplotP.h =================================================================== --- trunk/include/plplotP.h 2009-07-20 01:15:20 UTC (rev 10164) +++ trunk/include/plplotP.h 2009-07-20 01:47:47 UTC (rev 10165) @@ -518,6 +518,12 @@ difilt(PLINT *, PLINT *, PLINT, PLINT *, PLINT *, PLINT *, PLINT *); + /* Transforms the clipping region coordinates as necessary + based on the current plot orientation, etc. */ + +PLDLLIMPEXP void +difilt_clip(PLINT *, PLINT *); + /* Driver draws text */ void Modified: trunk/src/plcore.c =================================================================== --- trunk/src/plcore.c 2009-07-20 01:15:20 UTC (rev 10164) +++ trunk/src/plcore.c 2009-07-20 01:47:47 UTC (rev 10165) @@ -1127,6 +1127,34 @@ } /*--------------------------------------------------------------------------*\ + * void difilt_clip + * + * This provides the transformed text clipping region for the benefit of + * those drivers that render their own text. +\*--------------------------------------------------------------------------*/ + +void +difilt_clip(PLINT *x_coords, PLINT *y_coords) +{ + PLINT x1c, x2c, y1c, y2c; + + x1c = plsc->clpxmi; + y1c = plsc->clpymi; + x2c = plsc->clpxma; + y2c = plsc->clpyma; + x_coords[0] = x1c; + x_coords[1] = x1c; + x_coords[2] = x2c; + x_coords[3] = x2c; + y_coords[0] = y1c; + y_coords[1] = y2c; + y_coords[2] = y2c; + y_coords[3] = y1c; + difilt(x_coords, y_coords, 4, &x1c, &x2c, &y1c, &y2c); +} + + +/*--------------------------------------------------------------------------*\ * void pldi_ini * * Updates driver interface, making sure everything is in order. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2009-07-20 13:13:10
|
Revision: 10166 http://plplot.svn.sourceforge.net/plplot/?rev=10166&view=rev Author: andrewross Date: 2009-07-20 12:00:27 +0000 (Mon, 20 Jul 2009) Log Message: ----------- Sort out g++ visibility issues with qt driver. Can now compile and run example with qt raster and qtwidget drivers. The c++ qt_example work, but the visibility issues with the pyqt4 bindings are not (yet) sorted. Modified Paths: -------------- trunk/bindings/qt_gui/plqt.cpp trunk/drivers/qt.cpp trunk/include/pldll.h.in trunk/include/qt.h Modified: trunk/bindings/qt_gui/plqt.cpp =================================================================== --- trunk/bindings/qt_gui/plqt.cpp 2009-07-20 01:47:47 UTC (rev 10165) +++ trunk/bindings/qt_gui/plqt.cpp 2009-07-20 12:00:27 UTC (rev 10166) @@ -34,9 +34,43 @@ #include "qt.h" // Global variables for Qt driver. -int vectorize = 0; -MasterHandler handler; +PLDLLIMPEXP_QT_DATA(int) vectorize = 0; +PLDLLIMPEXP_QT_DATA(MasterHandler) handler; +// Master Device Handler for multiple streams +// Only handles multiple Qt devices +MasterHandler::MasterHandler():QObject() +{ + masterDevice=NULL; +} + +bool MasterHandler::isMasterDevice(QtPLDriver* d) +{ + return d==masterDevice; +} + +void MasterHandler::setMasterDevice(QtPLDriver* d) +{ + masterDevice=d; +} + +void MasterHandler::DeviceChangedPage(QtPLDriver* d) +{ + if(d==masterDevice) + { + emit MasterChangedPage(); + } +} + +void MasterHandler::DeviceClosed(QtPLDriver* d) +{ + if(d==masterDevice) + { + emit MasterClosed(); + masterDevice=NULL; + } +} + ///////////// Generic Qt driver class ///////////////// QMutex QtPLDriver::mutex; Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2009-07-20 01:47:47 UTC (rev 10165) +++ trunk/drivers/qt.cpp 2009-07-20 12:00:27 UTC (rev 10166) @@ -237,7 +237,7 @@ if(widget!=NULL && qt_family_check(pls)) {return;} #endif #if defined(PLD_qtwidget) || defined(PLD_extqt) - if(widget==NULL) widget=dynamic_cast<QtPLWidget*>((QWidget *) pls->dev); + if(widget==NULL) widget=dynamic_cast<QtPLWidget*>((QtPLWidget *) pls->dev); #endif if(widget==NULL) return; @@ -262,7 +262,7 @@ if(widget!=NULL && qt_family_check(pls)) {return;} #endif #if defined(PLD_qtwidget) || defined(PLD_extqt) - if(widget==NULL) widget=dynamic_cast<QtPLWidget*>((QWidget *) pls->dev); + if(widget==NULL) widget=dynamic_cast<QtPLWidget*>((QtPLWidget *) pls->dev); #endif if(widget==NULL) return; @@ -289,7 +289,7 @@ if(widget!=NULL && qt_family_check(pls)) {return;} #endif #if defined(PLD_qtwidget) || defined(PLD_extqt) - if(widget==NULL) widget=dynamic_cast<QtPLWidget*>((QWidget *) pls->dev); + if(widget==NULL) widget=dynamic_cast<QtPLWidget*>((QtPLWidget *) pls->dev); #endif if(widget==NULL) return; @@ -345,7 +345,7 @@ if(widget!=NULL && qt_family_check(pls)) {return;} #endif #if defined(PLD_qtwidget) || defined(PLD_extqt) - if(widget==NULL) widget=dynamic_cast<QtPLWidget*>((QWidget *) pls->dev); + if(widget==NULL) widget=dynamic_cast<QtPLWidget*>((QtPLWidget *) pls->dev); #endif if(widget==NULL) return; Modified: trunk/include/pldll.h.in =================================================================== --- trunk/include/pldll.h.in 2009-07-20 01:47:47 UTC (rev 10165) +++ trunk/include/pldll.h.in 2009-07-20 12:00:27 UTC (rev 10166) @@ -141,4 +141,12 @@ #define PLDLLIMPEXP_PLPLOT_MODULE_DATA(type) PLDLLIMPORT type #endif +#if defined(plplotqt${LIB_TAG}_EXPORTS) + #define PLDLLIMPEXP_QT PLDLLEXPORT + #define PLDLLIMPEXP_QT_DATA(type) PLDLLEXPORT type +#else + #define PLDLLIMPEXP_QT PLDLLIMPORT + #define PLDLLIMPEXP_QT_DATA(type) PLDLLIMPORT type +#endif + #endif /* __PL_DLL_H */ Modified: trunk/include/qt.h =================================================================== --- trunk/include/qt.h 2009-07-20 01:47:47 UTC (rev 10165) +++ trunk/include/qt.h 2009-07-20 12:00:27 UTC (rev 10166) @@ -88,48 +88,25 @@ #define QT_DEFAULT_X 842 #define QT_DEFAULT_Y 595 -class QtPLDriver; +class PLDLLIMPEXP_QT QtPLDriver; // Master Device Handler for multiple streams // Only handles multiple Qt devices -class MasterHandler:public QObject +class PLDLLIMPEXP_QT MasterHandler:public QObject { Q_OBJECT public: - MasterHandler():QObject() - { - masterDevice=NULL; - } + MasterHandler(); - ~MasterHandler(){} + bool isMasterDevice(QtPLDriver* d); - bool isMasterDevice(QtPLDriver* d) - { - return d==masterDevice; - } - - void setMasterDevice(QtPLDriver* d) - { - masterDevice=d; - } + void setMasterDevice(QtPLDriver* d); - void DeviceChangedPage(QtPLDriver* d) - { - if(d==masterDevice) - { - emit MasterChangedPage(); - } - } + void DeviceChangedPage(QtPLDriver* d); - void DeviceClosed(QtPLDriver* d) - { - if(d==masterDevice) - { - emit MasterClosed(); - masterDevice=NULL; - } - } + void DeviceClosed(QtPLDriver* d); + signals: void MasterChangedPage(); @@ -140,7 +117,7 @@ }; // Basic class, offering the common interface to all Qt plplot devices -class PLDLLIMPEXP_DRIVER QtPLDriver +class PLDLLIMPEXP_QT QtPLDriver { public: // Constructor, taking the device size as arguments @@ -196,7 +173,7 @@ #if defined (PLD_bmpqt) || defined(PLD_jpgqt) || defined (PLD_pngqt) || defined(PLD_ppmqt) || defined(PLD_tiffqt) // Driver painting whatever raster format Qt can save -class QtRasterDevice: public QtPLDriver, public QImage +class PLDLLIMPEXP_QT QtRasterDevice: public QtPLDriver, public QImage { public: QtRasterDevice(int i_iWidth=QT_DEFAULT_X, @@ -224,7 +201,7 @@ #if defined(PLD_svgqt) && QT_VERSION >= 0x040300 #include <QSvgGenerator> // Driver painting on an SVG device -class QtSVGDevice: public QtPLDriver, public QSvgGenerator +class PLDLLIMPEXP_QT QtSVGDevice: public QtPLDriver, public QSvgGenerator { public: QtSVGDevice(int i_iWidth=QT_DEFAULT_X, @@ -242,7 +219,7 @@ #if defined (PLD_epsqt) || defined (PLD_pdfqt) // Driver painting on an EPS or PDF device, uses QPrinter // A (possibly dummy) QApplication must be declared before use -class QtEPSDevice: public QtPLDriver, public QPrinter +class PLDLLIMPEXP_QT QtEPSDevice: public QtPLDriver, public QPrinter { public: #if QT_VERSION < 0x040400 @@ -336,7 +313,7 @@ // This widget allows to use plplot as a plotting engine in a Qt Application // The aspect ratio of the plotted data is constant, so gray strips are used // to delimit the page when the widget aspect ratio is not the one of the plotted page -class PLDLLIMPEXP_DRIVER QtPLWidget: public QWidget, public QtPLDriver +class PLDLLIMPEXP_QT QtPLWidget: public QWidget, public QtPLDriver { Q_OBJECT @@ -390,7 +367,7 @@ #endif #if defined (PLD_extqt) -class PLDLLIMPEXP_DRIVER QtExtWidget: public QtPLWidget +class PLDLLIMPEXP_QT QtExtWidget: public QtPLWidget { Q_OBJECT @@ -419,9 +396,9 @@ bool killed; }; -PLDLLIMPEXP_DRIVER void plsetqtdev(QtExtWidget* widget); // Registers the widget as plot device, as the widget has to be created in the Qt application GUI, prior to any plplot call. Must be called before plinit(). +PLDLLIMPEXP_QT void plsetqtdev(QtExtWidget* widget); // Registers the widget as plot device, as the widget has to be created in the Qt application GUI, prior to any plplot call. Must be called before plinit(). -PLDLLIMPEXP_DRIVER void plfreeqtdev(); // Deletes and unregisters the device. +PLDLLIMPEXP_QT void plfreeqtdev(); // Deletes and unregisters the device. #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2009-07-20 21:12:57
|
Revision: 10169 http://plplot.svn.sourceforge.net/plplot/?rev=10169&view=rev Author: andrewross Date: 2009-07-20 21:12:55 +0000 (Mon, 20 Jul 2009) Log Message: ----------- Big change to clean up the plplot namespace. Now plConfig.h only contains macros which need to be externally visible because they are referenced in plplot.h or are used in the examples. These are all prefaced with PL_ . All other macro definitions which are only used internally reside in config.h. Also, the HAVE_ISINF, HAVE_ISNAN and HAVE_FINITE definitions have PL_ added on the front to remove the redefinition warnings caused by python leaking the HAVE_* macros. Modified Paths: -------------- trunk/bindings/c++/plstream.cc trunk/bindings/tcl/tclAPI.c trunk/bindings/tk/plframe.c trunk/bindings/tk/tcpip.c trunk/bindings/tk-x-plat/plplotter.c trunk/cmake/modules/TestBrokenIsnanCXX.cmake trunk/cmake/modules/TestBrokenIsnanCXX.cxx trunk/cmake/modules/TestForNamespace.cmake trunk/cmake/modules/TestForStdintCXX.cmake trunk/cmake/modules/c++.cmake trunk/cmake/modules/plplot.cmake trunk/cmake/modules/wxwidgets.cmake trunk/config.h.cmake trunk/drivers/tk.c trunk/examples/c/plcdemos.h trunk/examples/c/x01c.c trunk/examples/c/x17c.c trunk/examples/c++/plc++demos.h trunk/examples/c++/x01.cc trunk/examples/c++/x01cc.cc trunk/examples/c++/x02.cc trunk/examples/c++/x03.cc trunk/examples/c++/x04.cc trunk/examples/c++/x05.cc trunk/examples/c++/x06.cc trunk/examples/c++/x07.cc trunk/examples/c++/x08.cc trunk/examples/c++/x09.cc trunk/examples/c++/x10.cc trunk/examples/c++/x11.cc trunk/examples/c++/x12.cc trunk/examples/c++/x13.cc trunk/examples/c++/x14.cc trunk/examples/c++/x15.cc trunk/examples/c++/x16.cc trunk/examples/c++/x17.cc trunk/examples/c++/x18.cc trunk/examples/c++/x19.cc trunk/examples/c++/x20.cc trunk/examples/c++/x21.cc trunk/examples/c++/x22.cc trunk/examples/c++/x23.cc trunk/examples/c++/x26.cc trunk/examples/c++/x27.cc trunk/examples/c++/x28.cc trunk/examples/c++/x29.cc trunk/examples/c++/x30.cc trunk/examples/c++/x31.cc trunk/include/plConfig.h.cmake trunk/include/plplot.h trunk/include/plplotP.h trunk/src/plctrl.c Modified: trunk/bindings/c++/plstream.cc =================================================================== --- trunk/bindings/c++/plstream.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/bindings/c++/plstream.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -31,7 +31,7 @@ #include <iostream> -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/bindings/tcl/tclAPI.c =================================================================== --- trunk/bindings/tcl/tclAPI.c 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/bindings/tcl/tclAPI.c 2009-07-20 21:12:55 UTC (rev 10169) @@ -34,7 +34,7 @@ #include "plplotP.h" #include "pltcl.h" #ifndef __WIN32__ -#ifdef HAVE_UNISTD_H +#ifdef PL_HAVE_UNISTD_H #include <unistd.h> #endif #else Modified: trunk/bindings/tk/plframe.c =================================================================== --- trunk/bindings/tk/plframe.c 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/bindings/tk/plframe.c 2009-07-20 21:12:55 UTC (rev 10169) @@ -54,7 +54,7 @@ #include "plxwd.h" #include "tcpip.h" -#ifdef HAVE_UNISTD_H +#ifdef PL_HAVE_UNISTD_H #include <unistd.h> #endif #include <fcntl.h> Modified: trunk/bindings/tk/tcpip.c =================================================================== --- trunk/bindings/tk/tcpip.c 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/bindings/tk/tcpip.c 2009-07-20 21:12:55 UTC (rev 10169) @@ -93,7 +93,7 @@ #if defined(__sgi) && !defined(SVR3) #include <sys/select.h> #endif -#ifdef HAVE_UNISTD_H +#ifdef PL_HAVE_UNISTD_H #include <unistd.h> #endif Modified: trunk/bindings/tk-x-plat/plplotter.c =================================================================== --- trunk/bindings/tk-x-plat/plplotter.c 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/bindings/tk-x-plat/plplotter.c 2009-07-20 21:12:55 UTC (rev 10169) @@ -82,7 +82,7 @@ #endif #ifndef __WIN32__ -#ifdef HAVE_UNISTD_H +#ifdef PL_HAVE_UNISTD_H #include <unistd.h> #include <fcntl.h> #endif Modified: trunk/cmake/modules/TestBrokenIsnanCXX.cmake =================================================================== --- trunk/cmake/modules/TestBrokenIsnanCXX.cmake 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/cmake/modules/TestBrokenIsnanCXX.cmake 2009-07-20 21:12:55 UTC (rev 10169) @@ -28,14 +28,14 @@ OUTPUT_VARIABLE OUTPUT) IF (CMAKE_BROKEN_ISNAN_CXX) MESSAGE(STATUS "Check for isnan in <cmath> - found") - SET (BROKEN_ISNAN_CXX 0 CACHE INTERNAL + SET (PL_BROKEN_ISNAN_CXX 0 CACHE INTERNAL "Does <cmath> contain isnan") FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log "Determining if <cmake> contains isnan passed with " "the following output:\n${OUTPUT}\n\n") ELSE (CMAKE_BROKEN_ISNAN_CXX) MESSAGE(STATUS "Check for isnan in <cmath> - not found") - SET (BROKEN_ISNAN_CXX 1 CACHE INTERNAL + SET (PL_BROKEN_ISNAN_CXX 1 CACHE INTERNAL "Does <cmath> contain isnan") FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log "Determining if <cmath> contains isnan failed with " Modified: trunk/cmake/modules/TestBrokenIsnanCXX.cxx =================================================================== --- trunk/cmake/modules/TestBrokenIsnanCXX.cxx 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/cmake/modules/TestBrokenIsnanCXX.cxx 2009-07-20 21:12:55 UTC (rev 10169) @@ -4,7 +4,7 @@ #include <math.h> #endif -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/cmake/modules/TestForNamespace.cmake =================================================================== --- trunk/cmake/modules/TestForNamespace.cmake 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/cmake/modules/TestForNamespace.cmake 2009-07-20 21:12:55 UTC (rev 10169) @@ -28,14 +28,14 @@ OUTPUT_VARIABLE OUTPUT) IF (CMAKE_USE_NAMESPACE) MESSAGE(STATUS "Check for using namespace - found") - SET (USE_NAMESPACE 1 CACHE INTERNAL + SET (PL_USE_NAMESPACE 1 CACHE INTERNAL "Does the compiler support using namespace") FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log "Determining if the CXX compiler has using namespace passed with " "the following output:\n${OUTPUT}\n\n") ELSE (CMAKE_USE_NAMESPACE) MESSAGE(STATUS "Check for using namespace - not found") - SET (USE_NAMESPACE 0 CACHE INTERNAL + SET (PL_USE_NAMESPACE 0 CACHE INTERNAL "Does the compiler support using namespace") FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log "Determining if the CXX compiler has using namespace failed with " Modified: trunk/cmake/modules/TestForStdintCXX.cmake =================================================================== --- trunk/cmake/modules/TestForStdintCXX.cmake 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/cmake/modules/TestForStdintCXX.cmake 2009-07-20 21:12:55 UTC (rev 10169) @@ -28,14 +28,14 @@ OUTPUT_VARIABLE OUTPUT) if(CMAKE_CXX_STDINT_H) message(STATUS "Check for using stdint.h with CXX compiler - ok") - set(HAVE_CXX_STDINT_H 1 CACHE INTERNAL + set(PL_HAVE_CXX_STDINT_H 1 CACHE INTERNAL "Does the CXX compiler support using stdint.h") file(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log "Determining if the CXX compiler supports using stdint.h passed with " "the following output:\n${OUTPUT}\n\n") else(CMAKE_CXX_STDINT_H) message(STATUS "Check for using stdint.h with CXX compiler - not found") - set(HAVE_CXX_STDINT_H 0 CACHE INTERNAL + set(PL_HAVE_CXX_STDINT_H 0 CACHE INTERNAL "Does the CXX compiler support using stdint.h") file(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log "Determining if the CXX compiler supports using stdint.h failed with " Modified: trunk/cmake/modules/c++.cmake =================================================================== --- trunk/cmake/modules/c++.cmake 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/cmake/modules/c++.cmake 2009-07-20 21:12:55 UTC (rev 10169) @@ -55,11 +55,11 @@ CHECK_INCLUDE_FILE_CXX(cmath HAVE_CMATH) if(NOT MSVC) - # Need to add check for broken cmath with isnan missing (BROKEN_ISNAN_CXX) + # Need to add check for broken cmath with isnan missing (PL_BROKEN_ISNAN_CXX) # but not for Visual C++ compilers include(TestBrokenIsnanCXX) endif(NOT MSVC) - # Need to add check if stdint.h can be used from c++ (HAVE_CXX_STDINT_H) + # Need to add check if stdint.h can be used from c++ (PL_HAVE_CXX_STDINT_H) INCLUDE(TestForStdintCXX) endif(ENABLE_cxx) Modified: trunk/cmake/modules/plplot.cmake =================================================================== --- trunk/cmake/modules/plplot.cmake 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/cmake/modules/plplot.cmake 2009-07-20 21:12:55 UTC (rev 10169) @@ -151,9 +151,9 @@ endif(NOT STDC_HEADERS) # AC_CHECK_HEADERS(unistd.h termios.h stdint.h) -check_include_files(unistd.h HAVE_UNISTD_H) +check_include_files(unistd.h PL_HAVE_UNISTD_H) check_include_files(termios.h HAVE_TERMIOS_H) -check_include_files(stdint.h HAVE_STDINT_H) +check_include_files(stdint.h PL_HAVE_STDINT_H) # AC_HEADER_SYS_WAIT include(TestForStandardHeaderwait) @@ -213,72 +213,72 @@ check_symbol_exists(finite "math.h" HAVE_FINITE_SYMBOL) if(HAVE_FINITE_SYMBOL) - set(HAVE_FINITE ON) + set(PL_HAVE_FINITE ON) else(HAVE_FINITE_SYMBOL) check_function_exists(finite HAVE_FINITE_FUNCTION) if(HAVE_FINITE_FUNCTION) - set(HAVE_FINITE ON) + set(PL_HAVE_FINITE ON) else(HAVE_FINITE_FUNCTION) check_symbol_exists(_finite "math.h" HAVE__FINITE_SYMBOL) if(HAVE__FINITE_SYMBOL) - set(_HAVE_FINITE ON) + set(PL__HAVE_FINITE ON) else(HAVE__FINITE_SYMBOL) check_function_exists(_finite HAVE__FINITE_FUNCTION) if(HAVE__FINITE_FUNCTION) - set(_HAVE_FINITE ON) + set(PL__HAVE_FINITE ON) endif(HAVE__FINITE_FUNCTION) endif(HAVE__FINITE_SYMBOL) endif(HAVE_FINITE_FUNCTION) endif(HAVE_FINITE_SYMBOL) -if(_HAVE_FINITE) - set(HAVE_FINITE ON) -endif(_HAVE_FINITE) +if(PL__HAVE_FINITE) + set(PL_HAVE_FINITE ON) +endif(PL__HAVE_FINITE) check_symbol_exists(isnan "math.h" HAVE_ISNAN_SYMBOL) if(HAVE_ISNAN_SYMBOL) - set(HAVE_ISNAN ON) + set(PL_HAVE_ISNAN ON) else(HAVE_ISNAN_SYMBOL) check_function_exists(isnan HAVE_ISNAN_FUNCTION) if(HAVE_ISNAN_FUNCTION) - set(HAVE_ISNAN ON) + set(PL_HAVE_ISNAN ON) else(HAVE_ISNAN_FUNCTION) check_symbol_exists(_isnan "math.h" HAVE__ISNAN_SYMBOL) if(HAVE__ISNAN_SYMBOL) - set(_HAVE_ISNAN ON) + set(PL__HAVE_ISNAN ON) else(HAVE__ISNAN_SYMBOL) check_function_exists(_isnan HAVE__ISNAN_FUNCTION) if(HAVE__ISNAN_FUNCTION) - set(_HAVE_ISNAN ON) + set(PL__HAVE_ISNAN ON) endif(HAVE__ISNAN_FUNCTION) endif(HAVE__ISNAN_SYMBOL) endif(HAVE_ISNAN_FUNCTION) endif(HAVE_ISNAN_SYMBOL) -if(_HAVE_ISNAN) - set(HAVE_ISNAN ON) -endif(_HAVE_ISNAN) +if(PL__HAVE_ISNAN) + set(PL_HAVE_ISNAN ON) +endif(PL__HAVE_ISNAN) check_symbol_exists(isinf "math.h" HAVE_ISINF_SYMBOL) if(HAVE_ISINF_SYMBOL) - set(HAVE_ISINF ON) + set(PL_HAVE_ISINF ON) else(HAVE_ISINF_SYMBOL) check_function_exists(isinf HAVE_ISINF_FUNCTION) if(HAVE_ISINF_FUNCTION) - set(HAVE_ISINF ON) + set(PL_HAVE_ISINF ON) else(HAVE_ISINF_FUNCTION) check_symbol_exists(_isinf "math.h" HAVE__ISINF_SYMBOL) if(HAVE__ISINF_SYMBOL) - set(_HAVE_ISINF ON) + set(PL__HAVE_ISINF ON) else(HAVE__ISINF_SYMBOL) check_function_exists(_isinf HAVE__ISINF_FUNCTION) if(HAVE__ISINF_FUNCTION) - set(_HAVE_ISINF ON) + set(PL__HAVE_ISINF ON) endif(HAVE__ISINF_FUNCTION) endif(HAVE__ISINF_SYMBOL) endif(HAVE_ISINF_FUNCTION) endif(HAVE_ISINF_SYMBOL) -if(_HAVE_ISINF) - set(HAVE_ISINF ON) -endif(_HAVE_ISINF) +if(PL__HAVE_ISINF) + set(PL_HAVE_ISINF ON) +endif(PL__HAVE_ISINF) check_function_exists(snprintf PL_HAVE_SNPRINTF) Modified: trunk/cmake/modules/wxwidgets.cmake =================================================================== --- trunk/cmake/modules/wxwidgets.cmake 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/cmake/modules/wxwidgets.cmake 2009-07-20 21:12:55 UTC (rev 10169) @@ -50,7 +50,7 @@ set(PLD_wxwidgets OFF CACHE BOOL "Enable wxwidgets device" FORCE) set(PLD_wxpng OFF CACHE BOOL "Enable wxwidgets png device" FORCE) else(NOT wxWidgets_FOUND) - # Check if stdint.h can be used from c++ (HAVE_CXX_STDINT_H) + # Check if stdint.h can be used from c++ (PL_HAVE_CXX_STDINT_H) include(TestForStdintCXX) endif(NOT wxWidgets_FOUND) endif(PLD_wxwidgets OR PLD_wxpng) Modified: trunk/config.h.cmake =================================================================== --- trunk/config.h.cmake 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/config.h.cmake 2009-07-20 21:12:55 UTC (rev 10169) @@ -10,7 +10,7 @@ #define BIN_DIR "${BIN_DIR}" /* isnan is in math.h but not cmath */ -#cmakedefine BROKEN_ISNAN_CXX +#cmakedefine PL_BROKEN_ISNAN_CXX /* Location of Build tree */ #define BUILD_DIR "${BUILD_DIR}" @@ -28,7 +28,7 @@ #cmakedefine HAVE_CMATH 1 /* Define if you have c++ accessible stdint.h */ -#cmakedefine HAVE_CXX_STDINT_H +#cmakedefine PL_HAVE_CXX_STDINT_H /* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'. */ @@ -38,10 +38,10 @@ #cmakedefine HAVE_DLFCN_H 1 /* Define if finite is available */ -#cmakedefine HAVE_FINITE +#cmakedefine PL_HAVE_FINITE /* Define if _finite is available */ -#cmakedefine _HAVE_FINITE +#cmakedefine PL__HAVE_FINITE /* Define if [freetype] is available */ #cmakedefine HAVE_FREETYPE @@ -62,16 +62,16 @@ #cmakedefine HAVE_INTTYPES_H 1 /* Define if isinf is available */ -#cmakedefine HAVE_ISINF +#cmakedefine PL_HAVE_ISINF /* Define if _isinf is available */ -#cmakedefine _HAVE_ISINF +#cmakedefine PL__HAVE_ISINF /* Define if isnan is available */ -#cmakedefine HAVE_ISNAN +#cmakedefine PL_HAVE_ISNAN /* Define if _isnan is available */ -#cmakedefine _HAVE_ISNAN +#cmakedefine PL__HAVE_ISNAN /* Define if snprintf is available */ #ifndef PL_HAVE_SNPRINTF @@ -139,7 +139,7 @@ #cmakedefine HAVE_QHULL /* Define to 1 if you have the <stdint.h> header file. */ -#cmakedefine HAVE_STDINT_H 1 +#cmakedefine PL_HAVE_STDINT_H 1 /* Define to 1 if you have the <stdlib.h> header file. */ #cmakedefine HAVE_STDLIB_H 1 @@ -165,7 +165,7 @@ #cmakedefine HAVE_TERMIOS_H 1 /* Define to 1 if you have the <unistd.h> header file. */ -#cmakedefine HAVE_UNISTD_H 1 +#cmakedefine PL_HAVE_UNISTD_H 1 /* Define if usleep is available */ #cmakedefine PL_HAVE_USLEEP @@ -472,7 +472,7 @@ #define TCL_DIR "${TCL_DIR}" /* Define if C++ compiler accepts using namespace */ -#cmakedefine USE_NAMESPACE +#cmakedefine PL_USE_NAMESPACE /* Version number of package */ #define VERSION "${VERSION}" Modified: trunk/drivers/tk.c =================================================================== --- trunk/drivers/tk.c 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/drivers/tk.c 2009-07-20 21:12:55 UTC (rev 10169) @@ -46,7 +46,7 @@ #include "metadefs.h" #include "plevent.h" -#if HAVE_UNISTD_H +#if PL_HAVE_UNISTD_H # include <unistd.h> #endif #include <sys/types.h> Modified: trunk/examples/c/plcdemos.h =================================================================== --- trunk/examples/c/plcdemos.h 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c/plcdemos.h 2009-07-20 21:12:55 UTC (rev 10169) @@ -39,4 +39,16 @@ #define ROUND(a) (PLINT)((a)<0. ? ((a)-.5) : ((a)+.5)) #endif +/* Add in missing isnan definition if required */ +#if defined(PL__HAVE_ISNAN) +# define isnan _isnan +# if defined(_MSC_VER) +# include <float.h> +# endif +#endif + +#if !defined(PL_HAVE_ISNAN) +# define isnan(x) ((x) != (x)) +#endif + #endif /* __PLCDEMOS_H__ */ Modified: trunk/examples/c/x01c.c =================================================================== --- trunk/examples/c/x01c.c 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c/x01c.c 2009-07-20 21:12:55 UTC (rev 10169) @@ -24,7 +24,7 @@ #include "plcdemos.h" #include "plevent.h" -#ifdef HAVE_UNISTD_H +#ifdef PL_HAVE_UNISTD_H # include <unistd.h> #endif Modified: trunk/examples/c/x17c.c =================================================================== --- trunk/examples/c/x17c.c 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c/x17c.c 2009-07-20 21:12:55 UTC (rev 10169) @@ -5,10 +5,10 @@ #include "plcdemos.h" #include <stdlib.h> -#ifdef HAVE_UNISTD_H +#ifdef PL_HAVE_UNISTD_H # include <unistd.h> #else -# ifdef HAS_POLL +# ifdef PL_HAVE_POLL # include <poll.h> # endif #endif @@ -130,7 +130,7 @@ #ifdef PL_HAVE_USLEEP usleep(10000); /* wait a little (10 ms) to simulate time elapsing */ #else -# ifdef HAS_POLL +# ifdef PL_HAVE_POLL poll(0,0,10); # else { int i; for( i=0; i<1000000; i++ ); } Modified: trunk/examples/c++/plc++demos.h =================================================================== --- trunk/examples/c++/plc++demos.h 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/plc++demos.h 2009-07-20 21:12:55 UTC (rev 10169) @@ -28,4 +28,16 @@ #define ROUND(a) (PLINT)((a)<0. ? ((a)-0.5) : ((a)+0.5)) #endif +/* Add in missing isnan definition if required */ +#if defined(PL__HAVE_ISNAN) +# define isnan _isnan +# if defined(_MSC_VER) +# include <float.h> +# endif +#endif + +#if !defined(PL_HAVE_ISNAN) +# define isnan(x) ((x) != (x)) +#endif + #endif /* __PLCXXDEMOS_H__ */ Modified: trunk/examples/c++/x01.cc =================================================================== --- trunk/examples/c++/x01.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x01.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -31,11 +31,11 @@ #include "plevent.h" #include <cctype> -#ifdef HAVE_UNISTD_H +#ifdef PL_HAVE_UNISTD_H #include <unistd.h> #endif -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x01cc.cc =================================================================== --- trunk/examples/c++/x01cc.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x01cc.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -32,7 +32,7 @@ #include "plc++demos.h" -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x02.cc =================================================================== --- trunk/examples/c++/x02.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x02.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -28,7 +28,7 @@ #include "plc++demos.h" -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x03.cc =================================================================== --- trunk/examples/c++/x03.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x03.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -28,7 +28,7 @@ #include "plc++demos.h" -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x04.cc =================================================================== --- trunk/examples/c++/x04.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x04.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -28,7 +28,7 @@ #include "plc++demos.h" -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x05.cc =================================================================== --- trunk/examples/c++/x05.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x05.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -28,7 +28,7 @@ #include "plc++demos.h" -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x06.cc =================================================================== --- trunk/examples/c++/x06.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x06.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -28,7 +28,7 @@ #include "plc++demos.h" -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x07.cc =================================================================== --- trunk/examples/c++/x07.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x07.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -28,7 +28,7 @@ #include "plc++demos.h" -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x08.cc =================================================================== --- trunk/examples/c++/x08.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x08.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -28,7 +28,7 @@ #include "plc++demos.h" -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x09.cc =================================================================== --- trunk/examples/c++/x09.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x09.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -28,7 +28,7 @@ #include "plc++demos.h" -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x10.cc =================================================================== --- trunk/examples/c++/x10.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x10.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -28,7 +28,7 @@ #include "plc++demos.h" -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x11.cc =================================================================== --- trunk/examples/c++/x11.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x11.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -28,7 +28,7 @@ #include "plc++demos.h" -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x12.cc =================================================================== --- trunk/examples/c++/x12.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x12.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -28,7 +28,7 @@ #include "plc++demos.h" -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x13.cc =================================================================== --- trunk/examples/c++/x13.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x13.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -28,7 +28,7 @@ #include "plc++demos.h" -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x14.cc =================================================================== --- trunk/examples/c++/x14.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x14.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -28,7 +28,7 @@ #include "plc++demos.h" -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x15.cc =================================================================== --- trunk/examples/c++/x15.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x15.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -28,7 +28,7 @@ #include "plc++demos.h" -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x16.cc =================================================================== --- trunk/examples/c++/x16.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x16.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -28,7 +28,7 @@ #include "plc++demos.h" -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x17.cc =================================================================== --- trunk/examples/c++/x17.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x17.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -27,15 +27,15 @@ //---------------------------------------------------------------------------// #include "plc++demos.h" -#ifdef HAVE_UNISTD_H +#ifdef PL_HAVE_UNISTD_H # include <unistd.h> #else -# ifdef HAS_POLL +# ifdef PL_HAVE_POLL # include <poll.h> # endif #endif -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif @@ -153,7 +153,7 @@ #ifdef PL_HAVE_USLEEP usleep(10000); /* wait a little (10 ms) to simulate time elapsing */ #else -# ifdef HAS_POLL +# ifdef PL_HAVE_POLL poll(0,0,10); # else { int i; for( i=0; i<1000000; i++ ); } Modified: trunk/examples/c++/x18.cc =================================================================== --- trunk/examples/c++/x18.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x18.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -28,7 +28,7 @@ #include "plc++demos.h" -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x19.cc =================================================================== --- trunk/examples/c++/x19.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x19.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -28,7 +28,7 @@ #include "plc++demos.h" -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x20.cc =================================================================== --- trunk/examples/c++/x20.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x20.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -30,7 +30,7 @@ #include "plevent.h" #include <fstream> -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x21.cc =================================================================== --- trunk/examples/c++/x21.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x21.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -29,11 +29,11 @@ #include "plc++demos.h" // Need for some Mac OSX systems with broken <cmath> header -#ifdef BROKEN_ISNAN_CXX +#ifdef PL_BROKEN_ISNAN_CXX extern "C" int isnan (double); #endif -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x22.cc =================================================================== --- trunk/examples/c++/x22.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x22.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -28,7 +28,7 @@ #include "plc++demos.h" -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x23.cc =================================================================== --- trunk/examples/c++/x23.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x23.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -29,7 +29,7 @@ #include "plc++demos.h" -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x26.cc =================================================================== --- trunk/examples/c++/x26.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x26.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -64,7 +64,7 @@ #include "plc++demos.h" -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x27.cc =================================================================== --- trunk/examples/c++/x27.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x27.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -1,5 +1,5 @@ //---------------------------------------------------------------------------// -// $Id:$ +// $Id$ // Drawing "spirograph" curves - epitrochoids, cycolids, roulettes //---------------------------------------------------------------------------// // @@ -28,7 +28,7 @@ #include "plc++demos.h" -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x28.cc =================================================================== --- trunk/examples/c++/x28.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x28.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -24,7 +24,7 @@ #include "plc++demos.h" -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x29.cc =================================================================== --- trunk/examples/c++/x29.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x29.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -23,7 +23,7 @@ #include "plc++demos.h" -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x30.cc =================================================================== --- trunk/examples/c++/x30.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x30.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -28,7 +28,7 @@ #include "plc++demos.h" -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/examples/c++/x31.cc =================================================================== --- trunk/examples/c++/x31.cc 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/examples/c++/x31.cc 2009-07-20 21:12:55 UTC (rev 10169) @@ -24,7 +24,7 @@ #include "plc++demos.h" -#ifdef USE_NAMESPACE +#ifdef PL_USE_NAMESPACE using namespace std; #endif Modified: trunk/include/plConfig.h.cmake =================================================================== --- trunk/include/plConfig.h.cmake 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/include/plConfig.h.cmake 2009-07-20 21:12:55 UTC (rev 10169) @@ -41,44 +41,20 @@ # include <config.h> #endif -/* Define if dynamic drivers are enabled.*/ -#cmakedefine ENABLE_DYNDRIVERS +/* Define if you have c++ accessible stdint.h */ +#cmakedefine PL_HAVE_CXX_STDINT_H -/* Define if [incr Tcl] is available */ -#cmakedefine HAVE_ITCL - -/* Define if [incr Tk] is available */ -#cmakedefine HAVE_ITK - -/* Define if [freetype] is available */ -#cmakedefine HAVE_FREETYPE - -/* Define if finite is available */ -#cmakedefine HAVE_FINITE - -/* Define if _finite is available */ -#cmakedefine _HAVE_FINITE - /* Define if isinf is available */ -#cmakedefine HAVE_ISINF +#cmakedefine PL_HAVE_ISNAN /* Define if _isinf is available */ -#cmakedefine _HAVE_ISINF +#cmakedefine PL__HAVE_ISNAN -/* Define if isnan is available */ -#cmakedefine HAVE_ISNAN - -/* Define if _isnan is available */ -#cmakedefine _HAVE_ISNAN - -/* Define if you have c++ accessible stdint.h */ -#cmakedefine HAVE_CXX_STDINT_H - /* Define to 1 if you have the <stdint.h> header file. */ -#cmakedefine HAVE_STDINT_H 1 +#cmakedefine PL_HAVE_STDINT_H 1 /* Define to 1 if you have the <unistd.h> header file. */ -#cmakedefine HAVE_UNISTD_H 1 +#cmakedefine PL_HAVE_UNISTD_H 1 /* Define if usleep is available */ #cmakedefine PL_HAVE_USLEEP @@ -87,13 +63,10 @@ #cmakedefine PL_DOUBLE /* Define if C++ compiler accepts using namespace */ -#cmakedefine USE_NAMESPACE +#cmakedefine PL_USE_NAMESPACE -/* Define to 1 if <cmath> header file is available */ -#cmakedefine HAVE_CMATH 1 - /* Define if isnan is present in <math.h> but not in <cmath> * - broken Mac OSX systems */ -#cmakedefine BROKEN_ISNAN_CXX +#cmakedefine PL_BROKEN_ISNAN_CXX #endif /* __PLCONFIG_H__ */ Modified: trunk/include/plplot.h =================================================================== --- trunk/include/plplot.h 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/include/plplot.h 2009-07-20 21:12:55 UTC (rev 10169) @@ -154,8 +154,8 @@ #define PLFLT_MIN FLT_MIN #endif -#if (defined(HAVE_STDINT_H) && !defined(__cplusplus)) ||\ -(defined(__cplusplus) && defined(HAVE_CXX_STDINT_H)) +#if (defined(PL_HAVE_STDINT_H) && !defined(__cplusplus)) ||\ +(defined(__cplusplus) && defined(PL_HAVE_CXX_STDINT_H)) #include <stdint.h> /* This is apparently portable if stdint.h exists. */ typedef uint32_t PLUINT; @@ -195,42 +195,6 @@ typedef void* PLPointer; /*--------------------------------------------------------------------------*\ - * Add in missing isnan / isinf functions on some platforms -\*--------------------------------------------------------------------------*/ - -#if defined(_HAVE_ISNAN) -# define isnan _isnan -# if defined(_MSC_VER) -# include <float.h> -# endif -#endif -#if defined(_HAVE_ISINF) -# define isinf _isinf -#endif -#if defined(_HAVE_FINITE) -# define finite _finite -#endif - -/* Note these replacements follow the old BSD convention and not - * C99. In particular isinf does not distinguish +/- inf. */ -#if !defined(HAVE_ISNAN) -# define isnan(x) ((x) != (x)) -#endif -#if !defined(HAVE_ISINF) -# define isinf(x) (!isnan(x) && isnan(x-x)) -#endif -#if !defined(HAVE_FINITE) -# define finite(x) (!isnan(x-x)) -#endif - -/* Check if C99 HUGE_VAL macro is available - if not then - * define a replacement */ -#ifndef HUGE_VAL -#define HUGE_VAL (1.0/0.0) -#endif - - -/*--------------------------------------------------------------------------*\ * Complex data types and other good stuff \*--------------------------------------------------------------------------*/ Modified: trunk/include/plplotP.h =================================================================== --- trunk/include/plplotP.h 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/include/plplotP.h 2009-07-20 21:12:55 UTC (rev 10169) @@ -241,6 +241,41 @@ #endif /* PL_HAVE_SNPRINTF */ /*--------------------------------------------------------------------------*\ + * Add in missing isnan / isinf functions on some platforms +\*--------------------------------------------------------------------------*/ + +#if defined(PL__HAVE_ISNAN) +# define isnan _isnan +# if defined(_MSC_VER) +# include <float.h> +# endif +#endif +#if defined(PL__HAVE_ISINF) +# define isinf _isinf +#endif +#if defined(PL__HAVE_FINITE) +# define finite _finite +#endif + +/* Note these replacements follow the old BSD convention and not + * C99. In particular isinf does not distinguish +/- inf. */ +#if !defined(PL_HAVE_ISNAN) +# define isnan(x) ((x) != (x)) +#endif +#if !defined(PL_HAVE_ISINF) +# define isinf(x) (!isnan(x) && isnan(x-x)) +#endif +#if !defined(PL_HAVE_FINITE) +# define finite(x) (!isnan(x-x)) +#endif + +/* Check if C99 HUGE_VAL macro is available - if not then + * define a replacement */ +#ifndef HUGE_VAL +#define HUGE_VAL (1.0/0.0) +#endif + +/*--------------------------------------------------------------------------*\ * PLPLOT control macros \*--------------------------------------------------------------------------*/ Modified: trunk/src/plctrl.c =================================================================== --- trunk/src/plctrl.c 2009-07-20 19:46:03 UTC (rev 10168) +++ trunk/src/plctrl.c 2009-07-20 21:12:55 UTC (rev 10169) @@ -44,7 +44,7 @@ #ifdef __unix #include <sys/types.h> #include <sys/stat.h> -#ifdef HAVE_UNISTD_H +#ifdef PL_HAVE_UNISTD_H #include <unistd.h> #endif #include <errno.h> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-07-30 20:14:12
|
Revision: 10192 http://plplot.svn.sourceforge.net/plplot/?rev=10192&view=rev Author: airwin Date: 2009-07-30 20:13:58 +0000 (Thu, 30 Jul 2009) Log Message: ----------- AWI for Alban Rochel. Allow changes to the background colors and background transparency. Modified Paths: -------------- trunk/bindings/qt_gui/plqt.cpp trunk/drivers/qt.cpp trunk/include/qt.h Modified: trunk/bindings/qt_gui/plqt.cpp =================================================================== --- trunk/bindings/qt_gui/plqt.cpp 2009-07-30 20:12:09 UTC (rev 10191) +++ trunk/bindings/qt_gui/plqt.cpp 2009-07-30 20:13:58 UTC (rev 10192) @@ -408,7 +408,7 @@ m_painterP->setRenderHint(QPainter::Antialiasing, true); // Let's fill the background - m_painterP->fillRect(0, 0, width(), height(), QBrush(Qt::black)); +// m_painterP->fillRect(0, 0, width(), height(), QBrush(Qt::black)); // fontScalingFactor=1.; } @@ -437,8 +437,16 @@ QBrush b=m_painterP->brush(); b.setStyle(Qt::SolidPattern); m_painterP->setBrush(b); - m_painterP->fillRect(0, 0, width(), height(), QBrush(Qt::black)); +// m_painterP->fillRect(0, 0, width(), height(), QBrush(Qt::black)); } + +void QtRasterDevice::setBackgroundColor(int r, int g, int b, double alpha) +{ + if(!m_painterP->isActive()) return; + + QBrush brush(QColor(r, g, b, (int)(alpha*255))); + m_painterP->fillRect(0, 0, width(), height(), brush); +} #endif #if defined(PLD_svgqt) && QT_VERSION >= 0x040300 @@ -465,13 +473,21 @@ #endif m_painterP=new QPainter(this); - m_painterP->fillRect(0, 0, (int)m_dWidth, (int)m_dHeight, QBrush(Qt::black)); +// m_painterP->fillRect(0, 0, (int)m_dWidth, (int)m_dHeight, QBrush(Qt::black)); } void QtSVGDevice::savePlot() { m_painterP->end(); } + +void QtSVGDevice::setBackgroundColor(int r, int g, int b, double alpha) +{ + if(!m_painterP->isActive()) return; + + QBrush brush(QColor(r, g, b, (int)(alpha*255))); + m_painterP->fillRect(0, 0, width(), height(), brush); +} #endif #if defined (PLD_epsqt) || defined(PLD_pdfqt) @@ -521,13 +537,21 @@ } m_painterP=new QPainter(this); - m_painterP->fillRect(0, 0, (int)m_dWidth, (int)m_dHeight, QBrush(Qt::black)); +// m_painterP->fillRect(0, 0, (int)m_dWidth, (int)m_dHeight, QBrush(Qt::black)); } void QtEPSDevice::savePlot() { m_painterP->end(); } + +void QtEPSDevice::setBackgroundColor(int r, int g, int b, double alpha) +{ + if(!m_painterP->isActive()) return; + + QBrush brush(QColor(r, g, b, (int)(alpha*255))); + m_painterP->fillRect(0, 0, width(), height(), brush); +} #endif #if defined (PLD_qtwidget) || defined(PLD_extqt) @@ -577,6 +601,10 @@ case SET_COLOUR: delete i->Data.ColourStruct; break; + + case SET_BG_COLOUR: + delete i->Data.ColourStruct; + break; case TEXT: delete[] i->Data.TextStruct->text; @@ -650,6 +678,19 @@ m_listBuffer.append(el); } +void QtPLWidget::setBackgroundColor(int r, int g, int b, double alpha) +{ + BufferElement el; + el.Element=SET_BG_COLOUR; + el.Data.ColourStruct=new struct ColourStruct_; + el.Data.ColourStruct->R=r; + el.Data.ColourStruct->G=g; + el.Data.ColourStruct->B=b; + el.Data.ColourStruct->A=alpha*255.; + + m_listBuffer.append(el); +} + void QtPLWidget::setSolid() { BufferElement el; @@ -804,7 +845,7 @@ // Draw the margins and the background painter->fillRect(0, 0, width(), height(), QBrush(Qt::white)); painter->fillRect(0, 0, width(), height(), QBrush(Qt::gray, Qt::Dense4Pattern)); - painter->fillRect((int)x_offset, (int)y_offset, (int)floor(x_fact*m_dWidth+0.5), (int)floor(y_fact*m_dHeight+0.5), QBrush(Qt::black)); +// painter->fillRect((int)x_offset, (int)y_offset, (int)floor(x_fact*m_dWidth+0.5), (int)floor(y_fact*m_dHeight+0.5), QBrush(Qt::black)); // Draw the plot doPlot(painter, x_fact, y_fact, x_offset, y_offset); @@ -891,6 +932,11 @@ p->setBrush(brush); break; + case SET_BG_COLOUR: + brush.setColor(QColor(i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A)); + p->fillRect((int)x_offset, (int)y_offset, (int)floor(x_fact*m_dWidth+0.5), (int)floor(y_fact*m_dHeight+0.5), brush); + break; + case SET_SOLID: pen.setStyle(Qt::SolidLine); p->setPen(pen); Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2009-07-30 20:12:09 UTC (rev 10191) +++ trunk/drivers/qt.cpp 2009-07-30 20:13:58 UTC (rev 10192) @@ -214,6 +214,7 @@ void plD_tidy_qtwidget(PLStream *); void plD_state_qtwidget(PLStream *, PLINT); void plD_esc_qtwidget(PLStream *, PLINT, void*); +void plD_bop_qtwidget(PLStream *); #endif #if defined(PLD_extqt) @@ -225,12 +226,9 @@ void plD_tidy_extqt(PLStream *); void plD_state_extqt(PLStream *, PLINT); void plD_esc_extqt(PLStream *, PLINT, void*); +void plD_bop_extqt(PLStream *); #endif -// Declaration of the generic interface functions - -void plD_bop_qt(PLStream *){} - ////////////////// Raster driver-specific definitions: class and interface functions ///////// #if defined (PLD_bmpqt) || defined(PLD_jpgqt) || defined (PLD_pngqt) || defined(PLD_ppmqt) || defined(PLD_tiffqt) void plD_init_rasterqt(PLStream * pls) @@ -437,6 +435,7 @@ pls->page++; if(qt_family_check(pls)) {return;} ((QtRasterDevice *)pls->dev)->definePlotName(pls->FileName, "BMP"); + ((QtRasterDevice *)pls->dev)->setBackgroundColor(pls->cmap0[0].r, pls->cmap0[0].g, pls->cmap0[0].b, pls->cmap0[0].a); } #endif @@ -468,6 +467,7 @@ pls->page++; if(qt_family_check(pls)) {return;} ((QtRasterDevice *)pls->dev)->definePlotName(pls->FileName, "JPG"); + ((QtRasterDevice *)pls->dev)->setBackgroundColor(pls->cmap0[0].r, pls->cmap0[0].g, pls->cmap0[0].b, pls->cmap0[0].a); } #endif @@ -499,6 +499,7 @@ pls->page++; if(qt_family_check(pls)) {return;} ((QtRasterDevice *)pls->dev)->definePlotName(pls->FileName, "PNG"); + ((QtRasterDevice *)pls->dev)->setBackgroundColor(pls->cmap0[0].r, pls->cmap0[0].g, pls->cmap0[0].b, pls->cmap0[0].a); } #endif @@ -530,6 +531,7 @@ pls->page++; if(qt_family_check(pls)) {return;} ((QtRasterDevice *)pls->dev)->definePlotName(pls->FileName, "PPM"); + ((QtRasterDevice *)pls->dev)->setBackgroundColor(pls->cmap0[0].r, pls->cmap0[0].g, pls->cmap0[0].b, pls->cmap0[0].a); } #endif @@ -561,6 +563,7 @@ pls->page++; if(qt_family_check(pls)) {return;} ((QtRasterDevice *)pls->dev)->definePlotName(pls->FileName, "TIFF"); + ((QtRasterDevice *)pls->dev)->setBackgroundColor(pls->cmap0[0].r, pls->cmap0[0].g, pls->cmap0[0].b, pls->cmap0[0].a); } #endif @@ -645,6 +648,7 @@ pls->page++; if(qt_family_check(pls)) {return;} ((QtSVGDevice *)pls->dev)->definePlotName(pls->FileName); + ((QtSVGDevice *)pls->dev)->setBackgroundColor(pls->cmap0[0].r, pls->cmap0[0].g, pls->cmap0[0].b, pls->cmap0[0].a); } void plD_eop_svgqt(PLStream *pls) @@ -875,6 +879,7 @@ pls->page++; if(qt_family_check(pls)) {return;} ((QtEPSDevice *)pls->dev)->definePlotName(pls->FileName, ifeps); + ((QtEPSDevice *)pls->dev)->setBackgroundColor(pls->cmap0[0].r, pls->cmap0[0].g, pls->cmap0[0].b, pls->cmap0[0].a); } void plD_eop_epspdfqt(PLStream *pls) @@ -1029,7 +1034,7 @@ pdt->pl_line = (plD_line_fp) plD_line_qtwidget; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qtwidget; pdt->pl_eop = (plD_eop_fp) plD_eop_qtwidget; - pdt->pl_bop = (plD_bop_fp) plD_bop_qt; + pdt->pl_bop = (plD_bop_fp) plD_bop_qtwidget; pdt->pl_tidy = (plD_tidy_fp) plD_tidy_qtwidget; pdt->pl_state = (plD_state_fp) plD_state_qtwidget; pdt->pl_esc = (plD_esc_fp) plD_esc_qtwidget; @@ -1105,6 +1110,12 @@ } } +void plD_bop_qtwidget(PLStream *pls) +{ + QtPLWidget* widget=((QtPLWidget*)pls->dev); + widget->setBackgroundColor(pls->cmap0[0].r, pls->cmap0[0].g, pls->cmap0[0].b, pls->cmap0[0].a); +} + void plD_line_qtwidget(PLStream * pls, short x1a, short y1a, short x2a, short y2a) { QtPLWidget* widget=(QtPLWidget*)pls->dev; @@ -1218,7 +1229,7 @@ pdt->pl_line = (plD_line_fp) plD_line_extqt; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_extqt; pdt->pl_eop = (plD_eop_fp) plD_eop_extqt; - pdt->pl_bop = (plD_bop_fp) plD_bop_qt; + pdt->pl_bop = (plD_bop_fp) plD_bop_extqt; pdt->pl_tidy = (plD_tidy_fp) plD_tidy_extqt; pdt->pl_state = (plD_state_fp) plD_state_extqt; pdt->pl_esc = (plD_esc_fp) plD_esc_extqt; @@ -1374,4 +1385,11 @@ void plD_eop_extqt(PLStream *pls) { } + +void plD_bop_extqt(PLStream *pls) +{ + QtExtWidget * widget=NULL; + widget=(QtExtWidget*)pls->dev; + widget->setBackgroundColor(pls->cmap0[0].r, pls->cmap0[0].g, pls->cmap0[0].b, pls->cmap0[0].a); +} #endif Modified: trunk/include/qt.h =================================================================== --- trunk/include/qt.h 2009-07-30 20:12:09 UTC (rev 10191) +++ trunk/include/qt.h 2009-07-30 20:13:58 UTC (rev 10192) @@ -136,6 +136,8 @@ virtual void setColor(int r, int g, int b, double alpha); + virtual void setBackgroundColor(int r, int g, int b, double alpha){} + virtual void setWidth(PLINT w); virtual void setDashed(PLINT nms, PLINT* mark, PLINT* space); @@ -180,6 +182,8 @@ int i_iHeight=QT_DEFAULT_Y); virtual ~QtRasterDevice(); + + virtual void setBackgroundColor(int r, int g, int b, double alpha); void definePlotName(const char* fileName, const char* format); @@ -209,6 +213,8 @@ virtual ~QtSVGDevice(); + virtual void setBackgroundColor(int r, int g, int b, double alpha); + void definePlotName(const char* fileName); void savePlot(); @@ -229,7 +235,9 @@ #endif virtual ~QtEPSDevice(); - + + virtual void setBackgroundColor(int r, int g, int b, double alpha); + void definePlotName(const char* fileName, int ifeps); void savePlot(); @@ -249,7 +257,8 @@ SET_WIDTH, SET_COLOUR, SET_SOLID, - TEXT + TEXT, + SET_BG_COLOUR } ElementType; // Identifiers for elements of the buffer struct LineStruct_ @@ -333,6 +342,7 @@ void drawPolyline(short * x, short * y, PLINT npts); void drawPolygon(short * x, short * y, PLINT npts); void setColor(int r, int g, int b, double alpha); + void setBackgroundColor(int r, int g, int b, double alpha); void setWidth(PLINT r); void setSolid(); void drawText(PLStream* pls, EscText* txt); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-07-31 18:08:12
|
Revision: 10195 http://plplot.svn.sourceforge.net/plplot/?rev=10195&view=rev Author: airwin Date: 2009-07-31 18:07:55 +0000 (Fri, 31 Jul 2009) Log Message: ----------- AWI for Alban Rochel. - Fix background issue (undefined background for first plot attempt) for qt_example. - Some code cleanup, but without any whitespace changes for now. (Those will be done in a followup commit). - QtWidget and ExtQt plot faster (1), especially when plotting x/y rectangular filled shapes (2). Example x20c is now *much* faster. This fairly extensive change has been tested for Qt4.5.1 by building, running, and looking at every standard example for all non-interactive qt devices and by running "make test_interactive". The results (except for the known example 17 issue for -dev qtwidget) look good. Modified Paths: -------------- trunk/bindings/qt_gui/plqt.cpp trunk/drivers/qt.cpp trunk/examples/c++/qt_PlotWindow.cpp trunk/include/qt.h Modified: trunk/bindings/qt_gui/plqt.cpp =================================================================== --- trunk/bindings/qt_gui/plqt.cpp 2009-07-31 15:37:43 UTC (rev 10194) +++ trunk/bindings/qt_gui/plqt.cpp 2009-07-31 18:07:55 UTC (rev 10195) @@ -136,18 +136,16 @@ f.setPointSizeF(currentFontSize*currentFontScale<4 ? 4 : currentFontSize*currentFontScale); - switch(fontFamily) { + switch(fontFamily) + { case 1: f.setStyleHint(QFont::Serif); -// f.setFamily("Times"); break; case 2: f.setStyleHint(QFont::TypeWriter); -// f.setFamily("Courier"); break; case 0: case 3: case 4:default: f.setStyleHint(QFont::SansSerif); -// f.setFamily("Helvetica"); break; } f.setFamily(""); // no family name, forcing Qt to find an appropriate font by itself @@ -164,8 +162,6 @@ void QtPLDriver::drawTextInPicture(QPainter* p, const QString& text) { -// if(!m_painterP->isActive()) return; - QRectF rect(0., 0., 0., 0.); QRectF bounding; QPicture tempPic; @@ -176,9 +172,9 @@ { bounding=tempPainter.boundingRect(rect, Qt::AlignHCenter|Qt::AlignVCenter|Qt::TextDontClip, text); - QPen savePen=tempPainter.pen(); - QPen pen=savePen; - pen.setStyle(Qt::NoPen); + tempPainter.save(); +// QPen savePen=tempPainter.pen(); + QPen pen=QPen(Qt::NoPen); tempPainter.setPen(pen); double offset=QFontMetrics(tempPainter.font(), &tempPic).boundingRect(text).top(); // Distance between the baseline and the top of the bounding box @@ -186,7 +182,7 @@ QPainterPath path; path.addText(QPointF(bounding.left(), bounding.top()-offset), tempPainter.font(), text); tempPainter.drawPath(path); - tempPainter.setPen(pen); + tempPainter.restore(); } else { @@ -242,30 +238,39 @@ { case 'd': drawTextInPicture(&p, currentString); - currentString.clear(); old_fontScale=currentFontScale; - if( yOffset>0.0 ) + if( yOffset>-0.000000000001 ) // I've already encountered precision issues here, so changed 0 into -epsilon + { currentFontScale *= 1.25; /* Subscript scaling parameter */ + } else + { currentFontScale *= 0.8; /* Subscript scaling parameter */ + } yOffset -= currentFontSize * old_fontScale / 2.; p.setFont(getFont(fci)); break; + case 'u': drawTextInPicture(&p, currentString); currentString.clear(); - if( yOffset<0.0 ) + if( yOffset<-0.000000000001 ) + { currentFontScale *= 1.25; /* Subscript scaling parameter */ + } else + { currentFontScale *= 0.8; /* Subscript scaling parameter */ + } yOffset += currentFontSize * currentFontScale / 2.; p.setFont(getFont(fci)); break; + case '-': drawTextInPicture(&p, currentString); @@ -273,6 +278,7 @@ underlined=!underlined; p.setFont(getFont(fci)); break; + case '+': drawTextInPicture(&p, currentString); @@ -280,9 +286,12 @@ overlined=!overlined; p.setFont(getFont(fci)); break; + + case '#': currentString.append(QString((QChar*)&(text[i]), 1)); break; + default : std::cout << "unknown escape char " << ((QChar)text[i]).toLatin1() << std::endl; break; @@ -309,13 +318,15 @@ if(!m_painterP->isActive()) return; /* Check that we got unicode, warning message and return if not */ - if( txt->unicode_array_len == 0 ) { + if( txt->unicode_array_len == 0 ) + { printf( "Non unicode string passed to a Qt driver, ignoring\n" ); return; } /* Check that unicode string isn't longer then the max we allow */ - if( txt->unicode_array_len >= 500 ) { + if( txt->unicode_array_len >= 500 ) + { printf( "Sorry, the Qt drivers only handle strings of length < %d\n", 500 ); return; } @@ -342,7 +353,7 @@ m_painterP->drawPicture(0, 0, picText); - m_painterP->setWorldMatrix(QMatrix()); + m_painterP->resetTransform();; m_painterP->setClipping(false); } @@ -369,21 +380,21 @@ m_painterP->setPen(p); } -void QtPLDriver::setDashed(PLINT nms, PLINT* mark, PLINT* space) -{ - if(!m_painterP->isActive()) return; +// void QtPLDriver::setDashed(PLINT nms, PLINT* mark, PLINT* space) +// { +// if(!m_painterP->isActive()) return; +// +// QVector<qreal> vect; +// for(int i=0; i<nms; ++i) +// { +// vect << (PLFLT)mark[i]*m_painterP->device()->logicalDpiX()/25400.; +// vect << (PLFLT)space[i]*m_painterP->device()->logicalDpiX()/25400.; +// } +// QPen p=m_painterP->pen(); +// p.setDashPattern(vect); +// m_painterP->setPen(p); +// } - QVector<qreal> vect; - for(int i=0; i<nms; ++i) - { - vect << (PLFLT)mark[i]*m_painterP->device()->logicalDpiX()/25400.; - vect << (PLFLT)space[i]*m_painterP->device()->logicalDpiX()/25400.; - } - QPen p=m_painterP->pen(); - p.setDashPattern(vect); - m_painterP->setPen(p); -} - void QtPLDriver::setSolid() { if(!m_painterP->isActive()) return; @@ -406,11 +417,6 @@ b.setStyle(Qt::SolidPattern); m_painterP->setBrush(b); m_painterP->setRenderHint(QPainter::Antialiasing, true); - - // Let's fill the background -// m_painterP->fillRect(0, 0, width(), height(), QBrush(Qt::black)); - -// fontScalingFactor=1.; } QtRasterDevice::~QtRasterDevice() @@ -437,7 +443,6 @@ QBrush b=m_painterP->brush(); b.setStyle(Qt::SolidPattern); m_painterP->setBrush(b); -// m_painterP->fillRect(0, 0, width(), height(), QBrush(Qt::black)); } void QtRasterDevice::setBackgroundColor(int r, int g, int b, double alpha) @@ -454,8 +459,6 @@ QtPLDriver(i_iWidth, i_iHeight) { m_painterP=NULL; - -// fontScalingFactor=1.; } QtSVGDevice::~QtSVGDevice() @@ -473,7 +476,6 @@ #endif m_painterP=new QPainter(this); -// m_painterP->fillRect(0, 0, (int)m_dWidth, (int)m_dHeight, QBrush(Qt::black)); } void QtSVGDevice::savePlot() @@ -515,8 +517,6 @@ m_dHeight=i_iHeight; } m_painterP=NULL; - -// fontScalingFactor=1.; } QtEPSDevice::~QtEPSDevice() @@ -537,7 +537,6 @@ } m_painterP=new QPainter(this); -// m_painterP->fillRect(0, 0, (int)m_dWidth, (int)m_dHeight, QBrush(Qt::black)); } void QtEPSDevice::savePlot() @@ -566,6 +565,7 @@ m_iOldSize=0; pageNumber=0; resize(i_iWidth, i_iHeight); + lastColour.r=-1; } QtPLWidget::~QtPLWidget() @@ -583,33 +583,33 @@ void QtPLWidget::clearBuffer() { + lastColour.r=-1; for(QLinkedList<BufferElement>::iterator i=m_listBuffer.begin(); i!=m_listBuffer.end(); ++i) { switch(i->Element) { + case LINE: + delete i->Data.Line; + break; + case RECTANGLE: + delete i->Data.Rect; + break; + case POLYLINE: case POLYGON: - delete[] i->Data.PolylineStruct->x; - delete[] i->Data.PolylineStruct->y; - delete i->Data.PolylineStruct; + delete i->Data.Polyline; break; - case LINE: - delete i->Data.LineStruct; + case TEXT: + delete[] i->Data.TextStruct->text; + delete i->Data.TextStruct; break; case SET_COLOUR: - delete i->Data.ColourStruct; - break; - case SET_BG_COLOUR: delete i->Data.ColourStruct; break; - case TEXT: - delete[] i->Data.TextStruct->text; - delete i->Data.TextStruct; - break; default: break; } @@ -622,11 +622,7 @@ { BufferElement el; el.Element=LINE; - el.Data.LineStruct=new struct LineStruct_; - el.Data.LineStruct->x1=(PLFLT)x1*downscale; - el.Data.LineStruct->y1=m_dHeight-(PLFLT)y1*downscale; - el.Data.LineStruct->x2=(PLFLT)x2*downscale; - el.Data.LineStruct->y2=m_dHeight-(PLFLT)y2*downscale; + el.Data.Line=new QLineF(QPointF((PLFLT)x1*downscale, (PLFLT)(m_dHeight-y1*downscale)), QPointF((PLFLT)x2*downscale, (PLFLT)(m_dHeight-y2*downscale))); m_listBuffer.append(el); } @@ -635,14 +631,10 @@ { BufferElement el; el.Element=POLYLINE; - el.Data.PolylineStruct=new struct PolylineStruct_; - el.Data.PolylineStruct->npts=(PLINT)npts; - el.Data.PolylineStruct->x=new PLFLT[npts]; - el.Data.PolylineStruct->y=new PLFLT[npts]; + el.Data.Polyline=new QPolygonF; for(int i=0; i<npts; ++i) { - el.Data.PolylineStruct->x[i]=(PLFLT)x[i]*downscale; - el.Data.PolylineStruct->y[i]=m_dHeight-(PLFLT)y[i]*downscale; + (*el.Data.Polyline) << QPointF((PLFLT)(x[i])*downscale, (PLFLT)(m_dHeight-(y[i])*downscale)); } m_listBuffer.append(el); @@ -651,22 +643,82 @@ void QtPLWidget::drawPolygon(short * x, short * y, PLINT npts) { BufferElement el; + + bool isRect=false; + if(npts==4) // Check if it's a rectangle. If so, it can be made faster to display + { + if(x[0]==x[1] && x[2]==x[3] && y[0]==y[3] && y[1]==y[2]) + { + isRect=true; + } + else if(x[0]==x[3] && x[1]==x[2] && y[0]==y[1] && y[2]==y[3]) + { + isRect=true; + } + } + if(npts==5) + { + if(x[0]==x[4] && y[0]==y[4]) + { + if(x[0]==x[1] && x[2]==x[3] && y[0]==y[3] && y[1]==y[2]) + { + isRect=true; + } + else if(x[0]==x[3] && x[1]==x[2] && y[0]==y[1] && y[2]==y[3]) + { + isRect=true; + } + } + } + + if(isRect) + { + el.Element=RECTANGLE; + + double x1, y1, x2, y2, x0, y0, width, height; + x1=(PLFLT)(x[0])*downscale; + x2=(PLFLT)(x[2])*downscale; + y1=(PLFLT)(m_dHeight-(y[0])*downscale); + y2=(PLFLT)(m_dHeight-(y[2])*downscale); + if(x1<x2) + { + x0=x1; + width=x2-x1; + } + else + { + x0=x2; + width=x1-x2; + } + if(y1<y2) + { + y0=y1; + height=y2-y1; + } + else + { + y0=y2; + height=y1-y2; + } + el.Data.Rect=new QRectF(x0, y0, width, height); + } + else + { el.Element=POLYGON; - el.Data.PolylineStruct=new struct PolylineStruct_; - el.Data.PolylineStruct->npts=(PLINT)npts; - el.Data.PolylineStruct->x=new PLFLT[npts]; - el.Data.PolylineStruct->y=new PLFLT[npts]; + el.Data.Polyline=new QPolygonF; for(int i=0; i<npts; ++i) { - el.Data.PolylineStruct->x[i]=(PLFLT)x[i]*downscale; - el.Data.PolylineStruct->y[i]=m_dHeight-(PLFLT)y[i]*downscale; + (*el.Data.Polyline) << QPointF((PLFLT)(x[i])*downscale, (PLFLT)(m_dHeight-(y[i])*downscale)); } + } m_listBuffer.append(el); } void QtPLWidget::setColor(int r, int g, int b, double alpha) { + if(lastColour.r!=r || lastColour.g!=g || lastColour.b!=b || lastColour.alpha!=alpha) + { BufferElement el; el.Element=SET_COLOUR; el.Data.ColourStruct=new struct ColourStruct_; @@ -676,7 +728,13 @@ el.Data.ColourStruct->A=alpha*255.; m_listBuffer.append(el); + + lastColour.r=r; + lastColour.g=g; + lastColour.b=b; + lastColour.alpha=alpha; } +} void QtPLWidget::setBackgroundColor(int r, int g, int b, double alpha) { @@ -691,13 +749,6 @@ m_listBuffer.append(el); } -void QtPLWidget::setSolid() -{ - BufferElement el; - el.Element=SET_SOLID; - m_listBuffer.append(el); -} - void QtPLWidget::setWidth(PLINT w) { BufferElement el; @@ -733,45 +784,8 @@ el.Data.TextStruct->chrht=pls->chrht; m_listBuffer.append(el); - } -void QtPLWidget::drawTextInPicture(QPainter* p, const QString& text) -{ - QRectF rect(0., 0., 0., 0.); - QRectF bounding; - QPicture tempPic; - QPainter tempPainter(&tempPic); - tempPainter.setFont(p->font()); - - if(vectorize) - { - bounding=tempPainter.boundingRect(rect, Qt::AlignHCenter|Qt::AlignVCenter|Qt::TextDontClip, text); - - QPen savePen=tempPainter.pen(); - QPen pen=savePen; - pen.setStyle(Qt::NoPen); - tempPainter.setPen(pen); - - double offset=QFontMetrics(tempPainter.font(), &tempPic).boundingRect(text).top(); // Distance between the baseline and the top of the bounding box - - QPainterPath path; - path.addText(QPointF(bounding.left(), bounding.top()-offset), tempPainter.font(), text); - tempPainter.drawPath(path); - tempPainter.setPen(pen); - } - else - { - tempPainter.drawText(rect, Qt::AlignHCenter|Qt::AlignVCenter|Qt::TextDontClip, text, &bounding); - - } - - tempPainter.end(); - - p->drawPicture((int)(xOffset+bounding.width()/2.), -yOffset, tempPic); - xOffset+=bounding.width(); -} - void QtPLWidget::renderText(QPainter* p, struct TextStruct_* s, double x_fact, double x_offset, double y_fact, double y_offset) { if(s->len<=0 || s->len>=500) return; @@ -781,7 +795,6 @@ p->setClipping(true); p->setClipRect(QRectF(s->clipxmin*x_fact+x_offset, s->clipymax*y_fact+y_offset, (s->clipxmax-s->clipxmin)*x_fact, (-s->clipymax+s->clipymin)*y_fact), Qt::ReplaceClip); - p->translate(s->x*x_fact+x_offset, s->y*y_fact+y_offset); QMatrix rotShearMatrix(cos(s->rotation)*s->stride, -sin(s->rotation)*s->stride, cos(s->rotation)*sin(s->shear)+sin(s->rotation)*cos(s->shear), -sin(s->rotation)*sin(s->shear)+cos(s->rotation)*cos(s->shear), 0.,0.); p->setWorldMatrix(rotShearMatrix, true); @@ -790,7 +803,7 @@ p->drawPicture(0., 0., picText); - p->setWorldMatrix(QMatrix()); + p->resetTransform(); p->setClipping(false); } @@ -845,7 +858,6 @@ // Draw the margins and the background painter->fillRect(0, 0, width(), height(), QBrush(Qt::white)); painter->fillRect(0, 0, width(), height(), QBrush(Qt::gray, Qt::Dense4Pattern)); -// painter->fillRect((int)x_offset, (int)y_offset, (int)floor(x_fact*m_dWidth+0.5), (int)floor(y_fact*m_dHeight+0.5), QBrush(Qt::black)); // Draw the plot doPlot(painter, x_fact, y_fact, x_offset, y_offset); @@ -871,15 +883,29 @@ QPointF * polyline; PLINT npts; QVector<qreal> vect; - QPen pen=p->pen(); - QBrush brush=p->brush(); - brush.setStyle(Qt::SolidPattern); - p->setBrush(brush); + QRectF rect; + + QPen SolidPen; + + QPen NoPen(Qt::NoPen); + NoPen.setWidthF(0.); // Cosmetic pen + p->setPen(SolidPen); + bool hasPen=true; + p->setRenderHints(QPainter::Antialiasing, true); + QBrush SolidBrush(Qt::SolidPattern); + p->setBrush(SolidBrush); + + QTransform trans; + trans=trans.translate(x_offset, y_offset); + trans=trans.scale(x_fact, y_fact); + + p->setTransform(trans); + if(m_listBuffer.empty()) { - p->fillRect(0, 0, (int)(x_fact+2.*x_offset), (int)(y_fact+2.*y_offset), QBrush()); + p->fillRect(0, 0, 1, 1, QBrush()); return; } // unrolls the buffer and draws each element accordingly @@ -888,60 +914,81 @@ switch(i->Element) { case LINE: - line=QLineF(i->Data.LineStruct->x1*x_fact+x_offset, i->Data.LineStruct->y1*y_fact+y_offset, i->Data.LineStruct->x2*x_fact+x_offset, i->Data.LineStruct->y2*y_fact+y_offset); - p->drawLine(line); + if(!hasPen) + { + p->setPen(SolidPen); + hasPen=true; + } + p->drawLine(*(i->Data.Line)); break; case POLYLINE: - npts=i->Data.PolylineStruct->npts; - polyline=new QPointF[npts]; - for(int j=0; j<npts; ++j) + if(!hasPen) { - polyline[j].setX(i->Data.PolylineStruct->x[j]*x_fact+x_offset); - polyline[j].setY(i->Data.PolylineStruct->y[j]*y_fact+y_offset); + p->setPen(SolidPen); + hasPen=true; } - p->drawPolyline(polyline, npts); - delete[] polyline; + p->drawPolyline(*(i->Data.Polyline)); break; + case RECTANGLE: + p->setRenderHints(QPainter::Antialiasing, false); + if(hasPen) + { + p->setPen(NoPen); + hasPen=false; + } + p->drawRect(*(i->Data.Rect)); + p->setRenderHints(QPainter::Antialiasing, true); + break; + case POLYGON: - npts=i->Data.PolylineStruct->npts; - polyline=new QPointF[npts]; - for(int j=0; j<npts; ++j) + p->setRenderHints(QPainter::Antialiasing, false); + if(hasPen) { - polyline[j].setX(i->Data.PolylineStruct->x[j]*x_fact+x_offset); - polyline[j].setY(i->Data.PolylineStruct->y[j]*y_fact+y_offset); + p->setPen(NoPen); + hasPen=false; } - p->drawPolygon(polyline, npts); - delete[] polyline; + p->drawConvexPolygon(*(i->Data.Polyline)); + p->setRenderHints(QPainter::Antialiasing, true); break; case TEXT: + if(!hasPen) + { + p->setPen(SolidPen); + hasPen=true; + } + p->save(); + p->resetTransform(); + renderText(p, i->Data.TextStruct, x_fact, x_offset, y_fact, y_offset); + p->restore(); break; case SET_WIDTH: - pen.setWidth(i->Data.intParam); - p->setPen(pen); + SolidPen.setWidthF(i->Data.intParam); + if(hasPen) + { + p->setPen(SolidPen); + } break; case SET_COLOUR: - pen.setColor(QColor(i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A)); - p->setPen(pen); - brush.setColor(QColor(i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A)); - p->setBrush(brush); + SolidPen.setColor(QColor(i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A)); + if(hasPen) + { + p->setPen(SolidPen); + } + SolidBrush.setColor(QColor(i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A)); + p->setBrush(SolidBrush); break; case SET_BG_COLOUR: - brush.setColor(QColor(i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A)); - p->fillRect((int)x_offset, (int)y_offset, (int)floor(x_fact*m_dWidth+0.5), (int)floor(y_fact*m_dHeight+0.5), brush); + SolidBrush.setColor(QColor(i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A)); + p->fillRect(0., 0., m_dWidth, m_dHeight, SolidBrush); break; - case SET_SOLID: - pen.setStyle(Qt::SolidLine); - p->setPen(pen); - break; - default: break; } @@ -985,10 +1032,8 @@ QCoreApplication::processEvents(QEventLoop::AllEvents, 10); delete m_pixPixmap; delete m_painterP; -// if(pic!=NULL) delete pic; m_pixPixmap=NULL; m_painterP=NULL; -// pic=NULL; } void QtExtWidget::captureMousePlotCoords(PLFLT* x, PLFLT* y) Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2009-07-31 15:37:43 UTC (rev 10194) +++ trunk/drivers/qt.cpp 2009-07-31 18:07:55 UTC (rev 10195) @@ -262,8 +262,6 @@ dpi = DEFAULT_DPI; else dpi = pls->xdpi; - // For raster debug - // std::cout << dpi << std::endl; // Shamelessly copied on the Cairo stuff :) if (pls->xlength <= 0 || pls->ylength <= 0) @@ -333,12 +331,12 @@ switch(op) { - case PLESC_DASH: - widget->setDashed(pls->nms, pls->mark, pls->space); - widget->QtPLDriver::setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, pls->curcolor.a); - widget->drawPolyline(pls->dev_x, pls->dev_y, pls->dev_npts); - widget->setSolid(); - break; + // case PLESC_DASH: + // widget->setDashed(pls->nms, pls->mark, pls->space); + // widget->QtPLDriver::setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, pls->curcolor.a); + // widget->drawPolyline(pls->dev_x, pls->dev_y, pls->dev_npts); + // widget->setSolid(); + // break; case PLESC_FILL: xa=new short[pls->dev_npts]; @@ -701,13 +699,6 @@ switch(op) { - case PLESC_DASH: - widget->setDashed(pls->nms, pls->mark, pls->space); - widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, pls->curcolor.a); - widget->drawPolyline(pls->dev_x, pls->dev_y, pls->dev_npts); - widget->setSolid(); - break; - case PLESC_FILL: xa=new short[pls->dev_npts]; ya=new short[pls->dev_npts]; @@ -731,7 +722,8 @@ widget->drawText(pls, (EscText *)ptr); break; - default: break; + default: + break; } } @@ -755,7 +747,6 @@ widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, pls->curcolor.a); break; - default: break; } } @@ -933,13 +924,6 @@ switch(op) { - case PLESC_DASH: - widget->setDashed(pls->nms, pls->mark, pls->space); - widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, pls->curcolor.a); - widget->drawPolyline(pls->dev_x, pls->dev_y, pls->dev_npts); - widget->setSolid(); - break; - case PLESC_FILL: xa=new short[pls->dev_npts]; ya=new short[pls->dev_npts]; @@ -1088,7 +1072,6 @@ /* Driver does not have a clear capability so use (good) PLplot core * fallback for that instead. */ pls->dev_clear=0; - // pls->termin=1; pls->dev_text = 1; // want to draw text pls->dev_unicode = 1; // want unicode @@ -1097,7 +1080,6 @@ qApp->connect(&handler, SIGNAL(MasterChangedPage()), widget, SLOT(nextPage())); qApp->connect(&handler, SIGNAL(MasterClosed()), widget, SLOT(close())); - } void plD_eop_qtwidget(PLStream *pls) @@ -1143,13 +1125,6 @@ switch(op) { - case PLESC_DASH: - widget->setDashed(pls->nms, pls->mark, pls->space); - widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, pls->curcolor.a); - widget->drawPolyline(pls->dev_x, pls->dev_y, pls->dev_npts); - widget->setSolid(); - break; - case PLESC_FILL: xa=new short[pls->dev_npts]; ya=new short[pls->dev_npts]; @@ -1309,13 +1284,6 @@ widget=(QtExtWidget*)pls->dev; switch(op) { - case PLESC_DASH: - widget->setDashed(pls->nms, pls->mark, pls->space); - widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, pls->curcolor.a); - widget->drawPolyline(pls->dev_x, pls->dev_y, pls->dev_npts); - widget->setSolid(); - break; - case PLESC_FILL: xa=new short[pls->dev_npts]; ya=new short[pls->dev_npts]; Modified: trunk/examples/c++/qt_PlotWindow.cpp =================================================================== --- trunk/examples/c++/qt_PlotWindow.cpp 2009-07-31 15:37:43 UTC (rev 10194) +++ trunk/examples/c++/qt_PlotWindow.cpp 2009-07-31 18:07:55 UTC (rev 10195) @@ -38,7 +38,6 @@ plot=new QtExtWidget(QT_DEFAULT_X, QT_DEFAULT_Y, this); setCentralWidget(plot); - // One window = One plot widget = one stream plmkstrm(&strm); plsdev ("extqt"); @@ -46,6 +45,8 @@ plinit(); resize(600, 600); + + pladv(0); } PlotWindow::~PlotWindow() @@ -78,6 +79,7 @@ } pladv(0); + plot->setBackgroundColor(50, 100, 200, 1.); plvpor(0.05, 0.95, 0.05, 0.45); plwind(0., 360., -1.2, 1.2); @@ -126,7 +128,6 @@ plcol0(2); plmtex("t", 1., 0.5, 0.5, "Square & Cubic"); - } void @@ -161,12 +162,9 @@ plot->clearWidget(); - pladv(0); plvsta(); - plcol0(2); - plwind(1980.0, 1990.0, 0.0, 35.0); plbox("bc", 1.0, 0, "bcnv", 10.0, 0); plcol0(2); Modified: trunk/include/qt.h =================================================================== --- trunk/include/qt.h 2009-07-31 15:37:43 UTC (rev 10194) +++ trunk/include/qt.h 2009-07-31 18:07:55 UTC (rev 10195) @@ -100,16 +100,12 @@ MasterHandler(); bool isMasterDevice(QtPLDriver* d); - void setMasterDevice(QtPLDriver* d); - void DeviceChangedPage(QtPLDriver* d); - void DeviceClosed(QtPLDriver* d); signals: void MasterChangedPage(); - void MasterClosed(); protected: @@ -127,32 +123,20 @@ // Draws a line from (x1, y1) to (x2, y2) in internal plplot coordinates virtual void drawLine(short x1, short y1, short x2, short y2); - virtual void drawPolyline(short * x, short * y, PLINT npts); - virtual void drawPolygon(short * x, short * y, PLINT npts); - virtual void drawText(PLStream* pls, EscText* txt); - virtual void setColor(int r, int g, int b, double alpha); - virtual void setBackgroundColor(int r, int g, int b, double alpha){} - virtual void setWidth(PLINT w); - - virtual void setDashed(PLINT nms, PLINT* mark, PLINT* space); - // Set pen to draw solid strokes (called after drawing dashed strokes) virtual void setSolid(); - // Conversion factor from internal plplot coordinates to device coordinates double downscale; double m_dWidth, m_dHeight; - static QMutex mutex; // All-purpose mutex protected: - // Returns font with the good size for a QPicture's resolution QFont getFont(PLUNICODE code); // Draws text in a QPicture using a sub-QPicture (!), updates the current xOffset @@ -168,8 +152,6 @@ double yOffset; double xOffset; -// double fontScalingFactor;// To have a nice font size on qtwidget - QPainter* m_painterP; }; @@ -180,15 +162,11 @@ public: QtRasterDevice(int i_iWidth=QT_DEFAULT_X, int i_iHeight=QT_DEFAULT_Y); - virtual ~QtRasterDevice(); virtual void setBackgroundColor(int r, int g, int b, double alpha); - void definePlotName(const char* fileName, const char* format); - void savePlot(); - virtual void setResolution(double dotsPerInch) { setDotsPerMeterX((int)((dotsPerInch/25.4)*1000.)); @@ -198,7 +176,6 @@ protected: char format[5]; QString fileName; - }; #endif @@ -214,10 +191,9 @@ virtual ~QtSVGDevice(); virtual void setBackgroundColor(int r, int g, int b, double alpha); - void definePlotName(const char* fileName); - void savePlot(); + protected: }; #endif @@ -237,13 +213,10 @@ virtual ~QtEPSDevice(); virtual void setBackgroundColor(int r, int g, int b, double alpha); - void definePlotName(const char* fileName, int ifeps); - void savePlot(); protected: - }; #endif @@ -254,28 +227,14 @@ LINE, POLYLINE, POLYGON, + RECTANGLE, SET_WIDTH, SET_COLOUR, - SET_SOLID, + SET_SMOOTH, TEXT, SET_BG_COLOUR } ElementType; // Identifiers for elements of the buffer -struct LineStruct_ -{ - PLFLT x1; - PLFLT x2; - PLFLT y1; - PLFLT y2; -}; - -struct PolylineStruct_ -{ - PLINT npts; - PLFLT* x; - PLFLT* y; -}; - struct ColourStruct_ { PLINT R, G, B, A; @@ -299,23 +258,21 @@ PLFLT chrht; }; + class BufferElement { public: - ElementType Element; union DataType { - struct LineStruct_* LineStruct; - - struct PolylineStruct_* PolylineStruct; - + QLineF* Line; + QPolygonF* Polyline; + QRectF * Rect; struct ColourStruct_* ColourStruct; - struct TextStruct_* TextStruct; - PLINT intParam; + PLFLT fltParam; } Data; }; @@ -344,7 +301,6 @@ void setColor(int r, int g, int b, double alpha); void setBackgroundColor(int r, int g, int b, double alpha); void setWidth(PLINT r); - void setSolid(); void drawText(PLStream* pls, EscText* txt); protected: @@ -354,7 +310,6 @@ void getPlotParameters(double & io_dXFact, double & io_dYFact, double & io_dXOffset, double & io_dYOffset); // gives the parameters to scale and center the plot on the page void doPlot(QPainter* p, double x_fact, double y_fact, double x_offset, double y_offset); // Actually draws the plot. Deported in a function for readability - void drawTextInPicture(QPainter* p, const QString& text); void renderText(QPainter* p, struct TextStruct_* s, double x_fact, double x_offset, double y_fact, double y_offset); double m_dAspectRatio; // Is kept constant during resizes @@ -364,14 +319,20 @@ bool m_bAwaitingRedraw; int m_iOldSize; // Holds the size of the buffer. Modified => image has to be redrawn + struct + { + int r; + int g; + int b; + double alpha; + } lastColour; + protected slots: void mouseReleaseEvent ( QMouseEvent * event ); void keyPressEvent(QKeyEvent* event); void closeEvent(QCloseEvent* event); void nextPage(); - - }; #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-07-31 18:17:49
|
Revision: 10196 http://plplot.svn.sourceforge.net/plplot/?rev=10196&view=rev Author: airwin Date: 2009-07-31 18:17:38 +0000 (Fri, 31 Jul 2009) Log Message: ----------- AWI for Alban Rochel. Whitespace cleanup. Modified Paths: -------------- trunk/bindings/qt_gui/plqt.cpp trunk/drivers/qt.cpp trunk/examples/c++/qt_PlotWindow.cpp trunk/include/qt.h Modified: trunk/bindings/qt_gui/plqt.cpp =================================================================== --- trunk/bindings/qt_gui/plqt.cpp 2009-07-31 18:07:55 UTC (rev 10195) +++ trunk/bindings/qt_gui/plqt.cpp 2009-07-31 18:17:38 UTC (rev 10196) @@ -1,33 +1,33 @@ /* - This software is provided under the LGPL in March 2009 by the - Cluster Science Centre - QSAS team, - Imperial College, London +This software is provided under the LGPL in March 2009 by the +Cluster Science Centre +QSAS team, +Imperial College, London - Copyright (C) 2009 Imperial College, London - Copyright (C) 2009 Alan W. Irwin +Copyright (C) 2009 Imperial College, London +Copyright (C) 2009 Alan W. Irwin - This is free software; you can redistribute it and/or modify - it under the terms of the GNU General Lesser Public License as published - by the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. +This is free software; you can redistribute it and/or modify +it under the terms of the GNU General Lesser Public License as published +by the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. - This software is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. +This software is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. - To received a copy of the GNU Library General Public License - write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - History: +To received a copy of the GNU Library General Public License +write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - March 2009: v1.00 - Initial release. - +History: + + +March 2009: v1.00 +Initial release. + */ @@ -41,33 +41,33 @@ // Only handles multiple Qt devices MasterHandler::MasterHandler():QObject() { - masterDevice=NULL; + masterDevice=NULL; } bool MasterHandler::isMasterDevice(QtPLDriver* d) { - return d==masterDevice; + return d==masterDevice; } void MasterHandler::setMasterDevice(QtPLDriver* d) { - masterDevice=d; + masterDevice=d; } void MasterHandler::DeviceChangedPage(QtPLDriver* d) { - if(d==masterDevice) + if(d==masterDevice) { - emit MasterChangedPage(); + emit MasterChangedPage(); } } void MasterHandler::DeviceClosed(QtPLDriver* d) { - if(d==masterDevice) + if(d==masterDevice) { - emit MasterClosed(); - masterDevice=NULL; + emit MasterClosed(); + masterDevice=NULL; } } @@ -76,8 +76,8 @@ QtPLDriver::QtPLDriver(PLINT i_iWidth, PLINT i_iHeight) { - m_dWidth=i_iWidth; - m_dHeight=i_iHeight; + m_dWidth=i_iWidth; + m_dHeight=i_iHeight; } QtPLDriver::~QtPLDriver() @@ -86,298 +86,298 @@ void QtPLDriver::drawLine(short x1, short y1, short x2, short y2) { - if(!m_painterP->isActive()) return; - QLineF line( (PLFLT)x1*downscale, - m_dHeight-(PLFLT)y1*downscale, - (PLFLT)x2*downscale, - m_dHeight-(PLFLT)y2*downscale - ); + if(!m_painterP->isActive()) return; + QLineF line( (PLFLT)x1*downscale, + m_dHeight-(PLFLT)y1*downscale, + (PLFLT)x2*downscale, + m_dHeight-(PLFLT)y2*downscale + ); - m_painterP->drawLine(line); + m_painterP->drawLine(line); } void QtPLDriver::drawPolyline(short * x, short * y, PLINT npts) { - if(!m_painterP->isActive()) return; - QPointF * polyline=new QPointF[npts]; - for(int i=0; i<npts; ++i) - { - polyline[i].setX((PLFLT)x[i]*downscale); - polyline[i].setY(m_dHeight-(PLFLT)y[i]*downscale); - } - m_painterP->drawPolyline(polyline, npts); - delete[] polyline; + if(!m_painterP->isActive()) return; + QPointF * polyline=new QPointF[npts]; + for(int i=0; i<npts; ++i) + { + polyline[i].setX((PLFLT)x[i]*downscale); + polyline[i].setY(m_dHeight-(PLFLT)y[i]*downscale); + } + m_painterP->drawPolyline(polyline, npts); + delete[] polyline; } void QtPLDriver::drawPolygon(short * x, short * y, PLINT npts) { - if(!m_painterP->isActive()) return; - QPointF * polygon=new QPointF[npts]; - for(int i=0; i<npts; ++i) - { - polygon[i].setX((PLFLT)x[i]*downscale); - polygon[i].setY(m_dHeight-(PLFLT)y[i]*downscale); - } - m_painterP->drawPolygon(polygon, npts); - delete[] polygon; + if(!m_painterP->isActive()) return; + QPointF * polygon=new QPointF[npts]; + for(int i=0; i<npts; ++i) + { + polygon[i].setX((PLFLT)x[i]*downscale); + polygon[i].setY(m_dHeight-(PLFLT)y[i]*downscale); + } + m_painterP->drawPolygon(polygon, npts); + delete[] polygon; } QFont QtPLDriver::getFont(PLUNICODE unicode) { - // Get new font parameters - unsigned char fontFamily, fontStyle, fontWeight; + // Get new font parameters + unsigned char fontFamily, fontStyle, fontWeight; - plP_fci2hex(unicode, &fontFamily, PL_FCI_FAMILY); - plP_fci2hex(unicode, &fontStyle, PL_FCI_STYLE); - plP_fci2hex(unicode, &fontWeight, PL_FCI_WEIGHT); - - QFont f; + plP_fci2hex(unicode, &fontFamily, PL_FCI_FAMILY); + plP_fci2hex(unicode, &fontStyle, PL_FCI_STYLE); + plP_fci2hex(unicode, &fontWeight, PL_FCI_WEIGHT); - f.setPointSizeF(currentFontSize*currentFontScale<4 ? 4 : currentFontSize*currentFontScale); + QFont f; + + f.setPointSizeF(currentFontSize*currentFontScale<4 ? 4 : currentFontSize*currentFontScale); switch(fontFamily) { - case 1: - f.setStyleHint(QFont::Serif); - break; - case 2: - f.setStyleHint(QFont::TypeWriter); - break; - case 0: case 3: case 4:default: - f.setStyleHint(QFont::SansSerif); - break; - } - f.setFamily(""); // no family name, forcing Qt to find an appropriate font by itself + case 1: + f.setStyleHint(QFont::Serif); + break; + case 2: + f.setStyleHint(QFont::TypeWriter); + break; + case 0: case 3: case 4:default: + f.setStyleHint(QFont::SansSerif); + break; + } + f.setFamily(""); // no family name, forcing Qt to find an appropriate font by itself - if(fontStyle) f.setItalic(true); - if(fontWeight) f.setWeight(QFont::Bold); - else f.setWeight(QFont::Normal); - - f.setUnderline(underlined); - f.setOverline(overlined); + if(fontStyle) f.setItalic(true); + if(fontWeight) f.setWeight(QFont::Bold); + else f.setWeight(QFont::Normal); - return f; + f.setUnderline(underlined); + f.setOverline(overlined); + + return f; } void QtPLDriver::drawTextInPicture(QPainter* p, const QString& text) { - QRectF rect(0., 0., 0., 0.); - QRectF bounding; - QPicture tempPic; - QPainter tempPainter(&tempPic); - tempPainter.setFont(p->font()); - - if(vectorize) - { - bounding=tempPainter.boundingRect(rect, Qt::AlignHCenter|Qt::AlignVCenter|Qt::TextDontClip, text); - + QRectF rect(0., 0., 0., 0.); + QRectF bounding; + QPicture tempPic; + QPainter tempPainter(&tempPic); + tempPainter.setFont(p->font()); + + if(vectorize) + { + bounding=tempPainter.boundingRect(rect, Qt::AlignHCenter|Qt::AlignVCenter|Qt::TextDontClip, text); + tempPainter.save(); // QPen savePen=tempPainter.pen(); QPen pen=QPen(Qt::NoPen); - tempPainter.setPen(pen); - - double offset=QFontMetrics(tempPainter.font(), &tempPic).boundingRect(text).top(); // Distance between the baseline and the top of the bounding box - - QPainterPath path; - path.addText(QPointF(bounding.left(), bounding.top()-offset), tempPainter.font(), text); - tempPainter.drawPath(path); + tempPainter.setPen(pen); + + double offset=QFontMetrics(tempPainter.font(), &tempPic).boundingRect(text).top(); // Distance between the baseline and the top of the bounding box + + QPainterPath path; + path.addText(QPointF(bounding.left(), bounding.top()-offset), tempPainter.font(), text); + tempPainter.drawPath(path); tempPainter.restore(); - } - else - { - tempPainter.drawText(rect, Qt::AlignHCenter|Qt::AlignVCenter|Qt::TextDontClip, text, &bounding); - } - - tempPainter.end(); - - p->drawPicture((int)(xOffset+bounding.width()/2.), -yOffset, tempPic); - - xOffset+=bounding.width(); + } + else + { + tempPainter.drawText(rect, Qt::AlignHCenter|Qt::AlignVCenter|Qt::TextDontClip, text, &bounding); + } + + tempPainter.end(); + + p->drawPicture((int)(xOffset+bounding.width()/2.), -yOffset, tempPic); + + xOffset+=bounding.width(); } QPicture QtPLDriver::getTextPicture(PLUNICODE fci, PLUNICODE* text, int len, PLFLT chrht) { - char plplotEsc; - plgesc( &plplotEsc ); - - double old_fontScale; - - QPicture res; - QPainter p(&res); - - QString currentString; + char plplotEsc; + plgesc( &plplotEsc ); - yOffset=0.; - xOffset=0.; + double old_fontScale; - // Scaling factor of 1.6 determined empirically to make all qt results - // have the same character size as cairo results (taking into account - // the slightly different actual glyph sizes for the different - // default fonts found by cairo and qt). - currentFontSize=chrht*POINTS_PER_INCH/25.4*1.45; - currentFontScale=1.; - underlined=false; - overlined=false; - - p.setFont(getFont(fci)); + QPicture res; + QPainter p(&res); - int i=0; - while(i < len) - { - if(text[i]<PL_FCI_MARK) // Not a font change - { - if(text[i]!=(PLUNICODE)plplotEsc) - { - currentString.append(QString(QChar(text[i]))); - ++i; - continue; - } - ++i; // Now analyse the escaped character - switch(text[i]) - { - case 'd': - drawTextInPicture(&p, currentString); - currentString.clear(); - old_fontScale=currentFontScale; + QString currentString; + + yOffset=0.; + xOffset=0.; + + // Scaling factor of 1.6 determined empirically to make all qt results + // have the same character size as cairo results (taking into account + // the slightly different actual glyph sizes for the different + // default fonts found by cairo and qt). + currentFontSize=chrht*POINTS_PER_INCH/25.4*1.45; + currentFontScale=1.; + underlined=false; + overlined=false; + + p.setFont(getFont(fci)); + + int i=0; + while(i < len) + { + if(text[i]<PL_FCI_MARK) // Not a font change + { + if(text[i]!=(PLUNICODE)plplotEsc) + { + currentString.append(QString(QChar(text[i]))); + ++i; + continue; + } + ++i; // Now analyse the escaped character + switch(text[i]) + { + case 'd': + drawTextInPicture(&p, currentString); + currentString.clear(); + old_fontScale=currentFontScale; if( yOffset>-0.000000000001 ) // I've already encountered precision issues here, so changed 0 into -epsilon { - currentFontScale *= 1.25; /* Subscript scaling parameter */ + currentFontScale *= 1.25; /* Subscript scaling parameter */ } - else + else { - currentFontScale *= 0.8; /* Subscript scaling parameter */ + currentFontScale *= 0.8; /* Subscript scaling parameter */ } - yOffset -= currentFontSize * old_fontScale / 2.; - - p.setFont(getFont(fci)); - break; + yOffset -= currentFontSize * old_fontScale / 2.; - case 'u': - drawTextInPicture(&p, currentString); - - currentString.clear(); + p.setFont(getFont(fci)); + break; + + case 'u': + drawTextInPicture(&p, currentString); + + currentString.clear(); if( yOffset<-0.000000000001 ) { - currentFontScale *= 1.25; /* Subscript scaling parameter */ + currentFontScale *= 1.25; /* Subscript scaling parameter */ } - else + else { - currentFontScale *= 0.8; /* Subscript scaling parameter */ + currentFontScale *= 0.8; /* Subscript scaling parameter */ } - yOffset += currentFontSize * currentFontScale / 2.; - p.setFont(getFont(fci)); - break; + yOffset += currentFontSize * currentFontScale / 2.; + p.setFont(getFont(fci)); + break; - case '-': - drawTextInPicture(&p, currentString); - - currentString.clear(); - underlined=!underlined; - p.setFont(getFont(fci)); - break; + case '-': + drawTextInPicture(&p, currentString); - case '+': - drawTextInPicture(&p, currentString); + currentString.clear(); + underlined=!underlined; + p.setFont(getFont(fci)); + break; - currentString.clear(); - overlined=!overlined; - p.setFont(getFont(fci)); - break; + case '+': + drawTextInPicture(&p, currentString); + currentString.clear(); + overlined=!overlined; + p.setFont(getFont(fci)); + break; + - case '#': - currentString.append(QString((QChar*)&(text[i]), 1)); - break; + case '#': + currentString.append(QString((QChar*)&(text[i]), 1)); + break; - default : - std::cout << "unknown escape char " << ((QChar)text[i]).toLatin1() << std::endl; - break; - } - } - else // Font change - { - drawTextInPicture(&p, currentString); + default : + std::cout << "unknown escape char " << ((QChar)text[i]).toLatin1() << std::endl; + break; + } + } + else // Font change + { + drawTextInPicture(&p, currentString); - currentString.clear(); - fci=text[i]; - p.setFont(getFont(fci)); - } - ++i; - } - drawTextInPicture(&p, currentString); - - p.end(); - return res; + currentString.clear(); + fci=text[i]; + p.setFont(getFont(fci)); + } + ++i; + } + drawTextInPicture(&p, currentString); + + p.end(); + return res; } void QtPLDriver::drawText(PLStream* pls, EscText* txt) { - if(!m_painterP->isActive()) return; + if(!m_painterP->isActive()) return; - /* Check that we got unicode, warning message and return if not */ + /* Check that we got unicode, warning message and return if not */ if( txt->unicode_array_len == 0 ) { - printf( "Non unicode string passed to a Qt driver, ignoring\n" ); - return; - } - - /* Check that unicode string isn't longer then the max we allow */ + printf( "Non unicode string passed to a Qt driver, ignoring\n" ); + return; + } + + /* Check that unicode string isn't longer then the max we allow */ if( txt->unicode_array_len >= 500 ) { - printf( "Sorry, the Qt drivers only handle strings of length < %d\n", 500 ); - return; - } + printf( "Sorry, the Qt drivers only handle strings of length < %d\n", 500 ); + return; + } - PLFLT rotation, shear, stride; - plRotationShear( txt->xform, &rotation, &shear, &stride); - - double picDpi; - PLUNICODE fci; - plgfci( &fci ); - QPicture picText=getTextPicture(fci, txt->unicode_array, txt->unicode_array_len, pls->chrht); - picDpi=picText.logicalDpiY(); + PLFLT rotation, shear, stride; + plRotationShear( txt->xform, &rotation, &shear, &stride); + + double picDpi; + PLUNICODE fci; + plgfci( &fci ); + QPicture picText=getTextPicture(fci, txt->unicode_array, txt->unicode_array_len, pls->chrht); + picDpi=picText.logicalDpiY(); - m_painterP->setClipping(true); - m_painterP->setClipRect(QRect((int)(pls->clpxmi*downscale), (int)(m_dHeight-pls->clpyma*downscale), (int)((pls->clpxma-pls->clpxmi)*downscale), (int)((pls->clpyma-pls->clpymi)*downscale)), Qt::ReplaceClip); + m_painterP->setClipping(true); + m_painterP->setClipRect(QRect((int)(pls->clpxmi*downscale), (int)(m_dHeight-pls->clpyma*downscale), (int)((pls->clpxma-pls->clpxmi)*downscale), (int)((pls->clpyma-pls->clpymi)*downscale)), Qt::ReplaceClip); - rotation -= pls->diorot * M_PI / 2.0; - m_painterP->translate(txt->x*downscale, m_dHeight-txt->y*downscale); - QMatrix rotShearMatrix(cos(rotation)*stride, -sin(rotation)*stride, cos(rotation)*sin(shear)+sin(rotation)*cos(shear), -sin(rotation)*sin(shear)+cos(rotation)*cos(shear), 0., 0.); + rotation -= pls->diorot * M_PI / 2.0; + m_painterP->translate(txt->x*downscale, m_dHeight-txt->y*downscale); + QMatrix rotShearMatrix(cos(rotation)*stride, -sin(rotation)*stride, cos(rotation)*sin(shear)+sin(rotation)*cos(shear), -sin(rotation)*sin(shear)+cos(rotation)*cos(shear), 0., 0.); - m_painterP->setWorldMatrix(rotShearMatrix, true); + m_painterP->setWorldMatrix(rotShearMatrix, true); - m_painterP->translate(-txt->just*xOffset*m_painterP->device()->logicalDpiY()/picDpi, 0.); + m_painterP->translate(-txt->just*xOffset*m_painterP->device()->logicalDpiY()/picDpi, 0.); - m_painterP->drawPicture(0, 0, picText); + m_painterP->drawPicture(0, 0, picText); m_painterP->resetTransform();; - m_painterP->setClipping(false); + m_painterP->setClipping(false); } void QtPLDriver::setColor(int r, int g, int b, double alpha) { - if(!m_painterP->isActive()) return; + if(!m_painterP->isActive()) return; - QPen p=m_painterP->pen(); - p.setColor(QColor(r, g, b, (int)(alpha*255))); - m_painterP->setPen(p); - - QBrush B=m_painterP->brush(); - B.setColor(QColor(r, g, b, (int)(alpha*255))); - B.setStyle(Qt::SolidPattern); - m_painterP->setBrush(B); + QPen p=m_painterP->pen(); + p.setColor(QColor(r, g, b, (int)(alpha*255))); + m_painterP->setPen(p); + + QBrush B=m_painterP->brush(); + B.setColor(QColor(r, g, b, (int)(alpha*255))); + B.setStyle(Qt::SolidPattern); + m_painterP->setBrush(B); } void QtPLDriver::setWidth(PLINT w) { - if(!m_painterP->isActive()) return; + if(!m_painterP->isActive()) return; - QPen p=m_painterP->pen(); - p.setWidth(w); - m_painterP->setPen(p); + QPen p=m_painterP->pen(); + p.setWidth(w); + m_painterP->setPen(p); } // void QtPLDriver::setDashed(PLINT nms, PLINT* mark, PLINT* space) @@ -397,98 +397,98 @@ void QtPLDriver::setSolid() { - if(!m_painterP->isActive()) return; + if(!m_painterP->isActive()) return; - QPen p=m_painterP->pen(); - p.setStyle(Qt::SolidLine); - m_painterP->setPen(p); + QPen p=m_painterP->pen(); + p.setStyle(Qt::SolidLine); + m_painterP->setPen(p); } ////////////////// Raster driver-specific definitions: class and interface functions ///////// #if defined (PLD_bmpqt) || defined(PLD_jpgqt) || defined (PLD_pngqt) || defined(PLD_ppmqt) || defined(PLD_tiffqt) QtRasterDevice::QtRasterDevice(int i_iWidth, int i_iHeight): - QtPLDriver(i_iWidth, i_iHeight), - QImage(i_iWidth, i_iHeight, QImage::Format_RGB32) + QtPLDriver(i_iWidth, i_iHeight), + QImage(i_iWidth, i_iHeight, QImage::Format_RGB32) { - // Painter initialised in the constructor contrary - // to buffered drivers, which paint only in doPlot(). - m_painterP=new QPainter(this); - QBrush b=m_painterP->brush(); - b.setStyle(Qt::SolidPattern); - m_painterP->setBrush(b); - m_painterP->setRenderHint(QPainter::Antialiasing, true); + // Painter initialised in the constructor contrary + // to buffered drivers, which paint only in doPlot(). + m_painterP=new QPainter(this); + QBrush b=m_painterP->brush(); + b.setStyle(Qt::SolidPattern); + m_painterP->setBrush(b); + m_painterP->setRenderHint(QPainter::Antialiasing, true); } QtRasterDevice::~QtRasterDevice() { - delete m_painterP; + delete m_painterP; } void QtRasterDevice::definePlotName(const char* fileName, const char* format) { - // Avoid buffer overflows - strncpy(this->format, format, 4); - this->format[4]='\0'; - - this->fileName=QString(fileName); + // Avoid buffer overflows + strncpy(this->format, format, 4); + this->format[4]='\0'; + + this->fileName=QString(fileName); } void QtRasterDevice::savePlot() { - m_painterP->end(); - save(fileName, format, 85); + m_painterP->end(); + save(fileName, format, 85); - m_painterP->begin(this); - m_painterP->setRenderHint(QPainter::Antialiasing, true); - QBrush b=m_painterP->brush(); - b.setStyle(Qt::SolidPattern); - m_painterP->setBrush(b); + m_painterP->begin(this); + m_painterP->setRenderHint(QPainter::Antialiasing, true); + QBrush b=m_painterP->brush(); + b.setStyle(Qt::SolidPattern); + m_painterP->setBrush(b); } void QtRasterDevice::setBackgroundColor(int r, int g, int b, double alpha) { - if(!m_painterP->isActive()) return; + if(!m_painterP->isActive()) return; - QBrush brush(QColor(r, g, b, (int)(alpha*255))); - m_painterP->fillRect(0, 0, width(), height(), brush); + QBrush brush(QColor(r, g, b, (int)(alpha*255))); + m_painterP->fillRect(0, 0, width(), height(), brush); } #endif #if defined(PLD_svgqt) && QT_VERSION >= 0x040300 QtSVGDevice::QtSVGDevice(int i_iWidth, int i_iHeight): - QtPLDriver(i_iWidth, i_iHeight) + QtPLDriver(i_iWidth, i_iHeight) { - m_painterP=NULL; + m_painterP=NULL; } QtSVGDevice::~QtSVGDevice() { - delete m_painterP; + delete m_painterP; } void QtSVGDevice::definePlotName(const char* fileName) { - setFileName(QString(fileName)); - setResolution(POINTS_PER_INCH); - setSize(QSize((int)m_dWidth, (int)m_dHeight)); + setFileName(QString(fileName)); + setResolution(POINTS_PER_INCH); + setSize(QSize((int)m_dWidth, (int)m_dHeight)); #if QT_VERSION >= 0x040500 - setViewBox(QRect(0, 0, (int)m_dWidth, (int)m_dHeight)); + setViewBox(QRect(0, 0, (int)m_dWidth, (int)m_dHeight)); #endif - m_painterP=new QPainter(this); + m_painterP=new QPainter(this); } void QtSVGDevice::savePlot() { - m_painterP->end(); + m_painterP->end(); } void QtSVGDevice::setBackgroundColor(int r, int g, int b, double alpha) { - if(!m_painterP->isActive()) return; + if(!m_painterP->isActive()) return; - QBrush brush(QColor(r, g, b, (int)(alpha*255))); - m_painterP->fillRect(0, 0, width(), height(), brush); + QBrush brush(QColor(r, g, b, (int)(alpha*255))); + m_painterP->fillRect(0, 0, width(), height(), brush); } #endif @@ -496,98 +496,98 @@ QtEPSDevice::QtEPSDevice(int i_iWidth, int i_iHeight) { #if QT_VERSION < 0x040400 - setPageSize(QPrinter::A4); + setPageSize(QPrinter::A4); #else - setFullPage(true); - setPaperSize(QSizeF(i_iHeight, i_iWidth), QPrinter::Point); + setFullPage(true); + setPaperSize(QSizeF(i_iHeight, i_iWidth), QPrinter::Point); #endif - setResolution(POINTS_PER_INCH); - setColorMode(QPrinter::Color); - setOrientation(QPrinter::Landscape); - setPrintProgram(QString("lpr")); - - if(i_iWidth<=0 || i_iHeight<=0) - { - m_dWidth=pageRect().width(); - m_dHeight=pageRect().height(); - } - else - { - m_dWidth=i_iWidth; - m_dHeight=i_iHeight; - } - m_painterP=NULL; + setResolution(POINTS_PER_INCH); + setColorMode(QPrinter::Color); + setOrientation(QPrinter::Landscape); + setPrintProgram(QString("lpr")); + + if(i_iWidth<=0 || i_iHeight<=0) + { + m_dWidth=pageRect().width(); + m_dHeight=pageRect().height(); + } + else + { + m_dWidth=i_iWidth; + m_dHeight=i_iHeight; + } + m_painterP=NULL; } QtEPSDevice::~QtEPSDevice() { - delete m_painterP; + delete m_painterP; } void QtEPSDevice::definePlotName(const char* fileName, int ifeps) { - setOutputFileName(QString(fileName)); - if(ifeps) - { - setOutputFormat(QPrinter::PostScriptFormat); - } - else - { - setOutputFormat(QPrinter::PdfFormat); - } - - m_painterP=new QPainter(this); + setOutputFileName(QString(fileName)); + if(ifeps) + { + setOutputFormat(QPrinter::PostScriptFormat); + } + else + { + setOutputFormat(QPrinter::PdfFormat); + } + + m_painterP=new QPainter(this); } void QtEPSDevice::savePlot() { - m_painterP->end(); + m_painterP->end(); } void QtEPSDevice::setBackgroundColor(int r, int g, int b, double alpha) { - if(!m_painterP->isActive()) return; + if(!m_painterP->isActive()) return; - QBrush brush(QColor(r, g, b, (int)(alpha*255))); - m_painterP->fillRect(0, 0, width(), height(), brush); + QBrush brush(QColor(r, g, b, (int)(alpha*255))); + m_painterP->fillRect(0, 0, width(), height(), brush); } #endif #if defined (PLD_qtwidget) || defined(PLD_extqt) QtPLWidget::QtPLWidget(int i_iWidth, int i_iHeight, QWidget* parent): - QWidget(parent), QtPLDriver(i_iWidth, i_iHeight) + QWidget(parent), QtPLDriver(i_iWidth, i_iHeight) { - m_painterP=new QPainter; - - m_dAspectRatio=m_dWidth/m_dHeight; - - m_pixPixmap=NULL; - m_iOldSize=0; - pageNumber=0; - resize(i_iWidth, i_iHeight); + m_painterP=new QPainter; + + m_dAspectRatio=m_dWidth/m_dHeight; + + m_pixPixmap=NULL; + m_iOldSize=0; + pageNumber=0; + resize(i_iWidth, i_iHeight); lastColour.r=-1; } QtPLWidget::~QtPLWidget() { - clearBuffer(); - delete m_pixPixmap; + clearBuffer(); + delete m_pixPixmap; } void QtPLWidget::clearWidget() { - clearBuffer(); - m_bAwaitingRedraw=true; - update(); + clearBuffer(); + m_bAwaitingRedraw=true; + update(); } void QtPLWidget::clearBuffer() { lastColour.r=-1; - for(QLinkedList<BufferElement>::iterator i=m_listBuffer.begin(); i!=m_listBuffer.end(); ++i) - { - switch(i->Element) - { + for(QLinkedList<BufferElement>::iterator i=m_listBuffer.begin(); i!=m_listBuffer.end(); ++i) + { + switch(i->Element) + { case LINE: delete i->Data.Line; break; @@ -595,54 +595,54 @@ delete i->Data.Rect; break; - case POLYLINE: - case POLYGON: + case POLYLINE: + case POLYGON: delete i->Data.Polyline; - break; - + break; + case TEXT: delete[] i->Data.TextStruct->text; delete i->Data.TextStruct; - break; - - case SET_COLOUR: - case SET_BG_COLOUR: - delete i->Data.ColourStruct; - break; - - default: - break; - } - } - - m_listBuffer.clear(); + break; + + case SET_COLOUR: + case SET_BG_COLOUR: + delete i->Data.ColourStruct; + break; + + default: + break; + } + } + + m_listBuffer.clear(); } void QtPLWidget::drawLine(short x1, short y1, short x2, short y2) { - BufferElement el; - el.Element=LINE; + BufferElement el; + el.Element=LINE; el.Data.Line=new QLineF(QPointF((PLFLT)x1*downscale, (PLFLT)(m_dHeight-y1*downscale)), QPointF((PLFLT)x2*downscale, (PLFLT)(m_dHeight-y2*downscale))); - m_listBuffer.append(el); + m_listBuffer.append(el); } void QtPLWidget::drawPolyline(short * x, short * y, PLINT npts) { - BufferElement el; - el.Element=POLYLINE; + BufferElement el; + el.Element=POLYLINE; el.Data.Polyline=new QPolygonF; - for(int i=0; i<npts; ++i) - { + for(int i=0; i<npts; ++i) + { (*el.Data.Polyline) << QPointF((PLFLT)(x[i])*downscale, (PLFLT)(m_dHeight-(y[i])*downscale)); - } - - m_listBuffer.append(el); + } + + m_listBuffer.append(el); } void QtPLWidget::drawPolygon(short * x, short * y, PLINT npts) { - BufferElement el; + BufferElement el; bool isRect=false; if(npts==4) // Check if it's a rectangle. If so, it can be made faster to display @@ -704,185 +704,185 @@ } else { - el.Element=POLYGON; + el.Element=POLYGON; el.Data.Polyline=new QPolygonF; - for(int i=0; i<npts; ++i) - { + for(int i=0; i<npts; ++i) + { (*el.Data.Polyline) << QPointF((PLFLT)(x[i])*downscale, (PLFLT)(m_dHeight-(y[i])*downscale)); - } + } } - - m_listBuffer.append(el); + + m_listBuffer.append(el); } void QtPLWidget::setColor(int r, int g, int b, double alpha) { if(lastColour.r!=r || lastColour.g!=g || lastColour.b!=b || lastColour.alpha!=alpha) { - BufferElement el; - el.Element=SET_COLOUR; - el.Data.ColourStruct=new struct ColourStruct_; - el.Data.ColourStruct->R=r; - el.Data.ColourStruct->G=g; - el.Data.ColourStruct->B=b; - el.Data.ColourStruct->A=alpha*255.; - - m_listBuffer.append(el); + BufferElement el; + el.Element=SET_COLOUR; + el.Data.ColourStruct = new struct ColourStruct_; + el.Data.ColourStruct->R=r; + el.Data.ColourStruct->G=g; + el.Data.ColourStruct->B=b; + el.Data.ColourStruct->A=alpha*255.; + + m_listBuffer.append(el); lastColour.r=r; lastColour.g=g; lastColour.b=b; lastColour.alpha=alpha; + } } -} void QtPLWidget::setBackgroundColor(int r, int g, int b, double alpha) { - BufferElement el; - el.Element=SET_BG_COLOUR; - el.Data.ColourStruct=new struct ColourStruct_; - el.Data.ColourStruct->R=r; - el.Data.ColourStruct->G=g; - el.Data.ColourStruct->B=b; - el.Data.ColourStruct->A=alpha*255.; - - m_listBuffer.append(el); + BufferElement el; + el.Element=SET_BG_COLOUR; + el.Data.ColourStruct=new struct ColourStruct_; + el.Data.ColourStruct->R=r; + el.Data.ColourStruct->G=g; + el.Data.ColourStruct->B=b; + el.Data.ColourStruct->A=alpha*255.; + + m_listBuffer.append(el); } void QtPLWidget::setWidth(PLINT w) { - BufferElement el; - el.Element=SET_WIDTH; - el.Data.intParam=w; - m_listBuffer.append(el); + BufferElement el; + el.Element=SET_WIDTH; + el.Data.intParam=w; + m_listBuffer.append(el); } void QtPLWidget::drawText(PLStream* pls, EscText* txt) { - BufferElement el; - el.Element=TEXT; - el.Data.TextStruct=new struct TextStruct_; - el.Data.TextStruct->x=txt->x*downscale; - el.Data.TextStruct->y=m_dHeight-txt->y*downscale; - el.Data.TextStruct->clipxmin=pls->clpxmi*downscale; - el.Data.TextStruct->clipymin=m_dHeight-pls->clpymi*downscale; - el.Data.TextStruct->clipxmax=pls->clpxma*downscale; - el.Data.TextStruct->clipymax=m_dHeight-pls->clpyma*downscale; - PLUNICODE fci; - plgfci(&fci); - el.Data.TextStruct->fci=fci; - PLFLT rotation, shear, stride; - plRotationShear( txt->xform, &rotation, &shear, &stride); - rotation -= pls->diorot * M_PI / 2.0; - el.Data.TextStruct->rotation=rotation; - el.Data.TextStruct->shear=shear; - el.Data.TextStruct->stride=stride; - el.Data.TextStruct->just=txt->just; - el.Data.TextStruct->text=new PLUNICODE[txt->unicode_array_len]; - memcpy(el.Data.TextStruct->text, txt->unicode_array, txt->unicode_array_len*sizeof(PLUNICODE)); - el.Data.TextStruct->len=txt->unicode_array_len; - el.Data.TextStruct->chrht=pls->chrht; - - m_listBuffer.append(el); + BufferElement el; + el.Element=TEXT; + el.Data.TextStruct=new struct TextStruct_; + el.Data.TextStruct->x=txt->x*downscale; + el.Data.TextStruct->y=m_dHeight-txt->y*downscale; + el.Data.TextStruct->clipxmin=pls->clpxmi*downscale; + el.Data.TextStruct->clipymin=m_dHeight-pls->clpymi*downscale; + el.Data.TextStruct->clipxmax=pls->clpxma*downscale; + el.Data.TextStruct->clipymax=m_dHeight-pls->clpyma*downscale; + PLUNICODE fci; + plgfci(&fci); + el.Data.TextStruct->fci=fci; + PLFLT rotation, shear, stride; + plRotationShear( txt->xform, &rotation, &shear, &stride); + rotation -= pls->diorot * M_PI / 2.0; + el.Data.TextStruct->rotation=rotation; + el.Data.TextStruct->shear=shear; + el.Data.TextStruct->stride=stride; + el.Data.TextStruct->just=txt->just; + el.Data.TextStruct->text=new PLUNICODE[txt->unicode_array_len]; + memcpy(el.Data.TextStruct->text, txt->unicode_array, txt->unicode_array_len*sizeof(PLUNICODE)); + el.Data.TextStruct->len=txt->unicode_array_len; + el.Data.TextStruct->chrht=pls->chrht; + + m_listBuffer.append(el); } void QtPLWidget::renderText(QPainter* p, struct TextStruct_* s, double x_fact, double x_offset, double y_fact, double y_offset) { - if(s->len<=0 || s->len>=500) return; - QPicture picText=getTextPicture(s->fci, s->text, s->len, s->chrht*y_fact); - - double picDpi=picText.logicalDpiY(); + if(s->len<=0 || s->len>=500) return; + QPicture picText=getTextPicture(s->fci, s->text, s->len, s->chrht*y_fact); - p->setClipping(true); - p->setClipRect(QRectF(s->clipxmin*x_fact+x_offset, s->clipymax*y_fact+y_offset, (s->clipxmax-s->clipxmin)*x_fact, (-s->clipymax+s->clipymin)*y_fact), Qt::ReplaceClip); - p->translate(s->x*x_fact+x_offset, s->y*y_fact+y_offset); - QMatrix rotShearMatrix(cos(s->rotation)*s->stride, -sin(s->rotation)*s->stride, cos(s->rotation)*sin(s->shear)+sin(s->rotation)*cos(s->shear), -sin(s->rotation)*sin(s->shear)+cos(s->rotation)*cos(s->shear), 0.,0.); - p->setWorldMatrix(rotShearMatrix, true); + double picDpi=picText.logicalDpiY(); - p->translate(-s->just*xOffset*p->device()->logicalDpiY()/picDpi, 0.); - - p->drawPicture(0., 0., picText); - + p->setClipping(true); + p->setClipRect(QRectF(s->clipxmin*x_fact+x_offset, s->clipymax*y_fact+y_offset, (s->clipxmax-s->clipxmin)*x_fact, (-s->clipymax+s->clipymin)*y_fact), Qt::ReplaceClip); + p->translate(s->x*x_fact+x_offset, s->y*y_fact+y_offset); + QMatrix rotShearMatrix(cos(s->rotation)*s->stride, -sin(s->rotation)*s->stride, cos(s->rotation)*sin(s->shear)+sin(s->rotation)*cos(s->shear), -sin(s->rotation)*sin(s->shear)+cos(s->rotation)*cos(s->shear), 0.,0.); + p->setWorldMatrix(rotShearMatrix, true); + + p->translate(-s->just*xOffset*p->device()->logicalDpiY()/picDpi, 0.); + + p->drawPicture(0., 0., picText); + p->resetTransform(); - p->setClipping(false); + p->setClipping(false); } void QtPLWidget::mouseReleaseEvent ( QMouseEvent * event ) { - if(event->button()==Qt::RightButton) - { - handler.DeviceChangedPage(this); - } + if(event->button()==Qt::RightButton) + { + handler.DeviceChangedPage(this); + } } void QtPLWidget::keyPressEvent(QKeyEvent* event) { - if(event->key()==Qt::Key_Enter || event->key()==Qt::Key_Return) - { - handler.DeviceChangedPage(this); - } + if(event->key()==Qt::Key_Enter || event->key()==Qt::Key_Return) + { + handler.DeviceChangedPage(this); + } } void QtPLWidget::closeEvent(QCloseEvent* event) { - handler.DeviceClosed(this); - event->ignore(); + handler.DeviceClosed(this); + event->ignore(); } void QtPLWidget::nextPage() { - clearWidget(); - pageNumber++; + clearWidget(); + pageNumber++; } void QtPLWidget::resizeEvent( QResizeEvent * ) { - m_bAwaitingRedraw=true; - delete m_pixPixmap; - m_pixPixmap=NULL; + m_bAwaitingRedraw=true; + delete m_pixPixmap; + m_pixPixmap=NULL; } void QtPLWidget::paintEvent( QPaintEvent * ) { - double x_fact, y_fact, x_offset(0.), y_offset(0.); //Parameters to scale and center the plot on the widget - - getPlotParameters(x_fact, y_fact, x_offset, y_offset); - if(m_bAwaitingRedraw || m_pixPixmap==NULL || m_listBuffer.size()!=m_iOldSize) // If must regenerate image, draw it in the pixmap - { - delete m_pixPixmap; - m_pixPixmap=new QPixmap(width(), height()); - QPainter* painter=new QPainter; - painter->begin(m_pixPixmap); - - // Draw the margins and the background - painter->fillRect(0, 0, width(), height(), QBrush(Qt::white)); - painter->fillRect(0, 0, width(), height(), QBrush(Qt::gray, Qt::Dense4Pattern)); - - // Draw the plot - doPlot(painter, x_fact, y_fact, x_offset, y_offset); - painter->end(); - - m_bAwaitingRedraw=false; - m_iOldSize=m_listBuffer.size(); - - delete painter; - } - - // draw the current pixmap - m_painterP->begin(this); - - m_painterP->drawPixmap(0, 0, *m_pixPixmap); - - m_painterP->end(); + double x_fact, y_fact, x_offset(0.), y_offset(0.); //Parameters to scale and center the plot on the widget + + getPlotParameters(x_fact, y_fact, x_offset, y_offset); + if(m_bAwaitingRedraw || m_pixPixmap==NULL || m_listBuffer.size()!=m_iOldSize) // If must regenerate image, draw it in the pixmap + { + delete m_pixPixmap; + m_pixPixmap=new QPixmap(width(), height()); + QPainter* painter=new QPainter; + painter->begin(m_pixPixmap); + + // Draw the margins and the background + painter->fillRect(0, 0, width(), height(), QBrush(Qt::white)); + painter->fillRect(0, 0, width(), height(), QBrush(Qt::gray, Qt::Dense4Pattern)); + + // Draw the plot + doPlot(painter, x_fact, y_fact, x_offset, y_offset); + painter->end(); + + m_bAwaitingRedraw=false; + m_iOldSize=m_listBuffer.size(); + + delete painter; + } + + // draw the current pixmap + m_painterP->begin(this); + + m_painterP->drawPixmap(0, 0, *m_pixPixmap); + + m_painterP->end(); } void QtPLWidget::doPlot(QPainter* p, double x_fact, double y_fact, double x_offset, double y_offset) { - QLineF line; - QPointF * polyline; - PLINT npts; - QVector<qreal> vect; + QLineF line; + QPointF * polyline; + PLINT npts; + QVector<qreal> vect; QRectF rect; QPen SolidPen; @@ -892,8 +892,8 @@ p->setPen(SolidPen); bool hasPen=true; - p->setRenderHints(QPainter::Antialiasing, true); - + p->setRenderHints(QPainter::Antialiasing, true); + QBrush SolidBrush(Qt::SolidPattern); p->setBrush(SolidBrush); @@ -903,33 +903,33 @@ p->setTransform(trans); - if(m_listBuffer.empty()) - { + if(m_listBuffer.empty()) + { p->fillRect(0, 0, 1, 1, QBrush()); - return; - } - // unrolls the buffer and draws each element accordingly - for(QLinkedList<BufferElement>::const_iterator i=m_listBuffer.begin(); i!=m_listBuffer.end(); ++i) - { - switch(i->Element) - { - case LINE: + return; + } + // unrolls the buffer and draws each element accordingly + for(QLinkedList<BufferElement>::const_iterator i=m_listBuffer.begin(); i!=m_listBuffer.end(); ++i) + { + switch(i->Element) + { + case LINE: if(!hasPen) { p->setPen(SolidPen); hasPen=true; } p->drawLine(*(i->Data.Line)); - break; - - case POLYLINE: + break; + + case POLYLINE: if(!hasPen) - { + { p->setPen(SolidPen); hasPen=true; - } + } p->drawPolyline(*(i->Data.Polyline)); - break; + break; case RECTANGLE: p->setRenderHints(QPainter::Antialiasing, false); @@ -942,18 +942,18 @@ p->setRenderHints(QPainter::Antialiasing, true); break; - case POLYGON: + case POLYGON: p->setRenderHints(QPainter::Antialiasing, false); if(hasPen) - { + { p->setPen(NoPen); hasPen=false; - } + } p->drawConvexPolygon(*(i->Data.Polyline)); p->setRenderHints(QPainter::Antialiasing, true); - break; + break; - case TEXT: + case TEXT: if(!hasPen) { p->setPen(SolidPen); @@ -962,19 +962,19 @@ p->save(); p->resetTransform(); - renderText(p, i->Data.TextStruct, x_fact, x_offset, y_fact, y_offset); + renderText(p, i->Data.TextStruct, x_fact, x_offset, y_fact, y_offset); p->restore(); - break; - - case SET_WIDTH: + break; + + case SET_WIDTH: SolidPen.setWidthF(i->Data.intParam); if(hasPen) { p->setPen(SolidPen); } - break; - - case SET_COLOUR: + break; + + case SET_COLOUR: SolidPen.setColor(QColor(i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A)); if(hasPen) { @@ -982,102 +982,102 @@ } SolidBrush.setColor(QColor(i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A)); p->setBrush(SolidBrush); - break; + break; - case SET_BG_COLOUR: + case SET_BG_COLOUR: SolidBrush.setColor(QColor(i->Data.ColourStruct->R, i->Data.ColourStruct->G, i->Data.ColourStruct->B, i->Data.ColourStruct->A)); p->fillRect(0., 0., m_dWidth, m_dHeight, SolidBrush); - break; + break; - default: - break; - } - } + default: + break; + } + } } void QtPLWidget::getPlotParameters(double & io_dXFact, double & io_dYFact, double & io_dXOffset, double & io_dYOffset) { - double w=(double)width(); - double h=(double)height(); - if(w/h>m_dAspectRatio) //Too wide, h is the limitating factor - { - io_dYFact=h/m_dHeight; - io_dXFact=h*m_dAspectRatio/m_dWidth; - io_dYOffset=0.; - io_dXOffset=(w-io_dXFact*m_dWidth)/2.; - } - else - { - io_dXFact=w/m_dWidth; - io_dYFact=w/m_dAspectRatio/m_dHeight; - io_dXOffset=0.; - io_dYOffset=(h-io_dYFact*m_dHeight)/2.; - } + double w=(double)width(); + double h=(double)height(); + if(w/h>m_dAspectRatio) //Too wide, h is the limitating factor + { + io_dYFact=h/m_dHeight; + io_dXFact=h*m_dAspectRatio/m_dWidth; + io_dYOffset=0.; + io_dXOffset=(w-io_dXFact*m_dWidth)/2.; + } + else + { + io_dXFact=w/m_dWidth; + io_dYFact=w/m_dAspectRatio/m_dHeight; + io_dXOffset=0.; + io_dYOffset=(h-io_dYFact*m_dHeight)/2.; + } } #endif #if defined(PLD_extqt) QtExtWidget::QtExtWidget(int i_iWidth, int i_iHeight, QWidget* parent): - QtPLWidget(i_iWidth, i_iHeight, parent) + QtPLWidget(i_iWidth, i_iHeight, parent) { - cursorParameters.isTracking=false; - cursorParameters.cursor_x=-1.0; - cursorParameters.cursor_y=-1.0; - killed=false; + cursorParameters.isTracking=false; + cursorParameters.cursor_x=-1.0; + cursorParameters.cursor_y=-1.0; + killed=false; } QtExtWidget::~QtExtWidget() { - killed=true; - QCoreApplication::processEvents(QEventLoop::AllEvents, 10); - delete m_pixPixmap; - delete m_painterP; - m_pixPixmap=NULL; - m_painterP=NULL; + killed=true; + QCoreApplication::processEvents(QEventLoop::AllEvents, 10); + delete m_pixPixmap; + delete m_painterP; + m_pixPixmap=NULL; + m_painterP=NULL; } void QtExtWidget::captureMousePlotCoords(PLFLT* x, PLFLT* y) { - setMouseTracking(true); - cursorParameters.isTracking=true; - cursorParameters.cursor_x= - cursorParameters.cursor_y=-1.; - do - { - QCoreApplication::processEvents(QEventLoop::AllEvents, 10); - } while(cursorParameters.isTracking && !killed); - - *x=cursorParameters.cursor_x; - *y=cursorParameters.cursor_y; + setMouseTracking(true); + cursorParameters.isTracking=true; + cursorParameters.cursor_x= + cursorParameters.cursor_y=-1.; + do + { + QCoreApplication::processEvents(QEventLoop::AllEvents, 10); + } while(cursorParameters.isTracking && !killed); + + *x=cursorParameters.cursor_x; + *y=cursorParameters.cursor_y; } void QtExtWidget::mouseMoveEvent(QMouseEvent* event) { - if(!cursorParameters.isTracking) return; + if(!cursorParameters.isTracking) return; - double x_fact, y_fact, x_offset, y_offset; //Parameters to scale and center the plot on the widget - - getPlotParameters(x_fact, y_fact, x_offset, y_offset); - - cursorParameters.cursor_x=(PLFLT)event->x(); - cursorParameters.cursor_y=(PLFLT)event->y(); + double x_fact, y_fact, x_offset, y_offset; //Parameters to scale and center the plot on the widget - double ratio_x; - double ratio_y; - ratio_x=(cursorParameters.cursor_x-x_offset)/(width()-2.*x_offset); - ratio_y=(cursorParameters.cursor_y-y_offset)/(height()-2.*y_offset); + getPlotParameters(x_fact, y_fact, x_offset, y_offset); - PLFLT a,b; - PLINT c; - plcalc_world(ratio_x, 1.-ratio_y, &a, &b, &c); + cursorParameters.cursor_x=(PLFLT)event->x(); + cursorParameters.cursor_y=(PLFLT)event->y(); - if(c<0) - { - cursorParameters.cursor_x=-1.; - cursorParameters.cursor_y=-1.; - } + double ratio_x; + double ratio_y; + ratio_x=(cursorParameters.cursor_x-x_offset)/(width()-2.*x_offset); + ratio_y=(cursorParameters.cursor_y-y_offset)/(height()-2.*y_offset); - update(); + PLFLT a,b; + PLINT c; + plcalc_world(ratio_x, 1.-ratio_y, &a, &b, &c); + + if(c<0) + { + cursorParameters.cursor_x=-1.; + cursorParameters.cursor_y=-1.; + } + + update(); } void QtExtWidget::mousePressEvent(QMouseEvent* event) @@ -1086,65 +1086,65 @@ void QtExtWidget::mouseReleaseEvent(QMouseEvent* event) { - if(!cursorParameters.isTracking) return; + if(!cursorParameters.isTracking) return; - double x_fact, y_fact, x_offset, y_offset; //Parameters to scale and center the plot on the widget - - getPlotParameters(x_fact, y_fact, x_offset, y_offset); + double x_fact, y_fact, x_offset, y_offset; //Parameters to scale and center the plot on the widget + + getPlotParameters(x_fact, y_fact, x_offset, y_offset); - cursorParameters.cursor_x=(PLFLT)event->x(); - cursorParameters.cursor_y=(PLFLT)event->y(); - cursorParameters.isTracking=false; - setMouseTracking(false); + cursorParameters.cursor_x=(PLFLT)event->x(); + cursorParameters.cursor_y=(PLFLT)event->y(); + cursorParameters.isTracking=false; + setMouseTracking(false); + + double ratio_x; + double ratio_y; + ratio_x=(cursorParameters.cursor_x-x_offset)/(width()-2.*x_offset); + ratio_y=(cursorParameters.cursor_y-y_offset)/(height()-2.*y_offset); - double ratio_x; - double ratio_y; - ratio_x=(cursorParameters.cursor_x-x_offset)/(width()-2.*x_offset); - ratio_y=(cursorParameters.cursor_y-y_offset)/(height()-2.*y_offset); + PLFLT a,b; + PLINT c; + plcalc_world(ratio_x, 1.-ratio_y, &a, &b, &c); - PLFLT a,b; - PLINT c; - plcalc_world(ratio_x, 1.-ratio_y, &a, &b, &c); + if(c<0) + { + cursorParameters.cursor_x=-1.; + cursorParameters.cursor_y=-1.; + } + else + { + cursorParameters.cursor_x=a; + cursorParameters.cursor_y=b; + } - if(c<0) - { - cursorParameters.cursor_x=-1.; - cursorParameters.cursor_y=-1.; - } - else - { - cursorParameters.cursor_x=a; - cursorParameters.cursor_y=b; - } - - update(); + update(); } void QtExtWidget::paintEvent(QPaintEvent* event) { - QtPLWidget::paintEvent(event); + QtPLWidget::paintEvent(event); - if(!cursorParameters.isTracking || cursorParameters.cursor_x<0) return; + if(!cursorParameters.isTracking || cursorParameters.cursor_x<0) return; - QPainter p(this); + QPainter p(this); - p.setPen(QPen(Qt::white)); + p.setPen(QPen(Qt::white)); - p.drawLine((int)cursorParameters.cursor_x, 0, (int)cursorParameters.cursor_x, height()); - p.drawLine(0, (int)cursorParameters.cursor_y, width(), (int)cursorParameters.cursor_y); + p.drawLine((int)cursorParameters.cursor_x, 0, (int)cursorParameters.cursor_x, height()); + p.drawLine(0, (int)cursorParameters.cursor_y, width(), (int)cursorParameters.cursor_y); - p.end(); + p.end(); } void plsetqtdev(QtExtWidget* widget) { - plsc->dev = (void*)widget; + plsc->dev = (void*)widget; } void plfreeqtdev() { - delete ((QtExtWidget*)plsc->dev); - plsc->dev=NULL; + delete ((QtExtWidget*)plsc->dev); + plsc->dev=NULL; } #endif Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2009-07-31 18:07:55 UTC (rev 10195) +++ trunk/drivers/qt.cpp 2009-07-31 18:17:38 UTC (rev 10196) @@ -1,33 +1,33 @@ /* - This software is provided under the LGPL in March 2009 by the - Cluster Science Centre - QSAS team, - Imperial College, London +This software is provided under the LGPL in March 2009 by the +Cluster Science Centre +QSAS team, +Imperial College, London - Copyright (C) 2009 Imperial College, London - Copyright (C) 2009 Alan W. Irwin +Copyright (C) 2009 Imperial College, London +Copyright (C) 2009 Alan W. Irwin - This is free software; you can redistribute it and/or modify - it under the terms of the GNU General Lesser Public License as published - by the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. +This is free software; you can redistribute it and/or modify +it under the terms of the GNU General Lesser Public License as published +by the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. - This software is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. +This software is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. - To received a copy of the GNU Library General Public License - write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - History: +To received a copy of the GNU Library General Public License +write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - March 2009: v1.00 - Initial release. - +History: + + +March 2009: v1.00 +Initial release. + */ @@ -77,65 +77,65 @@ #endif ; -static DrvOpt qt_options[]={ {"text_vectorize", DRV_INT, &vectorize, "Vectorize fonts on output (0|1)"}, - {NULL, DRV_INT, NULL, NULL}}; +static DrvOpt qt_options[]={ {"text_vectorize", DRV_INT, &vectorize, "Vectorize fonts on output (0|1)"}, + {NULL, DRV_INT, NULL, NULL}}; bool initQtApp(bool isGUI) { - QMutexLocker locker(&QtPLDriver::mutex); - bool res=false; - ++appCounter; - if(qApp==NULL && appCounter==1) - { - argc=1; - argv=new char*[2]; - argv[0]=new char[10]; - argv[1]=new char[1]; - snprintf(argv[0], 10, "qt_driver"); - argv[1][0]='\0'; - new QApplication(argc, argv, isGUI); - res=true; - } - return res; + QMutexLocker locker(&QtPLDriver::mutex); + bool res=false; + ++appCounter; + if(qApp==NULL && appCounter==1) + { + argc=1; + argv=new char*[2]; + argv[0]=new char[10]; + argv[1]=new char[1]; + snprintf(argv[0], 10, "qt_driver"); + argv[1][0]='\0'; + new QApplication(argc, argv, isGUI); + res=true; + } + return res; } void closeQtApp() { - QMutexLocker locker(&QtPLDriver::mutex); - --appCounter; - if(qApp!=NULL && appCounter==0) - { - delete qApp; - delete[] argv[0]; - delete[] argv[1]; - delete[] argv; - argv=NULL; - } + QMutexLocker locker(&QtPLDriver::mutex); + --appCounter; + if(qApp!=NULL && appCounter==0) + { + delete qApp; + delete[] argv[0]; + delete[] argv[1]; + delete[] argv; + argv=NULL; + } } /*--------------------------------------------------------------------- - qt_family_check () - - support function to help supress more than one page if family file - output not specified by the user (e.g., with the -fam command-line option). - Adapted directly from svg.c - ---------------------------------------------------------------------*/ +qt_family_check () + +support function to help supress more than one page if family file +output not specified by the user (e.g., with the -fam command-line option). +Adapted directly from svg.c +---------------------------------------------------------------------*/ static int already_warned = 0; static int qt_family_check(PLStream *pls) { - if (pls->family || pls->page == 1) - { - return 0; - } - else - { - if(! already_warned) + if (pls->family || pls->page == 1) { - already_warned = 1; - plwarn("All pages after the first skipped because family file output not specified.\n"); + return 0; } - return 1; - } + else + { + if(! already_warned) + { + already_warned = 1; + plwarn("All pages after the first skipped because family file output not specified.\n"); + } + return 1; + } } // Declaration of the driver-specific interface functions @@ -233,175 +233,175 @@ #if defined (PLD_bmpqt) || defined(PLD_jpgqt) || defined (PLD_pngqt) || defined(PLD_ppmqt) || defined(PLD_tiffqt) void plD_init_rasterqt(PLStream * pls) { - double dpi; - - vectorize=0; - plParseDrvOpts(qt_options); - - /* Stream setup */ - pls->color = 1; - pls->plbuf_write=0; - pls->dev_fill0 = 1; - pls->dev_fill1 = 0; - /* Let the PLplot core handle dashed lines since - * the driver results for this capability have a number of issues. - pls->dev_dash=1; */ - pls->dev_dash=0; - pls->dev_flush=1; - /* Driver does not have a clear capability so use (good) PLplot core - * fallback for that instead. */ - pls->dev_clear=0; - pls->termin=0; - pls->page = 0; - pls->dev_text = 1; // want to draw text - pls->dev_unicode = 1; // want unicode - - bool isMaster=initQtApp(/*false*/true); // Is it still a problem? - - if (pls->xdpi <=0.) - dpi = DEFAULT_DPI; - else - dpi = pls->xdpi; + double dpi; + + vectorize=0; + plParseDrvOpts(qt_options); + + /* Stream setup */ + pls->color = 1; + pls->plbuf_write=0; + pls->dev_fill0 = 1; + pls->dev_fill1 = 0; + /* Let the PLplot core handle dashed lines since + * the driver results for this capability have a number of issues. + pls->dev_dash=1; */ + pls->dev_dash=0; + pls->dev_flush=1; + /* Driver does not have a clear capability so use (good) PLplot core + * fallback for that instead. */ + pls->dev_clear=0; + pls->termin=0; + pls->page = 0; + pls->dev_text = 1; // want to draw text + pls->dev_unicode = 1; // want unicode - // Shamelessly copied on the Cairo stuff :) - if (pls->xlength <= 0 || pls->ylength <= 0) - { - pls->dev=new QtRasterDevice; - pls->xlength = (PLINT)(((QtRasterDevice*)(pls->dev))->m_dWidth); - pls->ylength = (PLINT)(((QtRasterDevice*)(pls->dev))->m_dHeight); - } - else - { - pls->dev=new QtRasterDevice(pls->xlength, pls->ylength); - } + bool isMaster=initQtApp(/*false*/true); // Is it still a problem? + + if (pls->xdpi <=0.) + dpi = DEFAULT_DPI; + else + dpi = pls->xdpi; + + // Shamelessly copied on the Cairo stuff :) + if (pls->xlength <= 0 || pls->ylength <= 0) + { + pls->dev=new QtRasterDevice; + pls->xlength = (PLINT)(((QtRasterDevice*)(pls->dev))->m_dWidth); + pls->ylength = (PLINT)(((QtRasterDevice*)(pls->dev))->m_dHeight); + } + else + { + pls->dev=new QtRasterDevice(pls->xlength, pls->ylength); + } - if(isMaster) handler.setMasterDevice((QtRasterDevice*)(pls->dev)); + if(isMaster) handler.setMasterDevice((QtRasterDevice*)(pls->dev)); - if (pls->xlength > pls->ylength) - ((QtRasterDevice*)(pls->dev))->downscale = (PLFLT)pls->xlength/(PLFLT)(PIXELS_X-1); - else - ((QtRasterDevice*)(pls->dev))->downscale = (PLFLT)pls->ylength/(PLFLT)PIXELS_Y; - - plP_setphy((PLINT) 0, (PLINT) (pls->xlength / ((QtRasterDevice*)(pls->dev))->downscale), (PLINT) 0, (PLINT) (pls->ylength / ((QtRasterDevice*)(pls->dev))->downscale)); - - plP_setpxl(dpi/25.4/((QtRasterDevice*)(pls->dev))->downscale, dpi/25.4/((QtRasterDevice*)(pls->dev))->downscale); - - ((QtRasterDevice*)(pls->dev))->setResolution(dpi); + if (pls->xlength > pls->ylength) + ((QtRasterDevice*)(pls->dev))->downscale = (PLFLT)pls->xlength/(PLFLT)(PIXELS_X-1); + else + ((QtRasterDevice*)(pls->dev))->downscale = (PLFLT)pls->ylength/(PLFLT)PIXELS_Y; + + plP_setphy((PLINT) 0, (PLINT) (pls->xlength / ((QtRasterDevice*)(pls->dev))->downscale), (PLINT) 0, (PLINT) (pls->ylength / ((QtRasterDevice*)(pls->dev))->downscale)); + + plP_setpxl(dpi/25.4/((QtRasterDevice*)(pls->dev))->downscale, dpi/25.4/((QtRasterDevice*)(pls->dev))->downscale); + + ((QtRasterDevice*)(pls->dev))->setResolution(dpi); - /* Initialize family file info */ - plFamInit(pls); - - plOpenFile(pls); + /* Initialize family file info */ + plFamInit(pls); + + plOpenFile(pls); } void plD_eop_rasterqt(PLStream *pls) { - if(qt_family_check(pls)) {return;} - ((QtRasterDevice *)pls->dev)->savePlot(); - handler.DeviceChangedPage((QtRasterDevice *)pls->dev); + if(qt_family_check(pls)) {return;} + ((QtRasterDevice *)pls->dev)->savePlot(); + handler.DeviceChangedPage((QtRasterDevice *)pls->dev); } void plD_line_rasterqt(PLStream * pls, short x1a, short y1a, short x2a, short y2a) { - QtRasterDevice* widget=(QtRasterDevice*)pls->dev; - if(widget!=NULL && qt_family_check(pls)) {return;} - if(widget==NULL) return; + QtRasterDevice* widget=(QtRasterDevice*)pls->dev; + if(widget!=NULL && qt_family_check(pls)) {return;} + if(widget==NULL) return; - widget->QtPLDriver::setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, pls->curcolor.a); - widget->drawLine(x1a, y1a, x2a, y2a); + widget->QtPLDriver::setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, pls->curcolor.a); + widget->drawLine(x1a, y1a, x2a, y2a); } void plD_polyline_rasterqt(PLStream *pls, short *xa, short *ya, PLINT npts) { - QtRasterDevice * widget=(QtRasterDevice *) pls->dev; - if(widget!=NULL && qt_family_check(pls)) {return;} - if(widget==NULL) return; + QtRasterDevice * widget=(QtRasterDevice *) pls->dev; + if(widget!=NULL && qt_family_check(pls)) {return;} + if(widget==NULL) return; - widget->QtPLDriver::setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, pls->curcolor.a); - widget->drawPolyline(xa, ya, npts); + widget->QtPLDriver::setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, pls->curcolor.a); + widget->drawPolyline(xa, ya, npts); } void plD_esc_rasterqt(PLStream * pls, PLINT op, void* ptr) { - short *xa, *ya; - PLINT i, j; - QtRasterDevice * widget=(QtRasterDevice *) pls->dev; - if(widget!=NULL && qt_family_check(pls)) {return;} - if(widget==NULL) return; - - switch(op) - { + short *xa, *ya; + PLINT i, j; + QtRasterDevice * widget=(QtRasterDevice *) pls->dev; + if(widget!=NULL && qt_family_check(pls)) {return;} + if(widget==NULL) return; + + switch(op) + { // case PLESC_DASH: // widget->setDashed(pls->nms, pls->mark, pls->space); // widget->QtPLDriver::setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b, pls->curcolor.a); // ... [truncated message content] |
From: <hez...@us...> - 2009-08-02 05:29:29
|
Revision: 10197 http://plplot.svn.sourceforge.net/plplot/?rev=10197&view=rev Author: hezekiahcarty Date: 2009-08-02 05:29:20 +0000 (Sun, 02 Aug 2009) Log Message: ----------- Add plarc to core, along with OCaml bindings. Example 3 (C and OCaml) has also been updated to use plarc to draw polar grid circles. Modified Paths: -------------- trunk/bindings/ocaml/plplot_h trunk/bindings/ocaml/plplot_h.inc trunk/drivers/cairo.c trunk/examples/c/x03c.c trunk/examples/ocaml/x03.ml trunk/include/plplot.h trunk/include/plplotP.h trunk/include/plstrm.h trunk/src/CMakeLists.txt Added Paths: ----------- trunk/src/plarc.c Modified: trunk/bindings/ocaml/plplot_h =================================================================== --- trunk/bindings/ocaml/plplot_h 2009-07-31 18:17:38 UTC (rev 10196) +++ trunk/bindings/ocaml/plplot_h 2009-08-02 05:29:20 UTC (rev 10197) @@ -55,6 +55,10 @@ c_plcalc_world(PLFLT rx, PLFLT ry, PLFLT *wx, PLFLT *wy, PLINT *window); void +c_plarc(PLFLT x, PLFLT y, PLFLT a, PLFLT b, PLFLT angle1, PLFLT angle2, + PLBOOL fill); + + void c_plclear(void); void Modified: trunk/bindings/ocaml/plplot_h.inc =================================================================== --- trunk/bindings/ocaml/plplot_h.inc 2009-07-31 18:17:38 UTC (rev 10196) +++ trunk/bindings/ocaml/plplot_h.inc 2009-08-02 05:29:20 UTC (rev 10197) @@ -8,6 +8,7 @@ [mlname(plbox)] void c_plbox ( [string] const char * xopt, double xtick, int nxsub, [string] const char * yopt, double ytick, int nysub ); [mlname(plbox3)] void c_plbox3 ( [string] const char * xopt, [string] const char * xlabel, double xtick, int nsubx, [string] const char * yopt, [string] const char * ylabel, double ytick, int nsuby, [string] const char * zopt, [string] const char * zlabel, double ztick, int nsubz ); [mlname(plcalc_world)] void c_plcalc_world ( double rx, double ry, [out] double * wx, [out] double * wy, [out] int * window ); +[mlname(plarc)] void c_plarc ( double x, double y, double a, double b, double angle1, double angle2, boolean fill ); [mlname(plclear)] void c_plclear ( void ); [mlname(plcol0)] void c_plcol0 ( int icol0 ); [mlname(plcol1)] void c_plcol1 ( double col1 ); Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2009-07-31 18:17:38 UTC (rev 10196) +++ trunk/drivers/cairo.c 2009-08-02 05:29:20 UTC (rev 10197) @@ -215,6 +215,7 @@ static void set_current_context(PLStream *); static void poly_line(PLStream *, short *, short *, PLINT); static void filled_polygon(PLStream *pls, short *xa, short *ya, PLINT npts); +static void arc(PLStream *, arc_struct *); static void rotate_cairo_surface(PLStream *, float, float, float, float, float, float); /* Rasterization of plotted material */ static void start_raster(PLStream*); @@ -487,6 +488,9 @@ case PLESC_END_RASTERIZE: /* End offscreen/rasterized rendering */ end_raster(pls); break; + case PLESC_ARC: /* Draw an arc, either filled or outline */ + arc(pls, (arc_struct *) ptr); + break; } } @@ -1016,6 +1020,7 @@ pls->alt_unicode = 1; /* Wants to handle unicode character by character */ pls->page = 0; pls->dev_fill0 = 1; /* Supports hardware solid fills */ + pls->dev_arc = 1; /* Supports driver-level arcs */ pls->plbuf_write = 1; /* Activate plot buffer */ @@ -1173,6 +1178,60 @@ } /*--------------------------------------------------------------------- + arc() + + Draws an arc, possibly filled. + ---------------------------------------------------------------------*/ + +void arc(PLStream *pls, arc_struct *arc_info) +{ + PLCairo *aStream; + double x, y, a, b; + double angle1, angle2; + + set_current_context(pls); + + aStream = (PLCairo *)pls->dev; + + /* Scale to the proper Cairo coordinates */ + x = aStream->downscale * arc_info->x; + y = aStream->downscale * arc_info->y; + a = aStream->downscale * arc_info->a; + b = aStream->downscale * arc_info->b; + + /* Degrees to radians */ + angle1 = arc_info->angle1 * M_PI / 180.0; + angle2 = arc_info->angle2 * M_PI / 180.0; + + cairo_save(aStream->cairoContext); + + /* Clip the output to the plotting window */ + set_clip(pls); + + /* Make sure the arc is properly shaped and oriented */ + cairo_save(aStream->cairoContext); + cairo_translate(aStream->cairoContext, x, y); + cairo_scale(aStream->cairoContext, a, b); + cairo_arc(aStream->cairoContext, 0.0, 0.0, 1.0, angle1, angle2); + if (arc_info->fill) + cairo_line_to(aStream->cairoContext, 0.0, 0.0); + cairo_restore(aStream->cairoContext); + + cairo_set_source_rgba(aStream->cairoContext, + (double)pls->curcolor.r/255.0, + (double)pls->curcolor.g/255.0, + (double)pls->curcolor.b/255.0, + (double)pls->curcolor.a); + if (arc_info->fill) { + cairo_fill(aStream->cairoContext); + } + else { + cairo_stroke(aStream->cairoContext); + } + cairo_restore(aStream->cairoContext); +} + +/*--------------------------------------------------------------------- rotate_cairo_surface() Rotates the cairo surface to the appropriate orientation. Modified: trunk/examples/c/x03c.c =================================================================== --- trunk/examples/c/x03c.c 2009-07-31 18:17:38 UTC (rev 10196) +++ trunk/examples/c/x03c.c 2009-08-02 05:29:20 UTC (rev 10197) @@ -41,15 +41,9 @@ /* Set up viewport and window, but do not draw box */ plenv(-1.3, 1.3, -1.3, 1.3, 1, -2); - for (i = 1; i <= 10; i++) { - for (j = 0; j <= 360; j++) { - x[j] = 0.1 * i * x0[j]; - y[j] = 0.1 * i * y0[j]; - } - /* Draw circles for polar grid */ - - plline(361, x, y); + for (i = 1; i <= 10; i++) { + plarc(0.0, 0.0, 0.1 * i, 0.1 * i, 0.0, 360.0, 0); } plcol0(2); Modified: trunk/examples/ocaml/x03.ml =================================================================== --- trunk/examples/ocaml/x03.ml 2009-07-31 18:17:38 UTC (rev 10196) +++ trunk/examples/ocaml/x03.ml 2009-08-02 05:29:20 UTC (rev 10197) @@ -1,7 +1,7 @@ (* $Id$ Polar plot demo. - Copyright (C) 2008 Hezekiah M. Carty + Copyright (C) 2008, 2009 Hezekiah M. Carty This file is part of PLplot. @@ -48,10 +48,9 @@ (* Set up viewport and window, but do not draw box *) plenv (-1.3) 1.3 (-1.3) 1.3 1 (-2); for i = 1 to 10 do - let x = Array.init 361 (fun j -> 0.1 *. float_of_int i *. x0.(j)) in - let y = Array.init 361 (fun j -> 0.1 *. float_of_int i *. y0.(j)) in (* Draw circles for polar grid *) - plline x y; + let r = 0.1 *. float_of_int i in + plarc 0.0 0.0 r r 0.0 360.0 false; done; plcol0 2; Modified: trunk/include/plplot.h =================================================================== --- trunk/include/plplot.h 2009-07-31 18:17:38 UTC (rev 10196) +++ trunk/include/plplot.h 2009-08-02 05:29:20 UTC (rev 10197) @@ -235,6 +235,7 @@ #define PLESC_END_TEXT 31 /* finish a drawing a line of text */ #define PLESC_START_RASTERIZE 32 /* start rasterized rendering */ #define PLESC_END_RASTERIZE 33 /* end rasterized rendering */ +#define PLESC_ARC 34 /* render an arc */ /* Alternative unicode text handling control characters */ #define PLTEXT_FONTCHANGE 0 /* font change in the text stream */ @@ -518,6 +519,7 @@ #define plbox c_plbox #define plbox3 c_plbox3 #define plcalc_world c_plcalc_world +#define plarc c_plarc #define plclear c_plclear #define plcol0 c_plcol0 #define plcol1 c_plcol1 @@ -771,6 +773,12 @@ PLDLLIMPEXP void c_plcalc_world(PLFLT rx, PLFLT ry, PLFLT *wx, PLFLT *wy, PLINT *window); +/* Plot an arc */ + +PLDLLIMPEXP void +c_plarc(PLFLT x, PLFLT y, PLFLT a, PLFLT b, PLFLT angle1, PLFLT angle2, + PLBOOL fill); + /* Clear current subpage. */ PLDLLIMPEXP void Modified: trunk/include/plplotP.h =================================================================== --- trunk/include/plplotP.h 2009-07-31 18:17:38 UTC (rev 10196) +++ trunk/include/plplotP.h 2009-08-02 05:29:20 UTC (rev 10197) @@ -932,6 +932,17 @@ plP_image(PLFLT *z, PLINT nx, PLINT ny, PLFLT xmin, PLFLT ymin, PLFLT dx, PLFLT dy, void (*pltr) (PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer), PLPointer pltr_data); +/* Structure for holding arc data */ +typedef struct { + PLFLT x; + PLFLT y; + PLFLT a; + PLFLT b; + PLFLT angle1; + PLFLT angle2; + PLBOOL fill; +} arc_struct; + /* End of page */ PLDLLIMPEXP void Modified: trunk/include/plstrm.h =================================================================== --- trunk/include/plstrm.h 2009-07-31 18:17:38 UTC (rev 10196) +++ trunk/include/plstrm.h 2009-08-02 05:29:20 UTC (rev 10197) @@ -531,7 +531,7 @@ PLINT color, colorset; PLINT family, member, finc, fflen, bytemax, famadv; PLINT dev_fill0, dev_fill1, dev_dash, dev_di, dev_flush, dev_swin; - PLINT dev_text, dev_xor, dev_clear, dev_fastimg; + PLINT dev_text, dev_xor, dev_clear, dev_fastimg, dev_arc; char DevName[80]; FILE *OutFile; Modified: trunk/src/CMakeLists.txt =================================================================== --- trunk/src/CMakeLists.txt 2009-07-31 18:17:38 UTC (rev 10196) +++ trunk/src/CMakeLists.txt 2009-08-02 05:29:20 UTC (rev 10197) @@ -21,6 +21,7 @@ set(plplot${LIB_TAG}_LIB_SRCS pdfutils.c + plarc.c plargs.c plbox.c plcont.c Added: trunk/src/plarc.c =================================================================== --- trunk/src/plarc.c (rev 0) +++ trunk/src/plarc.c 2009-08-02 05:29:20 UTC (rev 10197) @@ -0,0 +1,138 @@ +/* plarc() + * + * Copyright (C) 2009 Hezekiah M. Carty + * + * This file is part of PLplot. + * + * PLplot is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Library Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * PLplot is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with PLplot; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "plplotP.h" + +#define CIRCLE_SEGMENTS PL_MAXPOLY +#define DEG_TO_RAD(x) ((x) * M_PI / 180.0) + +#define PLARC_POINT_X(x, a, b, theta) ((x) + ((a) * cos(theta))) +#define PLARC_POINT_Y(y, a, b, theta) ((y) + ((b) * sin(theta))) + +/*------------------------------------------------------------------------- + * plarc_approx : Plot an approximated arc with a series of lines + * + * Takes the same arguments, with the same units, as c_plarc below. + * + *-------------------------------------------------------------------------*/ +void +plarc_approx(PLFLT x, PLFLT y, PLFLT a, PLFLT b, PLFLT angle1, PLFLT angle2, PLBOOL fill) +{ + PLINT i; + PLFLT theta0, theta_step, theta, d_angle; + PLINT segments; + PLFLT xs[CIRCLE_SEGMENTS], ys[CIRCLE_SEGMENTS]; + + /* The difference between the start and end angles */ + d_angle = DEG_TO_RAD(angle2 - angle1); + if (fabs(d_angle) > M_PI * 2.0) + d_angle = M_PI * 2.0; + + /* The number of line segments used to approximate the arc */ + segments = d_angle / (2.0 * M_PI) * CIRCLE_SEGMENTS; + /* Always use at least 2 arc points, otherwise fills will break. */ + if (segments < 2) + segments = 2; + /* The start angle in radians and number of radians in each approximating + segment. */ + theta0 = DEG_TO_RAD(angle1); + + theta_step = d_angle / (segments - 1); + + /* The coordinates for the circle outline */ + for (i = 0; i < segments; i++) { + theta = theta0 + theta_step * (PLFLT) i; + xs[i] = PLARC_POINT_X(x, a, b, theta); + ys[i] = PLARC_POINT_Y(y, a, b, theta); + } + + if (fill) { + /* Add the center point if we aren't drawing a circle */ + if (fabs(d_angle) < M_PI * 2.0) { + xs[segments - 1] = x; + ys[segments - 1] = y; + } + /* Draw a filled arc */ + plfill(segments, xs, ys); + } + else { + /* Draw the arc outline */ + plline(segments, xs, ys); + } +} + +/*------------------------------------------------------------------------- + * plarc : Plot an arc + * + * Takes the following arguments: + * + * x, y: + * x and y coordinates for the center of the arc + * + * a, b: + * Radius of the arc's major and minor axes + * + * angle1: + * Start angle (degrees) + * + * angle2: + * End angle (degrees) + * + * fill: + * Should the arc be filled? + * + *-------------------------------------------------------------------------*/ +void +c_plarc(PLFLT x, PLFLT y, PLFLT a, PLFLT b, PLFLT angle1, PLFLT angle2, PLBOOL fill) +{ + PLINT xscl[2], yscl[2]; + PLINT clpxmi, clpxma, clpymi, clpyma; + PLFLT orientation_offset, orientation; + arc_struct *arc_info; + + /* TODO: For now, only unrotated plots use the driver-accelerated path. */ + if (plsc->dev_arc && plsc->diorot == 0) { + arc_info = (arc_struct *) malloc((size_t) sizeof(arc_struct)); + + xscl[0] = plP_wcpcx(x-a); + xscl[1] = plP_wcpcx(x+a); + yscl[0] = plP_wcpcy(y-b); + yscl[1] = plP_wcpcy(y+b); + difilt(xscl,yscl,2,&clpxmi,&clpxma,&clpymi,&clpyma); + + arc_info->x = 0.5 * (xscl[1] + xscl[0]); + arc_info->y = 0.5 * (yscl[1] + yscl[0]); + arc_info->a = 0.5 * (xscl[1] - xscl[0]); + arc_info->b = 0.5 * (yscl[1] - yscl[0]); + + arc_info->angle1 = angle1; + arc_info->angle2 = angle2; + arc_info->fill = fill; + + plP_esc(PLESC_ARC, arc_info); + + free(arc_info); + } + else { + plarc_approx(x, y, a, b, angle1, angle2, fill); + } +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-08-03 20:32:20
|
Revision: 10205 http://plplot.svn.sourceforge.net/plplot/?rev=10205&view=rev Author: airwin Date: 2009-08-03 20:32:05 +0000 (Mon, 03 Aug 2009) Log Message: ----------- The qt code that is generated by moc is now done just in one place (the include subdirectory) to remove a lot of duplication. The plplotqt library, dynamic qt device, and static qt device builds all now depend on these moc-generated results through a target-level dependency. Modified Paths: -------------- trunk/bindings/qt_gui/CMakeLists.txt trunk/drivers/CMakeLists.txt trunk/include/CMakeLists.txt trunk/src/CMakeLists.txt Modified: trunk/bindings/qt_gui/CMakeLists.txt =================================================================== --- trunk/bindings/qt_gui/CMakeLists.txt 2009-08-03 19:27:12 UTC (rev 10204) +++ trunk/bindings/qt_gui/CMakeLists.txt 2009-08-03 20:32:05 UTC (rev 10205) @@ -27,7 +27,6 @@ ${CMAKE_SOURCE_DIR}/drivers ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/include - ${CMAKE_CURRENT_BINARY_DIR} ) if(qt_COMPILE_FLAGS) set_source_files_properties( @@ -41,56 +40,12 @@ PROPERTIES COMPILE_FLAGS "-DUSINGDLL" ) endif(qt_COMPILE_FLAGS) - set(MOC_OPTIONS) - if(PLD_bmpqt) - list(APPEND MOC_OPTIONS -DPLD_bmpqt) - endif(PLD_bmpqt) - if(PLD_jpgqt) - list(APPEND MOC_OPTIONS -DPLD_jpgqt) - endif(PLD_jpgqt) - if(PLD_pngqt) - list(APPEND MOC_OPTIONS -DPLD_pngqt) - endif(PLD_pngqt) - if(PLD_ppmqt) - list(APPEND MOC_OPTIONS -DPLD_ppmqt) - endif(PLD_ppmqt) - if(PLD_tiffqt) - list(APPEND MOC_OPTIONS -DPLD_tiffqt) - endif(PLD_tiffqt) - if(PLD_svgqt) - list(APPEND MOC_OPTIONS -DPLD_svgqt) - endif(PLD_svgqt) - if(PLD_epsqt) - list(APPEND MOC_OPTIONS -DPLD_epsqt) - endif(PLD_epsqt) - if(PLD_pdfqt) - list(APPEND MOC_OPTIONS -DPLD_pdfqt) - endif(PLD_pdfqt) - if(PLD_qtwidget) - list(APPEND MOC_OPTIONS -DPLD_qtwidget) - endif(PLD_qtwidget) - if(PLD_extqt) - list(APPEND MOC_OPTIONS -DPLD_extqt) - endif(PLD_extqt) - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/moc_files.h "/* Generated header file listing the moc generated files to include in plqt.cpp. */ \n#ifndef __MOC_FILES_H__\n#define __MOC_FILES_H__\n\n") - if(MOC_OPTIONS) - qt4_wrap_cpp( - QT_MOC_OUTFILES - ${CMAKE_SOURCE_DIR}/include/qt.h - OPTIONS ${MOC_OPTIONS} - ) - # CMake does not handle dependencies correctly for GENERATED source - # code that is #included by a header that is created at cmake time. - # Therefore, use fundamental means to force correct dependencies. - add_custom_target(moc_outfile_generated DEPENDS ${QT_MOC_OUTFILES}) - file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/moc_files.h "#include \"${QT_MOC_OUTFILES}\"\n") + if(ANY_QT_DEVICE) add_library(plplotqt${LIB_TAG} ${qt_SOURCE}) add_dependencies(plplotqt${LIB_TAG} moc_outfile_generated) - else(MOC_OPTIONS) - add_library(plplotqt${LIB_TAG} ${qt_SOURCE}) - endif(MOC_OPTIONS) - file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/moc_files.h "#endif /* __MOC_FILES_H__i */ \n") - + else(ANY_QT_DEVICE) + message(FATAL_ERROR "Internal build system inconsistency between ENABLE_qt true and ANY_QT_DEVICE false.") + endif(ANY_QT_DEVICE) #message("qt_LINK_FLAGS = ${qt_LINK_FLAGS}") target_link_libraries( plplotqt${LIB_TAG} Modified: trunk/drivers/CMakeLists.txt =================================================================== --- trunk/drivers/CMakeLists.txt 2009-08-03 19:27:12 UTC (rev 10204) +++ trunk/drivers/CMakeLists.txt 2009-08-03 20:32:05 UTC (rev 10205) @@ -30,7 +30,6 @@ ${CMAKE_SOURCE_DIR}/lib/qsastime ${CMAKE_SOURCE_DIR}/lib/nistcd ${CMAKE_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR}/include ) @@ -84,55 +83,12 @@ ) endif(${SOURCE_ROOT_NAME}_COMPILE_FLAGS) if(SOURCE_ROOT_NAME STREQUAL "qt" AND NOT ENABLE_qt) - set(MOC_OPTIONS) - if(PLD_bmpqt) - list(APPEND MOC_OPTIONS -DPLD_bmpqt) - endif(PLD_bmpqt) - if(PLD_jpgqt) - list(APPEND MOC_OPTIONS -DPLD_jpgqt) - endif(PLD_jpgqt) - if(PLD_pngqt) - list(APPEND MOC_OPTIONS -DPLD_pngqt) - endif(PLD_pngqt) - if(PLD_ppmqt) - list(APPEND MOC_OPTIONS -DPLD_ppmqt) - endif(PLD_ppmqt) - if(PLD_tiffqt) - list(APPEND MOC_OPTIONS -DPLD_tiffqt) - endif(PLD_tiffqt) - if(PLD_svgqt) - list(APPEND MOC_OPTIONS -DPLD_svgqt) - endif(PLD_svgqt) - if(PLD_epsqt) - list(APPEND MOC_OPTIONS -DPLD_epsqt) - endif(PLD_epsqt) - if(PLD_pdfqt) - list(APPEND MOC_OPTIONS -DPLD_pdfqt) - endif(PLD_pdfqt) - if(PLD_qtwidget) - list(APPEND MOC_OPTIONS -DPLD_qtwidget) - endif(PLD_qtwidget) - if(PLD_extqt) - list(APPEND MOC_OPTIONS -DPLD_extqt) - endif(PLD_extqt) - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/moc_files.h "/* Generated header file listing the moc generated files to include in plqt.cpp. */ \n#ifndef __MOC_FILES_H__\n#define __MOC_FILES_H__\n\n") - if(MOC_OPTIONS) - qt4_wrap_cpp( - QT_MOC_OUTFILES - ${CMAKE_SOURCE_DIR}/include/qt.h - OPTIONS ${MOC_OPTIONS} - ) - # CMake does not handle dependencies correctly for GENERATED source - # code that is #included by a header that is created at cmake time. - # Therefore, use fundamental means to force correct dependencies. - add_custom_target(moc_outfile_generated DEPENDS ${QT_MOC_OUTFILES}) - file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/moc_files.h "#include \"${QT_MOC_OUTFILES}\"\n") + if(ANY_QT_DEVICE) add_library(${SOURCE_ROOT_NAME} MODULE ${${SOURCE_ROOT_NAME}_SOURCE}) add_dependencies(${SOURCE_ROOT_NAME} moc_outfile_generated) - else(MOC_OPTIONS) - add_library(${SOURCE_ROOT_NAME} MODULE ${${SOURCE_ROOT_NAME}_SOURCE}) - endif(MOC_OPTIONS) - file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/moc_files.h "#endif /* __MOC_FILES_H__i */ \n") + else(ANY_QT_DEVICE) + message(FATAL_ERROR "Internal build system inconsistency. Attempt to build dynamic qt device when ANY_QT_DEVICE is false.") + endif(ANY_QT_DEVICE) else(SOURCE_ROOT_NAME STREQUAL "qt" AND NOT ENABLE_qt) add_library(${SOURCE_ROOT_NAME} MODULE ${${SOURCE_ROOT_NAME}_SOURCE}) endif(SOURCE_ROOT_NAME STREQUAL "qt" AND NOT ENABLE_qt) Modified: trunk/include/CMakeLists.txt =================================================================== --- trunk/include/CMakeLists.txt 2009-08-03 19:27:12 UTC (rev 10204) +++ trunk/include/CMakeLists.txt 2009-08-03 20:32:05 UTC (rev 10205) @@ -87,5 +87,54 @@ list(APPEND include_INSTALLED_HEADERS qt.h) endif(PLD_qtwidget OR PLD_extqt) +if(ANY_QT_DEVICE) + set(MOC_OPTIONS) + if(PLD_bmpqt) + list(APPEND MOC_OPTIONS -DPLD_bmpqt) + endif(PLD_bmpqt) + if(PLD_jpgqt) + list(APPEND MOC_OPTIONS -DPLD_jpgqt) + endif(PLD_jpgqt) + if(PLD_pngqt) + list(APPEND MOC_OPTIONS -DPLD_pngqt) + endif(PLD_pngqt) + if(PLD_ppmqt) + list(APPEND MOC_OPTIONS -DPLD_ppmqt) + endif(PLD_ppmqt) + if(PLD_tiffqt) + list(APPEND MOC_OPTIONS -DPLD_tiffqt) + endif(PLD_tiffqt) + if(PLD_svgqt) + list(APPEND MOC_OPTIONS -DPLD_svgqt) + endif(PLD_svgqt) + if(PLD_epsqt) + list(APPEND MOC_OPTIONS -DPLD_epsqt) + endif(PLD_epsqt) + if(PLD_pdfqt) + list(APPEND MOC_OPTIONS -DPLD_pdfqt) + endif(PLD_pdfqt) + if(PLD_qtwidget) + list(APPEND MOC_OPTIONS -DPLD_qtwidget) + endif(PLD_qtwidget) + if(PLD_extqt) + list(APPEND MOC_OPTIONS -DPLD_extqt) + endif(PLD_extqt) + if(MOC_OPTIONS) + qt4_wrap_cpp( + QT_MOC_OUTFILES + ${CMAKE_SOURCE_DIR}/include/qt.h + OPTIONS ${MOC_OPTIONS} + ) + # Use custom target to force correct dependencies in various directories. + # This target is used in three possible places (qt_gui, drivers, or src) + # depending on build options. + add_custom_target(moc_outfile_generated DEPENDS ${QT_MOC_OUTFILES}) + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/moc_files.h "/* Generated header file listing the moc generated files to include in plqt.cpp. */ \n#ifndef __MOC_FILES_H__\n#define __MOC_FILES_H__\n\n") + file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/moc_files.h "#include \"${QT_MOC_OUTFILES}\"\n") + file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/moc_files.h "#endif /* __MOC_FILES_H__i */ \n") + else(MOC_OPTIONS) + message(FATAL_ERROR "Internal build system inconsistency between ANY_QT_DEVICE true and MOC_OPTIONS false.") + endif(MOC_OPTIONS) +endif(ANY_QT_DEVICE) install(FILES ${include_INSTALLED_HEADERS} DESTINATION ${INCLUDE_DIR}) Modified: trunk/src/CMakeLists.txt =================================================================== --- trunk/src/CMakeLists.txt 2009-08-03 19:27:12 UTC (rev 10204) +++ trunk/src/CMakeLists.txt 2009-08-03 20:32:05 UTC (rev 10205) @@ -102,50 +102,13 @@ #message("${SOURCE_ROOT_NAME}_SOURCE = ${${SOURCE_ROOT_NAME}_SOURCE}") list(APPEND plplot${LIB_TAG}_LIB_SRCS ${${SOURCE_ROOT_NAME}_SOURCE}) if(SOURCE_ROOT_NAME STREQUAL "qt") - set(MOC_OPTIONS) - if(PLD_bmpqt) - list(APPEND MOC_OPTIONS -DPLD_bmpqt) - endif(PLD_bmpqt) - if(PLD_jpgqt) - list(APPEND MOC_OPTIONS -DPLD_jpgqt) - endif(PLD_jpgqt) - if(PLD_pngqt) - list(APPEND MOC_OPTIONS -DPLD_pngqt) - endif(PLD_pngqt) - if(PLD_ppmqt) - list(APPEND MOC_OPTIONS -DPLD_ppmqt) - endif(PLD_ppmqt) - if(PLD_tiffqt) - list(APPEND MOC_OPTIONS -DPLD_tiffqt) - endif(PLD_tiffqt) - if(PLD_svgqt) - list(APPEND MOC_OPTIONS -DPLD_svgqt) - endif(PLD_svgqt) - if(PLD_epsqt) - list(APPEND MOC_OPTIONS -DPLD_epsqt) - endif(PLD_epsqt) - if(PLD_pdfqt) - list(APPEND MOC_OPTIONS -DPLD_pdfqt) - endif(PLD_pdfqt) - if(PLD_qtwidget) - list(APPEND MOC_OPTIONS -DPLD_qtwidget) - endif(PLD_qtwidget) - if(PLD_extqt) - list(APPEND MOC_OPTIONS -DPLD_extqt) - endif(PLD_extqt) - if(MOC_OPTIONS) - qt4_wrap_cpp( - QT_MOC_OUTFILES - ${CMAKE_SOURCE_DIR}/include/qt.h - OPTIONS ${MOC_OPTIONS} - ) - # message("QT_MOC_OUTFILES = ${QT_MOC_OUTFILES}") - set_source_files_properties( - ${QT_MOC_OUTFILES} - PROPERTIES GENERATED "ON" - ) - list(APPEND plplot${LIB_TAG}_LIB_SRCS ${QT_MOC_OUTFILES}) - endif(MOC_OPTIONS) + if(ANY_QT_DEVICE) + # For this case libplot must have a target dependency on the + # moc files generated in the binary include directory. + set(qt_dependency moc_outfile_generated) + else(ANY_QT_DEVICE) + message(FATAL_ERROR "Internal build system inconsistency. Attempt to build static qt device when ANY_QT_DEVICE is false.") + endif(ANY_QT_DEVICE) endif(SOURCE_ROOT_NAME STREQUAL "qt") # qt device driver code within libplplot has some symbols that need to be @@ -190,7 +153,7 @@ ${CMAKE_BINARY_DIR}/include ) add_library(plplot${LIB_TAG} ${plplot${LIB_TAG}_LIB_SRCS}) -add_dependencies(plplot${LIB_TAG} plhershey-unicode.h_built) +add_dependencies(plplot${LIB_TAG} plhershey-unicode.h_built ${qt_dependency}) set(LIB_INSTALL_RPATH ${LIB_DIR}) if(ENABLE_DYNDRIVERS) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hez...@us...> - 2009-08-04 01:39:05
|
Revision: 10206 http://plplot.svn.sourceforge.net/plplot/?rev=10206&view=rev Author: hezekiahcarty Date: 2009-08-04 01:38:53 +0000 (Tue, 04 Aug 2009) Log Message: ----------- Add support for custom axis labels Modified Paths: -------------- trunk/doc/docbook/src/api.xml trunk/include/plplot.h trunk/include/plstrm.h trunk/src/plbox.c trunk/src/plvpor.c Modified: trunk/doc/docbook/src/api.xml =================================================================== --- trunk/doc/docbook/src/api.xml 2009-08-03 20:32:05 UTC (rev 10205) +++ trunk/doc/docbook/src/api.xml 2009-08-04 01:38:53 UTC (rev 10206) @@ -11887,6 +11887,64 @@ </sect1> + <sect1 id="plslabelfunc" renderas="sect3"> + <title> + <function>plslabelfunc</function>: Assign a function to use for generating custom axis labels + </title> + + <para> + <funcsynopsis> + <funcprototype> + <funcdef> + <function>plslabelfunc</function> + </funcdef> + <paramdef><parameter>label_func</parameter></paramdef> + </funcprototype> + </funcsynopsis> + </para> + + <para> + This function allows a user to provide their own function to provide + axis label text. The user function is given the numeric value for a + point on an axis and returns a string label to correspond with that + value. + </para> + + <variablelist> + <varlistentry> + <term> + <parameter>label_func</parameter> + (<literal>void (*) (PLINT, PLFLT, const char *, void *)</literal>, input) + </term> + <listitem> + <para> + This is the custom label function. In order to reset to the + default labeling, set this to <literal>NULL</literal>. The + <literal>const char*</literal> argument should be set to point to + the appropriate label text. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <parameter>label_data</parameter> + (<literal>void *</literal>, input) + </term> + <listitem> + <para> + This parameter may be used to pass data to the label_func + function. + </para> + </listitem> + </varlistentry> + </variablelist> + + <para> + This function is used in examples 1 and 19. + </para> + + </sect1> + <sect1 id="plsmaj" renderas="sect3"> <title> <function>plsmaj</function>: Set length of major ticks Modified: trunk/include/plplot.h =================================================================== --- trunk/include/plplot.h 2009-08-03 20:32:05 UTC (rev 10205) +++ trunk/include/plplot.h 2009-08-04 01:38:53 UTC (rev 10206) @@ -253,6 +253,11 @@ #define PLSWIN_DEVICE 1 /* device coordinates */ #define PLSWIN_WORLD 2 /* world coordinates */ +/* Axis label tags */ +#define PL_X_AXIS 1 /* The x-axis */ +#define PL_Y_AXIS 2 /* The y-axis */ +#define PL_Z_AXIS 3 /* The z-axis */ + /* PLplot Option table & support constants */ /* Option-specific settings */ @@ -451,6 +456,11 @@ #define PLESC_DOUBLEBUFFERING_DISABLE 2 #define PLESC_DOUBLEBUFFERING_QUERY 3 +typedef struct { + PLFLT exp_label_disp; + PLFLT exp_label_pos; + PLFLT exp_label_just; +} PLLabelDefaults; /*--------------------------------------------------------------------------*\ * BRAINDEAD-ness @@ -518,6 +528,7 @@ #define plbop c_plbop #define plbox c_plbox #define plbox3 c_plbox3 +#define plslabelfunc c_plslabelfunc #define plcalc_world c_plcalc_world #define plarc c_plarc #define plclear c_plclear @@ -768,6 +779,11 @@ const char *yopt, const char *ylabel, PLFLT ytick, PLINT nsuby, const char *zopt, const char *zlabel, PLFLT ztick, PLINT nsubz); +/* Setup a user-provided custom labeling function */ +PLDLLIMPEXP void +c_plslabelfunc(void (*label_func)(PLINT, PLFLT, const char *, PLPointer), + PLPointer label_data); + /* Calculate world coordinates and subpage from relative device coordinates. */ PLDLLIMPEXP void Modified: trunk/include/plstrm.h =================================================================== --- trunk/include/plstrm.h 2009-08-03 20:32:05 UTC (rev 10205) +++ trunk/include/plstrm.h 2009-08-04 01:38:53 UTC (rev 10206) @@ -656,6 +656,8 @@ PLINT xdigmax, ydigmax, zdigmax; PLINT xdigits, ydigits, zdigits; char *timefmt; + void (*label_func)(PLINT, PLFLT, const char *, PLPointer); + PLPointer label_data; /* Variables governing physical coordinate system */ Modified: trunk/src/plbox.c =================================================================== --- trunk/src/plbox.c 2009-08-03 20:32:05 UTC (rev 10205) +++ trunk/src/plbox.c 2009-08-04 01:38:53 UTC (rev 10206) @@ -37,7 +37,7 @@ /* Static function prototypes */ static void -plxybx(const char *opt, const char *label, PLFLT wx1, PLFLT wy1, +plxybx(const char *opt, const char *label, PLINT axis, PLFLT wx1, PLFLT wy1, PLFLT wx2, PLFLT wy2, PLFLT vmin, PLFLT vmax, PLFLT tick, PLINT nsub, PLINT nolast, PLINT *digits); @@ -55,7 +55,7 @@ PLFLT wy2, PLFLT disp, PLFLT pos, PLFLT just, const char *text); static void -plform(PLFLT value, PLINT scale, PLINT prec, char *result, PLINT len, PLINT ll, PLINT lf); +plform(PLINT axis, PLFLT value, PLINT scale, PLINT prec, char *result, PLINT len, PLBOOL ll, PLBOOL lf, PLBOOL lo); static void grid_box(const char *xopt, PLFLT xtick1, PLINT nxsub1, @@ -102,6 +102,7 @@ * l: Logarithmic axes, major ticks at decades, minor ticks at units * n: Write numeric label at conventional location * m: Write numeric label at unconventional location + * o: Label text is generated by a user-defined function * t: Draw major tick marks * s: Draw minor tick marks * v: (for Y only) Label vertically @@ -520,7 +521,7 @@ ty = plP_w3wcy(xmin, ymin, zmin); ux = plP_w3wcx(xmax, ymin, zmin); uy = plP_w3wcy(xmax, ymin, zmin); - plxybx(xopt, xlabel, tx, ty, ux, uy, + plxybx(xopt, xlabel, PL_X_AXIS, tx, ty, ux, uy, xmin, xmax, xtick, nsubx, 0, &xdigits); dx = ux - tx; @@ -532,7 +533,7 @@ ty = plP_w3wcy(xmin, ymax, zmin); ux = plP_w3wcx(xmin, ymin, zmin); uy = plP_w3wcy(xmin, ymin, zmin); - plxybx(yopt, ylabel, tx, ty, ux, uy, + plxybx(yopt, ylabel, PL_Y_AXIS, tx, ty, ux, uy, ymax, ymin, ytick, nsuby, ln, &ydigits); dx = ux - tx; @@ -548,7 +549,7 @@ ty = plP_w3wcy(xmin, ymax, zmin); ux = plP_w3wcx(xmin, ymin, zmin); uy = plP_w3wcy(xmin, ymin, zmin); - plxybx(yopt, ylabel, tx, ty, ux, uy, + plxybx(yopt, ylabel, PL_Y_AXIS, tx, ty, ux, uy, ymax, ymin, ytick, nsuby, 0, &ydigits); dx = ux - tx; @@ -560,7 +561,7 @@ ty = plP_w3wcy(xmax, ymax, zmin); ux = plP_w3wcx(xmin, ymax, zmin); uy = plP_w3wcy(xmin, ymax, zmin); - plxybx(xopt, xlabel, tx, ty, ux, uy, + plxybx(xopt, xlabel, PL_X_AXIS, tx, ty, ux, uy, xmax, xmin, xtick, nsubx, ln, &xdigits); dx = ux - tx; @@ -576,7 +577,7 @@ ty = plP_w3wcy(xmax, ymax, zmin); ux = plP_w3wcx(xmin, ymax, zmin); uy = plP_w3wcy(xmin, ymax, zmin); - plxybx(xopt, xlabel, tx, ty, ux, uy, + plxybx(xopt, xlabel, PL_X_AXIS, tx, ty, ux, uy, xmax, xmin, xtick, nsubx, 0, &xdigits); dx = ux - tx; @@ -588,7 +589,7 @@ ty = plP_w3wcy(xmax, ymin, zmin); ux = plP_w3wcx(xmax, ymax, zmin); uy = plP_w3wcy(xmax, ymax, zmin); - plxybx(yopt, ylabel, tx, ty, ux, uy, + plxybx(yopt, ylabel, PL_Y_AXIS, tx, ty, ux, uy, ymin, ymax, ytick, nsuby, ln, &ydigits); dx = ux - tx; @@ -604,7 +605,7 @@ ty = plP_w3wcy(xmax, ymin, zmin); ux = plP_w3wcx(xmax, ymax, zmin); uy = plP_w3wcy(xmax, ymax, zmin); - plxybx(yopt, ylabel, tx, ty, ux, uy, + plxybx(yopt, ylabel, PL_X_AXIS, tx, ty, ux, uy, ymin, ymax, ytick, nsuby, 0, &ydigits); dx = ux - tx; @@ -616,7 +617,7 @@ ty = plP_w3wcy(xmin, ymin, zmin); ux = plP_w3wcx(xmax, ymin, zmin); uy = plP_w3wcy(xmax, ymin, zmin); - plxybx(xopt, xlabel, tx, ty, ux, uy, + plxybx(xopt, xlabel, PL_X_AXIS, tx, ty, ux, uy, xmin, xmax, xtick, nsubx, ln, &xdigits); dx = ux - tx; @@ -649,18 +650,19 @@ * i: Inverts tick marks (i.e. drawn downwards) * l: Logarithmic axes, major ticks at decades, minor ticks at units * n: Write numeric label + * o: Use custom label function * t: Draw major tick marks * s: Draw minor tick marks * u: Write label on line \*--------------------------------------------------------------------------*/ static void -plxybx(const char *opt, const char *label, PLFLT wx1, PLFLT wy1, +plxybx(const char *opt, const char *label, PLINT axis, PLFLT wx1, PLFLT wy1, PLFLT wx2, PLFLT wy2, PLFLT vmin_in, PLFLT vmax_in, PLFLT tick, PLINT nsub, PLINT nolast, PLINT *digits) { static char string[STRING_LEN]; - PLINT lb, ld, lf, li, ll, ln, ls, lt, lu; + PLINT lb, ld, lf, li, ll, ln, ls, lt, lu, lo; PLINT major, minor, mode, prec, scale; PLINT i, i1, i2, i3, i4; PLINT nsub1; @@ -692,6 +694,7 @@ ls = plP_stsearch(opt, 's'); lt = plP_stsearch(opt, 't'); lu = plP_stsearch(opt, 'u'); + lo = plP_stsearch(opt, 'o'); if (lu) plxytx(wx1, wy1, wx2, wy2, 3.2, 0.5, 0.5, label); @@ -776,7 +779,7 @@ tp = tick1 * (1. + floor(vmin / tick1)); for (tn = tp; BETW(tn, vmin, vmax); tn += tick1) { if(BETW(tn, vmin+tcrit, vmax-tcrit)) { - plform(tn, scale, prec, string, STRING_LEN, ll, lf); + plform(axis, tn, scale, prec, string, STRING_LEN, ll, lf, lo); pos = (vmax_in > vmin_in)? (tn - vmin) / (vmax - vmin): (vmax - tn) / (vmax - vmin); @@ -784,7 +787,7 @@ } } *digits = 2; - if (!ll && mode) { + if (!ll && !lo && mode) { snprintf(string, STRING_LEN, "(x10#u%d#d)", (int) scale); plxytx(wx1, wy1, wx2, wy2, height, 1.0, 0.5, string); } @@ -859,6 +862,7 @@ * l: Logarithmic axes, major ticks at decades, minor ticks at units * m: Write numeric label on right axis * n: Write numeric label on left axis + * o: Use custom label function * s: Draw minor tick marks * t: Draw major tick marks * u: Writes left-hand label @@ -871,7 +875,7 @@ PLFLT tick, PLINT nsub, PLINT *digits) { static char string[STRING_LEN]; - PLINT lb, lc, ld, lf, li, ll, lm, ln, ls, lt, lu, lv; + PLINT lb, lc, ld, lf, li, ll, lm, ln, ls, lt, lu, lv, lo; PLINT i, mode, prec, scale; PLINT nsub1, lstring; PLFLT pos, tn, tp, temp, height, tick1; @@ -903,6 +907,7 @@ lt = plP_stsearch(opt, 't'); lu = plP_stsearch(opt, 'u'); lv = plP_stsearch(opt, 'v'); + lo = plP_stsearch(opt, 'o'); if (lu && !right) plztx("h", dx, dy, wx, wy1, wy2, 5.0, 0.5, 0.5, label); @@ -992,7 +997,7 @@ *digits = 0; tp = tick1 * floor(vmin / tick1); for (tn = tp + tick1; BETW(tn, vmin, vmax); tn += tick1) { - plform(tn, scale, prec, string, STRING_LEN, ll, lf); + plform(PL_Z_AXIS, tn, scale, prec, string, STRING_LEN, ll, lf, lo); pos = (vmax_in > vmin_in)? (tn - vmin) / (vmax - vmin): (vmax - tn) / (vmax - vmin); @@ -1005,7 +1010,7 @@ lstring = strlen(string); *digits = MAX(*digits, lstring); } - if (!ll && mode) { + if (!ll && !lo && mode) { snprintf(string, STRING_LEN, "(x10#u%d#d)", (int) scale); pos = 1.15; height = 0.5; @@ -1196,11 +1201,11 @@ label_box(const char *xopt, PLFLT xtick1, const char *yopt, PLFLT ytick1) { static char string[STRING_LEN]; - PLBOOL ldx, lfx, lix, llx, lmx, lnx, ltx; - PLBOOL ldy, lfy, liy, lly, lmy, lny, lty, lvy; + PLBOOL ldx, lfx, lix, llx, lmx, lnx, ltx, lox; + PLBOOL ldy, lfy, liy, lly, lmy, lny, lty, lvy, loy; PLFLT vpwxmi, vpwxma, vpwymi, vpwyma; PLFLT vpwxmin, vpwxmax, vpwymin, vpwymax; - PLFLT pos, tn, tp, offset, height; + PLFLT pos, tn, tp, offset, height, just; PLFLT factor, tstart; const char *timefmt; @@ -1213,6 +1218,7 @@ lmx = plP_stsearch(xopt, 'm'); lnx = plP_stsearch(xopt, 'n'); ltx = plP_stsearch(xopt, 't'); + lox = plP_stsearch(xopt, 'o'); ldy = plP_stsearch(yopt, 'd'); lfy = plP_stsearch(yopt, 'f'); @@ -1222,6 +1228,7 @@ lny = plP_stsearch(yopt, 'n'); lty = plP_stsearch(yopt, 't'); lvy = plP_stsearch(yopt, 'v'); + loy = plP_stsearch(yopt, 'o'); plP_xgvpw(&vpwxmin, &vpwxmax, &vpwymin, &vpwymax); /* n.b. large change; vpwxmi always numerically less than vpwxma, and @@ -1251,7 +1258,7 @@ strfqsas(string, STRING_LEN, timefmt, (double) tn, plsc->qsasconfig); } else { - plform(tn, xscale, xprec, string, STRING_LEN, llx, lfx); + plform(PL_X_AXIS, tn, xscale, xprec, string, STRING_LEN, llx, lfx, lox); } height = lix ? 1.75 : 1.5; pos = (vpwxmax > vpwxmin)? @@ -1267,14 +1274,24 @@ /* Write separate exponential label if mode = 1. */ - if (!llx && !ldx && xmode) { - pos = 1.0; - height = 3.2; + if (!llx && !ldx && !lox && xmode) { + /* Assume label data is for placement of exponents if no custom + label function is provided. */ + if (plsc->label_data) { + height = ((PLLabelDefaults *)plsc->label_data)->exp_label_disp; + pos = ((PLLabelDefaults *)plsc->label_data)->exp_label_pos; + just = ((PLLabelDefaults *)plsc->label_data)->exp_label_just; + } + else { + height = 3.2; + pos = 1.0; + just = 0.5; + } snprintf(string, STRING_LEN, "(x10#u%d#d)", (int) xscale); if (lnx) - plmtex("b", height, pos, 0.5, string); + plmtex("b", height, pos, just, string); if (lmx) - plmtex("t", height, pos, 0.5, string); + plmtex("t", height, pos, just, string); } } @@ -1298,7 +1315,7 @@ strfqsas(string, STRING_LEN, timefmt, (double) tn, plsc->qsasconfig); } else { - plform(tn, yscale, yprec, string, STRING_LEN, lly, lfy); + plform(PL_Y_AXIS, tn, yscale, yprec, string, STRING_LEN, lly, lfy, loy); } pos = (vpwymax > vpwymin)? (tn - vpwymi) / (vpwyma - vpwymi): @@ -1330,18 +1347,26 @@ /* Write separate exponential label if mode = 1. */ - if (!lly && !ldy && ymode) { + if (!lly && !ldy && !loy && ymode) { snprintf(string, STRING_LEN, "(x10#u%d#d)", (int) yscale); - offset = 0.02; - height = 2.0; - if (lny) { - pos = 0.0 - offset; - plmtex("t", height, pos, 1.0, string); - } - if (lmy) { - pos = 1.0 + offset; - plmtex("t", height, pos, 0.0, string); - } + if (plsc->label_data) { + height = ((PLLabelDefaults *)plsc->label_data)->exp_label_disp; + pos = ((PLLabelDefaults *)plsc->label_data)->exp_label_pos; + just = ((PLLabelDefaults *)plsc->label_data)->exp_label_just; + } + else { + offset = 0.02; + height = 2.0; + if (lny) { + pos = 0.0 - offset; + just = 1.0; + } + if (lmy) { + pos = 1.0 + offset; + just = 0.0; + } + } + plmtex("t", height, pos, just, string); } } } @@ -1366,62 +1391,108 @@ * - If scale == 1, use scientific notation with one place before the * decimal point and "prec" places after. In this case, the value * must be divided by 10^scale. + * + * The axis argument is included to support PLplot's custom axis labeling. It + * is passed on to the custom labeling function if it exists. Otherwise, it + * is ignored. \*--------------------------------------------------------------------------*/ static void -plform(PLFLT value, PLINT scale, PLINT prec, char *string, PLINT len, PLINT ll, PLINT lf) +plform(PLINT axis, PLFLT value, PLINT scale, PLINT prec, char *string, PLINT len, PLBOOL ll, PLBOOL lf, PLBOOL lo) { - if (ll) { + const char *custom_string; - /* Logarithmic */ + /* Check to see if a custom labeling function is defined. If not, */ + if (lo && plsc->label_func) { + (*plsc->label_func)(axis, value, custom_string, plsc->label_data); + snprintf(string, len, "%s", custom_string); + } + else { + if (lo) { + plwarn("Custom axis labels requested without a labeling function \ + - using default."); + } + if (ll) { - if (lf) { + /* Logarithmic */ - /* Fixed point, i.e. .1, 1, 10, etc */ + if (lf) { - int exponent = ROUND(value); + /* Fixed point, i.e. .1, 1, 10, etc */ - value = pow(10.0, exponent); - if (exponent < 0) { - char form[FORMAT_LEN]; - snprintf(form, FORMAT_LEN, "%%.%df", ABS(exponent)); - snprintf(string, len, form, value); - } - else { - snprintf(string, len, "%d", (int) value); - } - } - else { + int exponent = ROUND(value); - /* Exponential, i.e. 10^-1, 10^0, 10^1, etc */ + value = pow(10.0, exponent); + if (exponent < 0) { + char form[FORMAT_LEN]; + snprintf(form, FORMAT_LEN, "%%.%df", ABS(exponent)); + snprintf(string, len, form, value); + } + else { + snprintf(string, len, "%d", (int) value); + } + } + else { - snprintf(string, len, "10#u%d", (int) ROUND(value)); - } - } - else { + /* Exponential, i.e. 10^-1, 10^0, 10^1, etc */ - /* Linear */ + snprintf(string, len, "10#u%d", (int) ROUND(value)); + } + } + else { - PLINT setpre, precis; - char form[FORMAT_LEN], temp[TEMP_LEN]; - double scale2; + /* Linear */ - plP_gprec(&setpre, &precis); + PLINT setpre, precis; + char form[FORMAT_LEN], temp[TEMP_LEN]; + double scale2; - if (setpre) - prec = precis; + plP_gprec(&setpre, &precis); - if (scale) - value /= pow(10.,(double)scale); + if (setpre) + prec = precis; - /* This is necessary to prevent labels like "-0.0" on some systems */ + if (scale) + value /= pow(10.,(double)scale); - scale2 = pow(10., prec); - value = floor((value * scale2) + .5) / scale2; + /* This is necessary to prevent labels like "-0.0" on some systems */ - snprintf(form, FORMAT_LEN, "%%.%df", (int) prec); - snprintf(temp, TEMP_LEN, form, value); - strncpy(string, temp, len-1); - string[len-1] = '\0'; + scale2 = pow(10., prec); + value = floor((value * scale2) + .5) / scale2; + + snprintf(form, FORMAT_LEN, "%%.%df", (int) prec); + snprintf(temp, TEMP_LEN, form, value); + strncpy(string, temp, len-1); + string[len-1] = '\0'; + } } } + +/*--------------------------------------------------------------------------*\ + * plslabelfunc + * + * Formats a PLFLT value in one of the following formats. + * + * label_func - A pointer to a function which will provide a string to use + * as the label for the given floating point value. + * Pass this as NULL to clear the custom function and reset it to + * the default PLplot labeling function. + * + * label_data - Extra data to pass to the label function. + * + * The label_func function arguments are, in order: + * + * axis: PL_X_AXIS, PL_Y_AXIS or PL_Z_AXIS to indicate which axis is being + * labeled + * value: The value at this position on the axis + * string: The resulting label string should be stored here + * data: A pointer to whatever extra information the custom plotting function + * requires + * +\*--------------------------------------------------------------------------*/ +void +c_plslabelfunc(void (*label_func)(PLINT, PLFLT, const char *, PLPointer), PLPointer label_data) +{ + plsc->label_func = label_func; + plsc->label_data = label_data; +} Modified: trunk/src/plvpor.c =================================================================== --- trunk/src/plvpor.c 2009-08-03 20:32:05 UTC (rev 10205) +++ trunk/src/plvpor.c 2009-08-04 01:38:53 UTC (rev 10206) @@ -81,6 +81,10 @@ * axis=61 : Same as 1 except date / time X,Y tick marks. * axis=62 : Same as 2 except date / time X,Y tick marks. * axis=63 : Same as 62, but the grid will be also at the minor ticks. + * axis=70 : Same as 0 except custom X,Y labels. + * axis=71 : Same as 1 except custom X,Y labels. + * axis=72 : Same as 2 except custom X,Y labels. + * axis=73 : Same as 72, but the grid will be also at the minor ticks. \*--------------------------------------------------------------------------*/ void @@ -269,6 +273,18 @@ case 63: plbox("abcgdnsth", (PLFLT) 0.0, 0, "abcgdnstvh", (PLFLT) 0.0, 0); break; + case 70: + plbox("bcnost", (PLFLT) 0.0, 0, "bcnostv", (PLFLT) 0.0, 0); + break; + case 71: + plbox("abcnost", (PLFLT) 0.0, 0, "abcnostv", (PLFLT) 0.0, 0); + break; + case 72: + plbox("abcgnost", (PLFLT) 0.0, 0, "abcgnostv", (PLFLT) 0.0, 0); + break; + case 73: + plbox("abcgnosth", (PLFLT) 0.0, 0, "abcgnostvh", (PLFLT) 0.0, 0); + break; default: plwarn("plenv: Invalid axis argument"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |