Commit f4114d22 authored by Maciej Suminski's avatar Maciej Suminski

Display preferences for showing netnames applies to the GAL backend.

parent cc901496
......@@ -18,6 +18,10 @@
#include <dialog_display_options.h>
#include <dialog_display_options_base.h>
#include <class_drawpanel_gal.h>
#include <view/view.h>
#include <pcb_painter.h>
void PCB_EDIT_FRAME::InstallDisplayOptionsDialog( wxCommandEvent& aEvent )
{
......@@ -165,6 +169,17 @@ void DIALOG_DISPLAY_OPTIONS::OnOkClick(wxCommandEvent& event)
DisplayOpt.DisplayDrawItems = m_OptDisplayDrawings->GetSelection();
DisplayOpt.DisplayNetNamesMode = m_ShowNetNamesOption->GetSelection();
// Apply changes to the GAL
KiGfx::VIEW* view = m_Parent->GetGalCanvas()->GetView();
KiGfx::PCB_PAINTER* painter = static_cast<KiGfx::PCB_PAINTER*>( view->GetPainter() );
KiGfx::PCB_RENDER_SETTINGS* settings =
static_cast<KiGfx::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
settings->LoadDisplayOptions( DisplayOpt );
view->RecacheAllItems();
if( m_Parent->IsGalCanvasActive() )
m_Parent->GetGalCanvas()->Refresh();
else
m_Parent->GetCanvas()->Refresh();
EndModal( 1 );
......
......@@ -90,12 +90,36 @@ void PCB_RENDER_SETTINGS::ImportLegacyColors( COLORS_DESIGN_SETTINGS* aSettings
void PCB_RENDER_SETTINGS::LoadDisplayOptions( const DISPLAY_OPTIONS& aOptions )
{
m_hiContrastEnabled = aOptions.ContrastModeDisplay;
m_padNumbers = aOptions.DisplayPadNum;
// Whether to draw tracks, vias & pads filled or as outlines
m_sketchModeSelect[PADS_VISIBLE] = !aOptions.DisplayPadFill;
m_sketchModeSelect[VIAS_VISIBLE] = !aOptions.DisplayViaFill;
m_sketchModeSelect[TRACKS_VISIBLE] = !aOptions.DisplayPcbTrackFill;
switch( aOptions.DisplayNetNamesMode )
{
case 0:
m_netNamesOnPads = false;
m_netNamesOnTracks = false;
break;
case 1:
m_netNamesOnPads = true;
m_netNamesOnTracks = false;
break;
case 2:
m_netNamesOnPads = false;
m_netNamesOnTracks = true;
break;
case 3:
m_netNamesOnPads = true;
m_netNamesOnTracks = true;
break;
}
switch( aOptions.DisplayZonesMode )
{
case 0:
......@@ -264,7 +288,7 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
int netNumber = aTrack->GetNet();
COLOR4D color;
if( IsNetnameLayer( aLayer ) )
if( m_pcbSettings->m_netNamesOnTracks && IsNetnameLayer( aLayer ) )
{
// If there is a net name - display it on the track
if( netNumber != 0 )
......@@ -378,6 +402,11 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
// Draw description layer
if( IsNetnameLayer( aLayer ) )
{
// Is anything that we can display enabled?
if( m_pcbSettings->m_netNamesOnPads || m_pcbSettings->m_padNumbers )
{
bool displayNetname = ( m_pcbSettings->m_netNamesOnPads &&
!aPad->GetNetname().empty() );
size = VECTOR2D( aPad->GetSize() / 2 );
double scale = m_gal->GetZoomFactor();
double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE / scale;
......@@ -391,7 +420,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
// Keep the size ratio for the font, but make it smaller
if( size.x < size.y )
{
orientation -= M_PI / 2;
orientation -= M_PI / 2.0;
size.y = size.x * 4.0 / 3.0;
}
else if( size.x == size.y )
......@@ -424,27 +453,41 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
else
m_gal->SetStrokeColor( color.Highlighted( 0.8 ) );
// Let's make some space for a netname too, if there's one to display
if( !aPad->GetNetname().empty() )
if( displayNetname && m_pcbSettings->m_padNumbers )
{
// Divide the space, when both pad numbers and netnames are enabled
size = size / 2.0;
m_gal->SetGlyphSize( size );
m_gal->SetLineWidth( size.y / 10.0 );
m_gal->SetLineWidth( size.y / 8.0 );
m_gal->StrokeText( std::string( aPad->GetNetname().mb_str() ),
VECTOR2D( 0, size.y ), 0.0 );
m_gal->Translate( VECTOR2D( 0.0, -size.y / 2.0 ) );
VECTOR2D( 0.0, size.y ), 0.0 );
m_gal->StrokeText( std::string( aPad->GetPadName().mb_str() ),
VECTOR2D( 0.0, -size.y / 2.0 ), 0.0 );
}
else
{
// In case when there's no netname assigned
// There is only one thing to display
if( displayNetname )
{
m_gal->SetGlyphSize( size / 2.0 );
m_gal->SetLineWidth( size.y / 12.0 );
m_gal->StrokeText( std::string( aPad->GetNetname().mb_str() ),
VECTOR2D( 0.0, 0.0 ), 0.0 );
}
if( m_pcbSettings->m_padNumbers )
{
m_gal->SetGlyphSize( size );
m_gal->SetLineWidth( size.y / 10.0 );
m_gal->StrokeText( std::string( aPad->GetPadName().mb_str() ),
VECTOR2D( 0.0, 0.0 ), 0.0 );
}
}
m_gal->StrokeText( std::string( aPad->GetPadName().mb_str() ), VECTOR2D( 0, 0 ), 0.0 );
m_gal->Restore();
}
return;
}
......
......@@ -102,8 +102,9 @@ protected:
COLOR4D m_itemColorsDark [END_PCB_VISIBLE_LIST];
bool m_sketchModeSelect[END_PCB_VISIBLE_LIST];
bool m_visibleLayers [NB_LAYERS];
bool m_visibleItems [END_PCB_VISIBLE_LIST];
bool m_padNumbers;
bool m_netNamesOnPads;
bool m_netNamesOnTracks;
static const double MAX_FONT_SIZE = 100000000;
......
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