KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_construction_geom.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <boost/test/unit_test.hpp>
21
24
25
26BOOST_AUTO_TEST_SUITE( ConstructionGeom )
27
28
29BOOST_AUTO_TEST_CASE( HorizontalDimensionBracketHasPerpendicularEndTicks )
30{
31 std::array<SEG, 3> segments =
32 KIGFX::CONSTRUCTION_GEOM::DimensionBracketSegments( SEG( { 10, 20 }, { 40, 20 } ), 6 );
33
34 BOOST_CHECK_EQUAL( segments[0].A, VECTOR2I( 10, 20 ) );
35 BOOST_CHECK_EQUAL( segments[0].B, VECTOR2I( 40, 20 ) );
36 BOOST_CHECK_EQUAL( segments[1].A, VECTOR2I( 10, 17 ) );
37 BOOST_CHECK_EQUAL( segments[1].B, VECTOR2I( 10, 23 ) );
38 BOOST_CHECK_EQUAL( segments[2].A, VECTOR2I( 40, 17 ) );
39 BOOST_CHECK_EQUAL( segments[2].B, VECTOR2I( 40, 23 ) );
40}
41
42
43BOOST_AUTO_TEST_CASE( VerticalDimensionBracketHasPerpendicularEndTicks )
44{
45 std::array<SEG, 3> segments =
46 KIGFX::CONSTRUCTION_GEOM::DimensionBracketSegments( SEG( { 10, 20 }, { 10, 50 } ), 6 );
47
48 BOOST_CHECK_EQUAL( segments[0].A, VECTOR2I( 10, 20 ) );
49 BOOST_CHECK_EQUAL( segments[0].B, VECTOR2I( 10, 50 ) );
50 BOOST_CHECK_EQUAL( segments[1].A, VECTOR2I( 7, 20 ) );
51 BOOST_CHECK_EQUAL( segments[1].B, VECTOR2I( 13, 20 ) );
52 BOOST_CHECK_EQUAL( segments[2].A, VECTOR2I( 7, 50 ) );
53 BOOST_CHECK_EQUAL( segments[2].B, VECTOR2I( 13, 50 ) );
54}
55
56
57BOOST_AUTO_TEST_CASE( DimensionBracketOffsetsOutsideObjectEdge )
58{
59 std::array<SEG, 3> segments =
60 KIGFX::CONSTRUCTION_GEOM::DimensionBracketSegments( SEG( { 10, 20 }, { 10, 50 } ), 6, 8 );
61
62 BOOST_CHECK_EQUAL( segments[0].A, VECTOR2I( 18, 20 ) );
63 BOOST_CHECK_EQUAL( segments[0].B, VECTOR2I( 18, 50 ) );
64 BOOST_CHECK_EQUAL( segments[1].A, VECTOR2I( 15, 20 ) );
65 BOOST_CHECK_EQUAL( segments[1].B, VECTOR2I( 21, 20 ) );
66}
67
68
69BOOST_AUTO_TEST_CASE( SnapManagerOwnsDimensionBracketLifecycle )
70{
72 SNAP_MANAGER manager( geometry );
73
74 manager.SetDimensionBrackets( { SEG( { 10, 20 }, { 40, 20 } ), SEG( { 50, 20 }, { 80, 20 } ) } );
75
76 BOOST_REQUIRE_EQUAL( geometry.DimensionBrackets().size(), 2 );
77 manager.Clear();
78 BOOST_CHECK( geometry.DimensionBrackets().empty() );
79}
80
81
Shows construction geometry for things like line extensions, arc centers, etc.
const std::vector< SEG > & DimensionBrackets() const
static std::array< SEG, 3 > DimensionBracketSegments(const SEG &aSpan, int aTickLength, int aOffset=0)
Definition seg.h:38
A SNAP_MANAGER glues together the snap line manager and construction manager., along with some other ...
void SetDimensionBrackets(std::vector< SEG > aBrackets)
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_CASE(HorizontalDimensionBracketHasPerpendicularEndTicks)
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683