|
KiCad PCB EDA Suite
|
#include <constraint_overlay.h>
Public Member Functions | |
| CONSTRAINT_OVERLAY (BOARD *aBoard, KIGFX::VIEW *aView) | |
| ~CONSTRAINT_OVERLAY () override | |
| void | Update (const BOARD_CONSTRAINT_DIAGNOSTICS &aDiag) |
Redraw the tint and badges from aDiag (the caller owns the one board-wide solve). | |
| void | RefreshSelection () |
| Redraw from the last diagnosis without re-solving (for a selection-only change). | |
| void | Clear () |
| Hide the overlay. | |
| bool | SetSelected (const KIID &aConstraint) |
| Mark a constraint as selected so its badge draws enlarged and ringed; pass niluuid to clear. | |
| const KIID & | GetSelected () const |
| bool | SetIsolated (const KIID &aConstraint) |
| Show only this constraint, or niluuid to show all. Returns true if it changed. | |
| const KIID & | GetIsolated () const |
| bool | SetVisibilityMode (OVERLAY_MODE aMode) |
| Set the visibility mode (HOVER vs ALWAYS). Returns true if it changed. | |
| OVERLAY_MODE | GetVisibilityMode () const |
| bool | SetHoverShape (const KIID &aShape) |
| In HOVER mode, show only this shape's constraints; niluuid draws nothing. | |
| const KIID & | GetHoverShape () const |
| bool | SetPickPreview (const KIID &aElement, bool aWholeElement, const std::optional< VECTOR2I > &aAnchor) |
Preview next constraint pick target while authoring a point based constraint aElement is shape or dimension outlined aAnchor marks point unless aWholeElement niluuid clears. | |
| void | ClearPickPreview () |
| Drop any pick preview. | |
| const std::vector< CONSTRAINT_BADGE > & | Badges () const |
| Badges placed by the last Update(), for canvas hit-testing. | |
Static Public Member Functions | |
| static double | BadgeHitRadius () |
| Click hit radius in screen pixels. | |
| static VECTOR2D | BadgeScreenOffset () |
| Screen-pixel offset from a badge's anchor to where its glyph draws and hit-tests, keeping the glyph clear of the geometry so clicks on the shape still select the shape. | |
| static double | BadgeWorldPerPixel (double aWorldScale) |
| World units per screen pixel for badge sizing, capped at far zoom-out. | |
| static std::vector< VECTOR2D > | LayoutBadges (const std::vector< CONSTRAINT_BADGE > &aBadges, double aWorldPerPx) |
| The on-screen draw position (world units) of each badge at the given scale: the anchor offset by BadgeScreenOffset() plus a screen-constant fan-out that de-overlaps badges sharing (or near) an anchor. | |
Protected Attributes | |
| KIGFX::VIEW * | m_view |
| std::shared_ptr< KIGFX::VIEW_OVERLAY > | m_overlay |
Private Member Functions | |
| void | render () |
| Redraw the tint and badges from m_lastDiag (no re-solve). | |
Private Attributes | |
| BOARD * | m_board |
| BOARD_CONSTRAINT_DIAGNOSTICS | m_lastDiag |
| std::vector< CONSTRAINT_BADGE > | m_badges |
| KIID | m_selected |
| KIID | m_isolated |
| OVERLAY_MODE | m_mode = OVERLAY_MODE::ALWAYS |
| KIID | m_hoverShape = niluuid |
| CONSTRAINT_BADGE_ITEM | m_badgeItem |
| KIID | m_previewElement = niluuid |
| bool | m_previewWhole = true |
| std::optional< VECTOR2I > | m_previewAnchor |
Definition at line 140 of file constraint_overlay.h.
| CONSTRAINT_OVERLAY::CONSTRAINT_OVERLAY | ( | BOARD * | aBoard, |
| KIGFX::VIEW * | aView ) |
Definition at line 56 of file constraint_overlay.cpp.
References m_badgeItem, m_board, m_isolated, m_selected, VIEW_OVERLAY_HOLDER::m_view, niluuid, and VIEW_OVERLAY_HOLDER::VIEW_OVERLAY_HOLDER().
|
override |
Definition at line 66 of file constraint_overlay.cpp.
References m_badgeItem, and VIEW_OVERLAY_HOLDER::m_view.
|
static |
Click hit radius in screen pixels.
The badges draw at a constant screen size, so the caller converts this to world units with the view scale.
Definition at line 93 of file constraint_overlay.cpp.
Referenced by CONSTRAINT_EDIT_TOOL::hitTestBadge(), and CONSTRAINT_EDIT_TOOL::onHoverMotion().
|
inline |
Badges placed by the last Update(), for canvas hit-testing.
Definition at line 186 of file constraint_overlay.h.
References m_badges.
|
static |
Screen-pixel offset from a badge's anchor to where its glyph draws and hit-tests, keeping the glyph clear of the geometry so clicks on the shape still select the shape.
Definition at line 99 of file constraint_overlay.cpp.
Referenced by LayoutBadges().
|
static |
World units per screen pixel for badge sizing, capped at far zoom-out.
Shared by drawing and hit-testing.
Definition at line 107 of file constraint_overlay.cpp.
References pcbIUScale.
Referenced by CONSTRAINT_EDIT_TOOL::hitTestBadge(), CONSTRAINT_EDIT_TOOL::onHoverMotion(), and CONSTRAINT_BADGE_ITEM::ViewDraw().
| void CONSTRAINT_OVERLAY::Clear | ( | ) |
Hide the overlay.
Definition at line 73 of file constraint_overlay.cpp.
References m_badgeItem, m_badges, VIEW_OVERLAY_HOLDER::m_overlay, m_previewAnchor, m_previewElement, VIEW_OVERLAY_HOLDER::m_view, niluuid, and KIGFX::TARGET_OVERLAY.
| void CONSTRAINT_OVERLAY::ClearPickPreview | ( | ) |
Drop any pick preview.
Definition at line 248 of file constraint_overlay.cpp.
References niluuid, and SetPickPreview().
|
inline |
Definition at line 175 of file constraint_overlay.h.
References m_hoverShape.
|
inline |
Definition at line 164 of file constraint_overlay.h.
References m_isolated.
|
inline |
Definition at line 159 of file constraint_overlay.h.
References m_selected.
|
inline |
Definition at line 169 of file constraint_overlay.h.
References m_mode.
|
static |
The on-screen draw position (world units) of each badge at the given scale: the anchor offset by BadgeScreenOffset() plus a screen-constant fan-out that de-overlaps badges sharing (or near) an anchor.
Because it is a pure function of the badge set and aWorldPerPx, drawing and hit-testing call it identically so they can never diverge.
Definition at line 117 of file constraint_overlay.cpp.
References anchor, BadgeScreenOffset(), clearance, SEG::Distance(), VECTOR2< T >::EuclideanNorm(), KiROUND(), M_PI, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), CONSTRAINT_EDIT_TOOL::hitTestBadge(), CONSTRAINT_EDIT_TOOL::onHoverMotion(), and CONSTRAINT_BADGE_ITEM::ViewDraw().
| void CONSTRAINT_OVERLAY::RefreshSelection | ( | ) |
Redraw from the last diagnosis without re-solving (for a selection-only change).
Definition at line 264 of file constraint_overlay.cpp.
References render().
|
private |
Redraw the tint and badges from m_lastDiag (no re-solve).
Definition at line 272 of file constraint_overlay.cpp.
References std::abs(), ALWAYS, anchor, ANGLE_0, ANGLE_360, ARC, EDA_ANGLE::AsDegrees(), BEZIER, center, CIRCLE, BOARD_CONSTRAINT_DIAGNOSTICS::conflicting, ConstraintAnchorPosition(), ConstraintItemAnchors(), SHAPE_ELLIPSE::ConvertToPolyline(), EDA_ANGLE::Cos(), ELLIPSE, ELLIPSE_ARC, BOARD_CONSTRAINT_DIAGNOSTICS::errored, EDA_SHAPE::GetArcAngle(), EDA_SHAPE::GetBezierPoints(), PCB_SHAPE::GetCenter(), EDA_SHAPE::GetEllipseCenter(), EDA_SHAPE::GetEllipseEndAngle(), EDA_SHAPE::GetEllipseMajorRadius(), EDA_SHAPE::GetEllipseMinorRadius(), EDA_SHAPE::GetEllipseRotation(), EDA_SHAPE::GetEllipseStartAngle(), EDA_SHAPE::GetEnd(), BOARD_ITEM::GetMaxError(), PCB_CONSTRAINT::GetMembers(), EDA_SHAPE::GetRadius(), EDA_SHAPE::GetShape(), EDA_SHAPE::GetStart(), KiROUND(), LAYER_CONSTRAINT_OVER, LAYER_CONSTRAINT_UNDER, LAYER_CONSTRAINT_WELL, m_badgeItem, m_badges, m_board, m_hoverShape, m_isolated, CONSTRAINT_MEMBER::m_item, m_lastDiag, m_mode, VIEW_OVERLAY_HOLDER::m_overlay, m_previewAnchor, m_previewElement, m_previewWhole, m_selected, EDA_ITEM::m_Uuid, VIEW_OVERLAY_HOLDER::m_view, niluuid, OVER_CONSTRAINED, pcbIUScale, radius, SEGMENT, BOARD_CONSTRAINT_DIAGNOSTICS::shapeStates, EDA_ANGLE::Sin(), KIGFX::TARGET_OVERLAY, UNDER_CONSTRAINED, and WELL_CONSTRAINED.
Referenced by RefreshSelection(), SetPickPreview(), and Update().
| bool CONSTRAINT_OVERLAY::SetHoverShape | ( | const KIID & | aShape | ) |
In HOVER mode, show only this shape's constraints; niluuid draws nothing.
Independent of the panel-row isolation. Returns true if it changed.
Definition at line 223 of file constraint_overlay.cpp.
References m_hoverShape.
| bool CONSTRAINT_OVERLAY::SetIsolated | ( | const KIID & | aConstraint | ) |
Show only this constraint, or niluuid to show all. Returns true if it changed.
Definition at line 203 of file constraint_overlay.cpp.
References m_isolated.
| bool CONSTRAINT_OVERLAY::SetPickPreview | ( | const KIID & | aElement, |
| bool | aWholeElement, | ||
| const std::optional< VECTOR2I > & | aAnchor ) |
Preview next constraint pick target while authoring a point based constraint aElement is shape or dimension outlined aAnchor marks point unless aWholeElement niluuid clears.
Definition at line 233 of file constraint_overlay.cpp.
References m_previewAnchor, m_previewElement, m_previewWhole, and render().
Referenced by ClearPickPreview().
| bool CONSTRAINT_OVERLAY::SetSelected | ( | const KIID & | aConstraint | ) |
Mark a constraint as selected so its badge draws enlarged and ringed; pass niluuid to clear.
Returns true if the selection changed (the caller should then Update()).
Definition at line 193 of file constraint_overlay.cpp.
References m_selected.
| bool CONSTRAINT_OVERLAY::SetVisibilityMode | ( | OVERLAY_MODE | aMode | ) |
Set the visibility mode (HOVER vs ALWAYS). Returns true if it changed.
Definition at line 213 of file constraint_overlay.cpp.
References m_mode.
| void CONSTRAINT_OVERLAY::Update | ( | const BOARD_CONSTRAINT_DIAGNOSTICS & | aDiag | ) |
Redraw the tint and badges from aDiag (the caller owns the one board-wide solve).
Definition at line 254 of file constraint_overlay.cpp.
References m_board, m_lastDiag, VIEW_OVERLAY_HOLDER::m_overlay, and render().
|
private |
Definition at line 218 of file constraint_overlay.h.
Referenced by Clear(), CONSTRAINT_OVERLAY(), render(), and ~CONSTRAINT_OVERLAY().
|
private |
Definition at line 213 of file constraint_overlay.h.
|
private |
Definition at line 211 of file constraint_overlay.h.
Referenced by CONSTRAINT_OVERLAY(), render(), and Update().
Definition at line 217 of file constraint_overlay.h.
Referenced by GetHoverShape(), render(), and SetHoverShape().
|
private |
Definition at line 215 of file constraint_overlay.h.
Referenced by CONSTRAINT_OVERLAY(), GetIsolated(), render(), and SetIsolated().
|
private |
Definition at line 212 of file constraint_overlay.h.
|
private |
Definition at line 216 of file constraint_overlay.h.
Referenced by GetVisibilityMode(), render(), and SetVisibilityMode().
|
protectedinherited |
Definition at line 50 of file view_overlay_holder.h.
Referenced by CONSTRAINT_OVERLAY::Clear(), CONSTRAINT_OVERLAY::render(), CONSTRAINT_OVERLAY::Update(), VIEW_OVERLAY_HOLDER(), and ~VIEW_OVERLAY_HOLDER().
|
private |
Definition at line 224 of file constraint_overlay.h.
Referenced by Clear(), render(), and SetPickPreview().
Definition at line 222 of file constraint_overlay.h.
Referenced by Clear(), render(), and SetPickPreview().
|
private |
Definition at line 223 of file constraint_overlay.h.
Referenced by render(), and SetPickPreview().
|
private |
Definition at line 214 of file constraint_overlay.h.
Referenced by CONSTRAINT_OVERLAY(), GetSelected(), render(), and SetSelected().
|
protectedinherited |
Definition at line 49 of file view_overlay_holder.h.
Referenced by CONSTRAINT_OVERLAY::Clear(), CONSTRAINT_OVERLAY::CONSTRAINT_OVERLAY(), CONSTRAINT_OVERLAY::render(), VIEW_OVERLAY_HOLDER(), CONSTRAINT_OVERLAY::~CONSTRAINT_OVERLAY(), and ~VIEW_OVERLAY_HOLDER().