KiCad PCB EDA Suite
dialog_design_rules.cpp File Reference
#include <fctsys.h>
#include <class_drawpanel.h>
#include <base_units.h>
#include <confirm.h>
#include <pcbnew.h>
#include <pcb_edit_frame.h>
#include <board_design_settings.h>
#include <pcbnew_id.h>
#include <class_track.h>
#include <macros.h>
#include <html_messagebox.h>
#include <dialog_text_entry.h>
#include <dialog_design_rules.h>
#include <wx/generic/gridctrl.h>
#include <dialog_design_rules_aux_helper_class.h>
#include <tool/tool_event.h>
#include <tool/tool_manager.h>

Go to the source code of this file.

Macros

#define NET_TITLE   _( "Net" )
 
#define CLASS_TITLE   _( "Class" )
 
#define MYCELL(col)   ValueFromString( g_UserUnit, grid->GetCellValue( row, col ) )
 

Enumerations

enum  {
  GRID_CLEARANCE, GRID_TRACKSIZE, GRID_VIASIZE, GRID_VIADRILL,
  GRID_uVIASIZE, GRID_uVIADRILL, GRID_DIFF_PAIR_WIDTH, GRID_DIFF_PAIR_GAP
}
 

Functions

static void EnsureGridColumnWidths (wxWindow *aShower, wxGrid *aGrid)
 Function EnsureGridColumnWidths resizes all the columns in a wxGrid based only on the requirements of the column titles and not on the grid cell requirements, assuming that the grid cell width requirements are narrower than the column title requirements. More...
 
static void EnsureGridRowTitleWidth (wxWindow *aShower, wxGrid *aGrid, int aMinWidth)
 
static bool sortByClassThenName (NETCUP *a, NETCUP *b)
 
static void class2gridRow (wxGrid *grid, int row, const NETCLASSPTR &nc)
 
static void gridRow2class (wxGrid *grid, int row, const NETCLASSPTR &nc)
 
int sort_int (int *first, int *second)
 

Macro Definition Documentation

#define CLASS_TITLE   _( "Class" )
#define MYCELL (   col)    ValueFromString( g_UserUnit, grid->GetCellValue( row, col ) )

Referenced by gridRow2class().

#define NET_TITLE   _( "Net" )

Enumeration Type Documentation

anonymous enum
Enumerator
GRID_CLEARANCE 
GRID_TRACKSIZE 
GRID_VIASIZE 
GRID_VIADRILL 
GRID_uVIASIZE 
GRID_uVIADRILL 
GRID_DIFF_PAIR_WIDTH 
GRID_DIFF_PAIR_GAP 

Definition at line 59 of file dialog_design_rules.cpp.

Function Documentation

static void class2gridRow ( wxGrid *  grid,
int  row,
const NETCLASSPTR &  nc 
)
static

Definition at line 483 of file dialog_design_rules.cpp.

References g_UserUnit, GRID_CLEARANCE, GRID_DIFF_PAIR_GAP, GRID_DIFF_PAIR_WIDTH, GRID_TRACKSIZE, GRID_uVIADRILL, GRID_uVIASIZE, GRID_VIADRILL, GRID_VIASIZE, and StringFromValue().

Referenced by DIALOG_DESIGN_RULES::InitRulesList().

