Commit 3f6f3c7b authored by charras's avatar charras
Browse files

eeschema bug fix: wires connected to a component non dragged in drag component command

parent fbcc2b30
Loading
Loading
Loading
Loading
+73 −50
Original line number Diff line number Diff line
@@ -1416,20 +1416,28 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct )
/****************************************************/
static void CollectStructsToDrag( SCH_SCREEN* screen )
/****************************************************/

/* creates the list of items found when a drag block is initiated.
 * items are those slected in window block an some items outside this area but connected
 * to a selected item (connected wires to a component or an entry )
 */
{
    DrawPickedStruct*   DrawStructs, * FirstPicked;
    SCH_ITEM*           Struct;
    EDA_DrawLineStruct* SegmStruct;
    int ox, oy, fx, fy;

    /* Set membre .m_Flags des segments */
    /* .m_Flags member is used to handle how a wire is exactly slected
     * (fully selected, or partially selected by an end point )
     */
    for( Struct = screen->EEDrawList; Struct != NULL; Struct = Struct->Next() )
        Struct->m_Flags = 0;

    if( screen->BlockLocate.m_BlockDrawStruct->Type() ==
        DRAW_SEGMENT_STRUCT_TYPE )
    // Sel .m_Flags to selected for a wire or buss in selected area if there is only one item:
    if( screen->BlockLocate.m_BlockDrawStruct->Type() == DRAW_SEGMENT_STRUCT_TYPE )
        screen->BlockLocate.m_BlockDrawStruct->m_Flags = SELECTED;

    // Sel .m_Flags to selected for a wire or buss in selected area for a list of items:
    else if( screen->BlockLocate.m_BlockDrawStruct->Type() ==
             DRAW_PICK_ITEM_STRUCT_TYPE )
    {
@@ -1456,8 +1464,10 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
    if( fy < oy )
        EXCHG( fy, oy );

    /* Pour Drag Block: remise sous forme de liste de structure, s'il n'y
     *  a qu'un seul element ( pour homogeneiser les traitements ulterieurs */
    /* For drag block only:
     * If only one item, change for a list of one item
     * in order to have always a list to handle.
     */
    if( screen->BlockLocate.m_BlockDrawStruct->Type() !=
        DRAW_PICK_ITEM_STRUCT_TYPE )
    {
@@ -1486,9 +1496,8 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
        }
    }

    /* Recherche des elements complementaires a "dragger", c'est a dire les
     *  fils et connexions hors bloc relies a des pins ou entries elles meme
     *  draggees */
    /* Search for other items to drag. They are end wires connected to selected items
     */

    FirstPicked = DrawStructs =
                      (DrawPickedStruct*) screen->BlockLocate.
@@ -1498,22 +1507,25 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
        Struct      = DrawStructs->m_PickedStruct;
        DrawStructs = DrawStructs->Next();
        if( Struct->Type() == TYPE_SCH_COMPONENT )
        {
        {   // Add all pins of the selected component to list
            LibEDA_BaseStruct* DrawItem;
            wxPoint            pos;
            DrawItem = GetNextPinPosition( (SCH_COMPONENT*) Struct, pos );
            while( DrawItem )
            {
                if( (pos.x < ox) || (pos.x > fx) || (pos.y < oy)
                   || (pos.y > fy) )
                if( (pos.x < ox) || (pos.x > fx) || (pos.y < oy) || (pos.y > fy) )
                {   // This pin is outside area,
                    // but because it it the pin of a selected component
                    // we must also select connected items to this pin
                    AddPickedItem( screen, pos );
                }

                DrawItem = GetNextPinPosition( NULL, pos );
            }
        }

        if( Struct->Type() == DRAW_SHEET_STRUCT_TYPE )
        {
        {   // Add all pins sheets of a selected hierarchical sheet to the list
            Hierarchical_PIN_Sheet_Struct* SLabel =
                ( (DrawSheetStruct*) Struct )->m_Label;
            while( SLabel )
@@ -1705,13 +1717,25 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
                                              wxPoint&       aPosition )
/*********************************************************************************/

/** GetNextPinPosition()
 * calculate position of the "next" pin of the aDrawLibItem component
 * if aDrawLibItem is non null : search for the first pin
 * if aDrawLibItem == NULL, search the next pin
 * returns its position
 * @param aDrawLibItem = component test. search for the first pin
 *      if NULL, serach for the next pin for each call
 * @param aPosition = the calculated pin position, according to the component orientation and position
 * @return a pointer to the pin
 */
{
    EDA_LibComponentStruct* Entry;
    static LibEDA_BaseStruct* NextItem;
    static int Multi, convert, PartX, PartY, TransMat[2][2];
    static int Multi, convert, TransMat[2][2];
    LibEDA_BaseStruct* DEntry;
    int orient;
    LibDrawPin* Pin;
    static wxPoint CmpPosition;

    if( aDrawLibItem )
    {
@@ -1723,8 +1747,7 @@ static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
        DEntry      = Entry->m_Drawings;
        Multi       = aDrawLibItem->m_Multi;
        convert     = aDrawLibItem->m_Convert;
        PartX   = aDrawLibItem->m_Pos.x;
        PartY   = aDrawLibItem->m_Pos.y;
        CmpPosition = aDrawLibItem->m_Pos;
        memcpy( TransMat, aDrawLibItem->m_Transform, sizeof(TransMat) );
    }
    else
@@ -1746,7 +1769,7 @@ static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
        orient = Pin->ReturnPinDrawOrient( TransMat );

        /* Calcul de la position du point de reference */
        aPosition = TransformCoordinate( TransMat, Pin->m_Pos);
        aPosition = TransformCoordinate( TransMat, Pin->m_Pos ) + CmpPosition;
        NextItem  = DEntry->Next();
        return DEntry;
    }