Coding conventions.
This commit is contained in:
parent
700edb95e3
commit
ce0affedb1
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
* Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
||||||
* Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -30,7 +30,6 @@
|
||||||
#include <schematic.h>
|
#include <schematic.h>
|
||||||
#include <tool/tool_manager.h>
|
#include <tool/tool_manager.h>
|
||||||
#include <tools/ee_actions.h>
|
#include <tools/ee_actions.h>
|
||||||
#include <sch_sheet_path.h>
|
|
||||||
|
|
||||||
#include <hierarch.h>
|
#include <hierarch.h>
|
||||||
#include <kiface_base.h>
|
#include <kiface_base.h>
|
||||||
|
@ -42,12 +41,12 @@
|
||||||
/**
|
/**
|
||||||
* Store an SCH_SHEET_PATH of each sheet in hierarchy.
|
* Store an SCH_SHEET_PATH of each sheet in hierarchy.
|
||||||
*/
|
*/
|
||||||
class TreeItemData : public wxTreeItemData
|
class TREE_ITEM_DATA : public wxTreeItemData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SCH_SHEET_PATH m_SheetPath;
|
SCH_SHEET_PATH m_SheetPath;
|
||||||
|
|
||||||
TreeItemData( SCH_SHEET_PATH& sheet ) : wxTreeItemData()
|
TREE_ITEM_DATA( SCH_SHEET_PATH& sheet ) : wxTreeItemData()
|
||||||
{
|
{
|
||||||
m_SheetPath = sheet;
|
m_SheetPath = sheet;
|
||||||
}
|
}
|
||||||
|
@ -61,14 +60,15 @@ wxIMPLEMENT_ABSTRACT_CLASS( HIERARCHY_TREE, wxTreeCtrl );
|
||||||
|
|
||||||
int HIERARCHY_TREE::OnCompareItems( const wxTreeItemId& item1, const wxTreeItemId& item2 )
|
int HIERARCHY_TREE::OnCompareItems( const wxTreeItemId& item1, const wxTreeItemId& item2 )
|
||||||
{
|
{
|
||||||
SCH_SHEET_PATH* item1Path = &static_cast<TreeItemData*>( GetItemData( item1 ) )->m_SheetPath;
|
SCH_SHEET_PATH* item1Path = &static_cast<TREE_ITEM_DATA*>( GetItemData( item1 ) )->m_SheetPath;
|
||||||
SCH_SHEET_PATH* item2Path = &static_cast<TreeItemData*>( GetItemData( item2 ) )->m_SheetPath;
|
SCH_SHEET_PATH* item2Path = &static_cast<TREE_ITEM_DATA*>( GetItemData( item2 ) )->m_SheetPath;
|
||||||
|
|
||||||
return item1Path->ComparePageNum( *item2Path );
|
return item1Path->ComparePageNum( *item2Path );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HIERARCHY_NAVIG_PANEL::HIERARCHY_NAVIG_PANEL( SCH_EDIT_FRAME* aParent ) : WX_PANEL( aParent )
|
HIERARCHY_NAVIG_PANEL::HIERARCHY_NAVIG_PANEL( SCH_EDIT_FRAME* aParent ) :
|
||||||
|
WX_PANEL( aParent )
|
||||||
{
|
{
|
||||||
wxASSERT( dynamic_cast<SCH_EDIT_FRAME*>( aParent ) );
|
wxASSERT( dynamic_cast<SCH_EDIT_FRAME*>( aParent ) );
|
||||||
|
|
||||||
|
@ -81,8 +81,8 @@ HIERARCHY_NAVIG_PANEL::HIERARCHY_NAVIG_PANEL( SCH_EDIT_FRAME* aParent ) : WX_PAN
|
||||||
// Make an image list containing small icons
|
// Make an image list containing small icons
|
||||||
// All icons are expected having the same size.
|
// All icons are expected having the same size.
|
||||||
wxBitmap tree_nosel_bm( KiBitmap( BITMAPS::tree_nosel ) );
|
wxBitmap tree_nosel_bm( KiBitmap( BITMAPS::tree_nosel ) );
|
||||||
wxImageList* imageList =
|
wxImageList* imageList = new wxImageList( tree_nosel_bm.GetWidth(), tree_nosel_bm.GetHeight(),
|
||||||
new wxImageList( tree_nosel_bm.GetWidth(), tree_nosel_bm.GetHeight(), true, 2 );
|
true, 2 );
|
||||||
|
|
||||||
imageList->Add( tree_nosel_bm );
|
imageList->Add( tree_nosel_bm );
|
||||||
imageList->Add( KiBitmap( BITMAPS::tree_sel ) );
|
imageList->Add( KiBitmap( BITMAPS::tree_sel ) );
|
||||||
|
@ -123,7 +123,7 @@ void HIERARCHY_NAVIG_PANEL::buildHierarchyTree( SCH_SHEET_PATH* aList, const wxT
|
||||||
wxString sheetName = formatPageString( sheet->GetFields()[SHEETNAME].GetShownText(),
|
wxString sheetName = formatPageString( sheet->GetFields()[SHEETNAME].GetShownText(),
|
||||||
sheet->GetPageNumber( *aList ) );
|
sheet->GetPageNumber( *aList ) );
|
||||||
wxTreeItemId child = m_tree->AppendItem( aParent, sheetName, 0, 1 );
|
wxTreeItemId child = m_tree->AppendItem( aParent, sheetName, 0, 1 );
|
||||||
m_tree->SetItemData( child, new TreeItemData( *aList ) );
|
m_tree->SetItemData( child, new TREE_ITEM_DATA( *aList ) );
|
||||||
|
|
||||||
buildHierarchyTree( aList, child );
|
buildHierarchyTree( aList, child );
|
||||||
aList->pop_back();
|
aList->pop_back();
|
||||||
|
@ -150,7 +150,8 @@ void HIERARCHY_NAVIG_PANEL::UpdateHierarchySelection()
|
||||||
{
|
{
|
||||||
wxCHECK_RET( id.IsOk(), wxT( "Invalid tree item" ) );
|
wxCHECK_RET( id.IsOk(), wxT( "Invalid tree item" ) );
|
||||||
|
|
||||||
TreeItemData* itemData = static_cast<TreeItemData*>( m_tree->GetItemData( id ) );
|
TREE_ITEM_DATA* itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( id ) );
|
||||||
|
|
||||||
if( itemData->m_SheetPath == m_frame->GetCurrentSheet() )
|
if( itemData->m_SheetPath == m_frame->GetCurrentSheet() )
|
||||||
{
|
{
|
||||||
m_tree->EnsureVisible( id );
|
m_tree->EnsureVisible( id );
|
||||||
|
@ -159,6 +160,7 @@ void HIERARCHY_NAVIG_PANEL::UpdateHierarchySelection()
|
||||||
|
|
||||||
wxTreeItemIdValue cookie;
|
wxTreeItemIdValue cookie;
|
||||||
wxTreeItemId child = m_tree->GetFirstChild( id, cookie );
|
wxTreeItemId child = m_tree->GetFirstChild( id, cookie );
|
||||||
|
|
||||||
while( child.IsOk() )
|
while( child.IsOk() )
|
||||||
{
|
{
|
||||||
selectSheet( child );
|
selectSheet( child );
|
||||||
|
@ -201,7 +203,7 @@ void HIERARCHY_NAVIG_PANEL::UpdateHierarchyTree()
|
||||||
|
|
||||||
wxTreeItemId root = m_tree->AddRoot( getRootString(), 0, 1 );
|
wxTreeItemId root = m_tree->AddRoot( getRootString(), 0, 1 );
|
||||||
m_tree->SetItemBold( root, true );
|
m_tree->SetItemBold( root, true );
|
||||||
m_tree->SetItemData( root, new TreeItemData( m_list ) );
|
m_tree->SetItemData( root, new TREE_ITEM_DATA( m_list ) );
|
||||||
|
|
||||||
buildHierarchyTree( &m_list, root );
|
buildHierarchyTree( &m_list, root );
|
||||||
UpdateHierarchySelection();
|
UpdateHierarchySelection();
|
||||||
|
@ -224,7 +226,7 @@ void HIERARCHY_NAVIG_PANEL::UpdateHierarchyTree()
|
||||||
void HIERARCHY_NAVIG_PANEL::onSelectSheetPath( wxTreeEvent& event )
|
void HIERARCHY_NAVIG_PANEL::onSelectSheetPath( wxTreeEvent& event )
|
||||||
{
|
{
|
||||||
wxTreeItemId itemSel = m_tree->GetSelection();
|
wxTreeItemId itemSel = m_tree->GetSelection();
|
||||||
TreeItemData* itemData = static_cast<TreeItemData*>( m_tree->GetItemData( itemSel ) );
|
TREE_ITEM_DATA* itemData = static_cast<TREE_ITEM_DATA*>( m_tree->GetItemData( itemSel ) );
|
||||||
|
|
||||||
SetCursor( wxCURSOR_ARROWWAIT );
|
SetCursor( wxCURSOR_ARROWWAIT );
|
||||||
m_frame->GetToolManager()->RunAction( EE_ACTIONS::changeSheet, true, &itemData->m_SheetPath );
|
m_frame->GetToolManager()->RunAction( EE_ACTIONS::changeSheet, true, &itemData->m_SheetPath );
|
||||||
|
|
|
@ -108,11 +108,12 @@ private:
|
||||||
*/
|
*/
|
||||||
wxString formatPageString( const wxString& aName, const wxString& aPage );
|
wxString formatPageString( const wxString& aName, const wxString& aPage );
|
||||||
|
|
||||||
|
private:
|
||||||
SCH_SHEET_PATH m_list;
|
SCH_SHEET_PATH m_list;
|
||||||
SCH_EDIT_FRAME* m_frame;
|
SCH_EDIT_FRAME* m_frame;
|
||||||
HIERARCHY_TREE* m_tree;
|
HIERARCHY_TREE* m_tree;
|
||||||
|
|
||||||
bool m_events_bound;
|
bool m_events_bound;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // HIERARCH_H
|
#endif // HIERARCH_H
|
||||||
|
|
|
@ -55,7 +55,8 @@ class SCH_SHEET : public SCH_ITEM
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SCH_SHEET( EDA_ITEM* aParent = nullptr, const VECTOR2I& aPos = VECTOR2I( 0, 0 ),
|
SCH_SHEET( EDA_ITEM* aParent = nullptr, const VECTOR2I& aPos = VECTOR2I( 0, 0 ),
|
||||||
wxSize aSize = wxSize( schIUScale.MilsToIU( MIN_SHEET_WIDTH ), schIUScale.MilsToIU( MIN_SHEET_HEIGHT ) ),
|
wxSize aSize = wxSize( schIUScale.MilsToIU( MIN_SHEET_WIDTH ),
|
||||||
|
schIUScale.MilsToIU( MIN_SHEET_HEIGHT ) ),
|
||||||
FIELDS_AUTOPLACED aAutoplaceFields = FIELDS_AUTOPLACED_AUTO );
|
FIELDS_AUTOPLACED aAutoplaceFields = FIELDS_AUTOPLACED_AUTO );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -169,11 +170,7 @@ public:
|
||||||
void AddPin( SCH_SHEET_PIN* aSheetPin );
|
void AddPin( SCH_SHEET_PIN* aSheetPin );
|
||||||
|
|
||||||
std::vector<SCH_SHEET_PIN*>& GetPins() { return m_pins; }
|
std::vector<SCH_SHEET_PIN*>& GetPins() { return m_pins; }
|
||||||
|
const std::vector<SCH_SHEET_PIN*>& GetPins() const { return m_pins; }
|
||||||
const std::vector<SCH_SHEET_PIN*>& GetPins() const
|
|
||||||
{
|
|
||||||
return m_pins;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove \a aSheetPin from the sheet.
|
* Remove \a aSheetPin from the sheet.
|
||||||
|
@ -461,14 +458,16 @@ private:
|
||||||
|
|
||||||
friend class SCH_SHEET_PIN;
|
friend class SCH_SHEET_PIN;
|
||||||
|
|
||||||
SCH_SCREEN* m_screen; // Screen that contains the physical data for the sheet. In
|
private:
|
||||||
// complex hierarchies multiple sheets can share a common screen.
|
SCH_SCREEN* m_screen; // Screen that contains the physical data for the
|
||||||
|
// sheet. In complex hierarchies multiple sheets
|
||||||
|
// can share a common screen.
|
||||||
|
|
||||||
std::vector<SCH_SHEET_PIN*> m_pins; // The list of sheet connection points.
|
std::vector<SCH_SHEET_PIN*> m_pins; // The list of sheet connection points.
|
||||||
std::vector<SCH_FIELD> m_fields;
|
std::vector<SCH_FIELD> m_fields;
|
||||||
|
|
||||||
VECTOR2I m_pos; // The position of the sheet.
|
VECTOR2I m_pos; // The position of the sheet.
|
||||||
wxSize m_size; // The size of the sheet.
|
wxSize m_size; // The size of the sheet.
|
||||||
int m_borderWidth;
|
int m_borderWidth;
|
||||||
KIGFX::COLOR4D m_borderColor;
|
KIGFX::COLOR4D m_borderColor;
|
||||||
KIGFX::COLOR4D m_backgroundColor;
|
KIGFX::COLOR4D m_backgroundColor;
|
||||||
|
|
|
@ -103,7 +103,6 @@ struct SCH_SHEET_INSTANCE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
class wxFindReplaceData;
|
|
||||||
class EDA_ITEM;
|
class EDA_ITEM;
|
||||||
class SCH_SHEET;
|
class SCH_SHEET;
|
||||||
class SCH_SCREEN;
|
class SCH_SCREEN;
|
||||||
|
|
Loading…
Reference in New Issue