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/cselect.c | 982 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 662 insertions(+), 320 deletions(-) (limited to 'app/bin/cselect.c') diff --git a/app/bin/cselect.c b/app/bin/cselect.c index 4e4e8eb..1b153b9 100644 --- a/app/bin/cselect.c +++ b/app/bin/cselect.c @@ -20,29 +20,25 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include - +#include "common.h" #include "draw.h" #include "ccurve.h" #include "tcornu.h" #include "tbezier.h" #include "track.h" -#define PRIVATE_EXTRADATA #include "compound.h" #include "cselect.h" #include "cundo.h" #include "custom.h" #include "fileio.h" -#include "i18n.h" #include "layout.h" -#include "messages.h" #include "param.h" #include "track.h" -#include "utility.h" +#include "cjoin.h" #include "draw.h" #include "misc.h" #include "trackx.h" +#include "common-ui.h" #include "bitmaps/bmendpt.xbm" @@ -56,12 +52,12 @@ EXPORT wIndex_t selectCmdInx; EXPORT wIndex_t moveCmdInx; EXPORT wIndex_t rotateCmdInx; +EXPORT wIndex_t flipCmdInx; #define MAXMOVEMODE (3) static long moveMode = MAXMOVEMODE; static BOOL_T enableMoveDraw = TRUE; static BOOL_T move0B; -struct extraData { char junk[2000]; }; static wDrawBitMap_p endpt_bm; static wDrawBitMap_p angle_bm[4]; @@ -70,8 +66,8 @@ track_p IsInsideABox(coOrd pos); static track_p moveDescTrk; static coOrd moveDescPos; -int incrementalDrawLimit = 20; - static int microCount = 0; +int incrementalDrawLimit = 0; +static int microCount = 0; static dynArr_t tlist_da; @@ -128,6 +124,7 @@ void CreateArrowAnchor(coOrd pos,ANGLE_T a,DIST_T len) { anchors(i).u.l.pos[0] = pos; Translate(&anchors(i).u.l.pos[1],pos,NormalizeAngle(a-135),len); anchors(i).color = wDrawColorBlue; + wSetCursor(mainD.d,wCursorNone); } void static CreateRotateAnchor(coOrd pos) { @@ -146,6 +143,16 @@ void static CreateRotateAnchor(coOrd pos) { Translate(&head,pos,j*120,d*2); CreateArrowAnchor(head,NormalizeAngle((j*120)+90),d); } + DYNARR_APPEND(trkSeg_t,anchors_da,1); + i = anchors_da.cnt-1; + anchors(i).type = SEG_CRVLIN; + anchors(i).width = d/8; + anchors(i).u.c.center = pos; + anchors(i).u.c.a0 = 180.0; + anchors(i).u.c.a1 = 360.0; + anchors(i).u.c.radius = d/16; + anchors(i).color = wDrawColorAqua; + wSetCursor(mainD.d,wCursorNone); } void static CreateModifyAnchor(coOrd pos) { @@ -168,6 +175,7 @@ void static CreateModifyAnchor(coOrd pos) { anchors(i).u.c.a1 = 360.0; anchors(i).u.c.radius = d; anchors(i).color = wDrawColorPowderedBlue; + wSetCursor(mainD.d,wCursorNone); } @@ -193,6 +201,7 @@ void CreateDescribeAnchor(coOrd pos) { Translate(&anchors(i).u.l.pos[1],pos,180.0,d*1.5); anchors(i).color = wDrawColorPowderedBlue; } + wSetCursor(mainD.d,wCursorNone); } void CreateActivateAnchor(coOrd pos) { @@ -218,6 +227,7 @@ void CreateActivateAnchor(coOrd pos) { anchors(i).u.c.a1 = 360.0; anchors(i).u.c.radius = d; anchors(i).color = wDrawColorPowderedBlue; + wSetCursor(mainD.d,wCursorNone); } void static CreateMoveAnchor(coOrd pos) { @@ -225,6 +235,7 @@ void static CreateMoveAnchor(coOrd pos) { DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),pos,0,TRUE,wDrawColorBlue); DYNARR_SET(trkSeg_t,anchors_da,anchors_da.cnt+5); DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),pos,90,TRUE,wDrawColorBlue); + wSetCursor(mainD.d,wCursorNone); } void CreateEndAnchor(coOrd p, wBool_t lock) { @@ -382,7 +393,7 @@ EXPORT void SetAllTrackSelect( BOOL_T select ) selectedTrackCount = 0; trk = NULL; while ( TrackIterate( &trk ) ) { - if ((!select) || GetLayerVisible( GetTrkLayer( trk ))) { + if ((!select) || (GetLayerVisible( GetTrkLayer( trk )) && !GetLayerFrozen(GetTrkLayer( trk )) )) { if (select) selectedTrackCount++; if ((GetTrkSelected(trk)!=0) != select) { @@ -392,7 +403,7 @@ EXPORT void SetAllTrackSelect( BOOL_T select ) ClrTrkBits( trk, TB_SELECTED ); if (!doRedraw) SetTrkBits( trk, TB_SELREDRAW ); - DrawTrackAndEndPts( trk, wDrawColorBlack ); + DrawTrackAndEndPts( trk, wDrawColorBlack ); } } } @@ -405,20 +416,20 @@ EXPORT void SetAllTrackSelect( BOOL_T select ) } } -/* Invert selected state of all visible non-module objects. +/* Invert selected state of all visible non-module, non-frozen objects. * * \param none * \return none */ -EXPORT void InvertTrackSelect( void *ptr ) +EXPORT void InvertTrackSelect( void * unused ) { track_p trk; trk = NULL; while ( TrackIterate( &trk ) ) { if (GetLayerVisible( GetTrkLayer( trk )) && - !GetLayerModule(GetTrkLayer( trk ))) { + !GetLayerModule(GetTrkLayer( trk )) && !GetLayerFrozen(GetTrkLayer( trk )) ) { SelectOneTrack( trk, GetTrkSelected(trk)==0 ); } } @@ -428,7 +439,7 @@ EXPORT void InvertTrackSelect( void *ptr ) MainRedraw(); // InvertTrackSelect } -/* Select orphaned (ie single) track pieces. +/* Select orphaned (ie single) track pieces (ignore frozen and module) * * \param none * \return none @@ -444,7 +455,7 @@ EXPORT void OrphanedTrackSelect( void *ptr ) while( TrackIterate( &trk ) ) { cnt = 0; - if( GetLayerVisible( GetTrkLayer( trk ) && !GetLayerModule(GetTrkLayer(trk)))) { + if( GetLayerVisible( GetTrkLayer( trk ) && !GetLayerModule(GetTrkLayer(trk)) && !GetLayerFrozen(GetTrkLayer(trk)))) { for( ep = 0; ep < GetTrkEndPtCnt( trk ); ep++ ) { if( GetTrkEndTrk( trk, ep ) ) cnt++; @@ -480,12 +491,11 @@ static void SelectOneTrack( selectedTrackCount--; } SelectedTrackCountChange(); - DrawTrackAndEndPts( trk, wDrawColorBlack ); } -static void HighlightSelectedTracks( - track_p trk_ignore, BOOL_T box, BOOL_T invert ) +EXPORT void HighlightSelectedTracks( + track_p trk_ignore, BOOL_T keep, BOOL_T invert ) { track_p trk = NULL; if ( selectedTrackCount == 0 ) @@ -494,7 +504,9 @@ static void HighlightSelectedTracks( if (trk == trk_ignore) continue; if(GetTrkSelected(trk)) { if (!GetLayerVisible( GetTrkLayer( trk ))) continue; - if (invert) + if (keep) + DrawTrack(trk,&tempD,selectedColor); + else if (invert) DrawTrack(trk,&tempD,wDrawColorPreviewUnselected); else DrawTrack(trk,&tempD,wDrawColorPreviewSelected ); @@ -503,6 +515,11 @@ static void HighlightSelectedTracks( } +/* + * Select all tracks connected walking the tree until hitting ends or already selected tracks + * + * Ignore Frozen Tracks + */ static void SelectConnectedTracks( track_p trk, BOOL_T display_only ) { @@ -517,15 +534,17 @@ static void SelectConnectedTracks( if ( inx > 0 && (selectedTrackCount == 0) && !display_only ) return; trk = Tlist(inx); - if (inx!=0 && - GetTrkSelected(trk)) { - if (display_only) - DrawTrack(trk,&tempD,wDrawColorPreviewSelected ); - continue; - } else if (GetTrkSelected(trk)) { - if (display_only) - DrawTrack(trk,&tempD,wDrawColorPreviewUnselected); - continue; + if (!GetLayerFrozen(GetTrkLayer(trk))) { + if (inx!=0 && + GetTrkSelected(trk)) { + if (display_only) + DrawTrack(trk,&tempD,wDrawColorPreviewSelected ); + continue; + } else if (GetTrkSelected(trk)) { + if (display_only) + DrawTrack(trk,&tempD,wDrawColorPreviewUnselected); + continue; + } } for (ep=0; ep0) { - UndoStart( _("Delete Tracks"), "delete" ); + BOOL_T UndoStarted = FALSE; + if (!TestAllSelectedTracks(QueryTrack,(int)Q_ISTRAIN)) { // If all Cars, don't bother with UndoStart as there will be nothing to delete + UndoStarted = TRUE; + UndoStart( _("Delete Tracks"), "delete" ); + } wDrawDelayUpdate( mainD.d, TRUE ); wDrawDelayUpdate( mapD.d, TRUE ); DoSelectedTracks( DeleteTrack ); @@ -674,15 +725,26 @@ EXPORT void SelectDelete( void ) wDrawDelayUpdate( mapD.d, FALSE ); selectedTrackCount = 0; SelectedTrackCountChange(); - UndoEnd(); + if (UndoStarted) + UndoEnd(); } else { ErrorMessage( MSG_NO_SELECTED_TRK ); } + return 0; +} + +/* + * Called By Windows directly with Delete Key. We first try a simple Delete, and if that doesn't work saying "In Modify" we call Modify with a Text key for Delete + */ +EXPORT void TrySelectDelete( void ) { + if(SelectDelete() == 1) { + CmdModify((C_TEXT+(int)(127<<8)),zero); + } } BOOL_T flipHiddenDoSelectRecount; -static BOOL_T FlipHidden( track_p trk, BOOL_T junk ) +static BOOL_T FlipHidden( track_p trk, BOOL_T unused ) { EPINX_T i; track_p trk2; @@ -713,7 +775,7 @@ static BOOL_T FlipHidden( track_p trk, BOOL_T junk ) return TRUE; } -static BOOL_T FlipBridge( track_p trk, BOOL_T junk ) +static BOOL_T FlipBridge( track_p trk, BOOL_T unused ) { UndoModify( trk ); if (GetTrkBridge(trk)) { @@ -725,7 +787,7 @@ static BOOL_T FlipBridge( track_p trk, BOOL_T junk ) return TRUE; } -static BOOL_T FlipTies( track_p trk, BOOL_T junk ) +static BOOL_T FlipTies( track_p trk, BOOL_T unused ) { UndoModify( trk ); if (GetTrkNoTies(trk)) { @@ -737,7 +799,7 @@ static BOOL_T FlipTies( track_p trk, BOOL_T junk ) return TRUE; } -EXPORT void SelectTunnel( void ) +EXPORT void SelectTunnel( void * unused ) { if (SelectedTracksAreFrozen()) return; @@ -755,7 +817,7 @@ EXPORT void SelectTunnel( void ) SelectRecount(); } -EXPORT void SelectBridge( void ) +EXPORT void SelectBridge( void * unused ) { if (SelectedTracksAreFrozen()) return; @@ -772,7 +834,7 @@ EXPORT void SelectBridge( void ) MainRedraw(); // SelectBridge } -EXPORT void SelectTies( void ) +EXPORT void SelectTies( void * unused ) { if (SelectedTracksAreFrozen()) return; @@ -803,14 +865,14 @@ void SelectRecount( void ) } -static BOOL_T SetLayer( track_p trk, BOOL_T junk ) +static BOOL_T SetLayer( track_p trk, BOOL_T unused ) { UndoModify( trk ); SetTrkLayer( trk, curLayer ); return TRUE; } -EXPORT void MoveSelectedTracksToCurrentLayer( void ) +EXPORT void MoveSelectedTracksToCurrentLayer( void * unused ) { if (SelectedTracksAreFrozen()) return; @@ -823,20 +885,32 @@ EXPORT void MoveSelectedTracksToCurrentLayer( void ) } } -EXPORT void SelectCurrentLayer( void ) +EXPORT void SelectCurrentLayer( void * unused ) { track_p trk; trk = NULL; + if (GetLayerFrozen(curLayer)) return; while ( TrackIterate( &trk ) ) { - if ((!GetTrkSelected(trk)) && GetTrkLayer(trk) == curLayer ) { + if ((!GetTrkSelected(trk)) && GetTrkLayer(trk) == curLayer) { SelectOneTrack( trk, TRUE ); } } RedrawSelectedTracksBoundary(); } +EXPORT void DeselectLayer( unsigned int layer ) { + track_p trk; + trk = NULL; + while ( TrackIterate( &trk ) ) { + if ((GetTrkSelected(trk)) && GetTrkLayer(trk) == layer) { + SelectOneTrack( trk, FALSE ); + } + } + RedrawSelectedTracksBoundary(); +} + -static BOOL_T ClearElevation( track_p trk, BOOL_T junk ) +static BOOL_T ClearElevation( track_p trk, BOOL_T unused ) { EPINX_T ep; for ( ep=0; epd, FALSE );*/ } static BOOL_T AddSelectedTrack( - track_p trk, BOOL_T junk ) + track_p trk, BOOL_T unused ) { DYNARR_APPEND( track_p, tlist_da, 10 ); DYNARR_LAST( track_p, tlist_da ) = trk; return TRUE; } +static BOOL_T RemoveSelectedTrack(track_p trk) { + + for(int i=0;i lo.y ) layer_lo.y = lo.y; } } - wPos_t margin = (wPos_t)(10.5*mainD.scale/mainD.dpi); + wDrawPix_t margin = (10.5*mainD.scale/mainD.dpi); layer_hi.x +=margin; layer_hi.y +=margin; layer_lo.x -=margin; layer_lo.y -=margin; - wPos_t rect[4][2]; int type[4]; - coOrd top_left, bot_right; - top_left.x = layer_lo.x; top_left.y = layer_hi.y; - bot_right.x = layer_hi.x; bot_right.y = layer_lo.y; type[0] = type[1] = type[2] = type[3] = 0; - mainD.CoOrd2Pix(&mainD,layer_lo,&rect[0][0],&rect[0][1]); - mainD.CoOrd2Pix(&mainD,top_left,&rect[1][0],&rect[1][1]); - mainD.CoOrd2Pix(&mainD,layer_hi,&rect[2][0],&rect[2][1]); - mainD.CoOrd2Pix(&mainD,bot_right,&rect[3][0],&rect[3][1]); - wDrawPolygon(tempD.d,rect,(wPolyLine_e *)type,4,wDrawColorPowderedBlue,0,wDrawLineDash,wDrawOptTemp,0,0); + coOrd rect[4]; + // r3 r2 + // r0 r1 + rect[0].x = rect[3].x = layer_lo.x; + rect[1].x = rect[2].x = layer_hi.x; + rect[0].y = rect[1].y = layer_lo.y; + rect[2].y = rect[3].y = layer_hi.y; + DrawPoly(&tempD,4,rect,type,wDrawColorPowderedBlue,wDrawLineDash,DRAW_CLOSED); } void SetUpMenu2(coOrd pos, track_p trk) { @@ -1734,7 +1865,7 @@ static STATUS_T CmdMove( UndoStart( _("Move Tracks"), "move" ); base = zero; orig = pos; - + DYNARR_RESET(track_p,auto_select_da); GetMovedTracks(TRUE); SetMoveD( TRUE, base, 0.0 ); drawCount = 0; @@ -1747,7 +1878,7 @@ static STATUS_T CmdMove( drawEnable = enableMoveDraw; base.x = pos.x - orig.x; base.y = pos.y - orig.y; - SnapPos( &base ); + if ((MyGetKeyState() & WKEY_ALT) == 0) SnapPos( &base ); SetMoveD( TRUE, base, 0.0 ); if (((MyGetKeyState()&(WKEY_ALT)) == 0) == magneticSnap) { // ALT if (FindEndIntersection(base,zero,0.0,&t1,&ep1,&t2,&ep2)) { @@ -1776,6 +1907,7 @@ static STATUS_T CmdMove( } ep1 = -1; ep2 = -1; + RemoveEndCornus(); tlist_da.cnt = 0; return C_TERMINATE; @@ -1805,17 +1937,25 @@ static STATUS_T CmdMove( if ((action>>8) == 'c') { panCenter = pos; LOG( log_pan, 2, ( "PanCenter:Sel-%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); - PanHere((void*)0); + PanHere(I2VP(0)); } if ((action>>8) == 'e') { - DoZoomExtents(0); + DoZoomExtents(I2VP(0)); + } + if ((action>>8 == 's')) { + DoZoomExtents(I2VP(1)); } if ((action>>8) == '0' || (action>>8 == 'o')) { - PanMenuEnter('o'); + PanMenuEnter(I2VP('o')); } + if ((action>>8) == 127 || (action>>8) == 8) + SelectDelete(); break; case C_REDRAW: /* DO_REDRAW */ + //Draw all existing highlight boxes only + DrawHighlightBoxes(FALSE, FALSE, NULL); + HighlightSelectedTracks(NULL, TRUE, TRUE); if (anchors_da.cnt) DrawSegs( &tempD, zero, 0.0, &anchors(0), anchors_da.cnt, trackGauge, wDrawColorBlack ); if ( state == 0 ) @@ -1860,6 +2000,7 @@ static STATUS_T CmdMove( microCount = 0; MainRedraw(); // Micro step move } + RemoveEndCornus(); return C_CONTINUE; } break; @@ -1869,14 +2010,16 @@ static STATUS_T CmdMove( doingMove = FALSE; UndoEnd(); } + RemoveEndCornus(); tlist_da.cnt = 0; break; case C_CONFIRM: case C_CANCEL: if (doingMove) { doingMove = FALSE; - UndoUndo(); + UndoUndo(NULL); } + RemoveEndCornus(); tlist_da.cnt = 0; break; default: @@ -1889,8 +2032,9 @@ static STATUS_T CmdMove( static int rotateAlignState = 0; -static void RotateAlign( BOOL_T align ) +static void RotateAlign( void * alignVP ) { + BOOL_T align = (BOOL_T)VP2L(alignVP); rotateAlignState = 0; if (align) { rotateAlignState = 1; @@ -1951,6 +2095,7 @@ static STATUS_T CmdRotate( return C_TERMINATE; } UndoStart( _("Rotate Tracks"), "rotate" ); + DYNARR_RESET(track_p,auto_select_da); if ( rotateAlignState == 0 ) { drawnAngle = FALSE; angle = 0.0; @@ -2044,7 +2189,7 @@ static STATUS_T CmdRotate( ANGLE_T diff_angle = 0.0; base = pos; drawEnable = enableMoveDraw; - if ( FindDistance( orig, pos ) > (20.0/75.0)*mainD.scale ) { + if ( FindDistance( orig, pos ) > (20.0/BASE_DPI)*mainD.scale ) { ANGLE_T old_angle = angle; angle = FindAngle( orig, pos ); if (!drawnAngle) { @@ -2079,7 +2224,7 @@ static STATUS_T CmdRotate( angle = baseAngle+diff_angle; } Translate( &base, orig, angle, FindDistance(orig,pos) ); //Line one - Translate( &orig_base,orig, baseAngle, FindDistance(orig,pos)<=(60.0/75.00*mainD.scale)?FindDistance(orig,pos):60.0/75.00*mainD.scale ); //Line two + Translate( &orig_base,orig, baseAngle, FindDistance(orig,pos)<=(60.0/BASE_DPI*mainD.scale)?FindDistance(orig,pos):60.0/BASE_DPI*mainD.scale ); //Line two SetMoveD( FALSE, orig, NormalizeAngle( angle-baseAngle ) ); if (((MyGetKeyState()&(WKEY_ALT)) == WKEY_ALT) != magneticSnap) { //Just Shift if (FindEndIntersection(zero,orig,NormalizeAngle( angle-baseAngle ),&t1,&ep1,&t2,&ep2)) { @@ -2127,6 +2272,7 @@ static STATUS_T CmdRotate( } } UndoEnd(); + RemoveEndCornus(); tlist_da.cnt = 0; return C_TERMINATE; @@ -2154,30 +2300,35 @@ static STATUS_T CmdRotate( if ((action>>8) == 'd') { panCenter = pos; LOG( log_pan, 2, ( "PanCenter:Sel-%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); - PanHere((void*)0); + PanHere(I2VP(0)); } if ((action>>8) == 'e') { - DoZoomExtents(0); + DoZoomExtents(I2VP(0)); + } + if ((action>>8) == 's') { + DoZoomExtents(I2VP(1)); } if ((action>>8) == '0' || (action>>8 == 'o')) { - PanMenuEnter('o'); + PanMenuEnter(I2VP('o')); } break; case C_REDRAW: + DrawHighlightBoxes(FALSE,FALSE,NULL); + HighlightSelectedTracks(NULL, TRUE, TRUE); if (anchors_da.cnt) DrawSegs( &tempD, zero, 0.0, &anchors(0), anchors_da.cnt, trackGauge, wDrawColorBlack ); /* DO_REDRAW */ if ( state == 0 ) break; if ( rotateAlignState != 2 ) { - DIST_T width = mainD.scale*0.5; + DIST_T width = tempD.scale*0.15; DrawLine( &tempD, base, orig, 0, wDrawColorBlue ); if (drawnAngle) { - DrawLine( &tempD, orig_base, orig, (wDrawWidth)width, wDrawColorBlue ); + DrawLine( &tempD, orig_base, orig, (wDrawWidth)width/2, wDrawColorBlue ); ANGLE_T a = DifferenceBetweenAngles(FindAngle(orig, orig_base),FindAngle(orig, base)); DIST_T dist = FindDistance(orig,base); - if (dist>(60.0/75.0)*mainD.scale) dist = (60.0/75.0)*mainD.scale; + if (dist>(60.0/BASE_DPI)*mainD.scale) dist = (60.0/BASE_DPI)*mainD.scale; if (direction_set) { if (clockwise) { @@ -2211,6 +2362,7 @@ static STATUS_T CmdRotate( static void QuickMove( void* pos) { coOrd move_pos = *(coOrd*)pos; + DYNARR_RESET(track_p,auto_select_da); if ( SelectedTracksAreFrozen() ) return; wDrawDelayUpdate( mainD.d, TRUE ); @@ -2220,9 +2372,67 @@ static void QuickMove( void* pos) { wDrawDelayUpdate( mainD.d, FALSE ); } +static track_p SelectTrackByIndex(TRKINX_T ti, char * message ) { + track_p trk = FindTrack(ti); + if (trk) { + if (!GetLayerFrozen( GetTrkLayer( trk ) ) ) { + if (GetLayerModule(GetTrkLayer(trk))) { + DoModuleTracks(GetTrkLayer(trk),DrawSingleTrack,TRUE); + snprintf(message, STR_LONG_SIZE, "%s %d",_("In module layer:"),GetTrkLayer(trk)+1); + } else { + if (!GetLayerVisible(GetTrkLayer(trk))) FlipLayer(I2VP(GetTrkLayer(trk))); + if (!GetTrkVisible(trk) && drawTunnel==0 ) drawTunnel = 1; //Force DRAW_TUNNEL_DASH + SelectOneTrack(trk,TRUE); + } + } else { + snprintf(message, STR_LONG_SIZE, "%s %d",_("Frozen Layer:"),GetTrkLayer(trk)+1); + trk = NULL; + } + } else { + snprintf(message, STR_LONG_SIZE, "%s",_("Not found")); + } + return trk; +} + +EXPORT void SelectByIndex( void* string) { + char result[STR_LONG_SIZE] = ""; + char * message; + SetAllTrackSelect(FALSE); + char * cp = (char *)string; + cp = strtok(cp,","); + BOOL_T single = TRUE; + track_p trk = NULL; + while (cp) { + long ti = strtol(cp,&cp,0); + if (ti>0) { + message = MyMalloc(STR_LONG_SIZE); + trk = SelectTrackByIndex(ti, message); + if (!trk || message[0]) { + size_t len = strlen(result); + snprintf(result+len,(sizeof(result) - len),"I:%ld %s", ti, message); + MyFree(message); + } + } + cp = strtok(NULL,","); + if (cp) single = FALSE; + } + + DoZoomExtents(I2VP(1)); + if (strlen(result)) + InfoMessage(result); + else if (single && trk) { + char msg[STR_SIZE]; + DescribeTrack( trk, msg, sizeof msg ); + InfoMessage( msg ); + } else if (!single) { + InfoMessage(_("Multiple Selected")); + } +} + static void QuickRotate( void* pangle ) { - ANGLE_T angle = (ANGLE_T)(long)pangle; + ANGLE_T angle = (ANGLE_T)VP2L(pangle); + DYNARR_RESET(track_p,auto_select_da); if ( SelectedTracksAreFrozen() ) return; wDrawDelayUpdate( mainD.d, TRUE ); @@ -2236,8 +2446,24 @@ static void QuickRotate( void* pangle ) static wMenu_p moveDescM; static wMenuToggle_p moveDescMI; +static wMenuToggle_p moveDetailDescMI; + +static void ChangeDetailedFlag( void * mode ) +{ + wDrawDelayUpdate( mainD.d, TRUE ); + UndoStart( _("Toggle Detail"), "Modedetail( T%d )", GetTrkIndex(moveDescTrk) ); + UndoModify( moveDescTrk ); + UndrawNewTrack( moveDescTrk ); + if ( ( GetTrkBits( moveDescTrk ) & TB_DETAILDESC ) == 0 ) { + ClrTrkBits( moveDescTrk, TB_HIDEDESC ); + SetTrkBits( moveDescTrk, TB_DETAILDESC ); + } else + ClrTrkBits( moveDescTrk, TB_DETAILDESC ); + DrawNewTrack( moveDescTrk ); + wDrawDelayUpdate( mainD.d, FALSE ); +} -static void ChangeDescFlag( wBool_t set, void * mode ) +static void ChangeDescFlag( void * mode ) { wDrawDelayUpdate( mainD.d, TRUE ); UndoStart( _("Toggle Label"), "Modedesc( T%d )", GetTrkIndex(moveDescTrk) ); @@ -2251,9 +2477,13 @@ static void ChangeDescFlag( wBool_t set, void * mode ) wDrawDelayUpdate( mainD.d, FALSE ); } +/* + * Mode_o -1 = everything, 0 = elevations only, 1 = descriptions only + */ + track_p FindTrackDescription(coOrd pos, EPINX_T * ep_o, int * mode_o, BOOL_T show_hidden, BOOL_T * hidden_o) { track_p trk = NULL; - DIST_T d, dd = 10000; + DIST_T d, dd = DIST_INF; track_p trk1 = NULL; EPINX_T ep1=-1, ep=-1; BOOL_T hidden_t, hidden; @@ -2265,6 +2495,8 @@ track_p FindTrackDescription(coOrd pos, EPINX_T * ep_o, int * mode_o, BOOL_T sho continue; if ( (!GetTrkVisible(trk1)) && drawTunnel==0 ) continue; + if ( GetLayerFrozen( GetTrkLayer( trk1 ) )) + continue; if ( (labelEnable&LABELENABLE_ENDPT_ELEV)!=0 && *mode_o <= 0) { for ( ep1=0; ep1