Fix some artifacts when drawing items, both on Cairo and Opengl.
Fix also incorrect selection of De Morgan style selection in SYMBOL_PREVIEW_WIDGET.
This commit is contained in:
parent
2d5baac77d
commit
a6d014d959
|
@ -181,9 +181,17 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
|
||||||
m_gal->SetClearColor( settings->GetBackgroundColor() );
|
m_gal->SetClearColor( settings->GetBackgroundColor() );
|
||||||
m_gal->SetCursorColor( settings->GetLayerColor( LAYER_CURSOR ) );
|
m_gal->SetCursorColor( settings->GetLayerColor( LAYER_CURSOR ) );
|
||||||
|
|
||||||
|
// TODO: find why ClearScreen() must be called here in opengl mode
|
||||||
|
// and only if m_view->IsDirty() in Cairo mode to avoid distaly artifacts
|
||||||
|
// when moving the mouse cursor
|
||||||
|
if( m_backend == GAL_TYPE_OPENGL )
|
||||||
|
m_gal->ClearScreen();
|
||||||
|
|
||||||
if( m_view->IsDirty() )
|
if( m_view->IsDirty() )
|
||||||
{
|
{
|
||||||
|
if( m_backend != GAL_TYPE_OPENGL ) // already called in opengl
|
||||||
m_gal->ClearScreen();
|
m_gal->ClearScreen();
|
||||||
|
|
||||||
m_view->ClearTargets();
|
m_view->ClearTargets();
|
||||||
|
|
||||||
// Grid has to be redrawn only when the NONCACHED target is redrawn
|
// Grid has to be redrawn only when the NONCACHED target is redrawn
|
||||||
|
|
|
@ -241,11 +241,15 @@ void CAIRO_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double aS
|
||||||
{
|
{
|
||||||
SWAP( aStartAngle, >, aEndAngle );
|
SWAP( aStartAngle, >, aEndAngle );
|
||||||
|
|
||||||
|
if( isFillEnabled ) // Draw the filled area of the shape, before drawing the outline itself
|
||||||
|
{
|
||||||
|
double pen_size = GetLineWidth();
|
||||||
|
auto fgcolor = GetStrokeColor();
|
||||||
|
SetStrokeColor( GetFillColor() );
|
||||||
|
|
||||||
|
SetLineWidth( 0 );
|
||||||
cairo_new_sub_path( currentContext );
|
cairo_new_sub_path( currentContext );
|
||||||
cairo_arc( currentContext, aCenterPoint.x, aCenterPoint.y, aRadius, aStartAngle, aEndAngle );
|
cairo_arc( currentContext, aCenterPoint.x, aCenterPoint.y, aRadius, aStartAngle, aEndAngle );
|
||||||
|
|
||||||
if( isFillEnabled )
|
|
||||||
{
|
|
||||||
VECTOR2D startPoint( cos( aStartAngle ) * aRadius + aCenterPoint.x,
|
VECTOR2D startPoint( cos( aStartAngle ) * aRadius + aCenterPoint.x,
|
||||||
sin( aStartAngle ) * aRadius + aCenterPoint.y );
|
sin( aStartAngle ) * aRadius + aCenterPoint.y );
|
||||||
VECTOR2D endPoint( cos( aEndAngle ) * aRadius + aCenterPoint.x,
|
VECTOR2D endPoint( cos( aEndAngle ) * aRadius + aCenterPoint.x,
|
||||||
|
@ -255,8 +259,13 @@ void CAIRO_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double aS
|
||||||
cairo_line_to( currentContext, startPoint.x, startPoint.y );
|
cairo_line_to( currentContext, startPoint.x, startPoint.y );
|
||||||
cairo_line_to( currentContext, endPoint.x, endPoint.y );
|
cairo_line_to( currentContext, endPoint.x, endPoint.y );
|
||||||
cairo_close_path( currentContext );
|
cairo_close_path( currentContext );
|
||||||
|
flushPath();
|
||||||
|
SetLineWidth( pen_size );
|
||||||
|
SetStrokeColor( fgcolor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cairo_new_sub_path( currentContext );
|
||||||
|
cairo_arc( currentContext, aCenterPoint.x, aCenterPoint.y, aRadius, aStartAngle, aEndAngle );
|
||||||
flushPath();
|
flushPath();
|
||||||
|
|
||||||
isElementAdded = true;
|
isElementAdded = true;
|
||||||
|
|
|
@ -358,9 +358,6 @@ void SCH_PAINTER::draw( LIB_ARC *aArc, int aLayer )
|
||||||
VECTOR2D pos = mapCoords( aArc->GetPosition() );
|
VECTOR2D pos = mapCoords( aArc->GetPosition() );
|
||||||
|
|
||||||
m_gal->DrawArc( pos, aArc->GetRadius(), sa, ea);
|
m_gal->DrawArc( pos, aArc->GetRadius(), sa, ea);
|
||||||
/*m_gal->SetStrokeColor(COLOR4D(1.0,0,0,1.0));
|
|
||||||
m_gal->DrawLine ( pos - VECTOR2D(20, 20), pos + VECTOR2D(20, 20));
|
|
||||||
m_gal->DrawLine ( pos - VECTOR2D(-20, 20), pos + VECTOR2D(-20, 20));*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1215,9 +1212,20 @@ void SCH_PAINTER::draw( SCH_SHEET *aSheet, int aLayer )
|
||||||
VECTOR2D size = aSheet->GetSize();
|
VECTOR2D size = aSheet->GetSize();
|
||||||
|
|
||||||
m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_SHEET ) );
|
m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_SHEET ) );
|
||||||
m_gal->SetFillColor ( COLOR4D(1.0, 1.0, 1.0, 0.5) );
|
|
||||||
m_gal->SetIsStroke ( true );
|
if( aSheet->IsMoving() ) // Gives a filled background when moving for a better look
|
||||||
|
{
|
||||||
|
// Select a fill color working well with black and white background color,
|
||||||
|
// both in Opengl and Cairo
|
||||||
|
m_gal->SetFillColor ( COLOR4D(0.1, 0.5, 0.5, 0.3) );
|
||||||
m_gal->SetIsFill ( true );
|
m_gal->SetIsFill ( true );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Could be modified later, when sheets can have their own fill color
|
||||||
|
m_gal->SetIsFill ( false );
|
||||||
|
}
|
||||||
|
m_gal->SetIsStroke ( true );
|
||||||
m_gal->DrawRectangle( pos, pos + size );
|
m_gal->DrawRectangle( pos, pos + size );
|
||||||
|
|
||||||
auto nameAngle = 0.0;
|
auto nameAngle = 0.0;
|
||||||
|
|
|
@ -122,6 +122,9 @@ void SYMBOL_PREVIEW_WIDGET::DisplaySymbol( const LIB_ID& aSymbolID, int aUnit )
|
||||||
|
|
||||||
settings->m_ShowUnit = aUnit;
|
settings->m_ShowUnit = aUnit;
|
||||||
|
|
||||||
|
// For symbols having a De Morgan body style, use the first style
|
||||||
|
settings->m_ShowConvert = part->HasConversion() ? 1 : 0;
|
||||||
|
|
||||||
view->Add( alias );
|
view->Add( alias );
|
||||||
m_previewItem = alias;
|
m_previewItem = alias;
|
||||||
|
|
||||||
|
@ -167,6 +170,10 @@ void SYMBOL_PREVIEW_WIDGET::DisplayPart( LIB_PART* aPart, int aUnit )
|
||||||
if( aPart->IsMulti() && aUnit == 0 )
|
if( aPart->IsMulti() && aUnit == 0 )
|
||||||
aUnit = 1;
|
aUnit = 1;
|
||||||
|
|
||||||
|
// For symbols having a De Morgan body style, use the first style
|
||||||
|
auto settings = static_cast<KIGFX::SCH_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
|
||||||
|
settings->m_ShowConvert = aPart->HasConversion() ? 1 : 0;
|
||||||
|
|
||||||
view->Add( aPart );
|
view->Add( aPart );
|
||||||
m_previewItem = aPart;
|
m_previewItem = aPart;
|
||||||
|
|
||||||
|
|
|
@ -254,6 +254,16 @@ public:
|
||||||
fillColor = aColor;
|
fillColor = aColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the fill color.
|
||||||
|
*
|
||||||
|
* @return the color for filling a outline.
|
||||||
|
*/
|
||||||
|
inline const COLOR4D& GetFillColor() const
|
||||||
|
{
|
||||||
|
return fillColor;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set the stroke color.
|
* @brief Set the stroke color.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue