1。kicad启动:
single_top.cpp
启动函数:
1。
IMPLEMENT_APP( APP_SINGLE_TOP )
2。
PGM_SINGLE_TOP::OnPgmInit()
3。
PGM_BASE::InitPgm
2。kicad参数
grid参数定义:
struct GRID_SETTINGS
{
bool axes_enabled;
std::vector<wxString> sizes;
wxString user_grid_x;
wxString user_grid_y;
int last_size_idx;
int fast_grid_1;
int fast_grid_2;
double line_width;
double min_spacing;
bool show;
int style;
int snap;
};
grid参数配置文件:
kicad.json
symbol_editor.json
eeschema.json
"window": {
"cursor": {
"always_show_cursor": true,
"fullscreen_cursor": false
},
"display": 0,
"grid": {
"axes_enabled": false,
"fast_grid_1": 1,
"fast_grid_2": 2,
"last_size": 0,
"line_width": 1.0,
"min_spacing": 10.0,
"show": true,
"snap": 0,
"style": 0,
"user_grid_x": "10 mil",
"user_grid_y": "10 mil"
},
2.1 启动时设置grid参数:
APP_SETTINGS_BASE::addParamsForWindow()
中设置参数:
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.last_size",
&aWindow->grid.last_size_idx, defaultGridIdx ) );
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.fast_grid_1",
&aWindow->grid.fast_grid_1, defaultGridIdx ) );
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.fast_grid_2",
&aWindow->grid.fast_grid_2, defaultGridIdx + 1 ) );
APP_SETTINGS_BASE::migrateWindowConfig()
ret &= fromLegacy<int>( aCfg, aFrame + "_LastGridSize", gridPath + ".last_size" );
ret &= fromLegacy<int>( aCfg, aFrame + "FastGrid1", gridPath + ".fast_grid_1" );
ret &= fromLegacy<int>( aCfg, aFrame + "FastGrid2", gridPath + ".fast_grid_2" );
2.2启动的时候调用onGridchange事件
2.3 使用时,鼠标右键–>Grid,切换grid
调用OnGrid()函数:
int COMMON_TOOLS::GridPreset( int idx )
{
int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx;
currentGrid = std::max( 0, std::min( idx, (int) m_grids.size() - 1 ) );
return OnGridChanged();
}
启动GridPreset事件:
m_toolManager->RunAction( ACTIONS::gridPreset, true, static_cast<intptr_t>( idx ) );