7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 19:33:44 +00:00

API: Move locking to the PCB text objects

This commit is contained in:
Jon Evans 2024-11-28 11:48:01 -05:00
parent 523fcc039f
commit 32684decbb
4 changed files with 15 additions and 8 deletions

View File

@ -387,6 +387,7 @@ message BoardText
kiapi.common.types.Text text = 2;
BoardLayer layer = 3;
bool knockout = 4;
kiapi.common.types.LockedState locked = 5;
}
// A board-specific textbox, existing on a board layer
@ -395,6 +396,7 @@ message BoardTextBox
kiapi.common.types.KIID id = 1;
kiapi.common.types.TextBox textbox = 2;
BoardLayer layer = 3;
kiapi.common.types.LockedState locked = 4;
}
// NOTE: There has been some discussion about what to do with pad attributes and properties.

View File

@ -303,7 +303,10 @@ message Text
// kiapi.common.types.KIID id = 1;
kiapi.common.types.Vector2 position = 2;
kiapi.common.types.TextAttributes attributes = 3;
kiapi.common.types.LockedState locked = 4;
// Reserved for future use; base objects don't support locking right nos
//kiapi.common.types.LockedState locked = 4;
string text = 5;
string hyperlink = 6;
}
@ -313,7 +316,10 @@ message TextBox
kiapi.common.types.Vector2 top_left = 2;
kiapi.common.types.Vector2 bottom_right = 3;
kiapi.common.types.TextAttributes attributes = 4;
kiapi.common.types.LockedState locked = 5;
// Reserved for future use; base objects don't support locking right nos
//kiapi.common.types.LockedState locked = 5;
string text = 6;
}

View File

@ -89,6 +89,8 @@ void PCB_TEXT::Serialize( google::protobuf::Any &aContainer ) const
boardText.mutable_id()->set_value( m_Uuid.AsStdString() );
boardText.set_layer( ToProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>( GetLayer() ) );
boardText.set_knockout( IsKnockout() );
boardText.set_locked( IsLocked() ? types::LockedState::LS_LOCKED
: types::LockedState::LS_UNLOCKED );
google::protobuf::Any any;
EDA_TEXT::Serialize( any );
@ -99,9 +101,6 @@ void PCB_TEXT::Serialize( google::protobuf::Any &aContainer ) const
PackVector2( *text->mutable_position(), GetPosition() );
text->set_locked( IsLocked() ? types::LockedState::LS_LOCKED
: types::LockedState::LS_UNLOCKED );
aContainer.PackFrom( boardText );
}
@ -117,6 +116,7 @@ bool PCB_TEXT::Deserialize( const google::protobuf::Any &aContainer )
SetLayer( FromProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>( boardText.layer() ) );
const_cast<KIID&>( m_Uuid ) = KIID( boardText.id().value() );
SetIsKnockout( boardText.knockout() );
SetLocked( boardText.locked() == types::LockedState::LS_LOCKED );
google::protobuf::Any any;
any.PackFrom( boardText.text() );
@ -125,7 +125,6 @@ bool PCB_TEXT::Deserialize( const google::protobuf::Any &aContainer )
const types::Text& text = boardText.text();
SetPosition( UnpackVector2( text.position() ) );
SetLocked( text.locked() == types::LockedState::LS_LOCKED );
return true;
}

View File

@ -71,6 +71,7 @@ void PCB_TEXTBOX::Serialize( google::protobuf::Any &aContainer ) const
types::BoardTextBox boardText;
boardText.set_layer( ToProtoEnum<PCB_LAYER_ID, types::BoardLayer>( GetLayer() ) );
boardText.mutable_id()->set_value( m_Uuid.AsStdString() );
boardText.set_locked( IsLocked() ? LockedState::LS_LOCKED : LockedState::LS_UNLOCKED );
TextBox& text = *boardText.mutable_textbox();
@ -78,7 +79,6 @@ void PCB_TEXTBOX::Serialize( google::protobuf::Any &aContainer ) const
kiapi::common::PackVector2( *text.mutable_bottom_right(), GetEnd() );
text.set_text( GetText().ToStdString() );
//text.set_hyperlink( GetHyperlink().ToStdString() );
text.set_locked( IsLocked() ? LockedState::LS_LOCKED : LockedState::LS_UNLOCKED );
TextAttributes* attrs = text.mutable_attributes();
@ -117,12 +117,12 @@ bool PCB_TEXTBOX::Deserialize( const google::protobuf::Any &aContainer )
const_cast<KIID&>( m_Uuid ) = KIID( boardText.id().value() );
SetLayer( FromProtoEnum<PCB_LAYER_ID, types::BoardLayer>( boardText.layer() ) );
SetLocked( boardText.locked() == kiapi::common::types::LockedState::LS_LOCKED );
const kiapi::common::types::TextBox& text = boardText.textbox();
SetPosition( kiapi::common::UnpackVector2( text.top_left() ) );
SetEnd( kiapi::common::UnpackVector2( text.bottom_right() ) );
SetLocked( text.locked() == kiapi::common::types::LockedState::LS_LOCKED );
SetText( wxString( text.text().c_str(), wxConvUTF8 ) );
//SetHyperlink( wxString::FromUTF8( text.hyperlink() );