summaryrefslogtreecommitdiff
path: root/app/bin/cgroup.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/bin/cgroup.c')
-rw-r--r--app/bin/cgroup.c52
1 files changed, 39 insertions, 13 deletions
diff --git a/app/bin/cgroup.c b/app/bin/cgroup.c
index 76b15ca..b173987 100644
--- a/app/bin/cgroup.c
+++ b/app/bin/cgroup.c
@@ -1,6 +1,4 @@
-/*
- * $Header: /home/dmarkle/xtrkcad-fork-cvs/xtrkcad/app/bin/cgroup.c,v 1.2 2008-01-20 23:29:15 mni77 Exp $
- *
+/** \file cgroup.c
* Compound tracks: Group
*
*/
@@ -24,10 +22,23 @@
*/
#include <ctype.h>
-#include "track.h"
+#include <math.h>
+#include <string.h>
+
#include "compound.h"
-#include "shrtpath.h"
+#include "cundo.h"
+#include "custom.h"
+#include "fileio.h"
#include "i18n.h"
+#include "tbezier.h"
+#include "tcornu.h"
+#include "common.h"
+#include "messages.h"
+#include "param.h"
+#include "shrtpath.h"
+#include "track.h"
+#include "utility.h"
+
/*****************************************************************************
*
@@ -46,6 +57,10 @@ static char groupPartno[STR_SIZE];
static char groupTitle[STR_SIZE];
static int groupCompoundCount = 0;
+extern TRKTYP_T T_BZRTRK;
+extern TRKTYP_T T_BZRLIN;
+extern TRKTYP_T T_CORNU;
+
typedef struct {
int segInx;
EPINX_T segEP;
@@ -666,7 +681,11 @@ static char * FindPathBtwEP(
if ( ep1+ep2 != 1 )
AbortProg( "findPathBtwEP" );
*flip = ( ep1 == 1 );
- return "\1\0\0";
+ if (GetTrkType(trk) == T_CORNU ) { // Cornu doesn't have a path but lots of segs!
+ cp = CreateSegPathList(trk); // Make path
+LOG( log_group, 2, ( " Group: Cornu path:%s \n", cp ) )
+ } else cp = "\1\0\0"; //One segment (but could be a Bezier)
+ return cp;
}
cp = (char *)xx->paths;
pos1 = GetTrkEndPos(trk,ep1);
@@ -678,7 +697,7 @@ static char * FindPathBtwEP(
pos2.x -= xx->orig.x;
pos2.y -= xx->orig.y;
while ( cp[0] ) {
- cp += strlen(cp)+1;
+ cp += strlen(cp)+1; //Ignore Path Name
while ( cp[0] ) {
cp0 = cp;
epN = -1;
@@ -691,8 +710,8 @@ static char * FindPathBtwEP(
if ( epN != -1 ) {
GetSegInxEP( cp[-1], &segInx, &segEP );
if ( CheckTurnoutEndPoint( &xx->segs[segInx], epN==0?pos1:pos2, 1-segEP ) ) {
- *flip = epN==0;
- return cp0;
+ *flip = epN==0; // If its reversed, set up to be flipped or noted
+ return cp0; //Found path between EPs
}
}
cp++;
@@ -995,6 +1014,12 @@ static void GroupOk( void * junk )
DrawSegs( &groupD, xx->orig, xx->angle, segPtr, 1, trackGauge, wDrawColorBlack );
}
}
+ } else if (GetTrkType(trk) == T_BEZIER || GetTrkType(trk) == T_BZRLIN ) {
+ DYNARR_APPEND(trkSeg_t, trackSegs_da, 10);
+ segPtr = &trackSegs(trackSegs_da.cnt-1);
+ GetBezierSegmentFromTrack(trk,segPtr);
+ } else if (GetTrkType(trk) == T_CORNU) {
+ GetBezierSegmentsFromCornu(trk,&trackSegs_da); //Only give back Bezier - cant be undone
} else {
segCnt = tempSegs_da.cnt;
oldOptions = groupD.options;
@@ -1072,6 +1097,7 @@ static void GroupOk( void * junk )
}
/* Make sure no turnouts in groupTrk list have a path end which is not an EndPt */
+ //TODO Add Trap Points (which are Turnouts with a bumper track)
for ( inx=0; inx<groupTrk_da.cnt; inx++ ) {
trk = groupTrk(0).trk;
if ( GetTrkType( trk ) == T_TURNOUT ) {
@@ -1391,7 +1417,7 @@ if ( log_group >= 1 && logTable(log_group).level > log_group ) {
for ( pinx=0; pinx<trackSegs_da.cnt; pinx++ ) {
if ( segFlip(pinx) < 0 ) {
LOG( log_group, 1, ( "Flipping Segment %d\n", pinx+1 ) );
- SegProc( SEGPROC_FLIP, &trackSegs(pinx), NULL );
+ SegProc( SEGPROC_FLIP, &trackSegs(pinx), NULL );
}
}
@@ -1413,7 +1439,7 @@ LOG( log_group, 1, ( "Flipping Segment %d\n", pinx+1 ) );
if ( path == NULL )
AbortProg( "Missing Path T%d:%d.%d", GetTrkIndex(groupP->trk), ppp->ep2, ppp->ep1 );
if ( flip ) path += strlen((char *)path)-1;
- while ( *path ) {
+ while ( *path && (path >= ppp->path) ) { //Add Guard for flip backwards
DYNARR_APPEND( char, pathPtr_da, 10 );
pathChar = *path;
flip1 = flip;
@@ -1568,6 +1594,7 @@ EXPORT void DoGroup( void )
xx = NULL;
groupSegCnt = 0;
groupCompoundCount = 0;
+
while ( TrackIterate( &trk ) ) {
if ( GetTrkSelected( trk ) ) {
trkType = GetTrkType(trk);
@@ -1575,9 +1602,8 @@ EXPORT void DoGroup( void )
xx = GetTrkExtraData(trk);
groupSegCnt += xx->segCnt;
GroupCopyTitle( xtitle(xx) );
- } else {
+ } else
groupSegCnt += 1;
- }
}
}
if ( groupSegCnt <= 0 ) {