From: <and...@us...> - 2009-02-23 16:00:36
|
Revision: 9587 http://plplot.svn.sourceforge.net/plplot/?rev=9587&view=rev Author: andrewross Date: 2009-02-23 16:00:30 +0000 (Mon, 23 Feb 2009) Log Message: ----------- Use HUGE_VAL instead of INFINITY as this seems to be more widely supported without having to resort to our own macros. Modified Paths: -------------- trunk/include/plplot.h trunk/src/pdfutils.c Modified: trunk/include/plplot.h =================================================================== --- trunk/include/plplot.h 2009-02-23 15:54:44 UTC (rev 9586) +++ trunk/include/plplot.h 2009-02-23 16:00:30 UTC (rev 9587) @@ -199,10 +199,10 @@ # endif #endif -/* Check if C99 INFINITY macro is available - if not then +/* Check if C99 HUGE_VAL macro is available - if not then * define a replacement */ -#ifndef INFINITY -#define INFINITY (1.0/0.0) +#ifndef HUGE_VAL +#define HUGE_VAL (1.0/0.0) #endif Modified: trunk/src/pdfutils.c =================================================================== --- trunk/src/pdfutils.c 2009-02-23 15:54:44 UTC (rev 9586) +++ trunk/src/pdfutils.c 2009-02-23 16:00:30 UTC (rev 9587) @@ -918,8 +918,8 @@ PLFLT m, M; if (isnan(f[0][0]) || isinf(f[0][0])) { - M = -INFINITY; - m = INFINITY; + M = -HUGE_VAL; + m = HUGE_VAL; } else M = m = f[0][0]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-02-23 19:19:00
|
Revision: 9590 http://plplot.svn.sourceforge.net/plplot/?rev=9590&view=rev Author: airwin Date: 2009-02-23 19:18:56 +0000 (Mon, 23 Feb 2009) Log Message: ----------- Try mapping PLUNICODE to 32-bit Fortran integers for the f95 versions of plsfci and plgfci (similar to the previous simplifying change we made for f77). This simplified approach works for gfortran but should be tested on other compilers as well. Modified Paths: -------------- trunk/bindings/f95/CMakeLists.txt trunk/bindings/f95/scstubs.c trunk/examples/f95/x23f.f90 Modified: trunk/bindings/f95/CMakeLists.txt =================================================================== --- trunk/bindings/f95/CMakeLists.txt 2009-02-23 18:44:56 UTC (rev 9589) +++ trunk/bindings/f95/CMakeLists.txt 2009-02-23 19:18:56 UTC (rev 9590) @@ -45,8 +45,10 @@ FILE(APPEND "${INC_FILE}" "integer, parameter :: plflt = kind(1.0)\n") endif(PL_DOUBLE) + # Only 4 bytes required in Fortran to represent an unsigned 32-bit + # PLUNICODE. FILE(APPEND "${INC_FILE}" - "integer, parameter :: plunicode = selected_int_kind(10)\n") + "integer, parameter :: plunicode = 4\n") # Mark the include file as being generated set_source_files_properties(plflt.inc PROPERTIES GENERATED ON) Modified: trunk/bindings/f95/scstubs.c =================================================================== --- trunk/bindings/f95/scstubs.c 2009-02-23 18:44:56 UTC (rev 9589) +++ trunk/bindings/f95/scstubs.c 2009-02-23 19:18:56 UTC (rev 9590) @@ -305,15 +305,13 @@ c_plgfam(fam, num, bmax); } -/* Note: Fortran does not have unsigned integers so we need to use a - * 64 bit signed integer which corresponds to a fortran integer*8 - * in order to contain the number. */ +/* Note: Fortran does not distinguish between unsigned and signed integers + so the 32-bit PLUNICODE can be mapped to 4-byte Fortran integer outside + this routine. */ void -PLGFCI(PLINT64 *pfci) +PLGFCI(PLUNICODE *pfci) { - PLUNICODE fci; - c_plgfci(&fci); - *pfci = (PLINT64) fci; + c_plgfci(pfci); } void @@ -834,16 +832,13 @@ c_plsfam(*fam, *num, *bmax); } -/* Note: Fortran does not have unsigned integers so we need to use a - * 64 bit signed integer which corresponds to a fortran integer*8 - * in order to contain the number. */ -/* PLSFCI(PLINT64 *fci) */ +/* Note: Fortran does not distinguish between unsigned and signed integers + so the 32-bit PLUNICODE can be mapped to 4-byte Fortran integer outside + this routine. */ void -PLSFCI(PLINT64 *fci) +PLSFCI(PLUNICODE *fci) { - PLUNICODE f; - f = (PLUNICODE) (*fci & 0xffffffff); - c_plsfci(f); + c_plsfci(*fci); } void Modified: trunk/examples/f95/x23f.f90 =================================================================== --- trunk/examples/f95/x23f.f90 2009-02-23 18:44:56 UTC (rev 9589) +++ trunk/examples/f95/x23f.f90 2009-02-23 19:18:56 UTC (rev 9590) @@ -187,37 +187,41 @@ 0, & 0 / +! drop the leading '8' marker for FCI because some compilers (gfortran) +! have an implementation error (integer overflow error) for that case, and +! the marker is not needed, in any case, for calls to plsfci. + data (fci(i), i=1,fci_combinations) / & - z'80000000', & - z'80000001', & - z'80000002', & - z'80000003', & - z'80000004', & - z'80000010', & - z'80000011', & - z'80000012', & - z'80000013', & - z'80000014', & - z'80000020', & - z'80000021', & - z'80000022', & - z'80000023', & - z'80000024', & - z'80000100', & - z'80000101', & - z'80000102', & - z'80000103', & - z'80000104', & - z'80000110', & - z'80000111', & - z'80000112', & - z'80000113', & - z'80000114', & - z'80000120', & - z'80000121', & - z'80000122', & - z'80000123', & - z'80000124' / + z'00000000', & + z'00000001', & + z'00000002', & + z'00000003', & + z'00000004', & + z'00000010', & + z'00000011', & + z'00000012', & + z'00000013', & + z'00000014', & + z'00000020', & + z'00000021', & + z'00000022', & + z'00000023', & + z'00000024', & + z'00000100', & + z'00000101', & + z'00000102', & + z'00000103', & + z'00000104', & + z'00000110', & + z'00000111', & + z'00000112', & + z'00000113', & + z'00000114', & + z'00000120', & + z'00000121', & + z'00000122', & + z'00000123', & + z'00000124' / data (family(i), i=1,5) / & "sans-serif", & @@ -355,7 +359,8 @@ trim(weight(weight_index+1))//': '// & 'The quick brown fox jumps over the lazy dog' elseif(page == 13) then - write(string,'(a,"#<0x",z8,">",a)') & +! Note, must put in missing FCI marker for this particular case. + write(string,'(a,"#<0x8",z7.7,">",a)') & 'Page 14, '//trim(family(family_index+1))//', '// & trim(style(style_index+1))//', '// & trim(weight(weight_index+1))//': ', & This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2009-02-24 08:51:07
|
Revision: 9599 http://plplot.svn.sourceforge.net/plplot/?rev=9599&view=rev Author: andrewross Date: 2009-02-24 08:51:03 +0000 (Tue, 24 Feb 2009) Log Message: ----------- More tweaks to isnan, isinf, finite checks and macros to make them more portable. Modified Paths: -------------- trunk/cmake/modules/plplot.cmake trunk/include/plplot.h trunk/src/pdfutils.c Modified: trunk/cmake/modules/plplot.cmake =================================================================== --- trunk/cmake/modules/plplot.cmake 2009-02-24 05:15:26 UTC (rev 9598) +++ trunk/cmake/modules/plplot.cmake 2009-02-24 08:51:03 UTC (rev 9599) @@ -25,6 +25,7 @@ # Need these modules to do subsequent checks. include(CheckIncludeFiles) include(CheckFunctionExists) +include(CheckSymbolExists) include(CheckPrototypeExists) macro(TRANSFORM_VERSION _numerical_result _version) @@ -185,17 +186,25 @@ include(CheckFunctionExists) check_function_exists(popen HAVE_POPEN) check_function_exists(usleep PL_HAVE_USLEEP) -check_function_exists(isinf HAVE_ISINF) -check_function_exists(finite HAVE_FINITE) + +# Check for FP functions, including underscored version which +# are sometimes all that is available on windows +check_symbol_exists(finite "math.h" HAVE_FINITE) if(NOT HAVE_FINITE) - check_function_exists(_finite _HAVE_FINITE) + check_symbolnction_exists(_finite "math.h" _HAVE_FINITE) set(HAVE_FINITE ${_HAVE_FINITE} CACHE INTERNAL "Have function _finite") endif(NOT HAVE_FINITE) -check_function_exists(isnan HAVE_ISNAN) +check_symbol_exists(isnan "math.h" HAVE_ISNAN) if(NOT HAVE_ISNAN) - check_function_exists(_isnan _HAVE_ISNAN) + check_symbol_exists(_isnan "math.h" _HAVE_ISNAN) set(HAVE_ISNAN ${_HAVE_ISNAN} CACHE INTERNAL "Have function _isnan") endif(NOT HAVE_ISNAN) +check_symbol_exists(isinf "math.h" HAVE_ISINF) +if(NOT HAVE_ISINF) + check_symbol_exists(_isinf "math.h" _HAVE_ISINF) + set(HAVE_ISINF ${_HAVE_ISINF} CACHE INTERNAL "Have function _isinf") +endif(NOT HAVE_ISINF) + check_function_exists(snprintf PL_HAVE_SNPRINTF) if(NOT PL_HAVE_SNPRINTF) check_function_exists(_snprintf _PL_HAVE_SNPRINTF) Modified: trunk/include/plplot.h =================================================================== --- trunk/include/plplot.h 2009-02-24 05:15:26 UTC (rev 9598) +++ trunk/include/plplot.h 2009-02-24 08:51:03 UTC (rev 9599) @@ -187,18 +187,28 @@ * Add in missing isnan / isinf functions on some platforms \*--------------------------------------------------------------------------*/ -#if defined(WIN32) && (defined(_MSC_VER) || defined(__BORLANDC__)) +#if defined(_HAVE_ISNAN) # define isnan _isnan +#endif +#if defined(_HAVE_ISINF) # define isinf _isinf -#else -# if !defined(HAVE_ISNAN) -# define isnan(x) ((x) != (x)) -# endif -# if !defined(HAVE_ISINF) -# define isinf(x) (!isnan(x) && isnan(x-x)) -# endif #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 Modified: trunk/src/pdfutils.c =================================================================== --- trunk/src/pdfutils.c 2009-02-24 05:15:26 UTC (rev 9598) +++ trunk/src/pdfutils.c 2009-02-24 08:51:03 UTC (rev 9599) @@ -917,7 +917,7 @@ int i, j; PLFLT m, M; - if (isnan(f[0][0]) || isinf(f[0][0])) { + if (!finite(f[0][0])) { M = -HUGE_VAL; m = HUGE_VAL; } @@ -926,7 +926,7 @@ for (i = 0; i < nx; i++) { for (j = 0; j < ny; j++) { - if (isnan(f[i][j]) || isinf(f[i][j])) continue; + if (!finite(f[i][j])) continue; if (f[i][j] > M) M = f[i][j]; if (f[i][j] < m) m = f[i][j]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2009-02-24 13:08:43
|
Revision: 9602 http://plplot.svn.sourceforge.net/plplot/?rev=9602&view=rev Author: andrewross Date: 2009-02-24 13:08:40 +0000 (Tue, 24 Feb 2009) Log Message: ----------- Add support for handling NaN and +/-Inf values when plotting lines. Physical coordinates are of type PLINT and so we cannot directly use NaN / Inf values. Instead, coordinate transformations plP_wcpc[xy] map NaN and Inf to PLINT_MIN which is the smallest (most negative) number when can be held in a PLINT. This will never by used for "real" physical coordinates). Adding support at this level means that the only other change is that the low-level clipping routine will not attempt to draw any line segment where any of the physical coordinates have a value of PLINT_MIN. Modified Paths: -------------- trunk/include/plplot.h trunk/src/plcvt.c trunk/src/plline.c Modified: trunk/include/plplot.h =================================================================== --- trunk/include/plplot.h 2009-02-24 11:43:06 UTC (rev 9601) +++ trunk/include/plplot.h 2009-02-24 13:08:40 UTC (rev 9602) @@ -161,11 +161,13 @@ typedef uint32_t PLUINT; typedef int32_t PLINT; typedef int64_t PLINT64; +#define PLINT_MIN INT32_MIN #else /* A reasonable back-up in case stdint.h does not exist on the platform. */ typedef unsigned int PLUINT; typedef int PLINT; typedef __int64 PLINT64; +#define PLINT_MIN -2147483648 /* typedef unsigned int PLUINT; typedef int PLINT; Modified: trunk/src/plcvt.c =================================================================== --- trunk/src/plcvt.c 2009-02-24 11:43:06 UTC (rev 9601) +++ trunk/src/plcvt.c 2009-02-24 13:08:40 UTC (rev 9602) @@ -64,6 +64,7 @@ PLINT plP_wcpcx(PLFLT x) { + if (!finite(x)) return PLINT_MIN; return (ROUND(plsc->wpxoff + plsc->wpxscl * x)); } @@ -72,6 +73,7 @@ PLINT plP_wcpcy(PLFLT y) { + if (!finite(y)) return PLINT_MIN; return (ROUND(plsc->wpyoff + plsc->wpyscl * y)); } Modified: trunk/src/plline.c =================================================================== --- trunk/src/plline.c 2009-02-24 11:43:06 UTC (rev 9601) +++ trunk/src/plline.c 2009-02-24 13:08:40 UTC (rev 9602) @@ -1076,6 +1076,11 @@ (*p_y1 >= ymax && *p_y2 >= ymax)) return 1; +/* If one of the coordinates is not finite then return with an error */ + if ( (*p_x1 == PLINT_MIN) || (*p_y1 == PLINT_MIN) || + (*p_x2 == PLINT_MIN) || (*p_y2 == PLINT_MIN) ) + return 1; + flipx = 0; flipy = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-02-28 18:54:13
|
Revision: 9642 http://plplot.svn.sourceforge.net/plplot/?rev=9642&view=rev Author: airwin Date: 2009-02-28 18:54:06 +0000 (Sat, 28 Feb 2009) Log Message: ----------- Replace all time.h related C library calls by their qsastime equivalents. The result builds without any obvious problems, and example 29 still gives the same results, but this substantial simplification of pldtfac (which affects all time labelling) needs a lot of additional testing. Modified Paths: -------------- trunk/include/plplotP.h trunk/src/pldtik.c Modified: trunk/include/plplotP.h =================================================================== --- trunk/include/plplotP.h 2009-02-28 03:11:55 UTC (rev 9641) +++ trunk/include/plplotP.h 2009-02-28 18:54:06 UTC (rev 9642) @@ -112,7 +112,6 @@ #include <string.h> #include <limits.h> #include <float.h> -#include <time.h> #if defined(PLPLOT_WINTK) #elif defined(WIN32) &! defined (__GNUC__) /* Redefine tmpfile()! (AM)*/ Modified: trunk/src/pldtik.c =================================================================== --- trunk/src/pldtik.c 2009-02-28 03:11:55 UTC (rev 9641) +++ trunk/src/pldtik.c 2009-02-28 18:54:06 UTC (rev 9642) @@ -113,90 +113,72 @@ void pldtfac(PLFLT vmin, PLFLT vmax, PLFLT *factor, PLFLT *start) { PLFLT diff, tdiff; - time_t t, t2; - struct tm tm; + PLINT year, month, day, hour, min; + PLFLT sec; diff = vmax - vmin; if (start != NULL) { - struct tm* tmp; - - t = (time_t) vmin; - if(!(tmp=gmtime(&t))) { - plabort("pldtfac: gmtime() returned an invalid value"); - return; - } - tm = *tmp; - t2 = mktime(&tm); - /* Arg! This is because mktime is in local time and we need to - correct for the offset. C time handling really is broken... */ - tdiff = difftime(t,t2); - + plbtime(&year, &month, &day, &hour, &min, &sec, vmin); } if (diff < 3.0*60.0) { /* Seconds */ *factor = 1.0; if (start != NULL) { - tm.tm_sec = 0; - t = mktime(&tm); - *start = (PLFLT)t+tdiff; + sec = 0.; + plctime(year, month, day, hour, min, sec, start); } } else if (diff < 3.0*60.0*60.0) { /* Minutes */ *factor = 60.0; if (start != NULL) { - tm.tm_sec = 0; - tm.tm_min = 0; - t = mktime(&tm); - *start = (PLFLT)t+tdiff; + sec = 0.; + min = 0; + plctime(year, month, day, hour, min, sec, start); } } else if (diff < 3.0*60.0*60.0*24.0) { /* Hours */ *factor = 60.0*60.0; if (start != NULL) { - tm.tm_sec = 0; - tm.tm_min = 0; - tm.tm_hour = 0; - t = mktime(&tm); - *start = (PLFLT)t+tdiff; + sec = 0.; + min = 0; + hour = 0; + plctime(year, month, day, hour, min, sec, start); } } else if (diff < 3.0*60.0*60.0*24.0*7.0) { /* Days */ *factor = 60.0*60.0*24.0; if (start != NULL) { - tm.tm_sec = 0; - tm.tm_min = 0; - tm.tm_hour = 0; - t = mktime(&tm); - *start = (PLFLT)t+tdiff; + sec = 0.; + min = 0; + hour = 0; + plctime(year, month, day, hour, min, sec, start); } } else if (diff < 3.0*60.0*60.0*24.0*365) { /* Weeks */ *factor = 60.0*60.0*24.0*7.0; if (start != NULL) { - tm.tm_sec = 0; - tm.tm_min = 0; - tm.tm_hour = 0; - t = mktime(&tm); - *start = (PLFLT)t+tdiff; + sec = 0.; + min = 0; + hour = 0; + plctime(year, month, day, hour, min, sec, start); } } else { /* Years */ *factor = 60.0*60.0*24.0*365.25; if (start != NULL) { - tm.tm_sec = 0; - tm.tm_min = 0; - tm.tm_hour = 0; - tm.tm_mday = 1; - tm.tm_mon = 0; - t = mktime(&tm); - *start = (PLFLT)t+tdiff; + sec = 0.; + min = 0; + hour = 0; + day = 0; + month = 0; + plctime(year, month, day, hour, min, sec, start); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-02-28 21:03:11
|
Revision: 9644 http://plplot.svn.sourceforge.net/plplot/?rev=9644&view=rev Author: airwin Date: 2009-02-28 21:03:02 +0000 (Sat, 28 Feb 2009) Log Message: ----------- Make new time API available to our swig-generated interfaces, and update the 29th python example to use this new time API. The python example 29 results remain unchanged. Modified Paths: -------------- trunk/bindings/swig-support/plplotcapi.i trunk/examples/python/xw29.py Modified: trunk/bindings/swig-support/plplotcapi.i =================================================================== --- trunk/bindings/swig-support/plplotcapi.i 2009-02-28 20:59:11 UTC (rev 9643) +++ trunk/bindings/swig-support/plplotcapi.i 2009-02-28 21:03:02 UTC (rev 9644) @@ -248,6 +248,10 @@ void plbin(PLINT n, PLFLT *Array, PLFLT *ArrayCk, PLINT center); +%feature("autodoc", "Calculate broken-down time from continuous time for current stream.") plbtime; +void +plbtime(PLINT *OUTPUT, PLINT *OUTPUT, PLINT *OUTPUT, PLINT *OUTPUT, PLINT *OUTPUT, PLFLT *OUTPUT, PLFLT ctime); + %feature("autodoc", "Start new page. Should only be used with pleop().") plbop; void plbop(void); @@ -279,6 +283,10 @@ void plcol1(PLFLT col1); +%feature("autodoc", "Configure transformation between continuous and broken-down time (and vice versa) for current stream.") plconfigtime; +void +plconfigtime(PLFLT scale, PLFLT offset1, PLFLT offset2, PLINT ccontrol, PLBOOL ifbtime_offset, PLINT year, PLINT month, PLINT day, PLINT hour, PLINT min, PLFLT sec); + %feature("autodoc", "Draw a contour plot.") plcont; void plcont(PLFLT **Matrix, PLINT nx, PLINT ny, PLINT kx, PLINT lx, @@ -287,6 +295,10 @@ PLPointer SWIG_OBJECT_DATA); +%feature("autodoc", "Calculate continuous time from broken-down time for current stream.") plctime; +void +plctime(PLINT year, PLINT month, PLINT day, PLINT hour, PLINT min, PLFLT sec, PLFLT *OUTPUT); + %feature("autodoc", "Copy state parameters from the reference stream to the current stream.") plcpstrm; void plcpstrm(PLINT iplsr, PLBOOL flags); Modified: trunk/examples/python/xw29.py =================================================================== --- trunk/examples/python/xw29.py 2009-02-28 20:59:11 UTC (rev 9643) +++ trunk/examples/python/xw29.py 2009-02-28 21:03:02 UTC (rev 9644) @@ -137,11 +137,10 @@ # number of seconds elapsed since the Unix epoch (1970-01-01, UTC) for # 2005-12-01, UTC. - tstart = calendar.timegm((2005,12,1,0,0,0)) + xmin = plctime(2005,11,1,0,0,0.) npts = 62 - xmin = float(tstart) xmax = xmin + npts*60.0*60.0*24.0 ymin = 0.0 ymax = 5.0 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2009-03-03 11:06:37
|
Revision: 9665 http://plplot.svn.sourceforge.net/plplot/?rev=9665&view=rev Author: andrewross Date: 2009-03-03 11:06:31 +0000 (Tue, 03 Mar 2009) Log Message: ----------- Minor changes to cmake files to allow cross-compilation. This change enables executables used as part of the build process to be picked up from a separate native build. I will put instructions on how to actually run this on the wiki. Modified Paths: -------------- trunk/CMakeLists.txt trunk/drivers/CMakeLists.txt trunk/include/CMakeLists.txt trunk/lib/qsastime/CMakeLists.txt Modified: trunk/CMakeLists.txt =================================================================== --- trunk/CMakeLists.txt 2009-03-03 07:21:21 UTC (rev 9664) +++ trunk/CMakeLists.txt 2009-03-03 11:06:31 UTC (rev 9665) @@ -227,3 +227,10 @@ ) #message("CPACK_SOURCE_IGNORE_FILES = ${CPACK_SOURCE_IGNORE_FILES}") include(CPack) + +# Path to native build for executables required in the build process. +# This is only required for cross compiling +if (CMAKE_CROSSCOMPILING) + set(CMAKE_NATIVE_BINARY_DIR NATIVEDIR-NOTFOUND CACHE FILEPATH "Point to the native build directory") +endif (CMAKE_CROSSCOMPILING) + Modified: trunk/drivers/CMakeLists.txt =================================================================== --- trunk/drivers/CMakeLists.txt 2009-03-03 07:21:21 UTC (rev 9664) +++ trunk/drivers/CMakeLists.txt 2009-03-03 11:06:31 UTC (rev 9665) @@ -37,6 +37,7 @@ ${CMAKE_BINARY_DIR}/include ) + if(NOT CMAKE_CROSSCOMPILING) add_executable(get-drv-info get-drv-info.c) target_link_libraries(get-drv-info plplot${LIB_TAG} @@ -57,9 +58,15 @@ INSTALL_RPATH "${get-drv-info_RPATH}" BUILD_WITH_INSTALL_RPATH ON ) + else(NOT CMAKE_CROSSCOMPILING) + set(IMPORT_EXECUTABLES ${CMAKE_NATIVE_BINARY_DIR}/drivers/ImportExecutables.cmake) + include(${IMPORT_EXECUTABLES}) + endif(NOT CMAKE_CROSSCOMPILING) + + if(NOT CMAKE_CROSSCOMPILING) + export(TARGETS get-drv-info FILE ${CMAKE_CURRENT_BINARY_DIR}/ImportExecutables.cmake ) + endif(NOT CMAKE_CROSSCOMPILING) - get_target_property(get-drv-info_LOCATION get-drv-info LOCATION) - foreach(SOURCE_ROOT_NAME ${DRIVERS_LIST}) #message("${SOURCE_ROOT_NAME}_SOURCE = ${${SOURCE_ROOT_NAME}_SOURCE}") if(${SOURCE_ROOT_NAME}_COMPILE_FLAGS) @@ -140,11 +147,10 @@ ) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_ROOT_NAME}.rc - COMMAND ${get-drv-info_LOCATION} + COMMAND get-drv-info ${SOURCE_ROOT_NAME} > ${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_ROOT_NAME}.rc DEPENDS - ${get-drv-info_LOCATION} ${${SOURCE_ROOT_NAME}_LOCATION} ) add_custom_target( Modified: trunk/include/CMakeLists.txt =================================================================== --- trunk/include/CMakeLists.txt 2009-03-03 07:21:21 UTC (rev 9664) +++ trunk/include/CMakeLists.txt 2009-03-03 11:06:31 UTC (rev 9665) @@ -33,17 +33,16 @@ ${CMAKE_SOURCE_DIR}/fonts/plhershey-unicode-gen.c ) +if(NOT CMAKE_CROSSCOMPILING) add_executable(plhershey-unicode-gen ${plhershey-unicode-gen_SRCS}) +else(NOT CMAKE_CROSSCOMPILING) + SET(IMPORT_EXECUTABLES ${CMAKE_NATIVE_BINARY_DIR}/include/ImportExecutables.cmake) + INCLUDE(${IMPORT_EXECUTABLES}) +endif(NOT CMAKE_CROSSCOMPILING) -get_target_property( -plhershey-unicode-gen_LOCATION -plhershey-unicode-gen -LOCATION -) - add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/plhershey-unicode.h -COMMAND ${plhershey-unicode-gen_LOCATION} +COMMAND plhershey-unicode-gen ${CMAKE_SOURCE_DIR}/fonts/plhershey-unicode.csv ${CMAKE_CURRENT_BINARY_DIR}/plhershey-unicode.h DEPENDS @@ -51,6 +50,10 @@ ${CMAKE_SOURCE_DIR}/fonts/plhershey-unicode.csv ) +if(NOT CMAKE_CROSSCOMPILING) + export(TARGETS plhershey-unicode-gen FILE ${CMAKE_CURRENT_BINARY_DIR}/ImportExecutables.cmake ) +endif(NOT CMAKE_CROSSCOMPILING) + # For cross-directory dependencies.... add_custom_target( plhershey-unicode.h_built Modified: trunk/lib/qsastime/CMakeLists.txt =================================================================== --- trunk/lib/qsastime/CMakeLists.txt 2009-03-03 07:21:21 UTC (rev 9664) +++ trunk/lib/qsastime/CMakeLists.txt 2009-03-03 11:06:31 UTC (rev 9665) @@ -114,27 +114,31 @@ # Routine for generating a header of data to be used by the # TAI-UTC transformation code. -add_executable(tai-utc-gen ${CMAKE_CURRENT_SOURCE_DIR}/tai-utc-gen.c) -if(MATH_LIB) - target_link_libraries(tai-utc-gen ${MATH_LIB}) -endif(MATH_LIB) -get_target_property( - tai-utc-gen_LOCATION - tai-utc-gen - LOCATION - ) +if(NOT CMAKE_CROSSCOMPILING) + add_executable(tai-utc-gen ${CMAKE_CURRENT_SOURCE_DIR}/tai-utc-gen.c) + if(MATH_LIB) + target_link_libraries(tai-utc-gen ${MATH_LIB}) + endif(MATH_LIB) +else(NOT CMAKE_CROSSCOMPILING) + set(IMPORT_EXECUTABLES ${CMAKE_NATIVE_BINARY_DIR}/lib/qsastime/ImportExecutables.cmake) + include(${IMPORT_EXECUTABLES}) +endif(NOT CMAKE_CROSSCOMPILING) + add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/tai-utc.h - COMMAND ${tai-utc-gen_LOCATION} + COMMAND tai-utc-gen ${CMAKE_CURRENT_SOURCE_DIR}/tai-utc.dat ${CMAKE_CURRENT_BINARY_DIR}/tai-utc.h DEPENDS - ${tai-utc-gen_LOCATION} ${CMAKE_CURRENT_SOURCE_DIR}/tai-utc.dat ) +if(NOT CMAKE_CROSSCOMPILING) + export(TARGETS tai-utc-gen FILE ${CMAKE_CURRENT_BINARY_DIR}/ImportExecutables.cmake ) +endif(NOT CMAKE_CROSSCOMPILING) + # This target-level dependency needed below. add_custom_target( tai-utc.h_built This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-03-05 16:07:54
|
Revision: 9675 http://plplot.svn.sourceforge.net/plplot/?rev=9675&view=rev Author: airwin Date: 2009-03-05 16:07:41 +0000 (Thu, 05 Mar 2009) Log Message: ----------- AWI for Alban Rochel. Initial commit of qt device driver. Modified Paths: -------------- trunk/cmake/modules/drivers-finish.cmake trunk/cmake/modules/drivers-init.cmake trunk/cmake/modules/drivers.cmake trunk/config.h.cmake trunk/drivers/CMakeLists.txt trunk/include/drivers.h trunk/include/plDevs.h.cmake trunk/include/plcore.h trunk/plplot_test/plplot-test.sh.cmake Added Paths: ----------- trunk/cmake/modules/qt.cmake trunk/drivers/qt.cpp trunk/drivers/qt.h Modified: trunk/cmake/modules/drivers-finish.cmake =================================================================== --- trunk/cmake/modules/drivers-finish.cmake 2009-03-05 15:34:56 UTC (rev 9674) +++ trunk/cmake/modules/drivers-finish.cmake 2009-03-05 16:07:41 UTC (rev 9675) @@ -58,6 +58,11 @@ ${CMAKE_SOURCE_DIR}/drivers/${DRIVER}.cc ${${DRIVER}_SOURCE} ) + elseif(DRIVER STREQUAL "qt") + set(${DRIVER}_SOURCE + ${CMAKE_SOURCE_DIR}/drivers/${DRIVER}.cpp + ${${DRIVER}_SOURCE} + ) else(DRIVER STREQUAL "wxwidgets") set(${DRIVER}_SOURCE ${CMAKE_SOURCE_DIR}/drivers/${DRIVER}.c Modified: trunk/cmake/modules/drivers-init.cmake =================================================================== --- trunk/cmake/modules/drivers-init.cmake 2009-03-05 15:34:56 UTC (rev 9674) +++ trunk/cmake/modules/drivers-init.cmake 2009-03-05 16:07:41 UTC (rev 9675) @@ -83,6 +83,7 @@ "xcairo:cairo:ON" "cgm:cgm:ON" "dg300:dg300:OFF" +"epspdfqt:qt:OFF" "gif:gd:ON" "jpeg:gd:ON" "png:gd:ON" @@ -113,7 +114,10 @@ # (psttf and pscairo) to get modern fonts for postscript results. "pstex:pstex:OFF" "psttf:psttf:ON" +"qtwidget:qt:OFF" +"rasterqt:qt:OFF" "svg:svg:ON" +"svgqt:qt:OFF" "conex:tek:OFF" "mskermit:tek:OFF" "tek4010:tek:OFF" Modified: trunk/cmake/modules/drivers.cmake =================================================================== --- trunk/cmake/modules/drivers.cmake 2009-03-05 15:34:56 UTC (rev 9674) +++ trunk/cmake/modules/drivers.cmake 2009-03-05 16:07:41 UTC (rev 9675) @@ -87,6 +87,7 @@ include(tk) include(pstex) include(psttf) +include(qt) include(wingcc) include(aqt) include(wxwidgets) Added: trunk/cmake/modules/qt.cmake =================================================================== --- trunk/cmake/modules/qt.cmake (rev 0) +++ trunk/cmake/modules/qt.cmake 2009-03-05 16:07:41 UTC (rev 9675) @@ -0,0 +1,36 @@ +# Naive way to (try to?) dissociate the SVG driver (not available on Qt 4.2) from the other drivers. Yet to be tested! + +if(PLD_svgqt) + FIND_PACKAGE(Qt4) + SET(QT_USE_QTSVG 1) + INCLUDE(${QT_USE_FILE}) + if(NOT QT4_FOUND) + set(PLD_svgqt OFF CACHE BOOL "Enable Qt SVG device" FORCE) + else(NOT QT4_FOUND) + set(qt_COMPILE_FLAGS) + foreach(DIR ${QT_INCLUDES}) + set(qt_COMPILE_FLAGS "${qt_COMPILE_FLAGS} -I${DIR}") + endforeach(DIR ${QT_INCLUDES}) + + set(qt_LINK_FLAGS ${QT_LIBRARIES}) + set(DRIVERS_LINK_FLAGS ${DRIVERS_LINK_FLAGS} ${qt_LINK_FLAGS}) + endif(NOT QT4_FOUND) +endif(PLD_svgqt) + +if(PLD_rasterqt OR PLD_epspdfqt OR PLD_qtwidget) + FIND_PACKAGE(Qt4) + INCLUDE(${QT_USE_FILE}) + if(NOT QT4_FOUND) + set(PLD_rasterqt OFF CACHE BOOL "Enable Qt raster device" FORCE) + set(PLD_epspdfqt OFF CACHE BOOL "Enable Qt EPS/PDF device" FORCE) + set(PLD_qtwidget OFF CACHE BOOL "Enable Qt EPS/PDF device" FORCE) + else(NOT QT4_FOUND) + set(qt_COMPILE_FLAGS) + foreach(DIR ${QT_INCLUDES}) + set(qt_COMPILE_FLAGS "${qt_COMPILE_FLAGS} -I${DIR}") + endforeach(DIR ${QT_INCLUDES}) + + set(qt_LINK_FLAGS ${QT_LIBRARIES}) + set(DRIVERS_LINK_FLAGS ${DRIVERS_LINK_FLAGS} ${qt_LINK_FLAGS}) + endif(NOT QT4_FOUND) +endif(PLD_rasterqt OR PLD_epspdfqt OR PLD_qtwidget) \ No newline at end of file Property changes on: trunk/cmake/modules/qt.cmake ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/config.h.cmake =================================================================== --- trunk/config.h.cmake 2009-03-05 15:34:56 UTC (rev 9674) +++ trunk/config.h.cmake 2009-03-05 16:07:41 UTC (rev 9675) @@ -197,6 +197,9 @@ /* Define if dg300 driver is present */ #cmakedefine PLD_dg300 +/* Define if the EPS/PDF Qt driver is present */ +#cmakedefine PLD_epspdfqt + /* Define if the Cario external context driver is present */ #cmakedefine PLD_extcairo @@ -278,12 +281,21 @@ /* Define if psttf driver is present */ #cmakedefine PLD_psttf +/* Define if Qt Widgete driver is present */ +#cmakedefine PLD_qtwidget + +/* Define if raster Qt driver is present */ +#cmakedefine PLD_rasterqt + /* Define if svg driver is present */ #cmakedefine PLD_svg /* Define if Cairo SVG driver is present */ #cmakedefine PLD_svgcairo +/* Define if SVG Qt driver is present */ +#cmakedefine PLD_svgqt + /* Define if tek4010 driver is present */ #cmakedefine PLD_tek4010 Modified: trunk/drivers/CMakeLists.txt =================================================================== --- trunk/drivers/CMakeLists.txt 2009-03-05 15:34:56 UTC (rev 9674) +++ trunk/drivers/CMakeLists.txt 2009-03-05 16:07:41 UTC (rev 9675) @@ -24,6 +24,13 @@ DESTINATION ${DOC_DIR} ) +if(PLD_rasterqt) +install( +FILES qt.h +DESTINATION ${INCLUDE_DIR} +) +endif(PLD_rasterqt) + if(ENABLE_DYNDRIVERS) set_source_files_properties( get-drv-info.c @@ -81,7 +88,18 @@ PROPERTIES COMPILE_FLAGS "-DUSINGDLL" ) endif(${SOURCE_ROOT_NAME}_COMPILE_FLAGS) - add_library(${SOURCE_ROOT_NAME} MODULE ${${SOURCE_ROOT_NAME}_SOURCE}) + if(SOURCE_ROOT_NAME STREQUAL "qt") + qt4_wrap_cpp(QT_MOC_OUTFILES ${CMAKE_CURRENT_SOURCE_DIR}/qt.h) + # Temporary debugging message. + message("QT_MOC_OUTFILES = ${QT_MOC_OUTFILES}") + set_source_files_properties( + ${QT_MOC_OUTFILES} + PROPERTIES GENERATED "ON" + ) + add_library(${SOURCE_ROOT_NAME} MODULE ${${SOURCE_ROOT_NAME}_SOURCE} ${QT_MOC_OUTFILES}) + else(SOURCE_ROOT_NAME STREQUAL "qt") + add_library(${SOURCE_ROOT_NAME} MODULE ${${SOURCE_ROOT_NAME}_SOURCE}) + endif(SOURCE_ROOT_NAME STREQUAL "qt") # ${SOURCE_ROOT_NAME}_LINK_FLAGS is ideally a list of the full path names # to libraries determined with find_library. However, the list can also # include link flags such as the -L and -l form of specifying libraries, Added: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp (rev 0) +++ trunk/drivers/qt.cpp 2009-03-05 16:07:41 UTC (rev 9675) @@ -0,0 +1,1153 @@ +/* + + 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 + + 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 + +*/ + +#include "qt.h" +// #include "moc_qt.cxx" + +PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_qt = +#if defined(PLD_rasterqt) + "rasterqt:Qt Raster driver:0:qt:66:rasterqt\n" +#endif +#if defined(PLD_svgqt) + "svgqt:Qt SVG driver:0:qt:67:svgqt\n" +#endif +#if defined(PLD_epspdfqt) + "epspdfqt:Qt EPS/PDF driver:0:qt:68:epspdfqt\n" +#endif +#if defined(PLD_qtwidget) + "qtwidget:Qt Widget:0:qt:69:qtwidget\n" +#endif +; + +#if defined(PLD_rasterqt) +void plD_dispatch_init_rasterqt(PLDispatchTable *pdt); +void plD_init_rasterqt(PLStream *); +void plD_eop_rasterqt(PLStream *); +#endif + +#if defined(PLD_svgqt) +void plD_dispatch_init_svgqt(PLDispatchTable *pdt); +void plD_init_svgqt(PLStream *); +void plD_eop_svgqt(PLStream *); +#endif + +#if defined(PLD_epspdfqt) +void plD_dispatch_init_epspdfqt(PLDispatchTable *pdt); +void plD_init_epspdfqt(PLStream *); +void plD_eop_epspdfqt(PLStream *); +#endif + +#if defined(PLD_qtwidget) +void plD_dispatch_init_qtwidget(PLDispatchTable *pdt); +void plD_init_qtwidget(PLStream *); +void plD_eop_qtwidget(PLStream *); +#endif + +void plD_line_qt(PLStream *, short, short, short, short); +void plD_polyline_qt(PLStream *, short*, short*, PLINT); +void plD_bop_qt(PLStream *){} +void plD_tidy_qt(PLStream *){} +void plD_state_qt(PLStream *, PLINT); +void plD_esc_qt(PLStream *, PLINT, void*); + +///////////// Generic Qt driver class ///////////////// + +QtPLDriver::QtPLDriver(PLINT i_iWidth, PLINT i_iHeight) +{ + m_dWidth=i_iWidth; + m_dHeight=i_iHeight; + downscale=1.; +} + +QtPLDriver::~QtPLDriver() +{} + +void QtPLDriver::drawLine(short x1, short y1, short x2, short y2) +{ + 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) +{ + 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) +{ + 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; +} + +void QtPLDriver::setColor(int r, int g, int b) +{ + QPen p=m_painterP->pen(); + p.setColor(QColor(r, g, b)); + m_painterP->setPen(p); + + QBrush B=m_painterP->brush(); + B.setColor(QColor(r, g, b)); + m_painterP->setBrush(B); +} + +void QtPLDriver::setWidth(PLINT w) +{ + QPen p=m_painterP->pen(); + p.setWidth(w); + m_painterP->setPen(p); +} + +void QtPLDriver::setDashed(PLINT nms, PLINT* mark, PLINT* space) +{ + // 72 dpi + // => 72/25400 = 0.00283 dot for 1 micron + QVector<qreal> vect; + for(int i=0; i<nms; ++i) + { + vect << (PLFLT)mark[i]*0.00283; + vect << (PLFLT)space[i]*0.00283; + } + QPen p=m_painterP->pen(); + p.setDashPattern(vect); + m_painterP->setPen(p); +} + +void QtPLDriver::setSolid() +{ + QPen p=m_painterP->pen(); + p.setStyle(Qt::SolidLine); + m_painterP->setPen(p); +} + +void QtPLDriver::savePlot(char* fileName) +{ +} + +//////////// Buffered driver /////////////////////// + +QtPLBufferedDriver::QtPLBufferedDriver(PLINT i_iWidth, PLINT i_iHeight): + QtPLDriver(i_iWidth, i_iHeight) +{} + +QtPLBufferedDriver::~QtPLBufferedDriver() +{ + clearBuffer(); +} + +void QtPLBufferedDriver::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; + break; + + case SET_DASHED: + delete[] i->Data.PolylineStruct.x; + break; + + default: + break; + } + } + + m_listBuffer.clear(); +} + +void QtPLBufferedDriver::drawLine(short x1, short y1, short x2, short y2) +{ + BufferElement el; + el.Element=LINE; + 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 QtPLBufferedDriver::drawPolyline(short * x, short * y, PLINT npts) +{ + BufferElement el; + el.Element=POLYLINE; + 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 QtPLBufferedDriver::drawPolygon(short * x, short * y, PLINT npts) +{ + BufferElement el; + el.Element=POLYGON; + 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); + } + if(el.Data.PolylineStruct.x[0]==el.Data.PolylineStruct.x[npts-1] && el.Data.PolylineStruct.y[0]==el.Data.PolylineStruct.y[npts-1]) + { + --el.Data.PolylineStruct.npts; + } + + m_listBuffer.append(el); +} + +void QtPLBufferedDriver::setColor(int r, int g, int b) +{ + BufferElement el; + el.Element=SET_COLOUR; + el.Data.ColourStruct.R=r; + el.Data.ColourStruct.G=g; + el.Data.ColourStruct.B=b; + + m_listBuffer.append(el); +} + +void QtPLBufferedDriver::setWidth(PLINT w) +{ + BufferElement el; + el.Element=SET_WIDTH; + el.Data.intParam=w; + m_listBuffer.append(el); +} + +void QtPLBufferedDriver::setDashed(PLINT nms, PLINT* mark, PLINT* space) +{ + BufferElement el; + el.Element=SET_DASHED; + el.Data.PolylineStruct.npts=2*nms; + el.Data.PolylineStruct.x=new PLFLT[2*nms]; + for(int i=0; i<nms; i++) + { + el.Data.PolylineStruct.x[2*i]=(PLFLT)mark[i]*0.00283; + el.Data.PolylineStruct.x[2*i+1]=(PLFLT)space[i]*0.00283; + } + + m_listBuffer.append(el); +} + +void QtPLBufferedDriver::setSolid() +{ + BufferElement el; + el.Element=SET_SOLID; + m_listBuffer.append(el); +} + +void QtPLBufferedDriver::savePlot(char* fileName) +{ +} + +void QtPLBufferedDriver::doPlot(QPainter* i_painterP, double x_fact, double y_fact, double x_offset, double y_offset) +{ + QLineF line; + QPointF * polyline; + PLINT npts; + QVector<qreal> vect; + + if(i_painterP==NULL) i_painterP=m_painterP; + + QPen p=i_painterP->pen(); + QBrush b=i_painterP->brush(); + b.setStyle(Qt::SolidPattern); + i_painterP->setBrush(b); + + i_painterP->fillRect(x_offset, y_offset, m_dWidth*x_fact, m_dHeight*y_fact, QBrush(Qt::black)); + + if(m_listBuffer.empty()) + { + return; + } + 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); + i_painterP->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); + } + i_painterP->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); + } + i_painterP->drawPolygon(polyline, npts); + + delete[] polyline; + break; + + case SET_WIDTH: + + p.setWidthF(i->Data.intParam); + i_painterP->setPen(p); + break; + + case SET_COLOUR: + p.setColor(QColor(i->Data.ColourStruct.R, i->Data.ColourStruct.G, i->Data.ColourStruct.B)); + i_painterP->setPen(p); + b.setColor(QColor(i->Data.ColourStruct.R, i->Data.ColourStruct.G, i->Data.ColourStruct.B)); + i_painterP->setBrush(b); + break; + + case SET_DASHED: + vect.clear(); + for(int j=0; j<i->Data.PolylineStruct.npts; j++) + { + if(i->Data.PolylineStruct.x[j]>=1.) //TODO remove that when bug #228554 of Qt is solved on Windows... + vect << i->Data.PolylineStruct.x[j]; + else + vect <<1.; + } + p.setDashPattern(vect); + i_painterP->setPen(p); + break; + + case SET_SOLID: + p.setStyle(Qt::SolidLine); + i_painterP->setPen(p); + break; + + case SET_SMOOTH: + i_painterP->setRenderHint(QPainter::Antialiasing, i->Data.intParam); + break; + + default: + break; + } + } +} + +void QtPLBufferedDriver::getPlotParameters(double & io_dXFact, double & io_dYFact, double & io_dXOffset, double & io_dYOffset) +{ + io_dXFact=1.; + io_dYFact=1.; + io_dXOffset=0.; + io_dYOffset=0.; +} + +//////////////////// Generic driver interface /////////////// + +void plD_line_qt(PLStream * pls, short x1a, short y1a, short x2a, short y2a) +{ + QtPLDriver * widget=NULL; +#if defined(PLD_rasterqt) + if(widget==NULL) widget=dynamic_cast<QtRasterDevice*>((QtPLDriver *) pls->dev); +#endif +#if defined(PLD_svgqt) + if(widget==NULL) widget=dynamic_cast<QtSVGDevice*>((QtPLDriver *) pls->dev); +#endif +#if defined(PLD_epspdfqt) + if(widget==NULL) widget=dynamic_cast<QtEPSDevice*>((QtPLDriver *) pls->dev); +#endif +#if defined(PLD_qtwidget) + if(widget==NULL) widget=dynamic_cast<QtPLWidget*>((QWidget *) pls->dev); +#endif + if(widget==NULL) return; + + widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b); + widget->drawLine(x1a, y1a, x2a, y2a); +} + +void plD_polyline_qt(PLStream *pls, short *xa, short *ya, PLINT npts) +{ + QtPLDriver * widget=NULL; +#if defined(PLD_rasterqt) + if(widget==NULL) widget=dynamic_cast<QtRasterDevice*>((QtPLDriver *) pls->dev); +#endif +#if defined(PLD_svgqt) + if(widget==NULL) widget=dynamic_cast<QtSVGDevice*>((QtPLDriver *) pls->dev); +#endif +#if defined(PLD_epspdfqt) + if(widget==NULL) widget=dynamic_cast<QtEPSDevice*>((QtPLDriver *) pls->dev); +#endif +#if defined(PLD_qtwidget) + if(widget==NULL) widget=dynamic_cast<QtPLWidget*>((QWidget *) pls->dev); +#endif + if(widget==NULL) return; + + widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b); + widget->drawPolyline(xa, ya, npts); +} + +void plD_esc_qt(PLStream * pls, PLINT op, void* ptr) +{ + short *xa, *ya; + PLINT i, j; + QtPLDriver * widget=NULL; +#if defined(PLD_rasterqt) + if(widget==NULL) widget=dynamic_cast<QtRasterDevice*>((QtPLDriver *) pls->dev); +#endif +#if defined(PLD_svgqt) + if(widget==NULL) widget=dynamic_cast<QtSVGDevice*>((QtPLDriver *) pls->dev); +#endif +#if defined(PLD_epspdfqt) + if(widget==NULL) widget=dynamic_cast<QtEPSDevice*>((QtPLDriver *) pls->dev); +#endif +#if defined(PLD_qtwidget) + if(widget==NULL) widget=dynamic_cast<QtPLWidget*>((QWidget *) pls->dev); +#endif + if(widget==NULL) return; + + switch(op) + { + case PLESC_DASH: + widget->setDashed(pls->nms, pls->mark, pls->space); + widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b); + 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]; + + for (i = 0; i < pls->dev_npts; i++) + { + xa[i] = pls->dev_x[i]; + ya[i] = pls->dev_y[i]; + } + widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b); + widget->drawPolygon(xa, ya, pls->dev_npts); + + delete[] xa; + delete[] ya; + break; + + default: break; + } +} + +void plD_state_qt(PLStream * pls, PLINT op) +{ + QtPLDriver * widget=NULL; +#if defined(PLD_rasterqt) + if(widget==NULL) widget=dynamic_cast<QtRasterDevice*>((QtPLDriver *) pls->dev); +#endif +#if defined(PLD_svgqt) + if(widget==NULL) widget=dynamic_cast<QtSVGDevice*>((QtPLDriver *) pls->dev); +#endif +#if defined(PLD_epspdfqt) + if(widget==NULL) widget=dynamic_cast<QtEPSDevice*>((QtPLDriver *) pls->dev); +#endif +#if defined(PLD_qtwidget) + if(widget==NULL) widget=dynamic_cast<QtPLWidget*>((QWidget *) pls->dev); +#endif + if(widget==NULL) return; + + switch(op) + { + case PLSTATE_WIDTH: + widget->setWidth(pls->width); + break; + + case PLSTATE_COLOR0: + widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b); + break; + + case PLSTATE_COLOR1: + widget->setColor(pls->curcolor.r, pls->curcolor.g, pls->curcolor.b); + break; + + + default: break; + } +} + +#if defined(PLD_rasterqt) +QtRasterDevice::QtRasterDevice(int i_iWidth, int i_iHeight): + QtPLDriver(i_iWidth, i_iHeight), + QImage(i_iWidth, i_iHeight, QImage::Format_RGB32) +{ + m_painterP=new QPainter(this); + QBrush b=m_painterP->brush(); + b.setStyle(Qt::SolidPattern); + m_painterP->setBrush(b); + m_painterP->setRenderHint(QPainter::Antialiasing, true); + m_painterP->fillRect(0, 0, width(), height(), QBrush(Qt::black)); + pageCounter=0; +} + +QString QtRasterDevice::getFileName(char* fileName) +{ + QString fn(fileName); + + if(pageCounter==0) return fn; + + int pos=fn.lastIndexOf("."); + if(pos<0) pos=fn.length(); + QString res=fn.insert(pos, QString("_page%1").arg(pageCounter+1)); + return res; +} + +void QtRasterDevice::savePlot(char* fileName) +{ + m_painterP->end(); + save(getFileName(fileName), 0, 85); + + ++pageCounter; + 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_dispatch_init_rasterqt(PLDispatchTable *pdt) +{ +#ifndef ENABLE_DYNDRIVERS + pdt->pl_MenuStr = "Qt Raster Driver"; + pdt->pl_DevName = "rasterqt"; +#endif + pdt->pl_type = plDevType_FileOriented; + pdt->pl_seq = 66; + pdt->pl_init = (plD_init_fp) plD_init_rasterqt; + pdt->pl_line = (plD_line_fp) plD_line_qt; + pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; + pdt->pl_eop = (plD_eop_fp) plD_eop_rasterqt; + pdt->pl_bop = (plD_bop_fp) plD_bop_qt; + pdt->pl_tidy = (plD_tidy_fp) plD_tidy_qt; + pdt->pl_state = (plD_state_fp) plD_state_qt; + pdt->pl_esc = (plD_esc_fp) plD_esc_qt; +} + +void plD_init_rasterqt(PLStream * pls) +{ + /* Stream setup */ + pls->color = 1; + pls->plbuf_write=0; + pls->dev_fill0 = 1; + pls->dev_fill1 = 0; + pls->dev_dash=1; + pls->dev_flush=1; + pls->dev_clear=1; + pls->termin=0; + + pls->dev=new QtRasterDevice; + + if (pls->xlength <= 0 || pls->ylength <= 0) + { + pls->xlength = ((QtRasterDevice*)(pls->dev))->m_dWidth; + pls->ylength = ((QtRasterDevice*)(pls->dev))->m_dHeight; + } + + 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); + + printf("The file format will be determined by the file name extension\n"); + printf("Possible extensions are: bmp, jpg, png, ppm, tiff, xbm, xpm\n"); + plOpenFile(pls); +} + +void plD_eop_rasterqt(PLStream *pls) +{ + ((QtRasterDevice *)pls->dev)->savePlot(pls->FileName); +} +#endif + + +#if defined(PLD_svgqt) +QtSVGDevice::QtSVGDevice(int i_iWidth, int i_iHeight): + QtPLBufferedDriver(i_iWidth, i_iHeight) +{ + setSize(QSize(m_dWidth, m_dHeight)); + pageCounter=0; +} + +QtSVGDevice::~QtSVGDevice() +{ + clearBuffer(); +} + +QString QtSVGDevice::getFileName(char* fileName) +{ + QString fn(fileName); + + if(pageCounter==0) return fn; + + int pos=fn.lastIndexOf("."); + if(pos<0) pos=fn.length(); + QString res=fn.insert(pos, QString("_page%1").arg(pageCounter+1)); + return res; +} + +void QtSVGDevice::savePlot(char* fileName) +{ + setFileName(getFileName(fileName)); + setResolution(72); + + m_painterP=new QPainter(this); + doPlot(); + m_painterP->end(); +} + +void plD_dispatch_init_svgqt(PLDispatchTable *pdt) +{ +#ifndef ENABLE_DYNDRIVERS + pdt->pl_MenuStr = "Qt SVG Driver"; + pdt->pl_DevName = "svgqt"; +#endif + pdt->pl_type = plDevType_FileOriented; + pdt->pl_seq = 67; + pdt->pl_init = (plD_init_fp) plD_init_svgqt; + pdt->pl_line = (plD_line_fp) plD_line_qt; + pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; + pdt->pl_eop = (plD_eop_fp) plD_eop_svgqt; + pdt->pl_bop = (plD_bop_fp) plD_bop_qt; + pdt->pl_tidy = (plD_tidy_fp) plD_tidy_qt; + pdt->pl_state = (plD_state_fp) plD_state_qt; + pdt->pl_esc = (plD_esc_fp) plD_esc_qt; +} + +void plD_init_svgqt(PLStream * pls) +{ + /* Stream setup */ + pls->color = 1; + pls->plbuf_write=0; + pls->dev_fill0 = 1; + pls->dev_fill1 = 0; + pls->dev_dash=1; + pls->dev_flush=1; + pls->dev_clear=1; + pls->termin=0; + + pls->dev=new QtSVGDevice; + + if (pls->xlength <= 0 || pls->ylength <= 0) + { + pls->xlength = ((QtSVGDevice*)(pls->dev))->m_dWidth; + pls->ylength = ((QtSVGDevice*)(pls->dev))->m_dHeight; + } + + if (pls->xlength > pls->ylength) + ((QtSVGDevice*)(pls->dev))->downscale = (PLFLT)pls->xlength/(PLFLT)(PIXELS_X-1); + else + ((QtSVGDevice*)(pls->dev))->downscale = (PLFLT)pls->ylength/(PLFLT)PIXELS_Y; + + plP_setphy((PLINT) 0, (PLINT) (pls->xlength / ((QtSVGDevice*)(pls->dev))->downscale), (PLINT) 0, (PLINT) (pls->ylength / ((QtSVGDevice*)(pls->dev))->downscale)); + + plP_setpxl(DPI/25.4/((QtSVGDevice*)(pls->dev))->downscale, DPI/25.4/((QtSVGDevice*)(pls->dev))->downscale); + + plOpenFile(pls); +} + +void plD_eop_svgqt(PLStream *pls) +{ + double downscale; + int pageCounter; + QSize s; + + ((QtSVGDevice *)pls->dev)->savePlot(pls->FileName); + downscale=((QtSVGDevice *)pls->dev)->downscale; + pageCounter=((QtSVGDevice *)pls->dev)->pageCounter; + s=((QtSVGDevice *)pls->dev)->size(); + delete ((QtSVGDevice *)pls->dev); + + pls->dev=new QtSVGDevice(s.width(), s.height()); + ((QtSVGDevice *)pls->dev)->downscale=downscale; + ((QtSVGDevice *)pls->dev)->pageCounter=pageCounter+1; +} + +#endif + +#if defined (PLD_epspdfqt) +QtEPSDevice::QtEPSDevice() +{ + pageCounter=0; + setPageSize(QPrinter::A4); + setResolution(DPI); + setColorMode(QPrinter::Color); + setOrientation(QPrinter::Landscape); + + m_dWidth=pageRect().width(); + m_dHeight=pageRect().height(); +} + +QtEPSDevice::~QtEPSDevice() +{ + clearBuffer(); +} + +QString QtEPSDevice::getFileName(char* fileName) +{ + QString fn(fileName); + + if(pageCounter==0) return fn; + + int pos=fn.lastIndexOf("."); + if(pos<0) pos=fn.length(); + QString res=fn.insert(pos, QString("_page%1").arg(pageCounter+1)); + return res; +} + +void QtEPSDevice::savePlot(char* fileName) +{ + setOutputFileName(getFileName(fileName)); + if(QString(fileName).endsWith(".ps") || QString(fileName).endsWith(".eps")) + { + setOutputFormat(QPrinter::PostScriptFormat); + } + else if(QString(fileName).endsWith(".pdf")) + { + setOutputFormat(QPrinter::PdfFormat); + } + else + { + std::cerr << "Unhandled file format: " << fileName << std::endl; + return; + } + + m_painterP=new QPainter(this); + doPlot(); + m_painterP->end(); +} + +void plD_dispatch_init_epspdfqt(PLDispatchTable *pdt) +{ +#ifndef ENABLE_DYNDRIVERS + pdt->pl_MenuStr = "Qt EPS/PDF Driver"; + pdt->pl_DevName = "epspdfqt"; +#endif + pdt->pl_type = plDevType_FileOriented; + pdt->pl_seq = 68; + pdt->pl_init = (plD_init_fp) plD_init_epspdfqt; + pdt->pl_line = (plD_line_fp) plD_line_qt; + pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; + pdt->pl_eop = (plD_eop_fp) plD_eop_epspdfqt; + pdt->pl_bop = (plD_bop_fp) plD_bop_qt; + pdt->pl_tidy = (plD_tidy_fp) plD_tidy_qt; + pdt->pl_state = (plD_state_fp) plD_state_qt; + pdt->pl_esc = (plD_esc_fp) plD_esc_qt; +} + +void plD_init_epspdfqt(PLStream * pls) +{ + /* Stream setup */ + pls->color = 1; + pls->plbuf_write=0; + pls->dev_fill0 = 1; + pls->dev_fill1 = 0; + pls->dev_dash=1; + pls->dev_flush=1; + pls->dev_clear=1; + pls->termin=0; + + int argc=0; + char argv[]={'\0'}; + QApplication * app=new QApplication(argc, (char**)&argv); + pls->dev=new QtEPSDevice; + delete app; + + if (pls->xlength <= 0 || pls->ylength <= 0) + { + pls->xlength = ((QtSVGDevice*)(pls->dev))->m_dWidth; + pls->ylength = ((QtSVGDevice*)(pls->dev))->m_dHeight; + } + + if (pls->xlength > pls->ylength) + ((QtEPSDevice*)(pls->dev))->downscale = (PLFLT)pls->xlength/(PLFLT)(PIXELS_X-1); + else + ((QtEPSDevice*)(pls->dev))->downscale = (PLFLT)pls->ylength/(PLFLT)PIXELS_Y; + + plP_setphy((PLINT) 0, (PLINT) (pls->xlength / ((QtEPSDevice*)(pls->dev))->downscale), (PLINT) 0, (PLINT) (pls->ylength / ((QtEPSDevice*)(pls->dev))->downscale)); + + plP_setpxl(DPI/25.4/((QtEPSDevice*)(pls->dev))->downscale, DPI/25.4/((QtEPSDevice*)(pls->dev))->downscale); + + printf("The file format will be determined by the file name extension\n"); + printf("Possible extensions are: eps, pdf\n"); + plOpenFile(pls); +} + +void plD_eop_epspdfqt(PLStream *pls) +{ + double downscale; + int pageCounter; + + int argc=0; + char argv[]={'\0'}; + + ((QtEPSDevice *)pls->dev)->savePlot(pls->FileName); + downscale=((QtSVGDevice *)pls->dev)->downscale; + pageCounter=((QtSVGDevice *)pls->dev)->pageCounter; + delete ((QtEPSDevice *)pls->dev); + + QApplication * app=new QApplication(argc, (char**)&argv); + pls->dev=new QtEPSDevice; + ((QtEPSDevice *)pls->dev)->downscale=downscale; + ((QtEPSDevice *)pls->dev)->pageCounter=pageCounter+1; + delete app; +} + +#if defined (PLD_qtwidget) + +QtPLWidget::QtPLWidget(int i_iWidth, int i_iHeight, QWidget* parent): + QWidget(parent), QtPLBufferedDriver(i_iWidth, i_iHeight) +{ + m_painterP=new QPainter; + + m_dAspectRatio=(double)i_iWidth/(double)i_iHeight; + + cursorParameters.isTracking=false; + m_pixPixmap=NULL; + m_iOldSize=0; + + resize(i_iWidth, i_iHeight); + +} + +QtPLWidget::~QtPLWidget() +{ + clearBuffer(); + if(m_pixPixmap!=NULL) delete m_pixPixmap; +} + +void QtPLWidget::setSmooth(bool b) +{ + BufferElement el; + el.Element=SET_SMOOTH; + el.Data.intParam=b; + m_listBuffer.append(el); +} + +void QtPLWidget::clearWidget() +{ + clearBuffer(); + m_bAwaitingRedraw=true; + update(); +} + +void QtPLWidget::captureMousePlotCoords(double * xi, double* yi, double * xf, double * yf) +{ + setMouseTracking(true); + cursorParameters.isTracking=true; + cursorParameters.cursor_start_x= + cursorParameters.cursor_start_y= + cursorParameters.cursor_end_x= + cursorParameters.cursor_end_y=-1.; + cursorParameters.step=1; + do + { + QCoreApplication::processEvents(QEventLoop::AllEvents, 10); + + } while(cursorParameters.isTracking); + + PLFLT a,b; + PLINT c; + plcalc_world(cursorParameters.cursor_start_x, 1.-cursorParameters.cursor_start_y, &a, &b, &c); + *xi=a; + *yi=b; + plcalc_world(cursorParameters.cursor_end_x, 1.-cursorParameters.cursor_end_y, &a, &b, &c); + *xf=a; + *yf=b; + +} + +void QtPLWidget::captureMouseDeviceCoords(double * xi, double* yi, double * xf, double * yf) +{ + setMouseTracking(true); + cursorParameters.isTracking=true; + cursorParameters.cursor_start_x= + cursorParameters.cursor_start_y= + cursorParameters.cursor_end_x= + cursorParameters.cursor_end_y=-1.; + cursorParameters.step=1; + do + { + QCoreApplication::processEvents(QEventLoop::AllEvents, 10); + + } while(cursorParameters.isTracking); + + *xi=cursorParameters.cursor_start_x; + *yi=cursorParameters.cursor_start_y; + *xf=cursorParameters.cursor_end_x; + *yf=cursorParameters.cursor_end_y; +} + +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 actual redraw + if(m_bAwaitingRedraw || m_pixPixmap==NULL || m_listBuffer.size()!=m_iOldSize ) + { + if(m_pixPixmap!=NULL) delete m_pixPixmap; + m_pixPixmap=new QPixmap(width(), height()); + QPainter * painter=new QPainter; + painter->begin(m_pixPixmap); + 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)); + doPlot(painter, x_fact, y_fact, x_offset, y_offset); + painter->end(); + m_bAwaitingRedraw=false; + m_iOldSize=m_listBuffer.size(); + } + + m_painterP->begin(this); + + // repaint plot + m_painterP->drawPixmap(0, 0, *m_pixPixmap); + + // now paint the cursor tracking patterns + if(cursorParameters.isTracking) + { + QPen p=m_painterP->pen(); + p.setColor(Qt::white); + if(cursorParameters.step==1) + { + m_painterP->setPen(p); + m_painterP->drawLine((int)(cursorParameters.cursor_start_x*x_fact*m_dWidth+x_offset), 0, (int)(cursorParameters.cursor_start_x*x_fact*m_dWidth+x_offset), height()); + m_painterP->drawLine(0, (int)(cursorParameters.cursor_start_y*y_fact*m_dHeight+y_offset), width(), (int)(cursorParameters.cursor_start_y*y_fact*m_dHeight+y_offset)); + } + else + { + p.setStyle(Qt::DotLine); + m_painterP->setPen(p); + m_painterP->drawLine((int)(cursorParameters.cursor_start_x*x_fact*m_dWidth+x_offset), 0, (int)(cursorParameters.cursor_start_x*x_fact*m_dWidth+x_offset), height()); + m_painterP->drawLine(0, (int)(cursorParameters.cursor_start_y*y_fact*m_dHeight+y_offset), width(), (int)(cursorParameters.cursor_start_y*y_fact*m_dHeight+y_offset)); + p.setStyle(Qt::SolidLine); + m_painterP->setPen(p); + m_painterP->drawLine((int)(cursorParameters.cursor_end_x*x_fact*m_dWidth+x_offset), 0, (int)(cursorParameters.cursor_end_x*x_fact*m_dWidth+x_offset), height()); + m_painterP->drawLine(0, (int)(cursorParameters.cursor_end_y*y_fact*m_dHeight+y_offset), width(), (int)(cursorParameters.cursor_end_y*y_fact*m_dHeight+y_offset)); + } + } + + m_painterP->end(); +} + +void QtPLWidget::mousePressEvent(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); + + PLFLT X=(PLFLT)(event->x()-x_offset)/(m_dWidth*x_fact); + PLFLT Y=(PLFLT)(event->y()-y_offset)/(m_dHeight*y_fact); + + if(cursorParameters.step==1) + { + cursorParameters.cursor_start_x=X; + cursorParameters.cursor_start_y=Y; + cursorParameters.step=2; // First step of selection done, going to the next one + update(); + } +} + +void QtPLWidget::mouseReleaseEvent(QMouseEvent* event) +{ + 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); + + PLFLT X=(PLFLT)(event->x()-x_offset)/(m_dWidth*x_fact); + PLFLT Y=(PLFLT)(event->y()-y_offset)/(m_dHeight*y_fact); + + if(cursorParameters.step!=1) + { + cursorParameters.cursor_end_x=X; + cursorParameters.cursor_end_y=Y; + cursorParameters.isTracking=false; + setMouseTracking(false); + update(); + } +} + +void QtPLWidget::mouseMoveEvent(QMouseEvent* event) +{ + this->activateWindow(); + this->raise(); + + 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); + + PLFLT X=(PLFLT)(event->x()-x_offset)/(m_dWidth*x_fact); + PLFLT Y=(PLFLT)(event->y()-y_offset)/(m_dHeight*y_fact); + + if(cursorParameters.step==1) + { + cursorParameters.cursor_start_x=X; + cursorParameters.cursor_start_y=Y; + } + else + { + cursorParameters.cursor_end_x=X; + cursorParameters.cursor_end_y=Y; + } + + update(); +} + +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_dYFact*m_dAspectRatio; + 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_dXFact/m_dAspectRatio; + io_dXOffset=0.; + io_dYOffset=(h-io_dYFact*m_dHeight)/2.; + } +} + + +void plD_dispatch_init_qtwidget(PLDispatchTable *pdt) +{ +#ifndef ENABLE_DYNDRIVERS + pdt->pl_MenuStr = "Qt Widget"; + pdt->pl_DevName = "qtwidget"; +#endif + pdt->pl_type = plDevType_Interactive; + pdt->pl_seq = 69; + pdt->pl_init = (plD_init_fp) plD_init_qtwidget; + pdt->pl_line = (plD_line_fp) plD_line_qt; + pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; + pdt->pl_eop = (plD_eop_fp) plD_eop_qtwidget; + pdt->pl_bop = (plD_bop_fp) plD_bop_qt; + pdt->pl_tidy = (plD_tidy_fp) plD_tidy_qt; + pdt->pl_state = (plD_state_fp) plD_state_qt; + pdt->pl_esc = (plD_esc_fp) plD_esc_qt; +} + +void plsqtdev(QtPLWidget* dev) +{ + if(dev==NULL) return; + + PLINT w, h; + plsc->dev = (void*)dev; + plsc->xlength = dev->m_dWidth; + plsc->ylength = dev->m_dHeight; + + if (plsc->xlength > plsc->ylength) + dev->downscale = (PLFLT)plsc->xlength/(PLFLT)(PIXELS_X-1); + else + dev->downscale = (PLFLT)plsc->ylength/(PLFLT)PIXELS_Y; + + plP_setphy((PLINT) 0, (PLINT) (plsc->xlength / dev->downscale), (PLINT) 0, (PLINT) (plsc->ylength / dev->downscale)); + + plP_setpxl(DPI/25.4/dev->downscale, DPI/25.4/dev->downscale); +} + +void plD_init_qtwidget(PLStream * pls) +{ + if ((pls->phyxma == 0) || (pls->dev == NULL)) { + plexit("Must call plsqtdev first to set user plotting widget!"); + } + + pls->color = 1; /* Is a color device */ + pls->plbuf_write=0; + pls->dev_fill0 = 1; /* Handle solid fills */ + pls->dev_fill1 = 0; + pls->dev_dash=1; + pls->dev_flush=1; + pls->dev_clear=1; + pls->termin=1; +} + +void plD_eop_qtwidget(PLStream *pls) +{ + ((QtPLWidget *)pls->dev)->clearWidget(); +} +#endif + +#endif Property changes on: trunk/drivers/qt.cpp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/drivers/qt.h =================================================================== --- trunk/drivers/qt.h (rev 0) +++ trunk/drivers/qt.h 2009-03-05 16:07:41 UTC (rev 9675) @@ -0,0 +1,262 @@ +/* + + 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 + + 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 + +*/ + +#ifndef QT_H +#define QT_H + +#include <iostream> +#include <QImage> +#include <QPainter> +#include <QLinkedList> +#include <QSvgGenerator> +#include <QPrinter> +#include <QApplication> +#include <QWidget> +#include <QMouseEvent> + +#include "plplotP.h" +#include "drivers.h" + +#define DPI 72 +#define QT_DEFAULT_X 842 +#define QT_DEFAULT_Y 598 + +typedef enum ElementType_ +{ + LINE, + POLYLINE, + POLYGON, + SET_WIDTH, + SET_COLOUR, + SET_DASHED, + SET_SOLID, + SET_SMOOTH +} ElementType; + +class BufferElement +{ + public: + + ElementType Element; + + union DataType + { + struct LineStruct_ + { + PLFLT x1; + PLFLT x2; + PLFLT y1; + PLFLT y2; + } LineStruct; + + struct PolylineStruct_ + { + PLINT npts; + PLFLT* x; + PLFLT* y; + } PolylineStruct; + + struct ColourStruct_ + { + PLINT R, G, B; + } ColourStruct; + + PLINT intParam; + PLFLT fltParam; + } Data; +}; + + +class QtPLDriver +{ + public: + QtPLDriver(PLINT i_iWidth=QT_DEFAULT_X, PLINT i_iHeight=QT_DEFAULT_Y); + + virtual ~QtPLDriver(); + + 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 setColor(int r, int g, int b); + + virtual void setWidth(PLINT w); + + virtual void setDashed(PLINT nms, PLINT* mark, PLINT* space); + + virtual void setSolid(); + + virtual void savePlot(char* fileName); + + double downscale; + double m_dWidth, m_dHeight; + protected: + + QPainter* m_painterP; +}; + +class QtPLBufferedDriver: public QtPLDriver +{ + public: + QtPLBufferedDriver(PLINT i_iWidth=QT_DEFAULT_X, PLINT i_iHeight=QT_DEFAULT_Y); + + virtual ~QtPLBufferedDriver(); + + 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 setColor(int r, int g, int b); + + virtual void setWidth(PLINT r); + + virtual void setDashed(PLINT nms, PLINT* mark, PLINT* space); + + virtual void setSolid(); + + virtual void savePlot(char* fileName); + + protected: + + virtual void doPlot(QPainter* p=NULL, double x_fact=1., double y_fact=1., double x_offset=0., double y_offset=0.); + + virtual void getPlotParameters(double & io_dXFact, double & io_dYFact, double & io_dXOffset, double & io_dYOffset); + + void clearBuffer(); + + QLinkedList<BufferElement> m_listBuffer; +}; + +#if defined (PLD_rasterqt) +class QtRasterDevice: public QtPLDriver, public QImage +{ + public: + QtRasterDevice(int i_iWidth=QT_DEFAULT_X, + int i_iHeight=QT_DEFAULT_Y); + + virtual ~QtRasterDevice(){} + + QString getFileName(char* fileName); + + void savePlot(char* fileName); + + protected: + int pageCounter; + +}; +#endif + +#if defined (PLD_svgqt) +class QtSVGDevice: public QtPLBufferedDriver, public QSvgGenerator +{ + public: + QtSVGDevice(int i_iWidth=QT_DEFAULT_X, + int i_iHeight=QT_DEFAULT_Y); + + virtual ~QtSVGDevice(); + + QString getFileName(char* fileName); + + void savePlot(char* fileName); + + int pageCounter; + protected: +}; +#endif + +#if defined (PLD_epspdfqt) +class QtEPSDevice: public QtPLBufferedDriver, public QPrinter +{ + public: + QtEPSDevice(); + + virtual ~QtEPSDevice(); + + QString getFileName(char* fileName); + + void savePlot(char* fileName); + + int pageCounter; + protected: + +}; +#endif + +#if defined (PLD_qtwidget) + +class QtPLWidget: public QWidget, public QtPLBufferedDriver +{ + 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 setSmooth(bool); + + void clearWidget(); + + public slots: + + void captureMousePlotCoords(double* xi, double* yi, double* xf, double* yf); + void captureMouseDeviceCoords(double* xi, double* yi, double* xf, double* yf); + + protected slots: + + void resizeEvent(QResizeEvent*); + void paintEvent(QPaintEvent*); + void mousePressEvent(QMouseEvent*); + void mouseReleaseEvent(QMouseEvent*); + void mouseMoveEvent(QMouseEvent*); + + protected: + + void getPlotParameters(double & io_dXFact, double & io_dYFact, double & io_dXOffset, double & io_dYOffset); + + struct + { + bool isTracking; + int step; //1 for first part, 2 for second part + double cursor_start_x, cursor_start_y; + double cursor_end_x, cursor_end_y; + } cursorParameters; + + double m_dAspectRatio; + QPixmap * m_pixPixmap; // to avoid redrawing everything + bool m_bAwaitingRedraw; + int m_iOldSize; +}; + +void plsqtdev(QtPLWidget *plotdev); +#endif + +#endif Property changes on: trunk/drivers/qt.h ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/include/drivers.h =================================================================== --- trunk/include/drivers.h 2009-03-05 15:34:56 UTC (rev 9674) +++ trunk/include/drivers.h 2009-03-05 16:07:41 UTC (rev 9675) @@ -97,6 +97,10 @@ PLDLLIMPEXP_DRIVER void plD_dispatch_init_pngcairo ( PLDispatchTable *pdt ); PLDLLIMPEXP_DRIVER void plD_dispatch_init_memcairo ( PLDispatchTable *pdt ); PLDLLIMPEXP_DRIVER void plD_dispatch_init_extcairo ( PLDispatchTable *pdt ); +PLDLLIMPEXP_DRIVER void plD_dispatch_init_rasterqt ( PLDispatchTable *pdt ); +PLDLLIMPEXP_DRIVER void plD_dispatch_init_svgqt ( PLDispatchTable *pdt ); +PLDLLIMPEXP_DRIVER void plD_dispatch_init_epspdfqt ( PLDispatchTable *pdt ); +PLDLLIMPEXP_DRIVER void plD_dispatch_init_qtwidget ( PLDispatchTable *pdt ); /* Prototypes for plot buffer calls. */ Modified: trunk/include/plDevs.h.cmake =================================================================== --- trunk/include/plDevs.h.cmake 2009-03-05 15:34:56 UTC (rev 9674) +++ trunk/include/plDevs.h.cmake 2009-03-05 16:07:41 UTC (rev 9675) @@ -85,6 +85,9 @@ #cmakedefine PLD_pngcairo #cmakedefine PLD_memcairo #cmakedefine PLD_extcairo +#cmakedefine PLD_rasterqt +#cmakedefine PLD_svgqt +#cmakedefine PLD_epspdfqt +#cmakedefine PLD_qtwidget - #endif /* __PLDEVS_H__ */ Modified: trunk/include/plcore.h =================================================================== --- trunk/include/plcore.h 2009-03-05 15:34:56 UTC (rev 9674) +++ trunk/include/plcore.h 2009-03-05 16:07:41 UTC (rev 9675) @@ -296,7 +296,18 @@ #if defined(PLD_extcairo) && !defined(ENABLE_DYNDRIVERS) plD_dispatch_init_extcairo, #endif - +#if defined(PLD_rasterqt) && !defined(ENABLE_DYNDRIVERS) + plD_dispatch_init_rasterqt, +#endif +#if defined(PLD_svgqt) && !defined(ENABLE_DYNDRIVERS) + plD_dispatch_init_svgqt, +#endif +#if defined(PLD_epspdfqt) && !defined(ENABLE_DYNDRIVERS) + plD_dispatch_init_epspdfqt, +#endif +#if defined(PLD_qtwidget) && !defined(ENABLE_DYNDRIVERS) + plD_dispatch_init_qtwidget, +#endif NULL }; Modified: trunk/plplot_test/plplot-test.sh.cmake =================================================================== --- trunk/plplot_test/plplot-test.sh.cmake 2009-03-05 15:34:56 UTC (rev 9674) +++ trunk/plplot_test/plplot-test.sh.cmake 2009-03-05 16:07:41 UTC (rev 9675) @@ -195,6 +195,7 @@ PLD_cgm=@PLD_cgm@ PLD_conex=@PLD_conex@ PLD_dg300=@PLD_dg300@ +PLD_epspdfqt=@PLD_epspdfqt@ #interactive PLD_gcw=@PLD_gcw@ PLD_gif=@PLD_gif@ #interactive PLD_gnome=@PLD_gnome@ @@ -225,8 +226,11 @@ PLD_psttf=@PLD_psttf@ # special case PLD_psttfc=@PLD_psttf@ +#interactive PLD_qtwidget=@PLD_qtwidget@ +PLD_rasterqt=@PLD_rasterqt@ PLD_svg=@PLD_svg@ PLD_svgcairo=@PLD_svgcairo@ +PLD_svgqt=@PLD_svgqt@ PLD_tek4010=@PLD_tek4010@ PLD_tek4010f=@PLD_tek4010f@ PLD_tek4107=@PLD_tek4107@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-03-05 17:36:00
|
Revision: 9676 http://plplot.svn.sourceforge.net/plplot/?rev=9676&view=rev Author: airwin Date: 2009-03-05 17:35:49 +0000 (Thu, 05 Mar 2009) Log Message: ----------- AWI for Alban Rochel. Properly handle the non-availability of SVG on Qt 4.2. Modified Paths: -------------- trunk/cmake/modules/qt.cmake trunk/drivers/qt.cpp trunk/drivers/qt.h Modified: trunk/cmake/modules/qt.cmake =================================================================== --- trunk/cmake/modules/qt.cmake 2009-03-05 16:07:41 UTC (rev 9675) +++ trunk/cmake/modules/qt.cmake 2009-03-05 17:35:49 UTC (rev 9676) @@ -1,26 +1,10 @@ -# Naive way to (try to?) dissociate the SVG driver (not available on Qt 4.2) from the other drivers. Yet to be tested! - -if(PLD_svgqt) - FIND_PACKAGE(Qt4) - SET(QT_USE_QTSVG 1) +FIND_PACKAGE(Qt4) +if(PLD_rasterqt OR PLD_epspdfqt OR PLD_qtwidget OR PLD_svgqt) +if(PLD_svgqt AND ${QT_VERSION_MINOR} GREATER 2) + SET(QT_USE_QTSVG 1) +endif(PLD_svgqt AND ${QT_VERSION_MINOR} GREATER 2) INCLUDE(${QT_USE_FILE}) if(NOT QT4_FOUND) - set(PLD_svgqt OFF CACHE BOOL "Enable Qt SVG device" FORCE) - else(NOT QT4_FOUND) - set(qt_COMPILE_FLAGS) - foreach(DIR ${QT_INCLUDES}) - set(qt_COMPILE_FLAGS "${qt_COMPILE_FLAGS} -I${DIR}") - endforeach(DIR ${QT_INCLUDES}) - - set(qt_LINK_FLAGS ${QT_LIBRARIES}) - set(DRIVERS_LINK_FLAGS ${DRIVERS_LINK_FLAGS} ${qt_LINK_FLAGS}) - endif(NOT QT4_FOUND) -endif(PLD_svgqt) - -if(PLD_rasterqt OR PLD_epspdfqt OR PLD_qtwidget) - FIND_PACKAGE(Qt4) - INCLUDE(${QT_USE_FILE}) - if(NOT QT4_FOUND) set(PLD_rasterqt OFF CACHE BOOL "Enable Qt raster device" FORCE) set(PLD_epspdfqt OFF CACHE BOOL "Enable Qt EPS/PDF device" FORCE) set(PLD_qtwidget OFF CACHE BOOL "Enable Qt EPS/PDF device" FORCE) @@ -33,4 +17,4 @@ set(qt_LINK_FLAGS ${QT_LIBRARIES}) set(DRIVERS_LINK_FLAGS ${DRIVERS_LINK_FLAGS} ${qt_LINK_FLAGS}) endif(NOT QT4_FOUND) -endif(PLD_rasterqt OR PLD_epspdfqt OR PLD_qtwidget) \ No newline at end of file +endif(PLD_rasterqt OR PLD_epspdfqt OR PLD_qtwidget OR PLD_svgqt) \ No newline at end of file Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2009-03-05 16:07:41 UTC (rev 9675) +++ trunk/drivers/qt.cpp 2009-03-05 17:35:49 UTC (rev 9676) @@ -21,16 +21,22 @@ 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" -// #include "moc_qt.cxx" +// Drivers declaration PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_qt = #if defined(PLD_rasterqt) "rasterqt:Qt Raster driver:0:qt:66:rasterqt\n" #endif -#if defined(PLD_svgqt) +#if defined(PLD_svgqt) && QT_VERSION >= 0x040300 "svgqt:Qt SVG driver:0:qt:67:svgqt\n" #endif #if defined(PLD_epspdfqt) @@ -41,13 +47,14 @@ #endif ; +// Declaration of the driver-specific interface functions #if defined(PLD_rasterqt) void plD_dispatch_init_rasterqt(PLDispatchTable *pdt); void plD_init_rasterqt(PLStream *); void plD_eop_rasterqt(PLStream *); #endif -#if defined(PLD_svgqt) +#if defined(PLD_svgqt) && QT_VERSION >= 0x040300 void plD_dispatch_init_svgqt(PLDispatchTable *pdt); void plD_init_svgqt(PLStream *); void plD_eop_svgqt(PLStream *); @@ -65,6 +72,8 @@ void plD_eop_qtwidget(PLStream *); #endif +// Declaration of the generic interface functions + void plD_line_qt(PLStream *, short, short, short, short); void plD_polyline_qt(PLStream *, short*, short*, PLINT); void plD_bop_qt(PLStream *){} @@ -292,6 +301,7 @@ { } +// Draw the content of the buffer void QtPLBufferedDriver::doPlot(QPainter* i_painterP, double x_fact, double y_fact, double x_offset, double y_offset) { QLineF line; @@ -395,15 +405,17 @@ io_dYOffset=0.; } -//////////////////// Generic driver interface /////////////// +// Generic driver interface + void plD_line_qt(PLStream * pls, short x1a, short y1a, short x2a, short y2a) { QtPLDriver * widget=NULL; + // We have to dynamic_cast to make sure the good virtual functions are called #if defined(PLD_rasterqt) if(widget==NULL) widget=dynamic_cast<QtRasterDevice*>((QtPLDriver *) pls->dev); #endif -#if defined(PLD_svgqt) +#if defined(PLD_svgqt) && QT_VERSION >= 0x040300 if(widget==NULL) widget=dynamic_cast<QtSVGDevice*>((QtPLDriver *) pls->dev); #endif #if defined(PLD_epspdfqt) @@ -424,7 +436,7 @@ #if defined(PLD_rasterqt) if(widget==NULL) widget=dynamic_cast<QtRasterDevice*>((QtPLDriver *) pls->dev); #endif -#if defined(PLD_svgqt) +#if defined(PLD_svgqt) && QT_VERSION >= 0x040300 if(widget==NULL) widget=dynamic_cast<QtSVGDevice*>((QtPLDriver *) pls->dev); #endif #if defined(PLD_epspdfqt) @@ -447,7 +459,7 @@ #if defined(PLD_rasterqt) if(widget==NULL) widget=dynamic_cast<QtRasterDevice*>((QtPLDriver *) pls->dev); #endif -#if defined(PLD_svgqt) +#if defined(PLD_svgqt) && QT_VERSION >= 0x040300 if(widget==NULL) widget=dynamic_cast<QtSVGDevice*>((QtPLDriver *) pls->dev); #endif #if defined(PLD_epspdfqt) @@ -483,7 +495,7 @@ delete[] ya; break; - default: break; + default: break; } } @@ -493,7 +505,7 @@ #if defined(PLD_rasterqt) if(widget==NULL) widget=dynamic_cast<QtRasterDevice*>((QtPLDriver *) pls->dev); #endif -#if defined(PLD_svgqt) +#if defined(PLD_svgqt) && QT_VERSION >= 0x040300 if(widget==NULL) widget=dynamic_cast<QtSVGDevice*>((QtPLDriver *) pls->dev); #endif #if defined(PLD_epspdfqt) @@ -523,20 +535,27 @@ } } +////////////////// Raster driver-specific definitions: class and interface functions ///////// + #if defined(PLD_rasterqt) 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)); + // For page numbering pageCounter=0; } +// Used to append _page# when multiple pages QString QtRasterDevice::getFileName(char* fileName) { QString fn(fileName); @@ -593,8 +612,10 @@ pls->dev_clear=1; pls->termin=0; + // Initialised with the default (A4) size pls->dev=new QtRasterDevice; + // Shamelessly copied on the Cairo stuff :) if (pls->xlength <= 0 || pls->ylength <= 0) { pls->xlength = ((QtRasterDevice*)(pls->dev))->m_dWidth; @@ -622,7 +643,7 @@ #endif -#if defined(PLD_svgqt) +#if defined(PLD_svgqt) && QT_VERSION >= 0x040300 QtSVGDevice::QtSVGDevice(int i_iWidth, int i_iHeight): QtPLBufferedDriver(i_iWidth, i_iHeight) { @@ -714,6 +735,8 @@ QSize s; ((QtSVGDevice *)pls->dev)->savePlot(pls->FileName); + // Once saved, we have to create a new device with the same properties + // to be able to plot another page. downscale=((QtSVGDevice *)pls->dev)->downscale; pageCounter=((QtSVGDevice *)pls->dev)->pageCounter; s=((QtSVGDevice *)pls->dev)->size(); @@ -810,14 +833,15 @@ int argc=0; char argv[]={'\0'}; + // QPrinter devices won't create if there is no QApplication declared... QApplication * app=new QApplication(argc, (char**)&argv); pls->dev=new QtEPSDevice; delete app; if (pls->xlength <= 0 || pls->ylength <= 0) { - pls->xlength = ((QtSVGDevice*)(pls->dev))->m_dWidth; - pls->ylength = ((QtSVGDevice*)(pls->dev))->m_dHeight; + pls->xlength = ((QtEPSDevice*)(pls->dev))->m_dWidth; + pls->ylength = ((QtEPSDevice*)(pls->dev))->m_dHeight; } if (pls->xlength > pls->ylength) @@ -843,8 +867,10 @@ char argv[]={'\0'}; ((QtEPSDevice *)pls->dev)->savePlot(pls->FileName); - downscale=((QtSVGDevice *)pls->dev)->downscale; - pageCounter=((QtSVGDevice *)pls->dev)->pageCounter; + // Once saved, we have to create a new device with the same properties + // to be able to plot another page. + downscale=((QtEPSDevice *)pls->dev)->downscale; + pageCounter=((QtEPSDevice *)pls->dev)->pageCounter; delete ((QtEPSDevice *)pls->dev); QApplication * app=new QApplication(argc, (char**)&argv); @@ -954,7 +980,7 @@ 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 actual redraw + // If actual redraw, not just adding the cursor acquisition traces if(m_bAwaitingRedraw || m_pixPixmap==NULL || m_listBuffer.size()!=m_iOldSize ) { if(m_pixPixmap!=NULL) delete m_pixPixmap; @@ -1077,14 +1103,14 @@ 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_dYFact*m_dAspectRatio; + 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_dXFact/m_dAspectRatio; + io_dYFact=w/m_dAspectRatio/m_dHeight; io_dXOffset=0.; io_dYOffset=(h-io_dYFact*m_dHeight)/2.; } Modified: trunk/drivers/qt.h =================================================================== --- trunk/drivers/qt.h 2009-03-05 16:07:41 UTC (rev 9675) +++ trunk/drivers/qt.h 2009-03-05 17:35:49 UTC (rev 9676) @@ -21,6 +21,12 @@ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + History: + + + March 2009: v1.00 + Initial release. + */ #ifndef QT_H @@ -30,7 +36,6 @@ #include <QImage> #include <QPainter> #include <QLinkedList> -#include <QSvgGenerator> #include <QPrinter> #include <QApplication> #include <QWidget> @@ -43,6 +48,7 @@ #define QT_DEFAULT_X 842 #define QT_DEFAULT_Y 598 +// Types of buffer elements for buffered widgets typedef enum ElementType_ { LINE, @@ -55,6 +61,7 @@ SET_SMOOTH } ElementType; +// A buffer element in a buffered widget class BufferElement { public: @@ -88,16 +95,18 @@ } Data; }; - +// Basic class, offering the common interface to all Qt plplot devices class QtPLDriver { public: + // Constructor, taking the device size as arguments QtPLDriver(PLINT i_iWidth=QT_DEFAULT_X, PLINT i_iHeight=QT_DEFAULT_Y); virtual ~QtPLDriver(); - + + // 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); @@ -108,10 +117,12 @@ virtual void setDashed(PLINT nms, PLINT* mark, PLINT* space); + // Set pen to draw solid strokes (called after drawing dashed strokes) virtual void setSolid(); virtual void savePlot(char* fileName); + // Conversion factor from internal plplot coordinates to device coordinates double downscale; double m_dWidth, m_dHeight; protected: @@ -119,6 +130,9 @@ QPainter* m_painterP; }; +// This device is used in two situations: +// - if the device can only start plotting when given a destination file (SVG, EPS, PDF), then we have to accumulate the plot commands before printing them when eop() is called +// - If the device may have to redraw (Widget), then the accumulated commands are re-issued, possibly corrected to fit a new device size class QtPLBufferedDriver: public QtPLDriver { public: @@ -126,6 +140,7 @@ virtual ~QtPLBufferedDriver(); + // Accumulates a line command in the end of the buffer virtual void drawLine(short x1, short y1, short x2, short y2); virtual void drawPolyline(short * x, short * y, PLINT npts); @@ -142,18 +157,30 @@ virtual void savePlot(char* fileName); + // Actually plots on the device, using the p QPainter. + // if p is null, then the defaut QPainter m_painterP is used. + // x_fact, y_fact, x_offset and y_offset allow to center the plot + // on the device + // These 5 parameters are actually only used for widgets: + // widgets plot on a pixmap via p, and as the aspect ratio of + // what's drawn is set constant yet taking as much space as possible, + // offsets and factors have to be set + virtual void doPlot(QPainter* p=NULL, double x_fact=1., double y_fact=1., double x_offset=0., double y_offset=0.); + protected: - virtual void doPlot(QPainter* p=NULL, double x_fact=1., double y_fact=1., double x_offset=0., double y_offset=0.); - + // Gets the offsets and factors using the current size of the device virtual void getPlotParameters(double & io_dXFact, double & io_dYFact, double & io_dXOffset, double & io_dYOffset); + // Empties the buffer void clearBuffer(); + // Here is the buffer QLinkedList<BufferElement> m_listBuffer; }; #if defined (PLD_rasterqt) +// Driver painting whatever raster format Qt can save class QtRasterDevice: public QtPLDriver, public QImage { public: @@ -162,17 +189,21 @@ virtual ~QtRasterDevice(){} - QString getFileName(char* fileName); - + // Saves the plot to the fileName file, possibly appending + // _page# to the file name if not the 1st page void savePlot(char* fileName); protected: + // Generates the actual file name, depending on fileName and pageCounter + QString getFileName(char* fileName); int pageCounter; }; #endif -#if defined (PLD_svgqt) +#if defined(PLD_svgqt) && QT_VERSION >= 0x040300 +#include <QSvgGenerator> +// Driver painting on an SVG device class QtSVGDevice: public QtPLBufferedDriver, public QSvgGenerator { public: @@ -180,17 +211,18 @@ int i_iHeight=QT_DEFAULT_Y); virtual ~QtSVGDevice(); - - QString getFileName(char* fileName); void savePlot(char* fileName); - int pageCounter; + int pageCounter; // public because read and written by plD_eop protected: + QString getFileName(char* fileName); }; #endif #if defined (PLD_epspdfqt) +// Driver painting on an EPS or PDF device, uses QPrinter +// A (possibly dummy) QApplication must be declared before use class QtEPSDevice: public QtPLBufferedDriver, public QPrinter { public: @@ -202,14 +234,16 @@ void savePlot(char* fileName); - int pageCounter; + int pageCounter;// public because read and written by plD_eop protected: }; #endif #if defined (PLD_qtwidget) - +// 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 QtPLWidget: public QWidget, public QtPLBufferedDriver { Q_OBJECT @@ -221,13 +255,29 @@ virtual ~QtPLWidget(); + // This is an addition to plplot drawing routines. + // Calling setSmooth(...) will (de)activate anti-aliasing in plotting + // For example: + // plotWidget->setSmooth(true); + // plbox(...); + // plotWidget->setSmooth(false); + // plline(...) + // will only smooth the axes and their labels. void setSmooth(bool); + // Clears the widget void clearWidget(); public slots: + // This slot can be used to select an x/y range interactively + // xi, yi, xf and yf are the initial and final points coordinates + // in their respective windows, 0 if outside a window void captureMousePlotCoords(double* xi, double* yi, double* xf, double* yf); + + // This slot can be used to select an x/y range interactively + // xi, yi, xf and yf are the initial and final points coordinates + // in the whole page (normalized between 0 and 1) void captureMouseDeviceCoords(double* xi, double* yi, double* xf, double* yf); protected slots: @@ -240,8 +290,10 @@ protected: + // Used to center the plot on the page void getPlotParameters(double & io_dXFact, double & io_dYFact, double & io_dXOffset, double & io_dYOffset); + // Used for cursor tracking (capture[...] slots) struct { bool isTracking; @@ -256,6 +308,15 @@ int m_iOldSize; }; +// This function must be called between plinit to set up the widget +// The widget is created within the Qt Application +// e.g.: +// QtPLWidget*plot=new QtPLWidget(QT_DEFAULT_X, QT_DEFAULT_Y, this); +// plmkstrm(&strm); +// plsqtdev(plot); +// plsdev ("qtwidget"); +// plinit(); +// ... void plsqtdev(QtPLWidget *plotdev); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-03-06 02:01:09
|
Revision: 9678 http://plplot.svn.sourceforge.net/plplot/?rev=9678&view=rev Author: airwin Date: 2009-03-06 01:39:42 +0000 (Fri, 06 Mar 2009) Log Message: ----------- Split epspdfqt device into independent epsqt and pdfqt devices with corresponding cmake configuration parameters PLD_epsqt and PLD_pdfqt replacing PLD_epspdfqt, and with output PostScript of PDF file type completely determined by choice of device driver and not the suffix of the output file name. Modified Paths: -------------- trunk/cmake/modules/drivers-init.cmake trunk/cmake/modules/qt.cmake trunk/config.h.cmake trunk/drivers/CMakeLists.txt trunk/drivers/qt.cpp trunk/drivers/qt.h trunk/include/drivers.h trunk/include/plDevs.h.cmake trunk/include/plcore.h trunk/plplot_test/plplot-test.sh.cmake Modified: trunk/cmake/modules/drivers-init.cmake =================================================================== --- trunk/cmake/modules/drivers-init.cmake 2009-03-05 20:03:56 UTC (rev 9677) +++ trunk/cmake/modules/drivers-init.cmake 2009-03-06 01:39:42 UTC (rev 9678) @@ -83,7 +83,11 @@ "xcairo:cairo:ON" "cgm:cgm:ON" "dg300:dg300:OFF" -"epspdfqt:qt:OFF" +"epsqt:qt:OFF" +"pdfqt:qt:OFF" +"qtwidget:qt:OFF" +"rasterqt:qt:OFF" +"svgqt:qt:OFF" "gif:gd:ON" "jpeg:gd:ON" "png:gd:ON" @@ -114,10 +118,7 @@ # (psttf and pscairo) to get modern fonts for postscript results. "pstex:pstex:OFF" "psttf:psttf:ON" -"qtwidget:qt:OFF" -"rasterqt:qt:OFF" "svg:svg:ON" -"svgqt:qt:OFF" "conex:tek:OFF" "mskermit:tek:OFF" "tek4010:tek:OFF" Modified: trunk/cmake/modules/qt.cmake =================================================================== --- trunk/cmake/modules/qt.cmake 2009-03-05 20:03:56 UTC (rev 9677) +++ trunk/cmake/modules/qt.cmake 2009-03-06 01:39:42 UTC (rev 9678) @@ -1,13 +1,15 @@ find_package(Qt4) -if(PLD_rasterqt OR PLD_epspdfqt OR PLD_qtwidget OR PLD_svgqt) +if(PLD_rasterqt OR PLD_epsqt OR PLD_pdfqt OR PLD_qtwidget OR PLD_svgqt) if(PLD_svgqt AND ${QT_VERSION_MINOR} GREATER 2) set(QT_USE_QTSVG 1) endif(PLD_svgqt AND ${QT_VERSION_MINOR} GREATER 2) include(${QT_USE_FILE}) if(NOT QT4_FOUND) set(PLD_rasterqt OFF CACHE BOOL "Enable Qt raster device" FORCE) - set(PLD_epspdfqt OFF CACHE BOOL "Enable Qt EPS/PDF device" FORCE) - set(PLD_qtwidget OFF CACHE BOOL "Enable Qt EPS/PDF 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) else(NOT QT4_FOUND) set(qt_COMPILE_FLAGS) foreach(DIR ${QT_INCLUDES}) @@ -17,4 +19,4 @@ set(qt_LINK_FLAGS ${QT_LIBRARIES}) set(DRIVERS_LINK_FLAGS ${DRIVERS_LINK_FLAGS} ${qt_LINK_FLAGS}) endif(NOT QT4_FOUND) -endif(PLD_rasterqt OR PLD_epspdfqt OR PLD_qtwidget OR PLD_svgqt) \ No newline at end of file +endif(PLD_rasterqt OR PLD_epsqt OR PLD_pdfqt OR PLD_qtwidget OR PLD_svgqt) Modified: trunk/config.h.cmake =================================================================== --- trunk/config.h.cmake 2009-03-05 20:03:56 UTC (rev 9677) +++ trunk/config.h.cmake 2009-03-06 01:39:42 UTC (rev 9678) @@ -197,12 +197,6 @@ /* Define if dg300 driver is present */ #cmakedefine PLD_dg300 -/* Define if the EPS/PDF Qt driver is present */ -#cmakedefine PLD_epspdfqt - -/* Define if the Cario external context driver is present */ -#cmakedefine PLD_extcairo - /* Define if gcw driver is present */ #cmakedefine PLD_gcw @@ -254,48 +248,24 @@ /* Define if pdf driver is present */ #cmakedefine PLD_pdf -/* Define if Cairo PDF driver is present */ -#cmakedefine PLD_pdfcairo - /* Define if plmeta driver is present */ #cmakedefine PLD_plmeta -/* Define if Cairo memory driver is present */ -#cmakedefine PLD_memcairo - /* Define if png driver is present */ #cmakedefine PLD_png -/* Define if Cairo PNG driver is present */ -#cmakedefine PLD_pngcairo - /* Define if ps driver is present */ #cmakedefine PLD_ps -/* Define if Cairo PS driver is present */ -#cmakedefine PLD_pscairo - /* Define if pstex driver is present */ #cmakedefine PLD_pstex /* Define if psttf driver is present */ #cmakedefine PLD_psttf -/* Define if Qt Widgete driver is present */ -#cmakedefine PLD_qtwidget - -/* Define if raster Qt driver is present */ -#cmakedefine PLD_rasterqt - /* Define if svg driver is present */ #cmakedefine PLD_svg -/* Define if Cairo SVG driver is present */ -#cmakedefine PLD_svgcairo - -/* Define if SVG Qt driver is present */ -#cmakedefine PLD_svgqt - /* Define if tek4010 driver is present */ #cmakedefine PLD_tek4010 @@ -329,9 +299,6 @@ /* Define if wxwidgets png driver is present */ #cmakedefine PLD_wxpng -/* Define if the cairo X windows driver is present */ -#cmakedefine PLD_xcairo - /* Define if xfig driver is present */ #cmakedefine PLD_xfig @@ -341,6 +308,42 @@ /* Define if xwin driver is present */ #cmakedefine PLD_xwin +/* Define if the Cairo external context driver is present */ +#cmakedefine PLD_extcairo + +/* Define if Cairo PDF driver is present */ +#cmakedefine PLD_pdfcairo + +/* Define if Cairo memory driver is present */ +#cmakedefine PLD_memcairo + +/* Define if Cairo PNG driver is present */ +#cmakedefine PLD_pngcairo + +/* Define if Cairo PS driver is present */ +#cmakedefine PLD_pscairo + +/* Define if Cairo SVG driver is present */ +#cmakedefine PLD_svgcairo + +/* Define if the cairo X windows driver is present */ +#cmakedefine PLD_xcairo + +/* Define if the EPS Qt driver is present */ +#cmakedefine PLD_epsqt + +/* Define if the PDF Qt driver is present */ +#cmakedefine PLD_pdfqt + +/* Define if Qt Widget driver is present */ +#cmakedefine PLD_qtwidget + +/* Define if raster Qt driver is present */ +#cmakedefine PLD_rasterqt + +/* Define if SVG Qt driver is present */ +#cmakedefine PLD_svgqt + /* Portable definition for PTHREAD_MUTEX_RECURSIVE */ #define PLPLOT_MUTEX_RECURSIVE ${PLPLOT_MUTEX_RECURSIVE} Modified: trunk/drivers/CMakeLists.txt =================================================================== --- trunk/drivers/CMakeLists.txt 2009-03-05 20:03:56 UTC (rev 9677) +++ trunk/drivers/CMakeLists.txt 2009-03-06 01:39:42 UTC (rev 9678) @@ -24,12 +24,12 @@ DESTINATION ${DOC_DIR} ) -if(PLD_rasterqt) +if(PLD_rasterqt OR PLD_epsqt OR PLD_pdfqt OR PLD_qtwidget OR PLD_svgqt) install( FILES qt.h DESTINATION ${INCLUDE_DIR} ) -endif(PLD_rasterqt) +endif(PLD_rasterqt OR PLD_epsqt OR PLD_pdfqt OR PLD_qtwidget OR PLD_svgqt) if(ENABLE_DYNDRIVERS) set_source_files_properties( Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2009-03-05 20:03:56 UTC (rev 9677) +++ trunk/drivers/qt.cpp 2009-03-06 01:39:42 UTC (rev 9678) @@ -39,12 +39,15 @@ #if defined(PLD_svgqt) && QT_VERSION >= 0x040300 "svgqt:Qt SVG driver:0:qt:67:svgqt\n" #endif -#if defined(PLD_epspdfqt) - "epspdfqt:Qt EPS/PDF driver:0:qt:68:epspdfqt\n" -#endif #if defined(PLD_qtwidget) - "qtwidget:Qt Widget:0:qt:69:qtwidget\n" + "qtwidget:Qt Widget:0:qt:68:qtwidget\n" #endif +#if defined(PLD_epsqt) + "epsqt:Qt EPS driver:0:qt:69:epsqt\n" +#endif +#if defined(PLD_pdfqt) + "pdfqt:Qt PDF driver:0:qt:70:pdfqt\n" +#endif ; // Declaration of the driver-specific interface functions @@ -60,11 +63,18 @@ void plD_eop_svgqt(PLStream *); #endif -#if defined(PLD_epspdfqt) -void plD_dispatch_init_epspdfqt(PLDispatchTable *pdt); +#if defined(PLD_epsqt) || defined(PLD_pdfqt) void plD_init_epspdfqt(PLStream *); -void plD_eop_epspdfqt(PLStream *); +void plD_eop_epspdfqt_helper(PLStream *, int ifeps); #endif +#if defined(PLD_epsqt) +void plD_dispatch_init_epsqt(PLDispatchTable *pdt); +void plD_eop_epsqt(PLStream *); +#endif +#if defined(PLD_pdfqt) +void plD_dispatch_init_pdfqt(PLDispatchTable *pdt); +void plD_eop_pdfqt(PLStream *); +#endif #if defined(PLD_qtwidget) void plD_dispatch_init_qtwidget(PLDispatchTable *pdt); @@ -418,7 +428,7 @@ #if defined(PLD_svgqt) && QT_VERSION >= 0x040300 if(widget==NULL) widget=dynamic_cast<QtSVGDevice*>((QtPLDriver *) pls->dev); #endif -#if defined(PLD_epspdfqt) +#if defined(PLD_epsqt) || defined(PLD_pdfqt) if(widget==NULL) widget=dynamic_cast<QtEPSDevice*>((QtPLDriver *) pls->dev); #endif #if defined(PLD_qtwidget) @@ -439,7 +449,7 @@ #if defined(PLD_svgqt) && QT_VERSION >= 0x040300 if(widget==NULL) widget=dynamic_cast<QtSVGDevice*>((QtPLDriver *) pls->dev); #endif -#if defined(PLD_epspdfqt) +#if defined(PLD_epsqt) || defined(PLD_pdfqt) if(widget==NULL) widget=dynamic_cast<QtEPSDevice*>((QtPLDriver *) pls->dev); #endif #if defined(PLD_qtwidget) @@ -462,7 +472,7 @@ #if defined(PLD_svgqt) && QT_VERSION >= 0x040300 if(widget==NULL) widget=dynamic_cast<QtSVGDevice*>((QtPLDriver *) pls->dev); #endif -#if defined(PLD_epspdfqt) +#if defined(PLD_epsqt) || defined(PLD_pdfqt) if(widget==NULL) widget=dynamic_cast<QtEPSDevice*>((QtPLDriver *) pls->dev); #endif #if defined(PLD_qtwidget) @@ -508,7 +518,7 @@ #if defined(PLD_svgqt) && QT_VERSION >= 0x040300 if(widget==NULL) widget=dynamic_cast<QtSVGDevice*>((QtPLDriver *) pls->dev); #endif -#if defined(PLD_epspdfqt) +#if defined(PLD_epsqt) || defined(PLD_pdfqt) if(widget==NULL) widget=dynamic_cast<QtEPSDevice*>((QtPLDriver *) pls->dev); #endif #if defined(PLD_qtwidget) @@ -749,7 +759,7 @@ #endif -#if defined (PLD_epspdfqt) +#if defined (PLD_epsqt) || defined(PLD_pdfqt) QtEPSDevice::QtEPSDevice() { pageCounter=0; @@ -779,46 +789,63 @@ return res; } -void QtEPSDevice::savePlot(char* fileName) +void QtEPSDevice::savePlot(char* fileName, int ifeps) { setOutputFileName(getFileName(fileName)); - if(QString(fileName).endsWith(".ps") || QString(fileName).endsWith(".eps")) + if(ifeps) { setOutputFormat(QPrinter::PostScriptFormat); } - else if(QString(fileName).endsWith(".pdf")) + else { setOutputFormat(QPrinter::PdfFormat); } - else - { - std::cerr << "Unhandled file format: " << fileName << std::endl; - return; - } m_painterP=new QPainter(this); doPlot(); m_painterP->end(); } -void plD_dispatch_init_epspdfqt(PLDispatchTable *pdt) +#if defined(PLD_epsqt) +void plD_dispatch_init_epsqt(PLDispatchTable *pdt) { #ifndef ENABLE_DYNDRIVERS - pdt->pl_MenuStr = "Qt EPS/PDF Driver"; - pdt->pl_DevName = "epspdfqt"; + pdt->pl_MenuStr = "Qt EPS Driver"; + pdt->pl_DevName = "epsqt"; #endif pdt->pl_type = plDevType_FileOriented; - pdt->pl_seq = 68; + pdt->pl_seq = 69; pdt->pl_init = (plD_init_fp) plD_init_epspdfqt; pdt->pl_line = (plD_line_fp) plD_line_qt; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; - pdt->pl_eop = (plD_eop_fp) plD_eop_epspdfqt; + pdt->pl_eop = (plD_eop_fp) plD_eop_epsqt; pdt->pl_bop = (plD_bop_fp) plD_bop_qt; pdt->pl_tidy = (plD_tidy_fp) plD_tidy_qt; pdt->pl_state = (plD_state_fp) plD_state_qt; pdt->pl_esc = (plD_esc_fp) plD_esc_qt; } +#endif +#if defined(PLD_pdfqt) +void plD_dispatch_init_pdfqt(PLDispatchTable *pdt) +{ +#ifndef ENABLE_DYNDRIVERS + pdt->pl_MenuStr = "Qt PDF Driver"; + pdt->pl_DevName = "pdfqt"; +#endif + pdt->pl_type = plDevType_FileOriented; + pdt->pl_seq = 70; + pdt->pl_init = (plD_init_fp) plD_init_epspdfqt; + pdt->pl_line = (plD_line_fp) plD_line_qt; + pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; + pdt->pl_eop = (plD_eop_fp) plD_eop_pdfqt; + pdt->pl_bop = (plD_bop_fp) plD_bop_qt; + pdt->pl_tidy = (plD_tidy_fp) plD_tidy_qt; + pdt->pl_state = (plD_state_fp) plD_state_qt; + pdt->pl_esc = (plD_esc_fp) plD_esc_qt; +} +#endif + void plD_init_epspdfqt(PLStream * pls) { /* Stream setup */ @@ -853,12 +880,10 @@ plP_setpxl(DPI/25.4/((QtEPSDevice*)(pls->dev))->downscale, DPI/25.4/((QtEPSDevice*)(pls->dev))->downscale); - printf("The file format will be determined by the file name extension\n"); - printf("Possible extensions are: eps, pdf\n"); plOpenFile(pls); } -void plD_eop_epspdfqt(PLStream *pls) +void plD_eop_epspdfqt_helper(PLStream *pls, int ifeps) { double downscale; int pageCounter; @@ -866,7 +891,7 @@ int argc=0; char argv[]={'\0'}; - ((QtEPSDevice *)pls->dev)->savePlot(pls->FileName); + ((QtEPSDevice *)pls->dev)->savePlot(pls->FileName, ifeps); // Once saved, we have to create a new device with the same properties // to be able to plot another page. downscale=((QtEPSDevice *)pls->dev)->downscale; @@ -880,6 +905,20 @@ delete app; } +#if defined(PLD_epsqt) +void plD_eop_epsqt(PLStream *pls) +{ + plD_eop_epspdfqt_helper(pls, 1); +} +#endif + +#if defined(PLD_pdfqt) +void plD_eop_pdfqt(PLStream *pls) +{ + plD_eop_epspdfqt_helper(pls, 0); +} +#endif + #if defined (PLD_qtwidget) QtPLWidget::QtPLWidget(int i_iWidth, int i_iHeight, QWidget* parent): @@ -1124,7 +1163,7 @@ pdt->pl_DevName = "qtwidget"; #endif pdt->pl_type = plDevType_Interactive; - pdt->pl_seq = 69; + pdt->pl_seq = 68; pdt->pl_init = (plD_init_fp) plD_init_qtwidget; pdt->pl_line = (plD_line_fp) plD_line_qt; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; Modified: trunk/drivers/qt.h =================================================================== --- trunk/drivers/qt.h 2009-03-05 20:03:56 UTC (rev 9677) +++ trunk/drivers/qt.h 2009-03-06 01:39:42 UTC (rev 9678) @@ -220,7 +220,7 @@ }; #endif -#if defined (PLD_epspdfqt) +#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 QtPLBufferedDriver, public QPrinter @@ -232,7 +232,7 @@ QString getFileName(char* fileName); - void savePlot(char* fileName); + void savePlot(char* fileName, int ifeps); int pageCounter;// public because read and written by plD_eop protected: Modified: trunk/include/drivers.h =================================================================== --- trunk/include/drivers.h 2009-03-05 20:03:56 UTC (rev 9677) +++ trunk/include/drivers.h 2009-03-06 01:39:42 UTC (rev 9678) @@ -99,7 +99,8 @@ PLDLLIMPEXP_DRIVER void plD_dispatch_init_extcairo ( PLDispatchTable *pdt ); PLDLLIMPEXP_DRIVER void plD_dispatch_init_rasterqt ( PLDispatchTable *pdt ); PLDLLIMPEXP_DRIVER void plD_dispatch_init_svgqt ( PLDispatchTable *pdt ); -PLDLLIMPEXP_DRIVER void plD_dispatch_init_epspdfqt ( PLDispatchTable *pdt ); +PLDLLIMPEXP_DRIVER void plD_dispatch_init_epsqt ( PLDispatchTable *pdt ); +PLDLLIMPEXP_DRIVER void plD_dispatch_init_pdfqt ( PLDispatchTable *pdt ); PLDLLIMPEXP_DRIVER void plD_dispatch_init_qtwidget ( PLDispatchTable *pdt ); /* Prototypes for plot buffer calls. */ Modified: trunk/include/plDevs.h.cmake =================================================================== --- trunk/include/plDevs.h.cmake 2009-03-05 20:03:56 UTC (rev 9677) +++ trunk/include/plDevs.h.cmake 2009-03-06 01:39:42 UTC (rev 9678) @@ -87,7 +87,8 @@ #cmakedefine PLD_extcairo #cmakedefine PLD_rasterqt #cmakedefine PLD_svgqt -#cmakedefine PLD_epspdfqt +#cmakedefine PLD_epsqt +#cmakedefine PLD_pdfqt #cmakedefine PLD_qtwidget #endif /* __PLDEVS_H__ */ Modified: trunk/include/plcore.h =================================================================== --- trunk/include/plcore.h 2009-03-05 20:03:56 UTC (rev 9677) +++ trunk/include/plcore.h 2009-03-06 01:39:42 UTC (rev 9678) @@ -302,9 +302,12 @@ #if defined(PLD_svgqt) && !defined(ENABLE_DYNDRIVERS) plD_dispatch_init_svgqt, #endif -#if defined(PLD_epspdfqt) && !defined(ENABLE_DYNDRIVERS) - plD_dispatch_init_epspdfqt, +#if defined(PLD_epsqt) && !defined(ENABLE_DYNDRIVERS) + plD_dispatch_init_epsqt, #endif +#if defined(PLD_pdfqt) && !defined(ENABLE_DYNDRIVERS) + plD_dispatch_init_pdfqt, +#endif #if defined(PLD_qtwidget) && !defined(ENABLE_DYNDRIVERS) plD_dispatch_init_qtwidget, #endif Modified: trunk/plplot_test/plplot-test.sh.cmake =================================================================== --- trunk/plplot_test/plplot-test.sh.cmake 2009-03-05 20:03:56 UTC (rev 9677) +++ trunk/plplot_test/plplot-test.sh.cmake 2009-03-06 01:39:42 UTC (rev 9678) @@ -195,7 +195,11 @@ PLD_cgm=@PLD_cgm@ PLD_conex=@PLD_conex@ PLD_dg300=@PLD_dg300@ -PLD_epspdfqt=@PLD_epspdfqt@ +PLD_epsqt=@PLD_epsqt@ +PLD_pdfqt=@PLD_pdfqt@ +#interactive PLD_qtwidget=@PLD_qtwidget@ +PLD_rasterqt=@PLD_rasterqt@ +PLD_svgqt=@PLD_svgqt@ #interactive PLD_gcw=@PLD_gcw@ PLD_gif=@PLD_gif@ #interactive PLD_gnome=@PLD_gnome@ @@ -226,11 +230,8 @@ PLD_psttf=@PLD_psttf@ # special case PLD_psttfc=@PLD_psttf@ -#interactive PLD_qtwidget=@PLD_qtwidget@ -PLD_rasterqt=@PLD_rasterqt@ PLD_svg=@PLD_svg@ PLD_svgcairo=@PLD_svgcairo@ -PLD_svgqt=@PLD_svgqt@ PLD_tek4010=@PLD_tek4010@ PLD_tek4010f=@PLD_tek4010f@ PLD_tek4107=@PLD_tek4107@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-03-06 16:40:41
|
Revision: 9679 http://plplot.svn.sourceforge.net/plplot/?rev=9679&view=rev Author: airwin Date: 2009-03-06 16:40:31 +0000 (Fri, 06 Mar 2009) Log Message: ----------- AWI for Alban Rochel. Make the qtwidget device into a plug-in device accessible from libplplot and dynamically loaded by that library. Split the previous rasterqt device into bmpqt, jpgqt, pngqt, ppmqt, and tiffqt devices with corresponding PLD_bmpqt, PLD_jpgqt, etc., control options. Modified Paths: -------------- trunk/cmake/modules/drivers-init.cmake trunk/cmake/modules/qt.cmake trunk/config.h.cmake trunk/drivers/CMakeLists.txt trunk/drivers/qt.cpp trunk/drivers/qt.h trunk/include/drivers.h trunk/include/plDevs.h.cmake trunk/include/plcore.h trunk/plplot_test/plplot-test.sh.cmake Modified: trunk/cmake/modules/drivers-init.cmake =================================================================== --- trunk/cmake/modules/drivers-init.cmake 2009-03-06 01:39:42 UTC (rev 9678) +++ trunk/cmake/modules/drivers-init.cmake 2009-03-06 16:40:31 UTC (rev 9679) @@ -86,7 +86,11 @@ "epsqt:qt:OFF" "pdfqt:qt:OFF" "qtwidget:qt:OFF" -"rasterqt:qt:OFF" +"bmpqt:qt:OFF" +"jpgqt:qt:OFF" +"pngqt:qt:OFF" +"ppmqt:qt:OFF" +"tiffqt:qt:OFF" "svgqt:qt:OFF" "gif:gd:ON" "jpeg:gd:ON" Modified: trunk/cmake/modules/qt.cmake =================================================================== --- trunk/cmake/modules/qt.cmake 2009-03-06 01:39:42 UTC (rev 9678) +++ trunk/cmake/modules/qt.cmake 2009-03-06 16:40:31 UTC (rev 9679) @@ -1,11 +1,15 @@ find_package(Qt4) -if(PLD_rasterqt OR PLD_epsqt OR PLD_pdfqt OR PLD_qtwidget OR PLD_svgqt) +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) if(PLD_svgqt AND ${QT_VERSION_MINOR} GREATER 2) set(QT_USE_QTSVG 1) endif(PLD_svgqt AND ${QT_VERSION_MINOR} GREATER 2) include(${QT_USE_FILE}) if(NOT QT4_FOUND) - set(PLD_rasterqt OFF CACHE BOOL "Enable Qt raster device" FORCE) + 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) @@ -19,4 +23,4 @@ set(qt_LINK_FLAGS ${QT_LIBRARIES}) set(DRIVERS_LINK_FLAGS ${DRIVERS_LINK_FLAGS} ${qt_LINK_FLAGS}) endif(NOT QT4_FOUND) -endif(PLD_rasterqt OR PLD_epsqt OR PLD_pdfqt OR PLD_qtwidget OR PLD_svgqt) +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) Modified: trunk/config.h.cmake =================================================================== --- trunk/config.h.cmake 2009-03-06 01:39:42 UTC (rev 9678) +++ trunk/config.h.cmake 2009-03-06 16:40:31 UTC (rev 9679) @@ -338,12 +338,24 @@ /* Define if Qt Widget driver is present */ #cmakedefine PLD_qtwidget -/* Define if raster Qt driver is present */ -#cmakedefine PLD_rasterqt - /* Define if SVG Qt driver is present */ #cmakedefine PLD_svgqt +/* Define if bmp Qt driver is present */ +#cmakedefine PLD_bmpqt + +/* Define if jpg Qt driver is present */ +#cmakedefine PLD_jpgqt + +/* Define if png Qt driver is present */ +#cmakedefine PLD_pngqt + +/* Define if ppm Qt driver is present */ +#cmakedefine PLD_ppmqt + +/* Define if tiff Qt driver is present */ +#cmakedefine PLD_tiffqt + /* Portable definition for PTHREAD_MUTEX_RECURSIVE */ #define PLPLOT_MUTEX_RECURSIVE ${PLPLOT_MUTEX_RECURSIVE} Modified: trunk/drivers/CMakeLists.txt =================================================================== --- trunk/drivers/CMakeLists.txt 2009-03-06 01:39:42 UTC (rev 9678) +++ trunk/drivers/CMakeLists.txt 2009-03-06 16:40:31 UTC (rev 9679) @@ -24,12 +24,13 @@ DESTINATION ${DOC_DIR} ) -if(PLD_rasterqt OR PLD_epsqt OR PLD_pdfqt OR PLD_qtwidget OR PLD_svgqt) +#qt.h only useful if anyone wants to build a Qt application with the Qt widget driver +if(PLD_qtwidget) install( FILES qt.h DESTINATION ${INCLUDE_DIR} ) -endif(PLD_rasterqt OR PLD_epsqt OR PLD_pdfqt OR PLD_qtwidget OR PLD_svgqt) +endif(PLD_qtwidget) if(ENABLE_DYNDRIVERS) set_source_files_properties( Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2009-03-06 01:39:42 UTC (rev 9678) +++ trunk/drivers/qt.cpp 2009-03-06 16:40:31 UTC (rev 9679) @@ -33,30 +33,65 @@ // Drivers declaration PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_qt = -#if defined(PLD_rasterqt) - "rasterqt:Qt Raster driver:0:qt:66:rasterqt\n" +#if defined(PLD_bmpqt) + "bmpqt:Qt Windows bitmap driver:0:qt:66:bmpqt\n" #endif +#if defined(PLD_jpgqt) + "jpgqt:Qt jpg driver:0:qt:67:jpgqt\n" +#endif +#if defined(PLD_pngqt) + "pngqt:Qt png driver:0:qt:68:pngqt\n" +#endif +#if defined(PLD_ppmqt) + "ppmqt:Qt ppm driver:0:qt:69:ppmqt\n" +#endif +#if defined(PLD_tiffqt) + "tiffqt:Qt tiff driver:0:qt:70:tiffqt\n" +#endif #if defined(PLD_svgqt) && QT_VERSION >= 0x040300 - "svgqt:Qt SVG driver:0:qt:67:svgqt\n" + "svgqt:Qt SVG driver:0:qt:71:svgqt\n" #endif #if defined(PLD_qtwidget) - "qtwidget:Qt Widget:0:qt:68:qtwidget\n" + "qtwidget:Qt Widget:1:qt:72:qtwidget\n" #endif #if defined(PLD_epsqt) - "epsqt:Qt EPS driver:0:qt:69:epsqt\n" + "epsqt:Qt EPS driver:0:qt:73:epsqt\n" #endif #if defined(PLD_pdfqt) - "pdfqt:Qt PDF driver:0:qt:70:pdfqt\n" + "pdfqt:Qt PDF driver:0:qt:74:pdfqt\n" #endif ; // Declaration of the driver-specific interface functions -#if defined(PLD_rasterqt) -void plD_dispatch_init_rasterqt(PLDispatchTable *pdt); +#if defined (PLD_bmpqt) || defined(PLD_jpgqt) || defined (PLD_pngqt) || defined(PLD_ppmqt) || defined(PLD_tiffqt) void plD_init_rasterqt(PLStream *); -void plD_eop_rasterqt(PLStream *); #endif +#if defined (PLD_bmpqt) +void plD_dispatch_init_bmpqt(PLDispatchTable *pdt); +void plD_eop_bmpqt(PLStream *); +#endif + +#if defined (PLD_jpgqt) +void plD_dispatch_init_jpgqt(PLDispatchTable *pdt); +void plD_eop_jpgqt(PLStream *); +#endif + +#if defined (PLD_pngqt) +void plD_dispatch_init_pngqt(PLDispatchTable *pdt); +void plD_eop_pngqt(PLStream *); +#endif + +#if defined (PLD_ppmqt) +void plD_dispatch_init_ppmqt(PLDispatchTable *pdt); +void plD_eop_ppmqt(PLStream *); +#endif + +#if defined (PLD_tiffqt) +void plD_dispatch_init_tiffqt(PLDispatchTable *pdt); +void plD_eop_tiffqt(PLStream *); +#endif + #if defined(PLD_svgqt) && QT_VERSION >= 0x040300 void plD_dispatch_init_svgqt(PLDispatchTable *pdt); void plD_init_svgqt(PLStream *); @@ -80,6 +115,7 @@ void plD_dispatch_init_qtwidget(PLDispatchTable *pdt); void plD_init_qtwidget(PLStream *); void plD_eop_qtwidget(PLStream *); +void plD_tidy_qtwidget(PLStream *); #endif // Declaration of the generic interface functions @@ -422,7 +458,7 @@ { QtPLDriver * widget=NULL; // We have to dynamic_cast to make sure the good virtual functions are called -#if defined(PLD_rasterqt) +#if defined (PLD_bmpqt) || defined(PLD_jpgqt) || defined (PLD_pngqt) || defined(PLD_ppmqt) || defined(PLD_tiffqt) if(widget==NULL) widget=dynamic_cast<QtRasterDevice*>((QtPLDriver *) pls->dev); #endif #if defined(PLD_svgqt) && QT_VERSION >= 0x040300 @@ -432,7 +468,7 @@ if(widget==NULL) widget=dynamic_cast<QtEPSDevice*>((QtPLDriver *) pls->dev); #endif #if defined(PLD_qtwidget) - if(widget==NULL) widget=dynamic_cast<QtPLWidget*>((QWidget *) pls->dev); + if(widget==NULL) widget=dynamic_cast<QtPLTabWidget*>((QWidget *) pls->dev); #endif if(widget==NULL) return; @@ -443,7 +479,7 @@ void plD_polyline_qt(PLStream *pls, short *xa, short *ya, PLINT npts) { QtPLDriver * widget=NULL; -#if defined(PLD_rasterqt) +#if defined (PLD_bmpqt) || defined(PLD_jpgqt) || defined (PLD_pngqt) || defined(PLD_ppmqt) || defined(PLD_tiffqt) if(widget==NULL) widget=dynamic_cast<QtRasterDevice*>((QtPLDriver *) pls->dev); #endif #if defined(PLD_svgqt) && QT_VERSION >= 0x040300 @@ -453,7 +489,7 @@ if(widget==NULL) widget=dynamic_cast<QtEPSDevice*>((QtPLDriver *) pls->dev); #endif #if defined(PLD_qtwidget) - if(widget==NULL) widget=dynamic_cast<QtPLWidget*>((QWidget *) pls->dev); + if(widget==NULL) widget=dynamic_cast<QtPLTabWidget*>((QWidget *) pls->dev); #endif if(widget==NULL) return; @@ -466,7 +502,7 @@ short *xa, *ya; PLINT i, j; QtPLDriver * widget=NULL; -#if defined(PLD_rasterqt) +#if defined (PLD_bmpqt) || defined(PLD_jpgqt) || defined (PLD_pngqt) || defined(PLD_ppmqt) || defined(PLD_tiffqt) if(widget==NULL) widget=dynamic_cast<QtRasterDevice*>((QtPLDriver *) pls->dev); #endif #if defined(PLD_svgqt) && QT_VERSION >= 0x040300 @@ -476,7 +512,7 @@ if(widget==NULL) widget=dynamic_cast<QtEPSDevice*>((QtPLDriver *) pls->dev); #endif #if defined(PLD_qtwidget) - if(widget==NULL) widget=dynamic_cast<QtPLWidget*>((QWidget *) pls->dev); + if(widget==NULL) widget=dynamic_cast<QtPLTabWidget*>((QWidget *) pls->dev); #endif if(widget==NULL) return; @@ -512,7 +548,7 @@ void plD_state_qt(PLStream * pls, PLINT op) { QtPLDriver * widget=NULL; -#if defined(PLD_rasterqt) +#if defined (PLD_bmpqt) || defined(PLD_jpgqt) || defined (PLD_pngqt) || defined(PLD_ppmqt) || defined(PLD_tiffqt) if(widget==NULL) widget=dynamic_cast<QtRasterDevice*>((QtPLDriver *) pls->dev); #endif #if defined(PLD_svgqt) && QT_VERSION >= 0x040300 @@ -522,7 +558,7 @@ if(widget==NULL) widget=dynamic_cast<QtEPSDevice*>((QtPLDriver *) pls->dev); #endif #if defined(PLD_qtwidget) - if(widget==NULL) widget=dynamic_cast<QtPLWidget*>((QWidget *) pls->dev); + if(widget==NULL) widget=dynamic_cast<QtPLTabWidget*>((QWidget *) pls->dev); #endif if(widget==NULL) return; @@ -547,7 +583,7 @@ ////////////////// Raster driver-specific definitions: class and interface functions ///////// -#if defined(PLD_rasterqt) +#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) @@ -578,11 +614,11 @@ return res; } -void QtRasterDevice::savePlot(char* fileName) +void QtRasterDevice::savePlot(char* fileName, const char* format) { m_painterP->end(); - save(getFileName(fileName), 0, 85); - + save(getFileName(fileName), format, 85); + ++pageCounter; m_painterP->begin(this); m_painterP->setRenderHint(QPainter::Antialiasing, true); @@ -592,24 +628,6 @@ m_painterP->fillRect(0, 0, width(), height(), QBrush(Qt::black)); } -void plD_dispatch_init_rasterqt(PLDispatchTable *pdt) -{ -#ifndef ENABLE_DYNDRIVERS - pdt->pl_MenuStr = "Qt Raster Driver"; - pdt->pl_DevName = "rasterqt"; -#endif - pdt->pl_type = plDevType_FileOriented; - pdt->pl_seq = 66; - pdt->pl_init = (plD_init_fp) plD_init_rasterqt; - pdt->pl_line = (plD_line_fp) plD_line_qt; - pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; - pdt->pl_eop = (plD_eop_fp) plD_eop_rasterqt; - pdt->pl_bop = (plD_bop_fp) plD_bop_qt; - pdt->pl_tidy = (plD_tidy_fp) plD_tidy_qt; - pdt->pl_state = (plD_state_fp) plD_state_qt; - pdt->pl_esc = (plD_esc_fp) plD_esc_qt; -} - void plD_init_rasterqt(PLStream * pls) { /* Stream setup */ @@ -641,18 +659,137 @@ plP_setpxl(DPI/25.4/((QtRasterDevice*)(pls->dev))->downscale, DPI/25.4/((QtRasterDevice*)(pls->dev))->downscale); - printf("The file format will be determined by the file name extension\n"); - printf("Possible extensions are: bmp, jpg, png, ppm, tiff, xbm, xpm\n"); plOpenFile(pls); } -void plD_eop_rasterqt(PLStream *pls) +#endif + +#if defined(PLD_bmpqt) +void plD_dispatch_init_bmpqt(PLDispatchTable *pdt) { - ((QtRasterDevice *)pls->dev)->savePlot(pls->FileName); +#ifndef ENABLE_DYNDRIVERS + pdt->pl_MenuStr = "Qt Windows bitmap Driver"; + pdt->pl_DevName = "bmpqt"; +#endif + pdt->pl_type = plDevType_FileOriented; + pdt->pl_seq = 66; + pdt->pl_init = (plD_init_fp) plD_init_rasterqt; + pdt->pl_line = (plD_line_fp) plD_line_qt; + pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; + pdt->pl_eop = (plD_eop_fp) plD_eop_bmpqt; + pdt->pl_bop = (plD_bop_fp) plD_bop_qt; + pdt->pl_tidy = (plD_tidy_fp) plD_tidy_qt; + pdt->pl_state = (plD_state_fp) plD_state_qt; + pdt->pl_esc = (plD_esc_fp) plD_esc_qt; } + +void plD_eop_bmpqt(PLStream *pls) +{ + ((QtRasterDevice *)pls->dev)->savePlot(pls->FileName, "BMP"); +} #endif +#if defined(PLD_jpgqt) +void plD_dispatch_init_jpgqt(PLDispatchTable *pdt) +{ +#ifndef ENABLE_DYNDRIVERS + pdt->pl_MenuStr = "Qt jpg Driver"; + pdt->pl_DevName = "jpgqt"; +#endif + pdt->pl_type = plDevType_FileOriented; + pdt->pl_seq = 67; + pdt->pl_init = (plD_init_fp) plD_init_rasterqt; + pdt->pl_line = (plD_line_fp) plD_line_qt; + pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; + pdt->pl_eop = (plD_eop_fp) plD_eop_jpgqt; + pdt->pl_bop = (plD_bop_fp) plD_bop_qt; + pdt->pl_tidy = (plD_tidy_fp) plD_tidy_qt; + pdt->pl_state = (plD_state_fp) plD_state_qt; + pdt->pl_esc = (plD_esc_fp) plD_esc_qt; +} +void plD_eop_jpgqt(PLStream *pls) +{ + ((QtRasterDevice *)pls->dev)->savePlot(pls->FileName, "JPG"); +} +#endif + +#if defined(PLD_pngqt) +void plD_dispatch_init_pngqt(PLDispatchTable *pdt) +{ +#ifndef ENABLE_DYNDRIVERS + pdt->pl_MenuStr = "Qt png Driver"; + pdt->pl_DevName = "pngqt"; +#endif + pdt->pl_type = plDevType_FileOriented; + pdt->pl_seq = 68; + pdt->pl_init = (plD_init_fp) plD_init_rasterqt; + pdt->pl_line = (plD_line_fp) plD_line_qt; + pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; + pdt->pl_eop = (plD_eop_fp) plD_eop_pngqt; + pdt->pl_bop = (plD_bop_fp) plD_bop_qt; + pdt->pl_tidy = (plD_tidy_fp) plD_tidy_qt; + pdt->pl_state = (plD_state_fp) plD_state_qt; + pdt->pl_esc = (plD_esc_fp) plD_esc_qt; +} + +void plD_eop_pngqt(PLStream *pls) +{ + ((QtRasterDevice *)pls->dev)->savePlot(pls->FileName, "PNG"); +} +#endif + +#if defined(PLD_ppmqt) +void plD_dispatch_init_ppmqt(PLDispatchTable *pdt) +{ +#ifndef ENABLE_DYNDRIVERS + pdt->pl_MenuStr = "Qt ppm Driver"; + pdt->pl_DevName = "ppmqt"; +#endif + pdt->pl_type = plDevType_FileOriented; + pdt->pl_seq = 69; + pdt->pl_init = (plD_init_fp) plD_init_rasterqt; + pdt->pl_line = (plD_line_fp) plD_line_qt; + pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; + pdt->pl_eop = (plD_eop_fp) plD_eop_ppmqt; + pdt->pl_bop = (plD_bop_fp) plD_bop_qt; + pdt->pl_tidy = (plD_tidy_fp) plD_tidy_qt; + pdt->pl_state = (plD_state_fp) plD_state_qt; + pdt->pl_esc = (plD_esc_fp) plD_esc_qt; +} + +void plD_eop_ppmqt(PLStream *pls) +{ + ((QtRasterDevice *)pls->dev)->savePlot(pls->FileName, "PPM"); +} +#endif + +#if defined(PLD_tiffqt) +void plD_dispatch_init_tiffqt(PLDispatchTable *pdt) +{ +#ifndef ENABLE_DYNDRIVERS + pdt->pl_MenuStr = "Qt tiff Driver"; + pdt->pl_DevName = "tiffqt"; +#endif + pdt->pl_type = plDevType_FileOriented; + pdt->pl_seq = 70; + pdt->pl_init = (plD_init_fp) plD_init_rasterqt; + pdt->pl_line = (plD_line_fp) plD_line_qt; + pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; + pdt->pl_eop = (plD_eop_fp) plD_eop_tiffqt; + pdt->pl_bop = (plD_bop_fp) plD_bop_qt; + pdt->pl_tidy = (plD_tidy_fp) plD_tidy_qt; + pdt->pl_state = (plD_state_fp) plD_state_qt; + pdt->pl_esc = (plD_esc_fp) plD_esc_qt; +} + +void plD_eop_tiffqt(PLStream *pls) +{ + ((QtRasterDevice *)pls->dev)->savePlot(pls->FileName, "TIFF"); +} +#endif + + #if defined(PLD_svgqt) && QT_VERSION >= 0x040300 QtSVGDevice::QtSVGDevice(int i_iWidth, int i_iHeight): QtPLBufferedDriver(i_iWidth, i_iHeight) @@ -695,7 +832,7 @@ pdt->pl_DevName = "svgqt"; #endif pdt->pl_type = plDevType_FileOriented; - pdt->pl_seq = 67; + pdt->pl_seq = 71; pdt->pl_init = (plD_init_fp) plD_init_svgqt; pdt->pl_line = (plD_line_fp) plD_line_qt; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; @@ -814,7 +951,7 @@ pdt->pl_DevName = "epsqt"; #endif pdt->pl_type = plDevType_FileOriented; - pdt->pl_seq = 69; + pdt->pl_seq = 73; pdt->pl_init = (plD_init_fp) plD_init_epspdfqt; pdt->pl_line = (plD_line_fp) plD_line_qt; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; @@ -834,7 +971,7 @@ pdt->pl_DevName = "pdfqt"; #endif pdt->pl_type = plDevType_FileOriented; - pdt->pl_seq = 70; + pdt->pl_seq = 74; pdt->pl_init = (plD_init_fp) plD_init_epspdfqt; pdt->pl_line = (plD_line_fp) plD_line_qt; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; @@ -1155,7 +1292,17 @@ } } +void QtPLTabWidget::newTab() +{ + QtPLWidget * plotWidget=new QtPLWidget; + plotWidget->downscale=downscale; + plotWidget->m_dWidth=m_dWidth; + plotWidget->m_dHeight=m_dHeight; + addTab(plotWidget, QString("page %1").arg(count()+1)); + currentWidget=plotWidget; +} + void plD_dispatch_init_qtwidget(PLDispatchTable *pdt) { #ifndef ENABLE_DYNDRIVERS @@ -1163,42 +1310,43 @@ pdt->pl_DevName = "qtwidget"; #endif pdt->pl_type = plDevType_Interactive; - pdt->pl_seq = 68; + pdt->pl_seq = 72; pdt->pl_init = (plD_init_fp) plD_init_qtwidget; pdt->pl_line = (plD_line_fp) plD_line_qt; pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; pdt->pl_eop = (plD_eop_fp) plD_eop_qtwidget; pdt->pl_bop = (plD_bop_fp) plD_bop_qt; - pdt->pl_tidy = (plD_tidy_fp) plD_tidy_qt; + pdt->pl_tidy = (plD_tidy_fp) plD_tidy_qtwidget; pdt->pl_state = (plD_state_fp) plD_state_qt; pdt->pl_esc = (plD_esc_fp) plD_esc_qt; } -void plsqtdev(QtPLWidget* dev) +// global variables initialised in init(), used in tidy() +QApplication* app; +int argc=1; // argc and argv have to exist when tidy() is used, thus they are made global +char argv[20]; + +void plD_init_qtwidget(PLStream * pls) { - if(dev==NULL) return; - PLINT w, h; - plsc->dev = (void*)dev; - plsc->xlength = dev->m_dWidth; - plsc->ylength = dev->m_dHeight; + argv[0]='\0'; + app=new QApplication(argc, (char**)&argv); + QMainWindow * mw=new QMainWindow; + QtPLTabWidget* tabWidget=new QtPLTabWidget; + + plsc->dev = (void*)tabWidget; + plsc->xlength = tabWidget->m_dWidth; + plsc->ylength = tabWidget->m_dHeight; if (plsc->xlength > plsc->ylength) - dev->downscale = (PLFLT)plsc->xlength/(PLFLT)(PIXELS_X-1); + tabWidget->downscale = (PLFLT)plsc->xlength/(PLFLT)(PIXELS_X-1); else - dev->downscale = (PLFLT)plsc->ylength/(PLFLT)PIXELS_Y; + tabWidget->downscale = (PLFLT)plsc->ylength/(PLFLT)PIXELS_Y; - plP_setphy((PLINT) 0, (PLINT) (plsc->xlength / dev->downscale), (PLINT) 0, (PLINT) (plsc->ylength / dev->downscale)); + plP_setphy((PLINT) 0, (PLINT) (plsc->xlength / tabWidget->downscale), (PLINT) 0, (PLINT) (plsc->ylength / tabWidget->downscale)); - plP_setpxl(DPI/25.4/dev->downscale, DPI/25.4/dev->downscale); -} + plP_setpxl(DPI/25.4/tabWidget->downscale, DPI/25.4/tabWidget->downscale); -void plD_init_qtwidget(PLStream * pls) -{ - if ((pls->phyxma == 0) || (pls->dev == NULL)) { - plexit("Must call plsqtdev first to set user plotting widget!"); - } - pls->color = 1; /* Is a color device */ pls->plbuf_write=0; pls->dev_fill0 = 1; /* Handle solid fills */ @@ -1207,12 +1355,25 @@ pls->dev_flush=1; pls->dev_clear=1; pls->termin=1; + + mw->setCentralWidget(tabWidget); + mw->setVisible(true); + mw->setWindowTitle("plplot"); + mw->resize(plsc->xlength, plsc->ylength); + app->setActiveWindow(mw); + } void plD_eop_qtwidget(PLStream *pls) { - ((QtPLWidget *)pls->dev)->clearWidget(); + QtPLTabWidget* tabWidget=((QtPLTabWidget*)pls->dev); + tabWidget->currentWidget=NULL; } + +void plD_tidy_qtwidget(PLStream *pls) +{ + app->exec(); +} #endif #endif Modified: trunk/drivers/qt.h =================================================================== --- trunk/drivers/qt.h 2009-03-06 01:39:42 UTC (rev 9678) +++ trunk/drivers/qt.h 2009-03-06 16:40:31 UTC (rev 9679) @@ -40,6 +40,8 @@ #include <QApplication> #include <QWidget> #include <QMouseEvent> +#include <QTabWidget> +#include <QMainWindow> #include "plplotP.h" #include "drivers.h" @@ -179,7 +181,7 @@ QLinkedList<BufferElement> m_listBuffer; }; -#if defined (PLD_rasterqt) +#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 { @@ -191,7 +193,7 @@ // Saves the plot to the fileName file, possibly appending // _page# to the file name if not the 1st page - void savePlot(char* fileName); + void savePlot(char* fileName, const char* format); protected: // Generates the actual file name, depending on fileName and pageCounter @@ -308,16 +310,76 @@ int m_iOldSize; }; -// This function must be called between plinit to set up the widget -// The widget is created within the Qt Application -// e.g.: -// QtPLWidget*plot=new QtPLWidget(QT_DEFAULT_X, QT_DEFAULT_Y, this); -// plmkstrm(&strm); -// plsqtdev(plot); -// plsdev ("qtwidget"); -// plinit(); -// ... -void plsqtdev(QtPLWidget *plotdev); + +// This widget wraps up various QtPLWidgets as tabs +// The stream plots on currentWidget, which should be changed by eop() +// Actually, setting currentWidget as NULL creates a new page when +// the first plot instructions are issued. So eop() only has to set it as NULL; +class QtPLTabWidget: public QTabWidget, public QtPLDriver +{ + public: + QtPLTabWidget() + { + currentWidget=NULL; + } + + virtual void drawLine(short x1, short y1, short x2, short y2) + { + if(currentWidget==NULL) newTab(); + currentWidget->drawLine(x1, y1, x2, y2); + } + + virtual void drawPolyline(short * x, short * y, PLINT npts) + { + if(currentWidget==NULL) newTab(); + currentWidget->drawPolyline(x, y, npts); + } + + virtual void drawPolygon(short * x, short * y, PLINT npts) + { + if(currentWidget==NULL) newTab(); + currentWidget->drawPolygon(x, y, npts); + } + + virtual void setColor(int r, int g, int b) + { + if(currentWidget==NULL) newTab(); + currentWidget->setColor(r, g, b); + } + + virtual void setWidth(PLINT w) + { + if(currentWidget==NULL) newTab(); + currentWidget->setWidth(w); + } + + virtual void setDashed(PLINT nms, PLINT* mark, PLINT* space) + { + if(currentWidget==NULL) newTab(); + currentWidget->setDashed(nms, mark, space); + } + + // Set pen to draw solid strokes (called after drawing dashed strokes) + virtual void setSolid() + { + if(currentWidget==NULL) newTab(); + currentWidget->setSolid(); + } + + void setSmooth(bool b) + { + if(currentWidget==NULL) newTab(); + currentWidget->setSmooth(b); + } + + virtual void savePlot(char* fileName){} + + QtPLWidget* currentWidget; + + protected: + void newTab(); +}; + #endif #endif Modified: trunk/include/drivers.h =================================================================== --- trunk/include/drivers.h 2009-03-06 01:39:42 UTC (rev 9678) +++ trunk/include/drivers.h 2009-03-06 16:40:31 UTC (rev 9679) @@ -97,7 +97,11 @@ PLDLLIMPEXP_DRIVER void plD_dispatch_init_pngcairo ( PLDispatchTable *pdt ); PLDLLIMPEXP_DRIVER void plD_dispatch_init_memcairo ( PLDispatchTable *pdt ); PLDLLIMPEXP_DRIVER void plD_dispatch_init_extcairo ( PLDispatchTable *pdt ); -PLDLLIMPEXP_DRIVER void plD_dispatch_init_rasterqt ( PLDispatchTable *pdt ); +PLDLLIMPEXP_DRIVER void plD_dispatch_init_bmpqt ( PLDispatchTable *pdt ); +PLDLLIMPEXP_DRIVER void plD_dispatch_init_jpgqt ( PLDispatchTable *pdt ); +PLDLLIMPEXP_DRIVER void plD_dispatch_init_pngqt ( PLDispatchTable *pdt ); +PLDLLIMPEXP_DRIVER void plD_dispatch_init_ppmqt ( PLDispatchTable *pdt ); +PLDLLIMPEXP_DRIVER void plD_dispatch_init_tiffqt ( PLDispatchTable *pdt ); PLDLLIMPEXP_DRIVER void plD_dispatch_init_svgqt ( PLDispatchTable *pdt ); PLDLLIMPEXP_DRIVER void plD_dispatch_init_epsqt ( PLDispatchTable *pdt ); PLDLLIMPEXP_DRIVER void plD_dispatch_init_pdfqt ( PLDispatchTable *pdt ); Modified: trunk/include/plDevs.h.cmake =================================================================== --- trunk/include/plDevs.h.cmake 2009-03-06 01:39:42 UTC (rev 9678) +++ trunk/include/plDevs.h.cmake 2009-03-06 16:40:31 UTC (rev 9679) @@ -85,7 +85,11 @@ #cmakedefine PLD_pngcairo #cmakedefine PLD_memcairo #cmakedefine PLD_extcairo -#cmakedefine PLD_rasterqt +#cmakedefine PLD_bmpqt +#cmakedefine PLD_jpgqt +#cmakedefine PLD_pngqt +#cmakedefine PLD_ppmqt +#cmakedefine PLD_tiffqt #cmakedefine PLD_svgqt #cmakedefine PLD_epsqt #cmakedefine PLD_pdfqt Modified: trunk/include/plcore.h =================================================================== --- trunk/include/plcore.h 2009-03-06 01:39:42 UTC (rev 9678) +++ trunk/include/plcore.h 2009-03-06 16:40:31 UTC (rev 9679) @@ -296,9 +296,21 @@ #if defined(PLD_extcairo) && !defined(ENABLE_DYNDRIVERS) plD_dispatch_init_extcairo, #endif -#if defined(PLD_rasterqt) && !defined(ENABLE_DYNDRIVERS) - plD_dispatch_init_rasterqt, +#if defined(PLD_bmpqt) && !defined(ENABLE_DYNDRIVERS) + plD_dispatch_init_bmpqt, #endif +#if defined(PLD_jpgqt) && !defined(ENABLE_DYNDRIVERS) + plD_dispatch_init_jpgqt, +#endif +#if defined(PLD_pngqt) && !defined(ENABLE_DYNDRIVERS) + plD_dispatch_init_pngqt, +#endif +#if defined(PLD_ppmqt) && !defined(ENABLE_DYNDRIVERS) + plD_dispatch_init_ppmqt, +#endif +#if defined(PLD_tiffqt) && !defined(ENABLE_DYNDRIVERS) + plD_dispatch_init_tiffqt, +#endif #if defined(PLD_svgqt) && !defined(ENABLE_DYNDRIVERS) plD_dispatch_init_svgqt, #endif Modified: trunk/plplot_test/plplot-test.sh.cmake =================================================================== --- trunk/plplot_test/plplot-test.sh.cmake 2009-03-06 01:39:42 UTC (rev 9678) +++ trunk/plplot_test/plplot-test.sh.cmake 2009-03-06 16:40:31 UTC (rev 9679) @@ -198,7 +198,11 @@ PLD_epsqt=@PLD_epsqt@ PLD_pdfqt=@PLD_pdfqt@ #interactive PLD_qtwidget=@PLD_qtwidget@ -PLD_rasterqt=@PLD_rasterqt@ +PLD_bmpqt=@PLD_bmpqt@ +PLD_jpgqt=@PLD_jpgqt@ +PLD_pngqt=@PLD_pngqt@ +PLD_ppmqt=@PLD_ppmqt@ +PLD_tiffqt=@PLD_tiffqt@ PLD_svgqt=@PLD_svgqt@ #interactive PLD_gcw=@PLD_gcw@ PLD_gif=@PLD_gif@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-03-09 05:29:29
|
Revision: 9682 http://plplot.svn.sourceforge.net/plplot/?rev=9682&view=rev Author: airwin Date: 2009-03-09 05:29:26 +0000 (Mon, 09 Mar 2009) Log Message: ----------- Change from treating libcd as an external library to building it internally as libnistcd. Modified Paths: -------------- trunk/cmake/modules/cgm.cmake trunk/cmake/modules/plplot_version.cmake trunk/drivers/CMakeLists.txt trunk/lib/CMakeLists.txt Added Paths: ----------- trunk/lib/nistcd/ trunk/lib/nistcd/CMakeLists.txt trunk/lib/nistcd/README_plplot_nistcd trunk/lib/nistcd/cd.announce trunk/lib/nistcd/cd.c trunk/lib/nistcd/cd.h trunk/lib/nistcd/cd.html trunk/lib/nistcd/cd1.3.lsm trunk/lib/nistcd/cddll.h trunk/lib/nistcd/cdexp1.cgm trunk/lib/nistcd/cdexpert.c trunk/lib/nistcd/cdmulti.c trunk/lib/nistcd/cdmulti.cgm trunk/lib/nistcd/cdout.cgm trunk/lib/nistcd/cdsimple.c trunk/lib/nistcd/cdsimple.cgm trunk/lib/nistcd/cdtest.c trunk/lib/nistcd/cdtext.c trunk/lib/nistcd/cdtext.cgm trunk/lib/nistcd/color16.c trunk/lib/nistcd/color16.cgm trunk/lib/nistcd/defines.h trunk/lib/nistcd/readme Removed Paths: ------------- trunk/cmake/external/libcd/ trunk/cmake/modules/FindCD.cmake Deleted: trunk/cmake/modules/FindCD.cmake =================================================================== --- trunk/cmake/modules/FindCD.cmake 2009-03-09 04:54:25 UTC (rev 9681) +++ trunk/cmake/modules/FindCD.cmake 2009-03-09 05:29:26 UTC (rev 9682) @@ -1,38 +0,0 @@ -# Find cd header and library. This is the public domain library -# (see http://prdownloads.sourceforge.net/plplot/cd1.3.tar.gz?download -# for a copy) for creating CGM (Computer Graphics Metafile, see -# http://www.agocg.ac.uk/train/cgm/cgm.htm) files. -# - -# This module defines the following uncached variables: -# CD_FOUND, if false, do not try to use CD. -# CD_INCLUDE_DIRS, where to find cd.h. -# CD_LIBRARIES, the libraries to link against to use libcd.a -# CD_LIBRARY_DIRS, the directory where libcd.a is found. - -find_path(CD_INCLUDE_DIR cd.h /usr/local/include /usr/include) - -if(CD_INCLUDE_DIR) - find_library(CD_LIBRARY - NAMES cd - PATHS /usr/local/lib /usr/lib - ) - if(CD_LIBRARY) - set(CD_LIBRARY_DIR "") - get_filename_component(CD_LIBRARY_DIRS ${CD_LIBRARY} PATH) - # Set uncached variables as per standard. - set(CD_FOUND ON) - set(CD_INCLUDE_DIRS ${CD_INCLUDE_DIR}) - set(CD_LIBRARIES ${CD_LIBRARY}) - endif(CD_LIBRARY) -endif(CD_INCLUDE_DIR) - -if(CD_FOUND) - if(NOT CD_FIND_QUIETLY) - message(STATUS "FindCD: Found both cd.h and libcd.a") - endif(NOT CD_FIND_QUIETLY) -else(CD_FOUND) - if(CD_FIND_REQUIRED) - message(FATAL_ERROR "FindCD: Could not find cd.h and/or libcd.a") - endif(CD_FIND_REQUIRED) -endif(CD_FOUND) Modified: trunk/cmake/modules/cgm.cmake =================================================================== --- trunk/cmake/modules/cgm.cmake 2009-03-09 04:54:25 UTC (rev 9681) +++ trunk/cmake/modules/cgm.cmake 2009-03-09 05:29:26 UTC (rev 9682) @@ -21,28 +21,12 @@ # # The following variables are set / modified # -# PLD_cgm - ON means the cgm devic is enabled. -# cgm_COMPILE_FLAGS - COMPILE_FLAGS (string) required to compile cgm -# device driver. -# cgm_LINK_FLAGS - LINK_FLAGS (string) for dynamic cgm device driver. -# DRIVERS_LINK_FLAGS - list of LINK_FLAGS for all static device drivers. -# -# Include file searches use FindPath. To add extra search directories -# set the environment variable CMAKE_INCLUDE_PATH. -# Library searches use FindLibrary. To add extra search directories -# set the environment variable CMAKE_LIBRARY_PATH. -# See cmake documentation for further details. +# cgm_TARGETS - list of targets which the cgm dynamic device +# depends on. +# DRIVERS_LINK_FLAGS - list of targets which the cgm static device +# depends on. if(PLD_cgm) - find_package(CD) - if(CD_FOUND) - set(cgm_COMPILE_FLAGS "-I${CD_INCLUDE_DIRS}") - set(cgm_LINK_FLAGS ${CD_LIBRARIES}) - set(DRIVERS_LINK_FLAGS ${DRIVERS_LINK_FLAGS} ${cgm_LINK_FLAGS}) - else(CD_FOUND) - message(STATUS - "WARNING: cd.h and/or libcd.a not found. Setting PLD_cgm to OFF." - ) - set(PLD_cgm OFF CACHE BOOL "Enable cgm device" FORCE) - endif(CD_FOUND) + set(cgm_TARGETS nistcd) + set(DRIVERS_LINK_FLAGS ${DRIVERS_LINK_FLAGS} nistcd) endif(PLD_cgm) Modified: trunk/cmake/modules/plplot_version.cmake =================================================================== --- trunk/cmake/modules/plplot_version.cmake 2009-03-09 04:54:25 UTC (rev 9681) +++ trunk/cmake/modules/plplot_version.cmake 2009-03-09 05:29:26 UTC (rev 9682) @@ -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(nistcd_SOVERSION 0) +set(nistcd_VERSION ${nist_SOVERSION}.0.1) + set(csirocsa_SOVERSION 0) set(csirocsa_VERSION ${csirocsa_SOVERSION}.0.1) Modified: trunk/drivers/CMakeLists.txt =================================================================== --- trunk/drivers/CMakeLists.txt 2009-03-09 04:54:25 UTC (rev 9681) +++ trunk/drivers/CMakeLists.txt 2009-03-09 05:29:26 UTC (rev 9682) @@ -41,6 +41,7 @@ include_directories( ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/lib/qsastime + ${CMAKE_SOURCE_DIR}/lib/nistcd ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/include ) Modified: trunk/lib/CMakeLists.txt =================================================================== --- trunk/lib/CMakeLists.txt 2009-03-09 04:54:25 UTC (rev 9681) +++ trunk/lib/CMakeLists.txt 2009-03-09 05:29:26 UTC (rev 9682) @@ -1,3 +1,4 @@ add_subdirectory(csa) add_subdirectory(nn) add_subdirectory(qsastime) +add_subdirectory(nistcd) Added: trunk/lib/nistcd/CMakeLists.txt =================================================================== --- trunk/lib/nistcd/CMakeLists.txt (rev 0) +++ trunk/lib/nistcd/CMakeLists.txt 2009-03-09 05:29:26 UTC (rev 9682) @@ -0,0 +1,70 @@ +# lib/nistcd/CMakeLists.txt for PLplot +### +### Process this file with cmake to produce Makefile +### +# Copyright (C) 2006 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 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 + +# build nistcd library (a.k.a., "cd" library put into the public domain by +# NIST) required by the PLplot cgm device. +if(PLD_cgm) + include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ) + + set( cd_LIB_SRCS cd.c ) + set( cd_LIB_HDRS cd.h defines.h ) + + if(BUILD_SHARED_LIBS) + set_source_files_properties( ${cd_LIB_SRCS} + PROPERTIES COMPILE_FLAGS "-DUSINGDLL" + ) + endif(BUILD_SHARED_LIBS) + + add_library( nistcd ${cd_LIB_SRCS} ) + set_target_properties( + nistcd + PROPERTIES + SOVERSION ${nistcd_SOVERSION} + VERSION ${nistcd_VERSION} + INSTALL_NAME_DIR "${LIB_DIR}" + ) + + option(TEST_NISTCD "Test libnistcd" ON) + if(TEST_NISTCD) + # build and run applications to test libnistcd. + set( cd_EXE color16 cdsimple cdtext cdmulti cdexpert ) + foreach(EXE ${cd_EXE}) + add_executable( ${EXE} ${EXE}.c ) + target_link_libraries( ${EXE} nistcd ) + endforeach(EXE ${cd_EXE}) + endif(TEST_NISTCD) + + # install library and binaries + install( TARGETS + nistcd + ARCHIVE DESTINATION ${LIB_DIR} + LIBRARY DESTINATION ${LIB_DIR} + RUNTIME DESTINATION ${BIN_DIR} + ) + + # install library header files. + install( + FILES ${cd_LIB_HDRS} + DESTINATION ${INCLUDE_DIR} + ) +endif(PLD_cgm) Property changes on: trunk/lib/nistcd/CMakeLists.txt ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/lib/nistcd/README_plplot_nistcd =================================================================== --- trunk/lib/nistcd/README_plplot_nistcd (rev 0) +++ trunk/lib/nistcd/README_plplot_nistcd 2009-03-09 05:29:26 UTC (rev 9682) @@ -0,0 +1,10 @@ +Most of these files were obtained (as of 2001-12-09) from +http://www.pa.msu.edu/ftp/pub/unix/cd1.3.tar.gz + +This software was written originally by G. Edward Johnson at NIST, but it is +no longer maintained by him. It is public-domain software except for the +small part licensed under the libgd license (see his documentation). + +The PLplot developer's contribution is CMakeLists.txt, cddll.h, and some +small visibility modifications to cd.h. We call the resulting library, +libnistcd to distinguish it from all the other "libcd" libraries out there. Property changes on: trunk/lib/nistcd/README_plplot_nistcd ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/lib/nistcd/cd.announce =================================================================== --- trunk/lib/nistcd/cd.announce (rev 0) +++ trunk/lib/nistcd/cd.announce 2009-03-09 05:29:26 UTC (rev 9682) @@ -0,0 +1,56 @@ + + +Announcing the release of CGM Draw 1.3. + +CGM Draw is a freely available library for generating CGM files from a +C program. It has been tested on Solaris, Ultrix, Linux, IRIX, AIX, +OpenVMS, and DOS. CGM (Computer Graphics Metafile) is a vector +graphics format that can be read by many popular packages. With CGM +Draw your code can quickly draw images complete with lines, arcs, +rectangles, polygons, and text. CGM Draw is ideal for creating CGM +files on the fly when you have a rapidly changing data set (such as in +response to database queries.) + + +Documentation for cd is included with the package, and is available from +http://speckle.ncsl.nist.gov/~lorax/cgm/cd.html +General information about CGM is available many places on the web, including +http://speckle.ncsl.nist.gov/~lsr/cgm.htm +This distribution may be retrieved via ftp from +zing.ncsl.nist.gov in the directory "cgm" It will have the +name cd followed by the version number. +The current version is 1.3 and is at: +ftp://zing.ncsl.nist.gov/cgm/cd1.3.tar.gz + + +Whats new in this version: +-Polygon Sets, you can define multiple polygons and draw them all with + one simple command. +-Markers, set points in CGM's +-Expert functions, to give you more control of the final CGM if you need it. + + +What is CGM: +CGM is a widely used method for representing 2D vector +pictures. Many industry users have decided to use CGM as the means of +representing, storing, and interchanging pictures in all their documentation +(e.g., Air Transport Association will use CGM to represent illustrations, US +Petroleum industry has also adopted it). +CGM is already and established, open standard. In 1987 +ISO approved the first version as an international standard, and the +current version (which extends the original) was approved in 1992 (ISO +8632.) Many programs are already capable of creating CGM files. Major +illustration packages already can save their files in the CGM format +(CorelDraw is one example) and many word processing programs (WordPerfect +and Word) can include CGM files in their documents. + + +What types of pictures is CGM suited for: +CGM is ideally suited for pictures with geometric shapes, line drawings, +and text. Here are some particular applications that CGM would do well +with: + Charts and Graphs--For instance charts of recent stock market data, or +graphs of web server usage. + Technical illustrations--Diagrams for products or engineering drawings. +CGM pictures can be zoomed in on to show small details. + General illustrations--Such as those you see in books or comic strips. Property changes on: trunk/lib/nistcd/cd.announce ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/lib/nistcd/cd.c =================================================================== --- trunk/lib/nistcd/cd.c (rev 0) +++ trunk/lib/nistcd/cd.c 2009-03-09 05:29:26 UTC (rev 9682) @@ -0,0 +1,2911 @@ + +/* cd.c main file for cgmdraw module. + + Written by G. Edward Johnson <mailto:lo...@ni...> + Date: April 1996 + Copyright: cd software produced by NIST, an agency of the + U.S. government, is by statute not subject to copyright + in the United States. Recipients of this software assume all + responsibilities associated with its operation, modification + and maintenance. + + Portions of this package are from the gd package written by + Thomas Boutell and are copyright 1994, 1995, Quest Protein + Database Center, Cold Spring Harbor Labs. They are marked in the + source code. +*/ + +#ifndef NOMALLOCH +#include <malloc.h> +#endif +#include <stdio.h> +#include <math.h> +#include <string.h> +#include <stdlib.h> +#include "defines.h" +#include "cd.h" + + +static int cdImageAddColor(cdImagePtr im, int si, int ei); + +cdImagePtr cdImageCreate(int sx, int sy) +/* Creates a new image of size (sx,sy). Most people should always + * start by calling this function */ +{ + cdImagePtr im; + + im = cdImageStartCgm(); + if (!im) return 0; /* memory allocation failed */ + if (!cdImageSetSize(im, sx,sy)) {free (im);return 0;} + + if (!cdCgmHeader(im)) {free (im);return 0;} + + if (cdCgmPic(im, 0)) { + return im; + } + else { + free(im); + return 0; + } +} + +static int cdAppNull(unsigned char *es, int x) { +/* put x nulls in the string. + * return value is number of octets added (1) */ + int y; + + for(y=0; y<x; y++) { + *es = '\0'; + es++; + } + return x; +} + +static int cdAppByte(unsigned char *es, short int addme) { +/* Append an octet to the end of es + * Return value is number of octets added + * for internal cd functions only, do not call + */ + *es = (unsigned char) addme & 0377; + return 1; +} + +static int cdAppShort(unsigned char *es, short int addme) { +/* Append a short to the end of es + * return value is number of octets added + * For internal cd functions only, do not call! + */ + short int temp; + + temp = addme >> 8; + *es = (unsigned char) temp & 0377; + es++; + *es = (unsigned char) addme & 0377; + return 2; +} + +/* static int cdAppWord(unsigned char *es, int addme){ */ +/* Append an word to es + * Return value is number of octets added + * For internal cd functions only, do not call! + */ +/* + int temp; + temp = addme >> 24; + *es = (unsigned char) temp & 0377; + es++; + temp = addme >> 16; + *es = (unsigned char) temp & 0377; + es++; + temp = addme >> 8; + *es = (unsigned char) temp & 0377; + es++; + *es = (unsigned char) addme & 0377; + es++; + return 4; +} +*/ + +static int cdcomhead(unsigned char *es, int elemclass, int id, int len) { +/* sets the command header in the first two bytes of string es + * element class is in bits 15-12 + * element id is in bits 11-5 + * parameter list length is in bits 4-0 + */ + int temp; + + if (!es) return 0; /* the string must be allocated first */ + + /* set the element class */ + *es = (unsigned char) elemclass << 4; + /* set the element id */ + temp = 0177 & id ; + temp = temp >> 3; + *es = *es | temp; + es++; + id = id << 5; + *es = (unsigned char) id; + *es = *es | (unsigned char) ( 037 & len ); + + return 1; +} + +static int cdcomheadlong(unsigned char *es, int elemclass, int id, int len) { +/* sets the command header for the long form. + * first 16 bits: + * element class is in bits 15-12 + * element id is in bits 11-5 + * parameter list length is in bits 4-0 = 31 + * second 16 bits: + * bit 15 = 0 (for last partition) + * bit 14-0 param list len + */ + + /* I'm lazy, call cdcomhead to set the first two bytes */ + if (!cdcomhead(es, elemclass, id, 31)) return 0; + es += 2; + + /* now set the second two bytes */ + cdAppShort(es, (short int) len); + *es = *es & 0177; /* make bit 15 = 0 */ + es += 2; + + return 1; +} + +static int cdAddElem(cdImagePtr im, unsigned char *es, int octet_count) +/* adds a string, which is a CGM element to the elemlist. + * This function is called by other functions in this library and + * should NOT be called by users of the library + * For internal cd functions only, do not call! + */ +{ + unsigned char *newlist; /* in case memory allocation fails */ + int x; /* counter */ + + while ((octet_count + 1) >= im->bytestoend) { + /* not enough space, must grow elemlist */ + im->listlen = im->listlen + CDGROWLISTSIZE; + newlist = (unsigned char *) realloc(im->elemlist, SIZEOF(unsigned char ) * im->listlen); + if (newlist) { + /* successfully allocated memory */ + im->elemlist = newlist; + im->bytestoend = im->bytestoend + CDGROWLISTSIZE; + im->curelemlist = im->elemlist + (im->listlen - im->bytestoend); + } + else { + /* memory allocation failed, save yurself */ + im->listlen = im->listlen - CDGROWLISTSIZE; + return 0; + } + } + + /* ok, if we get to here, there is enough space, so add it. */ + for (x=0; x < octet_count; x++) { + *im->curelemlist = (unsigned char) *es; + im->curelemlist++; + es++; + } + im->bytestoend = im->bytestoend - octet_count; + return 1; +} + +int cdCgmHeader(cdImagePtr im) { +/* add the cgm header to the imagepointer's element list + * do it all in a string than call cdAddElem on it + * For internal cd functions only, do not call! + */ + unsigned char *headerp; + unsigned char *head; + const unsigned char *buf, *buf2; + int octet_count=0; + int blen; /* length of buf */ + int curly; + int fontlistlen; /* each font in the font list is stored as a string, + with a single octet in front of the string + giving its length, fontlistlen is the sum of + the lengths of all the font strings + the + length octets. */ + + if (im->state != 0) return 0; + headerp = (unsigned char *) calloc(1024, SIZEOF(unsigned char )); + if (!headerp) return 0; /* memory allocation failed */ + head=headerp; + + /*** Attribute: BegMF; Elem Class 0; Elem ID 1 */ + buf = (const unsigned char *) "cd: CgmDraw Library"; + blen = strlen( (const char *) buf); + cdcomhead(head, 0, 1, blen+1); + head += 2; + head += cdAppByte(head, (short int) blen); + buf2 = buf; + while (*buf2) { + *head++ = *buf2++; + } + octet_count += (blen + 3); + curly = 4 - (octet_count % 4); + if (curly % 4) { + octet_count += curly; + head += cdAppNull(head, curly); + } + + /*** Attribute: MFVersion; Elem Class 1; Elem ID 1 */ + cdcomhead(head, 1, 1, 2); + head += 2; + head += cdAppShort(head, (short int) 1); + octet_count += 4; + + /*** Attribute: MFDesc; Elem Class 1; Elem ID 2 */ + blen = strlen( (char *) im->desc); + cdcomheadlong(head, 1, 2, blen+1); + head += 4; + head += cdAppByte(head, (short int) blen); + buf2 = im->desc; + while (*buf2) { + *head++ = *buf2++; + } + octet_count += (blen + 5); + curly = 4 - (octet_count % 4); + if (curly % 4) { + octet_count += curly; + head += cdAppNull(head, curly); + } + + /*** Attribute: ColrPrec; Elem Class 1; Elem ID 7 */ + cdcomhead(head, 1, 7, 2); + head += 2; + head += cdAppShort(head, (short int) 8); + octet_count += 4; + + /*** Attribute: ColrIndexPrec; Elem Class 1; Elem ID 8 */ + cdcomhead(head, 1, 8, 2); + head += 2; + head += cdAppShort(head, (short int) 8); + octet_count += 4; + + /*** Attribute: MaxColrIndex; Elem Class 1; Elem ID 9 */ + cdcomhead(head, 1, 9, 1); + head += 2; + head += cdAppByte(head, (short int) 255); + octet_count += 4; head++; + + /*** Attribute: MFElemList; Elem Class 1; Elem ID 11 */ + /* shorthand here. 1 means 1 element specified, (-1,1) + * means drawing-plus-control set */ + cdcomhead(head, 1, 11, 6); + head += 2; + head += cdAppShort(head, (short int) 1); + head += cdAppShort(head, (short int) -1); + head += cdAppShort(head, (short int) 1); + octet_count += 8; + + /*** Attribute: FontList; Elem Class 1; Elem ID 13 */ + /* im->fontlist contains a comma separated list of font names + * since we don't need the commas, and every font except one has + * a comma, and we do need a length octet, that means that + * taking the string length will give us one less than the + * correct length. */ + buf = im->fontlist; + if (buf) { /* don't do this if there aren't any fonts */ + fontlistlen = strlen( (const char *) buf) + 1; + cdcomheadlong(head, 1, 13, fontlistlen); + head +=4; + + while (*buf) { + blen = 0; + buf2 = buf; + while ((*buf) && (*buf != ',')) { + buf++; + blen++; + } + head += cdAppByte(head, (short int) blen); + while (buf2 < buf) { + *head++ = *buf2++; + } + if (*buf) { + buf++; + } + } + octet_count += (4 + fontlistlen); + curly = 4 - (octet_count % 4); + if (curly % 4) { + octet_count += curly; + head += cdAppNull(head, curly); + } + } /* end of check to see if any fonts */ + + if (cdAddElem(im, headerp, octet_count)) { + free(headerp); + headerp = 0; + return 1; + } + else { + free(headerp); + return 0; + } +} + + +int cdCgmPic(cdImagePtr im, int sticky) { +/* Start the picture. if the sticky bit is set, set and use the defaults + * of the previous picture. Otherwise, reset all defaults. + * Gej: sticky = 0 reset defaults, 1 dont reset anything, 2 only + * reset the color table + */ + unsigned char *headerp; + unsigned char *head; + unsigned char *buf, *buf2; + char *tb; + int octet_count=0; + int blen; /* length of buf */ + int x1,x2,x3,x4; /* needed for setting defaults */ + + if ((im->state != 0) && (im->state != 2)) return 0; + if ((sticky > 2) || (sticky < 0)) return 0; /* invalid sticky bit */ + /* increment the picture number */ + im->picnum++; + tb = (char *) calloc(4*4, SIZEOF(char) ); + headerp = (unsigned char *) calloc(1024, SIZEOF(unsigned char )); + if (!headerp) return 0; /* memory allocation failed */ + head=headerp; + + /*** Attribute: BegPic; Elem Class 0; Elem ID 3 */ + sprintf(tb, "picture %d", im->picnum); + buf = (unsigned char*) tb; + /* buf = (unsigned char *) "picture 1"; */ + blen = strlen( (char *) buf); + cdcomhead(head, 0, 3, blen+1); + head += 2; + head += cdAppByte(head, (short int) blen); + buf2 = buf; + while (*buf2) { + *head++ = *buf2++; + } + free(tb); + octet_count += (blen + 3); + if (!(blen % 2)) { + octet_count++; + head += cdAppNull(head, 1); + } + if (octet_count % 4) { + octet_count +=2; + head += cdAppNull(head, 2); + } + + /*** Attribute: ColrMode; Elem Class 2; Elem ID 2 */ + cdcomhead(head, 2, 2, 2); + head += 2; + head += cdAppShort(head, (short int) 0); + octet_count += 4; + /* Picture Descriptor: Line Width Specification Mode; + * Elem Class 2; Elem ID 3*/ + if (sticky && (im->linespec != CDLINESPEC)) { + cdcomhead(head, 2, 3, 2); + head += 2; + head += cdAppShort(head, (short int) im->linespec); + octet_count += 4; + } + /* Picture Descriptor: Marker Size Specification Mode; + * Elem Class 2; Elem ID 4*/ + if (sticky && (im->markerspec != CDMARKERSPEC)) { + cdcomhead(head, 2, 4, 2); + head += 2; + head += cdAppShort(head, (short int) im->markerspec); + octet_count += 4; + } + /* Picture Descriptor: Edge Width Specification Mode; + * Elem Class 2; Elem ID 5*/ + if (sticky && (im->edgespec != CDEDGESPEC)) { + cdcomhead(head, 2, 5, 2); + head += 2; + head += cdAppShort(head, (short int) im->edgespec); + octet_count += 4; + } + + /*** Attribute: VDCExt; Elem Class 2; Elem ID 6 */ + cdcomhead(head, 2, 6, 8); + head += 2; + head += cdAppShort(head, (short int) 0); + head += cdAppShort(head, (short int) 0); + head += cdAppShort(head, (short int) im->sx); + head += cdAppShort(head, (short int) im->sy); + octet_count += 10; + + /*** Attribute: Begin Picture Body; Elem Class 0; Elem ID 4 */ + cdcomhead(head, 0, 4, 0); + head += 2; + octet_count += 2; + + if (cdAddElem(im, headerp, octet_count)) { + free(headerp); + } + else { + free(headerp); + return 0; + } + + if (sticky) { + /* keep defaults the way they are */ + if (sticky == 1) { + /* keep the color table */ + if(cdImageAddColor(im, 0, im->colorsTotal - 1) == -1) { + /* no colortable */ + return 1; + } + } + else { + /* Nuke the color table if there is one */ + cdImageColorClear(im); + } + im->state = 1; + x1=im->ltype; x2=im->lwidth; x3=im->lcolor; + im->ltype=CDLTYPE; im->lwidth=CDLWIDTH; im->lcolor=CDLCOLOR; + if(!cdSetLineAttrib(im, x1, x2, x3)) return 0; + + x1=im->shapestyle; x2=im->shapecolor; x3=im->shapehatch; + im->shapestyle=CDSHAPESTYLE; im->shapecolor=CDSHAPECOLOR; + im->shapehatch=CDSHAPEHATCH; + if (!cdSetShapeFillAttrib(im, x1, x2, x3)) return 0; + + x1=im->edgetype; x2=im->edgewidth; + x3=im->edgecolor; x4=im->edgevis; + im->edgetype=CDEDGETYPE; im->edgewidth=CDEDGEWIDTH; + im->edgecolor=CDEDGECOLOR; im->edgevis=CDEDGEVIS; + if (!cdSetShapeEdgeAttrib(im, x1, x2, x3, x4)) return 0; + + x1=im->textfont; x2=im->textcolor; x3=im->textheight; + im->textfont=CDTEXTFONT; im->textcolor=CDTEXTCOLOR; + im->textheight=CDTEXTHEIGHT; + if(!cdSetTextAttrib(im, x1, x2, x3)) return 0; + + x1=im->textpath; im->textpath = CDTEXTPATH; + if (!cdSetTextPath(im, x1)) return 0; + + x1=im->mtype; x2=im->msize; x3=im->mcolor; + im->ltype=CDMTYPE; im->lwidth=CDMSIZE; im->lcolor=CDMCOLOR; + if(!cdSetMarkerAttrib(im, x1, x2, x3)) return 0; + } + else { + /* reset all the defaults */ + cdImageSetDefaults(im); + /* Nuke the color table if there is one */ + cdImageColorClear(im); + im->state = 1; /* now we are officially in the picture */ + } + return 1; +} + +int cdCgmNewPic(cdImagePtr im, int sticky) +/* The CGM standard allows multiple images in a single file. This function + * will close the current picture, then open a new one. + * if sticky is 0 then all attributes will be reset to the defaults + * if sticky is 1 then all attributes will be inherited from the prevous + * picture. + * if sticky is 2 all attributes except the color table will be inherited + * from the previous picture + */ +{ + /* close the current picture */ + if (!cdImageEndPic(im)) return 0; + + /* now start the new picture */ + return(cdCgmPic(im, sticky)); +} + +int cdImageCgm(cdImagePtr im, FILE *out) +/* Gej: Write the image to file *out, which must be open already + * does not close the file */ +{ +/* + if (out) { + im->outfile = out; + } +*/ + cdImageSetOutput(im, out); + return cdImageEndCgm(im); +} + + +int cdSetLineType(cdImagePtr im, int lntype) { +/* Attribute: Line Type; Elem Class 5; Elem ID 2 + * Set the line type. Possible values are: + * 1=solid, 2=dash, 3=dot, 4=dash-dot, 5=dash-dot-dot + * Even though new ones can be defined, I am limiting lntype to these values + * If you really need more, you can make the proper changes. + */ + unsigned char *es, *esp; + int octet_count; + + /* First check and see if the user doesn't want any changes, + * if so, just return success */ + if (lntype == -1) + return 1; + + /* Check and see if the value it is being set to is the current + * value, if so, don't make any changes, just return 1 */ + if (lntype == im->ltype) + return 1; + + /* Make sure that lntype is between 1 and 5 */ + if ((lntype < 1) || (lntype > 5)) + return 0; + + /* allocate sufficent space. should be 32 bits * 4 to be safe */ + es = (unsigned char *) calloc(4*4, SIZEOF(unsigned char ) ); + if (!es) return 0; /* memory allocation failed */ + esp=es; + + if (!cdcomhead(es, 5, 2, 2)) {free(esp); return 0;} + es += 2; + /* set Param_List_Len to 2 (signed int at index precision) */ + + /* add in the value of lntype */ + es += cdAppShort(es, (short int) lntype); + + octet_count = 4; /* we just know this */ + + /* add it to the buffer */ + if (cdAddElem(im, esp, octet_count)) { + im->ltype = (short int) lntype; + free(esp); + return 1; + } + else { + free(esp); + return 0; + } +} + +int cdSetLineWidth(cdImagePtr im, int lnwidth) { +/* Attribute: Line Width; Elem Class 5; Elem ID 3 + * sets the line width. with an image of height X with line width 1 + * the displayed width will be 1/X%. as an example, if you image is + * x=5, y=10, and you set line width = 1, and draw a vertical line, the + * resulting line will cover 20% of horizontal area. + */ + unsigned char *es, *esp; + int octet_count; + + /* First check and see if the user doesn't want any changes, + * if so, just return success */ + if (lnwidth == -1) + return 1; + + /* Check and see if the value it is being set to is the current + * value, if so, don't make any changes, just return 1 */ + if (lnwidth == im->lwidth) + return 1; + + /* allocate sufficent space. should be 32 bits * 4 to be safe */ + es = (unsigned char *) calloc(4*4, SIZEOF(unsigned char ) ); + if (!es) return 0; /* memory allocation failed */ + esp=es; + + + /*gej: line width is 32 bit floating point number, 16 bits before the + * decimal, 16 bits after if Line Spec is default (1, scaled) + * if Line Spec is 0 (0, absolute) then it is 16 bit SI */ + if (im->linespec) { + if (!cdcomhead(es, 5, 3, 4)) {free(esp);return 0;} + es += 2; + octet_count = 2; + es += cdAppShort(es, (short int) lnwidth); + octet_count += 2; + /* the next two (after decimal point) will always be zero */ + es += cdAppNull(es, 2); + octet_count += 2; + } + else { + if (!cdcomhead(es, 5, 3, 2)) {free(esp);return 0;} + octet_count = 2; + es += 2; + es += cdAppShort(es, (short int) lnwidth); + octet_count += 2; + } + + + /* add it to the buffer */ + if (cdAddElem(im, esp, octet_count)) { + im->lwidth = lnwidth; + free(esp); + return 1; + } + else { + free(esp); + return 0; + } +} + +int cdSetLineColor(cdImagePtr im, int lncolor) { +/* Attribute: Line Colour; Elem Class 5; Elem ID 4 + * Sets the line color. lncolor should be an index into the color + * table that you have previously allocated. + */ + unsigned char *es, *esp; + int octet_count; + /* First check and see if the user doesn't want any changes, + * if so, just return success */ + if (lncolor == -1) + return 1; + + /* Check and see if the value it is being set to is the current + * value, if so, don't make any changes, just return 1 */ + if (lncolor == im->lcolor) + return 1; + + /* Make sure the color they want to use has been allocated. + * also, that color must be non-negative */ + if ((lncolor >= im->colorsTotal ) || (lncolor < 0)) + return 0; /* you must allocate a color before you use it */ + + /* allocate sufficent space. should be 32 bits * 4 to be safe */ + es = (unsigned char *) calloc(4*4, SIZEOF(unsigned char ) ); + if (!es) return 0; /* memory allocation failed */ + esp=es; + + + if (!cdcomhead(es, 5, 4, 1)) {free (esp);return 0;} + es += 2; + + *es = 0377 & lncolor; /* mask off last 8 bits and put in es */ + es++; + + es += cdAppNull(es, 1); + + octet_count = 4; /* we just know this; 2 octets of header, + * 1 octet of data, 1 octet of null data */ + + /* add it to the buffer */ + if (cdAddElem(im, esp, octet_count)) { + im->lcolor = (short int) lncolor; + free(esp); + return 1; + } + else { + free(esp); + return 0; + } +} + +int cdSetFillStyle(cdImagePtr im, int instyle) { +/* set the style of the interior of filled area elements. + * Attribute: Interior Style; Elem Class 5; Elem ID 22 + * These attributes stay in effect until changed, so you don't have to output + * them every time. + * Interior Style: (integers 0-6, corresponding to: hollow, solid, + * [not pattern], hatch, empty, [not geometric pattern], + * interpolated.) + * attribute is 16 bit signed int + */ + unsigned char *es, *esp; + int octet_count; + + /* First check and see if the user doesn't want any changes, + * if so, just return success */ + if (instyle == -1) + return 1; + + /* Check and see if the value it is being set to is the current + * value, if so, don't make any changes, just return 1 */ + if (instyle == im->shapestyle) + return 1; + + /* Make sure that lnhatch is between 0 and 6, but not + * 2, 5, or 6 */ + if ((instyle < 0) || (instyle > 4) || (instyle == 2)) + return 0; + + /* allocate sufficent space. should be 32 bits * 4 to be safe */ + es = (unsigned char *) calloc(4*4, SIZEOF(unsigned char ) ); + if (!es) return 0; /* memory allocation failed */ + esp=es; + + /* set the header to Class 5, ID 22, Length 2 */ + if (!cdcomhead(es, 5, 22, 2)) {free (esp);return 0;} + es += 2; + + /* add in the value of inhatch */ + es += cdAppShort(es, (short int) instyle); + + octet_count = 4; /* we just know this */ + + /* add it to the buffer */ + if (cdAddElem(im, esp, octet_count)) { + im->shapestyle = (short int) instyle; + free(esp); + return 1; + } + else { + free(esp); + return 0; + } +} + +int cdSetFillColor(cdImagePtr im, int incolor) { +/* set the color of the interior of filled area elements + * Attribute: Fill Colour; Elem Class 5; Elem ID 23 + * These attributes stay in effect until changed, so you don't have to output + * them every time. + * Fill Colour: (index into the color table) + */ + unsigned char *es, *esp; + int octet_count; + /* First check and see if the user doesn't want any changes, + * if so, just return success */ + if (incolor == -1) + return 1; + + /* Check and see if the value it is being set to is the current + * value, if so, don't make any changes, just return 1 */ + if (incolor == im->shapecolor) + return 1; + + /* Make sure the color they want to use has been allocated. + * also, that color must be non-negative */ + if ((incolor >= im->colorsTotal ) || (incolor < 0)) + return 0; /* you must allocate a color before you use it */ + + /* allocate sufficent space. should be 32 bits * 4 to be safe */ + es = (unsigned char *) calloc(4*4, SIZEOF(unsigned char ) ); + if (!es) return 0; /* memory allocation failed */ + esp=es; + + if (!cdcomhead(es, 5, 23, 1)) {free(esp);return 0;} + es += 2; + + *es = 0377 & incolor; /* mask off last 8 bits and put in es */ + es++; + es += cdAppNull(es, 1); + + octet_count = 4; /* we just know this; 2 octets of header, + * 1 octet of data, 1 octet of null data */ + + /* add it to the buffer */ + if (cdAddElem(im, esp, octet_count)) { + im->shapecolor = (short int) incolor; + free(esp); + return 1; + } + else { + free(esp); + return 0; + } +} + +int cdSetFillHatch(cdImagePtr im, int inhatch) { +/* Set the hatch pattern for the interior of filled-area elements + * the fill style must be set to hatch for this to have an effect. + * Attribute: Hatch Index; Elem Class 5; Elem ID 24 + * These attributes stay in effect until changed, so you don't have to output + * them every time. + * Hatch Index: (integers 1-6, corresponding to: horizontal lines, + * vertical lines, pos. slope parallel lines, + * neg. slope parallel lines, horizontal/vertical + * crosshatch, positive/negative slope crosshatch) + */ + + unsigned char *es, *esp; + int octet_count, temp; + + + /* First check and see if the user doesn't want any changes, + * if so, just return success */ + if (inhatch == -1) + return 1; + + /* Check and see if the value it is being set to is the current + * value, if so, don't make any changes, just return 1 */ + if (inhatch == im->shapehatch) + return 1; + + /* Make sure that lnhatch is between 1 and 6 */ + if ((inhatch < 1) || (inhatch > 6)) + return 0; + + /* allocate sufficent space. should be 32 bits * 4 to be safe */ + es = (unsigned char *) calloc(4*4, SIZEOF(unsigned char ) ); + if (!es) return 0; /* memory allocation failed */ + esp=es; + + /* set the command header to class 5, id 24, length 2 */ + if (!cdcomhead (es, 5, 24, 2)) {free(esp);return 0;} + es += 2; + + /* add in the value of inhatch */ + temp = inhatch >> 8; + *es = *es | (temp & 0377); + es++; + *es = *es | (inhatch & 0377); + es++; + + octet_count = 4; /* we just know this */ + + /* add it to the buffer */ + if (cdAddElem(im, esp, octet_count)) { + im->shapehatch = (short int) inhatch; + free(esp); + return 1; + } + else { + free(esp); + return 0; + } +} + +int cdSetEdgeType(cdImagePtr im, int edtype) { +/* set the type of the edge of filled-area elements. + * Attribute: Edge Type; Elem Class 5; Elem ID 27 + * These attributes stay in effect until changed, so you don't have to output + * them every time. + * Edge Type (integers 1-5, corresponding to: solid, dash, dot, + * dash-dot, dash-dot-dot. These are the same as those used + * for line type.) + * In Part 3 of the standard (Binary Encoding) on page 47 it says that + * edge type is integer. This is incorrect. Edge type is Index, just + * like line type. + * Even though new ones can be defined, I am limiting lntype to these values + * If you really need more, you can make the proper changes. + */ + unsigned char *es, *esp; + int octet_count; + + /* First check and see if the user doesn't want any changes, + * if so, just return success */ + if (edtype == -1) + return 1; + + /* Check and see if the value it is being set to is the current + * value, if so, don't make any changes, just return 1 */ + if (edtype == im->edgetype) + return 1; + + /* Make sure that lntype is between 1 and 5 */ + if ((edtype < 1) || (edtype > 5)) + return 0; + + /* allocate sufficent space. should be 32 bits * 4 to be safe */ + es = (unsigned char *) calloc(4*4, SIZEOF(unsigned char ) ); + if (!es) return 0; /* memory allocation failed */ + esp=es; + + if(!cdcomhead(es, 5, 27, 2)) {free(esp);return 0;} + es += 2; + + /* add in the value of edtype */ + es += cdAppShort(es, (short int) edtype); + + octet_count = 4; /* we just know this */ + + /* add it to the buffer */ + if (cdAddElem(im, esp, octet_count)) { + im->edgetype = (short int) edtype; + free(esp); + return 1; + } + else { + free(esp); + return 0; + } +} + +int cdSetEdgeWidth(cdImagePtr im, int edwidth) { +/* Set the width of the edge of filled-area elements. + * Attribute: Edge Width; Elem Class 5; Elem ID 28 + * These attributes stay in effect until changed, so you don't have to output + * them every time. + * Edge Width (should be the same as line width) + */ + unsigned char *es, *esp; + int octet_count; + + /* First check and see if the user doesn't want any changes, + * if so, just return success */ + if (edwidth == -1) + return 1; + + /* Check and see if the value it is being set to is the current + * value, if so, don't make any changes, just return 1 */ + if (edwidth == im->edgewidth) + return 1; + + /* allocate sufficent space. should be 32 bits * 4 to be safe */ + es = (unsigned char *) calloc(4*4, SIZEOF(unsigned char ) ); + if (!es) return 0; /* memory allocation failed */ + esp=es; + + /*gej: edge width is 32 bit floating point number, 16 bits before the + * decimal, 16 bits after for default edge spec (1, scaled) if + * edge spec is absolute (0) then just 16 bit SI */ + if (im->edgespec) { + if (!cdcomhead(es, 5, 28, 4)) {free(esp);return 0;} + es += 2; + octet_count = 2; + es+= cdAppShort(es, edwidth); + octet_count+=2; + /* the next two (after decimal point) will always be zero */ + es += cdAppNull(es, 2); + octet_count += 2; + } + else { + if (!cdcomhead(es, 5, 28, 2)) {free(esp);return 0;} + es += 2; + octet_count = 2; + es+= cdAppShort(es, edwidth); + octet_count+=2; + } + + /* add it to the buffer */ + if (cdAddElem(im, esp, octet_count)) { + im->edgewidth = edwidth; + free(esp); + return 1; + } + else { + free(esp); + return 0; + } +} + +int cdSetEdgeColor(cdImagePtr im, int edcolor) { +/* Set the color of the edge of filled-area elements. + * Attribute: Edge Color; Elem Class 5; Elem ID 29 + * These attributes stay in effect until changed, so you don't have to output + * them every time. + * Edge Colour (index into the color table) + */ + unsigned char *es, *esp; + int octet_count; + /* First check and see if the user doesn't want any changes, + * if so, just return success */ + if (edcolor == -1) + return 1; + + /* Check and see if the value it is being set to is the current + * value, if so, don't make any changes, just return 1 */ + if (edcolor == im->edgecolor) + return 1; + + /* Make sure the color they want to use has been allocated. + * also, that color must be non-negative */ + if ((edcolor >= im->colorsTotal ) || (edcolor < 0)) + return 0; /* you must allocate a color before you use it */ + + /* allocate sufficent space. should be 32 bits * 4 to be safe */ + es = (unsigned char *) calloc(4*4, SIZEOF(unsigned char ) ); + if (!es) return 0; /* memory allocation failed */ + esp=es; + if (!cdcomhead(es, 5, 29, 1)) {free(esp);return 0;} + es += 2; + + *es = 0377 & edcolor; /* mask off last 8 bits and put in es */ + es++; + es += cdAppNull(es, 1); + + octet_count = 4; /* we just know this; 2 octets of header, + * 1 octet of data, 1 octet of null data */ + + /* add it to the buffer */ + if (cdAddElem(im, esp, octet_count)) { + im->edgecolor = (short int) edcolor; + free(esp); + return 1; + } + else { + free(esp); + return 0; + } +} + +int cdSetEdgeVis(cdImagePtr im, int edvis) { +/* Set the visibility of the edge of filled-area elements. + * Attribute: Edge Visibility; Elem Class 5; Elem ID 30 + * These attributes stay in effect until changed, so you don't have to output + * them every time. + * Edge Visibility (integer 0 or 1, corresponding to: Off, On) + * Attribute is 16 bit signed int. + */ + unsigned char *es, *esp; + int octet_count, temp; + + /* First check and see if the user doesn't want any changes, + * if so, just return success */ + if (edvis == -1) + return 1; + + /* Check and see if the value it is being set to is the current + * value, if so, don't make any changes, just return 1 */ + if (edvis == im->edgevis) + return 1; + + /* allocate sufficent space. should be 32 bits * 4 to be safe */ + es = (unsigned char *) calloc(4*4, SIZEOF(unsigned char ) ); + if (!es) return 0; /* memory allocation failed */ + esp=es; + + if (!cdcomhead(es, 5, 30, 2)) {free(esp);return 0;} + es +=2; octet_count = 2; + temp = edvis >> 8; + *es = *es | (temp & 0377); + es++; + *es = *es | (edvis & 0377); + es++; + octet_count += 2; + + + /* add it to the buffer */ + if (cdAddElem(im, esp, octet_count)) { + im->edgevis = (short int) edvis; + free(esp); + return 1; + } + else { + free(esp); + return 0; + } +} + +int cdSetTextFont(cdImagePtr im, int font) { +/* Attribute: Text Font Index; Elem Class 5; Elem ID 10 + * font is an index into the font table. it can have one of the following + * values: + * 1 Times Roman + * 2 Times Bold + * 3 Times Italic + * 4 Times Bold Italic + * 5 Helvetica + * 6 Helvetica Bold + * 7 Helvetica Italic + * 8 Helvetica Bold Italic + * 9 Courier + * 10 Courier Bold + * 11 Courier Italic + * 12 Courier Bold Italic + */ + unsigned char *es, *esp; + int octet_count; + + /* First check and see if the user doesn't want any changes, + * if so, just return success */ + if (font == -1) + return 1; + + /* Check and see if the value it is being set to is the current + * value, if so, don't make any changes, just return 1 */ + if (font == im->textfont) + return 1; + + /* Make sure that font is between 1 and the number of fonts */ + if ((font < 1) || (font > im->numfonts)) + return 0; + + /* allocate sufficent space. should be 32 bits * 4 to be safe */ + es = (unsigned char *) calloc(4*4, SIZEOF(unsigned char ) ); + if (!es) return 0; /* memory allocation failed */ + esp=es; + + if(!cdcomhead(es, 5, 10, 2)) {free(esp);return 0;} + es += 2; + + es += cdAppShort(es, (short int) font); + + octet_count = 4; /* we just know this */ + + /* add it to the buffer */ + if (cdAddElem(im, esp, octet_count)) { + im->textfont = (short int) font; + free(esp); + return 1; + } + else { + free(esp); + return 0; + } +} + +int cdSetTextColor(cdImagePtr im, int color) { +/* Attribute: Text Colour ; Elem Class 5; Elem ID 14 + * set the forground color of text + */ + unsigned char *es, *esp; + int octet_count; + /* First check and see if the user doesn't want any changes, + * if so, just return success */ + if (color == -1) + return 1; + + /* Check and see if the value it is being set to is the current + * value, if so, don't make any changes, just return 1 */ + if (color == im->textcolor) + return 1; + + /* Make sure the color they want to use has been allocated. + * also, that color must be non-negative */ + if ((color >= im->colorsTotal ) || (color < 0)) + return 0; /* you must allocate a color before you use it */ + + /* allocate sufficent space. should be 32 bits * 4 to be safe */ + es = (unsigned char *) calloc(4*4, SIZEOF(unsigned char ) ); + if (!es) return 0; /* memory allocation failed */ + esp=es; + + if(!cdcomhead(es, 5, 14, 1)) {free(esp);return 0;} + es += 2; + + *es = 0377 & color; /* mask off last 8 bits and put in es */ + es++; + + octet_count = 4; /* we just know this; 2 octets of header, + * 1 octet of data, 1 octet of null data */ + + /* add it to the buffer */ + if (cdAddElem(im, esp, octet_count)) { + im->textcolor = (short int) color; + free(esp); + return 1; + } + else { + free(esp); + return 0; + } +} + +int cdSetTextHeight(cdImagePtr im, int height) { +/* Attribute: Character Height; Elem Class 5; Elem ID 15 + * the height is in the same units as line width + */ + unsigned char *es, *esp; + int octet_count; + /* First check and see if the user doesn't want any changes, + * if so, just return success */ + if (height == -1) + return 1; + + /* Check and see if the value it is being set to is the current + * value, if so, don't make any changes, just return 1 */ + if (height == im->textheight) + return 1; + + /* allocate sufficent space. should be 32 bits * 4 to be safe */ + es = (unsigned char *) calloc(4*4, SIZEOF(unsigned char ) ); + if (!es) return 0; /* memory allocation failed */ + esp=es; + + if(!cdcomhead(es, 5, 15, 2)) {free(esp);return 0;} + octet_count = 2; es += 2; + + es += cdAppShort(es, height); + octet_count += 2; + + /* add it to the buffer */ + if (cdAddElem(im, esp, octet_count)) { + im->textheight = height; + free(esp); + return 1; + } + else { + free(esp); + return 0; + } +} + +int cdSetTextPath(cdImagePtr im, int tpath) { +/* Attribute: Text Path; Elem Class 5; Elem ID 17 + * Is one of: + * 0 right -- Means the direction of the character base vector + * 1 left -- means 180 degrees from the character base vector + * 2 up -- means the direction of the character up vector + * 3 down -- means 180 degrees from the character up vector + */ + unsigned char *es, *esp; + int octet_count; + + /* First check and see if the user doesn't want any changes, + * if so, just return success */ + if (tpath == -1) + return 1; + + /* Check and see if the value it is being set to is the current + * value, if so, don't make any changes, just return 1 */ + if (tpath == im->textpath) + return 1; + + /* allocate sufficent space. should be 32 bits * 4 to be safe */ + es = (unsigned char *) calloc(4*4, SIZEOF(unsigned char ) ); + if (!es) return 0; /* memory allocation failed */ + esp=es; + octet_count = 0; + + if (!cdcomhead(es, 5, 17, 2)) {free(esp);return 0;} + es +=2; octet_count = 2; + + es += cdAppShort(es, (short int) tpath); + octet_count += 2; + + /* add it to the buffer */ + if (cdAddElem(im, esp, octet_count)) { + im->textpath = (short int) tpath; + free(esp); + return 1; + } + else { + free(esp); + return 0; + } +} + +int cdSetTextOrient(cdImagePtr im, int xup, int yup, int xbase, int ybase) { +/* Attribute: Character Orientation; Elem Class 5; Elem ID 16 + * (xbase,ybase) is the run and the rise of the line that the text is + * written along. For regular text at an angle, set xup = -ybase + * and yup = xbase. Setting it to something different will result in + * skewed text (which may be what you want.) Text written from bottom to + * top at a 90 degree angle would have the following parameters + * xup=-1, yup=0, xbase=0, ybase=1 + * + * This function adds the Orientation to the metafile every time. + * It does not follow the normal -1 for no change, although if you + * put in the same numbers it won't re-add it to the meta file. + */ + unsigned char *es, *esp; + int octet_count; + + + /* allocate sufficent space. should be 32 bits * 4 to be safe */ + es = (unsigned char *) calloc(4*4, SIZEOF(unsigned char ) ); + if (!es) return 0; /* memory allocation failed */ + esp=es; + octet_count = 0; + + if (!cdcomhead(es, 5, 16, 8)) {free(esp);return 0;} + es +=2; octet_count += 2; + + /* In the metafile it is a 16 bit signed integer */ + /* add xup */ + es += cdAppShort(es, (short int) xup); + octet_count += 2; + /* add the rest */ + es += cdAppShort(es, (short int) yup); + octet_count += 2; + es += cdAppShort(es, (short int) xbase); + octet_count += 2; + es += cdAppShort(es, (short int) ybase); + octet_count += 2; + + /* add it to the buffer */ + if (cdAddElem(im, esp, octet_count)) { + free(esp); + return 1; + } + else { + free(esp); + return 0; + } +} + +int cdSetMarkerType(cdImagePtr im, int mtype) { +/* Attribute: Marker Type; Elem Class 5; Elem ID 6 + * Set the Marker type. Possible values are: + * 1=dot, 2=plus, 3=asterisk, 4=circle, 5=cross + * Even though new ones can be defined, I am limiting lntype to these values + * If you really need more, you can make the proper changes. + */ + unsigned char *es, *esp; + int octet_count; + + /* First check and see if the user doesn't want any changes, + * if so, just return success */ + if (mtype == -1) + return 1; + + /* Check and see if the value it is being set to is the current + * value, if so, don't make any changes, just return 1 */ + if (mtype == im->mtype) + return 1; + + /* Make sure that mtype is between 1 and 5 */ + if ((mtype < 1) || (mtype > 5)) + return 0; + + /* allocate sufficent space. should be 32 bits * 4 to be safe */ + es = (unsigned char *) calloc(4*4, SIZEOF(unsigned char ) ); + if (!es) return 0; /* memory allocation failed */ + esp=es; + + if (!cdcomhead(es, 5, 6, 2)) {free(esp); return 0;} + es += 2; + /* set Param_List_Len to 2 (signed int at index precision) */ + + /* add in the value of mtype */ + es += cdAppShort(es, (short int) mtype); + + octet_count = 4; /* we just know this */ + + /* add it to the buffer */ + if (cdAddElem(im, esp, octet_count)) { + im->mtype = (short int) mtype; + free(esp); + return 1; + } + else { + free(esp); + return 0; + } +} + +int cdSetMarkerSize(cdImagePtr im, int msize) { +/* Attribute: Marker Size; Elem Class 5; Elem ID 7 + * sets the marker size. with an image of height X with marker size 1 + * the displayed size will be 1/X%. as an example, if you image is + * x=5, y=10, and you set marker size = 1, and draw a marker, the + * resulting marker will cover 20% of horizontal area. + */ + unsigned char *es, *esp; + int octet_count; + + /* First check and see if the user doesn't want any changes, + * if so, just return success */ + if (msize == -1) + return 1; + + /* Check and see if the value it is being set to is the current + * value, if so, don't make any changes, just return 1 */ + if (msize == im->msize) + return 1; + + /* allocate sufficent space. should be 32 bits * 4 to be safe */ + es = (unsigned char *) calloc(4*4, SIZEOF(unsigned char ) ); + if (!es) return 0; /* memory allocation failed */ + esp=es; + + + /*gej: marker size is 32 bit floating point number, 16 bits before the + * decimal, 16 bits after if marker spec is default (1, scaled) + * for absolute mode (0, absolute) it is 16 bit SI */ + if (im->markerspec) { + if (!cdcomhead(es, 5, 7, 4)) {free(esp);return 0;} + octet_count = 2; + es += 2; + es += cdAppShort(es, (short int) msize); + octet_count += 2; + /* the next two (after decimal point) will always be zero */ + es += cdAppNull(es, 2); + octet_count += 2; + } + else { + if (!cdcomhead(es, 5, 7, 4)) {free(esp);return 0;} + octet_count = 2; + es += 2; + es += cdAppShort(es, (short int) msize); + octet_count += 2; + } + + + /* add it to the buffer */ + if (cdAddElem(im, esp, octet_count)) { + im->msize = msize; + free(esp); + return 1; + } + else { + free(esp); + return 0; + } +} + +int cdSetMarkerColor(cdImagePtr im, int mcolor) { +/* Attribute: Marker Colour; Elem Class 5; Elem ID 8 + * Sets the marker color. mcolor should be an index into the color + * table that you have previously allocated. + */ + unsigned char *es, *esp; + int octet_count; + /* First check and see if the user doesn't want any changes, + * if so, just return success */ + if (mcolor == -1) + return 1; + + /* Check and see if the value it is being set to is the current + * value, if so, don't make any changes, just return 1 */ + if (mcolor == im->mcolor) + return 1; + + /* Make sure the color they want to use has been allocated. + * also, that color must be non-negative */ + if ((mcolor >= im->colorsTotal ) || (mcolor < 0)) + return 0; /* you must allocate a color before you use it */ + + /* allocate sufficent space. should be 32 bits * 4 to be safe */ + es = (unsigned char *) calloc(4*4, SIZEOF(unsigned char ) ); + if (!es) return 0; /* memory allocation failed */ + esp=es; + + + if (!cdcomhead(es, 5, 8, 1)) {free (esp);return 0;} + es += 2; + + *es = 0377 & mcolor; /* mask off last 8 bits and put in es */ + es++; + + es += cdAppNull(es, 1); + + octet_count = 4; /* we just know this; 2 octets of header, + * 1 octet of data, 1 octet of null data */ + + /* add it to the buffer */ + if (cdAddElem(im, esp, octet_count)) { + im->mcolor = (short int) mcolor; + free(esp); + return 1; + } + else { + free(esp); + return 0; + } +} + +int cdSetLineAttrib(cdImagePtr im, int lntype, int lnwidth, int lncolor) { +/* Spits out the attributes of lines. These attributes stay in effect + * until changed, so you don't have to output them every time. + */ + + if (!cdSetLineType(im, lntype)) return 0; + if (!cdSetLineWidth(im, lnwidth)) return 0; + if (!cdSetLineColor(im, lncolor)) return 0; + + return 1; +} + +int cdSetShapeFillAttrib(cdImagePtr im, int instyle, int incolor, int inhatch) { +/* Spits out the attributes for the interior of filled-area elements. + * These attributes stay in effect until changed, so you don't have to output + * them every time. + * Set the following attributes: + * Interior Style: (integers 0-6, corresponding to: hollow, solid, + * [not pattern], hatch, empty, [not geometric pattern], + * interpolated.) + * Fill Colour: (index into the color table) + * Hatch Index: (integers 1-6, corresponding to: horizontal lines, + * vertical lines, pos. slope parallel lines, + * neg. slope parallel lines, horizontal/vertical + * crosshatch, positive/negative slope crosshatch) + */ + if (!cdSetFillStyle(im, instyle)) return 0; + if (!cdSetFillColor(im, incolor)) return 0; + if (!cdSetFillHatch(im, inhatch)) return 0; + + return 1; +} + +int cdSetShapeEdgeAttrib(cdImagePtr im, int edtype, int edwidth, int edcolor, int edvis) { +/* Spits out the attributes for the edges of filled-area elements. It may + * seem logical that these would be the same as the corresponding line + * attributes, but this is not the case. + * These attributes stay in effect until changed, so you don't have to output + * them every time. + * Set the following attributes: + * Edge Type (integers 1-5, corresponding to: solid, dash, dot, + * dash-dot, dash-dot-dot. These are the same as those used + * for line type.) + * Edge Width (should be the same as line width) + * Edge Colour (index into the color table) + * Edge Visibility (integer 0 or 1, corresponding to: Off, On) + */ + if (!cdSetEdgeType(im, edtype)) return 0; + if (!cdSetEdgeWidth(im, edwidth)) return 0; + if (!cdSetEdgeColor(im, edcolor)) return 0; + if (!cdSetEdgeVis(im, edvis)) return 0; + + return 1; +} + +int cdSetTextAttrib(cdImagePtr im, int font, int color, int height) { +/* Set the attributes of text. the font is an integer pointer into the + * font list where: + * 1 Times + * 2 Times Bold + * 3 Times Italic + * 4 Times Bold Italic + * 5 Helvetica + * 6 Helvetica Bold + * 7 Helvetica Italic + * 8 Helvetica Bold Italic + * 9 Courier + * 10 Courier Bold + * 11 Courier Italic + * 12 Courier Bold Italic + * color is an index into the colortable which is the color of the text + * size is the approximate size you want the text written in. + */ + + if(!cdSetTextFont(im, font)) return 0; + if(!cdSetTextColor(im, color)) return 0; + if(!cdSetTextHeight(im, height)) return 0; + + return 1; +} + +int cdSetMarkerAttrib(cdImagePtr im, int mtype, int msize, int mcolor) { +/* Spits out the attributes of Markers. These attributes stay in effect + * until changed, so you don't have to output them every time. + */ + + if (!cdSetMarkerType(im, mtype)) return 0; + if (!cdSetMarkerSize(im, msize)) return 0; + if (!cdSetMarkerColor(im, mcolor)) return 0; + + return 1; +} + +int cdImageDestroy(cdImagePtr im) +/* gej: should work, unless I make changes to cdImage Struct */ +{ + if (im->elemlist) { + free(im->elemlist); + } + if (im->desc) { + free(im->desc); + } + if (im->fontlist) { + free(im->fontlist); + } + free(im); + + return 1; +} + +int cdImageColorClosest(cdImagePtr im, int r, int g, int b) +/* From gd library, see README file for copyright information */ +/* gej: should work unchanged */ +/* gej: 5/96, changed the colors to use short int */ +{ + short int i; + long rd, gd, bd; + int ct = (-1); + long mindist = 0; + for (i=0; (i<(im->colorsTotal)); i++) { + long dist; + if (im->open[i]) { + continue; + } + rd = (im->red[i] - r); + gd = (im->green[i] - g); + bd = (im->blue[i] - b); + dist = rd * rd + gd * gd + bd * bd; + if ((i == 0) || (dist < mindist)) { + mindist = dist; + ct = i; + } + } + return ct; +} + +int cdImageColorClear(cdImagePtr im) { +/* mark all entries in the color table as open */ + short int i; + for (i=0; (i<(cdMaxColors)); i++) { + im->open[i] = 1; + } + return 1; +} + +int cdImageColorExact(cdImagePtr im, int r, int g, int b) +/* From gd library, see README file for copyright information */ +/* gej: should work unchanged */ +/* gej: 5/96, changed colors to work with short ints */ +{ + short int i; + for (i=0; (i<(im->colorsTotal)); i++) { + if (im->open[i]) { + continue; + } + if ((im->red[i] == r) && + (im->green[i] == g) && + (im->blue[i] == b)) { + return i; + } + } + return -1; +} + +static int cdImageAddColorIndex(cdImagePtr im, int r, int g, int b) +/* adds the specified color to the colortable in the cdImagePtr. + * does not add it to the cgm file, cdImageAddColor does. + * do not use either of these two functions, use cdImageColorAllocate. + */ +{ + short int i; + short int ct = (-1); + for (i=0; (i<(im->colorsTotal)); i++) { + if (im->open[i]) { + ct = i; + break; + } + } + if (ct == (-1)) { + ct = im->colorsTotal; + if (ct == cdMaxColors) { + return -1; + } + im->colorsTotal++; + } + im->red[ct] = (short int) r; + im->green[ct] = (short int) g; + im->blue[ct] = (short int) b; + im->open[ct] = (short int) 0; + + return ct; +} + +static int cdImageAddColor(cdImagePtr im, int si, int ei) +/* adds colors to the cgm file, gets values from the color table. + * adds all colors from si to ei inclusive. + * Use cdImageColorAllocate, not this one. + */ +{ + unsigned char *cts, *ctsp; /* GEJ: color table attribute */ + int octet_count; /* GEJ: octet count */ + int numco, curly; + octet_count =... [truncated message content] |
From: <ai...@us...> - 2009-03-10 19:58:06
|
Revision: 9704 http://plplot.svn.sourceforge.net/plplot/?rev=9704&view=rev Author: airwin Date: 2009-03-10 19:57:42 +0000 (Tue, 10 Mar 2009) Log Message: ----------- Build -dev cgm correctly when dynamic devices are not enabled. The internally built lib/nistcd is now handled in a similar way to how the other internal libraries in lib. Modified Paths: -------------- trunk/cmake/modules/cgm.cmake trunk/src/CMakeLists.txt Modified: trunk/cmake/modules/cgm.cmake =================================================================== --- trunk/cmake/modules/cgm.cmake 2009-03-10 19:50:01 UTC (rev 9703) +++ trunk/cmake/modules/cgm.cmake 2009-03-10 19:57:42 UTC (rev 9704) @@ -23,14 +23,7 @@ # # cgm_TARGETS - list of targets which the cgm dynamic device # depends on. -# cgm_COMPILE_FLAGS - individual COMPILE_FLAGS required to compile cgm -# device. -# DRIVERS_LINK_FLAGS - list of targets which the cgm static device -# depends on. if(PLD_cgm) set(cgm_TARGETS nistcd) - set(cgm_COMPILE_FLAGS "-I${CMAKE_SOURCE_DIR}/lib/nistcd") - - set(DRIVERS_LINK_FLAGS ${DRIVERS_LINK_FLAGS} nistcd) endif(PLD_cgm) Modified: trunk/src/CMakeLists.txt =================================================================== --- trunk/src/CMakeLists.txt 2009-03-10 19:50:01 UTC (rev 9703) +++ trunk/src/CMakeLists.txt 2009-03-10 19:57:42 UTC (rev 9704) @@ -147,9 +147,6 @@ ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/include ) -if(NOT ENABLE_DYNDRIVERS AND PLD_cgm) - include_directories(${CMAKE_SOURCE_DIR}/lib/nistcd) -endif(NOT ENABLE_DYNDRIVERS AND PLD_cgm) add_library(plplot${LIB_TAG} ${plplot${LIB_TAG}_LIB_SRCS}) add_dependencies(plplot${LIB_TAG} plhershey-unicode.h_built) @@ -206,6 +203,15 @@ ) endif(HAVE_QHULL) +if(NOT ENABLE_DYNDRIVERS AND PLD_cgm) + list(APPEND libplplot${LIB_TAG}_LINK_LIBRARIES nistcd) + set( + libplplot${LIB_TAG}_LINK_FLAGS + "${libplplot${LIB_TAG}_LINK_FLAGS} -lnistcd" + ) + include_directories(${CMAKE_SOURCE_DIR}/lib/nistcd) +endif(NOT ENABLE_DYNDRIVERS AND PLD_cgm) + set( libplplot${LIB_TAG}_LINK_LIBRARIES ${libplplot${LIB_TAG}_LINK_LIBRARIES} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-03-11 02:50:21
|
Revision: 9713 http://plplot.svn.sourceforge.net/plplot/?rev=9713&view=rev Author: airwin Date: 2009-03-11 02:50:16 +0000 (Wed, 11 Mar 2009) Log Message: ----------- Generate *.rc files using template files and cmake logic. Has been tested in a variety of cases including when several devices out of many implemented in a device driver are turned off, and when all the devices in a device driver have been turned off. Modified Paths: -------------- trunk/cmake/modules/drivers-finish.cmake Added Paths: ----------- trunk/drivers/cairo.rc.in trunk/drivers/cgm.rc.in trunk/drivers/dg300.rc.in trunk/drivers/gcw.rc.in trunk/drivers/gd.rc.in trunk/drivers/hpgl.rc.in trunk/drivers/impress.rc.in trunk/drivers/ljii.rc.in trunk/drivers/ljiip.rc.in trunk/drivers/mem.rc.in trunk/drivers/null.rc.in trunk/drivers/pbm.rc.in trunk/drivers/plmeta.rc.in trunk/drivers/ps.rc.in trunk/drivers/pstex.rc.in trunk/drivers/psttf.rc.in trunk/drivers/qt.rc.in trunk/drivers/svg.rc.in trunk/drivers/tek.rc.in trunk/drivers/wxwidgets.rc.in trunk/drivers/xfig.rc.in trunk/drivers/xwin.rc.in Modified: trunk/cmake/modules/drivers-finish.cmake =================================================================== --- trunk/cmake/modules/drivers-finish.cmake 2009-03-11 02:48:05 UTC (rev 9712) +++ trunk/cmake/modules/drivers-finish.cmake 2009-03-11 02:50:16 UTC (rev 9713) @@ -38,6 +38,12 @@ endif(DRIVER STREQUAL "${DRIVER_IN_LIST}") endforeach(DRIVER_IN_LIST ${DRIVERS_LIST}) if(APPEND_DRIVER) + if(ENABLE_DYNDRIVERS) + file(STRINGS + ${CMAKE_SOURCE_DIR}/drivers/${DRIVER}.rc.in + ${DRIVER}_INFO + ) + endif(ENABLE_DYNDRIVERS) set(DRIVERS_LIST ${DRIVERS_LIST} ${DRIVER}) if(DRIVER STREQUAL "wxwidgets") set(${DRIVER}_SOURCE @@ -72,3 +78,38 @@ endif(APPEND_DRIVER) endif(PLD_${DEVICE}) endforeach(DRIVERS_DEVICE) + +foreach(DRIVERS_DEVICE ${DRIVERS_DEVICE_LIST}) + string(REGEX REPLACE "^(.*):.*:.*$" "\\1" DEVICE ${DRIVERS_DEVICE}) + string(REGEX REPLACE "^.*:(.*):.*$" "\\1" DRIVER ${DRIVERS_DEVICE}) + if(${DRIVER}_INFO) + if(NOT PLD_${DEVICE}) + set(DEVICE_INFO_MATCHED) + # Must remove corresponding data from ${DRIVER}_INFO + #message("DEVICE = ${DEVICE}") + foreach(DEVICE_INFO ${${DRIVER}_INFO}) + string(REGEX REPLACE "^(.*):.*:.*:.*:.*:.*$" "\\1" DEVICE_INFO_NAME ${DEVICE_INFO}) + #message("DEVICE_INFO_NAME = ${DEVICE_INFO_NAME}") + if(DEVICE STREQUAL "${DEVICE_INFO_NAME}") + #There should one and only one match. + set(DEVICE_INFO_MATCHED ${DEVICE_INFO}) + endif(DEVICE STREQUAL "${DEVICE_INFO_NAME}") + endforeach(DEVICE_INFO ${${DRIVER}_INFO}) + if(DEVICE_INFO_MATCHED) + list(REMOVE_ITEM ${DRIVER}_INFO ${DEVICE_INFO_MATCHED}) + else(DEVICE_INFO_MATCHED) + message(FATAL_ERROR "${CMAKE_SOURCE_DIR}/drivers/${DRIVER}.rc.in not consistent with ${CMAKE_SOURCE_DIR}/cmake/modules/drivers-init.cmake") + endif(DEVICE_INFO_MATCHED) + endif(NOT PLD_${DEVICE}) + endif(${DRIVER}_INFO) +endforeach(DRIVERS_DEVICE) + +foreach(DRIVERS_DEVICE ${DRIVERS_DEVICE_LIST}) + string(REGEX REPLACE "^.*:(.*):.*$" "\\1" DRIVER ${DRIVERS_DEVICE}) + if(${DRIVER}_INFO) + file(WRITE ${CMAKE_BINARY_DIR}/drivers/${DRIVER}.rc "") + foreach(DEVICE_INFO ${${DRIVER}_INFO}) + file(APPEND ${CMAKE_BINARY_DIR}/drivers/${DRIVER}.rc "${DEVICE_INFO}\n") + endforeach(DEVICE_INFO ${${DRIVER}_INFO}) + endif(${DRIVER}_INFO) +endforeach(DRIVERS_DEVICE ${DRIVERS_DEVICE_LIST}) Added: trunk/drivers/cairo.rc.in =================================================================== --- trunk/drivers/cairo.rc.in (rev 0) +++ trunk/drivers/cairo.rc.in 2009-03-11 02:50:16 UTC (rev 9713) @@ -0,0 +1,7 @@ +xcairo:Cairo X Windows Driver:1:cairo:59:xcairo +pdfcairo:Cairo PDF Driver:0:cairo:60:pdfcairo +pscairo:Cairo PS Driver:0:cairo:61:pscairo +svgcairo:Cairo SVG Driver:0:cairo:62:svgcairo +pngcairo:Cairo PNG Driver:0:cairo:63:pngcairo +memcairo:Cairo Memory Driver:0:cairo:64:memcairo +extcairo:Cairo External Context Driver:0:cairo:65:extcairo Property changes on: trunk/drivers/cairo.rc.in ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/drivers/cgm.rc.in =================================================================== --- trunk/drivers/cgm.rc.in (rev 0) +++ trunk/drivers/cgm.rc.in 2009-03-11 02:50:16 UTC (rev 9713) @@ -0,0 +1 @@ +cgm:CGM file:0:cgm:44:cgm Property changes on: trunk/drivers/cgm.rc.in ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/drivers/dg300.rc.in =================================================================== --- trunk/drivers/dg300.rc.in (rev 0) +++ trunk/drivers/dg300.rc.in 2009-03-11 02:50:16 UTC (rev 9713) @@ -0,0 +1 @@ +dg300:DG300 Terminal:0:dg300:25:dg300 Property changes on: trunk/drivers/dg300.rc.in ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/drivers/gcw.rc.in =================================================================== --- trunk/drivers/gcw.rc.in (rev 0) +++ trunk/drivers/gcw.rc.in 2009-03-11 02:50:16 UTC (rev 9713) @@ -0,0 +1 @@ +gcw:Gnome Canvas Widget:1:gcw:10:gcw Property changes on: trunk/drivers/gcw.rc.in ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/drivers/gd.rc.in =================================================================== --- trunk/drivers/gd.rc.in (rev 0) +++ trunk/drivers/gd.rc.in 2009-03-11 02:50:16 UTC (rev 9713) @@ -0,0 +1,3 @@ +png:PNG file:0:gd:39:png +jpeg:JPEG file:0:gd:40:jpeg +gif:GIF file:0:gd:47:gif Property changes on: trunk/drivers/gd.rc.in ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/drivers/hpgl.rc.in =================================================================== --- trunk/drivers/hpgl.rc.in (rev 0) +++ trunk/drivers/hpgl.rc.in 2009-03-11 02:50:16 UTC (rev 9713) @@ -0,0 +1,3 @@ +hp7470:HP 7470 Plotter File (HPGL Cartridge, Small Plotter):0:hpgl:34:hp7470 +hp7580:HP 7580 Plotter File (Large Plotter):0:hpgl:35:hp7580 +lj_hpgl:HP Laserjet III, HPGL emulation mode:0:hpgl:36:lj_hpgl Property changes on: trunk/drivers/hpgl.rc.in ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/drivers/impress.rc.in =================================================================== --- trunk/drivers/impress.rc.in (rev 0) +++ trunk/drivers/impress.rc.in 2009-03-11 02:50:16 UTC (rev 9713) @@ -0,0 +1 @@ +imp:Impress File:0:impress:37:imp Property changes on: trunk/drivers/impress.rc.in ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/drivers/ljii.rc.in =================================================================== --- trunk/drivers/ljii.rc.in (rev 0) +++ trunk/drivers/ljii.rc.in 2009-03-11 02:50:16 UTC (rev 9713) @@ -0,0 +1 @@ +ljii:LaserJet II Bitmap File (150 dpi):0:ljii:33:ljii Property changes on: trunk/drivers/ljii.rc.in ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/drivers/ljiip.rc.in =================================================================== --- trunk/drivers/ljiip.rc.in (rev 0) +++ trunk/drivers/ljiip.rc.in 2009-03-11 02:50:16 UTC (rev 9713) @@ -0,0 +1 @@ +ljiip:LaserJet IIp/deskjet compressed graphics:0:ljiip:32:ljiip Property changes on: trunk/drivers/ljiip.rc.in ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/drivers/mem.rc.in =================================================================== --- trunk/drivers/mem.rc.in (rev 0) +++ trunk/drivers/mem.rc.in 2009-03-11 02:50:16 UTC (rev 9713) @@ -0,0 +1 @@ +mem:User-supplied memory device:-1:mem:46:mem Property changes on: trunk/drivers/mem.rc.in ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/drivers/null.rc.in =================================================================== --- trunk/drivers/null.rc.in (rev 0) +++ trunk/drivers/null.rc.in 2009-03-11 02:50:16 UTC (rev 9713) @@ -0,0 +1 @@ +null:Null device:-1:null:42:null Property changes on: trunk/drivers/null.rc.in ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/drivers/pbm.rc.in =================================================================== --- trunk/drivers/pbm.rc.in (rev 0) +++ trunk/drivers/pbm.rc.in 2009-03-11 02:50:16 UTC (rev 9713) @@ -0,0 +1 @@ +pbm:PDB (PPM) Driver:0:pbm:38:pbm Property changes on: trunk/drivers/pbm.rc.in ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/drivers/plmeta.rc.in =================================================================== --- trunk/drivers/plmeta.rc.in (rev 0) +++ trunk/drivers/plmeta.rc.in 2009-03-11 02:50:16 UTC (rev 9713) @@ -0,0 +1 @@ +plmeta:PLplot Native Meta-File:0:plmeta:26:plm Property changes on: trunk/drivers/plmeta.rc.in ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/drivers/ps.rc.in =================================================================== --- trunk/drivers/ps.rc.in (rev 0) +++ trunk/drivers/ps.rc.in 2009-03-11 02:50:16 UTC (rev 9713) @@ -0,0 +1,2 @@ +ps:PostScript File (monochrome):0:ps:29:psm +psc:PostScript File (color):0:ps:30:psc Property changes on: trunk/drivers/ps.rc.in ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/drivers/pstex.rc.in =================================================================== --- trunk/drivers/pstex.rc.in (rev 0) +++ trunk/drivers/pstex.rc.in 2009-03-11 02:50:16 UTC (rev 9713) @@ -0,0 +1 @@ +pstex:Combined Postscript/LaTeX files:0:pstex:41:pstex Property changes on: trunk/drivers/pstex.rc.in ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/drivers/psttf.rc.in =================================================================== --- trunk/drivers/psttf.rc.in (rev 0) +++ trunk/drivers/psttf.rc.in 2009-03-11 02:50:16 UTC (rev 9713) @@ -0,0 +1,2 @@ +psttf:PostScript File (monochrome):0:psttf:55:psttfm +psttfc:PostScript File (color):0:psttf:56:psttfc Property changes on: trunk/drivers/psttf.rc.in ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/drivers/qt.rc.in =================================================================== --- trunk/drivers/qt.rc.in (rev 0) +++ trunk/drivers/qt.rc.in 2009-03-11 02:50:16 UTC (rev 9713) @@ -0,0 +1,9 @@ +bmpqt:Qt Windows bitmap driver:0:qt:66:bmpqt +jpgqt:Qt jpg driver:0:qt:67:jpgqt +pngqt:Qt png driver:0:qt:68:pngqt +ppmqt:Qt ppm driver:0:qt:69:ppmqt +tiffqt:Qt tiff driver:0:qt:70:tiffqt +svgqt:Qt SVG driver:0:qt:71:svgqt +qtwidget:Qt Widget:1:qt:72:qtwidget +epsqt:Qt EPS driver:0:qt:73:epsqt +pdfqt:Qt PDF driver:0:qt:74:pdfqt Property changes on: trunk/drivers/qt.rc.in ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/drivers/svg.rc.in =================================================================== --- trunk/drivers/svg.rc.in (rev 0) +++ trunk/drivers/svg.rc.in 2009-03-11 02:50:16 UTC (rev 9713) @@ -0,0 +1 @@ +svg:Scalable Vector Graphics (SVG 1.1):1:svg:57:svg Property changes on: trunk/drivers/svg.rc.in ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/drivers/tek.rc.in =================================================================== --- trunk/drivers/tek.rc.in (rev 0) +++ trunk/drivers/tek.rc.in 2009-03-11 02:50:16 UTC (rev 9713) @@ -0,0 +1,6 @@ +conex:Conex vt320/tek emulator:1:tek:24:conex +mskermit:MS-Kermit emulator:1:tek:21:mskermit +tek4107f:Tektronix File (4105/4107):0:tek:28:tek4107f +versaterm:Versaterm vt100/tek emulator:1:tek:22:versaterm +vlt:VLT vt100/tek emulator:1:tek:23:vlt +xterm:Xterm Window:1:tek:18:xterm Property changes on: trunk/drivers/tek.rc.in ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/drivers/wxwidgets.rc.in =================================================================== --- trunk/drivers/wxwidgets.rc.in (rev 0) +++ trunk/drivers/wxwidgets.rc.in 2009-03-11 02:50:16 UTC (rev 9713) @@ -0,0 +1,2 @@ +wxwidgets:wxWidgets Driver:1:wxwidgets:51:wxwidgets +wxpng:wxWidgets PNG Driver:0:wxwidgets:52:wxpng Property changes on: trunk/drivers/wxwidgets.rc.in ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/drivers/xfig.rc.in =================================================================== --- trunk/drivers/xfig.rc.in (rev 0) +++ trunk/drivers/xfig.rc.in 2009-03-11 02:50:16 UTC (rev 9713) @@ -0,0 +1 @@ +xfig:Fig file:0:xfig:31:xfig Property changes on: trunk/drivers/xfig.rc.in ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/drivers/xwin.rc.in =================================================================== --- trunk/drivers/xwin.rc.in (rev 0) +++ trunk/drivers/xwin.rc.in 2009-03-11 02:50:16 UTC (rev 9713) @@ -0,0 +1 @@ +xwin:X-Window (Xlib):1:xwin:5:xw Property changes on: trunk/drivers/xwin.rc.in ___________________________________________________________________ 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-03-11 17:53:23
|
Revision: 9723 http://plplot.svn.sourceforge.net/plplot/?rev=9723&view=rev Author: airwin Date: 2009-03-11 17:53:06 +0000 (Wed, 11 Mar 2009) Log Message: ----------- Make both test_dyndrivers and test_nistcd targets run for every build (unless cross building or if the TEST_DYNDRIVERS and/or TEST_NISTCD options are turned OFF). Modified Paths: -------------- trunk/drivers/CMakeLists.txt trunk/lib/nistcd/CMakeLists.txt Modified: trunk/drivers/CMakeLists.txt =================================================================== --- trunk/drivers/CMakeLists.txt 2009-03-11 17:50:27 UTC (rev 9722) +++ trunk/drivers/CMakeLists.txt 2009-03-11 17:53:06 UTC (rev 9723) @@ -194,7 +194,7 @@ ) endforeach(SOURCE_ROOT_NAME ${DRIVERS_LIST}) if(TEST_DYNDRIVERS AND NOT CMAKE_CROSSCOMPILING) - add_custom_target(test_dyndrivers + add_custom_target(test_dyndrivers ALL DEPENDS ${test_dyndrivers_FDEPENDS} ) add_dependencies(test_dyndrivers ${test_dyndrivers_TDEPENDS}) Modified: trunk/lib/nistcd/CMakeLists.txt =================================================================== --- trunk/lib/nistcd/CMakeLists.txt 2009-03-11 17:50:27 UTC (rev 9722) +++ trunk/lib/nistcd/CMakeLists.txt 2009-03-11 17:53:06 UTC (rev 9723) @@ -127,7 +127,7 @@ DEPENDS ${color16_LOC} ) - add_custom_target(test_nistcd + add_custom_target(test_nistcd ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/test_nistcd_dir/cdexp1.cgm ${CMAKE_CURRENT_BINARY_DIR}/test_nistcd_dir/cdmulti.cgm This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hba...@us...> - 2009-04-05 02:38:48
|
Revision: 9790 http://plplot.svn.sourceforge.net/plplot/?rev=9790&view=rev Author: hbabcock Date: 2009-04-05 02:38:45 +0000 (Sun, 05 Apr 2009) Log Message: ----------- Implemented alternate unicode text handling. Instead of the driver parsing the unicode string, the parsing is done by plplot core and the driver just has to handle starting a string, adding a character to a string, dealing with a control character and ending a string. The alternate unicode handling has been implemented for the cairo driver. Modified Paths: -------------- trunk/drivers/cairo.c trunk/include/plplot.h trunk/include/plplotP.h trunk/include/plstrm.h trunk/src/plcore.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2009-04-04 21:23:44 UTC (rev 9789) +++ trunk/drivers/cairo.c 2009-04-05 02:38:45 UTC (rev 9790) @@ -85,7 +85,10 @@ short text_clipping; short text_anti_aliasing; short graphics_anti_aliasing; - PLFLT downscale; + double downscale; + char *pangoMarkupString; + short upDown; + float fontSize; #if defined(PLD_xcairo) short exit_event_loop; Display *XDisplay; @@ -194,6 +197,10 @@ /* String processing */ static void proc_str(PLStream *, EscText *); +static void text_begin_cairo(PLStream *pls, EscText *args); +static void text_char_cairo(PLStream *pls, EscText *args); +static void text_esc_cairo(PLStream *pls, EscText *args); +static void text_end_cairo(PLStream *pls, EscText *args); static char *ucs4_to_pango_markup_format(PLUNICODE *, int, float); static void open_span_tag(char *, PLUNICODE, float, int); static void close_span_tag(char *, int); @@ -341,13 +348,210 @@ case PLESC_FILL: /* filled polygon */ filled_polygon(pls, pls->dev_x, pls->dev_y, pls->dev_npts); break; - case PLESC_HAS_TEXT: /* render rext */ + case PLESC_HAS_TEXT: proc_str(pls, (EscText *) ptr); break; + case PLESC_BEGIN_TEXT: /* get ready to get a handle a string of text */ + text_begin_cairo(pls, (EscText *) ptr); + break; + case PLESC_TEXT_CHAR: /* handle a character of text to display */ + text_char_cairo(pls, (EscText *) ptr); + break; + case PLESC_CONTROL_CHAR: /* handle a control character (super/subscript of fontchange) */ + text_esc_cairo(pls, (EscText *) ptr); + break; + case PLESC_END_TEXT: /* finish a string of text */ + text_end_cairo(pls, (EscText *) ptr); + break; } } /*--------------------------------------------------------------------- + text_begin_cairo() + + Begin text. + ---------------------------------------------------------------------*/ + +void text_begin_cairo(PLStream *pls, EscText *args) +{ + int i; + PLCairo *aStream; + + aStream = (PLCairo *)pls->dev; + aStream->upDown = 0; + aStream->pangoMarkupString = (char *) malloc (sizeof(char) * MAX_MARKUP_LEN); + aStream->fontSize = pls->chrht * DPI/25.4; + for(i = 0; i < MAX_MARKUP_LEN; i++){ + aStream->pangoMarkupString[i] = 0; + } + open_span_tag(aStream->pangoMarkupString, args->n_fci, aStream->fontSize, 0); +} + +/*--------------------------------------------------------------------- + text_char_cairo() + + Add text. + ---------------------------------------------------------------------*/ + +void text_char_cairo(PLStream *pls, EscText *args) +{ + char utf8[5]; + PLCairo *aStream; + + aStream = (PLCairo *)pls->dev; + /* make sure we are not too close to the end of the string */ + if(strlen(aStream->pangoMarkupString) < (MAX_MARKUP_LEN - 50)){ + switch (args->n_char) + { + case 38: + strncat(aStream->pangoMarkupString, "&", MAX_MARKUP_LEN-1-strlen(aStream->pangoMarkupString)); + break; + case 60: + strncat(aStream->pangoMarkupString, "<", MAX_MARKUP_LEN)-1-strlen(aStream->pangoMarkupString); + break; + case 62: + strncat(aStream->pangoMarkupString, ">", MAX_MARKUP_LEN-1-strlen(aStream->pangoMarkupString)); + break; + default: + ucs4_to_utf8(args->n_char,utf8); + strncat(aStream->pangoMarkupString, utf8, MAX_MARKUP_LEN-1-strlen(aStream->pangoMarkupString)); + break; + } + } +} + +/*--------------------------------------------------------------------- + text_esc_cairo() + + A font change, superscript, subscript, etc... + ---------------------------------------------------------------------*/ + +void text_esc_cairo(PLStream *pls, EscText *args) +{ + PLCairo *aStream; + + aStream = (PLCairo *)pls->dev; + switch(args->n_ctrl_char) + { + case PLTEXT_FONTCHANGE: + close_span_tag(aStream->pangoMarkupString, aStream->upDown); + open_span_tag(aStream->pangoMarkupString, args->n_fci, aStream->fontSize, aStream->upDown); + break; + case PLTEXT_SUPERSCRIPT: + if(aStream->upDown < 0){ + strncat(aStream->pangoMarkupString, "</sub>", MAX_MARKUP_LEN-1-strlen(aStream->pangoMarkupString)); + } else { + strncat(aStream->pangoMarkupString, "<sup>", MAX_MARKUP_LEN-1-strlen(aStream->pangoMarkupString)); + } + aStream->upDown++; + break; + case PLTEXT_SUBSCRIPT: + if(aStream->upDown > 0){ + strncat(aStream->pangoMarkupString, "</sup>", MAX_MARKUP_LEN-1-strlen(aStream->pangoMarkupString)); + } else { + strncat(aStream->pangoMarkupString, "<sub>", MAX_MARKUP_LEN-1-strlen(aStream->pangoMarkupString)); + } + aStream->upDown--; + break; + } +} + +/*--------------------------------------------------------------------- + text_end_cairo() + + Draw the text and clean up. + ---------------------------------------------------------------------*/ + +void text_end_cairo(PLStream *pls, EscText *args) +{ + int textXExtent, textYExtent; + char *textWithPangoMarkup; + PLFLT rotation, shear, stride, cos_rot, sin_rot, cos_shear, sin_shear; + cairo_matrix_t *cairoTransformMatrix; + cairo_font_options_t *cairoFontOptions; + PangoContext *context; + PangoLayout *layout; + PangoFontDescription *fontDescription; + PLCairo *aStream; + + aStream = (PLCairo *)pls->dev; + + set_current_context(pls); + + /* Close the last span tag. */ + close_span_tag(aStream->pangoMarkupString, aStream->upDown); + + /* Create the Pango text layout so we can figure out how big it is */ + layout = pango_cairo_create_layout(aStream->cairoContext); + pango_layout_set_markup(layout, aStream->pangoMarkupString, -1); + pango_layout_get_pixel_size(layout, &textXExtent, &textYExtent); + + /* Set font aliasing */ + context = pango_layout_get_context(layout); + cairoFontOptions = cairo_font_options_create(); + cairo_font_options_set_antialias(cairoFontOptions, aStream->text_anti_aliasing); + pango_cairo_context_set_font_options(context, cairoFontOptions); + 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_rectangle(aStream->cairoContext, aStream->downscale * pls->clpxmi, aStream->downscale * pls->clpymi, aStream->downscale * (pls->clpxma - pls->clpxmi), aStream->downscale * (pls->clpyma - pls->clpymi)); + cairo_clip(aStream->cairoContext); + } + + /* Move to the string reference point */ + cairo_move_to(aStream->cairoContext, aStream->downscale * (double) args->x, aStream->downscale * (double) args->y); + + /* Move to the string reference point */ + /* + cairo_move_to(aStream->cairoContext, aStream->refx, aStream->refy); + */ + + /* Invert the coordinate system so that the text is drawn right side up */ + cairoTransformMatrix = (cairo_matrix_t *) malloc (sizeof(cairo_matrix_t)); + cairo_matrix_init(cairoTransformMatrix, 1.0, 0.0, 0.0, -1.0, 0.0, 0.0); + cairo_transform(aStream->cairoContext, cairoTransformMatrix); + + /* Extract rotation angle and shear from the PLplot tranformation matrix. + Compute sines and cosines of the angles as an optimization. */ + plRotationShear(args->xform, &rotation, &shear, &stride); + rotation -= pls->diorot * 3.14159 / 2.0; + cos_rot = cos(rotation); + sin_rot = sin(rotation); + cos_shear = cos(shear); + sin_shear = sin(shear); + + /* Apply the transform matrix */ + cairo_matrix_init(cairoTransformMatrix, + cos_rot * stride, + -sin_rot * stride, + cos_rot * sin_shear + sin_rot * cos_shear, + -sin_rot * sin_shear + cos_rot * cos_shear, + 0,0); + cairo_transform(aStream->cairoContext, cairoTransformMatrix); + free(cairoTransformMatrix); + + /* Move to the text starting point */ + cairo_rel_move_to(aStream->cairoContext, + (double)(-1.0 * args->just * (double)textXExtent), + (double)(-0.5 * textYExtent)); + + /* Render the text */ + pango_cairo_show_layout(aStream->cairoContext, layout); + + /* Restore the transform matrix to its state prior to the text transform. */ + cairo_restore(aStream->cairoContext); + + /* Free the layout object and the markup string. */ + g_object_unref(layout); + free(aStream->pangoMarkupString); +} + +/*--------------------------------------------------------------------- proc_str() Processes strings for display. @@ -667,6 +871,7 @@ pls->color = 1; /* Supports color */ pls->dev_text = 1; /* Handles text */ pls->dev_unicode = 1; /* Wants unicode text */ + pls->alt_unicode = 1; /* Wants to handle unicode character by character */ pls->page = 0; pls->dev_fill0 = 1; /* Supports hardware solid fills */ pls->plbuf_write = 1; /* Activate plot buffer */ @@ -679,9 +884,9 @@ /* Calculate ratio of (smaller) external coordinates used for cairo devices to (larger) internal PLplot coordinates. */ if (pls->xlength > pls->ylength) - downscale = (PLFLT)pls->xlength/(PLFLT)(PIXELS_X-1); + downscale = (double)pls->xlength/(double)(PIXELS_X-1); else - downscale = (PLFLT)pls->ylength/(PLFLT)PIXELS_Y; + downscale = (double)pls->ylength/(double)PIXELS_Y; plP_setphy((PLINT) 0, (PLINT) (pls->xlength / downscale), (PLINT) 0, (PLINT) (pls->ylength / downscale)); plP_setpxl(DPI/25.4/downscale, DPI/25.4/downscale); @@ -1079,12 +1284,6 @@ switch(op) { - case PLESC_FILL: /* filled polygon */ - filled_polygon(pls, pls->dev_x, pls->dev_y, pls->dev_npts); - break; - case PLESC_HAS_TEXT: /* render rext */ - proc_str(pls, (EscText *) ptr); - break; case PLESC_FLUSH: /* forced update of the window */ XFlush(aStream->XDisplay); break; @@ -1123,8 +1322,11 @@ plbop(); break; - } } + default: + plD_esc_cairo(pls, op, ptr); + break; + } } /*--------------------------------------------------------------------- Modified: trunk/include/plplot.h =================================================================== --- trunk/include/plplot.h 2009-04-04 21:23:44 UTC (rev 9789) +++ trunk/include/plplot.h 2009-04-05 02:38:45 UTC (rev 9790) @@ -264,8 +264,17 @@ #define PLESC_DEV2PLCOL 24 /* convert device color to PLColor */ #define PLESC_SETBGFG 25 /* set BG, FG colors */ #define PLESC_DEVINIT 26 /* alternate device initialization */ -#define PLESC_GETBACKEND 27 /* get used backend of (wxWidgets) driver */ +#define PLESC_GETBACKEND 27 /* get used backend of (wxWidgets) driver */ +#define PLESC_BEGIN_TEXT 28 /* get ready to draw a line of text */ +#define PLESC_TEXT_CHAR 29 /* render a character of text */ +#define PLESC_CONTROL_CHAR 30 /* handle a text control character (super/subscript, etc.) */ +#define PLESC_END_TEXT 31 /* finish a drawing a line of text */ +/* Alternative unicode text handling control characters */ +#define PLTEXT_FONTCHANGE 0 /* font change in the text stream */ +#define PLTEXT_SUPERSCRIPT 1 /* superscript in the text stream */ +#define PLTEXT_SUBSCRIPT 2 /* subscript in the text stream */ + /* image operations */ #define ZEROW2B 1 #define ZEROW2D 2 Modified: trunk/include/plplotP.h =================================================================== --- trunk/include/plplotP.h 2009-04-04 21:23:44 UTC (rev 9789) +++ trunk/include/plplotP.h 2009-04-05 02:38:45 UTC (rev 9790) @@ -537,6 +537,11 @@ PLINT refx; /* processed ref. point--after justification, displacement, etc, processing */ PLINT refy; char font_face; /* font face OPTIONALLY used for rendering hershey codes */ + /* The following 3 fields are used by the alternative text handling pathway. + See drivers/cairo.h for details about how this works. */ + PLUNICODE n_fci; /* font storage for unicode font handling */ + PLUNICODE n_char; /* character storage for unicode font handling */ + PLINT n_ctrl_char; /* control character code storage for unicode font handling */ PLUNICODE unicode_char; /* an int to hold either a Hershey, ASC-II, or Unicode value for plsym calls */ PLUNICODE *unicode_array; /* a pointer to an array of ints holding either a Hershey, ASC-II, or Unicode value for cached plsym */ unsigned short unicode_array_len; Modified: trunk/include/plstrm.h =================================================================== --- trunk/include/plstrm.h 2009-04-04 21:23:44 UTC (rev 9789) +++ trunk/include/plstrm.h 2009-04-05 02:38:45 UTC (rev 9790) @@ -706,6 +706,8 @@ PLINT dev_unicode; + PLINT alt_unicode; /* The alternative interface for unicode text rendering. */ + PLUNICODE fci; PLINT dev_hrshsym; Modified: trunk/src/plcore.c =================================================================== --- trunk/src/plcore.c 2009-04-04 21:23:44 UTC (rev 9789) +++ trunk/src/plcore.c 2009-04-05 02:38:45 UTC (rev 9790) @@ -237,7 +237,8 @@ if(plsc->plbuf_write) plbuf_esc(plsc, op, ptr); /* Text coordinates must pass through the driver interface filter */ - if(op==PLESC_HAS_TEXT && plsc->dev_unicode) { + if((op==PLESC_HAS_TEXT && plsc->dev_unicode)|| + (op==PLESC_END_TEXT && plsc->alt_unicode)){ /* Apply the driver interface filter */ if (plsc->difilt) { @@ -559,6 +560,11 @@ /* Obtain FCI (font characterization integer) for start of * string. */ plgfci(&fci); + + if(plsc->alt_unicode){ + args.n_fci = fci; + plP_esc(PLESC_BEGIN_TEXT, &args); + } for (j=i=0;i<len;i++) { /* Walk through the string, and convert * some stuff to unicode on the fly */ skip=0; @@ -575,6 +581,15 @@ unicode_buffer[j++] = \ (PLUNICODE)hershey_to_unicode_lookup_table[idx].Unicode; + if(plsc->alt_unicode){ + args.n_fci = fci; + args.n_ctrl_char = PLTEXT_FONTCHANGE; + plP_esc(PLESC_CONTROL_CHAR, &args); + args.n_char = \ + (PLUNICODE)hershey_to_unicode_lookup_table[idx].Unicode; + plP_esc(PLESC_TEXT_CHAR, &args); + } + /* if unicode_buffer[j-1] corresponds to the escape * character must unescape it by appending one more. * This will probably always be necessary since it is @@ -595,6 +610,16 @@ plP_hex2fci(PL_FCI_SYMBOL, PL_FCI_FAMILY, &fci); unicode_buffer[j++]= fci; unicode_buffer[j++]=code; + + if(plsc->alt_unicode){ + args.n_fci = fci; + args.n_ctrl_char = PLTEXT_FONTCHANGE; + plP_esc(PLESC_CONTROL_CHAR, &args); + args.n_char = \ + (PLUNICODE)hershey_to_unicode_lookup_table[idx].Unicode; + plP_esc(PLESC_TEXT_CHAR, &args); + } + /* if unicode_buffer[j-1] corresponds to the escape * character must unescape it by appending one more. * This will probably always be necessary since it is @@ -618,6 +643,12 @@ fci = code; unicode_buffer[j]=fci; skip=1; + + if(plsc->alt_unicode){ + args.n_fci = fci; + args.n_ctrl_char = PLTEXT_FONTCHANGE; + plP_esc(PLESC_CONTROL_CHAR, &args); + } } else { /* code is not complete FCI. Change @@ -630,6 +661,12 @@ plP_hex2fci(hexdigit, hexpower, &fci); unicode_buffer[j]=fci; skip=1; + + if(plsc->alt_unicode){ + args.n_fci = fci; + args.n_ctrl_char = PLTEXT_FONTCHANGE; + plP_esc(PLESC_CONTROL_CHAR, &args); + } } } @@ -639,6 +676,12 @@ plP_hex2fci(hexdigit, hexpower, &fci); unicode_buffer[j]=fci; skip=1; + + if(plsc->alt_unicode){ + args.n_fci = fci; + args.n_ctrl_char = PLTEXT_FONTCHANGE; + plP_esc(PLESC_CONTROL_CHAR, &args); + } } } break; @@ -672,6 +715,12 @@ i+=2; unicode_buffer[j] = fci; skip = 1; + + if(plsc->alt_unicode){ + args.n_fci = fci; + args.n_ctrl_char = PLTEXT_FONTCHANGE; + plP_esc(PLESC_CONTROL_CHAR, &args); + } } break; @@ -685,6 +734,13 @@ fcisave = fci; plP_hex2fci(PL_FCI_SYMBOL, PL_FCI_FAMILY, &fci); unicode_buffer[j++]= fci; + + if(plsc->alt_unicode){ + args.n_fci = fci; + args.n_ctrl_char = PLTEXT_FONTCHANGE; + plP_esc(PLESC_CONTROL_CHAR, &args); + } + ig = plP_strpos(plP_greek_mnemonic, string[i+2]); if (ig >= 0) { if (ig >= 24) @@ -695,6 +751,12 @@ i+=2; skip=1; /* skip is set if we have copied something * into the unicode table */ + + if(plsc->alt_unicode){ + args.n_char = \ + (PLUNICODE)hershey_to_unicode_lookup_table[idx].Unicode; + plP_esc(PLESC_TEXT_CHAR, &args); + } } else { /* Use "unknown" unicode character if string[i+2] @@ -703,11 +765,40 @@ i+=2; skip=1; /* skip is set if we have copied something * into the unicode table */ + + if(plsc->alt_unicode){ + args.n_char = \ + (PLUNICODE)hershey_to_unicode_lookup_table[idx].Unicode; + plP_esc(PLESC_TEXT_CHAR, &args); + } } fci = fcisave; unicode_buffer[j]= fci; - break; - + + if(plsc->alt_unicode){ + args.n_fci = fci; + args.n_ctrl_char = PLTEXT_FONTCHANGE; + plP_esc(PLESC_CONTROL_CHAR, &args); + } + break; + + case 'u': + if(plsc->alt_unicode){ + args.n_ctrl_char = PLTEXT_SUPERSCRIPT; + plP_esc(PLESC_CONTROL_CHAR, &args); + i += 1; + skip = 1; + } + break; + + case 'd': + if(plsc->alt_unicode){ + args.n_ctrl_char = PLTEXT_SUBSCRIPT; + plP_esc(PLESC_CONTROL_CHAR, &args); + i += 1; + skip = 1; + } + break; } } @@ -736,7 +827,13 @@ if (unicode_buffer[j] == esc && string[i+1] == esc) { i++; unicode_buffer[++j] = esc; + args.n_char = esc; + } else { + args.n_char = unichar; } + if(plsc->alt_unicode){ + plP_esc(PLESC_TEXT_CHAR, &args); + } } j++; } @@ -751,6 +848,10 @@ /* Don't print anything, if there is no unicode to print! */ return; } + + if(plsc->alt_unicode){ + plP_esc(PLESC_END_TEXT, &args); + } } if (plsc->dev_unicode) { @@ -760,7 +861,9 @@ args.string = string; } - plP_esc(PLESC_HAS_TEXT, &args); + if (!plsc->alt_unicode){ + plP_esc(PLESC_HAS_TEXT, &args); + } #ifndef DEBUG_TEXT } else { #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-04-15 20:30:05
|
Revision: 9802 http://plplot.svn.sourceforge.net/plplot/?rev=9802&view=rev Author: airwin Date: 2009-04-15 20:29:27 +0000 (Wed, 15 Apr 2009) Log Message: ----------- AWI for Alban Rochel. Implement a new extqt device which can be used to access PLplot from any Qt GUI application. N.B. currently there is a build error with this device (undefined symbol: _ZTV11QtExtWidget (drivers/qt.so)) so this device is disabled by default until this bug is fixed. Modified Paths: -------------- trunk/cmake/modules/drivers-init.cmake trunk/config.h.cmake trunk/drivers/qt.cpp trunk/drivers/qt.h trunk/drivers/qt.rc.in trunk/include/drivers.h trunk/include/plDevs.h.cmake trunk/include/plcore.h Modified: trunk/cmake/modules/drivers-init.cmake =================================================================== --- trunk/cmake/modules/drivers-init.cmake 2009-04-15 06:54:10 UTC (rev 9801) +++ trunk/cmake/modules/drivers-init.cmake 2009-04-15 20:29:27 UTC (rev 9802) @@ -91,6 +91,8 @@ "pngqt:qt:ON" "ppmqt:qt:ON" "tiffqt:qt:ON" +# Default OFF until build error is fixed. +"extqt:qt:OFF" # Currently does not validate at http://validator.w3.org/, but that appears # to be a result of the validator being unfamiliar with SVG-1.2 (a draft # SVG standard that has not been finalized yet) which is produced Modified: trunk/config.h.cmake =================================================================== --- trunk/config.h.cmake 2009-04-15 06:54:10 UTC (rev 9801) +++ trunk/config.h.cmake 2009-04-15 20:29:27 UTC (rev 9802) @@ -356,6 +356,9 @@ /* Define if tiff Qt driver is present */ #cmakedefine PLD_tiffqt +/* Define if external context Qt driver is present */ +#cmakedefine PLD_extqt + /* Portable definition for PTHREAD_MUTEX_RECURSIVE */ #define PLPLOT_MUTEX_RECURSIVE ${PLPLOT_MUTEX_RECURSIVE} Modified: trunk/drivers/qt.cpp =================================================================== --- trunk/drivers/qt.cpp 2009-04-15 06:54:10 UTC (rev 9801) +++ trunk/drivers/qt.cpp 2009-04-15 20:29:27 UTC (rev 9802) @@ -68,6 +68,9 @@ #if defined(PLD_pdfqt) "pdfqt:Qt PDF driver:0:qt:74:pdfqt\n" #endif +#if defined(PLD_extqt) + "extqt:External Qt driver:0:qt:75:extqt\n" +#endif ; MasterHandler handler; @@ -190,6 +193,12 @@ void plD_eop_qtwidget(PLStream *); #endif +#if defined(PLD_extqt) +void plD_dispatch_init_extqt(PLDispatchTable *pdt); +void plD_init_extqt(PLStream *); +void plD_eop_extqt(PLStream *); +#endif + // Declaration of the generic interface functions void plD_line_qt(PLStream *, short, short, short, short); @@ -1277,7 +1286,7 @@ } #endif -#if defined (PLD_qtwidget) +#if defined (PLD_qtwidget) || defined(PLD_extqt) QtPLWidget::QtPLWidget(int i_iWidth, int i_iHeight, QWidget* parent): QWidget(parent), QtPLDriver(i_iWidth, i_iHeight) @@ -1300,6 +1309,9 @@ 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 QtPLWidget::clearWidget() @@ -1479,4 +1491,196 @@ #endif +#if defined(PLD_extqt) +QtExtWidget::QtExtWidget(int i_iWidth, int i_iHeight, QWidget* parent): + QtPLWidget(i_iWidth, i_iHeight, parent) +{ + 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(cursorParameters.cursor_x, 0., cursorParameters.cursor_x, height()); + p.drawLine(0., cursorParameters.cursor_y, width(), cursorParameters.cursor_y); + + p.end(); +} + +void plD_dispatch_init_extqt(PLDispatchTable *pdt) +{ +#ifndef ENABLE_DYNDRIVERS + pdt->pl_MenuStr = "External Qt Widget"; + pdt->pl_DevName = "extqt"; #endif + pdt->pl_type = plDevType_Interactive; + pdt->pl_seq = 75; + pdt->pl_init = (plD_init_fp) plD_init_extqt; + pdt->pl_line = (plD_line_fp) plD_line_qt; + pdt->pl_polyline = (plD_polyline_fp) plD_polyline_qt; + pdt->pl_eop = (plD_eop_fp) plD_eop_extqt; + pdt->pl_bop = (plD_bop_fp) plD_bop_qt; + pdt->pl_tidy = (plD_tidy_fp) plD_tidy_qt; + pdt->pl_state = (plD_state_fp) plD_state_qt; + pdt->pl_esc = (plD_esc_fp) plD_esc_qt; +} + +void plD_init_extqt(PLStream * pls) +{ + if(pls->dev==NULL/* || pls->xlength <= 0 || pls->ylength <= 0*/) + { + printf("Error: use plsetqtdev to set up the Qt device before calling plinit()\n"); + return; + } + + QtExtWidget* widget=(QtExtWidget*)(pls->dev); + + if (widget->m_dWidth > widget->m_dHeight) + widget->downscale = (PLFLT)widget->m_dWidth/(PLFLT)(PIXELS_X-1); + else + widget->downscale = (PLFLT)widget->m_dHeight/(PLFLT)PIXELS_Y; + + plP_setphy((PLINT) 0, (PLINT) (widget->m_dWidth / widget->downscale), (PLINT) 0, (PLINT) (widget->m_dHeight / widget->downscale)); + + QPicture temp; + QPainter tempPainter(&temp); + + plP_setpxl(temp.logicalDpiX()/25.4/widget->downscale, temp.logicalDpiY()/25.4/widget->downscale); + + pls->color = 1; /* Is a color device */ + pls->plbuf_write=0; + pls->dev_fill0 = 1; /* Handle solid fills */ + 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; + pls->dev_clear=1; + pls->dev_text = 1; // want to draw text + pls->dev_unicode = 1; // want unicode + + +} + +void plD_eop_extqt(PLStream *pls) +{ + +} + +void plsetqtdev(QtExtWidget* widget) +{ + plsc->dev = (void*)widget; +} + +void plfreeqtdev() +{ + delete ((QtExtWidget*)plsc->dev); + plsc->dev=NULL; +} +#endif + +#endif Modified: trunk/drivers/qt.h =================================================================== --- trunk/drivers/qt.h 2009-04-15 06:54:10 UTC (rev 9801) +++ trunk/drivers/qt.h 2009-04-15 20:29:27 UTC (rev 9802) @@ -262,7 +262,7 @@ }; #endif -#if defined (PLD_qtwidget) +#if defined (PLD_qtwidget) || defined (PLD_extqt) // 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 @@ -304,4 +304,40 @@ #endif +#if defined (PLD_extqt) +class 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; +}; + +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(). + +void plfreeqtdev(); // Deletes and unregisters the device. + #endif + +#endif Modified: trunk/drivers/qt.rc.in =================================================================== --- trunk/drivers/qt.rc.in 2009-04-15 06:54:10 UTC (rev 9801) +++ trunk/drivers/qt.rc.in 2009-04-15 20:29:27 UTC (rev 9802) @@ -7,3 +7,4 @@ qtwidget:Qt Widget:1:qt:72:qtwidget epsqt:Qt EPS driver:0:qt:73:epsqt pdfqt:Qt PDF driver:0:qt:74:pdfqt +extqt:External Qt driver:0:qt:75:extqt Modified: trunk/include/drivers.h =================================================================== --- trunk/include/drivers.h 2009-04-15 06:54:10 UTC (rev 9801) +++ trunk/include/drivers.h 2009-04-15 20:29:27 UTC (rev 9802) @@ -106,6 +106,7 @@ PLDLLIMPEXP_DRIVER void plD_dispatch_init_epsqt ( PLDispatchTable *pdt ); PLDLLIMPEXP_DRIVER void plD_dispatch_init_pdfqt ( PLDispatchTable *pdt ); PLDLLIMPEXP_DRIVER void plD_dispatch_init_qtwidget ( PLDispatchTable *pdt ); +PLDLLIMPEXP_DRIVER void plD_dispatch_init_extqt ( PLDispatchTable *pdt ); /* Prototypes for plot buffer calls. */ Modified: trunk/include/plDevs.h.cmake =================================================================== --- trunk/include/plDevs.h.cmake 2009-04-15 06:54:10 UTC (rev 9801) +++ trunk/include/plDevs.h.cmake 2009-04-15 20:29:27 UTC (rev 9802) @@ -94,5 +94,6 @@ #cmakedefine PLD_epsqt #cmakedefine PLD_pdfqt #cmakedefine PLD_qtwidget +#cmakedefine PLD_extqt #endif /* __PLDEVS_H__ */ Modified: trunk/include/plcore.h =================================================================== --- trunk/include/plcore.h 2009-04-15 06:54:10 UTC (rev 9801) +++ trunk/include/plcore.h 2009-04-15 20:29:27 UTC (rev 9802) @@ -323,6 +323,9 @@ #if defined(PLD_qtwidget) && !defined(ENABLE_DYNDRIVERS) plD_dispatch_init_qtwidget, #endif +#if defined(PLD_extqt) && !defined(ENABLE_DYNDRIVERS) + plD_dispatch_init_extqt, +#endif NULL }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2009-04-16 13:53:10
|
Revision: 9803 http://plplot.svn.sourceforge.net/plplot/?rev=9803&view=rev Author: andrewross Date: 2009-04-16 13:52:44 +0000 (Thu, 16 Apr 2009) Log Message: ----------- Fix up cmake support for PLD_extqt so moc is called with the right options. Modified Paths: -------------- trunk/cmake/modules/qt.cmake trunk/drivers/CMakeLists.txt trunk/src/CMakeLists.txt Modified: trunk/cmake/modules/qt.cmake =================================================================== --- trunk/cmake/modules/qt.cmake 2009-04-15 20:29:27 UTC (rev 9802) +++ trunk/cmake/modules/qt.cmake 2009-04-16 13:52:44 UTC (rev 9803) @@ -29,6 +29,7 @@ # PLD_pdfqt - ON means the pdfqt device is enabled. # PLD_qtwidget - ON means the qtwidget device is enabled. # PLD_svgqt - ON means the svgqt device is enabled. +# PLD_extqt - ON means the extqt device is enabled. # qt_COMPILE_FLAGS - individual COMPILE_FLAGS required to compile wxwidgets # device. # qt_LINK_FLAGS - list of full path names of libraries and @@ -38,7 +39,7 @@ # when ENABLE_DYNDRIVERS OFF. 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) +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) if(QT4_FOUND) if(PLD_svgqt AND ${QT_VERSION_MINOR} GREATER 2) set(QT_USE_QTSVG 1) @@ -64,5 +65,6 @@ 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) endif(QT4_FOUND) -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) +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) Modified: trunk/drivers/CMakeLists.txt =================================================================== --- trunk/drivers/CMakeLists.txt 2009-04-15 20:29:27 UTC (rev 9802) +++ trunk/drivers/CMakeLists.txt 2009-04-16 13:52:44 UTC (rev 9803) @@ -90,11 +90,12 @@ PROPERTIES COMPILE_FLAGS "-DUSINGDLL" ) endif(${SOURCE_ROOT_NAME}_COMPILE_FLAGS) - if(SOURCE_ROOT_NAME STREQUAL "qt" AND PLD_qtwidget) + if(SOURCE_ROOT_NAME STREQUAL "qt") + if(PLD_qtwidget OR PLD_extqt) qt4_wrap_cpp( QT_MOC_OUTFILES ${CMAKE_CURRENT_SOURCE_DIR}/qt.h - OPTIONS "-DPLD_qtwidget=ON" + OPTIONS "-DPLD_qtwidget=${PLD_qtwidget} -DPLD_extqt=${PLD_extqt}" ) # message("QT_MOC_OUTFILES = ${QT_MOC_OUTFILES}") set_source_files_properties( @@ -102,9 +103,12 @@ PROPERTIES GENERATED "ON" ) add_library(${SOURCE_ROOT_NAME} MODULE ${${SOURCE_ROOT_NAME}_SOURCE} ${QT_MOC_OUTFILES}) - else(SOURCE_ROOT_NAME STREQUAL "qt" AND PLD_qtwidget) - add_library(${SOURCE_ROOT_NAME} MODULE ${${SOURCE_ROOT_NAME}_SOURCE}) - endif(SOURCE_ROOT_NAME STREQUAL "qt" AND PLD_qtwidget) + else(PLD_qtwidget OR PLD_extqt) + add_library(${SOURCE_ROOT_NAME} MODULE ${${SOURCE_ROOT_NAME}_SOURCE}) + endif(PLD_qtwidget OR PLD_extqt) + else(SOURCE_ROOT_NAME STREQUAL "qt") + add_library(${SOURCE_ROOT_NAME} MODULE ${${SOURCE_ROOT_NAME}_SOURCE}) + endif(SOURCE_ROOT_NAME STREQUAL "qt") # ${SOURCE_ROOT_NAME}_LINK_FLAGS is ideally a list of the full path names # to libraries determined with find_library. However, the list can also # include link flags such as the -L and -l form of specifying libraries, Modified: trunk/src/CMakeLists.txt =================================================================== --- trunk/src/CMakeLists.txt 2009-04-15 20:29:27 UTC (rev 9802) +++ trunk/src/CMakeLists.txt 2009-04-16 13:52:44 UTC (rev 9803) @@ -100,19 +100,22 @@ foreach(SOURCE_ROOT_NAME ${DRIVERS_LIST}) #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" AND PLD_qtwidget) + if(SOURCE_ROOT_NAME STREQUAL "qt") + if(PLD_qtwidget OR PLD_extqt) qt4_wrap_cpp( - QT_MOC_OUTFILES - ${CMAKE_SOURCE_DIR}/drivers/qt.h - OPTIONS "-DPLD_qtwidget=ON" - ) + QT_MOC_OUTFILES + ${CMAKE_CURRENT_SOURCE_DIR}/qt.h + OPTIONS "-DPLD_qtwidget=${PLD_qtwidget} -DPLD_extqt=${PLD_extqt}" + ) # message("QT_MOC_OUTFILES = ${QT_MOC_OUTFILES}") set_source_files_properties( - ${QT_MOC_OUTFILES} - PROPERTIES GENERATED "ON" - ) + ${QT_MOC_OUTFILES} + PROPERTIES GENERATED "ON" + ) list(APPEND plplot${LIB_TAG}_LIB_SRCS ${QT_MOC_OUTFILES}) - endif(SOURCE_ROOT_NAME STREQUAL "qt" AND PLD_qtwidget) + endif(PLD_qtwidget OR PLD_extqt) + endif(SOURCE_ROOT_NAME STREQUAL "qt") + if(${SOURCE_ROOT_NAME}_COMPILE_FLAGS) set_source_files_properties( ${${SOURCE_ROOT_NAME}_SOURCE} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2009-04-16 14:09:22
|
Revision: 9804 http://plplot.svn.sourceforge.net/plplot/?rev=9804&view=rev Author: andrewross Date: 2009-04-16 14:08:44 +0000 (Thu, 16 Apr 2009) Log Message: ----------- Avoid quoting of space in options passed to moc. Modified Paths: -------------- trunk/drivers/CMakeLists.txt trunk/src/CMakeLists.txt Modified: trunk/drivers/CMakeLists.txt =================================================================== --- trunk/drivers/CMakeLists.txt 2009-04-16 13:52:44 UTC (rev 9803) +++ trunk/drivers/CMakeLists.txt 2009-04-16 14:08:44 UTC (rev 9804) @@ -95,7 +95,7 @@ qt4_wrap_cpp( QT_MOC_OUTFILES ${CMAKE_CURRENT_SOURCE_DIR}/qt.h - OPTIONS "-DPLD_qtwidget=${PLD_qtwidget} -DPLD_extqt=${PLD_extqt}" + OPTIONS -DPLD_qtwidget=${PLD_qtwidget} -DPLD_extqt=${PLD_extqt} ) # message("QT_MOC_OUTFILES = ${QT_MOC_OUTFILES}") set_source_files_properties( Modified: trunk/src/CMakeLists.txt =================================================================== --- trunk/src/CMakeLists.txt 2009-04-16 13:52:44 UTC (rev 9803) +++ trunk/src/CMakeLists.txt 2009-04-16 14:08:44 UTC (rev 9804) @@ -105,7 +105,7 @@ qt4_wrap_cpp( QT_MOC_OUTFILES ${CMAKE_CURRENT_SOURCE_DIR}/qt.h - OPTIONS "-DPLD_qtwidget=${PLD_qtwidget} -DPLD_extqt=${PLD_extqt}" + OPTIONS -DPLD_qtwidget=${PLD_qtwidget} -DPLD_extqt=${PLD_extqt} ) # message("QT_MOC_OUTFILES = ${QT_MOC_OUTFILES}") set_source_files_properties( This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-04-16 22:36:10
|
Revision: 9808 http://plplot.svn.sourceforge.net/plplot/?rev=9808&view=rev Author: airwin Date: 2009-04-16 22:36:09 +0000 (Thu, 16 Apr 2009) Log Message: ----------- Make qt4_wrap_cpp OPTIONS consistent with qt.h code which only checks of option is defined and not whether it is YES/NO. Modified Paths: -------------- trunk/drivers/CMakeLists.txt trunk/src/CMakeLists.txt Modified: trunk/drivers/CMakeLists.txt =================================================================== --- trunk/drivers/CMakeLists.txt 2009-04-16 17:13:42 UTC (rev 9807) +++ trunk/drivers/CMakeLists.txt 2009-04-16 22:36:09 UTC (rev 9808) @@ -91,24 +91,32 @@ ) endif(${SOURCE_ROOT_NAME}_COMPILE_FLAGS) if(SOURCE_ROOT_NAME STREQUAL "qt") - if(PLD_qtwidget OR PLD_extqt) - qt4_wrap_cpp( - QT_MOC_OUTFILES - ${CMAKE_CURRENT_SOURCE_DIR}/qt.h - OPTIONS -DPLD_qtwidget=${PLD_qtwidget} -DPLD_extqt=${PLD_extqt} - ) - # message("QT_MOC_OUTFILES = ${QT_MOC_OUTFILES}") - set_source_files_properties( - ${QT_MOC_OUTFILES} - PROPERTIES GENERATED "ON" - ) - add_library(${SOURCE_ROOT_NAME} MODULE ${${SOURCE_ROOT_NAME}_SOURCE} ${QT_MOC_OUTFILES}) - else(PLD_qtwidget OR PLD_extqt) + set(MOC_OPTIONS) + 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_CURRENT_SOURCE_DIR}/qt.h + OPTIONS ${MOC_OPTIONS} + ) + # message("QT_MOC_OUTFILES = ${QT_MOC_OUTFILES}") + set_source_files_properties( + ${QT_MOC_OUTFILES} + PROPERTIES GENERATED "ON" + ) + add_library(${SOURCE_ROOT_NAME} MODULE ${${SOURCE_ROOT_NAME}_SOURCE} ${QT_MOC_OUTFILES}) + else(MOC_OPTIONS) add_library(${SOURCE_ROOT_NAME} MODULE ${${SOURCE_ROOT_NAME}_SOURCE}) - endif(PLD_qtwidget OR PLD_extqt) + endif(MOC_OPTIONS) else(SOURCE_ROOT_NAME STREQUAL "qt") - add_library(${SOURCE_ROOT_NAME} MODULE ${${SOURCE_ROOT_NAME}_SOURCE}) + add_library(${SOURCE_ROOT_NAME} MODULE ${${SOURCE_ROOT_NAME}_SOURCE}) endif(SOURCE_ROOT_NAME STREQUAL "qt") + # ${SOURCE_ROOT_NAME}_LINK_FLAGS is ideally a list of the full path names # to libraries determined with find_library. However, the list can also # include link flags such as the -L and -l form of specifying libraries, Modified: trunk/src/CMakeLists.txt =================================================================== --- trunk/src/CMakeLists.txt 2009-04-16 17:13:42 UTC (rev 9807) +++ trunk/src/CMakeLists.txt 2009-04-16 22:36:09 UTC (rev 9808) @@ -100,20 +100,27 @@ foreach(SOURCE_ROOT_NAME ${DRIVERS_LIST}) #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") - if(PLD_qtwidget OR PLD_extqt) - qt4_wrap_cpp( - QT_MOC_OUTFILES - ${CMAKE_CURRENT_SOURCE_DIR}/qt.h - OPTIONS -DPLD_qtwidget=${PLD_qtwidget} -DPLD_extqt=${PLD_extqt} - ) - # 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(PLD_qtwidget OR PLD_extqt) + if(SOURCE_ROOT_NAME STREQUAL "qt") + set(MOC_OPTIONS) + 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_CURRENT_SOURCE_DIR}/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) endif(SOURCE_ROOT_NAME STREQUAL "qt") if(${SOURCE_ROOT_NAME}_COMPILE_FLAGS) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-04-17 16:58:39
|
Revision: 9813 http://plplot.svn.sourceforge.net/plplot/?rev=9813&view=rev Author: airwin Date: 2009-04-17 16:58:19 +0000 (Fri, 17 Apr 2009) Log Message: ----------- AWI for Alban Rochel. Set full list of moc options corresponding to all PLD_xxx values associated with qt. This fix should make a difference for the case when defining only non-interactive raster devices. Modified Paths: -------------- trunk/drivers/CMakeLists.txt trunk/src/CMakeLists.txt Modified: trunk/drivers/CMakeLists.txt =================================================================== --- trunk/drivers/CMakeLists.txt 2009-04-17 16:54:30 UTC (rev 9812) +++ trunk/drivers/CMakeLists.txt 2009-04-17 16:58:19 UTC (rev 9813) @@ -92,6 +92,30 @@ endif(${SOURCE_ROOT_NAME}_COMPILE_FLAGS) 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) Modified: trunk/src/CMakeLists.txt =================================================================== --- trunk/src/CMakeLists.txt 2009-04-17 16:54:30 UTC (rev 9812) +++ trunk/src/CMakeLists.txt 2009-04-17 16:58:19 UTC (rev 9813) @@ -102,6 +102,30 @@ 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) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-04-17 22:31:34
|
Revision: 9814 http://plplot.svn.sourceforge.net/plplot/?rev=9814&view=rev Author: airwin Date: 2009-04-17 22:31:29 +0000 (Fri, 17 Apr 2009) Log Message: ----------- Add qt_gui bindings whose sole purpose is to configure a pkg-config plplot(d)-qt.pc file. The purpose of that file is to help build Qt applications that use the installed extqt "device" to access the PLplot API. Modified Paths: -------------- trunk/CMakeLists.txt Added Paths: ----------- trunk/bindings/qt_gui/ trunk/bindings/qt_gui/CMakeLists.txt Modified: trunk/CMakeLists.txt =================================================================== --- trunk/CMakeLists.txt 2009-04-17 16:58:19 UTC (rev 9813) +++ trunk/CMakeLists.txt 2009-04-17 22:31:29 UTC (rev 9814) @@ -129,6 +129,9 @@ add_subdirectory(data) add_subdirectory(bindings) add_subdirectory(drivers) +# Must be processed after drivers since depends on qt target created by +# drivers. +add_subdirectory(bindings/qt_gui) add_subdirectory(examples) add_subdirectory(utils) add_subdirectory(plplot_test) Added: trunk/bindings/qt_gui/CMakeLists.txt =================================================================== --- trunk/bindings/qt_gui/CMakeLists.txt (rev 0) +++ trunk/bindings/qt_gui/CMakeLists.txt 2009-04-17 22:31:29 UTC (rev 9814) @@ -0,0 +1,80 @@ +# bindings/qt/CMakeLists.txt +### Process this file with cmake to produce Makefile +### +# Copyright (C) 2006 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 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(PLD_extqt) + + # Transform "${qt_LINK_FLAGS}" to the + # standard pkg-config form. + pkg_config_link_flags( + libplplotqt${LIB_TAG}_LINK_FLAGS + "${qt_LINK_FLAGS}" + ) + + # Configure pkg-config *.pc file corresponding to the compile and link + # flags needed by a Qt GUI executable using extqt to gain access to PLplot. + if(PKG_CONFIG_EXECUTABLE) + if(LIB_TAG) + set(PC_PRECISION "double") + else(LIB_TAG) + set(PC_PRECISION "single") + endif(LIB_TAG) + # Each list element must consist of a colon-separated string with the + # following fields which are parsed out in the foreach loop below and + # used to configure the corresponding pkg-config *.pc file. + # BINDING - ENABLE_${BINDING} keeps track of whether a + # binding has been enabled (ON) or not (OFF). + # Also, ${BINDING} used to determine PC_FILE_SUFFIX + # which helps to determine name of configured + # *.pc file. + # PC_SHORT_NAME - Used in *.pc NAME: field + # PC_LONG_NAME - Used in *.pc Description: field + # PC_LIBRARY_NAME - Used in *.pc Libs: field + # Also used to determine PC_LINK_FLAGS and + # PC_COMPILE_FLAGS used in *.pc Libs: and Cflags: + # fields. + set(PC_DATA "qt:QT:QT4 bindings, :plplotqt${LIB_TAG}") + + string(REGEX REPLACE "^(.*):.*:.*:.*$" "\\1" BINDING ${PC_DATA}) + set(PC_FILE_SUFFIX "-${BINDING}") + set(PC_REQUIRES "plplot${LIB_TAG}") + 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_COMPILE_FLAGS "${qt_COMPILE_FLAGS}") + set(PC_CONFIGURED_FILE + ${CMAKE_BINARY_DIR}/pkgcfg/plplot${LIB_TAG}${PC_FILE_SUFFIX}.pc + ) + configure_file( + ${CMAKE_SOURCE_DIR}/pkgcfg/plplot-template.pc.cmake + ${PC_CONFIGURED_FILE} + @ONLY + ) + install(FILES ${PC_CONFIGURED_FILE} DESTINATION ${PKG_CONFIG_DIR}) + endif(PKG_CONFIG_EXECUTABLE) +endif(PLD_extqt) Property changes on: trunk/bindings/qt_gui/CMakeLists.txt ___________________________________________________________________ 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-04-20 19:35:14
|
Revision: 9824 http://plplot.svn.sourceforge.net/plplot/?rev=9824&view=rev Author: airwin Date: 2009-04-20 19:34:54 +0000 (Mon, 20 Apr 2009) Log Message: ----------- Incorporate into the installed examples tree and tests some examples demonstrating how to use the PLplot xcairo and extcairo to draw into an externally supplied XDrawable or Cairo context. N.B. ext-cairo-test builds fine, but has run-time issues (no glyphs show at all in the test.ps result and a 177 error code is returned) so I leave the extcairo device driver disabled by default. Modified Paths: -------------- trunk/cmake/modules/cairo.cmake trunk/examples/c/CMakeLists.txt trunk/examples/c/Makefile.examples.in trunk/plplot_test/plplot-test-interactive.sh.in Modified: trunk/cmake/modules/cairo.cmake =================================================================== --- trunk/cmake/modules/cairo.cmake 2009-04-20 19:23:35 UTC (rev 9823) +++ trunk/cmake/modules/cairo.cmake 2009-04-20 19:34:54 UTC (rev 9824) @@ -155,3 +155,11 @@ OR PLD_xcairo OR PLD_extcairo ) + +if(NOT PLD_xcairo) + set(extXdrawable_true "#") +endif(NOT PLD_xcairo) + +if(NOT PLD_extcairo) + set(extcairo_true "#") +endif(NOT PLD_extcairo) Modified: trunk/examples/c/CMakeLists.txt =================================================================== --- trunk/examples/c/CMakeLists.txt 2009-04-20 19:23:35 UTC (rev 9823) +++ trunk/examples/c/CMakeLists.txt 2009-04-20 19:34:54 UTC (rev 9824) @@ -88,7 +88,19 @@ ) endif(ENABLE_gnome2) -install(FILES ${c_SRCS} ${plplotcanvas_SRCS} ${plplotcanvas_DOCS} +if(PLD_xcairo) + set(extXdrawable_SRC extXdrawable_demo.c) +endif(PLD_xcairo) + +if(PLD_extcairo) + set(extcairo_SRC ext-cairo-test.c) +endif(PLD_extcairo) + +if(PLD_xcairo OR PLD_extcairo) + set(cairo_DOCS README.cairo) +endif(PLD_xcairo OR PLD_extcairo) + +install(FILES ${c_SRCS} ${plplotcanvas_SRCS} ${plplotcanvas_DOCS} ${extXdrawable_SRC} ${extcairo_SRC} ${cairo_DOCS} DESTINATION ${DATA_DIR}/examples/c ) Modified: trunk/examples/c/Makefile.examples.in =================================================================== --- trunk/examples/c/Makefile.examples.in 2009-04-20 19:23:35 UTC (rev 9823) +++ trunk/examples/c/Makefile.examples.in 2009-04-20 19:34:54 UTC (rev 9824) @@ -32,6 +32,12 @@ @gcw_true@ plplotcanvas_demo$(EXEEXT) \ @gcw_true@ plplotcanvas_animation$(EXEEXT) +@extXdrawable_true@@pkg_config_true@extXdrawable_EXECUTABLES_list = \ +@extXdrawable_true@@pkg_config_true@ extXdrawable_demo$(EXEEXT) + +@extcairo_true@@pkg_config_true@extcairo_EXECUTABLES_list = \ +@extcairo_true@@pkg_config_true@ ext-cairo-test$(EXEEXT) + EXECUTABLES_list = \ x01c$(EXEEXT) \ x02c$(EXEEXT) \ @@ -64,7 +70,9 @@ x29c$(EXEEXT) \ x30c$(EXEEXT) \ x31c$(EXEEXT) \ - $(PLPLOTCANVAS_EXECUTABLES_list) + $(PLPLOTCANVAS_EXECUTABLES_list) \ + $(extXdrawable_EXECUTABLES_list) \ + $(extcairo_EXECUTABLES_list) all: $(EXECUTABLES_list) @@ -85,6 +93,14 @@ @gcw_true@@pkg_config_false@ $@ `plplot-config --cflags --libs --with-gcw` \ @gcw_true@@pkg_config_false@ @GCWTHREAD_CFLAGS@ @GCWTHREAD_LIBS@ +@extXdrawable_true@@pkg_config_true@extXdrawable_demo$(EXEEXT): extXdrawable_demo.c +@extXdrawable_true@@pkg_config_true@ $(CC) $< -o $@ $(RPATHCMD) \ +@extXdrawable_true@@pkg_config_true@ `$(PKG_CONFIG_ENV) pkg-config --cflags --libs plplot$(LIB_TAG) gtk+-x11-2.0` + +@extcairo_true@@pkg_config_true@ext-cairo-test$(EXEEXT): ext-cairo-test.c +@extcairo_true@@pkg_config_true@ $(CC) $< -o $@ $(RPATHCMD) \ +@extcairo_true@@pkg_config_true@ `$(PKG_CONFIG_ENV) pkg-config --cflags --libs plplot$(LIB_TAG) cairo` + .c$(EXEEXT): @pkg_config_true@ $(CC) $< -o $@ $(RPATHCMD) `$(PKG_CONFIG_ENV) pkg-config --cflags --libs plplot$(LIB_TAG)` @pkg_config_false@ $(CC) $< -o $@ `plplot-config --cflags --libs` Modified: trunk/plplot_test/plplot-test-interactive.sh.in =================================================================== --- trunk/plplot_test/plplot-test-interactive.sh.in 2009-04-20 19:23:35 UTC (rev 9823) +++ trunk/plplot_test/plplot-test-interactive.sh.in 2009-04-20 19:34:54 UTC (rev 9824) @@ -47,6 +47,20 @@ INDEX_LIST= COUNT=0 +if [ "@PLD_xcairo@" = "ON" ] ; then + INDEX_LIST="$INDEX_LIST $COUNT" + DIRECTORY[$COUNT]="c" + COMMAND[$COUNT]="./extXdrawable_demo" + COUNT=$(( $COUNT + 1 )) +fi + +if [ "@PLD_extcairo@" = "ON" ] ; then + INDEX_LIST="$INDEX_LIST $COUNT" + DIRECTORY[$COUNT]="c" + COMMAND[$COUNT]="./ext-cairo-test" + COUNT=$(( $COUNT + 1 )) +fi + if [ "@ENABLE_wxwidgets@" = "ON" ] ; then INDEX_LIST="$INDEX_LIST $COUNT" DIRECTORY[$COUNT]="c++" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-04-22 18:51:36
|
Revision: 9829 http://plplot.svn.sourceforge.net/plplot/?rev=9829&view=rev Author: airwin Date: 2009-04-22 18:51:27 +0000 (Wed, 22 Apr 2009) Log Message: ----------- Deprecate gcw device driver and related bindings. Deprecate gd devicd driver. Modified Paths: -------------- trunk/README.release trunk/cmake/modules/drivers-init.cmake trunk/cmake/modules/gcw.cmake Modified: trunk/README.release =================================================================== --- trunk/README.release 2009-04-22 17:17:11 UTC (rev 9828) +++ trunk/README.release 2009-04-22 18:51:27 UTC (rev 9829) @@ -53,6 +53,35 @@ V. This is official notice that (as of release 5.9.3) our build system requires CMake version 2.6.0 or higher. +VI. This is official notice that (as of release 5.9.3) we have deprecated +the gcw device driver and the related gnome2 and pygcw bindings since these +are essentially unmaintained. For example, the gcw device and associated +bindings still depends on the plfreetype approach for accessing unicode +fonts which has known issues (inconsistent text offsets, inconvenient font +setting capabilities, and incorrect rendering of CTL languages). To avoid +these issues we advise using the xcairo device and the externally supplied +XDrawable or Cairo context associated with the xcairo device and the +extcairo device (see examples/c/README.cairo) instead. If you still +absolutely must use -dev gcw or the related gnome2 or pygcw bindings despite +the known problems, then they can still be accessed by setting PLD_gcw, +ENABLE_gnome2, and/or ENABLE_pygcw to ON. + +VII. This is official notice that (as of release 5.9.3) we have deprecated +the gd device driver which implements the png, jpeg, and gif devices. This +device driver is essentially unmaintained. For example, it still depends on +the plfreetype approach for accessing unicode fonts which has known issues +(inconsistent text offsets, inconvenient font setting capabilities, and +incorrect rendering of CTL languages). To avoid these issues for PNG +format, we advise using the pngcairo or pngqt devices. To avoid these +issues for the JPEG format, we advise using the jpgqt device. PNG is +normally considered a better raster format than GIF, but if you absolutely +require GIF format, we advise using the pngcairo or pngqt devices and then +downgrading the results to the GIF format using the ImageMagick "convert" +application. For those platforms where libgd (the dependency of the gd +device driver) is accessible while the required dependencies of the cairo +and/or qt devices are not accessible, you can still use these deprecated +devices by setting PLD_png, PLD_jpeg, or PLD_gif to ON. + INDEX 1. Changes relative to PLplot 5.9.2 (the previous development release) Modified: trunk/cmake/modules/drivers-init.cmake =================================================================== --- trunk/cmake/modules/drivers-init.cmake 2009-04-22 17:17:11 UTC (rev 9828) +++ trunk/cmake/modules/drivers-init.cmake 2009-04-22 18:51:27 UTC (rev 9829) @@ -102,10 +102,12 @@ # which were in SVG results produced by QT-4.4.3 are gone for QT-4.5.0. # Therefore, the conclusion is to enable svgqt by default. "svgqt:qt:ON" -"gif:gd:ON" -"jpeg:gd:ON" -"png:gd:ON" -"gcw:gcw:ON" +# gd related devices are not maintained. +"gif:gd:OFF" +"jpeg:gd:OFF" +"png:gd:OFF" +# gcw is not maintained. +"gcw:gcw:OFF" # Do not implement gnome which is superseded by gcw #"gnome:gnome:OFF" "hp7470:hpgl:ON" Modified: trunk/cmake/modules/gcw.cmake =================================================================== --- trunk/cmake/modules/gcw.cmake 2009-04-22 17:17:11 UTC (rev 9828) +++ trunk/cmake/modules/gcw.cmake 2009-04-22 18:51:27 UTC (rev 9829) @@ -104,8 +104,8 @@ option(ENABLE_gnome2 "Enable Gnome2 bindings" OFF) option(ENABLE_pygcw "Enable Python Gnome2 bindings" OFF) else(DEFAULT_NO_BINDINGS) - option(ENABLE_gnome2 "Enable Gnome2 bindings" ON) - option(ENABLE_pygcw "Enable Python Gnome2 bindings" ON) + option(ENABLE_gnome2 "Enable Gnome2 bindings" OFF) + option(ENABLE_pygcw "Enable Python Gnome2 bindings" OFF) endif(DEFAULT_NO_BINDINGS) if(ENABLE_gnome2 AND NOT PLD_gcw) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-04-23 20:37:11
|
Revision: 9835 http://plplot.svn.sourceforge.net/plplot/?rev=9835&view=rev Author: airwin Date: 2009-04-23 20:36:57 +0000 (Thu, 23 Apr 2009) Log Message: ----------- Fix text bug in extcairo device (thanks to Hezekiah M. Carty for this fix). Enable extcairo device by default. Modified Paths: -------------- trunk/cmake/modules/drivers-init.cmake trunk/drivers/cairo.c Modified: trunk/cmake/modules/drivers-init.cmake =================================================================== --- trunk/cmake/modules/drivers-init.cmake 2009-04-23 12:32:26 UTC (rev 9834) +++ trunk/cmake/modules/drivers-init.cmake 2009-04-23 20:36:57 UTC (rev 9835) @@ -75,7 +75,7 @@ # memcairo does not work so turn it off by default. # The remaining cairo devices work well so turn them on by default. "memcairo:cairo:OFF" -"extcairo:cairo:OFF" +"extcairo:cairo:ON" "pdfcairo:cairo:ON" "pngcairo:cairo:ON" "pscairo:cairo:ON" Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2009-04-23 12:32:26 UTC (rev 9834) +++ trunk/drivers/cairo.c 2009-04-23 20:36:57 UTC (rev 9835) @@ -2026,12 +2026,6 @@ switch(op) { - case PLESC_FILL: /* filled polygon */ - filled_polygon(pls, pls->dev_x, pls->dev_y, pls->dev_npts); - break; - case PLESC_HAS_TEXT: /* render text */ - proc_str(pls, (EscText *) ptr); - break; case PLESC_DEVINIT: /* Set external context */ aStream->cairoContext = (cairo_t *)ptr; /* Set graphics aliasing */ @@ -2044,6 +2038,9 @@ Cairo does not provide a way to query the dimensions of a context? */ break; + default: /* Fall back on default Cairo actions */ + plD_esc_cairo(pls, op, ptr); + break; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |