7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-14 12:09:35 +00:00

Multiple improvements concerning colors, configuration handling and legacy features in pcbnew:

- support for background color setting
    - removed several global config settings (such as g_Drc_On)
    - wrapped most of global config settings in PCB_GENERAL_SETTINGS class
    - reorganized PCB general options dialog to clearly mark which options concern only the legacy canvas
    - new GAL feature for legacy users: double-click (or E) to change track width available as an option.

Fixes: lp:1530543
* https://bugs.launchpad.net/kicad/+bug/1530543

Fixes: lp:1707145
* https://bugs.launchpad.net/kicad/+bug/1707145
This commit is contained in:
Tomasz Włostowski 2017-08-04 14:43:02 +02:00
parent 33e05ae557
commit 32185ddcd3
116 changed files with 1234 additions and 1038 deletions
3d-viewer/3d_canvas
bitmap2component
common
cvpcb
gerbview
include
pcb_calculator
pcbnew

View File

@ -33,7 +33,6 @@
#include <class_board.h>
#include <3d_math.h>
#include "3d_fastmath.h"
#include <colors_selection.h>
/**
* Trace mask used to enable or disable the trace output of this class.
@ -530,7 +529,7 @@ SFVEC3F CINFO3D_VISU::GetLayerColor( PCB_LAYER_ID aLayerId ) const
{
wxASSERT( aLayerId < PCB_LAYER_ID_COUNT );
const COLOR4D color = g_ColorsSettings.GetLayerColor( aLayerId );
const COLOR4D color = m_board->Colors().GetLayerColor( aLayerId );
return SFVEC3F( color.r, color.g, color.b );
}
@ -538,7 +537,7 @@ SFVEC3F CINFO3D_VISU::GetLayerColor( PCB_LAYER_ID aLayerId ) const
SFVEC3F CINFO3D_VISU::GetItemColor( int aItemId ) const
{
return GetColor( g_ColorsSettings.GetItemColor( aItemId ) );
return GetColor( m_board->Colors().GetItemColor( aItemId ) );
}

View File

@ -31,7 +31,6 @@
#include <gestfich.h>
#include <wildcards_and_files_ext.h>
#include <bitmap_io.h>
#include <colors_selection.h>
#include <build_version.h>
#include <menus_helpers.h>
#include <kiway.h>

View File

@ -280,6 +280,7 @@ set( COMMON_SRCS
searchhelpfilefullpath.cpp
search_stack.cpp
selcolor.cpp
settings.cpp
systemdirsappend.cpp
trigo.cpp
utf8.cpp

View File

@ -100,6 +100,13 @@ COLORS_DESIGN_SETTINGS::COLORS_DESIGN_SETTINGS()
{
m_LayersColors[dst] = COLOR4D( default_items_color[src++] );
}
m_LayersColors[ LAYER_PCB_BACKGROUND ] = BLACK;
m_LayersColors[ LAYER_CURSOR ] = WHITE;
m_LayersColors[ LAYER_AUX_ITEMS ] = WHITE;
m_LayersColors[ LAYER_WORKSHEET ] = DARKRED;
setupConfigParams();
}
@ -147,3 +154,46 @@ void COLORS_DESIGN_SETTINGS::SetAllColorsAs( COLOR4D aColor )
for( unsigned ii = 0; ii < DIM(m_LayersColors); ii++ )
m_LayersColors[ii] = aColor;
}
#define LOC_COLOR(layer) &m_LayersColors[layer]
#define ITEM_COLOR(item_visible) &m_LayersColors[item_visible]
void COLORS_DESIGN_SETTINGS::setupConfigParams()
{
wxASSERT( DIM( m_LayersColors ) >= PCB_LAYER_ID_COUNT );
for( int i = 0; i<PCB_LAYER_ID_COUNT; ++i )
{
wxString vn = wxString::Format(
wxT( "ColorPCBLayer_%s" ),
LSET::Name( PCB_LAYER_ID( i ) ) );
Add( vn, LOC_COLOR(i), m_LayersColors[i] );
}
Add( wxT( "ColorTxtFrontEx" ), ITEM_COLOR( LAYER_MOD_TEXT_FR ), LIGHTGRAY );
Add( wxT( "ColorTxtBackEx" ), ITEM_COLOR( LAYER_MOD_TEXT_BK ), BLUE );
Add( wxT( "ColorTxtInvisEx" ), ITEM_COLOR( LAYER_MOD_TEXT_INVISIBLE ), DARKGRAY );
Add( wxT( "ColorPadBackEx" ), ITEM_COLOR( LAYER_PAD_BK ), GREEN );
Add( wxT( "ColorAnchorEx" ), ITEM_COLOR( LAYER_ANCHOR ), BLUE );
Add( wxT( "ColorPadFrontEx" ), ITEM_COLOR( LAYER_PAD_FR ), RED );
Add( wxT( "ColorViaThruEx" ), ITEM_COLOR( LAYER_VIA_THROUGH ), LIGHTGRAY );
Add( wxT( "ColorViaBBlindEx" ), ITEM_COLOR( LAYER_VIA_BBLIND ), BROWN );
Add( wxT( "ColorViaMicroEx" ), ITEM_COLOR( LAYER_VIA_MICROVIA ), CYAN );
Add( wxT( "ColorNonPlatedEx" ), ITEM_COLOR( LAYER_NON_PLATED ), YELLOW );
Add( wxT( "ColorRatsEx" ), ITEM_COLOR( LAYER_RATSNEST ), WHITE );
Add( wxT( "ColorPCBBackground" ), ITEM_COLOR( LAYER_PCB_BACKGROUND ), BLACK );
Add( wxT( "ColorPCBCursor" ), ITEM_COLOR( LAYER_CURSOR ), WHITE );
Add( wxT( "ColorAuxItems" ), ITEM_COLOR( LAYER_AUX_ITEMS ), WHITE );
Add( wxT( "ColorWorksheet" ), ITEM_COLOR( LAYER_WORKSHEET ), DARKRED );
}
void COLORS_DESIGN_SETTINGS::Load( wxConfigBase *aConfig )
{
SETTINGS::Load(aConfig);
}
void COLORS_DESIGN_SETTINGS::Save( wxConfigBase *aConfig )
{
SETTINGS::Save(aConfig);
}

View File

@ -23,7 +23,6 @@
*/
#include <common.h>
#include <colors_selection.h>
#include <layers_id_colors_and_visibility.h>
#include <bitmaps.h>

