KiCad PCB EDA Suite
dialog_exchange_footprints.cpp File Reference
#include <bitmaps.h>
#include <board_commit.h>
#include <class_board.h>
#include <class_module.h>
#include <dialog_exchange_footprints.h>
#include <fctsys.h>
#include <kicad_string.h>
#include <kiway.h>
#include <macros.h>
#include <pcb_edit_frame.h>
#include <pcbnew_settings.h>
#include <project.h>
#include <wx_html_report_panel.h>

Go to the source code of this file.

Macros

#define ID_MATCH_FP_ALL   4200
 
#define ID_MATCH_FP_SELECTED   4201
 
#define ID_MATCH_FP_REF   4202
 
#define ID_MATCH_FP_VAL   4203
 
#define ID_MATCH_FP_ID   4204
 

Functions

void processTextItem (const TEXTE_MODULE &aSrc, TEXTE_MODULE &aDest, bool resetText, bool resetTextLayers, bool resetTextEffects)
 
TEXTE_MODULEgetMatchingTextItem (TEXTE_MODULE *aRefItem, MODULE *aModule)
 

Variables

int g_matchModeForUpdate = ID_MATCH_FP_ALL
 
int g_matchModeForUpdateSelected = ID_MATCH_FP_SELECTED
 
int g_matchModeForExchange = ID_MATCH_FP_REF
 
int g_matchModeForExchangeSelected = ID_MATCH_FP_SELECTED
 
bool g_removeExtraTextItems = false
 
bool g_resetTextItemLayers = false
 
bool g_resetTextItemEffects = false
 
bool g_reset3DModels = false
 

Macro Definition Documentation

◆ ID_MATCH_FP_ALL

#define ID_MATCH_FP_ALL   4200

Definition at line 42 of file dialog_exchange_footprints.cpp.

◆ ID_MATCH_FP_ID

#define ID_MATCH_FP_ID   4204

Definition at line 46 of file dialog_exchange_footprints.cpp.

◆ ID_MATCH_FP_REF

#define ID_MATCH_FP_REF   4202

Definition at line 44 of file dialog_exchange_footprints.cpp.

◆ ID_MATCH_FP_SELECTED

#define ID_MATCH_FP_SELECTED   4201

Definition at line 43 of file dialog_exchange_footprints.cpp.

◆ ID_MATCH_FP_VAL

#define ID_MATCH_FP_VAL   4203

Definition at line 45 of file dialog_exchange_footprints.cpp.

Function Documentation

◆ getMatchingTextItem()

TEXTE_MODULE* getMatchingTextItem ( TEXTE_MODULE aRefItem,
MODULE aModule 
)

Definition at line 411 of file dialog_exchange_footprints.cpp.

412 {
413  std::vector<TEXTE_MODULE*> candidates;
414 
415  for( BOARD_ITEM* item : aModule->GraphicalItems() )
416  {
417  TEXTE_MODULE* candidate = dyn_cast<TEXTE_MODULE*>( item );
418 
419  if( candidate && candidate->GetText() == aRefItem->GetText() )
420  candidates.push_back( candidate );
421  }
422 
423  if( candidates.size() == 0 )
424  return nullptr;
425 
426  if( candidates.size() == 1 )
427  return candidates[0];
428 
429  // Try refining the match by layer
430  std::vector<TEXTE_MODULE*> candidatesOnSameLayer;
431 
432  for( TEXTE_MODULE* candidate : candidates )
433  {
434  if( candidate->GetLayer() == aRefItem->GetLayer() )
435  candidatesOnSameLayer.push_back( candidate );
436  }
437 
438  if( candidatesOnSameLayer.size() == 1 )
439  return candidatesOnSameLayer[0];
440 
441  // Last ditch effort: refine by position
442  std::vector<TEXTE_MODULE*> candidatesAtSamePos;
443 
444  for( TEXTE_MODULE* candidate : candidatesOnSameLayer.size() ? candidatesOnSameLayer : candidates )
445  {
446  if( candidate->GetPos0() == aRefItem->GetPos0() )
447  candidatesAtSamePos.push_back( candidate );
448  }
449 
450  if( candidatesAtSamePos.size() > 0 )
451  return candidatesAtSamePos[0];
452  else if( candidatesOnSameLayer.size() > 0 )
453  return candidatesOnSameLayer[0];
454  else
455  return candidates[0];
456 }
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
DRAWINGS & GraphicalItems()
Definition: class_module.h:183
const wxPoint & GetPos0() const
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:127

References BOARD_ITEM::GetLayer(), TEXTE_MODULE::GetPos0(), EDA_TEXT::GetText(), and MODULE::GraphicalItems().

Referenced by PCB_EDIT_FRAME::Exchange_Module().

◆ processTextItem()

void processTextItem ( const TEXTE_MODULE aSrc,
TEXTE_MODULE aDest,
bool  resetText,
bool  resetTextLayers,
bool  resetTextEffects 
)

Definition at line 389 of file dialog_exchange_footprints.cpp.

391 {
392  if( !resetText )
393  aDest.SetText( aSrc.GetText() );
394 
395  if( !resetTextLayers )
396  {
397  aDest.SetLayer( aSrc.GetLayer() );
398  aDest.SetVisible( aSrc.IsVisible() );
399  }
400 
401  if( !resetTextEffects )
402  {
403  // Careful: the visible bit is also in Effects
404  bool visible = aDest.IsVisible();
405  aDest.SetEffects( aSrc );
406  aDest.SetVisible( visible );
407  }
408 }
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
bool IsVisible() const
Definition: eda_text.h:186
void SetVisible(bool aVisible)
Definition: eda_text.h:185
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:121
void SetEffects(const TEXTE_MODULE &aSrc)
Function SetEffects sets the text effects from another instance.
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:127

References BOARD_ITEM::GetLayer(), EDA_TEXT::GetText(), EDA_TEXT::IsVisible(), TEXTE_MODULE::SetEffects(), BOARD_ITEM::SetLayer(), EDA_TEXT::SetText(), and EDA_TEXT::SetVisible().

Referenced by PCB_EDIT_FRAME::Exchange_Module().

Variable Documentation

◆ g_matchModeForExchange

int g_matchModeForExchange = ID_MATCH_FP_REF

◆ g_matchModeForExchangeSelected

int g_matchModeForExchangeSelected = ID_MATCH_FP_SELECTED

◆ g_matchModeForUpdate

int g_matchModeForUpdate = ID_MATCH_FP_ALL

◆ g_matchModeForUpdateSelected

int g_matchModeForUpdateSelected = ID_MATCH_FP_SELECTED

◆ g_removeExtraTextItems

◆ g_reset3DModels

◆ g_resetTextItemEffects

◆ g_resetTextItemLayers