7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-19 00:21:36 +00:00

Cleanup some unused files

This commit is contained in:
Ian McInerney 2020-06-19 12:34:15 +01:00
parent aa7ce74ad5
commit fe1e835471
37 changed files with 3 additions and 12611 deletions

View File

@ -43,17 +43,15 @@ our [Forum](https://forum.kicad.info/).
* [include](include) - Interfaces to the common library
* [kicad](kicad) - Sourcecode of the project manager
* [libs](libs) - Sourcecode of kicad utilities (geometry and others)
* [new](new) - Staging area for the new schematic library format
* [pagelayout_editor](pagelayout_editor) - Sourcecode of the pagelayout editor
* [patches](patches) - Collection of patches for external dependencies
* [pcbnew](pcbnew) - Sourcecode of the printed circuit board editor
* [plugins](plugins) - Sourcecode of the new plugin concept
* [polygon](polygon) - Sourcecode of the polygon library
* [qa](qa) - Testcases using the python interface
* [plugins](plugins) - Sourcecode for the 3d viewer plugins
* [qa](qa) - Unit testing framework for KiCad
* [resources](resources) - Resources for freedesktop mime-types for linux
* [scripting](scripting) - SWIG Python scripting definitions and build scripts
* [scripts](scripts) - Example scripts for distribution with KiCad
* [template](template) - Project and pagelayout templates
* [template](template) - Project template
* [thirdparty](thirdparty) - Sourcecode of external libraries used in kicad but not written by Kicad team
* [tools](tools) - Other miscellaneous helpers for testing
* [utils](utils) - Small utils for kicad, e.g. IDF, STEP and OGL tools and converters

View File

@ -1,50 +0,0 @@
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2012-2017 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 <core/settings.h>
void SETTINGS::Load( wxConfigBase *aConfig )
{
for( PARAM_CFG* param : m_params )
{
if( !!param->m_Group )
aConfig->SetPath( param->m_Group );
else
aConfig->SetPath( wxT("") );
param->ReadParam( aConfig );
}
}
void SETTINGS::Save( wxConfigBase *aConfig )
{
for( PARAM_CFG* param : m_params )
{
if( !!param->m_Group )
aConfig->SetPath( param->m_Group );
else
aConfig->SetPath( wxT("") );
param->SaveParam( aConfig );
}
}

View File

@ -1,127 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 CERN
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* 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 __SETTINGS_H
#define __SETTINGS_H
#include <wx/confbase.h>
#include <config_params.h>
/**
* TOOL_SETTINGS
*
* Manages persistent settings for a tool (just a simple wrapper to wxConfigBase)
*/
class SETTINGS
{
public:
SETTINGS()
{}
virtual ~SETTINGS()
{}
/** Set a prefix that will be prepent to the keywords when adding a setting in list
* @param aPrefix is the string to prepend to the keywords
*/
void SetConfigPrefix( const wxString& aPrefix )
{
m_prefix = aPrefix;
}
/** @return the current prefix
*/
const wxString& GetConfigPrefix()
{
return m_prefix;
}
virtual void Load( wxConfigBase *aConfig );
virtual void Save( wxConfigBase *aConfig );
#if 0
template<class T>
T Get( const wxString& aName, T aDefaultValue ) const
{
wxConfigBase* config = getConfigBase();
if( !config )
return aDefaultValue;
T tmp = aDefaultValue;
config->Read( getKeyName( aName ), &tmp );
return tmp;
}
template<class T>
void Set( const wxString& aName, const T &aValue )
{
wxConfigBase* config = getConfigBase();
if( !config )
return;
config->Write( getKeyName( aName ), aValue );
}
#endif
void Add( const wxString& name, int* aPtr, int aDefaultValue )
{
m_params.push_back( new PARAM_CFG_INT ( m_prefix+name, aPtr, aDefaultValue ) );
}
void Add( const wxString& name, bool* aPtr, bool aDefaultValue )
{
m_params.push_back( new PARAM_CFG_BOOL ( m_prefix+name, aPtr, aDefaultValue ) );
}
void Add( const wxString& name, KIGFX::COLOR4D* aPtr, KIGFX::COLOR4D aDefaultValue )
{
m_params.push_back( new PARAM_CFG_SETCOLOR ( m_prefix+name, aPtr, aDefaultValue ) );
}
void Add( const wxString& name, KIGFX::COLOR4D* aPtr, EDA_COLOR_T aDefaultValue )
{
m_params.push_back( new PARAM_CFG_SETCOLOR ( m_prefix+name, aPtr, aDefaultValue ) );
}
protected:
virtual wxString getKeyName( const wxString& aEntryName ) const
{
return aEntryName;
}
wxString m_prefix;
std::vector<PARAM_CFG*> m_params;
};
#endif

View File

@ -1,91 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2007-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2016 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
*/
/**
* @file pcbstruct.h
* @brief Classes and definitions used in Pcbnew.
*/
#ifndef PCBSTRUCT_H_
#define PCBSTRUCT_H_
/**
* Enum TRACE_CLEARANCE_DISPLAY_MODE_T
* is the set of values for DISPLAY_OPTIONS.ShowTrackClearanceMode parameter option.
* This parameter controls how to show tracks and vias clearance area.
*/
enum TRACE_CLEARANCE_DISPLAY_MODE_T {
DO_NOT_SHOW_CLEARANCE = 0, // Do not show clearance areas
SHOW_CLEARANCE_NEW_TRACKS, /* Show clearance areas only for new track
* during track creation. */
SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS, /* Show clearance areas only for new track
* during track creation, and shows a via
* clearance area at end of current new
* segment (guide to place a new via
*/
SHOW_CLEARANCE_NEW_AND_EDITED_TRACKS_AND_VIA_AREAS,
/* Show clearance for new, moving and
* dragging tracks and vias
*/
SHOW_CLEARANCE_ALWAYS /* Show Always clearance areas
* for track and vias
*/
};
/**
* DISPLAY_OPTIONS
* handles display options like enable/disable some optional drawings.
*/
class DISPLAY_OPTIONS
{
public:
bool m_DisplayPadFill;
bool m_DisplayViaFill;
bool m_DisplayPadNum; // show pads numbers
bool m_DisplayPadIsol;
bool m_DisplayModEdgeFill; // How to display module drawings ( sketch/ filled )
bool m_DisplayModTextFill; // How to display module texts ( sketch/ filled )
bool m_DisplayPcbTrackFill; // false : tracks are show in sketch mode, true = filled.
/// How trace clearances are displayed. @see TRACE_CLEARANCE_DISPLAY_MODE_T.
TRACE_CLEARANCE_DISPLAY_MODE_T m_ShowTrackClearanceMode;
int m_DisplayZonesMode;
int m_DisplayNetNamesMode; /* 0 do not show netnames,
* 1 show netnames on pads
* 2 show netnames on tracks
* 3 show netnames on tracks and pads
*/
bool m_ContrastModeDisplay;
int m_MaxLinksShowed; // in track creation: number of hairwires shown
bool m_Show_Module_Ratsnest; // When moving a footprint: allows displaying a ratsnest
public:
DISPLAY_OPTIONS();
};
#endif // PCBSTRUCT_H_

View File

@ -1,251 +0,0 @@
# This program source code file is part of KICAD, a free EDA CAD application.
#
# Copyright (C) 2011 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
# Copyright (C) 2011 Kicad Developers, see change_log.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
#
# for now, this is a stand alone project
if( 1 )
project(kicad-new)
cmake_minimum_required( VERSION 2.8 FATAL_ERROR )
set( PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../ )
# message( "PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}" )
# Path to local CMake modules.
set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules )
include( CheckFindPackageResult )
find_package(Doxygen)
# On Apple only wxwidgets 2.9 or higher doesn't need to find aui part of base
if(APPLE)
find_package(wxWidgets COMPONENTS gl adv html core net base xml QUIET )
else()
find_package(wxWidgets COMPONENTS gl adv html core net base xml aui QUIET )
endif()
check_find_package_result( wxWidgets_FOUND "wxWidgets" )
# make config.h
include( PerformFeatureChecks )
perform_feature_checks()
# Include wxWidgets macros.
include( ${wxWidgets_USE_FILE} )
include_directories( ${PROJECT_SOURCE_DIR}/include )
if(CMAKE_COMPILER_IS_GNUCXX)
# Set default flags for Release build.
set(CMAKE_C_FLAGS_RELEASE "-Wall -O2 -DNDEBUG ")
set(CMAKE_CXX_FLAGS_RELEASE "-Wall -O2 -DNDEBUG")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-s -static-libgcc")
# Set default flags for Debug build.
set(CMAKE_C_FLAGS_DEBUG "-Wall -g3 -ggdb3 -DDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g3 -ggdb3 -DDEBUG")
endif(CMAKE_COMPILER_IS_GNUCXX)
include(Functions)
endif()
#================================================
# Doxygen Output
#================================================
if(DOXYGEN_FOUND)
add_custom_target( new-docs ${DOXYGEN_EXECUTABLE}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS Doxyfile )
else(DOXYGEN_FOUND)
message( STATUS "WARNING: Doxygen not found - new-docs (Source Docs) target not created" )
endif()
include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
include_directories( ${CMAKE_BINARY_DIR} )
#=====<on standby for possible C++ unit testing>================================
if( false )
add_executable( test_dir_lib_source
sch_dir_lib_source.cpp
)
target_link_libraries( test_dir_lib_source ${wxWidgets_LIBRARIES} )
add_executable( test_sch_part sch_part.cpp )
target_link_libraries( test_sch_part ${wxWidgets_LIBRARIES} )
add_executable( test_lpid
sch_lpid.cpp
)
target_link_libraries( test_lpid ${wxWidgets_LIBRARIES} )
endif( false )
#=====</on standby for possible C++ unit testing>===============================
add_library( sweet SHARED
sch_lib_table.cpp
sch_lib.cpp
sch_lpid.cpp
sch_dir_lib_source.cpp
sch_part.cpp
sch_sweet_parser.cpp
${PROJECT_SOURCE_DIR}/common/richio.cpp
${PROJECT_SOURCE_DIR}/common/dsnlexer.cpp
)
make_lexer(
sweet
${CMAKE_CURRENT_SOURCE_DIR}/sch_lib_table.keywords
${CMAKE_CURRENT_SOURCE_DIR}/sch_lib_table_lexer.h
${CMAKE_CURRENT_SOURCE_DIR}/sch_lib_table_keywords.cpp
LT
)
make_lexer(
sweet
${CMAKE_CURRENT_SOURCE_DIR}/sweet.keywords
${CMAKE_CURRENT_SOURCE_DIR}/sweet_lexer.h
${CMAKE_CURRENT_SOURCE_DIR}/sweet_keywords.cpp
PR
)
target_link_libraries( sweet ${wxWidgets_LIBRARIES} )
# talk to import_export.h
set_target_properties( sweet PROPERTIES
DEFINE_SYMBOL COMPILING_DLL
)
add_executable( test_sch_lib_table test_sch_lib_table.cpp )
if( MINGW )
set_target_properties( test_sch_lib_table PROPERTIES
LINK_FLAGS -Wl,--enable-auto-import
)
endif()
target_link_libraries( test_sch_lib_table sweet )
if( 1 )
find_library( gal_LIBRARY "libgal.a"
PATHS
"${CMAKE_CURRENT_SOURCE_DIR}/../../kicad-gal/build"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../kicad-gal/build"
DOC
"Where is the static GAL library"
)
find_path( gal_ROOT NAMES "README.txt"
PATHS
"${CMAKE_CURRENT_SOURCE_DIR}/../../kicad-gal"
"${CMAKE_CURRENT_SOURCE_DIR}/../../../kicad-gal"
DOC
"Where is the base include directory for the GAL library"
)
else()
# we build the GAL library, therefore we know where it is, no need to find_library() it.
set( gal_ROOT "${CMAKE_CURRENT_BINARY_DIR}/gal-src" )
set( gal_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/gal-src/libgal.a" )
include( ExternalProject )
ExternalProject_Add( ki_gal
# skip the install step, build in source, use from source
SOURCE_DIR "${gal_ROOT}"
STAMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/gal-stamps"
TIMEOUT 120
DOWNLOAD_COMMAND bzr export ${gal_ROOT} lp:~kicad-testing-committers/kicad/kicad-gal
CONFIGURE_COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${gal_ROOT}
BUILD_IN_SOURCE 1
BUILD_COMMAND make
INSTALL_COMMAND ""
)
endif()
include_directories( "${gal_ROOT}" )
# Find pkg-config in order find cairo.
find_package( PkgConfig REQUIRED )
# Find cairo.
#pkg_search_module( CAIRO REQUIRED cairo>=1.8.1 )
#include_directories( ${CAIRO_INCLUDE_DIRS} )
# Find the OpenGL libraries (gl and glu)
find_package( OpenGL )
# Find GLEW
pkg_search_module( GLEW REQUIRED glew>=1.5.0 )
include_directories( ${GLEW_INCLUDE_DIRS} )
include_directories( ${gal_ROOT} )
add_executable( sweet_edit sweet_edit.cpp sweet_editor_panel.cpp sch_canvas.cpp )
target_link_libraries( sweet_edit
sweet
${OPENGL_LIBRARIES}
${gal_LIBRARY}
${wxWidgets_LIBRARIES}
${GLEW_LIBRARIES}
${GDI_PLUS_LIBRARIES}
)
#=====<USE_SWIG>============================================================
# if you want a Python scripting layer on top for unit testing or driving.
# reference: http://www.swig.org/Doc1.3/Introduction.html#Introduction_build_system
option( USE_SWIG "Use SWIG to build a python scripting interface (default OFF)." OFF)
if( USE_SWIG )
find_package( SWIG REQUIRED )
include( ${SWIG_USE_FILE} )
# first install "python-dev" linux package for this:
find_package( PythonLibs )
include_directories( ${PYTHON_INCLUDE_PATH} )
set( CMAKE_SWIG_FLAGS "" )
set_source_files_properties( sweet.i PROPERTIES CPLUSPLUS ON )
#set_source_files_properties( sweet.i PROPERTIES SWIG_FLAGS "-includeall" )
swig_add_module( sweet python sweet.i )
swig_link_libraries( sweet ${PYTHON_LIBRARIES} sweet )
# @todo need a separate interface for each DSNLEXER
endif()

File diff suppressed because it is too large Load Diff

View File

@ -1,476 +0,0 @@
namespace SCH {
/** @mainpage
This file describes the design of a new Distributed Library System for KiCad's
EESCHEMA. Many of the concepts can be adapted with modest modification to PCBNEW
also, in the future.
@author Dick Hollenbeck <dick@softplc.com>
@date October 2010 - January 2011
@section intr_sec Introduction
Schematic <b>parts</b> are frequently needed to complete a circuit design
schematic. Computer data entry of parts can be a rate limiting step in the
design of an overall PCB. Having ready made access to all needed parts in a
design significantly improves the productivity of a circuit designer. Sharing
parts within an organization is one step in the right direction, but there is
opportunity to share across organizational boundaries to improve productivity
even more. Using a part that someone else in another organization has already
entered into the computer can eliminate the first data input process for that
part. The more complicated the part and the board, the larger the positive
impact on productivity because the larger the time savings.
<p> Sharing parts within an organization is best done by directly accessing a
known internal source for those parts, say on a company network. Sharing parts
across organizational boundaries is best done using the Internet in real-time.
Having the ability to search for a part based on arbitrary search criteria can
speed up the pace at which new parts are found and used.
<p> Electronic component manufacturers need and look for ways to differentiate
their products from their competitors. With this Distributed Library System
facility in KiCad, one way for manufacturers to differentiate themselves and
their parts is to publish a part library on the Internet and save their
customers the work of doing the data entry of the part into the KiCad design
system.
<p> Maintaining a comprehensive part library is a fairly labor intensive
activity. New parts come into the market everyday. By being able to publish a
superior library on the Internet, it may be possible to make a for profit
business out of doing this. The KiCad eco-system would benefit should this
happen, and there could even be competition between such businesses. Or there
can be library specializations or niches.
<p> Often a found part is close to what is needed but not exactly what is
needed. This Distributed Library System design incorporates the concept of part
inheritance using a part description language called <b>Sweet</b>. Sweet is
based on s-expression syntax. Inheritance is the ability to incrementally change
an existing part without completely re-designing it. It is sometimes easier to
modify an existing part than it is to create the new part entirely from scratch.
<p> This Distributed Library System design will have the capability to
significantly benefit the KiCad eco-system, and that should mean expanding the
numbers of users and contributors to the project, and hopefully making for a
better KiCad tool-set for all.
@section definitions Definitions
Only new terms or changes in the definition of terms are given here.
<dl>
<dt>S-Expression</dt><dd>This is a syntactical textual envelop in the same vain as
XML. It may be used to express any number of domain specific grammars. It uses
parentheses to indicate the start and end of an element. A domain specific
grammar is a set of rules that dictate what keywords may be used, and in what
context. A grammar also establishes the allowed places and types of constants.
There can be any number of grammars which all use s-expressions to hold the
individual elements within the grammar. A grammar is at a higher level than
s-expressions, in the same way that a sentence will have grammatical rules which
are at a higher level than the rules used to spell words. Technically, grammars
nest within grammars. So once you are inside a grammatical element, it will have
its own set of rules as to which nested elements it may hold, and once you enter
one of those nested elements, then that nested element's grammar pertains,
etc.<p> In the case of the grammar for a part, the grammar itself is being given
the name Sweet. The name does not extend to the grammar for the schematic,
only the part grammar.</dd>
<dt>Schematic</dt><dd>This consists of one or more sheets and will be different
in three ways from existing schematics. <ul>
<li>All sheets will be in one file, thus the entire schematic is in one file.
<li>The schematic file will have its own s-expression grammar.
<li> There will be a <b>parts list</b> within the schematic, and within the
parts list will be <b>all</b> the parts for the schematic. yes <b>all</b> of
them. See class PARTS_LIST.</ul>
Within the sheets of the schematic will be components.</dd>
<dt>Component</dt><dd>A component is an instantiated part. The keyword for
component is (comp). A component does not have any of its own properties other
than: <ul> <li>rerence designator <li>part pointer or reference into the parts
list <li>location <li>rotation <li>stuff i.e. DNS or do stuff the part
<li>visual textual effect overrides </ul> Note that the (comp) may not have any
properties or fields of its own, and that it may not exist without a
corresponding part in the parts_list. A reason for this is to ensure that a
BOM can be made simply from the parts_list.</dd>
<dt>Component, again for good measure.</dt><dd>A component is an instantiation
of a part. A component exists within a schematic which has a parts list
containing the part from which the component is instantiated. A component has a
unique reference designator, part ref, its own location, orientation,
stuff/DNS, and text attributes but <b>not</b> its own text fields/strings (other
than reference designator). The part which is instantiated must exist in the
parts list of the same schematic.</dd>
<dt>Inheritance</dt><dd>Is the ability to mimic form and function from another
entity. In our case we use it only for parts. One part may "inherit from" or
"extend" another single part.</dd>
<dt>Part</dt><dd>A part is a symbolic schematic circuit element found within an
EESCHEMA library (or within a parts list). It is re-usable and may be
instantiated more than once within a schematic. For it to be instantiated, it
must be copied or inherited into the parts list of the instantiating schematic.
If inherited into the parts list, then only a concise reference is needed into
the originating library. If instead it is copied into the parts list, then the
part is fully autonomous and need have no reference to its original copy.</dd>
<dt>Parts List</dt><dd>A parts list, keyword (parts_list), is an entirely new
construct. It exists within a schematic and is the complete set of parts used
within a particular schematic. Each schematic has exactly one parts list
contained within it. A parts list is also a library source and a library sink
for the current schematic. A parts list in any schematic may also be a library
source for any other schematic, but not a library sink. The parts list construct
makes it almost wholly unnecessary to write to other types of library
sinks.</dd>
<dt>Library</dt><dd>A library is no longer a file. It is a memory cache of
parts, consistent with the normal definition of memory cache. Each library is
backed up with a <b>library source</b>. In rare cases, some libraries may also
have a <b>library sink</b>.</dd>
<dt>Library Source</dt><dd>A library source is an abstract read only repository
of parts. The repository itself might exist on the moon. The difference between
a library source and a library sink is that a source is a readable entity.</dd>
<dt>Library Sink</dt><dd>A library sink is an abstract place that parts can be
written to for future reading. The difference between a library source and a
library sink is that a library sink is a writable entity.</dd>
<dt>Symbol</dt><dd>The term "symbol" is not used in a specific way in this
document. There is no symbol in any of the grammars, so use of it on the
developers list will not be understood without explanation. Of course it is
possible to have multiple parts all extend a common base part, and you can think
of the base part as having most if not all the graphical lines for any
derivatives. But we do not need to use the term symbol to describe that
relationship, the term "part" is sufficient.</dd>
<dt>LPID</dt><dd>This stands for "Logical Part ID", and is a reference to any
part within any known library. The term "logical" is used because the contained
library name is logical, not a full library name. The LPID consists of 3 main
portions: logical library name, part name, and revision number.</dd>
<dt>Library Table</dt><dd>This is a lookup table that maps a logical library
name (i.e. a short name) into a fully specified library name and library type.
An applicable library table consists of rows from (at least) two sources:<ol>
<li>A schematic resident library table.
<li>A personal library table.
</ol>
These rows from the two sources are conceptually concatonated (although they may
not be physically concatonated in the implementation, TBD). The schematic
resident rows take presedence over the personal library table if there are
logical library names duplicately defined. (Or we will simply ask that any remote
(i.e. public) libraries use uppercase first letters in logical names, TBD.)
<p> Eventually there will be an external publicly available internet based
logical library table also, but this will need to be glued down at a hard coded
URL that we have control over. The internet based library table allows us to
advertise remote libraries without having to issue an update to KiCad.</dd>
<dt>Query Language</dt><dd>This is a means of searching for something that is
contained within a container. Since some library sources are remote, it is
important to be able to ask the library source for a part that matches some
criteria, for performance reasons.</dd>
</dl>
@section changes Required Changes
In order fulfill the vision embodied by this Distributed Library System design,
it will be necessary to change many APIs and file formats within EESCHEMA. In
fact, the entire schematic file format will be new, based on s-expressions,
the schematic grammar, and the Sweet language for parts.
Here are some of the changes required: <ul>
<li> All sheets which make up a schematic will go into a single s-expression
file. The multiple sheet support will still exist, but all the sheets for a
single schematic are all in a single file.
<li> A "library" is a collection of "parts". The unit of retrieval from a
library is a part as a textual string in the Sweet language. Sweet is a
particular "grammar" expressed in s-expression form, and can be used to fully
describe parts. Because EESCHEMA does not actually see a "library file",
(remember, EESCHEMA can only ask for a part), the actual file format for a
library is no longer pertinent nor visible to the core of EESCHEMA. The unit of
retrieval from the API is the part, so EESCHEMA gets an entire part s-expression
and must then parse it as a RAM resident Sweet string.
<li>EESCHEMA knows of no library files, instead there is a library API which
abstracts the actual part storage strategy used within any library
implementation. The API can be implemented by anyone wanting to provide a
library under a given storage strategy. The API provides a storage strategy
abstraction in classes LIB_SOURCE and LIB_SINK. The actual storage strategy used
in any particular library implementation is not technically part of the
conceptual core of EESCHEMA. This is an important concept to grasp. Eventually
the library implementations may be jetisoned into a plug-in structure, but
initially they are statically linked into EESCHEMA. Should the plug-in strategy
ever get done, the boundary of the plug-in interface will remain the C++ library
API as given here (mostly in class LIB_SOURCE). The only reason to introduce a
plug-in design is to allow proprietary closed source library implementations,
and this could eventually come about if a part vendor wanted to provide one for
the KiCad project. If a Texas Instruments type of company wants to maintain a
KiCad library, we will be positioned to accommodate them. Until then, the
LIB_SOURCE implementations can be statically linked into EESCHEMA and there is
no conceptual disruption either way.
<li> Most library implementations are read only. There are only two library
types that are writable, the "dir" type, and the "parts list". All other types
are read only from the perspective of the API. Stuffing those read only
libraries and maintaining them will be done using the normal update mechanisms
pertinent to the library's respective type of repository. The most common place
to do incremental enhancements to a part before using it is not in the external
library, but now in the parts list with this new design.
<li> The design will support classical clipboard usage. The part in the Sweet
language can be placed onto the clipboard for use by other applications and
instances of EESCHEMA. Eventually larger blocks of components may also be
supported on the clipboard, since the Sweet language allows these blocks to be
descributed textually in a very readable fashion. (Clipboard support beyond part
manipulation is not currently in this revision of the design however, it can be
a future separate enhancement. Perhaps someday complete sheets may be passed
through the clipboard.)
<li> The cumulative set of required changes are significant, and are tantamount
to saying that EESCHEMA will need its part handling foundations re-written. A
conversion program will convert everything over to the new architecture. The
conversion program can simplify things by simply putting all schematic parts
into a parts list within each schematic.
<li> An Internet connection is required to use some of the library sources. It
will be possible to omit these library sources and run KiCad by doing a
configuration change. Eventually, some library sources will spring up and will
not technically be part of the KiCad project, so they will remain remote, but
fully usable to those with an internet connection and permission from the
library source's owner.
<li>By far, even as radical as the distributed library concept is, complete with
remote access, the most significant conceptual change is the introduction of the
<b>parts list</b>. This is a special library that exists in a schematic, and is
the complete record of all parts used within that same schematic. It is
impossible to put a component into a schematic without that component's part
first existing within the parts list of that schematic.
<li> Because of inheritance, multi-body-form parts, alternate body styles, see
also references, and other needs, it is necessary to have a <b>part reference
mechanism</b>. A component has to reference a part, the one it "is". A part has
to be able to reference another part, either in the same library or elsewhere.
Enter the Logical Part ID, or LPID to serve this need. An LPID consists of a
logical library name, a part name, and an optional revision. It is used to
reference parts, from anywhere. If the reference is from a sheet's component,
then the logical library name of the LPID is not needed. Why? Well if you've
been paying attention you know. A comp can only be based on a part that exists
within the parts_list of the same schematic in which it resides. Likewise, a
part within any library that references another part in that <b>same</b> library
will also omit the logical library name from the LPID, and it must omit it. Why?
Well because it makes renaming the library easier, for one. Two, the logical
library name is only a lookup key into a "library table". The library table maps
the logical library name into an actual library source [and sink, iff writable].
See LIB_SOURCE and LIB_SINK.
<p> In the case of the component referencing the part that it "is", there is no
revision number allowed in the LPID. This is because that reference is to the
part in the parts list, and the parts list only holds a single revision of any
part (where "revision" is what you understand from version control systems).
<li> There needs to be a new query language designed and each library source
needs to support it. See LIB_SOURCE::FindParts() for a brief description of one.
</ul>
@section philosophy Design Philosophies
<p> Class names are chosen to be as concise as possible. Separate namespaces can be
used should these same class names be needed in both EESCHEMA and PCBNEW (later).
However, this design does not yet address PCBNEW. Suggested namespaces are
SCH for EESCHEMA, and PCB for PCBNEW.
<p> Since most if not all the APIs deal with file or non-volatile storage, only
8 bit string types are used. For international strings, UTF-8 is used, and
that is what is currently in use within the KiCad file storage formats.
<p> The typedef <b>STRINGS</b> is used frequently as a holder for multiple
std::strings. After some research, I chose std::dequeue<STRING> to hold a list of
STRINGs. I thought it best when considering overall speed, memory
fragmentation, memory efficiency, and speed of insertion and expansion.
<p> A part description language is introduced called <b>(Sweet)</b>. It supports
inheritance and its syntax is based on s-expressions.
<p> Since a part can be based on another part using inheritance, it is important
to understand the idea of library dependencies. A part in one library can be
dependent on another part in another library, or on another part in the same
library as itself. There are several library sources, some far away and some
very close to the schematic. The closest library to the schematic is the
<b>(parts list)</b> class PARTS_LIST. Circular dependencies are not allowed. All
dependencies must be resolvable in a straight forward way. This means that a
part in a remote library cannot be dependent on any part which is not always
resolvable.
<p> NRVO described:
http://msdn.microsoft.com/en-us/library/ms364057%28VS.80%29.aspx
Even with NRVO provided by most C++ compilers, I don't see it being as lean as
having class LIB keep expanded members STRING fetch and STRINGS vfetch for the
aResults values. But at the topmost API, client convenience is worth a minor
sacrifice in speed, so the topmost API does return these complex string objects
for convenience. So there is a different strategy underneath the hood than what
is used on the hood ornament. When aResults pointer is passed as an argument, I
won't refer to this as 'returning' a value, but rather 'fetching' a result to
distinguish between the two strategies.
<p> Functions named as lookupSomething() or LookupSomething() are to be understood
as "find and load if needed". This is different than a simple find operation only, in
that an implied load operation is also done, but only if needed.
@section architecture Architecture
This document set later shows some <b>library sources</b> derived from class
LIB_SOURCE. A library source is the backing to a library. The class name for a
library in the new design is LIB.
<p>
<IMG SRC="../drawing.png" ALT="You should see design architecture here">
*/
/**
* @defgroup string_types STRING Types
* Provide some string types for use within the API.
*/
/**
* @defgroup exception_types Exception Types
* Provide some exception types for use within the API.
*/
/**
* HTTP_LIB_SOURCE
* implements a LIB_SOURCE to access a remote document root repository using http protocol.
*/
class HTTP_LIB_SOURCE : public LIB_SOURCE
{
friend class LIB_TABLE; ///< constructor the LIB uses these functions.
protected:
/**
* Constructor ( const STRING& aHttpURL )
* sets up a LIB_SOURCE using aHttpURI which points to a subversion
* repository.
* @see LIB_TABLE::LookupPart()
*
* @param aHttpURL is a full URL of a document root repo directory. Example might
* be "http://kicad.org/libs"
*
* @param aOptions is the options string from the library table. It can be any
* string that the LIB_SOURCE can parse and understand, perhaps using comma separation
* between options. Options and their syntax is LIB_SOURCE implementation specific.
*/
HTTP_LIB_SOURCE( const STRING& aHttpURL, const STRING& aOptions ) throws( IO_ERROR );
};
/**
* SVN_LIB_SOURCE
* implements a LIB_SOURCE to access a [remote or local] subversion repository
* using subversion client protocol.
*/
class SVN_LIB_SOURCE : public LIB_SOURCE
{
friend class LIB_TABLE; ///< constructor the LIB uses these functions.
protected:
/**
* Constructor SVN_LIB_SOURCE( const STRING& aSvnURL )
* sets up a LIB_SOURCE using aSvnURI which points to a subversion
* repository.
* @see LIB_TABLE::LookupPart().
*
* @param aSvnURL is a full URL of a subversion repo directory. Example might
* be "svn://kicad.org/repos/library/trunk"
*
* @param aOptions is the options string from the library table. It can be any
* string that the LIB_SOURCE can parse and understand, perhaps using comma separation
* between options. Options and their syntax is LIB_SOURCE implementation specific.
*/
SVN_LIB_SOURCE( const STRING& aSvnURL, const STRING& aOptions ) throws( IO_ERROR );
};
/**
* SCHEMATIC_LIB_SOURCE
* implements a LIB_SOURCE in by reading a parts list from schematic file
* unrelated to the schematic currently being edited.
*/
class SCHEMATIC_LIB_SOURCE : public LIB_SOURCE
{
friend class LIB_TABLE; ///< constructor the LIB uses these functions.
protected:
/**
* Constructor SCHEMATIC_LIB_SOURCE( const STRING& aSchematicFile )
* sets up a LIB_SOURCE using aSchematicFile which is a full path and filename
* for a schematic not related to the schematic being editing in
* this EESCHEMA session.
* @see LIB_TABLE::LookupPart().
*
* @param aSchematicFile is a full path and filename. Example:
* "/home/user/kicadproject/design.sch"
*
* @param aOptions is the options string from the library table. It can be any
* string that the LIB_SOURCE can parse and understand, perhaps using comma separation
* between options. Options and their syntax is LIB_SOURCE implementation specific.
*/
SCHEMATIC_LIB_SOURCE( const STRING& aSchematicFile, const STRING& aOptions ) throws( IO_ERROR );
};
/**
* PARTS_LIST
* is a LIB which resides in a SCHEMATIC, and it is a table model for a
* spread sheet both. When columns are added or removed to/from the spreadsheet,
* this is adding or removing fields/properties to/from ALL the contained PARTS.
*/
class PARTS_LIST : public LIB
{
public:
/**
* Function GetModel
* returns a spreadsheet table model that allows both reading and writing to
* rows in a spreadsheet. The UI holds the actual screen widgets, but
* this is the table model, i.e. the PARTS_LIST is.
*/
SPREADSHEET_TABLE_MODEL* GetModel();
};
} // namespace SCH
/// @todo remove endsWithRev() in favor of EndsWithRev(), find home for it.
/// @todo add simple unit test infrastructure.
/// @todo review: http://www.sfml-dev.org/tutorials/1.2/graphics-wxwidgets.php
// EOF

This file was deleted.

Before

(image error) Size: 62 KiB

View File

@ -1,964 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="1012.09"
height="754.09998"
id="svg2"
version="1.1"
inkscape:version="0.47 r22583"
sodipodi:docname="drawing.svg"
inkscape:export-filename="/svn/kicad/new_design/new/drawing.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<defs
id="defs4">
<marker
inkscape:stockid="Arrow2Lend"
orient="auto"
refY="0.0"
refX="0.0"
id="Arrow2Lend"
style="overflow:visible;">
<path
id="path3674"
style="font-size:12.0;fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round;"
d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
transform="scale(1.1) rotate(180) translate(1,0)" />
</marker>
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 526.18109 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="744.09448 : 526.18109 : 1"
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
id="perspective10" />
<inkscape:perspective
id="perspective2852"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective2885"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective2932"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective2965"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective4115"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<marker
inkscape:stockid="Arrow2Lend"
orient="auto"
refY="0"
refX="0"
id="Arrow2Lend-9"
style="overflow:visible">
<path
id="path3674-3"
style="font-size:12px;fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="matrix(-1.1,0,0,-1.1,-1.1,0)" />
</marker>
<inkscape:perspective
id="perspective4352"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective4990"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.4"
inkscape:cx="575.26689"
inkscape:cy="1269.5904"
inkscape:document-units="px"
inkscape:current-layer="svg2"
showgrid="false"
inkscape:window-width="1920"
inkscape:window-height="1119"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
units="in"
inkscape:snap-global="false"
objecttolerance="10000"
inkscape:snap-midpoints="true"
inkscape:snap-bbox="false">
<inkscape:grid
type="xygrid"
id="grid2955"
empspacing="10"
visible="true"
enabled="true"
snapvisiblegridlinesonly="true"
spacingx="10px"
spacingy="10px"
dotted="true" />
</sodipodi:namedview>
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<rect
style="fill:#cccccc;fill-opacity:1;stroke:#000000;stroke-width:1.10099995;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect3942"
width="168.57143"
height="41.42857"
x="556.42859"
y="688.38568" />
<rect
style="fill:#00bad5;fill-opacity:0.9605735;stroke:#000000;stroke-width:0.95887607;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect4976"
width="234.49751"
height="98.013084"
x="755.58539"
y="508.26596" />
<rect
style="fill:#cccccc;fill-opacity:1;stroke:#000000;stroke-width:1.29770339;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect5805"
width="188.37473"
height="93.374725"
x="793.24127"
y="650.91266" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-298.25658)" />
<rect
style="fill:#cccccc;fill-rule:evenodd;stroke:#000000;stroke-width:1.6983366px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
id="rect2816"
width="872.59253"
height="273.89703"
x="95.277359"
y="22.688547"
sodipodi:insensitive="true" />
<text
xml:space="preserve"
style="font-size:44.65415192px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
x="329.44296"
y="69.284828"
id="text2818"
transform="scale(1.086331,0.92052975)"
sodipodi:insensitive="true"><tspan
sodipodi:role="line"
x="329.44296"
y="69.284828"
id="tspan2828">schematic</tspan></text>
<rect
style="fill:#00bad5;fill-rule:evenodd;stroke:#000000;stroke-width:1.41801190000000021px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:0.96057349"
id="rect2826"
width="452.43915"
height="129.58199"
x="90.923286"
y="508.6037" />
<text
xml:space="preserve"
style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="175.85715"
y="657.25031"
id="text2828"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan2830"
x="175.85715"
y="657.25031">HTTP_LIB_SOURCE</tspan></text>
<g
id="g3856">
<g
transform="translate(18,0)"
id="g3851">
<rect
style="fill:#ff8080;stroke:#000000;stroke-width:0.76680511;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect2833"
width="67.913422"
height="40.639297"
x="130.19307"
y="73.140556" />
<text
xml:space="preserve"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="138.37057"
y="97.500824"
id="text2835"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
x="138.37057"
y="97.500824"
id="tspan2839">comp</tspan></text>
</g>
</g>
<g
inkscape:groupmode="layer"
id="layer2"
inkscape:label="big blocks" />
<g
id="g3790"
transform="translate(60,-0.71428569)"
sodipodi:insensitive="true">
<rect
y="204.09998"
x="77.85714"
height="75"
width="801.42859"
id="rect2988"
style="fill:#f4d7d7;stroke:#000000;stroke-width:1;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<text
sodipodi:linespacing="125%"
id="text3786"
y="221.24283"
x="440"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="221.24283"
x="440"
id="tspan3788"
sodipodi:role="line">parts_list</tspan></text>
</g>
<g
id="g3822">
<g
transform="translate(-12.857147,6.4285736)"
id="g3801">
<rect
style="fill:#999999;stroke:#000000;stroke-width:0.78319448;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect3795"
width="56.64537"
height="39.502518"
x="164.8916"
y="222.563" />
<text
xml:space="preserve"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="172.85715"
y="247.6714"
id="text3797"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3799"
x="172.85715"
y="247.6714">part</tspan></text>
</g>
</g>
<g
id="g3828"
transform="translate(133.32018,-0.3941193)">
<g
id="g3830"
transform="translate(-12.857147,6.4285736)">
<rect
y="222.563"
x="164.8916"
height="39.502518"
width="56.64537"
id="rect3832"
style="fill:#999999;stroke:#000000;stroke-width:0.78319448;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<text
sodipodi:linespacing="125%"
id="text3834"
y="247.6714"
x="172.85715"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="247.6714"
x="172.85715"
id="tspan3836"
sodipodi:role="line">part</tspan></text>
</g>
</g>
<g
transform="translate(259.32018,-0.3941193)"
id="g3838">
<g
transform="translate(-12.857147,6.4285736)"
id="g3840">
<rect
style="fill:#999999;stroke:#000000;stroke-width:0.78319448;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect3842"
width="56.64537"
height="39.502518"
x="164.8916"
y="222.563" />
<text
xml:space="preserve"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="172.85715"
y="247.6714"
id="text3844"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3846"
x="172.85715"
y="247.6714">part</tspan></text>
</g>
</g>
<g
id="g3862"
transform="translate(130,0)">
<g
id="g3864"
transform="translate(18,0)">
<rect
y="73.140556"
x="130.19307"
height="40.639297"
width="67.913422"
id="rect3866"
style="fill:#ff8080;stroke:#000000;stroke-width:0.76680511;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<text
sodipodi:linespacing="125%"
id="text3868"
y="97.500824"
x="138.37057"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
xml:space="preserve"><tspan
id="tspan3870"
y="97.500824"
x="138.37057"
sodipodi:role="line">comp</tspan></text>
</g>
</g>
<g
transform="translate(256,0)"
id="g3872">
<g
transform="translate(18,0)"
id="g3874">
<rect
style="fill:#ff8080;stroke:#000000;stroke-width:0.76680511;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect3876"
width="67.913422"
height="40.639297"
x="130.19307"
y="73.140556" />
<text
xml:space="preserve"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="138.37057"
y="97.500824"
id="text3878"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
x="138.37057"
y="97.500824"
id="tspan3880">comp</tspan></text>
</g>
</g>
<g
id="g3882"
transform="translate(471.32018,-0.3941193)">
<g
id="g3884"
transform="translate(-12.857147,6.4285736)">
<rect
y="222.563"
x="164.8916"
height="39.502518"
width="56.64537"
id="rect3886"
style="fill:#999999;stroke:#000000;stroke-width:0.78319448;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<text
sodipodi:linespacing="125%"
id="text3888"
y="247.6714"
x="172.85715"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="247.6714"
x="172.85715"
id="tspan3890"
sodipodi:role="line">part</tspan></text>
</g>
</g>
<rect
style="fill:#cccccc;fill-opacity:1;stroke:#000000;stroke-width:1.11650062;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect3894"
width="473.64505"
height="82.716003"
x="493.0127"
y="368.03632" />
<text
xml:space="preserve"
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="684.51794"
y="389.21155"
id="text3896"
sodipodi:linespacing="100%"><tspan
sodipodi:role="line"
id="tspan3898"
x="684.51794"
y="389.21155">LIBS manager</tspan></text>
<g
id="g4102">
<path
id="path2876"
d="M 179.80715,116.16834 180,226.09998"
style="fill:none;stroke:#000000;stroke-width:0.69999999;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker-end:url(#Arrow2Lend)" />
<text
sodipodi:linespacing="125%"
id="text4098"
y="157.6049"
x="181.70563"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="157.6049"
x="181.70563"
id="tspan4100"
sodipodi:role="line">is</tspan></text>
</g>
<g
transform="translate(134,-4e-6)"
id="g4102-9">
<path
id="path2876-0"
d="M 179.80715,116.16834 180,226.09998"
style="fill:none;stroke:#000000;stroke-width:0.69999999;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker-end:url(#Arrow2Lend)" />
<text
sodipodi:linespacing="125%"
id="text4098-8"
y="157.6049"
x="181.70563"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="157.6049"
x="181.70563"
id="tspan4100-8"
sodipodi:role="line">is</tspan></text>
</g>
<g
id="g4144"
transform="translate(260,-4e-6)">
<path
style="fill:none;stroke:#000000;stroke-width:0.69999999;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker-end:url(#Arrow2Lend)"
d="M 179.80715,116.16834 180,226.09998"
id="path4146" />
<text
xml:space="preserve"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="181.70563"
y="157.6049"
id="text4148"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan4150"
x="181.70563"
y="157.6049">is</tspan></text>
</g>
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend-9)"
d="m 439.67732,268.09998 0.32268,46 210,0 0,-40"
id="path4152" />
<text
xml:space="preserve"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="520.22858"
y="330.28006"
id="text4340"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan4342"
x="520.22858"
y="330.28006">extends</tspan></text>
<g
id="g3828-4"
transform="translate(133.32018,329.60589)">
<g
id="g3830-8"
transform="translate(-12.857147,6.4285736)">
<rect
y="222.563"
x="164.8916"
height="39.502518"
width="56.64537"
id="rect3832-1"
style="fill:#999999;stroke:#000000;stroke-width:0.78319448;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<text
sodipodi:linespacing="125%"
id="text3834-0"
y="247.6714"
x="172.85715"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="247.6714"
x="172.85715"
id="tspan3836-3"
sodipodi:role="line">part</tspan></text>
</g>
</g>
<g
transform="translate(-2.67982,329.60589)"
id="g4378">
<g
transform="translate(-12.857147,6.4285736)"
id="g4380">
<rect
style="fill:#999999;stroke:#000000;stroke-width:0.78319448;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect4382"
width="56.64537"
height="39.502518"
x="164.8916"
y="222.563" />
<text
xml:space="preserve"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="172.85715"
y="247.6714"
id="text4384"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan4386"
x="172.85715"
y="247.6714">part</tspan></text>
</g>
</g>
<g
transform="translate(267.32018,329.60589)"
id="g4388">
<g
transform="translate(-12.857147,6.4285736)"
id="g4390">
<rect
style="fill:#999999;stroke:#000000;stroke-width:0.78319448;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect4392"
width="56.64537"
height="39.502518"
x="164.8916"
y="222.563" />
<text
xml:space="preserve"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="172.85715"
y="247.6714"
id="text4394"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan4396"
x="172.85715"
y="247.6714">part</tspan></text>
</g>
</g>
<path
style="fill:none;stroke:#000000;stroke-width:1.101;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#Arrow2Lend-9)"
d="M 180.35714,268.49409 180,554.09998"
id="path4398" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend-9)"
d="m 313.67732,268.09998 0,290.49749"
id="path4400" />
<text
sodipodi:linespacing="125%"
id="text4774"
y="354.28006"
x="184.22858"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="354.28006"
x="184.22858"
id="tspan4776"
sodipodi:role="line">extends</tspan></text>
<text
xml:space="preserve"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="316.22858"
y="354.28006"
id="text4778"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan4780"
x="316.22858"
y="354.28006">extends</tspan></text>
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend-9)"
d="m 313.9049,598.53648 0,48.73986 137.63329,0.25254 0.25254,-48.73986"
id="path4782" />
<text
sodipodi:linespacing="125%"
id="text4970"
y="664.28003"
x="348.22858"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="664.28003"
x="348.22858"
id="tspan4972"
sodipodi:role="line">extends</tspan></text>
<rect
style="fill:#00bad5;fill-opacity:0.9605735;stroke:#000000;stroke-width:1.10099995;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect4974"
width="145.46196"
height="128.28937"
x="564.67529"
y="508.6329" />
<text
sodipodi:linespacing="125%"
id="text4978"
y="661.25031"
x="581.85718"
style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="661.25031"
x="581.85718"
id="tspan4980"
sodipodi:role="line">DIR_LIB_SOURCE</tspan></text>
<text
sodipodi:linespacing="125%"
id="text4978-6"
y="631.6189"
x="792.89563"
style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="631.6189"
x="792.89563"
id="tspan4980-2"
sodipodi:role="line">SCHEMATIC_LIB_SOURCE</tspan></text>
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend-9)"
d="m 512.14734,451.05421 -0.50507,55.05331"
id="path5007" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend-9)"
d="m 637.91133,451.55929 -0.50507,55.05331"
id="path5009" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend-9)"
d="m 849.03322,450.54913 0,55.55839"
id="path5011" />
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend-9)"
d="m 740,298.38569 0,67.14286"
id="path5571" />
<g
id="g5759"
transform="translate(457.32018,329.60589)">
<g
id="g5761"
transform="translate(-12.857147,6.4285736)">
<rect
y="222.563"
x="164.8916"
height="39.502518"
width="56.64537"
id="rect5763"
style="fill:#999999;stroke:#000000;stroke-width:0.78319448;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<text
sodipodi:linespacing="125%"
id="text5765"
y="247.6714"
x="172.85715"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="247.6714"
x="172.85715"
id="tspan5767"
sodipodi:role="line">part</tspan></text>
</g>
</g>
<g
transform="translate(447.32018,339.60589)"
id="g5779">
<g
transform="translate(-12.857147,6.4285736)"
id="g5781">
<rect
style="fill:#999999;stroke:#000000;stroke-width:0.78319448;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect5783"
width="56.64537"
height="39.502518"
x="164.8916"
y="222.563" />
<text
xml:space="preserve"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="172.85715"
y="247.6714"
id="text5785"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan5787"
x="172.85715"
y="247.6714">part</tspan></text>
</g>
</g>
<text
xml:space="preserve"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="567.28571"
y="139.38568"
id="text5799"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan5801"
x="567.28571"
y="139.38568">All sheets are in one schematic object</tspan></text>
<rect
style="fill:#f4d7d7;fill-opacity:1;stroke:#000000;stroke-width:1.10099995;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect5803"
width="123.57143"
height="63.57143"
x="814.57141"
y="673.95709" />
<g
transform="translate(703.32018,451.60589)"
id="g5769">
<g
transform="translate(-12.857147,6.4285736)"
id="g5771">
<rect
style="fill:#999999;stroke:#000000;stroke-width:0.78319448;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect5773"
width="56.64537"
height="39.502518"
x="164.8916"
y="222.563" />
<text
xml:space="preserve"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="172.85715"
y="247.6714"
id="text5775"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan5777"
x="172.85715"
y="247.6714">part</tspan></text>
</g>
</g>
<g
id="g5789"
transform="translate(693.32018,461.60589)">
<g
id="g5791"
transform="translate(-12.857147,6.4285736)">
<rect
y="222.563"
x="164.8916"
height="39.502518"
width="56.64537"
id="rect5793"
style="fill:#999999;stroke:#000000;stroke-width:0.78319448;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<text
sodipodi:linespacing="125%"
id="text5795"
y="247.6714"
x="172.85715"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="247.6714"
x="172.85715"
id="tspan5797"
sodipodi:role="line">part</tspan></text>
</g>
</g>
<text
xml:space="preserve"
style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="826.71429"
y="663.95709"
id="text5807"
sodipodi:linespacing="100%"><tspan
sodipodi:role="line"
id="tspan5809"
x="826.71429"
y="663.95709">other schematic</tspan></text>
<rect
style="fill:#cccccc;fill-opacity:1;stroke:#000000;stroke-width:1.10099995;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect5811"
width="154.28572"
height="57.142857"
x="167.85715"
y="676.24286" />
<text
xml:space="preserve"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="202.85715"
y="711.24286"
id="text5813"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan5815"
x="202.85715"
y="711.24286">Internet</tspan></text>
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend-9)"
d="m 245,638.38569 -0.71428,37.14286"
id="path5817" />
<text
xml:space="preserve"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="495.57144"
y="527.95709"
id="text2962"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan2964"
x="495.57144"
y="527.95709">LIB</tspan></text>
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend-9)"
d="m 638.57143,638.38569 -0.71429,47.14286"
id="path2966" />
<text
xml:space="preserve"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="566"
y="712.95709"
id="text3938"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3940"
x="566"
y="712.95709">part files in a dir</tspan></text>
<text
sodipodi:linespacing="125%"
id="text3944"
y="527.95709"
x="669.57141"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="527.95709"
x="669.57141"
id="tspan3946"
sodipodi:role="line">LIB</tspan></text>
<flowRoot
xml:space="preserve"
id="flowRoot3948"
style="fill:black;stroke:none;stroke-opacity:1;stroke-width:1px;stroke-linejoin:miter;stroke-linecap:butt;fill-opacity:1;font-family:Bitstream Vera Sans;font-style:normal;font-weight:normal;font-size:18px;-inkscape-font-specification:Bitstream Vera Sans;font-stretch:normal;font-variant:normal;text-anchor:start;text-align:start;writing-mode:lr;line-height:125%"><flowRegion
id="flowRegion3950"><rect
id="rect3952"
width="240.71428"
height="148.57143"
x="740"
y="508.38568" /></flowRegion><flowPara
id="flowPara3954" /></flowRoot> <text
xml:space="preserve"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="953.57141"
y="527.95709"
id="text3956"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3958"
x="953.57141"
y="527.95709">LIB</tspan></text>
<g
transform="translate(695.32018,305.60589)"
id="g3960">
<g
transform="translate(-12.857147,6.4285736)"
id="g3962">
<rect
style="fill:#999999;stroke:#000000;stroke-width:0.78319448;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect3964"
width="56.64537"
height="39.502518"
x="164.8916"
y="222.563" />
<text
xml:space="preserve"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="172.85715"
y="247.6714"
id="text3966"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3968"
x="172.85715"
y="247.6714">part</tspan></text>
</g>
</g>
<g
id="g3970"
transform="translate(685.32018,315.60589)">
<g
id="g3972"
transform="translate(-12.857147,6.4285736)">
<rect
y="222.563"
x="164.8916"
height="39.502518"
width="56.64537"
id="rect3974"
style="fill:#999999;stroke:#000000;stroke-width:0.78319448;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<text
sodipodi:linespacing="125%"
id="text3976"
y="247.6714"
x="172.85715"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
xml:space="preserve"><tspan
y="247.6714"
x="172.85715"
id="tspan3978"
sodipodi:role="line">part</tspan></text>
</g>
</g>
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend-9)"
d="m 877.85714,607.6714 0,41.42858"
id="path3980" />
<text
xml:space="preserve"
style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans"
x="840.89563"
y="219.6189"
id="text4168"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan4170"
x="840.89563"
y="219.6189">LIB</tspan></text>
<path
style="fill:none;stroke:#000000;stroke-width:1.26530874px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-end:url(#Arrow2Lend-9)"
d="M 851.17116,365.3959 850.285,225.65964"
id="path4172" />
</svg>

Before

(image error) Size: 39 KiB

View File

@ -1,150 +0,0 @@
#!/bin/sh
BASEDIR=/tmp/eeschema-lib
CATEGORIES="lions tigers kitties"
PARTS="eyes ears feet"
REVS="rev1 rev5 rev10"
REFERENCE="
(reference U?
(effects (at 12 13 180)(font (size 7 10))(visible yes))
)"
LINE="
(line
(pts (xy 12 13)(xy 12 20))(stroke 1.5)
)"
RECT="
(rectangle
(start 4 5)(end 6 8)(stroke 2.3)(fill transparent)
)"
CIRCLE="
(circle
(center 1 0)(radius 5)(stroke 2.1)(fill none)
)"
ARC="
(arc
(pos 22 33)(radius 12)(start 2 4)(end 13 33)(stroke 2.3)(fill filled)
)"
BEZIER="
(bezier
(fill none)(stroke 2.0)(pts (xy 0 1)(xy 2 4))
)"
TEXT="
(text (at 23 23 90.0) \"This is some text\" (justify left bottom)(visible yes)(fill filled)
(font arial (size 8 12))
)"
PIN1="
(pin out line (at 7 8 90)
(signal #WE (font (size 8 10) bold)(visible no))
(pad A23 (font (size 9 11) italic bold))
)"
PIN2="
(pin in line (at 8 8)(visible yes)
(signal #WAIT (visible yes))
(pad A24 (visible yes))
)"
PIN3="
(pin (pad A25))"
PINS="
(pin (pad Z12))(pin (pad Y14))(pin (pad Z13))(pin (pad Y15))"
PIN_SWAP="
(pin_swap A23 A24)"
PIN_RENUM="
(pin_renum A24 B24)"
PIN_RENAME="
(pin_rename B24 LED)"
PIN_DELETE="
(pin_del B24)"
PIN_MERGE="(pin_merge A23 (pads Z12 Y14))(pin_merge A25 (pads Z13 Y15))"
PROP1="
(property mWatts 12
(effects (at 1 34 270)(font (size 5 9) italic bold)(visible no))
)"
KEYWORDS="
(keywords varistor batcave einstein)"
ALTERNATES="
(alternates 7400/7400_b 7400/7400_c)"
for C in ${CATEGORIES}; do
mkdir -p $BASEDIR/$C
for P in ${PARTS}; do
for R in ${REVS}; do
echo "(part $C/$P (value 22)(footprint SM0805)(model Airplane)(datasheet http://favorite.pdf)
$REFERENCE
$LINE
$RECT
$CIRCLE
$ARC
$BEZIER
$TEXT
$PIN1
$PIN2
$PIN3
$PINS
$PROP1
$KEYWORDS
$ALTERNATES
$PIN_SWAP
$PIN_RENUM
$PIN_RENAME
$PIN_DELETE
$PIN_MERGE
)" > $BASEDIR/$C/$P.part.$R
done
# also make the part without a rev:
echo "(part $C/$P (value 22)(footprint SM0805)(model Airplane)(datasheet http://favorite.pdf)
$REFERENCE
$LINE
$RECT
$CIRCLE
$ARC
$BEZIER
$TEXT
$PIN1
$PIN2
$PIN3
$PINS
$PROP1
$KEYWORDS
$ALTERNATES
$PIN_SWAP
$PIN_RENUM
$PIN_RENAME
$PIN_DELETE
$PIN_MERGE
)" > $BASEDIR/$C/$P.part
done
done

