Gerbview: enhancements.

This commit is contained in:
jean-pierre charras 2010-10-17 18:42:06 +02:00
parent de37bbad17
commit bfeaeafe50
10 changed files with 62 additions and 43 deletions

View File

@ -159,8 +159,8 @@ void GERBER_IMAGE::ResetDefaultValues()
// true = relative Coord // true = relative Coord
m_NoTrailingZeros = false; // true: trailing zeros deleted m_NoTrailingZeros = false; // true: trailing zeros deleted
m_ImageOffset.x = m_ImageOffset.y = 0; // Coord Offset, from IO command m_ImageOffset.x = m_ImageOffset.y = 0; // Coord Offset, from IO command
m_ImageRotation = 0; // Allowed 0, 900, 1800, 2700 (in 0.1 degree m_ImageRotation = 0; // Allowed 0, 90, 180, 270 (in degree)
m_LocalRotation = 0; // Layer totation from RO command (in 0.1 degree) m_LocalRotation = 0.0; // Layer totation from RO command (in 0.1 degree)
m_Offset.x = 0; m_Offset.x = 0;
m_Offset.y = 0; // Coord Offset, from OF command m_Offset.y = 0; // Coord Offset, from OF command
m_Scale.x = m_Scale.y = 1.0; // scale (A and B) this layer m_Scale.x = m_Scale.y = 1.0; // scale (A and B) this layer
@ -276,10 +276,12 @@ void GERBER_IMAGE::StepAndRepeatItem( const GERBER_DRAW_ITEM& aItem )
} }
/** Function DisplayInfo /** Function DisplayImageInfo
* has knowledge about the frame and how and where to put status information * has knowledge about the frame and how and where to put status information
* about this object into the frame's message panel. * about this object into the frame's message panel.
* Display info about Image Parameters. * Display info about Image Parameters.
* These parameters are valid for the entire file, and must set only once
* (If more than once, only the last value is used)
*/ */
void GERBER_IMAGE::DisplayImageInfo( void ) void GERBER_IMAGE::DisplayImageInfo( void )
{ {
@ -287,20 +289,23 @@ void GERBER_IMAGE::DisplayImageInfo( void )
m_Parent->ClearMsgPanel(); m_Parent->ClearMsgPanel();
// Display Image name // Display Image name (Image specific)
m_Parent->AppendMsgPanel( _( "Image name" ), m_ImageName, BROWN ); m_Parent->AppendMsgPanel( _( "Image name" ), m_ImageName, CYAN );
// Display graphic layer number // Display graphic layer number used to draw this Image
// (not a Gerber parameter but is also image specific)
msg.Printf( wxT( "%d" ), m_GraphicLayer + 1 ); msg.Printf( wxT( "%d" ), m_GraphicLayer + 1 );
m_Parent->AppendMsgPanel( _( "Graphic layer" ), msg, BROWN ); m_Parent->AppendMsgPanel( _( "Graphic layer" ), msg, BROWN );
// This next info can be see as debug info, so it can be disabled // Display Image rotation (Image specific)
msg.Printf( wxT( "%d" ), m_ImageRotation );
m_Parent->AppendMsgPanel( _( "Img Rot." ), msg, CYAN );
// Display rotation // Display Image polarity (Image specific)
msg.Printf( wxT( "%d" ), m_ImageRotation / 10 ); msg = m_ImageNegative ? _("Negative") : _("Normal");
m_Parent->AppendMsgPanel( _( "Rotation" ), msg, CYAN ); m_Parent->AppendMsgPanel( _( "Polarity" ), msg, BROWN );
// Display Image justification; // Display Image justification and offset for justification (Image specific)
msg = m_ImageJustifyXCenter ? _("Center") : _("Normal"); msg = m_ImageJustifyXCenter ? _("Center") : _("Normal");
m_Parent->AppendMsgPanel( _( "X Justify" ), msg, DARKRED ); m_Parent->AppendMsgPanel( _( "X Justify" ), msg, DARKRED );
@ -313,6 +318,6 @@ void GERBER_IMAGE::DisplayImageInfo( void )
else else
msg.Printf( wxT( "X=%f Y=%f" ), (double) m_ImageJustifyOffset.x*2.54/1000, msg.Printf( wxT( "X=%f Y=%f" ), (double) m_ImageJustifyOffset.x*2.54/1000,
(double) m_ImageJustifyOffset.y*2.54/1000 ); (double) m_ImageJustifyOffset.y*2.54/1000 );
m_Parent->AppendMsgPanel( _( "Image Justify Offset" ), msg, CYAN ); m_Parent->AppendMsgPanel( _( "Image Justify Offset" ), msg, DARKRED );
} }

