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