block_module_editor.cpp 21 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
/****************************************************/
/*	block_module_editor.cpp							*/
/* Handle block commands for the footprint editor	*/
/****************************************************/

#include "fctsys.h"
#include "gr_basic.h"

#include "common.h"
#include "pcbnew.h"
#include "autorout.h"
#include "pcbplot.h"
#include "trigo.h"

#include "protos.h"


#define BLOCK_COLOR BROWN
#define IS_SELECTED 1

/* Variables Locales */

/* Fonctions exportees */

/* Fonctions Locales */
26 27 28
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static int  MarkItemsInBloc( MODULE*  module,
                             EDA_Rect& Rect );
29

30 31 32 33 34 35
static void ClearMarkItems( MODULE* module );
static void CopyMarkedItems( MODULE* module, wxPoint offset );
static void MoveMarkedItems( MODULE* module, wxPoint offset );
static void MirrorMarkedItems( MODULE* module, wxPoint offset );
static void RotateMarkedItems( MODULE* module, wxPoint offset );
static void DeleteMarkedItems( MODULE* module );
36 37 38


/*************************************************************************/
39
int WinEDA_ModuleEditFrame::ReturnBlockCommand( int key )
40
/*************************************************************************/
41

42
/* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to
43 44 45
 *  the key (ALT, SHIFT ALT ..) pressed when dragging mouse and left or middle button
 *  pressed
 */
46
{
47
    int cmd;
48

49 50 51 52 53
    switch( key )
    {
    default:
        cmd = key & 0x255;
        break;
54

55 56 57
    case - 1:
        cmd = BLOCK_PRESELECT_MOVE;
        break;
58

59 60 61
    case 0:
        cmd = BLOCK_MOVE;
        break;
62

63 64 65
    case GR_KB_ALT:
        cmd = BLOCK_MIRROR_Y;
        break;
66

67 68 69
    case GR_KB_SHIFTCTRL:
        cmd = BLOCK_DELETE;
        break;
70

71 72 73
    case GR_KB_SHIFT:
        cmd = BLOCK_COPY;
        break;
74

75 76 77
    case GR_KB_CTRL:
        cmd = BLOCK_ROTATE;
        break;
78

79 80 81 82
    case MOUSE_MIDDLE:
        cmd = BLOCK_ZOOM;
        break;
    }
83

84
    return cmd;
85 86 87 88
}


/****************************************************/
89
int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
90
/****************************************************/
91

92
/* Command BLOCK END (end of block sizing)
93 94 95 96
 *  return :
 *  0 if command finished (zoom, delete ...)
 *  1 if HandleBlockPlace must follow (items found, and a block place command must follow)
 */