View File

@ -95,10 +95,8 @@ public:
wxPoint m_ImageOffset; // Coord Offset, from IO command wxPoint m_ImageOffset; // Coord Offset, from IO command
wxSize m_FmtScale; // Fmt 2.3: m_FmtScale = 3, fmt 3.4: m_FmtScale = 4 wxSize m_FmtScale; // Fmt 2.3: m_FmtScale = 3, fmt 3.4: m_FmtScale = 4
wxSize m_FmtLen; // Nb chars per coord. ex fmt 2.3, m_FmtLen = 5 wxSize m_FmtLen; // Nb chars per coord. ex fmt 2.3, m_FmtLen = 5
int m_ImageRotation; // Image rotation (0, 90, 180, 270 int m_ImageRotation; // Image rotation (0, 90, 180, 270 only) in degrees
// Note these values are stored in 0.1 degrees double m_LocalRotation; // Local rotation, in degrees, added to m_ImageRotation
int m_LocalRotation; // Local rotation, added to m_ImageRotation
// Note this value is stored in 0.1 degrees // Note this value is stored in 0.1 degrees
wxPoint m_Offset; // Coord Offset, from OF command wxPoint m_Offset; // Coord Offset, from OF command
wxRealPoint m_Scale; // scale (X and Y) of layer. wxRealPoint m_Scale; // scale (X and Y) of layer.

View File

