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

One block edit session, holding several anchors and one travel offset at once. More...

#include <board_constraint_adapter.h>

Inheritance diagram for BOARD_CONSTRAINT_BLOCK_SESSION:
BOARD_CONSTRAINT_SESSION

Public Member Functions

bool Build (BOARD *aBoard, const std::vector< BOARD_ITEM * > &aBlockItems)
 Build one adapter over the clusters holding aBlockItems.
 
CONSTRAINT_BLOCK_RESULT Solve (const std::vector< std::pair< CONSTRAINT_MEMBER, VECTOR2I > > &aPinnedAnchors, const std::set< KIID > &aTranslatedShapes, const VECTOR2I &aTranslation, std::vector< PCB_SHAPE * > *aModified, const std::function< void(BOARD_ITEM *)> &aBeforeModify)
 Solve one frame of the block edit and apply it.
 
bool HasBaseConflict () const
 

Protected Member Functions

bool buildCluster (BOARD *aBoard, const std::unordered_set< KIID > &aClusterShapes, const std::vector< PCB_CONSTRAINT * > &aConstraints)
 Assemble the adapter for one cluster and record its baseline.
 
void reset ()
 Drop the built cluster, leaving the session unusable until the next successful build.
 
bool usable () const
 
bool rewind ()
 Rewind to the state the next speculative solve starts from.
 
SNAP_RESULT startResult (const SNAP_SOURCE_CONTEXT &aContext) const
 Seed a snap result at the cursor, rejecting a cluster that was already broken.
 

Static Protected Member Functions

static void accept (SNAP_RESULT &aResult, const SNAP_CANDIDATE &aCandidate, double aResidual)
 Record one candidate the session honoured.
 

Protected Attributes

BOARD * m_board = nullptr
 
std::unique_ptr< BOARD_CONSTRAINT_ADAPTER > m_adapter
 
BOARD_CONSTRAINT_ADAPTER::SNAPSHOT m_baseline
 
bool m_baseConflict = false
 

Detailed Description

One block edit session, holding several anchors and one travel offset at once.

A block drag reshapes some shapes by their picked anchors while carrying others whole, so it needs more than the drag session's single anchor and more than the move session's one rigid step. The session is built once, over every cluster the block touches, and every frame solves from the same starting geometry, so the result depends only on where the drag ends and not on the path the cursor took.

Definition at line 576 of file board_constraint_adapter.h.

Member Function Documentation

◆ accept()

void BOARD_CONSTRAINT_SESSION::accept ( SNAP_RESULT & aResult,
const SNAP_CANDIDATE & aCandidate,
double aResidual )
staticprotectedinherited

Record one candidate the session honoured.

Only the residual and the freedom consumed belong here. SNAP_RESOLVER appends the id and the guides to whatever a feasibility callback returns, so reporting them again would draw every guide twice and enter the id in the sticky set twice.

Definition at line 3294 of file board_constraint_adapter.cpp.

References SNAP_CANDIDATE::consumedDof, SNAP_RESULT::quantizedResiduals, and SNAP_RESULT::remainingDof.

Referenced by BOARD_CONSTRAINT_DRAG_SESSION::ResolveCandidates(), and BOARD_CONSTRAINT_MOVE_SESSION::ResolveCandidates().

◆ Build()

◆ buildCluster()

bool BOARD_CONSTRAINT_SESSION::buildCluster ( BOARD * aBoard,
const std::unordered_set< KIID > & aClusterShapes,
const std::vector< PCB_CONSTRAINT * > & aConstraints )
protectedinherited

Assemble the adapter for one cluster and record its baseline.

Sets the base-conflict flag when the cluster's relations were already unsatisfied, which every solve then refuses rather than trying to repair an edit the user did not make.

Definition at line 3254 of file board_constraint_adapter.cpp.

References m_adapter, m_baseConflict, m_baseline, m_board, reset(), resolveClusterDimensions(), resolveClusterPads(), and resolveClusterShapes().

Referenced by BOARD_CONSTRAINT_BLOCK_SESSION::Build(), BOARD_CONSTRAINT_DRAG_SESSION::Build(), and BOARD_CONSTRAINT_MOVE_SESSION::Build().

◆ HasBaseConflict()

bool BOARD_CONSTRAINT_SESSION::HasBaseConflict ( ) const
inlineinherited

◆ reset()

void BOARD_CONSTRAINT_SESSION::reset ( )
protectedinherited

Drop the built cluster, leaving the session unusable until the next successful build.

Definition at line 3246 of file board_constraint_adapter.cpp.

References m_adapter, m_baseConflict, and m_baseline.

Referenced by BOARD_CONSTRAINT_BLOCK_SESSION::Build(), BOARD_CONSTRAINT_DRAG_SESSION::Build(), BOARD_CONSTRAINT_MOVE_SESSION::Build(), and buildCluster().

◆ rewind()

◆ Solve()

CONSTRAINT_BLOCK_RESULT BOARD_CONSTRAINT_BLOCK_SESSION::Solve ( const std::vector< std::pair< CONSTRAINT_MEMBER, VECTOR2I > > & aPinnedAnchors,
const std::set< KIID > & aTranslatedShapes,
const VECTOR2I & aTranslation,
std::vector< PCB_SHAPE * > * aModified,
const std::function< void(BOARD_ITEM *)> & aBeforeModify )

Solve one frame of the block edit and apply it.

Parameters
aPinnedAnchorsthe frame's anchors with their targets in IU.
aTranslatedShapesshapes the frame carried whole.
aTranslationhow far they travelled from the starting geometry.
[out]aModifiedthe shapes the solve moved, for the caller to stage and redraw.
aBeforeModifycalled with each item just before it is written, for the undo commit.
Returns
SOLVED after the geometry was written, REFUSED when an anchor could not be placed and the geometry is untouched, and NOT_MODELED when there was nothing to solve.

Definition at line 3494 of file board_constraint_adapter.cpp.

References BOARD_CONSTRAINT_SESSION::m_adapter, NOT_MODELED, result, BOARD_CONSTRAINT_SESSION::rewind(), SOLVED, and BOARD_CONSTRAINT_SESSION::usable().

Referenced by BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), and BOOST_FIXTURE_TEST_CASE().

◆ startResult()

SNAP_RESULT BOARD_CONSTRAINT_SESSION::startResult ( const SNAP_SOURCE_CONTEXT & aContext) const
protectedinherited

Seed a snap result at the cursor, rejecting a cluster that was already broken.

Definition at line 3280 of file board_constraint_adapter.cpp.

References BASE_CONFLICT, INCOMPATIBLE, m_adapter, m_baseConflict, result, and SNAP_SOURCE_CONTEXT::sourcePoint.

Referenced by BOARD_CONSTRAINT_DRAG_SESSION::ResolveCandidates(), and BOARD_CONSTRAINT_MOVE_SESSION::ResolveCandidates().

◆ usable()

bool BOARD_CONSTRAINT_SESSION::usable ( ) const
inlineprotectedinherited

Member Data Documentation

◆ m_adapter

◆ m_baseConflict

bool BOARD_CONSTRAINT_SESSION::m_baseConflict = false
protectedinherited

◆ m_baseline

BOARD_CONSTRAINT_ADAPTER::SNAPSHOT BOARD_CONSTRAINT_SESSION::m_baseline
protectedinherited

◆ m_board

BOARD* BOARD_CONSTRAINT_SESSION::m_board = nullptr
protectedinherited

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