97
{
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
    int     ItemsCount    = 0, MustDoPlace = 0;
    MODULE* Currentmodule = m_Pcb->m_Modules;

    if( GetScreen()->BlockLocate.m_BlockDrawStruct )
    {
        BlockState   state   = GetScreen()->BlockLocate.m_State;
        CmdBlockType command = GetScreen()->BlockLocate.m_Command;
        DrawPanel->ForceCloseManageCurseur( DrawPanel, DC );
        GetScreen()->BlockLocate.m_State   = state;
        GetScreen()->BlockLocate.m_Command = command;
        DrawPanel->ManageCurseur = DrawAndSizingBlockOutlines;
        DrawPanel->ForceCloseManageCurseur = AbortBlockCurrentCommand;
        GetScreen()->m_Curseur.x = GetScreen()->BlockLocate.GetRight();
        GetScreen()->m_Curseur.y = GetScreen()->BlockLocate.GetBottom();
        DrawPanel->MouseToCursorSchema();
    }

    switch( GetScreen()->BlockLocate.m_Command )
    {
    case  BLOCK_IDLE:
        DisplayError( this, wxT( "Error in HandleBlockPLace" ) );
        break;

    case BLOCK_DRAG:        /* Drag */
    case BLOCK_MOVE:        /* Move */
    case BLOCK_COPY:        /* Copy */
        ItemsCount = MarkItemsInBloc( Currentmodule, GetScreen()->BlockLocate );
        if( ItemsCount )
        {
            MustDoPlace = 1;
            if( DrawPanel->ManageCurseur != NULL )
            {
                DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
                DrawPanel->ManageCurseur = DrawMovingBlockOutlines;
                DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
            }
            GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE;
            DrawPanel->Refresh( TRUE );
        }
        break;

    case BLOCK_PRESELECT_MOVE:     /* Move with preselection list*/
        MustDoPlace = 1;
        DrawPanel->ManageCurseur = DrawMovingBlockOutlines;
        GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE;
        break;

    case BLOCK_DELETE:     /* Delete */
        ItemsCount = MarkItemsInBloc( Currentmodule, GetScreen()->BlockLocate );
        if( ItemsCount )
            SaveCopyInUndoList( Currentmodule );
        DeleteMarkedItems( Currentmodule );
        break;

    case BLOCK_SAVE:     /* Save */
    case BLOCK_PASTE:
        break;

    case BLOCK_ROTATE:
        ItemsCount = MarkItemsInBloc( Currentmodule, GetScreen()->BlockLocate );
        if( ItemsCount )
            SaveCopyInUndoList( Currentmodule );
        RotateMarkedItems( Currentmodule, GetScreen()->BlockLocate.Centre() );
        break;


    case BLOCK_MIRROR_X:
    case BLOCK_MIRROR_Y:
    case BLOCK_INVERT:     /* mirror */
        ItemsCount = MarkItemsInBloc( Currentmodule, GetScreen()->BlockLocate );
        if( ItemsCount )
            SaveCopyInUndoList( Currentmodule );
        MirrorMarkedItems( Currentmodule, GetScreen()->BlockLocate.Centre() );
        break;

    case BLOCK_ZOOM:     /* Window Zoom */
        Window_Zoom( GetScreen()->BlockLocate );
        break;

    case BLOCK_ABORT:
        break;

    case BLOCK_SELECT_ITEMS_ONLY:
        break;
    }

    if( MustDoPlace <= 0 )
    {
        if( GetScreen()->BlockLocate.m_Command  != BLOCK_SELECT_ITEMS_ONLY )
        {
            ClearMarkItems( Currentmodule );
        }
        GetScreen()->BlockLocate.m_Flags   = 0;
        GetScreen()->BlockLocate.m_State   = STATE_NO_BLOCK;
        GetScreen()->BlockLocate.m_Command = BLOCK_IDLE;
        DrawPanel->ManageCurseur = NULL;
        DrawPanel->ForceCloseManageCurseur = NULL;
195
        SetCurItem( NULL );
196 197 198 199 200 201
        SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString );
        DrawPanel->Refresh( TRUE );
    }


    return MustDoPlace;
202 203 204 205
}


/******************************************************/
206
void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC )
207
/******************************************************/
208

209
/* Routine to handle the BLOCK PLACE commande
210 211 212 213
 *  Last routine for block operation for:
 *  - block move & drag
 *  - block copie & paste
 */