@ -57,7 +57,7 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( BOARD_ITEM* aParent, GERBER_IMAGE* aGerberpa
m_mirrorA = false; m_mirrorA = false;
m_mirrorB = false; m_mirrorB = false;
m_drawScale.x = m_drawScale.y = 1.0; m_drawScale.x = m_drawScale.y = 1.0;
m_layerRotation = 0; m_lyrRotation = 0;
if( m_imageParams ) if( m_imageParams )
SetLayerParameters(); SetLayerParameters();
} }
@ -90,7 +90,7 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( const GERBER_DRAW_ITEM& aSource ) :
m_layerOffset = aSource.m_layerOffset; m_layerOffset = aSource.m_layerOffset;
m_drawScale.x = aSource.m_drawScale.x; m_drawScale.x = aSource.m_drawScale.x;
m_drawScale.y = aSource.m_drawScale.y; m_drawScale.y = aSource.m_drawScale.y;
m_layerRotation = aSource.m_layerRotation; m_lyrRotation = aSource.m_lyrRotation;
} }
@ -127,13 +127,15 @@ wxPoint GERBER_DRAW_ITEM::GetABPosition( const wxPoint& aXYPosition )
abPos += m_layerOffset + m_imageParams->m_ImageOffset; abPos += m_layerOffset + m_imageParams->m_ImageOffset;
abPos.x = wxRound( abPos.x * m_drawScale.x ); abPos.x = wxRound( abPos.x * m_drawScale.x );
abPos.y = wxRound( abPos.y * m_drawScale.y ); abPos.y = wxRound( abPos.y * m_drawScale.y );
int rotation = m_layerRotation + m_imageParams->m_ImageRotation; int rotation = wxRound(m_lyrRotation*10) + (m_imageParams->m_ImageRotation*10);
if( rotation ) if( rotation )
RotatePoint( &abPos, -rotation ); RotatePoint( &abPos, -rotation );
// Negate A axis if mirrored
if( m_mirrorA ) if( m_mirrorA )
NEGATE( abPos.x ); NEGATE( abPos.x );
// abPos.y must be negated, because draw axis is top to bottom // abPos.y must be negated when no mirror, because draw axis is top to bottom
if( !m_mirrorB ) if( !m_mirrorB )
NEGATE( abPos.y ); NEGATE( abPos.y );
return abPos; return abPos;
@ -157,7 +159,7 @@ wxPoint GERBER_DRAW_ITEM::GetXYPosition( const wxPoint& aABPosition )
NEGATE( xyPos.x ); NEGATE( xyPos.x );
if( !m_mirrorB ) if( !m_mirrorB )
NEGATE( xyPos.y ); NEGATE( xyPos.y );
int rotation = m_layerRotation + m_imageParams->m_ImageRotation; int rotation = wxRound(m_lyrRotation*10) + (m_imageParams->m_ImageRotation*10);
if( rotation ) if( rotation )
RotatePoint( &xyPos, rotation ); RotatePoint( &xyPos, rotation );
xyPos.x = wxRound( xyPos.x / m_drawScale.x ); xyPos.x = wxRound( xyPos.x / m_drawScale.x );
@ -186,7 +188,7 @@ void GERBER_DRAW_ITEM::SetLayerParameters()
m_drawScale = m_imageParams->m_Scale; // A and B scaling factor m_drawScale = m_imageParams->m_Scale; // A and B scaling factor
m_layerOffset = m_imageParams->m_Offset; // Offset from OF command m_layerOffset = m_imageParams->m_Offset; // Offset from OF command
// Rotation from RO command: // Rotation from RO command:
m_layerRotation = m_imageParams->m_LocalRotation; m_lyrRotation = m_imageParams->m_LocalRotation;
m_LayerNegative = m_imageParams->GetLayerParams().m_LayerNegative; m_LayerNegative = m_imageParams->GetLayerParams().m_LayerNegative;
} }
@ -477,23 +479,26 @@ void GERBER_DRAW_ITEM::DisplayInfo( WinEDA_DrawFrame* frame )
msg.Printf( wxT( "%d" ), GetLayer() + 1 ); msg.Printf( wxT( "%d" ), GetLayer() + 1 );
frame->AppendMsgPanel( _( "Graphic layer" ), msg, BROWN ); frame->AppendMsgPanel( _( "Graphic layer" ), msg, BROWN );
// This next info can be see as debug info, so it can be disabled // Display item rotation
#if 1 // The full rotation is Image rotation + m_lyrRotation
// but m_lyrRotation is specific to this object
// so we display only this parameter
msg.Printf( wxT( "%f" ), m_lyrRotation );
frame->AppendMsgPanel( _( "Rotation" ), msg, BLUE );
// Display rotation // Display item polarity (item specific)
msg.Printf( wxT( "%.1f" ), (double)(m_imageParams->m_ImageRotation+m_layerRotation) / 10 ); msg = m_LayerNegative ? _("Clear") : _("Dark");
frame->AppendMsgPanel( _( "Rotation" ), msg, DARKRED ); frame->AppendMsgPanel( _( "Polarity" ), msg, BLUE );
// Display mirroring // Display mirroring (item specific)
msg.Printf( wxT( "A:%s B:%s" ), msg.Printf( wxT( "A:%s B:%s" ),
m_mirrorA ? _("Yes") : _("No"), m_mirrorA ? _("Yes") : _("No"),
m_mirrorB ? _("Yes") : _("No")); m_mirrorB ? _("Yes") : _("No"));
frame->AppendMsgPanel( _( "Mirror" ), msg, DARKRED ); frame->AppendMsgPanel( _( "Mirror" ), msg, DARKRED );
// Display AB axis swap // Display AB axis swap (item specific)
msg = m_swapAxis ? wxT( "A=Y B=X" ) : wxT( "A=X B=Y" ); msg = m_swapAxis ? wxT( "A=Y B=X" ) : wxT( "A=X B=Y" );
frame->AppendMsgPanel( _( "AB axis" ), msg, DARKRED ); frame->AppendMsgPanel( _( "AB axis" ), msg, DARKRED );
#endif
} }

View File

@ -92,7 +92,7 @@ private:
bool m_mirrorB; // true: mirror / axe B bool m_mirrorB; // true: mirror / axe B
wxRealPoint m_drawScale; // A and B scaling factor wxRealPoint m_drawScale; // A and B scaling factor
wxPoint m_layerOffset; // Offset for A and B axis, from OF parameter wxPoint m_layerOffset; // Offset for A and B axis, from OF parameter
int m_layerRotation; // Fine rotation, from OR parameter double m_lyrRotation; // Fine rotation, from OR parameter, in degrees
public: public:
GERBER_DRAW_ITEM( BOARD_ITEM* aParent, GERBER_IMAGE* aGerberparams ); GERBER_DRAW_ITEM( BOARD_ITEM* aParent, GERBER_IMAGE* aGerberparams );

View File

