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>
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  // Get pin position in true schematic coordinate
81  pos = pin->GetPosition();
82  foundItem = pin;
83  break;
84  }
85  }
86  else
87  {
88  pos = component->GetPosition();
89  foundItem = component;
90  break;
91  }
92  }
93  }
94 
95  if( foundItem )
96  break;
97  }
98 
99  CROSS_PROBING_SETTINGS& crossProbingSettings = m_frame->eeconfig()->m_CrossProbing;
100 
101 
102  if( component )
103  {
104  if( *sheetWithComponentFound != m_frame->GetCurrentSheet() )
105  {
106  m_frame->Schematic().SetCurrentSheet( *sheetWithComponentFound );
108  }
109 
110  if( crossProbingSettings.center_on_items )
111  {
113  m_frame->CenterScreen( pos, false );
114 
115  if( crossProbingSettings.zoom_to_fit )
116  {
117 //#define COMP_1_TO_1_RATIO // Un-comment for normal KiCad full screen zoom cross-probe
118 #ifdef COMP_1_TO_1_RATIO
119  // Pass "false" to only include visible fields of component in bbox calculations
120  EDA_RECT bbox = component->GetBoundingBox( false );
121  wxSize bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize();
122  VECTOR2D screenSize = getView()->GetViewport().GetSize();
123 
124  // NOTE: The 1:1 here is using the default KiCad sizing, which adds a margin of 20%
125 
126  screenSize.x = std::max( 10.0, screenSize.x );
127  screenSize.y = std::max( 10.0, screenSize.y );
128  double ratio = std::max(
129  fabs( bbSize.x / screenSize.x ), fabs( bbSize.y / screenSize.y ) );
130 
131  // Try not to zoom on every cross-probe; it gets very noisy
132  if( ratio < 0.5 || ratio > 1.0 )
133  getView()->SetScale( getView()->GetScale() / ratio );
134 #endif // COMP_1_TO_1_RATIO
135 
136 #ifndef COMP_1_TO_1_RATIO // Do the scaled zoom
137  // Pass "false" to only include visible fields of component in bbox calculations
138  EDA_RECT bbox = component->GetBoundingBox( false );
139  wxSize bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize();
140  VECTOR2D screenSize = getView()->GetViewport().GetSize();
141 
142  // This code tries to come up with a zoom factor that doesn't simply zoom in
143  // to the cross probed component, but instead shows a reasonable amount of the
144  // circuit around it to provide context. This reduces or eliminates the need
145  // to manually change the zoom because it's too close.
146 
147  // Using the default text height as a constant to compare against, use the
148  // height of the bounding box of visible items for a footprint to figure out
149  // if this is a big symbol (like a processor) or a small symbol (like a resistor).
150  // This ratio is not useful by itself as a scaling factor. It must be "bent" to
151  // provide good scaling at varying component sizes. Bigger components need less
152  // scaling than small ones.
153  double currTextHeight = Mils2iu( DEFAULT_TEXT_SIZE );
154 
155  double compRatio = bbSize.y / currTextHeight; // Ratio of component to text height
156  double compRatioBent = 1.0;
157 
158  // LUT to scale zoom ratio to provide reasonable schematic context. Must work
159  // with symbols of varying sizes (e.g. 0402 package and 200 pin BGA).
160  // "first" is used as the input and "second" as the output
161  //
162  // "first" = compRatio (symbol height / default text height)
163  // "second" = Amount to scale ratio by
164  std::vector<std::pair<double, double>> lut
165  {
166  {1.25, 16}, // 32
167  {2.5, 12}, //24
168  {5, 8}, // 16
169  {6, 6}, //
170  {10, 4}, //8
171  {20, 2}, //4
172  {40, 1.5}, // 2
173  {100, 1}
174  };
175 
176  std::vector<std::pair<double, double>>::iterator it;
177 
178  compRatioBent =
179  lut.back().second; // Large component default is last LUT entry (1:1)
180 
181  // Use LUT to do linear interpolation of "compRatio" within "first", then
182  // use that result to linearly interpolate "second" which gives the scaling
183  // factor needed.
184 
185  if( compRatio >= lut.front().first )
186  {
187  for( it = lut.begin(); it < lut.end() - 1; it++ )
188  {
189  if( it->first <= compRatio && next( it )->first >= compRatio )
190  {
191 
192  double diffx = compRatio - it->first;
193  double diffn = next( it )->first - it->first;
194 
195  compRatioBent = it->second
196  + ( next( it )->second - it->second ) * diffx / diffn;
197  break; // We have our interpolated value
198  }
199  }
200  }
201  else
202  compRatioBent = lut.front().second; // Small component default is first entry
203 
204  // This is similar to the original KiCad code that scaled the zoom to make sure
205  // components were visible on screen. It's simply a ratio of screen size to component
206  // size, and its job is to zoom in to make the component fullscreen. Earlier in the
207  // code the component BBox is given a 20% margin to add some breathing room. We compare
208  // the height of this enlarged component bbox to the default text height. If a
209  // component will end up with the sides clipped, we adjust later to make sure it fits
210  // on screen.
211  screenSize.x = std::max( 10.0, screenSize.x );
212  screenSize.y = std::max( 10.0, screenSize.y );
213  double ratio = std::max( -1.0, fabs( bbSize.y / screenSize.y ) );
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 will be
219  // after the zoom, then punt and use the KiCad zoom algorithm since it guarantees the
220  // part's width will be encompassed within the screen.
221 
222  if( bbSize.x > screenSize.x * ratio * compRatioBent )
223  {
224  ratio = kicadRatio; // Use standard KiCad zoom for parts too wide to fit on screen
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 original
232  // 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  // Try not to zoom on every cross-probe; it gets very noisy
237  if( ( ratio < 0.5 || ratio > 1.0 ) || alwaysZoom )
238  getView()->SetScale( getView()->GetScale() / ratio );
239 #endif // ifndef COMP_1_TO_1_RATIO
240  }
241  }
242  }
243 
244  /* Print diag */
245  wxString msg;
246 
247  if( component )
248  {
249  if( aSearchType == HIGHLIGHT_PIN )
250  {
251  if( foundItem )
252  msg.Printf( _( "%s pin %s found" ), aReference, aSearchText );
253  else
254  msg.Printf( _( "%s found but pin %s not found" ), aReference, aSearchText );
255  }
256  else
257  {
258  msg.Printf( _( "%s found" ), aReference );
259  }
260  }
261  else
262  {
263  msg.Printf( _( "%s not found" ), aReference );
264  }
265 
266  m_frame->SetStatusText( msg );
267 
268  m_probingPcbToSch = true; // recursion guard
269  {
270  // Clear any existing highlighting
272 
273  if( foundItem )
274  m_toolMgr->RunAction( EE_ACTIONS::addItemToSel, true, foundItem );
275  }
276  m_probingPcbToSch = false;
277 
278  m_frame->GetCanvas()->Refresh();
279 
280  return foundItem;
281 }
282 
283 
284 void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
285 {
287  char line[1024];
288 
289  strncpy( line, cmdline, sizeof(line) - 1 );
290  line[ sizeof(line) - 1 ] = '\0';
291 
292  char* idcmd = strtok( line, " \n\r" );
293  char* text = strtok( NULL, "\"\n\r" );
294 
295  if( idcmd == NULL )
296  return;
297 
298  CROSS_PROBING_SETTINGS& crossProbingSettings = eeconfig()->m_CrossProbing;
299 
300  if( strcmp( idcmd, "$NET:" ) == 0 )
301  {
302  if( !crossProbingSettings.auto_highlight )
303  return;
304 
305  wxString netName = FROM_UTF8( text );
306 
307  if( auto sg = Schematic().ConnectionGraph()->FindFirstSubgraphByName( netName ) )
308  m_highlightedConn = sg->m_driver_connection;
309  else
310  m_highlightedConn = nullptr;
311 
313 
314  SetStatusText( _( "Selected net:" ) + wxS( " " ) + UnescapeString( netName ) );
315  return;
316  }
317 
318  if( strcmp( idcmd, "$CLEAR:" ) == 0 )
319  {
320  // Cross-probing is now done through selection so we no longer need a clear command
321  return;
322  }
323 
324  if( text == NULL )
325  return;
326 
327  if( strcmp( idcmd, "$PART:" ) != 0 )
328  return;
329 
330  wxString part_ref = FROM_UTF8( text );
331 
332  /* look for a complement */
333  idcmd = strtok( NULL, " \n\r" );
334 
335  if( idcmd == NULL ) // Highlight component only (from Cvpcb or Pcbnew)
336  {
337  // Highlight component part_ref, or clear Highlight, if part_ref is not existing
338  editor->FindComponentAndItem( part_ref, true, HIGHLIGHT_COMPONENT, wxEmptyString );
339  return;
340  }
341 
342  text = strtok( NULL, "\"\n\r" );
343 
344  if( text == NULL )
345  return;
346 
347  wxString msg = FROM_UTF8( text );
348 
349  if( strcmp( idcmd, "$REF:" ) == 0 )
350  {
351  // Highlighting the reference itself isn't actually that useful, and it's harder to
352  // see. Highlight the parent and display the message.
353  editor->FindComponentAndItem( part_ref, true, HIGHLIGHT_COMPONENT, msg );
354  }
355  else if( strcmp( idcmd, "$VAL:" ) == 0 )
356  {
357  // Highlighting the value itself isn't actually that useful, and it's harder to see.
358  // Highlight the parent and display the message.
359  editor->FindComponentAndItem( part_ref, true, HIGHLIGHT_COMPONENT, msg );
360  }
361  else if( strcmp( idcmd, "$PAD:" ) == 0 )
362  {
363  editor->FindComponentAndItem( part_ref, true, HIGHLIGHT_PIN, msg );
364  }
365  else
366  {
367  editor->FindComponentAndItem( part_ref, true, HIGHLIGHT_COMPONENT, wxEmptyString );
368  }
369 }
370 
371 
372 std::string FormatProbeItem( EDA_ITEM* aItem, SCH_COMPONENT* aSymbol )
373 {
374  // This is a keyword followed by a quoted string.
375 
376  // Cross probing to Pcbnew if a pin or a component is found
377  switch( aItem->Type() )
378  {
379  case SCH_FIELD_T:
380  if( aSymbol )
381  {
382  return StrPrintf( "$PART: \"%s\"",
383  TO_UTF8( aSymbol->GetField( REFERENCE_FIELD )->GetText() ) );
384  }
385  break;
386 
387  case SCH_COMPONENT_T:
388  aSymbol = (SCH_COMPONENT*) aItem;
389  return StrPrintf( "$PART: \"%s\"",
390  TO_UTF8( aSymbol->GetField( REFERENCE_FIELD )->GetText() ) );
391 
392  case SCH_SHEET_T:
393  {
394  // For cross probing, we need the full path of the sheet, because
395  // in complex hierarchies the sheet uuid of not unique
396  SCH_SHEET* sheet = (SCH_SHEET*)aItem;
397  wxString full_path;
398 
399  SCH_SHEET* parent = sheet;
400  while( (parent = dynamic_cast<SCH_SHEET*>( parent->GetParent() ) ) )
401  {
402  if( parent->GetParent() ) // The root sheet has no parent and path is just "/"
403  {
404  full_path.Prepend( parent->m_Uuid.AsString() );
405  full_path.Prepend( "/" );
406  }
407  }
408 
409  full_path += "/" + sheet->m_Uuid.AsString();
410 
411  return StrPrintf( "$SHEET: \"%s\"", TO_UTF8( full_path ) );
412  }
413 
414  case SCH_PIN_T:
415  {
416  SCH_PIN* pin = (SCH_PIN*) aItem;
417  aSymbol = pin->GetParentSymbol();
418 
419  if( !pin->GetNumber().IsEmpty() )
420  {
421  return StrPrintf( "$PIN: \"%s\" $PART: \"%s\"",
422  TO_UTF8( pin->GetNumber() ),
423  TO_UTF8( aSymbol->GetField( REFERENCE_FIELD )->GetText() ) );
424  }
425  else
426  {
427  return StrPrintf( "$PART: \"%s\"",
428  TO_UTF8( aSymbol->GetField( REFERENCE_FIELD )->GetText() ) );
429  }
430  }
431 
432  default:
433  break;
434  }
435 
436  return "";
437 }
438 
439 
441 {
442  wxASSERT( aObjectToSync ); // fix the caller
443 
444  if( !aObjectToSync )
445  return;
446 
447  std::string packet = FormatProbeItem( aObjectToSync, aLibItem );
448 
449  if( !packet.empty() )
450  {
451  if( Kiface().IsSingle() )
452  SendCommand( MSG_TO_PCB, packet.c_str() );
453  else
454  {
455  // Typically ExpressMail is going to be s-expression packets, but since
456  // we have existing interpreter of the cross probe packet on the other
457  // side in place, we use that here.
459  }
460  }
461 }
462 
463 
464 void SCH_EDIT_FRAME::SendCrossProbeNetName( const wxString& aNetName )
465 {
466  // The command is a keyword followed by a quoted string.
467 
468  std::string packet = StrPrintf( "$NET: \"%s\"", TO_UTF8( aNetName ) );
469 
470  if( !packet.empty() )
471  {
472  if( Kiface().IsSingle() )
473  SendCommand( MSG_TO_PCB, packet.c_str() );
474  else
475  {
476  // Typically ExpressMail is going to be s-expression packets, but since
477  // we have existing interpreter of the cross probe packet on the other
478  // side in place, we use that here.
480  }
481  }
482 }
483 
484 
486 {
487  if( !aConnection )
488  {
490  return;
491  }
492 
493  if( aConnection->IsNet() )
494  {
495  SendCrossProbeNetName( aConnection->Name() );
496  return;
497  }
498 
499  if( aConnection->Members().empty() )
500  return;
501 
502  auto all_members = aConnection->AllMembers();
503 
504  wxString nets = all_members[0]->Name();
505 
506  if( all_members.size() == 1 )
507  {
508  SendCrossProbeNetName( nets );
509  return;
510  }
511 
512  // TODO: This could be replaced by just sending the bus name once we have bus contents
513  // included as part of the netlist sent from eeschema to pcbnew (and thus pcbnew can
514  // natively keep track of bus membership)
515 
516  for( size_t i = 1; i < all_members.size(); i++ )
517  nets << "," << all_members[i]->Name();
518 
519  std::string packet = StrPrintf( "$NETS: \"%s\"", TO_UTF8( nets ) );
520 
521  if( !packet.empty() )
522  {
523  if( Kiface().IsSingle() )
524  SendCommand( MSG_TO_PCB, packet.c_str() );
525  else
526  {
527  // Typically ExpressMail is going to be s-expression packets, but since
528  // we have existing interpreter of the cross probe packet on the other
529  // side in place, we use that here.
531  }
532  }
533 }
534 
535 
537 {
538  std::string packet = "$CLEAR\n";
539 
540  if( Kiface().IsSingle() )
541  SendCommand( MSG_TO_PCB, packet.c_str() );
542  else
543  {
544  // Typically ExpressMail is going to be s-expression packets, but since
545  // we have existing interpreter of the cross probe packet on the other
546  // side in place, we use that here.
548  }
549 }
550 
551 
553 {
554  std::string& payload = mail.GetPayload();
555 
556  switch( mail.Command() )
557  {
558  case MAIL_CROSS_PROBE:
559  ExecuteRemoteCommand( payload.c_str() );
560  break;
561 
563  {
564  if( !payload.empty() )
565  {
566  wxString annotationMessage( payload );
567 
568  // Ensure schematic is OK for netlist creation (especially that it is fully annotated):
569  if( !ReadyToNetlist( annotationMessage ) )
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  {
601 
603  GetCanvas()->Refresh();
604  }
605  break;
606 
608  {
609  NET_SETTINGS& netSettings = Prj().GetProjectFile().NetSettings();
610 
611  netSettings.m_NetClassAssignments.clear();
612 
613  // Establish the set of nets which is currently valid
614  for( const wxString& name : Schematic().GetNetClassAssignmentCandidates() )
615  netSettings.m_NetClassAssignments[ name ] = "Default";
616 
617  // Copy their netclass assignments, dropping any assignments to non-current nets.
618  for( auto& ii : netSettings.m_NetClasses )
619  {
620  for( const wxString& member : *ii.second )
621  {
622  if( netSettings.m_NetClassAssignments.count( member ) )
623  netSettings.m_NetClassAssignments[ member ] = ii.first;
624  }
625 
626  ii.second->Clear();
627  }
628 
629  // Update the membership lists to contain only the current nets.
630  for( const std::pair<const wxString, wxString>& ii : netSettings.m_NetClassAssignments )
631  {
632  if( ii.second == "Default" )
633  continue;
634 
635  NETCLASSPTR netclass = netSettings.m_NetClasses.Find( ii.second );
636 
637  if( netclass )
638  netclass->Add( ii.first );
639  }
640 
641  netSettings.ResolveNetClassAssignments();
642  }
643  break;
644 
645  case MAIL_IMPORT_FILE:
646  {
647  // Extract file format type and path (plugin type and path separated with \n)
648  size_t split = payload.find( '\n' );
649  wxCHECK( split != std::string::npos, /*void*/ );
650  int importFormat;
651 
652  try
653  {
654  importFormat = std::stoi( payload.substr( 0, split ) );
655  }
656  catch( std::invalid_argument& )
657  {
658  wxFAIL;
659  importFormat = -1;
660  }
661 
662  std::string path = payload.substr( split + 1 );
663  wxASSERT( !path.empty() );
664 
665  if( importFormat >= 0 )
666  importFile( path, importFormat );
667  }
668  break;
669 
670  case MAIL_SCH_SAVE:
671  if( SaveProject() )
672  payload = "success";
673 
674  break;
675 
676  case MAIL_SCH_UPDATE:
678  break;
679 
680  case MAIL_REANNOTATE:
681  //Reannotate the schematic as per the netlist.
682  ReannotateFromPCBNew( this, payload );
683  break;
684 
685  default:;
686 
687  }
688 }
Field Reference of part, i.e. "IC21".
bool ReadyToNetlist(const wxString &aAnnotateMessage)
Checks 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:219
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:43
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:513
KIWAY & Kiway() const
Return 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
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.
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Returns a mandatory field in this symbol.
Definition: sch_symbol.cpp:688
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generates the connection data for the entire schematic hierarchy.
SCH_COMPONENT * GetParentSymbol() const
Definition: sch_pin.cpp:141
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:145
void SendCrossProbeClearHighlight()
Tells PcbNew to clear the existing highlighted net, if one exists.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1412
int GetWidth() const
Definition: eda_rect.h:114
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
wxString AsString() const
Definition: kiid.cpp:213
NET_SETTINGS & NetSettings()
Definition: project_file.h:92
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:439
wxString GetNumber() const
Definition: sch_pin.h:116
bool SendCommand(int service, const char *cmdline)
Definition: eda_dde.cpp:131
void DisplayCurrentSheet()
Draw the current sheet on the display.
Definition: hierarch.cpp:289
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:215
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:89
std::string FormatProbeItem(EDA_ITEM *aItem, SCH_COMPONENT *aSymbol)
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
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
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)
Find a component in the schematic and an item in this component.
static TOOL_ACTION updateSchematicFromPcb
Definition: actions.h:167
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:57
#define NULL
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 ReannotateFromPCBNew(SCH_EDIT_FRAME *aFrame, std::string &aNetlist)
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.
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:164
NET_SETTINGS stores various net-related settings in a project context.
Definition: net_settings.h:31
const std::string & GetString()
Definition: richio.h:435
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:54
#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:219
const KIID m_Uuid
Definition: eda_item.h:524
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
Definition: view.cpp:553
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:111
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:157
SCH_SEARCH_T
Schematic search type used by the socket link with Pcbnew.
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:150
EE_RTREE & Items()
Definition: sch_screen.h:162
#define MSG_TO_PCB
Definition: eda_dde.h:45
Handle the component boundary box.
Definition: eda_rect.h:42
Schematic symbol object.
Definition: sch_symbol.h:78
wxPoint GetPosition() const override
Definition: sch_symbol.h:680
void SetCrossProbeConnection(const SCH_CONNECTION *aConnection)
Sends a connection (net or bus) to pcbnew for highlighting.
void SetCurrentSheet(const SCH_SHEET_PATH &aPath) override
Definition: schematic.h:146
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:149
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.
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
const Vec & GetSize() const
Definition: box2.h:189
CROSS_PROBING_SETTINGS m_CrossProbing
Definition: app_settings.h:167
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:411
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:196
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: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:273
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:162
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:427
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
Definition: sch_symbol.cpp:837