MCPcopy Create free account
hub / github.com/KiCad/kicad-source-mirror / handleGetTextExtents

Method handleGetTextExtents

common/api/api_handler_common.cpp:165–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163
164
165HANDLER_RESULT<types::Box2> API_HANDLER_COMMON::handleGetTextExtents(
166 const HANDLER_CONTEXT<GetTextExtents>& aCtx )
167{
168 EDA_TEXT text( pcbIUScale );
169 google::protobuf::Any any;
170 any.PackFrom( aCtx.Request.text() );
171
172 if( !text.Deserialize( any ) )
173 {
174 ApiResponseStatus e;
175 e.set_status( ApiStatusCode::AS_BAD_REQUEST );
176 e.set_error_message( "Could not decode text in GetTextExtents message" );
177 return tl::unexpected( e );
178 }
179
180 types::Box2 response;
181
182 BOX2I bbox = text.GetTextBox( nullptr );
183 EDA_ANGLE angle = text.GetTextAngle();
184
185 if( !angle.IsZero() )
186 bbox = bbox.GetBoundingBoxRotated( text.GetTextPos(), text.GetTextAngle() );
187
188 response.mutable_position()->set_x_nm( bbox.GetPosition().x );
189 response.mutable_position()->set_y_nm( bbox.GetPosition().y );
190 response.mutable_size()->set_x_nm( bbox.GetSize().x );
191 response.mutable_size()->set_y_nm( bbox.GetSize().y );
192
193 return response;
194}
195
196
197HANDLER_RESULT<GetTextAsShapesResponse> API_HANDLER_COMMON::handleGetTextAsShapes(

Callers

nothing calls this directly

Calls 6

GetTextBoxMethod · 0.80
IsZeroMethod · 0.80
GetBoundingBoxRotatedMethod · 0.80
DeserializeMethod · 0.45
GetPositionMethod · 0.45
GetSizeMethod · 0.45

Tested by

no test coverage detected