Browse Source
All: use a S expression to describe the page layout (title block and grid references). Work in progress.
All: use a S expression to describe the page layout (title block and grid references). Work in progress.
This should allow users to define their own page layout.pull/1/head
20 changed files with 1182 additions and 1080 deletions
-
2.bzrignore
-
18Documentation/compiling/COMPILING.txt
-
14Documentation/compiling/build-config.txt
-
22Documentation/compiling/build-msw.txt
-
7Documentation/compiling/mac-osx.txt
-
530Documentation/releases/2010-mar-14.html
-
40Documentation/releases/2010-mar-14.txt
-
12common/CMakeLists.txt
-
1common/hotkeys_basic.cpp
-
72common/page_layout_default_description.cpp
-
461common/page_layout_reader.cpp
-
35common/page_layout_reader.keywords
-
586common/title_block_shapes.cpp
-
13common/title_block_shapes_gost.cpp
-
68common/worksheet.cpp
-
121include/class_title_block.h
-
2include/vector2d.h
-
15include/worksheet.h
-
203include/worksheet_shape_builder.h
-
40pcbnew/kicad_plugin.cpp
@ -1,530 +0,0 @@ |
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" |
|||
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
|||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> |
|||
<head> |
|||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
|||
<meta name="generator" content="AsciiDoc 8.4.5" /> |
|||
<title>KiCad 2010-xx-xx Release</title> |
|||
<style type="text/css"> |
|||
/* Debug borders */ |
|||
p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 { |
|||
/* |
|||
border: 1px solid red; |
|||
*/ |
|||
} |
|||
|
|||
body { |
|||
margin: 1em 5% 1em 5%; |
|||
} |
|||
|
|||
a { |
|||
color: blue; |
|||
text-decoration: underline; |
|||
} |
|||
a:visited { |
|||
color: fuchsia; |
|||
} |
|||
|
|||
em { |
|||
font-style: italic; |
|||
color: navy; |
|||
} |
|||
|
|||
strong { |
|||
font-weight: bold; |
|||
color: #083194; |
|||
} |
|||
|
|||
tt { |
|||
color: navy; |
|||
} |
|||
|
|||
h1, h2, h3, h4, h5, h6 { |
|||
color: #527bbd; |
|||
font-family: sans-serif; |
|||
margin-top: 1.2em; |
|||
margin-bottom: 0.5em; |
|||
line-height: 1.3; |
|||
} |
|||
|
|||
h1, h2, h3 { |
|||
border-bottom: 2px solid silver; |
|||
} |
|||
h2 { |
|||
padding-top: 0.5em; |
|||
} |
|||
h3 { |
|||
float: left; |
|||
} |
|||
h3 + * { |
|||
clear: left; |
|||
} |
|||
|
|||
div.sectionbody { |
|||
font-family: serif; |
|||
margin-left: 0; |
|||
} |
|||
|
|||
hr { |
|||
border: 1px solid silver; |
|||
} |
|||
|
|||
p { |
|||
margin-top: 0.5em; |
|||
margin-bottom: 0.5em; |
|||
} |
|||
|
|||
ul, ol, li > p { |
|||
margin-top: 0; |
|||
} |
|||
|
|||
pre { |
|||
padding: 0; |
|||
margin: 0; |
|||
} |
|||
|
|||
span#author { |
|||
color: #527bbd; |
|||
font-family: sans-serif; |
|||
font-weight: bold; |
|||
font-size: 1.1em; |
|||
} |
|||
span#email { |
|||
} |
|||
span#revnumber, span#revdate, span#revremark { |
|||
font-family: sans-serif; |
|||
} |
|||
|
|||
div#footer { |
|||
font-family: sans-serif; |
|||
font-size: small; |
|||
border-top: 2px solid silver; |
|||
padding-top: 0.5em; |
|||
margin-top: 4.0em; |
|||
} |
|||
div#footer-text { |
|||
float: left; |
|||
padding-bottom: 0.5em; |
|||
} |
|||
div#footer-badges { |
|||
float: right; |
|||
padding-bottom: 0.5em; |
|||
} |
|||
|
|||
div#preamble { |
|||
margin-top: 1.5em; |
|||
margin-bottom: 1.5em; |
|||
} |
|||
div.tableblock, div.imageblock, div.exampleblock, div.verseblock, |
|||
div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, |
|||
div.admonitionblock { |
|||
margin-top: 1.5em; |
|||
margin-bottom: 1.5em; |
|||
} |
|||
div.admonitionblock { |
|||
margin-top: 2.5em; |
|||
margin-bottom: 2.5em; |
|||
} |
|||
|
|||
div.content { /* Block element content. */ |
|||
padding: 0; |
|||
} |
|||
|
|||
/* Block element titles. */ |
|||
div.title, caption.title { |
|||
color: #527bbd; |
|||
font-family: sans-serif; |
|||
font-weight: bold; |
|||
text-align: left; |
|||
margin-top: 1.0em; |
|||
margin-bottom: 0.5em; |
|||
} |
|||
div.title + * { |
|||
margin-top: 0; |
|||
} |
|||
|
|||
td div.title:first-child { |
|||
margin-top: 0.0em; |
|||
} |
|||
div.content div.title:first-child { |
|||
margin-top: 0.0em; |
|||
} |
|||
div.content + div.title { |
|||
margin-top: 0.0em; |
|||
} |
|||
|
|||
div.sidebarblock > div.content { |
|||
background: #ffffee; |
|||
border: 1px solid silver; |
|||
padding: 0.5em; |
|||
} |
|||
|
|||
div.listingblock > div.content { |
|||
border: 1px solid silver; |
|||
background: #f4f4f4; |
|||
padding: 0.5em; |
|||
} |
|||
|
|||
div.quoteblock { |
|||
padding-left: 2.0em; |
|||
margin-right: 10%; |
|||
} |
|||
div.quoteblock > div.attribution { |
|||
padding-top: 0.5em; |
|||
text-align: right; |
|||
} |
|||
|
|||
div.verseblock { |
|||
padding-left: 2.0em; |
|||
margin-right: 10%; |
|||
} |
|||
div.verseblock > div.content { |
|||
white-space: pre; |
|||
} |
|||
div.verseblock > div.attribution { |
|||
padding-top: 0.75em; |
|||
text-align: left; |
|||
} |
|||
/* DEPRECATED: Pre version 8.2.7 verse style literal block. */ |
|||
div.verseblock + div.attribution { |
|||
text-align: left; |
|||
} |
|||
|
|||
div.admonitionblock .icon { |
|||
vertical-align: top; |
|||
font-size: 1.1em; |
|||
font-weight: bold; |
|||
text-decoration: underline; |
|||
color: #527bbd; |
|||
padding-right: 0.5em; |
|||
} |
|||
div.admonitionblock td.content { |
|||
padding-left: 0.5em; |
|||
border-left: 2px solid silver; |
|||
} |
|||
|
|||
div.exampleblock > div.content { |
|||
border-left: 2px solid silver; |
|||
padding: 0.5em; |
|||
} |
|||
|
|||
div.imageblock div.content { padding-left: 0; } |
|||
span.image img { border-style: none; } |
|||
a.image:visited { color: white; } |
|||
|
|||
dl { |
|||
margin-top: 0.8em; |
|||
margin-bottom: 0.8em; |
|||
} |
|||
dt { |
|||
margin-top: 0.5em; |
|||
margin-bottom: 0; |
|||
font-style: normal; |
|||
color: navy; |
|||
} |
|||
dd > *:first-child { |
|||
margin-top: 0.1em; |
|||
} |
|||
|
|||
ul, ol { |
|||
list-style-position: outside; |
|||
} |
|||
ol.arabic { |
|||
list-style-type: decimal; |
|||
} |
|||
ol.loweralpha { |
|||
list-style-type: lower-alpha; |
|||
} |
|||
ol.upperalpha { |
|||
list-style-type: upper-alpha; |
|||
} |
|||
ol.lowerroman { |
|||
list-style-type: lower-roman; |
|||
} |
|||
ol.upperroman { |
|||
list-style-type: upper-roman; |
|||
} |
|||
|
|||
div.compact ul, div.compact ol, |
|||
div.compact p, div.compact p, |
|||
div.compact div, div.compact div { |
|||
margin-top: 0.1em; |
|||
margin-bottom: 0.1em; |
|||
} |
|||
|
|||
div.tableblock > table { |
|||
border: 3px solid #527bbd; |
|||
} |
|||
thead { |
|||
font-family: sans-serif; |
|||
font-weight: bold; |
|||
} |
|||
tfoot { |
|||
font-weight: bold; |
|||
} |
|||
td > div.verse { |
|||
white-space: pre; |
|||
} |
|||
p.table { |
|||
margin-top: 0; |
|||
} |
|||
/* Because the table frame attribute is overriden by CSS in most browsers. */ |
|||
div.tableblock > table[frame="void"] { |
|||
border-style: none; |
|||
} |
|||
div.tableblock > table[frame="hsides"] { |
|||
border-left-style: none; |
|||
border-right-style: none; |
|||
} |
|||
div.tableblock > table[frame="vsides"] { |
|||
border-top-style: none; |
|||
border-bottom-style: none; |
|||
} |
|||
|
|||
|
|||
div.hdlist { |
|||
margin-top: 0.8em; |
|||
margin-bottom: 0.8em; |
|||
} |
|||
div.hdlist tr { |
|||
padding-bottom: 15px; |
|||
} |
|||
dt.hdlist1.strong, td.hdlist1.strong { |
|||
font-weight: bold; |
|||
} |
|||
td.hdlist1 { |
|||
vertical-align: top; |
|||
font-style: normal; |
|||
padding-right: 0.8em; |
|||
color: navy; |
|||
} |
|||
td.hdlist2 { |
|||
vertical-align: top; |
|||
} |
|||
div.hdlist.compact tr { |
|||
margin: 0; |
|||
padding-bottom: 0; |
|||
} |
|||
|
|||
.comment { |
|||
background: yellow; |
|||
} |
|||
|
|||
@media print { |
|||
div#footer-badges { display: none; } |
|||
} |
|||
|
|||
div#toctitle { |
|||
color: #527bbd; |
|||
font-family: sans-serif; |
|||
font-size: 1.1em; |
|||
font-weight: bold; |
|||
margin-top: 1.0em; |
|||
margin-bottom: 0.1em; |
|||
} |
|||
|
|||
div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 { |
|||
margin-top: 0; |
|||
margin-bottom: 0; |
|||
} |
|||
div.toclevel2 { |
|||
margin-left: 2em; |
|||
font-size: 0.9em; |
|||
} |
|||
div.toclevel3 { |
|||
margin-left: 4em; |
|||
font-size: 0.9em; |
|||
} |
|||
div.toclevel4 { |
|||
margin-left: 6em; |
|||
font-size: 0.9em; |
|||
} |
|||
/* Workarounds for IE6's broken and incomplete CSS2. */ |
|||
|
|||
div.sidebar-content { |
|||
background: #ffffee; |
|||
border: 1px solid silver; |
|||
padding: 0.5em; |
|||
} |
|||
div.sidebar-title, div.image-title { |
|||
color: #527bbd; |
|||
font-family: sans-serif; |
|||
font-weight: bold; |
|||
margin-top: 0.0em; |
|||
margin-bottom: 0.5em; |
|||
} |
|||
|
|||
div.listingblock div.content { |
|||
border: 1px solid silver; |
|||
background: #f4f4f4; |
|||
padding: 0.5em; |
|||
} |
|||
|
|||
div.quoteblock-attribution { |
|||
padding-top: 0.5em; |
|||
text-align: right; |
|||
} |
|||
|
|||
div.verseblock-content { |
|||
white-space: pre; |
|||
} |
|||
div.verseblock-attribution { |
|||
padding-top: 0.75em; |
|||
text-align: left; |
|||
} |
|||
|
|||
div.exampleblock-content { |
|||
border-left: 2px solid silver; |
|||
padding-left: 0.5em; |
|||
} |
|||
|
|||
/* IE6 sets dynamically generated links as visited. */ |
|||
div#toc a:visited { color: blue; } |
|||
</style> |
|||
</head> |
|||
<body> |
|||
<div id="header"> |
|||
<h1>KiCad 2010-xx-xx Release</h1> |
|||
</div> |
|||
<h2 id="_common">Common</h2> |
|||
<div class="sectionbody"> |
|||
<div class="ulist"><ul> |
|||
<li> |
|||
<p> |
|||
Actions can now be undo and redo |
|||
</p> |
|||
</li> |
|||
<li> |
|||
<p> |
|||
Menus and tooltips more clear |
|||
</p> |
|||
</li> |
|||
<li> |
|||
<p> |
|||
File history now in Open Recent submenu |
|||
</p> |
|||
</li> |
|||
<li> |
|||
<p> |
|||
Many new hotkeys added |
|||
</p> |
|||
</li> |
|||
<li> |
|||
<p> |
|||
Plot and print dialog rewritten |
|||
</p> |
|||
</li> |
|||
<li> |
|||
<p> |
|||
Remember last dialog position and tab |
|||
</p> |
|||
</li> |
|||
<li> |
|||
<p> |
|||
Better font shapes |
|||
</p> |
|||
</li> |
|||
<li> |
|||
<p> |
|||
Generation of bill of materials |
|||
</p> |
|||
</li> |
|||
<li> |
|||
<p> |
|||
Plot SVG output |
|||
</p> |
|||
</li> |
|||
</ul></div> |
|||
</div> |
|||
<h2 id="_kicad">KiCad</h2> |
|||
<div class="sectionbody"> |
|||
<div class="ulist"><ul> |
|||
<li> |
|||
<p> |
|||
Issue fixed when opening a project in a directory with a lot of subdirectories |
|||
</p> |
|||
</li> |
|||
<li> |
|||
<p> |
|||
If project is noname.pro no <tt>error</tt> will be displayed |
|||
</p> |
|||
</li> |
|||
</ul></div> |
|||
</div> |
|||
<h2 id="_eeschema">EESchema</h2> |
|||
<div class="sectionbody"> |
|||
<div class="ulist"><ul> |
|||
<li> |
|||
<p> |
|||
New pin properties dialog |
|||
</p> |
|||
</li> |
|||
</ul></div> |
|||
</div> |
|||
<h2 id="_pcbnew">PCBNew</h2> |
|||
<div class="sectionbody"> |
|||
<div class="ulist"><ul> |
|||
<li> |
|||
<p> |
|||
Advanced layer setup |
|||
</p> |
|||
</li> |
|||
<li> |
|||
<p> |
|||
New panel for layer management |
|||
</p> |
|||
</li> |
|||
<li> |
|||
<p> |
|||
Support for net classes |
|||
</p> |
|||
</li> |
|||
<li> |
|||
<p> |
|||
Incorrect DRC error fixed, DRC min via and min track check |
|||
</p> |
|||
</li> |
|||
<li> |
|||
<p> |
|||
Handle local mask clearance and local net clearance |
|||
</p> |
|||
</li> |
|||
<li> |
|||
<p> |
|||
Handle zones in connectivity calculations |
|||
</p> |
|||
</li> |
|||
</ul></div> |
|||
</div> |
|||
<h2 id="_core">Core</h2> |
|||
<div class="sectionbody"> |
|||
<div class="ulist"><ul> |
|||
<li> |
|||
<p> |
|||
Many many bugfixes and cleanups |
|||
</p> |
|||
</li> |
|||
<li> |
|||
<p> |
|||
All comments translated to English |
|||
</p> |
|||
</li> |
|||
<li> |
|||
<p> |
|||
Moved to wxAUI and dialogs created with wxFormBuilder |
|||
</p> |
|||
</li> |
|||
<li> |
|||
<p> |
|||
Full support for Mac OS X with wxWidgets 2.9 |
|||
</p> |
|||
</li> |
|||
</ul></div> |
|||
</div> |
|||
<div id="footer"> |
|||
<div id="footer-text"> |
|||
Last updated 2010-02-21 13:41:09 CEST |
|||
</div> |
|||
</div> |
|||
</body> |
|||
</html> |
|||
@ -1,40 +0,0 @@ |
|||
KiCad 2010-xx-xx Release |
|||
======================== |
|||
|
|||
== Common |
|||
* Actions can now be undo and redo |
|||
* Menus and tooltips more clear |
|||
* File history now in Open Recent submenu |
|||
* Many new hotkeys added |
|||
* Plot and print dialog rewritten |
|||
* Remember last dialog position and tab |
|||
* Better font shapes |
|||
* Generation of bill of materials |
|||
* Plot SVG output |
|||
|
|||
== KiCad |
|||
* Issue fixed when opening a project in a directory with a lot of subdirectories. |
|||
* If project is noname.pro no `error` will be displayed |
|||
|
|||
== EESchema |
|||
* New pin properties dialog |
|||
|
|||
== PCBNew |
|||
* Plot DXF output |
|||
* Advanced layer setup |
|||
* New panel for layer management |
|||
* Support for net classes |
|||
* Incorrect DRC error fixed, DRC min via and min track check |
|||
* Handle local mask clearance and local net clearance |
|||
* Handle zones in connectivity calculations |
|||
|
|||
== Core |
|||
* Many many bugfixes and cleanups |
|||
* All comments translated to English |
|||
* Moved to wxAUI and dialogs created with wxFormBuilder |
|||
* Full support for Mac OS X with wxWidgets 2.9 |
|||
|
|||
/////////////////////////////////////// |
|||
This is a asciidoc formatted file, it can be converted |
|||
to PDF,(XHTML) and others. See asciidoc homepage. |
|||
/////////////////////////////////////// |
|||
@ -0,0 +1,72 @@ |
|||
/**
|
|||
* @file page_layout_default_description.cpp |
|||
*/ |
|||
|
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 1992-2013 Jean-Pierre Charras <jp.charras at wanadoo.fr>. |
|||
* Copyright (C) 1992-2013 KiCad Developers, see change_log.txt for contributors. |
|||
* |
|||
* |
|||
* This program is free software; you can redistribute it and/or |
|||
* modify it under the terms of the GNU General Public License |
|||
* as published by the Free Software Foundation; either version 2 |
|||
* of the License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|||
* or you may search the http://www.gnu.org website for the version 2 license,
|
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
#include <fctsys.h>
|
|||
|
|||
// height of the band reference grid 2.0 mm
|
|||
// worksheet frame reference text size 1.3 mm
|
|||
// default text size 1.5 mm
|
|||
// default line width 0.15 mm
|
|||
// frame ref pitch 50 mm
|
|||
|
|||
extern const wxString defaultPageLayout; |
|||
|
|||
// Default page layout (sizes are in mm)
|
|||
const wxString defaultPageLayout( wxT( "( page_layout\n" |
|||
"(setup (textsize 1.5 1.5) (linewidth 0.15) (textlinewidth 0.15) )" |
|||
"(rect (comment rect around the title block) (linewidth 0.15) (start 110 34) (end 2 2) )\n" |
|||
"(rect (start 0 0 ltcorner) (end 0 0 rbcorner) (repeat 2) (incrx 2) (incry 2) )\n" |
|||
"(line (start 50 2 ltcorner) (end 50 0 ltcorner) (repeat 30) (incrx 50) )\n" |
|||
"(tbtext \"1\" (pos 25 1 ltcorner) (font (size 1.3 1.3))(repeat 100) (incrx 50) )\n" |
|||
"(line (start 50 2 lbcorner) (end 50 0 lbcorner) (repeat 30) (incrx 50) )\n" |
|||
"(tbtext \"1\" (pos 25 1 lbcorner) (font (size 1.3 1.3)) (repeat 100) (incrx 50) )\n" |
|||
"(line (start 0 50 ltcorner) (end 2 50 ltcorner) (repeat 30) (incry 50) )\n" |
|||
"(tbtext \"A\" (pos 1 25 ltcorner) (font (size 1.3 1.3)) (justify center)(repeat 100) (incry 50) )\n" |
|||
"(line (start 0 50 rtcorner) (end 2 50 rtcorner) (repeat 30) (incry 50) )\n" |
|||
"(tbtext \"A\" (pos 1 25 rtcorner) (font (size 1.3 1.3)) (justify center) (repeat 100) (incry 50) )\n" |
|||
"(tbtext \"Date: %D\" (pos 87 6.9) )\n" |
|||
"(line (start 110 5.5) end 2 5.5) )\n" |
|||
"(tbtext \"%K\" (pos 108 4.1) (comment Kicad version ) )\n" |
|||
"(line (start 110 8.5) end 2 8.5) )\n" |
|||
"(tbtext \"Rev: %R\" (pos 24 6.9)(font bold italic)(justify left) )\n" |
|||
"(tbtext \"Size: %Z\" (comment Paper format name)(pos 105 6.9) )\n" |
|||
"(tbtext \"Id: %S/%N\" (comment Sheet id)(pos 24 4.1) )\n" |
|||
"(line (start 110 12.5) end 2 12.5) )\n" |
|||
"(tbtext \"Title: %T\" (pos 108 10.7)(font bold (size 2 2)) )\n" |
|||
"(tbtext \"File: %F\" (pos 108 14.3) )\n" |
|||
"(line (start 110 18.5) end 2 18.5) )\n" |
|||
"(tbtext \"Sheet: %P\" (pos 108 17) )\n" |
|||
"(tbtext \"%Y\" (comment Company name) (pos 108 20)(font bold) )\n" |
|||
"(tbtext \"%C0\" (comment Comment 0) (pos 108 23) )\n" |
|||
"(tbtext \"%C1\" (comment Comment 0) (pos 108 26) )\n" |
|||
"(tbtext \"%C2\" (comment Comment 0) (pos 108 29) )\n" |
|||
"(tbtext \"%C3\" (comment Comment 0) (pos 108 32) )\n" |
|||
"(line (start 90 8.5) end 90 5.5) )\n" |
|||
"(line (start 26 8.5) end 26 2) )\n" |
|||
")\n") ); |
|||
@ -0,0 +1,461 @@ |
|||
/**
|
|||
* @file page_layout_reader.cpp |
|||
* @brief read an S expression of description of graphic items and texts |
|||
* to build a title block and page layout |
|||
*/ |
|||
|
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 1992-2013 Jean-Pierre Charras <jp.charras at wanadoo.fr>. |
|||
* Copyright (C) 1992-2013 KiCad Developers, see change_log.txt for contributors. |
|||
* |
|||
* |
|||
* This program is free software; you can redistribute it and/or |
|||
* modify it under the terms of the GNU General Public License |
|||
* as published by the Free Software Foundation; either version 2 |
|||
* of the License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program; if not, you may find one here: |
|||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|||
* or you may search the http://www.gnu.org website for the version 2 license,
|
|||
* or you may write to the Free Software Foundation, Inc., |
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|||
*/ |
|||
|
|||
#include <fctsys.h>
|
|||
#include <base_struct.h>
|
|||
#include <worksheet.h>
|
|||
#include <worksheet_shape_builder.h>
|
|||
#include <vector2d.h>
|
|||
#include <page_layout_reader_lexer.h>
|
|||
|
|||
// defaultPageLayout is the default page layout description
|
|||
// using the S expr.
|
|||
// see page_layout_default_shape.cpp
|
|||
extern const wxString defaultPageLayout; |
|||
|
|||
using namespace TB_READER_T; |
|||
|
|||
/**
|
|||
* Class PAGE_LAYOUT_READER_PARSER |
|||
* holds data and functions pertinent to parsing a S-expression file |
|||
* for a WORKSHEET_LAYOUT. |
|||
*/ |
|||
class PAGE_LAYOUT_READER_PARSER : public PAGE_LAYOUT_READER_LEXER |
|||
{ |
|||
DSIZE m_defaultTextSize; // Default text size, when not defined inside a tbtext
|
|||
double m_defaultLineWidth; |
|||
double m_defaulTextLineWidth; |
|||
|
|||
public: |
|||
PAGE_LAYOUT_READER_PARSER( const char* aLine, const wxString& aSource ); |
|||
void Parse( WORKSHEET_LAYOUT* aLayout ) |
|||
throw( PARSE_ERROR, IO_ERROR ); |
|||
|
|||
private: |
|||
|
|||
/**
|
|||
* Function parseInt |
|||
* parses an integer and constrains it between two values. |
|||
* @param aMin is the smallest return value. |
|||
* @param aMax is the largest return value. |
|||
* @return int - the parsed integer. |
|||
*/ |
|||
int parseInt( int aMin, int aMax ); |
|||
|
|||
/**
|
|||
* Function parseDouble |
|||
* parses a double |
|||
* @return double - the parsed double. |
|||
*/ |
|||
double parseDouble(); |
|||
|
|||
void parseSetup() throw( IO_ERROR, PARSE_ERROR ); |
|||
void parseGraphic( WORKSHEET_DATAITEM * aItem ) throw( IO_ERROR, PARSE_ERROR ); |
|||
void parseText( WORKSHEET_DATAITEM_TEXT * aItem ) throw( IO_ERROR, PARSE_ERROR ); |
|||
void parseCoordinate( POINT_COORD& aCoord) throw( IO_ERROR, PARSE_ERROR ); |
|||
}; |
|||
|
|||
// PCB_PLOT_PARAMS_PARSER
|
|||
|
|||
PAGE_LAYOUT_READER_PARSER::PAGE_LAYOUT_READER_PARSER( const char* aLine, const wxString& aSource ) : |
|||
PAGE_LAYOUT_READER_LEXER( aLine, aSource ) |
|||
{ |
|||
m_defaultTextSize.x = m_defaultTextSize.y = TB_DEFAULT_TEXTSIZE; |
|||
m_defaultLineWidth = 0.0; |
|||
m_defaulTextLineWidth = 0.0; |
|||
} |
|||
|
|||
|
|||
void PAGE_LAYOUT_READER_PARSER::Parse( WORKSHEET_LAYOUT* aLayout ) |
|||
throw( PARSE_ERROR, IO_ERROR ) |
|||
{ |
|||
T token; |
|||
WORKSHEET_DATAITEM * item; |
|||
|
|||
LOCALE_IO toggle; |
|||
|
|||
while( ( token = NextTok() ) != T_RIGHT ) |
|||
{ |
|||
if( token == T_EOF) |
|||
break; |
|||
|
|||
if( token == T_LEFT ) |
|||
token = NextTok(); |
|||
|
|||
if( token == T_page_layout ) |
|||
continue; |
|||
|
|||
switch( token ) |
|||
{ |
|||
case T_setup: // Defines default values for graphic items
|
|||
parseSetup(); |
|||
break; |
|||
|
|||
case T_line: |
|||
item = new WORKSHEET_DATAITEM( WORKSHEET_DATAITEM::WS_SEGMENT ); |
|||
parseGraphic( item ); |
|||
aLayout->Append( item ); |
|||
break; |
|||
|
|||
case T_rect: |
|||
item = new WORKSHEET_DATAITEM( WORKSHEET_DATAITEM::WS_RECT ); |
|||
parseGraphic( item ); |
|||
aLayout->Append( item ); |
|||
break; |
|||
|
|||
case T_tbtext: |
|||
NeedSYMBOLorNUMBER(); |
|||
item = new WORKSHEET_DATAITEM_TEXT( FromUTF8() ); |
|||
parseText( (WORKSHEET_DATAITEM_TEXT*) item ); |
|||
aLayout->Append( item ); |
|||
break; |
|||
|
|||
default: |
|||
Unexpected( CurText() ); |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
void PAGE_LAYOUT_READER_PARSER::parseSetup() throw( IO_ERROR, PARSE_ERROR ) |
|||
{ |
|||
T token; |
|||
while( ( token = NextTok() ) != T_RIGHT ) |
|||
{ |
|||
if( token == T_EOF) |
|||
break; |
|||
|
|||
switch( token ) |
|||
{ |
|||
case T_LEFT: |
|||
break; |
|||
|
|||
case T_linewidth: |
|||
m_defaultLineWidth = parseDouble(); |
|||
NeedRIGHT(); |
|||
break; |
|||
|
|||
case T_textsize: |
|||
m_defaultTextSize.x = parseDouble(); |
|||
m_defaultTextSize.y = parseDouble(); |
|||
NeedRIGHT(); |
|||
break; |
|||
|
|||
case T_textlinewidth: |
|||
m_defaulTextLineWidth = parseDouble(); |
|||
NeedRIGHT(); |
|||
break; |
|||
|
|||
default: |
|||
Unexpected( CurText() ); |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
void PAGE_LAYOUT_READER_PARSER::parseGraphic( WORKSHEET_DATAITEM * aItem ) |
|||
throw( IO_ERROR, PARSE_ERROR ) |
|||
{ |
|||
T token; |
|||
|
|||
aItem->m_LineWidth = m_defaultLineWidth; |
|||
|
|||
while( ( token = NextTok() ) != T_RIGHT ) |
|||
{ |
|||
if( token == T_EOF) |
|||
break; |
|||
|
|||
if( token == T_LEFT ) |
|||
token = NextTok(); |
|||
|
|||
switch( token ) |
|||
{ |
|||
case T_comment: // Comment, search the closing ')'
|
|||
while( ( token = NextTok() ) != T_RIGHT && token != T_EOF ); |
|||
break; |
|||
|
|||
case T_start: |
|||
parseCoordinate( aItem->m_Pos ); |
|||
break; |
|||
|
|||
case T_end: |
|||
parseCoordinate( aItem->m_End ); |
|||
break; |
|||
|
|||
case T_repeat: |
|||
aItem->m_RepeatCount = parseInt( -1, 100 ); |
|||
NeedRIGHT(); |
|||
break; |
|||
|
|||
case T_incrx: |
|||
aItem->m_IncrementVector.x = parseDouble(); |
|||
NeedRIGHT(); |
|||
break; |
|||
|
|||
case T_incry: |
|||
aItem->m_IncrementVector.y = parseDouble(); |
|||
NeedRIGHT(); |
|||
break; |
|||
|
|||
case T_linewidth: |
|||
aItem->m_LineWidth = parseDouble(); |
|||
NeedRIGHT(); |
|||
break; |
|||
|
|||
default: |
|||
Unexpected( CurText() ); |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
void PAGE_LAYOUT_READER_PARSER::parseText( WORKSHEET_DATAITEM_TEXT* aItem ) |
|||
throw( IO_ERROR, PARSE_ERROR ) |
|||
{ |
|||
T token; |
|||
|
|||
aItem->m_TextSize = m_defaultTextSize; |
|||
aItem->m_LineWidth = m_defaulTextLineWidth; |
|||
|
|||
while( ( token = NextTok() ) != T_RIGHT ) |
|||
{ |
|||
if( token == T_EOF) |
|||
break; |
|||
|
|||
if( token == T_LEFT ) |
|||
token = NextTok(); |
|||
|
|||
switch( token ) |
|||
{ |
|||
case T_comment: // Comment, search the closing ')'
|
|||
while( ( token = NextTok() ) != T_RIGHT && token != T_EOF ); |
|||
break; |
|||
|
|||
case T_pos: |
|||
parseCoordinate( aItem->m_Pos ); |
|||
break; |
|||
|
|||
case T_repeat: |
|||
aItem->m_RepeatCount = parseInt( -1, 100 ); |
|||
NeedRIGHT(); |
|||
break; |
|||
|
|||
case T_incrx: |
|||
aItem->m_IncrementVector.x = parseDouble(); |
|||
NeedRIGHT(); |
|||
break; |
|||
|
|||
case T_incry: |
|||
aItem->m_IncrementVector.y = parseDouble(); |
|||
NeedRIGHT(); |
|||
break; |
|||
|
|||
case T_incrlabel: |
|||
aItem->m_IncrementLabel = parseInt(INT_MIN, INT_MAX); |
|||
NeedRIGHT(); |
|||
break; |
|||
|
|||
case T_maxlen: |
|||
aItem->m_BoundingBoxSize.x = parseDouble(); |
|||
NeedRIGHT(); |
|||
break; |
|||
|
|||
case T_maxheight: |
|||
aItem->m_BoundingBoxSize.y = parseDouble(); |
|||
NeedRIGHT(); |
|||
break; |
|||
|
|||
case T_font: |
|||
while( ( token = NextTok() ) != T_RIGHT ) |
|||
{ |
|||
if( token == T_EOF) |
|||
break; |
|||
|
|||
switch( token ) |
|||
{ |
|||
case T_LEFT: |
|||
break; |
|||
|
|||
case T_bold: |
|||
aItem->m_Flags |= USE_BOLD; |
|||
break; |
|||
|
|||
case T_italic: |
|||
aItem->m_Flags |= USE_ITALIC; |
|||
break; |
|||
|
|||
case T_size: |
|||
aItem->m_TextSize.x = parseDouble(); |
|||
aItem->m_TextSize.y = parseDouble(); |
|||
NeedRIGHT(); |
|||
break; |
|||
|
|||
case T_linewidth: |
|||
aItem->m_LineWidth = parseDouble(); |
|||
NeedRIGHT(); |
|||
break; |
|||
|
|||
default: |
|||
Unexpected( CurText() ); |
|||
break; |
|||
} |
|||
} |
|||
break; |
|||
|
|||
case T_justify: |
|||
while( ( token = NextTok() ) != T_RIGHT ) |
|||
{ |
|||
if( token == T_EOF) |
|||
break; |
|||
|
|||
switch( token ) |
|||
{ |
|||
case T_center: |
|||
aItem->m_Hjustify = GR_TEXT_HJUSTIFY_CENTER; |
|||
aItem->m_Vjustify = GR_TEXT_VJUSTIFY_CENTER; |
|||
break; |
|||
|
|||
case T_left: |
|||
aItem->m_Hjustify = GR_TEXT_HJUSTIFY_LEFT; |
|||
break; |
|||
|
|||
case T_right: |
|||
aItem->m_Hjustify = GR_TEXT_HJUSTIFY_RIGHT; |
|||
break; |
|||
|
|||
case T_top: |
|||
aItem->m_Vjustify = GR_TEXT_VJUSTIFY_TOP; |
|||
break; |
|||
|
|||
case T_bottom: |
|||
aItem->m_Vjustify = GR_TEXT_VJUSTIFY_BOTTOM; |
|||
break; |
|||
|
|||
default: |
|||
Unexpected( CurText() ); |
|||
break; |
|||
} |
|||
} |
|||
break; |
|||
|
|||
case T_rotate: |
|||
aItem->m_Orient = parseDouble(); |
|||
NeedRIGHT(); |
|||
break; |
|||
|
|||
default: |
|||
Unexpected( CurText() ); |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
// parse an expression like " 25 1 ltcorner)"
|
|||
void PAGE_LAYOUT_READER_PARSER::parseCoordinate( POINT_COORD& aCoord) |
|||
throw( IO_ERROR, PARSE_ERROR ) |
|||
{ |
|||
T token; |
|||
|
|||
aCoord.m_Pos.x = parseDouble(); |
|||
aCoord.m_Pos.y = parseDouble(); |
|||
|
|||
while( ( token = NextTok() ) != T_RIGHT ) |
|||
{ |
|||
switch( token ) |
|||
{ |
|||
case T_ltcorner: |
|||
aCoord.m_Anchor = LT_CORNER; // left top corner
|
|||
break; |
|||
|
|||
case T_lbcorner: |
|||
aCoord.m_Anchor = LB_CORNER; // left bottom corner
|
|||
break; |
|||
|
|||
case T_rbcorner: |
|||
aCoord.m_Anchor = RB_CORNER; // right bottom corner
|
|||
break; |
|||
|
|||
case T_rtcorner: |
|||
aCoord.m_Anchor = RT_CORNER; // right top corner
|
|||
break; |
|||
|
|||
default: |
|||
Unexpected( CurText() ); |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
int PAGE_LAYOUT_READER_PARSER::parseInt( int aMin, int aMax ) |
|||
{ |
|||
T token = NextTok(); |
|||
|
|||
if( token != T_NUMBER ) |
|||
Expecting( T_NUMBER ); |
|||
|
|||
int val = atoi( CurText() ); |
|||
|
|||
if( val < aMin ) |
|||
val = aMin; |
|||
else if( val > aMax ) |
|||
val = aMax; |
|||
|
|||
return val; |
|||
} |
|||
|
|||
|
|||
double PAGE_LAYOUT_READER_PARSER::parseDouble() |
|||
{ |
|||
T token = NextTok(); |
|||
|
|||
if( token != T_NUMBER ) |
|||
Expecting( T_NUMBER ); |
|||
|
|||
double val = strtod( CurText(), NULL ); |
|||
|
|||
return val; |
|||
} |
|||
|
|||
|
|||
void WORKSHEET_LAYOUT::SetDefaultLayout() |
|||
{ |
|||
PAGE_LAYOUT_READER_PARSER lp_parser( defaultPageLayout, "default page" ); |
|||
|
|||
try |
|||
{ |
|||
lp_parser.Parse( this ); |
|||
} |
|||
catch( IO_ERROR ioe ) |
|||
{ |
|||
wxLogMessage( ioe.errorText ); |
|||
} |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
page_layout |
|||
setup |
|||
linewidth |
|||
textlinewidth |
|||
textsize |
|||
comment |
|||
line |
|||
rect |
|||
polygon |
|||
tbtext |
|||
ltcorner |
|||
lbcorner |
|||
rbcorner |
|||
rtcorner |
|||
name |
|||
pos |
|||
start |
|||
end |
|||
maxlen |
|||
maxheight |
|||
font |
|||
bold |
|||
italic |
|||
size |
|||
justify |
|||
left |
|||
center |
|||
right |
|||
top |
|||
bottom |
|||
rotate |
|||
repeat |
|||
incrx |
|||
incry |
|||
incrlabel |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue