KiCad PCB EDA Suite
Loading...
Searching...
No Matches
altium_parser_sch.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) 2020 Thomas Pointhuber <[email protected]>
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 <iostream>
26#include <unordered_map>
27#include <charconv>
28
29#include <base_units.h>
30#include <ki_exception.h>
31
32#include <wx/log.h>
33
37
38
39ALTIUM_SCH_RECORD ReadRecord( const std::map<wxString, wxString>& aProps )
40{
41 int recordId = ALTIUM_PROPS_UTILS::ReadInt( aProps, "RECORD", -1 );
42 return static_cast<ALTIUM_SCH_RECORD>( recordId );
43}
44
45
46constexpr int Altium2KiCadUnit( const int val, const int frac )
47{
48 constexpr double int_limit = ( std::numeric_limits<int>::max() - 10 ) / 2.54;
49
50 double dbase = 10 * schIUScale.MilsToIU( val );
51 double dfrac = schIUScale.MilsToIU( frac ) / 10000.0;
52
53 return KiROUND( std::clamp( ( dbase + dfrac ) / 10.0, -int_limit, int_limit ) ) * 10;
54}
55
56
57int ReadKiCadUnitFrac( const std::map<wxString, wxString>& aProps, const wxString& aKey )
58{
59 // a unit is stored using two fields, denoting the size in mils and a fraction size
60 int key = ALTIUM_PROPS_UTILS::ReadInt( aProps, aKey, 0 );
61 int keyFrac = ALTIUM_PROPS_UTILS::ReadInt( aProps, aKey + "_FRAC", 0 );
62 return Altium2KiCadUnit( key, keyFrac );
63}
64
65
66int ReadKiCadUnitFrac1( const std::map<wxString, wxString>& aProps, const wxString& aKey )
67{
68 // a unit is stored using two fields, denoting the size in mils and a fraction size
69 // Dunno why Altium invents different units for the same purpose
70 int key = ALTIUM_PROPS_UTILS::ReadInt( aProps, aKey, 0 );
71 int keyFrac = ALTIUM_PROPS_UTILS::ReadInt( aProps, aKey + "_FRAC1", 0 );
72 return Altium2KiCadUnit( key * 10, keyFrac );
73}
74
75
76int ReadOwnerIndex( const std::map<wxString, wxString>& aProperties )
77{
78 return ALTIUM_PROPS_UTILS::ReadInt( aProperties, "OWNERINDEX", ALTIUM_COMPONENT_NONE );
79}
80
81
82int ReadOwnerPartId( const std::map<wxString, wxString>& aProperties )
83{
84 return ALTIUM_PROPS_UTILS::ReadInt( aProperties, "OWNERPARTID", ALTIUM_COMPONENT_NONE );
85}
86
87
88template <typename T>
89T ReadEnum( const std::map<wxString, wxString>& aProps, const wxString& aKey, int aLower,
90 int aUpper, T aDefault )
91{
92 int value = ALTIUM_PROPS_UTILS::ReadInt( aProps, aKey, static_cast<int>( aDefault ) );
93
94 if( value < aLower || value > aUpper )
95 return aDefault;
96 else
97 return static_cast<T>( value );
98}
99
100
101ASCH_STORAGE_FILE::ASCH_STORAGE_FILE( const std::map<wxString, wxString>& aProps )
102{
103 filename = ALTIUM_PROPS_UTILS::ReadString( aProps, "NAME", "" );
104 size_t dataSize = ALTIUM_PROPS_UTILS::ReadInt( aProps, "DATA_LEN", 0 );
105
106 wxString hexData = ALTIUM_PROPS_UTILS::ReadString( aProps, "DATA", "" );
107 const size_t charCount = hexData.size();
108
109 if( charCount != dataSize * 2 )
110 {
111 THROW_IO_ERROR( wxString::Format( "Invalid binary file hex data size. Chars expected: %d, "
112 "hex string length: %d",
113 int( dataSize * 2 ), int( hexData.size() ) ) );
114 }
115
116 data.resize( dataSize );
117
118 char str[3] = { 0 };
119 uint8_t b = 0;
120 size_t outputId = 0;
121
122 for( size_t inputId = 1; inputId < charCount; inputId += 2 )
123 {
124 str[0] = (char) hexData[inputId - 1];
125 str[1] = (char) hexData[inputId];
126
127 std::from_chars( str, str + 2, b, 16 );
128 data[outputId] = b;
129
130 outputId++;
131 }
132}
133
134
136{
137 aReader.Skip( 5 );
138 filename = aReader.ReadWxString();
139 uint32_t dataSize = aReader.Read<uint32_t>();
140 data = aReader.ReadVector( dataSize );
141
142 if( aReader.HasParsingError() )
143 THROW_IO_ERROR( "Storage stream was not parsed correctly" );
144}
145
146
148{
149 aReader.Skip( 5 );
150 FileName = aReader.ReadWxString();
151 uint32_t dataSize = aReader.Read<uint32_t>();
152 Data = aReader.ReadVector( dataSize );
153
154 if( aReader.HasParsingError() )
155 THROW_IO_ERROR( "Additional stream was not parsed correctly" );
156}
157
158
159ASCH_SYMBOL::ASCH_SYMBOL( const std::map<wxString, wxString>& aProps )
160{
161 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::COMPONENT );
162
163 uniqueid = ALTIUM_PROPS_UTILS::ReadString( aProps, "UNIQUEID", "" );
165 libreference = ALTIUM_PROPS_UTILS::ReadString( aProps, "LIBREFERENCE", "" );
166 sourcelibraryname = ALTIUM_PROPS_UTILS::ReadString( aProps, "SOURCELIBRARYNAME", "" );
167 componentdescription = ALTIUM_PROPS_UTILS::ReadString( aProps, "COMPONENTDESCRIPTION", "" );
168
169 orientation = ALTIUM_PROPS_UTILS::ReadInt( aProps, "ORIENTATION", 0 );
170 isMirrored = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISMIRRORED", false );
171 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
172 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
173
174 partcount = ALTIUM_PROPS_UTILS::ReadInt( aProps, "PARTCOUNT", 0 );
175 displaymodecount = ALTIUM_PROPS_UTILS::ReadInt( aProps, "DISPLAYMODECOUNT", 0 );
176 m_indexInSheet = ALTIUM_PROPS_UTILS::ReadInt( aProps, "INDEXINSHEET", -1 );
177
178 // DISPLAYMODE may be a string. Leave displaymode at 0 in this case.
179 displaymode = 0;
180 wxString displayModeStr = ALTIUM_PROPS_UTILS::ReadString( aProps, "DISPLAYMODE", "" );
181
182 long v = 0;
183
184 if( displayModeStr.ToCLong( &v ) )
185 displaymode = int( v );
186}
187
188
189ASCH_TEMPLATE::ASCH_TEMPLATE( const std::map<wxString, wxString>& aProps ) :
190 ASCH_OWNER_INTERFACE( aProps )
191{
192 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::TEMPLATE );
193
194 filename = ALTIUM_PROPS_UTILS::ReadString( aProps, "FILENAME", "" );
195}
196
197
198ASCH_PIN::ASCH_PIN( const std::map<wxString, wxString>& aProps ) :
199 ASCH_OWNER_INTERFACE( aProps )
200{
201 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::PIN );
202
203 ownerpartdisplaymode = ALTIUM_PROPS_UTILS::ReadInt( aProps, "OWNERPARTDISPLAYMODE", 0 );
204
205 name = ALTIUM_PROPS_UTILS::ReadString( aProps, "NAME", "" );
206 text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
207 designator = ALTIUM_PROPS_UTILS::ReadString( aProps, "DESIGNATOR", "" );
208
209 int symbolOuterInt = ALTIUM_PROPS_UTILS::ReadInt( aProps, "SYMBOL_OUTER", 0 );
210 symbolOuter = ASCH_PIN_SYMBOL::FromInt( symbolOuterInt );
211
212 int symbolInnerInt = ALTIUM_PROPS_UTILS::ReadInt( aProps, "SYMBOL_INNER", 0 );
213 symbolInner = ASCH_PIN_SYMBOL::FromInt( symbolInnerInt );
214
215 int symbolOuterEdgeInt = ALTIUM_PROPS_UTILS::ReadInt( aProps, "SYMBOL_OUTEREDGE", 0 );
216 symbolOuterEdge = ASCH_PIN_SYMBOL::FromInt( symbolOuterEdgeInt );
217
218 int symbolInnerEdgeInt = ALTIUM_PROPS_UTILS::ReadInt( aProps, "SYMBOL_INNEREDGE", 0 );
219 symbolInnerEdge = ASCH_PIN_SYMBOL::FromInt( symbolInnerEdgeInt );
220
221 electrical = ReadEnum<ASCH_PIN_ELECTRICAL>( aProps, "ELECTRICAL", 0, 7,
223
224 int pinconglomerate = ALTIUM_PROPS_UTILS::ReadInt( aProps, "PINCONGLOMERATE", 0 );
225
226 orientation = static_cast<ASCH_RECORD_ORIENTATION>( pinconglomerate & 0x03 );
227 hidden = ( pinconglomerate & 0x04 ) != 0;
228 showPinName = ( pinconglomerate & 0x08 ) != 0;
229 showDesignator = ( pinconglomerate & 0x10 ) != 0;
230 // 0x20 is unknown
231 locked = ( pinconglomerate & 0x40 ) != 0;
232
233
234 int x = ALTIUM_PROPS_UTILS::ReadInt( aProps, "LOCATION.X", 0 );
235 int xfrac = ALTIUM_PROPS_UTILS::ReadInt( aProps, "LOCATION.X_FRAC", 0 );
236 int y = ALTIUM_PROPS_UTILS::ReadInt( aProps, "LOCATION.Y", 0 );
237 int yfrac = ALTIUM_PROPS_UTILS::ReadInt( aProps, "LOCATION.Y_FRAC", 0 );
238 location = VECTOR2I( Altium2KiCadUnit( x, xfrac ), -Altium2KiCadUnit( y, yfrac ) );
239
240 int p = ALTIUM_PROPS_UTILS::ReadInt( aProps, "PINLENGTH", 0 );
241 int pfrac = ALTIUM_PROPS_UTILS::ReadInt( aProps, "PINLENGTH_FRAC", 0 );
242 pinlength = Altium2KiCadUnit( p, pfrac );
243
244 // this code calculates the location as required by KiCad without rounding error attached
245 int kicadX = x;
246 int kicadXfrac = xfrac;
247 int kicadY = y;
248 int kicadYfrac = yfrac;
249
250 int offsetY = p;
251 int offsetYfrac = pfrac;
252
253 switch( orientation )
254 {
256 kicadX += offsetY;
257 kicadXfrac += offsetYfrac;
258 break;
259
261 kicadY += offsetY;
262 kicadYfrac += offsetYfrac;
263 break;
264
266 kicadX -= offsetY;
267 kicadXfrac -= offsetYfrac;
268 break;
269
271 kicadY -= offsetY;
272 kicadYfrac -= offsetYfrac;
273 break;
274
275 default:
276 wxLogWarning( "Pin has unexpected orientation" );
277 break;
278 }
279
280 kicadLocation = VECTOR2I( Altium2KiCadUnit( kicadX, kicadXfrac ),
281 -Altium2KiCadUnit( kicadY, kicadYfrac ) );
282}
283
284
285ASCH_OWNER_INTERFACE::ASCH_OWNER_INTERFACE( const std::map<wxString, wxString>& aProps )
286{
287 ownerindex = ReadOwnerIndex( aProps );
288 ownerpartid = ReadOwnerPartId( aProps );
289 ownerpartdisplaymode = ALTIUM_PROPS_UTILS::ReadInt( aProps, "OWNERPARTDISPLAYMODE", 0 );
290 indexinsheet = ALTIUM_PROPS_UTILS::ReadInt( aProps, "INDEXINSHEET", 0 );
291 IsNotAccesible = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISNOTACCESIBLE", false );
292}
293
294
295ASCH_FILL_INTERFACE::ASCH_FILL_INTERFACE( const std::map<wxString, wxString>& aProps )
296{
297 AreaColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "AREACOLOR", 0 );
298 IsSolid = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISSOLID", false );
299 IsTransparent = ALTIUM_PROPS_UTILS::ReadBool( aProps, "TRANSPARENT", false );
300}
301
302
303ASCH_BORDER_INTERFACE::ASCH_BORDER_INTERFACE( const std::map<wxString, wxString>& aProps )
304{
305 LineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" );
306
307 // Altium line width 0 means hairline. Since KiCad doesn't have a hairline, we
308 // represent it as a 1 mil line.
309 if( LineWidth == 0 )
310 LineWidth = schIUScale.MilsToIU( 1 );
311
312 Color = ALTIUM_PROPS_UTILS::ReadInt( aProps, "COLOR", 0 );
313}
314
315
316ASCH_LABEL::ASCH_LABEL( const std::map<wxString, wxString>& aProps ) :
317 ASCH_OWNER_INTERFACE( aProps )
318{
319 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::LABEL );
320
321 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
322 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
323
324 text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
325
326 textColor = 0;
327 fontId = ALTIUM_PROPS_UTILS::ReadInt( aProps, "FONTID", 0 );
328 isMirrored = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISMIRRORED", false );
329
330 justification = ReadEnum<ASCH_LABEL_JUSTIFICATION>( aProps, "JUSTIFICATION", 0, 8,
332
333 orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
335}
336
337
338ASCH_TEXT_FRAME::ASCH_TEXT_FRAME( const std::map<wxString, wxString>& aProps ) :
339 ASCH_OWNER_INTERFACE( aProps )
340{
341 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::NOTE
343
344 BottomLeft = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
345 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
346 TopRight = VECTOR2I( ReadKiCadUnitFrac( aProps, "CORNER.X" ),
347 -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) );
348
349 Location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
350 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
351 Size = VECTOR2I( ReadKiCadUnitFrac( aProps, "CORNER.X" ) - Location.x,
352 -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) - Location.y );
353
354 Text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
355 Text.Replace( "~1", "\n", true );
356
357 FontID = ALTIUM_PROPS_UTILS::ReadInt( aProps, "FONTID", 0 );
358 IsWordWrapped = ALTIUM_PROPS_UTILS::ReadBool( aProps, "WORDWRAP", false );
359 ShowBorder = ALTIUM_PROPS_UTILS::ReadBool( aProps, "SHOWBORDER", false );
360 TextMargin = ReadKiCadUnitFrac( aProps, "TEXTMARGIN" );
361
362 AreaColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "AREACOLOR", 0 );
363 BorderColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "COLOR", 0 );
364 TextColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "TEXTCOLOR", 0 );
365
366 BorderWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" );
367 isSolid = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISSOLID", false );
368
369 Alignment = ReadEnum<ASCH_TEXT_FRAME_ALIGNMENT>( aProps, "ALIGNMENT", 1, 3,
371}
372
373
374ASCH_NOTE::ASCH_NOTE( const std::map<wxString, wxString>& aProperties ) :
375 ASCH_TEXT_FRAME( aProperties )
376{
377 wxASSERT( ReadRecord( aProperties ) == ALTIUM_SCH_RECORD::NOTE );
378
379 author = ALTIUM_PROPS_UTILS::ReadString( aProperties, "AUTHOR", "" );
380}
381
382
383ASCH_BEZIER::ASCH_BEZIER( const std::map<wxString, wxString>& aProps ) :
384 ASCH_OWNER_INTERFACE( aProps ),
385 ASCH_BORDER_INTERFACE( aProps )
386{
387 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::BEZIER );
388
389 int locationCount = ALTIUM_PROPS_UTILS::ReadInt( aProps, "LOCATIONCOUNT", 0 );
390
391 for( int i = 1; i <= locationCount; i++ )
392 {
393 const wxString si = std::to_string( i );
394 points.emplace_back( ReadKiCadUnitFrac( aProps, "X" + si ),
395 -ReadKiCadUnitFrac( aProps, "Y" + si ) );
396 }
397}
398
399
400ASCH_POLYLINE::ASCH_POLYLINE( const std::map<wxString, wxString>& aProps ) :
401 ASCH_OWNER_INTERFACE( aProps ),
402 ASCH_BORDER_INTERFACE( aProps )
403{
404 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::POLYLINE );
405
406 int locationCount = ALTIUM_PROPS_UTILS::ReadInt( aProps, "LOCATIONCOUNT", 0 );
407
408 for( int i = 1; i <= locationCount; i++ )
409 {
410 const wxString si = std::to_string( i );
411 Points.emplace_back( ReadKiCadUnitFrac( aProps, "X" + si ),
412 -ReadKiCadUnitFrac( aProps, "Y" + si ) );
413 }
414
415 auto lineStyleExt = ReadEnum( aProps, "LINESTYLEEXT", 0, 3, ASCH_POLYLINE_LINESTYLE::SOLID );
416 LineStyle = ReadEnum( aProps, "LINESTYLE", 0, 3, lineStyleExt ); // overwrite if present.
417}
418
419
420ASCH_POLYGON::ASCH_POLYGON( const std::map<wxString, wxString>& aProps ) :
421 ASCH_OWNER_INTERFACE( aProps ),
422 ASCH_FILL_INTERFACE( aProps ),
423 ASCH_BORDER_INTERFACE( aProps )
424{
425 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::POLYGON );
426
427 int locationCount = ALTIUM_PROPS_UTILS::ReadInt( aProps, "LOCATIONCOUNT", 0 );
428
429 for( int i = 1; i <= locationCount; i++ )
430 {
431 const wxString si = std::to_string( i );
432 points.emplace_back( ReadKiCadUnitFrac( aProps, "X" + si ),
433 -ReadKiCadUnitFrac( aProps, "Y" + si ) );
434 }
435}
436
437
438ASCH_ROUND_RECTANGLE::ASCH_ROUND_RECTANGLE( const std::map<wxString, wxString>& aProps ) :
439 ASCH_OWNER_INTERFACE( aProps ),
440 ASCH_FILL_INTERFACE( aProps ),
441 ASCH_BORDER_INTERFACE( aProps )
442{
443 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::ROUND_RECTANGLE );
444
445 BottomLeft = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
446 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
447 TopRight = VECTOR2I( ReadKiCadUnitFrac( aProps, "CORNER.X" ),
448 -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) );
449
450 CornerRadius = VECTOR2I( ReadKiCadUnitFrac( aProps, "CORNERXRADIUS" ),
451 -ReadKiCadUnitFrac( aProps, "CORNERYRADIUS" ) );
452}
453
454
455ASCH_ARC::ASCH_ARC( const std::map<wxString, wxString>& aProps ) :
456 ASCH_OWNER_INTERFACE( aProps ),
457 ASCH_BORDER_INTERFACE( aProps ),
458 ASCH_FILL_INTERFACE( aProps )
459{
461 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::ARC || m_IsElliptical );
462
463 m_Center = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
464 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
465 m_Radius = ReadKiCadUnitFrac( aProps, "RADIUS" );
467
468 if( m_IsElliptical )
469 m_SecondaryRadius = ReadKiCadUnitFrac( aProps, "SECONDARYRADIUS" );
470
471 m_StartAngle = ALTIUM_PROPS_UTILS::ReadDouble( aProps, "STARTANGLE", 0 );
472 m_EndAngle = ALTIUM_PROPS_UTILS::ReadDouble( aProps, "ENDANGLE", 0 );
473}
474
475
476ASCH_PIECHART::ASCH_PIECHART( const std::map<wxString, wxString>& aProps ) :
477 ASCH_ARC( aProps )
478{}
479
480
481ASCH_ELLIPSE::ASCH_ELLIPSE( const std::map<wxString, wxString>& aProps ) :
482 ASCH_OWNER_INTERFACE( aProps ),
483 ASCH_FILL_INTERFACE( aProps ),
484 ASCH_BORDER_INTERFACE( aProps )
485{
486 ALTIUM_SCH_RECORD record = ReadRecord( aProps );
487
488 wxASSERT( record == ALTIUM_SCH_RECORD::ELLIPSE || record == ALTIUM_SCH_RECORD::ELLIPTICAL_ARC );
489
490 Center = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
491 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
492
493 Radius = ReadKiCadUnitFrac( aProps, "RADIUS" );
494 SecondaryRadius = ReadKiCadUnitFrac( aProps, "SECONDARYRADIUS" );
495}
496
497
498ASCH_LINE::ASCH_LINE( const std::map<wxString, wxString>& aProps ) :
499 ASCH_OWNER_INTERFACE( aProps ),
500 ASCH_BORDER_INTERFACE( aProps )
501{
502 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::LINE );
503
504 point1 = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
505 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
506 point2 = VECTOR2I( ReadKiCadUnitFrac( aProps, "CORNER.X" ),
507 -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) );
508
509 auto lineStyleExt = ReadEnum( aProps, "LINESTYLEEXT", 0, 3, ASCH_POLYLINE_LINESTYLE::SOLID );
510 LineStyle = ReadEnum( aProps, "LINESTYLE", 0, 3, lineStyleExt ); // overwrite if present.
511}
512
513
514ASCH_SIGNAL_HARNESS::ASCH_SIGNAL_HARNESS( const std::map<wxString, wxString>& aProps ) :
515 ASCH_OWNER_INTERFACE( aProps )
516{
517 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SIGNAL_HARNESS );
518
519
520 int locationCount = ALTIUM_PROPS_UTILS::ReadInt( aProps, "LOCATIONCOUNT", 0 );
521
522 for( int i = 1; i <= locationCount; i++ )
523 {
524 const wxString si = std::to_string( i );
525 points.emplace_back( ReadKiCadUnitFrac( aProps, "X" + si ),
526 -ReadKiCadUnitFrac( aProps, "Y" + si ) );
527 }
528
529 color = ALTIUM_PROPS_UTILS::ReadInt( aProps, "COLOR", 0 );
530 lineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" );
531}
532
533
534ASCH_HARNESS_CONNECTOR::ASCH_HARNESS_CONNECTOR( const std::map<wxString, wxString>& aProps ) :
535 ASCH_OWNER_INTERFACE( aProps )
536{
537 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::HARNESS_CONNECTOR );
538
539
540 m_location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
541 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
542 m_size = VECTOR2I( ReadKiCadUnitFrac( aProps, "XSIZE" ), ReadKiCadUnitFrac( aProps, "YSIZE" ) );
543
544 m_color = ALTIUM_PROPS_UTILS::ReadInt( aProps, "COLOR", 0 );
545 m_areaColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "AREACOLOR", 0 );
546
547 indexinsheet = 0;
548 m_lineWidth = 0;;
549 m_primaryConnectionPosition = ALTIUM_PROPS_UTILS::ReadInt( aProps, "PRIMARYCONNECTIONPOSITION", 0 );
551
552}
553
554
555ASCH_HARNESS_ENTRY::ASCH_HARNESS_ENTRY( const std::map<wxString, wxString>& aProps ) :
556 ASCH_OWNER_INTERFACE( aProps )
557{
558 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::HARNESS_ENTRY );
559
560 // use SCH_IO_ALTIUM::m_harnessEntryParent instead, because this property sometimes
561 // does not exist in altium file!
562 // ownerindex = ReadOwnerIndex( aProps );
563
564
565 DistanceFromTop = ReadKiCadUnitFrac1( aProps, "DISTANCEFROMTOP" );
566
568
569 Name = ALTIUM_PROPS_UTILS::ReadString( aProps, "NAME", "" );
570
571 OwnerIndexAdditionalList = ALTIUM_PROPS_UTILS::ReadBool( aProps, "OWNERINDEXADDITIONALLIST", true );
572
573 Color = ALTIUM_PROPS_UTILS::ReadInt( aProps, "COLOR", 0 );
574 AreaColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "AREACOLOR", 0 );
575 TextColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "TEXTCOLOR", 0 );
576 TextFontID = ALTIUM_PROPS_UTILS::ReadInt( aProps, "TEXTFONTID", 0 );
577 TextStyle = 0;
578}
579
580
581ASCH_HARNESS_TYPE::ASCH_HARNESS_TYPE( const std::map<wxString, wxString>& aProps ) :
582 ASCH_OWNER_INTERFACE( aProps )
583{
584 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::HARNESS_TYPE );
585
586 //ownerindex = ReadOwnerIndex( aProps ); // use SCH_IO_ALTIUM::m_harnessEntryParent instead!
587
588 Text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
589
590 Location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
591 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
592
593 IsHidden = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISHIDDEN", false );
594 OwnerIndexAdditionalList = ALTIUM_PROPS_UTILS::ReadBool( aProps, "OWNERINDEXADDITIONALLIST", true );
595
596 Color = ALTIUM_PROPS_UTILS::ReadInt( aProps, "COLOR", 0 );
597 FontID = ALTIUM_PROPS_UTILS::ReadInt( aProps, "TEXTFONTID", 0 );
598}
599
600
601ASCH_RECTANGLE::ASCH_RECTANGLE( const std::map<wxString, wxString>& aProps ) :
602 ASCH_OWNER_INTERFACE( aProps ),
603 ASCH_FILL_INTERFACE( aProps ),
604 ASCH_BORDER_INTERFACE( aProps )
605{
606 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::RECTANGLE );
607
608 BottomLeft = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
609 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
610 TopRight = VECTOR2I( ReadKiCadUnitFrac( aProps, "CORNER.X" ),
611 -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) );
612
613}
614
615
616ASCH_SHEET_SYMBOL::ASCH_SHEET_SYMBOL( const std::map<wxString, wxString>& aProps ) :
617 ASCH_OWNER_INTERFACE( aProps )
618{
619 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SHEET_SYMBOL );
620
621 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
622 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
623 size = VECTOR2I( ReadKiCadUnitFrac( aProps, "XSIZE" ),
624 ReadKiCadUnitFrac( aProps, "YSIZE" ) );
625
626 isSolid = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISSOLID", false );
627
628 color = ALTIUM_PROPS_UTILS::ReadInt( aProps, "COLOR", 0 );
629 areacolor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "AREACOLOR", 0 );
630}
631
632
633ASCH_SHEET_ENTRY::ASCH_SHEET_ENTRY( const std::map<wxString, wxString>& aProps ) :
634 ASCH_OWNER_INTERFACE( aProps )
635{
636 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SHEET_ENTRY );
637
638 // some magic, because it stores those infos in a different unit??
639 distanceFromTop = ReadKiCadUnitFrac1( aProps, "DISTANCEFROMTOP" );
640
642
643 name = ALTIUM_PROPS_UTILS::ReadString( aProps, "NAME", "" );
644 harnessType = ALTIUM_PROPS_UTILS::ReadString( aProps, "HARNESSTYPE", "" );
645
648}
649
650
651ASCH_POWER_PORT::ASCH_POWER_PORT( const std::map<wxString, wxString>& aProps ) :
652 ASCH_OWNER_INTERFACE( aProps )
653{
654 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::POWER_PORT );
655
656
657 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
658 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
659
660 orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
662
663 text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
664 showNetName = ALTIUM_PROPS_UTILS::ReadBool( aProps, "SHOWNETNAME", true );
665
666 style = ReadEnum<ASCH_POWER_PORT_STYLE>( aProps, "STYLE", 0, 10,
668}
669
670
671ASCH_PORT::ASCH_PORT( const std::map<wxString, wxString>& aProps ) :
672 ASCH_OWNER_INTERFACE( aProps )
673{
674 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::PORT );
675
676
677 Location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
678 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
679
680 Name = ALTIUM_PROPS_UTILS::ReadString( aProps, "NAME", "" );
681 HarnessType = ALTIUM_PROPS_UTILS::ReadString( aProps, "HARNESSTYPE", "" );
682
683 Width = ReadKiCadUnitFrac( aProps, "WIDTH" );
684 Height = ReadKiCadUnitFrac( aProps, "HEIGHT" );
685
688
689 AreaColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "AREACOLOR", 0 );
690 Color = ALTIUM_PROPS_UTILS::ReadInt( aProps, "COLOR", 0 );
691 FontID = ALTIUM_PROPS_UTILS::ReadInt( aProps, "TEXTFONTID", 0 );
692 TextColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "TEXTCOLOR", 0 );
693
695}
696
697
698ASCH_NO_ERC::ASCH_NO_ERC( const std::map<wxString, wxString>& aProps )
699{
700 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::NO_ERC );
701
702 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
703 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
704
705 isActive = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISACTIVE", true );
706 suppressAll = ALTIUM_PROPS_UTILS::ReadInt( aProps, "SUPPRESSALL", true );
707}
708
709
710ASCH_NET_LABEL::ASCH_NET_LABEL( const std::map<wxString, wxString>& aProps ) :
711 ASCH_OWNER_INTERFACE( aProps )
712{
713 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::NET_LABEL );
714
715 text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
716
717 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
718 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
719
720 justification = ReadEnum<ASCH_LABEL_JUSTIFICATION>( aProps, "JUSTIFICATION", 0, 8,
722
723 orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
725}
726
727
728ASCH_BUS::ASCH_BUS( const std::map<wxString, wxString>& aProps ) :
729 ASCH_OWNER_INTERFACE( aProps )
730{
731 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::BUS );
732
733 int locationcount = ALTIUM_PROPS_UTILS::ReadInt( aProps, "LOCATIONCOUNT", 0 );
734
735 for( int i = 1; i <= locationcount; i++ )
736 {
737 const wxString si = std::to_string( i );
738 points.emplace_back( ReadKiCadUnitFrac( aProps, "X" + si ),
739 -ReadKiCadUnitFrac( aProps, "Y" + si ) );
740 }
741
742 lineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" );
743}
744
745
746ASCH_WIRE::ASCH_WIRE( const std::map<wxString, wxString>& aProps ) :
747 ASCH_OWNER_INTERFACE( aProps )
748{
749 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::WIRE );
750
751 int locationcount = ALTIUM_PROPS_UTILS::ReadInt( aProps, "LOCATIONCOUNT", 0 );
752
753 for( int i = 1; i <= locationcount; i++ )
754 {
755 const wxString si = std::to_string( i );
756 points.emplace_back( ReadKiCadUnitFrac( aProps, "X" + si ),
757 -ReadKiCadUnitFrac( aProps, "Y" + si ) );
758 }
759
760 lineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" );
761}
762
763
764ASCH_JUNCTION::ASCH_JUNCTION( const std::map<wxString, wxString>& aProps ) :
765 ASCH_OWNER_INTERFACE( aProps )
766{
767 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::JUNCTION );
768
769
770 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
771 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
772}
773
774
775ASCH_IMAGE::ASCH_IMAGE( const std::map<wxString, wxString>& aProps ) :
776 ASCH_OWNER_INTERFACE( aProps ),
777 ASCH_BORDER_INTERFACE( aProps )
778{
779 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::IMAGE );
780
781 filename = ALTIUM_PROPS_UTILS::ReadString( aProps, "FILENAME", "" );
782
783 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
784 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
785 corner = VECTOR2I( ReadKiCadUnitFrac( aProps, "CORNER.X" ),
786 -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) );
787
788 embedimage = ALTIUM_PROPS_UTILS::ReadBool( aProps, "EMBEDIMAGE", false );
789 keepaspect = ALTIUM_PROPS_UTILS::ReadBool( aProps, "KEEPASPECT", false );
790}
791
792
793ASCH_SHEET_FONT::ASCH_SHEET_FONT( const std::map<wxString, wxString>& aProps, int aId ) :
794 ASCH_OWNER_INTERFACE( aProps )
795{
796 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SHEET );
797
798 const wxString sid = std::to_string( aId );
799
800 FontName = ALTIUM_PROPS_UTILS::ReadString( aProps, "FONTNAME" + sid, "" );
801
802 Size = ReadKiCadUnitFrac( aProps, "SIZE" + sid );
803 Rotation = ALTIUM_PROPS_UTILS::ReadInt( aProps, "ROTATION" + sid, 0 );
804
805 Italic = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ITALIC" + sid, false );
806 Bold = ALTIUM_PROPS_UTILS::ReadBool( aProps, "BOLD" + sid, false );
807 Underline = ALTIUM_PROPS_UTILS::ReadBool( aProps, "UNDERLINE" + sid, false );
808
809 AreaColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "AREACOLOR" + sid, 0 );
810}
811
812
814{
815 // From: https://github.com/vadmium/python-altium/blob/master/format.md#sheet
816 switch( aSheetSize )
817 {
818 default:
819 case ASCH_SHEET_SIZE::A4: return { 1150, 760 };
820 case ASCH_SHEET_SIZE::A3: return { 1550, 1110 };
821 case ASCH_SHEET_SIZE::A2: return { 2230, 1570 };
822 case ASCH_SHEET_SIZE::A1: return { 3150, 2230 };
823 case ASCH_SHEET_SIZE::A0: return { 4460, 3150 };
824 case ASCH_SHEET_SIZE::A: return { 950, 750 };
825 case ASCH_SHEET_SIZE::B: return { 1500, 950 };
826 case ASCH_SHEET_SIZE::C: return { 2000, 1500 };
827 case ASCH_SHEET_SIZE::D: return { 3200, 2000 };
828 case ASCH_SHEET_SIZE::E: return { 4200, 3200 };
829 case ASCH_SHEET_SIZE::LETTER: return { 1100, 850 };
830 case ASCH_SHEET_SIZE::LEGAL: return { 1400, 850 };
831 case ASCH_SHEET_SIZE::TABLOID: return { 1700, 1100 };
832 case ASCH_SHEET_SIZE::ORCAD_A: return { 990, 790 };
833 case ASCH_SHEET_SIZE::ORCAD_B: return { 1540, 990 };
834 case ASCH_SHEET_SIZE::ORCAD_C: return { 2060, 1560 };
835 case ASCH_SHEET_SIZE::ORCAD_D: return { 3260, 2060 };
836 case ASCH_SHEET_SIZE::ORCAD_E: return { 4280, 3280 };
837 }
838}
839
840
841ASCH_SHEET::ASCH_SHEET( const std::map<wxString, wxString>& aProps ) :
842 ASCH_OWNER_INTERFACE( aProps )
843{
844 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SHEET );
845
846 int fontidcount = ALTIUM_PROPS_UTILS::ReadInt( aProps, "FONTIDCOUNT", 0 );
847
848 for( int i = 1; i <= fontidcount; i++ )
849 fonts.emplace_back( aProps, i );
850
851 useCustomSheet = ALTIUM_PROPS_UTILS::ReadBool( aProps, "USECUSTOMSHEET", false );
852
853 customSize = VECTOR2I( ReadKiCadUnitFrac( aProps, "CUSTOMX" ),
854 ReadKiCadUnitFrac( aProps, "CUSTOMY" ) );
855
856 sheetSize = ReadEnum<ASCH_SHEET_SIZE>( aProps, "SHEETSTYLE", 0, 17, ASCH_SHEET_SIZE::A4 );
858 aProps, "WORKSPACEORIENTATION", 0, 1, ASCH_SHEET_WORKSPACEORIENTATION::LANDSCAPE );
859}
860
861
862ASCH_SHEET_NAME::ASCH_SHEET_NAME( const std::map<wxString, wxString>& aProps ) :
863 ASCH_OWNER_INTERFACE( aProps )
864{
865 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SHEET_NAME );
866
867 text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
868
869 orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
871
872 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
873 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
874
875 isHidden = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISHIDDEN", false );
876}
877
878
879ASCH_FILE_NAME::ASCH_FILE_NAME( const std::map<wxString, wxString>& aProps ) :
880 ASCH_OWNER_INTERFACE( aProps )
881{
882 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::FILE_NAME );
883
884 text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
885
886 orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
888
889 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
890 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
891
892 isHidden = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISHIDDEN", false );
893}
894
895
896ASCH_DESIGNATOR::ASCH_DESIGNATOR( const std::map<wxString, wxString>& aProps ) :
897 ASCH_OWNER_INTERFACE( aProps )
898{
899 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::DESIGNATOR );
900
901 name = ALTIUM_PROPS_UTILS::ReadString( aProps, "NAME", "" );
902 text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
903 fontId = ALTIUM_PROPS_UTILS::ReadInt( aProps, "FONTID", 0 );
904
905 justification = ReadEnum<ASCH_LABEL_JUSTIFICATION>( aProps, "JUSTIFICATION", 0, 8,
907
908 orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
910
911 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
912 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
913}
914
915
916ASCH_IMPLEMENTATION::ASCH_IMPLEMENTATION( const std::map<wxString, wxString>& aProps ) :
917 ASCH_OWNER_INTERFACE( aProps )
918{
919 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::IMPLEMENTATION );
920
922 name = ALTIUM_PROPS_UTILS::ReadString( aProps, "MODELNAME", "" );
923 type = ALTIUM_PROPS_UTILS::ReadString( aProps, "MODELTYPE", "" );
924 libname = ALTIUM_PROPS_UTILS::ReadString( aProps, "MODELDATAFILE0", "" );
925 description = ALTIUM_PROPS_UTILS::ReadString( aProps, "DESCRIPTION", "" );
926 isCurrent = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISCURRENT", false );
927}
928
929
930ASCH_IMPLEMENTATION_LIST::ASCH_IMPLEMENTATION_LIST( const std::map<wxString, wxString>& aProps ) :
931 ASCH_OWNER_INTERFACE( aProps )
932{
933 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::IMPLEMENTATION_LIST );
934}
935
936
937ASCH_BUS_ENTRY::ASCH_BUS_ENTRY( const std::map<wxString, wxString>& aProps ) :
938 ASCH_OWNER_INTERFACE( aProps )
939{
940 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::BUS_ENTRY );
941
942 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
943 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
944 corner = VECTOR2I( ReadKiCadUnitFrac( aProps, "CORNER.X" ),
945 -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) );
946}
947
948
949ASCH_PARAMETER::ASCH_PARAMETER( const std::map<wxString, wxString>& aProps ) :
950 ASCH_OWNER_INTERFACE( aProps )
951{
952 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::PARAMETER );
953
954 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
955 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
956
957 justification = ReadEnum<ASCH_LABEL_JUSTIFICATION>( aProps, "JUSTIFICATION", 0, 8,
959
960 orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
962
963 name = ALTIUM_PROPS_UTILS::ReadString( aProps, "NAME", "" );
964 text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
965
966 isHidden = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISHIDDEN", false );
967 isMirrored = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISMIRRORED", false );
968 isShowName = ALTIUM_PROPS_UTILS::ReadBool( aProps, "SHOWNAME", false );
969
970 fontId = ALTIUM_PROPS_UTILS::ReadInt( aProps, "FONTID", 0 );
971}
972
973
974ASCH_HYPERLINK::ASCH_HYPERLINK( const std::map<wxString, wxString>& aProps ) :
975 ASCH_LABEL( aProps )
976{
977 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::HYPERLINK );
978
979 url = ALTIUM_PROPS_UTILS::ReadString( aProps, "URL", "" );
980}
int ReadOwnerPartId(const std::map< wxString, wxString > &aProperties)
int ReadOwnerIndex(const std::map< wxString, wxString > &aProperties)
T ReadEnum(const std::map< wxString, wxString > &aProps, const wxString &aKey, int aLower, int aUpper, T aDefault)
constexpr int Altium2KiCadUnit(const int val, const int frac)
VECTOR2I ASchSheetGetSize(ASCH_SHEET_SIZE aSheetSize)
int ReadKiCadUnitFrac1(const std::map< wxString, wxString > &aProps, const wxString &aKey)
int ReadKiCadUnitFrac(const std::map< wxString, wxString > &aProps, const wxString &aKey)
ALTIUM_SCH_RECORD ReadRecord(const std::map< wxString, wxString > &aProps)
ALTIUM_SCH_RECORD
ASCH_RECORD_ORIENTATION
const int ALTIUM_COMPONENT_NONE
ASCH_SHEET_SIZE
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:114
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:990
void Skip(size_t aLength)
std::vector< char > ReadVector(size_t aSize)
static int ReadInt(const std::map< wxString, wxString > &aProps, const wxString &aKey, int aDefault)
static bool ReadBool(const std::map< wxString, wxString > &aProps, const wxString &aKey, bool aDefault)
static wxString ReadString(const std::map< wxString, wxString > &aProps, const wxString &aKey, const wxString &aDefault)
static double ReadDouble(const std::map< wxString, wxString > &aProps, const wxString &aKey, double aDefault)
static PTYPE FromInt(int aInt)
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
ASCH_ADDITIONAL_FILE(ALTIUM_BINARY_PARSER &aReader)
std::vector< char > Data
ASCH_ARC(const std::map< wxString, wxString > &aProps)
double m_StartAngle
VECTOR2I m_Center
ASCH_BEZIER(const std::map< wxString, wxString > &aProps)
std::vector< VECTOR2I > points
ASCH_BORDER_INTERFACE(const std::map< wxString, wxString > &aProps)
ASCH_BUS_ENTRY(const std::map< wxString, wxString > &aProps)
VECTOR2I corner
VECTOR2I location
ASCH_BUS(const std::map< wxString, wxString > &aProps)
std::vector< VECTOR2I > points
ASCH_LABEL_JUSTIFICATION justification
ASCH_DESIGNATOR(const std::map< wxString, wxString > &aProps)
ASCH_RECORD_ORIENTATION orientation
ASCH_ELLIPSE(const std::map< wxString, wxString > &aProps)
ASCH_FILE_NAME(const std::map< wxString, wxString > &aProps)
ASCH_RECORD_ORIENTATION orientation
ASCH_FILL_INTERFACE(const std::map< wxString, wxString > &aProps)
ASCH_HARNESS_CONNECTOR(const std::map< wxString, wxString > &aProps)
ASCH_SHEET_ENTRY_SIDE m_harnessConnectorSide
ASCH_HARNESS_ENTRY(const std::map< wxString, wxString > &aProps)
int TextStyle
int TextFontID
int AreaColor
int DistanceFromTop
ASCH_SHEET_ENTRY_SIDE Side
int TextColor
int Color
wxString Name
bool OwnerIndexAdditionalList
ASCH_HARNESS_TYPE(const std::map< wxString, wxString > &aProps)
ASCH_IMAGE(const std::map< wxString, wxString > &aProps)
ASCH_IMPLEMENTATION_LIST(const std::map< wxString, wxString > &aProps)
ASCH_IMPLEMENTATION(const std::map< wxString, wxString > &aProps)
ASCH_JUNCTION(const std::map< wxString, wxString > &aProps)
ASCH_RECORD_ORIENTATION orientation
ASCH_LABEL(const std::map< wxString, wxString > &aProps)
ASCH_LABEL_JUSTIFICATION justification
ASCH_POLYLINE_LINESTYLE LineStyle
ASCH_LINE(const std::map< wxString, wxString > &aProps)
ASCH_LABEL_JUSTIFICATION justification
ASCH_RECORD_ORIENTATION orientation
ASCH_NET_LABEL(const std::map< wxString, wxString > &aProps)
ASCH_NOTE(const std::map< wxString, wxString > &aProperties)
ASCH_NO_ERC(const std::map< wxString, wxString > &aProps)
ASCH_OWNER_INTERFACE(const std::map< wxString, wxString > &aProps)
ASCH_PARAMETER(const std::map< wxString, wxString > &aProps)
ASCH_RECORD_ORIENTATION orientation
ASCH_LABEL_JUSTIFICATION justification
ASCH_PIECHART(const std::map< wxString, wxString > &aProps)
VECTOR2I location
ASCH_PIN_SYMBOL::PTYPE symbolOuterEdge
VECTOR2I kicadLocation
wxString designator
ASCH_PIN_SYMBOL::PTYPE symbolOuter
ASCH_PIN_ELECTRICAL electrical
ASCH_PIN_SYMBOL::PTYPE symbolInner
ASCH_PIN_SYMBOL::PTYPE symbolInnerEdge
ASCH_RECORD_ORIENTATION orientation
ASCH_PIN(const std::map< wxString, wxString > &aProps)
std::vector< VECTOR2I > points
ASCH_POLYGON(const std::map< wxString, wxString > &aProps)
ASCH_POLYLINE(const std::map< wxString, wxString > &aProps)
ASCH_POLYLINE_LINESTYLE LineStyle
std::vector< VECTOR2I > Points
VECTOR2I Location
ASCH_PORT_IOTYPE IOtype
ASCH_PORT(const std::map< wxString, wxString > &aProps)
wxString HarnessType
ASCH_PORT_ALIGNMENT m_align
ASCH_PORT_STYLE Style
ASCH_POWER_PORT(const std::map< wxString, wxString > &aProps)
ASCH_POWER_PORT_STYLE style
ASCH_RECORD_ORIENTATION orientation
ASCH_RECTANGLE(const std::map< wxString, wxString > &aProps)
ASCH_ROUND_RECTANGLE(const std::map< wxString, wxString > &aProps)
wxString name
int distanceFromTop
ASCH_SHEET_ENTRY(const std::map< wxString, wxString > &aProps)
ASCH_SHEET_ENTRY_SIDE side
ASCH_PORT_IOTYPE iotype
wxString harnessType
ASCH_PORT_STYLE style
ASCH_SHEET_FONT(const std::map< wxString, wxString > &aProps, int aId)
ASCH_SHEET_NAME(const std::map< wxString, wxString > &aProps)
ASCH_RECORD_ORIENTATION orientation
ASCH_SHEET_SYMBOL(const std::map< wxString, wxString > &aProps)
ASCH_SHEET_SIZE sheetSize
ASCH_SHEET_WORKSPACEORIENTATION sheetOrientation
VECTOR2I customSize
ASCH_SHEET(const std::map< wxString, wxString > &aProps)
std::vector< ASCH_SHEET_FONT > fonts
std::vector< VECTOR2I > points
ASCH_SIGNAL_HARNESS(const std::map< wxString, wxString > &aProps)
std::vector< char > data
ASCH_STORAGE_FILE(const std::map< wxString, wxString > &aProps)
wxString componentdescription
ASCH_SYMBOL(const std::map< wxString, wxString > &aProps)
wxString libreference
wxString sourcelibraryname
ASCH_TEMPLATE(const std::map< wxString, wxString > &aProps)
ASCH_TEXT_FRAME_ALIGNMENT Alignment
ASCH_TEXT_FRAME(const std::map< wxString, wxString > &aProps)
ASCH_WIRE(const std::map< wxString, wxString > &aProps)
std::vector< VECTOR2I > points
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695