← Back to team overview

kicad-developers team mailing list archive

Re: I have trouble with wires in eeschema...

 

Le 22/05/2012 09:38, Lorenzo Marcantonio a écrit :
I have issues with patch 22 (the wire refactoring) and eeschema doesn't work quite right. I have troubles with wire creation... if I get it currently the BeginSegment look if it's the first click and need to begin a new wire or if it needs to proceed with the following segment.

The code is this:

     // We should know if a segment is currently in progress
     segment = (SCH_LINE*) GetScreen()->GetCurItem();
     if( segment )   // a current item exists, but not necessary a currently edited item
     {
         if( !segment->GetFlags() || ( segment->Type() != SCH_LINE_T ) )
         {
             if( segment->GetFlags() )
             {
                 wxLogDebug( wxT( "BeginSegment: item->GetFlags()== %X" ),
                     segment->GetFlags() );
             }
             // no wire, bus or graphic line in progress
             segment = NULL;
         }
     }

If there's nothing, no issue.

If there's something and is a line:
     If has flags, OK
     If hasn't flags take it as null

If there's something and it not a line:
     If has flags show them and take it as null anyway

I don't get the meaning of this code...
The previous segment has the IS_NEW flag set (so it passes) but what's the debug statemnet for???


When calling SCH_EDIT_FRAME::BeginSegment(), only 2 cases are OK:

1 - This is a request to create a new segment:
In this case GetScreen()->GetCurItem() should returns null (no current item) or an item previously selected,
but not currently edited (i.e. item->GetFlags() should returns 0)
2 - This is a request to finish a new segment in progress (and create a new one):
In this case GetScreen()->GetCurItem() should returns an active item currently edited,
(i.e. item->GetFlags() should returns NEW flag set) and the type must be SCH_LINE_T.

When you have:
if( !segment->GetFlags() || ( segment->Type() != SCH_LINE_T ) )

1 - you have an active item which is not a SCH_LINE_T :
    this is a bug: so wxLogDebug() displays a bug message.
2 - you have an just a previously selected but not active item (flags = 0),
    this case is OK, so no problem and no bug: just no line in progress.
For each case just start a new segment.


--
Jean-Pierre CHARRAS
KiCad Developers team.
KiCad Developers <kicad-developers@xxxxxxxxxxxxxxxxxxx>


Follow ups

References