Commit 6f2c09c6 authored by CHARRAS's avatar CHARRAS

code cleaning

parent e3a3d16a
......@@ -3,6 +3,12 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
email address.
2007-Dec-14 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+pcbnew:
code cleaning:
DRAWSEGMENT class functions moved in the new files class_drawsegment.cpp et .h
2007-Dec-12 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
......
......@@ -37,6 +37,7 @@ SET(CVPCB_EXTRA_SRCS
../pcbnew/basepcbframe.cpp
../pcbnew/class_board.cpp
../pcbnew/class_cotation.cpp
../pcbnew/class_drawsegment.cpp
../pcbnew/class_edge_mod.cpp
../pcbnew/class_equipot.cpp
../pcbnew/class_mire.cpp
......
......@@ -40,6 +40,7 @@ OBJECTS = $(TARGET).o \
zoom.o \
tracemod.o \
classpcb.o \
class_drawsegment.o \
class_board.o \
class_module.o \
class_pad.o \
......@@ -86,6 +87,9 @@ class_pcb_text.o: ../pcbnew/class_pcb_text.cpp ../pcbnew/class_pcb_text.h $(COMM
class_board.o: ../pcbnew/class_board.cpp $(DEPEND)
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp
class_drawsegment.o: ../pcbnew/class_drawsegment.cpp ../pcbnew/class_drawsegment.h $(DEPEND)
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp
class_track.o: ../pcbnew/class_track.cpp $(DEPEND)
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp
......
......@@ -42,6 +42,7 @@ SET(GERBVIEW_SRCS
SET(GERBVIEW_EXTRA_SRCS
../pcbnew/basepcbframe.cpp
../pcbnew/class_board.cpp
../pcbnew/class_drawsegment.cpp
../pcbnew/class_drc_item.cpp
../pcbnew/class_marker.cpp
../pcbnew/class_pcb_text.cpp
......
......@@ -22,6 +22,7 @@ OBJECTS= \
gerberframe.o\
onrightclick.o\
class_board.o\
class_drawsegment.o\
class_track.o \
class_drc_item.o \
drawframe.o\
......@@ -77,6 +78,9 @@ class_marker.o: ../pcbnew/class_marker.cpp ../pcbnew/class_marker.h $(COMMON)
class_zone.o: ../pcbnew/class_zone.cpp ../pcbnew/class_zone.h $(COMMON)
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp
class_drawsegment.o: ../pcbnew/class_drawsegment.cpp ../pcbnew/class_drawsegment.h $(DEPEND)
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp
class_drc_item.o: ../pcbnew/class_drc_item.cpp $(COMMON)
$(CXX) -c $(EDACPPFLAGS) -o $@ ../pcbnew/$*.cpp
......
......@@ -250,89 +250,7 @@ public:
/* Description des elements du PCB */
/***********************************/
class DRAWSEGMENT : public BOARD_ITEM
{
public:
int m_Width; // 0 = line. if > 0 = tracks, bus ...
wxPoint m_Start; // Line start point
wxPoint m_End; // Line end point
int m_Shape; // Shape: line, Circle, Arc
int m_Type; // Used in complex associations ( Dimensions.. )
int m_Angle; // Used only for Arcs: Arc angle in 1/10 deg
public:
DRAWSEGMENT( BOARD_ITEM* StructFather, KICAD_T idtype = TYPEDRAWSEGMENT );
~DRAWSEGMENT();
/**
* Function GetPosition
* returns the position of this object.
* Required by pure virtual BOARD_ITEM::GetPosition()
* @return const wxPoint& - The position of this object.
*/
wxPoint& GetPosition()
{
return m_Start;
}
/**
* 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 Save( FILE* aFile ) const;
bool ReadDrawSegmentDescr( FILE* File, int* LineNum );
/* remove this from the linked list */
void UnLink();
void Copy( DRAWSEGMENT* source );
/**
* Function Display_Infos
* 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_BasePcbFrame in which to print status information.
*/
void Display_Infos( WinEDA_DrawFrame* frame );
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
* @param ref_pos A wxPoint to test
* @return bool - true if a hit, else false
*/
bool HitTest( const wxPoint& ref_pos );
/**
* Function HitTest (overlayed)
* tests if the given EDA_Rect intersect this object.
* For now, an ending point must be inside this rect.
* @param refPos the given EDA_Rect to test
* @return bool - true if a hit, else false
*/
bool HitTest( EDA_Rect& refArea );
/**
* Function GetClass
* returns the class name.
* @return wxString
*/
wxString GetClass() const
{
return wxT("DRAWSEGMENT");
}
};
#include "class_drawsegment.h"
#include "class_pcb_text.h"
#include "class_cotation.h"
#include "class_mire.h"
......
......@@ -23,6 +23,7 @@ SET(PCBNEW_SRCS
class_board.cpp
class_board_item.cpp
class_cotation.cpp
class_drawsegment.cpp
class_drc_item.cpp
class_edge_mod.cpp
class_equipot.cpp
......
/***************************************************/
/* class and functions to handle a graphic segment */
/****************************************************/
#include "fctsys.h"
#include "wxstruct.h"
#include "gr_basic.h"
#include "common.h"
#include "pcbnew.h"
#ifdef CVPCB
#include "cvpcb.h"
#endif
#include "trigo.h"
/* DRAWSEGMENT: constructor */
DRAWSEGMENT::DRAWSEGMENT( BOARD_ITEM* StructFather, KICAD_T idtype ) :
BOARD_ITEM( StructFather, idtype )
{
m_Width = m_Flags = m_Shape = m_Type = m_Angle = 0;
}
/* destructor */
DRAWSEGMENT:: ~DRAWSEGMENT()
{
}
void DRAWSEGMENT::UnLink()
/**
* Function UnLink
* remove item from linked list.
*/
{
/* ereas back link */
if( Pback )
{
if( Pback->Type() != TYPEPCB )
{
Pback->Pnext = Pnext;
}
else /* Le chainage arriere pointe sur la structure "Pere" */
{
( (BOARD*) Pback )->m_Drawings = (BOARD_ITEM*) Pnext;
}
}
/* erase forward link */
if( Pnext )
Pnext->Pback = Pback;
Pnext = Pback = NULL;
}
/*******************************************/
void DRAWSEGMENT::Copy( DRAWSEGMENT* source )
/*******************************************/
{
m_Type = source->m_Type;
m_Layer = source->m_Layer;
m_Width = source->m_Width;
m_Start = source->m_Start;
m_End = source->m_End;
m_Shape = source->m_Shape;
m_Angle = source->m_Angle;
m_TimeStamp = source->m_TimeStamp;
}
bool DRAWSEGMENT::Save( FILE* aFile ) const
{
if( GetState( DELETED ) )
return true;
bool rc = false;
if( fprintf( aFile, "$DRAWSEGMENT\n" ) != sizeof("$DRAWSEGMENT\n") - 1 )
goto out;
fprintf( aFile, "Po %d %d %d %d %d %d\n",
m_Shape,
m_Start.x, m_Start.y,
m_End.x, m_End.y, m_Width );
fprintf( aFile, "De %d %d %d %lX %X\n",
m_Layer, m_Type, m_Angle,
m_TimeStamp, ReturnStatus() );
if( fprintf( aFile, "$EndDRAWSEGMENT\n" ) != sizeof("$EndDRAWSEGMENT\n") - 1 )
goto out;
rc = true;
out:
return rc;
}
/******************************************************************/
bool DRAWSEGMENT::ReadDrawSegmentDescr( FILE* File, int* LineNum )
/******************************************************************/
/* Read a DRAWSEGMENT from a file
*/
{
char Line[2048];
while( GetLine( File, Line, LineNum ) != NULL )
{
if( strnicmp( Line, "$End", 4 ) == 0 )
return TRUE; /* End of description */
if( Line[0] == 'P' )
{
sscanf( Line + 2, " %d %d %d %d %d %d",
&m_Shape, &m_Start.x, &m_Start.y,
&m_End.x, &m_End.y, &m_Width );
if( m_Width < 0 )
m_Width = 0;
}
if( Line[0] == 'D' )
{
int status;
sscanf( Line + 2, " %d %d %d %lX %X",
&m_Layer, &m_Type, &m_Angle,
&m_TimeStamp, &status );
if( m_Layer < FIRST_NO_COPPER_LAYER )
m_Layer = FIRST_NO_COPPER_LAYER;
if( m_Layer > LAST_NO_COPPER_LAYER )
m_Layer = LAST_NO_COPPER_LAYER;
SetState( status, ON );
}
}
return FALSE;
}
// see pcbstruct.h
void DRAWSEGMENT::Display_Infos( WinEDA_DrawFrame* frame )
{
int itype;
wxString msg;
frame->MsgPanel->EraseMsgBox();
itype = m_Type & 0x0F;
msg = wxT( "DRAWING" );
Affiche_1_Parametre( frame, 1, _( "Type" ), msg, DARKCYAN );
Affiche_1_Parametre( frame, 16, _( "Shape" ), wxEmptyString, RED );
if( m_Shape == S_CIRCLE )
Affiche_1_Parametre( frame, -1, wxEmptyString, _( "Circle" ), RED );
else if( m_Shape == S_ARC )
{
Affiche_1_Parametre( frame, -1, wxEmptyString, _( " Arc " ), RED );
msg.Printf( wxT( "%d" ), m_Angle );
Affiche_1_Parametre( frame, 32, wxT( " l.arc " ), msg, RED );
}
else
Affiche_1_Parametre( frame, -1, wxEmptyString, _( "Segment" ), RED );
Affiche_1_Parametre( frame, 48, _( "Layer" ),
ReturnPcbLayerName( m_Layer ), BROWN );
valeur_param( (unsigned) m_Width, msg );
Affiche_1_Parametre( frame, 60, _( "Width" ), msg, DARKCYAN );
}
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
* @param ref_pos A wxPoint to test
* @return bool - true if a hit, else false
*/
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 */
int dx = m_End.x - ux0;
int dy = m_End.y - uy0;
int spot_cX = ref_pos.x - ux0;
int spot_cY = ref_pos.y - uy0;
if( m_Shape==S_CIRCLE || m_Shape==S_ARC )
{
int rayon, dist, stAngle, endAngle, mouseAngle;
rayon = (int) hypot( (double) (dx), (double) (dy) );
dist = (int) hypot( (double) (spot_cX), (double) (spot_cY) );
if( abs( rayon - dist ) <= (m_Width / 2) )
{
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;
if( endAngle > 3600 )
{
stAngle -= 3600;
endAngle -= 3600;
}
if( mouseAngle >= stAngle && mouseAngle <= endAngle )
return true;
}
}
else
{
if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) )
return true;
}
return false;
}
/**
* Function HitTest (overlayed)
* tests if the given EDA_Rect intersect this object.
* For now, an ending point must be inside this rect.
* @param refArea : the given EDA_Rect
* @return bool - true if a hit, else false
*/
bool DRAWSEGMENT::HitTest( EDA_Rect& refArea )
{
if( refArea.Inside( m_Start ) )
return true;
if( refArea.Inside( m_End ) )
return true;
return false;
}
/*************************************/
/* class to handle a graphic segment */
/**************************************/
#ifndef CLASS_DRAWSEGMENT_H
#define CLASS_DRAWSEGMENT_H
class DRAWSEGMENT : public BOARD_ITEM
{
public:
int m_Width; // 0 = line. if > 0 = tracks, bus ...
wxPoint m_Start; // Line start point
wxPoint m_End; // Line end point
int m_Shape; // Shape: line, Circle, Arc
int m_Type; // Used in complex associations ( Dimensions.. )
int m_Angle; // Used only for Arcs: Arc angle in 1/10 deg
public:
DRAWSEGMENT( BOARD_ITEM* StructFather, KICAD_T idtype = TYPEDRAWSEGMENT );
~DRAWSEGMENT();
/**
* Function GetPosition
* returns the position of this object.
* Required by pure virtual BOARD_ITEM::GetPosition()
* @return const wxPoint& - The position of this object.
*/
wxPoint& GetPosition()
{
return m_Start;
}
/**
* 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 Save( FILE* aFile ) const;
bool ReadDrawSegmentDescr( FILE* File, int* LineNum );
/* remove this from the linked list */
void UnLink();
void Copy( DRAWSEGMENT* source );
/**
* Function Display_Infos
* 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_BasePcbFrame in which to print status information.
*/
void Display_Infos( WinEDA_DrawFrame* frame );
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
* @param ref_pos A wxPoint to test
* @return bool - true if a hit, else false
*/
bool HitTest( const wxPoint& ref_pos );
/**
* Function HitTest (overlayed)
* tests if the given EDA_Rect intersect this object.
* For now, an ending point must be inside this rect.
* @param refPos the given EDA_Rect to test
* @return bool - true if a hit, else false
*/
bool HitTest( EDA_Rect& refArea );
/**
* Function GetClass
* returns the class name.
* @return wxString
*/
wxString GetClass() const
{
return wxT( "DRAWSEGMENT" );
}
};
#endif // #ifndef CLASS_DRAWSEGMENT_H
......@@ -19,8 +19,6 @@
#include "trigo.h"
/**************************************************************/
void EDA_BaseStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC )
/**************************************************************/
......@@ -32,242 +30,6 @@ void EDA_BaseStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC )
}
/**********************/
/* Classe DRAWSEGMENT */
/**********************/
/* Classe DRAWSEGMENT: constructeur */
DRAWSEGMENT::DRAWSEGMENT( BOARD_ITEM* StructFather, KICAD_T idtype ) :
BOARD_ITEM( StructFather, idtype )
{
m_Width = m_Flags = m_Shape = m_Type = m_Angle = 0;
}
/* Effacement memoire de la structure */
DRAWSEGMENT:: ~DRAWSEGMENT()
{
}
void DRAWSEGMENT::UnLink()
{
/* Modification du chainage arriere */
if( Pback )
{
if( Pback->Type() != TYPEPCB )
{
Pback->Pnext = Pnext;
}
else /* Le chainage arriere pointe sur la structure "Pere" */
{
( (BOARD*) Pback )->m_Drawings = (BOARD_ITEM*) Pnext;
}
}
/* Modification du chainage avant */
if( Pnext )
Pnext->Pback = Pback;
Pnext = Pback = NULL;
}
/*******************************************/
void DRAWSEGMENT::Copy( DRAWSEGMENT* source )
/*******************************************/
{
m_Type = source->m_Type;
m_Layer = source->m_Layer;
m_Width = source->m_Width;
m_Start = source->m_Start;
m_End = source->m_End;
m_Shape = source->m_Shape;
m_Angle = source->m_Angle;
m_TimeStamp = source->m_TimeStamp;
}
bool DRAWSEGMENT::Save( FILE* aFile ) const
{
if( GetState( DELETED ) )
return true;
bool rc = false;
if( fprintf( aFile, "$DRAWSEGMENT\n" ) != sizeof("$DRAWSEGMENT\n")-1 )
goto out;
fprintf( aFile, "Po %d %d %d %d %d %d\n",
m_Shape,
m_Start.x, m_Start.y,
m_End.x, m_End.y, m_Width );
fprintf( aFile, "De %d %d %d %lX %X\n",
m_Layer, m_Type, m_Angle,
m_TimeStamp, ReturnStatus() );
if( fprintf( aFile, "$EndDRAWSEGMENT\n" ) != sizeof("$EndDRAWSEGMENT\n")-1 )
goto out;
rc = true;
out:
return rc;
}
/******************************************************************/
bool DRAWSEGMENT::ReadDrawSegmentDescr( FILE* File, int* LineNum )
/******************************************************************/
/* Lecture de la description de 1 segment type Drawing PCB
*/
{
char Line[2048];
while( GetLine( File, Line, LineNum ) != NULL )
{
if( strnicmp( Line, "$End", 4 ) == 0 )
return TRUE; /* fin de liste */
if( Line[0] == 'P' )
{
sscanf( Line + 2, " %d %d %d %d %d %d",
&m_Shape, &m_Start.x, &m_Start.y,
&m_End.x, &m_End.y, &m_Width );
if( m_Width < 0 )
m_Width = 0;
}
if( Line[0] == 'D' )
{
int status;
sscanf( Line + 2, " %d %d %d %lX %X",
&m_Layer, &m_Type, &m_Angle,
&m_TimeStamp, &status );
if( m_Layer < FIRST_NO_COPPER_LAYER )
m_Layer = FIRST_NO_COPPER_LAYER;
if( m_Layer > LAST_NO_COPPER_LAYER )
m_Layer = LAST_NO_COPPER_LAYER;
SetState( status, ON );
}
}
return FALSE;
}
// see pcbstruct.h
void DRAWSEGMENT::Display_Infos( WinEDA_DrawFrame* frame )
{
int itype;
wxString msg;
frame->MsgPanel->EraseMsgBox();
itype = m_Type & 0x0F;
msg = wxT( "DRAWING" );
Affiche_1_Parametre( frame, 1, _( "Type" ), msg, DARKCYAN );
Affiche_1_Parametre( frame, 16, _( "Shape" ), wxEmptyString, RED );
if( m_Shape == S_CIRCLE )
Affiche_1_Parametre( frame, -1, wxEmptyString, _( "Circle" ), RED );
else if( m_Shape == S_ARC )
{
Affiche_1_Parametre( frame, -1, wxEmptyString, _( " Arc " ), RED );
msg.Printf( wxT( "%d" ), m_Angle );
Affiche_1_Parametre( frame, 32, wxT( " l.arc " ), msg, RED );
}
else
Affiche_1_Parametre( frame, -1, wxEmptyString, _( "Segment" ), RED );
Affiche_1_Parametre( frame, 48, _( "Layer" ),
ReturnPcbLayerName( m_Layer ), BROWN );
/* Affiche Epaisseur */
valeur_param( (unsigned) m_Width, msg );
Affiche_1_Parametre( frame, 60, _( "Width" ), msg, DARKCYAN );
}
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
* @param ref_pos A wxPoint to test
* @return bool - true if a hit, else false
*/
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 */
int dx = m_End.x - ux0;
int dy = m_End.y - uy0;
int spot_cX = ref_pos.x - ux0;
int spot_cY = ref_pos.y - uy0;
if( m_Shape==S_CIRCLE || m_Shape==S_ARC )
{
int rayon, dist, stAngle, endAngle, mouseAngle;
rayon = (int) hypot( (double) (dx), (double) (dy) );
dist = (int) hypot( (double) (spot_cX), (double) (spot_cY) );
if( abs( rayon - dist ) <= (m_Width / 2) )
{
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;
if( endAngle > 3600 )
{
stAngle -= 3600;
endAngle -= 3600;
}
if( mouseAngle >= stAngle && mouseAngle <= endAngle )
return true;
}
}
else
{
if( DistanceTest( m_Width / 2, dx, dy, spot_cX, spot_cY ) )
return true;
}
return false;
}
/**
* Function HitTest (overlayed)
* tests if the given EDA_Rect intersect this object.
* For now, an ending point must be inside this rect.
* @param refArea : the given EDA_Rect
* @return bool - true if a hit, else false
*/
bool DRAWSEGMENT::HitTest( EDA_Rect& refArea )
{
if( refArea.Inside( m_Start ) )
return true;
if( refArea.Inside( m_End ) )
return true;
return false;
}
/**************************************************/
/* Class SCREEN: classe de gestion d'un affichage */
/***************************************************/
......@@ -295,11 +57,11 @@ void PCB_SCREEN::Init()
/*************************/
{
InitDatas();
m_Active_Layer = COPPER_LAYER_N; /* ref couche active 0.. 31 */
m_Route_Layer_TOP = CMP_N; /* ref couches par defaut pour vias (Cu.. Cmp) */
m_Active_Layer = COPPER_LAYER_N; /* ref couche active 0.. 31 */
m_Route_Layer_TOP = CMP_N; /* ref couches par defaut pour vias (Cu.. Cmp) */
m_Route_Layer_BOTTOM = COPPER_LAYER_N;
m_Zoom = 128; /* valeur */
m_Grid = wxSize( 500, 500 ); /* pas de la grille en 1/10000 "*/
m_Zoom = 128; /* valeur */
m_Grid = wxSize( 500, 500 ); /* pas de la grille en 1/10000 "*/
}
......@@ -309,23 +71,24 @@ void PCB_SCREEN::Init()
* It is mainly used to connect BGA to the first inner layer
* And it is allowed from an external layer to the first inner layer
*/
bool PCB_SCREEN::IsMicroViaAcceptable(void)
{
int copperlayercnt = g_DesignSettings.m_CopperLayerCount;
if ( ! g_DesignSettings.m_MicroViasAllowed )
return false; // Obvious..
if ( copperlayercnt < 4 )
return false; // Only on multilayer boards..
if ( (m_Active_Layer == COPPER_LAYER_N) ||
(m_Active_Layer == LAYER_CMP_N) ||
(m_Active_Layer == g_DesignSettings.m_CopperLayerCount - 2) ||
(m_Active_Layer == LAYER_N_2) )
return true;
return false;
bool PCB_SCREEN::IsMicroViaAcceptable( void )
{
int copperlayercnt = g_DesignSettings.m_CopperLayerCount;
if( !g_DesignSettings.m_MicroViasAllowed )
return false; // Obvious..
if( copperlayercnt < 4 )
return false; // Only on multilayer boards..
if( (m_Active_Layer == COPPER_LAYER_N)
|| (m_Active_Layer == LAYER_CMP_N)
|| (m_Active_Layer == g_DesignSettings.m_CopperLayerCount - 2)
|| (m_Active_Layer == LAYER_N_2) )
return true;
return false;
}
/*************************/
/* class DISPLAY_OPTIONS */
/*************************/
......@@ -406,17 +169,17 @@ EDA_BoardDesignSettings::EDA_BoardDesignSettings()
m_LayerColor[ii] = default_layer_color[ii];
// Layer colors (tracks and graphic items)
m_ViaColor[VIA_NOT_DEFINED] = DARKGRAY;
m_ViaColor[VIA_MICROVIA] = CYAN;
m_ViaColor[VIA_NOT_DEFINED] = DARKGRAY;
m_ViaColor[VIA_MICROVIA] = CYAN;
m_ViaColor[VIA_BLIND_BURIED] = BROWN;
m_ViaColor[VIA_THROUGH] = WHITE;
m_ModuleTextCMPColor = LIGHTGRAY; // Text module color for modules on the COMPONENT layer
m_ModuleTextCUColor = MAGENTA; // Text module color for modules on the COPPER layer
m_ModuleTextNOVColor = DARKGRAY; // Text module color for "invisible" texts (must be BLACK if really not displayed)
m_AnchorColor = BLUE; // Anchor color for modules and texts
m_PadCUColor = GREEN; // Pad color for the COMPONENT side of the pad
m_PadCMPColor = RED; // Pad color for the COPPER side of the pad
m_RatsnestColor = WHITE; // Ratsnest color
m_ViaColor[VIA_THROUGH] = WHITE;
m_ModuleTextCMPColor = LIGHTGRAY; // Text module color for modules on the COMPONENT layer
m_ModuleTextCUColor = MAGENTA; // Text module color for modules on the COPPER layer
m_ModuleTextNOVColor = DARKGRAY; // Text module color for "invisible" texts (must be BLACK if really not displayed)
m_AnchorColor = BLUE; // Anchor color for modules and texts
m_PadCUColor = GREEN; // Pad color for the COMPONENT side of the pad
m_PadCMPColor = RED; // Pad color for the COPPER side of the pad
m_RatsnestColor = WHITE; // Ratsnest color
}
......@@ -424,13 +187,12 @@ EDA_BoardDesignSettings::EDA_BoardDesignSettings()
int EDA_BoardDesignSettings::GetVisibleLayers() const
{
int layerMask = 0;
for( int i=0, mask=1; i< 32; ++i, mask<<=1 )
for( int i = 0, mask = 1; i< 32; ++i, mask <<= 1 )
{
if( !(m_LayerColor[i] & ITEM_NOT_SHOW) )
layerMask |= mask;
}
return layerMask;
}
/////////////////////////////////////////////////////////////////////////////
// Name: dialog_gendrill.cpp
// Purpose:
// Author: jean-pierre Charras
// Modified by:
// Created: 13/01/2008 17:26:27
// RCS-ID:
// Copyright: License GNU
// Licence:
/////////////////////////////////////////////////////////////////////////////
// Generated by DialogBlocks (unregistered), 13/01/2008 17:26:27
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
////@begin includes
////@end includes
#include "dialog_gendrill.h"
////@begin XPM images
////@end XPM images
/*!
* WinEDA_DrillFrame type definition
*/
IMPLEMENT_DYNAMIC_CLASS( WinEDA_DrillFrame, wxDialog )
/*!
* WinEDA_DrillFrame event table definition
*/
BEGIN_EVENT_TABLE( WinEDA_DrillFrame, wxDialog )
////@begin WinEDA_DrillFrame event table entries
EVT_CLOSE( WinEDA_DrillFrame::OnCloseWindow )
EVT_RADIOBOX( ID_SEL_DRILL_UNITS, WinEDA_DrillFrame::OnSelDrillUnitsSelected )
EVT_RADIOBOX( ID_SEL_ZEROS_FMT, WinEDA_DrillFrame::OnSelZerosFmtSelected )
EVT_BUTTON( wxID_OK, WinEDA_DrillFrame::OnOkClick )
EVT_BUTTON( wxID_CLOSE, WinEDA_DrillFrame::OnCloseClick )
////@end WinEDA_DrillFrame event table entries
END_EVENT_TABLE()
/*!
* WinEDA_DrillFrame constructors
*/
WinEDA_DrillFrame::WinEDA_DrillFrame()
{
Init();
}
WinEDA_DrillFrame::WinEDA_DrillFrame( WinEDA_PcbFrame* parent, wxWindowID id,
const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
m_Parent = parent;
SetFont( *g_DialogFont );
SetReturnCode( 1 );
Init();
Create(parent, id, caption, pos, size, style);
}
/*!
* WinEDA_DrillFrame creator
*/
bool WinEDA_DrillFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
////@begin WinEDA_DrillFrame creation
SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
wxDialog::Create( parent, id, caption, pos, size, style );
CreateControls();
if (GetSizer())
{
GetSizer()->SetSizeHints(this);
}
Centre();
////@end WinEDA_DrillFrame creation
return true;
}
/*!
* WinEDA_DrillFrame destructor
*/
WinEDA_DrillFrame::~WinEDA_DrillFrame()
{
////@begin WinEDA_DrillFrame destruction
////@end WinEDA_DrillFrame destruction
}
/*!
* Member initialisation
*/
void WinEDA_DrillFrame::Init()
{
////@begin WinEDA_DrillFrame member initialisation
m_LeftBoxSizer = NULL;
m_Choice_Unit = NULL;
m_Choice_Zeros_Format = NULL;
m_Choice_Precision = NULL;
m_Choice_Drill_Offset = NULL;
m_Choice_Drill_Map = NULL;
m_Choice_Drill_Report = NULL;
m_PenSpeed = NULL;
m_PenNum = NULL;
m_Check_Mirror = NULL;
m_Check_Minimal = NULL;
m_DefaultViasDrillSizer = NULL;
m_ViaDrillValue = NULL;
m_MicroViasDrillSizer = NULL;
m_MicroViaDrillValue = NULL;
m_PadsCountInfoMsg = NULL;
m_ThroughViasInfoMsg = NULL;
m_MicroViasInfoMsg = NULL;
m_BuriedViasInfoMsg = NULL;
////@end WinEDA_DrillFrame member initialisation
}
/*!
* Control creation for WinEDA_DrillFrame
*/
void WinEDA_DrillFrame::CreateControls()
{
////@begin WinEDA_DrillFrame content construction
// Generated by DialogBlocks, 14/01/2008 08:32:06 (unregistered)
WinEDA_DrillFrame* itemDialog1 = this;
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
itemDialog1->SetSizer(itemBoxSizer2);
m_LeftBoxSizer = new wxBoxSizer(wxVERTICAL);
itemBoxSizer2->Add(m_LeftBoxSizer, 0, wxGROW|wxALL, 5);
wxArrayString m_Choice_UnitStrings;
m_Choice_UnitStrings.Add(_("Millimeters"));
m_Choice_UnitStrings.Add(_("Inches"));
m_Choice_Unit = new wxRadioBox( itemDialog1, ID_SEL_DRILL_UNITS, _("Drill Units:"), wxDefaultPosition, wxDefaultSize, m_Choice_UnitStrings, 1, wxRA_SPECIFY_COLS );
m_Choice_Unit->SetSelection(0);
m_LeftBoxSizer->Add(m_Choice_Unit, 0, wxGROW|wxALL, 5);
wxArrayString m_Choice_Zeros_FormatStrings;
m_Choice_Zeros_FormatStrings.Add(_("decimal format"));
m_Choice_Zeros_FormatStrings.Add(_("suppress leading zeros"));
m_Choice_Zeros_FormatStrings.Add(_("suppress trailing zeros"));
m_Choice_Zeros_FormatStrings.Add(_("keep zeros"));
m_Choice_Zeros_Format = new wxRadioBox( itemDialog1, ID_SEL_ZEROS_FMT, _("Zeros Format"), wxDefaultPosition, wxDefaultSize, m_Choice_Zeros_FormatStrings, 1, wxRA_SPECIFY_COLS );
m_Choice_Zeros_Format->SetSelection(0);
m_LeftBoxSizer->Add(m_Choice_Zeros_Format, 0, wxALIGN_LEFT|wxALL, 5);
wxArrayString m_Choice_PrecisionStrings;
m_Choice_PrecisionStrings.Add(_("2:3"));
m_Choice_PrecisionStrings.Add(_("2:4"));
m_Choice_Precision = new wxRadioBox( itemDialog1, ID_SEL_PRECISION, _("Precision"), wxDefaultPosition, wxDefaultSize, m_Choice_PrecisionStrings, 1, wxRA_SPECIFY_COLS );
m_Choice_Precision->SetSelection(0);
m_LeftBoxSizer->Add(m_Choice_Precision, 0, wxGROW|wxALL, 5);
wxArrayString m_Choice_Drill_OffsetStrings;
m_Choice_Drill_OffsetStrings.Add(_("absolute"));
m_Choice_Drill_OffsetStrings.Add(_("auxiliary axis"));
m_Choice_Drill_Offset = new wxRadioBox( itemDialog1, ID_SEL_DRILL_SHEET, _("Drill Origin:"), wxDefaultPosition, wxDefaultSize, m_Choice_Drill_OffsetStrings, 1, wxRA_SPECIFY_COLS );
m_Choice_Drill_Offset->SetSelection(0);
m_LeftBoxSizer->Add(m_Choice_Drill_Offset, 0, wxGROW|wxALL, 5);
wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer2->Add(itemBoxSizer8, 0, wxGROW|wxALL, 5);
wxArrayString m_Choice_Drill_MapStrings;
m_Choice_Drill_MapStrings.Add(_("None"));
m_Choice_Drill_MapStrings.Add(_("drill sheet (HPGL)"));
m_Choice_Drill_MapStrings.Add(_("drill sheet (PostScript)"));
m_Choice_Drill_Map = new wxRadioBox( itemDialog1, ID_SEL_DRILL_SHEET, _("Drill Sheet:"), wxDefaultPosition, wxDefaultSize, m_Choice_Drill_MapStrings, 1, wxRA_SPECIFY_COLS );
m_Choice_Drill_Map->SetSelection(0);
itemBoxSizer8->Add(m_Choice_Drill_Map, 0, wxGROW|wxALL, 5);
wxArrayString m_Choice_Drill_ReportStrings;
m_Choice_Drill_ReportStrings.Add(_("None"));
m_Choice_Drill_ReportStrings.Add(_("Drill report"));
m_Choice_Drill_Report = new wxRadioBox( itemDialog1, ID_SEL_DRILL_REPORT, _("Drill Report:"), wxDefaultPosition, wxDefaultSize, m_Choice_Drill_ReportStrings, 1, wxRA_SPECIFY_COLS );
m_Choice_Drill_Report->SetSelection(0);
itemBoxSizer8->Add(m_Choice_Drill_Report, 0, wxGROW|wxALL, 5);
wxStaticBox* itemStaticBoxSizer11Static = new wxStaticBox(itemDialog1, wxID_ANY, _("HPGL plotter Options:"));
wxStaticBoxSizer* itemStaticBoxSizer11 = new wxStaticBoxSizer(itemStaticBoxSizer11Static, wxVERTICAL);
itemBoxSizer8->Add(itemStaticBoxSizer11, 0, wxGROW|wxALL, 5);
wxStaticText* itemStaticText12 = new wxStaticText( itemDialog1, wxID_STATIC, _("Speed (cm/s)"), wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer11->Add(itemStaticText12, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5);
m_PenSpeed = new wxTextCtrl( itemDialog1, ID_TEXTCTRL2, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer11->Add(m_PenSpeed, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
wxStaticText* itemStaticText14 = new wxStaticText( itemDialog1, wxID_STATIC, _("Pen Number"), wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer11->Add(itemStaticText14, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5);
m_PenNum = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer11->Add(m_PenNum, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
wxStaticBox* itemStaticBoxSizer16Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Options:"));
wxStaticBoxSizer* itemStaticBoxSizer16 = new wxStaticBoxSizer(itemStaticBoxSizer16Static, wxVERTICAL);
itemStaticBoxSizer11->Add(itemStaticBoxSizer16, 0, wxGROW|wxALL, 5);
m_Check_Mirror = new wxCheckBox( itemDialog1, ID_CHECKBOX2, _("mirror y axis"), wxDefaultPosition, wxDefaultSize, 0 );
m_Check_Mirror->SetValue(false);
itemStaticBoxSizer16->Add(m_Check_Mirror, 0, wxGROW|wxALL, 5);
m_Check_Minimal = new wxCheckBox( itemDialog1, ID_CHECKBOX3, _("minimal header"), wxDefaultPosition, wxDefaultSize, 0 );
m_Check_Minimal->SetValue(false);
itemStaticBoxSizer16->Add(m_Check_Minimal, 0, wxGROW|wxALL, 5);
wxBoxSizer* itemBoxSizer19 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer2->Add(itemBoxSizer19, 0, wxGROW|wxALL, 5);
wxStaticBox* itemStaticBoxSizer20Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Info:"));
wxStaticBoxSizer* itemStaticBoxSizer20 = new wxStaticBoxSizer(itemStaticBoxSizer20Static, wxVERTICAL);
itemBoxSizer19->Add(itemStaticBoxSizer20, 0, wxGROW|wxALL, 5);
m_DefaultViasDrillSizer = new wxStaticBox(itemDialog1, wxID_ANY, _("Default Vias Drill:"));
wxStaticBoxSizer* itemStaticBoxSizer21 = new wxStaticBoxSizer(m_DefaultViasDrillSizer, wxVERTICAL);
itemStaticBoxSizer20->Add(itemStaticBoxSizer21, 0, wxGROW|wxALL, 5);
m_ViaDrillValue = new wxStaticText( itemDialog1, wxID_STATIC, _("Via Drill Value"), wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer21->Add(m_ViaDrillValue, 0, wxGROW|wxALL, 5);
m_MicroViasDrillSizer = new wxStaticBox(itemDialog1, wxID_ANY, _("Micro Vias Drill:"));
wxStaticBoxSizer* itemStaticBoxSizer23 = new wxStaticBoxSizer(m_MicroViasDrillSizer, wxVERTICAL);
itemStaticBoxSizer20->Add(itemStaticBoxSizer23, 0, wxGROW|wxALL, 5);
m_MicroViaDrillValue = new wxStaticText( itemDialog1, wxID_STATIC, _("Micro Via Drill Value"), wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer23->Add(m_MicroViaDrillValue, 0, wxGROW|wxALL, 5);
wxStaticBox* itemStaticBoxSizer25Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Holes Count:"));
wxStaticBoxSizer* itemStaticBoxSizer25 = new wxStaticBoxSizer(itemStaticBoxSizer25Static, wxVERTICAL);
itemStaticBoxSizer20->Add(itemStaticBoxSizer25, 0, wxGROW|wxALL, 5);
m_PadsCountInfoMsg = new wxStaticText( itemDialog1, wxID_STATIC, _("Pads:"), wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer25->Add(m_PadsCountInfoMsg, 0, wxGROW|wxALL, 5);
m_ThroughViasInfoMsg = new wxStaticText( itemDialog1, wxID_STATIC, _("Through Vias:"), wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer25->Add(m_ThroughViasInfoMsg, 0, wxGROW|wxALL, 5);
m_MicroViasInfoMsg = new wxStaticText( itemDialog1, wxID_STATIC, _("Micro Vias:"), wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer25->Add(m_MicroViasInfoMsg, 0, wxGROW|wxALL, 5);
m_BuriedViasInfoMsg = new wxStaticText( itemDialog1, wxID_STATIC, _("Buried Vias:"), wxDefaultPosition, wxDefaultSize, 0 );
itemStaticBoxSizer25->Add(m_BuriedViasInfoMsg, 0, wxGROW|wxALL, 5);
itemBoxSizer19->Add(5, 5, 1, wxGROW|wxALL, 5);
wxButton* itemButton31 = new wxButton( itemDialog1, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );
itemButton31->SetForegroundColour(wxColour(156, 1, 5));
itemBoxSizer19->Add(itemButton31, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
wxButton* itemButton32 = new wxButton( itemDialog1, wxID_CLOSE, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 );
itemButton32->SetForegroundColour(wxColour(16, 1, 205));
itemBoxSizer19->Add(itemButton32, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
// Set validators
m_Choice_Unit->SetValidator( wxGenericValidator(& s_Unit_Drill_is_Inch) );
m_Choice_Zeros_Format->SetValidator( wxGenericValidator(& s_Zeros_Format) );
m_Check_Mirror->SetValidator( wxGenericValidator(& Mirror) );
m_Check_Minimal->SetValidator( wxGenericValidator(& Minimal) );
////@end WinEDA_DrillFrame content construction
InitDisplayParams();
}
/*!
* wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_RADIOBOX
*/
void WinEDA_DrillFrame::OnSelDrillUnitsSelected( wxCommandEvent& event )
{
UpdatePrecisionOptions(event);
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
*/
void WinEDA_DrillFrame::OnOkClick( wxCommandEvent& event )
{
GenDrillFiles(event);
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE
*/
void WinEDA_DrillFrame::OnCloseClick( wxCommandEvent& event )
{
UpdateConfig(); /* Save drill options: */
Close( true ); // true is to force the frame to close
}
/*!
* Should we show tooltips?
*/
bool WinEDA_DrillFrame::ShowToolTips()
{
return true;
}
/*!
* Get bitmap resources
*/
wxBitmap WinEDA_DrillFrame::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
////@begin WinEDA_DrillFrame bitmap retrieval
wxUnusedVar(name);
return wxNullBitmap;
////@end WinEDA_DrillFrame bitmap retrieval
}
/*!
* Get icon resources
*/
wxIcon WinEDA_DrillFrame::GetIconResource( const wxString& name )
{
// Icon retrieval
////@begin WinEDA_DrillFrame icon retrieval
wxUnusedVar(name);
return wxNullIcon;
////@end WinEDA_DrillFrame icon retrieval
}
/*!
* wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_SEL_ZEROS_FMT
*/
void WinEDA_DrillFrame::OnSelZerosFmtSelected( wxCommandEvent& event )
{
UpdatePrecisionOptions(event);
}
/*!
* wxEVT_CLOSE_WINDOW event handler for ID_WINEDA_DRILLFRAME
*/
void WinEDA_DrillFrame::OnCloseWindow( wxCloseEvent& event )
{
////@begin wxEVT_CLOSE_WINDOW event handler for ID_WINEDA_DRILLFRAME in WinEDA_DrillFrame.
// Before editing this code, remove the block markers.
event.Skip();
////@end wxEVT_CLOSE_WINDOW event handler for ID_WINEDA_DRILLFRAME in WinEDA_DrillFrame.
}
/////////////////////////////////////////////////////////////////////////////
// Name: dialog_gendrill.h
// Purpose:
// Author: jean-pierre Charras
// Modified by:
// Created: 13/01/2008 17:26:27
// RCS-ID:
// Copyright: License GNU
// Licence:
/////////////////////////////////////////////////////////////////////////////
// Generated by DialogBlocks (unregistered), 13/01/2008 17:26:27
#ifndef _DIALOG_GENDRILL_H_
#define _DIALOG_GENDRILL_H_
/*!
* Includes
*/
////@begin includes
#include "wx/valgen.h"
////@end includes
/*!
* Forward declarations
*/
////@begin forward declarations
class wxBoxSizer;
////@end forward declarations
/*!
* Control identifiers
*/
////@begin control identifiers
#define ID_WINEDA_DRILLFRAME 10000
#define ID_SEL_DRILL_UNITS 10002
#define ID_SEL_ZEROS_FMT 10001
#define ID_SEL_PRECISION 10003
#define ID_SEL_DRILL_SHEET 10004
#define ID_SEL_DRILL_REPORT 10010
#define ID_TEXTCTRL2 10007
#define ID_TEXTCTRL 10006
#define ID_CHECKBOX2 10011
#define ID_CHECKBOX3 10012
#define SYMBOL_WINEDA_DRILLFRAME_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL
#define SYMBOL_WINEDA_DRILLFRAME_TITLE _("WinEDA_DrillFrame")
#define SYMBOL_WINEDA_DRILLFRAME_IDNAME ID_WINEDA_DRILLFRAME
#define SYMBOL_WINEDA_DRILLFRAME_SIZE wxSize(400, 300)
#define SYMBOL_WINEDA_DRILLFRAME_POSITION wxDefaultPosition
////@end control identifiers
/*!
* WinEDA_DrillFrame class declaration
*/
class WinEDA_DrillFrame: public wxDialog
{
DECLARE_DYNAMIC_CLASS( WinEDA_DrillFrame )
DECLARE_EVENT_TABLE()
public:
/// Constructors
WinEDA_DrillFrame();
WinEDA_DrillFrame( WinEDA_PcbFrame* parent,
wxWindowID id = SYMBOL_WINEDA_DRILLFRAME_IDNAME,
const wxString& caption = SYMBOL_WINEDA_DRILLFRAME_TITLE,
const wxPoint& pos = SYMBOL_WINEDA_DRILLFRAME_POSITION,
const wxSize& size = SYMBOL_WINEDA_DRILLFRAME_SIZE,
long style = SYMBOL_WINEDA_DRILLFRAME_STYLE );
/// Creation
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_DRILLFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_DRILLFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_DRILLFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_DRILLFRAME_SIZE, long style = SYMBOL_WINEDA_DRILLFRAME_STYLE );
/// Destructor
~WinEDA_DrillFrame();
/// Initialises member variables
void Init();
/// Creates the controls and sizers
void CreateControls();
////@begin WinEDA_DrillFrame event handler declarations
/// wxEVT_CLOSE_WINDOW event handler for ID_WINEDA_DRILLFRAME
void OnCloseWindow( wxCloseEvent& event );
/// wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_SEL_DRILL_UNITS
void OnSelDrillUnitsSelected( wxCommandEvent& event );
/// wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_SEL_ZEROS_FMT
void OnSelZerosFmtSelected( wxCommandEvent& event );
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
void OnOkClick( wxCommandEvent& event );
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE
void OnCloseClick( wxCommandEvent& event );
////@end WinEDA_DrillFrame event handler declarations
////@begin WinEDA_DrillFrame member function declarations
/// Retrieves bitmap resources
wxBitmap GetBitmapResource( const wxString& name );
/// Retrieves icon resources
wxIcon GetIconResource( const wxString& name );
////@end WinEDA_DrillFrame member function declarations
/// Should we show tooltips?
static bool ShowToolTips();
////@begin WinEDA_DrillFrame member variables
wxBoxSizer* m_LeftBoxSizer;
wxRadioBox* m_Choice_Unit;
wxRadioBox* m_Choice_Zeros_Format;
wxRadioBox* m_Choice_Precision;
wxRadioBox* m_Choice_Drill_Offset;
wxRadioBox* m_Choice_Drill_Map;
wxRadioBox* m_Choice_Drill_Report;
wxTextCtrl* m_PenSpeed;
wxTextCtrl* m_PenNum;
wxCheckBox* m_Check_Mirror;
wxCheckBox* m_Check_Minimal;
wxStaticBox* m_DefaultViasDrillSizer;
wxStaticText* m_ViaDrillValue;
wxStaticBox* m_MicroViasDrillSizer;
wxStaticText* m_MicroViaDrillValue;
wxStaticText* m_PadsCountInfoMsg;
wxStaticText* m_ThroughViasInfoMsg;
wxStaticText* m_MicroViasInfoMsg;
wxStaticText* m_BuriedViasInfoMsg;
////@end WinEDA_DrillFrame member variables
private:
WinEDA_PcbFrame* m_Parent;
int m_PadsHoleCount;
int m_ThroughViasCount;
int m_MicroViasCount;
int m_BlindOrBuriedViasCount;
private:
void InitDisplayParams(void);
void SetParams(void);
void GenDrillFiles( wxCommandEvent& event );
void GenDrillMap( int format );
void UpdatePrecisionOptions( wxCommandEvent& event );
void UpdateConfig();
int Plot_Drill_PcbMap( FORET* buffer, int format );
void GenDrillReport();
int Gen_Liste_Forets( FORET* buffer, bool print_header );
int Create_Drill_File_EXCELLON( FORET* buffer );
void Init_Drill();
};
#endif
// _DIALOG_GENDRILL_H_
This source diff could not be displayed because it is too large. You can view the blob instead.
/***********************************************/
/* Routine de Generation du fichier de percage */
/***********************************************/
/***************************************************************/
/* Functionbs to create EXCELLON drill files and report files */
/***************************************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "plot_common.h"
#include "trigo.h"
#include "pcbnew.h"
#include "pcbplot.h"
#include "autorout.h"
#include "macros.h"
#include "protos.h"
#include "wx/defs.h"
/*
* Generation du fichier de percage en format EXCELLON
* Variantes supportees:
* - Decimal : coord flottantes en pouces
* - Metric : coord entieres en 1/10000 mm
* format "Trailling Zero" ( TZ )
* Creates the drill files in EXCELLON format
* Number format:
* - Floating point format
* - integer format
* - integer format: "Trailling Zero" ( TZ ) or "Leading Zero"
* Units
* - Decimal
* - Metric
*
* The drill maps can be created in HPGL or PS format
*
* On peut aussi generer le plan de percage en format HPGL ou PS
* dialog_gendrill.cpp is the file (included in this file) which handles the Dialog box for drill file generation
*/
/* Routines importees */
class FORET
class DRILL_TOOL
{
public:
int m_TotalCount;
......@@ -56,7 +53,8 @@ enum zeros_fmt {
KEEP_ZEROS
};
/* Routines Locales */
/* Local Function */
static void Gen_Line_EXCELLON( char* line, float x, float y );
static void Write_End_Of_File_Drill();
static void PlotDrillSymbol( const wxPoint& position, int diametre, int num_forme, int format );
static void PlotOvalDrillSymbol( const wxPoint& position,
......@@ -64,10 +62,10 @@ static void PlotOvalDrillSymbol( const wxPoint& position,
int orient,
int format );
/* Variables locales : */
static int DrillToolsCount; /* Nombre de forets a utiliser */
/* Local Variables : */
static int s_DrillToolsCount; /* Nombre de forets a utiliser */
static float conv_unit; /* coeff de conversion des unites drill / pcb */
static bool Unit_Drill_is_Inch = TRUE; /* INCH,LZ (2:4) */
static int s_Unit_Drill_is_Inch = TRUE; /* INCH,LZ (2:4) */
static int s_Zeros_Format = DECIMAL_FORMAT;
static DrillPrecision s_Precision( 2, 4 );
......@@ -85,206 +83,109 @@ static bool Mirror = true;
#define UnitDrillInchKey wxT( "DrillUnit" )
#define DrillOriginIsAuxAxisKey wxT( "DrillAuxAxis" )
/****************************************/
/* Dialog box for drill file generation */
/****************************************/
enum id_drill {
ID_CREATE_DRILL_FILES = 1370,
ID_CLOSE_DRILL,
ID_SEL_DRILL_UNITS,
ID_SEL_DRILL_SHEET,
ID_SEL_DRILL_REPORT,
ID_SEL_ZEROS_FMT,
ID_SEL_PRECISION
};
#include "dialog_gendrill.cpp" // Dialog box for drill file generation
class WinEDA_DrillFrame : public wxDialog
{
WinEDA_PcbFrame* m_Parent;
wxRadioBox* m_Choice_Drill_Map;
wxRadioBox* m_Choice_Drill_Report;
wxRadioBox* m_Choice_Unit;
wxRadioBox* m_Choice_Drill_Offset;
WinEDA_EnterText* m_EnterFileNameDrill;
WinEDA_ValueCtrl* m_ViaDrillCtrl;
WinEDA_ValueCtrl* m_PenSpeed;
WinEDA_ValueCtrl* m_PenNum;
wxCheckBox* m_Check_Mirror;
wxCheckBox* m_Check_Minimal;
wxRadioBox* m_Choice_Zeros_Format;
wxRadioBox* m_Choice_Precision;
// Constructor and destructor
public:
WinEDA_DrillFrame( WinEDA_PcbFrame* parent );
~WinEDA_DrillFrame() { };
private:
void OnQuit( wxCommandEvent& event );
void SetParams();
void GenDrillFiles( wxCommandEvent& event );
void GenDrillMap( int format );
void UpdatePrecisionOptions( wxCommandEvent& event );
void UpdateConfig();
int Plot_Drill_PcbMap( FORET* buffer, int format );
void GenDrillReport();
int Gen_Liste_Forets( FORET* buffer, bool print_header );
int Gen_Drill_File_EXCELLON( FORET* buffer );
void Gen_Line_EXCELLON( char* line, float x, float y );
void Init_Drill();
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE( WinEDA_DrillFrame, wxDialog )
EVT_BUTTON( ID_CLOSE_DRILL, WinEDA_DrillFrame::OnQuit )
EVT_BUTTON( ID_CREATE_DRILL_FILES, WinEDA_DrillFrame::GenDrillFiles )
EVT_RADIOBOX( ID_SEL_DRILL_UNITS, WinEDA_DrillFrame::UpdatePrecisionOptions )
EVT_RADIOBOX( ID_SEL_ZEROS_FMT, WinEDA_DrillFrame::UpdatePrecisionOptions )
END_EVENT_TABLE()
#define H_SIZE 550
#define V_SIZE 250
/*************************************************************************/
WinEDA_DrillFrame::WinEDA_DrillFrame( WinEDA_PcbFrame* parent ) :
wxDialog( parent, -1, _( "Drill tools" ), wxDefaultPosition, wxSize( H_SIZE, V_SIZE ),
DIALOG_STYLE )
/*************************************************************************/
/**********************************************/
void WinEDA_DrillFrame::InitDisplayParams(void)
/**********************************************/
/* some param values befor display dialog
*/
{
m_Parent = parent;
SetFont( *g_DialogFont );
SetReturnCode( 1 );
wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
SetSizer( MainBoxSizer );
wxBoxSizer* LeftBoxSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* MiddleBoxSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* RightBoxSizer = new wxBoxSizer( wxVERTICAL );
MainBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 );
MainBoxSizer->Add( MiddleBoxSizer, 0, wxGROW | wxALL, 5 );
MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
/* first column, NC drill options */
wxString choice_unit_msg[] =
{ _( "millimeters" ), _( "inches" ) };
m_Choice_Unit = new wxRadioBox( this, ID_SEL_DRILL_UNITS,
_( "Drill Units:" ),
wxDefaultPosition, wxSize( -1, -1 ),
2, choice_unit_msg, 1, wxRA_SPECIFY_COLS );
if( Unit_Drill_is_Inch )
m_Choice_Unit->SetSelection( 1 );
LeftBoxSizer->Add( m_Choice_Unit, 0, wxGROW | wxALL, 5 );
wxString choice_zeros_format_msg[] = {
_( "decimal format" ),
_( "suppress leading zeros" ), _( "suppress trailing zeros" ), _( "keep zeros" )
};
m_Choice_Zeros_Format = new wxRadioBox( this, ID_SEL_ZEROS_FMT,
_( "Zeros Format" ),
wxDefaultPosition, wxSize( -1, -1 ),
4, choice_zeros_format_msg, 1, wxRA_SPECIFY_COLS );
m_Choice_Zeros_Format->SetSelection( s_Zeros_Format );
LeftBoxSizer->Add( m_Choice_Zeros_Format, 0, wxGROW | wxALL, 5 );
wxString* choice_precision_msg;
wxString choice_precision_inch_msg[] = { _( "2:3" ), _( "2:4" ) };
wxString choice_precision_metric_msg[] = { _( "3:2" ), _( "3:3" ) };
if( Unit_Drill_is_Inch )
choice_precision_msg = choice_precision_inch_msg;
else
choice_precision_msg = choice_precision_metric_msg;
m_Choice_Precision = new wxRadioBox( this, ID_SEL_PRECISION,
_( "Precision" ),
wxDefaultPosition, wxSize( -1, -1 ),
2, choice_precision_msg, 1, wxRA_SPECIFY_COLS );
LeftBoxSizer->Add( m_Choice_Precision, 0, wxGROW | wxALL, 5 );
wxString ps;
ps << s_Precision.m_lhs << wxT( ":" ) << s_Precision.m_rhs;
m_Choice_Precision->SetStringSelection( ps );
wxString msg;
if( s_Zeros_Format==DECIMAL_FORMAT )
m_Choice_Precision->Enable( false );
wxString choice_drill_offset_msg[] =
{ _( "absolute" ), _( "auxiliary axis" ) };
m_Choice_Drill_Offset = new wxRadioBox( this, ID_SEL_DRILL_SHEET,
_( "Drill Origin:" ),
wxDefaultPosition, wxSize( -1, -1 ),
2, choice_drill_offset_msg, 1, wxRA_SPECIFY_COLS );
if( DrillOriginIsAuxAxis )
m_Choice_Drill_Offset->SetSelection( 1 );
LeftBoxSizer->Add( m_Choice_Drill_Offset, 0, wxGROW | wxALL, 5 );
/* second column */
wxString choice_drill_map_msg[] =
{ _( "None" ), _( "drill sheet (HPGL)" ), _( "drill sheet (PostScript)" ) };
m_Choice_Drill_Map = new wxRadioBox( this, ID_SEL_DRILL_SHEET,
_( "Drill Sheet:" ),
wxDefaultPosition, wxSize( -1, -1 ),
3, choice_drill_map_msg, 1, wxRA_SPECIFY_COLS );
MiddleBoxSizer->Add( m_Choice_Drill_Map, 0, wxGROW | wxALL, 5 );
wxString choice_drill_report_msg[] =
{ _( "None" ), _( "Drill report" ) };
m_Choice_Drill_Report = new wxRadioBox( this, ID_SEL_DRILL_REPORT,
_( "Drill Report:" ),
wxDefaultPosition, wxSize( -1, -1 ),
2, choice_drill_report_msg, 1, wxRA_SPECIFY_COLS );
MiddleBoxSizer->Add( m_Choice_Drill_Report, 0, wxGROW | wxALL, 5 );
m_ViaDrillCtrl = new WinEDA_ValueCtrl( this, _(
"Via Drill" ),
g_DesignSettings.m_ViaDrill, g_UnitMetric,
MiddleBoxSizer,
m_Parent->m_InternalUnits );
m_PenNum = new WinEDA_ValueCtrl( this, _( "Pen Number" ),
g_HPGL_Pen_Num, 2, MiddleBoxSizer, 1 );
m_PenSpeed = new WinEDA_ValueCtrl( this, _( "Speed (cm/s)" ),
g_HPGL_Pen_Speed, CENTIMETRE, MiddleBoxSizer, 1 );
m_Check_Mirror = new wxCheckBox( this, -1, _( "mirror y axis" ) );
m_Check_Mirror->SetValue( Mirror );
MiddleBoxSizer->Add( m_Check_Mirror, 0, wxGROW | wxALL, 5 );
m_Check_Minimal = new wxCheckBox( this, -1, _( "minimal header" ) );
m_Check_Minimal->SetValue( Minimal );
MiddleBoxSizer->Add( m_Check_Minimal, 0, wxGROW | wxALL, 5 );
/* third column, buttons */
wxButton* Button = new wxButton( this, ID_CREATE_DRILL_FILES,
_( "&Execute" ) );
Button->SetForegroundColour( *wxRED );
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
Button = new wxButton( this, ID_CLOSE_DRILL, _( "&Close" ) );
Button->SetForegroundColour( *wxBLUE );
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
GetSizer()->Fit( this );
GetSizer()->SetSizeHints( this );
Centre();
msg << s_Precision.m_lhs << wxT( ":" ) << s_Precision.m_rhs;
m_Choice_Precision->SetStringSelection( msg );
if( s_Zeros_Format==DECIMAL_FORMAT )
m_Choice_Precision->Enable( false );
msg = ReturnStringFromValue( g_UnitMetric, g_DesignSettings.m_ViaDrill, m_Parent->m_InternalUnits );
msg += ReturnUnitSymbol( g_UnitMetric );
m_ViaDrillValue->SetLabel(msg);
msg = ReturnStringFromValue( g_UnitMetric, g_DesignSettings.m_MicroViaDrill, m_Parent->m_InternalUnits );
msg += ReturnUnitSymbol( g_UnitMetric );
m_MicroViaDrillValue->SetLabel(msg);
msg.Empty();
msg << g_HPGL_Pen_Num;
m_PenNum->SetValue(msg);
msg.Empty();
msg << g_HPGL_Pen_Speed;
m_PenSpeed->SetValue(msg);
// See if we have some microvias, and display drill value if so
m_ThroughViasCount = 0;
m_MicroViasCount = 0;
m_BlindOrBuriedViasCount = 0;
for ( TRACK * track = m_Parent->m_Pcb->m_Track; track != NULL; track = track->Next() )
{
if ( track->Type() != TYPEVIA ) continue;
if ( track->Shape() == VIA_THROUGH )
m_ThroughViasCount++;
else if ( track->Shape() == VIA_MICROVIA )
m_MicroViasCount++;
else if ( track->Shape() == VIA_BLIND_BURIED )
m_BlindOrBuriedViasCount++;
}
m_MicroViasDrillSizer->Enable(m_MicroViasCount);
m_MicroViaDrillValue->Enable(m_MicroViasCount);
/* Display statistics */
// Pads holes cound:
m_PadsHoleCount = 0;
for ( MODULE * module = m_Parent->m_Pcb->m_Modules; module != NULL; module=module->Next() )
{
for ( D_PAD * pad = module->m_Pads; pad != NULL; pad = pad->Next() )
{
if( pad->m_DrillShape == PAD_CIRCLE )
if( pad->m_Drill.x != 0) m_PadsHoleCount++;
else
if ( MIN( pad->m_Drill.x, pad->m_Drill.y ) != 0 ) m_PadsHoleCount++;
}
}
msg = m_PadsCountInfoMsg->GetLabel();
msg << wxT(" ") << m_PadsHoleCount;
m_PadsCountInfoMsg->SetLabel(msg);
msg = m_ThroughViasInfoMsg->GetLabel();
msg << wxT(" ") << m_ThroughViasCount;
m_ThroughViasInfoMsg->SetLabel(msg);
msg = m_MicroViasInfoMsg->GetLabel();
msg << wxT(" ") << m_MicroViasCount;
m_MicroViasInfoMsg->SetLabel(msg);
msg = m_BuriedViasInfoMsg->GetLabel();
msg << wxT(" ") << m_BlindOrBuriedViasCount;
m_BuriedViasInfoMsg->SetLabel(msg);
}
/**************************************/
void WinEDA_DrillFrame::SetParams()
void WinEDA_DrillFrame::SetParams(void)
/**************************************/
{
Unit_Drill_is_Inch = (m_Choice_Unit->GetSelection() == 0) ? FALSE : TRUE;
wxString msg;
long ltmp;
s_Unit_Drill_is_Inch = (m_Choice_Unit->GetSelection() == 0) ? FALSE : TRUE;
Minimal = m_Check_Minimal->IsChecked();
Mirror = m_Check_Mirror->IsChecked();
s_Zeros_Format = m_Choice_Zeros_Format->GetSelection();
DrillOriginIsAuxAxis = m_Choice_Drill_Offset->GetSelection();
g_DesignSettings.m_ViaDrill = m_ViaDrillCtrl->GetValue();
Unit_Drill_is_Inch = m_Choice_Unit->GetSelection();
g_HPGL_Pen_Speed = m_PenSpeed->GetValue();
g_HPGL_Pen_Num = m_PenNum->GetValue();
if( m_Choice_Drill_Offset->GetSelection() == 0 )
msg = m_PenSpeed->GetValue();
if ( msg.ToLong(&ltmp) ) g_HPGL_Pen_Speed = ltmp;
msg = m_PenNum->GetValue();
if ( msg.ToLong(&ltmp) ) g_HPGL_Pen_Num = ltmp;
if( m_Choice_Drill_Offset->GetSelection() == 0 )
File_Drill_Offset = wxPoint( 0, 0 );
else
File_Drill_Offset = m_Parent->m_Auxiliary_Axis_Position;
......@@ -324,7 +225,7 @@ void WinEDA_PcbFrame::InstallDrillFrame( wxCommandEvent& event )
Config->Read( RightPrecisionKey, &s_Precision.m_rhs );
Config->Read( MirrorKey, &Mirror );
Config->Read( MinimalKey, &Minimal );
Config->Read( UnitDrillInchKey, &Unit_Drill_is_Inch );
Config->Read( UnitDrillInchKey, &s_Unit_Drill_is_Inch );
Config->Read( DrillOriginIsAuxAxisKey, &DrillOriginIsAuxAxis );
}
......@@ -349,24 +250,17 @@ void WinEDA_DrillFrame::UpdateConfig()
Config->Write( RightPrecisionKey, s_Precision.m_rhs );
Config->Write( MirrorKey, Mirror );
Config->Write( MinimalKey, Minimal );
Config->Write( UnitDrillInchKey, Unit_Drill_is_Inch );
Config->Write( UnitDrillInchKey, s_Unit_Drill_is_Inch );
Config->Write( DrillOriginIsAuxAxisKey, DrillOriginIsAuxAxis );
}
}
/****************************************************************/
void WinEDA_DrillFrame::OnQuit( wxCommandEvent& WXUNUSED (event) )
/****************************************************************/
{
UpdateConfig(); /* Save drill options: */
Close( true ); // true is to force the frame to close
}
/*************************************************************/
void WinEDA_DrillFrame::GenDrillFiles( wxCommandEvent& event )
/*************************************************************/
/* Calls the functions to create EXCELLOn drill files and/od drill map files
*/
{
wxString FullFileName, Mask( wxT( "*" ) ), Ext( wxT( ".drl" ) );
int ii;
......@@ -376,12 +270,12 @@ void WinEDA_DrillFrame::GenDrillFiles( wxCommandEvent& event )
m_Parent->MsgPanel->EraseMsgBox();
/* Calcul des echelles de conversion */
/* Set conversion scale depending on drill file units */
conv_unit = 0.0001; /* unites = INCHES */
if( !Unit_Drill_is_Inch )
if( !s_Unit_Drill_is_Inch )
conv_unit = 0.000254; /* unites = mm */
/* Init nom fichier */
/* Get the file name */
FullFileName = m_Parent->m_CurrentScreen->m_FileName;
ChangeFileNameExt( FullFileName, Ext );
Mask += Ext;
......@@ -409,17 +303,19 @@ void WinEDA_DrillFrame::GenDrillFiles( wxCommandEvent& event )
/* Init : */
Affiche_1_Parametre( m_Parent, 0, _( "File" ), FullFileName, BLUE );
Init_Drill();
setlocale (LC_NUMERIC, "C"); // Use the standard notation for float numbers
Init_Drill();
ii = Gen_Liste_Forets( (FORET*) adr_lowmem, TRUE );
ii = Gen_Liste_Forets( (DRILL_TOOL*) adr_lowmem, TRUE );
msg.Printf( wxT( "%d" ), ii );
Affiche_1_Parametre( m_Parent, 30, _( "Tools" ), msg, BROWN );
ii = Gen_Drill_File_EXCELLON( (FORET*) adr_lowmem );
ii = Create_Drill_File_EXCELLON( (DRILL_TOOL*) adr_lowmem );
msg.Printf( wxT( "%d" ), ii );
Affiche_1_Parametre( m_Parent, 45, _( "Drill" ), msg, GREEN );
Write_End_Of_File_Drill();
setlocale (LC_NUMERIC, ""); // Revert to locale float notation
}
switch( m_Choice_Drill_Map->GetSelection() )
......@@ -466,7 +362,7 @@ void WinEDA_DrillFrame::UpdatePrecisionOptions( wxCommandEvent& event )
/***************************************************************/
int WinEDA_DrillFrame::Gen_Drill_File_EXCELLON( FORET* buffer )
int WinEDA_DrillFrame::Create_Drill_File_EXCELLON( DRILL_TOOL* buffer )
/***************************************************************/
/* Create the drill file in EXCELLON format
......@@ -474,7 +370,7 @@ int WinEDA_DrillFrame::Gen_Drill_File_EXCELLON( FORET* buffer )
* buffer: Drill tools list
*/
{
FORET* foret;
DRILL_TOOL* foret;
TRACK* pt_piste;
D_PAD* pt_pad;
MODULE* Module;
......@@ -486,8 +382,8 @@ int WinEDA_DrillFrame::Gen_Drill_File_EXCELLON( FORET* buffer )
/* Create the pad drill list : */
nb_trous = 0;
/* Examen de la liste des forets */
for( ii = 0, foret = buffer; ii < DrillToolsCount; ii++, foret++ )
/* Read the hole file */
for( ii = 0, foret = buffer; ii < s_DrillToolsCount; ii++, foret++ )
{
sprintf( line, "T%d\n", ii + 1 ); fputs( line, dest );
/* Read the via list */
......@@ -507,25 +403,21 @@ int WinEDA_DrillFrame::Gen_Drill_File_EXCELLON( FORET* buffer )
x0 = pt_piste->m_Start.x - File_Drill_Offset.x;
y0 = pt_piste->m_Start.y - File_Drill_Offset.y;
//<ryan's edit>
if( !Mirror )
y0 *= -1;
xt = float (x0) * conv_unit; yt = float (y0) * conv_unit;
if( Unit_Drill_is_Inch )
if( s_Unit_Drill_is_Inch )
{
Gen_Line_EXCELLON( line, xt, yt );
}
//</ryan's edit>
else
{
/* metric 3:3 */
Gen_Line_EXCELLON( line, xt * 10, yt * 10 );
}
// si les flottants sont ecrits avec , au lieu de .
// conversion , -> . necessaire !
to_point( line );
fputs( line, dest );
nb_trous++;
}
......@@ -535,7 +427,7 @@ int WinEDA_DrillFrame::Gen_Drill_File_EXCELLON( FORET* buffer )
Module = m_Parent->m_Pcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{
/* Examen des pastilles */
/* Read and analyse pads */
pt_pad = (D_PAD*) Module->m_Pads;
for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
{
......@@ -551,31 +443,26 @@ int WinEDA_DrillFrame::Gen_Drill_File_EXCELLON( FORET* buffer )
x0 = pt_pad->m_Pos.x - File_Drill_Offset.x;
y0 = pt_pad->m_Pos.y - File_Drill_Offset.y;
//<ryan's edit>
if( !Mirror )
y0 *= -1;
xt = float (x0) * conv_unit; yt = float (y0) * conv_unit;
if( Unit_Drill_is_Inch )
if( s_Unit_Drill_is_Inch )
Gen_Line_EXCELLON( line, xt, yt );
else
Gen_Line_EXCELLON( line, xt * 10, yt * 10 );
to_point( line ); // Internationalization compensation (, to . for floats)
fputs( line, dest );
nb_trous++;
}
} /* ens analyse one module */
} // End analyse module list
/* Fin examen 1 module */
}
/* Fin 1 passe de foret */
/* Read pad list and create Drill infos for oblong holes only: */
Module = m_Parent->m_Pcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{
/* Examen des pastilles */
/* Analyse pad list for the module */
pt_pad = (D_PAD*) Module->m_Pads;
for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
{
......@@ -606,20 +493,17 @@ int WinEDA_DrillFrame::Gen_Drill_File_EXCELLON( FORET* buffer )
RotatePoint( &x0, &y0, xc, yc, pt_pad->m_Orient );
RotatePoint( &xf, &yf, xc, yc, pt_pad->m_Orient );
//<ryan's edit>
if( !Mirror )
{
y0 *= -1; yf *= -1;
}
// sprintf(line,"T%d\n",ii+1); fputs(line,dest);
xt = float (x0) * conv_unit; yt = float (y0) * conv_unit;
if( Unit_Drill_is_Inch )
if( s_Unit_Drill_is_Inch )
Gen_Line_EXCELLON( line, xt, yt );
else
Gen_Line_EXCELLON( line, xt * 10, yt * 10 );
to_point( line );
/* remove the '\n' from end of line, because we must add the "G85" command to the line: */
for( int kk = 0; line[kk] != 0; kk++ )
if( line[kk] == '\n' || line[kk] =='\r' )
......@@ -630,30 +514,23 @@ int WinEDA_DrillFrame::Gen_Drill_File_EXCELLON( FORET* buffer )
fputs( "G85", dest ); // add the "G85" command
xt = float (xf) * conv_unit; yt = float (yf) * conv_unit;
if( Unit_Drill_is_Inch )
if( s_Unit_Drill_is_Inch )
Gen_Line_EXCELLON( line, xt, yt );
else
Gen_Line_EXCELLON( line, xt * 10, yt * 10 );
to_point( line ); fputs( line, dest );
fputs( "G05\n", dest );
nb_trous++;
}
/* Fin examen 1 module */
}
/* fin analyse des trous de modules pour le foret en cours*/
} /* End Analyse pad list for the module */
} /* End analyse modules for the current tool */
}
/* fin analyse des forets */
return nb_trous;
}
/**********************************************************************/
void WinEDA_DrillFrame::Gen_Line_EXCELLON( char* line, float x, float y )
/**********************************************************************/
/*****************************************************/
void Gen_Line_EXCELLON( char* line, float x, float y )
/*****************************************************/
{
wxString xs, ys;
int xpad = s_Precision.m_lhs + s_Precision.m_rhs;
......@@ -726,7 +603,7 @@ void WinEDA_DrillFrame::Gen_Line_EXCELLON( char* line, float x, float y )
/***************************************************/
FORET* GetOrAddForet( FORET* buffer, int diameter )
DRILL_TOOL* GetOrAddForet( DRILL_TOOL* buffer, int diameter )
/***************************************************/
/* Search the drill tool for the diameter "diameter"
......@@ -734,20 +611,20 @@ FORET* GetOrAddForet( FORET* buffer, int diameter )
*/
{
int ii;
FORET* foret;
DRILL_TOOL* foret;
if( diameter == 0 )
return NULL;
/* Search for an existing tool: */
for( ii = 0, foret = buffer; ii < DrillToolsCount; ii++, foret++ )
for( ii = 0, foret = buffer; ii < s_DrillToolsCount; ii++, foret++ )
{
if( foret->m_Diameter == diameter ) /* found */
return foret;
}
/* No tool found, we must create a new one */
DrillToolsCount++;
s_DrillToolsCount++;
foret->m_TotalCount = 0;
foret->m_OvalCount = 0;
foret->m_Diameter = diameter;
......@@ -758,12 +635,12 @@ FORET* GetOrAddForet( FORET* buffer, int diameter )
/* Sort function by drill value */
int Sort_by_Drill_Value( void* foret1, void* foret2 )
{
return ( (FORET*) foret1 )->m_Diameter - ( (FORET*) foret2 )->m_Diameter;
return ( (DRILL_TOOL*) foret1 )->m_Diameter - ( (DRILL_TOOL*) foret2 )->m_Diameter;
}
/*********************************************************************/
int WinEDA_DrillFrame::Gen_Liste_Forets( FORET* buffer, bool print_header )
int WinEDA_DrillFrame::Gen_Liste_Forets( DRILL_TOOL* buffer, bool print_header )
/**********************************************************************/
/* Etablit la liste des forets de percage, dans l'ordre croissant des
......@@ -771,17 +648,17 @@ int WinEDA_DrillFrame::Gen_Liste_Forets( FORET* buffer, bool print_header )
* Retourne:
* Nombre de Forets
*
* Mise a jour: DrillToolsCount = nombre de forets differents
* Genere une liste de DrillToolsCount structures FORET a partir de buffer
* Mise a jour: s_DrillToolsCount = nombre de forets differents
* Genere une liste de s_DrillToolsCount structures DRILL_TOOL a partir de buffer
*/
{
FORET* foret;
DRILL_TOOL* foret;
D_PAD* pt_pad;
MODULE* Module;
int ii, diam;
char line[1024];
DrillToolsCount = 0; foret = buffer;
s_DrillToolsCount = 0; foret = buffer;
/* Create the via tools */
TRACK* pt_piste = m_Parent->m_Pcb->m_Track;
......@@ -826,24 +703,21 @@ int WinEDA_DrillFrame::Gen_Liste_Forets( FORET* buffer, bool print_header )
}
/* tri des forets par ordre de diametre croissant */
qsort( buffer, DrillToolsCount, sizeof(FORET),
qsort( buffer, s_DrillToolsCount, sizeof(DRILL_TOOL),
( int( * ) ( const void*, const void* ) )Sort_by_Drill_Value );
/* Generation de la section liste des outils */
if( print_header )
{
for( ii = 0, foret = (FORET*) buffer; ii < DrillToolsCount; ii++, foret++ )
for( ii = 0, foret = (DRILL_TOOL*) buffer; ii < s_DrillToolsCount; ii++, foret++ )
{
//<ryan's edit>
if( Unit_Drill_is_Inch ) /* does it need T01, T02 or is T1,T2 ok?*/
if( s_Unit_Drill_is_Inch ) /* does it need T01, T02 or is T1,T2 ok?*/
sprintf( line, "T%dC%.3f\n", ii + 1,
float (foret->m_Diameter) * conv_unit );
else
sprintf( line, "T%dC%.3f\n", ii + 1,
float (foret->m_Diameter) * conv_unit * 10.0 );
//</ryan's edit>
to_point( line );
fputs( line, dest );
}
......@@ -852,13 +726,13 @@ int WinEDA_DrillFrame::Gen_Liste_Forets( FORET* buffer, bool print_header )
fputs( "M47\n", dest ); /* Operator message */
fputs( "G05\n", dest ); /* Drill mode */
/* Units : */
if( Unit_Drill_is_Inch && !Minimal )
if( s_Unit_Drill_is_Inch && !Minimal )
fputs( "M72\n", dest ); /* M72 = inch mode */
else if( !Minimal )
fputs( "M71\n", dest ); /* M71 = metric mode */
}
return DrillToolsCount;
return s_DrillToolsCount;
}
......@@ -885,7 +759,7 @@ void WinEDA_DrillFrame::Init_Drill()
fputs( "R,T\nVER,1\nFMAT,2\n", dest );
}
if( Unit_Drill_is_Inch )
if( s_Unit_Drill_is_Inch )
fputs( "INCH", dest ); // Si unites en INCHES
else
fputs( "METRIC", dest ); // Si unites en mm
......@@ -929,7 +803,7 @@ void WinEDA_DrillFrame::GenDrillMap( int format )
{
int ii, x, y;
int plotX, plotY, TextWidth;
FORET* foret;
DRILL_TOOL* foret;
int intervalle = 0, CharSize = 0;
EDA_BaseStruct* PtStruct;
int old_g_PlotOrient = g_PlotOrient;
......@@ -978,6 +852,7 @@ void WinEDA_DrillFrame::GenDrillMap( int format )
if( FullFileName.IsEmpty() )
return;
setlocale (LC_NUMERIC, "C"); // Use the standard notation for float numbers
g_PlotOrient = 0;
/* calcul des dimensions et centre du PCB */
m_Parent->m_Pcb->ComputeBoundaryBox();
......@@ -1034,7 +909,7 @@ void WinEDA_DrillFrame::GenDrillMap( int format )
Affiche_1_Parametre( m_Parent, 0, _( "File" ), FullFileName, BLUE );
/* Calcul de la liste des diametres de percage (liste des forets) */
ii = Gen_Liste_Forets( (FORET*) adr_lowmem, FALSE );
ii = Gen_Liste_Forets( (DRILL_TOOL*) adr_lowmem, FALSE );
msg.Printf( wxT( "%d" ), ii );
Affiche_1_Parametre( m_Parent, 48, _( "Tools" ), msg, BROWN );
......@@ -1103,7 +978,7 @@ void WinEDA_DrillFrame::GenDrillMap( int format )
fputs( line, dest );
}
ii = Plot_Drill_PcbMap( (FORET*) adr_lowmem, format );
ii = Plot_Drill_PcbMap( (DRILL_TOOL*) adr_lowmem, format );
msg.Printf( wxT( "%d" ), ii );
Affiche_1_Parametre( m_Parent, 64, _( "Drill" ), msg, GREEN );
......@@ -1121,7 +996,6 @@ void WinEDA_DrillFrame::GenDrillMap( int format )
/* generation des dim: commande SI x,y; x et y = dim en cm */
char csize[256];
sprintf( csize, "%2.3f", (float) CharSize * CharScale * 0.000254 );
to_point( csize );
sprintf( line, "SI %s, %s;\n", csize, csize );
break;
}
......@@ -1182,7 +1056,7 @@ void WinEDA_DrillFrame::GenDrillMap( int format )
}
for( ii = 0, foret = (FORET*) adr_lowmem; ii < DrillToolsCount; ii++, foret++ )
for( ii = 0, foret = (DRILL_TOOL*) adr_lowmem; ii < s_DrillToolsCount; ii++, foret++ )
{
int plot_diam;
if( foret->m_TotalCount == 0 )
......@@ -1212,7 +1086,7 @@ void WinEDA_DrillFrame::GenDrillMap( int format )
// List the diameter of each drill in the selected Drill Unit,
// and then its diameter in the other Drill Unit.
if( Unit_Drill_is_Inch )
if( s_Unit_Drill_is_Inch )
sprintf( line, "PU %d, %d; LB%2.3f\" / %2.2fmm ",
x + (int) (intervalle * CharScale * fTextScale),
y - (int) (CharSize / 2 * CharScale * fTextScale),
......@@ -1249,7 +1123,7 @@ void WinEDA_DrillFrame::GenDrillMap( int format )
// List the diameter of each drill in the selected Drill Unit,
// and then its diameter in the other Drill Unit.
if( Unit_Drill_is_Inch )
if( s_Unit_Drill_is_Inch )
sprintf( line, "%2.3f\" / %2.2fmm ",
float (foret->m_Diameter) * 0.0001,
float (foret->m_Diameter) * 0.00254 );
......@@ -1298,12 +1172,14 @@ void WinEDA_DrillFrame::GenDrillMap( int format )
break;
}
setlocale (LC_NUMERIC, ""); // Revert to local notation for float numbers
g_PlotOrient = old_g_PlotOrient;
}
/********************************************************************/
int WinEDA_DrillFrame::Plot_Drill_PcbMap( FORET* buffer, int format )
int WinEDA_DrillFrame::Plot_Drill_PcbMap( DRILL_TOOL* buffer, int format )
/*********************************************************************/
/** Trace la liste des trous a percer en format HPGL ou POSTSCRIPT
......@@ -1312,7 +1188,7 @@ int WinEDA_DrillFrame::Plot_Drill_PcbMap( FORET* buffer, int format )
* @param format = ouput format (hpgl / ps)
*/
{
FORET* foret;
DRILL_TOOL* foret;
TRACK* pt_piste;
D_PAD* pt_pad;
MODULE* Module;
......@@ -1323,7 +1199,7 @@ int WinEDA_DrillFrame::Plot_Drill_PcbMap( FORET* buffer, int format )
nb_trous = 0;
/* create the drill list */
if( DrillToolsCount > 13 )
if( s_DrillToolsCount > 13 )
{
DisplayInfo( this,
_(
......@@ -1332,7 +1208,7 @@ int WinEDA_DrillFrame::Plot_Drill_PcbMap( FORET* buffer, int format )
}
// Plot the drill map:
for( shape_id = 0, foret = (FORET*) buffer; shape_id < DrillToolsCount; shape_id++, foret++ )
for( shape_id = 0, foret = (DRILL_TOOL*) buffer; shape_id < s_DrillToolsCount; shape_id++, foret++ )
{
/* create the via drill map */
{
......@@ -1397,7 +1273,7 @@ void PlotDrillSymbol( const wxPoint& position, int diametre, int num_forme, int
/* Trace un motif de numero de forme num_forme, aux coord x0, y0.
* x0, y0 = coordonnees tables
* diametre = diametre (coord table) du trou
* num_forme = index ( permet de gererer des formes caract )
* num_forme = index ( permet de generer des formes caract )
*/
{
int rayon = diametre / 2;
......@@ -1594,7 +1470,7 @@ void WinEDA_DrillFrame::GenDrillReport()
wxString FileName, Mask( wxT( "*" ) ), Ext( wxT( ".rpt" ) );
int ii, TotalHoleCount;
char line[1024];
FORET* foret;
DRILL_TOOL* foret;
wxString msg;
FileName = m_Parent->m_CurrentScreen->m_FileName;
......@@ -1625,7 +1501,7 @@ void WinEDA_DrillFrame::GenDrillReport()
Affiche_1_Parametre( m_Parent, 0, _( "File" ), FileName, BLUE );
/* Determine the list of the different drill diameters. */
ii = Gen_Liste_Forets( (FORET*) adr_lowmem, FALSE );
ii = Gen_Liste_Forets( (DRILL_TOOL*) adr_lowmem, FALSE );
msg.Printf( wxT( "%d" ), ii );
Affiche_1_Parametre( m_Parent, 30, _( "Tools" ), msg, BROWN );
......@@ -1634,19 +1510,19 @@ void WinEDA_DrillFrame::GenDrillReport()
fprintf( dest, "Created on %s\n", DateAndTime( line ) );
// List which Drill Unit option had been selected for the associated drill file.
if( Unit_Drill_is_Inch )
if( s_Unit_Drill_is_Inch )
fputs( "Selected Drill Unit: Imperial (\")\n\n", dest );
else
fputs( "Selected Drill Unit: Metric (mm)\n\n", dest );
TotalHoleCount = 0;
for( ii = 0, foret = (FORET*) adr_lowmem; ii < DrillToolsCount; ii++, foret++ )
for( ii = 0, foret = (DRILL_TOOL*) adr_lowmem; ii < s_DrillToolsCount; ii++, foret++ )
{
// List the tool number assigned to each drill,
// then its diameter in the selected Drill Unit,
// and then its diameter in the other Drill Unit.
if( Unit_Drill_is_Inch )
if( s_Unit_Drill_is_Inch )
sprintf( line, "T%d %2.3f\" %2.2fmm ",
ii + 1,
float (foret->m_Diameter) * 0.0001,
......@@ -1661,7 +1537,7 @@ void WinEDA_DrillFrame::GenDrillReport()
// Now list how many holes and ovals are associated with each drill.
if( ( foret->m_TotalCount == 1 ) && ( foret->m_OvalCount == 0 ) )
sprintf( line, "(1 hole)\n" );
else if( foret->m_TotalCount == 1 ) // && ( foret->m_OvalCount == 1 )
else if( foret->m_TotalCount == 1 )
sprintf( line, "(1 hole) (with 1 oblong)\n" );
else if( foret->m_OvalCount == 0 )
sprintf( line, "(%d holes)\n",
......
......@@ -32,6 +32,7 @@ OBJECTS= $(TARGET).o classpcb.o\
setpage.o \
tool_pcb.o \
pcbframe.o \
class_drawsegment.o \
class_track.o \
class_mire.o\
class_cotation.o\
......@@ -265,7 +266,7 @@ readgerb.o: readgerb.cpp pcbplot.h $(COMMON)
plot_rtn.o: plot_rtn.cpp pcbplot.h $(COMMON)
gendrill.o: gendrill.cpp pcbplot.h $(COMMON)
gendrill.o: gendrill.cpp dialog_gendrill.cpp dialog_gendrill.h pcbplot.h $(COMMON)
librairi.o: librairi.cpp $(COMMON)
......
......@@ -89,7 +89,7 @@ void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
if( m_ID_current_state == 0 )
{
DisplayError( this,
wxT( "WinEDA_PcbFrame::OnLeftClick() err: m_Flags != 0" ) );
wxT( "WinEDA_PcbFrame::OnLeftClick() err: DrawType %d m_Flags != 0" ), DrawStruct->Type() );
exit = true;
}
break;
......
......@@ -329,6 +329,7 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
wxT( "WinEDA_PcbFrame::OnRightClick() Error: illegal DrawType %d" ),
item->Type() );
DisplayError( this, msg );
SetCurItem(NULL);
break;
default:
......@@ -336,6 +337,9 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
wxT( "WinEDA_PcbFrame::OnRightClick() Error: unknown DrawType %d" ),
item->Type() );
DisplayError( this, msg );
// Attempt to clear error (but should no occurs )
if ( item->Type() >= MAX_STRUCT_TYPE_ID )
SetCurItem(NULL);
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