2007-08-20 01:20:48 +00:00
|
|
|
/************************************************/
|
2011-09-07 19:41:04 +00:00
|
|
|
/* Module editor: Dialog box for editing module */
|
|
|
|
/* properties and characteristics */
|
2007-08-20 01:20:48 +00:00
|
|
|
/************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <module_editor_frame.h>
|
|
|
|
#include <trigo.h>
|
|
|
|
#include <3d_viewer.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_pad.h>
|
|
|
|
#include <class_edge_mod.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialog_edit_module_for_BoardEditor.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/*
|
|
|
|
* Show module property dialog.
|
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::InstallModuleOptionsFrame( MODULE* Module, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-08-11 10:27:21 +00:00
|
|
|
if( Module == NULL )
|
|
|
|
return;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
DIALOG_MODULE_BOARD_EDITOR* dialog = new DIALOG_MODULE_BOARD_EDITOR( this, Module, DC );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-08-11 10:27:21 +00:00
|
|
|
int retvalue = dialog->ShowModal(); /* retvalue =
|
|
|
|
* -1 if abort,
|
|
|
|
* 0 if exchange module,
|
|
|
|
* 1 for normal edition
|
|
|
|
* and 2 for a goto editor command
|
|
|
|
*/
|
|
|
|
dialog->Destroy();
|
|
|
|
|
|
|
|
if( retvalue == 2 )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-09-12 09:53:11 +00:00
|
|
|
FOOTPRINT_EDIT_FRAME * editorFrame =
|
|
|
|
FOOTPRINT_EDIT_FRAME::GetActiveFootprintEditor();
|
|
|
|
if( editorFrame == NULL )
|
|
|
|
editorFrame = new FOOTPRINT_EDIT_FRAME( this );
|
|
|
|
|
|
|
|
editorFrame->Load_Module_From_BOARD( Module );
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-09-12 09:53:11 +00:00
|
|
|
editorFrame->Show( true );
|
|
|
|
editorFrame->Iconize( false );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-02-11 09:04:26 +00:00
|
|
|
* Move the footprint anchor position to the current cursor position.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2012-02-19 04:02:19 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::Place_Ancre( MODULE* aModule )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
wxPoint moveVector;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
if( aModule == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
moveVector = aModule->m_Pos - GetScreen()->GetCrossHairPosition();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
aModule->m_Pos = GetScreen()->GetCrossHairPosition();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Update the relative coordinates:
|
|
|
|
* The coordinates are relative to the anchor point.
|
|
|
|
* Calculate deltaX and deltaY from the anchor. */
|
2012-02-19 04:02:19 +00:00
|
|
|
RotatePoint( &moveVector, -aModule->m_Orient );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Update the pad coordinates.
|
|
|
|
for( D_PAD* pad = (D_PAD*) aModule->m_Pads; pad; pad = pad->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-02-19 04:02:19 +00:00
|
|
|
pad->SetPos0( pad->GetPos0() + moveVector );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
// Update the draw element coordinates.
|
|
|
|
for( EDA_ITEM* item = aModule->m_Drawings; item; item = item->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2012-02-11 09:04:26 +00:00
|
|
|
switch( item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_EDGE_T:
|
2012-02-11 09:04:26 +00:00
|
|
|
#undef STRUCT
|
|
|
|
#define STRUCT ( (EDGE_MODULE*) item )
|
2009-08-11 10:27:21 +00:00
|
|
|
STRUCT->m_Start0 += moveVector;
|
|
|
|
STRUCT->m_End0 += moveVector;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_TEXT_T:
|
2012-02-11 09:04:26 +00:00
|
|
|
#undef STRUCT
|
|
|
|
#define STRUCT ( (TEXTE_MODULE*) item )
|
2011-12-12 08:37:05 +00:00
|
|
|
STRUCT->SetPos0( STRUCT->GetPos0() + moveVector );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-19 04:02:19 +00:00
|
|
|
aModule->CalculateBoundingBox();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::RemoveStruct( EDA_ITEM* Item )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( Item == NULL )
|
|
|
|
return;
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( Item->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_PAD_T:
|
2010-08-11 13:15:30 +00:00
|
|
|
DeletePad( (D_PAD*) Item, false );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_TEXT_T:
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
TEXTE_MODULE* text = (TEXTE_MODULE*) Item;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-12-12 08:37:05 +00:00
|
|
|
if( text->GetType() == TEXT_is_REFERENCE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, _( "Text is REFERENCE!" ) );
|
|
|
|
break;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-12-12 08:37:05 +00:00
|
|
|
if( text->GetType() == TEXT_is_VALUE )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, _( "Text is VALUE!" ) );
|
|
|
|
break;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-05-23 07:16:05 +00:00
|
|
|
DeleteTextModule( text );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2009-08-11 10:27:21 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_EDGE_T:
|
2009-05-23 07:16:05 +00:00
|
|
|
Delete_Edge_Module( (EDGE_MODULE*) Item );
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_T:
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
wxString Line;
|
2011-08-26 17:01:17 +00:00
|
|
|
Line.Printf( wxT( " Remove: draw item type %d unknown." ), Item->Type() );
|
2007-08-20 01:20:48 +00:00
|
|
|
DisplayError( this, Line );
|
|
|
|
}
|
2009-08-11 10:27:21 +00:00
|
|
|
break;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|