KiCad PCB EDA Suite
Loading...
Searching...
No Matches
CONSTRAINT_OVERLAY Class Reference

#include <constraint_overlay.h>

Inheritance diagram for CONSTRAINT_OVERLAY:
VIEW_OVERLAY_HOLDER

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 KIIDGetSelected () const
 
bool SetIsolated (const KIID &aConstraint)
 Show only this constraint, or niluuid to show all. Returns true if it changed.
 
const KIIDGetIsolated () 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 KIIDGetHoverShape () 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< VECTOR2DLayoutBadges (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::VIEWm_view
 
std::shared_ptr< KIGFX::VIEW_OVERLAYm_overlay
 

Private Member Functions

void render ()
 Redraw the tint and badges from m_lastDiag (no re-solve).
 

Private Attributes

BOARDm_board
 
BOARD_CONSTRAINT_DIAGNOSTICS m_lastDiag
 
std::vector< CONSTRAINT_BADGEm_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< VECTOR2Im_previewAnchor
 

Detailed Description

Definition at line 140 of file constraint_overlay.h.

Constructor & Destructor Documentation

◆ CONSTRAINT_OVERLAY()

CONSTRAINT_OVERLAY::CONSTRAINT_OVERLAY ( BOARD * aBoard,
KIGFX::VIEW * aView )

◆ ~CONSTRAINT_OVERLAY()

CONSTRAINT_OVERLAY::~CONSTRAINT_OVERLAY ( )
override

Definition at line 66 of file constraint_overlay.cpp.

References m_badgeItem, and VIEW_OVERLAY_HOLDER::m_view.

Member Function Documentation

◆ BadgeHitRadius()

double CONSTRAINT_OVERLAY::BadgeHitRadius ( )
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().

◆ Badges()

const std::vector< CONSTRAINT_BADGE > & CONSTRAINT_OVERLAY::Badges ( ) const
inline

Badges placed by the last Update(), for canvas hit-testing.

Definition at line 186 of file constraint_overlay.h.

References m_badges.

◆ BadgeScreenOffset()

VECTOR2D CONSTRAINT_OVERLAY::BadgeScreenOffset ( )
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().

◆ BadgeWorldPerPixel()

double CONSTRAINT_OVERLAY::BadgeWorldPerPixel ( double aWorldScale)
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().

◆ Clear()

void CONSTRAINT_OVERLAY::Clear ( )

◆ ClearPickPreview()

void CONSTRAINT_OVERLAY::ClearPickPreview ( )

Drop any pick preview.

Definition at line 248 of file constraint_overlay.cpp.

References niluuid, and SetPickPreview().

◆ GetHoverShape()

const KIID & CONSTRAINT_OVERLAY::GetHoverShape ( ) const
inline

Definition at line 175 of file constraint_overlay.h.

References m_hoverShape.

◆ GetIsolated()

const KIID & CONSTRAINT_OVERLAY::GetIsolated ( ) const
inline

Definition at line 164 of file constraint_overlay.h.

References m_isolated.

◆ GetSelected()

const KIID & CONSTRAINT_OVERLAY::GetSelected ( ) const
inline

Definition at line 159 of file constraint_overlay.h.

References m_selected.

◆ GetVisibilityMode()

OVERLAY_MODE CONSTRAINT_OVERLAY::GetVisibilityMode ( ) const
inline

Definition at line 169 of file constraint_overlay.h.

References m_mode.

◆ LayoutBadges()

std::vector< VECTOR2D > CONSTRAINT_OVERLAY::LayoutBadges ( const std::vector< CONSTRAINT_BADGE > & aBadges,
double aWorldPerPx )
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().

◆ RefreshSelection()

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().

◆ render()

◆ SetHoverShape()

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.

◆ SetIsolated()

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.

◆ SetPickPreview()

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().

◆ SetSelected()

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.

◆ SetVisibilityMode()

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.

◆ Update()

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().

Member Data Documentation

◆ m_badgeItem

CONSTRAINT_BADGE_ITEM CONSTRAINT_OVERLAY::m_badgeItem
private

Definition at line 218 of file constraint_overlay.h.

Referenced by Clear(), CONSTRAINT_OVERLAY(), render(), and ~CONSTRAINT_OVERLAY().

◆ m_badges

std::vector<CONSTRAINT_BADGE> CONSTRAINT_OVERLAY::m_badges
private

Definition at line 213 of file constraint_overlay.h.

Referenced by Badges(), Clear(), and render().

◆ m_board

BOARD* CONSTRAINT_OVERLAY::m_board
private

Definition at line 211 of file constraint_overlay.h.

Referenced by CONSTRAINT_OVERLAY(), render(), and Update().

◆ m_hoverShape

KIID CONSTRAINT_OVERLAY::m_hoverShape = niluuid
private

Definition at line 217 of file constraint_overlay.h.

Referenced by GetHoverShape(), render(), and SetHoverShape().

◆ m_isolated

KIID CONSTRAINT_OVERLAY::m_isolated
private

Definition at line 215 of file constraint_overlay.h.

Referenced by CONSTRAINT_OVERLAY(), GetIsolated(), render(), and SetIsolated().

◆ m_lastDiag

BOARD_CONSTRAINT_DIAGNOSTICS CONSTRAINT_OVERLAY::m_lastDiag
private

Definition at line 212 of file constraint_overlay.h.

Referenced by render(), and Update().

◆ m_mode

OVERLAY_MODE CONSTRAINT_OVERLAY::m_mode = OVERLAY_MODE::ALWAYS
private

Definition at line 216 of file constraint_overlay.h.

Referenced by GetVisibilityMode(), render(), and SetVisibilityMode().

◆ m_overlay

std::shared_ptr<KIGFX::VIEW_OVERLAY> VIEW_OVERLAY_HOLDER::m_overlay
protectedinherited

◆ m_previewAnchor

std::optional<VECTOR2I> CONSTRAINT_OVERLAY::m_previewAnchor
private

Definition at line 224 of file constraint_overlay.h.

Referenced by Clear(), render(), and SetPickPreview().

◆ m_previewElement

KIID CONSTRAINT_OVERLAY::m_previewElement = niluuid
private

Definition at line 222 of file constraint_overlay.h.

Referenced by Clear(), render(), and SetPickPreview().

◆ m_previewWhole

bool CONSTRAINT_OVERLAY::m_previewWhole = true
private

Definition at line 223 of file constraint_overlay.h.

Referenced by render(), and SetPickPreview().

◆ m_selected

KIID CONSTRAINT_OVERLAY::m_selected
private

Definition at line 214 of file constraint_overlay.h.

Referenced by CONSTRAINT_OVERLAY(), GetSelected(), render(), and SetSelected().

◆ m_view


The documentation for this class was generated from the following files: