diff --git a/eeschema/dialogs/dialog_edit_label.cpp b/eeschema/dialogs/dialog_edit_label.cpp index 26257f5a9a..9fbb2c32bd 100644 --- a/eeschema/dialogs/dialog_edit_label.cpp +++ b/eeschema/dialogs/dialog_edit_label.cpp @@ -102,7 +102,7 @@ const int MAX_TEXTSIZE = INT_MAX; DIALOG_LABEL_EDITOR::DIALOG_LABEL_EDITOR( SCH_EDIT_FRAME* aParent, SCH_TEXT* aTextItem ) : DIALOG_LABEL_EDITOR_BASE( aParent ), m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, false ), - m_netNameValidator() + m_netNameValidator( true ) { m_Parent = aParent; m_CurrentText = aTextItem; @@ -146,6 +146,8 @@ DIALOG_LABEL_EDITOR::DIALOG_LABEL_EDITOR( SCH_EDIT_FRAME* aParent, SCH_TEXT* aTe if( m_CurrentText->Type() != SCH_TEXT_T ) m_valueSingleLine->SetValidator( m_netNameValidator ); + + m_valueCombo->SetValidator( m_netNameValidator ); } SetInitialFocus( m_activeTextCtrl ); diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp index 9bcee5e75d..5617d52831 100644 --- a/eeschema/edit_label.cpp +++ b/eeschema/edit_label.cpp @@ -35,6 +35,9 @@ #include #include #include + +#include + #include "invoke_sch_dialog.h" static PINSHEETLABEL_SHAPE lastGlobalLabelShape = NET_INPUT; @@ -42,12 +45,27 @@ static int lastTextOrientation = 0; static bool lastTextBold = false; static bool lastTextItalic = false; +static std::deque> queuedTexts; + +SCH_TEXT* SCH_EDIT_FRAME::GetNextNewText() +{ + if( queuedTexts.empty() ) + return nullptr; + + auto next_text = std::move( queuedTexts.front() ); + queuedTexts.pop_front(); + + return next_text.release(); +} + SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( int aType ) { wxPoint cursorPos = (wxPoint) GetCanvas()->GetViewControls()->GetCursorPosition(); SCH_TEXT* textItem = nullptr; + queuedTexts.clear(); + switch( aType ) { case LAYER_NOTES: @@ -85,6 +103,19 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( int aType ) return nullptr; } + if( aType != LAYER_NOTES ) + { + wxStringTokenizer tok( textItem->GetText(), wxDEFAULT_DELIMITERS, wxTOKEN_STRTOK ); + textItem->SetText( tok.GetNextToken() ); + + while( tok.HasMoreTokens() ) + { + std::unique_ptr nextitem( static_cast( textItem->Clone() ) ); + nextitem->SetText( tok.GetNextToken() ); + queuedTexts.push_back( std::move( nextitem ) ); + } + } + lastTextBold = textItem->IsBold(); lastTextItalic = textItem->IsItalic(); lastTextOrientation = textItem->GetLabelSpinStyle(); diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index b217b13afd..10f01c61b5 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -675,6 +675,12 @@ public: SCH_JUNCTION* AddJunction( const wxPoint& aPos, bool aAppendToUndo = false, bool aFinal = true ); + /** + * Gets the next queued text item + * @return next SCH_TEXT* or nullptr if empty + */ + SCH_TEXT* GetNextNewText(); + SCH_TEXT* CreateNewText( int aType ); /** diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index c25205a443..4ad013b45b 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -126,6 +126,7 @@ SCH_TEXT::SCH_TEXT( const SCH_TEXT& aText ) : m_shape = aText.m_shape; m_isDangling = aText.m_isDangling; m_spin_style = aText.m_spin_style; + m_connectionType = aText.m_connectionType; } diff --git a/eeschema/sch_validators.cpp b/eeschema/sch_validators.cpp index 7f48fec6b1..92d0725f61 100644 --- a/eeschema/sch_validators.cpp +++ b/eeschema/sch_validators.cpp @@ -144,12 +144,19 @@ bool SCH_FIELD_VALIDATOR::Validate( wxWindow *aParent ) SCH_NETNAME_VALIDATOR::SCH_NETNAME_VALIDATOR( wxString *aVal ) : - wxValidator() + wxValidator(), m_allowSpaces( false ) { } -SCH_NETNAME_VALIDATOR::SCH_NETNAME_VALIDATOR( const SCH_NETNAME_VALIDATOR& aValidator ) +SCH_NETNAME_VALIDATOR::SCH_NETNAME_VALIDATOR( const SCH_NETNAME_VALIDATOR& aValidator ) : + m_allowSpaces( aValidator.m_allowSpaces ) +{ +} + + +SCH_NETNAME_VALIDATOR::SCH_NETNAME_VALIDATOR( bool aAllowSpaces ) : + wxValidator(), m_allowSpaces( aAllowSpaces ) { } @@ -215,7 +222,7 @@ wxString SCH_NETNAME_VALIDATOR::IsValid( const wxString& str ) const if( str.Contains( '\r' ) || str.Contains( '\n' ) ) return _( "Signal names cannot contain CR or LF characters" ); - if( str.Contains( ' ' ) || str.Contains( '\t' ) ) + if( !m_allowSpaces && ( str.Contains( ' ' ) || str.Contains( '\t' ) ) ) return _( "Signal names cannot contain spaces" ); return wxString(); diff --git a/eeschema/sch_validators.h b/eeschema/sch_validators.h index ddbc11ef11..8a9e0c392a 100644 --- a/eeschema/sch_validators.h +++ b/eeschema/sch_validators.h @@ -72,8 +72,14 @@ class SCH_NETNAME_VALIDATOR : public wxValidator public: SCH_NETNAME_VALIDATOR( wxString *aVal = nullptr ); + SCH_NETNAME_VALIDATOR( bool aAllowSpaces ); + SCH_NETNAME_VALIDATOR( const SCH_NETNAME_VALIDATOR& aValidator ); + void SetAllowSpaces( bool aAllowSpaces = true ) { m_allowSpaces = aAllowSpaces; } + + bool GetAllowSpaces() const { return m_allowSpaces; } + bool Copy( const SCH_NETNAME_VALIDATOR& val ); virtual wxObject* Clone() const override { return new SCH_NETNAME_VALIDATOR( *this ); } @@ -91,6 +97,8 @@ protected: // returns the error message if the contents of 'val' are invalid virtual wxString IsValid( const wxString& aVal ) const; +private: + bool m_allowSpaces; }; #endif // _SCH_VALIDATORS_H_ diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index c20984a959..a62450f1fc 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -568,9 +568,20 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) { item->ClearFlags( IS_MOVED ); m_frame->AddItemToScreenAndUndoList( (SCH_ITEM*) item ); - item = nullptr; + item = m_frame->GetNextNewText(); - m_view->ClearPreview(); + if( item ) + { + m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); + item->SetFlags( IS_NEW | IS_MOVED ); + m_view->ClearPreview(); + m_view->AddToPreview( item->Clone() ); + m_selectionTool->AddItemToSel( item ); + } + else + { + m_view->ClearPreview(); + } } } else if( evt->IsClick( BUT_RIGHT ) )