From 642938455ed45e4cee738081567c615b40631048 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 9 Oct 2023 21:55:07 +0100 Subject: [PATCH] Add status popup for meander placer. --- pcbnew/generators/pcb_generator_meanders.cpp | 48 +++++++++++++++++++- pcbnew/tools/drawing_tool.cpp | 23 ++++++---- pcbnew/tools/drawing_tool.h | 3 ++ 3 files changed, 63 insertions(+), 11 deletions(-) diff --git a/pcbnew/generators/pcb_generator_meanders.cpp b/pcbnew/generators/pcb_generator_meanders.cpp index ddb21c6f02..ba8eb1c7b9 100644 --- a/pcbnew/generators/pcb_generator_meanders.cpp +++ b/pcbnew/generators/pcb_generator_meanders.cpp @@ -31,8 +31,11 @@ #include #include #include +#include #include +#include +#include #include #include #include @@ -52,6 +55,7 @@ #include #include #include +#include #include @@ -207,6 +211,38 @@ public: bool baselineValid() { return m_baseLine && m_baseLine->PointCount() > 1; } + static PCB_GENERATOR_MEANDERS* CreateNew( PCB_BASE_EDIT_FRAME* aFrame, BOARD_ITEM* aStartItem ) + { + BOARD* board = aStartItem->GetBoard(); + PCB_LAYER_ID layer = aStartItem->GetLayer(); + PCB_GENERATOR_MEANDERS* meander = new PCB_GENERATOR_MEANDERS( board, layer ); + + // TODO set mode to diff-pair if we find a matching net for aSourceItem + + std::shared_ptr& drcEngine = board->GetDesignSettings().m_DRCEngine; + DRC_CONSTRAINT constraint; + + constraint = drcEngine->EvalRules( LENGTH_CONSTRAINT, aStartItem, nullptr, + ToLAYER_ID( layer ) ); + + if( constraint.IsNull() ) + { + WX_UNIT_ENTRY_DIALOG dlg( aFrame, _( "Place Meander" ), _( "Target length:" ), + 100 * PCB_IU_PER_MM ); + + if( dlg.ShowModal() != wxID_OK ) + return nullptr; + + meander->m_targetLength = dlg.GetValue(); + } + else + { + meander->m_targetLength = constraint.GetValue().Opt(); + } + + return meander; + } + void EditStart( GENERATOR_TOOL* aTool, BOARD* aBoard, PCB_BASE_EDIT_FRAME* aFrame, BOARD_COMMIT* aCommit ) override { @@ -1083,8 +1119,7 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent ) generatorTool->HighlightNet( nullptr ); m_frame->SetActiveLayer( m_pickerItem->GetLayer() ); - - m_meander = new PCB_GENERATOR_MEANDERS( m_board, m_pickerItem->GetLayer() ); + m_meander = PCB_GENERATOR_MEANDERS::CreateNew( m_frame, m_pickerItem ); int dummyDist; int dummyClearance = std::numeric_limits::max() / 2; @@ -1153,6 +1188,12 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent ) { m_meander->EditStart( generatorTool, m_board, m_frame, nullptr ); m_meander->Update( generatorTool, m_board, m_frame, nullptr ); + + m_statusPopup->Popup(); + canvas()->SetStatusPopup( m_statusPopup.get() ); + + m_statusPopup->UpdateStatus( generatorTool->Router() ); + m_statusPopup->Move( KIPLATFORM::UI::GetMousePosition() + wxPoint( 20, 20 ) ); } } } ); @@ -1176,6 +1217,9 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent ) { GENERATOR_TOOL* generatorTool = m_toolMgr->GetTool(); + canvas()->SetStatusPopup( nullptr ); + m_statusPopup->Hide(); + generatorTool->HighlightNet( nullptr ); // Ensure the cursor gets changed & updated diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index d9d7d7154c..4ee2f8c83e 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -163,15 +164,17 @@ protected: DRAWING_TOOL::DRAWING_TOOL() : - PCB_TOOL_BASE( "pcbnew.InteractiveDrawing" ), - m_view( nullptr ), - m_controls( nullptr ), - m_board( nullptr ), - m_frame( nullptr ), - m_mode( MODE::NONE ), - m_inDrawingTool( false ), - m_layer( UNDEFINED_LAYER ), - m_stroke( 1, PLOT_DASH_TYPE::DEFAULT, COLOR4D::UNSPECIFIED ) + PCB_TOOL_BASE( "pcbnew.InteractiveDrawing" ), + m_view( nullptr ), + m_controls( nullptr ), + m_board( nullptr ), + m_frame( nullptr ), + m_mode( MODE::NONE ), + m_inDrawingTool( false ), + m_layer( UNDEFINED_LAYER ), + m_stroke( 1, PLOT_DASH_TYPE::DEFAULT, COLOR4D::UNSPECIFIED ), + m_pickerItem( nullptr ), + m_meander( nullptr ) { } @@ -287,6 +290,8 @@ void DRAWING_TOOL::Reset( RESET_REASON aReason ) m_textAttrs.m_Halign = GR_TEXT_H_ALIGN_LEFT; m_textAttrs.m_Valign = GR_TEXT_V_ALIGN_TOP; + m_statusPopup = std::make_unique( m_frame ); + UpdateStatusBar(); } diff --git a/pcbnew/tools/drawing_tool.h b/pcbnew/tools/drawing_tool.h index f4e7ff7a98..c74ee6d8d2 100644 --- a/pcbnew/tools/drawing_tool.h +++ b/pcbnew/tools/drawing_tool.h @@ -44,6 +44,7 @@ class PCB_BASE_EDIT_FRAME; class PCB_SHAPE; class POLYGON_GEOM_MANAGER; class PCB_GENERATOR_MEANDERS; +class PNS_TUNE_STATUS_POPUP; /** @@ -355,6 +356,8 @@ private: BOARD_CONNECTED_ITEM* m_pickerItem; PCB_GENERATOR_MEANDERS* m_meander; + std::unique_ptr m_statusPopup; + static const unsigned int WIDTH_STEP; // Amount of width change for one -/+ key press static const unsigned int COORDS_PADDING; // Padding from coordinates limits for this tool