KiCad PCB EDA Suite
Loading...
Searching...
No Matches
altium_parser_sch.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2020 Thomas Pointhuber <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <iostream>
26#include <unordered_map>
27#include <charconv>
28
29#include <base_units.h>
30#include <ki_exception.h>
31
32#include <wx/log.h>
33
37
38
39ALTIUM_SCH_RECORD ReadRecord( const std::map<wxString, wxString>& aProps )
40{
41 int recordId = ALTIUM_PROPS_UTILS::ReadInt( aProps, "RECORD", -1 );
42 return static_cast<ALTIUM_SCH_RECORD>( recordId );
43}
44
45
46constexpr int Altium2KiCadUnit( const int val, const int frac )
47{
48 constexpr double int_limit = ( std::numeric_limits<int>::max() - 10 ) / 2.54;
49
50 double dbase = 10 * schIUScale.MilsToIU( val );
51 double dfrac = schIUScale.MilsToIU( frac ) / 10000.0;
52
53 return KiROUND( std::clamp( ( dbase + dfrac ) / 10.0, -int_limit, int_limit ) ) * 10;
54}
55
56
57int ReadKiCadUnitFrac( const std::map<wxString, wxString>& aProps, const wxString& aKey )
58{
59 // a unit is stored using two fields, denoting the size in mils and a fraction size
60 int key = ALTIUM_PROPS_UTILS::ReadInt( aProps, aKey, 0 );
61 int keyFrac = ALTIUM_PROPS_UTILS::ReadInt( aProps, aKey + "_FRAC", 0 );
62 return Altium2KiCadUnit( key, keyFrac );
63}
64
65
66int ReadKiCadUnitFrac1( const std::map<wxString, wxString>& aProps, const wxString& aKey )
67{
68 // a unit is stored using two fields, denoting the size in mils and a fraction size
69 // Dunno why Altium invents different units for the same purpose
70 int key = ALTIUM_PROPS_UTILS::ReadInt( aProps, aKey, 0 );
71 int keyFrac = ALTIUM_PROPS_UTILS::ReadInt( aProps, aKey + "_FRAC1", 0 );
72 return Altium2KiCadUnit( key * 10, keyFrac );
73}
74
75
76int ReadOwnerIndex( const std::map<wxString, wxString>& aProperties )
77{
78 return ALTIUM_PROPS_UTILS::ReadInt( aProperties, "OWNERINDEX", ALTIUM_COMPONENT_NONE );
79}
80
81
82int ReadOwnerPartId( const std::map<wxString, wxString>& aProperties )
83{
84 return ALTIUM_PROPS_UTILS::ReadInt( aProperties, "OWNERPARTID", ALTIUM_COMPONENT_NONE );
85}
86
87
88template <typename T>
89T ReadEnum( const std::map<wxString, wxString>& aProps, const wxString& aKey, int aLower,
90 int aUpper, T aDefault )
91{
92 int value = ALTIUM_PROPS_UTILS::ReadInt( aProps, aKey, static_cast<int>( aDefault ) );
93
94 if( value < aLower || value > aUpper )
95 return aDefault;
96 else
97 return static_cast<T>( value );
98}
99
100
101ASCH_STORAGE_FILE::ASCH_STORAGE_FILE( const std::map<wxString, wxString>& aProps )
102{
103 filename = ALTIUM_PROPS_UTILS::ReadString( aProps, "NAME", "" );
104 size_t dataSize = ALTIUM_PROPS_UTILS::ReadInt( aProps, "DATA_LEN", 0 );
105
106 wxString hexData = ALTIUM_PROPS_UTILS::ReadString( aProps, "DATA", "" );
107 const size_t charCount = hexData.size();
108
109 if( charCount != dataSize * 2 )
110 {
111 THROW_IO_ERROR( wxString::Format( "Invalid binary file hex data size. Chars expected: %d, "
112 "hex string length: %d",
113 int( dataSize * 2 ), int( hexData.size() ) ) );
114 }
115
116 data.resize( dataSize );
117
118 char str[3] = { 0 };
119 uint8_t b = 0;
120 size_t outputId = 0;
121
122 for( size_t inputId = 1; inputId < charCount; inputId += 2 )
123 {
124 str[0] = (char) hexData[inputId - 1];
125 str[1] = (char) hexData[inputId];
126
127 std::from_chars( str, str + 2, b, 16 );
128 data[outputId] = b;
129
130 outputId++;
131 }
132}
133
134
136{
137 aReader.Skip( 5 );
138 filename = aReader.ReadWxString();
139 uint32_t dataSize = aReader.Read<uint32_t>();
140 data = aReader.ReadVector( dataSize );
141
142 if( aReader.HasParsingError() )
143 THROW_IO_ERROR( "Storage stream was not parsed correctly" );
144}
145
146
148{
149 aReader.Skip( 5 );
150 FileName = aReader.ReadWxString();
151 uint32_t dataSize = aReader.Read<uint32_t>();
152 Data = aReader.ReadVector( dataSize );
153
154 if( aReader.HasParsingError() )
155 THROW_IO_ERROR( "Additional stream was not parsed correctly" );
156}
157
158
159ASCH_SYMBOL::ASCH_SYMBOL( const std::map<wxString, wxString>& aProps )
160{
161 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::COMPONENT );
162
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 m_location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
540 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
541 m_size = VECTOR2I( ReadKiCadUnitFrac( aProps, "XSIZE" ), ReadKiCadUnitFrac( aProps, "YSIZE" ) );
542
543 m_color = ALTIUM_PROPS_UTILS::ReadInt( aProps, "COLOR", 0 );
544 m_areaColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "AREACOLOR", 0 );
545
546 indexinsheet = 0;
547 m_lineWidth = 0;;
548 m_primaryConnectionPosition = ALTIUM_PROPS_UTILS::ReadInt( aProps, "PRIMARYCONNECTIONPOSITION", 0 );
549 m_harnessConnectorSide = ReadEnum<ASCH_SHEET_ENTRY_SIDE>( aProps, "SIDE", 0, 3, ASCH_SHEET_ENTRY_SIDE::RIGHT );
550
551}
552
553
554ASCH_HARNESS_ENTRY::ASCH_HARNESS_ENTRY( const std::map<wxString, wxString>& aProps ) :
555 ASCH_OWNER_INTERFACE( aProps )
556{
557 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::HARNESS_ENTRY );
558
559 // use SCH_IO_ALTIUM::m_harnessEntryParent instead, because this property sometimes
560 // does not exist in altium file!
561 // ownerindex = ReadOwnerIndex( aProps );
562
563
564 DistanceFromTop = ReadKiCadUnitFrac1( aProps, "DISTANCEFROMTOP" );
565
566 Side = ReadEnum<ASCH_SHEET_ENTRY_SIDE>( aProps, "SIDE", 0, 3, ASCH_SHEET_ENTRY_SIDE::LEFT );
567
568 Name = ALTIUM_PROPS_UTILS::ReadString( aProps, "NAME", "" );
569
570 OwnerIndexAdditionalList = ALTIUM_PROPS_UTILS::ReadBool( aProps, "OWNERINDEXADDITIONALLIST", true );
571
572 Color = ALTIUM_PROPS_UTILS::ReadInt( aProps, "COLOR", 0 );
573 AreaColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "AREACOLOR", 0 );
574 TextColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "TEXTCOLOR", 0 );
575 TextFontID = ALTIUM_PROPS_UTILS::ReadInt( aProps, "TEXTFONTID", 0 );
576 TextStyle = 0;
577}
578
579
580ASCH_HARNESS_TYPE::ASCH_HARNESS_TYPE( const std::map<wxString, wxString>& aProps ) :
581 ASCH_OWNER_INTERFACE( aProps )
582{
583 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::HARNESS_TYPE );
584
585 //ownerindex = ReadOwnerIndex( aProps ); // use SCH_IO_ALTIUM::m_harnessEntryParent instead!
586
587 Text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
588
589 Location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
590 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
591
592 IsHidden = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISHIDDEN", false );
593 OwnerIndexAdditionalList = ALTIUM_PROPS_UTILS::ReadBool( aProps, "OWNERINDEXADDITIONALLIST", true );
594
595 Color = ALTIUM_PROPS_UTILS::ReadInt( aProps, "COLOR", 0 );
596 FontID = ALTIUM_PROPS_UTILS::ReadInt( aProps, "TEXTFONTID", 0 );
597}
598
599
600ASCH_RECTANGLE::ASCH_RECTANGLE( const std::map<wxString, wxString>& aProps ) :
601 ASCH_OWNER_INTERFACE( aProps ),
602 ASCH_FILL_INTERFACE( aProps ),
603 ASCH_BORDER_INTERFACE( aProps )
604{
605 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::RECTANGLE );
606
607 BottomLeft = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
608 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
609 TopRight = VECTOR2I( ReadKiCadUnitFrac( aProps, "CORNER.X" ),
610 -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) );
611
612}
613
614
615ASCH_SHEET_SYMBOL::ASCH_SHEET_SYMBOL( const std::map<wxString, wxString>& aProps ) :
616 ASCH_OWNER_INTERFACE( aProps )
617{
618 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SHEET_SYMBOL );
619
620 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
621 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
622 size = VECTOR2I( ReadKiCadUnitFrac( aProps, "XSIZE" ),
623 ReadKiCadUnitFrac( aProps, "YSIZE" ) );
624
625 isSolid = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISSOLID", false );
626
627 color = ALTIUM_PROPS_UTILS::ReadInt( aProps, "COLOR", 0 );
628 areacolor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "AREACOLOR", 0 );
629}
630
631
632ASCH_SHEET_ENTRY::ASCH_SHEET_ENTRY( const std::map<wxString, wxString>& aProps ) :
633 ASCH_OWNER_INTERFACE( aProps )
634{
635 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SHEET_ENTRY );
636
637 // some magic, because it stores those infos in a different unit??
638 distanceFromTop = ReadKiCadUnitFrac1( aProps, "DISTANCEFROMTOP" );
639
640 side = ReadEnum<ASCH_SHEET_ENTRY_SIDE>( aProps, "SIDE", 0, 3, ASCH_SHEET_ENTRY_SIDE::LEFT );
641
642 name = ALTIUM_PROPS_UTILS::ReadString( aProps, "NAME", "" );
643
644 iotype = ReadEnum<ASCH_PORT_IOTYPE>( aProps, "IOTYPE", 0, 3, ASCH_PORT_IOTYPE::UNSPECIFIED );
645 style = ReadEnum<ASCH_PORT_STYLE>( aProps, "STYLE", 0, 7, ASCH_PORT_STYLE::NONE_HORIZONTAL );
646}
647
648
649ASCH_POWER_PORT::ASCH_POWER_PORT( const std::map<wxString, wxString>& aProps ) :
650 ASCH_OWNER_INTERFACE( aProps )
651{
652 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::POWER_PORT );
653
654
655 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
656 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
657
658 orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
659 ASCH_RECORD_ORIENTATION::RIGHTWARDS );
660
661 text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
662 showNetName = ALTIUM_PROPS_UTILS::ReadBool( aProps, "SHOWNETNAME", true );
663
664 style = ReadEnum<ASCH_POWER_PORT_STYLE>( aProps, "STYLE", 0, 10,
665 ASCH_POWER_PORT_STYLE::CIRCLE );
666}
667
668
669ASCH_PORT::ASCH_PORT( const std::map<wxString, wxString>& aProps ) :
670 ASCH_OWNER_INTERFACE( aProps )
671{
672 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::PORT );
673
674
675 Location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
676 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
677
678 Name = ALTIUM_PROPS_UTILS::ReadString( aProps, "NAME", "" );
679 HarnessType = ALTIUM_PROPS_UTILS::ReadString( aProps, "HARNESSTYPE", "" );
680
681 Width = ReadKiCadUnitFrac( aProps, "WIDTH" );
682 Height = ReadKiCadUnitFrac( aProps, "HEIGHT" );
683
684 IOtype = ReadEnum<ASCH_PORT_IOTYPE>( aProps, "IOTYPE", 0, 3, ASCH_PORT_IOTYPE::UNSPECIFIED );
685 Style = ReadEnum<ASCH_PORT_STYLE>( aProps, "STYLE", 0, 7, ASCH_PORT_STYLE::NONE_HORIZONTAL );
686
687 AreaColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "AREACOLOR", 0 );
688 Color = ALTIUM_PROPS_UTILS::ReadInt( aProps, "COLOR", 0 );
689 FontID = ALTIUM_PROPS_UTILS::ReadInt( aProps, "TEXTFONTID", 0 );
690 TextColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "TEXTCOLOR", 0 );
691
692 m_align = ReadEnum<ASCH_PORT_ALIGNMENT>( aProps, "ALIGNMENT", 0, 2, ASCH_PORT_ALIGNMENT::CENTER );
693}
694
695
696ASCH_NO_ERC::ASCH_NO_ERC( const std::map<wxString, wxString>& aProps )
697{
698 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::NO_ERC );
699
700 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
701 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
702
703 isActive = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISACTIVE", true );
704 suppressAll = ALTIUM_PROPS_UTILS::ReadInt( aProps, "SUPPRESSALL", true );
705}
706
707
708ASCH_NET_LABEL::ASCH_NET_LABEL( const std::map<wxString, wxString>& aProps ) :
709 ASCH_OWNER_INTERFACE( aProps )
710{
711 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::NET_LABEL );
712
713 text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
714
715 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
716 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
717
718 justification = ReadEnum<ASCH_LABEL_JUSTIFICATION>( aProps, "JUSTIFICATION", 0, 8,
719 ASCH_LABEL_JUSTIFICATION::BOTTOM_LEFT );
720
721 orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
722 ASCH_RECORD_ORIENTATION::RIGHTWARDS );
723}
724
725
726ASCH_BUS::ASCH_BUS( const std::map<wxString, wxString>& aProps ) :
727 ASCH_OWNER_INTERFACE( aProps )
728{
729 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::BUS );
730
731 int locationcount = ALTIUM_PROPS_UTILS::ReadInt( aProps, "LOCATIONCOUNT", 0 );
732
733 for( int i = 1; i <= locationcount; i++ )
734 {
735 const wxString si = std::to_string( i );
736 points.emplace_back( ReadKiCadUnitFrac( aProps, "X" + si ),
737 -ReadKiCadUnitFrac( aProps, "Y" + si ) );
738 }
739
740 lineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" );
741}
742
743
744ASCH_WIRE::ASCH_WIRE( const std::map<wxString, wxString>& aProps ) :
745 ASCH_OWNER_INTERFACE( aProps )
746{
747 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::WIRE );
748
749 int locationcount = ALTIUM_PROPS_UTILS::ReadInt( aProps, "LOCATIONCOUNT", 0 );
750
751 for( int i = 1; i <= locationcount; i++ )
752 {
753 const wxString si = std::to_string( i );
754 points.emplace_back( ReadKiCadUnitFrac( aProps, "X" + si ),
755 -ReadKiCadUnitFrac( aProps, "Y" + si ) );
756 }
757
758 lineWidth = ReadKiCadUnitFrac( aProps, "LINEWIDTH" );
759}
760
761
762ASCH_JUNCTION::ASCH_JUNCTION( const std::map<wxString, wxString>& aProps ) :
763 ASCH_OWNER_INTERFACE( aProps )
764{
765 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::JUNCTION );
766
767
768 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
769 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
770}
771
772
773ASCH_IMAGE::ASCH_IMAGE( const std::map<wxString, wxString>& aProps ) :
774 ASCH_OWNER_INTERFACE( aProps ),
775 ASCH_BORDER_INTERFACE( aProps )
776{
777 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::IMAGE );
778
779 filename = ALTIUM_PROPS_UTILS::ReadString( aProps, "FILENAME", "" );
780
781 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
782 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
783 corner = VECTOR2I( ReadKiCadUnitFrac( aProps, "CORNER.X" ),
784 -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) );
785
786 embedimage = ALTIUM_PROPS_UTILS::ReadBool( aProps, "EMBEDIMAGE", false );
787 keepaspect = ALTIUM_PROPS_UTILS::ReadBool( aProps, "KEEPASPECT", false );
788}
789
790
791ASCH_SHEET_FONT::ASCH_SHEET_FONT( const std::map<wxString, wxString>& aProps, int aId ) :
792 ASCH_OWNER_INTERFACE( aProps )
793{
794 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SHEET );
795
796 const wxString sid = std::to_string( aId );
797
798 FontName = ALTIUM_PROPS_UTILS::ReadString( aProps, "FONTNAME" + sid, "" );
799
800 Size = ReadKiCadUnitFrac( aProps, "SIZE" + sid );
801 Rotation = ALTIUM_PROPS_UTILS::ReadInt( aProps, "ROTATION" + sid, 0 );
802
803 Italic = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ITALIC" + sid, false );
804 Bold = ALTIUM_PROPS_UTILS::ReadBool( aProps, "BOLD" + sid, false );
805 Underline = ALTIUM_PROPS_UTILS::ReadBool( aProps, "UNDERLINE" + sid, false );
806
807 AreaColor = ALTIUM_PROPS_UTILS::ReadInt( aProps, "AREACOLOR" + sid, 0 );
808}
809
810
812{
813 // From: https://github.com/vadmium/python-altium/blob/master/format.md#sheet
814 switch( aSheetSize )
815 {
816 default:
817 case ASCH_SHEET_SIZE::A4: return { 1150, 760 };
818 case ASCH_SHEET_SIZE::A3: return { 1550, 1110 };
819 case ASCH_SHEET_SIZE::A2: return { 2230, 1570 };
820 case ASCH_SHEET_SIZE::A1: return { 3150, 2230 };
821 case ASCH_SHEET_SIZE::A0: return { 4460, 3150 };
822 case ASCH_SHEET_SIZE::A: return { 950, 750 };
823 case ASCH_SHEET_SIZE::B: return { 1500, 950 };
824 case ASCH_SHEET_SIZE::C: return { 2000, 1500 };
825 case ASCH_SHEET_SIZE::D: return { 3200, 2000 };
826 case ASCH_SHEET_SIZE::E: return { 4200, 3200 };
827 case ASCH_SHEET_SIZE::LETTER: return { 1100, 850 };
828 case ASCH_SHEET_SIZE::LEGAL: return { 1400, 850 };
829 case ASCH_SHEET_SIZE::TABLOID: return { 1700, 1100 };
830 case ASCH_SHEET_SIZE::ORCAD_A: return { 990, 790 };
831 case ASCH_SHEET_SIZE::ORCAD_B: return { 1540, 990 };
832 case ASCH_SHEET_SIZE::ORCAD_C: return { 2060, 1560 };
833 case ASCH_SHEET_SIZE::ORCAD_D: return { 3260, 2060 };
834 case ASCH_SHEET_SIZE::ORCAD_E: return { 4280, 3280 };
835 }
836}
837
838
839ASCH_SHEET::ASCH_SHEET( const std::map<wxString, wxString>& aProps ) :
840 ASCH_OWNER_INTERFACE( aProps )
841{
842 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SHEET );
843
844 int fontidcount = ALTIUM_PROPS_UTILS::ReadInt( aProps, "FONTIDCOUNT", 0 );
845
846 for( int i = 1; i <= fontidcount; i++ )
847 fonts.emplace_back( aProps, i );
848
849 useCustomSheet = ALTIUM_PROPS_UTILS::ReadBool( aProps, "USECUSTOMSHEET", false );
850
851 customSize = VECTOR2I( ReadKiCadUnitFrac( aProps, "CUSTOMX" ),
852 ReadKiCadUnitFrac( aProps, "CUSTOMY" ) );
853
854 sheetSize = ReadEnum<ASCH_SHEET_SIZE>( aProps, "SHEETSTYLE", 0, 17, ASCH_SHEET_SIZE::A4 );
855 sheetOrientation = ReadEnum<ASCH_SHEET_WORKSPACEORIENTATION>(
856 aProps, "WORKSPACEORIENTATION", 0, 1, ASCH_SHEET_WORKSPACEORIENTATION::LANDSCAPE );
857}
858
859
860ASCH_SHEET_NAME::ASCH_SHEET_NAME( const std::map<wxString, wxString>& aProps ) :
861 ASCH_OWNER_INTERFACE( aProps )
862{
863 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::SHEET_NAME );
864
865 text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
866
867 orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
868 ASCH_RECORD_ORIENTATION::RIGHTWARDS );
869
870 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
871 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
872
873 isHidden = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISHIDDEN", false );
874}
875
876
877ASCH_FILE_NAME::ASCH_FILE_NAME( const std::map<wxString, wxString>& aProps ) :
878 ASCH_OWNER_INTERFACE( aProps )
879{
880 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::FILE_NAME );
881
882 text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
883
884 orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
885 ASCH_RECORD_ORIENTATION::RIGHTWARDS );
886
887 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
888 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
889
890 isHidden = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISHIDDEN", false );
891}
892
893
894ASCH_DESIGNATOR::ASCH_DESIGNATOR( const std::map<wxString, wxString>& aProps ) :
895 ASCH_OWNER_INTERFACE( aProps )
896{
897 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::DESIGNATOR );
898
899 name = ALTIUM_PROPS_UTILS::ReadString( aProps, "NAME", "" );
900 text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
901 fontId = ALTIUM_PROPS_UTILS::ReadInt( aProps, "FONTID", 0 );
902
903 justification = ReadEnum<ASCH_LABEL_JUSTIFICATION>( aProps, "JUSTIFICATION", 0, 8,
904 ASCH_LABEL_JUSTIFICATION::BOTTOM_LEFT );
905
906 orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
907 ASCH_RECORD_ORIENTATION::RIGHTWARDS );
908
909 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
910 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
911}
912
913
914ASCH_IMPLEMENTATION::ASCH_IMPLEMENTATION( const std::map<wxString, wxString>& aProps ) :
915 ASCH_OWNER_INTERFACE( aProps )
916{
917 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::IMPLEMENTATION );
918
920 name = ALTIUM_PROPS_UTILS::ReadString( aProps, "MODELNAME", "" );
921 type = ALTIUM_PROPS_UTILS::ReadString( aProps, "MODELTYPE", "" );
922 libname = ALTIUM_PROPS_UTILS::ReadString( aProps, "MODELDATAFILE0", "" );
923 description = ALTIUM_PROPS_UTILS::ReadString( aProps, "DESCRIPTION", "" );
924 isCurrent = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISCURRENT", false );
925}
926
927
928ASCH_IMPLEMENTATION_LIST::ASCH_IMPLEMENTATION_LIST( const std::map<wxString, wxString>& aProps ) :
929 ASCH_OWNER_INTERFACE( aProps )
930{
931 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::IMPLEMENTATION_LIST );
932}
933
934
935ASCH_BUS_ENTRY::ASCH_BUS_ENTRY( const std::map<wxString, wxString>& aProps ) :
936 ASCH_OWNER_INTERFACE( aProps )
937{
938 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::BUS_ENTRY );
939
940 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
941 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
942 corner = VECTOR2I( ReadKiCadUnitFrac( aProps, "CORNER.X" ),
943 -ReadKiCadUnitFrac( aProps, "CORNER.Y" ) );
944}
945
946
947ASCH_PARAMETER::ASCH_PARAMETER( const std::map<wxString, wxString>& aProps ) :
948 ASCH_OWNER_INTERFACE( aProps )
949{
950 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::PARAMETER );
951
952 location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
953 -ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
954
955 justification = ReadEnum<ASCH_LABEL_JUSTIFICATION>( aProps, "JUSTIFICATION", 0, 8,
956 ASCH_LABEL_JUSTIFICATION::BOTTOM_LEFT );
957
958 orientation = ReadEnum<ASCH_RECORD_ORIENTATION>( aProps, "ORIENTATION", 0, 3,
959 ASCH_RECORD_ORIENTATION::RIGHTWARDS );
960
961 name = ALTIUM_PROPS_UTILS::ReadString( aProps, "NAME", "" );
962 text = ALTIUM_PROPS_UTILS::ReadString( aProps, "TEXT", "" );
963
964 isHidden = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISHIDDEN", false );
965 isMirrored = ALTIUM_PROPS_UTILS::ReadBool( aProps, "ISMIRRORED", false );
966 isShowName = ALTIUM_PROPS_UTILS::ReadBool( aProps, "SHOWNAME", false );
967
968 fontId = ALTIUM_PROPS_UTILS::ReadInt( aProps, "FONTID", 0 );
969}
970
971
972ASCH_HYPERLINK::ASCH_HYPERLINK( const std::map<wxString, wxString>& aProps ) :
973 ASCH_LABEL( aProps )
974{
975 wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::HYPERLINK );
976
977 url = ALTIUM_PROPS_UTILS::ReadString( aProps, "URL", "" );
978}
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