View File

@ -1,3 +0,0 @@
# run this from the <kicad>/new directory
doxygen

View File

@ -1,148 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2011 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2011 KiCad Developers, see change_log.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 <sch_canvas.h>
#include <sch_part.h>
#include <gal/font/newstroke_font.h>
#define SWEET_UNIT 50 ///< world units comprizing a sweet grid cell
namespace SCH {
CANVAS::CANVAS( wxWindow* aParent ) :
OPENGL_GAL( aParent, NULL, this ) // I am my own PaintListener
{
Connect( EVT_GAL_REDRAW, wxCommandEventHandler( CANVAS::onRedraw ) );
// Set the world unit length
SetWorldUnitLength( 0.01 );
SetScreenDPI( 100 );
ComputeWorldScreenMatrix();
// Set the world unit length
// SetLookAtPoint( VECTOR2D( size.x / 2, size.y / 2 ) );
// Load Font
if( !m_font.LoadNewStrokeFont( newstroke_font, newstroke_font_bufsize ) )
{
printf( "Loading of the font failed.\n" );
}
m_font.SetGraphicsAbstractionLayer( this );
}
void CANVAS::onRedraw( wxCommandEvent& event )
{
PaintScene();
}
void CANVAS::PaintScene()
{
BeginDrawing();
SetBackgroundColor( COLOR4D( 0x6c/255.0, 0x53/255.0, 0x53/255.0, 1.0 ) );
ClearScreen();
SetLayerDepth( -10 );
SetGridSize( VECTOR2D( SWEET_UNIT, SWEET_UNIT ) );
DrawGrid();
PaintRectangle();
SetLayerDepth( 0 );
Flush();
EndDrawing();
}
void CANVAS::PaintRectangle()
{
VECTOR2D worldSize = GetSize();
#if 1
SetLineWidth( 1 );
SetIsFill( true );
SetIsStroke( true );
SetFillColor( COLOR4D( 1, 1, 1, 1 ) );
SetStrokeColor( COLOR4D( 0, 0, 0, 1 ) );
DrawRectangle( VECTOR2D( worldSize.x/4, worldSize.y/4 ), VECTOR2D( 3*worldSize.x/4, 3*worldSize.y/4 ) );
#else
D( cout << worldSize << endl; )
int k = 0;
double alpha = 0;
for( double y = 0; y < worldSize.y - worldSize.y / 4; y += worldSize.y / 8 )
{
double index = 1;
double y2 = y;
for( double x = 0; x < worldSize.x - worldSize.x / 4; x += worldSize.x / 8 )
{
SetLineWidth( index + 1 );
SetIsFill( ( k == 1 ) || ( k == 2 ) );
SetIsStroke( ( k == 0 ) || ( k == 2 ) );
SetFillColor( COLOR4D( 1 - alpha, 1, 1, 1 - alpha ) );
SetStrokeColor( COLOR4D( alpha, alpha, 1 - alpha, alpha ) );
DrawRectangle( VECTOR2D( x, y2 ), VECTOR2D( x + index * 10, y2 + index * 10 ) );
x += index * 5;
y2 += index * 5;
index += 1;
}
k = ( k + 1 ) % 3;
alpha += 0.1;
}
#endif
}
} // namespace SCH

View File

@ -1,69 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2011 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2011 KiCad Developers, see change_log.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 SCH_CANVAS_H_
#define SCH_CANVAS_H_
#include <gal/opengl/opengl_gal.h>
#include <gal/common/stroke_font.h>
namespace SCH {
class PART;
class CANVAS : public OPENGL_GAL
{
protected:
PART* m_part; ///< which PART to draw
STROKE_FONT m_font;
void onRedraw( wxCommandEvent& event );
public:
CANVAS( wxWindow* aParent );
/**
* Function SetPart
* sets the PART to draw, returns the previous PART.
*/
PART* SetPart( PART* aPart )
{
PART* ret = m_part;
m_part = aPart;
return ret;
}
void PaintScene();
void PaintRectangle();
};
} // namespace SCH
#endif // SCH_PART_H_

View File

