Commit bfeaeafe authored by jean-pierre charras's avatar jean-pierre charras

Gerbview: enhancements.

parent de37bbad
......@@ -159,8 +159,8 @@ void GERBER_IMAGE::ResetDefaultValues()
// true = relative Coord
m_NoTrailingZeros = false; // true: trailing zeros deleted
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_LocalRotation = 0; // Layer totation from RO command (in 0.1 degree)
m_ImageRotation = 0; // Allowed 0, 90, 180, 270 (in degree)
m_LocalRotation = 0.0; // Layer totation from RO command (in 0.1 degree)
m_Offset.x = 0;
m_Offset.y = 0; // Coord Offset, from OF command
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
* about this object into the frame's message panel.
* 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 )
{
......@@ -287,20 +289,23 @@ void GERBER_IMAGE::DisplayImageInfo( void )
m_Parent->ClearMsgPanel();
// Display Image name
m_Parent->AppendMsgPanel( _( "Image name" ), m_ImageName, BROWN );
// Display Image name (Image specific)
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 );
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
msg.Printf( wxT( "%d" ), m_ImageRotation / 10 );
m_Parent->AppendMsgPanel( _( "Rotation" ), msg, CYAN );
// Display Image polarity (Image specific)
msg = m_ImageNegative ? _("Negative") : _("Normal");
m_Parent->AppendMsgPanel( _( "Polarity" ), msg, BROWN );
// Display Image justification;
// Display Image justification and offset for justification (Image specific)
msg = m_ImageJustifyXCenter ? _("Center") : _("Normal");
m_Parent->AppendMsgPanel( _( "X Justify" ), msg, DARKRED );
......@@ -313,6 +318,6 @@ void GERBER_IMAGE::DisplayImageInfo( void )
else
msg.Printf( wxT( "X=%f Y=%f" ), (double) m_ImageJustifyOffset.x*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 );
}
......@@ -95,10 +95,8 @@ public:
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_FmtLen; // Nb chars per coord. ex fmt 2.3, m_FmtLen = 5
int m_ImageRotation; // Image rotation (0, 90, 180, 270
// Note these values are stored in 0.1 degrees
int m_LocalRotation; // Local rotation, added to m_ImageRotation
int m_ImageRotation; // Image rotation (0, 90, 180, 270 only) in degrees
double m_LocalRotation; // Local rotation, in degrees, added to m_ImageRotation
// Note this value is stored in 0.1 degrees
wxPoint m_Offset; // Coord Offset, from OF command
wxRealPoint m_Scale; // scale (X and Y) of layer.
......
......@@ -57,7 +57,7 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( BOARD_ITEM* aParent, GERBER_IMAGE* aGerberpa
m_mirrorA = false;
m_mirrorB = false;
m_drawScale.x = m_drawScale.y = 1.0;
m_layerRotation = 0;
m_lyrRotation = 0;
if( m_imageParams )
SetLayerParameters();
}
......@@ -90,7 +90,7 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( const GERBER_DRAW_ITEM& aSource ) :
m_layerOffset = aSource.m_layerOffset;
m_drawScale.x = aSource.m_drawScale.x;
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.x = wxRound( abPos.x * m_drawScale.x );
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 )
RotatePoint( &abPos, -rotation );
// Negate A axis if mirrored
if( m_mirrorA )
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 )
NEGATE( abPos.y );
return abPos;
......@@ -157,7 +159,7 @@ wxPoint GERBER_DRAW_ITEM::GetXYPosition( const wxPoint& aABPosition )
NEGATE( xyPos.x );
if( !m_mirrorB )
NEGATE( xyPos.y );
int rotation = m_layerRotation + m_imageParams->m_ImageRotation;
int rotation = wxRound(m_lyrRotation*10) + (m_imageParams->m_ImageRotation*10);
if( rotation )
RotatePoint( &xyPos, rotation );
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_layerOffset = m_imageParams->m_Offset; // Offset from OF command
// Rotation from RO command:
m_layerRotation = m_imageParams->m_LocalRotation;
m_lyrRotation = m_imageParams->m_LocalRotation;
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 );
frame->AppendMsgPanel( _( "Graphic layer" ), msg, BROWN );
// This next info can be see as debug info, so it can be disabled
#if 1
// Display item rotation
// 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
msg.Printf( wxT( "%.1f" ), (double)(m_imageParams->m_ImageRotation+m_layerRotation) / 10 );
frame->AppendMsgPanel( _( "Rotation" ), msg, DARKRED );
// Display item polarity (item specific)
msg = m_LayerNegative ? _("Clear") : _("Dark");
frame->AppendMsgPanel( _( "Polarity" ), msg, BLUE );
// Display mirroring
// Display mirroring (item specific)
msg.Printf( wxT( "A:%s B:%s" ),
m_mirrorA ? _("Yes") : _("No"),
m_mirrorB ? _("Yes") : _("No"));
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" );
frame->AppendMsgPanel( _( "AB axis" ), msg, DARKRED );
#endif
}
......
......@@ -92,7 +92,7 @@ private:
bool m_mirrorB; // true: mirror / axe B
wxRealPoint m_drawScale; // A and B scaling factor
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:
GERBER_DRAW_ITEM( BOARD_ITEM* aParent, GERBER_IMAGE* aGerberparams );
......
......@@ -124,6 +124,7 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_GERBVIEW_GLOBAL_DELETE:
Erase_Current_Layer( TRUE );
ClearMsgPanel();
break;
case ID_NO_SELECT_BUTT:
......
......@@ -16,7 +16,7 @@ static void LoadDCodeFile( WinEDA_GerberFrame* frame,
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
*/
void WinEDA_GerberFrame::OnFileHistory( wxCommandEvent& event )
......@@ -56,10 +56,8 @@ void WinEDA_GerberFrame::Files_io( wxCommandEvent& event )
{
setActiveLayer(origLayer+1);
Erase_Current_Layer( false );
if( !LoadOneGerberFile( wxEmptyString ) )
setActiveLayer(origLayer);
SetToolbars();
}
else
......@@ -76,6 +74,7 @@ delete an existing layer to load any new layers." ), NB_LAYERS );
Clear_Pcb( true );
Zoom_Automatique( false );
DrawPanel->Refresh();
ClearMsgPanel();
break;
case ID_GERBVIEW_LOAD_DRILL_FILE:
......@@ -105,10 +104,14 @@ bool WinEDA_GerberFrame::LoadOneGerberFile( const wxString& aFullFileName, bool
/* Standard gerber filetypes
* (See http://en.wikipedia.org/wiki/Gerber_File)
* 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("*.gb*;*.GB*;*.gt*;*.GT*;*.gko;*.GKO;*.GPB;*.gpb;*.lgr;*.LGR;*.ger;*.GER;*.pho;*.PHO" );
filetypes += wxT("*.g*;*.G*;*.lgr;*.LGR;*.pho;*.PHO" );
filetypes << wxT("|");
/* Special gerber filetypes */
......
......@@ -4,7 +4,7 @@ G04 the center line straight up *
G04 Handcoded by Julian Lamb *
%MOIN*%
%FSLAX23Y23*%
%RO45*%
%RO45.0*%
%ADD10C,0.025*%
G04 Quarter star *
......
......@@ -497,6 +497,7 @@ void WinEDA_GerberFrame::UpdateTitleAndInfo()
SetTitle( text );
SetStatusText( wxEmptyString, 0 );
m_TextInfo->Clear();
ClearMsgPanel();
return;
}
......@@ -504,6 +505,7 @@ void WinEDA_GerberFrame::UpdateTitleAndInfo()
text << wxT( " " ) << gerber->m_FileName;
SetTitle( text );
gerber->DisplayImageInfo( );
// Display Image Name and Layer Name (from the current gerber data):
text.Printf( _("Image name: \"%s\" Layer name \"%s\""),
......
......@@ -25,6 +25,8 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query )
if( !IsOK( this, _( "Current data will be lost?" ) ) )
return FALSE;
}
SetCurItem( NULL );
GetBoard()->m_Drawings.DeleteAll();
for( layer = 0; layer < 32; layer++ )
......@@ -45,8 +47,6 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query )
SetBaseScreen( ActiveScreen = ScreenPcb );
GetScreen()->Init();
setActiveLayer(LAYER_N_BACK);
SetCurItem( NULL );
return TRUE;
}
......
......@@ -53,6 +53,7 @@ enum RS274X_PARAMETERS {
// Layer specific parameters
// May be used singly or may be layer specfic
// 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_POLARITY = CODE( 'L', 'P' ),
KNOCKOUT = CODE( 'K', 'O' ), // Default: off
......@@ -389,16 +390,17 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
if( strnicmp( text, "0*", 2 ) == 0 )
m_ImageRotation = 0;
if( strnicmp( text, "90*", 2 ) == 0 )
m_ImageRotation = 900;
m_ImageRotation = 90;
if( strnicmp( text, "180*", 2 ) == 0 )
m_ImageRotation = 1800;
m_ImageRotation = 180;
if( strnicmp( text, "270*", 2 ) == 0 )
m_ImageRotation = 2700;
m_ImageRotation = 270;
else
ReportMessage( _( "RS274X: Command \"IR\" rotation value not allowed" ) );
break;
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; // offset for Step and Repeat command
GetLayerParams().m_XRepeatCount = 1;
......@@ -484,6 +486,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
break;
case KNOCKOUT:
m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Start a new Gerber layer
msg = _( "RS274X: Command KNOCKOUT ignored by Gerbview" ) ;
ReportMessage( msg );
break;
......@@ -500,7 +503,8 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
break;
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;
case IMAGE_NAME:
......@@ -513,6 +517,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
break;
case LAYER_NAME:
m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Start a new Gerber layer
GetLayerParams( ).m_LayerName.Empty();
while( *text != '*' )
{
......
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