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) <noreply@anthropic.com>
This commit is contained in:
parent
b5b1a0ac05
commit
890e7b317c
1 changed files with 32 additions and 0 deletions
|
|
@ -26,6 +26,9 @@
|
|||
#include <sch_item.h>
|
||||
#include <sch_line.h>
|
||||
#include <sch_junction.h>
|
||||
#include <sch_no_connect.h>
|
||||
#include <sch_text.h>
|
||||
#include <sch_label.h>
|
||||
#include <sch_screen.h>
|
||||
#include <sch_sheet_path.h>
|
||||
|
||||
|
|
@ -101,6 +104,12 @@ json itemToJson( SCH_ITEM* aItem )
|
|||
j["layer"] = (int) line->GetLayer();
|
||||
}
|
||||
|
||||
if( EDA_TEXT* txt = dynamic_cast<EDA_TEXT*>( aItem ) )
|
||||
j["text"] = toUtf8( txt->GetText() );
|
||||
|
||||
if( SCH_LABEL_BASE* lbl = dynamic_cast<SCH_LABEL_BASE*>( 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<int>() );
|
||||
|
||||
item = lbl;
|
||||
}
|
||||
|
||||
if( item )
|
||||
const_cast<KIID&>( item->m_Uuid ) = KIID( wxString::FromUTF8( j.value( "id", "" ).c_str() ) );
|
||||
|
|
|
|||
Loading…
Reference in a new issue