diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2018-03-19 19:55:58 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2018-03-19 19:55:58 +0100 |
commit | d1a8285f818eb7e5c3d6a05709ea21a808490b8c (patch) | |
tree | 326578f0505cbed07cfe60de530022822dc237ac /app/bin/tstraigh.c | |
parent | 16e9630b79f0a7a90c6cedb6781175bb8b337dc1 (diff) |
New upstream version 5.1.0upstream/5.1.0
Diffstat (limited to 'app/bin/tstraigh.c')
-rw-r--r-- | app/bin/tstraigh.c | 55 |
1 files changed, 41 insertions, 14 deletions
diff --git a/app/bin/tstraigh.c b/app/bin/tstraigh.c index 0f5f273..5cf1cda 100644 --- a/app/bin/tstraigh.c +++ b/app/bin/tstraigh.c @@ -1,5 +1,5 @@ -/* - * $Header: /home/dmarkle/xtrkcad-fork-cvs/xtrkcad/app/bin/tstraigh.c,v 1.2 2008-01-20 23:29:15 mni77 Exp $ +/** \file tstraigh.c + * Straight track */ /* XTrkCad - Model Railroad CAD @@ -20,9 +20,17 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "track.h" +#include <math.h> + #include "cstraigh.h" +#include "cundo.h" +#include "fileio.h" #include "i18n.h" +#include "layout.h" +#include "messages.h" +#include "param.h" +#include "track.h" +#include "utility.h" /******************************************************************************* * @@ -70,13 +78,13 @@ static struct { ANGLE_T angle; FLOAT_T grade; descPivot_t pivot; - LAYER_T layerNumber; + unsigned int layerNumber; } strData; typedef enum { E0, Z0, E1, Z1, LN, AN, GR, PV, LY } strDesc_e; static descData_t strDesc[] = { -/*E0*/ { DESC_POS, N_("End Pt 1: X"), &strData.endPt[0] }, +/*E0*/ { DESC_POS, N_("End Pt 1: X,Y"), &strData.endPt[0] }, /*Z0*/ { DESC_DIM, N_("Z"), &strData.elev[0] }, -/*E1*/ { DESC_POS, N_("End Pt 2: X"), &strData.endPt[1] }, +/*E1*/ { DESC_POS, N_("End Pt 2: X,Y"), &strData.endPt[1] }, /*Z1*/ { DESC_DIM, N_("Z"), &strData.elev[1] }, /*LN*/ { DESC_DIM, N_("Length"), &strData.length }, /*AN*/ { DESC_ANGLE, N_("Angle"), &strData.angle }, @@ -420,7 +428,7 @@ static BOOL_T TrimStraight( track_p trk, EPINX_T ep, DIST_T dist ) AdjustStraightEndPt( trk, ep, pos ); DrawNewTrack( trk ); } else - DeleteTrack( trk, FALSE ); + DeleteTrack( trk, TRUE ); return TRUE; } @@ -548,6 +556,7 @@ static STATUS_T ModifyStraight( track_p trk, wAction_t action, coOrd pos ) InfoMessage( _("Straight: Length=%s Angle=%0.3f"), FormatDistance( d ), PutAngle( GetTrkEndAngle( trk, ep ) ) ); MainRedraw(); + MapRedraw(); return C_CONTINUE; case C_UP: @@ -556,6 +565,7 @@ static STATUS_T ModifyStraight( track_p trk, wAction_t action, coOrd pos ) tempSegs_da.cnt = 0; DrawNewTrack( trk ); MainRedraw(); + MapRedraw(); return C_TERMINATE; default: @@ -576,14 +586,19 @@ static BOOL_T GetParamsStraight( int inx, track_p trk, coOrd pos, trackParams_t params->type = curveTypeStraight; if ( inx == PARAMS_PARALLEL ) { params->ep = 0; + } else if (inx == PARAMS_CORNU ){ + params->ep = PickEndPoint( pos, trk); + params->arcP = zero; + params->arcR = 0.0; } else { - params->ep = PickUnconnectedEndPoint( pos, trk ); - if (params->ep == -1) - return FALSE; + params->ep = PickUnconnectedEndPointSilent( pos, trk ); } + if (params->ep == -1) + return FALSE; params->lineOrig = GetTrkEndPos(trk,1-params->ep); params->lineEnd = GetTrkEndPos(trk,params->ep); params->len = FindDistance( params->lineOrig, params->lineEnd ); + params->track_angle = FindAngle( params->lineOrig, params->lineEnd); params->angle = GetTrkEndAngle(trk,params->ep); params->arcR = 0.0; return TRUE; @@ -610,6 +625,8 @@ static BOOL_T QueryStraight( track_p trk, int query ) case Q_CAN_MODIFYRADIUS: case Q_CAN_GROUP: case Q_ISTRACK: + case Q_CORNU_CAN_MODIFY: + case Q_MODIFY_CAN_SPLIT: return TRUE; default: return FALSE; @@ -703,9 +720,13 @@ EXPORT void StraightSegProc( case SEGPROC_TRAVERSE1: a1 = FindAngle( segPtr->u.l.pos[0], segPtr->u.l.pos[1] ); - a2 = NormalizeAngle( data->traverse1.angle+a1 ); - data->traverse1.backwards = (a2 < 270 && a2 > 90 ); + a2 = NormalizeAngle( a1-data->traverse1.angle ); + data->traverse1.backwards = ((a2 < 270) && (a2 > 90)); data->traverse1.dist = FindDistance( segPtr->u.l.pos[data->traverse1.backwards?1:0], data->traverse1.pos ); + data->traverse1.reverse_seg = FALSE; + data->traverse1.negative = FALSE; + data->traverse1.segs_backwards = FALSE; + data->traverse1.BezSegInx = 0; break; case SEGPROC_TRAVERSE2: @@ -716,7 +737,10 @@ EXPORT void StraightSegProc( data->traverse2.dist = 0; data->traverse2.angle = a1; } else { + a1 = FindAngle( segPtr->u.l.pos[data->traverse2.segDir], segPtr->u.l.pos[1-data->traverse2.segDir] ); + Translate( &data->traverse2.pos, segPtr->u.l.pos[data->traverse2.segDir], a1, d ); data->traverse2.dist -= d; + data->traverse2.angle = a1; } break; @@ -768,9 +792,12 @@ EXPORT void StraightSegProc( data->split.newSeg[1] = *segPtr; data->split.newSeg[0].u.l.pos[1] = data->split.newSeg[1].u.l.pos[0] = p0; break; - + /* + * Note GetAngle always gives a positive angle because p0 is always left of p1 + */ case SEGPROC_GETANGLE: data->getAngle.angle = FindAngle( segPtr->u.l.pos[0], segPtr->u.l.pos[1] ); + data->getAngle.radius = 0.0; break; } } @@ -788,7 +815,7 @@ track_p NewStraightTrack( coOrd p0, coOrd p1 ) track_p t; ANGLE_T a; t = NewTrack( 0, T_STRAIGHT, 2, 0 ); - SetTrkScale( t, curScaleInx ); + SetTrkScale( t, GetLayoutCurScale() ); a = FindAngle( p1, p0 ); SetTrkEndPoint( t, 0, p0, a ); SetTrkEndPoint( t, 1, p1, NormalizeAngle( a+180.0 ) ); |