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 isKiCadLibPin = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISKICADLIBPIN", false );
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,
222 ASCH_PIN_ELECTRICAL::INPUT );
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 if( isKiCadLibPin )
254 {
255 offsetY = -offsetY;
256 offsetYfrac = -offsetYfrac;
257 }
258
259 switch( orientation )
260 {
261 case ASCH_RECORD_ORIENTATION::RIGHTWARDS:
262 kicadX += offsetY;
263 kicadXfrac += offsetYfrac;
264 break;
265
266 case ASCH_RECORD_ORIENTATION::UPWARDS:
267 kicadY += offsetY;
268 kicadYfrac += offsetYfrac;
269 break;
270
271 case ASCH_RECORD_ORIENTATION::LEFTWARDS:
272 kicadX -= offsetY;
273 kicadXfrac -= offsetYfrac;
274 break;
275
276 case ASCH_RECORD_ORIENTATION::DOWNWARDS:
277 kicadY -= offsetY;
278 kicadYfrac -= offsetYfrac;
279 break;
280
281 default:
282 wxLogWarning( "Pin has unexpected orientation" );
283 break;
284 }
285
286 kicadLocation = VECTOR2I( Altium2KiCadUnit( kicadX, kicadXfrac ),
287 -Altium2KiCadUnit( kicadY, kicadYfrac ) );
288}
289
290
291ASCH_OWNER_INTERFACE::ASCH_OWNER_INTERFACE( const std::map<wxString, wxString>& aProps )
292{
293 ownerindex = ReadOwnerIndex( aProps );
294 ownerpartid = ReadOwnerPartId( aProps );
295 ownerpartdisplaymode = ALTIUM_PROPS_UTILS::ReadInt( aProps, "OWNERPARTDISPLAYMODE", 0 );
296 indexinsheet = ALTIUM_PROPS_UTILS::ReadInt( aProps, "INDEXINSHEET", 0 );
297 IsNotAccesible = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISNOTACCESIBLE", false );
298}
299
300
301ASCH_FILL_INTERFACE::ASCH_FILL_INTERFACE( const std::map<wxString, wxString>& aProps )
302{
303 AreaColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "AREACOLOR", 0 );
304 IsSolid = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISSOLID", false );
305 IsTransparent = ALTIUM_PROPS_UTILS::ReadBool( aProps, "TRANSPARENT", false );
306}
307
308
309ASCH_BORDER_INTERFACE::ASCH_BORDER_INTERFACE( const std::map<wxString, wxString>& aProps )
310{
311 LineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" );
312
313 // Altium line width 0 means hairline. Since KiCad doesn't have a hairline, we
314 // represent it as a 1 mil line.
315 if( LineWidth == 0 )
317
318 Color = ALTIUM_PROPS_UTILS::ReadInt( aProps, "COLOR", 0 );
319}
320
321
322ASCH_LABEL::ASCH_LABEL( const std::map<wxString, wxString>& aProps ) :
323 ASCH_OWNER_INTERFACE( aProps )
324{
325 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::LABEL );
326
327 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
328 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
329
330 text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
331
332 textColor = 0;
333 fontId = ALTIUM_PROPS_UTILS::ReadInt( aProps, "FONTID", 0 );
334 isMirrored = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISMIRRORED", false );
335
336 justification = ReadEnum<ASCH_LABEL_JUSTIFICATION>( aProps, "JUSTIFICATION", 0, 8,
337 ASCH_LABEL_JUSTIFICATION::BOTTOM_LEFT );
338
339 orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
340 ASCH_RECORD_ORIENTATION::RIGHTWARDS );
341}
342
343
344ASCH_TEXT_FRAME::ASCH_TEXT_FRAME( const std::map<wxString, wxString>& aProps ) :
345 ASCH_OWNER_INTERFACE( aProps )
346{
347 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::NOTE
348 || ReadRecord( aProps ) == ALTIUM_SCH_RECORD::TEXT_FRAME );
349
350 BottomLeft = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
351 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
352 TopRight = VECTOR2I( ReadKiCadUnitFrac( aProps, "CORNER.X" ),
353 -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) );
354
355 Location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
356 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
357 Size = VECTOR2I( ReadKiCadUnitFrac( aProps, "CORNER.X" ) - Location.x,
358 -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) - Location.y );
359
360 Text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
361 Text.Replace( "~1", "\n", true );
362
363 FontID = ALTIUM_PROPS_UTILS::ReadInt( aProps, "FONTID", 0 );
364 IsWordWrapped = ALTIUM_PROPS_UTILS::ReadBool( aProps, "WORDWRAP", false );
365 ShowBorder = ALTIUM_PROPS_UTILS::ReadBool( aProps, "SHOWBORDER", false );
366 TextMargin = ReadKiCadUnitFrac( aProps, "TEXTMARGIN" );
367
368 AreaColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "AREACOLOR", 0 );
369 BorderColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "COLOR", 0 );
370 TextColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "TEXTCOLOR", 0 );
371
372 BorderWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" );
373 isSolid = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISSOLID", false );
374
375 Alignment = ReadEnum<ASCH_TEXT_FRAME_ALIGNMENT>( aProps, "ALIGNMENT", 1, 3,
376 ASCH_TEXT_FRAME_ALIGNMENT::LEFT );
377}
378
379
380ASCH_NOTE::ASCH_NOTE( const std::map<wxString, wxString>& aProperties ) :
381 ASCH_TEXT_FRAME( aProperties )
382{
383 wxASSERT( ReadRecord( aProperties ) == ALTIUM_SCH_RECORD::NOTE );
384
385 author = ALTIUM_PROPS_UTILS::ReadString( aProperties, "AUTHOR", "" );
386}
387
388
389ASCH_BEZIER::ASCH_BEZIER( const std::map<wxString, wxString>& aProps ) :
390 ASCH_OWNER_INTERFACE( aProps ),
391 ASCH_BORDER_INTERFACE( aProps )
392{
393 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::BEZIER );
394
395 int locationCount = ALTIUM_PROPS_UTILS::ReadInt( aProps, "LOCATIONCOUNT", 0 );
396
397 for( int i = 1; i <= locationCount; i++ )
398 {
399 const wxString si = std::to_string( i );
400 points.emplace_back( ReadKiCadUnitFrac( aProps, "X" + si ),
401 -ReadKiCadUnitFrac( aProps, "Y" + si ) );
402 }
403}
404
405
406ASCH_POLYLINE::ASCH_POLYLINE( const std::map<wxString, wxString>& aProps ) :
407 ASCH_OWNER_INTERFACE( aProps ),
408 ASCH_BORDER_INTERFACE( aProps )
409{
410 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::POLYLINE );
411
412 int locationCount = ALTIUM_PROPS_UTILS::ReadInt( aProps, "LOCATIONCOUNT", 0 );
413
414 for( int i = 1; i <= locationCount; i++ )
415 {
416 const wxString si = std::to_string( i );
417 Points.emplace_back( ReadKiCadUnitFrac( aProps, "X" + si ),
418 -ReadKiCadUnitFrac( aProps, "Y" + si ) );
419 }
420
421 auto lineStyleExt = ReadEnum( aProps, "LINESTYLEEXT", 0, 3, ASCH_POLYLINE_LINESTYLE::SOLID );
422 LineStyle = ReadEnum( aProps, "LINESTYLE", 0, 3, lineStyleExt ); // overwrite if present.
423}
424
425
426ASCH_POLYGON::ASCH_POLYGON( const std::map<wxString, wxString>& aProps ) :
427 ASCH_OWNER_INTERFACE( aProps ),
428 ASCH_FILL_INTERFACE( aProps ),
429 ASCH_BORDER_INTERFACE( aProps )
430{
431 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::POLYGON );
432
433 int locationCount = ALTIUM_PROPS_UTILS::ReadInt( aProps, "LOCATIONCOUNT", 0 );
434
435 for( int i = 1; i <= locationCount; i++ )
436 {
437 const wxString si = std::to_string( i );
438 points.emplace_back( ReadKiCadUnitFrac( aProps, "X" + si ),
439 -ReadKiCadUnitFrac( aProps, "Y" + si ) );
440 }
441}
442
443
444ASCH_ROUND_RECTANGLE::ASCH_ROUND_RECTANGLE( const std::map<wxString, wxString>& aProps ) :
445 ASCH_OWNER_INTERFACE( aProps ),
446 ASCH_FILL_INTERFACE( aProps ),
447 ASCH_BORDER_INTERFACE( aProps )
448{
449 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::ROUND_RECTANGLE );
450
451 BottomLeft = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
452 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
453 TopRight = VECTOR2I( ReadKiCadUnitFrac( aProps, "CORNER.X" ),
454 -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) );
455
456 CornerRadius = VECTOR2I( ReadKiCadUnitFrac( aProps, "CORNERXRADIUS" ),
457 -ReadKiCadUnitFrac( aProps, "CORNERYRADIUS" ) );
458}
459
460
461ASCH_ARC::ASCH_ARC( const std::map<wxString, wxString>& aProps ) :
462 ASCH_OWNER_INTERFACE( aProps ),
463 ASCH_BORDER_INTERFACE( aProps )
464{
465 m_IsElliptical = ReadRecord( aProps ) == ALTIUM_SCH_RECORD::ELLIPTICAL_ARC;
466 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::ARC || m_IsElliptical );
467
468 m_Center = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
469 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
470 m_Radius = ReadKiCadUnitFrac( aProps, "RADIUS" );
472
473 if( m_IsElliptical )
474 m_SecondaryRadius = ReadKiCadUnitFrac( aProps, "SECONDARYRADIUS" );
475
476 m_StartAngle = ALTIUM_PROPS_UTILS::ReadDouble( aProps, "STARTANGLE", 0 );
477 m_EndAngle = ALTIUM_PROPS_UTILS::ReadDouble( aProps, "ENDANGLE", 0 );
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 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::ELLIPSE );
487
488 Center = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
489 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
490
491 Radius = ReadKiCadUnitFrac( aProps, "RADIUS" );
492 SecondaryRadius = ReadKiCadUnitFrac( aProps, "SECONDARYRADIUS" );
493}
494
495
496ASCH_LINE::ASCH_LINE( const std::map<wxString, wxString>& aProps ) :
497 ASCH_OWNER_INTERFACE( aProps ),
498 ASCH_BORDER_INTERFACE( aProps )
499{
500 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::LINE );
501
502 point1 = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
503 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
504 point2 = VECTOR2I( ReadKiCadUnitFrac( aProps, "CORNER.X" ),
505 -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) );
506
507 auto lineStyleExt = ReadEnum( aProps, "LINESTYLEEXT", 0, 3, ASCH_POLYLINE_LINESTYLE::SOLID );
508 LineStyle = ReadEnum( aProps, "LINESTYLE", 0, 3, lineStyleExt ); // overwrite if present.
509}
510
511
512ASCH_SIGNAL_HARNESS::ASCH_SIGNAL_HARNESS( const std::map<wxString, wxString>& aProps ) :
513 ASCH_OWNER_INTERFACE( aProps )
514{
515 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SIGNAL_HARNESS );
516
517
518 int locationCount = ALTIUM_PROPS_UTILS::ReadInt( aProps, "LOCATIONCOUNT", 0 );
519
520 for( int i = 1; i <= locationCount; i++ )
521 {
522 const wxString si = std::to_string( i );
523 Points.emplace_back( ReadKiCadUnitFrac( aProps, "X" + si ),
524 -ReadKiCadUnitFrac( aProps, "Y" + si ) );
525 }
526
527 Color = ALTIUM_PROPS_UTILS::ReadInt( aProps, "COLOR", 0 );
528 LineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" );
529}
530
531
532ASCH_HARNESS_CONNECTOR::ASCH_HARNESS_CONNECTOR( const std::map<wxString, wxString>& aProps ) :
533 ASCH_OWNER_INTERFACE( aProps )
534{
535 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::HARNESS_CONNECTOR );
536
537
538 Location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
539 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
540 Size = VECTOR2I( ReadKiCadUnitFrac( aProps, "XSIZE" ), ReadKiCadUnitFrac( aProps, "YSIZE" ) );
541
542 Color = ALTIUM_PROPS_UTILS::ReadInt( aProps, "COLOR", 0 );
543 AreaColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "AREACOLOR", 0 );
544
545 indexinsheet = 0;
546 LineWidth = 0;;
548}
549
550
551ASCH_HARNESS_ENTRY::ASCH_HARNESS_ENTRY( const std::map<wxString, wxString>& aProps ) :
552 ASCH_OWNER_INTERFACE( aProps )
553{
554 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::HARNESS_ENTRY );
555
556 // use SCH_IO_ALTIUM::m_harnessEntryParent instead, because this property sometimes
557 // does not exist in altium file!
558 // ownerindex = ReadOwnerIndex( aProps );
559
560
561 DistanceFromTop = ReadKiCadUnitFrac1( aProps, "DISTANCEFROMTOP" );
562
563 Side = ReadEnum<ASCH_SHEET_ENTRY_SIDE>( aProps, "SIDE", 0, 3, ASCH_SHEET_ENTRY_SIDE::LEFT );
564
565 Name = ALTIUM_PROPS_UTILS::ReadString( aProps, "NAME", "" );
566
567 OwnerIndexAdditionalList = ALTIUM_PROPS_UTILS::ReadBool( aProps, "OWNERINDEXADDITIONALLIST", true );
568
569 Color = ALTIUM_PROPS_UTILS::ReadInt( aProps, "COLOR", 0 );
570 AreaColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "AREACOLOR", 0 );
571 TextColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "TEXTCOLOR", 0 );
572 TextFontID = ALTIUM_PROPS_UTILS::ReadInt( aProps, "TEXTFONTID", 0 );
573 TextStyle = 0;
574}
575
576
577ASCH_HARNESS_TYPE::ASCH_HARNESS_TYPE( const std::map<wxString, wxString>& aProps ) :
578 ASCH_OWNER_INTERFACE( aProps )
579{
580 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::HARNESS_TYPE );
581
582 //ownerindex = ReadOwnerIndex( aProps ); // use SCH_IO_ALTIUM::m_harnessEntryParent instead!
583
584 Text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
585
586 Location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
587 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
588
589 IsHidden = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISHIDDEN", false );
590 OwnerIndexAdditionalList = ALTIUM_PROPS_UTILS::ReadBool( aProps, "OWNERINDEXADDITIONALLIST", true );
591
592 Color = ALTIUM_PROPS_UTILS::ReadInt( aProps, "COLOR", 0 );
593 FontID = ALTIUM_PROPS_UTILS::ReadInt( aProps, "TEXTFONTID", 0 );
594}
595
596
597ASCH_RECTANGLE::ASCH_RECTANGLE( const std::map<wxString, wxString>& aProps ) :
598 ASCH_OWNER_INTERFACE( aProps ),
599 ASCH_FILL_INTERFACE( aProps ),
600 ASCH_BORDER_INTERFACE( aProps )
601{
602 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::RECTANGLE );
603
604 BottomLeft = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
605 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
606 TopRight = VECTOR2I( ReadKiCadUnitFrac( aProps, "CORNER.X" ),
607 -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) );
608
609}
610
611
612ASCH_SHEET_SYMBOL::ASCH_SHEET_SYMBOL( const std::map<wxString, wxString>& aProps ) :
613 ASCH_OWNER_INTERFACE( aProps )
614{
615 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SHEET_SYMBOL );
616
617 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
618 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
619 size = VECTOR2I( ReadKiCadUnitFrac( aProps, "XSIZE" ),
620 ReadKiCadUnitFrac( aProps, "YSIZE" ) );
621
622 isSolid = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISSOLID", false );
623
624 color = ALTIUM_PROPS_UTILS::ReadInt( aProps, "COLOR", 0 );
625 areacolor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "AREACOLOR", 0 );
626}
627
628
629ASCH_SHEET_ENTRY::ASCH_SHEET_ENTRY( const std::map<wxString, wxString>& aProps ) :
630 ASCH_OWNER_INTERFACE( aProps )
631{
632 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SHEET_ENTRY );
633
634 // some magic, because it stores those infos in a different unit??
635 distanceFromTop = ReadKiCadUnitFrac1( aProps, "DISTANCEFROMTOP" );
636
637 side = ReadEnum<ASCH_SHEET_ENTRY_SIDE>( aProps, "SIDE", 0, 3, ASCH_SHEET_ENTRY_SIDE::LEFT );
638
639 name = ALTIUM_PROPS_UTILS::ReadString( aProps, "NAME", "" );
640
641 iotype = ReadEnum<ASCH_PORT_IOTYPE>( aProps, "IOTYPE", 0, 3, ASCH_PORT_IOTYPE::UNSPECIFIED );
642 style = ReadEnum<ASCH_PORT_STYLE>( aProps, "STYLE", 0, 7, ASCH_PORT_STYLE::NONE_HORIZONTAL );
643}
644
645
646ASCH_POWER_PORT::ASCH_POWER_PORT( const std::map<wxString, wxString>& aProps ) :
647 ASCH_OWNER_INTERFACE( aProps )
648{
649 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::POWER_PORT );
650
651
652 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
653 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
654
655 orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
656 ASCH_RECORD_ORIENTATION::RIGHTWARDS );
657
658 text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
659 showNetName = ALTIUM_PROPS_UTILS::ReadBool( aProps, "SHOWNETNAME", true );
660
661 style = ReadEnum<ASCH_POWER_PORT_STYLE>( aProps, "STYLE", 0, 10,
662 ASCH_POWER_PORT_STYLE::CIRCLE );
663}
664
665
666ASCH_PORT::ASCH_PORT( const std::map<wxString, wxString>& aProps ) :
667 ASCH_OWNER_INTERFACE( aProps )
668{
669 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::PORT );
670
671
672 Location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
673 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
674
675 Name = ALTIUM_PROPS_UTILS::ReadString( aProps, "NAME", "" );
676 HarnessType = ALTIUM_PROPS_UTILS::ReadString( aProps, "HARNESSTYPE", "" );
677
678 Width = ReadKiCadUnitFrac( aProps, "WIDTH" );
679 Height = ReadKiCadUnitFrac( aProps, "HEIGHT" );
680
681 IOtype = ReadEnum<ASCH_PORT_IOTYPE>( aProps, "IOTYPE", 0, 3, ASCH_PORT_IOTYPE::UNSPECIFIED );
682 Style = ReadEnum<ASCH_PORT_STYLE>( aProps, "STYLE", 0, 7, ASCH_PORT_STYLE::NONE_HORIZONTAL );
683
684 AreaColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "AREACOLOR", 0 );
685 Color = ALTIUM_PROPS_UTILS::ReadInt( aProps, "COLOR", 0 );
686 FontID = ALTIUM_PROPS_UTILS::ReadInt( aProps, "TEXTFONTID", 0 );
687 TextColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "TEXTCOLOR", 0 );
688
689 Alignment = ReadEnum<ASCH_TEXT_FRAME_ALIGNMENT>( aProps, "ALIGNMENT", 1, 3,
690 ASCH_TEXT_FRAME_ALIGNMENT::LEFT );
691}
692
693
694ASCH_NO_ERC::ASCH_NO_ERC( const std::map<wxString, wxString>& aProps )
695{
696 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::NO_ERC );
697
698 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
699 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
700
701 isActive = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISACTIVE", true );
702 suppressAll = ALTIUM_PROPS_UTILS::ReadInt( aProps, "SUPPRESSALL", true );
703}
704
705
706ASCH_NET_LABEL::ASCH_NET_LABEL( const std::map<wxString, wxString>& aProps ) :
707 ASCH_OWNER_INTERFACE( aProps )
708{
709 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::NET_LABEL );
710
711 text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
712
713 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
714 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
715
716 justification = ReadEnum<ASCH_LABEL_JUSTIFICATION>( aProps, "JUSTIFICATION", 0, 8,
717 ASCH_LABEL_JUSTIFICATION::BOTTOM_LEFT );
718
719 orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
720 ASCH_RECORD_ORIENTATION::RIGHTWARDS );
721}
722
723
724ASCH_BUS::ASCH_BUS( const std::map<wxString, wxString>& aProps ) :
725 ASCH_OWNER_INTERFACE( aProps )
726{
727 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::BUS );
728
729 int locationcount = ALTIUM_PROPS_UTILS::ReadInt( aProps, "LOCATIONCOUNT", 0 );
730
731 for( int i = 1; i <= locationcount; i++ )
732 {
733 const wxString si = std::to_string( i );
734 points.emplace_back( ReadKiCadUnitFrac( aProps, "X" + si ),
735 -ReadKiCadUnitFrac( aProps, "Y" + si ) );
736 }
737
738 lineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" );
739}
740
741
742ASCH_WIRE::ASCH_WIRE( const std::map<wxString, wxString>& aProps ) :
743 ASCH_OWNER_INTERFACE( aProps )
744{
745 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::WIRE );
746
747 int locationcount = ALTIUM_PROPS_UTILS::ReadInt( aProps, "LOCATIONCOUNT", 0 );
748
749 for( int i = 1; i <= locationcount; i++ )
750 {
751 const wxString si = std::to_string( i );
752 points.emplace_back( ReadKiCadUnitFrac( aProps, "X" + si ),
753 -ReadKiCadUnitFrac( aProps, "Y" + si ) );
754 }
755
756 lineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" );
757}
758
759
760ASCH_JUNCTION::ASCH_JUNCTION( const std::map<wxString, wxString>& aProps ) :
761 ASCH_OWNER_INTERFACE( aProps )
762{
763 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::JUNCTION );
764
765
766 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
767 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
768}
769
770
771ASCH_IMAGE::ASCH_IMAGE( const std::map<wxString, wxString>& aProps ) :
772 ASCH_OWNER_INTERFACE( aProps ),
773 ASCH_BORDER_INTERFACE( aProps )
774{
775 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::IMAGE );
776
777 filename = ALTIUM_PROPS_UTILS::ReadString( aProps, "FILENAME", "" );
778
779 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
780 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
781 corner = VECTOR2I( ReadKiCadUnitFrac( aProps, "CORNER.X" ),
782 -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) );
783
784 embedimage = ALTIUM_PROPS_UTILS::ReadBool( aProps, "EMBEDIMAGE", false );
785 keepaspect = ALTIUM_PROPS_UTILS::ReadBool( aProps, "KEEPASPECT", false );
786}
787
788
789ASCH_SHEET_FONT::ASCH_SHEET_FONT( const std::map<wxString, wxString>& aProps, int aId ) :
790 ASCH_OWNER_INTERFACE( aProps )
791{
792 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SHEET );
793
794 const wxString sid = std::to_string( aId );
795
796 FontName = ALTIUM_PROPS_UTILS::ReadString( aProps, "FONTNAME" + sid, "" );
797
798 Size = ReadKiCadUnitFrac( aProps, "SIZE" + sid );
799 Rotation = ALTIUM_PROPS_UTILS::ReadInt( aProps, "ROTATION" + sid, 0 );
800
801 Italic = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ITALIC" + sid, false );
802 Bold = ALTIUM_PROPS_UTILS::ReadBool( aProps, "BOLD" + sid, false );
803 Underline = ALTIUM_PROPS_UTILS::ReadBool( aProps, "UNDERLINE" + sid, false );
804
805 AreaColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "AREACOLOR" + sid, 0 );
806}
807
808
810{
811 // From: https://github.com/vadmium/python-altium/blob/master/format.md#sheet
812 switch( aSheetSize )
813 {
814 default:
815 case ASCH_SHEET_SIZE::A4: return { 1150, 760 };
816 case ASCH_SHEET_SIZE::A3: return { 1550, 1110 };
817 case ASCH_SHEET_SIZE::A2: return { 2230, 1570 };
818 case ASCH_SHEET_SIZE::A1: return { 3150, 2230 };
819 case ASCH_SHEET_SIZE::A0: return { 4460, 3150 };
820 case ASCH_SHEET_SIZE::A: return { 950, 750 };
821 case ASCH_SHEET_SIZE::B: return { 1500, 950 };
822 case ASCH_SHEET_SIZE::C: return { 2000, 1500 };
823 case ASCH_SHEET_SIZE::D: return { 3200, 2000 };
824 case ASCH_SHEET_SIZE::E: return { 4200, 3200 };
825 case ASCH_SHEET_SIZE::LETTER: return { 1100, 850 };
826 case ASCH_SHEET_SIZE::LEGAL: return { 1400, 850 };
827 case ASCH_SHEET_SIZE::TABLOID: return { 1700, 1100 };
828 case ASCH_SHEET_SIZE::ORCAD_A: return { 990, 790 };
829 case ASCH_SHEET_SIZE::ORCAD_B: return { 1540, 990 };
830 case ASCH_SHEET_SIZE::ORCAD_C: return { 2060, 1560 };
831 case ASCH_SHEET_SIZE::ORCAD_D: return { 3260, 2060 };
832 case ASCH_SHEET_SIZE::ORCAD_E: return { 4280, 3280 };
833 }
834}
835
836
837ASCH_SHEET::ASCH_SHEET( const std::map<wxString, wxString>& aProps ) :
838 ASCH_OWNER_INTERFACE( aProps )
839{
840 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SHEET );
841
842 int fontidcount = ALTIUM_PROPS_UTILS::ReadInt( aProps, "FONTIDCOUNT", 0 );
843
844 for( int i = 1; i <= fontidcount; i++ )
845 fonts.emplace_back( aProps, i );
846
847 useCustomSheet = ALTIUM_PROPS_UTILS::ReadBool( aProps, "USECUSTOMSHEET", false );
848
849 customSize = VECTOR2I( ReadKiCadUnitFrac( aProps, "CUSTOMX" ),
850 ReadKiCadUnitFrac( aProps, "CUSTOMY" ) );
851
852 sheetSize = ReadEnum<ASCH_SHEET_SIZE>( aProps, "SHEETSTYLE", 0, 17, ASCH_SHEET_SIZE::A4 );
853 sheetOrientation = ReadEnum<ASCH_SHEET_WORKSPACEORIENTATION>(
854 aProps, "WORKSPACEORIENTATION", 0, 1, ASCH_SHEET_WORKSPACEORIENTATION::LANDSCAPE );
855}
856
857
858ASCH_SHEET_NAME::ASCH_SHEET_NAME( const std::map<wxString, wxString>& aProps ) :
859 ASCH_OWNER_INTERFACE( aProps )
860{
861 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SHEET_NAME );
862
863 text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
864
865 orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
866 ASCH_RECORD_ORIENTATION::RIGHTWARDS );
867
868 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
869 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
870
871 isHidden = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISHIDDEN", false );
872}
873
874
875ASCH_FILE_NAME::ASCH_FILE_NAME( const std::map<wxString, wxString>& aProps ) :
876 ASCH_OWNER_INTERFACE( aProps )
877{
878 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::FILE_NAME );
879
880 text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
881
882 orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
883 ASCH_RECORD_ORIENTATION::RIGHTWARDS );
884
885 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
886 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
887
888 isHidden = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISHIDDEN", false );
889}
890
891
892ASCH_DESIGNATOR::ASCH_DESIGNATOR( const std::map<wxString, wxString>& aProps ) :
893 ASCH_OWNER_INTERFACE( aProps )
894{
895 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::DESIGNATOR );
896
897 name = ALTIUM_PROPS_UTILS::ReadString( aProps, "NAME", "" );
898 text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
899 fontId = ALTIUM_PROPS_UTILS::ReadInt( aProps, "FONTID", 0 );
900
901 justification = ReadEnum<ASCH_LABEL_JUSTIFICATION>( aProps, "JUSTIFICATION", 0, 8,
902 ASCH_LABEL_JUSTIFICATION::BOTTOM_LEFT );
903
904 orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
905 ASCH_RECORD_ORIENTATION::RIGHTWARDS );
906
907 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
908 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
909}
910
911
912ASCH_IMPLEMENTATION::ASCH_IMPLEMENTATION( const std::map<wxString, wxString>& aProps ) :
913 ASCH_OWNER_INTERFACE( aProps )
914{
915 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::IMPLEMENTATION );
916
918 name = ALTIUM_PROPS_UTILS::ReadString( aProps, "MODELNAME", "" );
919 type = ALTIUM_PROPS_UTILS::ReadString( aProps, "MODELTYPE", "" );
920 libname = ALTIUM_PROPS_UTILS::ReadString( aProps, "MODELDATAFILE0", "" );
921 description = ALTIUM_PROPS_UTILS::ReadString( aProps, "DESCRIPTION", "" );
922 isCurrent = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISCURRENT", false );
923}
924
925
926ASCH_IMPLEMENTATION_LIST::ASCH_IMPLEMENTATION_LIST( const std::map<wxString, wxString>& aProps ) :
927 ASCH_OWNER_INTERFACE( aProps )
928{
929 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::IMPLEMENTATION_LIST );
930}
931
932
933ASCH_BUS_ENTRY::ASCH_BUS_ENTRY( const std::map<wxString, wxString>& aProps ) :
934 ASCH_OWNER_INTERFACE( aProps )
935{
936 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::BUS_ENTRY );
937
938 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
939 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
940 corner = VECTOR2I( ReadKiCadUnitFrac( aProps, "CORNER.X" ),
941 -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) );
942}
943
944
945ASCH_PARAMETER::ASCH_PARAMETER( const std::map<wxString, wxString>& aProps ) :
946 ASCH_OWNER_INTERFACE( aProps )
947{
948 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::PARAMETER );
949
950 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
951 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
952
953 justification = ReadEnum<ASCH_LABEL_JUSTIFICATION>( aProps, "JUSTIFICATION", 0, 8,
954 ASCH_LABEL_JUSTIFICATION::BOTTOM_LEFT );
955
956 orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
957 ASCH_RECORD_ORIENTATION::RIGHTWARDS );
958
959 name = ALTIUM_PROPS_UTILS::ReadString( aProps, "NAME", "" );
960 text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
961
962 isHidden = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISHIDDEN", false );
963 isMirrored = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISMIRRORED", false );
964 isShowName = ALTIUM_PROPS_UTILS::ReadBool( aProps, "SHOWNAME", false );
965
966 fontId = ALTIUM_PROPS_UTILS::ReadInt( aProps, "FONTID", 0 );
967}
968
969
970ASCH_HYPERLINK::ASCH_HYPERLINK( const std::map<wxString, wxString>& aProps ) :
971 ASCH_LABEL( aProps )
972{
973 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::HYPERLINK );
974
975 url = ALTIUM_PROPS_UTILS::ReadString( aProps, "URL", "" );
976}
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:111
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
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:94
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:85
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588