Gerbview: added support forSF (scale factor), IO (Image Offset), OF (Offset) and MI (Mirror) commands.
This commit is contained in:
commit
c5668298a1
|
@ -82,8 +82,8 @@ static void GRSFilledArc( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int StAngle
|
|||
int EndAngle, int r, int width, int Color, int BgColor );
|
||||
static void GRSCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
||||
int width, int aPenSize, int Color );
|
||||
static void GRSFillCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
||||
int width, int Color );
|
||||
static void GRSLineArray( EDA_Rect* ClipBox, wxDC* DC, wxPoint points[],
|
||||
int lines, int width, int Color );
|
||||
/**/
|
||||
|
||||
extern BASE_SCREEN* ActiveScreen;
|
||||
|
@ -990,6 +990,13 @@ void GRCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
|||
GRMapY( y2 ), ZoomValue( width ), 0, Color );
|
||||
}
|
||||
|
||||
void GRCSegm( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
|
||||
int aWidth, int aColor )
|
||||
{
|
||||
GRSCSegm( aClipBox, aDC, GRMapX( aStart.x ), GRMapY( aStart.y ),
|
||||
GRMapX( aEnd.x ), GRMapY( aEnd.y ),
|
||||
ZoomValue( aWidth ), 0, aColor );
|
||||
}
|
||||
|
||||
/*
|
||||
* Draw segment (full) with rounded ends in object space (real coords.).
|
||||
|
@ -997,24 +1004,17 @@ void GRCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
|||
void GRFillCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
||||
int width, int Color )
|
||||
{
|
||||
GRSFillCSegm( ClipBox, DC, GRMapX( x1 ), GRMapY( y1 ), GRMapX( x2 ),
|
||||
GRMapY( y2 ), ZoomValue( width ), Color );
|
||||
WinClipAndDrawLine( ClipBox, DC, GRMapX( x1 ), GRMapY( y1 ), GRMapX( x2 ),
|
||||
GRMapY( y2 ), Color, ZoomValue( width ) );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Draw segment with rounded ends in screen space.
|
||||
*/
|
||||
void GRSFillCSegm( EDA_Rect* ClipBox,
|
||||
wxDC* DC,
|
||||
int x1,
|
||||
int y1,
|
||||
int x2,
|
||||
int y2,
|
||||
int width,
|
||||
int Color )
|
||||
void GRFilledSegment( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
|
||||
int aWidth, int aColor )
|
||||
{
|
||||
WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, Color, width );
|
||||
WinClipAndDrawLine( aClipBox, aDC, GRMapX( aStart.x ), GRMapY( aStart.y ),
|
||||
GRMapX( aEnd.x ), GRMapY( aEnd.y ),
|
||||
aColor, ZoomValue( aWidth ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1498,6 +1498,15 @@ void GRArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
|||
Color );
|
||||
}
|
||||
|
||||
void GRArc1( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
|
||||
wxPoint aCenter, int aWidth, int aColor )
|
||||
{
|
||||
GRSArc1( aClipBox, aDC, GRMapX( aStart.x ), GRMapY( aStart.y ),
|
||||
GRMapX( aEnd.x ), GRMapY( aEnd.y ),
|
||||
GRMapX( aCenter.x ), GRMapY( aCenter.y ), ZoomValue( aWidth ),
|
||||
aColor );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Draw an arc, width = width, in screen space.
|
||||
|
|
|
@ -45,9 +45,6 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel,
|
|||
wxDC* DC,
|
||||
bool erase );
|
||||
|
||||
static bool IsGbrItemInBox( BLOCK_SELECTOR& aBlocklocate, GERBER_DRAW_ITEM* aItem );
|
||||
|
||||
|
||||
/* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to
|
||||
* the key (ALT, SHIFT ALT ..)
|
||||
*/
|
||||
|
@ -292,7 +289,7 @@ void WinEDA_GerberFrame::Block_Delete( wxDC* DC )
|
|||
{
|
||||
nextitem = item->Next();
|
||||
GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
|
||||
if( IsGbrItemInBox( GetScreen()->m_BlockLocate, gerb_item ) )
|
||||
if( gerb_item->HitTest( GetScreen()->m_BlockLocate ) )
|
||||
gerb_item->DeleteStructure();
|
||||
}
|
||||
|
||||
|
@ -324,7 +321,7 @@ void WinEDA_GerberFrame::Block_Move( wxDC* DC )
|
|||
for( ; item; item = item->Next() )
|
||||
{
|
||||
GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
|
||||
if( IsGbrItemInBox( GetScreen()->m_BlockLocate, gerb_item ) )
|
||||
if( gerb_item->HitTest( GetScreen()->m_BlockLocate ) )
|
||||
gerb_item->Move( delta );
|
||||
}
|
||||
|
||||
|
@ -355,7 +352,7 @@ void WinEDA_GerberFrame::Block_Duplicate( wxDC* DC )
|
|||
for( ; item; item = item->Next() )
|
||||
{
|
||||
GERBER_DRAW_ITEM* gerb_item = (GERBER_DRAW_ITEM*) item;
|
||||
if( IsGbrItemInBox( GetScreen()->m_BlockLocate, gerb_item ) )
|
||||
if( gerb_item->HitTest( GetScreen()->m_BlockLocate ) )
|
||||
{
|
||||
/* this item must be duplicated */
|
||||
BOARD_ITEM* new_item = gerb_item->Copy();
|
||||
|
@ -367,17 +364,3 @@ void WinEDA_GerberFrame::Block_Duplicate( wxDC* DC )
|
|||
DrawPanel->Refresh();
|
||||
}
|
||||
|
||||
|
||||
/* Test if the structure PtStruct is inside the block
|
||||
* Returns true or false
|
||||
*/
|
||||
bool IsGbrItemInBox( BLOCK_SELECTOR& aBlocklocate, GERBER_DRAW_ITEM* aItem )
|
||||
{
|
||||
if( aBlocklocate.Inside( aItem->m_Start ) )
|
||||
return true;
|
||||
|
||||
if( aBlocklocate.Inside( aItem->m_End ) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -123,21 +123,23 @@ void GERBER::ResetDefaultValues()
|
|||
m_LayerName = wxT( "no layer name" ); // Layer name from the LN command
|
||||
m_LayerNegative = false; // true = Negative Layer
|
||||
m_ImageNegative = false; // true = Negative image
|
||||
m_GerbMetric = false; // false = Inches, true = metric
|
||||
m_GerbMetric = false; // false = Inches (default), true = metric
|
||||
m_Relative = false; // false = absolute Coord,
|
||||
// true = relative Coord
|
||||
m_NoTrailingZeros = false; // true: trailing zeros deleted
|
||||
m_MirorA = false; // true: miror / axe A (default = X)
|
||||
m_MirorB = false; // true: miror / axe B (default = Y)
|
||||
m_MirrorA = false; // true: miror / axe A (default = X)
|
||||
m_MirrorB = false; // true: miror / axe B (default = Y)
|
||||
m_SwapAxis = false; // false if A = X, B = Y; true if A =Y, B = Y
|
||||
m_ImageOffset.x = m_ImageOffset.y = 0; // Coord Offset, from IO command
|
||||
m_Offset.x = m_Offset.y = 0; // Coord Offset, from OF command
|
||||
m_Rotation = 0; // Allowed 0, 90, 180, 270
|
||||
m_Has_DCode = false; // true = DCodes in file
|
||||
// false = no DCode->
|
||||
// search for separate DCode file
|
||||
|
||||
m_FmtScale.x = m_FmtScale.y = 4; // Initialize default format to 3.4 => 4
|
||||
m_FmtLen.x = m_FmtLen.y = 3 + 4; // Initialize default format len = 3+4
|
||||
|
||||
m_LayerScale.x = m_LayerScale.y = 1.0; // scale (A and B) this layer
|
||||
m_Rotation = 0; // Allowed 0, 90, 180, 270
|
||||
m_Iterpolation = GERB_INTERPOL_LINEAR_1X; // Linear, 90 arc, Circ.
|
||||
m_360Arc_enbl = false; // 360 deg circular
|
||||
// interpolation disable
|
||||
|
|
|
@ -38,15 +38,17 @@ public:
|
|||
bool m_GerbMetric; // false = Inches, true = metric
|
||||
bool m_Relative; // false = absolute Coord, true = relative Coord
|
||||
bool m_NoTrailingZeros; // true: remove tailing zeros.
|
||||
bool m_MirorA; // true: miror / axe A (X)
|
||||
bool m_MirorB; // true: miror / axe B (Y)
|
||||
bool m_Has_DCode; // true = DCodes in file
|
||||
// (false = no DCode -> separate DCode file
|
||||
wxPoint m_Offset; // Coord Offset
|
||||
bool m_SwapAxis; // false (default) if A = X and B = Y
|
||||
// true if A = Y, B = X
|
||||
bool m_MirrorA; // true: miror / axe A (X)
|
||||
bool m_MirrorB; // true: miror / axe B (Y)
|
||||
wxPoint m_ImageOffset; // Coord Offset, from IO command
|
||||
wxPoint m_Offset; // Coord Offset, from OF command
|
||||
wxSize m_FmtScale; // Fmt 2.3: m_FmtScale = 3, fmt 3.4: m_FmtScale = 4
|
||||
wxSize m_FmtLen; // Nb chars per coord. ex fmt 2.3, m_FmtLen = 5
|
||||
wxRealPoint m_LayerScale; // scale (X and Y) of layer.
|
||||
int m_Rotation;
|
||||
int m_Rotation; // Image rotation (0, 90, 180, 270
|
||||
// Note these values are stored in 0.1 degrees
|
||||
int m_Iterpolation; // Linear, 90 arc, Circ.
|
||||
bool m_ImageNegative; // true = Negative image
|
||||
int m_Current_Tool; // Current Tool (Dcode) number selected
|
||||
|
@ -62,7 +64,8 @@ public:
|
|||
int m_FilesPtr; // Stack pointer for files list
|
||||
|
||||
int m_Selected_Tool; // For hightlight: current selected Dcode
|
||||
|
||||
bool m_Has_DCode; // true = DCodes in file
|
||||
// (false = no DCode -> separate DCode file
|
||||
bool m_360Arc_enbl; // Enbl 360 deg circular interpolation
|
||||
bool m_PolygonFillMode; // Enable polygon mode (read coord as a polygon descr)
|
||||
int m_PolygonFillModeState; // In polygon mode: 0 = first segm, 1 = next segm
|
||||
|
|
|
@ -147,6 +147,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
|
|||
* type is not stored in parameters list, so the first parameter is exposure
|
||||
*/
|
||||
curPos += mapPt( params[2].GetValue( tool ), params[3].GetValue( tool ), gerberMetric );
|
||||
curPos = aParent->GetABPosition( curPos );
|
||||
int radius = scale( params[1].GetValue( tool ), gerberMetric ) / 2;
|
||||
if( !aFilledShape )
|
||||
GRCircle( aClipBox, aDC, curPos, radius, 0, aColor );
|
||||
|
@ -170,12 +171,15 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
|
|||
if( rotation )
|
||||
{
|
||||
for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
|
||||
RotatePoint( &polybuffer[ii], rotation );
|
||||
RotatePoint( &polybuffer[ii], -rotation );
|
||||
}
|
||||
|
||||
// Move to current position:
|
||||
for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
|
||||
{
|
||||
polybuffer[ii] += curPos;
|
||||
polybuffer[ii] = aParent->GetABPosition( polybuffer[ii] );
|
||||
}
|
||||
|
||||
GRClosedPoly( aClipBox, aDC,
|
||||
polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor );
|
||||
|
@ -196,12 +200,15 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
|
|||
if( rotation )
|
||||
{
|
||||
for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
|
||||
RotatePoint( &polybuffer[ii], rotation );
|
||||
RotatePoint( &polybuffer[ii], -rotation );
|
||||
}
|
||||
|
||||
// Move to current position:
|
||||
for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
|
||||
{
|
||||
polybuffer[ii] += curPos;
|
||||
polybuffer[ii] = aParent->GetABPosition( polybuffer[ii] );
|
||||
}
|
||||
|
||||
GRClosedPoly( aClipBox, aDC,
|
||||
polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor );
|
||||
|
@ -222,12 +229,15 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
|
|||
if( rotation )
|
||||
{
|
||||
for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
|
||||
RotatePoint( &polybuffer[ii], rotation );
|
||||
RotatePoint( &polybuffer[ii], -rotation );
|
||||
}
|
||||
|
||||
// Move to current position:
|
||||
for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
|
||||
{
|
||||
polybuffer[ii] += curPos;
|
||||
polybuffer[ii] = aParent->GetABPosition( polybuffer[ii] );
|
||||
}
|
||||
|
||||
GRClosedPoly( aClipBox, aDC,
|
||||
polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor );
|
||||
|
@ -255,11 +265,14 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
|
|||
subshape_poly = polybuffer;
|
||||
int sub_rotation = rotation + 900 * ii;
|
||||
for( unsigned jj = 0; jj < subshape_poly.size(); jj++ )
|
||||
RotatePoint( &subshape_poly[jj], sub_rotation );
|
||||
RotatePoint( &subshape_poly[jj], -sub_rotation );
|
||||
|
||||
// Move to current position:
|
||||
for( unsigned jj = 0; jj < subshape_poly.size(); jj++ )
|
||||
{
|
||||
subshape_poly[jj] += curPos;
|
||||
subshape_poly[jj] = aParent->GetABPosition( subshape_poly[jj] );
|
||||
}
|
||||
|
||||
GRClosedPoly( aClipBox, aDC,
|
||||
subshape_poly.size(), &subshape_poly[0], true, aAltColor,
|
||||
|
@ -283,6 +296,8 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
|
|||
int gap = scale( params[4].GetValue( tool ), gerberMetric );
|
||||
int numCircles = wxRound( params[5].GetValue( tool ) );
|
||||
|
||||
// Draw circles:
|
||||
wxPoint center = aParent->GetABPosition( curPos );
|
||||
// adjust outerDiam by this on each nested circle
|
||||
int diamAdjust = (gap + penThickness); //*2; //Should we use * 2 ?
|
||||
for( int i = 0; i < numCircles; ++i, outerDiam -= diamAdjust )
|
||||
|
@ -292,12 +307,12 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
|
|||
if( !aFilledShape )
|
||||
{
|
||||
// draw the border of the pen's path using two circles, each as narrow as possible
|
||||
GRCircle( aClipBox, aDC, curPos, outerDiam / 2, 0, aColor );
|
||||
GRCircle( aClipBox, aDC, curPos, outerDiam / 2 - penThickness, 0, aColor );
|
||||
GRCircle( aClipBox, aDC, center, outerDiam / 2, 0, aColor );
|
||||
GRCircle( aClipBox, aDC, center, outerDiam / 2 - penThickness, 0, aColor );
|
||||
}
|
||||
else // Filled mode
|
||||
{
|
||||
GRCircle( aClipBox, aDC, curPos,
|
||||
GRCircle( aClipBox, aDC, center,
|
||||
(outerDiam - penThickness) / 2, penThickness, aColor );
|
||||
}
|
||||
}
|
||||
|
@ -305,17 +320,15 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
|
|||
// Draw the cross:
|
||||
ConvertShapeToPolygon( aParent, polybuffer, gerberMetric );
|
||||
|
||||
// shape rotation:
|
||||
rotation = wxRound( params[8].GetValue( tool ) * 10.0 );
|
||||
if( rotation )
|
||||
for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
|
||||
{
|
||||
for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
|
||||
RotatePoint( &polybuffer[ii], rotation );
|
||||
}
|
||||
|
||||
// shape rotation:
|
||||
RotatePoint( &polybuffer[ii], -rotation );
|
||||
// Move to current position:
|
||||
for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
|
||||
polybuffer[ii] += curPos;
|
||||
polybuffer[ii] = aParent->GetABPosition( polybuffer[ii] );
|
||||
}
|
||||
|
||||
GRClosedPoly( aClipBox, aDC,
|
||||
polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor );
|
||||
|
@ -344,13 +357,15 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
|
|||
// shape rotation:
|
||||
for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
|
||||
{
|
||||
NEGATE(polybuffer[ii].y);
|
||||
RotatePoint( &polybuffer[ii], rotation );
|
||||
RotatePoint( &polybuffer[ii], -rotation );
|
||||
}
|
||||
|
||||
// Move to current position:
|
||||
for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
|
||||
{
|
||||
polybuffer[ii] += curPos;
|
||||
polybuffer[ii] = aParent->GetABPosition( polybuffer[ii] );
|
||||
}
|
||||
|
||||
GRClosedPoly( aClipBox, aDC,
|
||||
polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor );
|
||||
|
@ -372,9 +387,9 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
|
|||
rotation = wxRound( params[5].GetValue( tool ) * 10.0 );
|
||||
for( unsigned ii = 0; ii < polybuffer.size(); ii++ )
|
||||
{
|
||||
NEGATE(polybuffer[ii].y);
|
||||
RotatePoint( &polybuffer[ii], rotation );
|
||||
RotatePoint( &polybuffer[ii], -rotation );
|
||||
polybuffer[ii] += curPos;
|
||||
polybuffer[ii] = aParent->GetABPosition( polybuffer[ii] );
|
||||
}
|
||||
GRClosedPoly( aClipBox, aDC,
|
||||
polybuffer.size(), &polybuffer[0], aFilledShape, aColor, aColor );
|
||||
|
@ -441,7 +456,6 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( GERBER_DRAW_ITEM* aParent,
|
|||
{
|
||||
RotatePoint( &aBuffer[ii], -angle );
|
||||
aBuffer[ii] += start;
|
||||
NEGATE( aBuffer[ii].y );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -471,7 +485,6 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( GERBER_DRAW_ITEM* aParent,
|
|||
tool ), aUnitsMetric );
|
||||
|
||||
// Build poly:
|
||||
NEGATE( lowerLeft.y );
|
||||
aBuffer.push_back( lowerLeft );
|
||||
lowerLeft.y += size.y; // Upper left
|
||||
aBuffer.push_back( lowerLeft );
|
||||
|
@ -479,10 +492,6 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( GERBER_DRAW_ITEM* aParent,
|
|||
aBuffer.push_back( lowerLeft );
|
||||
lowerLeft.y -= size.y; // lower right
|
||||
aBuffer.push_back( lowerLeft );
|
||||
|
||||
// Negate y coordinates:
|
||||
for( unsigned ii = 0; ii < aBuffer.size(); ii++ )
|
||||
NEGATE( aBuffer[ii].y );
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -42,10 +42,11 @@
|
|||
|
||||
|
||||
/**********************************************************/
|
||||
GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( BOARD_ITEM* aParent ) :
|
||||
GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( BOARD_ITEM* aParent, GERBER* aGerberparams ) :
|
||||
BOARD_ITEM( aParent, TYPE_GERBER_DRAW_ITEM )
|
||||
/**********************************************************/
|
||||
{
|
||||
m_imageParams = aGerberparams;
|
||||
m_Layer = 0;
|
||||
m_Shape = GBR_SEGMENT;
|
||||
m_Flashed = false;
|
||||
|
@ -53,6 +54,12 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( BOARD_ITEM* aParent ) :
|
|||
m_UnitsMetric = false;
|
||||
m_ImageNegative = false;
|
||||
m_LayerNegative = false;
|
||||
m_swapAxis = false;
|
||||
m_mirrorA = false;
|
||||
m_mirrorB = false;
|
||||
m_drawScale.x = m_drawScale.y = 1.0;
|
||||
if( m_imageParams )
|
||||
SetLayerParameters();
|
||||
}
|
||||
|
||||
|
||||
|
@ -60,6 +67,7 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( BOARD_ITEM* aParent ) :
|
|||
GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( const GERBER_DRAW_ITEM& aSource ) :
|
||||
BOARD_ITEM( aSource )
|
||||
{
|
||||
m_imageParams = aSource.m_imageParams;
|
||||
m_Shape = aSource.m_Shape;
|
||||
|
||||
m_Flags = aSource.m_Flags;
|
||||
|
@ -77,7 +85,12 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( const GERBER_DRAW_ITEM& aSource ) :
|
|||
m_UnitsMetric = aSource.m_UnitsMetric;
|
||||
m_ImageNegative = aSource.m_ImageNegative;
|
||||
m_LayerNegative = aSource.m_LayerNegative;
|
||||
|
||||
m_swapAxis = aSource.m_swapAxis;
|
||||
m_mirrorA = aSource.m_mirrorA;
|
||||
m_mirrorB = aSource.m_mirrorB;
|
||||
m_layerOffset = aSource.m_layerOffset;
|
||||
m_drawScale.x = aSource.m_drawScale.x;
|
||||
m_drawScale.y = aSource.m_drawScale.y;
|
||||
}
|
||||
|
||||
|
||||
|
@ -92,6 +105,84 @@ GERBER_DRAW_ITEM* GERBER_DRAW_ITEM::Copy() const
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function GetABPosition
|
||||
* returns the image position of aPosition for this object.
|
||||
* Image position is the value of aPosition, modified by image parameters:
|
||||
* offsets, axis selection, scale, rotation
|
||||
* @param aXYPosition = position in Y,X gerber axis
|
||||
* @return const wxPoint& - The position in A,B axis.
|
||||
* Because draw axis is top to bottom, the final y coordinates is negated
|
||||
*/
|
||||
wxPoint GERBER_DRAW_ITEM::GetABPosition( const wxPoint& aXYPosition )
|
||||
{
|
||||
/* Note: RS274Xrevd_e is obscure about the order of transforms:
|
||||
* For instance: Rotation must be made after or before mirroring ?
|
||||
* Note: if something is changed here, GetYXPosition must reflect changes
|
||||
*/
|
||||
wxPoint abPos = aXYPosition;
|
||||
|
||||
if( m_swapAxis )
|
||||
EXCHG( abPos.x, abPos.y );
|
||||
abPos += m_layerOffset + m_imageParams->m_ImageOffset;
|
||||
abPos.x = wxRound( abPos.x * m_drawScale.x );
|
||||
abPos.y = wxRound( abPos.y * m_drawScale.y );
|
||||
if( m_imageParams->m_Rotation )
|
||||
RotatePoint( &abPos, -m_imageParams->m_Rotation );
|
||||
if( m_mirrorA )
|
||||
NEGATE( abPos.x );
|
||||
// abPos.y must be negated, because draw axis is top to bottom
|
||||
if( !m_mirrorB )
|
||||
NEGATE( abPos.y );
|
||||
return abPos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function GetXYPosition
|
||||
* returns the image position of aPosition for this object.
|
||||
* Image position is the value of aPosition, modified by image parameters:
|
||||
* offsets, axis selection, scale, rotation
|
||||
* @param aABPosition = position in A,B plotter axis
|
||||
* @return const wxPoint - The given position in X,Y axis.
|
||||
*/
|
||||
wxPoint GERBER_DRAW_ITEM::GetXYPosition(const wxPoint& aABPosition )
|
||||
{
|
||||
// do the inverse tranform made by GetABPosition
|
||||
wxPoint xyPos = aABPosition;
|
||||
|
||||
if( m_mirrorA )
|
||||
NEGATE( xyPos.x );
|
||||
if( !m_mirrorB )
|
||||
NEGATE( xyPos.y );
|
||||
if( m_imageParams->m_Rotation )
|
||||
RotatePoint( &xyPos, m_imageParams->m_Rotation );
|
||||
xyPos.x = wxRound( xyPos.x / m_drawScale.x );
|
||||
xyPos.y = wxRound( xyPos.y / m_drawScale.y );
|
||||
xyPos -= m_layerOffset + m_imageParams->m_ImageOffset;
|
||||
if( m_swapAxis )
|
||||
EXCHG( xyPos.x, xyPos.y );
|
||||
return xyPos;
|
||||
}
|
||||
|
||||
/** function SetLayerParameters
|
||||
* Initialize draw parameters from Image and Layer parameters
|
||||
* found in the gerber file:
|
||||
* m_UnitsMetric,
|
||||
* m_MirrorA, m_MirrorB,
|
||||
* m_DrawScale, m_DrawOffset
|
||||
*/
|
||||
void GERBER_DRAW_ITEM::SetLayerParameters()
|
||||
{
|
||||
m_UnitsMetric = m_imageParams->m_GerbMetric;
|
||||
m_swapAxis = m_imageParams->m_SwapAxis; // false if A = X, B = Y;
|
||||
// true if A =Y, B = Y
|
||||
m_mirrorA = m_imageParams->m_MirrorA; // true: mirror / axe A
|
||||
m_mirrorB = m_imageParams->m_MirrorB; // true: mirror / axe B
|
||||
m_drawScale = m_imageParams->m_LayerScale; // A and B scaling factor
|
||||
m_layerOffset = m_imageParams->m_Offset; // Offset from OF command
|
||||
}
|
||||
|
||||
|
||||
wxString GERBER_DRAW_ITEM::ShowGBRShape()
|
||||
{
|
||||
switch( m_Shape )
|
||||
|
@ -154,6 +245,9 @@ EDA_Rect GERBER_DRAW_ITEM::GetBoundingBox()
|
|||
EDA_Rect bbox( m_Start, wxSize( 1, 1 ) );
|
||||
|
||||
bbox.Inflate( m_Size.x / 2, m_Size.y / 2 );
|
||||
|
||||
bbox.SetOrigin(GetXYPosition( bbox.GetOrigin() ) );
|
||||
bbox.SetEnd(GetXYPosition( bbox.GetEnd() ) );
|
||||
return bbox;
|
||||
}
|
||||
|
||||
|
@ -161,15 +255,16 @@ EDA_Rect GERBER_DRAW_ITEM::GetBoundingBox()
|
|||
/**
|
||||
* Function Move
|
||||
* move this object.
|
||||
* @param const wxPoint& aMoveVector - the move vector for this object.
|
||||
* @param const wxPoint& aMoveVector - the move vector for this object, in AB plotter axis.
|
||||
*/
|
||||
void GERBER_DRAW_ITEM::Move( const wxPoint& aMoveVector )
|
||||
{
|
||||
m_Start += aMoveVector;
|
||||
m_End += aMoveVector;
|
||||
m_ArcCentre += aMoveVector;
|
||||
wxPoint xymove = GetXYPosition( aMoveVector );
|
||||
m_Start += xymove;
|
||||
m_End += xymove;
|
||||
m_ArcCentre += xymove;
|
||||
for( unsigned ii = 0; ii < m_PolyCorners.size(); ii++ )
|
||||
m_PolyCorners[ii] += aMoveVector;
|
||||
m_PolyCorners[ii] += xymove;
|
||||
}
|
||||
|
||||
|
||||
|
@ -244,27 +339,29 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode,
|
|||
if( !isFilled )
|
||||
{
|
||||
// draw the border of the pen's path using two circles, each as narrow as possible
|
||||
GRCircle( &aPanel->m_ClipBox, aDC, m_Start, radius - halfPenWidth, 0, color );
|
||||
GRCircle( &aPanel->m_ClipBox, aDC, m_Start, radius + halfPenWidth, 0, color );
|
||||
GRCircle( &aPanel->m_ClipBox, aDC, GetABPosition( m_Start ),
|
||||
radius - halfPenWidth, 0, color );
|
||||
GRCircle( &aPanel->m_ClipBox, aDC, GetABPosition( m_Start ),
|
||||
radius + halfPenWidth, 0, color );
|
||||
}
|
||||
else // Filled mode
|
||||
{
|
||||
GRCircle( &aPanel->m_ClipBox, aDC, m_Start, radius, m_Size.x, color );
|
||||
GRCircle( &aPanel->m_ClipBox, aDC, GetABPosition( m_Start ),
|
||||
radius, m_Size.x, color );
|
||||
}
|
||||
break;
|
||||
|
||||
case GBR_ARC:
|
||||
if( !isFilled )
|
||||
{
|
||||
GRArc1( &aPanel->m_ClipBox, aDC, m_Start.x, m_Start.y,
|
||||
m_End.x, m_End.y,
|
||||
m_ArcCentre.x, m_ArcCentre.y, 0, color );
|
||||
GRArc1( &aPanel->m_ClipBox, aDC, GetABPosition( m_Start ),
|
||||
GetABPosition( m_End ), GetABPosition( m_ArcCentre ),
|
||||
0, color );
|
||||
}
|
||||
else
|
||||
{
|
||||
GRArc1( &aPanel->m_ClipBox, aDC, m_Start.x, m_Start.y,
|
||||
m_End.x, m_End.y,
|
||||
m_ArcCentre.x, m_ArcCentre.y,
|
||||
GRArc1( &aPanel->m_ClipBox, aDC, GetABPosition( m_Start ),
|
||||
GetABPosition( m_End ), GetABPosition( m_ArcCentre ),
|
||||
m_Size.x, color );
|
||||
}
|
||||
break;
|
||||
|
@ -281,11 +378,11 @@ void GERBER_DRAW_ITEM::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode,
|
|||
|
||||
case GBR_SEGMENT:
|
||||
if( !isFilled )
|
||||
GRCSegm( &aPanel->m_ClipBox, aDC, m_Start.x, m_Start.y,
|
||||
m_End.x, m_End.y, m_Size.x, color );
|
||||
GRCSegm( &aPanel->m_ClipBox, aDC, GetABPosition( m_Start ),
|
||||
GetABPosition( m_End ), m_Size.x, color );
|
||||
else
|
||||
GRFillCSegm( &aPanel->m_ClipBox, aDC, m_Start.x,
|
||||
m_Start.y, m_End.x, m_End.y, m_Size.x, color );
|
||||
GRFilledSegment( &aPanel->m_ClipBox, aDC, GetABPosition( m_Start ),
|
||||
GetABPosition( m_End ), m_Size.x, color );
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -312,19 +409,17 @@ void GERBER_DRAW_ITEM::DrawGbrPoly( EDA_Rect* aClipBox,
|
|||
std::vector<wxPoint> points;
|
||||
|
||||
points = m_PolyCorners;
|
||||
if( aOffset != wxPoint( 0, 0 ) )
|
||||
{
|
||||
for( unsigned ii = 0; ii < points.size(); ii++ )
|
||||
{
|
||||
points[ii] += aOffset;
|
||||
}
|
||||
points[ii] = GetABPosition( points[ii] );
|
||||
}
|
||||
|
||||
GRClosedPoly( aClipBox, aDC, points.size(), &points[0], aFilledShape, aColor, aColor );
|
||||
}
|
||||
|
||||
|
||||
/** Function DisplayInfoBase
|
||||
/** Function DisplayInfo
|
||||
* has knowledge about the frame and how and where to put status information
|
||||
* about this object into the frame's message panel.
|
||||
* Display info about the track segment only, and does not calculate the full track length
|
||||
|
@ -333,28 +428,59 @@ void GERBER_DRAW_ITEM::DrawGbrPoly( EDA_Rect* aClipBox,
|
|||
void GERBER_DRAW_ITEM::DisplayInfo( WinEDA_DrawFrame* frame )
|
||||
{
|
||||
wxString msg;
|
||||
BOARD* board = ( (WinEDA_BasePcbFrame*) frame )->GetBoard();
|
||||
|
||||
frame->ClearMsgPanel();
|
||||
|
||||
msg = ShowGBRShape();
|
||||
frame->AppendMsgPanel( _( "Type" ), msg, DARKCYAN );
|
||||
|
||||
/* Display layer */
|
||||
msg = board->GetLayerName( m_Layer );
|
||||
frame->AppendMsgPanel( _( "Layer" ), msg, BROWN );
|
||||
// Display D_Code value:
|
||||
msg.Printf( wxT("%d"), m_DCode);
|
||||
frame->AppendMsgPanel( _( "D Code" ), msg, RED );
|
||||
|
||||
// Display Image name
|
||||
if(m_imageParams)
|
||||
{
|
||||
msg = m_imageParams->m_ImageName;
|
||||
frame->AppendMsgPanel( _( "Image name" ), msg, BROWN );
|
||||
}
|
||||
|
||||
// Display graphic layer number
|
||||
msg.Printf( wxT("%d"), GetLayer()+1);
|
||||
frame->AppendMsgPanel( _( "Graphic layer" ), msg, BROWN );
|
||||
|
||||
// This next info can be see as debug info, so it can be disabled
|
||||
#if 1
|
||||
// Display offset
|
||||
wxPoint tmp = m_layerOffset + m_imageParams->m_ImageOffset;
|
||||
msg.Printf( wxT("X=%f Y=%f"), (double)tmp.x/10000, (double)tmp.y/10000);
|
||||
frame->AppendMsgPanel( _( "Offset" ), msg, DARKRED );
|
||||
|
||||
// Display rotation
|
||||
msg.Printf( wxT("%d"), m_imageParams->m_Rotation/10);
|
||||
frame->AppendMsgPanel( _( "Image rotation" ), msg, DARKRED );
|
||||
|
||||
// Display mirroring
|
||||
msg.Printf( wxT("X%d Y%d"), m_mirrorA, m_mirrorB);
|
||||
frame->AppendMsgPanel( _( "Mirror" ), msg, DARKRED );
|
||||
|
||||
// Display AB axis swap
|
||||
msg = m_swapAxis ? wxT("A=Y B=X") : wxT("A=X B=Y");
|
||||
frame->AppendMsgPanel( _( "AB axis" ), msg, DARKRED );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function HitTest
|
||||
* tests if the given wxPoint is within the bounds of this object.
|
||||
* @param ref_pos A wxPoint to test
|
||||
* @param aRefPos A wxPoint to test in AB axis
|
||||
* @return bool - true if a hit, else false
|
||||
*/
|
||||
bool GERBER_DRAW_ITEM::HitTest( const wxPoint& ref_pos )
|
||||
bool GERBER_DRAW_ITEM::HitTest( const wxPoint& aRefPos )
|
||||
{
|
||||
// TODO: a better analyse od the shape (perhaps create a D_CODE::HitTest for flashed items)
|
||||
wxPoint ref_pos = GetXYPosition( aRefPos );
|
||||
|
||||
// TODO: a better analyse of the shape (perhaps create a D_CODE::HitTest for flashed items)
|
||||
int radius = MIN( m_Size.x, m_Size.y ) >> 1;
|
||||
|
||||
// delta is a vector from m_Start to m_End (an origin of m_Start)
|
||||
|
@ -382,14 +508,16 @@ bool GERBER_DRAW_ITEM::HitTest( const wxPoint& ref_pos )
|
|||
* Function HitTest (overlayed)
|
||||
* tests if the given EDA_Rect intersect this object.
|
||||
* For now, an ending point must be inside this rect.
|
||||
* @param refArea : the given EDA_Rect
|
||||
* @param refArea : the given EDA_Rect in AB plotter axis
|
||||
* @return bool - true if a hit, else false
|
||||
*/
|
||||
bool GERBER_DRAW_ITEM::HitTest( EDA_Rect& refArea )
|
||||
{
|
||||
if( refArea.Inside( m_Start ) )
|
||||
wxPoint pos = GetABPosition( m_Start );
|
||||
if( refArea.Inside( pos ) )
|
||||
return true;
|
||||
if( refArea.Inside( m_End ) )
|
||||
pos = GetABPosition( m_End );
|
||||
if( refArea.Inside( pos ) )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include "base_struct.h"
|
||||
#include "class_board_item.h"
|
||||
class GERBER;
|
||||
|
||||
/* Shapes id for basic shapes ( .m_Shape member ) */
|
||||
enum Gbr_Basic_Shapes {
|
||||
|
@ -67,18 +68,34 @@ public:
|
|||
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
|
||||
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
|
||||
// These values are used to draw this item, according to gerber layers parameters
|
||||
// Because these values can change inside a gerber image, they are stored here
|
||||
// for each item
|
||||
bool m_ImageNegative; // true = item in negative image
|
||||
bool m_LayerNegative; // TRUE = item in negative Layer
|
||||
private:
|
||||
GERBER* m_imageParams; /* main GERBER info for this item
|
||||
* Note: some params stored in this class are common
|
||||
* to the whole gerber file (i.e) the whole graphic layer
|
||||
* and some can change when reaging the file, so they
|
||||
* are stored inside this item
|
||||
* there is no redundancy for these parameters
|
||||
*/
|
||||
bool m_swapAxis; // false if A = X, B = Y; true if A =Y, B = Y
|
||||
bool m_mirrorA; // true: mirror / axe A
|
||||
bool m_mirrorB; // true: mirror / axe B
|
||||
wxRealPoint m_drawScale; // A and B scaling factor
|
||||
wxPoint m_layerOffset; // Offset for A and B axis, from OF parameter
|
||||
|
||||
public:
|
||||
GERBER_DRAW_ITEM( BOARD_ITEM* aParent );
|
||||
GERBER_DRAW_ITEM( BOARD_ITEM* aParent, GERBER* aGerberparams );
|
||||
GERBER_DRAW_ITEM( const GERBER_DRAW_ITEM& aSource );
|
||||
~GERBER_DRAW_ITEM();
|
||||
|
||||
|
@ -99,6 +116,15 @@ public:
|
|||
}
|
||||
|
||||
|
||||
/** function SetLayerParameters
|
||||
* Initialize parameters from Image and Layer parameters
|
||||
* found in the gerber file:
|
||||
* m_UnitsMetric,
|
||||
* m_MirrorA, m_MirrorB,
|
||||
* m_DrawScale, m_DrawOffset
|
||||
*/
|
||||
void SetLayerParameters( );
|
||||
|
||||
/**
|
||||
* Function Move
|
||||
* move this object.
|
||||
|
@ -110,12 +136,32 @@ public:
|
|||
* Function GetPosition
|
||||
* returns the position of this object.
|
||||
* @return const wxPoint& - The position of this object.
|
||||
* This function exists mainly to satisfy the virtual GetPosition() in parent class
|
||||
*/
|
||||
wxPoint& GetPosition()
|
||||
{
|
||||
return m_Start; // it had to be start or end.
|
||||
}
|
||||
|
||||
/**
|
||||
* Function GetABPosition
|
||||
* returns the image position of aPosition for this object.
|
||||
* Image position is the value of aPosition, modified by image parameters:
|
||||
* offsets, axis selection, scale, rotation
|
||||
* @param aXYPosition = position in X,Y gerber axis
|
||||
* @return const wxPoint - The given position in plotter A,B axis.
|
||||
*/
|
||||
wxPoint GetABPosition(const wxPoint& aXYPosition );
|
||||
|
||||
/**
|
||||
* Function GetXYPosition
|
||||
* returns the image position of aPosition for this object.
|
||||
* Image position is the value of aPosition, modified by image parameters:
|
||||
* offsets, axis selection, scale, rotation
|
||||
* @param aABPosition = position in A,B plotter axis
|
||||
* @return const wxPoint - The given position in X,Y axis.
|
||||
*/
|
||||
wxPoint GetXYPosition(const wxPoint& aABPosition );
|
||||
|
||||
/**
|
||||
* Function GetDcodeDescr
|
||||
|
@ -157,19 +203,19 @@ public:
|
|||
/**
|
||||
* Function HitTest
|
||||
* tests if the given wxPoint is within the bounds of this object.
|
||||
* @param refPos A wxPoint to test
|
||||
* @param aRefPos A wxPoint to test
|
||||
* @return bool - true if a hit, else false
|
||||
*/
|
||||
bool HitTest( const wxPoint& refPos );
|
||||
bool HitTest( const wxPoint& aRefPos );
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @param aRefPos A wxPoint to test
|
||||
* @return bool - true if a hit, else false
|
||||
*/
|
||||
bool HitTest( EDA_Rect& refArea );
|
||||
bool HitTest( EDA_Rect& aRefArea );
|
||||
|
||||
/**
|
||||
* Function GetClass
|
||||
|
@ -185,6 +231,7 @@ public:
|
|||
bool Save( FILE* aFile ) const;
|
||||
|
||||
#if defined(DEBUG)
|
||||
|
||||
/**
|
||||
* Function Show
|
||||
* is used to output the object tree, currently for debugging only.
|
||||
|
@ -193,6 +240,7 @@ public:
|
|||
* @param os The ostream& to output to.
|
||||
*/
|
||||
virtual void Show( int nestLevel, std::ostream& os );
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -5,11 +5,9 @@
|
|||
#include "fctsys.h"
|
||||
#include "common.h"
|
||||
#include "class_drawpanel.h"
|
||||
|
||||
#include "pcbnew.h"
|
||||
#include "gerbview.h"
|
||||
|
||||
BOARD_ITEM* WinEDA_GerberFrame::GerberGeneralLocateAndDisplay()
|
||||
GERBER_DRAW_ITEM* WinEDA_GerberFrame::GerberGeneralLocateAndDisplay()
|
||||
{
|
||||
return Locate( CURSEUR_OFF_GRILLE );
|
||||
}
|
||||
|
|
|
@ -310,20 +310,23 @@ void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent,
|
|||
case APT_CIRCLE:
|
||||
radius = m_Size.x >> 1;
|
||||
if( !aFilledShape )
|
||||
GRCircle( aClipBox, aDC, aShapePos.x, aShapePos.y, radius, aColor );
|
||||
GRCircle( aClipBox, aDC, aParent->GetABPosition(aShapePos),
|
||||
radius, 0, aColor );
|
||||
else
|
||||
if( m_DrillShape == APT_DEF_NO_HOLE )
|
||||
GRFilledCircle( aClipBox, aDC, aShapePos, radius, aColor );
|
||||
GRFilledCircle( aClipBox, aDC, aParent->GetABPosition(aShapePos),
|
||||
radius, aColor );
|
||||
else if( APT_DEF_ROUND_HOLE == 1 ) // round hole in shape
|
||||
{
|
||||
int width = (m_Size.x - m_Drill.x ) / 2;
|
||||
GRCircle( aClipBox, aDC, aShapePos, radius - (width / 2), width, aColor );
|
||||
GRCircle( aClipBox, aDC, aParent->GetABPosition(aShapePos),
|
||||
radius - (width / 2), width, aColor );
|
||||
}
|
||||
else // rectangular hole
|
||||
{
|
||||
if( m_PolyCorners.size() == 0 )
|
||||
ConvertShapeToPolygon();
|
||||
DrawFlashedPolygon( aClipBox, aDC, aColor, aFilledShape, aShapePos );
|
||||
DrawFlashedPolygon( aParent, aClipBox, aDC, aColor, aFilledShape, aShapePos );
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -338,6 +341,8 @@ void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent,
|
|||
start.x = aShapePos.x - m_Size.x / 2;
|
||||
start.y = aShapePos.y - m_Size.y / 2;
|
||||
wxPoint end = start + m_Size;
|
||||
start = aParent->GetABPosition( start );
|
||||
end = aParent->GetABPosition( end );
|
||||
if( !aFilledShape )
|
||||
{
|
||||
GRRect( aClipBox, aDC, start.x, start.y, end.x, end.y,
|
||||
|
@ -352,7 +357,7 @@ void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent,
|
|||
{
|
||||
if( m_PolyCorners.size() == 0 )
|
||||
ConvertShapeToPolygon();
|
||||
DrawFlashedPolygon( aClipBox, aDC, aColor, aFilledShape, aShapePos );
|
||||
DrawFlashedPolygon( aParent, aClipBox, aDC, aColor, aFilledShape, aShapePos );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -375,6 +380,8 @@ void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent,
|
|||
end.y += delta;
|
||||
radius = m_Size.x;
|
||||
}
|
||||
start = aParent->GetABPosition( start );
|
||||
end = aParent->GetABPosition( end );
|
||||
if( !aFilledShape )
|
||||
{
|
||||
GRCSegm( aClipBox, aDC, start.x, start.y,
|
||||
|
@ -389,7 +396,7 @@ void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent,
|
|||
{
|
||||
if( m_PolyCorners.size() == 0 )
|
||||
ConvertShapeToPolygon();
|
||||
DrawFlashedPolygon( aClipBox, aDC, aColor, aFilledShape, aShapePos );
|
||||
DrawFlashedPolygon( aParent, aClipBox, aDC, aColor, aFilledShape, aShapePos );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -397,7 +404,7 @@ void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent,
|
|||
case APT_POLYGON:
|
||||
if( m_PolyCorners.size() == 0 )
|
||||
ConvertShapeToPolygon();
|
||||
DrawFlashedPolygon( aClipBox, aDC, aColor, aFilledShape, aShapePos );
|
||||
DrawFlashedPolygon( aParent, aClipBox, aDC, aColor, aFilledShape, aShapePos );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -409,7 +416,8 @@ void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent,
|
|||
* APT_POLYGON is always a polygon, but some complex shapes are also converted to
|
||||
* polygons (shapes with holes)
|
||||
*/
|
||||
void D_CODE::DrawFlashedPolygon( EDA_Rect* aClipBox, wxDC* aDC,
|
||||
void D_CODE::DrawFlashedPolygon( GERBER_DRAW_ITEM* aParent,
|
||||
EDA_Rect* aClipBox, wxDC* aDC,
|
||||
int aColor, bool aFilled,
|
||||
const wxPoint& aPosition )
|
||||
{
|
||||
|
@ -421,6 +429,7 @@ void D_CODE::DrawFlashedPolygon( EDA_Rect* aClipBox, wxDC* aDC,
|
|||
for( unsigned ii = 0; ii < points.size(); ii++ )
|
||||
{
|
||||
points[ii] += aPosition;
|
||||
points[ii] = aParent->GetABPosition( points[ii] );
|
||||
}
|
||||
|
||||
GRClosedPoly( aClipBox, aDC, points.size(), &points[0], aFilled, aColor, aColor );
|
||||
|
@ -557,9 +566,7 @@ void D_CODE::ConvertShapeToPolygon()
|
|||
int angle = wxRound( m_Rotation * 10 );
|
||||
for( unsigned jj = 0; jj < m_PolyCorners.size(); jj++ )
|
||||
{
|
||||
// Remember the Y axis is from top to bottom when draw items.
|
||||
RotatePoint( &m_PolyCorners[jj], -angle );
|
||||
NEGATE( m_PolyCorners[jj].y );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -193,6 +193,7 @@ public:
|
|||
/** function DrawFlashedShape
|
||||
* Draw the dcode shape for flashed items.
|
||||
* When an item is flashed, the DCode shape is the shape of the item
|
||||
* @param aParent = the GERBER_DRAW_ITEM being drawn
|
||||
* @param aClipBox = DC clip box (NULL is no clip)
|
||||
* @param aDC = device context
|
||||
* @param aColor = the normal color to use
|
||||
|
@ -209,13 +210,15 @@ public:
|
|||
* 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)
|
||||
* @param aParent = the GERBER_DRAW_ITEM being drawn
|
||||
* @param aClipBox = DC clip box (NULL is no clip)
|
||||
* @param aDC = device context
|
||||
* @param aColor = the normal color to use
|
||||
* @param aFilled = true to draw in filled mode, false to draw in skecth mode
|
||||
* @param aPosition = the actual shape position
|
||||
*/
|
||||
void DrawFlashedPolygon( EDA_Rect* aClipBox, wxDC* aDC, int aColor,
|
||||
void DrawFlashedPolygon( GERBER_DRAW_ITEM* aParent,
|
||||
EDA_Rect* aClipBox, wxDC* aDC, int aColor,
|
||||
bool aFilled, const wxPoint& aPosition );
|
||||
|
||||
/** function ConvertShapeToPolygon
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
#include "gerbview.h"
|
||||
#include "wxGerberFrame.h"
|
||||
#include "pcbnew.h"
|
||||
#include "wxPcbStruct.h"
|
||||
#include "pcbplot.h"
|
||||
#include "class_board_design_settings.h"
|
||||
|
|
|
@ -26,7 +26,7 @@ void WinEDA_GerberFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
|
|||
|
||||
if( m_ID_current_state == 0 )
|
||||
{
|
||||
if( DrawStruct && DrawStruct->m_Flags )
|
||||
if( DrawStruct && (DrawStruct->m_Flags & ~DRAW_ERASED) )
|
||||
{
|
||||
msg.Printf( wxT( "WinEDA_GerberFrame::ProcessCommand err: Struct %d, m_Flags = %X" ),
|
||||
(unsigned) DrawStruct->Type(),
|
||||
|
@ -228,7 +228,7 @@ void WinEDA_GerberFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
|
|||
switch( m_ID_current_state )
|
||||
{
|
||||
case 0:
|
||||
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
|
||||
if( (DrawStruct == NULL) || ((DrawStruct->m_Flags & ~DRAW_ERASED) == 0) )
|
||||
{
|
||||
DrawStruct = GerberGeneralLocateAndDisplay();
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ G90*
|
|||
%ADD14LINE2,0.8X0.5*%
|
||||
%ADD15OUTLINE*%
|
||||
%ADD16POLYGON,3X-10*%
|
||||
%ADD17POLYGON,6X0*%
|
||||
%ADD17POLYGON,6X10*%
|
||||
%ADD18MOIRE*%
|
||||
%ADD19THERMAL*%
|
||||
%ADD20LINELOWLEFT*%
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
#include "class_gerber_draw_item.h"
|
||||
#include "class_aperture_macro.h"
|
||||
|
||||
#define CURSEUR_ON_GRILLE 0
|
||||
#define CURSEUR_OFF_GRILLE 1
|
||||
|
||||
class WinEDA_GerberFrame;
|
||||
//class BOARD;
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ bool WinEDA_GerberFrame::Clear_Pcb( bool query )
|
|||
GetScreen()->Init();
|
||||
setActiveLayer(LAYER_N_BACK);
|
||||
|
||||
SetCurItem( NULL );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -59,6 +60,8 @@ void WinEDA_GerberFrame::Erase_Current_Layer( bool query )
|
|||
if( query && !IsOK( this, msg ) )
|
||||
return;
|
||||
|
||||
SetCurItem( NULL );
|
||||
|
||||
BOARD_ITEM* item = GetBoard()->m_Drawings;
|
||||
BOARD_ITEM * next;
|
||||
for( ; item; item = next )
|
||||
|
|
|
@ -4,20 +4,56 @@
|
|||
|
||||
#include "fctsys.h"
|
||||
#include "common.h"
|
||||
#include "class_drawpanel.h"
|
||||
|
||||
#include "pcbnew.h"
|
||||
#include "gerbview.h"
|
||||
#include "trigo.h"
|
||||
#include "class_gerber_draw_item.h"
|
||||
|
||||
|
||||
/* Display the character of the localized STRUCTURE and return a pointer
|
||||
* to it.
|
||||
/* localize a gerber item and return a pointer to it.
|
||||
* Display info about this item
|
||||
*/
|
||||
BOARD_ITEM* WinEDA_GerberFrame::Locate( int typeloc )
|
||||
GERBER_DRAW_ITEM* WinEDA_GerberFrame::Locate( int aTypeloc )
|
||||
{
|
||||
// TODO
|
||||
MsgPanel->EraseMsgBox();
|
||||
return NULL;
|
||||
wxPoint ref;
|
||||
bool found = false;
|
||||
if( aTypeloc == CURSEUR_ON_GRILLE )
|
||||
ref = GetScreen()->m_Curseur;
|
||||
else
|
||||
ref = GetScreen()->m_MousePosition;
|
||||
|
||||
int layer = GetScreen()->m_Active_Layer;
|
||||
|
||||
// Search first on active layer
|
||||
BOARD_ITEM* item = GetBoard()->m_Drawings;
|
||||
GERBER_DRAW_ITEM* gerb_item = NULL;
|
||||
for( ; item; item = item->Next() )
|
||||
{
|
||||
gerb_item = (GERBER_DRAW_ITEM*) item;
|
||||
if( gerb_item->GetLayer()!= layer )
|
||||
continue;
|
||||
if( gerb_item->HitTest( ref ) )
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( !found ) // Search on all layers
|
||||
{
|
||||
item = GetBoard()->m_Drawings;
|
||||
for( ; item; item = item->Next() )
|
||||
{
|
||||
gerb_item = (GERBER_DRAW_ITEM*) item;
|
||||
if( gerb_item->HitTest( ref ) )
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( found )
|
||||
{
|
||||
gerb_item->DisplayInfo( this );
|
||||
return gerb_item;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -104,7 +104,6 @@ static void fillFlashedGBRITEM( GERBER_DRAW_ITEM* aGbrItem,
|
|||
aGbrItem->SetLayer( aLayer );
|
||||
aGbrItem->m_Size = aSize;
|
||||
aGbrItem->m_Start = aPos;
|
||||
NEGATE( aGbrItem->m_Start.y );
|
||||
aGbrItem->m_End = aGbrItem->m_Start;
|
||||
aGbrItem->m_DCode = Dcode_index;
|
||||
aGbrItem->m_LayerNegative = aLayerNegative;
|
||||
|
@ -175,10 +174,7 @@ static void fillLineGBRITEM( GERBER_DRAW_ITEM* aGbrItem,
|
|||
aGbrItem->m_Size.x = aGbrItem->m_Size.y = aWidth;
|
||||
|
||||
aGbrItem->m_Start = aStart;
|
||||
NEGATE( aGbrItem->m_Start.y );
|
||||
|
||||
aGbrItem->m_End = aEnd;
|
||||
NEGATE( aGbrItem->m_End.y );
|
||||
|
||||
aGbrItem->m_DCode = Dcode_index;
|
||||
aGbrItem->m_LayerNegative = aLayerNegative;
|
||||
|
@ -300,10 +296,6 @@ static void fillArcGBRITEM( GERBER_DRAW_ITEM* aGbrItem, int Dcode_index, int aL
|
|||
aGbrItem->m_DCode = Dcode_index;
|
||||
aGbrItem->m_ArcCentre = center;
|
||||
|
||||
NEGATE( aGbrItem->m_Start.y );
|
||||
NEGATE( aGbrItem->m_End.y );
|
||||
NEGATE( aGbrItem->m_ArcCentre.y );
|
||||
|
||||
aGbrItem->m_LayerNegative = aLayerNegative;
|
||||
aGbrItem->m_ImageNegative = aImageNegative;
|
||||
|
||||
|
@ -358,7 +350,7 @@ static void fillArcPOLY( BOARD* aPcb, GERBER_DRAW_ITEM* aGbrItem,
|
|||
/* in order to calculate arc parameters, we use fillArcGBRITEM
|
||||
* so we muse create a dummy track and use its geometric parameters
|
||||
*/
|
||||
static GERBER_DRAW_ITEM dummyGbrItem( NULL );
|
||||
static GERBER_DRAW_ITEM dummyGbrItem( NULL, NULL );
|
||||
|
||||
aGbrItem->m_LayerNegative = aLayerNegative;
|
||||
aGbrItem->m_ImageNegative = aImageNegative;
|
||||
|
@ -861,12 +853,11 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, char*& text, int
|
|||
if( !m_Exposure )
|
||||
{
|
||||
m_Exposure = true;
|
||||
gbritem = new GERBER_DRAW_ITEM( pcb );
|
||||
gbritem = new GERBER_DRAW_ITEM( pcb, this );
|
||||
pcb->m_Drawings.Append( gbritem );
|
||||
gbritem->m_Shape = GBR_POLYGON;
|
||||
gbritem->SetLayer( activeLayer );
|
||||
gbritem->m_Flashed = false;
|
||||
gbritem->m_UnitsMetric = m_GerbMetric;
|
||||
}
|
||||
|
||||
switch( m_Iterpolation )
|
||||
|
@ -891,12 +882,10 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, char*& text, int
|
|||
// m_CurrentPos.x, m_CurrentPos.y, m_Iterpolation ); )
|
||||
|
||||
gbritem->m_Start = m_PreviousPos; // m_Start is used as temporary storage
|
||||
NEGATE( gbritem->m_Start.y );
|
||||
if( gbritem->m_PolyCorners.size() == 0 )
|
||||
gbritem->m_PolyCorners.push_back( gbritem->m_Start );
|
||||
|
||||
gbritem->m_End = m_CurrentPos; // m_End is used as temporary storage
|
||||
NEGATE( gbritem->m_End.y );
|
||||
gbritem->m_PolyCorners.push_back( gbritem->m_End );
|
||||
|
||||
// Set the erasure flag of gbritem if a negative polygon.
|
||||
|
@ -940,8 +929,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, char*& text, int
|
|||
switch( m_Iterpolation )
|
||||
{
|
||||
case GERB_INTERPOL_LINEAR_1X:
|
||||
gbritem = new GERBER_DRAW_ITEM( pcb );
|
||||
gbritem->m_UnitsMetric = m_GerbMetric;
|
||||
gbritem = new GERBER_DRAW_ITEM( pcb, this );
|
||||
pcb->m_Drawings.Append( gbritem );
|
||||
// D( printf( "Add line %d,%d to %d,%d\n",
|
||||
// m_PreviousPos.x, m_PreviousPos.y,
|
||||
|
@ -958,8 +946,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, char*& text, int
|
|||
|
||||
case GERB_INTERPOL_ARC_NEG:
|
||||
case GERB_INTERPOL_ARC_POS:
|
||||
gbritem = new GERBER_DRAW_ITEM( pcb );
|
||||
gbritem->m_UnitsMetric = m_GerbMetric;
|
||||
gbritem = new GERBER_DRAW_ITEM( pcb, this );
|
||||
pcb->m_Drawings.Append( gbritem );
|
||||
// D( printf( "Add arc %d,%d to %d,%d center %d, %d interpol %d 360_enb %d\n",
|
||||
// m_PreviousPos.x, m_PreviousPos.y, m_CurrentPos.x,
|
||||
|
@ -999,8 +986,7 @@ bool GERBER::Execute_DCODE_Command( WinEDA_GerberFrame* frame, char*& text, int
|
|||
aperture = tool->m_Shape;
|
||||
}
|
||||
|
||||
gbritem = new GERBER_DRAW_ITEM( pcb );
|
||||
gbritem->m_UnitsMetric = m_GerbMetric;
|
||||
gbritem = new GERBER_DRAW_ITEM( pcb, this );
|
||||
pcb->m_Drawings.Append( gbritem );
|
||||
// D( printf( "Add flashed dcode %d layer %d at %d %d\n", dcode, activeLayer,
|
||||
// m_CurrentPos.x, m_CurrentPos.y ); )
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
// So a gerber layer is not like a board layer or the graphic layers used in Gerbview to show a file.
|
||||
enum RS274X_PARAMETERS {
|
||||
// Directive parameters: single usage recommended
|
||||
// Must be at the beginning of the file
|
||||
AXIS_SELECT = CODE( 'A', 'S' ), // Default: A=X, B=Y
|
||||
FORMAT_STATEMENT = CODE( 'F', 'S' ), // no default: this command must exists
|
||||
MIRROR_IMAGE = CODE( 'M', 'I' ), // Default: mo mirror
|
||||
|
@ -291,7 +292,7 @@ bool GERBER::ExecuteRS274XCommand( int command,
|
|||
conv_scale = m_GerbMetric ? PCB_INTERNAL_UNIT / 25.4 : PCB_INTERNAL_UNIT;
|
||||
break;
|
||||
|
||||
case OFFSET: // command: OFAnnBnn (nn = float number)
|
||||
case OFFSET: // command: OFAnnBnn (nn = float number) = layer Offset
|
||||
m_Offset.x = m_Offset.y = 0;
|
||||
while( *text != '*' )
|
||||
{
|
||||
|
@ -310,7 +311,6 @@ bool GERBER::ExecuteRS274XCommand( int command,
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SCALE_FACTOR:
|
||||
|
@ -330,17 +330,43 @@ bool GERBER::ExecuteRS274XCommand( int command,
|
|||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
if( m_LayerScale.x != 1.0 || m_LayerScale.y != 1.0 )
|
||||
case IMAGE_OFFSET: // command: IOAnnBnn (nn = float number) = Image Offset
|
||||
m_ImageOffset.x = m_ImageOffset.y = 0;
|
||||
while( *text != '*' )
|
||||
{
|
||||
msg.Printf( _( "RS274X: FS command: Gerbview uses 1.0 only scale factor" ) );
|
||||
ReportMessage( msg );
|
||||
switch( *text )
|
||||
{
|
||||
case 'A': // A axis offset in current unit (inch or mm)
|
||||
text++;
|
||||
fcoord = ReadDouble( text );
|
||||
m_ImageOffset.x = wxRound( fcoord * conv_scale );
|
||||
break;
|
||||
|
||||
case 'B': // B axis offset in current unit (inch or mm)
|
||||
text++;
|
||||
fcoord = ReadDouble( text );
|
||||
m_ImageOffset.y = wxRound( fcoord * conv_scale );
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case IMAGE_ROTATION: // command IR0* or IR90* or IR180* or IR270*
|
||||
if( strnicmp( text, "0*", 2 ) == 0 )
|
||||
m_Rotation = 0;
|
||||
if( strnicmp( text, "90*", 2 ) == 0 )
|
||||
m_Rotation = 900;
|
||||
if( strnicmp( text, "180*", 2 ) == 0 )
|
||||
m_Rotation = 1800;
|
||||
if( strnicmp( text, "270*", 2 ) == 0 )
|
||||
m_Rotation = 2700;
|
||||
else
|
||||
ReportMessage( _( "RS274X: Command \"IR\" rotation value not allowed" ) );
|
||||
break;
|
||||
|
||||
case IMAGE_JUSTIFY:
|
||||
case IMAGE_ROTATION:
|
||||
case IMAGE_OFFSET:
|
||||
case PLOTTER_FILM:
|
||||
case KNOCKOUT:
|
||||
case STEP_AND_REPEAT:
|
||||
|
|
|
@ -167,6 +167,8 @@ void Show_Items_DCode_Value( WinEDA_DrawPanel* aPanel, wxDC* aDC, BOARD* aPcb, i
|
|||
pos.y = (gerb_item->m_Start.y + gerb_item->m_End.y) / 2;
|
||||
}
|
||||
|
||||
pos = gerb_item->GetABPosition( pos );
|
||||
|
||||
Line.Printf( wxT( "D%d" ), gerb_item->m_DCode );
|
||||
|
||||
width = MIN( gerb_item->m_Size.x, gerb_item->m_Size.y );
|
||||
|
|
|
@ -228,8 +228,8 @@ public:
|
|||
void OnSelectOptionToolbar( wxCommandEvent& event );
|
||||
void OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct );
|
||||
|
||||
BOARD_ITEM* GerberGeneralLocateAndDisplay();
|
||||
BOARD_ITEM* Locate( int typeloc );
|
||||
GERBER_DRAW_ITEM* GerberGeneralLocateAndDisplay();
|
||||
GERBER_DRAW_ITEM* Locate( int typeloc );
|
||||
|
||||
|
||||
void SetToolbars();
|
||||
|
|
|
@ -168,17 +168,23 @@ void GRArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
|||
int xc, int yc, int Color );
|
||||
void GRArc1( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
||||
int xc, int yc, int width, int Color );
|
||||
void GRArc1( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
|
||||
wxPoint aCenter, int aWidth, int aColor );
|
||||
void GRFilledArc( EDA_Rect* ClipBox, wxDC* DC, int x, int y,
|
||||
int StAngle, int EndAngle, int r, int Color, int BgColor );
|
||||
void GRFilledArc( EDA_Rect* ClipBox, wxDC* DC, int x, int y, int StAngle,
|
||||
int EndAngle, int r, int width, int Color, int BgColor );
|
||||
void GRCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, int Color );
|
||||
void GRCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
||||
int width, int aPenSize, int Color );
|
||||
|
||||
void GRFillCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
||||
int width, int Color );
|
||||
void GRFilledSegment( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
|
||||
int aWidth, int aColor );
|
||||
|
||||
void GRCSegm( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
|
||||
int width, int aPenSize, int Color );
|
||||
void GRCSegm( EDA_Rect* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
|
||||
int aWidth, int aColor );
|
||||
|
||||
void GRSetColor( int Color );
|
||||
void GRSetDefaultPalette();
|
||||
|
@ -200,7 +206,5 @@ void GRSFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1,
|
|||
|
||||
void GRLineArray( EDA_Rect* ClipBox, wxDC* DC, wxPoint points[],
|
||||
int lines, int width, int Color );
|
||||
void GRSLineArray( EDA_Rect* ClipBox, wxDC* DC, wxPoint points[],
|
||||
int lines, int width, int Color );
|
||||
|
||||
#endif /* define GR_BASIC */
|
||||
|
|
Loading…
Reference in New Issue