diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2017-08-08 20:06:26 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2017-08-08 20:06:26 (GMT) |
commit | 4773cc1128f60e83ba5721fe1ad3497b15078361 (patch) | |
tree | 7121fa9242d736c188b66a447ac0f371cf55fe4a | |
parent | 2a767479174cfd2b6b5459a31cc3fcd64152bd61 (diff) | |
download | blt-4773cc1128f60e83ba5721fe1ad3497b15078361.zip blt-4773cc1128f60e83ba5721fe1ad3497b15078361.tar.gz blt-4773cc1128f60e83ba5721fe1ad3497b15078361.tar.bz2 |
Squashed 'tkblt/' changes from e1747e4c..c79bffe0
c79bffe0 comment out MSVB flags, need a better way
f2bb9074 Merge pull request #6 from prs-de/master
95101fc9 Interpret empty strings as NaN
e4521220 Add -tickformat axis option, rename -command option to -tickformatcommand
d2c07875 Stop checking for NULL before free
e8635888 Prevent dangling pointer
796f2e81 Make sure enough arguments are passed before accessing them
dc04360d Update axis' margin when using it
04d02fd5 Use axis' own classid to determine the type
452da1d8 Don't remove pkgIndex.tcl on 'make clean'
314ade3a Import std namespace
6983f2fa Don't remove tkbltConfig.sh on 'make clean'
ac38d758 Correct function name
fbf29e98 Fix MSVC's C2375 "redefinition with different linkage"
f10a85ad Add cmath and printf wrappers for Windows
75db3cd1 Fix polymorphic variant in jump table
f14d9dc7 Enforce explicit downcasting of numeric values
095e27e5 Use double for comparing with GraphOption's aspect
9ffae9ee Upgrade BarGroup's lastY to double
16f221ec Upgrade BarGroup's sum to double
ce7e3c4d Remove superfluous literal suffixes
0383f13a Upgrade getBoundingBox angle to double
2655a6b4 Upgrade vScale_/hScale_ to double
642cb149 Add Windows-specific CFLAGS
1a9e6fba Place axes within their area when using multiple axis in a single margin
71312d1e Better align with TEA's expected file layout
ce90eafc fix win64 issue
git-subtree-dir: tkblt
git-subtree-split: c79bffe0a0e6c587473708c778b2744c37d8abba
-rwxr-xr-x | configure | 116 | ||||
-rw-r--r-- | configure.ac | 113 | ||||
-rw-r--r-- | doc/graph.html | 42 | ||||
-rw-r--r-- | doc/graph.n | 38 | ||||
-rw-r--r-- | generic/tkblt.decls (renamed from src/tkblt.decls) | 0 | ||||
-rw-r--r-- | generic/tkbltChain.C (renamed from src/tkbltChain.C) | 0 | ||||
-rw-r--r-- | generic/tkbltChain.h (renamed from src/tkbltChain.h) | 0 | ||||
-rw-r--r-- | generic/tkbltConfig.C (renamed from src/tkbltConfig.C) | 0 | ||||
-rw-r--r-- | generic/tkbltConfig.h (renamed from src/tkbltConfig.h) | 0 | ||||
-rw-r--r-- | generic/tkbltDecls.h (renamed from src/tkbltDecls.h) | 40 | ||||
-rw-r--r-- | generic/tkbltGrAxis.C (renamed from src/tkbltGrAxis.C) | 209 | ||||
-rw-r--r-- | generic/tkbltGrAxis.h (renamed from src/tkbltGrAxis.h) | 24 | ||||
-rw-r--r-- | generic/tkbltGrAxisOp.C (renamed from src/tkbltGrAxisOp.C) | 9 | ||||
-rw-r--r-- | generic/tkbltGrAxisOp.h (renamed from src/tkbltGrAxisOp.h) | 0 | ||||
-rw-r--r-- | generic/tkbltGrAxisOption.C (renamed from src/tkbltGrAxisOption.C) | 10 | ||||
-rw-r--r-- | generic/tkbltGrAxisOption.h (renamed from src/tkbltGrAxisOption.h) | 0 | ||||
-rw-r--r-- | generic/tkbltGrBind.C (renamed from src/tkbltGrBind.C) | 3 | ||||
-rw-r--r-- | generic/tkbltGrBind.h (renamed from src/tkbltGrBind.h) | 0 | ||||
-rw-r--r-- | generic/tkbltGrDef.h (renamed from src/tkbltGrDef.h) | 0 | ||||
-rw-r--r-- | generic/tkbltGrElem.C (renamed from src/tkbltGrElem.C) | 16 | ||||
-rw-r--r-- | generic/tkbltGrElem.h (renamed from src/tkbltGrElem.h) | 4 | ||||
-rw-r--r-- | generic/tkbltGrElemBar.C (renamed from src/tkbltGrElemBar.C) | 84 | ||||
-rw-r--r-- | generic/tkbltGrElemBar.h (renamed from src/tkbltGrElemBar.h) | 14 | ||||
-rw-r--r-- | generic/tkbltGrElemLine.C (renamed from src/tkbltGrElemLine.C) | 136 | ||||
-rw-r--r-- | generic/tkbltGrElemLine.h (renamed from src/tkbltGrElemLine.h) | 0 | ||||
-rw-r--r-- | generic/tkbltGrElemLineSpline.C (renamed from src/tkbltGrElemLineSpline.C) | 0 | ||||
-rw-r--r-- | generic/tkbltGrElemOp.C (renamed from src/tkbltGrElemOp.C) | 11 | ||||
-rw-r--r-- | generic/tkbltGrElemOp.h (renamed from src/tkbltGrElemOp.h) | 0 | ||||
-rw-r--r-- | generic/tkbltGrElemOption.C (renamed from src/tkbltGrElemOption.C) | 9 | ||||
-rw-r--r-- | generic/tkbltGrElemOption.h (renamed from src/tkbltGrElemOption.h) | 0 | ||||
-rw-r--r-- | generic/tkbltGrHairs.C (renamed from src/tkbltGrHairs.C) | 0 | ||||
-rw-r--r-- | generic/tkbltGrHairs.h (renamed from src/tkbltGrHairs.h) | 2 | ||||
-rw-r--r-- | generic/tkbltGrHairsOp.C (renamed from src/tkbltGrHairsOp.C) | 0 | ||||
-rw-r--r-- | generic/tkbltGrHairsOp.h (renamed from src/tkbltGrHairsOp.h) | 0 | ||||
-rw-r--r-- | generic/tkbltGrLegd.C (renamed from src/tkbltGrLegd.C) | 20 | ||||
-rw-r--r-- | generic/tkbltGrLegd.h (renamed from src/tkbltGrLegd.h) | 0 | ||||
-rw-r--r-- | generic/tkbltGrLegdOp.C (renamed from src/tkbltGrLegdOp.C) | 0 | ||||
-rw-r--r-- | generic/tkbltGrLegdOp.h (renamed from src/tkbltGrLegdOp.h) | 0 | ||||
-rw-r--r-- | generic/tkbltGrMarker.C (renamed from src/tkbltGrMarker.C) | 3 | ||||
-rw-r--r-- | generic/tkbltGrMarker.h (renamed from src/tkbltGrMarker.h) | 0 | ||||
-rw-r--r-- | generic/tkbltGrMarkerLine.C (renamed from src/tkbltGrMarkerLine.C) | 7 | ||||
-rw-r--r-- | generic/tkbltGrMarkerLine.h (renamed from src/tkbltGrMarkerLine.h) | 0 | ||||
-rw-r--r-- | generic/tkbltGrMarkerOp.C (renamed from src/tkbltGrMarkerOp.C) | 0 | ||||
-rw-r--r-- | generic/tkbltGrMarkerOp.h (renamed from src/tkbltGrMarkerOp.h) | 0 | ||||
-rw-r--r-- | generic/tkbltGrMarkerOption.C (renamed from src/tkbltGrMarkerOption.C) | 3 | ||||
-rw-r--r-- | generic/tkbltGrMarkerOption.h (renamed from src/tkbltGrMarkerOption.h) | 0 | ||||
-rw-r--r-- | generic/tkbltGrMarkerPolygon.C (renamed from src/tkbltGrMarkerPolygon.C) | 13 | ||||
-rw-r--r-- | generic/tkbltGrMarkerPolygon.h (renamed from src/tkbltGrMarkerPolygon.h) | 0 | ||||
-rw-r--r-- | generic/tkbltGrMarkerText.C (renamed from src/tkbltGrMarkerText.C) | 16 | ||||
-rw-r--r-- | generic/tkbltGrMarkerText.h (renamed from src/tkbltGrMarkerText.h) | 0 | ||||
-rw-r--r-- | generic/tkbltGrMisc.C (renamed from src/tkbltGrMisc.C) | 0 | ||||
-rw-r--r-- | generic/tkbltGrMisc.h (renamed from src/tkbltGrMisc.h) | 9 | ||||
-rw-r--r-- | generic/tkbltGrPSOutput.C (renamed from src/tkbltGrPSOutput.C) | 40 | ||||
-rw-r--r-- | generic/tkbltGrPSOutput.h (renamed from src/tkbltGrPSOutput.h) | 2 | ||||
-rw-r--r-- | generic/tkbltGrPen.C (renamed from src/tkbltGrPen.C) | 3 | ||||
-rw-r--r-- | generic/tkbltGrPen.h (renamed from src/tkbltGrPen.h) | 0 | ||||
-rw-r--r-- | generic/tkbltGrPenBar.C (renamed from src/tkbltGrPenBar.C) | 0 | ||||
-rw-r--r-- | generic/tkbltGrPenBar.h (renamed from src/tkbltGrPenBar.h) | 0 | ||||
-rw-r--r-- | generic/tkbltGrPenLine.C (renamed from src/tkbltGrPenLine.C) | 0 | ||||
-rw-r--r-- | generic/tkbltGrPenLine.h (renamed from src/tkbltGrPenLine.h) | 0 | ||||
-rw-r--r-- | generic/tkbltGrPenOp.C (renamed from src/tkbltGrPenOp.C) | 0 | ||||
-rw-r--r-- | generic/tkbltGrPenOp.h (renamed from src/tkbltGrPenOp.h) | 0 | ||||
-rw-r--r-- | generic/tkbltGrPenOption.C (renamed from src/tkbltGrPenOption.C) | 0 | ||||
-rw-r--r-- | generic/tkbltGrPostscript.C (renamed from src/tkbltGrPostscript.C) | 0 | ||||
-rw-r--r-- | generic/tkbltGrPostscript.h (renamed from src/tkbltGrPostscript.h) | 10 | ||||
-rw-r--r-- | generic/tkbltGrPostscriptOp.C (renamed from src/tkbltGrPostscriptOp.C) | 0 | ||||
-rw-r--r-- | generic/tkbltGrPostscriptOp.h (renamed from src/tkbltGrPostscriptOp.h) | 0 | ||||
-rw-r--r-- | generic/tkbltGrText.C (renamed from src/tkbltGrText.C) | 21 | ||||
-rw-r--r-- | generic/tkbltGrText.h (renamed from src/tkbltGrText.h) | 2 | ||||
-rw-r--r-- | generic/tkbltGrXAxisOp.C (renamed from src/tkbltGrXAxisOp.C) | 2 | ||||
-rw-r--r-- | generic/tkbltGrXAxisOp.h (renamed from src/tkbltGrXAxisOp.h) | 0 | ||||
-rw-r--r-- | generic/tkbltGraph.C (renamed from src/tkbltGraph.C) | 19 | ||||
-rw-r--r-- | generic/tkbltGraph.h (renamed from src/tkbltGraph.h) | 38 | ||||
-rw-r--r-- | generic/tkbltGraphBar.C (renamed from src/tkbltGraphBar.C) | 10 | ||||
-rw-r--r-- | generic/tkbltGraphBar.h (renamed from src/tkbltGraphBar.h) | 4 | ||||
-rw-r--r-- | generic/tkbltGraphLine.C (renamed from src/tkbltGraphLine.C) | 0 | ||||
-rw-r--r-- | generic/tkbltGraphLine.h (renamed from src/tkbltGraphLine.h) | 0 | ||||
-rw-r--r-- | generic/tkbltGraphOp.C (renamed from src/tkbltGraphOp.C) | 10 | ||||
-rw-r--r-- | generic/tkbltGraphOp.h (renamed from src/tkbltGraphOp.h) | 0 | ||||
-rw-r--r-- | generic/tkbltGraphSup.C (renamed from src/tkbltGraphSup.C) | 14 | ||||
-rw-r--r-- | generic/tkbltInt.C (renamed from src/tkbltInt.C) | 0 | ||||
-rw-r--r-- | generic/tkbltInt.h | 58 | ||||
-rw-r--r-- | generic/tkbltNsUtil.C (renamed from src/tkbltNsUtil.C) | 0 | ||||
-rw-r--r-- | generic/tkbltNsUtil.h (renamed from src/tkbltNsUtil.h) | 0 | ||||
-rw-r--r-- | generic/tkbltOp.C (renamed from src/tkbltOp.C) | 0 | ||||
-rw-r--r-- | generic/tkbltOp.h (renamed from src/tkbltOp.h) | 0 | ||||
-rw-r--r-- | generic/tkbltParse.C (renamed from src/tkbltParse.C) | 0 | ||||
-rw-r--r-- | generic/tkbltParse.h (renamed from src/tkbltParse.h) | 0 | ||||
-rw-r--r-- | generic/tkbltStubInit.c (renamed from src/tkbltStubInit.c) | 2 | ||||
-rw-r--r-- | generic/tkbltStubLib.C (renamed from src/tkbltStubLib.C) | 0 | ||||
-rw-r--r-- | generic/tkbltSwitch.C (renamed from src/tkbltSwitch.C) | 0 | ||||
-rw-r--r-- | generic/tkbltSwitch.h (renamed from src/tkbltSwitch.h) | 0 | ||||
-rw-r--r-- | generic/tkbltVecCmd.C (renamed from src/tkbltVecCmd.C) | 11 | ||||
-rw-r--r-- | generic/tkbltVecInt.h (renamed from src/tkbltVecInt.h) | 0 | ||||
-rw-r--r-- | generic/tkbltVecMath.C (renamed from src/tkbltVecMath.C) | 39 | ||||
-rw-r--r-- | generic/tkbltVecOp.C (renamed from src/tkbltVecOp.C) | 0 | ||||
-rw-r--r-- | generic/tkbltVector.C (renamed from src/tkbltVector.C) | 5 | ||||
-rw-r--r-- | generic/tkbltVector.h (renamed from src/tkbltVector.h) | 69 |
98 files changed, 697 insertions, 613 deletions
@@ -5644,55 +5644,55 @@ done vars=" -src/tkbltChain.C -src/tkbltConfig.C -src/tkbltGrAxis.C -src/tkbltGrAxisOp.C -src/tkbltGrAxisOption.C -src/tkbltGrBind.C -src/tkbltGrElemOp.C -src/tkbltGrElemOption.C -src/tkbltGrElem.C -src/tkbltGrElemBar.C -src/tkbltGrElemLine.C -src/tkbltGrElemLineSpline.C -src/tkbltGrHairs.C -src/tkbltGrHairsOp.C -src/tkbltGrLegd.C -src/tkbltGrLegdOp.C -src/tkbltGrMarkerOp.C -src/tkbltGrMarkerOption.C -src/tkbltGrMarker.C -src/tkbltGrMarkerLine.C -src/tkbltGrMarkerPolygon.C -src/tkbltGrMarkerText.C -src/tkbltGrMisc.C -src/tkbltGrPenOp.C -src/tkbltGrPenOption.C -src/tkbltGrPen.C -src/tkbltGrPenBar.C -src/tkbltGrPenLine.C -src/tkbltGrPostscript.C -src/tkbltGrPostscriptOp.C -src/tkbltGrPSOutput.C -src/tkbltGrText.C -src/tkbltGrXAxisOp.C -src/tkbltGraph.C -src/tkbltGraphBar.C -src/tkbltGraphLine.C -src/tkbltGraphOp.C -src/tkbltGraphSup.C -src/tkbltInt.C -src/tkbltNsUtil.C -src/tkbltParse.C -src/tkbltOp.C -src/tkbltStubInit.c -src/tkbltStubLib.C -src/tkbltSwitch.C -src/tkbltVecCmd.C -src/tkbltVecOp.C -src/tkbltVecMath.C -src/tkbltVector.C +tkbltChain.C +tkbltConfig.C +tkbltGrAxis.C +tkbltGrAxisOp.C +tkbltGrAxisOption.C +tkbltGrBind.C +tkbltGrElemOp.C +tkbltGrElemOption.C +tkbltGrElem.C +tkbltGrElemBar.C +tkbltGrElemLine.C +tkbltGrElemLineSpline.C +tkbltGrHairs.C +tkbltGrHairsOp.C +tkbltGrLegd.C +tkbltGrLegdOp.C +tkbltGrMarkerOp.C +tkbltGrMarkerOption.C +tkbltGrMarker.C +tkbltGrMarkerLine.C +tkbltGrMarkerPolygon.C +tkbltGrMarkerText.C +tkbltGrMisc.C +tkbltGrPenOp.C +tkbltGrPenOption.C +tkbltGrPen.C +tkbltGrPenBar.C +tkbltGrPenLine.C +tkbltGrPostscript.C +tkbltGrPostscriptOp.C +tkbltGrPSOutput.C +tkbltGrText.C +tkbltGrXAxisOp.C +tkbltGraph.C +tkbltGraphBar.C +tkbltGraphLine.C +tkbltGraphOp.C +tkbltGraphSup.C +tkbltInt.C +tkbltNsUtil.C +tkbltParse.C +tkbltOp.C +tkbltStubInit.c +tkbltStubLib.C +tkbltSwitch.C +tkbltVecCmd.C +tkbltVecOp.C +tkbltVecMath.C +tkbltVector.C " for i in $vars; do case $i in @@ -5729,8 +5729,8 @@ src/tkbltVector.C vars=" -src/tkbltVector.h -src/tkbltDecls.h +generic/tkbltVector.h +generic/tkbltDecls.h " for i in $vars; do # check for existence, be strict because it is installed @@ -5742,7 +5742,7 @@ src/tkbltDecls.h - vars="-I./src" + vars="" for i in $vars; do PKG_INCLUDES="$PKG_INCLUDES $i" done @@ -5763,12 +5763,11 @@ src/tkbltDecls.h done +#if test "windows" = "${TEA_PLATFORM}"; then +#TEA_ADD_CFLAGS([-TP -EHsc -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES]) +#fi - PKG_CFLAGS="$PKG_CFLAGS " - - - - vars="src/tkbltStubLib.C" + vars="tkbltStubLib.C" for i in $vars; do # check for existence - allows for generic/win/unix VPATH if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/generic/$i" \ @@ -5815,8 +5814,7 @@ src/tkbltDecls.h # TEA_ADD_* any platform specific compiler/build info here. #-------------------------------------------------------------------- -#CLEANFILES="$CLEANFILES pkgIndex.tcl" -CLEANFILES="$CLEANFILES tkbltConfig.sh" +CLEANFILES="$CLEANFILES" if test "${TEA_PLATFORM}" = "windows" ; then # Ensure no empty if clauses : diff --git a/configure.ac b/configure.ac index da04b23..7e2d152 100644 --- a/configure.ac +++ b/configure.ac @@ -72,64 +72,66 @@ TEA_SETUP_COMPILER #----------------------------------------------------------------------- TEA_ADD_SOURCES([ -src/tkbltChain.C -src/tkbltConfig.C -src/tkbltGrAxis.C -src/tkbltGrAxisOp.C -src/tkbltGrAxisOption.C -src/tkbltGrBind.C -src/tkbltGrElemOp.C -src/tkbltGrElemOption.C -src/tkbltGrElem.C -src/tkbltGrElemBar.C -src/tkbltGrElemLine.C -src/tkbltGrElemLineSpline.C -src/tkbltGrHairs.C -src/tkbltGrHairsOp.C -src/tkbltGrLegd.C -src/tkbltGrLegdOp.C -src/tkbltGrMarkerOp.C -src/tkbltGrMarkerOption.C -src/tkbltGrMarker.C -src/tkbltGrMarkerLine.C -src/tkbltGrMarkerPolygon.C -src/tkbltGrMarkerText.C -src/tkbltGrMisc.C -src/tkbltGrPenOp.C -src/tkbltGrPenOption.C -src/tkbltGrPen.C -src/tkbltGrPenBar.C -src/tkbltGrPenLine.C -src/tkbltGrPostscript.C -src/tkbltGrPostscriptOp.C -src/tkbltGrPSOutput.C -src/tkbltGrText.C -src/tkbltGrXAxisOp.C -src/tkbltGraph.C -src/tkbltGraphBar.C -src/tkbltGraphLine.C -src/tkbltGraphOp.C -src/tkbltGraphSup.C -src/tkbltInt.C -src/tkbltNsUtil.C -src/tkbltParse.C -src/tkbltOp.C -src/tkbltStubInit.c -src/tkbltStubLib.C -src/tkbltSwitch.C -src/tkbltVecCmd.C -src/tkbltVecOp.C -src/tkbltVecMath.C -src/tkbltVector.C +tkbltChain.C +tkbltConfig.C +tkbltGrAxis.C +tkbltGrAxisOp.C +tkbltGrAxisOption.C +tkbltGrBind.C +tkbltGrElemOp.C +tkbltGrElemOption.C +tkbltGrElem.C +tkbltGrElemBar.C +tkbltGrElemLine.C +tkbltGrElemLineSpline.C +tkbltGrHairs.C +tkbltGrHairsOp.C +tkbltGrLegd.C +tkbltGrLegdOp.C +tkbltGrMarkerOp.C +tkbltGrMarkerOption.C +tkbltGrMarker.C +tkbltGrMarkerLine.C +tkbltGrMarkerPolygon.C +tkbltGrMarkerText.C +tkbltGrMisc.C +tkbltGrPenOp.C +tkbltGrPenOption.C +tkbltGrPen.C +tkbltGrPenBar.C +tkbltGrPenLine.C +tkbltGrPostscript.C +tkbltGrPostscriptOp.C +tkbltGrPSOutput.C +tkbltGrText.C +tkbltGrXAxisOp.C +tkbltGraph.C +tkbltGraphBar.C +tkbltGraphLine.C +tkbltGraphOp.C +tkbltGraphSup.C +tkbltInt.C +tkbltNsUtil.C +tkbltParse.C +tkbltOp.C +tkbltStubInit.c +tkbltStubLib.C +tkbltSwitch.C +tkbltVecCmd.C +tkbltVecOp.C +tkbltVecMath.C +tkbltVector.C ]) TEA_ADD_HEADERS([ -src/tkbltVector.h -src/tkbltDecls.h +generic/tkbltVector.h +generic/tkbltDecls.h ]) -TEA_ADD_INCLUDES([-I./src]) +TEA_ADD_INCLUDES([]) TEA_ADD_LIBS([-lstdc++]) -TEA_ADD_CFLAGS([]) -TEA_ADD_STUB_SOURCES([src/tkbltStubLib.C]) +#if test "windows" = "${TEA_PLATFORM}"; then +#TEA_ADD_CFLAGS([-TP -EHsc -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES]) +#fi +TEA_ADD_STUB_SOURCES([tkbltStubLib.C]) TEA_ADD_TCL_SOURCES([library/graph.tcl]) #-------------------------------------------------------------------- @@ -144,8 +146,7 @@ TEA_ADD_TCL_SOURCES([library/graph.tcl]) # TEA_ADD_* any platform specific compiler/build info here. #-------------------------------------------------------------------- -#CLEANFILES="$CLEANFILES pkgIndex.tcl" -CLEANFILES="$CLEANFILES tkbltConfig.sh" +CLEANFILES="$CLEANFILES" if test "${TEA_PLATFORM}" = "windows" ; then # Ensure no empty if clauses : diff --git a/doc/graph.html b/doc/graph.html index 412c817..70f1e6f 100644 --- a/doc/graph.html +++ b/doc/graph.html @@ -438,23 +438,6 @@ Sets the color of the axis and tick labels. The default is black. - <B>-command</B> <I>prefix</I> - Specifies a Tcl command to be invoked when formatting the - axis tick labels. <I>Prefix</I> is a string containing the name - of a Tcl proc and any extra arguments for the procedure. - This command is invoked for each major tick on the axis. - Two additional arguments are passed to the procedure: the - pathname of the widget and the current the numeric value - of the tick. The procedure returns the formatted tick - label. If "" is returned, no label will appear next to - the tick. You can get the standard tick labels again by - setting <I>prefix</I> to "". The default is "". - - Please note that this procedure is invoked while the - graph is redrawn. You may query configuration options. - But do not them, because this can have unexpected - results. - <B>-descending</B> <I>boolean</I> Indicates whether the values along the axis are monotoni- cally increasing or decreasing. If <I>boolean</I> is true, the @@ -542,6 +525,31 @@ Specifies the font for axis tick labels. The default is *-Courier-Bold-R-Normal-*-100-*. + <B>-tickformat</B> <I>formatStr</I> + Specifies a printf-like description to format teh axis + tick labels. You can get the standard tick labels again by + setting <I>formatStr</I> to "". The default is "". + + <B>-tickformatcommand</B>, <B>-command</B> <I>prefix</I> + Specifies a Tcl command to be invoked when formatting the + axis tick labels. <I>Prefix</I> is a string containing the name + of a Tcl proc and any extra arguments for the procedure. + This command is invoked for each major tick on the axis. + Two additional arguments are passed to the procedure: the + pathname of the widget and the current the numeric value + of the tick. The procedure returns the formatted tick + label. If "" is returned, no label will appear next to + the tick. You can get the standard tick labels again by + setting <I>prefix</I> to "". The default is "". + + The numeric value for the tick might change when using the + <B>-logscale</B> and <B>-tickformat</B> options. + + Please note that this procedure is invoked while the + graph is redrawn. You may query configuration options. + But do not them, because this can have unexpected + results. + <B>-ticklength</B> <I>pixels</I> Sets the length of major and minor ticks (minor ticks are half the length of major ticks). If <I>pixels</I> is less than diff --git a/doc/graph.n b/doc/graph.n index 72df726..fbbbb9b 100644 --- a/doc/graph.n +++ b/doc/graph.n @@ -686,21 +686,6 @@ the element is always the first tag in the list. The default value is Sets the color of the axis and tick labels. The default is \f(CWblack\fR. .TP -\fB\-command \fIprefix\fR -Specifies a Tcl command to be invoked when formatting the axis tick -labels. \fIPrefix\fR is a string containing the name of a Tcl proc and -any extra arguments for the procedure. This command is invoked for each -major tick on the axis. Two additional arguments are passed to the -procedure: the pathname of the widget and the current the numeric -value of the tick. The procedure returns the formatted tick label. If -\f(CW""\fR is returned, no label will appear next to the tick. You can -get the standard tick labels again by setting \fIprefix\fR to -\f(CW""\fR. The default is \f(CW""\fR. -.sp 1 -Please note that this procedure is invoked while the graph is redrawn. -You may query configuration options. But do not them, because this -can have unexpected results. -.TP \fB\-descending \fIboolean\fR Indicates whether the values along the axis are monotonically increasing or decreasing. If \fIboolean\fR is true, the axis values will be @@ -810,6 +795,29 @@ displayed. The default is \f(CW2\fR. Specifies the font for axis tick labels. The default is \f(CW*-Courier-Bold-R-Normal-*-100-*\fR. .TP +\fB\-tickformat\fR \fIformatStr\fR +Specifies a printf-like description to format teh axis +tick labels. You can get the standard tick labels again by +setting \fIformatStr\fR to \f(CW""\fR. The default is \f(CW""\fR. +.TP +\fB\-tickformatcommand\fR, \fB\-command \fIprefix\fR +Specifies a Tcl command to be invoked when formatting the axis tick +labels. \fIPrefix\fR is a string containing the name of a Tcl proc and +any extra arguments for the procedure. This command is invoked for each +major tick on the axis. Two additional arguments are passed to the +procedure: the pathname of the widget and the current the numeric +value of the tick. The procedure returns the formatted tick label. If +\f(CW""\fR is returned, no label will appear next to the tick. You can +get the standard tick labels again by setting \fIprefix\fR to +\f(CW""\fR. The default is \f(CW""\fR. +.sp 1 +The numeric value for the tick might change when using the +\fB\-logscale\fR and \fB\-tickformat\fR options. +.sp 1 +Please note that this procedure is invoked while the graph is redrawn. +You may query configuration options. But do not them, because this +can have unexpected results. +.TP \fB\-ticklength \fIpixels\fR Sets the length of major and minor ticks (minor ticks are half the length of major ticks). If \fIpixels\fR is less than zero, the axis diff --git a/src/tkblt.decls b/generic/tkblt.decls index b4b5c67..b4b5c67 100644 --- a/src/tkblt.decls +++ b/generic/tkblt.decls diff --git a/src/tkbltChain.C b/generic/tkbltChain.C index dbd317c..dbd317c 100644 --- a/src/tkbltChain.C +++ b/generic/tkbltChain.C diff --git a/src/tkbltChain.h b/generic/tkbltChain.h index 6e254f9..6e254f9 100644 --- a/src/tkbltChain.h +++ b/generic/tkbltChain.h diff --git a/src/tkbltConfig.C b/generic/tkbltConfig.C index 82fea4e..82fea4e 100644 --- a/src/tkbltConfig.C +++ b/generic/tkbltConfig.C diff --git a/src/tkbltConfig.h b/generic/tkbltConfig.h index 790649b..790649b 100644 --- a/src/tkbltConfig.h +++ b/generic/tkbltConfig.h diff --git a/src/tkbltDecls.h b/generic/tkbltDecls.h index d50e207..4d7c679 100644 --- a/src/tkbltDecls.h +++ b/generic/tkbltDecls.h @@ -9,64 +9,64 @@ extern "C" { */ /* 0 */ -EXTERN int Blt_CreateVector(Tcl_Interp*interp, +TKBLT_STORAGE_CLASS int Blt_CreateVector(Tcl_Interp*interp, const char *vecName, int size, Blt_Vector**vecPtrPtr); /* 1 */ -EXTERN int Blt_CreateVector2(Tcl_Interp*interp, +TKBLT_STORAGE_CLASS int Blt_CreateVector2(Tcl_Interp*interp, const char *vecName, const char *cmdName, const char *varName, int initialSize, Blt_Vector **vecPtrPtr); /* 2 */ -EXTERN int Blt_DeleteVectorByName(Tcl_Interp*interp, +TKBLT_STORAGE_CLASS int Blt_DeleteVectorByName(Tcl_Interp*interp, const char *vecName); /* 3 */ -EXTERN int Blt_DeleteVector(Blt_Vector *vecPtr); +TKBLT_STORAGE_CLASS int Blt_DeleteVector(Blt_Vector *vecPtr); /* 4 */ -EXTERN int Blt_GetVector(Tcl_Interp*interp, const char *vecName, +TKBLT_STORAGE_CLASS int Blt_GetVector(Tcl_Interp*interp, const char *vecName, Blt_Vector **vecPtrPtr); /* 5 */ -EXTERN int Blt_GetVectorFromObj(Tcl_Interp*interp, +TKBLT_STORAGE_CLASS int Blt_GetVectorFromObj(Tcl_Interp*interp, Tcl_Obj *objPtr, Blt_Vector **vecPtrPtr); /* 6 */ -EXTERN int Blt_ResetVector(Blt_Vector *vecPtr, double *dataArr, +TKBLT_STORAGE_CLASS int Blt_ResetVector(Blt_Vector *vecPtr, double *dataArr, int n, int arraySize, Tcl_FreeProc *freeProc); /* 7 */ -EXTERN int Blt_ResizeVector(Blt_Vector *vecPtr, int n); +TKBLT_STORAGE_CLASS int Blt_ResizeVector(Blt_Vector *vecPtr, int n); /* 8 */ -EXTERN int Blt_VectorExists(Tcl_Interp*interp, +TKBLT_STORAGE_CLASS int Blt_VectorExists(Tcl_Interp*interp, const char *vecName); /* 9 */ -EXTERN int Blt_VectorExists2(Tcl_Interp*interp, +TKBLT_STORAGE_CLASS int Blt_VectorExists2(Tcl_Interp*interp, const char *vecName); /* 10 */ -EXTERN Blt_VectorId Blt_AllocVectorId(Tcl_Interp*interp, +TKBLT_STORAGE_CLASS Blt_VectorId Blt_AllocVectorId(Tcl_Interp*interp, const char *vecName); /* 11 */ -EXTERN int Blt_GetVectorById(Tcl_Interp*interp, +TKBLT_STORAGE_CLASS int Blt_GetVectorById(Tcl_Interp*interp, Blt_VectorId clientId, Blt_Vector **vecPtrPtr); /* 12 */ -EXTERN void Blt_SetVectorChangedProc(Blt_VectorId clientId, +TKBLT_STORAGE_CLASS void Blt_SetVectorChangedProc(Blt_VectorId clientId, Blt_VectorChangedProc *proc, ClientData clientData); /* 13 */ -EXTERN void Blt_FreeVectorId(Blt_VectorId clientId); +TKBLT_STORAGE_CLASS void Blt_FreeVectorId(Blt_VectorId clientId); /* 14 */ -EXTERN const char * Blt_NameOfVectorId(Blt_VectorId clientId); +TKBLT_STORAGE_CLASS const char * Blt_NameOfVectorId(Blt_VectorId clientId); /* 15 */ -EXTERN const char * Blt_NameOfVector(Blt_Vector *vecPtr); +TKBLT_STORAGE_CLASS const char * Blt_NameOfVector(Blt_Vector *vecPtr); /* 16 */ -EXTERN int Blt_ExprVector(Tcl_Interp*interp, char *expr, +TKBLT_STORAGE_CLASS int Blt_ExprVector(Tcl_Interp*interp, char *expr, Blt_Vector *vecPtr); /* 17 */ -EXTERN void Blt_InstallIndexProc(Tcl_Interp*interp, +TKBLT_STORAGE_CLASS void Blt_InstallIndexProc(Tcl_Interp*interp, const char *indexName, Blt_VectorIndexProc *procPtr); /* 18 */ -EXTERN double Blt_VecMin(Blt_Vector *vPtr); +TKBLT_STORAGE_CLASS double Blt_VecMin(Blt_Vector *vPtr); /* 19 */ -EXTERN double Blt_VecMax(Blt_Vector *vPtr); +TKBLT_STORAGE_CLASS double Blt_VecMax(Blt_Vector *vPtr); typedef struct TkbltStubs { int magic; diff --git a/src/tkbltGrAxis.C b/generic/tkbltGrAxis.C index 2d8dbfb..bac6316 100644 --- a/src/tkbltGrAxis.C +++ b/generic/tkbltGrAxis.C @@ -42,6 +42,7 @@ #include "tkbltGrDef.h" #include "tkbltConfig.h" #include "tkbltGrPSOutput.h" +#include "tkbltInt.h" using namespace Blt; @@ -83,8 +84,8 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_COLOR, "-color", "color", "Color", STD_NORMAL_FOREGROUND, -1, Tk_Offset(AxisOptions, tickColor), 0, NULL, CACHE}, - {TK_OPTION_STRING, "-command", "command", "Command", - NULL, -1, Tk_Offset(AxisOptions, formatCmd), TK_OPTION_NULL_OK, NULL, 0}, + {TK_OPTION_SYNONYM, "-command", NULL, NULL, + NULL, 0, -1, 0, (ClientData)"-tickformatcommand", 0}, {TK_OPTION_BOOLEAN, "-descending", "descending", "Descending", "no", -1, Tk_Offset(AxisOptions, descending), 0, NULL, RESET}, {TK_OPTION_BOOLEAN, "-exterior", "exterior", "exterior", @@ -178,6 +179,10 @@ static Tk_OptionSpec optionSpecs[] = { "8", -1, Tk_Offset(AxisOptions, tickLength), 0, NULL, LAYOUT}, {TK_OPTION_INT, "-tickdefault", "tickDefault", "TickDefault", "4", -1, Tk_Offset(AxisOptions, reqNumMajorTicks), 0, NULL, RESET}, + {TK_OPTION_STRING, "-tickformat", "tickFormat", "TickFormat", + NULL, -1, Tk_Offset(AxisOptions, tickFormat), TK_OPTION_NULL_OK, NULL, 0}, + {TK_OPTION_STRING, "-tickformatcommand", "tickformatcommand", "TickFormatCommand", + NULL, -1, Tk_Offset(AxisOptions, tickFormatCmd), TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_STRING, "-title", "title", "Title", NULL, -1, Tk_Offset(AxisOptions, title), TK_OPTION_NULL_OK, NULL, LAYOUT}, {TK_OPTION_BOOLEAN, "-titlealternate", "titleAlternate", "TitleAlternate", @@ -201,8 +206,7 @@ TickLabel::TickLabel(char* str) TickLabel::~TickLabel() { - if (string) - delete [] string; + delete [] string; } Ticks::Ticks(int cnt) @@ -213,8 +217,7 @@ Ticks::Ticks(int cnt) Ticks::~Ticks() { - if (values) - delete [] values; + delete [] values; } Axis::Axis(Graph* graphPtr, const char* name, int margin, Tcl_HashEntry* hPtr) @@ -309,10 +312,8 @@ Axis::~Axis() if (hashPtr_) Tcl_DeleteHashEntry(hashPtr_); - if (name_) - delete [] name_; - if (className_) - delete [] className_; + delete [] name_; + delete [] className_; if (tickGC_) Tk_FreeGC(graphPtr_->display_, tickGC_); @@ -320,27 +321,22 @@ Axis::~Axis() if (activeTickGC_) Tk_FreeGC(graphPtr_->display_, activeTickGC_); - if (ops->major.segments) - delete [] ops->major.segments; - if (ops->major.gc) + delete [] ops->major.segments; + if (ops->major.gc) graphPtr_->freePrivateGC(ops->major.gc); - if (ops->minor.segments) - delete [] ops->minor.segments; + delete [] ops->minor.segments; if (ops->minor.gc) graphPtr_->freePrivateGC(ops->minor.gc); - if (t1Ptr_) - delete t1Ptr_; - if (t2Ptr_) - delete t2Ptr_; + delete t1Ptr_; + delete t2Ptr_; freeTickLabels(); delete tickLabels_; - if (segments_) - delete [] segments_; + delete [] segments_; Tk_FreeConfigOptions((char*)ops_, optionTable_, graphPtr_->tkwin_); free(ops_); @@ -384,9 +380,9 @@ int Axis::configure() scrollMax_ = NAN; } - float angle = fmod(ops->tickAngle, 360.0); - if (angle < 0.0f) - angle += 360.0f; + double angle = fmod(ops->tickAngle, 360.0); + if (angle < 0.0) + angle += 360.0; ops->tickAngle = angle; resetTextStyles(); @@ -395,8 +391,8 @@ int Axis::configure() if (ops->title) { int w, h; graphPtr_->getTextExtents(ops->titleFont, ops->title, -1, &w, &h); - titleWidth_ = (unsigned short int)w; - titleHeight_ = (unsigned short int)h; + titleWidth_ = (unsigned int)w; + titleHeight_ = (unsigned int)h; } return TCL_OK; @@ -446,7 +442,7 @@ void Axis::mapStacked(int count, int margin) graphPtr_->getTextExtents(ops->tickFont, "0", 1, &w, &h); screenMin_ += (slice * count) + 2 + h / 2; screenRange_ = slice - 2 * 2 - h; - screenScale_ = 1.0f / screenRange_; + screenScale_ = 1.0 / screenRange_; AxisInfo info; offsets(margin, 0, &info); @@ -480,19 +476,13 @@ void Axis::mapGridlines() needed = t1Ptr->nTicks; if (needed != ops->major.nAllocated) { - if (ops->major.segments) { - delete [] ops->major.segments; - ops->major.segments = NULL; - } + delete [] ops->major.segments; ops->major.segments = new Segment2d[needed]; ops->major.nAllocated = needed; } needed = (t1Ptr->nTicks * t2Ptr->nTicks); if (needed != ops->minor.nAllocated) { - if (ops->minor.segments) { - delete [] ops->minor.segments; - ops->minor.segments = NULL; - } + delete [] ops->minor.segments; ops->minor.segments = new Segment2d[needed]; ops->minor.nAllocated = needed; } @@ -598,7 +588,7 @@ void Axis::draw(Drawable drawable) max_ = EXP10(max_); } updateScrollbar(graphPtr_->interp_, ops->scrollCmdObjPtr, - viewMin, viewMax, worldWidth); + (int)viewMin, (int)viewMax, (int)worldWidth); } else { viewMax = (fract * worldWidth); @@ -610,7 +600,7 @@ void Axis::draw(Drawable drawable) max_ = EXP10(max_); } updateScrollbar(graphPtr_->interp_, ops->scrollCmdObjPtr, - viewMax, viewMin, worldWidth); + (int)viewMax, (int)viewMin, (int)worldWidth); } } @@ -729,9 +719,7 @@ void Axis::drawLimits(Drawable drawable) void Axis::setClass(ClassId classId) { - if (className_) - delete [] className_; - className_ =NULL; + delete [] className_; classId_ = classId; switch (classId) { @@ -745,6 +733,7 @@ void Axis::setClass(ClassId classId) className_ = dupstr("YAxis"); break; default: + className_ = NULL; break; } } @@ -783,7 +772,7 @@ void Axis::logScale(double min, double max) minorStep = 0.2; } else - nMinor = (majorStep/minorStep) - 1; + nMinor = (int)(majorStep/minorStep) - 1; } else { if (tickMin == tickMax) @@ -841,7 +830,7 @@ void Axis::linearScale(double min, double max) axisMin = tickMin = floor(min / step) * step + 0.0; axisMax = tickMax = ceil(max / step) * step + 0.0; - nTicks = ((tickMax-tickMin) / step) + 1; + nTicks = (int)((tickMax-tickMin) / step) + 1; } majorSweep_.step = step; majorSweep_.initial = tickMin; @@ -1047,12 +1036,16 @@ TickLabel* Axis::makeLabel(double value) AxisOptions* ops = (AxisOptions*)ops_; char string[TICK_LABEL_SIZE + 1]; - if (ops->logScale) + + if (ops->tickFormat && *ops->tickFormat) { + snprintf(string, TICK_LABEL_SIZE, ops->tickFormat, value); + } else if (ops->logScale) { snprintf(string, TICK_LABEL_SIZE, "1E%d", int(value)); - else - snprintf(string, TICK_LABEL_SIZE, "%.*G", 15, value); + } else { + snprintf(string, TICK_LABEL_SIZE, "%.15G", value); + } - if (ops->formatCmd) { + if (ops->tickFormatCmd) { Tcl_Interp* interp = graphPtr_->interp_; Tk_Window tkwin = graphPtr_->tkwin_; @@ -1060,7 +1053,7 @@ TickLabel* Axis::makeLabel(double value) // name of the widget and the default tick label as arguments when // invoking it. Copy and save the new label from interp->result. Tcl_ResetResult(interp); - if (Tcl_VarEval(interp, ops->formatCmd, " ", Tk_PathName(tkwin), + if (Tcl_VarEval(interp, ops->tickFormatCmd, " ", Tk_PathName(tkwin), " ", string, NULL) != TCL_OK) { Tcl_BackgroundError(interp); } @@ -1268,7 +1261,17 @@ void Axis::offsets(int margin, int offset, AxisInfo *infoPtr) switch (margin) { case MARGIN_TOP: { - axisLine = graphPtr_->top_; + int mark = graphPtr_->top_ - offset - pad; + tickAnchor_ = TK_ANCHOR_S; + left_ = screenMin_ - inset - 2; + right_ = screenMin_ + screenRange_ + inset - 1; + if (gops->stackAxes) + top_ = mark - marginPtr->axesOffset; + else + top_ = mark - height_; + bottom_ = mark; + + axisLine = bottom_; if (ops->exterior) { axisLine -= gops->plotBW + axisPad + ops->lineWidth / 2; tickLabel = axisLine - 2; @@ -1283,16 +1286,6 @@ void Axis::offsets(int margin, int offset, AxisInfo *infoPtr) tickLabel = graphPtr_->top_ - gops->plotBW - 2; } - int mark = graphPtr_->top_ - offset - pad; - tickAnchor_ = TK_ANCHOR_S; - left_ = screenMin_ - inset - 2; - right_ = screenMin_ + screenRange_ + inset - 1; - if (gops->stackAxes) - top_ = mark - marginPtr->axesOffset; - else - top_ = mark - height_; - bottom_ = mark; - int x, y; if (ops->titleAlternate) { x = graphPtr_->right_ + AXIS_PAD_TITLE; @@ -1328,23 +1321,8 @@ void Axis::offsets(int margin, int offset, AxisInfo *infoPtr) * tick * title */ - axisLine = graphPtr_->bottom_; - if (gops->plotRelief == TK_RELIEF_SOLID) - axisLine++; - - if (ops->exterior) { - axisLine += gops->plotBW + axisPad + ops->lineWidth / 2; - tickLabel = axisLine + 2; - if (ops->lineWidth > 0) - tickLabel += ops->tickLength; - } - else { - axisLine -= axisPad + ops->lineWidth / 2; - tickLabel = graphPtr_->bottom_ + gops->plotBW + 2; - } - int mark = graphPtr_->bottom_ + offset; - float fangle = fmod(ops->tickAngle, 90.0); + double fangle = fmod(ops->tickAngle, 90.0); if (fangle == 0.0) tickAnchor_ = TK_ANCHOR_N; else { @@ -1357,12 +1335,27 @@ void Axis::offsets(int margin, int offset, AxisInfo *infoPtr) left_ = screenMin_ - inset - 2; right_ = screenMin_ + screenRange_ + inset - 1; - top_ = graphPtr_->bottom_ + labelOffset - t1; + top_ = mark + labelOffset - t1; if (gops->stackAxes) bottom_ = mark + marginPtr->axesOffset - 1; else bottom_ = mark + height_ - 1; + axisLine = top_; + if (gops->plotRelief == TK_RELIEF_SOLID) + axisLine++; + + if (ops->exterior) { + axisLine += gops->plotBW + axisPad + ops->lineWidth / 2; + tickLabel = axisLine + 2; + if (ops->lineWidth > 0) + tickLabel += ops->tickLength; + } + else { + axisLine -= axisPad + ops->lineWidth / 2; + tickLabel = graphPtr_->bottom_ + gops->plotBW + 2; + } + int x, y; if (ops->titleAlternate) { x = graphPtr_->right_ + AXIS_PAD_TITLE; @@ -1421,7 +1414,17 @@ void Axis::offsets(int margin, int offset, AxisInfo *infoPtr) * G = graph border width * H = highlight thickness */ - axisLine = graphPtr_->left_; + int mark = graphPtr_->left_ - offset; + tickAnchor_ = TK_ANCHOR_E; + if (gops->stackAxes) + left_ = mark - marginPtr->axesOffset; + else + left_ = mark - width_; + right_ = mark - 3; + top_ = screenMin_ - inset - 2; + bottom_ = screenMin_ + screenRange_ + inset - 1; + + axisLine = right_; if (ops->exterior) { axisLine -= gops->plotBW + axisPad + ops->lineWidth / 2; tickLabel = axisLine - 2; @@ -1435,16 +1438,6 @@ void Axis::offsets(int margin, int offset, AxisInfo *infoPtr) tickLabel = graphPtr_->left_ - gops->plotBW - 2; } - int mark = graphPtr_->left_ - offset; - tickAnchor_ = TK_ANCHOR_E; - if (gops->stackAxes) - left_ = mark - marginPtr->axesOffset; - else - left_ = mark - width_; - right_ = mark - 3; - top_ = screenMin_ - inset - 2; - bottom_ = screenMin_ + screenRange_ + inset - 1; - int x, y; if (ops->titleAlternate) { x = mark - (width_ / 2); @@ -1466,7 +1459,18 @@ void Axis::offsets(int margin, int offset, AxisInfo *infoPtr) case MARGIN_RIGHT: { - axisLine = graphPtr_->right_; + int mark = graphPtr_->right_ + offset + pad; + tickAnchor_ = TK_ANCHOR_W; + left_ = mark; + if (gops->stackAxes) + right_ = mark + marginPtr->axesOffset - 1; + else + right_ = mark + width_ - 1; + + top_ = screenMin_ - inset - 2; + bottom_ = screenMin_ + screenRange_ + inset -1; + + axisLine = left_; if (gops->plotRelief == TK_RELIEF_SOLID) axisLine++; @@ -1481,17 +1485,6 @@ void Axis::offsets(int margin, int offset, AxisInfo *infoPtr) tickLabel = graphPtr_->right_ + gops->plotBW + 2; } - int mark = graphPtr_->right_ + offset + pad; - tickAnchor_ = TK_ANCHOR_W; - left_ = mark; - if (gops->stackAxes) - right_ = mark + marginPtr->axesOffset - 1; - else - right_ = mark + width_ - 1; - - top_ = screenMin_ - inset - 2; - bottom_ = screenMin_ + screenRange_ + inset -1; - int x, y; if (ops->titleAlternate) { x = mark + (width_ / 2); @@ -1562,10 +1555,8 @@ void Axis::makeSegments(AxisInfo *infoPtr) { AxisOptions* ops = (AxisOptions*)ops_; - if (segments_) { - delete [] segments_; - segments_ = NULL; - } + delete [] segments_; + segments_ = NULL; Ticks* t1Ptr = ops->t1UPtr ? ops->t1UPtr : t1Ptr_; Ticks* t2Ptr = ops->t2UPtr ? ops->t2UPtr : t2Ptr_; @@ -1814,14 +1805,14 @@ void Axis::printLimits(PSOutput* psPtr) ops->limitsTextStyle.angle = 90.0; ops->limitsTextStyle.anchor = TK_ANCHOR_SE; - ts.printText(psPtr, maxPtr, (double)graphPtr_->right_, hMax); + ts.printText(psPtr, maxPtr, graphPtr_->right_, (int)hMax); hMax -= (textWidth + spacing); } else { ops->limitsTextStyle.angle = 0.0; ops->limitsTextStyle.anchor = TK_ANCHOR_NW; - ts.printText(psPtr, maxPtr, vMax, (double)graphPtr_->top_); + ts.printText(psPtr, maxPtr, (int)vMax, graphPtr_->top_); vMax += (textWidth + spacing); } } @@ -1836,13 +1827,13 @@ void Axis::printLimits(PSOutput* psPtr) if (isHoriz) { ops->limitsTextStyle.angle = 90.0; - ts.printText(psPtr, minPtr, (double)graphPtr_->left_, hMin); + ts.printText(psPtr, minPtr, graphPtr_->left_, (int)hMin); hMin -= (textWidth + spacing); } else { ops->limitsTextStyle.angle = 0.0; - ts.printText(psPtr, minPtr, vMin, (double)graphPtr_->bottom_); + ts.printText(psPtr, minPtr, (int)vMin, graphPtr_->bottom_); vMin += (textWidth + spacing); } } @@ -1918,12 +1909,12 @@ void Axis::getGeometry() labelPtr->width = lw; labelPtr->height = lh; - if (ops->tickAngle != 0.0f) { + if (ops->tickAngle != 0.0) { // Rotated label width and height double rlw, rlh; graphPtr_->getBoundingBox(lw, lh, ops->tickAngle, &rlw, &rlh, NULL); - lw = rlw; - lh = rlh; + lw = (int)rlw; + lh = (int)rlh; } if (maxTickWidth_ < int(lw)) maxTickWidth_ = lw; diff --git a/src/tkbltGrAxis.h b/generic/tkbltGrAxis.h index 2e35d3f..d459e8c 100644 --- a/src/tkbltGrAxis.h +++ b/generic/tkbltGrAxis.h @@ -114,7 +114,7 @@ namespace Blt { int showTicks; double windowSize; - const char *formatCmd; + const char *tickFormatCmd; int descending; int labelOffset; TextStyleOptions limitsTextStyle; @@ -153,6 +153,8 @@ namespace Blt { Tk_Font tickFont; Tk_Font titleFont; XColor* titleColor; + + const char *tickFormat; } AxisOptions; class Axis { @@ -175,8 +177,8 @@ namespace Blt { Chain* chain; Point2d titlePos_; - unsigned short int titleWidth_; - unsigned short int titleHeight_; + unsigned int titleWidth_; + unsigned int titleHeight_; double min_; double max_; double scrollMin_; @@ -194,14 +196,14 @@ namespace Blt { Segment2d *segments_; int nSegments_; Chain* tickLabels_; - short int left_; - short int right_; - short int top_; - short int bottom_; - short int width_; - short int height_; - short int maxTickWidth_; - short int maxTickHeight_; + int left_; + int right_; + int top_; + int bottom_; + int width_; + int height_; + int maxTickWidth_; + int maxTickHeight_; Tk_Anchor tickAnchor_; GC tickGC_; GC activeTickGC_; diff --git a/src/tkbltGrAxisOp.C b/generic/tkbltGrAxisOp.C index 89b2be9..e467d53 100644 --- a/src/tkbltGrAxisOp.C +++ b/generic/tkbltGrAxisOp.C @@ -36,6 +36,7 @@ #include "tkbltGrAxis.h" #include "tkbltGrAxisOp.h" #include "tkbltGrMisc.h" +#include "tkbltInt.h" using namespace Blt; @@ -554,10 +555,14 @@ int AxisTypeOp(Axis* axisPtr, Tcl_Interp* interp, { const char* typeName = ""; if (axisPtr->use_) { - if (axisNames[axisPtr->margin_].classId == CID_AXIS_X) + switch (axisPtr->classId_) { + case CID_AXIS_X: typeName = "x"; - else if (axisNames[axisPtr->margin_].classId == CID_AXIS_Y) + break; + case CID_AXIS_Y: typeName = "y"; + break; + } } Tcl_SetStringObj(Tcl_GetObjResult(interp), typeName, -1); diff --git a/src/tkbltGrAxisOp.h b/generic/tkbltGrAxisOp.h index 777aea7..777aea7 100644 --- a/src/tkbltGrAxisOp.h +++ b/generic/tkbltGrAxisOp.h diff --git a/src/tkbltGrAxisOption.C b/generic/tkbltGrAxisOption.C index d0f78e8..6f91d99 100644 --- a/src/tkbltGrAxisOption.C +++ b/generic/tkbltGrAxisOption.C @@ -35,6 +35,7 @@ #include "tkbltGrAxis.h" #include "tkbltGrAxisOption.h" #include "tkbltConfig.h" +#include "tkbltInt.h" using namespace Blt; @@ -63,7 +64,11 @@ static int AxisSetProc(ClientData clientData, Tcl_Interp* interp, return TCL_OK; Graph* graphPtr = getGraphFromWindowData(tkwin); - ClassId classId = (ClassId)(long(clientData)); +#ifdef _WIN64 + ClassId classId = (ClassId)((long long)clientData); +#else + ClassId classId = (ClassId)((long)clientData); +#endif Axis *axisPtr; if (graphPtr->getAxis(*objPtr, &axisPtr) != TCL_OK) @@ -211,8 +216,7 @@ static void TicksFreeProc(ClientData clientData, Tk_Window tkwin, char *ptr) { Ticks* ticksPtr = *(Ticks**)ptr; - if (ticksPtr) - delete ticksPtr; + delete ticksPtr; } static Tk_CustomOptionSetProc ObjectSetProc; diff --git a/src/tkbltGrAxisOption.h b/generic/tkbltGrAxisOption.h index 4efa8ee..4efa8ee 100644 --- a/src/tkbltGrAxisOption.h +++ b/generic/tkbltGrAxisOption.h diff --git a/src/tkbltGrBind.C b/generic/tkbltGrBind.C index 2873c8f..3e7e81e 100644 --- a/src/tkbltGrBind.C +++ b/generic/tkbltGrBind.C @@ -160,8 +160,7 @@ void BindTable::doEvent(XEvent* eventPtr) const char** tagArray = graphPtr_->getTags(item, classId, &nTags); Tk_BindEvent(table_, eventPtr, graphPtr_->tkwin_, nTags, (void**)tagArray); - if (tagArray) - delete [] tagArray; + delete [] tagArray; } void BindTable::pickItem(XEvent* eventPtr) diff --git a/src/tkbltGrBind.h b/generic/tkbltGrBind.h index 7947210..7947210 100644 --- a/src/tkbltGrBind.h +++ b/generic/tkbltGrBind.h diff --git a/src/tkbltGrDef.h b/generic/tkbltGrDef.h index d73836a..d73836a 100644 --- a/src/tkbltGrDef.h +++ b/generic/tkbltGrDef.h diff --git a/src/tkbltGrElem.C b/generic/tkbltGrElem.C index c80cbc1..faf1b72 100644 --- a/src/tkbltGrElem.C +++ b/generic/tkbltGrElem.C @@ -37,6 +37,7 @@ #include "tkbltGrBind.h" #include "tkbltGrElem.h" #include "tkbltGrPen.h" +#include "tkbltInt.h" using namespace Blt; @@ -52,14 +53,12 @@ ElemValues::ElemValues() ElemValues::~ElemValues() { - if (values_) - delete [] values_; + delete [] values_; } void ElemValues::reset() { - if (values_) - delete [] values_; + delete [] values_; values_ =NULL; nValues_ =0; min_ =0; @@ -133,8 +132,7 @@ int ElemValuesVector::fetchValues(Blt_Vector* vector) { Graph* graphPtr = elemPtr_->graphPtr_; - if (values_) - delete [] values_; + delete [] values_; values_ = NULL; nValues_ = 0; min_ =0; @@ -200,11 +198,9 @@ Element::~Element() if (hashPtr_) Tcl_DeleteHashEntry(hashPtr_); - if (name_) - delete [] name_; + delete [] name_; - if (activeIndices_) - delete [] activeIndices_; + delete [] activeIndices_; Tk_FreeConfigOptions((char*)ops_, optionTable_, graphPtr_->tkwin_); free(ops_); diff --git a/src/tkbltGrElem.h b/generic/tkbltGrElem.h index eabc9e9..8904df0 100644 --- a/src/tkbltGrElem.h +++ b/generic/tkbltGrElem.h @@ -156,8 +156,8 @@ namespace Blt { Graph* graphPtr_; const char* name_; Tcl_HashEntry* hashPtr_; - unsigned short row_; - unsigned short col_; + unsigned row_; + unsigned col_; int nActiveIndices_; int* activeIndices_; int active_; diff --git a/src/tkbltGrElemBar.C b/generic/tkbltGrElemBar.C index ad3099e..6698760 100644 --- a/src/tkbltGrElemBar.C +++ b/generic/tkbltGrElemBar.C @@ -41,6 +41,7 @@ #include "tkbltGrDef.h" #include "tkbltConfig.h" #include "tkbltGrPSOutput.h" +#include "tkbltInt.h" using namespace Blt; @@ -227,8 +228,7 @@ BarElement::~BarElement() { BarElementOptions* ops = (BarElementOptions*)ops_; - if (builtinPenPtr) - delete builtinPenPtr; + delete builtinPenPtr; reset(); @@ -272,14 +272,14 @@ void BarElement::map() return; int nPoints = NUMBEROFPOINTS(ops); - double barWidth = (ops->barWidth > 0.0f) ? ops->barWidth : gops->barWidth; + double barWidth = (ops->barWidth > 0.0) ? ops->barWidth : gops->barWidth; AxisOptions* axisyops = (AxisOptions*)ops->yAxis->ops(); double baseline = (axisyops->logScale) ? 0.0 : gops->baseline; double barOffset = barWidth * 0.5; // Create an array of bars representing the screen coordinates of all the // segments in the bar. - XRectangle* bars = new XRectangle[nPoints]; + Rectangle* bars = new Rectangle[nPoints]; int* barToData = new int[nPoints]; double* x = ops->coords.x->values_; @@ -287,7 +287,7 @@ void BarElement::map() int count = 0; int ii; - XRectangle* rp; + Rectangle* rp; for (rp=bars, ii=0; ii<nPoints; ii++) { // Two opposite corners of the rectangle in graph coordinates Point2d c1, c2; @@ -428,13 +428,15 @@ void BarElement::map() continue; int height = (int)dy; + int width = (int)dx; if (invertBar) - rp->y = (short int)MIN(c1.y, c2.y); + rp->y = (int)MIN(c1.y, c2.y); else - rp->y = (short int)(MAX(c1.y, c2.y)) - height; + rp->y = (int)(MAX(c1.y, c2.y)) - height; - rp->x = (short int)MIN(c1.x, c2.x); - rp->width = (short int)dx + 1; + rp->x = (int)MIN(c1.x, c2.x); + + rp->width = width + 1; rp->width |= 0x1; if (rp->width < 1) rp->width = 1; @@ -621,7 +623,7 @@ void BarElement::closest() int imin = 0; int ii; - XRectangle* bp; + Rectangle* bp; for (bp=bars_, ii=0; ii<nBars_; ii++, bp++) { if (PointInRectangle(bp, searchPtr->x, searchPtr->y)) { imin = barToData_[ii]; @@ -873,7 +875,7 @@ void BarElement::checkStacks(Axis* xAxis, Axis* yAxis, // Check if any of the y-values (because of stacking) are greater // than the current limits of the graph. - if (gp->sum < 0.0f) { + if (gp->sum < 0.0) { if (*minPtr > gp->sum) *minPtr = gp->sum; } @@ -904,9 +906,9 @@ void BarElement::mergePens(BarStyle** dataToStyle) // We have more than one style. Group bar segments of like pen styles together if (nBars_ > 0) { - XRectangle* bars = new XRectangle[nBars_]; + Rectangle* bars = new Rectangle[nBars_]; int* barToData = new int[nBars_]; - XRectangle* bp = bars; + Rectangle* bp = bars; int* ip = barToData; for (ChainLink* link = Chain_FirstLink(ops->stylePalette); link; link = Chain_NextLink(link)) { @@ -979,18 +981,16 @@ void BarElement::mergePens(BarStyle** dataToStyle) void BarElement::mapActive() { - if (activeRects_) { - delete [] activeRects_; - activeRects_ = NULL; - } - if (activeToData_) { - delete [] activeToData_; - activeToData_ = NULL; - } + delete [] activeRects_; + activeRects_ = NULL; + + delete [] activeToData_; + activeToData_ = NULL; + nActive_ = 0; if (nActiveIndices_ > 0) { - XRectangle* activeRects = new XRectangle[nActiveIndices_]; + Rectangle* activeRects = new Rectangle[nActiveIndices_]; int* activeToData = new int[nActiveIndices_]; int count = 0; for (int ii=0; ii<nBars_; ii++) { @@ -1015,34 +1015,26 @@ void BarElement::reset() ResetStylePalette(ops->stylePalette); - if (activeRects_) - delete [] activeRects_; + delete [] activeRects_; activeRects_ = NULL; - if (activeToData_) - delete [] activeToData_; + delete [] activeToData_; activeToData_ = NULL; - if (xeb_.segments) - delete [] xeb_.segments; + delete [] xeb_.segments; xeb_.segments = NULL; - if (xeb_.map) - delete [] xeb_.map; + delete [] xeb_.map; xeb_.map = NULL; xeb_.length = 0; - if (yeb_.segments) - delete [] yeb_.segments; + delete [] yeb_.segments; yeb_.segments = NULL; - if (yeb_.map) - delete [] yeb_.map; + delete [] yeb_.map; yeb_.map = NULL; yeb_.length = 0; - if (bars_) - delete [] bars_; + delete [] bars_; bars_ = NULL; - if (barToData_) - delete [] barToData_; + delete [] barToData_; barToData_ = NULL; nActive_ = 0; @@ -1189,10 +1181,10 @@ void BarElement::mapErrorBars(BarStyle **dataToStyle) } void BarElement::drawSegments(Drawable drawable, BarPen* penPtr, - XRectangle *bars, int nBars) + Rectangle *bars, int nBars) { BarPenOptions* pops = (BarPenOptions*)penPtr->ops(); - for (XRectangle *rp = bars, *rend = rp + nBars; rp < rend; rp++) { + for (Rectangle *rp = bars, *rend = rp + nBars; rp < rend; rp++) { if ((rp->width < 1) || (rp->height < 1)) continue; @@ -1207,7 +1199,7 @@ void BarElement::drawSegments(Drawable drawable, BarPen* penPtr, } void BarElement::drawValues(Drawable drawable, BarPen* penPtr, - XRectangle *bars, int nBars, int *barToData) + Rectangle *bars, int nBars, int *barToData) { BarElementOptions* ops = (BarElementOptions*)ops_; BarPenOptions* pops = (BarPenOptions*)penPtr->ops(); @@ -1219,7 +1211,7 @@ void BarElement::drawValues(Drawable drawable, BarPen* penPtr, TextStyle ts(graphPtr_, &pops->valueStyle); int count = 0; - for (XRectangle *rp = bars, *rend = rp + nBars; rp < rend; rp++) { + for (Rectangle *rp = bars, *rend = rp + nBars; rp < rend; rp++) { Point2d anchorPos; char string[TCL_DOUBLE_SPACE * 2 + 2]; @@ -1255,10 +1247,10 @@ void BarElement::drawValues(Drawable drawable, BarPen* penPtr, } void BarElement::printSegments(PSOutput* psPtr, BarPen* penPtr, - XRectangle *bars, int nBars) + Rectangle *bars, int nBars) { BarPenOptions* pops = (BarPenOptions*)penPtr->ops(); - for (XRectangle *rp = bars, *rend = rp + nBars; rp < rend; rp++) { + for (Rectangle *rp = bars, *rend = rp + nBars; rp < rend; rp++) { if ((rp->width < 1) || (rp->height < 1)) continue; @@ -1275,7 +1267,7 @@ void BarElement::printSegments(PSOutput* psPtr, BarPen* penPtr, } void BarElement::printValues(PSOutput* psPtr, BarPen* penPtr, - XRectangle *bars, int nBars, int *barToData) + Rectangle *bars, int nBars, int *barToData) { BarPenOptions* pops = (BarPenOptions*)penPtr->ops(); BarElementOptions* ops = (BarElementOptions*)ops_; @@ -1287,7 +1279,7 @@ void BarElement::printValues(PSOutput* psPtr, BarPen* penPtr, fmt = "%g"; TextStyle ts(graphPtr_, &pops->valueStyle); - for (XRectangle *rp = bars, *rend = rp + nBars; rp < rend; rp++) { + for (Rectangle *rp = bars, *rend = rp + nBars; rp < rend; rp++) { double x = ops->coords.x->values_[barToData[count]]; double y = ops->coords.y->values_[barToData[count]]; diff --git a/src/tkbltGrElemBar.h b/generic/tkbltGrElemBar.h index 9207a9f..8b48114 100644 --- a/src/tkbltGrElemBar.h +++ b/generic/tkbltGrElemBar.h @@ -49,7 +49,7 @@ namespace Blt { typedef struct { Weight weight; BarPen* penPtr; - XRectangle* bars; + Rectangle* bars; int nBars; GraphSegments xeb; GraphSegments yeb; @@ -88,9 +88,9 @@ namespace Blt { protected: BarPen* builtinPenPtr; int* barToData_; - XRectangle* bars_; + Rectangle* bars_; int* activeToData_; - XRectangle* activeRects_; + Rectangle* activeRects_; int nBars_; int nActive_; GraphSegments xeb_; @@ -103,10 +103,10 @@ namespace Blt { void mapActive(); void reset(); void mapErrorBars(BarStyle**); - void drawSegments(Drawable, BarPen*, XRectangle*, int); - void drawValues(Drawable, BarPen*, XRectangle*, int, int*); - void printSegments(PSOutput*, BarPen*, XRectangle*, int); - void printValues(PSOutput*, BarPen*, XRectangle*, int, int*); + void drawSegments(Drawable, BarPen*, Rectangle*, int); + void drawValues(Drawable, BarPen*, Rectangle*, int, int*); + void printSegments(PSOutput*, BarPen*, Rectangle*, int); + void printValues(PSOutput*, BarPen*, Rectangle*, int, int*); public: BarElement(Graph*, const char*, Tcl_HashEntry*); diff --git a/src/tkbltGrElemLine.C b/generic/tkbltGrElemLine.C index 8da4279..ac2b340 100644 --- a/src/tkbltGrElemLine.C +++ b/generic/tkbltGrElemLine.C @@ -41,6 +41,7 @@ #include "tkbltGrDef.h" #include "tkbltConfig.h" #include "tkbltGrPSOutput.h" +#include "tkbltInt.h" using namespace Blt; @@ -265,8 +266,7 @@ LineElement::~LineElement() { LineElementOptions* ops = (LineElementOptions*)ops_; - if (builtinPenPtr) - delete builtinPenPtr; + delete builtinPenPtr; reset(); @@ -275,8 +275,7 @@ LineElement::~LineElement() delete ops->stylePalette; } - if (fillPts_) - delete [] fillPts_; + delete [] fillPts_; } int LineElement::configure() @@ -526,8 +525,8 @@ void LineElement::draw(Drawable drawable) unsigned int count =0; for (Point2d *pp = fillPts_, *endp = pp + nFillPts_; pp < endp; pp++) { - points[count].x = pp->x; - points[count].y = pp->y; + points[count].x = (short)pp->x; + points[count].y = (short)pp->y; count++; } Tk_Fill3DPolygon(graphPtr_->tkwin_, drawable, ops->fillBg, points, @@ -925,11 +924,9 @@ int LineElement::scaleSymbol(int normalSize) scale = MIN(xScale, yScale); } } - int newSize = normalSize * scale; + int newSize = (int)(normalSize * scale); - // Don't let the size of symbols go unbounded. Both X and Win32 drawing - // routines assume coordinates to be a signed short int. - int maxSize = (int)MIN(graphPtr_->hRange_, graphPtr_->vRange_); + int maxSize = MIN(graphPtr_->hRange_, graphPtr_->vRange_); if (newSize > maxSize) newSize = maxSize; @@ -1295,14 +1292,10 @@ void LineElement::mapActiveSymbols() { LineElementOptions* ops = (LineElementOptions*)ops_; - if (activePts_.points) { - delete [] activePts_.points; - activePts_.points = NULL; - } - if (activePts_.map) { - delete [] activePts_.map; - activePts_.map = NULL; - } + delete [] activePts_.points; + activePts_.points = NULL; + delete [] activePts_.map; + activePts_.map = NULL; Region2d exts; graphPtr_->extents(&exts); @@ -1677,38 +1670,29 @@ void LineElement::reset() stylePtr->yeb.length = 0; } - if (symbolPts_.points) { - delete [] symbolPts_.points; - symbolPts_.points = NULL; - } + delete [] symbolPts_.points; + symbolPts_.points = NULL; - if (symbolPts_.map) - delete [] symbolPts_.map; + delete [] symbolPts_.map; symbolPts_.map = NULL; symbolPts_.length = 0; - if (activePts_.points) - delete [] activePts_.points; + delete [] activePts_.points; activePts_.points = NULL; activePts_.length = 0; - if (activePts_.map) - delete [] activePts_.map; + delete [] activePts_.map; activePts_.map = NULL; - if (xeb_.segments) - delete [] xeb_.segments; + delete [] xeb_.segments; xeb_.segments = NULL; - if (xeb_.map) - delete [] xeb_.map; + delete [] xeb_.map; xeb_.map = NULL; xeb_.length = 0; - if (yeb_.segments) - delete [] yeb_.segments; + delete [] yeb_.segments; yeb_.segments = NULL; - if (yeb_.map) - delete [] yeb_.map; + delete [] yeb_.map; yeb_.map = NULL; yeb_.length = 0; } @@ -1952,10 +1936,10 @@ void LineElement::drawCircle(Display *display, Drawable drawable, XArc *ap = arcs; for (Point2d *pp=symbolPts, *pend=pp+nSymbolPts; pp<pend; pp++) { if (DRAW_SYMBOL()) { - ap->x = pp->x - radius; - ap->y = pp->y - radius; - ap->width = (unsigned short)s; - ap->height = (unsigned short)s; + ap->x = (short)(pp->x - radius); + ap->y = (short)(pp->y - radius); + ap->width = (short)s; + ap->height = (short)s; ap->angle1 = 0; ap->angle2 = 23040; ap++; @@ -1985,21 +1969,21 @@ void LineElement::drawSquare(Display *display, Drawable drawable, int s = r + r; int count =0; - XRectangle* rectangles = new XRectangle[nSymbolPts]; - XRectangle* rp=rectangles; + Rectangle* rectangles = new Rectangle[nSymbolPts]; + Rectangle* rp=rectangles; for (Point2d *pp=symbolPts, *pend=pp+nSymbolPts; pp<pend; pp++) { if (DRAW_SYMBOL()) { - rp->x = pp->x - r; - rp->y = pp->y - r; - rp->width = (unsigned short)s; - rp->height = (unsigned short)s; + rp->x = (int)pp->x - r; + rp->y = (int)pp->y - r; + rp->width = s; + rp->height = s; rp++; count++; } symbolCounter_++; } - for (XRectangle *rp=rectangles, *rend=rp+count; rp<rend; rp ++) { + for (Rectangle *rp=rectangles, *rend=rp+count; rp<rend; rp ++) { if (penOps->symbol.fillGC) XFillRectangle(display, drawable, penOps->symbol.fillGC, rp->x, rp->y, rp->width, rp->height); @@ -2018,9 +2002,9 @@ void LineElement::drawSCross(Display* display, Drawable drawable, { LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); - XPoint pattern[4]; + Point pattern[4]; if (penOps->symbol.type == SYMBOL_SCROSS) { - r2 = (double)r2 * M_SQRT1_2; + r2 = (int)(r2 * M_SQRT1_2); pattern[3].y = pattern[2].x = pattern[0].x = pattern[0].y = -r2; pattern[3].x = pattern[2].y = pattern[1].y = pattern[1].x = r2; } @@ -2032,8 +2016,8 @@ void LineElement::drawSCross(Display* display, Drawable drawable, for (Point2d *pp=symbolPts, *endp=pp+nSymbolPts; pp<endp; pp++) { if (DRAW_SYMBOL()) { - int rndx = pp->x; - int rndy = pp->y; + int rndx = (int)pp->x; + int rndy = (int)pp->y; XDrawLine(graphPtr_->display_, drawable, penOps->symbol.outlineGC, pattern[0].x + rndx, pattern[0].y + rndy, pattern[1].x + rndx, pattern[1].y + rndy); @@ -2060,14 +2044,14 @@ void LineElement::drawCross(Display *display, Drawable drawable, * 9 8 */ int d = (r2 / 3); - XPoint pattern[13]; + Point pattern[13]; pattern[0].x = pattern[11].x = pattern[12].x = -r2; pattern[2].x = pattern[1].x = pattern[10].x = pattern[9].x = -d; pattern[3].x = pattern[4].x = pattern[7].x = pattern[8].x = d; pattern[5].x = pattern[6].x = r2; pattern[2].y = pattern[3].y = -r2; pattern[0].y = pattern[1].y = pattern[4].y = pattern[5].y = - pattern[12].y = -d; + pattern[12].y = -d; pattern[11].y = pattern[10].y = pattern[7].y = pattern[6].y = d; pattern[9].y = pattern[8].y = r2; @@ -2076,8 +2060,8 @@ void LineElement::drawCross(Display *display, Drawable drawable, for (int ii=0; ii<12; ii++) { double dx = (double)pattern[ii].x * M_SQRT1_2; double dy = (double)pattern[ii].y * M_SQRT1_2; - pattern[ii].x = dx - dy; - pattern[ii].y = dx + dy; + pattern[ii].x = (int)(dx - dy); + pattern[ii].y = (int)(dx + dy); } pattern[12] = pattern[0]; } @@ -2087,11 +2071,11 @@ void LineElement::drawCross(Display *display, Drawable drawable, XPoint* xpp = polygon; for (Point2d *pp = symbolPts, *endp = pp + nSymbolPts; pp < endp; pp++) { if (DRAW_SYMBOL()) { - int rndx = pp->x; - int rndy = pp->y; + int rndx = (int)pp->x; + int rndy = (int)pp->y; for (int ii=0; ii<13; ii++) { - xpp->x = pattern[ii].x + rndx; - xpp->y = pattern[ii].y + rndy; + xpp->x = (short)(pattern[ii].x + rndx); + xpp->y = (short)(pattern[ii].y + rndy); xpp++; } count++; @@ -2131,7 +2115,7 @@ void LineElement::drawDiamond(Display *display, Drawable drawable, * (fifth) point connects the first and * 3 last points. */ - XPoint pattern[5]; + Point pattern[5]; pattern[1].y = pattern[0].x = -r1; pattern[2].y = pattern[3].x = pattern[0].y = pattern[1].x = 0; pattern[3].y = pattern[2].x = r1; @@ -2142,11 +2126,11 @@ void LineElement::drawDiamond(Display *display, Drawable drawable, XPoint* xpp = polygon; for (Point2d *pp = symbolPts, *endp = pp + nSymbolPts; pp < endp; pp++) { if (DRAW_SYMBOL()) { - int rndx = pp->x; - int rndy = pp->y; + int rndx = (int)pp->x; + int rndy = (int)pp->y; for (int ii=0; ii<5; ii++) { - xpp->x = pattern[ii].x + rndx; - xpp->y = pattern[ii].y + rndy; + xpp->x = (short)(pattern[ii].x + rndx); + xpp->y = (short)(pattern[ii].y + rndy); xpp++; } count++; @@ -2180,10 +2164,10 @@ void LineElement::drawArrow(Display *display, Drawable drawable, { LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); - double b = size * B_RATIO * 0.7; - int b2 = b * 0.5; - int h2 = TAN30 * b2; - int h1 = b2 / COS30; + double b = size * B_RATIO * 0.7 * 0.5; + short b2 = (short)b; + short h2 = (short)(TAN30 * b); + short h1 = (short)(b / COS30); /* * The triangle symbol is a closed polygon * 0,3 of 3 points. The diagram to the left @@ -2193,7 +2177,7 @@ void LineElement::drawArrow(Display *display, Drawable drawable, * 2 1 last points. */ - XPoint pattern[4]; + Point pattern[4]; if (penOps->symbol.type == SYMBOL_ARROW) { pattern[3].x = pattern[0].x = 0; pattern[3].y = pattern[0].y = h1; @@ -2213,11 +2197,11 @@ void LineElement::drawArrow(Display *display, Drawable drawable, XPoint* xpp = polygon; for (Point2d *pp = symbolPts, *endp = pp + nSymbolPts; pp < endp; pp++) { if (DRAW_SYMBOL()) { - int rndx = pp->x; - int rndy = pp->y; + int rndx = (int)pp->x; + int rndy = (int)pp->y; for (int ii=0; ii<4; ii++) { - xpp->x = pattern[ii].x + rndx; - xpp->y = pattern[ii].y + rndy; + xpp->x = (short)(pattern[ii].x + rndx); + xpp->y = (short)(pattern[ii].y + rndy); xpp++; } count++; @@ -2252,7 +2236,7 @@ void LineElement::drawSymbols(Drawable drawable, LinePen* penPtr, int size, if (penOps->symbol.fillGC) { for (Point2d *pp = symbolPts, *endp = pp + nSymbolPts; pp < endp; pp++) XDrawLine(graphPtr_->display_, drawable, penOps->symbol.fillGC, - pp->x, pp->y, pp->x+1, pp->y+1); + (int)pp->x, (int)pp->y, (int)pp->x+1, (int)pp->y+1); } return; } @@ -2297,8 +2281,8 @@ void LineElement::drawTraces(Drawable drawable, LinePen* penPtr) XPoint* points = new XPoint[count]; XPoint*xpp = points; for (int ii=0; ii<count; ii++, xpp++) { - xpp->x = tracePtr->screenPts.points[ii].x; - xpp->y = tracePtr->screenPts.points[ii].y; + xpp->x = (short)tracePtr->screenPts.points[ii].x; + xpp->y = (short)tracePtr->screenPts.points[ii].y; } XDrawLines(graphPtr_->display_, drawable, penPtr->traceGC_, points, count, CoordModeOrigin); diff --git a/src/tkbltGrElemLine.h b/generic/tkbltGrElemLine.h index f937615..f937615 100644 --- a/src/tkbltGrElemLine.h +++ b/generic/tkbltGrElemLine.h diff --git a/src/tkbltGrElemLineSpline.C b/generic/tkbltGrElemLineSpline.C index 9224d53..9224d53 100644 --- a/src/tkbltGrElemLineSpline.C +++ b/generic/tkbltGrElemLineSpline.C diff --git a/src/tkbltGrElemOp.C b/generic/tkbltGrElemOp.C index c4bcbef..af6fc0c 100644 --- a/src/tkbltGrElemOp.C +++ b/generic/tkbltGrElemOp.C @@ -174,10 +174,9 @@ static int ActivateOp(ClientData clientData, Tcl_Interp* interp, } } - if (elemPtr->activeIndices_) - delete [] elemPtr->activeIndices_; - elemPtr->nActiveIndices_ = nIndices; + delete [] elemPtr->activeIndices_; elemPtr->activeIndices_ = indices; + elemPtr->nActiveIndices_ = nIndices; elemPtr->active_ = 1; @@ -306,10 +305,8 @@ static int DeactivateOp(ClientData clientData, Tcl_Interp* interp, if (graphPtr->getElement(objv[ii], &elemPtr) != TCL_OK) return TCL_ERROR; - if (elemPtr->activeIndices_) { - delete [] elemPtr->activeIndices_; - elemPtr->activeIndices_ = NULL; - } + delete [] elemPtr->activeIndices_; + elemPtr->activeIndices_ = NULL; elemPtr->nActiveIndices_ = 0; elemPtr->active_ = 0; } diff --git a/src/tkbltGrElemOp.h b/generic/tkbltGrElemOp.h index b596b11..b596b11 100644 --- a/src/tkbltGrElemOp.h +++ b/generic/tkbltGrElemOp.h diff --git a/src/tkbltGrElemOption.C b/generic/tkbltGrElemOption.C index 45591ac..a0a67e6 100644 --- a/src/tkbltGrElemOption.C +++ b/generic/tkbltGrElemOption.C @@ -136,8 +136,7 @@ static Tcl_Obj* ValuesGetProc(ClientData clientData, Tk_Window tkwin, static void ValuesFreeProc(ClientData clientData, Tk_Window tkwin, char *ptr) { ElemValues* valuesPtr = *(ElemValues**)ptr; - if (valuesPtr) - delete valuesPtr; + delete valuesPtr; } static Tk_CustomOptionSetProc PairsSetProc; @@ -171,12 +170,10 @@ static int PairsSetProc(ClientData clientData, Tcl_Interp* interp, } nValues /= 2; - if (coordsPtr->x) - delete coordsPtr->x; + delete coordsPtr->x; coordsPtr->x = new ElemValuesSource(nValues); - if (coordsPtr->y) - delete coordsPtr->y; + delete coordsPtr->y; coordsPtr->y = new ElemValuesSource(nValues); int ii=0; diff --git a/src/tkbltGrElemOption.h b/generic/tkbltGrElemOption.h index 4312691..4312691 100644 --- a/src/tkbltGrElemOption.h +++ b/generic/tkbltGrElemOption.h diff --git a/src/tkbltGrHairs.C b/generic/tkbltGrHairs.C index d7ea3d2..d7ea3d2 100644 --- a/src/tkbltGrHairs.C +++ b/generic/tkbltGrHairs.C diff --git a/src/tkbltGrHairs.h b/generic/tkbltGrHairs.h index 825cf2a..a86d0c6 100644 --- a/src/tkbltGrHairs.h +++ b/generic/tkbltGrHairs.h @@ -56,7 +56,7 @@ namespace Blt { int visible_; GC gc_; - XPoint segArr_[4]; + Point segArr_[4]; public: Crosshairs(Graph*); diff --git a/src/tkbltGrHairsOp.C b/generic/tkbltGrHairsOp.C index 57650ce..57650ce 100644 --- a/src/tkbltGrHairsOp.C +++ b/generic/tkbltGrHairsOp.C diff --git a/src/tkbltGrHairsOp.h b/generic/tkbltGrHairsOp.h index 3f3d009..3f3d009 100644 --- a/src/tkbltGrHairsOp.h +++ b/generic/tkbltGrHairsOp.h diff --git a/src/tkbltGrLegd.C b/generic/tkbltGrLegd.C index 5242215..b8822f1 100644 --- a/src/tkbltGrLegd.C +++ b/generic/tkbltGrLegd.C @@ -213,8 +213,8 @@ Legend::~Legend() if (focusGC_) graphPtr_->freePrivateGC(focusGC_); - if (graphPtr_->tkwin_) - Tk_DeleteSelHandler(graphPtr_->tkwin_, XA_PRIMARY, XA_STRING); + if (graphPtr_->tkwin_) + Tk_DeleteSelHandler(graphPtr_->tkwin_, XA_PRIMARY, XA_STRING); delete selected_; @@ -878,8 +878,8 @@ int Legend::getElementFromObj(Tcl_Obj* objPtr, Element** elemPtrPtr) Element* Legend::getNextRow(Element* focusPtr) { - int col = focusPtr->col_; - int row = focusPtr->row_ + 1; + unsigned col = focusPtr->col_; + unsigned row = focusPtr->row_ + 1; for (ChainLink* link = focusPtr->link; link; link = Chain_NextLink(link)) { Element* elemPtr = (Element*)Chain_GetValue(link); ElementOptions* elemOps = (ElementOptions*)elemPtr->ops(); @@ -895,8 +895,8 @@ Element* Legend::getNextRow(Element* focusPtr) Element* Legend::getNextColumn(Element* focusPtr) { - int col = focusPtr->col_ + 1; - int row = focusPtr->row_; + unsigned col = focusPtr->col_ + 1; + unsigned row = focusPtr->row_; for (ChainLink* link = focusPtr->link; link; link = Chain_NextLink(link)) { Element* elemPtr = (Element*)Chain_GetValue(link); ElementOptions* elemOps = (ElementOptions*)elemPtr->ops(); @@ -912,8 +912,8 @@ Element* Legend::getNextColumn(Element* focusPtr) Element* Legend::getPreviousRow(Element* focusPtr) { - int col = focusPtr->col_; - int row = focusPtr->row_ - 1; + unsigned col = focusPtr->col_; + unsigned row = focusPtr->row_ - 1; for (ChainLink* link = focusPtr->link; link; link = Chain_PrevLink(link)) { Element* elemPtr = (Element*)Chain_GetValue(link); ElementOptions* elemOps = (ElementOptions*)elemPtr->ops(); @@ -929,8 +929,8 @@ Element* Legend::getPreviousRow(Element* focusPtr) Element* Legend::getPreviousColumn(Element* focusPtr) { - int col = focusPtr->col_ - 1; - int row = focusPtr->row_; + unsigned col = focusPtr->col_ - 1; + unsigned row = focusPtr->row_; for (ChainLink* link = focusPtr->link; link; link = Chain_PrevLink(link)) { Element* elemPtr = (Element*)Chain_GetValue(link); ElementOptions* elemOps = (ElementOptions*)elemPtr->ops(); diff --git a/src/tkbltGrLegd.h b/generic/tkbltGrLegd.h index 66ffbc1..66ffbc1 100644 --- a/src/tkbltGrLegd.h +++ b/generic/tkbltGrLegd.h diff --git a/src/tkbltGrLegdOp.C b/generic/tkbltGrLegdOp.C index 139d2f1..139d2f1 100644 --- a/src/tkbltGrLegdOp.C +++ b/generic/tkbltGrLegdOp.C diff --git a/src/tkbltGrLegdOp.h b/generic/tkbltGrLegdOp.h index 6369a2b..6369a2b 100644 --- a/src/tkbltGrLegdOp.h +++ b/generic/tkbltGrLegdOp.h diff --git a/src/tkbltGrMarker.C b/generic/tkbltGrMarker.C index 6fdcfd6..6f701f8 100644 --- a/src/tkbltGrMarker.C +++ b/generic/tkbltGrMarker.C @@ -63,8 +63,7 @@ Marker::~Marker() if (hashPtr_) Tcl_DeleteHashEntry(hashPtr_); - if (name_) - delete [] name_; + delete [] name_; Tk_FreeConfigOptions((char*)ops_, optionTable_, graphPtr_->tkwin_); free(ops_); diff --git a/src/tkbltGrMarker.h b/generic/tkbltGrMarker.h index 573357d..573357d 100644 --- a/src/tkbltGrMarker.h +++ b/generic/tkbltGrMarker.h diff --git a/src/tkbltGrMarkerLine.C b/generic/tkbltGrMarkerLine.C index 30ef70e..82c9ab8 100644 --- a/src/tkbltGrMarkerLine.C +++ b/generic/tkbltGrMarkerLine.C @@ -103,8 +103,7 @@ LineMarker::~LineMarker() { if (gc_) graphPtr_->freePrivateGC(gc_); - if (segments_) - delete [] segments_; + delete [] segments_; } int LineMarker::configure() @@ -151,9 +150,9 @@ void LineMarker::map() { LineMarkerOptions* ops = (LineMarkerOptions*)ops_; + delete [] segments_; + segments_ = NULL; nSegments_ = 0; - if (segments_) - delete [] segments_; if (!ops->worldPts || (ops->worldPts->num < 2)) return; diff --git a/src/tkbltGrMarkerLine.h b/generic/tkbltGrMarkerLine.h index 3191951..3191951 100644 --- a/src/tkbltGrMarkerLine.h +++ b/generic/tkbltGrMarkerLine.h diff --git a/src/tkbltGrMarkerOp.C b/generic/tkbltGrMarkerOp.C index 20933ab..20933ab 100644 --- a/src/tkbltGrMarkerOp.C +++ b/generic/tkbltGrMarkerOp.C diff --git a/src/tkbltGrMarkerOp.h b/generic/tkbltGrMarkerOp.h index 6f7c16f..6f7c16f 100644 --- a/src/tkbltGrMarkerOp.h +++ b/generic/tkbltGrMarkerOp.h diff --git a/src/tkbltGrMarkerOption.C b/generic/tkbltGrMarkerOption.C index b6eab57..6b13fd9 100644 --- a/src/tkbltGrMarkerOption.C +++ b/generic/tkbltGrMarkerOption.C @@ -119,8 +119,7 @@ static void CoordsFreeProc(ClientData clientData, Tk_Window tkwin, { Coords* coordsPtr = *(Coords**)ptr; if (coordsPtr) { - if (coordsPtr->points) - delete [] coordsPtr->points; + delete [] coordsPtr->points; delete coordsPtr; } } diff --git a/src/tkbltGrMarkerOption.h b/generic/tkbltGrMarkerOption.h index 143810e..143810e 100644 --- a/src/tkbltGrMarkerOption.h +++ b/generic/tkbltGrMarkerOption.h diff --git a/src/tkbltGrMarkerPolygon.C b/generic/tkbltGrMarkerPolygon.C index ed655aa..383d0e8 100644 --- a/src/tkbltGrMarkerPolygon.C +++ b/generic/tkbltGrMarkerPolygon.C @@ -103,12 +103,9 @@ PolygonMarker::~PolygonMarker() Tk_FreeGC(graphPtr_->display_, fillGC_); if (outlineGC_) graphPtr_->freePrivateGC(outlineGC_); - if (fillPts_) - delete [] fillPts_; - if (outlinePts_) - delete [] outlinePts_; - if (screenPts_) - delete [] screenPts_; + delete [] fillPts_; + delete [] outlinePts_; + delete [] screenPts_; } int PolygonMarker::configure() @@ -164,8 +161,8 @@ void PolygonMarker::draw(Drawable drawable) XPoint* dp = points; for (Point2d *sp = fillPts_, *send = sp + nFillPts_; sp < send; sp++) { - dp->x = (short int)sp->x; - dp->y = (short int)sp->y; + dp->x = (short)sp->x; + dp->y = (short)sp->y; dp++; } diff --git a/src/tkbltGrMarkerPolygon.h b/generic/tkbltGrMarkerPolygon.h index 8eb2216..8eb2216 100644 --- a/src/tkbltGrMarkerPolygon.h +++ b/generic/tkbltGrMarkerPolygon.h diff --git a/src/tkbltGrMarkerText.C b/generic/tkbltGrMarkerText.C index f6307fb..9c4da2a 100644 --- a/src/tkbltGrMarkerText.C +++ b/generic/tkbltGrMarkerText.C @@ -120,8 +120,8 @@ int TextMarker::configure() TextMarkerOptions* ops = (TextMarkerOptions*)ops_; ops->style.angle = (float)fmod(ops->style.angle, 360.0); - if (ops->style.angle < 0.0f) - ops->style.angle += 360.0f; + if (ops->style.angle < 0.0) + ops->style.angle += 360.0; GC newGC = NULL; XGCValues gcValues; @@ -148,8 +148,8 @@ void TextMarker::draw(Drawable drawable) if (fillGC_) { XPoint points[4]; for (int ii=0; ii<4; ii++) { - points[ii].x = (short int)(outline_[ii].x + anchorPt_.x); - points[ii].y = (short int)(outline_[ii].y + anchorPt_.y); + points[ii].x = (short)(outline_[ii].x + anchorPt_.x); + points[ii].y = (short)(outline_[ii].y + anchorPt_.y); } XFillPolygon(graphPtr_->display_, drawable, fillGC_, points, 4, Convex, CoordModeOrigin); @@ -179,8 +179,8 @@ void TextMarker::map() double rw; double rh; graphPtr_->getBoundingBox(w, h, ops->style.angle, &rw, &rh, outline_); - width_ = rw; - height_ = rh; + width_ = (int)rw; + height_ = (int)rh; for (int ii=0; ii<4; ii++) { outline_[ii].x += rw * 0.5; outline_[ii].y += rh * 0.5; @@ -211,7 +211,7 @@ int TextMarker::pointIn(Point2d *samplePtr) if (!ops->string) return 0; - if (ops->style.angle != 0.0f) { + if (ops->style.angle != 0.0) { Point2d points[5]; // Figure out the bounding polygon (isolateral) for the text and see @@ -233,7 +233,7 @@ int TextMarker::regionIn(Region2d *extsPtr, int enclosed) { TextMarkerOptions* ops = (TextMarkerOptions*)ops_; - if (ops->style.angle != 0.0f) { + if (ops->style.angle != 0.0) { Point2d points[5]; for (int ii=0; ii<4; ii++) { points[ii].x = outline_[ii].x + anchorPt_.x; diff --git a/src/tkbltGrMarkerText.h b/generic/tkbltGrMarkerText.h index 99dc814..99dc814 100644 --- a/src/tkbltGrMarkerText.h +++ b/generic/tkbltGrMarkerText.h diff --git a/src/tkbltGrMisc.C b/generic/tkbltGrMisc.C index d951494..d951494 100644 --- a/src/tkbltGrMisc.C +++ b/generic/tkbltGrMisc.C diff --git a/src/tkbltGrMisc.h b/generic/tkbltGrMisc.h index b7c521f..ba86b75 100644 --- a/src/tkbltGrMisc.h +++ b/generic/tkbltGrMisc.h @@ -68,6 +68,15 @@ namespace Blt { class Graph; typedef struct { + int x, y; + } Point; + + typedef struct { + int x, y; + unsigned width, height; + } Rectangle; + + typedef struct { double x; double y; } Point2d; diff --git a/src/tkbltGrPSOutput.C b/generic/tkbltGrPSOutput.C index 8f02cba..07d4864 100644 --- a/src/tkbltGrPSOutput.C +++ b/generic/tkbltGrPSOutput.C @@ -144,46 +144,46 @@ void PSOutput::computeBBox(int width, int height) PostscriptOptions* pops = (PostscriptOptions*)setupPtr->ops_; // scale from points to pica - float pica = 25.4 / 72 * + double pica = 25.4 / 72 * WidthOfScreen(Tk_Screen(graphPtr_->tkwin_)) / WidthMMOfScreen(Tk_Screen(graphPtr_->tkwin_)); - int hBorder = 2*pops->xPad/pica; - int vBorder = 2*pops->yPad/pica; + double hBorder = 2*pops->xPad/pica; + double vBorder = 2*pops->yPad/pica; int hSize = !pops->landscape ? width : height; int vSize = !pops->landscape ? height : width; // If the paper size wasn't specified, set it to the graph size plus the // paper border. - int paperWidth = pops->reqPaperWidth > 0 ? pops->reqPaperWidth/pica : + double paperWidth = pops->reqPaperWidth > 0 ? pops->reqPaperWidth/pica : hSize + hBorder; - int paperHeight = pops->reqPaperHeight > 0 ? pops->reqPaperHeight/pica : + double paperHeight = pops->reqPaperHeight > 0 ? pops->reqPaperHeight/pica : vSize + vBorder; // Scale the plot size if it's bigger than the paper - float hScale = (hSize+hBorder) > paperWidth ? 1.0 : - (float)(paperWidth - hBorder) / hSize; - float vScale = (vSize + vBorder) > paperHeight ? 1.0 : - (float)(paperHeight - vBorder) / vSize; + double hScale = (hSize+hBorder) > paperWidth ? 1.0 : + paperWidth - hBorder / hSize; + double vScale = (vSize + vBorder) > paperHeight ? 1.0 : + paperHeight - vBorder / vSize; - float scale = MIN(hScale, vScale); + double scale = MIN(hScale, vScale); if (scale != 1.0) { - hSize = hSize*scale + 0.5; - vSize = vSize*scale + 0.5; + hSize = (int)(hSize*scale + 0.5); + vSize = (int)(vSize*scale + 0.5); } - int x = (paperWidth > hSize) && pops->center ? - (paperWidth - hSize) / 2 : pops->xPad/pica; - int y = (paperHeight > vSize) && pops->center ? - (paperHeight - vSize) / 2 : pops->yPad/pica; + int x = (int)((paperWidth > hSize) && pops->center ? + (paperWidth - hSize) / 2 : pops->xPad/pica); + int y = (int)((paperHeight > vSize) && pops->center ? + (paperHeight - vSize) / 2 : pops->yPad/pica); setupPtr->left = x; setupPtr->bottom = y; setupPtr->right = x + hSize - 1; setupPtr->top = y + vSize - 1; setupPtr->scale = scale; - setupPtr->paperHeight = paperHeight; - setupPtr->paperWidth = paperWidth; + setupPtr->paperHeight = (int)paperHeight; + setupPtr->paperWidth = (int)paperWidth; } const char* PSOutput::getValue(int* lengthPtr) @@ -236,9 +236,9 @@ void PSOutput::fillRectangle(double x, double y, int width, int height) append("fill\n"); } -void PSOutput::fillRectangles(XRectangle* rectangles, int nRectangles) +void PSOutput::fillRectangles(Rectangle* rectangles, int nRectangles) { - for (XRectangle *rp = rectangles, *rend = rp + nRectangles; rp < rend; rp++) + for (Rectangle *rp = rectangles, *rend = rp + nRectangles; rp < rend; rp++) fillRectangle((double)rp->x, (double)rp->y, (int)rp->width,(int)rp->height); } diff --git a/src/tkbltGrPSOutput.h b/generic/tkbltGrPSOutput.h index c54e771..04bb2fd 100644 --- a/src/tkbltGrPSOutput.h +++ b/generic/tkbltGrPSOutput.h @@ -65,7 +65,7 @@ namespace Blt { void print3DRectangle(Tk_3DBorder, double, double, int, int, int, int); void fillRectangle(double, double, int, int); - void fillRectangles(XRectangle*, int); + void fillRectangles(Rectangle*, int); void fill3DRectangle(Tk_3DBorder, double, double, int, int, int, int); void fillPolygon(Point2d*, int); diff --git a/src/tkbltGrPen.C b/generic/tkbltGrPen.C index 42851d8..71e5fe9 100644 --- a/src/tkbltGrPen.C +++ b/generic/tkbltGrPen.C @@ -48,8 +48,7 @@ Pen::Pen(Graph* graphPtr, const char* name, Tcl_HashEntry* hPtr) Pen::~Pen() { - if (name_) - delete [] name_; + delete [] name_; if (hashPtr_) Tcl_DeleteHashEntry(hashPtr_); diff --git a/src/tkbltGrPen.h b/generic/tkbltGrPen.h index 003e8dd..003e8dd 100644 --- a/src/tkbltGrPen.h +++ b/generic/tkbltGrPen.h diff --git a/src/tkbltGrPenBar.C b/generic/tkbltGrPenBar.C index 8f6e59a..8f6e59a 100644 --- a/src/tkbltGrPenBar.C +++ b/generic/tkbltGrPenBar.C diff --git a/src/tkbltGrPenBar.h b/generic/tkbltGrPenBar.h index f39db94..f39db94 100644 --- a/src/tkbltGrPenBar.h +++ b/generic/tkbltGrPenBar.h diff --git a/src/tkbltGrPenLine.C b/generic/tkbltGrPenLine.C index 5f15ce8..5f15ce8 100644 --- a/src/tkbltGrPenLine.C +++ b/generic/tkbltGrPenLine.C diff --git a/src/tkbltGrPenLine.h b/generic/tkbltGrPenLine.h index 63eeeb8..63eeeb8 100644 --- a/src/tkbltGrPenLine.h +++ b/generic/tkbltGrPenLine.h diff --git a/src/tkbltGrPenOp.C b/generic/tkbltGrPenOp.C index 8c5669d..8c5669d 100644 --- a/src/tkbltGrPenOp.C +++ b/generic/tkbltGrPenOp.C diff --git a/src/tkbltGrPenOp.h b/generic/tkbltGrPenOp.h index 5dab592..5dab592 100644 --- a/src/tkbltGrPenOp.h +++ b/generic/tkbltGrPenOp.h diff --git a/src/tkbltGrPenOption.C b/generic/tkbltGrPenOption.C index b1da1b6..b1da1b6 100644 --- a/src/tkbltGrPenOption.C +++ b/generic/tkbltGrPenOption.C diff --git a/src/tkbltGrPostscript.C b/generic/tkbltGrPostscript.C index 4bbf504..4bbf504 100644 --- a/src/tkbltGrPostscript.C +++ b/generic/tkbltGrPostscript.C diff --git a/src/tkbltGrPostscript.h b/generic/tkbltGrPostscript.h index 7ab54a3..a0c35a1 100644 --- a/src/tkbltGrPostscript.h +++ b/generic/tkbltGrPostscript.h @@ -56,11 +56,11 @@ namespace Blt { void* ops_; Graph* graphPtr_; - short int left; - short int bottom; - short int right; - short int top; - float scale; + int left; + int bottom; + int right; + int top; + double scale; int paperHeight; int paperWidth; diff --git a/src/tkbltGrPostscriptOp.C b/generic/tkbltGrPostscriptOp.C index 931feb9..931feb9 100644 --- a/src/tkbltGrPostscriptOp.C +++ b/generic/tkbltGrPostscriptOp.C diff --git a/src/tkbltGrPostscriptOp.h b/generic/tkbltGrPostscriptOp.h index 9a81266..9a81266 100644 --- a/src/tkbltGrPostscriptOp.h +++ b/generic/tkbltGrPostscriptOp.h diff --git a/src/tkbltGrText.C b/generic/tkbltGrText.C index 20709f1..1bed069 100644 --- a/src/tkbltGrText.C +++ b/generic/tkbltGrText.C @@ -94,13 +94,18 @@ void TextStyle::drawText(Drawable drawable, const char *text, int x, int y) Point2d rr = rotateText(x, y, w1, h1); #if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 6) TkDrawAngledTextLayout(graphPtr_->display_, drawable, gc_, layout, - rr.x, rr.y, ops->angle, 0, -1); + (int)rr.x, (int)rr.y, + ops->angle, 0, -1); #else Tk_DrawTextLayout(graphPtr_->display_, drawable, gc_, layout, rr.x, rr.y, 0, -1); #endif } +void TextStyle::drawText(Drawable drawable, const char *text, double x, double y) { + return drawText(drawable, text, (int)x, (int)y); +} + void TextStyle::drawText2(Drawable drawable, const char *text, int x, int y, int* ww, int* hh) { @@ -118,21 +123,21 @@ void TextStyle::drawText2(Drawable drawable, const char *text, Point2d rr = rotateText(x, y, w1, h1); #if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 6) TkDrawAngledTextLayout(graphPtr_->display_, drawable, gc_, layout, - rr.x, rr.y, ops->angle, 0, -1); + (int)rr.x, (int)rr.y, ops->angle, 0, -1); #else Tk_DrawTextLayout(graphPtr_->display_, drawable, gc_, layout, - rr.x, rr.y, 0, -1); + (int)rr.x, (int)rr.y, 0, -1); #endif - float angle = fmod(ops->angle, 360.0); + double angle = fmod(ops->angle, 360.0); if (angle < 0.0) angle += 360.0; if (angle != 0.0) { double rotWidth, rotHeight; graphPtr_->getBoundingBox(w1, h1, angle, &rotWidth, &rotHeight, NULL); - w1 = rotWidth; - h1 = rotHeight; + w1 = (int)rotWidth; + h1 = (int)rotHeight; } *ww = w1; @@ -182,6 +187,10 @@ void TextStyle::printText(PSOutput* psPtr, const char *text, int x, int y) psPtr->format("] %g %g %s DrawText\n", xx/-2.0, yy/-2.0, justify); } +void TextStyle::printText(PSOutput* psPtr, const char *text, double x, double y) { + return printText(psPtr, text, (int)x, (int)y); +} + void TextStyle::resetStyle() { TextStyleOptions* ops = (TextStyleOptions*)ops_; diff --git a/src/tkbltGrText.h b/generic/tkbltGrText.h index 770e99e..4337e81 100644 --- a/src/tkbltGrText.h +++ b/generic/tkbltGrText.h @@ -68,8 +68,10 @@ namespace Blt { void* ops() {return ops_;} void drawText(Drawable, const char*, int, int); + void drawText(Drawable, const char*, double, double); void drawText2(Drawable, const char*, int, int, int*, int*); void printText(PSOutput*, const char*, int, int); + void printText(PSOutput*, const char*, double, double); void getExtents(const char*, int*, int*); }; }; diff --git a/src/tkbltGrXAxisOp.C b/generic/tkbltGrXAxisOp.C index b431a43..ac788ff 100644 --- a/src/tkbltGrXAxisOp.C +++ b/generic/tkbltGrXAxisOp.C @@ -161,6 +161,7 @@ static int UseOp(ClientData clientData, Tcl_Interp* interp, Axis* axisPtr = (Axis*)Chain_GetValue(link); axisPtr->link = NULL; axisPtr->use_ =0; + axisPtr->margin_ = MARGIN_NONE; // Clear the axis type if it's not currently used if (axisPtr->refCount_ == 0) axisPtr->setClass(CID_NONE); @@ -190,6 +191,7 @@ static int UseOp(ClientData clientData, Tcl_Interp* interp, axisPtr->chain = chain; axisPtr->use_ =1; + axisPtr->margin_ = margin; } graphPtr->flags |= RESET; diff --git a/src/tkbltGrXAxisOp.h b/generic/tkbltGrXAxisOp.h index b813c83..b813c83 100644 --- a/src/tkbltGrXAxisOp.h +++ b/generic/tkbltGrXAxisOp.h diff --git a/src/tkbltGraph.C b/generic/tkbltGraph.C index bb1707d..f1453dc 100644 --- a/src/tkbltGraph.C +++ b/generic/tkbltGraph.C @@ -27,7 +27,8 @@ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include <float.h> +#include <cfloat> +#include <cmath> #include <tkInt.h> @@ -50,6 +51,7 @@ #include "tkbltGrDef.h" #include "tkbltGrPostscript.h" #include "tkbltGrPSOutput.h" +#include "tkbltInt.h" using namespace Blt; @@ -139,8 +141,7 @@ Graph::~Graph() destroyAxes(); destroyPens(); - if (bindTable_) - delete bindTable_; + delete bindTable_; if (drawGC_) Tk_FreeGC(display_, drawGC_); @@ -510,13 +511,13 @@ void Graph::reconfigure() void Graph::drawMargins(Drawable drawable) { GraphOptions* ops = (GraphOptions*)ops_; - XRectangle rects[4]; + Rectangle rects[4]; // Draw the four outer rectangles which encompass the plotting // surface. This clears the surrounding area and clips the plot. rects[0].x = rects[0].y = rects[3].x = rects[1].x = 0; - rects[0].width = rects[3].width = (short int)width_; - rects[0].height = (short int)top_; + rects[0].width = rects[3].width = width_; + rects[0].height = top_; rects[3].y = bottom_; rects[3].height = height_ - bottom_; rects[2].y = rects[1].y = top_; @@ -558,7 +559,7 @@ void Graph::printMargins(PSOutput* psPtr) { GraphOptions* ops = (GraphOptions*)ops_; PostscriptOptions* pops = (PostscriptOptions*)postscript_->ops_; - XRectangle margin[4]; + Rectangle margin[4]; margin[0].x = margin[0].y = margin[3].x = margin[1].x = 0; margin[0].width = margin[3].width = width_; @@ -595,7 +596,7 @@ void Graph::printMargins(PSOutput* psPtr) if (ops->title) { psPtr->append("% Graph title\n"); TextStyle ts(this, &ops->titleTextStyle); - ts.printText(psPtr, ops->title, (double)titleX_, (double)titleY_); + ts.printText(psPtr, ops->title, titleX_, titleY_); } } @@ -1426,7 +1427,7 @@ void Graph::drawSegments(Drawable drawable, GC gc, Segment2d* segments, int nSegments) { for (Segment2d *sp = segments, *send = sp + nSegments; sp < send; sp++) - XDrawLine(display_, drawable, gc, sp->p.x, sp->p.y, sp->q.x, sp->q.y); + XDrawLine(display_, drawable, gc, (int)sp->p.x, (int)sp->p.y, (int)sp->q.x, (int)sp->q.y); } GC Graph::getPrivateGC(unsigned long gcMask, XGCValues *valuePtr) diff --git a/src/tkbltGraph.h b/generic/tkbltGraph.h index 8aece0f..6f8df01 100644 --- a/src/tkbltGraph.h +++ b/generic/tkbltGraph.h @@ -72,12 +72,12 @@ namespace Blt { } ClosestSearch; typedef struct { - short int width; - short int height; - short int axesOffset; - short int axesTitleLength; - short int maxTickWidth; - short int maxTickHeight; + int width; + int height; + int axesOffset; + int axesTitleLength; + int maxTickWidth; + int maxTickHeight; unsigned int nAxes; Chain* axes; int reqSize; @@ -147,16 +147,16 @@ namespace Blt { Postscript* postscript_; int inset_; - short int titleX_; - short int titleY_; - short int titleWidth_; - short int titleHeight_; + int titleX_; + int titleY_; + int titleWidth_; + int titleHeight_; int width_; int height_; - short int left_; - short int right_; - short int top_; - short int bottom_; + int left_; + int right_; + int top_; + int bottom_; Axis* focusPtr_; int halo_; GC drawGC_; @@ -164,11 +164,11 @@ namespace Blt { int hRange_; int vOffset_; int hOffset_; - float vScale_; - float hScale_; + double vScale_; + double hScale_; Pixmap cache_; - short int cacheWidth_; - short int cacheHeight_; + int cacheWidth_; + int cacheHeight_; protected: void layoutGraph(); @@ -239,7 +239,7 @@ namespace Blt { int getXY(const char*, int*, int*); void getTextExtents(Tk_Font, const char*, int, int*, int*); - void getBoundingBox(int, int, float, double*, double*, Point2d*); + void getBoundingBox(int, int, double, double*, double*, Point2d*); Point2d anchorPoint(double, double, double, double, Tk_Anchor); const char** getTags(ClientData, ClassId, int*); diff --git a/src/tkbltGraphBar.C b/generic/tkbltGraphBar.C index dc8664c..861c12a 100644 --- a/src/tkbltGraphBar.C +++ b/generic/tkbltGraphBar.C @@ -239,8 +239,8 @@ int BarGraph::configure() { BarGraphOptions* ops = (BarGraphOptions*)ops_; // Don't allow negative bar widths. Reset to an arbitrary value (0.1) - if (ops->barWidth <= 0.0f) - ops->barWidth = 0.9f; + if (ops->barWidth <= 0.0) + ops->barWidth = 0.9; return Graph::configure(); } @@ -445,10 +445,8 @@ void BarGraph::initBarSets() void BarGraph::destroyBarSets() { - if (barGroups_) { - delete [] barGroups_; - barGroups_ = NULL; - } + delete [] barGroups_; + barGroups_ = NULL; nBarGroups_ = 0; Tcl_HashSearch iter; diff --git a/src/tkbltGraphBar.h b/generic/tkbltGraphBar.h index 252c8d9..5ee1ab8 100644 --- a/src/tkbltGraphBar.h +++ b/generic/tkbltGraphBar.h @@ -47,9 +47,9 @@ namespace Blt { int nSegments; Axis* xAxis; Axis* yAxis; - float sum; + double sum; int count; - float lastY; + double lastY; size_t index; public: diff --git a/src/tkbltGraphLine.C b/generic/tkbltGraphLine.C index fe3f5d0..fe3f5d0 100644 --- a/src/tkbltGraphLine.C +++ b/generic/tkbltGraphLine.C diff --git a/src/tkbltGraphLine.h b/generic/tkbltGraphLine.h index ea8d2a0..ea8d2a0 100644 --- a/src/tkbltGraphLine.h +++ b/generic/tkbltGraphLine.h diff --git a/src/tkbltGraphOp.C b/generic/tkbltGraphOp.C index 9d4f45b..ada2758 100644 --- a/src/tkbltGraphOp.C +++ b/generic/tkbltGraphOp.C @@ -228,7 +228,13 @@ topmargin, bottommargin, plotarea, or legend", (char*)NULL); static int InsideOp(ClientData clientData, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { + if (objc != 4) { + Tcl_WrongNumArgs(interp, 2, objv, "x y"); + return TCL_ERROR; + } + Graph* graphPtr = (Graph*)clientData; + int x; if (Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK) return TCL_ERROR; @@ -294,8 +300,8 @@ static int TransformOp(ClientData clientData, Tcl_Interp* interp, int objc, Point2d point = graphPtr->map2D(x, y, xAxis, yAxis); Tcl_Obj* listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **)NULL); - Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewIntObj(point.x)); - Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewIntObj(point.y)); + Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewIntObj((int)point.x)); + Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewIntObj((int)point.y)); Tcl_SetObjResult(interp, listObjPtr); return TCL_OK; diff --git a/src/tkbltGraphOp.h b/generic/tkbltGraphOp.h index ff3f6ef..ff3f6ef 100644 --- a/src/tkbltGraphOp.h +++ b/generic/tkbltGraphOp.h diff --git a/src/tkbltGraphSup.C b/generic/tkbltGraphSup.C index 005f10c..d5eb3d1 100644 --- a/src/tkbltGraphSup.C +++ b/generic/tkbltGraphSup.C @@ -243,12 +243,12 @@ void Graph::layoutGraph() // Step 5 // If necessary, correct for the requested plot area aspect ratio. if ((ops->reqPlotWidth == 0) && (ops->reqPlotHeight == 0) && - (ops->aspect > 0.0f)) { - float ratio; + (ops->aspect > 0.0)) { + double ratio; // Shrink one dimension of the plotarea to fit the requested // width/height aspect ratio. - ratio = (float)plotWidth / (float)plotHeight; + ratio = plotWidth / plotHeight; if (ratio > ops->aspect) { // Shrink the width int scaledWidth = (int)(plotHeight * ops->aspect); @@ -372,8 +372,8 @@ void Graph::layoutGraph() if (hRange_ < 1) hRange_ = 1; - hScale_ = 1.0f / (float)hRange_; - vScale_ = 1.0f / (float)vRange_; + hScale_ = 1.0 / hRange_; + vScale_ = 1.0 / vRange_; // Calculate the placement of the graph title so it is centered within the // space provided for it in the top margin @@ -535,12 +535,12 @@ void Graph::getTextExtents(Tk_Font font, const char *text, int textLen, * *--------------------------------------------------------------------------- */ -void Graph::getBoundingBox(int width, int height, float angle, +void Graph::getBoundingBox(int width, int height, double angle, double *rotWidthPtr, double *rotHeightPtr, Point2d *bbox) { angle = fmod(angle, 360.0); - if (fmod(angle, (double)90.0) == 0.0) { + if (fmod(angle, 90.0) == 0.0) { int ll, ur, ul, lr; double rotWidth, rotHeight; diff --git a/src/tkbltInt.C b/generic/tkbltInt.C index 5e9dde7..5e9dde7 100644 --- a/src/tkbltInt.C +++ b/generic/tkbltInt.C diff --git a/generic/tkbltInt.h b/generic/tkbltInt.h new file mode 100644 index 0000000..2bf96ee --- /dev/null +++ b/generic/tkbltInt.h @@ -0,0 +1,58 @@ +/* + * Copyright 2017 Patzschke+Rasp Software GmbH + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __TKBLT_INT_H__ + +#if defined(_MSC_VER) + +#include <limits> + +#if !defined(NAN) +#define NAN (std::numeric_limits<double>::quiet_NaN()) +#endif + +#if !defined(isnan) +#define isnan(x) _isnan(x) +#endif + +#if !defined(isfinite) +#define isfinite(x) _finite(x) +#endif + +#if !defined(isinf) +#define isinf(x) !_finite(x) +#endif + +#if !defined(numeric_limits) +#define numeric_limits(x) _numeric_limits(x) +#endif + +#if _MSC_VER < 1900 +#define snprintf _snprintf +#else +#include <stdio.h> //sprintf +#endif + +#endif /* _MSC_VER */ + +#endif /* __TKBLT_INT_H__ */ diff --git a/src/tkbltNsUtil.C b/generic/tkbltNsUtil.C index f2ecfa3..f2ecfa3 100644 --- a/src/tkbltNsUtil.C +++ b/generic/tkbltNsUtil.C diff --git a/src/tkbltNsUtil.h b/generic/tkbltNsUtil.h index 950a48a..950a48a 100644 --- a/src/tkbltNsUtil.h +++ b/generic/tkbltNsUtil.h diff --git a/src/tkbltOp.C b/generic/tkbltOp.C index 4199a44..4199a44 100644 --- a/src/tkbltOp.C +++ b/generic/tkbltOp.C diff --git a/src/tkbltOp.h b/generic/tkbltOp.h index fc9ffb7..fc9ffb7 100644 --- a/src/tkbltOp.h +++ b/generic/tkbltOp.h diff --git a/src/tkbltParse.C b/generic/tkbltParse.C index 095b16a..095b16a 100644 --- a/src/tkbltParse.C +++ b/generic/tkbltParse.C diff --git a/src/tkbltParse.h b/generic/tkbltParse.h index ee215a5..ee215a5 100644 --- a/src/tkbltParse.h +++ b/generic/tkbltParse.h diff --git a/src/tkbltStubInit.c b/generic/tkbltStubInit.c index 8d28789..354b7f1 100644 --- a/src/tkbltStubInit.c +++ b/generic/tkbltStubInit.c @@ -1,4 +1,4 @@ -#include <tkbltVector.h> +#include "tkbltVector.h" /* !BEGIN!: Do not edit below this line. */ diff --git a/src/tkbltStubLib.C b/generic/tkbltStubLib.C index e973063..e973063 100644 --- a/src/tkbltStubLib.C +++ b/generic/tkbltStubLib.C diff --git a/src/tkbltSwitch.C b/generic/tkbltSwitch.C index bb80663..bb80663 100644 --- a/src/tkbltSwitch.C +++ b/generic/tkbltSwitch.C diff --git a/src/tkbltSwitch.h b/generic/tkbltSwitch.h index eed7b31..eed7b31 100644 --- a/src/tkbltSwitch.h +++ b/generic/tkbltSwitch.h diff --git a/src/tkbltVecCmd.C b/generic/tkbltVecCmd.C index d42dcda..feaddab 100644 --- a/src/tkbltVecCmd.C +++ b/generic/tkbltVecCmd.C @@ -161,8 +161,17 @@ static int Blt_ExprDoubleFromObj(Tcl_Interp* interp, Tcl_Obj *objPtr, if (Tcl_GetDoubleFromObj((Tcl_Interp *)NULL, objPtr, valuePtr) == TCL_OK) return TCL_OK; + // Interpret the empty string as NaN + int length; + char *string; + string = Tcl_GetStringFromObj(objPtr, &length); + if (length == 0) { + *valuePtr = NAN; + return TCL_OK; + } + // Then try to parse it as an expression. - if (Tcl_ExprDouble(interp, Tcl_GetString(objPtr), valuePtr) == TCL_OK) + if (Tcl_ExprDouble(interp, string, valuePtr) == TCL_OK) return TCL_OK; return TCL_ERROR; diff --git a/src/tkbltVecInt.h b/generic/tkbltVecInt.h index cc516a1..cc516a1 100644 --- a/src/tkbltVecInt.h +++ b/generic/tkbltVecInt.h diff --git a/src/tkbltVecMath.C b/generic/tkbltVecMath.C index 099f5f4..03277d4 100644 --- a/src/tkbltVecMath.C +++ b/generic/tkbltVecMath.C @@ -36,11 +36,14 @@ #include <stdlib.h> #include <errno.h> #include <ctype.h> +#include <cmath> +#include "tkbltInt.h" #include "tkbltVecInt.h" #include "tkbltNsUtil.h" #include "tkbltParse.h" +using namespace std; using namespace Blt; /* @@ -531,7 +534,7 @@ static void MathError(Tcl_Interp* interp, double value) Tcl_SetErrorCode(interp, "ARITH", "DOMAIN", Tcl_GetStringResult(interp), (char *)NULL); } - else if ((errno == ERANGE) || std::isinf(value)) { + else if ((errno == ERANGE) || isinf(value)) { if (value == 0.0) { Tcl_AppendResult(interp, "floating-point value too small to represent", @@ -1416,7 +1419,7 @@ static int EvaluateExpression(Tcl_Interp* interp, char *string, /* Check for NaN's and overflows. */ for (vp = vPtr->valueArr, vend = vp + vPtr->length; vp < vend; vp++) { - if (!std::isfinite(*vp)) { + if (!isfinite(*vp)) { /* * IEEE floating-point error. */ @@ -1441,7 +1444,7 @@ static int ComponentFunc(ClientData clientData, Tcl_Interp* interp, MathError(interp, *vp); return TCL_ERROR; } - if (!std::isfinite(*vp)) { + if (!isfinite(*vp)) { /* * IEEE floating-point error. */ @@ -1481,19 +1484,19 @@ static int VectorFunc(ClientData clientData, Tcl_Interp* interp, Vector *vPtr) static MathFunction mathFunctions[] = { {"abs", (void*)ComponentFunc, (ClientData)Fabs}, - {"acos", (void*)ComponentFunc, (ClientData)acos}, - {"asin", (void*)ComponentFunc, (ClientData)asin}, - {"atan", (void*)ComponentFunc, (ClientData)atan}, + {"acos", (void*)ComponentFunc, (ClientData)(double (*)(double))acos}, + {"asin", (void*)ComponentFunc, (ClientData)(double (*)(double))asin}, + {"atan", (void*)ComponentFunc, (ClientData)(double (*)(double))atan}, {"adev", (void*)ScalarFunc, (ClientData)AvgDeviation}, - {"ceil", (void*)ComponentFunc, (ClientData)ceil}, - {"cos", (void*)ComponentFunc, (ClientData)cos}, - {"cosh", (void*)ComponentFunc, (ClientData)cosh}, - {"exp", (void*)ComponentFunc, (ClientData)exp}, - {"floor", (void*)ComponentFunc, (ClientData)floor}, + {"ceil", (void*)ComponentFunc, (ClientData)(double (*)(double))ceil}, + {"cos", (void*)ComponentFunc, (ClientData)(double (*)(double))cos}, + {"cosh", (void*)ComponentFunc, (ClientData)(double (*)(double))cosh}, + {"exp", (void*)ComponentFunc, (ClientData)(double (*)(double))exp}, + {"floor", (void*)ComponentFunc, (ClientData)(double (*)(double))floor}, {"kurtosis",(void*)ScalarFunc, (ClientData)Kurtosis}, {"length", (void*)ScalarFunc, (ClientData)Length}, - {"log", (void*)ComponentFunc, (ClientData)log}, - {"log10", (void*)ComponentFunc, (ClientData)log10}, + {"log", (void*)ComponentFunc, (ClientData)(double (*)(double))log}, + {"log10", (void*)ComponentFunc, (ClientData)(double (*)(double))log10}, {"max", (void*)ScalarFunc, (ClientData)Blt_VecMax}, {"mean", (void*)ScalarFunc, (ClientData)Mean}, {"median", (void*)ScalarFunc, (ClientData)Median}, @@ -1506,14 +1509,14 @@ static MathFunction mathFunctions[] = {"random", (void*)ComponentFunc, (ClientData)drand48}, {"round", (void*)ComponentFunc, (ClientData)Round}, {"sdev", (void*)ScalarFunc, (ClientData)StdDeviation}, - {"sin", (void*)ComponentFunc, (ClientData)sin}, - {"sinh", (void*)ComponentFunc, (ClientData)sinh}, + {"sin", (void*)ComponentFunc, (ClientData)(double (*)(double))sin}, + {"sinh", (void*)ComponentFunc, (ClientData)(double (*)(double))sinh}, {"skew", (void*)ScalarFunc, (ClientData)Skew}, {"sort", (void*)VectorFunc, (ClientData)Sort}, - {"sqrt", (void*)ComponentFunc, (ClientData)sqrt}, + {"sqrt", (void*)ComponentFunc, (ClientData)(double (*)(double))sqrt}, {"sum", (void*)ScalarFunc, (ClientData)Sum}, - {"tan", (void*)ComponentFunc, (ClientData)tan}, - {"tanh", (void*)ComponentFunc, (ClientData)tanh}, + {"tan", (void*)ComponentFunc, (ClientData)(double (*)(double))tan}, + {"tanh", (void*)ComponentFunc, (ClientData)(double (*)(double))tanh}, {"var", (void*)ScalarFunc, (ClientData)Variance}, {(char *)NULL,}, }; diff --git a/src/tkbltVecOp.C b/generic/tkbltVecOp.C index 6c84723..6c84723 100644 --- a/src/tkbltVecOp.C +++ b/generic/tkbltVecOp.C diff --git a/src/tkbltVector.C b/generic/tkbltVector.C index e6262ec..0837917 100644 --- a/src/tkbltVector.C +++ b/generic/tkbltVector.C @@ -52,6 +52,7 @@ #include <cmath> +#include "tkbltInt.h" #include "tkbltVecInt.h" #include "tkbltNsUtil.h" #include "tkbltSwitch.h" @@ -91,7 +92,7 @@ typedef struct { } VectorClient; static Tcl_CmdDeleteProc VectorInstDeleteProc; -extern Tcl_ObjCmdProc VectorCmd; +extern Tcl_ObjCmdProc VectorObjCmd; static Tcl_InterpDeleteProc VectorInterpDeleteProc; typedef struct { @@ -1241,7 +1242,7 @@ VectorInterpData* Blt::Vec_GetInterpData(Tcl_Interp* interp) Tcl_InitHashTable(&dataPtr->indexProcTable, TCL_STRING_KEYS); Vec_InstallMathFunctions(&dataPtr->mathProcTable); Vec_InstallSpecialIndices(&dataPtr->indexProcTable); - srand48(time((time_t *) NULL)); + srand48((long)time((time_t *) NULL)); } return dataPtr; } diff --git a/src/tkbltVector.h b/generic/tkbltVector.h index e6ee3b3..45ddf6e 100644 --- a/src/tkbltVector.h +++ b/generic/tkbltVector.h @@ -35,6 +35,17 @@ #include <tcl.h> +#ifdef BUILD_tkblt +# define TKBLT_STORAGE_CLASS DLLEXPORT +#else +# ifdef USE_TCL_STUBS +# define TKBLT_STORAGE_CLASS /* */ +# else +# define TKBLT_STORAGE_CLASS DLLIMPORT +# endif +#endif + + typedef enum { BLT_VECTOR_NOTIFY_UPDATE = 1, /* The vector's values has been updated */ BLT_VECTOR_NOTIFY_DESTROY /* The vector has been destroyed and the client @@ -90,36 +101,36 @@ typedef enum { #ifdef __cplusplus extern "C" { #endif - int Blt_CreateVector(Tcl_Interp* interp, const char *vecName, - int size, Blt_Vector** vecPtrPtr); - int Blt_CreateVector2(Tcl_Interp* interp, const char *vecName, - const char *cmdName, const char *varName, - int initialSize, Blt_Vector **vecPtrPtr); - int Blt_DeleteVectorByName(Tcl_Interp* interp, const char *vecName); - int Blt_DeleteVector(Blt_Vector *vecPtr); - int Blt_GetVector(Tcl_Interp* interp, const char *vecName, - Blt_Vector **vecPtrPtr); - int Blt_GetVectorFromObj(Tcl_Interp* interp, Tcl_Obj *objPtr, + TKBLT_STORAGE_CLASS int Blt_CreateVector(Tcl_Interp* interp, const char *vecName, + int size, Blt_Vector** vecPtrPtr); + TKBLT_STORAGE_CLASS int Blt_CreateVector2(Tcl_Interp* interp, const char *vecName, + const char *cmdName, const char *varName, + int initialSize, Blt_Vector **vecPtrPtr); + TKBLT_STORAGE_CLASS int Blt_DeleteVectorByName(Tcl_Interp* interp, const char *vecName); + TKBLT_STORAGE_CLASS int Blt_DeleteVector(Blt_Vector *vecPtr); + TKBLT_STORAGE_CLASS int Blt_GetVector(Tcl_Interp* interp, const char *vecName, Blt_Vector **vecPtrPtr); - int Blt_ResetVector(Blt_Vector *vecPtr, double *dataArr, int n, - int arraySize, Tcl_FreeProc *freeProc); - int Blt_ResizeVector(Blt_Vector *vecPtr, int n); - int Blt_VectorExists(Tcl_Interp* interp, const char *vecName); - int Blt_VectorExists2(Tcl_Interp* interp, const char *vecName); - Blt_VectorId Blt_AllocVectorId(Tcl_Interp* interp, const char *vecName); - int Blt_GetVectorById(Tcl_Interp* interp, Blt_VectorId clientId, - Blt_Vector **vecPtrPtr); - void Blt_SetVectorChangedProc(Blt_VectorId clientId, - Blt_VectorChangedProc *proc, - ClientData clientData); - void Blt_FreeVectorId(Blt_VectorId clientId); - const char *Blt_NameOfVectorId(Blt_VectorId clientId); - const char *Blt_NameOfVector(Blt_Vector *vecPtr); - int Blt_ExprVector(Tcl_Interp* interp, char *expr, Blt_Vector *vecPtr); - void Blt_InstallIndexProc(Tcl_Interp* interp, const char *indexName, - Blt_VectorIndexProc * procPtr); - double Blt_VecMin(Blt_Vector *vPtr); - double Blt_VecMax(Blt_Vector *vPtr); + TKBLT_STORAGE_CLASS int Blt_GetVectorFromObj(Tcl_Interp* interp, Tcl_Obj *objPtr, + Blt_Vector **vecPtrPtr); + TKBLT_STORAGE_CLASS int Blt_ResetVector(Blt_Vector *vecPtr, double *dataArr, int n, + int arraySize, Tcl_FreeProc *freeProc); + TKBLT_STORAGE_CLASS int Blt_ResizeVector(Blt_Vector *vecPtr, int n); + TKBLT_STORAGE_CLASS int Blt_VectorExists(Tcl_Interp* interp, const char *vecName); + TKBLT_STORAGE_CLASS int Blt_VectorExists2(Tcl_Interp* interp, const char *vecName); + TKBLT_STORAGE_CLASS Blt_VectorId Blt_AllocVectorId(Tcl_Interp* interp, const char *vecName); + TKBLT_STORAGE_CLASS int Blt_GetVectorById(Tcl_Interp* interp, Blt_VectorId clientId, + Blt_Vector **vecPtrPtr); + TKBLT_STORAGE_CLASS void Blt_SetVectorChangedProc(Blt_VectorId clientId, + Blt_VectorChangedProc *proc, + ClientData clientData); + TKBLT_STORAGE_CLASS void Blt_FreeVectorId(Blt_VectorId clientId); + TKBLT_STORAGE_CLASS const char *Blt_NameOfVectorId(Blt_VectorId clientId); + TKBLT_STORAGE_CLASS const char *Blt_NameOfVector(Blt_Vector *vecPtr); + TKBLT_STORAGE_CLASS int Blt_ExprVector(Tcl_Interp* interp, char *expr, Blt_Vector *vecPtr); + TKBLT_STORAGE_CLASS void Blt_InstallIndexProc(Tcl_Interp* interp, const char *indexName, + Blt_VectorIndexProc * procPtr); + TKBLT_STORAGE_CLASS double Blt_VecMin(Blt_Vector *vPtr); + TKBLT_STORAGE_CLASS double Blt_VecMax(Blt_Vector *vPtr); #ifdef __cplusplus } #endif |