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 <wxPcbStruct.h>
#include <class_board_design_settings.h>
#include <pcbnew_id.h>
#include <class_track.h>
#include <macros.h>
#include <html_messagebox.h>
#include <dialog_design_rules.h>
#include <wx/generic/gridctrl.h>
#include <dialog_design_rules_aux_helper_class.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, NETCLASSPTR nc)
 
static void gridRow2class (wxGrid *grid, int row, 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 55 of file dialog_design_rules.cpp.

Function Documentation

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

Definition at line 475 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().

476 {
477  wxString msg;
478 
479  // label is netclass name
480  grid->SetRowLabelValue( row, nc->GetName() );
481 
482  msg = StringFromValue( g_UserUnit, nc->GetClearance() );
483  grid->SetCellValue( row, GRID_CLEARANCE, msg );
484 
485  msg = StringFromValue( g_UserUnit, nc->GetTrackWidth() );
486  grid->SetCellValue( row, GRID_TRACKSIZE, msg );
487 
488  msg = StringFromValue( g_UserUnit, nc->GetViaDiameter() );
489  grid->SetCellValue( row, GRID_VIASIZE, msg );
490 
491  msg = StringFromValue( g_UserUnit, nc->GetViaDrill() );
492  grid->SetCellValue( row, GRID_VIADRILL, msg );
493 
494  msg = StringFromValue( g_UserUnit, nc->GetuViaDiameter() );
495  grid->SetCellValue( row, GRID_uVIASIZE, msg );
496 
497  msg = StringFromValue( g_UserUnit, nc->GetuViaDrill() );
498  grid->SetCellValue( row, GRID_uVIADRILL, msg );
499 
500  msg = StringFromValue( g_UserUnit, nc->GetDiffPairGap() );
501  grid->SetCellValue( row, GRID_DIFF_PAIR_GAP, msg );
502 
503  msg = StringFromValue( g_UserUnit, nc->GetDiffPairWidth() );
504  grid->SetCellValue( row, GRID_DIFF_PAIR_WIDTH, msg );
505 
506 }
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:203
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:56
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 120 of file dialog_design_rules.cpp.

Referenced by DIALOG_DESIGN_RULES::DIALOG_DESIGN_RULES().

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

Definition at line 140 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().

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

Definition at line 534 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().

535 {
536 #define MYCELL( col ) \
537  ValueFromString( g_UserUnit, grid->GetCellValue( row, col ) )
538 
539  nc->SetClearance( MYCELL( GRID_CLEARANCE ) );
540  nc->SetTrackWidth( MYCELL( GRID_TRACKSIZE ) );
541  nc->SetViaDiameter( MYCELL( GRID_VIASIZE ) );
542  nc->SetViaDrill( MYCELL( GRID_VIADRILL ) );
543  nc->SetuViaDiameter( MYCELL( GRID_uVIASIZE ) );
544  nc->SetuViaDrill( MYCELL( GRID_uVIADRILL ) );
545  nc->SetDiffPairGap( MYCELL( GRID_DIFF_PAIR_GAP ) );
546  nc->SetDiffPairWidth( MYCELL( GRID_DIFF_PAIR_WIDTH ) );
547 
548 }
#define MYCELL(col)
int sort_int ( int *  first,
int *  second 
)

Definition at line 759 of file dialog_design_rules.cpp.

Referenced by DIALOG_DESIGN_RULES::OnRemoveNetclassClick().

760 {
761  return *second - *first;
762 }
static bool sortByClassThenName ( NETCUP a,
NETCUP b 
)
static

Definition at line 357 of file dialog_design_rules.cpp.

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

Referenced by DIALOG_DESIGN_RULES::makePointers().

358 {
359  // return a < b
360  if( a->clazz < b->clazz )
361  return true;
362 
363  // inside the same class, sort by net name:
364  if( a->clazz == b->clazz )
365  {
366  if( a->net < b->net )
367  return true;
368  }
369 
370  return false;
371 }
wxString clazz
a class name
wxString net
a net name