484 {
485  wxString msg;
486 
487  // label is netclass name
488  grid->SetRowLabelValue( row, nc->GetName() );
489 
490  msg = StringFromValue( g_UserUnit, nc->GetClearance() );
491  grid->SetCellValue( row, GRID_CLEARANCE, msg );
492 
493  msg = StringFromValue( g_UserUnit, nc->GetTrackWidth() );
494  grid->SetCellValue( row, GRID_TRACKSIZE, msg );
495 
496  msg = StringFromValue( g_UserUnit, nc->GetViaDiameter() );
497  grid->SetCellValue( row, GRID_VIASIZE, msg );
498 
499  msg = StringFromValue( g_UserUnit, nc->GetViaDrill() );
500  grid->SetCellValue( row, GRID_VIADRILL, msg );
501 
502  msg = StringFromValue( g_UserUnit, nc->GetuViaDiameter() );
503  grid->SetCellValue( row, GRID_uVIASIZE, msg );
504 
505  msg = StringFromValue( g_UserUnit, nc->GetuViaDrill() );
506  grid->SetCellValue( row, GRID_uVIADRILL, msg );
507 
508  msg = StringFromValue( g_UserUnit, nc->GetDiffPairGap() );
509  grid->SetCellValue( row, GRID_DIFF_PAIR_GAP, msg );
510 
511  msg = StringFromValue( g_UserUnit, nc->GetDiffPairWidth() );
512  grid->SetCellValue( row, GRID_DIFF_PAIR_WIDTH, msg );
513 
514 }
wxString StringFromValue(EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymbol)
Function StringFromValue returns the string from aValue according to units (inch, mm ...
Definition: base_units.cpp:205
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:57
static void EnsureGridColumnWidths ( wxWindow *  aShower,
wxGrid *  aGrid 
)
static

Function EnsureGridColumnWidths resizes all the columns in a wxGrid based only on the requirements of the column titles and not on the grid cell requirements, assuming that the grid cell width requirements are narrower than the column title requirements.

Definition at line 124 of file dialog_design_rules.cpp.

Referenced by DIALOG_DESIGN_RULES::DIALOG_DESIGN_RULES().

125 {
126  wxWindowDC sDC( aShower );
127 
128  sDC.SetFont( aGrid->GetLabelFont() );
129 
130  int colCount = aGrid->GetNumberCols();
131 
132  for( int col = 0; col < colCount; ++col )
133  {
134  // add two spaces to the text and size it.
135  wxString colText = aGrid->GetColLabelValue( col ) + wxT( " " );
136 
137  wxSize needed = sDC.GetTextExtent( colText );
138 
139  // set the width of this column
140  aGrid->SetColSize( col, needed.x );
141  }
142 }
static void EnsureGridRowTitleWidth ( wxWindow *  aShower,
wxGrid *  aGrid,
int  aMinWidth 
)
static

Definition at line 144 of file dialog_design_rules.cpp.

References max.

Referenced by DIALOG_DESIGN_RULES::DIALOG_DESIGN_RULES(), DIALOG_DESIGN_RULES::OnAddNetclassClick(), and DIALOG_DESIGN_RULES::OnRemoveNetclassClick().

145 {
146  wxWindowDC sDC( aShower );
147  sDC.SetFont( aGrid->GetLabelFont() );
148 
149  int minsize = aMinWidth;
150  int rowCount = aGrid->GetNumberRows();
151 
152  for( int row = 0; row < rowCount; ++row )
153  {
154  // add two spaces to the text and size it.
155  wxString rowText = aGrid->GetRowLabelValue( row ) + wxT( " " );
156 
157  wxSize needed = sDC.GetTextExtent( rowText );
158 
159  minsize = std::max( minsize, needed.x );
160  }
161 
162  // set the width of the row laberls
163  aGrid->SetRowLabelSize( minsize );
164 }
#define max(a, b)
Definition: auxiliary.h:86
static void gridRow2class ( wxGrid *  grid,
int  row,
const NETCLASSPTR &  nc 
)
static

Definition at line 542 of file dialog_design_rules.cpp.

References GRID_CLEARANCE, GRID_DIFF_PAIR_GAP, GRID_DIFF_PAIR_WIDTH, GRID_TRACKSIZE, GRID_uVIADRILL, GRID_uVIASIZE, GRID_VIADRILL, GRID_VIASIZE, and MYCELL.

Referenced by DIALOG_DESIGN_RULES::CopyRulesListToBoard().

543 {
544 #define MYCELL( col ) \
545  ValueFromString( g_UserUnit, grid->GetCellValue( row, col ) )
546 
547  nc->SetClearance( MYCELL( GRID_CLEARANCE ) );
548  nc->SetTrackWidth( MYCELL( GRID_TRACKSIZE ) );
549  nc->SetViaDiameter( MYCELL( GRID_VIASIZE ) );
550  nc->SetViaDrill( MYCELL( GRID_VIADRILL ) );
551  nc->SetuViaDiameter( MYCELL( GRID_uVIASIZE ) );
552  nc->SetuViaDrill( MYCELL( GRID_uVIADRILL ) );
553  nc->SetDiffPairGap( MYCELL( GRID_DIFF_PAIR_GAP ) );
554  nc->SetDiffPairWidth( MYCELL( GRID_DIFF_PAIR_WIDTH ) );
555 
556 }
#define MYCELL(col)
int sort_int ( int *  first,
int *  second 
)

Definition at line 781 of file dialog_design_rules.cpp.

Referenced by DIALOG_DESIGN_RULES::OnRemoveNetclassClick().

782 {
783  return *second - *first;
784 }
static bool sortByClassThenName ( NETCUP a,
NETCUP b 
)
static

Definition at line 365 of file dialog_design_rules.cpp.

References NETCUP::clazz, and NETCUP::net.

Referenced by DIALOG_DESIGN_RULES::makePointers().

366 {
367  // return a < b
368  if( a->clazz < b->clazz )
369  return true;
370 
371  // inside the same class, sort by net name:
372  if( a->clazz == b->clazz )
373  {
374  if( a->net < b->net )
375  return true;
376  }
377 
378  return false;
379 }
wxString clazz
a class name
wxString net
a net name