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 The 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#include <properties/property.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
192std::vector<int> SCH_LINE::ViewGetLayers() const
193{
196}
197
198
199double SCH_LINE::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
200{
201 if( aLayer == LAYER_OP_VOLTAGES )
202 {
203 if( m_start == m_end )
204 return LOD_HIDE;
205
206 const int height = std::abs( m_end.y - m_start.y );
207
208 // Operating points will be shown only if zoom is appropriate
209 if( height > 0 )
210 return lodScaleForThreshold( height, schIUScale.mmToIU( 5 ) );
211
212 const int width = std::abs( m_end.x - m_start.x );
213 return lodScaleForThreshold( width, schIUScale.mmToIU( 15 ) );
214 }
215
216 // Other layers are always drawn.
217 return LOD_SHOW;
218}
219
220
222{
223 int width = GetPenWidth() / 2;
224
225 int xmin = std::min( m_start.x, m_end.x ) - width;
226 int ymin = std::min( m_start.y, m_end.y ) - width;
227
228 int xmax = std::max( m_start.x, m_end.x ) + width + 1;
229 int ymax = std::max( m_start.y, m_end.y ) + width + 1;
230
231 BOX2I ret( VECTOR2I( xmin, ymin ), VECTOR2I( xmax - xmin, ymax - ymin ) );
232
233 return ret;
234}
235
236
238{
239 return m_start.Distance( m_end );
240}
241
242
243void SCH_LINE::SetLineColor( const COLOR4D& aColor )
244{
245 m_stroke.SetColor( aColor );
247}
248
249
250void SCH_LINE::SetLineColor( const double r, const double g, const double b, const double a )
251{
252 COLOR4D newColor(r, g, b, a);
253
254 if( newColor == COLOR4D::UNSPECIFIED )
255 {
256 m_stroke.SetColor( COLOR4D::UNSPECIFIED );
257 }
258 else
259 {
260 // Eeschema does not allow alpha channel in colors
261 newColor.a = 1.0;
262 m_stroke.SetColor( newColor );
263 }
264}
265
266
268{
269 if( m_stroke.GetColor() != COLOR4D::UNSPECIFIED )
271 else if( !IsConnectable() )
272 m_lastResolvedColor = COLOR4D::UNSPECIFIED;
273 else if( !IsConnectivityDirty() )
274 m_lastResolvedColor = GetEffectiveNetClass()->GetSchematicColor();
275
276 return m_lastResolvedColor;
277}
278
279
281{
282 m_stroke.SetLineStyle( aStyle );
284}
285
286
288{
289 if( m_stroke.GetLineStyle() != LINE_STYLE::DEFAULT )
291 else if( !IsConnectable() )
292 m_lastResolvedLineStyle = LINE_STYLE::SOLID;
293 else if( !IsConnectivityDirty() )
295
297}
298
299
300void SCH_LINE::SetLineWidth( const int aSize )
301{
302 m_stroke.SetWidth( aSize );
304}
305
306
308{
309 SCHEMATIC* schematic = Schematic();
310
311 switch ( m_layer )
312 {
313 default:
314 if( m_stroke.GetWidth() > 0 )
315 return m_stroke.GetWidth();
316
317 if( schematic )
318 return schematic->Settings().m_DefaultLineWidth;
319
321
322 case LAYER_WIRE:
323 if( m_stroke.GetWidth() > 0 )
325 else if( !IsConnectivityDirty() )
326 m_lastResolvedWidth = GetEffectiveNetClass()->GetWireWidth();
327
328 return m_lastResolvedWidth;
329
330 case LAYER_BUS:
331 if( m_stroke.GetWidth() > 0 )
333 else if( !IsConnectivityDirty() )
334 m_lastResolvedWidth = GetEffectiveNetClass()->GetBusWidth();
335
336 return m_lastResolvedWidth;
337 }
338}
339
340
341void SCH_LINE::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
342 const VECTOR2I& offset, bool aForceNoFill, bool aDimmed )
343{
344 wxDC* DC = aSettings->GetPrintDC();
346
347 if( color == COLOR4D::UNSPECIFIED )
348 color = aSettings->GetLayerColor( GetLayer() );
349
350 VECTOR2I start = m_start;
351 VECTOR2I end = m_end;
352 LINE_STYLE lineStyle = GetEffectiveLineStyle();
353 int penWidth = GetEffectivePenWidth( aSettings );
354
355 if( lineStyle <= LINE_STYLE::FIRST_TYPE )
356 {
357 GRLine( DC, start.x, start.y, end.x, end.y, penWidth, color );
358 }
359 else
360 {
361 SHAPE_SEGMENT segment( start, end );
362
363 STROKE_PARAMS::Stroke( &segment, lineStyle, penWidth, aSettings,
364 [&]( const VECTOR2I& a, const VECTOR2I& b )
365 {
366 GRLine( DC, a.x, a.y, b.x, b.y, penWidth, color );
367 } );
368 }
369}
370
371
372void SCH_LINE::MirrorVertically( int aCenter )
373{
374 if( m_flags & STARTPOINT )
375 MIRROR( m_start.y, aCenter );
376
377 if( m_flags & ENDPOINT )
378 MIRROR( m_end.y, aCenter );
379}
380
381
383{
384 if( m_flags & STARTPOINT )
385 MIRROR( m_start.x, aCenter );
386
387 if( m_flags & ENDPOINT )
388 MIRROR( m_end.x, aCenter );
389}
390
391
392void SCH_LINE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
393{
394 if( m_flags & STARTPOINT )
395 RotatePoint( m_start, aCenter, aRotateCCW ? ANGLE_90 : ANGLE_270 );
396
397 if( m_flags & ENDPOINT )
398 RotatePoint( m_end, aCenter, aRotateCCW ? ANGLE_90 : ANGLE_270 );
399}
400
401
402int SCH_LINE::GetAngleFrom( const VECTOR2I& aPoint ) const
403{
404 VECTOR2I vec;
405
406 if( aPoint == m_start )
407 vec = m_end - aPoint;
408 else
409 vec = m_start - aPoint;
410
411 return KiROUND( EDA_ANGLE( vec ).AsDegrees() );
412}
413
414
415int SCH_LINE::GetReverseAngleFrom( const VECTOR2I& aPoint ) const
416{
417 VECTOR2I vec;
418
419 if( aPoint == m_end )
420 vec = m_start - aPoint;
421 else
422 vec = m_end - aPoint;
423
424 return KiROUND( EDA_ANGLE( vec ).AsDegrees() );
425}
426
427
428bool SCH_LINE::IsParallel( const SCH_LINE* aLine ) const
429{
430 wxCHECK_MSG( aLine != nullptr && aLine->Type() == SCH_LINE_T, false,
431 wxT( "Cannot test line segment for overlap." ) );
432
433 VECTOR2I firstSeg = m_end - m_start;
434 VECTOR2I secondSeg = aLine->m_end - aLine->m_start;
435
436 // Use long long here to avoid overflow in calculations
437 return !( (long long) firstSeg.x * secondSeg.y - (long long) firstSeg.y * secondSeg.x );
438}
439
440
441SCH_LINE* SCH_LINE::MergeOverlap( SCH_SCREEN* aScreen, SCH_LINE* aLine, bool aCheckJunctions )
442{
443 auto less =
444 []( const VECTOR2I& lhs, const VECTOR2I& rhs ) -> bool
445 {
446 if( lhs.x == rhs.x )
447 return lhs.y < rhs.y;
448
449 return lhs.x < rhs.x;
450 };
451
452 wxCHECK_MSG( aLine != nullptr && aLine->Type() == SCH_LINE_T, nullptr,
453 wxT( "Cannot test line segment for overlap." ) );
454
455 if( this == aLine || GetLayer() != aLine->GetLayer() )
456 return nullptr;
457
458 VECTOR2I leftmost_start = aLine->m_start;
459 VECTOR2I leftmost_end = aLine->m_end;
460
461 VECTOR2I rightmost_start = m_start;
462 VECTOR2I rightmost_end = m_end;
463
464 // We place the start to the left and below the end of both lines
465 if( leftmost_start != std::min( { leftmost_start, leftmost_end }, less ) )
466 std::swap( leftmost_start, leftmost_end );
467 if( rightmost_start != std::min( { rightmost_start, rightmost_end }, less ) )
468 std::swap( rightmost_start, rightmost_end );
469
470 // - leftmost is the line that starts farthest to the left
471 // - other is the line that is _not_ leftmost
472 // - rightmost is the line that ends farthest to the right. This may or may not be 'other'
473 // as the second line may be completely covered by the first.
474 if( less( rightmost_start, leftmost_start ) )
475 {
476 std::swap( leftmost_start, rightmost_start );
477 std::swap( leftmost_end, rightmost_end );
478 }
479
480 VECTOR2I other_start = rightmost_start;
481 VECTOR2I other_end = rightmost_end;
482
483 if( less( rightmost_end, leftmost_end ) )
484 {
485 rightmost_start = leftmost_start;
486 rightmost_end = leftmost_end;
487 }
488
489 // If we end one before the beginning of the other, no overlap is possible
490 if( less( leftmost_end, other_start ) )
491 {
492 return nullptr;
493 }
494
495 // Search for a common end:
496 if( ( leftmost_start == other_start ) && ( leftmost_end == other_end ) ) // Trivial case
497 {
498 SCH_LINE* ret = new SCH_LINE( *aLine );
499 ret->SetStartPoint( leftmost_start );
500 ret->SetEndPoint( leftmost_end );
501 ret->SetConnectivityDirty( true );
502
503 if( IsSelected() || aLine->IsSelected() )
504 ret->SetSelected();
505
506 return ret;
507 }
508
509 bool colinear = false;
510
511 /* Test alignment: */
512 if( ( leftmost_start.y == leftmost_end.y ) &&
513 ( other_start.y == other_end.y ) ) // Horizontal segment
514 {
515 colinear = ( leftmost_start.y == other_start.y );
516 }
517 else if( ( leftmost_start.x == leftmost_end.x ) &&
518 ( other_start.x == other_end.x ) ) // Vertical segment
519 {
520 colinear = ( leftmost_start.x == other_start.x );
521 }
522 else
523 {
524 // We use long long here to avoid overflow -- it enforces promotion
525 // The slope of the left-most line is dy/dx. Then we check that the slope from the
526 // left most start to the right most start is the same as well as the slope from the
527 // left most start to right most end.
528 long long dx = leftmost_end.x - leftmost_start.x;
529 long long dy = leftmost_end.y - leftmost_start.y;
530 colinear = ( ( ( other_start.y - leftmost_start.y ) * dx ==
531 ( other_start.x - leftmost_start.x ) * dy ) &&
532 ( ( other_end.y - leftmost_start.y ) * dx ==
533 ( other_end.x - leftmost_start.x ) * dy ) );
534 }
535
536 if( !colinear )
537 return nullptr;
538
539 // We either have a true overlap or colinear touching segments. We always want to merge
540 // the former, but the later only get merged if there no junction at the touch point.
541
542 bool touching = leftmost_end == rightmost_start;
543
544 if( touching && aCheckJunctions && aScreen->IsJunction( leftmost_end ) )
545 return nullptr;
546
547 // Make a new segment that merges the 2 segments
548 leftmost_end = rightmost_end;
549
550 SCH_LINE* ret = new SCH_LINE( *aLine );
551 ret->SetStartPoint( leftmost_start );
552 ret->SetEndPoint( leftmost_end );
553 ret->SetConnectivityDirty( true );
554
555 if( IsSelected() || aLine->IsSelected() )
556 ret->SetSelected();
557
558 return ret;
559}
560
561
563{
564 SCH_LINE* newSegment = static_cast<SCH_LINE*>( Duplicate() );
565
566 newSegment->SetStartPoint( aPoint );
567 newSegment->SetConnectivityDirty( true );
568 SetEndPoint( aPoint );
569
570 return newSegment;
571}
572
573
574void SCH_LINE::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
575{
576 if( IsConnectable() )
577 {
578 aItemList.emplace_back( IsBus() ? BUS_END : WIRE_END, this, m_start );
579 aItemList.emplace_back( IsBus() ? BUS_END : WIRE_END, this, m_end );
580 }
581}
582
583
584bool SCH_LINE::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListByType,
585 std::vector<DANGLING_END_ITEM>& aItemListByPos,
586 const SCH_SHEET_PATH* aPath )
587{
588 if( !IsConnectable() )
589 return false;
590
591 bool previousStartState = m_startIsDangling;
592 bool previousEndState = m_endIsDangling;
593
595
596 for( auto it = DANGLING_END_ITEM_HELPER::get_lower_pos( aItemListByPos, m_start );
597 it < aItemListByPos.end() && it->GetPosition() == m_start; it++ )
598 {
599 DANGLING_END_ITEM& item = *it;
600
601 if( item.GetItem() == this )
602 continue;
603
604 if( ( IsWire() && item.GetType() != BUS_END && item.GetType() != BUS_ENTRY_END )
605 || ( IsBus() && item.GetType() != WIRE_END && item.GetType() != PIN_END ) )
606 {
607 m_startIsDangling = false;
608 break;
609 }
610 }
611
612 for( auto it = DANGLING_END_ITEM_HELPER::get_lower_pos( aItemListByPos, m_end );
613 it < aItemListByPos.end() && it->GetPosition() == m_end; it++ )
614 {
615 DANGLING_END_ITEM& item = *it;
616
617 if( item.GetItem() == this )
618 continue;
619
620 if( ( IsWire() && item.GetType() != BUS_END && item.GetType() != BUS_ENTRY_END )
621 || ( IsBus() && item.GetType() != WIRE_END && item.GetType() != PIN_END ) )
622 {
623 m_endIsDangling = false;
624 break;
625 }
626 }
627
628 // We only use the bus dangling state for automatic line starting, so we don't care if it
629 // has changed or not (and returning true will result in extra work)
630 if( IsBus() )
631 return false;
632
633 return previousStartState != m_startIsDangling || previousEndState != m_endIsDangling;
634}
635
636
638{
639 if( m_layer == LAYER_WIRE || m_layer == LAYER_BUS )
640 return true;
641
642 return false;
643}
644
645
646bool SCH_LINE::CanConnect( const SCH_ITEM* aItem ) const
647{
648 switch( aItem->Type() )
649 {
650 case SCH_NO_CONNECT_T:
651 case SCH_SYMBOL_T:
652 return IsWire();
653
654 case SCH_JUNCTION_T:
655 case SCH_LABEL_T:
657 case SCH_HIER_LABEL_T:
660 case SCH_SHEET_T:
661 case SCH_SHEET_PIN_T:
662 return IsWire() || IsBus();
663
664 default:
665 return m_layer == aItem->GetLayer();
666 }
667}
668
669
671 const SCH_SHEET_PATH* aInstance ) const
672{
673 // Do not compare to ourself.
674 if( aItem == this || !IsConnectable() )
675 return false;
676
677 const SCH_LINE* line = dynamic_cast<const SCH_LINE*>( aItem );
678
679 // Don't compare against a different SCH_ITEM.
680 wxCHECK( line, false );
681
682 if( GetStartPoint() != line->GetStartPoint() )
683 return true;
684
685 return GetEndPoint() != line->GetEndPoint();
686}
687
688
689std::vector<VECTOR2I> SCH_LINE::GetConnectionPoints() const
690{
691 return { m_start, m_end };
692}
693
694
696{
697 switch( aItem->Type() )
698 {
699 case SCH_LINE_T:
700 return IsBus() == static_cast<const SCH_LINE*>( aItem )->IsBus();
701
702 default:
703 return true;
704 }
705}
706
707
708void SCH_LINE::GetSelectedPoints( std::vector<VECTOR2I>& aPoints ) const
709{
710 if( m_flags & STARTPOINT )
711 aPoints.push_back( m_start );
712
713 if( m_flags & ENDPOINT )
714 aPoints.push_back( m_end );
715}
716
717
718wxString SCH_LINE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
719{
720 wxString txtfmt;
721
722 if( m_start.x == m_end.x )
723 {
724 switch( m_layer )
725 {
726 case LAYER_WIRE: txtfmt = _( "Vertical Wire, length %s" ); break;
727 case LAYER_BUS: txtfmt = _( "Vertical Bus, length %s" ); break;
728 default: txtfmt = _( "Vertical Graphic Line, length %s" ); break;
729 }
730 }
731 else if( m_start.y == m_end.y )
732 {
733 switch( m_layer )
734 {
735 case LAYER_WIRE: txtfmt = _( "Horizontal Wire, length %s" ); break;
736 case LAYER_BUS: txtfmt = _( "Horizontal Bus, length %s" ); break;
737 default: txtfmt = _( "Horizontal Graphic Line, length %s" ); break;
738 }
739 }
740 else
741 {
742 switch( m_layer )
743 {
744 case LAYER_WIRE: txtfmt = _( "Wire, length %s" ); break;
745 case LAYER_BUS: txtfmt = _( "Bus, length %s" ); break;
746 default: txtfmt = _( "Graphic Line, length %s" ); break;
747 }
748 }
749
750 return wxString::Format( txtfmt,
751 aUnitsProvider->MessageTextFromValue( m_start.Distance( m_end ) ) );
752}
753
754
756{
757 if( m_layer == LAYER_NOTES )
758 return BITMAPS::add_dashed_line;
759 else if( m_layer == LAYER_WIRE )
760 return BITMAPS::add_line;
761
762 return BITMAPS::add_bus;
763}
764
765
766bool SCH_LINE::operator <( const SCH_ITEM& aItem ) const
767{
768 if( Type() != aItem.Type() )
769 return Type() < aItem.Type();
770
771 const SCH_LINE* line = static_cast<const SCH_LINE*>( &aItem );
772
773 if( GetLayer() != line->GetLayer() )
774 return GetLayer() < line->GetLayer();
775
776 if( GetStartPoint().x != line->GetStartPoint().x )
777 return GetStartPoint().x < line->GetStartPoint().x;
778
779 if( GetStartPoint().y != line->GetStartPoint().y )
780 return GetStartPoint().y < line->GetStartPoint().y;
781
782 if( GetEndPoint().x != line->GetEndPoint().x )
783 return GetEndPoint().x < line->GetEndPoint().x;
784
785 return GetEndPoint().y < line->GetEndPoint().y;
786}
787
788
789bool SCH_LINE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
790{
791 // Performance enhancement for connection-building
792 if( aPosition == m_start || aPosition == m_end )
793 return true;
794
795 if( aAccuracy >= 0 )
796 aAccuracy += GetPenWidth() / 2;
797 else
798 aAccuracy = abs( aAccuracy );
799
800 return TestSegmentHit( aPosition, m_start, m_end, aAccuracy );
801}
802
803
804bool SCH_LINE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
805{
807 return false;
808
809 BOX2I rect = aRect;
810
811 if ( aAccuracy )
812 rect.Inflate( aAccuracy );
813
814 if( aContained )
815 return rect.Contains( m_start ) && rect.Contains( m_end );
816
817 return rect.Intersects( m_start, m_end );
818}
819
820
822{
823 SCH_ITEM::SwapFlags( aItem );
824
825 SCH_LINE* item = (SCH_LINE*) aItem;
826
827 std::swap( m_layer, item->m_layer );
828
829 std::swap( m_start, item->m_start );
830 std::swap( m_end, item->m_end );
831 std::swap( m_startIsDangling, item->m_startIsDangling );
832 std::swap( m_endIsDangling, item->m_endIsDangling );
833 std::swap( m_stroke, item->m_stroke );
834}
835
836
837bool SCH_LINE::doIsConnected( const VECTOR2I& aPosition ) const
838{
839 if( m_layer != LAYER_WIRE && m_layer != LAYER_BUS )
840 return false;
841
842 return IsEndPoint( aPosition );
843}
844
845
846void SCH_LINE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
847 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
848{
849 if( aBackground )
850 return;
851
852 SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
853 int penWidth = GetEffectivePenWidth( renderSettings );
855
856 if( color == COLOR4D::UNSPECIFIED )
857 color = renderSettings->GetLayerColor( GetLayer() );
858
859 aPlotter->SetColor( color );
860
861 aPlotter->SetCurrentLineWidth( penWidth );
862 aPlotter->SetDash( penWidth, GetEffectiveLineStyle() );
863
864 aPlotter->MoveTo( m_start );
865 aPlotter->FinishTo( m_end );
866
867 aPlotter->SetDash( penWidth, LINE_STYLE::SOLID );
868
869 // Plot attributes to a hypertext menu
870 std::vector<wxString> properties;
871 BOX2I bbox = GetBoundingBox();
872 bbox.Inflate( penWidth * 3 );
873
874 if( aPlotOpts.m_PDFPropertyPopups )
875 {
876 if( GetLayer() == LAYER_WIRE )
877 {
878 if( SCH_CONNECTION* connection = Connection() )
879 {
880 properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
881 _( "Net" ),
882 connection->Name() ) );
883
884 properties.emplace_back(
885 wxString::Format( wxT( "!%s = %s" ), _( "Resolved netclass" ),
886 GetEffectiveNetClass()->GetHumanReadableName() ) );
887 }
888 }
889 else if( GetLayer() == LAYER_BUS )
890 {
891 if( SCH_CONNECTION* connection = Connection() )
892 {
893 for( const std::shared_ptr<SCH_CONNECTION>& member : connection->Members() )
894 properties.emplace_back( wxT( "!" ) + member->Name() );
895 }
896
897 }
898
899 if( !properties.empty() )
900 aPlotter->HyperlinkMenu( bbox, properties );
901 }
902}
903
904
905void SCH_LINE::SetPosition( const VECTOR2I& aPosition )
906{
907 m_end = m_end - ( m_start - aPosition );
908 m_start = aPosition;
909}
910
911
912void SCH_LINE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
913{
914 wxString msg;
915
916 switch( GetLayer() )
917 {
918 case LAYER_WIRE: msg = _( "Wire" ); break;
919 case LAYER_BUS: msg = _( "Bus" ); break;
920 default: msg = _( "Graphical" ); break;
921 }
922
923 aList.emplace_back( _( "Line Type" ), msg );
924
925 LINE_STYLE lineStyle = GetStroke().GetLineStyle();
926
927 if( GetEffectiveLineStyle() != lineStyle )
928 aList.emplace_back( _( "Line Style" ), _( "from netclass" ) );
929 else
930 m_stroke.GetMsgPanelInfo( aFrame, aList, true, false );
931
932 SCH_CONNECTION* conn = nullptr;
933
934 if( !IsConnectivityDirty() && dynamic_cast<SCH_EDIT_FRAME*>( aFrame ) )
935 conn = Connection();
936
937 if( conn )
938 {
939 conn->AppendInfoToMsgPanel( aList );
940
941 if( !conn->IsBus() )
942 {
943 aList.emplace_back( _( "Resolved Netclass" ),
944 UnescapeString( GetEffectiveNetClass()->GetHumanReadableName() ) );
945 }
946 }
947}
948
949
951{
952 return ( GetLayer() == LAYER_NOTES );
953}
954
955
957{
958 return ( GetLayer() == LAYER_WIRE );
959}
960
961
962bool SCH_LINE::IsBus() const
963{
964 return ( GetLayer() == LAYER_BUS );
965}
966
967
968bool SCH_LINE::operator==( const SCH_ITEM& aOther ) const
969{
970 if( Type() != aOther.Type() )
971 return false;
972
973 const SCH_LINE& other = static_cast<const SCH_LINE&>( aOther );
974
975 if( GetLayer() != other.GetLayer() )
976 return false;
977
978 if( m_start != other.m_start )
979 return false;
980
981 if( m_end != other.m_end )
982 return false;
983
984 if( m_stroke.GetWidth() != other.m_stroke.GetWidth() )
985 return false;
986
987 if( m_stroke.GetColor() != other.m_stroke.GetColor() )
988 return false;
989
990 if( m_stroke.GetLineStyle() != other.m_stroke.GetLineStyle() )
991 return false;
992
993 return true;
994}
995
996
997double SCH_LINE::Similarity( const SCH_ITEM& aOther ) const
998{
999 if( m_Uuid == aOther.m_Uuid )
1000 return 1.0;
1001
1002 if( Type() != aOther.Type() )
1003 return 0.0;
1004
1005 const SCH_LINE& other = static_cast<const SCH_LINE&>( aOther );
1006
1007 if( GetLayer() != other.GetLayer() )
1008 return 0.0;
1009
1010 double similarity = 1.0;
1011
1012 if( m_start != other.m_start )
1013 similarity *= 0.9;
1014
1015 if( m_end != other.m_end )
1016 similarity *= 0.9;
1017
1018 if( m_stroke.GetWidth() != other.m_stroke.GetWidth() )
1019 similarity *= 0.9;
1020
1021 if( m_stroke.GetColor() != other.m_stroke.GetColor() )
1022 similarity *= 0.9;
1023
1024 if( m_stroke.GetLineStyle() != other.m_stroke.GetLineStyle() )
1025 similarity *= 0.9;
1026
1027 return similarity;
1028}
1029
1030
1031static struct SCH_LINE_DESC
1032{
1034 {
1036
1037 if( lineStyleEnum.Choices().GetCount() == 0 )
1038 {
1039 lineStyleEnum.Map( LINE_STYLE::SOLID, _HKI( "Solid" ) )
1040 .Map( LINE_STYLE::DASH, _HKI( "Dashed" ) )
1041 .Map( LINE_STYLE::DOT, _HKI( "Dotted" ) )
1042 .Map( LINE_STYLE::DASHDOT, _HKI( "Dash-Dot" ) )
1043 .Map( LINE_STYLE::DASHDOTDOT, _HKI( "Dash-Dot-Dot" ) );
1044 }
1045
1047
1048 if( wireLineStyleEnum.Choices().GetCount() == 0 )
1049 {
1050 wireLineStyleEnum.Map( WIRE_STYLE::DEFAULT, _HKI( "Default" ) )
1051 .Map( WIRE_STYLE::SOLID, _HKI( "Solid" ) )
1052 .Map( WIRE_STYLE::DASH, _HKI( "Dashed" ) )
1053 .Map( WIRE_STYLE::DOT, _HKI( "Dotted" ) )
1054 .Map( WIRE_STYLE::DASHDOT, _HKI( "Dash-Dot" ) )
1055 .Map( WIRE_STYLE::DASHDOTDOT, _HKI( "Dash-Dot-Dot" ) );
1056 }
1057
1061
1062 auto isGraphicLine =
1063 []( INSPECTABLE* aItem ) -> bool
1064 {
1065 if( SCH_LINE* line = dynamic_cast<SCH_LINE*>( aItem ) )
1066 return line->IsGraphicLine();
1067
1068 return false;
1069 };
1070
1071 auto isWireOrBus =
1072 []( INSPECTABLE* aItem ) -> bool
1073 {
1074 if( SCH_LINE* line = dynamic_cast<SCH_LINE*>( aItem ) )
1075 return line->IsWire() || line->IsBus();
1076
1077 return false;
1078 };
1079
1080 propMgr.AddProperty( new PROPERTY_ENUM<SCH_LINE, LINE_STYLE>( _HKI( "Line Style" ),
1082 .SetAvailableFunc( isGraphicLine );
1083
1084 propMgr.AddProperty( new PROPERTY_ENUM<SCH_LINE, WIRE_STYLE>( _HKI( "Line Style" ),
1086 .SetAvailableFunc( isWireOrBus );
1087
1088 propMgr.AddProperty( new PROPERTY<SCH_LINE, int>( _HKI( "Line Width" ),
1089 &SCH_LINE::SetLineWidth, &SCH_LINE::GetLineWidth, PROPERTY_DISPLAY::PT_SIZE ) );
1090
1091 propMgr.AddProperty( new PROPERTY<SCH_LINE, COLOR4D>( _HKI( "Color" ),
1093 }
1095
int color
Definition: DXF_plotter.cpp:60
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:96
DANGLING_END_T GetType() const
Definition: sch_item.h:132
EDA_ITEM * GetItem() const
Definition: sch_item.h:130
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:490
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:501
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:686
static ENUM_MAP< T > & Instance()
Definition: property.h:680
wxPGChoices & Choices()
Definition: property.h:729
Class that other classes need to inherit from, in order to be inspectable.
Definition: inspectable.h:37
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
static constexpr double LOD_HIDE
Return this constant from ViewGetLOD() to hide the item unconditionally.
Definition: view_item.h:174
static constexpr double LOD_SHOW
Return this constant from ViewGetLOD() to show the item unconditionally.
Definition: view_item.h:179
static constexpr double lodScaleForThreshold(int aWhatIu, int aThresholdIu)
Get the scale at which aWhatIu would be drawn at the same size as aThresholdIu on screen.
Definition: view_item.h:196
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
Definition: kiid.h:49
std::string AsStdString() const
Definition: kiid.cpp:252
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:467
virtual void SetColor(const COLOR4D &color)=0
PROPERTY_BASE & SetAvailableFunc(std::function< bool(INSPECTABLE *)> aFunc)
Set a callback function to determine whether an object provides this property.
Definition: property.h:257
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:82
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:167
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
Definition: sch_item.h:656
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:283
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:282
void SetConnectivityDirty(bool aDirty=true)
Definition: sch_item.h:513
bool IsConnectivityDirty() const
Definition: sch_item.h:511
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:709
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:307
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
Definition: sch_line.cpp:837
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:574
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:150
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_line.cpp:755
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:584
bool m_startIsDangling
True if start point is not connected.
Definition: sch_line.h:353
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:789
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_line.cpp:905
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
Definition: sch_line.cpp:689
int GetReverseAngleFrom(const VECTOR2I &aPoint) const
Definition: sch_line.cpp:415
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:956
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_line.cpp:221
void SetWireStyle(const WIRE_STYLE aStyle)
Definition: sch_line.h:174
void SetLineColor(const COLOR4D &aColor)
Definition: sch_line.cpp:243
bool CanConnect(const SCH_ITEM *aItem) const override
Definition: sch_line.cpp:646
bool IsParallel(const SCH_LINE *aLine) const
Definition: sch_line.cpp:428
void SetLineWidth(const int aSize)
Definition: sch_line.cpp:300
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_line.cpp:382
virtual STROKE_PARAMS GetStroke() const override
Definition: sch_line.h:189
int GetAngleFrom(const VECTOR2I &aPoint) const
Definition: sch_line.cpp:402
void GetSelectedPoints(std::vector< VECTOR2I > &aPoints) const
Definition: sch_line.cpp:708
COLOR4D m_lastResolvedColor
Definition: sch_line.h:365
LINE_STYLE GetEffectiveLineStyle() const
Definition: sch_line.cpp:287
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:912
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:846
wxString m_operatingPoint
Definition: sch_line.h:367
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:392
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:695
LINE_STYLE m_lastResolvedLineStyle
Definition: sch_line.h:363
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:441
VECTOR2I m_start
Line start point.
Definition: sch_line.h:355
bool IsBus() const
Return true if the line is a bus.
Definition: sch_line.cpp:962
int m_lastResolvedWidth
Definition: sch_line.h:364
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:341
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:670
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:280
VECTOR2I m_end
Line end point.
Definition: sch_line.h:356
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.h:166
void MoveEnd(const VECTOR2I &aMoveVector)
Definition: sch_line.cpp:169
STROKE_PARAMS m_stroke
Line stroke properties.
Definition: sch_line.h:358
bool m_endIsDangling
True if end point is not connected.
Definition: sch_line.h:354
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_line.cpp:821
bool IsConnectable() const override
Definition: sch_line.cpp:637
wxString GetFriendlyName() const override
Definition: sch_line.cpp:139
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: sch_line.cpp:199
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_line.cpp:372
bool operator==(const SCH_ITEM &aOther) const override
Definition: sch_line.cpp:968
bool operator<(const SCH_ITEM &aItem) const override
Definition: sch_line.cpp:766
bool IsEndPoint(const VECTOR2I &aPoint) const
Definition: sch_line.h:90
WIRE_STYLE GetWireStyle() const
Definition: sch_line.h:175
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: sch_line.cpp:718
bool IsGraphicLine() const
Return if the line is a graphic (non electrical line)
Definition: sch_line.cpp:950
int GetLineWidth() const
Definition: sch_line.h:186
COLOR4D GetLineColor() const
Returns COLOR4D::UNSPECIFIED if a custom color hasn't been set for this line.
Definition: sch_line.cpp:267
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:192
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:237
SCH_LINE * BreakAt(const VECTOR2I &aPoint)
Break this segment into two at the specified point.
Definition: sch_line.cpp:562
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:997
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
void SetLineStyle(LINE_STYLE aLineStyle)
void SetWidth(int aWidth)
void SetColor(const KIGFX::COLOR4D &aColor)
void GetMsgPanelInfo(UNITS_PROVIDER *aUnitsProvider, std::vector< MSG_PANEL_ITEM > &aList, bool aIncludeStyle=true, bool aIncludeWidth=true)
LINE_STYLE GetLineStyle() const
KIGFX::COLOR4D GetColor() const
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:561
#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:401
@ LAYER_DANGLING
Definition: layer_ids.h:429
@ LAYER_WIRE
Definition: layer_ids.h:404
@ LAYER_NOTES
Definition: layer_ids.h:419
@ LAYER_NET_COLOR_HIGHLIGHT
Definition: layer_ids.h:445
@ LAYER_BUS
Definition: layer_ids.h:405
@ LAYER_SELECTION_SHADOWS
Definition: layer_ids.h:446
@ LAYER_OP_VOLTAGES
Definition: layer_ids.h:452
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 IMPLEMENT_ENUM_TO_WXANY(type)
Definition: property.h:780
#define REGISTER_TYPE(x)
Definition: property_mgr.h:371
@ BUS_END
Definition: sch_item.h:80
@ PIN_END
Definition: sch_item.h:82
@ BUS_ENTRY_END
Definition: sch_item.h:84
@ WIRE_END
Definition: sch_item.h:79
static struct SCH_LINE_DESC _SCH_LINE_DESC
wxString UnescapeString(const wxString &aSource)
LINE_STYLE
Dashed line types.
Definition: stroke_params.h:46
WIRE_STYLE
Definition: stroke_params.h:68
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:695