36 changed files with 27 additions and 2689 deletions
-
2common/CMakeLists.txt
-
4common/base_struct.cpp
-
22common/gr_basic.cpp
-
60common/legacy_gal/block.cpp
-
44common/legacy_gal/eda_draw_frame.cpp
-
223common/legacy_wx/block.cpp
-
130common/legacy_wx/eda_draw_frame.cpp
-
114common/legacy_wx/eda_draw_panel.cpp
-
1eeschema/sch_edit_frame.h
-
2eeschema/sch_field.h
-
2eeschema/tools/lib_control.cpp
-
1gerbview/CMakeLists.txt
-
219gerbview/block.cpp
-
8gerbview/events_called_functions.cpp
-
34gerbview/gerbview_frame.h
-
8include/base_screen.h
-
230include/block_commande.h
-
44include/draw_frame.h
-
8include/gr_basic.h
-
7include/undo_redo_container.h
-
2pcbnew/CMakeLists.txt
-
217pcbnew/append_board_to_current.cpp
-
890pcbnew/block_footprint_editor.cpp
-
4pcbnew/controle.cpp
-
67pcbnew/edit.cpp
-
15pcbnew/files.cpp
-
5pcbnew/footprint_edit_frame.cpp
-
44pcbnew/footprint_edit_frame.h
-
87pcbnew/footprint_editor_utils.cpp
-
30pcbnew/hotkeys_footprint_editor.cpp
-
134pcbnew/import_gfx/dialog_import_gfx.cpp
-
23pcbnew/menubar_pcb_editor.cpp
-
1pcbnew/move-drag_pads.cpp
-
23pcbnew/pcb_base_edit_frame.h
-
7pcbnew/pcb_edit_frame.h
-
4pcbnew/undo_redo.cpp
@ -1,60 +0,0 @@ |
|||
/**
|
|||
* OBSOLETE |
|||
*/ |
|||
|
|||
#include <fctsys.h>
|
|||
#include <gr_basic.h>
|
|||
#include <draw_frame.h>
|
|||
#include <common.h>
|
|||
#include <macros.h>
|
|||
#include <block_commande.h>
|
|||
|
|||
|
|||
BLOCK_SELECTOR::BLOCK_SELECTOR() : |
|||
EDA_RECT() |
|||
{ |
|||
m_state = STATE_NO_BLOCK; // State (enum BLOCK_STATE_T) of block.
|
|||
m_command = BLOCK_IDLE; // Type (enum BLOCK_COMMAND_T) of operation.
|
|||
} |
|||
|
|||
|
|||
BLOCK_SELECTOR::~BLOCK_SELECTOR() |
|||
{ |
|||
} |
|||
|
|||
|
|||
void BLOCK_SELECTOR::SetMessageBlock( EDA_DRAW_FRAME* frame ) |
|||
{ |
|||
} |
|||
|
|||
|
|||
void BLOCK_SELECTOR::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, |
|||
GR_DRAWMODE aDrawMode, COLOR4D aColor ) |
|||
{ |
|||
} |
|||
|
|||
|
|||
void BLOCK_SELECTOR::InitData( EDA_DRAW_PANEL* aPanel, const wxPoint& startpos ) |
|||
{ |
|||
} |
|||
|
|||
|
|||
void BLOCK_SELECTOR::ClearItemsList() |
|||
{ |
|||
} |
|||
|
|||
|
|||
void BLOCK_SELECTOR::ClearListAndDeleteItems() |
|||
{ |
|||
} |
|||
|
|||
|
|||
void BLOCK_SELECTOR::PushItem( ITEM_PICKER& aItem ) |
|||
{ |
|||
} |
|||
|
|||
|
|||
void BLOCK_SELECTOR::Clear() |
|||
{ |
|||
} |
|||
|
@ -1,223 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com |
|||
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. |
|||
* |
|||
* This program is free software; you can redistribute it and/or |
|||
* modify it under the terms of the GNU General Public License |
|||
* as published by the Free Software Foundation; either version 2 |
|||
* of the License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|||
* or you may search the http://www.gnu.org website for the version 2 license,
|
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
/**
|
|||
* @file block_commande.cpp |
|||
* @brief Common routines for managing on block commands. |
|||
*/ |
|||
|
|||
#include <fctsys.h>
|
|||
#include <gr_basic.h>
|
|||
#include <draw_frame.h>
|
|||
#include <common.h>
|
|||
#include <macros.h>
|
|||
#include <base_struct.h>
|
|||
#include <base_screen.h>
|
|||
#include <class_drawpanel.h>
|
|||
#include <confirm.h>
|
|||
#include <block_commande.h>
|
|||
|
|||
|
|||
BLOCK_SELECTOR::BLOCK_SELECTOR() : |
|||
EDA_RECT() |
|||
{ |
|||
m_state = STATE_NO_BLOCK; // State (enum BLOCK_STATE_T) of block.
|
|||
m_command = BLOCK_IDLE; // Type (enum BLOCK_COMMAND_T) of operation.
|
|||
m_color = BROWN; |
|||
m_appendUndo = false; |
|||
} |
|||
|
|||
|
|||
BLOCK_SELECTOR::~BLOCK_SELECTOR() |
|||
{ |
|||
ClearListAndDeleteItems(); |
|||
} |
|||
|
|||
|
|||
void BLOCK_SELECTOR::SetMessageBlock( EDA_DRAW_FRAME* frame ) |
|||
{ |
|||
wxString msg; |
|||
|
|||
switch( m_command ) |
|||
{ |
|||
case BLOCK_IDLE: |
|||
break; |
|||
|
|||
case BLOCK_MOVE: // Move
|
|||
case BLOCK_PRESELECT_MOVE: // Move with preselection list
|
|||
case BLOCK_MOVE_EXACT: |
|||
msg = _( "Block Move" ); |
|||
break; |
|||
|
|||
case BLOCK_DRAG: // Drag
|
|||
msg = _( "Block Drag" ); |
|||
break; |
|||
|
|||
case BLOCK_DRAG_ITEM: // Drag
|
|||
msg = _( "Drag item" ); |
|||
break; |
|||
|
|||
case BLOCK_DUPLICATE: // Duplicate
|
|||
msg = _( "Block Duplicate" ); |
|||
break; |
|||
|
|||
case BLOCK_DELETE: // Delete
|
|||
msg = _( "Block Delete" ); |
|||
break; |
|||
|
|||
case BLOCK_COPY: // Copy
|
|||
msg = _( "Block Copy" ); |
|||
break; |
|||
|
|||
case BLOCK_PASTE: |
|||
msg = _( "Block Paste" ); |
|||
break; |
|||
|
|||
case BLOCK_ZOOM: // Window Zoom
|
|||
msg = _( "Zoom to selection" ); |
|||
break; |
|||
|
|||
case BLOCK_FLIP: // Flip
|
|||
msg = _( "Block Flip" ); |
|||
break; |
|||
|
|||
case BLOCK_ABORT: |
|||
break; |
|||
|
|||
default: |
|||
msg = wxT( "???" ); |
|||
break; |
|||
} |
|||
|
|||
frame->DisplayToolMsg( msg ); |
|||
} |
|||
|
|||
|
|||
void BLOCK_SELECTOR::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, |
|||
GR_DRAWMODE aDrawMode, COLOR4D aColor ) |
|||
{ |
|||
if( !aDC ) |
|||
return; |
|||
|
|||
int w = GetWidth(); |
|||
int h = GetHeight(); |
|||
|
|||
GRSetDrawMode( aDC, aDrawMode ); |
|||
|
|||
if( w == 0 || h == 0 ) |
|||
GRLine( aPanel->GetClipBox(), aDC, GetX() + aOffset.x, GetY() + aOffset.y, |
|||
GetRight() + aOffset.x, GetBottom() + aOffset.y, 0, aColor ); |
|||
else |
|||
GRRect( aPanel->GetClipBox(), aDC, GetX() + aOffset.x, GetY() + aOffset.y, |
|||
GetRight() + aOffset.x, GetBottom() + aOffset.y, 0, aColor ); |
|||
} |
|||
|
|||
|
|||
void BLOCK_SELECTOR::InitData( EDA_DRAW_PANEL* aPanel, const wxPoint& startpos ) |
|||
{ |
|||
m_state = STATE_BLOCK_INIT; |
|||
SetOrigin( startpos ); |
|||
SetSize( wxSize( 0, 0 ) ); |
|||
m_items.ClearItemsList(); |
|||
aPanel->SetMouseCapture( DrawAndSizingBlockOutlines, AbortBlockCurrentCommand ); |
|||
} |
|||
|
|||
|
|||
void BLOCK_SELECTOR::ClearItemsList() |
|||
{ |
|||
m_items.ClearItemsList(); |
|||
} |
|||
|
|||
|
|||
void BLOCK_SELECTOR::ClearListAndDeleteItems() |
|||
{ |
|||
m_items.ClearListAndDeleteItems(); |
|||
} |
|||
|
|||
|
|||
void BLOCK_SELECTOR::PushItem( ITEM_PICKER& aItem ) |
|||
{ |
|||
m_items.PushItem( aItem ); |
|||
} |
|||
|
|||
|
|||
void BLOCK_SELECTOR::Clear() |
|||
{ |
|||
if( m_command != BLOCK_IDLE ) |
|||
{ |
|||
m_command = BLOCK_IDLE; |
|||
m_state = STATE_NO_BLOCK; |
|||
ClearItemsList(); |
|||
} |
|||
} |
|||
|
|||
|
|||
void DrawAndSizingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, |
|||
bool aErase ) |
|||
{ |
|||
BLOCK_SELECTOR* block = &aPanel->GetScreen()->m_BlockLocate; |
|||
|
|||
block->SetMoveVector( wxPoint( 0, 0 ) ); |
|||
|
|||
if( aErase && aDC ) // Erase current outline
|
|||
block->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, block->GetColor() ); |
|||
|
|||
block->SetLastCursorPosition( aPanel->GetParent()->GetCrossHairPosition() ); |
|||
block->SetEnd( aPanel->GetParent()->GetCrossHairPosition() ); |
|||
|
|||
if( aDC ) // Draw new outline
|
|||
block->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, block->GetColor() ); |
|||
|
|||
if( block->GetState() == STATE_BLOCK_INIT ) |
|||
{ |
|||
if( block->GetWidth() || block->GetHeight() ) |
|||
// 2nd point exists: the rectangle is not surface anywhere
|
|||
block->SetState( STATE_BLOCK_END ); |
|||
} |
|||
} |
|||
|
|||
|
|||
void AbortBlockCurrentCommand( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) |
|||
{ |
|||
BASE_SCREEN* screen = aPanel->GetScreen(); |
|||
|
|||
if( aPanel->IsMouseCaptured() ) // Erase current drawing on screen
|
|||
{ |
|||
// Clear block outline.
|
|||
aPanel->CallMouseCapture( aDC, wxDefaultPosition, false ); |
|||
aPanel->SetMouseCapture( NULL, NULL ); |
|||
screen->SetCurItem( NULL ); |
|||
|
|||
// Delete the picked wrapper if this is a picked list.
|
|||
screen->m_BlockLocate.ClearItemsList(); |
|||
} |
|||
|
|||
screen->m_BlockLocate.SetState( STATE_NO_BLOCK ); |
|||
screen->m_BlockLocate.SetCommand( BLOCK_ABORT ); |
|||
aPanel->GetParent()->HandleBlockEnd( aDC ); |
|||
|
|||
screen->m_BlockLocate.SetCommand( BLOCK_IDLE ); |
|||
aPanel->GetParent()->DisplayToolMsg( wxEmptyString ); |
|||
aPanel->SetCursor( (wxStockCursor) aPanel->GetCurrentCursor() ); |
|||
} |
@ -1,219 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 1992-2010 <Jean-Pierre Charras> |
|||
* Copyright (C) 1992-2010 KiCad Developers, see change_log.txt for contributors. |
|||
* |
|||
* This program is free software; you can redistribute it and/or |
|||
* modify it under the terms of the GNU General Public License |
|||
* as published by the Free Software Foundation; either version 2 |
|||
* of the License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|||
* or you may search the http://www.gnu.org website for the version 2 license,
|
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
/**
|
|||
* @file gerbview/block.cpp |
|||
* @brief Block operations: displacement. |
|||
*/ |
|||
|
|||
|
|||
#include <fctsys.h>
|
|||
#include <common.h>
|
|||
#include <class_drawpanel.h>
|
|||
#include <gerbview_frame.h>
|
|||
#include <gerber_draw_item.h>
|
|||
#include <gerber_file_image.h>
|
|||
#include <gerber_file_image_list.h>
|
|||
|
|||
// Call back function used in block command
|
|||
static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, |
|||
const wxPoint& aPosition, bool erase ); |
|||
|
|||
|
|||
int GERBVIEW_FRAME::BlockCommand( EDA_KEY key ) |
|||
{ |
|||
int cmd = 0; |
|||
|
|||
switch( key ) |
|||
{ |
|||
default: |
|||
cmd = key & 0x255; |
|||
break; |
|||
|
|||
case 0: |
|||
cmd = BLOCK_MOVE; |
|||
break; |
|||
|
|||
case GR_KB_SHIFT: |
|||
case GR_KB_CTRL: |
|||
case GR_KB_SHIFTCTRL: |
|||
case GR_KB_ALT: |
|||
break; |
|||
|
|||
case MOUSE_MIDDLE: |
|||
cmd = BLOCK_ZOOM; |
|||
break; |
|||
} |
|||
|
|||
return cmd; |
|||
} |
|||
|
|||
|
|||
void GERBVIEW_FRAME::HandleBlockPlace( wxDC* DC ) |
|||
{ |
|||
wxASSERT( m_canvas->IsMouseCaptured() ); |
|||
|
|||
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_STOP ); |
|||
|
|||
switch( GetScreen()->m_BlockLocate.GetCommand() ) |
|||
{ |
|||
case BLOCK_MOVE: /* Move */ |
|||
if( m_canvas->IsMouseCaptured() ) |
|||
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); |
|||
|
|||
Block_Move(); |
|||
GetScreen()->m_BlockLocate.ClearItemsList(); |
|||
break; |
|||
|
|||
default: |
|||
wxFAIL_MSG( wxT("HandleBlockPlace: Unexpected block command") ); |
|||
break; |
|||
} |
|||
|
|||
m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString, false ); |
|||
GetScreen()->SetModify(); |
|||
GetScreen()->ClearBlockCommand(); |
|||
|
|||
wxASSERT( GetScreen()->m_BlockLocate.GetCount() == 0 ); |
|||
|
|||
DisplayToolMsg( wxEmptyString ); |
|||
} |
|||
|
|||
|
|||
bool GERBVIEW_FRAME::HandleBlockEnd( wxDC* DC ) |
|||
{ |
|||
bool nextcmd = false; |
|||
bool zoom_command = false; |
|||
|
|||
if( m_canvas->IsMouseCaptured() ) |
|||
|
|||
switch( GetScreen()->m_BlockLocate.GetCommand() ) |
|||
{ |
|||
case BLOCK_MOVE: /* Move */ |
|||
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_MOVE ); |
|||
nextcmd = true; |
|||
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); |
|||
m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines ); |
|||
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); |
|||
break; |
|||
|
|||
case BLOCK_ZOOM: /* Window Zoom */ |
|||
zoom_command = true; |
|||
break; |
|||
|
|||
default: |
|||
wxFAIL_MSG( wxT("HandleBlockEnd: Unexpected block command") ); |
|||
break; |
|||
} |
|||
|
|||
if( ! nextcmd ) |
|||
{ |
|||
GetScreen()->ClearBlockCommand(); |
|||
m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString, |
|||
false ); |
|||
} |
|||
|
|||
return nextcmd ; |
|||
} |
|||
|
|||
|
|||
/* Traces the outline of the block structures of a repositioning move
|
|||
*/ |
|||
static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPositon, |
|||
bool aErase ) |
|||
{ |
|||
BASE_SCREEN* screen = aPanel->GetScreen(); |
|||
|
|||
COLOR4D Color = COLOR4D( YELLOW ); |
|||
|
|||
if( aErase ) |
|||
{ |
|||
screen->m_BlockLocate.Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, Color ); |
|||
|
|||
if( screen->m_BlockLocate.GetMoveVector().x|| screen->m_BlockLocate.GetMoveVector().y ) |
|||
{ |
|||
screen->m_BlockLocate.Draw( aPanel, |
|||
aDC, |
|||
screen->m_BlockLocate.GetMoveVector(), |
|||
g_XorMode, |
|||
Color ); |
|||
} |
|||
} |
|||
|
|||
if( screen->m_BlockLocate.GetState() != STATE_BLOCK_STOP ) |
|||
{ |
|||
const wxPoint& cross_hair = aPanel->GetParent()->GetCrossHairPosition(); |
|||
|
|||
screen->m_BlockLocate.SetMoveVector( |
|||
wxPoint( cross_hair.x - screen->m_BlockLocate.GetRight(), |
|||
cross_hair.y - screen->m_BlockLocate.GetBottom() ) ); |
|||
} |
|||
|
|||
screen->m_BlockLocate.Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, Color ); |
|||
|
|||
if( screen->m_BlockLocate.GetMoveVector().x || screen->m_BlockLocate.GetMoveVector().y ) |
|||
{ |
|||
screen->m_BlockLocate.Draw( aPanel, aDC, |
|||
screen->m_BlockLocate.GetMoveVector(), |
|||
g_XorMode, Color ); |
|||
} |
|||
} |
|||
|
|||
|
|||
void GERBVIEW_FRAME::Block_Move() |
|||
{ |
|||
wxPoint delta; |
|||
wxPoint oldpos; |
|||
|
|||
oldpos = GetCrossHairPosition(); |
|||
m_canvas->SetMouseCaptureCallback( NULL ); |
|||
|
|||
SetCrossHairPosition( oldpos ); |
|||
m_canvas->MoveCursorToCrossHair(); |
|||
GetScreen()->SetModify(); |
|||
GetScreen()->m_BlockLocate.Normalize(); |
|||
|
|||
/* Calculate displacement vectors. */ |
|||
delta = GetScreen()->m_BlockLocate.GetMoveVector(); |
|||
GERBER_FILE_IMAGE_LIST* images = GetGerberLayout()->GetImagesList(); |
|||
|
|||
for( unsigned layer = 0; layer < images->ImagesMaxCount(); ++layer ) |
|||
{ |
|||
GERBER_FILE_IMAGE* gerber = images->GetGbrImage( layer ); |
|||
|
|||
if( gerber == NULL ) // Graphic layer not yet used
|
|||
continue; |
|||
|
|||
/* Move items in block */ |
|||
for( GERBER_DRAW_ITEM* item = gerber->GetItemsList(); item; item = item->Next() ) |
|||
{ |
|||
GERBER_DRAW_ITEM* gerb_item = item; |
|||
|
|||
if( gerb_item->HitTest( GetScreen()->m_BlockLocate, true ) ) |
|||
gerb_item->MoveAB( delta ); |
|||
} |
|||
} |
|||
|
|||
m_canvas->Refresh( true ); |
|||
} |
@ -1,230 +0,0 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com |
|||
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. |
|||
* |
|||
* This program is free software; you can redistribute it and/or |
|||
* modify it under the terms of the GNU General Public License |
|||
* as published by the Free Software Foundation; either version 2 |
|||
* of the License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
|||
* or you may search the http://www.gnu.org website for the version 2 license, |
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
/** |
|||
* This file is part of the common library. |
|||
* @file block_commande.h |
|||
* @see common.h |
|||
*/ |
|||
|
|||
#ifndef __INCLUDE__BLOCK_COMMANDE_H__ |
|||
#define __INCLUDE__BLOCK_COMMANDE_H__ |
|||
|
|||
|
|||
#include <base_struct.h> |
|||
#include <undo_redo_container.h> |
|||
#include <gr_basic.h> |
|||
#include <eda_rect.h> |
|||
|
|||
/* Block state codes. */ |
|||
typedef enum { |
|||
STATE_NO_BLOCK, |
|||
STATE_BLOCK_INIT, |
|||
STATE_BLOCK_END, |
|||
STATE_BLOCK_MOVE, |
|||
STATE_BLOCK_STOP |
|||
} BLOCK_STATE_T; |
|||
|
|||
|
|||
/* Block command codes. */ |
|||
typedef enum { |
|||
BLOCK_IDLE, |
|||
BLOCK_MOVE, |
|||
BLOCK_DUPLICATE, |
|||
BLOCK_DUPLICATE_AND_INCREMENT, |
|||
BLOCK_COPY, |
|||
BLOCK_DELETE, |
|||
BLOCK_PASTE, |
|||
BLOCK_CUT, |
|||
BLOCK_DRAG, |
|||
BLOCK_DRAG_ITEM, // like BLOCK_DRAG, when used to drag a selected component |
|||
// and not using an area defined by a mouse drag |
|||
BLOCK_ROTATE, |
|||
BLOCK_FLIP, |
|||
BLOCK_ZOOM, |
|||
BLOCK_ABORT, |
|||
BLOCK_PRESELECT_MOVE, |
|||
BLOCK_MOVE_EXACT, |
|||
BLOCK_SELECT_ITEMS_ONLY, |
|||
BLOCK_MIRROR_X, |
|||
BLOCK_MIRROR_Y |
|||
} BLOCK_COMMAND_T; |
|||
|
|||
|
|||
class BLOCK_SELECTOR : public EDA_RECT |
|||
{ |
|||
BLOCK_STATE_T m_state; //< State (enum BLOCK_STATE_T) of the block. |
|||
BLOCK_COMMAND_T m_command; //< Command (enum BLOCK_COMMAND_T) operation. |
|||
PICKED_ITEMS_LIST m_items; //< List of items selected in this block. |
|||
COLOR4D m_color; //< Block Color (for drawings). |
|||
wxPoint m_moveVector; //< Move distance to move the block. |
|||
wxPoint m_lastCursorPosition; //< Last Mouse position in block command |
|||
//< last cursor position in move commands |
|||
//< 0,0 in paste command. |
|||
bool m_appendUndo; //< indicates that at least one undo record |
|||
//< has been saved and further undo records |
|||
//< should be appended |
|||
|
|||
public: |
|||
BLOCK_SELECTOR(); |
|||
~BLOCK_SELECTOR(); |
|||
|
|||
void SetState( BLOCK_STATE_T aState ) { m_state = aState; } |
|||
|
|||
BLOCK_STATE_T GetState() const { return m_state; } |
|||
|
|||
void SetCommand( BLOCK_COMMAND_T aCommand ) { m_command = aCommand; } |
|||
|
|||
BLOCK_COMMAND_T GetCommand() const { return m_command; } |
|||
|
|||
void SetColor( COLOR4D aColor ) { m_color = aColor; } |
|||
|
|||
COLOR4D GetColor() const { return m_color; } |
|||
|
|||
bool AppendUndo() const { return m_appendUndo; } |
|||
|
|||
void SetAppendUndo() { m_appendUndo = true; } |
|||
|
|||
/** |
|||
* Function SetLastCursorPosition |
|||
* sets the last cursor position to \a aPosition. |
|||
* |
|||
* @param aPosition The current cursor position. |
|||
*/ |
|||
void SetLastCursorPosition( const wxPoint& aPosition ) { m_lastCursorPosition = aPosition; } |
|||
|
|||
wxPoint GetLastCursorPosition() const { return m_lastCursorPosition; } |
|||
|
|||
void SetMoveVector( const wxPoint& aMoveVector ) { m_moveVector = aMoveVector; } |
|||
|
|||
wxPoint GetMoveVector() const { return m_moveVector; } |
|||
|
|||
/** |
|||
* Function InitData |
|||
* sets the initial values of a BLOCK_SELECTOR, before starting a block |
|||
* command |
|||
*/ |
|||
void InitData( EDA_DRAW_PANEL* Panel, const wxPoint& startpos ); |
|||
|
|||
/** |
|||
* Function SetMessageBlock |
|||
* Displays the type of block command in the status bar of the window |
|||
*/ |
|||
void SetMessageBlock( EDA_DRAW_FRAME* frame ); |
|||
|
|||
void Draw( EDA_DRAW_PANEL* aPanel, |
|||
wxDC* aDC, |
|||
const wxPoint& aOffset, |
|||
GR_DRAWMODE aDrawMode, |
|||
COLOR4D aColor ); |
|||
|
|||
/** |
|||
* Function PushItem |
|||
* adds \a aItem to the list of items. |
|||
* @param aItem = an ITEM_PICKER to add to the list |
|||
*/ |
|||
void PushItem( ITEM_PICKER& aItem ); |
|||
|
|||
/** |
|||
* Function ClearListAndDeleteItems |
|||
* deletes only the list of EDA_ITEM * pointers, AND the data printed |
|||
* by m_Item |
|||
*/ |
|||
void ClearListAndDeleteItems(); |
|||
|
|||
/** |
|||
* Function ClearItemsList |
|||
* clear only the list of #EDA_ITEM pointers, it does _NOT_ delete the #EDA_ITEM object |
|||
* itself |
|||
*/ |
|||
void ClearItemsList(); |
|||
|
|||
unsigned GetCount() const |
|||
{ |
|||
return m_items.GetCount(); |
|||
} |
|||
|
|||
PICKED_ITEMS_LIST& GetItems() { return m_items; } |
|||
|
|||
EDA_ITEM* GetItem( unsigned aIndex ) |
|||
{ |
|||
if( aIndex < m_items.GetCount() ) |
|||
return m_items.GetPickedItem( aIndex ); |
|||
|
|||
return NULL; |
|||
} |
|||
|
|||
/** |
|||
* Function SetFlags |
|||
* sets a status flag on each item in a block selector. |
|||
*/ |
|||
void SetFlags( const STATUS_FLAGS aFlag ) |
|||
{ |
|||
for( unsigned i = 0; i < m_items.GetCount(); i++ ) |
|||
m_items.GetPickedItem( i )->SetFlags( aFlag ); |
|||
} |
|||
|
|||
/** |
|||
* Function IsDragging |
|||
* returns true if the current block command is a drag operation. |
|||
*/ |
|||
bool IsDragging() const |
|||
{ |
|||
return m_command == BLOCK_DRAG || m_command == BLOCK_DRAG_ITEM; |
|||
} |
|||
|
|||
/** |
|||
* Function IsIdle |
|||
* returns true if there is currently no block operation in progress. |
|||
*/ |
|||
inline bool IsIdle() const { return m_command == BLOCK_IDLE; } |
|||
|
|||
/** |
|||
* Function Clear |
|||
* clears the block selector by setting the command to idle, the state to no block, |
|||
* and clears the selected item list. |
|||
*/ |
|||
void Clear(); |
|||
}; |
|||
|
|||
|
|||
/** |
|||
* Function AbortBlockCurrentCommand |
|||
* cancels the current block operation. |
|||
*/ |
|||
void AbortBlockCurrentCommand( EDA_DRAW_PANEL* aPanel, wxDC* aDC ); |
|||
|
|||
|
|||
/** |
|||
* Function DrawAndSizingBlockOutlines |
|||
* redraws the outlines of the block which shows the search area for block commands. |
|||
* |
|||
* The first point of the rectangle showing the area is initialized by InitBlockLocateDatas(). |
|||
* The other point of the rectangle is the mouse cursor position. |
|||
*/ |
|||
void DrawAndSizingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, |
|||
bool aErase ); |
|||
|
|||
|
|||
#endif /* __INCLUDE__BLOCK_COMMANDE_H__ */ |
@ -1,217 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2004-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr |
|||
* Copyright (C) 2014 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* This program is free software; you can redistribute it and/or |
|||
* modify it under the terms of the GNU General Public License |
|||
* as published by the Free Software Foundation; either version 2 |
|||
* of the License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|||
* or you may search the http://www.gnu.org website for the version 2 license,
|
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
/**
|
|||
* @file append_board_to_current.cpp |
|||
* @brief append a board to the currently edited board. |
|||
*/ |
|||
|
|||
#include <fctsys.h>
|
|||
#include <confirm.h>
|
|||
#include <properties.h>
|
|||
#include <pcb_edit_frame.h>
|
|||
#include <pcbnew.h>
|
|||
#include <io_mgr.h>
|
|||
#include <class_module.h>
|
|||
#include <class_zone.h>
|
|||
#include <class_board.h>
|
|||
#include <pcb_draw_panel_gal.h>
|
|||
|
|||
// Defined in files.cpp:
|
|||
extern IO_MGR::PCB_FILE_T plugin_type( const wxString& aFileName, int aCtl ); |
|||
|
|||
|
|||
bool PCB_EDIT_FRAME::AppendBoardFile( const wxString& aFullFileName, int aCtl ) |
|||
{ |
|||
IO_MGR::PCB_FILE_T pluginType = plugin_type( aFullFileName, aCtl ); |
|||
PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) ); |
|||
|
|||
// keep trace of existing items, in order to know what are the new items
|
|||
// (for undo command for instance)
|
|||
|
|||
// Tracks are inserted, not append, so mark existing tracks to know what are
|
|||
// the new tracks
|
|||
for( TRACK* track = GetBoard()->m_Track; track; track = track->Next() ) |
|||
track->SetFlags( FLAG0 ); |
|||
|
|||
// Other items are append to the item list, so keep trace to the
|
|||
// last existing item is enough
|
|||
MODULE* module = GetBoard()->m_Modules.GetLast(); |
|||
BOARD_ITEM* drawing = GetBoard()->DrawingsList().GetLast(); |
|||
int zonescount = GetBoard()->GetAreaCount(); |
|||
|
|||
// Keep also the count of copper layers, because we can happen boards
|
|||
// with different copper layers counts,
|
|||
// and the enabled layers
|
|||
int initialCopperLayerCount = GetBoard()->GetCopperLayerCount(); |
|||
LSET initialEnabledLayers = GetBoard()->GetEnabledLayers(); |
|||
|
|||
try |
|||
{ |
|||
PROPERTIES props; |
|||
char xbuf[30]; |
|||
char ybuf[30]; |
|||
|
|||
// EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet.
|
|||
sprintf( xbuf, "%d", GetPageSizeIU().x ); |
|||
sprintf( ybuf, "%d", GetPageSizeIU().y ); |
|||
|
|||
props["page_width"] = xbuf; |
|||
props["page_height"] = ybuf; |
|||
|
|||
GetDesignSettings().m_NetClasses.Clear(); |
|||
pi->Load( aFullFileName, GetBoard(), &props ); |
|||
} |
|||
catch( const IO_ERROR& ioe ) |
|||
{ |
|||
for( TRACK* track = GetBoard()->m_Track; track; track = track->Next() ) |
|||
{ |
|||
track->ClearFlags( FLAG0 ); |
|||
} |
|||
|
|||
DisplayErrorMessage( this, _( "Error loading board in AppendBoardFile" ), ioe.What() ); |
|||
|
|||
return false; |
|||
} |
|||
|
|||
// Now prepare a block move command to place the new items, and
|
|||
// prepare the undo command.
|
|||
BLOCK_SELECTOR& blockmove = GetScreen()->m_BlockLocate; |
|||
HandleBlockBegin( NULL, BLOCK_PRESELECT_MOVE, wxPoint( 0, 0) ); |
|||
PICKED_ITEMS_LIST& blockitemsList = blockmove.GetItems(); |
|||
PICKED_ITEMS_LIST undoListPicker; |
|||
ITEM_PICKER picker( NULL, UR_NEW ); |
|||
|
|||
EDA_RECT bbox; // the new items bounding box, for block move
|
|||
bool bboxInit = true; // true until the bounding box is initialized
|
|||
|
|||
for( TRACK* track = GetBoard()->m_Track; track; track = track->Next() ) |
|||
{ |
|||
if( track->GetFlags() & FLAG0 ) |
|||
{ |
|||
track->ClearFlags( FLAG0 ); |
|||
continue; |
|||
} |
|||
|
|||
track->SetFlags( IS_MOVED ); |
|||
picker.SetItem( track ); |
|||
undoListPicker.PushItem( picker ); |
|||
blockitemsList.PushItem( picker ); |
|||
|
|||
if( bboxInit ) |
|||
bbox = track->GetBoundingBox(); |
|||
else |
|||
bbox.Merge( track->GetBoundingBox() ); |
|||
|
|||
bboxInit = false; |
|||
} |
|||
|
|||
if( module ) |
|||
module = module->Next(); |
|||
else |
|||
module = GetBoard()->m_Modules; |
|||
|
|||
for( ; module; module = module->Next() ) |
|||
{ |
|||
module->SetFlags( IS_MOVED ); |
|||
picker.SetItem( module ); |
|||
undoListPicker.PushItem( picker ); |
|||
blockitemsList.PushItem( picker ); |
|||
|
|||
if( bboxInit ) |
|||
bbox = module->GetBoundingBox(); |
|||
else |
|||
bbox.Merge( module->GetBoundingBox() ); |
|||
|
|||
bboxInit = false; |
|||
} |
|||
|
|||
if( drawing ) |
|||
drawing = drawing->Next(); |
|||
else |
|||
drawing = GetBoard()->DrawingsList(); |
|||
|
|||
for( ; drawing; drawing = drawing->Next() ) |
|||
{ |
|||
drawing->SetFlags( IS_MOVED ); |
|||
picker.SetItem( drawing ); |
|||
undoListPicker.PushItem( picker ); |
|||
blockitemsList.PushItem( picker ); |
|||
|
|||
if( bboxInit ) |
|||
bbox = drawing->GetBoundingBox(); |
|||
else |
|||
bbox.Merge( drawing->GetBoundingBox() ); |
|||
|
|||
bboxInit = false; |
|||
} |
|||
|
|||
for( ZONE_CONTAINER* zone = GetBoard()->GetArea( zonescount ); zone; |
|||
zone = GetBoard()->GetArea( zonescount ) ) |
|||
{ |
|||
zone->SetFlags( IS_MOVED ); |
|||
picker.SetItem( zone ); |
|||
undoListPicker.PushItem( picker ); |
|||
blockitemsList.PushItem( picker ); |
|||
zonescount++; |
|||
|
|||
if( bboxInit ) |
|||
bbox = zone->GetBoundingBox(); |
|||
else |
|||
bbox.Merge( zone->GetBoundingBox() ); |
|||
|
|||
bboxInit = false; |
|||
} |
|||
|
|||
SaveCopyInUndoList( undoListPicker, UR_NEW ); |
|||
|
|||
// we should not ask PLUGINs to do these items:
|
|||
int copperLayerCount = GetBoard()->GetCopperLayerCount(); |
|||
|
|||
if( copperLayerCount > initialCopperLayerCount ) |
|||
GetBoard()->SetCopperLayerCount( copperLayerCount ); |
|||
|
|||
// Enable all used layers, and make them visible:
|
|||
LSET enabledLayers = GetBoard()->GetEnabledLayers(); |
|||
enabledLayers |= initialEnabledLayers; |
|||
GetBoard()->SetEnabledLayers( enabledLayers ); |
|||
GetBoard()->SetVisibleLayers( enabledLayers ); |
|||
|
|||
onBoardLoaded(); |
|||
|
|||
if( IsGalCanvasActive() ) |
|||
static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->SyncLayersVisibility( GetBoard() ); |
|||
|
|||
GetBoard()->BuildListOfNets(); |
|||
GetBoard()->SynchronizeNetsAndNetClasses(); |
|||
|
|||
// Finish block move command:
|
|||
wxPoint cpos = GetNearestGridPosition( bbox.Centre() ); |
|||
blockmove.SetOrigin( bbox.GetOrigin() ); |
|||
blockmove.SetSize( bbox.GetSize() ); |
|||
blockmove.SetLastCursorPosition( cpos ); |
|||
HandleBlockEnd( NULL ); |
|||
|
|||
return true; |
|||
} |
@ -1,890 +0,0 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr |
|||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> |
|||
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net> |
|||
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* |
|||
* This program is free software; you can redistribute it and/or |
|||
* modify it under the terms of the GNU General Public License |
|||
* as published by the Free Software Foundation; either version 2 |
|||
* of the License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|||
* or you may search the http://www.gnu.org website for the version 2 license,
|
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
/**
|
|||
* @file block_module_editor.cpp |
|||
* @brief Footprint editor block handling implementation. |
|||
*/ |
|||
|
|||
#include <fctsys.h>
|
|||
#include <pgm_base.h>
|
|||
#include <gr_basic.h>
|
|||
#include <class_drawpanel.h>
|
|||
#include <confirm.h>
|
|||
#include <block_commande.h>
|
|||
#include <macros.h>
|
|||
|
|||
#include <footprint_edit_frame.h>
|
|||
#include <pcbplot.h>
|
|||
#include <trigo.h>
|
|||
|
|||
#include <pcbnew.h>
|
|||
|
|||
#include <class_board.h>
|
|||
#include <class_track.h>
|
|||
#include <class_drawsegment.h>
|
|||
#include <class_pcb_text.h>
|
|||
#include <class_pcb_target.h>
|
|||
#include <class_module.h>
|
|||
#include <class_dimension.h>
|
|||
#include <class_edge_mod.h>
|
|||
|
|||
#include <dialogs/dialog_move_exact.h>
|
|||
|
|||
|
|||
#define BLOCK_COLOR BROWN
|
|||
|
|||
// Functions defined here, but used also in other files
|
|||
// These 3 functions are used in modedit to rotate, mirror or move the
|
|||
// whole footprint so they are called with force_all = true
|
|||
void MirrorMarkedItems( MODULE* module, wxPoint offset, bool force_all = false ); |
|||
void RotateMarkedItems( MODULE* module, wxPoint offset, bool force_all = false ); |
|||
void MoveMarkedItemsExactly( MODULE* module, const wxPoint& centre, |
|||
const wxPoint& translation, double rotation, |
|||
bool force_all = false ); |
|||
|
|||
// Local functions:
|
|||
static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, |
|||
bool aErase ); |
|||
static int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect ); |
|||
|
|||
static void ClearMarkItems( MODULE* module ); |
|||
static void CopyMarkedItems( MODULE* module, wxPoint offset, bool aIncrement ); |
|||
static void MoveMarkedItems( MODULE* module, wxPoint offset ); |
|||
static void DeleteMarkedItems( MODULE* module ); |
|||
|
|||
|
|||
int FOOTPRINT_EDIT_FRAME::BlockCommand( EDA_KEY key ) |
|||
{ |
|||
int cmd; |
|||
|
|||
switch( key ) |
|||
{ |
|||
default: |
|||
cmd = key & 0xFF; |
|||
break; |
|||
|
|||
case EDA_KEY_C( 0xffffffff ): // -1
|
|||
// Historically, -1 has been used as a key, which can cause bit flag
|
|||
// clashes with unaware code. On debug builds, catch any old code that
|
|||
// might still be doing this. TODO: remove if sure all this old code is gone.
|
|||
wxFAIL_MSG( "negative EDA_KEY value should be converted to GR_KEY_INVALID" ); |
|||
// fall through on release builds
|
|||
|
|||
case GR_KEY_INVALID: |
|||
cmd = BLOCK_PRESELECT_MOVE; |
|||
break; |
|||
|
|||
case 0: |
|||
cmd = BLOCK_MOVE; |
|||
break; |
|||
|
|||
case GR_KB_ALT: |
|||
cmd = BLOCK_MIRROR_Y; |
|||
break; |
|||
|
|||
case GR_KB_SHIFTCTRL: |
|||
cmd = BLOCK_DELETE; |
|||
break; |
|||
|
|||
case GR_KB_SHIFT: |
|||
cmd = BLOCK_DUPLICATE; |
|||
break; |
|||
|
|||
case GR_KB_CTRL: |
|||
cmd = BLOCK_ROTATE; |
|||
break; |
|||
|
|||
case MOUSE_MIDDLE: |
|||
cmd = BLOCK_ZOOM; |
|||
break; |
|||
} |
|||
|
|||
return cmd; |
|||
} |
|||
|
|||
|
|||
bool FOOTPRINT_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) |
|||
{ |
|||
int itemsCount = 0; |
|||
bool nextcmd = false; |
|||
MODULE* currentModule = GetBoard()->m_Modules; |
|||
|
|||
if( GetScreen()->m_BlockLocate.GetCount() ) |
|||
{ |
|||
// Set the SELECTED flag of all preselected items, and clear preselect list
|
|||
ClearMarkItems( currentModule ); |
|||
PICKED_ITEMS_LIST* list = &GetScreen()->m_BlockLocate.GetItems(); |
|||
|
|||
for( unsigned ii = 0, e = list->GetCount(); ii < e; ++ii ) |
|||
{ |
|||
BOARD_ITEM* item = (BOARD_ITEM*) list->GetPickedItem( ii ); |
|||
item->SetFlags( SELECTED ); |
|||
++itemsCount; |
|||
} |
|||
|
|||
GetScreen()->m_BlockLocate.ClearItemsList(); |
|||
} |
|||
|
|||
switch( GetScreen()->m_BlockLocate.GetCommand() ) |
|||
{ |
|||
case BLOCK_IDLE: |
|||
DisplayError( this, wxT( "Error in HandleBlockPLace" ) ); |
|||
break; |
|||
|
|||
case BLOCK_DRAG: // Drag
|
|||
case BLOCK_DRAG_ITEM: // Drag a given item (not used here)
|
|||
case BLOCK_MOVE: // Move
|
|||
case BLOCK_DUPLICATE: // Duplicate
|
|||
case BLOCK_DUPLICATE_AND_INCREMENT: // Specific to duplicate with increment command
|
|||
|
|||
// Find selected items if we didn't already set them manually
|
|||
if( itemsCount == 0 ) |
|||
itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate ); |
|||
|
|||
if( itemsCount ) |
|||
{ |
|||
nextcmd = true; |
|||
|
|||
if( m_canvas->IsMouseCaptured() ) |
|||
{ |
|||
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); |
|||
m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines ); |
|||
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); |
|||
} |
|||
|
|||
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_MOVE ); |
|||
m_canvas->Refresh( true ); |
|||
} |
|||
|
|||
break; |
|||
|
|||
case BLOCK_MOVE_EXACT: |
|||
itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate ); |
|||
|
|||
if( itemsCount ) |
|||
{ |
|||
wxPoint translation; |
|||
double rotation; |
|||
ROTATION_ANCHOR rotationAnchor = ROTATE_AROUND_SEL_CENTER; |
|||
|
|||
DIALOG_MOVE_EXACT dialog( this, translation, rotation, rotationAnchor ); |
|||
|
|||
if( dialog.ShowModal() == wxID_OK ) |
|||
{ |
|||
SaveCopyInUndoList( currentModule, UR_CHANGED ); |
|||
wxPoint blockCentre = GetScreen()->m_BlockLocate.Centre(); |
|||
blockCentre += translation; |
|||
|
|||
switch( rotationAnchor ) |
|||
{ |
|||
case ROTATE_AROUND_SEL_CENTER: |
|||
MoveMarkedItemsExactly( currentModule, blockCentre, translation, rotation ); |
|||
break; |
|||
case ROTATE_AROUND_USER_ORIGIN: |
|||
MoveMarkedItemsExactly( currentModule, GetScreen()->m_O_Curseur, translation, rotation ); |
|||
break; |
|||
default: |
|||
wxFAIL_MSG( "Rotation choice shouldn't have been available in this context." ); |
|||
} |
|||
|
|||
OnModify(); |
|||
} |
|||
} |
|||
break; |
|||
|
|||
case BLOCK_PRESELECT_MOVE: // Move with preselection list
|
|||
nextcmd = true; |
|||
m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines ); |
|||
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_MOVE ); |
|||
break; |
|||
|
|||
case BLOCK_DELETE: // Delete
|
|||
itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate ); |
|||
|
|||
if( itemsCount ) |
|||
SaveCopyInUndoList( currentModule, UR_CHANGED ); |
|||
|
|||
DeleteMarkedItems( currentModule ); |
|||
OnModify(); |
|||
break; |
|||
|
|||
case BLOCK_COPY: // Copy
|
|||
case BLOCK_PASTE: |
|||
case BLOCK_CUT: |
|||
break; |
|||
|
|||
case BLOCK_ROTATE: |
|||
itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate ); |
|||
|
|||
if( itemsCount ) |
|||
SaveCopyInUndoList( currentModule, UR_CHANGED ); |
|||
|
|||
RotateMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() ); |
|||
OnModify(); |
|||
break; |
|||
|
|||
case BLOCK_MIRROR_X: |
|||
case BLOCK_MIRROR_Y: |
|||
case BLOCK_FLIP: // mirror
|
|||
itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate ); |
|||
|
|||
if( itemsCount ) |
|||
SaveCopyInUndoList( currentModule, UR_CHANGED ); |
|||
|
|||
MirrorMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() ); |
|||
OnModify(); |
|||
break; |
|||
|
|||
case BLOCK_ABORT: |
|||
break; |
|||
|
|||
case BLOCK_SELECT_ITEMS_ONLY: |
|||
break; |
|||
} |
|||
|
|||
if( !nextcmd ) |
|||
{ |
|||
if( GetScreen()->m_BlockLocate.GetCommand() != BLOCK_SELECT_ITEMS_ONLY ) |
|||
{ |
|||
ClearMarkItems( currentModule ); |
|||
} |
|||
|
|||
GetScreen()->ClearBlockCommand(); |
|||
SetCurItem( NULL ); |
|||
m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString, |
|||
false ); |
|||
m_canvas->Refresh( true ); |
|||
} |
|||
|
|||
return nextcmd; |
|||
} |
|||
|
|||
|
|||
void FOOTPRINT_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) |
|||
{ |
|||
MODULE* currentModule = GetBoard()->m_Modules; |
|||
|
|||
if( !m_canvas->IsMouseCaptured() ) |
|||
{ |
|||
DisplayError( this, wxT( "HandleBlockPLace : m_mouseCaptureCallback = NULL" ) ); |
|||
} |
|||
|
|||
GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_STOP ); |
|||
|
|||
const BLOCK_COMMAND_T command = GetScreen()->m_BlockLocate.GetCommand(); |
|||
|
|||
switch( command ) |
|||
{ |
|||
case BLOCK_IDLE: |
|||
break; |
|||
|
|||
case BLOCK_DRAG: // Drag
|
|||
case BLOCK_MOVE: // Move
|
|||
case BLOCK_PRESELECT_MOVE: // Move with preselection list
|
|||
GetScreen()->m_BlockLocate.ClearItemsList(); |
|||
SaveCopyInUndoList( currentModule, UR_CHANGED ); |
|||
MoveMarkedItems( currentModule, GetScreen()->m_BlockLocate.GetMoveVector() ); |
|||
m_canvas->Refresh( true ); |
|||
break; |
|||
|
|||
case BLOCK_DUPLICATE: // Duplicate
|
|||
case BLOCK_DUPLICATE_AND_INCREMENT: // Duplicate and increment pad names
|
|||
GetScreen()->m_BlockLocate.ClearItemsList(); |
|||
SaveCopyInUndoList( currentModule, UR_CHANGED ); |
|||
CopyMarkedItems( currentModule, GetScreen()->m_BlockLocate.GetMoveVector(), |
|||
command == BLOCK_DUPLICATE_AND_INCREMENT ); |
|||
break; |
|||
|
|||
case BLOCK_PASTE: // Paste
|
|||
GetScreen()->m_BlockLocate.ClearItemsList(); |
|||
break; |
|||
|
|||
case BLOCK_MIRROR_X: |
|||
case BLOCK_MIRROR_Y: |
|||
case BLOCK_FLIP: // Mirror by popup menu, from block move
|
|||
SaveCopyInUndoList( currentModule, UR_CHANGED ); |
|||
MirrorMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() ); |
|||
break; |
|||
|
|||
case BLOCK_ROTATE: |
|||
SaveCopyInUndoList( currentModule, UR_CHANGED ); |
|||
RotateMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() ); |
|||
break; |
|||
|
|||
case BLOCK_ZOOM: // Handled by HandleBlockEnd
|
|||
case BLOCK_DELETE: |
|||
case BLOCK_COPY: |
|||
case BLOCK_ABORT: |
|||
default: |
|||
break; |
|||
} |
|||
|
|||
OnModify(); |
|||
|
|||
GetScreen()->m_BlockLocate.SetState( STATE_NO_BLOCK ); |
|||
GetScreen()->m_BlockLocate.SetCommand( BLOCK_IDLE ); |
|||
SetCurItem( NULL ); |
|||
m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString, false ); |
|||
m_canvas->Refresh( true ); |
|||
} |
|||
|
|||
|
|||
/* Traces the outline of the search block structures
|
|||
* The entire block follows the cursor |
|||
*/ |
|||
static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, |
|||
bool aErase ) |
|||
{ |
|||
BASE_SCREEN* screen = aPanel->GetScreen(); |
|||
FOOTPRINT_EDIT_FRAME* moduleEditFrame = static_cast<FOOTPRINT_EDIT_FRAME*>( aPanel->GetParent() ); |
|||
|
|||
wxASSERT( moduleEditFrame ); |
|||
MODULE* currentModule = moduleEditFrame->GetBoard()->m_Modules; |
|||
|
|||
BLOCK_SELECTOR* block = &screen->m_BlockLocate; |
|||
GRSetDrawMode( aDC, g_XorMode ); |
|||
|
|||
if( aErase ) |
|||
{ |
|||
block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() ); |
|||
|
|||
if( currentModule ) |
|||
{ |
|||
wxPoint move_offset = -block->GetMoveVector(); |
|||
BOARD_ITEM* item = currentModule->GraphicalItemsList(); |
|||
|
|||
for( ; item != NULL; item = item->Next() ) |
|||
{ |
|||
if( !item->IsSelected() ) |
|||
continue; |
|||
|
|||
switch( item->Type() ) |
|||
{ |
|||
case PCB_MODULE_TEXT_T: |
|||
case PCB_MODULE_EDGE_T: |
|||
item->Draw( aPanel, aDC, g_XorMode, move_offset ); |
|||
break; |
|||
|
|||
default: |
|||
break; |
|||
} |
|||
} |
|||
|
|||
D_PAD* pad = currentModule->PadsList(); |
|||
|
|||
for( ; pad != NULL; pad = pad->Next() ) |
|||
{ |
|||
if( !pad->IsSelected() ) |
|||
continue; |
|||
|
|||
pad->Draw( aPanel, aDC, g_XorMode, move_offset ); |
|||
} |
|||
} |
|||
} |
|||
|
|||
// Repaint new view.
|
|||
block->SetMoveVector( moduleEditFrame->GetCrossHairPosition() - block->GetLastCursorPosition() ); |
|||
|
|||
block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() ); |
|||
|
|||
if( currentModule ) |
|||
{ |
|||
BOARD_ITEM* item = currentModule->GraphicalItemsList(); |
|||
wxPoint move_offset = - block->GetMoveVector(); |
|||
|
|||
for( ; item != NULL; item = item->Next() ) |
|||
{ |
|||
if( !item->IsSelected() ) |
|||
continue; |
|||
|
|||
switch( item->Type() ) |
|||
{ |
|||
case PCB_MODULE_TEXT_T: |
|||
case PCB_MODULE_EDGE_T: |
|||
item->Draw( aPanel, aDC, g_XorMode, move_offset ); |
|||
break; |
|||
|
|||
default: |
|||
break; |
|||
} |
|||
} |
|||
|
|||
D_PAD* pad = currentModule->PadsList(); |
|||
|
|||
for( ; pad != NULL; pad = pad->Next() ) |
|||
{ |
|||
if( !pad->IsSelected() ) |
|||
continue; |
|||
|
|||
pad->Draw( aPanel, aDC, g_XorMode, move_offset ); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
/* Copy marked items, at new position = old position + offset
|
|||
*/ |
|||
void CopyMarkedItems( MODULE* module, wxPoint offset, bool aIncrement ) |
|||
{ |
|||
if( module == NULL ) |
|||
return; |
|||
|
|||
// Reference and value cannot be copied, they are unique.
|
|||
// Ensure they are not selected
|
|||
module->Reference().ClearFlags(); |
|||
module->Value().ClearFlags(); |
|||
|
|||
for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() ) |
|||
{ |
|||
if( !pad->IsSelected() ) |
|||
continue; |
|||
|
|||
pad->ClearFlags( SELECTED ); |
|||
D_PAD* NewPad = new D_PAD( *pad ); |
|||
NewPad->SetParent( module ); |
|||
NewPad->SetFlags( SELECTED ); |
|||
module->PadsList().PushFront( NewPad ); |
|||
|
|||
if( aIncrement ) |
|||
NewPad->IncrementPadName( true, true ); |
|||
} |
|||
|
|||
BOARD_ITEM* newItem; |
|||
|
|||
for( BOARD_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() ) |
|||
{ |
|||
if( !item->IsSelected() ) |
|||
continue; |
|||
|
|||
item->ClearFlags( SELECTED ); |
|||
|
|||
newItem = (BOARD_ITEM*)item->Clone(); |
|||
newItem->SetParent( module ); |
|||
newItem->SetFlags( SELECTED ); |
|||
module->GraphicalItemsList().PushFront( newItem ); |
|||
} |
|||
|
|||
MoveMarkedItems( module, offset ); |
|||
} |
|||
|
|||
|
|||
/* Move marked items, at new position = old position + offset
|
|||
*/ |
|||
void MoveMarkedItems( MODULE* module, wxPoint offset ) |
|||
{ |
|||
EDA_ITEM* item; |
|||
|
|||
if( module == NULL ) |
|||
return; |
|||
|
|||
if( module->Reference().IsSelected() ) |
|||
module->Reference().Move( offset ); |
|||
|
|||
if( module->Value().IsSelected() ) |
|||
module->Value().Move( offset ); |
|||
|
|||
D_PAD* pad = module->PadsList(); |
|||
|
|||
for( ; pad != NULL; pad = pad->Next() ) |
|||
{ |
|||
if( !pad->IsSelected() ) |
|||
continue; |
|||
|
|||
pad->SetPosition( pad->GetPosition() + offset ); |
|||
pad->SetPos0( pad->GetPos0() + offset ); |
|||
} |
|||
|
|||
item = module->GraphicalItemsList(); |
|||
|
|||
for( ; item != NULL; item = item->Next() ) |
|||
{ |
|||
if( !item->IsSelected() ) |
|||
continue; |
|||
|
|||
switch( item->Type() ) |
|||
{ |
|||
case PCB_MODULE_TEXT_T: |
|||
static_cast<TEXTE_MODULE*>( item )->Move( offset ); |
|||
break; |
|||
|
|||
case PCB_MODULE_EDGE_T: |
|||
{ |
|||
EDGE_MODULE* em = (EDGE_MODULE*) item; |
|||
em->Move( offset ); |
|||
em->SetStart0( em->GetStart0() + offset ); |
|||
em->SetEnd0( em->GetEnd0() + offset ); |
|||
em->SetBezier0_C1( em->GetBezier0_C1() + offset ); |
|||
em->SetBezier0_C2( em->GetBezier0_C2() + offset ); |
|||
} |
|||
break; |
|||
|
|||
default: |
|||
; |
|||
} |
|||
} |
|||
|
|||
ClearMarkItems( module ); |
|||
} |
|||
|
|||
|
|||
/* Delete marked items
|
|||
*/ |
|||
void DeleteMarkedItems( MODULE* module ) |
|||
{ |
|||
if( module == NULL ) |
|||
return; |
|||
|
|||
D_PAD* next_pad; |
|||
BOARD* board = module->GetBoard(); |
|||
|
|||
for( D_PAD* pad = module->PadsList(); pad; pad = next_pad ) |
|||
{ |
|||
next_pad = pad->Next(); |
|||
|
|||
if( !pad->IsSelected() ) |
|||
continue; |
|||
|
|||
if( board ) |
|||
board->PadDelete( pad ); |
|||
else |
|||
pad->DeleteStructure(); |
|||
} |
|||
|
|||
BOARD_ITEM* next_item; |
|||
|
|||
for( BOARD_ITEM* item = module->GraphicalItemsList(); item; item = next_item ) |
|||
{ |
|||
next_item = item->Next(); |
|||
|
|||
if( !item->IsSelected() ) |
|||
continue; |
|||
|
|||
item->DeleteStructure(); |
|||
} |
|||
|
|||
// Ref and value can be flagged, but cannot be deleted
|
|||
ClearMarkItems( module ); |
|||
} |
|||
|
|||
|
|||
/** Mirror marked items, refer to a Vertical axis at position offset
|
|||
* Note: because this function is used in global transform, |
|||
* if force_all is true, all items will be mirrored |
|||
*/ |
|||
void MirrorMarkedItems( MODULE* module, wxPoint offset, bool force_all ) |
|||
{ |
|||
#define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x;
|
|||
wxPoint tmp; |
|||
wxSize tmpz; |
|||
|
|||
if( module == NULL ) |
|||
return; |
|||
|
|||
if( module->Reference().IsSelected() || force_all ) |
|||
module->Reference().Mirror( offset, false ); |
|||
|
|||
if( module->Value().IsSelected() || force_all ) |
|||
module->Value().Mirror( offset, false ); |
|||
|
|||
for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() ) |
|||
{ |
|||
// Skip pads not selected, i.e. not inside the block to mirror:
|
|||
if( !pad->IsSelected() && !force_all ) |
|||
continue; |
|||
|
|||
tmp = pad->GetPosition(); |
|||
SETMIRROR( tmp.x ); |
|||
pad->SetPosition( tmp ); |
|||
|
|||
pad->SetX0( pad->GetPosition().x ); |
|||
|
|||
tmp = pad->GetOffset(); |
|||
tmp.x = -tmp.x; |
|||
pad->SetOffset( tmp ); |
|||
|
|||
tmpz = pad->GetDelta(); |
|||
tmpz.x = -tmpz.x; |
|||
pad->SetDelta( tmpz ); |
|||
|
|||
pad->SetOrientation( - pad->GetOrientation() ); |
|||
} |
|||
|
|||
for( EDA_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() ) |
|||
{ |
|||
// Skip items not selected, i.e. not inside the block to mirror:
|
|||
if( !item->IsSelected() && !force_all ) |
|||
continue; |
|||
|
|||
switch( item->Type() ) |
|||
{ |
|||
case PCB_MODULE_EDGE_T: |
|||
((EDGE_MODULE*) item)->Mirror( offset, false ); |
|||
break; |
|||
|
|||
case PCB_MODULE_TEXT_T: |
|||
static_cast<TEXTE_MODULE*>( item )->Mirror( offset, false ); |
|||
break; |
|||
|
|||
default: |
|||
break; |
|||
} |
|||
} |
|||
|
|||
ClearMarkItems( module ); |
|||
} |
|||
|
|||
|
|||
/** Rotate marked items, refer to a rotation point at position offset
|
|||
* Note: because this function is used in global transform, |
|||
* if force_all is true, all items will be rotated |
|||
*/ |
|||
void RotateMarkedItems( MODULE* module, wxPoint offset, bool force_all ) |
|||
{ |
|||
#define ROTATE( z ) RotatePoint( (&z), offset, 900 )
|
|||
|
|||
if( module == NULL ) |
|||
return; |
|||
|
|||
if( module->Reference().IsSelected() || force_all ) |
|||
module->Reference().Rotate( offset, 900 ); |
|||
|
|||
if( module->Value().IsSelected() || force_all ) |
|||
module->Value().Rotate( offset, 900 ); |
|||
|
|||
for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() ) |
|||
{ |
|||
if( !pad->IsSelected() && !force_all ) |
|||
continue; |
|||
|
|||
wxPoint pos = pad->GetPos0(); |
|||
ROTATE( pos ); |
|||
pad->SetPos0( pos ); |
|||
pad->SetOrientation( pad->GetOrientation() + 900 ); |
|||
|
|||
pad->SetDrawCoord(); |
|||
} |
|||
|
|||
for( EDA_ITEM* item = module->GraphicalItemsList(); item; item = item->Next() ) |
|||
{ |
|||
if( !item->IsSelected() && !force_all ) |
|||
continue; |
|||
|
|||
switch( item->Type() ) |
|||
{ |
|||
case PCB_MODULE_EDGE_T: |
|||
((EDGE_MODULE*) item)->Rotate( offset, 900 ); |
|||
break; |
|||
|
|||
case PCB_MODULE_TEXT_T: |
|||
static_cast<TEXTE_MODULE*>( item )->Rotate( offset, 900 ); |
|||
break; |
|||
|
|||
default: |
|||
break; |
|||
} |
|||
} |
|||
|
|||
ClearMarkItems( module ); |
|||
} |
|||
|
|||
|
|||
void ClearMarkItems( MODULE* module ) |
|||
{ |
|||
if( module == NULL ) |
|||
return; |
|||
|
|||
module->Reference().ClearFlags(); |
|||
module->Value().ClearFlags(); |
|||
|
|||
EDA_ITEM* item = module->GraphicalItemsList(); |
|||
|
|||
for( ; item != NULL; item = item->Next() ) |
|||
{ |
|||
item->ClearFlags(); |
|||
} |
|||
|
|||
item = module->PadsList(); |
|||
|
|||
for( ; item != NULL; item = item->Next() ) |
|||
{ |
|||
item->ClearFlags(); |
|||
} |
|||
} |
|||
|
|||
|
|||
void MoveMarkedItemsExactly( MODULE* module, const wxPoint& centre, |
|||
const wxPoint& translation, |
|||
double rotation, bool force_all ) |
|||
{ |
|||
if( module == NULL ) |
|||
return; |
|||
|
|||
if( module->Reference().IsSelected() || force_all ) |
|||
{ |
|||
module->Reference().Rotate( centre, rotation ); |
|||
module->Reference().Move( translation ); |
|||
} |
|||
|
|||
if( module->Value().IsSelected() || force_all ) |
|||
{ |
|||
module->Value().Rotate( centre, rotation ); |
|||
module->Value().Move( translation ); |
|||
} |
|||
|
|||
D_PAD* pad = module->PadsList(); |
|||
|
|||
for( ; pad != NULL; pad = pad->Next() ) |
|||
{ |
|||
if( !pad->IsSelected() && !force_all ) |
|||
continue; |
|||
|
|||
// rotate about centre point,
|
|||
wxPoint newPos = pad->GetPosition(); |
|||
RotatePoint( &newPos, centre, rotation ); |
|||
|
|||
// shift and update
|
|||
newPos += translation; |
|||
pad->SetPosition( newPos ); |
|||
pad->SetPos0( newPos ); |
|||
|
|||
// finally apply rotation to the pad itself
|
|||
pad->Rotate( newPos, rotation ); |
|||
} |
|||
|
|||
EDA_ITEM* item = module->GraphicalItemsList(); |
|||
|
|||
for( ; item != NULL; item = item->Next() ) |
|||
{ |
|||
if( !item->IsSelected() && !force_all ) |
|||
continue; |
|||
|
|||
switch( item->Type() ) |
|||
{ |
|||
case PCB_MODULE_TEXT_T: |
|||
{ |
|||
TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item ); |
|||
|
|||
text->Rotate( centre, rotation ); |
|||
text->Move( translation ); |
|||
break; |
|||
} |
|||
case PCB_MODULE_EDGE_T: |
|||
{ |
|||
EDGE_MODULE* em = static_cast<EDGE_MODULE*>( item ); |
|||
em->Rotate( centre, rotation ); |
|||
em->Move( translation ); |
|||
break; |
|||
} |
|||
default: |
|||
; |
|||
} |
|||
} |
|||
|
|||
ClearMarkItems( module ); |
|||
} |
|||
|
|||
|
|||
/* Mark items inside rect.
|
|||
* Items are inside rect when an end point is inside rect |
|||
*/ |
|||
int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect ) |
|||
{ |
|||
EDA_ITEM* item; |
|||
int ItemsCount = 0; |
|||
wxPoint pos; |
|||
D_PAD* pad; |
|||
|
|||
if( module == NULL ) |
|||
return 0; |
|||
|
|||
ClearMarkItems( module ); // Just in case ...
|
|||
|
|||
pos = module->Reference().GetTextPos(); |
|||
|
|||
if( Rect.Contains( pos ) ) |
|||
{ |
|||
module->Reference().SetFlags( SELECTED ); |
|||
ItemsCount++; |
|||
} |
|||
|
|||
pos = module->Value().GetTextPos(); |
|||
|
|||
if( Rect.Contains( pos ) ) |
|||
{ |
|||
module->Value().SetFlags( SELECTED ); |
|||
ItemsCount++; |
|||
} |
|||
|
|||
pad = module->PadsList(); |
|||
|
|||
for( ; pad != NULL; pad = pad->Next() ) |
|||
{ |
|||
pad->ClearFlags( SELECTED ); |
|||
pos = pad->GetPosition(); |
|||
|
|||
if( Rect.Contains( pos ) ) |
|||
{ |
|||
pad->SetFlags( SELECTED ); |
|||
ItemsCount++; |
|||
} |
|||
} |
|||
|
|||
item = module->GraphicalItemsList(); |
|||
|
|||
for( ; item != NULL; item = item->Next() ) |
|||
{ |
|||
item->ClearFlags( SELECTED ); |
|||
|
|||
switch( item->Type() ) |
|||
{ |
|||
case PCB_MODULE_EDGE_T: |
|||
if( ((EDGE_MODULE*)item )->HitTest( Rect, false ) ) |
|||
{ |
|||
item->SetFlags( SELECTED ); |
|||
ItemsCount++; |
|||
} |
|||
|
|||
break; |
|||
|
|||
case PCB_MODULE_TEXT_T: |
|||
pos = static_cast<TEXTE_MODULE*>( item )->GetTextPos(); |
|||
|
|||
if( Rect.Contains( pos ) ) |
|||
{ |
|||
item->SetFlags( SELECTED ); |
|||
ItemsCount++; |
|||
} |
|||
|
|||
break; |
|||
|
|||
default: |
|||
break; |
|||
} |
|||
} |
|||
|
|||
return ItemsCount; |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue