Comment translations.

* Completed translation of all kicad source.
* Translated source files A through C in pcbnew.
This commit is contained in:
stambaughw 2009-11-12 15:43:38 +00:00
parent cb24fb2588
commit 4611bfd58c
40 changed files with 1725 additions and 1831 deletions

View File

@ -126,7 +126,7 @@ void WinEDA_MainFrame::OnArchiveFiles( wxCommandEvent& event )
wxFileName zip = dlg.GetPath();
/* Liste des extensions des fichiers à sauver */
/* List of file extensions to save. */
static const wxChar* extList[] = {
wxT( "*.sch" ), wxT( "*.lib" ), wxT( "*.cmp" ), wxT( "*.brd" ),
wxT( "*.net" ), wxT( "*.pro" ), wxT( "*.pho" ), wxT( "*.py" ),

View File

@ -28,7 +28,7 @@ class WinEDA_PrjFrame;
/**
* Command IDs for Kicad.
*
* Please add IDs that are unique to Kica here and not in the global id.h
* Please add IDs that are unique to Kicad here and not in the global id.h
* file. This will prevent the entire project from being rebuilt when adding
* new commands to Kicad.
*/
@ -64,10 +64,6 @@ enum id_kicad_frm
};
/*******************************************/
/* classe pour la Fenetre generale de kicad*/
/*******************************************/
/* class WinEDA_MainFrame
* This is the main kicad frame
*/
@ -80,7 +76,7 @@ public:
WinEDA_PrjFrame* m_LeftWin;
wxSashLayoutWindow* m_BottomWin;
wxTextCtrl* m_DialogWin;
WinEDA_Toolbar* m_VToolBar; // Verticam Toolbar (not used)
WinEDA_Toolbar* m_VToolBar; // Vertical toolbar (not used)
wxString m_BoardFileName;
wxString m_SchematicRootFileName;
wxFileName m_ProjectFileName;
@ -90,7 +86,6 @@ public:
public:
// Constructor and destructor
WinEDA_MainFrame( wxWindow* parent, const wxString& title,
const wxPoint& pos, const wxSize& size );
@ -207,9 +202,9 @@ private:
};
/***********************************************************/
/* Classes pour l'arbre de hierarchie de gestion du projet */
/***********************************************************/
/*********************************/
/* Classes for the project tree. */
/*********************************/
/** class TreePrjItemData
* Handle one item (a file or a directory name) for the tree file
@ -414,7 +409,7 @@ public:
WinEDA_TreePrj( WinEDA_PrjFrame* parent );
~WinEDA_TreePrj();
private:
/* overlayed sort function */
/* overridden sort function */
int OnCompareItems( const wxTreeItemId& item1, const wxTreeItemId& item2 );
};

View File

@ -1,6 +1,6 @@
/******************************************************************/
/* mdiframe.cpp - fonctions de la classe du type WinEDA_MainFrame */
/******************************************************************/
/*******************/
/* preferences.cpp */
/*******************/
#ifdef __GNUG__
#pragma implementation

View File

@ -17,7 +17,7 @@
static const wxString GeneralGroupName( wxT( "/general" ) );
/* Kicad project file entry namse. */
/* Kicad project file entry names. */
static const wxString SchematicRootNameEntry( wxT( "RootSch" ) );
static const wxString BoardFileNameEntry( wxT( "BoardNm" ) );
@ -130,7 +130,6 @@ void WinEDA_MainFrame::OnSaveProject( wxCommandEvent& event )
m_ProjectFileName = dlg.GetPath();
/* ecriture de la configuration */
wxGetApp().WriteProjectConfig( m_ProjectFileName.GetFullPath(),
GeneralGroupName, NULL );
}

View File

@ -1,10 +1,9 @@
/**********************************************************/
/* prjconfig.h : configuration: definition des structures */
/**********************************************************/
/**********************************************************/
/* prjconfig.h : configuration: definition des structures */
/**********************************************************/
#include "param_config.h"
/* Liste des parametres */
extern PARAM_CFG_BASE* CfgParamList[];

View File

@ -22,12 +22,9 @@
#include "wx/dir.h"
/********************************************/
/* Methodes pour l'arbre gestion du projet */
/********************************************/
IMPLEMENT_ABSTRACT_CLASS( WinEDA_TreePrj, wxTreeCtrl )
WinEDA_TreePrj::WinEDA_TreePrj( WinEDA_PrjFrame* parent ) :
wxTreeCtrl( parent, ID_PROJECT_TREE,
wxDefaultPosition, wxDefaultSize,
@ -61,16 +58,13 @@ WinEDA_TreePrj::~WinEDA_TreePrj()
}
/***************************************************************************************/
int WinEDA_TreePrj::OnCompareItems( const wxTreeItemId& item1, const wxTreeItemId& item2 )
/***************************************************************************************/
/* sort function for tree items.
* items are sorted :
* directory names first by alphabetic order
* root file names after
* file names last by alphabetic order
*/
int WinEDA_TreePrj::OnCompareItems( const wxTreeItemId& item1, const wxTreeItemId& item2 )
{
TreePrjItemData* myitem1 = (TreePrjItemData*) GetItemData( item1 );
TreePrjItemData* myitem2 = (TreePrjItemData*) GetItemData( item2 );
@ -89,11 +83,9 @@ int WinEDA_TreePrj::OnCompareItems( const wxTreeItemId& item1, const wxTreeItemI
}
/****************************************************************************************************/
TreePrjItemData::TreePrjItemData( enum TreeFileType type, const wxString& data,
wxTreeCtrl* parent ) :
wxTreeItemData()
/****************************************************************************************************/
{
m_Type = type;
m_Parent = parent;
@ -105,26 +97,23 @@ TreePrjItemData::TreePrjItemData( enum TreeFileType type, const wxString& data,
#ifdef KICAD_PYTHON
using namespace boost::python;
/**************************************/
object TreePrjItemData::GetIdPy() const
/**************************************/
// Convert the data to an id
object TreePrjItemData::GetIdPy() const
{
wxTreeItemId* id = new wxTreeItemId();
*id = GetId();
return object( handle<>( borrowed( wxPyConstructObject( id, wxT( "wxTreeItemId" ), true ) ) ) );
return object( handle<>( borrowed( wxPyConstructObject( id,
wxT( "wxTreeItemId" ),
true ) ) ) );
}
#endif
/*******************************************/
void TreePrjItemData::SetState( int state )
/*******************************************/
// Set the state used in the icon list
void TreePrjItemData::SetState( int state )
{
wxImageList* imglist = m_Parent->GetImageList();
@ -137,10 +126,8 @@ void TreePrjItemData::SetState( int state )
}
/*******************************************/
wxString TreePrjItemData::GetDir() const
/*******************************************/
/* Get the directory containing the file */
wxString TreePrjItemData::GetDir() const
{
if( TREE_DIRECTORY == m_Type )
return m_FileName;
@ -161,28 +148,25 @@ wxString TreePrjItemData::GetDir() const
}
/****************************************************************/
void TreePrjItemData::OnRename( wxTreeEvent& event, bool check )
/****************************************************************/
/* Called upon tree item rename */
void TreePrjItemData::OnRename( wxTreeEvent& event, bool check )
{
//this segfaults on linux (in wxEvtHandler::ProcessEvent), wx version 2.8.7
//therefore, until it is fixed, we must cancel the rename.
event.Veto();
return;
if( !Rename( event.GetLabel(), check ) )
event.Veto();
}
/****************************************************/
void TreePrjItemData::Move( TreePrjItemData* dest )
/****************************************************/
// Move the object to dest
void TreePrjItemData::Move( TreePrjItemData* dest )
{
//function not safe.
return;
const wxString sep = wxFileName().GetPathSeparator();
if( m_Type == TREE_DIRECTORY )
@ -213,7 +197,8 @@ void TreePrjItemData::Move( TreePrjItemData* dest )
return; // Same place ??
// Move the file on the disk:
#if ( ( wxMAJOR_VERSION < 2) || ( ( wxMAJOR_VERSION == 2)&& (wxMINOR_VERSION < 7 ) ) )
#if ( ( wxMAJOR_VERSION < 2 ) || ( ( wxMAJOR_VERSION == 2 ) \
&& ( wxMINOR_VERSION < 7 ) ) )
if( !wxRenameFile( GetFileName(), destName ) )
#else
if( !wxRenameFile( GetFileName(), destName, false ) )
@ -255,10 +240,8 @@ void TreePrjItemData::Move( TreePrjItemData* dest )
}
/****************************************************************/
bool TreePrjItemData::Rename( const wxString& name, bool check )
/****************************************************************/
/* rename the file checking if extension change occurs */
bool TreePrjItemData::Rename( const wxString& name, bool check )
{
//this is broken & unsafe to use on linux.
if( m_Type == TREE_DIRECTORY )
@ -286,7 +269,8 @@ bool TreePrjItemData::Rename( const wxString& name, bool check )
if( check && !ext.IsEmpty() && !reg.Matches( newFile ) )
{
wxMessageDialog dialog( m_Parent,
_( "Changing file extension will change file type.\n Do you want to continue ?" ),
_( "Changing file extension will change file \
type.\n Do you want to continue ?" ),
_( "Rename File" ),
wxYES_NO | wxICON_QUESTION );
@ -294,7 +278,8 @@ bool TreePrjItemData::Rename( const wxString& name, bool check )
return false;
}
#if ( ( wxMAJOR_VERSION < 2) || ( ( wxMAJOR_VERSION == 2) && (wxMINOR_VERSION < 7 ) ) )
#if ( ( wxMAJOR_VERSION < 2 ) || ( ( wxMAJOR_VERSION == 2 ) \
&& ( wxMINOR_VERSION < 7 ) ) )
if( !wxRenameFile( m_FileName, newFile ) )
#else
if( !wxRenameFile( m_FileName, newFile, false ) )
@ -320,7 +305,8 @@ bool TreePrjItemData::Delete( bool check )
/*******************************************/
/* delete a file */
{
wxMessageDialog dialog( m_Parent, _ ("Do you really want to delete ") + GetFileName(),
wxMessageDialog dialog( m_Parent,
_ ("Do you really want to delete ") + GetFileName(),
_( "Delete File" ), wxYES_NO | wxICON_QUESTION );
if( !check || wxID_YES == dialog.ShowModal() )
@ -352,10 +338,8 @@ bool TreePrjItemData::Delete( bool check )
}
/**********************************/
void TreePrjItemData::Activate( WinEDA_PrjFrame* prjframe )
/**********************************/
/* Called under item activation */
void TreePrjItemData::Activate( WinEDA_PrjFrame* prjframe )
{
wxString sep = wxFileName().GetPathSeparator();
wxString FullFileName = GetFileName();
@ -390,12 +374,12 @@ void TreePrjItemData::Activate( WinEDA_PrjFrame* prjframe )
if( count == 0 )
{
/* The AddFile() text below should match the filter added to handle
it in treeprj_frame.cpp in the line looking like this:
m_Filters.push_back( wxT( "^no kicad files found" ) );
/* The AddFile() text below should match the filter added to
* handle it in treeprj_frame.cpp in the line looking like this:
* m_Filters.push_back( wxT( "^no kicad files found" ) );
*/
prjframe->AddFile(
_( "no kicad files found in this directory" ), id );
prjframe->AddFile( _( "no kicad files found in this directory" ),
id );
}
/* Sort filenames by alphabetic order */
@ -450,9 +434,7 @@ void TreePrjItemData::Activate( WinEDA_PrjFrame* prjframe )
}
/***************************************************/
TreePrjItemData* WinEDA_PrjFrame::GetSelectedData()
/***************************************************/
{
return dynamic_cast<TreePrjItemData*>( m_TreeProject->GetItemData( m_TreeProject->GetSelection() ) );
}

View File

@ -1,55 +1,53 @@
/*************************************/
/* ar-proto.h: Fichier entete pour l'autorouteur */
/*************************************/
/**************/
/* AUTOROUT.H */
/* ar-proto.h */
/**************/
MODULE ** GenListeModules( BOARD * Pcb, int * NbModules );
/***************/
/****************/
/* GRAPHPCB.CPP */
/***************/
/* Rem: op_logique done le type d'ecriture ( WRITE, OR , XOR , AND ) */
/****************/
void Place_1_Pad_Board(BOARD * Pcb, D_PAD * pt_pad, int type, int marge, int op_logique);
/* Initialise a la valeur type, les cellules du Board comprises dans la
surface du pad pointe par pt_pad, avec la marge reservee pour l'isolement */
void TraceSegmentPcb(BOARD * Pcb, TRACK * pt_segm, int type, int marge, int op_logique);
/* trace un Segment de piste sur le BOARD */
/* Initialize a value type, the cells included in the board surface of the
* pad edge by pt_pad, with the margin reserved for isolation. */
void Place_1_Pad_Board( BOARD * Pcb, D_PAD * pt_pad, int type, int marge,
int op_logique );
void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int type, int op_logique );
/* Draws a segment of track on the board. */
void TraceSegmentPcb( BOARD * Pcb, TRACK * pt_segm, int type, int marge,
int op_logique );
void TraceFilledRectangle(BOARD * Pcb, int ux0, int uy0, int ux1, int uy1 ,int side,
int color, int op_logique);
/* Met a la valeur color l'ensemble des cellules du board inscrites dans
le rectangle de coord ux0,uy0 ( angle haut a droite )
a ux1,uy1 ( angle bas a gauche ) (coord PCB)
Le rectangle est horizontal ( ou vertical )
masque_layer = masque des couches;
op_logique = WRITE_CELL, WRITE_OR_CELL, WRITE_XOR_CELL, WRITE_AND_CELL
void TraceLignePcb( int x0, int y0, int x1, int y1, int layer, int type,
int op_logique );
/* Uses the color value of all cells included in the board
* coord of the rectangle ux0, uy0 (top right corner)
* a ux1, uy1 (lower left corner) (coord PCB)
* the rectangle is horizontal (or vertical)
* masque_layer = mask layers;
* op_logique = WRITE_CELL, WRITE_OR_CELL, WRITE_XOR_CELL, WRITE_AND_CELL
*/
/* fonction surchargee: */
void TraceFilledRectangle(BOARD * Pcb, int ux0, int uy0, int ux1, int uy1, int angle,
int masque_layer, int color, int op_logique);
/* Identique a precedemment, mais le rectangle est
incline de l'angle angle */
void TraceFilledRectangle( BOARD * Pcb, int ux0, int uy0, int ux1, int uy1,
int side, int color, int op_logique);
void TraceArc(int ux0,int uy0,int ux1,int uy1, int ArcAngle, int lg,int layer,
int color, int op_logique);
/* Remplit toutes les cellules du BOARD contenues dans l'arc de "longueur" angle
de demi-largeur lg, centre ux,y0 commencant en ux,y1 a la valeur color .
coord en unites PCB (0.1 mil) relatives a l'origine pt_pcb->Pcb_oX,Y du board.
*/
/* Same as above, but the rectangle is inclined angle angle. */
void TraceFilledRectangle( BOARD * Pcb, int ux0, int uy0, int ux1, int uy1,
int angle, int masque_layer, int color,
int op_logique );
/* Fills all BOARD cells contained in the arc of "L" angle half-width lg
* ux center, starting in ux y0, y1 is set to color. Coordinates are in
* PCB units (0.1 mil) relating to the origin pt_pcb-> Pcb_oX, Y's board.
*/
void TraceArc( int ux0,int uy0, int ux1, int uy1, int ArcAngle, int lg,
int layer, int color, int op_logique);
/* SOLVE.CPP */
/* QUEUE.CPP */
void FreeQueue(); /* Libere la memoire de la queue de recherche */
void FreeQueue();
void InitQueue();
void GetQueue( int *, int *, int *, int *, int * );
int SetQueue( int, int, int, int, int, int, int );
@ -68,9 +66,9 @@ int GetApxDist( int, int, int, int );
int CalcDist( int, int, int ,int );
/* BOARD.CPP */
bool ComputeMatriceSize(WinEDA_BasePcbFrame * frame, int pas_route);
int Build_Work(BOARD * Pcb);
void PlaceCells(BOARD * Pcb, int net_code, int flag = 0);
bool ComputeMatriceSize( WinEDA_BasePcbFrame * frame, int pas_route );
int Build_Work( BOARD * Pcb );
void PlaceCells( BOARD * Pcb, int net_code, int flag = 0 );
BoardCell GetCell( int, int, int );
void SetCell( int, int, int, BoardCell );
@ -82,4 +80,3 @@ DistCell GetDist( int, int, int );
void SetDist( int, int, int, DistCell );
int GetDir( int, int, int );
void SetDir( int, int, int, int );

View File

