From: <hba...@us...> - 2009-08-05 02:29:02
|
Revision: 10214 http://plplot.svn.sourceforge.net/plplot/?rev=10214&view=rev Author: hbabcock Date: 2009-08-05 02:28:55 +0000 (Wed, 05 Aug 2009) Log Message: ----------- Propogated plspal0, plspal1 to tcl/tk and updated example 16. Modified Paths: -------------- trunk/bindings/tcl/plapi.tpl trunk/bindings/tk/PLWin.itk trunk/examples/tcl/x16.tcl Modified: trunk/bindings/tcl/plapi.tpl =================================================================== --- trunk/bindings/tcl/plapi.tpl 2009-08-05 02:04:03 UTC (rev 10213) +++ trunk/bindings/tcl/plapi.tpl 2009-08-05 02:28:55 UTC (rev 10214) @@ -820,6 +820,16 @@ xoff PLINT yoff PLINT +# Set color map 0 using a palette file + +pltclcmd plspal0 void +filename const char * + +# Set color map 1 using a palette file + +pltclcmd plspal1 void +filename const char * + # Set the pause (on end-of-page) status. pltclcmd plspause void Modified: trunk/bindings/tk/PLWin.itk =================================================================== --- trunk/bindings/tk/PLWin.itk 2009-08-05 02:04:03 UTC (rev 10213) +++ trunk/bindings/tk/PLWin.itk 2009-08-05 02:28:55 UTC (rev 10214) @@ -336,6 +336,14 @@ eval $plwin cmd plspage $args } + method plspal0 {args} { + eval $plwin cmd plspal0 $args + } + + method plspal1 {args} { + eval $plwin cmd plspal1 $args + } + method plspause {args} { eval $plwin cmd plspause $args } Modified: trunk/examples/tcl/x16.tcl =================================================================== --- trunk/examples/tcl/x16.tcl 2009-08-05 02:04:03 UTC (rev 10213) +++ trunk/examples/tcl/x16.tcl 2009-08-05 02:28:55 UTC (rev 10214) @@ -22,6 +22,9 @@ matrix zz f $nx $ny matrix ww f $nx $ny + $w cmd plspal0 "cmap0_black_on_white.pal" + $w cmd plspal1 "cmap1_gray.pal" + # Set up data array for {set i 0} {$i < $nx} {incr i} { @@ -102,6 +105,9 @@ # Plot using 1d coordinate transform + $w cmd plspal0 "cmap0_black_on_white.pal" + $w cmd plspal1 "cmap1_blue_yellow.pal" + $w cmd pladv 0 $w cmd plvpor 0.1 0.9 0.1 0.9 $w cmd plwind -1.0 1.0 -1.0 1.0 @@ -122,6 +128,9 @@ # Plot using 2d coordinate transform + $w cmd plspal0 "cmap0_black_on_white.pal" + $w cmd plspal1 "cmap1_blue_red.pal" + $w cmd pladv 0 $w cmd plvpor 0.1 0.9 0.1 0.9 $w cmd plwind -1.0 1.0 -1.0 1.0 @@ -141,6 +150,9 @@ # Plot using 2d coordinate transform with both shades and contours. +# $w cmd plspal0 "" +# $w cmd plspal1 "" + $w cmd pladv 0 $w cmd plvpor 0.1 0.9 0.1 0.9 $w cmd plwind -1.0 1.0 -1.0 1.0 @@ -159,6 +171,9 @@ # Polar plot example demonstrating wrapping support. + $w cmd plspal0 "cmap0_black_on_white.pal" + $w cmd plspal1 "cmap1_gray.pal" + # Build the new coordinate matrices. set nylim [expr $ny - 1]; set wrap 2; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hez...@us...> - 2009-08-05 15:18:05
|
Revision: 10215 http://plplot.svn.sourceforge.net/plplot/?rev=10215&view=rev Author: hezekiahcarty Date: 2009-08-05 15:17:56 +0000 (Wed, 05 Aug 2009) Log Message: ----------- Fix a string-handling segfault in the custom label support Modified Paths: -------------- trunk/doc/docbook/src/api.xml trunk/examples/c/x19c.c trunk/include/plplot.h trunk/include/plstrm.h trunk/src/plbox.c Modified: trunk/doc/docbook/src/api.xml =================================================================== --- trunk/doc/docbook/src/api.xml 2009-08-05 02:28:55 UTC (rev 10214) +++ trunk/doc/docbook/src/api.xml 2009-08-05 15:17:56 UTC (rev 10215) @@ -11914,14 +11914,14 @@ <varlistentry> <term> <parameter>label_func</parameter> - (<literal>void (*) (PLINT, PLFLT, const char *, void *)</literal>, input) + (<literal>void (*) (PLINT, PLFLT, char *, PLINT, void *)</literal>, input) </term> <listitem> <para> This is the custom label function. In order to reset to the default labeling, set this to <literal>NULL</literal>. The - <literal>const char*</literal> argument should be set to point to - the appropriate label text. + <literal>char*</literal> argument should be set to the appropriate + label text. </para> </listitem> </varlistentry> Modified: trunk/examples/c/x19c.c =================================================================== --- trunk/examples/c/x19c.c 2009-08-05 02:28:55 UTC (rev 10214) +++ trunk/examples/c/x19c.c 2009-08-05 15:17:56 UTC (rev 10215) @@ -48,9 +48,8 @@ /* A custom axis labeling function for longitudes and latitudes. */ void -geolocation_labeler(PLINT axis, PLFLT value, const char *label, PLPointer data) { +geolocation_labeler(PLINT axis, PLFLT value, char *label, PLINT length, PLPointer data) { const char *direction_label; - char *custom_label; PLFLT label_val; if (axis == PL_Y_AXIS) { @@ -79,12 +78,11 @@ } if (axis == PL_Y_AXIS && value == 0.0) { /* A special case for the equator */ - sprintf(custom_label, "%s", direction_label); + snprintf(label, length, "%s", direction_label); } else { - sprintf(custom_label, "%.0f%s", fabs(label_val), direction_label); + snprintf(label, length, "%.0f%s", fabs(label_val), direction_label); } - label = custom_label; } /*--------------------------------------------------------------------------*\ Modified: trunk/include/plplot.h =================================================================== --- trunk/include/plplot.h 2009-08-05 02:28:55 UTC (rev 10214) +++ trunk/include/plplot.h 2009-08-05 15:17:56 UTC (rev 10215) @@ -781,7 +781,7 @@ /* Setup a user-provided custom labeling function */ PLDLLIMPEXP void -c_plslabelfunc(void (*label_func)(PLINT, PLFLT, const char *, PLPointer), +c_plslabelfunc(void (*label_func)(PLINT, PLFLT, char *, PLINT, PLPointer), PLPointer label_data); /* Calculate world coordinates and subpage from relative device coordinates. */ Modified: trunk/include/plstrm.h =================================================================== --- trunk/include/plstrm.h 2009-08-05 02:28:55 UTC (rev 10214) +++ trunk/include/plstrm.h 2009-08-05 15:17:56 UTC (rev 10215) @@ -656,7 +656,7 @@ PLINT xdigmax, ydigmax, zdigmax; PLINT xdigits, ydigits, zdigits; char *timefmt; - void (*label_func)(PLINT, PLFLT, const char *, PLPointer); + void (*label_func)(PLINT, PLFLT, char *, PLINT, PLPointer); PLPointer label_data; /* Variables governing physical coordinate system */ Modified: trunk/src/plbox.c =================================================================== --- trunk/src/plbox.c 2009-08-05 02:28:55 UTC (rev 10214) +++ trunk/src/plbox.c 2009-08-05 15:17:56 UTC (rev 10215) @@ -1400,12 +1400,9 @@ static void plform(PLINT axis, PLFLT value, PLINT scale, PLINT prec, char *string, PLINT len, PLBOOL ll, PLBOOL lf, PLBOOL lo) { - const char *custom_string; - /* Check to see if a custom labeling function is defined. If not, */ if (lo && plsc->label_func) { - (*plsc->label_func)(axis, value, custom_string, plsc->label_data); - snprintf(string, len, "%s", custom_string); + (*plsc->label_func)(axis, value, string, len, plsc->label_data); } else { if (lo) { @@ -1491,7 +1488,7 @@ * \*--------------------------------------------------------------------------*/ void -c_plslabelfunc(void (*label_func)(PLINT, PLFLT, const char *, PLPointer), PLPointer label_data) +c_plslabelfunc(void (*label_func)(PLINT, PLFLT, char *, PLINT, PLPointer), PLPointer label_data) { plsc->label_func = label_func; plsc->label_data = label_data; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2009-08-12 15:28:36
|
Revision: 10231 http://plplot.svn.sourceforge.net/plplot/?rev=10231&view=rev Author: andrewross Date: 2009-08-12 15:28:07 +0000 (Wed, 12 Aug 2009) Log Message: ----------- Add in java and python support for plarc and plslabelfunc. Note that plslabelfunc does not yet work properly. Update python example 3 consistent with C version. Modified Paths: -------------- trunk/bindings/java/PLCallback.java trunk/bindings/java/plplotjavac.i trunk/bindings/python/plplotcmodule.i trunk/bindings/swig-support/plplotcapi.i trunk/examples/python/xw03.py Modified: trunk/bindings/java/PLCallback.java =================================================================== --- trunk/bindings/java/PLCallback.java 2009-08-12 06:29:43 UTC (rev 10230) +++ trunk/bindings/java/PLCallback.java 2009-08-12 15:28:07 UTC (rev 10231) @@ -4,4 +4,5 @@ public interface PLCallback { public void mapform(double[] x, double[] y); + public String label(int axis, double value); }; Modified: trunk/bindings/java/plplotjavac.i =================================================================== --- trunk/bindings/java/plplotjavac.i 2009-08-12 06:29:43 UTC (rev 10230) +++ trunk/bindings/java/plplotjavac.i 2009-08-12 15:28:07 UTC (rev 10231) @@ -1072,6 +1072,7 @@ typedef void (*pltr_func)(PLFLT, PLFLT, PLFLT *, PLFLT*, PLPointer); typedef void (*mapform_func)(PLINT, PLFLT *, PLFLT*); typedef PLFLT (*f2eval_func)(PLINT, PLINT, PLPointer); + typedef void (*label_func)(PLINT, PLFLT, char *, PLINT, PLPointer); %} /* First of two object arrays, where we check X and Y with previous. @@ -1181,6 +1182,50 @@ %typemap(jstype) mapform_func "PLCallback" %typemap(javain) mapform_func mapform "$javainput" +%{ + + jobject labelClass; + jmethodID labelID; + JNIEnv *cbenv; + + /* C label plotting callback function which calls the java + * label function in a PLCallback object. */ + void label_java(PLINT axis, PLFLT value, char *string, PLINT len, PLPointer data) { + jstring javaString; + const char *nativeString; + + javaString = (*cbenv)->CallObjectMethod(cbenv,labelClass, labelID, axis, value); + nativeString = (*cbenv)->GetStringUTFChars(cbenv,javaString,0); + strncpy(string,nativeString,len); + (*cbenv)->ReleaseStringUTFChars(cbenv,javaString,nativeString); + } +%} + + +/* Handle function pointers to label function using an java class */ +%typemap(in) (label_func lf, PLPointer data) { + + jobject obj = $input; + if (obj != NULL) { + jclass cls = (*jenv)->GetObjectClass(jenv,obj); + labelID = (*jenv)->GetMethodID(jenv,cls, "label","([I[D)Ljava/lang/String" ); + labelClass = obj; + cbenv = jenv; + $1 = label_java; + $2 = NULL; + } + else { + $1 = NULL; + $2 = NULL; + } + +} + +%typemap(jni) (label_func lf, PLPointer data) "jobject" +%typemap(jtype) (label_func lf, PLPointer data) "PLCallback" +%typemap(jstype) (label_func lf, PLPointer data) "PLCallback" +%typemap(javain) (label_func lf, PLPointer data) "$javainput" + /* Second of two object arrays, where we check X and Y with previous object. */ %typemap(in) PLPointer OBJECT_DATA { jPLFLT **adat; Modified: trunk/bindings/python/plplotcmodule.i =================================================================== --- trunk/bindings/python/plplotcmodule.i 2009-08-12 06:29:43 UTC (rev 10230) +++ trunk/bindings/python/plplotcmodule.i 2009-08-12 15:28:07 UTC (rev 10231) @@ -617,6 +617,7 @@ typedef void (*pltr_func)(PLFLT, PLFLT, PLFLT *, PLFLT*, PLPointer); typedef void (*mapform_func)(PLINT, PLFLT *, PLFLT*); typedef PLFLT (*f2eval_func)(PLINT, PLINT, PLPointer); +typedef char * (*label_func)(PLINT, PLFLT, PLPointer); %{ typedef PLINT (*defined_func)(PLFLT, PLFLT); @@ -624,6 +625,7 @@ typedef void (*pltr_func)(PLFLT, PLFLT, PLFLT *, PLFLT*, PLPointer); typedef void (*mapform_func)(PLINT, PLFLT *, PLFLT*); typedef PLFLT (*f2eval_func)(PLINT, PLINT, PLPointer); +typedef void (*label_func)(PLINT, PLFLT, char *, PLINT, PLPointer); %} #if 0 @@ -647,6 +649,7 @@ PyObject* python_pltr = NULL; PyObject* python_f2eval = NULL; PyObject* python_mapform = NULL; + PyObject* python_label = NULL; #if 0 #define MY_BLOCK_THREADS { \ @@ -739,7 +742,7 @@ /* build the argument list */ arglist = Py_BuildValue("(iiO)", x, y, pdata); /* call the python function */ - result = PyEval_CallObject(python_pltr, arglist); + result = PyEval_CallObject(python_f2eval, arglist); /* release the argument list */ Py_DECREF(arglist); /* check and unpack the result */ @@ -758,6 +761,45 @@ return fresult; } + void do_label_callback(PLINT axis, PLFLT value, char *string, PLINT len, PLPointer data) + { + PyObject *pdata, *arglist, *result; + char *pystring; + PLFLT fresult = 0.0; + + /* the data argument is acutally a pointer to a python object */ + pdata = (PyObject*)data; + if(python_label) { /* if not something is terribly wrong */ + /* hold a reference to the data object */ + Py_XINCREF(pdata); + /* grab the Global Interpreter Lock to be sure threads don't mess us up */ + MY_BLOCK_THREADS + /* build the argument list */ +#ifdef PL_DOUBLE + arglist = Py_BuildValue("(idO)", axis, value, pdata); +#else + arglist = Py_BuildValue("(ifO)", axis, value, pdata); +#endif + /* call the python function */ + result = PyEval_CallObject(python_label, arglist); + /* release the argument list */ + Py_DECREF(arglist); + /* check and unpack the result */ + if(!PyFloat_Check(result)) { + fprintf(stderr, "label callback must return a string\n"); + PyErr_SetString(PyExc_RuntimeError, "label callback must return a string."); + } else { + /* should I test the type here? */ + pystring = PyString_AsString(result); + strncpy(string,pystring,len); + } + /* release the result */ + Py_XDECREF(result); + /* release the global interpreter lock */ + MY_UNBLOCK_THREADS + } + } + void do_mapform_callback(PLINT n, PLFLT *x, PLFLT *y) { PyObject *px, *py, *arglist, *result; @@ -995,6 +1037,23 @@ Py_XDECREF(python_f2eval); python_f2eval = 0; } +/* marshall the label function pointer argument */ +%typemap(in) label_func label { + /* it must be a callable */ + if(!PyCallable_Check((PyObject*)$input)) { + PyErr_SetString(PyExc_ValueError, "label_func argument must be callable"); + return NULL; + } + /* hold a reference to it */ + Py_XINCREF((PyObject*)$input); + python_label = (PyObject*)$input; + /* this function handles calling the python function */ + $1 = do_label_callback; +} +%typemap(freearg) label_func label { + Py_XDECREF(python_label); + python_label = 0; +} %typemap(in, numinputs=0) defined_func df { $1 = NULL; } Modified: trunk/bindings/swig-support/plplotcapi.i =================================================================== --- trunk/bindings/swig-support/plplotcapi.i 2009-08-12 06:29:43 UTC (rev 10230) +++ trunk/bindings/swig-support/plplotcapi.i 2009-08-12 15:28:07 UTC (rev 10231) @@ -239,6 +239,11 @@ void pladv(PLINT page); +%feature("autodoc", "Plot an arc") plarc; +void +plarc(PLFLT x, PLFLT y, PLFLT a, PLFLT b, PLFLT angle1, PLFLT angle2, + PLBOOL fill); + %feature("autodoc", "This functions similarly to plbox() except that the origin of the axes is placed at the user-specified point (x0, y0).") plaxes; void plaxes(PLFLT x0, PLFLT y0, const char *xopt, PLFLT xtick, PLINT nxsub, @@ -752,6 +757,10 @@ pltr_func pltr, PLPointer SWIG_OBJECT_DATA); +%feature("autodoc", "Set up a user-provided custom labeling function") plslabelfunc; +void +plslabelfunc(label_func lf, PLPointer data); + %feature("autodoc", "Set up lengths of major tick marks.") plsmaj; void plsmaj(PLFLT def, PLFLT scale); Modified: trunk/examples/python/xw03.py =================================================================== --- trunk/examples/python/xw03.py 2009-08-12 06:29:43 UTC (rev 10230) +++ trunk/examples/python/xw03.py 2009-08-12 15:28:07 UTC (rev 10231) @@ -36,17 +36,10 @@ # Set up viewport and window, but do not draw box plenv(-1.3, 1.3, -1.3, 1.3, 1, -2) - - i = 0.1*arange(1,11) - #outerproduct(i,x0) and outerproduct(i,y0) is what we are - #mocking up here since old Numeric version does not have outerproduct. - i.shape = (-1,1) - x=i*x0 - y=i*y0 # Draw circles for polar grid for i in range(10): - plline(x[i], y[i]) + plarc(0.0, 0.0, 0.1*(i+1), 0.1*(i+1), 0.0, 360.0, 0) plcol0(2) for i in range(12): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2009-08-12 15:48:49
|
Revision: 10232 http://plplot.svn.sourceforge.net/plplot/?rev=10232&view=rev Author: andrewross Date: 2009-08-12 15:48:42 +0000 (Wed, 12 Aug 2009) Log Message: ----------- Further tweaking with python plslabelfunc support and preliminary update of example 19. Still not working correctly. Modified Paths: -------------- trunk/bindings/python/plplotcmodule.i trunk/examples/python/xw19.py Modified: trunk/bindings/python/plplotcmodule.i =================================================================== --- trunk/bindings/python/plplotcmodule.i 2009-08-12 15:28:07 UTC (rev 10231) +++ trunk/bindings/python/plplotcmodule.i 2009-08-12 15:48:42 UTC (rev 10232) @@ -617,7 +617,7 @@ typedef void (*pltr_func)(PLFLT, PLFLT, PLFLT *, PLFLT*, PLPointer); typedef void (*mapform_func)(PLINT, PLFLT *, PLFLT*); typedef PLFLT (*f2eval_func)(PLINT, PLINT, PLPointer); -typedef char * (*label_func)(PLINT, PLFLT, PLPointer); +typedef char * (*label_func)(PLINT, PLFLT, char *, PLINT, PLPointer); %{ typedef PLINT (*defined_func)(PLFLT, PLFLT); @@ -951,12 +951,17 @@ %} %typemap(in) pltr_func pltr { - /* it must be a callable */ - if(!PyCallable_Check((PyObject*)$input)) { - PyErr_SetString(PyExc_ValueError, "pltr argument must be callable"); - return NULL; + /* it must be a callable or None */ + if($input == Py_None) { + $1 = NULL; } - $1 = marshal_pltr($input); + else { + if(!PyCallable_Check((PyObject*)$input)) { + PyErr_SetString(PyExc_ValueError, "pltr argument must be callable"); + return NULL; + } + $1 = marshal_pltr($input); + } } %typemap(freearg) pltr_func pltr { cleanup_pltr(); @@ -969,12 +974,17 @@ } %typemap(in) mapform_func mapform { - /* it must be a callable */ - if(!PyCallable_Check((PyObject*)$input)) { - PyErr_SetString(PyExc_ValueError, "mapform argument must be callable"); - return NULL; + /* it must be a callable or none */ + if($input == Py_None) { + $1 = NULL; } - $1 = marshal_mapform($input); + else { + if(!PyCallable_Check((PyObject*)$input)) { + PyErr_SetString(PyExc_ValueError, "mapform argument must be callable"); + return NULL; + } + $1 = marshal_mapform($input); + } } %typemap(freearg) mapform_func mapform { cleanup_mapform(); @@ -1022,35 +1032,45 @@ /* marshall the f2eval function pointer argument */ %typemap(in) f2eval_func f2eval { - /* it must be a callable */ - if(!PyCallable_Check((PyObject*)$input)) { - PyErr_SetString(PyExc_ValueError, "pltr argument must be callable"); - return NULL; + /* it must be a callable or None */ + if($input == Py_None) { + $1 = NULL; } - /* hold a reference to it */ - Py_XINCREF((PyObject*)$input); - python_f2eval = (PyObject*)$input; - /* this function handles calling the python function */ - $1 = do_f2eval_callback; + else { + if(!PyCallable_Check((PyObject*)$input)) { + PyErr_SetString(PyExc_ValueError, "pltr argument must be callable"); + return NULL; + } + /* hold a reference to it */ + Py_XINCREF((PyObject*)$input); + python_f2eval = (PyObject*)$input; + /* this function handles calling the python function */ + $1 = do_f2eval_callback; + } } %typemap(freearg) f2eval_func f2eval { Py_XDECREF(python_f2eval); python_f2eval = 0; } /* marshall the label function pointer argument */ -%typemap(in) label_func label { - /* it must be a callable */ - if(!PyCallable_Check((PyObject*)$input)) { - PyErr_SetString(PyExc_ValueError, "label_func argument must be callable"); - return NULL; +%typemap(in) label_func lf { + /* it must be a callable or None */ + if($input == Py_None) { + $1 = NULL; } - /* hold a reference to it */ - Py_XINCREF((PyObject*)$input); - python_label = (PyObject*)$input; - /* this function handles calling the python function */ - $1 = do_label_callback; + else { + if(!PyCallable_Check((PyObject*)$input)) { + PyErr_SetString(PyExc_ValueError, "label_func argument must be callable"); + return NULL; + } + /* hold a reference to it */ + Py_XINCREF((PyObject*)$input); + python_label = (PyObject*)$input; + /* this function handles calling the python function */ + $1 = do_label_callback; + } } -%typemap(freearg) label_func label { +%typemap(freearg) label_func lf { Py_XDECREF(python_label); python_label = 0; } Modified: trunk/examples/python/xw19.py =================================================================== --- trunk/examples/python/xw19.py 2009-08-12 15:28:07 UTC (rev 10231) +++ trunk/examples/python/xw19.py 2009-08-12 15:48:42 UTC (rev 10232) @@ -38,11 +38,47 @@ y[i] = yp return [x,y] -# Null coordinate transform (equivalent to passing NULL to C -# version of plmap / plmeridians. -def nullmapform(n,x,y): - return [x,y] +## "Normalize" longitude values so that they always fall between -180.0 and +## 180.0 +def normalize_longitude(lon): + if ((lon >= -180.0) and (lon <= 180.0)): + return lon + else : + times = floor ((fabs(lon) + 180.0) / 360.0) + if (lon < 0.0) : + return(lon + 360.0 * times) + else : + return(lon - 360.0 * times) + +## A custom axis labeling function for longitudes and latitudes. +def geolocation_labeler(axis, value, data): + if (axis == PL_Y_AXIS) : + label_val = value + if (label_val > 0.0) : + direction_label = " N" + elif (label_val < 0.0) : + direction_label = " S" + + else : + direction_label = "Eq" + elif (axis == PL_X_AXIS) : + label_val = normalize_longitude(value) + if (label_val > 0.0) : + direction_label = " E" + elif (label_val < 0.0) : + direction_label = " W" + else : + direction_label = "" + + if (axis == PL_Y_AXIS and value == 0.0) : + # A special case for the equator + snprintf(label, length, "%s", direction_label) + else : + snprintf(label, length, "%.0f%s", fabs(label_val), direction_label) + return label + + # main # # Does a series of 3-d plots for a given data set, with different @@ -61,9 +97,12 @@ minx = 190 maxx = 190+360 + # Setup a custom latitude and longitude-based scaling function. + plslabelfunc(geolocation_labeler, None) + plcol0(1) - plenv(minx, maxx, miny, maxy, 1, -1) - plmap(nullmapform,"usaglobe", minx, maxx, miny, maxy) + plenv(minx, maxx, miny, maxy, 1, 70) + plmap(None,"usaglobe", minx, maxx, miny, maxy) # The Americas @@ -71,9 +110,12 @@ maxx = 340 plcol0(1) - plenv(minx, maxx, miny, maxy, 1, -1) - plmap(nullmapform, "usaglobe", minx, maxx, miny, maxy) + plenv(minx, maxx, miny, maxy, 1, 70) + plmap(None, "usaglobe", minx, maxx, miny, maxy) + # Clear the labeling function + plslabelfunc(None, None) + # Polar, Northern hemisphere minx = 0 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2009-08-12 20:56:22
|
Revision: 10233 http://plplot.svn.sourceforge.net/plplot/?rev=10233&view=rev Author: andrewross Date: 2009-08-12 20:56:03 +0000 (Wed, 12 Aug 2009) Log Message: ----------- Update java bindings to include plarc and modify example 3 consistent with C version. Modified Paths: -------------- trunk/bindings/java/PLStream.java trunk/examples/java/x03.java Modified: trunk/bindings/java/PLStream.java =================================================================== --- trunk/bindings/java/PLStream.java 2009-08-12 15:48:42 UTC (rev 10232) +++ trunk/bindings/java/PLStream.java 2009-08-12 20:56:03 UTC (rev 10233) @@ -118,6 +118,11 @@ plplotjavac.pladv(page); } +public void arc(double x, double y, double a, double b, double angle1, double angle2, boolean fill ) { + if (set_stream() == -1) return; + plplotjavac.plarc(x, y, a, b, angle1, angle2, fill); +} + public void axes(double x0, double y0, String xopt, double xtick, int nxsub, String yopt, double ytick, int nysub) { if (set_stream() == -1) return; Modified: trunk/examples/java/x03.java =================================================================== --- trunk/examples/java/x03.java 2009-08-12 15:48:42 UTC (rev 10232) +++ trunk/examples/java/x03.java 2009-08-12 20:56:03 UTC (rev 10233) @@ -77,14 +77,7 @@ pls.env(-1.3, 1.3, -1.3, 1.3, 1, -2); for (i = 1; i <= 10; i++) { - for (j = 0; j <= 360; j++) { - x[j] = 0.1 * i * x0[j]; - y[j] = 0.1 * i * y0[j]; - } - - // Draw circles for polar grid. - - pls.line(x, y); + pls.arc(0.0, 0.0, 0.1*i, 0.1*i, 0.0, 360.0, false); } pls.col0(2); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2009-08-13 09:53:38
|
Revision: 10240 http://plplot.svn.sourceforge.net/plplot/?rev=10240&view=rev Author: andrewross Date: 2009-08-13 09:53:27 +0000 (Thu, 13 Aug 2009) Log Message: ----------- Fix up python support for plslabelfunc properly so example 19 works identically to the C version. Modified Paths: -------------- trunk/bindings/python/plplotcmodule.i trunk/examples/python/xw19.py Modified: trunk/bindings/python/plplotcmodule.i =================================================================== --- trunk/bindings/python/plplotcmodule.i 2009-08-13 09:17:49 UTC (rev 10239) +++ trunk/bindings/python/plplotcmodule.i 2009-08-13 09:53:27 UTC (rev 10240) @@ -768,7 +768,10 @@ PLFLT fresult = 0.0; /* the data argument is acutally a pointer to a python object */ - pdata = (PyObject*)data; + if (data) + pdata = (PyObject*)data; + else + pdata = Py_None; if(python_label) { /* if not something is terribly wrong */ /* hold a reference to the data object */ Py_XINCREF(pdata); @@ -776,16 +779,20 @@ MY_BLOCK_THREADS /* build the argument list */ #ifdef PL_DOUBLE - arglist = Py_BuildValue("(idO)", axis, value, pdata); + arglist = Py_BuildValue("(ldO)", axis, value, pdata); #else - arglist = Py_BuildValue("(ifO)", axis, value, pdata); + arglist = Py_BuildValue("(lfO)", axis, value, pdata); #endif /* call the python function */ result = PyEval_CallObject(python_label, arglist); /* release the argument list */ - Py_DECREF(arglist); + //Py_DECREF(arglist); /* check and unpack the result */ - if(!PyFloat_Check(result)) { + if (result == NULL) { + fprintf(stderr, "label callback failed with 3 arguments\n"); + PyErr_SetString(PyExc_RuntimeError, "label callback must take 3 arguments."); + } + else if(!PyString_Check(result)) { fprintf(stderr, "label callback must return a string\n"); PyErr_SetString(PyExc_RuntimeError, "label callback must return a string."); } else { @@ -1054,6 +1061,11 @@ } /* marshall the label function pointer argument */ %typemap(in) label_func lf { + /* Release reference to previous function if applicable */ + if (python_label) { + Py_XDECREF(python_label); + python_label = 0; + } /* it must be a callable or None */ if($input == Py_None) { $1 = NULL; @@ -1070,10 +1082,6 @@ $1 = do_label_callback; } } -%typemap(freearg) label_func lf { - Py_XDECREF(python_label); - python_label = 0; -} %typemap(in, numinputs=0) defined_func df { $1 = NULL; } Modified: trunk/examples/python/xw19.py =================================================================== --- trunk/examples/python/xw19.py 2009-08-13 09:17:49 UTC (rev 10239) +++ trunk/examples/python/xw19.py 2009-08-13 09:53:27 UTC (rev 10240) @@ -53,7 +53,7 @@ ## A custom axis labeling function for longitudes and latitudes. def geolocation_labeler(axis, value, data): - if (axis == PL_Y_AXIS) : + if (axis == 2) : label_val = value if (label_val > 0.0) : direction_label = " N" @@ -62,7 +62,7 @@ else : direction_label = "Eq" - elif (axis == PL_X_AXIS) : + elif (axis == 1) : label_val = normalize_longitude(value) if (label_val > 0.0) : direction_label = " E" @@ -71,11 +71,11 @@ else : direction_label = "" - if (axis == PL_Y_AXIS and value == 0.0) : + if (axis == 2 and value == 0.0) : # A special case for the equator - snprintf(label, length, "%s", direction_label) + label = direction_label else : - snprintf(label, length, "%.0f%s", fabs(label_val), direction_label) + label = ""+`abs(label_val)` + direction_label return label This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2009-08-13 13:04:57
|
Revision: 10241 http://plplot.svn.sourceforge.net/plplot/?rev=10241&view=rev Author: andrewross Date: 2009-08-13 13:04:38 +0000 (Thu, 13 Aug 2009) Log Message: ----------- Update java bindings to add all the infrastructure for plslabelfunc. The actual call to the callback function is disabled for now since this causes a crash on my jvm. I will investigate. Update java example 19 to illustrate changes Add PL_[XYZ]_AXIS constants for python / java bindings and change python example 19 to use these. Modified Paths: -------------- trunk/bindings/java/CMakeLists.txt trunk/bindings/java/PLStream.java trunk/bindings/java/plplotjavac.i trunk/bindings/swig-support/plplotcapi.i trunk/examples/java/x19.java trunk/examples/python/xw19.py Added Paths: ----------- trunk/bindings/java/PLCallbackLabel.java trunk/bindings/java/PLCallbackMapform.java Removed Paths: ------------- trunk/bindings/java/PLCallback.java Modified: trunk/bindings/java/CMakeLists.txt =================================================================== --- trunk/bindings/java/CMakeLists.txt 2009-08-13 09:53:27 UTC (rev 10240) +++ trunk/bindings/java/CMakeLists.txt 2009-08-13 13:04:38 UTC (rev 10241) @@ -53,7 +53,8 @@ JAVA_FILES_FULL ${JAVA_GEN_FILES_FULL} ${CMAKE_CURRENT_SOURCE_DIR}/PLStream.java -${CMAKE_CURRENT_SOURCE_DIR}/PLCallback.java +${CMAKE_CURRENT_SOURCE_DIR}/PLCallbackMapform.java +${CMAKE_CURRENT_SOURCE_DIR}/PLCallbackLabel.java ) @@ -70,7 +71,8 @@ set( ${class_root}/plplotjavacJNI.class_DEPENDS -${class_root}/PLCallback.class +${class_root}/PLCallbackMapform.class +${class_root}/PLCallbackLabel.class ) set( @@ -88,7 +90,8 @@ ${class_root}/plplotjavacConstants.class ${class_root}/PLGraphicsIn.class ${class_root}/plplotjavacJNI.class -${class_root}/PLCallback.class +${class_root}/PLCallbackMapform.class +${class_root}/PLCallbackLabel.class ) set( @@ -96,7 +99,8 @@ ${class_root}/plplotjavacConstants.class ${class_root}/config.class ${class_root}/plplotjavac.class -${class_root}/PLCallback.class +${class_root}/PLCallbackMapform.class +${class_root}/PLCallbackLabel.class ) # This is currently the include list for swig, the C wrapper and the Deleted: trunk/bindings/java/PLCallback.java =================================================================== --- trunk/bindings/java/PLCallback.java 2009-08-13 09:53:27 UTC (rev 10240) +++ trunk/bindings/java/PLCallback.java 2009-08-13 13:04:38 UTC (rev 10241) @@ -1,8 +0,0 @@ - -package plplot.core; - -public interface PLCallback -{ - public void mapform(double[] x, double[] y); - public String label(int axis, double value); -}; Added: trunk/bindings/java/PLCallbackLabel.java =================================================================== --- trunk/bindings/java/PLCallbackLabel.java (rev 0) +++ trunk/bindings/java/PLCallbackLabel.java 2009-08-13 13:04:38 UTC (rev 10241) @@ -0,0 +1,7 @@ + +package plplot.core; + +public interface PLCallbackLabel +{ + public String label(int axis, double value); +}; Copied: trunk/bindings/java/PLCallbackMapform.java (from rev 10234, trunk/bindings/java/PLCallback.java) =================================================================== --- trunk/bindings/java/PLCallbackMapform.java (rev 0) +++ trunk/bindings/java/PLCallbackMapform.java 2009-08-13 13:04:38 UTC (rev 10241) @@ -0,0 +1,7 @@ + +package plplot.core; + +public interface PLCallbackMapform +{ + public void mapform(double[] x, double[] y); +}; Property changes on: trunk/bindings/java/PLCallbackMapform.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native Modified: trunk/bindings/java/PLStream.java =================================================================== --- trunk/bindings/java/PLStream.java 2009-08-13 09:53:27 UTC (rev 10240) +++ trunk/bindings/java/PLStream.java 2009-08-13 13:04:38 UTC (rev 10241) @@ -450,12 +450,12 @@ plplotjavac.pllsty(lin); } -public void map(PLCallback mapform, String type, double minlong, double maxlong, double minlat, double maxlat) { +public void map(PLCallbackMapform mapform, String type, double minlong, double maxlong, double minlat, double maxlat) { if (set_stream() == -1) return; plplotjavac.plmap(mapform, type, minlong, maxlong, minlat, maxlat); } -public void meridians(PLCallback mapform, double dlong, double dlat, double minlong, double maxlong, double minlat, double maxlat) { +public void meridians(PLCallbackMapform mapform, double dlong, double dlat, double minlong, double maxlong, double minlat, double maxlat) { if (set_stream() == -1) return; plplotjavac.plmeridians(mapform, dlong, dlat, minlong, maxlong, minlat, maxlat); } @@ -749,6 +749,16 @@ max_color, max_width, rectangular, pltr, OBJECT_DATA); } +public void slabelfunc(PLCallbackLabel label, Object obj) { + if (set_stream() == -1) return; + plplotjavac.plslabelfunc(label,obj); +} + +public void slabelfunc(PLCallbackLabel label) { + if (set_stream() == -1) return; + plplotjavac.plslabelfunc(label,null); +} + public void smaj(double def, double scale) { if (set_stream() == -1) return; plplotjavac.plsmaj(def, scale); Modified: trunk/bindings/java/plplotjavac.i =================================================================== --- trunk/bindings/java/plplotjavac.i 2009-08-13 09:53:27 UTC (rev 10240) +++ trunk/bindings/java/plplotjavac.i 2009-08-13 13:04:38 UTC (rev 10241) @@ -1149,7 +1149,7 @@ JNIEnv *cbenv; /* C mapform callback function which calls the java - * mapform function in a PLCallback object. */ + * mapform function in a PLCallbackMapform object. */ void mapform_java(PLINT n, PLFLT *x, PLFLT *y) { jdoubleArray jx = setup_java_array_1d_PLFLT(cbenv,x,n); jdoubleArray jy = setup_java_array_1d_PLFLT(cbenv,y,n); @@ -1178,8 +1178,8 @@ } %typemap(jni) mapform_func "jobject" -%typemap(jtype) mapform_func "PLCallback" -%typemap(jstype) mapform_func "PLCallback" +%typemap(jtype) mapform_func "PLCallbackMapform" +%typemap(jstype) mapform_func "PLCallbackMapform" %typemap(javain) mapform_func mapform "$javainput" %{ @@ -1189,43 +1189,54 @@ JNIEnv *cbenv; /* C label plotting callback function which calls the java - * label function in a PLCallback object. */ + * label function in a PLCallbackLabel object. */ void label_java(PLINT axis, PLFLT value, char *string, PLINT len, PLPointer data) { jstring javaString; const char *nativeString; + jint jaxis; + jdouble jvalue; - javaString = (*cbenv)->CallObjectMethod(cbenv,labelClass, labelID, axis, value); + jaxis = (jint) axis; + jvalue = (jdouble) value; + /* javaString = (jstring)(*cbenv)->CallObjectMethod(cbenv,labelClass, labelID, jaxis, jvalue); nativeString = (*cbenv)->GetStringUTFChars(cbenv,javaString,0); strncpy(string,nativeString,len); - (*cbenv)->ReleaseStringUTFChars(cbenv,javaString,nativeString); + (*cbenv)->ReleaseStringUTFChars(cbenv,javaString,nativeString);*/ + strncpy(string,"",len); } %} /* Handle function pointers to label function using an java class */ -%typemap(in) (label_func lf, PLPointer data) { +%typemap(in) label_func lf { jobject obj = $input; if (obj != NULL) { jclass cls = (*jenv)->GetObjectClass(jenv,obj); - labelID = (*jenv)->GetMethodID(jenv,cls, "label","([I[D)Ljava/lang/String" ); + labelID = (*jenv)->GetMethodID(jenv,cls, "label","(ID)Ljava/lang/String;" ); labelClass = obj; cbenv = jenv; $1 = label_java; - $2 = NULL; } else { $1 = NULL; - $2 = NULL; } } -%typemap(jni) (label_func lf, PLPointer data) "jobject" -%typemap(jtype) (label_func lf, PLPointer data) "PLCallback" -%typemap(jstype) (label_func lf, PLPointer data) "PLCallback" -%typemap(javain) (label_func lf, PLPointer data) "$javainput" +%typemap(jni) label_func lf "jobject" +%typemap(jtype) label_func lf "PLCallbackLabel" +%typemap(jstype) label_func lf "PLCallbackLabel" +%typemap(javain) label_func lf "$javainput" +%typemap(in) PLPointer data { + $1 = NULL; +} +%typemap(jni) PLPointer data "jobject" +%typemap(jtype) PLPointer data "Object" +%typemap(jstype) PLPointer data "Object" +%typemap(javain) PLPointer data "$javainput" + /* Second of two object arrays, where we check X and Y with previous object. */ %typemap(in) PLPointer OBJECT_DATA { jPLFLT **adat; Modified: trunk/bindings/swig-support/plplotcapi.i =================================================================== --- trunk/bindings/swig-support/plplotcapi.i 2009-08-13 09:53:27 UTC (rev 10240) +++ trunk/bindings/swig-support/plplotcapi.i 2009-08-13 13:04:38 UTC (rev 10241) @@ -100,6 +100,11 @@ #define PLSWIN_DEVICE 1 /* device coordinates */ #define PLSWIN_WORLD 2 /* world coordinates */ +/* Axis label tags */ +#define PL_X_AXIS 1 /* The x-axis */ +#define PL_Y_AXIS 2 /* The y-axis */ +#define PL_Z_AXIS 3 /* The z-axis */ + /* PLplot Option table & support constants */ /* Option-specific settings */ Modified: trunk/examples/java/x19.java =================================================================== --- trunk/examples/java/x19.java 2009-08-13 09:53:27 UTC (rev 10240) +++ trunk/examples/java/x19.java 2009-08-13 13:04:38 UTC (rev 10241) @@ -31,7 +31,7 @@ import java.lang.Math; -class Mapform19 implements PLCallback { +class Mapform19 implements PLCallbackMapform { public void mapform(double[] x, double[] y) { int i; @@ -49,6 +49,70 @@ } +class LabelFunc19 implements PLCallbackLabel { + + // A custom axis labeling function for longitudes and latitudes. + public String label(int axis, double value) { + String label = ""; + String direction_label = ""; + double label_val = 0.0; + + System.err.println("Entered callback function"); + if (axis == PLStream.PL_Y_AXIS) { + label_val = value; + if (label_val > 0.0) { + direction_label = " N"; + } + else if (label_val < 0.0) { + direction_label = " S"; + } + else { + direction_label = "Eq"; + } + } + else if (axis == PLStream.PL_X_AXIS) { + label_val = normalize_longitude(value); + if (label_val > 0.0) { + direction_label = " E"; + } + else if (label_val < 0.0) { + direction_label = " W"; + } + else { + direction_label = ""; + } + } + if (axis == PLStream.PL_Y_AXIS && value == 0.0) { + /* A special case for the equator */ + label = direction_label; + } + else { + label = ""+((int)Math.abs(label_val))+direction_label; + } + return label; + } + + // "Normalize" longitude values so that they always fall between -180.0 + // and 180.0 + double normalize_longitude(double lon) { + double times; + + if (lon >= -180.0 && lon <= 180.0) { + return(lon); + } + else { + times = Math.floor ((Math.abs(lon) + 180.0) / 360.0); + if (lon < 0.0) { + return(lon + 360.0 * times); + } + else { + return(lon - 360.0 * times); + } + } + } + +} + class x19 { PLStream pls = new PLStream(); @@ -61,7 +125,9 @@ public x19 (String[] args) { double minx, maxx, miny,maxy; - PLCallback nullCallback = null; + PLCallbackMapform nullCallback = null; + PLCallbackLabel nullLabelCallback = null; + LabelFunc19 geolocation_labeler = new LabelFunc19(); // Parse and process command line arguments. pls.parseopts( args, PLStream.PL_PARSE_FULL | PLStream.PL_PARSE_NOPROGRAM ); @@ -79,8 +145,11 @@ minx = 190; maxx = 190+360; + // Setup a custom latitude and longitude-based scaling function. + pls.slabelfunc(geolocation_labeler); + pls.col0(1); - pls.env(minx, maxx, miny, maxy, 1, -1); + pls.env(minx, maxx, miny, maxy, 1, 70); pls.map(nullCallback, "usaglobe", minx, maxx, miny, maxy); // The Americas @@ -89,9 +158,12 @@ maxx = 340; pls.col0(1); - pls.env(minx, maxx, miny, maxy, 1, -1); + pls.env(minx, maxx, miny, maxy, 1, 70); pls.map(nullCallback, "usaglobe", minx, maxx, miny, maxy); + // Clear the labelling function. + pls.slabelfunc(nullLabelCallback); + // Polar, Northern hemisphere // Create callback object containing mapform function Modified: trunk/examples/python/xw19.py =================================================================== --- trunk/examples/python/xw19.py 2009-08-13 09:53:27 UTC (rev 10240) +++ trunk/examples/python/xw19.py 2009-08-13 13:04:38 UTC (rev 10241) @@ -53,7 +53,7 @@ ## A custom axis labeling function for longitudes and latitudes. def geolocation_labeler(axis, value, data): - if (axis == 2) : + if (axis == PL_Y_AXIS) : label_val = value if (label_val > 0.0) : direction_label = " N" @@ -62,7 +62,7 @@ else : direction_label = "Eq" - elif (axis == 1) : + elif (axis == PL_X_AXIS) : label_val = normalize_longitude(value) if (label_val > 0.0) : direction_label = " E" @@ -71,7 +71,7 @@ else : direction_label = "" - if (axis == 2 and value == 0.0) : + if (axis == PL_Y_AXIS and value == 0.0) : # A special case for the equator label = direction_label else : This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sm...@us...> - 2009-08-13 13:24:27
|
Revision: 10242 http://plplot.svn.sourceforge.net/plplot/?rev=10242&view=rev Author: smekal Date: 2009-08-13 13:24:19 +0000 (Thu, 13 Aug 2009) Log Message: ----------- Fixed D examples x01 and x12. Modified Paths: -------------- trunk/bindings/d/plplot.d trunk/examples/d/x12d.d Modified: trunk/bindings/d/plplot.d =================================================================== --- trunk/bindings/d/plplot.d 2009-08-13 13:04:38 UTC (rev 10241) +++ trunk/bindings/d/plplot.d 2009-08-13 13:24:19 UTC (rev 10242) @@ -2,6 +2,7 @@ module plplot; private import std.string; +private import std.c.stdlib; // improved D interface @@ -250,17 +251,19 @@ /* Get the current device (keyword) name */ void plgdev(out string p_dev) { - char[1024] temp; - c_plgdev(temp.ptr); - p_dev=toString(temp.ptr); + char* temp = cast(char*)malloc(1024); + c_plgdev(temp); + p_dev=toString(temp); + free(temp); } /* Get the (current) output file name. Must be preallocated to >80 bytes */ void plgfnam(out string fnam) { - char[1024] temp; - c_plgfnam(temp.ptr); - fnam=toString(temp.ptr); + char* temp = cast(char*)malloc(1024); + c_plgfnam(temp); + fnam=toString(temp); + free(temp); } /* grid irregularly sampled data */ @@ -281,9 +284,10 @@ /* Get the current library version number */ void plgver(out string p_ver) { - char[1024] temp; - c_plgver(temp.ptr); - p_ver=toString(temp.ptr); + char* temp = cast(char*)malloc(1024); + c_plgver(temp); + p_ver=toString(temp); + free(temp); } /* Draws a histogram of n values of a variable in array data[0..n-1] */ Modified: trunk/examples/d/x12d.d =================================================================== --- trunk/examples/d/x12d.d 2009-08-13 13:04:38 UTC (rev 10241) +++ trunk/examples/d/x12d.d 2009-08-13 13:24:19 UTC (rev 10242) @@ -1,4 +1,4 @@ -/* +/* $Id:$ Bar chart demo. */ @@ -16,7 +16,6 @@ int main(char[][] args) { string text; - PLFLT[10] y0; /* Parse and process command line arguments */ plparseopts(args, PL_PARSE_FULL); @@ -31,10 +30,15 @@ plcol0( 2 ); pllab( "Year", "Widget Sales (millions)", "#frPLplot Example 12" ); - y0[] = [5.0, 15.0, 12.0, 24.0, 28.0, 30.0, 20.0, 8.0, 12.0, 3.0]; + PLFLT[] pos = [ 0.0, 0.25, 0.5, 0.75, 1.0 ]; + PLFLT[] red = [ 0.0, 0.25, 0.5, 1.0, 1.0 ]; + PLFLT[] green = [ 1.0, 0.5, 0.5, 0.5, 1.0 ]; + PLFLT[] blue = [ 1.0, 1.0, 0.5, 0.25, 0.0 ]; + plscmap1l( 1, pos, red, green, blue ); + PLFLT[] y0 = [ 5.0, 15.0, 12.0, 24.0, 28.0, 30.0, 20.0, 8.0, 12.0, 3.0 ]; for( size_t i=0; i<10; i++ ) { - plcol0( i+1 ); + plcol1( i/9.0 ); plpsty( 0 ); plfbox( (1980.+i), y0[i] ); text = format( "%.0f", y0[i] ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sm...@us...> - 2009-08-13 19:17:04
|
Revision: 10244 http://plplot.svn.sourceforge.net/plplot/?rev=10244&view=rev Author: smekal Date: 2009-08-13 19:16:56 +0000 (Thu, 13 Aug 2009) Log Message: ----------- Fixed D example 14. Fixed memory bugs in plplot.d introduced in the last commits regarding plgver(), etc. Modified Paths: -------------- trunk/bindings/d/plplot.d trunk/examples/d/x14d.d trunk/plplot_test/test_d.sh.in Modified: trunk/bindings/d/plplot.d =================================================================== --- trunk/bindings/d/plplot.d 2009-08-13 18:25:21 UTC (rev 10243) +++ trunk/bindings/d/plplot.d 2009-08-13 19:16:56 UTC (rev 10244) @@ -2,7 +2,6 @@ module plplot; private import std.string; -private import std.c.stdlib; // improved D interface @@ -251,19 +250,17 @@ /* Get the current device (keyword) name */ void plgdev(out string p_dev) { - char* temp = cast(char*)malloc(1024); - c_plgdev(temp); - p_dev=toString(temp); - free(temp); + p_dev.length = 1024; + c_plgdev(p_dev.ptr); + p_dev=toString(p_dev.ptr); } /* Get the (current) output file name. Must be preallocated to >80 bytes */ void plgfnam(out string fnam) { - char* temp = cast(char*)malloc(1024); - c_plgfnam(temp); - fnam=toString(temp); - free(temp); + fnam.length = 1024; + c_plgfnam(fnam.ptr); + fnam=toString(fnam.ptr); } /* grid irregularly sampled data */ @@ -284,10 +281,9 @@ /* Get the current library version number */ void plgver(out string p_ver) { - char* temp = cast(char*)malloc(1024); - c_plgver(temp); - p_ver=toString(temp); - free(temp); + p_ver.length = 1024; + c_plgver(p_ver.ptr); + p_ver=toString(p_ver.ptr); } /* Draws a histogram of n values of a variable in array data[0..n-1] */ Modified: trunk/examples/d/x14d.d =================================================================== --- trunk/examples/d/x14d.d 2009-08-13 18:25:21 UTC (rev 10243) +++ trunk/examples/d/x14d.d 2009-08-13 19:16:56 UTC (rev 10244) @@ -140,18 +140,28 @@ } +/* special variables for plot5() and mypltr */ +const int XPTS=35; +const int YPTS=46; +const double XSPA=2.0/(XPTS-1); +const double YSPA=2.0/(YPTS-1); + +/* Transformation function */ +extern (C) { + PLFLT[] tr = [ XSPA, 0.0, -1.0, 0.0, YSPA, -1.0 ]; + + void mypltr(PLFLT x, PLFLT y, PLFLT* tx, PLFLT* ty, void* pltr_data) + { + *tx = tr[0]*x + tr[1]*y + tr[2]; + *ty = tr[3]*x + tr[4]*y + tr[5]; + } +} + class plot { private PLFLT[] x, y, x0, y0; private PLFLT[6] xs, ys; private PLINT[1] space1 = [ 1500 ], mark1 = [ 1500 ]; - // special variables for plot5() and mypltr - private const int XPTS=35; - private const int YPTS=46; - private const double XSPA=2.0/(XPTS-1); - private const double YSPA=2.0/(YPTS-1); - private PLFLT[6] tr = [ XSPA, 0.0, -1.0, 0.0, YSPA, -1.0 ]; - public void plot1(PLFLT xscale, PLFLT yscale, PLFLT xoff, PLFLT yoff) { x.length=60; @@ -316,15 +326,9 @@ /* =============================================================== */ /* Demonstration of contour plotting */ - private void mypltr(PLFLT x, PLFLT y, PLFLT *tx, PLFLT *ty, void *pltr_data) - { - *tx = tr[0]*x + tr[1]*y + tr[2]; - *ty = tr[3]*x + tr[4]*y + tr[5]; - } - public void plot5() { - PLFLT[11] clevel = [ -1., -.8, -.6, -.4, -.2, 0, .2, .4, .6, .8, 1. ]; + PLFLT[] clevel = [ -1., -.8, -.6, -.4, -.2, 0, .2, .4, .6, .8, 1. ]; /* Set up function arrays */ PLFLT[][] z, w; @@ -343,10 +347,10 @@ plenv(-1.0, 1.0, -1.0, 1.0, 0, 0); plcol0(2); - //plcont(z, 1, XPTS, 1, YPTS, clevel, mypltr, null); + plcont(z, 1, XPTS, 1, YPTS, clevel, &mypltr); plstyl(mark1, space1); plcol0(3); - //plcont(w, 1, XPTS, 1, YPTS, clevel, mypltr, null); + plcont(w, 1, XPTS, 1, YPTS, clevel, &mypltr); plcol0(1); pllab("X Coordinate", "Y Coordinate", "Streamlines of flow"); plflush(); Modified: trunk/plplot_test/test_d.sh.in =================================================================== --- trunk/plplot_test/test_d.sh.in 2009-08-13 18:25:21 UTC (rev 10243) +++ trunk/plplot_test/test_d.sh.in 2009-08-13 19:16:56 UTC (rev 10244) @@ -31,7 +31,7 @@ # 20-22, 28, and 31 not implemented yet. # example 14 excluded until plgdev fixed since the bad driver information # causes run-time errors. -for index in 01 02 03 04 05 06 07 08 09 10 11 12 13 15 16 17 18 19 23 24 25 26 27 29 30; do +for index in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 23 24 25 26 27 29 30; do if [ "$verbose_test" ] ; then echo "x${index}${lang}" fi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sm...@us...> - 2009-08-13 19:57:34
|
Revision: 10245 http://plplot.svn.sourceforge.net/plplot/?rev=10245&view=rev Author: smekal Date: 2009-08-13 19:57:21 +0000 (Thu, 13 Aug 2009) Log Message: ----------- Added plarc() to D bindings. Fixed D examples 2 and 3. Modified Paths: -------------- trunk/bindings/d/plplot.d trunk/examples/d/x02d.d trunk/examples/d/x03d.d Modified: trunk/bindings/d/plplot.d =================================================================== --- trunk/bindings/d/plplot.d 2009-08-13 19:16:56 UTC (rev 10244) +++ trunk/bindings/d/plplot.d 2009-08-13 19:57:21 UTC (rev 10245) @@ -1156,6 +1156,7 @@ //alias c_plbox plbox; //alias c_plbox3 plbox3; alias c_plcalc_world plcalc_world; +alias c_plarc plarc; alias c_plclear plclear; alias c_plcol0 plcol0; alias c_plcol1 plcol1; @@ -1359,11 +1360,17 @@ void c_plbox(char *xopt, PLFLT xtick, PLINT nxsub, char *yopt, PLFLT ytick, PLINT nysub); /* This is the 3-d analogue of plbox(). */ -void c_plbox3(char *xopt, char *xlabel, PLFLT xtick, PLINT nsubx, char *yopt, char *ylabel, PLFLT ytick, PLINT nsuby, char *zopt, char *zlabel, PLFLT ztick, PLINT nsubz); +void c_plbox3(char *xopt, char *xlabel, PLFLT xtick, PLINT nsubx, char *yopt, + char *ylabel, PLFLT ytick, PLINT nsuby, char *zopt, char *zlabel, + PLFLT ztick, PLINT nsubz); /* Calculate world coordinates and subpage from relative device coordinates. */ void c_plcalc_world(PLFLT rx, PLFLT ry, PLFLT *wx, PLFLT *wy, PLINT *window); +/* Plot an arc */ +void c_plarc(PLFLT x, PLFLT y, PLFLT a, PLFLT b, PLFLT angle1, PLFLT angle2, + PLBOOL fill); + /* Clear current subpage. */ void c_plclear(); Modified: trunk/examples/d/x02d.d =================================================================== --- trunk/examples/d/x02d.d 2009-08-13 19:16:56 UTC (rev 10244) +++ trunk/examples/d/x02d.d 2009-08-13 19:57:21 UTC (rev 10245) @@ -79,7 +79,7 @@ PLFLT h = (360./10.)*(i%10); /* Vary lightness uniformly from top to bottom, between min & max */ - PLFLT l = lmin + (lmax-lmin)*(i/10)/9.; + PLFLT l = lmin + (lmax-lmin)*(i/10)/9.0; /* Use max saturation */ PLFLT s = 1.0; @@ -87,9 +87,10 @@ PLFLT r1, g1, b1; plhlsrgb(h, l, s, &r1, &g1, &b1); - r[i+16] = cast(PLINT)(r1*255); - g[i+16] = cast(PLINT)(g1*255); - b[i+16] = cast(PLINT)(b1*255); + /* Use 255.001 to avoid close truncation decisions in this example. */ + r[i+16] = cast(PLINT)(r1*255.001); + g[i+16] = cast(PLINT)(g1*255.001); + b[i+16] = cast(PLINT)(b1*255.001); } /* Load default cmap0 colors into our custom set */ Modified: trunk/examples/d/x03d.d =================================================================== --- trunk/examples/d/x03d.d 2009-08-13 19:16:56 UTC (rev 10244) +++ trunk/examples/d/x03d.d 2009-08-13 19:57:21 UTC (rev 10245) @@ -16,7 +16,8 @@ int main(char[][] args) { PLFLT dtr = PI/180.0; - PLFLT[361] x0, y0; + PLFLT[] x0, y0; + x0.length = y0.length = 361; for(size_t i=0; i<x0.length; i++) { x0[i] = cos(dtr*i); y0[i] = sin(dtr*i); @@ -35,17 +36,10 @@ /* Set up viewport and window, but do not draw box */ plenv(-1.3, 1.3, -1.3, 1.3, 1, -2); - PLFLT[361] x, y; - for(size_t i=1; i<=10; i++) { - for(size_t j=0; j<x.length; j++) { - x[j] = 0.1*i*x0[j]; - y[j] = 0.1*i*y0[j]; - } + /* Draw circles for polar grid */ + for(size_t i=1; i<11; i++) + plarc(0.0, 0.0, 0.1*i, 0.1*i, 0.0, 360.0, 0); - /* Draw circles for polar grid */ - plline(x, y); - } - plcol0(2); for(size_t i=0; i<=11; i++) { PLFLT theta = 30.0*i; @@ -75,6 +69,8 @@ /* Draw the graph */ PLFLT r; + PLFLT[] x, y; + x.length = y.length = 361; for(size_t i=0; i<x.length; i++) { r = sin(dtr*(5*i)); x[i] = x0[i]*r; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-08-13 23:49:07
|
Revision: 10247 http://plplot.svn.sourceforge.net/plplot/?rev=10247&view=rev Author: airwin Date: 2009-08-13 23:48:59 +0000 (Thu, 13 Aug 2009) Log Message: ----------- To avoid contamination of all builds with qt flags, use CMake include(${QT_USE_FILE}) command only for subdirectories and conditions where it is needed rather than (implicitly) in the top-level directory. Modified Paths: -------------- trunk/bindings/qt_gui/CMakeLists.txt trunk/cmake/modules/qt.cmake trunk/drivers/CMakeLists.txt trunk/src/CMakeLists.txt Modified: trunk/bindings/qt_gui/CMakeLists.txt =================================================================== --- trunk/bindings/qt_gui/CMakeLists.txt 2009-08-13 20:01:31 UTC (rev 10246) +++ trunk/bindings/qt_gui/CMakeLists.txt 2009-08-13 23:48:59 UTC (rev 10247) @@ -19,6 +19,11 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA if(ENABLE_qt) + # Set up Qt4-based build environment. + include(${QT_USE_FILE}) + if(NOT QT_LIBRARIES) + message(FATAL_ERROR "include(${QT_USE_FILE}) failed in bindings/qt_gui subdirectory.") + endif(NOT QT_LIBRARIES) set(qt_SOURCE plqt.cpp) include_directories( ${CMAKE_SOURCE_DIR}/include @@ -46,12 +51,11 @@ else(ANY_QT_DEVICE) message(FATAL_ERROR "Internal build system inconsistency between ENABLE_qt true and ANY_QT_DEVICE false.") endif(ANY_QT_DEVICE) - #message("qt_LINK_FLAGS = ${qt_LINK_FLAGS}") target_link_libraries( plplotqt${LIB_TAG} plplot${LIB_TAG} ${MATH_LIB} - ${qt_LINK_FLAGS} + ${QT_LIBRARIES} ) # qt_RPATH set in cmake/modules/qt.cmake. This is only used for the # install-tree rpath since cmake handles the build-tree rpath @@ -91,11 +95,10 @@ FILE export_plplotqt.cmake ) - # Transform "${qt_LINK_FLAGS}" to the - # standard pkg-config form. + # Transform "${QT_LIBRARIES}" to the standard pkg-config form. pkg_config_link_flags( libplplotqt${LIB_TAG}_LINK_FLAGS - "${qt_LINK_FLAGS}" + "${QT_LIBRARIES}" ) # Configure pkg-config *.pc file corresponding to the compile and link @@ -120,7 +123,7 @@ # 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}") + set(PC_DATA "qt:Qt:Qt4 bindings, :plplotqt${LIB_TAG}") string(REGEX REPLACE "^(.*):.*:.*:.*$" "\\1" BINDING ${PC_DATA}) set(PC_FILE_SUFFIX "-${BINDING}") Modified: trunk/cmake/modules/qt.cmake =================================================================== --- trunk/cmake/modules/qt.cmake 2009-08-13 20:01:31 UTC (rev 10246) +++ trunk/cmake/modules/qt.cmake 2009-08-13 23:48:59 UTC (rev 10247) @@ -69,24 +69,19 @@ 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}) - endif(QT4_FOUND) - if(QT4_FOUND AND QT_LIBRARIES) + # Do not include(${QT_USE_FILE}) here because it contaminates ALL + # build environments with Qt flags from the top-level directory on + # down. Instead include(${QT_USE_FILE}) only in certain subdirectories + # where it is necessary. set(qt_COMPILE_FLAGS) foreach(DIR ${QT_INCLUDES}) set(qt_COMPILE_FLAGS "${qt_COMPILE_FLAGS} -I${DIR}") endforeach(DIR ${QT_INCLUDES}) - message(STATUS "QT_LIBRARIES = ${QT_LIBRARIES}") - - set(qt_LINK_FLAGS ${QT_LIBRARIES}) - #message("qt_LINK_FLAGS = ${qt_LINK_FLAGS}") + set(qt_LINK_FLAGS) set(qt_RPATH ${QT_LIBRARY_DIR}) #message("qt_LIBRARY_DIR = ${qt_LIBRARY_DIR}") - else(QT4_FOUND AND QT_LIBRARIES) - message(STATUS "QT_LIBRARIES not found so disabling all qt devices") - set(ANY_QT_DEVICE OFF) - endif(QT4_FOUND AND QT_LIBRARIES) + endif(QT4_FOUND) endif(ANY_QT_DEVICE) if(NOT ANY_QT_DEVICE) Modified: trunk/drivers/CMakeLists.txt =================================================================== --- trunk/drivers/CMakeLists.txt 2009-08-13 20:01:31 UTC (rev 10246) +++ trunk/drivers/CMakeLists.txt 2009-08-13 23:48:59 UTC (rev 10247) @@ -82,34 +82,50 @@ PROPERTIES COMPILE_FLAGS "-DUSINGDLL" ) endif(${SOURCE_ROOT_NAME}_COMPILE_FLAGS) + + # ${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, + # but that way of doing things only works on Unix, and even for Unix, + # cmake does not correctly set the rpath for the build tree results + # for non-standard locations with the -L and -l forms. + #message("${SOURCE_ROOT_NAME}_LINK_FLAGS = ${${SOURCE_ROOT_NAME}_LINK_FLAGS}") + # ${SOURCE_ROOT_NAME}_TARGETS is a list of PLplot CMake targets that the + # device driver depends on. + #message("${SOURCE_ROOT_NAME}_TARGETS = ${${SOURCE_ROOT_NAME}_TARGETS}") + if(SOURCE_ROOT_NAME STREQUAL "qt" AND NOT ENABLE_qt) if(ANY_QT_DEVICE) add_library(${SOURCE_ROOT_NAME} MODULE ${${SOURCE_ROOT_NAME}_SOURCE}) add_dependencies(${SOURCE_ROOT_NAME} moc_outfile_generated) + # Set up Qt4-based build environment. + include(${QT_USE_FILE}) + if(NOT QT_LIBRARIES) + message(FATAL_ERROR "include(${QT_USE_FILE}) failed in drivers subdirectory.") + endif(NOT QT_LIBRARIES) + + target_link_libraries( + ${SOURCE_ROOT_NAME} + plplot${LIB_TAG} + ${MATH_LIB} + ${${SOURCE_ROOT_NAME}_LINK_FLAGS} + ${${SOURCE_ROOT_NAME}_TARGETS} + ${QT_LIBRARIES} + ) else(ANY_QT_DEVICE) message(FATAL_ERROR "Internal build system inconsistency. Attempt to build dynamic qt device when ANY_QT_DEVICE is false.") endif(ANY_QT_DEVICE) else(SOURCE_ROOT_NAME STREQUAL "qt" AND NOT ENABLE_qt) add_library(${SOURCE_ROOT_NAME} MODULE ${${SOURCE_ROOT_NAME}_SOURCE}) + target_link_libraries( + ${SOURCE_ROOT_NAME} + plplot${LIB_TAG} + ${MATH_LIB} + ${${SOURCE_ROOT_NAME}_LINK_FLAGS} + ${${SOURCE_ROOT_NAME}_TARGETS} + ) endif(SOURCE_ROOT_NAME STREQUAL "qt" AND NOT ENABLE_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, - # but that way of doing things only works on Unix, and even for Unix, - # cmake does not correctly set the rpath for the build tree results - # for non-standard locations with the -L and -l forms. - #message("${SOURCE_ROOT_NAME}_LINK_FLAGS = ${${SOURCE_ROOT_NAME}_LINK_FLAGS}") - # ${SOURCE_ROOT_NAME}_TARGETS is a list of PLplot CMake targets that the - # device driver depends on. - #message("${SOURCE_ROOT_NAME}_TARGETS = ${${SOURCE_ROOT_NAME}_TARGETS}") - target_link_libraries( - ${SOURCE_ROOT_NAME} - plplot${LIB_TAG} - ${MATH_LIB} - ${${SOURCE_ROOT_NAME}_LINK_FLAGS} - ${${SOURCE_ROOT_NAME}_TARGETS} - ) # ${SOURCE_ROOT_NAME}_RPATH originally set in cmake/modules files for # each driver in ${DRIVERS_LIST}. This is only used for the # install-tree rpath since cmake handles the build-tree rpath Modified: trunk/src/CMakeLists.txt =================================================================== --- trunk/src/CMakeLists.txt 2009-08-13 20:01:31 UTC (rev 10246) +++ trunk/src/CMakeLists.txt 2009-08-13 23:48:59 UTC (rev 10247) @@ -106,6 +106,14 @@ # For this case libplot must have a target dependency on the # moc files generated in the binary include directory. set(qt_dependency moc_outfile_generated) + + # Set up Qt4-based build environment. + include(${QT_USE_FILE}) + if(NOT QT_LIBRARIES) + message(FATAL_ERROR "include(${QT_USE_FILE}) failed in src subdirectory.") + endif(NOT QT_LIBRARIES) + set(DRIVERS_LINK_FLAGS ${DRIVERS_LINK_FLAGS} ${QT_LIBRARIES}) + else(ANY_QT_DEVICE) message(FATAL_ERROR "Internal build system inconsistency. Attempt to build static qt device when ANY_QT_DEVICE is false.") endif(ANY_QT_DEVICE) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2009-08-14 21:31:26
|
Revision: 10253 http://plplot.svn.sourceforge.net/plplot/?rev=10253&view=rev Author: andrewross Date: 2009-08-14 21:30:58 +0000 (Fri, 14 Aug 2009) Log Message: ----------- Fix java support for plspal0 and plspal1. Enable callback for plotting custom labels. This does not work with openjdk 6 for me (a bug? - it crashes with an erro) but does work with the gcj compiler. Further testing appreciated. Update examples 16 and 19 consistent with C version. Modified Paths: -------------- trunk/bindings/java/PLStream.java trunk/bindings/java/plplotjavac.i trunk/examples/java/x16.java trunk/examples/java/x19.java Modified: trunk/bindings/java/PLStream.java =================================================================== --- trunk/bindings/java/PLStream.java 2009-08-14 20:49:51 UTC (rev 10252) +++ trunk/bindings/java/PLStream.java 2009-08-14 21:30:58 UTC (rev 10253) @@ -779,6 +779,16 @@ plplotjavac.plspage(xp, yp, xleng, yleng, xoff, yoff); } +public void spal0(String filename) { + if (set_stream() == -1) return; + plplotjavac.plspal0(filename); +} + +public void spal1(String filename) { + if (set_stream() == -1) return; + plplotjavac.plspal1(filename); +} + public void spause(boolean pause) { if (set_stream() == -1) return; plplotjavac.plspause(pause); Modified: trunk/bindings/java/plplotjavac.i =================================================================== --- trunk/bindings/java/plplotjavac.i 2009-08-14 20:49:51 UTC (rev 10252) +++ trunk/bindings/java/plplotjavac.i 2009-08-14 21:30:58 UTC (rev 10253) @@ -1198,11 +1198,11 @@ jaxis = (jint) axis; jvalue = (jdouble) value; - /* javaString = (jstring)(*cbenv)->CallObjectMethod(cbenv,labelClass, labelID, jaxis, jvalue); + javaString = (jstring)(*cbenv)->CallObjectMethod(cbenv,labelClass, labelID, jaxis, jvalue); nativeString = (*cbenv)->GetStringUTFChars(cbenv,javaString,0); strncpy(string,nativeString,len); - (*cbenv)->ReleaseStringUTFChars(cbenv,javaString,nativeString);*/ - strncpy(string,"",len); + (*cbenv)->ReleaseStringUTFChars(cbenv,javaString,nativeString); + /*strncpy(string,"",len);*/ } %} Modified: trunk/examples/java/x16.java =================================================================== --- trunk/examples/java/x16.java 2009-08-14 20:49:51 UTC (rev 10252) +++ trunk/examples/java/x16.java 2009-08-14 21:30:58 UTC (rev 10253) @@ -92,6 +92,9 @@ // Parse and process command line arguments. pls.parseopts( args, PLStream.PL_PARSE_FULL | PLStream.PL_PARSE_NOPROGRAM ); + // Load colour palettes + pls.spal0("cmap0_black_on_white.pal"); + pls.spal1("cmap1_gray.pal"); // Reduce colors in cmap 0 so that cmap 1 is useful on a //16-color display pls.scmap0n(3); @@ -166,6 +169,13 @@ // Plot using 1d coordinate transform + // Load colour palettes + pls.spal0("cmap0_black_on_white.pal"); + pls.spal1("cmap1_blue_yellow.pal"); + // Reduce colors in cmap 0 so that cmap 1 is useful on a + //16-color display + pls.scmap0n(3); + pls.adv(0); pls.vpor(0.1, 0.9, 0.1, 0.9); pls.wind(-1.0, 1.0, -1.0, 1.0); @@ -185,6 +195,13 @@ // Plot using 2d coordinate transform + // Load colour palettes + pls.spal0("cmap0_black_on_white.pal"); + pls.spal1("cmap1_blue_red.pal"); + // Reduce colors in cmap 0 so that cmap 1 is useful on a + //16-color display + pls.scmap0n(3); + pls.adv(0); pls.vpor(0.1, 0.9, 0.1, 0.9); pls.wind(-1.0, 1.0, -1.0, 1.0); @@ -205,6 +222,13 @@ // Plot using 2d coordinate transform + // Load colour palettes + pls.spal0(""); + pls.spal1(""); + // Reduce colors in cmap 0 so that cmap 1 is useful on a + //16-color display + pls.scmap0n(3); + pls.adv(0); pls.vpor(0.1, 0.9, 0.1, 0.9); pls.wind(-1.0, 1.0, -1.0, 1.0); @@ -228,6 +252,13 @@ //Example with polar coordinates. + // Load colour palettes + pls.spal0("cmap0_black_on_white.pal"); + pls.spal1("cmap1_gray.pal"); + // Reduce colors in cmap 0 so that cmap 1 is useful on a + //16-color display + pls.scmap0n(3); + pls.adv(0); pls.vpor( .1, .9, .1, .9 ); pls.wind( -1., 1., -1., 1. ); Modified: trunk/examples/java/x19.java =================================================================== --- trunk/examples/java/x19.java 2009-08-14 20:49:51 UTC (rev 10252) +++ trunk/examples/java/x19.java 2009-08-14 21:30:58 UTC (rev 10253) @@ -57,7 +57,6 @@ String direction_label = ""; double label_val = 0.0; - System.err.println("Entered callback function"); if (axis == PLStream.PL_Y_AXIS) { label_val = value; if (label_val > 0.0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-08-15 19:22:16
|
Revision: 10263 http://plplot.svn.sourceforge.net/plplot/?rev=10263&view=rev Author: airwin Date: 2009-08-15 19:22:07 +0000 (Sat, 15 Aug 2009) Log Message: ----------- Retire the hpgl, impress, and ljii devices. Modified Paths: -------------- trunk/README.release trunk/cmake/modules/drivers-init.cmake Modified: trunk/README.release =================================================================== --- trunk/README.release 2009-08-15 16:29:57 UTC (rev 10262) +++ trunk/README.release 2009-08-15 19:22:07 UTC (rev 10263) @@ -81,18 +81,13 @@ to segfaults. The cause of the segfaults was a bug (now fixed) in how pthread support was implemented for the Tk-related components of PLplot. -IX. As of release 5.9.4 we have deprecated the hpgl device driver -(containing the hp7470, hp7580, and lj_hpgl devices). hp7450 and hp7580 -produce many "Invalid pen selection." messages on our standard examples and -lj_hpgl segfaults. - -X. As of release 5.9.4 we have deprecated the pbm device driver (containing +IX. As of release 5.9.4 we have deprecated the pbm device driver (containing the pbm device) because glibc detects a catastrophic double free. -XI. As of release 5.9.5 we have removed pyqt3 access to PLplot and +X. As of release 5.9.5 we have removed pyqt3 access to PLplot and replaced it by pyqt4 access to PLplot (see details below). -XII. As of release 5.9.5 the only method of specifying a non-default compiler +XI. As of release 5.9.5 the only method of specifying a non-default compiler (and associated compiler options) that we support is the environment variable approach, e.g., @@ -104,6 +99,15 @@ compiler options will not be supported until CMake bug 9220 is fixed, see discussion below of the soft-landing reimplementation for details. +XII. As of release 5.9.5 we have retired the hpgl driver (containing the +hp7470, hp7580, and lj_hpgl devices), the impress driver (containing the imp +device), and the ljii driver (containing the ljii and ljiip devices). +Retirement means we have removed the build options which would allow these +devices to build and install. Recent tests have shown a number of run-time +issues with these devices, and as far as we know there is no more user +interest in them. Therefore, we have decided to retire these devices rather +than fix them. + INDEX 1. Changes relative to PLplot 5.9.4 (the previous development release) Modified: trunk/cmake/modules/drivers-init.cmake =================================================================== --- trunk/cmake/modules/drivers-init.cmake 2009-08-15 16:29:57 UTC (rev 10262) +++ trunk/cmake/modules/drivers-init.cmake 2009-08-15 19:22:07 UTC (rev 10263) @@ -114,7 +114,10 @@ "xcairo:cairo:ON" # new example 16 shows severe valgrind issues with this device. "cgm:cgm:OFF" - "dg300:dg300:OFF" + # This unmaintained device driver builds but does not actually work + # (with error message: "Unable to locate dispatch table initialization + # function for driver: dg300.") so retire it. + # "dg300:dg300:OFF" "epsqt:qt:ON" "pdfqt:qt:ON" "qtwidget:qt:ON" @@ -141,18 +144,23 @@ "gcw:gcw:OFF" # Do not implement gnome which is superseded by gcw #"gnome:gnome:OFF" - # Produces ton of "Invalid pen selection." messages - "hp7470:hpgl:OFF" - # Produces ton of "Invalid pen selection." messages - "hp7580:hpgl:OFF" - # Segfaults. - "lj_hpgl:hpgl:OFF" - "imp:impress:OFF" - # Default off because poorly maintained (colours are incorrect) + # hpgl devices produce tons of "Invalid pen selection." messages and the + # lj_hpgl device produces the error message "Unable to locate dispatch + # table initialization function for driver: hpgl." + # Retire this elderly device driver rather than fixing it. + #"hp7470:hpgl:OFF" + #"hp7580:hpgl:OFF" + #"lj_hpgl:hpgl:OFF" + # This unmaintained driver generates double frees for example 14. + # Retire this elderly device driver rather than fixing it. + # "imp:impress:OFF" + # Default off because poorly maintained (e.g., colours are incorrect) # must use software fill, and must run as root. "linuxvga:linuxvga:OFF" - "ljii:ljii:OFF" - "ljiip:ljiip:OFF" + # ljii is unmaintained and both the ljii and ljiip segfault on example 14. + # Retire this elderly device driver rather than fixing it. + #"ljii:ljii:OFF" + #"ljiip:ljiip:OFF" "mem:mem:ON" "ntk:ntk:OFF" "null:null:ON" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-08-16 01:24:43
|
Revision: 10264 http://plplot.svn.sourceforge.net/plplot/?rev=10264&view=rev Author: airwin Date: 2009-08-16 01:24:32 +0000 (Sun, 16 Aug 2009) Log Message: ----------- Drop the #defines of the PLD_* macros from config.h. Thus, from now on use the configured plDevs.h header file exclusively to specify these macros. Modified Paths: -------------- trunk/config.h.cmake trunk/drivers/cairo.c trunk/examples/c++/CMakeLists.txt trunk/include/qt.h Modified: trunk/config.h.cmake =================================================================== --- trunk/config.h.cmake 2009-08-15 19:22:07 UTC (rev 10263) +++ trunk/config.h.cmake 2009-08-16 01:24:32 UTC (rev 10264) @@ -185,180 +185,6 @@ /* Define if the win32 ltdl implementation should be used */ #cmakedefine LTDL_WIN32 -/* Define if aqt driver is present */ -#cmakedefine PLD_aqt - -/* Define if cgm driver is present */ -#cmakedefine PLD_cgm - -/* Define if conex driver is present */ -#cmakedefine PLD_conex - -/* Define if dg300 driver is present */ -#cmakedefine PLD_dg300 - -/* Define if gcw driver is present */ -#cmakedefine PLD_gcw - -/* Define if gif driver is present */ -#cmakedefine PLD_gif - -/* Define if gnome driver is present */ -#cmakedefine PLD_gnome - -/* Define if hp7470 driver is present */ -#cmakedefine PLD_hp7470 - -/* Define if hp7580 driver is present */ -#cmakedefine PLD_hp7580 - -/* Define if imp driver is present */ -#cmakedefine PLD_imp - -/* Define if jpeg driver is present */ -#cmakedefine PLD_jpeg - -/* Define if linuxvga driver is present */ -#cmakedefine PLD_linuxvga - -/* Define if lj_hpgl driver is present */ -#cmakedefine PLD_lj_hpgl - -/* Define if ljii driver is present */ -#cmakedefine PLD_ljii - -/* Define if ljiip driver is present */ -#cmakedefine PLD_ljiip - -/* Define if mem driver is present */ -#cmakedefine PLD_mem - -/* Define if mskermit driver is present */ -#cmakedefine PLD_mskermit - -/* Define if ntk driver is present */ -#cmakedefine PLD_ntk - -/* Define if null driver is present */ -#cmakedefine PLD_null - -/* Define if pbm driver is present */ -#cmakedefine PLD_pbm - -/* Define if pdf driver is present */ -#cmakedefine PLD_pdf - -/* Define if plmeta driver is present */ -#cmakedefine PLD_plmeta - -/* Define if png driver is present */ -#cmakedefine PLD_png - -/* Define if ps driver is present */ -#cmakedefine PLD_ps - -/* Define if pstex driver is present */ -#cmakedefine PLD_pstex - -/* Define if psttf driver is present */ -#cmakedefine PLD_psttf - -/* Define if svg driver is present */ -#cmakedefine PLD_svg - -/* Define if tek4010 driver is present */ -#cmakedefine PLD_tek4010 - -/* Define if tek4010f driver is present */ -#cmakedefine PLD_tek4010f - -/* Define if tek4107 driver is present */ -#cmakedefine PLD_tek4107 - -/* Define if tek4107f driver is present */ -#cmakedefine PLD_tek4107f - -/* Define if tk driver is present */ -#cmakedefine PLD_tk - -/* Define if tkwin driver is present */ -#cmakedefine PLD_tkwin - -/* Define if versaterm driver is present */ -#cmakedefine PLD_versaterm - -/* Define if vlt driver is present */ -#cmakedefine PLD_vlt - -/* Define if wingcc driver is present */ -#cmakedefine PLD_wingcc - -/* Define if wxwidgets driver is present */ -#cmakedefine PLD_wxwidgets - -/* Define if wxwidgets png driver is present */ -#cmakedefine PLD_wxpng - -/* Define if xfig driver is present */ -#cmakedefine PLD_xfig - -/* Define if xterm driver is present */ -#cmakedefine PLD_xterm - -/* 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 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 - -/* 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/cairo.c =================================================================== --- trunk/drivers/cairo.c 2009-08-15 19:22:07 UTC (rev 10263) +++ trunk/drivers/cairo.c 2009-08-16 01:24:32 UTC (rev 10264) @@ -35,6 +35,7 @@ /* PLplot header files (must occur before driver-dependent includes) */ +#include "plDevs.h" #include "plplotP.h" #include "drivers.h" Modified: trunk/examples/c++/CMakeLists.txt =================================================================== --- trunk/examples/c++/CMakeLists.txt 2009-08-15 19:22:07 UTC (rev 10263) +++ trunk/examples/c++/CMakeLists.txt 2009-08-16 01:24:32 UTC (rev 10264) @@ -173,7 +173,6 @@ endif(QT4_FOUND AND QT_VERSION_MAJOR STREQUAL "${CORE_QT_VERSION_MAJOR}" AND QT_VERSION_MINOR STREQUAL "${CORE_QT_VERSION_MINOR}" AND QT_VERSION_PATCH STREQUAL "${CORE_QT_VERSION_PATCH}") endif(CORE_BUILD) if(BUILD_qt_example) - add_definitions(-DPLD_extqt) qt4_wrap_cpp( QT_MOC_OUTFILES ${CMAKE_CURRENT_SOURCE_DIR}/qt_PlotWindow.h Modified: trunk/include/qt.h =================================================================== --- trunk/include/qt.h 2009-08-15 19:22:07 UTC (rev 10263) +++ trunk/include/qt.h 2009-08-16 01:24:32 UTC (rev 10264) @@ -68,6 +68,7 @@ #include <QPicture> #include <QMutex> +#include "plDevs.h" #include "plplotP.h" #include "drivers.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sm...@us...> - 2009-08-17 08:07:52
|
Revision: 10265 http://plplot.svn.sourceforge.net/plplot/?rev=10265&view=rev Author: smekal Date: 2009-08-17 08:07:32 +0000 (Mon, 17 Aug 2009) Log Message: ----------- Added D examples 28 and 31. Added missing PL_NOTSET flag to D bindings. Modified Paths: -------------- trunk/bindings/d/plplot.d trunk/examples/d/CMakeLists.txt trunk/plplot_test/test_d.sh.in Added Paths: ----------- trunk/examples/d/x28d.d trunk/examples/d/x31d.d Modified: trunk/bindings/d/plplot.d =================================================================== --- trunk/bindings/d/plplot.d 2009-08-16 01:24:32 UTC (rev 10264) +++ trunk/bindings/d/plplot.d 2009-08-17 08:07:32 UTC (rev 10265) @@ -999,6 +999,7 @@ /* Macro used (in some cases) to ignore value of argument */ /* I don't plan on changing the value so you can hard-code it */ +const int PL_NOTSET = -42; /* See plcont.c for examples of the following */ Modified: trunk/examples/d/CMakeLists.txt =================================================================== --- trunk/examples/d/CMakeLists.txt 2009-08-16 01:24:32 UTC (rev 10264) +++ trunk/examples/d/CMakeLists.txt 2009-08-17 08:07:32 UTC (rev 10265) @@ -50,9 +50,10 @@ "25" "26" "27" - # "28" + "28" "29" "30" + "31" ) if(CORE_BUILD) Added: trunk/examples/d/x28d.d =================================================================== --- trunk/examples/d/x28d.d (rev 0) +++ trunk/examples/d/x28d.d 2009-08-17 08:07:32 UTC (rev 10265) @@ -0,0 +1,364 @@ +/* $Id: $ + + plmtex3, plptex3 demo. + + Copyright (C) 2009 Werner Smekal + + This file is part of PLplot. + + PLplot is free software; you can redistribute it and/or modify + it under the terms of the GNU General Library Public License as published + by the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + PLplot is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with PLplot; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +import std.string; +import std.math; + +import plplot; + +/*--------------------------------------------------------------------------*\ + * main + * + * Demonstrates plotting text in 3D. +\*--------------------------------------------------------------------------*/ +int main(char[][] args) +{ + /* Choose these values to correspond to tick marks. */ + const int XPTS=2; + const int YPTS=2; + const int NREVOLUTION=16; + const int NROTATION=8; + const int NSHEAR=8; + + PLFLT xmin=0.0, xmax=1.0, xmid = 0.5*(xmax+xmin), xrange = xmax-xmin; + PLFLT ymin=0.0, ymax=1.0, ymid = 0.5*(ymax+ymin), yrange = ymax-ymin; + PLFLT zmin=0.0, zmax=1.0, zmid = 0.5*(zmax+zmin), zrange = zmax-zmin; + + /* p1string must be exactly one character + the null termination + * character. */ + string pstring = "The future of our civilization depends on software freedom."; + + /* Allocate and define the minimal x, y, and z to insure 3D box */ + PLFLT[XPTS] x; + PLFLT[YPTS] y; + + PLFLT[][] z = new PLFLT[][XPTS]; + for(int i=0; i<XPTS; i++) + z[i] = new PLFLT[YPTS]; + + for(int i=0; i<XPTS; i++) + x[i] = xmin + i*xrange/(XPTS-1); + + for(int j=0; j<YPTS; j++) + y[j] = ymin + j*yrange/(YPTS-1); + + for(int i=0; i<XPTS; i++) + for(int j=0; j<YPTS; j++) + z[i][j] = 0.0; + + /* Parse and process command line arguments */ + plparseopts(args, PL_PARSE_FULL); + + plinit(); + + /* Page 1: Demonstrate inclination and shear capability pattern. */ + pladv(0); + plvpor(-0.15, 1.15, -0.05, 1.05); + plwind(-1.2, 1.2, -0.8, 1.5); + plw3d(1.0, 1.0, 1.0, xmin, xmax, ymin, ymax, zmin, zmax, 20., 45.); + + plcol0(2); + plbox3("b", "", xrange, 0, + "b", "", yrange, 0, + "bcd", "", zrange, 0); + + PLFLT x_inclination, y_inclination, z_inclination; + PLFLT x_shear, y_shear, z_shear; + PLFLT omega, sin_omega, cos_omega; + + /* z = zmin. */ + plschr(0., 1.0); + for(int i=0; i<NREVOLUTION; i++) { + omega = (2.*PI*i)/NREVOLUTION; + sin_omega = sin(omega); + cos_omega = cos(omega); + x_inclination = 0.5*xrange*cos_omega; + y_inclination = 0.5*yrange*sin_omega; + z_inclination = 0.0; + x_shear = -0.5*xrange*sin_omega; + y_shear = 0.5*yrange*cos_omega; + z_shear = 0.; + plptex3(xmid, ymid, zmin, + x_inclination, y_inclination, z_inclination, + x_shear, y_shear, z_shear, + 0.0, " revolution"); + } + + /* x = xmax. */ + plschr(0., 1.0); + for(int i=0; i<NREVOLUTION; i++) { + omega = (2.*PI*i)/NREVOLUTION; + sin_omega = sin(omega); + cos_omega = cos(omega); + x_inclination = 0.; + y_inclination = -0.5*yrange*cos_omega; + z_inclination = 0.5*zrange*sin_omega; + x_shear = 0.; + y_shear = 0.5*yrange*sin_omega; + z_shear = 0.5*zrange*cos_omega; + plptex3(xmax, ymid, zmid, + x_inclination, y_inclination, z_inclination, + x_shear, y_shear, z_shear, + 0.0, " revolution"); + } + + /* y = ymax. */ + plschr(0., 1.0); + for(int i=0; i<NREVOLUTION; i++) { + omega = (2.*PI*i)/NREVOLUTION; + sin_omega = sin(omega); + cos_omega = cos(omega); + x_inclination = 0.5*xrange*cos_omega; + y_inclination = 0.; + z_inclination = 0.5*zrange*sin_omega; + x_shear = -0.5*xrange*sin_omega; + y_shear = 0.; + z_shear = 0.5*zrange*cos_omega; + plptex3(xmid, ymax, zmid, + x_inclination, y_inclination, z_inclination, + x_shear, y_shear, z_shear, + 0.0, " revolution"); + } + + /* Draw minimal 3D grid to finish defining the 3D box. */ + plmesh(x, y, z, DRAW_LINEXY); + + /* Page 2: Demonstrate rotation of string around its axis. */ + pladv(0); + plvpor(-0.15, 1.15, -0.05, 1.05); + plwind(-1.2, 1.2, -0.8, 1.5); + plw3d(1.0, 1.0, 1.0, xmin, xmax, ymin, ymax, zmin, zmax, 20., 45.); + + plcol0(2); + plbox3("b", "", xrange, 0, + "b", "", yrange, 0, + "bcd", "", zrange, 0); + + /* y = ymax. */ + plschr(0., 1.0); + x_inclination = 1.; + y_inclination = 0.; + z_inclination = 0.; + x_shear = 0.; + for(int i=0; i<NROTATION; i++) { + omega = (2.*PI*i)/NROTATION; + sin_omega = sin(omega); + cos_omega = cos(omega); + y_shear = 0.5*yrange*sin_omega; + z_shear = 0.5*zrange*cos_omega; + plptex3(xmid, ymax, zmax -(zmax-0.2)*i/(NROTATION-1.0), + x_inclination, y_inclination, z_inclination, + x_shear, y_shear, z_shear, + 0.5, "rotation for y = y#dmax#u"); + } + + /* x = xmax. */ + plschr(0., 1.0); + x_inclination = 0.; + y_inclination = -1.; + z_inclination = 0.; + y_shear = 0.; + for(int i=0; i<NROTATION; i++) { + omega = (2.*PI*i)/NROTATION; + sin_omega = sin(omega); + cos_omega = cos(omega); + x_shear = 0.5*xrange*sin_omega; + z_shear = 0.5*zrange*cos_omega; + plptex3(xmax, ymid, zmax -(zmax-0.2)*i/(NROTATION-1.0), + x_inclination, y_inclination, z_inclination, + x_shear, y_shear, z_shear, + 0.5, "rotation for x = x#dmax#u"); + } + + /* z = zmin. */ + plschr(0., 1.0); + x_inclination = 1.; + y_inclination = 0.; + z_inclination = 0.; + x_shear = 0.; + for(int i=0; i<NROTATION; i++) { + omega = (2.*PI*i)/NROTATION; + sin_omega = sin(omega); + cos_omega = cos(omega); + y_shear = 0.5*yrange*cos_omega; + z_shear = 0.5*zrange*sin_omega; + plptex3(xmid, ymax -(ymax-0.2)*i/(NROTATION-1.0), zmin, + x_inclination, y_inclination, z_inclination, + x_shear, y_shear, z_shear, + 0.5, "rotation for z = z#dmin#u"); + } + /* Draw minimal 3D grid to finish defining the 3D box. */ + plmesh(x, y, z, DRAW_LINEXY); + + /* Page 3: Demonstrate shear of string along its axis. */ + /* Work around xcairo and pngcairo (but not pscairo) problems for + * shear vector too close to axis of string. (N.B. no workaround + * would be domega = 0.) */ + PLFLT domega = 0.05; + pladv(0); + plvpor(-0.15, 1.15, -0.05, 1.05); + plwind(-1.2, 1.2, -0.8, 1.5); + plw3d(1.0, 1.0, 1.0, xmin, xmax, ymin, ymax, zmin, zmax, 20., 45.); + + plcol0(2); + plbox3("b", "", xrange, 0, + "b", "", yrange, 0, + "bcd", "", zrange, 0); + + /* y = ymax. */ + plschr(0., 1.0); + x_inclination = 1.; + y_inclination = 0.; + z_inclination = 0.; + y_shear = 0.; + for(int i=0; i<NSHEAR; i++) { + omega = domega + (2.*PI*i)/NSHEAR; + sin_omega = sin(omega); + cos_omega = cos(omega); + x_shear = 0.5*xrange*sin_omega; + z_shear = 0.5*zrange*cos_omega; + plptex3(xmid, ymax, zmax -(zmax-0.2)*i/(NSHEAR-1.0), + x_inclination, y_inclination, z_inclination, + x_shear, y_shear, z_shear, + 0.5, "shear for y = y#dmax#u"); + } + + /* x = xmax. */ + plschr(0., 1.0); + x_inclination = 0.; + y_inclination = -1.; + z_inclination = 0.; + x_shear = 0.; + for(int i=0; i<NSHEAR; i++) { + omega = domega + (2.*PI*i)/NSHEAR; + sin_omega = sin(omega); + cos_omega = cos(omega); + y_shear = -0.5*yrange*sin_omega; + z_shear = 0.5*zrange*cos_omega; + plptex3(xmax, ymid, zmax -(zmax-0.2)*i/(NSHEAR-1.0), + x_inclination, y_inclination, z_inclination, + x_shear, y_shear, z_shear, + 0.5, "shear for x = x#dmax#u"); + } + + /* z = zmin. */ + plschr(0., 1.0); + x_inclination = 1.; + y_inclination = 0.; + z_inclination = 0.; + z_shear = 0.; + for(int i=0; i<NSHEAR; i++) { + omega = domega + (2.*PI*i)/NSHEAR; + sin_omega = sin(omega); + cos_omega = cos(omega); + y_shear = 0.5*yrange*cos_omega; + x_shear = 0.5*xrange*sin_omega; + plptex3(xmid, ymax -(ymax-0.2)*i/(NSHEAR-1.0), zmin, + x_inclination, y_inclination, z_inclination, + x_shear, y_shear, z_shear, + 0.5, "shear for z = z#dmin#u"); + } + /* Draw minimal 3D grid to finish defining the 3D box. */ + plmesh(x, y, z, DRAW_LINEXY); + + /* Page 4: Demonstrate drawing a string on a 3D path. */ + pladv(0); + plvpor(-0.15, 1.15, -0.05, 1.05); + plwind(-1.2, 1.2, -0.8, 1.5); + plw3d(1.0, 1.0, 1.0, xmin, xmax, ymin, ymax, zmin, zmax, 40., -30.); + + plcol0(2); + plbox3("b", "", xrange, 0, + "b", "", yrange, 0, + "bcd", "", zrange, 0); + + plschr(0., 1.2); + /* domega controls the spacing between the various characters of the + * string and also the maximum value of omega for the given number + * of characters in *pstring. */ + domega = 2.*PI/pstring.length; + omega = 0.; + /* 3D function is a helix of the given radius and pitch */ + PLFLT radius = 0.5; + PLFLT pitch = 1./(2.*PI); + PLFLT xpos, ypos, zpos; + for(int i=0; i<pstring.length; i++) { + sin_omega = sin(omega); + cos_omega = cos(omega); + xpos = xmid + radius*sin_omega; + ypos = ymid - radius*cos_omega; + zpos = zmin + pitch*omega; + + /* In general, the inclination is proportional to the derivative of + * the position wrt theta. */ + x_inclination = radius*cos_omega;; + y_inclination = radius*sin_omega; + z_inclination = pitch; + + /* The shear vector should be perpendicular to the 3D line with Z + * component maximized, but for low pitch a good approximation is + * a constant vector that is parallel to the Z axis. */ + x_shear = 0.; + y_shear = 0.; + z_shear = 1.; + plptex3(xpos, ypos, zpos, + x_inclination, y_inclination, z_inclination, + x_shear, y_shear, z_shear, + 0.5, pstring[i..i+1]); + omega += domega; + } + /* Draw minimal 3D grid to finish defining the 3D box. */ + plmesh(x, y, z, DRAW_LINEXY); + + /* Page 5: Demonstrate plmtex3 axis labelling capability */ + pladv(0); + plvpor(-0.15, 1.15, -0.05, 1.05); + plwind(-1.2, 1.2, -0.8, 1.5); + plw3d(1.0, 1.0, 1.0, xmin, xmax, ymin, ymax, zmin, zmax, 20., 45.); + + plcol0(2); + plbox3("b", "", xrange, 0, + "b", "", yrange, 0, + "bcd", "", zrange, 0); + + plschr(0., 1.0); + plmtex3("xp", 3.0, 0.5, 0.5, "Arbitrarily displaced"); + plmtex3("xp", 4.5, 0.5, 0.5, "primary X-axis label"); + plmtex3("xs", -2.5, 0.5, 0.5, "Arbitrarily displaced"); + plmtex3("xs", -1.0, 0.5, 0.5, "secondary X-axis label"); + plmtex3("yp", 3.0, 0.5, 0.5, "Arbitrarily displaced"); + plmtex3("yp", 4.5, 0.5, 0.5, "primary Y-axis label"); + plmtex3("ys", -2.5, 0.5, 0.5, "Arbitrarily displaced"); + plmtex3("ys", -1.0, 0.5, 0.5, "secondary Y-axis label"); + plmtex3("zp", 4.5, 0.5, 0.5, "Arbitrarily displaced"); + plmtex3("zp", 3.0, 0.5, 0.5, "primary Z-axis label"); + plmtex3("zs", -2.5, 0.5, 0.5, "Arbitrarily displaced"); + plmtex3("zs", -1.0, 0.5, 0.5, "secondary Z-axis label"); + + /* Draw minimal 3D grid to finish defining the 3D box. */ + plmesh(x, y, z, DRAW_LINEXY); + + plend(); + return 0; +} Added: trunk/examples/d/x31d.d =================================================================== --- trunk/examples/d/x31d.d (rev 0) +++ trunk/examples/d/x31d.d 2009-08-17 08:07:32 UTC (rev 10265) @@ -0,0 +1,251 @@ +/* $Id: $ + + Copyright (C) 2009 Werner Smekal + + set/get tester + + This file is part of PLplot. + + PLplot is free software; you can redistribute it and/or modify + it under the terms of the GNU General Library Public License as published + by the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + PLplot is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with PLplot; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +import std.string; +import std.stdio; +import std.math; +import std.cstream; + +import plplot; + +int main(char[][] args) +{ + /* Parse and process command line arguments */ + int status = 0; + plparseopts(args, PL_PARSE_FULL); + + /* Test setting / getting familying parameters before plinit */ + /* Save values set by plparseopts to be restored later. */ + PLINT fam0, num0, bmax0; + plgfam(&fam0, &num0, &bmax0); + PLINT fam1 = 0; + PLINT num1 = 10; + PLINT bmax1 = 1000; + plsfam(fam1, num1, bmax1); + + /* Retrieve the same values? */ + PLINT fam2, num2, bmax2; + plgfam(&fam2, &num2, &bmax2); + writefln("family parameters: fam, num, bmax = %d %d %d", fam2, num2, bmax2); + if(fam2 != fam1 || num2 != num1 || bmax2 != bmax1) { + derr.writefln("plgfam test failed"); + status = 1; + } + /* Restore values set initially by plparseopts. */ + plsfam(fam0, num0, bmax0); + + /* Test setting / getting page parameters before plinit */ + /* Save values set by plparseopts to be restored later. */ + PLFLT xp0, yp0; + PLINT xleng0, yleng0, xoff0, yoff0; + plgpage(&xp0, &yp0, &xleng0, &yleng0, &xoff0, &yoff0); + PLFLT xp1 = 200.0; + PLFLT yp1 = 200.0; + PLINT xleng1 = 400; + PLINT yleng1 = 200; + PLINT xoff1 = 10; + PLINT yoff1 = 20; + plspage(xp1, yp1, xleng1, yleng1, xoff1, yoff1); + + /* Retrieve the same values? */ + PLFLT xp2, yp2; + PLINT xleng2, yleng2, xoff2, yoff2; + plgpage(&xp2, &yp2, &xleng2, &yleng2, &xoff2, &yoff2); + writefln("page parameters: xp, yp, xleng, yleng, xoff, yoff = %f %f %d %d %d %d", xp2, yp2, xleng2, yleng2, xoff2, yoff2); + if(xp2 != xp1 || yp2 != yp1 || xleng2 != xleng1 || yleng2 != yleng1 || + xoff2 != xoff1 || yoff2 != yoff1 ) { + derr.writefln("plgpage test failed"); + status = 1; + } + /* Restore values set initially by plparseopts. */ + plspage(xp0, yp0, xleng0, yleng0, xoff0, yoff0); + + /* Test setting / getting compression parameter across plinit. */ + PLINT compression1 = 95; + plscompression(compression1); + + /* Initialize plplot */ + plinit(); + + /* Test if device initialization screwed around with the preset + * compression parameter. */ + PLINT compression2; + plgcompression(&compression2); + writefln("Output various PLplot parameters"); + writefln("compression parameter = %d", compression2); + if(compression2 != compression1) { + derr.writefln("plgcompression test failed"); + status = 1; + } + + + /* Exercise plscolor, plscol0, plscmap1, and plscmap1a to make sure + * they work without any obvious error messages. */ + PLINT[] r1 = [ 0, 255 ]; + PLINT[] g1 = [ 255, 0 ]; + PLINT[] b1 = [ 0, 0 ]; + PLFLT[] a1 = [ 1.0, 1.0 ]; + plscolor(1); + plscol0(1, 255, 0, 0); + plscmap1(r1, g1, b1); + plscmap1a(r1, g1, b1, a1); + + PLINT level2; + plglevel(&level2); + writefln("level parameter = %d", level2); + if(level2 != 1) { + derr.writefln("plglevel test failed."); + status = 1; + } + + pladv(0); + plvpor(0.01, 0.99, 0.02, 0.49); + PLFLT xmin, xmax, ymin, ymax; + plgvpd(&xmin, &xmax, &ymin, &ymax); + writefln("plvpor: xmin, xmax, ymin, ymax = %f %f %f %f", xmin, xmax, ymin, ymax); + if (xmin != 0.01 || xmax != 0.99 || ymin != 0.02 || ymax != 0.49) { + derr.writefln("plgvpd test failed"); + status = 1; + } + PLFLT xmid = 0.5*(xmin+xmax); + PLFLT ymid = 0.5*(ymin+ymax); + + plwind(0.2, 0.3, 0.4, 0.5); + plgvpw(&xmin, &xmax, &ymin, &ymax); + writefln("plwind: xmin, xmax, ymin, ymax = %f %f %f %f", xmin, xmax, ymin, ymax); + if (xmin != 0.2 || xmax != 0.3 || ymin != 0.4 || ymax != 0.5) { + derr.writefln("plgvpw test failed"); + status = 1; + } + + /* Get world coordinates for middle of viewport */ + PLFLT wx, wy; + PLINT win; + plcalc_world(xmid, ymid, &wx, &wy, &win); + writefln("world parameters: wx, wy, win = %f %f %d", wx, wy, win); + if (fabs(wx-0.5*(xmin+xmax))>1.0E-5 || fabs(wy-0.5*(ymin+ymax))>1.0E-5) { + derr.writefln("plcalc_world test failed"); + status = 1; + } + + /* Retrieve and print the name of the output file (if any). + * This goes to stderr not stdout since it will vary between tests and + * we want stdout to be identical for compare test. */ + string fnam; + plgfnam(fnam); + if(fnam.length == 0) + writefln("No output file name is set"); + else + writefln("Output file name read"); + derr.writefln("Output file name is %s",fnam); + + /* Set and get the number of digits used to display axis labels */ + /* Note digits is currently ignored in pls[xyz]ax and + therefore it does not make sense to test the returned + value */ + plsxax(3,0); + PLINT digmax, digits; + plgxax(&digmax,&digits); + writefln("x axis parameters: digmax, digits = %d %d", digmax, digits); + if(digmax != 3) { + derr.writefln("plgxax test failed"); + status = 1; + } + + plsyax(4,0); + plgyax(&digmax,&digits); + writefln("y axis parameters: digmax, digits = %d %d", digmax, digits); + if(digmax != 4) { + derr.writefln("plgyax test failed"); + status = 1; + } + + plszax(5,0); + plgzax(&digmax,&digits); + writefln("z axis parameters: digmax, digits = %d %d", digmax, digits); + if(digmax != 5) { + derr.writefln("plgzax test failed"); + status = 1; + } + + plsdidev(0.05, PL_NOTSET, 0.1, 0.2); + PLFLT mar, aspect, jx, jy; + plgdidev(&mar, &aspect, &jx, &jy); + writefln("device-space window parameters: mar, aspect, jx, jy = %f %f %f %f" , mar, aspect, jx, jy); + if(mar != 0.05 || jx != 0.1 || jy != 0.2) { + derr.writefln("plgdidev test failed"); + status = 1; + } + + plsdiori(1.0); + PLFLT ori; + plgdiori(&ori); + writefln("ori parameter = %f", ori); + if(ori != 1.0) { + derr.writefln("plgdiori test failed"); + status = 1; + } + + plsdiplt(0.1, 0.2, 0.9, 0.8); + plgdiplt(&xmin, &ymin, &xmax, &ymax); + writefln("plot-space window parameters: xmin, ymin, xmax, ymax = %f %f %f %f", xmin, ymin, xmax, ymax); + if(xmin != 0.1 || xmax != 0.9 || ymin != 0.2 || ymax != 0.8) { + derr.writefln("plgdiplt test failed"); + status = 1; + } + + plsdiplz(0.1, 0.1, 0.9, 0.9); + PLFLT zxmin, zymin, zxmax, zymax; + plgdiplt(&zxmin, &zymin, &zxmax, &zymax); + writefln("zoomed plot-space window parameters: xmin, ymin, xmax, ymax = %f %f %f %f", zxmin, zymin, zxmax, zymax); + if( fabs(zxmin -(xmin + (xmax-xmin)*0.1)) > 1.0E-5 || + fabs(zxmax -(xmin+(xmax-xmin)*0.9)) > 1.0E-5 || + fabs(zymin -(ymin+(ymax-ymin)*0.1)) > 1.0E-5 || + fabs(zymax -(ymin+(ymax-ymin)*0.9)) > 1.0E-5 ) { + derr.writefln("plsdiplz test failed"); + status = 1; + } + + plscolbg(10,20,30); + PLINT r, g, b; + plgcolbg(&r, &g, &b); + writefln("background colour parameters: r, g, b = %d %d %d", r, g, b); + if(r != 10 || g != 20 || b != 30) { + derr.writefln("plgcolbg test failed"); + status = 1; + } + + plscolbga(20, 30, 40, 0.5); + PLFLT a; + plgcolbga(&r, &g, &b, &a); + writefln("background/transparency colour parameters: r, g, b, a = %d %d %d %f", r, g, b, a); + if(r != 20 || g != 30 || b != 40 || a != 0.5) { + derr.writefln("plgcolbga test failed"); + status = 1; + } + + plend(); + + return status; +} Modified: trunk/plplot_test/test_d.sh.in =================================================================== --- trunk/plplot_test/test_d.sh.in 2009-08-16 01:24:32 UTC (rev 10264) +++ trunk/plplot_test/test_d.sh.in 2009-08-17 08:07:32 UTC (rev 10265) @@ -31,7 +31,7 @@ # 20-22, 28, and 31 not implemented yet. # example 14 excluded until plgdev fixed since the bad driver information # causes run-time errors. -for index in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 23 24 25 26 27 29 30; do +for index in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 23 24 25 26 27 28 29 30 31; do if [ "$verbose_test" ] ; then echo "x${index}${lang}" fi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2009-08-17 13:38:24
|
Revision: 10268 http://plplot.svn.sourceforge.net/plplot/?rev=10268&view=rev Author: andrewross Date: 2009-08-17 13:38:09 +0000 (Mon, 17 Aug 2009) Log Message: ----------- Add plbtime, plctime, plconfigtime to java bindings and update example 29 to use them. Modified Paths: -------------- trunk/bindings/java/PLStream.java trunk/examples/java/x29.java Modified: trunk/bindings/java/PLStream.java =================================================================== --- trunk/bindings/java/PLStream.java 2009-08-17 13:01:07 UTC (rev 10267) +++ trunk/bindings/java/PLStream.java 2009-08-17 13:38:09 UTC (rev 10268) @@ -153,6 +153,11 @@ zopt, zlabel, ztick, nsubz); } +public void btime(int year[], int month[], int day[], int hour[], int min[], double sec[], double ctime) { + if (set_stream() == -1) return; + plplotjavac.plbtime(year, month, day, hour, min, sec, ctime); +} + public void calc_world(double rx, double ry, double[] wx, double[] wy, int[] window) { if (set_stream() == -1) return; plplotjavac.plcalc_world(rx, ry, wx, wy, window); @@ -173,6 +178,15 @@ plplotjavac.plcol1(col1); } +public void configtime( double scale, double offset1, double offset2, + int ccontrol, boolean ifbtime_offset, int year, + int month, int day, int hour, int min, + double sec) { + if (set_stream() == -1) return; + plplotjavac.plconfigtime(scale, offset1, offset2, ccontrol, ifbtime_offset, + year, month, day, hour, min, sec); +} + public void cont(double[][] f, int kx, int lx, int ky, int ly, double[] clevel, double[][] pltr, double[][] OBJECT_DATA) { if (set_stream() == -1) return; @@ -184,6 +198,11 @@ plplotjavac.plcpstrm(pls.stream_id, flags); } +public void ctime(int year, int month, int day, int hour, int min, double sec, double ctime[]) { + if (set_stream() == -1) return; + plplotjavac.plctime(year, month, day, hour, min, sec, ctime); +} + // The end / end1 functions have extra code in to keep track of the // stream references in the class. public void end() { Modified: trunk/examples/java/x29.java =================================================================== --- trunk/examples/java/x29.java 2009-08-17 13:01:07 UTC (rev 10267) +++ trunk/examples/java/x29.java 2009-08-17 13:38:09 UTC (rev 10268) @@ -65,6 +65,8 @@ plot3(); + plot4(); + pls.end(); } @@ -237,7 +239,146 @@ } + void plot4() + { + /* TAI-UTC (seconds) as a function of time. + Use Besselian epochs as the continuous time interval just to prove + this does not introduce any issues. */ + + double scale, offset1, offset2; + double xmin[] = new double[1], xmax[] = new double[1]; + double ymin = 0.0, ymax = 0.0, xlabel_step = 0.0; + int kind, npts = 1001, i; + boolean if_TAI_time_format = false; + String time_format = ""; + String title_suffix = ""; + String xtitle = ""; + String title = ""; + double x[]; + double y[]; + int tai_year[] = new int[1], tai_month[] = new int[1], + tai_day[] = new int[1], tai_hour[] = new int[1], + tai_min[] = new int[1]; + double tai_sec[] = new double[1], tai; + int utc_year[] = new int[1], utc_month[] = new int[1], + utc_day[] = new int[1], utc_hour[] = new int[1], + utc_min[] = new int[1]; + double utc_sec[] = new double[1], utc[] = new double[1]; + /* Use the definition given in http://en.wikipedia.org/wiki/Besselian_epoch + * B = 1900. + (JD -2415020.31352)/365.242198781 + * ==> (as calculated with aid of "bc -l" command) + * B = (MJD + 678940.364163900)/365.242198781 + * ==> + * MJD = B*365.24219878 - 678940.364163900 */ + scale = 365.242198781; + offset1 = -678940.; + offset2 = -0.3641639; + pls.configtime(scale, offset1, offset2, 0x0, false, 0, 0, 0, 0, 0, 0.); + + for (kind=0;kind<7;kind++) { + if (kind == 0) { + pls.ctime(1950,0,2,0,0,0.,xmin); + pls.ctime(2020,0,2,0,0,0.,xmax); + npts = 70*12 + 1; + ymin = 0.0; + ymax = 36.0; + time_format = "%Y%"; + if_TAI_time_format = true; + title_suffix = "from 1950 to 2020"; + xtitle = "Year"; + xlabel_step = 10.; + } + else if (kind == 1 || kind ==2) { + pls.ctime(1961,7,1,0,0,1.64757-.20, xmin); + pls.ctime(1961,7,1,0,0,1.64757+.20, xmax); + npts = 1001; + ymin = 1.625; + ymax = 1.725; + time_format = "%S%2%"; + title_suffix = "near 1961-08-01 (TAI)"; + xlabel_step = 0.05/(scale*86400.); + if (kind == 1) { + if_TAI_time_format = true; + xtitle = "Seconds (TAI)"; + } + else { + if_TAI_time_format = false; + xtitle = "Seconds (TAI) labelled with corresponding UTC"; + } + } + else if (kind == 3 || kind ==4) { + pls.ctime(1963,10,1,0,0,2.6972788-.20, xmin); + pls.ctime(1963,10,1,0,0,2.6972788+.20, xmax); + npts = 1001; + ymin = 2.55; + ymax = 2.75; + time_format = "%S%2%"; + title_suffix = "near 1963-11-01 (TAI)"; + xlabel_step = 0.05/(scale*86400.); + if (kind == 3) { + if_TAI_time_format = true; + xtitle = "Seconds (TAI)"; + } + else { + if_TAI_time_format = false; + xtitle = "Seconds (TAI) labelled with corresponding UTC"; + } + } + else if (kind == 5 || kind == 6) { + pls.ctime(2009,0,1,0,0,34.-5.,xmin); + pls.ctime(2009,0,1,0,0,34.+5.,xmax); + npts = 1001; + ymin = 32.5; + ymax = 34.5; + time_format = "%S%2%"; + title_suffix = "near 2009-01-01 (TAI)"; + xlabel_step = 1./(scale*86400.); + if (kind == 5) { + if_TAI_time_format = true; + xtitle = "Seconds (TAI)"; + } + else { + if_TAI_time_format = false; + xtitle = "Seconds (TAI) labelled with corresponding UTC"; + } + } + + x = new double[npts]; + y = new double[npts]; + for (i=0;i<npts;i++) { + x[i] = xmin[0] + i*(xmax[0]-xmin[0])/((double)(npts-1)); + pls.configtime(scale, offset1, offset2, 0x0, false, 0, 0, 0, 0, 0, 0.); + tai = x[i]; + pls.btime(tai_year, tai_month, tai_day, tai_hour, tai_min, tai_sec, tai); + pls.configtime(scale, offset1, offset2, 0x2, false, 0, 0, 0, 0, 0, 0.); + pls.btime(utc_year, utc_month, utc_day, utc_hour, utc_min, utc_sec, tai); + pls.configtime(scale, offset1, offset2, 0x0, false, 0, 0, 0, 0, 0, 0.); + pls.ctime(utc_year[0], utc_month[0], utc_day[0], utc_hour[0], utc_min[0], utc_sec[0], utc); + y[i]=(tai-utc[0])*scale*86400.; + } + + pls.adv(0); + pls.vsta(); + pls.wind(xmin[0], xmax[0], ymin, ymax); + pls.col0(1); + if (if_TAI_time_format) + pls.configtime(scale, offset1, offset2, 0x0, false, 0, 0, 0, 0, 0, 0.); + else + pls.configtime(scale, offset1, offset2, 0x2, false, 0, 0, 0, 0, 0, 0.); + pls.timefmt(time_format); + pls.box("bcnstd", xlabel_step, 0, "bcnstv", 0., 0); + pls.col0(3); + title = "@frPLplot Example 29 - TAI-UTC "+title_suffix; + pls.lab(xtitle, "TAI-UTC (sec)", title); + + pls.col0(4); + + pls.line(x, y); + } + } + + public static void main( String[] args ) { new x29( args ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2009-08-17 17:51:44
|
Revision: 10271 http://plplot.svn.sourceforge.net/plplot/?rev=10271&view=rev Author: andrewross Date: 2009-08-17 17:51:31 +0000 (Mon, 17 Aug 2009) Log Message: ----------- Update octave bindings to include plarc, plbtime, plctime, plconfigtime, plspal0, plspal1. Update octave examples 3, 16 and 29 to showcase these. Modified Paths: -------------- trunk/bindings/octave/plplot_octave.h.in trunk/examples/octave/x03c.m trunk/examples/octave/x16c.m trunk/examples/octave/x29c.m Modified: trunk/bindings/octave/plplot_octave.h.in =================================================================== --- trunk/bindings/octave/plplot_octave.h.in 2009-08-17 17:07:49 UTC (rev 10270) +++ trunk/bindings/octave/plplot_octave.h.in 2009-08-17 17:51:31 UTC (rev 10271) @@ -424,21 +424,24 @@ #ifndef __PLSTUBS_H__ /* i.e. do not expand this in the stubs */ +#define pl_setcontlabelformat c_pl_setcontlabelformat +#define pl_setcontlabelparam c_pl_setcontlabelparam #define pladv c_pladv -#define plclear c_plclear +#define plarc c_plarc #define plaxes c_plaxes #define plbin c_plbin #define plbop c_plbop #define plbox c_plbox #define plbox3 c_plbox3 +#define plbtime c_plbtime +#define plcalc_world c_plcalc_world +#define plclear c_plclear #define plcol0 c_plcol0 #define plcol1 c_plcol1 -#define plxormod c_plxormod -#define plcalc_world c_plcalc_world +#define plconfigtime c_plconfigtime #define plcont c_plcont #define plcpstrm c_plcpstrm -#define pl_setcontlabelparam c_pl_setcontlabelparam -#define pl_setcontlabelformat c_pl_setcontlabelformat +#define plctime c_plctime #define plend c_plend #define plend1 c_plend1 #define plenv c_plenv @@ -498,7 +501,6 @@ #define plot3d c_plot3d #define plot3dc c_plot3dc #define plparseopts c_plparseopts -#define plsurf3d c_plsurf3d #define plpat c_plpat #define plpoin c_plpoin #define plpoin3 c_plpoin3 @@ -514,10 +516,13 @@ #define plrgbhls c_plrgbhls #define plschr c_plschr #define plscmap0 c_plscmap0 +#define plscmap0a c_plscmap0a +#define plscmap0n c_plscmap0n #define plscmap1 c_plscmap1 -#define plscmap0n c_plscmap0n +#define plscmap1a c_plscmap1a +#define plscmap1l c_plscmap1l +#define plscmap1la c_plscmap1la #define plscmap1n c_plscmap1n -#define plscmap1l c_plscmap1l #define plscol0 c_plscol0 #define plscol0a c_plscol0a #define plscolbg c_plscolbg @@ -525,11 +530,11 @@ #define plscolor c_plscolor #define plscompression c_plscompression #define plsdev c_plsdev -#define plsdiplt c_plsdiplt -#define plsdiplz c_plsdiplz #define plsdidev c_plsdidev #define plsdimap c_plsdimap #define plsdiori c_plsdiori +#define plsdiplt c_plsdiplt +#define plsdiplz c_plsdiplz #define plseed c_plseed #define plsesc c_plsesc #define plsfam c_plsfam @@ -539,10 +544,13 @@ #define plshades c_plshades #define plshade c_plshade #define plshade1 c_plshade1 +#define plslabelfunc c_plslabelfunc #define plsmaj c_plsmaj #define plsmin c_plsmin #define plsori c_plsori #define plspage c_plspage +#define plspal0 c_plspal0 +#define plspal1 c_plspal1 #define plspause c_plspause #define plsstrm c_plsstrm #define plssub c_plssub @@ -553,6 +561,7 @@ #define plstripc c_plstripc #define plstripd c_plstripd #define plstyl c_plstyl +#define plsurf3d c_plsurf3d #define plsvect c_plsvect #define plsvpa c_plsvpa #define plsxax c_plsxax @@ -569,6 +578,7 @@ #define plw3d c_plw3d #define plwid c_plwid #define plwind c_plwind +#define plxormod c_plxormod #endif /* __PLSTUBS_H__ */ @@ -605,6 +615,11 @@ void c_pladv(PLINT page); //%name pladv +/* Plot an arc */ + +void c_plarc(PLFLT x, PLFLT y, PLFLT a, PLFLT b, PLFLT angle1, PLFLT angle2, + PLBOOL fill); //%name plarc + /* This functions similarly to plbox() except that the origin of the axes */ /* is placed at the user-specified point (x0, y0). */ @@ -630,6 +645,12 @@ const char *yopt, const char *ylabel, PLFLT ytick, PLINT nsuby, const char *zopt, const char *zlabel, PLFLT ztick, PLINT nsubz); //%name plbox3 +/* Calculate broken-down time from continuous time for current stream. */ + void c_plbtime(PLINT *year, PLINT *month, PLINT *day, PLINT *hour, PLINT *min, PLFLT *sec, PLFLT ctime); //%name plbtime //%output year, month, day, hour, min, sec + +/* Start new page. Should only be used with pleop(). */ + + /* Set xor mode; 1-enter, 0-leave */ void c_plxormod(PLINT mode, PLINT *status); //%name plxormod //%output status @@ -653,6 +674,10 @@ void c_plcol1(PLFLT col1); //%name plcol1 +/* Configure transformation between continuous and broken-down time (and + vice versa) for current stream. */ + void c_plconfigtime(PLFLT scale, PLFLT offset1, PLFLT offset2, PLINT ccontrol, PLBOOL ifbtime_offset, PLINT year, PLINT month, PLINT day, PLINT hour, PLINT min, PLFLT sec); //%name plconfigtime + /* Identity transformation. */ void pltr0(PLFLT x, PLFLT y, PLFLT *tx, PLFLT *ty, PLPointer pltr_data); //%nowrap @@ -752,6 +777,9 @@ void c_plcpstrm(PLINT iplsr, PLINT flags); //%name plcpstrm +/* Calculate continuous time from broken-down time for current stream. */ + void c_plctime(PLINT year, PLINT month, PLINT day, PLINT hour, PLINT min, PLFLT sec, PLFLT *ctime); //%name plctime //%output ctime + /* Converts input values from relative device coordinates to relative plot */ /* coordinates. */ @@ -1360,6 +1388,14 @@ void c_plspage(PLFLT xp, PLFLT yp, PLINT xleng, PLINT yleng, PLINT xoff, PLINT yoff); //%name plspage +/* Set the colors for color table 0 from a cmap0 file */ + + void c_plspal0(const char *filename); //%name plspal0 + +/* Set the colors for color table 1 from a cmap1 file */ + +void c_plspal1(const char *filename); //%name plspal1 + /* Set the pause (on end-of-page) status */ void c_plspause(PLINT pause); //%name plspause Modified: trunk/examples/octave/x03c.m =================================================================== --- trunk/examples/octave/x03c.m 2009-08-17 17:07:49 UTC (rev 10270) +++ trunk/examples/octave/x03c.m 2009-08-17 17:51:31 UTC (rev 10271) @@ -46,13 +46,11 @@ ## Set up viewport and window, but do not draw box */ plenv(-1.3, 1.3, -1.3, 1.3, 1, -2); - for i=1:10 - x(:) = 0.1 * i * x0(:); - y(:) = 0.1 * i * y0(:); - - ## Draw circles for polar grid */ - plline(x', y'); - endfor + ## Draw circles for polar grid + for i=1:10 + plarc(0.0, 0.0, 0.1 * i, 0.1 * i, 0.0, 360.0, 0); + endfor + plcol0(2); for i=0:11 Modified: trunk/examples/octave/x16c.m =================================================================== --- trunk/examples/octave/x16c.m 2009-08-17 17:07:49 UTC (rev 10270) +++ trunk/examples/octave/x16c.m 2009-08-17 17:51:31 UTC (rev 10271) @@ -60,6 +60,9 @@ ## Reduce colors in cmap 0 so that cmap 1 is useful on a 16-color display + ## Load colour palettes + plspal0("cmap0_black_on_white.pal"); + plspal1("cmap1_gray.pal"); plscmap0n(3); ## Initialize plplot @@ -126,6 +129,12 @@ ## Plot using 1d coordinate transform + ## Load colour palettes + plspal0("cmap0_black_on_white.pal"); + plspal1("cmap1_blue_yellow.pal"); + ## Reduce colors in cmap 0 so that cmap 1 is useful on a 16-color display + plscmap0n(3); + pladv(0); plvpor(0.1, 0.9, 0.1, 0.9); plwind(-1.0, 1.0, -1.0, 1.0); @@ -146,6 +155,12 @@ ## Plot using 2d coordinate transform + ## Load colour palettes + plspal0("cmap0_black_on_white.pal"); + plspal1("cmap1_blue_red.pal"); + ## Reduce colors in cmap 0 so that cmap 1 is useful on a 16-color display + plscmap0n(3); + pladv(0); plvpor(0.1, 0.9, 0.1, 0.9); plwind(-1.0, 1.0, -1.0, 1.0); @@ -165,6 +180,12 @@ ## Plot using 2d coordinate transform + ## Load colour palettes + plspal0(""); + plspal1(""); + ## Reduce colors in cmap 0 so that cmap 1 is useful on a 16-color display + plscmap0n(3); + pladv(0); plvpor(0.1, 0.9, 0.1, 0.9); plwind(-1.0, 1.0, -1.0, 1.0); @@ -186,6 +207,12 @@ ## Plot using 2d coordinate transform and exclusion if (0) ## exclusion not implemented + ## Load colour palettes + plspal0("cmap0_black_on_white.pal"); + plspal1("cmap1_gray.pal"); + ## Reduce colors in cmap 0 so that cmap 1 is useful on a 16-color display + plscmap0n(3); + pladv(0); plvpor(0.1, 0.9, 0.1, 0.9); plwind(-1.0, 1.0, -1.0, 1.0); @@ -204,6 +231,12 @@ ### Example with polar coordinates. PERIMETERPTS=100; + ## Load colour palettes + plspal0("cmap0_black_on_white.pal"); + plspal1("cmap1_gray.pal"); + ## Reduce colors in cmap 0 so that cmap 1 is useful on a 16-color display + plscmap0n(3); + pladv(0); plvpor( .1, .9, .1, .9 ); plwind( -1., 1., -1., 1. ); Modified: trunk/examples/octave/x29c.m =================================================================== --- trunk/examples/octave/x29c.m 2009-08-17 17:07:49 UTC (rev 10270) +++ trunk/examples/octave/x29c.m 2009-08-17 17:51:31 UTC (rev 10271) @@ -41,6 +41,8 @@ plot2(); plot3(); + + plot4(); ## Clean up plend1(); @@ -199,6 +201,118 @@ plline(x', y'); endfunction + +function plot4 + + ## TAI-UTC (seconds) as a function of time. + ## Use Besselian epochs as the continuous time interval just to prove + ## this does not introduce any issues. + ## Use the definition given in http://en.wikipedia.org/wiki/Besselian_epoch + ## B = 1900. + (JD -2415020.31352)/365.242198781 + ## ==> (as calculated with aid of "bc -l" command) + ## B = (MJD + 678940.364163900)/365.242198781 + ## ==> + ## MJD = B*365.24219878 - 678940.364163900 + scale = 365.242198781; + offset1 = -678940.; + offset2 = -0.3641639; + plconfigtime(scale, offset1, offset2, 0x0, 0, 0, 0, 0, 0, 0, 0.); + + for kind=0:6 + if (kind == 0) + xmin = plctime(1950,0,2,0,0,0.); + xmax = plctime(2020,0,2,0,0,0.); + npts = 70*12 + 1; + ymin = 0.0; + ymax = 36.0; + time_format = "%Y%"; + if_TAI_time_format = 1; + title_suffix = "from 1950 to 2020"; + xtitle = "Year"; + xlabel_step = 10.; + elseif (kind == 1 || kind ==2) + xmin = plctime(1961,7,1,0,0,1.64757-.20); + xmax = plctime(1961,7,1,0,0,1.64757+.20); + npts = 1001; + ymin = 1.625; + ymax = 1.725; + time_format = "%S%2%"; + title_suffix = "near 1961-08-01 (TAI)"; + xlabel_step = 0.05/(scale*86400.); + if (kind == 1) + if_TAI_time_format = 1; + xtitle = "Seconds (TAI)"; + else + if_TAI_time_format = 0; + xtitle = "Seconds (TAI) labelled with corresponding UTC"; + endif + elseif (kind == 3 || kind ==4) + xmin = plctime(1963,10,1,0,0,2.6972788-.20); + xmax = plctime(1963,10,1,0,0,2.6972788+.20); + npts = 1001; + ymin = 2.55; + ymax = 2.75; + time_format = "%S%2%"; + title_suffix = "near 1963-11-01 (TAI)"; + xlabel_step = 0.05/(scale*86400.); + if (kind == 3) + if_TAI_time_format = 1; + xtitle = "Seconds (TAI)"; + else + if_TAI_time_format = 0; + xtitle = "Seconds (TAI) labelled with corresponding UTC"; + endif + elseif (kind == 5 || kind == 6) + xmin = plctime(2009,0,1,0,0,34.-5.); + xmax = plctime(2009,0,1,0,0,34.+5.); + npts = 1001; + ymin = 32.5; + ymax = 34.5; + time_format = "%S%2%"; + title_suffix = "near 2009-01-01 (TAI)"; + xlabel_step = 1./(scale*86400.); + if (kind == 5) + if_TAI_time_format = 1; + xtitle = "Seconds (TAI)"; + else + if_TAI_time_format = 0; + xtitle = "Seconds (TAI) labelled with corresponding UTC"; + endif + endif + + x = xmin + (0:npts-1)*(xmax-xmin)/(npts-1); + utc = zeros(npts,1); + plconfigtime(scale, offset1, offset2, 0x0, 0, 0, 0, 0, 0, 0, 0.); + tai = x; + [tai_year, tai_month, tai_day, tai_hour, tai_min, tai_sec] = plbtime(tai); + plconfigtime(scale, offset1, offset2, 0x2, 0, 0, 0, 0, 0, 0, 0.); + [utc_year, utc_month, utc_day, utc_hour, utc_min, utc_sec] = plbtime(tai); + plconfigtime(scale, offset1, offset2, 0x0, 0, 0, 0, 0, 0, 0, 0.); + utc = plctime(utc_year, utc_month, utc_day, utc_hour, utc_min, utc_sec); + y = (tai-utc)*scale*86400.0; + + pladv(0); + plvsta(); + plwind(xmin, xmax, ymin, ymax); + plcol0(1); + if (if_TAI_time_format) + plconfigtime(scale, offset1, offset2, 0x0, 0, 0, 0, 0, 0, 0, 0.); + else + plconfigtime(scale, offset1, offset2, 0x2, 0, 0, 0, 0, 0, 0, 0.); + endif + pltimefmt(time_format); + plbox("bcnstd", xlabel_step, 0, "bcnstv", 0., 0); + plcol0(3); + title = strcat("@frPLplot Example 29 - TAI-UTC ", title_suffix); + pllab(xtitle, "TAI-UTC (sec)", title); + + plcol0(4); + + plline(x', y'); + endfor +endfunction + + ix29c This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sm...@us...> - 2009-08-17 19:07:49
|
Revision: 10272 http://plplot.svn.sourceforge.net/plplot/?rev=10272&view=rev Author: smekal Date: 2009-08-17 19:07:32 +0000 (Mon, 17 Aug 2009) Log Message: ----------- Added D examples 21 and 22. Added functions plseed() and plMinMax2dGrid to D bindings. Fixed possible bug in plscmap1l() and plscmap1la(). Modified Paths: -------------- trunk/bindings/d/plplot.d trunk/examples/d/CMakeLists.txt trunk/plplot_test/test_d.sh.in Added Paths: ----------- trunk/examples/d/x21d.d trunk/examples/d/x22d.d Modified: trunk/bindings/d/plplot.d =================================================================== --- trunk/bindings/d/plplot.d 2009-08-17 17:51:31 UTC (rev 10271) +++ trunk/bindings/d/plplot.d 2009-08-17 19:07:32 UTC (rev 10272) @@ -3,7 +3,6 @@ private import std.string; - // improved D interface // certain functions must be declared as C functions so that PLplot @@ -504,9 +503,11 @@ assert(npts==coord1.length, "plscmap1l(): Arrays must be of same length!"); assert(npts==coord2.length, "plscmap1l(): Arrays must be of same length!"); assert(npts==coord3.length, "plscmap1l(): Arrays must be of same length!"); - if(rev!=null) + if(rev!=null) { assert(npts-1==rev.length, "plscmap1l(): Array rev must be of same length then other arrays minus 1!"); - c_plscmap1l(itype, npts, intensity.ptr, coord1.ptr, coord2.ptr, coord3.ptr, rev.ptr); + c_plscmap1l(itype, npts, intensity.ptr, coord1.ptr, coord2.ptr, coord3.ptr, rev.ptr); + } else + c_plscmap1l(itype, npts, intensity.ptr, coord1.ptr, coord2.ptr, coord3.ptr, null); } @@ -521,9 +522,11 @@ assert(npts==coord2.length, "plscmap1la(): Arrays must be of same length!"); assert(npts==coord3.length, "plscmap1la(): Arrays must be of same length!"); assert(npts==a.length, "plscmap1la(): Arrays must be of same length!"); - if(rev!=null) + if(rev!=null) { assert(npts-1==rev.length, "plscmap1la(): Array rev must be of same length then other arrays minus 1!"); - c_plscmap1la(itype, npts, intensity.ptr, coord1.ptr, coord2.ptr, coord3.ptr, a.ptr, rev.ptr); + c_plscmap1la(itype, npts, intensity.ptr, coord1.ptr, coord2.ptr, coord3.ptr, a.ptr, rev.ptr); + } else + c_plscmap1la(itype, npts, intensity.ptr, coord1.ptr, coord2.ptr, coord3.ptr, a.ptr, null); } /* Set the device (keyword) name */ @@ -797,7 +800,10 @@ //PLFLT plGetFlt(char *s); /* Find the maximum and minimum of a 2d matrix allocated with plAllc2dGrid(). */ -//void plMinMax2dGrid(PLFLT **f, PLINT nx, PLINT ny, PLFLT *fmax, PLFLT *fmin); +void plMinMax2dGrid(PLFLT[][] f, out PLFLT fmax, out PLFLT fmin) +{ + plMinMax2dGrid(convert_array(f), f.length, f[0].length, &fmax, &fmin); +} /* Wait for graphics input event and translate to world coordinates */ //int plGetCursor(PLGraphicsIn *gin); @@ -1278,6 +1284,7 @@ alias c_plsdiori plsdiori; alias c_plsdiplt plsdiplt; alias c_plsdiplz plsdiplz; +alias c_plseed plseed; alias c_plsesc plsesc; //alias c_plsetopt plsetopt; alias c_plsfam plsfam; @@ -1780,13 +1787,14 @@ void c_plsdiplt(PLFLT xmin, PLFLT ymin, PLFLT xmax, PLFLT ymax); /* Set window into plot space incrementally (zoom) */ +void c_plsdiplz(PLFLT xmin, PLFLT ymin, PLFLT xmax, PLFLT ymax); -void c_plsdiplz(PLFLT xmin, PLFLT ymin, PLFLT xmax, PLFLT ymax); +/* Set seed for internal random number generator */ +void c_plseed(uint s); /* Set the escape character for text strings. */ +void c_plsesc(char esc); -void c_plsesc(char esc); - /* Set family file parameters */ void c_plsfam(PLINT fam, PLINT num, PLINT bmax); @@ -2105,9 +2113,8 @@ void plFree2dGrid(PLFLT **f, PLINT nx, PLINT ny); /* Find the maximum and minimum of a 2d matrix allocated with plAllc2dGrid(). */ +void plMinMax2dGrid(PLFLT **f, PLINT nx, PLINT ny, PLFLT *fmax, PLFLT *fmin); -void plMinMax2dGrid(PLFLT **f, PLINT nx, PLINT ny, PLFLT *fmax, PLFLT *fmin); - /* Wait for graphics input event and translate to world coordinates */ int plGetCursor(PLGraphicsIn *gin); Modified: trunk/examples/d/CMakeLists.txt =================================================================== --- trunk/examples/d/CMakeLists.txt 2009-08-17 17:51:31 UTC (rev 10271) +++ trunk/examples/d/CMakeLists.txt 2009-08-17 19:07:32 UTC (rev 10272) @@ -45,6 +45,8 @@ "17" "18" "19" + "21" + "22" "23" "24" "25" Added: trunk/examples/d/x21d.d =================================================================== --- trunk/examples/d/x21d.d (rev 0) +++ trunk/examples/d/x21d.d 2009-08-17 19:07:32 UTC (rev 10272) @@ -0,0 +1,246 @@ +/* $Id:$ + Grid data demo + + Copyright (C) 2009 Werner Smekal + + This file is part of PLplot. + + PLplot is free software; you can redistribute it and/or modify + it under the terms of the GNU General Library Public License as published + by the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + PLplot is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with PLplot; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +import std.math; +import std.stdio; + +import plplot; + +/* Options data structure definition. */ +PLINT pts = 500; +PLINT xp = 25; +PLINT yp = 20; +PLINT nl = 16; +int knn_order = 20; +PLFLT threshold = 1.001; +PLFLT wmin = -1e3; +int randn = 0; +int rosen = 0; + + +PLFLT xm, xM, ym, yM; + +int main(char[][] args) +{ + string[] title = [ "Cubic Spline Approximation", + "Delaunay Linear Interpolation", + "Natural Neighbors Interpolation", + "KNN Inv. Distance Weighted", + "3NN Linear Interpolation", + "4NN Around Inv. Dist. Weighted" ]; + + xm = ym = -0.2; + xM = yM = 0.6; + + /* plMergeOpts(options, "x21c options", NULL); */ + plparseopts(args, PL_PARSE_FULL); + + PLFLT[] opt = [ 0.0, 0.0, wmin, knn_order, threshold, 0.0 ]; + + /* Initialize plplot */ + plinit(); + + /* Initialise random number generator */ + plseed(5489); + + PLFLT[] x, y, z; + x.length = y.length = z.length = pts; + create_data(x, y, z); /* the sampled data */ + PLFLT zmin = z[0]; + PLFLT zmax = z[0]; + for(int i=1; i<pts; i++) { + if(z[i] > zmax) + zmax = z[i]; + if(z[i] < zmin) + zmin = z[i]; + } + + PLFLT[] xg, yg; + xg.length = xp; + yg.length = yp; + create_grid(xg, yg); /* grid the data at */ + + PLFLT[][]zg = new PLFLT[][xp]; + for(int i=0; i<xp; i++) + zg[i] = new PLFLT[yp]; + + PLFLT[] clev = new PLFLT[nl]; + + plcol0(1); + plenv(xm, xM, ym, yM, 2, 0); + plcol0(15); + pllab("X", "Y", "The original data sampling"); + plcol0(2); + plpoin(x, y, 5); + pladv(0); + + plssub(3, 2); + + for(int k=0; k<2; k++) { + pladv(0); + for(int alg=1; alg<7; alg++) { + plgriddata(x, y, z, xg, yg, zg, alg, opt[alg-1]); + + /* - CSA can generate NaNs (only interpolates?!). + * - DTLI and NNI can generate NaNs for points outside the convex hull + * of the data points. + * - NNLI can generate NaNs if a sufficiently thick triangle is not found + * + * PLplot should be NaN/Inf aware, but changing it now is quite a job... + * so, instead of not plotting the NaN regions, a weighted average over + * the neighbors is done. + */ + + if(alg==GRID_CSA || alg==GRID_DTLI || alg==GRID_NNLI || alg==GRID_NNI) { + PLFLT dist, d; + + for(int i=0; i<xp; i++) { + for(int j=0; j<yp; j++) { + if(isnan(zg[i][j])) { /* average (IDW) over the 8 neighbors */ + zg[i][j] = 0.0; + dist = 0.0; + + for(int ii=i-1; ii<=i+1 && ii<xp; ii++) { + for(int jj=j-1; jj<=j+1 && jj<yp; jj++) { + if(ii>=0 && jj>=0 && !isnan(zg[ii][jj])) { + d = (abs(ii-i) + abs(jj-j)) == 1 ? 1.0 : 1.4142; + zg[i][j] += zg[ii][jj]/(d*d); + dist += d; + } + } + } + if(dist!=0.0) + zg[i][j] /= dist; + else + zg[i][j] = zmin; + } + } + } + } + + PLFLT lzM, lzm; + plMinMax2dGrid(zg, lzM, lzm); + + lzm = fmin(lzm, zmin); + lzM = fmax(lzM, zmax); + + /* Increase limits slightly to prevent spurious contours + due to rounding errors */ + lzm = lzm-0.01; + lzM = lzM+0.01; + + plcol0(1); + + pladv(alg); + + if(k == 0) { + for(int i=0; i<nl; i++) + clev[i] = lzm + (lzM-lzm)/(nl-1)*i; + + plenv0(xm, xM, ym, yM, 2, 0); + plcol0(15); + pllab("X", "Y", title[alg-1]); + plshades(zg, null, xm, xM, ym, yM, clev, 1, 0, 1, 1); + plcol0(2); + } else { + for(int i=0; i<nl; i++) + clev[i] = lzm + (lzM-lzm)/(nl-1)*i; + + cmap1_init(); + plvpor(0.0, 1.0, 0.0, 0.9); + plwind(-1.1, 0.75, -0.65, 1.20); + /* + * For the comparison to be fair, all plots should have the + * same z values, but to get the max/min of the data generated + * by all algorithms would imply two passes. Keep it simple. + * + * plw3d(1., 1., 1., xm, xM, ym, yM, zmin, zmax, 30, -60); + */ + + plw3d(1., 1., 1., xm, xM, ym, yM, lzm, lzM, 30, -40); + plbox3("bntu", "X", 0., 0, + "bntu", "Y", 0., 0, + "bcdfntu", "Z", 0.5, 0); + plcol0(15); + pllab("", "", title[alg-1]); + plot3dc(xg, yg, zg, DRAW_LINEXY | MAG_COLOR | BASE_CONT, clev); + } + } + } + + plend(); + + return 0; +} + + +void create_grid(PLFLT[] x, PLFLT[] y) +{ + int px = x.length; + int py = y.length; + + for(int i=0; i<px; i++) + x[i] = xm + (xM-xm)*i/(px-1.0); + + for(int i=0; i<py; i++) + y[i] = ym + (yM-ym)*i/(py-1.0); +} + + +void create_data(PLFLT[] x, PLFLT[] y, PLFLT[] z) +{ + int pts = x.length; + assert(pts==y.length, "create_data(): Arrays must be of same length"); + assert(pts==z.length, "create_data(): Arrays must be of same length"); + + PLFLT xt, yt, r; + for(int i=0; i<pts; i++) { + xt = (xM-xm)*plrandd(); + yt = (yM-ym)*plrandd(); + if(!randn) { + x[i] = xt + xm; + y[i] = yt + ym; + } else { /* std=1, meaning that many points are outside the plot range */ + x[i] = sqrt(-2.0*log(xt)) * cos(2.*PI*yt) + xm; + y[i] = sqrt(-2.0*log(xt)) * sin(2.*PI*yt) + ym; + } + if(!rosen) { + r = sqrt(x[i]*x[i] + y[i]*y[i]); + z[i] = exp(-r*r) * cos(2.0*PI*r); + } else + z[i] = log(pow(1.-x[i], 2.9) + 100.0*pow(y[i]-pow(x[i], 2.0), 2.0)); + } +} + + +void cmap1_init() +{ + PLFLT[] i = [ 0.0, 1.0 ]; /* boundaries */ + + PLFLT[] h = [ 240.0, 0.0 ]; /* blue -> green -> yellow -> red */ + PLFLT[] l = [ 0.6, 0.6 ]; + PLFLT[] s = [ 0.8, 0.8 ]; + + plscmap1n(256); + plscmap1l(0, i, h, l, s); +} Added: trunk/examples/d/x22d.d =================================================================== --- trunk/examples/d/x22d.d (rev 0) +++ trunk/examples/d/x22d.d 2009-08-17 19:07:32 UTC (rev 10272) @@ -0,0 +1,312 @@ +/* $Id:$ + + Simple vector plot example + Copyright (C) 2009 Werner Smekal + + + This file is part of PLplot. + + PLplot is free software; you can redistribute it and/or modify + it under the terms of the GNU General Library Public License as published + by the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + PLplot is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with PLplot; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +import std.math; + +import plplot; + +/*--------------------------------------------------------------------------*\ + * main + * + * Generates several simple vector plots. + \*--------------------------------------------------------------------------*/ + + +class plot { + /* + * Vector plot of the circulation about the origin + */ + void circulation() { + const int nx = 20; + const int ny = 20; + + PLFLT dx = 1.0; + PLFLT dy = 1.0; + + PLFLT xmin = -nx/2*dx; + PLFLT xmax = nx/2*dx; + PLFLT ymin = -ny/2*dy; + PLFLT ymax = ny/2*dy; + + PLcGrid2 cgrid2; + cgrid2.xg = new PLFLT[][nx]; + for(int i=0; i<nx; i++) + cgrid2.xg[i] = new PLFLT[ny]; + cgrid2.yg = new PLFLT[][nx]; + for(int i=0; i<nx; i++) + cgrid2.yg[i] = new PLFLT[ny]; + + PLFLT[][]u = new PLFLT[][nx]; + for(int i=0; i<nx; i++) + u[i] = new PLFLT[ny]; + PLFLT[][]v = new PLFLT[][nx]; + for(int i=0; i<nx; i++) + v[i] = new PLFLT[ny]; + + /* Create data - circulation around the origin. */ + PLFLT x, y; + for(int i=0; i<nx; i++) { + x = (i-nx/2+0.5)*dx; + for(int j=0; j<ny; j++) { + y = (j-ny/2+0.5)*dy; + cgrid2.xg[i][j] = x; + cgrid2.yg[i][j] = y; + u[i][j] = y; + v[i][j] = -x; + } + } + + /* Plot vectors with default arrows */ + plenv(xmin, xmax, ymin, ymax, 0, 0); + pllab("(x)", "(y)", "#frPLplot Example 22 - circulation"); + plcol0(2); + plvect(u, v, 0.0, cgrid2); + plcol0(1); + } + + /* + * Vector plot of flow through a constricted pipe + */ + void + constriction() { + const int nx = 20; + const int ny = 20; + + PLFLT dx = 1.0; + PLFLT dy = 1.0; + + PLFLT xmin = -nx/2*dx; + PLFLT xmax = nx/2*dx; + PLFLT ymin = -ny/2*dy; + PLFLT ymax = ny/2*dy; + + PLcGrid2 cgrid2; + cgrid2.xg = new PLFLT[][nx]; + for(int i=0; i<nx; i++) + cgrid2.xg[i] = new PLFLT[ny]; + cgrid2.yg = new PLFLT[][nx]; + for(int i=0; i<nx; i++) + cgrid2.yg[i] = new PLFLT[ny]; + + PLFLT[][]u = new PLFLT[][nx]; + for(int i=0; i<nx; i++) + u[i] = new PLFLT[ny]; + PLFLT[][]v = new PLFLT[][nx]; + for(int i=0; i<nx; i++) + v[i] = new PLFLT[ny]; + + PLFLT Q = 2.0; + PLFLT x, y, b, dbdx; + for(int i=0; i<nx; i++) { + x = (i-nx/2+0.5)*dx; + for(int j=0; j<ny; j++) { + y = (j-ny/2+0.5)*dy; + cgrid2.xg[i][j] = x; + cgrid2.yg[i][j] = y; + b = ymax/4.0*(3-cos(PI*x/xmax)); + if(fabs(y)<b) { + dbdx = ymax/4.0*sin(PI*x/xmax)*y/b; + u[i][j] = Q*ymax/b; + v[i][j] = dbdx*u[i][j]; + } else { + u[i][j] = 0.0; + v[i][j] = 0.0; + } + } + } + + plenv(xmin, xmax, ymin, ymax, 0, 0); + pllab("(x)", "(y)", "#frPLplot Example 22 - constriction"); + plcol0(2); + plvect(u, v, -0.5, cgrid2); + plcol0(1); + } + + /*--------------------------------------------------------------------------*\ + * f2mnmx + * + * Returns min & max of input 2d array. + \*--------------------------------------------------------------------------*/ + void f2mnmx(PLFLT[][] f, out PLFLT fmn, out PLFLT fmx) + { + fmx = f[0][0]; + fmn = fmx; + + for(int i=0; i<f.length; i++) { + for(int j=0; j<f[i].length; j++) { + fmx = fmax(fmx, f[i][j]); + fmn = fmin(fmn, f[i][j]); + } + } + } + + + /* + * Vector plot of the gradient of a shielded potential (see example 9) + */ + void potential() { + const int nper = 100; + const int nlevel = 10; + const int nr = 20; + const int ntheta = 20; + + PLcGrid2 cgrid2; + cgrid2.xg = new PLFLT[][nr]; + for(int i=0; i<nr; i++) + cgrid2.xg[i] = new PLFLT[ntheta]; + cgrid2.yg = new PLFLT[][nr]; + for(int i=0; i<nr; i++) + cgrid2.yg[i] = new PLFLT[ntheta]; + + PLFLT[][]u = new PLFLT[][nr]; + for(int i=0; i<nr; i++) + u[i] = new PLFLT[ntheta]; + PLFLT[][]v = new PLFLT[][nr]; + for(int i=0; i<nr; i++) + v[i] = new PLFLT[ntheta]; + PLFLT[][]z = new PLFLT[][nr]; + for(int i=0; i<nr; i++) + z[i] = new PLFLT[ntheta]; + + /* Potential inside a conducting cylinder (or sphere) by method of images. + * Charge 1 is placed at (d1, d1), with image charge at (d2, d2). + * Charge 2 is placed at (d1, -d1), with image charge at (d2, -d2). + * Also put in smoothing term at small distances. + */ + + PLFLT rmax = nr; + + PLFLT eps = 2.0; + + PLFLT q1 = 1.0; + PLFLT d1 = rmax/4.0; + + PLFLT q1i = - q1*rmax/d1; + PLFLT d1i = pow(rmax, 2.0)/d1; + + PLFLT q2 = -1.0; + PLFLT d2 = rmax/4.0; + + PLFLT q2i = - q2*rmax/d2; + PLFLT d2i = pow(rmax, 2.0)/d2; + + PLFLT r, theta, x, y; + PLFLT div1, div1i, div2, div2i; + for(int i=0; i<nr; i++) { + r = 0.5+i; + for(int j=0; j<ntheta; j++) { + theta = 2.0*PI/(ntheta-1)*(0.5+j); + x = r*cos(theta); + y = r*sin(theta); + cgrid2.xg[i][j] = x; + cgrid2.yg[i][j] = y; + div1 = sqrt(pow(x-d1, 2.0) + pow(y-d1, 2.0) + pow(eps, 2.0)); + div1i = sqrt(pow(x-d1i, 2.0) + pow(y-d1i, 2.0) + pow(eps, 2.0)); + div2 = sqrt(pow(x-d2, 2.0) + pow(y+d2, 2.0) + pow(eps, 2.0)); + div2i = sqrt(pow(x-d2i, 2.0) + pow(y+d2i, 2.0) + pow(eps, 2.0)); + z[i][j] = q1/div1 + q1i/div1i + q2/div2 + q2i/div2i; + u[i][j] = -q1*(x-d1)/pow(div1, 3.0) - q1i*(x-d1i)/pow(div1i, 3.0) + - q2*(x-d2)/pow(div2, 3.0) - q2i*(x-d2i)/pow(div2i, 3.0); + v[i][j] = -q1*(y-d1)/pow(div1, 3.0) - q1i*(y-d1i)/pow(div1i, 3.0) + - q2*(y+d2)/pow(div2, 3.0) - q2i*(y+d2i)/pow(div2i, 3.0); + } + } + + PLFLT xmin, xmax, ymin, ymax, zmin, zmax; + f2mnmx(cgrid2.xg, xmin, xmax); + f2mnmx(cgrid2.yg, ymin, ymax); + f2mnmx(z, zmin, zmax); + + plenv(xmin, xmax, ymin, ymax, 0, 0); + pllab("(x)", "(y)", "#frPLplot Example 22 - potential gradient vector plot"); + + /* Plot contours of the potential */ + PLFLT dz = (zmax-zmin)/nlevel; + PLFLT[] clevel = new PLFLT[nlevel]; + for(int i=0; i<nlevel; i++) + clevel[i] = zmin + (i+0.5)*dz; + + plcol0(3); + pllsty(2); + plcont(z, 1, nr, 1, ntheta, clevel, cgrid2); + pllsty(1); + plcol0(1); + + /* Plot the vectors of the gradient of the potential */ + plcol0(2); + plvect(u, v, 25.0, cgrid2); + plcol0(1); + + /* Plot the perimeter of the cylinder */ + PLFLT[] px = new PLFLT[nper]; + PLFLT[] py = new PLFLT[nper]; + for(int i=0; i<nper; i++) { + theta = (2.0*PI/(nper-1))*i; + px[i] = rmax*cos(theta); + py[i] = rmax*sin(theta); + } + plline(px, py); + } +} + + +int main(char[][] args) +{ + /* Parse and process command line arguments */ + plparseopts(args, PL_PARSE_FULL); + + /* Initialize plplot */ + plinit(); + + plot myPlot = new plot; + + myPlot.circulation(); + + PLINT fill = 0; + + /* Pairs of points making the line segments used to plot the user defined arrow */ + PLFLT[] arrow_x = [ -0.5, 0.5, 0.3, 0.5, 0.3, 0.5 ]; + PLFLT[] arrow_y = [ 0.0, 0.0, 0.2, 0.0, -0.2, 0.0 ]; + + /* Set arrow style using arrow_x and arrow_y then + plot using these arrows.*/ + plsvect(arrow_x, arrow_y, fill); + myPlot.constriction(); + + /* Pairs of points making the line segments used to plot the user defined arrow */ + PLFLT[] arrow2_x = [ -0.5, 0.3, 0.3, 0.5, 0.3, 0.3 ]; + PLFLT[] arrow2_y = [ 0.0, 0.0, 0.2, 0.0, -0.2, 0.0 ]; + + /* Set arrow style using arrow2_x and arrow2_y then + plot using these filled arrows. */ + fill = 1; + plsvect(arrow2_x, arrow2_y, fill); + myPlot.constriction(); + + myPlot.potential(); + + plend(); + + return 0; +} Modified: trunk/plplot_test/test_d.sh.in =================================================================== --- trunk/plplot_test/test_d.sh.in 2009-08-17 17:51:31 UTC (rev 10271) +++ trunk/plplot_test/test_d.sh.in 2009-08-17 19:07:32 UTC (rev 10272) @@ -31,7 +31,7 @@ # 20-22, 28, and 31 not implemented yet. # example 14 excluded until plgdev fixed since the bad driver information # causes run-time errors. -for index in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 23 24 25 26 27 28 29 30 31; do +for index in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 30 31; do if [ "$verbose_test" ] ; then echo "x${index}${lang}" fi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sm...@us...> - 2009-08-18 08:35:43
|
Revision: 10277 http://plplot.svn.sourceforge.net/plplot/?rev=10277&view=rev Author: smekal Date: 2009-08-18 08:35:33 +0000 (Tue, 18 Aug 2009) Log Message: ----------- Added D example 20 (differences in postscript output, although I can't spot any difference with the eye). Fixed D example 29. Modified Paths: -------------- trunk/examples/d/CMakeLists.txt trunk/examples/d/x21d.d trunk/examples/d/x29d.d trunk/plplot_test/test_d.sh.in Added Paths: ----------- trunk/examples/d/x20d.d Modified: trunk/examples/d/CMakeLists.txt =================================================================== --- trunk/examples/d/CMakeLists.txt 2009-08-18 08:33:44 UTC (rev 10276) +++ trunk/examples/d/CMakeLists.txt 2009-08-18 08:35:33 UTC (rev 10277) @@ -45,6 +45,7 @@ "17" "18" "19" + "20" "21" "22" "23" Added: trunk/examples/d/x20d.d =================================================================== --- trunk/examples/d/x20d.d (rev 0) +++ trunk/examples/d/x20d.d 2009-08-18 08:35:33 UTC (rev 10277) @@ -0,0 +1,284 @@ +/* $Id: $ + + plimage demo + +*/ + +import std.math; +import std.stdio; +import std.stream; + +import plplot; + +int dbg = 0; +int nosombrero = 0; +int nointeractive = 0; +string f_name; + +struct stretch_data { + PLFLT xmin, xmax, ymin, ymax; + PLFLT stretch; +}; + + +extern (C) { + /* Transformation function */ + void mypltr(PLFLT x, PLFLT y, PLFLT *tx, PLFLT *ty, PLPointer pltr_data) + { + stretch_data* s = cast(stretch_data *)pltr_data; + PLFLT x0 = (s.xmin + s.xmax)*0.5; + PLFLT y0 = (s.ymin + s.ymax)*0.5; + PLFLT dy = (s.ymax-s.ymin)*0.5; + *tx = x0 + (x0-x)*(1.0 - s.stretch*cos((y-y0)/dy*PI*0.5)); + *ty = y; + } +} + +int main(char[][] args) +{ + const int XDIM = 260; + const int YDIM = 220; + + /* + Bugs in plimage(): + -at high magnifications, the left and right edge are ragged, try + ./x20c -dev xwin -wplt 0.3,0.3,0.6,0.6 -ori 0.5 + + Bugs in x20c.c: + -if the window is resized after a selection is made on "lena", when + making a new selection the old one will re-appear. + */ + + /* Parse and process command line arguments */ + // plMergeOpts(options, "x20c options", NULL); + plparseopts(args, PL_PARSE_FULL); + + /* Initialize plplot */ + plinit(); + + PLFLT[][]z = new PLFLT[][XDIM]; + for(int i=0; i<XDIM; i++) + z[i] = new PLFLT[YDIM]; + + /* view image border pixels */ + if(dbg) { + plenv(1.0, XDIM, 1.0, YDIM, 1, 1); /* no plot box */ + + /* build a one pixel square border, for diagnostics */ + for(int i=0; i<XDIM; i++) + z[i][YDIM-1] = 1.0; /* right */ + for(int i=0; i<XDIM; i++) + z[i][0] = 1.0; /* left */ + + for(int i=0; i<YDIM; i++) + z[0][i] = 1.0; /* top */ + for(int i=0; i<YDIM; i++) + z[XDIM-1][i] = 1.0; /* botton */ + + pllab("...around a blue square."," ","A red border should appear..."); + + plimage(z, 1.0, XDIM, 1.0, YDIM, 0., 0., 1.0, XDIM, 1., YDIM); + } + + PLFLT[] x = new PLFLT[XDIM]; + PLFLT[] y = new PLFLT[YDIM]; + + /* sombrero-like demo */ + if(!nosombrero) { + PLFLT[][]r = new PLFLT[][XDIM]; + for(int i=0; i<XDIM; i++) + r[i] = new PLFLT[YDIM]; + + plcol0(2); /* draw a yellow plot box, useful for diagnostics! :( */ + plenv(0.0, 2.0*PI, 0, 3.0*PI, 1, -1); + + for(int i=0; i<XDIM; i++) + x[i] = i*2.0*PI/(XDIM-1); + for(int i=0; i<YDIM; i++) + y[i] = i*3.0*PI/(YDIM-1); + + for(int i=0; i<XDIM; i++) + for(int j=0; j<YDIM; j++) { + r[i][j] = sqrt(x[i]*x[i]+y[j]*y[j])+1e-3; + z[i][j] = sin(r[i][j]) / (r[i][j]); + } + + pllab("No, an amplitude clipped \"sombrero\"", "", "Saturn?"); + plptex(2.0, 2.0, 3.0, 4.0, 0.0, "Transparent image"); + plimage(z, 0.0, 2.0*PI, 0.0, 3.0*PI, 0.05, 1.0, + 0.0, 2.0*PI, 0.0, 3.0*PI); + + /* save the plot */ + if(f_name.length!=0) + save_plot(f_name); + } + + /* read Lena image */ + /* Note we try two different locations to cover the case where this + * examples is being run from the test_c.sh script */ + int width, height, num_col; + PLFLT[][] img_f; + if (read_img("lena.pgm", img_f, width, height, num_col)) { + if (read_img("../lena.pgm", img_f, width, height, num_col)) { + fwritefln(stderr, "No such file"); + plend(); + return 1; + } + } + + /* set gray colormap */ + gray_cmap(num_col); + + /* display Lena */ + plenv(1., width, 1., height, 1, -1); + + if(!nointeractive) + pllab("Set and drag Button 1 to (re)set selection, Button 2 to finish."," ","Lena..."); + else + pllab(""," ","Lena..."); + + plimage(img_f, 1., width, 1., height, 0., 0., + 1., width, 1., height); + + /* selection/expansion demo */ + if(!nointeractive) { + PLFLT xi = 200.0; + PLFLT xe = 330.0; + PLFLT yi = 280.0; + PLFLT ye = 220.0; + + if(get_clip(xi, xe, yi, ye)) { /* get selection rectangle */ + plend(); + return 0; + } + + plspause(0); + pladv(0); + + /* display selection only */ + plimage(img_f, 1., width, 1., height, 0., 0., xi, xe, ye, yi); + + plspause(1); + + /* zoom in selection */ + plenv(xi, xe, ye, yi, 1, -1); + plimage(img_f, 1., width, 1., height, 0., 0., xi, xe, ye, yi); + } + + /* Base the dynamic range on the image contents. */ + PLFLT img_min, img_max; + plMinMax2dGrid(img_f, img_max, img_min); + + /* Draw a saturated version of the original image. Only use the middle 50% + of the image's full dynamic range. */ + plcol0(2); + plenv(0, width, 0, height, 1, -1); + pllab("", "", "Reduced dynamic range image example"); + plimagefr(img_f, 0.0, cast(PLFLT)width, 0.0, cast(PLFLT)height, 0.0, 0.0, + img_min+img_max*0.25, img_max-img_max*0.25); + + /* Draw a distorted version of the original image, showing its full dynamic range. */ + plenv(0, width, 0, height, 1, -1); + pllab("", "", "Distorted image example"); + + stretch_data stretch = { 0, width, 0, height, 0.5 }; + + /* In C / C++ the following would work, with plimagefr directly calling + mypltr. For compatibilty with other language bindings the same effect + can be achieved by generating the transformed grid first and then + using pltr2. */ + plimagefr(img_f, 0.0, width, 0.0, height, 0.0, 0.0, img_min, img_max, &mypltr, cast(PLPointer)&stretch); + + plend(); + + return 0; +} + + +/* read image from file in binary ppm format */ +int read_img(string fname, out PLFLT[][] img_f, out int width, out int height, out int num_col) +{ + char* img; + + BufferedFile input = new BufferedFile; + try { + input.open(fname, FileMode.In); + + string ver; + input.readf("%s", &ver); + + if(ver != "P5") /* I only understand this! */ + return 1; + + char dummy; + char[] result; + input.read(dummy); + while(dummy == '#') { + result=input.readLine(); + if(result.length==0) + result=input.readLine(); // workaround: for some reason the first call returns empty string + input.read(dummy); + } + input.seek(-1, SeekPos.Current); + + if(input.readf("%d %d %d", &width, &height, &num_col) != 9) /* width, height num colors */ + return 1; + + img = (new char[width*height]).ptr; + + img_f = new PLFLT[][width]; + for(int i=0; i<width; i++) + img_f[i] = new PLFLT[height]; + + input.readExact(img, width*height); + } catch(OpenException exception) { + return 1; + } finally { + input.close(); + } + + for(int i=0; i<width; i++) + for(int j=0; j<height; j++) + img_f[i][j] = img[(height-1-j)*width+i]; /* flip image up-down */ + + return 0; +} + + +/* save plot */ +void save_plot(string fname) +{ + PLINT cur_strm, new_strm; + + plgstrm(&cur_strm); /* get current stream */ + plmkstrm(&new_strm); /* create a new one */ + + plsdev("psc"); /* new device type. Use a known existing driver */ + plsfnam(fname); /* file name */ + + plcpstrm(cur_strm, 0); /* copy old stream parameters to new stream */ + plreplot(); /* do the save */ + plend1(); /* close new device */ + + plsstrm(cur_strm); /* and return to previous one */ +} + + +/* get selection square interactively */ +int get_clip(ref PLFLT xi, ref PLFLT xe, ref PLFLT yi, ref PLFLT ye) +{ + return 0; +} + + +/* set gray colormap */ +void gray_cmap(PLINT num_col) +{ + PLFLT[] r = [ 0.0, 1.0 ]; + PLFLT[] g = [ 0.0, 1.0 ]; + PLFLT[] b = [ 0.0, 1.0 ]; + PLFLT[] pos = [ 0.0, 1.0 ]; + + plscmap1n(256); + plscmap1l(1, pos, r, g, b); +} Modified: trunk/examples/d/x21d.d =================================================================== --- trunk/examples/d/x21d.d 2009-08-18 08:33:44 UTC (rev 10276) +++ trunk/examples/d/x21d.d 2009-08-18 08:35:33 UTC (rev 10277) @@ -22,7 +22,6 @@ */ import std.math; -import std.stdio; import plplot; Modified: trunk/examples/d/x29d.d =================================================================== --- trunk/examples/d/x29d.d 2009-08-18 08:33:44 UTC (rev 10276) +++ trunk/examples/d/x29d.d 2009-08-18 08:35:33 UTC (rev 10277) @@ -63,6 +63,7 @@ myPlot.page1(); myPlot.page2(); myPlot.page3(); + myPlot.page4(); /* Don't forget to call plend() to finish off! */ plend(); @@ -226,4 +227,127 @@ plpoin(x, y, 2); plline(x, y); } + + void page4() + { + /* TAI-UTC (seconds) as a function of time. + Use Besselian epochs as the continuous time interval just to prove + this does not introduce any issues. */ + + /* Use the definition given in http://en.wikipedia.org/wiki/Besselian_epoch + * B = 1900. + (JD -2415020.31352)/365.242198781 + * ==> (as calculated with aid of "bc -l" command) + * B = (MJD + 678940.364163900)/365.242198781 + * ==> + * MJD = B*365.24219878 - 678940.364163900 */ + PLFLT scale = 365.242198781; + PLFLT offset1 = -678940.; + PLFLT offset2 = -0.3641639; + plconfigtime(scale, offset1, offset2, 0x0, 0, 0, 0, 0, 0, 0, 0.); + + PLFLT xmin, xmax, ymin, ymax, xlabel_step; + int npts, if_TAI_time_format; + string time_format, title_suffix, xtitle; + for(int kind=0; kind<7; kind++) { + if(kind == 0) { + plctime(1950, 0, 2, 0, 0, 0.0, &xmin); + plctime(2020, 0, 2, 0, 0, 0.0, &xmax); + npts = 70*12 + 1; + ymin = 0.0; + ymax = 36.0; + time_format = "%Y%"; + if_TAI_time_format = 1; + title_suffix = "from 1950 to 2020"; + xtitle = "Year"; + xlabel_step = 10.0; + } else if(kind==1 || kind==2) { + plctime(1961, 7, 1, 0, 0, 1.64757-0.20, &xmin); + plctime(1961, 7, 1, 0, 0, 1.64757+0.20, &xmax); + npts = 1001; + ymin = 1.625; + ymax = 1.725; + time_format = "%S%2%"; + title_suffix = "near 1961-08-01 (TAI)"; + xlabel_step = 0.05/(scale*86400.); + if (kind == 1) { + if_TAI_time_format = 1; + xtitle = "Seconds (TAI)"; + } else { + if_TAI_time_format = 0; + xtitle = "Seconds (TAI) labelled with corresponding UTC"; + } + } else if(kind==3 || kind==4) { + plctime(1963, 10, 1, 0, 0, 2.6972788-0.20, &xmin); + plctime(1963, 10, 1, 0, 0, 2.6972788+0.20, &xmax); + npts = 1001; + ymin = 2.55; + ymax = 2.75; + time_format = "%S%2%"; + title_suffix = "near 1963-11-01 (TAI)"; + xlabel_step = 0.05/(scale*86400.); + if (kind == 3) { + if_TAI_time_format = 1; + xtitle = "Seconds (TAI)"; + } else { + if_TAI_time_format = 0; + xtitle = "Seconds (TAI) labelled with corresponding UTC"; + } + } else if(kind==5 || kind==6) { + plctime(2009, 0, 1, 0, 0, 34.0-5.0, &xmin); + plctime(2009, 0, 1, 0, 0, 34.0+5.0, &xmax); + npts = 1001; + ymin = 32.5; + ymax = 34.5; + time_format = "%S%2%"; + title_suffix = "near 2009-01-01 (TAI)"; + xlabel_step = 1./(scale*86400.); + if(kind == 5) { + if_TAI_time_format = 1; + xtitle = "Seconds (TAI)"; + } else { + if_TAI_time_format = 0; + xtitle = "Seconds (TAI) labelled with corresponding UTC"; + } + } + + PLINT tai_year, tai_month, tai_day, tai_hour, tai_min; + PLFLT tai_sec, tai; + PLINT utc_year, utc_month, utc_day, utc_hour, utc_min; + PLFLT utc_sec, utc; + + PLFLT[] x, y; + x.length = y.length = npts; + for(int i=0; i<npts; i++) { + x[i] = xmin + i*(xmax-xmin)/(npts-1); + plconfigtime(scale, offset1, offset2, 0x0, 0, 0, 0, 0, 0, 0, 0.); + tai = x[i]; + plbtime(&tai_year, &tai_month, &tai_day, &tai_hour, &tai_min, &tai_sec, tai); + plconfigtime(scale, offset1, offset2, 0x2, 0, 0, 0, 0, 0, 0, 0.); + plbtime(&utc_year, &utc_month, &utc_day, &utc_hour, &utc_min, &utc_sec, tai); + plconfigtime(scale, offset1, offset2, 0x0, 0, 0, 0, 0, 0, 0, 0.); + plctime(utc_year, utc_month, utc_day, utc_hour, utc_min, utc_sec, &utc); + y[i]=(tai-utc)*scale*86400.; + } + + pladv(0); + plvsta(); + plwind(xmin, xmax, ymin, ymax); + plcol0(1); + if(if_TAI_time_format) + plconfigtime(scale, offset1, offset2, 0x0, 0, 0, 0, 0, 0, 0, 0.); + else + plconfigtime(scale, offset1, offset2, 0x2, 0, 0, 0, 0, 0, 0, 0.); + pltimefmt(time_format); + plbox("bcnstd", xlabel_step, 0, "bcnstv", 0., 0); + plcol0(3); + string title = "@frPLplot Example 29 - TAI-UTC "; + title ~= title_suffix; + pllab(xtitle, "TAI-UTC (sec)", title); + + plcol0(4); + + plline(x, y); + } + } + } Modified: trunk/plplot_test/test_d.sh.in =================================================================== --- trunk/plplot_test/test_d.sh.in 2009-08-18 08:33:44 UTC (rev 10276) +++ trunk/plplot_test/test_d.sh.in 2009-08-18 08:35:33 UTC (rev 10277) @@ -31,7 +31,7 @@ # 20-22, 28, and 31 not implemented yet. # example 14 excluded until plgdev fixed since the bad driver information # causes run-time errors. -for index in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29 30 31; do +for index in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31; do if [ "$verbose_test" ] ; then echo "x${index}${lang}" fi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2009-08-18 09:52:42
|
Revision: 10279 http://plplot.svn.sourceforge.net/plplot/?rev=10279&view=rev Author: andrewross Date: 2009-08-18 09:52:30 +0000 (Tue, 18 Aug 2009) Log Message: ----------- Update f95 bindings and examples to include plarc, plbtime, plctime and plconfigtime. Modified Paths: -------------- trunk/bindings/f95/plstubs.h trunk/bindings/f95/scstubs.c trunk/examples/f95/x03f.f90 trunk/examples/f95/x29f.f90 Modified: trunk/bindings/f95/plstubs.h =================================================================== --- trunk/bindings/f95/plstubs.h 2009-08-18 09:07:19 UTC (rev 10278) +++ trunk/bindings/f95/plstubs.h 2009-08-18 09:52:30 UTC (rev 10279) @@ -167,11 +167,13 @@ #define PL_SETCONTLABELPARAMa FNAME(PL_SETCONTLABELPARAM_,pl_setcontlabelparam_) #define PLABORT7 FNAME(PLABORT7,plabort7) #define PLADV FNAME(PLADV,pladv) +#define PLARC FNAME(PLARC,plarc) #define PLAXES7 FNAME(PLAXES7,plaxes7) #define PLBIN FNAME(PLBINF77,plbinf77) #define PLBOP FNAME(PLBOP,plbop) #define PLBOX37 FNAME(PLBOX37,plbox37) #define PLBOX7 FNAME(PLBOX7,plbox7) +#define PLBTIME FNAME(PLBTIME,plbtime) #define PLCALC_WORLD FNAME(PLCALC_WORLD,plcalc_world) #define PLCALC_WORLDa FNAME(PLCALC_WORLD_,plcalc_world_) #define PLCLEAR FNAME(PLCLEAR,plclear) @@ -179,11 +181,13 @@ #define PLCOL FNAME(PLCOL,plcol) #define PLCOL0 FNAME(PLCOL0,plcol0) #define PLCOL1 FNAME(PLCOL1,plcol1) +#define PLCONFIGTIME FNAME(PLCONFIGTIME,plconfigtime) #define PLCON07 FNAME(PLCON07,plcon07) #define PLCON17 FNAME(PLCON17,plcon17) #define PLCON27 FNAME(PLCON27,plcon27) #define PLCONT7 FNAME(PLCONT7,plcont7) #define PLCPSTRM FNAME(PLCPSTRMF77,plcpstrmf77) +#define PLCTIME FNAME(PLCTIME,plctime) #define PLEND FNAME(PLEND,plend) #define PLEND1 FNAME(PLEND1,plend1) #define PLENV FNAME(PLENV,plenv) Modified: trunk/bindings/f95/scstubs.c =================================================================== --- trunk/bindings/f95/scstubs.c 2009-08-18 09:07:19 UTC (rev 10278) +++ trunk/bindings/f95/scstubs.c 2009-08-18 09:52:30 UTC (rev 10279) @@ -74,6 +74,12 @@ } void +PLARC(PLFLT *x, PLFLT *y, PLFLT *a, PLFLT *b, PLFLT *angle1, PLFLT *angle2, PLBOOL *fill) +{ + c_plarc(*x, *y, *a, *b, *angle1, *angle2, *fill); +} + +void PLAXES7(PLFLT *x0, PLFLT *y0, const char *xopt, PLFLT *xtick, PLINT *nxsub, const char *yopt, PLFLT *ytick, PLINT *nysub) { @@ -87,6 +93,12 @@ } void +PLBTIME(PLINT *year, PLINT *month, PLINT *day, PLINT *hour, PLINT *min, PLFLT *sec, PLFLT *ctime) +{ + c_plbtime(year, month, day, hour, min, sec, *ctime); +} + +void PLBOP(void) { c_plbop(); @@ -148,12 +160,24 @@ } 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) +{ + c_plconfigtime(*scale, *offset1, *offset2, *ccontrol, *ifbtime_offset, *year, *month, *day, *hour, *min, *sec); +} + +void PLCPSTRM(PLINT *iplsr, PLBOOL *flags) { c_plcpstrm(*iplsr, *flags); } void +PLCTIME(PLINT *year, PLINT *month, PLINT *day, PLINT *hour, PLINT *min, PLFLT *sec, PLFLT *ctime) +{ + c_plctime(*year, *month, *day, *hour, *min, *sec, ctime); +} + +void PLEND(void) { c_plend(); @@ -270,7 +294,7 @@ } void -PLGDEV7(char *dev, int length ) +PLGDEV7(char *dev, int length) { c_plgdev(dev); } Modified: trunk/examples/f95/x03f.f90 =================================================================== --- trunk/examples/f95/x03f.f90 2009-08-18 09:07:19 UTC (rev 10278) +++ trunk/examples/f95/x03f.f90 2009-08-18 09:52:30 UTC (rev 10279) @@ -46,14 +46,10 @@ ! Set up viewport and window, but do not draw box call plenv(-1.3_plflt, 1.3_plflt, -1.3_plflt, 1.3_plflt, 1, -2) +! Draw circles for polar grid do i = 1,10 - do j = 0,360 - x(j) = 0.1_plflt*i*x0(j) - y(j) = 0.1_plflt*i*y0(j) - enddo -! Draw circles for polar grid - - call plline(x,y) + call plarc(0.0_plflt, 0.0_plflt, 0.1_plflt*i, 0.1_plflt*i, & + 0.0_plflt, 360.0_plflt, 0) enddo call plcol0(2) do i = 0,11 Modified: trunk/examples/f95/x29f.f90 =================================================================== --- trunk/examples/f95/x29f.f90 2009-08-18 09:07:19 UTC (rev 10278) +++ trunk/examples/f95/x29f.f90 2009-08-18 09:52:30 UTC (rev 10279) @@ -39,6 +39,7 @@ call plot1() call plot2() call plot3() + call plot4() call plend() end program x29f95 @@ -225,3 +226,144 @@ call plline(x(1:npts), y(1:npts)) end subroutine plot3 + +! +! +! + subroutine plot4() + use plplot, PI => PL_PI + implicit none + +! TAI-UTC (seconds) as a function of time. +! Use Besselian epochs as the continuous time interval just to prove +! this does not introduce any issues. + + real(kind=plflt) :: scale, offset1, offset2 + real(kind=plflt) :: xmin, xmax, ymin, ymax, xlabel_step + integer :: k, npts, i + logical :: if_TAI_time_format + character(len=10) :: time_format + character(len=100) :: title_suffix + character(len=100) :: xtitle + character(len=100) :: title + real(kind=plflt) :: x(1001), y(1001) + integer :: tai_year, tai_month, tai_day, tai_hour, tai_min; + real(kind=plflt) :: tai_sec, tai; + integer :: utc_year, utc_month, utc_day, utc_hour, utc_min; + real(kind=plflt) :: utc_sec, utc; + +! Use the definition given in http://en.wikipedia.org/wiki/Besselian_epoch +! B = 1900. + (JD -2415020.31352)/365.242198781 +! ==> (as calculated with aid of "bc -l" command) +! B = (MJD + 678940.364163900)/365.242198781 +! ==> +! MJD = B*365.24219878 - 678940.364163900 + scale = 365.242198781_plflt + offset1 = -678940.0_plflt + offset2 = -0.3641639_plflt + call plconfigtime(scale, offset1, offset2, z'0', 0, 0, 0, 0, 0, & + 0, 0._plflt) + + do k = 0,6 + if (k .eq. 0) then + call plctime(1950,0,2,0,0,0.,xmin) + call plctime(2020,0,2,0,0,0.,xmax) + npts = 70*12 + 1 + ymin = 0.0_plflt + ymax = 36.0_plflt + time_format="%Y%" + if_TAI_time_format = .true. + title_suffix = "from 1950 to 2020" + xtitle = "Year" + xlabel_step = 10.0_plflt + elseif ((k .eq. 1) .or. (k .eq. 2)) then + call plctime(1961,7,1,0,0,1.64757_plflt-.20_plflt, xmin) + call plctime(1961,7,1,0,0,1.64757_plflt+.20_plflt, xmax) + npts = 1001 + ymin = 1.625_plflt + ymax = 1.725_plflt + time_format = "%S%2%" + title_suffix = "near 1961-08-01 (TAI)" + xlabel_step = 0.05_plflt/(scale*86400.0_plflt) + if (k .eq. 1) then + if_TAI_time_format = .true. + xtitle = "Seconds (TAI)" + else + if_TAI_time_format = .false. + xtitle = "Seconds (TAI) labelled with corresponding UTC" + endif + elseif ((k .eq. 3) .or. (k .eq. 4)) then + call plctime(1963,10,1,0,0,2.6972788_plflt-.20_plflt, xmin) + call plctime(1963,10,1,0,0,2.6972788_plflt+.20_plflt, xmax) + npts = 1001 + ymin = 2.55_plflt + ymax = 2.75_plflt + time_format = "%S%2%" + title_suffix = "near 1963-11-01 (TAI)" + xlabel_step = 0.05_plflt/(scale*86400.0_plflt) + if (k .eq. 3) then + if_TAI_time_format = .true. + xtitle = "Seconds (TAI)" + else + if_TAI_time_format = .false. + xtitle = "Seconds (TAI) labelled with corresponding UTC" + endif + elseif ((k .eq. 5) .or. (k .eq. 6)) then + call plctime(2009,0,1,0,0,34._plflt-5._plflt,xmin) + call plctime(2009,0,1,0,0,34._plflt+5._plflt,xmax) + npts = 1001 + ymin = 32.5_plflt + ymax = 34.5_plflt + time_format = "%S%2%" + title_suffix = "near 2009-01-01 (TAI)" + xlabel_step = 1._plflt/(scale*86400._plflt) + if (k .eq. 5) then + if_TAI_time_format = .true. + xtitle = "Seconds (TAI)" + else + if_TAI_time_format = .false. + xtitle = "Seconds (TAI) labelled with corresponding UTC" + endif + endif + + do i=0,npts-1 + x(i+1) = xmin + i*(xmax-xmin)/(dble(npts-1)) + call plconfigtime(scale, offset1, offset2, z'0', 0, 0, 0, 0, & + 0, 0, 0._plflt) + tai = x(i+1); + call plbtime(tai_year, tai_month, tai_day, tai_hour, & + tai_min, tai_sec, tai) + call plconfigtime(scale, offset1, offset2, z'2', 0, 0, 0, & + 0, 0, 0, 0._plflt) + call plbtime(utc_year, utc_month, utc_day, utc_hour, & + utc_min, utc_sec, tai) + call plconfigtime(scale, offset1, offset2, z'0', 0, 0, 0, & + 0, 0, 0, 0._plflt) + call plctime(utc_year, utc_month, utc_day, utc_hour, & + utc_min, utc_sec, utc) + y(i+1)=(tai-utc)*scale*86400._plflt + enddo + + call pladv(0) + call plvsta() + call plwind(xmin, xmax, ymin, ymax) + call plcol0(1) + if (if_TAI_time_format) then + call plconfigtime(scale, offset1, offset2, z'0', 0, 0, 0, & + 0, 0, 0, 0._plflt) + else + call plconfigtime(scale, offset1, offset2, z'2', 0, 0, 0, & + 0, 0, 0, 0._plflt) + endif + call pltimefmt(time_format) + call plbox("bcnstd", xlabel_step, 0, "bcnstv", 0._plflt, 0) + call plcol0(3) + title = "@frPLplot Example 29 - TAI-UTC "// & + trim(title_suffix) + call pllab(xtitle, "TAI-UTC (sec)", title) + + call plcol0(4) + + call plline(x(1:npts), y(1:npts)) + enddo + end subroutine plot4 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2009-08-18 09:53:11
|
Revision: 10280 http://plplot.svn.sourceforge.net/plplot/?rev=10280&view=rev Author: andrewross Date: 2009-08-18 09:53:03 +0000 (Tue, 18 Aug 2009) Log Message: ----------- Small tidy-ups for f77 bindings and examples. Modified Paths: -------------- trunk/bindings/f77/scstubs.c trunk/examples/f77/x29f.fm4 Modified: trunk/bindings/f77/scstubs.c =================================================================== --- trunk/bindings/f77/scstubs.c 2009-08-18 09:52:30 UTC (rev 10279) +++ trunk/bindings/f77/scstubs.c 2009-08-18 09:53:03 UTC (rev 10280) @@ -62,7 +62,7 @@ } void -PLABORT7(char *text) +PLABORT7(const char *text) { plabort(text); } Modified: trunk/examples/f77/x29f.fm4 =================================================================== --- trunk/examples/f77/x29f.fm4 2009-08-18 09:52:30 UTC (rev 10279) +++ trunk/examples/f77/x29f.fm4 2009-08-18 09:53:03 UTC (rev 10280) @@ -270,7 +270,7 @@ offset1 = -678940.0d0 offset2 = -0.3641639d0 call plconfigtime(scale, offset1, offset2, z'0', 0, 0, 0, 0, 0, - 1 0, 0.) + 1 0, 0.d0) do kind = 0,6 if (kind .eq. 0) then @@ -358,10 +358,10 @@ call plcol0(1) if (if_TAI_time_format) then call plconfigtime(scale, offset1, offset2, z'0', 0, 0, 0, - 1 0, 0, 0, 0.) + 1 0, 0, 0, 0.d0) else call plconfigtime(scale, offset1, offset2, z'2', 0, 0, 0, - 1 0, 0, 0, 0.) + 1 0, 0, 0, 0.d0) endif call pltimefmt(time_format) call plbox("bcnstd", xlabel_step, 0, "bcnstv", 0.d0, 0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2009-08-18 13:52:28
|
Revision: 10281 http://plplot.svn.sourceforge.net/plplot/?rev=10281&view=rev Author: andrewross Date: 2009-08-18 13:52:20 +0000 (Tue, 18 Aug 2009) Log Message: ----------- Implement plsfunclabel for f77 / f95 and update example 19 accordingly. Modified Paths: -------------- trunk/bindings/f77/plstubs.h trunk/bindings/f77/scstubs.c trunk/bindings/f95/plstubs.h trunk/bindings/f95/scstubs.c trunk/examples/f77/x19f.fm4 trunk/examples/f95/x19f.f90 Modified: trunk/bindings/f77/plstubs.h =================================================================== --- trunk/bindings/f77/plstubs.h 2009-08-18 09:53:03 UTC (rev 10280) +++ trunk/bindings/f77/plstubs.h 2009-08-18 13:52:20 UTC (rev 10281) @@ -303,6 +303,7 @@ #define PLSHADES17 FNAME(PLSHADES17,plshades17) #define PLSHADES27 FNAME(PLSHADES27,plshades27) #define PLSHADES7 FNAME(PLSHADES7,plshades7) +#define PLSLABELFUNC FNAME(PLSLABELFUNC,plslabelfunc) #define PLSMAJ FNAME(PLSMAJ,plsmaj) #define PLSMEM FNAME(PLSMEM,plsmem) #define PLSMIN FNAME(PLSMIN,plsmin) Modified: trunk/bindings/f77/scstubs.c =================================================================== --- trunk/bindings/f77/scstubs.c 2009-08-18 09:53:03 UTC (rev 10280) +++ trunk/bindings/f77/scstubs.c 2009-08-18 13:52:20 UTC (rev 10281) @@ -36,6 +36,9 @@ #endif static void (STDCALL *plmapform)(PLINT *, PLFLT *, PLFLT *) ; /* Note: slightly different prototype than (*mapform)! */ +/* Slightly different to (*label_func) as we don't support PLPointer for + * additional data in f77. */ +static void (STDCALL *pllabelfunc)(PLINT *, PLFLT *, char *, PLINT *); void PL_SETCONTLABELFORMAT(PLINT *lexp, PLINT *sigdig) @@ -471,6 +474,21 @@ c_pllab(xlab, ylab, title); } +static void +pllabelfuncf2c( PLINT axis, PLFLT value, char *label, PLINT length, PLPointer data) +{ + int i; + + (*pllabelfunc)( &axis, &value, label, &length ); + + /* Ensure string is null terminated */ + i = length-1; + while ((i >= 0) && (label[i]== ' ')) + i--; + label[i+1] = '\0'; + +} + void PLLIGHTSOURCE(PLFLT *x, PLFLT *y, PLFLT *z) { @@ -819,6 +837,14 @@ } void +PLSLABELFUNC( void (STDCALL *labelfunc)(PLINT *, PLFLT *, char *, PLINT *)) +{ + pllabelfunc = labelfunc; + /* N.B. neglect pointer to additional data for f77 */ + c_plslabelfunc(pllabelfuncf2c, NULL); +} + +void PLSMAJ(PLFLT *def, PLFLT *scale) { c_plsmaj(*def, *scale); Modified: trunk/bindings/f95/plstubs.h =================================================================== --- trunk/bindings/f95/plstubs.h 2009-08-18 09:53:03 UTC (rev 10280) +++ trunk/bindings/f95/plstubs.h 2009-08-18 13:52:20 UTC (rev 10281) @@ -313,6 +313,7 @@ #define PLSHADES17 FNAME(PLSHADES17,plshades17) #define PLSHADES27 FNAME(PLSHADES27,plshades27) #define PLSHADES7 FNAME(PLSHADES7,plshades7) +#define PLSLABELFUNC FNAME(PLSLABELFUNC,plslabelfunc) #define PLSMAJ FNAME(PLSMAJ,plsmaj) #define PLSMEM FNAME(PLSMEM,plsmem) #define PLSMIN FNAME(PLSMIN,plsmin) Modified: trunk/bindings/f95/scstubs.c =================================================================== --- trunk/bindings/f95/scstubs.c 2009-08-18 09:53:03 UTC (rev 10280) +++ trunk/bindings/f95/scstubs.c 2009-08-18 13:52:20 UTC (rev 10281) @@ -36,6 +36,9 @@ #endif static void (STDCALL *plmapform)(PLINT *, PLFLT *, PLFLT *) ; /* Note: slightly different prototype than (*mapform)! */ +/* Slightly different to (*label_func) as we don't support PLPointer for + * additional data in f77. */ +static void (STDCALL *pllabelfunc)(PLINT *, PLFLT *, char *, PLINT *); void PL_SETCONTLABELFORMAT(PLINT *lexp, PLINT *sigdig) @@ -516,6 +519,21 @@ c_pllab(xlab, ylab, title); } +static void +pllabelfuncf2c( PLINT axis, PLFLT value, char *label, PLINT length, PLPointer data) +{ + int i; + + (*pllabelfunc)( &axis, &value, label, &length ); + + /* Ensure string is null terminated */ + i = length-1; + while ((i >= 0) && (label[i]== ' ')) + i--; + label[i+1] = '\0'; + +} + void PLLIGHTSOURCE(PLFLT *x, PLFLT *y, PLFLT *z) { @@ -878,6 +896,14 @@ } void +PLSLABELFUNC( void (STDCALL *labelfunc)(PLINT *, PLFLT *, char *, PLINT *)) +{ + pllabelfunc = labelfunc; + /* N.B. neglect pointer to additional data for f77 */ + c_plslabelfunc(pllabelfuncf2c, NULL); +} + +void PLSMAJ(PLFLT *def, PLFLT *scale) { c_plsmaj(*def, *scale); Modified: trunk/examples/f77/x19f.fm4 =================================================================== --- trunk/examples/f77/x19f.fm4 2009-08-18 09:53:03 UTC (rev 10280) +++ trunk/examples/f77/x19f.fm4 2009-08-18 13:52:20 UTC (rev 10281) @@ -67,6 +67,65 @@ return end +c "Normalize" longitude values so that they always fall between +c -180.0 and 180.0 + function normalize_longitude(lon) + implicit none + real*8 normalize_longitude + real*8 lon, times + + if ((lon .ge. -180.0d0) .and. (lon .le. 180.0d0)) then + normalize_longitude = lon + else + times = floor ((abs(lon) + 180.0d0) / 360.0d0) + if (lon .lt. 0.0d0) then + normalize_longitude = lon + 360.0d0 * times + else + normalize_longitude = lon - 360.0d0 * times + endif + endif + return + end function + +c A custom axis labeling function for longitudes and latitudes. + subroutine geolocation_labeler(axis, value, label, length) + implicit none + integer axis, length + real*8 value + character*(length) label + character*5 direction_label + real*8 label_val + real*8 normalize_longitude + + if (axis .eq. 2) then + label_val = value + if (label_val .gt. 0.0d0) then + direction_label = ' N' + else if (label_val .lt. 0.0d0) then + direction_label = ' S' + else + direction_label = 'Eq' + endif + else if (axis .eq. 1) then + label_val = normalize_longitude(value) + if (label_val .gt. 0.0d0) then + direction_label = ' E' + else if (label_val .lt. 0.0d0) then + direction_label = ' W' + else + direction_label = '' + endif + endif + if (axis .eq. 2 .and. value .eq. 0.0d0) then +c A special case for the equator + label = direction_label + else if (abs(label_val) .lt. 100.0d0) then + write(label,'(I2.1,A2)') iabs(int(label_val)),direction_label + else + write(label,'(I3.1,A2)') iabs(int(label_val)),direction_label + endif + end + c-------------------------------------------------------------------------- c main c @@ -78,6 +137,7 @@ real*8 minx, maxx, miny, maxy external ident external mapform19 + external geolocation_labeler integer PL_PARSE_FULL parameter(PL_PARSE_FULL = 1) @@ -97,8 +157,11 @@ minx = 190 maxx = 190+360 +c Setup a custom latitude and longitude-based scaling function. + call plslabelfunc(geolocation_labeler) + call plcol0(1) - call plenv(minx, maxx, miny, maxy, 1, -1) + call plenv(minx, maxx, miny, maxy, 1, 70) call plmap(ident, 'usaglobe', minx, maxx, miny, maxy) c The Americas @@ -107,9 +170,12 @@ maxx = 340 call plcol0(1) - call plenv(minx, maxx, miny, maxy, 1, -1) + call plenv(minx, maxx, miny, maxy, 1, 70) call plmap(ident, 'usaglobe', minx, maxx, miny, maxy) +c Clear the labeling function + call plslabelfunc(0) + c Polar, Northern hemisphere minx = 0 Modified: trunk/examples/f95/x19f.f90 =================================================================== --- trunk/examples/f95/x19f.f90 2009-08-18 09:53:03 UTC (rev 10280) +++ trunk/examples/f95/x19f.f90 2009-08-18 13:52:20 UTC (rev 10281) @@ -65,8 +65,71 @@ y(i) = yp enddo return - end + end subroutine +! "Normalize" longitude values so that they always fall between +! -180.0 and 180.0 + function normalize_longitude(lon) + use plplot + implicit none + real(kind=plflt) :: normalize_longitude + real(kind=plflt) :: lon, times + + if ((lon .ge. -180.0d0) .and. (lon .le. 180.0d0)) then + normalize_longitude = lon + else + times = floor ((abs(lon) + 180.0d0) / 360.0d0) + if (lon .lt. 0.0d0) then + normalize_longitude = lon + 360.0d0 * times + else + normalize_longitude = lon - 360.0d0 * times + endif + endif + return + end function + +! +! A custom axis labeling function for longitudes and latitudes. +! + subroutine geolocation_labeler(axis, value, label, length) + use plplot + implicit none + integer :: axis, length + real(kind=plflt) :: value + character*(length) label + character*5 direction_label + real(kind=plflt) :: label_val + real(kind=plflt) :: normalize_longitude + + if (axis .eq. 2) then + label_val = value + if (label_val .gt. 0.0d0) then + direction_label = ' N' + else if (label_val .lt. 0.0d0) then + direction_label = ' S' + else + direction_label = 'Eq' + endif + else if (axis .eq. 1) then + label_val = normalize_longitude(value) + if (label_val .gt. 0.0d0) then + direction_label = ' E' + else if (label_val .lt. 0.0d0) then + direction_label = ' W' + else + direction_label = '' + endif + endif + if (axis .eq. 2 .and. value .eq. 0.0d0) then +! A special case for the equator + label = direction_label + else if (abs(label_val) .lt. 100.0d0) then + write(label,'(I2.1,A2)') iabs(int(label_val)),direction_label + else + write(label,'(I3.1,A2)') iabs(int(label_val)),direction_label + endif + end subroutine + !-------------------------------------------------------------------------- ! main ! @@ -80,6 +143,7 @@ integer c external ident external mapform19 + external geolocation_labeler ! Process command-line arguments call plparseopts(PL_PARSE_FULL) @@ -97,8 +161,11 @@ minx = 190 maxx = 190+360 +! Setup a custom latitude and longitude-based scaling function. + call plslabelfunc(geolocation_labeler) + call plcol0(1) - call plenv(minx, maxx, miny, maxy, 1, -1) + call plenv(minx, maxx, miny, maxy, 1, 70) call plmap(ident, 'usaglobe', minx, maxx, miny, maxy) ! The Americas @@ -107,9 +174,12 @@ maxx = 340 call plcol0(1) - call plenv(minx, maxx, miny, maxy, 1, -1) + call plenv(minx, maxx, miny, maxy, 1, 70) call plmap(ident, 'usaglobe', minx, maxx, miny, maxy) +! Clear the labeling function + call plslabelfunc(0) + ! Polar, Northern hemisphere minx = 0 @@ -124,4 +194,4 @@ 0.0_plflt, 360.0_plflt, -10.0_plflt, & 80.0_plflt) call plend() - end + end program x19f This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2009-08-18 15:59:30
|
Revision: 10282 http://plplot.svn.sourceforge.net/plplot/?rev=10282&view=rev Author: airwin Date: 2009-08-18 15:59:21 +0000 (Tue, 18 Aug 2009) Log Message: ----------- Retire tek devices. Modified Paths: -------------- trunk/README.release trunk/cmake/modules/drivers-init.cmake Modified: trunk/README.release =================================================================== --- trunk/README.release 2009-08-18 13:52:20 UTC (rev 10281) +++ trunk/README.release 2009-08-18 15:59:21 UTC (rev 10282) @@ -101,12 +101,14 @@ XII. As of release 5.9.5 we have retired the hpgl driver (containing the hp7470, hp7580, and lj_hpgl devices), the impress driver (containing the imp -device), and the ljii driver (containing the ljii and ljiip devices). -Retirement means we have removed the build options which would allow these -devices to build and install. Recent tests have shown a number of run-time -issues with these devices, and as far as we know there is no more user -interest in them. Therefore, we have decided to retire these devices rather -than fix them. +device), the ljii driver (containing the ljii and ljiip devices), and the +tek driver (containing the conex, mskermit, tek4107, tek4107f, tek4010, +tek4010f, versaterm, vlt, and xterm devices). Retirement means we have +removed the build options which would allow these devices to build and +install. Recent tests have shown a number of run-time issues (hpgl, +impress, and ljii) or build-time issues (tek) with these devices, and as far +as we know there is no more user interest in them. Therefore, we have +decided to retire these devices rather than fix them. INDEX Modified: trunk/cmake/modules/drivers-init.cmake =================================================================== --- trunk/cmake/modules/drivers-init.cmake 2009-08-18 13:52:20 UTC (rev 10281) +++ trunk/cmake/modules/drivers-init.cmake 2009-08-18 15:59:21 UTC (rev 10282) @@ -178,15 +178,18 @@ "pstex:pstex:OFF" "psttf:psttf:ON" "svg:svg:ON" - "conex:tek:OFF" - "mskermit:tek:OFF" - "tek4010:tek:OFF" - "tek4010f:tek:OFF" - "tek4107:tek:OFF" - "tek4107f:tek:OFF" - "versaterm:tek:OFF" - "vlt:tek:OFF" - "xterm:tek:OFF" + # Build issues (inconsistent use of PLD names). We believe there is no + # user interest in the tek devices any more so retire them rather than + # fix them. + #"conex:tek:OFF" + #"mskermit:tek:OFF" + #"tek4010:tek:OFF" + #"tek4010f:tek:OFF" + #"tek4107:tek:OFF" + #"tek4107f:tek:OFF" + #"versaterm:tek:OFF" + #"vlt:tek:OFF" + #"xterm:tek:OFF" "tk:tk:ON" "tkwin:tkwin:ON" "wingcc:wingcc:ON" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hez...@us...> - 2009-08-18 16:21:57
|
Revision: 10284 http://plplot.svn.sourceforge.net/plplot/?rev=10284&view=rev Author: hezekiahcarty Date: 2009-08-18 16:21:50 +0000 (Tue, 18 Aug 2009) Log Message: ----------- Add plspal0 and plspal1 to the OCaml bindings and update x16.ml to use them Modified Paths: -------------- trunk/bindings/ocaml/plplot_h trunk/bindings/ocaml/plplot_h.inc trunk/examples/ocaml/x16.ml Modified: trunk/bindings/ocaml/plplot_h =================================================================== --- trunk/bindings/ocaml/plplot_h 2009-08-18 16:19:11 UTC (rev 10283) +++ trunk/bindings/ocaml/plplot_h 2009-08-18 16:21:50 UTC (rev 10284) @@ -476,6 +476,12 @@ PLINT xoff, PLINT yoff); void +c_plspal0(const char *filename); + + void +c_plspal1(const char *filename); + + void c_plspause(PLBOOL pause); void Modified: trunk/bindings/ocaml/plplot_h.inc =================================================================== --- trunk/bindings/ocaml/plplot_h.inc 2009-08-18 16:19:11 UTC (rev 10283) +++ trunk/bindings/ocaml/plplot_h.inc 2009-08-18 16:21:50 UTC (rev 10284) @@ -107,6 +107,8 @@ [mlname(plsmin)] void c_plsmin ( double def, double scale ); [mlname(plsori)] void c_plsori ( int ori ); [mlname(plspage)] void c_plspage ( double xp, double yp, int xleng, int yleng, int xoff, int yoff ); +[mlname(plspal0)] void c_plspal0 ( [string] const char * filename ); +[mlname(plspal1)] void c_plspal1 ( [string] const char * filename ); [mlname(plspause)] void c_plspause ( boolean pause ); [mlname(plsstrm)] void c_plsstrm ( int strm ); [mlname(plssub)] void c_plssub ( int nx, int ny ); Modified: trunk/examples/ocaml/x16.ml =================================================================== --- trunk/examples/ocaml/x16.ml 2009-08-18 16:19:11 UTC (rev 10283) +++ trunk/examples/ocaml/x16.ml 2009-08-18 16:21:50 UTC (rev 10284) @@ -58,6 +58,10 @@ (* Parse and process command line arguments *) ignore (plparseopts Sys.argv [PL_PARSE_FULL]); + (* Load color palettes *) + plspal0 "cmap0_black_on_white.pal"; + plspal1 "cmap1_gray.pal"; + (* Reduce colors in cmap 0 so that cmap 1 is useful on a 16-color display *) plscmap0n 3; @@ -135,6 +139,11 @@ pllab "distance" "altitude" "Bogon density"; (* Plot using 1d coordinate transform *) + + (* Load color palettes *) + plspal0 "cmap0_black_on_white.pal"; + plspal1 "cmap1_blue_yellow.pal"; + pladv 0; plvpor 0.1 0.9 0.1 0.9; plwind (-1.0) 1.0 (-1.0) 1.0; @@ -150,6 +159,11 @@ pllab "distance" "altitude" "Bogon density"; (* Plot using 2d coordinate transform *) + + (* Load color palettes *) + plspal0 "cmap0_black_on_white.pal"; + plspal1 "cmap1_blue_red.pal"; + pladv 0; plvpor 0.1 0.9 0.1 0.9; plwind (-1.0) 1.0 (-1.0) 1.0; @@ -167,6 +181,11 @@ pllab "distance" "altitude" "Bogon density, with streamlines"; (* Plot using 2d coordinate transform *) + + (* Load color palettes *) + plspal0 ""; + plspal1 ""; + pladv 0; plvpor 0.1 0.9 0.1 0.9; plwind (-1.0) 1.0 (-1.0) 1.0; @@ -201,6 +220,11 @@ pllab "distance" "altitude" "Bogon density with exclusion"; ); (* Example with polar coordinates. *) + + (* Load colour palettes*) + plspal0 "cmap0_black_on_white.pal"; + plspal1 "cmap1_gray.pal"; + pladv 0; plvpor 0.1 0.9 0.1 0.9; plwind (-1.0) 1.0 (-1.0) 1.0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hez...@us...> - 2009-08-18 16:26:29
|
Revision: 10285 http://plplot.svn.sourceforge.net/plplot/?rev=10285&view=rev Author: hezekiahcarty Date: 2009-08-18 16:26:04 +0000 (Tue, 18 Aug 2009) Log Message: ----------- Add plslabelfunc to the OCaml bindings and update x19.ml to use it Modified Paths: -------------- trunk/bindings/ocaml/plplot.idl trunk/bindings/ocaml/plplot_impl.c trunk/examples/ocaml/x19.ml Modified: trunk/bindings/ocaml/plplot.idl =================================================================== --- trunk/bindings/ocaml/plplot.idl 2009-08-18 16:21:50 UTC (rev 10284) +++ trunk/bindings/ocaml/plplot.idl 2009-08-18 16:26:04 UTC (rev 10285) @@ -178,6 +178,25 @@ PL_PARSE_NODASH | \ PL_PARSE_SKIP"); +// Data type to reference axes +quote(mlmli, "type plplot_axis_type = \ + PL_X_AXIS | \ + PL_Y_AXIS | \ + PL_Z_AXIS"); + +// Custom axis labeling +quote(ml, "external ml_plslabelfunc : unit -> unit = \"ml_plslabelfunc\""); +quote(ml, +"let plslabelfunc (f : plplot_axis_type -> float -> string) =\ + Callback.register \"caml_plplot_customlabel\" f;\ + ml_plslabelfunc ()"); +quote(mli, "val plslabelfunc : (plplot_axis_type -> float -> string) -> unit"); +quote(ml, +"let plunset_labelfunc () =\ + Callback.register \"caml_plplot_customlabel\" 0;\ + ml_plslabelfunc ()"); +quote(mli, "val plunset_labelfunc : unit -> unit"); + RAW_ML(external plgriddata : float array -> float array -> float array -> float array -> float array -> plplot_grid_method_type -> float -> float array array = "ml_plgriddata_bytecode" "ml_plgriddata") RAW_ML(external plparseopts : string array -> plplot_parse_method_type list -> int = "ml_plparseopts") Modified: trunk/bindings/ocaml/plplot_impl.c =================================================================== --- trunk/bindings/ocaml/plplot_impl.c 2009-08-18 16:21:50 UTC (rev 10284) +++ trunk/bindings/ocaml/plplot_impl.c 2009-08-18 16:26:04 UTC (rev 10285) @@ -17,8 +17,6 @@ along with PLplot. If not, see <http://www.gnu.org/licenses/>. */ -#include <plplotP.h> - /* The "usual" OCaml includes */ #include <caml/alloc.h> #include <caml/callback.h> @@ -28,18 +26,23 @@ #include <caml/mlvalues.h> #include <caml/bigarray.h> +#include <plplotP.h> #include <plplot.h> +#undef snprintf + #include <stdio.h> #define MAX_EXCEPTION_MESSAGE_LENGTH 1000 #define CAML_PLPLOT_PLOTTER_FUNC_NAME "caml_plplot_plotter" #define CAML_PLPLOT_MAPFORM_FUNC_NAME "caml_plplot_mapform" #define CAML_PLPLOT_DEFINED_FUNC_NAME "caml_plplot_defined" +#define CAML_PLPLOT_LABEL_FUNC_NAME "caml_plplot_customlabel" typedef void(*ML_PLOTTER_FUNC)(PLFLT, PLFLT, PLFLT*, PLFLT*, PLPointer); typedef PLINT(*ML_DEFINED_FUNC)(PLFLT, PLFLT); typedef void(*ML_MAPFORM_FUNC)(PLINT, PLFLT*, PLFLT*); +typedef void(*ML_LABEL_FUNC)(PLINT, PLFLT, char*, PLINT, PLPointer); /* @@ -130,6 +133,28 @@ CAMLreturn0; } +// A simple routine to wrap a properly registered OCaml callback in a form +// usable by PLPlot routines. +void ml_labelfunc(PLINT axis, PLFLT n, char *label, PLINT length, PLPointer d) { + CAMLparam0(); + CAMLlocal1(result); + + // Get the OCaml callback function (if there is one) + static value * callback = NULL; + if (callback == NULL) + callback = caml_named_value(CAML_PLPLOT_LABEL_FUNC_NAME); + + // No check to see if a callback function has been designated yet, + // because that is checked before we get to this point. + result = + caml_callback2(*callback, Val_int(axis - 1), caml_copy_double(n)); + + // Copy the OCaml callback output to the proper location. + snprintf(label, length, "%s", String_val(result)); + + CAMLreturn0; +} + // Check if the matching OCaml callback is defined. Return NULL if it is not, // and the proper function pointer if it is. ML_PLOTTER_FUNC get_ml_plotter_func() { @@ -175,7 +200,25 @@ } } +// Custom wrapper for plslabelfunc +value ml_plslabelfunc(value unit) { + CAMLparam1(unit); + static value * label = NULL; + if (label == NULL) + label = caml_named_value(CAML_PLPLOT_LABEL_FUNC_NAME); + if (label == NULL || Val_int(0) == *label) { + // No plotter defined + plslabelfunc(NULL, NULL); + } + else { + // Plotter is defined + plslabelfunc(ml_labelfunc, NULL); + } + + CAMLreturn(Val_unit); +} + /* CONTOURING, SHADING and IMAGE FUNCTIONS Modified: trunk/examples/ocaml/x19.ml =================================================================== --- trunk/examples/ocaml/x19.ml 2009-08-18 16:21:50 UTC (rev 10284) +++ trunk/examples/ocaml/x19.ml 2009-08-18 16:26:04 UTC (rev 10285) @@ -23,6 +23,7 @@ *) open Plplot +open Printf (*--------------------------------------------------------------------------*\ * mapform19 @@ -43,6 +44,48 @@ let yp = radius *. sin (x *. pi /. 180.0) in (xp, yp) +(* "Normalize" longitude values so that they always fall between -180.0 and + 180.0 *) +let normalize_longitude lon = + if lon >= -180.0 && lon <= 180.0 then + lon + else + let times = floor ((abs_float lon +. 180.0) /. 360.0) in + if lon < 0.0 then + lon +. 360.0 *. times + else + lon -. 360.0 *. times + +(* A custom axis labeling function for longitudes and latitudes. *) +let geolocation_labeler axis value = + let label_val, direction_label = + match axis with + | PL_Y_AXIS -> + let label_val = value in + label_val, + if label_val > 0.0 then + " N" + else if label_val < 0.0 then + " S" + else + "Eq" + | PL_X_AXIS -> + let label_val = normalize_longitude value in + label_val, + if label_val > 0.0 then + " E" + else if label_val < 0.0 then + " W" + else + "" + | PL_Z_AXIS -> invalid_arg "Invalid axis - only X or Y are supported" + in + if axis = PL_Y_AXIS && label_val = 0.0 then + (* A special case for the equator *) + sprintf "%s" direction_label + else + sprintf "%.0f%s" (abs_float label_val) direction_label + (*--------------------------------------------------------------------------*\ * main * @@ -65,8 +108,11 @@ let minx = 190.0 in let maxx = 190.0 +. 360.0 in + (* Setup a custom latitude and longitude-based scaling function. *) + plslabelfunc geolocation_labeler; + plcol0 1; - plenv minx maxx miny maxy 1 (-1); + plenv minx maxx miny maxy 1 70; (* No transform function is passed to plmap. Since we have not set one yet, it defaults to using an identity function (xp = x, yp = y) *) plmap "usaglobe" minx maxx miny maxy; @@ -76,11 +122,14 @@ let maxx = 340.0 in plcol0 1; - plenv minx maxx miny maxy 1 (-1); + plenv minx maxx miny maxy 1 70; (* Again, we have not set a transform. Everything remains in a Cartesian projection. *) plmap "usaglobe" minx maxx miny maxy; + (* Clear the labeling function *) + plunset_labelfunc (); + (* Polar, Northern hemisphere *) let minx = 0.0 in let maxx = 360.0 in This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |