summaryrefslogtreecommitdiff
path: root/app/bin/cselect.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2022-02-06 16:04:24 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2022-02-06 16:04:24 +0100
commit5d2c2b27a6323e2666378b986129b2a7c2c39e5c (patch)
treece8982b6c0111f79791068de2c2d4c6ce3138a49 /app/bin/cselect.c
parentb623f5953691b2a0614e6f1f4def86bdbb9a4113 (diff)
New upstream version 5.2.2GAupstream/5.2.2GA
Diffstat (limited to 'app/bin/cselect.c')
-rw-r--r--app/bin/cselect.c982
1 files changed, 662 insertions, 320 deletions
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 <math.h>
-#include <string.h>
-
+#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; ep<GetTrkEndPtCnt(trk); ep++) {
trk1 = GetTrkEndTrk( trk, ep );
@@ -535,10 +554,12 @@ static void SelectConnectedTracks(
} else TlistAppend( trk1 );
}
}
- if (display_only) DrawTrack(trk,&tempD,wDrawColorPreviewSelected );
+ if (display_only && !GetLayerFrozen(GetTrkLayer(trk))) DrawTrack(trk,&tempD,wDrawColorPreviewSelected );
else if (!GetTrkSelected(trk)) {
if (GetLayerModule(GetTrkLayer(trk))) {
continue;
+ } else if (GetLayerFrozen(GetTrkLayer(trk))) {
+ continue;
} else {
SelectOneTrack( trk, TRUE );
InfoCount( inx+1 );
@@ -572,7 +593,25 @@ static void DrawSingleTrack(track_p trk, BOOL_T bit) {
DrawTrack(trk,&tempD,bit?wDrawColorPreviewSelected:wDrawColorPreviewUnselected);
}
+typedef BOOL_T (*testSelectedTrackCallBack_t)(track_p, int);
+
+
+static BOOL_T TestAllSelectedTracks( testSelectedTrackCallBack_t testit, int value)
+{
+ track_p trk;
+ trk = NULL;
+ while ( TrackIterate( &trk ) ) {
+ if (GetTrkSelected(trk)) {
+ if ( !testit( trk, value ) ) {
+ return FALSE;
+ }
+ }
+ }
+ return TRUE;
+}
+
typedef BOOL_T (*doSelectedTrackCallBack_t)(track_p, BOOL_T);
+
static void DoSelectedTracks( doSelectedTrackCallBack_t doit )
{
track_p trk;
@@ -619,7 +658,7 @@ EXPORT void SelectTrackWidth( void* width )
if (GetTrkSelected(trk)) {
DrawTrackAndEndPts( trk, wDrawColorWhite );
UndoModify( trk );
- SetTrkWidth( trk, (int)(long)width );
+ SetTrkWidth( trk, (int)VP2L(width) );
DrawTrackAndEndPts( trk, wDrawColorBlack );
}
}
@@ -627,8 +666,9 @@ EXPORT void SelectTrackWidth( void* width )
UndoEnd();
}
-EXPORT void SelectLineType( void* width )
+static void SelectLineType( void* widthVP )
{
+ int width = (int)VP2L(widthVP);
track_p trk;
if (SelectedTracksAreFrozen())
return;
@@ -643,11 +683,11 @@ EXPORT void SelectLineType( void* width )
if (GetTrkSelected(trk)) {
UndoModify( trk );
if (QueryTrack(trk, Q_CAN_MODIFY_CONTROL_POINTS))
- SetBezierLineType(trk, (int) (long) width);
+ SetBezierLineType(trk, width);
else if (QueryTrack(trk, Q_IS_DRAW))
- SetLineType( trk, (int)(long)width );
+ SetLineType( trk, width );
else if (QueryTrack(trk, Q_IS_STRUCTURE)) {
- SetCompoundLineType(trk, (int)(long)width);
+ SetCompoundLineType(trk, width);
}
}
}
@@ -657,15 +697,26 @@ EXPORT void SelectLineType( void* width )
static BOOL_T doingDouble;
-EXPORT void SelectDelete( void )
+EXPORT int SelectDelete( void )
{
- if (GetCurrentCommand() != selectCmdInx) return;
- if (doingDouble) return;
+ if (GetCurrentCommand() != selectCmdInx ) {
+ if (GetCurrentCommand() != modifyCmdInx ) {
+ InfoMessage(_("Delete only works in Select Mode"));
+ wBeep();
+ return -1;
+ }
+ }
+
+ if (doingDouble || (GetCurrentCommand() == modifyCmdInx)) return 1;
if (SelectedTracksAreFrozen())
- return;
+ return 0;
if (selectedTrackCount>0) {
- 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; ep<GetTrkEndPtCnt(trk); ep++ ) {
@@ -850,7 +924,7 @@ static BOOL_T ClearElevation( track_p trk, BOOL_T junk )
return TRUE;
}
-EXPORT void ClearElevations( void )
+EXPORT void ClearElevations( void * unused )
{
if (SelectedTracksAreFrozen())
return;
@@ -866,7 +940,7 @@ EXPORT void ClearElevations( void )
static DIST_T elevDelta;
-static BOOL_T AddElevation( track_p trk, BOOL_T junk )
+static BOOL_T AddElevation( track_p trk, BOOL_T unused )
{
track_p trk1;
EPINX_T ep, ep1;
@@ -909,7 +983,7 @@ EXPORT void AddElevations( DIST_T delta )
}
-EXPORT void DoRefreshCompound( void )
+EXPORT void DoRefreshCompound( void * unused )
{
if (SelectedTracksAreFrozen())
return;
@@ -961,11 +1035,11 @@ static paramData_t rescalePLs[] = {
#define I_RESCALE_MODE (0)
{ PD_RADIO, &rescaleMode, "toggle", PDO_NOPREF, &rescaleToggleLabels, N_("Rescale by:"), BC_HORZ|BC_NOBORDER },
#define I_RESCALE_FROM_SCALE (1)
- { PD_STRING, rescaleFromScale, "fromS", PDO_NOPREF|PDO_STRINGLIMITLENGTH, (void*)100, N_("From:"),0, 0, sizeof(rescaleFromScale)},
+ { PD_STRING, rescaleFromScale, "fromS", PDO_NOPREF|PDO_STRINGLIMITLENGTH, I2VP(100), N_("From:"),0, 0, sizeof(rescaleFromScale)},
#define I_RESCALE_FROM_GAUGE (2)
- { PD_STRING, rescaleFromGauge, "fromG", PDO_NOPREF|PDO_DLGHORZ | PDO_STRINGLIMITLENGTH, (void*)100, " / ", 0, 0, sizeof(rescaleFromGauge)},
+ { PD_STRING, rescaleFromGauge, "fromG", PDO_NOPREF|PDO_DLGHORZ | PDO_STRINGLIMITLENGTH, I2VP(100), " / ", 0, 0, sizeof(rescaleFromGauge)},
#define I_RESCALE_TO_SCALE (3)
- { PD_DROPLIST, &rescaleToScaleInx, "toS", PDO_NOPREF|PDO_LISTINDEX, (void *)100, N_("To: ") },
+ { PD_DROPLIST, &rescaleToScaleInx, "toS", PDO_NOPREF|PDO_LISTINDEX, I2VP(100), N_("To: ") },
#define I_RESCALE_TO_GAUGE (4)
{ PD_DROPLIST, &rescaleToGaugeInx, "toG", PDO_NOPREF|PDO_LISTINDEX|PDO_DLGHORZ, NULL, " / " },
#define I_RESCALE_CHANGE (5)
@@ -973,13 +1047,13 @@ static paramData_t rescalePLs[] = {
#define I_RESCALE_PERCENT (6)
{ PD_FLOAT, &rescalePercent, "ratio", 0, &r0o001_10000, N_("Ratio") },
{ PD_MESSAGE, "%", NULL, PDO_DLGHORZ } };
-static paramGroup_t rescalePG = { "rescale", 0, rescalePLs, sizeof rescalePLs/sizeof rescalePLs[0] };
+static paramGroup_t rescalePG = { "rescale", 0, rescalePLs, COUNT( rescalePLs ) };
static long getboundsCount;
static coOrd getboundsLo, getboundsHi;
-static BOOL_T GetboundsDoIt( track_p trk, BOOL_T junk )
+static BOOL_T GetboundsDoIt( track_p trk, BOOL_T unused )
{
coOrd hi, lo;
@@ -998,7 +1072,7 @@ static BOOL_T GetboundsDoIt( track_p trk, BOOL_T junk )
}
static coOrd rescaleShift;
-static BOOL_T RescaleDoIt( track_p trk, BOOL_T junk )
+static BOOL_T RescaleDoIt( track_p trk, BOOL_T unused )
{
EPINX_T ep, ep1;
track_p trk1;
@@ -1026,7 +1100,7 @@ static BOOL_T RescaleDoIt( track_p trk, BOOL_T junk )
static void RescaleDlgOk(
- void * junk )
+ void * unused )
{
coOrd center, size;
DIST_T d;
@@ -1073,6 +1147,19 @@ static void RescaleDlgOk(
rescaleToInx = GetScaleInx( rescaleToScaleInx, rescaleToGaugeInx );
DoSelectedTracks( RescaleDoIt );
+
+ // rescale the background if it exists and the layout is resized
+ if (HasBackGround() && ratio != 1.0) {
+ coOrd pos = GetLayoutBackGroundPos();
+ double size = GetLayoutBackGroundSize();
+ pos.x = ratio * pos.x + rescaleShift.x;
+ pos.y = ratio * pos.y + rescaleShift.y;
+ SetLayoutBackGroundPos(pos);
+
+ size *= ratio;
+ SetLayoutBackGroundSize(size);
+ }
+ DoRedraw();
wHide( rescalePG.win );
}
@@ -1126,11 +1213,11 @@ static void RescaleDlgUpdate(
* FIXME: special cases like tracks pieces with different gauges or scale need to be handled
*
* \param IN trk track element
- * \param IN junk
+ * \param IN unused
* \return TRUE;
*/
-static BOOL_T SelectedScaleGauge( track_p trk, BOOL_T junk )
+static BOOL_T SelectedScaleGauge( track_p trk, BOOL_T unused )
{
char *scaleName;
SCALEINX_T scale;
@@ -1159,7 +1246,7 @@ static BOOL_T SelectedScaleGauge( track_p trk, BOOL_T junk )
* RescaleDlgUpdate()
*/
-EXPORT void DoRescale( void )
+EXPORT void DoRescale( void * unused )
{
if ( rescalePG.win == NULL ) {
ParamCreateDialog( &rescalePG, MakeWindowTitle(_("Rescale")), _("Ok"), RescaleDlgOk, wHide, TRUE, NULL, F_BLOCK, RescaleDlgUpdate );
@@ -1200,21 +1287,35 @@ static void DrawSelectedTracksD( drawCmd_p d, wDrawColor color )
}
if (color != wDrawColorWhite)
ClrTrkBits(trk, TB_UNDRAWN);
- DrawTrack( trk, d, color );
if (color == wDrawColorWhite)
SetTrkBits( trk, TB_UNDRAWN );
}
+ MainRedraw(); //Omitting all the tracks with TB_UNDRAWN set
/*wDrawDelayUpdate( d->d, 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<tlist_da.cnt; i++) {
+ if (DYNARR_N(track_p,tlist_da,i) == trk) {
+ for (int j=i;j<tlist_da.cnt-1;j++) {
+ DYNARR_N(track_p,tlist_da,j) = DYNARR_N(track_p,tlist_da,j+1);
+ }
+ tlist_da.cnt--;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
static coOrd moveOrig;
static ANGLE_T moveAngle;
@@ -1257,6 +1358,8 @@ static void AccumulateTracks( void )
/*wDrawDelayUpdate( moveD.d, FALSE );*/
}
+static dynArr_t auto_select_da;
+
static void AddEndCornus() {
for (int i=0;i<tlist_da.cnt;i++) {
track_p trk = DYNARR_N(track_p,tlist_da,i);
@@ -1267,11 +1370,23 @@ static void AddEndCornus() {
SelectOneTrack( tc, TRUE );
DYNARR_APPEND(track_p,tlist_da,1); //Add to selected list
DYNARR_LAST(track_p,tlist_da) = tc;
+ DYNARR_APPEND(track_p,auto_select_da,1);
+ DYNARR_LAST(track_p,auto_select_da) = tc;
}
}
}
}
+static void RemoveEndCornus() {
+ track_p tc;
+ for (int i=0;i<auto_select_da.cnt;i++) {
+ tc = DYNARR_N(track_p,auto_select_da,i);
+ SelectOneTrack( tc, FALSE );
+ RemoveSelectedTrack(tc);
+ }
+ DYNARR_RESET(track_p,auto_select_da);
+}
+
static void GetMovedTracks( BOOL_T undraw )
{
@@ -1343,7 +1458,7 @@ static void DrawMovedTracks( void )
dynArr_t cornu_segs;
DrawSegs( &tempD, moveOrig, moveAngle, &tempSegs(0), tempSegs_da.cnt,
- 0.0, wDrawColorBlack );
+ 0.0, selectedColor );
for ( inx=0; inx<tlist_da.cnt; inx++ ) {
trk = Tlist(inx);
@@ -1377,7 +1492,7 @@ static void DrawMovedTracks( void )
trkSeg_p cornu_p = &DYNARR_N(trkSeg_t,cornu_segs,0);
DrawSegsO(&tempD, trk, zero, 0.0, cornu_p,cornu_segs.cnt,
- GetTrkGauge(trk), wDrawColorBlack, DTS_LEFT|DTS_RIGHT );
+ GetTrkGauge(trk), selectedColor, DTS_LEFT|DTS_RIGHT );
}
}
@@ -1413,20 +1528,37 @@ static void MoveTracks(
DrawSelectedTracksD( &mapD, wDrawColorWhite );
}
}
+ //Do non-Cornu first to establish new end-points
+ for ( inx=0; inx<tlist_da.cnt; inx++ ) {
+ trk = Tlist(inx);
+ UndoModify( trk );
+ if (QueryTrack(trk, Q_IS_CORNU)) continue;
+ if (move)
+ MoveTrack( trk, base );
+ if (rotate)
+ RotateTrack( trk, orig, angle );
+ for (ep=0; ep<GetTrkEndPtCnt(trk); ep++) {
+ if ((trk1 = GetTrkEndTrk(trk,ep)) != NULL &&
+ !GetTrkSelected(trk1)) {
+ ep1 = GetEndPtConnectedToMe( trk1, trk );
+ DisconnectTracks( trk, ep, trk1, ep1 );
+ DrawEndPt( &mainD, trk1, ep1, wDrawColorBlack );
+ }
+ }
+ }
+ //Now do the just Cornus - to reset to where the fixed parts ended up
for ( inx=0; inx<tlist_da.cnt; inx++ ) {
trk = Tlist(inx);
UndoModify( trk );
BOOL_T fixed_end;
fixed_end = FALSE;
- if (QueryTrack(trk, Q_IS_CORNU)) {
- for (int i=0;i<2;i++) {
- track_p te;
- if ((te = GetTrkEndTrk(trk,i)) && !GetTrkSelected(te)) {
- fixed_end = TRUE;
- }
+ if (!QueryTrack(trk, Q_IS_CORNU)) continue;
+ for (int i=0;i<2;i++) {
+ track_p te;
+ if ((te = GetTrkEndTrk(trk,i)) && !GetTrkSelected(te)) {
+ fixed_end = TRUE;
}
}
-
if (!fixed_end) {
if (move)
MoveTrack( trk, base );
@@ -1441,65 +1573,64 @@ static void MoveTracks(
}
}
} else {
- if (QueryTrack(trk, Q_IS_CORNU)) { //Cornu will be at the end of selected set
- for (int i=0;i<2;i++) {
- if ((trk1 = GetTrkEndTrk(trk,i)) && GetTrkSelected(trk1)) {
- ep1 = GetEndPtConnectedToMe( trk1, trk );
- DisconnectTracks(trk,i,trk1,ep1);
- GetTrackParams(PARAMS_CORNU,trk1,GetTrkEndPos(trk1,ep1),&trackParms);
- if (trackParms.type == curveTypeStraight) {
- endRadius = 0;
- endCenter = zero;
- } else {
- endRadius = trackParms.arcR;
- endCenter = trackParms.arcP;
- }
- DrawTrack(trk,&mainD,wDrawColorWhite);
- DrawTrack(trk,&mapD,wDrawColorWhite);
- endAngle = NormalizeAngle(GetTrkEndAngle(trk1,ep1)+180);
- if (SetCornuEndPt(trk,i,GetTrkEndPos(trk1,ep1),endCenter,endAngle,endRadius)) {
- ConnectTracks(trk,i,trk1,ep1);
- DrawTrack(trk,&mainD,wDrawColorBlack);
- DrawTrack(trk,&mapD,wDrawColorBlack);
- } else {
- DeleteTrack(trk,TRUE);
- ErrorMessage(_("Cornu too tight - it was deleted"));
- DoRedraw(); // MoveTracks: Cornu/delete
- return;
- }
- } else if (!trk1) { //No end track
- DrawTrack(trk,&mainD,wDrawColorWhite);
- DrawTrack(trk,&mapD,wDrawColorWhite);
- GetTrackParams(PARAMS_CORNU,trk,GetTrkEndPos(trk,i),&trackParms);
- if (move) {
- coOrd end_pos, end_center;
- end_pos = trackParms.cornuEnd[i];
- end_pos.x += base.x;
- end_pos.y += base.y;
- end_center = trackParms.cornuCenter[i];
- end_center.x += base.x;
- end_center.y += base.y;
- SetCornuEndPt(trk,i,end_pos,end_center,trackParms.cornuAngle[i],trackParms.cornuRadius[i]);
- }
- if (rotate) {
- coOrd end_pos, end_center;
- ANGLE_T end_angle;
- end_pos = trackParms.cornuEnd[i];
- end_center = trackParms.cornuCenter[i];
- Rotate(&end_pos, orig, angle);
- Rotate(&end_center, orig, angle);
- end_angle = NormalizeAngle( trackParms.cornuAngle[i] + angle );
- SetCornuEndPt(trk,i,end_pos,end_center,end_angle,trackParms.cornuRadius[i]);
- }
+ for (int i=0;i<2;i++) {
+ if ((trk1 = GetTrkEndTrk(trk,i)) && GetTrkSelected(trk1)) {
+ ep1 = GetEndPtConnectedToMe( trk1, trk );
+ DisconnectTracks(trk,i,trk1,ep1);
+ GetTrackParams(PARAMS_CORNU,trk1,GetTrkEndPos(trk1,ep1),&trackParms);
+ if (trackParms.type == curveTypeStraight) {
+ endRadius = 0;
+ endCenter = zero;
+ } else {
+ endRadius = trackParms.arcR;
+ endCenter = trackParms.arcP;
+ }
+ DrawTrack(trk,&mainD,wDrawColorWhite);
+ DrawTrack(trk,&mapD,wDrawColorWhite);
+ endAngle = NormalizeAngle(GetTrkEndAngle(trk1,ep1)+180);
+ if (SetCornuEndPt(trk,i,GetTrkEndPos(trk1,ep1),endCenter,endAngle,endRadius)) {
+ ConnectTracks(trk,i,trk1,ep1);
DrawTrack(trk,&mainD,wDrawColorBlack);
DrawTrack(trk,&mapD,wDrawColorBlack);
+ } else {
+ DeleteTrack(trk,TRUE);
+ ErrorMessage(_("Cornu too tight - it was deleted"));
+ DoRedraw(); // MoveTracks: Cornu/delete
+ continue;
+ }
+ } else if (!trk1) { //No end track
+ DrawTrack(trk,&mainD,wDrawColorWhite);
+ DrawTrack(trk,&mapD,wDrawColorWhite);
+ GetTrackParams(PARAMS_CORNU,trk,GetTrkEndPos(trk,i),&trackParms);
+ if (move) {
+ coOrd end_pos, end_center;
+ end_pos = trackParms.cornuEnd[i];
+ end_pos.x += base.x;
+ end_pos.y += base.y;
+ end_center = trackParms.cornuCenter[i];
+ end_center.x += base.x;
+ end_center.y += base.y;
+ SetCornuEndPt(trk,i,end_pos,end_center,trackParms.cornuAngle[i],trackParms.cornuRadius[i]);
}
+ if (rotate) {
+ coOrd end_pos, end_center;
+ ANGLE_T end_angle;
+ end_pos = trackParms.cornuEnd[i];
+ end_center = trackParms.cornuCenter[i];
+ Rotate(&end_pos, orig, angle);
+ Rotate(&end_center, orig, angle);
+ end_angle = NormalizeAngle( trackParms.cornuAngle[i] + angle );
+ SetCornuEndPt(trk,i,end_pos,end_center,end_angle,trackParms.cornuRadius[i]);
+ }
+ DrawTrack(trk,&mainD,wDrawColorBlack);
+ DrawTrack(trk,&mapD,wDrawColorBlack);
}
}
}
InfoCount( inx );
}
+ RemoveEndCornus();
ClrAllTrkBits(TB_UNDRAWN);
DoRedraw();
wSetCursor( mainD.d, defaultCursor );
@@ -1534,6 +1665,7 @@ void MoveToJoin(
ConnectTracks( trk0, ep0, trk1, ep1 );
DrawNewTrack( trk0 );
DrawNewTrack( trk1 );
+ RemoveEndCornus();
}
void FreeTempStrings() {
@@ -1627,23 +1759,22 @@ void DrawHighlightLayer(int layer) {
if (layer_lo.y > 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<GetTrkEndPtCnt(trk1); ep1++ ) {
d = EndPtDescriptionDistance( pos, trk1, ep1, &dpos, FALSE, NULL ); //No hidden
@@ -2278,7 +2510,8 @@ track_p FindTrackDescription(coOrd pos, EPINX_T * ep_o, int * mode_o, BOOL_T sho
}
}
}
- if ( !QueryTrack( trk1, Q_HAS_DESC ) && (mode <0 || mode > 0) )
+ if (IsClose(dd)) break;
+ if ( *mode_o == 0 || !QueryTrack( trk1, Q_HAS_DESC ) )
continue;
if ((labelEnable&LABELENABLE_TRKDESC)==0)
continue;
@@ -2321,15 +2554,47 @@ track_p FindTrackDescription(coOrd pos, EPINX_T * ep_o, int * mode_o, BOOL_T sho
hidden = hidden_t;
cpos = dpos;
}
+ d = StraightDescriptionDistance( pos, trk1, &dpos, show_hidden, &hidden_t );
+ if (d < dd ) {
+ dd = d;
+ trk = trk1;
+ ep = -1;
+ mode = 5;
+ hidden = hidden_t;
+ cpos = dpos;
+ }
+ d = JointDescriptionDistance( pos, trk1, &dpos, show_hidden, &hidden_t );
+ if (d < dd ) {
+ dd = d;
+ trk = trk1;
+ ep = -1;
+ mode = 6;
+ hidden = hidden_t;
+ cpos = dpos;
+ }
+
}
- if ((trk != NULL && (trk == OnTrack(&pos, FALSE, FALSE))) ||
- IsClose(d) || IsClose(FindDistance( pos, cpos) )) { //Only when close to a label or the track - not anywhere on layout!
+
+ coOrd pos1 = pos;
+
+ if ((trk != NULL) && IsClose(dd) ) {
if (ep_o) *ep_o = ep;
if (mode_o) *mode_o = mode;
if (hidden_o) *hidden_o = hidden;
return trk;
+ } else { // Return other track for description (not near to description but nearest to track)
+ if ((trk1 = OnTrack(&pos1, FALSE, FALSE))==NULL) return NULL;
+ if (!QueryTrack( trk1, Q_HAS_DESC )) return NULL;
+ if (GetLayerFrozen(GetTrkLayer(trk1))) return NULL;
+ if (IsClose(FindDistance(pos,pos1))) {
+ if (mode_o) *mode_o = -1;
+ if (ep_o) *ep_o = -1;
+ if (hidden_o) *hidden_o = GetTrkBits( trk1 ) & TB_HIDEDESC;
+ return trk1;
+ }
}
- else return NULL;
+
+ return NULL;
}
static long moveDescMode;
@@ -2338,31 +2603,55 @@ STATUS_T CmdMoveDescription(
wAction_t action,
coOrd pos )
{
- static track_p trk;
static EPINX_T ep;
static BOOL_T hidden;
static int mode;
BOOL_T bChanged;
- moveDescMode = (long)commandContext; //Context 0 = everything, 1 means elevations, 2 means descriptions
+ moveDescMode = VP2L(commandContext); //Context 0 = everything, 1 means elevations, 2 means descriptions
bChanged = FALSE;
switch (action&0xFF) {
case C_START:
moveDescTrk = NULL;
moveDescPos = zero;
- trk = NULL;
hidden = FALSE;
mode = -1;
if ( labelWhen < 2 || mainD.scale > labelScale ||
(labelEnable&(LABELENABLE_TRKDESC|LABELENABLE_ENDPT_ELEV))==0 ) {
ErrorMessage( MSG_DESC_NOT_VISIBLE );
- return C_TERMINATE;
+ return C_ERROR;
}
- InfoMessage( _("Select and drag a description") );
- break;
+ SetAllTrackSelect( FALSE );
+ /* no break */
+ case wActionMove:
+ if ( labelWhen < 2 || mainD.scale > labelScale ) return C_CONTINUE;
+ mode = moveDescMode-1; // -1 means everything, 0 means elevations only, 1 means descriptions only
+ if ((moveDescTrk=FindTrackDescription(pos,&ep,&mode,TRUE,&hidden))!=NULL) {
+ if (mode==0) {
+ InfoMessage(_("Elevation description"));
+ } else {
+ if (moveDescMode == 1) {
+ moveDescTrk = NULL;
+ return C_CONTINUE; //Ignore other tracks if only looking for elevations
+ }
+ if (hidden) {
+ InfoMessage(_("Hidden description - 's' to Show, 'd' Details"));
+ moveDescPos = pos;
+ } else {
+ InfoMessage(_("Shown description - 'h' to Hide"));
+ moveDescPos = pos;
+ }
+ }
+ return C_CONTINUE;
+ } else {
+ moveDescTrk = NULL;
+ }
+ InfoMessage( _("Select and drag a description") );
+ break;
case C_TEXT:
if (!moveDescTrk) return C_CONTINUE;
+ if (mode == 0) return C_CONTINUE;
bChanged = FALSE;
if (action>>8 == 's') {
if ( ( GetTrkBits( moveDescTrk ) & TB_HIDEDESC) != 0 )
@@ -2372,97 +2661,105 @@ STATUS_T CmdMoveDescription(
if ( ( GetTrkBits( moveDescTrk ) & TB_HIDEDESC) == 0 )
bChanged = TRUE;
SetTrkBits( moveDescTrk, TB_HIDEDESC );
+ ClrTrkBits( moveDescTrk, TB_DETAILDESC );
+ } else if (action>>8 == 'd') { //Toggle Detailed
+ bChanged = TRUE;
+ if ((GetTrkBits( moveDescTrk ) & TB_DETAILDESC) != 0)
+ ClrTrkBits( moveDescTrk, TB_DETAILDESC);
+ else {
+ ClrTrkBits( moveDescTrk, TB_HIDEDESC );
+ SetTrkBits( moveDescTrk, TB_DETAILDESC );
+ }
}
if ( bChanged ) {
- // We should push the draw/undraw of the description down
- // but there is no clear way to do that
- MainRedraw(); // CmdMoveDescription
- }
- /*no break*/
- case wActionMove:
- if ( labelWhen < 2 || mainD.scale > labelScale ) return C_CONTINUE;
- mode = moveDescMode-1; // -1 means everything, 0 means elevations only, 1 means descriptions only
- if ((trk=FindTrackDescription(pos,&ep,&mode,TRUE,&hidden))!=NULL) {
- if (mode==0) {
- InfoMessage(_("Elevation description"));
- } else {
- if (hidden) {
- InfoMessage(_("Hidden description - 's' to Show"));
- moveDescTrk = trk;
- moveDescPos = pos;
- } else {
- InfoMessage(_("Shown description - 'h' to Hide"));
- moveDescTrk = trk;
- moveDescPos = pos;
- }
- }
- return C_CONTINUE;
+ return C_TERMINATE;
}
- InfoMessage( _("Select and drag a description") );
break;
case C_DOWN:
if (( labelWhen < 2 || mainD.scale > labelScale ) ||
(labelEnable&(LABELENABLE_TRKDESC|LABELENABLE_ENDPT_ELEV))==0 ) {
ErrorMessage( MSG_DESC_NOT_VISIBLE );
- return C_TERMINATE;
+ return C_ERROR;
}
mode = moveDescMode-1;
- trk = FindTrackDescription(pos,&ep,&mode,TRUE,&hidden);
- if (trk == NULL )
+ moveDescTrk = FindTrackDescription(pos,&ep,&mode,TRUE,&hidden);
+ if (moveDescTrk == NULL )
return C_CONTINUE;
if (hidden) {
- ClrTrkBits( trk, TB_HIDEDESC );
InfoMessage(_("Hidden Label - Drag to reveal"));
} else {
InfoMessage(_("Drag label"));
}
- UndoStart( _("Move Label"), "Modedesc( T%d )", GetTrkIndex(trk) );
- UndoModify( trk );
+ if (ep == -1 )
+ DrawTrack( moveDescTrk, &mainD, wDrawColorWhite );
/* no break */
case C_MOVE:
+ if (moveDescTrk == NULL )
+ return C_CONTINUE;
+ UndoStart( _("Move Label"), "Modedesc( T%d )", GetTrkIndex(moveDescTrk) );
+ UndoModify( moveDescTrk );
+ ClrTrkBits( moveDescTrk, TB_HIDEDESC );
+ hidden = FALSE;
+ /* no break */
case C_UP:
- case C_REDRAW:
if ( labelWhen < 2 || mainD.scale > labelScale )
- return C_TERMINATE;
- if ( trk == NULL )
return C_CONTINUE;
- STATUS_T status = C_ERROR;
- if ( action == C_REDRAW ) {
- if (mode==0) {
- DrawEndPt2( &tempD, trk, ep, wDrawColorBlue );
- } else {
- if (hidden) {
- DrawTrack( trk,&tempD,wDrawColorAqua);
- } else {
- DrawTrack( trk,&tempD,wDrawColorBlue);
- }
- }
- }
+ if ( moveDescTrk == NULL )
+ return C_CONTINUE;
+ int rc = C_CONTINUE;
switch (mode) {
case 0:
- return EndPtDescriptionMove( trk, ep, action, pos );
+ rc = EndPtDescriptionMove( moveDescTrk, ep, action, pos );
+ break;
case 1:
- return CompoundDescriptionMove( trk, action, pos );
+ rc = CompoundDescriptionMove( moveDescTrk, action, pos );
+ break;
case 2:
- return CurveDescriptionMove( trk, action, pos );
+ rc = CurveDescriptionMove( moveDescTrk, action, pos );
+ break;
case 3:
- return CornuDescriptionMove( trk, action, pos );
+ rc = CornuDescriptionMove( moveDescTrk, action, pos );
+ break;
case 4:
- return BezierDescriptionMove( trk, action, pos );
+ rc = BezierDescriptionMove( moveDescTrk, action, pos );
+ break;
+ case 5:
+ rc = StraightDescriptionMove( moveDescTrk, action, pos);
+ break;
+ case 6:
+ rc = JointDescriptionMove( moveDescTrk, action, pos);
+ break;
}
hidden = FALSE;
if ( action == C_UP ) {
- trk = NULL;
+ moveDescTrk = NULL;
InfoMessage(_("To Hide, use Context Menu"));
+ return C_TERMINATE;
+ }
+ break;
+ case C_REDRAW:
+ if ( labelWhen < 2 || mainD.scale > labelScale )
+ return C_CONTINUE;
+ if ( moveDescTrk ) {
+ if (mode==0) {
+ DrawEndPt2( &tempD, moveDescTrk, ep, drawColorPreviewSelected );
+ } else {
+ if (hidden) {
+ DrawTrack( moveDescTrk,&tempD,wDrawColorAqua);
+ } else {
+ DrawTrack( moveDescTrk,&tempD,drawColorPreviewSelected);
+ }
+ }
}
break;
-
case C_CMDMENU:
- if (trk == NULL) {
- moveDescTrk = OnTrack( &pos, TRUE, FALSE );
+ if (moveDescTrk != NULL && mode !=0) {
+ if ( GetLayerFrozen( GetTrkLayer( moveDescTrk ) ) ) {
+ moveDescTrk = NULL;
+ break;
+ }
moveDescPos = pos;
} else {
- moveDescTrk = trk;
moveDescPos = pos;
}
if ( moveDescTrk == NULL ) break;
@@ -2470,8 +2767,10 @@ STATUS_T CmdMoveDescription(
if ( moveDescM == NULL ) {
moveDescM = MenuRegister( "Move Desc Toggle" );
moveDescMI = wMenuToggleCreate( moveDescM, "", _("Show/Hide Description"), 0, TRUE, ChangeDescFlag, NULL );
+ moveDetailDescMI = wMenuToggleCreate( moveDescM, "", _("Toggle Detailed Description"), 0, TRUE, ChangeDetailedFlag, NULL );
}
- wMenuToggleSet( moveDescMI, ( GetTrkBits( moveDescTrk ) & TB_HIDEDESC ) == 0 );
+ wMenuToggleSet( moveDescMI, !( GetTrkBits( moveDescTrk ) & TB_HIDEDESC ) );
+ wMenuToggleSet( moveDetailDescMI, ( GetTrkBits( moveDescTrk ) & TB_DETAILDESC ) );
menuPos = pos;
wMenuPopupShow( moveDescM );
break;
@@ -2572,6 +2871,8 @@ static STATUS_T CmdFlip(
case C_CANCEL:
#endif
case C_REDRAW:
+ DrawHighlightBoxes(FALSE,FALSE,NULL);
+ HighlightSelectedTracks(NULL, TRUE, TRUE);
if ( state == 0 )
return C_CONTINUE;
DrawLine( &tempD, pos0, pos1, 0, wDrawColorBlack );
@@ -2654,7 +2955,9 @@ static BOOL_T SelectArea(
lo.x >= base.x && hi.x <= base.x+size.x &&
lo.y >= base.y && hi.y <= base.y+size.y) {
if ( (GetTrkSelected( trk )==0) == (action==C_UP) ) {
- if (GetLayerModule(GetTrkLayer(trk))) {
+ if (GetLayerFrozen(GetTrkLayer(trk))) {
+ continue;
+ } else if (GetLayerModule(GetTrkLayer(trk))) {
if (add)
DoModuleTracks(GetTrkLayer(trk),SelectOneTrack,TRUE);
else
@@ -2693,12 +2996,14 @@ static BOOL_T SelectArea(
break;
//Draw to-be selected tracks versus not.
trk = NULL;
- if (selectMode == 0 && add) HighlightSelectedTracks(NULL, TRUE, TRUE);
+ if (selectMode == 1 && add) HighlightSelectedTracks(NULL, TRUE, TRUE);
while ( TrackIterate( &trk ) ) {
GetBoundingBox( trk, &hi, &lo );
if (GetLayerVisible( GetTrkLayer( trk ) ) &&
lo.x >= base.x && hi.x <= base.x+size.x &&
lo.y >= base.y && hi.y <= base.y+size.y) {
+ if (GetLayerFrozen(GetTrkLayer(trk)))
+ continue;
if (GetLayerModule(GetTrkLayer(trk))) {
if (add)
DoModuleTracks(GetTrkLayer(trk),DrawSingleTrack,TRUE);
@@ -2745,6 +3050,13 @@ static STATUS_T SelectTrack(
return C_CONTINUE;
}
if (trk == NULL) return C_CONTINUE;
+ if (!CheckTrackLayerSilent( trk ) ) {
+ if (GetLayerFrozen(GetTrkLayer(trk)) ) {
+ trk = NULL;
+ InfoMessage(_("Track is in Frozen Layer"));
+ return C_CONTINUE;
+ }
+ }
inDescribeCmd = FALSE;
DescribeTrack( trk, msg, sizeof msg );
InfoMessage( msg );
@@ -2830,12 +3142,11 @@ void DrawHighlightBoxes(BOOL_T highlight_selected, BOOL_T select, track_p not_th
coOrd size;
size.x = max.x-origin.x;
size.y = max.y-origin.y;
- wPos_t w,h;
- w = (wPos_t)((size.x/mainD.scale)*mainD.dpi+0.5+10);
- h = (wPos_t)((size.y/mainD.scale)*mainD.dpi+0.5+10);
- wPos_t x, y;
- tempD.CoOrd2Pix(&tempD,origin,&x,&y);
- wDrawFilledRectangle(tempD.d, x-5, y-5, w, h, wDrawColorPowderedBlue, wDrawOptTemp|wDrawOptTransparent);
+ origin.x -= 5*tempD.scale/tempD.dpi;
+ origin.y -= 5*tempD.scale/tempD.dpi;
+ size.x += 10*tempD.scale/tempD.dpi;
+ size.y += 10*tempD.scale/tempD.dpi;
+ DrawRectangle( &tempD, origin, size, wDrawColorPowderedBlue, DRAW_TRANSPARENT );
}
}
@@ -2853,7 +3164,7 @@ static STATUS_T CallDescribe(wAction_t action, coOrd pos) {
return rc;
}
-static void CallPushDescribe(void * func) {
+static void CallPushDescribe(void * unused) {
if (moveDescTrk) {
CallDescribe(C_START, moveDescPos);
CallDescribe(C_DOWN, moveDescPos);
@@ -2864,7 +3175,7 @@ static void CallPushDescribe(void * func) {
static STATUS_T CmdSelect(wAction_t,coOrd);
-static void CallPushModify(void * func) {
+static void CallPushModify(void * unused) {
if (moveDescTrk) {
CmdSelect(C_LDOUBLE, moveDescPos);
}
@@ -2900,7 +3211,6 @@ static STATUS_T CmdSelect(
}
}
-
switch (action&0xFF) {
case C_START:
InfoMessage( _("Select track") );
@@ -2949,13 +3259,14 @@ static STATUS_T CmdSelect(
CreateModifyAnchor(pos);
showMode = SHOWMODIFY;
} else {
- if (QueryTrack(ht,Q_IS_ACTIVATEABLE))
+ if (QueryTrack(ht,Q_IS_ACTIVATEABLE)) {
CreateActivateAnchor(pos);
showMode = SHOWACTIVATE;
+ } else wSetCursor(mainD.d,defaultCursor);
}
- }
- }
- }
+ } else wSetCursor(mainD.d,defaultCursor);
+ } else wSetCursor(mainD.d,defaultCursor);
+ } else wSetCursor(mainD.d,defaultCursor);
break;
case C_DOWN:
@@ -2965,7 +3276,6 @@ static STATUS_T CmdSelect(
}
DYNARR_RESET(trkSeg_t,anchors_da);
switch (mode) {
- rc = C_CONTINUE;
case MOVE:
if (SelectedTracksAreFrozen() || (selectedTrackCount==0)) {
rc = C_TERMINATE;
@@ -2973,7 +3283,7 @@ static STATUS_T CmdSelect(
} else if ((MyGetKeyState()&(WKEY_CTRL|WKEY_SHIFT))==WKEY_CTRL) {
doingRotate = TRUE;
doingMove = FALSE;
- RotateAlign( FALSE );
+ RotateAlign( I2VP(FALSE) );
rc = CmdRotate( action, pos );
} else if ((MyGetKeyState()&(WKEY_SHIFT|WKEY_CTRL))==WKEY_SHIFT) {
doingMove = TRUE;
@@ -2992,6 +3302,11 @@ static STATUS_T CmdSelect(
return rc;
break;
case wActionExtKey:
+ if ((action>>8)==wAccelKey_Del) {
+ SelectDelete();
+ break;
+ }
+ /* No Break */
case C_RMOVE:
case C_MOVE:
if (doingDouble) {
@@ -3010,7 +3325,7 @@ static STATUS_T CmdSelect(
doingMove = FALSE;
doingRotate = FALSE;
} else if (doingRotate == TRUE) {
- RotateAlign( FALSE );
+ RotateAlign( I2VP(FALSE) );
rc = CmdRotate( action, pos );
} else if (doingMove == TRUE) {
rc = CmdMove( action, pos );
@@ -3040,7 +3355,7 @@ static STATUS_T CmdSelect(
doingMove = FALSE;
doingRotate = FALSE;
} else if (doingRotate == TRUE) {
- RotateAlign( FALSE );
+ RotateAlign( I2VP(FALSE) );
rc = CmdRotate( action, pos );
} else if (doingMove == TRUE) {
rc = CmdMove( action, pos );
@@ -3061,6 +3376,11 @@ static STATUS_T CmdSelect(
break;
case C_REDRAW:
+ if ( trk != NULL && IsTrackDeleted(trk) ) {
+ // If the track is deleted, then trk should be cleared
+ // TODO: This should be done at the point trk is deleted
+ trk = NULL;
+ }
if (doingDouble) {
return CallModify(action,pos);
}
@@ -3097,20 +3417,26 @@ static STATUS_T CmdSelect(
DrawHighlightBoxes(FALSE, FALSE, trk);
// If not on a track, show all tracks as going to be de-selected if selectZero on
- if (!trk && selectZero ) {
- HighlightSelectedTracks(NULL, TRUE, TRUE);
- //Handle the SHIFT+ which means SelectAllConnected case
- } else if ( trk && !IsTrackDeleted(trk)) {
+ if (!trk) {
+ if ( selectZero ) {
+ HighlightSelectedTracks(NULL, FALSE, TRUE);
+ } else {
+ HighlightSelectedTracks(trk, TRUE, FALSE);
+ }
+ } else {
+ //Handle the SHIFT+ which means SelectAllConnected case
if ((MyGetKeyState() & WKEY_SHIFT) )
SelectConnectedTracks(trk, TRUE); //Highlight all connected
//Normal case - handle track we are hovering over
- else {
+ else {
//Select=Add
if (selectMode == 1) {
if ((MyGetKeyState() & (WKEY_CTRL|WKEY_SHIFT)) == WKEY_CTRL) {
- //Only Highlight if adding
+ //Only Highlight if adding otherwise show already selected
if (!GetTrkSelected(trk))
DrawTrack(trk,&tempD,wDrawColorPreviewSelected);
+ else
+ DrawTrack(trk,&tempD,selectedColor);
} else {
if (GetTrkSelected(trk))
DrawTrack(trk,&tempD,wDrawColorPreviewUnselected); //Toggle
@@ -3128,6 +3454,8 @@ static STATUS_T CmdSelect(
//Only Highlight if adding
if (!GetTrkSelected(trk))
DrawTrack(trk,&tempD,wDrawColorPreviewSelected );
+ else
+ DrawTrack(trk,&tempD,selectedColor);
}
}
}
@@ -3138,20 +3466,19 @@ static STATUS_T CmdSelect(
else
DoModuleTracks(GetTrkLayer(trk),DrawSingleTrack,TRUE);
DrawHighlightLayer(GetTrkLayer(trk));
+ }
+ //Select=Add
+ if (selectMode == 1) {
+ if (((MyGetKeyState() & (WKEY_CTRL|WKEY_SHIFT)) == WKEY_CTRL))
+ HighlightSelectedTracks(trk, FALSE, TRUE);
+ else
+ HighlightSelectedTracks(trk, TRUE, FALSE); // Highlight all others selected
+ //Select=Only
} else {
- //Select=Add
- if (selectMode == 1) {
- if (((MyGetKeyState() & (WKEY_CTRL|WKEY_SHIFT)) == WKEY_CTRL))
- HighlightSelectedTracks(trk, TRUE, TRUE);
- //else
- // HighlightSelectedTracks(trk, TRUE, FALSE); Highlight all selected
- //Select=Only
- } else {
- if (((MyGetKeyState() & (WKEY_CTRL|WKEY_SHIFT)) != WKEY_CTRL))
- HighlightSelectedTracks(trk, TRUE, TRUE);
- //else
- // HighlightSelectedTracks(trk, TRUE, TRUE); Highlight all selected
- }
+ if (((MyGetKeyState() & (WKEY_CTRL|WKEY_SHIFT)) != WKEY_CTRL))
+ HighlightSelectedTracks(trk, FALSE, TRUE);
+ else
+ HighlightSelectedTracks(trk, TRUE, FALSE); // Highlight all others selected
}
}
//Finally add the anchors for any actions or snaps
@@ -3222,28 +3549,41 @@ static STATUS_T CmdSelect(
if (doingDouble) {
return CallModify(action,pos);
}
+ if ((action>>8) == 127 || (action>>8) == 8) { //Backspace or Delete key
+ SelectDelete();
+ break;
+ }
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);
}
if ((action>>8) == '0' || (action>>8 == 'o')) {
- PanMenuEnter('o');
+ PanMenuEnter(I2VP('o'));
}
if ((action>>8) == '?') {
if((moveDescTrk = OnTrack(&pos,FALSE,FALSE)) != NULL)
moveDescPos = pos;
- CallPushDescribe((void*)0);
+ CallPushDescribe(I2VP(0));
wSetCursor(mainD.d,defaultCursor);
moveDescTrk = NULL;
}
break;
+ case C_CONFIRM:
+ if (doingDouble)
+ return CallModify(action,pos);
+ return C_CONTINUE;
case C_FINISH:
+ if (doingDouble) {
+ CallModify(C_OK,pos);
+ CallModify(C_FINISH,pos);
+ }
if (doingMove) UndoEnd();
doingDouble = FALSE;
+ wSetCursor(mainD.d,defaultCursor);
break;
default:
if (doingDouble) return CallModify(action, pos);
@@ -3259,8 +3599,8 @@ static STATUS_T CmdSelect(
#include "bitmaps/bridge.xpm"
#include "bitmaps/move.xpm"
#include "bitmaps/rotate.xpm"
-#include "bitmaps/flip.xpm"
-#include "bitmaps/movedesc.xpm"
+#include "bitmaps/reflect.xpm"
+#include "bitmaps/description.xpm"
static void SetMoveMode( char * line )
@@ -3272,19 +3612,20 @@ static void SetMoveMode( char * line )
enableMoveDraw = ((tmp&0x10) == 0);
}
-static void moveDescription( void ) {
+static void moveDescription( void * unused ) {
if (!moveDescTrk) return;
int hidden = GetTrkBits( moveDescTrk) &TB_HIDEDESC ;
if (hidden)
ClrTrkBits( moveDescTrk, TB_HIDEDESC );
else
SetTrkBits( moveDescTrk, TB_HIDEDESC );
+ MainRedraw();
}
EXPORT void InitCmdSelect( wMenu_p menu )
{
- selectCmdInx = AddMenuButton( menu, CmdSelect, "cmdSelect", _("Select"), wIconCreatePixMap(select_xpm),
+ selectCmdInx = AddMenuButton( menu, CmdSelect, "cmdSelect", _("Select"), wIconCreatePixMap(select_xpm[iconSize]),
LEVEL0, IC_CANCEL|IC_POPUP|IC_LCLICK|IC_CMDMENU|IC_WANT_MOVE|IC_WANT_MODKEYS, ACCL_SELECT, NULL );
}
@@ -3303,68 +3644,72 @@ EXPORT void InitCmdSelect2( wMenu_p menu ) {
if (moveMode > MAXMOVEMODE || moveMode < 0)
moveMode = MAXMOVEMODE;
selectPopup1M = MenuRegister( "Select Mode Menu" );
- wMenuPushCreate(selectPopup1M, "", _("Undo"), 0,(wMenuCallBack_p) UndoUndo, (void *) 0);
- wMenuPushCreate(selectPopup1M, "", _("Redo"), 0,(wMenuCallBack_p) UndoRedo, (void *) 0);
+ wMenuPushCreate(selectPopup1M, "", _("Undo"), 0, UndoUndo, NULL);
+ wMenuPushCreate(selectPopup1M, "", _("Redo"), 0, UndoRedo, NULL);
wMenuSeparatorCreate( selectPopup1M );
- wMenuPushCreate(selectPopup1M, "cmdDescribeMode", GetBalloonHelpStr("cmdModifyMode"), 0, DoCommandB, (void*) (intptr_t) modifyCmdInx);
- wMenuPushCreate(selectPopup1M, "cmdPanMode", GetBalloonHelpStr("cmdPanMode"), 0, DoCommandB, (void*) (intptr_t) panCmdInx);
- wMenuPushCreate(selectPopup1M, "cmdTrainMode", GetBalloonHelpStr("cmdTrainMode"), 0, DoCommandB, (void*) (intptr_t) trainCmdInx);
+ wMenuPushCreate(selectPopup1M, "cmdDescribeMode", GetBalloonHelpStr("cmdModifyMode"), 0, DoCommandB, I2VP(modifyCmdInx));
+ wMenuPushCreate(selectPopup1M, "cmdPanMode", GetBalloonHelpStr("cmdPanMode"), 0, DoCommandB, I2VP(panCmdInx));
+ wMenuPushCreate(selectPopup1M, "cmdTrainMode", GetBalloonHelpStr("cmdTrainMode"), 0, DoCommandB, I2VP(trainCmdInx));
wMenuSeparatorCreate( selectPopup1M );
- wMenuPushCreate(selectPopup1M, "", _("Zoom In"), 0,(wMenuCallBack_p) DoZoomUp, (void*) 1);
- wMenuPushCreate( selectPopup1M, "", _("Zoom to extents - 'e'"), 0, (wMenuCallBack_p)DoZoomExtents, (void*) 0);
+ wMenuPushCreate(selectPopup1M, "", _("Zoom In"), 0, DoZoomUp, I2VP(1));
+ wMenuPushCreate( selectPopup1M, "", _("Zoom to extents - 'e'"), 0, DoZoomExtents, I2VP(0) );
wMenu_p zoomPop1 = wMenuMenuCreate(selectPopup1M, "", _("&Zoom"));
InitCmdZoom(NULL, NULL, zoomPop1, NULL);
- wMenuPushCreate(selectPopup1M, "", _("Zoom Out"), 0, (wMenuCallBack_p) DoZoomDown, (void*) 1);
- wMenuPushCreate(selectPopup1M, "", _("Pan to Origin - 'o'/'0'"), 0, (wMenuCallBack_p) PanMenuEnter, (void*) 'o');
- wMenuPushCreate(selectPopup1M, "", _("Pan Center Here - 'c'"), 0, (wMenuCallBack_p) PanHere, (void*) 3);
+ wMenuPushCreate(selectPopup1M, "", _("Zoom Out"), 0, DoZoomDown, I2VP(1));
+ wMenuPushCreate(selectPopup1M, "", _("Pan to Origin - 'o'/'0'"), 0, PanMenuEnter, I2VP( 'o'));
+ wMenuPushCreate(selectPopup1M, "", _("Pan Center Here - 'c'"), 0, PanHere, I2VP( 3));
wMenuSeparatorCreate( selectPopup1M );
- wMenuPushCreate(selectPopup1M, "", _("Select All"), 0,(wMenuCallBack_p) SetAllTrackSelect, (void *) 1);
- wMenuPushCreate(selectPopup1M, "",_("Select Current Layer"), 0,(wMenuCallBack_p) SelectCurrentLayer, (void *) 0);
+ wMenuPushCreate(selectPopup1M, "", _("Select All"), 0,(wMenuCallBack_p) SetAllTrackSelect, I2VP( 1));
+ wMenuPushCreate(selectPopup1M, "",_("Select Current Layer"), 0, SelectCurrentLayer, I2VP( 0));
+ AddIndexMenu( selectPopup1M, SelectByIndex);
wMenuSeparatorCreate( selectPopup1M );
selectPopup2M = MenuRegister( "Track Selected Menu " );
- wMenuPushCreate(selectPopup2M, "", _("Undo"), 0,(wMenuCallBack_p) UndoUndo, (void *) 0);
- wMenuPushCreate(selectPopup2M, "", _("Redo"), 0,(wMenuCallBack_p) UndoRedo, (void *) 0);
+ wMenuPushCreate(selectPopup2M, "", _("Undo"), 0, UndoUndo , NULL);
+ wMenuPushCreate(selectPopup2M, "", _("Redo"), 0, UndoRedo , NULL);
wMenuSeparatorCreate( selectPopup2M );
- wMenuPushCreate(selectPopup2M, "", _("Zoom In"), 0,(wMenuCallBack_p) DoZoomUp, (void*) 1);
- wMenuPushCreate(selectPopup2M, "", _("Zoom Out"), 0, (wMenuCallBack_p) DoZoomDown, (void*) 1);
- wMenuPushCreate(selectPopup2M, "", _("Pan Center Here - 'c'"), 0, (wMenuCallBack_p) PanHere, (void*) 3);
+ wMenuPushCreate(selectPopup2M, "", _("Zoom In"), 0, DoZoomUp, I2VP( 1));
+ wMenuPushCreate(selectPopup2M, "", _("Zoom Out"), 0, DoZoomDown, I2VP( 1));
+ wMenuPushCreate( selectPopup2M, "", _("Zoom to extents - 'e'"), 0, DoZoomExtents, I2VP( 0));
+ wMenuPushCreate( selectPopup2M, "", _("Zoom to selected - 's'"), 0, DoZoomExtents, I2VP( 1));
+ wMenuPushCreate(selectPopup2M, "", _("Pan Center Here - 'c'"), 0, PanHere, I2VP( 3));
wMenuSeparatorCreate( selectPopup2M );
- wMenuPushCreate(selectPopup2M, "", _("Deselect All"), 0, (wMenuCallBack_p) SetAllTrackSelect, (void *) 0);
+ AddIndexMenu( selectPopup2M, SelectByIndex);
+ wMenuPushCreate(selectPopup2M, "", _("Deselect All"), 0, (wMenuCallBack_p) SetAllTrackSelect, I2VP( 0));
wMenuSeparatorCreate( selectPopup2M );
- wMenuPushCreate(selectPopup2M, "", _("Properties -'?'"), 0,(wMenuCallBack_p) CallPushDescribe, (void*)0);
- menuPushModify = wMenuPushCreate(selectPopup2M, "", _("Modify/Activate Track"), 0,(wMenuCallBack_p) CallPushModify, (void*)0);
+ wMenuPushCreate(selectPopup2M, "", _("Properties -'?'"), 0, CallPushDescribe, I2VP(0));
+ menuPushModify = wMenuPushCreate(selectPopup2M, "", _("Modify/Activate Track"), 0, CallPushModify, I2VP(0));
wMenuSeparatorCreate( selectPopup2M );
- wMenuPushCreate(selectPopup2M, "", _("Cut"), 0,(wMenuCallBack_p) EditCut, (void *) 0);
- wMenuPushCreate(selectPopup2M, "", _("Copy"), 0,(wMenuCallBack_p) EditCopy, (void *) 0);
- wMenuPushCreate(selectPopup2M, "", _("Paste"), 0, (wMenuCallBack_p) EditPaste, (void *) 0);
- wMenuPushCreate(selectPopup2M, "", _("Clone"), 0, (wMenuCallBack_p) EditClone, (void *) 0);
+ wMenuPushCreate(selectPopup2M, "", _("Cut"), 0, EditCut, I2VP( 0));
+ wMenuPushCreate(selectPopup2M, "", _("Copy"), 0, EditCopy, I2VP( 0));
+ wMenuPushCreate(selectPopup2M, "", _("Paste"), 0, EditPaste, I2VP( 0));
+ wMenuPushCreate(selectPopup2M, "", _("Clone"), 0, EditClone, I2VP( 0));
AddMoveMenu( selectPopup2M, QuickMove);
selectPopup2RM = wMenuMenuCreate(selectPopup2M, "", _("Rotate..."));
AddRotateMenu( selectPopup2RM, QuickRotate );
- rotateAlignMI = wMenuPushCreate( selectPopup2RM, "", _("Align"), 0, (wMenuCallBack_p)RotateAlign, (void* ) 1 );
+ rotateAlignMI = wMenuPushCreate( selectPopup2RM, "", _("Align"), 0, RotateAlign, I2VP(1) );
wMenuSeparatorCreate( selectPopup2M );
- descriptionMI = wMenuPushCreate(selectPopup2M, "cmdMoveLabel", _("Show/Hide Description"), 0, (wMenuCallBack_p)moveDescription, (void*) 0);
+ descriptionMI = wMenuPushCreate(selectPopup2M, "cmdMoveLabel", _("Show/Hide Description"), 0, moveDescription, I2VP(0));
wMenuSeparatorCreate( selectPopup2M );
- hideMI = wMenuPushCreate(selectPopup2M, "", _("Hide/NoHide"), 0,(wMenuCallBack_p) SelectTunnel, (void *) 0);
- bridgeMI = wMenuPushCreate(selectPopup2M, "", _("Bridge/NoBridge"), 0,(wMenuCallBack_p) SelectBridge, (void *) 0);
- tiesMI = wMenuPushCreate(selectPopup2M, "", _("NoTies/Ties"), 0,(wMenuCallBack_p) SelectTies, (void *) 0);
+ hideMI = wMenuPushCreate(selectPopup2M, "", _("Hide/NoHide"), 0, SelectTunnel, I2VP( 0));
+ bridgeMI = wMenuPushCreate(selectPopup2M, "", _("Bridge/NoBridge"), 0, SelectBridge, I2VP( 0));
+ tiesMI = wMenuPushCreate(selectPopup2M, "", _("NoTies/Ties"), 0, SelectTies, I2VP( 0));
selectPopup2TM = wMenuMenuCreate(selectPopup2M, "", _("Thickness..."));
- wMenuPushCreate( selectPopup2TM, "", _("Thin Tracks"), 0, (void*)(wMenuCallBack_p)SelectTrackWidth, (void *)0 );
- wMenuPushCreate( selectPopup2TM, "", _("Medium Tracks"), 0, (void*)(wMenuCallBack_p)SelectTrackWidth, (void *)2 );
- wMenuPushCreate( selectPopup2TM, "", _("Thick Tracks"), 0, (void*)(wMenuCallBack_p)SelectTrackWidth, (void *)3 );
+ wMenuPushCreate( selectPopup2TM, "", _("Thin Tracks"), 0, SelectTrackWidth, I2VP(0 ));
+ wMenuPushCreate( selectPopup2TM, "", _("Medium Tracks"), 0, SelectTrackWidth, I2VP(2 ));
+ wMenuPushCreate( selectPopup2TM, "", _("Thick Tracks"), 0, SelectTrackWidth, I2VP(3 ));
selectPopup2TYM = wMenuMenuCreate( selectPopup2M, "", _("LineType...") );
- wMenuPushCreate( selectPopup2TYM, "", _("Solid Line"), 0, (wMenuCallBack_p)SelectLineType, (void*)0 );
- wMenuPushCreate( selectPopup2TYM, "", _("Dashed Line"), 0, (wMenuCallBack_p)SelectLineType, (void*)1 );
- wMenuPushCreate( selectPopup2TYM, "", _("Dotted Line"), 0, (wMenuCallBack_p)SelectLineType, (void*)2 );
- wMenuPushCreate( selectPopup2TYM, "", _("Dash-Dotted Line"), 0, (wMenuCallBack_p)SelectLineType, (void*)3 );
- wMenuPushCreate( selectPopup2TYM, "", _("Dash-Dot-Dotted Line"), 0, (wMenuCallBack_p)SelectLineType, (void*)4 );
+ wMenuPushCreate( selectPopup2TYM, "", _("Solid Line"), 0, SelectLineType, I2VP(0 ));
+ wMenuPushCreate( selectPopup2TYM, "", _("Dashed Line"), 0, SelectLineType, I2VP(1 ));
+ wMenuPushCreate( selectPopup2TYM, "", _("Dotted Line"), 0, SelectLineType, I2VP(2 ));
+ wMenuPushCreate( selectPopup2TYM, "", _("Dash-Dotted Line"), 0, SelectLineType, I2VP(3 ));
+ wMenuPushCreate( selectPopup2TYM, "", _("Dash-Dot-Dotted Line"), 0, SelectLineType, I2VP(4 ));
wMenuSeparatorCreate( selectPopup2M );
- wMenuPushCreate(selectPopup2M, "", _("Move To Front"), 0,(wMenuCallBack_p) SelectAbove,(void *) 0);
- wMenuPushCreate(selectPopup2M, "", _("Move To Back"), 0,(wMenuCallBack_p) SelectBelow, (void *) 0);
+ wMenuPushCreate(selectPopup2M, "", _("Move To Front"), 0, SelectAbove,I2VP( 0));
+ wMenuPushCreate(selectPopup2M, "", _("Move To Back"), 0, SelectBelow, I2VP( 0));
wMenuSeparatorCreate( selectPopup2M );
- wMenuPushCreate(selectPopup2M, "", _("Group"), 0,(wMenuCallBack_p) DoGroup, (void *) 0);
- wMenuPushCreate(selectPopup2M, "", _("UnGroup"), 0,(wMenuCallBack_p) DoUngroup, (void *) 0);
+ wMenuPushCreate(selectPopup2M, "", _("Group"), 0, DoGroup, I2VP( 0));
+ wMenuPushCreate(selectPopup2M, "", _("UnGroup"), 0, DoUngroup, I2VP( 0));
wMenuSeparatorCreate( selectPopup2M );
ParamRegister( &rescalePG );
@@ -3375,41 +3720,38 @@ EXPORT void InitCmdSelect2( wMenu_p menu ) {
EXPORT void InitCmdDelete( void )
{
wIcon_p icon;
- icon = wIconCreatePixMap( delete_xpm );
+ icon = wIconCreatePixMap( delete_xpm[iconSize] );
AddToolbarButton( "cmdDelete", icon, IC_SELECTED, (wButtonCallBack_p)SelectDelete, 0 );
-#ifdef WINDOWS
- wAttachAccelKey( wAccelKey_Del, 0, (wAccelKeyCallBack_p)SelectDelete, NULL );
-#endif
}
EXPORT void InitCmdTunnel( void )
{
wIcon_p icon;
- icon = wIconCreatePixMap( tunnel_xpm );
- AddToolbarButton( "cmdTunnel", icon, IC_SELECTED|IC_POPUP, (addButtonCallBack_t)SelectTunnel, NULL );
+ icon = wIconCreatePixMap( tunnel_xpm[iconSize] );
+ AddToolbarButton( "cmdTunnel", icon, IC_SELECTED|IC_POPUP, SelectTunnel, NULL );
}
EXPORT void InitCmdBridge( void)
{
wIcon_p icon;
- icon = wIconCreatePixMap( bridge_xpm );
- AddToolbarButton( "cmdBridge", icon, IC_SELECTED|IC_POPUP, (addButtonCallBack_t)SelectBridge, NULL );
+ icon = wIconCreatePixMap( bridge_xpm[iconSize] );
+ AddToolbarButton( "cmdBridge", icon, IC_SELECTED|IC_POPUP, SelectBridge, NULL );
}
EXPORT void InitCmdMoveDescription( wMenu_p menu )
{
- AddMenuButton( menu, CmdMoveDescription, "cmdMoveLabel", _("Move Description"), wIconCreatePixMap(movedesc_xpm),
- LEVEL0, IC_STICKY|IC_POPUP3|IC_CMDMENU|IC_WANT_MOVE, ACCL_MOVEDESC, (void*) 0 );
+ AddMenuButton( menu, CmdMoveDescription, "cmdMoveLabel", _("Move Description"), wIconCreatePixMap(description_xpm[iconSize]),
+ LEVEL0, IC_STICKY|IC_POPUP3|IC_CMDMENU|IC_WANT_MOVE, ACCL_MOVEDESC, I2VP( 0 ));
}
EXPORT void InitCmdMove( wMenu_p menu )
{
- moveCmdInx = AddMenuButton( menu, CmdMove, "cmdMove", _("Move"), wIconCreatePixMap(move_xpm),
+ moveCmdInx = AddMenuButton( menu, CmdMove, "cmdMove", _("Move"), wIconCreatePixMap(move_xpm[iconSize]),
LEVEL0, IC_STICKY|IC_SELECTED|IC_CMDMENU|IC_WANT_MOVE, ACCL_MOVE, NULL );
- rotateCmdInx = AddMenuButton( menu, CmdRotate, "cmdRotate", _("Rotate"), wIconCreatePixMap(rotate_xpm),
+ rotateCmdInx = AddMenuButton( menu, CmdRotate, "cmdRotate", _("Rotate"), wIconCreatePixMap(rotate_xpm[iconSize]),
LEVEL0, IC_STICKY|IC_SELECTED|IC_CMDMENU|IC_WANT_MOVE, ACCL_ROTATE, NULL );
- /*flipCmdInx =*/ AddMenuButton( menu, CmdFlip, "cmdFlip", _("Flip"), wIconCreatePixMap(flip_xpm),
+ flipCmdInx = AddMenuButton( menu, CmdFlip, "cmdFlip", _("Flip"), wIconCreatePixMap(reflect_xpm[iconSize]),
LEVEL0, IC_STICKY|IC_SELECTED|IC_CMDMENU, ACCL_FLIP, NULL );
}