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