KiCad PCB EDA Suite
eeschema/cross-probing.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) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
6  * Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #include <kiface_i.h>
27 #include <kiway_express.h>
28 #include <eda_dde.h>
29 #include <connection_graph.h>
30 #include <sch_component.h>
31 #include <schematic.h>
32 #include <reporter.h>
33 #include <kicad_string.h>
35 #include <project/project_file.h>
36 #include <project/net_settings.h>
37 #include <tools/ee_actions.h>
38 #include <tools/reannotate.h>
40 #include <advanced_config.h>
41 #include <netclass.h>
42 
44  bool aSearchHierarchy,
45  SCH_SEARCH_T aSearchType,
46  const wxString& aSearchText )
47 {
48  SCH_SHEET_PATH* sheetWithComponentFound = NULL;
49  SCH_COMPONENT* component = NULL;
50  wxPoint pos;
51  SCH_PIN* pin = nullptr;
52  SCH_SHEET_LIST sheetList;
53  SCH_ITEM* foundItem = nullptr;
54 
55  if( !aSearchHierarchy )
56  sheetList.push_back( m_frame->GetCurrentSheet() );
57  else
58  sheetList = m_frame->Schematic().GetSheets();
59 
60  for( SCH_SHEET_PATH& sheet : sheetList )
61  {
62  SCH_SCREEN* screen = sheet.LastScreen();
63 
64  for( auto item : screen->Items().OfType( SCH_COMPONENT_T ) )
65  {
66  SCH_COMPONENT* candidate = static_cast<SCH_COMPONENT*>( item );
67 
68  if( aReference.CmpNoCase( candidate->GetRef( &sheet ) ) == 0 )
69  {
70  component = candidate;
71  sheetWithComponentFound = &sheet;
72 
73  if( aSearchType == HIGHLIGHT_PIN )
74  {
75  pos = component->GetPosition(); // temporary: will be changed if the pin is found.
76  pin = component->GetPin( aSearchText );
77 
78  if( pin )
79  {
80  pos = pin->GetPosition();
81  foundItem = component;
82  break;
83  }
84  }
85  else
86  {
87  pos = component->GetPosition();
88  foundItem = component;
89  break;
90  }
91  }
92  }
93 
94  if( foundItem )
95  break;
96  }
97 
98  CROSS_PROBING_SETTINGS& crossProbingSettings = m_frame->eeconfig()->m_CrossProbing;
99 
100 
101  if( component )
102  {
103  if( *sheetWithComponentFound != m_frame->GetCurrentSheet() )
104  {
105  m_frame->Schematic().SetCurrentSheet( *sheetWithComponentFound );
107  }
108 
109  wxPoint delta;
110  pos -= component->GetPosition();
111  delta = component->GetTransform().TransformCoordinate( pos );
112  pos = delta + component->GetPosition();
113 
114  if( crossProbingSettings.center_on_items )
115  {
117  m_frame->CenterScreen( pos, false );
118 
119  if( crossProbingSettings.zoom_to_fit )
120  {
121 //#define COMP_1_TO_1_RATIO // Un-comment for normal KiCad full screen zoom cross-probe
122 #ifdef COMP_1_TO_1_RATIO
123  // Pass "false" to only include visible fields of component in bbox calculations
124  EDA_RECT bbox = component->GetBoundingBox( false );
125  wxSize bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize();
126  VECTOR2D screenSize = getView()->GetViewport().GetSize();
127 
128  // NOTE: The 1:1 here is using the default KiCad sizing, which adds a margin of 20%
129 
130  screenSize.x = std::max( 10.0, screenSize.x );
131  screenSize.y = std::max( 10.0, screenSize.y );
132  double ratio = std::max(
133  fabs( bbSize.x / screenSize.x ), fabs( bbSize.y / screenSize.y ) );
134 
135  // Try not to zoom on every cross-probe; it gets very noisy
136  if( ratio < 0.5 || ratio > 1.0 )
137  getView()->SetScale( getView()->GetScale() / ratio );
138 #endif // COMP_1_TO_1_RATIO
139 
140 #ifndef COMP_1_TO_1_RATIO // Do the scaled zoom
141  // Pass "false" to only include visible fields of component in bbox calculations
142  EDA_RECT bbox = component->GetBoundingBox( false );
143  wxSize bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize();
144  VECTOR2D screenSize = getView()->GetViewport().GetSize();
145 
146  // This code tries to come up with a zoom factor that doesn't simply zoom in
147  // to the cross probed component, but instead shows a reasonable amount of the
148  // circuit around it to provide context. This reduces or eliminates the need
149  // to manually change the zoom because it's too close.
150 
151  // Using the default text height as a constant to compare against, use the
152  // height of the bounding box of visible items for a footprint to figure out
153  // if this is a big symbol (like a processor) or a small symbol (like a resistor).
154  // This ratio is not useful by itself as a scaling factor. It must be "bent" to
155  // provide good scaling at varying component sizes. Bigger components need less
156  // scaling than small ones.
157  double currTextHeight = Mils2iu( DEFAULT_TEXT_SIZE );
158 
159  double compRatio = bbSize.y / currTextHeight; // Ratio of component to text height
160  double compRatioBent = 1.0;
161 
162  // LUT to scale zoom ratio to provide reasonable schematic context. Must work
163  // with symbols of varying sizes (e.g. 0402 package and 200 pin BGA).
164  // "first" is used as the input and "second" as the output
165  //
166  // "first" = compRatio (symbol height / default text height)
167  // "second" = Amount to scale ratio by
168  std::vector<std::pair<double, double>> lut
169  {
170  {1.25, 16}, // 32
171  {2.5, 12}, //24
172  {5, 8}, // 16
173  {6, 6}, //
174  {10, 4}, //8
175  {20, 2}, //4
176  {40, 1.5}, // 2
177  {100, 1}
178  };
179 
180  std::vector<std::pair<double, double>>::iterator it;
181 
182  compRatioBent =
183  lut.back().second; // Large component default is last LUT entry (1:1)
184 
185  // Use LUT to do linear interpolation of "compRatio" within "first", then
186  // use that result to linearly interpolate "second" which gives the scaling
187  // factor needed.
188 
189  if( compRatio >= lut.front().first )
190  {
191  for( it = lut.begin(); it < lut.end() - 1; it++ )
192  {
193  if( it->first <= compRatio && next( it )->first >= compRatio )
194  {
195 
196  double diffx = compRatio - it->first;
197  double diffn = next( it )->first - it->first;
198 
199  compRatioBent = it->second
200  + ( next( it )->second - it->second ) * diffx / diffn;
201  break; // We have our interpolated value
202  }
203  }
204  }
205  else
206  compRatioBent = lut.front().second; // Small component default is first entry
207 
208  // This is similar to the original KiCad code that scaled the zoom to make sure
209  // components were visible on screen. It's simply a ratio of screen size to component
210  // size, and its job is to zoom in to make the component fullscreen. Earlier in the
211  // code the component BBox is given a 20% margin to add some breathing room. We compare
212  // the height of this enlarged component bbox to the default text height. If a
213  // component will end up with the sides clipped, we adjust later to make sure it fits
214  // on screen.
215  screenSize.x = std::max( 10.0, screenSize.x );
216  screenSize.y = std::max( 10.0, screenSize.y );
217  double ratio = std::max( -1.0, fabs( bbSize.y / screenSize.y ) );
218  // Original KiCad code for how much to scale the zoom
219  double kicadRatio = std::max( fabs( bbSize.x / screenSize.x ),
220  fabs( bbSize.y / screenSize.y ) );
221 
222  // If the width of the part we're probing is bigger than what the screen width will be
223  // after the zoom, then punt and use the KiCad zoom algorithm since it guarantees the
224  // part's width will be encompassed within the screen.
225 
226  if( bbSize.x > screenSize.x * ratio * compRatioBent )
227  {
228  ratio = kicadRatio; // Use standard KiCad zoom for parts too wide to fit on screen
229  compRatioBent = 1.0; // Reset so we don't modify the "KiCad" ratio
230  wxLogTrace( "CROSS_PROBE_SCALE",
231  "Part TOO WIDE for screen. Using normal KiCad zoom ratio: %1.5f",
232  ratio );
233  }
234 
235  // Now that "compRatioBent" holds our final scaling factor we apply it to the original
236  // fullscreen zoom ratio to arrive at the final ratio itself.
237  ratio *= compRatioBent;
238 
239  bool alwaysZoom = false; // DEBUG - allows us to minimize zooming or not
240  // Try not to zoom on every cross-probe; it gets very noisy
241  if( ( ratio < 0.5 || ratio > 1.0 ) || alwaysZoom )
242  getView()->SetScale( getView()->GetScale() / ratio );
243 #endif // ifndef COMP_1_TO_1_RATIO
244  }
245  }
246  }
247 
248  /* Print diag */
249  wxString msg_item;
250  wxString msg;
251 
252  if( aSearchType == HIGHLIGHT_PIN )
253  msg_item.Printf( _( "pin %s" ), aSearchText );
254  else
255  msg_item = _( "component" );
256 
257  if( component )
258  {
259  if( foundItem )
260  msg.Printf( _( "%s %s found" ), aReference, msg_item );
261  else
262  msg.Printf( _( "%s found but %s not found" ), aReference, msg_item );
263  }
264  else
265  msg.Printf( _( "Component %s not found" ), aReference );
266 
267  m_frame->SetStatusText( msg );
268 
269  m_probingPcbToSch = true; // recursion guard
270  {
271  // Clear any existing highlighting
273 
274  if( foundItem )
275  m_toolMgr->RunAction( EE_ACTIONS::addItemToSel, true, foundItem );
276  }
277  m_probingPcbToSch = false;
278 
279  m_frame->GetCanvas()->Refresh();
280 
281  return foundItem;
282 }
283 
284 
285 void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
286 {
288  char line[1024];
289 
290  strncpy( line, cmdline, sizeof(line) - 1 );
291  line[ sizeof(line) - 1 ] = '\0';
292 
293  char* idcmd = strtok( line, " \n\r" );
294  char* text = strtok( NULL, "\"\n\r" );
295 
296  if( idcmd == NULL )
297  return;
298 
299  CROSS_PROBING_SETTINGS& crossProbingSettings = eeconfig()->m_CrossProbing;
300 
301  if( strcmp( idcmd, "$NET:" ) == 0 )
302  {
303  if( !crossProbingSettings.auto_highlight )
304  return;
305 
306  wxString netName = FROM_UTF8( text );
307 
308  if( auto sg = Schematic().ConnectionGraph()->FindFirstSubgraphByName( netName ) )
309  m_highlightedConn = sg->m_driver_connection;
310 
312 
313  SetStatusText( _( "Selected net:" ) + wxS( " " ) + UnescapeString( netName ) );
314  return;
315  }
316 
317  if( strcmp( idcmd, "$CLEAR:" ) == 0 )
318  {
319  // Cross-probing is now done through selection so we no longer need a clear command
320  return;
321  }
322 
323  if( text == NULL )
324  return;
325 
326  if( strcmp( idcmd, "$PART:" ) != 0 )
327  return;
328 
329  wxString part_ref = FROM_UTF8( text );
330 
331  /* look for a complement */
332  idcmd = strtok( NULL, " \n\r" );
333 
334  if( idcmd == NULL ) // Highlight component only (from Cvpcb or Pcbnew)
335  {
336  // Highlight component part_ref, or clear Highlight, if part_ref is not existing
337  editor->FindComponentAndItem( part_ref, true, HIGHLIGHT_COMPONENT, wxEmptyString );
338  return;
339  }
340 
341  text = strtok( NULL, "\"\n\r" );
342 
343  if( text == NULL )
344  return;
345 
346  wxString msg = FROM_UTF8( text );
347 
348  if( strcmp( idcmd, "$REF:" ) == 0 )
349  {
350  // Highlighting the reference itself isn't actually that useful, and it's harder to
351  // see. Highlight the parent and display the message.
352  editor->FindComponentAndItem( part_ref, true, HIGHLIGHT_COMPONENT, msg );
353  }
354  else if( strcmp( idcmd, "$VAL:" ) == 0 )
355  {
356  // Highlighting the value itself isn't actually that useful, and it's harder to see.
357  // Highlight the parent and display the message.
358  editor->FindComponentAndItem( part_ref, true, HIGHLIGHT_COMPONENT, msg );
359  }
360  else if( strcmp( idcmd, "$PAD:" ) == 0 )
361  {
362  editor->FindComponentAndItem( part_ref, true, HIGHLIGHT_PIN, msg );
363  }
364  else
365  {
366  editor->FindComponentAndItem( part_ref, true, HIGHLIGHT_COMPONENT, wxEmptyString );
367  }
368 }
369 
370 
371 std::string FormatProbeItem( EDA_ITEM* aItem, SCH_COMPONENT* aComp )
372 {
373  // This is a keyword followed by a quoted string.
374 
375  // Cross probing to Pcbnew if a pin or a component is found
376  switch( aItem->Type() )
377  {
378  case SCH_FIELD_T:
379  if( aComp )
380  return StrPrintf( "$PART: \"%s\"", TO_UTF8( aComp->GetField( REFERENCE )->GetText() ) );
381  break;
382 
383  case SCH_COMPONENT_T:
384  aComp = (SCH_COMPONENT*) aItem;
385  return StrPrintf( "$PART: \"%s\"", TO_UTF8( aComp->GetField( REFERENCE )->GetText() ) );
386 
387  case SCH_SHEET_T:
388  {
389  // For cross probing, we need the full path of the sheet, because
390  // in complex hierarchies the sheet uuid of not unique
391  SCH_SHEET* sheet = (SCH_SHEET*)aItem;
392  wxString full_path;
393 
394  SCH_SHEET* parent = sheet;
395  while( (parent = dynamic_cast<SCH_SHEET*>( parent->GetParent() ) ) )
396  {
397  if( parent->GetParent() ) // The root sheet has no parent and path is just "/"
398  {
399  full_path.Prepend( parent->m_Uuid.AsString() );
400  full_path.Prepend( "/" );
401  }
402  }
403 
404  full_path += "/" + sheet->m_Uuid.AsString();
405 
406  return StrPrintf( "$SHEET: \"%s\"", TO_UTF8( full_path ) );
407  }
408 
409  case SCH_PIN_T:
410  {
411  SCH_PIN* pin = (SCH_PIN*) aItem;
412  aComp = pin->GetParentComponent();
413 
414  if( !pin->GetNumber().IsEmpty() )
415  {
416  return StrPrintf( "$PIN: \"%s\" $PART: \"%s\"",
417  TO_UTF8( pin->GetNumber() ),
418  TO_UTF8( aComp->GetField( REFERENCE )->GetText() ) );
419  }
420  else
421  {
422  return StrPrintf( "$PART: \"%s\"",
423  TO_UTF8( aComp->GetField( REFERENCE )->GetText() ) );
424  }
425  }
426 
427  default:
428  break;
429  }
430 
431  return "";
432 }
433 
434 
436 {
437  wxASSERT( aObjectToSync ); // fix the caller
438 
439  if( !aObjectToSync )
440  return;
441 
442  std::string packet = FormatProbeItem( aObjectToSync, aLibItem );
443 
444  if( !packet.empty() )
445  {
446  if( Kiface().IsSingle() )
447  SendCommand( MSG_TO_PCB, packet.c_str() );
448  else
449  {
450  // Typically ExpressMail is going to be s-expression packets, but since
451  // we have existing interpreter of the cross probe packet on the other
452  // side in place, we use that here.
454  }
455  }
456 }
457 
458 
459 void SCH_EDIT_FRAME::SendCrossProbeNetName( const wxString& aNetName )
460 {
461  // The command is a keyword followed by a quoted string.
462 
463  std::string packet = StrPrintf( "$NET: \"%s\"", TO_UTF8( aNetName ) );
464 
465  if( !packet.empty() )
466  {
467  if( Kiface().IsSingle() )
468  SendCommand( MSG_TO_PCB, packet.c_str() );
469  else
470  {
471  // Typically ExpressMail is going to be s-expression packets, but since
472  // we have existing interpreter of the cross probe packet on the other
473  // side in place, we use that here.
475  }
476  }
477 }
478 
479 
481 {
482  if( !aConnection )
483  {
485  return;
486  }
487 
488  if( aConnection->IsNet() )
489  {
490  SendCrossProbeNetName( aConnection->Name() );
491  return;
492  }
493 
494  if( aConnection->Members().empty() )
495  return;
496 
497  auto all_members = aConnection->AllMembers();
498 
499  wxString nets = all_members[0]->Name();
500 
501  if( all_members.size() == 1 )
502  {
503  SendCrossProbeNetName( nets );
504  return;
505  }
506 
507  // TODO: This could be replaced by just sending the bus name once we have bus contents
508  // included as part of the netlist sent from eeschema to pcbnew (and thus pcbnew can
509  // natively keep track of bus membership)
510 
511  for( size_t i = 1; i < all_members.size(); i++ )
512  nets << "," << all_members[i]->Name();
513 
514  std::string packet = StrPrintf( "$NETS: \"%s\"", TO_UTF8( nets ) );
515 
516  if( !packet.empty() )
517  {
518  if( Kiface().IsSingle() )
519  SendCommand( MSG_TO_PCB, packet.c_str() );
520  else
521  {
522  // Typically ExpressMail is going to be s-expression packets, but since
523  // we have existing interpreter of the cross probe packet on the other
524  // side in place, we use that here.
526  }
527  }
528 }
529 
530 
532 {
533  std::string packet = "$CLEAR\n";
534 
535  if( Kiface().IsSingle() )
536  SendCommand( MSG_TO_PCB, packet.c_str() );
537  else
538  {
539  // Typically ExpressMail is going to be s-expression packets, but since
540  // we have existing interpreter of the cross probe packet on the other
541  // side in place, we use that here.
543  }
544 }
545 
546 
548 {
549  std::string& payload = mail.GetPayload();
550 
551  switch( mail.Command() )
552  {
553  case MAIL_CROSS_PROBE:
554  ExecuteRemoteCommand( payload.c_str() );
555  break;
556 
558  {
559  if( payload.find( "quiet-annotate" ) != std::string::npos )
560  {
562  AnnotateComponents( true, UNSORTED, INCREMENTAL_BY_REF, 0, false, false, true,
564  }
565 
566  if( payload.find( "no-annotate" ) == std::string::npos )
567  {
568  // Ensure schematic is OK for netlist creation (especially that it is fully annotated):
569  if( !ReadyToNetlist() )
570  return;
571  }
572 
573  NETLIST_EXPORTER_KICAD exporter( &Schematic() );
574  STRING_FORMATTER formatter;
575 
576  // TODO remove once real-time connectivity is a given
577  if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
578  // Ensure the netlist data is up to date:
580 
581  exporter.Format( &formatter, GNL_ALL | GNL_OPT_KICAD );
582 
583  payload = formatter.GetString();
584  }
585  break;
586 
588  try
589  {
591  controlTool->AssignFootprints( payload );
592  }
593  catch( const IO_ERROR& )
594  {
595  }
596  break;
597 
598  case MAIL_SCH_REFRESH:
599  {
600  SCH_SCREENS schematic( Schematic().Root() );
601  schematic.TestDanglingEnds();
602 
604  GetCanvas()->Refresh();
605  }
606  break;
607 
609  {
610  NET_SETTINGS& netSettings = Prj().GetProjectFile().NetSettings();
611 
612  netSettings.m_NetClassAssignments.clear();
613 
614  // Establish the set of nets which is currently valid
615  for( const wxString& name : Schematic().GetNetClassAssignmentCandidates() )
616  netSettings.m_NetClassAssignments[ name ] = "Default";
617 
618  // Copy their netclass assignments, dropping any assignments to non-current nets.
619  for( auto& ii : netSettings.m_NetClasses )
620  {
621  for( const wxString& member : *ii.second )
622  {
623  if( netSettings.m_NetClassAssignments.count( member ) )
624  netSettings.m_NetClassAssignments[ member ] = ii.first;
625  }
626 
627  ii.second->Clear();
628  }
629 
630  // Update the membership lists to contain only the current nets.
631  for( const std::pair<const wxString, wxString>& ii : netSettings.m_NetClassAssignments )
632  {
633  if( ii.second == "Default" )
634  continue;
635 
636  NETCLASSPTR netclass = netSettings.m_NetClasses.Find( ii.second );
637 
638  if( netclass )
639  netclass->Add( ii.first );
640  }
641 
642  netSettings.ResolveNetClassAssignments();
643  }
644  break;
645 
646  case MAIL_IMPORT_FILE:
647  {
648  // Extract file format type and path (plugin type and path separated with \n)
649  size_t split = payload.find( '\n' );
650  wxCHECK( split != std::string::npos, /*void*/ );
651  int importFormat;
652 
653  try
654  {
655  importFormat = std::stoi( payload.substr( 0, split ) );
656  }
657  catch( std::invalid_argument& )
658  {
659  wxFAIL;
660  importFormat = -1;
661  }
662 
663  std::string path = payload.substr( split + 1 );
664  wxASSERT( !path.empty() );
665 
666  if( importFormat >= 0 )
667  importFile( path, importFormat );
668  }
669  break;
670 
671  case MAIL_SCH_SAVE:
672  if( SaveProject() )
673  payload = "success";
674 
675  break;
676 
677  case MAIL_SCH_UPDATE:
679  break;
680 
681  case MAIL_REANNOTATE:
682  //Reannotate the schematic as per the netlist.
683  ReannotateFromPCBNew( this, payload );
684  break;
685 
686  default:;
687 
688  }
689 }
CITER next(CITER it)
Definition: ptree.cpp:126
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
KIGFX::SCH_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
std::map< wxString, wxString > m_NetClassAssignments
Definition: net_settings.h:43
KIWAY_EXPRESS carries a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition: kiway_express.h:39
BOX2D GetViewport() const
Function GetViewport() Returns the current viewport visible area rectangle.
Definition: view.cpp:519
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
DDE server & client.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel.
NETCLASSPTR Find(const wxString &aName) const
Function Find searches this container for a NETCLASS given by aName.
Definition: netclass.cpp:132
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:109
void SendCrossProbeNetName(const wxString &aNetName)
Sends a net name to pcbnew for highlighting.
SCH_SHEET_LIST GetSheets() const
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:91
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generates the connection data for the entire schematic hierarchy.
void SendCrossProbeClearHighlight()
Tells PcbNew to clear the existing highlighted net, if one exists.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
void AnnotateComponents(bool aAnnotateSchematic, ANNOTATE_ORDER_T aSortOption, ANNOTATE_OPTION_T aAlgoOption, int aStartNumber, bool aResetAnnotation, bool aRepairTimestamps, bool aLockUnits, REPORTER &aReporter)
Annotate the components in the schematic that are not currently annotated.
EE_TYPE OfType(KICAD_T aType)
Definition: sch_rtree.h:219
void UpdateAllItems(int aUpdateFlags)
Updates all items in the view according to the given flags.
Definition: view.cpp:1417
int GetWidth() const
Definition: eda_rect.h:119
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:141
Annotate incrementally using the first free reference number.
SCH_PIN * GetPin(const wxString &number)
Find a symbol pin by number.
wxString AsString() const
Definition: kiid.cpp:174
NET_SETTINGS & NetSettings()
Definition: project_file.h:92
wxString GetNumber() const
Definition: sch_pin.h:114
bool SendCommand(int service, const char *cmdline)
Definition: eda_dde.cpp:131
bool ReadyToNetlist(bool aSilent=false, bool aSilentAnnotate=false)
Checks if we are ready to write a netlist file for the current schematic.
void DisplayCurrentSheet()
Draw the current sheet on the display.
Definition: hierarch.cpp:234
std::string FormatProbeItem(EDA_ITEM *aItem, SCH_COMPONENT *aComp)
Item needs to be redrawn.
Definition: view_item.h:63
void Format(OUTPUTFORMATTER *aOutputFormatter, int aCtl)
Output this s-expression netlist into aOutputFormatter.
static TOOL_ACTION updateNetHighlighting
Definition: ee_actions.h:216
bool importFile(const wxString &aFileName, int aFileType)
Load the given filename but sets the path to the current project path.
wxPoint GetPosition() const override
Definition: sch_pin.h:87
Field Reference of part, i.e. "IC21".
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:42
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
EESCHEMA_SETTINGS * eeconfig() const
int StrPrintf(std::string *result, const char *format,...)
Function StrPrintf is like sprintf() but the output is appended to a std::string instead of to a char...
Definition: richio.cpp:78
SCH_EDITOR_CONTROL.
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:95
void SendMessageToPCBNEW(EDA_ITEM *aObjectToSync, SCH_COMPONENT *aPart)
Send a message to Pcbnew via a socket connection.
Cross-probing behavior.
Definition: app_settings.h:30
SCH_ITEM * FindComponentAndItem(const wxString &aReference, bool aSearchHierarchy, SCH_SEARCH_T aSearchType, const wxString &aSearchText)
Finds a component in the schematic and an item in this component.
static TOOL_ACTION updateSchematicFromPcb
Definition: actions.h:162
NETCLASSES m_NetClasses
Definition: net_settings.h:39
wxString Name(bool aIgnoreSheet=false) const
const std::vector< std::shared_ptr< SCH_CONNECTION > > AllMembers() const
static TOOL_ACTION addItemToSel
Selects an item (specified as the event parameter).
Definition: ee_actions.h:59
#define NULL
bool IsSingle() const
Function IsSingle is this KIFACE_I running under single_top?
Definition: kiface_i.h:117
VTBL_ENTRY PROJECT_FILE & GetProjectFile() const
Definition: project.h:143
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
TRANSFORM & GetTransform() const
void ReannotateFromPCBNew(SCH_EDIT_FRAME *aFrame, std::string &aNetlist)
Backannotate the schematic with a netlist sent from PCBNew.
Definition: reannotate.cpp:58
void ResolveNetClassAssignments(bool aRebuildFromScratch=false)
Explodes the list of netclass assignments to include atomic members of composite labels (buses).
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Annotate by position of component in the schematic sheet object list.
Generate the KiCad netlist format supported by Pcbnew.
SCHEMATIC & Schematic() const
void KiwayMailIn(KIWAY_EXPRESS &aEvent) override
Function KiwayMailIn receives KIWAY_EXPRESS messages from other players.
EDA_ITEM * GetParent() const
Definition: eda_item.h:184
NET_SETTINGS stores various net-related settings in a project context.
Definition: net_settings.h:31
const std::string & GetString()
Definition: richio.h:476
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Moves the graphic crosshair cursor to the requested position expressed in world coordinates.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
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...
bool zoom_to_fit
Zoom to fit items (ignored if center_on_items is off)
Definition: app_settings.h:33
const SCH_CONNECTION * m_highlightedConn
The highlighted net or bus, or nullptr.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:219
const KIID m_Uuid
Definition: eda_item.h:151
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Function SetScale() Sets the scaling factor, zooming around a given anchor point.
Definition: view.cpp:559
static bool m_allowRealTime
SCH_FIELD * GetField(int aFieldNdx)
Returns a field in this symbol.
VTBL_ENTRY void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=NULL)
Function ExpressMail send aPayload to aDestination from aSource.
Definition: kiway.cpp:437
bool auto_highlight
Automatically turn on highlight mode in the target frame.
Definition: app_settings.h:34
bool IsNet() const
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:48
SCH_SEARCH_T
Schematic search type used by the socket link with Pcbnew.
void TestDanglingEnds()
const char * name
Definition: DXF_plotter.cpp:59
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
#define _(s)
Definition: 3d_actions.cpp:33
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:152
EE_RTREE & Items()
Definition: sch_screen.h:159
#define GNL_ALL
#define MSG_TO_PCB
Definition: eda_dde.h:45
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
Schematic symbol object.
Definition: sch_component.h:79
wxPoint GetPosition() const override
void SetCrossProbeConnection(const SCH_CONNECTION *aConnection)
Sends a connection (net or bus) to pcbnew for highlighting.
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: eda_item.h:148
void ExecuteRemoteCommand(const char *cmdline) override
Execute a remote command sent by Pcbnew via a socket connection.
std::vector< std::shared_ptr< SCH_CONNECTION > > & Members()
void AssignFootprints(const std::string &aChangedSetOfReferences)
SCH_SHEET_PATH & GetCurrentSheet() const
virtual void CenterScreen(const wxPoint &aCenterPoint, bool aWarpPointer)
#define DEFAULT_TEXT_SIZE
The offset of the pin name string from the end of the pin in mils.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers of advanced config.
void AnnotatePowerSymbols()
Silently annotate the not yet annotated power symbols of the entire hierarchy of the sheet path list.
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:76
const Vec & GetSize() const
Definition: box2.h:189
static REPORTER & GetInstance()
Definition: reporter.cpp:105
CROSS_PROBING_SETTINGS m_CrossProbing
Definition: app_settings.h:159
MAIL_T Command()
Function Command returns the MAIL_T associated with this mail.
Definition: kiway_express.h:52
void SetCurrentSheet(const SCH_SHEET_PATH &aPath)
Definition: schematic.h:126
bool center_on_items
Automatically pan to cross-probed items.
Definition: app_settings.h:32
STRING_FORMATTER implements OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:446
SCH_COMPONENT * GetParentComponent() const
Definition: sch_pin.cpp:127
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:194
std::string & GetPayload()
Function Payload returns the payload, which can be any text but it typicall self identifying s-expres...
Definition: kiway_express.h:62
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:521
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:363
static std::vector< std::string > split(const std::string &aStr, const std::string &aDelim)
Splits the input string into a vector of output strings.
Definition: kicad_string.h:268
KICAD_T Type() const
Function Type()
Definition: eda_item.h:182
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.