214
{
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
    bool    err = FALSE;
    MODULE* Currentmodule = m_Pcb->m_Modules;

    if( DrawPanel->ManageCurseur == NULL )
    {
        err = TRUE;
        DisplayError( this, wxT( "HandleBlockPLace : ManageCurseur = NULL" ) );
    }

    GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP;

    switch( GetScreen()->BlockLocate.m_Command )
    {
    case  BLOCK_IDLE:
        err = TRUE;
        break;

    case BLOCK_DRAG:                /* Drag */
    case BLOCK_MOVE:                /* Move */
    case BLOCK_PRESELECT_MOVE:      /* Move with preselection list*/
        GetScreen()->BlockLocate.m_BlockDrawStruct = NULL;
        SaveCopyInUndoList( Currentmodule );
        MoveMarkedItems( Currentmodule, GetScreen()->BlockLocate.m_MoveVector );
        DrawPanel->Refresh( TRUE );
        break;

    case BLOCK_COPY:     /* Copy */
        GetScreen()->BlockLocate.m_BlockDrawStruct = NULL;
        SaveCopyInUndoList( Currentmodule );
        CopyMarkedItems( Currentmodule, GetScreen()->BlockLocate.m_MoveVector );
        break;

    case BLOCK_PASTE:     /* Paste (recopie du dernier bloc sauve */
        GetScreen()->BlockLocate.m_BlockDrawStruct = NULL;
        break;

    case BLOCK_MIRROR_X:
    case BLOCK_MIRROR_Y:
    case BLOCK_INVERT:      /* Mirror by popup menu, from block move */
        SaveCopyInUndoList( Currentmodule );
        MirrorMarkedItems( Currentmodule, GetScreen()->BlockLocate.Centre() );
        break;

    case BLOCK_ROTATE:
        SaveCopyInUndoList( Currentmodule );
        RotateMarkedItems( Currentmodule, GetScreen()->BlockLocate.Centre() );
        break;

    case BLOCK_ZOOM:        // Handled by HandleBlockEnd
    case BLOCK_DELETE:
    case BLOCK_SAVE:
    case BLOCK_ABORT:
    default:
        break;
    }

    GetScreen()->SetModify();

    DrawPanel->ManageCurseur = NULL;
    DrawPanel->ForceCloseManageCurseur = NULL;
    GetScreen()->BlockLocate.m_Flags   = 0;
    GetScreen()->BlockLocate.m_State   = STATE_NO_BLOCK;
    GetScreen()->BlockLocate.m_Command = BLOCK_IDLE;
278
    SetCurItem( NULL );
279 280 281
    DrawPanel->Refresh( TRUE );

    SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString );
282 283 284 285
}


/************************************************************************/
286 287
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
                                     bool erase )
288
/************************************************************************/
289

290
/* Retrace le contour du block de recherche de structures
291 292
 *  L'ensemble du block suit le curseur
 */
293
{
294 295 296 297
    DrawBlockStruct* PtBlock;
    BASE_SCREEN*     screen = panel->m_Parent->GetScreen();
    EDA_BaseStruct*  item;
    wxPoint          move_offset;
298
    MODULE*          Currentmodule = g_EDA_Appl->m_ModuleEditFrame->m_Pcb->m_Modules;
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319

    PtBlock = &panel->GetScreen()->BlockLocate;
    GRSetDrawMode( DC, g_XorMode );

    /* Effacement ancien cadre */
    if( erase )
    {
        PtBlock->Offset( PtBlock->m_MoveVector );
        PtBlock->Draw( panel, DC );
        PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y );

        if( Currentmodule )
        {
            move_offset.x = -PtBlock->m_MoveVector.x;
            move_offset.y = -PtBlock->m_MoveVector.y;
            item = Currentmodule->m_Drawings;
            for( ; item != NULL; item = item->Next() )
            {
                if( item->m_Selected == 0 )
                    continue;

320
                switch( item->Type() )
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364
                {
                case TYPETEXTEMODULE:
                    ( (TEXTE_MODULE*) item )->Draw( panel, DC, move_offset, g_XorMode );
                    break;

                case TYPEEDGEMODULE:
                    ( (EDGE_MODULE*) item )->Draw( panel, DC, move_offset, g_XorMode );
                    break;

                default:
                    break;
                }
            }

            D_PAD* pad = Currentmodule->m_Pads;
            for( ; pad != NULL; pad = pad->Next() )
            {
                if( pad->m_Selected == 0 )
                    continue;
                pad->Draw( panel, DC, move_offset, g_XorMode );
            }
        }
    }

    /* Redessin nouvel affichage */
    PtBlock->m_MoveVector.x = screen->m_Curseur.x - PtBlock->m_BlockLastCursorPosition.x;
    PtBlock->m_MoveVector.y = screen->m_Curseur.y - PtBlock->m_BlockLastCursorPosition.y;

    GRSetDrawMode( DC, g_XorMode );
    PtBlock->Offset( PtBlock->m_MoveVector );
    PtBlock->Draw( panel, DC );
    PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y );


    if( Currentmodule )
    {
        item = Currentmodule->m_Drawings;
        move_offset.x = -PtBlock->m_MoveVector.x;
        move_offset.y = -PtBlock->m_MoveVector.y;
        for( ; item != NULL; item = item->Next() )
        {
            if( item->m_Selected == 0 )
                continue;

365
            switch( item->Type() )
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387
            {
            case TYPETEXTEMODULE:
                ( (TEXTE_MODULE*) item )->Draw( panel, DC, move_offset, g_XorMode );
                break;

            case TYPEEDGEMODULE:
                ( (EDGE_MODULE*) item )->Draw( panel, DC, move_offset, g_XorMode );
                break;

            default:
                break;
            }
        }

        D_PAD* pad = Currentmodule->m_Pads;
        for( ; pad != NULL; pad = pad->Next() )
        {
            if( pad->m_Selected == 0 )
                continue;
            pad->Draw( panel, DC, move_offset, g_XorMode );
        }
    }
