7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-20 13:01:41 +00:00

GerbView GAL support part 1: changes to existing files

- New GAL draw layers for GerbView
- Improved bounding boxes for Gerber shapes
- Switched to use of SHAPE_POLY_SET for polygons
- Add GAL methods to support selection and rendering
- Add GUI support of editing GAL options
- Rename get/setActiveLayer to Get/SetActiveLayer to match convention
This commit is contained in:
Jon Evans 2017-09-17 18:43:20 -04:00 committed by Maciej Suminski
parent 460b1e8540
commit 915e51e1f0
42 changed files with 1483 additions and 535 deletions

View File

@ -100,7 +100,8 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
{
#define TO_POLY_SHAPE { aShapeBuffer.NewOutline(); \
for( unsigned jj = 0; jj < polybuffer.size(); jj++ )\
aShapeBuffer.Append( polybuffer[jj].x, polybuffer[jj].y );}
aShapeBuffer.Append( polybuffer[jj].x, polybuffer[jj].y );\
aShapeBuffer.Append( polybuffer[0].x, polybuffer[0].y );}
// Draw the primitive shape for flashed items.
static std::vector<wxPoint> polybuffer; // create a static buffer to avoid a lot of memory reallocation
@ -746,6 +747,50 @@ int AM_PRIMITIVE::GetShapeDim( GERBER_DRAW_ITEM* aParent )
}
SHAPE_POLY_SET* APERTURE_MACRO::GetApertureMacroShape( GERBER_DRAW_ITEM* aParent,
wxPoint aShapePos )
{
SHAPE_POLY_SET holeBuffer;
bool hasHole = false;
m_shape.RemoveAllContours();
for( AM_PRIMITIVES::iterator prim_macro = primitives.begin();
prim_macro != primitives.end(); ++prim_macro )
{
if( prim_macro->primitive_id == AMP_COMMENT )
continue;
if( prim_macro->IsAMPrimitiveExposureOn( aParent ) )
prim_macro->DrawBasicShape( aParent, m_shape, aShapePos );
else
{
prim_macro->DrawBasicShape( aParent, holeBuffer, aShapePos );
if( holeBuffer.OutlineCount() ) // we have a new hole in shape: remove the hole
{
m_shape.BooleanSubtract( holeBuffer, SHAPE_POLY_SET::PM_FAST );
holeBuffer.RemoveAllContours();
hasHole = true;
}
}
}
// If a hole is defined inside a polygon, we must fracture the polygon
// to be able to drawn it (i.e link holes by overlapping edges)
if( hasHole )
m_shape.Fracture( SHAPE_POLY_SET::PM_FAST );
m_boundingBox = EDA_RECT( wxPoint( 0, 0 ), wxSize( 1, 1 ) );
auto bb = m_shape.BBox();
wxPoint center( bb.Centre().x, bb.Centre().y );
m_boundingBox.Move( aParent->GetABPosition( center ) );
m_boundingBox.Inflate( bb.GetWidth() / 2, bb.GetHeight() / 2 );
return &m_shape;
}
/*
* Function DrawApertureMacroShape
* Draw the primitive shape for flashed items.
@ -756,39 +801,14 @@ void APERTURE_MACRO::DrawApertureMacroShape( GERBER_DRAW_ITEM* aParent,
COLOR4D aColor,
wxPoint aShapePos, bool aFilledShape )
{
SHAPE_POLY_SET shapeBuffer;
SHAPE_POLY_SET holeBuffer;
bool hasHole = false;
SHAPE_POLY_SET* shapeBuffer = GetApertureMacroShape( aParent, aShapePos );
for( AM_PRIMITIVES::iterator prim_macro = primitives.begin();
prim_macro != primitives.end(); ++prim_macro )
{
if( prim_macro->IsAMPrimitiveExposureOn( aParent ) )
prim_macro->DrawBasicShape( aParent, shapeBuffer, aShapePos );
else
{
prim_macro->DrawBasicShape( aParent, holeBuffer, aShapePos );
if( holeBuffer.OutlineCount() ) // we have a new hole in shape: remove the hole
{
shapeBuffer.BooleanSubtract( holeBuffer, SHAPE_POLY_SET::PM_FAST );
holeBuffer.RemoveAllContours();
hasHole = true;
}
}
}
if( shapeBuffer.OutlineCount() == 0 )
if( shapeBuffer->OutlineCount() == 0 )
return;
// If a hole is defined inside a polygon, we must fracture the polygon
// to be able to drawn it (i.e link holes by overlapping edges)
if( hasHole )
shapeBuffer.Fracture( SHAPE_POLY_SET::PM_FAST );
for( int ii = 0; ii < shapeBuffer.OutlineCount(); ii++ )
for( int ii = 0; ii < shapeBuffer->OutlineCount(); ii++ )
{
SHAPE_LINE_CHAIN& poly = shapeBuffer.Outline( ii );
SHAPE_LINE_CHAIN& poly = shapeBuffer->Outline( ii );
GRClosedPoly( aClipBox, aDC,
poly.PointCount(), (wxPoint*)&poly.Point( 0 ), aFilledShape, aColor, aColor );

View File

@ -35,6 +35,7 @@
#include <base_struct.h>
#include <class_am_param.h>
#include <class_eda_rect.h>
class SHAPE_POLY_SET;
@ -170,6 +171,9 @@ struct APERTURE_MACRO
*/
AM_PARAMS m_localparamStack;
SHAPE_POLY_SET m_shape; ///< The shape of the item, calculated by GetApertureMacroShape
EDA_RECT m_boundingBox; ///< The bounding box of the item, calculated by GetApertureMacroShape
/**
* function GetLocalParam
* Usually, parameters are defined inside the aperture primitive
@ -183,6 +187,16 @@ struct APERTURE_MACRO
*/
double GetLocalParam( const D_CODE* aDcode, unsigned aParamId ) const;
/**
* Function GetApertureMacroShape
* Calculate the primitive shape for flashed items.
* When an item is flashed, this is the shape of the item
* @param aParent = the parent GERBER_DRAW_ITEM which is actually drawn
* @return The shape of the item
*/
SHAPE_POLY_SET* GetApertureMacroShape( GERBER_DRAW_ITEM* aParent, wxPoint aShapePos );
/**
* Function DrawApertureMacroShape
* Draw the primitive shape for flashed items.
@ -210,6 +224,12 @@ struct APERTURE_MACRO
* @return a dimension, or -1 if no dim to calculate
*/
int GetShapeDim( GERBER_DRAW_ITEM* aParent );
/// Returns the bounding box of the shape
EDA_RECT GetBoundingBox() const
{
return m_boundingBox;
}
};

View File

@ -47,6 +47,8 @@ public:
bool m_DisplayNegativeObjects; ///< Option to draw negative objects in a specific color
bool m_IsPrinting; ///< true when printing a page, false when drawing on screen
bool m_ForceBlackAndWhite; ///< Option print in blackand white (ont used id draw mode
bool m_DiffMode; ///< Display layers in diff mode
bool m_HighContrastMode; ///< High contrast mode (dim un-highlighted objects)
COLOR4D m_NegativeDrawColor; ///< The color used to draw negative objects, usually the
///< background color, but not always, when negative objects
///< must be visible
@ -65,6 +67,8 @@ public:
m_ForceBlackAndWhite = false;
m_NegativeDrawColor = COLOR4D( DARKGRAY );
m_BgDrawColor = COLOR4D::BLACK;
m_DiffMode = true;
m_HighContrastMode = false;
}
};

View File

@ -73,7 +73,7 @@ COLOR4D GBR_LAYER_BOX_SELECTOR::GetLayerColor( int aLayer ) const
{
GERBVIEW_FRAME* frame = (GERBVIEW_FRAME*) GetParent()->GetParent();
return frame->GetLayerColor( aLayer );
return frame->GetLayerColor( GERBER_DRAW_LAYER( aLayer ) );
}

View File

@ -36,7 +36,8 @@
#include <class_gerber_file_image.h>
#include <class_gerber_file_image_list.h>
GBR_LAYOUT::GBR_LAYOUT()
GBR_LAYOUT::GBR_LAYOUT() :
EDA_ITEM( (EDA_ITEM*)NULL, GERBER_LAYOUT_T )
{
}
@ -46,7 +47,7 @@ GBR_LAYOUT::~GBR_LAYOUT()
}
// Accessor to the list of gerber files (and drill files) images
GERBER_FILE_IMAGE_LIST* GBR_LAYOUT::GetImagesList()
GERBER_FILE_IMAGE_LIST* GBR_LAYOUT::GetImagesList() const
{
return &GERBER_FILE_IMAGE_LIST::GetImagesList();
}
@ -64,7 +65,7 @@ bool GBR_LAYOUT::IsLayerPrintable( int aLayer ) const
}
EDA_RECT GBR_LAYOUT::ComputeBoundingBox()
EDA_RECT GBR_LAYOUT::ComputeBoundingBox() const
{
EDA_RECT bbox;
bool first_item = true;
@ -88,7 +89,10 @@ EDA_RECT GBR_LAYOUT::ComputeBoundingBox()
}
}
SetBoundingBox( bbox );
bbox.Inflate( ( bbox.GetWidth() / 10 ) + 100 );
bbox.Normalize();
m_BoundingBox = bbox;
return bbox;
}
@ -185,7 +189,7 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
// In non transparent modes, the last layer drawn masks others layers
for( int layer = GERBER_DRAWLAYERS_COUNT-1; !end; --layer )
{
int active_layer = gerbFrame->getActiveLayer();
int active_layer = gerbFrame->GetActiveLayer();
if( layer == active_layer ) // active layer will be drawn after other layers
continue;
@ -204,12 +208,12 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
if( aDisplayOptions->m_IsPrinting )
gerber->m_IsVisible = IsLayerPrintable( layer );
else
gerber->m_IsVisible = gerbFrame->IsLayerVisible( layer );
gerber->m_IsVisible = gerbFrame->IsLayerVisible( GERBER_DRAW_LAYER( layer ) );
if( !gerber->m_IsVisible )
continue;
gerber->m_PositiveDrawColor = gerbFrame->GetLayerColor( layer );
gerber->m_PositiveDrawColor = gerbFrame->GetLayerColor( GERBER_DRAW_LAYER( layer ) );
// Force black and white draw mode on request:
if( aDisplayOptions->m_ForceBlackAndWhite )
@ -277,7 +281,7 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
int dcode_highlight = 0;
if( layer == gerbFrame->getActiveLayer() )
if( layer == gerbFrame->GetActiveLayer() )
dcode_highlight = gerber->m_Selected_Tool;
GR_DRAWMODE layerdrawMode = GR_COPY;
@ -433,3 +437,50 @@ void GBR_LAYOUT::DrawItemsDCodeID( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
}
}
}
SEARCH_RESULT GBR_LAYOUT::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] )
{
KICAD_T stype;
SEARCH_RESULT result = SEARCH_CONTINUE;
const KICAD_T* p = scanTypes;
bool done = false;
#if 0 && defined(DEBUG)
std::cout << GetClass().mb_str() << ' ';
#endif
while( !done )
{
stype = *p;
switch( stype )
{
case GERBER_IMAGE_LIST_T:
for( unsigned layer = 0; layer < GetImagesList()->ImagesMaxCount(); ++layer )
{
GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( layer );
if( gerber == NULL ) // Graphic layer not yet used
continue;
result = gerber->Visit( inspector, testData, p );
if( result == SEARCH_QUIT )
break;
}
++p;
break;
default: // catch EOT or ANY OTHER type here and return.
done = true;
break;
}
if( result == SEARCH_QUIT )
break;
}
return result;
}

View File

@ -50,10 +50,10 @@ class GERBER_FILE_IMAGE_LIST;
* Class GBR_LAYOUT
* holds list of GERBER_DRAW_ITEM currently loaded.
*/
class GBR_LAYOUT
class GBR_LAYOUT : public EDA_ITEM
{
private:
EDA_RECT m_BoundingBox;
mutable EDA_RECT m_BoundingBox;
TITLE_BLOCK m_titles;
wxPoint m_originAxisPosition;
std::vector<int> m_printLayersList; // When printing: the list of graphic layers Id to print
@ -63,9 +63,14 @@ public:
GBR_LAYOUT();
~GBR_LAYOUT();
wxString GetClass() const override
{
return wxT( "GBR_LAYOUT" );
}
// Accessor to the GERBER_FILE_IMAGE_LIST,
// which handles the list of gerber files (and drill files) images loaded
GERBER_FILE_IMAGE_LIST* GetImagesList();
GERBER_FILE_IMAGE_LIST* GetImagesList() const;
const wxPoint& GetAuxOrigin() const
{
@ -92,14 +97,15 @@ public:
* calculates the bounding box containing all Gerber items.
* @return EDA_RECT - the full item list bounding box
*/
EDA_RECT ComputeBoundingBox();
EDA_RECT ComputeBoundingBox() const;
/**
* Function GetBoundingBox
* may be called soon after ComputeBoundingBox() to return the same EDA_RECT,
* as long as the CLASS_GBR_LAYOUT has not changed.
*/
EDA_RECT GetBoundingBox() const { return m_BoundingBox; }
const EDA_RECT GetBoundingBox() const override
{
return ComputeBoundingBox();
}
void SetBoundingBox( const EDA_RECT& aBox ) { m_BoundingBox = aBox; }
@ -176,8 +182,13 @@ public:
*/
bool IsLayerPrintable( int aLayer ) const;
///> @copydoc EDA_ITEM::Visit()
SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const;
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
#endif
};

View File

@ -33,6 +33,7 @@
#include <class_drawpanel.h>
#include <msgpanel.h>
#include <gerbview_frame.h>
#include <convert_basic_shapes_to_polygon.h>
#include <class_gerber_draw_item.h>
#include <class_gerber_file_image.h>
@ -40,7 +41,7 @@
GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( GERBER_FILE_IMAGE* aGerberImageFile ) :
EDA_ITEM( (EDA_ITEM*)NULL, TYPE_GERBER_DRAW_ITEM )
EDA_ITEM( (EDA_ITEM*)NULL, GERBER_DRAW_ITEM_T )
{
m_GerberImageFile = aGerberImageFile;
m_Shape = GBR_SEGMENT;
@ -158,7 +159,7 @@ void GERBER_DRAW_ITEM::SetLayerParameters()
}
wxString GERBER_DRAW_ITEM::ShowGBRShape()
wxString GERBER_DRAW_ITEM::ShowGBRShape() const
{
switch( m_Shape )
{
@ -203,7 +204,7 @@ wxString GERBER_DRAW_ITEM::ShowGBRShape()
}
D_CODE* GERBER_DRAW_ITEM::GetDcodeDescr()
D_CODE* GERBER_DRAW_ITEM::GetDcodeDescr() const
{
if( (m_DCode < FIRST_DCODE) || (m_DCode > LAST_DCODE) )
return NULL;
@ -211,7 +212,7 @@ D_CODE* GERBER_DRAW_ITEM::GetDcodeDescr()
if( m_GerberImageFile == NULL )
return NULL;
return m_GerberImageFile->GetDCODE( m_DCode, false );
return m_GerberImageFile->GetDCODE( m_DCode );
}
@ -219,8 +220,100 @@ const EDA_RECT GERBER_DRAW_ITEM::GetBoundingBox() const
{
// return a rectangle which is (pos,dim) in nature. therefore the +1
EDA_RECT bbox( m_Start, wxSize( 1, 1 ) );
D_CODE* code = GetDcodeDescr();
bbox.Inflate( m_Size.x / 2, m_Size.y / 2 );
// TODO(JE) GERBER_DRAW_ITEM maybe should actually be a number of subclasses.
// Until/unless that is changed, we need to do different things depending on
// what is actually being represented by this GERBER_DRAW_ITEM.
switch( m_Shape )
{
case GBR_POLYGON:
{
auto bb = m_Polygon.BBox();
bbox.Inflate( bb.GetWidth() / 2, bb.GetHeight() / 2 );
bbox.SetOrigin( bb.GetOrigin().x, bb.GetOrigin().y );
break;
}
case GBR_CIRCLE:
{
double radius = GetLineLength( m_Start, m_End );
bbox.Inflate( radius, radius );
break;
}
case GBR_ARC:
{
// Note: using a larger-than-necessary BB to simplify computation
double radius = GetLineLength( m_Start, m_ArcCentre );
bbox.Inflate( radius, radius );
break;
}
case GBR_SPOT_CIRCLE:
{
int radius = code->m_Size.x >> 1;
bbox.Inflate( radius, radius );
break;
}
case GBR_SPOT_RECT:
{
bbox.Inflate( code->m_Size.x / 2, code->m_Size.y / 2 );
break;
}
case GBR_SPOT_OVAL:
{
bbox.Inflate( code->m_Size.x, code->m_Size.y );
break;
}
case GBR_SPOT_POLY:
{
if( code->m_Polygon.OutlineCount() == 0 )
code->ConvertShapeToPolygon();
bbox.Inflate( code->m_Polygon.BBox().GetWidth() / 2, code->m_Polygon.BBox().GetHeight() / 2 );
break;
}
case GBR_SPOT_MACRO:
{
bbox = code->GetMacro()->GetBoundingBox();
break;
}
case GBR_SEGMENT:
{
if( code && code->m_Shape == APT_RECT )
{
if( m_Polygon.OutlineCount() > 0 )
{
auto bb = m_Polygon.BBox();
bbox.Inflate( bb.GetWidth() / 2, bb.GetHeight() / 2 );
bbox.SetOrigin( bb.GetOrigin().x, bb.GetOrigin().y );
}
}
else
{
int radius = ( m_Size.x + 1 ) / 2;
int ymax = std::max( m_Start.y, m_End.y ) + radius;
int xmax = std::max( m_Start.x, m_End.x ) + radius;
int ymin = std::min( m_Start.y, m_End.y ) - radius;
int xmin = std::min( m_Start.x, m_End.x ) - radius;
bbox = EDA_RECT( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
}
break;
}
default:
wxASSERT_MSG( false, wxT( "GERBER_DRAW_ITEM shape is unknown!" ) );
break;
}
// calculate the corners coordinates in current gerber axis orientations
wxPoint org = GetABPosition( bbox.GetOrigin() );
@ -243,8 +336,11 @@ void GERBER_DRAW_ITEM::MoveAB( const wxPoint& aMoveVector )
m_End += xymove;
m_ArcCentre += xymove;
for( unsigned ii = 0; ii < m_PolyCorners.size(); ii++ )
m_PolyCorners[ii] += xymove;
if( m_Polygon.OutlineCount() > 0 )
{
for( auto it = m_Polygon.Iterate( 0 ); it; ++it )
*it += xymove;
}
}
@ -254,8 +350,11 @@ void GERBER_DRAW_ITEM::MoveXY( const wxPoint& aMoveVector )
m_End += aMoveVector;
m_ArcCentre += aMoveVector;
for( unsigned ii = 0; ii < m_PolyCorners.size(); ii++ )
m_PolyCorners[ii] += aMoveVector;
if( m_Polygon.OutlineCount() > 0 )
{
for( auto it = m_Polygon.Iterate( 0 ); it; ++it )
*it += aMoveVector;
}
}
@ -378,8 +477,8 @@ void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDra
*/
if( d_codeDescr->m_Shape == APT_RECT )
{
if( m_PolyCorners.size() == 0 )
ConvertSegmentToPolygon( );
if( m_Polygon.OutlineCount() == 0 )
ConvertSegmentToPolygon();
DrawGbrPoly( aPanel->GetClipBox(), aDC, color, aOffset, isFilled );
}
@ -411,10 +510,10 @@ void GERBER_DRAW_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDra
}
void GERBER_DRAW_ITEM::ConvertSegmentToPolygon( )
void GERBER_DRAW_ITEM::ConvertSegmentToPolygon()
{
m_PolyCorners.clear();
m_PolyCorners.reserve(6);
m_Polygon.RemoveAllContours();
m_Polygon.NewOutline();
wxPoint start = m_Start;
wxPoint end = m_End;
@ -443,34 +542,37 @@ void GERBER_DRAW_ITEM::ConvertSegmentToPolygon( )
wxPoint corner;
corner.x -= m_Size.x/2;
corner.y -= m_Size.y/2;
m_PolyCorners.push_back( corner ); // Lower left corner, start point (1)
wxPoint close = corner;
m_Polygon.Append( VECTOR2I( corner ) ); // Lower left corner, start point (1)
corner.y += m_Size.y;
m_PolyCorners.push_back( corner ); // upper left corner, start point (2)
m_Polygon.Append( VECTOR2I( corner ) ); // upper left corner, start point (2)
if( delta.x || delta.y)
{
corner += delta;
m_PolyCorners.push_back( corner ); // upper left corner, end point (3)
m_Polygon.Append( VECTOR2I( corner ) ); // upper left corner, end point (3)
}
corner.x += m_Size.x;
m_PolyCorners.push_back( corner ); // upper right corner, end point (4)
m_Polygon.Append( VECTOR2I( corner ) ); // upper right corner, end point (4)
corner.y -= m_Size.y;
m_PolyCorners.push_back( corner ); // lower right corner, end point (5)
m_Polygon.Append( VECTOR2I( corner ) ); // lower right corner, end point (5)
if( delta.x || delta.y )
{
corner -= delta;
m_PolyCorners.push_back( corner ); // lower left corner, start point (6)
m_Polygon.Append( VECTOR2I( corner ) ); // lower left corner, start point (6)
}
m_Polygon.Append( VECTOR2I( close ) ); // close the shape
// Create final polygon:
for( unsigned ii = 0; ii < m_PolyCorners.size(); ii++ )
for( auto it = m_Polygon.Iterate( 0 ); it; ++it )
{
if( change )
m_PolyCorners[ii].y = -m_PolyCorners[ii].y;
( *it ).y = -( *it ).y;
m_PolyCorners[ii] += start;
*it += start;
}
}
@ -482,15 +584,19 @@ void GERBER_DRAW_ITEM::DrawGbrPoly( EDA_RECT* aClipBox,
bool aFilledShape )
{
std::vector<wxPoint> points;
SHAPE_LINE_CHAIN& poly = m_Polygon.Outline( 0 );
int pointCount = poly.PointCount() - 1;
points = m_PolyCorners;
for( unsigned ii = 0; ii < points.size(); ii++ )
points.reserve( pointCount );
for( int ii = 0; ii < pointCount; ii++ )
{
points[ii] += aOffset;
points[ii] = GetABPosition( points[ii] );
wxPoint p( poly.Point( ii ).x, poly.Point( ii ).y );
points[ii] = p + aOffset;
points[ii] = GetABPosition( points[ii] );
}
GRClosedPoly( aClipBox, aDC, points.size(), &points[0], aFilledShape, aColor, aColor );
GRClosedPoly( aClipBox, aDC, pointCount, &points[0], aFilledShape, aColor, aColor );
}
@ -506,7 +612,7 @@ void GERBER_DRAW_ITEM::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
msg.Printf( _( "D Code %d" ), m_DCode );
D_CODE* apertDescr = GetDcodeDescr();
if( apertDescr->m_AperFunction.IsEmpty() )
if( !apertDescr || apertDescr->m_AperFunction.IsEmpty() )
text = _( "No attribute" );
else
text = apertDescr->m_AperFunction;
@ -582,6 +688,37 @@ bool GERBER_DRAW_ITEM::HitTest( const wxPoint& aRefPos ) const
// TODO: a better analyze of the shape (perhaps create a D_CODE::HitTest for flashed items)
int radius = std::min( m_Size.x, m_Size.y ) >> 1;
SHAPE_POLY_SET poly;
switch( m_Shape )
{
case GBR_POLYGON:
poly = m_Polygon;
return poly.Contains( VECTOR2I( ref_pos ), 0 );
break;
case GBR_SPOT_POLY:
poly = GetDcodeDescr()->m_Polygon;
poly.Move( m_Start );
return poly.Contains( VECTOR2I( ref_pos ), 0 );
break;
case GBR_SPOT_RECT:
return GetBoundingBox().Contains( aRefPos );
break;
case GBR_SPOT_MACRO:
// Aperture macro polygons are already in absolute coordinates
poly = GetDcodeDescr()->GetMacro()->m_shape;
for( int i = 0; i < poly.OutlineCount(); ++i )
{
if( poly.Contains( VECTOR2I( aRefPos ), i ) )
return true;
}
return false;
break;
}
if( m_Flashed )
return HitTestPoints( m_Start, ref_pos, radius );
else
@ -624,3 +761,60 @@ void GERBER_DRAW_ITEM::Show( int nestLevel, std::ostream& os ) const
}
#endif
void GERBER_DRAW_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
{
aCount = 2;
aLayers[0] = GERBER_DRAW_LAYER( GetLayer() );
aLayers[1] = GERBER_DCODE_LAYER( aLayers[0] );
}
const BOX2I GERBER_DRAW_ITEM::ViewBBox() const
{
EDA_RECT bbox = GetBoundingBox();
return BOX2I( VECTOR2I( bbox.GetOrigin() ),
VECTOR2I( bbox.GetSize() ) );
}
unsigned int GERBER_DRAW_ITEM::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
{
// DCodes will be shown only if zoom is appropriate
if( IsDCodeLayer( aLayer ) )
{
return ( 400000 / ( m_Size.x + 1 ) );
}
// Other layers are shown without any conditions
return 0;
}
SEARCH_RESULT GERBER_DRAW_ITEM::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] )
{
KICAD_T stype = *scanTypes;
// If caller wants to inspect my type
if( stype == Type() )
{
if( SEARCH_QUIT == inspector( this, testData ) )
return SEARCH_QUIT;
}
return SEARCH_CONTINUE;
}
wxString GERBER_DRAW_ITEM::GetSelectMenuText() const
{
wxString text, layerName;
layerName = GERBER_FILE_IMAGE_LIST::GetImagesList().GetDisplayName( GetLayer(), true );
text.Printf( _( "%s (D%d) on layer %d: %s" ), ShowGBRShape(), m_DCode,
GetLayer() + 1, layerName );
return text;
}

View File

@ -35,6 +35,7 @@
#include <gr_basic.h>
#include <gbr_netlist_metadata.h>
#include <dcode.h>
#include <geometry/shape_poly_set.h>
class GERBER_FILE_IMAGE;
class GBR_LAYOUT;
@ -42,6 +43,11 @@ class D_CODE;
class MSG_PANEL_ITEM;
class GBR_DISPLAY_OPTIONS;
namespace KIGFX
{
class VIEW;
};
/* Shapes id for basic shapes ( .m_Shape member ) */
enum Gbr_Basic_Shapes {
@ -76,7 +82,7 @@ public:
// 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)
SHAPE_POLY_SET m_Polygon; // Polygon shape data (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
@ -116,7 +122,7 @@ public:
GERBER_DRAW_ITEM* Back() const { return static_cast<GERBER_DRAW_ITEM*>( Pback ); }
void SetNetAttributes( const GBR_NETLIST_METADATA& aNetAttributes );
const GBR_NETLIST_METADATA& GetNetAttributes() { return m_netAttributes; }
const GBR_NETLIST_METADATA& GetNetAttributes() const { return m_netAttributes; }
/**
* Function GetLayer
@ -124,7 +130,7 @@ public:
*/
int GetLayer() const;
bool GetLayerPolarity()
bool GetLayerPolarity() const
{
return m_LayerNegative;
}
@ -186,6 +192,11 @@ public:
*/
wxPoint GetABPosition( const wxPoint& aXYPosition ) const;
VECTOR2I GetABPosition( const VECTOR2I& aXYPosition ) const
{
return VECTOR2I( GetABPosition( wxPoint( aXYPosition.x, aXYPosition.y ) ) );
}
/**
* Function GetXYPosition
* returns the image position of aPosition for this object.
@ -201,7 +212,7 @@ public:
* returns the GetDcodeDescr of this object, or NULL.
* @return D_CODE* - a pointer to the DCode description (for flashed items).
*/
D_CODE* GetDcodeDescr();
D_CODE* GetDcodeDescr() const;
const EDA_RECT GetBoundingBox() const override;
@ -229,7 +240,7 @@ public:
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override;
wxString ShowGBRShape();
wxString ShowGBRShape() const;
/**
* Function HitTest
@ -284,6 +295,26 @@ public:
void Show( int nestLevel, std::ostream& os ) const override;
#endif
/// @copydoc VIEW_ITEM::ViewGetLayers()
virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
/// @copydoc VIEW_ITEM::ViewBBox()
virtual const BOX2I ViewBBox() const override;
/// @copydoc VIEW_ITEM::ViewGetLOD()
virtual unsigned int ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
///> @copydoc EDA_ITEM::Visit()
SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
virtual wxString GetSelectMenuText() const override;
};
class GERBER_NEGATIVE_IMAGE_BACKDROP : public EDA_ITEM
{
};
#endif /* CLASS_GERBER_DRAW_ITEM_H */

View File

@ -89,7 +89,8 @@ void GERBER_LAYER::ResetDefaultValues()
}
GERBER_FILE_IMAGE::GERBER_FILE_IMAGE( int aLayer )
GERBER_FILE_IMAGE::GERBER_FILE_IMAGE( int aLayer ) :
EDA_ITEM( (EDA_ITEM*)NULL, GERBER_IMAGE_T )
{
m_GraphicLayer = aLayer; // Graphic layer Number
m_IsVisible = true; // must be drawn
@ -126,7 +127,8 @@ GERBER_DRAW_ITEM * GERBER_FILE_IMAGE::GetItemsList()
return m_Drawings;
}
D_CODE* GERBER_FILE_IMAGE::GetDCODE( int aDCODE, bool aCreateIfNoExist )
D_CODE* GERBER_FILE_IMAGE::GetDCODEOrCreate( int aDCODE, bool aCreateIfNoExist )
{
unsigned ndx = aDCODE - FIRST_DCODE;
@ -146,6 +148,19 @@ D_CODE* GERBER_FILE_IMAGE::GetDCODE( int aDCODE, bool aCreateIfNoExist )
}
D_CODE* GERBER_FILE_IMAGE::GetDCODE( int aDCODE ) const
{
unsigned ndx = aDCODE - FIRST_DCODE;
if( ndx < (unsigned) DIM( m_Aperture_List ) )
{
return m_Aperture_List[ndx];
}
return NULL;
}
APERTURE_MACRO* GERBER_FILE_IMAGE::FindApertureMacro( const APERTURE_MACRO& aLookup )
{
APERTURE_MACRO_SET::iterator iter = m_aperture_macros.find( aLookup );
@ -370,3 +385,43 @@ void GERBER_FILE_IMAGE::RemoveAttribute( X2_ATTRIBUTE& aAttribute )
if( aAttribute.GetPrm( 1 ).IsEmpty() || aAttribute.GetPrm( 1 ) == ".AperFunction" )
m_AperFunction.Clear();
}
SEARCH_RESULT GERBER_FILE_IMAGE::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] )
{
KICAD_T stype;
SEARCH_RESULT result = SEARCH_CONTINUE;
const KICAD_T* p = scanTypes;
bool done = false;
#if 0 && defined(DEBUG)
std::cout << GetClass().mb_str() << ' ';
#endif
while( !done )
{
stype = *p;
switch( stype )
{
case GERBER_IMAGE_T:
case GERBER_IMAGE_LIST_T:
++p;
break;
case GERBER_DRAW_ITEM_T:
result = IterateForward( &m_Drawings[0], inspector, testData, p );
++p;
break;
default: // catch EOT or ANY OTHER type here and return.
done = true;
break;
}
if( result == SEARCH_QUIT )
break;
}
return result;
}

View File

@ -95,7 +95,7 @@ private:
* holds the Image data and parameters for one gerber file
* and layer parameters (TODO: move them in GERBER_LAYER class
*/
class GERBER_FILE_IMAGE
class GERBER_FILE_IMAGE : public EDA_ITEM
{
D_CODE* m_Aperture_List[TOOLS_MAX_COUNT]; ///< Dcode (Aperture) List for this layer (max 999)
bool m_Exposure; ///< whether an aperture macro tool is flashed on or off
@ -180,6 +180,11 @@ public:
GERBER_FILE_IMAGE( int layer );
virtual ~GERBER_FILE_IMAGE();
wxString GetClass() const override
{
return wxT( "GERBER_FILE_IMAGE" );
}
void Clear_GERBER_FILE_IMAGE();
/**
@ -300,7 +305,7 @@ public:
/**
* Function GetDCODE
* Function GetDCODEOrCreate
* returns a pointer to the D_CODE within this GERBER for the given
* \a aDCODE.
* @param aDCODE The numeric value of the D_CODE to look up.
@ -309,7 +314,17 @@ public:
* @return D_CODE* - the one implied by the given \a aDCODE, or NULL
* if the requested \a aDCODE is out of range.
*/
D_CODE* GetDCODE( int aDCODE, bool aCreateIfNoExist = true );
D_CODE* GetDCODEOrCreate( int aDCODE, bool aCreateIfNoExist = true );
/**
* Function GetDCODE
* returns a pointer to the D_CODE within this GERBER for the given
* \a aDCODE.
* @param aDCODE The numeric value of the D_CODE to look up.
* @return D_CODE* - the one implied by the given \a aDCODE, or NULL
* if the requested \a aDCODE is out of range.
*/
D_CODE* GetDCODE( int aDCODE ) const;
/**
* Function FindApertureMacro
@ -350,6 +365,15 @@ public:
* only this attribute is cleared
*/
void RemoveAttribute( X2_ATTRIBUTE& aAttribute );
///> @copydoc EDA_ITEM::Visit()
SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
#endif
};
#endif // ifndef CLASS_GERBER_FILE_IMAGE_H

View File

@ -43,7 +43,8 @@ GERBER_FILE_IMAGE_LIST s_GERBER_List;
// GERBER_FILE_IMAGE_LIST is a helper class to handle a list of GERBER_FILE_IMAGE files
GERBER_FILE_IMAGE_LIST::GERBER_FILE_IMAGE_LIST()
GERBER_FILE_IMAGE_LIST::GERBER_FILE_IMAGE_LIST() :
EDA_ITEM( (EDA_ITEM*)NULL, GERBER_IMAGE_LIST_T )
{
m_GERBER_List.reserve( GERBER_DRAWLAYERS_COUNT );
@ -244,4 +245,3 @@ void GERBER_FILE_IMAGE_LIST::SortImagesByZOrder()
gerber->m_GraphicLayer = layer ;
}
}

View File

@ -59,7 +59,7 @@ class GERBER_FILE_IMAGE;
* which are loaded and can be displayed
* there are 32 images max which can be loaded
*/
class GERBER_FILE_IMAGE_LIST
class GERBER_FILE_IMAGE_LIST : public EDA_ITEM
{
// the list of loaded images (1 image = 1 gerber file)
std::vector<GERBER_FILE_IMAGE*> m_GERBER_List;
@ -68,6 +68,11 @@ public:
GERBER_FILE_IMAGE_LIST();
~GERBER_FILE_IMAGE_LIST();
wxString GetClass() const override
{
return wxT( "GERBER_FILE_IMAGE_LIST" );
}
//Accessor
static GERBER_FILE_IMAGE_LIST& GetImagesList();
GERBER_FILE_IMAGE* GetGbrImage( int aIdx );
@ -115,6 +120,12 @@ public:
* (SortImagesByZOrder updates the graphic layer of these items)
*/
void SortImagesByZOrder();
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
#endif
};
#endif // ifndef CLASS_GERBER_FILE_IMAGE_LIST_H

View File

@ -41,6 +41,10 @@
#include <layer_widget.h>
#include <class_gerbview_layer_widget.h>
#include <view/view.h>
#include <gerbview_painter.h>
#include <gal/graphics_abstraction_layer.h>
/*
* Class GERBER_LAYER_WIDGET
@ -80,6 +84,12 @@ GERBER_FILE_IMAGE_LIST* GERBER_LAYER_WIDGET::GetImagesList()
}
bool GERBER_LAYER_WIDGET::AreArbitraryColorsAllowed()
{
return myframe->IsGalCanvasActive();
}
void GERBER_LAYER_WIDGET::SetLayersManagerTabsText( )
{
m_notebook->SetPageText(0, _("Layer") );
@ -180,8 +190,11 @@ void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
int layer = getDecodedId( cb->GetId() );
bool loc_visible = visible;
if( force_active_layer_visible && (layer == myframe->getActiveLayer() ) )
if( force_active_layer_visible &&
(layer == GERBER_DRAW_LAYER( myframe->GetActiveLayer() ) ) )
{
loc_visible = true;
}
cb->SetValue( loc_visible );
@ -228,8 +241,19 @@ void GERBER_LAYER_WIDGET::ReFill()
{
wxString msg = GetImagesList()->GetDisplayName( layer );
AppendLayerRow( LAYER_WIDGET::ROW( msg, layer,
myframe->GetLayerColor( layer ), wxEmptyString, true ) );
bool visible = true;
if( auto canvas = myframe->GetGalCanvas() )
{
visible = canvas->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( layer ) );
}
else
{
visible = myframe->IsLayerVisible( layer );
}
AppendLayerRow( LAYER_WIDGET::ROW( msg, GERBER_DRAW_LAYER( layer ),
myframe->GetLayerColor( GERBER_DRAW_LAYER( layer ) ),
wxEmptyString, visible, true ) );
}
Thaw();
@ -246,6 +270,14 @@ void GERBER_LAYER_WIDGET::OnLayerColorChange( int aLayer, COLOR4D aColor )
{
myframe->SetLayerColor( aLayer, aColor );
myframe->m_SelLayerBox->ResyncBitmapOnly();
if( myframe->IsGalCanvasActive() )
{
KIGFX::VIEW* view = myframe->GetGalCanvas()->GetView();
view->GetPainter()->GetSettings()->ImportLegacyColors( myframe->m_colorsSettings );
view->UpdateLayerColor( aLayer );
}
myframe->GetCanvas()->Refresh();
}
@ -253,11 +285,13 @@ bool GERBER_LAYER_WIDGET::OnLayerSelect( int aLayer )
{
// the layer change from the GERBER_LAYER_WIDGET can be denied by returning
// false from this function.
int layer = myframe->getActiveLayer( );
myframe->setActiveLayer( aLayer, false );
int layer = myframe->GetActiveLayer( );
// TODO(JE) ActiveLayer is stored as an index from 0 rather than as a layer
// id matching GERBER_DRAW_LAYER( idx ), is this what we want long-term?
myframe->SetActiveLayer( GERBER_DRAW_LAYER_INDEX( aLayer ), false );
myframe->syncLayerBox();
if( layer != myframe->getActiveLayer( ) )
if( layer != myframe->GetActiveLayer( ) )
{
if( ! OnLayerSelected() )
myframe->GetCanvas()->Refresh();
@ -284,13 +318,48 @@ void GERBER_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFin
void GERBER_LAYER_WIDGET::OnRenderColorChange( int aId, COLOR4D aColor )
{
myframe->SetVisibleElementColor( (GERBVIEW_LAYER_ID) aId, aColor );
myframe->GetCanvas()->Refresh();
auto galCanvas = myframe->GetGalCanvas();
if( galCanvas && myframe->IsGalCanvasActive() )
{
auto view = galCanvas->GetView();
view->GetPainter()->GetSettings()->ImportLegacyColors( myframe->m_colorsSettings );
view->UpdateLayerColor( aId );
// TODO(JE) Why are the below two lines needed? Not needed in pcbnew
view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
view->RecacheAllItems();
}
if( galCanvas && myframe->IsGalCanvasActive() )
galCanvas->Refresh();
else
myframe->GetCanvas()->Refresh();
}
void GERBER_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled )
{
myframe->SetElementVisibility( (GERBVIEW_LAYER_ID) aId, isEnabled );
myframe->GetCanvas()->Refresh();
auto galCanvas = myframe->GetGalCanvas();
if( galCanvas )
{
if( aId == LAYER_GERBVIEW_GRID )
{
galCanvas->GetGAL()->SetGridVisibility( myframe->IsGridVisible() );
galCanvas->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
// TODO(JE) Why is the below line needed? Not needed in pcbnew
galCanvas->GetView()->RecacheAllItems();
}
else
galCanvas->GetView()->SetLayerVisible( aId, isEnabled );
}
if( galCanvas && myframe->IsGalCanvasActive() )
galCanvas->Refresh();
else
myframe->GetCanvas()->Refresh();
}
//-----</LAYER_WIDGET callbacks>------------------------------------------

View File

@ -65,6 +65,8 @@ class GERBER_LAYER_WIDGET : public LAYER_WIDGET
*/
virtual bool useAlternateBitmap(int aRow) override;
virtual bool AreArbitraryColorsAllowed() override;
GERBER_FILE_IMAGE_LIST* GetImagesList();
public:

View File

@ -35,6 +35,7 @@
#include <class_gerber_file_image.h>
#include <class_gerber_file_image_list.h>
#include <class_gerbview_layer_widget.h>
#include <view/view.h>
bool GERBVIEW_FRAME::Clear_DrawLayers( bool query )
{
@ -47,11 +48,16 @@ bool GERBVIEW_FRAME::Clear_DrawLayers( bool query )
return false;
}
if( auto canvas = GetGalCanvas() )
{
canvas->GetView()->Clear();
}
GetImagesList()->DeleteAllImages();
GetGerberLayout()->SetBoundingBox( EDA_RECT() );
setActiveLayer( 0 );
SetActiveLayer( 0 );
ReFillLayerWidget();
syncLayerBox();
return true;
@ -60,7 +66,7 @@ bool GERBVIEW_FRAME::Clear_DrawLayers( bool query )
void GERBVIEW_FRAME::Erase_Current_DrawLayer( bool query )
{
int layer = getActiveLayer();
int layer = GetActiveLayer();
wxString msg;
msg.Printf( _( "Clear layer %d?" ), layer + 1 );

View File

@ -36,6 +36,7 @@
#include <gerbview_frame.h>
#include <class_gerber_file_image.h>
#include <convert_to_biu.h>
#include <convert_basic_shapes_to_polygon.h>
#define DCODE_DEFAULT_SIZE Millimeter2iu( 0.1 )
@ -87,7 +88,7 @@ void D_CODE::Clear_D_CODE_Data()
m_Macro = NULL;
m_Rotation = 0.0;
m_EdgesCount = 0;
m_PolyCorners.clear();
m_Polygon.RemoveAllContours();
}
@ -173,7 +174,7 @@ void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent,
GRFilledCircle( aClipBox, aDC, aParent->GetABPosition(aShapePos),
radius, aColor );
}
else if( APT_DEF_ROUND_HOLE == 1 ) // round hole in shape
else if( m_DrillShape == APT_DEF_ROUND_HOLE ) // round hole in shape
{
int width = (m_Size.x - m_Drill.x ) / 2;
GRCircle( aClipBox, aDC, aParent->GetABPosition(aShapePos),
@ -181,7 +182,7 @@ void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent,
}
else // rectangular hole
{
if( m_PolyCorners.size() == 0 )
if( m_Polygon.OutlineCount() == 0 )
ConvertShapeToPolygon();
DrawFlashedPolygon( aParent, aClipBox, aDC, aColor, aFilledShape, aShapePos );
@ -207,7 +208,7 @@ void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent,
}
else
{
if( m_PolyCorners.size() == 0 )
if( m_Polygon.OutlineCount() == 0 )
ConvertShapeToPolygon();
DrawFlashedPolygon( aParent, aClipBox, aDC, aColor, aFilledShape, aShapePos );
@ -248,7 +249,7 @@ void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent,
}
else
{
if( m_PolyCorners.size() == 0 )
if( m_Polygon.OutlineCount() == 0 )
ConvertShapeToPolygon();
DrawFlashedPolygon( aParent, aClipBox, aDC, aColor, aFilledShape, aShapePos );
@ -257,7 +258,7 @@ void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent,
break;
case APT_POLYGON:
if( m_PolyCorners.size() == 0 )
if( m_Polygon.OutlineCount() == 0 )
ConvertShapeToPolygon();
DrawFlashedPolygon( aParent, aClipBox, aDC, aColor, aFilledShape, aShapePos );
@ -271,27 +272,29 @@ void D_CODE::DrawFlashedPolygon( GERBER_DRAW_ITEM* aParent,
COLOR4D aColor, bool aFilled,
const wxPoint& aPosition )
{
if( m_PolyCorners.size() == 0 )
if( m_Polygon.OutlineCount() == 0 )
return;
int pointCount = m_Polygon.VertexCount();
std::vector<wxPoint> points;
points = m_PolyCorners;
points.reserve( pointCount );
for( unsigned ii = 0; ii < points.size(); ii++ )
for( int ii = 0; ii < pointCount; ii++ )
{
points[ii] += aPosition;
wxPoint p( m_Polygon.Vertex( ii ).x, m_Polygon.Vertex( ii ).y );
points[ii] = p + aPosition;
points[ii] = aParent->GetABPosition( points[ii] );
}
GRClosedPoly( aClipBox, aDC, points.size(), &points[0], aFilled, aColor, aColor );
GRClosedPoly( aClipBox, aDC, pointCount, &points[0], aFilled, aColor, aColor );
}
#define SEGS_CNT 32 // number of segments to approximate a circle
#define SEGS_CNT 64 // number of segments to approximate a circle
// A helper function for D_CODE::ConvertShapeToPolygon(). Add a hole to a polygon
static void addHoleToPolygon( std::vector<wxPoint>& aBuffer,
static void addHoleToPolygon( SHAPE_POLY_SET* aPolygon,
APERTURE_DEF_HOLETYPE aHoleShape,
wxSize aSize,
wxPoint aAnchorPos );
@ -302,43 +305,37 @@ void D_CODE::ConvertShapeToPolygon()
wxPoint initialpos;
wxPoint currpos;
m_PolyCorners.clear();
m_Polygon.RemoveAllContours();
switch( m_Shape )
{
case APT_CIRCLE: // creates only a circle with rectangular hole
currpos.x = m_Size.x >> 1;
initialpos = currpos;
for( unsigned ii = 0; ii <= SEGS_CNT; ii++ )
{
currpos = initialpos;
RotatePoint( &currpos, ii * 3600.0 / SEGS_CNT );
m_PolyCorners.push_back( currpos );
}
addHoleToPolygon( m_PolyCorners, m_DrillShape, m_Drill, initialpos );
TransformCircleToPolygon( m_Polygon, initialpos, m_Size.x >> 1, SEGS_CNT );
addHoleToPolygon( &m_Polygon, m_DrillShape, m_Drill, initialpos );
break;
case APT_RECT:
m_Polygon.NewOutline();
currpos.x = m_Size.x / 2;
currpos.y = m_Size.y / 2;
initialpos = currpos;
m_PolyCorners.push_back( currpos );
m_Polygon.Append( VECTOR2I( currpos ) );
currpos.x -= m_Size.x;
m_PolyCorners.push_back( currpos );
m_Polygon.Append( VECTOR2I( currpos ) );
currpos.y -= m_Size.y;
m_PolyCorners.push_back( currpos );
m_Polygon.Append( VECTOR2I( currpos ) );
currpos.x += m_Size.x;
m_PolyCorners.push_back( currpos );
m_Polygon.Append( VECTOR2I( currpos ) );
currpos.y += m_Size.y;
m_PolyCorners.push_back( currpos ); // close polygon
m_Polygon.Append( VECTOR2I( currpos ) ); // close polygon
m_Polygon.Append( VECTOR2I( initialpos ) );
addHoleToPolygon( m_PolyCorners, m_DrillShape, m_Drill, initialpos );
addHoleToPolygon( &m_Polygon, m_DrillShape, m_Drill, initialpos );
break;
case APT_OVAL:
{
m_Polygon.NewOutline();
int delta, radius;
// we create an horizontal oval shape. then rotate if needed
@ -355,7 +352,7 @@ void D_CODE::ConvertShapeToPolygon()
currpos.y = radius;
initialpos = currpos;
m_PolyCorners.push_back( currpos );
m_Polygon.Append( VECTOR2I( currpos ) );
// build the right arc of the shape
unsigned ii = 0;
@ -365,7 +362,7 @@ void D_CODE::ConvertShapeToPolygon()
currpos = initialpos;
RotatePoint( &currpos, ii * 3600.0 / SEGS_CNT );
currpos.x += delta;
m_PolyCorners.push_back( currpos );
m_Polygon.Append( VECTOR2I( currpos ) );
}
// build the left arc of the shape
@ -374,22 +371,23 @@ void D_CODE::ConvertShapeToPolygon()
currpos = initialpos;
RotatePoint( &currpos, ii * 3600.0 / SEGS_CNT );
currpos.x -= delta;
m_PolyCorners.push_back( currpos );
m_Polygon.Append( VECTOR2I( currpos ) );
}
m_PolyCorners.push_back( initialpos ); // close outline
m_Polygon.Append( VECTOR2I( initialpos ) ); // close outline
if( m_Size.y > m_Size.x ) // vertical oval, rotate polygon.
{
for( unsigned jj = 0; jj < m_PolyCorners.size(); jj++ )
RotatePoint( &m_PolyCorners[jj], 900 );
for( auto it = m_Polygon.Iterate( 0 ); it; ++it )
it->Rotate( -M_PI / 2 );
}
addHoleToPolygon( m_PolyCorners, m_DrillShape, m_Drill, initialpos );
addHoleToPolygon( &m_Polygon, m_DrillShape, m_Drill, initialpos );
}
break;
case APT_POLYGON:
m_Polygon.NewOutline();
currpos.x = m_Size.x >> 1; // first point is on X axis
initialpos = currpos;
@ -400,23 +398,21 @@ void D_CODE::ConvertShapeToPolygon()
if( m_EdgesCount > 12 )
m_EdgesCount = 12;
for( int ii = 0; ii <= m_EdgesCount; ii++ )
for( int ii = 0; ii < m_EdgesCount; ii++ )
{
currpos = initialpos;
RotatePoint( &currpos, ii * 3600.0 / m_EdgesCount );
m_PolyCorners.push_back( currpos );
m_Polygon.Append( VECTOR2I( currpos ) );
}
addHoleToPolygon( m_PolyCorners, m_DrillShape, m_Drill, initialpos );
addHoleToPolygon( &m_Polygon, m_DrillShape, m_Drill, initialpos );
if( m_Rotation ) // vertical oval, rotate polygon.
{
int angle = KiROUND( m_Rotation * 10 );
for( unsigned jj = 0; jj < m_PolyCorners.size(); jj++ )
{
RotatePoint( &m_PolyCorners[jj], -angle );
}
for( auto it = m_Polygon.Iterate( 0 ); it; ++it )
it->Rotate( -angle );
}
break;
@ -431,39 +427,36 @@ void D_CODE::ConvertShapeToPolygon()
// The helper function for D_CODE::ConvertShapeToPolygon().
// Add a hole to a polygon
static void addHoleToPolygon( std::vector<wxPoint>& aBuffer,
static void addHoleToPolygon( SHAPE_POLY_SET* aPolygon,
APERTURE_DEF_HOLETYPE aHoleShape,
wxSize aSize,
wxPoint aAnchorPos )
{
wxPoint currpos;
SHAPE_POLY_SET holeBuffer;
if( aHoleShape == APT_DEF_ROUND_HOLE ) // build a round hole
if( aHoleShape == APT_DEF_ROUND_HOLE )
{
for( int ii = 0; ii <= SEGS_CNT; ii++ )
{
currpos.x = 0;
currpos.y = aSize.x / 2; // aSize.x / 2 is the radius of the hole
RotatePoint( &currpos, ii * 3600.0 / SEGS_CNT );
aBuffer.push_back( currpos );
}
aBuffer.push_back( aAnchorPos ); // link to outline
TransformCircleToPolygon( holeBuffer, wxPoint( 0, 0 ), aSize.x / 2, SEGS_CNT );
}
if( aHoleShape == APT_DEF_RECT_HOLE ) // Create rectangular hole
else if( aHoleShape == APT_DEF_RECT_HOLE )
{
holeBuffer.NewOutline();
currpos.x = aSize.x / 2;
currpos.y = aSize.y / 2;
aBuffer.push_back( currpos ); // link to hole and begin hole
holeBuffer.Append( VECTOR2I( currpos ) ); // link to hole and begin hole
currpos.x -= aSize.x;
aBuffer.push_back( currpos );
holeBuffer.Append( VECTOR2I( currpos ) );
currpos.y -= aSize.y;
aBuffer.push_back( currpos );
holeBuffer.Append( VECTOR2I( currpos ) );
currpos.x += aSize.x;
aBuffer.push_back( currpos );
holeBuffer.Append( VECTOR2I( currpos ) );
currpos.y += aSize.y;
aBuffer.push_back( currpos ); // close hole
aBuffer.push_back( aAnchorPos ); // link to outline
holeBuffer.Append( VECTOR2I( currpos ) ); // close hole
}
aPolygon->BooleanSubtract( holeBuffer, SHAPE_POLY_SET::PM_FAST );
// Needed for legacy canvas only
aPolygon->Fracture( SHAPE_POLY_SET::PM_FAST );
}

View File

@ -34,6 +34,7 @@
#include <base_struct.h>
#include <gal/color4d.h>
#include <geometry/shape_poly_set.h>
using KIGFX::COLOR4D;
@ -89,11 +90,6 @@ private:
*/
std::vector<double> m_am_params;
std::vector <wxPoint> m_PolyCorners; /* Polygon used to draw APT_POLYGON shape and some other
* complex shapes which are converted to polygon
* (shapes with hole )
*/
public:
wxSize m_Size; ///< Horizontal and vertical dimensions.
APERTURE_T m_Shape; ///< shape ( Line, rectangle, circle , oval .. )
@ -108,7 +104,10 @@ public:
bool m_Defined; ///< false if the aperture is not defined in the header
wxString m_AperFunction; ///< the aperture attribute (created by a %TA.AperFunction command)
///< attached to the D_CODE
SHAPE_POLY_SET m_Polygon; /* Polygon used to draw APT_POLYGON shape and some other
* complex shapes which are converted to polygon
* (shapes with hole )
*/
public:
D_CODE( int num_dcode );

View File

@ -32,11 +32,18 @@
#include <common.h>
#include <macros.h>
#include <class_drawpanel.h>
#include <config_map.h>
#include <gerbview.h>
#include <gerbview_frame.h>
#include <gerbview_dialog_display_options_frame_base.h>
#include <class_draw_panel_gal.h>
#include <view/view.h>
#include <gerbview_painter.h>
#include <gal/gal_display_options.h>
#include <widgets/gal_options_panel.h>
/*******************************************/
/* Dialog frame to select display options */
@ -45,6 +52,7 @@ class DIALOG_DISPLAY_OPTIONS : public DIALOG_DISPLAY_OPTIONS_BASE
{
private:
GERBVIEW_FRAME* m_Parent;
GAL_OPTIONS_PANEL* m_galOptsPanel;
public:
@ -79,6 +87,8 @@ DIALOG_DISPLAY_OPTIONS::DIALOG_DISPLAY_OPTIONS( GERBVIEW_FRAME *parent) :
GetSizer()->SetSizeHints( this );
Center();
m_sdbSizer1OK->SetDefault();
FinishDialogSettings();
}
@ -90,23 +100,14 @@ void DIALOG_DISPLAY_OPTIONS::OnCancelButtonClick( wxCommandEvent& event )
void DIALOG_DISPLAY_OPTIONS::initOptDialog( )
{
KIGFX::GAL_DISPLAY_OPTIONS& galOptions = m_Parent->GetGalDisplayOptions();
m_galOptsPanel = new GAL_OPTIONS_PANEL( this, galOptions );
m_UpperSizer->Add( m_galOptsPanel, 0, wxEXPAND, 0 );
m_galOptsPanel->TransferDataToWindow();
m_PolarDisplay->SetSelection( m_Parent->m_DisplayOptions.m_DisplayPolarCood ? 1 : 0 );
m_BoxUnits->SetSelection( g_UserUnit ? 1 : 0 );
// @todo: LEGACY: Cursor shape can be set using the GAL options
// widget, when that is added to gerbview. For now, access the
// setting via the frame's GAL options object directly
// Cursor shape cannot be implemented on OS X
#ifdef __APPLE__
m_CursorShape->Hide();
#else
{
auto& galOpts = m_Parent->GetGalDisplayOptions();
m_CursorShape->SetSelection( galOpts.m_fullscreenCursor ? 1 : 0 );
}
#endif // __APPLE__
// Show Option Draw Lines. We use DisplayPcbTrackFill as Lines draw option
m_OptDisplayLines->SetSelection( m_Parent->m_DisplayOptions.m_DisplayLinesFill ? 1 : 0 );
m_OptDisplayFlashedItems->SetSelection( m_Parent->m_DisplayOptions.m_DisplayFlashedItemsFill ? 1 : 0);
@ -131,8 +132,6 @@ void DIALOG_DISPLAY_OPTIONS::initOptDialog( )
}
m_OptDisplayDCodes->SetValue( m_Parent->IsElementVisible( LAYER_DCODES ) );
m_OptZoomNoCenter->SetValue( m_Parent->GetCanvas()->GetEnableZoomNoCenter() );
m_OptMousewheelPan->SetValue( m_Parent->GetCanvas()->GetEnableMousewheelPan() );
}
@ -140,18 +139,12 @@ void DIALOG_DISPLAY_OPTIONS::initOptDialog( )
void DIALOG_DISPLAY_OPTIONS::OnOKBUttonClick( wxCommandEvent& event )
{
auto displayOptions = (GBR_DISPLAY_OPTIONS*) m_Parent->GetDisplayOptions();
m_Parent->m_DisplayOptions.m_DisplayPolarCood =
(m_PolarDisplay->GetSelection() == 0) ? false : true;
g_UserUnit = (m_BoxUnits->GetSelection() == 0) ? INCHES : MILLIMETRES;
// @todo LEGACY: as above, this should be via the GAL display widget
#ifndef __APPLE__
{
auto& galOpts = m_Parent->GetGalDisplayOptions();
galOpts.m_fullscreenCursor = m_CursorShape->GetSelection();
}
#endif // !__APPLE__
if( m_OptDisplayLines->GetSelection() == 1 )
m_Parent->m_DisplayOptions.m_DisplayLinesFill = true;
else
@ -166,7 +159,6 @@ void DIALOG_DISPLAY_OPTIONS::OnOKBUttonClick( wxCommandEvent& event )
m_Parent->m_DisplayOptions.m_DisplayFlashedItemsFill = false;
}
if( m_OptDisplayPolygons->GetSelection() == 0 )
m_Parent->m_DisplayOptions.m_DisplayPolygonsFill = false;
else
@ -185,6 +177,16 @@ void DIALOG_DISPLAY_OPTIONS::OnOKBUttonClick( wxCommandEvent& event )
m_Parent->GetCanvas()->SetEnableZoomNoCenter( m_OptZoomNoCenter->GetValue() );
m_Parent->GetCanvas()->SetEnableMousewheelPan( m_OptMousewheelPan->GetValue() );
m_galOptsPanel->TransferDataFromWindow();
// Apply changes to the GAL
auto view = m_Parent->GetGalCanvas()->GetView();
auto painter = static_cast<KIGFX::GERBVIEW_PAINTER*>( view->GetPainter() );
auto settings = static_cast<KIGFX::GERBVIEW_RENDER_SETTINGS*>( painter->GetSettings() );
settings->LoadDisplayOptions( displayOptions );
view->RecacheAllItems();
view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
m_Parent->GetCanvas()->Refresh();
EndModal( 1 );

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version May 6 2016)
// C++ code generated with wxFormBuilder (version Nov 30 2016)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -16,8 +16,7 @@ DIALOG_DISPLAY_OPTIONS_BASE::DIALOG_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWi
wxBoxSizer* bDialogSizer;
bDialogSizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bUpperSizer;
bUpperSizer = new wxBoxSizer( wxHORIZONTAL );
m_UpperSizer = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bLeftSizer;
bLeftSizer = new wxBoxSizer( wxVERTICAL );
@ -34,42 +33,30 @@ DIALOG_DISPLAY_OPTIONS_BASE::DIALOG_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWi
m_BoxUnits->SetSelection( 0 );
bLeftSizer->Add( m_BoxUnits, 0, wxALL|wxEXPAND, 5 );
wxString m_CursorShapeChoices[] = { _("Small cross"), _("Full screen cursor") };
int m_CursorShapeNChoices = sizeof( m_CursorShapeChoices ) / sizeof( wxString );
m_CursorShape = new wxRadioBox( this, wxID_ANY, _("Cursor"), wxDefaultPosition, wxDefaultSize, m_CursorShapeNChoices, m_CursorShapeChoices, 1, wxRA_SPECIFY_COLS );
m_CursorShape->SetSelection( 1 );
bLeftSizer->Add( m_CursorShape, 0, wxALL|wxEXPAND, 5 );
wxString m_OptDisplayFlashedItemsChoices[] = { _("Sketch"), _("Filled") };
int m_OptDisplayFlashedItemsNChoices = sizeof( m_OptDisplayFlashedItemsChoices ) / sizeof( wxString );
m_OptDisplayFlashedItems = new wxRadioBox( this, wxID_ANY, _("Flashed items"), wxDefaultPosition, wxDefaultSize, m_OptDisplayFlashedItemsNChoices, m_OptDisplayFlashedItemsChoices, 1, wxRA_SPECIFY_COLS );
m_OptDisplayFlashedItems->SetSelection( 1 );
bLeftSizer->Add( m_OptDisplayFlashedItems, 0, wxALL|wxEXPAND, 5 );
wxString m_OptDisplayLinesChoices[] = { _("Sketch"), _("Filled") };
int m_OptDisplayLinesNChoices = sizeof( m_OptDisplayLinesChoices ) / sizeof( wxString );
m_OptDisplayLines = new wxRadioBox( this, wxID_ANY, _("Lines"), wxDefaultPosition, wxDefaultSize, m_OptDisplayLinesNChoices, m_OptDisplayLinesChoices, 1, wxRA_SPECIFY_COLS );
m_OptDisplayLines->SetSelection( 1 );
bLeftSizer->Add( m_OptDisplayLines, 0, wxALL|wxEXPAND, 5 );
wxString m_OptDisplayPolygonsChoices[] = { _("Sketch"), _("Filled") };
int m_OptDisplayPolygonsNChoices = sizeof( m_OptDisplayPolygonsChoices ) / sizeof( wxString );
m_OptDisplayPolygons = new wxRadioBox( this, wxID_ANY, _("Polygons"), wxDefaultPosition, wxDefaultSize, m_OptDisplayPolygonsNChoices, m_OptDisplayPolygonsChoices, 1, wxRA_SPECIFY_COLS );
m_OptDisplayPolygons->SetSelection( 1 );
bLeftSizer->Add( m_OptDisplayPolygons, 0, wxALL|wxEXPAND, 5 );
m_OptDisplayDCodes = new wxCheckBox( this, wxID_ANY, _("Show D codes"), wxDefaultPosition, wxDefaultSize, 0 );
m_OptDisplayDCodes->SetValue(true);
bLeftSizer->Add( m_OptDisplayDCodes, 0, wxALL, 5 );
bUpperSizer->Add( bLeftSizer, 1, wxALL|wxEXPAND, 5 );
wxBoxSizer* bMiddleSizer;
bMiddleSizer = new wxBoxSizer( wxVERTICAL );
wxString m_OptDisplayLinesChoices[] = { _("Sketch"), _("Filled") };
int m_OptDisplayLinesNChoices = sizeof( m_OptDisplayLinesChoices ) / sizeof( wxString );
m_OptDisplayLines = new wxRadioBox( this, wxID_ANY, _("Lines"), wxDefaultPosition, wxDefaultSize, m_OptDisplayLinesNChoices, m_OptDisplayLinesChoices, 1, wxRA_SPECIFY_COLS );
m_OptDisplayLines->SetSelection( 1 );
bMiddleSizer->Add( m_OptDisplayLines, 0, wxALL|wxEXPAND, 5 );
wxString m_OptDisplayFlashedItemsChoices[] = { _("Sketch"), _("Filled") };
int m_OptDisplayFlashedItemsNChoices = sizeof( m_OptDisplayFlashedItemsChoices ) / sizeof( wxString );
m_OptDisplayFlashedItems = new wxRadioBox( this, wxID_ANY, _("Flashed items"), wxDefaultPosition, wxDefaultSize, m_OptDisplayFlashedItemsNChoices, m_OptDisplayFlashedItemsChoices, 1, wxRA_SPECIFY_COLS );
m_OptDisplayFlashedItems->SetSelection( 1 );
bMiddleSizer->Add( m_OptDisplayFlashedItems, 0, wxALL|wxEXPAND, 5 );
wxString m_OptDisplayPolygonsChoices[] = { _("Sketch"), _("Filled") };
int m_OptDisplayPolygonsNChoices = sizeof( m_OptDisplayPolygonsChoices ) / sizeof( wxString );
m_OptDisplayPolygons = new wxRadioBox( this, wxID_ANY, _("Polygons"), wxDefaultPosition, wxDefaultSize, m_OptDisplayPolygonsNChoices, m_OptDisplayPolygonsChoices, 1, wxRA_SPECIFY_COLS );
m_OptDisplayPolygons->SetSelection( 1 );
bMiddleSizer->Add( m_OptDisplayPolygons, 0, wxALL|wxEXPAND, 5 );
bUpperSizer->Add( bMiddleSizer, 1, wxALL|wxEXPAND, 5 );
m_UpperSizer->Add( bLeftSizer, 1, wxALL|wxEXPAND, 5 );
wxBoxSizer* bRightSizer;
bRightSizer = new wxBoxSizer( wxVERTICAL );
@ -97,10 +84,10 @@ DIALOG_DISPLAY_OPTIONS_BASE::DIALOG_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWi
bRightSizer->Add( bLeftBottomSizer, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 );
bUpperSizer->Add( bRightSizer, 2, wxALL|wxEXPAND, 5 );
m_UpperSizer->Add( bRightSizer, 2, wxALL|wxEXPAND, 5 );
bDialogSizer->Add( bUpperSizer, 1, wxEXPAND, 5 );
bDialogSizer->Add( m_UpperSizer, 1, wxEXPAND, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bDialogSizer->Add( m_staticline1, 0, wxEXPAND|wxLEFT|wxRIGHT, 5 );

View File

@ -99,9 +99,9 @@
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bUpperSizer</property>
<property name="name">m_UpperSizer</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<property name="permission">protected</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
@ -309,7 +309,7 @@
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices">&quot;Small cross&quot; &quot;Full screen cursor&quot;</property>
<property name="choices">&quot;Sketch&quot; &quot;Filled&quot;</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
@ -324,7 +324,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Cursor</property>
<property name="label">Flashed items</property>
<property name="majorDimension">1</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
@ -333,7 +333,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_CursorShape</property>
<property name="name">m_OptDisplayFlashedItems</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -381,105 +381,6 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">1</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Show D codes</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_OptDisplayDCodes</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnCheckBox"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bMiddleSizer</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
@ -570,96 +471,6 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxRadioBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices">&quot;Sketch&quot; &quot;Filled&quot;</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Flashed items</property>
<property name="majorDimension">1</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_OptDisplayFlashedItems</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="selection">1</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxRA_SPECIFY_COLS</property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRadioBox"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
@ -750,6 +561,94 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">1</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Show D codes</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_OptDisplayDCodes</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnCheckBox"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version May 6 2016)
// C++ code generated with wxFormBuilder (version Nov 30 2016)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -38,13 +38,13 @@ class DIALOG_DISPLAY_OPTIONS_BASE : public DIALOG_SHIM
private:
protected:
wxBoxSizer* m_UpperSizer;
wxRadioBox* m_PolarDisplay;
wxRadioBox* m_BoxUnits;
wxRadioBox* m_CursorShape;
wxCheckBox* m_OptDisplayDCodes;
wxRadioBox* m_OptDisplayLines;
wxRadioBox* m_OptDisplayFlashedItems;
wxRadioBox* m_OptDisplayLines;
wxRadioBox* m_OptDisplayPolygons;
wxCheckBox* m_OptDisplayDCodes;
wxRadioBox* m_ShowPageLimits;
wxCheckBox* m_OptZoomNoCenter;
wxCheckBox* m_OptMousewheelPan;

View File

@ -135,7 +135,16 @@ void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
if( IsShown() )
{
m_overlay.Reset();
wxDCOverlay overlaydc( m_overlay, (wxWindowDC*)DC );
// On macOS, the call to create overlaydc fails for some reason due to
// the DC having zero size initially.
wxCoord w = 0, h = 0;
( (wxWindowDC*)DC )->GetSize( &w, &h );
if( w == 0 || h == 0)
{
w = h = 1;
}
wxDCOverlay overlaydc( m_overlay, (wxWindowDC*)DC, 0, 0, 1, 1 );
overlaydc.Clear();
}
#endif

View File

@ -43,6 +43,10 @@
#include <class_gerbview_layer_widget.h>
#include <dialog_show_page_borders.h>
#include <tool/tool_manager.h>
#include <gerbview_painter.h>
#include <view/view.h>
// Event table:
@ -83,6 +87,12 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME )
EVT_MENU( ID_MENU_GERBVIEW_SHOW_HIDE_LAYERS_MANAGER_DIALOG,
GERBVIEW_FRAME::OnSelectOptionToolbar )
EVT_MENU( wxID_PREFERENCES, GERBVIEW_FRAME::InstallGerberOptionsDialog )
EVT_UPDATE_UI( ID_MENU_CANVAS_LEGACY, GERBVIEW_FRAME::OnUpdateSwitchCanvas )
EVT_UPDATE_UI( ID_MENU_CANVAS_CAIRO, GERBVIEW_FRAME::OnUpdateSwitchCanvas )
EVT_UPDATE_UI( ID_MENU_CANVAS_OPENGL, GERBVIEW_FRAME::OnUpdateSwitchCanvas )
EVT_MENU( ID_MENU_CANVAS_LEGACY, GERBVIEW_FRAME::SwitchCanvas )
EVT_MENU( ID_MENU_CANVAS_CAIRO, GERBVIEW_FRAME::SwitchCanvas )
EVT_MENU( ID_MENU_CANVAS_OPENGL, GERBVIEW_FRAME::SwitchCanvas )
// menu Postprocess
EVT_MENU( ID_GERBVIEW_SHOW_LIST_DCODES, GERBVIEW_FRAME::Process_Special_Functions )
@ -115,6 +125,7 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME )
// Option toolbar
//EVT_TOOL( ID_NO_TOOL_SELECTED, GERBVIEW_FRAME::Process_Special_Functions ) // mentioned below
EVT_TOOL( ID_ZOOM_SELECTION, GERBVIEW_FRAME::Process_Special_Functions )
EVT_TOOL( ID_TB_MEASUREMENT_TOOL, GERBVIEW_FRAME::Process_Special_Functions )
EVT_TOOL( ID_TB_OPTIONS_SHOW_POLAR_COORD, GERBVIEW_FRAME::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH, GERBVIEW_FRAME::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH, GERBVIEW_FRAME::OnSelectOptionToolbar )
@ -125,11 +136,13 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME )
EVT_TOOL( ID_TB_OPTIONS_SHOW_NEGATIVE_ITEMS, GERBVIEW_FRAME::OnSelectOptionToolbar )
EVT_TOOL_RANGE( ID_TB_OPTIONS_SHOW_GBR_MODE_0, ID_TB_OPTIONS_SHOW_GBR_MODE_2,
GERBVIEW_FRAME::OnSelectDisplayMode )
EVT_TOOL( ID_TB_OPTIONS_DIFF_MODE, GERBVIEW_FRAME::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_HIGH_CONTRAST_MODE, GERBVIEW_FRAME::OnSelectOptionToolbar )
// Auxiliary horizontal toolbar
EVT_CHOICE( ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE, GERBVIEW_FRAME::Process_Special_Functions )
EVT_CHOICE( ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE, GERBVIEW_FRAME::Process_Special_Functions )
EVT_CHOICE( ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE, GERBVIEW_FRAME::Process_Special_Functions )
EVT_CHOICE( ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE, GERBVIEW_FRAME::OnSelectHighlightChoice )
EVT_CHOICE( ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE, GERBVIEW_FRAME::OnSelectHighlightChoice )
EVT_CHOICE( ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE, GERBVIEW_FRAME::OnSelectHighlightChoice )
// Right click context menu
EVT_MENU( ID_HIGHLIGHT_CMP_ITEMS, GERBVIEW_FRAME::Process_Special_Functions )
@ -139,6 +152,7 @@ BEGIN_EVENT_TABLE( GERBVIEW_FRAME, EDA_DRAW_FRAME )
EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, GERBVIEW_FRAME::OnUpdateSelectTool )
EVT_UPDATE_UI( ID_ZOOM_SELECTION, GERBVIEW_FRAME::OnUpdateSelectTool )
EVT_UPDATE_UI( ID_TB_MEASUREMENT_TOOL, GERBVIEW_FRAME::OnUpdateSelectTool )
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_POLAR_COORD, GERBVIEW_FRAME::OnUpdateCoordType )
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH,
GERBVIEW_FRAME::OnUpdateFlashedItemsDrawMode )
@ -223,6 +237,10 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
SetNoToolSelected();
break;
case ID_TB_MEASUREMENT_TOOL:
SetToolID( id, wxCURSOR_DEFAULT, _( "Unsupported tool in this canvas" ) );
break;
case ID_POPUP_CLOSE_CURRENT_TOOL:
SetToolID( ID_NO_TOOL_SELECTED, m_canvas->GetDefaultCursor(), wxEmptyString );
break;
@ -246,12 +264,6 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
HandleBlockEnd( &dc );
break;
case ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE:
case ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE:
case ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE:
m_canvas->Refresh();
break;
case ID_HIGHLIGHT_CMP_ITEMS:
if( m_SelComponentBox->SetStringSelection( currItem->GetNetAttributes().m_Cmpref ) )
m_canvas->Refresh();
@ -275,8 +287,8 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
m_SelNetnameBox->SetSelection( 0 );
m_SelAperAttributesBox->SetSelection( 0 );
if( GetGbrImage( getActiveLayer() ) )
GetGbrImage( getActiveLayer() )->m_Selected_Tool = 0;
if( GetGbrImage( GetActiveLayer() ) )
GetGbrImage( GetActiveLayer() )->m_Selected_Tool = 0;
m_canvas->Refresh();
break;
@ -288,9 +300,40 @@ void GERBVIEW_FRAME::Process_Special_Functions( wxCommandEvent& event )
}
// Handles the changing of the highlighted component/net/attribute
void GERBVIEW_FRAME::OnSelectHighlightChoice( wxCommandEvent& event )
{
if( IsGalCanvasActive() )
{
auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetGalCanvas()->GetView()->GetPainter() )->GetSettings();
switch( event.GetId() )
{
case ID_GBR_AUX_TOOLBAR_PCB_CMP_CHOICE:
settings->m_componentHighlightString = m_SelComponentBox->GetStringSelection();
break;
case ID_GBR_AUX_TOOLBAR_PCB_NET_CHOICE:
settings->m_netHighlightString = m_SelNetnameBox->GetStringSelection();
break;
case ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE:
settings->m_attributeHighlightString = m_SelAperAttributesBox->GetStringSelection();
break;
}
GetGalCanvas()->GetView()->RecacheAllItems();
GetGalCanvas()->Refresh();
}
else
m_canvas->Refresh();
}
void GERBVIEW_FRAME::OnSelectActiveDCode( wxCommandEvent& event )
{
GERBER_FILE_IMAGE* gerber_image = GetGbrImage( getActiveLayer() );
GERBER_FILE_IMAGE* gerber_image = GetGbrImage( GetActiveLayer() );
if( gerber_image )
{
@ -307,11 +350,11 @@ void GERBVIEW_FRAME::OnSelectActiveDCode( wxCommandEvent& event )
void GERBVIEW_FRAME::OnSelectActiveLayer( wxCommandEvent& event )
{
int layer = getActiveLayer();
int layer = GetActiveLayer();
setActiveLayer( event.GetSelection() );
SetActiveLayer( event.GetSelection() );
if( layer != getActiveLayer() )
if( layer != GetActiveLayer() )
{
if( m_LayersManager->OnLayerSelected() )
m_canvas->Refresh();
@ -321,7 +364,7 @@ void GERBVIEW_FRAME::OnSelectActiveLayer( wxCommandEvent& event )
void GERBVIEW_FRAME::OnShowGerberSourceFile( wxCommandEvent& event )
{
int layer = getActiveLayer();
int layer = GetActiveLayer();
GERBER_FILE_IMAGE* gerber_layer = GetGbrImage( layer );
if( gerber_layer )
@ -427,16 +470,19 @@ void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
case ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH:
m_DisplayOptions.m_DisplayFlashedItemsFill = not state;
applyDisplaySettingsToGAL();
m_canvas->Refresh( true );
break;
case ID_TB_OPTIONS_SHOW_LINES_SKETCH:
m_DisplayOptions.m_DisplayLinesFill = not state;
applyDisplaySettingsToGAL();
m_canvas->Refresh( true );
break;
case ID_TB_OPTIONS_SHOW_POLYGONS_SKETCH:
m_DisplayOptions.m_DisplayPolygonsFill = not state;
applyDisplaySettingsToGAL();
m_canvas->Refresh( true );
break;
@ -450,6 +496,18 @@ void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
m_canvas->Refresh( true );
break;
case ID_TB_OPTIONS_DIFF_MODE:
m_DisplayOptions.m_DiffMode = state;
applyDisplaySettingsToGAL();
m_canvas->Refresh( true );
break;
case ID_TB_OPTIONS_HIGH_CONTRAST_MODE:
m_DisplayOptions.m_HighContrastMode = state;
applyDisplaySettingsToGAL();
m_canvas->Refresh( true );
break;
case ID_TB_OPTIONS_SHOW_LAYERS_MANAGER_VERTICAL_TOOLBAR:
// show/hide auxiliary Vertical layers and visibility manager toolbar
@ -461,6 +519,11 @@ void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
_("Hide &Layers Manager" ) : _("Show &Layers Manager" ));
break;
// collect GAL-only tools here:
case ID_TB_MEASUREMENT_TOOL:
SetToolID( id, wxCURSOR_DEFAULT, _( "Unsupported tool in this canvas" ) );
break;
default:
wxMessageBox( wxT( "GERBVIEW_FRAME::OnSelectOptionToolbar error" ) );
break;
@ -472,3 +535,62 @@ void GERBVIEW_FRAME::OnUpdateSelectTool( wxUpdateUIEvent& aEvent )
{
aEvent.Check( GetToolId() == aEvent.GetId() );
}
void GERBVIEW_FRAME::SwitchCanvas( wxCommandEvent& aEvent )
{
bool use_gal = false;
EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
switch( aEvent.GetId() )
{
case ID_MENU_CANVAS_LEGACY:
break;
case ID_MENU_CANVAS_CAIRO:
use_gal = GetGalCanvas()->SwitchBackend( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
if( use_gal )
canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO;
break;
case ID_MENU_CANVAS_OPENGL:
use_gal = GetGalCanvas()->SwitchBackend( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL );
if( use_gal )
canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL;
break;
}
SaveCanvasTypeSetting( canvasType );
UseGalCanvas( use_gal );
wxUpdateUIEvent e;
OnUpdateSwitchCanvas( e );
}
void GERBVIEW_FRAME::OnUpdateSwitchCanvas( wxUpdateUIEvent& aEvent )
{
wxMenuBar* menuBar = GetMenuBar();
EDA_DRAW_PANEL_GAL* gal_canvas = GetGalCanvas();
EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
if( IsGalCanvasActive() && gal_canvas )
canvasType = gal_canvas->GetBackend();
struct { int menuId; int galType; } menuList[] =
{
{ ID_MENU_CANVAS_LEGACY, EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE },
{ ID_MENU_CANVAS_OPENGL, EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL },
{ ID_MENU_CANVAS_CAIRO, EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO },
};
for( auto ii: menuList )
{
wxMenuItem* item = menuBar->FindItem( ii.menuId );
if( ii.galType == canvasType )
{
item->Check( true );
}
}
}

View File

@ -73,6 +73,7 @@
#include <class_excellon.h>
#include <kicad_string.h>
#include <class_X2_gerber_attributes.h>
#include <view/view.h>
#include <cmath>
@ -160,7 +161,7 @@ static EXCELLON_CMD excellon_G_CmdList[] =
bool GERBVIEW_FRAME::Read_EXCELLON_File( const wxString& aFullFileName )
{
wxString msg;
int layerId = getActiveLayer(); // current layer used in GerbView
int layerId = GetActiveLayer(); // current layer used in GerbView
GERBER_FILE_IMAGE_LIST* images = GetGerberLayout()->GetImagesList();
EXCELLON_IMAGE* drill_Layer = (EXCELLON_IMAGE*) images->GetGbrImage( layerId );
@ -193,6 +194,21 @@ bool GERBVIEW_FRAME::Read_EXCELLON_File( const wxString& aFullFileName )
dlg.ListSet( drill_Layer->GetMessages() );
dlg.ShowModal();
}
// TODO(JE) Is this the best place to add items to the view?
if( success )
{
EDA_DRAW_PANEL_GAL* canvas = GetGalCanvas();
if( canvas )
{
KIGFX::VIEW* view = canvas->GetView();
for( GERBER_DRAW_ITEM* item = drill_Layer->GetItemsList(); item; item = item->Next() )
{
view->Add( (KIGFX::VIEW_ITEM*) item );
}
}
}
return success;
}
@ -494,7 +510,7 @@ bool EXCELLON_IMAGE::readToolInformation( char*& aText )
// Initialize Dcode to handle this Tool
// Remember: dcodes are >= FIRST_DCODE
D_CODE* dcode = GetDCODE( iprm + FIRST_DCODE );
D_CODE* dcode = GetDCODEOrCreate( iprm + FIRST_DCODE );
if( dcode == NULL )
return false;
@ -532,7 +548,7 @@ bool EXCELLON_IMAGE::Execute_Drill_Command( char*& text )
Execute_EXCELLON_G_Command( text );
break;
case 0: // E.O.L: execute command
tool = GetDCODE( m_Current_Tool, false );
tool = GetDCODE( m_Current_Tool );
if( !tool )
{
@ -593,13 +609,13 @@ bool EXCELLON_IMAGE::Select_Tool( char*& text )
dcode_id = TOOLS_MAX_COUNT - 1;
m_Current_Tool = dcode_id;
D_CODE* currDcode = GetDCODE( dcode_id , false );
D_CODE* currDcode = GetDCODEOrCreate( dcode_id, true );
if( currDcode == NULL && tool_id > 0 ) // if the definition is embedded, enter it
{
text = startline; // text starts at the beginning of the command
readToolInformation( text );
currDcode = GetDCODE( dcode_id , false );
currDcode = GetDCODE( dcode_id );
}
if( currDcode )

View File

@ -222,7 +222,7 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName )
// Read gerber files: each file is loaded on a new GerbView layer
bool success = true;
int layer = getActiveLayer();
int layer = GetActiveLayer();
// Manage errors when loading files
wxString msg;
@ -237,7 +237,7 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName )
m_lastFileName = filename.GetFullPath();
setActiveLayer( layer, false );
SetActiveLayer( layer, false );
if( Read_GERBER_File( filename.GetFullPath() ) )
{
@ -263,7 +263,7 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName )
break;
}
setActiveLayer( layer, false );
SetActiveLayer( layer, false );
}
}
@ -278,7 +278,7 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName )
// Synchronize layers tools with actual active layer:
ReFillLayerWidget();
setActiveLayer( getActiveLayer() );
SetActiveLayer( GetActiveLayer() );
m_LayersManager->UpdateLayerIcons();
syncLayerBox();
return success;
@ -325,7 +325,7 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName )
// Read Excellon drill files: each file is loaded on a new GerbView layer
bool success = true;
int layer = getActiveLayer();
int layer = GetActiveLayer();
// Manage errors when loading files
wxString msg;
@ -340,7 +340,7 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName )
m_lastFileName = filename.GetFullPath();
setActiveLayer( layer, false );
SetActiveLayer( layer, false );
if( Read_EXCELLON_File( filename.GetFullPath() ) )
{
@ -367,7 +367,7 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName )
break;
}
setActiveLayer( layer, false );
SetActiveLayer( layer, false );
}
}
@ -382,7 +382,7 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName )
// Synchronize layers tools with actual active layer:
ReFillLayerWidget();
setActiveLayer( getActiveLayer() );
SetActiveLayer( GetActiveLayer() );
m_LayersManager->UpdateLayerIcons();
syncLayerBox();
@ -454,7 +454,7 @@ bool GERBVIEW_FRAME::unarchiveFiles( const wxString& aFullFileName, REPORTER* aR
continue;
}
int layer = getActiveLayer();
int layer = GetActiveLayer();
if( layer == NO_AVAILABLE_LAYERS )
{
@ -531,7 +531,7 @@ bool GERBVIEW_FRAME::unarchiveFiles( const wxString& aFullFileName, REPORTER* aR
gerber_image->m_FileName = fname;
layer = getNextAvailableLayer( layer );
setActiveLayer( layer, false );
SetActiveLayer( layer, false );
}
}
@ -584,7 +584,7 @@ bool GERBVIEW_FRAME::LoadZipArchiveFile( const wxString& aFullFileName )
// Synchronize layers tools with actual active layer:
ReFillLayerWidget();
setActiveLayer( getActiveLayer() );
SetActiveLayer( GetActiveLayer() );
m_LayersManager->UpdateLayerIcons();
syncLayerBox();

Some files were not shown because too many files have changed in this diff Show More