KiCad PCB EDA Suite
reannotate.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2020 Brian Piccioni brian@documenteddesigns.com
5  * Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #include <sch_edit_frame.h>
26 #include <tools/backannotate.h>
27 #include <reannotate.h>
28 
29 
31  m_MinSeverity( aSeverity )
32 {
33 
34 }
35 
36 
38 {
39 }
40 
41 
42 REPORTER& WX_STRING_REPORTER_FILTERED::Report( const wxString &aText, SEVERITY aSeverity )
43 {
44  if ( aSeverity < m_MinSeverity )
45  return *this;
46 
47  m_string << aText << "\n";
48  return *this;
49 }
50 
51 
53 {
54  return !m_string.IsEmpty();
55 }
56 
57 
58 void ReannotateFromPCBNew( SCH_EDIT_FRAME* aFrame, std::string& aNetlist )
59 {
60  wxString annotateerrors;
62 
63  BACK_ANNOTATE backAnno( aFrame,
64  reporter,
65  false, //aRelinkFootprints
66  false, //aProcessFootprints
67  false, //aProcessValues
68  true, //aProcessReferences
69  false, //aProcessNetNames
70  false ); //aDryRun
71 
72  if( !backAnno.BackAnnotateSymbols( aNetlist ) )
73  {
74  aNetlist = _( "Errors reported by Eeschema:\n" )
75  + reporter.m_string.ToStdString(); //Assume the worst
76  aNetlist += _( "\nAnnotation not performed!\n" );
77  }
78  else
79  {
80  aNetlist.clear(); //Empty means good
81  }
82 
84  aFrame->SetSheetNumberAndCount();
85  aFrame->SyncView();
86  aFrame->OnModify();
87  aFrame->GetCanvas()->Refresh();
88 }
SEVERITY
Definition: ui_common.h:76
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Function Report is a pure virtual function to override in the derived object.
Definition: reannotate.cpp:42
Schematic editor (Eeschema) main window.
REPORTER is a pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:64
void UpdateAllScreenReferences()
Update all the symbol references for this sheet path.
bool BackAnnotateSymbols(const std::string &aNetlist)
Run back annotation algorithm.
void SyncView()
Mark all items for refresh.
void ReannotateFromPCBNew(SCH_EDIT_FRAME *aFrame, std::string &aNetlist)
Backannotate the schematic with a netlist sent from PCBNew.
Definition: reannotate.cpp:58
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
bool HasMessage() const override
Function HasMessage Returns true if the reporter client is non-empty.
Definition: reannotate.cpp:52
Class WX_STRING_REPORTER is a wrapper for reporting to a wxString object.
Definition: reannotate.h:33
virtual ~WX_STRING_REPORTER_FILTERED()
Definition: reannotate.cpp:37
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
WX_STRING_REPORTER_FILTERED(SEVERITY aSeverity)
Definition: reannotate.cpp:30
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
#define _(s)
Definition: 3d_actions.cpp:33
Back annotation algorithm class used to recieve, check, and apply a NETLIST from PCBNEW.
Definition: backannotate.h:55
SCH_SHEET_PATH & GetCurrentSheet() const
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...