Commit a1998410 authored by charras's avatar charras

Some enhancements and fixes. (see changelog)

parent cacb2225
......@@ -4,6 +4,15 @@ KiCad ChangeLog 2009
Please add newer entries at the top, list the date and your name with
email address.
2009-Dec-30 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================
++pcbnew
Added option to use some usual Gerber files extension, depending on the layer
Do not allow in plot menu to output files for non enabled layers.
++Kicad and Gerbview
Display Gerber files that use usual files extension (in tree project or dialog files)
(See http://en.wikipedia.org/wiki/Gerber_File)
2009-Dec-20 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++pcbnew
......
......@@ -521,7 +521,7 @@ void WinEDA_DrawPanel::EraseScreen( wxDC* DC )
#ifndef WX_ZOOM
GRSFilledRect( &m_ClipBox, DC, m_ClipBox.GetX(), m_ClipBox.GetY(),
m_ClipBox.GetRight(), m_ClipBox.GetBottom(),
g_DrawBgColor, g_DrawBgColor );
0, g_DrawBgColor, g_DrawBgColor );
#else
EDA_Rect tmp = m_ClipBox;
......@@ -534,7 +534,7 @@ void WinEDA_DrawPanel::EraseScreen( wxDC* DC )
GRSFilledRect( &m_ClipBox, DC, m_ClipBox.GetX(), m_ClipBox.GetY(),
m_ClipBox.GetRight(), m_ClipBox.GetBottom(),
g_DrawBgColor, g_DrawBgColor );
0, g_DrawBgColor, g_DrawBgColor );
m_ClipBox = tmp;
#endif
......
......@@ -69,6 +69,13 @@ static int lastwidth = -1;
static int s_Last_Pen_Style = -1;
static wxDC* lastDC = NULL;
/* Local functions: */
static void GRSRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1,
int x2, int y2, int Color );
static void GRSRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1,
int x2, int y2, int width, int Color );
/*
* Macro clipping the trace of a line:
* Line (x1, y1 x2, y2) is clipped to remain within
......@@ -362,9 +369,13 @@ void GRSetDrawMode( wxDC* DC, int draw_mode )
if( draw_mode & GR_OR )
#if defined(__WXMAC__) && (wxMAC_USE_CORE_GRAPHICS || wxCHECK_VERSION( 2, 9, 0 ) )
DC->SetLogicalFunction( wxCOPY );
#else
DC->SetLogicalFunction( wxOR );
#endif
else if( draw_mode & GR_XOR )
......@@ -372,9 +383,13 @@ void GRSetDrawMode( wxDC* DC, int draw_mode )
else if( draw_mode & GR_NXOR )
#if defined(__WXMAC__) && (wxMAC_USE_CORE_GRAPHICS || wxCHECK_VERSION( 2, 9, 0 ) )
DC->SetLogicalFunction( wxXOR );
#else
DC->SetLogicalFunction( wxEQUIV );
#endif
else
......@@ -1422,12 +1437,8 @@ void GRArc( EDA_Rect* ClipBox,
/*
* Draw a rectangle in drawing space.
*/
void GRRect( EDA_Rect* ClipBox,
wxDC* DC,
int x1,
int y1,
int x2,
int y2,
void GRRect( EDA_Rect* ClipBox, wxDC* DC,
int x1, int y1, int x2, int y2,
int Color )
{
x1 = GRMapX( x1 );
......@@ -1438,18 +1449,25 @@ void GRRect( EDA_Rect* ClipBox,
GRSRect( ClipBox, DC, x1, y1, x2, y2, Color );
}
void GRRect( EDA_Rect* aClipBox, wxDC* aDC,
const EDA_Rect& aRect,
int aColor )
{
int x1 = GRMapX( aRect.GetX() );
int y1 = GRMapY( aRect.GetY() );
int x2 = GRMapX( aRect.GetRight() );
int y2 = GRMapY( aRect.GetBottom() );
GRSRect( aClipBox, aDC, x1, y1, x2, y2, aColor );
}
/*
* Draw a rectangle in drawing space.
* Draw a rectangle (thick lines) in drawing space.
*/
void GRRect( EDA_Rect* ClipBox,
wxDC* DC,
int x1,
int y1,
int x2,
int y2,
int width,
int Color )
void GRRect( EDA_Rect* ClipBox, wxDC* DC,
int x1, int y1, int x2, int y2,
int width, int Color )
{
x1 = GRMapX( x1 );
y1 = GRMapY( y1 );
......@@ -1460,6 +1478,20 @@ void GRRect( EDA_Rect* ClipBox,
GRSRect( ClipBox, DC, x1, y1, x2, y2, width, Color );
}
void GRRect( EDA_Rect* aClipBox, wxDC* aDC,
const EDA_Rect& aRect,
int aWidth, int aColor )
{
int x1 = GRMapX( aRect.GetX() );
int y1 = GRMapY( aRect.GetY() );
int x2 = GRMapX( aRect.GetRight() );
int y2 = GRMapY( aRect.GetBottom() );
int width = ZoomValue( aWidth );
GRSRect( aClipBox, aDC, x1, y1, x2, y2, width, aColor );
}
/*
* Draw a rectangle (filled with AreaColor) in drawing space.
......@@ -1543,31 +1575,10 @@ void GRSRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
}
/*
* Draw a filled rectangle in screen space.
*/
void GRSFilledRect( EDA_Rect* ClipBox,
wxDC* DC,
int x1,
int y1,
int x2,
int y2,
int Color,
int BgColor )
{
GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, 0, Color, BgColor );
}
void GRSFilledRect( EDA_Rect* ClipBox,
wxDC* DC,
int x1,
int y1,
int x2,
int y2,
int width,
int Color,
int BgColor )
void GRSFilledRect( EDA_Rect* ClipBox, wxDC* DC,
int x1, int y1, int x2, int y2,
int width, int Color, int BgColor )
{
if( x1 > x2 )
EXCHG( x1, x2 );
......@@ -1656,6 +1667,7 @@ void ClipAndDrawFilledPoly( EDA_Rect* aClipBox,
aDC->DrawPolygon( clippedPolygon.size(), &clippedPolygon[0] );
}
#endif
......
......@@ -451,7 +451,7 @@ bool LIB_COMPONENT::Save( FILE* aFile )
if( fprintf( aFile, "DEF" ) < 0 )
return false;
if( ( value.m_Attributs & TEXT_NO_VISIBLE ) == 0 )
if( value.IsVisible() )
{
if( fprintf( aFile, " %s", CONV_TO_UTF8( value.m_Text ) ) < 0 )
return false;
......@@ -859,7 +859,7 @@ EDA_Rect LIB_COMPONENT::GetBoundaryBox( int aUnit, int aConvert )
continue;
if ( ( item.Type() == COMPONENT_FIELD_DRAW_TYPE )
&& ( ( ( LIB_TEXT& ) item ).m_Attributs & TEXT_NO_VISIBLE ) )
&& !( ( LIB_FIELD& ) item ).IsVisible() )
continue;
bBox.Merge( item.GetBoundingBox() );
......
......@@ -84,9 +84,16 @@ public:
int aColor, int aDrawMode, void* aData,
const int aTransformMatrix[2][2] );
/** Function IsVisible
* @return true is this field is visible, false if flagged invisible
*/
bool IsVisible()
{
return (m_Attributs & TEXT_NO_VISIBLE) == 0 ? true : false;
}
/**
* Return the bounding rectangle of the field text.
*
* @return Bounding rectangle.
*/
virtual EDA_Rect GetBoundingBox();
......
......@@ -67,6 +67,14 @@ public:
*/
int GetPenSize( );
/** Function IsVisible
* @return true is this field is visible, false if flagged invisible
*/
bool IsVisible()
{
return (m_Attributs & TEXT_NO_VISIBLE) == 0 ? true : false;
}
/**
* Function Draw
*/
......
......@@ -205,8 +205,7 @@ void SCH_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
SCH_FIELD* field = GetField( REFERENCE );
if( ( ( field->m_Attributs & TEXT_NO_VISIBLE ) == 0 )
&& !( field->m_Flags & IS_MOVED ) )
if( field->IsVisible() && !( field->m_Flags & IS_MOVED ) )
{
if( Entry->GetPartCount() > 1 )
{
......@@ -236,23 +235,20 @@ void SCH_COMPONENT::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
{
EDA_Rect BoundaryBox;
BoundaryBox = GetBoundaryBox();
int x1 = BoundaryBox.GetX();
int y1 = BoundaryBox.GetY();
int x2 = BoundaryBox.GetRight();
int y2 = BoundaryBox.GetBottom();
GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN );
GRRect( &panel->m_ClipBox, DC, BoundaryBox, BROWN );
#if 1
if( GetField( REFERENCE )->IsVisible() )
{
BoundaryBox = GetField( REFERENCE )->GetBoundaryBox();
x1 = BoundaryBox.GetX();
y1 = BoundaryBox.GetY();
x2 = BoundaryBox.GetRight();
y2 = BoundaryBox.GetBottom();
GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN );
GRRect( &panel->m_ClipBox, DC, BoundaryBox, BROWN );
}
if( GetField( VALUE )->IsVisible() )
{
BoundaryBox = GetField( VALUE )->GetBoundaryBox();
x1 = BoundaryBox.GetX();
y1 = BoundaryBox.GetY();
x2 = BoundaryBox.GetRight();
y2 = BoundaryBox.GetBottom();
GRRect( &panel->m_ClipBox, DC, x1, y1, x2, y2, BROWN );
GRRect( &panel->m_ClipBox, DC, BoundaryBox, BROWN );
}
#endif
}
#endif
}
......@@ -530,7 +526,13 @@ LIB_PIN* SCH_COMPONENT::GetPin( const wxString& number )
return Entry->GetPin( number, m_Multi, m_Convert );
}
/**
* Function GetBoundaryBox
* returns the orthogonal, bounding box of this object for display purposes.
* This box should be an enclosing perimeter for graphic items and pins.
* this include only fields defined in library
* use GetBoundingBox() to include fields in schematic
*/
EDA_Rect SCH_COMPONENT::GetBoundaryBox() const
{
LIB_COMPONENT* Entry = CMP_LIBRARY::FindLibraryComponent( m_ChipName );
......@@ -1064,6 +1066,13 @@ bool SCH_COMPONENT::Save( FILE* f ) const
}
/**
* Function GetBoundingBox
* returns the orthogonal, bounding box of this object for display purposes.
* This box should be an enclosing perimeter for visible components of this
* object, and the units should be in the pcb or schematic coordinate system.
* It is OK to overestimate the size by a few counts.
*/
EDA_Rect SCH_COMPONENT::GetBoundingBox()
{
const int PADDING = 40;
......@@ -1074,11 +1083,13 @@ EDA_Rect SCH_COMPONENT::GetBoundingBox()
// Include BoundingBoxes of fields
for( int ii = 0; ii < GetFieldCount(); ii++ )
{
if( ! GetField( ii )->IsVisible() )
continue;
bbox.Merge( GetField( ii )->GetBoundaryBox() );
}
// ... add padding
bbox.Inflate( PADDING, PADDING );
bbox.Inflate( PADDING );
return bbox;
}
......
......@@ -209,6 +209,13 @@ public:
*/
void SetTimeStamp( long aNewTimeStamp);
/**
* Function GetBoundaryBox
* returns the orthogonal, bounding box of this object for display purposes.
* This box should be an enclosing perimeter for graphic items and pins.
* this include only fields defined in library
* use GetBoundingBox() to include fields in schematic
*/
EDA_Rect GetBoundaryBox() const;
/**
......
......@@ -22,8 +22,6 @@
/* Used for EDA_BaseStruct, .m_Select member */
#define IS_SELECTED 1
#define TEXT_NO_VISIBLE 1
//#define GR_DEFAULT_DRAWMODE GR_COPY
#define GR_DEFAULT_DRAWMODE GR_COPY
......
......@@ -417,7 +417,6 @@ bool IsItemInBox( EDA_Rect& aBox, SCH_ITEM* DrawStruct )
case TYPE_SCH_TEXT:
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_COMPONENT:
case DRAW_SHEET_STRUCT_TYPE:
case TYPE_SCH_MARKER:
BoundaryBox = DrawStruct->GetBoundingBox();
......@@ -425,6 +424,14 @@ bool IsItemInBox( EDA_Rect& aBox, SCH_ITEM* DrawStruct )
return true;
break;
case TYPE_SCH_COMPONENT:
// Use a more restrictive area than GetBoundingBox()
// Area is restricted to the body area, excludint fields outside this area
BoundaryBox = ((SCH_COMPONENT*)DrawStruct)->GetBoundaryBox();
if( aBox.Intersects( BoundaryBox ) )
return true;
break;
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
break;
......
......@@ -5,6 +5,9 @@
#ifndef PROGRAM_H
#define PROGRAM_H
#define HIGHLIGHT_COLOR WHITE
#define TEXT_NO_VISIBLE 1
#include "wxEeschemaStruct.h"
#include "macros.h"
#include "base_struct.h"
......@@ -17,9 +20,6 @@
#include "class_text-label.h"
#include "class_schematic_items.h"
#define HIGHLIGHT_COLOR WHITE
#define TEXT_NO_VISIBLE 1
/* Rotation, mirror of graphic items in components bodies are handled by a
* transform matrix. The default matix is useful to draw lib entries with
......
......@@ -110,9 +110,14 @@ bool WinEDA_GerberFrame::LoadOneGerberFile( const wxString& FullFileName,
{
wxString current_path = filename.GetPath();
/* Standard gerber filetypes */
filetypes += _( "Gerber files (.gbr .gbx .lgr .ger .pho)| \
.gbr;*.GBR;*.gbx;*.GBX;*.lgr;*.LGR;*.ger;*.GER;*.pho;*.PHO|" );
/* Standard gerber filetypes
* (See http://en.wikipedia.org/wiki/Gerber_File)
* the .pho extension is the default used in Pcbnew
*/
filetypes = _( "Gerber files (.gb* .gt* .lgr .ger .pho)" );
filetypes << wxT("|");
filetypes += wxT("*.gb*;*.GB*;.gt*;.GT*;.gko;.GKO;*.GPB;*.gpb;*.lgr;*.LGR;*.ger;*.GER;*.pho;*.PHO" );
filetypes << wxT("|");
/* Special gerber filetypes */
filetypes += _( "Top layer (*.GTL)|*.GTL;*.gtl|" );
......
......@@ -175,15 +175,15 @@ public:
bool Inside( int x, int y ) { return Inside( wxPoint( x, y ) ); }
wxSize GetSize() { return m_Size; }
int GetX() { return m_Pos.x; }
int GetY() { return m_Pos.y; }
int GetX() const { return m_Pos.x; }
int GetY() const { return m_Pos.y; }
wxPoint GetOrigin() { return m_Pos; }
wxPoint GetPosition() { return m_Pos; }
wxPoint GetEnd() { return wxPoint( GetRight(), GetBottom() ); }
int GetWidth() { return m_Size.x; }
int GetHeight() { return m_Size.y; }
int GetRight() { return m_Pos.x + m_Size.x; }
int GetBottom() { return m_Pos.y + m_Size.y; }
wxPoint GetEnd() const { return wxPoint( GetRight(), GetBottom() ); }
int GetWidth() const { return m_Size.x; }
int GetHeight() const { return m_Size.y; }
int GetRight() const { return m_Pos.x + m_Size.x; }
int GetBottom() const { return m_Pos.y + m_Size.y; }
void SetOrigin( const wxPoint& pos ) { m_Pos = pos; }
void SetOrigin( int x, int y ) { m_Pos.x = x; m_Pos.y = y; }
void SetSize( const wxSize& size ) { m_Size = size; }
......
......@@ -58,6 +58,10 @@ void GRForceBlackPen( bool flagforce );
bool GetGRForceBlackPenState( void );
void SetPenMinWidth( int minwidth );
void GRSPutPixel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int color );
void GRSFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1,
int x2, int y2, int width, int Color, int BgColor );
void GRLine( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
int aWidth, int aColor );
void GRLine( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2,
......@@ -205,24 +209,19 @@ void GRSetColor( int Color );
void GRSetDefaultPalette();
int GRGetColor();
void GRPutPixel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int color );
void GRSPutPixel( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int color );
int GRGetPixel( wxDC* DC, int x, int y );
void GRFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1,
int x2, int y2, int Color, int BgColor );
void GRFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1,
int x2, int y2, int width, int Color, int BgColor );
void GRSFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1,
int x2, int y2, int Color, int BgColor );
void GRSFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1,
int x2, int y2, int width, int Color, int BgColor );
void GRRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1,
int x2, int y2, int Color );
void GRRect( EDA_Rect* ClipBox, wxDC* DC,const EDA_Rect& aRect,
int Color );
void GRRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1,
int x2, int y2, int width, int Color );
void GRSRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1,
int x2, int y2, int Color );
void GRSRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1,
int x2, int y2, int width, int Color );
void GRRect( EDA_Rect* aClipBox, wxDC* aDC,const EDA_Rect& aRect,
int aWidth, int aColor );
#endif /* define GR_BASIC */
No preview for this file type
This diff is collapsed.
......@@ -40,8 +40,11 @@ const wxChar* s_AllowedExtensionsToList[] =
wxT( "^[^$].*\\.brd$" ),
wxT( "^.*\\.net$" ),
wxT( "^.*\\.txt$" ),
wxT( "^.*\\.pho$" ),
wxT( "^.*\\.gbr$" ),
wxT( "^.*\\.pho$" ), // Gerber file
wxT( "^.*\\.gbr$" ), // Gerber file
wxT( "^.*\\.gb[alops]$" ), // Gerber back (or bottom) layer file
wxT( "^.*\\.gt[alops]$" ), // Gerber front (or top) layer file
wxT( "^.*\\.g[0-9]{1,2}$" ), // Gerber inner layer file
wxT( "^.*\\.odt$" ),
wxT( "^.*\\.sxw$" ),
wxT( "^.*\\.htm$" ),
......
This diff is collapsed.
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