From 890e7b317ce23449d0048686c9ebc9df1d41bada Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20T=C3=B6rcsv=C3=A1ri?= Date: Thu, 4 Jun 2026 09:40:13 +0200 Subject: [PATCH] feat(eeschema): collab apply converters for text, labels, no-connect Extend doApply added-item construction beyond wires: SCH_TEXT, SCH_LABEL / SCH_GLOBALLABEL / SCH_HIERLABEL (position + text + label shape), and SCH_NO_CONNECT. Serialize text (any EDA_TEXT) and label shape in itemToJson. Moving/deleting existing items of any type already worked (generic changed->Move and removed->Remove); this adds their reconstruction on add. Still uncovered: SCH_SYMBOL (needs lib-symbol + fields/orientation) and graphic shapes (SCH_SHAPE). Known issues to fix next: adding text freezes the app; circles (SCH_SHAPE) don't sync; deletes don't apply; wire moves only partially converge. Co-Authored-By: Claude Opus 4.8 (1M context) --- wasm/bindings/eeschema_embind.cpp | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/wasm/bindings/eeschema_embind.cpp b/wasm/bindings/eeschema_embind.cpp index 0803a4e..ab83f97 100644 --- a/wasm/bindings/eeschema_embind.cpp +++ b/wasm/bindings/eeschema_embind.cpp @@ -26,6 +26,9 @@ #include #include #include +#include +#include +#include #include #include @@ -101,6 +104,12 @@ json itemToJson( SCH_ITEM* aItem ) j["layer"] = (int) line->GetLayer(); } + if( EDA_TEXT* txt = dynamic_cast( aItem ) ) + j["text"] = toUtf8( txt->GetText() ); + + if( SCH_LABEL_BASE* lbl = dynamic_cast( aItem ) ) + j["shape"] = (int) lbl->GetShape(); + return j; } @@ -123,6 +132,29 @@ SCH_ITEM* makeItem( const json& j ) { item = new SCH_JUNCTION( VECTOR2I( j.value( "x", 0 ), j.value( "y", 0 ) ) ); } + else if( type == "SCH_NO_CONNECT" ) + { + item = new SCH_NO_CONNECT( VECTOR2I( j.value( "x", 0 ), j.value( "y", 0 ) ) ); + } + else if( type == "SCH_TEXT" ) + { + item = new SCH_TEXT( VECTOR2I( j.value( "x", 0 ), j.value( "y", 0 ) ), + wxString::FromUTF8( j.value( "text", "" ).c_str() ) ); + } + else if( type == "SCH_LABEL" || type == "SCH_GLOBALLABEL" || type == "SCH_HIERLABEL" ) + { + VECTOR2I pos( j.value( "x", 0 ), j.value( "y", 0 ) ); + wxString text = wxString::FromUTF8( j.value( "text", "" ).c_str() ); + + SCH_LABEL_BASE* lbl = ( type == "SCH_LABEL" ) ? (SCH_LABEL_BASE*) new SCH_LABEL( pos, text ) + : ( type == "SCH_GLOBALLABEL" ) ? (SCH_LABEL_BASE*) new SCH_GLOBALLABEL( pos, text ) + : (SCH_LABEL_BASE*) new SCH_HIERLABEL( pos, text ); + + if( j.contains( "shape" ) ) + lbl->SetShape( (LABEL_FLAG_SHAPE) j["shape"].get() ); + + item = lbl; + } if( item ) const_cast( item->m_Uuid ) = KIID( wxString::FromUTF8( j.value( "id", "" ).c_str() ) );