Commit da9fc844 authored by Tomasz Włostowski's avatar Tomasz Włostowski

improved module locking: lock pads only/lock whole module mode added

parent 5d78a007
......@@ -57,7 +57,7 @@ MODULE::MODULE( BOARD* parent ) :
m_Attributs = MOD_DEFAULT;
m_Layer = F_Cu;
m_Orient = 0;
m_ModuleStatus = 0;
m_ModuleStatus = MODULE_PADS_LOCKED;
flag = 0;
m_CntRot90 = m_CntRot180 = 0;
m_Surface = 0.0;
......@@ -815,6 +815,11 @@ void MODULE::RunOnChildren( boost::function<void (BOARD_ITEM*)> aFunction )
}
}
const BOX2I MODULE::ViewBBox() const
{
return BOX2I( VECTOR2I( GetFootprintRect().GetOrigin() ),
VECTOR2I( GetFootprintRect().GetSize() ) );
}
void MODULE::ViewUpdate( int aUpdateFlags )
{
......@@ -867,12 +872,6 @@ unsigned int MODULE::ViewGetLOD( int aLayer ) const
return 30;
}
const BOX2I MODULE::ViewBBox() const
{
EDA_RECT fpRect = GetFootprintRect();
return BOX2I( VECTOR2I( fpRect.GetOrigin() ), VECTOR2I( fpRect.GetSize() ) );
}
/* Test for validity of the name in a library of the footprint
* ( no spaces, dir separators ... )
......@@ -1116,3 +1115,18 @@ void MODULE::SetOrientation( double newangle )
CalculateBoundingBox();
}
double MODULE::PadCoverageRatio() const
{
double padArea = 0.0;
double moduleArea = GetFootprintRect().GetArea();
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
padArea += pad->GetBoundingBox().GetArea();
if(moduleArea == 0.0)
return 1.0;
double ratio = padArea / moduleArea;
return std::min(ratio, 1.0);
}
......@@ -223,6 +223,7 @@ public:
#define MODULE_is_LOCKED 0x01 ///< module LOCKED: no autoplace allowed
#define MODULE_is_PLACED 0x02 ///< In autoplace: module automatically placed
#define MODULE_to_PLACE 0x04 ///< In autoplace: module waiting for autoplace
#define MODULE_PADS_LOCKED 0x08 ///< In autoplace: module waiting for autoplace
bool IsLocked() const
......@@ -261,6 +262,15 @@ public:
m_ModuleStatus &= ~MODULE_to_PLACE;
}
bool PadsLocked() const { return (m_ModuleStatus & MODULE_PADS_LOCKED ); }
void SetPadsLocked( bool aPadsLocked )
{
if( aPadsLocked )
m_ModuleStatus |= MODULE_PADS_LOCKED;
else
m_ModuleStatus &= ~MODULE_PADS_LOCKED;
}
void SetLastEditTime( time_t aTime ) { m_LastEditTime = aTime; }
void SetLastEditTime( ) { m_LastEditTime = time( NULL ); }
time_t GetLastEditTime() const { return m_LastEditTime; }
......@@ -559,6 +569,14 @@ public:
m_initial_comments = aInitialComments;
}
/**
* Function PadCoverageRatio
* Calculates the ratio of total area of the footprint pads to the area of the
* footprint. Used by selection tool heuristics.
* @return the ratio
*/
double PadCoverageRatio() const;
/// Return the initial comments block or NULL if none, without transfer of ownership.
const wxArrayString* GetInitialComments() const { return m_initial_comments; }
......
......@@ -177,7 +177,6 @@ const EDA_RECT D_PAD::GetBoundingBox() const
area.SetOrigin( m_Pos.x-dx, m_Pos.y-dy );
area.SetSize( 2*dx, 2*dy );
break;
break;
case PAD_RECT:
//Use two corners and track their rotation
......
......@@ -313,12 +313,19 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties()
break;
}
m_AutoPlaceCtrl->SetSelection( (m_CurrentModule->IsLocked()) ? 1 : 0 );
if (m_CurrentModule->IsLocked() )
m_AutoPlaceCtrl->SetSelection( 2 );
else if (m_CurrentModule->PadsLocked() )
m_AutoPlaceCtrl->SetSelection( 1 );
else
m_AutoPlaceCtrl->SetSelection( 0 );
m_AutoPlaceCtrl->SetItemToolTip( 0,
_( "Enable hotkey move commands and Auto Placement" ) );
_( "Component can be freely moved and auto placed. User can arbitrarily select and edit component's pads." ) );
m_AutoPlaceCtrl->SetItemToolTip( 1,
_( "Disable hotkey move commands and Auto Placement" ) );
_( "Component can be freely moved and auto placed, but its pads cannot be selected or edited." ) );
m_AutoPlaceCtrl->SetItemToolTip( 2,
_( "Component is locked: it cannot be freely moved or auto placed." ) );
m_CostRot90Ctrl->SetValue( m_CurrentModule->GetPlacementCost90() );
......@@ -583,7 +590,8 @@ void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event )
modpos.x = ValueFromTextCtrl( *m_ModPositionX );
modpos.y = ValueFromTextCtrl( *m_ModPositionY );
m_CurrentModule->SetPosition( modpos );
m_CurrentModule->SetLocked( m_AutoPlaceCtrl->GetSelection() == 1 );
m_CurrentModule->SetLocked( m_AutoPlaceCtrl->GetSelection() == 2 );
m_CurrentModule->SetPadsLocked( m_AutoPlaceCtrl->GetSelection() == 1 );
switch( m_AttributsCtrl->GetSelection() )
{
......
......@@ -143,10 +143,10 @@ DIALOG_MODULE_BOARD_EDITOR_BASE::DIALOG_MODULE_BOARD_EDITOR_BASE( wxWindow* pare
m_AttributsCtrl->SetSelection( 0 );
bSizerAttrib->Add( m_AttributsCtrl, 1, wxALL|wxEXPAND, 5 );
wxString m_AutoPlaceCtrlChoices[] = { _("Free"), _("Locked") };
wxString m_AutoPlaceCtrlChoices[] = { _("Free"), _("Lock pads"), _("Lock module") };
int m_AutoPlaceCtrlNChoices = sizeof( m_AutoPlaceCtrlChoices ) / sizeof( wxString );
m_AutoPlaceCtrl = new wxRadioBox( m_PanelProperties, wxID_ANY, _("Move and Place"), wxDefaultPosition, wxDefaultSize, m_AutoPlaceCtrlNChoices, m_AutoPlaceCtrlChoices, 1, wxRA_SPECIFY_COLS );
m_AutoPlaceCtrl->SetSelection( 0 );
m_AutoPlaceCtrl->SetSelection( 1 );
bSizerAttrib->Add( m_AutoPlaceCtrl, 1, wxALL|wxEXPAND, 5 );
......
......@@ -2260,7 +2260,7 @@
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices">&quot;Free&quot; &quot;Locked&quot;</property>
<property name="choices">&quot;Free&quot; &quot;Lock pads&quot; &quot;Lock module&quot;</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
......@@ -2292,7 +2292,7 @@
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="selection">0</property>
<property name="selection">1</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxRA_SPECIFY_COLS</property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment