Commit aaab12d3 authored by jean-pierre charras's avatar jean-pierre charras

Mainly for testing purposes: page layout: if the environment variable...

Mainly for testing purposes: page layout: if the environment variable KICAD_WKSFILE points a S expr page layout descr, this descr is used instead of internal descr.
Therefore one can use a custom page layout and title block.
Eeschema, dialog edit component: minor enhancement (the last selected notebook page is remembered during a session)
parents 7432d4de c8c05cb4
......@@ -27,8 +27,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h>
/* keyword used in page layout description are (see page_layout_reader.keywords)
* page_layout
* setup
......@@ -136,6 +134,8 @@
// default line width 0.15 mm
// frame ref pitch 50 mm
// export defaultPageLayout:
extern const char defaultPageLayout[];
// Default page layout (sizes are in mm)
const char defaultPageLayout[] = "( page_layout\n"
......
......@@ -441,9 +441,14 @@ double PAGE_LAYOUT_READER_PARSER::parseDouble()
return val;
}
// defaultPageLayout is the default page layout description
// using the S expr.
// see page_layout_default_shape.cpp
extern const char defaultPageLayout[];
void WORKSHEET_LAYOUT::SetDefaultLayout()
{
ClearList();
PAGE_LAYOUT_READER_PARSER lp_parser( defaultPageLayout, wxT( "default page" ) );
try
......@@ -455,3 +460,60 @@ void WORKSHEET_LAYOUT::SetDefaultLayout()
wxLogMessage( ioe.errorText );
}
}
#include <wx/file.h>
// SetLayout() try to load a custom layout file,
// currently defined by the environment variable KICAD_WKSFILE
// (a *.kicad_wks file).
// if does not exists, loads the default page layout.
void WORKSHEET_LAYOUT::SetLayout()
{
wxString fullFileName;
wxGetEnv( wxT( "KICAD_WKSFILE" ), &fullFileName );
if( fullFileName.IsEmpty() || !wxFileExists( fullFileName ) )
{
#ifdef DEBUG
if( !wxFileExists( fullFileName ) )
{
wxLogMessage( wxT("Page layout file <%s> not found"),
fullFileName.GetData() );
}
#endif
SetDefaultLayout();
return;
}
wxFile wksFile( fullFileName );
if( ! wksFile.IsOpened() )
{
SetDefaultLayout();
return;
}
int filelen = wksFile.Length();
char * buffer = new char[filelen+10];
if( wksFile.Read( buffer, filelen ) != filelen )
wxLogMessage( _("The file <%s> was not fully read"),
fullFileName.GetData() );
else
{
buffer[filelen]=0;
ClearList();
PAGE_LAYOUT_READER_PARSER lp_parser( buffer, fullFileName );
try
{
lp_parser.Parse( this );
}
catch( IO_ERROR ioe )
{
wxLogMessage( ioe.errorText );
}
}
delete[] buffer;
}
......@@ -3,11 +3,6 @@
* @brief description of graphic items and texts to build a title block
*/
/*
* This file creates a lot of structures which define the shape of a title block
* and frame references
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
......@@ -33,14 +28,38 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/*
* the class WORKSHEET_DATAITEM (and WORKSHEET_DATAITEM_TEXT) defines
* a basic shape of a page layout ( frame references and title block )
* Basic shapes are line, rect and texts
* the WORKSHEET_DATAITEM coordinates units is the mm, and are relative to
* one of 4 page corners.
*
* These items cannot be drawn or plot "as this". they should be converted
* to a "draw list" (WS_DRAW_ITEM_BASE and derived items)
* The list of these items is stored in a WORKSHEET_LAYOUT instance.
*
* When building the draw list:
* the WORKSHEET_LAYOUT is used to create a WS_DRAW_ITEM_LIST
* coordinates are converted to draw/plot coordinates.
* texts are expanded if they contain format symbols.
* Items with m_RepeatCount > 1 are created m_RepeatCount times
*
* the WORKSHEET_LAYOUT is created only once.
* the WS_DRAW_ITEM_LIST is created each time the page layout is plot/drawn
*
* the WORKSHEET_LAYOUT instance is created from a S expression which
* describes the page layout (can be the default page layout or a custom file).
*/
#include <fctsys.h>
#include <drawtxt.h>
#include <worksheet.h>
#include <class_title_block.h>
#include <worksheet_shape_builder.h>
extern void SetDataList( WORKSHEET_LAYOUT& aDataList );
WORKSHEET_DATAITEM_TEXT::WORKSHEET_DATAITEM_TEXT( const wxChar* aTextBase ) :
WORKSHEET_DATAITEM( WS_TEXT )
......@@ -207,7 +226,7 @@ void WS_DRAW_ITEM_LIST::BuildWorkSheetGraphicList(
// Build the basic layout shape, if the layout list is empty
if( dataList.GetCount() == 0 )
dataList.SetDefaultLayout();
dataList.SetLayout();
WORKSHEET_DATAITEM::m_WSunits2Iu = m_milsToIu / milsTomm;
......
/////////////////////////////////////////////////////////////////////////////
// Name: dialog_edit_component_in_lib.cpp
// Author: jean-pierre Charras
// Licence: GPL
/////////////////////////////////////////////////////////////////////////////
/**
* @file dialog_edit_component_in_lib.cpp
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* 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
*/
#include <fctsys.h>
#include <common.h>
......@@ -11,12 +32,12 @@
#include <appl_wxstruct.h>
#include <general.h>
#include <protos.h>
#include <libeditframe.h>
#include <class_library.h>
#include <dialog_edit_component_in_lib.h>
int DIALOG_EDIT_COMPONENT_IN_LIBRARY::m_lastOpenedPage = 0;
DIALOG_EDIT_COMPONENT_IN_LIBRARY::DIALOG_EDIT_COMPONENT_IN_LIBRARY( LIB_EDIT_FRAME* aParent ):
DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( aParent )
......@@ -33,6 +54,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY::DIALOG_EDIT_COMPONENT_IN_LIBRARY( LIB_EDIT_FRA
DIALOG_EDIT_COMPONENT_IN_LIBRARY::~DIALOG_EDIT_COMPONENT_IN_LIBRARY()
{
m_lastOpenedPage = m_NoteBook->GetSelection( );
}
/* Initialize state of check boxes and texts
......@@ -86,6 +108,8 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::initDlg()
m_ButtonDeleteOneFootprintFilter->Enable( false );
}
m_NoteBook->SetSelection( m_lastOpenedPage );
m_stdSizerButtonOK->SetDefault();
}
......@@ -156,7 +180,6 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel()
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
{
/* Update the doc, keyword and doc filename strings */
int index;
LIB_ALIAS* alias;
......
/////////////////////////////////////////////////////////////////////////////
// Name: dialog_edit_component_in_lib.h
// Author: jean-pierre Charras
// Licence: GPL
/////////////////////////////////////////////////////////////////////////////
/**
* @file dialog_edit_component_in_lib.h
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* 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
*/
#ifndef _DIALOG_EDIT_COMPONENT_IN_LIB_H_
......@@ -13,6 +34,8 @@
class DIALOG_EDIT_COMPONENT_IN_LIBRARY: public DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE
{
static int m_lastOpenedPage; // To remember the last notebook selection
public:
LIB_EDIT_FRAME* m_Parent;
bool m_RecreateToolbar;
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 10 2012)
// C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -109,7 +109,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
m_PanelBasic->SetSizer( bSizerBasicPanel );
m_PanelBasic->Layout();
bSizerBasicPanel->Fit( m_PanelBasic );
m_NoteBook->AddPage( m_PanelBasic, _("Options"), false );
m_NoteBook->AddPage( m_PanelBasic, _("Options"), true );
m_PanelDoc = new wxPanel( m_NoteBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
wxBoxSizer* m_PanelDocBoxSizer;
m_PanelDocBoxSizer = new wxBoxSizer( wxVERTICAL );
......@@ -121,6 +121,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
m_PanelDocBoxSizer->Add( m_staticTextDescription, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_DocCtrl = new wxTextCtrl( m_PanelDoc, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_DocCtrl->SetMaxLength( 0 );
m_PanelDocBoxSizer->Add( m_DocCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_staticTextKeywords = new wxStaticText( m_PanelDoc, wxID_ANY, _("Keywords:"), wxDefaultPosition, wxDefaultSize, 0 );
......@@ -130,6 +131,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
m_PanelDocBoxSizer->Add( m_staticTextKeywords, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_KeywordsCtrl = new wxTextCtrl( m_PanelDoc, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_KeywordsCtrl->SetMaxLength( 0 );
m_PanelDocBoxSizer->Add( m_KeywordsCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_staticTextDocFileName = new wxStaticText( m_PanelDoc, wxID_ANY, _("DocFileName:"), wxDefaultPosition, wxDefaultSize, 0 );
......@@ -139,6 +141,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
m_PanelDocBoxSizer->Add( m_staticTextDocFileName, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_DocfileCtrl = new wxTextCtrl( m_PanelDoc, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 400,-1 ), 0 );
m_DocfileCtrl->SetMaxLength( 0 );
m_PanelDocBoxSizer->Add( m_DocfileCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizerPaneldocbutts;
......@@ -157,7 +160,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
m_PanelDoc->SetSizer( m_PanelDocBoxSizer );
m_PanelDoc->Layout();
m_PanelDocBoxSizer->Fit( m_PanelDoc );
m_NoteBook->AddPage( m_PanelDoc, _("Description"), true );
m_NoteBook->AddPage( m_PanelDoc, _("Description"), false );
m_PanelAlias = new wxPanel( m_NoteBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
wxBoxSizer* bSizerMainPanelAlias;
bSizerMainPanelAlias = new wxBoxSizer( wxHORIZONTAL );
......
......@@ -185,7 +185,7 @@
<object class="notebookpage" expanded="1">
<property name="bitmap"></property>
<property name="label">Options</property>
<property name="select">0</property>
<property name="select">1</property>
<object class="wxPanel" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
......@@ -1348,7 +1348,7 @@
<object class="notebookpage" expanded="1">
<property name="bitmap"></property>
<property name="label">Description</property>
<property name="select">1</property>
<property name="select">0</property>
<object class="wxPanel" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 10 2012)
// C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -11,6 +11,8 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/checkbox.h>
......
......@@ -47,9 +47,5 @@ void DrawPageLayout( wxDC* aDC, EDA_DRAW_PANEL * aCanvas,
int aPenWidth, double aScalar,
EDA_COLOR_T aLineColor, EDA_COLOR_T aTextColor );
// defaultPageLayout is the default page layout description
// using the S expr.
// see page_layout_default_shape.cpp
extern const char defaultPageLayout[];
#endif // WORKSHEET_H_
......@@ -507,6 +507,13 @@ public:
* Fills the list with the default layout shape
*/
void SetDefaultLayout();
/**
* Fills the list with a custom layout, or
* the default layout, if no custom layout available
*/
void SetLayout();
};
#endif // WORKSHEET_SHAPE_BUILDER_H
( page_layout
( 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) )
( rect (start 0 0 ltcorner) (end 0 0 rbcorner) (repeat 2) (incrx 2) (incry 2) )
( line (start 50 2 ltcorner) (end 50 0 ltcorner) (repeat 30) (incrx 50) )
( tbtext "1" (pos 25 1 ltcorner) (font (size 1.3 1.3))(repeat 100) (incrx 50) )
( line (start 50 2 lbcorner) (end 50 0 lbcorner) (repeat 30) (incrx 50) )
( tbtext "1" (pos 25 1 lbcorner) (font (size 1.3 1.3)) (repeat 100) (incrx 50) )
( line (start 0 50 ltcorner) (end 2 50 ltcorner) (repeat 30) (incry 50) )
( tbtext "A" (pos 1 25 ltcorner) (font (size 1.3 1.3))
(justify center)(repeat 100) (incry 50) )
( line (start 0 50 rtcorner) (end 2 50 rtcorner) (repeat 30) (incry 50) )
( tbtext "A" (pos 1 25 rtcorner) (font (size 1.3 1.3))
(justify center) (repeat 100) (incry 50) )
( tbtext "Date: %D" (pos 87 6.9) )
( line (start 110 5.5) end 2 5.5) )
( tbtext "%K" (pos 109 4.1) (comment Kicad version ) )
( line (start 110 8.5) end 2 8.5) )
( tbtext "Rev: %R" (pos 24 6.9)(font bold)(justify left) )
( tbtext "Size: %Z" (comment Paper format name)(pos 109 6.9) )
( tbtext "Id: %S/%N" (comment Sheet id)(pos 24 4.1) )
( line (start 110 12.5) end 2 12.5) )
( tbtext "Title: %T" (pos 109 10.7)(font bold (size 2 2)) )
( tbtext "File: %F" (pos 109 14.3) )
( line (start 110 18.5) end 2 18.5) )
( tbtext "Sheet: %P" (pos 109 17) )
( tbtext "%Y" (comment Company name) (pos 109 20)(font bold) )
( tbtext "%C0" (comment Comment 0) (pos 109 23) )
( tbtext "%C1" (comment Comment 0) (pos 109 26) )
( tbtext "%C2" (comment Comment 0) (pos 109 29) )
( tbtext "%C3" (comment Comment 0) (pos 109 32) )
( line (start 90 8.5) end 90 5.5) )
( line (start 26 8.5) end 26 2) )
)
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