From 7392f04b75ace9ebad917e4981f02769d746e9b9 Mon Sep 17 00:00:00 2001 From: Ronald Sousa Date: Wed, 11 Feb 2015 11:11:05 +0000 Subject: [PATCH] - Added sheet information to the net file. i.e. sheet number, human path name and timestamp - update bom_with_title_block_2_csv.xsl --- eeschema/netform.cpp | 64 +++++++++---------- .../plugins/bom_with_title_block_2_csv.xsl | 44 +++++-------- eeschema/sch_sheet_path.h | 6 ++ 3 files changed, 54 insertions(+), 60 deletions(-) diff --git a/eeschema/netform.cpp b/eeschema/netform.cpp index 5ca5fb2836..f65fe71fa8 100644 --- a/eeschema/netform.cpp +++ b/eeschema/netform.cpp @@ -653,12 +653,15 @@ static XNODE* node( const wxString& aName, const wxString& aTextualContent = wxE XNODE* NETLIST_EXPORT_TOOL::makeGenericDesignHeader() { - SCH_SCREEN* screen; SCH_SCREENS screenList; - screen = screenList.GetFirst(); + SCH_SCREEN* screen; XNODE* xdesign = node( wxT("design") ); - XNODE* xsheetNode; XNODE* xsheetInfo; + XNODE* xcommentNode; + XNODE* xpagesNode; + XNODE* xpageNode; + wxString sheetNumTxt; + wxString sheetNumTxtFormat = wxT( "%d" ); // the root sheet is a special sheet, call it source xdesign->AddChild( node( wxT( "source" ), g_RootSheet->GetScreen()->GetFileName() ) ); @@ -668,46 +671,43 @@ XNODE* NETLIST_EXPORT_TOOL::makeGenericDesignHeader() // which Eeschema tool xdesign->AddChild( node( wxT( "tool" ), wxT( "Eeschema " ) + GetBuildVersion() ) ); - xdesign->AddChild( xsheetNode = node( wxT( "sheets" ) ) ); + /* + Export the sheets information + */ + SCH_SHEET_LIST sheetList; + xdesign->AddChild( xpagesNode = node( wxT( "sheets" ) ) ); - for( screen = screenList.GetFirst(); screen != NULL; screen = screenList.GetNext() ) + for( SCH_SHEET_PATH* sheet = sheetList.GetFirst(); sheet; sheet = sheetList.GetNext() ) { + xpagesNode->AddChild( xpageNode = node( wxT( "sheet" ) ) ); + + // get the string representation of the sheet index number. + // Note that sheet->GetIndex() is zero index base and we need to increment the number by one to make + // human readable + sheetNumTxt.Printf( sheetNumTxtFormat, ( sheetList.GetIndex() + 1 ) ); + + xpageNode->AddChild( node( wxT( "number" ), sheetNumTxt ) ); + xpageNode->AddChild( node( wxT( "names" ), sheet->PathHumanReadable() ) ); + xpageNode->AddChild( node( wxT( "tstamps" ), sheet->Path() ) ); + screen = sheet->LastScreen(); TITLE_BLOCK tb = screen->GetTitleBlock(); - xsheetNode->AddChild( xsheetInfo = node( wxT( "sheet" ) ) ); - + xpageNode->AddChild( xsheetInfo = node( wxT( "page" ) ) ); + xsheetInfo->AddChild( node( wxT( "title" ), tb.GetTitle() ) ); xsheetInfo->AddChild( node( wxT( "company" ), tb.GetCompany() ) ); xsheetInfo->AddChild( node( wxT( "revision" ), tb.GetRevision() ) ); xsheetInfo->AddChild( node( wxT( "issueDate" ), tb.GetDate() ) ); - xsheetInfo->AddChild( node( wxT( "comment1" ), tb.GetComment1() ) ); - xsheetInfo->AddChild( node( wxT( "comment2" ), tb.GetComment2() ) ); - xsheetInfo->AddChild( node( wxT( "comment3" ), tb.GetComment3() ) ); - xsheetInfo->AddChild( node( wxT( "comment4" ), tb.GetComment4() ) ); - } + xsheetInfo->AddChild( node( wxT( "source" ), screen->GetFileName() ) ); - /* @todo might do a list of schematic pages + xsheetInfo->AddChild( xcommentNode = node( wxT( "comments" ) ) ); + xcommentNode->AddChild( node( wxT( "comment" ), tb.GetComment1() ) ); + xcommentNode->AddChild( node( wxT( "comment" ), tb.GetComment2() ) ); + xcommentNode->AddChild( node( wxT( "comment" ), tb.GetComment3() ) ); + xcommentNode->AddChild( node( wxT( "comment" ), tb.GetComment4() ) ); - - - <revision/> - <company/> - <comments> - <comment>blah</comment> <!-- comment1 --> - <comment>blah</comment> <!-- comment2 --> - </comments> - <pagesize/> - </page> - : - - and a sheet hierarchy report here - <sheets> - <sheet name="sheetname1" page="pagenameA"> - <sheet name="sheetname2" page="pagenameB"/> use recursion to output? - </sheet> - </sheets> - */ + } return xdesign; } diff --git a/eeschema/plugins/bom_with_title_block_2_csv.xsl b/eeschema/plugins/bom_with_title_block_2_csv.xsl index e4583fa063..5e192af3de 100644 --- a/eeschema/plugins/bom_with_title_block_2_csv.xsl +++ b/eeschema/plugins/bom_with_title_block_2_csv.xsl @@ -73,8 +73,8 @@ <xsl:template match="/export/design/sheets/sheet[1]"> <xsl:choose> - <xsl:when test="title !=''"> - <xsl:text>Title,</xsl:text><xsl:value-of select="title"/><xsl:text>&nl;</xsl:text> + <xsl:when test="page/title !=''"> + <xsl:text>Title,</xsl:text><xsl:value-of select="page/title"/><xsl:text>&nl;</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>Title,Not Set</xsl:text><xsl:text>&nl;</xsl:text> @@ -83,8 +83,8 @@ <xsl:choose> - <xsl:when test="company !=''"> - <xsl:text>Company,</xsl:text><xsl:value-of select="company"/><xsl:text>&nl;</xsl:text> + <xsl:when test="page/company !=''"> + <xsl:text>Company,</xsl:text><xsl:value-of select="page/company"/><xsl:text>&nl;</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>Company,Not Set</xsl:text><xsl:text>&nl;</xsl:text> @@ -92,8 +92,8 @@ </xsl:choose> <xsl:choose> - <xsl:when test="revision !=''"> - <xsl:text>Revision,</xsl:text><xsl:value-of select="revision"/><xsl:text>&nl;</xsl:text> + <xsl:when test="page/revision !=''"> + <xsl:text>Revision,</xsl:text><xsl:value-of select="page/revision"/><xsl:text>&nl;</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>Revision,Not Set</xsl:text><xsl:text>&nl;</xsl:text> @@ -101,39 +101,27 @@ </xsl:choose> <xsl:choose> - <xsl:when test="issueDate !=''"> - <xsl:text>Date Issue,</xsl:text><xsl:value-of select="issueDate"/><xsl:text>&nl;</xsl:text> + <xsl:when test="page/issueDate !=''"> + <xsl:text>Date Issue,</xsl:text><xsl:value-of select="page/issueDate"/><xsl:text>&nl;</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>Date Issue,Not Set</xsl:text><xsl:text>&nl;</xsl:text> </xsl:otherwise> </xsl:choose> + <xsl:apply-templates select="page/comments/comment"/><xsl:text>&nl;</xsl:text> + </xsl:template> + + <xsl:template match="page/comments/comment"> <xsl:choose> - <xsl:when test="comment1 !=''"> - <xsl:text>Comment,</xsl:text><xsl:value-of select="comment1"/><xsl:text>&nl;</xsl:text> - </xsl:when> - </xsl:choose> - - <xsl:choose> - <xsl:when test="comment2 !=''"> - <xsl:text>Comment,</xsl:text><xsl:value-of select="comment2"/><xsl:text>&nl;</xsl:text> - </xsl:when> - </xsl:choose> - - <xsl:choose> - <xsl:when test="comment3 !=''"> - <xsl:text>Comment,</xsl:text><xsl:value-of select="comment3"/><xsl:text>&nl;</xsl:text> - </xsl:when> - </xsl:choose> - - <xsl:choose> - <xsl:when test="comment4 !=''"> - <xsl:text>Comment,</xsl:text><xsl:value-of select="comment4"/><xsl:text>&nl;</xsl:text> + <xsl:when test=". !=''"> + <xsl:text>Comment,</xsl:text><xsl:value-of select="."/><xsl:text>&nl;</xsl:text> </xsl:when> </xsl:choose> </xsl:template> + + <!-- the table entries --> <xsl:template match="components/comp"> <xsl:value-of select="@ref"/><xsl:text>,</xsl:text> diff --git a/eeschema/sch_sheet_path.h b/eeschema/sch_sheet_path.h index 365680a430..d5bb231d83 100644 --- a/eeschema/sch_sheet_path.h +++ b/eeschema/sch_sheet_path.h @@ -324,6 +324,12 @@ public: */ int GetCount() const { return m_count; } + /** + * Function GetIndex + * @return the last selected screen index. + */ + int GetIndex() const { return m_index; } + /** * Function GetFirst * @return the first item (sheet) in m_List and prepare calls to GetNext()