kicad源代码研究:参照Candence实现工程管理
创建工程:
创建工程和打开工程触发事件:
KICAD_MANAGER_ACTIONS::newProject
KICAD_MANAGER_ACTIONS::openProject
newProject和OpenProject事件响应具体实现,在KICAD_MANAGER_CONTROL类中实现:
Go( &KICAD_MANAGER_CONTROL::NewProject, KICAD_MANAGER_ACTIONS::newProject.MakeEvent() );
KICAD_MANAGER_CONTROL::NewProject中的具体实现中调用了KICAD_MANAGER_FRAME的CreateNewProject和LoadProject。
KICAD_MANAGER_FRAME* m_frame;m_frame->CreateNewProject( pro );m_frame->LoadProject( pro );
ProjectTree页面创建
创建ProjectTree在kiaca/kicad_manager_frame.cpp中是实现,
m_leftWin = new PROJECT_TREE_PANE( this );
btdabs/PROJECT_TREE_PANEZ
void PROJECT_TREE_PANE::ReCreateTreePrj()
project treee右键事件
void PROJECT_TREE_PANE::onRight( wxTreeEvent& Event )
创建sch工程文件:
void BTDABS_MANAGER_FRAME::CreateSchFile(const wxFileName& aProjectFileName)
{wxFileName fn( aProjectFileName.GetFullPath() );fn.SetExt( BTDSchematicFileExtension );// If a <project>.btd_sch file does not exist, create a "stub" file ( minimal schematic// file ).if( !fn.FileExists() ){wxFFile file( fn.GetFullPath(), "wb" );if( file.IsOpened() )file.Write( wxString::Format( "(btd_sch (version %d) (generator eeschema)\n"" (paper \"A4\")\n (lib_symbols)\n"" (symbol_instances)\n)\n",SEXPR_SCHEMATIC_FILE_VERSION ) );// wxFFile dtor will close the file}
}
int KICAD_MANAGER_CONTROL::CreateSch( const TOOL_EVENT& aEvent )
{auto fileName = Prj().GetProjectFullName();if(false == fileName.IsEmpty()){m_frame->CreateSchFile(fileName);}return 0;
}
FlowManager
/kicad/FLOW_MANAGER_MODEL类:
void FLOW_MANAGER_MODEL::RebuildFlow()
{
CreateFlowNode( wxID_ANY, _("Create"), "", false, parentNode, &KICAD_MANAGER_ACTIONS::createSch );
KICAD_MANAGER_ACTIONS::createSch
createSch事件的响应函数:
Go( &KICAD_MANAGER_CONTROL::CreateSch, KICAD_MANAGER_ACTIONS::createSch.MakeEvent() );
在指定路径创建文件夹
wxString absWorkDir;wxFileName dirName( absWorkDir + wxFileName::GetPathSeparator());if( !dirName.DirExists() ){if( !dirName.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL | wxPATH_RMDIR_RECURSIVE ) ){wxLogMessage( "Failed to create directory: %s", absWorkDir );return "";}}