2014-07-09 11:50:27 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 CERN
|
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <pcb_base_edit_frame.h>
|
2015-08-15 14:00:34 +00:00
|
|
|
#include <tool/tool_manager.h>
|
|
|
|
#include <pcb_draw_panel_gal.h>
|
2019-11-23 22:43:54 +00:00
|
|
|
#include <pcb_layer_widget.h>
|
2020-05-06 01:45:48 +00:00
|
|
|
#include <pcbnew_settings.h>
|
|
|
|
#include <pgm_base.h>
|
2016-01-13 18:37:52 +00:00
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
2015-08-15 14:00:34 +00:00
|
|
|
#include <class_board.h>
|
2016-12-02 17:58:12 +00:00
|
|
|
#include <view/view.h>
|
2018-08-03 16:53:38 +00:00
|
|
|
#include "footprint_info_impl.h"
|
|
|
|
#include <project.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/color_settings.h>
|
2020-05-06 01:45:48 +00:00
|
|
|
#include <settings/settings_manager.h>
|
2018-10-10 09:48:16 +00:00
|
|
|
#include <tools/pcb_actions.h>
|
2018-08-03 16:53:38 +00:00
|
|
|
|
|
|
|
PCB_BASE_EDIT_FRAME::PCB_BASE_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent,
|
|
|
|
FRAME_T aFrameType, const wxString& aTitle,
|
|
|
|
const wxPoint& aPos, const wxSize& aSize, long aStyle,
|
|
|
|
const wxString& aFrameName ) :
|
|
|
|
PCB_BASE_FRAME( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ),
|
2020-01-11 16:56:25 +00:00
|
|
|
m_rotationAngle( 900 ), m_undoRedoBlocked( false ),
|
|
|
|
m_Layers( nullptr )
|
2018-08-03 16:53:38 +00:00
|
|
|
{
|
2018-08-04 23:07:25 +00:00
|
|
|
if( !GFootprintList.GetCount() )
|
2018-08-03 16:53:38 +00:00
|
|
|
{
|
|
|
|
wxTextFile footprintInfoCache( Prj().GetProjectPath() + "fp-info-cache" );
|
|
|
|
GFootprintList.ReadCacheFromFile( &footprintInfoCache );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PCB_BASE_EDIT_FRAME::~PCB_BASE_EDIT_FRAME()
|
|
|
|
{
|
2019-12-25 20:53:22 +00:00
|
|
|
if( wxFileName::IsDirWritable( Prj().GetProjectPath() ) )
|
|
|
|
{
|
|
|
|
wxTextFile footprintInfoCache( Prj().GetProjectPath() + "fp-info-cache" );
|
|
|
|
GFootprintList.WriteCacheToFile( &footprintInfoCache );
|
|
|
|
}
|
2019-09-23 13:41:44 +00:00
|
|
|
|
|
|
|
GetCanvas()->GetView()->Clear();
|
2018-08-03 16:53:38 +00:00
|
|
|
}
|
2018-07-23 11:37:01 +00:00
|
|
|
|
2014-07-09 11:50:27 +00:00
|
|
|
|
|
|
|
void PCB_BASE_EDIT_FRAME::SetRotationAngle( int aRotationAngle )
|
|
|
|
{
|
|
|
|
wxCHECK2_MSG( aRotationAngle > 0 && aRotationAngle <= 900, aRotationAngle = 900,
|
|
|
|
wxT( "Invalid rotation angle, defaulting to 90." ) );
|
|
|
|
|
|
|
|
m_rotationAngle = aRotationAngle;
|
|
|
|
}
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2015-02-18 19:27:00 +00:00
|
|
|
|
2019-05-30 12:25:08 +00:00
|
|
|
void PCB_BASE_EDIT_FRAME::ActivateGalCanvas()
|
2015-08-07 17:15:36 +00:00
|
|
|
{
|
2019-05-30 12:25:08 +00:00
|
|
|
PCB_BASE_FRAME::ActivateGalCanvas();
|
2015-08-07 17:15:36 +00:00
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->SyncLayersVisibility( m_Pcb );
|
2015-08-07 17:15:36 +00:00
|
|
|
}
|
2015-08-15 14:00:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
void PCB_BASE_EDIT_FRAME::SetBoard( BOARD* aBoard )
|
|
|
|
{
|
|
|
|
bool new_board = ( aBoard != m_Pcb );
|
|
|
|
|
|
|
|
if( new_board )
|
2017-07-31 13:07:55 +00:00
|
|
|
{
|
|
|
|
if( m_toolManager )
|
|
|
|
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->GetView()->Clear();
|
2017-07-31 13:07:55 +00:00
|
|
|
}
|
2015-08-15 14:00:34 +00:00
|
|
|
|
|
|
|
PCB_BASE_FRAME::SetBoard( aBoard );
|
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->GetGAL()->SetGridOrigin( VECTOR2D( aBoard->GetGridOrigin() ) );
|
2016-01-13 18:37:52 +00:00
|
|
|
|
2015-08-15 14:00:34 +00:00
|
|
|
// update the tool manager with the new board and its view.
|
|
|
|
if( m_toolManager )
|
|
|
|
{
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->DisplayBoard( aBoard );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
GetCanvas()->UpdateColors();
|
2019-06-13 17:28:55 +00:00
|
|
|
m_toolManager->SetEnvironment( aBoard, GetCanvas()->GetView(),
|
|
|
|
GetCanvas()->GetViewControls(), this );
|
2015-08-15 14:00:34 +00:00
|
|
|
|
|
|
|
if( new_board )
|
|
|
|
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
|
|
|
}
|
|
|
|
}
|
2018-10-10 09:48:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
void PCB_BASE_EDIT_FRAME::unitsChangeRefresh()
|
|
|
|
{
|
|
|
|
PCB_BASE_FRAME::unitsChangeRefresh();
|
|
|
|
|
|
|
|
ReCreateAuxiliaryToolbar();
|
|
|
|
|
|
|
|
if( m_toolManager )
|
|
|
|
m_toolManager->RunAction( PCB_ACTIONS::updateUnits, true );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-23 22:43:54 +00:00
|
|
|
void PCB_BASE_EDIT_FRAME::SetGridVisibility( bool aVisible )
|
|
|
|
{
|
|
|
|
PCB_BASE_FRAME::SetGridVisibility( aVisible );
|
|
|
|
|
2019-11-24 00:51:54 +00:00
|
|
|
// Update the grid checkbox in the layer widget
|
2019-11-23 22:43:54 +00:00
|
|
|
if( m_Layers )
|
2019-11-24 00:51:54 +00:00
|
|
|
m_Layers->SetRenderState( LAYER_GRID, aVisible );
|
2019-11-23 22:43:54 +00:00
|
|
|
|
|
|
|
// TODO (ISM): Remove this by changing toolbars to use the EVT_UPDATE_UI to get the state
|
|
|
|
SyncToolbars();
|
|
|
|
}
|
2020-05-06 01:45:48 +00:00
|
|
|
|
|
|
|
|
2020-05-16 17:15:43 +00:00
|
|
|
COLOR_SETTINGS* PCB_BASE_EDIT_FRAME::GetColorSettings()
|
2020-05-06 01:45:48 +00:00
|
|
|
{
|
|
|
|
return Pgm().GetSettingsManager().GetColorSettings( GetPcbNewSettings()->m_ColorTheme );
|
|
|
|
}
|