← Back to team overview

kicad-developers team mailing list archive

Re: GAL canvas strategy - testers needed!

 

Le 16/09/2018 à 15:08, Jeff Young a écrit :
> I pushed a bunch of CLangTidy fixes and a fix for the grid colour.
> 
> Cheers,
> Jeff.
> 

Hi Jeff,
Attached a patch to fix some artifacts when drawing items.

Cheers,

> 
>> On 16 Sep 2018, at 08:40, mdoesbur@xxxxxxxxx wrote:
>>
>> I've given the GAL version a test-drive. Here are some issues I noted.
>> I guess most of it is because the black background was not tested before.
>>
>> 1. Grid color always black. (Not visible on black background) 
>> 2. Hierarchical sheet color always white.
>> 3. When using another background color (for example 1,1,1) the sheet
>>   color is correct after zooming.  When moving the mouse the sheet color
>>   gradually changes to white. Sometimes a double picture is shown, see
>>   attachment. The background color was 1,1,1 for this schematic.
>> <kicad_gal.png>


-- 
Jean-Pierre CHARRAS
From 533553983c01ac8d1a68a665174326672a385b05 Mon Sep 17 00:00:00 2001
From: jean-pierre charras <jp.charras@xxxxxxxxxx>
Date: Sun, 16 Sep 2018 13:30:18 +0200
Subject: [PATCH] Fix some artifacts when drawing items, both on Cairo and
 Opengl.

Fix also incorrect selection of De Morgan style selection in SYMBOL_PREVIEW_WIDGET.
---
 common/draw_panel_gal.cpp                  | 10 +++++++++-
 common/gal/cairo/cairo_gal.cpp             | 17 +++++++++++++----
 eeschema/sch_painter.cpp                   | 18 +++++++++++++-----
 eeschema/widgets/symbol_preview_widget.cpp |  7 +++++++
 include/gal/graphics_abstraction_layer.h   | 10 ++++++++++
 5 files changed, 52 insertions(+), 10 deletions(-)

diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp
index 543769151..69a99f2e2 100644
--- a/common/draw_panel_gal.cpp
+++ b/common/draw_panel_gal.cpp
@@ -172,9 +172,17 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
         m_gal->SetClearColor( settings->GetBackgroundColor() );
         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() )
         {
-            m_gal->ClearScreen();
+            if( m_backend != GAL_TYPE_OPENGL )   // already called in opengl
+                m_gal->ClearScreen();
+
             m_view->ClearTargets();
 
             // Grid has to be redrawn only when the NONCACHED target is redrawn
diff --git a/common/gal/cairo/cairo_gal.cpp b/common/gal/cairo/cairo_gal.cpp
index d9834b469..06b0acbd7 100644
--- a/common/gal/cairo/cairo_gal.cpp
+++ b/common/gal/cairo/cairo_gal.cpp
@@ -241,11 +241,15 @@ void CAIRO_GAL::DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double aS
 {
     SWAP( aStartAngle, >, aEndAngle );
 
-    cairo_new_sub_path( currentContext );
-    cairo_arc( currentContext, aCenterPoint.x, aCenterPoint.y, aRadius, aStartAngle, aEndAngle );
-
-    if( isFillEnabled )
+    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_arc( currentContext, aCenterPoint.x, aCenterPoint.y, aRadius, aStartAngle, aEndAngle );
         VECTOR2D startPoint( cos( aStartAngle ) * aRadius + aCenterPoint.x,
                              sin( aStartAngle ) * aRadius + aCenterPoint.y );
         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, endPoint.x, endPoint.y );
         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();
 
     isElementAdded = true;
diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp
index 875f8d00a..fe579b8f4 100644
--- a/eeschema/sch_painter.cpp
+++ b/eeschema/sch_painter.cpp
@@ -358,9 +358,6 @@ void SCH_PAINTER::draw( LIB_ARC *aArc, int aLayer )
     VECTOR2D pos = mapCoords( aArc->GetPosition() );
 
     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();
 
     m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_SHEET ) );
-    m_gal->SetFillColor ( COLOR4D(1.0, 1.0, 1.0, 0.5) );
+
+    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 );
+    }
+    else
+    {
+        // Could be modified later, when sheets can have their own fill color
+        m_gal->SetIsFill ( false );
+    }
     m_gal->SetIsStroke ( true );
-    m_gal->SetIsFill ( true );
     m_gal->DrawRectangle( pos, pos + size );
 
     auto nameAngle = 0.0;
diff --git a/eeschema/widgets/symbol_preview_widget.cpp b/eeschema/widgets/symbol_preview_widget.cpp
index 43741ef88..cd9a0d8b8 100644
--- a/eeschema/widgets/symbol_preview_widget.cpp
+++ b/eeschema/widgets/symbol_preview_widget.cpp
@@ -122,6 +122,9 @@ void SYMBOL_PREVIEW_WIDGET::DisplaySymbol( const LIB_ID& aSymbolID, int 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 );
         m_previewItem = alias;
 
@@ -167,6 +170,10 @@ void SYMBOL_PREVIEW_WIDGET::DisplayPart( LIB_PART* aPart, int aUnit )
         if( aPart->IsMulti() && aUnit == 0 )
             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 );
         m_previewItem = aPart;
 
diff --git a/include/gal/graphics_abstraction_layer.h b/include/gal/graphics_abstraction_layer.h
index b68c49a5a..bdffc3d2e 100644
--- a/include/gal/graphics_abstraction_layer.h
+++ b/include/gal/graphics_abstraction_layer.h
@@ -254,6 +254,16 @@ public:
         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.
      *
-- 
2.17.0.windows.1


Follow ups

References