KiCad PCB EDA Suite
pcbnew/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-2021 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-3.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 
34 #include <board.h>
35 #include <footprint.h>
36 #include <track.h>
37 #include <collectors.h>
38 #include <eda_dde.h>
39 #include <kiface_i.h>
40 #include <kiway_express.h>
43 #include <painter.h>
44 #include <pcb_edit_frame.h>
45 #include <pcbnew_settings.h>
46 #include <render_settings.h>
47 #include <tool/tool_manager.h>
48 #include <tools/pcb_actions.h>
51 
52 /* Execute a remote command send by Eeschema via a socket,
53  * port KICAD_PCB_PORT_SERVICE_NUMBER
54  * cmdline = received command from Eeschema
55  * Commands are
56  * $PART: "reference" put cursor on component
57  * $PIN: "pin name" $PART: "reference" put cursor on the footprint pin
58  * $NET: "net name" highlight the given net (if highlight tool is active)
59  * $CLEAR Clear existing highlight
60  * They are a keyword followed by a quoted string.
61  */
62 void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
63 {
64  char line[1024];
65  wxString msg;
66  wxString modName;
67  char* idcmd;
68  char* text;
69  int netcode = -1;
70  bool multiHighlight = false;
71  FOOTPRINT* footprint = nullptr;
72  PAD* pad = nullptr;
73  BOARD* pcb = GetBoard();
74 
75  CROSS_PROBING_SETTINGS& crossProbingSettings = GetPcbNewSettings()->m_CrossProbing;
76 
78  KIGFX::RENDER_SETTINGS* renderSettings = view->GetPainter()->GetSettings();
79 
80  strncpy( line, cmdline, sizeof(line) - 1 );
81  line[sizeof(line) - 1] = 0;
82 
83  idcmd = strtok( line, " \n\r" );
84  text = strtok( NULL, "\"\n\r" );
85 
86  if( idcmd == NULL )
87  return;
88 
89  if( strcmp( idcmd, "$NET:" ) == 0 )
90  {
91  if( !crossProbingSettings.auto_highlight )
92  return;
93 
94  wxString net_name = FROM_UTF8( text );
95 
96  NETINFO_ITEM* netinfo = pcb->FindNet( net_name );
97 
98  if( netinfo )
99  {
100  netcode = netinfo->GetNetCode();
101 
102  MSG_PANEL_ITEMS items;
103  netinfo->GetMsgPanelInfo( this, items );
104  SetMsgPanel( items );
105  }
106  }
107  if( strcmp( idcmd, "$NETS:" ) == 0 )
108  {
109  if( !crossProbingSettings.auto_highlight )
110  return;
111 
112  wxStringTokenizer netsTok = wxStringTokenizer( FROM_UTF8( text ), "," );
113  bool first = true;
114 
115  while( netsTok.HasMoreTokens() )
116  {
117  NETINFO_ITEM* netinfo = pcb->FindNet( netsTok.GetNextToken() );
118 
119  if( netinfo )
120  {
121  if( first )
122  {
123  // TODO: Once buses are included in netlist, show bus name
124  MSG_PANEL_ITEMS items;
125  netinfo->GetMsgPanelInfo( this, items );
126  SetMsgPanel( items );
127  first = false;
128 
129  pcb->SetHighLightNet( netinfo->GetNetCode() );
130  renderSettings->SetHighlight( true, netinfo->GetNetCode() );
131  multiHighlight = true;
132  }
133  else
134  {
135  pcb->SetHighLightNet( netinfo->GetNetCode(), true );
136  renderSettings->SetHighlight( true, netinfo->GetNetCode(), true );
137  }
138  }
139  }
140 
141  netcode = -1;
142  }
143  else if( strcmp( idcmd, "$PIN:" ) == 0 )
144  {
145  wxString pinName = FROM_UTF8( text );
146 
147  text = strtok( NULL, " \n\r" );
148 
149  if( text && strcmp( text, "$PART:" ) == 0 )
150  text = strtok( NULL, "\"\n\r" );
151 
152  modName = FROM_UTF8( text );
153 
154  footprint = pcb->FindFootprintByReference( modName );
155 
156  if( footprint )
157  pad = footprint->FindPadByName( pinName );
158 
159  if( pad )
160  netcode = pad->GetNetCode();
161 
162  if( footprint == NULL )
163  msg.Printf( _( "%s not found" ), modName );
164  else if( pad == NULL )
165  msg.Printf( _( "%s pin %s not found" ), modName, pinName );
166  else
167  msg.Printf( _( "%s pin %s found" ), modName, pinName );
168 
169  SetStatusText( msg );
170  }
171  else if( strcmp( idcmd, "$PART:" ) == 0 )
172  {
173  pcb->ResetNetHighLight();
174 
175  modName = FROM_UTF8( text );
176 
177  footprint = pcb->FindFootprintByReference( modName );
178 
179  if( footprint )
180  msg.Printf( _( "%s found" ), modName );
181  else
182  msg.Printf( _( "%s not found" ), modName );
183 
184  SetStatusText( msg );
185  }
186  else if( strcmp( idcmd, "$SHEET:" ) == 0 )
187  {
188  msg.Printf( _( "Selecting all from sheet \"%s\"" ), FROM_UTF8( text ) );
189  wxString sheetUIID( FROM_UTF8( text ) );
190  SetStatusText( msg );
192  static_cast<void*>( &sheetUIID ) );
193  return;
194  }
195  else if( strcmp( idcmd, "$CLEAR" ) == 0 )
196  {
197  if( renderSettings->IsHighlightEnabled() )
198  {
199  renderSettings->SetHighlight( false );
200  view->UpdateAllLayersColor();
201  }
202 
203  if( pcb->IsHighLightNetON() )
204  {
205  pcb->ResetNetHighLight();
206  SetMsgPanel( pcb );
207  }
208 
209  GetCanvas()->Refresh();
210  return;
211  }
212 
213  BOX2I bbox = { { 0, 0 }, { 0, 0 } };
214 
215  if( footprint )
216  {
217  bbox = footprint->GetBoundingBox( true, false ); // No invisible text in bbox calc
218 
219  if( pad )
220  m_toolManager->RunAction( PCB_ACTIONS::highlightItem, true, (void*) pad );
221  else
222  m_toolManager->RunAction( PCB_ACTIONS::highlightItem, true, (void*) footprint );
223  }
224  else if( netcode > 0 || multiHighlight )
225  {
226  if( !multiHighlight )
227  {
228  renderSettings->SetHighlight( ( netcode >= 0 ), netcode );
229  pcb->SetHighLightNet( netcode );
230  }
231  else
232  {
233  // Just pick the first one for area calculation
234  netcode = *pcb->GetHighLightNetCodes().begin();
235  }
236 
237  pcb->HighLightON();
238 
239  auto merge_area =
240  [netcode, &bbox]( BOARD_CONNECTED_ITEM* aItem )
241  {
242  if( aItem->GetNetCode() == netcode )
243  {
244  if( bbox.GetWidth() == 0 )
245  bbox = aItem->GetBoundingBox();
246  else
247  bbox.Merge( aItem->GetBoundingBox() );
248  }
249  };
250 
251  if( crossProbingSettings.center_on_items )
252  {
253  for( ZONE* zone : pcb->Zones() )
254  merge_area( zone );
255 
256  for( TRACK* track : pcb->Tracks() )
257  merge_area( track );
258 
259  for( FOOTPRINT* fp : pcb->Footprints() )
260  {
261  for( PAD* p : fp->Pads() )
262  merge_area( p );
263  }
264  }
265  }
266  else
267  {
268  renderSettings->SetHighlight( false );
269  }
270 
271  if( crossProbingSettings.center_on_items && bbox.GetWidth() > 0 && bbox.GetHeight() > 0 )
272  {
273  if( crossProbingSettings.zoom_to_fit )
274  {
275 //#define DEFAULT_PCBNEW_CODE // Un-comment for normal full zoom KiCad algorithm
276  #ifdef DEFAULT_PCBNEW_CODE
277  auto bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize();
278  auto screenSize = view->ToWorld( GetCanvas()->GetClientSize(), false );
279 
280  // The "fabs" on x ensures the right answer when the view is flipped
281  screenSize.x = std::max( 10.0, fabs( screenSize.x ) );
282  screenSize.y = std::max( 10.0, screenSize.y );
283  double ratio = std::max( fabs( bbSize.x / screenSize.x ), fabs( bbSize.y / screenSize.y ) );
284 
285  // Try not to zoom on every cross-probe; it gets very noisy
286  if( crossProbingSettings.zoom_to_fit && ( ratio < 0.5 || ratio > 1.0 ) )
287  view->SetScale( view->GetScale() / ratio );
288  #endif // DEFAULT_PCBNEW_CODE
289 
290 #ifndef DEFAULT_PCBNEW_CODE // Do the scaled zoom
291  auto bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize();
292  auto screenSize = view->ToWorld( GetCanvas()->GetClientSize(), false );
293 
294  // This code tries to come up with a zoom factor that doesn't simply zoom in
295  // to the cross probed component, but instead shows a reasonable amount of the
296  // circuit around it to provide context. This reduces or eliminates the need
297  // to manually change the zoom because it's too close.
298 
299  // Using the default text height as a constant to compare against, use the
300  // height of the bounding box of visible items for a footprint to figure out
301  // if this is a big footprint (like a processor) or a small footprint (like a resistor).
302  // This ratio is not useful by itself as a scaling factor. It must be "bent" to
303  // provide good scaling at varying component sizes. Bigger components need less
304  // scaling than small ones.
305  double currTextHeight = Millimeter2iu( DEFAULT_TEXT_SIZE );
306 
307  double compRatio = bbSize.y / currTextHeight; // Ratio of component to text height
308  double compRatioBent = 1.0; // This will end up as the scaling factor we apply to "ratio"
309 
310  // This is similar to the original KiCad code that scaled the zoom to make sure components
311  // were visible on screen. It's simply a ratio of screen size to component size, and its
312  // job is to zoom in to make the component fullscreen. Earlier in the code the
313  // component BBox is given a 20% margin to add some breathing room. We compare
314  // the height of this enlarged component bbox to the default text height. If a component
315  // will end up with the sides clipped, we adjust later to make sure it fits on screen.
316  //
317  // The "fabs" on x ensures the right answer when the view is flipped
318  screenSize.x = std::max( 10.0, fabs( screenSize.x ) );
319  screenSize.y = std::max( 10.0, screenSize.y );
320  double ratio = std::max( -1.0, fabs( bbSize.y / screenSize.y ) );
321  // Original KiCad code for how much to scale the zoom
322  double kicadRatio = std::max( fabs( bbSize.x / screenSize.x ),
323  fabs( bbSize.y / screenSize.y ) );
324 
325  // LUT to scale zoom ratio to provide reasonable schematic context. Must work
326  // with footprints of varying sizes (e.g. 0402 package and 200 pin BGA).
327  // "first" is used as the input and "second" as the output
328  //
329  // "first" = compRatio (footprint height / default text height)
330  // "second" = Amount to scale ratio by
331  std::vector<std::pair<double, double>> lut{
332  { 1, 8 },
333  { 1.5, 5 },
334  { 3, 3 },
335  { 4.5, 2.5 },
336  { 8, 2.0 },
337  { 12, 1.7 },
338  { 16, 1.5 },
339  { 24, 1.3 },
340  { 32, 1.0 },
341  };
342 
343 
344  std::vector<std::pair<double, double>>::iterator it;
345 
346  compRatioBent = lut.back().second; // Large component default
347 
348  if( compRatio >= lut.front().first )
349  {
350  // Use LUT to do linear interpolation of "compRatio" within "first", then
351  // use that result to linearly interpolate "second" which gives the scaling
352  // factor needed.
353 
354  for( it = lut.begin(); it < lut.end() - 1; it++ )
355  {
356  if( it->first <= compRatio && next( it )->first >= compRatio )
357  {
358  double diffx = compRatio - it->first;
359  double diffn = next( it )->first - it->first;
360 
361  compRatioBent =
362  it->second + ( next( it )->second - it->second ) * diffx / diffn;
363  break; // We have our interpolated value
364  }
365  }
366  }
367  else
368  compRatioBent = lut.front().second; // Small component default
369 
370  // If the width of the part we're probing is bigger than what the screen width will be
371  // after the zoom, then punt and use the KiCad zoom algorithm since it guarantees the
372  // part's width will be encompassed within the screen. This will apply to parts that are
373  // much wider than they are tall.
374 
375  if( bbSize.x > screenSize.x * ratio * compRatioBent )
376  {
377  ratio = kicadRatio; // Use standard KiCad zoom algorithm for parts too wide to fit screen
378  compRatioBent = 1.0; // Reset so we don't modify the "KiCad" ratio
379  wxLogTrace( "CROSS_PROBE_SCALE",
380  "Part TOO WIDE for screen. Using normal KiCad zoom ratio: %1.5f", ratio );
381  }
382 
383  // Now that "compRatioBent" holds our final scaling factor we apply it to the original
384  // fullscreen zoom ratio to arrive at the final ratio itself.
385  ratio *= compRatioBent;
386 
387  bool alwaysZoom = false; // DEBUG - allows us to minimize zooming or not
388  // Try not to zoom on every cross-probe; it gets very noisy
389  if( ( ratio < 0.5 || ratio > 1.0 ) || alwaysZoom )
390  view->SetScale( view->GetScale() / ratio );
391 #endif // ifndef DEFAULT_PCBNEW_CODE
392  }
393  view->SetCenter( bbox.Centre() );
394  }
395 
396  view->UpdateAllLayersColor();
397  // Ensure the display is refreshed, because in some installs the refresh is done only
398  // when the gal canvas has the focus, and that is not the case when crossprobing from
399  // Eeschema:
400  GetCanvas()->Refresh();
401 }
402 
403 
404 std::string FormatProbeItem( BOARD_ITEM* aItem )
405 {
406  FOOTPRINT* footprint;
407 
408  if( !aItem )
409  return "$CLEAR: \"HIGHLIGHTED\""; // message to clear highlight state
410 
411  switch( aItem->Type() )
412  {
413  case PCB_FOOTPRINT_T:
414  footprint = (FOOTPRINT*) aItem;
415  return StrPrintf( "$PART: \"%s\"", TO_UTF8( footprint->GetReference() ) );
416 
417  case PCB_PAD_T:
418  {
419  footprint = static_cast<FOOTPRINT*>( aItem->GetParent() );
420  wxString pad = static_cast<PAD*>( aItem )->GetName();
421 
422  return StrPrintf( "$PART: \"%s\" $PAD: \"%s\"",
423  TO_UTF8( footprint->GetReference() ),
424  TO_UTF8( pad ) );
425  }
426 
427  case PCB_FP_TEXT_T:
428  {
429  footprint = static_cast<FOOTPRINT*>( aItem->GetParent() );
430 
431  FP_TEXT* text = static_cast<FP_TEXT*>( aItem );
432  const char* text_key;
433 
434  /* This can't be a switch since the break need to pull out
435  * from the outer switch! */
436  if( text->GetType() == FP_TEXT::TEXT_is_REFERENCE )
437  text_key = "$REF:";
438  else if( text->GetType() == FP_TEXT::TEXT_is_VALUE )
439  text_key = "$VAL:";
440  else
441  break;
442 
443  return StrPrintf( "$PART: \"%s\" %s \"%s\"",
444  TO_UTF8( footprint->GetReference() ),
445  text_key,
446  TO_UTF8( text->GetText() ) );
447  }
448 
449  default:
450  break;
451  }
452 
453  return "";
454 }
455 
456 
457 /* Send a remote command to Eeschema via a socket,
458  * aSyncItem = item to be located on schematic (footprint, pin or text)
459  * Commands are
460  * $PART: "reference" put cursor on component anchor
461  * $PART: "reference" $PAD: "pad number" put cursor on the component pin
462  * $PART: "reference" $REF: "reference" put cursor on the component ref
463  * $PART: "reference" $VAL: "value" put cursor on the component value
464  */
466 {
467  std::string packet = FormatProbeItem( aSyncItem );
468 
469  if( !packet.empty() )
470  {
471  if( Kiface().IsSingle() )
472  SendCommand( MSG_TO_SCH, packet.c_str() );
473  else
474  {
475  // Typically ExpressMail is going to be s-expression packets, but since
476  // we have existing interpreter of the cross probe packet on the other
477  // side in place, we use that here.
478  Kiway().ExpressMail( FRAME_SCH, MAIL_CROSS_PROBE, packet, this );
479  }
480  }
481 }
482 
483 
484 void PCB_EDIT_FRAME::SendCrossProbeNetName( const wxString& aNetName )
485 {
486  std::string packet = StrPrintf( "$NET: \"%s\"", TO_UTF8( aNetName ) );
487 
488  if( !packet.empty() )
489  {
490  if( Kiface().IsSingle() )
491  SendCommand( MSG_TO_SCH, packet.c_str() );
492  else
493  {
494  // Typically ExpressMail is going to be s-expression packets, but since
495  // we have existing interpreter of the cross probe packet on the other
496  // side in place, we use that here.
497  Kiway().ExpressMail( FRAME_SCH, MAIL_CROSS_PROBE, packet, this );
498  }
499  }
500 }
501 
502 
504 {
505  std::string& payload = mail.GetPayload();
506 
507  switch( mail.Command() )
508  {
510  {
511  NETLIST netlist;
512  STRING_FORMATTER sf;
513 
514  for( FOOTPRINT* footprint : GetBoard()->Footprints() )
515  {
516  if( footprint->GetAttributes() & FP_BOARD_ONLY )
517  continue; // Don't add board-only footprints to the netlist
518 
519  COMPONENT* component = new COMPONENT( footprint->GetFPID(), footprint->GetReference(),
520  footprint->GetValue(), footprint->GetPath(), {} );
521 
522  for( PAD* pad : footprint->Pads() )
523  {
524  const wxString& netname = pad->GetShortNetname();
525 
526  if( !netname.IsEmpty() )
527  {
528  component->AddNet( pad->GetName(), netname, pad->GetPinFunction(),
529  pad->GetPinType() );
530  }
531  }
532 
533  netlist.AddComponent( component );
534  }
535 
536  netlist.Format( "pcb_netlist", &sf, 0, CTL_OMIT_FILTERS );
537  payload = sf.GetString();
538  }
539  break;
540 
542  try
543  {
544  NETLIST netlist;
545  FetchNetlistFromSchematic( netlist, wxEmptyString );
546 
547  BOARD_NETLIST_UPDATER updater( this, GetBoard() );
548  updater.SetLookupByTimestamp( false );
549  updater.SetDeleteUnusedComponents ( false );
550  updater.SetReplaceFootprints( false );
551  updater.SetDeleteSinglePadNets( false );
552  updater.SetWarnPadNoNetInNetlist( false );
553  updater.UpdateNetlist( netlist );
554 
555  bool dummy;
556  OnNetlistChanged( updater, &dummy );
557  }
558  catch( const IO_ERROR& )
559  {
560  assert( false ); // should never happen
561  return;
562  }
563  break;
564 
565  case MAIL_CROSS_PROBE:
566  ExecuteRemoteCommand( payload.c_str() );
567  break;
568 
569  case MAIL_PCB_UPDATE:
571  break;
572 
573  case MAIL_IMPORT_FILE:
574  {
575  // Extract file format type and path (plugin type and path separated with \n)
576  size_t split = payload.find( '\n' );
577  wxCHECK( split != std::string::npos, /*void*/ );
578  int importFormat;
579 
580  try
581  {
582  importFormat = std::stoi( payload.substr( 0, split ) );
583  }
584  catch( std::invalid_argument& )
585  {
586  wxFAIL;
587  importFormat = -1;
588  }
589 
590  std::string path = payload.substr( split + 1 );
591  wxASSERT( !path.empty() );
592 
593  if( importFormat >= 0 )
594  importFile( path, importFormat );
595  }
596  break;
597 
598  // many many others.
599  default:
600  ;
601  }
602 }
603 
CITER next(CITER it)
Definition: ptree.cpp:126
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:1268
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:289
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
Definition: kiway_express.h:38
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.
void SendCrossProbeNetName(const wxString &aNetName)
Send a net name to Eeschema for highlighting.
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
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
ZONES & Zones()
Definition: board.h:309
bool importFile(const wxString &aFileName, int aFileType)
Load the given filename but sets the path to the current project path.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
void HighLightON(bool aValue=true)
Enable or disable net highlighting.
Definition: board.cpp:2006
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Converts a screen space point/vector to a point/vector in world space coordinates.
Definition: view.cpp:450
Update the BOARD with a new netlist.
static TOOL_ACTION highlightItem
Definition: pcb_actions.h:450
void SetDeleteSinglePadNets(bool aEnabled)
Enable warning option if a connectable pad is not found in netlist connectable = pad with a name and ...
bool IsHighLightNetON() const
Definition: board.h:469
#define MSG_TO_SCH
Definition: eda_dde.h:46
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
void SetWarnPadNoNetInNetlist(bool aEnabled)
Enable dry run mode (just report, no changes to PCB).
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
Definition: sch_symbol.cpp:69
BOARD_NETLIST_UPDATER class definition.
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
class PAD, a pad in a footprint
Definition: typeinfo.h:89
static TOOL_ACTION updatePcbFromSchematic
Definition: actions.h:166
bool SendCommand(int service, const char *cmdline)
Definition: eda_dde.cpp:131
bool FetchNetlistFromSchematic(NETLIST &aNetlist, const wxString &aAnnotateMessage)
void SetLookupByTimestamp(bool aEnabled)
bool IsHighlightEnabled() const
Return current highlight setting.
void OnNetlistChanged(BOARD_NETLIST_UPDATER &aUpdater, bool *aRunDragCommand)
Called after netlist is updated.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
bool UpdateNetlist(NETLIST &aNetlist)
Update the board's components according to the new netlist.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:207
void AddComponent(COMPONENT *aComponent)
Function AddComponent adds aComponent to the NETLIST.
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
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
void KiwayMailIn(KIWAY_EXPRESS &aEvent) override
Receive KIWAY_EXPRESS messages from other players.
Cross-probing behavior.
Definition: app_settings.h:30
void ResetNetHighLight()
Reset all high light data to the init state.
Definition: board.cpp:1984
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:579
NETLIST stores all of information read from a netlist along with the flags used to update the NETLIST...
Definition: pcb_netlist.h:207
#define NULL
bool IsSingle() const
Is this KIFACE_I running under single_top?
Definition: kiface_i.h:104
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
void ExecuteRemoteCommand(const char *cmdline) override
Execute a remote command send by Eeschema via a socket, port KICAD_PCB_PORT_SERVICE_NUMBER (currently...
coord_type GetWidth() const
Definition: box2.h:197
#define CTL_OMIT_FILTERS
Definition: pcb_netlist.h:296
FOOTPRINTS & Footprints()
Definition: board.h:303
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
void SetReplaceFootprints(bool aEnabled)
Enable removing unused components.
const wxString & GetReference() const
Definition: footprint.h:423
ZONE handles a list of polygons defining a copper zone.
Definition: zone.h:57
const std::string & GetString()
Definition: richio.h:435
PAD * FindPadByName(const wxString &aPadName) const
Return a PAD with a matching name.
Definition: footprint.cpp:956
void SetHighLightNet(int aNetCode, bool aMulti=false)
Select the netcode to be highlighted.
Definition: board.cpp:1993
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect.
Definition: box2.h:386
std::string FormatProbeItem(BOARD_ITEM *aItem)
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
COMPONENT is used to store components and all of their related information found in a netlist.
Definition: pcb_netlist.h:85
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
const std::set< int > & GetHighLightNetCodes() const
Definition: board.h:454
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
Definition: view.cpp:553
void SendMessageToEESCHEMA(BOARD_ITEM *objectToSync)
Send a message to the schematic editor so that it may move its cursor to a symbol with the same refer...
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
bool auto_highlight
Automatically turn on highlight mode in the target frame.
Definition: app_settings.h:34
Handle the data for a net.
Definition: netinfo.h:64
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:302
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:157
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aMulti=false)
Turns on/off highlighting.
Vec Centre() const
Definition: box2.h:79
static TOOL_ACTION selectOnSheetFromEeschema
Select all components on sheet from Eeschema crossprobing.
Definition: pcb_actions.h:87
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
#define _(s)
Definition: 3d_actions.cpp:33
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: footprint.cpp:630
void Format(const char *aDocName, OUTPUTFORMATTER *aOut, int aNestLevel, int aCtl=0)
void SetDeleteUnusedComponents(bool aEnabled)
Enable component lookup by timestamp instead of reference.
PCBNEW_SETTINGS * GetPcbNewSettings() const
coord_type GetHeight() const
Definition: box2.h:198
void AddNet(const wxString &aPinName, const wxString &aNetName, const wxString &aPinFunction, const wxString &aPinType)
Definition: pcb_netlist.h:138
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:97
#define DEFAULT_TEXT_SIZE
Ratio of the font height to the baseline of the text above the wire.
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
BOARD * GetBoard() const
CROSS_PROBING_SETTINGS m_CrossProbing
Definition: app_settings.h:167
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Return the information about the NETINFO_ITEM in aList to display in the message panel.
Definition: pad.h:60
MAIL_T Command()
Returns the MAIL_T associated with this mail.
Definition: kiway_express.h:49
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
Definition: view.cpp:770
double GetScale() const
Definition: view.h:263
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:168
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
static constexpr int Millimeter2iu(double mm)
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
std::string & GetPayload()
Return the payload, which can be any text but it typically self identifying s-expression.
Definition: kiway_express.h:57
TRACKS & Tracks()
Definition: board.h:300
Definition: track.h:83
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
FOOTPRINT * FindFootprintByReference(const wxString &aReference) const
Search for a FOOTPRINT within this board with the given reference designator.
Definition: board.cpp:1289
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:162
int GetNetCode() const
Definition: netinfo.h:113