From 5d2c2b27a6323e2666378b986129b2a7c2c39e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 6 Feb 2022 16:04:24 +0100 Subject: New upstream version 5.2.2GA --- app/bin/cstraigh.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'app/bin/cstraigh.c') diff --git a/app/bin/cstraigh.c b/app/bin/cstraigh.c index 464f16e..277db96 100644 --- a/app/bin/cstraigh.c +++ b/app/bin/cstraigh.c @@ -19,17 +19,15 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include #include "cstraigh.h" +#include "cselect.h" #include "cundo.h" #include "fileio.h" -#include "i18n.h" -#include "messages.h" #include "param.h" #include "track.h" -#include "utility.h" #include "layout.h" +#include "common-ui.h" /* * STATE INFO @@ -75,6 +73,7 @@ static STATUS_T CmdStraight( wAction_t action, coOrd pos ) Dl.ep=-1; Dl.down = FALSE; InfoMessage( _("Place 1st endpoint of straight track, snap to unconnected endpoint") ); + SetAllTrackSelect( FALSE ); return C_CONTINUE; case C_DOWN: @@ -113,6 +112,7 @@ static STATUS_T CmdStraight( wAction_t action, coOrd pos ) case C_MOVE: case wActionMove: DYNARR_RESET(trkSeg_t,anchors_da); + found = FALSE; if (!Dl.down) { if (((MyGetKeyState() & WKEY_ALT) == 0) == magneticSnap) { p = pos; @@ -120,12 +120,18 @@ static STATUS_T CmdStraight( wAction_t action, coOrd pos ) if (GetTrkGauge(t) == GetScaleTrackGauge(GetLayoutCurScale())) { EPINX_T ep = PickUnconnectedEndPointSilent(pos, t); if (ep != -1) { - if (GetTrkGauge(t) == GetScaleTrackGauge(GetLayoutCurScale())) + if (GetTrkGauge(t) == GetScaleTrackGauge(GetLayoutCurScale())) { CreateEndAnchor(GetTrkEndPos(t,ep),FALSE); + found = TRUE; + } } } } } + if (!found && SnapPos( &pos )) { + CreateEndAnchor(pos,FALSE); + found = TRUE; + } return C_CONTINUE; } ANGLE_T angle, angle2; @@ -135,7 +141,10 @@ static STATUS_T CmdStraight( wAction_t action, coOrd pos ) if (angle2 > 90.0 && angle2 < 270.0) Translate( &pos, Dl.pos0, angle, FindDistance( Dl.pos0, pos ) ); else pos = Dl.pos0; - } else SnapPos( &pos ); + } else if (SnapPos( &pos )) { + CreateEndAnchor(pos,FALSE); + found = TRUE; + } InfoMessage( _("Straight Track Length=%s Angle=%0.3f"), FormatDistance(FindDistance( Dl.pos0, pos )), @@ -188,5 +197,5 @@ static STATUS_T CmdStraight( wAction_t action, coOrd pos ) void InitCmdStraight( wMenu_p menu ) { - AddMenuButton( menu, CmdStraight, "cmdStraight", _("Straight Track"), wIconCreatePixMap(straight_xpm), LEVEL0_50, IC_STICKY|IC_POPUP2|IC_WANT_MOVE, ACCL_STRAIGHT, NULL ); + AddMenuButton( menu, CmdStraight, "cmdStraight", _("Straight Track"), wIconCreatePixMap(straight_xpm[iconSize]), LEVEL0_50, IC_STICKY|IC_POPUP2|IC_WANT_MOVE, ACCL_STRAIGHT, NULL ); } -- cgit v1.2.3 From a14a7a0ccc9de76aeab0b2e4bbf58f1a79deedc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 3 Jul 2024 10:19:30 +0200 Subject: New upstream version 5.3.0GA --- app/bin/cstraigh.c | 112 ++++++++++++++++++++++++++++------------------------- 1 file changed, 59 insertions(+), 53 deletions(-) (limited to 'app/bin/cstraigh.c') diff --git a/app/bin/cstraigh.c b/app/bin/cstraigh.c index 277db96..b61d9b8 100644 --- a/app/bin/cstraigh.c +++ b/app/bin/cstraigh.c @@ -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 */ #include "cstraigh.h" @@ -33,16 +33,17 @@ * STATE INFO */ static struct { - coOrd pos0, pos1; - track_p trk; - EPINX_T ep; - BOOL_T down; - } Dl; + coOrd pos0, pos1; + track_p trk; + EPINX_T ep; + BOOL_T down; +} Dl; static dynArr_t anchors_da; #define anchors(N) DYNARR_N(trkSeg_t,anchors_da,N) -static void CreateEndAnchor(coOrd p, wBool_t lock) { +static void CreateEndAnchor(coOrd p, wBool_t lock) +{ DIST_T d = tempD.scale*0.15; DYNARR_APPEND(trkSeg_t,anchors_da,1); @@ -53,7 +54,7 @@ static void CreateEndAnchor(coOrd p, wBool_t lock) { anchors(i).u.c.radius = d/2; anchors(i).u.c.a0 = 0.0; anchors(i).u.c.a1 = 360.0; - anchors(i).width = 0; + anchors(i).lineWidth = 0; } @@ -72,7 +73,8 @@ static STATUS_T CmdStraight( wAction_t action, coOrd pos ) Dl.trk = NULL; Dl.ep=-1; Dl.down = FALSE; - InfoMessage( _("Place 1st endpoint of straight track, snap to unconnected endpoint") ); + InfoMessage( + _("Place 1st endpoint of straight track, snap to unconnected endpoint") ); SetAllTrackSelect( FALSE ); return C_CONTINUE; @@ -83,30 +85,30 @@ static STATUS_T CmdStraight( wAction_t action, coOrd pos ) Dl.trk = NULL; if (((MyGetKeyState() & WKEY_ALT) == 0) == magneticSnap) { if ((t = OnTrack(&p, FALSE, TRUE)) != NULL) { - EPINX_T ep = PickUnconnectedEndPointSilent(p, t); - if (ep != -1) { - if (GetTrkGauge(t) != GetScaleTrackGauge(GetLayoutCurScale())) { - wBeep(); - InfoMessage(_("Track is different gauge")); - return C_CONTINUE; - } - Dl.trk = t; - Dl.ep = ep; - pos = GetTrkEndPos(t, ep); - found = TRUE; - } + EPINX_T ep = PickUnconnectedEndPointSilent(p, t); + if (ep != -1) { + if (GetTrkGauge(t) != GetScaleTrackGauge(GetLayoutCurScale())) { + wBeep(); + InfoMessage(_("Track is different gauge")); + return C_CONTINUE; + } + Dl.trk = t; + Dl.ep = ep; + pos = GetTrkEndPos(t, ep); + found = TRUE; + } } } - Dl.down = TRUE; - if (!found) SnapPos( &pos ); + Dl.down = TRUE; + if (!found) { SnapPos( &pos ); } Dl.pos0 = pos; InfoMessage( _("Drag to place 2nd end point") ); DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); tempSegs(0).color = wDrawColorBlack; - tempSegs(0).width = 0; - tempSegs_da.cnt = 0; + tempSegs(0).lineWidth = 0; tempSegs(0).type = SEG_STRTRK; tempSegs(0).u.l.pos[0] = pos; + DYNARR_RESET( trkSeg_t, tempSegs_da ); return C_CONTINUE; case C_MOVE: @@ -118,13 +120,13 @@ static STATUS_T CmdStraight( wAction_t action, coOrd pos ) p = pos; if ((t = OnTrack(&p, FALSE, TRUE)) != NULL) { if (GetTrkGauge(t) == GetScaleTrackGauge(GetLayoutCurScale())) { - EPINX_T ep = PickUnconnectedEndPointSilent(pos, t); - if (ep != -1) { - if (GetTrkGauge(t) == GetScaleTrackGauge(GetLayoutCurScale())) { - CreateEndAnchor(GetTrkEndPos(t,ep),FALSE); - found = TRUE; - } - } + EPINX_T ep = PickUnconnectedEndPointSilent(pos, t); + if (ep != -1) { + if (GetTrkGauge(t) == GetScaleTrackGauge(GetLayoutCurScale())) { + CreateEndAnchor(GetTrkEndPos(t,ep),FALSE); + found = TRUE; + } + } } } } @@ -138,35 +140,35 @@ static STATUS_T CmdStraight( wAction_t action, coOrd pos ) if (Dl.trk && !(MyGetKeyState() & WKEY_SHIFT)) { angle = NormalizeAngle(GetTrkEndAngle( Dl.trk, Dl.ep)); angle2 = NormalizeAngle(FindAngle(pos, Dl.pos0)-angle); - if (angle2 > 90.0 && angle2 < 270.0) + if (angle2 > 90.0 && angle2 < 270.0) { Translate( &pos, Dl.pos0, angle, FindDistance( Dl.pos0, pos ) ); - else pos = Dl.pos0; + } else { pos = Dl.pos0; } } else if (SnapPos( &pos )) { - CreateEndAnchor(pos,FALSE); - found = TRUE; + CreateEndAnchor(pos,FALSE); + found = TRUE; } - + InfoMessage( _("Straight Track Length=%s Angle=%0.3f"), - FormatDistance(FindDistance( Dl.pos0, pos )), - PutAngle(FindAngle( Dl.pos0, pos )) ); + FormatDistance(FindDistance( Dl.pos0, pos )), + PutAngle(FindAngle( Dl.pos0, pos )) ); + DYNARR_SET( trkSeg_t, tempSegs_da, 1 ); tempSegs(0).u.l.pos[1] = pos; - tempSegs_da.cnt = 1; return C_CONTINUE; case C_UP: DYNARR_RESET(trkSeg_t,anchors_da); - if (!Dl.down) return C_CONTINUE; - tempSegs_da.cnt = 0; + if (!Dl.down) { return C_CONTINUE; } + DYNARR_RESET( trkSeg_t, tempSegs_da ); if (Dl.trk && !(MyGetKeyState() & WKEY_SHIFT)) { angle = NormalizeAngle(GetTrkEndAngle( Dl.trk, Dl.ep)); angle2 = NormalizeAngle(FindAngle(pos, Dl.pos0)-angle); - if (angle2 > 90.0 && angle2 < 270.0) + if (angle2 > 90.0 && angle2 < 270.0) { Translate( &pos, Dl.pos0, angle, FindDistance( Dl.pos0, pos )); - else pos = Dl.pos0; - } else SnapPos( &pos ); + } else { pos = Dl.pos0; } + } else { SnapPos( &pos ); } if ((dist=FindDistance( Dl.pos0, pos )) <= minLength) { - ErrorMessage( MSG_TRK_TOO_SHORT, "Straight ", PutDim(fabs(minLength-dist)) ); - return C_TERMINATE; + ErrorMessage( MSG_TRK_TOO_SHORT, "Straight ", PutDim(fabs(minLength-dist)) ); + return C_TERMINATE; } UndoStart( _("Create Straight Track"), "newStraight" ); t = NewStraightTrack( Dl.pos0, pos ); @@ -178,10 +180,12 @@ static STATUS_T CmdStraight( wAction_t action, coOrd pos ) return C_TERMINATE; case C_REDRAW: - if (anchors_da.cnt) - DrawSegs( &tempD, zero, 0.0, &anchors(0), anchors_da.cnt, trackGauge, wDrawColorBlack ); - if (Dl.down) - DrawSegs( &tempD, zero, 0.0, &tempSegs(0), tempSegs_da.cnt, trackGauge, wDrawColorBlack ); + DrawSegsDA( &tempD, NULL, zero, 0.0, &anchors_da, trackGauge, wDrawColorBlack, + 0 ); + if (Dl.down) { + DrawSegsDA( &tempD, NULL, zero, 0.0, &tempSegs_da, trackGauge, wDrawColorBlack, + 0 ); + } return C_CONTINUE; case C_CANCEL: Dl.down = FALSE; @@ -193,9 +197,11 @@ static STATUS_T CmdStraight( wAction_t action, coOrd pos ) } -#include "bitmaps/straight.xpm" +#include "bitmaps/straight.xpm3" void InitCmdStraight( wMenu_p menu ) { - AddMenuButton( menu, CmdStraight, "cmdStraight", _("Straight Track"), wIconCreatePixMap(straight_xpm[iconSize]), LEVEL0_50, IC_STICKY|IC_POPUP2|IC_WANT_MOVE, ACCL_STRAIGHT, NULL ); + AddMenuButton( menu, CmdStraight, "cmdStraight", _("Straight Track"), + wIconCreatePixMap(straight_xpm3[iconSize]), LEVEL0_50, + IC_STICKY|IC_POPUP2|IC_WANT_MOVE, ACCL_STRAIGHT, NULL ); } -- cgit v1.2.3