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