mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 17:23:44 +00:00
pcbnew: clean-up and partial de-auto-ization of MULTICHANNEL_TOOL
This commit is contained in:
parent
d37bdfbfe8
commit
6e84d665ed
@ -34,10 +34,9 @@ DIALOG_MULTICHANNEL_GENERATE_RULE_AREAS::DIALOG_MULTICHANNEL_GENERATE_RULE_AREAS
|
||||
DIALOG_MULTICHANNEL_GENERATE_RULE_AREAS_BASE( aFrame ),
|
||||
m_parentTool( aParentTool )
|
||||
{
|
||||
|
||||
int i = 0;
|
||||
|
||||
auto raData = m_parentTool->GetData();
|
||||
RULE_AREAS_DATA* raData = m_parentTool->GetData();
|
||||
|
||||
m_sheetsGrid->AppendCols( 3 );
|
||||
m_sheetsGrid->EnableEditing( true );
|
||||
@ -46,15 +45,14 @@ DIALOG_MULTICHANNEL_GENERATE_RULE_AREAS::DIALOG_MULTICHANNEL_GENERATE_RULE_AREAS
|
||||
m_sheetsGrid->SetColLabelValue( 1, wxT("Sheet Path") );
|
||||
m_sheetsGrid->SetColLabelValue( 2, wxT("Sheet Name") );
|
||||
m_sheetsGrid->AppendRows( raData->m_areas.size() - 1 );
|
||||
for( auto& sheet : raData->m_areas )
|
||||
{
|
||||
|
||||
for( RULE_AREA& sheet : raData->m_areas )
|
||||
{
|
||||
m_sheetsGrid->SetCellValue( i, 1, sheet.m_sheetPath );
|
||||
m_sheetsGrid->SetCellValue( i, 2, sheet.m_sheetName );
|
||||
m_sheetsGrid->SetCellRenderer( i, 0, new wxGridCellBoolRenderer);
|
||||
m_sheetsGrid->SetCellEditor( i, 0, new wxGridCellBoolEditor);
|
||||
m_sheetsGrid->SetCellValue( i, 0, sheet.m_generateEnabled ? wxT("1") : wxT( "0" ) );
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
@ -72,12 +70,12 @@ DIALOG_MULTICHANNEL_GENERATE_RULE_AREAS::DIALOG_MULTICHANNEL_GENERATE_RULE_AREAS
|
||||
|
||||
bool DIALOG_MULTICHANNEL_GENERATE_RULE_AREAS::TransferDataFromWindow()
|
||||
{
|
||||
auto raData = m_parentTool->GetData();
|
||||
RULE_AREAS_DATA* raData = m_parentTool->GetData();
|
||||
|
||||
for( size_t i = 0; i < raData->m_areas.size(); i++)
|
||||
for( size_t i = 0; i < raData->m_areas.size(); i++ )
|
||||
{
|
||||
wxString enabled = m_sheetsGrid->GetCellValue( i, 0 );
|
||||
raData->m_areas[i].m_generateEnabled = ( !enabled.CompareTo( wxT("1") ) ) ? true : false;
|
||||
raData->m_areas[i].m_generateEnabled = ( !enabled.CompareTo( wxT( "1" ) ) ) ? true : false;
|
||||
}
|
||||
|
||||
raData->m_replaceExisting = m_cbReplaceExisting->GetValue();
|
||||
|
@ -37,8 +37,6 @@ DIALOG_MULTICHANNEL_REPEAT_LAYOUT::DIALOG_MULTICHANNEL_REPEAT_LAYOUT (
|
||||
auto data = m_parentTool->GetData();
|
||||
m_refRAName->SetLabelText( data->m_refRA->m_area->GetZoneName() );
|
||||
|
||||
printf("CMAP: %d entries\n", (int) data->m_compatMap.size() );
|
||||
|
||||
for( auto& ra : data->m_compatMap )
|
||||
{
|
||||
TABLE_ENTRY ent;
|
||||
@ -73,15 +71,14 @@ DIALOG_MULTICHANNEL_REPEAT_LAYOUT::DIALOG_MULTICHANNEL_REPEAT_LAYOUT (
|
||||
m_raGrid->SetColLabelValue( 1, wxT("Target Rule Area") );
|
||||
m_raGrid->SetColLabelValue( 2, wxT("Status") );
|
||||
m_raGrid->AppendRows( m_targetRAs.size() - 1 );
|
||||
for( auto& entry : m_targetRAs)
|
||||
{
|
||||
|
||||
for( TABLE_ENTRY& entry : m_targetRAs)
|
||||
{
|
||||
m_raGrid->SetCellValue( i, 1, entry.m_raName );
|
||||
m_raGrid->SetCellValue( i, 2, entry.m_isOK ? _("OK") : entry.m_errMsg );
|
||||
m_raGrid->SetCellRenderer( i, 0, new wxGridCellBoolRenderer);
|
||||
m_raGrid->SetCellEditor( i, 0, new wxGridCellBoolEditor);
|
||||
m_raGrid->SetCellValue( i, 0, entry.m_doCopy ? wxT("1") : wxT("0") );
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
@ -104,13 +101,12 @@ bool DIALOG_MULTICHANNEL_REPEAT_LAYOUT::TransferDataFromWindow()
|
||||
{
|
||||
auto data = m_parentTool->GetData();
|
||||
|
||||
for( size_t i = 0; i < m_targetRAs.size(); i++)
|
||||
for( size_t i = 0; i < m_targetRAs.size(); i++ )
|
||||
{
|
||||
wxString doCopy = m_raGrid->GetCellValue( i, 0 );
|
||||
|
||||
data->m_compatMap[ m_targetRAs[i].m_targetRA ].m_doCopy = !doCopy.CompareTo( wxT("1") ) ? true : false;
|
||||
|
||||
// printf("RA %d cpy=%d\n", i, data->m_compatMap[ m_targetRAs[i].m_targetRA ].m_doCopy ? 1 : 0);
|
||||
data->m_compatMap[m_targetRAs[i].m_targetRA].m_doCopy =
|
||||
!doCopy.CompareTo( wxT( "1" ) ) ? true : false;
|
||||
}
|
||||
|
||||
data->m_options.m_copyPlacement = m_cbCopyPlacement->GetValue();
|
||||
@ -125,6 +121,8 @@ bool DIALOG_MULTICHANNEL_REPEAT_LAYOUT::TransferDataFromWindow()
|
||||
|
||||
bool DIALOG_MULTICHANNEL_REPEAT_LAYOUT::TransferDataToWindow()
|
||||
{
|
||||
// fixme: I have no idea how to use this together with wxGrid so that it resizes correctly...
|
||||
|
||||
//if( !wxDialog::TransferDataToWindow() )
|
||||
//return false;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -34,9 +34,8 @@
|
||||
#include <pad.h>
|
||||
#include <footprint.h>
|
||||
#include <reporter.h>
|
||||
#include <core/profile.h>
|
||||
|
||||
typedef std::vector<std::pair<FOOTPRINT*, FOOTPRINT*> > FP_PAIRS;
|
||||
typedef std::vector<std::pair<FOOTPRINT*, FOOTPRINT*>> FP_PAIRS;
|
||||
|
||||
enum class REPEAT_LAYOUT_EDGE_MODE
|
||||
{
|
||||
@ -47,25 +46,27 @@ enum class REPEAT_LAYOUT_EDGE_MODE
|
||||
|
||||
struct REPEAT_LAYOUT_OPTIONS
|
||||
{
|
||||
bool m_copyRouting = true;
|
||||
bool m_copyPlacement = true;
|
||||
bool m_groupItems = false;
|
||||
bool m_moveOffRAComponents = true;
|
||||
bool m_includeLockedItems = true;
|
||||
bool m_keepOldRouting = false;
|
||||
bool m_copyRouting = true;
|
||||
bool m_copyPlacement = true;
|
||||
bool m_groupItems = false;
|
||||
bool m_moveOffRAComponents = true;
|
||||
bool m_includeLockedItems = true;
|
||||
bool m_keepOldRouting = false;
|
||||
REPEAT_LAYOUT_EDGE_MODE m_edgeMode;
|
||||
};
|
||||
|
||||
struct PAD_PREFIX_ENTRY
|
||||
{
|
||||
PAD_PREFIX_ENTRY( PAD* pad_, wxString pfx_ ):
|
||||
pad(pad_), componentPrefix( pfx_ ), processed( false ) {};
|
||||
PAD* pad;
|
||||
PAD_PREFIX_ENTRY( PAD* pad_, wxString pfx_ ) :
|
||||
pad( pad_ ), componentPrefix( pfx_ ), processed( false ){};
|
||||
PAD* pad;
|
||||
wxString componentPrefix;
|
||||
bool processed;
|
||||
bool processed;
|
||||
|
||||
wxString format() const {
|
||||
return wxString::Format( wxT("%s-%s[%s]"), componentPrefix, pad->GetNumber(), pad->GetNetname().c_str().AsChar() );
|
||||
wxString format() const
|
||||
{
|
||||
return wxString::Format( wxT( "%s-%s[%s]" ), componentPrefix, pad->GetNumber(),
|
||||
pad->GetNetname().c_str().AsChar() );
|
||||
}
|
||||
|
||||
bool matchesPadNumberAndPrefix( const PAD_PREFIX_ENTRY& aOther ) const
|
||||
@ -82,10 +83,10 @@ struct PAD_PREFIX_ENTRY
|
||||
|
||||
struct FP_WITH_CONNECTIONS
|
||||
{
|
||||
FOOTPRINT* fp;
|
||||
typedef std::unordered_map<PAD*, std::vector<PAD_PREFIX_ENTRY> > PAD_CONNECTION_MAP;
|
||||
PAD_CONNECTION_MAP connsWithinRA;
|
||||
bool processed;
|
||||
FOOTPRINT* fp;
|
||||
typedef std::unordered_map<PAD*, std::vector<PAD_PREFIX_ENTRY>> PAD_CONNECTION_MAP;
|
||||
PAD_CONNECTION_MAP connsWithinRA;
|
||||
bool processed;
|
||||
|
||||
void sortByPadNumbers()
|
||||
{
|
||||
@ -94,7 +95,7 @@ struct FP_WITH_CONNECTIONS
|
||||
for( auto& ent : connsWithinRA )
|
||||
{
|
||||
std::vector<PAD_PREFIX_ENTRY> v( ent.second );
|
||||
auto compare = [] ( const PAD_PREFIX_ENTRY& a, const PAD_PREFIX_ENTRY& b ) -> int
|
||||
auto compare = []( const PAD_PREFIX_ENTRY& a, const PAD_PREFIX_ENTRY& b ) -> int
|
||||
{
|
||||
if( a.pad->GetNumber() > b.pad->GetNumber() )
|
||||
return 0;
|
||||
@ -105,7 +106,7 @@ struct FP_WITH_CONNECTIONS
|
||||
};
|
||||
|
||||
std::sort( v.begin(), v.end(), compare );
|
||||
sorted[ ent.first ] = v;
|
||||
sorted[ent.first] = v;
|
||||
}
|
||||
|
||||
connsWithinRA = sorted;
|
||||
@ -116,31 +117,31 @@ struct RULE_AREA;
|
||||
|
||||
struct RULE_AREA_COMPAT_DATA
|
||||
{
|
||||
RULE_AREA* m_refArea;
|
||||
bool m_isOk;
|
||||
bool m_doCopy;
|
||||
wxString m_errorMsg;
|
||||
std::vector< std::pair<FOOTPRINT*, FOOTPRINT*> > m_matchingFootprints;
|
||||
RULE_AREA* m_refArea;
|
||||
bool m_isOk;
|
||||
bool m_doCopy;
|
||||
wxString m_errorMsg;
|
||||
std::vector<std::pair<FOOTPRINT*, FOOTPRINT*>> m_matchingFootprints;
|
||||
};
|
||||
|
||||
struct RULE_AREA
|
||||
{
|
||||
ZONE* m_area;
|
||||
std::vector<FP_WITH_CONNECTIONS> m_raFootprints;
|
||||
std::set<FOOTPRINT*> m_sheetComponents;
|
||||
std::map<PAD*, FOOTPRINT*> m_fpPads;
|
||||
bool m_existsAlready;
|
||||
bool m_generateEnabled;
|
||||
wxString m_sheetPath;
|
||||
wxString m_sheetName;
|
||||
wxString m_ruleName;
|
||||
VECTOR2I m_center;
|
||||
};
|
||||
{
|
||||
ZONE* m_area;
|
||||
std::vector<FP_WITH_CONNECTIONS> m_raFootprints;
|
||||
std::set<FOOTPRINT*> m_sheetComponents;
|
||||
std::map<PAD*, FOOTPRINT*> m_fpPads;
|
||||
bool m_existsAlready;
|
||||
bool m_generateEnabled;
|
||||
wxString m_sheetPath;
|
||||
wxString m_sheetName;
|
||||
wxString m_ruleName;
|
||||
VECTOR2I m_center;
|
||||
};
|
||||
|
||||
|
||||
struct RA_SHEET
|
||||
{
|
||||
bool m_generateEnabled;
|
||||
bool m_generateEnabled;
|
||||
wxString m_sheetPath;
|
||||
wxString m_sheetName;
|
||||
};
|
||||
@ -148,52 +149,51 @@ struct RA_SHEET
|
||||
|
||||
struct RULE_AREAS_DATA
|
||||
{
|
||||
bool m_replaceExisting;
|
||||
bool m_groupItems;
|
||||
RULE_AREA* m_refRA;
|
||||
bool m_replaceExisting;
|
||||
bool m_groupItems;
|
||||
RULE_AREA* m_refRA;
|
||||
REPEAT_LAYOUT_OPTIONS m_options;
|
||||
|
||||
std::vector<RULE_AREA> m_areas;
|
||||
std::vector<RULE_AREA> m_areas;
|
||||
std::unordered_map<RULE_AREA*, RULE_AREA_COMPAT_DATA> m_compatMap;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
class MULTICHANNEL_TOOL : public PCB_TOOL_BASE
|
||||
{
|
||||
public:
|
||||
MULTICHANNEL_TOOL();
|
||||
~MULTICHANNEL_TOOL();
|
||||
public:
|
||||
MULTICHANNEL_TOOL();
|
||||
~MULTICHANNEL_TOOL();
|
||||
|
||||
RULE_AREAS_DATA* GetData() { return &m_areas; }
|
||||
RULE_AREAS_DATA* GetData() { return &m_areas; }
|
||||
|
||||
private:
|
||||
void setTransitions() override;
|
||||
int autogenerateRuleAreas( const TOOL_EVENT& aEvent );
|
||||
int repeatLayout( const TOOL_EVENT& aEvent );
|
||||
wxString stripComponentIndex( wxString aRef ) const;
|
||||
bool identifyComponentsInRuleArea( ZONE* aRuleArea, std::set<FOOTPRINT*>& aComponents );
|
||||
const SHAPE_LINE_CHAIN buildRAOutline( std::set<FOOTPRINT*>& aFootprints, int aMargin );
|
||||
std::set<FOOTPRINT*> queryComponentsInSheet( wxString aSheetName );
|
||||
void findExistingRuleAreas();
|
||||
void querySheets();
|
||||
private:
|
||||
void setTransitions() override;
|
||||
int autogenerateRuleAreas( const TOOL_EVENT& aEvent );
|
||||
int repeatLayout( const TOOL_EVENT& aEvent );
|
||||
wxString stripComponentIndex( wxString aRef ) const;
|
||||
bool identifyComponentsInRuleArea( ZONE* aRuleArea, std::set<FOOTPRINT*>& aComponents );
|
||||
const SHAPE_LINE_CHAIN buildRAOutline( std::set<FOOTPRINT*>& aFootprints, int aMargin );
|
||||
std::set<FOOTPRINT*> queryComponentsInSheet( wxString aSheetName );
|
||||
void findExistingRuleAreas();
|
||||
void querySheets();
|
||||
|
||||
RULE_AREA* findRAByName( const wxString& aName );
|
||||
bool resolveConnectionTopology( RULE_AREA* aRefArea, RULE_AREA* aTargetArea, RULE_AREA_COMPAT_DATA& aMatches );
|
||||
bool copyRuleAreaContents( FP_PAIRS& aMatches, BOARD_COMMIT* aCommit, RULE_AREA* aRefArea, RULE_AREA* aTargetArea, REPEAT_LAYOUT_OPTIONS aOpts );
|
||||
int findRoutedConnections( std::set<BOARD_ITEM*> &aOutput,
|
||||
std::shared_ptr<CONNECTIVITY_DATA> aConnectivity,
|
||||
const SHAPE_POLY_SET& aRAPoly, RULE_AREA* aRA,
|
||||
FOOTPRINT* aFp,
|
||||
const REPEAT_LAYOUT_OPTIONS& aOpts ) const;
|
||||
RULE_AREA* findRAByName( const wxString& aName );
|
||||
bool resolveConnectionTopology( RULE_AREA* aRefArea, RULE_AREA* aTargetArea,
|
||||
RULE_AREA_COMPAT_DATA& aMatches );
|
||||
bool copyRuleAreaContents( FP_PAIRS& aMatches, BOARD_COMMIT* aCommit, RULE_AREA* aRefArea,
|
||||
RULE_AREA* aTargetArea, REPEAT_LAYOUT_OPTIONS aOpts );
|
||||
int findRoutedConnections( std::set<BOARD_ITEM*>& aOutput,
|
||||
std::shared_ptr<CONNECTIVITY_DATA> aConnectivity,
|
||||
const SHAPE_POLY_SET& aRAPoly, RULE_AREA* aRA, FOOTPRINT* aFp,
|
||||
const REPEAT_LAYOUT_OPTIONS& aOpts ) const;
|
||||
|
||||
bool checkIfPadNetsMatch( FP_WITH_CONNECTIONS& aRef, FP_WITH_CONNECTIONS& aTgt, FP_PAIRS& aMatches ) const;
|
||||
bool checkIfPadNetsMatch( FP_WITH_CONNECTIONS& aRef, FP_WITH_CONNECTIONS& aTgt,
|
||||
FP_PAIRS& aMatches ) const;
|
||||
|
||||
std::unique_ptr<REPORTER> m_reporter;
|
||||
RULE_AREAS_DATA m_areas;
|
||||
std::unique_ptr<REPORTER> m_reporter;
|
||||
RULE_AREAS_DATA m_areas;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // TOOLS_MULTICHANNEL_TOOL
|
||||
|
Loading…
Reference in New Issue
Block a user