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

Gerbview code redesign

parent 3ae0df15
...@@ -4,6 +4,24 @@ KiCad ChangeLog 2010 ...@@ -4,6 +4,24 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2010-jul-27, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================
++gerbview:
Important changes:
graphic functions rewritten.
graphics items are now specific to gerbview (added a GERBER_DRAW_ITEM class)
and do not use tracks from pcbnew.
The way used to draw them is also new.
Apertures are now correctly drawn for round, oval and rectangular shapes
(with or without holes)
Aperture definition type Polygon is not yet handle.
Polygons are correctly drawn.
TODO:
Draw functions for aperture definition type Polygon.
Draw functions for aperture macros.
Work in progress.
2010-Aug-9 UPDATE Dick Hollenbeck <dick@softplc.com> 2010-Aug-9 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================ ================================================================================
++CMakeModules: ++CMakeModules:
...@@ -67,7 +85,7 @@ email address. ...@@ -67,7 +85,7 @@ email address.
2010-jul-27, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr> 2010-jul-27, UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================ ================================================================================
++all: ++all:
Updated boost to version 1.43 Updated boost to version 1.44
Added boost::polygon (experimental) Added boost::polygon (experimental)
++pcbnew: ++pcbnew:
Added experimental zone fill calculations with boost::polygon Added experimental zone fill calculations with boost::polygon
......
...@@ -58,6 +58,10 @@ int g_DrawBgColor = WHITE; ...@@ -58,6 +58,10 @@ int g_DrawBgColor = WHITE;
void ClipAndDrawFilledPoly( EDA_Rect* ClipBox, wxDC * DC, wxPoint Points[], int n ); void ClipAndDrawFilledPoly( EDA_Rect* ClipBox, wxDC * DC, wxPoint Points[], int n );
#endif #endif
static void GRSCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int width, int Color );
static void GRSFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r,
int width, int Color, int BgColor );
extern BASE_SCREEN* ActiveScreen; extern BASE_SCREEN* ActiveScreen;
...@@ -545,8 +549,8 @@ void GRSetColorPen( wxDC* DC, int Color, int width, int style ) ...@@ -545,8 +549,8 @@ void GRSetColorPen( wxDC* DC, int Color, int width, int style )
} }
if( s_DC_lastcolor != Color || if( s_DC_lastcolor != Color ||
s_DC_lastwidth != width || s_DC_lastwidth != width ||
s_DC_lastpenstyle != style || s_DC_lastpenstyle != style ||
s_DC_lastDC != DC ) s_DC_lastDC != DC )
{ {
wxPen pen; wxPen pen;
...@@ -573,8 +577,8 @@ void GRSetBrush( wxDC* DC, int Color, int fill ) ...@@ -573,8 +577,8 @@ void GRSetBrush( wxDC* DC, int Color, int fill )
if( ForceBlackPen ) if( ForceBlackPen )
Color = BLACK; Color = BLACK;
if( s_DC_lastbrushcolor != Color || if( s_DC_lastbrushcolor != Color ||
s_DC_lastbrushfill != fill || s_DC_lastbrushfill != fill ||
s_DC_lastDC != DC ) s_DC_lastDC != DC )
{ {
wxBrush DrawBrush; wxBrush DrawBrush;
...@@ -1333,6 +1337,26 @@ void GRCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int Color ) ...@@ -1333,6 +1337,26 @@ void GRCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int Color )
GRSCircle( ClipBox, DC, cx, cy, radius, 0, Color ); GRSCircle( ClipBox, DC, cx, cy, radius, 0, Color );
} }
/*
* Draw a circle in object space.
*/
void GRCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int width, int Color )
{
r = ZoomValue( r );
width = ZoomValue( width );
GRSCircle( ClipBox, DC, GRMapX( x ), GRMapY( y ), r, width, Color );
}
/*
* Draw a circle in object space.
*/
void GRCircle( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, int aColor )
{
aRadius = ZoomValue( aRadius );
aWidth = ZoomValue( aWidth );
GRSCircle( aClipBox, aDC, GRMapX( aPos.x ), GRMapY( aPos.y ), aRadius, aWidth, aColor );
}
/* /*
* Draw a filled circle, in object space. * Draw a filled circle, in object space.
...@@ -1346,6 +1370,14 @@ void GRFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, ...@@ -1346,6 +1370,14 @@ void GRFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r,
Color, BgColor ); Color, BgColor );
} }
/*
* Draw a filled circle, in object space.
*/
void GRFilledCircle( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aColor )
{
aRadius = ZoomValue( aRadius );
GRSFilledCircle( aClipBox, aDC, GRMapX( aPos.x ), GRMapY( aPos.y ), aRadius, 0, aColor, aColor );
}
/* /*
* Draw a filled circle, in drawing space. * Draw a filled circle, in drawing space.
...@@ -1377,22 +1409,6 @@ void GRSFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, ...@@ -1377,22 +1409,6 @@ void GRSFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r,
} }
/*
* Draw a circle in object space.
*/
void GRCircle( EDA_Rect* ClipBox,
wxDC* DC,
int x,
int y,
int r,
int width,
int Color )
{
r = ZoomValue( r );
width = ZoomValue( width );
GRSCircle( ClipBox, DC, GRMapX( x ), GRMapY( y ), r, width, Color );
}
/* /*
* Draw a circle in drawing space. * Draw a circle in drawing space.
......
...@@ -15,6 +15,8 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ...@@ -15,6 +15,8 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
### ###
set(GERBVIEW_SRCS set(GERBVIEW_SRCS
block.cpp block.cpp
class_GERBER.cpp
class_gerber_draw_item.cpp
class_gerbview_layer_widget.cpp class_gerbview_layer_widget.cpp
controle.cpp controle.cpp
dcode.cpp dcode.cpp
...@@ -32,7 +34,6 @@ set(GERBVIEW_SRCS ...@@ -32,7 +34,6 @@ set(GERBVIEW_SRCS
gerbview.cpp gerbview.cpp
hotkeys.cpp hotkeys.cpp
initpcb.cpp initpcb.cpp
lay2plot.cpp
locate.cpp locate.cpp
menubar.cpp menubar.cpp
onrightclick.cpp onrightclick.cpp
......
This diff is collapsed.
/** @file class_GERBER.cpp
* a GERBER class handle for a given layer info about used D_CODES and how the layer is drawn
*/
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 1992-2010 <Jean-Pierre Charras>
* 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
*/
#include "fctsys.h"
#include "common.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "macros.h"
#include "gerbview.h"
/* Format Gerber: NOTES:
* Tools and D_CODES
* tool number (identification of shapes)
* 1 to 999
*
* D_CODES:
* D01 ... D9 = action codes:
* D01 = activating light (lower pen) when di placement
* D02 = light extinction (lift pen) when di placement
* D03 Flash
* D09 = VAPE Flash
* D10 ... = Indentification Tool (Opening)
*
* For tools:
* DCode min = D10
* DCode max = 999
*/
GERBER::GERBER( int aLayer )
{
m_Layer = aLayer; // Layer Number
m_Selected_Tool = FIRST_DCODE;
ResetDefaultValues();
for( unsigned ii = 0; ii < DIM( m_Aperture_List ); ii++ )
m_Aperture_List[ii] = 0;
m_Pcb = 0;
}
GERBER::~GERBER()
{
for( unsigned ii = 0; ii < DIM( m_Aperture_List ); ii++ )
{
delete m_Aperture_List[ii];
// m_Aperture_List[ii] = NULL;
}
delete m_Pcb;
}
D_CODE* GERBER::GetDCODE( int aDCODE, bool create )
{
unsigned ndx = aDCODE - FIRST_DCODE;
if( ndx < (unsigned) DIM( m_Aperture_List ) )
{
// lazily create the D_CODE if it does not exist.
if( create )
{
if( m_Aperture_List[ndx] == NULL )
m_Aperture_List[ndx] = new D_CODE( ndx + FIRST_DCODE );
}
return m_Aperture_List[ndx];
}
return NULL;
}
APERTURE_MACRO* GERBER::FindApertureMacro( const APERTURE_MACRO& aLookup )
{
APERTURE_MACRO_SET::iterator iter = m_aperture_macros.find( aLookup );
if( iter != m_aperture_macros.end() )
{
APERTURE_MACRO* pam = (APERTURE_MACRO*) &(*iter);
return pam;
}
return NULL; // not found
}
void GERBER::ResetDefaultValues()
{
m_FileName.Empty();
m_Name = wxT( "no name" ); // Layer name
m_LayerNegative = FALSE; // TRUE = Negative Layer
m_ImageNegative = FALSE; // TRUE = Negative image
m_GerbMetric = FALSE; // FALSE = Inches, TRUE = metric
m_Relative = FALSE; // FALSE = absolute Coord, RUE =
// relative Coord
m_NoTrailingZeros = FALSE; // True: trailing zeros deleted
m_MirorA = FALSE; // True: miror / axe A (X)
m_MirorB = FALSE; // True: miror / axe B (Y)
m_Has_DCode = FALSE; // TRUE = DCodes in file (FALSE = no
// DCode->
// separate DCode file
m_Offset.x = m_Offset.y = 0; // Coord Offset
m_FmtScale.x = m_FmtScale.y = g_Default_GERBER_Format % 10;
m_FmtLen.x = m_FmtLen.y = m_FmtScale.x + (g_Default_GERBER_Format / 10);
m_LayerScale.x = m_LayerScale.y = 1.0; // scale (X and Y) this
// layer
m_Rotation = 0;
m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Linear, 90 arc, Circ.
m_360Arc_enbl = FALSE; // 360 deg circular
// interpolation disable
m_Current_Tool = 0; // Current Tool (Dcode)
// number selected
m_CommandState = 0; // gives tate of the
// stacking order analysis
m_CurrentPos.x = m_CurrentPos.y = 0; // current specified coord
// for plot
m_PreviousPos.x = m_PreviousPos.y = 0; // old current specified
// coord for plot
m_IJPos.x = m_IJPos.y = 0; // current centre coord for
// plot arcs & circles
m_Current_File = NULL; // File to read
m_FilesPtr = 0;
m_Transform[0][0] = m_Transform[1][1] = 1;
m_Transform[0][1] = m_Transform[1][0] = 0; // Rotation/mirror = Normal
m_PolygonFillMode = FALSE;
m_PolygonFillModeState = 0;
}
int GERBER::ReturnUsedDcodeNumber()
{
int count = 0;
for( unsigned ii = 0; ii < DIM( m_Aperture_List ); ii++ )
{
if( m_Aperture_List[ii] )
if( m_Aperture_List[ii]->m_InUse || m_Aperture_List[ii]->m_Defined )
++count;
}
return count;
}
void GERBER::InitToolTable()
{
for( int count = 0; count < TOOLS_MAX_COUNT; count++ )
{
if( m_Aperture_List[count] == NULL )
continue;
m_Aperture_List[count]->m_Num_Dcode = count + FIRST_DCODE;
m_Aperture_List[count]->Clear_D_CODE_Data();
}
}
This diff is collapsed.
/*******************************************************************/
/* class_gerber_draw_item.h: definitions relatives to tracks, vias and zones */
/*******************************************************************/
#ifndef CLASS_GERBER_DRAW_ITEM_H
#define CLASS_GERBER_DRAW_ITEM_H
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 1992-2010 <Jean-Pierre Charras>
* 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
*/
#include "base_struct.h"
/* Shapes id for basic shapes ( .m_Shape member ) */
enum Gbr_Basic_Shapes {
GBR_SEGMENT = 0, // usual segment : line with rounded ends
GBR_ARC, // Arcs (with rounded ends)
GBR_CIRCLE, // ring
GBR_POLYGON, // polygonal shape
GBR_SPOT_CIRCLE, // flashed shape: round shape (can have hole)
GBR_SPOT_RECT, // flashed shape: rectangular shape can have hole)
GBR_SPOT_OVAL, // flashed shape: oval shape
GBR_MACRO, // complex shape described by a macro
GBR_LAST // last value for this list
};
/***/
class GERBER_DRAW_ITEM : public BOARD_ITEM
{
// make SetNext() and SetBack() private so that they may not be called from anywhere.
// list management is done on GERBER_DRAW_ITEMs using DLIST<GERBER_DRAW_ITEM> only.
private:
void SetNext( EDA_BaseStruct* aNext ) { Pnext = aNext; }
void SetBack( EDA_BaseStruct* aBack ) { Pback = aBack; }
public:
int m_Layer;
int m_Shape; // Shape and type of this gerber item
wxPoint m_Start; // Line or arc start point or position of the shape
// for flashed items
wxPoint m_End; // Line or arc end point
wxPoint m_ArcCentre; // for arcs only: Centre of arc
std::vector <wxPoint> m_PolyCorners; // list of corners for polygons (G36 to G37 coordinates)
// or for complex shapes which are converted to polygon
wxSize m_Size; // Flashed shapes size of the shape
// Lines : m_Size.x = m_Size.y = line width
bool m_Flashed; // True for flashed items
int m_DCode; // DCode used to draw this item.
// 0 for items that do not use DCodes (polygons)
// or when unknown and normal values are 10 to 999
// values 0 to 9 can be used for special purposes
public:
GERBER_DRAW_ITEM( BOARD_ITEM* aParent );
GERBER_DRAW_ITEM( const GERBER_DRAW_ITEM& aSource );
~GERBER_DRAW_ITEM();
/**
* Function Copy
* will copy this object
* the corresponding type.
* @return - GERBER_DRAW_ITEM*
*/
GERBER_DRAW_ITEM* Copy() const;
GERBER_DRAW_ITEM* Next() const { return (GERBER_DRAW_ITEM*) Pnext; }
GERBER_DRAW_ITEM* Back() const { return (GERBER_DRAW_ITEM*) Pback; }
int ReturnMaskLayer()
{
return 1 << m_Layer;
}
/**
* Function Move
* move this object.
* @param const wxPoint& aMoveVector - the move vector for this object.
*/
void Move( const wxPoint& aMoveVector );
/**
* Function GetPosition
* returns the position of this object.
* @return const wxPoint& - The position of this object.
*/
wxPoint& GetPosition()
{
return m_Start; // it had to be start or end.
}
/**
* Function GetDcodeDescr
* returns the GetDcodeDescr of this object, or NULL.
* @return D_CODE* - a pointer to the DCode description (for flashed items).
*/
D_CODE* GetDcodeDescr();
EDA_Rect GetBoundingBox();
/* Display on screen: */
void Draw( WinEDA_DrawPanel* aPanel,
wxDC* aDC,
int aDrawMode,
const wxPoint& aOffset = ZeroOffset );
/** function DrawGbrPoly
* a helper function used id ::Draw to draw the polygon stored ion m_PolyCorners
*/
void DrawGbrPoly( EDA_Rect* aClipBox,
wxDC* aDC, int aColor,
const wxPoint& aOffset, bool aFilledShape );
/* divers */
int Shape() const { return m_Shape; }
/**
* Function DisplayInfo
* has knowledge about the frame and how and where to put status information
* about this object into the frame's message panel.
* Is virtual from EDA_BaseStruct.
* Display info about the track segment and the full track length
* @param frame A WinEDA_DrawFrame in which to print status information.
*/
void DisplayInfo( WinEDA_DrawFrame* frame );
wxString ShowGBRShape();
/**
* Function HitTest
* tests if the given wxPoint is within the bounds of this object.
* @param refPos A wxPoint to test
* @return bool - true if a hit, else false
*/
bool HitTest( const wxPoint& refPos );
/**
* Function HitTest (overlayed)
* tests if the given wxRect intersect this object.
* For now, an ending point must be inside this rect.
* @param refPos A wxPoint to test
* @return bool - true if a hit, else false
*/
bool HitTest( EDA_Rect& refArea );
/**
* Function GetClass
* returns the class name.
* @return wxString
*/
wxString GetClass() const
{
return wxT( "GERBER_DRAW_ITEM" );
}
bool Save( FILE* aFile ) const;
};
#endif /* CLASS_GERBER_DRAW_ITEM_H */
This diff is collapsed.
/**************/
/* dcode.h */
/**************/
#ifndef _DCODE_H_
#define _DCODE_H_
#include <vector>
#include <set>
#include "base_struct.h"
/**
* Enum APERTURE_T
* is the set of all gerber aperture types allowed, according to page 16 of
* http://gerbv.sourceforge.net/docs/rs274xrevd_e.pdf
*/
enum APERTURE_T
{
APT_CIRCLE = 'C',
APT_LINE = 'L',
APT_RECT = 'R',
APT_OVAL = '0',
APT_POLYGON = 'P',
APT_MACRO = 'M'
};
#define FIRST_DCODE 10
#define LAST_DCODE 999 // dcodes values are from 10 to 999
#define TOOLS_MAX_COUNT (LAST_DCODE+1)
class D_CODE;
/**
* Class DCODE_PARAM
* holds a parameter for a DCODE or an "aperture macro" as defined within
* standard RS274X. The \a value field can be a constant, i.e. "immediate"
* parameter or it may not be used if this param is going to defer to the
* referencing aperture macro. In that case, the \a index field is an index
* into the aperture macro's parameters.
*/
class DCODE_PARAM
{
public:
DCODE_PARAM() :
index(-1),
value(0.0)
{}
double GetValue( const D_CODE* aDcode ) const;
void SetValue( double aValue )
{
value = aValue;
index = -1;
}
/**
* Function IsImmediate
* tests if this DCODE_PARAM holds an immediate parameter or is a pointer
* into a parameter held by an owning D_CODE.
*/
bool IsImmediate() const { return index == -1; }
unsigned GetIndex() const
{
return (unsigned) index;
}
void SetIndex( int aIndex )
{
index = aIndex;
}
private:
int index; ///< if -1, then \a value field is an immediate value,
// else this is an index into parent's
// D_CODE.m_am_params.
double value; ///< if IsImmediate()==true then use the value, else
// 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
*/
enum AM_PRIMITIVE_ID
{
AMP_CIRCLE = 1,
AMP_LINE2 = 2,
AMP_LINE20 = 20,
AMP_LINE_CENTER = 21,
AMP_LINE_LOWER_LEFT = 22,
AMP_EOF = 3,
AMP_OUTLINE = 4,
AMP_POLYGON = 5,
AMP_MOIRE = 6,
AMP_THERMAL = 7,
};
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
* holds a gerber DCODE definition.
*/
class D_CODE
{
friend class DCODE_PARAM;
APERTURE_MACRO* m_Macro; ///< no ownership, points to
// GERBER.m_aperture_macros element
/**
* parameters used only when this D_CODE holds a reference to an aperture
* macro, and these parameters would customize the macro.
*/
DCODE_PARAMS m_am_params;
std::vector <wxPoint> m_PolyCorners; /* Polygon used to draw AMP_POLYGON shape and some other
* complex shapes which are converted to polygon
* (shapes with hole, rotated rectangles ...
*/
public:
wxSize m_Size; /* Horizontal and vertical dimensions. */
APERTURE_T m_Shape; /* shape ( Line, rectangle, circle , oval .. ) */
int m_Num_Dcode; /* D code ( >= 10 ) */
wxSize m_Drill; /* dimension of the hole (if any) */
int m_DrillShape; /* shape of the hole (round = 1, rect = 2) */
double m_Rotation; /* shape rotation in degrees */
bool m_InUse; /* FALSE if not used */
bool m_Defined; /* FALSE if not defined */
wxString m_SpecialDescr;
public:
D_CODE( int num_dcode );
~D_CODE();
void Clear_D_CODE_Data();
void AppendParam( double aValue )
{
DCODE_PARAM param;
param.SetValue( aValue );
m_am_params.push_back( param );
}
void SetMacro( APERTURE_MACRO* aMacro )
{
m_Macro = aMacro;
}
APERTURE_MACRO* GetMacro() { return m_Macro; }
/**
* Function ShowApertureType
* returns a character string telling what type of aperture type \a aType is.
* @param aType The aperture type to show.
*/
static const wxChar* ShowApertureType( APERTURE_T aType );
/** function DrawFlashedShape
* Draw the dcode shape for flashed items.
* When an item is flashed, the DCode shape is the shape of the item
*/
void DrawFlashedShape( EDA_Rect* aClipBox, wxDC* aDC, int aColor,
wxPoint aShapePos, bool aFilledShape );
/** function DrawFlashedPolygon
* a helper function used id ::Draw to draw the polygon stored ion m_PolyCorners
* Draw some Apertures shapes when they are defined as filled polygons.
* APT_POLYGON is always a polygon, but some complex shapes are also converted to
* polygons (shapes with holes, some rotated shapes)
*/
void DrawFlashedPolygon( EDA_Rect* aClipBox, wxDC* aDC, int aColor,
bool aFilled, const wxPoint& aPosition );
/** function ConvertShapeToPolygon
* convert a shape to an equivalent polygon.
* Arcs and circles are approximated by segments
* Useful when a shape is not a graphic primitive (shape with hole,
* rotated shape ... ) and cannot be easily drawn.
*/
void ConvertShapeToPolygon( );
};
inline double DCODE_PARAM::GetValue( const D_CODE* aDcode ) const
{
if( IsImmediate() )
return value;
else
{
// the first one was numbered 1, not zero, as in $1, see page 19 of spec.
unsigned ndx = GetIndex() - 1;
wxASSERT(aDcode);
// get the parameter from the aDcode
if( ndx < aDcode->m_am_params.size() )
return aDcode->m_am_params[ndx].GetValue( NULL );
else
{
wxASSERT( GetIndex()-1 < aDcode->m_am_params.size() );
return 0.0;
}
}
}
#endif // ifndef _DCODE_H_
/*********************************************/ /*********************************************/
/* Edit Track: Erase Routines */ /* Edit Track: Erase functions */
/* Drop the segment, track, and net area */
/*********************************************/ /*********************************************/
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
#include "class_drawpanel.h" //#include "class_drawpanel.h"
#include "gerbview.h" #include "gerbview.h"
#include "protos.h" #include "class_gerber_draw_item.h"
void WinEDA_GerberFrame::Delete_DCode_Items( wxDC* DC, void WinEDA_GerberFrame::Delete_DCode_Items( wxDC* DC,
...@@ -18,73 +17,22 @@ void WinEDA_GerberFrame::Delete_DCode_Items( wxDC* DC, ...@@ -18,73 +17,22 @@ void WinEDA_GerberFrame::Delete_DCode_Items( wxDC* DC,
if( dcode_value < FIRST_DCODE ) // No tool selected if( dcode_value < FIRST_DCODE ) // No tool selected
return; return;
TRACK* next; BOARD_ITEM* item = GetBoard()->m_Drawings;
for( TRACK* track = GetBoard()->m_Track; track; track = next ) BOARD_ITEM * next;
for( ; item; item = next )
{ {
next = track->Next(); next = item->Next();
GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
if( dcode_value != track->GetNet() ) if( dcode_value != gerb_item->m_DCode )
continue; continue;
if( layer_number >= 0 && layer_number != track->GetLayer() ) if( layer_number >= 0 && layer_number != gerb_item->m_Layer )
continue; continue;
Delete_Segment( DC, track ); // TODO: Delete_Item( DC, item );
} }
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
} }
/* Removes 1 segment of track.
*
* If There is evidence of new track: erase segment
* Otherwise: Delete segment under the cursor.
*/
TRACK* WinEDA_GerberFrame::Delete_Segment( wxDC* DC, TRACK* Track )
{
if( Track == NULL )
return NULL;
if( Track->m_Flags & IS_NEW ) // Trace in progress, delete the last
// segment
{
if( g_CurrentTrackList.GetCount() > 0 )
{
// Change track.
delete g_CurrentTrackList.PopBack();
if( g_CurrentTrackList.GetCount()
&& g_CurrentTrackSegment->Type() == TYPE_VIA )
{
delete g_CurrentTrackList.PopBack();
}
UpdateStatusBar();
if( g_CurrentTrackList.GetCount() == 0 )
{
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
return NULL;
}
else
{
if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
return g_CurrentTrackSegment;
}
}
return NULL;
}
Trace_Segment( GetBoard(), DrawPanel, DC, Track, GR_XOR );
DLIST<TRACK>* container = (DLIST<TRACK>*)Track->GetList();
wxASSERT( container );
container->Remove( Track );
GetScreen()->SetModify();
return NULL;
}
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "common.h" #include "common.h"
#include "pcbnew.h" #include "pcbnew.h"
TRACK* Marque_Une_Piste( BOARD* aPcb, TRACK* Marque_Une_Piste( BOARD* aPcb,
TRACK* aStartSegm, TRACK* aStartSegm,
int* aSegmCount, int* aSegmCount,
...@@ -19,3 +18,4 @@ TRACK* Marque_Une_Piste( BOARD* aPcb, ...@@ -19,3 +18,4 @@ TRACK* Marque_Une_Piste( BOARD* aPcb,
{ {
return NULL; return NULL;
} }
...@@ -53,12 +53,11 @@ void WinEDA_GerberFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) ...@@ -53,12 +53,11 @@ void WinEDA_GerberFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
DrawStruct = GerberGeneralLocateAndDisplay(); DrawStruct = GerberGeneralLocateAndDisplay();
if( DrawStruct == NULL ) if( DrawStruct == NULL )
break; break;
if( DrawStruct->Type() == TYPE_TRACK ) /* TODO:
{ Delete_Item( DC, (GERBER_DRAW_ITEM*) DrawStruct );
Delete_Segment( DC, (TRACK*) DrawStruct ); GetScreen()->SetCurItem( NULL );
GetScreen()->SetCurItem( NULL ); GetScreen()->SetModify();
GetScreen()->SetModify(); */
}
break; break;
default: default:
...@@ -85,13 +84,9 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -85,13 +84,9 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
{ {
case wxID_CUT: case wxID_CUT:
case wxID_COPY: case wxID_COPY:
case ID_POPUP_MIRROR_X_BLOCK:
case ID_POPUP_DELETE_BLOCK: case ID_POPUP_DELETE_BLOCK:
case ID_POPUP_PLACE_BLOCK: case ID_POPUP_PLACE_BLOCK:
case ID_POPUP_ZOOM_BLOCK: case ID_POPUP_ZOOM_BLOCK:
case ID_POPUP_FLIP_BLOCK:
case ID_POPUP_ROTATE_BLOCK:
case ID_POPUP_COPY_BLOCK:
break; break;
case ID_POPUP_CANCEL_CURRENT_COMMAND: case ID_POPUP_CANCEL_CURRENT_COMMAND:
...@@ -196,13 +191,6 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -196,13 +191,6 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
HandleBlockPlace( &dc ); HandleBlockPlace( &dc );
break; break;
case ID_POPUP_COPY_BLOCK:
GetScreen()->m_BlockLocate.m_Command = BLOCK_COPY;
GetScreen()->m_BlockLocate.SetMessageBlock( this );
DrawPanel->m_AutoPAN_Request = FALSE;
HandleBlockEnd( &dc );
break;
case ID_POPUP_ZOOM_BLOCK: case ID_POPUP_ZOOM_BLOCK:
GetScreen()->m_BlockLocate.m_Command = BLOCK_ZOOM; GetScreen()->m_BlockLocate.m_Command = BLOCK_ZOOM;
GetScreen()->m_BlockLocate.SetMessageBlock( this ); GetScreen()->m_BlockLocate.SetMessageBlock( this );
...@@ -216,12 +204,6 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -216,12 +204,6 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
HandleBlockEnd( &dc ); HandleBlockEnd( &dc );
break; break;
case ID_POPUP_MIRROR_X_BLOCK:
GetScreen()->m_BlockLocate.m_Command = BLOCK_MIRROR_X;
GetScreen()->m_BlockLocate.SetMessageBlock( this );
HandleBlockEnd( &dc );
break;
case ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS: case ID_GERBVIEW_POPUP_DELETE_DCODE_ITEMS:
if( gerber_layer ) if( gerber_layer )
Delete_DCode_Items( &dc, gerber_layer->m_Selected_Tool, Delete_DCode_Items( &dc, gerber_layer->m_Selected_Tool,
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "gerbview.h" #include "gerbview.h"
#include "class_board_design_settings.h" #include "class_board_design_settings.h"
#include "class_gerber_draw_item.h"
#include "protos.h" #include "protos.h"
static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, static int SavePcbFormatAscii( WinEDA_GerberFrame* frame,
...@@ -128,7 +129,6 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile, ...@@ -128,7 +129,6 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile,
int* LayerLookUpTable ) int* LayerLookUpTable )
{ {
char line[256]; char line[256];
TRACK* track;
BOARD* gerberPcb = frame->GetBoard(); BOARD* gerberPcb = frame->GetBoard();
BOARD* pcb; BOARD* pcb;
...@@ -136,10 +136,11 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile, ...@@ -136,10 +136,11 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile,
// create an image of gerber data // create an image of gerber data
pcb = new BOARD( NULL, frame ); pcb = new BOARD( NULL, frame );
BOARD_ITEM* item = gerberPcb->m_Drawings;
for( track = gerberPcb->m_Track; track; track = track->Next() ) for( ; item; item = item->Next() )
{ {
int layer = track->GetLayer(); GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
int layer = gerb_item->m_Layer;
int pcb_layer_number = LayerLookUpTable[layer]; int pcb_layer_number = LayerLookUpTable[layer];
if( pcb_layer_number < 0 || pcb_layer_number > LAST_NO_COPPER_LAYER ) if( pcb_layer_number < 0 || pcb_layer_number > LAST_NO_COPPER_LAYER )
continue; continue;
...@@ -149,17 +150,17 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile, ...@@ -149,17 +150,17 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile,
DRAWSEGMENT* drawitem = new DRAWSEGMENT( pcb, TYPE_DRAWSEGMENT ); DRAWSEGMENT* drawitem = new DRAWSEGMENT( pcb, TYPE_DRAWSEGMENT );
drawitem->SetLayer( pcb_layer_number ); drawitem->SetLayer( pcb_layer_number );
drawitem->m_Start = track->m_Start; drawitem->m_Start = gerb_item->m_Start;
drawitem->m_End = track->m_End; drawitem->m_End = gerb_item->m_End;
drawitem->m_Width = track->m_Width; drawitem->m_Width = gerb_item->m_Size.x;
if( track->m_Shape == S_ARC ) if( gerb_item->m_Shape == GBR_ARC )
{ {
double cx = track->m_Param; double cx = gerb_item->m_ArcCentre.x;
double cy = track->GetSubNet(); double cy = gerb_item->m_ArcCentre.y;
double a = atan2( track->m_Start.y - cy, double a = atan2( gerb_item->m_Start.y - cy,
track->m_Start.x - cx ); gerb_item->m_Start.x - cx );
double b = atan2( track->m_End.y - cy, track->m_End.x - cx ); double b = atan2( gerb_item->m_End.y - cy, gerb_item->m_End.x - cx );
drawitem->m_Shape = S_ARC; drawitem->m_Shape = S_ARC;
drawitem->m_Angle = (int) fmod( drawitem->m_Angle = (int) fmod(
...@@ -175,34 +176,28 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile, ...@@ -175,34 +176,28 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile,
TRACK* newtrack; TRACK* newtrack;
// replace spots with vias when possible // replace spots with vias when possible
if( track->m_Shape == S_SPOT_CIRCLE if( gerb_item->m_Shape == GBR_SPOT_CIRCLE
|| track->m_Shape == S_SPOT_RECT || gerb_item->m_Shape == GBR_SPOT_RECT
|| track->m_Shape == S_SPOT_OVALE ) || gerb_item->m_Shape == GBR_SPOT_OVAL )
{ {
newtrack = new SEGVIA( (const SEGVIA &) * track ); newtrack = new SEGVIA( pcb );
// A spot is found, and can be a via: change it to via, and // A spot is found, and can be a via: change it to via, and
// delete other // delete other
// spots at same location // spots at same location
newtrack->m_Shape = VIA_THROUGH; newtrack->m_Shape = VIA_THROUGH;
newtrack->SetLayer( 0x0F ); // Layers are 0 to 15 (Cu/Cmp) newtrack->SetLayer( 0x0F ); // Layers are 0 to 15 (Cu/Cmp)
newtrack->SetDrillDefault(); newtrack->SetDrillDefault();
newtrack->m_Start = newtrack->m_End = gerb_item->m_Start;
// Compute the via position from track position ( Via position newtrack->m_Width = (gerb_item->m_Size.x + gerb_item->m_Size.y) / 2;
// is the
// position of the middle of the track segment )
newtrack->m_Start.x =
(newtrack->m_Start.x + newtrack->m_End.x) / 2;
newtrack->m_Start.y =
(newtrack->m_Start.y + newtrack->m_End.y) / 2;
newtrack->m_End = newtrack->m_Start;
} }
else // a true TRACK else // a true TRACK
{ {
newtrack = track->Copy(); newtrack = new TRACK( pcb );
newtrack->SetLayer( pcb_layer_number ); newtrack->SetLayer( pcb_layer_number );
newtrack->m_Start = gerb_item->m_Start;
newtrack->m_End = gerb_item->m_End;
newtrack->m_Width = gerb_item->m_Size.x;
} }
pcb->Add( newtrack ); pcb->Add( newtrack );
...@@ -210,7 +205,7 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile, ...@@ -210,7 +205,7 @@ static int SavePcbFormatAscii( WinEDA_GerberFrame* frame, FILE* aFile,
} }
// delete redundant vias // delete redundant vias
for( track = pcb->m_Track; track; track = track->Next() ) for( TRACK * track = pcb->m_Track; track; track = track->Next() )
{ {
if( track->m_Shape != VIA_THROUGH ) if( track->m_Shape != VIA_THROUGH )
continue; continue;
......
G04 Test flashing of circular apertures*
G04 Four groups of circular apertures are arranged in a square*
G04 Handcoded by Julian Lamb *
%MOIN*%
%FSLAX23Y23*%
%ADD10C,0.050*%
%ADD11C,0.050X0.025*%
%ADD12C,0.050X0.025X0.030*%
G04 No hole, centered at 0,0 *
G54D10*
X0Y0D03*
G04 Round hole, centered at 0.1,0 *
G54D11*
X00100Y0D03*
G04 Square hole, centered at 0,0.1 *
G54D12*
X0Y00100D03*
G04 Two, with round holes, slightly overlapping, centered at 0.1,0.1 *
G54D11*
X00100Y00090D03*
X00100Y00110D03*
M02*
G04 Test flashing of obround apertures*
G04 Four groups of obround apertures are arranged in a square*
G04 Handcoded by Julian Lamb *
%MOIN*%
%FSLAX23Y23*%
%ADD10O,0.050X0.080*%
%ADD11O,0.080X0.050X0.025*%
%ADD12O,0.050X0.025X0.025X0.0150*%
G04 No hole, centered at 0,0 *
G54D10*
X0Y0D03*
G04 Round hole, centered at 0.1,0 *
G54D11*
X00100Y0D03*
G04 Square hole, centered at 0,0.1 *
G54D12*
X0Y00100D03*
G04 Two, with round holes, slightly overlapping, centered at 0.1,0.1 *
G54D11*
X00100Y00090D03*
X00100Y00110D03*
M02*
G04 Test flashing of polygon apertures*
G04 Four groups of polygon apertures are arranged in a square*
G04 Handcoded by Julian Lamb *
%MOIN*%
%FSLAX23Y23*%
%ADD10P,0.050X3*%
%ADD11P,0.050X6X-45X0.035*%
%ADD12P,0.040X10X25X0.025X0.025X0.0150*%
G04 Triangle, centered at 0,0 *
G54D10*
X0Y0D03*
G04 Hexagon with round hole rotate 45 degreed ccwise, centered at 0.1,0 *
G54D11*
X00100Y0D03*
G04 10-sided with square hole rotated 25 degrees, centered at 0,0.1 *
G54D12*
X0Y00100D03*
G04 Two, with round holes, slightly overlapping, centered at 0.1,0.1 *
G54D11*
X00100Y00090D03*
X00100Y00110D03*
M02*
G04 Test flashing of rectangular apertures*
G04 Four groups of rectangular apertures are arranged in a square*
G04 Handcoded by Julian Lamb *
%MOIN*%
%FSLAX23Y23*%
%ADD10R,0.050X0.080*%
%ADD11R,0.080X0.050X0.025*%
%ADD12R,0.050X0.025X0.025X0.0150*%
G04 No hole, centered at 0,0 *
G54D10*
X0Y0D03*
G04 Round hole, centered at 0.1,0 *
G54D11*
X00100Y0D03*
G04 Square hole, centered at 0,0.1 *
G54D12*
X0Y00100D03*
G04 Two, with round holes, slightly overlapping, centered at 0.1,0.1 *
G54D11*
X00100Y00090D03*
X00100Y00110D03*
M02*
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "class_drawpanel.h" #include "class_drawpanel.h"
#include "gerbview.h" #include "gerbview.h"
#include "class_gerber_draw_item.h"
#include "pcbplot.h" #include "pcbplot.h"
#include "bitmaps.h" #include "bitmaps.h"
#include "protos.h" #include "protos.h"
...@@ -113,6 +114,10 @@ BEGIN_EVENT_TABLE( WinEDA_GerberFrame, WinEDA_BasePcbFrame ) ...@@ -113,6 +114,10 @@ BEGIN_EVENT_TABLE( WinEDA_GerberFrame, WinEDA_BasePcbFrame )
// Option toolbar // Option toolbar
EVT_TOOL_RANGE( ID_TB_OPTIONS_START, ID_TB_OPTIONS_END, EVT_TOOL_RANGE( ID_TB_OPTIONS_START, ID_TB_OPTIONS_END,
WinEDA_GerberFrame::OnSelectOptionToolbar ) WinEDA_GerberFrame::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH,
WinEDA_GerberFrame::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_LINES_SKETCH,
WinEDA_GerberFrame::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR, EVT_TOOL( ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR,
WinEDA_GerberFrame::OnSelectOptionToolbar ) WinEDA_GerberFrame::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_DCODES, EVT_TOOL( ID_TB_OPTIONS_SHOW_DCODES,
...@@ -236,117 +241,22 @@ void WinEDA_GerberFrame::OnCloseWindow( wxCloseEvent& Event ) ...@@ -236,117 +241,22 @@ void WinEDA_GerberFrame::OnCloseWindow( wxCloseEvent& Event )
} }
/** Function SetToolbars() int WinEDA_GerberFrame::BestZoom()
* Set the tools state for the toolbars, according to display options
*/
void WinEDA_GerberFrame::SetToolbars()
{ {
PCB_SCREEN* screen = (PCB_SCREEN*) GetScreen(); double x, y;
int layer = screen->m_Active_Layer; EDA_Rect bbox;
GERBER* gerber = g_GERBER_List[layer];
if( m_HToolBar == NULL )
return;
if( GetScreen()->m_BlockLocate.m_Command == BLOCK_MOVE )
{
m_HToolBar->EnableTool( wxID_CUT, true );
m_HToolBar->EnableTool( wxID_COPY, true );
}
else
{
m_HToolBar->EnableTool( wxID_CUT, false );
m_HToolBar->EnableTool( wxID_COPY, false );
}
if( m_SelLayerBox && (m_SelLayerBox->GetSelection() != screen->m_Active_Layer) )
{
m_SelLayerBox->SetSelection( screen->m_Active_Layer );
}
if( m_SelLayerTool )
{
if( gerber )
{
int sel_index;
m_SelLayerTool->Enable( true );
if( gerber->m_Selected_Tool < FIRST_DCODE ) // No tool selected
sel_index = 0;
else
sel_index = gerber->m_Selected_Tool - FIRST_DCODE + 1;
if( sel_index != m_SelLayerTool->GetSelection() )
{
m_SelLayerTool->SetSelection( sel_index );
}
}
else
{
m_SelLayerTool->SetSelection( 0 );
m_SelLayerTool->Enable( false );
}
}
if( m_OptionsToolBar ) BOARD_ITEM* item = GetBoard()->m_Drawings;
for( ; item; item = item->Next() )
{ {
m_OptionsToolBar->ToggleTool( GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
ID_TB_OPTIONS_SELECT_UNIT_MM, bbox.Merge( gerb_item->GetBoundingBox() );
g_UserUnit ==
MILLIMETRES ? true : false );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_INCH,
g_UserUnit == INCHES ? true : false );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_POLAR_COORD,
DisplayOpt.DisplayPolarCood );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_GRID,
IsGridVisible() );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_CURSOR,
m_CursorShape );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH,
!m_DisplayPadFill );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH,
!m_DisplayPcbTrackFill );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH,
g_DisplayPolygonsModeSketch == 0 ? 0 : 1 );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_DCODES,
IsElementVisible( DCODES_VISIBLE ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR,
m_show_layer_manager_tools );
if( m_show_layer_manager_tools )
GetMenuBar()->SetLabel( ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
_("Hide &Layers Manager" ) );
else
GetMenuBar()->SetLabel( ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
_("Show &Layers Manager" ) );
} }
DisplayUnitsMsg(); wxSize size = DrawPanel->GetClientSize();
x = ( bbox.GetWidth() + GetScreen()->GetGridSize().x ) / (double) size.x;
if( m_auimgr.GetManagedWindow() ) y = ( bbox.GetHeight() + GetScreen()->GetGridSize().y ) / (double) size.y;
m_auimgr.Update(); GetScreen()->m_Curseur = bbox.Centre();
}
int WinEDA_GerberFrame::BestZoom()
{
double x, y;
wxSize size;
GetBoard()->ComputeBoundaryBox();
size = DrawPanel->GetClientSize();
x = ( (double) GetBoard()->m_BoundaryBox.GetWidth() +
GetScreen()->GetGridSize().x ) / (double) size.x;
y = ( (double) GetBoard()->m_BoundaryBox.GetHeight() +
GetScreen()->GetGridSize().y ) / (double) size.y;
GetScreen()->m_Curseur = GetBoard()->m_BoundaryBox.Centre();
return wxRound( MAX( x, y ) * (double) GetScreen()->m_ZoomScalar ); return wxRound( MAX( x, y ) * (double) GetScreen()->m_ZoomScalar );
} }
...@@ -506,3 +416,65 @@ void WinEDA_GerberFrame::SetLanguage( wxCommandEvent& event ) ...@@ -506,3 +416,65 @@ void WinEDA_GerberFrame::SetLanguage( wxCommandEvent& event )
ReFillLayerWidget(); ReFillLayerWidget();
} }
void WinEDA_GerberFrame::Liste_D_Codes( )
{
int ii, jj;
D_CODE* pt_D_code;
wxString Line;
WinEDA_TextFrame* List;
int scale = 10000;
int curr_layer = GetScreen()->m_Active_Layer;
List = new WinEDA_TextFrame( this, _( "List D codes" ) );
for( int layer = 0; layer < 32; layer++ )
{
GERBER* gerber = g_GERBER_List[layer];
if( gerber == NULL )
continue;
if( gerber->ReturnUsedDcodeNumber() == 0 )
continue;
if( layer == curr_layer )
Line.Printf( wxT( "*** Active layer (%2.2d) ***" ), layer + 1 );
else
Line.Printf( wxT( "*** layer %2.2d ***" ), layer + 1 );
List->Append( Line );
for( ii = 0, jj = 1; ii < TOOLS_MAX_COUNT; ii++ )
{
pt_D_code = gerber->GetDCODE( ii + FIRST_DCODE, false );
if( pt_D_code == NULL )
continue;
if( !pt_D_code->m_InUse && !pt_D_code->m_Defined )
continue;
Line.Printf( wxT(
"tool %2.2d: D%2.2d V %2.4f H %2.4f %s" ),
jj,
pt_D_code->m_Num_Dcode,
(float) pt_D_code->m_Size.y / scale,
(float) pt_D_code->m_Size.x / scale,
D_CODE::ShowApertureType( pt_D_code->m_Shape )
);
if( !pt_D_code->m_Defined )
Line += wxT( " ?" );
if( !pt_D_code->m_InUse )
Line += wxT( " *" );
List->Append( Line );
jj++;
}
}
ii = List->ShowModal();
List->Destroy();
if( ii < 0 )
return;
}
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <vector> #include <vector>
#include <set> #include <set>
#include "dcode.h"
class WinEDA_GerberFrame; class WinEDA_GerberFrame;
class BOARD; class BOARD;
...@@ -54,22 +55,6 @@ extern Ki_PageDescr* g_GerberPageSizeList[]; ...@@ -54,22 +55,6 @@ extern Ki_PageDescr* g_GerberPageSizeList[];
extern const wxString GerbviewShowPageSizeOption; extern const wxString GerbviewShowPageSizeOption;
extern const wxString GerbviewShowDCodes; extern const wxString GerbviewShowDCodes;
/**
* Enum APERTURE_T
* is the set of all gerber aperture types allowed, according to page 16 of
* http://gerbv.sourceforge.net/docs/rs274xrevd_e.pdf
*/
enum APERTURE_T
{
APT_CIRCLE = 'C',
APT_LINE = 'L',
APT_RECT = 'R',
APT_OVAL = '0',
APT_POLYGON = 'P',
APT_MACRO = 'M'
};
// Interpolation type // Interpolation type
enum Gerb_Interpolation enum Gerb_Interpolation
{ {
...@@ -106,9 +91,6 @@ enum Gerb_GCommand ...@@ -106,9 +91,6 @@ enum Gerb_GCommand
}; };
#define MAX_TOOLS 2048
#define FIRST_DCODE 10
enum Gerb_Analyse_Cmd enum Gerb_Analyse_Cmd
{ {
CMD_IDLE = 0, CMD_IDLE = 0,
...@@ -119,223 +101,13 @@ enum Gerb_Analyse_Cmd ...@@ -119,223 +101,13 @@ enum Gerb_Analyse_Cmd
class D_CODE; class D_CODE;
/**
* Class DCODE_PARAM
* holds a parameter for a DCODE or an "aperture macro" as defined within
* standard RS274X. The \a value field can be a constant, i.e. "immediate"
* parameter or it may not be used if this param is going to defer to the
* referencing aperture macro. In that case, the \a index field is an index
* into the aperture macro's parameters.
*/
class DCODE_PARAM
{
public:
DCODE_PARAM() :
index(-1),
value(0.0)
{}
double GetValue( const D_CODE* aDcode ) const;
void SetValue( double aValue )
{
value = aValue;
index = -1;
}
/**
* Function IsImmediate
* tests if this DCODE_PARAM holds an immediate parameter or is a pointer
* into a parameter held by an owning D_CODE.
*/
bool IsImmediate() const { return index == -1; }
unsigned GetIndex() const
{
return (unsigned) index;
}
void SetIndex( int aIndex )
{
index = aIndex;
}
private:
int index; ///< if -1, then \a value field is an immediate value,
// else this is an index into parent's
// D_CODE.m_am_params.
double value; ///< if IsImmediate()==true then use the value, else
// 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
*/
enum AM_PRIMITIVE_ID
{
AMP_CIRCLE = 1,
AMP_LINE2 = 2,
AMP_LINE20 = 20,
AMP_LINE_CENTER = 21,
AMP_LINE_LOWER_LEFT = 22,
AMP_EOF = 3,
AMP_OUTLINE = 4,
AMP_POLYGON = 5,
AMP_MOIRE = 6,
AMP_THERMAL = 7,
};
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
* holds a gerber DCODE definition.
*/
class D_CODE
{
friend class DCODE_PARAM;
APERTURE_MACRO* m_Macro; ///< no ownership, points to
// GERBER.m_aperture_macros element
/**
* parameters used only when this D_CODE holds a reference to an aperture
* macro, and these parameters would customize the macro.
*/
DCODE_PARAMS m_am_params;
public:
wxSize m_Size; /* Horizontal and vertical dimensions. */
APERTURE_T m_Shape; /* shape ( Line, rectangle, circle , oval .. ) */
int m_Num_Dcode; /* D code ( >= 10 ) */
wxSize m_Drill; /* dimension of the hole (if any) */
int m_DrillShape; /* shape of the hole (round = 1, rect = 2) */
bool m_InUse; /* FALSE if not used */
bool m_Defined; /* FALSE if not defined */
wxString m_SpecialDescr;
public:
D_CODE( int num_dcode );
~D_CODE();
void Clear_D_CODE_Data();
void AppendParam( double aValue )
{
DCODE_PARAM param;
param.SetValue( aValue );
m_am_params.push_back( param );
}
void SetMacro( APERTURE_MACRO* aMacro )
{
m_Macro = aMacro;
}
APERTURE_MACRO* GetMacro() { return m_Macro; }
/**
* Function ShowApertureType
* returns a character string telling what type of aperture type \a aType is.
* @param aType The aperture type to show.
*/
static const wxChar* ShowApertureType( APERTURE_T aType );
};
inline double DCODE_PARAM::GetValue( const D_CODE* aDcode ) const
{
if( IsImmediate() )
return value;
else
{
// the first one was numbered 1, not zero, as in $1, see page 19 of spec.
unsigned ndx = GetIndex() - 1;
wxASSERT(aDcode);
// get the parameter from the aDcode
if( ndx < aDcode->m_am_params.size() )
return aDcode->m_am_params[ndx].GetValue( NULL );
else
{
wxASSERT( GetIndex()-1 < aDcode->m_am_params.size() );
return 0.0;
}
}
}
/** /**
* Class GERBER * Class GERBER
* holds the data for one gerber file or layer * holds the data for one gerber file or layer
*/ */
class GERBER class GERBER
{ {
D_CODE* m_Aperture_List[MAX_TOOLS]; ///< Dcode (Aperture) List for this layer D_CODE* m_Aperture_List[TOOLS_MAX_COUNT]; ///< Dcode (Aperture) List for this layer
bool m_Exposure; ///< whether an aperture macro tool is flashed on or off bool m_Exposure; ///< whether an aperture macro tool is flashed on or off
BOARD* m_Pcb; BOARD* m_Pcb;
......
...@@ -35,7 +35,7 @@ static PARAM_CFG_WXSTRING DrillExtBufCfg ...@@ -35,7 +35,7 @@ static PARAM_CFG_WXSTRING DrillExtBufCfg
static PARAM_CFG_INT UnitCfg // Units; 0 inches, 1 mm static PARAM_CFG_INT UnitCfg // Units; 0 inches, 1 mm
( (
wxT("Unite"), wxT("Units"),
(int*)&g_UserUnit, (int*)&g_UserUnit,
MILLIMETRES MILLIMETRES
); );
......
...@@ -24,6 +24,8 @@ enum gerbview_ids ...@@ -24,6 +24,8 @@ enum gerbview_ids
ID_GERBVIEW_DISPLAY_OPTIONS_SETUP, ID_GERBVIEW_DISPLAY_OPTIONS_SETUP,
ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR, ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR,
ID_TB_OPTIONS_SHOW_DCODES, ID_TB_OPTIONS_SHOW_DCODES,
ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH,
ID_TB_OPTIONS_SHOW_LINES_SKETCH,
ID_GERBER_END_LIST ID_GERBER_END_LIST
}; };
......
...@@ -39,7 +39,7 @@ static Ki_HotkeyInfo HkHelp( wxT( "Help: this message" ), HK_HELP, '?' ); ...@@ -39,7 +39,7 @@ static Ki_HotkeyInfo HkHelp( wxT( "Help: this message" ), HK_HELP, '?' );
static Ki_HotkeyInfo HkSwitchUnits( wxT( "Switch Units" ), HK_SWITCH_UNITS, 'U' ); static Ki_HotkeyInfo HkSwitchUnits( wxT( "Switch Units" ), HK_SWITCH_UNITS, 'U' );
static Ki_HotkeyInfo HkTrackDisplayMode( wxT( static Ki_HotkeyInfo HkTrackDisplayMode( wxT(
"Track Display Mode" ), "Track Display Mode" ),
HK_SWITCH_TRACK_DISPLAY_MODE, 'F' ); HK_SWITCH_GBR_ITEMS_DISPLAY_MODE, 'F' );
static Ki_HotkeyInfo HkSwitch2NextCopperLayer( wxT( static Ki_HotkeyInfo HkSwitch2NextCopperLayer( wxT(
"Switch to Next Layer" ), "Switch to Next Layer" ),
...@@ -134,7 +134,7 @@ void WinEDA_GerberFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -134,7 +134,7 @@ void WinEDA_GerberFrame::OnHotKey( wxDC* DC, int hotkey,
g_UserUnit = (g_UserUnit == INCHES ) ? MILLIMETRES : INCHES; g_UserUnit = (g_UserUnit == INCHES ) ? MILLIMETRES : INCHES;
break; break;
case HK_SWITCH_TRACK_DISPLAY_MODE: case HK_SWITCH_GBR_ITEMS_DISPLAY_MODE:
DisplayOpt.DisplayPcbTrackFill ^= 1; DisplayOpt.DisplayPcbTrackFill &= 1; DisplayOpt.DisplayPcbTrackFill ^= 1; DisplayOpt.DisplayPcbTrackFill &= 1;
DrawPanel->Refresh(); DrawPanel->Refresh();
break; break;
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
// for shared hotkeys id // for shared hotkeys id
enum hotkey_id_commnand { enum hotkey_id_commnand {
HK_SWITCH_UNITS = HK_COMMON_END, HK_SWITCH_UNITS = HK_COMMON_END,
HK_SWITCH_TRACK_DISPLAY_MODE, HK_SWITCH_GBR_ITEMS_DISPLAY_MODE,
HK_SWITCH_LAYER_TO_NEXT, HK_SWITCH_LAYER_TO_NEXT,
HK_SWITCH_LAYER_TO_PREVIOUS HK_SWITCH_LAYER_TO_PREVIOUS
}; };
......
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
#include "confirm.h" #include "confirm.h"
#include "gerbview.h" #include "gerbview.h"
#include "protos.h" #include "class_gerber_draw_item.h"
//#include "protos.h"
bool WinEDA_GerberFrame::Clear_Pcb( bool query ) bool WinEDA_GerberFrame::Clear_Pcb( bool query )
...@@ -24,13 +25,8 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query ) ...@@ -24,13 +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;
} }
GetBoard()->m_Drawings.DeleteAll(); GetBoard()->m_Drawings.DeleteAll();
GetBoard()->m_Track.DeleteAll();
GetBoard()->m_Zone.DeleteAll();
for( layer = 0; layer < 32; layer++ ) for( layer = 0; layer < 32; layer++ )
{ {
if( g_GERBER_List[layer] ) if( g_GERBER_List[layer] )
...@@ -60,26 +56,15 @@ void WinEDA_GerberFrame::Erase_Current_Layer( bool query ) ...@@ -60,26 +56,15 @@ void WinEDA_GerberFrame::Erase_Current_Layer( bool query )
if( query && !IsOK( this, msg ) ) if( query && !IsOK( this, msg ) )
return; return;
/* Delete tracks (spots and lines) */ BOARD_ITEM* item = GetBoard()->m_Drawings;
TRACK* PtNext; BOARD_ITEM * next;
for( TRACK* pt_segm = GetBoard()->m_Track; for( ; item; item = next )
pt_segm != NULL;
pt_segm = (TRACK*) PtNext )
{
PtNext = pt_segm->Next();
if( pt_segm->GetLayer() != layer )
continue;
pt_segm->DeleteStructure();
}
/* Delete polygons */
SEGZONE* Nextzone;
for( SEGZONE* zone = GetBoard()->m_Zone; zone != NULL; zone = Nextzone )
{ {
Nextzone = zone->Next(); next = item->Next();
if( zone->GetLayer() != layer ) GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
if( gerb_item->m_Layer != layer )
continue; continue;
zone->DeleteStructure(); gerb_item->DeleteStructure();
} }
ScreenPcb->SetModify(); ScreenPcb->SetModify();
......
/****************/
/* lay2plot.cpp */
/****************/
#include "fctsys.h"
#include "common.h"
#include "class_drawpanel.h"
#include "gerbview.h"
#include "protos.h"
/* Routine to plot the pcb, by selected layers. */
void Print_PcbItems(BOARD * Pcb, wxDC *DC, int drawmode, int printmasklayer)
{
DISPLAY_OPTIONS save_opt;
TRACK * pt_piste;
save_opt = DisplayOpt;
DisplayOpt.DisplayPadFill = FILLED;
DisplayOpt.DisplayViaFill = FILLED;
DisplayOpt.DisplayPadNum = 0;
DisplayOpt.DisplayPadIsol = 0;
DisplayOpt.DisplayPcbTrackFill = FILLED;
DisplayOpt.ShowTrackClearanceMode = DO_NOT_SHOW_CLEARANCE;
DisplayOpt.DisplayDrawItems = FILLED;
DisplayOpt.DisplayZonesMode = 0;
pt_piste = Pcb->m_Track;
for( ; pt_piste != NULL ; pt_piste = pt_piste->Next() )
{
// if( (printmasklayer & ReturnMaskLayer(pt_piste) ) == 0 ) continue;
Trace_Segment(Pcb, NULL, DC, pt_piste, drawmode);
}
DisplayOpt = save_opt;
}
This diff is collapsed.
...@@ -47,17 +47,11 @@ bool WinEDA_GerberFrame::OnRightClick( const wxPoint& MousePos, ...@@ -47,17 +47,11 @@ bool WinEDA_GerberFrame::OnRightClick( const wxPoint& MousePos,
{ {
if( BlockActive ) if( BlockActive )
{ {
PopMenu->Append( ID_POPUP_CANCEL_CURRENT_COMMAND, PopMenu->Append( ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel Block" ) );
_( "Cancel Block" ) );
PopMenu->Append( ID_POPUP_ZOOM_BLOCK,
_( "Zoom Block (drag middle mouse)" ) );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
PopMenu->Append( ID_POPUP_PLACE_BLOCK, _( "Place Block" ) ); PopMenu->Append( ID_POPUP_PLACE_BLOCK, _( "Place Block" ) );
PopMenu->Append( ID_POPUP_COPY_BLOCK,
_( "Copy Block (shift mouse)" ) );
PopMenu->Append( ID_POPUP_DELETE_BLOCK, PopMenu->Append( ID_POPUP_DELETE_BLOCK,
_( "Delete Block (ctrl + drag mouse)" ) ); _( "Delete Block (ctrl + drag mouse)" ) );
PopMenu->Append( ID_POPUP_MIRROR_X_BLOCK, _( "Mirror Block" ) );
} }
else else
PopMenu->Append( ID_POPUP_CANCEL_CURRENT_COMMAND, PopMenu->Append( ID_POPUP_CANCEL_CURRENT_COMMAND,
...@@ -77,19 +71,6 @@ bool WinEDA_GerberFrame::OnRightClick( const wxPoint& MousePos, ...@@ -77,19 +71,6 @@ bool WinEDA_GerberFrame::OnRightClick( const wxPoint& MousePos,
GetScreen()->SetCurItem( DrawStruct ); GetScreen()->SetCurItem( DrawStruct );
switch( DrawStruct->Type() )
{
case TYPE_TRACK:
break;
default:
msg.Printf( wxT( "WinEDA_GerberFrame::OnRightClick Error: illegal or unknown DrawType %d" ),
DrawStruct->Type() );
DisplayError( this, msg );
break;
}
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
return true; return true;
} }
...@@ -66,7 +66,7 @@ void WinEDA_GerberFrame::OnSelectOptionToolbar( wxCommandEvent& event ) ...@@ -66,7 +66,7 @@ void WinEDA_GerberFrame::OnSelectOptionToolbar( wxCommandEvent& event )
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
break; break;
case ID_TB_OPTIONS_SHOW_PADS_SKETCH: case ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH:
if( state ) if( state )
{ {
DisplayOpt.DisplayPadFill = m_DisplayPadFill = false; DisplayOpt.DisplayPadFill = m_DisplayPadFill = false;
...@@ -78,19 +78,7 @@ void WinEDA_GerberFrame::OnSelectOptionToolbar( wxCommandEvent& event ) ...@@ -78,19 +78,7 @@ void WinEDA_GerberFrame::OnSelectOptionToolbar( wxCommandEvent& event )
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
break; break;
case ID_TB_OPTIONS_SHOW_VIAS_SKETCH: case ID_TB_OPTIONS_SHOW_LINES_SKETCH:
if( state )
{
DisplayOpt.DisplayViaFill = m_DisplayViaFill = false;
}
else
{
DisplayOpt.DisplayViaFill = m_DisplayViaFill = true;
}
DrawPanel->Refresh( TRUE );
break;
case ID_TB_OPTIONS_SHOW_TRACKS_SKETCH:
if(state ) if(state )
{ {
m_DisplayPcbTrackFill = FALSE; m_DisplayPcbTrackFill = FALSE;
......
/* declarations prototype */ /* declarations prototype */
int* InstallDialogLayerPairChoice( WinEDA_GerberFrame* parent ); int* InstallDialogLayerPairChoice( WinEDA_GerberFrame* parent );
bool Read_Config(); bool Read_Config();
void Print_PcbItems( BOARD* Pcb, wxDC* DC, int drawmode, int printmasklayer );
void DisplayColorSetupFrame( WinEDA_GerberFrame* parent, const wxPoint& framepos );
void Trace_Segment( BOARD* aBrd, WinEDA_DrawPanel* panel,
wxDC* DC,
TRACK* pt_piste,
int draw_mode );
...@@ -49,7 +49,6 @@ ...@@ -49,7 +49,6 @@
* *
* Tools and D_CODES * Tools and D_CODES
* Tool number (identification of shapes) * Tool number (identification of shapes)
* 1 to 99 (Classical)
* 1 to 999 * 1 to 999
* D_CODES: * D_CODES:
* *
...@@ -60,8 +59,7 @@ ...@@ -60,8 +59,7 @@
* D09 = VAPE Flash * D09 = VAPE Flash
* D51 = G54 preceded by -> Select VAPE * D51 = G54 preceded by -> Select VAPE
* *
* D10 ... D255 = Identification Tool (Opening) * D10 ... D999 = Identification Tool (shapes id)
* Not in order (see table in PCBPLOT.H)
*/ */
...@@ -83,14 +81,6 @@ ...@@ -83,14 +81,6 @@
* -1 = File not found * -1 = File not found
* -2 = Error reading file * -2 = Error reading file
* Rank D_code max lu (nbr of dCode) * Rank D_code max lu (nbr of dCode)
*
* Internal Representation:
*
* Lines are represented as standard TRACKS
* The flash is represented as DRAWSEGMENTS
* - Round or oval: DRAWSEGMENTS
* - Rectangles DRAWSEGMENTS
* Reference to the D-CODE is set in the member Getnet()
*/ */
......
This diff is collapsed.
...@@ -448,7 +448,7 @@ bool GERBER::ExecuteRS274XCommand( int command, ...@@ -448,7 +448,7 @@ bool GERBER::ExecuteRS274XCommand( int command,
while( *text == ' ' ) while( *text == ' ' )
text++; text++;
if( *text == 'Y' ) if( *text == 'X' )
{ {
text++; text++;
dcode->m_Drill.y = dcode->m_Drill.y =
......
...@@ -107,10 +107,10 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void ) ...@@ -107,10 +107,10 @@ void WinEDA_GerberFrame::ReCreateHToolbar( void )
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
choices.Clear(); choices.Clear();
choices.Alloc(MAX_TOOLS+1); choices.Alloc(TOOLS_MAX_COUNT+1);
choices.Add( _( "No tool" ) ); choices.Add( _( "No tool" ) );
for( ii = 0; ii < MAX_TOOLS; ii++ ) for( ii = 0; ii < TOOLS_MAX_COUNT; ii++ )
{ {
wxString msg; wxString msg;
msg = _( "Tool " ); msg << ii + FIRST_DCODE; msg = _( "Tool " ); msg << ii + FIRST_DCODE;
...@@ -187,11 +187,11 @@ void WinEDA_GerberFrame::ReCreateOptToolbar( void ) ...@@ -187,11 +187,11 @@ void WinEDA_GerberFrame::ReCreateOptToolbar( void )
_( "Change cursor shape" ), wxITEM_CHECK ); _( "Change cursor shape" ), wxITEM_CHECK );
m_OptionsToolBar->AddSeparator(); m_OptionsToolBar->AddSeparator();
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH, wxEmptyString, m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH, wxEmptyString,
wxBitmap( pad_sketch_xpm ), wxBitmap( pad_sketch_xpm ),
_( "Show spots in sketch mode" ), wxITEM_CHECK ); _( "Show spots in sketch mode" ), wxITEM_CHECK );
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, wxEmptyString, m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_LINES_SKETCH, wxEmptyString,
wxBitmap( showtrack_xpm ), wxBitmap( showtrack_xpm ),
_( "Show lines in sketch mode" ), wxITEM_CHECK ); _( "Show lines in sketch mode" ), wxITEM_CHECK );
...@@ -215,3 +215,103 @@ void WinEDA_GerberFrame::ReCreateOptToolbar( void ) ...@@ -215,3 +215,103 @@ void WinEDA_GerberFrame::ReCreateOptToolbar( void )
m_OptionsToolBar->Realize(); m_OptionsToolBar->Realize();
} }
/** Function SetToolbars()
* Set the tools state for the toolbars, according to display options
*/
void WinEDA_GerberFrame::SetToolbars()
{
PCB_SCREEN* screen = (PCB_SCREEN*) GetScreen();
int layer = screen->m_Active_Layer;
GERBER* gerber = g_GERBER_List[layer];
if( m_HToolBar == NULL )
return;
if( GetScreen()->m_BlockLocate.m_Command == BLOCK_MOVE )
{
m_HToolBar->EnableTool( wxID_CUT, true );
m_HToolBar->EnableTool( wxID_COPY, true );
}
else
{
m_HToolBar->EnableTool( wxID_CUT, false );
m_HToolBar->EnableTool( wxID_COPY, false );
}
if( m_SelLayerBox && (m_SelLayerBox->GetSelection() != screen->m_Active_Layer) )
{
m_SelLayerBox->SetSelection( screen->m_Active_Layer );
}
if( m_SelLayerTool )
{
if( gerber )
{
int sel_index;
m_SelLayerTool->Enable( true );
if( gerber->m_Selected_Tool < FIRST_DCODE ) // No tool selected
sel_index = 0;
else
sel_index = gerber->m_Selected_Tool - FIRST_DCODE + 1;
if( sel_index != m_SelLayerTool->GetSelection() )
{
m_SelLayerTool->SetSelection( sel_index );
}
}
else
{
m_SelLayerTool->SetSelection( 0 );
m_SelLayerTool->Enable( false );
}
}
if( m_OptionsToolBar )
{
m_OptionsToolBar->ToggleTool(
ID_TB_OPTIONS_SELECT_UNIT_MM,
g_UserUnit ==
MILLIMETRES ? true : false );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_INCH,
g_UserUnit == INCHES ? true : false );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_POLAR_COORD,
DisplayOpt.DisplayPolarCood );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_GRID,
IsGridVisible() );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_CURSOR,
m_CursorShape );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH,
!m_DisplayPadFill );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_LINES_SKETCH,
!m_DisplayPcbTrackFill );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH,
g_DisplayPolygonsModeSketch == 0 ? 0 : 1 );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_DCODES,
IsElementVisible( DCODES_VISIBLE ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR,
m_show_layer_manager_tools );
if( m_show_layer_manager_tools )
GetMenuBar()->SetLabel( ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
_("Hide &Layers Manager" ) );
else
GetMenuBar()->SetLabel( ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
_("Show &Layers Manager" ) );
}
DisplayUnitsMsg();
if( m_auimgr.GetManagedWindow() )
m_auimgr.Update();
}
This diff is collapsed.
...@@ -223,8 +223,6 @@ public: ...@@ -223,8 +223,6 @@ public:
* @param DC A device context to draw on. * @param DC A device context to draw on.
*/ */
void Block_Delete( wxDC* DC ); void Block_Delete( wxDC* DC );
void Block_Rotate( wxDC* DC );
void Block_Invert( wxDC* DC );
/** /**
* Function Block_Move * Function Block_Move
...@@ -237,14 +235,6 @@ public: ...@@ -237,14 +235,6 @@ public:
*/ */
void Block_Move( wxDC* DC ); void Block_Move( wxDC* DC );
/**
* Function Block_Mirror_X
* mirrors all tracks and segments within the currently selected block
* in the X axis.
*
* @param DC A device context to draw on.
*/
void Block_Mirror_X( wxDC* DC );
/** /**
* Function Block_Duplicate * Function Block_Duplicate
* copies-and-moves all tracks and segments within the selected block. * copies-and-moves all tracks and segments within the selected block.
...@@ -339,7 +329,6 @@ public: ...@@ -339,7 +329,6 @@ public:
bool Clear_Pcb( bool query ); bool Clear_Pcb( bool query );
void Erase_Current_Layer( bool query ); void Erase_Current_Layer( bool query );
void Delete_DCode_Items( wxDC* DC, int dcode_value, int layer_number ); void Delete_DCode_Items( wxDC* DC, int dcode_value, int layer_number );
TRACK* Delete_Segment( wxDC* DC, TRACK* Track );
// Conversion function // Conversion function
void ExportDataInPcbnewFormat( wxCommandEvent& event ); void ExportDataInPcbnewFormat( wxCommandEvent& event );
......
...@@ -87,6 +87,11 @@ enum KICAD_T { ...@@ -87,6 +87,11 @@ enum KICAD_T {
*/ */
COMPONENT_FIELD_DRAW_TYPE, COMPONENT_FIELD_DRAW_TYPE,
/*
* For Gerbview: items type:
*/
TYPE_GERBER_DRAW_ITEM,
// End value // End value
MAX_STRUCT_TYPE_ID MAX_STRUCT_TYPE_ID
}; };
......
...@@ -9,18 +9,15 @@ ...@@ -9,18 +9,15 @@
#include <boost/ptr_container/ptr_vector.hpp> #include <boost/ptr_container/ptr_vector.hpp>
/* Shapes for segments (graphic segments and tracks) ( .shape member ) */ /* Shapes for segments (graphic segments and tracks) ( .m_Shape member ) */
enum Track_Shapes { enum Track_Shapes {
S_SEGMENT = 0, /* usual segment : line with rounded ends */ S_SEGMENT = 0, /* usual segment : line with rounded ends */
S_RECT, /* segment with non rounded ends */ S_RECT, /* segment with non rounded ends */
S_ARC, /* Arcs (with rounded ends)*/ S_ARC, /* Arcs (with rounded ends)*/
S_CIRCLE, /* ring*/ S_CIRCLE, /* ring*/
S_ARC_RECT, /* Arcs (with non rounded ends) (GERBER)*/ S_POLYGON, /* polygonal shape (not yet used for tracks, but could be in microwave apps) */
S_SPOT_OVALE, /* Oblong spot (for GERBER)*/ S_CURVE, /* Bezier Curve*/
S_SPOT_CIRCLE, /* rounded spot (for GERBER)*/ S_LAST /* last value for this list */
S_SPOT_RECT, /* Rectangular spott (for GERBER)*/
S_POLYGON, /* polygonal shape */
S_CURVE /* Bezier Curve*/
}; };
......
...@@ -171,12 +171,10 @@ void GRCircle( EDA_Rect* ClipBox, wxDC* aDC, int x, int y, int aRadius, ...@@ -171,12 +171,10 @@ void GRCircle( EDA_Rect* ClipBox, wxDC* aDC, int x, int y, int aRadius,
void GRCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int width, void GRCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int width,
int Color ); int Color );
void GRFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, void GRFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int width, int Color, int BgColor );
int width, int Color, int BgColor ); void GRFilledCircle( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aColor );
void GRSCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r, int width, void GRCircle( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, int aColor );
int Color );
void GRSFilledCircle( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int r,
int width, int Color, int BgColor );
void GRArc( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int StAngle, void GRArc( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int StAngle,
int EndAngle, int r, int Color ); int EndAngle, int r, int Color );
void GRArc( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int StAngle, void GRArc( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int StAngle,
......
...@@ -25,12 +25,6 @@ wxString BOARD_ITEM::ShowShape( Track_Shapes aShape ) ...@@ -25,12 +25,6 @@ wxString BOARD_ITEM::ShowShape( Track_Shapes aShape )
case S_ARC: return _( "Arc" ); case S_ARC: return _( "Arc" );
case S_CIRCLE: return _( "Circle" ); case S_CIRCLE: return _( "Circle" );
case S_CURVE: return _( "Bezier Curve" ); case S_CURVE: return _( "Bezier Curve" );
// used in Gerbview:
case S_ARC_RECT: return wxT( "arc_rect" );
case S_SPOT_OVALE: return wxT( "spot_oval" );
case S_SPOT_CIRCLE: return wxT( "spot_circle" );
case S_SPOT_RECT: return wxT( "spot_rect" );
case S_POLYGON: return wxT( "polygon" ); case S_POLYGON: return wxT( "polygon" );
default: return wxT( "??" ); default: return wxT( "??" );
} }
......
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