@ -1,5 +1,5 @@
/******************************************/
/* Track editing: attribute flags edition */
/* Track editing: attribute flags editing */
/******************************************/
#include "fctsys.h"
@ -12,15 +12,12 @@
#include "protos.h"
/*****************************************************************************/
void WinEDA_PcbFrame::Attribut_Segment( TRACK* track, wxDC* DC, bool Flag_On )
/*****************************************************************************/
/* Attribute change for 1 track segment.
* Attributes are
* SEGM_FIXE protection against global delete
* SEGM_AR AutoRouted segment
*/
void WinEDA_PcbFrame::Attribut_Segment( TRACK* track, wxDC* DC, bool Flag_On )
{
if( track == NULL )
return;
@ -34,10 +31,8 @@ void WinEDA_PcbFrame::Attribut_Segment( TRACK* track, wxDC* DC, bool Flag_On )
}
/***************************************************************************/
void WinEDA_PcbFrame::Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On )
/***************************************************************************/
/* Attribute change for an entire track */
void WinEDA_PcbFrame::Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On )
{
TRACK* Track;
int nb_segm;
@ -62,14 +57,11 @@ void WinEDA_PcbFrame::Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On )
}
/***********************************************************************/
void WinEDA_PcbFrame::Attribut_net( wxDC* DC, int net_code, bool Flag_On )
/***********************************************************************/
/* Modify the flag SEGM_FIXE according to Flag_On value,
* for all the segments related to net_code.
* if net_code < 0 all the segments are modified.
*/
void WinEDA_PcbFrame::Attribut_net( wxDC* DC, int net_code, bool Flag_On )
{
TRACK* Track = GetBoard()->m_Track;

View File

@ -1,10 +1,7 @@
/****************************************************************/
/* Routines de deplacement automatique et rotation des MODULES */
/* routines et menu d'autoplacement */
/* Routines for automatic displacement and rotation of modules. */
/****************************************************************/
/* Fichier automove.cpp */
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
@ -19,8 +16,6 @@
#include "protos.h"
/* variables locales */
typedef enum {
FIXE_MODULE,
FREE_MODULE,
@ -29,19 +24,15 @@ typedef enum {
} SelectFixeFct;
/* Fonctions locales */
static int tri_modules( MODULE** pt_ref, MODULE** pt_compare );
/* Variables locales */
wxString ModulesMaskSelection = wxT( "*" );
/******************************************************/
void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event )
/******************************************************/
/* Called on events (popup menus) relative to automove and autoplace footprints
*/
void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event )
{
int id = event.GetId();
wxPoint pos;
@ -79,7 +70,7 @@ void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event )
break;
}
/* Erase rastnest if needed */
/* Erase ratsnest if needed */
if( g_Show_Ratsnest )
DrawGeneralRatsnest( &dc );
GetBoard()->m_Status_Pcb |= DO_NOT_SHOW_GENERAL_RASTNEST;
@ -150,7 +141,7 @@ void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event )
break;
case ID_POPUP_PCB_REORIENT_ALL_MODULES:
OnOrientFootprints( );
OnOrientFootprints();
break;
case ID_POPUP_PCB_AUTOROUTE_ALL_MODULES:
@ -187,33 +178,31 @@ void WinEDA_PcbFrame::AutoPlace( wxCommandEvent& event )
}
/*****************************************************************************/
void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
/*****************************************************************************/
/* Routine de repartition des composants dans un rectangle de format 4 / 3,
* partant du curseur souris
* Les composants ayant le status FIXE ne sont normalement pas bouges
* Selon les flags:
* Tous les modules (non fixes) seront repartis
* Seuls les modules Hors PCB seront repartis
/* Routine allocation of components in a rectangular format 4 / 3,
* Starting from the mouse cursor
* The components with the FIXED status are not normally dives
* According to the flags:
* All modules (not fixed) will be left
* Only PCB modules are not left
*/
void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
{
MODULE** pt_Dmod, ** BaseListeModules;
MODULE* Module;
wxPoint start, current;
int Ymax_size, Xsize_allowed;
int pas_grille = (int)GetScreen()->GetGridSize().x;
int pas_grille = (int) GetScreen()->GetGridSize().x;
bool EdgeExists;
float surface;
if( GetBoard()->m_Modules == NULL )
{
DisplayError( this, _( "No Modules!" ), 10 ); return;
DisplayError( this, _( "No modules found!" ) );
return;
}
/* Confirmation */
if( !IsOK( this, _( "Move Modules ?" ) ) )
if( !IsOK( this, _( "Move modules?" ) ) )
return;
EdgeExists = SetBoardBoundaryBoxFromEdgesOnly();
@ -221,13 +210,13 @@ void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
if( PlaceModulesHorsPcb && !EdgeExists )
{
DisplayError( this,
_( "Autoplace modules: No board edges detected. Unable to place modules" ),
20 );
_( "Could not automatically place modules. No board \
edges detected." ) );
return;
}
Module = GetBoard()->m_Modules;
for( ; Module != NULL; Module = Module->Next() ) // remise a jour du rect d'encadrement
for( ; Module != NULL; Module = Module->Next() )
{
Module->Set_Rectangle_Encadrement();
Module->SetRectangleExinscrit();
@ -235,16 +224,18 @@ void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
BaseListeModules = GenListeModules( GetBoard(), NULL );
/* Si repartition de modules Hors PCB, le curseur est mis au dessous
* du PCB, pour eviter de placer des composants dans la zone PCB
/* If allocation of modules not PCBs, the cursor is placed below
* PCB, to avoid placing components in PCB area.
*/
if( PlaceModulesHorsPcb && EdgeExists )
{
if( GetScreen()->m_Curseur.y < (GetBoard()->m_BoundaryBox.GetBottom() + 2000) )
GetScreen()->m_Curseur.y = GetBoard()->m_BoundaryBox.GetBottom() + 2000;
if( GetScreen()->m_Curseur.y <
(GetBoard()->m_BoundaryBox.GetBottom() + 2000) )
GetScreen()->m_Curseur.y = GetBoard()->m_BoundaryBox.GetBottom() +
2000;
}
/* calcul de la surface occupee par les circuits */
/* calculating the area occupied by the circuits */
surface = 0.0;
for( pt_Dmod = BaseListeModules; *pt_Dmod != NULL; pt_Dmod++ )
{
@ -257,7 +248,7 @@ void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
surface += Module->m_Surface;
}
Xsize_allowed = (int) (sqrt( surface ) * 4.0 / 3.0);
Xsize_allowed = (int) ( sqrt( surface ) * 4.0 / 3.0 );
start = current = GetScreen()->m_Curseur;
Ymax_size = 0;
@ -299,15 +290,12 @@ void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
}
/***********************************************************/
void WinEDA_PcbFrame::FixeModule( MODULE* Module, bool Fixe )
/***********************************************************/
/* Met a jour (FALSE ou TRUE) l'attribut FIXE sur le module Module,
* ou sur tous les modules si Modulle == NULL
/* Update (TRUE or FALSE) FIXED attribute on the module Module
* or all the modules if Module == NULL
*/
void WinEDA_PcbFrame::FixeModule( MODULE* Module, bool Fixe )
{
if( Module ) /* Traitement du module */
if( Module )
{
Module->SetLocked( Fixe );
@ -319,7 +307,8 @@ void WinEDA_PcbFrame::FixeModule( MODULE* Module, bool Fixe )
Module = GetBoard()->m_Modules;
for( ; Module != NULL; Module = Module->Next() )
{
if( WildCompareString( ModulesMaskSelection, Module->m_Reference->m_Text ) )
if( WildCompareString( ModulesMaskSelection,
Module->m_Reference->m_Text ) )
{
Module->SetLocked( Fixe );
GetScreen()->SetModify();
@ -329,29 +318,25 @@ void WinEDA_PcbFrame::FixeModule( MODULE* Module, bool Fixe )
}
/*********************************************************/
MODULE** GenListeModules( BOARD* Pcb, int* NbModules )
/*********************************************************/
/* Cree par allocation memoire la liste ordonnee des structures D_MODULES
* decrivant les modules a deplacer
* la fin de la liste est signalee par NULL
* Retourne egalement le nombre de modules par *NbModules
* Penser a desallouer la memoire apres usage
/* Create memory allocation by the ordered list of structures D_MODULES
* Describing the module to move
* The end of the list is indicated by NULL
* Also returns the number of modules per NbModules *
* Deallocates memory after use
*/
MODULE** GenListeModules( BOARD* Pcb, int* NbModules )
{
MODULE* Module;
MODULE** ListeMod, ** PtList;
int NbMod;
/* Reservation de la memoire pour description des modules que l'on
* peut deplacer */
/* Reserve memory for descriptions of modules that are to be moved. */
Module = Pcb->m_Modules;
NbMod = 0;
for( ; Module != NULL; Module = Module->Next() )
NbMod++;
ListeMod = (MODULE**) MyZMalloc( (NbMod + 1) * sizeof(MODULE *) );
ListeMod = (MODULE**) MyZMalloc( (NbMod + 1) * sizeof(MODULE*) );
if( ListeMod == NULL )
{
if( NbModules != NULL )
@ -367,9 +352,9 @@ MODULE** GenListeModules( BOARD* Pcb, int* NbModules )
Module->SetRectangleExinscrit();
}
/* Tri par surface decroissante des modules ( on place les plus gros en 1er) */
/* Sort by surface area module largest to smallest */
qsort( ListeMod, NbMod, sizeof(MODULE * *),
( int( * ) ( const void*, const void* ) )tri_modules );
( int ( * )( const void*, const void* ) )tri_modules );
if( NbModules != NULL )
*NbModules = NbMod;
@ -377,10 +362,6 @@ MODULE** GenListeModules( BOARD* Pcb, int* NbModules )
}
/**************************************************/
/* Routine de tri de modules, utilisee par qsort: */
/**************************************************/
static int tri_modules( MODULE** pt_ref, MODULE** pt_compare )
{
float ff;

View File

@ -1,8 +1,6 @@
/*************************************************/
/* Routines de placement automatique des MODULES */
/*************************************************/
/* Fichier autoplac.cpp */
/*******************************************/
/* Routines to automatically place MODULES */
/*******************************************/
#include "fctsys.h"
#include "gr_basic.h"
@ -19,19 +17,16 @@
#include "protos.h"
/************************************************************/
/* Menu et Routines de placement automatique des composants */
/************************************************************/
#define GAIN 16
#define PENALITE 500
/* Penalite pour orientation donnee par CntRot90 et CntRot180:
* gradue de 0 ( rotation interdite ) a 10 ( rotation a cout null )
* Le cout est ici donne en majoration
/* Penalty for guidance given by CntRot90 and CntRot180:
* graduated from 0 (rotation allowed) to 10 (rotation count null)
* the count is increased.
*/
static const float OrientPenality[11] = {
2.0f, /* CntRot = 0 en fait rotation interdite */
static const float OrientPenality[11] =
{
2.0f, /* CntRot = 0 rotation prohibited */
1.9f, /* CntRot = 1 */
1.8f, /* CntRot = 2 */
1.7f, /* CntRot = 3 */
@ -41,37 +36,40 @@ static const float OrientPenality[11] = {
1.3f, /* CntRot = 7 */
1.2f, /* CntRot = 8 */
1.1f, /* CntRot = 9 */
1.0f /* CntRot = 10 rotation autorisee, penalite nulle */
1.0f /* CntRot = 10 rotation authorized, no penalty */
};
/* Etat d'une cellule */
/* Cell states. */
#define OUT_OF_BOARD -2
#define OCCUPED_By_MODULE -1
/* variables locales */
static wxPoint CurrPosition; // position courante du module en cours de placement
static wxPoint CurrPosition; // Current position of the current module
// placement
static bool AutoPlaceShowAll = TRUE;
float MinCout;
/* Fonctions locales */
static int TstModuleOnBoard( BOARD* Pcb, MODULE* Module, bool TstOtherSide );
static int Tri_PlaceModules( MODULE** pt_ref, MODULE** pt_compare );
static void TracePenaliteRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1,
int marge, int Penalite, int masque_layer );
static void TracePenaliteRectangle( BOARD* Pcb,
int ux0,
int uy0,
int ux1,
int uy1,
int marge,
int Penalite,
int masque_layer );
static MODULE* PickModule( WinEDA_PcbFrame* pcbframe, wxDC* DC );
/********************************************************************************/
void WinEDA_PcbFrame::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
/********************************************************************************/
/* Routine de Placement Automatique des composants dans le contour du PCB
* Les composants ayant le status FIXE ne sont pas bouges
* Si le menu appelant est le placement de 1 module, il sera replace
/* Routine to automatically place components in the contour of the PCB
* The components with the FIXED status are not moved. If the menu is
* calling the placement of 1 module, it will be replaced.
*/
void WinEDA_PcbFrame::AutoPlaceModule( MODULE* Module,
int place_mode,
wxDC* DC )
{
int ii, activ;
MODULE* ThisModule = NULL;
@ -118,7 +116,7 @@ void WinEDA_PcbFrame::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC
lay_tmp_TOP = Route_Layer_TOP;
OldPasRoute = g_GridRoutingSize;
g_GridRoutingSize = (int)GetScreen()->GetGridSize().x;
g_GridRoutingSize = (int) GetScreen()->GetGridSize().x;
// Ensure g_GridRoutingSize has a reasonnable value:
if( g_GridRoutingSize < 10 )
@ -126,21 +124,19 @@ void WinEDA_PcbFrame::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC
/* Compute module parmeters used in auto place */
Module = GetBoard()->m_Modules;
for( ; Module != NULL; Module = Module->Next() ) // remise a jour du rect d'encadrement
for( ; Module != NULL; Module = Module->Next() )
{
Module->Set_Rectangle_Encadrement();
Module->SetRectangleExinscrit();
}
/* Generation du plan de placement */
if( GenPlaceBoard() == 0 )
return;
/* Mise a jour des parametres modules utiles au placement */
/* Updating the parameters useful for module placement. */
BaseListeModules = GenListeModules( GetBoard(), &NbTotalModules );
MyFree( BaseListeModules );
/* Placement des modules fixes sur le plan de placement */
Module = GetBoard()->m_Modules;
for( ; Module != NULL; Module = Module->Next() )
{
@ -190,8 +186,9 @@ void WinEDA_PcbFrame::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC
}
}
/* Placement des modules */
activ = 0; Pas = 100.0;
activ = 0;
Pas = 100.0;
if( NbModules )
Pas = 100.0 / (float) NbModules;
while( ( Module = PickModule( this, DC ) ) != NULL )
@ -199,18 +196,18 @@ void WinEDA_PcbFrame::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC
float BestScore;
DisplayActivity( (int) (activ * Pas), wxEmptyString ); activ++;
/* Affichage du remplissage: surface de placement, obstacles, penalites */
/* Display fill area of interest, barriers, penalties. */
DrawInfoPlace( DC );
/* Recherche du placement: orientation 0 */
error = RecherchePlacementModule( Module, DC );
BestScore = MinCout;
PosOK = CurrPosition;
if( error == ESC )
goto end_of_tst;
/* Recherche du placement: orientation 180 */
/* Determine if the best orientation of a module is 180. */
ii = Module->m_CntRot180 & 0x0F;
if( ii != 0 )
{
int Angle_Rot_Module = 1800;
@ -218,7 +215,7 @@ void WinEDA_PcbFrame::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC
Module->SetRectangleExinscrit();
error = RecherchePlacementModule( Module, DC );
MinCout *= OrientPenality[ii];
if( BestScore > MinCout ) /* Cette orientation est meilleure */
if( BestScore > MinCout ) /* This orientation is best. */
{
PosOK = CurrPosition;
BestScore = MinCout;
@ -232,7 +229,7 @@ void WinEDA_PcbFrame::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC
goto end_of_tst;
}
/* Recherche du placement: orientation 90 */
/* Determine if the best orientation of a module is 90. */
ii = Module->m_CntRot90 & 0x0F;
if( ii != 0 )
{
@ -240,7 +237,7 @@ void WinEDA_PcbFrame::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC
Rotate_Module( DC, Module, Angle_Rot_Module, FALSE );
error = RecherchePlacementModule( Module, DC );
MinCout *= OrientPenality[ii];
if( BestScore > MinCout ) /* Cette orientation est meilleure */
if( BestScore > MinCout ) /* This orientation is best. */
{
PosOK = CurrPosition;
BestScore = MinCout;
@ -254,7 +251,7 @@ void WinEDA_PcbFrame::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC
goto end_of_tst;
}
/* Recherche du placement: orientation -90 (ou 270 degres) */
/* Determine if the best orientation of a module is 270. */
ii = (Module->m_CntRot90 >> 4 ) & 0x0F;
if( ii != 0 )
{
@ -262,7 +259,7 @@ void WinEDA_PcbFrame::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC
Rotate_Module( DC, Module, Angle_Rot_Module, FALSE );
error = RecherchePlacementModule( Module, DC );
MinCout *= OrientPenality[ii];
if( BestScore > MinCout ) /* Cette orientation est meilleure */
if( BestScore > MinCout ) /* This orientation is best. */
{
PosOK = CurrPosition;
BestScore = MinCout;
@ -281,7 +278,7 @@ end_of_tst:
if( error == ESC )
break;
/* placement du module */
/* Place module. */
CurrPosition = GetScreen()->m_Curseur;
GetScreen()->m_Curseur = PosOK;
Place_Module( Module, DC );
@ -297,7 +294,6 @@ end_of_tst:
CurrPosition = memopos;
/* Liberation de la memoire */
Board.UnInitBoard();
Route_Layer_TOP = lay_tmp_TOP;
@ -318,12 +314,7 @@ end_of_tst:
}
/**********************************************/
void WinEDA_PcbFrame::DrawInfoPlace( wxDC* DC )
/**********************************************/
/* Affiche a l'ecran les infos de placement
*/
{
int color, ii, jj;
int ox, oy;
@ -332,30 +323,30 @@ void WinEDA_PcbFrame::DrawInfoPlace( wxDC* DC )
GRSetDrawMode( DC, GR_COPY );
for( ii = 0; ii < Nrows; ii++ )
{
oy = GetBoard()->m_BoundaryBox.m_Pos.y + (ii * g_GridRoutingSize);
oy = GetBoard()->m_BoundaryBox.m_Pos.y + ( ii * g_GridRoutingSize );
for( jj = 0; jj < Ncols; jj++ )
{
ox = GetBoard()->m_BoundaryBox.m_Pos.x + (jj * g_GridRoutingSize);
/* surface de placement : */
ox = GetBoard()->m_BoundaryBox.m_Pos.x +
(jj * g_GridRoutingSize);
color = BLACK;
top_state = GetCell( ii, jj, TOP );
bottom_state = GetCell( ii, jj, BOTTOM );
if( (top_state & CELL_is_ZONE) )
if( top_state & CELL_is_ZONE )
color = BLUE;
/* obstacles */
if( (top_state & CELL_is_EDGE) || (bottom_state & CELL_is_EDGE) )
if( ( top_state & CELL_is_EDGE ) || ( bottom_state & CELL_is_EDGE ) )
color = WHITE;
else if( top_state & (HOLE | CELL_is_MODULE) )
else if( top_state & ( HOLE | CELL_is_MODULE ) )
color = LIGHTRED;
else if( bottom_state & (HOLE | CELL_is_MODULE) )
color = LIGHTGREEN;
else /* Affichage du remplissage: Penalites */
else /* Display the filling and keep out regions. */
{
if( GetDist( ii, jj, TOP ) || GetDist( ii, jj, BOTTOM ) )
color = DARKGRAY;
@ -367,28 +358,25 @@ void WinEDA_PcbFrame::DrawInfoPlace( wxDC* DC )
}
/***************************************/
int WinEDA_PcbFrame::GenPlaceBoard()
/***************************************/
/* Routine de generation du board ( cote composant + cote cuivre ) :
* Alloue la memoire necessaire pour representer en "bitmap" sur la grille
* courante:
* - la surface de placement des composant ( le board )
* - le bitmap des penalites
* et initialise les cellules du board a
* - HOLE pour les cellules occupees par un segment EDGE
* - CELL_is_ZONE pour les cellules internes au contour EDGE (s'il est ferme)
/* Generate board (component side copper + rating):
* Allocate the memory needed to represent in "bitmap" on the grid
* Current:
* - The size of clearance area of component (the board)
* - The bitmap PENALTIES
* And initialize the cells of the board has
* - Hole in the cells occupied by a segment EDGE
* - CELL_is_ZONE for cell internal contour EDGE (if closed)
*
* la surface de placement (board) donne les cellules internes au contour
* du pcb, et parmi celle-ci les cellules libres et les cellules deja occupees
* Placement surface (board) gives the cells internal to the contour
* PCB, and among the latter the free cells and cells already occupied
*
* le bitmap des penalites donnent les cellules occupes par les modules,
* augmentes d'une surface de penalite liee au nombre de pads du module
* The bitmap PENALTIES give cells occupied by the modules,
* Plus a surface penalty related to the number of pads of the module
*
* le bitmap des penalites est mis a 0
* l'occupation des cellules est laisse a 0
* Bitmap of the penalty is set to 0
* Occupation cell is a 0 leaves
*/
int WinEDA_PcbFrame::GenPlaceBoard()
{
int jj, ii;
int NbCells;
@ -399,13 +387,15 @@ int WinEDA_PcbFrame::GenPlaceBoard()
if( !SetBoardBoundaryBoxFromEdgesOnly() )
{
DisplayError( this, _( "No edge PCB, Unknown board size!" ), 30 );
DisplayError( this, _( "No PCB edge found, unknown board size!" ) );
return 0;
}
/* The boundary box must have its start point on placing grid: */
GetBoard()->m_BoundaryBox.m_Pos.x -= GetBoard()->m_BoundaryBox.m_Pos.x % g_GridRoutingSize;
GetBoard()->m_BoundaryBox.m_Pos.y -= GetBoard()->m_BoundaryBox.m_Pos.y % g_GridRoutingSize;
GetBoard()->m_BoundaryBox.m_Pos.x -= GetBoard()->m_BoundaryBox.m_Pos.x %
g_GridRoutingSize;
GetBoard()->m_BoundaryBox.m_Pos.y -= GetBoard()->m_BoundaryBox.m_Pos.y %
g_GridRoutingSize;
/* The boundary box must have its end point on placing grid: */
wxPoint end = GetBoard()->m_BoundaryBox.GetEnd();
end.x -= end.x % g_GridRoutingSize; end.x += g_GridRoutingSize;
@ -426,18 +416,18 @@ int WinEDA_PcbFrame::GenPlaceBoard()
msg.Printf( wxT( "%d" ), NbCells );
Affiche_1_Parametre( this, 14, _( "Cells." ), msg, YELLOW );
/* Choix du nombre de faces de placement */
/* Choose the number of board sides. */
Nb_Sides = TWO_SIDES;
Affiche_1_Parametre( this, 22, wxT( "S" ), ( Nb_Sides == TWO_SIDES ) ? wxT( "2" ) : wxT(
"1" ), WHITE );
Affiche_1_Parametre( this, 22, wxT( "S" ),
( Nb_Sides == TWO_SIDES ) ? wxT( "2" ) : wxT( "1" ),
WHITE );
/* Creation du mapping du board */
Board.InitBoard();
/* Affichage de la memoire utilisee */
/* Display memory usage. */
msg.Printf( wxT( "%d" ), Board.m_MemSize / 1024 );
Affiche_1_Parametre( this, 24, wxT( "Mem(Ko)" ), msg, CYAN );
Affiche_1_Parametre( this, 24, wxT( "Mem(Kb)" ), msg, CYAN );
Route_Layer_BOTTOM = CMP_N;
if( Nb_Sides == TWO_SIDES )
@ -467,7 +457,8 @@ int WinEDA_PcbFrame::GenPlaceBoard()
TmpSegm.m_Shape = DrawSegm->m_Shape;
TmpSegm.m_Param = DrawSegm->m_Angle;
TraceSegmentPcb( GetBoard(), &TmpSegm, HOLE | CELL_is_EDGE, g_GridRoutingSize, WRITE_CELL );
TraceSegmentPcb( GetBoard(), &TmpSegm, HOLE | CELL_is_EDGE,
g_GridRoutingSize, WRITE_CELL );
break;
case TYPE_TEXTE:
@ -476,11 +467,12 @@ int WinEDA_PcbFrame::GenPlaceBoard()
}
}
/* Init du point d'accrochage de la zone */
/* Init the point of attachment to the area. */
OrCell( Nrows / 2, Ncols / 2, BOTTOM, CELL_is_ZONE );
/* Remplissage des cellules de la couche BOTTOM */
ii = 1; jj = 1;
/* Fill bottom layer zones. */
ii = 1;
jj = 1;
while( ii )
{
@ -489,21 +481,18 @@ int WinEDA_PcbFrame::GenPlaceBoard()
ii = Propagation( this );
}
/* Init de la couche TOP */
/* Initialize top layer. */
if( Board.m_BoardSide[TOP] )
memcpy( Board.m_BoardSide[TOP], Board.m_BoardSide[BOTTOM], NbCells * sizeof(BoardCell) );
memcpy( Board.m_BoardSide[TOP], Board.m_BoardSide[BOTTOM],
NbCells * sizeof(BoardCell) );
return 1;
}
/******************************************************/
void WinEDA_PcbFrame::GenModuleOnBoard( MODULE* Module )
/******************************************************/
/* initialise sur le board de placement les cellules correspondantes au
* module Module
/* Place module on board.
*/
void WinEDA_PcbFrame::GenModuleOnBoard( MODULE* Module )
{
int ox, oy, fx, fy, Penalite;
int marge = g_GridRoutingSize / 2;
@ -547,15 +536,16 @@ void WinEDA_PcbFrame::GenModuleOnBoard( MODULE* Module )
int trackWidth = GetBoard()->m_NetClasses.GetDefault()->GetTrackWidth();
int clearance = GetBoard()->m_NetClasses.GetDefault()->GetClearance();
/* Trace des pads et leur surface de securite */
/* Trace pads and surface safely. */
marge = trackWidth + clearance;
for( Pad = Module->m_Pads; Pad != NULL; Pad = Pad->Next() )
{
Place_1_Pad_Board( GetBoard(), Pad, CELL_is_MODULE, marge, WRITE_OR_CELL );
Place_1_Pad_Board( GetBoard(), Pad, CELL_is_MODULE, marge,
WRITE_OR_CELL );
}
/* Trace de la penalite */
/* Trace clearance. */
marge = (g_GridRoutingSize * Module->m_PadNum ) / GAIN;
Penalite = PENALITE;
TracePenaliteRectangle( GetBoard(), ox, oy, fx, fy, marge, Penalite,
@ -563,21 +553,19 @@ void WinEDA_PcbFrame::GenModuleOnBoard( MODULE* Module )
}
/************************************************************************/
int WinEDA_PcbFrame::RecherchePlacementModule( MODULE* Module, wxDC* DC )
/************************************************************************/
/*
* Routine Principale de recherche de la position optimale du module
* Search for the optimal position of the module.
* Entree:
* Module pointe la struct MODULE du module a placer.
* Retourne:
* 1 si placement impossible, 0 si OK
* et MinCout = variable externe = cout du meilleur placement
* Module tip MODULE struct module's place.
* Returns:
* 1 if placement impossible, 0 if OK
* = MinCout and external variable = cost of best placement
*/
int WinEDA_PcbFrame::RecherchePlacementModule( MODULE* Module, wxDC* DC )
{
int cx, cy;
int ox, oy, fx, fy;/* cadre d'occupation du module centre sur le curseur */
int ox, oy, fx, fy; /* occupying part of the module focuses on the
* cursor */
int error = 1;
int DisplayChevelu = 0;
wxPoint LastPosOK;
@ -598,7 +586,7 @@ int WinEDA_PcbFrame::RecherchePlacementModule( MODULE* Module, wxDC* DC )
CurrPosition.x = GetBoard()->m_BoundaryBox.m_Pos.x - ox;
CurrPosition.y = GetBoard()->m_BoundaryBox.m_Pos.y - oy;
/* remise sur la grille de placement: */
/* Module placement on grid. */
CurrPosition.x -= CurrPosition.x % g_GridRoutingSize;
CurrPosition.y -= CurrPosition.y % g_GridRoutingSize;
@ -606,11 +594,10 @@ int WinEDA_PcbFrame::RecherchePlacementModule( MODULE* Module, wxDC* DC )
g_Offset_Module.y = cy - CurrPosition.y;
GetBoard()->m_Status_Pcb &= ~RATSNEST_ITEM_LOCAL_OK;
/* tst des pastilles traversantes, qui pour un circuit imprime ayant des
* composants des 2 cotes, peuvent tomber sur un composant de cote oppose:
* s'il y a au moins 1 pastille apparaissant sur l'autre cote, ce cote
* est teste */
/* Test pads, a printed circuit with components of the 2 dimensions
* can become a component on opposite side if there is at least 1 patch
* appearing on the other side.
*/
TstOtherSide = FALSE;
if( Nb_Sides == TWO_SIDES )
{
@ -621,7 +608,7 @@ int WinEDA_PcbFrame::RecherchePlacementModule( MODULE* Module, wxDC* DC )
for( Pad = Module->m_Pads; Pad != NULL; Pad = Pad->Next() )
{
if( (Pad->m_Masque_Layer & masque_otherlayer) == 0 )
if( ( Pad->m_Masque_Layer & masque_otherlayer ) == 0 )
continue;
TstOtherSide = TRUE;
break;
@ -640,7 +627,7 @@ int WinEDA_PcbFrame::RecherchePlacementModule( MODULE* Module, wxDC* DC )
wxYield();
if( DrawPanel->m_AbortRequest )
{
if( IsOK( this, _( "Ok to abort ?" ) ) )
if( IsOK( this, _( "Ok to abort?" ) ) )
return ESC;
else
DrawPanel->m_AbortRequest = FALSE;
@ -654,7 +641,7 @@ int WinEDA_PcbFrame::RecherchePlacementModule( MODULE* Module, wxDC* DC )
g_Offset_Module.x = cx - CurrPosition.x;
CurrPosition.y = GetBoard()->m_BoundaryBox.m_Pos.y - oy;
/* remise sur la grille de placement: */
/* Placement on grid. */
CurrPosition.y -= CurrPosition.y % g_GridRoutingSize;
DrawModuleOutlines( DrawPanel, DC, Module );
@ -662,7 +649,7 @@ int WinEDA_PcbFrame::RecherchePlacementModule( MODULE* Module, wxDC* DC )
for( ; CurrPosition.y < GetBoard()->m_BoundaryBox.GetBottom() - fy;
CurrPosition.y += g_GridRoutingSize )
{
/* effacement des traces */
/* Erase traces. */
DrawModuleOutlines( DrawPanel, DC, Module );
if( DisplayChevelu )
Compute_Ratsnest_PlaceModule( DC );
@ -673,7 +660,7 @@ int WinEDA_PcbFrame::RecherchePlacementModule( MODULE* Module, wxDC* DC )
g_Offset_Module.y = cy - CurrPosition.y;
DrawModuleOutlines( DrawPanel, DC, Module );
Penalite = TstModuleOnBoard( GetBoard(), Module, TstOtherSide );
if( Penalite >= 0 ) /* c a d si le module peut etre place */
if( Penalite >= 0 ) /* c a d if the module can be placed. */
{
error = 0;
build_ratsnest_module( DC, Module );
@ -688,7 +675,8 @@ int WinEDA_PcbFrame::RecherchePlacementModule( MODULE* Module, wxDC* DC )
wxString msg;
msg.Printf( wxT( "Score %d, pos %3.4f, %3.4f" ),
(int) mincout,
(float) LastPosOK.x / 10000, (float) LastPosOK.y / 10000 );
(float) LastPosOK.x / 10000,
(float) LastPosOK.y / 10000 );
Affiche_Message( msg );
}
}
@ -698,55 +686,55 @@ int WinEDA_PcbFrame::RecherchePlacementModule( MODULE* Module, wxDC* DC )
}
}
DrawModuleOutlines( DrawPanel, DC, Module ); /* effacement du dernier trace */
DrawModuleOutlines( DrawPanel, DC, Module ); /* erasing the last traces */
if( DisplayChevelu )
Compute_Ratsnest_PlaceModule( DC );
/* Regeneration des variables modifiees */
/* Regeneration of the modified variable. */
Module->m_RealBoundaryBox.m_Pos.x = ox + cx;
Module->m_RealBoundaryBox.m_Pos.y = oy + cy;
CurrPosition = LastPosOK;
GetBoard()->m_Status_Pcb &= ~(RATSNEST_ITEM_LOCAL_OK | LISTE_PAD_OK );
GetBoard()->m_Status_Pcb &= ~( RATSNEST_ITEM_LOCAL_OK | LISTE_PAD_OK );
MinCout = mincout;
return error;
}
/**************************************************************************/
int TstRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int side )
/**************************************************************************/
/* tst si la surface rectangulaire (ux,y0 .. ux,y1):
* - est sur une zone libre ( retourne OCCUPED_By_MODULE sinon)
* - est sur la surface utile du board ( retourne OUT_OF_BOARD sinon)
/* Test if the rectangular area (ux, ux .. y0, y1):
* - is a free zone (except OCCUPED_By_MODULE returns)
* - is on the working surface of the board (otherwise returns OUT_OF_BOARD)
*
* retourne 0 si OK
* Returns 0 if OK
*/
int TstRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int side )
{
int row, col;
int row_min, row_max, col_min, col_max;
unsigned int data;
ux0 -= Pcb->m_BoundaryBox.m_Pos.x; uy0 -= Pcb->m_BoundaryBox.m_Pos.y;
ux1 -= Pcb->m_BoundaryBox.m_Pos.x; uy1 -= Pcb->m_BoundaryBox.m_Pos.y;
ux0 -= Pcb->m_BoundaryBox.m_Pos.x;
uy0 -= Pcb->m_BoundaryBox.m_Pos.y;
ux1 -= Pcb->m_BoundaryBox.m_Pos.x;
uy1 -= Pcb->m_BoundaryBox.m_Pos.y;
/* Calcul des coord limites des cellules appartenant au rectangle */
row_max = uy1 / g_GridRoutingSize;
col_max = ux1 / g_GridRoutingSize;
row_min = uy0 / g_GridRoutingSize; if( uy0 > row_min * g_GridRoutingSize )
row_min = uy0 / g_GridRoutingSize;
if( uy0 > row_min * g_GridRoutingSize )
row_min++;
col_min = ux0 / g_GridRoutingSize; if( ux0 > col_min * g_GridRoutingSize )
col_min = ux0 / g_GridRoutingSize;
if( ux0 > col_min * g_GridRoutingSize )
col_min++;
if( row_min < 0 )
row_min = 0;
if( row_max >= (Nrows - 1) )
if( row_max >= ( Nrows - 1 ) )
row_max = Nrows - 1;
if( col_min < 0 )
col_min = 0;
if( col_max >= (Ncols - 1) )
if( col_max >= ( Ncols - 1 ) )
col_max = Ncols - 1;
for( row = row_min; row <= row_max; row++ )
@ -754,9 +742,9 @@ int TstRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int side )
for( col = col_min; col <= col_max; col++ )
{
data = GetCell( row, col, side );
if( (data & CELL_is_ZONE) == 0 ) /* Cellule non autorisee */
if( ( data & CELL_is_ZONE ) == 0 )
return OUT_OF_BOARD;
if( data & CELL_is_MODULE ) /* Deja utilisee */
if( data & CELL_is_MODULE )
return OCCUPED_By_MODULE;
}
}
@ -765,37 +753,38 @@ int TstRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int side )
}
/******************************************************************************/
/* Calculates and returns the clearance area of the rectangular surface
* (ux, ux .. y0, y1):
* (Sum of cells in terms of distance)
*/
unsigned int CalculePenaliteRectangle( BOARD* Pcb, int ux0, int uy0,
int ux1, int uy1, int side )
/******************************************************************************/
/* calcule et retourne la penalite de la surface rectangulaire (ux,y0 .. ux,y1):
* ( somme des valeurs des cellules du plan des Distances )
*/
{
int row, col;
int row_min, row_max, col_min, col_max;
unsigned int Penalite;
ux0 -= Pcb->m_BoundaryBox.m_Pos.x; uy0 -= Pcb->m_BoundaryBox.m_Pos.y;
ux1 -= Pcb->m_BoundaryBox.m_Pos.x; uy1 -= Pcb->m_BoundaryBox.m_Pos.y;
ux0 -= Pcb->m_BoundaryBox.m_Pos.x;
uy0 -= Pcb->m_BoundaryBox.m_Pos.y;
ux1 -= Pcb->m_BoundaryBox.m_Pos.x;
uy1 -= Pcb->m_BoundaryBox.m_Pos.y;
/* Calcul des coord limites des cellules appartenant au rectangle */
row_max = uy1 / g_GridRoutingSize;
col_max = ux1 / g_GridRoutingSize;
row_min = uy0 / g_GridRoutingSize; if( uy0 > row_min * g_GridRoutingSize )
row_min = uy0 / g_GridRoutingSize;
if( uy0 > row_min * g_GridRoutingSize )
row_min++;
col_min = ux0 / g_GridRoutingSize; if( ux0 > col_min * g_GridRoutingSize )
col_min = ux0 / g_GridRoutingSize;
if( ux0 > col_min * g_GridRoutingSize )
col_min++;
if( row_min < 0 )
row_min = 0;
if( row_max >= (Nrows - 1) )
if( row_max >= ( Nrows - 1 ) )
row_max = Nrows - 1;
if( col_min < 0 )
col_min = 0;
if( col_max >= (Ncols - 1) )
if( col_max >= ( Ncols - 1 ) )
col_max = Ncols - 1;
Penalite = 0;
@ -811,14 +800,11 @@ unsigned int CalculePenaliteRectangle( BOARD* Pcb, int ux0, int uy0,
}
/**********************************************************************/
int TstModuleOnBoard( BOARD* Pcb, MODULE* Module, bool TstOtherSide )
/**********************************************************************/
/* Teste si le module peut etre place sur le board.
* retourne de diagnostic de TstRectangle().
* le module est connu par son rectangle d'encadrement
/* Test if the module can be placed on the board.
* Returns the value TstRectangle().
* Module is known by its rectangle
*/
int TstModuleOnBoard( BOARD* Pcb, MODULE* Module, bool TstOtherSide )
{
int ox, oy, fx, fy;
int error, Penalite, marge, side, otherside;
@ -845,7 +831,7 @@ int TstModuleOnBoard( BOARD* Pcb, MODULE* Module, bool TstOtherSide )
return error;
}
marge = (g_GridRoutingSize * Module->m_PadNum ) / GAIN;
marge = ( g_GridRoutingSize * Module->m_PadNum ) / GAIN;
Penalite = CalculePenaliteRectangle( Pcb, ox - marge, oy - marge,
fx + marge, fy + marge, side );
@ -853,32 +839,32 @@ int TstModuleOnBoard( BOARD* Pcb, MODULE* Module, bool TstOtherSide )
}
/************************************************************/
float WinEDA_PcbFrame::Compute_Ratsnest_PlaceModule( wxDC* DC )
/************************************************************/
/* Routine affichant le chevelu du module en cours de deplacement, et
* evaluant le "cout" de la position.
* Le cout est la longueur des chevelus en distance de manhattan, avec
* penalite pour les inclinaisons se rapprochant de 45 degre
/*
* Display the module's ratsnet during displacement, and
* assess the "cost" of the position.
* The cost is the longest ratsnest distance with penalty for connections
* approaching 45 degrees.
*/
float WinEDA_PcbFrame::Compute_Ratsnest_PlaceModule( wxDC* DC )
{
double cout, icout;
int ox, oy;
int fx, fy;
int dx, dy;
if( (GetBoard()->m_Status_Pcb & RATSNEST_ITEM_LOCAL_OK) == 0 )
if( ( GetBoard()->m_Status_Pcb & RATSNEST_ITEM_LOCAL_OK ) == 0 )
return -1;
cout = 0;
for( unsigned ii = 0; ii < GetBoard()->m_LocalRatsnest.size(); ii++ )
{
RATSNEST_ITEM* pt_local_chevelu = &GetBoard()->m_LocalRatsnest[ii];
if( !(pt_local_chevelu->m_Status & LOCAL_RATSNEST_ITEM) )
if( !( pt_local_chevelu->m_Status & LOCAL_RATSNEST_ITEM ) )
{
ox = pt_local_chevelu->m_PadStart->GetPosition().x - g_Offset_Module.x;
oy = pt_local_chevelu->m_PadStart->GetPosition().y - g_Offset_Module.y;
ox = pt_local_chevelu->m_PadStart->GetPosition().x -
g_Offset_Module.x;
oy = pt_local_chevelu->m_PadStart->GetPosition().y -
g_Offset_Module.y;
fx = pt_local_chevelu->m_PadEnd->GetPosition().x;
fy = pt_local_chevelu->m_PadEnd->GetPosition().y;
@ -888,7 +874,7 @@ float WinEDA_PcbFrame::Compute_Ratsnest_PlaceModule( wxDC* DC )
0, g_DesignSettings.m_RatsnestColor | GR_XOR );
}
/* Evaluation du cout du chevelu: */
/* Cost of the ratsnest. */
dx = fx - ox;
dy = fy - oy;
@ -896,34 +882,41 @@ float WinEDA_PcbFrame::Compute_Ratsnest_PlaceModule( wxDC* DC )
dy = abs( dy );
if( dx < dy )
EXCHG( dx, dy );/* dx >= dy */
EXCHG( dx, dy ); /* dx >= dy */
/* cout de la distance: */
/* Cost of the longest connection. */
icout = (float) dx * dx;
/* cout de l'inclinaison */
/* Cost of inclination. */
icout += 3 * (float) dy * dy;
icout = sqrt( icout );
cout += icout; /* cout total = somme des couts de chaque chevelu */
cout += icout; /* Total cost = sum of costs of each connection. */
}
}
return (float)cout;
return (float) cout;
}
/*****************************************************************/
/* Construction de la zone de penalite ( rectangle ) d'un module */
/*****************************************************************/
/***********************************/
/* Draw keep out area of a module. */
/***********************************/
/* les cellules ( du plan des Distances ) du rectangle x0,y0 a x1,y1 sont
/* ???
* les cellules ( du plan des Distances ) du rectangle x0,y0 a x1,y1 sont
* incrementees de la valeur Penalite
* celles qui sont externes au rectangle, mais internes au rectangle
* x0,y0 -marge a x1,y1 + marge sont incrementees d'une valeur
* (Penalite ... 0) decroissante en fonction de leur eloignement
*/
static void TracePenaliteRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1,
int marge, int Penalite, int masque_layer )
static void TracePenaliteRectangle( BOARD* Pcb,
int ux0,
int uy0,
int ux1,
int uy1,
int marge,
int Penalite,
int masque_layer )
{
int row, col;
int row_min, row_max, col_min, col_max, pmarge;
@ -932,16 +925,18 @@ static void TracePenaliteRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int u
int lgain, cgain;
if( masque_layer & g_TabOneLayerMask[Route_Layer_BOTTOM] )
trace = 1; /* Trace sur BOTTOM */
trace = 1; /* Trace on bottom layer. */
if( (masque_layer & g_TabOneLayerMask[Route_Layer_TOP] ) && Nb_Sides )
trace |= 2; /* Trace sur TOP */
if( ( masque_layer & g_TabOneLayerMask[Route_Layer_TOP] ) && Nb_Sides )
trace |= 2; /* Trace on top layer. */
if( trace == 0 )
return;
ux0 -= Pcb->m_BoundaryBox.m_Pos.x; uy0 -= Pcb->m_BoundaryBox.m_Pos.y;
ux1 -= Pcb->m_BoundaryBox.m_Pos.x; uy1 -= Pcb->m_BoundaryBox.m_Pos.y;
ux0 -= Pcb->m_BoundaryBox.m_Pos.x;
uy0 -= Pcb->m_BoundaryBox.m_Pos.y;
ux1 -= Pcb->m_BoundaryBox.m_Pos.x;
uy1 -= Pcb->m_BoundaryBox.m_Pos.y;
ux0 -= marge; ux1 += marge;
uy0 -= marge; uy1 += marge;
@ -949,7 +944,7 @@ static void TracePenaliteRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int u
pmarge = marge / g_GridRoutingSize; if( pmarge < 1 )
pmarge = 1;
/* Calcul des coord limites des cellules appartenant au rectangle */
/* Calculate the coordinate limits of the rectangle. */
row_max = uy1 / g_GridRoutingSize;
col_max = ux1 / g_GridRoutingSize;
row_min = uy0 / g_GridRoutingSize; if( uy0 > row_min * g_GridRoutingSize )
@ -970,22 +965,22 @@ static void TracePenaliteRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int u
{
lgain = 256;
if( row < pmarge )
lgain = (256 * row) / pmarge;
lgain = ( 256 * row ) / pmarge;
else if( row > row_max - pmarge )
lgain = ( 256 * (row_max - row) ) / pmarge;
lgain = ( 256 * ( row_max - row ) ) / pmarge;
for( col = col_min; col <= col_max; col++ )
{
cgain = 256;
LocalPenalite = Penalite;
if( col < pmarge )
cgain = (256 * col) / pmarge;
cgain = ( 256 * col ) / pmarge;
else if( col > col_max - pmarge )
cgain = ( 256 * (col_max - col) ) / pmarge;
cgain = ( 256 * ( col_max - col ) ) / pmarge;
cgain = (cgain * lgain) / 256;
cgain = ( cgain * lgain ) / 256;
if( cgain != 256 )
LocalPenalite = (LocalPenalite * cgain) / 256;
LocalPenalite = ( LocalPenalite * cgain ) / 256;
if( trace & 1 )
{
data = GetDist( row, col, BOTTOM ) + LocalPenalite;
@ -1002,9 +997,9 @@ static void TracePenaliteRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int u
}
/***************************************************/
/* Routines de tri de modules, utilisee par qsort: */
/***************************************************/
/************************************/
/* Sort routines for use with qsort */
/************************************/
static int Tri_PlaceModules( MODULE** pt_ref, MODULE** pt_compare )
{
@ -1036,15 +1031,12 @@ static int Tri_RatsModules( MODULE** pt_ref, MODULE** pt_compare )
}
/***************************************************************/
static MODULE* PickModule( WinEDA_PcbFrame* pcbframe, wxDC* DC )
/***************************************************************/
/* Recherche le "meilleur" module a placer
* les criteres de choix sont:
* - maximum de chevelus avec les modules deja places
* - taille max, et nombre de pads max
/* Find the "best" module place
* The criteria of choice are:
* - Maximum ratsnet with modules already placed
* - Max size, and number of pads max
*/
static MODULE* PickModule( WinEDA_PcbFrame* pcbframe, wxDC* DC )
{
MODULE** BaseListeModules, ** pt_Dmod;
MODULE* Module = NULL, * AltModule = NULL;
@ -1054,9 +1046,9 @@ static MODULE* PickModule( WinEDA_PcbFrame* pcbframe, wxDC* DC )
if( BaseListeModules == NULL )
return NULL;
/* Tri par surface decroissante des modules
* (on place les plus gros en 1er), surface ponderee par le nombre de pads */
/* Sort surface area of modules from greatest to least. Surface area
* weighted by the number of pads
*/
qsort( BaseListeModules, NbModules, sizeof(MODULE * *),
( int (*)( const void*, const void* ) )Tri_PlaceModules );
@ -1069,10 +1061,13 @@ static MODULE* PickModule( WinEDA_PcbFrame* pcbframe, wxDC* DC )
(*pt_Dmod)->DisplayInfo( pcbframe );
pcbframe->build_ratsnest_module( DC, *pt_Dmod );
/* calcul du nombre de chevelus externes */
for( unsigned ii = 0; ii < pcbframe->GetBoard()->m_LocalRatsnest.size(); ii++ )
/* Calculate external ratsnet. */
for( unsigned ii = 0;
ii < pcbframe->GetBoard()->m_LocalRatsnest.size();
ii++ )
{
if( (pcbframe->GetBoard()->m_LocalRatsnest[ii].m_Status & LOCAL_RATSNEST_ITEM) == 0 )
if( ( pcbframe->GetBoard()->m_LocalRatsnest[ii].m_Status &
LOCAL_RATSNEST_ITEM ) == 0 )
(*pt_Dmod)->flag++;
}
}
@ -1083,7 +1078,7 @@ static MODULE* PickModule( WinEDA_PcbFrame* pcbframe, wxDC* DC )
( int (*)( const void*, const void* ) )Tri_RatsModules );
/* Recherche du "meilleur" module */
/* Search for "best" module. */
Module = NULL;
for( pt_Dmod = BaseListeModules; *pt_Dmod != NULL; pt_Dmod++ )
{
@ -1103,16 +1098,14 @@ static MODULE* PickModule( WinEDA_PcbFrame* pcbframe, wxDC* DC )
}
/*******************************************************/
bool WinEDA_PcbFrame::SetBoardBoundaryBoxFromEdgesOnly()
/*******************************************************/
/* Determine le rectangle d'encadrement du pcb, selon les contours
* (couche EDGE) uniquement
* Sortie:
* GetBoard()->m_BoundaryBox mis a jour
* Retourne FALSE si pas de contour
/*
* Determine the rectangle of the pcb, according to the contours
* layer (EDGE) only
* Output:
* GetBoard()->m_BoundaryBox updated
* Returns FALSE if no contour
*/
bool WinEDA_PcbFrame::SetBoardBoundaryBoxFromEdgesOnly()
{
int rayon, cx, cy, d;
int xmax, ymax;
@ -1123,10 +1116,10 @@ bool WinEDA_PcbFrame::SetBoardBoundaryBoxFromEdgesOnly()
if( GetBoard() == NULL )
return FALSE;
GetBoard()->m_BoundaryBox.m_Pos.x = GetBoard()->m_BoundaryBox.m_Pos.y = 0x7FFFFFFFl;
GetBoard()->m_BoundaryBox.m_Pos.x = GetBoard()->m_BoundaryBox.m_Pos.y =
0x7FFFFFFFl;
xmax = ymax = -0x7FFFFFFFl;
/* Analyse des Contours PCB */
PtStruct = GetBoard()->m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{
@ -1138,10 +1131,14 @@ bool WinEDA_PcbFrame::SetBoardBoundaryBoxFromEdgesOnly()
if( ptr->m_Shape == S_CIRCLE )
{
cx = ptr->m_Start.x; cy = ptr->m_Start.y;
rayon = (int) hypot( (double) (ptr->m_End.x - cx), (double) (ptr->m_End.y - cy) );
rayon =
(int) hypot( (double) ( ptr->m_End.x - cx ),
(double) ( ptr->m_End.y - cy ) );
rayon += d;
GetBoard()->m_BoundaryBox.m_Pos.x = MIN( GetBoard()->m_BoundaryBox.m_Pos.x, cx - rayon );
GetBoard()->m_BoundaryBox.m_Pos.y = MIN( GetBoard()->m_BoundaryBox.m_Pos.y, cy - rayon );
GetBoard()->m_BoundaryBox.m_Pos.x = MIN(
GetBoard()->m_BoundaryBox.m_Pos.x, cx - rayon );
GetBoard()->m_BoundaryBox.m_Pos.y = MIN(
GetBoard()->m_BoundaryBox.m_Pos.y, cy - rayon );
xmax = MAX( xmax, cx + rayon );
ymax = MAX( ymax, cy + rayon );
}
@ -1149,8 +1146,10 @@ bool WinEDA_PcbFrame::SetBoardBoundaryBoxFromEdgesOnly()
{
cx = MIN( ptr->m_Start.x, ptr->m_End.x );
cy = MIN( ptr->m_Start.y, ptr->m_End.y );
GetBoard()->m_BoundaryBox.m_Pos.x = MIN( GetBoard()->m_BoundaryBox.m_Pos.x, cx - d );
GetBoard()->m_BoundaryBox.m_Pos.y = MIN( GetBoard()->m_BoundaryBox.m_Pos.y, cy - d );
GetBoard()->m_BoundaryBox.m_Pos.x = MIN(
GetBoard()->m_BoundaryBox.m_Pos.x, cx - d );
GetBoard()->m_BoundaryBox.m_Pos.y = MIN(
GetBoard()->m_BoundaryBox.m_Pos.y, cy - d );
cx = MAX( ptr->m_Start.x, ptr->m_End.x );
cy = MAX( ptr->m_Start.y, ptr->m_End.y );
xmax = MAX( xmax, cx + d );
@ -1158,7 +1157,9 @@ bool WinEDA_PcbFrame::SetBoardBoundaryBoxFromEdgesOnly()
}
}
GetBoard()->m_BoundaryBox.SetWidth( xmax - GetBoard()->m_BoundaryBox.m_Pos.x );
GetBoard()->m_BoundaryBox.SetHeight( ymax - GetBoard()->m_BoundaryBox.m_Pos.y );
GetBoard()->m_BoundaryBox.SetWidth(
xmax - GetBoard()->m_BoundaryBox.m_Pos.x );
GetBoard()->m_BoundaryBox.SetHeight(
ymax - GetBoard()->m_BoundaryBox.m_Pos.y );
return succes;
}

View File

@ -17,8 +17,8 @@
#include "protos.h"
int E_scale; /* facteur d'echelle des tables de distance */
int Nb_Sides; /* Nombre de couches pour autoroutage (0 ou 1) */
int E_scale; /* Scaling factor of distance tables. */
int Nb_Sides; /* Number of layer for autorouting (0 or 1) */
int Nrows = ILLEGAL;
int Ncols = ILLEGAL;
int Ntotal;
@ -30,10 +30,8 @@ int MaxNodes; /* maximum number of nodes opened at one time */
BOARDHEAD Board; /* 2-sided board */
/********************************************************/
void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode )
/********************************************************/
/* init board, route traces*/
void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode )
{
int start, stop;
MODULE* Module = NULL;
@ -78,7 +76,8 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode )
Module = (MODULE*) GetScreen()->GetCurItem();
if( (Module == NULL) || (Module->Type() != TYPE_MODULE) )
{
DisplayError( this, _( "Module not selected" ) ); return;
DisplayError( this, _( "Module not selected" ) );
return;
}
break;
@ -86,7 +85,8 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode )
Pad = (D_PAD*) GetScreen()->GetCurItem();
if( (Pad == NULL) || (Pad->Type() != TYPE_PAD) )
{
DisplayError( this, _( "Pad not selected" ) ); return;
DisplayError( this, _( "Pad not selected" ) );
return;
}
break;
}
@ -94,7 +94,7 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode )
if( (GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK ) == 0 )
Compile_Ratsnest( DC, TRUE );
/* Placement du flag CH_ROUTE_REQ sur les chevelus demandes */
/* Set the flag on the ratsnest to CH_ROUTE_REQ. */
for( unsigned ii = 0; ii < GetBoard()->GetRatsnestsCount(); ii++ )
{
RATSNEST_ITEM* ptmp = &GetBoard()->m_FullRatsnest[ii];
@ -103,7 +103,8 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode )
switch( mode )
{
case ROUTE_ALL:
ptmp->m_Status |= CH_ROUTE_REQ; break;
ptmp->m_Status |= CH_ROUTE_REQ;
break;
case ROUTE_NET:
if( autoroute_net_code == ptmp->GetNet() )
@ -125,7 +126,7 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode )
}
case ROUTE_PAD:
if( (ptmp->m_PadStart == Pad) || (ptmp->m_PadEnd == Pad) )
if( ( ptmp->m_PadStart == Pad ) || ( ptmp->m_PadEnd == Pad ) )
ptmp->m_Status |= CH_ROUTE_REQ;
break;
}
@ -133,19 +134,19 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode )
start = time( NULL );
/* Calcul du pas de routage fixe a 5 mils et plus */
/* Calculation of no fixed routing to 5 mils and more. */
g_GridRoutingSize = (int)GetScreen()->GetGridSize().x;
if( g_GridRoutingSize < 50 )
g_GridRoutingSize = 50;
E_scale = g_GridRoutingSize / 50; if( E_scale < 1 )
E_scale = 1;
/* calcule de Ncols et Nrow, taille de la matrice de routage */
/* Calculated ncol and nrow, matrix size for routing. */
ComputeMatriceSize( this, g_GridRoutingSize );
MsgPanel->EraseMsgBox();
/* Creation du mapping du board */
/* Map the board */
Nb_Sides = ONE_SIDE;
if( Route_Layer_TOP != Route_Layer_BOTTOM )
Nb_Sides = TWO_SIDES;
@ -153,14 +154,14 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode )
if( Board.InitBoard() < 0 )
{
DisplayError( this, _( "No memory for autorouting" ) );
Board.UnInitBoard(); /* Libere la memoire BitMap */
Board.UnInitBoard(); /* Free memory. */
return;
}
Affiche_Message( _( "Place Cells" ) );
PlaceCells( GetBoard(), -1, FORCE_PADS );
/* Construction de la liste des pistes a router */
/* Construction of the track list for router. */
Build_Work( GetBoard() );
// DisplayBoard(DrawPanel, DC);
@ -170,26 +171,24 @@ void WinEDA_PcbFrame::Autoroute( wxDC* DC, int mode )
else
Solve( DC, ONE_SIDE ); /* simple face */
/* Liberation de la memoire */
FreeQueue(); /* Libere la memoire de routage */
InitWork(); /* Libere la memoire de la liste des connexions a router */
Board.UnInitBoard(); /* Libere la memoire BitMap */
/* Free memory. */
FreeQueue();
InitWork(); /* Free memory for the list of router connections. */
Board.UnInitBoard();
stop = time( NULL ) - start;
msg.Printf( wxT( "time = %d second%s" ), stop, (stop == 1) ? wxT( "" ) : wxT( "s" ) );
msg.Printf( wxT( "time = %d second%s" ), stop,
( stop == 1 ) ? wxT( "" ) : wxT( "s" ) );
Affiche_Message( msg );
}
/************************************************/
void WinEDA_PcbFrame::Reset_Noroutable( wxDC* DC )
/*************************************************/
/* Remet a 0 le flag CH_NOROUTABLE qui est positionne a 1 par Solve()
* lorsque un chevelu n'a pas ete route.
* Si ce flag est a 1 il n'est pas reroute
/* Clear the flag has CH_NOROUTABLE which is set to 1 by Solve()
* When a ratsnets has not been routed.
* If this flag is 1 it is not reroute
*/
void WinEDA_PcbFrame::Reset_Noroutable( wxDC* DC )
{
if( (GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK )== 0 )
if( ( GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK )== 0 )
Compile_Ratsnest( DC, TRUE );
for( unsigned ii = 0; ii < GetBoard()->GetRatsnestsCount(); ii++ )
@ -199,17 +198,15 @@ void WinEDA_PcbFrame::Reset_Noroutable( wxDC* DC )
}
/*****************************************************/
/* Function DEBUG: displays filling cells TOP and BOTTOM */
void DisplayBoard( WinEDA_DrawPanel* panel, wxDC* DC )
/****************************************************/
/* Fonction de DEBUG : affiche le remplissage des cellules TOP et BOTTOM */
{
int row, col, i, j;
int dcell0, dcell1 = 0, color;
int maxi;
maxi = 600 / Ncols;
maxi = (maxi * 3 ) / 4;
maxi = ( maxi * 3 ) / 4;
if( !maxi )
maxi = 1;
@ -227,7 +224,7 @@ void DisplayBoard( WinEDA_DrawPanel* panel, wxDC* DC )
if( dcell1 & HOLE )
color |= RED;
// dcell0 |= dcell1;
if( !color && (dcell0 & VIA_IMPOSSIBLE) )
if( !color && ( dcell0 & VIA_IMPOSSIBLE ) )
color = BLUE;
if( dcell0 & CELL_is_EDGE )
color = YELLOW;
@ -241,8 +238,8 @@ void DisplayBoard( WinEDA_DrawPanel* panel, wxDC* DC )
for( i = 0; i < maxi; i++ )
for( j = 0; j < maxi; j++ )
GRSPutPixel( &panel->m_ClipBox, DC,
(col * maxi) + i + DRAW_OFFSET_X,
(row * maxi) + j + DRAW_OFFSET_Y, color );
( col * maxi ) + i + DRAW_OFFSET_X,
( row * maxi ) + j + DRAW_OFFSET_Y, color );
}
}

