2009-11-18 12:52:19 +00:00
|
|
|
/***************/
|
|
|
|
/* modules.cpp */
|
|
|
|
/***************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "pcbnew.h"
|
2009-07-30 11:04:07 +00:00
|
|
|
#include "wxPcbStruct.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "trigo.h"
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
#include "drag.h"
|
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
static void Abort_MoveOrCopyModule( EDA_DRAW_PANEL* Panel, wxDC* DC );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2010-07-20 18:11:34 +00:00
|
|
|
static MODULE* s_ModuleInitialCopy = NULL; /* Copy of module for
|
|
|
|
* abort/undo command
|
|
|
|
*/
|
|
|
|
static PICKED_ITEMS_LIST s_PickedList; /* a picked list to
|
|
|
|
* save initial module
|
|
|
|
* and dragged tracks
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
/* Get a module name from user and return a pointer to the corresponding module
|
2007-08-10 19:14:51 +00:00
|
|
|
*/
|
2009-11-18 12:52:19 +00:00
|
|
|
MODULE* WinEDA_BasePcbFrame::GetModuleByName()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-07-20 18:11:34 +00:00
|
|
|
wxString moduleName;
|
|
|
|
MODULE* module = NULL;
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2010-07-20 18:11:34 +00:00
|
|
|
wxTextEntryDialog dlg( this, _( "Name:" ), _( "Search footprint" ), moduleName );
|
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return NULL; //Aborted by user
|
|
|
|
|
2010-07-21 08:15:54 +00:00
|
|
|
moduleName = dlg.GetValue();
|
2010-07-20 18:11:34 +00:00
|
|
|
moduleName.Trim( true );
|
|
|
|
moduleName.Trim( false );
|
|
|
|
if( !moduleName.IsEmpty() )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
module = GetBoard()->m_Modules;
|
2007-08-10 19:14:51 +00:00
|
|
|
while( module )
|
|
|
|
{
|
2010-07-20 18:11:34 +00:00
|
|
|
if( module->m_Reference->m_Text.CmpNoCase( moduleName ) == 0 )
|
2007-08-10 19:14:51 +00:00
|
|
|
break;
|
|
|
|
module = module->Next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return module;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
|
|
|
|
void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-10 19:14:51 +00:00
|
|
|
if( module == NULL )
|
|
|
|
return;
|
|
|
|
|
2009-08-06 07:11:04 +00:00
|
|
|
if( s_ModuleInitialCopy )
|
|
|
|
delete s_ModuleInitialCopy;
|
|
|
|
|
|
|
|
s_PickedList.ClearItemsList(); // Should be empty, but...
|
2009-11-18 12:52:19 +00:00
|
|
|
// Creates a copy of the current module, for abort and undo commands
|
|
|
|
s_ModuleInitialCopy = new MODULE( GetBoard() );
|
2009-08-06 07:11:04 +00:00
|
|
|
s_ModuleInitialCopy->Copy( module );
|
|
|
|
s_ModuleInitialCopy->m_Flags = 0;
|
|
|
|
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( module );
|
2009-05-24 18:28:36 +00:00
|
|
|
GetBoard()->m_Status_Pcb &= ~RATSNEST_ITEM_LOCAL_OK;
|
2007-08-10 19:14:51 +00:00
|
|
|
module->m_Flags |= IS_MOVED;
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Show ratsnest. */
|
2010-07-20 18:11:34 +00:00
|
|
|
if( GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
|
2007-08-10 19:14:51 +00:00
|
|
|
DrawGeneralRatsnest( DC );
|
|
|
|
|
2010-08-31 15:54:05 +00:00
|
|
|
EraseDragList();
|
2010-10-26 11:47:16 +00:00
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
if( g_Drag_Pistes_On )
|
|
|
|
{
|
|
|
|
Build_Drag_Liste( DrawPanel, DC, module );
|
2009-11-18 12:52:19 +00:00
|
|
|
ITEM_PICKER itemWrapper( NULL, UR_CHANGED );
|
2010-08-31 15:54:05 +00:00
|
|
|
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
|
2009-08-06 07:11:04 +00:00
|
|
|
{
|
2010-08-31 15:54:05 +00:00
|
|
|
TRACK* segm = g_DragSegmentList[ii].m_Segm;
|
2009-08-06 07:11:04 +00:00
|
|
|
itemWrapper.m_PickedItem = segm;
|
|
|
|
itemWrapper.m_Link = segm->Copy();
|
2011-02-13 17:53:48 +00:00
|
|
|
itemWrapper.m_Link->SetState( IN_EDIT, OFF );
|
2009-11-18 12:52:19 +00:00
|
|
|
s_PickedList.PushItem( itemWrapper );
|
2009-08-06 07:11:04 +00:00
|
|
|
}
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
GetBoard()->m_Status_Pcb |= DO_NOT_SHOW_GENERAL_RASTNEST;
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->SetMouseCapture( Montre_Position_Empreinte, Abort_MoveOrCopyModule );
|
2010-01-13 13:43:36 +00:00
|
|
|
DrawPanel->m_AutoPAN_Request = true;
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
// Erase the module.
|
2008-08-06 07:46:03 +00:00
|
|
|
if( DC )
|
2008-04-01 05:21:50 +00:00
|
|
|
{
|
|
|
|
int tmp = module->m_Flags;
|
|
|
|
module->m_Flags |= DO_NOT_DRAW;
|
2011-01-30 22:22:38 +00:00
|
|
|
DrawPanel->RefreshDrawingRect( module->GetBoundingBox() );
|
2008-04-01 05:21:50 +00:00
|
|
|
module->m_Flags = tmp;
|
|
|
|
}
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2008-08-06 07:46:03 +00:00
|
|
|
/* Called on a move or copy module command abort
|
|
|
|
*/
|
2011-01-21 19:30:59 +00:00
|
|
|
void Abort_MoveOrCopyModule( EDA_DRAW_PANEL* Panel, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
TRACK* pt_segm;
|
|
|
|
MODULE* module;
|
2009-12-21 12:05:36 +00:00
|
|
|
WinEDA_PcbFrame* pcbframe = (WinEDA_PcbFrame*) Panel->GetParent();
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
module = (MODULE*) pcbframe->GetScreen()->GetCurItem();
|
2009-05-24 18:28:36 +00:00
|
|
|
pcbframe->GetBoard()->m_Status_Pcb &= ~RATSNEST_ITEM_LOCAL_OK;
|
2011-02-13 09:07:30 +00:00
|
|
|
Panel->SetMouseCapture( NULL, NULL );
|
2007-08-10 19:14:51 +00:00
|
|
|
|
|
|
|
if( module )
|
|
|
|
{
|
2008-08-06 07:46:03 +00:00
|
|
|
// Erase the current footprint on screen
|
2007-08-10 19:14:51 +00:00
|
|
|
DrawModuleOutlines( Panel, DC, module );
|
2008-08-06 07:46:03 +00:00
|
|
|
|
|
|
|
/* If a move command: return to old position
|
2009-11-18 12:52:19 +00:00
|
|
|
* If a copy command, delete the new footprint
|
2008-08-06 07:46:03 +00:00
|
|
|
*/
|
|
|
|
if( module->m_Flags & IS_MOVED ) // Move command
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
|
|
|
if( g_Drag_Pistes_On )
|
|
|
|
{
|
2008-08-06 07:46:03 +00:00
|
|
|
/* Erase on screen dragged tracks */
|
2010-08-31 15:54:05 +00:00
|
|
|
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2010-08-31 15:54:05 +00:00
|
|
|
pt_segm = g_DragSegmentList[ii].m_Segm;
|
2007-08-10 19:14:51 +00:00
|
|
|
pt_segm->Draw( Panel, DC, GR_XOR );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-06 07:46:03 +00:00
|
|
|
/* Go to old position for dragged tracks */
|
2010-08-31 15:54:05 +00:00
|
|
|
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2010-08-31 15:54:05 +00:00
|
|
|
pt_segm = g_DragSegmentList[ii].m_Segm;
|
2011-02-13 17:53:48 +00:00
|
|
|
pt_segm->SetState( IN_EDIT, OFF );
|
2010-08-31 15:54:05 +00:00
|
|
|
g_DragSegmentList[ii].SetInitialValues();
|
2007-08-10 19:14:51 +00:00
|
|
|
pt_segm->Draw( Panel, DC, GR_OR );
|
|
|
|
}
|
|
|
|
|
2010-08-31 15:54:05 +00:00
|
|
|
EraseDragList();
|
2007-08-10 19:14:51 +00:00
|
|
|
module->m_Flags = 0;
|
|
|
|
}
|
|
|
|
|
2009-06-11 14:26:17 +00:00
|
|
|
if( (module->m_Flags & IS_NEW) ) // Copy command: delete new footprint
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2008-08-06 07:46:03 +00:00
|
|
|
module->DeleteStructure();
|
2007-08-10 19:14:51 +00:00
|
|
|
module = NULL;
|
2009-01-05 05:21:35 +00:00
|
|
|
pcbframe->GetBoard()->m_Status_Pcb = 0;
|
2009-06-11 14:26:17 +00:00
|
|
|
pcbframe->GetBoard()->m_NetInfo->BuildListOfNets();
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Redraw the module. */
|
2009-08-06 07:11:04 +00:00
|
|
|
if( module && s_ModuleInitialCopy )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2009-08-06 07:11:04 +00:00
|
|
|
if( s_ModuleInitialCopy->m_Orient != module->m_Orient )
|
2009-11-18 12:52:19 +00:00
|
|
|
pcbframe->Rotate_Module( NULL,
|
|
|
|
module,
|
|
|
|
s_ModuleInitialCopy->m_Orient,
|
|
|
|
FALSE );
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2009-08-06 07:11:04 +00:00
|
|
|
if( s_ModuleInitialCopy->GetLayer() != module->GetLayer() )
|
|
|
|
pcbframe->Change_Side_Module( module, NULL );
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2008-04-01 05:21:50 +00:00
|
|
|
module->Draw( Panel, DC, GR_OR );
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
g_Drag_Pistes_On = FALSE;
|
2007-09-12 02:14:07 +00:00
|
|
|
pcbframe->SetCurItem( NULL );
|
2008-08-06 07:46:03 +00:00
|
|
|
|
2009-08-06 07:11:04 +00:00
|
|
|
delete s_ModuleInitialCopy;
|
|
|
|
s_ModuleInitialCopy = NULL;
|
|
|
|
s_PickedList.ClearListAndDeleteItems();
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
// Display ratsnest is allowed
|
|
|
|
pcbframe->GetBoard()->m_Status_Pcb &= ~DO_NOT_SHOW_GENERAL_RASTNEST;
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2010-07-20 18:11:34 +00:00
|
|
|
if( pcbframe->GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
|
2008-08-06 07:46:03 +00:00
|
|
|
pcbframe->DrawGeneralRatsnest( DC );
|
2010-10-09 08:08:29 +00:00
|
|
|
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
pcbframe->GetScreen()->SetRefreshReq();
|
|
|
|
#endif
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-06 07:46:03 +00:00
|
|
|
/**
|
2009-11-18 12:52:19 +00:00
|
|
|
* Function Copie_Module
|
|
|
|
* Copy an existing footprint. The new footprint is added in module list
|
2008-08-06 07:46:03 +00:00
|
|
|
* @param module = footprint to copy
|
|
|
|
* @return a pointer on the new footprint (the copy of the existing footprint)
|
|
|
|
*/
|
2009-11-18 12:52:19 +00:00
|
|
|
MODULE* WinEDA_BasePcbFrame::Copie_Module( MODULE* module )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-10 19:14:51 +00:00
|
|
|
MODULE* newmodule;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
if( module == NULL )
|
|
|
|
return NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Duplicate module */
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->m_Status_Pcb = 0;
|
|
|
|
newmodule = new MODULE( GetBoard() );
|
2007-08-10 19:14:51 +00:00
|
|
|
newmodule->Copy( module );
|
2008-12-06 08:21:54 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->Add( newmodule, ADD_APPEND );
|
2008-12-06 08:21:54 +00:00
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
newmodule->m_Flags = IS_NEW;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-06-11 14:26:17 +00:00
|
|
|
GetBoard()->m_NetInfo->BuildListOfNets();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-17 08:51:02 +00:00
|
|
|
newmodule->DisplayInfo( this );
|
2009-05-24 18:28:36 +00:00
|
|
|
GetBoard()->m_Status_Pcb &= ~RATSNEST_ITEM_LOCAL_OK;
|
2007-08-10 19:14:51 +00:00
|
|
|
return newmodule;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Redraw the footprint when moving the mouse.
|
2007-08-10 19:14:51 +00:00
|
|
|
*/
|
2011-02-03 19:27:28 +00:00
|
|
|
void Montre_Position_Empreinte( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
|
|
|
|
bool aErase )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-02-03 19:27:28 +00:00
|
|
|
MODULE* module = (MODULE*) aPanel->GetScreen()->GetCurItem();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
if( module == NULL )
|
2007-08-10 19:14:51 +00:00
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Erase current footprint. */
|
2011-02-03 19:27:28 +00:00
|
|
|
if( aErase )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2011-02-03 19:27:28 +00:00
|
|
|
DrawModuleOutlines( aPanel, aDC, module );
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Redraw the module at the new position. */
|
2011-02-11 20:48:13 +00:00
|
|
|
g_Offset_Module = module->m_Pos - aPanel->GetScreen()->GetCrossHairPosition();
|
2011-02-03 19:27:28 +00:00
|
|
|
DrawModuleOutlines( aPanel, aDC, module );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-02-03 19:27:28 +00:00
|
|
|
Dessine_Segments_Dragges( aPanel, aDC );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-13 10:08:42 +00:00
|
|
|
/**
|
2009-11-18 12:52:19 +00:00
|
|
|
* Function Delete Module
|
|
|
|
* Remove a footprint from m_Modules linked list and put it in undelete buffer
|
|
|
|
* The ratsnest and pad list are recalculated
|
2010-12-29 17:47:32 +00:00
|
|
|
* @param aModule = footprint to delete
|
|
|
|
* @param aDC = currentDevice Context. if NULL: do not redraw new ratsnest
|
|
|
|
* @param aAskBeforeDeleting : if true: ask for confirmation before deleting
|
2007-08-10 19:14:51 +00:00
|
|
|
*/
|
2010-12-29 17:47:32 +00:00
|
|
|
bool WinEDA_PcbFrame::Delete_Module( MODULE* aModule,
|
|
|
|
wxDC* aDC,
|
2009-11-18 12:52:19 +00:00
|
|
|
bool aAskBeforeDeleting )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
wxString msg;
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2010-12-29 17:47:32 +00:00
|
|
|
if( aModule == NULL )
|
2007-08-10 19:14:51 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2010-12-29 17:47:32 +00:00
|
|
|
aModule->DisplayInfo( this );
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Confirm module delete. */
|
2008-08-06 07:46:03 +00:00
|
|
|
if( aAskBeforeDeleting )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2010-07-20 18:11:34 +00:00
|
|
|
msg.Printf( _( "Delete Module %s (value %s) ?" ),
|
2010-12-29 17:47:32 +00:00
|
|
|
GetChars( aModule->m_Reference->m_Text ),
|
|
|
|
GetChars( aModule->m_Value->m_Text ) );
|
2008-03-22 18:08:44 +00:00
|
|
|
if( !IsOK( this, msg ) )
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2009-07-29 13:10:36 +00:00
|
|
|
/* Remove module from list, and put it in undo command list */
|
2010-12-29 17:47:32 +00:00
|
|
|
m_Pcb->m_Modules.Remove( aModule );
|
2011-02-13 17:53:48 +00:00
|
|
|
aModule->SetState( IS_DELETED, ON );
|
2010-12-29 17:47:32 +00:00
|
|
|
SaveCopyInUndoList( aModule, UR_DELETED );
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2010-12-29 17:47:32 +00:00
|
|
|
if( aDC && GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
|
|
|
|
Compile_Ratsnest( aDC, true );
|
2008-08-06 07:46:03 +00:00
|
|
|
|
2010-01-13 13:43:36 +00:00
|
|
|
// Redraw the full screen to ensure perfect display of board and ratsnest.
|
2010-12-29 17:47:32 +00:00
|
|
|
if( aDC )
|
2010-07-20 18:11:34 +00:00
|
|
|
DrawPanel->Refresh();
|
2010-01-13 13:43:36 +00:00
|
|
|
|
|
|
|
return true;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2008-03-22 18:08:44 +00:00
|
|
|
/**
|
2008-01-25 13:16:24 +00:00
|
|
|
* Function Change_Side_Module
|
2009-11-18 12:52:19 +00:00
|
|
|
* Flip a footprint (switch layer from component or component to copper)
|
2008-01-25 13:16:24 +00:00
|
|
|
* The mirroring is made from X axis
|
|
|
|
* if a footprint is not on copper or component layer it is not flipped
|
|
|
|
* (it could be on an adhesive layer, not supported at this time)
|
2008-03-13 21:18:05 +00:00
|
|
|
* @param Module the footprint to flip
|
2008-01-25 13:16:24 +00:00
|
|
|
* @param DC Current Device Context. if NULL, no redraw
|
2007-08-10 19:14:51 +00:00
|
|
|
*/
|
2009-11-18 12:52:19 +00:00
|
|
|
void WinEDA_PcbFrame::Change_Side_Module( MODULE* Module, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-10 19:14:51 +00:00
|
|
|
if( Module == NULL )
|
|
|
|
return;
|
2009-12-07 03:46:13 +00:00
|
|
|
if( ( Module->GetLayer() != LAYER_N_FRONT )
|
2010-07-20 18:11:34 +00:00
|
|
|
&& ( Module->GetLayer() != LAYER_N_BACK ) )
|
2007-08-10 19:14:51 +00:00
|
|
|
return;
|
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
if( !( Module->m_Flags & IS_MOVED ) ) /* This is a simple flip, no other
|
2010-07-20 18:11:34 +00:00
|
|
|
*edition in progress */
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
GetBoard()->m_Status_Pcb &= ~( LISTE_RATSNEST_ITEM_OK | CONNEXION_OK );
|
2009-08-06 07:11:04 +00:00
|
|
|
if( DC )
|
2008-04-01 05:21:50 +00:00
|
|
|
{
|
|
|
|
int tmp = Module->m_Flags;
|
|
|
|
Module->m_Flags |= DO_NOT_DRAW;
|
2011-01-30 22:22:38 +00:00
|
|
|
DrawPanel->RefreshDrawingRect( Module->GetBoundingBox() );
|
2008-04-01 05:21:50 +00:00
|
|
|
Module->m_Flags = tmp;
|
|
|
|
}
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Show ratsnest if necessary. */
|
2010-07-20 18:11:34 +00:00
|
|
|
if( DC && GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
|
2009-08-06 07:11:04 +00:00
|
|
|
DrawGeneralRatsnest( DC );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
g_Offset_Module.x = 0;
|
|
|
|
g_Offset_Module.y = 0;
|
|
|
|
}
|
2009-11-18 12:52:19 +00:00
|
|
|
else // Module is being moved.
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Erase footprint and draw outline if it has been already drawn. */
|
2009-08-06 07:11:04 +00:00
|
|
|
if( DC )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2009-08-06 07:11:04 +00:00
|
|
|
DrawModuleOutlines( DrawPanel, DC, Module );
|
|
|
|
Dessine_Segments_Dragges( DrawPanel, DC );
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-01 19:26:05 +00:00
|
|
|
/* Flip the module */
|
|
|
|
Module->Flip( Module->m_Pos );
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2009-08-06 07:11:04 +00:00
|
|
|
Module->DisplayInfo( this );
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
if( !( Module->m_Flags & IS_MOVED ) ) /* Inversion simple */
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2009-08-06 07:11:04 +00:00
|
|
|
if( DC )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2009-08-06 07:11:04 +00:00
|
|
|
Module->Draw( DrawPanel, DC, GR_OR );
|
2010-10-25 12:33:00 +00:00
|
|
|
if( GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
|
|
|
|
Compile_Ratsnest( DC, true );
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-08-06 07:11:04 +00:00
|
|
|
if( DC )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2009-08-06 07:11:04 +00:00
|
|
|
DrawModuleOutlines( DrawPanel, DC, Module );
|
|
|
|
Dessine_Segments_Dragges( DrawPanel, DC );
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
2009-08-06 07:11:04 +00:00
|
|
|
GetBoard()->m_Status_Pcb &= ~RATSNEST_ITEM_LOCAL_OK;
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Place module at cursor position.
|
|
|
|
*
|
|
|
|
* DC (if NULL: no display screen has the output.
|
|
|
|
* Update module coordinates with the new position.
|
2007-08-10 19:14:51 +00:00
|
|
|
*/
|
2009-11-18 12:52:19 +00:00
|
|
|
void WinEDA_BasePcbFrame::Place_Module( MODULE* module,
|
|
|
|
wxDC* DC,
|
|
|
|
bool aDoNotRecreateRatsnest )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
TRACK* pt_segm;
|
|
|
|
wxPoint newpos;
|
2007-08-10 19:14:51 +00:00
|
|
|
|
|
|
|
if( module == 0 )
|
|
|
|
return;
|
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2009-05-24 18:28:36 +00:00
|
|
|
GetBoard()->m_Status_Pcb &= ~( LISTE_RATSNEST_ITEM_OK | CONNEXION_OK);
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
if( module->m_Flags & IS_NEW )
|
2009-08-06 07:11:04 +00:00
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
SaveCopyInUndoList( module, UR_NEW );
|
2009-08-06 07:11:04 +00:00
|
|
|
}
|
|
|
|
else if( (module->m_Flags & IS_MOVED ) )
|
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
ITEM_PICKER picker( module, UR_CHANGED );
|
2009-08-06 07:11:04 +00:00
|
|
|
picker.m_Link = s_ModuleInitialCopy;
|
2009-11-18 12:52:19 +00:00
|
|
|
s_PickedList.PushItem( picker );
|
|
|
|
s_ModuleInitialCopy = NULL; // the picker is now owner of
|
|
|
|
// s_ModuleInitialCopy.
|
2009-08-06 07:11:04 +00:00
|
|
|
}
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
if( s_PickedList.GetCount() )
|
2009-08-06 07:11:04 +00:00
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
SaveCopyInUndoList( s_PickedList, UR_UNSPECIFIED );
|
|
|
|
|
2009-08-06 07:11:04 +00:00
|
|
|
// Clear list, but DO NOT delete items,
|
2009-11-18 12:52:19 +00:00
|
|
|
// because they are owned by the saved undo list and they therefore in
|
|
|
|
// use
|
2009-08-06 07:11:04 +00:00
|
|
|
s_PickedList.ClearItemsList();
|
|
|
|
}
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
if( g_Show_Module_Ratsnest && ( GetBoard()->m_Status_Pcb & LISTE_PAD_OK )
|
|
|
|
&& DC )
|
2007-08-10 19:14:51 +00:00
|
|
|
trace_ratsnest_module( DC );
|
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
newpos = GetScreen()->GetCrossHairPosition();
|
2007-08-10 19:14:51 +00:00
|
|
|
module->SetPosition( newpos );
|
2010-07-20 18:11:34 +00:00
|
|
|
module->m_Flags = 0;
|
2009-12-29 18:03:23 +00:00
|
|
|
|
|
|
|
delete s_ModuleInitialCopy;
|
|
|
|
s_ModuleInitialCopy = NULL;
|
2009-11-18 12:52:19 +00:00
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
if( DC )
|
2008-04-01 05:21:50 +00:00
|
|
|
module->Draw( DrawPanel, DC, GR_OR );
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2010-08-31 15:54:05 +00:00
|
|
|
if( g_DragSegmentList.size() )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2009-08-06 07:11:04 +00:00
|
|
|
/* Redraw dragged track segments */
|
2010-08-31 15:54:05 +00:00
|
|
|
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2010-08-31 15:54:05 +00:00
|
|
|
pt_segm = g_DragSegmentList[ii].m_Segm;
|
2011-02-13 17:53:48 +00:00
|
|
|
pt_segm->SetState( IN_EDIT, OFF );
|
2011-02-11 20:48:13 +00:00
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
if( DC )
|
|
|
|
pt_segm->Draw( DrawPanel, DC, GR_OR );
|
|
|
|
}
|
|
|
|
|
2009-08-06 07:11:04 +00:00
|
|
|
// Delete drag list
|
2010-08-31 15:54:05 +00:00
|
|
|
EraseDragList();
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
2009-12-29 18:03:23 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
g_Drag_Pistes_On = false;
|
|
|
|
DrawPanel->SetMouseCapture( NULL, NULL );
|
2009-12-29 18:03:23 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
if( GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) && !aDoNotRecreateRatsnest )
|
|
|
|
Compile_Ratsnest( DC, true );
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2009-08-03 12:12:29 +00:00
|
|
|
if( DC )
|
2010-07-20 18:11:34 +00:00
|
|
|
DrawPanel->Refresh();
|
2009-08-03 12:12:29 +00:00
|
|
|
|
2009-04-17 08:51:02 +00:00
|
|
|
module->DisplayInfo( this );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2009-11-18 12:52:19 +00:00
|
|
|
* Rotate the footprint angle degrees in the direction < 0.
|
2010-01-13 13:43:36 +00:00
|
|
|
* If incremental == true, the rotation is made from the last orientation,
|
2009-11-18 12:52:19 +00:00
|
|
|
* If the module is placed in the absolute orientation angle.
|
|
|
|
* If DC == NULL, the component does not redraw.
|
|
|
|
* Otherwise, it erases and redraws turns
|
2007-08-10 19:14:51 +00:00
|
|
|
*/
|
2009-11-18 12:52:19 +00:00
|
|
|
void WinEDA_BasePcbFrame::Rotate_Module( wxDC* DC, MODULE* module,
|
|
|
|
int angle, bool incremental )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-10 19:14:51 +00:00
|
|
|
if( module == NULL )
|
|
|
|
return;
|
|
|
|
|
2010-02-19 13:23:58 +00:00
|
|
|
OnModify();
|
2007-08-10 19:14:51 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
if( !( module->m_Flags & IS_MOVED ) ) /* This is a simple rotation, no other
|
|
|
|
* edition in progress */
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2009-11-18 12:52:19 +00:00
|
|
|
if( DC ) // Erase footprint to screen
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2008-04-01 05:21:50 +00:00
|
|
|
int tmp = module->m_Flags;
|
|
|
|
module->m_Flags |= DO_NOT_DRAW;
|
2011-01-30 22:22:38 +00:00
|
|
|
DrawPanel->RefreshDrawingRect( module->GetBoundingBox() );
|
2008-04-01 05:21:50 +00:00
|
|
|
module->m_Flags = tmp;
|
2008-03-13 21:18:05 +00:00
|
|
|
|
2010-07-20 18:11:34 +00:00
|
|
|
if( GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
|
2007-08-10 19:14:51 +00:00
|
|
|
DrawGeneralRatsnest( DC );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( DC )
|
|
|
|
{
|
|
|
|
DrawModuleOutlines( DrawPanel, DC, module );
|
|
|
|
Dessine_Segments_Dragges( DrawPanel, DC );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
GetBoard()->m_Status_Pcb &= ~( LISTE_RATSNEST_ITEM_OK | CONNEXION_OK );
|
2007-08-10 19:14:51 +00:00
|
|
|
|
|
|
|
if( incremental )
|
|
|
|
module->SetOrientation( module->m_Orient + angle );
|
|
|
|
else
|
|
|
|
module->SetOrientation( angle );
|
|
|
|
|
2009-04-17 08:51:02 +00:00
|
|
|
module->DisplayInfo( this );
|
2007-08-10 19:14:51 +00:00
|
|
|
|
|
|
|
if( DC )
|
|
|
|
{
|
2010-01-13 13:43:36 +00:00
|
|
|
if( !( module->m_Flags & IS_MOVED ) )
|
2010-07-20 18:11:34 +00:00
|
|
|
{
|
|
|
|
// not beiing moved: redraw the module and update ratsnest
|
2008-04-01 05:21:50 +00:00
|
|
|
module->Draw( DrawPanel, DC, GR_OR );
|
2010-10-07 09:05:28 +00:00
|
|
|
if( GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
|
|
|
|
Compile_Ratsnest( DC, true );
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
else
|
2010-07-20 18:11:34 +00:00
|
|
|
{
|
|
|
|
// Beiing moved: just redraw it
|
2007-08-10 19:14:51 +00:00
|
|
|
DrawModuleOutlines( DrawPanel, DC, module );
|
|
|
|
Dessine_Segments_Dragges( DrawPanel, DC );
|
|
|
|
}
|
2010-01-13 13:43:36 +00:00
|
|
|
|
|
|
|
if( module->m_Flags == 0 ) // module not in edit: redraw full screen
|
2010-07-20 18:11:34 +00:00
|
|
|
DrawPanel->Refresh();
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************/
|
2010-12-29 17:47:32 +00:00
|
|
|
/* Redraw in XOR mode the outlines of a module. */
|
2007-06-05 12:10:51 +00:00
|
|
|
/*************************************************/
|
2011-01-21 19:30:59 +00:00
|
|
|
void DrawModuleOutlines( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* module )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-10 19:14:51 +00:00
|
|
|
int pad_fill_tmp;
|
|
|
|
D_PAD* pt_pad;
|
|
|
|
|
|
|
|
if( module == NULL )
|
|
|
|
return;
|
|
|
|
module->DrawEdgesOnly( panel, DC, g_Offset_Module, GR_XOR );
|
|
|
|
|
|
|
|
if( g_Show_Pads_Module_in_Move )
|
|
|
|
{
|
|
|
|
pad_fill_tmp = DisplayOpt.DisplayPadFill;
|
2009-11-18 12:52:19 +00:00
|
|
|
DisplayOpt.DisplayPadFill = true;
|
2010-09-21 23:46:02 +00:00
|
|
|
|
2007-08-10 19:14:51 +00:00
|
|
|
pt_pad = module->m_Pads;
|
2008-11-24 06:53:43 +00:00
|
|
|
for( ; pt_pad != NULL; pt_pad = pt_pad->Next() )
|
2007-08-10 19:14:51 +00:00
|
|
|
{
|
2008-04-01 05:21:50 +00:00
|
|
|
pt_pad->Draw( panel, DC, GR_XOR, g_Offset_Module );
|
2007-08-10 19:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DisplayOpt.DisplayPadFill = pad_fill_tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( g_Show_Module_Ratsnest && panel )
|
|
|
|
{
|
2009-12-21 12:05:36 +00:00
|
|
|
WinEDA_BasePcbFrame* frame = (WinEDA_BasePcbFrame*) panel->GetParent();
|
2010-12-29 17:47:32 +00:00
|
|
|
frame->build_ratsnest_module( module );
|
2007-08-10 19:14:51 +00:00
|
|
|
frame->trace_ratsnest_module( DC );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|