Commit 81509a11 authored by jean-pierre charras's avatar jean-pierre charras

Gerbview: code cleanup and a minoe enhancement. Kicad: minor code cleanup

parents c4948a6c cb8a0315
......@@ -278,6 +278,37 @@ void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event )
#endif
}
/*
* Function OnSelectPreferredEditor
* Open a dialog to select the preferred editor that will be used in Kicad
* to edit or display files (reports ... )
* The full filename editor is saved in configuration (global params)
*/
void EDA_BASE_FRAME::OnSelectPreferredEditor( wxCommandEvent& event )
{
wxFileName fn = wxGetApp().m_EditorName;
wxString wildcard( wxT( "*" ) );
#ifdef __WINDOWS__
wildcard += wxT( ".exe" );
#endif
wildcard = _( "Executable file (" ) + wildcard + wxT( ")|" ) + wildcard;
wxFileDialog dlg( this, _( "Select Prefered Editor" ), fn.GetPath(),
fn.GetFullName(), wildcard,
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
if( dlg.ShowModal() == wxID_CANCEL )
return;
wxASSERT( wxGetApp().m_EDA_CommonConfig );
wxConfig* cfg = wxGetApp().m_EDA_CommonConfig;
wxGetApp().m_EditorName = dlg.GetPath();
cfg->Write( wxT( "Editor" ), wxGetApp().m_EditorName );
}
/*
*
......
......@@ -6,7 +6,7 @@
#endif
#ifndef KICAD_BUILD_VERSION
#define KICAD_BUILD_VERSION "(2011-03-11 BZR 2884)"
#define KICAD_BUILD_VERSION "(2011-03-12)"
#endif
//#define VERSION_STABILITY "stable"
......
update=01/04/2010 16:21:47
update=12/03/2011 18:54:54
version=1
last_client=eeschema
last_client=pcbnew
[cvpcb]
version=1
NetITyp=0
......@@ -11,72 +11,6 @@ LibDir=
NetType=0
[cvpcb/libraries]
EquName1=devcms
[pcbnew]
version=1
PadDrlX=320
PadDimH=600
PadDimV=600
PadForm=1
PadMask=14745599
ViaDiam=450
ViaDril=250
Isol=60
Countlayer=2
Lpiste=170
RouteTo=15
RouteBo=0
TypeVia=3
Segm45=1
Racc45=1
Unite=0
SegFill=1
SegAffG=0
NewAffG=1
PadFill=1
PadAffG=1
PadSNum=1
ModAffC=0
ModAffT=0
PcbAffT=0
SgPcb45=1
TxtPcbV=800
TxtPcbH=600
TxtModV=600
TxtModH=600
TxtModW=120
HPGLnum=1
HPGdiam=15
HPGLSpd=20
HPGLrec=2
HPGLorg=0
GERBmin=15
VEgarde=100
DrawLar=150
EdgeLar=150
TxtLar=120
MSegLar=150
ForPlot=1
WpenSer=10
UserGrX=0,01
UserGrY=0,01
UserGrU=1
DivGrPc=1
TimeOut=600
MaxLnkS=3
ShowRat=0
ShowMRa=1
[pcbnew/libraries]
LibDir=
LibName1=sockets
LibName2=connect
LibName3=discret
LibName4=pin_array
LibName5=divers
LibName6=libcms
LibName7=display
LibName8=valves
LibName9=led
LibName10=dip_sockets
[general]
version=1
[eeschema]
......@@ -123,3 +57,32 @@ LibName5=linear
LibName6=regul
LibName7=interface
LibName8=special
[pcbnew]
version=1
PadDrlX=320
PadDimH=600
PadDimV=600
BoardThickness=630
TxtPcbV=800
TxtPcbH=600
TxtModV=600
TxtModH=600
TxtModW=120
VEgarde=100
DrawLar=150
EdgeLar=150
TxtLar=120
MSegLar=150
LastNetListRead=
[pcbnew/libraries]
LibDir=
LibName1=sockets
LibName2=connect
LibName3=discret
LibName4=pin_array
LibName5=divers
LibName6=libcms
LibName7=display
LibName8=valves
LibName9=led
LibName10=dip_sockets
......@@ -13,6 +13,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
###
# Sources
###
set(DIALOGS_SRCS
dialogs/gerbview_dialog_display_options_frame_base.cpp
dialogs/gerbview_dialog_display_options_frame.cpp
......@@ -35,9 +36,9 @@ set(GERBVIEW_SRCS
edit.cpp
export_to_pcbnew.cpp
files.cpp
gerberframe.cpp
gerbview_config.cpp
gerbview.cpp
gerbview_config.cpp
gerbview_frame.cpp
hotkeys.cpp
initpcb.cpp
locate.cpp
......@@ -50,7 +51,8 @@ set(GERBVIEW_SRCS
rs274d.cpp
rs274x.cpp
select_layers_to_pcb.cpp
toolbars_gerber.cpp )
toolbars_gerber.cpp
)
###
# We need some extra sources from pcbnew
......
/**********************************************************/
/* Block operations: displacement, rotation, deletion ... */
/**********************************************************/
/**********************************/
/* Block operations: displacement */
/**********************************/
/*
* This program source code file is part of KICAD, a free EDA CAD application.
......@@ -28,15 +28,14 @@
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "class_drawpanel.h"
#include "trigo.h"
#include "confirm.h"
#include "gerbview.h"
#include "class_gerber_draw_item.h"
#include "wx/debug.h"
#define BLOCK_COLOR BROWN
......@@ -46,6 +45,7 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
/* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to
* the key (ALT, SHIFT ALT ..)
* Currently, only block move and block zoom is supported
*/
int GERBVIEW_FRAME::ReturnBlockCommand( int key )
{
......@@ -62,17 +62,9 @@ int GERBVIEW_FRAME::ReturnBlockCommand( int key )
break;
case GR_KB_SHIFT:
break;
case GR_KB_CTRL:
break;
case GR_KB_SHIFTCTRL:
cmd = BLOCK_DELETE;
break;
case GR_KB_ALT:
cmd = BLOCK_COPY;
break;
case MOUSE_MIDDLE:
......@@ -87,25 +79,13 @@ int GERBVIEW_FRAME::ReturnBlockCommand( int key )
/* Routine to handle the BLOCK PLACE command */
void GERBVIEW_FRAME::HandleBlockPlace( wxDC* DC )
{
bool err = false;
wxASSERT( DrawPanel->IsMouseCaptured() );
if( !DrawPanel->IsMouseCaptured() )
{
err = true;
DisplayError( this,
wxT( "Error in HandleBlockPLace : m_mouseCaptureCallback = NULL" ) );
}
GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP;
switch( GetScreen()->m_BlockLocate.m_Command )
{
case BLOCK_IDLE:
err = true;
break;
case BLOCK_DRAG: /* Drag */
case BLOCK_MOVE: /* Move */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
if( DrawPanel->IsMouseCaptured() )
DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false );
......@@ -122,9 +102,9 @@ void GERBVIEW_FRAME::HandleBlockPlace( wxDC* DC )
break;
case BLOCK_PASTE:
break;
case BLOCK_ZOOM: // Handle by HandleBlockEnd()
case BLOCK_DRAG:
case BLOCK_PRESELECT_MOVE:
case BLOCK_ZOOM:
case BLOCK_ROTATE:
case BLOCK_FLIP:
case BLOCK_DELETE:
......@@ -133,6 +113,8 @@ void GERBVIEW_FRAME::HandleBlockPlace( wxDC* DC )
case BLOCK_SELECT_ITEMS_ONLY:
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y:
case BLOCK_IDLE:
wxFAIL_MSG( wxT("HandleBlockPlace: Unexpected block command") );
break;
}
......@@ -142,11 +124,7 @@ void GERBVIEW_FRAME::HandleBlockPlace( wxDC* DC )
GetScreen()->SetModify();
GetScreen()->ClearBlockCommand();
if( GetScreen()->m_BlockLocate.GetCount() )
{
DisplayError( this, wxT( "HandleBlockPLace error: some items left" ) );
GetScreen()->m_BlockLocate.ClearItemsList();
}
wxASSERT( GetScreen()->m_BlockLocate.GetCount() == 0 );
DisplayToolMsg( wxEmptyString );
}
......@@ -171,15 +149,8 @@ bool GERBVIEW_FRAME::HandleBlockEnd( wxDC* DC )
switch( GetScreen()->m_BlockLocate.m_Command )
{
case BLOCK_IDLE:
DisplayError( this, wxT( "Error in HandleBlockPLace" ) );
break;
case BLOCK_DRAG: /* Drag (not used, for future
* enhancements) */
case BLOCK_MOVE: /* Move */
case BLOCK_COPY: /* Copy */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list */
GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE;
nextcmd = true;
DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false );
......@@ -193,20 +164,22 @@ bool GERBVIEW_FRAME::HandleBlockEnd( wxDC* DC )
Block_Delete( DC );
break;
case BLOCK_ZOOM: /* Window Zoom */
zoom_command = true;
break;
case BLOCK_PRESELECT_MOVE: /* Move with preselection list */
case BLOCK_DRAG:
case BLOCK_IDLE:
case BLOCK_MIRROR_X: /* Mirror, unused*/
case BLOCK_ROTATE: /* Unused */
case BLOCK_FLIP: /* Flip, unused */
case BLOCK_SAVE: /* Save (not used)*/
case BLOCK_PASTE:
break;
case BLOCK_ZOOM: /* Window Zoom */
zoom_command = true;
break;
case BLOCK_ABORT:
case BLOCK_SELECT_ITEMS_ONLY:
case BLOCK_MIRROR_Y:
wxFAIL_MSG( wxT("HandleBlockEnd: Unexpected block command") );
break;
}
......
......@@ -33,7 +33,6 @@
#include "class_drawpanel.h"
#include "pcbstruct.h"
#include "gerbview.h"
#include "wxGerberFrame.h"
#include "layer_widget.h"
#include "class_gerbview_layer_widget.h"
......
......@@ -137,17 +137,17 @@ int D_CODE::GetShapeDim( GERBER_DRAW_ITEM* aParent )
/*
* Function Read_D_Code_File
* Function ReadDCodeDefinitionFile
* Can be useful only with old RS274D Gerber file format.
* Is not needed with RS274X files format.
* These files need an auxiliary DCode file description. There is no defined file format for this.
* This function read a file format I needed a long time ago.
* reads in a dcode file assuming ALSPCB file format with ';' indicating comments.
* Format is like CSV but with optional ';' delineated comments:
* tool, Horiz, Vert, drill, vitesse, acc. ,Type ; [DCODE (commentaire)]
* tool, Horiz, Vert, drill, speed, accel. ,Type ; [DCODE (commentaire)]
* ex: 1, 12, 12, 0, 0, 0, 3 ; D10
*/
int GERBVIEW_FRAME::Read_D_Code_File( const wxString& D_Code_FullFileName )
int GERBVIEW_FRAME::ReadDCodeDefinitionFile( const wxString& D_Code_FullFileName )
{
int current_Dcode, ii, dcode_scale;
char* ptcar;
......
......@@ -15,7 +15,6 @@
#include "printout_controler.h"
#include "gerbview.h"
#include "wxGerberFrame.h"
#include "pcbplot.h"
#include "class_board_design_settings.h"
......
......@@ -118,11 +118,11 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
switch( id )
{
case ID_EXIT:
Close( TRUE );
Close( true );
break;
case ID_GERBVIEW_GLOBAL_DELETE:
Erase_Current_Layer( TRUE );
Erase_Current_Layer( true );
ClearMsgPanel();
break;
......@@ -171,6 +171,10 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
wxFileName fn( gerber_layer->m_FileName );
ExecuteFile( this, editorname, QuoteFullPath( fn ) );
}
else
{
wxMessageBox(_("No editor defined. Please select one") );
}
}
break;
......
......@@ -10,9 +10,6 @@
#include "gerbview.h"
static void LoadDCodeFile( GERBVIEW_FRAME* frame,
const wxString& FullFileName );
/* Load a Gerber file selected from history list on current layer
* Previous data is deleted
......@@ -79,11 +76,12 @@ clear an existing layer to load any new layers." ), NB_LAYERS );
break;
case ID_GERBVIEW_LOAD_DCODE_FILE:
LoadDCodeFile( this, wxEmptyString );
LoadDCodeFile( wxEmptyString );
DrawPanel->Refresh();
break;
default:
DisplayError( this, wxT( "File_io Internal Error" ) );
wxFAIL_MSG( wxT( "File_io: unexpected command id" ) );
break;
}
}
......@@ -199,33 +197,33 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName )
/*
* Read a DCode file (not used with RX274X files , just with RS274D old files).
* Note: there is no standard for DCode file.
* Note: there is no standard for DCode files.
* Just read a file format created by early versions of Pcbnew.
* Returns:
* 0 if file not read (cancellation of order ...)
* 1 if OK
* false if file not read (cancellation of order ...)
* true if OK
*/
static void LoadDCodeFile( GERBVIEW_FRAME* frame, const wxString& FullFileName )
bool GERBVIEW_FRAME::LoadDCodeFile( const wxString& aFullFileName )
{
wxString wildcard;
wxFileName fn = FullFileName;
wxFileName fn = aFullFileName;
if( !fn.IsOk() )
{
wildcard = _( "Gerber DCODE files" );
wildcard += AllFilesWildcard;
fn = frame->GetScreen()->GetFileName();
wxFileDialog dlg( (wxWindow*) frame, _( "Load GERBER DCODE File" ),
wildcard += wxT(" ") + AllFilesWildcard;
fn = GetScreen()->GetFileName();
wxFileDialog dlg( this, _( "Load GERBER DCODE File" ),
fn.GetPath(), fn.GetFullName(), wildcard,
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
if( dlg.ShowModal() == wxID_CANCEL )
return;
return false;
fn = dlg.GetPath();
}
frame->Read_D_Code_File( fn.GetFullPath() );
frame->CopyDCodesSizeToItems();
frame->Refresh();
ReadDCodeDefinitionFile( fn.GetFullPath() );
CopyDCodesSizeToItems();
return true;
}
......@@ -11,7 +11,6 @@
#include "gerbview.h"
#include "gerbview_id.h"
#include "wxGerberFrame.h"
#include "pcbplot.h"
#include "bitmaps.h"
#include "zones.h"
......
......@@ -108,6 +108,6 @@ bool GetEndOfBlock( char buff[GERBER_BUFZ], char*& text, FILE* gerber_file );
extern GERBER_IMAGE* g_GERBER_List[32];
#include "pcbcommon.h"
#include "wxGerberFrame.h"
#include "gerbview_frame.h"
#endif // ifndef GERBVIEW_H
......@@ -64,6 +64,8 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, PCB_BASE_FRAME )
EVT_MENU( ID_GERBVIEW_SHOW_LIST_DCODES, GERBVIEW_FRAME::Process_Special_Functions )
EVT_MENU( ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS, GERBVIEW_FRAME::Process_Special_Functions )
EVT_MENU( ID_GERBVIEW_SHOW_SOURCE, GERBVIEW_FRAME::Process_Special_Functions )
EVT_MENU( ID_MENU_GERBVIEW_SELECT_PREFERED_EDITOR,
EDA_BASE_FRAME::OnSelectPreferredEditor )
// menu Miscellaneous
EVT_MENU( ID_GERBVIEW_GLOBAL_DELETE, GERBVIEW_FRAME::Process_Special_Functions )
......
......@@ -406,7 +406,18 @@ public: GERBVIEW_FRAME( wxWindow* father, const wxString& title,
void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 );
/**
* Function Read_D_Code_File
* Read a DCode file (not used with RX274X files , just with RS274D old files).
* Note: there is no standard for DCode file.
* Just read a file format created by early versions of Pcbnew.
* @return false if file not read (cancellation)
* true if OK
* @ aparm aFullFileName = name of file to load.
* if empty, or if the file does not exist, a file dialog is opened
*/
bool LoadDCodeFile( const wxString& aFullFileName );
/**
* Function ReadDCodeDefinitionFile
* reads in a dcode file assuming ALSPCB file format with ';' indicating
* comments.
* <p>
......@@ -418,7 +429,7 @@ public: GERBVIEW_FRAME( wxWindow* father, const wxString& title,
* Ver, Hor, Type, Tool [,Drill]<br>
* example: 0.012, 0.012, L , D10<br>
*
* Categorize all found dcodes into a table of D_CODE instantiations.
* Load all found dcodes into a table of D_CODE instantiations.
* @param D_Code_FullFileName The name of the file to read from.
* @return int - <br>
* -1 = file not found<br>
......@@ -428,7 +439,7 @@ public: GERBVIEW_FRAME( wxWindow* father, const wxString& title,
* g_GERBER_List[]<br>
* 1 = read OK<br>
*/
int Read_D_Code_File( const wxString& D_Code_FullFileName );
int ReadDCodeDefinitionFile( const wxString& D_Code_FullFileName );
void CopyDCodesSizeToItems();
void Liste_D_Codes();
......
......@@ -16,6 +16,7 @@ enum gerbview_ids
ID_MAIN_MENUBAR = ID_END_LIST,
ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
ID_MENU_GERBVIEW_SELECT_PREFERED_EDITOR,
ID_TOOLBARH_GERBVIEW_SELECT_LAYER,
ID_GERBVIEW_GLOBAL_DELETE,
......
......@@ -6,7 +6,7 @@
#include "appl_wxstruct.h"
#include "common.h"
#include "macros.h"
//#include "macros.h"
#include "gerbview.h"
#include "bitmaps.h"
#include "gerbview_id.h"
......@@ -91,6 +91,13 @@ void GERBVIEW_FRAME::ReCreateMenuBar( void )
_( "&Clear Layer" ),
_( "Clear current layer" ), general_deletions_xpm );
miscellaneous_menu->AppendSeparator();
ADD_MENUITEM_WITH_HELP( miscellaneous_menu, ID_MENU_GERBVIEW_SELECT_PREFERED_EDITOR,
_( "&Text Editor" ),
_( "Select your preferred text editor" ),
editor_xpm );
// Menu Help:
wxMenu* helpMenu = new wxMenu;
AddHelpVersionInfoMenuEntry( helpMenu );
......
......@@ -88,3 +88,4 @@ void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
break;
}
}
......@@ -165,31 +165,7 @@ bool GERBVIEW_FRAME::Read_GERBER_File( const wxString& GERBER_FullFileName,
*/
if( !gerber->m_Has_DCode )
{
wxFileName fn;
if( D_Code_FullFileName.IsEmpty() )
{
wxString wildcard;
fn = GERBER_FullFileName;
fn.SetExt( wxEmptyString );
wildcard = _( "Gerber DCODE files" );
wildcard += AllFilesWildcard;
wxFileDialog dlg( this, _( "Load GERBER DCODE File" ),
wxEmptyString, fn.GetFullName(), wildcard,
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
}
else
fn = D_Code_FullFileName;
if( fn.IsOk() )
{
Read_D_Code_File( fn.GetFullPath() );
CopyDCodesSizeToItems();
}
else
return false;
return LoadDCodeFile( D_Code_FullFileName );
}
return true;
......
......@@ -127,6 +127,14 @@ public:
virtual void LoadSettings();
virtual void SaveSettings();
/**
* Function OnSelectPreferredEditor
* Open a dialog to select the editor that will used in Kicad
* to edit or display files (reports ... )
* The full filename editor is saved in configuration (global params)
*/
virtual void OnSelectPreferredEditor( wxCommandEvent& event );
// Read/Save and Import/export hotkeys config
/**
......
......@@ -109,7 +109,6 @@ public:
void OnRefresh( wxCommandEvent& event );
void OnSelectDefaultPdfBrowser( wxCommandEvent& event );
void OnSelectPreferredPdfBrowser( wxCommandEvent& event );
void OnSelectPreferredEditor( wxCommandEvent& event );
void OnUpdateDefaultPdfBrowser( wxUpdateUIEvent& event );
void OnUpdatePreferredPdfBrowser( wxUpdateUIEvent& event );
......
This diff is collapsed.
......@@ -69,33 +69,6 @@ void WinEDA_MainFrame::OnSelectPreferredPdfBrowser( wxCommandEvent& event )
wxGetApp().WritePdfBrowserInfos();
}
void WinEDA_MainFrame::OnSelectPreferredEditor( wxCommandEvent& event )
{
wxFileName fn = wxGetApp().m_EditorName;
wxString wildcard( wxT( "*" ) );
#ifdef __WINDOWS__
wildcard += wxT( ".exe" );
#endif
wildcard = _( "Executable file (" ) + wildcard + wxT( ")|" ) + wildcard;
wxFileDialog dlg( this, _( "Select Prefered Editor" ), fn.GetPath(),
fn.GetFullName(), wildcard,
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
if( dlg.ShowModal() == wxID_CANCEL )
return;
wxASSERT( wxGetApp().m_EDA_CommonConfig );
wxConfig* cfg = wxGetApp().m_EDA_CommonConfig;
wxGetApp().m_EditorName = dlg.GetPath();
cfg->Write( wxT( "Editor" ), wxGetApp().m_EditorName );
}
void WinEDA_MainFrame::SetLanguage( wxCommandEvent& event )
{
EDA_BASE_FRAME::SetLanguage( event );
......
......@@ -17,7 +17,7 @@
; General Product Description Definitions
!define PRODUCT_NAME "KiCad"
!define PRODUCT_VERSION "2011.03.11"
!define PRODUCT_VERSION "2011.03.12"
!define PRODUCT_WEB_SITE "http://iut-tice.ujf-grenoble.fr/kicad/"
!define SOURCEFORGE_WEB_SITE "http://kicad.sourceforge.net/"
!define COMPANY_NAME ""
......
release version:
2011 mar 11
2011 mar 12
files (.zip,.tgz):
kicad-2011-03-11
kicad-2011-03-12
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