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 (C) 2022-2024 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( Clamp<double>( -int_limit, ( dbase + dfrac ) / 10.0, 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
164 libreference = ALTIUM_PROPS_UTILS::ReadString( aProps, "LIBREFERENCE", "" );
165 sourcelibraryname = ALTIUM_PROPS_UTILS::ReadString( aProps, "SOURCELIBRARYNAME", "" );
166 componentdescription = ALTIUM_PROPS_UTILS::ReadString( aProps, "COMPONENTDESCRIPTION", "" );
167
168 orientation = ALTIUM_PROPS_UTILS::ReadInt( aProps, "ORIENTATION", 0 );
169 isMirrored = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISMIRRORED", false );
170 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
171 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
172
173 partcount = ALTIUM_PROPS_UTILS::ReadInt( aProps, "PARTCOUNT", 0 );
174 displaymodecount = ALTIUM_PROPS_UTILS::ReadInt( aProps, "DISPLAYMODECOUNT", 0 );
175 m_indexInSheet = ALTIUM_PROPS_UTILS::ReadInt( aProps, "INDEXINSHEET", -1 );
176
177 // DISPLAYMODE may be a string. Leave displaymode at 0 in this case.
178 displaymode = 0;
179 wxString displayModeStr = ALTIUM_PROPS_UTILS::ReadString( aProps, "DISPLAYMODE", "" );
180
181 long v = 0;
182
183 if( displayModeStr.ToCLong( &v ) )
184 displaymode = int( v );
185}
186
187
188ASCH_TEMPLATE::ASCH_TEMPLATE( const std::map<wxString, wxString>& aProps ) :
189 ASCH_OWNER_INTERFACE( aProps )
190{
191 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::TEMPLATE );
192
193 filename = ALTIUM_PROPS_UTILS::ReadString( aProps, "FILENAME", "" );
194}
195
196
197ASCH_PIN::ASCH_PIN( const std::map<wxString, wxString>& aProps ) :
198 ASCH_OWNER_INTERFACE( aProps )
199{
200 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::PIN );
201
202 ownerpartdisplaymode = ALTIUM_PROPS_UTILS::ReadInt( aProps, "OWNERPARTDISPLAYMODE", 0 );
203
204 name = ALTIUM_PROPS_UTILS::ReadString( aProps, "NAME", "" );
205 text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
206 designator = ALTIUM_PROPS_UTILS::ReadString( aProps, "DESIGNATOR", "" );
207
208 int symbolOuterInt = ALTIUM_PROPS_UTILS::ReadInt( aProps, "SYMBOL_OUTER", 0 );
209 symbolOuter = ASCH_PIN_SYMBOL::FromInt( symbolOuterInt );
210
211 int symbolInnerInt = ALTIUM_PROPS_UTILS::ReadInt( aProps, "SYMBOL_INNER", 0 );
212 symbolInner = ASCH_PIN_SYMBOL::FromInt( symbolInnerInt );
213
214 int symbolOuterEdgeInt = ALTIUM_PROPS_UTILS::ReadInt( aProps, "SYMBOL_OUTEREDGE", 0 );
215 symbolOuterEdge = ASCH_PIN_SYMBOL::FromInt( symbolOuterEdgeInt );
216
217 int symbolInnerEdgeInt = ALTIUM_PROPS_UTILS::ReadInt( aProps, "SYMBOL_INNEREDGE", 0 );
218 symbolInnerEdge = ASCH_PIN_SYMBOL::FromInt( symbolInnerEdgeInt );
219
220 electrical = ReadEnum<ASCH_PIN_ELECTRICAL>( aProps, "ELECTRICAL", 0, 7,
221 ASCH_PIN_ELECTRICAL::INPUT );
222
223 int pinconglomerate = ALTIUM_PROPS_UTILS::ReadInt( aProps, "PINCONGLOMERATE", 0 );
224
225 orientation = static_cast<ASCH_RECORD_ORIENTATION>( pinconglomerate & 0x03 );
226 hidden = ( pinconglomerate & 0x04 ) != 0;
227 showPinName = ( pinconglomerate & 0x08 ) != 0;
228 showDesignator = ( pinconglomerate & 0x10 ) != 0;
229 // 0x20 is unknown
230 locked = ( pinconglomerate & 0x40 ) != 0;
231
232
233 int x = ALTIUM_PROPS_UTILS::ReadInt( aProps, "LOCATION.X", 0 );
234 int xfrac = ALTIUM_PROPS_UTILS::ReadInt( aProps, "LOCATION.X_FRAC", 0 );
235 int y = ALTIUM_PROPS_UTILS::ReadInt( aProps, "LOCATION.Y", 0 );
236 int yfrac = ALTIUM_PROPS_UTILS::ReadInt( aProps, "LOCATION.Y_FRAC", 0 );
237 location = VECTOR2I( Altium2KiCadUnit( x, xfrac ), -Altium2KiCadUnit( y, yfrac ) );
238
239 int p = ALTIUM_PROPS_UTILS::ReadInt( aProps, "PINLENGTH", 0 );
240 int pfrac = ALTIUM_PROPS_UTILS::ReadInt( aProps, "PINLENGTH_FRAC", 0 );
241 pinlength = Altium2KiCadUnit( p, pfrac );
242
243 // this code calculates the location as required by KiCad without rounding error attached
244 int kicadX = x;
245 int kicadXfrac = xfrac;
246 int kicadY = y;
247 int kicadYfrac = yfrac;
248
249 int offsetY = p;
250 int offsetYfrac = pfrac;
251
252 switch( orientation )
253 {
254 case ASCH_RECORD_ORIENTATION::RIGHTWARDS:
255 kicadX += offsetY;
256 kicadXfrac += offsetYfrac;
257 break;
258
259 case ASCH_RECORD_ORIENTATION::UPWARDS:
260 kicadY += offsetY;
261 kicadYfrac += offsetYfrac;
262 break;
263
264 case ASCH_RECORD_ORIENTATION::LEFTWARDS:
265 kicadX -= offsetY;
266 kicadXfrac -= offsetYfrac;
267 break;
268
269 case ASCH_RECORD_ORIENTATION::DOWNWARDS:
270 kicadY -= offsetY;
271 kicadYfrac -= offsetYfrac;
272 break;
273
274 default:
275 wxLogWarning( "Pin has unexpected orientation" );
276 break;
277 }
278
279 kicadLocation = VECTOR2I( Altium2KiCadUnit( kicadX, kicadXfrac ),
280 -Altium2KiCadUnit( kicadY, kicadYfrac ) );
281}
282
283
284ASCH_OWNER_INTERFACE::ASCH_OWNER_INTERFACE( const std::map<wxString, wxString>& aProps )
285{
286 ownerindex = ReadOwnerIndex( aProps );
287 ownerpartid = ReadOwnerPartId( aProps );
288 ownerpartdisplaymode = ALTIUM_PROPS_UTILS::ReadInt( aProps, "OWNERPARTDISPLAYMODE", 0 );
289 indexinsheet = ALTIUM_PROPS_UTILS::ReadInt( aProps, "INDEXINSHEET", 0 );
290 IsNotAccesible = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISNOTACCESIBLE", false );
291}
292
293
294ASCH_FILL_INTERFACE::ASCH_FILL_INTERFACE( const std::map<wxString, wxString>& aProps )
295{
296 AreaColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "AREACOLOR", 0 );
297 IsSolid = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISSOLID", false );
298 IsTransparent = ALTIUM_PROPS_UTILS::ReadBool( aProps, "TRANSPARENT", false );
299}
300
301
302ASCH_BORDER_INTERFACE::ASCH_BORDER_INTERFACE( const std::map<wxString, wxString>& aProps )
303{
304 LineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" );
305
306 // Altium line width 0 means hairline. Since KiCad doesn't have a hairline, we
307 // represent it as a 1 mil line.
308 if( LineWidth == 0 )
310
311 Color = ALTIUM_PROPS_UTILS::ReadInt( aProps, "COLOR", 0 );
312}
313
314
315ASCH_LABEL::ASCH_LABEL( const std::map<wxString, wxString>& aProps ) :
316 ASCH_OWNER_INTERFACE( aProps )
317{
318 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::LABEL );
319
320 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
321 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
322
323 text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
324
325 textColor = 0;
326 fontId = ALTIUM_PROPS_UTILS::ReadInt( aProps, "FONTID", 0 );
327 isMirrored = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISMIRRORED", false );
328
329 justification = ReadEnum<ASCH_LABEL_JUSTIFICATION>( aProps, "JUSTIFICATION", 0, 8,
330 ASCH_LABEL_JUSTIFICATION::BOTTOM_LEFT );
331
332 orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
333 ASCH_RECORD_ORIENTATION::RIGHTWARDS );
334}
335
336
337ASCH_TEXT_FRAME::ASCH_TEXT_FRAME( const std::map<wxString, wxString>& aProps ) :
338 ASCH_OWNER_INTERFACE( aProps )
339{
340 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::NOTE
341 || ReadRecord( aProps ) == ALTIUM_SCH_RECORD::TEXT_FRAME );
342
343 BottomLeft = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
344 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
345 TopRight = VECTOR2I( ReadKiCadUnitFrac( aProps, "CORNER.X" ),
346 -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) );
347
348 Location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
349 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
350 Size = VECTOR2I( ReadKiCadUnitFrac( aProps, "CORNER.X" ) - Location.x,
351 -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) - Location.y );
352
353 Text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
354 Text.Replace( "~1", "\n", true );
355
356 FontID = ALTIUM_PROPS_UTILS::ReadInt( aProps, "FONTID", 0 );
357 IsWordWrapped = ALTIUM_PROPS_UTILS::ReadBool( aProps, "WORDWRAP", false );
358 ShowBorder = ALTIUM_PROPS_UTILS::ReadBool( aProps, "SHOWBORDER", false );
359 TextMargin = ReadKiCadUnitFrac( aProps, "TEXTMARGIN" );
360
361 AreaColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "AREACOLOR", 0 );
362 BorderColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "COLOR", 0 );
363 TextColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "TEXTCOLOR", 0 );
364
365 BorderWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" );
366 isSolid = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISSOLID", false );
367
368 Alignment = ReadEnum<ASCH_TEXT_FRAME_ALIGNMENT>( aProps, "ALIGNMENT", 1, 3,
369 ASCH_TEXT_FRAME_ALIGNMENT::LEFT );
370}
371
372
373ASCH_NOTE::ASCH_NOTE( const std::map<wxString, wxString>& aProperties ) :
374 ASCH_TEXT_FRAME( aProperties )
375{
376 wxASSERT( ReadRecord( aProperties ) == ALTIUM_SCH_RECORD::NOTE );
377
378 author = ALTIUM_PROPS_UTILS::ReadString( aProperties, "AUTHOR", "" );
379}
380
381
382ASCH_BEZIER::ASCH_BEZIER( const std::map<wxString, wxString>& aProps ) :
383 ASCH_OWNER_INTERFACE( aProps ),
384 ASCH_BORDER_INTERFACE( aProps )
385{
386 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::BEZIER );
387
388 int locationCount = ALTIUM_PROPS_UTILS::ReadInt( aProps, "LOCATIONCOUNT", 0 );
389
390 for( int i = 1; i <= locationCount; i++ )
391 {
392 const wxString si = std::to_string( i );
393 points.emplace_back( ReadKiCadUnitFrac( aProps, "X" + si ),
394 -ReadKiCadUnitFrac( aProps, "Y" + si ) );
395 }
396}
397
398
399ASCH_POLYLINE::ASCH_POLYLINE( const std::map<wxString, wxString>& aProps ) :
400 ASCH_OWNER_INTERFACE( aProps ),
401 ASCH_BORDER_INTERFACE( aProps )
402{
403 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::POLYLINE );
404
405 int locationCount = ALTIUM_PROPS_UTILS::ReadInt( aProps, "LOCATIONCOUNT", 0 );
406
407 for( int i = 1; i <= locationCount; i++ )
408 {
409 const wxString si = std::to_string( i );
410 Points.emplace_back( ReadKiCadUnitFrac( aProps, "X" + si ),
411 -ReadKiCadUnitFrac( aProps, "Y" + si ) );
412 }
413
414 auto lineStyleExt = ReadEnum( aProps, "LINESTYLEEXT", 0, 3, ASCH_POLYLINE_LINESTYLE::SOLID );
415 LineStyle = ReadEnum( aProps, "LINESTYLE", 0, 3, lineStyleExt ); // overwrite if present.
416}
417
418
419ASCH_POLYGON::ASCH_POLYGON( const std::map<wxString, wxString>& aProps ) :
420 ASCH_OWNER_INTERFACE( aProps ),
421 ASCH_FILL_INTERFACE( aProps ),
422 ASCH_BORDER_INTERFACE( aProps )
423{
424 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::POLYGON );
425
426 int locationCount = ALTIUM_PROPS_UTILS::ReadInt( aProps, "LOCATIONCOUNT", 0 );
427
428 for( int i = 1; i <= locationCount; i++ )
429 {
430 const wxString si = std::to_string( i );
431 points.emplace_back( ReadKiCadUnitFrac( aProps, "X" + si ),
432 -ReadKiCadUnitFrac( aProps, "Y" + si ) );
433 }
434}
435
436
437ASCH_ROUND_RECTANGLE::ASCH_ROUND_RECTANGLE( const std::map<wxString, wxString>& aProps ) :
438 ASCH_OWNER_INTERFACE( aProps ),
439 ASCH_FILL_INTERFACE( aProps ),
440 ASCH_BORDER_INTERFACE( aProps )
441{
442 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::ROUND_RECTANGLE );
443
444 BottomLeft = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
445 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
446 TopRight = VECTOR2I( ReadKiCadUnitFrac( aProps, "CORNER.X" ),
447 -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) );
448
449 CornerRadius = VECTOR2I( ReadKiCadUnitFrac( aProps, "CORNERXRADIUS" ),
450 -ReadKiCadUnitFrac( aProps, "CORNERYRADIUS" ) );
451}
452
453
454ASCH_ARC::ASCH_ARC( const std::map<wxString, wxString>& aProps ) :
455 ASCH_OWNER_INTERFACE( aProps ),
456 ASCH_BORDER_INTERFACE( aProps ),
457 ASCH_FILL_INTERFACE( aProps )
458{
459 m_IsElliptical = ReadRecord( aProps ) == ALTIUM_SCH_RECORD::ELLIPTICAL_ARC;
460 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::ARC || m_IsElliptical );
461
462 m_Center = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
463 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
464 m_Radius = ReadKiCadUnitFrac( aProps, "RADIUS" );
466
467 if( m_IsElliptical )
468 m_SecondaryRadius = ReadKiCadUnitFrac( aProps, "SECONDARYRADIUS" );
469
470 m_StartAngle = ALTIUM_PROPS_UTILS::ReadDouble( aProps, "STARTANGLE", 0 );
471 m_EndAngle = ALTIUM_PROPS_UTILS::ReadDouble( aProps, "ENDANGLE", 0 );
472}
473
474
475ASCH_PIECHART::ASCH_PIECHART( const std::map<wxString, wxString>& aProps ) :
476 ASCH_ARC( aProps )
477{}
478
479
480ASCH_ELLIPSE::ASCH_ELLIPSE( const std::map<wxString, wxString>& aProps ) :
481 ASCH_OWNER_INTERFACE( aProps ),
482 ASCH_FILL_INTERFACE( aProps ),
483 ASCH_BORDER_INTERFACE( aProps )
484{
485 ALTIUM_SCH_RECORD record = ReadRecord( aProps );
486
487 wxASSERT( record == ALTIUM_SCH_RECORD::ELLIPSE || record == ALTIUM_SCH_RECORD::ELLIPTICAL_ARC );
488
489 Center = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
490 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
491
492 Radius = ReadKiCadUnitFrac( aProps, "RADIUS" );
493 SecondaryRadius = ReadKiCadUnitFrac( aProps, "SECONDARYRADIUS" );
494}
495
496
497ASCH_LINE::ASCH_LINE( const std::map<wxString, wxString>& aProps ) :
498 ASCH_OWNER_INTERFACE( aProps ),
499 ASCH_BORDER_INTERFACE( aProps )
500{
501 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::LINE );
502
503 point1 = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
504 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
505 point2 = VECTOR2I( ReadKiCadUnitFrac( aProps, "CORNER.X" ),
506 -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) );
507
508 auto lineStyleExt = ReadEnum( aProps, "LINESTYLEEXT", 0, 3, ASCH_POLYLINE_LINESTYLE::SOLID );
509 LineStyle = ReadEnum( aProps, "LINESTYLE", 0, 3, lineStyleExt ); // overwrite if present.
510}
511
512
513ASCH_SIGNAL_HARNESS::ASCH_SIGNAL_HARNESS( const std::map<wxString, wxString>& aProps ) :
514 ASCH_OWNER_INTERFACE( aProps )
515{
516 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SIGNAL_HARNESS );
517
518
519 int locationCount = ALTIUM_PROPS_UTILS::ReadInt( aProps, "LOCATIONCOUNT", 0 );
520
521 for( int i = 1; i <= locationCount; i++ )
522 {
523 const wxString si = std::to_string( i );
524 Points.emplace_back( ReadKiCadUnitFrac( aProps, "X" + si ),
525 -ReadKiCadUnitFrac( aProps, "Y" + si ) );
526 }
527
528 Color = ALTIUM_PROPS_UTILS::ReadInt( aProps, "COLOR", 0 );
529 LineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" );
530}
531
532
533ASCH_HARNESS_CONNECTOR::ASCH_HARNESS_CONNECTOR( const std::map<wxString, wxString>& aProps ) :
534 ASCH_OWNER_INTERFACE( aProps )
535{
536 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::HARNESS_CONNECTOR );
537
538
539 Location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
540 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
541 Size = VECTOR2I( ReadKiCadUnitFrac( aProps, "XSIZE" ), ReadKiCadUnitFrac( aProps, "YSIZE" ) );
542
543 Color = ALTIUM_PROPS_UTILS::ReadInt( aProps, "COLOR", 0 );
544 AreaColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "AREACOLOR", 0 );
545
546 indexinsheet = 0;
547 LineWidth = 0;;
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
564 Side = ReadEnum<ASCH_SHEET_ENTRY_SIDE>( aProps, "SIDE", 0, 3, ASCH_SHEET_ENTRY_SIDE::LEFT );
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
638 side = ReadEnum<ASCH_SHEET_ENTRY_SIDE>( aProps, "SIDE", 0, 3, ASCH_SHEET_ENTRY_SIDE::LEFT );
639
640 name = ALTIUM_PROPS_UTILS::ReadString( aProps, "NAME", "" );
641
642 iotype = ReadEnum<ASCH_PORT_IOTYPE>( aProps, "IOTYPE", 0, 3, ASCH_PORT_IOTYPE::UNSPECIFIED );
643 style = ReadEnum<ASCH_PORT_STYLE>( aProps, "STYLE", 0, 7, ASCH_PORT_STYLE::NONE_HORIZONTAL );
644}
645
646
647ASCH_POWER_PORT::ASCH_POWER_PORT( const std::map<wxString, wxString>& aProps ) :
648 ASCH_OWNER_INTERFACE( aProps )
649{
650 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::POWER_PORT );
651
652
653 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
654 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
655
656 orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
657 ASCH_RECORD_ORIENTATION::RIGHTWARDS );
658
659 text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
660 showNetName = ALTIUM_PROPS_UTILS::ReadBool( aProps, "SHOWNETNAME", true );
661
662 style = ReadEnum<ASCH_POWER_PORT_STYLE>( aProps, "STYLE", 0, 10,
663 ASCH_POWER_PORT_STYLE::CIRCLE );
664}
665
666
667ASCH_PORT::ASCH_PORT( const std::map<wxString, wxString>& aProps ) :
668 ASCH_OWNER_INTERFACE( aProps )
669{
670 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::PORT );
671
672
673 Location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
674 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
675
676 Name = ALTIUM_PROPS_UTILS::ReadString( aProps, "NAME", "" );
677 HarnessType = ALTIUM_PROPS_UTILS::ReadString( aProps, "HARNESSTYPE", "" );
678
679 Width = ReadKiCadUnitFrac( aProps, "WIDTH" );
680 Height = ReadKiCadUnitFrac( aProps, "HEIGHT" );
681
682 IOtype = ReadEnum<ASCH_PORT_IOTYPE>( aProps, "IOTYPE", 0, 3, ASCH_PORT_IOTYPE::UNSPECIFIED );
683 Style = ReadEnum<ASCH_PORT_STYLE>( aProps, "STYLE", 0, 7, ASCH_PORT_STYLE::NONE_HORIZONTAL );
684
685 AreaColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "AREACOLOR", 0 );
686 Color = ALTIUM_PROPS_UTILS::ReadInt( aProps, "COLOR", 0 );
687 FontID = ALTIUM_PROPS_UTILS::ReadInt( aProps, "TEXTFONTID", 0 );
688 TextColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "TEXTCOLOR", 0 );
689
690 Alignment = ReadEnum<ASCH_TEXT_FRAME_ALIGNMENT>( aProps, "ALIGNMENT", 1, 3,
691 ASCH_TEXT_FRAME_ALIGNMENT::LEFT );
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,
718 ASCH_LABEL_JUSTIFICATION::BOTTOM_LEFT );
719
720 orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
721 ASCH_RECORD_ORIENTATION::RIGHTWARDS );
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 );
854 sheetOrientation = ReadEnum<ASCH_SHEET_WORKSPACEORIENTATION>(
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,
867 ASCH_RECORD_ORIENTATION::RIGHTWARDS );
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,
884 ASCH_RECORD_ORIENTATION::RIGHTWARDS );
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,
903 ASCH_LABEL_JUSTIFICATION::BOTTOM_LEFT );
904
905 orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
906 ASCH_RECORD_ORIENTATION::RIGHTWARDS );
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,
955 ASCH_LABEL_JUSTIFICATION::BOTTOM_LEFT );
956
957 orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
958 ASCH_RECORD_ORIENTATION::RIGHTWARDS );
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:110
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)
Definition: ki_exception.h:39
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
double m_EndAngle
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_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)
VECTOR2I location
ASCH_IMAGE(const std::map< wxString, wxString > &aProps)
wxString filename
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
VECTOR2I location
ASCH_LABEL(const std::map< wxString, wxString > &aProps)
ASCH_LABEL_JUSTIFICATION justification
VECTOR2I point1
VECTOR2I point2
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)
wxString author
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
wxString name
wxString text
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_TEXT_FRAME_ALIGNMENT Alignment
ASCH_PORT_IOTYPE IOtype
ASCH_PORT(const std::map< wxString, wxString > &aProps)
wxString HarnessType
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
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
ASCH_SIGNAL_HARNESS(const std::map< wxString, wxString > &aProps)
std::vector< VECTOR2I > Points
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
constexpr int MilsToIU(int mils) const
Definition: base_units.h:93
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:121
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:673