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