388 389
}

390

391
/****************************************************************************/
392
void CopyMarkedItems( MODULE* module, wxPoint offset )
393
/****************************************************************************/
394 395 396

/* Copy marked items, at new position = old position + offset
 */
397
{
398 399
    BOARD_ITEM* item;
    BOARD_ITEM* NewStruct;
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426

    if( module == NULL )
        return;

    D_PAD* pad = module->m_Pads;
    for( ; pad != NULL; pad = pad->Next() )
    {
        if( pad->m_Selected == 0 )
            continue;
        pad->m_Selected = 0;
        D_PAD* NewPad = new D_PAD( module );
        NewPad->Copy( pad );
        NewPad->m_Selected = IS_SELECTED;
        NewPad->Pnext = module->m_Pads;
        NewPad->Pback = module;
        module->m_Pads->Pback = NewPad;
        module->m_Pads = NewPad;
    }

    item = module->m_Drawings;
    for( ; item != NULL; item = item->Next() )
    {
        if( item->m_Selected == 0 )
            continue;
        item->m_Selected = 0;
        NewStruct = NULL;

427
        switch( item->Type() )
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453
        {
        case TYPETEXTEMODULE:
            NewStruct = new TEXTE_MODULE( module );
            ( (TEXTE_MODULE*) NewStruct )->Copy( (TEXTE_MODULE*) item );
            break;

        case TYPEEDGEMODULE:
            NewStruct = new EDGE_MODULE( module );
            ( (EDGE_MODULE*) NewStruct )->Copy( (EDGE_MODULE*) item );
            break;

        default:
            DisplayError( NULL, wxT( "Internal Err: CopyMarkedItems: type indefini" ) );
            break;
        }

        if( NewStruct == NULL )
            break;
        NewStruct->m_Selected = IS_SELECTED;
        NewStruct->Pnext = module->m_Drawings;
        NewStruct->Pback = module;
        module->m_Drawings->Pback = module;
        module->m_Drawings = NewStruct;
    }

    MoveMarkedItems( module, offset );
454 455
}

456

457
/****************************************************/
458
void MoveMarkedItems( MODULE* module, wxPoint offset )
459
/****************************************************/
460 461 462

/* Move marked items, at new position = old position + offset
 */
463
{
464 465 466 467 468 469 470 471 472 473
    EDA_BaseStruct* item;

    if( module == NULL )
        return;

    D_PAD* pad = module->m_Pads;
    for( ; pad != NULL; pad = pad->Next() )
    {
        if( pad->m_Selected == 0 )
            continue;
474 475
        pad->GetPosition().x  += offset.x;
        pad->GetPosition().y  += offset.y;
476 477 478 479 480 481 482 483 484 485
        pad->m_Pos0.x += offset.x;
        pad->m_Pos0.y += offset.y;
    }

    item = module->m_Drawings;
    for( ; item != NULL; item = item->Next() )
    {
        if( item->m_Selected == 0 )
            continue;

486
        switch( item->Type() )
487 488
        {
        case TYPETEXTEMODULE:
489 490
            ( (TEXTE_MODULE*) item )->GetPosition().x  += offset.x;
            ( (TEXTE_MODULE*) item )->GetPosition().y  += offset.y;
491 492 493 494 495 496 497
            ( (TEXTE_MODULE*) item )->m_Pos0.x += offset.x;
            ( (TEXTE_MODULE*) item )->m_Pos0.y += offset.y;
            break;

        case TYPEEDGEMODULE:
            ( (EDGE_MODULE*) item )->m_Start.x  += offset.x;
            ( (EDGE_MODULE*) item )->m_Start.y  += offset.y;
498
            
499 500
            ( (EDGE_MODULE*) item )->m_End.x    += offset.x;
            ( (EDGE_MODULE*) item )->m_End.y    += offset.y;
501
            
502 503
            ( (EDGE_MODULE*) item )->m_Start0.x += offset.x;
            ( (EDGE_MODULE*) item )->m_Start0.y += offset.y;
504
            
505 506 507
            ( (EDGE_MODULE*) item )->m_End0.x   += offset.x;
            ( (EDGE_MODULE*) item )->m_End0.y   += offset.y;
            break;
508 509 510

        default:
            ;
511 512 513 514
        }

        item->m_Flags = item->m_Selected = 0;
    }
515 516
}

