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
Please add newer entries at the top, list the date and your name with
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>
================================================================================
+ all
......
......@@ -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
if( BlockActive )
{
AddMenusForBlock( PopMenu, this );
PopMenu->AppendSeparator();
return;
}
// Simple localisation des elements si possible
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
{
......@@ -121,18 +128,13 @@ void WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
}
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 );
PopMenu->AppendSeparator();
}
}
if( BlockActive )
return;
if( DrawStruct == NULL )
{
if( m_CurrentScreen != ScreenSch )
......
......@@ -19,306 +19,6 @@
static void Process_Move_Item( WinEDA_PcbFrame* frame,
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
void WinEDA_PcbFrame::SendMessageToEESCHEMA( EDA_BaseStruct* objectToSync )
{
......@@ -363,7 +63,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
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_COPY:
......@@ -456,7 +156,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
{
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 )
{
m_CurrentScreen->BlockLocate.m_Command = BLOCK_IDLE;
......@@ -469,7 +169,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
SetCursor( DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor );
break;
default: // Arret de la commande de d�placement en cours
default: // Finish (abort ) the command
if( DrawPanel->ManageCurseur
&& DrawPanel->ForceCloseManageCurseur )
{
......@@ -479,7 +179,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break;
}
switch( id ) // Traitement des commandes
switch( id ) // Execute command
{
case ID_EXIT:
Close( TRUE );
......@@ -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 )
/***************************************************************/
......
/***********************************************/
/* Routine de Generation du fichier de percage */
/***********************************************/
/***********************************************/
/* Routine de Generation du fichier de percage */
/***********************************************/
#include "fctsys.h"
#include "gr_basic.h"
......@@ -18,14 +18,14 @@
#include "wx/defs.h"
/*
Generation du fichier de percage en format EXCELLON
Variantes supportees:
- Decimal : coord flottantes en pouces
- Metric : coord entieres en 1/10000 mm
format "Trailling Zero" ( TZ )
On peut aussi generer le plan de percage en format HPGL ou PS
*/
* Generation du fichier de percage en format EXCELLON
* Variantes supportees:
* - Decimal : coord flottantes en pouces
* - Metric : coord entieres en 1/10000 mm
* format "Trailling Zero" ( TZ )
*
* On peut aussi generer le plan de percage en format HPGL ou PS
*/
/* Routines importees */
......@@ -45,7 +45,7 @@ public:
int m_rhs;
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 */
......@@ -57,29 +57,33 @@ enum zeros_fmt {
};
/* Routines Locales */
static void Fin_Drill();
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 Write_End_Of_File_Drill();
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 );
/* Variables locales : */
static int DrillToolsCount; /* Nombre de forets a utiliser */
static float conv_unit; /* coeff de conversion des unites drill / pcb */
static bool Unit_Drill_is_Inch = TRUE; /* INCH,LZ (2:4) */
static int s_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 wxPoint File_Drill_Offset; /* Offset des coord de percage pour le fichier gnr */
static bool Minimal = false;
static bool Mirror = true;
// Keywords for read and write config
#define ZerosFormatKey wxT("DrillZerosFormat")
#define LeftPrecisionKey wxT("DrillLeftPrecisionOpt")
#define RightPrecisionKey wxT("DrillRightPrecisionOpt")
#define MirrorKey wxT("DrillMirrorYOpt")
#define MinimalKey wxT("DrillMinHeader")
#define UnitDrillInchKey wxT("DrillUnit")
#define DrillOriginIsAuxAxisKey wxT("DrillAuxAxis")
#define ZerosFormatKey wxT( "DrillZerosFormat" )
#define LeftPrecisionKey wxT( "DrillLeftPrecisionOpt" )
#define RightPrecisionKey wxT( "DrillRightPrecisionOpt" )
#define MirrorKey wxT( "DrillMirrorYOpt" )
#define MinimalKey wxT( "DrillMinHeader" )
#define UnitDrillInchKey wxT( "DrillUnit" )
#define DrillOriginIsAuxAxisKey wxT( "DrillAuxAxis" )
/****************************************/
/* Dialog box for drill file generation */
......@@ -94,170 +98,174 @@ enum id_drill {
ID_SEL_PRECISION
};
class WinEDA_DrillFrame: public wxDialog
class WinEDA_DrillFrame : public wxDialog
{
WinEDA_PcbFrame * m_Parent;
wxRadioBox * m_Choice_Drill_Map;
wxRadioBox * m_Choice_Drill_Report;
wxRadioBox * m_Choice_Unit;
wxRadioBox * m_Choice_Drill_Offset;
WinEDA_EnterText * m_EnterFileNameDrill;
WinEDA_ValueCtrl * m_ViaDrillCtrl;
WinEDA_ValueCtrl * m_PenSpeed;
WinEDA_ValueCtrl * m_PenNum;
wxCheckBox * m_Check_Mirror;
wxCheckBox * m_Check_Minimal;
wxRadioBox * m_Choice_Zeros_Format;
wxRadioBox * m_Choice_Precision;
WinEDA_PcbFrame* m_Parent;
wxRadioBox* m_Choice_Drill_Map;
wxRadioBox* m_Choice_Drill_Report;
wxRadioBox* m_Choice_Unit;
wxRadioBox* m_Choice_Drill_Offset;
WinEDA_EnterText* m_EnterFileNameDrill;
WinEDA_ValueCtrl* m_ViaDrillCtrl;
WinEDA_ValueCtrl* m_PenSpeed;
WinEDA_ValueCtrl* m_PenNum;
wxCheckBox* m_Check_Mirror;
wxCheckBox* m_Check_Minimal;
wxRadioBox* m_Choice_Zeros_Format;
wxRadioBox* m_Choice_Precision;
// Constructor and destructor
public:
WinEDA_DrillFrame(WinEDA_PcbFrame *parent);
~WinEDA_DrillFrame() {};
WinEDA_DrillFrame( WinEDA_PcbFrame* parent );
~WinEDA_DrillFrame() { };
private:
void OnQuit(wxCommandEvent& event);
void OnQuit( wxCommandEvent& event );
void SetParams();
void GenDrillFiles(wxCommandEvent& event);
void GenDrillMap(int format);
void UpdatePrecisionOptions(wxCommandEvent& event);
void GenDrillFiles( wxCommandEvent& event );
void GenDrillMap( int format );
void UpdatePrecisionOptions( wxCommandEvent& event );
void UpdateConfig();
int Plot_Drill_PcbMap( FORET * buffer, int format);
int Plot_Drill_PcbMap( FORET* buffer, int format );
void GenDrillReport();
int Gen_Liste_Forets( FORET * buffer,bool print_header);
int Gen_Drill_File_EXCELLON( FORET * buffer);
void Gen_Line_EXCELLON(char *line, float x, float y);
int Gen_Liste_Forets( FORET* buffer, bool print_header );
int Gen_Drill_File_EXCELLON( FORET* buffer );
void Gen_Line_EXCELLON( char* line, float x, float y );
void Init_Drill();
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE(WinEDA_DrillFrame, wxDialog)
EVT_BUTTON(ID_CLOSE_DRILL, WinEDA_DrillFrame::OnQuit)
EVT_BUTTON(ID_CREATE_DRILL_FILES, WinEDA_DrillFrame::GenDrillFiles)
EVT_RADIOBOX(ID_SEL_DRILL_UNITS, WinEDA_DrillFrame::UpdatePrecisionOptions)
EVT_RADIOBOX(ID_SEL_ZEROS_FMT, WinEDA_DrillFrame::UpdatePrecisionOptions)
BEGIN_EVENT_TABLE( WinEDA_DrillFrame, wxDialog )
EVT_BUTTON( ID_CLOSE_DRILL, WinEDA_DrillFrame::OnQuit )
EVT_BUTTON( ID_CREATE_DRILL_FILES, WinEDA_DrillFrame::GenDrillFiles )
EVT_RADIOBOX( ID_SEL_DRILL_UNITS, WinEDA_DrillFrame::UpdatePrecisionOptions )
EVT_RADIOBOX( ID_SEL_ZEROS_FMT, WinEDA_DrillFrame::UpdatePrecisionOptions )
END_EVENT_TABLE()
#define H_SIZE 550
#define V_SIZE 250
/*************************************************************************/
WinEDA_DrillFrame::WinEDA_DrillFrame(WinEDA_PcbFrame *parent):
wxDialog(parent, -1, _("Drill tools"), wxDefaultPosition, wxSize(H_SIZE, V_SIZE),
DIALOG_STYLE)
WinEDA_DrillFrame::WinEDA_DrillFrame( WinEDA_PcbFrame* parent ) :
wxDialog( parent, -1, _( "Drill tools" ), wxDefaultPosition, wxSize( H_SIZE, V_SIZE ),
DIALOG_STYLE )
/*************************************************************************/
{
m_Parent = parent;
SetFont(*g_DialogFont);
SetFont( *g_DialogFont );
SetReturnCode(1);
SetReturnCode( 1 );
wxBoxSizer * MainBoxSizer = new wxBoxSizer(wxHORIZONTAL);
SetSizer(MainBoxSizer);
wxBoxSizer * LeftBoxSizer = new wxBoxSizer(wxVERTICAL);
wxBoxSizer * MiddleBoxSizer = new wxBoxSizer(wxVERTICAL);
wxBoxSizer * RightBoxSizer = new wxBoxSizer(wxVERTICAL);
MainBoxSizer->Add(LeftBoxSizer, 0, wxGROW|wxALL, 5);
MainBoxSizer->Add(MiddleBoxSizer, 0, wxGROW|wxALL, 5);
MainBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
SetSizer( MainBoxSizer );
wxBoxSizer* LeftBoxSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* MiddleBoxSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* RightBoxSizer = new wxBoxSizer( wxVERTICAL );
MainBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 );
MainBoxSizer->Add( MiddleBoxSizer, 0, wxGROW | wxALL, 5 );
MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
/* first column, NC drill options */
wxString choice_unit_msg[] =
{_("millimeters"), _("inches") };
m_Choice_Unit = new wxRadioBox(this, ID_SEL_DRILL_UNITS,
_("Drill Units:"),
wxDefaultPosition,wxSize(-1,-1),
2,choice_unit_msg,1,wxRA_SPECIFY_COLS);
if ( Unit_Drill_is_Inch )m_Choice_Unit->SetSelection(1);
LeftBoxSizer->Add(m_Choice_Unit, 0, wxGROW|wxALL, 5);
wxString choice_zeros_format_msg[] = {
_("decimal format"),
_("suppress leading zeros"), _("suppress trailing zeros"), _("keep zeros")
wxString choice_unit_msg[] =
{ _( "millimeters" ), _( "inches" ) };
m_Choice_Unit = new wxRadioBox( this, ID_SEL_DRILL_UNITS,
_( "Drill Units:" ),
wxDefaultPosition, wxSize( -1, -1 ),
2, choice_unit_msg, 1, wxRA_SPECIFY_COLS );
if( Unit_Drill_is_Inch )
m_Choice_Unit->SetSelection( 1 );
LeftBoxSizer->Add( m_Choice_Unit, 0, wxGROW | wxALL, 5 );
wxString choice_zeros_format_msg[] = {
_( "decimal format" ),
_( "suppress leading zeros" ), _( "suppress trailing zeros" ), _( "keep zeros" )
};
m_Choice_Zeros_Format = new wxRadioBox(this, ID_SEL_ZEROS_FMT,
_("Zeros Format"),
wxDefaultPosition,wxSize(-1,-1),
4,choice_zeros_format_msg,1,wxRA_SPECIFY_COLS);
m_Choice_Zeros_Format->SetSelection(s_Zeros_Format);
LeftBoxSizer->Add(m_Choice_Zeros_Format, 0, wxGROW|wxALL, 5);
wxString *choice_precision_msg;
wxString choice_precision_inch_msg[] = { _("2:3"), _("2:4")};
wxString choice_precision_metric_msg[] = { _("3:2"), _("3:3")};
if (Unit_Drill_is_Inch)
m_Choice_Zeros_Format = new wxRadioBox( this, ID_SEL_ZEROS_FMT,
_( "Zeros Format" ),
wxDefaultPosition, wxSize( -1, -1 ),
4, choice_zeros_format_msg, 1, wxRA_SPECIFY_COLS );
m_Choice_Zeros_Format->SetSelection( s_Zeros_Format );
LeftBoxSizer->Add( m_Choice_Zeros_Format, 0, wxGROW | wxALL, 5 );
wxString* choice_precision_msg;
wxString choice_precision_inch_msg[] = { _( "2:3" ), _( "2:4" ) };
wxString choice_precision_metric_msg[] = { _( "3:2" ), _( "3:3" ) };
if( Unit_Drill_is_Inch )
choice_precision_msg = choice_precision_inch_msg;
else
choice_precision_msg = choice_precision_metric_msg;
m_Choice_Precision = new wxRadioBox(this, ID_SEL_PRECISION,
_("Precision"),
wxDefaultPosition, wxSize(-1,-1),
2,choice_precision_msg,1,wxRA_SPECIFY_COLS);
LeftBoxSizer->Add(m_Choice_Precision, 0, wxGROW|wxALL, 5);
wxString ps;
ps << s_Precision.m_lhs << wxT(":") << s_Precision.m_rhs;
m_Choice_Precision->SetStringSelection(ps);
if (s_Zeros_Format==DECIMAL_FORMAT) m_Choice_Precision->Enable(false);
wxString choice_drill_offset_msg[] =
{_("absolute"), _("auxiliary axis")};
m_Choice_Drill_Offset = new wxRadioBox(this, ID_SEL_DRILL_SHEET,
_("Drill Origin:"),
wxDefaultPosition,wxSize(-1,-1),
2,choice_drill_offset_msg,1,wxRA_SPECIFY_COLS);
if ( DrillOriginIsAuxAxis ) m_Choice_Drill_Offset->SetSelection(1);
LeftBoxSizer->Add(m_Choice_Drill_Offset, 0, wxGROW|wxALL, 5);
m_Choice_Precision = new wxRadioBox( this, ID_SEL_PRECISION,
_( "Precision" ),
wxDefaultPosition, wxSize( -1, -1 ),
2, choice_precision_msg, 1, wxRA_SPECIFY_COLS );
LeftBoxSizer->Add( m_Choice_Precision, 0, wxGROW | wxALL, 5 );
wxString ps;
ps << s_Precision.m_lhs << wxT( ":" ) << s_Precision.m_rhs;
m_Choice_Precision->SetStringSelection( ps );
if( s_Zeros_Format==DECIMAL_FORMAT )
m_Choice_Precision->Enable( false );
wxString choice_drill_offset_msg[] =
{ _( "absolute" ), _( "auxiliary axis" ) };
m_Choice_Drill_Offset = new wxRadioBox( this, ID_SEL_DRILL_SHEET,
_( "Drill Origin:" ),
wxDefaultPosition, wxSize( -1, -1 ),
2, choice_drill_offset_msg, 1, wxRA_SPECIFY_COLS );
if( DrillOriginIsAuxAxis )
m_Choice_Drill_Offset->SetSelection( 1 );
LeftBoxSizer->Add( m_Choice_Drill_Offset, 0, wxGROW | wxALL, 5 );
/* second column */
wxString choice_drill_map_msg[] =
{_("None"), _("drill sheet (HPGL)"), _("drill sheet (PostScript)")};
m_Choice_Drill_Map = new wxRadioBox(this, ID_SEL_DRILL_SHEET,
_("Drill Sheet:"),
wxDefaultPosition,wxSize(-1,-1),
3,choice_drill_map_msg,1,wxRA_SPECIFY_COLS);
MiddleBoxSizer->Add(m_Choice_Drill_Map, 0, wxGROW|wxALL, 5);
wxString choice_drill_report_msg[] =
{_("None"), _("Drill report") };
m_Choice_Drill_Report = new wxRadioBox(this, ID_SEL_DRILL_REPORT,
_("Drill Report:"),
wxDefaultPosition,wxSize(-1,-1),
2,choice_drill_report_msg,1,wxRA_SPECIFY_COLS);
MiddleBoxSizer->Add(m_Choice_Drill_Report, 0, wxGROW|wxALL, 5);
m_ViaDrillCtrl = new WinEDA_ValueCtrl(this, _("Via Drill"),
g_DesignSettings.m_ViaDrill, g_UnitMetric, MiddleBoxSizer,
m_Parent->m_InternalUnits);
m_PenNum = new WinEDA_ValueCtrl(this, _("Pen Number"),
g_HPGL_Pen_Num, 2, MiddleBoxSizer, 1);
m_PenSpeed = new WinEDA_ValueCtrl(this, _("Speed (cm/s)"),
g_HPGL_Pen_Speed, CENTIMETRE, MiddleBoxSizer, 1);
m_Check_Mirror = new wxCheckBox(this, -1, _("mirror y axis"));
m_Check_Mirror->SetValue(Mirror);
MiddleBoxSizer->Add(m_Check_Mirror, 0, wxGROW|wxALL, 5);
m_Check_Minimal = new wxCheckBox(this, -1, _("minimal header"));
m_Check_Minimal->SetValue(Minimal);
MiddleBoxSizer->Add(m_Check_Minimal, 0, wxGROW|wxALL, 5);
wxString choice_drill_map_msg[] =
{ _( "None" ), _( "drill sheet (HPGL)" ), _( "drill sheet (PostScript)" ) };
m_Choice_Drill_Map = new wxRadioBox( this, ID_SEL_DRILL_SHEET,
_( "Drill Sheet:" ),
wxDefaultPosition, wxSize( -1, -1 ),
3, choice_drill_map_msg, 1, wxRA_SPECIFY_COLS );
MiddleBoxSizer->Add( m_Choice_Drill_Map, 0, wxGROW | wxALL, 5 );
wxString choice_drill_report_msg[] =
{ _( "None" ), _( "Drill report" ) };
m_Choice_Drill_Report = new wxRadioBox( this, ID_SEL_DRILL_REPORT,
_( "Drill Report:" ),
wxDefaultPosition, wxSize( -1, -1 ),
2, choice_drill_report_msg, 1, wxRA_SPECIFY_COLS );
MiddleBoxSizer->Add( m_Choice_Drill_Report, 0, wxGROW | wxALL, 5 );
m_ViaDrillCtrl = new WinEDA_ValueCtrl( this, _(
"Via Drill" ),
g_DesignSettings.m_ViaDrill, g_UnitMetric,
MiddleBoxSizer,
m_Parent->m_InternalUnits );
m_PenNum = new WinEDA_ValueCtrl( this, _( "Pen Number" ),
g_HPGL_Pen_Num, 2, MiddleBoxSizer, 1 );
m_PenSpeed = new WinEDA_ValueCtrl( this, _( "Speed (cm/s)" ),
g_HPGL_Pen_Speed, CENTIMETRE, MiddleBoxSizer, 1 );
m_Check_Mirror = new wxCheckBox( this, -1, _( "mirror y axis" ) );
m_Check_Mirror->SetValue( Mirror );
MiddleBoxSizer->Add( m_Check_Mirror, 0, wxGROW | wxALL, 5 );
m_Check_Minimal = new wxCheckBox( this, -1, _( "minimal header" ) );
m_Check_Minimal->SetValue( Minimal );
MiddleBoxSizer->Add( m_Check_Minimal, 0, wxGROW | wxALL, 5 );
/* third column, buttons */
wxButton * Button = new wxButton(this, ID_CREATE_DRILL_FILES,
_("&Execute"));
Button->SetForegroundColour(*wxRED);
RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5);
wxButton* Button = new wxButton( this, ID_CREATE_DRILL_FILES,
_( "&Execute" ) );
Button->SetForegroundColour( *wxRED );
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
Button = new wxButton(this, ID_CLOSE_DRILL, _("&Close"));
Button->SetForegroundColour(*wxBLUE);
RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5);
Button = new wxButton( this, ID_CLOSE_DRILL, _( "&Close" ) );
Button->SetForegroundColour( *wxBLUE );
RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
GetSizer()->Fit(this);
GetSizer()->SetSizeHints(this);
GetSizer()->Fit( this );
GetSizer()->SetSizeHints( this );
Centre();
}
......@@ -276,40 +284,42 @@ void WinEDA_DrillFrame::SetParams()
Unit_Drill_is_Inch = m_Choice_Unit->GetSelection();
g_HPGL_Pen_Speed = m_PenSpeed->GetValue();
g_HPGL_Pen_Num = m_PenNum->GetValue();
if ( m_Choice_Drill_Offset->GetSelection() == 0)
File_Drill_Offset = wxPoint(0,0);
if( m_Choice_Drill_Offset->GetSelection() == 0 )
File_Drill_Offset = wxPoint( 0, 0 );
else
File_Drill_Offset = m_Parent->m_Auxiliary_Axis_Position;
/* 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 l=ps.substr(0,1);
wxString r=ps.substr(2,1);
l.ToLong((long*)&s_Precision.m_lhs);
r.ToLong((long*)&s_Precision.m_rhs);
wxString l = ps.substr( 0, 1 );
wxString r = ps.substr( 2, 1 );
l.ToLong( (long*) &s_Precision.m_lhs );
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
*/
*/
{
wxConfig * Config = m_Parent->m_EDA_Config;
wxConfig* Config = m_Parent->m_EDA_Config;
if( Config )
{
Config->Read(ZerosFormatKey, & s_Zeros_Format );
Config->Read(LeftPrecisionKey, & s_Precision.m_lhs );
Config->Read(RightPrecisionKey, & s_Precision.m_rhs );
Config->Read(MirrorKey, &Mirror );
Config->Read(MinimalKey, &Minimal );
Config->Read(UnitDrillInchKey, &Unit_Drill_is_Inch );
Config->Read(DrillOriginIsAuxAxisKey, &DrillOriginIsAuxAxis );
Config->Read( ZerosFormatKey, &s_Zeros_Format );
Config->Read( LeftPrecisionKey, &s_Precision.m_lhs );
Config->Read( RightPrecisionKey, &s_Precision.m_rhs );
Config->Read( MirrorKey, &Mirror );
Config->Read( MinimalKey, &Minimal );
Config->Read( UnitDrillInchKey, &Unit_Drill_is_Inch );
Config->Read( DrillOriginIsAuxAxisKey, &DrillOriginIsAuxAxis );
}
WinEDA_DrillFrame * frame = new WinEDA_DrillFrame(this);
WinEDA_DrillFrame* frame = new WinEDA_DrillFrame( this );
frame->ShowModal(); frame->Destroy();
}
......@@ -318,40 +328,40 @@ WinEDA_DrillFrame * frame = new WinEDA_DrillFrame(this);
/******************************************/
void WinEDA_DrillFrame::UpdateConfig()
/******************************************/
/* Save drill options: */
/* Save drill options: */
{
SetParams();
wxConfig * Config = m_Parent->m_Parent->m_EDA_Config;
wxConfig* Config = m_Parent->m_Parent->m_EDA_Config;
if( Config )
{
Config->Write(ZerosFormatKey, s_Zeros_Format);
Config->Write(LeftPrecisionKey, s_Precision.m_lhs );
Config->Write(RightPrecisionKey, s_Precision.m_rhs );
Config->Write(MirrorKey, Mirror);
Config->Write(MinimalKey, Minimal);
Config->Write(UnitDrillInchKey, Unit_Drill_is_Inch);
Config->Write(DrillOriginIsAuxAxisKey, DrillOriginIsAuxAxis);
Config->Write( ZerosFormatKey, s_Zeros_Format );
Config->Write( LeftPrecisionKey, s_Precision.m_lhs );
Config->Write( RightPrecisionKey, s_Precision.m_rhs );
Config->Write( MirrorKey, Mirror );
Config->Write( MinimalKey, Minimal );
Config->Write( UnitDrillInchKey, Unit_Drill_is_Inch );
Config->Write( DrillOriginIsAuxAxisKey, DrillOriginIsAuxAxis );
}
}
/****************************************************************/
void WinEDA_DrillFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
void WinEDA_DrillFrame::OnQuit( wxCommandEvent& WXUNUSED (event) )
/****************************************************************/
{
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"));
int ii;
wxString msg;
wxString FullFileName, Mask( wxT( "*" ) ), Ext( wxT( ".drl" ) );
int ii;
wxString msg;
UpdateConfig(); /* set params and Save drill options */
......@@ -359,14 +369,15 @@ wxString msg;
/* Calcul des echelles de conversion */
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 */
FullFileName = m_Parent->m_CurrentScreen->m_FileName;
ChangeFileNameExt(FullFileName, Ext);
ChangeFileNameExt( FullFileName, Ext );
Mask += Ext;
FullFileName = EDA_FileSelector(_("Drill file"),
FullFileName = EDA_FileSelector( _( "Drill file" ),
wxEmptyString, /* Chemin par defaut */
FullFileName, /* nom fichier par defaut */
Ext, /* extension par defaut */
......@@ -375,180 +386,205 @@ wxString msg;
wxFD_SAVE,
TRUE
);
if ( FullFileName != wxEmptyString )
if( FullFileName != wxEmptyString )
{
dest = wxFopen(FullFileName, wxT("w") );
if (dest == 0)
dest = wxFopen( FullFileName, wxT( "w" ) );
if( dest == 0 )
{
msg = _("Unable to create file ") + FullFileName;
DisplayError(this, msg);
EndModal(0);
return ;
msg = _( "Unable to create file " ) + FullFileName;
DisplayError( this, msg );
EndModal( 0 );
return;
}
/* Init : */
Affiche_1_Parametre(m_Parent, 0,_("File"),FullFileName,BLUE) ;
Affiche_1_Parametre( m_Parent, 0, _( "File" ), FullFileName, BLUE );
Init_Drill();
ii = Gen_Liste_Forets( (FORET *) adr_lowmem,TRUE);
msg.Printf( wxT("%d"),ii);
Affiche_1_Parametre(m_Parent, 30,_("Tools"), msg, BROWN);
ii = Gen_Liste_Forets( (FORET*) adr_lowmem, TRUE );
msg.Printf( wxT( "%d" ), ii );
Affiche_1_Parametre( m_Parent, 30, _( "Tools" ), msg, BROWN );
ii = Gen_Drill_File_EXCELLON( (FORET *) adr_lowmem);
msg.Printf( wxT("%d"),ii);
Affiche_1_Parametre(m_Parent, 45,_("Drill"), msg, GREEN);
ii = Gen_Drill_File_EXCELLON( (FORET*) adr_lowmem );
msg.Printf( wxT( "%d" ), ii );
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:
GenDrillMap(PLOT_FORMAT_HPGL);
GenDrillMap( PLOT_FORMAT_HPGL );
break;
case 2:
GenDrillMap(PLOT_FORMAT_POST);
GenDrillMap( PLOT_FORMAT_POST );
break;
}
if ( m_Choice_Drill_Report->GetSelection() > 0 )
if( m_Choice_Drill_Report->GetSelection() > 0 )
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 */
m_Choice_Precision->SetString(0,_("2:3"));
m_Choice_Precision->SetString(1,_("2:4"));
m_Choice_Precision->SetString( 0, _( "2:3" ) );
m_Choice_Precision->SetString( 1, _( "2:4" ) );
}
else
{ /* metric options */
m_Choice_Precision->SetString(0,_("3:2"));
m_Choice_Precision->SetString(1,_("3:3"));
{
/* metric options */
m_Choice_Precision->SetString( 0, _( "3:2" ) );
m_Choice_Precision->SetString( 1, _( "3:3" ) );
}
if (m_Choice_Zeros_Format->GetSelection()==DECIMAL_FORMAT)
m_Choice_Precision->Enable(false);
if( m_Choice_Zeros_Format->GetSelection()==DECIMAL_FORMAT )
m_Choice_Precision->Enable( false );
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
Return hole count
buffer: Drill tools list
*/
* Return hole count
* buffer: Drill tools list
*/
{
FORET * foret;
TRACK * pt_piste;
D_PAD * pt_pad;
MODULE * Module;
int ii, diam, nb_trous;
int x0, y0, xf, yf, xc, yc;
float xt,yt;
char line[1024];
FORET* foret;
TRACK* pt_piste;
D_PAD* pt_pad;
MODULE* Module;
int ii, diam, nb_trous;
int x0, y0, xf, yf, xc, yc;
float xt, yt;
char line[1024];
/* Create the pad drill list : */
nb_trous = 0;
/* 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 */
{
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->m_Drill == 0 ) continue;
int via_drill = ( pt_piste->m_Drill < 0 ) ? g_DesignSettings.m_ViaDrill : pt_piste->m_Drill;
if ( foret->m_Diameter != via_drill )
if( pt_piste->Type() != TYPEVIA )
continue;
if( pt_piste->m_Drill == 0 )
continue;
int via_drill = ( pt_piste->m_Drill <
0 ) ? g_DesignSettings.m_ViaDrill : pt_piste->m_Drill;
if( foret->m_Diameter != via_drill )
continue;
x0 = pt_piste->m_Start.x - File_Drill_Offset.x;
y0 = pt_piste->m_Start.y - File_Drill_Offset.y;
//<ryan's edit>
if (!Mirror) y0 *= -1;
if( !Mirror )
y0 *= -1;
xt = float(x0) * conv_unit; yt = float(y0) * conv_unit;
if(Unit_Drill_is_Inch)
xt = float (x0) * conv_unit; yt = float (y0) * conv_unit;
if( Unit_Drill_is_Inch )
{
Gen_Line_EXCELLON(line, xt, yt);
Gen_Line_EXCELLON( line, xt, yt );
}
//</ryan's edit>
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 .
// conversion , -> . necessaire !
to_point( line );
fputs(line,dest);
fputs( line, dest );
nb_trous++;
}
}
/* Read pad list and create Drill infos for round holes only: */
Module = m_Parent->m_Pcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*)Module->Pnext )
for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{
/* Examen des pastilles */
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;
if ( diam == 0 ) continue;
if(diam != foret->m_Diameter) continue;
if( diam == 0 )
continue;
if( diam != foret->m_Diameter )
continue;
/* Compute the hole coordinates: */
x0 = pt_pad->m_Pos.x - File_Drill_Offset.x;
y0 = pt_pad->m_Pos.y - File_Drill_Offset.y;
//<ryan's edit>
if (!Mirror) y0 *= -1;
if( !Mirror )
y0 *= -1;
xt = float(x0) * conv_unit; yt = float(y0) * conv_unit;
if(Unit_Drill_is_Inch)
Gen_Line_EXCELLON(line, xt, yt);
xt = float (x0) * conv_unit; yt = float (y0) * conv_unit;
if( Unit_Drill_is_Inch )
Gen_Line_EXCELLON( line, xt, yt );
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)
fputs(line,dest);
fputs( line, dest );
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: */
Module = m_Parent->m_Pcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*)Module->Pnext )
for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{
/* Examen des pastilles */
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 ) ;
if ( diam == 0 ) continue;
if(diam != foret->m_Diameter) continue;
diam = MIN( pt_pad->m_Drill.x, pt_pad->m_Drill.y );
if( diam == 0 )
continue;
if( diam != foret->m_Diameter )
continue;
/* Compute the hole coordinates: */
xc = x0 = xf = pt_pad->m_Pos.x - File_Drill_Offset.x;
yc = y0 = yf = pt_pad->m_Pos.y - File_Drill_Offset.y;
/* 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;
y0 -= delta; yf += delta;
......@@ -558,215 +594,264 @@ char line[1024];
int delta = (pt_pad->m_Drill.x - pt_pad->m_Drill.y) / 2;
x0 -= delta; xf += delta;
}
RotatePoint(&x0, &y0, xc, yc, pt_pad->m_Orient);
RotatePoint(&xf, &yf, xc, yc, pt_pad->m_Orient);
RotatePoint( &x0, &y0, xc, yc, pt_pad->m_Orient );
RotatePoint( &xf, &yf, xc, yc, pt_pad->m_Orient );
//<ryan's edit>
if (!Mirror) { y0 *= -1; yf *= -1; }
if( !Mirror )
{
y0 *= -1; yf *= -1;
}
// sprintf(line,"T%d\n",ii+1); fputs(line,dest);
xt = float(x0) * conv_unit; yt = float(y0) * conv_unit;
if(Unit_Drill_is_Inch)
Gen_Line_EXCELLON(line, xt, yt);
xt = float (x0) * conv_unit; yt = float (y0) * conv_unit;
if( Unit_Drill_is_Inch )
Gen_Line_EXCELLON( line, xt, yt );
else
Gen_Line_EXCELLON(line, xt*10, yt*10);
Gen_Line_EXCELLON( line, xt * 10, yt * 10 );
to_point( line );
/* remove the '\n' from end of line: */
for ( int kk = 0; line[kk] != 0; kk++ )
if ( line[kk] == '\n' || line[kk] =='\r' )
for( int kk = 0; line[kk] != 0; kk++ )
if( line[kk] == '\n' || line[kk] =='\r' )
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;
if(Unit_Drill_is_Inch)
Gen_Line_EXCELLON(line, xt, yt);
xt = float (xf) * conv_unit; yt = float (yf) * conv_unit;
if( Unit_Drill_is_Inch )
Gen_Line_EXCELLON( line, xt, yt );
else
Gen_Line_EXCELLON(line, xt*10, yt*10);
to_point( line ); fputs(line,dest);
fputs("G05\n",dest);
Gen_Line_EXCELLON( line, xt * 10, yt * 10 );
to_point( line ); fputs( line, dest );
fputs( "G05\n", dest );
nb_trous++;
} /* Fin examen 1 module */
} /* fin analyse des trous de modules pour le foret en cours*/
} /* 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;
int xpad = s_Precision.m_lhs + s_Precision.m_rhs;
int ypad = xpad;
/* 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. */
switch (s_Zeros_Format)
switch( s_Zeros_Format )
{
default:
case DECIMAL_FORMAT:
sprintf(line,"X%.3fY%.3f\n", x, y);
sprintf( line, "X%.3fY%.3f\n", x, y );
break;
case SUPPRESS_LEADING: /* that should work now */
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) );
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 ) );
break;
case SUPPRESS_TRAILING:
{
for (int i=0;i< s_Precision.m_rhs;i++)
{ x *= 10; y*=10; }
if (x<0)xpad++;
if (y<0)ypad++;
for( int i = 0; i< s_Precision.m_rhs; i++ )
{
x *= 10; y *= 10;
}
if( x<0 )
xpad++;
if( y<0 )
ypad++;
xs.Printf( wxT("%0*d"), xpad, (int) round(x) );
ys.Printf( wxT("%0*d"), ypad, (int) round(y) );
xs.Printf( wxT( "%0*d" ), xpad, (int) round( x ) );
ys.Printf( wxT( "%0*d" ), ypad, (int) round( y ) );
size_t j=xs.Len()-1;
while (xs[j] == '0' && j) xs.Truncate(j--);
j=ys.Len()-1;
while (ys[j] == '0' && j) ys.Truncate(j--);
size_t j = xs.Len() - 1;
while( xs[j] == '0' && j )
xs.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;
}
case KEEP_ZEROS:
for (int i=0;i< s_Precision.m_rhs;i++)
{ x *= 10; y*=10; }
if (x<0)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));
for( int i = 0; i< s_Precision.m_rhs; i++ )
{
x *= 10; y *= 10;
}
if( x<0 )
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;
};
}
;
}
/***************************************************/
/***************************************************/
FORET * GetOrAddForet( FORET * buffer, int diameter)
FORET* GetOrAddForet( FORET* buffer, int 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;
FORET * foret;
int ii;
FORET* foret;
if(diameter == 0) return NULL;
if( diameter == 0 )
return NULL;
/* Search for an existing tool: */
for(ii = 0, foret = buffer ; ii < DrillToolsCount; ii++, foret++)
for( ii = 0, foret = buffer; ii < DrillToolsCount; ii++, foret++ )
{
if(foret->m_Diameter == diameter) /* found */
if( foret->m_Diameter == diameter ) /* found */
return foret;
}
/* No tool found, we must create a new one */
DrillToolsCount ++;
DrillToolsCount++;
foret->m_TotalCount = 0;
foret->m_OvalCount = 0;
foret->m_Diameter = diameter;
return foret;
}
/* 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
Genere une liste de DrillToolsCount structures FORET a partir de buffer
*/
/* 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
* Genere une liste de DrillToolsCount structures FORET a partir de buffer
*/
{
FORET * foret;
D_PAD * pt_pad;
MODULE * Module;
int ii, diam;
char line[1024];
FORET* foret;
D_PAD* pt_pad;
MODULE* Module;
int ii, diam;
char line[1024];
DrillToolsCount = 0; foret = buffer;
/* 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 )
{
if(pt_piste->Type() != TYPEVIA) continue;
if ( pt_piste->m_Drill == 0 ) continue;
if( pt_piste->Type() != TYPEVIA )
continue;
if( pt_piste->m_Drill == 0 )
continue;
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;
foret = GetOrAddForet( buffer, via_drill);
if ( foret ) foret->m_TotalCount++;
foret = GetOrAddForet( buffer, via_drill );
if( foret )
foret->m_TotalCount++;
}
/* Create the pad tools : */
Module = m_Parent->m_Pcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*)Module->Pnext )
for( ; Module != NULL; Module = (MODULE*) Module->Pnext )
{
/* Examen des pastilles */
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;
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);
if ( foret )
foret = GetOrAddForet( buffer, diam );
if( foret )
{
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 */
qsort(buffer,DrillToolsCount,sizeof(FORET),
(int(*)(const void *, const void * ))Sort_by_Drill_Value);
qsort( buffer, DrillToolsCount, sizeof(FORET),
( int( * ) ( const void*, const void* ) )Sort_by_Drill_Value );
/* 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>
if (Unit_Drill_is_Inch) /* does it need T01, T02 or is T1,T2 ok?*/
sprintf(line,"T%dC%.3f\n", ii+1,
float(foret->m_Diameter) * conv_unit);
if( Unit_Drill_is_Inch ) /* does it need T01, T02 or is T1,T2 ok?*/
sprintf( line, "T%dC%.3f\n", ii + 1,
float (foret->m_Diameter) * conv_unit );
else
sprintf(line,"T%dC%.3f\n", ii+1,
float(foret->m_Diameter) * conv_unit * 10.0);
sprintf( line, "T%dC%.3f\n", ii + 1,
float (foret->m_Diameter) * conv_unit * 10.0 );
//</ryan's edit>
to_point( line );
fputs(line,dest);
fputs( line, dest );
}
fputs("%\n",dest);
if (!Minimal) fputs("M47\n",dest); /* Operator message */
fputs("G05\n",dest); /* Drill mode */
fputs( "%\n", dest );
if( !Minimal )
fputs( "M47\n", dest ); /* Operator message */
fputs( "G05\n", dest ); /* Drill mode */
/* Units : */
if (Unit_Drill_is_Inch && !Minimal) fputs("M72\n",dest); /* M72 = inch mode */
else if (!Minimal) fputs("M71\n",dest); /* M71 = metric mode */
if( Unit_Drill_is_Inch && !Minimal )
fputs( "M72\n", dest ); /* M72 = inch mode */
else if( !Minimal )
fputs( "M71\n", dest ); /* M71 = metric mode */
}
return(DrillToolsCount);
return DrillToolsCount;
}
......@@ -775,103 +860,106 @@ void WinEDA_DrillFrame::Init_Drill()
/***************************************/
/* 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);
wxString Title = g_Main_Title + wxT(" ") + GetBuildVersion();
fprintf(dest,";DRILL file {%s} date %s\n",CONV_TO_UTF8(Title),Line);
fputs(";FORMAT={",dest);
fprintf(dest,"%s / absolute / ",
CONV_TO_UTF8(m_Choice_Precision->GetStringSelection()));
fprintf(dest,"%s / ",CONV_TO_UTF8(m_Choice_Unit->GetStringSelection()));
fprintf(dest,"%s}\n",CONV_TO_UTF8(m_Choice_Zeros_Format->GetStringSelection()));
fputs("R,T\nVER,1\nFMAT,2\n",dest);
DateAndTime( Line );
wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion();
fprintf( dest, ";DRILL file {%s} date %s\n", CONV_TO_UTF8( Title ), Line );
fputs( ";FORMAT={", dest );
fprintf( dest, "%s / absolute / ",
CONV_TO_UTF8( m_Choice_Precision->GetStringSelection() ) );
fprintf( dest, "%s / ", CONV_TO_UTF8( m_Choice_Unit->GetStringSelection() ) );
fprintf( dest, "%s}\n", CONV_TO_UTF8( m_Choice_Zeros_Format->GetStringSelection() ) );
fputs( "R,T\nVER,1\nFMAT,2\n", dest );
}
if( Unit_Drill_is_Inch ) fputs("INCH",dest); // Si unites en INCHES
else fputs("METRIC",dest); // Si unites en mm
if( Unit_Drill_is_Inch )
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 DECIMAL_FORMAT:
fputs(",TZ\n",dest);
fputs( ",TZ\n", dest );
break;
case SUPPRESS_TRAILING:
fputs(",LZ\n",dest);
fputs( ",LZ\n", dest );
break;
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;
}
if (!Minimal)
fputs("TCST,OFF\nICI,OFF\nATC,ON\n",dest);
if( !Minimal )
fputs( "TCST,OFF\nICI,OFF\nATC,ON\n", dest );
}
/************************/
void Fin_Drill()
/************************/
/*****************************/
void Write_End_Of_File_Drill()
/*****************************/
{
//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
*/
*/
{
int ii, x, y;
int plotX, plotY, TextWidth;
FORET * foret;
int intervalle = 0, CharSize = 0;
EDA_BaseStruct * PtStruct;
int old_g_PlotOrient = g_PlotOrient;
wxString FullFileName, Mask(wxT("*")), Ext;
char line[1024];
int dX, dY;
wxPoint BoardCentre;
int PlotMarge_in_mils = 400; // Margin in 1/1000 inch
int marge = PlotMarge_in_mils * U_PCB;
wxSize SheetSize;
float fTextScale = 1.0;
double scale_x = 1.0, scale_y = 1.0;
Ki_PageDescr * SheetPS = NULL;
wxString msg;
int ii, x, y;
int plotX, plotY, TextWidth;
FORET* foret;
int intervalle = 0, CharSize = 0;
EDA_BaseStruct* PtStruct;
int old_g_PlotOrient = g_PlotOrient;
wxString FullFileName, Mask( wxT( "*" ) ), Ext;
char line[1024];
int dX, dY;
wxPoint BoardCentre;
int PlotMarge_in_mils = 400; // Margin in 1/1000 inch
int marge = PlotMarge_in_mils * U_PCB;
wxSize SheetSize;
float fTextScale = 1.0;
double scale_x = 1.0, scale_y = 1.0;
Ki_PageDescr* SheetPS = NULL;
wxString msg;
/* Init extension */
switch( format )
{
case PLOT_FORMAT_HPGL:
Ext = wxT("-drl.plt");
Ext = wxT( "-drl.plt" );
break;
case PLOT_FORMAT_POST:
Ext = wxT("-drl.ps");
Ext = wxT( "-drl.ps" );
break;
default:
DisplayError (this, wxT("WinEDA_DrillFrame::GenDrillMap() error"));
DisplayError( this, wxT( "WinEDA_DrillFrame::GenDrillMap() error" ) );
return;
}
/* Init file name */
FullFileName = m_Parent->m_CurrentScreen->m_FileName;
ChangeFileNameExt(FullFileName, Ext);
ChangeFileNameExt( FullFileName, Ext );
Mask += Ext;
FullFileName = EDA_FileSelector(_("Drill Map file"),
FullFileName = EDA_FileSelector( _( "Drill Map file" ),
wxEmptyString, /* Chemin par defaut */
FullFileName, /* nom fichier par defaut */
Ext, /* extension par defaut */
......@@ -880,7 +968,8 @@ wxString msg;
wxFD_SAVE,
TRUE
);
if ( FullFileName.IsEmpty()) return;
if( FullFileName.IsEmpty() )
return;
g_PlotOrient = 0;
/* calcul des dimensions et centre du PCB */
......@@ -903,7 +992,7 @@ wxString msg;
SheetSize.x *= U_PCB;
SheetSize.y *= U_PCB;
g_PlotOffset.x = 0;
g_PlotOffset.y = (int)(SheetSize.y * scale_y);
g_PlotOffset.y = (int) (SheetSize.y * scale_y);
break;
case PLOT_FORMAT_POST:
......@@ -912,42 +1001,42 @@ wxString msg;
SheetPS = &g_Sheet_A4;
SheetSize.x = SheetPS->m_Size.x * U_PCB;
SheetSize.y = SheetPS->m_Size.y * U_PCB;
float Xscale = (float) (SheetSize.x - (marge*2)) / dX;
float Yscale = (float) (SheetSize.y * 0.6 - (marge*2)) / dY;
float Xscale = (float) ( SheetSize.x - (marge * 2) ) / dX;
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) +
(int)(BoardCentre.x * scale_x) + marge;
g_PlotOffset.y = SheetSize.y/2 +
(int)(BoardCentre.y * scale_y) - marge;
g_PlotOffset.y += SheetSize.y / 8 ; /* decalage pour legende */
g_PlotOffset.x = -(SheetSize.x / 2) +
(int) (BoardCentre.x * scale_x) + marge;
g_PlotOffset.y = SheetSize.y / 2 +
(int) (BoardCentre.y * scale_y) - marge;
g_PlotOffset.y += SheetSize.y / 8; /* decalage pour legende */
break;
}
}
dest = wxFopen(FullFileName, wxT("wt") );
if (dest == 0)
dest = wxFopen( FullFileName, wxT( "wt" ) );
if( dest == 0 )
{
msg.Printf( _("Unable to create file <%s>"),FullFileName.GetData()) ;
DisplayError(this, msg); return ;
msg.Printf( _( "Unable to create file <%s>" ), FullFileName.GetData() );
DisplayError( this, msg ); return;
}
/* Init : */
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) */
ii = Gen_Liste_Forets( (FORET *) adr_lowmem, FALSE);
msg.Printf( wxT("%d"),ii);
Affiche_1_Parametre(m_Parent, 48, _("Tools"), msg, BROWN);
ii = Gen_Liste_Forets( (FORET*) adr_lowmem, FALSE );
msg.Printf( wxT( "%d" ), ii );
Affiche_1_Parametre( m_Parent, 48, _( "Tools" ), msg, BROWN );
switch( format )
{
case PLOT_FORMAT_HPGL:
InitPlotParametresHPGL(g_PlotOffset, scale_x, scale_y);
PrintHeaderHPGL(dest, g_HPGL_Pen_Speed,g_HPGL_Pen_Num);
InitPlotParametresHPGL( g_PlotOffset, scale_x, scale_y );
PrintHeaderHPGL( dest, g_HPGL_Pen_Speed, g_HPGL_Pen_Num );
break;
case PLOT_FORMAT_POST:
......@@ -956,11 +1045,11 @@ wxString msg;
BBox[0] = BBox[1] = PlotMarge_in_mils;
BBox[2] = SheetPS->m_Size.x - PlotMarge_in_mils;
BBox[3] = SheetPS->m_Size.y - PlotMarge_in_mils;
InitPlotParametresPS(g_PlotOffset, SheetPS,
(double) 1.0 / PCB_INTERNAL_UNIT, (double) 1.0 / PCB_INTERNAL_UNIT);
SetDefaultLineWidthPS(10); // Set line with to 10/1000 inch
PrintHeaderPS(dest, wxT("PCBNEW-PS"), FullFileName, 1, BBox, wxLANDSCAPE);
InitPlotParametresPS(g_PlotOffset, SheetPS, scale_x, scale_y);
InitPlotParametresPS( g_PlotOffset, SheetPS,
(double) 1.0 / PCB_INTERNAL_UNIT, (double) 1.0 / PCB_INTERNAL_UNIT );
SetDefaultLineWidthPS( 10 ); // Set line with to 10/1000 inch
PrintHeaderPS( dest, wxT( "PCBNEW-PS" ), FullFileName, 1, BBox, wxLANDSCAPE );
InitPlotParametresPS( g_PlotOffset, SheetPS, scale_x, scale_y );
}
break;
......@@ -979,62 +1068,65 @@ wxString msg;
break;
case TYPETEXTE:
PlotTextePcb((TEXTE_PCB*) PtStruct, format, EDGE_LAYER);
PlotTextePcb( (TEXTE_PCB*) PtStruct, format, EDGE_LAYER );
break;
case TYPECOTATION:
PlotCotation((COTATION*) PtStruct, format, EDGE_LAYER);
PlotCotation( (COTATION*) PtStruct, format, EDGE_LAYER );
break;
case TYPEMIRE:
PlotMirePcb((MIREPCB*) PtStruct, format, EDGE_LAYER);
PlotMirePcb( (MIREPCB*) PtStruct, format, EDGE_LAYER );
break;
default:
DisplayError(this, wxT("WinEDA_DrillFrame::GenDrillMap() : Unexpected Draw Type") );
DisplayError( this, wxT( "WinEDA_DrillFrame::GenDrillMap() : Unexpected Draw Type" ) );
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 )
{
sprintf( line, "%d setlinewidth\n", TextWidth );
fputs(line,dest);
fputs( line, dest );
}
ii = Plot_Drill_PcbMap( (FORET *) adr_lowmem, format);
msg.Printf( wxT("%d"),ii);
Affiche_1_Parametre(m_Parent, 64, _("Drill"), msg,GREEN);
ii = Plot_Drill_PcbMap( (FORET*) adr_lowmem, format );
msg.Printf( wxT( "%d" ), ii );
Affiche_1_Parametre( m_Parent, 64, _( "Drill" ), msg, GREEN );
/* Impression de la liste des symboles utilises */
CharSize = 600; /* hauteur des textes en 1/10000 mils */
float CharScale = 1.0;
TextWidth = (int)(50 * CharScale); // Set text width
intervalle = (int)(CharSize * CharScale) + TextWidth;
CharSize = 800; /* text size in 1/10000 mils */
float CharScale = 1.0 / scale_x; /* real scale will be CharScale * scale_x,
* because the global plot scale is scale_x */
TextWidth = (int) (50 * CharScale); // Set text width
intervalle = (int) (CharSize * CharScale) + TextWidth;
switch( format)
switch( format )
{
case PLOT_FORMAT_HPGL:
{
/* generation des dim: commande SI x,y; x et y = dim en cm */
char csize[256];
sprintf(csize, "%2.3f", (float)CharSize * CharScale * 0.000254);
to_point(csize);
sprintf(line,"SI %s, %s;\n", csize, csize);
sprintf( csize, "%2.3f", (float) CharSize * CharScale * 0.000254 );
to_point( csize );
sprintf( line, "SI %s, %s;\n", csize, csize );
break;
}
case PLOT_FORMAT_POST:
/* Reglage de l'epaisseur de traits des textes */
sprintf( line,"%d setlinewidth\n", TextWidth );
sprintf( line, "%d setlinewidth\n", TextWidth );
break;
default: *line = 0;
default:
*line = 0;
break;
}
fputs(line,dest);
fputs( line, dest );
switch( format )
{
......@@ -1042,11 +1134,11 @@ wxString msg;
case PLOT_FORMAT_POST:
g_PlotOffset.x = 0;
g_PlotOffset.y = 0;
InitPlotParametresPS(g_PlotOffset, SheetPS, scale_x, scale_x);
InitPlotParametresPS( g_PlotOffset, SheetPS, scale_x, scale_x );
break;
case PLOT_FORMAT_HPGL:
InitPlotParametresHPGL(g_PlotOffset, scale_x, scale_x);
InitPlotParametresHPGL( g_PlotOffset, scale_x, scale_x );
break;
}
......@@ -1055,78 +1147,84 @@ wxString msg;
/* Trace de "Infos" */
plotX = marge + 1000;
plotY = CharSize + 1000;
x = plotX ; y = plotY;
x = +g_PlotOffset.x + (int)(x * fTextScale);
y = g_PlotOffset.y - (int)(y * fTextScale);
x = plotX; y = plotY;
x = +g_PlotOffset.x + (int) (x * fTextScale);
y = g_PlotOffset.y - (int) (y * fTextScale);
plotY += (int) ( intervalle * 1.2) + 200;
switch( format )
{
case PLOT_FORMAT_HPGL:
sprintf(line,"PU %d, %d; LBInfos\03;\n",
x + (int)(intervalle * CharScale * fTextScale),
y - (int)(CharSize / 2 * CharScale * fTextScale) );
fputs(line,dest);
sprintf( line, "PU %d, %d; LBInfos\03;\n",
x + (int) (intervalle * CharScale * fTextScale),
y - (int) (CharSize / 2 * CharScale * fTextScale) );
fputs( line, dest );
break;
case PLOT_FORMAT_POST:
wxString Text = wxT("Infos");
Plot_1_texte(format, Text, 0, TextWidth,
wxString Text = wxT( "Infos" );
Plot_1_texte( format, Text, 0, TextWidth,
x, y,
(int) (CharSize * CharScale), (int) (CharSize * CharScale),
FALSE);
FALSE );
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;
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 = -g_PlotOffset.x + (int)(x * fTextScale);
y = g_PlotOffset.y - (int)(y * fTextScale);
PlotDrillSymbol(wxPoint(x,y),plot_diam,ii, format);
x = -g_PlotOffset.x + (int) (x * fTextScale);
y = g_PlotOffset.y - (int) (y * fTextScale);
PlotDrillSymbol( wxPoint( x, y ), plot_diam, ii, format );
intervalle = (int)(CharSize * CharScale) + TextWidth;
intervalle = (int)( intervalle * 1.2);
intervalle = (int) (CharSize * CharScale) + TextWidth;
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;
x = plotX + rayon + (int)(CharSize * CharScale); y = plotY;
x = -g_PlotOffset.x + (int)(x * fTextScale);
y = g_PlotOffset.y - (int)(y * fTextScale);
int rayon = plot_diam / 2;
x = plotX + rayon + (int) (CharSize * CharScale); y = plotY;
x = -g_PlotOffset.x + (int) (x * fTextScale);
y = g_PlotOffset.y - (int) (y * fTextScale);
/* Trace de la legende associee */
switch( format )
{
case PLOT_FORMAT_HPGL:
// List the diameter of each drill in the selected Drill Unit,
// and then its diameter in the other Drill Unit.
if ( Unit_Drill_is_Inch )
if( Unit_Drill_is_Inch )
sprintf( line, "PU %d, %d; LB%2.3f\" / %2.2fmm ",
x + (int)(intervalle * CharScale * fTextScale),
y - (int)(CharSize / 2 * CharScale * fTextScale),
float(foret->m_Diameter) * 0.0001,
float(foret->m_Diameter) * 0.00254 );
x + (int) (intervalle * CharScale * fTextScale),
y - (int) (CharSize / 2 * CharScale * fTextScale),
float (foret->m_Diameter) * 0.0001,
float (foret->m_Diameter) * 0.00254 );
else
sprintf( line, "PU %d, %d; LB%2.2fmm / %2.3f\" ",
x + (int)(intervalle * CharScale * fTextScale),
y - (int)(CharSize / 2 * CharScale * fTextScale),
float(foret->m_Diameter) * 0.00254,
float(foret->m_Diameter) * 0.0001 );
x + (int) (intervalle * CharScale * fTextScale),
y - (int) (CharSize / 2 * CharScale * fTextScale),
float (foret->m_Diameter) * 0.00254,
float (foret->m_Diameter) * 0.0001 );
fputs( line, dest );
// 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" );
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" );
else if ( foret->m_OvalCount == 0 )
else if( foret->m_OvalCount == 0 )
sprintf( line, "(%d holes)\n",
foret->m_TotalCount );
else if ( foret->m_OvalCount == 1 )
else if( foret->m_OvalCount == 1 )
sprintf( line, "(%d holes) (with 1 oblong)\n",
foret->m_TotalCount );
else // if ( foret->m_OvalCount > 1 )
......@@ -1134,315 +1232,368 @@ wxString msg;
foret->m_TotalCount,
foret->m_OvalCount );
fputs( line, dest );
fputs("\03;\n",dest);
fputs( "\03;\n", dest );
break;
case PLOT_FORMAT_POST:
// List the diameter of each drill in the selected Drill Unit,
// and then its diameter in the other Drill Unit.
if ( Unit_Drill_is_Inch )
if( Unit_Drill_is_Inch )
sprintf( line, "%2.3f\" / %2.2fmm ",
float(foret->m_Diameter) * 0.0001,
float(foret->m_Diameter) * 0.00254 );
float (foret->m_Diameter) * 0.0001,
float (foret->m_Diameter) * 0.00254 );
else
sprintf( line, "%2.2fmm / %2.3f\" ",
float(foret->m_Diameter) * 0.00254,
float(foret->m_Diameter) * 0.0001 );
msg = CONV_FROM_UTF8(line);
float (foret->m_Diameter) * 0.00254,
float (foret->m_Diameter) * 0.0001 );
msg = CONV_FROM_UTF8( line );
// 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)" );
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)" );
else if ( foret->m_OvalCount == 0 )
else if( foret->m_OvalCount == 0 )
sprintf( line, "(%d holes)",
foret->m_TotalCount );
else if ( foret->m_OvalCount == 1 )
else if( foret->m_OvalCount == 1 )
sprintf( line, "(%d holes) (with 1 oblong)",
foret->m_TotalCount );
else // if ( foret->m_OvalCount > 1 )
sprintf( line, "(%d holes) (with %d oblongs)",
foret->m_TotalCount,
foret->m_OvalCount );
msg += CONV_FROM_UTF8(line);
Plot_1_texte(format, msg, 0, TextWidth,
msg += CONV_FROM_UTF8( line );
Plot_1_texte( format, msg, 0, TextWidth,
x, y,
(int) (CharSize * CharScale),
(int) (CharSize * CharScale),
FALSE);
FALSE );
break;
}
plotY += intervalle;
}
switch( format )
{
case PLOT_FORMAT_HPGL:
CloseFileHPGL(dest);
CloseFileHPGL( dest );
break;
case PLOT_FORMAT_POST:
CloseFilePS(dest);
CloseFilePS( dest );
break;
}
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:
Nombre de trous
Utilise:
liste des forets pointee par buffer
*/
/** Trace la liste des trous a percer en format HPGL ou POSTSCRIPT
* @return drill count
* @param buffer = drill list buffer
* @param format = ouput format (hpgl / ps)
*/
{
FORET * foret;
TRACK * pt_piste;
D_PAD * pt_pad;
MODULE * Module;
int ii , diam, nb_trous;
wxPoint pos;
wxSize size;
FORET* foret;
TRACK* pt_piste;
D_PAD* pt_pad;
MODULE* Module;
int ii, diam, nb_trous;
wxPoint pos;
wxSize size;
nb_trous = 0;
/* create the drill list */
if ( DrillToolsCount > 13 )
if( DrillToolsCount > 13 )
{
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);
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 );
}
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 */
{
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->m_Drill == 0) continue;
if( pt_piste->Type() != TYPEVIA )
continue;
if( pt_piste->m_Drill == 0 )
continue;
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;
PlotDrillSymbol(pos, via_drill,ii, format);
PlotDrillSymbol( pos, via_drill, ii, format );
nb_trous++;
}
}
/* 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;
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:
diam = pt_pad->m_Drill.x;
if(diam != foret->m_Diameter) continue;
PlotDrillSymbol(pt_pad->m_Pos, diam,ii, format);
if( diam != foret->m_Diameter )
continue;
PlotDrillSymbol( pt_pad->m_Pos, diam, ii, format );
break;
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 );
if(diam != foret->m_Diameter) continue;
PlotOvalDrillSymbol(pt_pad->m_Pos, pt_pad->m_Drill,pt_pad->m_Orient, format);
if( diam != foret->m_Diameter )
continue;
PlotOvalDrillSymbol( pt_pad->m_Pos, pt_pad->m_Drill, pt_pad->m_Orient, format );
break;
}
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.
x0, y0 = coordonnees tables
diametre = diametre (coord table) du trou
num_forme = index ( permet de gererer des formes caract )
*/
* x0, y0 = coordonnees tables
* diametre = diametre (coord table) du trou
* num_forme = index ( permet de gererer des formes caract )
*/
{
int rayon = diametre / 2;
void (*FctPlume)(wxPoint pos, int state);
int x0, y0;
int rayon = diametre / 2;
void (*FctPlume)( wxPoint pos, int state );
int x0, y0;
x0 = position.x; y0 = position.y;
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 */
FctPlume( wxPoint(x0 - rayon, y0 - rayon), 'U');
FctPlume( wxPoint(x0 + rayon, y0 + rayon), 'D');
FctPlume( wxPoint(x0 + rayon, y0 - rayon), 'U');
FctPlume( wxPoint(x0 - rayon, y0 + rayon), 'D');
FctPlume( wxPoint( x0 - rayon, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0 + rayon, y0 + rayon ), 'D' );
FctPlume( wxPoint( x0 + rayon, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0 - rayon, y0 + rayon ), 'D' );
break;
case 1: /* Cercle */
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 )
trace_1_pastille_RONDE_POST(wxPoint(x0, y0), diametre, FILAIRE);
trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE );
break;
case 2: /* forme en + */
FctPlume( wxPoint(x0 , y0 - rayon),'U');
FctPlume( wxPoint(x0 , y0 + rayon),'D');
FctPlume( wxPoint(x0 + rayon, y0), 'U');
FctPlume( wxPoint(x0 - rayon, y0), 'D');
FctPlume( wxPoint( x0, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0, y0 + rayon ), 'D' );
FctPlume( wxPoint( x0 + rayon, y0 ), 'U' );
FctPlume( wxPoint( x0 - rayon, y0 ), 'D' );
break;
case 3: /* forme en X cercle */
FctPlume( wxPoint(x0 - rayon, y0 - rayon),'U');
FctPlume( wxPoint(x0 + rayon, y0 + rayon),'D');
FctPlume( wxPoint(x0 + rayon, y0 - rayon),'U');
FctPlume( wxPoint(x0 - rayon, y0 + rayon),'D');
FctPlume( wxPoint( x0 - rayon, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0 + rayon, y0 + rayon ), 'D' );
FctPlume( wxPoint( x0 + rayon, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0 - rayon, y0 + rayon ), 'D' );
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 )
trace_1_pastille_RONDE_POST(wxPoint(x0, y0), diametre, FILAIRE);
trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE );
break;
case 4: /* forme en cercle barre de - */
FctPlume( wxPoint(x0 - rayon, y0), 'U');
FctPlume( wxPoint(x0 + rayon, y0), 'D');
FctPlume( wxPoint( x0 - rayon, y0 ), 'U' );
FctPlume( wxPoint( x0 + rayon, y0 ), 'D' );
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 )
trace_1_pastille_RONDE_POST(wxPoint(x0, y0), diametre, FILAIRE);
trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE );
break;
case 5: /* forme en cercle barre de | */
FctPlume( wxPoint(x0, y0 - rayon),'U');
FctPlume( wxPoint(x0, y0 + rayon),'D');
FctPlume( wxPoint( x0, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0, y0 + rayon ), 'D' );
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 )
trace_1_pastille_RONDE_POST(wxPoint(x0, y0), diametre, FILAIRE);
trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE );
break;
case 6: /* forme en carre */
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 )
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;
case 7: /* forme en losange */
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 )
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;
case 8: /* forme en carre barre par un X*/
FctPlume( wxPoint(x0 - rayon, y0 - rayon),'U');
FctPlume( wxPoint(x0 + rayon, y0 + rayon),'D');
FctPlume( wxPoint(x0 + rayon, y0 - rayon),'U');
FctPlume( wxPoint(x0 - rayon, y0 + rayon),'D');
FctPlume( wxPoint( x0 - rayon, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0 + rayon, y0 + rayon ), 'D' );
FctPlume( wxPoint( x0 + rayon, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0 - rayon, y0 + rayon ), 'D' );
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 )
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;
case 9: /* forme en losange barre par un +*/
FctPlume( wxPoint(x0, y0 - rayon),'U');
FctPlume( wxPoint(x0, y0 + rayon),'D');
FctPlume( wxPoint(x0 + rayon, y0), 'U');
FctPlume( wxPoint(x0 - rayon, y0), 'D');
FctPlume( wxPoint( x0, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0, y0 + rayon ), 'D' );
FctPlume( wxPoint( x0 + rayon, y0 ), 'U' );
FctPlume( wxPoint( x0 - rayon, y0 ), 'D' );
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 )
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;
case 10: /* forme en carre barre par un '/' */
FctPlume( wxPoint(x0 - rayon, y0 - rayon),'U');
FctPlume( wxPoint(x0 + rayon, y0 + rayon),'D');
FctPlume( wxPoint( x0 - rayon, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0 + rayon, y0 + rayon ), 'D' );
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 )
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;
case 11: /* forme en losange barre par un |*/
FctPlume( wxPoint(x0, y0 - rayon), 'U');
FctPlume( wxPoint(x0, y0 + rayon), 'D');
FctPlume( wxPoint( x0, y0 - rayon ), 'U' );
FctPlume( wxPoint( x0, y0 + rayon ), 'D' );
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 )
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;
case 12: /* forme en losange barre par un -*/
FctPlume( wxPoint(x0 - rayon, y0), 'U');
FctPlume( wxPoint(x0 + rayon, y0), 'D');
FctPlume( wxPoint( x0 - rayon, y0 ), 'U' );
FctPlume( wxPoint( x0 + rayon, y0 ), 'D' );
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 )
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;
default:
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 )
trace_1_pastille_RONDE_POST(wxPoint(x0, y0), diametre, FILAIRE);
trace_1_pastille_RONDE_POST( wxPoint( x0, y0 ), diametre, FILAIRE );
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 )
{
case PLOT_FORMAT_HPGL:
trace_1_pastille_OVALE_HPGL(position, size, orient, FILAIRE);
trace_1_pastille_OVALE_HPGL( position, size, orient, FILAIRE );
break;
case PLOT_FORMAT_POST:
trace_1_pastille_OVALE_POST(position, size, orient, FILAIRE);
trace_1_pastille_OVALE_POST( position, size, orient, FILAIRE );
break;
}
}
/*******************************************/
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"));
int ii, TotalHoleCount;
char line[1024];
FORET * foret;
wxString msg;
wxString FileName, Mask( wxT( "*" ) ), Ext( wxT( ".rpt" ) );
int ii, TotalHoleCount;
char line[1024];
FORET* foret;
wxString msg;
FileName = m_Parent->m_CurrentScreen->m_FileName;
ChangeFileNameExt(FileName, wxT("-drl") + Ext);
ChangeFileNameExt( FileName, wxT( "-drl" ) + Ext );
Mask += Ext;
FileName = EDA_FileSelector(_("Drill Report file"),
FileName = EDA_FileSelector( _( "Drill Report file" ),
wxEmptyString, /* Chemin par defaut */
FileName, /* nom fichier par defaut */
Ext, /* extension par defaut */
......@@ -1451,62 +1602,63 @@ wxString msg;
wxFD_SAVE,
TRUE
);
if ( FileName.IsEmpty()) return;
if( FileName.IsEmpty() )
return;
dest = wxFopen(FileName, wxT("w") );
if (dest == 0)
dest = wxFopen( FileName, wxT( "w" ) );
if( dest == 0 )
{
msg = _("Unable to create file ") + FileName;
DisplayError(this, msg);
return ;
msg = _( "Unable to create file " ) + FileName;
DisplayError( this, msg );
return;
}
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. */
ii = Gen_Liste_Forets( (FORET *) adr_lowmem, FALSE );
msg.Printf( wxT("%d"), ii );
Affiche_1_Parametre( m_Parent, 30, _("Tools"), msg, BROWN );
ii = Gen_Liste_Forets( (FORET*) adr_lowmem, FALSE );
msg.Printf( wxT( "%d" ), ii );
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.
if ( Unit_Drill_is_Inch )
fputs("Selected Drill Unit: Imperial (\")\n\n", dest);
if( Unit_Drill_is_Inch )
fputs( "Selected Drill Unit: Imperial (\")\n\n", dest );
else
fputs("Selected Drill Unit: Metric (mm)\n\n", dest);
fputs( "Selected Drill Unit: Metric (mm)\n\n", dest );
TotalHoleCount = 0;
for ( ii = 0, foret = (FORET*)adr_lowmem ; ii < DrillToolsCount; ii++, foret++ )
for( ii = 0, foret = (FORET*) adr_lowmem; ii < DrillToolsCount; ii++, foret++ )
{
// List the tool number assigned to each drill,
// then its diameter in the selected Drill Unit,
// and then its diameter in the other Drill Unit.
if ( Unit_Drill_is_Inch )
if( Unit_Drill_is_Inch )
sprintf( line, "T%d %2.3f\" %2.2fmm ",
ii + 1,
float(foret->m_Diameter) * 0.0001,
float(foret->m_Diameter) * 0.00254 );
float (foret->m_Diameter) * 0.0001,
float (foret->m_Diameter) * 0.00254 );
else
sprintf( line, "T%d %2.2fmm %2.3f\" ",
ii + 1,
float(foret->m_Diameter) * 0.00254,
float(foret->m_Diameter) * 0.0001 );
float (foret->m_Diameter) * 0.00254,
float (foret->m_Diameter) * 0.0001 );
fputs( line, dest );
// 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" );
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" );
else if ( foret->m_OvalCount == 0 )
else if( foret->m_OvalCount == 0 )
sprintf( line, "(%d holes)\n",
foret->m_TotalCount );
else if ( foret->m_OvalCount == 1 )
else if( foret->m_OvalCount == 1 )
sprintf( line, "(%d holes) (with 1 oblong)\n",
foret->m_TotalCount );
else // if ( foret->m_OvalCount > 1 )
......@@ -1518,8 +1670,8 @@ wxString msg;
TotalHoleCount += foret->m_TotalCount;
}
msg.Printf( wxT("%d"), TotalHoleCount );
Affiche_1_Parametre( m_Parent, 45, _("Drill"), msg, GREEN );
msg.Printf( wxT( "%d" ), TotalHoleCount );
Affiche_1_Parametre( m_Parent, 45, _( "Drill" ), msg, GREEN );
fclose(dest);
fclose( dest );
}
......@@ -11,6 +11,7 @@ OBJECTS= $(TARGET).o classpcb.o\
modedit_undo_redo.o\
block_module_editor.o\
onrightclick.o\
onleftclick.o\
modedit_onclick.o\
via_edit.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 )
BOARD_ITEM* item = GetCurItem();
DrawPanel->CursorOff( &dc );
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( item && item->m_Flags )
......@@ -141,24 +150,14 @@ void WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
}
else
{
if( (item && item->m_Flags) || BlockActive )
{
if( BlockActive )
createPopUpBlockMenu( aPopMenu );
else
if( item && item->m_Flags )
{
ADD_MENUITEM( aPopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND,
_( "Cancel" ), cancel_xpm );
}
aPopMenu->AppendSeparator();
}
}
if( BlockActive )
{
DrawPanel->CursorOn( &dc );
return;
}
/* Select a proper item */
if( !item || !item->m_Flags )
......@@ -434,9 +433,9 @@ void WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
}
/****************************************/
/*********************************************************/
void WinEDA_PcbFrame::createPopUpBlockMenu( wxMenu* menu )
/****************************************/
/*********************************************************/
/* Create Pop sub menu for block commands
*/
......
......@@ -743,7 +743,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
int localrealbutt = 0, localbutt = 0, localkey = 0;
BASE_SCREEN* screen = GetScreen();
static WinEDA_DrawPanel* LastPanel;
static bool LastClickIsADoubleClick = false;
static bool IgnoreNextLeftButtonRelease = false;
if( event.Leaving() || event.Entering() )
{
......@@ -846,14 +846,14 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
if( localbutt == (int) (GR_M_LEFT_DOWN | GR_M_DCLICK) )
{
m_Parent->OnLeftDClick( &DC, screen->m_MousePositionInPixels );
LastClickIsADoubleClick = true;
IgnoreNextLeftButtonRelease = true;
}
else if( event.LeftUp() && screen->BlockLocate.m_State==STATE_NO_BLOCK )
if ( ! LastClickIsADoubleClick )
if ( ! IgnoreNextLeftButtonRelease )
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) )
{
......@@ -878,7 +878,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
m_CanStartBlock = -1;
// 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
if( !event.LeftIsDown() && !event.MiddleIsDown() )
{
......@@ -900,6 +900,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
{
m_AutoPAN_Request = FALSE;
m_Parent->HandleBlockPlace( &DC );
IgnoreNextLeftButtonRelease = true;
}
}
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