/* * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2019-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 * 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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "drc_proto.h" PROJECT_CONTEXT loadKicadProject( wxString filename, OPT rulesFilePath ) { PROJECT_CONTEXT rv; auto &manager = Pgm().GetSettingsManager(); wxFileName pro( filename ); wxFileName brdName ( filename ); wxFileName schName ( filename ); wxFileName ruleFileName ( filename ); pro.SetExt( ProjectFileExtension ); brdName.SetExt( KiCadPcbFileExtension ); schName.SetExt( KiCadSchematicFileExtension ); ruleFileName.SetExt( DesignRulesFileExtension ); brdName.MakeAbsolute(); schName.MakeAbsolute(); ruleFileName.MakeAbsolute(); pro.MakeAbsolute(); manager.LoadProject( pro.GetFullPath() ); rv.project = &manager.Prj(); rv.board.reset( KI_TEST::ReadBoardFromFileOrStream( std::string( brdName.GetFullPath().ToUTF8() ) ).release() ); rv.board->SetProject( rv.project ); if( rulesFilePath ) rv.rulesFilePath = *rulesFilePath; else rv.rulesFilePath = ruleFileName.GetFullPath(); if( wxFileExists( schName.GetFullPath() ) ) { //printf("Generating SCH netlist for '%s'\n", (const char*) schName.GetFullPath() ); //rv.netlist.reset( new NETLIST ); //generateSchematicNetlist( schName.GetFullPath(), *rv.netlist.get() ); } return rv; } int runDRCProto( PROJECT_CONTEXT project, std::shared_ptr aDebugOverlay ) { std::shared_ptr drcEngine( new DRC_ENGINE ); CONSOLE_LOG consoleLog; project.board->GetDesignSettings().m_DRCEngine = drcEngine; drcEngine->SetBoard( project.board.get() ); drcEngine->SetDesignSettings( &project.board->GetDesignSettings() ); drcEngine->SetLogReporter( new CONSOLE_MSG_REPORTER ( &consoleLog ) ); drcEngine->SetProgressReporter( new CONSOLE_PROGRESS_REPORTER ( &consoleLog ) ); drcEngine->SetViolationHandler( [&]( const std::shared_ptr& aItem, wxPoint aPos ) { // fixme } ); drcEngine->InitEngine( project.rulesFilePath ); drcEngine->SetDebugOverlay( aDebugOverlay ); for( auto provider : drcEngine->GetTestProviders() ) { //if( provider->GetName() == "diff_pair_coupling" ) // provider->Enable(true); //else // provider->Enable(false); } drcEngine->RunTests( EDA_UNITS::MILLIMETRES, true, false ); return 0; }