517

518
/******************************************************/
519
void DeleteMarkedItems( MODULE* module )
520
/******************************************************/
521 522 523

/* Delete marked items
 */
524
{
525 526 527 528
    BOARD_ITEM*     item;
    BOARD_ITEM*     next_item;
    D_PAD*          pad;
    D_PAD*          next_pad;
529 530 531 532 533 534 535 536 537 538

    if( module == NULL )
        return;

    pad = module->m_Pads;
    for( ; pad != NULL; pad = next_pad )
    {
        next_pad = pad->Next();
        if( pad->m_Selected == 0 )
            continue;
539
        pad->DeleteStructure();
540 541 542 543 544 545 546 547
    }

    item = module->m_Drawings;
    for( ; item != NULL; item = next_item )
    {
        next_item = item->Next();
        if( item->m_Selected == 0 )
            continue;
548
        item->DeleteStructure();
549
    }
550 551 552 553
}


/******************************************************/
554
void MirrorMarkedItems( MODULE* module, wxPoint offset )
555
/******************************************************/
556

557
/* Mirror marked items, refer to a Vertical axis at position offset
558
 */
559
{
560 561 562 563 564 565 566 567 568 569 570
#define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x;
    EDA_BaseStruct* item;

    if( module == NULL )
        return;

    D_PAD* pad = module->m_Pads;
    for( ; pad != NULL; pad = pad->Next() )
    {
        if( pad->m_Selected == 0 )
            continue;
571 572
        SETMIRROR( pad->GetPosition().x );
        pad->m_Pos0.x      = pad->GetPosition().x;
573 574 575 576 577 578 579 580 581 582 583 584
        pad->m_Offset.x    = -pad->m_Offset.x;
        pad->m_DeltaSize.x = -pad->m_DeltaSize.x;
        pad->m_Orient = 1800 - pad->m_Orient;
        NORMALIZE_ANGLE( pad->m_Orient );
    }

    item = module->m_Drawings;
    for( ; item != NULL; item = item->Next() )
    {
        if( item->m_Selected == 0 )
            continue;

585
        switch( item->Type() )
586 587 588 589 590 591 592 593 594 595
        {
        case TYPEEDGEMODULE:
            SETMIRROR( ( (EDGE_MODULE*) item )->m_Start.x );
            ( (EDGE_MODULE*) item )->m_Start0.x = ( (EDGE_MODULE*) item )->m_Start.x;
            SETMIRROR( ( (EDGE_MODULE*) item )->m_End.x );
            ( (EDGE_MODULE*) item )->m_End0.x = ( (EDGE_MODULE*) item )->m_End.x;
            ( (EDGE_MODULE*) item )->m_Angle  = -( (EDGE_MODULE*) item )->m_Angle;
            break;

        case TYPETEXTEMODULE:
596 597
            SETMIRROR( ( (TEXTE_MODULE*) item )->GetPosition().x );
            ( (TEXTE_MODULE*) item )->m_Pos0.x = ( (TEXTE_MODULE*) item )->GetPosition().x;
598
            break;
599 600 601
            
        default:
            ;
602 603 604 605
        }

        item->m_Flags = item->m_Selected = 0;
    }
606 607
}

608

609
/******************************************************/
610
void RotateMarkedItems( MODULE* module, wxPoint offset )
611
/******************************************************/
612

613
/* Rotate marked items, refer to a Vertical axis at position offset
614
 */
