Commit 7432d4de authored by jean-pierre charras's avatar jean-pierre charras

Page layout: add comments, and fix a very minor issue.

Eeschema, dialog netlist: fix a bug when removing a plugin panel, when is is not the last.
dialog netlist:Add a predefined command string for python scripts, when creating a new netlist plugin entry.
parent 7f18b883
...@@ -104,6 +104,27 @@ ...@@ -104,6 +104,27 @@
* and the full text x size to the maxlen 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. * 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"
*
*/ */
#include <worksheet.h> // defaultPageLayout #include <worksheet.h> // defaultPageLayout
...@@ -133,11 +154,11 @@ const char defaultPageLayout[] = "( page_layout\n" ...@@ -133,11 +154,11 @@ const char defaultPageLayout[] = "( page_layout\n"
"(line (start 110 5.5) end 2 5.5) )\n" "(line (start 110 5.5) end 2 5.5) )\n"
"(tbtext \"%K\" (pos 109 4.1) (comment Kicad version ) )\n" "(tbtext \"%K\" (pos 109 4.1) (comment Kicad version ) )\n"
"(line (start 110 8.5) end 2 8.5) )\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 \"Rev: %R\" (pos 24 6.9)(font bold)(justify left) )\n"
"(tbtext \"Size: %Z\" (comment Paper format name)(pos 109 6.9) )\n" "(tbtext \"Size: %Z\" (comment Paper format name)(pos 109 6.9) )\n"
"(tbtext \"Id: %S/%N\" (comment Sheet id)(pos 24 4.1) )\n" "(tbtext \"Id: %S/%N\" (comment Sheet id)(pos 24 4.1) )\n"
"(line (start 110 12.5) end 2 12.5) )\n" "(line (start 110 12.5) end 2 12.5) )\n"
"(tbtext \"Title: %T\" (pos 109 10.7)(font bold (size 2 2)) )\n" "(tbtext \"Title: %T\" (pos 109 10.7)(font bold italic (size 2 2)) )\n"
"(tbtext \"File: %F\" (pos 109 14.3) )\n" "(tbtext \"File: %F\" (pos 109 14.3) )\n"
"(line (start 110 18.5) end 2 18.5) )\n" "(line (start 110 18.5) end 2 18.5) )\n"
"(tbtext \"Sheet: %P\" (pos 109 17) )\n" "(tbtext \"Sheet: %P\" (pos 109 17) )\n"
......
...@@ -225,8 +225,6 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( ...@@ -225,8 +225,6 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
WS_DRAW_ITEM_TEXT* gtext; WS_DRAW_ITEM_TEXT* gtext;
int pensize; int pensize;
bool bold;
bool italic = false;
EDA_COLOR_T color; EDA_COLOR_T color;
for( unsigned ii = 0; ; ii++ ) for( unsigned ii = 0; ; ii++ )
...@@ -245,7 +243,6 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( ...@@ -245,7 +243,6 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
if( wsText->m_FullText.IsEmpty() ) if( wsText->m_FullText.IsEmpty() )
break; break;
bold = false;
pensize = wsText->GetPenSizeUi(); pensize = wsText->GetPenSizeUi();
if( pensize == 0 ) if( pensize == 0 )
...@@ -264,11 +261,8 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( ...@@ -264,11 +261,8 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
textsize.y = KiROUND( wsText->m_ConstrainedTextSize.y textsize.y = KiROUND( wsText->m_ConstrainedTextSize.y
* WORKSHEET_DATAITEM::m_WSunits2Iu ); * WORKSHEET_DATAITEM::m_WSunits2Iu );
if( wsText->m_Flags & USE_BOLD ) if( wsText->IsBold())
{
bold = true;
pensize = GetPenSizeForBold( std::min( textsize.x, textsize.y ) ); pensize = GetPenSizeForBold( std::min( textsize.x, textsize.y ) );
}
for( int jj = 0; jj < wsText->m_RepeatCount; ) for( int jj = 0; jj < wsText->m_RepeatCount; )
{ {
...@@ -277,7 +271,9 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList( ...@@ -277,7 +271,9 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
Append( gtext = new WS_DRAW_ITEM_TEXT( wsText->m_FullText, Append( gtext = new WS_DRAW_ITEM_TEXT( wsText->m_FullText,
wsText->GetStartPosUi( jj ), wsText->GetStartPosUi( jj ),
textsize, textsize,
pensize, color, italic, bold ) ); pensize, color,
wsText->IsItalic(),
wsText->IsBold() ) );
wsText->TransfertSetupToGraphicText( gtext ); wsText->TransfertSetupToGraphicText( gtext );
jj++; jj++;
......
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras@wanadoo.fr * Copyright (C) 2013 Jean-Pierre Charras, jp.charras@wanadoo.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -656,7 +656,8 @@ void NETLIST_DIALOG::WriteCurrentNetlistSetup( void ) ...@@ -656,7 +656,8 @@ void NETLIST_DIALOG::WriteCurrentNetlistSetup( void )
m_config->Write( NETLIST_USE_DEFAULT_NETNAME, GetUseDefaultNetlistName() ); m_config->Write( NETLIST_USE_DEFAULT_NETNAME, GetUseDefaultNetlistName() );
// Update the new titles // Update existing custom pages
int jj = 0;
for( int ii = 0; ii < CUSTOMPANEL_COUNTMAX; ii++ ) for( int ii = 0; ii < CUSTOMPANEL_COUNTMAX; ii++ )
{ {
NETLIST_PAGE_DIALOG* currPage = m_PanelNetType[ii + PANELCUSTOMBASE]; NETLIST_PAGE_DIALOG* currPage = m_PanelNetType[ii + PANELCUSTOMBASE];
...@@ -664,29 +665,32 @@ void NETLIST_DIALOG::WriteCurrentNetlistSetup( void ) ...@@ -664,29 +665,32 @@ void NETLIST_DIALOG::WriteCurrentNetlistSetup( void )
if( currPage == NULL ) if( currPage == NULL )
break; break;
msg = wxT( "Custom" ); wxString title = currPage->m_TitleStringCtrl->GetValue();
msg << ii + 1;
if( currPage->m_TitleStringCtrl ) if( title.IsEmpty() )
{ continue;
wxString title = currPage->m_TitleStringCtrl->GetValue();
currPage->SetPageNetFmtName( title );
if( msg != title ) // Title has changed, Update config
{
msg = CUSTOM_NETLIST_TITLE;
msg << ii + 1;
m_config->Write( msg, title );
}
}
if( currPage->m_CommandStringCtrl ) msg = CUSTOM_NETLIST_TITLE;
{ msg << jj + 1;
Command = currPage->m_CommandStringCtrl->GetValue(); m_config->Write( msg, title );
msg = CUSTOM_NETLIST_COMMAND;
msg << ii + 1; Command = currPage->m_CommandStringCtrl->GetValue();
m_config->Write( msg, Command ); msg = CUSTOM_NETLIST_COMMAND;
} msg << jj + 1;
m_config->Write( msg, Command );
jj++;
}
// Ensure all other pages are void
for(; jj < CUSTOMPANEL_COUNTMAX; jj++ )
{
msg = CUSTOM_NETLIST_TITLE;
msg << jj + 1;
m_config->Write( msg, wxEmptyString );
msg = CUSTOM_NETLIST_COMMAND;
msg << jj + 1;
m_config->Write( msg, wxEmptyString );
} }
} }
...@@ -807,8 +811,9 @@ void NETLIST_DIALOG_ADD_PLUGIN::OnBrowsePlugins( wxCommandEvent& event ) ...@@ -807,8 +811,9 @@ void NETLIST_DIALOG_ADD_PLUGIN::OnBrowsePlugins( wxCommandEvent& event )
if( FullFileName.IsEmpty() ) if( FullFileName.IsEmpty() )
return; return;
// Creates a default command line, suitable for external tool xslproc: // Creates a default command line, suitable for external tool xslproc or python
// try to build a default command line depending on plugin extension // try to build a default command line depending on plugin extension
// "xsl" or "exe" or "py"
wxString cmdLine; wxString cmdLine;
wxFileName fn( FullFileName ); wxFileName fn( FullFileName );
wxString ext = fn.GetExt(); wxString ext = fn.GetExt();
...@@ -817,6 +822,8 @@ void NETLIST_DIALOG_ADD_PLUGIN::OnBrowsePlugins( wxCommandEvent& event ) ...@@ -817,6 +822,8 @@ void NETLIST_DIALOG_ADD_PLUGIN::OnBrowsePlugins( wxCommandEvent& event )
cmdLine.Printf(wxT("xsltproc -o \"%%O\" \"%s\" \"%%I\""), GetChars(FullFileName) ); cmdLine.Printf(wxT("xsltproc -o \"%%O\" \"%s\" \"%%I\""), GetChars(FullFileName) );
else if( ext == wxT("exe" ) || ext.IsEmpty() ) else if( ext == wxT("exe" ) || ext.IsEmpty() )
cmdLine.Printf(wxT("\"%s\" > \"%%O\" < \"%%I\""), GetChars(FullFileName) ); cmdLine.Printf(wxT("\"%s\" > \"%%O\" < \"%%I\""), GetChars(FullFileName) );
else if( ext == wxT("py" ) || ext.IsEmpty() )
cmdLine.Printf(wxT("python \"%s\" \"%%I\" \"%%O\""), GetChars(FullFileName) );
else else
cmdLine.Printf(wxT("\"%s\""), GetChars(FullFileName) ); cmdLine.Printf(wxT("\"%s\""), GetChars(FullFileName) );
......
...@@ -156,6 +156,16 @@ public: ...@@ -156,6 +156,16 @@ public:
* the corresponding text size is not constrained * the corresponding text size is not constrained
*/ */
void SetConstrainedTextSize(); void SetConstrainedTextSize();
/**
* @return true is a bold font should be selected
*/
bool IsBold() { return (m_Flags & USE_BOLD) != 0; }
/**
* @return true is an italic font should be selected
*/
bool IsItalic() { return (m_Flags & USE_ITALIC) != 0; }
}; };
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment