From d0479eb92c0049bba5ab9069769b16acdc01d250 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 31 Aug 2020 12:53:15 +0100 Subject: [PATCH] Fix signed/unsigned comparison that was destined to fail. --- ...autoplacer_tool.cpp => autoplace_tool.cpp} | 44 +++++++++---------- .../{autoplacer_tool.h => autoplace_tool.h} | 0 pcbnew/pcb_edit_frame.cpp | 4 +- 3 files changed, 24 insertions(+), 24 deletions(-) rename pcbnew/autorouter/{autoplacer_tool.cpp => autoplace_tool.cpp} (80%) rename pcbnew/autorouter/{autoplacer_tool.h => autoplace_tool.h} (100%) diff --git a/pcbnew/autorouter/autoplacer_tool.cpp b/pcbnew/autorouter/autoplace_tool.cpp similarity index 80% rename from pcbnew/autorouter/autoplacer_tool.cpp rename to pcbnew/autorouter/autoplace_tool.cpp index 06bed8851a..da1f296fd0 100644 --- a/pcbnew/autorouter/autoplacer_tool.cpp +++ b/pcbnew/autorouter/autoplace_tool.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2017 Kicad Developers, see change_log.txt for contributors. + * Copyright (C) 2017-2020 Kicad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -23,24 +23,13 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include - -// For action icons -#include - -#include -#include +//#include +//#include +//#include +//#include +//#include #include -#include -#include - +#include #include #include "ar_autoplacer.h" @@ -61,6 +50,7 @@ AUTOPLACE_TOOL::~AUTOPLACE_TOOL() // It is called by the autoplacer to update the view, when something must be displayed // especially each time a footprint is autoplaced, static PCB_BASE_EDIT_FRAME* fparent; + static int refreshCallback( MODULE* aModule ) { if( aModule ) @@ -76,15 +66,25 @@ static int refreshCallback( MODULE* aModule ) int AUTOPLACE_TOOL::autoplace( std::vector& aModules, bool aPlaceOffboard ) { - auto overlay = view()->MakeOverlay(); + EDA_RECT bbox = board()->GetBoardEdgesBoundingBox(); + + if( bbox.GetWidth() == 0 || bbox.GetHeight() == 0 ) + { + wxString msg = wxString::Format( _( "Board edges must be defined on the %s layer." ), + LayerName( Edge_Cuts ) ); + + frame()->GetInfoBar()->ShowMessageFor( msg, 4000, wxICON_ERROR ); + return 0; + } Activate(); AR_AUTOPLACER autoplacer( board() ); + BOARD_COMMIT commit( frame() ); - BOARD_COMMIT commit( frame() ); - + std::shared_ptr overlay = view()->MakeOverlay(); autoplacer.SetOverlay( overlay ); + fparent = frame(); std::function callback = refreshCallback; autoplacer.SetRefreshCallback( callback ); @@ -108,7 +108,7 @@ int AUTOPLACE_TOOL::autoplaceSelected( const TOOL_EVENT& aEvent ) { std::vector mods; - for( auto item : selection() ) + for( EDA_ITEM* item : selection() ) { if( item->Type() == PCB_MODULE_T ) mods.push_back( static_cast( item ) ); diff --git a/pcbnew/autorouter/autoplacer_tool.h b/pcbnew/autorouter/autoplace_tool.h similarity index 100% rename from pcbnew/autorouter/autoplacer_tool.h rename to pcbnew/autorouter/autoplace_tool.h diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 0bad8e7c24..fe252bbcb1 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -81,7 +81,7 @@ #include #include #include -#include +#include #include #include #include @@ -366,7 +366,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : wxString strK2S = Pgm().GetExecutablePath(); #ifdef __WXMAC__ - if (strK2S.find( "pcbnew.app" ) != wxNOT_FOUND ) + if( strK2S.Find( "pcbnew.app" ) != wxNOT_FOUND ) { // On macOS, we have standalone applications inside the main bundle, so we handle that here: strK2S += "../../";