mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-15 10:43:15 +02:00
Gerbview: fix a crash when reading polygons with arcs.
Fix a very minor other issue (due to a minor bug in wx 3.1) Displays the full graphic layer name of the selected item in message panel (instead of just the graphic layer number)
This commit is contained in:
parent
cd976d36b7
commit
c8cf78398b
@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
#include <class_gerber_draw_item.h>
|
#include <class_gerber_draw_item.h>
|
||||||
#include <class_gerber_file_image.h>
|
#include <class_gerber_file_image.h>
|
||||||
|
#include <class_gerber_file_image_list.h>
|
||||||
|
|
||||||
|
|
||||||
GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( GERBER_FILE_IMAGE* aGerberImageFile ) :
|
GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( GERBER_FILE_IMAGE* aGerberImageFile ) :
|
||||||
@ -52,6 +53,7 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( GERBER_FILE_IMAGE* aGerberImageFile ) :
|
|||||||
m_mirrorB = false;
|
m_mirrorB = false;
|
||||||
m_drawScale.x = m_drawScale.y = 1.0;
|
m_drawScale.x = m_drawScale.y = 1.0;
|
||||||
m_lyrRotation = 0;
|
m_lyrRotation = 0;
|
||||||
|
|
||||||
if( m_GerberImageFile )
|
if( m_GerberImageFile )
|
||||||
SetLayerParameters();
|
SetLayerParameters();
|
||||||
}
|
}
|
||||||
@ -437,8 +439,8 @@ void GERBER_DRAW_ITEM::ConvertSegmentToPolygon( )
|
|||||||
|
|
||||||
// Now create the full polygon.
|
// Now create the full polygon.
|
||||||
// Due to previous changes, the shape is always something like
|
// Due to previous changes, the shape is always something like
|
||||||
// 3 4
|
// 3 4
|
||||||
// 2 5
|
// 2 5
|
||||||
// 1 6
|
// 1 6
|
||||||
wxPoint corner;
|
wxPoint corner;
|
||||||
corner.x -= m_Size.x/2;
|
corner.x -= m_Size.x/2;
|
||||||
@ -514,7 +516,7 @@ void GERBER_DRAW_ITEM::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
|
|||||||
aList.push_back( MSG_PANEL_ITEM( msg, text, RED ) );
|
aList.push_back( MSG_PANEL_ITEM( msg, text, RED ) );
|
||||||
|
|
||||||
// Display graphic layer number
|
// Display graphic layer number
|
||||||
msg.Printf( wxT( "%d" ), GetLayer() + 1 );
|
msg = GERBER_FILE_IMAGE_LIST::GetImagesList().GetDisplayName( GetLayer(), true );
|
||||||
aList.push_back( MSG_PANEL_ITEM( _( "Graphic Layer" ), msg, BROWN ) );
|
aList.push_back( MSG_PANEL_ITEM( _( "Graphic Layer" ), msg, BROWN ) );
|
||||||
|
|
||||||
// Display item rotation
|
// Display item rotation
|
||||||
|
@ -120,7 +120,7 @@ void GERBER_FILE_IMAGE_LIST::DeleteImage( int aIdx )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build a name for image aIdx which can be used in layers manager
|
// Build a name for image aIdx which can be used in layers manager
|
||||||
const wxString GERBER_FILE_IMAGE_LIST::GetDisplayName( int aIdx )
|
const wxString GERBER_FILE_IMAGE_LIST::GetDisplayName( int aIdx, bool aNameOnly )
|
||||||
{
|
{
|
||||||
wxString name;
|
wxString name;
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ const wxString GERBER_FILE_IMAGE_LIST::GetDisplayName( int aIdx )
|
|||||||
{
|
{
|
||||||
if( gerber->m_FileFunction->IsCopper() )
|
if( gerber->m_FileFunction->IsCopper() )
|
||||||
{
|
{
|
||||||
name.Printf( "%d %s (%s, %s, %s)", aIdx + 1,
|
name.Printf( "%s (%s, %s, %s)",
|
||||||
filename.GetData(),
|
filename.GetData(),
|
||||||
GetChars( gerber->m_FileFunction->GetFileType() ),
|
GetChars( gerber->m_FileFunction->GetFileType() ),
|
||||||
GetChars( gerber->m_FileFunction->GetBrdLayerId() ),
|
GetChars( gerber->m_FileFunction->GetBrdLayerId() ),
|
||||||
@ -159,14 +159,23 @@ const wxString GERBER_FILE_IMAGE_LIST::GetDisplayName( int aIdx )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
name.Printf( "%d %s (%s, %s)", aIdx + 1,
|
name.Printf( "%s (%s, %s)",
|
||||||
filename.GetData(),
|
filename.GetData(),
|
||||||
GetChars( gerber->m_FileFunction->GetFileType() ),
|
GetChars( gerber->m_FileFunction->GetFileType() ),
|
||||||
GetChars( gerber->m_FileFunction->GetBrdLayerId() ) );
|
GetChars( gerber->m_FileFunction->GetBrdLayerId() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
name.Printf( _( "%d %s" ), aIdx + 1, filename.GetData() );
|
name = filename;
|
||||||
|
|
||||||
|
if( aNameOnly )
|
||||||
|
return name;
|
||||||
|
|
||||||
|
wxString fullname;
|
||||||
|
|
||||||
|
fullname.Printf( "%d ", aIdx + 1 );
|
||||||
|
fullname << name;
|
||||||
|
return fullname;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
name.Printf( _( "Graphic layer %d" ), aIdx + 1 );
|
name.Printf( _( "Graphic layer %d" ), aIdx + 1 );
|
||||||
|
@ -97,7 +97,7 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a name for image aIdx which can be used in layers manager
|
* @return a name for image aIdx which can be used in layers manager
|
||||||
* and layer selector
|
* and layer selector or in the status bar
|
||||||
* if a file is loaded, the name is:
|
* if a file is loaded, the name is:
|
||||||
* "<aIdx+1> <short filename> <X2 FileFunction info> if a X2 FileFunction info is found"
|
* "<aIdx+1> <short filename> <X2 FileFunction info> if a X2 FileFunction info is found"
|
||||||
* or (if no FileFunction info)
|
* or (if no FileFunction info)
|
||||||
@ -105,8 +105,10 @@ public:
|
|||||||
* if no file loaded, the name is:
|
* if no file loaded, the name is:
|
||||||
* "Layer n" with n = aIdx+1
|
* "Layer n" with n = aIdx+1
|
||||||
* @param aIdx = the index ( 0 ... GERBER_DRAWLAYERS_COUNT-1 )
|
* @param aIdx = the index ( 0 ... GERBER_DRAWLAYERS_COUNT-1 )
|
||||||
|
* @param aNameOnly = false (default) to add the layer number (for layers manager)
|
||||||
|
* or true to return only the name without layer name (status bar)
|
||||||
*/
|
*/
|
||||||
const wxString GetDisplayName( int aIdx );
|
const wxString GetDisplayName( int aIdx, bool aNameOnly = false );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sort loaded images by Z order priority, if they have the X2 FileFormat info
|
* Sort loaded images by Z order priority, if they have the X2 FileFormat info
|
||||||
|
@ -111,7 +111,7 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName )
|
|||||||
* Because the first letter is usually g, we accept g* as extension
|
* Because the first letter is usually g, we accept g* as extension
|
||||||
* (Mainly internal copper layers do not have specific extension,
|
* (Mainly internal copper layers do not have specific extension,
|
||||||
* and filenames are like *.g1, *.g2 *.gb1 ...).
|
* and filenames are like *.g1, *.g2 *.gb1 ...).
|
||||||
* Now (2014) Ucamco (the company which manager the Gerber format) encourage
|
* Now (2014) Ucamco (the company which manages the Gerber format) encourages
|
||||||
* use of .gbr only and the Gerber X2 file format.
|
* use of .gbr only and the Gerber X2 file format.
|
||||||
*/
|
*/
|
||||||
filetypes = _( "Gerber files (.g* .lgr .pho)" );
|
filetypes = _( "Gerber files (.g* .lgr .pho)" );
|
||||||
@ -133,17 +133,23 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName )
|
|||||||
filetypes += _( "Top Pad Master (*.GPT)|*.GPT;*.gpt|" );
|
filetypes += _( "Top Pad Master (*.GPT)|*.GPT;*.gpt|" );
|
||||||
filetypes += _( "Bottom Pad Master (*.GPB)|*.GPB;*.gpb|" );
|
filetypes += _( "Bottom Pad Master (*.GPB)|*.GPB;*.gpb|" );
|
||||||
|
|
||||||
/* All filetypes */
|
// All filetypes
|
||||||
filetypes += AllFilesWildcard;
|
filetypes += AllFilesWildcard;
|
||||||
|
|
||||||
/* Use the current working directory if the file name path does not exist. */
|
// Use the current working directory if the file name path does not exist.
|
||||||
if( filename.DirExists() )
|
if( filename.DirExists() )
|
||||||
currentPath = filename.GetPath();
|
currentPath = filename.GetPath();
|
||||||
else
|
else
|
||||||
|
{
|
||||||
currentPath = m_mruPath;
|
currentPath = m_mruPath;
|
||||||
|
|
||||||
wxFileDialog dlg( this,
|
// On wxWidgets 3.1 (bug?) the path in wxFileDialog is ignored when
|
||||||
_( "Open Gerber File" ),
|
// finishing by the dir separator. Remove it if any:
|
||||||
|
if( currentPath.EndsWith( '\\' ) || currentPath.EndsWith( '/' ) )
|
||||||
|
currentPath.RemoveLast();
|
||||||
|
}
|
||||||
|
|
||||||
|
wxFileDialog dlg( this, _( "Open Gerber File" ),
|
||||||
currentPath,
|
currentPath,
|
||||||
filename.GetFullName(),
|
filename.GetFullName(),
|
||||||
filetypes,
|
filetypes,
|
||||||
|
@ -221,7 +221,8 @@ static void fillArcGBRITEM( GERBER_DRAW_ITEM* aGbrItem, int Dcode_index,
|
|||||||
aGbrItem->m_Size = aPenSize;
|
aGbrItem->m_Size = aPenSize;
|
||||||
aGbrItem->m_Flashed = false;
|
aGbrItem->m_Flashed = false;
|
||||||
|
|
||||||
aGbrItem->SetNetAttributes( aGbrItem->m_GerberImageFile->m_NetAttributeDict );
|
if( aGbrItem->m_GerberImageFile )
|
||||||
|
aGbrItem->SetNetAttributes( aGbrItem->m_GerberImageFile->m_NetAttributeDict );
|
||||||
|
|
||||||
if( aMultiquadrant )
|
if( aMultiquadrant )
|
||||||
center = aStart + aRelCenter;
|
center = aStart + aRelCenter;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user