View File

@ -179,7 +179,9 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
try
{
m_gal->BeginDrawing();
m_gal->ClearScreen( settings->GetBackgroundColor() );
m_gal->SetClearColor( settings->GetBackgroundColor() );
m_gal->SetCursorColor( settings->GetLayerColor( LAYER_CURSOR ) );
m_gal->ClearScreen( );
KIGFX::COLOR4D gridColor = settings->GetLayerColor( LAYER_GRID );
m_gal->SetGridColor( gridColor );

View File

@ -123,7 +123,7 @@ void CAIRO_COMPOSITOR::Begin()
{
}
void CAIRO_COMPOSITOR::ClearBuffer()
void CAIRO_COMPOSITOR::ClearBuffer( const COLOR4D& aColor )
{
// Clear the pixel storage
memset( m_buffers[m_current].bitmap.get(), 0x00, m_bufferSize * sizeof(int) );

View File

@ -381,10 +381,10 @@ void CAIRO_GAL::Flush()
}
void CAIRO_GAL::ClearScreen( const COLOR4D& aColor )
void CAIRO_GAL::ClearScreen( )
{
backgroundColor = aColor;
cairo_set_source_rgb( currentContext, aColor.r, aColor.g, aColor.b );
backgroundColor = m_clearColor;
cairo_set_source_rgb( currentContext, backgroundColor.r, backgroundColor.g, backgroundColor.b );
cairo_rectangle( currentContext, 0.0, 0.0, screenSize.x, screenSize.y );
cairo_fill( currentContext );
}
@ -850,7 +850,7 @@ void CAIRO_GAL::ClearTarget( RENDER_TARGET aTarget )
break;
}
compositor->ClearBuffer();
compositor->ClearBuffer( COLOR4D::BLACK );
// Restore the previous state
compositor->SetBuffer( currentBuffer );
@ -1014,8 +1014,9 @@ void CAIRO_GAL::initSurface()
cairo_set_antialias( context, CAIRO_ANTIALIAS_NONE );
m_clearColor = backgroundColor;
// Clear the screen
ClearScreen( backgroundColor );
ClearScreen( );
// Compute the world <-> screen transformations
ComputeWorldScreenMatrix();

View File

