API: Improve handling of compound shapes
This commit is contained in:
@@ -44,17 +44,25 @@ message GetTextExtents
|
||||
kiapi.common.types.Text text = 1;
|
||||
}
|
||||
|
||||
message TextOrTextBox
|
||||
{
|
||||
oneof inner {
|
||||
kiapi.common.types.Text text = 1;
|
||||
kiapi.common.types.TextBox textbox = 2;
|
||||
}
|
||||
}
|
||||
|
||||
// Render the given text object(s) as shapes. Depending on whether the text is using
|
||||
// the KiCad stroke font or a custom font, the response will be a compound shape containing
|
||||
// a set of polygons or a set of segments.
|
||||
message GetTextAsShapes
|
||||
{
|
||||
repeated kiapi.common.types.Text text = 1;
|
||||
repeated TextOrTextBox text = 1;
|
||||
}
|
||||
|
||||
message TextWithShapes
|
||||
{
|
||||
kiapi.common.types.Text text = 1;
|
||||
TextOrTextBox text = 1;
|
||||
|
||||
kiapi.common.types.CompoundShape shapes = 2;
|
||||
}
|
||||
|
||||
@@ -404,22 +404,10 @@ message GraphicShape
|
||||
}
|
||||
}
|
||||
|
||||
message CompoundShapeEntry
|
||||
{
|
||||
oneof geometry {
|
||||
GraphicSegmentAttributes segment = 1;
|
||||
GraphicRectangleAttributes rectangle = 2;
|
||||
GraphicArcAttributes arc = 3;
|
||||
GraphicCircleAttributes circle = 4;
|
||||
PolySet polygon = 5;
|
||||
GraphicBezierAttributes bezier = 6;
|
||||
}
|
||||
}
|
||||
|
||||
// A SHAPE_COMPOUND in KiCad
|
||||
message CompoundShape
|
||||
{
|
||||
repeated CompoundShapeEntry shapes = 1;
|
||||
repeated GraphicShape shapes = 1;
|
||||
}
|
||||
|
||||
// The text strings that can be set in a drawing sheet for the title block
|
||||
|
||||
@@ -125,11 +125,21 @@ HANDLER_RESULT<GetTextAsShapesResponse> API_HANDLER_COMMON::handleGetTextAsShape
|
||||
{
|
||||
GetTextAsShapesResponse reply;
|
||||
|
||||
for( const Text& textMsg : aMsg.text() )
|
||||
for( const TextOrTextBox& textMsg : aMsg.text() )
|
||||
{
|
||||
Text dummyText;
|
||||
const Text* textPtr = &textMsg.text();
|
||||
|
||||
if( textMsg.has_textbox() )
|
||||
{
|
||||
dummyText.set_text( textMsg.textbox().text() );
|
||||
dummyText.mutable_attributes()->CopyFrom( textMsg.textbox().attributes() );
|
||||
textPtr = &dummyText;
|
||||
}
|
||||
|
||||
EDA_TEXT text( pcbIUScale );
|
||||
google::protobuf::Any any;
|
||||
any.PackFrom( textMsg );
|
||||
any.PackFrom( *textPtr );
|
||||
|
||||
if( !text.Deserialize( any ) )
|
||||
{
|
||||
@@ -148,7 +158,8 @@ HANDLER_RESULT<GetTextAsShapesResponse> API_HANDLER_COMMON::handleGetTextAsShape
|
||||
{
|
||||
EDA_SHAPE proxy( *subshape );
|
||||
proxy.Serialize( any );
|
||||
any.UnpackTo( entry->mutable_shapes() );
|
||||
GraphicShape* shapeMsg = entry->mutable_shapes()->add_shapes();
|
||||
any.UnpackTo( shapeMsg );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user