From 16e9630b79f0a7a90c6cedb6781175bb8b337dc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sat, 29 Apr 2017 12:11:08 +0200 Subject: New upstream version 4.3.0 --- app/bin/cdraw.c | 156 +++++++++++++++++++++----------------------------------- 1 file changed, 58 insertions(+), 98 deletions(-) (limited to 'app/bin/cdraw.c') diff --git a/app/bin/cdraw.c b/app/bin/cdraw.c index 59e45b8..efdb51a 100644 --- a/app/bin/cdraw.c +++ b/app/bin/cdraw.c @@ -2,23 +2,23 @@ * Drawing of geometric elements */ -/* XTrkCad - Model Railroad CAD - * Copyright (C) 2005 Dave Bullis - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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. - */ + /* XTrkCad - Model Railroad CAD + * Copyright (C) 2005 Dave Bullis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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. + */ #include "track.h" #include "ccurve.h" @@ -35,31 +35,49 @@ static long fontSizeList[] = { 200, 250, 300, 350, 400, 450, 500 }; EXPORT void LoadFontSizeList( - wList_p list, - long curFontSize ) + wList_p list, + long curFontSize) { - wIndex_t curInx=0, inx1; + wIndex_t curInx = 0, inx1; int inx; - wListClear( list ); - for ( inx=0; inx fontSizeList[inx-1] ) && - ( curFontSize < fontSizeList[inx] ) ) { - sprintf( message, "%ld", curFontSize ); - curInx = wListAddValue( list, message, NULL, (void*)curFontSize ); + wListClear(list); + for (inx = 0; inx < sizeof fontSizeList / sizeof fontSizeList[0]; inx++) + { + if ((inx == 0 || curFontSize > fontSizeList[inx - 1]) && + (curFontSize < fontSizeList[inx])) + { + sprintf(message, "%ld", curFontSize); + curInx = wListAddValue(list, message, NULL, (void*)curFontSize); } - sprintf( message, "%ld", fontSizeList[inx] ); - inx1 = wListAddValue( list, message, NULL, (void*)fontSizeList[inx] ); - if ( curFontSize == fontSizeList[inx] ) + sprintf(message, "%ld", fontSizeList[inx]); + inx1 = wListAddValue(list, message, NULL, (void*)fontSizeList[inx]); + if (curFontSize == fontSizeList[inx]) curInx = inx1; } - if ( curFontSize > fontSizeList[(sizeof fontSizeList/sizeof fontSizeList[0])-1] ) { - sprintf( message, "%ld", curFontSize ); - curInx = wListAddValue( list, message, NULL, (void*)curFontSize ); + if (curFontSize > fontSizeList[(sizeof fontSizeList / sizeof fontSizeList[0]) - 1]) + { + sprintf(message, "%ld", curFontSize); + curInx = wListAddValue(list, message, NULL, (void*)curFontSize); } - wListSetIndex( list, curInx ); + wListSetIndex(list, curInx); wFlush(); } +long GetFontSize(wIndex_t inx) +{ + return(fontSizeList[inx]); +} + +long GetFontSizeIndex(long size) +{ + int i; + for (i = 0; i < sizeof fontSizeList / sizeof fontSizeList[0]; i++) + { + if (fontSizeList[i] == size) + return(i); + } + return(-1); +} EXPORT void UpdateFontSizeList( long * fontSizeR, @@ -232,7 +250,8 @@ static void UpdateDraw( track_p trk, int inx, descData_p descUpd, BOOL_T final ) return; segPtr = &xx->segs[drawSegInx]; MainRedraw(); - //UndrawNewTrack( trk ); + MapRedraw(); + UndrawNewTrack( trk ); switch ( inx ) { case LW: segPtr->width = drawData.lineWidth/mainD.dpi; @@ -371,6 +390,7 @@ static void UpdateDraw( track_p trk, int inx, descData_p descUpd, BOOL_T final ) } ComputeDrawBoundingBox( trk ); DrawNewTrack( trk ); + DoCurCommand( C_REDRAW, zero ); } static void DescribeDraw( track_p trk, char * str, CSIZE_T len ) @@ -391,6 +411,7 @@ static void DescribeDraw( track_p trk, char * str, CSIZE_T len ) drawDesc[inx].control0 = NULL; } drawData.color = segPtr->color; + drawData.layer = GetTrkLayer(trk); drawDesc[CO].mode = 0; drawData.lineWidth = (long)floor(segPtr->width*mainD.dpi+0.5); drawDesc[LW].mode = 0; @@ -759,43 +780,10 @@ static drawContext_t drawCmdContext = { static void DrawRedraw( void ) { MainRedraw(); + MapRedraw(); } -#ifdef LATER -static void DrawOk( void * context ) -{ - track_p t; - struct extraData * xx; - trkSeg_p sp; - wIndex_t cnt; - - for ( cnt=0,sp=&DrawLineSegs(0); sp < &DrawLineSegs(drawCmdContext.Segs_da.cnt); sp++ ) - if (sp->type != ' ') - cnt++; - if (cnt == 0) - return; - UndoStart( _("Create Lines"), "newDraw" ); - for ( sp=&DrawLineSegs(0); sp < &DrawLineSegs(drawCmdContext.Segs_da.cnt); sp++ ) { - if (sp->type != ' ') { - t = NewTrack( 0, T_DRAW, 0, sizeof *xx + sizeof *(trkSeg_p)0 ); - xx = GetTrkExtraData( t ); - xx->orig = zero; - xx->angle = 0.0; - xx->segCnt = 1; - memcpy( xx->segs, sp, sizeof *(trkSeg_p)0 ); - ComputeDrawBoundingBox( t ); - DrawNewTrack(t); - } - } - UndoEnd(); - DYNARR_RESET( trkSeg_t, drawCmdContext.Segs_da ); - Reset(); -} -#endif - - - static wIndex_t benchChoice; static wIndex_t benchOrient; static wIndex_t dimArrowSize; @@ -914,10 +902,7 @@ static STATUS_T CmdDraw( wAction_t action, coOrd pos ) labels[2] = N_("Color"); if ( wListGetCount( (wList_p)drawBenchChoicePD.control ) == 0 ) BenchLoadLists( (wList_p)drawBenchChoicePD.control, (wList_p)drawBenchOrientPD.control ); -#ifdef LATER - if ( benchInx >= 0 && benchInx < wListGetCount( (wList_p)drawBenchChoicePD.control ) ) - wListSetIndex( (wList_p)drawBenchChoicePD.control, benchInx ); -#endif + ParamLoadControls( &drawPG ); BenchUpdateOrientationList( (long)wListGetItemContext( (wList_p)drawBenchChoicePD.control, benchChoice ), (wList_p)drawBenchOrientPD.control ); wListSetIndex( (wList_p)drawBenchOrientPD.control, benchOrient ); @@ -959,9 +944,7 @@ static STATUS_T CmdDraw( wAction_t action, coOrd pos ) if ( drawCmdContext.Op == OP_BENCH ) { drawCmdContext.benchOption = GetBenchData( (long)wListGetItemContext((wList_p)drawBenchChoicePD.control, benchChoice ), benchOrient ); drawCmdContext.Color = benchColor; -#ifdef LATER - benchInx = wListGetIndex( (wList_p)drawBenchChoicePD.control ); -#endif + } else if ( drawCmdContext.Op == OP_DIMLINE ) { drawCmdContext.benchOption = dimArrowSize; } else { @@ -1074,29 +1057,6 @@ static drawStuff_t drawStuff[4] = { { "cmdDrawShapeSetCmd", N_("Shapes"), N_("Draw Shapes"), 4, dshapeCmds} }; -#ifdef LATER -static void SetDrawMode( char * modeName ) -{ - wButton_p bb; - int inx1, inx2; - drawData_t * dp; - - for ( inx1=0; inx1<4; inx1++ ) { - for ( inx2=0; inx2modeS, strlen(dp->modeS) ) == 0 ) { - bb = GetCommandButton(drawStuff[inx1].cmdInx); - wButtonSetLabel( bb, (char*)(dp->icon) ); - wControlSetHelp( (wControl_p)bb, dp->help ); - drawStuff[inx1].curr = inx2; - DoCommandB( (void*)(drawStuff[inx1].cmdInx) ); - return; - } - } - } -} -#endif - static void ChangeDraw( long changes ) { -- cgit v1.2.3