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-2021 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_symbol.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>
39 #include <advanced_config.h>
40 #include <netclass.h>
41 #include <wx/log.h>
42 
43 SCH_ITEM* SCH_EDITOR_CONTROL::FindSymbolAndItem( const wxString& aReference,
44  bool aSearchHierarchy,
45  SCH_SEARCH_T aSearchType,
46  const wxString& aSearchText )
47 {
48  SCH_SHEET_PATH* sheetWithSymbolFound = nullptr;
49  SCH_SYMBOL* symbol = nullptr;
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_SYMBOL_T ) )
65  {
66  SCH_SYMBOL* candidate = static_cast<SCH_SYMBOL*>( item );
67 
68  if( aReference.CmpNoCase( candidate->GetRef( &sheet ) ) == 0 )
69  {
70  symbol = candidate;
71  sheetWithSymbolFound = &sheet;
72 
73  if( aSearchType == HIGHLIGHT_PIN )
74  {
75  // temporary: will be changed if the pin is found.
76  pos = symbol->GetPosition();
77  pin = symbol->GetPin( aSearchText );
78 
79  // Ensure we have found the right unit in case of multi-units symbol
80  if( pin )
81  {
82  int unit = pin->GetLibPin()->GetUnit();
83 
84  if( unit != 0 && unit != symbol->GetUnit() )
85  {
86  pin = nullptr;
87  continue;
88  }
89 
90  // Get pin position in true schematic coordinate
91  pos = pin->GetPosition();
92  foundItem = pin;
93  break;
94  }
95  }
96  else
97  {
98  pos = symbol->GetPosition();
99  foundItem = symbol;
100  break;
101  }
102  }
103  }
104 
105  if( foundItem )
106  break;
107  }
108 
109  CROSS_PROBING_SETTINGS& crossProbingSettings = m_frame->eeconfig()->m_CrossProbing;
110 
111 
112  if( symbol )
113  {
114  if( *sheetWithSymbolFound != m_frame->GetCurrentSheet() )
115  {
116  m_frame->Schematic().SetCurrentSheet( *sheetWithSymbolFound );
118  }
119 
120  if( crossProbingSettings.center_on_items )
121  {
123  m_frame->CenterScreen( pos, false );
124 
125  if( crossProbingSettings.zoom_to_fit )
126  {
127 //#define COMP_1_TO_1_RATIO // Un-comment for normal KiCad full screen zoom cross-probe
128 #ifdef COMP_1_TO_1_RATIO
129  // Pass "false" to only include visible fields of symbol in bbox calculations
130  EDA_RECT bbox = symbol->GetBoundingBox( false );
131  wxSize bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize();
132  VECTOR2D screenSize = getView()->GetViewport().GetSize();
133 
134  // NOTE: The 1:1 here is using the default KiCad sizing, which adds a margin of 20%
135 
136  screenSize.x = std::max( 10.0, screenSize.x );
137  screenSize.y = std::max( 10.0, screenSize.y );
138  double ratio = std::max(
139  fabs( bbSize.x / screenSize.x ), fabs( bbSize.y / screenSize.y ) );
140 
141  // Try not to zoom on every cross-probe; it gets very noisy
142  if( ratio < 0.5 || ratio > 1.0 )
143  getView()->SetScale( getView()->GetScale() / ratio );
144 #endif // COMP_1_TO_1_RATIO
145 
146 #ifndef COMP_1_TO_1_RATIO // Do the scaled zoom
147  // Pass "false" to only include visible fields of symbol in bbox calculations.
148  EDA_RECT bbox = symbol->GetBoundingBox( false );
149  wxSize bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize();
150  VECTOR2D screenSize = getView()->GetViewport().GetSize();
151 
152  // This code tries to come up with a zoom factor that doesn't simply zoom in
153  // to the cross probed symbol, but instead shows a reasonable amount of the
154  // circuit around it to provide context. This reduces or eliminates the need
155  // to manually change the zoom because it's too close.
156 
157  // Using the default text height as a constant to compare against, use the
158  // height of the bounding box of visible items for a footprint to figure out
159  // if this is a big symbol (like a processor) or a small symbol (like a resistor).
160  // This ratio is not useful by itself as a scaling factor. It must be "bent" to
161  // provide good scaling at varying symbol sizes. Bigger symbols need less
162  // scaling than small ones.
163  double currTextHeight = Mils2iu( DEFAULT_TEXT_SIZE );
164 
165  double compRatio = bbSize.y / currTextHeight; // Ratio of symbol to text height
166  double compRatioBent = 1.0;
167 
168  // LUT to scale zoom ratio to provide reasonable schematic context. Must work
169  // with symbols of varying sizes (e.g. 0402 package and 200 pin BGA).
170  // "first" is used as the input and "second" as the output
171  //
172  // "first" = compRatio (symbol height / default text height)
173  // "second" = Amount to scale ratio by
174  std::vector<std::pair<double, double>> lut
175  {
176  {1.25, 16}, // 32
177  {2.5, 12}, //24
178  {5, 8}, // 16
179  {6, 6}, //
180  {10, 4}, //8
181  {20, 2}, //4
182  {40, 1.5}, // 2
183  {100, 1}
184  };
185 
186  std::vector<std::pair<double, double>>::iterator it;
187 
188  // Large symbol default is last LUT entry (1:1).
189  compRatioBent = lut.back().second;
190 
191  // Use LUT to do linear interpolation of "compRatio" within "first", then
192  // use that result to linearly interpolate "second" which gives the scaling
193  // factor needed.
194  if( compRatio >= lut.front().first )
195  {
196  for( it = lut.begin(); it < lut.end() - 1; it++ )
197  {
198  if( it->first <= compRatio && next( it )->first >= compRatio )
199  {
200 
201  double diffx = compRatio - it->first;
202  double diffn = next( it )->first - it->first;
203 
204  compRatioBent = it->second
205  + ( next( it )->second - it->second ) * diffx / diffn;
206  break; // We have our interpolated value
207  }
208  }
209  }
210  else
211  {
212  compRatioBent = lut.front().second; // Small symbol default is first entry
213  }
214 
215  // This is similar to the original KiCad code that scaled the zoom to make sure
216  // symbols were visible on screen. It's simply a ratio of screen size to
217  // symbol size, and its job is to zoom in to make the component fullscreen.
218  // Earlier in the code the symbol BBox is given a 20% margin to add some
219  // breathing room. We compare the height of this enlarged symbol bbox to the
220  // default text height. If a symbol will end up with the sides clipped, we
221  // adjust later to make sure it fits on screen.
222  screenSize.x = std::max( 10.0, screenSize.x );
223  screenSize.y = std::max( 10.0, screenSize.y );
224  double ratio = std::max( -1.0, fabs( bbSize.y / screenSize.y ) );
225 
226  // Original KiCad code for how much to scale the zoom
227  double kicadRatio = std::max( fabs( bbSize.x / screenSize.x ),
228  fabs( bbSize.y / screenSize.y ) );
229 
230  // If the width of the part we're probing is bigger than what the screen width
231  // will be after the zoom, then punt and use the KiCad zoom algorithm since it
232  // guarantees the part's width will be encompassed within the screen.
233  if( bbSize.x > screenSize.x * ratio * compRatioBent )
234  {
235  // Use standard KiCad zoom for parts too wide to fit on screen/
236  ratio = kicadRatio;
237  compRatioBent = 1.0; // Reset so we don't modify the "KiCad" ratio
238  wxLogTrace( "CROSS_PROBE_SCALE",
239  "Part TOO WIDE for screen. Using normal KiCad zoom ratio: %1.5f",
240  ratio );
241  }
242 
243  // Now that "compRatioBent" holds our final scaling factor we apply it to the
244  // original fullscreen zoom ratio to arrive at the final ratio itself.
245  ratio *= compRatioBent;
246 
247  bool alwaysZoom = false; // DEBUG - allows us to minimize zooming or not
248 
249  // Try not to zoom on every cross-probe; it gets very noisy
250  if( ( ratio < 0.5 || ratio > 1.0 ) || alwaysZoom )
251  getView()->SetScale( getView()->GetScale() / ratio );
252 #endif // ifndef COMP_1_TO_1_RATIO
253  }
254  }
255  }
256 
257  /* Print diag */
258  wxString msg;
259 
260  if( symbol )
261  {
262  if( aSearchType == HIGHLIGHT_PIN )
263  {
264  if( foundItem )
265  msg.Printf( _( "%s pin %s found" ), aReference, aSearchText );
266  else
267  msg.Printf( _( "%s found but pin %s not found" ), aReference, aSearchText );
268  }
269  else
270  {
271  msg.Printf( _( "%s found" ), aReference );
272  }
273  }
274  else
275  {
276  msg.Printf( _( "%s not found" ), aReference );
277  }
278 
279  m_frame->SetStatusText( msg );
280 
281  m_probingPcbToSch = true; // recursion guard
282 
283  {
284  // Clear any existing highlighting
286 
287  if( foundItem )
288  m_toolMgr->RunAction( EE_ACTIONS::addItemToSel, true, foundItem );
289  }
290 
291  m_probingPcbToSch = false;
292 
293  m_frame->GetCanvas()->Refresh();
294 
295  return foundItem;
296 }
297 
298 
299 void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
300 {
302  char line[1024];
303 
304  strncpy( line, cmdline, sizeof( line ) - 1 );
305  line[ sizeof( line ) - 1 ] = '\0';
306 
307  char* idcmd = strtok( line, " \n\r" );
308  char* text = strtok( nullptr, "\"\n\r" );
309 
310  if( idcmd == nullptr )
311  return;
312 
313  CROSS_PROBING_SETTINGS& crossProbingSettings = eeconfig()->m_CrossProbing;
314 
315  if( strcmp( idcmd, "$NET:" ) == 0 )
316  {
317  if( !crossProbingSettings.auto_highlight )
318  return;
319 
320  wxString netName = FROM_UTF8( text );
321 
322  if( auto sg = Schematic().ConnectionGraph()->FindFirstSubgraphByName( netName ) )
323  m_highlightedConn = sg->m_driver_connection;
324  else
325  m_highlightedConn = nullptr;
326 
328 
329  SetStatusText( _( "Selected net:" ) + wxS( " " ) + UnescapeString( netName ) );
330  return;
331  }
332 
333  if( strcmp( idcmd, "$CLEAR:" ) == 0 )
334  {
335  // Cross-probing is now done through selection so we no longer need a clear command
336  return;
337  }
338 
339  if( text == nullptr )
340  return;
341 
342  if( strcmp( idcmd, "$PART:" ) != 0 )
343  return;
344 
345  wxString part_ref = FROM_UTF8( text );
346 
347  /* look for a complement */
348  idcmd = strtok( nullptr, " \n\r" );
349 
350  if( idcmd == nullptr ) // Highlight symbol only (from CvPcb or Pcbnew)
351  {
352  // Highlight symbol part_ref, or clear Highlight, if part_ref is not existing
353  editor->FindSymbolAndItem( part_ref, true, HIGHLIGHT_SYMBOL, wxEmptyString );
354  return;
355  }
356 
357  text = strtok( nullptr, "\"\n\r" );
358 
359  if( text == nullptr )
360  return;
361 
362  wxString msg = FROM_UTF8( text );
363 
364  if( strcmp( idcmd, "$REF:" ) == 0 )
365  {
366  // Highlighting the reference itself isn't actually that useful, and it's harder to
367  // see. Highlight the parent and display the message.
368  editor->FindSymbolAndItem( part_ref, true, HIGHLIGHT_SYMBOL, msg );
369  }
370  else if( strcmp( idcmd, "$VAL:" ) == 0 )
371  {
372  // Highlighting the value itself isn't actually that useful, and it's harder to see.
373  // Highlight the parent and display the message.
374  editor->FindSymbolAndItem( part_ref, true, HIGHLIGHT_SYMBOL, msg );
375  }
376  else if( strcmp( idcmd, "$PAD:" ) == 0 )
377  {
378  editor->FindSymbolAndItem( part_ref, true, HIGHLIGHT_PIN, msg );
379  }
380  else
381  {
382  editor->FindSymbolAndItem( part_ref, true, HIGHLIGHT_SYMBOL, wxEmptyString );
383  }
384 }
385 
386 
387 std::string FormatProbeItem( EDA_ITEM* aItem, SCH_SYMBOL* aSymbol )
388 {
389  // This is a keyword followed by a quoted string.
390 
391  // Cross probing to Pcbnew if a pin or a symbol is found.
392  switch( aItem->Type() )
393  {
394  case SCH_FIELD_T:
395  if( aSymbol )
396  {
397  return StrPrintf( "$PART: \"%s\"",
398  TO_UTF8( aSymbol->GetField( REFERENCE_FIELD )->GetText() ) );
399  }
400  break;
401 
402  case SCH_SYMBOL_T:
403  aSymbol = (SCH_SYMBOL*) aItem;
404  return StrPrintf( "$PART: \"%s\"",
405  TO_UTF8( aSymbol->GetField( REFERENCE_FIELD )->GetText() ) );
406 
407  case SCH_SHEET_T:
408  {
409  // For cross probing, we need the full path of the sheet, because
410  // in complex hierarchies the sheet uuid of not unique
411  SCH_SHEET* sheet = (SCH_SHEET*)aItem;
412  wxString full_path;
413 
414  SCH_SHEET* parent = sheet;
415  while( (parent = dynamic_cast<SCH_SHEET*>( parent->GetParent() ) ) )
416  {
417  if( parent->GetParent() ) // The root sheet has no parent and path is just "/"
418  {
419  full_path.Prepend( parent->m_Uuid.AsString() );
420  full_path.Prepend( "/" );
421  }
422  }
423 
424  full_path += "/" + sheet->m_Uuid.AsString();
425 
426  return StrPrintf( "$SHEET: \"%s\"", TO_UTF8( full_path ) );
427  }
428 
429  case SCH_PIN_T:
430  {
431  SCH_PIN* pin = (SCH_PIN*) aItem;
432  aSymbol = pin->GetParentSymbol();
433 
434  if( !pin->GetShownNumber().IsEmpty() )
435  {
436  return StrPrintf( "$PIN: \"%s\" $PART: \"%s\"",
437  TO_UTF8( pin->GetShownNumber() ),
438  TO_UTF8( aSymbol->GetField( REFERENCE_FIELD )->GetText() ) );
439  }
440  else
441  {
442  return StrPrintf( "$PART: \"%s\"",
443  TO_UTF8( aSymbol->GetField( REFERENCE_FIELD )->GetText() ) );
444  }
445  }
446 
447  default:
448  break;
449  }
450 
451  return "";
452 }
453 
454 
455 void SCH_EDIT_FRAME::SendMessageToPCBNEW( EDA_ITEM* aObjectToSync, SCH_SYMBOL* aLibItem )
456 {
457  wxASSERT( aObjectToSync ); // fix the caller
458 
459  if( !aObjectToSync )
460  return;
461 
462  std::string packet = FormatProbeItem( aObjectToSync, aLibItem );
463 
464  if( !packet.empty() )
465  {
466  if( Kiface().IsSingle() )
467  {
468  SendCommand( MSG_TO_PCB, packet );
469  }
470  else
471  {
472  // Typically ExpressMail is going to be s-expression packets, but since
473  // we have existing interpreter of the cross probe packet on the other
474  // side in place, we use that here.
476  }
477  }
478 }
479 
480 
481 void SCH_EDIT_FRAME::SendCrossProbeNetName( const wxString& aNetName )
482 {
483  // The command is a keyword followed by a quoted string.
484 
485  std::string packet = StrPrintf( "$NET: \"%s\"", TO_UTF8( aNetName ) );
486 
487  if( !packet.empty() )
488  {
489  if( Kiface().IsSingle() )
490  {
491  SendCommand( MSG_TO_PCB, packet );
492  }
493  else
494  {
495  // Typically ExpressMail is going to be s-expression packets, but since
496  // we have existing interpreter of the cross probe packet on the other
497  // side in place, we use that here.
499  }
500  }
501 }
502 
503 
505 {
506  if( !aConnection )
507  {
509  return;
510  }
511 
512  if( aConnection->IsNet() )
513  {
514  SendCrossProbeNetName( aConnection->Name() );
515  return;
516  }
517 
518  if( aConnection->Members().empty() )
519  return;
520 
521  auto all_members = aConnection->AllMembers();
522 
523  wxString nets = all_members[0]->Name();
524 
525  if( all_members.size() == 1 )
526  {
527  SendCrossProbeNetName( nets );
528  return;
529  }
530 
531  // TODO: This could be replaced by just sending the bus name once we have bus contents
532  // included as part of the netlist sent from Eeschema to Pcbnew (and thus Pcbnew can
533  // natively keep track of bus membership)
534 
535  for( size_t i = 1; i < all_members.size(); i++ )
536  nets << "," << all_members[i]->Name();
537 
538  std::string packet = StrPrintf( "$NETS: \"%s\"", TO_UTF8( nets ) );
539 
540  if( !packet.empty() )
541  {
542  if( Kiface().IsSingle() )
543  SendCommand( MSG_TO_PCB, packet );
544  else
545  {
546  // Typically ExpressMail is going to be s-expression packets, but since
547  // we have existing interpreter of the cross probe packet on the other
548  // side in place, we use that here.
550  }
551  }
552 }
553 
554 
556 {
557  std::string packet = "$CLEAR\n";
558 
559  if( Kiface().IsSingle() )
560  {
561  SendCommand( MSG_TO_PCB, packet );
562  }
563  else
564  {
565  // Typically ExpressMail is going to be s-expression packets, but since
566  // we have existing interpreter of the cross probe packet on the other
567  // side in place, we use that here.
569  }
570 }
571 
572 
574 {
575  std::string& payload = mail.GetPayload();
576 
577  switch( mail.Command() )
578  {
579  case MAIL_CROSS_PROBE:
580  ExecuteRemoteCommand( payload.c_str() );
581  break;
582 
584  {
585  if( !payload.empty() )
586  {
587  wxString annotationMessage( payload );
588 
589  // Ensure schematic is OK for netlist creation (especially that it is fully annotated):
590  if( !ReadyToNetlist( annotationMessage ) )
591  return;
592  }
593 
594  NETLIST_EXPORTER_KICAD exporter( &Schematic() );
595  STRING_FORMATTER formatter;
596 
597  // TODO remove once real-time connectivity is a given
598  if( !ADVANCED_CFG::GetCfg().m_RealTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
599  // Ensure the netlist data is up to date:
601 
602  exporter.Format( &formatter, GNL_ALL | GNL_OPT_KICAD );
603 
604  payload = formatter.GetString();
605  }
606  break;
607 
609  try
610  {
612  controlTool->AssignFootprints( payload );
613  }
614  catch( const IO_ERROR& )
615  {
616  }
617  break;
618 
619  case MAIL_SCH_REFRESH:
620  {
622 
624  GetCanvas()->Refresh();
625  }
626  break;
627 
629  {
630  NET_SETTINGS& netSettings = Prj().GetProjectFile().NetSettings();
631 
632  netSettings.m_NetClassAssignments.clear();
633 
634  // Establish the set of nets which is currently valid
635  for( const wxString& name : Schematic().GetNetClassAssignmentCandidates() )
636  netSettings.m_NetClassAssignments[ name ] = "Default";
637 
638  // Copy their netclass assignments, dropping any assignments to non-current nets.
639  for( auto& ii : netSettings.m_NetClasses )
640  {
641  for( const wxString& member : *ii.second )
642  {
643  if( netSettings.m_NetClassAssignments.count( member ) )
644  netSettings.m_NetClassAssignments[ member ] = ii.first;
645  }
646 
647  ii.second->Clear();
648  }
649 
650  // Update the membership lists to contain only the current nets.
651  for( const std::pair<const wxString, wxString>& ii : netSettings.m_NetClassAssignments )
652  {
653  if( ii.second == "Default" )
654  continue;
655 
656  NETCLASSPTR netclass = netSettings.m_NetClasses.Find( ii.second );
657 
658  if( netclass )
659  netclass->Add( ii.first );
660  }
661 
662  netSettings.ResolveNetClassAssignments();
663  }
664  break;
665 
666  case MAIL_IMPORT_FILE:
667  {
668  // Extract file format type and path (plugin type and path separated with \n)
669  size_t split = payload.find( '\n' );
670  wxCHECK( split != std::string::npos, /*void*/ );
671  int importFormat;
672 
673  try
674  {
675  importFormat = std::stoi( payload.substr( 0, split ) );
676  }
677  catch( std::invalid_argument& )
678  {
679  wxFAIL;
680  importFormat = -1;
681  }
682 
683  std::string path = payload.substr( split + 1 );
684  wxASSERT( !path.empty() );
685 
686  if( importFormat >= 0 )
687  importFile( path, importFormat );
688  }
689  break;
690 
691  case MAIL_SCH_SAVE:
692  if( SaveProject() )
693  payload = "success";
694 
695  break;
696 
697  case MAIL_SCH_UPDATE:
699  break;
700 
701  default:;
702 
703  }
704 }
Field Reference of part, i.e. "IC21".
bool ReadyToNetlist(const wxString &aAnnotateMessage)
Check if we are ready to write a netlist file for the current schematic.
CITER next(CITER it)
Definition: ptree.cpp:126
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:216
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
std::map< wxString, wxString > m_NetClassAssignments
Definition: net_settings.h:44
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition: kiway_express.h:38
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
Definition: view.cpp:514
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
DDE server & client.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
NETCLASSPTR Find(const wxString &aName) const
Search this container for a NETCLASS given by aName.
Definition: netclass.cpp:132
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110
void SendCrossProbeNetName(const wxString &aNetName)
Sends a net name to Pcbnew for highlighting.
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generate the connection data for the entire schematic hierarchy.
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:665
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:145
void SendCrossProbeClearHighlight()
Tell Pcbnew to clear the existing highlighted net, if one exists.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1416
int GetWidth() const
Definition: eda_rect.h:109
bool SendCommand(int aService, const std::string &aMessage)
Must be called to clean up the socket thread used by SendCommand.
Definition: eda_dde.cpp:313
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
wxString AsString() const
Definition: kiid.cpp:218
NET_SETTINGS & NetSettings()
Definition: project_file.h:94
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:467
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:431
void DisplayCurrentSheet()
Draw the current sheet on the display.
Definition: hierarch.cpp:285
All except INITIAL_ADD.
Definition: view_item.h:58
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.
SCH_ITEM * FindSymbolAndItem(const wxString &aReference, bool aSearchHierarchy, SCH_SEARCH_T aSearchType, const wxString &aSearchText)
Find a symbol in the schematic and an item in this symbol.
EESCHEMA_SETTINGS * eeconfig() const
int StrPrintf(std::string *result, const char *format,...)
This is like sprintf() but the output is appended to a std::string instead of to a character array.
Definition: richio.cpp:78
Handle actions specific to the schematic editor.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
Cross-probing behavior.
Definition: app_settings.h:30
static TOOL_ACTION updateSchematicFromPcb
Definition: actions.h:164
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
NETCLASSES m_NetClasses
Definition: net_settings.h:40
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:56
bool IsSingle() const
Is this KIFACE_I running under single_top?
Definition: kiface_i.h:104
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
void ResolveNetClassAssignments(bool aRebuildFromScratch=false)
Explode 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.
Generate the KiCad netlist format supported by Pcbnew.
SCHEMATIC & Schematic() const
void KiwayMailIn(KIWAY_EXPRESS &aEvent) override
Receive KIWAY_EXPRESS messages from other players.
EDA_ITEM * GetParent() const
Definition: eda_item.h:115
#define _(s)
NET_SETTINGS stores various net-related settings in a project context.
Definition: net_settings.h:32
const std::string & GetString()
Definition: richio.h:438
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:53
#define GNL_ALL
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move 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
Returns the instance of #VIEW object used in the application.
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:54
const KIID m_Uuid
Definition: eda_item.h:475
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
Definition: view.cpp:554
static bool m_allowRealTime
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
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:156
SCH_SEARCH_T
Schematic search type used by the socket link with Pcbnew.
Schematic symbol object.
Definition: sch_symbol.h:78
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).
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:214
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
Definition: sch_symbol.cpp:830
EE_RTREE & Items()
Definition: sch_screen.h:102
#define MSG_TO_PCB
Definition: eda_dde.h:49
Handle the component boundary box.
Definition: eda_rect.h:42
void SetCrossProbeConnection(const SCH_CONNECTION *aConnection)
Send a connection (net or bus) to Pcbnew for highlighting.
void SetCurrentSheet(const SCH_SHEET_PATH &aPath) override
Definition: schematic.h:124
wxPoint GetPosition() const override
Definition: sch_symbol.h:641
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
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
Ratio of the font height to the baseline of the text above the wire.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
void SendMessageToPCBNEW(EDA_ITEM *aObjectToSync, SCH_SYMBOL *aPart)
Send a message to Pcbnew via a socket connection.
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
const Vec & GetSize() const
Definition: box2.h:179
CROSS_PROBING_SETTINGS m_CrossProbing
Definition: app_settings.h:167
int GetUnit() const
Definition: sch_symbol.h:195
MAIL_T Command()
Returns the MAIL_T associated with this mail.
Definition: kiway_express.h:49
bool center_on_items
Automatically pan to cross-probed items.
Definition: app_settings.h:32
Implement an OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:414
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:197
std::string FormatProbeItem(EDA_ITEM *aItem, SCH_SYMBOL *aSymbol)
std::string & GetPayload()
Return the payload, which can be any text but it typically self identifying s-expression.
Definition: kiway_express.h:57
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364
static std::vector< std::string > split(const std::string &aStr, const std::string &aDelim)
Split the input string into a vector of output strings.
Definition: kicad_string.h:290
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113