View File

@ -1,7 +1,5 @@
/****************************************************/
/* AUTOROUT.H */
/* declarations communes relative au routage */
/* et placement automatique des composants */
/****************************************************/
#ifndef AUTOROUT_H
@ -14,11 +12,7 @@
#define ILLEGAL -1
/***********************************************/
/* description d'un segment de chevelu general */
/***********************************************/
/* Commandes d'autoplacement / autorouage possibles */
/* Autorouter commands. */
enum CommandOpt {
PLACE_ALL,
PLACE_OUT_OF_BOARD,
@ -32,17 +26,14 @@ enum CommandOpt {
};
/* Variables et structures d'autoroutage */
extern int E_scale; /* facteur d'echelle des tables de distance */
extern int E_scale; /* Scaling factor of distance tables. */
#define ONE_SIDE 0
#define TWO_SIDES 1
extern int Nb_Sides; /* Nombre de couches pour autoroutage (0 ou 1) */
extern int Nb_Sides; /* Number of layers for autorouting (0 or 1) */
/* Bits Flags de gestion de remplissage du BOARD */
#define FORCE_PADS 1 /* pour forcage placement pads quel que soit le netcode */
#define FORCE_PADS 1 /* Force placement of pads for any Netcode */
/* board dimensions */
extern int Nrows;
@ -55,8 +46,7 @@ extern int ClosNodes; /* total number of nodes closed */
extern int MoveNodes; /* total number of nodes moved */
extern int MaxNodes; /* maximum number of nodes opened at one time */
/* Structures utiles a la generation du board en Bit Map */
/* Structures useful to the generation of board as bitmap. */
typedef char BoardCell;
typedef int DistCell;
@ -65,8 +55,10 @@ class BOARDHEAD /* header of blocks of BoardCell */
{
public:
BoardCell* m_BoardSide[2]; /* ptr to block of memory: 2-sided board */
DistCell* m_DistSide[2]; /* ptr to block of memory: path distance to cells */
char* m_DirSide[2]; /* header of blocks of chars:pointers back to source */
DistCell* m_DistSide[2]; /* ptr to block of memory: path distance to
* cells */
char* m_DirSide[2]; /* header of blocks of chars:pointers back to
* source */
bool m_InitBoardDone;
int m_Layers;
int m_Nrows, m_Ncols;
@ -82,7 +74,7 @@ public:
extern BOARDHEAD Board; /* 2-sided board */
/* Constantes utilisees pour le trace des cellules sur le BOARD */
/* Constants used to trace the cells on the BOARD */
#define WRITE_CELL 0
#define WRITE_OR_CELL 1
#define WRITE_XOR_CELL 2

View File

@ -1,6 +1,6 @@
/************************************************************************/
/* basepcbframe.cpp - fonctions des classes du type WinEDA_BasePcbFrame */
/************************************************************************/
/********************/
/* basepcbframe.cpp */
/********************/
#ifdef __GNUG__
#pragma implementation
@ -44,10 +44,6 @@ BEGIN_EVENT_TABLE( WinEDA_BasePcbFrame, WinEDA_DrawFrame )
END_EVENT_TABLE()
/****************/
/* Constructeur */
/****************/
WinEDA_BasePcbFrame::WinEDA_BasePcbFrame( wxWindow* father,
int idtype,
const wxString& title,
@ -95,12 +91,10 @@ void WinEDA_BasePcbFrame::SetBoard( BOARD* aBoard )
}
/**************************************/
int WinEDA_BasePcbFrame::BestZoom( void )
/**************************************/
/**
* Return the "best" zoom, i.e. the zoom which shows the entire board on screen
*/
int WinEDA_BasePcbFrame::BestZoom( void )
{
int dx, dy, ii, jj;
int bestzoom;
@ -124,9 +118,7 @@ int WinEDA_BasePcbFrame::BestZoom( void )
}
/***********************************************************/
void WinEDA_BasePcbFrame::CursorGoto( const wxPoint& aPos )
/***********************************************************/
{
// factored out of pcbnew/find.cpp
@ -134,7 +126,7 @@ void WinEDA_BasePcbFrame::CursorGoto( const wxPoint& aPos )
wxClientDC dc( DrawPanel );
/* Il y a peut-etre necessite de recadrer le dessin: */
/* There may be need to reframe the drawing. */
if( !DrawPanel->IsPointOnDisplay( aPos ) )
{
screen->m_Curseur = aPos;
@ -151,27 +143,21 @@ void WinEDA_BasePcbFrame::CursorGoto( const wxPoint& aPos )
}
/*************************************************/
void WinEDA_BasePcbFrame::ReCreateMenuBar( void )
/*************************************************/
// Virtual function
void WinEDA_BasePcbFrame::ReCreateMenuBar( void )
{
}
/* Virtual functions: Do nothing for WinEDA_BasePcbFrame window */
/* Virtual functions: Do nothing for WinEDA_BasePcbFrame window */
void WinEDA_BasePcbFrame::Show3D_Frame( wxCommandEvent& event )
{
}
/****************************************************************/
void WinEDA_BasePcbFrame::SwitchLayer( wxDC* DC, int layer )
/*****************************************************************/
// Note: virtual, overridden in WinEDA_PcbFrame;
void WinEDA_BasePcbFrame::SwitchLayer( wxDC* DC, int layer )
{
int preslayer = ((PCB_SCREEN*)GetScreen())->m_Active_Layer;
@ -200,8 +186,8 @@ void WinEDA_BasePcbFrame::SwitchLayer( wxDC* DC, int layer )
// layers are also capable of being selected.
else
{
if( (layer != COPPER_LAYER_N) && (layer != LAYER_CMP_N)
&& (layer >= m_Pcb->m_BoardSettings->GetCopperLayerCount() - 1) )
if( ( layer != COPPER_LAYER_N ) && ( layer != LAYER_CMP_N )
&& ( layer >= m_Pcb->m_BoardSettings->GetCopperLayerCount() - 1 ) )
{
return;
}
@ -244,9 +230,7 @@ void WinEDA_BasePcbFrame::ProcessItemSelection( wxCommandEvent& event )
}
/*****************************************************************/
void WinEDA_BasePcbFrame::SetCurItem( BOARD_ITEM* aItem, bool aDisplayInfo )
/*****************************************************************/
{
GetScreen()->SetCurItem( aItem );
@ -275,20 +259,16 @@ void WinEDA_BasePcbFrame::SetCurItem( BOARD_ITEM* aItem, bool aDisplayInfo )
}
/*****************************************************************/
BOARD_ITEM* WinEDA_BasePcbFrame::GetCurItem()
/*****************************************************************/
{
return GetScreen()->GetCurItem();
}
/****************************************************************/
GENERAL_COLLECTORS_GUIDE WinEDA_BasePcbFrame::GetCollectorsGuide()
/****************************************************************/
{
GENERAL_COLLECTORS_GUIDE guide( m_Pcb->m_BoardSettings->GetVisibleLayers(),
((PCB_SCREEN*)GetScreen())->m_Active_Layer );
( (PCB_SCREEN*)GetScreen())->m_Active_Layer );
// account for the globals
guide.SetIgnoreMTextsMarkedNoShow( ! g_DesignSettings.IsElementVisible( MODULE_TEXT_NOV_VISIBLE ));
@ -324,10 +304,11 @@ void WinEDA_BasePcbFrame::SetToolID( int id, int new_cursor_id,
DrawPanel->Refresh();
}
void WinEDA_BasePcbFrame::UpdateStatusBar()
/*
* Update the status bar information.
*/
void WinEDA_BasePcbFrame::UpdateStatusBar()
{
WinEDA_DrawFrame::UpdateStatusBar();
@ -351,7 +332,8 @@ void WinEDA_BasePcbFrame::UpdateStatusBar()
theta = theta * 180.0 / M_PI;
ro = sqrt( ( (double) dx * dx ) + ( (double) dy * dy ) );
Line.Printf( g_UnitMetric ? wxT( "Ro %.3f Th %.1f" ) : wxT( "Ro %.4f Th %.1f" ),
Line.Printf( g_UnitMetric ? wxT( "Ro %.3f Th %.1f" ) :
wxT( "Ro %.4f Th %.1f" ),
To_User_Unit( g_UnitMetric, ro, m_InternalUnits ),
theta );
@ -381,21 +363,24 @@ void WinEDA_BasePcbFrame::LoadSettings()
wxConfig* cfg = wxGetApp().m_EDA_Config;
WinEDA_DrawFrame::LoadSettings();
// Ensure grid id is an existant grid id:
// Ensure grid id is an existent grid id:
if( (m_LastGridSizeId <= 0) ||
(m_LastGridSizeId > (ID_POPUP_GRID_USER - ID_POPUP_GRID_LEVEL_1000)) )
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_500 - ID_POPUP_GRID_LEVEL_1000;
cfg->Read( m_FrameName + UserGridSizeXEntry, &m_UserGridSize.x, 0.01 );
cfg->Read( m_FrameName + UserGridSizeYEntry, &m_UserGridSize.y, 0.01 );
cfg->Read( m_FrameName + UserGridUnitsEntry, &m_UserGridUnits, ( long )INCHES );
cfg->Read( m_FrameName + UserGridUnitsEntry, &m_UserGridUnits,
( long )INCHES );
cfg->Read( m_FrameName + DisplayPadFillEntry, &m_DisplayPadFill, true );
cfg->Read( m_FrameName + DisplayViaFillEntry, &m_DisplayViaFill, true );
cfg->Read( m_FrameName + DisplayPadNumberEntry, &m_DisplayPadNum, true );
cfg->Read( m_FrameName + DisplayModuleEdgeEntry, &m_DisplayModEdge, ( long )FILLED );
cfg->Read( m_FrameName + DisplayModuleEdgeEntry, &m_DisplayModEdge,
( long )FILLED );
if( m_DisplayModEdge < FILAIRE || m_DisplayModEdge > SKETCH )
m_DisplayModEdge = FILLED;
cfg->Read( m_FrameName + DisplayModuleTextEntry, &m_DisplayModText, ( long )FILLED );
cfg->Read( m_FrameName + DisplayModuleTextEntry, &m_DisplayModText,
( long )FILLED );
if( m_DisplayModText < FILAIRE || m_DisplayModText > SKETCH )
m_DisplayModText = FILLED;
}

View File

@ -1,6 +1,6 @@
/*****************************************************************/
/* Operations sur Blocks : deplacement, rotation, effacement ... */
/*****************************************************************/
/*************/
/* block.cpp */
/*************/
#include "fctsys.h"
@ -21,12 +21,11 @@
#define BLOCK_COLOR BROWN
/* Routines Locales */
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
bool erase );
/* Variables locales :*/
static bool Block_Include_Modules = TRUE;
static bool Block_Include_Tracks = TRUE;
static bool Block_Include_Zones = TRUE;
@ -34,6 +33,7 @@ static bool Block_Include_Draw_Items = TRUE;
static bool Block_Include_Edges_Items = TRUE;
static bool Block_Include_PcbTextes = TRUE;
/************************************/
/* class WinEDA_ExecBlockCmdFrame */
/************************************/
@ -52,7 +52,6 @@ private:
public:
// Constructor and destructor
WinEDA_ExecBlockCmdFrame( WinEDA_BasePcbFrame* parent,
const wxString& title );
~WinEDA_ExecBlockCmdFrame()
@ -67,22 +66,22 @@ private:
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE( WinEDA_ExecBlockCmdFrame, wxDialog )
EVT_BUTTON( wxID_OK, WinEDA_ExecBlockCmdFrame::ExecuteCommand )
EVT_BUTTON( wxID_CANCEL, WinEDA_ExecBlockCmdFrame::Cancel )
EVT_BUTTON( wxID_OK, WinEDA_ExecBlockCmdFrame::ExecuteCommand )
EVT_BUTTON( wxID_CANCEL, WinEDA_ExecBlockCmdFrame::Cancel )
END_EVENT_TABLE()
/**************************************************************/
static bool InstallBlockCmdFrame( WinEDA_BasePcbFrame* parent,
const wxString& title )
/**************************************************************/
{
int nocmd;
wxPoint oldpos = parent->GetScreen()->m_Curseur;
parent->DrawPanel->m_IgnoreMouseEvents = TRUE;
WinEDA_ExecBlockCmdFrame* frame = new WinEDA_ExecBlockCmdFrame( parent, title );
WinEDA_ExecBlockCmdFrame* frame =
new WinEDA_ExecBlockCmdFrame( parent, title );
nocmd = frame->ShowModal();
frame->Destroy();
@ -92,19 +91,17 @@ static bool InstallBlockCmdFrame( WinEDA_BasePcbFrame* parent,
parent->DrawPanel->MouseToCursorSchema();
parent->DrawPanel->m_IgnoreMouseEvents = FALSE;
parent->DrawPanel->SetCursor(
parent->DrawPanel->m_PanelCursor = parent->DrawPanel->m_PanelDefaultCursor );
parent->DrawPanel->SetCursor( parent->DrawPanel->m_PanelCursor =
parent->DrawPanel->m_PanelDefaultCursor );
return nocmd ? FALSE : TRUE;
}
/******************************************************************************/
WinEDA_ExecBlockCmdFrame::WinEDA_ExecBlockCmdFrame( WinEDA_BasePcbFrame* parent,
const wxString& title ) :
wxDialog( parent, -1, title, wxPoint( -1, -1 ), wxDefaultSize,
DIALOG_STYLE )
/******************************************************************************/
{
wxPoint pos;
wxButton* m_button1;
@ -122,38 +119,38 @@ WinEDA_ExecBlockCmdFrame::WinEDA_ExecBlockCmdFrame( WinEDA_BasePcbFrame* parent,
fgSizer1->SetFlexibleDirection( wxBOTH );
fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
// Selection des options :
m_Include_Modules = new wxCheckBox( this, -1, _(
"Include Modules" ), wxDefaultPosition, wxDefaultSize,
m_Include_Modules = new wxCheckBox( this, -1, _( "Include Modules" ),
wxDefaultPosition, wxDefaultSize,
0 );
m_Include_Modules->SetValue( Block_Include_Modules );
fgSizer1->Add( m_Include_Modules, 0, wxALL, 5 );
m_Include_Tracks = new wxCheckBox( this, -1, _(
"Include tracks" ), wxDefaultPosition, wxDefaultSize, 0 );
m_Include_Tracks = new wxCheckBox( this, -1, _( "Include tracks" ),
wxDefaultPosition, wxDefaultSize, 0 );
m_Include_Tracks->SetValue( Block_Include_Tracks );
fgSizer1->Add( m_Include_Tracks, 0, wxALL, 5 );
m_Include_Zones = new wxCheckBox( this, -1, _(
"Include zones" ), wxDefaultPosition, wxDefaultSize, 0 );
m_Include_Zones = new wxCheckBox( this, -1, _( "Include zones" ),
wxDefaultPosition, wxDefaultSize, 0 );
m_Include_Zones->SetValue( Block_Include_Zones );
fgSizer1->Add( m_Include_Zones, 0, wxALL, 5 );
m_Include_PcbTextes = new wxCheckBox( this, -1,
_(
"Include Text on copper layers" ), wxDefaultPosition,
_( "Include Text on copper layers" ),
wxDefaultPosition,
wxDefaultSize, 0 );
m_Include_PcbTextes->SetValue( Block_Include_PcbTextes );
fgSizer1->Add( m_Include_PcbTextes, 0, wxALL, 5 );
m_Include_Draw_Items = new wxCheckBox( this, -1, _(
"Include drawings" ), wxDefaultPosition,
m_Include_Draw_Items = new wxCheckBox( this, -1, _( "Include drawings" ),
wxDefaultPosition,
wxDefaultSize, 0 );
m_Include_Draw_Items->SetValue( Block_Include_Draw_Items );
fgSizer1->Add( m_Include_Draw_Items, 0, wxALL, 5 );
m_Include_Edges_Items = new wxCheckBox( this, -1, _(
"Include board outline layer" ), wxDefaultPosition,
m_Include_Edges_Items = new wxCheckBox( this, -1,
_( "Include board outline layer" ),
wxDefaultPosition,
wxDefaultSize, 0 );
m_Include_Edges_Items->SetValue( Block_Include_Edges_Items );
fgSizer1->Add( m_Include_Edges_Items, 0, wxALL, 5 );
@ -164,11 +161,11 @@ WinEDA_ExecBlockCmdFrame::WinEDA_ExecBlockCmdFrame( WinEDA_BasePcbFrame* parent,
fgSizer2->SetFlexibleDirection( wxBOTH );
fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
/* Creation des boutons de commande */
m_button2 = new wxButton( this, wxID_CANCEL, _(
"Cancel" ), wxDefaultPosition, wxDefaultSize, 0 );
m_button2 = new wxButton( this, wxID_CANCEL, _( "Cancel" ),
wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_button2, 0, wxALL, 5 );
m_button1 = new wxButton( this, wxID_OK, _( "OK" ), wxDefaultPosition, wxDefaultSize, 0 );
m_button1 = new wxButton( this, wxID_OK, _( "OK" ), wxDefaultPosition,
wxDefaultSize, 0 );
m_button1->SetDefault();
fgSizer2->Add( m_button1, 0, wxALL, 5 );
@ -179,17 +176,13 @@ WinEDA_ExecBlockCmdFrame::WinEDA_ExecBlockCmdFrame( WinEDA_BasePcbFrame* parent,
}
/**********************************************************************/
void WinEDA_ExecBlockCmdFrame::Cancel( wxCommandEvent& WXUNUSED (event) )
/**********************************************************************/
{
EndModal( -1 );
}
/*******************************************************************/
void WinEDA_ExecBlockCmdFrame::ExecuteCommand( wxCommandEvent& event )
/*******************************************************************/
{
Block_Include_Modules = m_Include_Modules->GetValue();
Block_Include_Tracks = m_Include_Tracks->GetValue();
@ -202,13 +195,10 @@ void WinEDA_ExecBlockCmdFrame::ExecuteCommand( wxCommandEvent& event )
}
/*************************************************/
int WinEDA_PcbFrame::ReturnBlockCommand( int key )
/*************************************************/
/* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to
* the key (ALT, SHIFT ALT ..)
*/
int WinEDA_PcbFrame::ReturnBlockCommand( int key )
{
int cmd = 0;
@ -247,10 +237,8 @@ int WinEDA_PcbFrame::ReturnBlockCommand( int key )
}
/*****************************************************/
/* Routine to handle the BLOCK PLACE command */
void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC )
/*****************************************************/
/* Routine to handle the BLOCK PLACE commande */
{
bool err = FALSE;
@ -308,16 +296,13 @@ void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC )
}
/**********************************************/
int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
/**********************************************/
/* Routine de gestion de la commande BLOCK END
* returne :
* 0 si aucun composant selectionne
* 1 sinon
* -1 si commande terminée et composants trouvés (block delete, block save)
/* Handle END BLOCK command.
* Returns:
* 0 if no features selected
* 1 otherwise
* -1 If order is completed and components found (block delete, block save)
*/
int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
{
int endcommande = TRUE;
@ -381,7 +366,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_ZOOM: /* Window Zoom */
//Turn off the redraw block routine now so it is not displayed
// Turn off the redraw block routine now so it is not displayed
// with one corner at the new center of the screen
DrawPanel->ManageCurseur = NULL;
Window_Zoom( GetScreen()->m_BlockLocate );
@ -424,10 +409,10 @@ void WinEDA_PcbFrame::Block_SelectItems()
PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.m_ItemsSelection;
ITEM_PICKER picker( NULL, UR_UNSPECIFIED );
/* Effacement des modules */
if( Block_Include_Modules )
{
for( MODULE* module = m_Pcb->m_Modules; module != NULL; module = module->Next() )
for( MODULE* module = m_Pcb->m_Modules; module != NULL;
module = module->Next() )
{
if( module->HitTest( GetScreen()->m_BlockLocate ) )
{
@ -441,7 +426,8 @@ void WinEDA_PcbFrame::Block_SelectItems()
/* Remove tracks and vias */
if( Block_Include_Tracks )
{
for( TRACK* pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = pt_segm->Next() )
for( TRACK* pt_segm = m_Pcb->m_Track; pt_segm != NULL;
pt_segm = pt_segm->Next() )
{
if( pt_segm->HitTest( GetScreen()->m_BlockLocate ) )
{
@ -461,7 +447,8 @@ void WinEDA_PcbFrame::Block_SelectItems()
if( !Block_Include_Edges_Items )
masque_layer &= ~EDGE_LAYER;
for( BOARD_ITEM* PtStruct = m_Pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() )
for( BOARD_ITEM* PtStruct = m_Pcb->m_Drawings; PtStruct != NULL;
PtStruct = PtStruct->Next() )
{
bool select_me = false;
switch( PtStruct->Type() )
@ -483,7 +470,7 @@ void WinEDA_PcbFrame::Block_SelectItems()
break;
case TYPE_MIRE:
if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 )
if( ( g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer ) == 0 )
break;
if( !PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
break;
@ -491,7 +478,7 @@ void WinEDA_PcbFrame::Block_SelectItems()
break;
case TYPE_COTATION:
if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 )
if( ( g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer ) == 0 )
break;
if( !PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
break;
@ -518,7 +505,8 @@ void WinEDA_PcbFrame::Block_SelectItems()
* m_Pcb->m_Zone can have a *lot* of items (100 000 is easily possible)
* so it is not selected (and TODO: will be removed, one day)
*/
for( SEGZONE* pt_segm = m_Pcb->m_Zone; pt_segm != NULL; pt_segm = pt_segm->Next() )
for( SEGZONE* pt_segm = m_Pcb->m_Zone; pt_segm != NULL;
pt_segm = pt_segm->Next() )
{ /* Segments used in Zone filling selection */
if( pt_segm->HitTest( GetScreen()->m_BlockLocate ) )
@ -543,23 +531,22 @@ void WinEDA_PcbFrame::Block_SelectItems()
}
/**************************************************************************/
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/**************************************************************************/
/* Retrace le contour du block de repositionnement des structures a déplacer
/* Traces the outline of the block structures during move.
*/
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
bool erase )
{
int Color;
BASE_SCREEN* screen = panel->GetScreen();
Color = YELLOW;
/* Effacement ancien cadre */
if( erase )
{
screen->m_BlockLocate.Draw( panel, DC, wxPoint( 0, 0 ), g_XorMode, Color );
if( screen->m_BlockLocate.m_MoveVector.x || screen->m_BlockLocate.m_MoveVector.y )
screen->m_BlockLocate.Draw( panel, DC, wxPoint( 0, 0 ), g_XorMode,
Color );
if( screen->m_BlockLocate.m_MoveVector.x
|| screen->m_BlockLocate.m_MoveVector.y )
{
screen->m_BlockLocate.Draw( panel,
DC,
@ -578,7 +565,8 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool era
}
screen->m_BlockLocate.Draw( panel, DC, wxPoint( 0, 0 ), g_XorMode, Color );
if( screen->m_BlockLocate.m_MoveVector.x || screen->m_BlockLocate.m_MoveVector.y )
if( screen->m_BlockLocate.m_MoveVector.x
|| screen->m_BlockLocate.m_MoveVector.y )
{
screen->m_BlockLocate.Draw( panel,
DC,
@ -589,13 +577,10 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool era
}
/************************************************/
void WinEDA_PcbFrame::Block_Delete()
/************************************************/
/*
* routine d'effacement du block deja selectionne
* Erase selected block.
*/
void WinEDA_PcbFrame::Block_Delete()
{
if( !InstallBlockCmdFrame( this, _( "Delete Block" ) ) )
return;
@ -664,14 +649,14 @@ void WinEDA_PcbFrame::Block_Delete()
/**
* Function Block_Rotate
* Rotate all items within the selected block.
* The rotation centre is the centre of the block
* The rotation center is the center of the block
* @param none
*/
void WinEDA_PcbFrame::Block_Rotate()
{
wxPoint oldpos;
wxPoint centre; // rotation centre for the rotation transform
int rotAngle = 900; // rottaion angle in 0.1 deg.
wxPoint centre; // rotation cent-re for the rotation transform
int rotAngle = 900; // rotation angle in 0.1 deg.
if( !InstallBlockCmdFrame( this, _( "Rotate Block" ) ) )
return;
@ -681,7 +666,7 @@ void WinEDA_PcbFrame::Block_Rotate()
return;
oldpos = GetScreen()->m_Curseur;
centre = GetScreen()->m_BlockLocate.Centre(); // This is the rotation centre
centre = GetScreen()->m_BlockLocate.Centre();
GetScreen()->SetModify();
@ -736,14 +721,14 @@ void WinEDA_PcbFrame::Block_Rotate()
/**
* Function Block_Flip
* Flip items within the selected block.
* The flip centre is the centre of the block
* The flip center is the center of the block
* @param none
*/
void WinEDA_PcbFrame::Block_Flip()
{
#define INVERT( pos ) (pos) = center.y - ( (pos) - center.y )
wxPoint memo;
wxPoint center; /* position de l'axe d'inversion de l'ensemble des elements */
wxPoint center; /* Position of the axis for inversion of all elements */
Block_SelectItems();
if( GetScreen()->m_BlockLocate.GetCount() == 0 )
@ -756,7 +741,6 @@ void WinEDA_PcbFrame::Block_Flip()
memo = GetScreen()->m_Curseur;
/* calcul du centre d'inversion */
center = GetScreen()->m_BlockLocate.Centre();
for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
@ -807,7 +791,8 @@ void WinEDA_PcbFrame::Block_Flip()
/**
* Function Block_Move
* moves all tracks and segments within the selected block.
* New location is determined by the current offset from the selected block's original location.
* New location is determined by the current offset from the selected block's
* original location.
* @param none
*/
void WinEDA_PcbFrame::Block_Move()
@ -874,7 +859,8 @@ void WinEDA_PcbFrame::Block_Move()
/**
* Function Block_Duplicate
* Duplicate all items within the selected block.
* New location is determined by the current offset from the selected block's original location.
* New location is determined by the current offset from the selected block's
* original location.
* @param none
*/
void WinEDA_PcbFrame::Block_Duplicate()
@ -933,7 +919,8 @@ void WinEDA_PcbFrame::Block_Duplicate()
case TYPE_ZONE_CONTAINER:
{
ZONE_CONTAINER* new_zone = new ZONE_CONTAINER( (BOARD*) item->GetParent() );
ZONE_CONTAINER* new_zone =
new ZONE_CONTAINER( (BOARD*) item->GetParent() );
new_zone->Copy( (ZONE_CONTAINER*) item );
new_zone->m_TimeStamp = GetTimeStamp();
newitem = new_zone;

View File

@ -23,11 +23,7 @@
#define BLOCK_COLOR BROWN
#define IS_SELECTED 1
/* Variables Locales */
/* Fonctions exportees */
/* Fonctions Locales */
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel,
wxDC* DC,
bool erase );
@ -42,14 +38,11 @@ static void RotateMarkedItems( MODULE* module, wxPoint offset );
static void DeleteMarkedItems( MODULE* module );
/*************************************************************************/
int WinEDA_ModuleEditFrame::ReturnBlockCommand( int key )
/*************************************************************************/
/* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to
* the key (ALT, SHIFT ALT ..) pressed when dragging mouse and left or middle button
* pressed
* the key (ALT, SHIFT ALT ..) pressed when dragging mouse and left or
* middle button pressed
*/
int WinEDA_ModuleEditFrame::ReturnBlockCommand( int key )
{
int cmd;
@ -92,15 +85,13 @@ int WinEDA_ModuleEditFrame::ReturnBlockCommand( int key )
}
/****************************************************/
int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
/****************************************************/
/* Command BLOCK END (end of block sizing)
* return :
* 0 if command finished (zoom, delete ...)
* 1 if HandleBlockPlace must follow (items found, and a block place command must follow)
* 1 if HandleBlockPlace must follow (items found, and a block place command
* must follow)
*/
int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
{
int ItemsCount = 0, MustDoPlace = 0;
MODULE* Currentmodule = GetBoard()->m_Modules;
@ -128,7 +119,8 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_DRAG: /* Drag */
case BLOCK_MOVE: /* Move */
case BLOCK_COPY: /* Copy */
ItemsCount = MarkItemsInBloc( Currentmodule, GetScreen()->m_BlockLocate );
ItemsCount = MarkItemsInBloc( Currentmodule,
GetScreen()->m_BlockLocate );
if( ItemsCount )
{
MustDoPlace = 1;
@ -200,7 +192,8 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
SetCurItem( NULL );
SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString );
SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor,
wxEmptyString );
DrawPanel->Refresh( TRUE );
}
@ -213,10 +206,10 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC )
/******************************************************/
/* Routine to handle the BLOCK PLACE commande
/* Routine to handle the BLOCK PLACE command
* Last routine for block operation for:
* - block move & drag
* - block copie & paste
* - block copy & paste
*/
{
bool err = FALSE;
@ -251,7 +244,7 @@ void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC )
CopyMarkedItems( Currentmodule, GetScreen()->m_BlockLocate.m_MoveVector );
break;
case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */
case BLOCK_PASTE: /* Paste */
GetScreen()->m_BlockLocate.ClearItemsList();
break;
@ -291,14 +284,11 @@ void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC )
}
/************************************************************************/
/* Traces the outline of the search block structures
* The entire block follows the cursor
*/
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
bool erase )
/************************************************************************/
/* Retrace le contour du block de recherche de structures
* L'ensemble du block suit le curseur
*/
{
BLOCK_SELECTOR* PtBlock;
BASE_SCREEN* screen = panel->GetScreen();
@ -310,10 +300,10 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
PtBlock = &screen->m_BlockLocate;
GRSetDrawMode( DC, g_XorMode );
/* Effacement ancien cadre */
if( erase )
{
PtBlock->Draw( panel, DC, PtBlock->m_MoveVector, g_XorMode, PtBlock->m_Color );
PtBlock->Draw( panel, DC, PtBlock->m_MoveVector, g_XorMode,
PtBlock->m_Color );
if( Currentmodule )
{
@ -347,10 +337,12 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
}
}
/* Redessin nouvel affichage */
PtBlock->m_MoveVector = screen->m_Curseur - PtBlock->m_BlockLastCursorPosition;
/* Repaint new view. */
PtBlock->m_MoveVector =
screen->m_Curseur - PtBlock->m_BlockLastCursorPosition;
PtBlock->Draw( panel, DC, PtBlock->m_MoveVector, g_XorMode, PtBlock->m_Color );
PtBlock->Draw( panel, DC, PtBlock->m_MoveVector, g_XorMode,
PtBlock->m_Color );
if( Currentmodule )
@ -385,12 +377,9 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
}
/****************************************************************************/
void CopyMarkedItems( MODULE* module, wxPoint offset )
/****************************************************************************/
/* Copy marked items, at new position = old position + offset
*/
void CopyMarkedItems( MODULE* module, wxPoint offset )
{
if( module == NULL )
return;
@ -432,8 +421,7 @@ void CopyMarkedItems( MODULE* module, wxPoint offset )
break;
default:
DisplayError( NULL,
wxT( "Internal Err: CopyMarkedItems: type indefini" ) );
DisplayError( NULL, wxT( "CopyMarkedItems: type undefined" ) );
break;
}
}
@ -442,12 +430,9 @@ void CopyMarkedItems( MODULE* module, wxPoint offset )
}
/****************************************************/
void MoveMarkedItems( MODULE* module, wxPoint offset )
/****************************************************/
/* Move marked items, at new position = old position + offset
*/
void MoveMarkedItems( MODULE* module, wxPoint offset )
{
EDA_BaseStruct* item;
@ -493,12 +478,9 @@ void MoveMarkedItems( MODULE* module, wxPoint offset )
}
/******************************************************/
void DeleteMarkedItems( MODULE* module )
/******************************************************/
/* Delete marked items
*/
void DeleteMarkedItems( MODULE* module )
{
BOARD_ITEM* item;
BOARD_ITEM* next_item;
@ -528,12 +510,9 @@ void DeleteMarkedItems( MODULE* module )
}
/******************************************************/
void MirrorMarkedItems( MODULE* module, wxPoint offset )
/******************************************************/
/* Mirror marked items, refer to a Vertical axis at position offset
*/
void MirrorMarkedItems( MODULE* module, wxPoint offset )
{
#define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x;
EDA_BaseStruct* item;
@ -588,12 +567,9 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset )
}
/******************************************************/
void RotateMarkedItems( MODULE* module, wxPoint offset )
/******************************************************/
/* Rotate marked items, refer to a Vertical axis at position offset
*/
void RotateMarkedItems( MODULE* module, wxPoint offset )
{
#define ROTATE( z ) RotatePoint( (&z), offset, 900 )
EDA_BaseStruct* item;
@ -644,9 +620,7 @@ void RotateMarkedItems( MODULE* module, wxPoint offset )
}
/*********************************************************/
void ClearMarkItems( MODULE* module )
/*********************************************************/
{
EDA_BaseStruct* item;
@ -663,13 +637,10 @@ void ClearMarkItems( MODULE* module )
}
/***************************************************************/
int MarkItemsInBloc( MODULE* module, EDA_Rect& Rect )
/***************************************************************/
/* Mark items inside rect.
* Items are inside rect when an end point is inside rect
*/
int MarkItemsInBloc( MODULE* module, EDA_Rect& Rect )
{
EDA_BaseStruct* item;
int ItemsCount = 0;

View File

@ -1,4 +1,4 @@
/* Fichier BOARD.CPP : functions for autorouting */
/* BOARD.CPP : functions for autorouting */
#include "fctsys.h"
#include "gr_basic.h"
@ -11,9 +11,7 @@
#include "protos.h"
/* routines externes : */
/* Routines definies ici: */
int Build_Work( BOARD* Pcb );
void PlaceCells( BOARD* Pcb, int net_code, int flag );
int InitBoard();
@ -29,14 +27,12 @@ void SetDist( int, int, int, DistCell );
int GetDir( int, int, int );
void SetDir( int, int, int, int );
/*****************************************************************/
bool ComputeMatriceSize( WinEDA_BasePcbFrame* frame, int g_GridRoutingSize )
/*****************************************************************/
/*
* Calcule Nrows et Ncols, dimensions de la matrice de representation du BOARD
* pour les routages automatiques et calculs de zone
* Calculates nrows and ncols, dimensions of the matrix representation of BOARD
* for routing and automatic calculation of area.
*/
bool ComputeMatriceSize( WinEDA_BasePcbFrame* frame, int g_GridRoutingSize )
{
BOARD* pcb = frame->GetBoard();
@ -81,13 +77,10 @@ BOARDHEAD::~BOARDHEAD()
}
/******************************/
int BOARDHEAD::InitBoard()
/*****************************/
/* initialize the data structures
* retourne la taille RAM utilisee, ou -1 si defaut
* returns the RAM size used, or -1 if default
*/
int BOARDHEAD::InitBoard()
{
int ii, kk;
@ -128,10 +121,7 @@ int BOARDHEAD::InitBoard()
}
/*********************************/
void BOARDHEAD::UnInitBoard()
/*********************************/
/* deallocation de la memoire */
{
int ii;
@ -162,21 +152,17 @@ void BOARDHEAD::UnInitBoard()
}
/*****************************************************/
void PlaceCells( BOARD* aPcb, int net_code, int flag )
/*****************************************************/
/* Initialise les cellules du board a la valeur HOLE et VIA_IMPOSSIBLE
* selon les marges d'isolement
* les elements de net_code = net_code ne seront pas places comme occupe
* mais en VIA_IMPOSSIBLE uniquement
* Pour Routage 1 seule face:
* le plan BOTTOM est utilise
* et Route_Layer_BOTTOM = Route_Layer_TOP
/* Initialize the cell board is set and VIA_IMPOSSIBLE HOLE according to
* the setbacks
* The elements of net_code = net_code will not be occupied as places
* but only VIA_IMPOSSIBLE
* For single-sided Routing 1:
* BOTTOM side is used and Route_Layer_BOTTOM = Route_Layer_TOP
*
* Selon les bits = 1 du parametre flag:
* si FORCE_PADS : tous les pads seront places meme ceux de meme net_code
* According to the bits = 1 parameter flag:
* If FORCE_PADS: all pads will be placed even those same net_code.
*/
void PlaceCells( BOARD* aPcb, int net_code, int flag )
{
int ux0 = 0, uy0 = 0, ux1, uy1, dx, dy;
int marge, via_marge;
@ -192,9 +178,9 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag )
marge = clearance + (trackWidth / 2);
via_marge = clearance + (viaSize / 2);
/////////////////////////////////////
// Placement des PADS sur le board //
/////////////////////////////////////
//////////////////////////
// Place PADS on board. //
//////////////////////////
for( unsigned i=0; i < aPcb->GetPadsCount(); ++i )
{
@ -207,9 +193,9 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag )
Place_1_Pad_Board( aPcb, pad, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL );
}
///////////////////////////////////////////////
// Placement des elements de modules sur PCB //
///////////////////////////////////////////////
////////////////////////////////////////////
// Placing the elements of modules on PCB //
////////////////////////////////////////////
for( MODULE* module = aPcb->m_Modules; module; module = module->Next() )
{
for( BOARD_ITEM* item = module->m_Drawings; item; item = item->Next() )
@ -247,7 +233,7 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag )
}
////////////////////////////////////////////
// Placement des contours et segments PCB //
// Placement contours and segments on PCB //
////////////////////////////////////////////
for( BOARD_ITEM* item = aPcb->m_Drawings; item; item = item->Next() )
{
@ -296,7 +282,7 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag )
/* Put bounding box (rectangle) on matrix */
dx /= 2;
dy /= 2; /* dx et dy = demi dimensionx X et Y */
dy /= 2;
ux1 = ux0 + dx;
uy1 = uy0 + dy;
@ -306,8 +292,8 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag )
masque_layer = g_TabOneLayerMask[PtText->GetLayer()];
TraceFilledRectangle( aPcb, ux0 - marge, uy0 - marge, ux1 + marge, uy1 + marge,
(int) (PtText->m_Orient),
TraceFilledRectangle( aPcb, ux0 - marge, uy0 - marge, ux1 + marge,
uy1 + marge, (int) (PtText->m_Orient),
masque_layer, HOLE, WRITE_CELL );
TraceFilledRectangle( aPcb, ux0 - via_marge, uy0 - via_marge,
@ -344,10 +330,7 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag )
}
/******************************************************/
int Build_Work( BOARD* Pcb )
/*****************************************************/
/* Build liste conn */
{
RATSNEST_ITEM* pt_rats;
D_PAD* pt_pad;
@ -361,7 +344,7 @@ int Build_Work( BOARD* Pcb )
for( unsigned ii = 0; ii < Pcb->GetRatsnestsCount(); ii++ )
{
pt_rats = &Pcb->m_FullRatsnest[ii];
/* On ne route que les chevelus actifs et routables */
/* ??? On ne route que les chevelus actifs et routables */
if( (pt_rats->m_Status & CH_ACTIF) == 0 )
continue;
if( pt_rats->m_Status & CH_UNROUTABLE )
@ -373,18 +356,20 @@ int Build_Work( BOARD* Pcb )
current_net_code = pt_pad->GetNet();
pt_ch = pt_rats;
r1 = (pt_pad->GetPosition().y - Pcb->m_BoundaryBox.m_Pos.y + demi_pas ) / g_GridRoutingSize;
r1 = ( pt_pad->GetPosition().y - Pcb->m_BoundaryBox.m_Pos.y
+ demi_pas ) / g_GridRoutingSize;
if( r1 < 0 || r1 >= Nrows )
{
msg.Printf( wxT( "erreur : row = %d ( padY %d pcbY %d) " ), r1,
msg.Printf( wxT( "error : row = %d ( padY %d pcbY %d) " ), r1,
pt_pad->GetPosition().y, Pcb->m_BoundaryBox.m_Pos.y );
DisplayError( NULL, msg );
return 0;
}
c1 = (pt_pad->GetPosition().x - Pcb->m_BoundaryBox.m_Pos.x + demi_pas ) / g_GridRoutingSize;
c1 = ( pt_pad->GetPosition().x - Pcb->m_BoundaryBox.m_Pos.x
+ demi_pas ) / g_GridRoutingSize;
if( c1 < 0 || c1 >= Ncols )
{
msg.Printf( wxT( "erreur : col = %d ( padX %d pcbX %d) " ), c1,
msg.Printf( wxT( "error : col = %d ( padX %d pcbX %d) " ), c1,
pt_pad->GetPosition().x, Pcb->m_BoundaryBox.m_Pos.x );
DisplayError( NULL, msg );
return 0;
@ -392,18 +377,20 @@ int Build_Work( BOARD* Pcb )
pt_pad = pt_rats->m_PadEnd;
r2 = (pt_pad->GetPosition().y - Pcb->m_BoundaryBox.m_Pos.y + demi_pas ) / g_GridRoutingSize;
r2 = ( pt_pad->GetPosition().y - Pcb->m_BoundaryBox.m_Pos.y
+ demi_pas ) / g_GridRoutingSize;
if( r2 < 0 || r2 >= Nrows )
{
msg.Printf( wxT( "erreur : row = %d ( padY %d pcbY %d) " ), r2,
msg.Printf( wxT( "error : row = %d ( padY %d pcbY %d) " ), r2,
pt_pad->GetPosition().y, Pcb->m_BoundaryBox.m_Pos.y );
DisplayError( NULL, msg );
return 0;
}
c2 = (pt_pad->GetPosition().x - Pcb->m_BoundaryBox.m_Pos.x + demi_pas ) / g_GridRoutingSize;
c2 = ( pt_pad->GetPosition().x - Pcb->m_BoundaryBox.m_Pos.x
+ demi_pas ) / g_GridRoutingSize;
if( c2 < 0 || c2 >= Ncols )
{
msg.Printf( wxT( "erreur : col = %d ( padX %d pcbX %d) " ), c2,
msg.Printf( wxT( "error : col = %d ( padX %d pcbX %d) " ), c2,
pt_pad->GetPosition().x, Pcb->m_BoundaryBox.m_Pos.x );
DisplayError( NULL, msg );
return 0;
@ -418,12 +405,7 @@ int Build_Work( BOARD* Pcb )
}
/*******************************************/
BoardCell GetCell( int row, int col, int side )
/*******************************************/
/* fetch board cell :
*/
{
BoardCell* p;

View File

@ -1,13 +1,15 @@
/* Bits caracterisant une cellule */
#define HOLE (char)0x01 /* a conducting hole, ou obstacle */
#define CELL_is_MODULE (char)0x02 /* autoplacement: occupe par un module */
#define CELL_is_EDGE (char)0x20 /* zone et autoplacement: cellule limitant un contour (Board, Zone) */
#define CELL_is_FRIEND (char)0x40 /* zone et autoplacement: cellule faisant partie du net */
#define CELL_is_ZONE (char)0x80 /* zone et autoplacement: cellule disponible */
/* Bits characterizing cell */
#define HOLE (char)0x01 /* a conducting hole or obstacle */
#define CELL_is_MODULE (char)0x02 /* auto placement occupied by a module */
#define CELL_is_EDGE (char)0x20 /* Area and auto-placement: limiting cell
* contour (Board, Zone) */
#define CELL_is_FRIEND (char)0x40 /* Area and auto-placement: cell part of the
* net */
#define CELL_is_ZONE (char)0x80 /* Area and auto-placement: cell available */
/* Bits Masques de presence d'obstacles pour autoroutage */
#define OCCUPE 1 /* autoroutage : obstacle pour pistes et vias */
#define VIA_IMPOSSIBLE 2 /* autoroutage : obsacle pour vias */
/* Bit masks for presence of obstacles to autorouting */
#define OCCUPE 1 /* Autorouting: obstacle tracks and vias. */
#define VIA_IMPOSSIBLE 2 /* Autorouting: obstacle for vias. */
#define CURRENT_PAD 4

View File

@ -18,20 +18,23 @@ wxPoint BOARD_ITEM::ZeroOffset( 0, 0 );
/* Class BOARD: */
/*****************/
/* Constructor */
BOARD::BOARD( EDA_BaseStruct* parent, WinEDA_BasePcbFrame* frame ) :
BOARD_ITEM( (BOARD_ITEM*)parent, TYPE_PCB ),
m_NetClasses( this )
{
m_PcbFrame = frame;
m_Status_Pcb = 0; // Mot d'etat: Bit 1 = Chevelu calcule
m_Status_Pcb = 0; // Status word: bit 1 = calculate.
m_BoardSettings = &g_DesignSettings;
m_NbNodes = 0; // nombre de pads connectes
m_NbNoconnect = 0; // nombre de chevelus actifs
m_NbNodes = 0; // Number of connected pads.
m_NbNoconnect = 0; // Number of unconnected nets.
m_CurrentZoneContour = NULL; // This ZONE_CONTAINER handle the zone contour cuurently in progress
m_NetInfo = new NETINFO_LIST( this ); // handle nets info list (name, design constraints ..
m_NetInfo->BuildListOfNets(); // prepare pads and nets lists containers.
m_CurrentZoneContour = NULL; // This ZONE_CONTAINER handle the
// zone contour currently in
// progress
m_NetInfo = new NETINFO_LIST( this ); // handle nets info list (name,
// design constraints ..
m_NetInfo->BuildListOfNets(); // prepare pads and nets lists
// containers.
for( int layer = 0; layer < NB_COPPER_LAYERS; ++layer )
{
@ -39,20 +42,22 @@ BOARD::BOARD( EDA_BaseStruct* parent, WinEDA_BasePcbFrame* frame ) :
m_Layer[layer].m_Type = LT_SIGNAL;
}
// Initial parameters for the default NETCLASS come from the global preferences
// Initial parameters for the default NETCLASS come from the global
// preferences
// within g_DesignSettings via the NETCLASS() constructor.
// Should user eventually load a board from a disk file, then these defaults
// Should user eventually load a board from a disk file, then these
// defaults
// will get overwritten during load.
m_NetClasses.GetDefault()->SetDescription( _( "This is the default net class." ) );
m_NetClasses.GetDefault()->SetDescription(
_( "This is the default net class." ) );
m_ViaSizeSelector = 0;
m_TrackWidthSelector = 0;
SetCurrentNetClass(m_NetClasses.GetDefault()->GetName( )); // Initialize default values
// Initialize default values.
SetCurrentNetClass( m_NetClasses.GetDefault()->GetName() );
}
/***************/
/* Destructeur */
/***************/
BOARD::~BOARD()
{
if( m_PcbFrame->GetScreen() )
@ -77,21 +82,23 @@ BOARD::~BOARD()
delete m_NetInfo;
}
/**
* Function SetCurrentNetClass
* Must be called after a netclass selection (or after a netclass parameter change
* Initialise vias and tracks values displayed in combo boxs of the auxiliary toolbar
* and some others parametres (netclass name ....)
* Must be called after a netclass selection (or after a netclass parameter
* change
* Initialize vias and tracks values displayed in combo boxes of the auxiliary
* toolbar and some other parameters (netclass name ....)
* @param aNetClassName = the new netclass name
* @return true if lists of tracks and vias sizes are modified
*/
bool BOARD::SetCurrentNetClass( const wxString & aNetClassName)
bool BOARD::SetCurrentNetClass( const wxString& aNetClassName )
{
NETCLASS * netClass = m_NetClasses.Find(aNetClassName);
NETCLASS* netClass = m_NetClasses.Find( aNetClassName );
bool lists_sizes_modified = false;
// if not found (should not happen) use the default
if ( netClass == NULL )
if( netClass == NULL )
netClass = m_NetClasses.GetDefault();
m_CurrentNetClassName = netClass->GetName();
@ -101,12 +108,12 @@ BOARD::~BOARD()
{
VIA_DIMENSION viadim;
lists_sizes_modified = true;
m_ViasDimensionsList.push_back(viadim);
m_ViasDimensionsList.push_back( viadim );
}
if( m_TrackWidthList.size() == 0 )
{
lists_sizes_modified = true;
m_TrackWidthList.push_back(0);
m_TrackWidthList.push_back( 0 );
}
/* note the m_ViasDimensionsList[0] and m_TrackWidthList[0] values
@ -128,21 +135,27 @@ BOARD::~BOARD()
return lists_sizes_modified;
}
/** function GetBiggestClearanceValue
* @return the biggest clerance value found in NetClasses list
* @return the biggest clearance value found in NetClasses list
*/
int BOARD::GetBiggestClearanceValue()
{
int clearance = m_NetClasses.GetDefault()->GetClearance();
//Read list of Net Classes
for( NETCLASSES::const_iterator nc = m_NetClasses.begin(); nc != m_NetClasses.end(); nc++ )
for( NETCLASSES::const_iterator nc = m_NetClasses.begin();
nc != m_NetClasses.end();
nc++ )
{
NETCLASS* netclass = nc->second;
clearance = MAX( clearance, netclass->GetClearance() );
}
return clearance;
}
/** function GetCurrentMicroViaSize
* @return the current micro via size,
* that is the current netclass value
@ -150,9 +163,11 @@ int BOARD::GetBiggestClearanceValue()
int BOARD::GetCurrentMicroViaSize()
{
NETCLASS* netclass = m_NetClasses.Find( m_CurrentNetClassName );
return netclass->GetuViaDiameter();
}
/** function GetCurrentMicroViaDrill
* @return the current micro via drill,
* that is the current netclass value
@ -160,16 +175,19 @@ int BOARD::GetCurrentMicroViaSize()
int BOARD::GetCurrentMicroViaDrill()
{
NETCLASS* netclass = m_NetClasses.Find( m_CurrentNetClassName );
return netclass->GetuViaDrill();
}
wxString BOARD::GetLayerName( int aLayerIndex ) const
{
if( ! IsValidLayerIndex( aLayerIndex ))
if( !IsValidLayerIndex( aLayerIndex ) )
return wxEmptyString;
// copper layer names are stored in the BOARD.
if( IsValidCopperLayerIndex( aLayerIndex ) && m_BoardSettings->IsLayerEnabled( aLayerIndex ))
if( IsValidCopperLayerIndex( aLayerIndex )
&& m_BoardSettings->IsLayerEnabled( aLayerIndex ) )
{
// default names were set in BOARD::BOARD() but they may be
// over-ridden by BOARD::SetLayerName()
@ -182,7 +200,7 @@ wxString BOARD::GetLayerName( int aLayerIndex ) const
bool BOARD::SetLayerName( int aLayerIndex, const wxString& aLayerName )
{
if( ! IsValidCopperLayerIndex( aLayerIndex ))
if( !IsValidCopperLayerIndex( aLayerIndex ) )
return false;
if( aLayerName == wxEmptyString || aLayerName.Len() > 20 )
@ -197,11 +215,12 @@ bool BOARD::SetLayerName( int aLayerIndex, const wxString& aLayerName )
// replace any spaces with underscores before we do any comparing
NameTemp.Replace( wxT( " " ), wxT( "_" ) );
if( m_BoardSettings->IsLayerEnabled( aLayerIndex ))
if( m_BoardSettings->IsLayerEnabled( aLayerIndex ) )
{
for( int i = 0; i < NB_COPPER_LAYERS; i++ )
{
if( i != aLayerIndex && m_BoardSettings->IsLayerEnabled( i ) && NameTemp == m_Layer[i].m_Name )
if( i != aLayerIndex && m_BoardSettings->IsLayerEnabled( i )
&& NameTemp == m_Layer[i].m_Name )
return false;
}
@ -216,12 +235,12 @@ bool BOARD::SetLayerName( int aLayerIndex, const wxString& aLayerName )
LAYER_T BOARD::GetLayerType( int aLayerIndex ) const
{
if( ! IsValidCopperLayerIndex( aLayerIndex ))
if( !IsValidCopperLayerIndex( aLayerIndex ) )
return LT_SIGNAL;
//@@IMB: The original test was broken due to the discontinuity
// in the layer sequence.
if( m_BoardSettings->IsLayerEnabled( aLayerIndex ))
if( m_BoardSettings->IsLayerEnabled( aLayerIndex ) )
return m_Layer[aLayerIndex].m_Type;
return LT_SIGNAL;
}
@ -229,12 +248,12 @@ LAYER_T BOARD::GetLayerType( int aLayerIndex ) const
bool BOARD::SetLayerType( int aLayerIndex, LAYER_T aLayerType )
{
if( ! IsValidCopperLayerIndex( aLayerIndex ))
if( !IsValidCopperLayerIndex( aLayerIndex ) )
return false;
//@@IMB: The original test was broken due to the discontinuity
// in the layer sequence.
if( m_BoardSettings->IsLayerEnabled( aLayerIndex ))
if( m_BoardSettings->IsLayerEnabled( aLayerIndex ) )
{
m_Layer[aLayerIndex].m_Type = aLayerType;
return true;
@ -251,16 +270,20 @@ const char* LAYER::ShowType( LAYER_T aType )
{
default:
case LT_SIGNAL:
cp = "signal"; break;
cp = "signal";
break;
case LT_POWER:
cp = "power"; break;
cp = "power";
break;
case LT_MIXED:
cp = "mixed"; break;
cp = "mixed";
break;
case LT_JUMPER:
cp = "jumper"; break;
cp = "jumper";
break;
}
return cp;
@ -287,31 +310,37 @@ int BOARD::GetCopperLayerCount() const
return m_BoardSettings->GetCopperLayerCount();
}
int BOARD::GetEnabledLayers() const
{
return m_BoardSettings->GetEnabledLayers();
}
int BOARD::GetVisibleLayers() const
{
return m_BoardSettings->GetVisibleLayers();
}
void BOARD::SetEnabledLayers( int aLayerMask )
{
m_BoardSettings->SetEnabledLayers( aLayerMask );
}
void BOARD::SetVisibleLayers( int aLayerMask )
{
m_BoardSettings->SetVisibleLayers( aLayerMask );
}
void BOARD::SetVisibleElements( int aMask )
{
m_BoardSettings->SetVisibleElements( aMask );
}
int BOARD::GetVisibleElements() const
{
return m_BoardSettings->GetVisibleElements();
@ -372,7 +401,8 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl )
aBoardItem->SetParent( this );
// Because the list of pads has changed, reset the status
// This indicate the list of pad and nets must be recalculated before use
// This indicate the list of pad and nets must be recalculated before
// use
m_Status_Pcb = 0;
break;
@ -478,7 +508,8 @@ void BOARD::DeleteMARKERs()
void BOARD::DeleteZONEOutlines()
{
// the vector does not know how to delete the ZONE Outlines, it holds pointers
// the vector does not know how to delete the ZONE Outlines, it holds
// pointers
for( unsigned i = 0; i<m_ZoneDescriptorList.size(); ++i )
delete m_ZoneDescriptorList[i];
@ -514,10 +545,6 @@ unsigned BOARD::GetNodesCount()
}
/***********************************/
bool BOARD::ComputeBoundaryBox()
/***********************************/
/** Function ComputeBoundaryBox()
* Calculate the bounding box of the board
* This box contains pcb edges, pads , vias and tracks
@ -525,6 +552,7 @@ bool BOARD::ComputeBoundaryBox()
*
* @return 0 for an empty board (no items), else 1
*/
bool BOARD::ComputeBoundaryBox()
{
int rayon, cx, cy, d, xmin, ymin, xmax, ymax;
bool hasItems = FALSE;
@ -534,7 +562,7 @@ bool BOARD::ComputeBoundaryBox()
xmin = ymin = 0x7FFFFFFFl;
xmax = ymax = -0x7FFFFFFFl;
/* Analyse PCB edges*/
/* Analyze PCB edges*/
PtStruct = m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{
@ -547,7 +575,8 @@ bool BOARD::ComputeBoundaryBox()
if( ptr->m_Shape == S_CIRCLE )
{
cx = ptr->m_Start.x; cy = ptr->m_Start.y;
rayon = (int) hypot( (double) ( ptr->m_End.x - cx ), (double) ( ptr->m_End.y - cy ) );
rayon = (int) hypot( (double) ( ptr->m_End.x - cx ),
(double) ( ptr->m_End.y - cy ) );
rayon += d;
xmin = MIN( xmin, cx - rayon );
ymin = MIN( ymin, cy - rayon );
@ -569,15 +598,19 @@ bool BOARD::ComputeBoundaryBox()
}
}
/* Analyse footprints */
/* Analise footprints */
for( MODULE* module = m_Modules; module; module = module->Next() )
{
hasItems = TRUE;
xmin = MIN( xmin, ( module->m_Pos.x + module->m_BoundaryBox.GetX() ) );
ymin = MIN( ymin, ( module->m_Pos.y + module->m_BoundaryBox.GetY() ) );
xmax = MAX( xmax, module->m_Pos.x + module->m_BoundaryBox.GetRight() );
ymax = MAX( ymax, module->m_Pos.y + module->m_BoundaryBox.GetBottom() );
xmin = MIN( xmin, ( module->m_Pos.x
+ module->m_BoundaryBox.GetX() ) );
ymin = MIN( ymin, ( module->m_Pos.y
+ module->m_BoundaryBox.GetY() ) );
xmax = MAX( xmax, module->m_Pos.x
+ module->m_BoundaryBox.GetRight() );
ymax = MAX( ymax,
module->m_Pos.y + module->m_BoundaryBox.GetBottom() );
for( D_PAD* pt_pad = module->m_Pads; pt_pad; pt_pad = pt_pad->Next() )
@ -592,10 +625,10 @@ bool BOARD::ComputeBoundaryBox()
}
}
/* Analyse track and zones */
/* Analise track and zones */
for( TRACK* track = m_Track; track; track = track->Next() )
{
d = (track->m_Width / 2) + 1;
d = ( track->m_Width / 2 ) + 1;
cx = MIN( track->m_Start.x, track->m_End.x );
cy = MIN( track->m_Start.y, track->m_End.y );
xmin = MIN( xmin, cx - d );
@ -609,7 +642,7 @@ bool BOARD::ComputeBoundaryBox()
for( TRACK* track = m_Zone; track; track = track->Next() )
{
d = (track->m_Width / 2) + 1;
d = ( track->m_Width / 2 ) + 1;
cx = MIN( track->m_Start.x, track->m_End.x );
cy = MIN( track->m_Start.y, track->m_End.y );
xmin = MIN( xmin, cx - d );
@ -648,11 +681,11 @@ bool BOARD::ComputeBoundaryBox()
// virtual, see pcbstruct.h
/* Display board statistics: pads, nets, connections.. count
*/
void BOARD::DisplayInfo( WinEDA_DrawFrame* frame )
{
/* Display board statistics: pads, nets, connections.. count
*/
wxString txt;
frame->ClearMsgPanel();
@ -688,7 +721,7 @@ void BOARD::DisplayInfo( WinEDA_DrawFrame* frame )
frame->AppendMsgPanel( _( "Connect" ), txt, DARKGREEN );
txt.Printf( wxT( "%d" ), GetNoconnectCount() );
frame->AppendMsgPanel( _( "NoConn" ), txt, BLUE );
frame->AppendMsgPanel( _( "Unconnected" ), txt, BLUE );
}
}
@ -779,19 +812,23 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
;
break;
#if 0 // both these are on same list, so we must scan it twice in order to get VIA priority,
// using new #else code below.
// But we are not using separte lists for TRACKs and SEGVIAs, because items are ordered (sortered) in the linked
#if 0 // both these are on same list, so we must scan it twice in order
// to get VIA priority, using new #else code below.
// But we are not using separate lists for TRACKs and SEGVIAs, because
// items are ordered (sorted) in the linked
// list by netcode AND by physical distance:
// when created, if a track or via is connected to an existing track or via, it is put in linked list
// after this existing track or via
// when created, if a track or via is connected to an existing track or
// via, it is put in linked list after this existing track or via
// So usually, connected tracks or vias are grouped in this list
// So the algorithm (used in rastnest computations) which computes the track connectivity is faster (more than 100 time regarding to
// a non ordered list) because when it searchs for a connexion, first it tests the near (near in term of linked list) 50 items
// So the algorithm (used in rastnest computations) which computes the
// track connectivity is faster (more than 100 time regarding to
// a non ordered list) because when it searches for a connexion, first
// it tests the near (near in term of linked list) 50 items
// from the current item (track or via) in test.
// Usually, because of this sort, a connected item (if exists) is found.
// If not found (and only in this case) an exhaustive (and time consumming) search is made,
// but this case is statistically rare.
// Usually, because of this sort, a connected item (if exists) is
// found.
// If not found (and only in this case) an exhaustive (and time
// consuming) search is made, but this case is statistically rare.
case TYPE_VIA:
case TYPE_TRACK:
result = IterateForward( m_Track, inspector, testData, p );
@ -844,7 +881,9 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
// TYPE_ZONE_CONTAINER are in the m_ZoneDescriptorList std::vector
for( unsigned i = 0; i< m_ZoneDescriptorList.size(); ++i )
{
result = m_ZoneDescriptorList[i]->Visit( inspector, testData, p );
result = m_ZoneDescriptorList[i]->Visit( inspector,
testData,
p );
if( result == SEARCH_QUIT )
break;
}
@ -886,7 +925,8 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
* found(0), layer(alayer), layer_mask( g_TabOneLayerMask[alayer] )
* {}
*
* SEARCH_RESULT Inspect( EDA_BaseStruct* testItem, const void* testData )
* SEARCH_RESULT Inspect( EDA_BaseStruct* testItem, const void* testData
* )
* {
* BOARD_ITEM* item = (BOARD_ITEM*) testItem;
* const wxPoint& refPos = *(const wxPoint*) testData;
@ -967,8 +1007,8 @@ NETINFO_ITEM* BOARD::FindNet( int anetcode ) const
{
if( anetcode != net->GetNet() )
{
printf("FindNet() anetcode %d != GetNet() %d (net: %s)\n",
anetcode, net->GetNet(), CONV_TO_UTF8(net->GetNetname()));
printf( "FindNet() anetcode %d != GetNet() %d (net: %s)\n",
anetcode, net->GetNet(), CONV_TO_UTF8( net->GetNetname() ) );
}
}
#endif
@ -978,7 +1018,7 @@ NETINFO_ITEM* BOARD::FindNet( int anetcode ) const
/**
* Function FindNet overlayed
* Function FindNet overlaid
* searches for a net with the given name.
* @param aNetname A Netname to search for.
* @return NETINFO_ITEM* - the net or NULL if not found.
@ -995,7 +1035,7 @@ NETINFO_ITEM* BOARD::FindNet( const wxString& aNetname ) const
// Search for a netname = aNetname
#if 0
// Use a sequencial search: easy to understand, but slow
// Use a sequential search: easy to understand, but slow
for( int ii = 1; ii < ncount; ii++ )
{
NETINFO_ITEM* item = m_NetInfo->GetNetItem( ii );
@ -1009,7 +1049,8 @@ NETINFO_ITEM* BOARD::FindNet( const wxString& aNetname ) const
// Use a fast binary search,
// this is possible because Nets are alphabetically ordered in list
// see NETINFO_LIST::BuildListOfNets() and NETINFO_LIST::Build_Pads_Full_List()
// see NETINFO_LIST::BuildListOfNets() and
// NETINFO_LIST::Build_Pads_Full_List()
int imax = ncount - 1;
int index = imax;
while( ncount > 0 )
@ -1093,10 +1134,12 @@ static bool s_SortByNodes( const NETINFO_ITEM* a, const NETINFO_ITEM* b )
/**
* Function ReturnSortedNetnamesList
* @param aNames An array string to fill with net names.
* @param aSortbyPadsCount : true = sort by active pads count, false = no sort (i.e. leave the sort by net names)
* @param aSortbyPadsCount : true = sort by active pads count, false = no sort
* (i.e. leave the sort by net names)
* @return int - net names count.
*/
int BOARD::ReturnSortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCount )
int BOARD::ReturnSortedNetnamesList( wxArrayString& aNames,
bool aSortbyPadsCount )
{
if( m_NetInfo->GetCount() == 0 )
return 0;
@ -1123,9 +1166,7 @@ int BOARD::ReturnSortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCoun
}
/************************************/
bool BOARD::Save( FILE* aFile ) const
/************************************/
{
bool rc = false;
BOARD_ITEM* item;
@ -1159,7 +1200,8 @@ bool BOARD::Save( FILE* aFile ) const
// future: throw exception here
#if defined(DEBUG)
printf( "BOARD::Save() ignoring m_Drawings type %d\n", item->Type() );
printf( "BOARD::Save() ignoring m_Drawings type %d\n",
item->Type() );
#endif
break;
}
@ -1201,14 +1243,14 @@ out:
}
/***********************************************************************************************/
void BOARD::RedrawAreasOutlines( WinEDA_DrawPanel* panel, wxDC* aDC, int aDrawMode, int aLayer )
/***********************************************************************************************/
/**
* Function RedrawAreasOutlines
* Redraw all areas outlines on layer aLayer ( redraw all if aLayer < 0 )
*/
void BOARD::RedrawAreasOutlines( WinEDA_DrawPanel* panel,
wxDC* aDC,
int aDrawMode,
int aLayer )
{
if( !aDC )
return;
@ -1222,14 +1264,14 @@ void BOARD::RedrawAreasOutlines( WinEDA_DrawPanel* panel, wxDC* aDC, int aDrawMo
}
/***********************************************************************************************/
void BOARD::RedrawFilledAreas( WinEDA_DrawPanel* panel, wxDC* aDC, int aDrawMode, int aLayer )
/***********************************************************************************************/
/**
* Function RedrawFilledAreas
* Redraw all areas outlines on layer aLayer ( redraw all if aLayer < 0 )
*/
void BOARD::RedrawFilledAreas( WinEDA_DrawPanel* panel,
wxDC* aDC,
int aDrawMode,
int aLayer )
{
if( !aDC )
return;
@ -1245,13 +1287,15 @@ void BOARD::RedrawFilledAreas( WinEDA_DrawPanel* panel, wxDC* aDC, int aDrawMode
/**
* Function HitTestForAnyFilledArea
* tests if the given wxPoint is within the bounds of a filled area of this zone.
* tests if the given wxPoint is within the bounds of a filled area of this
* zone.
* the test is made on zones on layer from aStartLayer to aEndLayer
* Note: if a zone has its flag BUSY (in .m_State) is set, it is ignored.
* @param refPos A wxPoint to test
* @param aStartLayer the first layer to test
* @param aEndLayer the last layer (-1 to ignore it) to test
* @return ZONE_CONTAINER* return a pointer to the ZONE_CONTAINER found, else NULL
* @return ZONE_CONTAINER* return a pointer to the ZONE_CONTAINER found, else
* NULL
*/
ZONE_CONTAINER* BOARD::HitTestForAnyFilledArea( const wxPoint& aRefPos,
int aStartLayer,
@ -1268,7 +1312,8 @@ ZONE_CONTAINER* BOARD::HitTestForAnyFilledArea( const wxPoint& aRefPos,
int layer = area->GetLayer();
if( (layer < aStartLayer) || (layer > aEndLayer) )
continue;
if( area->GetState( BUSY ) ) // In locate functions we must skip tagged items with BUSY flag set.
if( area->GetState( BUSY ) ) // In locate functions we must skip
// tagged items with BUSY flag set.
continue;
if( area->HitTestFilledArea( aRefPos ) )
return area;
@ -1280,9 +1325,12 @@ ZONE_CONTAINER* BOARD::HitTestForAnyFilledArea( const wxPoint& aRefPos,
/**
* Function SetAreasNetCodesFromNetNames
* Set the .m_NetCode member of all copper areas, according to the area Net Name
* The SetNetCodesFromNetNames is an equivalent to net name, for fast comparisons.
* However the Netcode is an arbitrary equivalence, it must be set after each netlist read
* Set the .m_NetCode member of all copper areas, according to the area Net
* Name
* The SetNetCodesFromNetNames is an equivalent to net name, for fast
* comparisons.
* However the Netcode is an arbitrary equivalence, it must be set after each
* netlist read
* or net change
* Must be called after pad netcodes are calculated
* @return : error count
@ -1300,7 +1348,8 @@ int BOARD::SetAreasNetCodesFromNetNames( void )
continue;
}
if( GetArea( ii )->GetNet() != 0 ) // i.e. if this zone is connected to a net
if( GetArea( ii )->GetNet() != 0 ) // i.e. if this zone is
// connected to a net
{
const NETINFO_ITEM* net = FindNet( GetArea( ii )->m_Netname );
if( net )
@ -1310,7 +1359,8 @@ int BOARD::SetAreasNetCodesFromNetNames( void )
else
{
error_count++;
GetArea( ii )->SetNet( -1 ); //keep Net Name ane set m_NetCode to -1 : error flag
GetArea( ii )->SetNet( -1 ); // keep Net Name and set
// m_NetCode to -1 : error flag
}
}
}
@ -1333,7 +1383,8 @@ void BOARD::Show( int nestLevel, std::ostream& os )
BOARD_ITEM* p;
// for now, make it look like XML:
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << ">\n";
NestedSpace( nestLevel,
os ) << '<' << GetClass().Lower().mb_str() << ">\n";
// specialization of the output:
NestedSpace( nestLevel + 1, os ) << "<modules>\n";
@ -1366,7 +1417,8 @@ void BOARD::Show( int nestLevel, std::ostream& os )
/*
* NestedSpace( nestLevel+1, os ) << "<zone_container>\n";
* for( ZONE_CONTAINERS::iterator i=m_ZoneDescriptorList.begin(); i!=m_ZoneDescriptorList.end(); ++i )
* for( ZONE_CONTAINERS::iterator i=m_ZoneDescriptorList.begin();
* i!=m_ZoneDescriptorList.end(); ++i )
* (*i)->Show( nestLevel+2, os );
* NestedSpace( nestLevel+1, os ) << "</zone_container>\n";
*/
@ -1377,7 +1429,8 @@ void BOARD::Show( int nestLevel, std::ostream& os )
p->Show( nestLevel + 1, os );
}
NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str()
<< ">\n";
}

View File

@ -106,12 +106,12 @@ private:
LAYER m_Layer[NB_COPPER_LAYERS];
public:
WinEDA_BasePcbFrame* m_PcbFrame; // Window de visualisation
WinEDA_BasePcbFrame* m_PcbFrame; // Window of visualization
EDA_Rect m_BoundaryBox; // Board size and position
int m_Status_Pcb; // Flags used in ratsnet calculation and update
EDA_BoardDesignSettings* m_BoardSettings; // Link to current design settings
int m_NbNodes; // Active pads (pads attached to a net ) count
int m_NbNoconnect; // Active ratsnet count (rastnests not alraedy connected by tracks)
int m_NbNoconnect; // Active ratsnet count (rastnests not already connected by tracks)
DLIST<BOARD_ITEM> m_Drawings; // linked list of lines & texts
DLIST<MODULE> m_Modules; // linked list of MODULEs
@ -327,7 +327,7 @@ public:
/* Functions to get some items count */
int GetNumSegmTrack();
int GetNumSegmZone();
unsigned GetNoconnectCount(); // retourne le nombre de connexions manquantes
unsigned GetNoconnectCount(); // Return the number of missing links.
/**
* Function GetNumRatsnests
@ -353,7 +353,6 @@ public:
}
// Calcul du rectangle d'encadrement:
bool ComputeBoundaryBox();
@ -448,8 +447,8 @@ public:
/**
* Function SetCurrentNetClass
* Must be called after a netclass selection (or after a netclass parameter change
* Initialise vias and tracks values displayed in comb boxs of the auxiliary toolbar
* and some others parametres (netclass name ....)
* Initialise vias and tracks values displayed in comb boxes of the auxiliary toolbar
* and some others parameters (netclass name ....)
* @param aNetClassName = the new netclass name
* @return true if lists of tracks and vias sizes are modified
*/
@ -461,7 +460,7 @@ public:
int GetBiggestClearanceValue();
/** function GetCurrentTrackWidth
* @return the current track width, accordint to the selected options
* @return the current track width, according to the selected options
* ( using the default netclass value or a preset value )
* the default netclass is always in m_TrackWidthList[0]
*/
@ -471,7 +470,7 @@ public:
}
/** function GetCurrentViaSize
* @return the current via size, accordint to the selected options
* @return the current via size, according to the selected options
* ( using the default netclass value or a preset value )
* the default netclass is always in m_TrackWidthList[0]
*/
@ -481,7 +480,7 @@ public:
}
/** function GetCurrentViaDrill
* @return the current via size, accordint to the selected options
* @return the current via size, according to the selected options
* ( using the default netclass value or a preset value )
* the default netclass is always in m_TrackWidthList[0]
*/
@ -577,8 +576,8 @@ public:
/**
* Function SetAreasNetCodesFromNetNames
* Set the .m_NetCode member of all copper areas, according to the area Net Name
* The SetNetCodesFromNetNames is an equivalent to net name, for fas comparisons.
* However the Netcode is an arbitrary equyivalence, it must be set after each netlist read
* The SetNetCodesFromNetNames is an equivalent to net name, for fast comparisons.
* However the Netcode is an arbitrary equivalence, it must be set after each netlist read
* or net change
* Must be called after pad netcodes are calculated
* @return : error count
@ -761,7 +760,7 @@ public:
* If possible, combine 2 copper areas
* @param aDeletedList = a PICKED_ITEMS_LIST * where to store deleted areas (useful in undo commands
* can be NULL
* @param area_ref = tje main area (zone)
* @param area_ref = the main area (zone)
* @param area_to_combine = the zone that can be merged with area_ref
* area_ref must be BEFORE area_to_combine
* area_to_combine will be deleted, if areas are combined
@ -778,7 +777,7 @@ public:
* Test Areas outlines for DRC:
* Test areas inside other areas
* Test areas too close
* @param aArea_To_Examine: area to compare with other areas. if NULL: all areas are compared tp all others
* @param aArea_To_Examine: area to compare with other areas. if NULL: all areas are compared to all others
* @param aCreate_Markers: if true create DRC markers. False: do not creates anything
* @return errors count
*/
@ -790,7 +789,7 @@ public:
/**
* Function Test_Connection_To_Copper_Areas
* init .m_ZoneSubnet parameter in tracks and pads according to the connections to areas found
* @param aNetcode = netcode to analyse. if -1, analyse all nets
* @param aNetcode = netcode to analyze. if -1, analyze all nets
*/
void Test_Connections_To_Copper_Areas( int aNetcode = -1 );

View File

@ -1,6 +1,6 @@
/************************************/
/* fonctions de la classe COTATION */
/************************************/
/*****************************/
/* COTATION class definition */
/*****************************/
#include "fctsys.h"
#include "gr_basic.h"
@ -25,7 +25,6 @@ COTATION::COTATION( BOARD_ITEM* aParent ) :
}
/* Effacement memoire de la structure */
COTATION::~COTATION()
{
delete m_Text;
@ -39,11 +38,9 @@ void COTATION:: SetText( const wxString& NewText )
}
/**********************************/
wxString COTATION::GetText( void )
/**********************************/
/* Reutun the dimension text
/* Return the dimension text
*/
wxString COTATION::GetText( void )
{
return m_Text->m_Text;
}
@ -59,9 +56,8 @@ void COTATION::SetLayer( int aLayer )
m_Text->SetLayer( aLayer);
}
/*************************************/
void COTATION::Copy( COTATION* source )
/*************************************/
{
m_Value = source->m_Value;
SetLayer( source->GetLayer() );
@ -72,26 +68,38 @@ void COTATION::Copy( COTATION* source )
m_TimeStamp = GetTimeStamp();
m_Text->Copy( source->m_Text );
Barre_ox = source->Barre_ox; Barre_oy = source->Barre_oy;
Barre_fx = source->Barre_fx; Barre_fy = source->Barre_fy;
TraitG_ox = source->TraitG_ox; TraitG_oy = source->TraitG_oy;
TraitG_fx = source->TraitG_fx; TraitG_fy = source->TraitG_fy;
TraitD_ox = source->TraitD_ox; TraitD_oy = source->TraitD_oy;
TraitD_fx = source->TraitD_fx; TraitD_fy = source->TraitD_fy;
FlecheD1_ox = source->FlecheD1_ox; FlecheD1_oy = source->FlecheD1_oy;
FlecheD1_fx = source->FlecheD1_fx; FlecheD1_fy = source->FlecheD1_fy;
FlecheD2_ox = source->FlecheD2_ox; FlecheD2_oy = source->FlecheD2_oy;
FlecheD2_fx = source->FlecheD2_fx; FlecheD2_fy = source->FlecheD2_fy;
FlecheG1_ox = source->FlecheG1_ox; FlecheG1_oy = source->FlecheG1_oy;
FlecheG1_fx = source->FlecheG1_fx; FlecheG1_fy = source->FlecheG1_fy;
FlecheG2_ox = source->FlecheG2_ox; FlecheG2_oy = source->FlecheG2_oy;
FlecheG2_fx = source->FlecheG2_fx; FlecheG2_fy = source->FlecheG2_fy;
Barre_ox = source->Barre_ox;
Barre_oy = source->Barre_oy;
Barre_fx = source->Barre_fx;
Barre_fy = source->Barre_fy;
TraitG_ox = source->TraitG_ox;
TraitG_oy = source->TraitG_oy;
TraitG_fx = source->TraitG_fx;
TraitG_fy = source->TraitG_fy;
TraitD_ox = source->TraitD_ox;
TraitD_oy = source->TraitD_oy;
TraitD_fx = source->TraitD_fx;
TraitD_fy = source->TraitD_fy;
FlecheD1_ox = source->FlecheD1_ox;
FlecheD1_oy = source->FlecheD1_oy;
FlecheD1_fx = source->FlecheD1_fx;
FlecheD1_fy = source->FlecheD1_fy;
FlecheD2_ox = source->FlecheD2_ox;
FlecheD2_oy = source->FlecheD2_oy;
FlecheD2_fx = source->FlecheD2_fx;
FlecheD2_fy = source->FlecheD2_fy;
FlecheG1_ox = source->FlecheG1_ox;
FlecheG1_oy = source->FlecheG1_oy;
FlecheG1_fx = source->FlecheG1_fx;
FlecheG1_fy = source->FlecheG1_fy;
FlecheG2_ox = source->FlecheG2_ox;
FlecheG2_oy = source->FlecheG2_oy;
FlecheG2_fx = source->FlecheG2_fx;
FlecheG2_fy = source->FlecheG2_fy;
}
/***************************************************************/
bool COTATION::ReadCotationDescr( FILE* File, int* LineNum )
/***************************************************************/
{
char Line[2048], Text[2048];
@ -112,7 +120,6 @@ bool COTATION::ReadCotationDescr( FILE* File, int* LineNum )
sscanf( Line + 2, " %d %d %lX", &m_Shape, &layer, &m_TimeStamp );
/* Mise a jour des param .layer des sous structures */
if( layer < FIRST_NO_COPPER_LAYER )
layer = FIRST_NO_COPPER_LAYER;
if( layer > LAST_NO_COPPER_LAYER )
@ -214,41 +221,52 @@ bool COTATION::ReadCotationDescr( FILE* File, int* LineNum )
return FALSE;
}
/****************************************/
void COTATION::Move(const wxPoint& offset)
/****************************************/
/**
* Function Move
* @param offset : moving vector
*/
void COTATION::Move(const wxPoint& offset)
{
m_Pos += offset;
m_Text->m_Pos += offset;
Barre_ox += offset.x; Barre_oy += offset.y;
Barre_fx += offset.x; Barre_fy += offset.y;
TraitG_ox += offset.x; TraitG_oy += offset.y;
TraitG_fx += offset.x; TraitG_fy += offset.y;
TraitD_ox += offset.x; TraitD_oy += offset.y;
TraitD_fx += offset.x; TraitD_fy += offset.y;
FlecheG1_ox += offset.x; FlecheG1_oy += offset.y;
FlecheG1_fx += offset.x; FlecheG1_fy += offset.y;
FlecheG2_ox += offset.x; FlecheG2_oy += offset.y;
FlecheG2_fx += offset.x; FlecheG2_fy += offset.y;
FlecheD1_ox += offset.x; FlecheD1_oy += offset.y;
FlecheD1_fx += offset.x; FlecheD1_fy += offset.y;
FlecheD2_ox += offset.x; FlecheD2_oy += offset.y;
FlecheD2_fx += offset.x; FlecheD2_fy += offset.y;
Barre_ox += offset.x;
Barre_oy += offset.y;
Barre_fx += offset.x;
Barre_fy += offset.y;
TraitG_ox += offset.x;
TraitG_oy += offset.y;
TraitG_fx += offset.x;
TraitG_fy += offset.y;
TraitD_ox += offset.x;
TraitD_oy += offset.y;
TraitD_fx += offset.x;
TraitD_fy += offset.y;
FlecheG1_ox += offset.x;
FlecheG1_oy += offset.y;
FlecheG1_fx += offset.x;
FlecheG1_fy += offset.y;
FlecheG2_ox += offset.x;
FlecheG2_oy += offset.y;
FlecheG2_fx += offset.x;
FlecheG2_fy += offset.y;
FlecheD1_ox += offset.x;
FlecheD1_oy += offset.y;
FlecheD1_fx += offset.x;
FlecheD1_fy += offset.y;
FlecheD2_ox += offset.x;
FlecheD2_oy += offset.y;
FlecheD2_fx += offset.x;
FlecheD2_fy += offset.y;
}
/******************************************************/
void COTATION::Rotate(const wxPoint& centre, int angle)
/******************************************************/
/**
* Function Rotate
* @param centre : Rotation point
* @param center : Rotation point
* @param angle : Rotation angle in 0.1 degrees
*/
void COTATION::Rotate(const wxPoint& centre, int angle)
{
RotatePoint( &m_Pos, centre, angle );
@ -256,8 +274,7 @@ void COTATION::Rotate(const wxPoint& centre, int angle)
m_Text->m_Orient += angle;
if( m_Text->m_Orient >= 3600 )
m_Text->m_Orient -= 3600;
if( (m_Text->m_Orient > 900)
&& (m_Text->m_Orient <2700) )
if( ( m_Text->m_Orient > 900 ) && ( m_Text->m_Orient <2700 ) )
m_Text->m_Orient -= 1800;
RotatePoint( &Barre_ox, &Barre_oy, centre.x, centre.y, angle );
@ -276,6 +293,7 @@ void COTATION::Rotate(const wxPoint& centre, int angle)
RotatePoint( &FlecheD2_fx, &FlecheD2_fy, centre.x, centre.y, angle );
}
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
@ -287,9 +305,7 @@ void COTATION::Flip(const wxPoint& aCentre )
SetLayer( ChangeSideNumLayer( GetLayer() ) );
}
/**********************************************/
void COTATION::Mirror(const wxPoint& axis_pos)
/**********************************************/
/**
* Function Mirror
* Mirror the Dimension , relative to a given horizontal axis
@ -297,6 +313,7 @@ void COTATION::Mirror(const wxPoint& axis_pos)
* the layer is not changed
* @param axis_pos : vertical axis position
*/
void COTATION::Mirror(const wxPoint& axis_pos)
{
#define INVERT( pos ) (pos) = axis_pos.y - ( (pos) - axis_pos.y )
#define INVERT_ANGLE( phi ) (phi) = -(phi)
@ -305,7 +322,7 @@ void COTATION::Mirror(const wxPoint& axis_pos)
INVERT_ANGLE( m_Text->m_Orient );
if( m_Text->m_Orient >= 3600 )
m_Text->m_Orient -= 3600;
if( (m_Text->m_Orient > 900) && (m_Text->m_Orient <2700) )
if( ( m_Text->m_Orient > 900 ) && ( m_Text->m_Orient < 2700 ) )
m_Text->m_Orient -= 1800;
INVERT( Barre_oy );
@ -324,9 +341,8 @@ void COTATION::Mirror(const wxPoint& axis_pos)
INVERT( FlecheD2_fy );
}
/****************************************/
bool COTATION::Save( FILE* aFile ) const
/****************************************/
{
if( GetState( DELETED ) )
return true;
@ -392,13 +408,10 @@ out:
/************************************************************************/
/* Print 1 dimension: series of n + 1 segments text
*/
void COTATION::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
int mode_color, const wxPoint& offset )
/************************************************************************/
/* impression de 1 cotation : serie de n segments + 1 texte
*/
{
int ox, oy, typeaff, width, gcolor;
@ -504,11 +517,11 @@ bool COTATION::HitTest( const wxPoint& ref_pos )
if( m_Text && m_Text->TextHitTest( ref_pos ) )
return true;
/* Localisation des SEGMENTS ?) */
/* Locate SEGMENTS? */
ux0 = Barre_ox;
uy0 = Barre_oy;
/* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
/* Recalculate coordinates with ux0, uy0 = origin. */
dx = Barre_fx - ux0;
dy = Barre_fy - uy0;
@ -521,49 +534,42 @@ bool COTATION::HitTest( const wxPoint& ref_pos )
ux0 = TraitG_ox;
uy0 = TraitG_oy;
/* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
dx = TraitG_fx - ux0;
dy = TraitG_fy - uy0;
spot_cX = ref_pos.x - ux0;
spot_cY = ref_pos.y - uy0;
/* detection : */
if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) )
return true;
ux0 = TraitD_ox;
uy0 = TraitD_oy;
/* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
dx = TraitD_fx - ux0;
dy = TraitD_fy - uy0;
spot_cX = ref_pos.x - ux0;
spot_cY = ref_pos.y - uy0;
/* detection : */
if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) )
return true;
ux0 = FlecheD1_ox;
uy0 = FlecheD1_oy;
/* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
dx = FlecheD1_fx - ux0;
dy = FlecheD1_fy - uy0;
spot_cX = ref_pos.x - ux0;
spot_cY = ref_pos.y - uy0;
/* detection : */
if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) )
return true;
ux0 = FlecheD2_ox;
uy0 = FlecheD2_oy;
/* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
dx = FlecheD2_fx - ux0;
dy = FlecheD2_fy - uy0;
@ -576,7 +582,6 @@ bool COTATION::HitTest( const wxPoint& ref_pos )
ux0 = FlecheG1_ox;
uy0 = FlecheG1_oy;
/* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
dx = FlecheG1_fx - ux0;
dy = FlecheG1_fy - uy0;
@ -589,7 +594,6 @@ bool COTATION::HitTest( const wxPoint& ref_pos )
ux0 = FlecheG2_ox;
uy0 = FlecheG2_oy;
/* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
dx = FlecheG2_fx - ux0;
dy = FlecheG2_fy - uy0;
@ -602,8 +606,9 @@ bool COTATION::HitTest( const wxPoint& ref_pos )
return false;
}
/**
* Function HitTest (overlayed)
* Function HitTest (overlaid)
* tests if the given EDA_Rect intersect this object.
* @param EDA_Rect : the given EDA_Rect
* @return bool - true if a hit, else false

View File

@ -1,6 +1,6 @@
/************************************/
/* fonctions de la classe COTATION */
/************************************/
/*****************************/
/* COTATION class definition */
/*****************************/
#ifndef COTATION_H
#define COTATION_H
@ -13,9 +13,9 @@ public:
wxPoint m_Pos;
int m_Shape;
int m_Unit; /* 0 = inches, 1 = mm */
int m_Value; /* valeur en unites PCB de la cote */
int m_Value; /* value of PCB dimensions. */
TEXTE_PCB* m_Text; /* pour affichage du texte */
TEXTE_PCB* m_Text;
int Barre_ox, Barre_oy, Barre_fx, Barre_fy;
int TraitG_ox, TraitG_oy, TraitG_fx, TraitG_fy;
int TraitD_ox, TraitD_oy, TraitD_fx, TraitD_fy;
@ -54,7 +54,6 @@ public:
*/
bool Save( FILE* aFile ) const;
/* Modification du texte de la cotation */
void SetText( const wxString& NewText );
wxString GetText( void );
@ -111,7 +110,7 @@ public:
bool HitTest( const wxPoint& ref_pos );
/**
* Function HitTest (overlayed)
* Function HitTest (overlaid)
* tests if the given EDA_Rect intersect this object.
* For now, the anchor must be inside this rect.
* @param refArea : the given EDA_Rect

View File

@ -241,13 +241,11 @@ void DRAWSEGMENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
color = g_DesignSettings.m_LayerColor[GetLayer()];
GRSetDrawMode( DC, draw_mode );
l_piste = m_Width >> 1; /* l_piste = demi largeur piste */
l_piste = m_Width >> 1; /* half trace width */
/* coord de depart */
ux0 = m_Start.x;
uy0 = m_Start.y;
/* coord d'arrivee */
dx = m_End.x;
dy = m_End.y;
@ -287,7 +285,7 @@ void DRAWSEGMENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
if( StAngle > EndAngle )
EXCHG( StAngle, EndAngle );
}
else //Mirrored mode: arc orientation is reversed
else // Mirrored mode: arc orientation is reversed
{
if( StAngle < EndAngle )
EXCHG( StAngle, EndAngle );
@ -318,7 +316,8 @@ void DRAWSEGMENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
if( mode == FILAIRE )
GRLine( &panel->m_ClipBox, DC,
m_BezierPoints[i].x, m_BezierPoints[i].y,
m_BezierPoints[i-1].x, m_BezierPoints[i-1].y, 0, color );
m_BezierPoints[i-1].x, m_BezierPoints[i-1].y, 0,
color );
else if( mode == SKETCH )
{
GRCSegm( &panel->m_ClipBox, DC,
@ -418,7 +417,7 @@ bool DRAWSEGMENT::HitTest( const wxPoint& ref_pos )
int ux0 = m_Start.x;
int uy0 = m_Start.y;
/* recalcul des coordonnees avec ux0, uy0 = origine des coordonnees */
/* Calculate coordinates with ux0, uy0 = origin. */
int dx = m_End.x - ux0;
int dy = m_End.y - uy0;
@ -439,7 +438,6 @@ bool DRAWSEGMENT::HitTest( const wxPoint& ref_pos )
if( m_Shape == S_CIRCLE )
return true;
/* pour un arc, controle complementaire */
mouseAngle = (int) ArcTangente( spot_cY, spot_cX );
stAngle = (int) ArcTangente( dy, dx );
endAngle = stAngle + m_Angle;
@ -458,7 +456,8 @@ bool DRAWSEGMENT::HitTest( const wxPoint& ref_pos )
case S_CURVE:
for( unsigned int i= 1; i < m_BezierPoints.size(); i++)
{
if( TestSegmentHit( ref_pos,m_BezierPoints[i-1],m_BezierPoints[i-1], m_Width / 2 ) )
if( TestSegmentHit( ref_pos,m_BezierPoints[i-1],
m_BezierPoints[i-1], m_Width / 2 ) )
return true;
}
break;

View File

@ -1,5 +1,5 @@
/****************************************************/
/* class_module.cpp : fonctions de la classe MODULE */
/* class_module.cpp : EDGE_MODULE class definition. */
/****************************************************/
#include "fctsys.h"
@ -14,11 +14,12 @@
#include "pcbnew.h"
#include "class_board_design_settings.h"
#define MAX_WIDTH 10000 // Epaisseur (en 1/10000 ") max raisonnable des traits, textes...
#define MAX_WIDTH 10000 /* Thickness (in 1 / 10000 ") of maximum reasonable
* features, text... */
/******************************************/
/* class EDGE_MODULE ( contour de module ) */
/******************************************/
/*********************/
/* class EDGE_MODULE */
/*********************/
EDGE_MODULE::EDGE_MODULE( MODULE* parent ) :
BOARD_ITEM( parent, TYPE_EDGE_MODULE )
@ -35,10 +36,7 @@ EDGE_MODULE::~EDGE_MODULE()
}
/********************************************/
void EDGE_MODULE::Copy( EDGE_MODULE* source )
/********************************************/
// copy structure
{
if( source == NULL )
return;
@ -46,18 +44,17 @@ void EDGE_MODULE::Copy( EDGE_MODULE* source )
m_Start = source->m_Start;
m_End = source->m_End;
m_Shape = source->m_Shape;
m_Start0 = source->m_Start0; // coord relatives a l'ancre du point de depart(Orient 0)
m_End0 = source->m_End0; // coord relatives a l'ancre du point de fin (Orient 0)
m_Angle = source->m_Angle; // pour les arcs de cercle: longueur de l'arc en 0,1 degres
m_Start0 = source->m_Start0;
m_End0 = source->m_End0;
m_Angle = source->m_Angle;
m_Layer = source->m_Layer;
m_Width = source->m_Width;
m_PolyPoints = source->m_PolyPoints; // std::vector copy
}
/***********************************/
void EDGE_MODULE::SetDrawCoord()
/***********************************/
{
MODULE* Module = (MODULE*) m_Parent;
@ -74,19 +71,16 @@ void EDGE_MODULE::SetDrawCoord()
}
/********************************************************************************/
void EDGE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
int draw_mode, const wxPoint& offset )
/********************************************************************************/
/* Affichage d'un segment contour de module :
* Entree : ox, oy = offset de trace
* draw_mode = mode de trace ( GR_OR, GR_XOR, GR_AND)
* Les contours sont de differents type:
/* Draw EDGE_MODULE:
* Entry: offset = offset trace
* Draw_mode mode = trace (GR_OR, GR_XOR, GR_AND)
* The contours are of different types:
* - Segment
* - Cercles
* - Circles
* - Arcs
*/
void EDGE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
int draw_mode, const wxPoint& offset )
{
int ux0, uy0, dx, dy, rayon, StAngle, EndAngle;
int color, type_trace;
@ -95,7 +89,7 @@ void EDGE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
WinEDA_BasePcbFrame* frame;
MODULE* Module = NULL;
if( m_Parent && (m_Parent->Type() == TYPE_MODULE) )
if( m_Parent && ( m_Parent->Type() == TYPE_MODULE ) )
Module = (MODULE*) m_Parent;
if( g_DesignSettings.IsLayerVisible( m_Layer ) == false )
@ -231,15 +225,18 @@ void EDGE_MODULE::DisplayInfo( WinEDA_DrawFrame* frame )
frame->AppendMsgPanel( _( "Graphic Item" ), wxEmptyString, DARKCYAN );
frame->AppendMsgPanel( _( "Module" ), module->m_Reference->m_Text, DARKCYAN );
frame->AppendMsgPanel( _( "Module" ), module->m_Reference->m_Text,
DARKCYAN );
frame->AppendMsgPanel( _( "Value" ), module->m_Value->m_Text, BLUE );
msg.Printf( wxT( "%8.8lX" ), module->m_TimeStamp );
frame->AppendMsgPanel( _( "TimeStamp" ), msg, BROWN );
frame->AppendMsgPanel( _( "Mod Layer" ), board->GetLayerName( module->GetLayer() ), RED );
frame->AppendMsgPanel( _( "Mod Layer" ),
board->GetLayerName( module->GetLayer() ), RED );
frame->AppendMsgPanel( _( "Seg Layer" ), board->GetLayerName( GetLayer() ), RED );
frame->AppendMsgPanel( _( "Seg Layer" ),
board->GetLayerName( GetLayer() ), RED );
valeur_param( m_Width, msg );
frame->AppendMsgPanel( _( "Width" ), msg, BLUE );
@ -284,7 +281,8 @@ bool EDGE_MODULE::Save( FILE* aFile ) const
m_Width, m_Layer );
for( unsigned i=0; i<m_PolyPoints.size(); ++i )
fprintf( aFile, "Dl %d %d\n", m_PolyPoints[i].x, m_PolyPoints[i].y );
fprintf( aFile, "Dl %d %d\n", m_PolyPoints[i].x,
m_PolyPoints[i].y );
break;
default:
@ -299,13 +297,6 @@ bool EDGE_MODULE::Save( FILE* aFile ) const
}
/****************************************************************/
int EDGE_MODULE::ReadDescr( char* Line, FILE* File,
int* LineNum )
/***************************************************************/
/* Read a description line like:
* DS 2600 0 2600 -600 120 21
* this description line is in Line
@ -316,6 +307,8 @@ int EDGE_MODULE::ReadDescr( char* Line, FILE* File,
* - Polygon
*
*/
int EDGE_MODULE::ReadDescr( char* Line, FILE* File,
int* LineNum )
{
int ii;
int error = 0;
@ -409,13 +402,13 @@ int EDGE_MODULE::ReadDescr( char* Line, FILE* File,
break;
}
// Check for a reasonnable width:
// Check for a reasonable width:
if( m_Width <= 1 )
m_Width = 1;
if( m_Width > MAX_WIDTH )
m_Width = MAX_WIDTH;
// Check for a reasonnable layer:
// Check for a reasonable layer:
// m_Layer must be >= FIRST_NON_COPPER_LAYER, but because microwave footprints
// can use the copper layers m_Layer < FIRST_NON_COPPER_LAYER is allowed.
// @todo: changes use of EDGE_MODULE these footprints and allows only m_Layer >= FIRST_NON_COPPER_LAYER
@ -447,7 +440,6 @@ bool EDGE_MODULE::HitTest( const wxPoint& ref_pos )
switch( m_Shape )
{
case S_SEGMENT:
/* recalcul des coordonnees avec ux0,uy0 = origine des coord. */
spot_cX = ref_pos.x - ux0;
spot_cY = ref_pos.y - uy0;
@ -459,19 +451,20 @@ bool EDGE_MODULE::HitTest( const wxPoint& ref_pos )
case S_CIRCLE:
rayon = (int) hypot( (double) (uxf - ux0), (double) (uyf - uy0) );
dist = (int) hypot( (double) (ref_pos.x - ux0), (double) (ref_pos.y - uy0) );
dist = (int) hypot( (double) (ref_pos.x - ux0),
(double) (ref_pos.y - uy0) );
if( abs( rayon - dist ) <= m_Width )
return true;
break;
case S_ARC:
rayon = (int) hypot( (double) (uxf - ux0), (double) (uyf - uy0) );
dist = (int) hypot( (double) (ref_pos.x - ux0), (double) (ref_pos.y - uy0) );
dist = (int) hypot( (double) (ref_pos.x - ux0),
(double) (ref_pos.y - uy0) );
if( abs( rayon - dist ) > m_Width )
break;
/* pour un arc, controle complementaire */
int mouseAngle = (int) ArcTangente( ref_pos.y - uy0, ref_pos.x - ux0 );
int stAngle = (int) ArcTangente( uyf - uy0, uxf - ux0 );
int endAngle = stAngle + m_Angle;
@ -494,6 +487,7 @@ bool EDGE_MODULE::HitTest( const wxPoint& ref_pos )
#if defined(DEBUG)
/**
* Function Show
* is used to output the object tree, currently for debugging only.

View File

@ -1,12 +1,10 @@
/**************************************************************/
/* class_edge_module.h : description des contours d'un module */
/**************************************************************/
/*******************************************************/
/* class_edge_module.h : EDGE_MODULE class definition. */
/*******************************************************/
class Pcb3D_GLCanvas;
/* description des contours (empreintes ) et TYPES des CONTOURS : */
class EDGE_MODULE : public BOARD_ITEM
{
public:
@ -14,11 +12,11 @@ public:
wxPoint m_Start; // Line start point
wxPoint m_End; // Line end point
int m_Shape; // voir "enum Track_Shapes"
wxPoint m_Start0; // coord relatives a l'ancre du point de depart(Orient 0)
wxPoint m_End0; // coord relatives a l'ancre du point de fin (Orient 0)
int m_Shape; // enum Track_Shapes
wxPoint m_Start0; // Start point.
wxPoint m_End0; // End point.
int m_Angle; // pour les arcs de cercle: longueur de l'arc en 0,1 degres
int m_Angle; // Arcs: angle in 0.1 degrees
std::vector<wxPoint> m_PolyPoints; // For polygons: number of points (> 2)
// Coord are relative to Origin, orient 0
@ -54,7 +52,6 @@ public:
int ReadDescr( char* Line, FILE* File, int* LineNum = NULL );
// Mise a jour des coordon<6F>s pour l'affichage
void SetDrawCoord();
/* drawing functions */

View File

@ -1,5 +1,5 @@
/****************************************************/
/* fonctions de la classe MIRE (targets for photos) */
/* MIRE class definition (targets for photos) */
/****************************************************/
#include "fctsys.h"
@ -27,9 +27,7 @@ MIREPCB::~MIREPCB()
}
/**********************************/
void MIREPCB::Copy( MIREPCB* source )
/**********************************/
{
m_Layer = source->m_Layer;
m_Width = source->m_Width;
@ -40,19 +38,16 @@ void MIREPCB::Copy( MIREPCB* source )
}
/**************************************************************/
bool MIREPCB::ReadMirePcbDescr( FILE* File, int* LineNum )
/**************************************************************/
/* Lecture de la description de 1 segment type Drawing PCB
/* Read the description from the PCB file.
*/
bool MIREPCB::ReadMirePcbDescr( FILE* File, int* LineNum )
{
char Line[256];
while( GetLine( File, Line, LineNum ) != NULL )
{
if( strnicmp( Line, "$End", 4 ) == 0 )
return TRUE; /* fin de liste */
return TRUE;
if( Line[0] == 'P' )
{
sscanf( Line + 2, " %X %d %d %d %d %d %lX",
@ -69,9 +64,8 @@ bool MIREPCB::ReadMirePcbDescr( FILE* File, int* LineNum )
return FALSE;
}
/**************************************/
bool MIREPCB::Save( FILE* aFile ) const
/**************************************/
{
if( GetState( DELETED ) )
return true;
@ -98,15 +92,12 @@ out:
/**********************************************************/
/* Draw MIREPCB object: 2 segments + 1 circle
* The circle radius is half the radius of the target
* 2 lines have length the diameter of the target
*/
void MIREPCB::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
int mode_color, const wxPoint& offset )
/**********************************************************/
/* Affichage de 1 mire : 2 segments + 1 cercle
* le cercle a pour rayon le demi rayon de la mire
* les 2 traits ont pour longueur le diametre de la mire
*/
{
int rayon, ox, oy, gcolor, width;
int dx1, dx2, dy1, dy2;
@ -126,7 +117,6 @@ void MIREPCB::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
if( panel->GetScreen()->Scale( width ) < 2 )
typeaff = FILAIRE;
/* Trace du cercle: */
rayon = m_Size / 4;
switch( typeaff )
@ -145,15 +135,17 @@ void MIREPCB::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
}
/* Trace des 2 traits */
rayon = m_Size / 2;
dx1 = rayon, dy1 = 0;
dx2 = 0, dy2 = rayon;
dx1 = rayon;
dy1 = 0;
dx2 = 0;
dy2 = rayon;
if( m_Shape ) /* Forme X */
if( m_Shape ) /* Form X */
{
dx1 = dy1 = (rayon * 7) / 5;
dx2 = dx1; dy2 = -dy1;
dx1 = dy1 = ( rayon * 7 ) / 5;
dx2 = dx1;
dy2 = -dy1;
}
switch( typeaff )
@ -189,9 +181,10 @@ bool MIREPCB::HitTest( const wxPoint& refPos )
int dX = refPos.x - m_Pos.x;
int dY = refPos.y - m_Pos.y;
int rayon = m_Size / 2;
return abs(dX)<=rayon && abs(dY)<=rayon;
return abs( dX ) <= rayon && abs( dY ) <= rayon;
}
/**
* Function HitTest (overlayed)
* tests if the given EDA_Rect intersect this object.
@ -205,6 +198,7 @@ bool MIREPCB::HitTest( EDA_Rect& refArea )
return false;
}
/**
* Function Rotate
* Rotate this object.
@ -216,6 +210,7 @@ void MIREPCB::Rotate(const wxPoint& aRotCentre, int aAngle)
RotatePoint( &m_Pos, aRotCentre, aAngle );
}
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
@ -223,7 +218,6 @@ void MIREPCB::Rotate(const wxPoint& aRotCentre, int aAngle)
*/
void MIREPCB::Flip(const wxPoint& aCentre )
{
m_Pos.y = aCentre.y - (m_Pos.y - aCentre.y);
m_Pos.y = aCentre.y - ( m_Pos.y - aCentre.y );
SetLayer( ChangeSideNumLayer( GetLayer() ) );
}

View File

@ -1,5 +1,5 @@
/****************************************************/
/* fonctions de la classe MIRE (targets for photos) */
/* MIREPCB class definition. (targets for photos) */
/****************************************************/
#ifndef MIRE_H
#define MIRE_H
@ -12,7 +12,7 @@ class MIREPCB : public BOARD_ITEM
public:
int m_Width;
wxPoint m_Pos;
int m_Shape; // bit 0 : 0 = forme +, 1 = forme X
int m_Shape; // bit 0 : 0 = draw +, 1 = draw X
int m_Size;
public:
@ -77,7 +77,7 @@ public:
bool HitTest( const wxPoint& refPos );
/**
* Function HitTest (overlayed)
* Function HitTest (overlaid)
* tests if the given EDA_Rect intersect this object.
* For now, the anchor must be inside this rect.
* @param refArea : the given EDA_Rect

View File

@ -1,5 +1,5 @@
/****************************************************/
/* class_module.cpp : fonctions de la classe MODULE */
/* class_module.cpp : MODULE class implementation. */
/****************************************************/
#include "fctsys.h"
@ -23,9 +23,9 @@
#include "protos.h"
/*************************************************/
/* Class MODULE : description d'un composant pcb */
/*************************************************/
/*********************************************/
/* Class MODULE : describes a pcb component. */
/*********************************************/
MODULE::MODULE( BOARD* parent ) :
BOARD_ITEM( parent, TYPE_MODULE )
{
@ -59,14 +59,12 @@ MODULE::~MODULE()
}
/*********************************************************************************/
/* Draw the anchor cross (vertical)
* Must be done after the pads, because drawing the hole will erase overwrite
* every thing already drawn.
*/
void MODULE::DrawAncre( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int dim_ancre, int draw_mode )
/*********************************************************************************/
/* trace de l'ancre (croix verticale)
* (doit etre fait apres les pads,
* car le trace du trou efface tout donc peut etre l'ancre */
{
int anchor_size = panel->GetScreen()->Unscale( dim_ancre );
@ -86,9 +84,7 @@ void MODULE::DrawAncre( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset
}
/*********************************/
void MODULE::Copy( MODULE* aModule )
/*********************************/
{
m_Pos = aModule->m_Pos;
m_Layer = aModule->m_Layer;
@ -106,7 +102,7 @@ void MODULE::Copy( MODULE* aModule )
m_LocalSolderPasteMargin = aModule->m_LocalSolderPasteMargin;
m_LocalSolderPasteMarginRatio = aModule->m_LocalSolderPasteMarginRatio;
/* Copy des structures auxiliaires: Reference et value */
/* Copy reference and value. */
m_Reference->Copy( aModule->m_Reference );
m_Value->Copy( aModule->m_Value );
@ -156,7 +152,9 @@ void MODULE::Copy( MODULE* aModule )
if( item->m_Shape3DName.IsEmpty() ) // do not copy empty shapes.
continue;
S3D_MASTER* t3d = m_3D_Drawings;
if( t3d && t3d->m_Shape3DName.IsEmpty() ) // The first entry can exist, but is empty : use it.
if( t3d && t3d->m_Shape3DName.IsEmpty() ) // The first entry can
// exist, but is empty :
// use it.
t3d->Copy( item );
else
{
@ -166,17 +164,11 @@ void MODULE::Copy( MODULE* aModule )
}
}
/* Copie des elements complementaires */
m_Doc = aModule->m_Doc;
m_KeyWord = aModule->m_KeyWord;
}
/**********************************************************/
void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
int draw_mode, const wxPoint& offset )
/**********************************************************/
/** Function Draw
* Draws the footprint to the current Device Context
* @param panel = The active Draw Panel (used to know the clip box)
@ -184,6 +176,8 @@ void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
* @param offset = draw offset (usually wxPoint(0,0)
* @param draw_mode = GR_OR, GR_XOR, GR_AND
*/
void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
int draw_mode, const wxPoint& offset )
{
if( (m_Flags & DO_NOT_DRAW) )
return;
@ -196,7 +190,7 @@ void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
pad->Draw( panel, DC, draw_mode, offset );
}
// Draws foootprint anchor
// Draws footprint anchor
DrawAncre( panel, DC, offset, DIM_ANCRE_MODULE, draw_mode );
/* Draw graphic items */
@ -225,11 +219,6 @@ void MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
}
/**************************************************************/
void MODULE::DrawEdgesOnly( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int draw_mode )
/**************************************************************/
/** Function DrawEdgesOnly
* Draws the footprint edges only to the current Device Context
* @param panel = The active Draw Panel (used to know the clip box)
@ -237,6 +226,8 @@ void MODULE::DrawEdgesOnly( WinEDA_DrawPanel* panel, wxDC* DC,
* @param offset = draw offset (usually wxPoint(0,0)
* @param draw_mode = GR_OR, GR_XOR, GR_AND
*/
void MODULE::DrawEdgesOnly( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int draw_mode )
{
for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
{
@ -253,9 +244,7 @@ void MODULE::DrawEdgesOnly( WinEDA_DrawPanel* panel, wxDC* DC,
}
/**************************************/
bool MODULE::Save( FILE* aFile ) const
/**************************************/
{
char statusTxt[8];
BOARD_ITEM* item;
@ -267,7 +256,6 @@ bool MODULE::Save( FILE* aFile ) const
fprintf( aFile, "$MODULE %s\n", CONV_TO_UTF8( m_LibRef ) );
// Generation des coord et caracteristiques
memset( statusTxt, 0, sizeof(statusTxt) );
if( IsLocked() )
statusTxt[0] = 'F';
@ -351,7 +339,6 @@ bool MODULE::Save( FILE* aFile ) const
if( !item->Save( aFile ) )
goto out;
// Generation des informations de trac<61>3D
Write_3D_Descr( aFile );
fprintf( aFile, "$EndMODULE %s\n", CONV_TO_UTF8( m_LibRef ) );
@ -362,12 +349,9 @@ out:
}
/***************************************/
int MODULE::Write_3D_Descr( FILE* File ) const
/***************************************/
/* Sauvegarde de la description 3D du MODULE
/* Save the description of 3D MODULE
*/
int MODULE::Write_3D_Descr( FILE* File ) const
{
char buf[512];
@ -405,14 +389,11 @@ int MODULE::Write_3D_Descr( FILE* File ) const
}
/****************************************************/
int MODULE::Read_3D_Descr( FILE* File, int* LineNum )
/****************************************************/
/* Lecture de la description d'un MODULE (format Ascii)
* la 1ere ligne de descr ($MODULE) est supposee etre deja lue
* retourne 0 si OK
/* Read 3D module from file. (Ascii)
* The 1st line of descr ($MODULE) is assumed to be already read
* Returns 0 if OK
*/
int MODULE::Read_3D_Descr( FILE* File, int* LineNum )
{
char Line[1024];
char* text = Line + 3;
@ -432,7 +413,7 @@ int MODULE::Read_3D_Descr( FILE* File, int* LineNum )
{
switch( Line[0] )
{
case '$': // Fin de description
case '$':
if( Line[1] == 'E' )
return 0;
return 1;
@ -475,14 +456,11 @@ int MODULE::Read_3D_Descr( FILE* File, int* LineNum )
}
/**************************************************/
int MODULE::ReadDescr( FILE* File, int* LineNum )
/**************************************************/
/* Read a MODULE description
* The first description line ($MODULE) is already read
* @return 0 if no error
*/
int MODULE::ReadDescr( FILE* File, int* LineNum )
{
char Line[256], BufLine[256], BufCar1[128], * PtLine;
int itmp1, itmp2;
@ -513,7 +491,8 @@ int MODULE::ReadDescr( FILE* File, int* LineNum )
PtLine = Line + 3;
/* Decode the first code of the current line and read the correspondint data
/* Decode the first code of the current line and read the
* corresponding data
*/
switch( Line[0] )
{
@ -570,13 +549,14 @@ int MODULE::ReadDescr( FILE* File, int* LineNum )
}
if( Line[1] == 'R' )
{
//alternate reference, e.g. /478C2408/478AD1B6
// alternate reference, e.g. /478C2408/478AD1B6
sscanf( PtLine, " %s", BufLine );
m_Path = CONV_FROM_UTF8( BufLine );
}
break;
case 'T': /* Read a footprint text description (ref, value, or drawing */
case 'T': /* Read a footprint text description (ref, value, or
* drawing */
TEXTE_MODULE * textm;
sscanf( Line + 1, "%d", &itmp1 );
if( itmp1 == TEXT_is_REFERENCE )
@ -628,30 +608,27 @@ int MODULE::ReadDescr( FILE* File, int* LineNum )
}
/************************************************/
void MODULE::Set_Rectangle_Encadrement()
/************************************************/
/* Mise a jour du rectangle d'encadrement du module
* Entree : pointeur sur module
* Le rectangle d'encadrement est le rectangle comprenant les contours et les
* pads.
* Le rectangle est calcule:
* pour orient 0
* en coord relatives / position ancre
/* Update the bounding rectangle of the module
*
* The rectangle is the rectangle with the contours and
* Pads.
* The rectangle is calculated:
* For East 0
* Coord in on / anchor position
*/
void MODULE::Set_Rectangle_Encadrement()
{
int width;
int cx, cy, uxf, uyf, rayon;
int xmax, ymax;
/* Init des pointeurs */
/* Init des coord du cadre a une valeur limite non nulle */
m_BoundaryBox.m_Pos.x = -500; xmax = 500;
m_BoundaryBox.m_Pos.y = -500; ymax = 500;
/* Initial coordinates of the module has a nonzero limit value. */
m_BoundaryBox.m_Pos.x = -500;
m_BoundaryBox.m_Pos.y = -500;
xmax = 500;
ymax = 500;
/* Contours: Recherche des coord min et max et mise a jour du cadre */
for( EDGE_MODULE* pt_edge_mod = (EDGE_MODULE*) m_Drawings.GetFirst();
pt_edge_mod; pt_edge_mod = pt_edge_mod->Next() )
{
@ -665,7 +642,7 @@ void MODULE::Set_Rectangle_Encadrement()
case S_ARC:
case S_CIRCLE:
{
cx = pt_edge_mod->m_Start0.x; cy = pt_edge_mod->m_Start0.y; // centre
cx = pt_edge_mod->m_Start0.x; cy = pt_edge_mod->m_Start0.y; // center
uxf = pt_edge_mod->m_End0.x; uyf = pt_edge_mod->m_End0.y;
rayon = (int) hypot( (double) (cx - uxf), (double) (cy - uyf) );
rayon += width;
@ -677,10 +654,14 @@ void MODULE::Set_Rectangle_Encadrement()
}
default:
m_BoundaryBox.m_Pos.x = MIN( m_BoundaryBox.m_Pos.x, pt_edge_mod->m_Start0.x - width );
m_BoundaryBox.m_Pos.x = MIN( m_BoundaryBox.m_Pos.x, pt_edge_mod->m_End0.x - width );
m_BoundaryBox.m_Pos.y = MIN( m_BoundaryBox.m_Pos.y, pt_edge_mod->m_Start0.y - width );
m_BoundaryBox.m_Pos.y = MIN( m_BoundaryBox.m_Pos.y, pt_edge_mod->m_End0.y - width );
m_BoundaryBox.m_Pos.x = MIN( m_BoundaryBox.m_Pos.x,
pt_edge_mod->m_Start0.x - width );
m_BoundaryBox.m_Pos.x = MIN( m_BoundaryBox.m_Pos.x,
pt_edge_mod->m_End0.x - width );
m_BoundaryBox.m_Pos.y = MIN( m_BoundaryBox.m_Pos.y,
pt_edge_mod->m_Start0.y - width );
m_BoundaryBox.m_Pos.y = MIN( m_BoundaryBox.m_Pos.y,
pt_edge_mod->m_End0.y - width );
xmax = MAX( xmax, pt_edge_mod->m_Start0.x + width );
xmax = MAX( xmax, pt_edge_mod->m_End0.x + width );
ymax = MAX( ymax, pt_edge_mod->m_Start0.y + width );
@ -689,11 +670,14 @@ void MODULE::Set_Rectangle_Encadrement()
}
}
/* Pads: Recherche des coord min et max et mise a jour du cadre */
/* Pads: find the min and max coordinates and update the bounding
* rectangle.
*/
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{
rayon = pad->m_Rayon;
cx = pad->m_Pos0.x; cy = pad->m_Pos0.y;
cx = pad->m_Pos0.x;
cy = pad->m_Pos0.y;
m_BoundaryBox.m_Pos.x = MIN( m_BoundaryBox.m_Pos.x, cx - rayon );
m_BoundaryBox.m_Pos.y = MIN( m_BoundaryBox.m_Pos.y, cy - rayon );
xmax = MAX( xmax, cx + rayon );
@ -705,17 +689,13 @@ void MODULE::Set_Rectangle_Encadrement()
}
/****************************************/
void MODULE::SetRectangleExinscrit()
/****************************************/
/* Analogue a MODULE::Set_Rectangle_Encadrement() mais en coord reelles:
* Mise a jour du rectangle d'encadrement reel du module c.a.d en coord PCB
* Entree : pointeur sur module
* Le rectangle d'encadrement est le rectangle comprenant les contours et les
* pads.
* Met egalement a jour la surface (.m_Surface) du module.
/* Equivalent to Module:: Set_Rectangle_Encadrement() coord but real:
* Updating the rectangle real module PCB cad in ord
* Entree: pointer module
* The rectangle is the rectangle with the contours and pads.
* Also updates the surface (.M_Surface) module.
*/
void MODULE::SetRectangleExinscrit()
{
int width;
int cx, cy, uxf, uyf, rayon;
@ -724,8 +704,8 @@ void MODULE::SetRectangleExinscrit()
m_RealBoundaryBox.m_Pos.x = xmax = m_Pos.x;
m_RealBoundaryBox.m_Pos.y = ymax = m_Pos.y;
/* Contours: Recherche des coord min et max et mise a jour du cadre */
for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings.GetFirst(); edge; edge = edge->Next() )
for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings.GetFirst();
edge; edge = edge->Next() )
{
if( edge->Type() != TYPE_EDGE_MODULE )
continue;
@ -737,22 +717,30 @@ void MODULE::SetRectangleExinscrit()
case S_ARC:
case S_CIRCLE:
{
cx = edge->m_Start.x; cy = edge->m_Start.y; // centre
uxf = edge->m_End.x; uyf = edge->m_End.y;
cx = edge->m_Start.x;
cy = edge->m_Start.y; // center
uxf = edge->m_End.x;
uyf = edge->m_End.y;
rayon = (int) hypot( (double) (cx - uxf), (double) (cy - uyf) );
rayon += width;
m_RealBoundaryBox.m_Pos.x = MIN( m_RealBoundaryBox.m_Pos.x, cx - rayon );
m_RealBoundaryBox.m_Pos.y = MIN( m_RealBoundaryBox.m_Pos.y, cy - rayon );
m_RealBoundaryBox.m_Pos.x = MIN( m_RealBoundaryBox.m_Pos.x,
cx - rayon );
m_RealBoundaryBox.m_Pos.y = MIN( m_RealBoundaryBox.m_Pos.y,
cy - rayon );
xmax = MAX( xmax, cx + rayon );
ymax = MAX( ymax, cy + rayon );
break;
}
default:
m_RealBoundaryBox.m_Pos.x = MIN( m_RealBoundaryBox.m_Pos.x, edge->m_Start.x - width );
m_RealBoundaryBox.m_Pos.x = MIN( m_RealBoundaryBox.m_Pos.x, edge->m_End.x - width );
m_RealBoundaryBox.m_Pos.y = MIN( m_RealBoundaryBox.m_Pos.y, edge->m_Start.y - width );
m_RealBoundaryBox.m_Pos.y = MIN( m_RealBoundaryBox.m_Pos.y, edge->m_End.y - width );
m_RealBoundaryBox.m_Pos.x = MIN( m_RealBoundaryBox.m_Pos.x,
edge->m_Start.x - width );
m_RealBoundaryBox.m_Pos.x = MIN( m_RealBoundaryBox.m_Pos.x,
edge->m_End.x - width );
m_RealBoundaryBox.m_Pos.y = MIN( m_RealBoundaryBox.m_Pos.y,
edge->m_Start.y - width );
m_RealBoundaryBox.m_Pos.y = MIN( m_RealBoundaryBox.m_Pos.y,
edge->m_End.y - width );
xmax = MAX( xmax, edge->m_Start.x + width );
xmax = MAX( xmax, edge->m_End.x + width );
ymax = MAX( ymax, edge->m_Start.y + width );
@ -761,7 +749,6 @@ void MODULE::SetRectangleExinscrit()
}
}
/* Pads: Recherche des coord min et max et mise a jour du cadre */
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{
rayon = pad->m_Rayon;
@ -778,14 +765,15 @@ void MODULE::SetRectangleExinscrit()
m_RealBoundaryBox.SetWidth( xmax - m_RealBoundaryBox.m_Pos.x );
m_RealBoundaryBox.SetHeight( ymax - m_RealBoundaryBox.m_Pos.y );
m_Surface = ABS( (float) m_RealBoundaryBox.GetWidth() * m_RealBoundaryBox.GetHeight() );
m_Surface = ABS( (float) m_RealBoundaryBox.GetWidth()
* m_RealBoundaryBox.GetHeight() );
}
/**
* Function GetBoundingBox
* returns the full bounding box of this Footprint, including texts
* Mainly used to redraw the screen area occuped by the footprint
* Mainly used to redraw the screen area occupied by the footprint
*/
EDA_Rect MODULE::GetBoundingBox()
{
@ -801,7 +789,8 @@ EDA_Rect MODULE::GetBoundingBox()
text_area = m_Value->GetBoundingBox();
area.Merge( text_area );
for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings.GetFirst(); edge; edge = edge->Next() )
for( EDGE_MODULE* edge = (EDGE_MODULE*) m_Drawings.GetFirst(); edge;
edge = edge->Next() )
{
if( edge->Type() != TYPE_TEXTE_MODULE )
continue;
@ -809,8 +798,9 @@ EDA_Rect MODULE::GetBoundingBox()
area.Merge( text_area );
}
// Add the Clearence shape size: (shape around the pads when the clearence is shown
// Not optimized, but the draw cost is small (perhaps smaller than optimization)
// Add the Clearance shape size: (shape around the pads when the
// clearance is shown. Not optimized, but the draw cost is small
// (perhaps smaller than optimization).
int biggest_clearance = GetBoard()->GetBiggestClearanceValue();
area.Inflate( biggest_clearance );
@ -818,13 +808,10 @@ EDA_Rect MODULE::GetBoundingBox()
}
/*******************************************************/
void MODULE::DisplayInfo( WinEDA_DrawFrame* frame )
/*******************************************************/
/* Virtual function, from EDA_BaseStruct.
* display module info on MsgPanel
*/
void MODULE::DisplayInfo( WinEDA_DrawFrame* frame )
{
int nbpad;
char bufcar[512], Line[512];
@ -851,7 +838,7 @@ void MODULE::DisplayInfo( WinEDA_DrawFrame* frame )
msg = CONV_FROM_UTF8( bufcar );
frame->AppendMsgPanel( _( "Last Change" ), msg, BROWN );
}
else // displa time stamp in schematic
else // display time stamp in schematic
{
msg.Printf( wxT( "%8.8lX" ), m_TimeStamp );
frame->AppendMsgPanel( _( "Netlist path" ), m_Path, BROWN );
@ -902,13 +889,13 @@ void MODULE::DisplayInfo( WinEDA_DrawFrame* frame )
*/
bool MODULE::HitTest( const wxPoint& refPos )
{
/* Calcul des coord souris dans le repere module */
/* Calculation of the cursor coordinate relative to module */
int spot_cX = refPos.x - m_Pos.x;
int spot_cY = refPos.y - m_Pos.y;
RotatePoint( &spot_cX, &spot_cY, -m_Orient );
/* la souris est-elle dans ce rectangle : */
/* Check if cursor is in the rectangle. */
if( m_BoundaryBox.Inside( spot_cX, spot_cY ) )
return true;
@ -917,7 +904,7 @@ bool MODULE::HitTest( const wxPoint& refPos )
/**
* Function HitTest (overlayed)
* Function HitTest (overlaid)
* tests if the given EDA_Rect intersect the bounds of this object.
* @param refArea : the given EDA_Rect
* @return bool - true if a hit, else false
@ -1059,7 +1046,8 @@ void MODULE::Show( int nestLevel, std::ostream& os )
NestedSpace( nestLevel + 1, os ) <<
"<boundingBox" << m_BoundaryBox.m_Pos << m_BoundaryBox.m_Size << "/>\n";
NestedSpace( nestLevel + 1, os ) << "<orientation tenths=\"" << m_Orient << "\"/>\n";
NestedSpace( nestLevel + 1, os ) << "<orientation tenths=\"" << m_Orient
<< "\"/>\n";
EDA_BaseStruct* p;
@ -1083,7 +1071,8 @@ void MODULE::Show( int nestLevel, std::ostream& os )
p->Show( nestLevel + 1, os );
}
NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str()
<< ">\n";
}

View File

@ -11,22 +11,14 @@ class S3D_MASTER;
/* pad are in class_pad.xx */
/************************************/
/* Format des modules:
* Description generale
* Description segments contour
* Description textes
* Description pastilles
*/
/* Flags :*/
enum Mod_Attribut /* Attributs used for modules */
enum Mod_Attribut /* Attributes used for modules */
{
MOD_DEFAULT = 0, /* Type default */
MOD_CMS = 1, /* Set for modules listed in the automatic insertion list
* (usually SMD footprints) */
MOD_VIRTUAL = 2 /* Virtuel component: when created by copper shapes on board
* (Like edge card connectors, mounting hole...) */
MOD_VIRTUAL = 2 /* Virtual component: when created by copper shapes on
* board (Like edge card connectors, mounting hole...) */
};
@ -41,41 +33,60 @@ public:
wxPoint m_Pos; // Real coord on board
DLIST<D_PAD> m_Pads; /* Pad list (linked list) */
DLIST<BOARD_ITEM> m_Drawings; /* Graphic items list (linked list) */
DLIST<S3D_MASTER> m_3D_Drawings; /* First item of the 3D shapes (linked list)*/
DLIST<S3D_MASTER> m_3D_Drawings; /* First item of the 3D shapes (linked
* list)*/
TEXTE_MODULE* m_Reference; // Component reference (U34, R18..)
TEXTE_MODULE* m_Value; // Component value (74LS00, 22K..)
wxString m_LibRef; /* Name of the module in library (and the default value when loading amodule from the library) */
wxString m_AlternateReference; /* Used when m_Reference cannot be used to
* identify the footprint ( after a full reannotation of the schematic */
wxString m_LibRef; /* Name of the module in library (and
* the default value when loading a
*module from the library) */
wxString m_AlternateReference; /* Used when m_Reference cannot
* be used to identify the
* footprint ( after a full
* reannotation of the schematic */
int m_Attributs; /* Flags(ORed bits) ( see Mod_Attribut ) */
int m_Attributs; /* Flag bits ( see Mod_Attribut ) */
int m_Orient; /* orientation in 0.1 degrees */
int flag; /* flag utilise en trace rastnest et routage auto */
int m_ModuleStatus; /* For autoplace: flags (LOCKED, AUTOPLACED) */
EDA_Rect m_BoundaryBox; /* Bounding box coordinates relatives to the anchor, orient 0*/
EDA_Rect m_RealBoundaryBox; /* Bounding box : coordinates on board, real orientation */
int flag; /* Use to trace rastnest and auto
* routing. */
int m_ModuleStatus; /* For autoplace: flags (LOCKED,
* AUTOPLACED) */
EDA_Rect m_BoundaryBox; /* Bounding box coordinates relatives
* to the anchor, orient 0*/
EDA_Rect m_RealBoundaryBox; /* Bounding box : coordinates on board,
* real orientation */
int m_PadNum; // Pad count
int m_AltPadNum; // Pad with netcode > 0 (active pads)count
int m_AltPadNum; /* Pad with netcode > 0 (active pads)
* count */
int m_CntRot90; // Automatic placement : cost ( 0..10 ) for 90 degrees rotaion (Horiz<->Vertical)
int m_CntRot180; // Automatic placement : cost ( 0..10 ) for 180 degrees rotaion (UP <->Down)
wxSize m_Ext; // Automatic placement margin around the module
int m_CntRot90; /* Automatic placement : cost ( 0..10 )
* for 90 degrees rotation
* (Horiz<->Vertical) */
int m_CntRot180; /* Automatic placement : cost ( 0..10 )
* for 180 degrees rotation
* (UP <->Down) */
wxSize m_Ext; /* Automatic placement margin around
* the module */
float m_Surface; // Bounding box area
unsigned long m_Link; // Temporary variable ( used in editions, ...)
long m_LastEdit_Time; // Date de la derniere modification du module (gestion de librairies)
unsigned long m_Link; /* Temporary variable ( used in
* editions, ...) */
long m_LastEdit_Time;
wxString m_Path;
wxString m_Doc; // Module Description (info for users)
wxString m_KeyWord; // Keywords to select the module in lib
// Local clearance. When null, the netclasses values are used. Usually the local clearance is null
// Local clearance. When null, the netclasses values are used. Usually
// the local clearance is null
int m_LocalClearance;
// Local mask margins: when NULL, the global design values are used
int m_LocalSolderMaskMargin; // Local solder mask margin
int m_LocalSolderPasteMargin; // Local solder paste margin absolute value
double m_LocalSolderPasteMarginRatio; // Local solder pask margin ratio value of pad size
int m_LocalSolderMaskMargin; // Solder mask margin
int m_LocalSolderPasteMargin; /* Solder paste margin
* absolute value */
double m_LocalSolderPasteMarginRatio; /* Solder mask margin ratio
* value of pad size */
// The final margin is the sum of these 2 values
public:
@ -100,20 +111,21 @@ public:
/**
* Function Set_Rectangle_Encadrement()
* calculates the bounding box for orient 0 et origin = module anchor)
* calculates the bounding box for orient 0 at origin = module anchor)
*/
void Set_Rectangle_Encadrement();
/** function SetRectangleExinscrit()
* Calculates the real bounding box accordint to theboard position, and real orientaion
* and also calculates the area value (used in automatic placement)
* Calculates the real bounding box according to the board position,
* and real orientation and also calculates the area value (used in
* automatic placement)
*/
void SetRectangleExinscrit();
/**
* Function GetBoundingBox
* returns the bounding box of this Footprint
* Mainly used to redraw the screen area occuped by the footprint
* Mainly used to redraw the screen area occupied by the footprint
*/
EDA_Rect GetBoundingBox();
@ -184,8 +196,9 @@ public:
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* writes the data structures for this object out to a FILE in "*.brd"
* format.
* a@param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
@ -206,7 +219,7 @@ public:
/* drawing functions */
/** Function Draw
* Draw the text accordint to the footprint pos and orient
* Draw the text according to the footprint pos and orient
* @param panel = draw panel, Used to know the clip box
* @param DC = Current Device Context
* @param offset = draw offset (usually wxPoint(0,0)
@ -242,7 +255,7 @@ public:
/**
* Function HitTest (overlayed)
* Function HitTest (overlaid)
* tests if the given EDA_Rect intersect the bounds of this object.
* @param refArea : the given EDA_Rect
* @return bool - true if a hit, else false
@ -274,7 +287,8 @@ public:
* returns a D_PAD* with a matching name. Note that names may not be
* unique, depending on how the foot print was created.
* @param
* @return D_PAD* - The first matching name is returned, or NULL if not found.
* @return D_PAD* - The first matching name is returned, or NULL if not
* found.
*/
D_PAD* FindPadByName( const wxString& aPadName ) const;

View File

@ -13,48 +13,55 @@
#include "pcbnew.h"
#include "protos.h"
/*************************************/
int ChangeSideNumLayer( int oldlayer )
/*************************************/
/* Routine de recalcul du numero de couche lors des
* echanges cote cu/cmp pour les couches CU/CMP specialisees
* (cuivre, serigr., pate , soudure)
/* Calculate the layer number for changing cu / cmp layers for Cu / CMP
* (Copper, Mask, Paste, solder)
*/
int ChangeSideNumLayer( int oldlayer )
{
int newlayer;
switch( oldlayer )
{
case COPPER_LAYER_N:
newlayer = CMP_N; break;
newlayer = CMP_N;
break;
case CMP_N:
newlayer = COPPER_LAYER_N; break;
newlayer = COPPER_LAYER_N;
break;
case SILKSCREEN_N_CU:
newlayer = SILKSCREEN_N_CMP; break;
newlayer = SILKSCREEN_N_CMP;
break;
case SILKSCREEN_N_CMP:
newlayer = SILKSCREEN_N_CU; break;
newlayer = SILKSCREEN_N_CU;
break;
case ADHESIVE_N_CU:
newlayer = ADHESIVE_N_CMP; break;
newlayer = ADHESIVE_N_CMP;
break;
case ADHESIVE_N_CMP:
newlayer = ADHESIVE_N_CU; break;
newlayer = ADHESIVE_N_CU;
break;
case SOLDERMASK_N_CU:
newlayer = SOLDERMASK_N_CMP; break;
newlayer = SOLDERMASK_N_CMP;
break;
case SOLDERMASK_N_CMP:
newlayer = SOLDERMASK_N_CU; break;
newlayer = SOLDERMASK_N_CU;
break;
case SOLDERPASTE_N_CU:
newlayer = SOLDERPASTE_N_CMP; break;
newlayer = SOLDERPASTE_N_CMP;
break;
case SOLDERPASTE_N_CMP:
newlayer = SOLDERPASTE_N_CU; break;
newlayer = SOLDERPASTE_N_CU;
break;
default:
newlayer = oldlayer;
@ -63,14 +70,12 @@ int ChangeSideNumLayer( int oldlayer )
return newlayer;
}
/*********************************************/
static int ChangeSideMaskLayer( int masque )
/*********************************************/
/* Routine de recalcul du masque-layer lors des
* echanges cote cu/cmp pour les couches CU/CMP specialisees
* (cuivre, serigr., pate , soudure)
/* Change the mask layer during routing cu / cmp layers for
* Cu / CMP..
* (Copper, mask, paste, solder)
*/
static int ChangeSideMaskLayer( int masque )
{
int newmasque;
@ -126,6 +131,7 @@ void MODULE::Move(const wxPoint& aMoveVector)
SetPosition( newpos );
}
/**
* Function Rotate
* Rotate this object.
@ -140,6 +146,7 @@ void MODULE::Rotate(const wxPoint& aRotCentre, int aAngle)
SetOrientation( m_Orient + aAngle );
}
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
@ -154,33 +161,33 @@ void MODULE::Flip(const wxPoint& aCentre )
// Move module to its final position:
wxPoint finalPos = m_Pos;
finalPos.y = aCentre.y - (finalPos.y - aCentre.y); /// Mirror the Y position
finalPos.y = aCentre.y - ( finalPos.y - aCentre.y ); /// Mirror the Y position
SetPosition(finalPos);
/* Flip layer */
SetLayer( ChangeSideNumLayer( GetLayer() ) );
/* Inversion miroir de l'orientation */
/* Reverse mirror orientation. */
NEGATE( m_Orient );
NORMALIZE_ANGLE_POS( m_Orient );
/* Inversion miroir + layers des pastilles */
/* Mirror inversion layers pads. */
pt_pad = m_Pads;
for( ; pt_pad != NULL; pt_pad = pt_pad->Next() )
{
pt_pad->m_Pos.y -= m_Pos.y;
pt_pad->m_Pos.y = -pt_pad->m_Pos.y;
pt_pad->m_Pos.y += m_Pos.y;
NEGATE(pt_pad->m_Pos0.y);
NEGATE(pt_pad->m_Offset.y);
NEGATE(pt_pad->m_DeltaSize.y);
NEGATE( pt_pad->m_Pos0.y );
NEGATE( pt_pad->m_Offset.y );
NEGATE( pt_pad->m_DeltaSize.y );
NEGATE_AND_NORMALIZE_ANGLE_POS( pt_pad->m_Orient );
/* flip pads layers*/
pt_pad->m_Masque_Layer = ChangeSideMaskLayer( pt_pad->m_Masque_Layer );
}
/* Inversion miroir de la Reference et mise en miroir : */
/* Mirror reference. */
pt_texte = m_Reference;
pt_texte->m_Pos.y -= m_Pos.y;
pt_texte->m_Pos.y = -pt_texte->m_Pos.y;
@ -201,12 +208,12 @@ void MODULE::Flip(const wxPoint& aCentre )
|| (GetLayer() == ADHESIVE_N_CU) || (GetLayer() == COPPER_LAYER_N) )
pt_texte->m_Mirror = true;
/* Inversion miroir de la Valeur et mise en miroir : */
/* Mirror value. */
pt_texte = m_Value;
pt_texte->m_Pos.y -= m_Pos.y;
NEGATE(pt_texte->m_Pos.y);
NEGATE( pt_texte->m_Pos.y );
pt_texte->m_Pos.y += m_Pos.y;
NEGATE(pt_texte->m_Pos0.y);
NEGATE( pt_texte->m_Pos0.y );
pt_texte->m_Mirror = false;
NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient );
pt_texte->SetLayer( GetLayer() );
@ -222,7 +229,7 @@ void MODULE::Flip(const wxPoint& aCentre )
|| (GetLayer() == ADHESIVE_N_CU) || (GetLayer() == COPPER_LAYER_N) )
pt_texte->m_Mirror = true;
/* Inversion miroir des dessins de l'empreinte : */
/* Reverse mirror footprints. */
PtStruct = m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{
@ -236,9 +243,8 @@ void MODULE::Flip(const wxPoint& aCentre )
pt_edgmod->m_End.y -= m_Pos.y;
pt_edgmod->m_End.y = -pt_edgmod->m_End.y;
pt_edgmod->m_End.y += m_Pos.y;
/* inversion des coords locales */
NEGATE(pt_edgmod->m_Start0.y);
NEGATE(pt_edgmod->m_End0.y);
NEGATE( pt_edgmod->m_Start0.y );
NEGATE( pt_edgmod->m_End0.y );
if( pt_edgmod->m_Shape == S_ARC )
{
NEGATE(pt_edgmod->m_Angle);
@ -248,12 +254,12 @@ void MODULE::Flip(const wxPoint& aCentre )
break;
case TYPE_TEXTE_MODULE:
/* Inversion miroir de la position et mise en miroir : */
/* Reverse mirror position and mirror. */
pt_texte = (TEXTE_MODULE*) PtStruct;
pt_texte->m_Pos.y -= m_Pos.y;
pt_texte->m_Pos.y = -pt_texte->m_Pos.y;
pt_texte->m_Pos.y += m_Pos.y;
NEGATE(pt_texte->m_Pos0.y);
NEGATE( pt_texte->m_Pos0.y );
pt_texte->m_Mirror = false;
NEGATE_AND_NORMALIZE_ANGLE_POS( pt_texte->m_Orient );
@ -281,40 +287,29 @@ void MODULE::Flip(const wxPoint& aCentre )
}
}
/* calcul du rectangle d'encadrement */
Set_Rectangle_Encadrement();
}
/*************************************************/
void MODULE::SetPosition( const wxPoint& newpos )
/*************************************************/
// replace le module en position newpos
{
int deltaX = newpos.x - m_Pos.x;
int deltaY = newpos.y - m_Pos.y;
/* deplacement de l'ancre */
m_Pos.x += deltaX;
m_Pos.y += deltaY;
/* deplacement de la reference */
m_Reference->m_Pos.x += deltaX;
m_Reference->m_Pos.y += deltaY;
/* deplacement de la Valeur */
m_Value->m_Pos.x += deltaX;
m_Value->m_Pos.y += deltaY;
/* deplacement des pastilles */
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{
pad->m_Pos.x += deltaX;
pad->m_Pos.y += deltaY;
}
/* deplacement des dessins de l'empreinte : */
EDA_BaseStruct* PtStruct = m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
{
@ -336,7 +331,8 @@ void MODULE::SetPosition( const wxPoint& newpos )
}
default:
wxMessageBox( wxT( "Type Draw Indefini" ) ); break;
wxMessageBox( wxT( "Draw type undefined." ) );
break;
}
}
@ -344,21 +340,15 @@ void MODULE::SetPosition( const wxPoint& newpos )
}
/*********************************************/
void MODULE::SetOrientation( int newangle )
/*********************************************/
/* Tourne de newangle (en 0.1 degres) le module
*/
{
int px, py;
newangle -= m_Orient; // = delta de rotation
newangle -= m_Orient; // = Change in rotation
m_Orient += newangle;
NORMALIZE_ANGLE_POS( m_Orient );
/* deplacement et rotation des pastilles */
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{
px = pad->m_Pos0.x;
@ -372,11 +362,11 @@ void MODULE::SetOrientation( int newangle )
pad->m_Pos.y = m_Pos.y + py;
}
/* mise a jour de la reference et de la valeur*/
/* Update of the reference and value. */
m_Reference->SetDrawCoord();
m_Value->SetDrawCoord();
/* deplacement des contours et textes de l'empreinte : */
/* Displace contours and text of the footprint. */
for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
{
if( item->Type() == TYPE_EDGE_MODULE )
@ -387,13 +377,10 @@ void MODULE::SetOrientation( int newangle )
if( item->Type() == TYPE_TEXTE_MODULE )
{
/* deplacement des inscriptions : */
TEXTE_MODULE* pt_texte = (TEXTE_MODULE*) item;
pt_texte->SetDrawCoord();
}
}
/* Recalcul du rectangle d'encadrement */
Set_Rectangle_Encadrement();
}

View File

@ -1,5 +1,5 @@
/************************/
/* file class_equipot.h */
/* file class_netinfo.h */
/************************/
/*
@ -11,33 +11,34 @@
#include "class_netclass.h"
// Forward declaration:
class NETINFO_ITEM;
/* Class RATSNEST_ITEM: describes a ratsnest line: a straight line connecting 2 pads */
/* Class RATSNEST_ITEM: describes a ratsnest line: a straight line connecting
* 2 pads */
/*****************************/
/* flags for a RATSNEST_ITEM */
/*****************************/
#define CH_VISIBLE 1 /* affichage permanent demande */
#define CH_UNROUTABLE 2 /* non route par l'autorouteur */
#define CH_ROUTE_REQ 4 /* doit etre route par l'autorouteur */
#define CH_ACTIF 8 /* chevelu non encore routé */
#define LOCAL_RATSNEST_ITEM 0x8000 /* indique un chevelu reliant 2 pins d'un meme
* module pour le calcul des chevelus relatifs a 1 seul module */
#define CH_VISIBLE 1 /* Visible */
#define CH_UNROUTABLE 2 /* Don't use autorouter. */
#define CH_ROUTE_REQ 4 /* Must be routed by the autorouter. */
#define CH_ACTIF 8 /* Not routed. */
#define LOCAL_RATSNEST_ITEM 0x8000 /* Line between two pads of a single
* module. */
class RATSNEST_ITEM
{
private:
int m_NetCode; // netcode ( = 1.. n , 0 is the value used for not connected items)
int m_NetCode; // netcode ( = 1.. n , 0 is the value used for not
// connected items)
public:
int m_Status; // State: see previous defines (CH_ ...)
D_PAD* m_PadStart; // pointer to the starting pad
D_PAD* m_PadEnd; // pointer to ending pad
int m_Lenght; // lenght of the line (temporary used in some calculations)
int m_Lenght; // length of the line (used in some calculations)
/* constructor */
RATSNEST_ITEM();
/**
@ -58,7 +59,10 @@ public:
/** function Draw
*/
void Draw( WinEDA_DrawPanel* panel, wxDC* DC, int aDrawMode, const wxPoint& offset );
void Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
int aDrawMode,
const wxPoint& offset );
};
/***************************************************************/
@ -70,18 +74,21 @@ class NETINFO_LIST
{
private:
BOARD* m_Parent;
std::vector<NETINFO_ITEM*> m_NetBuffer; // nets buffer list (name, design constraints ..
std::vector<NETINFO_ITEM*> m_NetBuffer; // nets buffer list (name,
// design constraints ..
public:
std::vector<D_PAD*> m_PadsFullList; // Entry for a sorted pad list (used in ratsnest calculations)
std::vector<D_PAD*> m_PadsFullList; // Entry for a sorted pad
// list (used in ratsnest
// calculations)
public:
NETINFO_LIST( BOARD* aParent );
public: NETINFO_LIST( BOARD* aParent );
~NETINFO_LIST();
/** Function GetItem
* @param aNetcode = netcode to identify a given NETINFO_ITEM
* @return a NETINFO_ITEM pointer to the selected NETINFO_ITEM by its netcode, or NULL if not found
* @return a NETINFO_ITEM pointer to the selected NETINFO_ITEM by its
* netcode, or NULL if not found
*/
NETINFO_ITEM* GetNetItem( int aNetcode );
@ -152,13 +159,16 @@ class NETINFO_ITEM
{
private:
int m_NetCode; // this is a number equivalent to the net name
// Used for fast comparisons in rastnest and DRC computations.
// Used for fast comparisons in ratsnest and DRC computations.
wxString m_Netname; // Full net name like /mysheet/mysubsheet/vout used by eeschema
wxString m_Netname; // Full net name like /mysheet/mysubsheet/vout
// used by eeschema
wxString m_ShortNetname; // short net name, like vout from /mysheet/mysubsheet/vout
wxString m_ShortNetname; // short net name, like vout from
// /mysheet/mysubsheet/vout
wxString m_NetClassName; // Net Class name. if void this is equivalent to "default" (the first
wxString m_NetClassName; // Net Class name. if void this is equivalent
// to "default" (the first
// item of the net classes list
NETCLASS* m_NetClass;
@ -168,15 +178,19 @@ public:
int m_NbNodes; // Pads count for this net
int m_NbLink; // Ratsnets count for this net
int m_NbNoconn; // Ratsnets remaining to route count
int m_Flag; // used in some calculations. Had no special meaning
int m_Flag; // used in some calculations. Had no
// special meaning
std::vector <D_PAD*> m_ListPad; // List of pads connected to this net
unsigned m_RatsnestStartIdx; /* Starting point of ratsnests of this net (included)
* in a general buffer of ratsnest (a vector<RATSNEST_ITEM*> buffer)
*/
unsigned m_RatsnestStartIdx; /* Starting point of ratsnests of
* this
* net (included) in a general buffer of
* ratsnest (a vector<RATSNEST_ITEM*>
* buffer) */
unsigned m_RatsnestEndIdx; // Ending point of ratsnests of this net (excluded) in this buffer
unsigned m_RatsnestEndIdx; // Ending point of ratsnests of this net
// (excluded) in this buffer
NETINFO_ITEM( BOARD_ITEM* aParent );
~NETINFO_ITEM();
@ -194,21 +208,25 @@ public:
m_NetClassName = NETCLASS::Default;
}
NETCLASS* GetNetClass()
{
return m_NetClass;
}
/**
* Function GetClassName
* returns the class name
*/
const wxString& GetClassName( ) const
const wxString& GetClassName() const
{
return m_NetClassName;
}
#if 1
/**
* Function GetTrackWidth
* returns the width of tracks used to route this net.
@ -221,6 +239,7 @@ public:
#if 0
/**
* Function GetTrackMinWidth
* returns the Minimum value for tracks thickness (used in DRC)
@ -229,6 +248,8 @@ public:
{
return g_DesignSettings.m_TrackMinWidth;
}
#endif
/**
@ -241,6 +262,7 @@ public:
return m_NetClass->GetViaDiameter();
}
/**
* Function GetMicroViaSize
* returns the size of vias used to route this net
@ -262,6 +284,7 @@ public:
return m_NetClass->GetViaDrill();
}
/**
* Function GetViaDrillSize
* returns the size of via drills used to route this net
@ -273,8 +296,8 @@ public:
}
#if 0
/**
* Function GetViaMinSize
* returns the Minimum value for via sizes (used in DRC)
@ -284,6 +307,8 @@ public:
wxASSERT( m_NetClass );
return m_NetClass->GetViaMinSize();
}
#endif
/**
@ -295,6 +320,8 @@ public:
wxASSERT( m_NetClass );
return m_NetClass->GetClearance();
}
#endif
/* Reading and writing data on files */
@ -302,7 +329,8 @@ public:
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* writes the data structures for this object out to a FILE in "*.brd"
* format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
@ -310,9 +338,11 @@ public:
/** function Draw
* @todo we actually could show a NET, simply show all the tracks and pads or net name on pad and vias
* @todo we actually could show a NET, simply show all the tracks and
* a pads or net name on pad and vias
*/
void Draw( WinEDA_DrawPanel* panel, wxDC* DC, int aDrawMode, const wxPoint& offset );
void Draw( WinEDA_DrawPanel* panel, wxDC* DC, int aDrawMode,
const wxPoint& offset );
/**
@ -354,9 +384,9 @@ public:
};
/****************************************************************/
/* description d'un point de piste pour le suivi des connexions */
/****************************************************************/
/***********************************************************/
/* Description of a trace point for monitoring connections */
/***********************************************************/
#define START_ON_PAD 0x10
#define END_ON_PAD 0x20
#define START_ON_TRACK 0x40
@ -366,12 +396,13 @@ public:
/* Status bit (OR'ed bits) for class BOARD member .m_Status_Pcb */
enum StatusPcbFlags {
LISTE_PAD_OK = 1, /* Pad list is Ok */
LISTE_RATSNEST_ITEM_OK = 2, /* General Rastnest is Ok */
RATSNEST_ITEM_LOCAL_OK = 4, /* current MODULE rastnest is Ok */
CONNEXION_OK = 8, /* Bit indicant que la liste des connexions existe */
NET_CODES_OK = 0x10, /* Bit indicant que les netcodes sont OK ( pas de modif
* de noms de net */
DO_NOT_SHOW_GENERAL_RASTNEST = 0x20 /* Do not display the general rastnest (used in module moves) */
LISTE_RATSNEST_ITEM_OK = 2, /* General Ratsnest is Ok */
RATSNEST_ITEM_LOCAL_OK = 4, /* current MODULE ratsnest is Ok */
CONNEXION_OK = 8, /* List of connections exists. */
NET_CODES_OK = 0x10, /* Bit indicating that Netcode is OK,
* do not change net name. */
DO_NOT_SHOW_GENERAL_RASTNEST = 0x20 /* Do not display the general
* ratsnest (used in module moves) */
};

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* NETINFO_ITEM class, to handle info on nets (netnames, net constraints ...) */
/* NETINFO_ITEM class, to handle info on nets (netnames, net constraints */
/*************************************************************************/
#include "fctsys.h"
@ -14,7 +14,6 @@
/* class NETINFO_ITEM: handle data relative to a given net */
/*********************************************************/
/* Constructor */
NETINFO_ITEM::NETINFO_ITEM( BOARD_ITEM* aParent )
{
SetNet( 0 );
@ -22,7 +21,8 @@ NETINFO_ITEM::NETINFO_ITEM( BOARD_ITEM* aParent )
m_NbLink = 0;
m_NbNoconn = 0;
m_Flag = 0;
m_RatsnestStartIdx = 0; // Starting point of ratsnests of this net in a general buffer of ratsnest
m_RatsnestStartIdx = 0; // Starting point of ratsnests of this net in a
// general buffer of ratsnest
m_RatsnestEndIdx = 0; // Ending point of ratsnests of this net
m_NetClassName = NETCLASS::Default;
@ -37,14 +37,11 @@ NETINFO_ITEM::~NETINFO_ITEM()
}
/*********************************************************/
int NETINFO_ITEM:: ReadDescr( FILE* File, int* LineNum )
/*********************************************************/
/* Routine de lecture de 1 descr Equipotentielle.
* retourne 0 si OK
* 1 si lecture incomplete
/* Read NETINFO_ITEM from file.
* Returns 0 if OK
* 1 if incomplete reading
*/
int NETINFO_ITEM::ReadDescr( FILE* File, int* LineNum )
{
char Line[1024], Ltmp[1024];
int tmp;
@ -54,7 +51,7 @@ int NETINFO_ITEM:: ReadDescr( FILE* File, int* LineNum )
if( strnicmp( Line, "$End", 4 ) == 0 )
return 0;
if( strncmp( Line, "Na", 2 ) == 0 ) /* Texte */
if( strncmp( Line, "Na", 2 ) == 0 )
{
sscanf( Line + 2, " %d", &tmp );
SetNet( tmp );
@ -69,13 +66,11 @@ int NETINFO_ITEM:: ReadDescr( FILE* File, int* LineNum )
}
/*******************************************/
bool NETINFO_ITEM::Save( FILE* aFile ) const
/*******************************************/
/** Note: the old name of class NETINFO_ITEM was EQUIPOT
* so in Save (and read) functions, for compatibility, we use EQUIPOT as keyword
* so in Save (and read) functions, for compatibility, we use EQUIPOT as
* keyword
*/
bool NETINFO_ITEM::Save( FILE* aFile ) const
{
bool success = false;
@ -108,7 +103,10 @@ void NETINFO_ITEM::SetNetname( const wxString& aNetname )
/** function Draw (TODO)
*/
void NETINFO_ITEM::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int aDrawMode, const wxPoint& aOffset )
void NETINFO_ITEM::Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
int aDrawMode,
const wxPoint& aOffset )
{
}
@ -176,18 +174,23 @@ void NETINFO_ITEM::DisplayInfo( WinEDA_DrawFrame* frame )
RATSNEST_ITEM::RATSNEST_ITEM()
{
m_NetCode = 0; // netcode ( = 1.. n , 0 is the value used for not connected items)
m_NetCode = 0; // netcode ( = 1.. n , 0 is the value used for not
// connected items)
m_Status = 0; // state
m_PadStart = NULL; // pointer to the starting pad
m_PadEnd = NULL; // pointer to ending pad
m_Lenght = 0; // lenght of the line (temporary used in some calculations)
m_Lenght = 0; // length of the line (temporary used in some
// calculations)
}
/** function Draw
* Draws a line (a ratsnest) from the starting pad to the ending pad
*/
void RATSNEST_ITEM::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int aDrawMode, const wxPoint& aOffset )
void RATSNEST_ITEM::Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
int aDrawMode,
const wxPoint& aOffset )
{
GRLine( &panel->m_ClipBox, DC, m_PadStart->m_Pos - aOffset,
m_PadEnd->m_Pos - aOffset, 0, g_DesignSettings.m_RatsnestColor );

View File

@ -1,6 +1,6 @@
/************************************************/
/* class_pad.cpp : fonctions de la classe D_PAD */
/************************************************/
/***********************************************/
/* class_pad.cpp : D_PAD class implementation. */
/***********************************************/
#include "fctsys.h"
#include "common.h"
@ -13,15 +13,11 @@
#include "class_board_design_settings.h"
/*******************************/
/* classe D_PAD : constructeur */
/*******************************/
D_PAD::D_PAD( MODULE* parent ) : BOARD_CONNECTED_ITEM( parent, TYPE_PAD )
{
m_NumPadName = 0;
m_Size.x = m_Size.y = 500; // give it a reasonnable size
m_Size.x = m_Size.y = 500; // give it a reasonable size
m_Orient = 0; // Pad rotation in 1/10 degrees
if( m_Parent && (m_Parent->Type() == TYPE_MODULE) )
@ -29,16 +25,22 @@ D_PAD::D_PAD( MODULE* parent ) : BOARD_CONNECTED_ITEM( parent, TYPE_PAD )
m_Pos = ( (MODULE*) m_Parent )->GetPosition();
}
m_PadShape = PAD_CIRCLE; // Shape: PAD_CIRCLE, PAD_RECT PAD_OVAL PAD_TRAPEZOID
m_Attribut = PAD_STANDARD; // Type: NORMAL, PAD_SMD, PAD_CONN
m_PadShape = PAD_CIRCLE; // Shape: PAD_CIRCLE,
// PAD_RECT PAD_OVAL
// PAD_TRAPEZOID
m_Attribut = PAD_STANDARD; // Type: NORMAL, PAD_SMD,
// PAD_CONN
m_DrillShape = PAD_CIRCLE; // Drill shape = circle
m_LocalClearance = 0;
m_LocalSolderMaskMargin = 0;
m_LocalSolderPasteMargin = 0;
m_LocalSolderPasteMarginRatio = 0.0;
m_Masque_Layer = PAD_STANDARD_DEFAULT_LAYERS; // set layers mask to default for a standard pad
m_Masque_Layer = PAD_STANDARD_DEFAULT_LAYERS; // set layers mask to
// default for a standard
// pad
SetSubRatsnest( 0 ); // used in ratsnest calculations
SetSubRatsnest( 0 ); // used in ratsnest
// calculations
ComputeRayon();
}
@ -48,12 +50,9 @@ D_PAD::~D_PAD()
}
/****************************/
void D_PAD::ComputeRayon()
/****************************/
/* met a jour m_Rayon, rayon du cercle exinscrit
/* Calculate the radius of the pad.
*/
void D_PAD::ComputeRayon()
{
switch( m_PadShape & 0x7F )
{
@ -77,12 +76,13 @@ void D_PAD::ComputeRayon()
/**
* Function GetBoundingBox
* returns the bounding box of this pad
* Mainly used to redraw the screen area occuped by the pad
* Mainly used to redraw the screen area occupied by the pad
*/
EDA_Rect D_PAD::GetBoundingBox()
{
// Calculate area:
ComputeRayon(); // calculate the radius of the area, considered as a circle
ComputeRayon(); // calculate the radius of the area, considered as a
// circle
EDA_Rect area;
area.SetOrigin( m_Pos );
area.Inflate( m_Rayon, m_Rayon );
@ -91,11 +91,8 @@ EDA_Rect D_PAD::GetBoundingBox()
}
/*********************************************/
// Returns the position of the pad.
const wxPoint D_PAD::ReturnShapePos()
/*********************************************/
// retourne la position de la forme (pastilles excentrees)
{
if( m_Offset.x == 0 && m_Offset.y == 0 )
return m_Pos;
@ -115,12 +112,9 @@ const wxPoint D_PAD::ReturnShapePos()
}
/****************************************/
wxString D_PAD::ReturnStringPadName()
/****************************************/
/* Return pad name as string in a wxString
*/
wxString D_PAD::ReturnStringPadName()
{
wxString name;
@ -129,12 +123,9 @@ wxString D_PAD::ReturnStringPadName()
}
/********************************************/
void D_PAD::ReturnStringPadName( wxString& text )
/********************************************/
/* Return pad name as string in a buffer
*/
void D_PAD::ReturnStringPadName( wxString& text )
{
int ii;
@ -148,11 +139,8 @@ void D_PAD::ReturnStringPadName( wxString& text )
}
/********************************************/
void D_PAD::SetPadName( const wxString& name )
/********************************************/
// Change pad name
void D_PAD::SetPadName( const wxString& name )
{
int ii, len;
@ -167,23 +155,18 @@ void D_PAD::SetPadName( const wxString& name )
}
/**************************************************/
void D_PAD::SetNetname( const wxString& aNetname )
/**************************************************/
/**
* Function SetNetname
* @param const wxString : the new netname
*/
void D_PAD::SetNetname( const wxString& aNetname )
{
m_Netname = aNetname;
m_ShortNetname = m_Netname.AfterLast( '/' );
}
/********************************/
void D_PAD::Copy( D_PAD* source )
/********************************/
{
if( source == NULL )
return;
@ -191,18 +174,18 @@ void D_PAD::Copy( D_PAD* source )
m_Pos = source->m_Pos;
m_Masque_Layer = source->m_Masque_Layer;
memcpy( m_Padname, source->m_Padname, sizeof(m_Padname) ); /* nom de la pastille */
SetNet( source->GetNet() ); /* Numero de net pour comparaisons rapides */
m_Drill = source->m_Drill; // Diametre de percage
memcpy( m_Padname, source->m_Padname, sizeof(m_Padname) );
SetNet( source->GetNet() );
m_Drill = source->m_Drill;
m_DrillShape = source->m_DrillShape;
m_Offset = source->m_Offset; // Offset de la forme
m_Size = source->m_Size; // Dimension ( pour orient 0 )
m_DeltaSize = source->m_DeltaSize; // delta sur formes rectangle -> trapezes
m_Pos0 = source->m_Pos0; /* Coord relatives a l'ancre du pad en orientation 0 */
m_Rayon = source->m_Rayon; // rayon du cercle exinscrit du pad
m_PadShape = source->m_PadShape; // forme CERCLE, PAD_RECT PAD_OVAL PAD_TRAPEZOID ou libre
m_Attribut = source->m_Attribut; // NORMAL, PAD_SMD, PAD_CONN, Bit 7 = STACK
m_Orient = source->m_Orient; // en 1/10 degres
m_Offset = source->m_Offset;
m_Size = source->m_Size;
m_DeltaSize = source->m_DeltaSize;
m_Pos0 = source->m_Pos0;
m_Rayon = source->m_Rayon;
m_PadShape = source->m_PadShape;
m_Attribut = source->m_Attribut;
m_Orient = source->m_Orient;
m_LocalClearance = source->m_LocalClearance;
m_LocalSolderMaskMargin = source->m_LocalSolderMaskMargin;
m_LocalSolderPasteMargin = source->m_LocalSolderPasteMargin;
@ -214,21 +197,24 @@ void D_PAD::Copy( D_PAD* source )
m_ShortNetname = source->m_ShortNetname;
}
/** Virtual function GetClearance
* returns the clearance in 1/10000 inches. If \a aItem is not NULL then the
* returned clearance is the greater of this object's NETCLASS clearance and
* aItem's NETCLASS clearance. If \a aItem is NULL, then this objects clearance
* aItem's NETCLASS clearance. If \a aItem is NULL, then this objects
* clearance
* is returned.
* @param aItem is another BOARD_CONNECTED_ITEM or NULL
* @return int - the clearance in 1/10000 inches.
*/
*/
int D_PAD::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
{
int clearance = m_LocalClearance;
if ( clearance == 0 )
if( clearance == 0 )
{
if( GetParent() && ((MODULE*)GetParent())->m_LocalClearance )
clearance = ((MODULE*)GetParent())->m_LocalClearance;
if( GetParent() && ( (MODULE*) GetParent() )->m_LocalClearance )
clearance = ( (MODULE*) GetParent() )->m_LocalClearance;
}
if( clearance == 0 )
@ -247,6 +233,7 @@ int D_PAD::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
return clearance;
}
// Mask margins handling:
/** Function GetSolderMaskMargin
@ -260,19 +247,20 @@ int D_PAD::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
int D_PAD::GetSolderMaskMargin()
{
int margin = m_LocalSolderMaskMargin;
if ( margin == 0 )
if( margin == 0 )
{
if( GetParent() && ((MODULE*)GetParent())->m_LocalSolderMaskMargin )
margin = ((MODULE*)GetParent())->m_LocalSolderMaskMargin;
if( GetParent() && ( (MODULE*) GetParent() )->m_LocalSolderMaskMargin )
margin = ( (MODULE*) GetParent() )->m_LocalSolderMaskMargin;
}
if ( margin == 0 )
if( margin == 0 )
margin = g_DesignSettings.m_SolderMaskMargin;
// ensure mask have a size alwyas >= 0
// ensure mask have a size always >= 0
if( margin < 0 )
{
int minsize = - MIN( m_Size.x, m_Size.y) / 2;
if (margin < minsize )
int minsize = -MIN( m_Size.x, m_Size.y ) / 2;
if( margin < minsize )
minsize = minsize;
}
return margin;
@ -290,47 +278,45 @@ int D_PAD::GetSolderMaskMargin()
wxSize D_PAD::GetSolderPasteMargin()
{
int margin = m_LocalSolderPasteMargin;
if( margin == 0 && GetParent() )
margin = ((MODULE*)GetParent())->m_LocalSolderPasteMargin;
margin = ( (MODULE*) GetParent() )->m_LocalSolderPasteMargin;
if( margin == 0 && GetParent() )
margin = g_DesignSettings.m_SolderPasteMargin;
double mratio = m_LocalSolderPasteMarginRatio;
if( mratio == 0.0 && GetParent() )
mratio = ((MODULE*)GetParent())->m_LocalSolderPasteMarginRatio;
mratio = ( (MODULE*) GetParent() )->m_LocalSolderPasteMarginRatio;
if( mratio == 0.0 )
mratio = g_DesignSettings.m_SolderPasteMarginRatio;
wxSize pad_margin;
pad_margin.x = margin + wxRound(m_Size.x * mratio);
pad_margin.y = margin + wxRound(m_Size.y * mratio);
pad_margin.x = margin + wxRound( m_Size.x * mratio );
pad_margin.y = margin + wxRound( m_Size.y * mratio );
// ensure mask have a size alwyas >= 0
if (pad_margin.x < -m_Size.x/2 )
pad_margin.x = -m_Size.x/2;
// ensure mask have a size always >= 0
if( pad_margin.x < -m_Size.x / 2 )
pad_margin.x = -m_Size.x / 2;
if (pad_margin.y < -m_Size.y/2 )
pad_margin.y = -m_Size.y/2;
if( pad_margin.y < -m_Size.y / 2 )
pad_margin.y = -m_Size.y / 2;
return pad_margin;
}
/*************************************************/
int D_PAD::ReadDescr( FILE* File, int* LineNum )
/*************************************************/
/* Routine de lecture de descr de pads
* la 1ere ligne de descr ($PAD) est supposee etre deja lue
* syntaxe:
/* Read pad from file.
* The 1st line of descr ($PAD) is assumed to be already read
* Syntax:
* $PAD
* Sh "N1" C 550 550 0 0 1800
* Dr 310 0 0
* At STD N 00C0FFFF
* Ne 3 "netname"
* Do 3 "netname"
* Po 6000 -6000
* $EndPAD
*/
int D_PAD::ReadDescr( FILE* File, int* LineNum )
{
char Line[1024], BufLine[1024], BufCar[256];
char* PtLine;
@ -379,7 +365,7 @@ int D_PAD::ReadDescr( FILE* File, int* LineNum )
ll = 0xFF & BufCar[0];
/*Read pad shape */
/* Read pad shape */
m_PadShape = PAD_CIRCLE;
switch( ll )
@ -448,14 +434,14 @@ int D_PAD::ReadDescr( FILE* File, int* LineNum )
break;
case '.': /* Read specific data */
if( strnicmp(Line, ".SolderMask ", 12 ) == 0 )
m_LocalSolderMaskMargin = atoi(Line+12);
else if( strnicmp(Line, ".SolderPaste ", 13) == 0 )
m_LocalSolderPasteMargin = atoi(Line+13);
else if( strnicmp(Line, ".SolderPasteRatio ", 18 ) == 0 )
m_LocalSolderPasteMarginRatio = atoi(Line+18);
else if( strnicmp(Line, ".LocalClearance ", 16 ) == 0 )
m_LocalClearance = atoi(Line+16);
if( strnicmp( Line, ".SolderMask ", 12 ) == 0 )
m_LocalSolderMaskMargin = atoi( Line + 12 );
else if( strnicmp( Line, ".SolderPaste ", 13 ) == 0 )
m_LocalSolderPasteMargin = atoi( Line + 13 );
else if( strnicmp( Line, ".SolderPasteRatio ", 18 ) == 0 )
m_LocalSolderPasteMarginRatio = atoi( Line + 18 );
else if( strnicmp( Line, ".LocalClearance ", 16 ) == 0 )
m_LocalClearance = atoi( Line + 16 );
break;
default:
@ -468,9 +454,7 @@ int D_PAD::ReadDescr( FILE* File, int* LineNum )
}
/*************************************/
bool D_PAD::Save( FILE* aFile ) const
/*************************************/
{
int cshape;
const char* texttype;
@ -495,7 +479,7 @@ bool D_PAD::Save( FILE* aFile ) const
default:
cshape = 'C';
DisplayError( NULL, _( "Unknown Pad shape" ) );
DisplayError( NULL, _( "Unknown pad shape" ) );
break;
}
@ -537,13 +521,15 @@ bool D_PAD::Save( FILE* aFile ) const
fprintf( aFile, "Po %d %d\n", m_Pos0.x, m_Pos0.y );
if( m_LocalSolderMaskMargin != 0 )
fprintf( aFile, ".SolderMask %d\n",m_LocalSolderMaskMargin );
fprintf( aFile, ".SolderMask %d\n", m_LocalSolderMaskMargin );
if( m_LocalSolderPasteMargin != 0 )
fprintf( aFile, ".SolderPaste %d\n",m_LocalSolderPasteMargin);
if( m_LocalSolderPasteMarginRatio != 0)
fprintf( aFile, ".SolderPasteRatio %g\n",m_LocalSolderPasteMarginRatio);
fprintf( aFile, ".SolderPaste %d\n", m_LocalSolderPasteMargin );
if( m_LocalSolderPasteMarginRatio != 0 )
fprintf( aFile,
".SolderPasteRatio %g\n",
m_LocalSolderPasteMarginRatio );
if( m_LocalClearance != 0 )
fprintf( aFile, ".LocalClearance %d\n",m_LocalClearance );
fprintf( aFile, ".LocalClearance %d\n", m_LocalClearance );
if( fprintf( aFile, "$EndPAD\n" ) != sizeof("$EndPAD\n") - 1 )
return false;
@ -552,10 +538,7 @@ bool D_PAD::Save( FILE* aFile ) const
}
/******************************************************/
void D_PAD::DisplayInfo( WinEDA_DrawFrame* frame )
/******************************************************/
/* Affiche en bas d'ecran les caract de la pastille demandee */
{
int ii;
MODULE* module;
@ -563,13 +546,14 @@ void D_PAD::DisplayInfo( WinEDA_DrawFrame* frame )
/* Pad messages */
static const wxString Msg_Pad_Shape[6] =
{ wxT( "??? " ), wxT( "Circ" ), wxT( "Rect" ), wxT( "Oval" ), wxT( "trap" ), wxT( "spec" ) };
{ wxT( "??? " ), wxT( "Circ" ), wxT( "Rect" ), wxT( "Oval" ), wxT( "trap" ),
wxT( "spec" ) };
static const wxString Msg_Pad_Layer[9] =
{
wxT( "??? " ), wxT( "cmp " ), wxT( "cu " ), wxT( "cmp+cu " ), wxT(
"int " ),
wxT( "cmp+int " ), wxT( "cu+int " ), wxT( "all " ), wxT( "No copp" )
wxT( "??? " ), wxT( "cmp " ), wxT( "cu " ), wxT( "cmp+cu " ),
wxT( "int " ), wxT( "cmp+int " ), wxT( "cu+int " ),
wxT( "all " ), wxT( "No copp" )
};
static const wxString Msg_Pad_Attribut[5] =
@ -578,7 +562,6 @@ void D_PAD::DisplayInfo( WinEDA_DrawFrame* frame )
frame->EraseMsgBox();
/* Recherche du module correspondant */
module = (MODULE*) m_Parent;
if( module )
{
@ -589,9 +572,11 @@ void D_PAD::DisplayInfo( WinEDA_DrawFrame* frame )
}
frame->AppendMsgPanel( _( "Net" ), m_Netname, DARKCYAN );
/* For test and debug only: display m_physical_connexion and m_logical_connexion */
/* For test and debug only: display m_physical_connexion and
* m_logical_connexion */
#if 1 // Used only to debug connectivity calculations
Line.Printf( wxT( "%d-%d-%d " ), GetSubRatsnest(), GetSubNet(), m_ZoneSubnet );
Line.Printf( wxT( "%d-%d-%d " ), GetSubRatsnest(),
GetSubNet(), m_ZoneSubnet );
frame->AppendMsgPanel( wxT( "L-P-Z" ), Line, DARKGREEN );
#endif
@ -701,7 +686,8 @@ void D_PAD::DisplayInfo( WinEDA_DrawFrame* frame )
int module_orient = module ? module->m_Orient : 0;
if( module_orient )
Line.Printf( wxT( "%3.1f(+%3.1f)" ),
(float) ( m_Orient - module_orient ) / 10, (float) module_orient / 10 );
(float) ( m_Orient - module_orient ) / 10,
(float) module_orient / 10 );
else
Line.Printf( wxT( "%3.1f" ), (float) m_Orient / 10 );
frame->AppendMsgPanel( _( "Orient" ), Line, BLUE );
@ -738,16 +724,13 @@ bool D_PAD::HitTest( const wxPoint& ref_pos )
deltaX = ref_pos.x - shape_pos.x;
deltaY = ref_pos.y - shape_pos.y;
/* Test rapide: le point a tester doit etre a l'interieur du cercle exinscrit ... */
if( (abs( deltaX ) > m_Rayon )
|| (abs( deltaY ) > m_Rayon) )
/* Quick test: a test point must be inside the circle. */
if( ( abs( deltaX ) > m_Rayon ) || ( abs( deltaY ) > m_Rayon ) )
return false;
/* calcul des demi dim dx et dy */
dx = m_Size.x >> 1; // dx also is the radius for rounded pads
dy = m_Size.y >> 1;
/* localisation ? */
switch( m_PadShape & 0x7F )
{
case PAD_CIRCLE:
@ -757,7 +740,6 @@ bool D_PAD::HitTest( const wxPoint& ref_pos )
break;
default:
/* calcul des coord du point test dans le repere du Pad */
RotatePoint( &deltaX, &deltaY, -m_Orient );
if( (abs( deltaX ) <= dx ) && (abs( deltaY ) <= dy) )
return true;
@ -768,9 +750,7 @@ bool D_PAD::HitTest( const wxPoint& ref_pos )
}
/************************************************************/
int D_PAD::Compare( const D_PAD* padref, const D_PAD* padcmp )
/************************************************************/
{
int diff;
@ -790,8 +770,9 @@ int D_PAD::Compare( const D_PAD* padref, const D_PAD* padcmp )
return diff;
// @todo check if export_gencad still works:
// specctra_export needs this, but maybe export_gencad does not. added on Jan 24 2008 by Dick.
if( (diff = padref->m_Masque_Layer - padcmp->m_Masque_Layer) )
// specctra_export needs this, but maybe export_gencad does not. added on
// Jan 24 2008 by Dick.
if( ( diff = padref->m_Masque_Layer - padcmp->m_Masque_Layer ) )
return diff;
return 0;
@ -854,7 +835,8 @@ static const char* ShowPadAttr( int aPadAttr )
*/
void D_PAD::Show( int nestLevel, std::ostream& os )
{
char padname[5] = { m_Padname[0], m_Padname[1], m_Padname[2], m_Padname[3], 0 };
char padname[5] =
{ m_Padname[0], m_Padname[1], m_Padname[2], m_Padname[3], 0 };
char layerMask[16];
@ -871,7 +853,8 @@ void D_PAD::Show( int nestLevel, std::ostream& os )
// NestedSpace( nestLevel+1, os ) << m_Text.mb_str() << '\n';
// NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
// NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str()
// << ">\n";
}

View File

@ -6,7 +6,7 @@ class Pcb3D_GLCanvas;
#include "pad_shapes.h"
/* Default layers used for pads, accordint to the pad type.
/* Default layers used for pads, according to the pad type.
* this is default values only, they can be changed for a given pad
*/
@ -25,7 +25,6 @@ class Pcb3D_GLCanvas;
SOLDERMASK_LAYER_CU | SOLDERMASK_LAYER_CMP
/* Definition type Structure d'un pad */
class D_PAD : public BOARD_CONNECTED_ITEM
{
private:
@ -54,11 +53,11 @@ public:
wxSize m_Drill; // Drill diam (drill shape = PAD_CIRCLE) or drill size(shape = OVAL)
// for drill shape = PAD_CIRCLE, drill diam = m_Drill.x
wxSize m_Offset; /* This parameter is usefull only for oblong pads (it can be used for other
wxSize m_Offset; /* This parameter is useful only for oblong pads (it can be used for other
* shapes, but without any interest).
* this is the offset between the pad hole and the pad shape (you must
* understand here pad shape = copper area around the hole)
* Most of cases, the hole is the centre of the shape (m_Offset = 0).
* Most of cases, the hole is the center of the shape (m_Offset = 0).
* But some board designers use oblong pads with a hole moved to one of the
* oblong pad shape ends.
* In all cases the pad position is the pad hole.
@ -69,11 +68,11 @@ public:
wxSize m_Size; // X and Y size ( relative to orient 0)
wxSize m_DeltaSize; // delta sur formes rectangle -> trapezes
wxSize m_DeltaSize; // delta on rectangular shapes
wxPoint m_Pos0; // Initial Pad position (i.e. pas position relative to the module anchor, orientation 0
int m_Rayon; // rayon du cercle exinscrit du pad
int m_Rayon; // radius of pad circle
int m_Attribut; // NORMAL, PAD_SMD, PAD_CONN
int m_Orient; // in 1/10 degrees
@ -85,7 +84,7 @@ public:
// Local mask margins: when NULL, the parent footprint design values are used
int m_LocalSolderMaskMargin; // Local solder mask margin
int m_LocalSolderPasteMargin; // Local solder paste margin absolute value
double m_LocalSolderPasteMarginRatio; // Local solder pask margin ratio value of pad size
double m_LocalSolderPasteMarginRatio; // Local solder mask margin ratio value of pad size
// The final margin is the sum of these 2 values
private:
@ -169,7 +168,7 @@ public:
/** Function GetSolderPasteMargin
* @return the margin for the solder mask layer
* usually < 0 (mask shape smaller than pad
* because the margin can be dependant on the pad size, the margin has a x and a y value
* because the margin can be dependent on the pad size, the margin has a x and a y value
* value is
* 1 - the local value
* 2 - if null, the parent footprint value
@ -199,8 +198,8 @@ public:
void SetPadName( const wxString& name ); // Change pad name
wxString ReturnStringPadName(); // Return pad name as string in a wxString
void ReturnStringPadName( wxString& text ); // Return pad name as string in a buffer
void ComputeRayon(); // compute m_Rayon, rayon du cercle exinscrit
const wxPoint ReturnShapePos(); // retourne la position
void ComputeRayon(); // compute radius
const wxPoint ReturnShapePos();
/**
@ -254,7 +253,7 @@ public:
/**
* Function GetBoundingBox
* returns the bounding box of this pad
* Mainly used to redraw the screen area occuped by the pad
* Mainly used to redraw the screen area occupied by the pad
*/
EDA_Rect GetBoundingBox();

View File

@ -1,6 +1,6 @@
/*******************************************************/
/* class_pad_draw_function.cpp : functionsto draw pads */
/*******************************************************/
/*******************************/
/* class_pad_draw_function.cpp */
/*******************************/
#include "fctsys.h"
#include "gr_basic.h"
@ -14,16 +14,13 @@
#include "class_board_design_settings.h"
/*******************************************************************************************/
void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
const wxPoint& offset )
/*******************************************************************************************/
/** Draw a pad:
* @param DC = device context
* @param offset = draw offset
* @param draw_mode = mode: GR_OR, GR_XOR, GR_AND...
*/
void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
const wxPoint& offset )
{
int ii;
int color = 0;
@ -123,7 +120,8 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
// if PAD_SMD pad and high contrast mode
if( (m_Attribut==PAD_SMD || m_Attribut==PAD_CONN) && DisplayOpt.ContrastModeDisplay )
if( ( m_Attribut == PAD_SMD || m_Attribut == PAD_CONN )
&& DisplayOpt.ContrastModeDisplay )
{
// when routing tracks
if( frame && frame->m_ID_current_state == ID_TRACK_BUTT )
@ -134,8 +132,10 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
// if routing between copper and component layers,
// or the current layer is one of said 2 external copper layers,
// then highlight only the current layer.
if( ( (1 << routeTop) | (1 << routeBot) ) == (CUIVRE_LAYER | CMP_LAYER)
|| ( (1 << screen->m_Active_Layer) & (CUIVRE_LAYER | CMP_LAYER) ) )
if( ( ( 1 << routeTop ) | ( 1 << routeBot ) )
== ( CUIVRE_LAYER | CMP_LAYER )
|| ( ( 1 << screen->m_Active_Layer )
& ( CUIVRE_LAYER | CMP_LAYER ) ) )
{
if( !IsOnLayer( screen->m_Active_Layer ) )
{
@ -143,9 +143,9 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
color |= DARKDARKGRAY;
}
}
// else routing between an internal signal layer and some other layer.
// grey out all PAD_SMD pads not on current or the single selected
// external layer.
// else routing between an internal signal layer and some other
// layer. Grey out all PAD_SMD pads not on current or the single
// selected external layer.
else if( !IsOnLayer( screen->m_Active_Layer )
&& !IsOnLayer( routeTop )
&& !IsOnLayer( routeBot ) )
@ -154,7 +154,8 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
color |= DARKDARKGRAY;
}
}
// when not edting tracks, show PAD_SMD components not on active layer as greyed out
// when not edting tracks, show PAD_SMD components not on active layer
// as greyed out
else
{
if( !IsOnLayer( screen->m_Active_Layer ) )
@ -165,16 +166,18 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
}
}
// if Contrast mode is ON and a technical layer active, show pads on this layer
// so we can see pads on paste or solder layer and the size of the mask
if( DisplayOpt.ContrastModeDisplay && screen->m_Active_Layer > LAST_COPPER_LAYER )
// if Contrast mode is ON and a technical layer active, show pads on this
// layer so we can see pads on paste or solder layer and the size of the
// mask
if( DisplayOpt.ContrastModeDisplay
&& screen->m_Active_Layer > LAST_COPPER_LAYER )
{
if( IsOnLayer( screen->m_Active_Layer ) )
{
color = g_DesignSettings.m_LayerColor[screen->m_Active_Layer];
// In hight contrast mode, and if the active layer is the mask layer
// shows the pad size with the mask clearance
// In hight contrast mode, and if the active layer is the mask
// layer shows the pad size with the mask clearance
switch( screen->m_Active_Layer )
{
case SOLDERMASK_N_CU:
@ -228,9 +231,9 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
SetAlpha( &color, 170 );
/* Get the pad clearance. This has a meaning only for Pcbnew.
* for Cvpcb (and Gerbview) GetClearance() creates debug errors because there is no
* net classes so a call to GetClearance() is made only when needed
* (never needed in Cvpcb nor in Gerbview)
* for Cvpcb (and Gerbview) GetClearance() creates debug errors because
* there is no net classes so a call to GetClearance() is made only when
* needed (never needed in Cvpcb nor in Gerbview)
*/
int padClearance = DisplayIsol ? GetClearance() : 0;
@ -238,9 +241,11 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
{
case PAD_CIRCLE:
if( fillpad )
GRFilledCircle( &panel->m_ClipBox, DC, xc, yc, dx + mask_margin.x, 0, color, color );
GRFilledCircle( &panel->m_ClipBox, DC, xc, yc,
dx + mask_margin.x, 0, color, color );
else
GRCircle( &panel->m_ClipBox, DC, xc, yc, dx + mask_margin.x, 0, color );
GRCircle( &panel->m_ClipBox, DC, xc, yc, dx + mask_margin.x,
0, color );
if( DisplayIsol )
{
@ -255,18 +260,17 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
break;
case PAD_OVAL:
/* calcul de l'entraxe de l'ellipse */
if( dx > dy ) /* ellipse horizontale */
if( dx > dy ) /* horizontal */
{
delta_cx = dx - dy;
delta_cy = 0;
rotdx = m_Size.y + (mask_margin.y*2);
rotdx = m_Size.y + ( mask_margin.y * 2 );
}
else /* ellipse verticale */
else /* vertical */
{
delta_cx = 0;
delta_cy = dy - dx;
rotdx = m_Size.x + (mask_margin.x*2);
rotdx = m_Size.x + ( mask_margin.x * 2 );
}
RotatePoint( &delta_cx, &delta_cy, angle );
@ -285,7 +289,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
rotdx, color );
}
/* Trace de la marge d'isolement */
/* Draw the isolation line. */
if( DisplayIsol )
{
rotdx = rotdx + 2 * padClearance;
@ -300,8 +304,8 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
case PAD_TRAPEZOID:
{
int ddx, ddy;
ddx = (m_DeltaSize.x >> 1);
ddy = (m_DeltaSize.y >> 1); /* demi dim dx et dy */
ddx = ( m_DeltaSize.x >> 1 );
ddy = ( m_DeltaSize.y >> 1 );
coord[0].x = -dx - ddy - mask_margin.x;
coord[0].y = +dy + ddx + mask_margin.y;
@ -383,30 +387,32 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
switch( m_DrillShape )
{
case PAD_CIRCLE:
if( screen->Scale( hole ) > 1 ) /* draw hole if its size is enought */
GRFilledCircle( &panel->m_ClipBox, DC, cx0, cy0, hole, 0, color, color );
if( screen->Scale( hole ) > 1 ) /* draw hole if its size is enought
*/
GRFilledCircle( &panel->m_ClipBox, DC, cx0, cy0, hole, 0,
color, color );
break;
case PAD_OVAL:
dx = m_Drill.x >> 1;
dy = m_Drill.y >> 1; /* demi dim dx et dy */
dy = m_Drill.y >> 1;
/* calcul de l'entraxe de l'ellipse */
if( m_Drill.x > m_Drill.y ) /* ellipse horizontale */
if( m_Drill.x > m_Drill.y ) /* horizontal */
{
delta_cx = dx - dy; delta_cy = 0;
delta_cx = dx - dy;
delta_cy = 0;
rotdx = m_Drill.y;
}
else /* ellipse verticale */
else /* vertical */
{
delta_cx = 0; delta_cy = dy - dx;
delta_cx = 0;
delta_cy = dy - dx;
rotdx = m_Drill.x;
}
RotatePoint( &delta_cx, &delta_cy, angle );
GRFillCSegm( &panel->m_ClipBox, DC, cx0 + delta_cx, cy0 + delta_cy,
cx0 - delta_cx, cy0 - delta_cy,
rotdx, color );
cx0 - delta_cx, cy0 - delta_cy, rotdx, color );
break;
default:
@ -419,17 +425,17 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
GRSetDrawMode( DC, draw_mode );
/* Trace du symbole "No connect" ( / ou \ ou croix en X) si necessaire : */
/* Draw "No connect" ( / or \ or cross X ) if necessary. : */
if( m_Netname.IsEmpty() && DisplayOpt.DisplayPadNoConn )
{
dx0 = MIN( dx0, dy0 );
int nc_color = BLUE;
if( m_Masque_Layer & CMP_LAYER ) /* Trace forme \ */
if( m_Masque_Layer & CMP_LAYER ) /* Draw \ */
GRLine( &panel->m_ClipBox, DC, cx0 - dx0, cy0 - dx0,
cx0 + dx0, cy0 + dx0, 0, nc_color );
if( m_Masque_Layer & CUIVRE_LAYER ) /* Trace forme / */
if( m_Masque_Layer & CUIVRE_LAYER ) /* Draw / */
GRLine( &panel->m_ClipBox, DC, cx0 + dx0, cy0 - dx0,
cx0 - dx0, cy0 + dx0, 0, nc_color );
}
@ -440,7 +446,8 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
display_padnum = false;
bool display_netname = true;
if( (DisplayOpt.DisplayNetNamesMode == 0) || (DisplayOpt.DisplayNetNamesMode == 2) )
if( ( DisplayOpt.DisplayNetNamesMode == 0 )
|| ( DisplayOpt.DisplayNetNamesMode == 2 ) )
display_netname = false;
if( !display_padnum && !display_netname )
@ -448,7 +455,8 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
wxPoint tpos0 = wxPoint( ux0, uy0 ); // Position of the centre of text
wxPoint tpos = tpos0;
wxSize AreaSize; // size of text area, normalized to AreaSize.y < AreaSize.x
wxSize AreaSize; // size of text area, normalized to
// AreaSize.y < AreaSize.x
int shortname_len = m_ShortNetname.Len();
if( !display_netname )
shortname_len = 0;
@ -462,22 +470,26 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
AreaSize.y = m_Size.x;
}
if( shortname_len > 0 ) // if there is a netname, provides room to display this netname
if( shortname_len > 0 ) // if there is a netname, provides room
// to display this netname
{
AreaSize.y /= 2; // Text used only the upper area of the pad. The lower area displays the net name
AreaSize.y /= 2; // Text used only the upper area of the
// pad. The lower area displays the net
// name
tpos.y -= AreaSize.y / 2;
}
// Calculate the position of text, that is the middle point of the upper area of the pad
// Calculate the position of text, that is the middle point of the upper
// area of the pad
RotatePoint( &tpos, wxPoint( ux0, uy0 ), angle );
/* Draw text with an angle between -90 deg and + 90 deg */
int t_angle = angle;
NORMALIZE_ANGLE_90( t_angle );
/* Note: in next calculations, texte size is calculated for 3 or more chars.
* Of course, pads numbers and nets names can have less than 3 chars.
* but after some tries, i found this is gives the best look
/* Note: in next calculations, texte size is calculated for 3 or more
* chars. Of course, pads numbers and nets names can have less than 3
* chars. but after some tries, i found this is gives the best look
*/
#define MIN_CHAR_COUNT 3
wxString buffer;
@ -491,15 +503,17 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
tsize = min( AreaSize.y, AreaSize.x / numpad_len );
#define CHAR_SIZE_MIN 5
if( screen->Scale( tsize ) >= CHAR_SIZE_MIN ) // Not drawable when size too small.
if( screen->Scale( tsize ) >= CHAR_SIZE_MIN ) // Not drawable when
// size too small.
{
tsize = (int) ( tsize * 0.8 ); // reserve room for marges and segments thickness
tsize = (int) ( tsize * 0.8 ); // reserve room for
// marges and segments
// thickness
DrawGraphicText( panel, DC, tpos,
WHITE, buffer, t_angle, wxSize( tsize,
tsize ),
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize / 7, false,
false, false );
DrawGraphicText( panel, DC, tpos, WHITE, buffer, t_angle,
wxSize( tsize, tsize ), GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_CENTER, tsize / 7, false, false,
false );
}
}
@ -510,20 +524,22 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
shortname_len = MAX( shortname_len, MIN_CHAR_COUNT );
tsize = min( AreaSize.y, AreaSize.x / shortname_len );
if( screen->Scale( tsize ) >= CHAR_SIZE_MIN ) // Not drawable in size too small.
if( screen->Scale( tsize ) >= CHAR_SIZE_MIN ) // Not drawable in size too
// small.
{
if( !(!IsOnLayer( screen->m_Active_Layer )&& DisplayOpt.ContrastModeDisplay) )
if( !( !IsOnLayer( screen->m_Active_Layer )
&& DisplayOpt.ContrastModeDisplay ) )
{
tpos = tpos0;
if( display_padnum )
tpos.y += AreaSize.y / 2;
RotatePoint( &tpos, wxPoint( ux0, uy0 ), angle );
tsize = (int) ( tsize * 0.8 ); // reserve room for marges and segments thickness
DrawGraphicText( panel, DC, tpos,
WHITE, m_ShortNetname, t_angle, wxSize( tsize, tsize ),
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize / 7,
false, false );
tsize = (int) ( tsize * 0.8 ); // reserve room for marges and
// segments thickness
DrawGraphicText( panel, DC, tpos, WHITE, m_ShortNetname, t_angle,
wxSize( tsize, tsize ), GR_TEXT_HJUSTIFY_CENTER,
GR_TEXT_VJUSTIFY_CENTER, tsize / 7, false, false );
}
}
}

View File

@ -28,13 +28,11 @@ TEXTE_PCB::TEXTE_PCB( BOARD_ITEM* parent ) :
}
/* Destructeur */
TEXTE_PCB:: ~TEXTE_PCB()
{
}
/* copie de stucture */
void TEXTE_PCB::Copy( TEXTE_PCB* source )
{
m_Parent = source->m_Parent;
@ -56,31 +54,28 @@ void TEXTE_PCB::Copy( TEXTE_PCB* source )
}
/****************************************************************/
int TEXTE_PCB::ReadTextePcbDescr( FILE* File, int* LineNum )
/****************************************************************/
/** Function ReadTextePcbDescr
* Read a pcb text description
* The format is like:
* $TEXTPCB
* Te "Text example"
* Po 66750 53450 600 800 150 0
* De 24 1 0 Italic
* $EndTEXTPCB
* for a single line text
* Read a text description from pcb file.
*
* or
* For a single line text:
*
* $TEXTPCB
* Te "Text example"
* nl "ligne 2"
* Po 66750 53450 600 800 150 0
* De 24 1 0 Italic
* From 24 1 0 Italic
* $EndTEXTPCB
* for a multi line text
* nl "ligne nn" is a line added to the current text
*
* For a multi line text
*
* $TEXTPCB
* Te "Text example"
* Nl "Line 2"
* Po 66750 53450 600 800 150 0
* From 24 1 0 Italic
* $EndTEXTPCB
* Nl "line nn" is a line added to the current text
*/
int TEXTE_PCB::ReadTextePcbDescr( FILE* File, int* LineNum )
{
char text[1024], Line[1024];
char style[256];
@ -137,7 +132,7 @@ int TEXTE_PCB::ReadTextePcbDescr( FILE* File, int* LineNum )
}
}
// Set a reasonnable width:
// Set a reasonable width:
if( m_Width < 1 )
m_Width = 1;
m_Width = Clamp_Text_PenSize( m_Width, m_Size );
@ -146,9 +141,7 @@ int TEXTE_PCB::ReadTextePcbDescr( FILE* File, int* LineNum )
}
/*****************************************/
bool TEXTE_PCB::Save( FILE* aFile ) const
/*****************************************/
{
if( GetState( DELETED ) )
return true;
@ -185,17 +178,14 @@ bool TEXTE_PCB::Save( FILE* aFile ) const
}
/**********************************************************************/
void TEXTE_PCB::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
int DrawMode, const wxPoint& offset )
/**********************************************************************/
/** Function Draw
* DrawMode = GR_OR, GR_XOR ..
* Like tracks, texts are drawn in filled or sketch mode, never in line mode
* because the line mode does not keep the actual size of the text
* and the actual size is very important, especially for copper texts
*/
void TEXTE_PCB::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
int DrawMode, const wxPoint& offset )
{
if( g_DesignSettings.IsLayerVisible( m_Layer ) == false )
return;
@ -206,10 +196,7 @@ void TEXTE_PCB::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
if ( DisplayOpt.DisplayDrawItems == SKETCH)
fillmode = SKETCH;
EDA_TextStruct::Draw(
panel, DC,
offset,
(EDA_Colors) color,
EDA_TextStruct::Draw( panel, DC, offset, (EDA_Colors) color,
DrawMode, fillmode,
g_DesignSettings.IsElementVisible( ANCHOR_VISIBLE ) ?
(EDA_Colors) g_AnchorColor : UNSPECIFIED_COLOR );
@ -260,6 +247,7 @@ void TEXTE_PCB::DisplayInfo( WinEDA_DrawFrame* frame )
frame->AppendMsgPanel( _( "V Size" ), msg, RED );
}
/**
* Function Rotate
* Rotate this object.
@ -276,6 +264,7 @@ void TEXTE_PCB::Rotate(const wxPoint& aRotCentre, int aAngle)
m_Orient += 3600;
}
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
@ -283,17 +272,16 @@ void TEXTE_PCB::Rotate(const wxPoint& aRotCentre, int aAngle)
*/
void TEXTE_PCB::Flip(const wxPoint& aCentre )
{
m_Pos.y = aCentre.y - (m_Pos.y - aCentre.y);
m_Pos.y = aCentre.y - ( m_Pos.y - aCentre.y );
NEGATE( m_Orient );
if( (GetLayer() == COPPER_LAYER_N) || (GetLayer() == CMP_N) )
if( ( GetLayer() == COPPER_LAYER_N ) || ( GetLayer() == CMP_N ) )
{
m_Mirror = not m_Mirror; /* inverse miroir */
m_Mirror = not m_Mirror; /* inverse mirror */
}
SetLayer( ChangeSideNumLayer( GetLayer() ) );
}
#if defined(DEBUG)
/**
@ -309,7 +297,8 @@ void TEXTE_PCB::Show( int nestLevel, std::ostream& os )
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() <<
" string=\"" << m_Text.mb_str() << "\"/>\n";
// NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
// NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str()
// << ">\n";
}

View File

@ -1,6 +1,6 @@
/************************************/
/* fonctions de la classe TEXTE_PCB */
/************************************/
/********************************/
/* TEXTE_PCB class definition. */
/********************************/
#ifndef CLASS_PCB_TEXT_H
#define CLASS_PCB_TEXT_H
@ -52,14 +52,16 @@ public:
/* duplicate structure */
void Copy( TEXTE_PCB* source );
void Draw( WinEDA_DrawPanel * panel, wxDC* DC, int aDrawMode, const wxPoint& offset = ZeroOffset );
void Draw( WinEDA_DrawPanel * panel, wxDC* DC, int aDrawMode,
const wxPoint& offset = ZeroOffset );
// File Operations:
int ReadTextePcbDescr( FILE* File, int* LineNum );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* writes the data structures for this object out to a FILE in "*.brd"
* format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
@ -88,7 +90,7 @@ public:
/**
* Function HitTest (overlayed)
* Function HitTest (overlaid)
* tests if the given EDA_Rect intersect this object.
* @param refArea the given EDA_Rect to test
* @return bool - true if a hit, else false

View File

@ -1,6 +1,6 @@
/****************************************************/
/* class_module.cpp : fonctions de la classe MODULE */
/****************************************************/
/********************************************************/
/* class_module.cpp : TEXT_MODULE class implementation. */
/********************************************************/
#include "fctsys.h"
#include "gr_basic.h"
@ -14,16 +14,10 @@
#include "pcbcommon.h"
#include "class_board_design_settings.h"
//#include "autorout.h"
//#include "drag.h"
//#include "protos.h"
/*******************************************************************/
/* Class TEXTE_MODULE base class type of text elements in a module */
/*******************************************************************/
/************************************************************************/
/* Class TEXTE_MODULE classe de base des elements type Texte sur module */
/************************************************************************/
/* Constructeur de TEXTE_MODULE */
TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, int text_type ) :
BOARD_ITEM( parent, TYPE_TEXTE_MODULE ), EDA_TextStruct ()
{
@ -34,10 +28,11 @@ TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, int text_type ) :
m_Type = TEXT_is_DIVERS;
m_NoShow = false;
m_Size.x = m_Size.y = 400; m_Width = 120; /* dimensions raisonnables par defaut */
m_Size.x = m_Size.y = 400;
m_Width = 120; /* Set default dimension to a reasonable value. */
SetLayer( SILKSCREEN_N_CMP );
if( Module && (Module->Type() == TYPE_MODULE) )
if( Module && ( Module->Type() == TYPE_MODULE ) )
{
m_Pos = Module->m_Pos;
@ -65,16 +60,13 @@ TEXTE_MODULE::~TEXTE_MODULE()
}
/*******************************************/
bool TEXTE_MODULE::Save( FILE* aFile ) const
/*******************************************/
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool TEXTE_MODULE::Save( FILE* aFile ) const
{
MODULE* parent = (MODULE*) GetParent();
int orient = m_Orient;
@ -99,9 +91,6 @@ bool TEXTE_MODULE::Save( FILE* aFile ) const
}
/*********************************************************************/
int TEXTE_MODULE::ReadDescr( char* aLine, FILE* aFile, int* aLineNum )
/*********************************************************************/
/**
* Function ReadLineDescr
* Read description from a given line in "*.brd" format.
@ -110,6 +99,7 @@ int TEXTE_MODULE::ReadDescr( char* aLine, FILE* aFile, int* aLineNum )
* @param LineNum a point to the line count (currently not used).
* @return int - > 0 if success reading else 0.
*/
int TEXTE_MODULE::ReadDescr( char* aLine, FILE* aFile, int* aLineNum )
{
int success = true;
int type;
@ -149,7 +139,7 @@ int TEXTE_MODULE::ReadDescr( char* aLine, FILE* aFile, int* aLineNum )
else
m_Italic = false;
// Test for a reasonnable layer:
// Test for a reasonable layer:
if( layer < 0 )
layer = 0;
if( layer > LAST_NO_COPPER_LAYER )
@ -161,19 +151,19 @@ int TEXTE_MODULE::ReadDescr( char* aLine, FILE* aFile, int* aLineNum )
SetLayer( layer );
/* calcul de la position vraie */
/* Calculate the true position. */
SetDrawCoord();
/* Lecture de la chaine "text" */
/* Read the "text" string. */
ReadDelimitedText( BufLine, aLine, sizeof(BufLine) );
m_Text = CONV_FROM_UTF8( BufLine );
// Test for a reasonnable size:
// Test for a reasonable size:
if( m_Size.x < TEXTS_MIN_SIZE )
m_Size.x = TEXTS_MIN_SIZE;
if( m_Size.y < TEXTS_MIN_SIZE )
m_Size.y = TEXTS_MIN_SIZE;
// Set a reasonnable width:
// Set a reasonable width:
if( m_Width < 1 )
m_Width = 1;
m_Width = Clamp_Text_PenSize( m_Width, m_Size );
@ -182,11 +172,7 @@ int TEXTE_MODULE::ReadDescr( char* aLine, FILE* aFile, int* aLineNum )
}
/**********************************************/
void TEXTE_MODULE::Copy( TEXTE_MODULE* source )
/**********************************************/
// copy structure
{
if( source == NULL )
return;
@ -194,39 +180,32 @@ void TEXTE_MODULE::Copy( TEXTE_MODULE* source )
m_Pos = source->m_Pos;
SetLayer( source->GetLayer() );
m_Mirror = source->m_Mirror; // Show normal / mirror
m_NoShow = source->m_NoShow; // 0: visible 1: invisible
m_Type = source->m_Type; // 0: ref,1: val, others = 2..255
m_Orient = source->m_Orient; // orientation in 1/10 deg
m_Pos0 = source->m_Pos0; // text coordinates relatives to the footprint ancre, orient 0
// Text coordinate ref point is the text centre
m_Mirror = source->m_Mirror;
m_NoShow = source->m_NoShow;
m_Type = source->m_Type;
m_Orient = source->m_Orient;
m_Pos0 = source->m_Pos0;
m_Size = source->m_Size;
m_Width = source->m_Width;
m_Italic = source->m_Italic;
m_Bold = source->m_Bold;
m_Text = source->m_Text;
}
/******************************************/
int TEXTE_MODULE:: GetLength()
/******************************************/
{
return m_Text.Len();
}
/******************************************/
void TEXTE_MODULE:: SetWidth( int new_width )
/******************************************/
{
m_Width = new_width;
}
// Update draw ccordinates
// Update draw coordinates
void TEXTE_MODULE:: SetDrawCoord()
{
MODULE* Module = (MODULE*) m_Parent;
@ -244,7 +223,8 @@ void TEXTE_MODULE:: SetDrawCoord()
}
// Update "local" cooedinates (coordinates relatives to the footprint anchor point)
// Update "local" coordinates (coordinates relatives to the footprint
// anchor point)
void TEXTE_MODULE:: SetLocalCoord()
{
MODULE* Module = (MODULE*) m_Parent;
@ -264,10 +244,9 @@ void TEXTE_MODULE:: SetLocalCoord()
}
/* locate functions */
/** Function GetTextRect
* @return an EDA_Rect which gives the position and size of the text area (for the O orient footprint)
* @return an EDA_Rect which gives the position and size of the text area
* (for the footprint orientation)
*/
EDA_Rect TEXTE_MODULE::GetTextRect( void )
{
@ -280,7 +259,7 @@ EDA_Rect TEXTE_MODULE::GetTextRect( void )
dx += m_Width / 2;
dy = ( m_Size.y + m_Width ) / 2;
wxPoint Org = m_Pos; // This is the position of the centre of the area
wxPoint Org = m_Pos; // This is the position of the center of the area
Org.x -= dx;
Org.y -= dy;
area.SetOrigin( Org );
@ -304,7 +283,8 @@ bool TEXTE_MODULE::HitTest( const wxPoint& refPos )
EDA_Rect area = GetTextRect();
/* Rotate refPos to - angle
* to test if refPos is within area (which is relative to an horizontal text)
* to test if refPos is within area (which is relative to an horizontal
* text)
*/
rel_pos = refPos;
RotatePoint( &rel_pos, m_Pos, -GetDrawRotation() );
@ -318,11 +298,12 @@ bool TEXTE_MODULE::HitTest( const wxPoint& refPos )
/**
* Function GetBoundingBox
* returns the bounding box of this Text (according to text and footprint orientation)
* returns the bounding box of this Text (according to text and footprint
* orientation)
*/
EDA_Rect TEXTE_MODULE::GetBoundingBox()
{
// Calculate area without text fielsd:
// Calculate area without text fields:
EDA_Rect text_area;
int angle = GetDrawRotation();
wxPoint textstart, textend;
@ -340,21 +321,19 @@ EDA_Rect TEXTE_MODULE::GetBoundingBox()
}
/******************************************************************************************/
void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoint& offset )
/******************************************************************************************/
/** Function Draw
* Draw the text accordint to the footprint pos and orient
* Draw the text according to the footprint pos and orient
* @param panel = draw panel, Used to know the clip box
* @param DC = Current Device Context
* @param offset = draw offset (usually wxPoint(0,0)
* @param draw_mode = GR_OR, GR_XOR..
*/
void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
const wxPoint& offset )
{
int width, color, orient;
wxSize size;
wxPoint pos; // Centre du texte
wxPoint pos; // Center of text
PCB_SCREEN* screen;
WinEDA_BasePcbFrame* frame;
MODULE* Module = (MODULE*) m_Parent;
@ -373,7 +352,7 @@ void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const
orient = GetDrawRotation();
width = m_Width;
if( (frame->m_DisplayModText == FILAIRE)
if( ( frame->m_DisplayModText == FILAIRE )
|| ( screen->Scale( width ) < L_MIN_DESSIN ) )
width = 0;
else if( frame->m_DisplayModText == SKETCH )
@ -381,8 +360,7 @@ void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const
GRSetDrawMode( DC, draw_mode );
/* trace du centre du texte */
if( g_DesignSettings.IsElementVisible( ANCHOR_VISIBLE ))
if( g_DesignSettings.IsElementVisible( ANCHOR_VISIBLE ) )
{
int anchor_size = screen->Unscale( 2 );
GRLine( &panel->m_ClipBox, DC,
@ -422,18 +400,14 @@ void TEXTE_MODULE::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const
if( m_Mirror )
size.x = -size.x;
/* Trace du texte */
DrawGraphicText( panel, DC, pos, (enum EDA_Colors) color, m_Text,
orient, size, m_HJustify, m_VJustify, width, m_Italic, m_Bold);
DrawGraphicText( panel, DC, pos, (enum EDA_Colors) color, m_Text, orient,
size, m_HJustify, m_VJustify, width, m_Italic, m_Bold );
}
/******************************************/
int TEXTE_MODULE::GetDrawRotation()
/******************************************/
/* Return text rotation for drawings and plotting
*/
int TEXTE_MODULE::GetDrawRotation()
{
int rotation;
MODULE* Module = (MODULE*) m_Parent;
@ -444,7 +418,8 @@ int TEXTE_MODULE::GetDrawRotation()
NORMALIZE_ANGLE_POS( rotation );
// if( (rotation > 900 ) && (rotation < 2700 ) ) rotation -= 1800; // For angle = 0 .. 180 deg
// For angle = 0 .. 180 deg
// if( (rotation > 900 ) && (rotation < 2700 ) ) rotation -= 1800;
while( rotation > 900 )
rotation -= 1800;
@ -563,7 +538,8 @@ void TEXTE_MODULE::Show( int nestLevel, std::ostream& os )
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() <<
" string=\"" << m_Text.mb_str() << "\"/>\n";
// NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
// NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str()
// << ">\n";
}

View File

@ -7,7 +7,6 @@
#define TEXT_MODULE_H
/* Description des Textes sur Modules : */
#define TEXT_is_REFERENCE 0
#define TEXT_is_VALUE 1
#define TEXT_is_DIVERS 2
@ -17,15 +16,15 @@ class TEXTE_MODULE : public BOARD_ITEM, public EDA_TextStruct
{
/* Note: orientation in 1/10 deg relative to the footprint
* Physical orient is m_Orient + m_Parent->m_Orient
*/
*/
public:
wxPoint m_Pos0; // text coordinates relatives to the footprint ancre, orient 0
wxPoint m_Pos0; // text coordinates relatives to the footprint
// ancre, orient 0
// Text coordinate ref point is the text centre
char m_Type; // 0: ref,1: val, others = 2..255
bool m_NoShow; // true = invisible
public:
TEXTE_MODULE( MODULE* parent, int text_type = TEXT_is_DIVERS );
public: TEXTE_MODULE( MODULE* parent, int text_type = TEXT_is_DIVERS );
~TEXTE_MODULE();
TEXTE_MODULE* Next() const { return (TEXTE_MODULE*) Pnext; }
@ -42,33 +41,36 @@ public:
return m_Pos;
}
void Copy( TEXTE_MODULE* source ); // copy structure
/* Gestion du texte */
void SetWidth( int new_width );
int GetLength(); /* text length */
int GetDrawRotation(); // Return text rotation for drawings and plotting
int GetDrawRotation(); // Return text rotation for drawings and
// plotting
/** Function GetTextRect
* @return an EDA_Rect which gives the position and size of the text area (for the 0 orient text and footprint)
* @return an EDA_Rect which gives the position and size of the text area
* (for the 0 orient text and footprint)
*/
EDA_Rect GetTextRect( void );
/**
* Function GetBoundingBox
* returns the bounding box of this Text (according to text and footprint orientation)
* returns the bounding box of this Text (according to text and footprint
* orientation)
*/
EDA_Rect GetBoundingBox();
void SetDrawCoord(); // mise a jour des coordonn<6E>s absolues de trac<61>
void SetDrawCoord(); // Set absolute coordinates.
// a partir des coord relatives
void SetLocalCoord(); // mise a jour des coordonn<6E>s relatives
void SetLocalCoord(); // Set relative coordinates.
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* writes the data structures for this object out to a FILE in "*.brd"
* format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
@ -77,7 +79,8 @@ public:
/**
* Function ReadLineDescr
* Read description from a given line in "*.brd" format.
* @param aLine The current line which contains the first line of description.
* @param aLine The current line which contains the first line of
* description.
* @param aLine The FILE to read next lines (currently not used).
* @param LineNum a point to the line count (currently not used).
* @return int - > 0 if success reading else 0.
@ -93,8 +96,8 @@ public:
/**
* Function DisplayInfo
* has knowledge about the frame and how and where to put status information
* about this object into the frame's message panel.
* has knowledge about the frame and how and where to put status
* information about this object into the frame's message panel.
* Is virtual from EDA_BaseStruct.
* @param frame A WinEDA_DrawFrame in which to print status information.
*/
@ -122,8 +125,8 @@ public:
/**
* Function IsOnOneOfTheseLayers
* returns true if this object is on one of the given layers. Is virtual so
* objects like D_PAD, which reside on multiple layers, can do their own
* returns true if this object is on one of the given layers. Is virtual
* so objects like D_PAD, which reside on multiple layers, can do their own
* form of testing.
* virtual inheritance from BOARD_ITEM.
* @param aLayerMask The bit-mapped set of layers to test for.
@ -143,7 +146,7 @@ public:
}
#if defined (DEBUG)
#if defined(DEBUG)
/**
* Function Show

View File

@ -1067,7 +1067,7 @@ bool TRACK::HitTest( const wxPoint& ref_pos )
int spot_cX = ref_pos.x - m_Start.x;
int spot_cY = ref_pos.y - m_Start.y;
if( Type() == TYPE_VIA ) /* VIA rencontree */
if( Type() == TYPE_VIA )
{
return (double) spot_cX * spot_cX + (double) spot_cY * spot_cY <=
(double) radius * radius;

View File

@ -1,7 +1,7 @@
/**********************************************************************/
/* fonctions membres des classes utilisees dans pcbnew (voir pcbstruct.h */
/* sauf routines relatives aux pistes (voir class_track.cpp) */
/**********************************************************************/
/****************************************************************/
/* member functions of classes used in pcbnew (see pcbstruct.h) */
/* except for tracks (see class_track.cpp) */
/****************************************************************/
#include "fctsys.h"