Commit 68961c82 authored by Maciej Suminski's avatar Maciej Suminski

Added possibility to change display modes of zones.

parent 0f5aa063
......@@ -202,17 +202,29 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
case ID_TB_OPTIONS_SHOW_ZONES:
DisplayOpt.DisplayZonesMode = 0;
m_canvas->Refresh();
#ifdef KICAD_GAL
recache = true;
if( !IsGalCanvasActive() )
#endif /* KICAD_GAL */
m_canvas->Refresh();
break;
case ID_TB_OPTIONS_SHOW_ZONES_DISABLE:
DisplayOpt.DisplayZonesMode = 1;
m_canvas->Refresh();
#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;
m_canvas->Refresh();
#ifdef KICAD_GAL
recache = true;
if( !IsGalCanvasActive() )
#endif /* KICAD_GAL */
m_canvas->Refresh();
break;
case ID_TB_OPTIONS_SHOW_VIAS_SKETCH:
......
......@@ -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,25 +502,60 @@ 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();
if( polyPoints.size() == 0 ) // Nothing to draw
return;
COLOR4D fillColor = getLayerColor( aContainer->GetLayer(), aContainer->GetNet() );
std::vector<CPolyPt>::iterator polyIterator;
COLOR4D color = getLayerColor( aContainer->GetLayer(), aContainer->GetNet() );
std::deque<VECTOR2D> corners;
int fillMode = aContainer->GetFillMode();
PCB_RENDER_SETTINGS::DisplayZonesMode displayMode = m_pcbSettings->m_displayZoneMode;
m_gal->SetFillColor( fillColor );
m_gal->SetStrokeColor( fillColor );
m_gal->SetIsFill( !fillMode );
// Draw the outline
m_gal->SetStrokeColor( color );
m_gal->SetIsFill( false );
m_gal->SetIsStroke( true );
m_gal->SetLineWidth( aContainer->GetThermalReliefCopperBridge() / 2.0 );
m_gal->SetLineWidth( m_pcbSettings->m_outlineWidth );
// FIXME implement hatch mode
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 );
}
if( fillMode == 0 )
// 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;
// Set up drawing options
m_gal->SetFillColor( color );
m_gal->SetLineWidth( aContainer->GetThermalReliefCopperBridge() / 2.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
......@@ -513,8 +563,16 @@ void PCB_PAINTER::draw( const ZONE_CONTAINER* aContainer )
if( polyIterator->end_contour )
{
m_gal->DrawPolygon( corners );
m_gal->DrawPolyline( corners );
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();
}
}
......
......@@ -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;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment