Added possibility to change display modes of zones.

This commit is contained in:
Maciej Suminski 2013-07-02 14:02:42 +02:00
parent 0f5aa0630a
commit 68961c82fd
3 changed files with 97 additions and 21 deletions

View File

@ -202,16 +202,28 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
case ID_TB_OPTIONS_SHOW_ZONES:
DisplayOpt.DisplayZonesMode = 0;
#ifdef KICAD_GAL
recache = true;
if( !IsGalCanvasActive() )
#endif /* KICAD_GAL */
m_canvas->Refresh();
break;
case ID_TB_OPTIONS_SHOW_ZONES_DISABLE:
DisplayOpt.DisplayZonesMode = 1;
#ifdef KICAD_GAL
recache = true;
if( !IsGalCanvasActive() )
#endif /* KICAD_GAL */
m_canvas->Refresh();
break;
case ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY:
DisplayOpt.DisplayZonesMode = 2;
#ifdef KICAD_GAL
recache = true;
if( !IsGalCanvasActive() )
#endif /* KICAD_GAL */
m_canvas->Refresh();
break;

View File

@ -84,6 +84,21 @@ void PCB_RENDER_SETTINGS::LoadDisplayOptions( const DISPLAY_OPTIONS& aOptions )
m_sketchModeSelect[PADS_VISIBLE] = !aOptions.DisplayPadFill;
m_sketchModeSelect[VIAS_VISIBLE] = !aOptions.DisplayViaFill;
m_sketchModeSelect[TRACKS_VISIBLE] = !aOptions.DisplayPcbTrackFill;
switch( aOptions.DisplayZonesMode )
{
case 0:
m_displayZoneMode = DZ_SHOW_FILLED;
break;
case 1:
m_displayZoneMode = DZ_HIDE_FILLED;
break;
case 2:
m_displayZoneMode = DZ_SHOW_OUTLINED;
break;
}
}
@ -487,34 +502,77 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
void PCB_PAINTER::draw( const ZONE_CONTAINER* aContainer )
{
std::vector<CPolyPt> polyPoints = aContainer->GetFilledPolysList().GetList();
COLOR4D color = getLayerColor( aContainer->GetLayer(), aContainer->GetNet() );
std::deque<VECTOR2D> corners;
PCB_RENDER_SETTINGS::DisplayZonesMode displayMode = m_pcbSettings->m_displayZoneMode;
// Draw the outline
m_gal->SetStrokeColor( color );
m_gal->SetIsFill( false );
m_gal->SetIsStroke( true );
m_gal->SetLineWidth( m_pcbSettings->m_outlineWidth );
const CPolyLine* outline = aContainer->Outline();
for( int i = 0; i < outline->GetCornersCount(); ++i )
{
corners.push_back( VECTOR2D( outline->GetPos( i ) ) );
}
// The last point for closing the polyline
corners.push_back( VECTOR2D( outline->GetPos( 0 ) ) );
m_gal->DrawPolyline( corners );
corners.clear();
// Draw the outline's hatch lines
std::vector<CSegment>::const_iterator hatch, hatch_end;
for( hatch = outline->m_HatchLines.begin(), hatch_end = outline->m_HatchLines.end();
hatch != hatch_end; ++hatch )
{
const VECTOR2D start = VECTOR2D( hatch->m_Start );
const VECTOR2D end = VECTOR2D( hatch->m_End );
m_gal->DrawLine( start, end );
}
// Draw the filling
if( displayMode != PCB_RENDER_SETTINGS::DZ_HIDE_FILLED )
{
const std::vector<CPolyPt> polyPoints = aContainer->GetFilledPolysList().GetList();
if( polyPoints.size() == 0 ) // Nothing to draw
return;
COLOR4D fillColor = getLayerColor( aContainer->GetLayer(), aContainer->GetNet() );
std::vector<CPolyPt>::iterator polyIterator;
std::deque<VECTOR2D> corners;
int fillMode = aContainer->GetFillMode();
m_gal->SetFillColor( fillColor );
m_gal->SetStrokeColor( fillColor );
m_gal->SetIsFill( !fillMode );
m_gal->SetIsStroke( true );
// Set up drawing options
m_gal->SetFillColor( color );
m_gal->SetLineWidth( aContainer->GetThermalReliefCopperBridge() / 2.0 );
// FIXME implement hatch mode
if( fillMode == 0 )
if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_FILLED )
{
m_gal->SetIsFill( true );
m_gal->SetIsStroke( true );
}
else if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_OUTLINED )
{
m_gal->SetIsFill( false );
m_gal->SetIsStroke( true );
}
std::vector<CPolyPt>::const_iterator polyIterator;
for( polyIterator = polyPoints.begin(); polyIterator != polyPoints.end(); polyIterator++ )
{
// Find out all of polygons and then draw them
corners.push_back( VECTOR2D( *polyIterator ) );
if( polyIterator->end_contour )
{
if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_FILLED )
{
m_gal->DrawPolygon( corners );
m_gal->DrawPolyline( corners );
}
else if( displayMode == PCB_RENDER_SETTINGS::DZ_SHOW_OUTLINED )
{
m_gal->DrawPolyline( corners );
}
corners.clear();
}
}

View File

@ -61,7 +61,6 @@ class STROKE_FONT;
class PCB_RENDER_SETTINGS : public RENDER_SETTINGS
{
public:
friend class PCB_PAINTER;
enum ClearanceMode {
@ -70,6 +69,12 @@ public:
CL_TRACKS = 0x4
};
enum DisplayZonesMode {
DZ_HIDE_FILLED = 0,
DZ_SHOW_FILLED,
DZ_SHOW_OUTLINED
};
PCB_RENDER_SETTINGS();
/// @copydoc RENDER_SETTINGS::Update()
@ -87,7 +92,6 @@ public:
void LoadDisplayOptions( const DISPLAY_OPTIONS& aOptions );
protected:
/// Colors for all layers (including special, highlighted & darkened versions)
COLOR4D m_layerColors [NB_LAYERS];
COLOR4D m_layerColorsHi [NB_LAYERS];
@ -101,6 +105,8 @@ protected:
bool m_sketchModeSelect[END_PCB_VISIBLE_LIST];
bool m_visibleLayers [NB_LAYERS];
bool m_visibleItems [END_PCB_VISIBLE_LIST];
DisplayZonesMode m_displayZoneMode;
};