36constexpr double FILL_ALPHA = 0.35;
40constexpr double POLYGON_FILL_ALPHA = 0.20;
42const KIGFX::COLOR4D HIDDEN_FILL( 0.5, 0.5, 0.5, 0.10 );
55 explicit OVERLAY_GEOMETRY_SINK( KIGFX::VIEW_OVERLAY& aOverlay ) : m_overlay( aOverlay ) {}
57 void FillPolygon(
const DOCUMENT_POLYGON& aPoly )
override
59 if( !aPoly.filled || aPoly.outline.size() < 3 )
62 m_overlay.SetIsFill(
true );
63 m_overlay.SetIsStroke(
false );
64 m_overlay.SetFillColor( aPoly.color );
66 std::deque<VECTOR2D> pts;
68 for(
const VECTOR2I& pt : aPoly.outline )
69 pts.emplace_back( pt.
x, pt.
y );
71 m_overlay.Polygon( pts );
74 void StrokePolygon(
const DOCUMENT_POLYGON& aPoly )
override
78 if( aPoly.outline.size() < 2 || ( aPoly.filled && aPoly.lineWidth == 0 ) )
81 m_overlay.SetIsFill(
false );
82 m_overlay.SetIsStroke(
true );
83 m_overlay.SetStrokeColor( aPoly.color );
84 m_overlay.SetLineWidth(
static_cast<double>( aPoly.lineWidth ) );
86 for( std::size_t i = 0; i + 1 < aPoly.outline.size(); ++i )
88 m_overlay.Line(
VECTOR2D( aPoly.outline[i].x, aPoly.outline[i].y ),
89 VECTOR2D( aPoly.outline[i + 1].x, aPoly.outline[i + 1].y ) );
93 m_overlay.Line(
VECTOR2D( aPoly.outline.back().x, aPoly.outline.back().y ),
94 VECTOR2D( aPoly.outline.front().x, aPoly.outline.front().y ) );
97 void DrawSegment(
const DOCUMENT_SEGMENT& aSegment )
override
99 m_overlay.SetIsFill(
false );
100 m_overlay.SetIsStroke(
true );
101 m_overlay.SetStrokeColor( aSegment.color );
103 if( aSegment.width > 0 )
105 m_overlay.Segment(
VECTOR2D( aSegment.start.x, aSegment.start.y ),
106 VECTOR2D( aSegment.end.x, aSegment.end.y ),
107 static_cast<double>( aSegment.width ) );
111 m_overlay.SetLineWidth( 0.0 );
112 m_overlay.Line(
VECTOR2D( aSegment.start.x, aSegment.start.y ),
113 VECTOR2D( aSegment.end.x, aSegment.end.y ) );
117 void DrawCircle(
const DOCUMENT_CIRCLE& aCircle )
override
121 m_overlay.SetIsFill(
true );
122 m_overlay.SetIsStroke(
false );
123 m_overlay.SetFillColor( aCircle.color );
127 m_overlay.SetIsFill(
false );
128 m_overlay.SetIsStroke(
true );
129 m_overlay.SetStrokeColor( aCircle.color );
130 m_overlay.SetLineWidth(
static_cast<double>( aCircle.lineWidth ) );
133 m_overlay.Circle(
VECTOR2D( aCircle.center.x, aCircle.center.y ),
134 static_cast<double>( aCircle.radius ) );
138 KIGFX::VIEW_OVERLAY& m_overlay;
142void renderDocumentGeometry( KIGFX::VIEW_OVERLAY& aOverlay,
const DOCUMENT_GEOMETRY& aGeometry )
144 OVERLAY_GEOMETRY_SINK sink( aOverlay );
152 const std::array<bool, CATEGORY_COUNT>& aVisible,
const std::optional<KIID_PATH>& aHighlight,
153 const std::set<KIID_PATH>& aHidden )
173 if( !aVisible[
static_cast<std::size_t
>( cat )] )
178 if( !s.polygons.empty() || s.bbox.GetWidth() <= 0 || s.bbox.GetHeight() <= 0 )
182 itemBoxes.
Append( s.bbox.GetOrigin().x, s.bbox.GetOrigin().y, o, -1 );
183 itemBoxes.
Append( s.bbox.GetEnd().x, s.bbox.GetOrigin().y, o, -1 );
184 itemBoxes.
Append( s.bbox.GetEnd().x, s.bbox.GetEnd().y, o, -1 );
185 itemBoxes.
Append( s.bbox.GetOrigin().x, s.bbox.GetEnd().y, o, -1 );
191 if( !aVisible[
static_cast<std::size_t
>( cat )] )
199 const bool hidden = !aHidden.empty() && aHidden.count( s.changeId ) > 0;
204 if( !s.polygons.empty() )
207 fill.
a = POLYGON_FILL_ALPHA;
228 border.
a = hidden ? HIDDEN_FILL.a : 1.0;
246 aOverlay.
Rectangle( s.bbox.GetOrigin(), s.bbox.GetEnd() );
A color representation with 4 components: red, green, blue, alpha.
void SetLineWidth(double aLineWidth)
void Polygon(const std::deque< VECTOR2D > &aPointList)
void Rectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
void SetIsFill(bool aIsFillEnabled)
void SetFillColor(const COLOR4D &aColor)
void SetIsStroke(bool aIsStrokeEnabled)
void SetStrokeColor(const COLOR4D &aColor)
Represent a set of closed polygons.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
int NewOutline()
Creates a new empty polygon in the set and returns its index.
int OutlineCount() const
Return the number of outlines in the set.
void BooleanSubtract(const SHAPE_POLY_SET &b)
Perform boolean polyset difference.
void IterateDocumentGeometry(const DOCUMENT_GEOMETRY &aGeometry, GEOMETRY_SINK &aSink)
Walk a DOCUMENT_GEOMETRY in the canonical render order shared by the GAL and plotter renderers: every...
void RenderSceneToOverlay(KIGFX::VIEW_OVERLAY &aOverlay, const DIFF_SCENE &aScene, const std::array< bool, CATEGORY_COUNT > &aVisible, const std::optional< KIID_PATH > &aHighlight, const std::set< KIID_PATH > &aHidden)
Push a DIFF_SCENE's shapes onto a VIEW_OVERLAY as filled, semi-transparent rectangles,...
CATEGORY
Visual category each ITEM_CHANGE belongs to in the scene.
const std::vector< SCENE_SHAPE > & ShapesFor(const DIFF_SCENE &aScene, CATEGORY aCategory)
Read-only access to a DIFF_SCENE's shape list for a given category.
constexpr std::array< CATEGORY, 4 > PAINT_ORDER
Paint order.
SHAPE_POLY_SET PolySetFromPolygonList(const SCENE_SHAPE::PolygonList &aPolygons)
Build a SHAPE_POLY_SET from a SCENE_SHAPE::PolygonList.
void DrawSegment(const ROUND_SEGMENT_2D &aSegment, unsigned int aNrSidesPerCircle)
Draw a thick line segment with rounded ends.
DOCUMENT_GEOMETRY referenceGeometry
Background geometry from the two source documents.
DOCUMENT_GEOMETRY comparisonGeometry
Aggregate of background geometry extracted from one source document.
Sink for the shared DOCUMENT_GEOMETRY walk.
Shared rendering model consumed by both the GAL renderer (interactive widget) and the plotter rendere...
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D