Run AutoAutoplaceFields() in SCH_SHEET constructor
A constructor should create a fully initialized object.
This commit is contained in:
parent
75d750a3cb
commit
2e1862de1c
|
@ -84,17 +84,18 @@ const wxString SCH_SHEET::GetDefaultFieldName( int aFieldNdx, bool aTranslated )
|
|||
}
|
||||
|
||||
|
||||
SCH_SHEET::SCH_SHEET( EDA_ITEM* aParent, const wxPoint& pos ) :
|
||||
SCH_ITEM( aParent, SCH_SHEET_T )
|
||||
SCH_SHEET::SCH_SHEET( EDA_ITEM* aParent, const wxPoint& aPos, wxSize aSize,
|
||||
FIELDS_AUTOPLACED aAutoplaceFields ) :
|
||||
SCH_ITEM( aParent, SCH_SHEET_T )
|
||||
{
|
||||
m_layer = LAYER_SHEET;
|
||||
m_pos = pos;
|
||||
m_size = wxSize( Mils2iu( MIN_SHEET_WIDTH ), Mils2iu( MIN_SHEET_HEIGHT ) );
|
||||
m_pos = aPos;
|
||||
m_size = aSize;
|
||||
m_screen = nullptr;
|
||||
|
||||
for( int i = 0; i < SHEET_MANDATORY_FIELDS; ++i )
|
||||
{
|
||||
m_fields.emplace_back( pos, i, this, GetDefaultFieldName( i ) );
|
||||
m_fields.emplace_back( aPos, i, this, GetDefaultFieldName( i ) );
|
||||
m_fields.back().SetVisible( true );
|
||||
|
||||
if( i == SHEETNAME )
|
||||
|
@ -105,7 +106,8 @@ SCH_SHEET::SCH_SHEET( EDA_ITEM* aParent, const wxPoint& pos ) :
|
|||
m_fields.back().SetLayer( LAYER_SHEETFIELDS );
|
||||
}
|
||||
|
||||
m_fieldsAutoplaced = FIELDS_AUTOPLACED_AUTO;
|
||||
m_fieldsAutoplaced = aAutoplaceFields;
|
||||
AutoAutoplaceFields( nullptr );
|
||||
|
||||
m_borderWidth = 0;
|
||||
m_borderColor = COLOR4D::UNSPECIFIED;
|
||||
|
|
|
@ -54,7 +54,9 @@ enum SHEET_FIELD_TYPE
|
|||
class SCH_SHEET : public SCH_ITEM
|
||||
{
|
||||
public:
|
||||
SCH_SHEET( EDA_ITEM* aParent = nullptr, const wxPoint& pos = wxPoint( 0, 0 ) );
|
||||
SCH_SHEET( EDA_ITEM* aParent = nullptr, const wxPoint& aPos = wxPoint( 0, 0 ),
|
||||
wxSize aSize = wxSize( Mils2iu( MIN_SHEET_WIDTH ), Mils2iu( MIN_SHEET_HEIGHT ) ),
|
||||
FIELDS_AUTOPLACED aAutoplaceFields = FIELDS_AUTOPLACED_AUTO );
|
||||
|
||||
/**
|
||||
* Copy \a aSheet into a new object. All sheet pins are copied as is except and
|
||||
|
|
|
@ -63,19 +63,19 @@ static SCH_ITEM* Instatiate( KICAD_T aType, SCH_SHEET* sheet )
|
|||
|
||||
switch( aType )
|
||||
{
|
||||
case SCH_MARKER_T: return nullptr;
|
||||
case SCH_JUNCTION_T: return new SCH_JUNCTION();
|
||||
case SCH_NO_CONNECT_T: return new SCH_NO_CONNECT();
|
||||
case SCH_MARKER_T: return nullptr;
|
||||
case SCH_JUNCTION_T: return new SCH_JUNCTION();
|
||||
case SCH_NO_CONNECT_T: return new SCH_NO_CONNECT();
|
||||
case SCH_BUS_WIRE_ENTRY_T: return new SCH_BUS_WIRE_ENTRY();
|
||||
case SCH_BUS_BUS_ENTRY_T: return new SCH_BUS_BUS_ENTRY();
|
||||
case SCH_LINE_T: return new SCH_LINE();
|
||||
case SCH_BITMAP_T: return new SCH_BITMAP();
|
||||
case SCH_TEXT_T: return new SCH_TEXT( wxPoint( 0, 0 ), "test text" );
|
||||
case SCH_LABEL_T: return new SCH_LABEL( wxPoint( 0, 0 ), "test label" );
|
||||
case SCH_GLOBAL_LABEL_T: return new SCH_GLOBALLABEL();
|
||||
case SCH_HIER_LABEL_T: return new SCH_HIERLABEL();
|
||||
case SCH_FIELD_T: return new SCH_FIELD( wxPoint( 0, 0 ), 0, nullptr );
|
||||
case SCH_SYMBOL_T: return new SCH_SYMBOL();
|
||||
case SCH_BUS_BUS_ENTRY_T: return new SCH_BUS_BUS_ENTRY();
|
||||
case SCH_LINE_T: return new SCH_LINE();
|
||||
case SCH_BITMAP_T: return new SCH_BITMAP();
|
||||
case SCH_TEXT_T: return new SCH_TEXT( wxPoint( 0, 0 ), "test text" );
|
||||
case SCH_LABEL_T: return new SCH_LABEL( wxPoint( 0, 0 ), "test label" );
|
||||
case SCH_GLOBAL_LABEL_T: return new SCH_GLOBALLABEL();
|
||||
case SCH_HIER_LABEL_T: return new SCH_HIERLABEL();
|
||||
case SCH_FIELD_T: return new SCH_FIELD( wxPoint( 0, 0 ), 0, nullptr );
|
||||
case SCH_SYMBOL_T: return new SCH_SYMBOL();
|
||||
|
||||
case SCH_SHEET_PIN_T:
|
||||
// XXX (?): Sheet pins currently have to have their initial positions calculated manually.
|
||||
|
@ -84,20 +84,10 @@ static SCH_ITEM* Instatiate( KICAD_T aType, SCH_SHEET* sheet )
|
|||
wxPoint( sheet->GetPosition().x, sheet->GetPosition().y + Millimeter2iu( 40 ) ),
|
||||
"test pin" );
|
||||
|
||||
case SCH_SHEET_T:
|
||||
{
|
||||
SCH_SHEET* sheet = new SCH_SHEET();
|
||||
sheet->SetSize( wxSize( Millimeter2iu( 100 ), Millimeter2iu( 50 ) ) );
|
||||
|
||||
// XXX (?): Sheet fields currently have to be positioned with an additional method call.
|
||||
sheet->AutoplaceFields( nullptr, false );
|
||||
return sheet;
|
||||
}
|
||||
|
||||
case SCH_SHEET_T: return new SCH_SHEET();
|
||||
case SCH_PIN_T:
|
||||
case SCHEMATIC_T:
|
||||
// TODO
|
||||
return nullptr;
|
||||
|
||||
case SCHEMATIC_T: // You can't rotate or mirror a schematic object.
|
||||
|
||||
// `LIB_ITEM`s aren't handled in this module.
|
||||
case LIB_SYMBOL_T:
|
||||
|
|
Loading…
Reference in New Issue