Commit bc9d5217 authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Eeschema: fix bug in load_one_schematic_file.cpp: error about files version,...

Eeschema: fix bug in load_one_schematic_file.cpp: error about files version, that create errors for hierarchical labels.
Pcbnew: cleaning code in block.cpp, and modifye previous way to calculate block size in block command, because old way creates unexpected behavior in block rotate and block flip.
Pcbnew: Fix a bug in plot silkscreen layers.
Cvpcb: Fix compilation issue under MACOX
parent 25df2772
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -15,6 +15,7 @@
#include "protos.h"
#include "protos.h"
#include "cvstruct.h"
#include "cvstruct.h"
#include "colors_selection.h"
#include "colors_selection.h"
#include "cvpcb_id.h"


#include "build_version.h"
#include "build_version.h"


+11 −7
Original line number Original line Diff line number Diff line
@@ -71,10 +71,14 @@ bool WinEDA_SchematicFrame::LoadOneEEFile( SCH_SCREEN* screen, const wxString& F
        return FALSE;
        return FALSE;
    }
    }


    // get the file version here. TODO: Support version numbers > 9
    // get the file version here.
    char version = line[9 + sizeof(SCHEMATIC_HEAD_STRING)];
    char *strversion = line + 9 + sizeof(SCHEMATIC_HEAD_STRING);
    int  ver     = version - '0';
    // Skip blanks
    if( ver > EESCHEMA_VERSION )
    while( *strversion && *strversion < '0' )
        strversion++;
    int  version = atoi(strversion);

    if( version > EESCHEMA_VERSION )
    {
    {
        MsgDiag = FullFileName + _( " was created by a more recent \
        MsgDiag = FullFileName + _( " was created by a more recent \
version of EESchema and may not load correctly. Please consider updating!" );
version of EESchema and may not load correctly. Please consider updating!" );
@@ -83,7 +87,7 @@ version of EESchema and may not load correctly. Please consider updating!" );


#if 0
#if 0
    // Compile it if the new version is unreadable by previous eeschema versions
    // Compile it if the new version is unreadable by previous eeschema versions
    else if( ver < EESCHEMA_VERSION )
    else if( version < EESCHEMA_VERSION )
    {
    {
        MsgDiag = FullFileName + _( " was created by an older version of \
        MsgDiag = FullFileName + _( " was created by an older version of \
EESchema. It will be stored in the new file format when you save this file \
EESchema. It will be stored in the new file format when you save this file \
@@ -159,9 +163,9 @@ again." );
            }
            }
            else if( Name1[0] == 'L' )
            else if( Name1[0] == 'L' )
                item = new SCH_LABEL();
                item = new SCH_LABEL();
            else if( Name1[0] == 'G' && ver > '1' )
            else if( Name1[0] == 'G' && version > 1 )
                item = new SCH_GLOBALLABEL();
                item = new SCH_GLOBALLABEL();
            else if( (Name1[0] == 'H') || (Name1[0] == 'G' && ver == '1') )
            else if( (Name1[0] == 'H') || (Name1[0] == 'G' && version == 1) )
                item = new SCH_HIERLABEL();
                item = new SCH_HIERLABEL();
            else
            else
                item = new SCH_TEXT();
                item = new SCH_TEXT();
+2 −0
Original line number Original line Diff line number Diff line
@@ -4,6 +4,7 @@ add_definitions(-DPCBNEW)
# Includes
# Includes
###
###
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
                    ${CMAKE_CURRENT_SOURCE_DIR}/dialogs
                    ${Boost_INCLUDE_DIR}
                    ${Boost_INCLUDE_DIR}
                    ../3d-viewer
                    ../3d-viewer
                    ../common
                    ../common
@@ -41,6 +42,7 @@ set(PCBNEW_SRCS
    cross-probing.cpp
    cross-probing.cpp
    debug_kbool_key_file_fct.cpp
    debug_kbool_key_file_fct.cpp
    deltrack.cpp
    deltrack.cpp
    dialogs/dialog_block_options_base.cpp
    dialog_copper_zones.cpp
    dialog_copper_zones.cpp
    dialog_copper_zones_base.cpp
    dialog_copper_zones_base.cpp
    dialog_design_rules.cpp
    dialog_design_rules.cpp
+204 −283
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@
#include "pcbplot.h"
#include "pcbplot.h"
#include "trigo.h"
#include "trigo.h"


#include "dialog_block_options_base.h"

#include "protos.h"
#include "protos.h"


#define BLOCK_OUTLINE_COLOR YELLOW
#define BLOCK_OUTLINE_COLOR YELLOW
@@ -29,6 +31,7 @@
 **/
 **/
static void drawPickedItems( WinEDA_DrawPanel* aPanel, wxDC* aDC,
static void drawPickedItems( WinEDA_DrawPanel* aPanel, wxDC* aDC,
                             wxPoint aOffset );
                             wxPoint aOffset );

/**
/**
 * Function drawMovingBlock
 * Function drawMovingBlock
 * handles drawing of a moving block
 * handles drawing of a moving block
@@ -40,184 +43,89 @@ static void drawMovingBlock( WinEDA_DrawPanel* aPanel, wxDC* aDC,
                             bool aErase );
                             bool aErase );




static bool Block_Include_Modules     = TRUE;
static bool Block_Include_Modules     = true;
static bool BlockIncludeLockedModules = TRUE;
static bool BlockIncludeLockedModules = true;
static bool Block_Include_Tracks      = TRUE;
static bool Block_Include_Tracks      = true;
static bool Block_Include_Zones       = TRUE;
static bool Block_Include_Zones       = true;
static bool Block_Include_Draw_Items  = TRUE;
static bool Block_Include_Draw_Items  = true;
static bool Block_Include_Edges_Items = TRUE;
static bool Block_Include_Edges_Items = true;
static bool Block_Include_PcbTextes   = TRUE;
static bool Block_Include_PcbTextes   = true;
static bool BlockDrawItems            = TRUE;
static bool BlockDrawItems = true;


/************************************/
/************************************/
/* class WinEDA_ExecBlockCmdFrame */
/* class DIALOG_BLOCK_OPTIONS */
/************************************/
/************************************/


class WinEDA_ExecBlockCmdFrame : public wxDialog
class DIALOG_BLOCK_OPTIONS : public DIALOG_BLOCK_OPTIONS_BASE
{
{
private:
private:

    WinEDA_BasePcbFrame* m_Parent;
    WinEDA_BasePcbFrame* m_Parent;
    wxCheckBox*          m_Include_Modules;
    wxCheckBox*          m_IncludeLockedModules;
    wxCheckBox*          m_Include_Tracks;
    wxCheckBox*          m_Include_Zones;
    wxCheckBox*          m_Include_Draw_Items;
    wxCheckBox*          m_Include_Edges_Items;
    wxCheckBox*          m_Include_PcbTextes;
    wxCheckBox*          m_DrawBlockItems;


public:
public:


    WinEDA_ExecBlockCmdFrame( WinEDA_BasePcbFrame* parent,
    DIALOG_BLOCK_OPTIONS( WinEDA_BasePcbFrame* parent,
                          const wxString&      title );
                          const wxString&      title );
    ~WinEDA_ExecBlockCmdFrame()
    ~DIALOG_BLOCK_OPTIONS()
    {
    {
    }
    }




private:
private:
    void ExecuteCommand( wxCommandEvent& event );
    void ExecuteCommand( wxCommandEvent& event );
    void Cancel( wxCommandEvent& event );
    void OnCancel( wxCommandEvent& event );
    void checkBoxClicked( wxCommandEvent& aEvent );
    void checkBoxClicked( wxCommandEvent& aEvent );

    DECLARE_EVENT_TABLE()
};
};




BEGIN_EVENT_TABLE( WinEDA_ExecBlockCmdFrame, wxDialog )
static bool InstallBlockCmdFrame( WinEDA_BasePcbFrame* parent, const wxString& title )
    EVT_BUTTON( wxID_OK, WinEDA_ExecBlockCmdFrame::ExecuteCommand )
    EVT_BUTTON( wxID_CANCEL, WinEDA_ExecBlockCmdFrame::Cancel )
    EVT_CHECKBOX( wxID_ANY, WinEDA_ExecBlockCmdFrame::checkBoxClicked )
END_EVENT_TABLE()


static bool InstallBlockCmdFrame( WinEDA_BasePcbFrame* parent,
                                  const wxString&      title )
{
{
    int     nocmd;
    int     nocmd;
    wxPoint oldpos = parent->GetScreen()->m_Curseur;
    wxPoint oldpos = parent->GetScreen()->m_Curseur;


    parent->DrawPanel->m_IgnoreMouseEvents = TRUE;
    parent->DrawPanel->m_IgnoreMouseEvents = true;
    WinEDA_ExecBlockCmdFrame* frame =
    DIALOG_BLOCK_OPTIONS dlg( parent, title );
        new WinEDA_ExecBlockCmdFrame( parent, title );


    nocmd = frame->ShowModal();
    nocmd = dlg.ShowModal();
    frame->Destroy();


    parent->GetScreen()->m_Curseur = oldpos;
    parent->GetScreen()->m_Curseur = oldpos;


    parent->DrawPanel->MouseToCursorSchema();
    parent->DrawPanel->MouseToCursorSchema();
    parent->DrawPanel->m_IgnoreMouseEvents = FALSE;
    parent->DrawPanel->m_IgnoreMouseEvents = false;


    parent->DrawPanel->SetCursor( parent->DrawPanel->m_PanelCursor =
    parent->DrawPanel->SetCursor( parent->DrawPanel->m_PanelCursor =
                                      parent->DrawPanel->m_PanelDefaultCursor );
                                      parent->DrawPanel->m_PanelDefaultCursor );


    return nocmd ? FALSE : TRUE;
    return nocmd ? false : true;
}
}




WinEDA_ExecBlockCmdFrame::WinEDA_ExecBlockCmdFrame( WinEDA_BasePcbFrame* parent,
DIALOG_BLOCK_OPTIONS::DIALOG_BLOCK_OPTIONS( WinEDA_BasePcbFrame* parent,
                                            const wxString&      title ) :
                                            const wxString&      title ) :
    wxDialog( parent, -1, title, wxPoint( -1, -1 ), wxDefaultSize,
    DIALOG_BLOCK_OPTIONS_BASE( parent, -1, title )
              DIALOG_STYLE )
{
{
    wxPoint   pos;
    wxButton* m_button1;
    wxButton* m_button2;

    m_Parent = parent;
    m_Parent = parent;
    Centre();
    this->SetSizeHints( wxDefaultSize, wxDefaultSize );
    this->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90,
                           false, wxEmptyString ) );

    /* Sizer 1 creation */
    wxFlexGridSizer* fgSizer1;
    fgSizer1 = new wxFlexGridSizer( 7, 1, 0, 0 );
    fgSizer1->SetFlexibleDirection( wxBOTH );
    fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );

    m_Include_Modules = new wxCheckBox( this, -1, _( "Include Modules" ),
                                        wxDefaultPosition, wxDefaultSize,
                                        0 );
    m_Include_Modules->SetValue( Block_Include_Modules );
    fgSizer1->Add( m_Include_Modules, 0, wxALL, 5 );


    m_IncludeLockedModules = new wxCheckBox( this, -1, _( "Include Locked Modules" ),
    m_Include_Modules->SetValue( Block_Include_Modules );
                                            wxDefaultPosition, wxDefaultSize,
                                            0 );
    m_IncludeLockedModules->SetValue( BlockIncludeLockedModules );
    m_IncludeLockedModules->SetValue( BlockIncludeLockedModules );
    if( m_Include_Modules->GetValue() )
        m_IncludeLockedModules->Enable();
    else
        m_IncludeLockedModules->Disable();
    fgSizer1->Add( m_IncludeLockedModules, 0, wxALL, 5 );

    m_Include_Tracks = new wxCheckBox( this, -1, _( "Include Tracks" ),
                                       wxDefaultPosition, wxDefaultSize, 0 );
    m_Include_Tracks->SetValue( Block_Include_Tracks );
    m_Include_Tracks->SetValue( Block_Include_Tracks );
    fgSizer1->Add( m_Include_Tracks, 0, wxALL, 5 );

    m_Include_Zones = new wxCheckBox( this, -1, _( "Include Zones" ),
                                      wxDefaultPosition, wxDefaultSize, 0 );
    m_Include_Zones->SetValue( Block_Include_Zones );
    m_Include_Zones->SetValue( Block_Include_Zones );
    fgSizer1->Add( m_Include_Zones, 0, wxALL, 5 );

    m_Include_PcbTextes = new wxCheckBox( this, -1,
                                          _( "Include Text Items" ),
                                          wxDefaultPosition,
                                          wxDefaultSize, 0 );
    m_Include_PcbTextes->SetValue( Block_Include_PcbTextes );
    fgSizer1->Add( m_Include_PcbTextes, 0, wxALL, 5 );

    m_Include_Draw_Items = new wxCheckBox( this, -1, _( "Include Drawings" ),
                                           wxDefaultPosition,
                                           wxDefaultSize, 0 );
    m_Include_Draw_Items->SetValue( Block_Include_Draw_Items );
    m_Include_Draw_Items->SetValue( Block_Include_Draw_Items );
    fgSizer1->Add( m_Include_Draw_Items, 0, wxALL, 5 );

    m_Include_Edges_Items = new wxCheckBox( this, -1,
                                            _( "Include Board Outline Layer" ),
                                            wxDefaultPosition,
                                            wxDefaultSize, 0 );
    m_Include_Edges_Items->SetValue( Block_Include_Edges_Items );
    m_Include_Edges_Items->SetValue( Block_Include_Edges_Items );
    fgSizer1->Add( m_Include_Edges_Items, 0, wxALL, 5 );
    m_Include_PcbTextes->SetValue( Block_Include_PcbTextes );

    m_DrawBlockItems = new wxCheckBox( this, -1,
                                       _( "Draw Block Items" ),
                                       wxDefaultPosition,
                                       wxDefaultSize, 0 );
    m_DrawBlockItems->SetValue( BlockDrawItems );
    m_DrawBlockItems->SetValue( BlockDrawItems );
    fgSizer1->Add( m_DrawBlockItems, 0, wxALL, 5 );
    SetFocus();

    GetSizer()->SetSizeHints( this );
    /* Sizer 2 creation */
    Centre();
    wxFlexGridSizer* fgSizer2;
    fgSizer2 = new wxFlexGridSizer( 1, 2, 0, 0 );
    fgSizer2->SetFlexibleDirection( wxBOTH );
    fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );

    m_button2 = new wxButton( this, wxID_CANCEL, _( "Cancel" ),
                              wxDefaultPosition, wxDefaultSize, 0 );
    fgSizer2->Add( m_button2, 0, wxALL, 5 );
    m_button1 = new wxButton( this, wxID_OK, _( "OK" ), wxDefaultPosition,
                              wxDefaultSize, 0 );
    m_button1->SetDefault();
    fgSizer2->Add( m_button1, 0, wxALL, 5 );

    fgSizer1->Add( fgSizer2, 1, wxALIGN_RIGHT, 5 );
    this->SetSizer( fgSizer1 );
    this->Layout();
    fgSizer1->Fit( this );
}
}




void WinEDA_ExecBlockCmdFrame::Cancel( wxCommandEvent& WXUNUSED (event) )
void DIALOG_BLOCK_OPTIONS::OnCancel( wxCommandEvent& WXUNUSED (event) )
{
{
    EndModal( -1 );
    EndModal( -1 );
}
}


void WinEDA_ExecBlockCmdFrame::checkBoxClicked( wxCommandEvent& WXUNUSED (aEvent) )

void DIALOG_BLOCK_OPTIONS::checkBoxClicked( wxCommandEvent& WXUNUSED (aEvent) )
{
{
    if( m_Include_Modules->GetValue() )
    if( m_Include_Modules->GetValue() )
        m_IncludeLockedModules->Enable();
        m_IncludeLockedModules->Enable();
@@ -225,7 +133,8 @@ void WinEDA_ExecBlockCmdFrame::checkBoxClicked( wxCommandEvent& WXUNUSED (aEvent
        m_IncludeLockedModules->Disable();
        m_IncludeLockedModules->Disable();
}
}


void WinEDA_ExecBlockCmdFrame::ExecuteCommand( wxCommandEvent& event )

void DIALOG_BLOCK_OPTIONS::ExecuteCommand( wxCommandEvent& event )
{
{
    Block_Include_Modules     = m_Include_Modules->GetValue();
    Block_Include_Modules     = m_Include_Modules->GetValue();
    BlockIncludeLockedModules = m_IncludeLockedModules->GetValue();
    BlockIncludeLockedModules = m_IncludeLockedModules->GetValue();
@@ -285,11 +194,11 @@ int WinEDA_PcbFrame::ReturnBlockCommand( int key )
/* Routine to handle the BLOCK PLACE command */
/* Routine to handle the BLOCK PLACE command */
void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC )
void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC )
{
{
    bool err = FALSE;
    bool err = false;


    if( DrawPanel->ManageCurseur == NULL )
    if( DrawPanel->ManageCurseur == NULL )
    {
    {
        err = TRUE;
        err = true;
        DisplayError( this, wxT( "Error in HandleBlockPLace : ManageCurseur = NULL" ) );
        DisplayError( this, wxT( "Error in HandleBlockPLace : ManageCurseur = NULL" ) );
    }
    }
    GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP;
    GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP;
@@ -297,21 +206,21 @@ void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC )
    switch( GetScreen()->m_BlockLocate.m_Command )
    switch( GetScreen()->m_BlockLocate.m_Command )
    {
    {
    case BLOCK_IDLE:
    case BLOCK_IDLE:
        err = TRUE;
        err = true;
        break;
        break;


    case BLOCK_DRAG:                /* Drag */
    case BLOCK_DRAG:                /* Drag */
    case BLOCK_MOVE:                /* Move */
    case BLOCK_MOVE:                /* Move */
    case BLOCK_PRESELECT_MOVE:      /* Move with preselection list*/
    case BLOCK_PRESELECT_MOVE:      /* Move with preselection list*/
        if( DrawPanel->ManageCurseur )
        if( DrawPanel->ManageCurseur )
            DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
            DrawPanel->ManageCurseur( DrawPanel, DC, false );
        Block_Move();
        Block_Move();
        GetScreen()->m_BlockLocate.ClearItemsList();
        GetScreen()->m_BlockLocate.ClearItemsList();
        break;
        break;


    case BLOCK_COPY:     /* Copy */
    case BLOCK_COPY:     /* Copy */
        if( DrawPanel->ManageCurseur )
        if( DrawPanel->ManageCurseur )
            DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
            DrawPanel->ManageCurseur( DrawPanel, DC, false );
        Block_Duplicate();
        Block_Duplicate();
        GetScreen()->m_BlockLocate.ClearItemsList();
        GetScreen()->m_BlockLocate.ClearItemsList();
        break;
        break;
@@ -349,7 +258,7 @@ void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC )
 */
 */
int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
{
{
    int endcommande = TRUE;
    int endcommande = true;


    // If coming here after cancel block, clean up and exit
    // If coming here after cancel block, clean up and exit
    if( GetScreen()->m_BlockLocate.m_State == STATE_NO_BLOCK )
    if( GetScreen()->m_BlockLocate.m_State == STATE_NO_BLOCK )
@@ -365,8 +274,8 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )


    // Show dialog if there are no selected items and
    // Show dialog if there are no selected items and
    // we're not zooming
    // we're not zooming
    if ( !GetScreen()->m_BlockLocate.GetCount() &&
    if( !GetScreen()->m_BlockLocate.GetCount()
         GetScreen()->m_BlockLocate.m_Command != BLOCK_ZOOM )
        && GetScreen()->m_BlockLocate.m_Command != BLOCK_ZOOM )
    {
    {
        if( !InstallBlockCmdFrame( this, _( "Block Operation" ) ) )
        if( !InstallBlockCmdFrame( this, _( "Block Operation" ) ) )
        {
        {
@@ -377,15 +286,15 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
            GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
            GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
            GetScreen()->m_BlockLocate.ClearItemsList();
            GetScreen()->m_BlockLocate.ClearItemsList();
            DisplayToolMsg( wxEmptyString );
            DisplayToolMsg( wxEmptyString );
            DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE );
            DrawAndSizingBlockOutlines( DrawPanel, DC, false );
            return 0;
            return 0;
        }
        }

        DrawAndSizingBlockOutlines( DrawPanel, DC, false );
        DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE );
        Block_SelectItems();
        Block_SelectItems();


        // Exit if no items found
        // Exit if no items found
        if( !GetScreen()->m_BlockLocate.GetCount() ) {
        if( !GetScreen()->m_BlockLocate.GetCount() )
        {
            DrawPanel->ManageCurseur = NULL;
            DrawPanel->ManageCurseur = NULL;
            DrawPanel->ForceCloseManageCurseur   = NULL;
            DrawPanel->ForceCloseManageCurseur   = NULL;
            GetScreen()->m_BlockLocate.m_Flags   = 0;
            GetScreen()->m_BlockLocate.m_Flags   = 0;
@@ -396,15 +305,19 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
            return 0;
            return 0;
        }
        }


        // Move cursor to the center of the smallest rectangle
        wxPoint blockCenter;

        // Move cursor to the best position in selected rect:
        // can be the block locate rect or the the smallest rectangle
        // containing the centers of all selected items.
        // containing the centers of all selected items.
        // Unfortunately, this option gives unpredicatble results when flipping or mirroring blocks
#if 0   // set to 1 to use  smallest rectangle center
        // Move cursor to the center of
        // Also set m_BlockLocate to the size of the rectangle.
        // Also set m_BlockLocate to the size of the rectangle.
        PICKED_ITEMS_LIST* itemsList = &DrawPanel->GetScreen()->m_BlockLocate.m_ItemsSelection;
        PICKED_ITEMS_LIST* itemsList = &DrawPanel->GetScreen()->m_BlockLocate.m_ItemsSelection;
        wxPoint blockCenter;
        int minX, minY, maxX, maxY;
        int minX, minY, maxX, maxY;
        int tempX, tempY;
        int tempX, tempY;
        BOARD_ITEM*        item = (BOARD_ITEM*) itemsList->GetPickedItem( 0 );
        BOARD_ITEM*        item = (BOARD_ITEM*) itemsList->GetPickedItem( 0 );

        minX = item->GetPosition().x;
        minX = item->GetPosition().x;
        minY = item->GetPosition().y;
        minY = item->GetPosition().y;
        maxX = minX;
        maxX = minX;
@@ -426,17 +339,19 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )


        blockCenter.x = ( minX + maxX ) / 2;
        blockCenter.x = ( minX + maxX ) / 2;
        blockCenter.y = ( minY + maxY ) / 2;
        blockCenter.y = ( minY + maxY ) / 2;
        GetScreen()->m_BlockLocate.SetOrigin( minX, minY );
        GetScreen()->m_BlockLocate.SetEnd( maxX, maxY );
#else
        blockCenter = GetScreen()->m_BlockLocate.Centre();
#endif
        DrawPanel->CursorOff( DC );
        DrawPanel->CursorOff( DC );
        GetScreen()->m_Curseur = blockCenter;
        GetScreen()->m_Curseur = blockCenter;
        GetScreen()->m_BlockLocate.SetLastCursorPosition( blockCenter );
        GetScreen()->m_BlockLocate.SetLastCursorPosition( blockCenter );
        GetScreen()->m_BlockLocate.SetOrigin( minX, minY );
        GetScreen()->m_BlockLocate.SetEnd( maxX, maxY );
        DrawPanel->MouseToCursorSchema();
        DrawPanel->MouseToCursorSchema();
        DrawPanel->CursorOn( DC );
        DrawPanel->CursorOn( DC );
    }
    }


    if( DrawPanel->ManageCurseur )
    if( DrawPanel->ManageCurseur )
    {
        switch( GetScreen()->m_BlockLocate.m_Command )
        switch( GetScreen()->m_BlockLocate.m_Command )
        {
        {
        case BLOCK_IDLE:
        case BLOCK_IDLE:
@@ -448,9 +363,9 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
        case BLOCK_COPY:            /* Copy */
        case BLOCK_COPY:            /* Copy */
        case BLOCK_PRESELECT_MOVE:  /* Move with preselection list*/
        case BLOCK_PRESELECT_MOVE:  /* Move with preselection list*/
            GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE;
            GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE;
            endcommande = FALSE;
            endcommande = false;
            DrawPanel->ManageCurseur = drawMovingBlock;
            DrawPanel->ManageCurseur = drawMovingBlock;
            DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
            DrawPanel->ManageCurseur( DrawPanel, DC, false );
            break;
            break;


        case BLOCK_DELETE: /* Delete */
        case BLOCK_DELETE: /* Delete */
@@ -493,9 +408,8 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
        default:
        default:
            break;
            break;
        }
        }
    }


    if( endcommande == TRUE )
    if( endcommande == true )
    {
    {
        GetScreen()->m_BlockLocate.m_Flags   = 0;
        GetScreen()->m_BlockLocate.m_Flags   = 0;
        GetScreen()->m_BlockLocate.m_State   = STATE_NO_BLOCK;
        GetScreen()->m_BlockLocate.m_State   = STATE_NO_BLOCK;
@@ -533,8 +447,8 @@ void WinEDA_PcbFrame::Block_SelectItems()
        for( MODULE* module = m_Pcb->m_Modules; module != NULL;
        for( MODULE* module = m_Pcb->m_Modules; module != NULL;
            module = module->Next() )
            module = module->Next() )
        {
        {
            if( module->HitTest( GetScreen()->m_BlockLocate ) &&
            if( module->HitTest( GetScreen()->m_BlockLocate )
                ( !module->IsLocked() || BlockIncludeLockedModules ) )
               && ( !module->IsLocked() || BlockIncludeLockedModules ) )
            {
            {
                picker.m_PickedItem     = module;
                picker.m_PickedItem     = module;
                picker.m_PickedItemType = module->Type();
                picker.m_PickedItemType = module->Type();
@@ -621,13 +535,15 @@ void WinEDA_PcbFrame::Block_SelectItems()
    if( Block_Include_Zones )
    if( Block_Include_Zones )
    {
    {
#if 0
#if 0

        /* This section can creates problems if selected:
        /* This section can creates problems if selected:
         * m_Pcb->m_Zone can have a *lot* of items (100 000 is easily possible)
         * m_Pcb->m_Zone can have a *lot* of items (100 000 is easily possible)
         * so it is not selected (and TODO: will be removed, one day)
         * so it is not selected (and TODO: will be removed, one day)
         */
         */
        for( SEGZONE* pt_segm = m_Pcb->m_Zone; pt_segm != NULL;
        for( SEGZONE* pt_segm = m_Pcb->m_Zone; pt_segm != NULL;
            pt_segm = pt_segm->Next() )
            pt_segm = pt_segm->Next() )
        {    /* Segments used in Zone filling selection */
        {
            /* Segments used in Zone filling selection */


            if( pt_segm->HitTest( GetScreen()->m_BlockLocate ) )
            if( pt_segm->HitTest( GetScreen()->m_BlockLocate ) )
            {
            {
@@ -636,6 +552,7 @@ void WinEDA_PcbFrame::Block_SelectItems()
                itemsList->PushItem( picker );
                itemsList->PushItem( picker );
            }
            }
        }
        }

#endif
#endif
        for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
        for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
        {
        {
@@ -650,13 +567,14 @@ void WinEDA_PcbFrame::Block_SelectItems()
    }
    }
}
}



static void drawPickedItems( WinEDA_DrawPanel* aPanel, wxDC* aDC,
static void drawPickedItems( WinEDA_DrawPanel* aPanel, wxDC* aDC,
                             wxPoint aOffset )
                             wxPoint aOffset )
{
{
    PICKED_ITEMS_LIST*   itemsList = &aPanel->GetScreen()->m_BlockLocate.m_ItemsSelection;
    PICKED_ITEMS_LIST*   itemsList = &aPanel->GetScreen()->m_BlockLocate.m_ItemsSelection;
    WinEDA_BasePcbFrame* frame     = (WinEDA_BasePcbFrame*) aPanel->GetParent();
    WinEDA_BasePcbFrame* frame     = (WinEDA_BasePcbFrame*) aPanel->GetParent();
    g_Offset_Module = -aOffset;


    g_Offset_Module = -aOffset;
    for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
    for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
    {
    {
        BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
        BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
@@ -669,18 +587,21 @@ static void drawPickedItems( WinEDA_DrawPanel* aPanel, wxDC* aDC,
            DrawModuleOutlines( aPanel, aDC, module );
            DrawModuleOutlines( aPanel, aDC, module );
            break;
            break;
        }
        }

        case TYPE_DRAWSEGMENT:
        case TYPE_DRAWSEGMENT:
        {
        {
            DRAWSEGMENT* segment = (DRAWSEGMENT*) item;
            DRAWSEGMENT* segment = (DRAWSEGMENT*) item;
            segment->Draw( aPanel, aDC, GR_XOR, aOffset );
            segment->Draw( aPanel, aDC, GR_XOR, aOffset );
            break;
            break;
        }
        }

        case TYPE_TEXTE:
        case TYPE_TEXTE:
        {
        {
            TEXTE_PCB* text = (TEXTE_PCB*) item;
            TEXTE_PCB* text = (TEXTE_PCB*) item;
            text->Draw( aPanel, aDC, GR_XOR, aOffset );
            text->Draw( aPanel, aDC, GR_XOR, aOffset );
            break;
            break;
        }
        }

        case TYPE_TRACK:
        case TYPE_TRACK:
        case TYPE_VIA:
        case TYPE_VIA:
        {
        {
@@ -688,18 +609,21 @@ static void drawPickedItems( WinEDA_DrawPanel* aPanel, wxDC* aDC,
            track->Draw( aPanel, aDC, GR_XOR, aOffset );
            track->Draw( aPanel, aDC, GR_XOR, aOffset );
            break;
            break;
        }
        }

        case TYPE_MIRE:
        case TYPE_MIRE:
        {
        {
            MIREPCB* mire = (MIREPCB*) item;
            MIREPCB* mire = (MIREPCB*) item;
            mire->Draw( aPanel, aDC, GR_XOR, aOffset );
            mire->Draw( aPanel, aDC, GR_XOR, aOffset );
            break;
            break;
        }
        }

        case TYPE_DIMENSION:
        case TYPE_DIMENSION:
        {
        {
            DIMENSION* dimension = (DIMENSION*) item;
            DIMENSION* dimension = (DIMENSION*) item;
            dimension->Draw( aPanel, aDC, GR_XOR, aOffset );
            dimension->Draw( aPanel, aDC, GR_XOR, aOffset );
            break;
            break;
        }
        }

        case TYPE_ZONE_CONTAINER:
        case TYPE_ZONE_CONTAINER:
        {
        {
            ZONE_CONTAINER* zoneContainer = (ZONE_CONTAINER*) item;
            ZONE_CONTAINER* zoneContainer = (ZONE_CONTAINER*) item;
@@ -707,6 +631,7 @@ static void drawPickedItems( WinEDA_DrawPanel* aPanel, wxDC* aDC,
            zoneContainer->DrawFilledArea( aPanel, aDC, GR_XOR, aOffset );
            zoneContainer->DrawFilledArea( aPanel, aDC, GR_XOR, aOffset );
            break;
            break;
        }
        }

        // Currently markers are not affected by block commands
        // Currently markers are not affected by block commands
        case TYPE_MARKER_PCB:
        case TYPE_MARKER_PCB:
        {
        {
@@ -719,9 +644,11 @@ static void drawPickedItems( WinEDA_DrawPanel* aPanel, wxDC* aDC,
            break;
            break;
        }
        }
    }
    }

    g_Offset_Module = wxPoint( 0, 0 );
    g_Offset_Module = wxPoint( 0, 0 );
}
}



static void drawMovingBlock( WinEDA_DrawPanel* aPanel, wxDC* aDC,
static void drawMovingBlock( WinEDA_DrawPanel* aPanel, wxDC* aDC,
                             bool aErase )
                             bool aErase )
{
{
@@ -732,29 +659,25 @@ static void drawMovingBlock( WinEDA_DrawPanel* aPanel, wxDC* aDC,
        if( screen->m_BlockLocate.m_MoveVector.x
        if( screen->m_BlockLocate.m_MoveVector.x
            || screen->m_BlockLocate.m_MoveVector.y )
            || screen->m_BlockLocate.m_MoveVector.y )
        {
        {
            if( !BlockDrawItems )
            screen->m_BlockLocate.Draw( aPanel, aDC, screen->m_BlockLocate.m_MoveVector,
            screen->m_BlockLocate.Draw( aPanel, aDC, screen->m_BlockLocate.m_MoveVector,
                                        GR_XOR, BLOCK_OUTLINE_COLOR );
                                        GR_XOR, BLOCK_OUTLINE_COLOR );
            else
            if( BlockDrawItems )
                drawPickedItems( aPanel, aDC, screen->m_BlockLocate.m_MoveVector );
                drawPickedItems( aPanel, aDC, screen->m_BlockLocate.m_MoveVector );
        }
        }
    }
    }


    if( screen->m_BlockLocate.m_State != STATE_BLOCK_STOP )
    if( screen->m_BlockLocate.m_State != STATE_BLOCK_STOP )
    {
    {
        screen->m_BlockLocate.m_MoveVector.x = screen->m_Curseur.x -
        screen->m_BlockLocate.m_MoveVector = screen->m_Curseur -
                                               screen->m_BlockLocate.m_BlockLastCursorPosition.x;
                                             screen->m_BlockLocate.m_BlockLastCursorPosition;
        screen->m_BlockLocate.m_MoveVector.y = screen->m_Curseur.y -
                                               screen->m_BlockLocate.m_BlockLastCursorPosition.y;
    }
    }


    if( screen->m_BlockLocate.m_MoveVector.x
    if( screen->m_BlockLocate.m_MoveVector.x
        || screen->m_BlockLocate.m_MoveVector.y )
        || screen->m_BlockLocate.m_MoveVector.y )
    {
    {
            if( !BlockDrawItems )
        screen->m_BlockLocate.Draw( aPanel, aDC, screen->m_BlockLocate.m_MoveVector,
        screen->m_BlockLocate.Draw( aPanel, aDC, screen->m_BlockLocate.m_MoveVector,
                                    GR_XOR, BLOCK_OUTLINE_COLOR );
                                    GR_XOR, BLOCK_OUTLINE_COLOR );
            else
        if( BlockDrawItems )
            drawPickedItems( aPanel, aDC, screen->m_BlockLocate.m_MoveVector );
            drawPickedItems( aPanel, aDC, screen->m_BlockLocate.m_MoveVector );
    }
    }
}
}
@@ -817,8 +740,8 @@ void WinEDA_PcbFrame::Block_Delete()


    SaveCopyInUndoList( *itemsList, UR_DELETED );
    SaveCopyInUndoList( *itemsList, UR_DELETED );


    Compile_Ratsnest( NULL, TRUE );
    Compile_Ratsnest( NULL, true );
    DrawPanel->Refresh( TRUE );
    DrawPanel->Refresh( true );
}
}




@@ -848,7 +771,6 @@ void WinEDA_PcbFrame::Block_Rotate()
        wxASSERT( item );
        wxASSERT( item );
        itemsList->SetPickedItemStatus( UR_ROTATED, ii );
        itemsList->SetPickedItemStatus( UR_ROTATED, ii );
        item->Rotate( centre, rotAngle );
        item->Rotate( centre, rotAngle );

        switch( item->Type() )
        switch( item->Type() )
        {
        {
        case TYPE_MODULE:
        case TYPE_MODULE:
@@ -883,14 +805,14 @@ void WinEDA_PcbFrame::Block_Rotate()


    SaveCopyInUndoList( *itemsList, UR_ROTATED, centre );
    SaveCopyInUndoList( *itemsList, UR_ROTATED, centre );


    Compile_Ratsnest( NULL, TRUE );
    Compile_Ratsnest( NULL, true );
    DrawPanel->Refresh( TRUE );
    DrawPanel->Refresh( true );
}
}




/**
/**
 * Function Block_Flip
 * Function Block_Flip
 * flips items within the selected block.
 * Flip items within the selected block.
 * The flip center is the center of the block
 * The flip center is the center of the block
 * @param none
 * @param none
 */
 */
@@ -915,7 +837,6 @@ void WinEDA_PcbFrame::Block_Flip()
        wxASSERT( item );
        wxASSERT( item );
        itemsList->SetPickedItemStatus( UR_FLIPPED, ii );
        itemsList->SetPickedItemStatus( UR_FLIPPED, ii );
        item->Flip( center );
        item->Flip( center );

        switch( item->Type() )
        switch( item->Type() )
        {
        {
        case TYPE_MODULE:
        case TYPE_MODULE:
@@ -950,8 +871,8 @@ void WinEDA_PcbFrame::Block_Flip()
    }
    }


    SaveCopyInUndoList( *itemsList, UR_FLIPPED, center );
    SaveCopyInUndoList( *itemsList, UR_FLIPPED, center );
    Compile_Ratsnest( NULL, TRUE );
    Compile_Ratsnest( NULL, true );
    DrawPanel->Refresh( TRUE );
    DrawPanel->Refresh( true );
}
}




@@ -1011,14 +932,14 @@ void WinEDA_PcbFrame::Block_Move()


    SaveCopyInUndoList( *itemsList, UR_MOVED, MoveVector );
    SaveCopyInUndoList( *itemsList, UR_MOVED, MoveVector );


    Compile_Ratsnest( NULL, TRUE );
    Compile_Ratsnest( NULL, true );
    DrawPanel->Refresh( TRUE );
    DrawPanel->Refresh( true );
}
}




/**
/**
 * Function Block_Duplicate
 * Function Block_Duplicate
 * duplicates all items within the selected block.
 * Duplicate all items within the selected block.
 * New location is determined by the current offset from the selected block's
 * New location is determined by the current offset from the selected block's
 * original location.
 * original location.
 * @param none
 * @param none
@@ -1134,6 +1055,6 @@ void WinEDA_PcbFrame::Block_Duplicate()
    if( newList.GetCount() )
    if( newList.GetCount() )
        SaveCopyInUndoList( newList, UR_NEW );
        SaveCopyInUndoList( newList, UR_NEW );


    Compile_Ratsnest( NULL, TRUE );
    Compile_Ratsnest( NULL, true );
    DrawPanel->Refresh( TRUE );
    DrawPanel->Refresh( true );
}
}
Loading