7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2024-11-25 19:50:24 +00:00
kicad/qa/tests/libs/kimath/geometry/geom_test_utils.cpp
John Beard b2be0d39bd Snapping: Add construction geometry snapping
This is a pretty major rework of the snapping system.
The GRID_HELPERs now have a separate CONSTRUCTION_MANAGER
which handles some of the state involving "construction
geometry".

This is fed with 'extended' geometry (e.g. "infinite" lines from
segments) for use in generating things like intersection points.
It also handles adding this geoemtry to a GAL view item
(CONSTRUCTION_GEOM) for display to the user.

The process is:

* A TOOL creates a GRID_HELPER
* Optionally, it pre-loads a "persistent" batch of construction
  geometry (e.g. for an item's original position)
* The grid helper finds useful snap 'anchors' as before, including
  those involving the construction items.
* Other items on the board can be 'activated' by snapping to one
  of their main points. Then, if it has construction geometry,
  it will be added to the display. At most 2 items of this kind of
  geometry are shown, plus the original item, to reduce avoid
  too much clutter.

The dashed snap lines state machine is also handled in the
CONSTRUCTION_MANAGER and displayed in the CONSTRUCTION_GEOM item.
2024-09-11 22:35:35 +01:00

38 lines
942 B
C++

#include "geom_test_utils.h"
std::ostream& boost_test_print_type( std::ostream& os, const SHAPE_LINE_CHAIN& c )
{
os << "SHAPE_LINE_CHAIN: " << c.PointCount() << " points: [\n";
for( int i = 0; i < c.PointCount(); ++i )
{
os << " " << i << ": " << c.CPoint( i ) << "\n";
}
os << "]";
return os;
}
std::string toString( const POINT_TYPE& aType )
{
switch( aType )
{
case PT_NONE: return "PT_NONE";
case PT_CENTER: return "PT_CENTER";
case PT_END: return "PT_END";
case PT_MID: return "PT_MID";
case PT_QUADRANT: return "PT_QUADRANT";
case PT_CORNER: return "PT_CORNER";
case PT_INTERSECTION: return "PT_INTERSECTION";
default: return "Unknown POINT_TYPE: " + std::to_string( (int) aType );
}
}
std::ostream& operator<<( std::ostream& os, const TYPED_POINT2I& aPt )
{
os << "TYPED_POINT2I: " << aPt.m_point << " (" << aPt.m_types << ")";
return os;
}