@ -1,728 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2010 SoftPLC Corporation, <dick@softplc.com>
* Copyright (C) 2010 KiCad Developers, see change_log.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
*/
/* Note: this LIB_SOURCE implementation relies on the posix specified opendir() and
related functions rather than wx functions which might do the same thing. This
is because I did not want to become very dependent on wxWidgets at such a low
level as this, in case someday this code needs to be used on kde or whatever.
Mingw and unix, linux, & osx will all have these posix functions.
MS Visual Studio may need the posix compatible opendir() functions brought in
http://www.softagalleria.net/dirent.php
wx has these but they are based on wxString which can be wchar_t based and wx should
not be introduced at a level this low.
Part files: have the general form partname.part[.revN...]
Categories: are any subdirectories immediately below the sourceURI, one level only.
Part names: [category/]partname[/revN...]
*/
#include <dirent.h>
#include <sys/stat.h>
#include <cstring>
#include <cstdio>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <assert.h>
#include <sch_dir_lib_source.h>
using namespace SCH;
/**
* DIR_WRAP
* provides a destructor which is invoked if an exception is thrown.
*/
class DIR_WRAP
{
DIR* dir;
public:
DIR_WRAP( DIR* aDir ) : dir( aDir ) {}
~DIR_WRAP()
{
if( dir )
closedir( dir );
}
DIR* operator->() { return dir; }
DIR* operator*() { return dir; }
operator bool () { return dir!=0; }
};
/**
* FILE_WRAP
* provides a destructor which is invoked if an exception is thrown.
*/
class FILE_WRAP
{
int fh;
public:
FILE_WRAP( int aFileHandle ) : fh( aFileHandle ) {}
~FILE_WRAP()
{
if( fh != -1 )
close( fh );
}
operator int () { return fh; }
};
/**
* Function strrstr
* finds the last instance of needle in haystack, if any.
*/
static const char* strrstr( const char* haystack, const char* needle )
{
const char* ret = 0;
const char* next = haystack;
// find last instance of haystack
while( (next = strstr( next, needle )) != 0 )
{
ret = next;
++next; // don't keep finding the same one.
}
return ret;
}
#if 1 // @todo switch over to EndsWithRev() global
static inline bool isDigit( char c )
{
return c >= '0' && c <= '9';
}
/**
* Function endsWithRev
* returns a pointer to the final string segment: "revN[N..]" or NULL if none.
* @param start is the beginning of string segment to test, the partname or
* any middle portion of it.
* @param tail is a pointer to the terminating nul, or one past inclusive end of
* segment, i.e. the string segment of interest is [start,tail)
* @param separator is the separating byte, expected: '.' or '/', depending on context.
*/
static const char* endsWithRev( const char* start, const char* tail, char separator = '/' )
{
bool sawDigit = false;
while( tail > start && isDigit( *--tail ) )
{
sawDigit = true;
}
// if sawDigit, tail points to the 'v' here.
if( sawDigit && tail-3 >= start )
{
tail -= 3;
if( tail[0]==separator && tail[1]=='r' && tail[2]=='e' && tail[3]=='v' )
{
return tail+1; // omit separator, return "revN[N..]"
}
}
return 0;
}
static inline const char* endsWithRev( const STRING& aPartName, char separator = '/' )
{
return endsWithRev( aPartName.c_str(), aPartName.c_str()+aPartName.size(), separator );
}
#endif
// see struct BY_REV
bool BY_REV::operator() ( const STRING& s1, const STRING& s2 ) const
{
// avoid instantiating new STRINGs, and thank goodness that c_str() is const.
const char* rev1 = endsWithRev( s1 );
const char* rev2 = endsWithRev( s2 );
int rootLen1 = rev1 ? rev1 - s1.c_str() : s1.size();
int rootLen2 = rev2 ? rev2 - s2.c_str() : s2.size();
int r = memcmp( s1.c_str(), s2.c_str(), min( rootLen1, rootLen2 ) );
if( r )
{
return r < 0;
}
if( rootLen1 != rootLen2 )
{
return rootLen1 < rootLen2;
}
// root strings match at this point, compare the revision number numerically,
// and chose the higher numbered version as "less", according to std::set lingo.
if( bool(rev1) != bool(rev2) )
{
return bool(rev1) < bool(rev2);
}
if( rev1 && rev2 )
{
int rnum1 = atoi( rev1+3 );
int rnum2 = atoi( rev2+3 );
// higher numbered revs are "less" so that they bubble to top.
return rnum1 > rnum2;
}
return false; // strings are equal, and they don't have a rev
}
bool DIR_LIB_SOURCE::makePartName( STRING* aPartName, const char* aEntry,
const STRING& aCategory )
{
const char* cp = strrstr( aEntry, SWEET_EXT );
// if base name is not empty, contains SWEET_EXT, && cp is not NULL
if( cp > aEntry )
{
const char* limit = cp + strlen( cp );
// If versioning, then must find a trailing "revN.." type of string.
if( useVersioning )
{
const char* rev = endsWithRev( cp + SWEET_EXTZ, limit, '.' );
if( rev )
{
if( aCategory.size() )
*aPartName = aCategory + "/";
else
aPartName->clear();
aPartName->append( aEntry, cp - aEntry );
aPartName->append( "/" );
aPartName->append( rev );
return true;
}
}
// If using versioning, then all valid partnames must have a rev string,
// so we don't even bother to try and load any other partfile down here.
else
{
// if file extension is exactly SWEET_EXT, and no rev
if( cp==limit-5 )
{
if( aCategory.size() )
*aPartName = aCategory + "/";
else
aPartName->clear();
aPartName->append( aEntry, cp - aEntry );
return true;
}
}
}
return false;
}
STRING DIR_LIB_SOURCE::makeFileName( const STRING& aPartName )
{
// create a fileName for the sweet string, using a reversible
// partname <-> fileName conversion protocol:
STRING fileName = sourceURI + "/";
const char* rev = endsWithRev( aPartName );
if( rev )
{
int basePartLen = rev - aPartName.c_str() - 1; // omit '/' separator
fileName.append( aPartName, 0, basePartLen );
fileName += SWEET_EXT;
fileName += '.';
fileName += rev;
}
else
{
fileName += aPartName;
fileName += SWEET_EXT;
}
return fileName;
}
void DIR_LIB_SOURCE::readString( STRING* aResult, const STRING& aFileName )
{
FILE_WRAP fw = open( aFileName.c_str(), O_RDONLY );
if( fw == -1 )
{
STRING msg = strerror( errno );
msg += "; cannot open(O_RDONLY) file " + aFileName;
THROW_IO_ERROR( msg );
}
struct stat fs;
fstat( fw, &fs );
// sanity check on file size
if( fs.st_size > (1*1024*1024) )
{
STRING msg = aFileName;
msg += " seems too big. ( > 1 mbyte )";
THROW_IO_ERROR( msg );
}
#if 0
// I read somewhere on the Internet that std::string chars are not guaranteed
// (over time) to be contiguous in future implementations of C++, so this
// strategy is here for that eventuality. We buffer through readBuffer here.
// reuse same readBuffer, which is not thread safe, but the API
// is not advertising thread safe (yet, if ever).
if( (int) fs.st_size > (int) readBuffer.size() )
readBuffer.resize( fs.st_size + 1000 );
int count = read( fw, &readBuffer[0], fs.st_size );
if( count != (int) fs.st_size )
{
STRING msg = strerror( errno );
msg += "; cannot read file " + aFileName;
THROW_IO_ERROR( msg );
}
aResult->assign( &readBuffer[0], count );
#else
// read into the string directly
aResult->resize( fs.st_size );
int count = read( fw, &(*aResult)[0], fs.st_size );
if( count != (int) fs.st_size )
{
STRING msg = strerror( errno );
msg += "; cannot read file " + aFileName;
THROW_IO_ERROR( msg );
}
// test trailing nul is there, which should have been put there with resize() above
// printf( "'%s'\n", aResult->c_str() ); // checked OK.
#endif
}
void DIR_LIB_SOURCE::cache()
{
partnames.clear();
categories.clear();
cacheOneDir( "" );
}
DIR_LIB_SOURCE::DIR_LIB_SOURCE( const STRING& aDirectoryPath,
const STRING& aOptions ) :
useVersioning( strstr( aOptions.c_str(), "useVersioning" ) )
{
sourceURI = aDirectoryPath;
sourceType = "dir";
if( sourceURI.size() == 0 )
{
THROW_IO_ERROR( STRING("aDirectoryPath cannot be empty") );
}
// remove any trailing separator, so we can add it back later without ambiguity
if( strchr( "/\\", sourceURI[sourceURI.size()-1] ) )
sourceURI.erase( sourceURI.size()-1 );
cache();
}
DIR_LIB_SOURCE::~DIR_LIB_SOURCE()
{
}
void DIR_LIB_SOURCE::GetCategoricalPartNames( STRINGS* aResults, const STRING& aCategory )
{
PN_ITER end = aCategory.size() ?
partnames.lower_bound( aCategory + char( '/' + 1 ) ) :
partnames.end();
PN_ITER it = aCategory.size() ?
partnames.upper_bound( aCategory + "/" ) :
partnames.begin();
aResults->clear();
if( useVersioning )
{
STRING partName;
while( it != end )
{
const char* rev = endsWithRev( *it );
// all cached partnames have a rev string in useVersioning mode
assert( rev );
// partName is substring which omits the rev AND the rev separator
partName.assign( *it, 0, rev - it->c_str() - 1 );
aResults->push_back( partName );
// skip over all other versions of the same partName.
it = partnames.lower_bound( partName + char( '/' + 1 ) );
}
}
else
{
while( it != end )
aResults->push_back( *it++ );
}
}
void DIR_LIB_SOURCE::GetRevisions( STRINGS* aResults, const STRING& aPartName )
{
aResults->clear();
if( useVersioning )
{
STRING partName;
const char* rev = endsWithRev( aPartName );
if( rev )
// partName is substring which omits the rev and the separator
partName.assign( aPartName, 0, rev - aPartName.c_str() - 1 );
else
partName = aPartName;
PN_ITER it = partnames.upper_bound( partName +'/' );
PN_ITER end = partnames.lower_bound( partName + char( '/' +1 ) );
for( ; it != end; ++it )
{
const char* rev = endsWithRev( *it );
assert( rev );
aResults->push_back( it->substr( rev - it->c_str() ) );
}
}
else
{
// In non-version mode, there were no revisions read in, only part
// files without a revision. But clients higher up expect to see
// at least one revision in order for the API to work, so we return
// a revision ""
aResults->push_back( "" );
}
}
void DIR_LIB_SOURCE::ReadPart( STRING* aResult, const STRING& aPartName, const STRING& aRev )
{
STRING partName = aPartName;
const char* hasRev = endsWithRev( partName );
if( useVersioning )
{
if( aRev.size() )
{
// a supplied rev replaces any in aPartName
if( hasRev )
partName.resize( hasRev - partName.c_str() - 1 );
partName += '/';
partName + aRev;
// find this exact revision
PN_ITER it = partnames.find( partName );
if( it == partnames.end() ) // part not found
{
partName += " not found.";
THROW_IO_ERROR( partName );
}
readString( aResult, makeFileName( partName ) );
}
else
{
// There's no rev on partName string. Find the most recent rev, i.e. highest,
// which will be first because of the BY_REV compare method, which treats
// higher numbered revs as first.
STRING search = partName + '/';
// There's no rev on partName string. Find the most recent rev, i.e. highest,
// which will be first because of the BY_REV compare method, which treats
// higher numbered revs as first.
PN_ITER it = partnames.upper_bound( search );
// verify that this one that is greater than partName is a match and not
// some unrelated name that is larger.
if( it == partnames.end() ||
it->compare( 0, search.size(), search ) != 0 )
{
partName += " is not present without a revision.";
THROW_IO_ERROR( partName );
}
readString( aResult, makeFileName( *it ) );
}
}
else // !useVersioning
{
#if 1
if( hasRev || aRev.size() )
{
STRING msg = "this type 'dir' LIB_SOURCE not using 'useVersioning' option, cannot ask for a revision";
THROW_IO_ERROR( msg );
}
#else
// no revisions allowed, strip it
if( hasRev )
partName.resize( hasRev - partName.c_str() - 1 );
#endif
// find the part name without any revision
PN_ITER it = partnames.find( partName );
if( it == partnames.end() ) // part not found
{
partName += " not found.";
THROW_IO_ERROR( partName );
}
readString( aResult, makeFileName( partName ) );
}
}
void DIR_LIB_SOURCE::ReadParts( STRINGS* aResults, const STRINGS& aPartNames )
{
aResults->clear();
for( STRINGS::const_iterator n = aPartNames.begin(); n!=aPartNames.end(); ++n )
{
aResults->push_back( STRING() );
ReadPart( &aResults->back(), *n );
}
}
void DIR_LIB_SOURCE::GetCategories( STRINGS* aResults )
{
aResults->clear();
// caller fetches them sorted.
for( NAME_CACHE::const_iterator it = categories.begin(); it!=categories.end(); ++it )
{
aResults->push_back( *it );
}
}
#if defined(DEBUG)
void DIR_LIB_SOURCE::Show()
{
printf( "Show categories:\n" );
for( NAME_CACHE::const_iterator it = categories.begin(); it!=categories.end(); ++it )
printf( " '%s'\n", it->c_str() );
printf( "\n" );
printf( "Show parts:\n" );
for( PART_CACHE::const_iterator it = partnames.begin(); it != partnames.end(); ++it )
{
printf( " '%s'\n", it->c_str() );
}
}
#endif
void DIR_LIB_SOURCE::cacheOneDir( const STRING& aCategory )
{
STRING curDir = sourceURI;
if( aCategory.size() )
curDir += "/" + aCategory;
DIR_WRAP dir = opendir( curDir.c_str() );
if( !dir )
{
STRING msg = strerror( errno );
msg += "; scanning directory " + curDir;
THROW_IO_ERROR( msg );
}
struct stat fs;
STRING partName;
STRING fileName;
dirent* entry;
while( (entry = readdir( *dir )) != NULL )
{
if( !strcmp( ".", entry->d_name ) || !strcmp( "..", entry->d_name ) )
continue;
fileName = curDir + "/" + entry->d_name;
if( !stat( fileName.c_str(), &fs ) )
{
// is this a valid part name?
if( S_ISREG( fs.st_mode ) && makePartName( &partName, entry->d_name, aCategory ) )
{
std::pair<NAME_CACHE::iterator, bool> pair = partnames.insert( partName );
if( !pair.second )
{
STRING msg = partName;
msg += " has already been encountered";
THROW_IO_ERROR( msg );
}
}
// is this an acceptable category name?
else if( S_ISDIR( fs.st_mode ) && !aCategory.size() && isCategoryName( entry->d_name ) )
{
// only one level of recursion is used, controlled by the
// emptiness of aCategory.
categories.insert( entry->d_name );
// somebody needs to test Windows (mingw), make sure it can
// handle opendir() recursively
cacheOneDir( entry->d_name );
}
else
{
//D( printf( "ignoring %s\n", entry->d_name );)
}
}
}
}
#if 0 && defined(DEBUG)
void DIR_LIB_SOURCE::Test( int argc, char** argv )
{
STRINGS partnames;
STRINGS sweets;
try
{
STRINGS::const_iterator pn;
// DIR_LIB_SOURCE uut( argv[1] ? argv[1] : "", "" );
DIR_LIB_SOURCE uut( argv[1] ? argv[1] : "", "useVersioning" );
// show the cached content, only the directory information is cached,
// parts are cached in class LIB, not down here.
uut.Show();
uut.GetCategoricalPartNames( &partnames, "lions" );
printf( "\nGetCategoricalPartNames( aCatagory = 'lions' ):\n" );
for( STRINGS::const_iterator it = partnames.begin(); it!=partnames.end(); ++it )
{
printf( " '%s'\n", it->c_str() );
}
uut.ReadParts( &sweets, partnames );
printf( "\nSweets for Category = 'lions' parts:\n" );
pn = partnames.begin();
for( STRINGS::const_iterator it = sweets.begin(); it!=sweets.end(); ++it, ++pn )
{
printf( " %s: %s", pn->c_str(), it->c_str() );
}
// fetch the part names for ALL categories.
uut.GetCategoricalPartNames( &partnames );
printf( "\nGetCategoricalPartNames( aCategory = '' i.e. ALL):\n" );
for( STRINGS::const_iterator it = partnames.begin(); it!=partnames.end(); ++it )
{
printf( " '%s'\n", it->c_str() );
}
uut.ReadParts( &sweets, partnames );
printf( "\nSweets for ALL parts:\n" );
pn = partnames.begin();
for( STRINGS::const_iterator it = sweets.begin(); it!=sweets.end(); ++it, ++pn )
{
printf( " %s: %s", pn->c_str(), it->c_str() );
}
}
catch( std::exception& ex )
{
printf( "std::exception\n" );
}
catch( const IO_ERROR& ioe )
{
printf( "exception: %s\n", (const char*) ioe.errorText.ToUTF8() ) );
}
}
int main( int argc, char** argv )
{
DIR_LIB_SOURCE::Test( argc, argv );
return 0;
}
#endif

View File

@ -1,198 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2010 KiCad Developers, see change_log.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 DIR_LIB_SOURCE_H_
#define DIR_LIB_SOURCE_H_
#include <set>
#include <vector>
#include <sch_lib.h>
/// This file extension is an implementation detail specific to this LIB_SOURCE
/// and to a corresponding LIB_SINK.
/// Core EESCHEMA should never have to see this.
#define SWEET_EXT ".part"
#define SWEET_EXTZ (sizeof(SWEET_EXT)-1)
/**
* struct BY_REV
* is here to provide a custom way to compare STRINGs. Namely, the revN[N..]
* string if present, is collated according to a 'higher revision first', but
* any part string without a revision, is even 'before' that.
*/
struct BY_REV
{
bool operator() ( const STRING& s1, const STRING& s2 ) const;
};
/**
* Type PART_CACHE
* holds a set of part names in sorted order, according to the sort
* order given by struct BY_REV.
*/
typedef std::set< STRING, BY_REV > PART_CACHE;
/**
* Type NAME_CACHE
* holds a set of categories in sorted order.
*/
typedef std::set< STRING > NAME_CACHE;
namespace SCH {
/**
* DIR_LIB_SOURCE
* implements a LIB_SOURCE in a file system directory.
*
* @author Dick Hollenbeck
*/
class DIR_LIB_SOURCE : public LIB_SOURCE
{
friend class LIB_TABLE; ///< constructor is protected, LIB_TABLE can construct
bool useVersioning; ///< use files with extension ".revNNN..", else not
/// normal partnames, some of which may be prefixed with a category,
/// and some of which may have legal "revN[N..]" type strings.
PART_CACHE partnames;
typedef PART_CACHE::const_iterator PN_ITER;
/// categories which we expect to find in the set of @a partnames
NAME_CACHE categories;
std::vector<char> readBuffer; ///< used by readString()
/**
* Function cache
* [re-]loads the directory cache(s).
*/
void cache();
/**
* Function isCategoryName
* returns true iff aName is a valid category name.
*/
bool isCategoryName( const char* aName )
{
return true;
}
/**
* Function makePartName
* returns true iff aEntry holds a valid part filename, in the form of
* "someroot.part[.revNNNN]" where NNN are number characters [0-9]
* @param aEntry is the raw directory entry without path information.
* @param aCategory is the last portion of the directory path.
* @param aPartName is where to put a part name, assuming @a aEntry is legal.
* @return bool - true only if aEntry is a legal part file name.
*/
bool makePartName( STRING* aPartName, const char* aEntry, const STRING& aCategory );
/**
* Function readString
* reads a Sweet string into aResult. Candidate for virtual function later.
*/
void readString( STRING* aResult, const STRING& aFileName );
/**
* Function cacheOneDir
* loads part names [and categories] from a directory given by
* "sourceURI + '/' + category"
* Categories are only loaded if processing the top most directory because
* only one level of categories is supported. We know we are in the
* top most directory if aCategory is empty.
*/
void cacheOneDir( const STRING& aCategory );
/**
* Function makeFileName
* converts a part name into a filename and returns it.
*/
STRING makeFileName( const STRING& aPartName );
protected:
/**
* Constructor DIR_LIB_SOURCE( const STRING& aDirectoryPath )
* sets up a LIB_SOURCE using aDirectoryPath in a file system.
* @see LIB_TABLE::LookupPart().
*
* @param aDirectoryPath is a full file pathname of a directory which contains
* the library source of part files. Examples might be "C:\kicad_data\mylib" or
* "/home/designer/mylibdir". This is not a URI, but an OS specific path that
* can be given to opendir().
*
* @param aOptions is the options string from the library table, currently
* the only supported option, that this LIB_SOURCE knows about is
* "useVersioning". If present means support versioning in the directory
* tree, otherwise only a single version of each part is recognized, namely the
* one without the ".revN[N..]" trailer.
*/
DIR_LIB_SOURCE( const STRING& aDirectoryPath, const STRING& aOptions = "" );
~DIR_LIB_SOURCE();
//-----<LIB_SOURCE implementation functions >------------------------------
void ReadPart( STRING* aResult, const STRING& aPartName, const STRING& aRev = "" );
void ReadParts( STRINGS* aResults, const STRINGS& aPartNames );
void GetCategories( STRINGS* aResults );
void GetCategoricalPartNames( STRINGS* aResults, const STRING& aCategory = "" );
void GetRevisions( STRINGS* aResults, const STRING& aPartName );
void FindParts( STRINGS* aResults, const STRING& aQuery )
{
// @todo
}
//-----</LIB_SOURCE implementation functions >------------------------------
#if defined(DEBUG)
/**
* Function Show
* will output a debug dump of contents.
*/
void Show();
public:
static void Test( int argc, char** argv );
#endif
};
} // namespace SCH
#endif // DIR_LIB_SOURCE_H_

View File

