35std::shared_ptr<EDIT_POINTS> makeTriangle(
EDA_ITEM* aParent,
int aOffset = 0 )
37 std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aParent );
39 points->AddPoint(
VECTOR2I( aOffset, 0 ) );
40 points->AddPoint(
VECTOR2I( aOffset + 1000, 0 ) );
41 points->AddPoint(
VECTOR2I( aOffset + 1000, 1000 ) );
42 points->AddLine( points->Point( 0 ), points->Point( 1 ) );
43 points->AddLine( points->Point( 1 ), points->Point( 2 ) );
68 std::shared_ptr<EDIT_POINTS> zonePoints = makeTriangle( zone );
69 std::shared_ptr<EDIT_POINTS> polyPoints = makeTriangle( poly, 5000 );
71 std::set<PCB_HANDLE_KEY> picked;
76 std::vector<EDIT_POINTS*> collections{ zonePoints.get(), polyPoints.get() };
118 outline.
Append( 100000, 0 );
119 outline.
Append( 100000, 100000 );
120 outline.
Append( 0, 100000 );
122 std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( zone );
126 BOOST_REQUIRE_MESSAGE( points->Line( 0 ).GetDragPolicy() !=
nullptr,
"every edge should come with a drag rule" );
129 std::set<PCB_HANDLE_KEY> picked;
132 std::vector<EDIT_POINTS*> collections{ points.get() };
163 auto run = [&](
const std::vector<VECTOR2I>& aPath )
172 outline.
Append( 100000, 0 );
173 outline.
Append( 100000, 100000 );
174 outline.
Append( 0, 100000 );
176 std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( zone );
179 std::set<PCB_HANDLE_KEY> picked;
182 std::vector<EDIT_POINTS*> collections{ points.get() };
194 std::vector<VECTOR2I>
result;
202 const VECTOR2I target( 7000, 5000 );
204 std::vector<VECTOR2I> direct = run( { target } );
205 std::vector<VECTOR2I> wandered = run( {
VECTOR2I( 30000, -20000 ),
VECTOR2I( -5000, 40000 ), target } );
209 for(
size_t ii = 0; ii < direct.size(); ++ii )
211 BOOST_CHECK_MESSAGE( direct[ii] == wandered[ii],
212 "corner " << ii <<
" landed at " << wandered[ii].x <<
"," << wandered[ii].y
213 <<
" by one path and " << direct[ii].x <<
"," << direct[ii].y <<
" by another" );
226 std::shared_ptr<EDIT_POINTS> points = makeTriangle( zone );
228 std::set<PCB_HANDLE_KEY> picked;
231 std::vector<EDIT_POINTS*> collections{ points.get() };
252 std::shared_ptr<EDIT_POINTS> points = makeTriangle( zone );
255 std::set<PCB_HANDLE_KEY> picked;
259 std::vector<EDIT_POINTS*> collections{ points.get() };
269 for(
const auto& [key, origin] : origins )
270 lineKeys += key.IsLine() ? 1 : 0;
292 std::shared_ptr<EDIT_POINTS> before = makeTriangle( zone );
294 std::set<PCB_HANDLE_KEY> picked;
297 std::vector<EDIT_POINTS*> collections{ before.get() };
303 std::shared_ptr<EDIT_POINTS> after = std::make_shared<EDIT_POINTS>( zone );
304 after->AddPoint(
VECTOR2I( 0, 0 ) );
305 after->AddPoint(
VECTOR2I( 1000, 0 ) );
307 std::vector<EDIT_POINTS*> rebuilt{ after.get() };
bool BlockDragApplyDisplacement(const std::vector< EDIT_POINTS * > &aCollections, const std::map< PCB_HANDLE_KEY, VECTOR2I > &aOrigins, const VECTOR2I &aDelta, const GRID_HELPER &aGrid)
Put every handle at its starting position plus the drag's offset.
std::map< PCB_HANDLE_KEY, VECTOR2I > BlockDragMoveOrigins(const std::vector< EDIT_POINTS * > &aCollections, const std::set< PCB_HANDLE_KEY > &aPicked)
Note every handle the drag will move, and where each one started.
Information pertinent to a Pcbnew printed circuit board.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
A base class for most all the KiCad significant classes used in schematics and boards.
static std::optional< PCB_HANDLE_KEY > Make(const EDIT_POINTS &aPoints, const EDIT_POINT *aPoint)
Build the key for a handle in a collection.
static void UpdateOutlineFromPoints(SHAPE_POLY_SET &aOutline, const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints)
Update the polygon outline with the new positions of the edit points.
static void BuildForPolyOutline(EDIT_POINTS &aPoints, const SHAPE_POLY_SET &aOutline)
Build the edit points for the given polygon outline.
Represent a set of closed polygons.
int TotalVertices() const
Return total number of vertices stored in the set.
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.
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the index-th vertex in a given hole outline within a given outline.
Handle a list of polygons defining a copper zone.
SHAPE_POLY_SET * Outline()
static bool empty(const wxTextEntryBase *aCtrl)
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_CASE(OneDisplacementReachesEveryPickedHandle)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_CHECK(res.column_datatype(0)==SQL_NUMERIC||res.column_datatype(0)==SQL_DECIMAL)
BOOST_REQUIRE_EQUAL(rows.size(), 1)
BOOST_CHECK_EQUAL(std::any_cast< std::string >(rows[0].at("val")), "12345678901234567.89")
BOOST_REQUIRE_MESSAGE(dc.CacheTableInfo(table, { "part_id", "val" }), dc.GetLastError())
BOOST_REQUIRE(res.columns()==1)
BOOST_AUTO_TEST_SUITE_END()
wxString result
Test unit parsing edge cases and error handling.
VECTOR2< int32_t > VECTOR2I