diff options
Diffstat (limited to 'app/tools')
26 files changed, 1784 insertions, 118 deletions
diff --git a/app/tools/CMakeLists.txt b/app/tools/CMakeLists.txt index befe170..433d464 100644 --- a/app/tools/CMakeLists.txt +++ b/app/tools/CMakeLists.txt @@ -1,15 +1,10 @@ -set ( sources listxtp.c ) +add_executable(listxtp listxtp.c) +set_target_properties(listxtp PROPERTIES FOLDER "Param Files") if (WIN32) - set ( sources - ${sources} - dirent.c) - - include_directories( before ${CMAKE_CURRENT_SOURCE_DIR}) + target_sources(listxtp PRIVATE dirent.c ) endif () - -add_executable( listxtp ${sources}) add_subdirectory(halibut) - +add_subdirectory(pngtoxpm) diff --git a/app/tools/HACKING b/app/tools/HACKING index fbed100..0b25ea1 100644 --- a/app/tools/HACKING +++ b/app/tools/HACKING @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ int global; /**< this is a global variable */ diff --git a/app/tools/TurnoutDesigner.xtr b/app/tools/TurnoutDesigner.xtr new file mode 100644 index 0000000..11e8c73 --- /dev/null +++ b/app/tools/TurnoutDesigner.xtr @@ -0,0 +1,918 @@ +# XTrackCAD Version: 5.3.0Beta1, Date: Fri May 27 12:14:43 2022 + +VERSION 12 +ROOMSIZE 96.0 x 48.0 +SCALE DEMO +ORIG 4.000 0.000 0.000 +# LOG CLOCK Thu May 26 16:02:31 2022 + +MESSAGE +Test Turnout Designer + +This demo invokes each Turnout Designer and generates the turnout definition. +Each definition is placed on the layout and Regression checks that each matches. + +Instructions: + Run xtrkcad with the regression option set to 2: + xtrkcad -d regression=2 + + Select the recording (Macro|Playback) from $(SRCDIR)/app/tools/TurnoutDesigner.xtr + + Playback the demo. You probably want to choose a faster playback Speed. + +Check the log file (Linux: stdout, Windows: xtclog.txt) +END$MESSAGE +STEP +PARAMETER grid horzspacing 12.000 +PARAMETER grid horzdivision 12 +PARAMETER grid horzenable 0 +PARAMETER grid vertspacing 12.000 +PARAMETER grid vertdivision 12 +PARAMETER grid vertenable 0 +PARAMETER grid origx 0.000 +PARAMETER grid origy 0.000 +PARAMETER grid origa 0.000 +PARAMETER grid show 0 +PARAMETER GROUP grid +PARAMETER easement val 0.000 +PARAMETER easement r 0.000 +PARAMETER easement x 0.000 +PARAMETER easement l 0.000 +PARAMETER GROUP easement +PARAMETER layout roomsizeX 96.000 +PARAMETER layout roomsizeY 48.000 +PARAMETER layout title1 Empty +PARAMETER layout title2 +PARAMETER layout mintrackradius 11.000 +PARAMETER layout maxtrackgrade 5.000 +PARAMETER layout backgroundposX 0.000 +PARAMETER layout backgroundposY 0.000 +PARAMETER layout backgroundWidth 0.000 +PARAMETER layout backgroundScreen 0 +PARAMETER layout backgroundAngle 0.000 +PARAMETER GROUP layout +PARAMETER display color-track 0 +PARAMETER display color-draw 0 +PARAMETER display tunnels 1 +PARAMETER display endpt 2 +PARAMETER display unconnected-endpt 0 +PARAMETER display tiedraw 0 +PARAMETER display centerdraw 0 +PARAMETER display tworailscale 16 +PARAMETER display mapscale 41 +PARAMETER display donthidecursor 0 +PARAMETER display constrainmain 0 +PARAMETER display livemap 0 +PARAMETER display autoPan 0 +PARAMETER display labelenable 0 +PARAMETER display labelscale 8 +PARAMETER display description-fontsize 72 +PARAMETER display hotbarlabels 1 +PARAMETER display layoutlabels 6 +PARAMETER display listlabels 7 +PARAMETER display carhotbarlabels 1 Proto/Manuf +PARAMETER display trainpause 300 +PARAMETER display hideTrainsInTunnels 0 +PARAMETER GROUP display +PARAMETER cmdopt preselect 1 +PARAMETER cmdopt rightclickmode 0 +PARAMETER cmdopt selectmode 0 +PARAMETER cmdopt selectzero 1 +PARAMETER GROUP cmdopt +PARAMETER pref iconsize 1 +PARAMETER pref anglesystem 0 +PARAMETER pref units 0 +PARAMETER pref dstfmt 1 +PARAMETER pref minlength 0.100 +PARAMETER pref connectdistance 0.100 +PARAMETER pref connectangle 1.000 +PARAMETER pref turntable-angle 15.000 +PARAMETER pref coupling-speed-max 100 +PARAMETER pref balloonhelp 1 +PARAMETER pref showflextrack 0 +PARAMETER pref dragpixels 20 +PARAMETER pref dragtimeout 500 +PARAMETER pref mingridspacing 5 +PARAMETER pref checkpoint 0 +PARAMETER pref autosave 0 +PARAMETER pref onstartup 0 +PARAMETER GROUP pref +PARAMETER rgbcolor snapgrid 65280 +PARAMETER rgbcolor marker 16711680 +PARAMETER rgbcolor border 0 +PARAMETER rgbcolor crossmajor 16711680 +PARAMETER rgbcolor crossminor 255 +PARAMETER rgbcolor normal 0 +PARAMETER rgbcolor selected 16711680 +PARAMETER rgbcolor profile 16711935 +PARAMETER rgbcolor exception 16711808 +PARAMETER rgbcolor tie 16744448 +#PARAMETER rgbcolor bridge 16777215 +#PARAMETER rgbcolor roadbed 12823467 +PARAMETER GROUP rgbcolor +PARAMETER misc toolbarset 65535 +PARAMETER misc cur-turnout-ep 0 +PARAMETER GROUP misc +PARAMETER sticky set 67108479 +PARAMETER GROUP sticky +LAYERS 0 1 0 1 255 0 0 0 0 "Main" 1 0 9.750000 0.000000 0.616800 0.100000 0.200000 +LAYERS 1 1 0 1 128 0 0 0 0 "Staging" 1 0 9.750000 0.000000 0.616800 0.100000 0.200000 +LAYERS 2 0 0 1 32768 0 0 0 0 "Switch Machines" 1 0 9.750000 0.000000 0.616800 0.100000 0.200000 +LAYERS 3 0 0 0 16776960 0 0 0 0 "Lighting and Ductwork" 1 0 9.750000 0.000000 0.616800 0.100000 0.200000 +LAYERS 4 0 0 1 65280 0 0 0 0 "" 1 0 9.750000 0.000000 0.616800 0.100000 0.200000 +LAYERS 5 1 0 1 65535 0 0 0 0 "Table Edges" 1 0 9.750000 0.000000 0.616800 0.100000 0.200000 +LAYERS 6 1 0 1 179456 0 0 0 0 "" 1 0 9.750000 0.000000 0.616800 0.100000 0.200000 +LAYERS 7 0 0 1 8388736 0 0 0 0 "Scenery Details" 1 0 9.750000 0.000000 0.616800 0.100000 0.200000 +LAYERS 8 0 0 1 8421376 0 0 0 0 "BenchWork" 1 0 9.750000 0.000000 0.616800 0.100000 0.200000 +LAYERS 9 1 0 1 16711935 0 0 0 0 "Body Circles" 1 0 9.750000 0.000000 0.616800 0.100000 0.200000 +LAYERS 10 0 0 1 255 0 0 0 0 "Old tracks" 1 0 9.750000 0.000000 0.616800 0.100000 0.200000 +LAYERS CURRENT 0 +REDRAW +RESET +CTURNOUT DESIGNER SHOW Regular Turnout +PARAMETER turnoutNew len0 0.000 +PARAMETER turnoutNew len1 0.000 +PARAMETER turnoutNew off0 0.000 +PARAMETER turnoutNew angle0 0.000 +PARAMETER turnoutNew manuf x +PARAMETER turnoutNew desc1 x +PARAMETER turnoutNew partno1 x +PARAMETER turnoutNew desc2 x +PARAMETER turnoutNew partno2 x +PARAMETER turnoutNew roadbedWidth 0.000 +PARAMETER turnoutNew roadbedLineWidth 0 +PARAMETER turnoutNew color 0 +PARAMETER turnoutNew angleMode 1 +PARAMETER GROUP turnoutNew +PARAMETER turnoutNew len0 5.000000 +PARAMETER turnoutNew angle0 6.000000 +PARAMETER turnoutNew angleMode 0 +PARAMETER turnoutNew off0 0.750000 +PARAMETER turnoutNew len1 6.000000 +PARAMETER turnoutNew manuf Turnout Designer +PARAMETER turnoutNew desc1 Regular Left +PARAMETER turnoutNew partno1 L +PARAMETER turnoutNew desc2 Regular Right +PARAMETER turnoutNew partno2 R +PARAMETER turnoutNew partno1 Reg L +PARAMETER turnoutNew partno2 Reg R +PARAMETER turnoutNew done +PARAMETER turnoutNew partno2 Reg R + +CTURNOUT DESIGNER SHOW Curved Turnout +PARAMETER turnoutNew len0 0.000 +PARAMETER turnoutNew len1 0.000 +PARAMETER turnoutNew off0 0.000 +PARAMETER turnoutNew off1 0.000 +PARAMETER turnoutNew angle0 0.000 +PARAMETER turnoutNew angle1 0.000 +PARAMETER turnoutNew manuf Turnout Designer +PARAMETER turnoutNew desc1 +PARAMETER turnoutNew partno1 +PARAMETER turnoutNew desc2 +PARAMETER turnoutNew partno2 +PARAMETER turnoutNew roadbedWidth 0.000 +PARAMETER turnoutNew roadbedLineWidth 0 +PARAMETER turnoutNew color 0 +PARAMETER turnoutNew angleMode 0 +PARAMETER GROUP turnoutNew +PARAMETER turnoutNew angle0 4.000000 +PARAMETER turnoutNew angle1 6.000000 +PARAMETER turnoutNew manuf Turnout Designer +PARAMETER turnoutNew desc1 Curved Left +PARAMETER turnoutNew partno1 Crv L +PARAMETER turnoutNew desc2 Curved Right +PARAMETER turnoutNew partno2 Crv R +PARAMETER turnoutNew len0 6.000000 +PARAMETER turnoutNew len1 7.000000 +PARAMETER turnoutNew off1 0.500000 +PARAMETER turnoutNew off0 1.000000 +PARAMETER turnoutNew done +PARAMETER turnoutNew off0 1.000000 + +CTURNOUT DESIGNER SHOW Cornu Curved Turnout +PARAMETER turnoutNew len0 0.000 +PARAMETER turnoutNew off0 0.000 +PARAMETER turnoutNew rad2 0.000 +PARAMETER turnoutNew angle0 0.000 +PARAMETER turnoutNew manuf Turnout Designer +PARAMETER turnoutNew desc1 +PARAMETER turnoutNew partno1 +PARAMETER turnoutNew desc2 +PARAMETER turnoutNew partno2 +PARAMETER turnoutNew roadbedWidth 0.000 +PARAMETER turnoutNew roadbedLineWidth 0 +PARAMETER turnoutNew color 0 +PARAMETER turnoutNew angleMode 1 +PARAMETER GROUP turnoutNew +PARAMETER turnoutNew len0 6.000 +PARAMETER turnoutNew angle0 14.500 +PARAMETER turnoutNew off0 1.100 +PARAMETER turnoutNew rad0 18.000 +PARAMETER turnoutNew len1 7.000 +PARAMETER turnoutNew angle1 9.6 +PARAMETER turnoutNew off1 0.770 +PARAMETER turnoutNew rad1 17.000 +PARAMETER turnoutNew toeL 0.500 +PARAMETER turnoutNew rad2 0.000 +PARAMETER turnoutNew desc1 Cornu Curved Left +PARAMETER turnoutNew partno1 Cor Crv L +PARAMETER turnoutNew desc2 Cornu Curved Right +PARAMETER turnoutNew partno2 Cor Crv R +PARAMETER turnoutNew done + +CTURNOUT DESIGNER SHOW Wye Turnout +PARAMETER turnoutNew len0 0.000 +PARAMETER turnoutNew len1 0.000 +PARAMETER turnoutNew off0 0.000 +PARAMETER turnoutNew off1 0.000 +PARAMETER turnoutNew angle0 0.000 +PARAMETER turnoutNew angle1 0.000 +PARAMETER turnoutNew manuf Turnout Designer +PARAMETER turnoutNew desc1 +PARAMETER turnoutNew partno1 +PARAMETER turnoutNew roadbedWidth 0.000 +PARAMETER turnoutNew roadbedLineWidth 0 +PARAMETER turnoutNew color 0 +PARAMETER turnoutNew angleMode 0 +PARAMETER GROUP turnoutNew +PARAMETER turnoutNew len0 5.000000 +PARAMETER turnoutNew off0 1.000000 +PARAMETER turnoutNew off1 1.000000 +PARAMETER turnoutNew len1 5.000000 +PARAMETER turnoutNew desc1 Wye +PARAMETER turnoutNew partno1 Wye +PARAMETER turnoutNew partno1 Wye +PARAMETER turnoutNew angle0 3.000000 +PARAMETER turnoutNew angle1 3.000000 +PARAMETER turnoutNew done +PARAMETER turnoutNew angle1 3.000000 + +CTURNOUT DESIGNER SHOW Cornu Wye Turnout +PARAMETER turnoutNew len0 0.000 +PARAMETER turnoutNew len1 0.000 +PARAMETER turnoutNew off0 0.000 +PARAMETER turnoutNew off1 0.000 +PARAMETER turnoutNew rad0 0.000 +PARAMETER turnoutNew rad1 0.000 +PARAMETER turnoutNew rad2 0.000 +PARAMETER turnoutNew toeL 0.000 +PARAMETER turnoutNew angle0 0.000 +PARAMETER turnoutNew angle1 0.000 +PARAMETER turnoutNew manuf Turnout Designer +PARAMETER turnoutNew desc1 +PARAMETER turnoutNew partno1 +PARAMETER turnoutNew roadbedWidth 0.000 +PARAMETER turnoutNew roadbedLineWidth 0 +PARAMETER turnoutNew color 0 +PARAMETER turnoutNew angleMode 1 +PARAMETER GROUP turnoutNew +PARAMETER turnoutNew len0 5.000 +PARAMETER turnoutNew angle0 19.500 +PARAMETER turnoutNew off0 1.000 +PARAMETER turnoutNew rad0 18.000 +PARAMETER turnoutNew len1 5.000 +PARAMETER turnoutNew angle1 19.500 +PARAMETER turnoutNew off1 1.000 +PARAMETER turnoutNew rad1 18.000 +PARAMETER turnoutNew toeL 0.354 +PARAMETER turnoutNew rad2 0.000 +PARAMETER turnoutNew desc1 Cornu Wye +PARAMETER turnoutNew partno1 Cor Wye +PARAMETER turnoutNew done +PARAMETER turnoutNew partno1 Cor Wye + +CTURNOUT DESIGNER SHOW 3-way Turnout +PARAMETER turnoutNew len0 0.000 +PARAMETER turnoutNew len1 0.000 +PARAMETER turnoutNew len2 0.000 +PARAMETER turnoutNew off0 0.000 +PARAMETER turnoutNew off1 0.000 +PARAMETER turnoutNew angle0 0.000 +PARAMETER turnoutNew angle1 0.000 +PARAMETER turnoutNew manuf Turnout Designer +PARAMETER turnoutNew desc1 +PARAMETER turnoutNew partno1 +PARAMETER turnoutNew roadbedWidth 0.000 +PARAMETER turnoutNew roadbedLineWidth 0 +PARAMETER turnoutNew color 0 +PARAMETER turnoutNew angleMode 0 +PARAMETER GROUP turnoutNew +PARAMETER turnoutNew len2 7.000000 +PARAMETER turnoutNew len0 6.000000 +PARAMETER turnoutNew angle0 3.000000 +PARAMETER turnoutNew off0 1.000000 +PARAMETER turnoutNew off1 1.000000 +PARAMETER turnoutNew angle1 3.000000 +PARAMETER turnoutNew len1 5.000000 +PARAMETER turnoutNew manuf Turnout Designer +PARAMETER turnoutNew desc1 3-Way +PARAMETER turnoutNew partno1 3 Way +PARAMETER turnoutNew len1 6.000000 +PARAMETER turnoutNew done +PARAMETER turnoutNew len1 6.000000 + +CTURNOUT DESIGNER SHOW Cornu 3-way Turnout +PARAMETER turnoutNew len0 0.000 +PARAMETER turnoutNew len1 0.000 +PARAMETER turnoutNew len3 0.000 +PARAMETER turnoutNew off0 0.000 +PARAMETER turnoutNew off1 0.000 +PARAMETER turnoutNew off3 0.000 +PARAMETER turnoutNew rad0 0.000 +PARAMETER turnoutNew rad1 0.000 +PARAMETER turnoutNew rad2 0.000 +PARAMETER turnoutNew rad3 0.000 +PARAMETER turnoutNew toeL 0.000 +PARAMETER turnoutNew toeR 0.000 +PARAMETER turnoutNew angle0 0.000 +PARAMETER turnoutNew angle1 0.000 +PARAMETER turnoutNew angle3 0.000 +PARAMETER turnoutNew manuf Turnout Designer +PARAMETER turnoutNew desc1 +PARAMETER turnoutNew partno1 +PARAMETER turnoutNew roadbedWidth 0.000 +PARAMETER turnoutNew roadbedLineWidth 0 +PARAMETER turnoutNew color 0 +PARAMETER turnoutNew angleMode 1 +PARAMETER GROUP turnoutNew +PARAMETER turnoutNew len0 5.000 +PARAMETER turnoutNew angle0 19.2 +PARAMETER turnoutNew off0 1.000 +PARAMETER turnoutNew rad0 18.000 +PARAMETER turnoutNew len1 5.000 +PARAMETER turnoutNew angle1 19.2 +PARAMETER turnoutNew off1 1.000 +PARAMETER turnoutNew rad1 18.000 +PARAMETER turnoutNew len3 6.000 +PARAMETER turnoutNew angle3 0.000 +PARAMETER turnoutNew off3 0.000 +PARAMETER turnoutNew rad3 0.000 +PARAMETER turnoutNew toeL 0.354 +PARAMETER turnoutNew rad2 0.000 +PARAMETER turnoutNew manuf Turnout Designer +PARAMETER turnoutNew desc1 Cornu 3-Way +PARAMETER turnoutNew manuf Turnout Designer +PARAMETER turnoutNew partno1 Cor 3 Way +PARAMETER turnoutNew done +PARAMETER turnoutNew partno1 Cor 3 Way + +CTURNOUT DESIGNER SHOW Crossing +PARAMETER turnoutNew len0 0.000 +PARAMETER turnoutNew len1 0.000 +PARAMETER turnoutNew angle0 0.000 +PARAMETER turnoutNew manuf Turnout Designer +PARAMETER turnoutNew desc1 +PARAMETER turnoutNew partno1 +PARAMETER turnoutNew roadbedWidth 0.000 +PARAMETER turnoutNew roadbedLineWidth 0 +PARAMETER turnoutNew color 0 +PARAMETER turnoutNew angleMode 0 +PARAMETER GROUP turnoutNew +PARAMETER turnoutNew len0 6.000000 +PARAMETER turnoutNew angle0 4.000000 +PARAMETER turnoutNew len1 5.000000 +PARAMETER turnoutNew desc1 Xing +PARAMETER turnoutNew partno1 Xing +PARAMETER turnoutNew desc1 Crossing +PARAMETER turnoutNew done +PARAMETER turnoutNew desc1 Crossing +CTURNOUT DESIGNER SHOW Single Slipswitch +PARAMETER turnoutNew len0 0.000 +PARAMETER turnoutNew len1 0.000 +PARAMETER turnoutNew angle0 0.000 +PARAMETER turnoutNew manuf Turnout Designer +PARAMETER turnoutNew desc1 +PARAMETER turnoutNew partno1 +PARAMETER turnoutNew roadbedWidth 0.000 +PARAMETER turnoutNew roadbedLineWidth 0 +PARAMETER turnoutNew color 0 +PARAMETER turnoutNew angleMode 0 +PARAMETER GROUP turnoutNew +PARAMETER turnoutNew len0 5.000000 +PARAMETER turnoutNew angle0 4.000000 +PARAMETER turnoutNew len1 6.000000 +PARAMETER turnoutNew desc1 Single Slip +PARAMETER turnoutNew partno1 S Slip +PARAMETER turnoutNew done +PARAMETER turnoutNew partno1 S Slip +CTURNOUT DESIGNER SHOW Double Slipswitch +PARAMETER turnoutNew len0 0.000 +PARAMETER turnoutNew len1 0.000 +PARAMETER turnoutNew angle0 0.000 +PARAMETER turnoutNew manuf Turnout Designer +PARAMETER turnoutNew desc1 +PARAMETER turnoutNew partno1 +PARAMETER turnoutNew roadbedWidth 0.000 +PARAMETER turnoutNew roadbedLineWidth 0 +PARAMETER turnoutNew color 0 +PARAMETER turnoutNew angleMode 0 +PARAMETER turnoutNew slipMode 1 +PARAMETER GROUP turnoutNew +PARAMETER turnoutNew angle0 4.000000 +PARAMETER turnoutNew len1 5.000000 +PARAMETER turnoutNew len0 6.000000 +PARAMETER turnoutNew desc1 Double Slip +PARAMETER turnoutNew partno1 D Slip +PARAMETER turnoutNew done +PARAMETER turnoutNew partno1 D Slip +CTURNOUT DESIGNER SHOW Right Crossover +PARAMETER turnoutNew len0 0.000 +PARAMETER turnoutNew off0 0.000 +PARAMETER turnoutNew manuf Turnout Designer +PARAMETER turnoutNew desc1 +PARAMETER turnoutNew partno1 +PARAMETER turnoutNew roadbedWidth 0.000 +PARAMETER turnoutNew roadbedLineWidth 0 +PARAMETER turnoutNew color 0 +PARAMETER GROUP turnoutNew +PARAMETER turnoutNew len0 7.000000 +PARAMETER turnoutNew off0 1.500000 +PARAMETER turnoutNew desc1 Right Crossover +PARAMETER turnoutNew partno1 Xovr R +PARAMETER turnoutNew done +PARAMETER turnoutNew partno1 Xovr R +CTURNOUT DESIGNER SHOW Left Crossover +PARAMETER turnoutNew len0 0.000 +PARAMETER turnoutNew off0 0.000 +PARAMETER turnoutNew manuf Turnout Designer +PARAMETER turnoutNew desc1 +PARAMETER turnoutNew partno1 +PARAMETER turnoutNew roadbedWidth 0.000 +PARAMETER turnoutNew roadbedLineWidth 0 +PARAMETER turnoutNew color 0 +PARAMETER GROUP turnoutNew +PARAMETER turnoutNew len0 7.000000 +PARAMETER turnoutNew off0 1.500000 +PARAMETER turnoutNew desc1 Left Crossover +PARAMETER turnoutNew partno1 Xovr L +PARAMETER turnoutNew done +PARAMETER turnoutNew partno1 Xovr L +CTURNOUT DESIGNER SHOW Double Crossover +PARAMETER turnoutNew len0 0.000 +PARAMETER turnoutNew off0 0.000 +PARAMETER turnoutNew manuf Turnout Designer +PARAMETER turnoutNew desc1 +PARAMETER turnoutNew partno1 +PARAMETER turnoutNew roadbedWidth 0.000 +PARAMETER turnoutNew roadbedLineWidth 0 +PARAMETER turnoutNew color 0 +PARAMETER GROUP turnoutNew +PARAMETER turnoutNew len0 7.000000 +PARAMETER turnoutNew off0 1.500000 +PARAMETER turnoutNew desc1 Double Crossover +PARAMETER turnoutNew partno1 Xovr D +PARAMETER turnoutNew done +PARAMETER turnoutNew partno1 Xovr D +CTURNOUT DESIGNER SHOW Straight Section +PARAMETER turnoutNew len0 0.000 +PARAMETER turnoutNew manuf Turnout Designer +PARAMETER turnoutNew desc1 +PARAMETER turnoutNew partno1 +PARAMETER turnoutNew roadbedWidth 0.000 +PARAMETER turnoutNew roadbedLineWidth 0 +PARAMETER turnoutNew color 0 +PARAMETER GROUP turnoutNew +PARAMETER turnoutNew len0 6.000000 +PARAMETER turnoutNew desc1 Straight +PARAMETER turnoutNew partno1 Str +PARAMETER turnoutNew done +PARAMETER turnoutNew partno1 Str +CTURNOUT DESIGNER SHOW Curved Section +PARAMETER turnoutNew len0 0.000 +PARAMETER turnoutNew angle0 0.000 +PARAMETER turnoutNew manuf Turnout Designer +PARAMETER turnoutNew desc1 +PARAMETER turnoutNew partno1 +PARAMETER turnoutNew roadbedWidth 0.000 +PARAMETER turnoutNew roadbedLineWidth 0 +PARAMETER turnoutNew color 0 +PARAMETER GROUP turnoutNew +PARAMETER turnoutNew len0 15.000000 +PARAMETER turnoutNew angle0 15.000000 +PARAMETER turnoutNew desc1 Curved +PARAMETER turnoutNew partno1 Crv +PARAMETER turnoutNew done +PARAMETER turnoutNew partno1 Crv +MESSAGE +----------------------------------------------------- + +Create an instance of each turnout +END$MESSAGE +STEP + +HOTBARSELECT Turnout Designer Regular Left Reg L +MOUSE 2 1.000 1.000 +MOUSE 4 1.000 1.000 +MOUSE 3336 1.000 1.000 + +HOTBARSELECT Turnout Designer Regular Right Reg R +MOUSE 2 1.000 3.000 +MOUSE 4 1.000 3.000 +MOUSE 3336 1.000 3.000 + +HOTBARSELECT Turnout Designer Curved Left Crv L +MOUSE 2 1.000 4.500 +MOUSE 4 1.000 4.500 +MOUSE 3336 1.000 4.500 + +HOTBARSELECT Turnout Designer Curved Right Crv R +MOUSE 2 1.000 7.500 +MOUSE 4 1.000 7.500 +MOUSE 3336 1.000 7.500 + +HOTBARSELECT Turnout Designer Cornu Curved Left Cor Crv L +MOUSE 2 1.000 9.500 +MOUSE 4 1.000 9.500 +MOUSE 3336 1.000 9.500 + +HOTBARSELECT Turnout Designer Cornu Curved Right Cor Crv R +MOUSE 2 1.000 12.000 +MOUSE 4 1.000 12.000 +MOUSE 3336 1.000 12.000 + +HOTBARSELECT Turnout Designer Wye Wye +MOUSE 2 9.500 1.000 +MOUSE 4 9.500 1.000 +MOUSE 3336 9.500 1.000 + +HOTBARSELECT Turnout Designer Cornu Wye Cor Wye +MOUSE 2 9.500 3.000 +MOUSE 4 9.500 3.000 +MOUSE 3336 9.500 3.000 + +HOTBARSELECT Turnout Designer 3-Way 3 Way +MOUSE 2 9.500 5.000 +MOUSE 4 9.500 5.000 +MOUSE 3336 9.500 3.000 + +HOTBARSELECT Turnout Designer Cornu 3-Way Cor 3 Way +MOUSE 2 9.500 7.000 +MOUSE 4 9.500 7.000 +MOUSE 3336 9.500 7.000 + +HOTBARSELECT Turnout Designer Crossing Xing +MOUSE 2 9.500 9.000 +MOUSE 4 9.500 9.000 +MOUSE 3336 9.500 9.000 + +HOTBARSELECT Turnout Designer Single Slip S Slip +MOUSE 2 9.500 11.000 +MOUSE 4 9.500 11.000 +MOUSE 3336 9.500 11.000 + +HOTBARSELECT Turnout Designer Double Slip D Slip +MOUSE 2 9.500 13.000 +MOUSE 4 9.500 13.000 +MOUSE 3336 9.500 13.000 + +HOTBARSELECT Turnout Designer Right Crossover Xovr R +MOUSE 2 18.000 1.000 +MOUSE 4 18.000 1.000 +MOUSE 3336 18.000 1.000 + +HOTBARSELECT Turnout Designer Left Crossover Xovr L +MOUSE 2 18.000 4.000 +MOUSE 4 18.000 4.000 +MOUSE 3336 18.000 4.000 + +HOTBARSELECT Turnout Designer Double Crossover Xovr D +MOUSE 2 18.000 7.000 +MOUSE 4 18.000 7.000 +MOUSE 3336 18.000 7.000 + +HOTBARSELECT Turnout Designer Straight Str +MOUSE 2 18.000 10.000 +MOUSE 4 18.000 10.000 +MOUSE 3336 18.000 10.000 + +HOTBARSELECT Turnout Designer Curved Crv +MOUSE 2 18.000 12.000 +MOUSE 4 18.000 12.000 +MOUSE 3336 18.000 12.000 + +MESSAGE +----------------------------------------------------- + +Run Regression Checks +END$MESSAGE +STEP +REGRESSION START 12 Turnout Designer Test Case +TURNOUT 1 0 0 0 0 DEMO 2 1.000000 1.000000 0 0.000000 "Turnout Designer Regular Left Reg L" + E4 1.000000 1.000000 270.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 7.000000 1.000000 90.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 6.000000 1.750000 80.405932 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + D 0.000000 0.000000 + P "Normal" 1 2 + P "Reverse" 1 3 4 + S 0 0.000000 0.000000 0.000000 0.354300 0.000000 + S 0 0.000000 0.354300 0.000000 6.000000 0.000000 + C 0 0.000000 -2.486173 0.354300 2.486173 170.405932 9.594068 + S 0 0.000000 0.768662 0.034773 5.000000 0.750000 + END$SEGS +TURNOUT 2 0 0 0 0 DEMO 2 1.000000 3.000000 0 0.000000 "Turnout Designer Regular Right Reg R" + E4 1.000000 3.000000 270.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 7.000000 3.000000 90.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 6.000000 2.250000 99.594068 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + D 0.000000 0.000000 + P "Normal" 1 2 + P "Reverse" 1 3 4 + S 0 0.000000 0.000000 0.000000 0.354300 -0.000000 + S 0 0.000000 0.354300 -0.000000 6.000000 0.000000 + C 0 0.000000 2.486173 0.354300 -2.486173 0.000000 9.594068 + S 0 0.000000 0.768662 -0.034773 5.000000 -0.750000 + END$SEGS +TURNOUT 3 0 0 0 0 DEMO 2 1.000000 4.500000 0 0.000000 "Turnout Designer Curved Left Crv L" + E4 1.000000 4.500000 270.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 8.000000 5.000000 80.405932 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 7.000000 5.500000 75.522488 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + D 0.000000 0.000000 + P "Normal" 1 6 4 5 + P "Reverse" 1 2 3 + S 0 0.000000 0.000000 0.000000 0.354300 0.000000 + C 0 0.000000 -13.956569 0.354300 13.956569 165.522488 14.477512 + S 0 0.000000 3.843442 0.443179 6.000000 1.000000 + C 0 0.000000 -31.526372 1.396260 31.526372 170.405932 9.594068 + S 0 0.000000 6.650655 0.440950 7.000000 0.500000 + S 0 0.000000 0.354300 0.000000 1.396260 0.000000 + END$SEGS +TURNOUT 4 0 0 0 0 DEMO 2 1.000000 7.500000 0 0.000000 "Turnout Designer Curved Right Crv R" + E4 1.000000 7.500000 270.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 8.000000 7.000000 99.594068 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 7.000000 6.500000 104.477512 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + D 0.000000 0.000000 + P "Normal" 1 6 4 5 + P "Reverse" 1 2 3 + S 0 0.000000 0.000000 0.000000 0.354300 -0.000000 + C 0 0.000000 13.956569 0.354300 -13.956569 0.000000 14.477512 + S 0 0.000000 3.843442 -0.443179 6.000000 -1.000000 + C 0 0.000000 31.526372 1.396260 -31.526372 0.000000 9.594068 + S 0 0.000000 6.650655 -0.440950 7.000000 -0.500000 + S 0 0.000000 0.354300 -0.000000 1.396260 -0.000000 + END$SEGS +TURNOUT 5 0 0 0 0 DEMO 2 1.000000 9.500000 0 0.000000 "Turnout Designer Cornu Curved Left Cor Crv L" + E4 1.000000 9.500000 270.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 8.000000 10.270000 80.400000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 7.000000 10.600000 75.500000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + D 0.000000 0.000000 + P "Normal" 1 2 3 4 + P "Reverse" 1 5 6 7 8 + S 0 0.000000 0.000000 0.000000 0.499980 0.001608 + C 0 0.000000 -23.557999 -0.084688 23.552351 170.856688 7.721184 + S 0 0.000000 3.658782 0.293681 6.802609 0.737807 + C 0 0.000000 -17.000000 4.164931 17.531933 170.400000 0.674068 + C 0 0.000000 -10.187780 0.450483 10.189268 172.093896 7.627733 + C 0 0.000000 -12.230134 -0.027711 12.183174 164.805564 6.354200 + S 0 0.000000 3.177751 0.380581 5.806096 1.051001 + C 0 0.000000 -18.000000 1.493160 18.526658 165.500000 0.636620 + END$SEGS +TURNOUT 6 0 0 0 0 DEMO 2 1.000000 12.000000 0 0.000000 "Turnout Designer Cornu Curved Right Cor Crv R" + E4 1.000000 12.000000 270.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 8.000000 11.230000 99.600000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 7.000000 10.900000 104.500000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + D 0.000000 0.000000 + P "Normal" 1 2 3 4 + P "Reverse" 1 5 6 7 8 + S 0 0.000000 0.000000 0.000000 0.499980 -0.001608 + C 0 0.000000 23.557999 -0.084688 -23.552351 1.422128 7.721184 + S 0 0.000000 3.658782 -0.293681 6.802609 -0.737807 + C 0 0.000000 17.000000 4.164931 -17.531933 8.925932 0.674068 + C 0 0.000000 10.187780 0.450483 -10.189268 0.278371 7.627733 + C 0 0.000000 12.230134 -0.027711 -12.183174 8.840236 6.354200 + S 0 0.000000 3.177751 -0.380581 5.806096 -1.051001 + C 0 0.000000 18.000000 1.493160 -18.526658 13.863380 0.636620 + END$SEGS +TURNOUT 7 0 0 0 0 DEMO 2 9.500000 1.000000 0 0.000000 "Turnout Designer Wye Wye" + E4 9.500000 1.000000 270.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 14.500000 2.000000 70.528779 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 14.500000 0.000000 109.471221 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + D 0.000000 0.000000 + P "Left" 1 2 3 + P "Right" 1 4 5 + S 0 0.000000 0.000000 0.000000 0.354300 0.000000 + C 0 0.000000 -10.591843 0.354300 10.591843 160.528779 19.471221 + S 0 0.000000 3.884914 0.605758 5.000000 1.000000 + C 0 0.000000 10.591843 0.354300 -10.591843 0.000000 19.471221 + S 0 0.000000 3.884914 -0.605758 5.000000 -1.000000 + END$SEGS +TURNOUT 8 0 0 0 0 DEMO 2 9.500000 3.000000 0 0.000000 "Turnout Designer Cornu Wye Cor Wye" + E4 9.500000 3.000000 270.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 14.500000 4.000000 70.500000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 14.500000 2.000000 109.500000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + D 0.000000 0.000000 + P "Left" 1 2 3 4 5 6 + P "Right" 1 2 7 8 9 10 + S 0 0.000000 0.000000 0.000000 0.200000 0.000000 + S 0 0.000000 0.200000 0.000000 0.354000 0.000000 + C 0 0.000000 -11.721160 0.500050 11.720250 175.110495 5.603451 + C 0 0.000000 -7.987944 0.693119 7.988923 165.986563 8.222483 + C 0 0.000000 -20.842358 -2.596956 20.415677 159.180018 6.303393 + C 0 0.000000 -18.000000 -1.008523 17.967547 160.500000 0.636620 + C 0 0.000000 10.805495 0.496564 -10.804555 359.244037 6.074250 + C 0 0.000000 7.902213 0.624248 -7.899322 6.348994 8.306227 + C 0 0.000000 29.327974 -4.982624 -28.578689 15.031369 4.476610 + C 0 0.000000 18.000000 -1.008523 -17.967547 18.863380 0.636620 + END$SEGS +TURNOUT 9 0 0 0 0 DEMO 2 9.500000 5.000000 0 0.000000 "Turnout Designer 3-Way 3 Way" + E4 9.500000 5.000000 270.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 15.500000 6.000000 70.528779 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 15.500000 4.000000 109.471221 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 16.500000 5.000000 90.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + D 0.000000 0.000000 + P "Left" 1 2 3 + P "Normal" 1 6 + P "Right" 1 4 5 + S 0 0.000000 0.000000 0.000000 0.525873 0.000000 + C 0 0.000000 -15.420270 0.525873 15.420270 160.528779 19.471221 + S 0 0.000000 5.665963 0.881900 6.000000 1.000000 + C 0 0.000000 15.420270 0.525873 -15.420270 0.000000 19.471221 + S 0 0.000000 5.665963 -0.881900 6.000000 -1.000000 + S 0 0.000000 0.525873 0.000000 7.000000 0.000000 + END$SEGS +TURNOUT 10 0 0 0 0 DEMO 2 9.500000 7.000000 0 0.000000 "Turnout Designer Cornu 3-Way Cor 3 Way" + E4 9.500000 7.000000 270.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 14.500000 8.000000 70.800000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 14.500000 6.000000 109.200000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 15.500000 7.000000 90.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + D 0.000000 0.000000 + P "Normal" 1 2 3 4 5 + P "Left" 1 2 3 6 7 8 9 + P "Right" 1 2 10 11 12 13 + S 0 0.000000 0.000000 0.000000 0.200000 0.000000 + S 0 0.000000 0.200000 0.000000 0.000000 0.000000 + S 0 0.000000 0.000000 0.000000 0.354000 0.000000 + S 0 0.000000 0.354000 0.000000 5.800000 0.000000 + S 0 0.000000 5.800000 0.000000 6.000000 0.000000 + C 0 0.000000 -11.463991 0.499120 11.463072 174.997261 5.728053 + C 0 0.000000 -7.957029 0.675689 7.957092 165.809447 8.252862 + C 0 0.000000 -22.458410 -3.058640 21.969836 159.488282 5.848707 + C 0 0.000000 -18.000000 -0.919600 17.998775 160.800000 0.636620 + C 0 0.000000 13.194589 0.155392 -13.193674 359.325214 5.350882 + C 0 0.000000 9.251876 0.335646 -9.251448 5.553830 7.631375 + C 0 0.000000 25.329956 -3.475308 -24.871603 13.518938 5.575451 + C 0 0.000000 18.000000 -0.919600 -17.998775 18.563380 0.636620 + END$SEGS +TURNOUT 11 0 0 0 0 DEMO 2 9.500000 9.000000 0 0.000000 "Turnout Designer Crossing Xing" + E4 9.500000 9.000000 270.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 15.500000 9.000000 90.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 10.079385 9.625000 284.477512 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 14.920615 8.375000 104.477512 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + D 0.000000 0.000000 + P "Normal" 1 0 2 + S 0 0.000000 0.000000 0.000000 6.000000 0.000000 + S 0 0.000000 0.579385 0.625000 5.420615 -0.625000 + END$SEGS +TURNOUT 12 0 0 0 0 DEMO 2 9.500000 11.000000 0 0.000000 "Turnout Designer Single Slip S Slip" + E4 9.500000 11.000000 270.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 14.500000 11.000000 90.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 9.095262 11.750000 284.477512 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 14.904738 10.250000 104.477512 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + D 0.000000 0.000000 + P "Normal" 1 2 0 3 4 + P "Reverse" 1 5 4 + S 0 0.000000 0.000000 0.000000 0.354300 0.000000 + S 0 0.000000 0.354300 0.000000 5.000000 0.000000 + S 0 0.000000 -0.404738 0.750000 4.577565 -0.536425 + S 0 0.000000 4.577565 -0.536425 5.404738 -0.750000 + C 0 0.000000 16.893060 0.354300 -16.893060 0.000000 14.477512 + END$SEGS +TURNOUT 13 0 512 0 0 DEMO 2 9.500000 13.000000 0 0.000000 "Turnout Designer Double Slip D Slip" + E4 9.500000 13.000000 270.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 15.500000 13.000000 90.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 10.079385 13.625000 284.477512 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 14.920615 12.375000 104.477512 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + D 0.000000 0.000000 + P "Cross1" 1 2 3 + P "Cross2" 4 5 6 + P "Slip1" 1 7 6 + P "Slip2" 4 8 3 + S 0 0.000000 0.000000 0.000000 1.208600 0.000000 + S 0 0.000000 1.208600 0.000000 4.791400 0.000000 + S 0 0.000000 4.791400 0.000000 6.000000 0.000000 + S 0 0.000000 0.579385 0.625000 1.265484 0.447850 + S 0 0.000000 1.265484 0.447850 4.734516 -0.447850 + S 0 0.000000 4.734516 -0.447850 5.420615 -0.625000 + C 0 0.000000 14.103662 1.208600 -14.103662 0.000000 14.477512 + C 0 0.000000 -14.103662 4.791400 14.103662 180.000000 14.477512 + END$SEGS +TURNOUT 14 0 0 0 0 DEMO 2 18.000000 1.000000 0 0.000000 "Turnout Designer Right Crossover Xovr R" + E4 18.000000 1.000000 270.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 25.000000 1.000000 90.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 18.000000 2.500000 270.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 25.000000 2.500000 90.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + D 0.000000 0.000000 + P "Normal" 1 2 0 3 4 + P "Reverse" 3 5 6 7 2 + S 0 0.000000 0.000000 0.000000 6.461065 0.000000 + S 0 0.000000 6.461065 0.000000 7.000000 0.000000 + S 0 0.000000 0.000000 1.500000 0.538935 1.500000 + S 0 0.000000 0.538935 1.500000 7.000000 1.500000 + C 0 0.000000 6.136583 0.538935 -4.636583 0.000000 25.493739 + S 0 0.000000 3.180197 0.902495 3.819803 0.597505 + C 0 0.000000 -6.136583 6.461065 6.136583 180.000000 25.493739 + END$SEGS +TURNOUT 15 0 0 0 0 DEMO 2 18.000000 4.000000 0 0.000000 "Turnout Designer Left Crossover Xovr L" + E4 18.000000 4.000000 270.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 25.000000 4.000000 90.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 18.000000 5.500000 270.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 25.000000 5.500000 90.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + D 0.000000 0.000000 + P "Normal" 1 2 0 3 4 + P "Reverse" 1 5 6 7 4 + S 0 0.000000 0.000000 0.000000 0.538935 0.000000 + S 0 0.000000 0.538935 0.000000 7.000000 0.000000 + S 0 0.000000 0.000000 1.500000 6.461065 1.500000 + S 0 0.000000 6.461065 1.500000 7.000000 1.500000 + C 0 0.000000 -6.136583 0.538935 6.136583 154.506261 25.493739 + S 0 0.000000 3.180197 0.597505 3.819803 0.902495 + C 0 0.000000 6.136583 6.461065 -4.636583 334.506261 25.493739 + END$SEGS +TURNOUT 16 0 0 0 0 DEMO 2 18.000000 7.000000 0 0.000000 "Turnout Designer Double Crossover Xovr D" + E4 18.000000 7.000000 270.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 25.000000 7.000000 90.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 18.000000 8.500000 270.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 25.000000 8.500000 90.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + D 0.000000 0.000000 + P "Normal" 1 2 3 0 4 5 6 + P "Reverse" 1 7 8 9 6 0 4 10 11 12 3 + S 0 0.000000 0.000000 0.000000 0.538935 0.000000 + S 0 0.000000 0.538935 0.000000 6.461065 0.000000 + S 0 0.000000 6.461065 0.000000 7.000000 0.000000 + S 0 0.000000 0.000000 1.500000 0.538935 1.500000 + S 0 0.000000 0.538935 1.500000 6.461065 1.500000 + S 0 0.000000 6.461065 1.500000 7.000000 1.500000 + C 0 0.000000 -6.136583 0.538935 6.136583 154.506261 25.493739 + S 0 0.000000 3.180197 0.597505 3.819803 0.902495 + C 0 0.000000 6.136583 6.461065 -4.636583 334.506261 25.493739 + C 0 0.000000 6.136583 0.538935 -4.636583 0.000000 25.493739 + S 0 0.000000 3.180197 0.902495 3.819803 0.597505 + C 0 0.000000 -6.136583 6.461065 6.136583 180.000000 25.493739 + END$SEGS +TURNOUT 17 0 0 0 0 DEMO 2 18.000000 10.000000 0 0.000000 "Turnout Designer Straight Str" + E4 18.000000 10.000000 270.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 24.000000 10.000000 90.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + D 0.000000 0.000000 + P "Normal" 1 + S 0 0.000000 0.000000 0.000000 6.000000 0.000000 + END$SEGS +TURNOUT 18 0 0 0 0 DEMO 2 18.000000 12.000000 0 0.000000 "Turnout Designer Curved Crv" + E4 18.000000 12.000000 270.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + E4 21.882286 12.511113 75.000000 0 0.0 0.0 0.0 0.0 0 0 0 0.000000 + D 0.000000 0.000000 + P "Normal" 1 + C 0 0.000000 -15.000000 0.000000 15.000000 165.000000 15.000000 + END$SEGS +REGRESSION END + +MESSAGE +----------------------------------------------------- + +Remove the parameter definitions +END$MESSAGE +STEP + +PARAMETER misc cmdCustmgm +PARAMETER custmgm inx 0 Turnout Designer DEMO Reg L Regular Left +PARAMETER custmgm delete +PARAMETER custmgm inx 0 Turnout Designer DEMO Reg R Regular Right +PARAMETER custmgm delete +PARAMETER custmgm inx 0 Turnout Designer DEMO Crv L Curved Left +PARAMETER custmgm delete +PARAMETER custmgm inx 0 Turnout Designer DEMO Crv R Curved Right +PARAMETER custmgm delete +PARAMETER custmgm inx 0 Turnout Designer DEMO Cor Crv L Cornu Curved Left +PARAMETER custmgm delete +PARAMETER custmgm inx 0 Turnout Designer DEMO Cor Crv R Cornu Curved Right +PARAMETER custmgm delete +PARAMETER custmgm inx 0 Turnout Designer DEMO Wye Wye +PARAMETER custmgm delete +PARAMETER custmgm inx 0 Turnout Designer DEMO Cor Wye Cornu Wye +PARAMETER custmgm delete +PARAMETER custmgm inx 0 Turnout Designer DEMO 3 Way 3-Way +PARAMETER custmgm delete +PARAMETER custmgm inx 0 Turnout Designer DEMO Cor 3 Way Cornu 3-Way +PARAMETER custmgm delete +PARAMETER custmgm inx 0 Turnout Designer DEMO Xing Crossing +PARAMETER custmgm delete +PARAMETER custmgm inx 0 Turnout Designer DEMO S Slip Single Slip +PARAMETER custmgm delete +PARAMETER custmgm inx 0 Turnout Designer DEMO D Slip Double Slip +PARAMETER custmgm delete +PARAMETER custmgm inx 0 Turnout Designer DEMO Xovr R Right Crossover +PARAMETER custmgm delete +PARAMETER custmgm inx 0 Turnout Designer DEMO Xovr L Left Crossover +PARAMETER custmgm delete +PARAMETER custmgm inx 0 Turnout Designer DEMO Xovr D Double Crossover +PARAMETER custmgm delete +PARAMETER custmgm inx 0 Turnout Designer DEMO Str Straight +PARAMETER custmgm delete +PARAMETER custmgm inx 0 Turnout Designer DEMO Crv Curved +PARAMETER custmgm delete +PARAMETER custmgm ok + +MESSAGE +----------------------------------------------------- + +End of Playback. Hit Step to exit +END$MESSAGE +STEP diff --git a/app/tools/dirent.c b/app/tools/dirent.c index 08ea800..bf6e7ff 100644 --- a/app/tools/dirent.c +++ b/app/tools/dirent.c @@ -21,7 +21,7 @@ extern "C" struct DIR { - long handle; /* -1 for failed rewind */ + intptr_t handle; /* -1 for failed rewind */ struct _finddata_t info; struct dirent result; /* d_name null iff first time */ char *name; /* null-terminated char string */ @@ -42,7 +42,7 @@ DIR *opendir(const char *name) { strcat(strcpy(dir->name, name), all); - if((dir->handle = (long) _findfirst(dir->name, &dir->info)) != -1) + if((dir->handle = _findfirst(dir->name, &dir->info)) != -1) { dir->result.d_name = 0; } @@ -116,7 +116,7 @@ void rewinddir(DIR *dir) if(dir && dir->handle != -1) { _findclose(dir->handle); - dir->handle = (long) _findfirst(dir->name, &dir->info); + dir->handle = _findfirst(dir->name, &dir->info); dir->result.d_name = 0; } else diff --git a/app/tools/halibut/CMakeLists.txt b/app/tools/halibut/CMakeLists.txt index ec7d74b..a4ddc75 100644 --- a/app/tools/halibut/CMakeLists.txt +++ b/app/tools/halibut/CMakeLists.txt @@ -1,4 +1,5 @@ -SET(SOURCES + +add_executable(halibut biblio.c bk_html.c contents.c @@ -22,11 +23,13 @@ SET(SOURCES ustring.c version.c wcwidth.c - ) +) -INCLUDE_DIRECTORIES(charset) -ADD_EXECUTABLE(halibut ${SOURCES}) -TARGET_LINK_LIBRARIES(halibut xtrkcad-charset) +set_target_properties( + halibut + PROPERTIES FOLDER HelpDocs +) +target_link_libraries(halibut xtrkcad-charset) -ADD_SUBDIRECTORY(charset) +add_subdirectory(charset) diff --git a/app/tools/halibut/bk_html.c b/app/tools/halibut/bk_html.c index b01d035..3e937c5 100644 --- a/app/tools/halibut/bk_html.c +++ b/app/tools/halibut/bk_html.c @@ -1611,8 +1611,8 @@ void html_backend(paragraph *sourceform, keywordlist *keywords, */ if (conf.appletoc_filename) { - htmlsect *s, *top; - htmlfile *f; + htmlsect *s;// , *top; +// htmlfile *f; htmloutput ho; ho.charset = conf.output_charset; ho.restrict_charset = conf.restrict_charset; @@ -2728,7 +2728,7 @@ static char *html_sanitise_fragment(htmlfilelist *files, htmlfile *file, while (add234(files->frags, frag) != frag) { if (!len) { - len = strlen(text); + len = (int)strlen(text); frag->fragment = text = sresize(text, len+20, char); } @@ -2781,7 +2781,7 @@ static char *html_sanitise_filename(htmlfilelist *files, char *text) while (find234(files->files, text, NULL)) { if (!p) { - len = strlen(text); + len = (int)strlen(text); p = text; text = snewn(len+20, char); diff --git a/app/tools/halibut/bk_paper.c b/app/tools/halibut/bk_paper.c index 2e0289c..8c244b8 100644 --- a/app/tools/halibut/bk_paper.c +++ b/app/tools/halibut/bk_paper.c @@ -316,70 +316,70 @@ static paper_conf paper_configure(paragraph *source, font_list *fontlist) { ret.bullet = uadv(p->keyword); } else if (!ustricmp(p->keyword, L"paper-page-width")) { ret.paper_width = - (int) 0.5 + FUNITS_PER_PT * utof(uadv(p->keyword)); + (int) (0.5 + FUNITS_PER_PT * utof(uadv(p->keyword))); } else if (!ustricmp(p->keyword, L"paper-page-height")) { ret.paper_height = - (int) 0.5 + FUNITS_PER_PT * utof(uadv(p->keyword)); + (int) (0.5 + FUNITS_PER_PT * utof(uadv(p->keyword))); } else if (!ustricmp(p->keyword, L"paper-left-margin")) { ret.left_margin = - (int) 0.5 + FUNITS_PER_PT * utof(uadv(p->keyword)); + (int) (0.5 + FUNITS_PER_PT * utof(uadv(p->keyword))); } else if (!ustricmp(p->keyword, L"paper-top-margin")) { ret.top_margin = - (int) 0.5 + FUNITS_PER_PT * utof(uadv(p->keyword)); + (int) (0.5 + FUNITS_PER_PT * utof(uadv(p->keyword))); } else if (!ustricmp(p->keyword, L"paper-right-margin")) { ret.right_margin = - (int) 0.5 + FUNITS_PER_PT * utof(uadv(p->keyword)); + (int) (0.5 + FUNITS_PER_PT * utof(uadv(p->keyword))); } else if (!ustricmp(p->keyword, L"paper-bottom-margin")) { ret.bottom_margin = - (int) 0.5 + FUNITS_PER_PT * utof(uadv(p->keyword)); + (int) (0.5 + FUNITS_PER_PT * utof(uadv(p->keyword))); } else if (!ustricmp(p->keyword, L"paper-list-indent")) { ret.indent_list_bullet = - (int) 0.5 + FUNITS_PER_PT * utof(uadv(p->keyword)); + (int) (0.5 + FUNITS_PER_PT * utof(uadv(p->keyword))); } else if (!ustricmp(p->keyword, L"paper-listitem-indent")) { ret.indent_list = - (int) 0.5 + FUNITS_PER_PT * utof(uadv(p->keyword)); + (int) (0.5 + FUNITS_PER_PT * utof(uadv(p->keyword))); } else if (!ustricmp(p->keyword, L"paper-quote-indent")) { ret.indent_quote = - (int) 0.5 + FUNITS_PER_PT * utof(uadv(p->keyword)); + (int) (0.5 + FUNITS_PER_PT * utof(uadv(p->keyword))); } else if (!ustricmp(p->keyword, L"paper-base-leading")) { ret.base_leading = - (int) 0.5 + FUNITS_PER_PT * utof(uadv(p->keyword)); + (int) (0.5 + FUNITS_PER_PT * utof(uadv(p->keyword))); } else if (!ustricmp(p->keyword, L"paper-base-para-spacing")) { ret.base_para_spacing = - (int) 0.5 + FUNITS_PER_PT * utof(uadv(p->keyword)); + (int) (0.5 + FUNITS_PER_PT * utof(uadv(p->keyword))); } else if (!ustricmp(p->keyword, L"paper-chapter-top-space")) { ret.chapter_top_space = - (int) 0.5 + FUNITS_PER_PT * utof(uadv(p->keyword)); + (int) (0.5 + FUNITS_PER_PT * utof(uadv(p->keyword))); } else if (!ustricmp(p->keyword, L"paper-sect-num-left-space")) { ret.sect_num_left_space = - (int) 0.5 + FUNITS_PER_PT * utof(uadv(p->keyword)); + (int) (0.5 + FUNITS_PER_PT * utof(uadv(p->keyword))); } else if (!ustricmp(p->keyword, L"paper-chapter-underline-depth")) { ret.chapter_underline_depth = - (int) 0.5 + FUNITS_PER_PT * utof(uadv(p->keyword)); + (int) (0.5 + FUNITS_PER_PT * utof(uadv(p->keyword))); } else if (!ustricmp(p->keyword, L"paper-chapter-underline-thickness")) { ret.chapter_underline_thickness = - (int) 0.5 + FUNITS_PER_PT * utof(uadv(p->keyword)); + (int) (0.5 + FUNITS_PER_PT * utof(uadv(p->keyword))); } else if (!ustricmp(p->keyword, L"paper-rule-thickness")) { ret.rule_thickness = - (int) 0.5 + FUNITS_PER_PT * utof(uadv(p->keyword)); + (int) (0.5 + FUNITS_PER_PT * utof(uadv(p->keyword))); } else if (!ustricmp(p->keyword, L"paper-contents-indent-step")) { ret.contents_indent_step = - (int) 0.5 + FUNITS_PER_PT * utof(uadv(p->keyword)); + (int) (0.5 + FUNITS_PER_PT * utof(uadv(p->keyword))); } else if (!ustricmp(p->keyword, L"paper-contents-margin")) { ret.contents_margin = - (int) 0.5 + FUNITS_PER_PT * utof(uadv(p->keyword)); + (int) (0.5 + FUNITS_PER_PT * utof(uadv(p->keyword))); } else if (!ustricmp(p->keyword, L"paper-leader-separation")) { ret.leader_separation = - (int) 0.5 + FUNITS_PER_PT * utof(uadv(p->keyword)); + (int) (0.5 + FUNITS_PER_PT * utof(uadv(p->keyword))); } else if (!ustricmp(p->keyword, L"paper-index-gutter")) { ret.index_gutter = - (int) 0.5 + FUNITS_PER_PT * utof(uadv(p->keyword)); + (int) (0.5 + FUNITS_PER_PT * utof(uadv(p->keyword))); } else if (!ustricmp(p->keyword, L"paper-index-minsep")) { ret.index_minsep = - (int) 0.5 + FUNITS_PER_PT * utof(uadv(p->keyword)); + (int) (0.5 + FUNITS_PER_PT * utof(uadv(p->keyword))); } else if (!ustricmp(p->keyword, L"paper-footer-distance")) { ret.footer_distance = - (int) 0.5 + FUNITS_PER_PT * utof(uadv(p->keyword)); + (int) (0.5 + FUNITS_PER_PT * utof(uadv(p->keyword))); } else if (!ustricmp(p->keyword, L"paper-base-font-size")) { ret.fbase.font_size = utoi(uadv(p->keyword)); } else if (!ustricmp(p->keyword, L"paper-index-columns")) { @@ -514,7 +514,7 @@ void *paper_pre_backend(paragraph *sourceform, keywordlist *keywords, int has_index; int pagenum; paragraph index_placeholder_para; - page_data *first_index_page; + page_data *first_index_page = NULL; init_std_fonts(); fontlist = snew(font_list); @@ -1707,7 +1707,7 @@ static void wrap_paragraph(para_data *pdata, word *words, for (p = wrapping; p; p = p->next) { line_data *ldata; - word *wd; +// word *wd; int len, wid, spaces; ldata = snew(line_data); @@ -1732,7 +1732,7 @@ static void wrap_paragraph(para_data *pdata, word *words, spaces = 0; len = paper_width_list(&ctx, ldata->first, ldata->end, &spaces); wid = (p == wrapping ? w - i1 : w - i2); - wd = ldata->first; +// wd = ldata->first; ldata->hshortfall = wid - len; ldata->nspaces = spaces; @@ -1846,8 +1846,8 @@ static page_data *page_breaks(line_data *first, line_data *last, */ if (m != last && m->next && !m->next->page_break) { - int x = (this_height - minheight) / FUNITS_PER_PT * - 4096.0; + int x = (int)((this_height - minheight) / FUNITS_PER_PT * + 4096.0); int xf; xf = x & 0xFF; @@ -1938,8 +1938,8 @@ static page_data *page_breaks(line_data *first, line_data *last, l->page = page; l->ypos = text + space + head; if (page->first_line->space[n]) { - l->ypos += space * (float)page->first_line->vshortfall[n] / - page->first_line->space[n]; + l->ypos += (int)(space * (float)page->first_line->vshortfall[n] / + page->first_line->space[n]); } if (l == page->last_line) @@ -2296,7 +2296,7 @@ static int render_line(line_data *ldata, int left_x, int top_y, xr = NULL; { - int extra_indent, shortfall, spaces; + int extra_indent = 0, shortfall = 0, spaces = 0; int just = ldata->pdata->justification; /* @@ -2344,7 +2344,7 @@ static void render_para(para_data *pdata, paper_conf *conf, keywordlist *keywords, indexdata *idx, paragraph *index_placeholder, page_data *index_page) { - int last_x; + int last_x = 0; xref *cxref; page_data *cxref_page; xref_dest dest; @@ -2530,7 +2530,8 @@ static para_data *code_paragraph(int indent, word *words, paper_conf *conf) w->alt = NULL; w->type = (prev == 0 ? word_WeakCode : prev == 1 ? word_Emph : word_Normal); - w->text = snewn(t-start+1, wchar_t); + w->text = snewn((int)(t-start+1), + wchar_t); memcpy(w->text, start, (t-start) * sizeof(wchar_t)); w->text[t-start] = '\0'; w->breaks = FALSE; @@ -2740,7 +2741,7 @@ static word *fake_end_ref(void) static word *prepare_contents_title(word *first, wchar_t *separator, word *second) { - word *ret; + word *ret = NULL; word **wptr, *w; wptr = &ret; diff --git a/app/tools/halibut/charset/CMakeLists.txt b/app/tools/halibut/charset/CMakeLists.txt index 86521b8..684c70e 100644 --- a/app/tools/halibut/charset/CMakeLists.txt +++ b/app/tools/halibut/charset/CMakeLists.txt @@ -1,4 +1,7 @@ -SET(SOURCES +# +# Character set conversion library as required for halibut + +add_library(xtrkcad-charset big5enc.c big5set.c charset.h @@ -29,10 +32,11 @@ SET(SOURCES utf16.c utf7.c utf8.c - xenc.c - ) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) + xenc.c) -ADD_LIBRARY(xtrkcad-charset ${SOURCES}) +set_target_properties( + xtrkcad-charset + PROPERTIES FOLDER HelpDocs + ) + target_include_directories(xtrkcad-charset PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/app/tools/halibut/charset/fromucs.c b/app/tools/halibut/charset/fromucs.c index 8090c19..3faf48e 100644 --- a/app/tools/halibut/charset/fromucs.c +++ b/app/tools/halibut/charset/fromucs.c @@ -16,7 +16,7 @@ static void charset_emit(void *ctx, long int output) struct charset_emit_param *param = (struct charset_emit_param *)ctx; if (param->outlen > 0) { - *param->output++ = output; + *param->output++ = (char)output; param->outlen--; } else { param->stopped = 1; @@ -47,7 +47,7 @@ int charset_from_unicode(const wchar_t **input, int *inlen, *error = FALSE; while (*inlen > 0) { - int lenbefore = param.output - output; + int lenbefore = (int)(param.output - output); int ret; if (input) @@ -78,5 +78,5 @@ int charset_from_unicode(const wchar_t **input, int *inlen, (*input)++; (*inlen)--; } - return param.output - output; + return (int)(param.output - output); } diff --git a/app/tools/halibut/charset/iso2022.c b/app/tools/halibut/charset/iso2022.c index 8cf3c25..b0492d9 100644 --- a/app/tools/halibut/charset/iso2022.c +++ b/app/tools/halibut/charset/iso2022.c @@ -879,7 +879,7 @@ static void docs_char(charset_state *state, emit(emitctx, '/'); emit(emitctx, '0' + ctext_encodings[curr_cset].octets_per_char); len = currlen + datalen + - strlen(ctext_encodings[curr_cset].name); + (int)strlen(ctext_encodings[curr_cset].name); assert(len < (1 << 14)); emit(emitctx, 0x80 | ((len >> 7) & 0x7F)); emit(emitctx, 0x80 | ((len ) & 0x7F)); @@ -964,7 +964,7 @@ static void docs_char(charset_state *state, static void write_to_pointer(void *ctx, long int output) { char **ptr = (char **)ctx; - *(*ptr)++ = output; + *(*ptr)++ = (char)output; } /* @@ -1195,7 +1195,7 @@ static int write_iso2022(charset_spec const *charset, long int input_chr, } if (cs != -2) { - docs_char(state, emit, emitctx, cs, data, p - data); + docs_char(state, emit, emitctx, cs, data, (int)(p - data)); return TRUE; } } diff --git a/app/tools/halibut/charset/test.c b/app/tools/halibut/charset/test.c index fc5128e..54eab56 100644 --- a/app/tools/halibut/charset/test.c +++ b/app/tools/halibut/charset/test.c @@ -39,7 +39,7 @@ int main(int argc, char **argv) while (1) { - rdret = fread(inbuf, 1, sizeof(inbuf), stdin); + rdret = (int)fread(inbuf, 1, sizeof(inbuf), stdin); if (rdret <= 0) break; /* EOF */ diff --git a/app/tools/halibut/charset/toucs.c b/app/tools/halibut/charset/toucs.c index bee98ab..807001b 100644 --- a/app/tools/halibut/charset/toucs.c +++ b/app/tools/halibut/charset/toucs.c @@ -30,7 +30,7 @@ static void unicode_emit(void *ctx, long int output) outlen = 1; } } else { - outval = output; + outval = (wchar_t)output; p = &outval; outlen = 1; } @@ -65,7 +65,7 @@ int charset_to_unicode(const char **input, int *inlen, localstate = *state; /* structure copy */ while (*inlen > 0) { - int lenbefore = param.output - output; + int lenbefore = (int)(param.output - output); spec->read(spec, (unsigned char)**input, &localstate, unicode_emit, ¶m); if (param.stopped) { @@ -83,5 +83,5 @@ int charset_to_unicode(const char **input, int *inlen, (*inlen)--; } - return param.output - output; + return (int)(param.output - output); } diff --git a/app/tools/halibut/deflate.c b/app/tools/halibut/deflate.c index 685097b..6366708 100644 --- a/app/tools/halibut/deflate.c +++ b/app/tools/halibut/deflate.c @@ -266,6 +266,7 @@ static void lz77_compress(struct LZ77Context *ctx, st->npending -= i; defermatch.len = 0; + defermatch.distance = 0; deferchr = '\0'; while (len > 0) { @@ -1203,7 +1204,7 @@ static void outblock(deflate_compress_ctx *out, */ for (i = 0; i < 19; i++) codelen[i] = len3[lenlenmap[i]]; - for (hclen = 19; hclen > 4 && codelen[hclen-1] == 0; hclen--); + for (hclen = 19; hclen > 4 && codelen[hclen-1] == 0; hclen--){}; /* * Now work out the exact size of both the dynamic and the @@ -1786,8 +1787,9 @@ static struct table *mkonetab(int *codes, unsigned char *lengths, int nsyms, int pfxmask = (1 << pfxbits) - 1; int nbits, i, j, code; - tab->table = snewn(1 << bits, struct tableentry); - tab->mask = (1 << bits) - 1; + int bit = 1 << bits; + tab->table = snewn(bit, struct tableentry); + tab->mask = bit - 1; for (code = 0; code <= tab->mask; code++) { tab->table[code].code = -1; @@ -2041,7 +2043,8 @@ int deflate_decompress_data(deflate_decompress_ctx *dctx, { const coderecord *rec; const unsigned char *block = (const unsigned char *)vblock; - int code, bfinal, btype, rep, dist, nlen, header, cksum; + int code, bfinal, btype, rep, dist, header, cksum; +// int nlen; int error = 0; if (len == 0) { @@ -2440,7 +2443,7 @@ int deflate_decompress_data(deflate_decompress_ctx *dctx, */ if (dctx->nbits < 16) goto finished; - nlen = dctx->bits & 0xFFFF; +// nlen = dctx->bits & 0xFFFF; EATBITS(16); if (dctx->uncomplen == 0) dctx->state = OUTSIDEBLK; /* block is empty */ diff --git a/app/tools/halibut/in_afm.c b/app/tools/halibut/in_afm.c index b2aacae..cb2b39c 100644 --- a/app/tools/halibut/in_afm.c +++ b/app/tools/halibut/in_afm.c @@ -100,56 +100,56 @@ void read_afm_file(input *in) { error(err_afmval, &in->pos, key, 4); goto giveup; } - fi->fontbbox[i] = atof(val); + fi->fontbbox[i] = (float)atof(val); } } else if (strcmp(key, "CapHeight") == 0) { if (!(val = strtok(NULL, " \t"))) { error(err_afmval, &in->pos, key, 1); goto giveup; } - fi->capheight = atof(val); + fi->capheight = (float)atof(val); } else if (strcmp(key, "XHeight") == 0) { if (!(val = strtok(NULL, " \t"))) { error(err_afmval, &in->pos, key, 1); goto giveup; } - fi->xheight = atof(val); + fi->xheight = (float)atof(val); } else if (strcmp(key, "Ascender") == 0) { if (!(val = strtok(NULL, " \t"))) { error(err_afmval, &in->pos, key, 1); goto giveup; } - fi->ascent = atof(val); + fi->ascent = (float)atof(val); } else if (strcmp(key, "Descender") == 0) { if (!(val = strtok(NULL, " \t"))) { error(err_afmval, &in->pos, key, 1); goto giveup; } - fi->descent = atof(val); + fi->descent = (float)atof(val); } else if (strcmp(key, "CapHeight") == 0) { if (!(val = strtok(NULL, " \t"))) { error(err_afmval, &in->pos, key, 1); goto giveup; } - fi->capheight = atof(val); + fi->capheight = (float)atof(val); } else if (strcmp(key, "StdHW") == 0) { if (!(val = strtok(NULL, " \t"))) { error(err_afmval, &in->pos, key, 1); goto giveup; } - fi->stemh = atof(val); + fi->stemh = (float)atof(val); } else if (strcmp(key, "StdVW") == 0) { if (!(val = strtok(NULL, " \t"))) { error(err_afmval, &in->pos, key, 1); goto giveup; } - fi->stemv = atof(val); + fi->stemv = (float)atof(val); } else if (strcmp(key, "ItalicAngle") == 0) { if (!(val = strtok(NULL, " \t"))) { error(err_afmval, &in->pos, key, 1); goto giveup; } - fi->italicangle = atof(val); + fi->italicangle = (float)atof(val); } else if (strcmp(key, "StartCharMetrics") == 0) { int nglyphs, i; if (!(val = strtok(NULL, " \t"))) { @@ -229,14 +229,14 @@ void read_afm_file(input *in) { } else if (strcmp(key, "StartKernPairs") == 0 || strcmp(key, "StartKernPairs0") == 0) { int nkerns, i; - kern_pair *kerns; +// kern_pair *kerns; if (!(val = strtok(NULL, " \t"))) { error(err_afmval, &in->pos, key, 1); goto giveup; } nkerns = atoi(val); sfree(line); - kerns = snewn(nkerns, kern_pair); +// kerns = snewn(nkerns, kern_pair); for (i = 0; i < nkerns; i++) { line = afm_read_line(in); if (line == NULL) diff --git a/app/tools/halibut/in_pf.c b/app/tools/halibut/in_pf.c index 3df6d37..a50dce0 100644 --- a/app/tools/halibut/in_pf.c +++ b/app/tools/halibut/in_pf.c @@ -22,6 +22,8 @@ typedef struct t1_font_Tag t1_font; typedef struct t1_data_Tag t1_data; +font_info *all_fonts; + struct t1_font_Tag { t1_data *data; size_t length1; @@ -68,7 +70,7 @@ static t1_data *load_pfb_file(FILE *fp, filepos *pos) { if (c == EOF) abort(); tail->length |= c << (8 * i); } - tail->data = snewn(tail->length, unsigned char); + tail->data = snewn((int)tail->length, unsigned char); if (fread(tail->data, 1, tail->length, fp) != tail->length) abort(); } } @@ -80,15 +82,15 @@ static t1_data *load_pfa_file(FILE *fp, filepos *pos) { pos->line = 0; ret->type = PFB_ASCII; len = 32768; - ret->data = snewn(len, unsigned char); + ret->data = snewn((int)len, unsigned char); for (;;) { got = fread(ret->data + off, 1, len - off, fp); off += got; if (off != len) break; len *= 2; - ret->data = sresize(ret->data, len, unsigned char); + ret->data = sresize(ret->data, (int)len, unsigned char); } - ret->data = sresize(ret->data, off, unsigned char); + ret->data = sresize(ret->data, (int)off, unsigned char); ret->length = off; return ret; } @@ -189,7 +191,7 @@ static void pf_identify(t1_font *tf) { p++; p += strspn(p, " \t"); len = strcspn(p, " \t"); - fontname = snewn(len + 1, char); + fontname = snewn((int)len + 1, char); memcpy(fontname, p, len); fontname[len] = 0; sfree(rsc.text); @@ -283,11 +285,11 @@ static void pf_getascii(t1_font *tf, size_t off, size_t len, while (td && len) { blk = len < td->length ? len : td->length; if (td->type == PFB_ASCII) { - *bufp = sresize(*bufp, *lenp + blk, char); + *bufp = sresize(*bufp, (int)(*lenp + blk), char); memcpy(*bufp + *lenp, td->data + off, blk); *lenp += blk; } else { - *bufp = sresize(*bufp, *lenp + blk * 2 + blk / 39 + 3, char); + *bufp = sresize(*bufp, (int)(*lenp + blk * 2 + blk / 39 + 3), char); p = *bufp + *lenp; for (i = 0; i < blk; i++) { if (i % 39 == 0) p += sprintf(p, "\n"); @@ -334,11 +336,11 @@ static void pf_getbinary(t1_font *tf, size_t off, size_t len, while (td && len) { blk = len < td->length ? len : td->length; if (td->type == PFB_BINARY) { - *bufp = sresize(*bufp, *lenp + blk, char); + *bufp = sresize(*bufp, (int)(*lenp + blk), char); memcpy(*bufp + *lenp, td->data + off, blk); *lenp += blk; } else { - *bufp = sresize(*bufp, *lenp + blk / 2 + 1, char); + *bufp = sresize(*bufp, (int)(*lenp + blk / 2 + 1), char); p = *bufp + *lenp; for (i = 0; i < blk; i++) { if (pf_isspace(td->data[off + i])) continue; diff --git a/app/tools/halibut/input.c b/app/tools/halibut/input.c index 256d9c6..0f38569 100644 --- a/app/tools/halibut/input.c +++ b/app/tools/halibut/input.c @@ -831,7 +831,7 @@ static void read_file(paragraph ***ret, input *in, indexdata *idx, */ par.type = para_Normal; if (t.type == tok_cmd) { - int needkw; + int needkw = -1; int is_macro = FALSE; par.fpos = t.pos; diff --git a/app/tools/halibut/malloc.c b/app/tools/halibut/malloc.c index 2ff22fd..32f286a 100644 --- a/app/tools/halibut/malloc.c +++ b/app/tools/halibut/malloc.c @@ -92,7 +92,7 @@ void *(srealloc)(LOGPARAMS void *p, int size) { * of smalloc (and also reliably defined in all environments :-) */ char *dupstr(char *s) { - char *r = smalloc(1+strlen(s)); + char *r = smalloc(1+(int)strlen(s)); strcpy(r,s); return r; } diff --git a/app/tools/halibut/misc.c b/app/tools/halibut/misc.c index 3f2483c..c0e86e4 100644 --- a/app/tools/halibut/misc.c +++ b/app/tools/halibut/misc.c @@ -90,7 +90,7 @@ void rdaddc(rdstringc *rs, char c) { rs->text[rs->pos] = 0; } void rdaddsc(rdstringc *rs, char const *p) { - rdaddsn(rs, p, strlen(p)); + rdaddsn(rs, p, (int)strlen(p)); } void rdaddsn(rdstringc *rs, char const *p, int len) { if (rs->pos >= rs->size - len) { @@ -527,7 +527,7 @@ void cmdline_cfg_add(paragraph *cfg, char *string) ulen += 1 + ustrlen(cfg->keyword+ulen); len = 0; while (cfg->origkeyword[len]) - len += 1 + strlen(cfg->origkeyword+len); + len += 1 + (int)strlen(cfg->origkeyword+len); ustring = ufroma_locale_dup(string); @@ -538,7 +538,7 @@ void cmdline_cfg_add(paragraph *cfg, char *string) cfg->keyword[ulen-1] = L'\0'; pos = len; - len += 2 + strlen(string); + len += 2 + (int)strlen(string); cfg->origkeyword = sresize(cfg->origkeyword, len, char); strcpy(cfg->origkeyword+pos, string); cfg->origkeyword[len-1] = '\0'; diff --git a/app/tools/halibut/paper.h b/app/tools/halibut/paper.h index 29d6407..959accd 100644 --- a/app/tools/halibut/paper.h +++ b/app/tools/halibut/paper.h @@ -78,8 +78,6 @@ struct ligature_Tag { * metrics are read in. */ -font_info *all_fonts; - struct font_info_Tag { font_info *next; /* @@ -118,6 +116,8 @@ struct font_info_Tag { float italicangle; }; +extern font_info *all_fonts; + /* * This structure holds the information about how a font is used * in a document. diff --git a/app/tools/halibut/tree234.c b/app/tools/halibut/tree234.c index 26d188e..e971453 100644 --- a/app/tools/halibut/tree234.c +++ b/app/tools/halibut/tree234.c @@ -1162,7 +1162,7 @@ tree234 *join234r(tree234 *t1, tree234 *t2) { static node234 *split234_internal(tree234 *t, int index) { node234 *halves[2], *n, *sib, *sub; node234 *lparent, *rparent; - int ki, pki, i, half, lcount, rcount; + int ki, pki = 0, i, half, lcount, rcount; n = t->root; LOG(("splitting tree %p at point %d\n", t, index)); diff --git a/app/tools/halibut/ustring.c b/app/tools/halibut/ustring.c index 95477a5..99303ef 100644 --- a/app/tools/halibut/ustring.c +++ b/app/tools/halibut/ustring.c @@ -72,7 +72,7 @@ wchar_t *ustrfroma(char const *s, wchar_t *outbuf, int size, int charset) { return outbuf; } - len = strlen(s); + len = (int)strlen(s); size--; /* allow for terminating NUL */ *outbuf = L'\0'; while (len > 0) { @@ -155,7 +155,7 @@ wchar_t *ufroma_dup(char const *s, int charset) { int len; wchar_t *buf = NULL; - len = strlen(s) + 1; + len = (int)strlen(s) + 1; do { buf = sresize(buf, len, wchar_t); ustrfroma(s, buf, len, charset); @@ -184,7 +184,7 @@ char *utoa_locale_dup(wchar_t const *s) if (siz) { assert(siz <= (size_t)(MB_CUR_MAX * len)); ret[siz] = '\0'; - ret = sresize(ret, siz+1, char); + ret = sresize(ret, (int)siz+1, char); return ret; } @@ -206,7 +206,7 @@ wchar_t *ufroma_locale_dup(char const *s) int len; size_t siz; - len = strlen(s); + len = (int)strlen(s); ret = snewn(1 + 2*len, wchar_t); /* be conservative */ @@ -215,7 +215,7 @@ wchar_t *ufroma_locale_dup(char const *s) if (siz) { assert(siz <= (size_t)(2 * len)); ret[siz] = L'\0'; - ret = sresize(ret, siz+1, wchar_t); + ret = sresize(ret, (int)siz+1, wchar_t); return ret; } @@ -323,12 +323,12 @@ wchar_t *ustrlow(wchar_t *s) { } int utoi(wchar_t const *s) { - int sign = +1; +// int sign = +1; int n; if (*s == L'-') { s++; - sign = -1; +// sign = -1; } n = 0; @@ -429,7 +429,7 @@ wchar_t *ustrftime(const wchar_t *wfmt, const struct tm *timespec) rdadd(&rs, L'%'); wfmt += 2; } else if (wfmt[0] == L'%' && wfmt[1]) { - ustrftime_internal(&rs, wfmt[1], timespec); + ustrftime_internal(&rs, (char)(wfmt[1]), timespec); wfmt += 2; } else { rdadd(&rs, wfmt[0]); diff --git a/app/tools/halibut/wcwidth.c b/app/tools/halibut/wcwidth.c index 269359f..0ffe9dd 100644 --- a/app/tools/halibut/wcwidth.c +++ b/app/tools/halibut/wcwidth.c @@ -144,12 +144,13 @@ int ustrwid(wchar_t const *s, int charset) wid = 0; while (len > 0) { - int err, ret; + int err; +// int ret; wchar_t const *s_orig; err = 0; s_orig = s; - ret = charset_from_unicode(&s, &len, buf, lenof(buf), + /*ret =*/ charset_from_unicode(&s, &len, buf, lenof(buf), charset, &state, &err); wid += wcswidth(s_orig, s - s_orig); if (err) { @@ -165,7 +166,7 @@ int ustrwid(wchar_t const *s, int charset) int strwid(char const *s, int charset) { wchar_t buf[256]; - int wid, len = strlen(s); + int wid, len = (int)strlen(s); charset_state state = CHARSET_INIT_STATE; wid = 0; diff --git a/app/tools/lib/linux/libzip.a b/app/tools/lib/linux/libzip.a Binary files differnew file mode 100644 index 0000000..b5cea1c --- /dev/null +++ b/app/tools/lib/linux/libzip.a diff --git a/app/tools/listxtp.c b/app/tools/listxtp.c index 35d0daa..93fd2e9 100644 --- a/app/tools/listxtp.c +++ b/app/tools/listxtp.c @@ -19,7 +19,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include <stdio.h> @@ -148,8 +148,10 @@ main( int argc, char **argv ) /* * if found, store the restof the line and the filename */ + char *bp; buffer[ strlen( buffer ) - 1 ] = '\0'; - sprintf( buffer, "%s (%s)", buffer + strlen( CONTENTSCOMMAND ) + 1, ent->d_name ); + bp = buffer; + sprintf( buffer, "%s (%s)", bp + strlen( CONTENTSCOMMAND ) + 1, ent->d_name ); results[ cnt ] = malloc( strlen( buffer ) + 1 ); strcpy( results[ cnt ], buffer ); cnt++; diff --git a/app/tools/pngtoxpm/CMakeLists.txt b/app/tools/pngtoxpm/CMakeLists.txt new file mode 100644 index 0000000..54f697b --- /dev/null +++ b/app/tools/pngtoxpm/CMakeLists.txt @@ -0,0 +1,16 @@ +# Build pngtoxpm + +add_executable(pngtoxpm pngtoxpm.c) +target_link_libraries(pngtoxpm + PRIVATE + FreeImage::FreeImage +) + +if(WIN32) +# copy dlls into the build dir for easier debugging + add_custom_command( + TARGET pngtoxpm POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${FREEIMAGE_SHAREDLIB} ${CMAKE_CURRENT_BINARY_DIR} + ) + set(ENV{path} "${CMAKE_CURRENT_BINARY_DIR};$ENV{PATH}") +endif() diff --git a/app/tools/pngtoxpm/pngtoxpm.c b/app/tools/pngtoxpm/pngtoxpm.c new file mode 100644 index 0000000..cebc829 --- /dev/null +++ b/app/tools/pngtoxpm/pngtoxpm.c @@ -0,0 +1,721 @@ +
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include <string.h>
+#include <fcntl.h>
+
+#include <assert.h>
+
+#include <FreeImage.h>
+
+//#define DEBUGPRINT
+
+#define CHATTY 0 /* 1 = Enable progress messages */
+#define ALPHATHRESH 96 /* If alpha >= this value the color is not transparent */
+#define BACKGROUND 208 /* The background color RGB = value */
+#define BGMASK 0xF8 /* Mask top 5 bits for partitioning */
+#define NUMPALETTE 40 /* Maximum number of palette entries */
+
+#if defined(WIN32) || defined(_WIN32)
+#include <io.h>
+#define ENDLN "\n"
+#else
+#include <unistd.h>
+// Generate DOS style line ends
+#define ENDLN "\r\n"
+#define E2BIG 1
+double min(double a, double b)
+{
+ if (a < b) { return a; }
+ return b;
+}
+#endif
+
+FIBITMAP* image;
+
+/* Note that percent does not print so omit that char from the list! */
+char palette[76] =
+ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~!@#$^&=+-<>/";
+
+char xpm3Buff[10000];
+
+/**********************************************************************
+C Implementation of Wu's Color Quantizer (v. 2)
+(see Graphics Gems vol. II, pp. 126-133)
+Author: Xiaolin Wu
+Dept. of Computer Science
+Univ. of Western Ontario
+London, Ontario N6A 5B7
+wu@csd.uwo.ca
+Algorithm: Greedy orthogonal bipartition of RGB space for variance
+minimization aided by inclusion-exclusion tricks.
+For speed no nearest neighbor search is done. Slightly
+better performance can be expected by more sophisticated
+but more expensive versions.
+The author thanks Tom Lane at Tom_Lane@G.GP.CS.CMU.EDU for much of
+additional documentation and a cure to a previous bug.
+
+Free to distribute, comments and suggestions are appreciated.
+
+Code from https://gist.github.com/bert/1192520
+**********************************************************************/
+
+#define MAXCOLOR 256
+#define RED 2
+#define GREEN 1
+#define BLUE 0
+
+static float m2[33][33][33];
+static long int wt[33][33][33], mr[33][33][33], mg[33][33][33], mb[33][33][33];
+unsigned char* Ir, * Ig, * Ib, * Ia;
+int size; /*image size*/
+int K; /*color look-up table size*/
+unsigned short int* Qadd;
+unsigned char lut_r[MAXCOLOR], lut_g[MAXCOLOR], lut_b[MAXCOLOR];
+
+struct box {
+ int r0; /* min value, exclusive */
+ int r1; /* max value, inclusive */
+ int g0;
+ int g1;
+ int b0;
+ int b1;
+ int vol;
+};
+
+/* Histogram is in elements 1..HISTSIZE along each axis,
+* element 0 is for base or marginal value
+* NB: these must start out 0!
+*/
+
+/* build 3-D color histogram of counts, r/g/b, c^2 */
+void Hist3d(long* vwt, long* vmr, long* vmg, long* vmb, float* m2)
+{
+ register int ind, r, g, b;
+ int inr, ing, inb, table[256];
+ register long int i;
+
+ for (i = 0; i < 256; ++i) { table[i] = i * i; }
+ Qadd = (unsigned short int*)malloc(sizeof(short int) * size);
+ if (Qadd == NULL) { fprintf(stderr, "Not enough space\n"); exit(1); }
+ for (i = 0; i < size; ++i) {
+ r = Ir[i]; g = Ig[i]; b = Ib[i];
+ inr = (r >> 3) + 1;
+ ing = (g >> 3) + 1;
+ inb = (b >> 3) + 1;
+ Qadd[i] = ind = (inr << 10) + (inr << 6) + inr + (ing << 5) + ing + inb;
+ /*[inr][ing][inb]*/
+ ++vwt[ind];
+ vmr[ind] += r;
+ vmg[ind] += g;
+ vmb[ind] += b;
+ m2[ind] += (float)(table[r] + table[g] + table[b]);
+ }
+}
+
+/* At conclusion of the histogram step, we can interpret
+* wt[r][g][b] = sum over voxel of P(c)
+* mr[r][g][b] = sum over voxel of r*P(c) , similarly for mg, mb
+* m2[r][g][b] = sum over voxel of c^2*P(c)
+* Actually each of these should be divided by 'size' to give the usual
+* interpretation of P() as ranging from 0 to 1, but we needn't do that here.
+*/
+
+/* We now convert histogram into moments so that we can rapidly calculate
+* the sums of the above quantities over any desired box.
+*/
+
+/* compute cumulative moments. */
+void M3d(long* vwt, long* vmr, long* vmg, long* vmb, float* m2)
+{
+ register unsigned short int ind1, ind2;
+ register unsigned char i, r, g, b;
+ long int line, line_r, line_g, line_b,
+ area[33], area_r[33], area_g[33], area_b[33];
+ float line2, area2[33];
+
+ for (r = 1; r <= 32; ++r) {
+ for (i = 0; i <= 32; ++i) {
+ area2[i] = area[i] = area_r[i] = area_g[i] = area_b[i] = 0.0f;
+ }
+ for (g = 1; g <= 32; ++g) {
+ line2 = line = line_r = line_g = line_b = 0;
+ for (b = 1; b <= 32; ++b) {
+ ind1 = (r << 10) + (r << 6) + r + (g << 5) + g + b; /* [r][g][b] */
+ line += vwt[ind1];
+ line_r += vmr[ind1];
+ line_g += vmg[ind1];
+ line_b += vmb[ind1];
+ line2 += m2[ind1];
+ area[b] += line;
+ area_r[b] += line_r;
+ area_g[b] += line_g;
+ area_b[b] += line_b;
+ area2[b] += line2;
+ ind2 = ind1 - 1089; /* [r-1][g][b] */
+ vwt[ind1] = vwt[ind2] + area[b];
+ vmr[ind1] = vmr[ind2] + area_r[b];
+ vmg[ind1] = vmg[ind2] + area_g[b];
+ vmb[ind1] = vmb[ind2] + area_b[b];
+ m2[ind1] = m2[ind2] + area2[b];
+ }
+ }
+ }
+}
+
+
+/* Compute sum over a box of any given statistic */
+long int Vol(struct box* cube, long int mmt[33][33][33])
+{
+ return(mmt[cube->r1][cube->g1][cube->b1]
+ - mmt[cube->r1][cube->g1][cube->b0]
+ - mmt[cube->r1][cube->g0][cube->b1]
+ + mmt[cube->r1][cube->g0][cube->b0]
+ - mmt[cube->r0][cube->g1][cube->b1]
+ + mmt[cube->r0][cube->g1][cube->b0]
+ + mmt[cube->r0][cube->g0][cube->b1]
+ - mmt[cube->r0][cube->g0][cube->b0]);
+}
+
+/* The next two routines allow a slightly more efficient calculation
+* of Vol() for a proposed subbox of a given box. The sum of Top()
+* and Bottom() is the Vol() of a subbox split in the given direction
+* and with the specified new upper bound.
+*/
+
+/* Compute part of Vol(cube, mmt) that doesn't depend on r1, g1, or b1 */
+/* (depending on dir) */
+long int Bottom(struct box* cube, int dir, long int mmt[33][33][33])
+{
+ switch (dir) {
+ case RED:
+ return(-mmt[cube->r0][cube->g1][cube->b1]
+ + mmt[cube->r0][cube->g1][cube->b0]
+ + mmt[cube->r0][cube->g0][cube->b1]
+ - mmt[cube->r0][cube->g0][cube->b0]);
+ break;
+ case GREEN:
+ return(-mmt[cube->r1][cube->g0][cube->b1]
+ + mmt[cube->r1][cube->g0][cube->b0]
+ + mmt[cube->r0][cube->g0][cube->b1]
+ - mmt[cube->r0][cube->g0][cube->b0]);
+ break;
+ case BLUE:
+ return(-mmt[cube->r1][cube->g1][cube->b0]
+ + mmt[cube->r1][cube->g0][cube->b0]
+ + mmt[cube->r0][cube->g1][cube->b0]
+ - mmt[cube->r0][cube->g0][cube->b0]);
+ break;
+ }
+ fprintf(stderr, "Bottom: Invalid dir.\n");
+ exit(1);
+}
+
+
+long int Top(struct box* cube, int dir, int pos, long int mmt[33][33][33])
+/* Compute remainder of Vol(cube, mmt), substituting pos for */
+/* r1, g1, or b1 (depending on dir) */
+{
+ switch (dir) {
+ case RED:
+ return(mmt[pos][cube->g1][cube->b1]
+ - mmt[pos][cube->g1][cube->b0]
+ - mmt[pos][cube->g0][cube->b1]
+ + mmt[pos][cube->g0][cube->b0]);
+ break;
+ case GREEN:
+ return(mmt[cube->r1][pos][cube->b1]
+ - mmt[cube->r1][pos][cube->b0]
+ - mmt[cube->r0][pos][cube->b1]
+ + mmt[cube->r0][pos][cube->b0]);
+ break;
+ case BLUE:
+ return(mmt[cube->r1][cube->g1][pos]
+ - mmt[cube->r1][cube->g0][pos]
+ - mmt[cube->r0][cube->g1][pos]
+ + mmt[cube->r0][cube->g0][pos]);
+ break;
+ }
+ fprintf(stderr, "Top: Invalid dir.\n");
+ exit(1);
+}
+
+
+/* Compute the weighted variance of a box */
+/* NB: as with the raw statistics, this is really the variance * size */
+float Var(struct box* cube)
+{
+ float dr, dg, db, xx;
+
+ dr = Vol(cube, mr);
+ dg = Vol(cube, mg);
+ db = Vol(cube, mb);
+ xx = m2[cube->r1][cube->g1][cube->b1]
+ - m2[cube->r1][cube->g1][cube->b0]
+ - m2[cube->r1][cube->g0][cube->b1]
+ + m2[cube->r1][cube->g0][cube->b0]
+ - m2[cube->r0][cube->g1][cube->b1]
+ + m2[cube->r0][cube->g1][cube->b0]
+ + m2[cube->r0][cube->g0][cube->b1]
+ - m2[cube->r0][cube->g0][cube->b0];
+
+ return(xx - (dr * dr + dg * dg + db * db) / (float)Vol(cube, wt));
+}
+
+/* We want to minimize the sum of the variances of two subboxes.
+* The sum(c^2) terms can be ignored since their sum over both subboxes
+* is the same (the sum for the whole box) no matter where we split.
+* The remaining terms have a minus sign in the variance formula,
+* so we drop the minus sign and MAXIMIZE the sum of the two terms.
+*/
+
+float Maximize(struct box* cube, int dir, int first, int last, int* cut,
+ long whole_r, long whole_g, long whole_b, long whole_w)
+{
+ register long int half_r, half_g, half_b, half_w;
+ long int base_r, base_g, base_b, base_w;
+ register int i;
+ register float temp, max;
+
+ base_r = Bottom(cube, dir, mr);
+ base_g = Bottom(cube, dir, mg);
+ base_b = Bottom(cube, dir, mb);
+ base_w = Bottom(cube, dir, wt);
+ max = 0.0;
+ *cut = -1;
+ for (i = first; i < last; ++i) {
+ half_r = base_r + Top(cube, dir, i, mr);
+ half_g = base_g + Top(cube, dir, i, mg);
+ half_b = base_b + Top(cube, dir, i, mb);
+ half_w = base_w + Top(cube, dir, i, wt);
+ /* now half_x is sum over lower half of box, if split at i */
+ if (half_w == 0) { /* subbox could be empty of pixels! */
+ continue; /* never split into an empty box */
+ } else
+ temp = ((float)half_r * half_r + (float)half_g * half_g +
+ (float)half_b * half_b) / half_w;
+
+ half_r = whole_r - half_r;
+ half_g = whole_g - half_g;
+ half_b = whole_b - half_b;
+ half_w = whole_w - half_w;
+ if (half_w == 0) { /* subbox could be empty of pixels! */
+ continue; /* never split into an empty box */
+ } else
+ temp += ((float)half_r * half_r + (float)half_g * half_g +
+ (float)half_b * half_b) / half_w;
+
+ if (temp > max) { max = temp; *cut = i; }
+ }
+ return(max);
+}
+
+int Cut(struct box* set1, struct box* set2)
+{
+ int dir;
+ int cutr, cutg, cutb;
+ float maxr, maxg, maxb;
+ long int whole_r, whole_g, whole_b, whole_w;
+
+ whole_r = Vol(set1, mr);
+ whole_g = Vol(set1, mg);
+ whole_b = Vol(set1, mb);
+ whole_w = Vol(set1, wt);
+
+ maxr = Maximize(set1, RED, set1->r0 + 1, set1->r1, &cutr,
+ whole_r, whole_g, whole_b, whole_w);
+ maxg = Maximize(set1, GREEN, set1->g0 + 1, set1->g1, &cutg,
+ whole_r, whole_g, whole_b, whole_w);
+ maxb = Maximize(set1, BLUE, set1->b0 + 1, set1->b1, &cutb,
+ whole_r, whole_g, whole_b, whole_w);
+
+ if ((maxr >= maxg) && (maxr >= maxb)) {
+ dir = RED;
+ if (cutr < 0) { return 0; } /* can't split the box */
+ } else if ((maxg >= maxr) && (maxg >= maxb)) {
+ dir = GREEN;
+ } else {
+ dir = BLUE;
+ }
+
+ set2->r1 = set1->r1;
+ set2->g1 = set1->g1;
+ set2->b1 = set1->b1;
+
+ switch (dir) {
+ case RED:
+ set2->r0 = set1->r1 = cutr;
+ set2->g0 = set1->g0;
+ set2->b0 = set1->b0;
+ break;
+ case GREEN:
+ set2->g0 = set1->g1 = cutg;
+ set2->r0 = set1->r0;
+ set2->b0 = set1->b0;
+ break;
+ case BLUE:
+ set2->b0 = set1->b1 = cutb;
+ set2->r0 = set1->r0;
+ set2->g0 = set1->g0;
+ break;
+ }
+ set1->vol = (set1->r1 - set1->r0) * (set1->g1 - set1->g0) *
+ (set1->b1 - set1->b0);
+ set2->vol = (set2->r1 - set2->r0) * (set2->g1 - set2->g0) *
+ (set2->b1 - set2->b0);
+ return 1;
+}
+
+
+void Mark(struct box* cube, int label, unsigned char* tag)
+{
+ register int r, g, b;
+
+ for (r = cube->r0 + 1; r <= cube->r1; ++r)
+ for (g = cube->g0 + 1; g <= cube->g1; ++g)
+ for (b = cube->b0 + 1; b <= cube->b1; ++b) {
+ tag[(r << 10) + (r << 6) + r + (g << 5) + g + b] = label;
+ }
+}
+
+
+void cq()
+{
+ struct box cube[MAXCOLOR];
+ unsigned char* tag;
+ int next;
+ register long int i, weight;
+ register int k;
+ float vv[MAXCOLOR], temp;
+
+ K = NUMPALETTE;
+
+ Hist3d((long*)wt, (long*)mr, (long*)mg, (long*)mb, (float*)m2);
+ if (CHATTY) { printf("Histogram done\n"); }
+
+ M3d((long*)wt, (long*)mr, (long*)mg, (long*)mb, (float*)m2);
+ if (CHATTY) { printf("Moments done\n"); }
+
+ cube[0].r0 = cube[0].g0 = cube[0].b0 = 0;
+ cube[0].r1 = cube[0].g1 = cube[0].b1 = 32;
+ next = 0;
+ for (i = 1; i < K; ++i) {
+ if (Cut(&cube[next], &cube[i])) {
+ /* volume test ensures we won't try to cut one-cell box */
+ vv[next] = (cube[next].vol > 1) ? Var(&cube[next]) : 0.0;
+ vv[i] = (cube[i].vol > 1) ? Var(&cube[i]) : 0.0;
+ } else {
+ vv[next] = 0.0; /* don't try to split this box again */
+ i--; /* didn't create box i */
+ }
+ next = 0; temp = vv[0];
+ for (k = 1; k <= i; ++k)
+ if (vv[k] > temp) {
+ temp = vv[k]; next = k;
+ }
+ if (temp <= 0.0) {
+ K = i + 1;
+ if (CHATTY) { printf("Only got %d boxes\n", K); }
+ break;
+ }
+ }
+ if (CHATTY) { printf("Partition done\n"); }
+
+ tag = (unsigned char*)malloc(33 * 33 * 33);
+ if (tag == NULL) { fprintf(stderr, "Not enough space\n"); exit(1); }
+ for (k = 0; k < K; ++k) {
+ Mark(&cube[k], k, tag);
+ weight = Vol(&cube[k], wt);
+ if (weight) {
+ lut_r[k] = Vol(&cube[k], mr) / weight;
+ lut_g[k] = Vol(&cube[k], mg) / weight;
+ lut_b[k] = Vol(&cube[k], mb) / weight;
+ } else {
+ fprintf(stderr, "bogus box %d\n", k);
+ lut_r[k] = lut_g[k] = lut_b[k] = 0;
+ }
+ }
+
+ for (i = 0; i < size; ++i) { Qadd[i] = tag[Qadd[i]]; }
+
+ free(tag);
+}
+
+char pChar(int j)
+{
+
+ char c = '.';
+ c = palette[j];
+ return c;
+}
+
+/* Safe version of strcat - will not overflow buffer */
+size_t
+strscat(char* dest, const char* src, size_t count)
+{
+ long sptr = 0;
+ long dptr = strlen(dest);
+ count -= dptr;
+
+ if (count <= 0) {
+ return -E2BIG;
+ }
+
+ while (count) {
+ char c;
+
+ c = src[sptr];
+ dest[dptr] = c;
+ if (!c) {
+ return dptr;
+ }
+ sptr++;
+ dptr++;
+ count--;
+ }
+
+ /* Hit buffer length without finding a NUL; force NUL-termination. */
+ if (dptr) {
+ dest[dptr - 1] = '\0';
+ }
+
+ return -E2BIG;
+}
+
+int genXpm(int icon, char* name, int width, int height)
+{
+ char xpmName[100]; // XPM object name
+ char tmpBuff[100]; // sprintf
+ char c[2];
+ int i, j;
+ int x, y;
+ RGBQUAD color;
+ c[1] = 0;
+
+ strcpy(xpmName, name);
+ for (i = 0; i < strlen(xpmName); i++) {
+ if (xpmName[i] == '-') {
+ xpmName[i] = '_';
+ }
+ }
+
+ strscat(xpm3Buff, "static char *", sizeof(xpm3Buff));
+ strscat(xpm3Buff, xpmName, sizeof(xpm3Buff));
+ strscat(xpm3Buff, "_x", sizeof(xpm3Buff));
+ sprintf(tmpBuff, "%d", height); strscat(xpm3Buff, tmpBuff, sizeof(xpm3Buff));
+ strscat(xpm3Buff, "[] = {"ENDLN, sizeof(xpm3Buff));
+ strscat(xpm3Buff, "\t\"", sizeof(xpm3Buff));
+ sprintf(tmpBuff, "%d %d %d %d", width, height, (K + 1), 1);
+ strscat(xpm3Buff, tmpBuff, sizeof(xpm3Buff));
+ strscat(xpm3Buff, "\","ENDLN"\t\" \tc\tNone\","ENDLN, sizeof(xpm3Buff));
+ for (i = 0; i < K; i++) {
+ strscat(xpm3Buff, "\t\"", sizeof(xpm3Buff));
+ sprintf(tmpBuff, "%c\tc\t#%02x%02x%02x", pChar(i), lut_r[i], lut_g[i],
+ lut_b[i]); strscat(xpm3Buff, tmpBuff, sizeof(xpm3Buff));
+ strscat(xpm3Buff, "\","ENDLN, sizeof(xpm3Buff));
+ }
+
+ // Write the pixels
+ i = 0;
+ for (y = height - 1; y >= 0; y--) {
+ strscat(xpm3Buff, "\t\"", sizeof(xpm3Buff));
+ for (x = 0; x < width; x++) {
+ FreeImage_GetPixelColor(image, x, y, &color);
+ if (color.rgbReserved >= ALPHATHRESH) {
+ j = Qadd[i];
+ c[0] = pChar(j);
+ strscat(xpm3Buff, c, sizeof(xpm3Buff));
+ i++;
+ } else {
+ strscat(xpm3Buff, " ", sizeof(xpm3Buff));
+ }
+ }
+
+ if (y > 0) {
+ strscat(xpm3Buff, "\","ENDLN, sizeof(xpm3Buff));
+ } else {
+ strscat(xpm3Buff, "\"};"ENDLN, sizeof(xpm3Buff));
+ }
+ }
+
+ if (icon == 32) {
+ strscat(xpm3Buff, ENDLN"static char **", sizeof(xpm3Buff));
+ strscat(xpm3Buff, xpmName, sizeof(xpm3Buff));
+ strscat(xpm3Buff, "_xpm3[3] = { ", sizeof(xpm3Buff));
+ strscat(xpm3Buff, xpmName, sizeof(xpm3Buff));
+ strscat(xpm3Buff, "_x16, ", sizeof(xpm3Buff));
+ strscat(xpm3Buff, xpmName, sizeof(xpm3Buff));
+ strscat(xpm3Buff, "_x24, ", sizeof(xpm3Buff));
+ strscat(xpm3Buff, xpmName, sizeof(xpm3Buff));
+ strscat(xpm3Buff, "_x32 };"ENDLN, sizeof(xpm3Buff));
+ }
+ return 0;
+}
+
+int process(char* path, char* name, int icon)
+{
+ int i;
+ int w, h;
+ int x, y;
+ short a;
+ float frac;
+ short bg;
+ char filename[1000];
+ RGBQUAD color;
+
+
+ memset(m2, 0, sizeof(m2));
+ memset(wt, 0, sizeof(wt));
+ memset(mr, 0, sizeof(mr));
+ memset(mg, 0, sizeof(mg));
+ memset(mb, 0, sizeof(mb));
+
+ /* printf( "FreeImage version %s\n\n",FreeImage_GetVersion( ) ); */
+
+ // Try override first
+ sprintf(filename, "%spng/%s%d.png", path, name, icon);
+ //#if defined(WIN32) || defined(_WIN32)
+ // if ( _access(filename, 04) != 0) {
+ //#else
+ // if ( access( filename, R_OK ) != 0 ) {
+ //#endif
+ // sprintf( filename,"%s/png/%s%d.png",path,name,icon );
+ // }
+#ifdef DEBUGPRINT
+ fprintf(stdout, "PNG: %s\n", filename);
+#endif
+
+ image = FreeImage_Load(FIF_PNG, filename, PNG_DEFAULT);
+ if (image == NULL) {
+ fprintf(stderr, "%s not found.\n", filename);
+ exit(1);
+ }
+
+ if (FreeImage_GetBPP(image) != 32) {
+ FIBITMAP* tempImage = image;
+ image = FreeImage_ConvertTo32Bits(tempImage);
+ }
+
+ w = FreeImage_GetWidth(image);
+ h = FreeImage_GetHeight(image);
+
+ // Count non-transparent pixels - this is the "size" of the image
+ size = 0;
+ for (y = 0; y < h; y++) {
+ for (x = 0; x < w; x++) {
+ FreeImage_GetPixelColor(image, x, y, &color);
+ a = color.rgbReserved;
+ if (a >= ALPHATHRESH) {
+ size++;
+ }
+ }
+ }
+
+ /* input R,G,B components into Ir, Ig, Ib */
+ Ir = (unsigned char*)malloc(size);
+ Ig = (unsigned char*)malloc(size);
+ Ib = (unsigned char*)malloc(size);
+ assert(Ir && Ig && Ib);
+ i = 0;
+ for (y = h - 1; y >= 0; y--) {
+ for (x = 0; x < w; x++) {
+ FreeImage_GetPixelColor(image, x, y, &color);
+ a = color.rgbReserved;
+ if (a >= ALPHATHRESH) {
+ frac = (float)a / 255;
+ bg = BACKGROUND * (1.0f - frac);
+ Ir[i] = (unsigned char)min(255, color.rgbRed * frac + bg) & BGMASK;
+ Ig[i] = (unsigned char)min(255, color.rgbGreen * frac + bg) & BGMASK;
+ Ib[i] = (unsigned char)min(255, color.rgbBlue * frac + bg) & BGMASK;
+ i++;
+ }
+ }
+ }
+
+ cq();
+
+ free(Ig); free(Ib); free(Ir); /* */
+
+ genXpm(icon, name, w, h);
+
+ // Delete
+ FreeImage_Unload(image);
+
+ return 0;
+}
+
+int main(int argc, char* argv[])
+{
+ char buffer[1000];
+ char path[1000];
+ char name[100];
+ char* temp;
+ char* ext;
+ int i = 0, j = 0;
+ int icon;
+
+#ifdef DEBUGPRINT
+ fprintf(stderr, "Begin pngtoxpm\n");
+#endif
+
+ if (argc < 2) {
+ printf("PngToXpm ver 0.2\nUsage: pngtoxpm filename\nfilename is the path to the resultant XPM3\n");
+ return 0;
+ }
+
+ // Get the file base name from path/name.ext
+ strncpy(buffer, argv[1], sizeof(buffer) - 1);
+
+ strncpy(path, argv[1], sizeof(path) - 1);
+#ifdef DEBUGPRINT
+ fprintf(stderr, "Filename: %s\n", path);
+#endif
+
+ temp = strrchr(path, '/');
+ if (temp != NULL) {
+ temp++;
+ *temp = '\0';
+ } else {
+ path[0] = '\0';
+ }
+
+#ifdef DEBUGPRINT
+ fprintf(stderr, "Path: %s\n", path);
+#endif
+
+ (temp = strrchr(buffer, '/')) ? ++temp : (temp = buffer);
+
+ ext = strrchr(temp, '.');
+ if (ext != NULL) {
+ *ext = '\0';
+ }
+ strncpy(name, temp, sizeof(name) - 1);
+
+#ifdef DEBUGPRINT
+ fprintf(stdout, "In: %s %s\n", path, name);
+#endif
+
+
+ for (icon = 16; icon <= 32; icon += 8) {
+ process(path, name, icon);
+ }
+
+ // Write the xpm file
+ strncpy(buffer, argv[1], sizeof(buffer) - 1);
+#ifdef DEBUGPRINT
+ fprintf(stdout, "XPM: %s\n", buffer);
+#endif
+
+ FILE* ptr;
+ ptr = fopen(buffer, "w");
+ if (ptr == NULL) {
+ fprintf(stderr, "XPM3 file could not be created.\n");
+ exit(1);
+ }
+ fprintf(ptr, "%s", xpm3Buff);
+ fclose(ptr);
+
+ return 0;
+}
+
|