diff --git a/common/eda_shape.cpp b/common/eda_shape.cpp index 3339135286..d9d3d56d07 100644 --- a/common/eda_shape.cpp +++ b/common/eda_shape.cpp @@ -628,7 +628,7 @@ void EDA_SHAPE::ShapeGetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector 54 ) + tmp = tmp.Left( 52 ) + wxT( "..." ); + + return tmp; +} + + wxString EDA_TEXT::ShortenedShownText() const { wxString tmp = GetShownText(); diff --git a/common/stroke_params.cpp b/common/stroke_params.cpp index ac60e8c147..444e450b16 100644 --- a/common/stroke_params.cpp +++ b/common/stroke_params.cpp @@ -28,6 +28,7 @@ #include #include #include +#include using namespace STROKEPARAMS_T; @@ -173,7 +174,7 @@ void STROKE_PARAMS::Stroke( const SHAPE* aShape, PLOT_DASH_TYPE aLineStyle, int } -static wxString getLineStyleToken( PLOT_DASH_TYPE aStyle ) +wxString STROKE_PARAMS::GetLineStyleToken( PLOT_DASH_TYPE aStyle ) { wxString token; @@ -191,6 +192,32 @@ static wxString getLineStyleToken( PLOT_DASH_TYPE aStyle ) } +void STROKE_PARAMS::GetMsgPanelInfo( EDA_UNITS aUnits, std::vector& aList, + bool aIncludeStyle, bool aIncludeWidth ) +{ + if( aIncludeStyle ) + { + wxString lineStyle = _( "Default" ); + + for( const std::pair& typeEntry : lineTypeNames ) + { + if( typeEntry.first == GetPlotStyle() ) + { + lineStyle = typeEntry.second.name; + break; + } + } + + aList.emplace_back( _( "Line Style" ), lineStyle ); + } + + if( aIncludeWidth ) + { + aList.emplace_back( _( "Line Width" ), MessageTextFromValue( aUnits, GetWidth() ) ); + } +} + + void STROKE_PARAMS::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel ) const { wxASSERT( aFormatter != nullptr ); @@ -199,13 +226,13 @@ void STROKE_PARAMS::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel ) const { aFormatter->Print( aNestLevel, "(stroke (width %s) (type %s))", FormatInternalUnits(GetWidth() ).c_str(), - TO_UTF8( getLineStyleToken( GetPlotStyle() ) ) ); + TO_UTF8( GetLineStyleToken( GetPlotStyle() ) ) ); } else { aFormatter->Print( aNestLevel, "(stroke (width %s) (type %s) (color %d %d %d %s))", FormatInternalUnits(GetWidth() ).c_str(), - TO_UTF8( getLineStyleToken( GetPlotStyle() ) ), + TO_UTF8( GetLineStyleToken( GetPlotStyle() ) ), KiROUND( GetColor().r * 255.0 ), KiROUND( GetColor().g * 255.0 ), KiROUND( GetColor().b * 255.0 ), @@ -293,3 +320,5 @@ double STROKE_PARAMS_PARSER::parseDouble( const char* aText ) return val; } + + diff --git a/eeschema/lib_textbox.cpp b/eeschema/lib_textbox.cpp index 04597b39a9..c3d3f808ec 100644 --- a/eeschema/lib_textbox.cpp +++ b/eeschema/lib_textbox.cpp @@ -363,15 +363,24 @@ void LIB_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOf void LIB_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) { + EDA_UNITS units = aFrame->GetUserUnits(); + // Don't use GetShownText() here; we want to show the user the variable references - aList.emplace_back( _( "Text Box" ), UnescapeString( GetText() ) ); + aList.emplace_back( _( "Text Box" ), UnescapeString( ShortenedText() ) ); wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) }; int style = IsBold() && IsItalic() ? 3 : IsBold() ? 2 : IsItalic() ? 1 : 0; aList.emplace_back( _( "Style" ), textStyle[style] ); - aList.emplace_back( _( "Text Size" ), MessageTextFromValue( aFrame->GetUserUnits(), - GetTextWidth() ) ); + aList.emplace_back( _( "Text Size" ), MessageTextFromValue( units, GetTextWidth() ) ); + + wxString msg = MessageTextFromValue( units, std::abs( GetEnd().x - GetStart().x ) ); + aList.emplace_back( _( "Box Width" ), msg ); + + msg = MessageTextFromValue( units, std::abs( GetEnd().y - GetStart().y ) ); + aList.emplace_back( _( "Box Height" ), msg ); + + m_stroke.GetMsgPanelInfo( units, aList ); } diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index c66cbaf480..7849a8b08b 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -93,45 +93,6 @@ EDA_ITEM* SCH_LINE::Clone() const } -/* - * Conversion between PLOT_DASH_TYPE values and style names displayed - */ -const std::map lineStyleNames{ - { PLOT_DASH_TYPE::SOLID, "solid" }, - { PLOT_DASH_TYPE::DASH, "dashed" }, - { PLOT_DASH_TYPE::DASHDOT, "dash_dot" }, - { PLOT_DASH_TYPE::DOT, "dotted" }, -}; - - -const char* SCH_LINE::GetLineStyleName( PLOT_DASH_TYPE aStyle ) -{ - auto resultIt = lineStyleNames.find( aStyle ); - - //legacy behavior is to default to dash if there is no name - return resultIt == lineStyleNames.end() ? lineStyleNames.find( PLOT_DASH_TYPE::DASH )->second : - resultIt->second; -} - - -PLOT_DASH_TYPE SCH_LINE::GetLineStyleByName( const wxString& aStyleName ) -{ - PLOT_DASH_TYPE id = PLOT_DASH_TYPE::DEFAULT; // Default style id - - //find the name by value - auto resultIt = std::find_if( lineStyleNames.begin(), lineStyleNames.end(), - [aStyleName]( const auto& it ) - { - return it.second == aStyleName; - } ); - - if( resultIt != lineStyleNames.end() ) - id = resultIt->first; - - return id; -} - - void SCH_LINE::Move( const VECTOR2I& aOffset ) { if( aOffset != VECTOR2I( 0, 0 ) ) @@ -926,12 +887,12 @@ void SCH_LINE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetUserUnits(), aList, true, false ); SCH_CONNECTION* conn = nullptr; diff --git a/eeschema/sch_line.h b/eeschema/sch_line.h index 819b118a08..bd1380cacb 100644 --- a/eeschema/sch_line.h +++ b/eeschema/sch_line.h @@ -149,14 +149,6 @@ public: /// this might be set on the line or inherited from the line's netclass PLOT_DASH_TYPE GetEffectiveLineStyle() const; - /// @return the style name from the style id - /// (mainly to write it in .sch file) - static const char* GetLineStyleName( PLOT_DASH_TYPE aStyle ); - - /// @return the style id from the style name - /// (mainly to read style from .sch file) - static PLOT_DASH_TYPE GetLineStyleByName( const wxString& aStyleName ); - void SetLineColor( const COLOR4D& aColor ); void SetLineColor( const double r, const double g, const double b, const double a ); diff --git a/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp b/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp index 667c12d503..cc4c5bd864 100644 --- a/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp +++ b/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp @@ -804,8 +804,15 @@ SCH_LINE* SCH_LEGACY_PLUGIN::loadWire( LINE_READER& aReader ) else if( buf == T_STYLE ) { parseUnquotedString( buf, aReader, line, &line ); - PLOT_DASH_TYPE style = SCH_LINE::GetLineStyleByName( buf ); - wire->SetLineStyle( style ); + + if( buf == wxT( "solid" ) ) + wire->SetLineStyle( PLOT_DASH_TYPE::SOLID ); + else if( buf == wxT( "dashed" ) ) + wire->SetLineStyle( PLOT_DASH_TYPE::DASH ); + else if( buf == wxT( "dash_dot" ) ) + wire->SetLineStyle( PLOT_DASH_TYPE::DASHDOT ); + else if( buf == wxT( "dotted" ) ) + wire->SetLineStyle( PLOT_DASH_TYPE::DOT ); } else // should be the color parameter. { @@ -1854,7 +1861,7 @@ void SCH_LEGACY_PLUGIN::saveLine( SCH_LINE* aLine ) if( aLine->GetLineStyle() != aLine->GetDefaultStyle() ) m_out->Print( 0, " %s %s", T_STYLE, - SCH_LINE::GetLineStyleName( aLine->GetLineStyle() ) ); + TO_UTF8( STROKE_PARAMS::GetLineStyleToken( aLine->GetLineStyle() ) ) ); if( aLine->GetLineColor() != COLOR4D::UNSPECIFIED ) m_out->Print( 0, " %s", diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 6b10396830..be49a2961c 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -443,7 +443,7 @@ void SCH_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) { + EDA_UNITS units = aFrame->GetUserUnits(); + // Don't use GetShownText() here; we want to show the user the variable references - aList.emplace_back( _( "Text Box" ), UnescapeString( GetText() ) ); + aList.emplace_back( _( "Text Box" ), UnescapeString( ShortenedText() ) ); wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) }; int style = IsBold() && IsItalic() ? 3 : IsBold() ? 2 : IsItalic() ? 1 : 0; aList.emplace_back( _( "Style" ), textStyle[style] ); - aList.emplace_back( _( "Text Size" ), MessageTextFromValue( aFrame->GetUserUnits(), - GetTextWidth() ) ); + aList.emplace_back( _( "Text Size" ), MessageTextFromValue( units, GetTextWidth() ) ); + + wxString msg = MessageTextFromValue( units, std::abs( GetEnd().x - GetStart().x ) ); + aList.emplace_back( _( "Box Width" ), msg ); + + msg = MessageTextFromValue( units, std::abs( GetEnd().y - GetStart().y ) ); + aList.emplace_back( _( "Box Height" ), msg ); + + m_stroke.GetMsgPanelInfo( units, aList ); } diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index c370034db1..148610fe27 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -353,6 +353,7 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent ) { symbol->SetPosition( cursorPos ); m_view->Update( symbol ); + m_frame->SetMsgPanel( symbol ); } else if( symbol && evt->IsAction( &ACTIONS::doDelete ) ) { @@ -575,6 +576,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent ) m_view->ClearPreview(); m_view->AddToPreview( image->Clone() ); m_view->RecacheAllItems(); // Bitmaps are cached in Opengl + m_frame->SetMsgPanel( image ); } else if( image && evt->IsAction( &ACTIONS::doDelete ) ) { @@ -780,6 +782,7 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent ) previewItem->SetPosition( (wxPoint)cursorPos ); m_view->ClearPreview(); m_view->AddToPreview( previewItem->Clone() ); + m_frame->SetMsgPanel( previewItem ); } else if( evt->Category() == TC_COMMAND ) { @@ -1083,6 +1086,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) { m_view->AddToPreview( aChild->Clone() ); } ); + m_frame->SetMsgPanel( item ); }; auto cleanup = @@ -1462,6 +1466,7 @@ int SCH_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) item->CalcEdit( (wxPoint) cursorPos ); m_view->ClearPreview(); m_view->AddToPreview( item->Clone() ); + m_frame->SetMsgPanel( item ); } else if( evt->IsDblClick( BUT_LEFT ) && !item ) { @@ -1650,6 +1655,7 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent ) sizeSheet( sheet, cursorPos ); m_view->ClearPreview(); m_view->AddToPreview( sheet->Clone() ); + m_frame->SetMsgPanel( sheet ); } else if( evt->IsClick( BUT_RIGHT ) ) { diff --git a/include/eda_text.h b/include/eda_text.h index e241ab4729..ddf7e91b7d 100644 --- a/include/eda_text.h +++ b/include/eda_text.h @@ -87,6 +87,11 @@ public: */ virtual const wxString& GetText() const { return m_text; } + /** + * Returns a shortened version (max 54 characters) of the shown text + */ + wxString ShortenedText() const; + /** * Return the string actually shown after processing of the base text. * @@ -96,7 +101,7 @@ public: virtual wxString GetShownText( int aDepth = 0 ) const { return m_shown_text; } /** - * Returns a shortened version (max 15 characters) of the shown text + * Returns a shortened version (max 36 characters) of the shown text */ wxString ShortenedShownText() const; diff --git a/include/stroke_params.h b/include/stroke_params.h index c500a41ac7..b9bd2ee9ec 100644 --- a/include/stroke_params.h +++ b/include/stroke_params.h @@ -32,6 +32,7 @@ #include class STROKE_PARAMS_LEXER; +class MSG_PANEL_ITEM; namespace KIGFX { @@ -111,8 +112,13 @@ public: void Format( OUTPUTFORMATTER* out, int nestLevel ) const; + void GetMsgPanelInfo( EDA_UNITS aUnits, std::vector& aList, + bool aIncludeStyle = true, bool aIncludeWidth = true ); + // Helper functions + static wxString GetLineStyleToken( PLOT_DASH_TYPE aStyle ); + static void Stroke( const SHAPE* aShape, PLOT_DASH_TYPE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS* aRenderSettings, std::function aStroker ); diff --git a/pcbnew/fp_textbox.cpp b/pcbnew/fp_textbox.cpp index e896f73ec2..af8d6fe228 100644 --- a/pcbnew/fp_textbox.cpp +++ b/pcbnew/fp_textbox.cpp @@ -213,8 +213,16 @@ void FP_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorSetAutoPan( false ); m_controls->CaptureCursor( false ); m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); - m_frame->SetMsgPanel( board() ); + + if( selection().Empty() ) + m_frame->SetMsgPanel( board() ); return 0; } @@ -1195,7 +1197,9 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); m_view->Remove( &preview ); - m_frame->SetMsgPanel( board() ); + + if( selection().Empty() ) + m_frame->SetMsgPanel( board() ); return 0; } @@ -1788,7 +1792,9 @@ bool DRAWING_TOOL::drawSegment( const std::string& aTool, PCB_SHAPE** aGraphic, m_view->Remove( &twoPointAsst ); m_view->Remove( &preview ); - m_frame->SetMsgPanel( board() ); + + if( selection().Empty() ) + m_frame->SetMsgPanel( board() ); m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); m_controls->SetAutoPan( false ); @@ -2064,7 +2070,9 @@ bool DRAWING_TOOL::drawArc( const std::string& aTool, PCB_SHAPE** aGraphic, bool preview.Remove( graphic ); m_view->Remove( &arcAsst ); m_view->Remove( &preview ); - m_frame->SetMsgPanel( board() ); + + if( selection().Empty() ) + m_frame->SetMsgPanel( board() ); m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); m_controls->SetAutoPan( false ); diff --git a/pcbnew/tools/pcb_point_editor.cpp b/pcbnew/tools/pcb_point_editor.cpp index f525e0f321..1baeab5687 100644 --- a/pcbnew/tools/pcb_point_editor.cpp +++ b/pcbnew/tools/pcb_point_editor.cpp @@ -650,8 +650,6 @@ int PCB_POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent ) if( m_editPoints ) { getView()->Remove( m_editPoints.get() ); - - finishItem(); m_editPoints.reset(); } @@ -1598,17 +1596,8 @@ void PCB_POINT_EDITOR::updateItem() const } getView()->Update( item ); -} - - -void PCB_POINT_EDITOR::finishItem() -{ - auto item = m_editPoints->GetParent(); - - if( !item ) - return; - // TODO Refill edited zones when KiCad supports auto re-fill + frame()->SetMsgPanel( item ); } diff --git a/pcbnew/tools/pcb_point_editor.h b/pcbnew/tools/pcb_point_editor.h index 022c478aaf..5a0c342524 100644 --- a/pcbnew/tools/pcb_point_editor.h +++ b/pcbnew/tools/pcb_point_editor.h @@ -74,9 +74,6 @@ private: ///< Update item's points with edit points. void updateItem() const; - ///< Apply the last changes to the edited item. - void finishItem(); - /** * Validate a polygon and displays a popup warning if invalid. *