@ -1,278 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2010 KiCad Developers, see change_log.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 <memory> // std::auto_ptr
#include <wx/string.h>
#include <sch_lib.h>
#include <sch_lpid.h>
#include <sch_part.h>
#include <sch_sweet_parser.h>
#include <sch_lib_table.h>
#if 1
#include <map>
/*
The LIB part cache consists of a std::map of partnames without revisions at the
top level. Each top level map entry can point to another std::map which it owns
and which holds all the revisions for that part name. At any point in the tree,
there can be NULL pointers which allow for lazy loading, including the very top
most root pointer itself, which is PARTS* parts. We use the key to hold the
partName at one level, and revision at the deeper nested level.
1) Only things which are asked for are done.
2) Anything we learn we remember.
*/
namespace SCH {
/**
* Struct LTREV
* is for PART_REVS, and provides a custom way to compare rev STRINGs.
* Namely, the revN[N..] string if present, is collated according to a
* 'higher revision first'.
*/
struct LTREV
{
bool operator() ( const STRING& s1, const STRING& s2 ) const
{
return RevCmp( s1.c_str(), s2.c_str() ) < 0;
}
};
/**
* PART_REVS
* contains the collection of revisions for a particular part name, in the
* form of cached PARTs. The tuple consists of a rev string and a PART pointer.
* The rev string is like "rev1", the PART pointer will be NULL until the PART
* gets loaded, lazily.
*/
class PART_REVS : public std::map< STRING, PART*, LTREV >
{
public:
~PART_REVS()
{
for( iterator it = begin(); it != end(); ++it )
{
delete it->second; // second may be NULL, no problem
}
}
};
/**
* PARTS
* contains the collection of PART_REVS for all PARTs in the lib.
* The tuple consists of a part name and a PART_REVS pointer.
* The part name does not have the revision attached (of course this is understood
* by definition of "part name"). The PART_REVS pointer will be NULL until a client
* askes about the revisions for a part name, so the loading is done lazily.
*/
class PARTS : public std::map< STRING, PART_REVS* >
{
public:
~PARTS()
{
for( iterator it = begin(); it != end(); ++it )
{
delete it->second; // second may be NULL, no problem
}
}
};
} // namespace SCH
#else // was nothing but grief:
#include <boost/ptr_container/ptr_map.hpp>
namespace SCH {
/// PARTS' key is revision, like "rev12", PART pointer may be null until loaded.
typedef boost::ptr_map< STRING, boost::nullable<PART> > PARTS;
typedef PARTS::iterator PARTS_ITER;
typedef PARTS::const_iterator PARTS_CITER;
/// PART_REVS' key is part name, w/o rev, PART pointer may be null until loaded.
typedef boost::ptr_map< STRING, boost::nullable<PARTS> > PART_REVS;
typedef PART_REVS::iterator PART_REVS_ITER;
typedef PART_REVS::const_iterator PART_REVS_CITER;
} // namespace SCH
#endif
using namespace SCH;
LIB::LIB( const STRING& aLogicalLibrary, LIB_SOURCE* aSource, LIB_SINK* aSink ) :
logicalName( aLogicalLibrary ),
source( aSource ),
sink( aSink ),
cachedCategories( false ),
parts( 0 )
{
}
LIB::~LIB()
{
delete source;
delete sink;
delete parts;
}
const PART* LIB::lookupPart( const LPID& aLPID )
{
if( !parts )
{
parts = new PARTS;
source->GetCategoricalPartNames( &vfetch );
// insert a PART_REVS for each part name
for( STRINGS::const_iterator it = vfetch.begin(); it!=vfetch.end(); ++it )
{
D(printf("lookupPart:%s\n", it->c_str() );)
(*parts)[*it] = new PART_REVS;
}
}
// load all the revisions for this part name, only if it has any
PARTS::iterator pi = parts->find( aLPID.GetPartName() );
PART_REVS* revs = pi != parts->end() ? pi->second : NULL;
// D(printf("revs:%p partName:%s\n", revs, aLPID.GetPartName().c_str() );)
// if the key for parts has no aLPID.GetPartName() the part is not in this lib
if( revs )
{
if( revs->size() == 0 ) // assume rev list has not been loaded yet
{
// load all the revisions for this part.
source->GetRevisions( &vfetch, aLPID.GetPartName() );
// create a PART_REV entry for each revision, but leave the PART* NULL
for( STRINGS::const_iterator it = vfetch.begin(); it!=vfetch.end(); ++it )
{
D(printf("lookupPartRev:%s\n", it->c_str() );)
(*revs)[*it] = 0;
}
}
PART_REVS::iterator rev;
// If caller did not say what revision, find the highest numbered one and return that.
if( !aLPID.GetRevision().size() && revs->size() )
{
rev = revs->begin(); // sort order has highest rev first
if( !rev->second ) // the PART has never been instantiated before
{
rev->second = new PART( this, LPID::Format( "", aLPID.GetPartName(), rev->first ) );
}
D(printf("lookupPartLatestRev:%s\n", rev->second->partNameAndRev.c_str() );)
return rev->second;
}
else
{
rev = revs->find( aLPID.GetRevision() );
if( rev != revs->end() )
{
if( !rev->second ) // the PART has never been instantiated before
{
rev->second = new PART( this, aLPID.GetPartNameAndRev() );
}
return rev->second;
}
}
}
return 0; // no such part name in this lib
}
PART* LIB::LookupPart( const LPID& aLPID, LIB_TABLE* aLibTable )
{
PART* part = (PART*) lookupPart( aLPID );
if( !part ) // part does not exist in this lib
{
wxString msg = wxString::Format( _("part \"%s\" not found in lib %s" ),
wxString::FromUTF8( aLPID.GetPartNameAndRev().c_str() ).GetData(),
wxString::FromUTF8( logicalName.c_str() ).GetData() );
THROW_IO_ERROR( msg );
}
if( part->body.empty() )
{
// load body
source->ReadPart( &part->body, aLPID.GetPartName(), aLPID.GetRevision() );
#if 0 && defined(DEBUG)
const STRING& body = part->body;
printf( "body: %s", body.c_str() );
if( !body.size() || body[body.size()-1] != '\n' )
printf( "\n" );
#endif
// @todo consider changing ReadPart to return a "source"
SWEET_PARSER sp( part->body, wxString::FromUTF8( aLPID.Format().c_str() ) );
part->Parse( &sp, aLibTable );
}
return part;
}
#if 0 && defined(DEBUG)
void LIB::Test( int argc, char** argv );
{
}
int main( int argc, char** argv )
{
LIB::Test( argc, argv );
return 0;
}
#endif

View File

@ -1,357 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2010 KiCad Developers, see change_log.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 SCH_LIB_H_
#define SCH_LIB_H_
#include <utf8.h>
#include <richio.h>
#include <import_export.h>
namespace SCH {
class LPID;
class PART;
class LIB_TABLE;
/**
* LIB_SOURCE
* is an abstract class from which implementation specific LIB_SOURCEs
* may be derived, one for each kind of library type allowed in the library table.
* The class name stems from the fact that this interface only provides READ ONLY
* functions.
*
* @author Dick Hollenbeck
*/
class LIB_SOURCE
{
friend class LIB; ///< the LIB uses these functions.
protected: ///< derived classes must implement
/**
* Function GetSourceType
* returns the library table entry's type for this library source.
*/
const STRING& GetSourceType() { return sourceType; }
/**
* Function GetSourceURI
* returns absolute location of the library source.
*/
const STRING& GetSourceURI() { return sourceURI; }
//-----<abstract for implementors>---------------------------------------
/**
* Function ReadPart
* fetches @a aPartName's s-expression into @a aResult after clear()ing aResult.
*/
virtual void ReadPart( STR_UTF* aResult, const STRING& aPartName, const STRING& aRev = "" ) = 0;
/**
* Function ReadParts
* fetches the s-expressions for each part given in @a aPartNames, into @a aResults,
* honoring the array indices respectfully.
* @param aPartNames is a list of part names, one name per list element. If a part name
* does not have a version string, then the most recent version is fetched.
* @param aResults receives the s-expressions
*/
virtual void ReadParts( STR_UTFS* aResults, const STRINGS& aPartNames ) = 0;
/**
* Function GetCategories
* fetches all categories present in the library source into @a aResults
*/
virtual void GetCategories( STRINGS* aResults ) = 0;
/**
* Function GetCategoricalPartNames
* fetches all the part names for @a aCategory, which was returned by GetCategories().
*
* @param aCategory is a subdividing navigator within the library source,
* but may default to empty which will be taken to mean all categories.
*
* @param aResults is a place to put the fetched result, one category per STRING.
*/
virtual void GetCategoricalPartNames( STRINGS* aResults, const STRING& aCategory="" ) = 0;
/**
* Function GetRevisions
* fetches all revisions for @a aPartName into @a aResults. Revisions are strings
* like "rev12", "rev279", and are library source agnostic. These do not have to be
* in a contiguous order, but the first 3 characters must be "rev" and subsequent
* characters must consist of at least one decimal digit. If the LIB_SOURCE
* does not support revisions, it is allowed to return a single "" string as
* the only result. This means aPartName is present in the libsource, only once
* without a revision. This is a special case.
*/
virtual void GetRevisions( STRINGS* aResults, const STRING& aPartName ) = 0;
/**
* Function FindParts
* fetches part names for all parts matching the criteria given in @a
* aQuery, into @a aResults. The query string is designed to be easily marshalled,
* i.e. serialized, so that long distance queries can be made with minimal overhead.
* The library source needs to have an intelligent friend on the other end if
* the actual library data is remotely located, otherwise it will be too slow
* to honor this portion of the API contract.
*
* @param aQuery is a string holding a domain specific query language expression.
* One candidate here is an s-expression that uses (and ..) and (or ..) operators
* and uses them as RPN. For example "(and (footprint 0805)(value 33ohm)(category passives))".
* The UI can shield the user from this if it wants.
*
* @param aResults is a place to put the fetched part names, one part per STRING.
*/
virtual void FindParts( STRINGS* aResults, const STRING& aQuery ) = 0;
//-----</abstract for implementors>--------------------------------------
protected:
STRING sourceType;
STRING sourceURI;
};
/**
* LIB_SINK
* is an abstract class from which implementation specific LIB_SINKs
* may be derived, one for each kind of library type in the library table that
* supports writing. The class name stems from the fact that this interface
* only provides WRITE functions.
*
* @author Dick Hollenbeck
*/
class LIB_SINK
{
friend class LIB; ///< only the LIB uses these functions.
protected: ///< derived classes must implement
/**
* Function GetSinkType
* returns the library table entry's type for this library sink.
*/
const STRING& GetSinkType() { return sinkType; }
/**
* Function GetSinkURI
* returns absolute location of the library sink.
*/
const STRING& GetSinkURI() { return sinkURI; }
/**
* Function WritePart
* saves the part to non-volatile storage. @a aPartName may have the revision
* portion present. If it is not present, and a overwrite of an existhing
* part is done, then LIB::ReloadPart() must be called on this same part
* and all parts that inherit it must be reparsed.
* @return STRING - if the LIB_SINK support revision numbering, then return a
* revision name that was next in the sequence, e.g. "rev22", else "".
*/
virtual STRING WritePart( const STRING& aPartName, const STRING& aSExpression ) = 0;
protected:
STRING sinkType;
STRING sinkURI;
};
class PARTS;
/**
* LIB
* is a cache of parts, and because the LIB_SOURCE is abstracted, there
* should be no need to extend from this class in any case except for the
* PARTS_LIST.
*
* @author Dick Hollenbeck
*/
class MY_API LIB
{
friend class LIB_TABLE; ///< protected constructor, LIB_TABLE may construct
protected: // constructor is not public, called from LIB_TABLE only.
/**
* Constructor LIB
* is not public and is only called from class LIB_TABLE
*
* @param aLogicalLibrary is the name of a well known logical library, and is
* known because it already exists in the library table.
*
* @param aSource is an open LIB_SOURCE whose ownership is
* given over to this LIB.
*
* @param aSink is an open LIB_SINK whose ownership is given over
* to this LIB, and it is normally NULL.
*/
LIB( const STRING& aLogicalLibrary, LIB_SOURCE* aSource, LIB_SINK* aSink = NULL );
public:
~LIB();
/**
* Function HasSink
* returns true if this library has write/save capability. Most LIBs
* are read only.
*/
bool HasSink() { return sink != NULL; }
/**
* Function LogicalName
* returns the logical name of this LIB.
*/
STRING LogicalName();
//-----<use delegates: source and sink>---------------------------------
/**
* Function LookupPart
* returns a PART given @a aPartName, such as "passives/R". No ownership
* is given to the PART, it stays in the cache that is this LIB.
*
* @param aLPID is the part to lookup. The logicalLibName can be empty in it
* since yes, we know which LIB is in play.
*
* @param aLibTable is the LIB_TABLE view that is in effect for inheritance,
* and comes from the big containing SCHEMATIC object.
*
* @return PART* - The desired PART and will never be NULL. No ownership is
* given to caller. PARTs always reside in the cache that is a LIB.
*
* @throw IO_ERROR if the part cannot be found or loaded.
*/
PART* LookupPart( const LPID& aLPID, LIB_TABLE* aLibTable );
/**
* Function ReloadPart
* will reload the part assuming the library source has a changed content
* for it.
*/
void ReloadPart( PART* aPart );
/**
* Function GetCategories
* returns all categories of parts within this LIB into @a aResults.
*/
STRINGS GetCategories();
/**
* Function GetCategoricalPartNames
* returns the part names for @a aCategory, and at the same time
* creates cache entries for the very same parts if they do not already exist
* in this LIB (i.e. cache).
*/
STRINGS GetCategoricalPartNames( const STRING& aCategory = "" );
//-----<.use delegates: source and sink>--------------------------------
/**
* Function WritePart
* saves the part to non-volatile storage and returns the next new revision
* name in the sequence established by the LIB_SINK.
*/
STRING WritePart( PART* aPart );
void SetPartBody( PART* aPart, const STRING& aSExpression );
/**
* Function GetRevisions
* returns the revisions of @a aPartName that are present in this LIB.
* The returned STRINGS will look like "rev1", "rev2", etc.
*/
STRINGS GetRevisions( const STRING& aPartName );
/**
* Function FindParts
* returns part names for all parts matching the criteria given in @a
* aQuery, into @a aResults. The query string is designed to be easily marshalled,
* i.e. serialized, so that long distance queries can be made with minimal overhead.
* The library source needs to have an intelligent friend on the other end if
* the actual library data is remotely located, otherwise it will be too slow
* to honor this portion of the API contract.
*
* @param aQuery is a string holding a domain specific language expression. One candidate
* here is an RPN s-expression that uses (and ..) and (or ..) operators. For example
* "(and (footprint 0805)(value 33ohm)(category passives))"
*/
STRINGS FindParts( const STRING& aQuery )
{
// run the query on the cached data first for any PARTS which are fully
// parsed (i.e. cached), then on the LIB_SOURCE to find any that
// are not fully parsed, then unify the results.
return STRINGS();
}
#if defined(DEBUG)
static void Test( int argc, char** argv );
#endif
protected:
STR_UTF fetch; // scratch, used to fetch things, grows to worst case size.
STR_UTFS vfetch; // scratch, used to fetch things.
STRING logicalName;
LIB_SOURCE* source;
LIB_SINK* sink;
STRINGS categories;
bool cachedCategories; /// < is true only after reading categories
/** parts are in various states of readiness:
* 1) not even loaded (if cachedParts is false)
* 2) present, but without member 'body' having been read() yet.
* 3) body has been read, but not parsed yet.
* 4) parsed and inheritance if any has been applied.
*/
PARTS* parts;
/**
* Function lookupPart
* looks up a PART, returns NULL if cannot find in source. Does not parse
* the part. Does not even load the part's Sweet string. No ownership
* is given to the PART, it stays in the cache that is this LIB.
*
* @throw IO_ERROR if there is some kind of communications error reading
* the original list of parts.
*
* @return PART* - the cached PART, or NULL if not found. No ownership transferred.
*/
const PART* lookupPart( const LPID& aLPID );
};
} // namespace SCH
#endif // SCH_LIB_H_

View File

@ -1,336 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2010-2011 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2010 KiCad Developers, see change_log.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 <set>
#include <assert.h>
#include <sch_lib_table_lexer.h>
#include <sch_lpid.h>
#include <sch_lib_table.h>
#include <sch_dir_lib_source.h>
using namespace SCH;
using namespace LT; // tokens, enum T for LIB_TABLE
LIB_TABLE::LIB_TABLE( LIB_TABLE* aFallBackTable ):
fallBack( aFallBackTable )
{
// not copying fall back, simply search aFallBackTable separately
// if "logicalName not found".
}
void LIB_TABLE::Parse( SCH_LIB_TABLE_LEXER* in )
{
/* grammar:
(lib_table
(lib (logical LOGICAL)(type TYPE)(full_uri FULL_URI)(options OPTIONS))
(lib (logical LOGICAL)(type TYPE)(full_uri FULL_URI)(options OPTIONS))
(lib (logical LOGICAL)(type TYPE)(full_uri FULL_URI)(options OPTIONS))
)
note: "(lib_table" has already been read in.
*/
T tok;
while( ( tok = in->NextTok() ) != T_RIGHT )
{
// (lib (logical "LOGICAL")(type "TYPE")(full_uri "FULL_URI")(options "OPTIONS"))
if( tok == T_EOF )
in->Expecting( T_RIGHT );
if( tok != T_LEFT )
in->Expecting( T_LEFT );
if( ( tok = in->NextTok() ) != T_lib )
in->Expecting( T_lib );
in->NeedLEFT();
if( ( tok = in->NextTok() ) != T_logical )
in->Expecting( T_logical );
in->NeedSYMBOLorNUMBER();
std::auto_ptr<ROW> row( new ROW( this ) );
row->SetLogicalName( in->CurText() );
in->NeedRIGHT();
in->NeedLEFT();
if( ( tok = in->NextTok() ) != T_type )
in->Expecting( T_type );
in->NeedSYMBOLorNUMBER();
// verify that type is one of: {dir, schematic, subversion, http}
if( strcmp( in->CurText(), "dir" ) &&
strcmp( in->CurText(), "schematic" ) &&
strcmp( in->CurText(), "subversion" ) &&
strcmp( in->CurText(), "http" ) )
{
in->Expecting( "dir|schematic|subversion|http" );
}
row->SetType( in->CurText() );
in->NeedRIGHT();
in->NeedLEFT();
if( ( tok = in->NextTok() ) != T_full_uri )
in->Expecting( T_full_uri );
in->NeedSYMBOLorNUMBER();
row->SetFullURI( in->CurText() );
in->NeedRIGHT();
in->NeedLEFT();
if( ( tok = in->NextTok() ) != T_options )
in->Expecting( T_options );
in->NeedSYMBOLorNUMBER();
row->SetOptions( in->CurText() );
in->NeedRIGHT();
in->NeedRIGHT(); // terminate the (lib..)
// all logicalNames within this table fragment must be unique, so we do not
// use doReplace in InsertRow(). However a fallBack table can have a
// conflicting logicalName and ours will supercede that one since in
// FindLib() we search this table before any fall back.
if( !InsertRow( row ) )
{
STRING msg;
msg += '\'';
msg += row->logicalName;
msg += '\'';
msg += " is a duplicate logical lib name";
THROW_IO_ERROR( msg );
}
}
}
void LIB_TABLE::Format( OUTPUTFORMATTER* out, int nestLevel ) const
{
out->Print( nestLevel, "(lib_table\n" );
for( ROWS_CITER it = rows.begin(); it != rows.end(); ++it )
it->second->Format( out, nestLevel+1 );
out->Print( nestLevel, ")\n" );
}
void LIB_TABLE::ROW::Format( OUTPUTFORMATTER* out, int nestLevel ) const
{
out->Print( nestLevel, "(lib (logical %s)(type %s)(full_uri %s)(options %s))\n",
out->Quotes( logicalName ).c_str(),
out->Quotes( libType ).c_str(),
out->Quotes( fullURI ).c_str(),
out->Quotes( options ).c_str()
);
}
STRINGS LIB_TABLE::GetLogicalLibs()
{
// Only return unique logical library names. Use std::set::insert() to
// quietly reject any duplicates, which can happen when encountering a duplicate
// logical lib name from one of the fall back table(s).
std::set<STRING> unique;
STRINGS ret;
const LIB_TABLE* cur = this;
do
{
for( ROWS_CITER it = cur->rows.begin(); it!=cur->rows.end(); ++it )
{
unique.insert( it->second->logicalName );
}
} while( ( cur = cur->fallBack ) != 0 );
// return a sorted, unique set of logical lib name STRINGS to caller
for( std::set<STRING>::const_iterator it = unique.begin(); it!=unique.end(); ++it )
ret.push_back( *it );
return ret;
}
PART* LIB_TABLE::LookupPart( const LPID& aLPID, LIB* aLocalLib )
{
LIB* lib = lookupLib( aLPID, aLocalLib );
return lib->LookupPart( aLPID, this );
}
LIB* LIB_TABLE::lookupLib( const LPID& aLPID, LIB* aFallBackLib )
{
if( aLPID.GetLogicalLib().size() )
{
ROW* row = FindRow( aLPID.GetLogicalLib() );
if( !row )
{
STRING msg = "lib table contains no logical lib '";
msg += aLPID.GetLogicalLib();
msg += '\'';
THROW_IO_ERROR( msg );
}
if( !row->lib )
{
loadLib( row );
}
assert( row->lib ); // fix loadLib() to throw if cannot load
return row->lib;
}
if( aFallBackLib )
{
return aFallBackLib;
}
STRING msg = "lookupLib() requires logicalLibName or a fallback lib";
THROW_IO_ERROR( msg );
}
void LIB_TABLE::loadLib( ROW* aRow )
{
assert( !aRow->lib ); // caller should know better.
const STRING& libType = aRow->GetType();
if( !libType.compare( "dir" ) )
{
// autor_ptr wrap source while we create sink, in case sink throws.
std::auto_ptr<LIB_SOURCE> source(
new DIR_LIB_SOURCE(
aRow->GetFullURI(),
aRow->GetOptions() ) );
/* @todo load LIB_SINK
std::auto_ptr<LIB_SINK> sink(
new DIR_LIB_SINK(
aRow->GetFullURI(),
aRow->GetOptions() ) );
*/
// LIB::LIB( const STRING& aLogicalLibrary, LIB_SOURCE* aSource, LIB_SINK* aSink = NULL );
aRow->lib = new LIB( aRow->GetLogicalName(), source.release(), NULL );
}
/*
else if( !libType.compare( "schematic" ) )
{
// @todo code and load SCHEMATIC_LIB_SOURCE
}
else if( !libType.compare( "subversion" ) )
{
// @todo code and load SVN_LIB_SOURCE
}
else if( !libType.compare( "http" ) )
{
// @todo code and load HTTP_LIB_SOURCE
}
*/
else
{
STRING msg = "cannot load unknown libType: '";
msg += libType;
msg += '\'';
THROW_IO_ERROR( msg );
}
}
LIB_TABLE::ROW* LIB_TABLE::FindRow( const STRING& aLogicalName ) const
{
// this function must be *super* fast, so therefore should not instantiate
// anything which would require using the heap. This function is the reason
// ptr_map<> was used instead of ptr_set<>, which would have required
// instantiating a ROW just to find a ROW.
const LIB_TABLE* cur = this;
do
{
ROWS_CITER it = cur->rows.find( aLogicalName );
if( it != cur->rows.end() )
{
// reference: http://myitcorner.com/blog/?p=361
return (LIB_TABLE::ROW*) it->second; // found
}
// not found, search fall back table(s), if any
} while( ( cur = cur->fallBack ) != 0 );
return 0; // not found
}
bool LIB_TABLE::InsertRow( std::auto_ptr<ROW>& aRow, bool doReplace )
{
// this does not need to be super fast.
ROWS_CITER it = rows.find( aRow->logicalName );
if( it == rows.end() )
{
// be careful here, key is needed because aRow can be
// release()ed before logicalName is captured.
const STRING& key = aRow->logicalName;
rows.insert( key, aRow );
return true;
}
if( doReplace )
{
rows.erase( aRow->logicalName );
// be careful here, key is needed because aRow can be
// release()ed before logicalName is captured.
const STRING& key = aRow->logicalName;
rows.insert( key, aRow );
return true;
}
return false;
}

