KiCad PCB EDA Suite
drawing_sheet_parser.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) 1992-2013 Jean-Pierre Charras <jp.charras at wanadoo.fr>.
5 * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <charconv>
27#include <wx/ffile.h>
28#include <wx/log.h>
29#include <eda_item.h>
30#include <locale_io.h>
31#include <string_utils.h>
35#include <drawing_sheet/drawing_sheet_lexer.h>
37#include <font/font.h>
38
39using namespace DRAWINGSHEET_T;
40
46class DRAWING_SHEET_PARSER : public DRAWING_SHEET_LEXER
47{
48public:
49 DRAWING_SHEET_PARSER( const char* aLine, const wxString& aSource );
50 void Parse( DS_DATA_MODEL* aLayout );
51
52private:
54
59 void parseHeader( T aHeaderType );
60
64 int parseInt();
65
73 int parseInt( int aMin, int aMax );
74
80 double parseDouble();
81
82 void parseSetup( DS_DATA_MODEL* aLayout );
83
87 void parseGraphic( DS_DATA_ITEM * aItem );
88
92 void parseText( DS_DATA_ITEM_TEXT * aItem );
93
98 void parsePolygon( DS_DATA_ITEM_POLYGONS * aItem );
99
104
105
109 void parseBitmap( DS_DATA_ITEM_BITMAP * aItem );
110
111 void parseCoordinate( POINT_COORD& aCoord);
112 void readOption( DS_DATA_ITEM * aItem );
113 void readPngdata( DS_DATA_ITEM_BITMAP * aItem );
114};
115
116
118 const wxString& aSource ) :
119 DRAWING_SHEET_LEXER( aLine, aSource ),
120 m_requiredVersion( 0 )
121{
122}
123
124
125wxString convertLegacyVariableRefs( const wxString& aTextbase )
126{
127 wxString msg;
128
129 /*
130 * Legacy formats
131 * %% = replaced by %
132 * %K = Kicad version
133 * %Z = paper format name (A4, USLetter)
134 * %Y = company name
135 * %D = date
136 * %R = revision
137 * %S = sheet number
138 * %N = number of sheets
139 * %L = layer name
140 * %Cx = comment (x = 0 to 9 to identify the comment)
141 * %F = filename
142 * %P = sheet path (sheet full name)
143 * %T = title
144 */
145
146 for( unsigned ii = 0; ii < aTextbase.Len(); ii++ )
147 {
148 if( aTextbase[ii] != '%' )
149 {
150 msg << aTextbase[ii];
151 continue;
152 }
153
154 if( ++ii >= aTextbase.Len() )
155 break;
156
157 wxChar format = aTextbase[ii];
158
159 switch( format )
160 {
161 case '%': msg += '%'; break;
162 case 'D': msg += wxT( "${ISSUE_DATE}" ); break;
163 case 'R': msg += wxT( "${REVISION}" ); break;
164 case 'K': msg += wxT( "${KICAD_VERSION}" ); break;
165 case 'Z': msg += wxT( "${PAPER}" ); break;
166 case 'S': msg += wxT( "${#}" ); break;
167 case 'N': msg += wxT( "${##}" ); break;
168 case 'F': msg += wxT( "${FILENAME}" ); break;
169 case 'L': msg += wxT( "${LAYER}" ); break;
170 case 'P': msg += wxT( "${SHEETPATH}" ); break;
171 case 'Y': msg += wxT( "${COMPANY}" ); break;
172 case 'T': msg += wxT( "${TITLE}" ); break;
173 case 'C':
174 format = aTextbase[++ii];
175
176 switch( format )
177 {
178 case '0': msg += wxT( "${COMMENT1}" ); break;
179 case '1': msg += wxT( "${COMMENT2}" ); break;
180 case '2': msg += wxT( "${COMMENT3}" ); break;
181 case '3': msg += wxT( "${COMMENT4}" ); break;
182 case '4': msg += wxT( "${COMMENT5}" ); break;
183 case '5': msg += wxT( "${COMMENT6}" ); break;
184 case '6': msg += wxT( "${COMMENT7}" ); break;
185 case '7': msg += wxT( "${COMMENT8}" ); break;
186 case '8': msg += wxT( "${COMMENT9}" ); break;
187 }
188 break;
189
190 default:
191 break;
192 }
193 }
194
195 return msg;
196}
197
198
200{
201 DS_DATA_ITEM* item;
202 LOCALE_IO toggle;
203
204 NeedLEFT();
205 T token = NextTok();
206
207 parseHeader( token );
209
210 for( token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
211 {
212 if( token == T_LEFT )
213 token = NextTok();
214
215 switch( token )
216 {
217 case T_setup: // Defines default values for graphic items
218 parseSetup( aLayout );
219 break;
220
221 case T_line:
223 parseGraphic( item );
224 aLayout->Append( item );
225 break;
226
227 case T_rect:
229 parseGraphic( item );
230 aLayout->Append( item );
231 break;
232
233 case T_polygon:
234 item = new DS_DATA_ITEM_POLYGONS();
236 aLayout->Append( item );
237 break;
238
239 case T_bitmap:
240 item = new DS_DATA_ITEM_BITMAP( NULL );
242
243 // Drop invalid bitmaps
244 if( static_cast<DS_DATA_ITEM_BITMAP*>( item )->m_ImageBitmap->GetOriginalImageData() )
245 {
246 aLayout->Append( item );
247 }
248 else
249 {
250 delete static_cast<DS_DATA_ITEM_BITMAP*>( item )->m_ImageBitmap;
251 delete item;
252 }
253
254 break;
255
256 case T_tbtext:
257 NeedSYMBOLorNUMBER();
258 item = new DS_DATA_ITEM_TEXT( convertLegacyVariableRefs( FromUTF8() ) );
259 parseText( (DS_DATA_ITEM_TEXT*) item );
260 aLayout->Append( item );
261 break;
262
263 default:
264 Unexpected( CurText() );
265 break;
266 }
267 }
268}
269
271{
272 // The older files had no versioning and their first token after the initial left parenthesis
273 // was a `page_layout` or `drawing_sheet` token. The newer files have versions and have a
274 // `kicad_wks` token instead.
275
276 if( aHeaderType == T_kicad_wks || aHeaderType == T_drawing_sheet )
277 {
278 NeedLEFT();
279
280 T tok = NextTok();
281
282 if( tok == T_version )
283 {
285
287 throw FUTURE_FORMAT_ERROR( FromUTF8() );
288
289 NeedRIGHT();
290 }
291 else
292 {
293 Expecting( T_version );
294 }
295
296 // Ignore generator info.
297 NeedLEFT();
298 NeedSYMBOL();
299 NeedSYMBOL();
300 NeedRIGHT();
301 }
302 else
303 {
304 // We assign version 0 to files that were created before there was any versioning of
305 // worksheets. The below line is not strictly necessary, as `m_requiredVersion` is already
306 // initialized to 0 in the constructor.
308 }
309}
310
312{
313 for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
314 {
315 switch( token )
316 {
317 case T_LEFT:
318 break;
319
320 case T_linewidth:
321 aLayout->m_DefaultLineWidth = parseDouble();
322 NeedRIGHT();
323 break;
324
325 case T_textsize:
326 aLayout->m_DefaultTextSize.x = parseDouble();
327 aLayout->m_DefaultTextSize.y = parseDouble();
328 NeedRIGHT();
329 break;
330
331 case T_textlinewidth:
333 NeedRIGHT();
334 break;
335
336 case T_left_margin:
337 aLayout->SetLeftMargin( parseDouble() );
338 NeedRIGHT();
339 break;
340
341 case T_right_margin:
342 aLayout->SetRightMargin( parseDouble() );
343 NeedRIGHT();
344 break;
345
346 case T_top_margin:
347 aLayout->SetTopMargin( parseDouble() );
348 NeedRIGHT();
349 break;
350
351 case T_bottom_margin:
352 aLayout->SetBottomMargin( parseDouble() );
353 NeedRIGHT();
354 break;
355
356 default:
357 Unexpected( CurText() );
358 break;
359 }
360 }
361
362 // The file is well-formed. If it has no further items, then that's the way the
363 // user wants it.
364 aLayout->AllowVoidList( true );
365}
366
367
369{
370 for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
371 {
372 if( token == T_LEFT )
373 token = NextTok();
374
375 switch( token )
376 {
377 case T_comment:
378 NeedSYMBOLorNUMBER();
379 aItem->m_Info = FromUTF8();
380 NeedRIGHT();
381 break;
382
383 case T_pos:
384 parseCoordinate( aItem->m_Pos );
385 break;
386
387 case T_name:
388 NeedSYMBOLorNUMBER();
389 aItem->m_Name = FromUTF8();
390 NeedRIGHT();
391 break;
392
393 case T_option:
394 readOption( aItem );
395 break;
396
397 case T_pts:
398 parsePolyOutline( aItem );
399 aItem->CloseContour();
400 break;
401
402 case T_rotate:
404 NeedRIGHT();
405 break;
406
407 case T_repeat:
408 aItem->m_RepeatCount = parseInt( 1, 100 );
409 NeedRIGHT();
410 break;
411
412 case T_incrx:
414 NeedRIGHT();
415 break;
416
417 case T_incry:
419 NeedRIGHT();
420 break;
421
422 case T_linewidth:
423 aItem->m_LineWidth = parseDouble();
424 NeedRIGHT();
425 break;
426
427 default:
428 Unexpected( CurText() );
429 break;
430 }
431 }
432
433 aItem->SetBoundingBox();
434}
435
437{
438 VECTOR2D corner;
439
440 for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
441 {
442 if( token == T_LEFT )
443 token = NextTok();
444
445 switch( token )
446 {
447 case T_xy:
448 corner.x = parseDouble();
449 corner.y = parseDouble();
450 aItem->AppendCorner( corner );
451 NeedRIGHT();
452 break;
453
454 default:
455 Unexpected( CurText() );
456 break;
457 }
458 }
459}
460
461
463{
465 aItem->m_ImageBitmap = image;
466
467 for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
468 {
469 if( token == T_LEFT )
470 token = NextTok();
471
472 switch( token )
473 {
474 case T_name:
475 NeedSYMBOLorNUMBER();
476 aItem->m_Name = FromUTF8();
477 NeedRIGHT();
478 break;
479
480 case T_pos:
481 parseCoordinate( aItem->m_Pos );
482 break;
483
484 case T_repeat:
485 aItem->m_RepeatCount = parseInt( 1, 100 );
486 NeedRIGHT();
487 break;
488
489 case T_incrx:
491 NeedRIGHT();
492 break;
493
494 case T_incry:
496 NeedRIGHT();
497 break;
498
499 case T_linewidth:
500 aItem->m_LineWidth = parseDouble();
501 NeedRIGHT();
502 break;
503
504 case T_scale:
506 NeedRIGHT();
507 break;
508
509 case T_comment:
510 NeedSYMBOLorNUMBER();
511 aItem->m_Info = FromUTF8();
512 NeedRIGHT();
513 break;
514
515 case T_pngdata:
516 readPngdata( aItem );
517 break;
518
519 case T_option:
520 readOption( aItem );
521 break;
522
523 default:
524 Unexpected( CurText() );
525 break;
526 }
527 }
528}
529
531{
532 std::string tmp;
533
534 for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
535 {
536 if( token == T_LEFT )
537 token = NextTok();
538
539 switch( token )
540 {
541 case T_data:
542 NeedSYMBOLorNUMBER();
543 tmp += CurStr();
544 tmp += "\n";
545 NeedRIGHT();
546 break;
547
548 default:
549 Unexpected( CurText() );
550 break;
551 }
552 }
553
554 tmp += "EndData";
555
556 wxString msg;
557 STRING_LINE_READER str_reader( tmp, wxT("Png kicad_wks data") );
558
559 if( ! aItem->m_ImageBitmap->LoadData( str_reader, msg ) )
560 wxLogMessage(msg);
561}
562
563
565{
566 for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
567 {
568 switch( token )
569 {
570 case T_page1only: aItem->SetPage1Option( FIRST_PAGE_ONLY ); break;
571 case T_notonpage1: aItem->SetPage1Option( SUBSEQUENT_PAGES ); break;
572 default: Unexpected( CurText() ); break;
573 }
574 }
575}
576
577
579{
580 for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
581 {
582 if( token == T_LEFT )
583 token = NextTok();
584 else
585 {
586 // If another token than T_LEFT is read here, this is an error
587 // however, due to a old bug in kicad, the token T_end can be found
588 // without T_LEFT in a very few .wks files (perhaps only one in a demo).
589 // So this ugly hack disables the error detection.
590 if( token != T_end )
591 Unexpected( CurText() );
592 }
593
594 switch( token )
595 {
596 case T_comment:
597 NeedSYMBOLorNUMBER();
598 aItem->m_Info = FromUTF8();
599 NeedRIGHT();
600 break;
601
602 case T_option:
603 readOption( aItem );
604 break;
605
606 case T_name:
607 NeedSYMBOLorNUMBER();
608 aItem->m_Name = FromUTF8();
609 NeedRIGHT();
610 break;
611
612 case T_start:
613 parseCoordinate( aItem->m_Pos );
614 break;
615
616 case T_end:
617 parseCoordinate( aItem->m_End );
618 break;
619
620 case T_repeat:
621 aItem->m_RepeatCount = parseInt( 1, 100 );
622 NeedRIGHT();
623 break;
624
625 case T_incrx:
627 NeedRIGHT();
628 break;
629
630 case T_incry:
632 NeedRIGHT();
633 break;
634
635 case T_linewidth:
636 aItem->m_LineWidth = parseDouble();
637 NeedRIGHT();
638 break;
639
640 default:
641 Unexpected( CurText() );
642 break;
643 }
644 }
645}
646
647
649{
650 if( m_requiredVersion < 20210606 )
652
653 for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
654 {
655 if( token == T_LEFT )
656 token = NextTok();
657
658 switch( token )
659 {
660 case T_comment:
661 NeedSYMBOLorNUMBER();
662 aItem->m_Info = FromUTF8();
663 NeedRIGHT();
664 break;
665
666 case T_option:
667 readOption( aItem );
668 break;
669
670 case T_name:
671 NeedSYMBOLorNUMBER();
672 aItem->m_Name = FromUTF8();
673 NeedRIGHT();
674 break;
675
676 case T_pos:
677 parseCoordinate( aItem->m_Pos );
678 break;
679
680 case T_repeat:
681 aItem->m_RepeatCount = parseInt( 1, 100 );
682 NeedRIGHT();
683 break;
684
685 case T_incrx:
687 NeedRIGHT();
688 break;
689
690 case T_incry:
692 NeedRIGHT();
693 break;
694
695 case T_incrlabel:
696 aItem->m_IncrementLabel = parseInt(INT_MIN, INT_MAX);
697 NeedRIGHT();
698 break;
699
700 case T_maxlen:
702 NeedRIGHT();
703 break;
704
705 case T_maxheight:
707 NeedRIGHT();
708 break;
709
710 case T_font:
711 {
712 wxString faceName;
713
714 aItem->m_TextColor = COLOR4D::UNSPECIFIED;
715
716 for( token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
717 {
718 switch( token )
719 {
720 case T_LEFT:
721 break;
722
723 case T_face:
724 NeedSYMBOL();
725 faceName = FromUTF8();
726 NeedRIGHT();
727 break;
728
729 case T_bold:
730 aItem->m_Bold = true;
731 break;
732
733 case T_italic:
734 aItem->m_Italic = true;
735 break;
736
737 case T_size:
738 aItem->m_TextSize.x = parseDouble();
739 aItem->m_TextSize.y = parseDouble();
740 NeedRIGHT();
741 break;
742
743 case T_color:
744 aItem->m_TextColor.r = parseInt( 0, 255 ) / 255.0;
745 aItem->m_TextColor.g = parseInt( 0, 255 ) / 255.0;
746 aItem->m_TextColor.b = parseInt( 0, 255 ) / 255.0;
747 aItem->m_TextColor.a = Clamp( parseDouble(), 0.0, 1.0 );
748 NeedRIGHT();
749 break;
750
751 case T_linewidth:
752 aItem->m_LineWidth = parseDouble();
753 NeedRIGHT();
754 break;
755
756 default:
757 Unexpected( CurText() );
758 break;
759 }
760 }
761
762 if( !faceName.IsEmpty() )
763 aItem->m_Font = KIFONT::FONT::GetFont( faceName, aItem->m_Bold, aItem->m_Italic );
764
765 break;
766 }
767
768 case T_justify:
769 for( token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
770 {
771 switch( token )
772 {
773 case T_center:
776 break;
777
778 case T_left:
780 break;
781
782 case T_right:
784 break;
785
786 case T_top:
788 break;
789
790 case T_bottom:
792 break;
793
794 default:
795 Unexpected( CurText() );
796 break;
797 }
798 }
799 break;
800
801 case T_rotate:
802 aItem->m_Orient = parseDouble();
803 NeedRIGHT();
804 break;
805
806 default:
807 Unexpected( CurText() );
808 break;
809 }
810 }
811}
812
813// parse an expression like " 25 1 ltcorner)"
815{
816 aCoord.m_Pos.x = parseDouble();
817 aCoord.m_Pos.y = parseDouble();
818
819 for( T token = NextTok(); token != T_RIGHT && token != EOF; token = NextTok() )
820 {
821 switch( token )
822 {
823 case T_ltcorner: aCoord.m_Anchor = LT_CORNER; break;
824 case T_lbcorner: aCoord.m_Anchor = LB_CORNER; break;
825 case T_rbcorner: aCoord.m_Anchor = RB_CORNER; break;
826 case T_rtcorner: aCoord.m_Anchor = RT_CORNER; break;
827 default: Unexpected( CurText() ); break;
828 }
829 }
830}
831
833{
834 T token = NextTok();
835
836 if( token != T_NUMBER )
837 Expecting( T_NUMBER );
838
839 return atoi( CurText() );
840}
841
842int DRAWING_SHEET_PARSER::parseInt( int aMin, int aMax )
843{
844 int val = parseInt();
845
846 if( val < aMin )
847 val = aMin;
848 else if( val > aMax )
849 val = aMax;
850
851 return val;
852}
853
854
856{
857 T token = NextTok();
858
859 if( token != T_NUMBER )
860 Expecting( T_NUMBER );
861
862
863 return DSNLEXER::parseDouble();
864}
865
866// defaultDrawingSheet is the default drawing sheet using the S expr.
867extern const char defaultDrawingSheet[];
868
870{
871 SetPageLayout( defaultDrawingSheet, false, wxT( "default page" ) );
872}
873
874// Returns defaultDrawingSheet as a string;
876{
877 return wxString( defaultDrawingSheet );
878}
879
880// emptyDrawingSheet is a "empty" drawing sheet using the S expr.
881// there is a 0 length line to fool something somewhere.
882extern const char emptyDrawingSheet[];
883
885{
886 SetPageLayout( emptyDrawingSheet, false, wxT( "empty page" ) );
887}
888
889
891{
892 return wxString( emptyDrawingSheet );
893}
894
895
896void DS_DATA_MODEL::SetPageLayout( const char* aPageLayout, bool Append, const wxString& aSource )
897{
898 if( ! Append )
899 ClearList();
900
901 DRAWING_SHEET_PARSER parser( aPageLayout, wxT( "Sexpr_string" ) );
902
903 try
904 {
905 parser.Parse( this );
906 }
907 catch( const IO_ERROR& ioe )
908 {
909 wxLogMessage( ioe.What() );
910 }
911 catch( const std::bad_alloc& )
912 {
913 wxLogMessage( wxS( "Memory exhaustion reading drawing sheet" ) );
914 }
915}
916
917
918bool DS_DATA_MODEL::LoadDrawingSheet( const wxString& aFullFileName, bool Append )
919{
920 wxString fullFileName = aFullFileName;
921
922 if( !Append )
923 {
924 if( fullFileName.IsEmpty() )
925 {
927 return true; // we assume its fine / default init
928 }
929
930 if( !wxFileExists( fullFileName ) )
931 {
932 wxLogMessage( _( "Drawing sheet '%s' not found." ), fullFileName );
934 return false;
935 }
936 }
937
938 wxFFile wksFile( fullFileName, wxS( "rb" ) );
939
940 if( ! wksFile.IsOpened() )
941 {
942 wxLogMessage( _( "Drawing sheet '%s' could not be opened." ), fullFileName );
943
944 if( !Append )
946
947 return false;
948 }
949
950 size_t filelen = wksFile.Length();
951 std::unique_ptr<char[]> buffer = std::make_unique<char[]>(filelen+10);
952
953 if( wksFile.Read( buffer.get(), filelen ) != filelen )
954 {
955 wxLogMessage( _( "Drawing sheet '%s' was not fully read." ), fullFileName.GetData() );
956 return false;
957 }
958 else
959 {
960 buffer[filelen]=0;
961
962 if( ! Append )
963 ClearList();
964
965 DRAWING_SHEET_PARSER parser( buffer.get(), fullFileName );
966
967 try
968 {
969 parser.Parse( this );
970 }
971 catch( const IO_ERROR& ioe )
972 {
973 wxLogMessage( ioe.What() );
974 return false;
975 }
976 catch( const std::bad_alloc& )
977 {
978 wxLogMessage( wxS( "Memory exhaustion reading drawing sheet" ) );
979 return false;
980 }
981 }
982
983 return true;
984}
This class handle bitmap images in KiCad.
Definition: bitmap_base.h:52
bool LoadData(LINE_READER &aLine, wxString &aErrorMsg)
Load an image data saved by SaveData.
void SetScale(double aScale)
Definition: bitmap_base.h:79
DRAWING_SHEET_PARSER holds data and functions pertinent to parsing a S-expression file for a DS_DATA_...
void parseCoordinate(POINT_COORD &aCoord)
void parseHeader(T aHeaderType)
Parse the data specified at the very beginning of the file, like version and the application used to ...
DRAWING_SHEET_PARSER(const char *aLine, const wxString &aSource)
void parseBitmap(DS_DATA_ITEM_BITMAP *aItem)
Parse a bitmap item starting by "( bitmap" and read parameters.
void readPngdata(DS_DATA_ITEM_BITMAP *aItem)
void parsePolygon(DS_DATA_ITEM_POLYGONS *aItem)
Parse a polygon item starting by "( polygon" and read parameters.
void parseText(DS_DATA_ITEM_TEXT *aItem)
Parse a text item starting by "(tbtext" and read parameters.
void Parse(DS_DATA_MODEL *aLayout)
int parseInt()
Parse an integer.
void readOption(DS_DATA_ITEM *aItem)
double parseDouble()
Parse a double.
void parseSetup(DS_DATA_MODEL *aLayout)
void parseGraphic(DS_DATA_ITEM *aItem)
Parse a graphic item starting by "(line" or "(rect" and read parameters.
void parsePolyOutline(DS_DATA_ITEM_POLYGONS *aItem)
Parse a list of corners starting by "( pts" and read coordinates.
double parseDouble()
Parse the current token as an ASCII numeric string with possible leading whitespace into a double pre...
Definition: dsnlexer.cpp:825
BITMAP_BASE * m_ImageBitmap
Definition: ds_data_item.h:370
void SetBoundingBox()
Calculate the bounding box of the set polygons.
void CloseContour()
Close the current contour, by storing the index of the last corner of the current polygon in m_polyIn...
Definition: ds_data_item.h:238
void AppendCorner(const VECTOR2D &aCorner)
Add a corner in corner list.
Definition: ds_data_item.h:229
KIFONT::FONT * m_Font
Definition: ds_data_item.h:342
GR_TEXT_H_ALIGN_T m_Hjustify
Definition: ds_data_item.h:338
KIGFX::COLOR4D m_TextColor
Definition: ds_data_item.h:344
VECTOR2D m_BoundingBoxSize
Definition: ds_data_item.h:345
GR_TEXT_V_ALIGN_T m_Vjustify
Definition: ds_data_item.h:339
Drawing sheet structure type definitions.
Definition: ds_data_item.h:96
void SetPage1Option(PAGE_OPTION aChoice)
Definition: ds_data_item.h:134
wxString m_Name
Definition: ds_data_item.h:198
VECTOR2D m_IncrementVector
Definition: ds_data_item.h:204
POINT_COORD m_Pos
Definition: ds_data_item.h:200
wxString m_Info
Definition: ds_data_item.h:199
double m_LineWidth
Definition: ds_data_item.h:202
POINT_COORD m_End
Definition: ds_data_item.h:201
int m_IncrementLabel
Definition: ds_data_item.h:205
Handle the graphic items list to draw/plot the frame and title block.
Definition: ds_data_model.h:39
void SetBottomMargin(double aMargin)
Definition: ds_data_model.h:73
VECTOR2D m_DefaultTextSize
void SetRightMargin(double aMargin)
Definition: ds_data_model.h:67
double m_DefaultLineWidth
static wxString DefaultLayout()
Return a string containing the empty layout shape.
static wxString EmptyLayout()
Return a string containing the empty layout shape.
void SetLeftMargin(double aMargin)
Definition: ds_data_model.h:64
double m_DefaultTextThickness
void Append(DS_DATA_ITEM *aItem)
void AllowVoidList(bool Allow)
In KiCad applications, a drawing sheet is needed So if the list is empty, a default drawing sheet is ...
Definition: ds_data_model.h:83
void ClearList()
Erase the list of items.
void SetTopMargin(double aMargin)
Definition: ds_data_model.h:70
void SetFileFormatVersionAtLoad(int aVersion)
Definition: ds_data_model.h:61
void SetPageLayout(const char *aPageLayout, bool aAppend=false, const wxString &aSource=wxT("Sexpr_string"))
Populate the list from a S expr description stored in a string.
bool LoadDrawingSheet(const wxString &aFullFileName=wxEmptyString, bool Append=false)
Populates the list with a custom layout or the default layout if no custom layout is available.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:76
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
Definition: font.cpp:138
double r
Red component.
Definition: color4d.h:372
double g
Green component.
Definition: color4d.h:373
double a
Alpha component.
Definition: color4d.h:375
double b
Blue component.
Definition: color4d.h:374
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:41
A coordinate point.
Definition: ds_data_item.h:70
VECTOR2D m_Pos
Definition: ds_data_item.h:80
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:241
const char emptyDrawingSheet[]
wxString convertLegacyVariableRefs(const wxString &aTextbase)
const char defaultDrawingSheet[]
@ FIRST_PAGE_ONLY
Definition: ds_data_item.h:58
@ SUBSEQUENT_PAGES
Definition: ds_data_item.h:59
@ RB_CORNER
Definition: ds_data_item.h:49
@ RT_CORNER
Definition: ds_data_item.h:50
@ LT_CORNER
Definition: ds_data_item.h:52
@ LB_CORNER
Definition: ds_data_item.h:51
#define SEXPR_WORKSHEET_FILE_VERSION
This file contains the file format version information for the s-expression drawing sheet file format...
#define _(s)
@ DEGREES_T
Definition: eda_angle.h:31
wxString ConvertToNewOverbarNotation(const wxString &aOldStr)
Convert the old ~...~ overbar notation to the new ~{...} one.
Variant of PARSE_ERROR indicating that a syntax or related error was likely caused by a file generate...
Definition: ki_exception.h:175
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_TOP
constexpr T Clamp(const T &lower, const T &value, const T &upper)
Limit value within the range lower <= value <= upper.
Definition: util.h:64