Post merge request clean up.
This commit is contained in:
parent
43c45f3ee8
commit
23169ca1a7
|
@ -39,12 +39,15 @@
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <sch_drawing_tools.h>
|
#include <sch_drawing_tools.h>
|
||||||
|
|
||||||
DIALOG_SYNC_SHEET_PINS::DIALOG_SYNC_SHEET_PINS(
|
|
||||||
wxWindow* aParent, std::list<SCH_SHEET_PATH> aSheetPath,
|
DIALOG_SYNC_SHEET_PINS::DIALOG_SYNC_SHEET_PINS( wxWindow* aParent,
|
||||||
|
std::list<SCH_SHEET_PATH> aSheetPath,
|
||||||
std::shared_ptr<SHEET_SYNCHRONIZATION_AGENT> aAgent ) :
|
std::shared_ptr<SHEET_SYNCHRONIZATION_AGENT> aAgent ) :
|
||||||
DIALOG_SYNC_SHEET_PINS_BASE( aParent ),
|
DIALOG_SYNC_SHEET_PINS_BASE( aParent ),
|
||||||
m_agent( std::move( aAgent ) ), m_lastEditSheet( nullptr ),
|
m_agent( std::move( aAgent ) ),
|
||||||
m_placeItemKind( PlaceItemKind::UNDEFINED ), m_placementTemplate( nullptr )
|
m_lastEditSheet( nullptr ),
|
||||||
|
m_placeItemKind( PlaceItemKind::UNDEFINED ),
|
||||||
|
m_placementTemplate( nullptr )
|
||||||
{
|
{
|
||||||
wxImageList* imageList = new wxImageList( SYNC_SHEET_PIN_PREFERENCE::NORMAL_WIDTH,
|
wxImageList* imageList = new wxImageList( SYNC_SHEET_PIN_PREFERENCE::NORMAL_WIDTH,
|
||||||
SYNC_SHEET_PIN_PREFERENCE::NORMAL_HEIGHT );
|
SYNC_SHEET_PIN_PREFERENCE::NORMAL_HEIGHT );
|
||||||
|
@ -122,6 +125,7 @@ void DIALOG_SYNC_SHEET_PINS::OnCloseBtnClick( wxCommandEvent& event )
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DIALOG_SYNC_SHEET_PINS::OnClose( wxCloseEvent& aEvent )
|
void DIALOG_SYNC_SHEET_PINS::OnClose( wxCloseEvent& aEvent )
|
||||||
{
|
{
|
||||||
aEvent.Skip();
|
aEvent.Skip();
|
||||||
|
|
|
@ -37,6 +37,7 @@ class EDA_ITEM;
|
||||||
class SHEET_SYNCHRONIZATION_AGENT;
|
class SHEET_SYNCHRONIZATION_AGENT;
|
||||||
class PANEL_SYNC_SHEET_PINS;
|
class PANEL_SYNC_SHEET_PINS;
|
||||||
class SCH_HIERLABEL;
|
class SCH_HIERLABEL;
|
||||||
|
|
||||||
class DIALOG_SYNC_SHEET_PINS : public DIALOG_SYNC_SHEET_PINS_BASE
|
class DIALOG_SYNC_SHEET_PINS : public DIALOG_SYNC_SHEET_PINS_BASE
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -59,7 +60,7 @@ public:
|
||||||
void EndPlaceItem( EDA_ITEM* aNewItem );
|
void EndPlaceItem( EDA_ITEM* aNewItem );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Start place a new SHEET_PIN / HIERLABEL
|
* Start place a new #SHEET_PIN/#HIERLABEL.
|
||||||
*
|
*
|
||||||
* @param aSheet The sheet instance
|
* @param aSheet The sheet instance
|
||||||
* @param aKind SHEET_PIN / HIERLABEL
|
* @param aKind SHEET_PIN / HIERLABEL
|
||||||
|
@ -68,7 +69,7 @@ public:
|
||||||
void BeginPlaceItem( SCH_SHEET* aSheet, PlaceItemKind aKind, EDA_ITEM* aTemplate );
|
void BeginPlaceItem( SCH_SHEET* aSheet, PlaceItemKind aKind, EDA_ITEM* aTemplate );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the Placement Template SHEET_PIN / HIERLABEL used for place a new HIERLABEL/SHEET_PIN
|
* Get the Placement Template SHEET_PIN / HIERLABEL used for place a new #HIERLABEL/#SHEET_PIN.
|
||||||
*
|
*
|
||||||
* @return SCH_HIERLABEL*
|
* @return SCH_HIERLABEL*
|
||||||
*/
|
*/
|
||||||
|
@ -79,6 +80,7 @@ private:
|
||||||
//It's the agent that performs modification and placement
|
//It's the agent that performs modification and placement
|
||||||
std::shared_ptr<SHEET_SYNCHRONIZATION_AGENT> m_agent;
|
std::shared_ptr<SHEET_SYNCHRONIZATION_AGENT> m_agent;
|
||||||
SCH_SHEET* m_lastEditSheet;
|
SCH_SHEET* m_lastEditSheet;
|
||||||
|
|
||||||
//The same sheet may have mutiple instances
|
//The same sheet may have mutiple instances
|
||||||
std::unordered_map<SCH_SHEET*, PANEL_SYNC_SHEET_PINS*> m_panels;
|
std::unordered_map<SCH_SHEET*, PANEL_SYNC_SHEET_PINS*> m_panels;
|
||||||
PlaceItemKind m_placeItemKind;
|
PlaceItemKind m_placeItemKind;
|
||||||
|
|
|
@ -42,10 +42,14 @@
|
||||||
PANEL_SYNC_SHEET_PINS::PANEL_SYNC_SHEET_PINS( wxWindow* aParent, SCH_SHEET* aSheet,
|
PANEL_SYNC_SHEET_PINS::PANEL_SYNC_SHEET_PINS( wxWindow* aParent, SCH_SHEET* aSheet,
|
||||||
wxNotebook* aNoteBook, int aIndex,
|
wxNotebook* aNoteBook, int aIndex,
|
||||||
SHEET_SYNCHRONIZATION_AGENT& aAgent,
|
SHEET_SYNCHRONIZATION_AGENT& aAgent,
|
||||||
SCH_SHEET_PATH aPath ) :
|
const SCH_SHEET_PATH& aPath ) :
|
||||||
PANEL_SYNC_SHEET_PINS_BASE( aParent ),
|
PANEL_SYNC_SHEET_PINS_BASE( aParent ),
|
||||||
m_sheet( aSheet ), m_noteBook( aNoteBook ), m_index( aIndex ),
|
m_sheet( aSheet ),
|
||||||
m_sheetFileName( aSheet->GetFileName() ), m_agent( aAgent ), m_path( std::move( aPath ) )
|
m_noteBook( aNoteBook ),
|
||||||
|
m_index( aIndex ),
|
||||||
|
m_sheetFileName( aSheet->GetFileName() ),
|
||||||
|
m_agent( aAgent ),
|
||||||
|
m_path( std::move( aPath ) )
|
||||||
{
|
{
|
||||||
m_btnUsePinAsTemplate->SetBitmap( KiBitmapBundle( BITMAPS::add_hierar_pin ) );
|
m_btnUsePinAsTemplate->SetBitmap( KiBitmapBundle( BITMAPS::add_hierar_pin ) );
|
||||||
m_btnUseLabelAsTemplate->SetBitmap( KiBitmapBundle( BITMAPS::add_hierarchical_label ) );
|
m_btnUseLabelAsTemplate->SetBitmap( KiBitmapBundle( BITMAPS::add_hierarchical_label ) );
|
||||||
|
@ -101,6 +105,7 @@ void PANEL_SYNC_SHEET_PINS::UpdateForms()
|
||||||
for( size_t i = 0; i < pins_ori.size(); i++ )
|
for( size_t i = 0; i < pins_ori.size(); i++ )
|
||||||
{
|
{
|
||||||
SCH_SHEET_PIN* cur_pin = pins_ori[i];
|
SCH_SHEET_PIN* cur_pin = pins_ori[i];
|
||||||
|
|
||||||
if( label->GetText() == cur_pin->GetText() && label->GetShape() == cur_pin->GetShape() )
|
if( label->GetText() == cur_pin->GetText() && label->GetShape() == cur_pin->GetShape() )
|
||||||
{
|
{
|
||||||
associated_list.push_back(
|
associated_list.push_back(
|
||||||
|
@ -109,11 +114,11 @@ void PANEL_SYNC_SHEET_PINS::UpdateForms()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
labels_list.push_back(
|
labels_list.push_back(
|
||||||
std::make_shared<SCH_HIERLABEL_SYNCHRONIZATION_ITEM>( label, m_sheet ) );
|
std::make_shared<SCH_HIERLABEL_SYNCHRONIZATION_ITEM>( label, m_sheet ) );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
for( const auto& item : labels_ori )
|
for( const auto& item : labels_ori )
|
||||||
check_matched( static_cast<SCH_HIERLABEL*>( item ) );
|
check_matched( static_cast<SCH_HIERLABEL*>( item ) );
|
||||||
|
|
||||||
|
@ -141,8 +146,7 @@ void PANEL_SYNC_SHEET_PINS::UpdateForms()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SHEET_SYNCHRONIZATION_MODEL_PTR
|
SHEET_SYNCHRONIZATION_MODEL_PTR PANEL_SYNC_SHEET_PINS::GetModel( int aKind ) const
|
||||||
PANEL_SYNC_SHEET_PINS::GetModel( int aKind ) const
|
|
||||||
{
|
{
|
||||||
return m_models.at( aKind );
|
return m_models.at( aKind );
|
||||||
}
|
}
|
||||||
|
@ -172,11 +176,15 @@ void PANEL_SYNC_SHEET_PINS::OnBtnAddLabelsClicked( wxCommandEvent& aEvent )
|
||||||
|
|
||||||
if( auto idx = m_models[SHEET_SYNCHRONIZATION_MODEL::SHEET_PIN]->GetSelectedIndex();
|
if( auto idx = m_models[SHEET_SYNCHRONIZATION_MODEL::SHEET_PIN]->GetSelectedIndex();
|
||||||
idx.has_value() )
|
idx.has_value() )
|
||||||
|
{
|
||||||
if( SHEET_SYNCHRONIZATION_ITE_PTR item =
|
if( SHEET_SYNCHRONIZATION_ITE_PTR item =
|
||||||
m_models[SHEET_SYNCHRONIZATION_MODEL::SHEET_PIN]->GetSynchronizationItem(
|
m_models[SHEET_SYNCHRONIZATION_MODEL::SHEET_PIN]->GetSynchronizationItem(
|
||||||
*idx ) )
|
*idx ) )
|
||||||
|
{
|
||||||
m_agent.PlaceHieraLable( m_sheet, m_path,
|
m_agent.PlaceHieraLable( m_sheet, m_path,
|
||||||
static_cast<SCH_SHEET_PIN*>( item->GetItem() ) );
|
static_cast<SCH_SHEET_PIN*>( item->GetItem() ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -186,11 +194,15 @@ void PANEL_SYNC_SHEET_PINS::OnBtnAddSheetPinsClicked( wxCommandEvent& aEvent )
|
||||||
|
|
||||||
if( auto idx = m_models[SHEET_SYNCHRONIZATION_MODEL::HIRE_LABEL]->GetSelectedIndex();
|
if( auto idx = m_models[SHEET_SYNCHRONIZATION_MODEL::HIRE_LABEL]->GetSelectedIndex();
|
||||||
idx.has_value() )
|
idx.has_value() )
|
||||||
|
{
|
||||||
if( SHEET_SYNCHRONIZATION_ITE_PTR item =
|
if( SHEET_SYNCHRONIZATION_ITE_PTR item =
|
||||||
m_models[SHEET_SYNCHRONIZATION_MODEL::HIRE_LABEL]->GetSynchronizationItem(
|
m_models[SHEET_SYNCHRONIZATION_MODEL::HIRE_LABEL]->GetSynchronizationItem(
|
||||||
*idx ) )
|
*idx ) )
|
||||||
|
{
|
||||||
m_agent.PlaceSheetPin( m_sheet, m_path,
|
m_agent.PlaceSheetPin( m_sheet, m_path,
|
||||||
static_cast<SCH_HIERLABEL*>( item->GetItem() ) );
|
static_cast<SCH_HIERLABEL*>( item->GetItem() ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -200,8 +212,10 @@ void PANEL_SYNC_SHEET_PINS::GenericSync( SYNC_DIRECTION direction )
|
||||||
wxDataViewItem pinIdx = m_viewSheetPins->GetSelection();
|
wxDataViewItem pinIdx = m_viewSheetPins->GetSelection();
|
||||||
|
|
||||||
for( auto& idx : { labelIdx, pinIdx } )
|
for( auto& idx : { labelIdx, pinIdx } )
|
||||||
|
{
|
||||||
if( !idx.IsOk() )
|
if( !idx.IsOk() )
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SHEET_SYNCHRONIZATION_ITE_PTR labelItem =
|
SHEET_SYNCHRONIZATION_ITE_PTR labelItem =
|
||||||
m_models[SHEET_SYNCHRONIZATION_MODEL::HIRE_LABEL]->TakeItem( labelIdx );
|
m_models[SHEET_SYNCHRONIZATION_MODEL::HIRE_LABEL]->TakeItem( labelIdx );
|
||||||
|
@ -209,8 +223,10 @@ void PANEL_SYNC_SHEET_PINS::GenericSync( SYNC_DIRECTION direction )
|
||||||
m_models[SHEET_SYNCHRONIZATION_MODEL::SHEET_PIN]->TakeItem( pinIdx );
|
m_models[SHEET_SYNCHRONIZATION_MODEL::SHEET_PIN]->TakeItem( pinIdx );
|
||||||
|
|
||||||
for( const auto& item : { labelItem, pinItem } )
|
for( const auto& item : { labelItem, pinItem } )
|
||||||
|
{
|
||||||
if( !item )
|
if( !item )
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto label_ptr =
|
auto label_ptr =
|
||||||
std::static_pointer_cast<SCH_HIERLABEL_SYNCHRONIZATION_ITEM>( labelItem )->GetLabel();
|
std::static_pointer_cast<SCH_HIERLABEL_SYNCHRONIZATION_ITEM>( labelItem )->GetLabel();
|
||||||
|
@ -247,7 +263,9 @@ void PANEL_SYNC_SHEET_PINS::GenericSync( SYNC_DIRECTION direction )
|
||||||
|
|
||||||
for( auto idx :
|
for( auto idx :
|
||||||
{ SHEET_SYNCHRONIZATION_MODEL::HIRE_LABEL, SHEET_SYNCHRONIZATION_MODEL::SHEET_PIN } )
|
{ SHEET_SYNCHRONIZATION_MODEL::HIRE_LABEL, SHEET_SYNCHRONIZATION_MODEL::SHEET_PIN } )
|
||||||
|
{
|
||||||
PostProcessModelSelection( idx, {} );
|
PostProcessModelSelection( idx, {} );
|
||||||
|
}
|
||||||
|
|
||||||
m_models[SHEET_SYNCHRONIZATION_MODEL::HIRE_LABEL]->DoNotify();
|
m_models[SHEET_SYNCHRONIZATION_MODEL::HIRE_LABEL]->DoNotify();
|
||||||
}
|
}
|
||||||
|
@ -317,6 +335,7 @@ void PANEL_SYNC_SHEET_PINS::OnBtnUndoClicked( wxCommandEvent& aEvent )
|
||||||
std::make_shared<SCH_SHEET_PIN_SYNCHRONIZATION_ITEM>( associated->GetPin(),
|
std::make_shared<SCH_SHEET_PIN_SYNCHRONIZATION_ITEM>( associated->GetPin(),
|
||||||
m_sheet ) );
|
m_sheet ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
PostProcessModelSelection( SHEET_SYNCHRONIZATION_MODEL::ASSOCIATED, {} );
|
PostProcessModelSelection( SHEET_SYNCHRONIZATION_MODEL::ASSOCIATED, {} );
|
||||||
UpdatePageImage();
|
UpdatePageImage();
|
||||||
}
|
}
|
||||||
|
@ -335,12 +354,14 @@ void PANEL_SYNC_SHEET_PINS::PostProcessModelSelection( int aIdex, wxDataViewItem
|
||||||
{
|
{
|
||||||
for( auto btn : { m_btnAddLabels, m_btnRmPins } )
|
for( auto btn : { m_btnAddLabels, m_btnRmPins } )
|
||||||
btn->Enable( m_models[SHEET_SYNCHRONIZATION_MODEL::SHEET_PIN]->HasSelectedIndex() );
|
btn->Enable( m_models[SHEET_SYNCHRONIZATION_MODEL::SHEET_PIN]->HasSelectedIndex() );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SHEET_SYNCHRONIZATION_MODEL::HIRE_LABEL:
|
case SHEET_SYNCHRONIZATION_MODEL::HIRE_LABEL:
|
||||||
{
|
{
|
||||||
for( auto btn : { m_btnAddSheetPins, m_btnRmLabels } )
|
for( auto btn : { m_btnAddSheetPins, m_btnRmLabels } )
|
||||||
btn->Enable( m_models[SHEET_SYNCHRONIZATION_MODEL::HIRE_LABEL]->HasSelectedIndex() );
|
btn->Enable( m_models[SHEET_SYNCHRONIZATION_MODEL::HIRE_LABEL]->HasSelectedIndex() );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SHEET_SYNCHRONIZATION_MODEL::ASSOCIATED:
|
case SHEET_SYNCHRONIZATION_MODEL::ASSOCIATED:
|
||||||
|
@ -348,7 +369,8 @@ void PANEL_SYNC_SHEET_PINS::PostProcessModelSelection( int aIdex, wxDataViewItem
|
||||||
m_btnUndo->Enable( m_models[SHEET_SYNCHRONIZATION_MODEL::ASSOCIATED]->HasSelectedIndex() );
|
m_btnUndo->Enable( m_models[SHEET_SYNCHRONIZATION_MODEL::ASSOCIATED]->HasSelectedIndex() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: break;
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( aIdex != SHEET_SYNCHRONIZATION_MODEL::ASSOCIATED )
|
if( aIdex != SHEET_SYNCHRONIZATION_MODEL::ASSOCIATED )
|
||||||
|
|
|
@ -53,7 +53,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
PANEL_SYNC_SHEET_PINS( wxWindow* aParent, SCH_SHEET* aSheet, wxNotebook* aNoteBook, int aIndex,
|
PANEL_SYNC_SHEET_PINS( wxWindow* aParent, SCH_SHEET* aSheet, wxNotebook* aNoteBook, int aIndex,
|
||||||
SHEET_SYNCHRONIZATION_AGENT& aAgent, SCH_SHEET_PATH aPath );
|
SHEET_SYNCHRONIZATION_AGENT& aAgent, const SCH_SHEET_PATH& aPath );
|
||||||
|
|
||||||
~PANEL_SYNC_SHEET_PINS() override;
|
~PANEL_SYNC_SHEET_PINS() override;
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,10 @@ SHEET_SYNCHRONIZATION_AGENT::SHEET_SYNCHRONIZATION_AGENT( DO_MODIFY_ITEM aDoMod
|
||||||
TOOL_MANAGER* aToolManager,
|
TOOL_MANAGER* aToolManager,
|
||||||
SCH_EDIT_FRAME* a_frame ) :
|
SCH_EDIT_FRAME* a_frame ) :
|
||||||
m_doModify( std::move( aDoModify ) ),
|
m_doModify( std::move( aDoModify ) ),
|
||||||
m_doDelete( std::move( aNotifyItemChange ) ), m_doPlaceItem( std::move( aPlaceItem ) ),
|
m_doDelete( std::move( aNotifyItemChange ) ),
|
||||||
m_toolManager( aToolManager ), m_frame( a_frame )
|
m_doPlaceItem( std::move( aPlaceItem ) ),
|
||||||
|
m_toolManager( aToolManager ),
|
||||||
|
m_frame( a_frame )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +56,7 @@ void SHEET_SYNCHRONIZATION_AGENT::ModifyItem( SHEET_SYNCHRONIZATION_ITEM& aItem,
|
||||||
|
|
||||||
|
|
||||||
void SHEET_SYNCHRONIZATION_AGENT::ModifyItem( SCH_ITEM* sch_item, std::function<void()> aDoModify,
|
void SHEET_SYNCHRONIZATION_AGENT::ModifyItem( SCH_ITEM* sch_item, std::function<void()> aDoModify,
|
||||||
SCH_SHEET_PATH const& aPath,
|
const SCH_SHEET_PATH& aPath,
|
||||||
SHEET_SYNCHRONIZATION_ITEM_KIND aKind )
|
SHEET_SYNCHRONIZATION_ITEM_KIND aKind )
|
||||||
{
|
{
|
||||||
if( !aDoModify )
|
if( !aDoModify )
|
||||||
|
@ -68,20 +70,20 @@ void SHEET_SYNCHRONIZATION_AGENT::ModifyItem( SCH_ITEM* sch_item, std::function<
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SHEET_SYNCHRONIZATION_ITEM_KIND::SHEET_PIN:
|
case SHEET_SYNCHRONIZATION_ITEM_KIND::SHEET_PIN:
|
||||||
|
|
||||||
{
|
{
|
||||||
SCH_SHEET_PATH path_cp = aPath;
|
SCH_SHEET_PATH path_cp = aPath;
|
||||||
path_cp.pop_back();
|
path_cp.pop_back();
|
||||||
m_doModify( sch_item, path_cp, aDoModify );
|
m_doModify( sch_item, path_cp, aDoModify );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SHEET_SYNCHRONIZATION_ITEM_KIND::HIERLABEL_AND_SHEET_PIN: break;
|
case SHEET_SYNCHRONIZATION_ITEM_KIND::HIERLABEL_AND_SHEET_PIN:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SHEET_SYNCHRONIZATION_AGENT::RemoveItem( SHEET_SYNCHRONIZATION_ITEM& aItem, SCH_SHEET* aSheet,
|
void SHEET_SYNCHRONIZATION_AGENT::RemoveItem( SHEET_SYNCHRONIZATION_ITEM& aItem, SCH_SHEET* aSheet,
|
||||||
SCH_SHEET_PATH const& aPath )
|
const SCH_SHEET_PATH& aPath )
|
||||||
{
|
{
|
||||||
if( !aSheet )
|
if( !aSheet )
|
||||||
return;
|
return;
|
||||||
|
@ -101,7 +103,8 @@ void SHEET_SYNCHRONIZATION_AGENT::RemoveItem( SHEET_SYNCHRONIZATION_ITEM& aItem,
|
||||||
m_doDelete( aItem.GetItem(), path_cp );
|
m_doDelete( aItem.GetItem(), path_cp );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SHEET_SYNCHRONIZATION_ITEM_KIND::HIERLABEL_AND_SHEET_PIN: break;
|
case SHEET_SYNCHRONIZATION_ITEM_KIND::HIERLABEL_AND_SHEET_PIN:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,7 @@ class SCH_ITEM;
|
||||||
enum class SHEET_SYNCHRONIZATION_ITEM_KIND;
|
enum class SHEET_SYNCHRONIZATION_ITEM_KIND;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Agent for all the modifications while syncing the sheet pin and hierlabel
|
* Agent for all the modifications while syncing the sheet pin and hierarchical label.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class SHEET_SYNCHRONIZATION_AGENT
|
class SHEET_SYNCHRONIZATION_AGENT
|
||||||
{
|
{
|
||||||
|
@ -69,9 +68,9 @@ public:
|
||||||
~SHEET_SYNCHRONIZATION_AGENT();
|
~SHEET_SYNCHRONIZATION_AGENT();
|
||||||
|
|
||||||
void ModifyItem( SHEET_SYNCHRONIZATION_ITEM& aItem, std::function<void()> aDoModify,
|
void ModifyItem( SHEET_SYNCHRONIZATION_ITEM& aItem, std::function<void()> aDoModify,
|
||||||
SCH_SHEET_PATH const& aPath );
|
const SCH_SHEET_PATH& aPath );
|
||||||
|
|
||||||
void ModifyItem( SCH_ITEM* aItem, std::function<void()> aDoModify, SCH_SHEET_PATH const& aPath,
|
void ModifyItem( SCH_ITEM* aItem, std::function<void()> aDoModify, const SCH_SHEET_PATH& aPath,
|
||||||
SHEET_SYNCHRONIZATION_ITEM_KIND aKind );
|
SHEET_SYNCHRONIZATION_ITEM_KIND aKind );
|
||||||
|
|
||||||
void RemoveItem( SHEET_SYNCHRONIZATION_ITEM& aItem, SCH_SHEET* aSheet,
|
void RemoveItem( SHEET_SYNCHRONIZATION_ITEM& aItem, SCH_SHEET* aSheet,
|
||||||
|
|
|
@ -143,14 +143,16 @@ int ASSOCIATED_SCH_LABEL_PIN::GetShape() const
|
||||||
wxBitmap& ASSOCIATED_SCH_LABEL_PIN::GetBitmap() const
|
wxBitmap& ASSOCIATED_SCH_LABEL_PIN::GetBitmap() const
|
||||||
{
|
{
|
||||||
static auto label_and_pin_icon = ( []{
|
static auto label_and_pin_icon = ( []{
|
||||||
wxBitmap left = KiBitmap( BITMAPS::add_hierar_pin, SYNC_SHEET_PIN_PREFERENCE::NORMAL_HEIGHT );
|
wxBitmap left = KiBitmap( BITMAPS::add_hierar_pin,
|
||||||
|
SYNC_SHEET_PIN_PREFERENCE::NORMAL_HEIGHT );
|
||||||
wxBitmap right =
|
wxBitmap right =
|
||||||
KiBitmap( BITMAPS::add_hierarchical_label, SYNC_SHEET_PIN_PREFERENCE::NORMAL_HEIGHT );
|
KiBitmap( BITMAPS::add_hierarchical_label,
|
||||||
|
SYNC_SHEET_PIN_PREFERENCE::NORMAL_HEIGHT );
|
||||||
wxImage img( wxSize{ SYNC_SHEET_PIN_PREFERENCE::NORMAL_WIDTH * 2,
|
wxImage img( wxSize{ SYNC_SHEET_PIN_PREFERENCE::NORMAL_WIDTH * 2,
|
||||||
SYNC_SHEET_PIN_PREFERENCE::NORMAL_HEIGHT } );
|
SYNC_SHEET_PIN_PREFERENCE::NORMAL_HEIGHT } );
|
||||||
img.Paste( left.ConvertToImage(), 0, 0 );
|
img.Paste( left.ConvertToImage(), 0, 0 );
|
||||||
img.Paste( right.ConvertToImage(), SYNC_SHEET_PIN_PREFERENCE::NORMAL_WIDTH, 0 );
|
img.Paste( right.ConvertToImage(), SYNC_SHEET_PIN_PREFERENCE::NORMAL_WIDTH, 0 );
|
||||||
return wxBitmap(img);
|
return wxBitmap( img );
|
||||||
} )();
|
} )();
|
||||||
|
|
||||||
return label_and_pin_icon;
|
return label_and_pin_icon;
|
||||||
|
|
|
@ -44,6 +44,7 @@ enum class SHEET_SYNCHRONIZATION_ITEM_KIND
|
||||||
};
|
};
|
||||||
|
|
||||||
using SCREEN_UPDATER = std::function<void( EDA_ITEM* )>;
|
using SCREEN_UPDATER = std::function<void( EDA_ITEM* )>;
|
||||||
|
|
||||||
class SHEET_SYNCHRONIZATION_ITEM
|
class SHEET_SYNCHRONIZATION_ITEM
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -60,6 +61,7 @@ public:
|
||||||
virtual SHEET_SYNCHRONIZATION_ITEM_KIND GetKind() const = 0;
|
virtual SHEET_SYNCHRONIZATION_ITEM_KIND GetKind() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class SCH_HIERLABEL_SYNCHRONIZATION_ITEM : public SHEET_SYNCHRONIZATION_ITEM
|
class SCH_HIERLABEL_SYNCHRONIZATION_ITEM : public SHEET_SYNCHRONIZATION_ITEM
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -39,9 +39,11 @@ extern wxString getElectricalTypeLabel( LABEL_FLAG_SHAPE aType );
|
||||||
|
|
||||||
SHEET_SYNCHRONIZATION_MODEL::SHEET_SYNCHRONIZATION_MODEL( SHEET_SYNCHRONIZATION_AGENT& aAgent,
|
SHEET_SYNCHRONIZATION_MODEL::SHEET_SYNCHRONIZATION_MODEL( SHEET_SYNCHRONIZATION_AGENT& aAgent,
|
||||||
SCH_SHEET* aSheet,
|
SCH_SHEET* aSheet,
|
||||||
SCH_SHEET_PATH aPath ) :
|
SCH_SHEET_PATH& aPath ) :
|
||||||
m_selectedIndex( std::optional<unsigned>() ),
|
m_selectedIndex( std::optional<unsigned>() ),
|
||||||
m_agent( aAgent ), m_sheet( aSheet ), m_path( std::move( aPath ) )
|
m_agent( aAgent ),
|
||||||
|
m_sheet( aSheet ),
|
||||||
|
m_path( std::move( aPath ) )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +58,9 @@ void SHEET_SYNCHRONIZATION_MODEL::GetValueByRow( wxVariant& aVariant, unsigned r
|
||||||
|
|
||||||
switch( col )
|
switch( col )
|
||||||
{
|
{
|
||||||
case NAME: aVariant << wxDataViewIconText( item->GetName(), item->GetBitmap() ); break;
|
case NAME:
|
||||||
|
aVariant << wxDataViewIconText( item->GetName(), item->GetBitmap() );
|
||||||
|
break;
|
||||||
case SHAPE:
|
case SHAPE:
|
||||||
aVariant = getElectricalTypeLabel( static_cast<LABEL_FLAG_SHAPE>( item->GetShape() ) );
|
aVariant = getElectricalTypeLabel( static_cast<LABEL_FLAG_SHAPE>( item->GetShape() ) );
|
||||||
break;
|
break;
|
||||||
|
@ -139,7 +143,9 @@ SHEET_SYNCHRONIZATION_MODEL::TakeItems( wxDataViewItemArray const& aItems )
|
||||||
for( unsigned i = 0; i < m_items.size(); i++ )
|
for( unsigned i = 0; i < m_items.size(); i++ )
|
||||||
{
|
{
|
||||||
if( rowsToBeRemove.find( i ) == rowsToBeRemove.end() )
|
if( rowsToBeRemove.find( i ) == rowsToBeRemove.end() )
|
||||||
|
{
|
||||||
items_remain.push_back( m_items[i] );
|
items_remain.push_back( m_items[i] );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
items_token.push_back( m_items[i] );
|
items_token.push_back( m_items[i] );
|
||||||
|
|
|
@ -40,6 +40,7 @@ class SHEET_SYNCHRONIZATION_NOTIFIER;
|
||||||
class SHEET_SYNCHRONIZATION_AGENT;
|
class SHEET_SYNCHRONIZATION_AGENT;
|
||||||
class SCH_SHEET;
|
class SCH_SHEET;
|
||||||
class SCH_SHEET_PATH;
|
class SCH_SHEET_PATH;
|
||||||
|
|
||||||
class SHEET_SYNCHRONIZATION_MODEL : public wxDataViewVirtualListModel
|
class SHEET_SYNCHRONIZATION_MODEL : public wxDataViewVirtualListModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -70,7 +71,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
SHEET_SYNCHRONIZATION_MODEL( SHEET_SYNCHRONIZATION_AGENT& aAgent, SCH_SHEET* aSheet,
|
SHEET_SYNCHRONIZATION_MODEL( SHEET_SYNCHRONIZATION_AGENT& aAgent, SCH_SHEET* aSheet,
|
||||||
SCH_SHEET_PATH aPath );
|
SCH_SHEET_PATH& aPath );
|
||||||
~SHEET_SYNCHRONIZATION_MODEL() override;
|
~SHEET_SYNCHRONIZATION_MODEL() override;
|
||||||
|
|
||||||
void GetValueByRow( wxVariant& variant, unsigned row, unsigned col ) const override;
|
void GetValueByRow( wxVariant& variant, unsigned row, unsigned col ) const override;
|
||||||
|
@ -82,12 +83,12 @@ public:
|
||||||
void RemoveItems( wxDataViewItemArray const& aItems );
|
void RemoveItems( wxDataViewItemArray const& aItems );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Add a new item, the notifiers are notified
|
* Add a new item, the notifiers are notified.
|
||||||
*/
|
*/
|
||||||
bool AppendNewItem( std::shared_ptr<SHEET_SYNCHRONIZATION_ITEM> aItem );
|
bool AppendNewItem( std::shared_ptr<SHEET_SYNCHRONIZATION_ITEM> aItem );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Just append item to the list, the notifiers are not notified
|
* Just append item to the list, the notifiers are not notified.
|
||||||
*/
|
*/
|
||||||
bool AppendItem( std::shared_ptr<SHEET_SYNCHRONIZATION_ITEM> aItem );
|
bool AppendItem( std::shared_ptr<SHEET_SYNCHRONIZATION_ITEM> aItem );
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ bool SHEET_FILE_CHANGE_NOTIFIER::ShouldIgnore() const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SHEET_FILE_CHANGE_NOTIFIER::Sync()
|
void SHEET_FILE_CHANGE_NOTIFIER::Sync()
|
||||||
{
|
{
|
||||||
m_panel->UpdateForms();
|
m_panel->UpdateForms();
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
class SHEET_SYNCHRONIZATION_MODEL;
|
class SHEET_SYNCHRONIZATION_MODEL;
|
||||||
class PANEL_SYNC_SHEET_PINS;
|
class PANEL_SYNC_SHEET_PINS;
|
||||||
|
|
||||||
class SHEET_SYNCHRONIZATION_NOTIFIER
|
class SHEET_SYNCHRONIZATION_NOTIFIER
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -55,7 +56,7 @@ private:
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Used to sync the modifications between the mutiple instances of a sheet file
|
* Used to sync the modifications between the mutiple instances of a sheet file.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class SHEET_FILE_CHANGE_NOTIFIER : public SHEET_SYNCHRONIZATION_NOTIFIER
|
class SHEET_FILE_CHANGE_NOTIFIER : public SHEET_SYNCHRONIZATION_NOTIFIER
|
||||||
|
|
|
@ -511,8 +511,7 @@ TOOL_ACTION EE_ACTIONS::placeSheetPin( TOOL_ACTION_ARGS()
|
||||||
.Icon( BITMAPS::add_hierar_pin )
|
.Icon( BITMAPS::add_hierar_pin )
|
||||||
.Flags( AF_ACTIVATE ) );
|
.Flags( AF_ACTIVATE ) );
|
||||||
|
|
||||||
TOOL_ACTION EE_ACTIONS::syncSheetPins(
|
TOOL_ACTION EE_ACTIONS::syncSheetPins( TOOL_ACTION_ARGS()
|
||||||
TOOL_ACTION_ARGS()
|
|
||||||
.Name( "eeschema.InteractiveDrawing.syncSheetPins" )
|
.Name( "eeschema.InteractiveDrawing.syncSheetPins" )
|
||||||
.Scope( AS_GLOBAL )
|
.Scope( AS_GLOBAL )
|
||||||
.FriendlyName( _( "Sync Sheet Pins" ) )
|
.FriendlyName( _( "Sync Sheet Pins" ) )
|
||||||
|
@ -520,8 +519,7 @@ TOOL_ACTION EE_ACTIONS::syncSheetPins(
|
||||||
.Icon( BITMAPS::import_hierarchical_label )
|
.Icon( BITMAPS::import_hierarchical_label )
|
||||||
.Flags( AF_ACTIVATE ) );
|
.Flags( AF_ACTIVATE ) );
|
||||||
|
|
||||||
TOOL_ACTION EE_ACTIONS::syncAllSheetsPins(
|
TOOL_ACTION EE_ACTIONS::syncAllSheetsPins( TOOL_ACTION_ARGS()
|
||||||
TOOL_ACTION_ARGS()
|
|
||||||
.Name( "eeschema.InteractiveDrawing.syncAllSheetsPins" )
|
.Name( "eeschema.InteractiveDrawing.syncAllSheetsPins" )
|
||||||
.Scope( AS_GLOBAL )
|
.Scope( AS_GLOBAL )
|
||||||
.FriendlyName( _( "Sync Sheet Pins" ) )
|
.FriendlyName( _( "Sync Sheet Pins" ) )
|
||||||
|
|
|
@ -1584,6 +1584,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
item = createNewSheetPin( sheet, cursorPos );
|
item = createNewSheetPin( sheet, cursorPos );
|
||||||
|
|
||||||
if( m_dialogSyncSheetPin && m_dialogSyncSheetPin->GetPlacementTemplate() )
|
if( m_dialogSyncSheetPin && m_dialogSyncSheetPin->GetPlacementTemplate() )
|
||||||
{
|
{
|
||||||
auto label = static_cast<SCH_HIERLABEL*>(
|
auto label = static_cast<SCH_HIERLABEL*>(
|
||||||
|
@ -1746,7 +1747,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
||||||
if( m_dialogSyncSheetPin && m_dialogSyncSheetPin->GetPlacementTemplate() )
|
if( m_dialogSyncSheetPin && m_dialogSyncSheetPin->GetPlacementTemplate() )
|
||||||
{
|
{
|
||||||
m_dialogSyncSheetPin->EndPlaceItem( nullptr );
|
m_dialogSyncSheetPin->EndPlaceItem( nullptr );
|
||||||
m_dialogSyncSheetPin->Show(true);
|
m_dialogSyncSheetPin->Show( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2562,7 +2563,7 @@ int SCH_DRAWING_TOOLS::SyncSheetsPins( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
VECTOR2I cursorPos = getViewControls()->GetMousePosition();
|
VECTOR2I cursorPos = getViewControls()->GetMousePosition();
|
||||||
|
|
||||||
if( EDA_ITEM* i = nullptr; static_cast<void>(m_selectionTool->SelectPoint( cursorPos, { SCH_SHEET_T }, &i )) , i != nullptr )
|
if( EDA_ITEM* i = nullptr; static_cast<void>(m_selectionTool->SelectPoint( cursorPos, { SCH_SHEET_T }, &i ) ) , i != nullptr )
|
||||||
{
|
{
|
||||||
sheet = dynamic_cast<SCH_SHEET*>( i );
|
sheet = dynamic_cast<SCH_SHEET*>( i );
|
||||||
}
|
}
|
||||||
|
@ -2591,23 +2592,23 @@ int SCH_DRAWING_TOOLS::SyncAllSheetsPins( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
std::vector<SCH_ITEM*> sheetChildren;
|
std::vector<SCH_ITEM*> sheetChildren;
|
||||||
aScene->GetSheets( &sheetChildren );
|
aScene->GetSheets( &sheetChildren );
|
||||||
aVisited.insert(aScene);
|
aVisited.insert( aScene );
|
||||||
|
|
||||||
for( SCH_ITEM* child : sheetChildren)
|
for( SCH_ITEM* child : sheetChildren )
|
||||||
{
|
{
|
||||||
SCH_SHEET_PATH cp = aCurPath;
|
SCH_SHEET_PATH cp = aCurPath;
|
||||||
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( child );
|
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( child );
|
||||||
cp.push_back(sheet);
|
cp.push_back( sheet );
|
||||||
aPaths.push_back( cp );
|
aPaths.push_back( cp );
|
||||||
getSheetChildren(aPaths , sheet->GetScreen() , aVisited ,cp);
|
getSheetChildren( aPaths, sheet->GetScreen(), aVisited, cp );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::list<SCH_SHEET_PATH> sheetPaths;
|
std::list<SCH_SHEET_PATH> sheetPaths;
|
||||||
std::set<SCH_SCREEN*> visited;
|
std::set<SCH_SCREEN*> visited;
|
||||||
SCH_SHEET_PATH current;
|
SCH_SHEET_PATH current;
|
||||||
current.push_back(&m_frame->Schematic().Root());
|
current.push_back( &m_frame->Schematic().Root() );
|
||||||
getSheetChildren(sheetPaths , m_frame->Schematic().Root().GetScreen() ,visited ,current );
|
getSheetChildren( sheetPaths, m_frame->Schematic().Root().GetScreen(), visited, current );
|
||||||
return doSyncSheetsPins( sheetPaths );
|
return doSyncSheetsPins( sheetPaths );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue