Auto zone refilling after using the POINT_EDITOR.

Minor code cleaning.
This commit is contained in:
Maciej Suminski 2014-03-06 11:49:08 +01:00
parent b6e3b3a3f9
commit f72aec25c0
5 changed files with 49 additions and 43 deletions

View File

@ -358,19 +358,6 @@ public:
*/
bool HitTest( const EDA_RECT& aRect, bool aContained = true, int aAccuracy = 0 ) const;
/**
* Function Fill_Zone
* Calculate the zone filling
* The zone outline is a frontier, and can be complex (with holes)
* The filling starts from starting points like pads, tracks.
* If exists the old filling is removed
* @param frame = reference to the main frame
* @param DC = current Device Context
* @param verbose = true to show error messages
* @return error level (0 = no error)
*/
int Fill_Zone( PCB_EDIT_FRAME* frame, wxDC* DC, bool verbose = true );
/**
* Function FillZoneAreasWithSegments
* Fill sub areas in a zone with segments with m_ZoneMinThickness width

View File

@ -2339,7 +2339,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
arcsegcount = 32;
zc->SetArcSegmentCount( arcsegcount );
zc->SetIsFilled( fillstate == 'S' ? true : false );
zc->SetIsFilled( fillstate == 'S' );
zc->SetThermalReliefGap( thermalReliefGap );
zc->SetThermalReliefCopperBridge( thermalReliefCopperBridge );
}

View File

@ -32,6 +32,7 @@
#include "selection_tool.h"
#include "point_editor.h"
#include <wxPcbStruct.h>
#include <class_drawsegment.h>
#include <class_zone.h>
@ -206,6 +207,7 @@ int POINT_EDITOR::OnSelectionChange( TOOL_EVENT& aEvent )
if( m_editPoints )
{
finishItem();
item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
m_toolMgr->GetView()->Remove( m_editPoints.get() );
m_editPoints.reset();
@ -326,6 +328,20 @@ void POINT_EDITOR::updateItem() const
}
void POINT_EDITOR::finishItem() const
{
EDA_ITEM* item = m_editPoints->GetParent();
if( item->Type() == PCB_ZONE_AREA_T )
{
ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
if( zone->IsFilled() )
getEditFrame<PCB_EDIT_FRAME>()->Fill_Zone( zone );
}
}
void POINT_EDITOR::updatePoints() const
{
EDA_ITEM* item = m_editPoints->GetParent();

View File

@ -69,6 +69,9 @@ private:
///> Updates item's points with edit points.
void updateItem() const;
///> Applies the last changes to the edited item.
void finishItem() const;
///> Updates edit points with item's points.
void updatePoints() const;

View File

@ -54,8 +54,7 @@
* to add holes for pads and tracks and other items not in net.
*/
bool ZONE_CONTAINER::BuildFilledSolidAreasPolygons( BOARD* aPcb,
CPOLYGONS_LIST* aCornerBuffer )
bool ZONE_CONTAINER::BuildFilledSolidAreasPolygons( BOARD* aPcb, CPOLYGONS_LIST* aCornerBuffer )
{
if( aCornerBuffer == NULL )
m_FilledPolysList.RemoveAllContours();
@ -80,9 +79,11 @@ bool ZONE_CONTAINER::BuildFilledSolidAreasPolygons( BOARD* aPcb,
case ZONE_SETTINGS::SMOOTHING_CHAMFER:
m_smoothedPoly = m_Poly->Chamfer( m_cornerRadius );
break;
case ZONE_SETTINGS::SMOOTHING_FILLET:
m_smoothedPoly = m_Poly->Fillet( m_cornerRadius, m_ArcToSegmentsCount );
break;
default:
m_smoothedPoly = new CPolyLine;
m_smoothedPoly->Copy( m_Poly );
@ -90,11 +91,9 @@ bool ZONE_CONTAINER::BuildFilledSolidAreasPolygons( BOARD* aPcb,
}
if( aCornerBuffer )
ConvertPolysListWithHolesToOnePolygon( m_smoothedPoly->m_CornersList,
*aCornerBuffer );
ConvertPolysListWithHolesToOnePolygon( m_smoothedPoly->m_CornersList, *aCornerBuffer );
else
ConvertPolysListWithHolesToOnePolygon( m_smoothedPoly->m_CornersList,
m_FilledPolysList );
ConvertPolysListWithHolesToOnePolygon( m_smoothedPoly->m_CornersList, m_FilledPolysList );
/* For copper layers, we now must add holes in the Polygon list.
* holes are pads and tracks with their clearance area
@ -124,10 +123,13 @@ bool ZONE_CONTAINER::BuildFilledSolidAreasPolygons( BOARD* aPcb,
m_FilledPolysList.RemoveAllContours();
CopyPolygonsFromKiPolygonListToFilledPolysList( polyset_zone_solid_areas );
}
if( m_FillMode ) // if fill mode uses segments, create them:
FillZoneAreasWithSegments();
}
m_IsFilled = true;
return 1;
}
@ -145,9 +147,7 @@ int ZONE_CONTAINER::FillZoneAreasWithSegments()
int count = 0;
std::vector <int> x_coordinates;
bool error = false;
int istart, iend; // index of the starting and the endif corner of one filled area in m_FilledPolysList
int margin = m_ZoneMinThickness * 2 / 10;
int minwidth = Mils2iu( 2 );
margin = std::max ( minwidth, margin );
@ -168,10 +168,7 @@ int ZONE_CONTAINER::FillZoneAreasWithSegments()
EDA_RECT rect = CalculateSubAreaBoundaryBox( istart, iend );
// Calculate the y limits of the zone
int refy = rect.GetY();
int endy = rect.GetBottom();
for( ; refy < endy; refy += step )
for( int refy = rect.GetY(), endy = rect.GetBottom(); refy < endy; refy += step )
{
// find all intersection points of an infinite line with polyline sides
x_coordinates.clear();
@ -267,6 +264,9 @@ int ZONE_CONTAINER::FillZoneAreasWithSegments()
break;
} // End examine all areas
if( !error )
m_IsFilled = true;
return count;
}