KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_line.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 (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <base_units.h>
26#include <bitmaps.h>
27#include <string_utils.h>
28#include <core/mirror.h>
29#include <sch_painter.h>
30#include <sch_plotter.h>
32#include <sch_line.h>
33#include <sch_edit_frame.h>
35#include <connection_graph.h>
38#include <trigo.h>
39#include <board_item.h>
40#include <api/api_enums.h>
41#include <api/api_utils.h>
42#include <api/schematic/schematic_types.pb.h>
43
44
45SCH_LINE::SCH_LINE( const VECTOR2I& pos, int layer ) :
46 SCH_ITEM( nullptr, SCH_LINE_T )
47{
48 m_start = pos;
49 m_end = pos;
50 m_stroke.SetWidth( 0 );
51 m_stroke.SetLineStyle( LINE_STYLE::DEFAULT );
52 m_stroke.SetColor( COLOR4D::UNSPECIFIED );
53
54 switch( layer )
55 {
56 default: m_layer = LAYER_NOTES; break;
57 case LAYER_WIRE: m_layer = LAYER_WIRE; break;
58 case LAYER_BUS: m_layer = LAYER_BUS; break;
59 }
60
61 if( layer == LAYER_NOTES )
63 else
65
66 if( layer == LAYER_WIRE )
68 else if( layer == LAYER_BUS )
70 else
72
73 m_lastResolvedLineStyle = LINE_STYLE::SOLID;
74 m_lastResolvedColor = COLOR4D::UNSPECIFIED;
75}
76
77
79 SCH_ITEM( aLine )
80{
81 m_start = aLine.m_start;
82 m_end = aLine.m_end;
83 m_stroke = aLine.m_stroke;
86
90
92}
93
94
95void SCH_LINE::Serialize( google::protobuf::Any &aContainer ) const
96{
97 kiapi::schematic::types::Line line;
98
99 line.mutable_id()->set_value( m_Uuid.AsStdString() );
100 kiapi::common::PackVector2( *line.mutable_start(), GetStartPoint() );
101 kiapi::common::PackVector2( *line.mutable_end(), GetEndPoint() );
102 line.set_layer(
103 ToProtoEnum<SCH_LAYER_ID, kiapi::schematic::types::SchematicLayer>( GetLayer() ) );
104
105 aContainer.PackFrom( line );
106}
107
108
109bool SCH_LINE::Deserialize( const google::protobuf::Any &aContainer )
110{
111 kiapi::schematic::types::Line line;
112
113 if( !aContainer.UnpackTo( &line ) )
114 return false;
115
116 const_cast<KIID&>( m_Uuid ) = KIID( line.id().value() );
119 SCH_LAYER_ID layer =
120 FromProtoEnum<SCH_LAYER_ID, kiapi::schematic::types::SchematicLayer>( line.layer() );
121
122 switch( layer )
123 {
124 case LAYER_WIRE:
125 case LAYER_BUS:
126 case LAYER_NOTES:
127 SetLayer( layer );
128 break;
129
130 default:
131 break;
132 }
133
134 return true;
135}
136
137
139{
140 switch( GetLayer() )
141 {
142 case LAYER_WIRE: return _( "Wire" );
143 case LAYER_BUS: return _( "Bus" );
144 default: return _( "Graphic Line" );
145 }
146}
147
148
150{
151 return new SCH_LINE( *this );
152}
153
154
155void SCH_LINE::Move( const VECTOR2I& aOffset )
156{
157 m_start += aOffset;
158 m_end += aOffset;
159}
160
161
162void SCH_LINE::MoveStart( const VECTOR2I& aOffset )
163{
164 m_start += aOffset;
165}
166
167
168void SCH_LINE::MoveEnd( const VECTOR2I& aOffset )
169{
170 m_end += aOffset;
171}
172
173
174#if defined(DEBUG)
175
176void SCH_LINE::Show( int nestLevel, std::ostream& os ) const
177{
178 NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
179 << " layer=\"" << m_layer << '"'
180 << " startIsDangling=\"" << m_startIsDangling
181 << '"' << " endIsDangling=\""
182 << m_endIsDangling << '"' << ">"
183 << " <start" << m_start << "/>"
184 << " <end" << m_end << "/>" << "</"
185 << GetClass().Lower().mb_str() << ">\n";
186}
187
188#endif
189
190
191std::vector<int> SCH_LINE::ViewGetLayers() const
192{
195}
196
197
198double SCH_LINE::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
199{
200 constexpr double HIDE = std::numeric_limits<double>::max();
201 constexpr double SHOW = 0.0;
202
203 if( aLayer == LAYER_OP_VOLTAGES )
204 {
205 if( m_start == m_end )
206 return HIDE;
207
208 int height = std::abs( m_end.y - m_start.y );
209 int width = std::abs( m_end.x - m_start.x );
210
211 // Operating points will be shown only if zoom is appropriate
212 if( height == 0 )
213 return (double) schIUScale.mmToIU( 15 ) / width;
214 else
215 return (double) schIUScale.mmToIU( 5 ) / height;
216 }
217
218 // Other layers are always drawn.
219 return SHOW;
220}
221
222
224{
225 int width = GetPenWidth() / 2;
226
227 int xmin = std::min( m_start.x, m_end.x ) - width;
228 int ymin = std::min( m_start.y, m_end.y ) - width;
229
230 int xmax = std::max( m_start.x, m_end.x ) + width + 1;
231 int ymax = std::max( m_start.y, m_end.y ) + width + 1;
232
233 BOX2I ret( VECTOR2I( xmin, ymin ), VECTOR2I( xmax - xmin, ymax - ymin ) );
234
235 return ret;
236}
237
238
240{
241 return m_start.Distance( m_end );
242}
243
244
245void SCH_LINE::SetLineColor( const COLOR4D& aColor )
246{
247 m_stroke.SetColor( aColor );
249}
250
251
252void SCH_LINE::SetLineColor( const double r, const double g, const double b, const double a )
253{
254 COLOR4D newColor(r, g, b, a);
255
256 if( newColor == COLOR4D::UNSPECIFIED )
257 {
258 m_stroke.SetColor( COLOR4D::UNSPECIFIED );
259 }
260 else
261 {
262 // Eeschema does not allow alpha channel in colors
263 newColor.a = 1.0;
264 m_stroke.SetColor( newColor );
265 }
266}
267
268
270{
271 if( m_stroke.GetColor() != COLOR4D::UNSPECIFIED )
273 else if( !IsConnectable() )
274 m_lastResolvedColor = COLOR4D::UNSPECIFIED;
275 else if( !IsConnectivityDirty() )
276 m_lastResolvedColor = GetEffectiveNetClass()->GetSchematicColor();
277
278 return m_lastResolvedColor;
279}
280
281
282void SCH_LINE::SetLineStyle( const int aStyleId )
283{
284 SetLineStyle( static_cast<LINE_STYLE>( aStyleId ) );
285}
286
287
289{
290 m_stroke.SetLineStyle( aStyle );
292}
293
294
296{
297 if( m_stroke.GetLineStyle() != LINE_STYLE::DEFAULT )
298 return m_stroke.GetLineStyle();
299
300 return LINE_STYLE::SOLID;
301}
302
303
305{
306 if( m_stroke.GetLineStyle() != LINE_STYLE::DEFAULT )
308 else if( !IsConnectable() )
309 m_lastResolvedLineStyle = LINE_STYLE::SOLID;
310 else if( !IsConnectivityDirty() )
312
314}
315
316
317void SCH_LINE::SetLineWidth( const int aSize )
318{
319 m_stroke.SetWidth( aSize );
321}
322
323
325{
326 SCHEMATIC* schematic = Schematic();
327
328 switch ( m_layer )
329 {
330 default:
331 if( m_stroke.GetWidth() > 0 )
332 return m_stroke.GetWidth();
333
334 if( schematic )
335 return schematic->Settings().m_DefaultLineWidth;
336
338
339 case LAYER_WIRE:
340 if( m_stroke.GetWidth() > 0 )
342 else if( !IsConnectivityDirty() )
343 m_lastResolvedWidth = GetEffectiveNetClass()->GetWireWidth();
344
345 return m_lastResolvedWidth;
346
347 case LAYER_BUS:
348 if( m_stroke.GetWidth() > 0 )
350 else if( !IsConnectivityDirty() )
351 m_lastResolvedWidth = GetEffectiveNetClass()->GetBusWidth();
352
353 return m_lastResolvedWidth;
354 }
355}
356
357
358void SCH_LINE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
359 const VECTOR2I& offset, bool aForceNoFill, bool aDimmed )
360{
361 wxDC* DC = aSettings->GetPrintDC();
363
364 if( color == COLOR4D::UNSPECIFIED )
365 color = aSettings->GetLayerColor( GetLayer() );
366
367 VECTOR2I start = m_start;
368 VECTOR2I end = m_end;
369 LINE_STYLE lineStyle = GetEffectiveLineStyle();
370 int penWidth = GetEffectivePenWidth( aSettings );
371
372 if( lineStyle <= LINE_STYLE::FIRST_TYPE )
373 {
374 GRLine( DC, start.x, start.y, end.x, end.y, penWidth, color );
375 }
376 else
377 {
378 SHAPE_SEGMENT segment( start, end );
379
380 STROKE_PARAMS::Stroke( &segment, lineStyle, penWidth, aSettings,
381 [&]( const VECTOR2I& a, const VECTOR2I& b )
382 {
383 GRLine( DC, a.x, a.y, b.x, b.y, penWidth, color );
384 } );
385 }
386}
387
388
389void SCH_LINE::MirrorVertically( int aCenter )
390{
391 if( m_flags & STARTPOINT )
392 MIRROR( m_start.y, aCenter );
393
394 if( m_flags & ENDPOINT )
395 MIRROR( m_end.y, aCenter );
396}
397
398
400{
401 if( m_flags & STARTPOINT )
402 MIRROR( m_start.x, aCenter );
403
404 if( m_flags & ENDPOINT )
405 MIRROR( m_end.x, aCenter );
406}
407
408
409void SCH_LINE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
410{
411 if( m_flags & STARTPOINT )
412 RotatePoint( m_start, aCenter, aRotateCCW ? ANGLE_90 : ANGLE_270 );
413
414 if( m_flags & ENDPOINT )
415 RotatePoint( m_end, aCenter, aRotateCCW ? ANGLE_90 : ANGLE_270 );
416}
417
418
419int SCH_LINE::GetAngleFrom( const VECTOR2I& aPoint ) const
420{
421 VECTOR2I vec;
422
423 if( aPoint == m_start )
424 vec = m_end - aPoint;
425 else
426 vec = m_start - aPoint;
427
428 return KiROUND( EDA_ANGLE( vec ).AsDegrees() );
429}
430
431
432int SCH_LINE::GetReverseAngleFrom( const VECTOR2I& aPoint ) const
433{
434 VECTOR2I vec;
435
436 if( aPoint == m_end )
437 vec = m_start - aPoint;
438 else
439 vec = m_end - aPoint;
440
441 return KiROUND( EDA_ANGLE( vec ).AsDegrees() );
442}
443
444
445bool SCH_LINE::IsParallel( const SCH_LINE* aLine ) const
446{
447 wxCHECK_MSG( aLine != nullptr && aLine->Type() == SCH_LINE_T, false,
448 wxT( "Cannot test line segment for overlap." ) );
449
450 VECTOR2I firstSeg = m_end - m_start;
451 VECTOR2I secondSeg = aLine->m_end - aLine->m_start;
452
453 // Use long long here to avoid overflow in calculations
454 return !( (long long) firstSeg.x * secondSeg.y - (long long) firstSeg.y * secondSeg.x );
455}
456
457
458SCH_LINE* SCH_LINE::MergeOverlap( SCH_SCREEN* aScreen, SCH_LINE* aLine, bool aCheckJunctions )
459{
460 auto less =
461 []( const VECTOR2I& lhs, const VECTOR2I& rhs ) -> bool
462 {
463 if( lhs.x == rhs.x )
464 return lhs.y < rhs.y;
465
466 return lhs.x < rhs.x;
467 };
468
469 wxCHECK_MSG( aLine != nullptr && aLine->Type() == SCH_LINE_T, nullptr,
470 wxT( "Cannot test line segment for overlap." ) );
471
472 if( this == aLine || GetLayer() != aLine->GetLayer() )
473 return nullptr;
474
475 VECTOR2I leftmost_start = aLine->m_start;
476 VECTOR2I leftmost_end = aLine->m_end;
477
478 VECTOR2I rightmost_start = m_start;
479 VECTOR2I rightmost_end = m_end;
480
481 // We place the start to the left and below the end of both lines
482 if( leftmost_start != std::min( { leftmost_start, leftmost_end }, less ) )
483 std::swap( leftmost_start, leftmost_end );
484 if( rightmost_start != std::min( { rightmost_start, rightmost_end }, less ) )
485 std::swap( rightmost_start, rightmost_end );
486
487 // - leftmost is the line that starts farthest to the left
488 // - other is the line that is _not_ leftmost
489 // - rightmost is the line that ends farthest to the right. This may or may not be 'other'
490 // as the second line may be completely covered by the first.
491 if( less( rightmost_start, leftmost_start ) )
492 {
493 std::swap( leftmost_start, rightmost_start );
494 std::swap( leftmost_end, rightmost_end );
495 }
496
497 VECTOR2I other_start = rightmost_start;
498 VECTOR2I other_end = rightmost_end;
499
500 if( less( rightmost_end, leftmost_end ) )
501 {
502 rightmost_start = leftmost_start;
503 rightmost_end = leftmost_end;
504 }
505
506 // If we end one before the beginning of the other, no overlap is possible
507 if( less( leftmost_end, other_start ) )
508 {
509 return nullptr;
510 }
511
512 // Search for a common end:
513 if( ( leftmost_start == other_start ) && ( leftmost_end == other_end ) ) // Trivial case
514 {
515 SCH_LINE* ret = new SCH_LINE( *aLine );
516 ret->SetStartPoint( leftmost_start );
517 ret->SetEndPoint( leftmost_end );
518 ret->SetConnectivityDirty( true );
519
520 if( IsSelected() || aLine->IsSelected() )
521 ret->SetSelected();
522
523 return ret;
524 }
525
526 bool colinear = false;
527
528 /* Test alignment: */
529 if( ( leftmost_start.y == leftmost_end.y ) &&
530 ( other_start.y == other_end.y ) ) // Horizontal segment
531 {
532 colinear = ( leftmost_start.y == other_start.y );
533 }
534 else if( ( leftmost_start.x == leftmost_end.x ) &&
535 ( other_start.x == other_end.x ) ) // Vertical segment
536 {
537 colinear = ( leftmost_start.x == other_start.x );
538 }
539 else
540 {
541 // We use long long here to avoid overflow -- it enforces promotion
542 // The slope of the left-most line is dy/dx. Then we check that the slope from the
543 // left most start to the right most start is the same as well as the slope from the
544 // left most start to right most end.
545 long long dx = leftmost_end.x - leftmost_start.x;
546 long long dy = leftmost_end.y - leftmost_start.y;
547 colinear = ( ( ( other_start.y - leftmost_start.y ) * dx ==
548 ( other_start.x - leftmost_start.x ) * dy ) &&
549 ( ( other_end.y - leftmost_start.y ) * dx ==
550 ( other_end.x - leftmost_start.x ) * dy ) );
551 }
552
553 if( !colinear )
554 return nullptr;
555
556 // We either have a true overlap or colinear touching segments. We always want to merge
557 // the former, but the later only get merged if there no junction at the touch point.
558
559 bool touching = leftmost_end == rightmost_start;
560
561 if( touching && aCheckJunctions && aScreen->IsJunction( leftmost_end ) )
562 return nullptr;
563
564 // Make a new segment that merges the 2 segments
565 leftmost_end = rightmost_end;
566
567 SCH_LINE* ret = new SCH_LINE( *aLine );
568 ret->SetStartPoint( leftmost_start );
569 ret->SetEndPoint( leftmost_end );
570 ret->SetConnectivityDirty( true );
571
572 if( IsSelected() || aLine->IsSelected() )
573 ret->SetSelected();
574
575 return ret;
576}
577
578
580{
581 SCH_LINE* newSegment = static_cast<SCH_LINE*>( Duplicate() );
582
583 newSegment->SetStartPoint( aPoint );
584 newSegment->SetConnectivityDirty( true );
585 SetEndPoint( aPoint );
586
587 return newSegment;
588}
589
590
591void SCH_LINE::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
592{
593 if( IsConnectable() )
594 {
595 aItemList.emplace_back( IsBus() ? BUS_END : WIRE_END, this, m_start );
596 aItemList.emplace_back( IsBus() ? BUS_END : WIRE_END, this, m_end );
597 }
598}
599
600
601bool SCH_LINE::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListByType,
602 std::vector<DANGLING_END_ITEM>& aItemListByPos,
603 const SCH_SHEET_PATH* aPath )
604{
605 if( !IsConnectable() )
606 return false;
607
608 bool previousStartState = m_startIsDangling;
609 bool previousEndState = m_endIsDangling;
610
612
613 for( auto it = DANGLING_END_ITEM_HELPER::get_lower_pos( aItemListByPos, m_start );
614 it < aItemListByPos.end() && it->GetPosition() == m_start; it++ )
615 {
616 DANGLING_END_ITEM& item = *it;
617
618 if( item.GetItem() == this )
619 continue;
620
621 if( ( IsWire() && item.GetType() != BUS_END && item.GetType() != BUS_ENTRY_END )
622 || ( IsBus() && item.GetType() != WIRE_END && item.GetType() != PIN_END ) )
623 {
624 m_startIsDangling = false;
625 break;
626 }
627 }
628
629 for( auto it = DANGLING_END_ITEM_HELPER::get_lower_pos( aItemListByPos, m_end );
630 it < aItemListByPos.end() && it->GetPosition() == m_end; it++ )
631 {
632 DANGLING_END_ITEM& item = *it;
633
634 if( item.GetItem() == this )
635 continue;
636
637 if( ( IsWire() && item.GetType() != BUS_END && item.GetType() != BUS_ENTRY_END )
638 || ( IsBus() && item.GetType() != WIRE_END && item.GetType() != PIN_END ) )
639 {
640 m_endIsDangling = false;
641 break;
642 }
643 }
644
645 // We only use the bus dangling state for automatic line starting, so we don't care if it
646 // has changed or not (and returning true will result in extra work)
647 if( IsBus() )
648 return false;
649
650 return previousStartState != m_startIsDangling || previousEndState != m_endIsDangling;
651}
652
653
655{
656 if( m_layer == LAYER_WIRE || m_layer == LAYER_BUS )
657 return true;
658
659 return false;
660}
661
662
663bool SCH_LINE::CanConnect( const SCH_ITEM* aItem ) const
664{
665 switch( aItem->Type() )
666 {
667 case SCH_NO_CONNECT_T:
668 case SCH_SYMBOL_T:
669 return IsWire();
670
671 case SCH_JUNCTION_T:
672 case SCH_LABEL_T:
674 case SCH_HIER_LABEL_T:
677 case SCH_SHEET_T:
678 case SCH_SHEET_PIN_T:
679 return IsWire() || IsBus();
680
681 default:
682 return m_layer == aItem->GetLayer();
683 }
684}
685
686
688 const SCH_SHEET_PATH* aInstance ) const
689{
690 // Do not compare to ourself.
691 if( aItem == this || !IsConnectable() )
692 return false;
693
694 const SCH_LINE* line = dynamic_cast<const SCH_LINE*>( aItem );
695
696 // Don't compare against a different SCH_ITEM.
697 wxCHECK( line, false );
698
699 if( GetStartPoint() != line->GetStartPoint() )
700 return true;
701
702 return GetEndPoint() != line->GetEndPoint();
703}
704
705
706std::vector<VECTOR2I> SCH_LINE::GetConnectionPoints() const
707{
708 return { m_start, m_end };
709}
710
711
713{
714 switch( aItem->Type() )
715 {
716 case SCH_LINE_T:
717 return IsBus() == static_cast<const SCH_LINE*>( aItem )->IsBus();
718
719 default:
720 return true;
721 }
722}
723
724
725void SCH_LINE::GetSelectedPoints( std::vector<VECTOR2I>& aPoints ) const
726{
727 if( m_flags & STARTPOINT )
728 aPoints.push_back( m_start );
729
730 if( m_flags & ENDPOINT )
731 aPoints.push_back( m_end );
732}
733
734
735wxString SCH_LINE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
736{
737 wxString txtfmt;
738
739 if( m_start.x == m_end.x )
740 {
741 switch( m_layer )
742 {
743 case LAYER_WIRE: txtfmt = _( "Vertical Wire, length %s" ); break;
744 case LAYER_BUS: txtfmt = _( "Vertical Bus, length %s" ); break;
745 default: txtfmt = _( "Vertical Graphic Line, length %s" ); break;
746 }
747 }
748 else if( m_start.y == m_end.y )
749 {
750 switch( m_layer )
751 {
752 case LAYER_WIRE: txtfmt = _( "Horizontal Wire, length %s" ); break;
753 case LAYER_BUS: txtfmt = _( "Horizontal Bus, length %s" ); break;
754 default: txtfmt = _( "Horizontal Graphic Line, length %s" ); break;
755 }
756 }
757 else
758 {
759 switch( m_layer )
760 {
761 case LAYER_WIRE: txtfmt = _( "Wire, length %s" ); break;
762 case LAYER_BUS: txtfmt = _( "Bus, length %s" ); break;
763 default: txtfmt = _( "Graphic Line, length %s" ); break;
764 }
765 }
766
767 return wxString::Format( txtfmt,
768 aUnitsProvider->MessageTextFromValue( m_start.Distance( m_end ) ) );
769}
770
771
773{
774 if( m_layer == LAYER_NOTES )
775 return BITMAPS::add_dashed_line;
776 else if( m_layer == LAYER_WIRE )
777 return BITMAPS::add_line;
778
779 return BITMAPS::add_bus;
780}
781
782
783bool SCH_LINE::operator <( const SCH_ITEM& aItem ) const
784{
785 if( Type() != aItem.Type() )
786 return Type() < aItem.Type();
787
788 const SCH_LINE* line = static_cast<const SCH_LINE*>( &aItem );
789
790 if( GetLayer() != line->GetLayer() )
791 return GetLayer() < line->GetLayer();
792
793 if( GetStartPoint().x != line->GetStartPoint().x )
794 return GetStartPoint().x < line->GetStartPoint().x;
795
796 if( GetStartPoint().y != line->GetStartPoint().y )
797 return GetStartPoint().y < line->GetStartPoint().y;
798
799 if( GetEndPoint().x != line->GetEndPoint().x )
800 return GetEndPoint().x < line->GetEndPoint().x;
801
802 return GetEndPoint().y < line->GetEndPoint().y;
803}
804
805
806bool SCH_LINE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
807{
808 // Performance enhancement for connection-building
809 if( aPosition == m_start || aPosition == m_end )
810 return true;
811
812 if( aAccuracy >= 0 )
813 aAccuracy += GetPenWidth() / 2;
814 else
815 aAccuracy = abs( aAccuracy );
816
817 return TestSegmentHit( aPosition, m_start, m_end, aAccuracy );
818}
819
820
821bool SCH_LINE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
822{
824 return false;
825
826 BOX2I rect = aRect;
827
828 if ( aAccuracy )
829 rect.Inflate( aAccuracy );
830
831 if( aContained )
832 return rect.Contains( m_start ) && rect.Contains( m_end );
833
834 return rect.Intersects( m_start, m_end );
835}
836
837
839{
840 SCH_ITEM::SwapFlags( aItem );
841
842 SCH_LINE* item = (SCH_LINE*) aItem;
843
844 std::swap( m_layer, item->m_layer );
845
846 std::swap( m_start, item->m_start );
847 std::swap( m_end, item->m_end );
848 std::swap( m_startIsDangling, item->m_startIsDangling );
849 std::swap( m_endIsDangling, item->m_endIsDangling );
850 std::swap( m_stroke, item->m_stroke );
851}
852
853
854bool SCH_LINE::doIsConnected( const VECTOR2I& aPosition ) const
855{
856 if( m_layer != LAYER_WIRE && m_layer != LAYER_BUS )
857 return false;
858
859 return IsEndPoint( aPosition );
860}
861
862
863void SCH_LINE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
864 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
865{
866 if( aBackground )
867 return;
868
869 SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
870 int penWidth = GetEffectivePenWidth( renderSettings );
872
873 if( color == COLOR4D::UNSPECIFIED )
874 color = renderSettings->GetLayerColor( GetLayer() );
875
876 aPlotter->SetColor( color );
877
878 aPlotter->SetCurrentLineWidth( penWidth );
879 aPlotter->SetDash( penWidth, GetEffectiveLineStyle() );
880
881 aPlotter->MoveTo( m_start );
882 aPlotter->FinishTo( m_end );
883
884 aPlotter->SetDash( penWidth, LINE_STYLE::SOLID );
885
886 // Plot attributes to a hypertext menu
887 std::vector<wxString> properties;
888 BOX2I bbox = GetBoundingBox();
889 bbox.Inflate( penWidth * 3 );
890
891 if( aPlotOpts.m_PDFPropertyPopups )
892 {
893 if( GetLayer() == LAYER_WIRE )
894 {
895 if( SCH_CONNECTION* connection = Connection() )
896 {
897 properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
898 _( "Net" ),
899 connection->Name() ) );
900
901 properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
902 _( "Resolved netclass" ),
903 GetEffectiveNetClass()->GetName() ) );
904 }
905 }
906 else if( GetLayer() == LAYER_BUS )
907 {
908 if( SCH_CONNECTION* connection = Connection() )
909 {
910 for( const std::shared_ptr<SCH_CONNECTION>& member : connection->Members() )
911 properties.emplace_back( wxT( "!" ) + member->Name() );
912 }
913
914 }
915
916 if( !properties.empty() )
917 aPlotter->HyperlinkMenu( bbox, properties );
918 }
919}
920
921
922void SCH_LINE::SetPosition( const VECTOR2I& aPosition )
923{
924 m_end = m_end - ( m_start - aPosition );
925 m_start = aPosition;
926}
927
928
929void SCH_LINE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
930{
931 wxString msg;
932
933 switch( GetLayer() )
934 {
935 case LAYER_WIRE: msg = _( "Wire" ); break;
936 case LAYER_BUS: msg = _( "Bus" ); break;
937 default: msg = _( "Graphical" ); break;
938 }
939
940 aList.emplace_back( _( "Line Type" ), msg );
941
942 LINE_STYLE lineStyle = GetLineStyle();
943
944 if( GetEffectiveLineStyle() != lineStyle )
945 aList.emplace_back( _( "Line Style" ), _( "from netclass" ) );
946 else
947 m_stroke.GetMsgPanelInfo( aFrame, aList, true, false );
948
949 SCH_CONNECTION* conn = nullptr;
950
951 if( !IsConnectivityDirty() && dynamic_cast<SCH_EDIT_FRAME*>( aFrame ) )
952 conn = Connection();
953
954 if( conn )
955 {
956 conn->AppendInfoToMsgPanel( aList );
957
958 if( !conn->IsBus() )
959 {
960 aList.emplace_back( _( "Resolved Netclass" ),
961 UnescapeString( GetEffectiveNetClass()->GetName() ) );
962 }
963 }
964}
965
966
968{
969 return ( GetLayer() == LAYER_NOTES );
970}
971
972
974{
975 return ( GetLayer() == LAYER_WIRE );
976}
977
978
979bool SCH_LINE::IsBus() const
980{
981 return ( GetLayer() == LAYER_BUS );
982}
983
984
985bool SCH_LINE::operator==( const SCH_ITEM& aOther ) const
986{
987 if( Type() != aOther.Type() )
988 return false;
989
990 const SCH_LINE& other = static_cast<const SCH_LINE&>( aOther );
991
992 if( GetLayer() != other.GetLayer() )
993 return false;
994
995 if( m_start != other.m_start )
996 return false;
997
998 if( m_end != other.m_end )
999 return false;
1000
1001 if( m_stroke.GetWidth() != other.m_stroke.GetWidth() )
1002 return false;
1003
1004 if( m_stroke.GetColor() != other.m_stroke.GetColor() )
1005 return false;
1006
1007 if( m_stroke.GetLineStyle() != other.m_stroke.GetLineStyle() )
1008 return false;
1009
1010 return true;
1011}
1012
1013
1014double SCH_LINE::Similarity( const SCH_ITEM& aOther ) const
1015{
1016 if( m_Uuid == aOther.m_Uuid )
1017 return 1.0;
1018
1019 if( Type() != aOther.Type() )
1020 return 0.0;
1021
1022 const SCH_LINE& other = static_cast<const SCH_LINE&>( aOther );
1023
1024 if( GetLayer() != other.GetLayer() )
1025 return 0.0;
1026
1027 double similarity = 1.0;
1028
1029 if( m_start != other.m_start )
1030 similarity *= 0.9;
1031
1032 if( m_end != other.m_end )
1033 similarity *= 0.9;
1034
1035 if( m_stroke.GetWidth() != other.m_stroke.GetWidth() )
1036 similarity *= 0.9;
1037
1038 if( m_stroke.GetColor() != other.m_stroke.GetColor() )
1039 similarity *= 0.9;
1040
1041 if( m_stroke.GetLineStyle() != other.m_stroke.GetLineStyle() )
1042 similarity *= 0.9;
1043
1044 return similarity;
1045}
1046
1047
1048static struct SCH_LINE_DESC
1049{
1051 {
1053
1054 if( plotDashTypeEnum.Choices().GetCount() == 0 )
1055 {
1056 plotDashTypeEnum.Map( LINE_STYLE::DEFAULT, _HKI( "Default" ) )
1057 .Map( LINE_STYLE::SOLID, _HKI( "Solid" ) )
1058 .Map( LINE_STYLE::DASH, _HKI( "Dashed" ) )
1059 .Map( LINE_STYLE::DOT, _HKI( "Dotted" ) )
1060 .Map( LINE_STYLE::DASHDOT, _HKI( "Dash-Dot" ) )
1061 .Map( LINE_STYLE::DASHDOTDOT, _HKI( "Dash-Dot-Dot" ) );
1062 }
1063
1067
1068 void ( SCH_LINE::*lineStyleSetter )( LINE_STYLE ) = &SCH_LINE::SetLineStyle;
1069
1070 propMgr.AddProperty( new PROPERTY_ENUM<SCH_LINE, LINE_STYLE>( _HKI( "Line Style" ),
1071 lineStyleSetter, &SCH_LINE::GetLineStyle ) );
1072
1073 propMgr.AddProperty( new PROPERTY<SCH_LINE, int>( _HKI( "Line Width" ),
1074 &SCH_LINE::SetLineWidth, &SCH_LINE::GetLineWidth, PROPERTY_DISPLAY::PT_SIZE ) );
1075
1076 propMgr.AddProperty( new PROPERTY<SCH_LINE, COLOR4D>( _HKI( "Color" ),
1078 }
int color
Definition: DXF_plotter.cpp:58
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:110
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition: box2.h:990
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:558
constexpr bool Contains(const Vec &aPoint) const
Definition: box2.h:168
constexpr bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:311
static std::vector< DANGLING_END_ITEM >::iterator get_lower_pos(std::vector< DANGLING_END_ITEM > &aItemListByPos, const VECTOR2I &aPos)
Definition: sch_item.cpp:592
Helper class used to store the state of schematic items that can be connected to other schematic item...
Definition: sch_item.h:95
DANGLING_END_T GetType() const
Definition: sch_item.h:131
EDA_ITEM * GetItem() const
Definition: sch_item.h:129
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
const KIID m_Uuid
Definition: eda_item.h:489
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:499
bool IsSelected() const
Definition: eda_item.h:110
void SetSelected()
Definition: eda_item.h:119
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition: property.h:669
static ENUM_MAP< T > & Instance()
Definition: property.h:663
wxPGChoices & Choices()
Definition: property.h:712
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
double a
Alpha component.
Definition: color4d.h:395
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
wxDC * GetPrintDC() const
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
Definition: kiid.h:49
std::string AsStdString() const
Definition: kiid.cpp:244
Base plotter engine class.
Definition: plotter.h:105
void MoveTo(const VECTOR2I &pos)
Definition: plotter.h:244
virtual void SetDash(int aLineWidth, LINE_STYLE aLineStyle)=0
void FinishTo(const VECTOR2I &pos)
Definition: plotter.h:254
virtual void SetCurrentLineWidth(int width, void *aData=nullptr)=0
Set the line width for the next drawing.
virtual void HyperlinkMenu(const BOX2I &aBox, const std::vector< wxString > &aDestURLs)
Create a clickable hyperlink menu with a rectangular click area.
Definition: plotter.h:465
virtual void SetColor(const COLOR4D &color)=0
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:85
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:87
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
Holds all the data relating to one schematic.
Definition: schematic.h:77
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:312
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
bool IsBus() const
void AppendInfoToMsgPanel(std::vector< MSG_PANEL_ITEM > &aList) const
Adds information about the connection object to aList.
Schematic editor (Eeschema) main window.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:166
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
Definition: sch_item.h:670
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:150
std::shared_ptr< NETCLASS > GetEffectiveNetClass(const SCH_SHEET_PATH *aSheet=nullptr) const
Definition: sch_item.cpp:247
void SetLayer(SCH_LAYER_ID aLayer)
Definition: sch_item.h:282
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:281
void SetConnectivityDirty(bool aDirty=true)
Definition: sch_item.h:512
bool IsConnectivityDirty() const
Definition: sch_item.h:510
void SwapFlags(SCH_ITEM *aItem)
Swap the non-temp and non-edit flags.
Definition: sch_item.cpp:351
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:218
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
Definition: sch_item.cpp:473
SCH_LAYER_ID m_layer
Definition: sch_item.h:723
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
Definition: sch_item.cpp:131
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:41
int GetPenWidth() const override
Definition: sch_line.cpp:324
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
Definition: sch_line.cpp:854
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
Definition: sch_line.cpp:591
void SetStartPoint(const VECTOR2I &aPosition)
Definition: sch_line.h:137
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_line.cpp:149
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_line.cpp:772
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemListByType, std::vector< DANGLING_END_ITEM > &aItemListByPos, const SCH_SHEET_PATH *aPath=nullptr) override
Test the schematic item to aItemList to check if it's dangling state has changed.
Definition: sch_line.cpp:601
bool m_startIsDangling
True if start point is not connected.
Definition: sch_line.h:348
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: sch_line.cpp:806
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_line.cpp:922
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
Definition: sch_line.cpp:706
int GetReverseAngleFrom(const VECTOR2I &aPoint) const
Definition: sch_line.cpp:432
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: sch_line.cpp:198
SCH_LINE(const VECTOR2I &pos=VECTOR2I(0, 0), int layer=LAYER_NOTES)
Definition: sch_line.cpp:45
bool IsWire() const
Return true if the line is a wire.
Definition: sch_line.cpp:973
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_line.cpp:223
void SetLineColor(const COLOR4D &aColor)
Definition: sch_line.cpp:245
bool CanConnect(const SCH_ITEM *aItem) const override
Definition: sch_line.cpp:663
bool IsParallel(const SCH_LINE *aLine) const
Definition: sch_line.cpp:445
void SetLineWidth(const int aSize)
Definition: sch_line.cpp:317
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_line.cpp:399
int GetAngleFrom(const VECTOR2I &aPoint) const
Definition: sch_line.cpp:419
void GetSelectedPoints(std::vector< VECTOR2I > &aPoints) const
Definition: sch_line.cpp:725
COLOR4D m_lastResolvedColor
Definition: sch_line.h:360
LINE_STYLE GetEffectiveLineStyle() const
Definition: sch_line.cpp:304
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition: sch_line.cpp:929
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
Definition: sch_line.cpp:863
wxString m_operatingPoint
Definition: sch_line.h:362
wxString GetClass() const override
Return the class name.
Definition: sch_line.h:63
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_line.cpp:409
VECTOR2I GetEndPoint() const
Definition: sch_line.h:141
VECTOR2I GetStartPoint() const
Definition: sch_line.h:136
bool ConnectionPropagatesTo(const EDA_ITEM *aItem) const override
Return true if this item should propagate connection info to aItem.
Definition: sch_line.cpp:712
LINE_STYLE m_lastResolvedLineStyle
Definition: sch_line.h:358
SCH_LINE * MergeOverlap(SCH_SCREEN *aScreen, SCH_LINE *aLine, bool aCheckJunctions)
Check line against aLine to see if it overlaps and merge if it does.
Definition: sch_line.cpp:458
VECTOR2I m_start
Line start point.
Definition: sch_line.h:350
bool IsBus() const
Return true if the line is a bus.
Definition: sch_line.cpp:979
int m_lastResolvedWidth
Definition: sch_line.h:359
void Print(const SCH_RENDER_SETTINGS *aSettings, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aForceNoFill, bool aDimmed) override
Print an item.
Definition: sch_line.cpp:358
bool HasConnectivityChanges(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aInstance=nullptr) const override
Check if aItem has connectivity changes against this object.
Definition: sch_line.cpp:687
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: sch_line.cpp:95
void SetLineStyle(const LINE_STYLE aStyle)
Definition: sch_line.cpp:288
VECTOR2I m_end
Line end point.
Definition: sch_line.h:351
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_line.cpp:155
LINE_STYLE GetLineStyle() const
Definition: sch_line.cpp:295
void MoveEnd(const VECTOR2I &aMoveVector)
Definition: sch_line.cpp:168
STROKE_PARAMS m_stroke
Line stroke properties.
Definition: sch_line.h:353
bool m_endIsDangling
True if end point is not connected.
Definition: sch_line.h:349
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_line.cpp:838
bool IsConnectable() const override
Definition: sch_line.cpp:654
wxString GetFriendlyName() const override
Definition: sch_line.cpp:138
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_line.cpp:389
bool operator==(const SCH_ITEM &aOther) const override
Definition: sch_line.cpp:985
bool operator<(const SCH_ITEM &aItem) const override
Definition: sch_line.cpp:783
bool IsEndPoint(const VECTOR2I &aPoint) const
Definition: sch_line.h:90
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: sch_line.cpp:735
bool IsGraphicLine() const
Return if the line is a graphic (non electrical line)
Definition: sch_line.cpp:967
int GetLineWidth() const
Definition: sch_line.h:181
COLOR4D GetLineColor() const
Returns COLOR4D::UNSPECIFIED if a custom color hasn't been set for this line.
Definition: sch_line.cpp:269
std::vector< int > ViewGetLayers() const override
Return the layers the item is drawn on (which may be more than its "home" layer)
Definition: sch_line.cpp:191
void MoveStart(const VECTOR2I &aMoveVector)
Definition: sch_line.cpp:162
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition: sch_line.cpp:109
double GetLength() const
Definition: sch_line.cpp:239
SCH_LINE * BreakAt(const VECTOR2I &aPoint)
Break this segment into two at the specified point.
Definition: sch_line.cpp:579
void SetEndPoint(const VECTOR2I &aPosition)
Definition: sch_line.h:142
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
Definition: sch_line.cpp:1014
bool IsJunction(const VECTOR2I &aPosition) const
Test if a junction is required for the items at aPosition on the screen.
Definition: sch_screen.cpp:479
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
int GetWidth() const
Definition: stroke_params.h:89
void SetLineStyle(LINE_STYLE aLineStyle)
Definition: stroke_params.h:93
void SetWidth(int aWidth)
Definition: stroke_params.h:90
void SetColor(const KIGFX::COLOR4D &aColor)
Definition: stroke_params.h:96
void GetMsgPanelInfo(UNITS_PROVIDER *aUnitsProvider, std::vector< MSG_PANEL_ITEM > &aList, bool aIncludeStyle=true, bool aIncludeWidth=true)
LINE_STYLE GetLineStyle() const
Definition: stroke_params.h:92
KIGFX::COLOR4D GetColor() const
Definition: stroke_params.h:95
static void Stroke(const SHAPE *aShape, LINE_STYLE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aRenderSettings, const std::function< void(const VECTOR2I &a, const VECTOR2I &b)> &aStroker)
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
double Distance(const VECTOR2< extended_type > &aVector) const
Compute the distance between two vectors.
Definition: vector2d.h:557
#define DEFAULT_BUS_WIDTH_MILS
The default noconnect size in mils.
#define DEFAULT_WIRE_WIDTH_MILS
The default bus width in mils. (can be changed in preference menu)
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
#define _HKI(x)
#define _(s)
static constexpr EDA_ANGLE ANGLE_90
Definition: eda_angle.h:403
static constexpr EDA_ANGLE ANGLE_270
Definition: eda_angle.h:406
#define STRUCT_DELETED
flag indication structures to be erased
#define ENDPOINT
ends. (Used to support dragging.)
#define SKIP_STRUCT
flag indicating that the structure should be ignored
#define STARTPOINT
When a line is selected, these flags indicate which.
void GRLine(wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:171
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:353
@ LAYER_DANGLING
Definition: layer_ids.h:381
@ LAYER_WIRE
Definition: layer_ids.h:356
@ LAYER_NOTES
Definition: layer_ids.h:371
@ LAYER_NET_COLOR_HIGHLIGHT
Definition: layer_ids.h:396
@ LAYER_BUS
Definition: layer_ids.h:357
@ LAYER_SELECTION_SHADOWS
Definition: layer_ids.h:397
@ LAYER_OP_VOLTAGES
Definition: layer_ids.h:403
constexpr void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Definition: mirror.h:45
KICOMMON_API VECTOR2I UnpackVector2(const types::Vector2 &aInput)
Definition: api_utils.cpp:84
KICOMMON_API void PackVector2(types::Vector2 &aOutput, const VECTOR2I &aInput)
Definition: api_utils.cpp:77
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:390
#define TYPE_HASH(x)
Definition: property.h:71
#define REGISTER_TYPE(x)
Definition: property_mgr.h:371
@ BUS_END
Definition: sch_item.h:79
@ PIN_END
Definition: sch_item.h:81
@ BUS_ENTRY_END
Definition: sch_item.h:83
@ WIRE_END
Definition: sch_item.h:78
static struct SCH_LINE_DESC _SCH_LINE_DESC
wxString UnescapeString(const wxString &aSource)
LINE_STYLE
Dashed line types.
Definition: stroke_params.h:46
constexpr int MilsToIU(int mils) const
Definition: base_units.h:93
constexpr int mmToIU(double mm) const
Definition: base_units.h:88
bool m_PDFPropertyPopups
Definition: sch_plotter.h:91
bool TestSegmentHit(const VECTOR2I &aRefPoint, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
Definition: trigo.cpp:175
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
Definition: trigo.cpp:229
@ SCH_LINE_T
Definition: typeinfo.h:163
@ SCH_NO_CONNECT_T
Definition: typeinfo.h:160
@ SCH_SYMBOL_T
Definition: typeinfo.h:172
@ SCH_DIRECTIVE_LABEL_T
Definition: typeinfo.h:171
@ SCH_LABEL_T
Definition: typeinfo.h:167
@ SCH_SHEET_T
Definition: typeinfo.h:174
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:169
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:173
@ SCH_BUS_WIRE_ENTRY_T
Definition: typeinfo.h:161
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:168
@ SCH_JUNCTION_T
Definition: typeinfo.h:159
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:691