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();
|
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 )
|
void MODULE::SetOrientation( double newangle )
|
||||||
{
|
{
|
||||||
|
|
|
@ -162,6 +162,19 @@ public:
|
||||||
|
|
||||||
void Flip( const wxPoint& aCentre );
|
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
|
* function IsFlipped
|
||||||
* @return true if the module is flipped, i.e. on the back side of the board
|
* @return true if the module is flipped, i.e. on the back side of the board
|
||||||
|
|
|
@ -4,12 +4,11 @@
|
||||||
/************************************************/
|
/************************************************/
|
||||||
|
|
||||||
#include <fctsys.h>
|
#include <fctsys.h>
|
||||||
#include <class_drawpanel.h>
|
|
||||||
#include <confirm.h>
|
#include <confirm.h>
|
||||||
|
#include <class_drawpanel.h>
|
||||||
#include <pcbnew.h>
|
#include <pcbnew.h>
|
||||||
#include <wxPcbStruct.h>
|
#include <wxPcbStruct.h>
|
||||||
#include <module_editor_frame.h>
|
#include <module_editor_frame.h>
|
||||||
#include <trigo.h>
|
|
||||||
#include <3d_viewer.h>
|
#include <3d_viewer.h>
|
||||||
|
|
||||||
#include <class_module.h>
|
#include <class_module.h>
|
||||||
|
@ -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 )
|
void FOOTPRINT_EDIT_FRAME::RemoveStruct( EDA_ITEM* Item )
|
||||||
{
|
{
|
||||||
if( Item == NULL )
|
if( Item == NULL )
|
||||||
|
@ -134,13 +81,13 @@ void FOOTPRINT_EDIT_FRAME::RemoveStruct( EDA_ITEM* Item )
|
||||||
|
|
||||||
if( text->GetType() == TEXT_is_REFERENCE )
|
if( text->GetType() == TEXT_is_REFERENCE )
|
||||||
{
|
{
|
||||||
DisplayError( this, _( "Text is REFERENCE!" ) );
|
DisplayError( this, _( "Cannot delete REFERENCE!" ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( text->GetType() == TEXT_is_VALUE )
|
if( text->GetType() == TEXT_is_VALUE )
|
||||||
{
|
{
|
||||||
DisplayError( this, _( "Text is VALUE!" ) );
|
DisplayError( this, _( "Cannot delete VALUE!" ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,8 +106,8 @@ void FOOTPRINT_EDIT_FRAME::RemoveStruct( EDA_ITEM* Item )
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
wxString Line;
|
wxString Line;
|
||||||
Line.Printf( wxT( " Remove: draw item type %d unknown." ), Item->Type() );
|
Line.Printf( wxT( " RemoveStruct: item type %d unknown." ), Item->Type() );
|
||||||
DisplayError( this, Line );
|
wxMessageBox( Line );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include <class_edge_mod.h>
|
#include <class_edge_mod.h>
|
||||||
|
|
||||||
#include <pcbnew.h>
|
#include <pcbnew.h>
|
||||||
//#include <protos.h>
|
|
||||||
#include <pcbnew_id.h>
|
#include <pcbnew_id.h>
|
||||||
#include <hotkeys.h>
|
#include <hotkeys.h>
|
||||||
#include <module_editor_frame.h>
|
#include <module_editor_frame.h>
|
||||||
|
@ -112,7 +111,7 @@ void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DisplayError( this, wxT( "ProcessCommand error: item flags error" ) );
|
wxMessageBox( wxT( "ProcessCommand error: unknown shape" ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -140,13 +139,15 @@ void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
|
||||||
|| (module->GetFlags() != 0) )
|
|| (module->GetFlags() != 0) )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
module->ClearFlags();
|
|
||||||
SaveCopyInUndoList( module, UR_MODEDIT );
|
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
|
// set the new relative internal local coordinates of footprint items
|
||||||
module->SetPosition( wxPoint( 0, 0 ) );
|
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 );
|
SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString );
|
||||||
SetCurItem( NULL );
|
SetCurItem( NULL );
|
||||||
m_canvas->Refresh();
|
m_canvas->Refresh();
|
||||||
|
|
|
@ -225,7 +225,6 @@ public:
|
||||||
|
|
||||||
|
|
||||||
// Footprint edition
|
// Footprint edition
|
||||||
void Place_Ancre( MODULE* module );
|
|
||||||
void RemoveStruct( EDA_ITEM* Item );
|
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
|
version=1
|
||||||
last_client=pcbnew
|
last_client=pcbnew
|
||||||
[general]
|
[general]
|
||||||
|
@ -52,20 +52,21 @@ LibName30=valves
|
||||||
[pcbnew]
|
[pcbnew]
|
||||||
version=1
|
version=1
|
||||||
LastNetListRead=
|
LastNetListRead=
|
||||||
PadDrlX=320
|
UseCmpFile=1
|
||||||
PadDimH=550
|
PadDrill=0.6
|
||||||
PadDimV=550
|
PadSizeH=1
|
||||||
BoardThickness=620
|
PadSizeV=1
|
||||||
TxtPcbV=600
|
PcbTextSizeV=1
|
||||||
TxtPcbH=600
|
PcbTextSizeH=1
|
||||||
TxtModV=500
|
PcbTextThickness=0.3
|
||||||
TxtModH=500
|
ModuleTextSizeV=1
|
||||||
TxtModW=100
|
ModuleTextSizeH=1
|
||||||
VEgarde=100
|
ModuleTextSizeThickness=0.15
|
||||||
DrawLar=120
|
SolderMaskClearance=0
|
||||||
EdgeLar=80
|
SolderMaskMinWidth=0
|
||||||
TxtLar=120
|
DrawSegmentWidth=0.2
|
||||||
MSegLar=120
|
BoardOutlineThickness=0.15
|
||||||
|
ModuleOutlineThickness=0.15
|
||||||
[pcbnew/libraries]
|
[pcbnew/libraries]
|
||||||
LibDir=
|
LibDir=
|
||||||
LibName1=sockets
|
LibName1=sockets
|
||||||
|
@ -73,9 +74,14 @@ LibName2=connect
|
||||||
LibName3=discret
|
LibName3=discret
|
||||||
LibName4=pin_array
|
LibName4=pin_array
|
||||||
LibName5=divers
|
LibName5=divers
|
||||||
LibName6=libcms
|
LibName6=smd_capacitors
|
||||||
LibName7=display
|
LibName7=smd_resistors
|
||||||
LibName8=led
|
LibName8=smd_crystal&oscillator
|
||||||
LibName9=dip_sockets
|
LibName9=smd_dil
|
||||||
LibName10=pga_sockets
|
LibName10=smd_transistors
|
||||||
LibName11=valves
|
LibName11=libcms
|
||||||
|
LibName12=display
|
||||||
|
LibName13=led
|
||||||
|
LibName14=dip_sockets
|
||||||
|
LibName15=pga_sockets
|
||||||
|
LibName16=valves
|
||||||
|
|
Loading…
Reference in New Issue