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