From 784dcff5376efcb03b8d38e728d18e3338f6b844 Mon Sep 17 00:00:00 2001 From: Russell Oliver Date: Fri, 2 Feb 2018 12:02:50 +1100 Subject: [PATCH] Add empty eeschema page layout for Eagle schematic import. Bug #1729722 --- common/CMakeLists.txt | 1 + .../page_layout/page_layout_empty_description.cpp | 136 +++++++++++++++++++++ common/page_layout/page_layout_reader.cpp | 22 +++- eeschema/sch_eagle_plugin.cpp | 7 ++ include/worksheet_shape_builder.h | 5 + 5 files changed, 170 insertions(+), 1 deletion(-) create mode 100644 common/page_layout/page_layout_empty_description.cpp diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 3ed042b..b732b8e 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -190,6 +190,7 @@ set( COMMON_PAGE_LAYOUT_SRCS page_layout/worksheet_dataitem.cpp page_layout/worksheet_layout.cpp page_layout/page_layout_default_description.cpp + page_layout/page_layout_empty_description.cpp page_layout/page_layout_graphic_items.cpp page_layout/page_layout_reader_keywords.cpp page_layout/page_layout_reader.cpp diff --git a/common/page_layout/page_layout_empty_description.cpp b/common/page_layout/page_layout_empty_description.cpp new file mode 100644 index 0000000..98981d0 --- /dev/null +++ b/common/page_layout/page_layout_empty_description.cpp @@ -0,0 +1,136 @@ +/** + * @file common/page_layout/page_layout_empty_description.cpp + */ + +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 1992-2013 Jean-Pierre Charras . + * Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.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 + */ + +/* keyword used in page layout description are listed + * in page_layout_reader.keywords file + */ + +/* + * Items use coordinates. + * A coordinate is defined relative to a page corner + * A coordinate is the X pos, the Y pos, and the corner which is the coordinate origin + * the default is the bottom right corner + * example: (start 10 0 ltcorner) or (start 20 10) + * The direction depends on the corner: a positive coordinate define a point + * from the corner origin, to the opposite corner. + * + * Items are defined by a name, coordinates in mm and some attributes, + * and can be repeated. + * for instance (repeat 2) (incrx 2) (incry 2) repeat the item 2 times, + * and coordinates are incremented by 2 on X direction, and 2 on Y direction + * Comments are allowed. they are inside (), and start by the keyword comment + * example: + * (comment rect around the title block) + * + * Lines and rect are defined by 2 coordinates start and end, and attributes. + * Attributes are linewidth and repeat parameters. + * example: + * (line (start 50 2 ltcorner) (end 50 0 ltcorner) (repeat 30) (incrx 50) ) + * (rect (comment rect around the title block) (linewidth 0.15) (start 110 34) (end 2 2) ) + * + * Texts are defined by the text (between quotes), the position, and attributes + * example + * "(tbtext \"1\" (pos 25 1 lbcorner) (font (size 1.3 1.3)) (repeat 100) (incrx 50) )" + * the text can be rotated by (rotation ) with value = rot angle in degrees + * (font (size 1.3 1.3) bold italic) defines a specific size, + * with bold and italic options + * (justify ) controls the text justification (the default is left) + * justif keyword is center, left, right, top and bottom + * (justify center top) is a text centered on X axis and top aligned on vertical axis + * The text size can be constrained: + * (maxlen ) and (maxheight ) force the actual text x and/or y size to be + * reduced to limit the text height to the maxheight value, + * and the full text x size to the maxlen value. + * If the actual text size is smaller than limits, its size is not modified. + * + * Texts can include a format symbol, a la printf. + * At run time these format symbols will be replaced by their actual value. + * + * format symbols are: + * + * %% = replaced by % + * %K = Kicad version + * %Z = paper format name (A4, USLetter ...) + * %Y = company name + * %D = date + * %R = revision + * %S = sheet number + * %N = number of sheets + * %Cx = comment (x = 0 to 9 to identify the comment) + * %F = filename + * %P = sheet path (sheet full name) + * %T = title + * + * example: + * (tbtext \"Size: %Z\" ...) displays "Size A4" or Size USLetter" + * + * Poly Polygons + * Set of filled polygons are supported. + * + * The main purpose is to allow logos, or complex shapes + * They support the repeat and rotation options + * They are defined by + * (polygon (position ..) + * the parameter linewidth defines the pen size used to draw/plot + * the polygon outlines (default = 0) + * example: + * (polygon (pos 134 18 rbcorner) (rotate 20) (linewidth 0.00254) + * + * and a list of corners like + * (pts (xy 20.574 8.382) (xy 19.9009 8.382) (xy 19.9009 6.26364) (xy 19.7485 5.98932) + * .... ) + * + * each sequence like + * (pts (xy 20.574 8.382) (xy 19.9009 8.382) (xy 19.9009 6.26364) (xy 19.7485 5.98932) + * .... ) + * defines a polygon. + * Each coordinate is relative to the polygon position. + * Therefore a "polygon" is in fact a set of polygons, of a poly polygon + * + */ + +#include // emptyPageLayout + + +// 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 + +// export emptyPageLayout: +extern const char emptyPageLayout[]; + +// Default page layout (sizes are in mm) +const char emptyPageLayout[] = "(page_layout\n" + "(setup (textsize 1.5 1.5)(linewidth 0.15)(textlinewidth 0.15)\n" + "(left_margin 10)(right_margin 10)(top_margin 10)(bottom_margin 10))\n" + "(line (name segm1:Line) (start 0 0) (end 0 0))\n" + ")\n" +; diff --git a/common/page_layout/page_layout_reader.cpp b/common/page_layout/page_layout_reader.cpp index 1f197df..5150594 100644 --- a/common/page_layout/page_layout_reader.cpp +++ b/common/page_layout/page_layout_reader.cpp @@ -773,6 +773,27 @@ void WORKSHEET_LAYOUT::SetDefaultLayout() } } +// emptyPageLayout is a "empty" page layout description +// there is a 0 length line to fool something somewhere. +// using the S expr. +// see page_layout_empty_description.cpp +extern const char emptyPageLayout[]; + +void WORKSHEET_LAYOUT::SetEmptyLayout() +{ + ClearList(); + PAGE_LAYOUT_READER_PARSER lp_parser( emptyPageLayout, wxT( "empty page" ) ); + + try + { + lp_parser.Parse( this ); + } + catch( const IO_ERROR& ioe ) + { + wxLogMessage( ioe.What() ); + } +} + /** * Populates the list from a S expr description stored in a string * @param aPageLayout = the S expr string @@ -859,4 +880,3 @@ void WORKSHEET_LAYOUT::SetPageLayout( const wxString& aFullFileName, bool Append delete[] buffer; } - diff --git a/eeschema/sch_eagle_plugin.cpp b/eeschema/sch_eagle_plugin.cpp index 1278fa8..dca0377 100644 --- a/eeschema/sch_eagle_plugin.cpp +++ b/eeschema/sch_eagle_plugin.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -374,6 +375,12 @@ SCH_SHEET* SCH_EAGLE_PLUGIN::Load( const wxString& aFileName, KIWAY* aKiway, m_rootSheet->SetScreen( screen ); } + WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance(); + + pglayout.SetEmptyLayout( ); + + + SYMBOL_LIB_TABLE* libTable = m_kiway->Prj().SchSymbolLibTable(); wxCHECK_MSG( libTable, NULL, "Could not load symbol lib table." ); diff --git a/include/worksheet_shape_builder.h b/include/worksheet_shape_builder.h index 4baa5df..86e03b3 100644 --- a/include/worksheet_shape_builder.h +++ b/include/worksheet_shape_builder.h @@ -718,6 +718,11 @@ public: void SetDefaultLayout(); /** + * Fills the list with an empty layout shape + */ + void SetEmptyLayout(); + + /** * Populates the list with a custom layout, or * the default layout, if no custom layout available * @param aFullFileName = the custom page layout description file. -- 2.7.4