@ -24,6 +24,7 @@
#include <gal/opengl/antialiasing.h>
#include <gal/opengl/opengl_compositor.h>
#include <gal/opengl/utils.h>
#include <gal/color4d.h>
#include <tuple>
@ -181,7 +182,7 @@ VECTOR2U ANTIALIASING_SUPERSAMPLING::GetInternalBufferSize()
void ANTIALIASING_SUPERSAMPLING::Begin()
{
compositor->SetBuffer( ssaaMainBuffer );
compositor->ClearBuffer();
compositor->ClearBuffer( COLOR4D::BLACK );
}
@ -445,7 +446,7 @@ void ANTIALIASING_SMAA::DrawBuffer( GLuint buffer )
void ANTIALIASING_SMAA::Begin()
{
compositor->SetBuffer( smaaBaseBuffer );
compositor->ClearBuffer();
compositor->ClearBuffer( COLOR4D::BLACK );
}
@ -487,7 +488,7 @@ void ANTIALIASING_SMAA::Present()
// pass 1: main-buffer -> smaaEdgesBuffer
//
compositor->SetBuffer( smaaEdgesBuffer );
compositor->ClearBuffer();
compositor->ClearBuffer( COLOR4D::BLACK );
glActiveTexture( GL_TEXTURE0 );
glBindTexture( GL_TEXTURE_2D, sourceTexture ); checkGlError( "binding colorTex" );
@ -499,7 +500,7 @@ void ANTIALIASING_SMAA::Present()
// pass 2: smaaEdgesBuffer -> smaaBlendBuffer
//
compositor->SetBuffer( smaaBlendBuffer );
compositor->ClearBuffer();
compositor->ClearBuffer( COLOR4D::BLACK );
auto edgesTex = compositor->GetBufferTexture( smaaEdgesBuffer );
@ -518,7 +519,7 @@ void ANTIALIASING_SMAA::Present()
// pass 3: colorTex + BlendBuffer -> output
//
compositor->SetBuffer( OPENGL_COMPOSITOR::DIRECT_RENDERING );
compositor->ClearBuffer();
compositor->ClearBuffer( COLOR4D::BLACK );
auto blendTex = compositor->GetBufferTexture( smaaBlendBuffer );
glActiveTexture( GL_TEXTURE0 );

View File

@ -31,6 +31,8 @@
#include <gal/opengl/opengl_compositor.h>
#include <gal/opengl/utils.h>
#include <gal/color4d.h>
#include <stdexcept>
#include <cassert>
@ -245,7 +247,7 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer( VECTOR2U aDimensions )
return 0;
}
ClearBuffer();
ClearBuffer( COLOR4D::BLACK );
// Return to direct rendering (we were asked only to create a buffer, not switch to one)
bindFb( DIRECT_RENDERING );
@ -290,11 +292,11 @@ void OPENGL_COMPOSITOR::SetBuffer( unsigned int aBufferHandle )
}
void OPENGL_COMPOSITOR::ClearBuffer()
void OPENGL_COMPOSITOR::ClearBuffer( const COLOR4D& aColor )
{
assert( m_initialized );
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
glClearColor( aColor.r, aColor.g, aColor.b, 0.0f );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
}

View File

@ -1145,11 +1145,11 @@ void OPENGL_GAL::Flush()
}
void OPENGL_GAL::ClearScreen( const COLOR4D& aColor )
void OPENGL_GAL::ClearScreen( )
{
// Clear screen
compositor->SetBuffer( OPENGL_COMPOSITOR::DIRECT_RENDERING );
glClearColor( aColor.r, aColor.g, aColor.b, aColor.a );
glClearColor( m_clearColor.r, m_clearColor.g, m_clearColor.b, m_clearColor.a );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
}
@ -1312,7 +1312,11 @@ void OPENGL_GAL::ClearTarget( RENDER_TARGET aTarget )
break;
}
compositor->ClearBuffer();
if( aTarget != TARGET_OVERLAY )
compositor->ClearBuffer( m_clearColor );
else
compositor->ClearBuffer( COLOR4D::BLACK );
// Restore the previous state
compositor->SetBuffer( oldTarget );
@ -1675,6 +1679,7 @@ void OPENGL_GAL::blitCursor()
const COLOR4D color( cColor.r * cColor.a, cColor.g * cColor.a,
cColor.b * cColor.a, 1.0 );
glActiveTexture( GL_TEXTURE0 );
glDisable( GL_TEXTURE_2D );
glLineWidth( 1.0 );
glColor4d( color.r, color.g, color.b, color.a );

View File

@ -26,6 +26,7 @@
#include <preview_items/preview_utils.h>
#include <gal/graphics_abstraction_layer.h>
#include <view/view.h>
#include <pcb_painter.h>
#include <common.h>
#include <base_units.h>
@ -88,40 +89,47 @@ double angleIsSpecial( double aRadians )
}
static void drawLineWithHilight( KIGFX::GAL& aGal,
static void drawLineWithHilight( KIGFX::VIEW *aView,
const VECTOR2I& aStart, const VECTOR2I& aEnd, bool aDim )
{
auto gal = aView->GetGAL();
auto rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( aView->GetPainter()->GetSettings() );
const auto vec = aEnd - aStart;
COLOR4D strokeColor = PreviewOverlayDefaultColor();
COLOR4D strokeColor = rs->GetLayerColor( LAYER_AUX_ITEMS );
if( angleIsSpecial( vec.Angle() ) )
strokeColor = PreviewOverlaySpecialAngleColor();
strokeColor = rs->IsBackgroundDark() ? COLOR4D( 0.5, 1.0, 0.5, 1.0 ) : COLOR4D( 0.0, 0.7, 0.0, 1.0 ) ;
aGal.SetStrokeColor( strokeColor.WithAlpha( PreviewOverlayDeemphAlpha( aDim ) ) );
aGal.DrawLine( aStart, aEnd );
gal->SetStrokeColor( strokeColor.WithAlpha( PreviewOverlayDeemphAlpha( aDim ) ) );
gal->DrawLine( aStart, aEnd );
}
static void drawArcWithHilight( KIGFX::GAL& aGal,
static void drawArcWithHilight( KIGFX::VIEW *aView,
const VECTOR2I& aOrigin, double aRad, double aStartAngle,
double aEndAngle )
{
COLOR4D color = PreviewOverlayDefaultColor();
auto gal = aView->GetGAL();
auto rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( aView->GetPainter()->GetSettings() );
auto color = rs->GetLayerColor( LAYER_AUX_ITEMS );
if( angleIsSpecial( aStartAngle - aEndAngle ) )
color = PreviewOverlaySpecialAngleColor();
color = rs->IsBackgroundDark() ? COLOR4D( 0.5, 1.0, 0.5, 1.0 ) : COLOR4D( 0.0, 0.7, 0.0, 1.0 ) ;
aGal.SetStrokeColor( color );
aGal.SetFillColor( color.WithAlpha( 0.2 ) );
gal->SetStrokeColor( color );
gal->SetFillColor( color.WithAlpha( 0.2 ) );
// draw the angle reference arc
aGal.DrawArc( aOrigin, aRad, -aStartAngle, -aEndAngle );
gal->DrawArc( aOrigin, aRad, -aStartAngle, -aEndAngle );
}
void ARC_ASSISTANT::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
{
auto& gal = *aView->GetGAL();
auto rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( aView->GetPainter()->GetSettings() );
// not in a position to draw anything
if( m_constructMan.IsReset() )
@ -144,7 +152,7 @@ void ARC_ASSISTANT::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
// draw first radius line
bool dimFirstLine = m_constructMan.GetStep() > ARC_GEOM_MANAGER::SET_START;
drawLineWithHilight( gal, origin, m_constructMan.GetStartRadiusEnd(), dimFirstLine );
drawLineWithHilight( aView, origin, m_constructMan.GetStartRadiusEnd(), dimFirstLine );
std::vector<wxString> cursorStrings;
@ -156,11 +164,11 @@ void ARC_ASSISTANT::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
const auto angleRefLineEnd = m_constructMan.GetOrigin() + VECTOR2D( innerRad * 1.5, 0.0 );
gal.SetStrokeColor( PreviewOverlayDefaultColor() );
gal.SetStrokeColor( rs->GetLayerColor( LAYER_AUX_ITEMS ) );
gal.DrawLine( origin, angleRefLineEnd );
// draw the angle reference arc
drawArcWithHilight( gal, origin, innerRad, initAngle, 0.0 );
drawArcWithHilight( aView, origin, innerRad, initAngle, 0.0 );
double degs = getNormDeciDegFromRad( initAngle );
@ -169,18 +177,18 @@ void ARC_ASSISTANT::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
}
else
{
drawLineWithHilight( gal, origin, m_constructMan.GetEndRadiusEnd(), false );
drawLineWithHilight( aView, origin, m_constructMan.GetEndRadiusEnd(), false );
auto start = m_constructMan.GetStartAngle();
auto subtended = m_constructMan.GetSubtended();
drawArcWithHilight( gal, origin, innerRad, start, start + subtended );
drawArcWithHilight( aView, origin, innerRad, start, start + subtended );
double subtendedDeg = getNormDeciDegFromRad( subtended );
double endAngleDeg = getNormDeciDegFromRad( start + subtended );
// draw dimmed extender line to cursor
drawLineWithHilight( gal, origin, m_constructMan.GetLastPoint(), true );
drawLineWithHilight( aView, origin, m_constructMan.GetLastPoint(), true );
cursorStrings.push_back( DimensionLabel( "Δθ", subtendedDeg, DEGREES ) );
cursorStrings.push_back( DimensionLabel( "θ", endAngleDeg, DEGREES ) );
@ -194,7 +202,7 @@ void ARC_ASSISTANT::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
}
// place the text next to cursor, on opposite side from radius
DrawTextNextToCursor( gal, m_constructMan.GetLastPoint(),
DrawTextNextToCursor( aView, m_constructMan.GetLastPoint(),
origin - m_constructMan.GetLastPoint(),
cursorStrings );
}

View File

@ -26,7 +26,7 @@
#include <preview_items/two_point_geom_manager.h>
#include <gal/graphics_abstraction_layer.h>
#include <view/view.h>
using namespace KIGFX::PREVIEW;
@ -93,8 +93,10 @@ const BOX2I CENTRELINE_RECT_ITEM::ViewBBox() const
}
void CENTRELINE_RECT_ITEM::drawPreviewShape( KIGFX::GAL& aGal ) const
void CENTRELINE_RECT_ITEM::drawPreviewShape( KIGFX::VIEW* aView ) const
{
aGal.DrawLine( m_geomMgr.GetOrigin(), m_geomMgr.GetEnd() );
aGal.DrawPolygon( getOutline() );
auto& gal = *aView->GetGAL();
gal.DrawLine( m_geomMgr.GetOrigin(), m_geomMgr.GetEnd() );
gal.DrawPolygon( getOutline() );
}

View File

@ -27,6 +27,7 @@
#include <gal/graphics_abstraction_layer.h>
#include <view/view.h>
#include <pcb_painter.h>
using namespace KIGFX::PREVIEW;
@ -59,14 +60,17 @@ void POLYGON_ITEM::SetPoints( const std::vector<VECTOR2I>& aLockedPts,
}
void POLYGON_ITEM::drawPreviewShape( KIGFX::GAL& aGal ) const
void POLYGON_ITEM::drawPreviewShape( KIGFX::VIEW* aView ) const
{
aGal.DrawPolyline( m_lockedChain );
aGal.DrawPolygon( m_polyfill );
auto& gal = *aView->GetGAL();
auto rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( aView->GetPainter()->GetSettings() );
gal.DrawPolyline( m_lockedChain );
gal.DrawPolygon( m_polyfill );
// draw the leader line in a different color
aGal.SetStrokeColor( PreviewOverlayDefaultColor() );
aGal.DrawPolyline( m_leaderChain );
gal.SetStrokeColor( rs->GetLayerColor( LAYER_AUX_ITEMS ) );
gal.DrawPolyline( m_leaderChain );
}

View File

@ -24,19 +24,8 @@
#include <preview_items/preview_utils.h>
#include <gal/graphics_abstraction_layer.h>
#include <base_units.h>
COLOR4D KIGFX::PREVIEW::PreviewOverlayDefaultColor()
{
return COLOR4D( 1.0, 1.0, 1.0, 1.0 );
}
double KIGFX::PREVIEW::PreviewOverlayFillAlpha()
{
return 0.2;
}
#include <pcb_painter.h>
#include <view/view.h>
double KIGFX::PREVIEW::PreviewOverlayDeemphAlpha( bool aDeemph )
{
@ -44,12 +33,6 @@ double KIGFX::PREVIEW::PreviewOverlayDeemphAlpha( bool aDeemph )
}
COLOR4D KIGFX::PREVIEW::PreviewOverlaySpecialAngleColor()
{
return COLOR4D( 0.5, 1.0, 0.5, 1.0 );
}
static wxString getDimensionUnit( EDA_UNITS_T aUnits )
{
switch( aUnits )
@ -129,11 +112,13 @@ void KIGFX::PREVIEW::SetConstantGlyphHeight( KIGFX::GAL& aGal, double aHeight )
}
void KIGFX::PREVIEW::DrawTextNextToCursor( KIGFX::GAL& aGal,
void KIGFX::PREVIEW::DrawTextNextToCursor( KIGFX::VIEW* aView,
const VECTOR2D& aCursorPos, const VECTOR2D& aTextQuadrant,
const std::vector<wxString>& aStrings )
{
auto glyphSize = aGal.GetGlyphSize();
auto gal = aView->GetGAL();
auto glyphSize = gal->GetGlyphSize();
auto rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( aView->GetPainter()->GetSettings() );
const auto lineSpace = glyphSize.y * 0.2;
auto linePitch = glyphSize.y + lineSpace;
@ -151,23 +136,23 @@ void KIGFX::PREVIEW::DrawTextNextToCursor( KIGFX::GAL& aGal,
if( aTextQuadrant.x < 0 )
{
aGal.SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
textPos.x += 15.0 / aGal.GetWorldScale();
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
textPos.x += 15.0 / gal->GetWorldScale();
}
else
{
aGal.SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT );
textPos.x -= 15.0 / aGal.GetWorldScale();
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT );
textPos.x -= 15.0 / gal->GetWorldScale();
}
aGal.SetStrokeColor( PreviewOverlayDefaultColor().WithAlpha(
gal->SetStrokeColor( rs->GetLayerColor( LAYER_AUX_ITEMS ).WithAlpha(
PreviewOverlayDeemphAlpha( true ) ) );
aGal.SetIsFill( false );
gal->SetIsFill( false );
// write strings top-to-bottom
for( const auto& str : aStrings )
{
textPos.y += linePitch;
aGal.BitmapText( str, textPos, 0.0 );
gal->BitmapText( str, textPos, 0.0 );
}
}

View File

@ -27,6 +27,7 @@
#include <gal/graphics_abstraction_layer.h>
#include <layers_id_colors_and_visibility.h>
#include <view/view.h>
#include <pcb_painter.h>
#include <base_units.h>
#include <common.h>
@ -38,7 +39,7 @@ static const double midTickLengthFactor = 1.5;
static const double majorTickLengthFactor = 2.5;
static void drawCursorStrings( KIGFX::GAL& aGal, const VECTOR2D& aCursor,
static void drawCursorStrings( KIGFX::VIEW* aView, const VECTOR2D& aCursor,
const VECTOR2D& aRulerVec )
{
// draw the cursor labels
@ -56,7 +57,7 @@ static void drawCursorStrings( KIGFX::GAL& aGal, const VECTOR2D& aCursor,
}
auto temp = aRulerVec;
DrawTextNextToCursor( aGal, aCursor, -temp, cursorStrings );
DrawTextNextToCursor( aView, aCursor, -temp, cursorStrings );
}
@ -117,13 +118,14 @@ static TICK_FORMAT getTickFormatForScale( double aScale, double& aTickSpace )
* @param aLine line vector
* @param aMinorTickLen length of minor ticks in IU
*/
void drawTicksAlongLine( KIGFX::GAL& aGal, const VECTOR2D& aOrigin,
void drawTicksAlongLine( KIGFX::VIEW *aView, const VECTOR2D& aOrigin,
const VECTOR2D& aLine, double aMinorTickLen )
{
VECTOR2D tickLine = aLine.Rotate( -M_PI_2 );
auto gal = aView->GetGAL();
double tickSpace;
TICK_FORMAT tickF = getTickFormatForScale( aGal.GetWorldScale(), tickSpace );
TICK_FORMAT tickF = getTickFormatForScale( gal->GetWorldScale(), tickSpace );
auto rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( aView->GetPainter()->GetSettings() );
// number of ticks in whole ruler
int numTicks = (int) std::ceil( aLine.EuclideanNorm() / tickSpace );
@ -133,16 +135,16 @@ void drawTicksAlongLine( KIGFX::GAL& aGal, const VECTOR2D& aOrigin,
if( aLine.Angle() > 0 )
{
aGal.SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_LEFT );
}
else
{
aGal.SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT );
gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_RIGHT );
labelAngle += M_PI;
}
// text and ticks are dimmed
aGal.SetStrokeColor( PreviewOverlayDefaultColor().WithAlpha( PreviewOverlayDeemphAlpha( true ) ) );
gal->SetStrokeColor( rs->GetLayerColor( LAYER_AUX_ITEMS ).WithAlpha( PreviewOverlayDeemphAlpha( true ) ) );
const auto labelOffset = tickLine.Resize( aMinorTickLen * ( majorTickLengthFactor + 1 ) );
@ -164,7 +166,7 @@ void drawTicksAlongLine( KIGFX::GAL& aGal, const VECTOR2D& aOrigin,
length *= midTickLengthFactor;
}
aGal.DrawLine( tickPos, tickPos + tickLine.Resize( length ) );
gal->DrawLine( tickPos, tickPos + tickLine.Resize( length ) );
if( drawLabel )
{
@ -173,7 +175,7 @@ void drawTicksAlongLine( KIGFX::GAL& aGal, const VECTOR2D& aOrigin,
// FIXME: spaces choke OpenGL lp:1668455
label.erase( std::remove( label.begin(), label.end(), ' ' ), label.end() );
aGal.BitmapText( label, tickPos + labelOffset, labelAngle );
gal->BitmapText( label, tickPos + labelOffset, labelAngle );
}
}
}
@ -230,6 +232,7 @@ void RULER_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
void RULER_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
{
auto& gal = *aView->GetGAL();
auto rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( aView->GetPainter()->GetSettings() );
const auto origin = m_geomMgr.GetOrigin();
const auto end = m_geomMgr.GetEnd();
@ -237,7 +240,7 @@ void RULER_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
gal.SetLineWidth( 1.0 );
gal.SetIsStroke( true );
gal.SetIsFill( false );
gal.SetStrokeColor( PreviewOverlayDefaultColor() );
gal.SetStrokeColor( rs->GetLayerColor( LAYER_AUX_ITEMS ) );
gal.ResetTextAttributes();
@ -249,7 +252,7 @@ void RULER_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
// constant text size on screen
SetConstantGlyphHeight( gal, 12.0 );
drawCursorStrings( gal, end, rulerVec );
drawCursorStrings( aView, end, rulerVec );
// tick label size
SetConstantGlyphHeight( gal, 10.0 );
@ -257,9 +260,9 @@ void RULER_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
// basic tick size
const double minorTickLen = 5.0 / gal.GetWorldScale();
drawTicksAlongLine( gal, origin, rulerVec, minorTickLen );
drawTicksAlongLine( aView, origin, rulerVec, minorTickLen );
gal.SetStrokeColor( PreviewOverlayDefaultColor().WithAlpha( PreviewOverlayDeemphAlpha( true ) ) );
gal.SetStrokeColor( rs->GetLayerColor( LAYER_AUX_ITEMS ).WithAlpha( PreviewOverlayDeemphAlpha( true ) ) );
drawBacksideTicks( gal, origin, rulerVec, minorTickLen * majorTickLengthFactor, 2 );
// draw the back of the origin "crosshair"

View File

@ -26,23 +26,44 @@
#include <gal/graphics_abstraction_layer.h>
#include <view/view.h>
#include <pcb_painter.h>
using namespace KIGFX::PREVIEW;
// Selection area colours
const COLOR4D SELECT_MODE_NORMAL( 0.3, 0.3, 0.7, 0.3 ); // Slight blue
const COLOR4D SELECT_MODE_ADDITIVE( 0.3, 0.7, 0.3, 0.3 ); // Slight green
const COLOR4D SELECT_MODE_SUBTRACT( 0.7, 0.3, 0.3, 0.3 ); // Slight red
struct SELECTION_COLORS
{
COLOR4D normal;
COLOR4D additive;
COLOR4D subtract;
COLOR4D outline_l2r;
COLOR4D outline_r2l;
};
static const SELECTION_COLORS selectionColorScheme[2] = {
{ // dark background
COLOR4D( 0.3, 0.3, 0.7, 0.3 ), // Slight blue
COLOR4D( 0.3, 0.7, 0.3, 0.3 ), // Slight green
COLOR4D( 0.7, 0.3, 0.3, 0.3 ), // Slight red
COLOR4D( 1.0, 1.0, 0.4, 1.0 ), // yellow
COLOR4D( 0.4, 0.4, 1.0, 1.0 ) // blue
},
{ // bright background
COLOR4D( 0.5, 0.3, 1.0, 0.5 ), // Slight blue
COLOR4D( 0.5, 1.0, 0.5, 0.5 ), // Slight green
COLOR4D( 1.0, 0.5, 0.5, 0.5 ), // Slight red
COLOR4D( 0.7, 0.7, 0.0, 1.0 ), // yellow
COLOR4D( 0.1, 0.1, 1.0, 1.0 ) // blue
}
};
const COLOR4D SELECT_OUTLINE_L2R( 1.0, 1.0, 0.4, 1.0 );
const COLOR4D SELECT_OUTLINE_R2L( 0.4, 0.4, 1.0, 1.0 );
SELECTION_AREA::SELECTION_AREA() :
m_additive( false ),
m_subtractive( false )
{
SetStrokeColor( SELECT_OUTLINE_L2R );
SetFillColor( SELECT_MODE_NORMAL );
}
@ -74,26 +95,33 @@ const BOX2I SELECTION_AREA::ViewBBox() const
return tmp;
}
void SELECTION_AREA::drawPreviewShape( KIGFX::GAL& aGal ) const
void SELECTION_AREA::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
{
auto& gal = *aView->GetGAL();
auto rs = static_cast<PCB_RENDER_SETTINGS*>( aView->GetPainter()->GetSettings() );
const auto& scheme = rs->IsBackgroundDark() ? selectionColorScheme[0] : selectionColorScheme[1];
// Set the fill of the selection rectangle
// based on the selection mode
if( m_additive )
{
aGal.SetFillColor( SELECT_MODE_ADDITIVE );
gal.SetFillColor( scheme.additive );
}
else if( m_subtractive )
{
aGal.SetFillColor( SELECT_MODE_SUBTRACT );
gal.SetFillColor( scheme.subtract );
}
else
{
aGal.SetFillColor( SELECT_MODE_NORMAL );
gal.SetFillColor( scheme.normal );
}
// Set the stroke color to indicate window or crossing selection
aGal.SetStrokeColor( ( m_origin.x <= m_end.x ) ? SELECT_OUTLINE_L2R : SELECT_OUTLINE_R2L );
gal.SetIsStroke( true );
gal.SetIsFill( true );
aGal.DrawRectangle( m_origin, m_end );
// Set the stroke color to indicate window or crossing selection
gal.SetStrokeColor( ( m_origin.x <= m_end.x ) ? scheme.outline_l2r : scheme.outline_r2l );
gal.DrawRectangle( m_origin, m_end );
}

View File

@ -44,7 +44,7 @@ void SIMPLE_OVERLAY_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
auto& gal = *aView->GetGAL();
setupGal( gal );
drawPreviewShape( gal );
drawPreviewShape( aView );
}

View File

@ -1,8 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2010-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2014 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 2012-2017 Kicad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -22,13 +21,30 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/* colors_selection.h */
#include <core/settings.h>
#ifndef _COLORS_SELECTION_H_
#define _COLORS_SELECTION_H_
void SETTINGS::Load( wxConfigBase *aConfig )
{
for( const PARAM_CFG_BASE& param : m_params )
{
if( !!param.m_Group )
aConfig->SetPath( param.m_Group );
else
aConfig->SetPath( wxT("") );
#include <class_colors_design_settings.h>
// Colors for layers and items
extern COLORS_DESIGN_SETTINGS g_ColorsSettings;
param.ReadParam( aConfig );
}
}
#endif // _COLORS_SELECTION_H_
void SETTINGS::Save( wxConfigBase *aConfig )
{
for( PARAM_CFG_BASE& param : m_params )
{
if( !!param.m_Group )
aConfig->SetPath( param.m_Group );
else
aConfig->SetPath( wxT("") );
param.SaveParam( aConfig );
}
}

View File

@ -36,6 +36,7 @@ set( CVPCB_DIALOGS
set( CVPCB_SRCS
../common/base_units.cpp
../pcbnew/board_items_to_polygon_shape_transform.cpp
../pcbnew/pcb_general_settings.cpp
../pcbnew/class_drc_item.cpp
autosel.cpp
cfg.cpp

View File

@ -432,7 +432,7 @@ void DISPLAY_FOOTPRINTS_FRAME::SetGridVisibility(bool aVisible)
}
COLOR4D DISPLAY_FOOTPRINTS_FRAME::GetGridColor() const
COLOR4D DISPLAY_FOOTPRINTS_FRAME::GetGridColor()
{
return COLOR4D( DARKGRAY );
}

View File

@ -87,7 +87,7 @@ public:
* Function GetGridColor() , virtual
* @return the color of the grid
*/
virtual COLOR4D GetGridColor() const override;
virtual COLOR4D GetGridColor() override;
void OnLeftClick( wxDC* DC, const wxPoint& MousePos ) override;
void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) override;

View File

@ -38,7 +38,6 @@
#include <cvpcb.h>
#include <zones.h>
#include <cvpcb_mainframe.h>
#include <colors_selection.h>
#include <cvpcb_id.h>
#include <build_version.h>

View File

@ -71,6 +71,8 @@ set( GERBVIEW_EXTRA_SRCS
../common/eda_text.cpp
../common/class_layer_box_selector.cpp
../common/class_page_info.cpp
../common/lset.cpp
../common/settings.cpp
../pcbnew/layer_widget.cpp
)

View File

@ -30,7 +30,6 @@
*/
#include <common.h>
#include <colors_selection.h>
#include <gerbview_frame.h>
#include <class_gerber_file_image_list.h>

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