Commit bfb03b8f authored by CHARRAS's avatar CHARRAS

pcbnew: onleftclick.cpp added. move onleftclick() and OnLeftDClick() from edit.cpp to it

parent f066aa18
...@@ -4,6 +4,14 @@ Started 2007-June-11 ...@@ -4,6 +4,14 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2007-Sep-29 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+ pcbnew
create new file onleftclick.cpp
move onleftcligk() and onleftDcligk() from edit.cpp to onleftclick.cpp
2007-Sep-27 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2007-Sep-27 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================ ================================================================================
+ all + all
......
...@@ -92,6 +92,13 @@ void WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, ...@@ -92,6 +92,13 @@ void WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
DrawPanel->m_CanStartBlock = -1; // Ne pas engager un debut de bloc sur validation menu DrawPanel->m_CanStartBlock = -1; // Ne pas engager un debut de bloc sur validation menu
if( BlockActive )
{
AddMenusForBlock( PopMenu, this );
PopMenu->AppendSeparator();
return;
}
// Simple localisation des elements si possible // Simple localisation des elements si possible
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{ {
...@@ -121,18 +128,13 @@ void WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, ...@@ -121,18 +128,13 @@ void WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
} }
else else
{ {
if( (DrawStruct && DrawStruct->m_Flags) || BlockActive ) if( DrawStruct && DrawStruct->m_Flags )
{ {
if( BlockActive )
AddMenusForBlock( PopMenu, this );
else
ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel" ), cancel_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel" ), cancel_xpm );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
} }
} }
if( BlockActive )
return;
if( DrawStruct == NULL ) if( DrawStruct == NULL )
{ {
if( m_CurrentScreen != ScreenSch ) if( m_CurrentScreen != ScreenSch )
......
...@@ -19,306 +19,6 @@ ...@@ -19,306 +19,6 @@
static void Process_Move_Item( WinEDA_PcbFrame* frame, static void Process_Move_Item( WinEDA_PcbFrame* frame,
EDA_BaseStruct* DrawStruct, wxDC* DC ); EDA_BaseStruct* DrawStruct, wxDC* DC );
/********************************************************************/
void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
/********************************************************************/
/* Handle the left buttom mouse click, when a tool is active
*/
{
BOARD_ITEM* DrawStruct = GetCurItem();
bool exit = false;
if( (m_ID_current_state == 0) || ( DrawStruct && DrawStruct->m_Flags ) )
{
DrawPanel->m_AutoPAN_Request = FALSE;
if( DrawStruct && DrawStruct->m_Flags ) // "POPUP" in progress
{
DrawPanel->m_IgnoreMouseEvents = TRUE;
DrawPanel->CursorOff( DC );
switch( DrawStruct->Type() )
{
case TYPETRACK:
case TYPEVIA:
if( DrawStruct->m_Flags & IS_DRAGGED )
{
PlaceDraggedTrackSegment( (TRACK*) DrawStruct, DC );
exit = true;
}
break;
case TYPETEXTE:
Place_Texte_Pcb( (TEXTE_PCB*) DrawStruct, DC );
exit = true;
break;
case TYPETEXTEMODULE:
PlaceTexteModule( (TEXTE_MODULE*) DrawStruct, DC );
exit = true;
break;
case TYPEPAD:
PlacePad( (D_PAD*) DrawStruct, DC );
exit = true;
break;
case TYPEMODULE:
Place_Module( (MODULE*) DrawStruct, DC );
exit = true;
break;
case TYPEMIRE:
Place_Mire( (MIREPCB*) DrawStruct, DC );
exit = true;
break;
case TYPEDRAWSEGMENT:
if( m_ID_current_state == 0 )
{
Place_DrawItem( (DRAWSEGMENT*) DrawStruct, DC );
exit = true;
}
break;
default:
if( m_ID_current_state == 0 )
{
DisplayError( this,
wxT( "WinEDA_PcbFrame::OnLeftClick() err: m_Flags != 0" ) );
exit = true;
}
break;
}
DrawPanel->m_IgnoreMouseEvents = FALSE;
DrawPanel->CursorOn( DC );
if ( exit ) return;
}
else if( !wxGetKeyState(WXK_SHIFT) && !wxGetKeyState(WXK_ALT) &&
!wxGetKeyState(WXK_CONTROL) )
{
DrawStruct = PcbGeneralLocateAndDisplay();
if( DrawStruct )
SendMessageToEESCHEMA( DrawStruct );
}
}
switch( m_ID_current_state )
{
case ID_MAIN_MENUBAR:
case 0:
break;
case ID_NO_SELECT_BUTT:
break;
case ID_PCB_MUWAVE_TOOL_SELF_CMD:
case ID_PCB_MUWAVE_TOOL_GAP_CMD:
case ID_PCB_MUWAVE_TOOL_STUB_CMD:
case ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD:
case ID_PCB_MUWAVE_TOOL_FUNCTION_SHAPE_CMD:
MuWaveCommand( DC, MousePos );
break;
case ID_PCB_HIGHLIGHT_BUTT:
{
int netcode = Select_High_Light( DC );
if( netcode < 0 )
m_Pcb->Display_Infos( this );
else
Affiche_Infos_Equipot( netcode, this );
}
break;
case ID_PCB_SHOW_1_RATSNEST_BUTT:
#if 0
DrawStruct = m_Pcb->FindPadOrModule( GetScreen()->RefPos(true),
GetScreen()->m_Active_Layer );
#else
DrawStruct = PcbGeneralLocateAndDisplay();
#endif
Show_1_Ratsnest( DrawStruct, DC );
if( DrawStruct )
SendMessageToEESCHEMA( DrawStruct );
break;
case ID_PCB_MIRE_BUTT:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
SetCurItem( Create_Mire( DC ) );
DrawPanel->MouseToCursorSchema();
}
else if( DrawStruct->Type() == TYPEMIRE )
{
Place_Mire( (MIREPCB*) DrawStruct, DC );
}
else
DisplayError( this, wxT( "Internal err: Struct not TYPEMIRE" ) );
break;
case ID_PCB_CIRCLE_BUTT:
case ID_PCB_ARC_BUTT:
case ID_LINE_COMMENT_BUTT:
{
int shape = S_SEGMENT;
if( m_ID_current_state == ID_PCB_CIRCLE_BUTT )
shape = S_CIRCLE;
if( m_ID_current_state == ID_PCB_ARC_BUTT )
shape = S_ARC;
if( GetScreen()->m_Active_Layer <= CMP_N )
{
DisplayError( this, _( "Graphic not autorized on Copper layers" ) );
break;
}
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
DrawStruct = Begin_DrawSegment( NULL, shape, DC );
SetCurItem( DrawStruct );
DrawPanel->m_AutoPAN_Request = TRUE;
}
else if( DrawStruct
&& (DrawStruct->Type() == TYPEDRAWSEGMENT)
&& (DrawStruct->m_Flags & IS_NEW) )
{
DrawStruct = Begin_DrawSegment( (DRAWSEGMENT*) DrawStruct, shape, DC );
SetCurItem( DrawStruct );
DrawPanel->m_AutoPAN_Request = TRUE;
}
break;
}
case ID_TRACK_BUTT:
if( GetScreen()->m_Active_Layer > CMP_N )
{
DisplayError( this, _( "Tracks on Copper layers only " ) );
break;
}
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
DrawStruct = Begin_Route( NULL, DC );
SetCurItem( DrawStruct );
if( DrawStruct )
DrawPanel->m_AutoPAN_Request = TRUE;
}
else if( DrawStruct &&
// (DrawStruct->Type() == TYPETRACK) &&
(DrawStruct->m_Flags & IS_NEW) )
{
TRACK* track = Begin_Route( (TRACK*) DrawStruct, DC );
if( track ) // c'est a dire si OK
SetCurItem( DrawStruct = track );
DrawPanel->m_AutoPAN_Request = TRUE;
}
break;
case ID_PCB_ZONES_BUTT:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
SetCurItem( DrawStruct = Begin_Zone() );
}
else if( DrawStruct
&& (DrawStruct->Type() == TYPEEDGEZONE)
&& (DrawStruct->m_Flags & IS_NEW) )
{
SetCurItem( DrawStruct = Begin_Zone() );
}
else
DisplayError( this, wxT( "Edit: zone internal error" ) );
break;
case ID_TEXT_COMMENT_BUTT:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
SetCurItem( Create_Texte_Pcb( DC ) );
DrawPanel->MouseToCursorSchema();
DrawPanel->m_AutoPAN_Request = TRUE;
}
else if( DrawStruct->Type() == TYPETEXTE )
{
Place_Texte_Pcb( (TEXTE_PCB*) DrawStruct, DC );
DrawPanel->m_AutoPAN_Request = FALSE;
}
else
DisplayError( this, wxT( "Internal err: Struct not TYPETEXTE" ) );
break;
case ID_COMPONENT_BUTT:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
DrawPanel->MouseToCursorSchema();
DrawStruct = Load_Module_From_Library( wxEmptyString, DC );
SetCurItem( DrawStruct );
if( DrawStruct )
StartMove_Module( (MODULE*) DrawStruct, DC );
}
else if( DrawStruct->Type() == TYPEMODULE )
{
Place_Module( (MODULE*) DrawStruct, DC );
DrawPanel->m_AutoPAN_Request = FALSE;
}
else
DisplayError( this, wxT( "Internal err: Struct not TYPEMODULE" ) );
break;
case ID_PCB_COTATION_BUTT:
if( GetScreen()->m_Active_Layer <= CMP_N )
{
DisplayError( this, _( "Cotation not autorized on Copper layers" ) );
break;
}
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
DrawStruct = Begin_Cotation( NULL, DC );
SetCurItem( DrawStruct );
DrawPanel->m_AutoPAN_Request = TRUE;
}
else if( DrawStruct
&& (DrawStruct->Type() == TYPECOTATION)
&& (DrawStruct->m_Flags & IS_NEW) )
{
DrawStruct = Begin_Cotation( (COTATION*) DrawStruct, DC );
SetCurItem( DrawStruct );
DrawPanel->m_AutoPAN_Request = TRUE;
}
else
DisplayError( this, wxT( "Internal err: Struct not COTATION" ) );
break;
case ID_PCB_DELETE_ITEM_BUTT:
if( !DrawStruct || (DrawStruct->m_Flags == 0) )
{
DrawStruct = PcbGeneralLocateAndDisplay();
if( DrawStruct && (DrawStruct->m_Flags == 0) )
{
RemoveStruct( DrawStruct, DC );
SetCurItem( DrawStruct = NULL );
}
}
break;
case ID_PCB_PLACE_OFFSET_COORD_BUTT:
DrawPanel->m_Draw_Auxiliary_Axis( DC, GR_XOR );
m_Auxiliary_Axis_Position = GetScreen()->m_Curseur;
DrawPanel->m_Draw_Auxiliary_Axis( DC, GR_COPY );
GetScreen()->SetModify();
break;
default:
DrawPanel->SetCursor( wxCURSOR_ARROW );
DisplayError( this, wxT( "WinEDA_PcbFrame::OnLeftClick() id error" ) );
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
break;
}
}
// see wxstruct.h // see wxstruct.h
void WinEDA_PcbFrame::SendMessageToEESCHEMA( EDA_BaseStruct* objectToSync ) void WinEDA_PcbFrame::SendMessageToEESCHEMA( EDA_BaseStruct* objectToSync )
{ {
...@@ -363,7 +63,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -363,7 +63,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
pos.y += 20; pos.y += 20;
switch( id ) // Arret eventuel de la commande de d�placement en cours switch( id ) // Some (not all ) edit commands must be finished or aborted
{ {
case wxID_CUT: case wxID_CUT:
case wxID_COPY: case wxID_COPY:
...@@ -456,7 +156,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -456,7 +156,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
{ {
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
} }
/* ne devrait pas etre execute, sauf bug */ /* Should not be executed, just in case */
if( m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE ) if( m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE )
{ {
m_CurrentScreen->BlockLocate.m_Command = BLOCK_IDLE; m_CurrentScreen->BlockLocate.m_Command = BLOCK_IDLE;
...@@ -469,7 +169,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -469,7 +169,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
SetCursor( DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor ); SetCursor( DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor );
break; break;
default: // Arret de la commande de d�placement en cours default: // Finish (abort ) the command
if( DrawPanel->ManageCurseur if( DrawPanel->ManageCurseur
&& DrawPanel->ForceCloseManageCurseur ) && DrawPanel->ForceCloseManageCurseur )
{ {
...@@ -479,7 +179,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -479,7 +179,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
} }
switch( id ) // Traitement des commandes switch( id ) // Execute command
{ {
case ID_EXIT: case ID_EXIT:
Close( TRUE ); Close( TRUE );
...@@ -1230,126 +930,6 @@ static void Process_Move_Item( WinEDA_PcbFrame* frame, ...@@ -1230,126 +930,6 @@ static void Process_Move_Item( WinEDA_PcbFrame* frame,
} }
} }
/********************************************************************************/
void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
/********************************************************************************/
/* Appel� sur un double click:
* pour un �l�ment editable (textes, composant):
* appel de l'editeur correspondant.
* pour une connexion en cours:
* termine la connexion
*/
{
BOARD_ITEM* DrawStruct = GetCurItem();
wxPoint pos = GetPosition();
wxClientDC dc( DrawPanel );
DrawPanel->PrepareGraphicContext( &dc );
switch( m_ID_current_state )
{
case 0:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
DrawStruct = PcbGeneralLocateAndDisplay();
}
if( (DrawStruct == NULL) || (DrawStruct->m_Flags != 0) )
break;
SendMessageToEESCHEMA( DrawStruct );
// Element localis�
SetCurItem( DrawStruct );
switch( DrawStruct->Type() )
{
case TYPETRACK:
case TYPEVIA:
if( DrawStruct->m_Flags & IS_NEW )
{
End_Route( (TRACK*) DrawStruct, DC );
DrawPanel->m_AutoPAN_Request = FALSE;
}
else if( DrawStruct->m_Flags == 0 )
{
Edit_TrackSegm_Width( DC, (TRACK*) DrawStruct );
}
break;
case TYPETEXTE:
InstallTextPCBOptionsFrame( (TEXTE_PCB*) DrawStruct,
DC, ( (TEXTE_PCB*) DrawStruct )->m_Pos );
DrawPanel->MouseToCursorSchema();
break;
case TYPEPAD:
InstallPadOptionsFrame( (D_PAD*) DrawStruct, &dc, pos );
DrawPanel->MouseToCursorSchema();
break;
case TYPEMODULE:
InstallModuleOptionsFrame( (MODULE*) DrawStruct, &dc, pos );
DrawPanel->MouseToCursorSchema();
break;
case TYPEMIRE:
InstallMireOptionsFrame( (MIREPCB*) DrawStruct, &dc, pos );
DrawPanel->MouseToCursorSchema();
break;
case TYPETEXTEMODULE:
InstallTextModOptionsFrame( (TEXTE_MODULE*) DrawStruct, &dc, pos );
DrawPanel->MouseToCursorSchema();
break;
case TYPEDRAWSEGMENT:
break;
default:
break;
}
break; // end case 0
case ID_TRACK_BUTT:
if( DrawStruct && (DrawStruct->m_Flags & IS_NEW) )
{
End_Route( (TRACK*) DrawStruct, DC );
DrawPanel->m_AutoPAN_Request = FALSE;
}
break;
case ID_PCB_ZONES_BUTT:
End_Zone( DC );
DrawPanel->m_AutoPAN_Request = FALSE;
SetCurItem( NULL );
break;
case ID_LINE_COMMENT_BUTT:
case ID_PCB_ARC_BUTT:
case ID_PCB_CIRCLE_BUTT:
if( DrawStruct == NULL )
break;
if( DrawStruct->Type() != TYPEDRAWSEGMENT )
{
DisplayError( this, wxT( "DrawStruct Type error" ) );
DrawPanel->m_AutoPAN_Request = FALSE;
break;
}
if( (DrawStruct->m_Flags & IS_NEW) )
{
End_Edge( (DRAWSEGMENT*) DrawStruct, &dc );
DrawPanel->m_AutoPAN_Request = FALSE;
SetCurItem( NULL );
}
break;
}
}
/***************************************************************/ /***************************************************************/
void WinEDA_PcbFrame::RemoveStruct( EDA_BaseStruct* Item, wxDC* DC ) void WinEDA_PcbFrame::RemoveStruct( EDA_BaseStruct* Item, wxDC* DC )
/***************************************************************/ /***************************************************************/
......
/***********************************************/ /***********************************************/
/* Routine de Generation du fichier de percage */ /* Routine de Generation du fichier de percage */
/***********************************************/ /***********************************************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -18,14 +18,14 @@ ...@@ -18,14 +18,14 @@
#include "wx/defs.h" #include "wx/defs.h"
/* /*
Generation du fichier de percage en format EXCELLON * Generation du fichier de percage en format EXCELLON
Variantes supportees: * Variantes supportees:
- Decimal : coord flottantes en pouces * - Decimal : coord flottantes en pouces
- Metric : coord entieres en 1/10000 mm * - Metric : coord entieres en 1/10000 mm
format "Trailling Zero" ( TZ ) * format "Trailling Zero" ( TZ )
*
On peut aussi generer le plan de percage en format HPGL ou PS * On peut aussi generer le plan de percage en format HPGL ou PS
*/ */
/* Routines importees */ /* Routines importees */
...@@ -45,7 +45,7 @@ public: ...@@ -45,7 +45,7 @@ public:
int m_rhs; int m_rhs;
public: public:
DrillPrecision(int l, int r) {m_lhs=l; m_rhs=r;} DrillPrecision( int l, int r ) { m_lhs = l; m_rhs = r; }
}; };
/* zeros format */ /* zeros format */
...@@ -57,29 +57,33 @@ enum zeros_fmt { ...@@ -57,29 +57,33 @@ enum zeros_fmt {
}; };
/* Routines Locales */ /* Routines Locales */
static void Fin_Drill(); static void Write_End_Of_File_Drill();
static void PlotDrillSymbol(const wxPoint & position,int diametre,int num_forme,int format); static void PlotDrillSymbol( const wxPoint& position, int diametre, int num_forme, int format );
static void PlotOvalDrillSymbol(const wxPoint & position,const wxSize & size,int orient,int format); static void PlotOvalDrillSymbol( const wxPoint& position,
const wxSize& size,
int orient,
int format );
/* Variables locales : */ /* Variables locales : */
static int DrillToolsCount; /* Nombre de forets a utiliser */ static int DrillToolsCount; /* Nombre de forets a utiliser */
static float conv_unit; /* coeff de conversion des unites drill / pcb */ static float conv_unit; /* coeff de conversion des unites drill / pcb */
static bool Unit_Drill_is_Inch = TRUE; /* INCH,LZ (2:4) */ static bool Unit_Drill_is_Inch = TRUE; /* INCH,LZ (2:4) */
static int s_Zeros_Format = DECIMAL_FORMAT; static int s_Zeros_Format = DECIMAL_FORMAT;
static DrillPrecision s_Precision(2,4); static DrillPrecision s_Precision( 2, 4 );
static bool DrillOriginIsAuxAxis; // Axis selection (main / auxiliary) for Drill Origin coordinates static bool DrillOriginIsAuxAxis; // Axis selection (main / auxiliary) for Drill Origin coordinates
static wxPoint File_Drill_Offset; /* Offset des coord de percage pour le fichier gnr */ static wxPoint File_Drill_Offset; /* Offset des coord de percage pour le fichier gnr */
static bool Minimal = false; static bool Minimal = false;
static bool Mirror = true; static bool Mirror = true;
// Keywords for read and write config // Keywords for read and write config
#define ZerosFormatKey wxT("DrillZerosFormat") #define ZerosFormatKey wxT( "DrillZerosFormat" )
#define LeftPrecisionKey wxT("DrillLeftPrecisionOpt") #define LeftPrecisionKey wxT( "DrillLeftPrecisionOpt" )
#define RightPrecisionKey wxT("DrillRightPrecisionOpt") #define RightPrecisionKey wxT( "DrillRightPrecisionOpt" )
#define MirrorKey wxT("DrillMirrorYOpt") #define MirrorKey wxT( "DrillMirrorYOpt" )
#define MinimalKey wxT("DrillMinHeader") #define MinimalKey wxT( "DrillMinHeader" )
#define UnitDrillInchKey wxT("DrillUnit") #define UnitDrillInchKey wxT( "DrillUnit" )
#define DrillOriginIsAuxAxisKey wxT("DrillAuxAxis") #define DrillOriginIsAuxAxisKey wxT( "DrillAuxAxis" )
/****************************************/ /****************************************/
/* Dialog box for drill file generation */ /* Dialog box for drill file generation */
...@@ -94,170 +98,174 @@ enum id_drill { ...@@ -94,170 +98,174 @@ enum id_drill {
ID_SEL_PRECISION ID_SEL_PRECISION
}; };
class WinEDA_DrillFrame: public wxDialog class WinEDA_DrillFrame : public wxDialog
{ {
WinEDA_PcbFrame* m_Parent;
WinEDA_PcbFrame * m_Parent; wxRadioBox* m_Choice_Drill_Map;
wxRadioBox * m_Choice_Drill_Map; wxRadioBox* m_Choice_Drill_Report;
wxRadioBox * m_Choice_Drill_Report; wxRadioBox* m_Choice_Unit;
wxRadioBox * m_Choice_Unit; wxRadioBox* m_Choice_Drill_Offset;
wxRadioBox * m_Choice_Drill_Offset; WinEDA_EnterText* m_EnterFileNameDrill;
WinEDA_EnterText * m_EnterFileNameDrill; WinEDA_ValueCtrl* m_ViaDrillCtrl;
WinEDA_ValueCtrl * m_ViaDrillCtrl; WinEDA_ValueCtrl* m_PenSpeed;
WinEDA_ValueCtrl * m_PenSpeed; WinEDA_ValueCtrl* m_PenNum;
WinEDA_ValueCtrl * m_PenNum; wxCheckBox* m_Check_Mirror;
wxCheckBox * m_Check_Mirror; wxCheckBox* m_Check_Minimal;
wxCheckBox * m_Check_Minimal; wxRadioBox* m_Choice_Zeros_Format;
wxRadioBox * m_Choice_Zeros_Format; wxRadioBox* m_Choice_Precision;
wxRadioBox * m_Choice_Precision;
// Constructor and destructor // Constructor and destructor
public: public:
WinEDA_DrillFrame(WinEDA_PcbFrame *parent); WinEDA_DrillFrame( WinEDA_PcbFrame* parent );
~WinEDA_DrillFrame() {}; ~WinEDA_DrillFrame() { };
private: private:
void OnQuit(wxCommandEvent& event); void OnQuit( wxCommandEvent& event );
void SetParams(); void SetParams();
void GenDrillFiles(wxCommandEvent& event); void GenDrillFiles( wxCommandEvent& event );
void GenDrillMap(int format); void GenDrillMap( int format );
void UpdatePrecisionOptions(wxCommandEvent& event); void UpdatePrecisionOptions( wxCommandEvent& event );
void UpdateConfig(); void UpdateConfig();
int Plot_Drill_PcbMap( FORET * buffer, int format); int Plot_Drill_PcbMap( FORET* buffer, int format );
void GenDrillReport(); void GenDrillReport();
int Gen_Liste_Forets( FORET * buffer,bool print_header); int Gen_Liste_Forets( FORET* buffer, bool print_header );
int Gen_Drill_File_EXCELLON( FORET * buffer); int Gen_Drill_File_EXCELLON( FORET* buffer );
void Gen_Line_EXCELLON(char *line, float x, float y); void Gen_Line_EXCELLON( char* line, float x, float y );
void Init_Drill(); void Init_Drill();
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
BEGIN_EVENT_TABLE(WinEDA_DrillFrame, wxDialog) BEGIN_EVENT_TABLE( WinEDA_DrillFrame, wxDialog )
EVT_BUTTON(ID_CLOSE_DRILL, WinEDA_DrillFrame::OnQuit) EVT_BUTTON( ID_CLOSE_DRILL, WinEDA_DrillFrame::OnQuit )
EVT_BUTTON(ID_CREATE_DRILL_FILES, WinEDA_DrillFrame::GenDrillFiles) EVT_BUTTON( ID_CREATE_DRILL_FILES, WinEDA_DrillFrame::GenDrillFiles )
EVT_RADIOBOX(ID_SEL_DRILL_UNITS, WinEDA_DrillFrame::UpdatePrecisionOptions) EVT_RADIOBOX( ID_SEL_DRILL_UNITS, WinEDA_DrillFrame::UpdatePrecisionOptions )
EVT_RADIOBOX(ID_SEL_ZEROS_FMT, WinEDA_DrillFrame::UpdatePrecisionOptions) EVT_RADIOBOX( ID_SEL_ZEROS_FMT, WinEDA_DrillFrame::UpdatePrecisionOptions )
END_EVENT_TABLE() END_EVENT_TABLE()
#define H_SIZE 550 #define H_SIZE 550
#define V_SIZE 250 #define V_SIZE 250
/*************************************************************************/ /*************************************************************************/
WinEDA_DrillFrame::WinEDA_DrillFrame(WinEDA_PcbFrame *parent): WinEDA_DrillFrame::WinEDA_DrillFrame( WinEDA_PcbFrame* parent ) :
wxDialog(parent, -1, _("Drill tools"), wxDefaultPosition, wxSize(H_SIZE, V_SIZE), wxDialog( parent, -1, _( "Drill tools" ), wxDefaultPosition, wxSize( H_SIZE, V_SIZE ),
DIALOG_STYLE) DIALOG_STYLE )
/*************************************************************************/ /*************************************************************************/
{ {
m_Parent = parent; m_Parent = parent;
SetFont(*g_DialogFont); SetFont( *g_DialogFont );
SetReturnCode(1); SetReturnCode( 1 );
wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
SetSizer(MainBoxSizer); SetSizer( MainBoxSizer );
wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer* LeftBoxSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer * MiddleBoxSizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer* MiddleBoxSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL); wxBoxSizer* RightBoxSizer = new wxBoxSizer( wxVERTICAL );
MainBoxSizer->Add(LeftBoxSizer, 0, wxGROW|wxALL, 5); MainBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 );
MainBoxSizer->Add(MiddleBoxSizer, 0, wxGROW|wxALL, 5); MainBoxSizer->Add( MiddleBoxSizer, 0, wxGROW | wxALL, 5 );
MainBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
/* first column, NC drill options */ /* first column, NC drill options */
wxString choice_unit_msg[] = wxString choice_unit_msg[] =
{_("millimeters"), _("inches") }; { _( "millimeters" ), _( "inches" ) };
m_Choice_Unit = new wxRadioBox(this, ID_SEL_DRILL_UNITS, m_Choice_Unit = new wxRadioBox( this, ID_SEL_DRILL_UNITS,
_("Drill Units:"), _( "Drill Units:" ),
wxDefaultPosition,wxSize(-1,-1), wxDefaultPosition, wxSize( -1, -1 ),
2,choice_unit_msg,1,wxRA_SPECIFY_COLS); 2, choice_unit_msg, 1, wxRA_SPECIFY_COLS );
if ( Unit_Drill_is_Inch )m_Choice_Unit->SetSelection(1); if( Unit_Drill_is_Inch )
LeftBoxSizer->Add(m_Choice_Unit, 0, wxGROW|wxALL, 5); m_Choice_Unit->SetSelection( 1 );
LeftBoxSizer->Add( m_Choice_Unit, 0, wxGROW | wxALL, 5 );
wxString choice_zeros_format_msg[] = {
_("decimal format"), wxString choice_zeros_format_msg[] = {
_("suppress leading zeros"), _("suppress trailing zeros"), _("keep zeros") _( "decimal format" ),
_( "suppress leading zeros" ), _( "suppress trailing zeros" ), _( "keep zeros" )
}; };
m_Choice_Zeros_Format = new wxRadioBox(this, ID_SEL_ZEROS_FMT, m_Choice_Zeros_Format = new wxRadioBox( this, ID_SEL_ZEROS_FMT,
_("Zeros Format"), _( "Zeros Format" ),
wxDefaultPosition,wxSize(-1,-1), wxDefaultPosition, wxSize( -1, -1 ),
4,choice_zeros_format_msg,1,wxRA_SPECIFY_COLS); 4, choice_zeros_format_msg, 1, wxRA_SPECIFY_COLS );
m_Choice_Zeros_Format->SetSelection(s_Zeros_Format); m_Choice_Zeros_Format->SetSelection( s_Zeros_Format );
LeftBoxSizer->Add(m_Choice_Zeros_Format, 0, wxGROW|wxALL, 5); LeftBoxSizer->Add( m_Choice_Zeros_Format, 0, wxGROW | wxALL, 5 );
wxString *choice_precision_msg; wxString* choice_precision_msg;
wxString choice_precision_inch_msg[] = { _("2:3"), _("2:4")}; wxString choice_precision_inch_msg[] = { _( "2:3" ), _( "2:4" ) };
wxString choice_precision_metric_msg[] = { _("3:2"), _("3:3")}; wxString choice_precision_metric_msg[] = { _( "3:2" ), _( "3:3" ) };
if (Unit_Drill_is_Inch) if( Unit_Drill_is_Inch )
choice_precision_msg = choice_precision_inch_msg; choice_precision_msg = choice_precision_inch_msg;
else else
choice_precision_msg = choice_precision_metric_msg; choice_precision_msg = choice_precision_metric_msg;
m_Choice_Precision = new wxRadioBox(this, ID_SEL_PRECISION, m_Choice_Precision = new wxRadioBox( this, ID_SEL_PRECISION,
_("Precision"), _( "Precision" ),
wxDefaultPosition, wxSize(-1,-1), wxDefaultPosition, wxSize( -1, -1 ),
2,choice_precision_msg,1,wxRA_SPECIFY_COLS); 2, choice_precision_msg, 1, wxRA_SPECIFY_COLS );
LeftBoxSizer->Add(m_Choice_Precision, 0, wxGROW|wxALL, 5); LeftBoxSizer->Add( m_Choice_Precision, 0, wxGROW | wxALL, 5 );
wxString ps; wxString ps;
ps << s_Precision.m_lhs << wxT(":") << s_Precision.m_rhs; ps << s_Precision.m_lhs << wxT( ":" ) << s_Precision.m_rhs;
m_Choice_Precision->SetStringSelection(ps); m_Choice_Precision->SetStringSelection( ps );
if (s_Zeros_Format==DECIMAL_FORMAT) m_Choice_Precision->Enable(false); if( s_Zeros_Format==DECIMAL_FORMAT )
m_Choice_Precision->Enable( false );
wxString choice_drill_offset_msg[] =
{_("absolute"), _("auxiliary axis")}; wxString choice_drill_offset_msg[] =
m_Choice_Drill_Offset = new wxRadioBox(this, ID_SEL_DRILL_SHEET, { _( "absolute" ), _( "auxiliary axis" ) };
_("Drill Origin:"), m_Choice_Drill_Offset = new wxRadioBox( this, ID_SEL_DRILL_SHEET,
wxDefaultPosition,wxSize(-1,-1), _( "Drill Origin:" ),
2,choice_drill_offset_msg,1,wxRA_SPECIFY_COLS); wxDefaultPosition, wxSize( -1, -1 ),
if ( DrillOriginIsAuxAxis ) m_Choice_Drill_Offset->SetSelection(1); 2, choice_drill_offset_msg, 1, wxRA_SPECIFY_COLS );
LeftBoxSizer->Add(m_Choice_Drill_Offset, 0, wxGROW|wxALL, 5); if( DrillOriginIsAuxAxis )
m_Choice_Drill_Offset->SetSelection( 1 );
LeftBoxSizer->Add( m_Choice_Drill_Offset, 0, wxGROW | wxALL, 5 );
/* second column */ /* second column */
wxString choice_drill_map_msg[] = wxString choice_drill_map_msg[] =
{_("None"), _("drill sheet (HPGL)"), _("drill sheet (PostScript)")}; { _( "None" ), _( "drill sheet (HPGL)" ), _( "drill sheet (PostScript)" ) };
m_Choice_Drill_Map = new wxRadioBox(this, ID_SEL_DRILL_SHEET, m_Choice_Drill_Map = new wxRadioBox( this, ID_SEL_DRILL_SHEET,
_("Drill Sheet:"), _( "Drill Sheet:" ),
wxDefaultPosition,wxSize(-1,-1), wxDefaultPosition, wxSize( -1, -1 ),
3,choice_drill_map_msg,1,wxRA_SPECIFY_COLS); 3, choice_drill_map_msg, 1, wxRA_SPECIFY_COLS );
MiddleBoxSizer->Add(m_Choice_Drill_Map, 0, wxGROW|wxALL, 5); MiddleBoxSizer->Add( m_Choice_Drill_Map, 0, wxGROW | wxALL, 5 );
wxString choice_drill_report_msg[] = wxString choice_drill_report_msg[] =
{_("None"), _("Drill report") }; { _( "None" ), _( "Drill report" ) };
m_Choice_Drill_Report = new wxRadioBox(this, ID_SEL_DRILL_REPORT, m_Choice_Drill_Report = new wxRadioBox( this, ID_SEL_DRILL_REPORT,
_("Drill Report:"), _( "Drill Report:" ),
wxDefaultPosition,wxSize(-1,-1), wxDefaultPosition, wxSize( -1, -1 ),
2,choice_drill_report_msg,1,wxRA_SPECIFY_COLS); 2, choice_drill_report_msg, 1, wxRA_SPECIFY_COLS );
MiddleBoxSizer->Add(m_Choice_Drill_Report, 0, wxGROW|wxALL, 5); MiddleBoxSizer->Add( m_Choice_Drill_Report, 0, wxGROW | wxALL, 5 );
m_ViaDrillCtrl = new WinEDA_ValueCtrl(this, _("Via Drill"), m_ViaDrillCtrl = new WinEDA_ValueCtrl( this, _(
g_DesignSettings.m_ViaDrill, g_UnitMetric, MiddleBoxSizer, "Via Drill" ),
m_Parent->m_InternalUnits); g_DesignSettings.m_ViaDrill, g_UnitMetric,
MiddleBoxSizer,
m_PenNum = new WinEDA_ValueCtrl(this, _("Pen Number"), m_Parent->m_InternalUnits );
g_HPGL_Pen_Num, 2, MiddleBoxSizer, 1);
m_PenNum = new WinEDA_ValueCtrl( this, _( "Pen Number" ),
m_PenSpeed = new WinEDA_ValueCtrl(this, _("Speed (cm/s)"), g_HPGL_Pen_Num, 2, MiddleBoxSizer, 1 );
g_HPGL_Pen_Speed, CENTIMETRE, MiddleBoxSizer, 1);
m_PenSpeed = new WinEDA_ValueCtrl( this, _( "Speed (cm/s)" ),
m_Check_Mirror = new wxCheckBox(this, -1, _("mirror y axis")); g_HPGL_Pen_Speed, CENTIMETRE, MiddleBoxSizer, 1 );
m_Check_Mirror->SetValue(Mirror);
MiddleBoxSizer->Add(m_Check_Mirror, 0, wxGROW|wxALL, 5); m_Check_Mirror = new wxCheckBox( this, -1, _( "mirror y axis" ) );
m_Check_Mirror->SetValue( Mirror );
m_Check_Minimal = new wxCheckBox(this, -1, _("minimal header")); MiddleBoxSizer->Add( m_Check_Mirror, 0, wxGROW | wxALL, 5 );
m_Check_Minimal->SetValue(Minimal);
MiddleBoxSizer->Add(m_Check_Minimal, 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 */ /* third column, buttons */
wxButton * Button = new wxButton(this, ID_CREATE_DRILL_FILES, wxButton* Button = new wxButton( this, ID_CREATE_DRILL_FILES,
_("&Execute")); _( "&Execute" ) );
Button->SetForegroundColour(*wxRED); Button->SetForegroundColour( *wxRED );
RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
Button = new wxButton(this, ID_CLOSE_DRILL, _("&Close")); Button = new wxButton( this, ID_CLOSE_DRILL, _( "&Close" ) );
Button->SetForegroundColour(*wxBLUE); Button->SetForegroundColour( *wxBLUE );
RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
GetSizer()->Fit(this); GetSizer()->Fit( this );
GetSizer()->SetSizeHints(this); GetSizer()->SetSizeHints( this );
Centre(); Centre();
} }
...@@ -276,40 +284,42 @@ void WinEDA_DrillFrame::SetParams() ...@@ -276,40 +284,42 @@ void WinEDA_DrillFrame::SetParams()
Unit_Drill_is_Inch = m_Choice_Unit->GetSelection(); Unit_Drill_is_Inch = m_Choice_Unit->GetSelection();
g_HPGL_Pen_Speed = m_PenSpeed->GetValue(); g_HPGL_Pen_Speed = m_PenSpeed->GetValue();
g_HPGL_Pen_Num = m_PenNum->GetValue(); g_HPGL_Pen_Num = m_PenNum->GetValue();
if ( m_Choice_Drill_Offset->GetSelection() == 0) if( m_Choice_Drill_Offset->GetSelection() == 0 )
File_Drill_Offset = wxPoint(0,0); File_Drill_Offset = wxPoint( 0, 0 );
else else
File_Drill_Offset = m_Parent->m_Auxiliary_Axis_Position; File_Drill_Offset = m_Parent->m_Auxiliary_Axis_Position;
/* get precision from radio box strings (this just makes it easier to /* get precision from radio box strings (this just makes it easier to
change options later)*/ * change options later)*/
wxString ps = m_Choice_Precision->GetStringSelection(); wxString ps = m_Choice_Precision->GetStringSelection();
wxString l=ps.substr(0,1); wxString l = ps.substr( 0, 1 );
wxString r=ps.substr(2,1); wxString r = ps.substr( 2, 1 );
l.ToLong((long*)&s_Precision.m_lhs); l.ToLong( (long*) &s_Precision.m_lhs );
r.ToLong((long*)&s_Precision.m_rhs); r.ToLong( (long*) &s_Precision.m_rhs );
} }
/*****************************************************************/ /*****************************************************************/
void WinEDA_PcbFrame::InstallDrillFrame(wxCommandEvent& event) void WinEDA_PcbFrame::InstallDrillFrame( wxCommandEvent& event )
/*****************************************************************/ /*****************************************************************/
/* This function displays and deletes the dialog frame for drill tools /* This function displays and deletes the dialog frame for drill tools
*/ */
{ {
wxConfig * Config = m_Parent->m_EDA_Config; wxConfig* Config = m_Parent->m_EDA_Config;
if( Config ) if( Config )
{ {
Config->Read(ZerosFormatKey, & s_Zeros_Format ); Config->Read( ZerosFormatKey, &s_Zeros_Format );
Config->Read(LeftPrecisionKey, & s_Precision.m_lhs ); Config->Read( LeftPrecisionKey, &s_Precision.m_lhs );
Config->Read(RightPrecisionKey, & s_Precision.m_rhs ); Config->Read( RightPrecisionKey, &s_Precision.m_rhs );
Config->Read(MirrorKey, &Mirror ); Config->Read( MirrorKey, &Mirror );
Config->Read(MinimalKey, &Minimal ); Config->Read( MinimalKey, &Minimal );
Config->Read(UnitDrillInchKey, &Unit_Drill_is_Inch ); Config->Read( UnitDrillInchKey, &Unit_Drill_is_Inch );
Config->Read(DrillOriginIsAuxAxisKey, &DrillOriginIsAuxAxis ); Config->Read( DrillOriginIsAuxAxisKey, &DrillOriginIsAuxAxis );
} }
WinEDA_DrillFrame * frame = new WinEDA_DrillFrame(this); WinEDA_DrillFrame* frame = new WinEDA_DrillFrame( this );
frame->ShowModal(); frame->Destroy(); frame->ShowModal(); frame->Destroy();
} }
...@@ -318,40 +328,40 @@ WinEDA_DrillFrame * frame = new WinEDA_DrillFrame(this); ...@@ -318,40 +328,40 @@ WinEDA_DrillFrame * frame = new WinEDA_DrillFrame(this);
/******************************************/ /******************************************/
void WinEDA_DrillFrame::UpdateConfig() void WinEDA_DrillFrame::UpdateConfig()
/******************************************/ /******************************************/
/* Save drill options: */ /* Save drill options: */
{ {
SetParams(); SetParams();
wxConfig * Config = m_Parent->m_Parent->m_EDA_Config; wxConfig* Config = m_Parent->m_Parent->m_EDA_Config;
if( Config ) if( Config )
{ {
Config->Write(ZerosFormatKey, s_Zeros_Format); Config->Write( ZerosFormatKey, s_Zeros_Format );
Config->Write(LeftPrecisionKey, s_Precision.m_lhs ); Config->Write( LeftPrecisionKey, s_Precision.m_lhs );
Config->Write(RightPrecisionKey, s_Precision.m_rhs ); Config->Write( RightPrecisionKey, s_Precision.m_rhs );
Config->Write(MirrorKey, Mirror); Config->Write( MirrorKey, Mirror );
Config->Write(MinimalKey, Minimal); Config->Write( MinimalKey, Minimal );
Config->Write(UnitDrillInchKey, Unit_Drill_is_Inch); Config->Write( UnitDrillInchKey, Unit_Drill_is_Inch );
Config->Write(DrillOriginIsAuxAxisKey, DrillOriginIsAuxAxis); Config->Write( DrillOriginIsAuxAxisKey, DrillOriginIsAuxAxis );
} }
} }
/****************************************************************/ /****************************************************************/
void WinEDA_DrillFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) void WinEDA_DrillFrame::OnQuit( wxCommandEvent& WXUNUSED (event) )
/****************************************************************/ /****************************************************************/
{ {
UpdateConfig(); /* Save drill options: */ UpdateConfig(); /* Save drill options: */
Close(true); // true is to force the frame to close Close( true ); // true is to force the frame to close
} }
/*************************************************************/ /*************************************************************/
void WinEDA_DrillFrame::GenDrillFiles(wxCommandEvent& event) void WinEDA_DrillFrame::GenDrillFiles( wxCommandEvent& event )
/*************************************************************/ /*************************************************************/
{ {
wxString FullFileName, Mask(wxT("*")), Ext(wxT(".drl")); wxString FullFileName, Mask( wxT( "*" ) ), Ext( wxT( ".drl" ) );
int ii; int ii;
wxString msg; wxString msg;
UpdateConfig(); /* set params and Save drill options */ UpdateConfig(); /* set params and Save drill options */
...@@ -359,14 +369,15 @@ wxString msg; ...@@ -359,14 +369,15 @@ wxString msg;
/* Calcul des echelles de conversion */ /* Calcul des echelles de conversion */
conv_unit = 0.0001; /* unites = INCHES */ conv_unit = 0.0001; /* unites = INCHES */
if( ! Unit_Drill_is_Inch) conv_unit = 0.000254; /* unites = mm */ if( !Unit_Drill_is_Inch )
conv_unit = 0.000254; /* unites = mm */
/* Init nom fichier */ /* Init nom fichier */
FullFileName = m_Parent->m_CurrentScreen->m_FileName; FullFileName = m_Parent->m_CurrentScreen->m_FileName;
ChangeFileNameExt(FullFileName, Ext); ChangeFileNameExt( FullFileName, Ext );
Mask += Ext; Mask += Ext;
FullFileName = EDA_FileSelector(_("Drill file"), FullFileName = EDA_FileSelector( _( "Drill file" ),
wxEmptyString, /* Chemin par defaut */ wxEmptyString, /* Chemin par defaut */
FullFileName, /* nom fichier par defaut */ FullFileName, /* nom fichier par defaut */
Ext, /* extension par defaut */ Ext, /* extension par defaut */
...@@ -375,180 +386,205 @@ wxString msg; ...@@ -375,180 +386,205 @@ wxString msg;
wxFD_SAVE, wxFD_SAVE,
TRUE TRUE
); );
if ( FullFileName != wxEmptyString ) if( FullFileName != wxEmptyString )
{ {
dest = wxFopen(FullFileName, wxT("w") ); dest = wxFopen( FullFileName, wxT( "w" ) );
if (dest == 0) if( dest == 0 )
{ {
msg = _("Unable to create file ") + FullFileName; msg = _( "Unable to create file " ) + FullFileName;
DisplayError(this, msg); DisplayError( this, msg );
EndModal(0); EndModal( 0 );
return ; return;
} }
/* Init : */ /* Init : */
Affiche_1_Parametre(m_Parent, 0,_("File"),FullFileName,BLUE) ; Affiche_1_Parametre( m_Parent, 0, _( "File" ), FullFileName, BLUE );
Init_Drill(); Init_Drill();
ii = Gen_Liste_Forets( (FORET *) adr_lowmem,TRUE); ii = Gen_Liste_Forets( (FORET*) adr_lowmem, TRUE );
msg.Printf( wxT("%d"),ii); msg.Printf( wxT( "%d" ), ii );
Affiche_1_Parametre(m_Parent, 30,_("Tools"), msg, BROWN); Affiche_1_Parametre( m_Parent, 30, _( "Tools" ), msg, BROWN );
ii = Gen_Drill_File_EXCELLON( (FORET *) adr_lowmem); ii = Gen_Drill_File_EXCELLON( (FORET*) adr_lowmem );
msg.Printf( wxT("%d"),ii); msg.Printf( wxT( "%d" ), ii );
Affiche_1_Parametre(m_Parent, 45,_("Drill"), msg, GREEN); Affiche_1_Parametre( m_Parent, 45, _( "Drill" ), msg, GREEN );
Fin_Drill(); Write_End_Of_File_Drill();
} }
switch ( m_Choice_Drill_Map->GetSelection() ) switch( m_Choice_Drill_Map->GetSelection() )
{ {
case 0: break; case 0:
break;
case 1: case 1:
GenDrillMap(PLOT_FORMAT_HPGL); GenDrillMap( PLOT_FORMAT_HPGL );
break; break;
case 2: case 2:
GenDrillMap(PLOT_FORMAT_POST); GenDrillMap( PLOT_FORMAT_POST );
break; break;
} }
if ( m_Choice_Drill_Report->GetSelection() > 0 ) if( m_Choice_Drill_Report->GetSelection() > 0 )
GenDrillReport(); GenDrillReport();
EndModal(0); EndModal( 0 );
} }
/********************************************************************/ /********************************************************************/
void WinEDA_DrillFrame::UpdatePrecisionOptions(wxCommandEvent& event) void WinEDA_DrillFrame::UpdatePrecisionOptions( wxCommandEvent& event )
/********************************************************************/ /********************************************************************/
{ {
if (m_Choice_Unit->GetSelection()==1) if( m_Choice_Unit->GetSelection()==1 )
{ /* inch options */ { /* inch options */
m_Choice_Precision->SetString(0,_("2:3")); m_Choice_Precision->SetString( 0, _( "2:3" ) );
m_Choice_Precision->SetString(1,_("2:4")); m_Choice_Precision->SetString( 1, _( "2:4" ) );
} }
else else
{ /* metric options */ {
m_Choice_Precision->SetString(0,_("3:2")); /* metric options */
m_Choice_Precision->SetString(1,_("3:3")); m_Choice_Precision->SetString( 0, _( "3:2" ) );
m_Choice_Precision->SetString( 1, _( "3:3" ) );
} }
if (m_Choice_Zeros_Format->GetSelection()==DECIMAL_FORMAT) if( m_Choice_Zeros_Format->GetSelection()==DECIMAL_FORMAT )
m_Choice_Precision->Enable(false); m_Choice_Precision->Enable( false );
else else
m_Choice_Precision->Enable(true); m_Choice_Precision->Enable( true );
} }
/***************************************************************/ /***************************************************************/
int WinEDA_DrillFrame::Gen_Drill_File_EXCELLON( FORET * buffer) int WinEDA_DrillFrame::Gen_Drill_File_EXCELLON( FORET* buffer )
/***************************************************************/ /***************************************************************/
/* Create the drill file in EXECELLON format /* Create the drill file in EXECELLON format
Return hole count * Return hole count
buffer: Drill tools list * buffer: Drill tools list
*/ */
{ {
FORET * foret; FORET* foret;
TRACK * pt_piste; TRACK* pt_piste;
D_PAD * pt_pad; D_PAD* pt_pad;
MODULE * Module; MODULE* Module;
int ii, diam, nb_trous; int ii, diam, nb_trous;
int x0, y0, xf, yf, xc, yc; int x0, y0, xf, yf, xc, yc;
float xt,yt; float xt, yt;
char line[1024]; char line[1024];
/* Create the pad drill list : */ /* Create the pad drill list : */
nb_trous = 0; nb_trous = 0;
/* Examen de la liste des forets */ /* Examen de la liste des forets */
for(ii = 0, foret = buffer; ii < DrillToolsCount; ii++, foret++) for( ii = 0, foret = buffer; ii < DrillToolsCount; ii++, foret++ )
{ {
sprintf(line,"T%d\n",ii+1); fputs(line,dest); sprintf( line, "T%d\n", ii + 1 ); fputs( line, dest );
/* Read the via list */ /* Read the via list */
{ {
pt_piste = m_Parent->m_Pcb->m_Track; pt_piste = m_Parent->m_Pcb->m_Track;
for( ; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext) for( ; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext )
{ {
if(pt_piste->Type() != TYPEVIA) continue; if( pt_piste->Type() != TYPEVIA )
if ( pt_piste->m_Drill == 0 ) continue; continue;
int via_drill = ( pt_piste->m_Drill < 0 ) ? g_DesignSettings.m_ViaDrill : pt_piste->m_Drill; if( pt_piste->m_Drill == 0 )
if ( foret->m_Diameter != via_drill ) continue;
int via_drill = ( pt_piste->m_Drill <
0 ) ? g_DesignSettings.m_ViaDrill : pt_piste->m_Drill;
if( foret->m_Diameter != via_drill )
continue; continue;
x0 = pt_piste->m_Start.x - File_Drill_Offset.x; x0 = pt_piste->m_Start.x - File_Drill_Offset.x;
y0 = pt_piste->m_Start.y - File_Drill_Offset.y; y0 = pt_piste->m_Start.y - File_Drill_Offset.y;
//<ryan's edit> //<ryan's edit>
if (!Mirror) y0 *= -1; if( !Mirror )
y0 *= -1;
xt = float(x0) * conv_unit; yt = float(y0) * conv_unit; xt = float (x0) * conv_unit; yt = float (y0) * conv_unit;
if(Unit_Drill_is_Inch) if( Unit_Drill_is_Inch )
{ {
Gen_Line_EXCELLON(line, xt, yt); Gen_Line_EXCELLON( line, xt, yt );
} }
//</ryan's edit> //</ryan's edit>
else else
{ /* metric 3:3 */ {
Gen_Line_EXCELLON(line, xt*10, yt*10); /* metric 3:3 */
Gen_Line_EXCELLON( line, xt * 10, yt * 10 );
} }
// si les flottants sont ecrits avec , au lieu de . // si les flottants sont ecrits avec , au lieu de .
// conversion , -> . necessaire ! // conversion , -> . necessaire !
to_point( line ); to_point( line );
fputs(line,dest); fputs( line, dest );
nb_trous++; nb_trous++;
} }
} }
/* Read pad list and create Drill infos for round holes only: */ /* Read pad list and create Drill infos for round holes only: */
Module = m_Parent->m_Pcb->m_Modules; Module = m_Parent->m_Pcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*)Module->Pnext ) for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{ {
/* Examen des pastilles */ /* Examen des pastilles */
pt_pad = (D_PAD*) Module->m_Pads; pt_pad = (D_PAD*) Module->m_Pads;
for ( ; pt_pad != NULL; pt_pad = (D_PAD*)pt_pad->Pnext ) for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
{ {
if ( pt_pad->m_DrillShape != CIRCLE ) continue; if( pt_pad->m_DrillShape != CIRCLE )
continue;
diam = pt_pad->m_Drill.x; diam = pt_pad->m_Drill.x;
if ( diam == 0 ) continue; if( diam == 0 )
if(diam != foret->m_Diameter) continue; continue;
if( diam != foret->m_Diameter )
continue;
/* Compute the hole coordinates: */ /* Compute the hole coordinates: */
x0 = pt_pad->m_Pos.x - File_Drill_Offset.x; x0 = pt_pad->m_Pos.x - File_Drill_Offset.x;
y0 = pt_pad->m_Pos.y - File_Drill_Offset.y; y0 = pt_pad->m_Pos.y - File_Drill_Offset.y;
//<ryan's edit> //<ryan's edit>
if (!Mirror) y0 *= -1; if( !Mirror )
y0 *= -1;
xt = float(x0) * conv_unit; yt = float(y0) * conv_unit; xt = float (x0) * conv_unit; yt = float (y0) * conv_unit;
if(Unit_Drill_is_Inch) if( Unit_Drill_is_Inch )
Gen_Line_EXCELLON(line, xt, yt); Gen_Line_EXCELLON( line, xt, yt );
else else
Gen_Line_EXCELLON(line, xt*10, yt*10); Gen_Line_EXCELLON( line, xt * 10, yt * 10 );
to_point( line ); // Internationalization compensation (, to . for floats) to_point( line ); // Internationalization compensation (, to . for floats)
fputs(line,dest); fputs( line, dest );
nb_trous++; nb_trous++;
} /* Fin examen 1 module */ }
} /* Fin 1 passe de foret */
/* Fin examen 1 module */
}
/* Fin 1 passe de foret */
/* Read pad list and create Drill infos for oblong holes only: */ /* Read pad list and create Drill infos for oblong holes only: */
Module = m_Parent->m_Pcb->m_Modules; Module = m_Parent->m_Pcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*)Module->Pnext ) for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{ {
/* Examen des pastilles */ /* Examen des pastilles */
pt_pad = (D_PAD*) Module->m_Pads; pt_pad = (D_PAD*) Module->m_Pads;
for ( ; pt_pad != NULL; pt_pad = (D_PAD*)pt_pad->Pnext ) for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
{ {
if ( pt_pad->m_DrillShape != OVALE ) continue; if( pt_pad->m_DrillShape != OVALE )
continue;
diam = MIN( pt_pad->m_Drill.x, pt_pad->m_Drill.y ) ; diam = MIN( pt_pad->m_Drill.x, pt_pad->m_Drill.y );
if ( diam == 0 ) continue; if( diam == 0 )
if(diam != foret->m_Diameter) continue; continue;
if( diam != foret->m_Diameter )
continue;
/* Compute the hole coordinates: */ /* Compute the hole coordinates: */
xc = x0 = xf = pt_pad->m_Pos.x - File_Drill_Offset.x; xc = x0 = xf = pt_pad->m_Pos.x - File_Drill_Offset.x;
yc = y0 = yf = pt_pad->m_Pos.y - File_Drill_Offset.y; yc = y0 = yf = pt_pad->m_Pos.y - File_Drill_Offset.y;
/* Compute the start and end coordinates for the shape */ /* Compute the start and end coordinates for the shape */
if ( pt_pad->m_Drill.x < pt_pad->m_Drill.y ) if( pt_pad->m_Drill.x < pt_pad->m_Drill.y )
{ {
int delta = (pt_pad->m_Drill.y - pt_pad->m_Drill.x) / 2; int delta = (pt_pad->m_Drill.y - pt_pad->m_Drill.x) / 2;
y0 -= delta; yf += delta; y0 -= delta; yf += delta;
...@@ -558,215 +594,264 @@ char line[1024]; ...@@ -558,215 +594,264 @@ char line[1024];
int delta = (pt_pad->m_Drill.x - pt_pad->m_Drill.y) / 2; int delta = (pt_pad->m_Drill.x - pt_pad->m_Drill.y) / 2;
x0 -= delta; xf += delta; x0 -= delta; xf += delta;
} }
RotatePoint(&x0, &y0, xc, yc, pt_pad->m_Orient); RotatePoint( &x0, &y0, xc, yc, pt_pad->m_Orient );
RotatePoint(&xf, &yf, xc, yc, pt_pad->m_Orient); RotatePoint( &xf, &yf, xc, yc, pt_pad->m_Orient );
//<ryan's edit> //<ryan's edit>
if (!Mirror) { y0 *= -1; yf *= -1; } if( !Mirror )
{
y0 *= -1; yf *= -1;
}
// sprintf(line,"T%d\n",ii+1); fputs(line,dest); // sprintf(line,"T%d\n",ii+1); fputs(line,dest);
xt = float(x0) * conv_unit; yt = float(y0) * conv_unit; xt = float (x0) * conv_unit; yt = float (y0) * conv_unit;
if(Unit_Drill_is_Inch) if( Unit_Drill_is_Inch )
Gen_Line_EXCELLON(line, xt, yt); Gen_Line_EXCELLON( line, xt, yt );
else else
Gen_Line_EXCELLON(line, xt*10, yt*10); Gen_Line_EXCELLON( line, xt * 10, yt * 10 );
to_point( line ); to_point( line );
/* remove the '\n' from end of line: */ /* remove the '\n' from end of line: */
for ( int kk = 0; line[kk] != 0; kk++ ) for( int kk = 0; line[kk] != 0; kk++ )
if ( line[kk] == '\n' || line[kk] =='\r' ) if( line[kk] == '\n' || line[kk] =='\r' )
line[kk] = 0; line[kk] = 0;
fputs(line,dest);
fputs("G85",dest); fputs( line, dest );
fputs( "G85", dest );
xt = float(xf) * conv_unit; yt = float(yf) * conv_unit; xt = float (xf) * conv_unit; yt = float (yf) * conv_unit;
if(Unit_Drill_is_Inch) if( Unit_Drill_is_Inch )
Gen_Line_EXCELLON(line, xt, yt); Gen_Line_EXCELLON( line, xt, yt );
else else
Gen_Line_EXCELLON(line, xt*10, yt*10); Gen_Line_EXCELLON( line, xt * 10, yt * 10 );
to_point( line ); fputs(line,dest); to_point( line ); fputs( line, dest );
fputs("G05\n",dest); fputs( "G05\n", dest );
nb_trous++; nb_trous++;
} /* Fin examen 1 module */ }
} /* fin analyse des trous de modules pour le foret en cours*/
} /* fin analyse des forets */ /* Fin examen 1 module */
}
/* fin analyse des trous de modules pour le foret en cours*/
}
/* fin analyse des forets */
return(nb_trous); return nb_trous;
} }
/**********************************************************************/ /**********************************************************************/
void WinEDA_DrillFrame::Gen_Line_EXCELLON(char *line, float x, float y) void WinEDA_DrillFrame::Gen_Line_EXCELLON( char* line, float x, float y )
/**********************************************************************/ /**********************************************************************/
{ {
wxString xs, ys; wxString xs, ys;
int xpad = s_Precision.m_lhs + s_Precision.m_rhs; int xpad = s_Precision.m_lhs + s_Precision.m_rhs;
int ypad = xpad; int ypad = xpad;
/* I need to come up with an algorithm that handles any lhs:rhs format.*/ /* I need to come up with an algorithm that handles any lhs:rhs format.*/
/* one idea is to take more inputs for xpad/ypad when metric is used. */ /* one idea is to take more inputs for xpad/ypad when metric is used. */
switch (s_Zeros_Format) switch( s_Zeros_Format )
{ {
default: default:
case DECIMAL_FORMAT: case DECIMAL_FORMAT:
sprintf(line,"X%.3fY%.3f\n", x, y); sprintf( line, "X%.3fY%.3f\n", x, y );
break; break;
case SUPPRESS_LEADING: /* that should work now */ case SUPPRESS_LEADING: /* that should work now */
for (int i=0;i< s_Precision.m_rhs;i++) for( int i = 0; i< s_Precision.m_rhs; i++ )
{ x*=10; y*=10; } {
sprintf(line,"X%dY%d\n", (int) round(x), (int) round(y) ); x *= 10; y *= 10;
}
sprintf( line, "X%dY%d\n", (int) round( x ), (int) round( y ) );
break; break;
case SUPPRESS_TRAILING: case SUPPRESS_TRAILING:
{ {
for (int i=0;i< s_Precision.m_rhs;i++) for( int i = 0; i< s_Precision.m_rhs; i++ )
{ x *= 10; y*=10; } {
if (x<0)xpad++; x *= 10; y *= 10;
if (y<0)ypad++; }
if( x<0 )
xpad++;
if( y<0 )
ypad++;
xs.Printf( wxT("%0*d"), xpad, (int) round(x) ); xs.Printf( wxT( "%0*d" ), xpad, (int) round( x ) );
ys.Printf( wxT("%0*d"), ypad, (int) round(y) ); ys.Printf( wxT( "%0*d" ), ypad, (int) round( y ) );
size_t j=xs.Len()-1; size_t j = xs.Len() - 1;
while (xs[j] == '0' && j) xs.Truncate(j--); while( xs[j] == '0' && j )
j=ys.Len()-1; xs.Truncate( j-- );
while (ys[j] == '0' && j) ys.Truncate(j--);
sprintf(line, "X%sY%s\n", CONV_TO_UTF8(xs), CONV_TO_UTF8(ys)); j = ys.Len() - 1;
while( ys[j] == '0' && j )
ys.Truncate( j-- );
sprintf( line, "X%sY%s\n", CONV_TO_UTF8( xs ), CONV_TO_UTF8( ys ) );
break; break;
} }
case KEEP_ZEROS: case KEEP_ZEROS:
for (int i=0;i< s_Precision.m_rhs;i++) for( int i = 0; i< s_Precision.m_rhs; i++ )
{ x *= 10; y*=10; } {
if (x<0)xpad++; x *= 10; y *= 10;
if (y<0)ypad++; }
xs.Printf( wxT("%0*d"), xpad, (int) round(x) );
ys.Printf( wxT("%0*d"), ypad, (int) round(y) ); if( x<0 )
sprintf(line, "X%sY%s\n", CONV_TO_UTF8(xs), CONV_TO_UTF8(ys)); xpad++;
if( y<0 )
ypad++;
xs.Printf( wxT( "%0*d" ), xpad, (int) round( x ) );
ys.Printf( wxT( "%0*d" ), ypad, (int) round( y ) );
sprintf( line, "X%sY%s\n", CONV_TO_UTF8( xs ), CONV_TO_UTF8( ys ) );
break; break;
}; }
;
} }
/***************************************************/
/***************************************************/ /***************************************************/
FORET * GetOrAddForet( FORET * buffer, int diameter) FORET* GetOrAddForet( FORET* buffer, int diameter )
/***************************************************/ /***************************************************/
/* Search the drill tool for the diameter "diameter" /* Search the drill tool for the diameter "diameter"
Create a new one if not found * Create a new one if not found
*/ */
{ {
int ii; int ii;
FORET * foret; FORET* foret;
if(diameter == 0) return NULL; if( diameter == 0 )
return NULL;
/* Search for an existing tool: */ /* Search for an existing tool: */
for(ii = 0, foret = buffer ; ii < DrillToolsCount; ii++, foret++) for( ii = 0, foret = buffer; ii < DrillToolsCount; ii++, foret++ )
{ {
if(foret->m_Diameter == diameter) /* found */ if( foret->m_Diameter == diameter ) /* found */
return foret; return foret;
} }
/* No tool found, we must create a new one */ /* No tool found, we must create a new one */
DrillToolsCount ++; DrillToolsCount++;
foret->m_TotalCount = 0; foret->m_TotalCount = 0;
foret->m_OvalCount = 0; foret->m_OvalCount = 0;
foret->m_Diameter = diameter; foret->m_Diameter = diameter;
return foret; return foret;
} }
/* Sort function by drill value */ /* Sort function by drill value */
int Sort_by_Drill_Value(void * foret1, void * foret2) int Sort_by_Drill_Value( void* foret1, void* foret2 )
{ {
return( ((FORET*)foret1)->m_Diameter - ((FORET*)foret2)->m_Diameter); return ( (FORET*) foret1 )->m_Diameter - ( (FORET*) foret2 )->m_Diameter;
} }
/*********************************************************************/ /*********************************************************************/
int WinEDA_DrillFrame::Gen_Liste_Forets( FORET * buffer, bool print_header) int WinEDA_DrillFrame::Gen_Liste_Forets( FORET* buffer, bool print_header )
/**********************************************************************/ /**********************************************************************/
/* Etablit la liste des forets de percage, dans l'ordre croissant des
diametres
Retourne:
Nombre de Forets
Mise a jour: DrillToolsCount = nombre de forets differents /* Etablit la liste des forets de percage, dans l'ordre croissant des
Genere une liste de DrillToolsCount structures FORET a partir de buffer * diametres
*/ * Retourne:
* Nombre de Forets
*
* Mise a jour: DrillToolsCount = nombre de forets differents
* Genere une liste de DrillToolsCount structures FORET a partir de buffer
*/
{ {
FORET * foret; FORET* foret;
D_PAD * pt_pad; D_PAD* pt_pad;
MODULE * Module; MODULE* Module;
int ii, diam; int ii, diam;
char line[1024]; char line[1024];
DrillToolsCount = 0; foret = buffer; DrillToolsCount = 0; foret = buffer;
/* Create the via tools */ /* Create the via tools */
TRACK * pt_piste = m_Parent->m_Pcb->m_Track; TRACK* pt_piste = m_Parent->m_Pcb->m_Track;
for( ; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext ) for( ; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext )
{ {
if(pt_piste->Type() != TYPEVIA) continue; if( pt_piste->Type() != TYPEVIA )
if ( pt_piste->m_Drill == 0 ) continue; continue;
if( pt_piste->m_Drill == 0 )
continue;
int via_drill = g_DesignSettings.m_ViaDrill; int via_drill = g_DesignSettings.m_ViaDrill;
if ( pt_piste->m_Drill > 0 ) // Drill value is not the default value if( pt_piste->m_Drill > 0 ) // Drill value is not the default value
via_drill = pt_piste->m_Drill; via_drill = pt_piste->m_Drill;
foret = GetOrAddForet( buffer, via_drill); foret = GetOrAddForet( buffer, via_drill );
if ( foret ) foret->m_TotalCount++; if( foret )
foret->m_TotalCount++;
} }
/* Create the pad tools : */ /* Create the pad tools : */
Module = m_Parent->m_Pcb->m_Modules; Module = m_Parent->m_Pcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*)Module->Pnext ) for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{ {
/* Examen des pastilles */ /* Examen des pastilles */
pt_pad = (D_PAD*) Module->m_Pads; pt_pad = (D_PAD*) Module->m_Pads;
for ( ; pt_pad != NULL; pt_pad = (D_PAD*)pt_pad->Pnext ) for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
{ {
if ( pt_pad->m_DrillShape == CIRCLE ) if( pt_pad->m_DrillShape == CIRCLE )
diam = pt_pad->m_Drill.x; diam = pt_pad->m_Drill.x;
else diam = MIN (pt_pad->m_Drill.x, pt_pad->m_Drill.y); else
diam = MIN( pt_pad->m_Drill.x, pt_pad->m_Drill.y );
if(diam == 0) continue; if( diam == 0 )
continue;
foret = GetOrAddForet( buffer, diam); foret = GetOrAddForet( buffer, diam );
if ( foret ) if( foret )
{ {
foret->m_TotalCount++; foret->m_TotalCount++;
if ( pt_pad->m_DrillShape == OVALE )foret->m_OvalCount++; if( pt_pad->m_DrillShape == OVALE )
foret->m_OvalCount++;
}
} }
} /* Fin examen 1 module */
/* Fin examen 1 module */
} }
/* tri des forets par ordre de diametre croissant */ /* tri des forets par ordre de diametre croissant */
qsort(buffer,DrillToolsCount,sizeof(FORET), qsort( buffer, DrillToolsCount, sizeof(FORET),
(int(*)(const void *, const void * ))Sort_by_Drill_Value); ( int( * ) ( const void*, const void* ) )Sort_by_Drill_Value );
/* Generation de la section liste des outils */ /* Generation de la section liste des outils */
if (print_header) if( print_header )
{ {
for(ii = 0, foret = (FORET*) buffer ; ii < DrillToolsCount; ii++, foret++) for( ii = 0, foret = (FORET*) buffer; ii < DrillToolsCount; ii++, foret++ )
{ {
//<ryan's edit> //<ryan's edit>
if (Unit_Drill_is_Inch) /* does it need T01, T02 or is T1,T2 ok?*/ if( Unit_Drill_is_Inch ) /* does it need T01, T02 or is T1,T2 ok?*/
sprintf(line,"T%dC%.3f\n", ii+1, sprintf( line, "T%dC%.3f\n", ii + 1,
float(foret->m_Diameter) * conv_unit); float (foret->m_Diameter) * conv_unit );
else else
sprintf(line,"T%dC%.3f\n", ii+1, sprintf( line, "T%dC%.3f\n", ii + 1,
float(foret->m_Diameter) * conv_unit * 10.0); float (foret->m_Diameter) * conv_unit * 10.0 );
//</ryan's edit> //</ryan's edit>
to_point( line ); to_point( line );
fputs(line,dest); fputs( line, dest );
} }
fputs("%\n",dest);
if (!Minimal) fputs("M47\n",dest); /* Operator message */ fputs( "%\n", dest );
fputs("G05\n",dest); /* Drill mode */ if( !Minimal )
fputs( "M47\n", dest ); /* Operator message */
fputs( "G05\n", dest ); /* Drill mode */
/* Units : */ /* Units : */
if (Unit_Drill_is_Inch && !Minimal) fputs("M72\n",dest); /* M72 = inch mode */ if( Unit_Drill_is_Inch && !Minimal )
else if (!Minimal) fputs("M71\n",dest); /* M71 = metric mode */ fputs( "M72\n", dest ); /* M72 = inch mode */
else if( !Minimal )
fputs( "M71\n", dest ); /* M71 = metric mode */
} }
return(DrillToolsCount); return DrillToolsCount;
} }
...@@ -775,103 +860,106 @@ void WinEDA_DrillFrame::Init_Drill() ...@@ -775,103 +860,106 @@ void WinEDA_DrillFrame::Init_Drill()
/***************************************/ /***************************************/
/* Print the DRILL file header */ /* Print the DRILL file header */
{ {
char Line[256]; char Line[256];
fputs("M48\n",dest); fputs( "M48\n", dest );
if (!Minimal) if( !Minimal )
{ {
DateAndTime(Line); DateAndTime( Line );
wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion(); wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion();
fprintf(dest,";DRILL file {%s} date %s\n",CONV_TO_UTF8(Title),Line); fprintf( dest, ";DRILL file {%s} date %s\n", CONV_TO_UTF8( Title ), Line );
fputs(";FORMAT={",dest); fputs( ";FORMAT={", dest );
fprintf(dest,"%s / absolute / ", fprintf( dest, "%s / absolute / ",
CONV_TO_UTF8(m_Choice_Precision->GetStringSelection())); CONV_TO_UTF8( m_Choice_Precision->GetStringSelection() ) );
fprintf(dest,"%s / ",CONV_TO_UTF8(m_Choice_Unit->GetStringSelection())); fprintf( dest, "%s / ", CONV_TO_UTF8( m_Choice_Unit->GetStringSelection() ) );
fprintf(dest,"%s}\n",CONV_TO_UTF8(m_Choice_Zeros_Format->GetStringSelection())); fprintf( dest, "%s}\n", CONV_TO_UTF8( m_Choice_Zeros_Format->GetStringSelection() ) );
fputs("R,T\nVER,1\nFMAT,2\n",dest); fputs( "R,T\nVER,1\nFMAT,2\n", dest );
} }
if( Unit_Drill_is_Inch ) fputs("INCH",dest); // Si unites en INCHES if( Unit_Drill_is_Inch )
else fputs("METRIC",dest); // Si unites en mm fputs( "INCH", dest ); // Si unites en INCHES
else
fputs( "METRIC", dest ); // Si unites en mm
switch(s_Zeros_Format) switch( s_Zeros_Format )
{ {
case SUPPRESS_LEADING: case SUPPRESS_LEADING:
case DECIMAL_FORMAT: case DECIMAL_FORMAT:
fputs(",TZ\n",dest); fputs( ",TZ\n", dest );
break; break;
case SUPPRESS_TRAILING: case SUPPRESS_TRAILING:
fputs(",LZ\n",dest); fputs( ",LZ\n", dest );
break; break;
case KEEP_ZEROS: case KEEP_ZEROS:
fputs(",TZ\n",dest); // TZ is acceptable when all zeros are kept fputs( ",TZ\n", dest ); // TZ is acceptable when all zeros are kept
break; break;
} }
if (!Minimal) if( !Minimal )
fputs("TCST,OFF\nICI,OFF\nATC,ON\n",dest); fputs( "TCST,OFF\nICI,OFF\nATC,ON\n", dest );
} }
/************************/
void Fin_Drill() /*****************************/
/************************/ void Write_End_Of_File_Drill()
/*****************************/
{ {
//add if minimal here //add if minimal here
fputs("T0\nM30\n",dest) ; fclose(dest) ; fputs( "T0\nM30\n", dest ); fclose( dest );
} }
/***********************************************/ /***********************************************/
void WinEDA_DrillFrame::GenDrillMap(int format) void WinEDA_DrillFrame::GenDrillMap( int format )
/***********************************************/ /***********************************************/
/* Genere le plan de percage (Drill map) format HPGL ou POSTSCRIPT /* Genere le plan de percage (Drill map) format HPGL ou POSTSCRIPT
*/ */
{ {
int ii, x, y; int ii, x, y;
int plotX, plotY, TextWidth; int plotX, plotY, TextWidth;
FORET * foret; FORET* foret;
int intervalle = 0, CharSize = 0; int intervalle = 0, CharSize = 0;
EDA_BaseStruct * PtStruct; EDA_BaseStruct* PtStruct;
int old_g_PlotOrient = g_PlotOrient; int old_g_PlotOrient = g_PlotOrient;
wxString FullFileName, Mask(wxT("*")), Ext; wxString FullFileName, Mask( wxT( "*" ) ), Ext;
char line[1024]; char line[1024];
int dX, dY; int dX, dY;
wxPoint BoardCentre; wxPoint BoardCentre;
int PlotMarge_in_mils = 400; // Margin in 1/1000 inch int PlotMarge_in_mils = 400; // Margin in 1/1000 inch
int marge = PlotMarge_in_mils * U_PCB; int marge = PlotMarge_in_mils * U_PCB;
wxSize SheetSize; wxSize SheetSize;
float fTextScale = 1.0; float fTextScale = 1.0;
double scale_x = 1.0, scale_y = 1.0; double scale_x = 1.0, scale_y = 1.0;
Ki_PageDescr * SheetPS = NULL; Ki_PageDescr* SheetPS = NULL;
wxString msg; wxString msg;
/* Init extension */ /* Init extension */
switch( format ) switch( format )
{ {
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
Ext = wxT("-drl.plt"); Ext = wxT( "-drl.plt" );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
Ext = wxT("-drl.ps"); Ext = wxT( "-drl.ps" );
break; break;
default: default:
DisplayError (this, wxT("WinEDA_DrillFrame::GenDrillMap() error")); DisplayError( this, wxT( "WinEDA_DrillFrame::GenDrillMap() error" ) );
return; return;
} }
/* Init file name */ /* Init file name */
FullFileName = m_Parent->m_CurrentScreen->m_FileName; FullFileName = m_Parent->m_CurrentScreen->m_FileName;
ChangeFileNameExt(FullFileName, Ext); ChangeFileNameExt( FullFileName, Ext );
Mask += Ext; Mask += Ext;
FullFileName = EDA_FileSelector(_("Drill Map file"), FullFileName = EDA_FileSelector( _( "Drill Map file" ),
wxEmptyString, /* Chemin par defaut */ wxEmptyString, /* Chemin par defaut */
FullFileName, /* nom fichier par defaut */ FullFileName, /* nom fichier par defaut */
Ext, /* extension par defaut */ Ext, /* extension par defaut */
...@@ -880,7 +968,8 @@ wxString msg; ...@@ -880,7 +968,8 @@ wxString msg;
wxFD_SAVE, wxFD_SAVE,
TRUE TRUE
); );
if ( FullFileName.IsEmpty()) return; if( FullFileName.IsEmpty() )
return;
g_PlotOrient = 0; g_PlotOrient = 0;
/* calcul des dimensions et centre du PCB */ /* calcul des dimensions et centre du PCB */
...@@ -903,7 +992,7 @@ wxString msg; ...@@ -903,7 +992,7 @@ wxString msg;
SheetSize.x *= U_PCB; SheetSize.x *= U_PCB;
SheetSize.y *= U_PCB; SheetSize.y *= U_PCB;
g_PlotOffset.x = 0; g_PlotOffset.x = 0;
g_PlotOffset.y = (int)(SheetSize.y * scale_y); g_PlotOffset.y = (int) (SheetSize.y * scale_y);
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
...@@ -912,42 +1001,42 @@ wxString msg; ...@@ -912,42 +1001,42 @@ wxString msg;
SheetPS = &g_Sheet_A4; SheetPS = &g_Sheet_A4;
SheetSize.x = SheetPS->m_Size.x * U_PCB; SheetSize.x = SheetPS->m_Size.x * U_PCB;
SheetSize.y = SheetPS->m_Size.y * U_PCB; SheetSize.y = SheetPS->m_Size.y * U_PCB;
float Xscale = (float) (SheetSize.x - (marge*2)) / dX; float Xscale = (float) ( SheetSize.x - (marge * 2) ) / dX;
float Yscale = (float) (SheetSize.y * 0.6 - (marge*2)) / dY; float Yscale = (float) ( SheetSize.y * 0.6 - (marge * 2) ) / dY;
scale_x = scale_y = MIN(Xscale, Yscale); scale_x = scale_y = MIN( Xscale, Yscale );
g_PlotOffset.x = - (SheetSize.x/2) + g_PlotOffset.x = -(SheetSize.x / 2) +
(int)(BoardCentre.x * scale_x) + marge; (int) (BoardCentre.x * scale_x) + marge;
g_PlotOffset.y = SheetSize.y/2 + g_PlotOffset.y = SheetSize.y / 2 +
(int)(BoardCentre.y * scale_y) - marge; (int) (BoardCentre.y * scale_y) - marge;
g_PlotOffset.y += SheetSize.y / 8 ; /* decalage pour legende */ g_PlotOffset.y += SheetSize.y / 8; /* decalage pour legende */
break; break;
} }
} }
dest = wxFopen(FullFileName, wxT("wt") ); dest = wxFopen( FullFileName, wxT( "wt" ) );
if (dest == 0) if( dest == 0 )
{ {
msg.Printf( _("Unable to create file <%s>"),FullFileName.GetData()) ; msg.Printf( _( "Unable to create file <%s>" ), FullFileName.GetData() );
DisplayError(this, msg); return ; DisplayError( this, msg ); return;
} }
/* Init : */ /* Init : */
m_Parent->MsgPanel->EraseMsgBox(); m_Parent->MsgPanel->EraseMsgBox();
Affiche_1_Parametre(m_Parent, 0,_("File"), FullFileName, BLUE); Affiche_1_Parametre( m_Parent, 0, _( "File" ), FullFileName, BLUE );
/* Calcul de la liste des diametres de percage (liste des forets) */ /* Calcul de la liste des diametres de percage (liste des forets) */
ii = Gen_Liste_Forets( (FORET *) adr_lowmem, FALSE); ii = Gen_Liste_Forets( (FORET*) adr_lowmem, FALSE );
msg.Printf( wxT("%d"),ii); msg.Printf( wxT( "%d" ), ii );
Affiche_1_Parametre(m_Parent, 48, _("Tools"), msg, BROWN); Affiche_1_Parametre( m_Parent, 48, _( "Tools" ), msg, BROWN );
switch( format ) switch( format )
{ {
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
InitPlotParametresHPGL(g_PlotOffset, scale_x, scale_y); InitPlotParametresHPGL( g_PlotOffset, scale_x, scale_y );
PrintHeaderHPGL(dest, g_HPGL_Pen_Speed,g_HPGL_Pen_Num); PrintHeaderHPGL( dest, g_HPGL_Pen_Speed, g_HPGL_Pen_Num );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
...@@ -956,11 +1045,11 @@ wxString msg; ...@@ -956,11 +1045,11 @@ wxString msg;
BBox[0] = BBox[1] = PlotMarge_in_mils; BBox[0] = BBox[1] = PlotMarge_in_mils;
BBox[2] = SheetPS->m_Size.x - PlotMarge_in_mils; BBox[2] = SheetPS->m_Size.x - PlotMarge_in_mils;
BBox[3] = SheetPS->m_Size.y - PlotMarge_in_mils; BBox[3] = SheetPS->m_Size.y - PlotMarge_in_mils;
InitPlotParametresPS(g_PlotOffset, SheetPS, InitPlotParametresPS( g_PlotOffset, SheetPS,
(double) 1.0 / PCB_INTERNAL_UNIT, (double) 1.0 / PCB_INTERNAL_UNIT); (double) 1.0 / PCB_INTERNAL_UNIT, (double) 1.0 / PCB_INTERNAL_UNIT );
SetDefaultLineWidthPS(10); // Set line with to 10/1000 inch SetDefaultLineWidthPS( 10 ); // Set line with to 10/1000 inch
PrintHeaderPS(dest, wxT("PCBNEW-PS"), FullFileName, 1, BBox, wxLANDSCAPE); PrintHeaderPS( dest, wxT( "PCBNEW-PS" ), FullFileName, 1, BBox, wxLANDSCAPE );
InitPlotParametresPS(g_PlotOffset, SheetPS, scale_x, scale_y); InitPlotParametresPS( g_PlotOffset, SheetPS, scale_x, scale_y );
} }
break; break;
...@@ -979,62 +1068,65 @@ wxString msg; ...@@ -979,62 +1068,65 @@ wxString msg;
break; break;
case TYPETEXTE: case TYPETEXTE:
PlotTextePcb((TEXTE_PCB*) PtStruct, format, EDGE_LAYER); PlotTextePcb( (TEXTE_PCB*) PtStruct, format, EDGE_LAYER );
break; break;
case TYPECOTATION: case TYPECOTATION:
PlotCotation((COTATION*) PtStruct, format, EDGE_LAYER); PlotCotation( (COTATION*) PtStruct, format, EDGE_LAYER );
break; break;
case TYPEMIRE: case TYPEMIRE:
PlotMirePcb((MIREPCB*) PtStruct, format, EDGE_LAYER); PlotMirePcb( (MIREPCB*) PtStruct, format, EDGE_LAYER );
break; break;
default: default:
DisplayError(this, wxT("WinEDA_DrillFrame::GenDrillMap() : Unexpected Draw Type") ); DisplayError( this, wxT( "WinEDA_DrillFrame::GenDrillMap() : Unexpected Draw Type" ) );
break; break;
} }
} }
TextWidth = (int)(50 * scale_x); // Set Drill Symbols width TextWidth = 50; // Set Drill Symbols width in 1/10000 mils
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
{ {
sprintf( line, "%d setlinewidth\n", TextWidth ); sprintf( line, "%d setlinewidth\n", TextWidth );
fputs(line,dest); fputs( line, dest );
} }
ii = Plot_Drill_PcbMap( (FORET *) adr_lowmem, format); ii = Plot_Drill_PcbMap( (FORET*) adr_lowmem, format );
msg.Printf( wxT("%d"),ii); msg.Printf( wxT( "%d" ), ii );
Affiche_1_Parametre(m_Parent, 64, _("Drill"), msg,GREEN); Affiche_1_Parametre( m_Parent, 64, _( "Drill" ), msg, GREEN );
/* Impression de la liste des symboles utilises */ /* Impression de la liste des symboles utilises */
CharSize = 600; /* hauteur des textes en 1/10000 mils */ CharSize = 800; /* text size in 1/10000 mils */
float CharScale = 1.0; float CharScale = 1.0 / scale_x; /* real scale will be CharScale * scale_x,
TextWidth = (int)(50 * CharScale); // Set text width * because the global plot scale is scale_x */
intervalle = (int)(CharSize * CharScale) + TextWidth; TextWidth = (int) (50 * CharScale); // Set text width
intervalle = (int) (CharSize * CharScale) + TextWidth;
switch( format) switch( format )
{ {
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
{ {
/* generation des dim: commande SI x,y; x et y = dim en cm */ /* generation des dim: commande SI x,y; x et y = dim en cm */
char csize[256]; char csize[256];
sprintf(csize, "%2.3f", (float)CharSize * CharScale * 0.000254); sprintf( csize, "%2.3f", (float) CharSize * CharScale * 0.000254 );
to_point(csize); to_point( csize );
sprintf(line,"SI %s, %s;\n", csize, csize); sprintf( line, "SI %s, %s;\n", csize, csize );
break; break;
} }
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
/* Reglage de l'epaisseur de traits des textes */ /* Reglage de l'epaisseur de traits des textes */
sprintf( line,"%d setlinewidth\n", TextWidth ); sprintf( line, "%d setlinewidth\n", TextWidth );
break; break;
default: *line = 0; default:
*line = 0;
break; break;
} }
fputs(line,dest);
fputs( line, dest );
switch( format ) switch( format )
{ {
...@@ -1042,11 +1134,11 @@ wxString msg; ...@@ -1042,11 +1134,11 @@ wxString msg;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
g_PlotOffset.x = 0; g_PlotOffset.x = 0;
g_PlotOffset.y = 0; g_PlotOffset.y = 0;
InitPlotParametresPS(g_PlotOffset, SheetPS, scale_x, scale_x); InitPlotParametresPS( g_PlotOffset, SheetPS, scale_x, scale_x );
break; break;
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
InitPlotParametresHPGL(g_PlotOffset, scale_x, scale_x); InitPlotParametresHPGL( g_PlotOffset, scale_x, scale_x );
break; break;
} }
...@@ -1055,78 +1147,84 @@ wxString msg; ...@@ -1055,78 +1147,84 @@ wxString msg;
/* Trace de "Infos" */ /* Trace de "Infos" */
plotX = marge + 1000; plotX = marge + 1000;
plotY = CharSize + 1000; plotY = CharSize + 1000;
x = plotX ; y = plotY; x = plotX; y = plotY;
x = +g_PlotOffset.x + (int)(x * fTextScale); x = +g_PlotOffset.x + (int) (x * fTextScale);
y = g_PlotOffset.y - (int)(y * fTextScale); y = g_PlotOffset.y - (int) (y * fTextScale);
plotY += (int) ( intervalle * 1.2) + 200;
switch( format ) switch( format )
{ {
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
sprintf(line,"PU %d, %d; LBInfos\03;\n", sprintf( line, "PU %d, %d; LBInfos\03;\n",
x + (int)(intervalle * CharScale * fTextScale), x + (int) (intervalle * CharScale * fTextScale),
y - (int)(CharSize / 2 * CharScale * fTextScale) ); y - (int) (CharSize / 2 * CharScale * fTextScale) );
fputs(line,dest); fputs( line, dest );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
wxString Text = wxT("Infos"); wxString Text = wxT( "Infos" );
Plot_1_texte(format, Text, 0, TextWidth, Plot_1_texte( format, Text, 0, TextWidth,
x, y, x, y,
(int) (CharSize * CharScale), (int) (CharSize * CharScale), (int) (CharSize * CharScale), (int) (CharSize * CharScale),
FALSE); FALSE );
break; break;
} }
plotY += (int)( intervalle * 1.2) + 200;
for(ii = 0, foret = (FORET*)adr_lowmem ; ii < DrillToolsCount; ii++, foret++) for( ii = 0, foret = (FORET*) adr_lowmem; ii < DrillToolsCount; ii++, foret++ )
{ {
int plot_diam; int plot_diam;
if ( foret->m_TotalCount == 0 ) continue; if( foret->m_TotalCount == 0 )
continue;
plot_diam = (int)(foret->m_Diameter * scale_x); plot_diam = (int) (foret->m_Diameter);
x = plotX; y = plotY; x = plotX; y = plotY;
x = -g_PlotOffset.x + (int)(x * fTextScale); x = -g_PlotOffset.x + (int) (x * fTextScale);
y = g_PlotOffset.y - (int)(y * fTextScale); y = g_PlotOffset.y - (int) (y * fTextScale);
PlotDrillSymbol(wxPoint(x,y),plot_diam,ii, format); PlotDrillSymbol( wxPoint( x, y ), plot_diam, ii, format );
intervalle = (int)(CharSize * CharScale) + TextWidth; intervalle = (int) (CharSize * CharScale) + TextWidth;
intervalle = (int)( intervalle * 1.2); intervalle = (int) ( intervalle * 1.2);
if ( intervalle < (plot_diam + 200 + TextWidth) ) intervalle = plot_diam + 200 + TextWidth; if( intervalle < (plot_diam + 200 + TextWidth) )
intervalle = plot_diam + 200 + TextWidth;
int rayon = plot_diam/2; int rayon = plot_diam / 2;
x = plotX + rayon + (int)(CharSize * CharScale); y = plotY; x = plotX + rayon + (int) (CharSize * CharScale); y = plotY;
x = -g_PlotOffset.x + (int)(x * fTextScale); x = -g_PlotOffset.x + (int) (x * fTextScale);
y = g_PlotOffset.y - (int)(y * fTextScale); y = g_PlotOffset.y - (int) (y * fTextScale);
/* Trace de la legende associee */ /* Trace de la legende associee */
switch( format ) switch( format )
{ {
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
// List the diameter of each drill in the selected Drill Unit, // List the diameter of each drill in the selected Drill Unit,
// and then its diameter in the other Drill Unit. // and then its diameter in the other Drill Unit.
if ( Unit_Drill_is_Inch ) if( Unit_Drill_is_Inch )
sprintf( line, "PU %d, %d; LB%2.3f\" / %2.2fmm ", sprintf( line, "PU %d, %d; LB%2.3f\" / %2.2fmm ",
x + (int)(intervalle * CharScale * fTextScale), x + (int) (intervalle * CharScale * fTextScale),
y - (int)(CharSize / 2 * CharScale * fTextScale), y - (int) (CharSize / 2 * CharScale * fTextScale),
float(foret->m_Diameter) * 0.0001, float (foret->m_Diameter) * 0.0001,
float(foret->m_Diameter) * 0.00254 ); float (foret->m_Diameter) * 0.00254 );
else else
sprintf( line, "PU %d, %d; LB%2.2fmm / %2.3f\" ", sprintf( line, "PU %d, %d; LB%2.2fmm / %2.3f\" ",
x + (int)(intervalle * CharScale * fTextScale), x + (int) (intervalle * CharScale * fTextScale),
y - (int)(CharSize / 2 * CharScale * fTextScale), y - (int) (CharSize / 2 * CharScale * fTextScale),
float(foret->m_Diameter) * 0.00254, float (foret->m_Diameter) * 0.00254,
float(foret->m_Diameter) * 0.0001 ); float (foret->m_Diameter) * 0.0001 );
fputs( line, dest ); fputs( line, dest );
// Now list how many holes and ovals are associated with each drill. // Now list how many holes and ovals are associated with each drill.
if ( ( foret->m_TotalCount == 1 ) && ( foret->m_OvalCount == 0 ) ) if( ( foret->m_TotalCount == 1 ) && ( foret->m_OvalCount == 0 ) )
sprintf( line, "(1 hole)\n" ); sprintf( line, "(1 hole)\n" );
else if ( foret->m_TotalCount == 1 ) // && ( foret->m_OvalCount == 1 ) else if( foret->m_TotalCount == 1 ) // && ( foret->m_OvalCount == 1 )
sprintf( line, "(1 hole) (with 1 oblong)\n" ); sprintf( line, "(1 hole) (with 1 oblong)\n" );
else if ( foret->m_OvalCount == 0 ) else if( foret->m_OvalCount == 0 )
sprintf( line, "(%d holes)\n", sprintf( line, "(%d holes)\n",
foret->m_TotalCount ); foret->m_TotalCount );
else if ( foret->m_OvalCount == 1 ) else if( foret->m_OvalCount == 1 )
sprintf( line, "(%d holes) (with 1 oblong)\n", sprintf( line, "(%d holes) (with 1 oblong)\n",
foret->m_TotalCount ); foret->m_TotalCount );
else // if ( foret->m_OvalCount > 1 ) else // if ( foret->m_OvalCount > 1 )
...@@ -1134,315 +1232,368 @@ wxString msg; ...@@ -1134,315 +1232,368 @@ wxString msg;
foret->m_TotalCount, foret->m_TotalCount,
foret->m_OvalCount ); foret->m_OvalCount );
fputs( line, dest ); fputs( line, dest );
fputs("\03;\n",dest); fputs( "\03;\n", dest );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
// List the diameter of each drill in the selected Drill Unit, // List the diameter of each drill in the selected Drill Unit,
// and then its diameter in the other Drill Unit. // and then its diameter in the other Drill Unit.
if ( Unit_Drill_is_Inch ) if( Unit_Drill_is_Inch )
sprintf( line, "%2.3f\" / %2.2fmm ", sprintf( line, "%2.3f\" / %2.2fmm ",
float(foret->m_Diameter) * 0.0001, float (foret->m_Diameter) * 0.0001,
float(foret->m_Diameter) * 0.00254 ); float (foret->m_Diameter) * 0.00254 );
else else
sprintf( line, "%2.2fmm / %2.3f\" ", sprintf( line, "%2.2fmm / %2.3f\" ",
float(foret->m_Diameter) * 0.00254, float (foret->m_Diameter) * 0.00254,
float(foret->m_Diameter) * 0.0001 ); float (foret->m_Diameter) * 0.0001 );
msg = CONV_FROM_UTF8(line); msg = CONV_FROM_UTF8( line );
// Now list how many holes and ovals are associated with each drill. // Now list how many holes and ovals are associated with each drill.
if ( ( foret->m_TotalCount == 1 ) && ( foret->m_OvalCount == 0 ) ) if( ( foret->m_TotalCount == 1 ) && ( foret->m_OvalCount == 0 ) )
sprintf( line, "(1 hole)" ); sprintf( line, "(1 hole)" );
else if ( foret->m_TotalCount == 1 ) // && ( foret->m_OvalCount == 1 ) else if( foret->m_TotalCount == 1 ) // && ( foret->m_OvalCount == 1 )
sprintf( line, "(1 hole) (with 1 oblong)" ); sprintf( line, "(1 hole) (with 1 oblong)" );
else if ( foret->m_OvalCount == 0 ) else if( foret->m_OvalCount == 0 )
sprintf( line, "(%d holes)", sprintf( line, "(%d holes)",
foret->m_TotalCount ); foret->m_TotalCount );
else if ( foret->m_OvalCount == 1 ) else if( foret->m_OvalCount == 1 )
sprintf( line, "(%d holes) (with 1 oblong)", sprintf( line, "(%d holes) (with 1 oblong)",
foret->m_TotalCount ); foret->m_TotalCount );
else // if ( foret->m_OvalCount > 1 ) else // if ( foret->m_OvalCount > 1 )
sprintf( line, "(%d holes) (with %d oblongs)", sprintf( line, "(%d holes) (with %d oblongs)",
foret->m_TotalCount, foret->m_TotalCount,
foret->m_OvalCount ); foret->m_OvalCount );
msg += CONV_FROM_UTF8(line); msg += CONV_FROM_UTF8( line );
Plot_1_texte(format, msg, 0, TextWidth, Plot_1_texte( format, msg, 0, TextWidth,
x, y, x, y,
(int) (CharSize * CharScale), (int) (CharSize * CharScale),
(int) (CharSize * CharScale), (int) (CharSize * CharScale),
FALSE); FALSE );
break; break;
} }
plotY += intervalle; plotY += intervalle;
} }
switch( format ) switch( format )
{ {
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
CloseFileHPGL(dest); CloseFileHPGL( dest );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
CloseFilePS(dest); CloseFilePS( dest );
break; break;
} }
g_PlotOrient = old_g_PlotOrient; g_PlotOrient = old_g_PlotOrient;
} }
/********************************************************************/ /********************************************************************/
int WinEDA_DrillFrame::Plot_Drill_PcbMap( FORET * buffer, int format) int WinEDA_DrillFrame::Plot_Drill_PcbMap( FORET* buffer, int format )
/*********************************************************************/ /*********************************************************************/
/* Trace la liste des trous a percer en format HPGL ou POSTSCRIPT
Retourne: /** Trace la liste des trous a percer en format HPGL ou POSTSCRIPT
Nombre de trous * @return drill count
Utilise: * @param buffer = drill list buffer
liste des forets pointee par buffer * @param format = ouput format (hpgl / ps)
*/ */
{ {
FORET * foret; FORET* foret;
TRACK * pt_piste; TRACK* pt_piste;
D_PAD * pt_pad; D_PAD* pt_pad;
MODULE * Module; MODULE* Module;
int ii , diam, nb_trous; int ii, diam, nb_trous;
wxPoint pos; wxPoint pos;
wxSize size; wxSize size;
nb_trous = 0; nb_trous = 0;
/* create the drill list */ /* create the drill list */
if ( DrillToolsCount > 13 ) if( DrillToolsCount > 13 )
{ {
DisplayInfo(this, DisplayInfo( this,
_(" Drill map: Too many diameter values to draw to draw one symbol per drill value (max 13)\nPlot uses circle shape for some drill values"), 10); _(
" Drill map: Too many diameter values to draw to draw one symbol per drill value (max 13)\nPlot uses circle shape for some drill values" ),
10 );
} }
for(ii = 0, foret = (FORET*)buffer ; ii < DrillToolsCount; ii++, foret++) for( ii = 0, foret = (FORET*) buffer; ii < DrillToolsCount; ii++, foret++ )
{ {
/* create the via drill map */ /* create the via drill map */
{ {
pt_piste = m_Parent->m_Pcb->m_Track; pt_piste = m_Parent->m_Pcb->m_Track;
for( ; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext) for( ; pt_piste != NULL; pt_piste = (TRACK*) pt_piste->Pnext )
{ {
if(pt_piste->Type() != TYPEVIA) continue; if( pt_piste->Type() != TYPEVIA )
if(pt_piste->m_Drill == 0) continue; continue;
if( pt_piste->m_Drill == 0 )
continue;
int via_drill = g_DesignSettings.m_ViaDrill; int via_drill = g_DesignSettings.m_ViaDrill;
if (pt_piste->m_Drill >= 0) via_drill = pt_piste->m_Drill; if( pt_piste->m_Drill >= 0 )
via_drill = pt_piste->m_Drill;
pos = pt_piste->m_Start; pos = pt_piste->m_Start;
PlotDrillSymbol(pos, via_drill,ii, format); PlotDrillSymbol( pos, via_drill, ii, format );
nb_trous++; nb_trous++;
} }
} }
/* create the pad drill map: */ /* create the pad drill map: */
for(Module = m_Parent->m_Pcb->m_Modules; Module != NULL; Module = (MODULE*)Module->Pnext) for( Module = m_Parent->m_Pcb->m_Modules; Module != NULL; Module = (MODULE*) Module->Pnext )
{ {
pt_pad = (D_PAD*) Module->m_Pads; pt_pad = (D_PAD*) Module->m_Pads;
for ( ; pt_pad != NULL; pt_pad = (D_PAD*)pt_pad->Pnext ) for( ; pt_pad != NULL; pt_pad = (D_PAD*) pt_pad->Pnext )
{ {
switch ( pt_pad->m_DrillShape ) switch( pt_pad->m_DrillShape )
{ {
case CIRCLE: case CIRCLE:
diam = pt_pad->m_Drill.x; diam = pt_pad->m_Drill.x;
if(diam != foret->m_Diameter) continue; if( diam != foret->m_Diameter )
PlotDrillSymbol(pt_pad->m_Pos, diam,ii, format); continue;
PlotDrillSymbol( pt_pad->m_Pos, diam, ii, format );
break; break;
case OVALE: case OVALE:
if ( pt_pad->m_DrillShape != OVALE ) continue; if( pt_pad->m_DrillShape != OVALE )
continue;
diam = MIN( pt_pad->m_Drill.x, pt_pad->m_Drill.y ); diam = MIN( pt_pad->m_Drill.x, pt_pad->m_Drill.y );
if(diam != foret->m_Diameter) continue; if( diam != foret->m_Diameter )
PlotOvalDrillSymbol(pt_pad->m_Pos, pt_pad->m_Drill,pt_pad->m_Orient, format); continue;
PlotOvalDrillSymbol( pt_pad->m_Pos, pt_pad->m_Drill, pt_pad->m_Orient, format );
break; break;
} }
nb_trous++; nb_trous++;
} /* Fin examen 1 module */ }
} /* Fin 1 passe de foret */
} /* fin analyse des trous de modules */ /* Fin examen 1 module */
}
/* Fin 1 passe de foret */
}
/* fin analyse des trous de modules */
return(nb_trous); return nb_trous;
} }
/************************************************************************************/ /************************************************************************************/
void PlotDrillSymbol(const wxPoint & position,int diametre,int num_forme, int format) void PlotDrillSymbol( const wxPoint& position, int diametre, int num_forme, int format )
/************************************************************************************/ /************************************************************************************/
/* Trace un motif de numero de forme num_forme, aux coord x0, y0. /* Trace un motif de numero de forme num_forme, aux coord x0, y0.
x0, y0 = coordonnees tables * x0, y0 = coordonnees tables
diametre = diametre (coord table) du trou * diametre = diametre (coord table) du trou
num_forme = index ( permet de gererer des formes caract ) * num_forme = index ( permet de gererer des formes caract )
*/ */
{ {
int rayon = diametre / 2; int rayon = diametre / 2;
void (*FctPlume)(wxPoint pos, int state);
int x0, y0; void (*FctPlume)( wxPoint pos, int state );
int x0, y0;
x0 = position.x; y0 = position.y; x0 = position.x; y0 = position.y;
FctPlume = Move_Plume_HPGL; FctPlume = Move_Plume_HPGL;
if(format == PLOT_FORMAT_POST) FctPlume = LineTo_PS; if( format == PLOT_FORMAT_POST )
FctPlume = LineTo_PS;
switch( num_forme) switch( num_forme )
{ {
case 0: /* vias : forme en X */ case 0: /* vias : forme en X */
FctPlume( wxPoint(x0 - rayon, y0 - rayon), 'U'); FctPlume( wxPoint( x0 - rayon, y0 - rayon ), 'U' );
FctPlume( wxPoint(x0 + rayon, y0 + rayon), 'D'); FctPlume( wxPoint( x0 + rayon, y0 + rayon ), 'D' );
FctPlume( wxPoint(x0 + rayon, y0 - rayon), 'U'); FctPlume( wxPoint( x0 + rayon, y0 - rayon ), 'U' );
FctPlume( wxPoint(x0 - rayon, y0 + rayon), 'D'); FctPlume( wxPoint( x0 - rayon, y0 + rayon ), 'D' );
break; break;
case 1: /* Cercle */ case 1: /* Cercle */
if( format == PLOT_FORMAT_HPGL ) if( format == PLOT_FORMAT_HPGL )
trace_1_pastille_RONDE_HPGL(wxPoint(x0, y0), diametre, FILAIRE); trace_1_pastille_RONDE_HPGL( wxPoint( x0, y0 ), diametre, FILAIRE );
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
trace_1_pastille_RONDE_POST(wxPoint(x0, y0), diametre, FILAIRE); trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE );
break; break;
case 2: /* forme en + */ case 2: /* forme en + */
FctPlume( wxPoint(x0 , y0 - rayon),'U'); FctPlume( wxPoint( x0, y0 - rayon ), 'U' );
FctPlume( wxPoint(x0 , y0 + rayon),'D'); FctPlume( wxPoint( x0, y0 + rayon ), 'D' );
FctPlume( wxPoint(x0 + rayon, y0), 'U'); FctPlume( wxPoint( x0 + rayon, y0 ), 'U' );
FctPlume( wxPoint(x0 - rayon, y0), 'D'); FctPlume( wxPoint( x0 - rayon, y0 ), 'D' );
break; break;
case 3: /* forme en X cercle */ case 3: /* forme en X cercle */
FctPlume( wxPoint(x0 - rayon, y0 - rayon),'U'); FctPlume( wxPoint( x0 - rayon, y0 - rayon ), 'U' );
FctPlume( wxPoint(x0 + rayon, y0 + rayon),'D'); FctPlume( wxPoint( x0 + rayon, y0 + rayon ), 'D' );
FctPlume( wxPoint(x0 + rayon, y0 - rayon),'U'); FctPlume( wxPoint( x0 + rayon, y0 - rayon ), 'U' );
FctPlume( wxPoint(x0 - rayon, y0 + rayon),'D'); FctPlume( wxPoint( x0 - rayon, y0 + rayon ), 'D' );
if( format == PLOT_FORMAT_HPGL ) if( format == PLOT_FORMAT_HPGL )
trace_1_pastille_RONDE_HPGL(wxPoint(x0, y0), diametre, FILAIRE); trace_1_pastille_RONDE_HPGL( wxPoint( x0, y0 ), diametre, FILAIRE );
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
trace_1_pastille_RONDE_POST(wxPoint(x0, y0), diametre, FILAIRE); trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE );
break; break;
case 4: /* forme en cercle barre de - */ case 4: /* forme en cercle barre de - */
FctPlume( wxPoint(x0 - rayon, y0), 'U'); FctPlume( wxPoint( x0 - rayon, y0 ), 'U' );
FctPlume( wxPoint(x0 + rayon, y0), 'D'); FctPlume( wxPoint( x0 + rayon, y0 ), 'D' );
if( format == PLOT_FORMAT_HPGL ) if( format == PLOT_FORMAT_HPGL )
trace_1_pastille_RONDE_HPGL(wxPoint(x0, y0), diametre, FILAIRE); trace_1_pastille_RONDE_HPGL( wxPoint( x0, y0 ), diametre, FILAIRE );
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
trace_1_pastille_RONDE_POST(wxPoint(x0, y0), diametre, FILAIRE); trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE );
break; break;
case 5: /* forme en cercle barre de | */ case 5: /* forme en cercle barre de | */
FctPlume( wxPoint(x0, y0 - rayon),'U'); FctPlume( wxPoint( x0, y0 - rayon ), 'U' );
FctPlume( wxPoint(x0, y0 + rayon),'D'); FctPlume( wxPoint( x0, y0 + rayon ), 'D' );
if( format == PLOT_FORMAT_HPGL ) if( format == PLOT_FORMAT_HPGL )
trace_1_pastille_RONDE_HPGL(wxPoint(x0, y0), diametre, FILAIRE); trace_1_pastille_RONDE_HPGL( wxPoint( x0, y0 ), diametre, FILAIRE );
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
trace_1_pastille_RONDE_POST(wxPoint(x0, y0), diametre, FILAIRE); trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE );
break; break;
case 6: /* forme en carre */ case 6: /* forme en carre */
if( format == PLOT_FORMAT_HPGL ) if( format == PLOT_FORMAT_HPGL )
trace_1_pad_TRAPEZE_HPGL(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 0, FILAIRE) ; trace_1_pad_TRAPEZE_HPGL( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 0,
FILAIRE );
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
trace_1_pad_TRAPEZE_POST(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 0, FILAIRE) ; trace_1_pad_TRAPEZE_POST( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 0,
FILAIRE );
break; break;
case 7: /* forme en losange */ case 7: /* forme en losange */
if( format == PLOT_FORMAT_HPGL ) if( format == PLOT_FORMAT_HPGL )
trace_1_pad_TRAPEZE_HPGL(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 450, FILAIRE) ; trace_1_pad_TRAPEZE_HPGL( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 450,
FILAIRE );
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
trace_1_pad_TRAPEZE_POST(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 450, FILAIRE) ; trace_1_pad_TRAPEZE_POST( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 450,
FILAIRE );
break; break;
case 8: /* forme en carre barre par un X*/ case 8: /* forme en carre barre par un X*/
FctPlume( wxPoint(x0 - rayon, y0 - rayon),'U'); FctPlume( wxPoint( x0 - rayon, y0 - rayon ), 'U' );
FctPlume( wxPoint(x0 + rayon, y0 + rayon),'D'); FctPlume( wxPoint( x0 + rayon, y0 + rayon ), 'D' );
FctPlume( wxPoint(x0 + rayon, y0 - rayon),'U'); FctPlume( wxPoint( x0 + rayon, y0 - rayon ), 'U' );
FctPlume( wxPoint(x0 - rayon, y0 + rayon),'D'); FctPlume( wxPoint( x0 - rayon, y0 + rayon ), 'D' );
if( format == PLOT_FORMAT_HPGL ) if( format == PLOT_FORMAT_HPGL )
trace_1_pad_TRAPEZE_HPGL(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 0, FILAIRE) ; trace_1_pad_TRAPEZE_HPGL( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 0,
FILAIRE );
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
trace_1_pad_TRAPEZE_POST(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 0, FILAIRE) ; trace_1_pad_TRAPEZE_POST( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 0,
FILAIRE );
break; break;
case 9: /* forme en losange barre par un +*/ case 9: /* forme en losange barre par un +*/
FctPlume( wxPoint(x0, y0 - rayon),'U'); FctPlume( wxPoint( x0, y0 - rayon ), 'U' );
FctPlume( wxPoint(x0, y0 + rayon),'D'); FctPlume( wxPoint( x0, y0 + rayon ), 'D' );
FctPlume( wxPoint(x0 + rayon, y0), 'U'); FctPlume( wxPoint( x0 + rayon, y0 ), 'U' );
FctPlume( wxPoint(x0 - rayon, y0), 'D'); FctPlume( wxPoint( x0 - rayon, y0 ), 'D' );
if( format == PLOT_FORMAT_HPGL ) if( format == PLOT_FORMAT_HPGL )
trace_1_pad_TRAPEZE_HPGL(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 450, FILAIRE); trace_1_pad_TRAPEZE_HPGL( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 450,
FILAIRE );
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
trace_1_pad_TRAPEZE_POST(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 450, FILAIRE); trace_1_pad_TRAPEZE_POST( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 450,
FILAIRE );
break; break;
case 10: /* forme en carre barre par un '/' */ case 10: /* forme en carre barre par un '/' */
FctPlume( wxPoint(x0 - rayon, y0 - rayon),'U'); FctPlume( wxPoint( x0 - rayon, y0 - rayon ), 'U' );
FctPlume( wxPoint(x0 + rayon, y0 + rayon),'D'); FctPlume( wxPoint( x0 + rayon, y0 + rayon ), 'D' );
if( format == PLOT_FORMAT_HPGL ) if( format == PLOT_FORMAT_HPGL )
trace_1_pad_TRAPEZE_HPGL(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 0, FILAIRE) ; trace_1_pad_TRAPEZE_HPGL( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 0,
FILAIRE );
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
trace_1_pad_TRAPEZE_POST(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 0, FILAIRE) ; trace_1_pad_TRAPEZE_POST( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 0,
FILAIRE );
break; break;
case 11: /* forme en losange barre par un |*/ case 11: /* forme en losange barre par un |*/
FctPlume( wxPoint(x0, y0 - rayon), 'U'); FctPlume( wxPoint( x0, y0 - rayon ), 'U' );
FctPlume( wxPoint(x0, y0 + rayon), 'D'); FctPlume( wxPoint( x0, y0 + rayon ), 'D' );
if( format == PLOT_FORMAT_HPGL ) if( format == PLOT_FORMAT_HPGL )
trace_1_pad_TRAPEZE_HPGL(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 450, FILAIRE) ; trace_1_pad_TRAPEZE_HPGL( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 450,
FILAIRE );
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
trace_1_pad_TRAPEZE_POST(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 450, FILAIRE) ; trace_1_pad_TRAPEZE_POST( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 450,
FILAIRE );
break; break;
case 12: /* forme en losange barre par un -*/ case 12: /* forme en losange barre par un -*/
FctPlume( wxPoint(x0 - rayon, y0), 'U'); FctPlume( wxPoint( x0 - rayon, y0 ), 'U' );
FctPlume( wxPoint(x0 + rayon, y0), 'D'); FctPlume( wxPoint( x0 + rayon, y0 ), 'D' );
if( format == PLOT_FORMAT_HPGL ) if( format == PLOT_FORMAT_HPGL )
trace_1_pad_TRAPEZE_HPGL(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 450, FILAIRE) ; trace_1_pad_TRAPEZE_HPGL( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 450,
FILAIRE );
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
trace_1_pad_TRAPEZE_POST(wxPoint(x0,y0),wxSize(rayon, rayon),wxSize(0,0), 450, FILAIRE) ; trace_1_pad_TRAPEZE_POST( wxPoint( x0, y0 ), wxSize( rayon, rayon ), wxSize( 0,
0 ), 450,
FILAIRE );
break; break;
default: default:
if( format == PLOT_FORMAT_HPGL ) if( format == PLOT_FORMAT_HPGL )
trace_1_pastille_RONDE_HPGL(wxPoint(x0, y0), diametre, FILAIRE); trace_1_pastille_RONDE_HPGL( wxPoint( x0, y0 ), diametre, FILAIRE );
if( format == PLOT_FORMAT_POST ) if( format == PLOT_FORMAT_POST )
trace_1_pastille_RONDE_POST(wxPoint(x0, y0), diametre, FILAIRE); trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE );
break; break;
} }
if( format == PLOT_FORMAT_HPGL) Plume_HPGL('U');
if( format == PLOT_FORMAT_HPGL )
Plume_HPGL( 'U' );
} }
/*******************************************************************************************/ /*******************************************************************************************/
void PlotOvalDrillSymbol(const wxPoint & position,const wxSize & size,int orient,int format) void PlotOvalDrillSymbol( const wxPoint& position, const wxSize& size, int orient, int format )
/*******************************************************************************************/ /*******************************************************************************************/
{ {
switch( format ) switch( format )
{ {
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
trace_1_pastille_OVALE_HPGL(position, size, orient, FILAIRE); trace_1_pastille_OVALE_HPGL( position, size, orient, FILAIRE );
break; break;
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
trace_1_pastille_OVALE_POST(position, size, orient, FILAIRE); trace_1_pastille_OVALE_POST( position, size, orient, FILAIRE );
break; break;
} }
} }
/*******************************************/ /*******************************************/
void WinEDA_DrillFrame::GenDrillReport() void WinEDA_DrillFrame::GenDrillReport()
/*******************************************/ /*******************************************/
/* /*
Create a list of drill values and drill count * Create a list of drill values and drill count
*/ */
{ {
wxString FileName, Mask(wxT("*")), Ext(wxT(".rpt")); wxString FileName, Mask( wxT( "*" ) ), Ext( wxT( ".rpt" ) );
int ii, TotalHoleCount; int ii, TotalHoleCount;
char line[1024]; char line[1024];
FORET * foret; FORET* foret;
wxString msg; wxString msg;
FileName = m_Parent->m_CurrentScreen->m_FileName; FileName = m_Parent->m_CurrentScreen->m_FileName;
ChangeFileNameExt(FileName, wxT("-drl") + Ext); ChangeFileNameExt( FileName, wxT( "-drl" ) + Ext );
Mask += Ext; Mask += Ext;
FileName = EDA_FileSelector(_("Drill Report file"), FileName = EDA_FileSelector( _( "Drill Report file" ),
wxEmptyString, /* Chemin par defaut */ wxEmptyString, /* Chemin par defaut */
FileName, /* nom fichier par defaut */ FileName, /* nom fichier par defaut */
Ext, /* extension par defaut */ Ext, /* extension par defaut */
...@@ -1451,62 +1602,63 @@ wxString msg; ...@@ -1451,62 +1602,63 @@ wxString msg;
wxFD_SAVE, wxFD_SAVE,
TRUE TRUE
); );
if ( FileName.IsEmpty()) return; if( FileName.IsEmpty() )
return;
dest = wxFopen(FileName, wxT("w") ); dest = wxFopen( FileName, wxT( "w" ) );
if (dest == 0) if( dest == 0 )
{ {
msg = _("Unable to create file ") + FileName; msg = _( "Unable to create file " ) + FileName;
DisplayError(this, msg); DisplayError( this, msg );
return ; return;
} }
m_Parent->MsgPanel->EraseMsgBox(); m_Parent->MsgPanel->EraseMsgBox();
Affiche_1_Parametre( m_Parent, 0, _("File"), FileName, BLUE ); Affiche_1_Parametre( m_Parent, 0, _( "File" ), FileName, BLUE );
/* Determine the list of the different drill diameters. */ /* Determine the list of the different drill diameters. */
ii = Gen_Liste_Forets( (FORET *) adr_lowmem, FALSE ); ii = Gen_Liste_Forets( (FORET*) adr_lowmem, FALSE );
msg.Printf( wxT("%d"), ii ); msg.Printf( wxT( "%d" ), ii );
Affiche_1_Parametre( m_Parent, 30, _("Tools"), msg, BROWN ); Affiche_1_Parametre( m_Parent, 30, _( "Tools" ), msg, BROWN );
fprintf(dest, "Drill report for %s\n", CONV_TO_UTF8(m_Parent->m_CurrentScreen->m_FileName) ); fprintf( dest, "Drill report for %s\n", CONV_TO_UTF8( m_Parent->m_CurrentScreen->m_FileName ) );
fprintf(dest, "Created on %s\n", DateAndTime(line)); fprintf( dest, "Created on %s\n", DateAndTime( line ) );
// List which Drill Unit option had been selected for the associated drill file. // List which Drill Unit option had been selected for the associated drill file.
if ( Unit_Drill_is_Inch ) if( Unit_Drill_is_Inch )
fputs("Selected Drill Unit: Imperial (\")\n\n", dest); fputs( "Selected Drill Unit: Imperial (\")\n\n", dest );
else else
fputs("Selected Drill Unit: Metric (mm)\n\n", dest); fputs( "Selected Drill Unit: Metric (mm)\n\n", dest );
TotalHoleCount = 0; TotalHoleCount = 0;
for ( ii = 0, foret = (FORET*)adr_lowmem ; ii < DrillToolsCount; ii++, foret++ ) for( ii = 0, foret = (FORET*) adr_lowmem; ii < DrillToolsCount; ii++, foret++ )
{ {
// List the tool number assigned to each drill, // List the tool number assigned to each drill,
// then its diameter in the selected Drill Unit, // then its diameter in the selected Drill Unit,
// and then its diameter in the other Drill Unit. // and then its diameter in the other Drill Unit.
if ( Unit_Drill_is_Inch ) if( Unit_Drill_is_Inch )
sprintf( line, "T%d %2.3f\" %2.2fmm ", sprintf( line, "T%d %2.3f\" %2.2fmm ",
ii + 1, ii + 1,
float(foret->m_Diameter) * 0.0001, float (foret->m_Diameter) * 0.0001,
float(foret->m_Diameter) * 0.00254 ); float (foret->m_Diameter) * 0.00254 );
else else
sprintf( line, "T%d %2.2fmm %2.3f\" ", sprintf( line, "T%d %2.2fmm %2.3f\" ",
ii + 1, ii + 1,
float(foret->m_Diameter) * 0.00254, float (foret->m_Diameter) * 0.00254,
float(foret->m_Diameter) * 0.0001 ); float (foret->m_Diameter) * 0.0001 );
fputs( line, dest ); fputs( line, dest );
// Now list how many holes and ovals are associated with each drill. // Now list how many holes and ovals are associated with each drill.
if ( ( foret->m_TotalCount == 1 ) && ( foret->m_OvalCount == 0 ) ) if( ( foret->m_TotalCount == 1 ) && ( foret->m_OvalCount == 0 ) )
sprintf( line, "(1 hole)\n" ); sprintf( line, "(1 hole)\n" );
else if ( foret->m_TotalCount == 1 ) // && ( foret->m_OvalCount == 1 ) else if( foret->m_TotalCount == 1 ) // && ( foret->m_OvalCount == 1 )
sprintf( line, "(1 hole) (with 1 oblong)\n" ); sprintf( line, "(1 hole) (with 1 oblong)\n" );
else if ( foret->m_OvalCount == 0 ) else if( foret->m_OvalCount == 0 )
sprintf( line, "(%d holes)\n", sprintf( line, "(%d holes)\n",
foret->m_TotalCount ); foret->m_TotalCount );
else if ( foret->m_OvalCount == 1 ) else if( foret->m_OvalCount == 1 )
sprintf( line, "(%d holes) (with 1 oblong)\n", sprintf( line, "(%d holes) (with 1 oblong)\n",
foret->m_TotalCount ); foret->m_TotalCount );
else // if ( foret->m_OvalCount > 1 ) else // if ( foret->m_OvalCount > 1 )
...@@ -1518,8 +1670,8 @@ wxString msg; ...@@ -1518,8 +1670,8 @@ wxString msg;
TotalHoleCount += foret->m_TotalCount; TotalHoleCount += foret->m_TotalCount;
} }
msg.Printf( wxT("%d"), TotalHoleCount ); msg.Printf( wxT( "%d" ), TotalHoleCount );
Affiche_1_Parametre( m_Parent, 45, _("Drill"), msg, GREEN ); Affiche_1_Parametre( m_Parent, 45, _( "Drill" ), msg, GREEN );
fclose(dest); fclose( dest );
} }
...@@ -11,6 +11,7 @@ OBJECTS= $(TARGET).o classpcb.o\ ...@@ -11,6 +11,7 @@ OBJECTS= $(TARGET).o classpcb.o\
modedit_undo_redo.o\ modedit_undo_redo.o\
block_module_editor.o\ block_module_editor.o\
onrightclick.o\ onrightclick.o\
onleftclick.o\
modedit_onclick.o\ modedit_onclick.o\
via_edit.o\ via_edit.o\
wxprint.o \ wxprint.o \
......
/**************************************************************/
/* onleftclick.cpp: */
/* function called when the left button is clicked (released) */
/* function called when the left button is double clicked */
/**************************************************************/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "pcbnew.h"
#include "autorout.h"
#include "id.h"
#include "protos.h"
#include "eda_dde.h"
/********************************************************************/
void WinEDA_PcbFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
/********************************************************************/
/* Handle the left buttom mouse click, when a tool is active
*/
{
BOARD_ITEM* DrawStruct = GetCurItem();
bool exit = false;
if( (m_ID_current_state == 0) || ( DrawStruct && DrawStruct->m_Flags ) )
{
DrawPanel->m_AutoPAN_Request = FALSE;
if( DrawStruct && DrawStruct->m_Flags ) // "POPUP" in progress
{
DrawPanel->m_IgnoreMouseEvents = TRUE;
DrawPanel->CursorOff( DC );
switch( DrawStruct->Type() )
{
case TYPETRACK:
case TYPEVIA:
if( DrawStruct->m_Flags & IS_DRAGGED )
{
PlaceDraggedTrackSegment( (TRACK*) DrawStruct, DC );
exit = true;
}
break;
case TYPETEXTE:
Place_Texte_Pcb( (TEXTE_PCB*) DrawStruct, DC );
exit = true;
break;
case TYPETEXTEMODULE:
PlaceTexteModule( (TEXTE_MODULE*) DrawStruct, DC );
exit = true;
break;
case TYPEPAD:
PlacePad( (D_PAD*) DrawStruct, DC );
exit = true;
break;
case TYPEMODULE:
Place_Module( (MODULE*) DrawStruct, DC );
exit = true;
break;
case TYPEMIRE:
Place_Mire( (MIREPCB*) DrawStruct, DC );
exit = true;
break;
case TYPEDRAWSEGMENT:
if( m_ID_current_state == 0 )
{
Place_DrawItem( (DRAWSEGMENT*) DrawStruct, DC );
exit = true;
}
break;
default:
if( m_ID_current_state == 0 )
{
DisplayError( this,
wxT( "WinEDA_PcbFrame::OnLeftClick() err: m_Flags != 0" ) );
exit = true;
}
break;
}
DrawPanel->m_IgnoreMouseEvents = FALSE;
DrawPanel->CursorOn( DC );
if ( exit ) return;
}
else if( !wxGetKeyState(WXK_SHIFT) && !wxGetKeyState(WXK_ALT) &&
!wxGetKeyState(WXK_CONTROL) )
{
DrawStruct = PcbGeneralLocateAndDisplay();
if( DrawStruct )
SendMessageToEESCHEMA( DrawStruct );
}
}
switch( m_ID_current_state )
{
case ID_MAIN_MENUBAR:
case 0:
break;
case ID_NO_SELECT_BUTT:
break;
case ID_PCB_MUWAVE_TOOL_SELF_CMD:
case ID_PCB_MUWAVE_TOOL_GAP_CMD:
case ID_PCB_MUWAVE_TOOL_STUB_CMD:
case ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD:
case ID_PCB_MUWAVE_TOOL_FUNCTION_SHAPE_CMD:
MuWaveCommand( DC, MousePos );
break;
case ID_PCB_HIGHLIGHT_BUTT:
{
int netcode = Select_High_Light( DC );
if( netcode < 0 )
m_Pcb->Display_Infos( this );
else
Affiche_Infos_Equipot( netcode, this );
}
break;
case ID_PCB_SHOW_1_RATSNEST_BUTT:
#if 0
DrawStruct = m_Pcb->FindPadOrModule( GetScreen()->RefPos(true),
GetScreen()->m_Active_Layer );
#else
DrawStruct = PcbGeneralLocateAndDisplay();
#endif
Show_1_Ratsnest( DrawStruct, DC );
if( DrawStruct )
SendMessageToEESCHEMA( DrawStruct );
break;
case ID_PCB_MIRE_BUTT:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
SetCurItem( Create_Mire( DC ) );
DrawPanel->MouseToCursorSchema();
}
else if( DrawStruct->Type() == TYPEMIRE )
{
Place_Mire( (MIREPCB*) DrawStruct, DC );
}
else
DisplayError( this, wxT( "Internal err: Struct not TYPEMIRE" ) );
break;
case ID_PCB_CIRCLE_BUTT:
case ID_PCB_ARC_BUTT:
case ID_LINE_COMMENT_BUTT:
{
int shape = S_SEGMENT;
if( m_ID_current_state == ID_PCB_CIRCLE_BUTT )
shape = S_CIRCLE;
if( m_ID_current_state == ID_PCB_ARC_BUTT )
shape = S_ARC;
if( GetScreen()->m_Active_Layer <= CMP_N )
{
DisplayError( this, _( "Graphic not autorized on Copper layers" ) );
break;
}
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
DrawStruct = Begin_DrawSegment( NULL, shape, DC );
SetCurItem( DrawStruct );
DrawPanel->m_AutoPAN_Request = TRUE;
}
else if( DrawStruct
&& (DrawStruct->Type() == TYPEDRAWSEGMENT)
&& (DrawStruct->m_Flags & IS_NEW) )
{
DrawStruct = Begin_DrawSegment( (DRAWSEGMENT*) DrawStruct, shape, DC );
SetCurItem( DrawStruct );
DrawPanel->m_AutoPAN_Request = TRUE;
}
break;
}
case ID_TRACK_BUTT:
if( GetScreen()->m_Active_Layer > CMP_N )
{
DisplayError( this, _( "Tracks on Copper layers only " ) );
break;
}
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
DrawStruct = Begin_Route( NULL, DC );
SetCurItem( DrawStruct );
if( DrawStruct )
DrawPanel->m_AutoPAN_Request = TRUE;
}
else if( DrawStruct &&
// (DrawStruct->Type() == TYPETRACK) &&
(DrawStruct->m_Flags & IS_NEW) )
{
TRACK* track = Begin_Route( (TRACK*) DrawStruct, DC );
if( track ) // c'est a dire si OK
SetCurItem( DrawStruct = track );
DrawPanel->m_AutoPAN_Request = TRUE;
}
break;
case ID_PCB_ZONES_BUTT:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
SetCurItem( DrawStruct = Begin_Zone() );
}
else if( DrawStruct
&& (DrawStruct->Type() == TYPEEDGEZONE)
&& (DrawStruct->m_Flags & IS_NEW) )
{
SetCurItem( DrawStruct = Begin_Zone() );
}
else
DisplayError( this, wxT( "Edit: zone internal error" ) );
break;
case ID_TEXT_COMMENT_BUTT:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
SetCurItem( Create_Texte_Pcb( DC ) );
DrawPanel->MouseToCursorSchema();
DrawPanel->m_AutoPAN_Request = TRUE;
}
else if( DrawStruct->Type() == TYPETEXTE )
{
Place_Texte_Pcb( (TEXTE_PCB*) DrawStruct, DC );
DrawPanel->m_AutoPAN_Request = FALSE;
}
else
DisplayError( this, wxT( "Internal err: Struct not TYPETEXTE" ) );
break;
case ID_COMPONENT_BUTT:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
DrawPanel->MouseToCursorSchema();
DrawStruct = Load_Module_From_Library( wxEmptyString, DC );
SetCurItem( DrawStruct );
if( DrawStruct )
StartMove_Module( (MODULE*) DrawStruct, DC );
}
else if( DrawStruct->Type() == TYPEMODULE )
{
Place_Module( (MODULE*) DrawStruct, DC );
DrawPanel->m_AutoPAN_Request = FALSE;
}
else
DisplayError( this, wxT( "Internal err: Struct not TYPEMODULE" ) );
break;
case ID_PCB_COTATION_BUTT:
if( GetScreen()->m_Active_Layer <= CMP_N )
{
DisplayError( this, _( "Cotation not autorized on Copper layers" ) );
break;
}
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
DrawStruct = Begin_Cotation( NULL, DC );
SetCurItem( DrawStruct );
DrawPanel->m_AutoPAN_Request = TRUE;
}
else if( DrawStruct
&& (DrawStruct->Type() == TYPECOTATION)
&& (DrawStruct->m_Flags & IS_NEW) )
{
DrawStruct = Begin_Cotation( (COTATION*) DrawStruct, DC );
SetCurItem( DrawStruct );
DrawPanel->m_AutoPAN_Request = TRUE;
}
else
DisplayError( this, wxT( "Internal err: Struct not COTATION" ) );
break;
case ID_PCB_DELETE_ITEM_BUTT:
if( !DrawStruct || (DrawStruct->m_Flags == 0) )
{
DrawStruct = PcbGeneralLocateAndDisplay();
if( DrawStruct && (DrawStruct->m_Flags == 0) )
{
RemoveStruct( DrawStruct, DC );
SetCurItem( DrawStruct = NULL );
}
}
break;
case ID_PCB_PLACE_OFFSET_COORD_BUTT:
DrawPanel->m_Draw_Auxiliary_Axis( DC, GR_XOR );
m_Auxiliary_Axis_Position = GetScreen()->m_Curseur;
DrawPanel->m_Draw_Auxiliary_Axis( DC, GR_COPY );
GetScreen()->SetModify();
break;
default:
DrawPanel->SetCursor( wxCURSOR_ARROW );
DisplayError( this, wxT( "WinEDA_PcbFrame::OnLeftClick() id error" ) );
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
break;
}
}
/********************************************************************************/
void WinEDA_PcbFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
/********************************************************************************/
/* handle the double click on the mouse left button
*/
{
BOARD_ITEM* DrawStruct = GetCurItem();
wxPoint pos = GetPosition();
wxClientDC dc( DrawPanel );
DrawPanel->PrepareGraphicContext( &dc );
switch( m_ID_current_state )
{
case 0:
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
DrawStruct = PcbGeneralLocateAndDisplay();
}
if( (DrawStruct == NULL) || (DrawStruct->m_Flags != 0) )
break;
SendMessageToEESCHEMA( DrawStruct );
// An item is found
SetCurItem( DrawStruct );
switch( DrawStruct->Type() )
{
case TYPETRACK:
case TYPEVIA:
if( DrawStruct->m_Flags & IS_NEW )
{
End_Route( (TRACK*) DrawStruct, DC );
DrawPanel->m_AutoPAN_Request = FALSE;
}
else if( DrawStruct->m_Flags == 0 )
{
Edit_TrackSegm_Width( DC, (TRACK*) DrawStruct );
}
break;
case TYPETEXTE:
InstallTextPCBOptionsFrame( (TEXTE_PCB*) DrawStruct,
DC, ( (TEXTE_PCB*) DrawStruct )->m_Pos );
DrawPanel->MouseToCursorSchema();
break;
case TYPEPAD:
InstallPadOptionsFrame( (D_PAD*) DrawStruct, &dc, pos );
DrawPanel->MouseToCursorSchema();
break;
case TYPEMODULE:
InstallModuleOptionsFrame( (MODULE*) DrawStruct, &dc, pos );
DrawPanel->MouseToCursorSchema();
break;
case TYPEMIRE:
InstallMireOptionsFrame( (MIREPCB*) DrawStruct, &dc, pos );
DrawPanel->MouseToCursorSchema();
break;
case TYPETEXTEMODULE:
InstallTextModOptionsFrame( (TEXTE_MODULE*) DrawStruct, &dc, pos );
DrawPanel->MouseToCursorSchema();
break;
case TYPEDRAWSEGMENT:
break;
default:
break;
}
break; // end case 0
case ID_TRACK_BUTT:
if( DrawStruct && (DrawStruct->m_Flags & IS_NEW) )
{
End_Route( (TRACK*) DrawStruct, DC );
DrawPanel->m_AutoPAN_Request = FALSE;
}
break;
case ID_PCB_ZONES_BUTT:
End_Zone( DC );
DrawPanel->m_AutoPAN_Request = FALSE;
SetCurItem( NULL );
break;
case ID_LINE_COMMENT_BUTT:
case ID_PCB_ARC_BUTT:
case ID_PCB_CIRCLE_BUTT:
if( DrawStruct == NULL )
break;
if( DrawStruct->Type() != TYPEDRAWSEGMENT )
{
DisplayError( this, wxT( "DrawStruct Type error" ) );
DrawPanel->m_AutoPAN_Request = FALSE;
break;
}
if( (DrawStruct->m_Flags & IS_NEW) )
{
End_Edge( (DRAWSEGMENT*) DrawStruct, &dc );
DrawPanel->m_AutoPAN_Request = FALSE;
SetCurItem( NULL );
}
break;
}
}
...@@ -120,11 +120,20 @@ void WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) ...@@ -120,11 +120,20 @@ void WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
BOARD_ITEM* item = GetCurItem(); BOARD_ITEM* item = GetCurItem();
DrawPanel->CursorOff( &dc );
DrawPanel->m_CanStartBlock = -1; // Avoid to start a block coomand when clicking on menu DrawPanel->m_CanStartBlock = -1; // Avoid to start a block coomand when clicking on menu
// If command in progress: Put the Cancel command (if needed) and End command // If command or block in progress: Put the Cancel command (if needed) and the End command
if( BlockActive )
{
createPopUpBlockMenu( aPopMenu );
aPopMenu->AppendSeparator();
return;
}
DrawPanel->CursorOff( &dc );
if( m_ID_current_state ) if( m_ID_current_state )
{ {
if( item && item->m_Flags ) if( item && item->m_Flags )
...@@ -141,24 +150,14 @@ void WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) ...@@ -141,24 +150,14 @@ void WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
} }
else else
{ {
if( (item && item->m_Flags) || BlockActive ) if( item && item->m_Flags )
{
if( BlockActive )
createPopUpBlockMenu( aPopMenu );
else
{ {
ADD_MENUITEM( aPopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, ADD_MENUITEM( aPopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND,
_( "Cancel" ), cancel_xpm ); _( "Cancel" ), cancel_xpm );
}
aPopMenu->AppendSeparator(); aPopMenu->AppendSeparator();
} }
} }
if( BlockActive )
{
DrawPanel->CursorOn( &dc );
return;
}
/* Select a proper item */ /* Select a proper item */
if( !item || !item->m_Flags ) if( !item || !item->m_Flags )
...@@ -434,9 +433,9 @@ void WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) ...@@ -434,9 +433,9 @@ void WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
} }
/****************************************/ /*********************************************************/
void WinEDA_PcbFrame::createPopUpBlockMenu( wxMenu* menu ) void WinEDA_PcbFrame::createPopUpBlockMenu( wxMenu* menu )
/****************************************/ /*********************************************************/
/* Create Pop sub menu for block commands /* Create Pop sub menu for block commands
*/ */
......
...@@ -743,7 +743,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -743,7 +743,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
int localrealbutt = 0, localbutt = 0, localkey = 0; int localrealbutt = 0, localbutt = 0, localkey = 0;
BASE_SCREEN* screen = GetScreen(); BASE_SCREEN* screen = GetScreen();
static WinEDA_DrawPanel* LastPanel; static WinEDA_DrawPanel* LastPanel;
static bool LastClickIsADoubleClick = false; static bool IgnoreNextLeftButtonRelease = false;
if( event.Leaving() || event.Entering() ) if( event.Leaving() || event.Entering() )
{ {
...@@ -846,14 +846,14 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -846,14 +846,14 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
if( localbutt == (int) (GR_M_LEFT_DOWN | GR_M_DCLICK) ) if( localbutt == (int) (GR_M_LEFT_DOWN | GR_M_DCLICK) )
{ {
m_Parent->OnLeftDClick( &DC, screen->m_MousePositionInPixels ); m_Parent->OnLeftDClick( &DC, screen->m_MousePositionInPixels );
LastClickIsADoubleClick = true; IgnoreNextLeftButtonRelease = true;
} }
else if( event.LeftUp() && screen->BlockLocate.m_State==STATE_NO_BLOCK ) else if( event.LeftUp() && screen->BlockLocate.m_State==STATE_NO_BLOCK )
if ( ! LastClickIsADoubleClick ) if ( ! IgnoreNextLeftButtonRelease )
m_Parent->OnLeftClick( &DC, screen->m_MousePositionInPixels ); m_Parent->OnLeftClick( &DC, screen->m_MousePositionInPixels );
if( event.LeftUp() ) LastClickIsADoubleClick = false; if( event.LeftUp() ) IgnoreNextLeftButtonRelease = false;
if( event.ButtonUp( 2 ) && (screen->BlockLocate.m_State == STATE_NO_BLOCK) ) if( event.ButtonUp( 2 ) && (screen->BlockLocate.m_State == STATE_NO_BLOCK) )
{ {
...@@ -878,7 +878,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -878,7 +878,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
m_CanStartBlock = -1; m_CanStartBlock = -1;
// A new command block can start after a release buttons // A new command block can start after a release buttons
// Avoid a false start block when a dialog bos is demiss, // Avoid a false start block when a dialog box is demiss,
// or when changing panels in hierachy navigation // or when changing panels in hierachy navigation
if( !event.LeftIsDown() && !event.MiddleIsDown() ) if( !event.LeftIsDown() && !event.MiddleIsDown() )
{ {
...@@ -900,6 +900,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -900,6 +900,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
{ {
m_AutoPAN_Request = FALSE; m_AutoPAN_Request = FALSE;
m_Parent->HandleBlockPlace( &DC ); m_Parent->HandleBlockPlace( &DC );
IgnoreNextLeftButtonRelease = true;
} }
} }
else if( (m_CanStartBlock >= 0 ) else if( (m_CanStartBlock >= 0 )
......
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