Pcbnew, ModEdit: fix issue when setting anchor position, and minor code cleaning.
This commit is contained in:
parent
25e7abec0d
commit
21d1402c03
|
@ -921,6 +921,63 @@ void MODULE::SetPosition( const wxPoint& newpos )
|
|||
CalculateBoundingBox();
|
||||
}
|
||||
|
||||
void MODULE::MoveAnchorPosition( const wxPoint& aMoveVector )
|
||||
{
|
||||
/* Move the reference point of the footprint
|
||||
* the footprints elements (pads, outlines, edges .. ) are moved
|
||||
* but:
|
||||
* - the footprint position is not modified.
|
||||
* - the relative (local) coordinates of these items are modified
|
||||
*/
|
||||
|
||||
wxPoint footprintPos = GetPosition();
|
||||
|
||||
/* Update the relative coordinates:
|
||||
* The coordinates are relative to the anchor point.
|
||||
* Calculate deltaX and deltaY from the anchor. */
|
||||
wxPoint moveVector = aMoveVector;
|
||||
RotatePoint( &moveVector, -GetOrientation() );
|
||||
|
||||
// Update of the reference and value.
|
||||
m_Reference->SetPos0( m_Reference->GetPos0() + moveVector );
|
||||
m_Reference->SetDrawCoord();
|
||||
m_Value->SetPos0( m_Value->GetPos0() + moveVector );
|
||||
m_Value->SetDrawCoord();
|
||||
|
||||
// Update the pad local coordinates.
|
||||
for( D_PAD* pad = Pads(); pad; pad = pad->Next() )
|
||||
{
|
||||
pad->SetPos0( pad->GetPos0() + moveVector );
|
||||
pad->SetPosition( pad->GetPos0() + footprintPos );
|
||||
}
|
||||
|
||||
// Update the draw element coordinates.
|
||||
for( EDA_ITEM* item = GraphicalItems(); item; item = item->Next() )
|
||||
{
|
||||
switch( item->Type() )
|
||||
{
|
||||
case PCB_MODULE_EDGE_T:
|
||||
#undef STRUCT
|
||||
#define STRUCT ( (EDGE_MODULE*) item )
|
||||
STRUCT->m_Start0 += moveVector;
|
||||
STRUCT->m_End0 += moveVector;
|
||||
STRUCT->SetDrawCoord();
|
||||
break;
|
||||
|
||||
case PCB_MODULE_TEXT_T:
|
||||
#undef STRUCT
|
||||
#define STRUCT ( (TEXTE_MODULE*) item )
|
||||
STRUCT->SetPos0( STRUCT->GetPos0() + moveVector );
|
||||
STRUCT->SetDrawCoord();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CalculateBoundingBox();
|
||||
}
|
||||
|
||||
void MODULE::SetOrientation( double newangle )
|
||||
{
|
||||
|
|
|
@ -162,6 +162,19 @@ public:
|
|||
|
||||
void Flip( const wxPoint& aCentre );
|
||||
|
||||
/**
|
||||
* Function MoveAnchorPosition
|
||||
* Move the reference point of the footprint
|
||||
* It looks like a move footprint:
|
||||
* the footprints elements (pads, outlines, edges .. ) are moved
|
||||
* However:
|
||||
* - the footprint position is not modified.
|
||||
* - the relative (local) coordinates of these items are modified
|
||||
* (a move footprint does not change these local coordinates,
|
||||
* but changes the footprint position)
|
||||
*/
|
||||
void MoveAnchorPosition( const wxPoint& aMoveVector );
|
||||
|
||||
/**
|
||||
* function IsFlipped
|
||||
* @return true if the module is flipped, i.e. on the back side of the board
|
||||
|
|
|
@ -4,12 +4,11 @@
|
|||
/************************************************/
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <confirm.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <pcbnew.h>
|
||||
#include <wxPcbStruct.h>
|
||||
#include <module_editor_frame.h>
|
||||
#include <trigo.h>
|
||||
#include <3d_viewer.h>
|
||||
|
||||
#include <class_module.h>
|
||||
|
@ -34,7 +33,7 @@ void PCB_EDIT_FRAME::InstallModuleOptionsFrame( MODULE* Module, wxDC* DC )
|
|||
// Raising an Exception - Fixes #764678
|
||||
DIALOG_MODULE_BOARD_EDITOR* dialog = new DIALOG_MODULE_BOARD_EDITOR( this, Module, NULL );
|
||||
#endif
|
||||
|
||||
|
||||
int retvalue = dialog->ShowModal(); /* retvalue =
|
||||
* -1 if abort,
|
||||
* 0 if exchange module,
|
||||
|
@ -65,58 +64,6 @@ void PCB_EDIT_FRAME::InstallModuleOptionsFrame( MODULE* Module, wxDC* DC )
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Move the footprint anchor position to the current cursor position.
|
||||
*/
|
||||
void FOOTPRINT_EDIT_FRAME::Place_Ancre( MODULE* aModule )
|
||||
{
|
||||
wxPoint moveVector;
|
||||
|
||||
if( aModule == NULL )
|
||||
return;
|
||||
|
||||
moveVector = aModule->GetPosition() - GetScreen()->GetCrossHairPosition();
|
||||
|
||||
aModule->SetPosition( GetScreen()->GetCrossHairPosition() );
|
||||
|
||||
/* Update the relative coordinates:
|
||||
* The coordinates are relative to the anchor point.
|
||||
* Calculate deltaX and deltaY from the anchor. */
|
||||
RotatePoint( &moveVector, -aModule->GetOrientation() );
|
||||
|
||||
// Update the pad coordinates.
|
||||
for( D_PAD* pad = (D_PAD*) aModule->Pads(); pad; pad = pad->Next() )
|
||||
{
|
||||
pad->SetPos0( pad->GetPos0() + moveVector );
|
||||
}
|
||||
|
||||
// Update the draw element coordinates.
|
||||
for( EDA_ITEM* item = aModule->GraphicalItems(); item; item = item->Next() )
|
||||
{
|
||||
switch( item->Type() )
|
||||
{
|
||||
case PCB_MODULE_EDGE_T:
|
||||
#undef STRUCT
|
||||
#define STRUCT ( (EDGE_MODULE*) item )
|
||||
STRUCT->m_Start0 += moveVector;
|
||||
STRUCT->m_End0 += moveVector;
|
||||
break;
|
||||
|
||||
case PCB_MODULE_TEXT_T:
|
||||
#undef STRUCT
|
||||
#define STRUCT ( (TEXTE_MODULE*) item )
|
||||
STRUCT->SetPos0( STRUCT->GetPos0() + moveVector );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
aModule->CalculateBoundingBox();
|
||||
}
|
||||
|
||||
|
||||
void FOOTPRINT_EDIT_FRAME::RemoveStruct( EDA_ITEM* Item )
|
||||
{
|
||||
if( Item == NULL )
|
||||
|
@ -134,13 +81,13 @@ void FOOTPRINT_EDIT_FRAME::RemoveStruct( EDA_ITEM* Item )
|
|||
|
||||
if( text->GetType() == TEXT_is_REFERENCE )
|
||||
{
|
||||
DisplayError( this, _( "Text is REFERENCE!" ) );
|
||||
DisplayError( this, _( "Cannot delete REFERENCE!" ) );
|
||||
break;
|
||||
}
|
||||
|
||||
if( text->GetType() == TEXT_is_VALUE )
|
||||
{
|
||||
DisplayError( this, _( "Text is VALUE!" ) );
|
||||
DisplayError( this, _( "Cannot delete VALUE!" ) );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -159,8 +106,8 @@ void FOOTPRINT_EDIT_FRAME::RemoveStruct( EDA_ITEM* Item )
|
|||
default:
|
||||
{
|
||||
wxString Line;
|
||||
Line.Printf( wxT( " Remove: draw item type %d unknown." ), Item->Type() );
|
||||
DisplayError( this, Line );
|
||||
Line.Printf( wxT( " RemoveStruct: item type %d unknown." ), Item->Type() );
|
||||
wxMessageBox( Line );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include <class_edge_mod.h>
|
||||
|
||||
#include <pcbnew.h>
|
||||
//#include <protos.h>
|
||||
#include <pcbnew_id.h>
|
||||
#include <hotkeys.h>
|
||||
#include <module_editor_frame.h>
|
||||
|
@ -112,7 +111,7 @@ void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
|
|||
}
|
||||
else
|
||||
{
|
||||
DisplayError( this, wxT( "ProcessCommand error: item flags error" ) );
|
||||
wxMessageBox( wxT( "ProcessCommand error: unknown shape" ) );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -140,13 +139,15 @@ void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
|
|||
|| (module->GetFlags() != 0) )
|
||||
break;
|
||||
|
||||
module->ClearFlags();
|
||||
SaveCopyInUndoList( module, UR_MODEDIT );
|
||||
Place_Ancre( module ); // set the new relatives internal coordinates of items
|
||||
RedrawScreen( wxPoint( 0, 0 ), true );
|
||||
|
||||
// Replace the module in position 0, to recalculate absolutes coordinates of items
|
||||
module->SetPosition( wxPoint( 0, 0 ) );
|
||||
// set the new relative internal local coordinates of footprint items
|
||||
wxPoint moveVector = module->GetPosition() -
|
||||
GetScreen()->GetCrossHairPosition();
|
||||
module->MoveAnchorPosition( moveVector );
|
||||
|
||||
// Usually, we do not need to change twice the anchor position,
|
||||
// so deselect the active tool
|
||||
SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString );
|
||||
SetCurItem( NULL );
|
||||
m_canvas->Refresh();
|
||||
|
|
|
@ -225,7 +225,6 @@ public:
|
|||
|
||||
|
||||
// Footprint edition
|
||||
void Place_Ancre( MODULE* module );
|
||||
void RemoveStruct( EDA_ITEM* Item );
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
update=13/10/2012 17:48:08
|
||||
update=21/03/2013 14:06:30
|
||||
version=1
|
||||
last_client=pcbnew
|
||||
[general]
|
||||
|
@ -52,20 +52,21 @@ LibName30=valves
|
|||
[pcbnew]
|
||||
version=1
|
||||
LastNetListRead=
|
||||
PadDrlX=320
|
||||
PadDimH=550
|
||||
PadDimV=550
|
||||
BoardThickness=620
|
||||
TxtPcbV=600
|
||||
TxtPcbH=600
|
||||
TxtModV=500
|
||||
TxtModH=500
|
||||
TxtModW=100
|
||||
VEgarde=100
|
||||
DrawLar=120
|
||||
EdgeLar=80
|
||||
TxtLar=120
|
||||
MSegLar=120
|
||||
UseCmpFile=1
|
||||
PadDrill=0.6
|
||||
PadSizeH=1
|
||||
PadSizeV=1
|
||||
PcbTextSizeV=1
|
||||
PcbTextSizeH=1
|
||||
PcbTextThickness=0.3
|
||||
ModuleTextSizeV=1
|
||||
ModuleTextSizeH=1
|
||||
ModuleTextSizeThickness=0.15
|
||||
SolderMaskClearance=0
|
||||
SolderMaskMinWidth=0
|
||||
DrawSegmentWidth=0.2
|
||||
BoardOutlineThickness=0.15
|
||||
ModuleOutlineThickness=0.15
|
||||
[pcbnew/libraries]
|
||||
LibDir=
|
||||
LibName1=sockets
|
||||
|
@ -73,9 +74,14 @@ LibName2=connect
|
|||
LibName3=discret
|
||||
LibName4=pin_array
|
||||
LibName5=divers
|
||||
LibName6=libcms
|
||||
LibName7=display
|
||||
LibName8=led
|
||||
LibName9=dip_sockets
|
||||
LibName10=pga_sockets
|
||||
LibName11=valves
|
||||
LibName6=smd_capacitors
|
||||
LibName7=smd_resistors
|
||||
LibName8=smd_crystal&oscillator
|
||||
LibName9=smd_dil
|
||||
LibName10=smd_transistors
|
||||
LibName11=libcms
|
||||
LibName12=display
|
||||
LibName13=led
|
||||
LibName14=dip_sockets
|
||||
LibName15=pga_sockets
|
||||
LibName16=valves
|
||||
|
|
Loading…
Reference in New Issue