@ -124,6 +124,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_GERBVIEW_GLOBAL_DELETE: case ID_GERBVIEW_GLOBAL_DELETE:
Erase_Current_Layer( TRUE ); Erase_Current_Layer( TRUE );
ClearMsgPanel();
break; break;
case ID_NO_SELECT_BUTT: case ID_NO_SELECT_BUTT:

View File

@ -16,7 +16,7 @@ static void LoadDCodeFile( WinEDA_GerberFrame* frame,
const wxString& FullFileName ); const wxString& FullFileName );
/* Load agerber file selected from history list on current layer /* Load a Gerber file selected from history list on current layer
* Previous data is deleted * Previous data is deleted
*/ */
void WinEDA_GerberFrame::OnFileHistory( wxCommandEvent& event ) void WinEDA_GerberFrame::OnFileHistory( wxCommandEvent& event )
@ -56,10 +56,8 @@ void WinEDA_GerberFrame::Files_io( wxCommandEvent& event )
{ {
setActiveLayer(origLayer+1); setActiveLayer(origLayer+1);
Erase_Current_Layer( false ); Erase_Current_Layer( false );
if( !LoadOneGerberFile( wxEmptyString ) ) if( !LoadOneGerberFile( wxEmptyString ) )
setActiveLayer(origLayer); setActiveLayer(origLayer);
SetToolbars(); SetToolbars();
} }
else else
@ -76,6 +74,7 @@ delete an existing layer to load any new layers." ), NB_LAYERS );
Clear_Pcb( true ); Clear_Pcb( true );
Zoom_Automatique( false ); Zoom_Automatique( false );
DrawPanel->Refresh(); DrawPanel->Refresh();
ClearMsgPanel();
break; break;
case ID_GERBVIEW_LOAD_DRILL_FILE: case ID_GERBVIEW_LOAD_DRILL_FILE:
@ -105,10 +104,14 @@ bool WinEDA_GerberFrame::LoadOneGerberFile( const wxString& aFullFileName, bool
/* Standard gerber filetypes /* Standard gerber filetypes
* (See http://en.wikipedia.org/wiki/Gerber_File) * (See http://en.wikipedia.org/wiki/Gerber_File)
* the .pho extension is the default used in Pcbnew * the .pho extension is the default used in Pcbnew
* However there are a lot of other extensions used for gerber files
* Because the first letter is usually g, we accept g* as extension
* (Mainly internal copper layers do not have specific extention,
* and filenames are like *.g1, *.g2 *.gb1 ...).
*/ */
filetypes = _( "Gerber files (.gb* .gt* .lgr .ger .pho)" ); filetypes = _( "Gerber files (.g* .lgr .pho)" );
filetypes << wxT("|"); filetypes << wxT("|");
filetypes += wxT("*.gb*;*.GB*;*.gt*;*.GT*;*.gko;*.GKO;*.GPB;*.gpb;*.lgr;*.LGR;*.ger;*.GER;*.pho;*.PHO" ); filetypes += wxT("*.g*;*.G*;*.lgr;*.LGR;*.pho;*.PHO" );
filetypes << wxT("|"); filetypes << wxT("|");
/* Special gerber filetypes */ /* Special gerber filetypes */

View File

@ -4,7 +4,7 @@ G04 the center line straight up *
G04 Handcoded by Julian Lamb * G04 Handcoded by Julian Lamb *
%MOIN*% %MOIN*%
%FSLAX23Y23*% %FSLAX23Y23*%
%RO45*% %RO45.0*%
%ADD10C,0.025*% %ADD10C,0.025*%
G04 Quarter star * G04 Quarter star *

View File

@ -497,6 +497,7 @@ void WinEDA_GerberFrame::UpdateTitleAndInfo()
SetTitle( text ); SetTitle( text );
SetStatusText( wxEmptyString, 0 ); SetStatusText( wxEmptyString, 0 );
m_TextInfo->Clear(); m_TextInfo->Clear();
ClearMsgPanel();
return; return;
} }
@ -504,6 +505,7 @@ void WinEDA_GerberFrame::UpdateTitleAndInfo()
text << wxT( " " ) << gerber->m_FileName; text << wxT( " " ) << gerber->m_FileName;
SetTitle( text ); SetTitle( text );
gerber->DisplayImageInfo( );
// Display Image Name and Layer Name (from the current gerber data): // Display Image Name and Layer Name (from the current gerber data):
text.Printf( _("Image name: \"%s\" Layer name \"%s\""), text.Printf( _("Image name: \"%s\" Layer name \"%s\""),

View File

@ -25,6 +25,8 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query )
if( !IsOK( this, _( "Current data will be lost?" ) ) ) if( !IsOK( this, _( "Current data will be lost?" ) ) )
return FALSE; return FALSE;
} }
SetCurItem( NULL );
GetBoard()->m_Drawings.DeleteAll(); GetBoard()->m_Drawings.DeleteAll();
for( layer = 0; layer < 32; layer++ ) for( layer = 0; layer < 32; layer++ )
@ -45,8 +47,6 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query )
SetBaseScreen( ActiveScreen = ScreenPcb ); SetBaseScreen( ActiveScreen = ScreenPcb );
GetScreen()->Init(); GetScreen()->Init();
setActiveLayer(LAYER_N_BACK); setActiveLayer(LAYER_N_BACK);
SetCurItem( NULL );
return TRUE; return TRUE;
} }

