2007-08-20 01:20:48 +00:00
|
|
|
/************************************************/
|
|
|
|
/* Module editor: Dialog box for editing module */
|
2009-11-14 22:15:22 +00:00
|
|
|
/* properties and characteristics */
|
2007-08-20 01:20:48 +00:00
|
|
|
/************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.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"
|
2010-08-10 18:34:26 +00:00
|
|
|
#include "module_editor_frame.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "trigo.h"
|
|
|
|
#include "3d_viewer.h"
|
|
|
|
|
2009-08-11 10:27:21 +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
|
|
|
|
2009-08-11 10:27:21 +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
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
if( m_ModuleEditFrame == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
m_ModuleEditFrame = new WinEDA_ModuleEditFrame( this,
|
2009-08-11 10:27:21 +00:00
|
|
|
_( "Module Editor" ),
|
|
|
|
wxPoint( -1, -1 ),
|
|
|
|
wxSize( 600, 400 ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2009-08-11 10:27:21 +00:00
|
|
|
m_ModuleEditFrame->Load_Module_From_BOARD( Module );
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
m_ModuleEditFrame->Show( TRUE );
|
|
|
|
m_ModuleEditFrame->Iconize( FALSE );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2009-11-14 22:15:22 +00:00
|
|
|
* Position anchor under the cursor.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-11-14 22:15:22 +00:00
|
|
|
void WinEDA_ModuleEditFrame::Place_Ancre( MODULE* pt_mod )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
wxPoint moveVector;
|
|
|
|
EDA_ITEM* PtStruct;
|
|
|
|
D_PAD* pt_pad;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( pt_mod == NULL )
|
|
|
|
return;
|
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
moveVector = pt_mod->m_Pos - GetScreen()->GetCrossHairPosition();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2011-02-11 20:48:13 +00:00
|
|
|
pt_mod->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. */
|
2009-08-11 10:27:21 +00:00
|
|
|
RotatePoint( &moveVector, -pt_mod->m_Orient );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Update the pad coordinates. */
|
2007-08-20 01:20:48 +00:00
|
|
|
pt_pad = (D_PAD*) pt_mod->m_Pads;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
for( ; pt_pad != NULL; pt_pad = pt_pad->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-08-11 10:27:21 +00:00
|
|
|
pt_pad->m_Pos0 += moveVector;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Update the draw element coordinates. */
|
2007-08-20 01:20:48 +00:00
|
|
|
PtStruct = pt_mod->m_Drawings;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2007-09-01 12:00:30 +00:00
|
|
|
switch( PtStruct->Type() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_EDGE_MODULE:
|
2007-08-20 01:20:48 +00:00
|
|
|
#undef STRUCT
|
|
|
|
#define STRUCT ( (EDGE_MODULE*) PtStruct )
|
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;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_TEXTE_MODULE:
|
2007-08-20 01:20:48 +00:00
|
|
|
#undef STRUCT
|
|
|
|
#define STRUCT ( (TEXTE_MODULE*) PtStruct )
|
2009-08-11 10:27:21 +00:00
|
|
|
STRUCT->m_Pos0 += moveVector;
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pt_mod->Set_Rectangle_Encadrement();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void WinEDA_ModuleEditFrame::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
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_PAD:
|
2010-08-11 13:15:30 +00:00
|
|
|
DeletePad( (D_PAD*) Item, false );
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_TEXTE_MODULE:
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
TEXTE_MODULE* text = (TEXTE_MODULE*) Item;
|
|
|
|
if( text->m_Type == TEXT_is_REFERENCE )
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "Text is REFERENCE!" ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if( text->m_Type == TEXT_is_VALUE )
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "Text is VALUE!" ) );
|
|
|
|
break;
|
|
|
|
}
|
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
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_EDGE_MODULE:
|
2009-05-23 07:16:05 +00:00
|
|
|
Delete_Edge_Module( (EDGE_MODULE*) Item );
|
|
|
|
DrawPanel->Refresh();
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
case TYPE_MODULE:
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
wxString Line;
|
2009-11-14 22:15:22 +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
|
|
|
}
|