Fix a bug in tool activation/deactivation and another illegal static_cast.
Fixes: lp:1836419 * https://bugs.launchpad.net/kicad/+bug/1836419
This commit is contained in:
parent
37af3adffb
commit
1dbaa89f95
|
@ -54,7 +54,7 @@ static const std::string flag2string( int aFlag, const FlagString* aExps )
|
|||
void TOOL_EVENT::init()
|
||||
{
|
||||
// By default only MESSAGEs and Cancels are passed to multiple recipients
|
||||
m_passEvent = m_category == TC_MESSAGE || IsCancelInteractive();
|
||||
m_passEvent = m_category == TC_MESSAGE || IsCancelInteractive() || IsActivate();
|
||||
|
||||
m_hasPosition = ( m_category == TC_MOUSE || m_category == TC_COMMAND );
|
||||
}
|
||||
|
|
|
@ -22,19 +22,14 @@
|
|||
*/
|
||||
|
||||
#include <tools/zone_create_helper.h>
|
||||
|
||||
#include <view/view.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <class_zone.h>
|
||||
#include <class_drawsegment.h>
|
||||
#include <class_edge_mod.h>
|
||||
#include <class_pad.h>
|
||||
#include <board_commit.h>
|
||||
#include <pcb_painter.h>
|
||||
|
||||
#include <tools/pcb_actions.h>
|
||||
#include <tools/selection_tool.h>
|
||||
|
||||
#include <zone_filler.h>
|
||||
|
||||
ZONE_CREATE_HELPER::ZONE_CREATE_HELPER( DRAWING_TOOL& aTool, PARAMS& aParams ):
|
||||
|
@ -133,9 +128,7 @@ void ZONE_CREATE_HELPER::performZoneCutout( ZONE_CONTAINER& aZone, ZONE_CONTAINE
|
|||
newZoneOutline->AddOutline( originalOutline.Outline( i ) );
|
||||
|
||||
for (int j = 0; j < originalOutline.HoleCount(i) ; j++ )
|
||||
{
|
||||
newZoneOutline->AddHole( originalOutline.CHole(i, j), i );
|
||||
}
|
||||
|
||||
auto newZone = new ZONE_CONTAINER( aZone );
|
||||
newZone->SetOutline( newZoneOutline );
|
||||
|
@ -160,9 +153,6 @@ void ZONE_CREATE_HELPER::performZoneCutout( ZONE_CONTAINER& aZone, ZONE_CONTAINE
|
|||
|
||||
void ZONE_CREATE_HELPER::commitZone( std::unique_ptr<ZONE_CONTAINER> aZone )
|
||||
{
|
||||
auto& frame = *m_tool.getEditFrame<PCB_BASE_EDIT_FRAME>();
|
||||
auto board = m_tool.getModel<BOARD>();
|
||||
|
||||
switch ( m_params.m_mode )
|
||||
{
|
||||
case ZONE_MODE::CUTOUT:
|
||||
|
@ -179,7 +169,7 @@ void ZONE_CREATE_HELPER::commitZone( std::unique_ptr<ZONE_CONTAINER> aZone )
|
|||
|
||||
if( !m_params.m_keepout )
|
||||
{
|
||||
ZONE_FILLER filler( board );
|
||||
ZONE_FILLER filler( m_tool.getModel<BOARD>() );
|
||||
filler.Fill( { aZone.get() } );
|
||||
}
|
||||
|
||||
|
@ -192,13 +182,12 @@ void ZONE_CREATE_HELPER::commitZone( std::unique_ptr<ZONE_CONTAINER> aZone )
|
|||
case ZONE_MODE::GRAPHIC_POLYGON:
|
||||
{
|
||||
BOARD_COMMIT bCommit( &m_tool );
|
||||
BOARD_ITEM_CONTAINER* parent = frame.GetModel();
|
||||
BOARD_ITEM_CONTAINER* parent = m_tool.m_frame->GetModel();
|
||||
|
||||
if( m_tool.getDrawingLayer() != Edge_Cuts )
|
||||
{
|
||||
auto poly = m_tool.m_editModules ?
|
||||
new EDGE_MODULE( (MODULE *) parent ) :
|
||||
new DRAWSEGMENT();
|
||||
auto poly = m_tool.m_editModules ? new EDGE_MODULE( (MODULE *) parent )
|
||||
: new DRAWSEGMENT();
|
||||
poly->SetShape ( S_POLYGON );
|
||||
poly->SetLayer( m_tool.getDrawingLayer() );
|
||||
poly->SetPolyShape ( *aZone->Outline() );
|
||||
|
@ -211,9 +200,8 @@ void ZONE_CREATE_HELPER::commitZone( std::unique_ptr<ZONE_CONTAINER> aZone )
|
|||
|
||||
for( auto seg = outline->IterateSegments( 0 ); seg; seg++ )
|
||||
{
|
||||
auto new_seg = m_tool.m_editModules ?
|
||||
new EDGE_MODULE( (MODULE *) parent ) :
|
||||
new DRAWSEGMENT();
|
||||
auto new_seg = m_tool.m_editModules ? new EDGE_MODULE( (MODULE *) parent )
|
||||
: new DRAWSEGMENT();
|
||||
new_seg->SetShape( S_SEGMENT );
|
||||
new_seg->SetLayer( m_tool.getDrawingLayer() );
|
||||
new_seg->SetStart( wxPoint( seg.Get().A.x, seg.Get().A.y ) );
|
||||
|
@ -233,8 +221,7 @@ void ZONE_CREATE_HELPER::commitZone( std::unique_ptr<ZONE_CONTAINER> aZone )
|
|||
bool ZONE_CREATE_HELPER::OnFirstPoint( POLYGON_GEOM_MANAGER& aMgr )
|
||||
{
|
||||
// if we don't have a zone, create one
|
||||
// the user's choice here can affect things like the colour
|
||||
// of the preview
|
||||
// the user's choice here can affect things like the colour of the preview
|
||||
if( !m_zone )
|
||||
{
|
||||
m_tool.GetManager()->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||
|
@ -255,18 +242,12 @@ bool ZONE_CREATE_HELPER::OnFirstPoint( POLYGON_GEOM_MANAGER& aMgr )
|
|||
|
||||
m_parentView.SetVisible( &m_previewItem, true );
|
||||
|
||||
aMgr.SetLeaderMode( m_zone.get()->GetHV45()
|
||||
? POLYGON_GEOM_MANAGER::LEADER_MODE::DEG45
|
||||
aMgr.SetLeaderMode( m_zone->GetHV45() ? POLYGON_GEOM_MANAGER::LEADER_MODE::DEG45
|
||||
: POLYGON_GEOM_MANAGER::LEADER_MODE::DIRECT );
|
||||
}
|
||||
}
|
||||
|
||||
if( !m_zone )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return m_zone != nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -295,9 +276,7 @@ void ZONE_CREATE_HELPER::OnComplete( const POLYGON_GEOM_MANAGER& aMgr )
|
|||
auto* outline = m_zone->Outline();
|
||||
|
||||
for( int i = 0; i < finalPoints.PointCount(); ++i )
|
||||
{
|
||||
outline->Append( finalPoints.CPoint( i ) );
|
||||
}
|
||||
|
||||
outline->Outline( 0 ).SetClosed( true );
|
||||
outline->RemoveNullSegments();
|
||||
|
|
Loading…
Reference in New Issue