615
{
616 617 618 619 620 621 622 623 624 625 626
#define ROTATE( z ) RotatePoint( (&z), offset, 900 )
    EDA_BaseStruct* item;

    if( module == NULL )
        return;

    D_PAD* pad = module->m_Pads;
    for( ; pad != NULL; pad = pad->Next() )
    {
        if( pad->m_Selected == 0 )
            continue;
627 628
        ROTATE( pad->GetPosition() );
        pad->m_Pos0    = pad->GetPosition();
629 630 631 632 633 634 635 636 637 638
        pad->m_Orient += 900;
        NORMALIZE_ANGLE( pad->m_Orient );
    }

    item = module->m_Drawings;
    for( ; item != NULL; item = item->Next() )
    {
        if( item->m_Selected == 0 )
            continue;

639
        switch( item->Type() )
640 641 642 643 644 645 646 647 648
        {
        case TYPEEDGEMODULE:
            ROTATE( ( (EDGE_MODULE*) item )->m_Start );
            ( (EDGE_MODULE*) item )->m_Start0 = ( (EDGE_MODULE*) item )->m_Start;
            ROTATE( ( (EDGE_MODULE*) item )->m_End );
            ( (EDGE_MODULE*) item )->m_End0 = ( (EDGE_MODULE*) item )->m_End;
            break;

        case TYPETEXTEMODULE:
649 650
            ROTATE( ( (TEXTE_MODULE*) item )->GetPosition() );
            ( (TEXTE_MODULE*) item )->m_Pos0    = ( (TEXTE_MODULE*) item )->GetPosition();
651 652
            ( (TEXTE_MODULE*) item )->m_Orient += 900;
            break;
653 654 655
        
        default:
            ;
656 657 658 659
        }

        item->m_Flags = item->m_Selected = 0;
    }
660 661
}

662

663
/*********************************************************/
664
void ClearMarkItems( MODULE* module )
665 666
/*********************************************************/
{
667 668 669 670
    EDA_BaseStruct* item;

    if( module == NULL )
        return;
671

672 673 674
    item = module->m_Drawings;
    for( ; item != NULL; item = item->Next() )
        item->m_Flags = item->m_Selected = 0;
675

676 677 678
    item = module->m_Pads;
    for( ; item != NULL; item = item->Next() )
        item->m_Flags = item->m_Selected = 0;
679 680
}

681

682
/***************************************************************/
683
int MarkItemsInBloc( MODULE* module, EDA_Rect& Rect )
684
/***************************************************************/
685

686
/* Mark items inside rect.
687 688
 *  Items are inside rect when an end point is inside rect
 */
689
{
690 691 692 693 694 695 696 697 698 699 700 701
    EDA_BaseStruct* item;
    int             ItemsCount = 0;
    wxPoint         pos;
    D_PAD*          pad;

    if( module == NULL )
        return 0;

    pad = module->m_Pads;
    for( ; pad != NULL; pad = pad->Next() )
    {
        pad->m_Selected = 0;
702
        pos = pad->GetPosition();
703 704 705 706 707 708 709 710 711 712 713 714
        if( Rect.Inside( pos ) )
        {
            pad->m_Selected = IS_SELECTED;
            ItemsCount++;
        }
    }

    item = module->m_Drawings;
    for( ; item != NULL; item = item->Next() )
    {
        item->m_Selected = 0;

715
        switch( item->Type() )
716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732
        {
        case TYPEEDGEMODULE:
            pos = ( (EDGE_MODULE*) item )->m_Start;
            if( Rect.Inside( pos ) )
            {
                item->m_Selected = IS_SELECTED;
                ItemsCount++;
            }
            pos = ( (EDGE_MODULE*) item )->m_End;
            if( Rect.Inside( pos ) )
            {
                item->m_Selected = IS_SELECTED;
                ItemsCount++;
            }
            break;

        case TYPETEXTEMODULE:
733
            pos = ( (TEXTE_MODULE*) item )->GetPosition();
734 735 736 737 738 739 740 741 742 743 744 745 746
            if( Rect.Inside( pos ) )
            {
                item->m_Selected = IS_SELECTED;
                ItemsCount++;
            }
            break;

        default:
            break;
        }
    }

    return ItemsCount;
747
}