View File

@ -1,387 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2010 KiCad Developers, see change_log.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 SCH_LIB_TABLE_H_
#define SCH_LIB_TABLE_H_
#include <string>
#include <boost/ptr_container/ptr_map.hpp>
#include <import_export.h>
#include <sch_lib.h>
class OUTPUTFORMATTER;
class SCH_LIB_TABLE_LEXER;
namespace SCH {
class LPID;
class PART;
/**
* LIB_TABLE
* holds LIB_TABLE::ROW records, and can be searched in a very high speed
* way based on logical library name.
* <p>
* This class owns the <b>library table</b>, which is like fstab in concept and maps logical
* library name to library URI, type, and options. It has the following columns:
* <ul>
* <li> Logical Library Name
* <li> Library Type
* <li> Library URI. The full URI to the library source, form dependent on Type.
* <li> Options, used for access, such as password
* </ul>
* <p>
* The Library Type can be one of:
* <ul>
* <li> "dir"
* <li> "schematic" i.e. a parts list from another schematic.
* <li> "subversion"
* <li> "http"
* </ul>
* <p>
* For now, the Library URI types needed to support the various types can be one of those
* shown below, which are typical of each type:
* <ul>
* <li> "file://C:/mylibdir"
* <li> "file://home/user/kicadwork/jtagboard.sch"
* <li> "svn://kicad.org/partlib/trunk"
* <li> "http://kicad.org/partlib"
* </ul>
* <p>
* The applicable library table is built up from several additive rows (table fragments),
* and the final table is a (conceptual) merging of the table fragments. Two
* anticipated sources of the rows are a personal table, and a schematic resident
* table. The schematic resident table rows are considered a higher priority in
* the final dynamically assembled library table. A row in the schematic
* contribution to the library table takes precedence over the personal table
* if there is a collision on logical library name, otherwise the rows simply
* combine without issue to make up the applicable library table.
*
* @author Dick Hollenbeck
*/
class MY_API LIB_TABLE
{
public:
/**
* ROW
* holds a record identifying a LIB in the LIB_TABLE.
*/
class ROW
{
friend class LIB_TABLE;
public:
/**
* Function GetLogicalName
* returns the logical name of this library table entry.
*/
const STRING& GetLogicalName() const
{
return logicalName;
}
/**
* Function GetType
* returns the type of LIB represented by this record.
*/
const STRING& GetType() const
{
return libType;
}
/**
* Function GetFullURI
* returns the full location specifying URI for the LIB.
*/
const STRING& GetFullURI() const
{
return fullURI;
}
/**
* Function GetOptions
* returns the options string, which may hold a password or anything else needed to
* instantiate the underlying LIB_SOURCE.
*/
const STRING& GetOptions() const
{
return options;
}
~ROW()
{
delete lib;
}
/**
* Function Format
* serializes this object as utf8 text to an OUTPUTFORMATTER, and tries to
* make it look good using multiple lines and indentation.
* @param out is an OUTPUTFORMATTER
* @param nestLevel is the indentation level to base all lines of the output.
* Actual indentation will be 2 spaces for each nestLevel.
*/
void Format( OUTPUTFORMATTER* out, int nestLevel ) const;
protected:
ROW( LIB_TABLE* aOwner ) :
owner( aOwner ),
lib( 0 )
{}
/**
* Function SetLogicalName
* changes the logical name of this library, useful for an editor.
*/
void SetLogicalName( const STRING& aLogicalName )
{
logicalName = aLogicalName;
}
/**
* Function SetType
* changes the type represented by this record.
*/
void SetType( const STRING& aType )
{
libType = aType;
}
/**
* Function SetFullURI
* changes the full URI for the library, useful from a library table editor.
*/
void SetFullURI( const STRING& aFullURI )
{
fullURI = aFullURI;
}
/**
* Function SetOptions
* changes the options string for this record, and is useful from
* the library table editor.
*/
void SetOptions( const STRING& aOptions )
{
options = aOptions;
}
private:
LIB_TABLE* owner;
STRING logicalName;
STRING libType;
STRING fullURI;
STRING options;
LIB* lib; ///< ownership of the loaded LIB is here
};
/**
* Constructor LIB_TABLE
* builds a library table by pre-pending this table fragment in front of
* @a aFallBackTable. Loading of this table fragment is done by using Parse().
*
* @param aFallBackTable is another LIB_TABLE which is searched only when
* a record is not found in this table. No ownership is taken of aFallBackTable.
*/
LIB_TABLE( LIB_TABLE* aFallBackTable = NULL );
/**
* Function Parse
* fills this table fragment from information in the input stream \a aParser, which
* is a DSNLEXER customized for the grammar needed to describe instances of this object.
* The entire textual element spec is <br>
*
* <pre>
* (lib_table
* (lib (logical LOGICAL)(type TYPE)(full_uri FULL_URI)(options OPTIONS))
* (lib (logical LOGICAL)(type TYPE)(full_uri FULL_URI)(options OPTIONS))
* (lib (logical LOGICAL)(type TYPE)(full_uri FULL_URI)(options OPTIONS))
* )
* </pre>
*
* When this function is called, the input token stream given by \a aParser
* is assumed to be positioned at the '^' in the following example, i.e. just
* after the identifying keyword and before the content specifying stuff.
* <br>
* (lib_table ^ (....) )
*
* @param aParser is the input token stream of keywords and symbols.
*/
void Parse( SCH_LIB_TABLE_LEXER* aParser ) throw( IO_ERROR, PARSE_ERROR );
/**
* Function Format
* serializes this object as utf8 text to an OUTPUTFORMATTER, and tries to
* make it look good using multiple lines and indentation.
*
* @param out is an OUTPUTFORMATTER
* @param nestLevel is the indentation level to base all lines of the output.
* Actual indentation will be 2 spaces for each nestLevel.
*/
void Format( OUTPUTFORMATTER* out, int nestLevel ) const;
/**
* Function LookupPart
* finds and loads a PART, and parses it. As long as the part is
* accessible in any LIB_SOURCE, opened or not opened, this function
* will find it and load it into its containing LIB, even if that means
* having to open a LIB in this table that was not previously opened.
*
* @param aLogicalPartID holds the partName and may also hold the logicalLibName. If
* logicalLibName is empty, then @a aFallBackLib should not be NULL.
*
* @param aFallBackLib is used only if aLogicalPartID has an empty logicalLibName.
* This is for the case when an LPID has no logicalLibName because the LPID is using
* a partName from the same LIB as was the referring content.
*
* @return PART* - this will never be NULL, and no ownership is transfered because
* all PARTs live in LIBs. You only get to point to them in some LIB. If the PART
* cannot be found, then an exception is thrown.
*
* @throw IO_ERROR if any problem occurs or if the part cannot be found.
*/
PART* LookupPart( const LPID& aLogicalPartID, LIB* aFallBackLib = NULL );
/**
* Function GetLogicalLibs
* returns the logical library names, all of them that are in pertinent to
* a lookup done on this LIB_TABLE.
*/
STRINGS GetLogicalLibs();
//----<read accessors>----------------------------------------------------
// the returning of a const STRING* tells if not found, but might be too
// promiscuous?
/**
* Function GetLibURI
* returns the full library path from a logical library name.
* @param aLogicalLibraryName is the short name for the library of interest.
* @return const STRING* - or NULL if not found.
*/
const STRING* GetLibURI( const STRING& aLogicalLibraryName ) const
{
const ROW* row = FindRow( aLogicalLibraryName );
return row ? &row->fullURI : 0;
}
/**
* Function GetLibType
* returns the type of a logical library.
* @param aLogicalLibraryName is the short name for the library of interest.
* @return const STRING* - or NULL if not found.
*/
const STRING* GetLibType( const STRING& aLogicalLibraryName ) const
{
const ROW* row = FindRow( aLogicalLibraryName );
return row ? &row->libType : 0;
}
/**
* Function GetLibOptions
* returns the options string for \a aLogicalLibraryName.
* @param aLogicalLibraryName is the short name for the library of interest.
* @return const STRING* - or NULL if not found.
*/
const STRING* GetLibOptions( const STRING& aLogicalLibraryName ) const
{
const ROW* row = FindRow( aLogicalLibraryName );
return row ? &row->options : 0;
}
//----</read accessors>---------------------------------------------------
#if 1 || defined(DEBUG)
/// implement the tests in here so we can honor the priviledge levels of the
/// accessors, something difficult to do from int main(int, char**)
void Test();
#endif
protected: // only a table editor can use these
/**
* Function InsertRow
* adds aRow if it does not already exist or if doReplace is true. If doReplace
* is not true and the key for aRow already exists, the function fails and returns false.
* The key for the table is the logicalName, and all in this table must be unique.
* @param aRow is the new row to insert, or to forcibly add if doReplace is true.
* @param doReplace if true, means insert regardless of whether aRow's key already
* exists. If false, then fail if the key already exists.
* @return bool - true if the operation succeeded.
*/
bool InsertRow( std::auto_ptr<ROW>& aRow, bool doReplace = false );
/**
* Function FindRow
* returns a ROW* if aLogicalName is found in this table or in any chained
* fallBack table fragment, else NULL.
*/
ROW* FindRow( const STRING& aLogicalName ) const;
private:
/**
* Function lookupLib
* finds or loads a LIB based on @a aLogicalPartID or @a aFallBackLib.
* If the LIB is already loaded then it is returned as is, else it is loaded.
*
* @param aLogicalPartID holds the partName and may also hold the logicalLibName. If
* logicalLibName is empty, then @a aFallBackLib should not be NULL.
*
* @param aFallBackLib is used only if aLogicalPartID has an empty logicalLibName.
* This is for the case when an LPID has no logicalLibName because the LPID is using
* a partName from the same LIB as was the referring content.
*
* @return LIB* - this will never be NULL, and no ownership is transfered because
* all LIBs live in the LIB_TABLEs. You only get to point to them in some LIB_TABLE.
* If the LIB cannot be found, then an exception is thrown.
*
* @throw IO_ERROR if any problem occurs or if the LIB cannot be found or cannot be loaded.
*/
LIB* lookupLib( const LPID& aLogicalPartID, LIB* aFallBackLib = NULL );
/**
* Function loadLib
* loads a LIB using information in @a aRow. Call only if LIB not
* already loaded.
*/
void loadLib( ROW* aRow );
typedef boost::ptr_map<STRING, ROW> ROWS;
typedef ROWS::iterator ROWS_ITER;
typedef ROWS::const_iterator ROWS_CITER;
ROWS rows;
LIB_TABLE* fallBack;
};
} // namespace SCH
#endif // SCH_LIB_TABLE_H_

View File

@ -1,6 +0,0 @@
lib_table
logical
type
full_uri
options
lib

View File

@ -1,501 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2010 KiCad Developers, see change_log.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 <cstring>
#include <wx/wx.h> // _()
#include <sch_lpid.h>
using namespace SCH;
static inline bool isDigit( char c )
{
return c >= '0' && c <= '9';
}
const char* EndsWithRev( const char* start, const char* tail, char separator )
{
bool sawDigit = false;
while( tail > start && isDigit( *--tail ) )
{
sawDigit = true;
}
// if sawDigit, tail points to the 'v' here.
if( sawDigit && tail-3 >= start )
{
tail -= 3;
if( tail[0]==separator && tail[1]=='r' && tail[2]=='e' && tail[3]=='v' )
{
return tail+1; // omit separator, return "revN[N..]"
}
}
return 0;
}
int RevCmp( const char* s1, const char* s2 )
{
int r = strncmp( s1, s2, 3 );
if( r || strlen(s1)<4 || strlen(s2)<4 )
{
return r;
}
int rnum1 = atoi( s1+3 );
int rnum2 = atoi( s2+3 );
return -(rnum1 - rnum2); // swap the sign, higher revs first
}
//----<Policy and field test functions>-------------------------------------
// These all return -1 on success, or >= 0 if there is an error at a
// particular character offset into their respective arguments. If >=0,
// then that return value gives the character offset of the error.
static inline int okLogical( const STRING& aField )
{
// std::string::npos is largest positive number, casting to int makes it -1.
// Returning that means success.
return int( aField.find_first_of( ":/" ) );
}
static inline int okBase( const STRING& aField )
{
int offset = int( aField.find_first_of( ":/" ) );
if( offset != -1 )
return offset;
// cannot be empty
if( !aField.size() )
return 0;
return offset; // ie. -1
}
static inline int okCategory( const STRING& aField )
{
return int( aField.find_first_of( ":/" ) );
}
static int okRevision( const STRING& aField )
{
char rev[32]; // C string for speed
if( aField.size() >= 4 )
{
strcpy( rev, "x/" );
strcat( rev, aField.c_str() );
if( EndsWithRev( rev, rev + strlen(rev) ) == rev+2 )
return -1; // success
}
return 0; // first character position "is in error", is best we can do.
}
//----</Policy and field test functions>-------------------------------------
void LPID::clear()
{
logical.clear();
category.clear();
baseName.clear();
partName.clear();
revision.clear();
}
int LPID::Parse( const STRING& aLPID )
{
clear();
const char* rev = EndsWithRev( aLPID );
size_t revNdx;
size_t partNdx;
size_t baseNdx;
int offset;
//=====<revision>=========================================
if( rev )
{
revNdx = rev - aLPID.c_str();
// no need to check revision, EndsWithRev did that.
revision = aLPID.substr( revNdx );
--revNdx; // back up to omit the '/' which preceeds the rev
}
else
revNdx = aLPID.size();
//=====<logical>==========================================
if( ( partNdx = aLPID.find( ':' ) ) != aLPID.npos )
{
offset = SetLogicalLib( aLPID.substr( 0, partNdx ) );
if( offset > -1 )
{
return offset;
}
++partNdx; // skip ':'
}
else
partNdx = 0;
//=====<rawName && category>==============================
// "length limited" search:
const char* base = (const char*) memchr( aLPID.c_str() + partNdx, '/', revNdx - partNdx );
if( base )
{
baseNdx = base - aLPID.c_str();
offset = SetCategory( aLPID.substr( partNdx, baseNdx - partNdx ) );
if( offset > -1 )
{
return offset + partNdx;
}
++baseNdx; // skip '/'
}
else
{
baseNdx = partNdx;
}
//=====<baseName>==========================================
offset = SetBaseName( aLPID.substr( baseNdx, revNdx - baseNdx ) );
if( offset > -1 )
{
return offset + baseNdx;
}
return -1;
}
LPID::LPID( const STRING& aLPID ) throw( PARSE_ERROR )
{
int offset = Parse( aLPID );
if( offset != -1 )
{
THROW_PARSE_ERROR(
_( "Illegal character found in LPID string" ),
wxString::FromUTF8( aLPID.c_str() ),
aLPID.c_str(),
0,
offset
);
}
}
int LPID::SetLogicalLib( const STRING& aLogical )
{
int offset = okLogical( aLogical );
if( offset == -1 )
{
logical = aLogical;
}
return offset;
}
int LPID::SetCategory( const STRING& aCategory )
{
int offset = okCategory( aCategory );
if( offset == -1 )
{
category = aCategory;
// set the partName too
if( category.size() )
{
partName = category;
partName += '/';
partName += baseName;
}
else
partName = baseName;
}
return offset;
}
int LPID::SetBaseName( const STRING& aBaseName )
{
int offset = okBase( aBaseName );
if( offset == -1 )
{
baseName = aBaseName;
// set the partName too
if( category.size() )
{
partName = category;
partName += '/';
partName += baseName;
}
else
partName = baseName;
}
return offset;
}
int LPID::SetPartName( const STRING& aPartName )
{
STRING category;
STRING base;
int offset;
int separation = int( aPartName.find_first_of( "/" ) );
if( separation != -1 )
{
category = aPartName.substr( 0, separation );
base = aPartName.substr( separation+1 );
}
else
{
// leave category empty
base = aPartName;
}
if( (offset = SetCategory( category )) != -1 )
return offset;
if( (offset = SetBaseName( base )) != -1 )
{
return offset + separation + 1;
}
return -1;
}
int LPID::SetRevision( const STRING& aRevision )
{
int offset = okRevision( aRevision );
if( offset == -1 )
{
revision = aRevision;
}
return offset;
}
STRING LPID::Format() const
{
STRING ret;
if( logical.size() )
{
ret += logical;
ret += ':';
}
if( category.size() )
{
ret += category;
ret += '/';
}
ret += baseName;
if( revision.size() )
{
ret += '/';
ret += revision;
}
return ret;
}
STRING LPID::GetPartNameAndRev() const
{
STRING ret;
if( category.size() )
{
ret += category;
ret += '/';
}
ret += baseName;
if( revision.size() )
{
ret += '/';
ret += revision;
}
return ret;
}
STRING LPID::Format( const STRING& aLogicalLib, const STRING& aPartName, const STRING& aRevision )
throw( PARSE_ERROR )
{
STRING ret;
int offset;
if( aLogicalLib.size() )
{
offset = okLogical( aLogicalLib );
if( offset != -1 )
{
THROW_PARSE_ERROR(
_( "Illegal character found in logical lib name" ),
wxString::FromUTF8( aLogicalLib.c_str() ),
aLogicalLib.c_str(),
0,
offset
);
}
ret += aLogicalLib;
ret += ':';
}
{
STRING category;
STRING base;
int separation = int( aPartName.find_first_of( "/" ) );
if( separation != -1 )
{
category = aPartName.substr( 0, separation );
base = aPartName.substr( separation+1 );
}
else
{
// leave category empty
base = aPartName;
}
if( (offset = okCategory( category )) != -1 )
{
THROW_PARSE_ERROR(
_( "Illegal character found in category" ),
wxString::FromUTF8( aRevision.c_str() ),
aRevision.c_str(),
0,
offset
);
}
if( (offset = okBase( base )) != -1 )
{
THROW_PARSE_ERROR(
_( "Illegal character found in base name" ),
wxString::FromUTF8( aRevision.c_str() ),
aRevision.c_str(),
0,
offset + separation + 1
);
}
if( category.size() )
{
ret += category;
ret += '/';
}
ret += base;
}
if( aRevision.size() )
{
offset = okRevision( aRevision );
if( offset != -1 )
{
THROW_PARSE_ERROR(
_( "Illegal character found in revision" ),
wxString::FromUTF8( aRevision.c_str() ),
aRevision.c_str(),
0,
offset
);
}
ret += '/';
ret += aRevision;
}
return ret;
}
#if 0 && defined(DEBUG)
// build this with Debug CMAKE_BUILD_TYPE
void LPID::Test()
{
static const char* lpids[] = {
"me:passives/R/rev0",
"passives/R/rev2",
":passives/R/rev3",
"C/rev22",
"passives/C22",
"R",
"me:R",
// most difficult:
"me:/R/rev0",
"me:R/rev0",
};
for( unsigned i=0; i<sizeof(lpids)/sizeof(lpids[0]); ++i )
{
// test some round tripping
LPID lpid( lpids[i] ); // parse
// format
printf( "input:'%s' full:'%s' base:'%s' partName:'%s' cat:'%s' rev:'%s'\n",
lpids[i],
lpid.Format().c_str(),
lpid.GetBaseName().c_str(),
lpid.GetPartName().c_str(),
lpid.GetCategory().c_str(),
lpid.GetRevision().c_str()
);
}
}
int main( int argc, char** argv )
{
LPID::Test();
return 0;
}
#endif

View File