View File

@ -53,6 +53,7 @@ enum RS274X_PARAMETERS {
// Layer specific parameters // Layer specific parameters
// May be used singly or may be layer specfic // May be used singly or may be layer specfic
// theses parameters are at the beginning of the file or layer // theses parameters are at the beginning of the file or layer
// and reset some layer parameters (like interpolation)
LAYER_NAME = CODE( 'L', 'N' ), // Default: Positive LAYER_NAME = CODE( 'L', 'N' ), // Default: Positive
LAYER_POLARITY = CODE( 'L', 'P' ), LAYER_POLARITY = CODE( 'L', 'P' ),
KNOCKOUT = CODE( 'K', 'O' ), // Default: off KNOCKOUT = CODE( 'K', 'O' ), // Default: off
@ -389,16 +390,17 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
if( strnicmp( text, "0*", 2 ) == 0 ) if( strnicmp( text, "0*", 2 ) == 0 )
m_ImageRotation = 0; m_ImageRotation = 0;
if( strnicmp( text, "90*", 2 ) == 0 ) if( strnicmp( text, "90*", 2 ) == 0 )
m_ImageRotation = 900; m_ImageRotation = 90;
if( strnicmp( text, "180*", 2 ) == 0 ) if( strnicmp( text, "180*", 2 ) == 0 )
m_ImageRotation = 1800; m_ImageRotation = 180;
if( strnicmp( text, "270*", 2 ) == 0 ) if( strnicmp( text, "270*", 2 ) == 0 )
m_ImageRotation = 2700; m_ImageRotation = 270;
else else
ReportMessage( _( "RS274X: Command \"IR\" rotation value not allowed" ) ); ReportMessage( _( "RS274X: Command \"IR\" rotation value not allowed" ) );
break; break;
case STEP_AND_REPEAT: // command SR, like %SRX3Y2I5.0J2*% case STEP_AND_REPEAT: // command SR, like %SRX3Y2I5.0J2*%
m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Start a new Gerber layer
GetLayerParams().m_StepForRepeat.x = 0.0; GetLayerParams().m_StepForRepeat.x = 0.0;
GetLayerParams().m_StepForRepeat.x = 0.0; // offset for Step and Repeat command GetLayerParams().m_StepForRepeat.x = 0.0; // offset for Step and Repeat command
GetLayerParams().m_XRepeatCount = 1; GetLayerParams().m_XRepeatCount = 1;
@ -484,6 +486,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
break; break;
case KNOCKOUT: case KNOCKOUT:
m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Start a new Gerber layer
msg = _( "RS274X: Command KNOCKOUT ignored by Gerbview" ) ; msg = _( "RS274X: Command KNOCKOUT ignored by Gerbview" ) ;
ReportMessage( msg ); ReportMessage( msg );
break; break;
@ -500,7 +503,8 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
break; break;
case ROTATE: // Layer rotation: command like %RO45*% case ROTATE: // Layer rotation: command like %RO45*%
m_LocalRotation = wxRound(ReadDouble( text ) * 10 ); m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Start a new Gerber layer
m_LocalRotation =ReadDouble( text ); // Store layer rotation in degrees
break; break;
case IMAGE_NAME: case IMAGE_NAME:
@ -513,6 +517,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
break; break;
case LAYER_NAME: case LAYER_NAME:
m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Start a new Gerber layer
GetLayerParams( ).m_LayerName.Empty(); GetLayerParams( ).m_LayerName.Empty();
while( *text != '*' ) while( *text != '*' )
{ {