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 @@
* 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"
*
*/
#include <worksheet.h> // defaultPageLayout
......@@ -133,11 +154,11 @@ const char defaultPageLayout[] = "( page_layout\n"
"(line (start 110 5.5) end 2 5.5) )\n"
"(tbtext \"%K\" (pos 109 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 \"Rev: %R\" (pos 24 6.9)(font bold)(justify left) )\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"
"(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"
"(line (start 110 18.5) end 2 18.5) )\n"
"(tbtext \"Sheet: %P\" (pos 109 17) )\n"
......
......@@ -225,8 +225,6 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
WS_DRAW_ITEM_TEXT* gtext;
int pensize;
bool bold;
bool italic = false;
EDA_COLOR_T color;
for( unsigned ii = 0; ; ii++ )
......@@ -245,7 +243,6 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
if( wsText->m_FullText.IsEmpty() )
break;
bold = false;
pensize = wsText->GetPenSizeUi();
if( pensize == 0 )
......@@ -264,11 +261,8 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
textsize.y = KiROUND( wsText->m_ConstrainedTextSize.y
* WORKSHEET_DATAITEM::m_WSunits2Iu );
if( wsText->m_Flags & USE_BOLD )
{
bold = true;
if( wsText->IsBold())
pensize = GetPenSizeForBold( std::min( textsize.x, textsize.y ) );
}
for( int jj = 0; jj < wsText->m_RepeatCount; )
{
......@@ -277,7 +271,9 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
Append( gtext = new WS_DRAW_ITEM_TEXT( wsText->m_FullText,
wsText->GetStartPosUi( jj ),
textsize,
pensize, color, italic, bold ) );
pensize, color,
wsText->IsItalic(),
wsText->IsBold() ) );
wsText->TransfertSetupToGraphicText( gtext );
jj++;
......
/*
* 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) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras@wanadoo.fr
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......@@ -656,7 +656,8 @@ void NETLIST_DIALOG::WriteCurrentNetlistSetup( void )
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++ )
{
NETLIST_PAGE_DIALOG* currPage = m_PanelNetType[ii + PANELCUSTOMBASE];
......@@ -664,29 +665,32 @@ void NETLIST_DIALOG::WriteCurrentNetlistSetup( void )
if( currPage == NULL )
break;
msg = wxT( "Custom" );
msg << ii + 1;
wxString title = currPage->m_TitleStringCtrl->GetValue();
if( currPage->m_TitleStringCtrl )
{
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( title.IsEmpty() )
continue;
if( currPage->m_CommandStringCtrl )
{
Command = currPage->m_CommandStringCtrl->GetValue();
msg = CUSTOM_NETLIST_COMMAND;
msg << ii + 1;
m_config->Write( msg, Command );
}
msg = CUSTOM_NETLIST_TITLE;
msg << jj + 1;
m_config->Write( msg, title );
Command = currPage->m_CommandStringCtrl->GetValue();
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 )
if( FullFileName.IsEmpty() )
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
// "xsl" or "exe" or "py"
wxString cmdLine;
wxFileName fn( FullFileName );
wxString ext = fn.GetExt();
......@@ -817,6 +822,8 @@ void NETLIST_DIALOG_ADD_PLUGIN::OnBrowsePlugins( wxCommandEvent& event )
cmdLine.Printf(wxT("xsltproc -o \"%%O\" \"%s\" \"%%I\""), GetChars(FullFileName) );
else if( ext == wxT("exe" ) || ext.IsEmpty() )
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
cmdLine.Printf(wxT("\"%s\""), GetChars(FullFileName) );
......
......@@ -156,6 +156,16 @@ public:
* the corresponding text size is not constrained
*/
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