Fix load gerber file path bug, fixes lp:712104.
This commit is contained in:
parent
85b8fc66ee
commit
bd99012ad0
|
@ -39,19 +39,19 @@ void WinEDA_GerberFrame::Files_io( wxCommandEvent& event )
|
|||
switch( id )
|
||||
{
|
||||
case wxID_FILE:
|
||||
{
|
||||
Erase_Current_Layer( false );
|
||||
LoadGerberFiles( wxEmptyString );
|
||||
break;
|
||||
}
|
||||
|
||||
case ID_MENU_INC_LAYER_AND_APPEND_FILE:
|
||||
case ID_INC_LAYER_AND_APPEND_FILE:
|
||||
{
|
||||
int origLayer = getActiveLayer();
|
||||
if( origLayer < NB_LAYERS )
|
||||
int origLayer = getNextAvailableLayer();
|
||||
|
||||
if( origLayer != NO_AVAILABLE_LAYERS )
|
||||
{
|
||||
setActiveLayer(origLayer+1);
|
||||
setActiveLayer( origLayer );
|
||||
|
||||
Erase_Current_Layer( false );
|
||||
|
||||
if( !LoadGerberFiles( wxEmptyString ) )
|
||||
|
@ -61,7 +61,7 @@ void WinEDA_GerberFrame::Files_io( wxCommandEvent& event )
|
|||
{
|
||||
wxString msg;
|
||||
msg.Printf( _( "GerbView only supports a maximum of %d layers. You must first \
|
||||
delete an existing layer to load any new layers." ), NB_LAYERS );
|
||||
clear an existing layer to load any new layers." ), NB_LAYERS );
|
||||
wxMessageBox( msg );
|
||||
}
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ bool WinEDA_GerberFrame::LoadGerberFiles( const wxString& aFullFileName )
|
|||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
return false;
|
||||
|
||||
dlg.GetFilenames( filenamesList );
|
||||
dlg.GetPaths( filenamesList );
|
||||
currentPath = wxGetCwd();
|
||||
}
|
||||
else
|
||||
|
@ -160,18 +160,32 @@ bool WinEDA_GerberFrame::LoadGerberFiles( const wxString& aFullFileName )
|
|||
for( unsigned ii = 0; ii < filenamesList.GetCount(); ii++ )
|
||||
{
|
||||
wxFileName filename = filenamesList[ii];
|
||||
|
||||
if( !filename.IsAbsolute() )
|
||||
filename.SetPath( currentPath );
|
||||
GetScreen()->SetFileName( filename.GetFullPath() );
|
||||
|
||||
if( !filename.HasExt() )
|
||||
filename.SetExt( g_PenFilenameExt );
|
||||
|
||||
GetScreen()->SetFileName( filename.GetFullPath() );
|
||||
|
||||
setActiveLayer( layer, false );
|
||||
|
||||
if( Read_GERBER_File( GetScreen()->GetFileName(), filename.GetFullPath() ) )
|
||||
if( Read_GERBER_File( filename.GetFullPath(), filename.GetFullPath() ) )
|
||||
{
|
||||
SetLastProject( GetScreen()->GetFileName() );
|
||||
layer++;
|
||||
if( layer >= NB_LAYERS )
|
||||
layer = 0;
|
||||
|
||||
layer = getNextAvailableLayer( layer );
|
||||
|
||||
if( layer == NO_AVAILABLE_LAYERS )
|
||||
{
|
||||
wxString msg = wxT( "No more empty layers are available. The remaining gerber " );
|
||||
msg += wxT( "files will not be loaded." );
|
||||
wxMessageBox( msg );
|
||||
break;
|
||||
}
|
||||
|
||||
setActiveLayer( layer, false );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -404,6 +404,27 @@ void WinEDA_GerberFrame::SetElementVisibility( int aGERBER_VISIBLE, bool aNewSta
|
|||
}
|
||||
|
||||
|
||||
int WinEDA_GerberFrame::getNextAvailableLayer( int aLayer ) const
|
||||
{
|
||||
int layer = aLayer;
|
||||
|
||||
for( int i = 0; i < NB_LAYERS; i++ )
|
||||
{
|
||||
GERBER_IMAGE* gerber = g_GERBER_List[ layer ];
|
||||
|
||||
if( gerber == NULL || gerber->m_FileName.IsEmpty() )
|
||||
return layer;
|
||||
|
||||
layer++;
|
||||
|
||||
if( layer >= NB_LAYERS )
|
||||
layer = 0;
|
||||
}
|
||||
|
||||
return NO_AVAILABLE_LAYERS;
|
||||
}
|
||||
|
||||
|
||||
void WinEDA_GerberFrame::syncLayerWidget()
|
||||
{
|
||||
m_LayersManager->SelectLayer( getActiveLayer() );
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
#include "class_gerbview_layer_widget.h"
|
||||
#include "class_layerchoicebox.h"
|
||||
|
||||
|
||||
#define NO_AVAILABLE_LAYERS -1
|
||||
|
||||
|
||||
/**
|
||||
* Command IDs for the gerber file viewer.
|
||||
*
|
||||
|
@ -33,6 +37,7 @@ enum id_gerbview_frm {
|
|||
|
||||
class DCODE_SELECTION_BOX;
|
||||
|
||||
|
||||
/******************************************************************
|
||||
* class WinEDA_GerberFrame: this is the main window used in gerbview
|
||||
******************************************************************/
|
||||
|
@ -53,16 +58,17 @@ public:
|
|||
|
||||
private:
|
||||
int m_displayMode; // Gerber images ("layers" in Gerbview) can be drawn:
|
||||
// - in fast mode (write mode) but if there are negative items
|
||||
// only the last image is correctly drawn
|
||||
// (no problem to see only one image or when no negative items)
|
||||
// - in fast mode (write mode) but if there are negative
|
||||
// items only the last image is correctly drawn (no
|
||||
// problem to see only one image or when no negative items)
|
||||
// - in "exact" mode (but slower) in write mode:
|
||||
// last image covers previous images
|
||||
// - in "exact" mode (also slower) in OR mode
|
||||
// (transparency mode)
|
||||
// m_displayMode = 0, 1 or 2
|
||||
bool m_show_layer_manager_tools;
|
||||
wxArrayString m_Messages; // An array sting to store warning messages when reaging a gerber file
|
||||
wxArrayString m_Messages; // An array sting to store warning messages when reaging
|
||||
// a gerber file
|
||||
|
||||
public: WinEDA_GerberFrame( wxWindow* father, const wxString& title,
|
||||
const wxPoint& pos, const wxSize& size,
|
||||
|
@ -198,6 +204,17 @@ public: WinEDA_GerberFrame( wxWindow* father, const wxString& title,
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function getNextAvailableLayer
|
||||
* finds the next empty layer starting at \a aLayer and returns it to the caller. If no
|
||||
* empty layers are found, NO_AVAILABLE_LAYERS is return.
|
||||
* @param aLayer The first layer to search.
|
||||
* @return The first empty layer found or NO_AVAILABLE_LAYERS.
|
||||
*/
|
||||
int getNextAvailableLayer( int aLayer = 0 ) const;
|
||||
|
||||
bool hasAvailableLayers() const { return getNextAvailableLayer() != NO_AVAILABLE_LAYERS; }
|
||||
|
||||
/**
|
||||
* Function syncLayerWidget
|
||||
* updates the currently "selected" layer within the PCB_LAYER_WIDGET.
|
||||
|
@ -350,15 +367,12 @@ public: WinEDA_GerberFrame( wxWindow* father, const wxString& title,
|
|||
void Genere_HPGL( const wxString& FullFileName, int Layers );
|
||||
void Genere_GERBER( const wxString& FullFileName, int Layers );
|
||||
void Genere_PS( const wxString& FullFileName, int Layers );
|
||||
void Plot_Layer_HPGL( FILE* File, int masque_layer,
|
||||
int garde, bool trace_via,
|
||||
void Plot_Layer_HPGL( FILE* File, int masque_layer,int garde, bool trace_via,
|
||||
GRTraceMode trace_mode );
|
||||
void Plot_Layer_GERBER( FILE* File, int masque_layer,
|
||||
int garde, bool trace_via,
|
||||
void Plot_Layer_GERBER( FILE* File, int masque_layer, int garde, bool trace_via,
|
||||
GRTraceMode trace_mode );
|
||||
int Gen_D_CODE_File( const wxString& Name_File );
|
||||
void Plot_Layer_PS( FILE* File, int masque_layer,
|
||||
int garde, bool trace_via,
|
||||
void Plot_Layer_PS( FILE* File, int masque_layer, int garde, bool trace_via,
|
||||
GRTraceMode trace_mode );
|
||||
|
||||
void Files_io( wxCommandEvent& event );
|
||||
|
@ -367,8 +381,8 @@ public: WinEDA_GerberFrame( wxWindow* father, const wxString& title,
|
|||
/**
|
||||
* function LoadGerberFiles
|
||||
* Load a photoplot (Gerber) file or many files.
|
||||
* @param aFileName - void string or file name with full path to open or empty string to open a new
|
||||
* file. In this case one one file is loaded
|
||||
* @param aFileName - void string or file name with full path to open or empty string to
|
||||
* open a new file. In this case one one file is loaded
|
||||
* if void string: user will be prompted for filename(s)
|
||||
* @return true if file was opened successfully.
|
||||
*/
|
||||
|
@ -418,8 +432,7 @@ public: WinEDA_GerberFrame( wxWindow* father, const wxString& title,
|
|||
* currently: do nothing in gerbview.
|
||||
* but must be defined because it is a pure virtual in PCB_BASE_FRAME
|
||||
*/
|
||||
virtual void SaveCopyInUndoList(
|
||||
BOARD_ITEM* aItemToCopy,
|
||||
virtual void SaveCopyInUndoList( BOARD_ITEM* aItemToCopy,
|
||||
UndoRedoOpType aTypeCommand = UR_UNSPECIFIED,
|
||||
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) { }
|
||||
|
||||
|
@ -432,15 +445,13 @@ public: WinEDA_GerberFrame( wxWindow* father, const wxString& title,
|
|||
* @param aTransformPoint = the reference point of the transformation,
|
||||
* for commands like move
|
||||
*/
|
||||
virtual void SaveCopyInUndoList(
|
||||
PICKED_ITEMS_LIST& aItemsList,
|
||||
virtual void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
|
||||
UndoRedoOpType aTypeCommand,
|
||||
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) )
|
||||
{
|
||||
// currently: do nothing in gerbview.
|
||||
}
|
||||
|
||||
|
||||
/** Virtual function PrintPage
|
||||
* used to print a page
|
||||
* @param aDC = wxDC given by the calling print function
|
||||
|
@ -448,8 +459,7 @@ public: WinEDA_GerberFrame( wxWindow* father, const wxString& title,
|
|||
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
|
||||
* @param aData = a pointer on an auxiliary data (not always used, NULL if not used)
|
||||
*/
|
||||
virtual void PrintPage( wxDC* aDC,
|
||||
int aPrintMasklayer, bool aPrintMirrorMode,
|
||||
virtual void PrintPage( wxDC* aDC, int aPrintMasklayer, bool aPrintMirrorMode,
|
||||
void* aData = NULL );
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue