2020-08-13 23:09:17 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 Ian McInerney <ian.s.mcinerney at ieee.org>
|
2022-02-12 16:32:55 +00:00
|
|
|
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2020-08-13 23:09:17 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
#include <pgm_base.h>
|
|
|
|
#include <settings/settings_manager.h>
|
|
|
|
#include <pcbnew_settings.h>
|
|
|
|
#include <footprint_editor_settings.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2020-08-13 23:09:17 +00:00
|
|
|
#include <pcb_base_frame.h>
|
|
|
|
#include <tool/selection.h>
|
|
|
|
#include <tools/pcb_editor_conditions.h>
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
#include <wx/debug.h>
|
|
|
|
|
|
|
|
using namespace std::placeholders;
|
|
|
|
|
|
|
|
|
2020-08-19 22:15:44 +00:00
|
|
|
SELECTION_CONDITION PCB_EDITOR_CONDITIONS::HasItems()
|
|
|
|
{
|
|
|
|
// Requires a PCB_BASE_FRAME
|
|
|
|
PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
|
|
|
|
|
|
|
|
wxASSERT( drwFrame );
|
|
|
|
|
2020-08-27 00:19:32 +00:00
|
|
|
return std::bind( &PCB_EDITOR_CONDITIONS::hasItemsFunc, _1, drwFrame );
|
2020-08-19 22:15:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-13 23:09:17 +00:00
|
|
|
SELECTION_CONDITION PCB_EDITOR_CONDITIONS::PadNumbersDisplay()
|
|
|
|
{
|
|
|
|
// Requires a PCB_BASE_FRAME
|
|
|
|
PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
|
|
|
|
|
|
|
|
wxASSERT( drwFrame );
|
|
|
|
|
|
|
|
return std::bind( &PCB_EDITOR_CONDITIONS::padNumberDisplayFunc, _1, drwFrame );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SELECTION_CONDITION PCB_EDITOR_CONDITIONS::PadFillDisplay()
|
|
|
|
{
|
|
|
|
// Requires a PCB_BASE_FRAME
|
|
|
|
PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
|
|
|
|
|
|
|
|
wxASSERT( drwFrame );
|
|
|
|
|
|
|
|
return std::bind( &PCB_EDITOR_CONDITIONS::padFillDisplayFunc, _1, drwFrame );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SELECTION_CONDITION PCB_EDITOR_CONDITIONS::TextFillDisplay()
|
|
|
|
{
|
|
|
|
// Requires a PCB_BASE_FRAME
|
|
|
|
PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
|
|
|
|
|
|
|
|
wxASSERT( drwFrame );
|
|
|
|
|
|
|
|
return std::bind( &PCB_EDITOR_CONDITIONS::textFillDisplayFunc, _1, drwFrame );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SELECTION_CONDITION PCB_EDITOR_CONDITIONS::GraphicsFillDisplay()
|
|
|
|
{
|
|
|
|
// Requires a PCB_BASE_FRAME
|
|
|
|
PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
|
|
|
|
|
|
|
|
wxASSERT( drwFrame );
|
|
|
|
|
|
|
|
return std::bind( &PCB_EDITOR_CONDITIONS::graphicsFillDisplayFunc, _1, drwFrame );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SELECTION_CONDITION PCB_EDITOR_CONDITIONS::ViaFillDisplay()
|
|
|
|
{
|
|
|
|
// Requires a PCB_BASE_FRAME
|
|
|
|
PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
|
|
|
|
|
|
|
|
wxASSERT( drwFrame );
|
|
|
|
|
|
|
|
return std::bind( &PCB_EDITOR_CONDITIONS::viaFillDisplayFunc, _1, drwFrame );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SELECTION_CONDITION PCB_EDITOR_CONDITIONS::TrackFillDisplay()
|
|
|
|
{
|
|
|
|
// Requires a PCB_BASE_FRAME
|
|
|
|
PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
|
|
|
|
|
|
|
|
wxASSERT( drwFrame );
|
|
|
|
|
|
|
|
return std::bind( &PCB_EDITOR_CONDITIONS::trackFillDisplayFunc, _1, drwFrame );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SELECTION_CONDITION PCB_EDITOR_CONDITIONS::ZoneDisplayMode( ZONE_DISPLAY_MODE aMode )
|
|
|
|
{
|
|
|
|
// Requires a PCB_BASE_FRAME
|
|
|
|
PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
|
|
|
|
|
|
|
|
wxASSERT( drwFrame );
|
|
|
|
|
|
|
|
return std::bind( &PCB_EDITOR_CONDITIONS::zoneDisplayModeFunc, _1, drwFrame, aMode );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-09-02 22:32:15 +00:00
|
|
|
SELECTION_CONDITION PCB_EDITOR_CONDITIONS::Get45degMode()
|
2021-02-05 23:43:32 +00:00
|
|
|
{
|
|
|
|
PCB_BASE_FRAME* drwFrame = dynamic_cast<PCB_BASE_FRAME*>( m_frame );
|
|
|
|
|
|
|
|
wxASSERT( drwFrame );
|
|
|
|
|
2021-09-02 22:32:15 +00:00
|
|
|
return std::bind( &PCB_EDITOR_CONDITIONS::get45degModeFunc, _1, drwFrame );
|
2021-02-05 23:43:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-19 22:15:44 +00:00
|
|
|
bool PCB_EDITOR_CONDITIONS::hasItemsFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame )
|
|
|
|
{
|
|
|
|
BOARD* board = aFrame->GetBoard();
|
|
|
|
|
|
|
|
return board && !board->IsEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-13 23:09:17 +00:00
|
|
|
bool PCB_EDITOR_CONDITIONS::padNumberDisplayFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame )
|
|
|
|
{
|
2022-02-12 16:32:55 +00:00
|
|
|
return aFrame->Settings().m_Display.m_PadNumbers;
|
2020-08-13 23:09:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool PCB_EDITOR_CONDITIONS::padFillDisplayFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame )
|
|
|
|
{
|
2021-12-26 00:36:12 +00:00
|
|
|
return aFrame->Settings().m_Display.m_DisplayPadFill;
|
2020-08-13 23:09:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool PCB_EDITOR_CONDITIONS::textFillDisplayFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame )
|
|
|
|
{
|
2021-12-26 00:36:12 +00:00
|
|
|
return aFrame->Settings().m_Display.m_DisplayTextFill;
|
2020-08-13 23:09:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool PCB_EDITOR_CONDITIONS::graphicsFillDisplayFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame )
|
|
|
|
{
|
2021-12-26 00:36:12 +00:00
|
|
|
return aFrame->Settings().m_Display.m_DisplayGraphicsFill;
|
2020-08-13 23:09:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool PCB_EDITOR_CONDITIONS::viaFillDisplayFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame )
|
|
|
|
{
|
2021-12-26 00:36:12 +00:00
|
|
|
return aFrame->Settings().m_Display.m_DisplayViaFill;
|
2020-08-13 23:09:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool PCB_EDITOR_CONDITIONS::trackFillDisplayFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame )
|
|
|
|
{
|
2021-12-26 00:36:12 +00:00
|
|
|
return aFrame->Settings().m_Display.m_DisplayPcbTrackFill;
|
2020-08-13 23:09:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool PCB_EDITOR_CONDITIONS::zoneDisplayModeFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame,
|
|
|
|
ZONE_DISPLAY_MODE aMode )
|
|
|
|
{
|
|
|
|
return aFrame->GetDisplayOptions().m_ZoneDisplayMode == aMode;
|
|
|
|
}
|
2021-02-05 23:43:32 +00:00
|
|
|
|
2021-09-02 22:32:15 +00:00
|
|
|
bool PCB_EDITOR_CONDITIONS::get45degModeFunc( const SELECTION& aSelection, PCB_BASE_FRAME* aFrame )
|
2021-02-05 23:43:32 +00:00
|
|
|
{
|
2021-08-29 23:33:08 +00:00
|
|
|
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
|
|
|
|
2021-10-01 11:11:03 +00:00
|
|
|
if( aFrame->IsType( FRAME_PCB_EDITOR ) )
|
2021-08-29 23:33:08 +00:00
|
|
|
return mgr.GetAppSettings<PCBNEW_SETTINGS>()->m_Use45DegreeLimit;
|
2021-10-01 11:11:03 +00:00
|
|
|
else
|
2021-08-29 23:33:08 +00:00
|
|
|
return mgr.GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>()->m_Use45Limit;
|
2021-02-05 23:43:32 +00:00
|
|
|
}
|