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 476 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().

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

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

Definition at line 760 of file dialog_design_rules.cpp.

Referenced by DIALOG_DESIGN_RULES::OnRemoveNetclassClick().

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

Definition at line 358 of file dialog_design_rules.cpp.

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

Referenced by DIALOG_DESIGN_RULES::makePointers().

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