kicad/pcbnew/editmod.cpp

164 lines
4.5 KiB
C++
Raw Normal View History

/************************************************/
/* Module editor: Dialog box for editing module */
/* properties and carateristics */
/************************************************/
#include "fctsys.h"
#include "common.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "pcbnew.h"
2009-07-30 11:04:07 +00:00
#include "wxPcbStruct.h"
#include "trigo.h"
#include "3d_viewer.h"
2009-08-11 10:27:21 +00:00
#include "dialog_edit_module_for_BoardEditor.h"
/*******************************************************************/
2009-08-11 10:27:21 +00:00
void WinEDA_PcbFrame::InstallModuleOptionsFrame( MODULE* Module, wxDC* DC )
/*******************************************************************/
/* Fonction relai d'installation de la frame d'<27>dition des proprietes
* du module*/
{
2009-08-11 10:27:21 +00:00
if( Module == NULL )
return;
2009-08-11 10:27:21 +00:00
DIALOG_MODULE_BOARD_EDITOR* dialog =
new DIALOG_MODULE_BOARD_EDITOR( this, Module, DC );
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 )
{
if( m_ModuleEditFrame == NULL )
{
m_ModuleEditFrame = new WinEDA_ModuleEditFrame( this,
2009-08-11 10:27:21 +00:00
_( "Module Editor" ),
wxPoint( -1, -1 ),
wxSize( 600, 400 ) );
}
2009-08-11 10:27:21 +00:00
m_ModuleEditFrame->Load_Module_From_BOARD( Module );
SetCurItem( NULL );
m_ModuleEditFrame->Show( TRUE );
m_ModuleEditFrame->Iconize( FALSE );
}
}
/*******************************************************************/
void WinEDA_ModuleEditFrame::Place_Ancre( MODULE* pt_mod )
/*******************************************************************/
/*
* Repositionne l'ancre sous le curseur souris
*/
{
2009-08-11 10:27:21 +00:00
wxPoint moveVector;
EDA_BaseStruct* PtStruct;
D_PAD* pt_pad;
if( pt_mod == NULL )
return;
2009-08-11 10:27:21 +00:00
moveVector = pt_mod->m_Pos - GetScreen()->m_Curseur;
pt_mod->m_Pos = GetScreen()->m_Curseur;
/* Mise a jour des coord relatives des elements:
* les coordonnees relatives sont relatives a l'ancre, pour orient 0.
* il faut donc recalculer deltaX et deltaY en orientation 0 */
2009-08-11 10:27:21 +00:00
RotatePoint( &moveVector, -pt_mod->m_Orient );
/* Mise a jour des coord relatives des pads */
pt_pad = (D_PAD*) pt_mod->m_Pads;
for( ; pt_pad != NULL; pt_pad = pt_pad->Next() )
{
2009-08-11 10:27:21 +00:00
pt_pad->m_Pos0 += moveVector;
}
/* Mise a jour des coord relatives contours .. */
PtStruct = pt_mod->m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{
2007-09-01 12:00:30 +00:00
switch( PtStruct->Type() )
{
case TYPE_EDGE_MODULE:
#undef STRUCT
#define STRUCT ( (EDGE_MODULE*) PtStruct )
2009-08-11 10:27:21 +00:00
STRUCT->m_Start0 += moveVector;
STRUCT->m_End0 += moveVector;
break;
case TYPE_TEXTE_MODULE:
#undef STRUCT
#define STRUCT ( (TEXTE_MODULE*) PtStruct )
2009-08-11 10:27:21 +00:00
STRUCT->m_Pos0 += moveVector;
break;
default:
break;
}
}
pt_mod->Set_Rectangle_Encadrement();
}
/**********************************************************************/
void WinEDA_ModuleEditFrame::RemoveStruct( EDA_BaseStruct* Item )
/**********************************************************************/
{
if( Item == NULL )
return;
2007-09-01 12:00:30 +00:00
switch( Item->Type() )
{
case TYPE_PAD:
2009-05-21 12:45:21 +00:00
DeletePad( (D_PAD*) Item );
break;
case TYPE_TEXTE_MODULE:
{
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;
}
DeleteTextModule( text );
}
2009-08-11 10:27:21 +00:00
break;
case TYPE_EDGE_MODULE:
Delete_Edge_Module( (EDGE_MODULE*) Item );
DrawPanel->Refresh();
break;
case TYPE_MODULE:
break;
default:
{
wxString Line;
Line.Printf( wxT( " Remove: StructType %d Inattendu" ),
2009-08-11 10:27:21 +00:00
Item->Type() );
DisplayError( this, Line );
}
2009-08-11 10:27:21 +00:00
break;
}
}