Gerbview: more about apertures macros and draw funtions.
This commit is contained in:
parent
22f483e1d8
commit
659299ee8f
|
@ -1163,6 +1163,9 @@ static bool IsGRSPolyDrawable( EDA_Rect* ClipBox, int n, wxPoint Points[] )
|
||||||
if( ! ClipBox )
|
if( ! ClipBox )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if( n <= 0 )
|
||||||
|
return false;
|
||||||
|
|
||||||
int Xmin, Xmax, Ymin, Ymax;
|
int Xmin, Xmax, Ymin, Ymax;
|
||||||
|
|
||||||
Xmin = Xmax = Points[0].x;
|
Xmin = Xmax = Points[0].x;
|
||||||
|
|
|
@ -15,6 +15,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
###
|
###
|
||||||
set(GERBVIEW_SRCS
|
set(GERBVIEW_SRCS
|
||||||
block.cpp
|
block.cpp
|
||||||
|
class_aperture_macro.cpp
|
||||||
class_GERBER.cpp
|
class_GERBER.cpp
|
||||||
class_gerber_draw_item.cpp
|
class_gerber_draw_item.cpp
|
||||||
class_gerbview_layer_widget.cpp
|
class_gerbview_layer_widget.cpp
|
||||||
|
|
|
@ -49,6 +49,7 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( BOARD_ITEM* aParent ) :
|
||||||
m_Shape = GBR_SEGMENT;
|
m_Shape = GBR_SEGMENT;
|
||||||
m_Flashed = false;
|
m_Flashed = false;
|
||||||
m_DCode = 0;
|
m_DCode = 0;
|
||||||
|
m_UnitsMetric = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,6 +71,7 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( const GERBER_DRAW_ITEM& aSource ) :
|
||||||
m_Flashed = aSource.m_Flashed;
|
m_Flashed = aSource.m_Flashed;
|
||||||
m_DCode = aSource.m_DCode;
|
m_DCode = aSource.m_DCode;
|
||||||
m_PolyCorners = aSource.m_PolyCorners;
|
m_PolyCorners = aSource.m_PolyCorners;
|
||||||
|
m_UnitsMetric = aSource.m_UnitsMetric;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -176,7 +178,7 @@ bool GERBER_DRAW_ITEM::Save( FILE* aFile ) const
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
|
void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode,
|
||||||
const wxPoint& aOffset )
|
const wxPoint& aOffset )
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
{
|
{
|
||||||
|
@ -203,9 +205,9 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
|
||||||
|
|
||||||
color = brd->GetLayerColor( GetLayer() );
|
color = brd->GetLayerColor( GetLayer() );
|
||||||
|
|
||||||
if( draw_mode & GR_SURBRILL )
|
if( aDrawMode & GR_SURBRILL )
|
||||||
{
|
{
|
||||||
if( draw_mode & GR_AND )
|
if( aDrawMode & GR_AND )
|
||||||
color &= ~HIGHT_LIGHT_FLAG;
|
color &= ~HIGHT_LIGHT_FLAG;
|
||||||
else
|
else
|
||||||
color |= HIGHT_LIGHT_FLAG;
|
color |= HIGHT_LIGHT_FLAG;
|
||||||
|
@ -214,7 +216,7 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
|
||||||
color = ColorRefs[color & MASKCOLOR].m_LightColor;
|
color = ColorRefs[color & MASKCOLOR].m_LightColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
GRSetDrawMode( DC, draw_mode );
|
GRSetDrawMode( aDC, aDrawMode );
|
||||||
|
|
||||||
isFilled = DisplayOpt.DisplayPcbTrackFill ? true : false;
|
isFilled = DisplayOpt.DisplayPcbTrackFill ? true : false;
|
||||||
|
|
||||||
|
@ -224,7 +226,7 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
|
||||||
isFilled = (g_DisplayPolygonsModeSketch == false);
|
isFilled = (g_DisplayPolygonsModeSketch == false);
|
||||||
if( m_Flags & DRAW_ERASED )
|
if( m_Flags & DRAW_ERASED )
|
||||||
isFilled = true;
|
isFilled = true;
|
||||||
DrawGbrPoly( &panel->m_ClipBox, DC, color, aOffset, isFilled );
|
DrawGbrPoly( &aPanel->m_ClipBox, aDC, color, aOffset, isFilled );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GBR_CIRCLE:
|
case GBR_CIRCLE:
|
||||||
|
@ -236,14 +238,14 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
|
||||||
if( !isFilled )
|
if( !isFilled )
|
||||||
{
|
{
|
||||||
// draw the border of the pen's path using two circles, each as narrow as possible
|
// draw the border of the pen's path using two circles, each as narrow as possible
|
||||||
GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y,
|
GRCircle( &aPanel->m_ClipBox, aDC, m_Start.x, m_Start.y,
|
||||||
radius - halfPenWidth, 0, color );
|
radius - halfPenWidth, 0, color );
|
||||||
GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y,
|
GRCircle( &aPanel->m_ClipBox, aDC, m_Start.x, m_Start.y,
|
||||||
radius + halfPenWidth, 0, color );
|
radius + halfPenWidth, 0, color );
|
||||||
}
|
}
|
||||||
else // Filled mode
|
else // Filled mode
|
||||||
{
|
{
|
||||||
GRCircle( &panel->m_ClipBox, DC, m_Start.x, m_Start.y,
|
GRCircle( &aPanel->m_ClipBox, aDC, m_Start.x, m_Start.y,
|
||||||
radius, m_Size.x, color );
|
radius, m_Size.x, color );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -251,13 +253,13 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
|
||||||
case GBR_ARC:
|
case GBR_ARC:
|
||||||
if( !isFilled )
|
if( !isFilled )
|
||||||
{
|
{
|
||||||
GRArc1( &panel->m_ClipBox, DC, m_Start.x, m_Start.y,
|
GRArc1( &aPanel->m_ClipBox, aDC, m_Start.x, m_Start.y,
|
||||||
m_End.x, m_End.y,
|
m_End.x, m_End.y,
|
||||||
m_ArcCentre.x, m_ArcCentre.y, 0, color );
|
m_ArcCentre.x, m_ArcCentre.y, 0, color );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GRArc1( &panel->m_ClipBox, DC, m_Start.x, m_Start.y,
|
GRArc1( &aPanel->m_ClipBox, aDC, m_Start.x, m_Start.y,
|
||||||
m_End.x, m_End.y,
|
m_End.x, m_End.y,
|
||||||
m_ArcCentre.x, m_ArcCentre.y,
|
m_ArcCentre.x, m_ArcCentre.y,
|
||||||
m_Size.x, color );
|
m_Size.x, color );
|
||||||
|
@ -268,17 +270,18 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
|
||||||
case GBR_SPOT_RECT:
|
case GBR_SPOT_RECT:
|
||||||
case GBR_SPOT_OVAL:
|
case GBR_SPOT_OVAL:
|
||||||
case GBR_SPOT_POLY:
|
case GBR_SPOT_POLY:
|
||||||
|
case GBR_SPOT_MACRO:
|
||||||
isFilled = DisplayOpt.DisplayPadFill ? true : false;
|
isFilled = DisplayOpt.DisplayPadFill ? true : false;
|
||||||
d_codeDescr->DrawFlashedShape( &panel->m_ClipBox, DC, color,
|
d_codeDescr->DrawFlashedShape( this, &aPanel->m_ClipBox, aDC, color,
|
||||||
m_Start, isFilled );
|
m_Start, isFilled );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GBR_SEGMENT:
|
case GBR_SEGMENT:
|
||||||
if( !isFilled )
|
if( !isFilled )
|
||||||
GRCSegm( &panel->m_ClipBox, DC, m_Start.x, m_Start.y,
|
GRCSegm( &aPanel->m_ClipBox, aDC, m_Start.x, m_Start.y,
|
||||||
m_End.x, m_End.y, m_Size.x, color );
|
m_End.x, m_End.y, m_Size.x, color );
|
||||||
else
|
else
|
||||||
GRFillCSegm( &panel->m_ClipBox, DC, m_Start.x,
|
GRFillCSegm( &aPanel->m_ClipBox, aDC, m_Start.x,
|
||||||
m_Start.y, m_End.x, m_End.y, m_Size.x, color );
|
m_Start.y, m_End.x, m_End.y, m_Size.x, color );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "base_struct.h"
|
#include "base_struct.h"
|
||||||
|
#include "class_board_item.h"
|
||||||
|
|
||||||
/* Shapes id for basic shapes ( .m_Shape member ) */
|
/* Shapes id for basic shapes ( .m_Shape member ) */
|
||||||
enum Gbr_Basic_Shapes {
|
enum Gbr_Basic_Shapes {
|
||||||
|
@ -57,6 +58,8 @@ private:
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
bool m_UnitsMetric; /* store here the gerber units (inch/mm).
|
||||||
|
* Used only to calculate aperture macros shapes sizes */
|
||||||
int m_Shape; // Shape and type of this gerber item
|
int m_Shape; // Shape and type of this gerber item
|
||||||
wxPoint m_Start; // Line or arc start point or position of the shape
|
wxPoint m_Start; // Line or arc start point or position of the shape
|
||||||
// for flashed items
|
// for flashed items
|
||||||
|
|
|
@ -96,10 +96,11 @@ const wxChar* D_CODE::ShowApertureType( APERTURE_T aType )
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Function Read_D_Code_File
|
/** Function Read_D_Code_File
|
||||||
* Can be useful only with old RS274D Gerber file format.
|
* Can be useful only with old RS274D Gerber file format.
|
||||||
* Is not needed with RS274X files format.
|
* Is not needed with RS274X files format.
|
||||||
* These files need an auxiliary DCode file description. Ther is no defined file format for this.
|
* These files need an auxiliary DCode file description. There is no defined file format for this.
|
||||||
* This function read a file format I needed a long time ago.
|
* This function read a file format I needed a long time ago.
|
||||||
* reads in a dcode file assuming ALSPCB file format with ';' indicating comments.
|
* reads in a dcode file assuming ALSPCB file format with ';' indicating comments.
|
||||||
* Format is like CSV but with optional ';' delineated comments:
|
* Format is like CSV but with optional ';' delineated comments:
|
||||||
|
@ -165,7 +166,7 @@ int WinEDA_GerberFrame::Read_D_Code_File( const wxString& D_Code_FullFileName )
|
||||||
if( ii >= 6 ) /* valeurs en mils */
|
if( ii >= 6 ) /* valeurs en mils */
|
||||||
{
|
{
|
||||||
sscanf( line, "%d,%d,%d,%d,%d,%d,%d", &ii,
|
sscanf( line, "%d,%d,%d,%d,%d,%d,%d", &ii,
|
||||||
&dimH, &dimV, &drill, &dummy, &dummy, &type_outil );
|
&dimH, &dimV, &drill, &dummy, &dummy, &type_outil );
|
||||||
|
|
||||||
dimH = wxRound( dimH * dcode_scale );
|
dimH = wxRound( dimH * dcode_scale );
|
||||||
dimV = wxRound( dimV * dcode_scale );
|
dimV = wxRound( dimV * dcode_scale );
|
||||||
|
@ -279,7 +280,7 @@ void WinEDA_GerberFrame::CopyDCodesSizeToItems()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
wxMessageBox( wxT("WinEDA_GerberFrame::CopyDCodesSizeToItems() error" ) );
|
wxMessageBox( wxT( "WinEDA_GerberFrame::CopyDCodesSizeToItems() error" ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -291,15 +292,18 @@ void WinEDA_GerberFrame::CopyDCodesSizeToItems()
|
||||||
* Draw the dcode shape for flashed items.
|
* Draw the dcode shape for flashed items.
|
||||||
* When an item is flashed, the DCode shape is the shape of the item
|
* When an item is flashed, the DCode shape is the shape of the item
|
||||||
*/
|
*/
|
||||||
void D_CODE::DrawFlashedShape( EDA_Rect* aClipBox, wxDC* aDC, int aColor,
|
void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent,
|
||||||
wxPoint aShapePos, bool aFilledShape )
|
EDA_Rect* aClipBox, wxDC* aDC, int aColor,
|
||||||
|
wxPoint aShapePos, bool aFilledShape )
|
||||||
{
|
{
|
||||||
int radius;
|
int radius;
|
||||||
|
|
||||||
switch( m_Shape )
|
switch( m_Shape )
|
||||||
{
|
{
|
||||||
|
case APT_MACRO:
|
||||||
|
GetMacro()->DrawApertureMacroShape( aParent, aClipBox, aDC, aColor, aShapePos, aFilledShape);
|
||||||
|
break;
|
||||||
|
|
||||||
case APT_MACRO: // TODO: current a round shape
|
|
||||||
case APT_CIRCLE:
|
case APT_CIRCLE:
|
||||||
radius = m_Size.x >> 1;
|
radius = m_Size.x >> 1;
|
||||||
if( !aFilledShape )
|
if( !aFilledShape )
|
||||||
|
@ -427,7 +431,7 @@ void D_CODE::DrawFlashedPolygon( EDA_Rect* aClipBox, wxDC* aDC,
|
||||||
static void addHoleToPolygon( std::vector<wxPoint>& aBuffer,
|
static void addHoleToPolygon( std::vector<wxPoint>& aBuffer,
|
||||||
APERTURE_DEF_HOLETYPE aHoleShape,
|
APERTURE_DEF_HOLETYPE aHoleShape,
|
||||||
wxSize aSize,
|
wxSize aSize,
|
||||||
wxPoint aAnchorPos );
|
wxPoint aAnchorPos );
|
||||||
|
|
||||||
/** function ConvertShapeToPolygon
|
/** function ConvertShapeToPolygon
|
||||||
* convert a shape to an equivalent polygon.
|
* convert a shape to an equivalent polygon.
|
||||||
|
@ -439,6 +443,7 @@ void D_CODE::ConvertShapeToPolygon()
|
||||||
{
|
{
|
||||||
wxPoint initialpos;
|
wxPoint initialpos;
|
||||||
wxPoint currpos;;
|
wxPoint currpos;;
|
||||||
|
|
||||||
m_PolyCorners.clear();
|
m_PolyCorners.clear();
|
||||||
|
|
||||||
switch( m_Shape )
|
switch( m_Shape )
|
||||||
|
@ -530,6 +535,7 @@ void D_CODE::ConvertShapeToPolygon()
|
||||||
case APT_POLYGON:
|
case APT_POLYGON:
|
||||||
currpos.x = m_Size.x >> 1; // first point is on X axis
|
currpos.x = m_Size.x >> 1; // first point is on X axis
|
||||||
initialpos = currpos;
|
initialpos = currpos;
|
||||||
|
|
||||||
// rs274x said: m_EdgesCount = 3 ... 12
|
// rs274x said: m_EdgesCount = 3 ... 12
|
||||||
if( m_EdgesCount < 3 )
|
if( m_EdgesCount < 3 )
|
||||||
m_EdgesCount = 3;
|
m_EdgesCount = 3;
|
||||||
|
@ -541,15 +547,16 @@ void D_CODE::ConvertShapeToPolygon()
|
||||||
RotatePoint( &currpos, ii * 3600 / m_EdgesCount );
|
RotatePoint( &currpos, ii * 3600 / m_EdgesCount );
|
||||||
m_PolyCorners.push_back( currpos );
|
m_PolyCorners.push_back( currpos );
|
||||||
}
|
}
|
||||||
|
|
||||||
addHoleToPolygon( m_PolyCorners, m_DrillShape, m_Drill, initialpos );
|
addHoleToPolygon( m_PolyCorners, m_DrillShape, m_Drill, initialpos );
|
||||||
if( m_Rotation ) // vertical oval, rotate polygon.
|
if( m_Rotation ) // vertical oval, rotate polygon.
|
||||||
{
|
{
|
||||||
int angle = wxRound( m_Rotation*10 );
|
int angle = wxRound( m_Rotation * 10 );
|
||||||
for( unsigned jj = 0; jj < m_PolyCorners.size(); jj++ )
|
for( unsigned jj = 0; jj < m_PolyCorners.size(); jj++ )
|
||||||
{
|
{
|
||||||
// Remember the Y axis is from top to bottom when draw items.
|
// Remember the Y axis is from top to bottom when draw items.
|
||||||
RotatePoint( &m_PolyCorners[jj], -angle );
|
RotatePoint( &m_PolyCorners[jj], -angle );
|
||||||
NEGATE(m_PolyCorners[jj].y);
|
NEGATE( m_PolyCorners[jj].y );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -561,6 +568,7 @@ void D_CODE::ConvertShapeToPolygon()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// The helper function for D_CODE::ConvertShapeToPolygon().
|
// The helper function for D_CODE::ConvertShapeToPolygon().
|
||||||
// Add a hole to a polygon
|
// Add a hole to a polygon
|
||||||
static void addHoleToPolygon( std::vector<wxPoint>& aBuffer,
|
static void addHoleToPolygon( std::vector<wxPoint>& aBuffer,
|
||||||
|
@ -569,6 +577,7 @@ static void addHoleToPolygon( std::vector<wxPoint>& aBuffer,
|
||||||
wxPoint aAnchorPos )
|
wxPoint aAnchorPos )
|
||||||
{
|
{
|
||||||
wxPoint currpos;
|
wxPoint currpos;
|
||||||
|
|
||||||
if( aHoleShape == APT_DEF_ROUND_HOLE ) // build a round hole
|
if( aHoleShape == APT_DEF_ROUND_HOLE ) // build a round hole
|
||||||
{
|
{
|
||||||
for( int ii = 0; ii <= SEGS_CNT; ii++ )
|
for( int ii = 0; ii <= SEGS_CNT; ii++ )
|
||||||
|
@ -579,9 +588,9 @@ static void addHoleToPolygon( std::vector<wxPoint>& aBuffer,
|
||||||
aBuffer.push_back( currpos );
|
aBuffer.push_back( currpos );
|
||||||
}
|
}
|
||||||
|
|
||||||
aBuffer.push_back( aAnchorPos ); // link to outline
|
aBuffer.push_back( aAnchorPos ); // link to outline
|
||||||
}
|
}
|
||||||
if( aHoleShape == APT_DEF_RECT_HOLE ) // Create rectangular hole
|
if( aHoleShape == APT_DEF_RECT_HOLE ) // Create rectangular hole
|
||||||
{
|
{
|
||||||
currpos.x = aSize.x / 2;
|
currpos.x = aSize.x / 2;
|
||||||
currpos.y = aSize.y / 2;
|
currpos.y = aSize.y / 2;
|
||||||
|
@ -593,7 +602,7 @@ static void addHoleToPolygon( std::vector<wxPoint>& aBuffer,
|
||||||
currpos.x += aSize.x;
|
currpos.x += aSize.x;
|
||||||
aBuffer.push_back( currpos );
|
aBuffer.push_back( currpos );
|
||||||
currpos.y += aSize.y;
|
currpos.y += aSize.y;
|
||||||
aBuffer.push_back( currpos ); // close hole
|
aBuffer.push_back( currpos ); // close hole
|
||||||
aBuffer.push_back( aAnchorPos ); // link to outline
|
aBuffer.push_back( aAnchorPos ); // link to outline
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
134
gerbview/dcode.h
134
gerbview/dcode.h
|
@ -2,6 +2,31 @@
|
||||||
/* dcode.h */
|
/* dcode.h */
|
||||||
/**************/
|
/**************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 1992-2010 Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
|
||||||
|
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||||
|
* Copyright (C) 1992-2010 Kicad Developers, see change_log.txt for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef _DCODE_H_
|
#ifndef _DCODE_H_
|
||||||
#define _DCODE_H_
|
#define _DCODE_H_
|
||||||
|
|
||||||
|
@ -9,7 +34,7 @@
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include "base_struct.h"
|
#include "base_struct.h"
|
||||||
|
class GERBER_DRAW_ITEM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum APERTURE_T
|
* Enum APERTURE_T
|
||||||
|
@ -42,6 +67,7 @@ enum APERTURE_DEF_HOLETYPE {
|
||||||
#define LAST_DCODE 999
|
#define LAST_DCODE 999
|
||||||
#define TOOLS_MAX_COUNT (LAST_DCODE + 1)
|
#define TOOLS_MAX_COUNT (LAST_DCODE + 1)
|
||||||
|
|
||||||
|
class APERTURE_MACRO;
|
||||||
class D_CODE;
|
class D_CODE;
|
||||||
|
|
||||||
|
|
||||||
|
@ -97,91 +123,8 @@ private:
|
||||||
// not used.
|
// not used.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enum AM_PRIMITIVE_ID
|
|
||||||
* is the set of all "aperture macro primitives" (primitive numbers). See
|
|
||||||
* Table 3 in http://gerbv.sourceforge.net/docs/rs274xrevd_e.pdf
|
|
||||||
* aperture macro primitives are basic shapes which can be combined to create a complex shape
|
|
||||||
* This complex shape is flashed.
|
|
||||||
*/
|
|
||||||
enum AM_PRIMITIVE_ID {
|
|
||||||
AMP_CIRCLE = 1, // Circle. (diameter and position)
|
|
||||||
AMP_LINE2 = 2, // Line with rectangle ends. (Width, start and end pos + rotation)
|
|
||||||
AMP_LINE20 = 20, // Same as AMP_LINE2
|
|
||||||
AMP_LINE_CENTER = 21, // Rectangle. (height, width and center pos + rotation)
|
|
||||||
AMP_LINE_LOWER_LEFT = 22, // Rectangle. (height, width and lrft bottom corner pos + rotation)
|
|
||||||
AMP_EOF = 3, // End Of File marquer: not really a shape
|
|
||||||
AMP_OUTLINE = 4, // Free polyline (n corners + rotation)
|
|
||||||
AMP_POLYGON = 5, // Closed regular polygon(diameter, number of vertices (3 to 10), rotation)
|
|
||||||
AMP_MOIRE = 6, // A cross hair with n concentric circles + rotation
|
|
||||||
AMP_THERMAL = 7, // Thermal shape (pos, outer and inner dioameter, cross hair thickness + rotation)
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
typedef std::vector<DCODE_PARAM> DCODE_PARAMS;
|
typedef std::vector<DCODE_PARAM> DCODE_PARAMS;
|
||||||
|
|
||||||
/**
|
|
||||||
* Struct AM_PRIMITIVE
|
|
||||||
* holds an aperture macro primitive as given in Table 3 of
|
|
||||||
* http://gerbv.sourceforge.net/docs/rs274xrevd_e.pdf
|
|
||||||
*/
|
|
||||||
struct AM_PRIMITIVE
|
|
||||||
{
|
|
||||||
AM_PRIMITIVE_ID primitive_id; ///< The primitive type
|
|
||||||
DCODE_PARAMS params; ///< A sequence of parameters used by
|
|
||||||
// the primitive
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function GetExposure
|
|
||||||
* returns the first parameter in integer form. Some but not all primitives
|
|
||||||
* use the first parameter as an exposure control.
|
|
||||||
*/
|
|
||||||
int GetExposure() const
|
|
||||||
{
|
|
||||||
// No D_CODE* for GetValue()
|
|
||||||
wxASSERT( params.size() && params[0].IsImmediate() );
|
|
||||||
return (int) params[0].GetValue( NULL );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
typedef std::vector<AM_PRIMITIVE> AM_PRIMITIVES;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Struct APERTURE_MACRO
|
|
||||||
* helps support the "aperture macro" defined within standard RS274X.
|
|
||||||
*/
|
|
||||||
struct APERTURE_MACRO
|
|
||||||
{
|
|
||||||
wxString name; ///< The name of the aperture macro
|
|
||||||
AM_PRIMITIVES primitives; ///< A sequence of AM_PRIMITIVEs
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Struct APERTURE_MACRO_less_than
|
|
||||||
* is used by std:set<APERTURE_MACRO> instantiation which uses
|
|
||||||
* APERTURE_MACRO.name as its key.
|
|
||||||
*/
|
|
||||||
struct APERTURE_MACRO_less_than
|
|
||||||
{
|
|
||||||
// a "less than" test on two APERTURE_MACROs (.name wxStrings)
|
|
||||||
bool operator()( const APERTURE_MACRO& am1, const APERTURE_MACRO& am2 ) const
|
|
||||||
{
|
|
||||||
return am1.name.Cmp( am2.name ) < 0; // case specific wxString compare
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type APERTURE_MACRO_SET
|
|
||||||
* is a sorted collection of APERTURE_MACROS whose key is the name field in
|
|
||||||
* the APERTURE_MACRO.
|
|
||||||
*/
|
|
||||||
typedef std::set<APERTURE_MACRO, APERTURE_MACRO_less_than> APERTURE_MACRO_SET;
|
|
||||||
typedef std::pair<APERTURE_MACRO_SET::iterator, bool> APERTURE_MACRO_SET_PAIR;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class D_CODE
|
* Class D_CODE
|
||||||
|
@ -206,15 +149,15 @@ class D_CODE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxSize m_Size; /* Horizontal and vertical dimensions. */
|
wxSize m_Size; /* Horizontal and vertical dimensions. */
|
||||||
APERTURE_T m_Shape; /* shape ( Line, rectangle, circle , oval .. ) */
|
APERTURE_T m_Shape; /* shape ( Line, rectangle, circle , oval .. ) */
|
||||||
int m_Num_Dcode; /* D code ( >= 10 ) */
|
int m_Num_Dcode; /* D code ( >= 10 ) */
|
||||||
wxSize m_Drill; /* dimension of the hole (if any) */
|
wxSize m_Drill; /* dimension of the hole (if any) */
|
||||||
APERTURE_DEF_HOLETYPE m_DrillShape; /* shape of the hole (0 = no hole, round = 1, rect = 2) */
|
APERTURE_DEF_HOLETYPE m_DrillShape; /* shape of the hole (0 = no hole, round = 1, rect = 2) */
|
||||||
double m_Rotation; /* shape rotation in degrees */
|
double m_Rotation; /* shape rotation in degrees */
|
||||||
int m_EdgesCount; /* in apeture definition Polygon only: number of edges for the polygon */
|
int m_EdgesCount; /* in apeture definition Polygon only: number of edges for the polygon */
|
||||||
bool m_InUse; /* FALSE if not used */
|
bool m_InUse; /* FALSE if not used */
|
||||||
bool m_Defined; /* FALSE if not defined */
|
bool m_Defined; /* FALSE if not defined */
|
||||||
wxString m_SpecialDescr;
|
wxString m_SpecialDescr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -251,8 +194,9 @@ public:
|
||||||
* Draw the dcode shape for flashed items.
|
* Draw the dcode shape for flashed items.
|
||||||
* When an item is flashed, the DCode shape is the shape of the item
|
* When an item is flashed, the DCode shape is the shape of the item
|
||||||
*/
|
*/
|
||||||
void DrawFlashedShape( EDA_Rect* aClipBox, wxDC* aDC, int aColor,
|
void DrawFlashedShape( GERBER_DRAW_ITEM* aParent,
|
||||||
wxPoint aShapePos, bool aFilledShape );
|
EDA_Rect* aClipBox, wxDC* aDC, int aColor,
|
||||||
|
wxPoint aShapePos, bool aFilledShape );
|
||||||
|
|
||||||
/** function DrawFlashedPolygon
|
/** function DrawFlashedPolygon
|
||||||
* a helper function used id ::Draw to draw the polygon stored ion m_PolyCorners
|
* a helper function used id ::Draw to draw the polygon stored ion m_PolyCorners
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include "dcode.h"
|
#include "dcode.h"
|
||||||
|
#include "class_gerber_draw_item.h"
|
||||||
|
#include "class_aperture_macro.h"
|
||||||
|
|
||||||
class WinEDA_GerberFrame;
|
class WinEDA_GerberFrame;
|
||||||
class BOARD;
|
class BOARD;
|
||||||
|
|
|
@ -631,48 +631,15 @@ wxPoint GERBER::ReadIJCoord( char*& Text )
|
||||||
}
|
}
|
||||||
current_coord = atoi( line );
|
current_coord = atoi( line );
|
||||||
double real_scale = 1.0;
|
double real_scale = 1.0;
|
||||||
|
if( fmt_scale < 0 || fmt_scale > 9 )
|
||||||
|
fmt_scale = 4; // select scale 1.0
|
||||||
|
|
||||||
switch( fmt_scale )
|
double scale_list[10] =
|
||||||
{
|
{ 10000.0, 1000.0, 100.0, 10.0,
|
||||||
case 0:
|
1,
|
||||||
real_scale = 10000.0;
|
0.1, 0.01, 0.001, 0.0001, 0.00001
|
||||||
break;
|
};
|
||||||
|
real_scale = scale_list[fmt_scale];
|
||||||
case 1:
|
|
||||||
real_scale = 1000.0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
real_scale = 100.0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
real_scale = 10.0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
|
||||||
real_scale = 0.1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 6:
|
|
||||||
real_scale = 0.01;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 7:
|
|
||||||
real_scale = 0.001;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 8:
|
|
||||||
real_scale = 0.0001;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 9:
|
|
||||||
real_scale = 0.00001;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( m_GerbMetric )
|
if( m_GerbMetric )
|
||||||
real_scale = real_scale / 25.4;
|
real_scale = real_scale / 25.4;
|
||||||
|
@ -844,7 +811,7 @@ bool GERBER::Execute_G_Command( char*& text, int G_commande )
|
||||||
* Function scale
|
* Function scale
|
||||||
* converts a distance given in floating point to our deci-mils
|
* converts a distance given in floating point to our deci-mils
|
||||||
*/
|
*/
|
||||||
static int scale( double aCoord, bool isMetric )
|
int scale( double aCoord, bool isMetric )
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -863,7 +830,7 @@ static int scale( double aCoord, bool isMetric )
|
||||||
* deci-mils coordinate system.
|
* deci-mils coordinate system.
|
||||||
* @return wxPoint - The gerbview coordinate system vector.
|
* @return wxPoint - The gerbview coordinate system vector.
|
||||||
*/
|
*/
|
||||||
static wxPoint mapPt( double x, double y, bool isMetric )
|
wxPoint mapPt( double x, double y, bool isMetric )
|
||||||
{
|
{
|
||||||
wxPoint ret( scale( x, isMetric ),
|
wxPoint ret( scale( x, isMetric ),
|
||||||
scale( y, isMetric ) );
|
scale( y, isMetric ) );
|
||||||
|
@ -908,8 +875,7 @@ static bool mapExposure( int param1, bool curExposure, bool isNegative )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame,
|
bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, char*& text, int D_commande )
|
||||||
char*& text, int D_commande )
|
|
||||||
{
|
{
|
||||||
wxSize size( 15, 15 );
|
wxSize size( 15, 15 );
|
||||||
|
|
||||||
|
@ -958,6 +924,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame,
|
||||||
gbritem->m_Shape = GBR_POLYGON;
|
gbritem->m_Shape = GBR_POLYGON;
|
||||||
gbritem->SetLayer( activeLayer );
|
gbritem->SetLayer( activeLayer );
|
||||||
gbritem->m_Flashed = false;
|
gbritem->m_Flashed = false;
|
||||||
|
gbritem->m_UnitsMetric = m_GerbMetric;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch( m_Iterpolation )
|
switch( m_Iterpolation )
|
||||||
|
@ -1033,6 +1000,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame,
|
||||||
{
|
{
|
||||||
case GERB_INTERPOL_LINEAR_1X:
|
case GERB_INTERPOL_LINEAR_1X:
|
||||||
gbritem = new GERBER_DRAW_ITEM( pcb );
|
gbritem = new GERBER_DRAW_ITEM( pcb );
|
||||||
|
gbritem->m_UnitsMetric = m_GerbMetric;
|
||||||
pcb->m_Drawings.Append( gbritem );
|
pcb->m_Drawings.Append( gbritem );
|
||||||
D( printf( "R:%p\n", gbritem ); )
|
D( printf( "R:%p\n", gbritem ); )
|
||||||
fillLineGBRITEM( gbritem, dcode, activeLayer, m_PreviousPos,
|
fillLineGBRITEM( gbritem, dcode, activeLayer, m_PreviousPos,
|
||||||
|
@ -1049,6 +1017,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame,
|
||||||
case GERB_INTERPOL_ARC_NEG:
|
case GERB_INTERPOL_ARC_NEG:
|
||||||
case GERB_INTERPOL_ARC_POS:
|
case GERB_INTERPOL_ARC_POS:
|
||||||
gbritem = new GERBER_DRAW_ITEM( pcb );
|
gbritem = new GERBER_DRAW_ITEM( pcb );
|
||||||
|
gbritem->m_UnitsMetric = m_GerbMetric;
|
||||||
pcb->m_Drawings.Append( gbritem );
|
pcb->m_Drawings.Append( gbritem );
|
||||||
D( printf( "R:%p\n", gbritem ); )
|
D( printf( "R:%p\n", gbritem ); )
|
||||||
fillArcGBRITEM( gbritem, dcode, activeLayer, m_PreviousPos,
|
fillArcGBRITEM( gbritem, dcode, activeLayer, m_PreviousPos,
|
||||||
|
@ -1087,6 +1056,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame,
|
||||||
case APT_POLYGON: // flashed regular polygon
|
case APT_POLYGON: // flashed regular polygon
|
||||||
case APT_CIRCLE:
|
case APT_CIRCLE:
|
||||||
gbritem = new GERBER_DRAW_ITEM( pcb );
|
gbritem = new GERBER_DRAW_ITEM( pcb );
|
||||||
|
gbritem->m_UnitsMetric = m_GerbMetric;
|
||||||
pcb->m_Drawings.Append( gbritem );
|
pcb->m_Drawings.Append( gbritem );
|
||||||
D( printf( "R:%p\n", gbritem ); )
|
D( printf( "R:%p\n", gbritem ); )
|
||||||
fillRoundFlashGBRITEM( gbritem, dcode, activeLayer,
|
fillRoundFlashGBRITEM( gbritem, dcode, activeLayer,
|
||||||
|
@ -1099,6 +1069,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame,
|
||||||
case APT_OVAL:
|
case APT_OVAL:
|
||||||
case APT_RECT:
|
case APT_RECT:
|
||||||
gbritem = new GERBER_DRAW_ITEM( pcb );
|
gbritem = new GERBER_DRAW_ITEM( pcb );
|
||||||
|
gbritem->m_UnitsMetric = m_GerbMetric;
|
||||||
pcb->m_Drawings.Append( gbritem );
|
pcb->m_Drawings.Append( gbritem );
|
||||||
D( printf( "R:%p\n", gbritem ); )
|
D( printf( "R:%p\n", gbritem ); )
|
||||||
fillOvalOrRectFlashGBRITEM( gbritem, dcode, activeLayer,
|
fillOvalOrRectFlashGBRITEM( gbritem, dcode, activeLayer,
|
||||||
|
@ -1112,7 +1083,15 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame,
|
||||||
{
|
{
|
||||||
APERTURE_MACRO* macro = tool->GetMacro();
|
APERTURE_MACRO* macro = tool->GetMacro();
|
||||||
wxASSERT( macro );
|
wxASSERT( macro );
|
||||||
|
#if 1
|
||||||
|
gbritem = new GERBER_DRAW_ITEM( pcb );
|
||||||
|
gbritem->m_UnitsMetric = m_GerbMetric;
|
||||||
|
pcb->m_Drawings.Append( gbritem );
|
||||||
|
fillRoundFlashGBRITEM( gbritem, dcode, activeLayer,
|
||||||
|
m_CurrentPos, size.x,
|
||||||
|
!(m_LayerNegative ^ m_ImageNegative) );
|
||||||
|
gbritem->m_Shape = GBR_SPOT_MACRO;
|
||||||
|
#else
|
||||||
// split the macro primitives up into multiple normal GBRITEM
|
// split the macro primitives up into multiple normal GBRITEM
|
||||||
// elements
|
// elements
|
||||||
for( AM_PRIMITIVES::iterator p = macro->primitives.begin();
|
for( AM_PRIMITIVES::iterator p = macro->primitives.begin();
|
||||||
|
@ -1346,6 +1325,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue