Commit 0120f07d authored by CHARRAS's avatar CHARRAS

code cleaning

parent 1fb25193
......@@ -133,7 +133,6 @@ public:
*/
BOARD_ITEM* PcbGeneralLocateAndDisplay( int aHotKeyCode = 0 );
BOARD_ITEM* Locate( int typeloc, int LayerSearch );
void ProcessItemSelection( wxCommandEvent& event );
/**
......
......@@ -566,11 +566,11 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
}
}
for ( unsigned ii = 0; ii < m_Pcb->m_ZoneDescriptorList.size(); ii++ )
for ( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{
if( m_Pcb->m_ZoneDescriptorList[ii]->HitTest( GetScreen()->BlockLocate ) )
if( m_Pcb->GetArea(ii)->HitTest( GetScreen()->BlockLocate ) )
{
m_Pcb->Delete(m_Pcb->m_ZoneDescriptorList[ii]);
m_Pcb->Delete(m_Pcb->GetArea(ii));
ii--; // because the current data was removed, ii points actually the next data
}
}
......@@ -666,11 +666,11 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC )
}
track = track->Next();
}
for ( unsigned ii = 0; ii < m_Pcb->m_ZoneDescriptorList.size(); ii++ )
for ( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{
if( m_Pcb->m_ZoneDescriptorList[ii]->HitTest( GetScreen()->BlockLocate ) )
if( m_Pcb->GetArea(ii)->HitTest( GetScreen()->BlockLocate ) )
{
m_Pcb->m_ZoneDescriptorList[ii]->Rotate(centre, 900);
m_Pcb->GetArea(ii)->Rotate(centre, 900);
}
}
}
......@@ -842,12 +842,12 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC )
}
track = (TRACK*) track->Pnext;
}
for ( unsigned ii = 0; ii < m_Pcb->m_ZoneDescriptorList.size(); ii++ )
for ( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{
if( m_Pcb->m_ZoneDescriptorList[ii]->HitTest( GetScreen()->BlockLocate ) )
if( m_Pcb->GetArea(ii)->HitTest( GetScreen()->BlockLocate ) )
{
m_Pcb->m_ZoneDescriptorList[ii]->Mirror( wxPoint(0, centerY) );
m_Pcb->m_ZoneDescriptorList[ii]->SetLayer( ChangeSideNumLayer( m_Pcb->m_ZoneDescriptorList[ii]->GetLayer() ) );
m_Pcb->GetArea(ii)->Mirror( wxPoint(0, centerY) );
m_Pcb->GetArea(ii)->SetLayer( ChangeSideNumLayer( m_Pcb->GetArea(ii)->GetLayer() ) );
}
}
}
......@@ -1012,11 +1012,11 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC )
}
track = (TRACK*) track->Pnext;
}
for ( unsigned ii = 0; ii < m_Pcb->m_ZoneDescriptorList.size(); ii++ )
for ( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{
if( m_Pcb->m_ZoneDescriptorList[ii]->HitTest( GetScreen()->BlockLocate ) )
if( m_Pcb->GetArea(ii)->HitTest( GetScreen()->BlockLocate ) )
{
m_Pcb->m_ZoneDescriptorList[ii]->Move( MoveVector );
m_Pcb->GetArea(ii)->Move( MoveVector );
}
}
}
......@@ -1176,25 +1176,25 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
{
if( segzone->HitTest( GetScreen()->BlockLocate ) )
{
/* la piste est ici bonne a etre dupliquee */
new_segzone = (SEGZONE*) segzone->Copy();
new_segzone->Insert( m_Pcb, NULL );
new_segzone->m_Start += MoveVector;
new_segzone->m_End += MoveVector;
new_segzone->Draw( DrawPanel, DC, GR_OR ); // reaffichage
new_segzone->Draw( DrawPanel, DC, GR_OR );
}
segzone = segzone->Next();
}
unsigned imax = m_Pcb->m_ZoneDescriptorList.size();
unsigned imax = m_Pcb->GetAreaCount();
for ( unsigned ii = 0; ii < imax; ii++ )
{
if( m_Pcb->m_ZoneDescriptorList[ii]->HitTest( GetScreen()->BlockLocate ) )
if( m_Pcb->GetArea(ii)->HitTest( GetScreen()->BlockLocate ) )
{
ZONE_CONTAINER * new_zone = new ZONE_CONTAINER(m_Pcb);
new_zone->Copy( m_Pcb->m_ZoneDescriptorList[ii] );
new_zone->Copy( m_Pcb->GetArea(ii) );
new_zone->m_TimeStamp = GetTimeStamp();
new_zone->Move( MoveVector );
m_Pcb->m_ZoneDescriptorList.push_back(new_zone);
m_Pcb->Add(new_zone);
new_zone->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
}
}
......
......@@ -118,6 +118,12 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl )
m_markers.push_back( (MARKER*) aBoardItem );
break;
// this one uses a vector
case TYPEZONE_CONTAINER:
aBoardItem->m_Parent = this;
m_ZoneDescriptorList.push_back( (ZONE_CONTAINER*) aBoardItem );
break;
// other types may use linked list
default:
wxFAIL_MSG( wxT("BOARD::Add() needs work") );
......
......@@ -19,8 +19,6 @@ class BOARD : public BOARD_ITEM
private:
std::vector<MARKER*> m_markers; ///< MARKERs for clearance problems, owned by pointer
public:
std::vector<ZONE_CONTAINER*> m_ZoneDescriptorList; ///< edge zone descriptors, owned by pointer
public:
......@@ -225,6 +223,30 @@ public:
#endif
/* Copper Areas handling */
/**
* Function GetArea
* returns the Area (Zone Container) at a given index.
* @param index The array type index into a collection of ZONE_CONTAINER *.
* @return ZONE_CONTAINER* - a pointer to the Area or NULL if index out of range.
*/
ZONE_CONTAINER* GetArea( int index ) const
{
if( (unsigned) index < m_ZoneDescriptorList.size() )
return m_ZoneDescriptorList[index];
return NULL;
}
/**
* Function GetAreaCount
* @return int - The number of Areas or ZONE_CONTAINER.
*/
int GetAreaCount() const
{
return (int) m_ZoneDescriptorList.size();
}
/* Functions used in test, merge and cut outlines */
/**
* Function AddArea
......
......@@ -530,17 +530,17 @@ void ZONE_CONTAINER::Mirror( const wxPoint& mirror_ref)
/** Function copy
* copy data from the source.
* flags and some poinetrs are NOT copied
* copy usefull data from the source.
* flags and linked list pointers are NOT copied
*/
void ZONE_CONTAINER::Copy( ZONE_CONTAINER * src )
{
m_Parent = src->m_Parent;
m_Layer = src->m_Layer;
SetNet(src->GetNet());
m_TimeStamp = GetTimeStamp();
m_TimeStamp = src->m_TimeStamp;
m_Poly->Copy(src->m_Poly); // copy outlines
m_CornerSelection = -1; // For corner moving, corner index to drag, or -1 if no selection
m_CornerSelection = -1; // For corner moving, corner index to drag, or -1 if no selection
m_ZoneClearance = src->m_ZoneClearance; // clearance value
m_GridFillValue = src->m_GridFillValue; // Grid used for filling
m_PadOption = src->m_PadOption;
......
......@@ -45,8 +45,8 @@ public:
void UnLink(void) {};
/** Function copy
* copy data from the source.
* flags and some poinetrs are NOT copied
* copy usefull data from the source.
* flags and linked list pointers are NOT copied
*/
void Copy( ZONE_CONTAINER * src );
......
This diff is collapsed.
......@@ -138,15 +138,6 @@ D_PAD * Locate_Pads(MODULE * Module, const wxPoint & ref_pos,int layer) ;
pointeur NULL si pastille non trouvee
*/
TEXTE_MODULE * LocateTexteModule(BOARD * Pcb, MODULE ** Module, int typeloc);
/* localisation du texte pointe par la souris (texte sur empreinte)
si Module == NULL; recherche sur tous les modules
sinon sur le module pointe par Module
retourne
- pointeur sur le texte localise ( ou NULL )
- pointeur sur module Module ( non modifie sinon ) */
MODULE * Locate_Prefered_Module(BOARD * Pcb, int typeloc);
/* localisation d'une empreinte par son rectangle d'encadrement */
......@@ -160,25 +151,12 @@ D_PAD * Locate_Pads(MODULE * Module, int typeloc);
pointeur NULL si pastille non trouvee
*/
EDGE_MODULE * Locate_Edge_Module(MODULE * Module, int typeloc);
/* Localisation de segments de contour du type edge MODULE
Les contours sont de differents type:
simple, Arcs de cercles, box.
Retourne:
Pointeur sur DEBUT du segment localise
NULL si rien trouve
*/
TRACK * Locate_Pistes(TRACK * start_adresse, int typeloc);
/* routine de localisation du segment de piste pointe par la souris
La recherche commence a l'adresse start_adresse */
DRAWSEGMENT * Locate_Segment_Pcb(BOARD * Pcb, int LayerSearch , int typeloc) ;
TEXTE_PCB * Locate_Texte_Pcb(EDA_BaseStruct * PtStruct, int LayerSearch , int typeloc);
/* localisation des inscriptions sur le Pcb:
la recherche se fait a partir de l'adresse pr_texte */
D_PAD * Fast_Locate_Pad_Connecte(BOARD * Pcb, const wxPoint & ref_pos, int layer);
/* Routine cherchant le pad contenant le point px,py, sur la couche layer
......@@ -203,12 +181,6 @@ TRACK * Locate_Zone(TRACK * start_adresse, const wxPoint & ref_pos,int layer);
La recherche commence a l'adresse start_adresse
*/
COTATION* Locate_Cotation(BOARD * Pcb, int LayerSearch, int typeloc);
/* Localise un element de cotation, en priorite sur la couche active,
et a defaut sur les autres couches
retourne un pointeur sur l'element (TRACK ou TEXTE_PCB) localise
sinon retiurne NULL */
/*************/
/* MODULES.C */
......
......@@ -299,17 +299,17 @@ void WinEDA_PcbFrame::End_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_conta
/* Combine zones if possible */
int layer = zone_container->GetLayer();
for( unsigned ii = 0; ii < m_Pcb->m_ZoneDescriptorList.size(); ii++ )
for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{
ZONE_CONTAINER* edge_zone = m_Pcb->m_ZoneDescriptorList[ii];
ZONE_CONTAINER* edge_zone = m_Pcb->GetArea(ii);
if( layer == edge_zone->GetLayer() )
edge_zone->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
}
m_Pcb->AreaPolygonModified( zone_container, true, false );
for( unsigned ii = 0; ii < m_Pcb->m_ZoneDescriptorList.size(); ii++ )
for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{
ZONE_CONTAINER* edge_zone = m_Pcb->m_ZoneDescriptorList[ii];
ZONE_CONTAINER* edge_zone = m_Pcb->GetArea(ii);
if( layer == edge_zone->GetLayer() )
edge_zone->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
}
......@@ -336,9 +336,9 @@ void WinEDA_PcbFrame::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER * zone_contai
if ( DC )
{
for( unsigned ii = 0; ii < m_Pcb->m_ZoneDescriptorList.size(); ii++ )
for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{
ZONE_CONTAINER* edge_zone = m_Pcb->m_ZoneDescriptorList[ii];
ZONE_CONTAINER* edge_zone = m_Pcb->GetArea(ii);
if( layer == edge_zone->GetLayer() )
edge_zone->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
}
......@@ -350,9 +350,9 @@ void WinEDA_PcbFrame::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER * zone_contai
m_Pcb->AreaPolygonModified( zone_container, true, false );
if ( DC )
{
for( unsigned ii = 0; ii < m_Pcb->m_ZoneDescriptorList.size(); ii++ )
for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{
ZONE_CONTAINER* edge_zone = m_Pcb->m_ZoneDescriptorList[ii];
ZONE_CONTAINER* edge_zone = m_Pcb->GetArea(ii);
if( layer == edge_zone->GetLayer() )
edge_zone->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
}
......@@ -429,15 +429,15 @@ EDGE_ZONE* WinEDA_PcbFrame::Begin_Zone( wxDC* DC )
EDGE_ZONE* newedge = NULL;
// verify if s_CurrentZone exists:
unsigned ii;
int ii;
for( ii = 0; ii < m_Pcb->m_ZoneDescriptorList.size(); ii++ )
for( ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{
if( s_CurrentZone == m_Pcb->m_ZoneDescriptorList[ii] )
if( s_CurrentZone == m_Pcb->GetArea(ii) )
break;
}
if( ii == m_Pcb->m_ZoneDescriptorList.size() ) // Not found: coul be deleted since last selection
if( ii == m_Pcb->GetAreaCount() ) // Not found: coul be deleted since last selection
{
s_AddCutoutToCurrentZone = false;
s_CurrentZone = NULL;
......@@ -568,9 +568,9 @@ void WinEDA_PcbFrame::End_Zone( wxDC* DC )
DrawPanel->ForceCloseManageCurseur = NULL;
// Undraw old drawings, because they can have important changes
for( unsigned ii = 0; ii < m_Pcb->m_ZoneDescriptorList.size(); ii++ )
for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{
ZONE_CONTAINER* edge_zone = m_Pcb->m_ZoneDescriptorList[ii];
ZONE_CONTAINER* edge_zone = m_Pcb->GetArea(ii);
if( layer == edge_zone->GetLayer() )
edge_zone->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
}
......@@ -629,9 +629,9 @@ void WinEDA_PcbFrame::End_Zone( wxDC* DC )
m_Pcb->AreaPolygonModified( new_zone_container, true, false );
// Redraw the real edge zone :
for( unsigned ii = 0; ii < m_Pcb->m_ZoneDescriptorList.size(); ii++ )
for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{
ZONE_CONTAINER* edge_zone = m_Pcb->m_ZoneDescriptorList[ii];
ZONE_CONTAINER* edge_zone = m_Pcb->GetArea(ii);
if( layer == edge_zone->GetLayer() )
edge_zone->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
}
......@@ -712,9 +712,9 @@ void WinEDA_PcbFrame::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container
return;
// Undraw old zone outlines
for( unsigned ii = 0; ii < m_Pcb->m_ZoneDescriptorList.size(); ii++ )
for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{
ZONE_CONTAINER* edge_zone = m_Pcb->m_ZoneDescriptorList[ii];
ZONE_CONTAINER* edge_zone = m_Pcb->GetArea(ii);
edge_zone->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR );
}
......@@ -732,9 +732,9 @@ void WinEDA_PcbFrame::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container
m_Pcb->AreaPolygonModified( zone_container, true, false );
// Redraw the real new zone outlines:
for( unsigned ii = 0; ii < m_Pcb->m_ZoneDescriptorList.size(); ii++ )
for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{
ZONE_CONTAINER* edge_zone = m_Pcb->m_ZoneDescriptorList[ii];
ZONE_CONTAINER* edge_zone = m_Pcb->GetArea(ii);
edge_zone->m_Flags = 0;
edge_zone->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_OR );
}
......@@ -867,9 +867,9 @@ int WinEDA_PcbFrame::Fill_All_Zones( wxDC* DC, bool verbose )
m_Pcb->m_NbSegmZone = 0;
}
for( unsigned ii = 0; ii < m_Pcb->m_ZoneDescriptorList.size(); ii++ )
for( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{
zone_container = m_Pcb->m_ZoneDescriptorList[ii];
zone_container = m_Pcb->GetArea(ii);
error_level = Fill_Zone( NULL, zone_container, verbose );
if( error_level && !verbose )
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment