Length Tuner: Allow controlling the side of the meander using the cursor

Also fixes an issue that did not allow single meanders to be placed
This commit is contained in:
Roberto Fernandez Bautista 2021-09-28 18:19:58 +01:00
parent 2225c4e4ed
commit 71156368c9
4 changed files with 14 additions and 9 deletions

View File

@ -254,7 +254,7 @@ bool DP_MEANDER_PLACER::Move( const VECTOR2I& aP, ITEM* aEndItem )
curIndexN = tunedN.NextShape( curIndexN ); curIndexN = tunedN.NextShape( curIndexN );
} }
m_result.MeanderSegment( base ); m_result.MeanderSegment( base, base.Side( aP ) < 0 );
} }
while( curIndexP < tunedP.PointCount() && curIndexP != -1 ) while( curIndexP < tunedP.PointCount() && curIndexP != -1 )

View File

@ -42,13 +42,13 @@ const MEANDER_SETTINGS& MEANDERED_LINE::Settings() const
} }
void MEANDERED_LINE::MeanderSegment( const SEG& aBase, int aBaseIndex ) void MEANDERED_LINE::MeanderSegment( const SEG& aBase, bool aSide, int aBaseIndex )
{ {
double base_len = aBase.Length(); double base_len = aBase.Length();
SHAPE_LINE_CHAIN lc; SHAPE_LINE_CHAIN lc;
bool side = true; bool side = aSide;
VECTOR2D dir( aBase.B - aBase.A ); VECTOR2D dir( aBase.B - aBase.A );
if( !m_dual ) if( !m_dual )
@ -80,11 +80,13 @@ void MEANDERED_LINE::MeanderSegment( const SEG& aBase, int aBaseIndex )
{ {
for( int i = 0; i < 2; i++ ) for( int i = 0; i < 2; i++ )
{ {
if( m.Fit( MT_CHECK_START, aBase, m_last, i ) ) bool checkSide = ( i == 0 ) ? side : !side;
if( m.Fit( MT_CHECK_START, aBase, m_last, checkSide ) )
{ {
turning = true; turning = true;
AddMeander( new MEANDER_SHAPE( m ) ); AddMeander( new MEANDER_SHAPE( m ) );
side = !i; side = !checkSide;
started = true; started = true;
break; break;
} }
@ -96,12 +98,14 @@ void MEANDERED_LINE::MeanderSegment( const SEG& aBase, int aBaseIndex )
for( int i = 0; i < 2; i++ ) for( int i = 0; i < 2; i++ )
{ {
if( m.Fit( MT_SINGLE, aBase, m_last, i ) ) bool checkSide = ( i == 0 ) ? side : !side;
if( m.Fit( MT_SINGLE, aBase, m_last, checkSide ) )
{ {
AddMeander( new MEANDER_SHAPE( m ) ); AddMeander( new MEANDER_SHAPE( m ) );
fail = false; fail = false;
started = false; started = false;
side = !i; side = !checkSide;
break; break;
} }
} }

View File

@ -472,9 +472,10 @@ public:
* Fit maximum amplitude meanders on a given segment and adds to the current line. * Fit maximum amplitude meanders on a given segment and adds to the current line.
* *
* @param aSeg the base segment to meander. * @param aSeg the base segment to meander.
* @param aSide Side to start meandering the segment. True=left, False=Right
* @param aBaseIndex index of the base segment in the original line. * @param aBaseIndex index of the base segment in the original line.
*/ */
void MeanderSegment( const SEG& aSeg, int aBaseIndex = 0 ); void MeanderSegment( const SEG& aSeg, bool aSide, int aBaseIndex = 0 );
/// @copydoc MEANDER_SHAPE::SetBaselineOffset() /// @copydoc MEANDER_SHAPE::SetBaselineOffset()
void SetBaselineOffset( int aOffset ) void SetBaselineOffset( int aOffset )

View File

@ -139,7 +139,7 @@ bool MEANDER_PLACER::doMove( const VECTOR2I& aP, ITEM* aEndItem, long long int a
const SEG s = tuned.CSegment( i ); const SEG s = tuned.CSegment( i );
m_result.AddCorner( s.A ); m_result.AddCorner( s.A );
m_result.MeanderSegment( s ); m_result.MeanderSegment( s, s.Side( aP ) < 0 );
m_result.AddCorner( s.B ); m_result.AddCorner( s.B );
} }