KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_table.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <pgm_base.h>
21#include <sch_edit_frame.h>
22#include <plotters/plotter.h>
24#include <geometry/shape_rect.h>
25#include <bitmaps.h>
26#include <string_utils.h>
27#include <schematic.h>
29#include <sch_painter.h>
30#include <wx/log.h>
31#include <sch_table.h>
33#include <properties/property.h>
35
36#include <api/api_enums.h>
37#include <api/api_utils.h>
38#include <api/schematic/schematic_types.pb.h>
39
40SCH_TABLE::SCH_TABLE( int aLineWidth ) :
41 SCH_ITEM( nullptr, SCH_TABLE_T ),
42 m_strokeExternal( true ),
45 m_strokeRows( true ),
46 m_strokeColumns( true ),
48 m_colCount( 0 )
49{
51}
52
53
55 SCH_ITEM( aTable )
56{
63
64 m_colCount = aTable.m_colCount;
65 m_colWidths = aTable.m_colWidths;
67
68 for( SCH_TABLECELL* src : aTable.m_cells )
69 AddCell( new SCH_TABLECELL( *src ) );
70}
71
72
74{
75 // We own our cells; delete them
76 for( SCH_TABLECELL* cell : m_cells )
77 delete cell;
78}
79
80
81void SCH_TABLE::Serialize( google::protobuf::Any& aContainer ) const
82{
83 using namespace kiapi::common;
84 using namespace kiapi::schematic::types;
85
86 SchematicTable table;
87
88 table.mutable_id()->set_value( m_Uuid.AsStdString() );
89 table.set_locked( IsLocked() ? types::LockedState::LS_LOCKED : types::LockedState::LS_UNLOCKED );
90
91 table.set_column_count( m_colCount );
92
93 for( int col = 0; col < m_colCount; ++col )
94 PackDistance( *table.add_column_widths(), GetColWidth( col ), schIUScale );
95
96 for( int row = 0; row < GetRowCount(); ++row )
97 PackDistance( *table.add_row_heights(), GetRowHeight( row ), schIUScale );
98
99 for( const SCH_TABLECELL* cell : m_cells )
100 cell->Serialize( *table.add_cells() );
101
102 table.set_external_border( m_strokeExternal ? TableStrokeMode::TSM_ENABLED : TableStrokeMode::TSM_DISABLED );
103 table.set_header_separator( m_StrokeHeaderSeparator ? TableStrokeMode::TSM_ENABLED
104 : TableStrokeMode::TSM_DISABLED );
105
106 PackStroke( *table.mutable_border_stroke(), m_borderStroke, schIUScale );
107
108 table.set_row_separators( m_strokeRows ? TableStrokeMode::TSM_ENABLED : TableStrokeMode::TSM_DISABLED );
109 table.set_column_separators( m_strokeColumns ? TableStrokeMode::TSM_ENABLED : TableStrokeMode::TSM_DISABLED );
110
111 PackStroke( *table.mutable_separators_stroke(), m_separatorsStroke, schIUScale );
112
113 kiapi::common::PackCustomProperties( table.mutable_custom_properties(), *this );
114 aContainer.PackFrom( table );
115}
116
117
118bool SCH_TABLE::Deserialize( const google::protobuf::Any& aContainer )
119{
120 using namespace kiapi::schematic::types;
121
122 SchematicTable table;
123
124 if( !aContainer.UnpackTo( &table ) )
125 return false;
126
127 kiapi::common::UnpackCustomProperties( table.custom_properties(), *this );
128
129 if( table.column_count() < 1 )
130 return false;
131
132 const_cast<KIID&>( m_Uuid ) = KIID( table.id().value() );
133 SetLocked( table.locked() == kiapi::common::types::LockedState::LS_LOCKED );
134
135 ClearCells();
136 m_colWidths.clear();
137 m_rowHeights.clear();
138
139 SetColCount( table.column_count() );
140
141 for( int i = 0; i < table.column_widths_size() && i < table.column_count(); ++i )
142 SetColWidth( i, kiapi::common::UnpackDistance( table.column_widths( i ), schIUScale ) );
143
144 for( const SchematicTableCell& protoCell : table.cells() )
145 {
146 SCH_TABLECELL* cell = new SCH_TABLECELL();
147
148 if( !cell->Deserialize( protoCell ) )
149 {
150 // Since cells are positional, we must add something to the table. Probably better
151 // to add a new, empy cell than a partially deserialized who-knows-what.
152 delete cell;
153 cell = new SCH_TABLECELL();
154 }
155
156 AddCell( cell );
157 }
158
159 int rowCount = m_colCount > 0 ? static_cast<int>( m_cells.size() ) / m_colCount : 0;
160
161 for( int i = 0; i < table.row_heights_size() && i < rowCount; ++i )
163
164 m_strokeExternal = table.external_border() == TableStrokeMode::TSM_ENABLED;
165 m_StrokeHeaderSeparator = table.header_separator() == TableStrokeMode::TSM_ENABLED;
166
167 if( table.has_border_stroke() )
169
170 m_strokeRows = table.row_separators() == TableStrokeMode::TSM_ENABLED;
171 m_strokeColumns = table.column_separators() == TableStrokeMode::TSM_ENABLED;
172
173 if( table.has_separators_stroke() )
175
176 Normalize();
177 return true;
178}
179
180
182{
183 wxCHECK_RET( aItem != nullptr && aItem->Type() == SCH_TABLE_T, wxT( "Cannot swap data with invalid table." ) );
184
185 SCH_TABLE* table = static_cast<SCH_TABLE*>( aItem );
186
187 std::swap( m_strokeExternal, table->m_strokeExternal );
188 std::swap( m_StrokeHeaderSeparator, table->m_StrokeHeaderSeparator );
189 std::swap( m_borderStroke, table->m_borderStroke );
190 std::swap( m_strokeRows, table->m_strokeRows );
191 std::swap( m_strokeColumns, table->m_strokeColumns );
192 std::swap( m_separatorsStroke, table->m_separatorsStroke );
193
194 std::swap( m_colCount, table->m_colCount );
195 std::swap( m_colWidths, table->m_colWidths );
196 std::swap( m_rowHeights, table->m_rowHeights );
197
198 std::swap( m_cells, table->m_cells );
199
200 for( SCH_TABLECELL* cell : m_cells )
201 cell->SetParent( this );
202
203 for( SCH_TABLECELL* cell : table->m_cells )
204 cell->SetParent( table );
205}
206
207
209{
210 Move( aPos - GetPosition() );
211}
212
213
215{
216 if( m_cells.empty() )
217 return VECTOR2I( 0, 0 ); // Return origin if table has no cells
218
219 return m_cells[0]->GetPosition();
220}
221
222
224{
225 BOX2I bbox;
226
227 for( SCH_TABLECELL* cell : m_cells )
228 {
229 bbox.Merge( cell->GetPosition() );
230 bbox.Merge( cell->GetEnd() );
231 }
232
233 return bbox.GetCenter();
234}
235
236
238{
239 VECTOR2I tableSize;
240
241 for( int ii = 0; ii < GetColCount(); ++ii )
242 tableSize.x += GetColWidth( ii );
243
244 for( int ii = 0; ii < GetRowCount(); ++ii )
245 tableSize.y += GetRowHeight( ii );
246
247 return GetPosition() + tableSize;
248}
249
250
252{
253 int y = GetPosition().y;
254
255 for( int row = 0; row < GetRowCount(); ++row )
256 {
257 int x = GetPosition().x;
258 int rowHeight = m_rowHeights[row];
259
260 for( int col = 0; col < GetColCount(); ++col )
261 {
262 int colWidth = m_colWidths[col];
263
264 SCH_TABLECELL* cell = GetCell( row, col );
265
266 if( !cell )
267 continue; // Skip if cell doesn't exist (shouldn't happen, but be defensive)
268
269 VECTOR2I pos( x, y );
270
271 RotatePoint( pos, GetPosition(), cell->GetTextAngle() );
272
273 if( cell->GetPosition() != pos )
274 {
275 cell->SetPosition( pos );
276 cell->ClearRenderCache();
277 }
278
279 VECTOR2I end = VECTOR2I( x + colWidth, y + rowHeight );
280
281 if( cell->GetColSpan() > 1 || cell->GetRowSpan() > 1 )
282 {
283 for( int ii = col + 1; ii < col + cell->GetColSpan(); ++ii )
284 end.x += m_colWidths[ii];
285
286 for( int ii = row + 1; ii < row + cell->GetRowSpan(); ++ii )
287 end.y += m_rowHeights[ii];
288 }
289
291
292 if( cell->GetEnd() != end )
293 {
294 cell->SetEnd( end );
295 cell->ClearRenderCache();
296 }
297
298 x += colWidth;
299 }
300
301 y += rowHeight;
302 }
303}
304
305
306void SCH_TABLE::Move( const VECTOR2I& aMoveVector )
307{
308 for( SCH_TABLECELL* cell : m_cells )
309 cell->Move( aMoveVector );
310}
311
312
314{
315 // We could mirror all the cells, but it doesn't seem useful....
316}
317
318
320{
321 // We could mirror all the cells, but it doesn't seem useful....
322}
323
324
325void SCH_TABLE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
326{
327 for( SCH_TABLECELL* cell : m_cells )
328 cell->Rotate( aCenter, aRotateCCW );
329
330 Normalize();
331}
332
333
334bool SCH_TABLE::operator<( const SCH_ITEM& aItem ) const
335{
336 if( Type() != aItem.Type() )
337 return Type() < aItem.Type();
338
339 const SCH_TABLE& other = static_cast<const SCH_TABLE&>( aItem );
340
341 if( m_cells.size() != other.m_cells.size() )
342 return m_cells.size() < other.m_cells.size();
343
344 if( GetPosition().x != other.GetPosition().x )
345 return GetPosition().x < other.GetPosition().x;
346
347 if( GetPosition().y != other.GetPosition().y )
348 return GetPosition().y < other.GetPosition().y;
349
351 return m_strokeExternal;
352
355
356 if( m_borderStroke != other.m_borderStroke )
357 return m_borderStroke < other.m_borderStroke;
358
359 if( m_strokeRows != other.m_strokeRows )
360 return m_strokeRows;
361
362 if( m_strokeColumns != other.m_strokeColumns )
363 return m_strokeColumns;
364
367
368 int diff;
369
370 if( ( diff = GetColCount() - other.GetColCount() ) != 0 )
371 return diff;
372
373 for( int col = 0; col < GetColCount(); ++col )
374 {
375 if( ( diff = GetColWidth( col ) - other.GetColWidth( col ) ) != 0 )
376 return diff;
377 }
378
379 if( ( diff = GetRowCount() - other.GetRowCount() ) != 0 )
380 return diff;
381
382 for( int row = 0; row < GetRowCount(); ++row )
383 {
384 if( ( diff = GetRowHeight( row ) - other.GetRowHeight( row ) ) != 0 )
385 return diff;
386 }
387
388 for( int ii = 0; ii < (int) m_cells.size(); ++ii )
389 {
390 if( m_cells[ii] != other.m_cells[ii] )
391 return m_cells[ii] < other.m_cells[ii];
392 }
393
394 return false;
395}
396
397
398void SCH_TABLE::RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction, RECURSE_MODE aMode )
399{
400 for( SCH_TABLECELL* cell : m_cells )
401 aFunction( cell );
402}
403
404
406{
407 if( m_cells.empty() )
408 return BOX2I();
409
410 BOX2I bbox = m_cells[0]->GetBoundingBox();
411
412 bbox.Merge( m_cells[m_cells.size() - 1]->GetBoundingBox() );
413
414 if( m_strokeExternal )
415 bbox.Inflate( m_borderStroke.GetWidth() / 2 );
416
417 return bbox;
418}
419
420
421INSPECT_RESULT SCH_TABLE::Visit( INSPECTOR aInspector, void* aTestData, const std::vector<KICAD_T>& aScanTypes )
422{
423 for( KICAD_T scanType : aScanTypes )
424 {
425 if( scanType == SCH_LOCATE_ANY_T || scanType == SCH_TABLE_T )
426 {
427 if( INSPECT_RESULT::QUIT == aInspector( this, aTestData ) )
429 }
430
431 if( scanType == SCH_LOCATE_ANY_T || scanType == SCH_TABLECELL_T )
432 {
433 for( SCH_TABLECELL* cell : m_cells )
434 {
435 if( INSPECT_RESULT::QUIT == aInspector( cell, (void*) this ) )
437 }
438 }
439 }
440
442}
443
444
445wxString SCH_TABLE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
446{
447 return wxString::Format( _( "%d Column Table" ), m_colCount );
448}
449
450
452{
453 return BITMAPS::spreadsheet; // JEY TODO
454}
455
456
457std::vector<int> SCH_TABLE::ViewGetLayers() const
458{
460}
461
462
463bool SCH_TABLE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
464{
465 BOX2I rect = GetBoundingBox();
466
467 rect.Inflate( aAccuracy );
468
469 return rect.Contains( aPosition );
470}
471
472
473bool SCH_TABLE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
474{
475 BOX2I rect = aRect;
476
477 rect.Inflate( aAccuracy );
478
479 if( aContained )
480 return rect.Contains( GetBoundingBox() );
481
482 return rect.Intersects( GetBoundingBox() );
483}
484
485
486bool SCH_TABLE::HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const
487{
488 return KIGEOM::BoxHitTest( aPoly, GetBoundingBox(), aContained );
489}
490
491
492void SCH_TABLE::DrawBorders( const std::function<void( const VECTOR2I& aPt1, const VECTOR2I& aPt2,
493 const STROKE_PARAMS& aStroke )>& aCallback ) const
494{
495 if( m_cells.empty() ) // Shouldn't be possible....
496 return;
497
498 EDA_ANGLE drawAngle = GetCell( 0, 0 )->GetTextAngle();
499
500 std::vector<VECTOR2I> topLeft = GetCell( 0, 0 )->GetCornersInSequence( drawAngle );
501 std::vector<VECTOR2I> bottomLeft = GetCell( GetRowCount() - 1, 0 )->GetCornersInSequence( drawAngle );
502 std::vector<VECTOR2I> topRight = GetCell( 0, GetColCount() - 1 )->GetCornersInSequence( drawAngle );
503 std::vector<VECTOR2I> botRight = GetCell( GetRowCount() - 1, GetColCount() - 1 )->GetCornersInSequence( drawAngle );
504 STROKE_PARAMS stroke;
505
506 for( int col = 0; col < GetColCount() - 1; ++col )
507 {
508 for( int row = 0; row < GetRowCount(); ++row )
509 {
510 if( row == 0 && StrokeHeaderSeparator() )
511 stroke = GetBorderStroke();
512 else if( StrokeColumns() )
513 stroke = GetSeparatorsStroke();
514 else
515 continue;
516
517 SCH_TABLECELL* cell = GetCell( row, col );
518
519 if( cell->GetColSpan() == 0 )
520 continue;
521
522 if( col + cell->GetColSpan() == GetColCount() )
523 continue;
524
525 std::vector<VECTOR2I> corners = cell->GetCornersInSequence( drawAngle );
526
527 if( corners.size() == 4 )
528 aCallback( corners[1], corners[2], stroke );
529 }
530 }
531
532 for( int row = 0; row < GetRowCount() - 1; ++row )
533 {
534 if( row == 0 && StrokeHeaderSeparator() )
535 stroke = GetBorderStroke();
536 else if( StrokeRows() )
537 stroke = GetSeparatorsStroke();
538 else
539 continue;
540
541 for( int col = 0; col < GetColCount(); ++col )
542 {
543 SCH_TABLECELL* cell = GetCell( row, col );
544
545 if( cell->GetRowSpan() == 0 )
546 continue;
547
548 if( row + cell->GetRowSpan() == GetRowCount() )
549 continue;
550
551 std::vector<VECTOR2I> corners = cell->GetCornersInSequence( drawAngle );
552
553 if( corners.size() == 4 )
554 aCallback( corners[2], corners[3], stroke );
555 }
556 }
557
558 if( StrokeExternal() && GetBorderStroke().GetWidth() >= 0 )
559 {
560 aCallback( topLeft[0], topRight[1], GetBorderStroke() );
561 aCallback( topRight[1], botRight[2], GetBorderStroke() );
562 aCallback( botRight[2], bottomLeft[3], GetBorderStroke() );
563 aCallback( bottomLeft[3], topLeft[0], GetBorderStroke() );
564 }
565}
566
567
568void SCH_TABLE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts, int aUnit, int aBodyStyle,
569 const VECTOR2I& aOffset, bool aDimmed )
570{
571 for( SCH_TABLECELL* cell : m_cells )
572 cell->Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
573
574 if( aBackground )
575 return;
576
577 RENDER_SETTINGS* settings = aPlotter->RenderSettings();
578
580 [&]( const VECTOR2I& ptA, const VECTOR2I& ptB, const STROKE_PARAMS& stroke )
581 {
582 int lineWidth = stroke.GetWidth();
583 COLOR4D color = stroke.GetColor();
584 LINE_STYLE lineStyle = stroke.GetLineStyle();
585
586 if( lineWidth == 0 )
587 {
588 if( SCHEMATIC* schematic = Schematic() )
589 lineWidth = schematic->Settings().m_DefaultLineWidth;
590 else
591 lineWidth = schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS );
592 }
593
594 if( lineWidth < settings->GetMinPenWidth() )
595 lineWidth = settings->GetMinPenWidth();
596
597 if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
598 color = settings->GetLayerColor( m_layer );
599
600 if( color.m_text && Schematic() )
601 color = COLOR4D( ResolveText( *color.m_text, &Schematic()->CurrentSheet() ) );
602
603 if( lineStyle == LINE_STYLE::DEFAULT )
604 lineStyle = LINE_STYLE::SOLID;
605
606 aPlotter->SetColor( color );
607 aPlotter->SetDash( lineWidth, lineStyle );
608
609 aPlotter->MoveTo( ptA );
610 aPlotter->FinishTo( ptB );
611 } );
612}
613
614
615void SCH_TABLE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
616{
617 // Don't use GetShownText() here; we want to show the user the variable references
618 aList.emplace_back( _( "Table" ), wxString::Format( _( "%d Columns" ), m_colCount ) );
619
620 SCH_ITEM::GetMsgPanelInfo( aFrame, aList );
621}
622
623
624bool SCH_TABLE::operator==( const SCH_ITEM& aOther ) const
625{
626 if( Type() != aOther.Type() )
627 return false;
628
629 const SCH_TABLE& other = static_cast<const SCH_TABLE&>( aOther );
630
631 if( m_cells.size() != other.m_cells.size() )
632 return false;
633
635 return false;
636
638 return false;
639
640 if( m_borderStroke != other.m_borderStroke )
641 return false;
642
643 if( m_strokeRows != other.m_strokeRows )
644 return false;
645
646 if( m_strokeColumns != other.m_strokeColumns )
647 return false;
648
650 return false;
651
652 if( m_colWidths != other.m_colWidths )
653 return false;
654
655 if( m_rowHeights != other.m_rowHeights )
656 return false;
657
658 for( int ii = 0; ii < (int) m_cells.size(); ++ii )
659 {
660 if( !( *m_cells[ii] == *other.m_cells[ii] ) )
661 return false;
662 }
663
664 return true;
665}
666
667
668double SCH_TABLE::Similarity( const SCH_ITEM& aOther ) const
669{
670 if( aOther.Type() != Type() )
671 return 0.0;
672
673 const SCH_TABLE& other = static_cast<const SCH_TABLE&>( aOther );
674
675 if( m_cells.size() != other.m_cells.size() )
676 return 0.1;
677
678 double similarity = 1.0;
679
680 for( int ii = 0; ii < (int) m_cells.size(); ++ii )
681 similarity *= m_cells[ii]->Similarity( *other.m_cells[ii] );
682
683 return similarity;
684}
685
686
687static struct SCH_TABLE_DESC
688{
690 {
693
696
697 propMgr.AddProperty( new PROPERTY<SCH_TABLE, int>( _HKI( "Start X" ),
700 propMgr.AddProperty( new PROPERTY<SCH_TABLE, int>( _HKI( "Start Y" ),
703
704 const wxString tableProps = _( "Table Properties" );
705
706 propMgr.AddProperty( new PROPERTY<SCH_TABLE, bool>( _HKI( "External Border" ),
708 tableProps );
709
710 propMgr.AddProperty( new PROPERTY<SCH_TABLE, bool>( _HKI( "Header Border" ),
712 tableProps );
713
714 propMgr.AddProperty( new PROPERTY<SCH_TABLE, int>( _HKI( "Border Width" ),
717 tableProps );
718
719 propMgr.AddProperty( new PROPERTY_ENUM<SCH_TABLE, LINE_STYLE>( _HKI( "Border Style" ),
721 tableProps );
722
723 propMgr.AddProperty( new PROPERTY<SCH_TABLE, COLOR4D>( _HKI( "Border Color" ),
725 tableProps );
726
727 propMgr.AddProperty( new PROPERTY<SCH_TABLE, bool>( _HKI( "Row Separators" ),
729 tableProps );
730
731 propMgr.AddProperty( new PROPERTY<SCH_TABLE, bool>( _HKI( "Cell Separators" ),
733 tableProps );
734
735 propMgr.AddProperty( new PROPERTY<SCH_TABLE, int>( _HKI( "Separators Width" ),
738 tableProps );
739
740 propMgr.AddProperty( new PROPERTY_ENUM<SCH_TABLE, LINE_STYLE>( _HKI( "Separators Style" ),
742 tableProps );
743
744 propMgr.AddProperty( new PROPERTY<SCH_TABLE, COLOR4D>( _HKI( "Separators Color" ),
746 tableProps );
747 }
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:130
BITMAPS
A list of all bitmap identifiers.
BOX2< VECTOR2I > BOX2I
Definition box2.h:914
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition box2.h:553
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition box2.h:594
constexpr const Vec GetCenter() const
Definition box2.h:227
constexpr bool Contains(const Vec &aPoint) const
Definition box2.h:165
constexpr bool Intersects(const BOX2< Vec > &aRect) const
Definition box2.h:308
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:400
The base class for create windows for drawing purpose.
const KIID m_Uuid
Definition eda_item.h:599
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.cpp:153
virtual void SetEnd(const VECTOR2I &aEnd)
Definition eda_shape.h:337
virtual std::vector< VECTOR2I > GetCornersInSequence(EDA_ANGLE angle) const
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition eda_shape.h:333
virtual void ClearRenderCache()
Definition eda_text.cpp:669
virtual EDA_ANGLE GetTextAngle() const
Definition eda_text.h:178
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
std::shared_ptr< wxString > m_text
Definition color4d.h:397
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
Definition kiid.h:46
Base plotter engine class.
Definition plotter.h:138
void MoveTo(const VECTOR2I &pos)
Definition plotter.h:325
virtual void SetDash(int aLineWidth, LINE_STYLE aLineStyle)=0
void FinishTo(const VECTOR2I &pos)
Definition plotter.h:335
RENDER_SETTINGS * RenderSettings()
Definition plotter.h:169
bool GetColorMode() const
Definition plotter.h:166
virtual void SetColor(const COLOR4D &color)=0
Provide class metadata.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
Holds all the data relating to one schematic.
Definition schematic.h:149
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:170
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.
void SetLocked(bool aLocked) override
Definition sch_item.h:262
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:302
bool IsLocked() const override
Definition sch_item.cpp:179
void SetLayer(SCH_LAYER_ID aLayer)
Definition sch_item.h:354
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition sch_item.cpp:65
wxString ResolveText(const wxString &aText, const SCH_SHEET_PATH *aPath, int aDepth=0) const
Definition sch_item.cpp:464
SCH_LAYER_ID m_layer
Definition sch_item.h:843
void SetPosition(const VECTOR2I &aPos) override
Definition sch_shape.h:89
VECTOR2I GetPosition() const override
Definition sch_shape.h:88
int GetColSpan() const
int GetRowSpan() const
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
void SetBorderWidth(int aWidth)
Definition sch_table.h:60
void SetSeparatorsStyle(const LINE_STYLE aStyle)
Definition sch_table.h:81
LINE_STYLE GetSeparatorsStyle() const
Definition sch_table.h:86
std::vector< int > ViewGetLayers() const override
Return the layers the item is drawn on (which may be more than its "home" layer)
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
bool operator<(const SCH_ITEM &aItem) const override
void SetRowHeight(int aRow, int aHeight)
Definition sch_table.h:138
std::vector< SCH_TABLECELL * > m_cells
Definition sch_table.h:260
const STROKE_PARAMS & GetSeparatorsStroke() const
Definition sch_table.h:76
std::map< int, int > m_rowHeights
Definition sch_table.h:259
bool m_strokeColumns
Definition sch_table.h:254
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
void SetColCount(int aCount)
Definition sch_table.h:118
bool StrokeExternal() const
Definition sch_table.h:52
void SetBorderColor(const COLOR4D &aColor)
Definition sch_table.h:72
bool m_strokeRows
Definition sch_table.h:253
int GetPositionY() const
Definition sch_table.h:116
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
void SetPositionX(int x)
Definition sch_table.h:113
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
LINE_STYLE GetBorderStyle() const
Definition sch_table.h:64
void SetSeparatorsColor(const COLOR4D &aColor)
Definition sch_table.h:94
int GetRowHeight(int aRow) const
Definition sch_table.h:140
void SetColWidth(int aCol, int aWidth)
Definition sch_table.h:128
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode) override
COLOR4D GetSeparatorsColor() const
Definition sch_table.h:95
SCH_TABLE(int aLineWidth=0)
Definition sch_table.cpp:40
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
void DrawBorders(const std::function< void(const VECTOR2I &aPt1, const VECTOR2I &aPt2, const STROKE_PARAMS &aStroke)> &aCallback) const
int GetColWidth(int aCol) const
Definition sch_table.h:130
void SetStrokeHeaderSeparator(bool aDoStroke)
Definition sch_table.h:54
void AddCell(SCH_TABLECELL *aCell)
Definition sch_table.h:163
void SetSeparatorsWidth(int aWidth)
Definition sch_table.h:78
const STROKE_PARAMS & GetBorderStroke() const
Definition sch_table.h:58
bool m_StrokeHeaderSeparator
Definition sch_table.h:251
VECTOR2I GetCenter() const
int m_colCount
Definition sch_table.h:257
VECTOR2I GetPosition() const override
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
void SetStrokeExternal(bool aDoStroke)
Definition sch_table.h:51
VECTOR2I GetEnd() const
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.
void SetPositionY(int y)
Definition sch_table.h:114
STROKE_PARAMS m_separatorsStroke
Definition sch_table.h:255
int GetColCount() const
Definition sch_table.h:119
bool StrokeHeaderSeparator() const
Definition sch_table.h:55
bool m_strokeExternal
Definition sch_table.h:250
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.
std::map< int, int > m_colWidths
Definition sch_table.h:258
void SetStrokeColumns(bool aDoStroke)
Definition sch_table.h:97
SCH_TABLECELL * GetCell(int aRow, int aCol) const
Definition sch_table.h:148
void ClearCells()
Definition sch_table.h:175
int GetSeparatorsWidth() const
Definition sch_table.h:79
bool StrokeColumns() const
Definition sch_table.h:98
void SetPosition(const VECTOR2I &aPos) override
int GetPositionX() const
Definition sch_table.h:115
bool StrokeRows() const
Definition sch_table.h:101
STROKE_PARAMS m_borderStroke
Definition sch_table.h:252
int GetRowCount() const
Definition sch_table.h:121
void SetStrokeRows(bool aDoStroke)
Definition sch_table.h:100
void SetBorderStyle(const LINE_STYLE aStyle)
Definition sch_table.h:63
COLOR4D GetBorderColor() const
Definition sch_table.h:73
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
bool operator==(const SCH_ITEM &aOther) const override
int GetBorderWidth() const
Definition sch_table.h:61
void Normalize()
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition sch_table.cpp:81
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Simple container to manage line stroke parameters.
int GetWidth() const
LINE_STYLE GetLineStyle() const
KIGFX::COLOR4D GetColor() const
#define DEFAULT_LINE_WIDTH_MILS
The default line width in mils. (can be changed in preference menu)
#define UNSPECIFIED
#define _(s)
RECURSE_MODE
Definition eda_item.h:50
INSPECT_RESULT
Definition eda_item.h:44
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
Definition eda_item.h:91
a few functions useful in geometry calculations.
@ LAYER_NOTES
Definition layer_ids.h:495
@ LAYER_NOTES_BACKGROUND
Definition layer_ids.h:497
@ LAYER_SELECTION_SHADOWS
Definition layer_ids.h:523
bool BoxHitTest(const VECTOR2I &aHitPoint, const BOX2I &aHittee, int aAccuracy)
Perform a point-to-box hit test.
KICOMMON_API void UnpackStroke(STROKE_PARAMS &aOutput, const types::StrokeAttributes &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API int UnpackDistance(const types::Distance &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackCustomProperties(google::protobuf::RepeatedPtrField< types::CustomProperty > *aOutput, const EDA_ITEM &aItem)
KICOMMON_API void PackDistance(types::Distance &aOutput, int aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackStroke(types::StrokeAttributes &aOutput, const STROKE_PARAMS &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void UnpackCustomProperties(const google::protobuf::RepeatedPtrField< types::CustomProperty > &aInput, EDA_ITEM &aItem)
#define _HKI(x)
Definition page_info.cpp:40
see class PGM_BASE
#define TYPE_HASH(x)
Macro to generate unique identifier for a type.
Definition property.h:74
@ PT_COORD
Coordinate expressed in distance units (mm/inch)
Definition property.h:65
@ PT_SIZE
Size expressed in distance units (mm/inch)
Definition property.h:63
#define REGISTER_TYPE(x)
Helper macro to map type hashes to names.
static struct SCH_TABLE_DESC _SCH_TABLE_DESC
LINE_STYLE
Dashed line types.
VECTOR2I end
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:227
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:70
@ SCH_TABLE_T
Definition typeinfo.h:161
@ SCH_TABLECELL_T
Definition typeinfo.h:162
@ SCH_LOCATE_ANY_T
Definition typeinfo.h:195
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708