Draw meander borders while placing.

This commit is contained in:
Jeff Young 2023-10-11 14:09:53 +01:00
parent 4da3e0ff93
commit a57c9967f3
3 changed files with 40 additions and 21 deletions

View File

@ -624,6 +624,7 @@ public:
if( li->Parent() )
{
li->Parent()->SetForcedTransparency( 1.0 );
aFrame->GetCanvas()->GetView()->Update( li->Parent() );
m_removedItems.insert( li->Parent() );
}
}
@ -906,7 +907,7 @@ public:
void ViewDraw( int aLayer, KIGFX::VIEW* aView ) const override final
{
if( !IsSelected() )
if( !IsSelected() && !IsNew() )
return;
KIGFX::PREVIEW::DRAW_CONTEXT ctx( *aView );
@ -959,8 +960,8 @@ public:
int GetSpacing() const { return m_spacing; }
void SetSpacing( int aValue ) { m_spacing = aValue; }
int GetTargetLength() const { return m_targetLength; }
void SetTargetLength( int aValue ) { m_targetLength = aValue; }
long long int GetTargetLength() const { return m_targetLength; }
void SetTargetLength( long long int aValue ) { m_targetLength = aValue; }
int GetTargetSkew() const { return m_targetSkew; }
void SetTargetSkew( int aValue ) { m_targetSkew = aValue; }
@ -1129,7 +1130,7 @@ protected:
int m_minAmplitude;
int m_maxAmplitude;
int m_spacing;
int m_targetLength;
long long int m_targetLength;
int m_targetSkew;
bool m_overrideCustomRules;
int m_cornerRadiusPercentage;
@ -1171,6 +1172,10 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent )
m_pickerItem = nullptr;
m_meander = nullptr;
// Add a VIEW_GROUP that serves as a preview for the new item
m_preview.Clear();
m_view->Add( &m_preview );
picker->SetCursor( KICURSOR::BULLSEYE );
picker->SetClickHandler(
@ -1198,6 +1203,8 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent )
m_pickerItem->GetEffectiveShape()->Collide( aPosition, dummyClearance,
&dummyDist, &closestPt );
m_meander->SetPosition( closestPt );
m_preview.Add( m_meander );
return true; // keep going
}
else
@ -1218,7 +1225,7 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent )
[this]( const VECTOR2D& aPos )
{
BOARD* board = m_frame->GetBoard();
PCB_SELECTION_TOOL* selTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
PCB_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
GENERAL_COLLECTORS_GUIDE guide = m_frame->GetCollectorsGuide();
GENERAL_COLLECTOR collector;
GENERATOR_TOOL* generatorTool = m_toolMgr->GetTool<GENERATOR_TOOL>();
@ -1227,7 +1234,7 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent )
collector.Collect( board, { PCB_TRACE_T, PCB_ARC_T }, aPos, guide );
if( collector.GetCount() > 1 )
selTool->GuessSelectionCandidates( collector, aPos );
selectionTool->GuessSelectionCandidates( collector, aPos );
BOARD_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
@ -1260,6 +1267,8 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent )
m_statusPopup->Popup();
canvas()->SetStatusPopup( m_statusPopup.get() );
m_view->Update( &m_preview );
m_meander->UpdateStatus( generatorTool, m_frame, m_statusPopup.get() );
m_statusPopup->Move( KIPLATFORM::UI::GetMousePosition() + wxPoint( 20, 20 ) );
}
@ -1276,6 +1285,8 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent )
// First click already made; clean up meander preview
m_meander->EditRevert( generatorTool, m_board, m_frame, nullptr );
m_preview.Clear();
delete m_meander;
m_meander = nullptr;
}
@ -1284,13 +1295,20 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent )
picker->SetFinalizeHandler(
[this]( const int& aFinalState )
{
GENERATOR_TOOL* generatorTool = m_toolMgr->GetTool<GENERATOR_TOOL>();
PCB_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
GENERATOR_TOOL* generatorTool = m_toolMgr->GetTool<GENERATOR_TOOL>();
canvas()->SetStatusPopup( nullptr );
m_statusPopup->Hide();
generatorTool->HighlightNet( nullptr );
m_preview.Clear();
m_view->Remove( &m_preview );
if( m_meander )
selectionTool->AddItemToSel( m_meander );
// Ensure the cursor gets changed & updated
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
m_frame->GetCanvas()->Refresh();
@ -1376,7 +1394,7 @@ static struct PCB_GENERATOR_MEANDERS_DESC
PROPERTY_DISPLAY::PT_DEFAULT, ORIGIN_TRANSFORMS::NOT_A_COORD ),
groupTab );
propMgr.AddProperty( new PROPERTY<PCB_GENERATOR_MEANDERS, int>(
propMgr.AddProperty( new PROPERTY<PCB_GENERATOR_MEANDERS, long long int>(
_HKI( "Target length" ),
&PCB_GENERATOR_MEANDERS::SetTargetLength,
&PCB_GENERATOR_MEANDERS::GetTargetLength,

View File

@ -1804,8 +1804,8 @@ bool DRAWING_TOOL::drawShape( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic,
KIGFX::PREVIEW::TWO_POINT_ASSISTANT twoPointAsst( twoPointMgr, pcbIUScale, userUnits, geomShape );
// Add a VIEW_GROUP that serves as a preview for the new item
PCB_SELECTION preview;
m_view->Add( &preview );
m_preview.Clear();
m_view->Add( &m_preview );
m_view->Add( &twoPointAsst );
bool started = false;
@ -1822,8 +1822,8 @@ bool DRAWING_TOOL::drawShape( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic,
auto cleanup =
[&]()
{
preview.Clear();
m_view->Update( &preview );
m_preview.Clear();
m_view->Update( &m_preview );
delete graphic;
graphic = nullptr;
@ -1924,7 +1924,7 @@ bool DRAWING_TOOL::drawShape( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic,
if( PCB_TEXTBOX* pcb_textbox = dynamic_cast<PCB_TEXTBOX*>( graphic ) )
pcb_textbox->SetAttributes( m_textAttrs );
m_view->Update( &preview );
m_view->Update( &m_preview );
frame()->SetMsgPanel( graphic );
}
else
@ -1971,7 +1971,7 @@ bool DRAWING_TOOL::drawShape( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic,
if( !isLocalOriginSet )
m_frame->GetScreen()->m_LocalOrigin = cursorPos;
preview.Add( graphic );
m_preview.Add( graphic );
frame()->SetMsgPanel( graphic );
m_controls->SetAutoPan( true );
m_controls->CaptureCursor( true );
@ -2008,7 +2008,7 @@ bool DRAWING_TOOL::drawShape( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic,
graphic = nullptr;
}
preview.Clear();
m_preview.Clear();
twoPointMgr.Reset();
break;
}
@ -2042,7 +2042,7 @@ bool DRAWING_TOOL::drawShape( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic,
}
updateSegmentFromGeometryMgr( twoPointMgr, graphic );
m_view->Update( &preview );
m_view->Update( &m_preview );
m_view->Update( &twoPointAsst );
}
else if( started && ( evt->IsAction( &ACTIONS::undo )
@ -2065,7 +2065,7 @@ bool DRAWING_TOOL::drawShape( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic,
}
updateSegmentFromGeometryMgr( twoPointMgr, graphic );
m_view->Update( &preview );
m_view->Update( &m_preview );
m_view->Update( &twoPointAsst );
}
else
@ -2077,7 +2077,7 @@ bool DRAWING_TOOL::drawShape( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic,
{
m_stroke.SetWidth( m_stroke.GetWidth() + WIDTH_STEP );
graphic->SetStroke( m_stroke );
m_view->Update( &preview );
m_view->Update( &m_preview );
frame()->SetMsgPanel( graphic );
}
else if( graphic && evt->IsAction( &PCB_ACTIONS::decWidth ) )
@ -2086,14 +2086,14 @@ bool DRAWING_TOOL::drawShape( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic,
{
m_stroke.SetWidth( m_stroke.GetWidth() - WIDTH_STEP );
graphic->SetStroke( m_stroke );
m_view->Update( &preview );
m_view->Update( &m_preview );
frame()->SetMsgPanel( graphic );
}
}
else if( started && evt->IsAction( &PCB_ACTIONS::properties ) )
{
frame()->OnEditItemRequest( graphic );
m_view->Update( &preview );
m_view->Update( &m_preview );
frame()->SetMsgPanel( graphic );
break;
}
@ -2127,7 +2127,7 @@ bool DRAWING_TOOL::drawShape( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic,
m_frame->GetScreen()->m_LocalOrigin = VECTOR2D( 0, 0 );
m_view->Remove( &twoPointAsst );
m_view->Remove( &preview );
m_view->Remove( &m_preview );
if( selection().Empty() )
m_frame->SetMsgPanel( board() );

View File

@ -353,6 +353,7 @@ private:
STROKE_PARAMS m_stroke; // Current stroke for multi-segment drawing
TEXT_ATTRIBUTES m_textAttrs;
PCB_SELECTION m_preview;
BOARD_CONNECTED_ITEM* m_pickerItem;
PCB_GENERATOR_MEANDERS* m_meander;