@ -1,245 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2010 KiCad Developers, see change_log.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 SCH_LPID_H_
#define SCH_LPID_H_
#include <utf8.h>
#include <richio.h>
namespace SCH {
/**
* LPID
* (aka GUID) is a Logical Part ID and consists of various portions much like a URI.
* It is a container for the separated portions of a logical part id STRING so they
* can be accessed individually. The various portions of an LPID are:
* logicalLibraryName, category, baseName, and revision. Only the baseName is
* mandatory. There is another construct called "partName" which consists of
* [category/]baseName. That is the category followed by a slash, but only if
* the category is not empty.
* <p>
* partName = [category/]baseName
* <p>
* Example LPID string:
* "kicad:passives/R/rev6".
* <p>
* <ul>
* <li> "kicad" is the logical library name.
* <li> "passives" is the category.
* <li> "passives/R" is the partname.
* <li> "rev6" is the revision, which is optional. If missing then its
* / delimiter should also not be present. A revision must begin with
* "rev" and be followed by at least one or more decimal digits.
* </ul>
* @author Dick Hollenbeck
*/
class LPID // aka GUID
{
public:
LPID() {}
/**
* Constructor LPID
* takes aLPID string and parses it. A typical LPID string uses a logical
* library name followed by a part name.
* e.g.: "kicad:passives/R/rev2", or
* e.g.: "mylib:R33"
*/
LPID( const STRING& aLPID ) throw( PARSE_ERROR );
/**
* Function Parse
* [re-]stuffs this LPID with the information from @a aLPID.
* @return int - minus 1 (i.e. -1) means success, >= 0 indicates the
* character offset into aLPID at which an error was detected.
*/
int Parse( const STRING& aLPID );
/**
* Function GetLogicalLib
* returns the logical library portion of a LPID. There is not Set accessor
* for this portion since it comes from the library table and is considered
* read only here.
*/
const STRING& GetLogicalLib() const
{
return logical;
}
/**
* Function SetCategory
* overrides the logical lib name portion of the LPID to @a aLogical, and can be empty.
* @return int - minus 1 (i.e. -1) means success, >= 0 indicates the
* character offset into the parameter at which an error was detected, usually
* because it contained '/' or ':'.
*/
int SetLogicalLib( const STRING& aLogical );
/**
* Function GetCategory
* returns the category of this part id, "passives" in the example at the
* top of the class description.
*/
const STRING& GetCategory() const
{
return category;
}
/**
* Function SetCategory
* overrides the category portion of the LPID to @a aCategory and is typically
* either the empty string or a single word like "passives".
* @return int - minus 1 (i.e. -1) means success, >= 0 indicates the
* character offset into the parameter at which an error was detected, usually
* because it contained '/' or ':'.
*/
int SetCategory( const STRING& aCategory );
/**
* Function GetBaseName
* returns the part name without the category.
*/
const STRING& GetBaseName() const
{
return baseName;
}
/**
* Function SetBaseName
* overrides the base name portion of the LPID to @a aBaseName
* @return int - minus 1 (i.e. -1) means success, >= 0 indicates the
* character offset into the parameter at which an error was detected, usually
* because it contained '/' or ':', or is blank.
*/
int SetBaseName( const STRING& aBaseName );
/**
* Function GetPartName
* returns the part name, i.e. category/baseName without revision.
*/
const STRING& GetPartName() const
{
return partName;
}
/**
* Function GetPartNameAndRev
* returns the part name with revision if any, i.e. [category/]baseName[/revN..]
*/
STRING GetPartNameAndRev() const;
/**
* Function SetPartName
* overrides the part name portion of the LPID to @a aPartName
* @return int - minus 1 (i.e. -1) means success, >= 0 indicates the
* character offset into the parameter at which an error was detected, usually
* because it contained more than one '/', or one or more ':', or is blank.
* A single '/' is allowed, since that is used to separate the category from the
* base name.
*/
int SetPartName( const STRING& aPartName );
/**
* Function GetRevision
* returns the revision portion of the LPID.
*/
const STRING& GetRevision() const
{
return revision;
}
/**
* Function SetRevision
* overrides the revision portion of the LPID to @a aRevision and must
* be in the form "rev<num>" where "<num>" is "1", "2", etc.
* @return int - minus 1 (i.e. -1) means success, >= 0 indicates the
* character offset into the parameter at which an error was detected,
* because it did not look like "rev23"
*/
int SetRevision( const STRING& aRevision );
/**
* Function Format
* returns the full text of the LPID.
*/
STRING Format() const;
/**
* Function Format
* returns a STRING in the proper format as an LPID for a combination of
* aLogicalLib, aPartName, and aRevision.
* @throw PARSE_ERROR if any of the pieces are illegal.
*/
static STRING Format( const STRING& aLogicalLib, const STRING& aPartName, const STRING& aRevision="" )
throw( PARSE_ERROR );
void clear();
#if defined(DEBUG)
static void Test();
#endif
protected:
STRING logical; ///< logical lib name or empty
STRING category; ///< or empty
STRING baseName; ///< without category
STRING revision; ///< "revN[N..]" or empty
STRING partName; ///< cannot be set directory, set via SetBaseName() & SetCategory()
};
} // namespace SCH
/**
* Function EndsWithRev
* returns a pointer to the final string segment: "revN[N..]" or NULL if none.
* @param start is the beginning of string segment to test, the partname or
* any middle portion of it.
* @param tail is a pointer to the terminating nul, or one past inclusive end of
* segment, i.e. the string segment of interest is [start,tail)
* @param separator is the separating byte, expected: '.' or '/', depending on context.
*/
const char* EndsWithRev( const char* start, const char* tail, char separator = '/' );
static inline const char* EndsWithRev( const STRING& aPartName, char separator = '/' )
{
return EndsWithRev( aPartName.c_str(), aPartName.c_str()+aPartName.size(), separator );
}
/**
* Function RevCmp
* compares two rev strings in a way like strcmp() except that the highest numbered
* revision is considered first in the sort order. The function probably won't work
* unless you give it two rev strings.
* @param s1 is a rev string like "rev10"
* @param s2 is a rev string like "rev1".
* @return int - either negative, zero, or positive depending on whether the revision
* is greater, equal, or less on the left hand side.
*/
int RevCmp( const char* s1, const char* s2 );
#endif // SCH_LPID_H_

View File

@ -1,659 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2011 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2010 KiCad Developers, see change_log.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 <wx/wx.h> // _()
#include <sch_part.h>
#include <sch_sweet_parser.h>
#include <sch_lpid.h>
#include <sch_lib_table.h>
#include <macros.h>
/**
* Function formatAt
* outputs a formatted "(at X Y [ANGLE])" s-expression
*/
static void formatAt( OUTPUTFORMATTER* out, const SCH::POINT& aPos, ANGLE aAngle, int indent=0 )
{
// if( aPos.x || aPos.y || aAngle )
{
out->Print( indent, aAngle!=0.0 ? "(at %.6g %.6g %.6g)" : "(at %.6g %.6g)",
InternalToLogical( aPos.x ), InternalToLogical( aPos.y ),
double( aAngle ) );
}
}
static void formatStroke( OUTPUTFORMATTER* out, STROKE aStroke, int indent=0 )
{
if( aStroke == STROKE_DEFAULT )
out->Print( indent, "(stroke %.6g)", InternalToWidth( aStroke ) );
}
using namespace SCH;
PART::PART( LIB* aOwner, const STRING& aPartNameAndRev ) :
owner( aOwner ),
contains( 0 ),
partNameAndRev( aPartNameAndRev ),
extends( 0 ),
base( 0 )
{
// Our goal is to have class LIB only instantiate what is needed, so print here
// what it is doing. It is the only class where PART can be instantiated.
D(printf("PART::PART(%s)\n", aPartNameAndRev.c_str() );)
for( int i=REFERENCE; i<END; ++i )
mandatory[i] = 0;
}
void PART::clear()
{
if( extends )
{
delete extends;
extends = 0;
}
// clear the mandatory fields
for( int ndx = REFERENCE; ndx < END; ++ndx )
{
delete mandatory[ndx];
mandatory[ndx] = 0;
}
// delete properties I own, since their container will not destroy them:
for( PROPERTIES::iterator it = properties.begin(); it != properties.end(); ++it )
delete *it;
properties.clear();
// delete graphics I own, since their container will not destroy them:
for( GRAPHICS::iterator it = graphics.begin(); it != graphics.end(); ++it )
delete *it;
graphics.clear();
// delete PINs I own, since their container will not destroy them.
for( PINS::iterator it = pins.begin(); it != pins.end(); ++it )
delete *it;
pins.clear();
alternates.clear();
keywords.clear();
pin_merges.clear();
contains = 0;
}
PROPERTY* PART::FieldLookup( PROP_ID aPropertyId )
{
wxASSERT( unsigned(aPropertyId) < unsigned(END) );
PROPERTY* p = mandatory[aPropertyId];
if( !p )
{
switch( aPropertyId )
{
case REFERENCE:
p = new PROPERTY( this, wxT( "reference" ) );
p->text = wxT( "U?" );
break;
case VALUE:
p = new PROPERTY( this, wxT( "value" ) );
break;
case FOOTPRINT:
p = new PROPERTY( this, wxT( "footprint" ) );
break;
case DATASHEET:
p = new PROPERTY( this, wxT( "datasheet" ) );
break;
case MODEL:
p = new PROPERTY( this, wxT( "model" ) );
break;
default:
;
}
mandatory[aPropertyId] = p;
}
return p;
}
PROPERTY& PROPERTY::operator = ( const PROPERTY& r )
{
*(BASE_GRAPHIC*) this = (BASE_GRAPHIC&) r;
name = r.name;
text = r.text;
delete effects;
if( r.effects )
effects = new TEXT_EFFECTS( *r.effects );
else
effects = 0;
return *this;
}
PINS::iterator PART::pinFindByPad( const wxString& aPad )
{
PINS::iterator it;
for( it = pins.begin(); it != pins.end(); ++it )
{
if( (*it)->pad.text == aPad )
break;
}
return it;
}
void PART::PinsFindBySignal( PIN_LIST* aResults, const wxString& aSignal )
{
for( PINS::const_iterator it = pins.begin(); it != pins.end(); ++it )
{
if( (*it)->signal.text == aSignal )
{
aResults->push_back( *it );
}
}
}
bool PART::PinDelete( const wxString& aPad )
{
PINS::iterator it = pinFindByPad( aPad );
if( it != pins.end() )
{
delete *it;
pins.erase( it );
return true;
}
// there is only one reason this can fail: not found:
return false;
}
PART::~PART()
{
clear();
}
void PART::setExtends( LPID* aLPID )
{
delete extends;
extends = aLPID;
}
void PART::inherit( const PART& r )
{
// Inherit can be called at any time, even from an interactive text
// editor, so cannot assume 'this' object is new. Clear it.
clear();
// copy anything inherited, such as drawables, properties, pins, etc. here
contains = r.contains;
base = &r;
anchor = r.anchor;
for( int i=REFERENCE; i<END; ++i )
{
if( r.mandatory[i] )
mandatory[i] = (PROPERTY*) r.mandatory[i]->Clone( this );
}
for( PROPERTIES::const_iterator it = r.properties.begin(); it != r.properties.end(); ++it )
properties.push_back( (PROPERTY*) (*it)->Clone( this ) );
for( GRAPHICS::const_iterator it = r.graphics.begin(); it != r.graphics.end(); ++it )
graphics.push_back( (*it)->Clone( this ) );
for( PINS::const_iterator it = r.pins.begin(); it != r.pins.end(); ++it )
pins.push_back( (PIN*) (*it)->Clone( this ) );
/* not sure about this concept yet:
for( PART_REFS::const_iterator it = r.alternates.begin(); it != r.alternates.end(); ++it )
alternates.push_back( *it );
*/
for( KEYWORDS::const_iterator it = r.keywords.begin(); it != r.keywords.end(); ++it )
keywords.insert( *it );
for( MERGE_SETS::const_iterator it = r.pin_merges.begin(); it != r.pin_merges.end(); ++it )
{
pin_merges[ *it->first ] = * new MERGE_SET( *it->second );
}
}
PART& PART::operator=( const PART& r )
{
// maintain in concert with inherit(), which is a partial assignment operator.
inherit( r );
owner = r.owner;
partNameAndRev = r.partNameAndRev;
body = r.body;
base = r.base;
setExtends( r.extends ? new LPID( *r.extends ) : 0 );
return *this;
}
void PART::Parse( SWEET_PARSER* aParser , LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_ERROR )
{
aParser->Parse( this, aTable );
}
bool PART::PropDelete( const wxString& aPropertyName )
{
PROPERTIES::iterator it = propertyFind( aPropertyName );
if( it != properties.end() )
{
delete *it;
properties.erase( it );
return true;
}
return false;
}
PROPERTIES::iterator PART::propertyFind( const wxString& aPropertyName )
{
PROPERTIES::iterator it;
for( it = properties.begin(); it!=properties.end(); ++it )
if( (*it)->name == aPropertyName )
break;
return it;
}
void PART::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
{
out->Print( indent, "(part %s", partNameAndRev.c_str() );
if( extends )
out->Print( 0, " inherits %s", extends->Format().c_str() );
out->Print( 0, "\n" );
for( int i = REFERENCE; i < END; ++i )
{
PROPERTY* prop = Field( PROP_ID( i ) );
if( prop )
prop->Format( out, indent+1, ctl );
}
for( PROPERTIES::const_iterator it = properties.begin(); it != properties.end(); ++it )
{
(*it)->Format( out, indent+1, ctl );
}
if( anchor.x || anchor.y )
{
out->Print( indent+1, "(anchor (at %.6g %.6g))\n",
InternalToLogical( anchor.x ),
InternalToLogical( anchor.y ) );
}
if( keywords.size() )
{
out->Print( indent+1, "(keywords" );
for( KEYWORDS::iterator it = keywords.begin(); it != keywords.end(); ++it )
out->Print( 0, " %s", out->Quotew( *it ).c_str() );
out->Print( 0, ")\n" );
}
for( GRAPHICS::const_iterator it = graphics.begin(); it != graphics.end(); ++it )
{
(*it)->Format( out, indent+1, ctl );
}
for( PINS::const_iterator it = pins.begin(); it != pins.end(); ++it )
{
(*it)->Format( out, indent+1, ctl );
}
if( alternates.size() )
{
out->Print( indent+1, "(alternates" );
for( PART_REFS::const_iterator it = alternates.begin(); it!=alternates.end(); ++it )
out->Print( 0, " %s", out->Quotes( it->Format() ).c_str() );
out->Print( 0, ")\n" );
}
for( MERGE_SETS::const_iterator mit = pin_merges.begin(); mit != pin_merges.end(); ++mit )
{
out->Print( indent+1, "(pin_merge %s (pads", out->Quotew( mit->first ).c_str() );
const MERGE_SET& mset = *mit->second;
for( MERGE_SET::const_iterator pit = mset.begin(); pit != mset.end(); ++pit )
{
out->Print( 0, " %s", out->Quotew( *pit ).c_str() );
}
out->Print( 0, "))\n" );
}
out->Print( indent, ")\n" );
}
//-----< PART objects >------------------------------------------------------
void PROPERTY::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
{
wxASSERT( owner ); // all PROPERTYs should have an owner.
int i;
for( i = PART::REFERENCE; i < PART::END; ++i )
{
if( owner->Field( PART::PROP_ID(i) ) == this )
break;
}
if( i < PART::END ) // is a field not a property
out->Print( indent, "(%s", TO_UTF8( name ) );
else
out->Print( indent, "(property %s", out->Quotew( name ).c_str() );
if( effects )
{
out->Print( 0, " %s\n", out->Quotew( text ).c_str() );
effects->Format( out, indent+1, ctl | CTL_OMIT_NL );
out->Print( 0, ")\n" );
}
else
{
out->Print( 0, " %s)\n", out->Quotew( text ).c_str() );
}
}
TEXT_EFFECTS* PROPERTY::EffectsLookup()
{
if( !effects )
{
effects = new TEXT_EFFECTS();
}
return effects;
}
void TEXT_EFFECTS::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
{
if( propName.IsEmpty() )
out->Print( indent, "(effects " );
else
out->Print( indent, "(effects %s ", out->Quotew( propName ).c_str() );
formatAt( out, pos, angle );
font.Format( out, 0, ctl | CTL_OMIT_NL );
out->Print( 0, "(visible %s))%s",
isVisible ? "yes" : "no",
ctl & CTL_OMIT_NL ? "" : "\n" );
}
void FONT::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
{
if( italic || bold || !name.IsEmpty() || size.height != FONTZ_DEFAULT || size.width != FONTZ_DEFAULT )
{
if( name.IsEmpty() )
out->Print( indent, "(font " );
else
out->Print( indent, "(font %s ", out->Quotew( name ).c_str() );
out->Print( 0, "(size %.6g %.6g)",
InternalToFontz( size.height ),
InternalToFontz( size.width ) );
if( italic )
out->Print( 0, " italic" );
if( bold )
out->Print( 0, " bold" );
out->Print( 0, ")%s", (ctl & CTL_OMIT_NL) ? "" : "\n" );
}
}
void PIN::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
{
bool hasSignal = !signal.text.IsEmpty();
bool hasPad = !pad.text.IsEmpty();
out->Print( indent, "(pin" );
if( connectionType != PIN_CONN_DEFAULT )
out->Print( 0, " %s", ShowType() );
if( shape != PIN_SHAPE_DEFAULT )
out->Print( 0, " %s", ShowShape() );
out->Print( 0, " " );
if( pos.x || pos.y || angle )
formatAt( out, pos, angle );
if( length != PIN_LEN_DEFAULT )
out->Print( 0, "(length %.6g)", InternalToLogical( length ) );
if( !isVisible )
out->Print( 0, "(visible %s)", isVisible ? "yes" : "no" );
if( hasSignal )
signal.Format( out, "signal", 0, CTL_OMIT_NL );
if( hasPad )
pad.Format( out, "pad", 0, CTL_OMIT_NL );
out->Print( 0, ")\n" );
}
PIN::~PIN()
{
}
void PINTEXT::Format( OUTPUTFORMATTER* out, const char* aElement, int indent, int ctl ) const
{
out->Print( indent, "(%s %s", aElement, out->Quotew( text ).c_str() );
font.Format( out, 0, CTL_OMIT_NL );
if( !isVisible )
out->Print( 0, " (visible %s)", isVisible ? "yes" : "no" );
out->Print( 0, ")%s", ctl & CTL_OMIT_NL ? "" : "\n" );
}
void POLY_LINE::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
{
out->Print( indent, "(%s ", pts.size() == 2 ? "line" : "polyline" );
formatContents( out, indent, ctl );
}
void POLY_LINE::formatContents( OUTPUTFORMATTER* out, int indent, int ctl ) const
{
formatStroke( out, stroke );
if( fillType != PR::T_none )
out->Print( 0, "(fill %s)", ShowFill( fillType ) );
out->Print( 0, "\n" );
if( pts.size() )
{
const int maxLength = 75;
int len = 10;
len += out->Print( indent+1, "(pts " );
for( POINTS::const_iterator it = pts.begin(); it != pts.end(); ++it )
{
if( len > maxLength )
{
len = 10;
out->Print( 0, "\n" );
out->Print( indent+2, "(xy %.6g %.6g)",
InternalToLogical( it->x ), InternalToLogical( it->y ) );
}
else
out->Print( 0, "(xy %.6g %.6g)",
InternalToLogical( it->x ), InternalToLogical( it->y ) );
}
out->Print( 0, ")" );
}
out->Print( 0, ")\n" );
}
void BEZIER::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
{
out->Print( indent, "(bezier " );
formatContents( out, indent, ctl ); // inherited from POLY_LINE
}
void RECTANGLE::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
{
// (rectangle (start X Y) (end X Y) [(stroke WIDTH)] (fill FILL_TYPE))
out->Print( indent, "(rectangle (start %.6g %.6g)(end %.6g %.6g)",
InternalToLogical( start.x ), InternalToLogical( start.y ),
InternalToLogical( end.x ), InternalToLogical( end.y )
);
formatStroke( out, stroke );
if( fillType != PR::T_none )
out->Print( 0, "(fill %s)", ShowFill( fillType ) );
out->Print( 0, ")\n" );
}
void CIRCLE::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
{
/*
(circle (center X Y)(radius LENGTH) [(stroke WIDTH)] (fill FILL_TYPE))
*/
out->Print( indent, "(circle (center %.6g %.6g)(radius %.6g)",
InternalToLogical( center.x ), InternalToLogical( center.y ),
InternalToLogical( radius) );
formatStroke( out, stroke );
if( fillType != PR::T_none )
out->Print( 0, "(fill %s)", ShowFill( fillType ) );
out->Print( 0, ")\n" );
}
void ARC::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
{
/*
(arc (pos X Y)(radius RADIUS)(start X Y)(end X Y) [(stroke WIDTH)] (fill FILL_TYPE))
*/
out->Print( indent, "(arc (pos %.6g %.6g)(radius %.6g)(start %.6g %.6g)(end %.6g %.6g)",
InternalToLogical( pos.x ), InternalToLogical( pos.y ),
InternalToLogical( radius),
InternalToLogical( start.x ), InternalToLogical( start.y ),
InternalToLogical( end.x ), InternalToLogical( end.y )
);
formatStroke( out, stroke );
if( fillType != PR::T_none )
out->Print( 0, "(fill %s)", ShowFill( fillType ) );
out->Print( 0, ")\n" );
}
void GR_TEXT::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
{
/*
(text "This is the text that gets drawn."
(at X Y [ANGLE])(justify HORIZONTAL_JUSTIFY VERTICAL_JUSTIFY)(visible YES)(fill FILL_TYPE)
(font [FONT] (size HEIGHT WIDTH) [italic] [bold])
)
*/
out->Print( indent, "(text %s\n", out->Quotew( text ).c_str() );
formatAt( out, pos, angle, indent+1 );
if( hjustify != PR::T_left || vjustify != PR::T_bottom )
out->Print( 0, "(justify %s %s)",
ShowJustify( hjustify ), ShowJustify( vjustify ) );
if( !isVisible )
out->Print( 0, "(visible %s)", isVisible ? "yes" : "no" );
if( fillType != PR::T_filled )
out->Print( 0, "(fill %s)", ShowFill( fillType ) );
font.Format( out, 0, CTL_OMIT_NL );
out->Print( 0, ")\n" );
}

