mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-20 00:21:31 +00:00
Push a couple of layers of indirection out of grid settings.
This commit is contained in:
parent
60915fbc76
commit
f84406009b
3d-viewer
common
cvpcb
eeschema
dialogs
eeschema_config.cppfiles-io.cpphierarch.cpplib_view_frame.cpplibedit
sch_base_frame.cppsch_draw_panel.cppsch_edit_frame.cppsch_screen.cppsch_screen.hsheet.cpptools
gerbview
include
kicad
pagelayout_editor
pcbnew
dialogs
footprint_edit_frame.cppfootprint_preview_panel.cppfootprint_viewer_frame.cppfootprint_viewer_frame.hfootprint_wizard_frame.cpppcb_base_edit_frame.cpppcb_base_frame.cpppcb_edit_frame.cpppcb_screen.cpppcbnew_settings.cpppcbnew_settings.htools
qa/qa_utils
@ -92,7 +92,7 @@ PANEL_PREV_3D::PANEL_PREV_3D( wxWindow* aParent, PCB_BASE_FRAME* aFrame, MODULE*
|
||||
|
||||
// Create the manager
|
||||
m_toolManager = new TOOL_MANAGER;
|
||||
m_toolManager->SetEnvironment( m_dummyBoard, nullptr, nullptr, this );
|
||||
m_toolManager->SetEnvironment( m_dummyBoard, nullptr, nullptr, nullptr, this );
|
||||
|
||||
m_actions = new EDA_3D_ACTIONS();
|
||||
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
|
||||
|
@ -121,7 +121,7 @@ EDA_3D_VIEWER::EDA_3D_VIEWER( KIWAY *aKiway, PCB_BASE_FRAME *aParent, const wxSt
|
||||
|
||||
// Create the manager
|
||||
m_toolManager = new TOOL_MANAGER;
|
||||
m_toolManager->SetEnvironment( GetBoard(), nullptr, nullptr, this );
|
||||
m_toolManager->SetEnvironment( GetBoard(), nullptr, nullptr, config, this );
|
||||
|
||||
m_actions = new EDA_3D_ACTIONS();
|
||||
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
||||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.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
|
||||
@ -24,20 +24,10 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file base_screen.cpp
|
||||
* @brief BASE_SCREEN object implementation.
|
||||
*/
|
||||
|
||||
|
||||
#include <base_screen.h>
|
||||
#include <base_struct.h>
|
||||
#include <base_units.h>
|
||||
#include <common.h>
|
||||
#include <fctsys.h>
|
||||
#include <id.h>
|
||||
#include <math/util.h> // for KiROUND
|
||||
#include <macros.h>
|
||||
#include <trace_helpers.h>
|
||||
|
||||
|
||||
@ -52,10 +42,7 @@ BASE_SCREEN::BASE_SCREEN( EDA_ITEM* aParent, KICAD_T aType ) :
|
||||
m_ScreenNumber = 1;
|
||||
m_NumberOfScreens = 1; // Hierarchy: Root: ScreenNumber = 1
|
||||
m_Zoom = 32.0;
|
||||
m_Grid.m_Size = wxRealPoint( 50, 50 ); // Default grid size
|
||||
m_Grid.m_CmdId = ID_POPUP_GRID_LEVEL_50;
|
||||
m_Center = true;
|
||||
m_IsPrinting = false;
|
||||
|
||||
m_FlagModified = false; // Set when any change is made on board.
|
||||
m_FlagSave = false; // Used in auto save set when an auto save is required.
|
||||
@ -104,180 +91,6 @@ bool BASE_SCREEN::SetZoom( double iu_per_du )
|
||||
}
|
||||
|
||||
|
||||
int BASE_SCREEN::BuildGridsChoiceList( wxArrayString& aGridsList, bool aMmFirst) const
|
||||
{
|
||||
wxString msg;
|
||||
wxRealPoint curr_grid_size = GetGridSize();
|
||||
int idx = -1;
|
||||
int idx_usergrid = -1;
|
||||
|
||||
for( size_t i = 0; i < GetGridCount(); i++ )
|
||||
{
|
||||
const GRID_TYPE& grid = m_grids[i];
|
||||
double gridValueMils = To_User_Unit( EDA_UNITS::INCHES, grid.m_Size.x ) * 1000;
|
||||
double gridValue_mm = To_User_Unit( EDA_UNITS::MILLIMETRES, grid.m_Size.x );
|
||||
|
||||
if( grid.m_CmdId == ID_POPUP_GRID_USER )
|
||||
{
|
||||
if( aMmFirst )
|
||||
msg.Printf( _( "User grid: %.4f mm (%.2f mils)" ),
|
||||
gridValue_mm, gridValueMils );
|
||||
else
|
||||
msg.Printf( _( "User grid: %.2f mils (%.4f mm)" ),
|
||||
gridValueMils, gridValue_mm );
|
||||
idx_usergrid = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( aMmFirst )
|
||||
msg.Printf( _( "Grid: %.4f mm (%.2f mils)" ),
|
||||
gridValue_mm, gridValueMils );
|
||||
else
|
||||
msg.Printf( _( "Grid: %.2f mils (%.4f mm)" ),
|
||||
gridValueMils, gridValue_mm );
|
||||
}
|
||||
|
||||
aGridsList.Add( msg );
|
||||
|
||||
if( curr_grid_size == grid.m_Size )
|
||||
idx = i;
|
||||
}
|
||||
|
||||
if( idx < 0 )
|
||||
idx = idx_usergrid;
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
|
||||
int BASE_SCREEN::SetGrid( const wxRealPoint& size )
|
||||
{
|
||||
wxASSERT( !m_grids.empty() );
|
||||
|
||||
GRID_TYPE nearest_grid = m_grids[0];
|
||||
int gridIdx = 0;
|
||||
|
||||
for( GRID_TYPE& grid : m_grids )
|
||||
{
|
||||
if( grid.m_Size == size )
|
||||
{
|
||||
m_Grid = grid;
|
||||
return grid.m_CmdId - ID_POPUP_GRID_LEVEL_1000;
|
||||
}
|
||||
|
||||
// keep track of the nearest larger grid size, if the exact size is not found
|
||||
if ( size.x < grid.m_Size.x )
|
||||
{
|
||||
gridIdx = grid.m_CmdId - ID_POPUP_GRID_LEVEL_1000;
|
||||
nearest_grid = grid;
|
||||
}
|
||||
}
|
||||
|
||||
m_Grid = nearest_grid;
|
||||
return gridIdx;
|
||||
}
|
||||
|
||||
|
||||
int BASE_SCREEN::SetGrid( int aCommandId )
|
||||
{
|
||||
wxASSERT( !m_grids.empty() );
|
||||
|
||||
for( GRID_TYPE& grid : m_grids )
|
||||
{
|
||||
if( grid.m_CmdId == aCommandId )
|
||||
{
|
||||
m_Grid = grid;
|
||||
return grid.m_CmdId - ID_POPUP_GRID_LEVEL_1000;
|
||||
}
|
||||
}
|
||||
|
||||
m_Grid = m_grids[0];
|
||||
return m_grids[0].m_CmdId - ID_POPUP_GRID_LEVEL_1000;
|
||||
}
|
||||
|
||||
|
||||
void BASE_SCREEN::AddGrid( const GRID_TYPE& aGrid )
|
||||
{
|
||||
for( GRID_TYPE& existing : m_grids )
|
||||
{
|
||||
if( existing.m_Size == aGrid.m_Size && aGrid.m_CmdId != ID_POPUP_GRID_USER )
|
||||
{
|
||||
wxLogTrace( traceScreen, "Discarding duplicate grid size( %g, %g ).",
|
||||
aGrid.m_Size.x, aGrid.m_Size.y );
|
||||
return;
|
||||
}
|
||||
|
||||
if( existing.m_CmdId == aGrid.m_CmdId )
|
||||
{
|
||||
wxLogTrace( traceScreen, wxT( "Changing grid ID %d from size( %g, %g ) to " ) \
|
||||
wxT( "size( %g, %g )." ),
|
||||
aGrid.m_CmdId, existing.m_Size.x,
|
||||
existing.m_Size.y, aGrid.m_Size.x, aGrid.m_Size.y );
|
||||
existing.m_Size = aGrid.m_Size;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_grids.push_back( aGrid );
|
||||
}
|
||||
|
||||
|
||||
void BASE_SCREEN::AddGrid( const wxRealPoint& size, EDA_UNITS aUnit, int id )
|
||||
{
|
||||
wxRealPoint new_size;
|
||||
GRID_TYPE new_grid;
|
||||
|
||||
new_size.x = From_User_Unit( aUnit, size.x );
|
||||
new_size.y = From_User_Unit( aUnit, size.y );
|
||||
new_grid.m_CmdId = id;
|
||||
new_grid.m_Size = new_size;
|
||||
|
||||
AddGrid( new_grid );
|
||||
}
|
||||
|
||||
|
||||
GRID_TYPE& BASE_SCREEN::GetGrid( size_t aIndex )
|
||||
{
|
||||
wxCHECK_MSG( !m_grids.empty() && aIndex < m_grids.size(), m_Grid,
|
||||
wxT( "Cannot get grid object outside the bounds of the grid list." ) );
|
||||
|
||||
return m_grids[ aIndex ];
|
||||
}
|
||||
|
||||
|
||||
bool BASE_SCREEN::GridExists( int aCommandId )
|
||||
{
|
||||
// tests for grid command ID (not an index in grid list, but a wxID) exists in grid list.
|
||||
for( GRID_TYPE& grid : m_grids)
|
||||
{
|
||||
if( grid.m_CmdId == aCommandId )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
wxPoint BASE_SCREEN::getNearestGridPosition( const wxPoint& aPosition,
|
||||
const wxPoint& aGridOrigin ) const
|
||||
{
|
||||
wxPoint pt;
|
||||
wxRealPoint gridSize = GetGridSize();
|
||||
|
||||
double offset = fmod( aGridOrigin.x, gridSize.x );
|
||||
int x = KiROUND( (aPosition.x - offset) / gridSize.x );
|
||||
|
||||
pt.x = KiROUND( x * gridSize.x + offset );
|
||||
|
||||
offset = fmod( aGridOrigin.y, gridSize.y );
|
||||
|
||||
int y = KiROUND( (aPosition.y - offset) / gridSize.y );
|
||||
pt.y = KiROUND ( y * gridSize.y + offset );
|
||||
|
||||
return pt;
|
||||
}
|
||||
|
||||
|
||||
void BASE_SCREEN::ClearUndoRedoList()
|
||||
{
|
||||
ClearUndoORRedoList( m_UndoList );
|
||||
@ -334,13 +147,6 @@ void BASE_SCREEN::Show( int nestLevel, std::ostream& os ) const
|
||||
// for now, make it look like XML, expand on this later.
|
||||
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n";
|
||||
|
||||
/* this class will eventually go away, but here's a place holder until then.
|
||||
for( EDA_ITEM* item = m_drawList; item; item = item->Next() )
|
||||
{
|
||||
item->Show( nestLevel+1, os );
|
||||
}
|
||||
*/
|
||||
|
||||
NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
|
||||
}
|
||||
|
||||
|
@ -367,7 +367,9 @@ bool EDA_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType )
|
||||
if( aGalType == m_backend && m_gal != NULL )
|
||||
return true;
|
||||
|
||||
bool result = true; // assume everything will be fine
|
||||
VECTOR2D grid_size = m_gal ? m_gal->GetGridSize() : VECTOR2D();
|
||||
bool grid_visibility = m_gal ? m_gal->GetGridVisibility() : true;
|
||||
bool result = true; // assume everything will be fine
|
||||
|
||||
// Prevent refreshing canvas during backend switch
|
||||
StopDrawing();
|
||||
@ -437,6 +439,11 @@ bool EDA_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType )
|
||||
clientSize.y = std::max( 10, clientSize.y );
|
||||
m_gal->ResizeScreen( clientSize.GetX(), clientSize.GetY() );
|
||||
|
||||
if( grid_size.x > 0 && grid_size.y > 0 )
|
||||
m_gal->SetGridSize( grid_size );
|
||||
|
||||
m_gal->SetGridVisibility( grid_visibility );
|
||||
|
||||
if( m_painter )
|
||||
m_painter->SetGAL( m_gal );
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 2004-2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.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
|
||||
@ -26,7 +26,6 @@
|
||||
#include <base_screen.h>
|
||||
#include <bitmaps.h>
|
||||
#include <confirm.h>
|
||||
#include <dialog_helpers.h>
|
||||
#include <dialog_shim.h>
|
||||
#include <eda_draw_frame.h>
|
||||
#include <fctsys.h>
|
||||
@ -82,8 +81,6 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
|
||||
m_messagePanel = NULL;
|
||||
m_currentScreen = NULL;
|
||||
m_showBorderAndTitleBlock = false; // true to display reference sheet.
|
||||
m_LastGridSizeId = 0;
|
||||
m_drawGrid = true; // hide/Show grid. default = show
|
||||
m_gridColor = COLOR4D( DARKGRAY ); // Default grid color
|
||||
m_showPageLimits = false;
|
||||
m_drawBgColor = COLOR4D( BLACK ); // the background color of the draw canvas:
|
||||
@ -242,19 +239,10 @@ void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
|
||||
if( m_gridSelectBox == NULL )
|
||||
return;
|
||||
|
||||
int select = wxNOT_FOUND;
|
||||
int idx = config()->m_Window.grid.last_size_idx;
|
||||
|
||||
for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ )
|
||||
{
|
||||
if( GetScreen()->GetGridCmdId() == GetScreen()->GetGrid( i ).m_CmdId )
|
||||
{
|
||||
select = (int) i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( select != m_gridSelectBox->GetSelection() )
|
||||
m_gridSelectBox->SetSelection( select );
|
||||
if( idx >= 0 && idx < m_gridSelectBox->GetCount() && idx != m_gridSelectBox->GetSelection() )
|
||||
m_gridSelectBox->SetSelection( idx );
|
||||
}
|
||||
|
||||
|
||||
@ -271,28 +259,28 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
|
||||
{
|
||||
wxCHECK_RET( m_gridSelectBox, "m_gridSelectBox uninitialized" );
|
||||
|
||||
int id = m_gridSelectBox->GetCurrentSelection() + ID_POPUP_GRID_FIRST;
|
||||
int idx = m_gridSelectBox->GetCurrentSelection();
|
||||
|
||||
if( id == ID_POPUP_GRID_SEPARATOR )
|
||||
if( idx == m_gridSelectBox->GetCount() - 2 )
|
||||
{
|
||||
// wxWidgets will check the separator, which we don't want.
|
||||
// Re-check the current grid.
|
||||
wxUpdateUIEvent dummy;
|
||||
OnUpdateSelectGrid( dummy );
|
||||
}
|
||||
else if( id == ID_POPUP_GRID_SETTINGS )
|
||||
else if( idx == m_gridSelectBox->GetCount() - 1 )
|
||||
{
|
||||
// wxWidgets will check the Grid Settings... entry, which we don't want.
|
||||
// R-check the current grid.
|
||||
// Re-check the current grid.
|
||||
wxUpdateUIEvent dummy;
|
||||
OnUpdateSelectGrid( dummy );
|
||||
// Now run the Grid Settings... dialog
|
||||
wxCommandEvent dummy2;
|
||||
OnGridSettings( dummy2 );
|
||||
}
|
||||
else if( id >= ID_POPUP_GRID_FIRST && id < ID_POPUP_GRID_SEPARATOR )
|
||||
else
|
||||
{
|
||||
m_toolManager->RunAction( ACTIONS::gridPreset, true, id - ID_POPUP_GRID_FIRST );
|
||||
m_toolManager->RunAction( ACTIONS::gridPreset, true, idx );
|
||||
}
|
||||
|
||||
UpdateStatusBar();
|
||||
@ -300,6 +288,32 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
|
||||
}
|
||||
|
||||
|
||||
bool EDA_DRAW_FRAME::IsGridVisible() const
|
||||
{
|
||||
return config()->m_Window.grid.show;
|
||||
}
|
||||
|
||||
|
||||
void EDA_DRAW_FRAME::SetGridVisibility( bool aVisible )
|
||||
{
|
||||
config()->m_Window.grid.show = aVisible;
|
||||
|
||||
// Update the display with the new grid
|
||||
if( GetCanvas() )
|
||||
{
|
||||
// Check to ensure these exist, since this function could be called before
|
||||
// the GAL and View have been created
|
||||
if( GetCanvas()->GetGAL() )
|
||||
GetCanvas()->GetGAL()->SetGridVisibility( aVisible );
|
||||
|
||||
if( GetCanvas()->GetView() )
|
||||
GetCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
||||
|
||||
GetCanvas()->Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EDA_DRAW_FRAME::InitExitKey()
|
||||
{
|
||||
wxAcceleratorEntry entries[1];
|
||||
@ -392,21 +406,12 @@ void EDA_DRAW_FRAME::DisplayGridMsg()
|
||||
|
||||
switch( m_userUnits )
|
||||
{
|
||||
case EDA_UNITS::INCHES:
|
||||
gridformatter = "grid %.3f";
|
||||
break;
|
||||
|
||||
case EDA_UNITS::MILLIMETRES:
|
||||
gridformatter = "grid %.4f";
|
||||
break;
|
||||
|
||||
default:
|
||||
gridformatter = "grid %f";
|
||||
break;
|
||||
case EDA_UNITS::INCHES: gridformatter = "grid %.3f"; break;
|
||||
case EDA_UNITS::MILLIMETRES: gridformatter = "grid %.4f"; break;
|
||||
default: gridformatter = "grid %f"; break;
|
||||
}
|
||||
|
||||
wxRealPoint curr_grid_size = GetScreen()->GetGridSize();
|
||||
double grid = To_User_Unit( m_userUnits, curr_grid_size.x );
|
||||
double grid = To_User_Unit( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().x );
|
||||
line.Printf( gridformatter, grid );
|
||||
|
||||
SetStatusText( line, 4 );
|
||||
@ -419,13 +424,9 @@ void EDA_DRAW_FRAME::DisplayUnitsMsg()
|
||||
|
||||
switch( m_userUnits )
|
||||
{
|
||||
case EDA_UNITS::INCHES:
|
||||
msg = _( "Inches" );
|
||||
break;
|
||||
case EDA_UNITS::MILLIMETRES:
|
||||
msg = _( "mm" );
|
||||
break;
|
||||
default: msg = _( "Units" ); break;
|
||||
case EDA_UNITS::INCHES: msg = _( "Inches" ); break;
|
||||
case EDA_UNITS::MILLIMETRES: msg = _( "mm" ); break;
|
||||
default: msg = _( "Units" ); break;
|
||||
}
|
||||
|
||||
SetStatusText( msg, 5 );
|
||||
@ -470,15 +471,6 @@ void EDA_DRAW_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
||||
// Read units used in dialogs and toolbars
|
||||
SetUserUnits( static_cast<EDA_UNITS>( aCfg->m_System.units ) );
|
||||
|
||||
// Read show/hide grid entry
|
||||
SetGridVisibility( window->grid.show );
|
||||
|
||||
m_LastGridSizeId = window->grid.last_size;
|
||||
|
||||
// m_LastGridSizeId is an offset, expected to be >= 0
|
||||
if( m_LastGridSizeId < 0 )
|
||||
m_LastGridSizeId = 0;
|
||||
|
||||
m_UndoRedoCountMax = aCfg->m_System.max_undo_items;
|
||||
m_firstRunDialogSetting = aCfg->m_System.first_run_shown;
|
||||
|
||||
@ -505,9 +497,6 @@ void EDA_DRAW_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
||||
aCfg->m_System.units = static_cast<int>( m_userUnits );
|
||||
aCfg->m_System.first_run_shown = m_firstRunDialogSetting;
|
||||
|
||||
window->grid.show = IsGridVisible();
|
||||
window->grid.last_size = m_LastGridSizeId;
|
||||
|
||||
if( GetScreen() )
|
||||
aCfg->m_System.max_undo_items = GetScreen()->GetMaxUndoItems();
|
||||
|
||||
@ -660,14 +649,20 @@ bool EDA_DRAW_FRAME::saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvas
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----< BASE_SCREEN API moved here >--------------------------------------------
|
||||
|
||||
wxPoint EDA_DRAW_FRAME::GetNearestGridPosition( const wxPoint& aPosition ) const
|
||||
{
|
||||
return GetScreen()->getNearestGridPosition( aPosition, GetGridOrigin() );
|
||||
const wxPoint& gridOrigin = GetGridOrigin();
|
||||
VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize();
|
||||
|
||||
double xOffset = fmod( gridOrigin.x, gridSize.x );
|
||||
int x = KiROUND( (aPosition.x - xOffset) / gridSize.x );
|
||||
double yOffset = fmod( gridOrigin.y, gridSize.y );
|
||||
int y = KiROUND( (aPosition.y - yOffset) / gridSize.y );
|
||||
|
||||
return wxPoint( KiROUND( x * gridSize.x + xOffset ), KiROUND( y * gridSize.y + yOffset ) );
|
||||
}
|
||||
|
||||
//-----</BASE_SCREEN API moved here >--------------------------------------------
|
||||
|
||||
const BOX2I EDA_DRAW_FRAME::GetDocumentExtents() const
|
||||
{
|
||||
|
@ -26,13 +26,12 @@
|
||||
#include <settings/common_settings.h>
|
||||
#include <settings/parameters.h>
|
||||
|
||||
|
||||
///! Update the schema version whenever a migration is required
|
||||
const int appSettingsSchemaVersion = 0;
|
||||
|
||||
|
||||
APP_SETTINGS_BASE::APP_SETTINGS_BASE( std::string aFilename, int aSchemaVersion ) :
|
||||
JSON_SETTINGS( std::move( aFilename ), SETTINGS_LOC::USER, aSchemaVersion ),
|
||||
APP_SETTINGS_BASE::APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaVersion ) :
|
||||
JSON_SETTINGS( aFilename, SETTINGS_LOC::USER, aSchemaVersion ),
|
||||
m_Printing(), m_System(), m_Window(), m_appSettingsSchemaVersion( aSchemaVersion )
|
||||
{
|
||||
// Make Coverity happy:
|
||||
@ -211,6 +210,19 @@ bool APP_SETTINGS_BASE::migrateWindowConfig( wxConfigBase* aCfg, const std::stri
|
||||
|
||||
ret &= fromLegacy<int>( aCfg,
|
||||
aFrame + "_LastGridSize", aJsonPath + ".grid.last_size" );
|
||||
|
||||
#if defined( PCBNEW )
|
||||
double x, y;
|
||||
|
||||
if( aCfg->Read( aFrame + "PcbUserGrid_X", &x ) && aCfg->Read( aFrame + "PcbUserGrid_Y", &y ) )
|
||||
{
|
||||
EDA_UNITS u = (EDA_UNITS)aCfg->Read( aFrame + "PcbUserGrid_Unit", (int)EDA_UNITS::INCHES );
|
||||
|
||||
( *this )[PointerFromString( ".grid.user_grid_x" )] = StringFromValue( u, x, true, true );
|
||||
( *this )[PointerFromString( ".grid.user_grid_y" )] = StringFromValue( u, y, true, true );
|
||||
}
|
||||
#endif
|
||||
|
||||
ret &= fromLegacy<bool>( aCfg,
|
||||
aFrame + gd + "GridAxesEnabled", aJsonPath + ".grid.axes_enabled" );
|
||||
ret &= fromLegacy<double>( aCfg,
|
||||
@ -227,17 +239,18 @@ bool APP_SETTINGS_BASE::migrateWindowConfig( wxConfigBase* aCfg, const std::stri
|
||||
|
||||
void APP_SETTINGS_BASE::addParamsForWindow( WINDOW_SETTINGS* aWindow, const std::string& aJsonPath )
|
||||
{
|
||||
m_params.emplace_back(
|
||||
new PARAM<bool>( aJsonPath + ".maximized", &aWindow->maximized, false ) );
|
||||
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".maximized",
|
||||
&aWindow->maximized, false ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".mru_path", &aWindow->mru_path, "" ) );
|
||||
m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".mru_path",
|
||||
&aWindow->mru_path, "" ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<int>( aJsonPath + ".size_x", &aWindow->size_x, 0 ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<int>( aJsonPath + ".size_y", &aWindow->size_y, 0 ) );
|
||||
|
||||
m_params.emplace_back(
|
||||
new PARAM<wxString>( aJsonPath + ".perspective", &aWindow->perspective, "" ) );
|
||||
m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".perspective",
|
||||
&aWindow->perspective, "" ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<int>( aJsonPath + ".pos_x", &aWindow->pos_x, 0 ) );
|
||||
|
||||
@ -246,18 +259,28 @@ void APP_SETTINGS_BASE::addParamsForWindow( WINDOW_SETTINGS* aWindow, const std:
|
||||
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.axes_enabled",
|
||||
&aWindow->grid.axes_enabled, false ) );
|
||||
|
||||
m_params.emplace_back(
|
||||
new PARAM<int>( aJsonPath + ".grid.last_size", &aWindow->grid.last_size, 0 ) );
|
||||
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.last_size",
|
||||
&aWindow->grid.last_size_idx, 0 ) );
|
||||
|
||||
m_params.emplace_back(
|
||||
new PARAM<double>( aJsonPath + ".grid.line_width", &aWindow->grid.line_width, 1.0 ) );
|
||||
m_params.emplace_back( new PARAM_LIST<wxString>( aJsonPath + ".grid.sizes",
|
||||
&aWindow->grid.sizes, {} ) );
|
||||
|
||||
m_params.emplace_back(
|
||||
new PARAM<double>( aJsonPath + ".grid.min_spacing", &aWindow->grid.min_spacing, 10 ) );
|
||||
m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".grid.user_grid_x",
|
||||
&aWindow->grid.user_grid_x, "12.5 mil" ) );
|
||||
m_params.emplace_back( new PARAM<wxString>( aJsonPath + ".grid.user_grid_x",
|
||||
&aWindow->grid.user_grid_x, "12.5 mil" ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.show", &aWindow->grid.show, true ) );
|
||||
m_params.emplace_back( new PARAM<double>( aJsonPath + ".grid.line_width",
|
||||
&aWindow->grid.line_width, 1.0 ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.style", &aWindow->grid.style, 0 ) );
|
||||
m_params.emplace_back( new PARAM<double>( aJsonPath + ".grid.min_spacing",
|
||||
&aWindow->grid.min_spacing, 10 ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".grid.show",
|
||||
&aWindow->grid.show, true ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.style",
|
||||
&aWindow->grid.style, 0 ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".cursor.always_show_cursor",
|
||||
&aWindow->cursor.always_show_cursor, true ) );
|
||||
|
@ -30,16 +30,30 @@
|
||||
#include <view/view.h>
|
||||
#include <view/view_controls.h>
|
||||
#include <gal/graphics_abstraction_layer.h>
|
||||
#include <settings/app_settings.h>
|
||||
#include <base_screen.h>
|
||||
#include <tool/common_tools.h>
|
||||
#include <id.h>
|
||||
#include <project.h>
|
||||
#include <kiface_i.h>
|
||||
#include <dialog_configure_paths.h>
|
||||
#include <base_units.h>
|
||||
|
||||
|
||||
void COMMON_TOOLS::Reset( RESET_REASON aReason )
|
||||
{
|
||||
m_frame = getEditFrame<EDA_DRAW_FRAME>();
|
||||
|
||||
m_grids.clear();
|
||||
|
||||
for( const wxString& gridDef : m_toolMgr->GetSettings()->m_Window.grid.sizes )
|
||||
{
|
||||
int gridSize = (int) ValueFromString( EDA_UNITS::MILLIMETRES, gridDef, true );
|
||||
m_grids.emplace_back( gridSize, gridSize );
|
||||
}
|
||||
|
||||
if( aReason == GAL_SWITCH )
|
||||
OnGridChanged();
|
||||
}
|
||||
|
||||
|
||||
@ -62,7 +76,7 @@ int COMMON_TOOLS::CursorControl( const TOOL_EVENT& aEvent )
|
||||
bool mirroredX = getView()->IsMirroredX();
|
||||
|
||||
VECTOR2D cursor = getViewControls()->GetRawCursorPosition( false );
|
||||
VECTOR2I gridSize = VECTOR2D( m_frame->GetScreen()->GetGridSize() );
|
||||
VECTOR2D gridSize = getView()->GetGAL()->GetGridSize();
|
||||
|
||||
if( fastMove )
|
||||
gridSize = gridSize * 10;
|
||||
@ -125,7 +139,7 @@ int COMMON_TOOLS::PanControl( const TOOL_EVENT& aEvent )
|
||||
long type = aEvent.Parameter<intptr_t>();
|
||||
KIGFX::VIEW* view = getView();
|
||||
VECTOR2D center = view->GetCenter();
|
||||
VECTOR2I gridSize = VECTOR2D( m_frame->GetScreen()->GetGridSize() ) * 10;
|
||||
VECTOR2D gridSize = getView()->GetGAL()->GetGridSize() * 10;
|
||||
bool mirroredX = view->IsMirroredX();
|
||||
|
||||
switch( type )
|
||||
@ -336,56 +350,26 @@ int COMMON_TOOLS::doZoomToPreset( int idx, bool aCenterOnCursor )
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Advance a BASE_SCREEN's grid forwards or backwards by the given offset and
|
||||
* return the cmd ID of that grid (doesn't change the grid).
|
||||
*
|
||||
* This works even if the base screen's grid do not have consecutive command IDs.
|
||||
*
|
||||
* @param aScreen the base screen to use
|
||||
* @param aOffset how many grids to advance by (negative to go backwards)
|
||||
* @return the cmd ID of the requested grid, or empty if it can't be found
|
||||
*/
|
||||
static OPT<int> getNextPreviousGrid( const BASE_SCREEN& aScreen, int aOffset )
|
||||
{
|
||||
const GRIDS& grids = aScreen.GetGrids();
|
||||
const GRID_TYPE& currGrid = aScreen.GetGrid();
|
||||
|
||||
auto iter = std::find_if( grids.begin(), grids.end(),
|
||||
[&]( const GRID_TYPE& aCandidate ) { return aCandidate.m_CmdId == currGrid.m_CmdId; } );
|
||||
|
||||
wxCHECK_MSG( iter != grids.end(), {}, "Grid not found in screen's grid list" );
|
||||
|
||||
int index = std::distance( grids.begin(), iter ) + aOffset;
|
||||
|
||||
// If we go off the end, return invalid, but we could also wrap around if wanted.
|
||||
if( index < 0 || static_cast<size_t>( index ) >= grids.size() )
|
||||
return {};
|
||||
|
||||
return grids[index].m_CmdId;
|
||||
}
|
||||
|
||||
|
||||
// Grid control
|
||||
int COMMON_TOOLS::GridNext( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
const OPT<int> next_grid_id = getNextPreviousGrid( *m_frame->GetScreen(), 1 );
|
||||
int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
|
||||
|
||||
if( next_grid_id )
|
||||
return GridPreset( *next_grid_id - ID_POPUP_GRID_LEVEL_1000 );
|
||||
if( currentGrid + 1 < m_grids.size() )
|
||||
currentGrid++;
|
||||
|
||||
return 1;
|
||||
return OnGridChanged();
|
||||
}
|
||||
|
||||
|
||||
int COMMON_TOOLS::GridPrev( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
const OPT<int> next_grid_id = getNextPreviousGrid( *m_frame->GetScreen(), -1 );
|
||||
int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
|
||||
|
||||
if( next_grid_id )
|
||||
return GridPreset( *next_grid_id - ID_POPUP_GRID_LEVEL_1000 );
|
||||
if( currentGrid > 0 )
|
||||
currentGrid--;
|
||||
|
||||
return 1;
|
||||
return OnGridChanged();
|
||||
}
|
||||
|
||||
|
||||
@ -397,27 +381,31 @@ int COMMON_TOOLS::GridPreset( const TOOL_EVENT& aEvent )
|
||||
|
||||
int COMMON_TOOLS::GridPreset( int idx )
|
||||
{
|
||||
BASE_SCREEN* screen = m_frame->GetScreen();
|
||||
int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
|
||||
|
||||
if( !screen->GridExists( idx + ID_POPUP_GRID_LEVEL_1000 ) )
|
||||
idx = 0;
|
||||
currentGrid = std::max( 0, std::min( idx, (int) m_grids.size() - 1 ) );
|
||||
|
||||
screen->SetGrid( idx + ID_POPUP_GRID_LEVEL_1000 );
|
||||
return OnGridChanged();
|
||||
}
|
||||
|
||||
// Be sure m_LastGridSizeId is up to date.
|
||||
m_frame->SetLastGridSizeId( idx );
|
||||
|
||||
int COMMON_TOOLS::OnGridChanged()
|
||||
{
|
||||
int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
|
||||
|
||||
// Update the combobox (if any)
|
||||
wxUpdateUIEvent dummy;
|
||||
m_frame->OnUpdateSelectGrid( dummy );
|
||||
|
||||
// Update GAL canvas from screen
|
||||
getView()->GetGAL()->SetGridSize( VECTOR2D( screen->GetGridSize() ) );
|
||||
getView()->GetGAL()->SetGridSize( m_grids[ currentGrid ] );
|
||||
getView()->GetGAL()->SetGridVisibility( m_toolMgr->GetSettings()->m_Window.grid.show );
|
||||
getView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
||||
|
||||
// Put cursor on new grid
|
||||
VECTOR2D gridCursor = getViewControls()->GetCursorPosition( true );
|
||||
getViewControls()->SetCrossHairCursorPosition( gridCursor, false );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -426,10 +414,6 @@ int COMMON_TOOLS::ToggleGrid( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
m_frame->SetGridVisibility( !m_frame->IsGridVisible() );
|
||||
|
||||
m_frame->GetCanvas()->GetGAL()->SetGridVisibility( m_frame->IsGridVisible() );
|
||||
getView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
||||
m_frame->GetCanvas()->Refresh();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 2015 CERN
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
* Copyright (C) 2015-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.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
|
||||
@ -27,57 +27,89 @@
|
||||
#include <id.h>
|
||||
#include <eda_draw_frame.h>
|
||||
#include <base_screen.h>
|
||||
#include <settings/app_settings.h>
|
||||
#include <tool/actions.h>
|
||||
#include <bitmaps.h>
|
||||
#include <base_units.h>
|
||||
|
||||
#include <functional>
|
||||
using namespace std::placeholders;
|
||||
|
||||
GRID_MENU::GRID_MENU( EDA_DRAW_FRAME* aParent ) :
|
||||
ACTION_MENU( true ),
|
||||
m_parent( aParent )
|
||||
{
|
||||
BASE_SCREEN* screen = m_parent->GetScreen();
|
||||
|
||||
SetTitle( _( "Grid" ) );
|
||||
SetIcon( grid_select_xpm );
|
||||
|
||||
wxArrayString gridsList;
|
||||
screen->BuildGridsChoiceList( gridsList, m_parent->GetUserUnits() != EDA_UNITS::INCHES );
|
||||
APP_SETTINGS_BASE* settings = m_parent->config();
|
||||
wxArrayString gridsList;
|
||||
int i = 0;
|
||||
|
||||
for( unsigned int i = 0; i < gridsList.GetCount(); ++i )
|
||||
{
|
||||
GRID_TYPE& grid = screen->GetGrid( i );
|
||||
Append( grid.m_CmdId, gridsList[i], wxEmptyString, wxITEM_CHECK );
|
||||
}
|
||||
BuildChoiceList( &gridsList, settings, m_parent->GetUserUnits() != EDA_UNITS::INCHES );
|
||||
|
||||
for( const wxString& grid : gridsList )
|
||||
Append( i++, grid, wxEmptyString, wxITEM_CHECK );
|
||||
}
|
||||
|
||||
|
||||
OPT_TOOL_EVENT GRID_MENU::eventHandler( const wxMenuEvent& aEvent )
|
||||
{
|
||||
OPT_TOOL_EVENT event( ACTIONS::gridPreset.MakeEvent() );
|
||||
intptr_t idx = aEvent.GetId() - ID_POPUP_GRID_SELECT - 1;
|
||||
event->SetParameter( idx );
|
||||
|
||||
event->SetParameter( (intptr_t) aEvent.GetId() );
|
||||
return event;
|
||||
}
|
||||
|
||||
|
||||
void GRID_MENU::update()
|
||||
{
|
||||
BASE_SCREEN* screen = m_parent->GetScreen();
|
||||
int currentId = screen->GetGridCmdId();
|
||||
wxArrayString gridsList;
|
||||
APP_SETTINGS_BASE* settings = m_parent->config();
|
||||
int current = settings->m_Window.grid.last_size_idx;
|
||||
wxArrayString gridsList;
|
||||
|
||||
screen->BuildGridsChoiceList( gridsList, m_parent->GetUserUnits() != EDA_UNITS::INCHES );
|
||||
BuildChoiceList( &gridsList, settings, m_parent->GetUserUnits() != EDA_UNITS::INCHES );
|
||||
|
||||
for( unsigned int i = 0; i < GetMenuItemCount(); ++i )
|
||||
{
|
||||
GRID_TYPE& grid = screen->GetGrid( i );
|
||||
wxMenuItem* menuItem = FindItemByPosition( i );
|
||||
|
||||
menuItem->SetId( grid.m_CmdId );
|
||||
menuItem->SetItemLabel( gridsList[ i ] ); // Refresh label in case units have changed
|
||||
menuItem->Check( grid.m_CmdId == currentId ); // Refresh checkmark
|
||||
menuItem->SetItemLabel( gridsList[ i ] ); // Refresh label in case units have changed
|
||||
menuItem->Check( i == current ); // Refresh checkmark
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GRID_MENU::BuildChoiceList( wxArrayString* aGridsList, APP_SETTINGS_BASE* aCfg, bool mmFirst )
|
||||
{
|
||||
wxString msg;
|
||||
|
||||
for( const wxString& gridSize : aCfg->m_Window.grid.sizes )
|
||||
{
|
||||
int val = (int) ValueFromString( EDA_UNITS::MILLIMETRES, gridSize, true );
|
||||
double gridValueMils = To_User_Unit( EDA_UNITS::INCHES, val ) * 1000;
|
||||
double gridValue_mm = To_User_Unit( EDA_UNITS::MILLIMETRES, val );
|
||||
|
||||
if( mmFirst )
|
||||
msg.Printf( _( "Grid: %.4f mm (%.2f mils)" ), gridValue_mm, gridValueMils );
|
||||
else
|
||||
msg.Printf( _( "Grid: %.2f mils (%.4f mm)" ), gridValueMils, gridValue_mm );
|
||||
|
||||
aGridsList->Add( msg );
|
||||
}
|
||||
|
||||
|
||||
if( !aCfg->m_Window.grid.user_grid_x.empty() )
|
||||
{
|
||||
int val = (int) ValueFromString( EDA_UNITS::INCHES, aCfg->m_Window.grid.user_grid_x, true );
|
||||
double gridValueMils = To_User_Unit( EDA_UNITS::INCHES, val ) * 1000;
|
||||
double gridValue_mm = To_User_Unit( EDA_UNITS::MILLIMETRES, val );
|
||||
|
||||
if( mmFirst )
|
||||
msg.Printf( _( "User grid: %.4f mm (%.2f mils)" ), gridValue_mm, gridValueMils );
|
||||
else
|
||||
msg.Printf( _( "User grid: %.2f mils (%.4f mm)" ), gridValueMils, gridValue_mm );
|
||||
|
||||
aGridsList->Add( msg );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1013,12 +1013,14 @@ TOOL_ID TOOL_MANAGER::MakeToolId( const std::string& aToolName )
|
||||
|
||||
|
||||
void TOOL_MANAGER::SetEnvironment( EDA_ITEM* aModel, KIGFX::VIEW* aView,
|
||||
KIGFX::VIEW_CONTROLS* aViewControls, TOOLS_HOLDER* aFrame )
|
||||
KIGFX::VIEW_CONTROLS* aViewControls,
|
||||
APP_SETTINGS_BASE* aSettings, TOOLS_HOLDER* aFrame )
|
||||
{
|
||||
m_model = aModel;
|
||||
m_view = aView;
|
||||
m_viewControls = aViewControls;
|
||||
m_frame = aFrame;
|
||||
m_settings = aSettings;
|
||||
}
|
||||
|
||||
|
||||
|
@ -190,7 +190,7 @@ void CVPCB_MAINFRAME::setupTools()
|
||||
// Create the manager
|
||||
m_actions = new CVPCB_ACTIONS();
|
||||
m_toolManager = new TOOL_MANAGER;
|
||||
m_toolManager->SetEnvironment( nullptr, nullptr, nullptr, this );
|
||||
m_toolManager->SetEnvironment( nullptr, nullptr, nullptr, config(), this );
|
||||
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
|
||||
|
||||
// Register tools
|
||||
|
@ -92,12 +92,6 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa
|
||||
|
||||
LoadSettings( config() );
|
||||
|
||||
// Initialize grid id to a default value if not found in config or incorrect:
|
||||
if( !( GetScreen()->GridExists( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ) ) )
|
||||
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_500 - ID_POPUP_GRID_LEVEL_1000;
|
||||
|
||||
GetScreen()->SetGrid( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 );
|
||||
|
||||
// Initialize some display options
|
||||
auto displ_opts = GetDisplayOptions();
|
||||
displ_opts.m_DisplayPadIsol = false; // Pad clearance has no meaning here
|
||||
@ -109,7 +103,7 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa
|
||||
// Create the manager and dispatcher & route draw panel events to the dispatcher
|
||||
m_toolManager = new TOOL_MANAGER;
|
||||
m_toolManager->SetEnvironment( GetBoard(), gal_drawPanel->GetView(),
|
||||
gal_drawPanel->GetViewControls(), this );
|
||||
gal_drawPanel->GetViewControls(), config(), this );
|
||||
m_actions = new CVPCB_ACTIONS();
|
||||
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
|
||||
gal_drawPanel->SetEventDispatcher( m_toolDispatcher );
|
||||
@ -135,16 +129,11 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa
|
||||
|
||||
m_auimgr.SetManagedWindow( this );
|
||||
|
||||
m_auimgr.AddPane( m_mainToolBar,
|
||||
EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
|
||||
m_auimgr.AddPane( m_optionsToolBar,
|
||||
EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
|
||||
m_auimgr.AddPane( m_infoBar,
|
||||
EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
|
||||
m_auimgr.AddPane( GetCanvas(),
|
||||
EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
|
||||
m_auimgr.AddPane( m_messagePanel,
|
||||
EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
|
||||
m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
|
||||
m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
|
||||
m_auimgr.AddPane( m_infoBar, EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
|
||||
m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
|
||||
m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
|
||||
|
||||
// Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
|
||||
// hidding it.
|
||||
@ -199,7 +188,6 @@ void DISPLAY_FOOTPRINTS_FRAME::OnCloseWindow( wxCloseEvent& event )
|
||||
void DISPLAY_FOOTPRINTS_FRAME::ReCreateVToolbar()
|
||||
{
|
||||
// Currently, no vertical right toolbar.
|
||||
// So do nothing
|
||||
}
|
||||
|
||||
|
||||
@ -280,7 +268,7 @@ void DISPLAY_FOOTPRINTS_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
||||
// We don't allow people to change this right now, so make sure it's on
|
||||
GetWindowSettings( cfg )->cursor.always_show_cursor = true;
|
||||
|
||||
EDA_DRAW_FRAME::LoadSettings( cfg );
|
||||
PCB_BASE_FRAME::LoadSettings( cfg );
|
||||
|
||||
SetDisplayOptions( cfg->m_FootprintViewerDisplayOptions );
|
||||
}
|
||||
@ -291,7 +279,7 @@ void DISPLAY_FOOTPRINTS_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
||||
auto cfg = dynamic_cast<CVPCB_SETTINGS*>( aCfg );
|
||||
wxCHECK( cfg, /* void */ );
|
||||
|
||||
EDA_DRAW_FRAME::SaveSettings( cfg );
|
||||
PCB_BASE_FRAME::SaveSettings( cfg );
|
||||
|
||||
cfg->m_FootprintViewerDisplayOptions = GetDisplayOptions();
|
||||
|
||||
@ -315,17 +303,6 @@ MAGNETIC_SETTINGS* DISPLAY_FOOTPRINTS_FRAME::GetMagneticItemsSettings()
|
||||
}
|
||||
|
||||
|
||||
void DISPLAY_FOOTPRINTS_FRAME::ApplyDisplaySettingsToGAL()
|
||||
{
|
||||
auto painter = static_cast<KIGFX::PCB_PAINTER*>( GetCanvas()->GetView()->GetPainter() );
|
||||
|
||||
painter->GetSettings()->LoadDisplayOptions( GetDisplayOptions(), false );
|
||||
|
||||
GetCanvas()->GetView()->UpdateAllItems( KIGFX::ALL );
|
||||
GetCanvas()->Refresh();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Virtual function needed by the PCB_SCREEN class derived from BASE_SCREEN
|
||||
* this is a virtual pure function in BASE_SCREEN
|
||||
|
@ -76,9 +76,6 @@ public:
|
||||
|
||||
MAGNETIC_SETTINGS* GetMagneticItemsSettings() override;
|
||||
|
||||
/// Updates the GAL with display settings changes
|
||||
void ApplyDisplaySettingsToGAL();
|
||||
|
||||
///> @copydoc EDA_DRAW_FRAME::UpdateMsgPanel()
|
||||
void UpdateMsgPanel() override;
|
||||
|
||||
|
@ -486,8 +486,6 @@ void SCH_PRINTOUT::PrintPage( SCH_SCREEN* aScreen )
|
||||
dc->SetLogicalFunction( wxCOPY );
|
||||
GRResetPenAndBrush( dc );
|
||||
|
||||
aScreen->m_IsPrinting = true;
|
||||
|
||||
COLOR4D savedBgColor = m_parent->GetDrawBgColor();
|
||||
COLOR4D bgColor = m_parent->GetColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND );
|
||||
|
||||
@ -529,7 +527,6 @@ void SCH_PRINTOUT::PrintPage( SCH_SCREEN* aScreen )
|
||||
aScreen->Print( &renderSettings );
|
||||
|
||||
m_parent->SetDrawBgColor( savedBgColor );
|
||||
aScreen->m_IsPrinting = false;
|
||||
|
||||
GRForceBlackPen( false );
|
||||
|
||||
|
@ -23,11 +23,10 @@
|
||||
|
||||
#include <dialog_set_grid_base.h>
|
||||
#include <common.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <settings/app_settings.h>
|
||||
#include <sch_base_frame.h>
|
||||
#include <class_draw_panel_gal.h>
|
||||
#include <sch_view.h>
|
||||
#include <gal/graphics_abstraction_layer.h>
|
||||
|
||||
#include <tool/grid_menu.h>
|
||||
|
||||
class DIALOG_SET_GRID : public DIALOG_SET_GRID_BASE
|
||||
{
|
||||
@ -53,16 +52,16 @@ DIALOG_SET_GRID::DIALOG_SET_GRID( SCH_BASE_FRAME* aParent ):
|
||||
|
||||
bool DIALOG_SET_GRID::TransferDataToWindow()
|
||||
{
|
||||
const GRIDS& gridSizes = m_frame->GetScreen()->GetGrids();
|
||||
int idx = m_frame->config()->m_Window.grid.last_size_idx;
|
||||
wxArrayString grids;
|
||||
|
||||
for( size_t i = 0; i < gridSizes.size(); i++ )
|
||||
{
|
||||
m_choiceGridSize->Append( wxString::Format( "%0.1f",
|
||||
static_cast<float>( Iu2Mils( gridSizes[i].m_Size.x ) ) ) );
|
||||
GRID_MENU::BuildChoiceList( &grids, m_frame->config(), GetUserUnits() != EDA_UNITS::INCHES );
|
||||
|
||||
if( gridSizes[i].m_CmdId == m_frame->GetScreen()->GetGridCmdId() )
|
||||
m_choiceGridSize->SetSelection( (int) i );
|
||||
}
|
||||
for( const wxString& grid : grids )
|
||||
m_choiceGridSize->Append( grid );
|
||||
|
||||
if( idx >= 0 && idx < m_choiceGridSize->GetCount() )
|
||||
m_choiceGridSize->SetSelection( idx );
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -70,12 +69,9 @@ bool DIALOG_SET_GRID::TransferDataToWindow()
|
||||
|
||||
bool DIALOG_SET_GRID::TransferDataFromWindow()
|
||||
{
|
||||
const GRIDS& gridSizes = m_frame->GetScreen()->GetGrids();
|
||||
wxRealPoint gridSize = gridSizes[ (size_t) m_choiceGridSize->GetSelection() ].m_Size;
|
||||
m_frame->SetLastGridSizeId( m_frame->GetScreen()->SetGrid( gridSize ) );
|
||||
int idx = m_choiceGridSize->GetSelection();
|
||||
|
||||
m_frame->GetCanvas()->GetView()->GetGAL()->SetGridSize( VECTOR2D( gridSize ) );
|
||||
m_frame->GetCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
||||
m_frame->GetToolManager()->RunAction( "common.Control.gridPreset", true, idx );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -416,23 +416,44 @@ void SCH_BASE_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
||||
|
||||
EDA_DRAW_FRAME::LoadSettings( aCfg );
|
||||
|
||||
if( eeconfig() )
|
||||
EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( aCfg );
|
||||
wxCHECK( cfg, /*void*/ );
|
||||
|
||||
if( cfg->m_Window.grid.sizes.empty() )
|
||||
{
|
||||
wxString templateFieldNames = eeconfig()->m_Drawing.field_names;
|
||||
/*
|
||||
* Do NOT add others values (mainly grid values in mm), because they can break the
|
||||
* schematic: Because wires and pins are considered as connected when the are to the
|
||||
* same coordinate we cannot mix coordinates in mils (internal units) and mm (that
|
||||
* cannot exactly converted in mils in many cases). In fact schematic must only use
|
||||
* 50 and 25 mils to place labels, wires and components others values are useful only
|
||||
* for graphic items (mainly in library editor) so use integer values in mils only.
|
||||
* The 100 mil grid is added to help conform to the KiCad Library Convention which
|
||||
* states: "Using a 100mil grid, pin ends and origin must lie on grid nodes IEC-60617"
|
||||
*/
|
||||
cfg->m_Window.grid.sizes = { "100 mil",
|
||||
"50 mil",
|
||||
"25 mil",
|
||||
"10 mil",
|
||||
"5 mil",
|
||||
"2 mil",
|
||||
"1 mil" };
|
||||
}
|
||||
|
||||
if( !templateFieldNames.IsEmpty() )
|
||||
wxString templateFieldNames = cfg->m_Drawing.field_names;
|
||||
|
||||
if( !templateFieldNames.IsEmpty() )
|
||||
{
|
||||
TEMPLATE_FIELDNAMES_LEXER lexer( TO_UTF8( templateFieldNames ) );
|
||||
|
||||
try
|
||||
{
|
||||
TEMPLATE_FIELDNAMES_LEXER lexer( TO_UTF8( templateFieldNames ) );
|
||||
|
||||
try
|
||||
{
|
||||
m_templateFieldNames.Parse( &lexer, true );
|
||||
}
|
||||
catch( const IO_ERROR& DBG( e ) )
|
||||
{
|
||||
// @todo show error msg
|
||||
DBG( printf( "templatefieldnames parsing error: '%s'\n", TO_UTF8( e.What() ) ); )
|
||||
}
|
||||
m_templateFieldNames.Parse( &lexer, true );
|
||||
}
|
||||
catch( const IO_ERROR& DBG( e ) )
|
||||
{
|
||||
// @todo show error msg
|
||||
DBG( printf( "templatefieldnames parsing error: '%s'\n", TO_UTF8( e.What() ) ); )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -481,7 +481,6 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
||||
GetScreen()->m_Initialized = true;
|
||||
}
|
||||
|
||||
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
|
||||
m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
|
||||
SetSheetNumberAndCount();
|
||||
|
||||
@ -538,7 +537,6 @@ bool SCH_EDIT_FRAME::AppendSchematic()
|
||||
SCH_SCREENS screens( GetCurrentSheet().Last() );
|
||||
screens.TestDanglingEnds();
|
||||
|
||||
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
|
||||
m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
|
||||
SetSheetNumberAndCount();
|
||||
|
||||
@ -844,7 +842,6 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
|
||||
|
||||
GetScreen()->ClearUndoORRedoList( GetScreen()->m_UndoList, 1 );
|
||||
|
||||
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
|
||||
m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
|
||||
SetSheetNumberAndCount();
|
||||
SyncView();
|
||||
|
@ -235,10 +235,7 @@ void SCH_EDIT_FRAME::DisplayCurrentSheet()
|
||||
|
||||
wxASSERT( screen );
|
||||
|
||||
// Switch to current sheet,
|
||||
// and update the grid size, because it can be modified in latest screen
|
||||
SetScreen( screen );
|
||||
GetScreen()->SetGrid( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 );
|
||||
|
||||
// update the References
|
||||
GetCurrentSheet().UpdateAllScreenReferences();
|
||||
|
@ -126,9 +126,6 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
|
||||
m_cmpListWidth = 300;
|
||||
m_listPowerCmpOnly = false;
|
||||
|
||||
// Initialize grid id to the default value (50 mils):
|
||||
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000;
|
||||
|
||||
SetScreen( new SCH_SCREEN );
|
||||
GetScreen()->m_Center = true; // Axis origin centered on screen.
|
||||
LoadSettings( config() );
|
||||
@ -137,7 +134,6 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
|
||||
KIGFX::GAL_DISPLAY_OPTIONS& gal_opts = GetGalDisplayOptions();
|
||||
gal_opts.m_axesEnabled = true;
|
||||
GetCanvas()->GetGAL()->SetAxesEnabled( true );
|
||||
GetCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() );
|
||||
|
||||
GetRenderSettings()->m_ShowHiddenText = true;
|
||||
GetRenderSettings()->m_ShowHiddenPins = true;
|
||||
@ -188,8 +184,6 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
|
||||
|
||||
m_auimgr.Update();
|
||||
|
||||
GetToolManager()->RunAction( ACTIONS::gridPreset, true, m_LastGridSizeId );
|
||||
|
||||
if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame
|
||||
{
|
||||
Raise();
|
||||
@ -228,7 +222,7 @@ void LIB_VIEW_FRAME::setupTools()
|
||||
// Create the manager and dispatcher & route draw panel events to the dispatcher
|
||||
m_toolManager = new TOOL_MANAGER;
|
||||
m_toolManager->SetEnvironment( GetScreen(), GetCanvas()->GetView(),
|
||||
GetCanvas()->GetViewControls(), this );
|
||||
GetCanvas()->GetViewControls(), config(), this );
|
||||
m_actions = new EE_ACTIONS();
|
||||
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
|
||||
|
||||
@ -618,7 +612,7 @@ void LIB_VIEW_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
||||
{
|
||||
auto cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
|
||||
|
||||
EDA_DRAW_FRAME::LoadSettings( cfg );
|
||||
SCH_BASE_FRAME::LoadSettings( cfg );
|
||||
|
||||
// Grid shape, etc.
|
||||
GetGalDisplayOptions().ReadWindowSettings( cfg->m_LibViewPanel.window );
|
||||
@ -641,7 +635,7 @@ void LIB_VIEW_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg)
|
||||
{
|
||||
EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
|
||||
|
||||
EDA_DRAW_FRAME::SaveSettings( cfg );
|
||||
SCH_BASE_FRAME::SaveSettings( cfg );
|
||||
|
||||
if( m_libListWidth && m_libList )
|
||||
m_libListWidth = m_libList->GetSize().x;
|
||||
|
@ -103,9 +103,6 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||
m_convert = 1;
|
||||
m_AboutTitle = "LibEdit";
|
||||
|
||||
// Initialize grid id to the default value 50 mils:
|
||||
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000;
|
||||
|
||||
wxIcon icon;
|
||||
icon.CopyFromBitmap( KiBitmap( icon_libedit_xpm ) );
|
||||
SetIcon( icon );
|
||||
@ -168,15 +165,12 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||
m_auimgr.GetPane( "InfoBar" ).Hide();
|
||||
m_auimgr.Update();
|
||||
|
||||
GetToolManager()->RunAction( "common.Control.gridPreset", true, m_LastGridSizeId );
|
||||
|
||||
Raise();
|
||||
Show( true );
|
||||
|
||||
SyncView();
|
||||
GetCanvas()->GetViewControls()->SetSnapping( true );
|
||||
GetCanvas()->GetView()->UseDrawPriority( true );
|
||||
GetCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() );
|
||||
GetCanvas()->GetGAL()->SetAxesEnabled( true );
|
||||
|
||||
// Set the working/draw area size to display a symbol to a reasonable value:
|
||||
@ -255,7 +249,7 @@ void LIB_EDIT_FRAME::setupTools()
|
||||
// Create the manager and dispatcher & route draw panel events to the dispatcher
|
||||
m_toolManager = new TOOL_MANAGER;
|
||||
m_toolManager->SetEnvironment( GetScreen(), GetCanvas()->GetView(),
|
||||
GetCanvas()->GetViewControls(), this );
|
||||
GetCanvas()->GetViewControls(), config(), this );
|
||||
m_actions = new EE_ACTIONS();
|
||||
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
|
||||
|
||||
|
@ -34,15 +34,11 @@
|
||||
#include <class_library.h>
|
||||
#include <template_fieldnames.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <lib_manager.h>
|
||||
#include <symbol_tree_pane.h>
|
||||
#include <widgets/lib_tree.h>
|
||||
#include <sch_legacy_plugin.h>
|
||||
#include <dialog_choose_component.h>
|
||||
#include <symbol_tree_model_adapter.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <dialogs/dialog_lib_new_component.h>
|
||||
#include <dialog_helpers.h>
|
||||
#include <wx/clipbrd.h>
|
||||
@ -200,23 +196,6 @@ bool LIB_EDIT_FRAME::LoadComponentFromCurrentLib( const wxString& aAliasName, in
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronize screen settings from a current screen into another screen.
|
||||
*
|
||||
* This can be used, for example, when loading a new screen into a frame,
|
||||
* but you want the new screen to inherit some settings (e.g. grids) from the
|
||||
* frame's current screen.
|
||||
*
|
||||
* @param aCurrentScreen the existing frame screen
|
||||
* @param aIncomingScreen a screen that is intended to replace the current screen
|
||||
*/
|
||||
static void synchronizeLibEditScreenSettings( const SCH_SCREEN& aCurrentScreen,
|
||||
SCH_SCREEN& aIncomingScreen )
|
||||
{
|
||||
aIncomingScreen.SetGrid( aCurrentScreen.GetGridSize() );
|
||||
}
|
||||
|
||||
|
||||
bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_PART* aEntry, const wxString& aLibrary,
|
||||
int aUnit, int aConvert )
|
||||
{
|
||||
@ -240,14 +219,6 @@ bool LIB_EDIT_FRAME::LoadOneLibraryPartAux( LIB_PART* aEntry, const wxString& aL
|
||||
// The buffered screen for the part
|
||||
SCH_SCREEN* part_screen = m_libMgr->GetScreen( lib_part->GetName(), aLibrary );
|
||||
|
||||
const SCH_SCREEN* curr_screen = GetScreen();
|
||||
|
||||
// Before we set the frame screen, transfer any settings from the current
|
||||
// screen that we want to keep to the incoming (buffered) part's screen
|
||||
// which could be out of date relative to the current screen.
|
||||
if( curr_screen )
|
||||
synchronizeLibEditScreenSettings( *curr_screen, *part_screen );
|
||||
|
||||
SetScreen( part_screen );
|
||||
SetCurPart( new LIB_PART( *lib_part ) );
|
||||
SetCurLib( aLibrary );
|
||||
|
@ -442,8 +442,6 @@ void SCH_BASE_FRAME::RemoveFromScreen( EDA_ITEM* aItem, SCH_SCREEN* aScreen )
|
||||
|
||||
void SCH_BASE_FRAME::SyncView()
|
||||
{
|
||||
auto gs = GetScreen()->GetGridSize();
|
||||
GetCanvas()->GetGAL()->SetGridSize( VECTOR2D( gs.x, gs.y ));
|
||||
GetCanvas()->GetView()->UpdateAllItems( KIGFX::ALL );
|
||||
}
|
||||
|
||||
|
@ -137,18 +137,10 @@ void SCH_DRAW_PANEL::setDefaultLayerOrder()
|
||||
|
||||
bool SCH_DRAW_PANEL::SwitchBackend( GAL_TYPE aGalType )
|
||||
{
|
||||
VECTOR2D grid_size = m_gal->GetGridSize();
|
||||
bool rv = EDA_DRAW_PANEL_GAL::SwitchBackend( aGalType );
|
||||
setDefaultLayerDeps();
|
||||
m_gal->SetWorldUnitLength( SCH_WORLD_UNIT );
|
||||
|
||||
// Keep grid size and grid visibility:
|
||||
m_gal->SetGridSize( grid_size );
|
||||
SCH_BASE_FRAME* frame = dynamic_cast<SCH_BASE_FRAME*>( GetParentEDAFrame() );
|
||||
|
||||
if( frame )
|
||||
m_gal->SetGridVisibility( frame->IsGridVisible() );
|
||||
|
||||
Refresh();
|
||||
|
||||
return rv;
|
||||
|
@ -226,9 +226,6 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
|
||||
icon.CopyFromBitmap( KiBitmap( icon_eeschema_xpm ) );
|
||||
SetIcon( icon );
|
||||
|
||||
// Initialize grid id to the default value (50 mils):
|
||||
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000;
|
||||
|
||||
LoadSettings( eeconfig() );
|
||||
|
||||
CreateScreens();
|
||||
@ -273,12 +270,8 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
|
||||
|
||||
GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true );
|
||||
|
||||
// Init grid size and visibility
|
||||
GetToolManager()->RunAction( ACTIONS::gridPreset, true, m_LastGridSizeId );
|
||||
|
||||
if( GetCanvas() )
|
||||
{
|
||||
GetCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() );
|
||||
GetCanvas()->GetGAL()->SetAxesEnabled( false );
|
||||
|
||||
if( auto p = dynamic_cast<KIGFX::SCH_PAINTER*>( GetCanvas()->GetView()->GetPainter() ) )
|
||||
@ -319,7 +312,7 @@ void SCH_EDIT_FRAME::setupTools()
|
||||
// Create the manager and dispatcher & route draw panel events to the dispatcher
|
||||
m_toolManager = new TOOL_MANAGER;
|
||||
m_toolManager->SetEnvironment( &Schematic(), GetCanvas()->GetView(),
|
||||
GetCanvas()->GetViewControls(), this );
|
||||
GetCanvas()->GetViewControls(), config(), this );
|
||||
m_actions = new EE_ACTIONS();
|
||||
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
|
||||
|
||||
|
@ -66,7 +66,6 @@
|
||||
// TODO(JE) Debugging only
|
||||
#include <profile.h>
|
||||
|
||||
#define EESCHEMA_FILE_STAMP "EESchema"
|
||||
#define ZOOM_FACTOR( x ) ( x * IU_PER_MILS )
|
||||
|
||||
|
||||
@ -97,29 +96,6 @@ static double SchematicZoomList[] =
|
||||
};
|
||||
|
||||
|
||||
/* Default grid sizes for the schematic editor.
|
||||
* Do NOT add others values (mainly grid values in mm), because they
|
||||
* can break the schematic: Because wires and pins are considered as
|
||||
* connected when the are to the same coordinate we cannot mix
|
||||
* coordinates in mils (internal units) and mm (that cannot exactly
|
||||
* converted in mils in many cases). In fact schematic must only use
|
||||
* 50 and 25 mils to place labels, wires and components others values
|
||||
* are useful only for graphic items (mainly in library editor) so use
|
||||
* integer values in mils only. The 100 mil grid is added to help
|
||||
* conform to the KiCad Library Convention. Which states: "Using a
|
||||
* 100mil grid, pin ends and origin must lie on grid nodes IEC-60617"
|
||||
*/
|
||||
static GRID_TYPE SchematicGridList[] = {
|
||||
{ ID_POPUP_GRID_LEVEL_100, wxRealPoint( Mils2iu( 100 ), Mils2iu( 100 ) ) },
|
||||
{ ID_POPUP_GRID_LEVEL_50, wxRealPoint( Mils2iu( 50 ), Mils2iu( 50 ) ) },
|
||||
{ ID_POPUP_GRID_LEVEL_25, wxRealPoint( Mils2iu( 25 ), Mils2iu( 25 ) ) },
|
||||
{ ID_POPUP_GRID_LEVEL_10, wxRealPoint( Mils2iu( 10 ), Mils2iu( 10 ) ) },
|
||||
{ ID_POPUP_GRID_LEVEL_5, wxRealPoint( Mils2iu( 5 ), Mils2iu( 5 ) ) },
|
||||
{ ID_POPUP_GRID_LEVEL_2, wxRealPoint( Mils2iu( 2 ), Mils2iu( 2 ) ) },
|
||||
{ ID_POPUP_GRID_LEVEL_1, wxRealPoint( Mils2iu( 1 ), Mils2iu( 1 ) ) },
|
||||
};
|
||||
|
||||
|
||||
SCH_SCREEN::SCH_SCREEN( EDA_ITEM* aParent ) :
|
||||
BASE_SCREEN( aParent, SCH_SCREEN_T ),
|
||||
m_paper( wxT( "A4" ) )
|
||||
@ -131,12 +107,6 @@ SCH_SCREEN::SCH_SCREEN( EDA_ITEM* aParent ) :
|
||||
for( unsigned zoom : SchematicZoomList )
|
||||
m_ZoomList.push_back( zoom );
|
||||
|
||||
for( GRID_TYPE grid : SchematicGridList )
|
||||
AddGrid( grid );
|
||||
|
||||
// Set the default grid size, now that the grid list is populated
|
||||
SetGrid( wxRealPoint( Mils2iu( 50 ), Mils2iu( 50 ) ) );
|
||||
|
||||
m_refCount = 0;
|
||||
|
||||
// Suitable for schematic only. For libedit and viewlib, must be set to true
|
||||
|
@ -115,7 +115,7 @@ private:
|
||||
/// Origin of the auxiliary axis, which is used in exports mostly, but not yet in EESCHEMA
|
||||
wxPoint m_aux_origin;
|
||||
|
||||
EE_RTREE m_rtree;
|
||||
EE_RTREE m_rtree;
|
||||
|
||||
int m_modification_sync; ///< inequality with PART_LIBS::GetModificationHash()
|
||||
///< will trigger ResolveAll().
|
||||
@ -159,15 +159,8 @@ public:
|
||||
|
||||
SCHEMATIC* Schematic() const;
|
||||
|
||||
EE_RTREE& Items()
|
||||
{
|
||||
return m_rtree;
|
||||
}
|
||||
|
||||
const EE_RTREE& Items() const
|
||||
{
|
||||
return m_rtree;
|
||||
}
|
||||
EE_RTREE& Items() { return m_rtree; }
|
||||
const EE_RTREE& Items() const { return m_rtree; }
|
||||
|
||||
bool IsEmpty()
|
||||
{
|
||||
@ -203,9 +196,7 @@ public:
|
||||
void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) { m_titles = aTitleBlock; }
|
||||
|
||||
void DecRefCount();
|
||||
|
||||
void IncRefCount();
|
||||
|
||||
int GetRefCount() const { return m_refCount; }
|
||||
|
||||
/**
|
||||
@ -254,8 +245,8 @@ public:
|
||||
* @param aType The type of item to find.
|
||||
* @return The item found that meets the search criteria or NULL if none found.
|
||||
*/
|
||||
SCH_ITEM* GetItem(
|
||||
const wxPoint& aPosition, int aAccuracy = 0, KICAD_T aType = SCH_LOCATE_ANY_T );
|
||||
SCH_ITEM* GetItem( const wxPoint& aPosition, int aAccuracy = 0,
|
||||
KICAD_T aType = SCH_LOCATE_ANY_T );
|
||||
|
||||
void Place( SCH_EDIT_FRAME* frame, wxDC* DC ) { };
|
||||
|
||||
@ -405,7 +396,7 @@ public:
|
||||
* @return The pin item if found, otherwise NULL.
|
||||
*/
|
||||
LIB_PIN* GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponent = NULL,
|
||||
bool aEndPointOnly = false );
|
||||
bool aEndPointOnly = false );
|
||||
|
||||
/**
|
||||
* Test the screen if \a aPosition is a sheet label object.
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user