View File

@ -1,894 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2011 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2010 KiCad Developers, see change_log.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 SCH_PART_H_
#define SCH_PART_H_
#include <sch_lib.h>
#include <sch_lib_table.h>
#include <sch_lpid.h>
//#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/ptr_container/ptr_map.hpp>
#define INTERNAL_PER_LOGICAL 10000 ///< no. internal units per logical unit
/**
* Function InternalToLogical
* converts an internal coordinate to a logical coordinate. Logical coordinates
* are defined as the standard distance between pins being equal to one.
* Internal coordinates are currently INTERNAL_PER_LOGICAL times that.
*/
static inline double InternalToLogical( int aCoord )
{
return double( aCoord ) / INTERNAL_PER_LOGICAL;
}
/**
* Function LogicalToInternal
* converts a logical coordinate to an internal coordinate. Logical coordinates
* are defined as the standard distance between pins being equal to one.
* Internal coordinates are currently INTERNAL_PER_LOGICAL times that.
*/
static inline int LogicalToInternal( double aCoord )
{
return int( aCoord * INTERNAL_PER_LOGICAL );
}
static inline int WidthToInternal( double aWidth )
{
// sweet line widths are a "percent of a logical unit"
return LogicalToInternal( aWidth ) / 100;
}
static inline double InternalToWidth( int aWidth )
{
// sweet line widths are a "percent of a logical unit"
return InternalToLogical( aWidth ) * 100;
}
static inline int FontzToInternal( double aFontSize )
{
// sweet font sizes are deci-pins
return LogicalToInternal( aFontSize ) / 10;
}
static inline double InternalToFontz( int aFontSize )
{
// sweet font sizes are deci-pins
return InternalToLogical( aFontSize ) * 10;
}
//-----<temporary home for PART sub objects, move after stable>------------------
#include <wx/gdicmn.h>
#include <deque>
#include <vector>
#include <set>
#include <sweet_lexer.h>
class OUTPUTFORMATTER;
/// Control Bits for Format() functions
#define CTL_OMIT_NL (1<<0) ///< omit new line in Format()s.
namespace SCH {
class PART;
class SWEET_PARSER;
class PROPERTY;
class POINT : public wxPoint
{
public:
POINT( int x, int y ) :
wxPoint( x, y )
{}
POINT( const POINT& r ) :
wxPoint( r )
{}
POINT() :
wxPoint()
{}
// assume assignment operator is inherited.
};
};
/// a set of pin padnames that are electrically equivalent for a PART.
typedef std::set< wxString > MERGE_SET;
/// The key is the VISIBLE_PIN from
/// (pin_merge VISIBLE_PIN (hide HIDDEN_PIN1 HIDDEN_PIN2...))
typedef boost::ptr_map< wxString, MERGE_SET > MERGE_SETS;
/**
* FONTZ
* is the size of a font, and comes with a constructor which initializes
* height and width to special values which defer font size decision to
* a higher control.
*/
class FONTZ
{
public:
#define FONTZ_DEFAULT -1 ///< when size defers to higher control
FONTZ() :
height( FONTZ_DEFAULT ),
width( FONTZ_DEFAULT )
{}
int height;
int width;
};
typedef float ANGLE;
typedef int STROKE; ///< will be a class someday, currently only line width
namespace SCH {
class FONT
{
friend class PART;
friend class SWEET_PARSER;
protected:
wxString name; ///< name or other id such as number, TBD
FONTZ size;
bool italic;
bool bold;
public:
FONT() :
italic( false ),
bold( false )
{}
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const;
// trust compiler to write its own assignment operator for this class OK.
};
struct TEXT_EFFECTS
{
POINT pos;
ANGLE angle;
FONT font;
bool isVisible;
PROPERTY* property; ///< only used from a COMPONENT, specifies PROPERTY in PART
wxString propName; ///< only used from a COMPONENT, specifies PROPERTY in PART
TEXT_EFFECTS() :
angle( 0 ),
isVisible( false ),
property( 0 )
{}
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const;
// trust compiler to write its own assignment operator for this class OK.
};
#define STROKE_DEFAULT -1 ///< defer line width decision to higher control
#define FILL_TYPE_DEFAULT PR::T_none ///< fillType defaut
class BASE_GRAPHIC
{
friend class PART;
friend class SWEET_PARSER;
protected:
PART* owner;
PART* birthplace; ///< at which PART in inheritance chain was 'this' added
public:
BASE_GRAPHIC( PART* aOwner ) :
owner( aOwner ),
birthplace( aOwner )
{}
virtual ~BASE_GRAPHIC() {}
/**
* Function Clone
* invokes the copy constructor on a heap allocated object of this same
* type and creates a deep copy of 'this' into it
* @param aOwner is the owner of the returned, new object.
*/
virtual BASE_GRAPHIC* Clone( PART* aOwner ) const = 0;
static const char* ShowFill( int aFillType )
{
return SWEET_LEXER::TokenName( PR::T( aFillType ) );
}
/**
* Function Format
* outputs this object to @a aFormatter in s-expression form.
*/
virtual void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
{}
};
typedef std::deque<POINT> POINTS;
class POLY_LINE : public BASE_GRAPHIC
{
friend class PART;
friend class SWEET_PARSER;
protected:
STROKE stroke;
int fillType; // T_none, T_filled, or T_transparent
POINTS pts;
void formatContents( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const;
public:
POLY_LINE( PART* aOwner ) :
BASE_GRAPHIC( aOwner ),
stroke( STROKE_DEFAULT ),
fillType( PR::T_none )
{
}
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const;
BASE_GRAPHIC* Clone( PART* aOwner ) const
{
POLY_LINE* n = new POLY_LINE( *this );
n->owner = aOwner;
return n;
}
};
class BEZIER : public POLY_LINE
{
friend class PART;
friend class SWEET_PARSER;
public:
BEZIER( PART* aOwner ) :
POLY_LINE( aOwner )
{
stroke = STROKE_DEFAULT;
fillType = PR::T_none;
}
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const;
BASE_GRAPHIC* Clone( PART* aOwner ) const
{
BEZIER* n = new BEZIER( *this );
n->owner = aOwner;
return n;
}
};
class RECTANGLE : public BASE_GRAPHIC
{
friend class PART;
friend class SWEET_PARSER;
protected:
STROKE stroke;
int fillType; // T_none, T_filled, or T_transparent
POINT start;
POINT end;
public:
RECTANGLE( PART* aOwner ) :
BASE_GRAPHIC( aOwner ),
stroke( STROKE_DEFAULT ),
fillType( FILL_TYPE_DEFAULT )
{
}
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const;
BASE_GRAPHIC* Clone( PART* aOwner ) const
{
RECTANGLE* n = new RECTANGLE( *this );
n->owner = aOwner;
return n;
}
};
class CIRCLE : public BASE_GRAPHIC
{
friend class PART;
friend class SWEET_PARSER;
protected:
POINT center;
int radius;
STROKE stroke;
int fillType; // T_none, T_filled, or T_transparent
public:
CIRCLE( PART* aOwner ) :
BASE_GRAPHIC( aOwner ),
radius( LogicalToInternal( 0.5 ) ),
stroke( STROKE_DEFAULT ),
fillType( FILL_TYPE_DEFAULT )
{
}
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const;
BASE_GRAPHIC* Clone( PART* aOwner ) const
{
CIRCLE* n = new CIRCLE( *this );
n->owner = aOwner;
return n;
}
};
class ARC : public BASE_GRAPHIC
{
friend class PART;
friend class SWEET_PARSER;
protected:
POINT pos;
STROKE stroke;
int fillType; // T_none, T_filled, or T_transparent
int radius;
POINT start;
POINT end;
public:
ARC( PART* aOwner ) :
BASE_GRAPHIC( aOwner ),
stroke( STROKE_DEFAULT ),
fillType( FILL_TYPE_DEFAULT ),
radius( LogicalToInternal( 0.5 ) )
{
}
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const;
BASE_GRAPHIC* Clone( PART* aOwner ) const
{
ARC* n = new ARC( *this );
n->owner = aOwner;
return n;
}
};
class GR_TEXT : public BASE_GRAPHIC
{
friend class PART;
friend class SWEET_PARSER;
protected:
POINT pos;
ANGLE angle;
int fillType; ///< T_none, T_filled, or T_transparent
int hjustify; ///< T_center, T_right, or T_left
int vjustify; ///< T_center, T_top, or T_bottom
bool isVisible;
wxString text;
FONT font;
public:
GR_TEXT( PART* aOwner ) :
BASE_GRAPHIC( aOwner ),
angle( 0 ),
fillType( PR::T_filled ),
hjustify( PR::T_left ),
vjustify( PR::T_bottom ),
isVisible( true )
{}
static const char* ShowJustify( int aJustify )
{
return SWEET_LEXER::TokenName( PR::T( aJustify ) );
}
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const;
BASE_GRAPHIC* Clone( PART* aOwner ) const
{
GR_TEXT* n = new GR_TEXT( *this );
n->owner = aOwner;
return n;
}
};
class PROPERTY : public BASE_GRAPHIC
{
friend class PART;
friend class SWEET_PARSER;
protected:
wxString name;
wxString text;
TEXT_EFFECTS* effects;
void clear()
{
delete effects;
effects = 0;
name = wxEmptyString;
text = wxEmptyString;
}
public:
PROPERTY( PART* aOwner, const wxChar* aName = wxT( "" ) ) :
BASE_GRAPHIC( aOwner ),
name( aName ),
effects( 0 )
{}
PROPERTY( const PROPERTY& r ) :
BASE_GRAPHIC( NULL ),
effects( 0 )
{
// use assignment operator
*this = r;
}
PROPERTY& operator = ( const PROPERTY& r ); // @todo
~PROPERTY()
{
clear();
}
/**
* Function Effects
* returns a pointer to the TEXT_EFFECTS object for this PROPERTY, and optionally
* will lazily allocate one if it did not exist previously.
* @param doAlloc if true, means do an allocation of a new TEXT_EFFECTS if one
* currently does not exist, otherwise return NULL if non-existent.
*/
TEXT_EFFECTS* EffectsLookup();
TEXT_EFFECTS* Effects() const
{
return effects;
}
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const;
BASE_GRAPHIC* Clone( PART* aOwner ) const
{
PROPERTY* n = new PROPERTY( *this );
n->owner = aOwner;
return n;
}
};
struct PINTEXT
{
wxString text;
FONT font;
bool isVisible;
PINTEXT() :
isVisible( true )
{}
void Format( OUTPUTFORMATTER* aFormatter, const char* aElement, int aNestLevel, int aControlBits ) const;
};
#define PIN_LEN_DEFAULT -1 ///< use standard pin length for given type
#define PIN_SHAPE_DEFAULT PR::T_line ///< use standard pin shape
#define PIN_CONN_DEFAULT PR::T_in ///< use standard pin connection type
class PIN : public BASE_GRAPHIC
{
friend class PART;
friend class SWEET_PARSER;
public:
PIN( PART* aOwner ) :
BASE_GRAPHIC( aOwner ),
angle( 0 ),
connectionType( PIN_CONN_DEFAULT ),
shape( PIN_SHAPE_DEFAULT ),
length( PIN_LEN_DEFAULT ),
isVisible( true )
{}
~PIN();
const char* ShowType() const
{
return SWEET_LEXER::TokenName( PR::T( connectionType ) );
}
const char* ShowShape() const
{
return SWEET_LEXER::TokenName( PR::T( shape ) );
}
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const;
BASE_GRAPHIC* Clone( PART* aOwner ) const
{
PIN* n = new PIN( *this );
n->owner = aOwner;
return n;
}
protected:
POINT pos;
ANGLE angle;
PINTEXT pad;
PINTEXT signal;
int connectionType; ///< T_in, T_out, T_inout, T_tristate, T_passive, T_unspecified,
///< T_power_in, T_power_out, T_open_collector, T_open_emitter, or T_unconnected.
int shape; ///< T_none, T_line, T_inverted, T_clock, T_inverted_clk, T_input_low, T_clock_low,
///< T_falling_edge, T_non_logic.
int length; ///< length of pin in internal units
bool isVisible; ///< pin is visible
wxString pin_merge; ///< pad of (pin_merge ...) that I am a member of, else empty if none
};
/**
* PART_REF
* is an LPID with a pointer to the "looked up" PART, which is looked up lazily.
*/
class PART_REF : public LPID
{
public:
PART_REF() :
LPID(),
part(0)
{}
/**
* Constructor LPID
* takes aLPID string and parses it. A typical LPID string uses a logical
* library name followed by a part name.
* e.g.: "kicad:passives/R/rev2", or
* e.g.: "mylib:R33"
*/
PART_REF( const STRING& aLPID ) throw( PARSE_ERROR ) :
LPID( aLPID ),
part(0)
{
}
/**
* Function Lookup
* returns the PART that this LPID refers to. Never returns NULL, because
* instead an exception would be thrown.
* @throw IO_ERROR if any problem occurs or if the part cannot be found.
*/
PART* Lookup( LIB_TABLE* aLibTable, LIB* aFallBackLib )
{
if( !part )
{
part = aLibTable->LookupPart( *this, aFallBackLib );
}
return part;
}
protected:
PART* part; ///< The looked-up PART,
///< no ownership (duh, PARTs are always owned by a LIB)
};
typedef std::vector<PART_REF> PART_REFS;
} // namespace SCH
//-----</temporary home for PART sub objects, move after stable>-----------------
typedef std::set< wxString > KEYWORDS;
namespace SCH {
typedef std::vector< BASE_GRAPHIC* > GRAPHICS;
typedef std::vector< PROPERTY* > PROPERTIES;
typedef std::vector< PIN* > PINS;
typedef std::vector< PIN* > PIN_LIST; ///< no ownership, used for searches
class LPID;
class SWEET_PARSER;
/**
* PART
* will have to be unified with what Wayne is doing. I want a separate copy
* here until I can get the state management correct. Since a PART only lives
* within a cache called a LIB, its constructor is private (only a LIB
* can instantiate one), and it exists in various states of freshness and
* completeness relative to the LIB_SOURCE within the LIB.
*/
class PART
{
friend class LIB; // is the owner of all PARTS, afterall
friend class SWEET_PARSER;
public:
/**
* Enum PROP_ID
* is the set of "mandatory" properties within a PART. These are used by
* PART as array indices into PART::mandatory[].
*/
enum PROP_ID
{
REFERENCE, ///< reference prefix, a template for instantiation at COMPONENT level
VALUE, ///< value, e.g. "3.3K"
FOOTPRINT, ///< name of PCB module, e.g. "16DIP300"
DATASHEET, ///< URI of datasheet
MODEL, ///< spice model name
END ///< array sentinel, not a valid index
};
virtual ~PART();
PART& operator = ( const PART& other );
/**
* Function Owner
* returns the LIB* owner of this part.
*/
LIB* Owner() { return owner; }
/**
* Function Parse
* translates a Sweet string into a binary form that is represented
* by the normal fields of this class. Parse is expected to call Inherit()
* if this part extends any other.
*
* @param aParser is an instance of SWEET_PARSER, rewound at the first line.
*
* @param aLibTable is the LIB_TABLE "view" that is in effect for inheritance,
* and comes from the big containing SCHEMATIC object.
*/
void Parse( SWEET_PARSER* aParser, LIB_TABLE* aLibTable ) throw( IO_ERROR, PARSE_ERROR );
/**
* Function Format
* outputs this PART in UTF8 encoded s-expression format to @a aFormatter.
* @param aFormatter is the output sink to write to.
* @param aNestLevel is the initial indent level
* @param aControlBits are bit flags ORed together which control how the output
* is done.
*/
void Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits = 0 ) const;
/**
* Function PropDelete
* deletes the property with aPropertyName if found and returns true, else false
* if not found.
*/
bool PropDelete( const wxString& aPropertyName );
/**
* Function Field
* returns a pointer to one of the mandatory properties, or NULL
* if non-existent. Use FieldLookup() to potentially allocate it.
*/
PROPERTY* Field( PROP_ID aPropertyId ) const
{
wxASSERT( unsigned(aPropertyId) < unsigned(END) );
return mandatory[aPropertyId];
}
/**
* Function FieldLookup
* returns a pointer to one of the mandatory properties, which is lazily
* constructed by this function if need be.
* @param aPropertyId tells which field.
*/
PROPERTY* FieldLookup( PROP_ID aPropertyId );
/**
* Function PinFindByPad
* finds a PIN based on aPad or returns NULL if not found.
* @param aPad is the pin to find
* @return PIN* - the found PIN or NULL if not found.
*/
PIN* PinFindByPad( const wxString& aPad )
{
PINS::iterator it = pinFindByPad( aPad );
return it != pins.end() ? *it : NULL;
}
/**
* Function PinsFindBySignal
* fetches all the pins matching aSignal into aResults.
*/
void PinsFindBySignal( PIN_LIST* aResults, const wxString& aSignal );
/**
* Function PinDelete
* deletes the pin with aPad if found and returns true, else false
* if not found.
*/
bool PinDelete( const wxString& aPad );
/*
void SetValue( const wxString& aValue )
{
value = aValue;
}
const wxString& GetValue()
{
return value;
}
void SetFootprint( const wxString& aFootprint )
{
footprint = aFootprint;
}
const wxString& GetFootprint()
{
return footprint;
}
void SetModel( const wxString& aModel )
{
model = aModel;
}
const wxString& GetModel()
{
return model;
}
*/
/*
void SetBody( const STR_UTF& aSExpression )
{
body = aSExpression;
}
*/
protected: // not likely to have C++ descendants, but protected none-the-less.
/// a protected constructor, only a LIB can instantiate a PART.
PART( LIB* aOwner, const STRING& aPartNameAndRev );
/**
* Function destroy
* clears out this object, deleting everything that this PART owns and
* initializing values back to a state as if the object was just constructed
* empty.
*/
void clear();
/**
* Function inherit
* is a specialized assignment function that copies a specific subset, enough
* to fulfill the requirements of the Sweet s-expression language.
*/
void inherit( const PART& aBasePart );
/**
* Function propertyFind
* searches for aPropertyName and returns a PROPERTIES::iterator which
* is the found item or properties.end() if not found.
*/
PROPERTIES::iterator propertyFind( const wxString& aPropertyName );
/**
* Function pinFindByPad
* searches for a PIN with aPad and returns a PROPERTIES::iterator which
* is the found item or pins.end() if not found.
*/
PINS::iterator pinFindByPad( const wxString& aPad );
LIB* owner; ///< which LIB am I a part of (pun if you want)
int contains; ///< has bits from Enum PartParts
STRING partNameAndRev; ///< example "passives/R[/revN..]", immutable.
LPID* extends; ///< of base part, NULL if none, otherwise I own it.
const PART* base; ///< which PART am I extending, if any. no ownership.
POINT anchor;
/// encapsulate the old version deletion, take ownership of @a aLPID
void setExtends( LPID* aLPID );
/// s-expression text for the part, initially empty, and read in as this part
/// actually becomes cached in RAM.
STRING body;
/// mandatory properties, aka fields. Index into mandatory[] is PROP_ID.
PROPERTY* mandatory[END];
/**
* Member properties
* holds the non-mandatory properties.
*/
PROPERTIES properties;
/**
* Member graphics
* owns : POLY_LINE, RECTANGLE, CIRCLE, ARC, BEZIER, and GR_TEXT objects.
*/
GRAPHICS graphics;
/**
* Member pins
* owns all the PINs in pins.
*/
PINS pins;
/// Alternate body forms.
PART_REFS alternates;
/// searching aids
KEYWORDS keywords;
/**
* A pin_merge set is a set of pins that are all electrically equivalent
* and whose anchor pin is the only one visible. The visible pin is the
* key in the MERGE_SETS boost::ptr_map::map
*/
MERGE_SETS pin_merges;
};
} // namespace PART
#endif // SCH_PART_

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More