2008-01-21 20:53:35 +00:00
|
|
|
/*
|
2011-09-30 18:15:37 +00:00
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
2008-01-21 20:53:35 +00:00
|
|
|
*
|
2013-05-01 15:48:00 +00:00
|
|
|
* Copyright (C) 2007-2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2023-04-01 13:11:56 +00:00
|
|
|
* Copyright (C) 2007-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2008-02-07 20:23:58 +00:00
|
|
|
*
|
2008-01-21 20:53:35 +00:00
|
|
|
* 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.
|
2008-02-07 20:23:58 +00:00
|
|
|
*
|
2008-01-21 20:53:35 +00:00
|
|
|
* 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.
|
2008-02-07 20:23:58 +00:00
|
|
|
*
|
2008-01-21 20:53:35 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
2008-02-07 20:23:58 +00:00
|
|
|
* 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.,
|
2008-01-21 20:53:35 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2008-01-21 22:16:45 +00:00
|
|
|
#ifndef SPECCTRA_H_
|
|
|
|
#define SPECCTRA_H_
|
|
|
|
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 22:16:45 +00:00
|
|
|
// see http://www.boost.org/libs/ptr_container/doc/ptr_sequence_adapter.html
|
|
|
|
#include <boost/ptr_container/ptr_vector.hpp>
|
|
|
|
|
2008-02-14 01:07:52 +00:00
|
|
|
// see http://www.boost.org/libs/ptr_container/doc/ptr_set.html
|
|
|
|
#include <boost/ptr_container/ptr_set.hpp>
|
|
|
|
|
2019-07-03 09:08:55 +00:00
|
|
|
#include <specctra_import_export/specctra_lexer.h>
|
2010-04-06 14:09:52 +00:00
|
|
|
|
2016-06-29 15:09:55 +00:00
|
|
|
#include <memory>
|
2021-07-07 14:40:19 +00:00
|
|
|
#include <geometry/shape_poly_set.h>
|
2016-06-29 15:09:55 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
// all outside the DSN namespace:
|
2011-09-23 13:57:12 +00:00
|
|
|
class BOARD;
|
2021-06-11 21:07:02 +00:00
|
|
|
class PCB_TRACK;
|
|
|
|
class PCB_VIA;
|
2011-09-23 13:57:12 +00:00
|
|
|
class NETCLASS;
|
2020-11-13 15:15:52 +00:00
|
|
|
class FOOTPRINT;
|
2015-07-27 19:45:57 +00:00
|
|
|
class SHAPE_POLY_SET;
|
2008-01-29 16:45:14 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
typedef DSN::T DSN_T;
|
2008-01-21 22:16:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* This source file implements export and import capabilities to the
|
|
|
|
* specctra dsn file format. The grammar for that file format is documented
|
|
|
|
* fairly well. There are classes for each major type of descriptor in the
|
|
|
|
* spec.
|
|
|
|
*
|
|
|
|
* Since there are so many classes in here, it may be helpful to generate
|
|
|
|
* the Doxygen directory:
|
|
|
|
*
|
|
|
|
* $ cd <kicadSourceRoot>
|
|
|
|
* $ doxygen
|
|
|
|
*
|
|
|
|
* Then you can view the html documentation in the <kicadSourceRoot>/doxygen
|
|
|
|
* directory. The main class in this file is SPECCTRA_DB and its main
|
|
|
|
* functions are LoadPCB(), LoadSESSION(), and ExportPCB().
|
|
|
|
*
|
|
|
|
* Wide use is made of boost::ptr_vector<> and std::vector<> template classes.
|
|
|
|
* If the contained object is small, then std::vector tends to be used.
|
|
|
|
* If the contained object is large, variable size, or would require writing
|
|
|
|
* an assignment operator() or copy constructor, then boost::ptr_vector
|
|
|
|
* cannot be beat.
|
|
|
|
*/
|
2008-01-21 20:53:35 +00:00
|
|
|
namespace DSN {
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-29 16:45:14 +00:00
|
|
|
|
2009-12-11 04:55:24 +00:00
|
|
|
class SPECCTRA_DB;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
|
|
|
|
2023-11-20 03:06:27 +00:00
|
|
|
/**
|
|
|
|
* @brief Helper method to export board to DSN file
|
|
|
|
* @param aBoard board object
|
|
|
|
* @param aFullFilename specctra file name
|
|
|
|
*/
|
|
|
|
void ExportBoardToSpecctraFile( BOARD* aBoard, const wxString& aFullFilename );
|
|
|
|
|
|
|
|
|
2009-12-11 04:55:24 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* The DSN namespace and returns the C string representing a SPECCTRA_DB::keyword.
|
|
|
|
*
|
|
|
|
* We needed a non-instance function to get at the SPECCTRA_DB::keyword[] and class
|
|
|
|
* SPECCTRA_DB is not defined yet.
|
2009-12-11 04:55:24 +00:00
|
|
|
*/
|
2011-01-19 20:46:07 +00:00
|
|
|
const char* GetTokenText( T aTok );
|
2008-01-29 16:45:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* A point in the SPECCTRA DSN coordinate system.
|
|
|
|
*
|
|
|
|
* It can also be used to hold a distance (vector really) from some origin.
|
2008-01-29 16:45:14 +00:00
|
|
|
*/
|
2008-01-21 20:53:35 +00:00
|
|
|
struct POINT
|
|
|
|
{
|
2008-01-22 20:48:02 +00:00
|
|
|
double x;
|
|
|
|
double y;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
POINT() { x=0.0; y=0.0; }
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-24 21:47:54 +00:00
|
|
|
POINT( double aX, double aY ) :
|
|
|
|
x(aX), y(aY)
|
|
|
|
{
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-22 20:48:02 +00:00
|
|
|
bool operator==( const POINT& other ) const
|
|
|
|
{
|
|
|
|
return x==other.x && y==other.y;
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-22 20:48:02 +00:00
|
|
|
bool operator!=( const POINT& other ) const
|
|
|
|
{
|
|
|
|
return !( *this == other );
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-25 22:03:36 +00:00
|
|
|
POINT& operator+=( const POINT& other )
|
|
|
|
{
|
|
|
|
x += other.x;
|
|
|
|
y += other.y;
|
|
|
|
return *this;
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-25 22:03:36 +00:00
|
|
|
POINT& operator=( const POINT& other )
|
|
|
|
{
|
|
|
|
x = other.x;
|
|
|
|
y = other.y;
|
2008-02-07 20:23:58 +00:00
|
|
|
return *this;
|
2008-01-25 22:03:36 +00:00
|
|
|
}
|
|
|
|
|
2008-01-29 16:45:14 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Change negative zero to positive zero in the IEEE floating point storage format.
|
|
|
|
*
|
|
|
|
* Basically turns off the sign bit if the mantissa and exponent say the value is otherwise
|
|
|
|
* zero.
|
2008-01-29 16:45:14 +00:00
|
|
|
*/
|
|
|
|
void FixNegativeZero()
|
|
|
|
{
|
|
|
|
if( x == -0.0 )
|
|
|
|
x = 0.0;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-01-29 16:45:14 +00:00
|
|
|
if( y == -0.0 )
|
|
|
|
y = 0.0;
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
|
|
|
|
*
|
2008-01-21 20:53:35 +00:00
|
|
|
* @param out The formatter to write to.
|
2021-06-09 19:32:58 +00:00
|
|
|
* @param nestLevel A multiple of the number of spaces to precede the output with.
|
2010-11-09 15:45:11 +00:00
|
|
|
* @throw IO_ERROR if a system error writing the output, such as a full disk.
|
2008-01-21 20:53:35 +00:00
|
|
|
*/
|
2017-06-08 21:47:21 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) const
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2008-02-07 20:23:58 +00:00
|
|
|
out->Print( nestLevel, " %.6g %.6g", x, y );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<std::string> STRINGS;
|
|
|
|
typedef std::vector<POINT> POINTS;
|
|
|
|
|
|
|
|
struct PROPERTY
|
|
|
|
{
|
|
|
|
std::string name;
|
|
|
|
std::string value;
|
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
|
|
|
|
*
|
2008-01-21 20:53:35 +00:00
|
|
|
* @param out The formatter to write to.
|
2021-06-09 19:32:58 +00:00
|
|
|
* @param nestLevel A multiple of the number of spaces to precede the output with.
|
2010-11-09 15:45:11 +00:00
|
|
|
* @throw IO_ERROR if a system error writing the output, such as a full disk.
|
2008-01-21 20:53:35 +00:00
|
|
|
*/
|
2017-06-08 21:47:21 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) const
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
const char* quoteName = out->GetQuoteChar( name.c_str() );
|
|
|
|
const char* quoteValue = out->GetQuoteChar( value.c_str() );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
|
|
|
out->Print( nestLevel, "(%s%s%s %s%s%s)\n",
|
2008-01-21 20:53:35 +00:00
|
|
|
quoteName, name.c_str(), quoteName,
|
|
|
|
quoteValue, value.c_str(), quoteValue );
|
|
|
|
}
|
|
|
|
};
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
typedef std::vector<PROPERTY> PROPERTIES;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UNIT_RES;
|
2008-01-21 20:53:35 +00:00
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* A base class for any DSN element class.
|
|
|
|
*
|
|
|
|
* See class #ELEM_HOLDER also.
|
2008-02-07 20:23:58 +00:00
|
|
|
*/
|
2008-01-21 20:53:35 +00:00
|
|
|
class ELEM
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
ELEM( DSN_T aType, ELEM* aParent = nullptr );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
virtual ~ELEM();
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-29 16:45:14 +00:00
|
|
|
DSN_T Type() const { return type; }
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2009-12-11 04:55:24 +00:00
|
|
|
const char* Name() const;
|
|
|
|
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Return the units for this section.
|
|
|
|
*
|
|
|
|
* Derived classes may override this to check for section specific overrides.
|
|
|
|
*
|
|
|
|
* @return an element from a local or parent scope.
|
2008-01-21 20:53:35 +00:00
|
|
|
*/
|
2008-02-07 20:23:58 +00:00
|
|
|
virtual UNIT_RES* GetUnits() const;
|
2008-01-21 20:53:35 +00:00
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Write this object as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
|
|
|
|
*
|
2008-01-21 20:53:35 +00:00
|
|
|
* @param out The formatter to write to.
|
2021-06-09 19:32:58 +00:00
|
|
|
* @param nestLevel A multiple of the number of spaces to precede the output with.
|
2010-11-09 15:45:11 +00:00
|
|
|
* @throw IO_ERROR if a system error writing the output, such as a full disk.
|
2008-01-21 20:53:35 +00:00
|
|
|
*/
|
2017-06-08 21:47:21 +00:00
|
|
|
virtual void Format( OUTPUTFORMATTER* out, int nestLevel );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Write the contents as ASCII out to an OUTPUTFORMATTER according to the SPECCTRA DSN format.
|
|
|
|
*
|
|
|
|
* This is the same as Format() except that the outer wrapper is not included.
|
|
|
|
*
|
2008-01-21 20:53:35 +00:00
|
|
|
* @param out The formatter to write to.
|
2021-06-09 19:32:58 +00:00
|
|
|
* @param nestLevel A multiple of the number of spaces to precede the output with.
|
2010-11-09 15:45:11 +00:00
|
|
|
* @throw IO_ERROR if a system error writing the output, such as a full disk.
|
2008-01-21 20:53:35 +00:00
|
|
|
*/
|
2017-06-08 21:47:21 +00:00
|
|
|
virtual void FormatContents( OUTPUTFORMATTER* out, int nestLevel )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
// overridden in ELEM_HOLDER
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-22 20:48:02 +00:00
|
|
|
void SetParent( ELEM* aParent )
|
|
|
|
{
|
|
|
|
parent = aParent;
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a string which uniquely represents this ELEM among other ELEMs of the same
|
|
|
|
* derived class as "this" one.
|
|
|
|
*
|
|
|
|
* It is not usable for all derived classes, only those which plan for
|
|
|
|
* it by implementing a FormatContents() function that captures all info
|
|
|
|
* which will be used in the subsequent string compare. THIS SHOULD
|
|
|
|
* NORMALLY EXCLUDE THE TYPENAME, AND INSTANCE NAME OR ID AS WELL.
|
|
|
|
*/
|
|
|
|
std::string makeHash()
|
|
|
|
{
|
|
|
|
sf.Clear();
|
|
|
|
FormatContents( &sf, 0 );
|
|
|
|
sf.StripUseless();
|
|
|
|
|
|
|
|
return sf.GetString();
|
|
|
|
}
|
|
|
|
|
|
|
|
// avoid creating this for every compare, make static.
|
|
|
|
static STRING_FORMATTER sf;
|
|
|
|
|
|
|
|
DSN_T type;
|
|
|
|
ELEM* parent;
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* A holder for any DSN class.
|
|
|
|
*
|
|
|
|
* It can contain other class instances, including classes derived from this class.
|
2008-02-07 20:23:58 +00:00
|
|
|
*/
|
2008-01-21 20:53:35 +00:00
|
|
|
class ELEM_HOLDER : public ELEM
|
|
|
|
{
|
2008-02-07 20:23:58 +00:00
|
|
|
public:
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
ELEM_HOLDER( DSN_T aType, ELEM* aParent = nullptr ) :
|
2008-01-21 20:53:35 +00:00
|
|
|
ELEM( aType, aParent )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
virtual void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
//-----< list operations >--------------------------------------------
|
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Find a particular instance number of a given type of ELEM.
|
|
|
|
*
|
2008-01-21 20:53:35 +00:00
|
|
|
* @param aType The type of ELEM to find
|
|
|
|
* @param instanceNum The instance number of to find: 0 for first, 1 for second, etc.
|
|
|
|
* @return int - The index into the kids array or -1 if not found.
|
|
|
|
*/
|
|
|
|
int FindElem( DSN_T aType, int instanceNum = 0 );
|
|
|
|
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Return the number of ELEMs in this holder.
|
|
|
|
*
|
|
|
|
* @return the count of children elements.
|
2008-01-21 20:53:35 +00:00
|
|
|
*/
|
2021-03-04 21:15:00 +00:00
|
|
|
int Length() const
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
return kids.size();
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-03-04 21:15:00 +00:00
|
|
|
void Append( ELEM* aElem )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
kids.push_back( aElem );
|
|
|
|
}
|
|
|
|
|
2021-03-04 21:15:00 +00:00
|
|
|
ELEM* Replace( int aIndex, ELEM* aElem )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
ELEM_ARRAY::auto_type ret = kids.replace( aIndex, aElem );
|
|
|
|
return ret.release();
|
|
|
|
}
|
|
|
|
|
2021-03-04 21:15:00 +00:00
|
|
|
ELEM* Remove( int aIndex )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
ELEM_ARRAY::auto_type ret = kids.release( kids.begin() + aIndex );
|
2008-01-21 20:53:35 +00:00
|
|
|
return ret.release();
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Insert( int aIndex, ELEM* aElem ) { kids.insert( kids.begin() + aIndex, aElem ); }
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-03-04 21:15:00 +00:00
|
|
|
ELEM* At( int aIndex ) const
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
// we have varying sized objects and are using polymorphism, so we
|
|
|
|
// must return a pointer not a reference.
|
2008-01-29 16:45:14 +00:00
|
|
|
return (ELEM*) &kids[aIndex];
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-29 16:45:14 +00:00
|
|
|
ELEM* operator[]( int aIndex ) const
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
return At( aIndex );
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Delete( int aIndex ) { kids.erase( kids.begin() + aIndex ); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
|
|
|
typedef boost::ptr_vector<ELEM> ELEM_ARRAY;
|
|
|
|
|
|
|
|
ELEM_ARRAY kids; ///< ELEM pointers
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* A configuration record per the SPECCTRA DSN file spec.
|
|
|
|
*
|
2008-01-21 20:53:35 +00:00
|
|
|
* It is not actually a parser, but rather corresponds to <parser_descriptor>
|
|
|
|
*/
|
|
|
|
class PARSER : public ELEM
|
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
PARSER( ELEM* aParent );
|
|
|
|
|
|
|
|
void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override;
|
|
|
|
|
|
|
|
private:
|
2008-01-21 20:53:35 +00:00
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
|
|
|
char string_quote;
|
|
|
|
bool space_in_quoted_tokens;
|
|
|
|
bool case_sensitive;
|
|
|
|
bool wires_include_testpoint;
|
|
|
|
bool routes_include_testpoint;
|
|
|
|
bool routes_include_guides;
|
|
|
|
bool routes_include_image_conductor;
|
|
|
|
bool via_rotate_first;
|
|
|
|
bool generated_by_freeroute;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-02-14 01:07:52 +00:00
|
|
|
/// This holds pairs of strings, one pair for each constant definition
|
|
|
|
STRINGS constants;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
std::string host_cad;
|
|
|
|
std::string host_version;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* A holder for either a T_unit or T_resolution object which are usually
|
2008-01-21 20:53:35 +00:00
|
|
|
* mutually exclusive in the dsn grammar, except within the T_pcb level.
|
|
|
|
*/
|
|
|
|
class UNIT_RES : public ELEM
|
|
|
|
{
|
|
|
|
public:
|
2008-02-07 20:23:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A static instance which holds the default units of T_inch and 2540000.
|
|
|
|
* See page 108 of the specctra spec, May 2000.
|
|
|
|
*/
|
|
|
|
static UNIT_RES Default;
|
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
UNIT_RES( ELEM* aParent, DSN_T aType ) :
|
|
|
|
ELEM( aType, aParent )
|
|
|
|
{
|
|
|
|
units = T_inch;
|
|
|
|
value = 2540000;
|
|
|
|
}
|
|
|
|
|
2021-03-04 21:15:00 +00:00
|
|
|
DSN_T GetEngUnits() const { return units; }
|
|
|
|
int GetValue() const { return value; }
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
if( type == T_unit )
|
2021-03-04 21:15:00 +00:00
|
|
|
out->Print( nestLevel, "(%s %s)\n", Name(), GetTokenText( units ) );
|
2008-02-07 20:23:58 +00:00
|
|
|
else // T_resolution
|
2021-03-04 21:15:00 +00:00
|
|
|
out->Print( nestLevel, "(%s %s %d)\n", Name(), GetTokenText( units ), value );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
private:
|
2008-01-21 20:53:35 +00:00
|
|
|
friend class SPECCTRA_DB;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
DSN_T units;
|
|
|
|
int value;
|
|
|
|
};
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
class RECTANGLE : public ELEM
|
|
|
|
{
|
2008-01-21 20:53:35 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
RECTANGLE( ELEM* aParent ) :
|
|
|
|
ELEM( T_rect, aParent )
|
|
|
|
{
|
|
|
|
}
|
2008-01-24 21:47:54 +00:00
|
|
|
|
|
|
|
void SetLayerId( const char* aLayerId )
|
|
|
|
{
|
|
|
|
layer_id = aLayerId;
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-24 21:47:54 +00:00
|
|
|
void SetCorners( const POINT& aPoint0, const POINT& aPoint1 )
|
|
|
|
{
|
|
|
|
point0 = aPoint0;
|
2008-02-07 20:23:58 +00:00
|
|
|
point0.FixNegativeZero();
|
|
|
|
|
2008-01-24 21:47:54 +00:00
|
|
|
point1 = aPoint1;
|
2008-02-07 20:23:58 +00:00
|
|
|
point1.FixNegativeZero();
|
2008-01-24 21:47:54 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2013-10-04 08:42:09 +00:00
|
|
|
POINT GetOrigin() { return point0; }
|
|
|
|
POINT GetEnd() { return point1; }
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2008-01-25 22:03:36 +00:00
|
|
|
const char* newline = nestLevel ? "\n" : "";
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-25 22:03:36 +00:00
|
|
|
const char* quote = out->GetQuoteChar( layer_id.c_str() );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
|
|
|
out->Print( nestLevel, "(%s %s%s%s %.6g %.6g %.6g %.6g)%s",
|
2021-03-04 21:15:00 +00:00
|
|
|
Name(),
|
|
|
|
quote, layer_id.c_str(), quote,
|
|
|
|
point0.x, point0.y,
|
|
|
|
point1.x, point1.y,
|
|
|
|
newline );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
|
|
|
std::string layer_id;
|
|
|
|
|
|
|
|
POINT point0; ///< one of two opposite corners
|
|
|
|
POINT point1;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* A <rule_descriptor> in the specctra dsn spec.
|
2008-01-21 20:53:35 +00:00
|
|
|
*/
|
|
|
|
class RULE : public ELEM
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
RULE( ELEM* aParent, DSN_T aType ) :
|
|
|
|
ELEM( aType, aParent )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2009-12-11 04:55:24 +00:00
|
|
|
out->Print( nestLevel, "(%s", Name() );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
bool singleLine;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_rules.size() == 1 )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
singleLine = true;
|
2023-04-01 14:14:35 +00:00
|
|
|
out->Print( 0, " %s)", m_rules.begin()->c_str() );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
else
|
|
|
|
{
|
2008-01-24 21:47:54 +00:00
|
|
|
out->Print( 0, "\n" );
|
2008-01-21 20:53:35 +00:00
|
|
|
singleLine = false;
|
2021-03-04 21:15:00 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( STRINGS::const_iterator i = m_rules.begin(); i != m_rules.end(); ++i )
|
2008-01-24 21:47:54 +00:00
|
|
|
out->Print( nestLevel+1, "%s\n", i->c_str() );
|
2021-03-04 21:15:00 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
out->Print( nestLevel, ")" );
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
if( nestLevel || !singleLine )
|
|
|
|
out->Print( 0, "\n" );
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
STRINGS m_rules; ///< rules are saved in std::string form.
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class LAYER_RULE : public ELEM
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
LAYER_RULE( ELEM* aParent ) :
|
|
|
|
ELEM( T_layer_rule, aParent )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
m_rule = nullptr;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2021-03-04 21:15:00 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
~LAYER_RULE()
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
delete m_rule;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2009-12-11 04:55:24 +00:00
|
|
|
out->Print( nestLevel, "(%s", Name() );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( STRINGS::const_iterator i = m_layer_ids.begin(); i != m_layer_ids.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
const char* quote = out->GetQuoteChar( i->c_str() );
|
|
|
|
out->Print( 0, " %s%s%s", quote, i->c_str(), quote );
|
|
|
|
}
|
2021-03-04 21:15:00 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
out->Print( 0 , "\n" );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_rule )
|
|
|
|
m_rule->Format( out, nestLevel+1 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
out->Print( nestLevel, ")\n" );
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
STRINGS m_layer_ids;
|
|
|
|
RULE* m_rule;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
2021-03-04 21:15:00 +00:00
|
|
|
|
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
typedef boost::ptr_vector<LAYER_RULE> LAYER_RULES;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Support both the <path_descriptor> and the <polygon_descriptor> per
|
2008-01-21 20:53:35 +00:00
|
|
|
* the specctra dsn spec.
|
|
|
|
*/
|
|
|
|
class PATH : public ELEM
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2008-01-22 20:48:02 +00:00
|
|
|
PATH( ELEM* aParent, DSN_T aType = T_path ) :
|
2008-01-21 20:53:35 +00:00
|
|
|
ELEM( aType, aParent )
|
|
|
|
{
|
|
|
|
aperture_width = 0.0;
|
|
|
|
aperture_type = T_round;
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-25 22:03:36 +00:00
|
|
|
void AppendPoint( const POINT& aPoint )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2008-01-25 22:03:36 +00:00
|
|
|
points.push_back( aPoint );
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2013-10-04 08:42:09 +00:00
|
|
|
POINTS& GetPoints() {return points; }
|
|
|
|
|
2008-01-25 22:03:36 +00:00
|
|
|
void SetLayerId( const char* aLayerId )
|
|
|
|
{
|
|
|
|
layer_id = aLayerId;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-02-22 17:34:11 +00:00
|
|
|
void SetAperture( double aWidth )
|
|
|
|
{
|
|
|
|
aperture_width = aWidth;
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2008-01-25 22:03:36 +00:00
|
|
|
const char* newline = nestLevel ? "\n" : "";
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
const char* quote = out->GetQuoteChar( layer_id.c_str() );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
|
|
|
const int RIGHTMARGIN = 70;
|
|
|
|
int perLine = out->Print( nestLevel, "(%s %s%s%s %.6g",
|
2021-03-04 21:15:00 +00:00
|
|
|
Name(),
|
|
|
|
quote, layer_id.c_str(), quote,
|
|
|
|
aperture_width );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2012-09-22 11:19:37 +00:00
|
|
|
int wrapNest = std::max( nestLevel+1, 6 );
|
2021-03-04 21:15:00 +00:00
|
|
|
|
|
|
|
for( unsigned i = 0; i < points.size(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2008-01-23 22:37:55 +00:00
|
|
|
if( perLine > RIGHTMARGIN )
|
|
|
|
{
|
|
|
|
out->Print( 0, "\n" );
|
2008-02-01 20:32:18 +00:00
|
|
|
perLine = out->Print( wrapNest, "%s", "" );
|
2008-01-23 22:37:55 +00:00
|
|
|
}
|
|
|
|
else
|
2021-03-04 21:15:00 +00:00
|
|
|
{
|
2008-01-23 22:37:55 +00:00
|
|
|
perLine += out->Print( 0, " " );
|
2021-03-04 21:15:00 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-23 22:37:55 +00:00
|
|
|
perLine += out->Print( 0, "%.6g %.6g", points[i].x, points[i].y );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-01-23 22:37:55 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
if( aperture_type == T_square )
|
2008-01-23 22:37:55 +00:00
|
|
|
{
|
2008-02-01 20:32:18 +00:00
|
|
|
out->Print( 0, "(aperture_type square)" );
|
2008-01-23 22:37:55 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
|
|
|
out->Print( 0, ")%s", newline );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
|
|
|
std::string layer_id;
|
|
|
|
double aperture_width;
|
|
|
|
|
|
|
|
POINTS points;
|
|
|
|
DSN_T aperture_type;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
typedef boost::ptr_vector<PATH> PATHS;
|
|
|
|
|
|
|
|
|
|
|
|
class BOUNDARY : public ELEM
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
BOUNDARY( ELEM* aParent, DSN_T aType = T_boundary ) :
|
|
|
|
ELEM( aType, aParent )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
rectangle = nullptr;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
~BOUNDARY()
|
|
|
|
{
|
|
|
|
delete rectangle;
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2013-10-04 08:42:09 +00:00
|
|
|
/**
|
|
|
|
* GetCorners fills aBuffer with a list of coordinates (x,y) of corners
|
|
|
|
*/
|
|
|
|
void GetCorners( std::vector<double>& aBuffer )
|
|
|
|
{
|
|
|
|
if( rectangle )
|
|
|
|
{
|
|
|
|
aBuffer.push_back( rectangle->GetOrigin().x );
|
|
|
|
aBuffer.push_back( rectangle->GetOrigin().y );
|
|
|
|
|
|
|
|
aBuffer.push_back( rectangle->GetOrigin().x );
|
|
|
|
aBuffer.push_back( rectangle->GetEnd().y );
|
|
|
|
|
|
|
|
aBuffer.push_back( rectangle->GetEnd().x );
|
|
|
|
aBuffer.push_back( rectangle->GetEnd().y );
|
|
|
|
|
|
|
|
aBuffer.push_back( rectangle->GetEnd().x );
|
|
|
|
aBuffer.push_back( rectangle->GetOrigin().y );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for( PATHS::iterator i=paths.begin(); i!=paths.end(); ++i )
|
|
|
|
{
|
|
|
|
POINTS& plist = i->GetPoints();
|
2021-03-04 21:15:00 +00:00
|
|
|
|
2013-10-04 08:42:09 +00:00
|
|
|
for( unsigned jj = 0; jj < plist.size(); jj++ )
|
|
|
|
{
|
|
|
|
aBuffer.push_back( plist[jj].x );
|
|
|
|
aBuffer.push_back( plist[jj].y );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2009-12-11 04:55:24 +00:00
|
|
|
out->Print( nestLevel, "(%s\n", Name() );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
|
|
|
if( rectangle )
|
|
|
|
rectangle->Format( out, nestLevel+1 );
|
|
|
|
else
|
|
|
|
{
|
2021-03-04 21:15:00 +00:00
|
|
|
for( PATHS::iterator i = paths.begin(); i != paths.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
i->Format( out, nestLevel+1 );
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
|
|
|
out->Print( nestLevel, ")\n" );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
private:
|
2008-01-21 20:53:35 +00:00
|
|
|
friend class SPECCTRA_DB;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
// only one or the other of these two is used, not both
|
|
|
|
PATHS paths;
|
|
|
|
RECTANGLE* rectangle;
|
|
|
|
};
|
2008-02-07 20:23:58 +00:00
|
|
|
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
class CIRCLE : public ELEM
|
|
|
|
{
|
2008-02-07 20:23:58 +00:00
|
|
|
public:
|
2008-01-21 20:53:35 +00:00
|
|
|
CIRCLE( ELEM* aParent ) :
|
|
|
|
ELEM( T_circle, aParent )
|
|
|
|
{
|
|
|
|
diameter = 0.0;
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2008-01-25 22:03:36 +00:00
|
|
|
const char* newline = nestLevel ? "\n" : "";
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
const char* quote = out->GetQuoteChar( layer_id.c_str() );
|
2021-07-19 23:56:05 +00:00
|
|
|
out->Print( nestLevel, "(%s %s%s%s %.6g", Name(), quote, layer_id.c_str(), quote,
|
|
|
|
diameter );
|
2008-01-25 22:03:36 +00:00
|
|
|
|
|
|
|
if( vertex.x!=0.0 || vertex.y!=0.0 )
|
|
|
|
out->Print( 0, " %.6g %.6g)%s", vertex.x, vertex.y, newline );
|
|
|
|
else
|
|
|
|
out->Print( 0, ")%s", newline );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-24 21:47:54 +00:00
|
|
|
void SetLayerId( const char* aLayerId )
|
|
|
|
{
|
|
|
|
layer_id = aLayerId;
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-24 21:47:54 +00:00
|
|
|
void SetDiameter( double aDiameter )
|
|
|
|
{
|
|
|
|
diameter = aDiameter;
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-25 22:03:36 +00:00
|
|
|
void SetVertex( const POINT& aVertex )
|
|
|
|
{
|
|
|
|
vertex = aVertex;
|
|
|
|
}
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
private:
|
2008-01-21 20:53:35 +00:00
|
|
|
friend class SPECCTRA_DB;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
std::string layer_id;
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
double diameter;
|
|
|
|
POINT vertex; // POINT's constructor sets to (0,0)
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class QARC : public ELEM
|
|
|
|
{
|
2008-02-07 20:23:58 +00:00
|
|
|
public:
|
2008-01-21 20:53:35 +00:00
|
|
|
QARC( ELEM* aParent ) :
|
|
|
|
ELEM( T_qarc, aParent )
|
|
|
|
{
|
|
|
|
aperture_width = 0.0;
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2008-01-25 22:03:36 +00:00
|
|
|
const char* newline = nestLevel ? "\n" : "";
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
const char* quote = out->GetQuoteChar( layer_id.c_str() );
|
2021-07-19 23:56:05 +00:00
|
|
|
out->Print( nestLevel, "(%s %s%s%s %.6g", Name(), quote, layer_id.c_str(), quote,
|
|
|
|
aperture_width );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
for( int i=0; i<3; ++i )
|
2021-07-19 23:56:05 +00:00
|
|
|
out->Print( 0, " %.6g %.6g", vertex[i].x, vertex[i].y );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-25 22:03:36 +00:00
|
|
|
out->Print( 0, ")%s", newline );
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-25 22:03:36 +00:00
|
|
|
void SetLayerId( const char* aLayerId )
|
|
|
|
{
|
|
|
|
layer_id = aLayerId;
|
|
|
|
}
|
2021-03-04 21:15:00 +00:00
|
|
|
|
2008-01-25 22:03:36 +00:00
|
|
|
void SetStart( const POINT& aStart )
|
|
|
|
{
|
2008-01-29 16:45:14 +00:00
|
|
|
vertex[0] = aStart;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-01-29 16:45:14 +00:00
|
|
|
// no -0.0 on the printouts!
|
|
|
|
vertex[0].FixNegativeZero();
|
2008-01-25 22:03:36 +00:00
|
|
|
}
|
2021-03-04 21:15:00 +00:00
|
|
|
|
2008-01-25 22:03:36 +00:00
|
|
|
void SetEnd( const POINT& aEnd )
|
|
|
|
{
|
|
|
|
vertex[1] = aEnd;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-01-29 16:45:14 +00:00
|
|
|
// no -0.0 on the printouts!
|
|
|
|
vertex[1].FixNegativeZero();
|
2008-01-25 22:03:36 +00:00
|
|
|
}
|
2021-03-04 21:15:00 +00:00
|
|
|
|
2008-01-25 22:03:36 +00:00
|
|
|
void SetCenter( const POINT& aCenter )
|
|
|
|
{
|
|
|
|
vertex[2] = aCenter;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-01-29 16:45:14 +00:00
|
|
|
// no -0.0 on the printouts!
|
|
|
|
vertex[2].FixNegativeZero();
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
|
|
|
std::string layer_id;
|
|
|
|
double aperture_width;
|
|
|
|
POINT vertex[3];
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class WINDOW : public ELEM
|
|
|
|
{
|
|
|
|
public:
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-29 16:45:14 +00:00
|
|
|
WINDOW( ELEM* aParent, DSN_T aType = T_window ) :
|
|
|
|
ELEM( aType, aParent )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
shape = nullptr;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
~WINDOW()
|
|
|
|
{
|
2008-01-29 16:45:14 +00:00
|
|
|
delete shape;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-01-29 16:45:14 +00:00
|
|
|
|
|
|
|
void SetShape( ELEM* aShape )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2008-01-29 16:45:14 +00:00
|
|
|
delete shape;
|
|
|
|
shape = aShape;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-29 16:45:14 +00:00
|
|
|
if( aShape )
|
|
|
|
{
|
2021-03-04 21:15:00 +00:00
|
|
|
wxASSERT( aShape->Type()==T_rect
|
|
|
|
|| aShape->Type()==T_circle
|
|
|
|
|| aShape->Type()==T_qarc
|
|
|
|
|| aShape->Type()==T_path
|
|
|
|
|| aShape->Type()==T_polygon);
|
2008-02-07 20:23:58 +00:00
|
|
|
|
|
|
|
aShape->SetParent( this );
|
2008-01-29 16:45:14 +00:00
|
|
|
}
|
|
|
|
}
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-29 16:45:14 +00:00
|
|
|
{
|
2009-12-11 04:55:24 +00:00
|
|
|
out->Print( nestLevel, "(%s ", Name() );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-29 16:45:14 +00:00
|
|
|
if( shape )
|
|
|
|
shape->Format( out, 0 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-29 16:45:14 +00:00
|
|
|
out->Print( 0, ")\n" );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
|
|
|
|
2008-02-07 20:23:58 +00:00
|
|
|
protected:
|
2008-01-30 19:16:46 +00:00
|
|
|
/* <shape_descriptor >::=
|
|
|
|
[<rectangle_descriptor> |
|
|
|
|
<circle_descriptor> |
|
|
|
|
<polygon_descriptor> |
|
|
|
|
<path_descriptor> |
|
|
|
|
<qarc_descriptor> ]
|
|
|
|
*/
|
2021-07-19 23:56:05 +00:00
|
|
|
ELEM* shape;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef boost::ptr_vector<WINDOW> WINDOWS;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Used for <keepout_descriptor> and <plane_descriptor>.
|
|
|
|
*/
|
|
|
|
class KEEPOUT : public ELEM
|
|
|
|
{
|
2008-01-21 20:53:35 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Require a DSN_T because this class is used for T_place_keepout, T_via_keepout,
|
2008-01-21 20:53:35 +00:00
|
|
|
* T_wire_keepout, T_bend_keepout, and T_elongate_keepout as well as T_keepout.
|
|
|
|
*/
|
|
|
|
KEEPOUT( ELEM* aParent, DSN_T aType ) :
|
|
|
|
ELEM( aType, aParent )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
m_rules = nullptr;
|
|
|
|
m_place_rules = nullptr;
|
|
|
|
m_shape = nullptr;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
m_sequence_number = -1;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
~KEEPOUT()
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
delete m_rules;
|
|
|
|
delete m_place_rules;
|
|
|
|
delete m_shape;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-30 19:16:46 +00:00
|
|
|
void SetShape( ELEM* aShape )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
delete m_shape;
|
|
|
|
m_shape = aShape;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-30 19:16:46 +00:00
|
|
|
if( aShape )
|
|
|
|
{
|
2021-03-04 21:15:00 +00:00
|
|
|
wxASSERT( aShape->Type()==T_rect
|
|
|
|
|| aShape->Type()==T_circle
|
|
|
|
|| aShape->Type()==T_qarc
|
|
|
|
|| aShape->Type()==T_path
|
|
|
|
|| aShape->Type()==T_polygon);
|
2008-02-07 20:23:58 +00:00
|
|
|
|
|
|
|
aShape->SetParent( this );
|
2008-01-30 19:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-06 14:23:56 +00:00
|
|
|
void AddWindow( WINDOW* aWindow )
|
|
|
|
{
|
|
|
|
aWindow->SetParent( this );
|
2023-04-01 14:14:35 +00:00
|
|
|
m_windows.push_back( aWindow );
|
2009-02-06 14:23:56 +00:00
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2008-02-05 05:08:10 +00:00
|
|
|
const char* newline = "\n";
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2009-12-11 04:55:24 +00:00
|
|
|
out->Print( nestLevel, "(%s", Name() );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_name.size() )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
const char* quote = out->GetQuoteChar( m_name.c_str() );
|
|
|
|
out->Print( 0, " %s%s%s", quote, m_name.c_str(), quote );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2017-11-02 17:18:57 +00:00
|
|
|
// Could be not needed:
|
|
|
|
#if 1
|
2009-02-06 22:10:37 +00:00
|
|
|
else
|
2021-07-19 23:56:05 +00:00
|
|
|
{
|
2009-02-06 22:10:37 +00:00
|
|
|
out->Print( 0, " \"\"" ); // the zone with no name or net_code == 0
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2017-11-02 17:18:57 +00:00
|
|
|
#endif
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_sequence_number != -1 )
|
|
|
|
out->Print( 0, " (sequence_number %d)", m_sequence_number );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_shape )
|
2008-02-05 05:08:10 +00:00
|
|
|
{
|
|
|
|
out->Print( 0, " " );
|
2023-04-01 14:14:35 +00:00
|
|
|
m_shape->Format( out, 0 );
|
2008-02-05 05:08:10 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_rules )
|
2008-02-05 05:08:10 +00:00
|
|
|
{
|
|
|
|
out->Print( 0, "%s", newline );
|
|
|
|
newline = "";
|
2023-04-01 14:14:35 +00:00
|
|
|
m_rules->Format( out, nestLevel+1 );
|
2008-02-05 05:08:10 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_place_rules )
|
2008-02-05 05:08:10 +00:00
|
|
|
{
|
|
|
|
out->Print( 0, "%s", newline );
|
|
|
|
newline = "";
|
2023-04-01 14:14:35 +00:00
|
|
|
m_place_rules->Format( out, nestLevel+1 );
|
2008-02-05 05:08:10 +00:00
|
|
|
}
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_windows.size() )
|
2008-02-05 05:08:10 +00:00
|
|
|
{
|
|
|
|
out->Print( 0, "%s", newline );
|
|
|
|
newline = "";
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( WINDOWS::iterator i = m_windows.begin(); i != m_windows.end(); ++i )
|
2008-02-05 05:08:10 +00:00
|
|
|
i->Format( out, nestLevel+1 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2009-02-06 14:23:56 +00:00
|
|
|
out->Print( nestLevel, ")\n" );
|
|
|
|
}
|
|
|
|
else
|
2021-07-19 23:56:05 +00:00
|
|
|
{
|
2009-02-06 14:23:56 +00:00
|
|
|
out->Print( 0, ")\n" );
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
protected:
|
2023-04-01 14:14:35 +00:00
|
|
|
std::string m_name;
|
|
|
|
int m_sequence_number;
|
|
|
|
RULE* m_rules;
|
|
|
|
RULE* m_place_rules;
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
WINDOWS m_windows;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
/* <shape_descriptor >::=
|
|
|
|
[<rectangle_descriptor> |
|
|
|
|
<circle_descriptor> |
|
|
|
|
<polygon_descriptor> |
|
|
|
|
<path_descriptor> |
|
|
|
|
<qarc_descriptor> ]
|
|
|
|
*/
|
2023-04-01 14:14:35 +00:00
|
|
|
ELEM* m_shape;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
2008-01-21 20:53:35 +00:00
|
|
|
friend class SPECCTRA_DB;
|
2021-07-19 23:56:05 +00:00
|
|
|
};
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
typedef boost::ptr_vector<KEEPOUT> KEEPOUTS;
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A <via_descriptor> in the specctra dsn spec.
|
|
|
|
*/
|
|
|
|
class VIA : public ELEM
|
|
|
|
{
|
2008-01-21 20:53:35 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
VIA( ELEM* aParent ) :
|
|
|
|
ELEM( T_via, aParent )
|
|
|
|
{
|
|
|
|
}
|
2008-01-29 16:45:14 +00:00
|
|
|
|
|
|
|
void AppendVia( const char* aViaName )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
m_padstacks.push_back( aViaName );
|
2008-01-29 16:45:14 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2008-01-24 21:47:54 +00:00
|
|
|
const int RIGHTMARGIN = 80;
|
2009-12-11 04:55:24 +00:00
|
|
|
int perLine = out->Print( nestLevel, "(%s", Name() );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( STRINGS::iterator i = m_padstacks.begin(); i != m_padstacks.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2008-01-24 21:47:54 +00:00
|
|
|
if( perLine > RIGHTMARGIN )
|
|
|
|
{
|
|
|
|
out->Print( 0, "\n" );
|
|
|
|
perLine = out->Print( nestLevel+1, "%s", "");
|
|
|
|
}
|
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
const char* quote = out->GetQuoteChar( i->c_str() );
|
2008-01-24 21:47:54 +00:00
|
|
|
perLine += out->Print( 0, " %s%s%s", quote, i->c_str(), quote );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_spares.size() )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2008-01-24 21:47:54 +00:00
|
|
|
out->Print( 0, "\n" );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-24 21:47:54 +00:00
|
|
|
perLine = out->Print( nestLevel+1, "(spare" );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( STRINGS::iterator i = m_spares.begin(); i != m_spares.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2008-01-24 21:47:54 +00:00
|
|
|
if( perLine > RIGHTMARGIN )
|
|
|
|
{
|
|
|
|
out->Print( 0, "\n" );
|
|
|
|
perLine = out->Print( nestLevel+2, "%s", "");
|
|
|
|
}
|
2021-03-04 21:15:00 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
const char* quote = out->GetQuoteChar( i->c_str() );
|
2008-01-24 21:47:54 +00:00
|
|
|
perLine += out->Print( 0, " %s%s%s", quote, i->c_str(), quote );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-24 21:47:54 +00:00
|
|
|
out->Print( 0, ")" );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-24 21:47:54 +00:00
|
|
|
out->Print( 0, ")\n" );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
STRINGS m_padstacks;
|
|
|
|
STRINGS m_spares;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class CLASSES : public ELEM
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CLASSES( ELEM* aParent ) :
|
|
|
|
ELEM( T_classes, aParent )
|
|
|
|
{
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2021-03-04 21:15:00 +00:00
|
|
|
for( STRINGS::iterator i = class_ids.begin(); i != class_ids.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
const char* quote = out->GetQuoteChar( i->c_str() );
|
|
|
|
out->Print( nestLevel, "%s%s%s\n", quote, i->c_str(), quote );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
private:
|
2008-01-21 20:53:35 +00:00
|
|
|
friend class SPECCTRA_DB;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
STRINGS class_ids;
|
|
|
|
};
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
class CLASS_CLASS : public ELEM_HOLDER
|
|
|
|
{
|
2008-01-21 20:53:35 +00:00
|
|
|
public:
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
/**
|
Fix typos in pcbnew sub-directory
Found via `codespell -q 3 -S *.po,./thirdparty,./Documentation/changelogs -L aactual,acount,aline,alocation,alog,anormal,anumber,aother,apoints,aparent,aray,ba,busses,dout,einstance,leaded,modul,ontext,ot,overide,serie,te,,tesselate,tesselator,tht`
2022-06-29 20:21:10 +00:00
|
|
|
* @param aParent is the parent element of the object.
|
2008-01-21 20:53:35 +00:00
|
|
|
* @param aType May be either T_class_class or T_region_class_class
|
|
|
|
*/
|
|
|
|
CLASS_CLASS( ELEM* aParent, DSN_T aType ) :
|
|
|
|
ELEM_HOLDER( aType, aParent )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
classes = nullptr;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
~CLASS_CLASS()
|
|
|
|
{
|
|
|
|
delete classes;
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
if( classes )
|
|
|
|
classes->Format( out, nestLevel );
|
|
|
|
|
|
|
|
// format the kids
|
|
|
|
ELEM_HOLDER::FormatContents( out, nestLevel );
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
|
|
|
CLASSES* classes;
|
|
|
|
|
|
|
|
// rule | layer_rule are put into the kids container.
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class CONTROL : public ELEM_HOLDER
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CONTROL( ELEM* aParent ) :
|
|
|
|
ELEM_HOLDER( T_control, aParent )
|
|
|
|
{
|
|
|
|
via_at_smd = false;
|
|
|
|
via_at_smd_grid_on = false;
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
~CONTROL()
|
|
|
|
{
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2009-12-11 04:55:24 +00:00
|
|
|
out->Print( nestLevel, "(%s\n", Name() );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2021-03-04 21:15:00 +00:00
|
|
|
out->Print( nestLevel+1, "(via_at_smd %s", via_at_smd ? "on" : "off" );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-03-04 21:15:00 +00:00
|
|
|
if( via_at_smd_grid_on )
|
|
|
|
out->Print( 0, " grid %s", via_at_smd_grid_on ? "on" : "off" );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2021-03-04 21:15:00 +00:00
|
|
|
out->Print( 0, ")\n" );
|
|
|
|
|
|
|
|
for( int i = 0; i < Length(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
At(i)->Format( out, nestLevel+1 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
|
|
|
out->Print( nestLevel, ")\n" );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
private:
|
2008-01-21 20:53:35 +00:00
|
|
|
friend class SPECCTRA_DB;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
bool via_at_smd;
|
|
|
|
bool via_at_smd_grid_on;
|
|
|
|
};
|
2008-02-07 20:23:58 +00:00
|
|
|
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
class LAYER : public ELEM
|
|
|
|
{
|
2008-01-21 20:53:35 +00:00
|
|
|
public:
|
|
|
|
LAYER( ELEM* aParent ) :
|
|
|
|
ELEM( T_layer, aParent )
|
|
|
|
{
|
|
|
|
layer_type = T_signal;
|
|
|
|
direction = -1;
|
|
|
|
cost = -1;
|
|
|
|
cost_type = -1;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
rules = nullptr;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
~LAYER()
|
|
|
|
{
|
|
|
|
delete rules;
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
const char* quote = out->GetQuoteChar( name.c_str() );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
out->Print( nestLevel, "(%s %s%s%s\n", Name(), quote, name.c_str(), quote );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2009-12-11 04:55:24 +00:00
|
|
|
out->Print( nestLevel+1, "(type %s)\n", GetTokenText( layer_type ) );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
|
|
|
if( properties.size() )
|
|
|
|
{
|
2009-12-11 04:55:24 +00:00
|
|
|
out->Print( nestLevel+1, "(property\n" );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
for( PROPERTIES::iterator i = properties.begin(); i != properties.end(); ++i )
|
|
|
|
{
|
|
|
|
i->Format( out, nestLevel+2 );
|
|
|
|
}
|
|
|
|
out->Print( nestLevel+1, ")\n" );
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
if( direction != -1 )
|
2021-03-04 21:15:00 +00:00
|
|
|
out->Print( nestLevel+1, "(direction %s)\n", GetTokenText( (DSN_T)direction ) );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
|
|
|
if( rules )
|
|
|
|
rules->Format( out, nestLevel+1 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
if( cost != -1 )
|
|
|
|
{
|
|
|
|
if( cost < 0 )
|
2021-07-19 23:56:05 +00:00
|
|
|
// positive integer, stored as negative.
|
|
|
|
out->Print( nestLevel+1, "(cost %d", -cost );
|
2008-01-21 20:53:35 +00:00
|
|
|
else
|
2009-12-11 04:55:24 +00:00
|
|
|
out->Print( nestLevel+1, "(cost %s", GetTokenText( (DSN_T)cost ) );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
if( cost_type != -1 )
|
2009-12-11 04:55:24 +00:00
|
|
|
out->Print( 0, " (type %s)", GetTokenText( (DSN_T)cost_type ) );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
out->Print( 0, ")\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( use_net.size() )
|
|
|
|
{
|
|
|
|
out->Print( nestLevel+1, "(use_net" );
|
2021-03-04 21:15:00 +00:00
|
|
|
|
|
|
|
for( STRINGS::const_iterator i = use_net.begin(); i != use_net.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2016-04-22 10:44:08 +00:00
|
|
|
quote = out->GetQuoteChar( i->c_str() );
|
2008-01-21 20:53:35 +00:00
|
|
|
out->Print( 0, " %s%s%s", quote, i->c_str(), quote );
|
|
|
|
}
|
2021-03-04 21:15:00 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
out->Print( 0, ")\n" );
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
|
|
|
out->Print( nestLevel, ")\n" );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
|
|
|
std::string name;
|
|
|
|
DSN_T layer_type; ///< one of: T_signal, T_power, T_mixed, T_jumper
|
|
|
|
int direction;
|
|
|
|
|
|
|
|
///< [forbidden | high | medium | low | free | \<positive_integer\> | -1]
|
|
|
|
int cost;
|
|
|
|
int cost_type; ///< T_length | T_way
|
|
|
|
RULE* rules;
|
|
|
|
STRINGS use_net;
|
|
|
|
|
|
|
|
PROPERTIES properties;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
|
|
|
|
2009-07-13 22:59:56 +00:00
|
|
|
typedef boost::ptr_vector<LAYER> LAYERS;
|
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2017-01-10 19:12:50 +00:00
|
|
|
class SPECCTRA_LAYER_PAIR : public ELEM
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-01-10 19:12:50 +00:00
|
|
|
SPECCTRA_LAYER_PAIR( ELEM* aParent ) :
|
2008-01-21 20:53:35 +00:00
|
|
|
ELEM( T_layer_pair, aParent )
|
|
|
|
{
|
|
|
|
layer_weight = 0.0;
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
const char* quote0 = out->GetQuoteChar( layer_id0.c_str() );
|
|
|
|
const char* quote1 = out->GetQuoteChar( layer_id1.c_str() );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
out->Print( nestLevel, "(%s %s%s%s %s%s%s %.6g)\n", Name(), quote0, layer_id0.c_str(),
|
|
|
|
quote0, quote1, layer_id1.c_str(), quote1, layer_weight );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
|
|
|
std::string layer_id0;
|
|
|
|
std::string layer_id1;
|
|
|
|
|
|
|
|
double layer_weight;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2017-01-10 19:12:50 +00:00
|
|
|
typedef boost::ptr_vector<SPECCTRA_LAYER_PAIR> SPECCTRA_LAYER_PAIRS;
|
2008-01-21 20:53:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
class LAYER_NOISE_WEIGHT : public ELEM
|
|
|
|
{
|
|
|
|
friend class SPECCTRA_DB;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2017-01-10 19:12:50 +00:00
|
|
|
SPECCTRA_LAYER_PAIRS layer_pairs;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
LAYER_NOISE_WEIGHT( ELEM* aParent ) :
|
|
|
|
ELEM( T_layer_noise_weight, aParent )
|
|
|
|
{
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2009-12-11 04:55:24 +00:00
|
|
|
out->Print( nestLevel, "(%s\n", Name() );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-03-04 21:15:00 +00:00
|
|
|
for( SPECCTRA_LAYER_PAIRS::iterator i = layer_pairs.begin(); i != layer_pairs.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
i->Format( out, nestLevel+1 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
out->Print( nestLevel, ")\n" );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-01-23 22:37:55 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* A <plane_descriptor> in the specctra dsn spec.
|
2008-01-23 22:37:55 +00:00
|
|
|
*/
|
|
|
|
class COPPER_PLANE : public KEEPOUT
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2008-02-07 20:23:58 +00:00
|
|
|
public:
|
2008-01-23 22:37:55 +00:00
|
|
|
COPPER_PLANE( ELEM* aParent ) :
|
2008-01-21 20:53:35 +00:00
|
|
|
KEEPOUT( aParent, T_plane )
|
2008-01-22 20:48:02 +00:00
|
|
|
{}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-01-23 22:37:55 +00:00
|
|
|
typedef boost::ptr_vector<COPPER_PLANE> COPPER_PLANES;
|
2008-01-21 20:53:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* A container for a single property whose value is another DSN_T token.
|
|
|
|
*
|
2008-01-21 20:53:35 +00:00
|
|
|
* The name of the property is obtained from the DSN_T Type().
|
|
|
|
*/
|
|
|
|
class TOKPROP : public ELEM
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TOKPROP( ELEM* aParent, DSN_T aType ) :
|
|
|
|
ELEM( aType, aParent )
|
|
|
|
{
|
2015-03-14 11:50:39 +00:00
|
|
|
// Do not leave uninitialized members
|
|
|
|
value = T_NONE;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
out->Print( nestLevel, "(%s %s)\n", Name(), GetTokenText( value ) );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
|
|
|
DSN_T value;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* A container for a single property whose value is a string.
|
|
|
|
*
|
2008-01-21 20:53:35 +00:00
|
|
|
* The name of the property is obtained from the DSN_T.
|
|
|
|
*/
|
|
|
|
class STRINGPROP : public ELEM
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
STRINGPROP( ELEM* aParent, DSN_T aType ) :
|
|
|
|
ELEM( aType, aParent )
|
|
|
|
{
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
const char* quote = out->GetQuoteChar( value.c_str() );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-03-04 21:15:00 +00:00
|
|
|
out->Print( nestLevel, "(%s %s%s%s)\n",
|
|
|
|
Name(),
|
|
|
|
quote, value.c_str(), quote );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
private:
|
2008-01-21 20:53:35 +00:00
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
std::string value;
|
|
|
|
};
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
class REGION : public ELEM_HOLDER
|
|
|
|
{
|
2008-01-21 20:53:35 +00:00
|
|
|
public:
|
|
|
|
REGION( ELEM* aParent ) :
|
|
|
|
ELEM_HOLDER( T_region, aParent )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
m_rectangle = nullptr;
|
|
|
|
m_polygon = nullptr;
|
|
|
|
m_rules = nullptr;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
~REGION()
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
delete m_rectangle;
|
|
|
|
delete m_polygon;
|
|
|
|
delete m_rules;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_region_id.size() )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
const char* quote = out->GetQuoteChar( m_region_id.c_str() );
|
|
|
|
out->Print( nestLevel, "%s%s%s\n", quote, m_region_id.c_str(), quote );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_rectangle )
|
|
|
|
m_rectangle->Format( out, nestLevel );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_polygon )
|
|
|
|
m_polygon->Format( out, nestLevel );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
|
|
|
ELEM_HOLDER::FormatContents( out, nestLevel );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_rules )
|
|
|
|
m_rules->Format( out, nestLevel );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
std::string m_region_id;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
//-----<mutually exclusive>--------------------------------------
|
2023-04-01 14:14:35 +00:00
|
|
|
RECTANGLE* m_rectangle;
|
|
|
|
PATH* m_polygon;
|
2021-07-19 23:56:05 +00:00
|
|
|
//-----</mutually exclusive>-------------------------------------
|
|
|
|
|
|
|
|
/* region_net | region_class | region_class_class are all mutually
|
|
|
|
exclusive and are put into the kids container.
|
|
|
|
*/
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
RULE* m_rules;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class GRID : public ELEM
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GRID( ELEM* aParent ) :
|
|
|
|
ELEM( T_grid, aParent )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
m_grid_type = T_via;
|
|
|
|
m_direction = T_NONE;
|
|
|
|
m_dimension = 0.0;
|
|
|
|
m_offset = 0.0;
|
|
|
|
m_image_type = T_NONE;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
out->Print( nestLevel, "(%s %s %.6g", Name(), GetTokenText( m_grid_type ), m_dimension );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_grid_type == T_place )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_image_type == T_smd || m_image_type == T_pin )
|
|
|
|
out->Print( 0, " (image_type %s)", GetTokenText( m_image_type ) );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_direction == T_x || m_direction == T_y )
|
|
|
|
out->Print( 0, " (direction %s)", GetTokenText( m_direction ) );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_offset != 0.0 )
|
|
|
|
out->Print( 0, " (offset %.6g)", m_offset );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
out->Print( 0, ")\n");
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
DSN_T m_grid_type; ///< T_via | T_wire | T_via_keepout | T_place | T_snap
|
|
|
|
double m_dimension;
|
|
|
|
DSN_T m_direction; ///< T_x | T_y | -1 for both
|
|
|
|
double m_offset;
|
|
|
|
DSN_T m_image_type;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-07-13 22:59:56 +00:00
|
|
|
class STRUCTURE_OUT : public ELEM
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
STRUCTURE_OUT( ELEM* aParent ) :
|
|
|
|
ELEM( T_structure_out, aParent )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
m_rules = nullptr;
|
2009-07-13 22:59:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
~STRUCTURE_OUT()
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
delete m_rules;
|
2009-07-13 22:59:56 +00:00
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
|
2009-07-13 22:59:56 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
for( LAYERS::iterator i = m_layers.begin(); i != m_layers.end(); ++i )
|
2009-07-13 22:59:56 +00:00
|
|
|
i->Format( out, nestLevel );
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_rules )
|
|
|
|
m_rules->Format( out, nestLevel );
|
2009-07-13 22:59:56 +00:00
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
private:
|
2008-01-21 20:53:35 +00:00
|
|
|
friend class SPECCTRA_DB;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
LAYERS m_layers;
|
|
|
|
RULE* m_rules;
|
2021-07-19 23:56:05 +00:00
|
|
|
};
|
2008-02-07 20:23:58 +00:00
|
|
|
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
class STRUCTURE : public ELEM_HOLDER
|
|
|
|
{
|
2008-01-21 20:53:35 +00:00
|
|
|
public:
|
|
|
|
STRUCTURE( ELEM* aParent ) :
|
|
|
|
ELEM_HOLDER( T_structure, aParent )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
m_unit = nullptr;
|
|
|
|
m_layer_noise_weight = nullptr;
|
|
|
|
m_boundary = nullptr;
|
|
|
|
m_place_boundary = nullptr;
|
|
|
|
m_via = nullptr;
|
|
|
|
m_control = nullptr;
|
|
|
|
m_rules = nullptr;
|
|
|
|
m_place_rules = nullptr;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
~STRUCTURE()
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
delete m_unit;
|
|
|
|
delete m_layer_noise_weight;
|
|
|
|
delete m_boundary;
|
|
|
|
delete m_place_boundary;
|
|
|
|
delete m_via;
|
|
|
|
delete m_control;
|
|
|
|
delete m_rules;
|
|
|
|
delete m_place_rules;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-22 20:48:02 +00:00
|
|
|
void SetBOUNDARY( BOUNDARY *aBoundary )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
delete m_boundary;
|
|
|
|
m_boundary = aBoundary;
|
|
|
|
|
|
|
|
if( m_boundary )
|
|
|
|
m_boundary->SetParent( this );
|
2008-01-22 20:48:02 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-22 20:48:02 +00:00
|
|
|
void SetPlaceBOUNDARY( BOUNDARY *aBoundary )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
delete m_place_boundary;
|
|
|
|
m_place_boundary = aBoundary;
|
|
|
|
|
|
|
|
if( m_place_boundary )
|
|
|
|
m_place_boundary->SetParent( this );
|
2008-01-22 20:48:02 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_unit )
|
|
|
|
m_unit->Format( out, nestLevel );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( LAYERS::iterator i=m_layers.begin(); i!=m_layers.end(); ++i )
|
2008-02-07 20:23:58 +00:00
|
|
|
i->Format( out, nestLevel );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_layer_noise_weight )
|
|
|
|
m_layer_noise_weight->Format( out, nestLevel );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_boundary )
|
|
|
|
m_boundary->Format( out, nestLevel );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_place_boundary )
|
|
|
|
m_place_boundary->Format( out, nestLevel );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( COPPER_PLANES::iterator i=m_planes.begin(); i!=m_planes.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
i->Format( out, nestLevel );
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( REGIONS::iterator i=m_regions.begin(); i!=m_regions.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
i->Format( out, nestLevel );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( KEEPOUTS::iterator i=m_keepouts.begin(); i!=m_keepouts.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
i->Format( out, nestLevel );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_via )
|
|
|
|
m_via->Format( out, nestLevel );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_control )
|
|
|
|
m_control->Format( out, nestLevel );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
for( int i=0; i<Length(); ++i )
|
|
|
|
{
|
|
|
|
At(i)->Format( out, nestLevel );
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_rules )
|
|
|
|
m_rules->Format( out, nestLevel );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_place_rules )
|
|
|
|
m_place_rules->Format( out, nestLevel );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( GRIDS::iterator i=m_grids.begin(); i!=m_grids.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
i->Format( out, nestLevel );
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
UNIT_RES* GetUnits() const override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_unit )
|
|
|
|
return m_unit;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
return ELEM::GetUnits();
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
private:
|
2008-01-21 20:53:35 +00:00
|
|
|
friend class SPECCTRA_DB;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
UNIT_RES* m_unit;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
LAYERS m_layers;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
LAYER_NOISE_WEIGHT* m_layer_noise_weight;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
BOUNDARY* m_boundary;
|
|
|
|
BOUNDARY* m_place_boundary;
|
|
|
|
VIA* m_via;
|
|
|
|
CONTROL* m_control;
|
|
|
|
RULE* m_rules;
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
KEEPOUTS m_keepouts;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
COPPER_PLANES m_planes;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
typedef boost::ptr_vector<REGION> REGIONS;
|
2023-04-01 14:14:35 +00:00
|
|
|
REGIONS m_regions;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
RULE* m_place_rules;
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
typedef boost::ptr_vector<GRID> GRIDS;
|
2023-04-01 14:14:35 +00:00
|
|
|
GRIDS m_grids;
|
2021-07-19 23:56:05 +00:00
|
|
|
};
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
/**
|
|
|
|
* Implement a <placement_reference> in the specctra dsn spec.
|
|
|
|
*/
|
|
|
|
class PLACE : public ELEM
|
|
|
|
{
|
2008-01-21 20:53:35 +00:00
|
|
|
public:
|
|
|
|
PLACE( ELEM* aParent ) :
|
|
|
|
ELEM( T_place, aParent )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
m_side = T_front;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
m_rotation = 0.0;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
m_hasVertex = false;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
m_mirror = T_NONE;
|
|
|
|
m_status = T_NONE;
|
2009-12-11 04:55:24 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
m_place_rules = nullptr;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
m_lock_type = T_NONE;
|
|
|
|
m_rules = nullptr;
|
|
|
|
m_region = nullptr;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
~PLACE()
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
delete m_place_rules;
|
|
|
|
delete m_rules;
|
|
|
|
delete m_region;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
void SetVertex( const POINT& aVertex )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
m_vertex = aVertex;
|
|
|
|
m_vertex.FixNegativeZero();
|
|
|
|
m_hasVertex = true;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetRotation( double aRotation )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
m_rotation = aRotation;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override;
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
private:
|
2008-01-21 20:53:35 +00:00
|
|
|
friend class SPECCTRA_DB;
|
2008-01-29 22:09:09 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
std::string m_component_id; ///< reference designator
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
DSN_T m_side;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
double m_rotation;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
bool m_hasVertex;
|
|
|
|
POINT m_vertex;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
DSN_T m_mirror;
|
|
|
|
DSN_T m_status;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
std::string m_logical_part;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
RULE* m_place_rules;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
PROPERTIES m_properties;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
DSN_T m_lock_type;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
//-----<mutually exclusive>--------------
|
2023-04-01 14:14:35 +00:00
|
|
|
RULE* m_rules;
|
|
|
|
REGION* m_region;
|
2021-07-19 23:56:05 +00:00
|
|
|
//-----</mutually exclusive>-------------
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
std::string m_part_number;
|
2021-07-19 23:56:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef boost::ptr_vector<PLACE> PLACES;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implement a <component_descriptor> in the specctra dsn spec.
|
|
|
|
*/
|
|
|
|
class COMPONENT : public ELEM
|
|
|
|
{
|
2008-01-21 20:53:35 +00:00
|
|
|
public:
|
|
|
|
COMPONENT( ELEM* aParent ) :
|
|
|
|
ELEM( T_component, aParent )
|
|
|
|
{
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
const std::string& GetImageId() const { return m_image_id; }
|
2008-02-07 20:23:58 +00:00
|
|
|
void SetImageId( const std::string& aImageId )
|
2008-01-29 22:09:09 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
m_image_id = aImageId;
|
2008-01-29 22:09:09 +00:00
|
|
|
}
|
|
|
|
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-29 22:09:09 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Compare two objects of this type and returns <0, 0, or >0.
|
2008-01-29 22:09:09 +00:00
|
|
|
*/
|
|
|
|
// static int Compare( IMAGE* lhs, IMAGE* rhs );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
const char* quote = out->GetQuoteChar( m_image_id.c_str() );
|
|
|
|
out->Print( nestLevel, "(%s %s%s%s\n", Name(), quote, m_image_id.c_str(), quote );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-29 22:09:09 +00:00
|
|
|
FormatContents( out, nestLevel+1 );
|
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
out->Print( nestLevel, ")\n" );
|
|
|
|
}
|
2008-01-29 22:09:09 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-29 22:09:09 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
for( PLACES::iterator i=m_places.begin(); i!=m_places.end(); ++i )
|
2008-01-29 22:09:09 +00:00
|
|
|
i->Format( out, nestLevel );
|
|
|
|
}
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
private:
|
2008-01-21 20:53:35 +00:00
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
// std::string m_hash; ///< a hash string used by Compare(), not Format()ed/exported.
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
std::string m_image_id;
|
|
|
|
PLACES m_places;
|
2021-07-19 23:56:05 +00:00
|
|
|
};
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
typedef boost::ptr_vector<COMPONENT> COMPONENTS;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
class PLACEMENT : public ELEM
|
|
|
|
{
|
2008-02-07 20:23:58 +00:00
|
|
|
public:
|
2008-01-21 20:53:35 +00:00
|
|
|
PLACEMENT( ELEM* aParent ) :
|
|
|
|
ELEM( T_placement, aParent )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
m_unit = nullptr;
|
|
|
|
m_flip_style = DSN_T( T_NONE );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
~PLACEMENT()
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
delete m_unit;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-01-29 22:09:09 +00:00
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Look up a COMPONENT by name.
|
|
|
|
*
|
|
|
|
* If the name is not found, a new COMPONENT is added to the components container. At any
|
|
|
|
* time the names in the component container should remain unique.
|
|
|
|
*
|
|
|
|
* @return existing or new COMPONENT.
|
2008-01-29 22:09:09 +00:00
|
|
|
*/
|
|
|
|
COMPONENT* LookupCOMPONENT( const std::string& imageName )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
for( unsigned i = 0; i < m_components.size(); ++i )
|
2008-01-29 22:09:09 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
if( 0 == m_components[i].GetImageId().compare( imageName ) )
|
|
|
|
return &m_components[i];
|
2008-01-29 22:09:09 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-29 22:09:09 +00:00
|
|
|
COMPONENT* added = new COMPONENT(this);
|
2023-04-01 14:14:35 +00:00
|
|
|
m_components.push_back( added );
|
2008-01-29 22:09:09 +00:00
|
|
|
added->SetImageId( imageName );
|
|
|
|
return added;
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_unit )
|
|
|
|
m_unit->Format( out, nestLevel );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_flip_style != DSN_T( T_NONE ) )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
out->Print( nestLevel, "(place_control (flip_style %s))\n",
|
2023-04-01 14:14:35 +00:00
|
|
|
GetTokenText( m_flip_style ) );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( COMPONENTS::iterator i = m_components.begin(); i != m_components.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
i->Format( out, nestLevel );
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
UNIT_RES* GetUnits() const override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_unit )
|
|
|
|
return m_unit;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
return ELEM::GetUnits();
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
UNIT_RES* m_unit;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
DSN_T m_flip_style;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
COMPONENTS m_components;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-01-25 22:03:36 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* A "(shape ..)" element in the specctra dsn spec.
|
|
|
|
*
|
2008-01-26 02:02:27 +00:00
|
|
|
* It is not a <shape_descriptor>, which is one of things that this
|
2008-01-25 22:03:36 +00:00
|
|
|
* elements contains, i.e. in its "shape" field. This class also implements
|
|
|
|
* the "(outline ...)" element as a dual personality.
|
|
|
|
*/
|
2008-01-29 16:45:14 +00:00
|
|
|
class SHAPE : public WINDOW
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
public:
|
2008-02-22 17:34:11 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Takes a DSN_T aType of T_outline
|
2008-02-22 17:34:11 +00:00
|
|
|
*/
|
2008-01-21 20:53:35 +00:00
|
|
|
SHAPE( ELEM* aParent, DSN_T aType = T_shape ) :
|
2008-01-29 16:45:14 +00:00
|
|
|
WINDOW( aParent, aType )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
m_connect = T_on;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-01-25 22:03:36 +00:00
|
|
|
|
|
|
|
void SetConnect( DSN_T aConnect )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
m_connect = aConnect;
|
2008-01-25 22:03:36 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-25 22:03:36 +00:00
|
|
|
{
|
2009-12-11 04:55:24 +00:00
|
|
|
out->Print( nestLevel, "(%s ", Name() );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-25 22:03:36 +00:00
|
|
|
if( shape )
|
|
|
|
shape->Format( out, 0 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_connect == T_off )
|
|
|
|
out->Print( 0, "(connect %s)", GetTokenText( m_connect ) );
|
2008-01-25 22:03:36 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_windows.size() )
|
2008-01-25 22:03:36 +00:00
|
|
|
{
|
|
|
|
out->Print( 0, "\n" );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( WINDOWS::iterator i=m_windows.begin(); i!=m_windows.end(); ++i )
|
2008-01-25 22:03:36 +00:00
|
|
|
i->Format( out, nestLevel+1 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
|
|
|
out->Print( nestLevel, ")\n" );
|
2008-01-25 22:03:36 +00:00
|
|
|
}
|
|
|
|
else
|
2021-07-19 23:56:05 +00:00
|
|
|
{
|
2008-01-25 22:03:36 +00:00
|
|
|
out->Print( 0, ")\n" );
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
private:
|
2008-01-21 20:53:35 +00:00
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
DSN_T m_connect;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
/* <shape_descriptor >::=
|
|
|
|
[<rectangle_descriptor> |
|
|
|
|
<circle_descriptor> |
|
|
|
|
<polygon_descriptor> |
|
|
|
|
<path_descriptor> |
|
|
|
|
<qarc_descriptor> ]
|
|
|
|
ELEM* shape; // inherited from WINDOW
|
|
|
|
*/
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
WINDOWS m_windows;
|
2021-07-19 23:56:05 +00:00
|
|
|
};
|
2008-02-14 01:07:52 +00:00
|
|
|
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
class PIN : public ELEM
|
|
|
|
{
|
2008-01-21 20:53:35 +00:00
|
|
|
public:
|
|
|
|
PIN( ELEM* aParent ) :
|
|
|
|
ELEM( T_pin, aParent )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
m_rotation = 0.0;
|
|
|
|
m_isRotated = false;
|
|
|
|
m_kiNetCode = 0;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetRotation( double aRotation )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
m_rotation = aRotation;
|
|
|
|
m_isRotated = (aRotation != 0.0);
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-29 16:45:14 +00:00
|
|
|
void SetVertex( const POINT& aPoint )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
m_vertex = aPoint;
|
|
|
|
m_vertex.FixNegativeZero();
|
2008-01-29 16:45:14 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
const char* quote = out->GetQuoteChar( m_padstack_id.c_str() );
|
|
|
|
if( m_isRotated )
|
|
|
|
out->Print( nestLevel, "(pin %s%s%s (rotate %.6g)", quote, m_padstack_id.c_str(), quote,
|
|
|
|
m_rotation );
|
2008-01-21 20:53:35 +00:00
|
|
|
else
|
2023-04-01 14:14:35 +00:00
|
|
|
out->Print( nestLevel, "(pin %s%s%s", quote, m_padstack_id.c_str(), quote );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
quote = out->GetQuoteChar( m_pin_id.c_str() );
|
|
|
|
out->Print( 0, " %s%s%s %.6g %.6g)\n", quote, m_pin_id.c_str(), quote, m_vertex.x, m_vertex.y );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-14 01:07:52 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
private:
|
2008-01-21 20:53:35 +00:00
|
|
|
friend class SPECCTRA_DB;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
std::string m_padstack_id;
|
|
|
|
double m_rotation;
|
|
|
|
bool m_isRotated;
|
|
|
|
std::string m_pin_id;
|
|
|
|
POINT m_vertex;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
int m_kiNetCode; ///< KiCad netcode
|
2021-07-19 23:56:05 +00:00
|
|
|
};
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
typedef boost::ptr_vector<PIN> PINS;
|
2008-01-23 22:37:55 +00:00
|
|
|
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
class LIBRARY;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
class IMAGE : public ELEM_HOLDER
|
|
|
|
{
|
2008-01-21 20:53:35 +00:00
|
|
|
public:
|
|
|
|
IMAGE( ELEM* aParent ) :
|
|
|
|
ELEM_HOLDER( T_image, aParent )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
m_side = T_both;
|
|
|
|
m_unit = nullptr;
|
|
|
|
m_rules = nullptr;
|
|
|
|
m_place_rules = nullptr;
|
|
|
|
m_duplicated = 0;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
~IMAGE()
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
delete m_unit;
|
|
|
|
delete m_rules;
|
|
|
|
delete m_place_rules;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
|
|
|
|
2008-01-29 16:45:14 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Compare two objects of this type and returns <0, 0, or >0.
|
2008-01-29 16:45:14 +00:00
|
|
|
*/
|
|
|
|
static int Compare( IMAGE* lhs, IMAGE* rhs );
|
|
|
|
|
2008-02-03 21:46:12 +00:00
|
|
|
std::string GetImageId()
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_duplicated )
|
2008-02-03 21:46:12 +00:00
|
|
|
{
|
2023-04-17 15:39:34 +00:00
|
|
|
return m_image_id + "::" + std::to_string( m_duplicated );
|
2008-02-03 21:46:12 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
return m_image_id;
|
2008-02-03 21:46:12 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2008-02-03 21:46:12 +00:00
|
|
|
std::string imageId = GetImageId();
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-02-03 21:46:12 +00:00
|
|
|
const char* quote = out->GetQuoteChar( imageId.c_str() );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
out->Print( nestLevel, "(%s %s%s%s", Name(), quote, imageId.c_str(), quote );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-29 16:45:14 +00:00
|
|
|
FormatContents( out, nestLevel+1 );
|
|
|
|
|
|
|
|
out->Print( nestLevel, ")\n" );
|
|
|
|
}
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2008-01-29 16:45:14 +00:00
|
|
|
// this is here for makeHash()
|
2021-07-19 23:56:05 +00:00
|
|
|
void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-29 16:45:14 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_side != T_both )
|
|
|
|
out->Print( 0, " (side %s)", GetTokenText( m_side ) );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
out->Print( 0, "\n");
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_unit )
|
|
|
|
m_unit->Format( out, nestLevel );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
|
|
|
// format the kids, which in this class are the shapes
|
2008-01-29 16:45:14 +00:00
|
|
|
ELEM_HOLDER::FormatContents( out, nestLevel );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( PINS::iterator i=m_pins.begin(); i!=m_pins.end(); ++i )
|
2008-01-29 16:45:14 +00:00
|
|
|
i->Format( out, nestLevel );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_rules )
|
|
|
|
m_rules->Format( out, nestLevel );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_place_rules )
|
|
|
|
m_place_rules->Format( out, nestLevel );
|
2008-01-23 22:37:55 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( KEEPOUTS::iterator i=m_keepouts.begin(); i!=m_keepouts.end(); ++i )
|
2008-01-29 16:45:14 +00:00
|
|
|
i->Format( out, nestLevel );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
UNIT_RES* GetUnits() const override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_unit )
|
|
|
|
return m_unit;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
return ELEM::GetUnits();
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
private:
|
2008-01-21 20:53:35 +00:00
|
|
|
friend class SPECCTRA_DB;
|
2021-07-19 23:56:05 +00:00
|
|
|
friend class LIBRARY;
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
std::string m_hash; ///< a hash string used by Compare(), not Format()ed/exported.
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
std::string m_image_id;
|
|
|
|
DSN_T m_side;
|
|
|
|
UNIT_RES* m_unit;
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
/* The grammar spec says only one outline is supported, but I am seeing
|
|
|
|
*.dsn examples with multiple outlines. So the outlines will go into
|
|
|
|
the kids list.
|
|
|
|
*/
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
PINS m_pins;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
RULE* m_rules;
|
|
|
|
RULE* m_place_rules;
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
KEEPOUTS m_keepouts;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
int m_duplicated; ///< no. times this image_id is duplicated
|
2021-07-19 23:56:05 +00:00
|
|
|
};
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
typedef boost::ptr_vector<IMAGE> IMAGES;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hold either a via or a pad definition.
|
|
|
|
*/
|
|
|
|
class PADSTACK : public ELEM_HOLDER
|
|
|
|
{
|
|
|
|
public:
|
2008-02-14 01:07:52 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Cannot take ELEM* aParent because PADSTACKSET confuses this with a
|
2008-02-14 01:07:52 +00:00
|
|
|
* copy constructor and causes havoc. Instead set parent with
|
|
|
|
* LIBRARY::AddPadstack()
|
|
|
|
*/
|
|
|
|
PADSTACK() :
|
2021-07-19 23:56:05 +00:00
|
|
|
ELEM_HOLDER( T_padstack, nullptr )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
m_unit = nullptr;
|
2023-04-01 13:11:56 +00:00
|
|
|
m_rotate = T_on;
|
|
|
|
m_absolute = T_off;
|
2023-04-01 14:14:35 +00:00
|
|
|
m_rules = nullptr;
|
2023-04-01 13:11:56 +00:00
|
|
|
m_attach = T_off;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
~PADSTACK()
|
|
|
|
{
|
2023-04-01 13:11:56 +00:00
|
|
|
delete m_unit;
|
|
|
|
delete m_rules;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
|
|
|
|
2008-02-09 08:34:45 +00:00
|
|
|
const std::string& GetPadstackId()
|
|
|
|
{
|
2023-04-01 13:11:56 +00:00
|
|
|
return m_padstack_id;
|
2008-02-09 08:34:45 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-29 16:45:14 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Compare two objects of this type and returns <0, 0, or >0.
|
2008-01-29 16:45:14 +00:00
|
|
|
*/
|
|
|
|
static int Compare( PADSTACK* lhs, PADSTACK* rhs );
|
|
|
|
|
2008-01-24 21:47:54 +00:00
|
|
|
void SetPadstackId( const char* aPadstackId )
|
|
|
|
{
|
2023-04-01 13:11:56 +00:00
|
|
|
m_padstack_id = aPadstackId;
|
2008-01-24 21:47:54 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 13:11:56 +00:00
|
|
|
const char* quote = out->GetQuoteChar( m_padstack_id.c_str() );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 13:11:56 +00:00
|
|
|
out->Print( nestLevel, "(%s %s%s%s\n", Name(), quote, m_padstack_id.c_str(), quote );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2008-01-29 16:45:14 +00:00
|
|
|
FormatContents( out, nestLevel+1 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-29 16:45:14 +00:00
|
|
|
out->Print( nestLevel, ")\n" );
|
|
|
|
}
|
|
|
|
|
|
|
|
// this factored out for use by Compare()
|
2021-07-19 23:56:05 +00:00
|
|
|
void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-29 16:45:14 +00:00
|
|
|
{
|
2023-04-01 13:11:56 +00:00
|
|
|
if( m_unit )
|
|
|
|
m_unit->Format( out, nestLevel );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
|
|
|
// format the kids, which in this class are the shapes
|
2008-01-29 16:45:14 +00:00
|
|
|
ELEM_HOLDER::FormatContents( out, nestLevel );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2008-01-29 22:09:09 +00:00
|
|
|
out->Print( nestLevel, "%s", "" );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
// spec for <attach_descriptor> says default is on, so
|
2008-02-07 20:23:58 +00:00
|
|
|
// print the off condition to override this.
|
2023-04-01 13:11:56 +00:00
|
|
|
if( m_attach == T_off )
|
2021-03-04 21:15:00 +00:00
|
|
|
{
|
2008-01-21 20:53:35 +00:00
|
|
|
out->Print( 0, "(attach off)" );
|
2021-03-04 21:15:00 +00:00
|
|
|
}
|
2023-04-01 13:11:56 +00:00
|
|
|
else if( m_attach == T_on )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 13:11:56 +00:00
|
|
|
const char* quote = out->GetQuoteChar( m_via_id.c_str() );
|
2021-03-04 21:15:00 +00:00
|
|
|
|
2023-04-01 13:11:56 +00:00
|
|
|
out->Print( 0, "(attach on (use_via %s%s%s))", quote, m_via_id.c_str(), quote );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 13:11:56 +00:00
|
|
|
if( m_rotate == T_off ) // print the non-default
|
|
|
|
out->Print( 0, "(rotate %s)", GetTokenText( m_rotate ) );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2023-04-01 13:11:56 +00:00
|
|
|
if( m_absolute == T_on ) // print the non-default
|
|
|
|
out->Print( 0, "(absolute %s)", GetTokenText( m_absolute ) );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
|
|
|
out->Print( 0, "\n" );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 13:11:56 +00:00
|
|
|
if( m_rules )
|
|
|
|
m_rules->Format( out, nestLevel );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-01-29 16:45:14 +00:00
|
|
|
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
UNIT_RES* GetUnits() const override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 13:11:56 +00:00
|
|
|
if( m_unit )
|
|
|
|
return m_unit;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
return ELEM::GetUnits();
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
2023-04-01 13:11:56 +00:00
|
|
|
std::string m_hash; ///< a hash string used by Compare(), not Format()ed/exported.
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 13:11:56 +00:00
|
|
|
std::string m_padstack_id;
|
|
|
|
UNIT_RES* m_unit;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
/* The shapes are stored in the kids list */
|
|
|
|
|
2023-04-01 13:11:56 +00:00
|
|
|
DSN_T m_rotate;
|
|
|
|
DSN_T m_absolute;
|
|
|
|
DSN_T m_attach;
|
|
|
|
std::string m_via_id;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 13:11:56 +00:00
|
|
|
RULE* m_rules;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-01-24 21:47:54 +00:00
|
|
|
typedef boost::ptr_vector<PADSTACK> PADSTACKS;
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2009-12-11 04:55:24 +00:00
|
|
|
|
2008-02-14 01:07:52 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Used by the PADSTACKSET boost::ptr_set below.
|
2008-02-14 01:07:52 +00:00
|
|
|
*/
|
|
|
|
inline bool operator<( const PADSTACK& lhs, const PADSTACK& rhs )
|
|
|
|
{
|
|
|
|
return PADSTACK::Compare( (PADSTACK*) &lhs, (PADSTACK*) &rhs ) < 0;
|
|
|
|
}
|
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* A <library_descriptor> in the specctra dsn specification.
|
|
|
|
*
|
2008-02-07 20:23:58 +00:00
|
|
|
* Only unit_descriptor, image_descriptors, and padstack_descriptors are
|
2008-01-21 20:53:35 +00:00
|
|
|
* included as children at this time.
|
|
|
|
*/
|
|
|
|
class LIBRARY : public ELEM
|
|
|
|
{
|
|
|
|
public:
|
2008-01-23 22:37:55 +00:00
|
|
|
LIBRARY( ELEM* aParent, DSN_T aType = T_library ) :
|
|
|
|
ELEM( aType, aParent )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
m_unit = nullptr;
|
2009-11-02 05:20:58 +00:00
|
|
|
// via_start_index = -1; // 0 or greater means there is at least one via
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
~LIBRARY()
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
delete m_unit;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-01-29 16:45:14 +00:00
|
|
|
|
|
|
|
void AddPadstack( PADSTACK* aPadstack )
|
|
|
|
{
|
2008-02-14 01:07:52 +00:00
|
|
|
aPadstack->SetParent( this );
|
2023-04-01 14:14:35 +00:00
|
|
|
m_padstacks.push_back( aPadstack );
|
2008-01-29 16:45:14 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 05:20:58 +00:00
|
|
|
/*
|
2008-01-29 16:45:14 +00:00
|
|
|
void SetViaStartIndex( int aIndex )
|
|
|
|
{
|
|
|
|
via_start_index = aIndex;
|
|
|
|
}
|
|
|
|
int GetViaStartIndex()
|
|
|
|
{
|
|
|
|
return via_start_index;
|
|
|
|
}
|
2009-11-02 05:20:58 +00:00
|
|
|
*/
|
2008-01-29 16:45:14 +00:00
|
|
|
|
2008-01-29 22:09:09 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Search this LIBRARY for an image which matches the argument.
|
|
|
|
*
|
|
|
|
* @return index of image if found, else -1.
|
2008-01-29 22:09:09 +00:00
|
|
|
*/
|
2008-01-29 16:45:14 +00:00
|
|
|
int FindIMAGE( IMAGE* aImage )
|
|
|
|
{
|
2008-02-03 21:46:12 +00:00
|
|
|
unsigned i;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( i=0; i<m_images.size(); ++i )
|
2008-01-29 16:45:14 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
if( 0 == IMAGE::Compare( aImage, &m_images[i] ) )
|
2008-01-29 16:45:14 +00:00
|
|
|
return (int) i;
|
|
|
|
}
|
2008-02-03 21:46:12 +00:00
|
|
|
|
|
|
|
// There is no match to the IMAGE contents, but now generate a unique
|
|
|
|
// name for it.
|
2008-02-07 20:23:58 +00:00
|
|
|
int dups = 1;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( i=0; i<m_images.size(); ++i )
|
2008-02-03 21:46:12 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
if( 0 == aImage->m_image_id.compare( m_images[i].m_image_id ) )
|
|
|
|
aImage->m_duplicated = dups++;
|
2008-02-03 21:46:12 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-29 16:45:14 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2008-01-29 22:09:09 +00:00
|
|
|
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-29 22:09:09 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Add the image to the image list.
|
2008-01-29 22:09:09 +00:00
|
|
|
*/
|
2008-01-29 16:45:14 +00:00
|
|
|
void AppendIMAGE( IMAGE* aImage )
|
|
|
|
{
|
|
|
|
aImage->SetParent( this );
|
2023-04-01 14:14:35 +00:00
|
|
|
m_images.push_back( aImage );
|
2008-01-29 16:45:14 +00:00
|
|
|
}
|
2008-01-29 22:09:09 +00:00
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Add the image only if one exactly like it does not already exist in the image container.
|
|
|
|
*
|
|
|
|
* @return the IMAGE which is registered in the LIBRARY that matches the argument, and it
|
|
|
|
* will be either the argument or a previous image which is a duplicate.
|
2008-01-29 22:09:09 +00:00
|
|
|
*/
|
|
|
|
IMAGE* LookupIMAGE( IMAGE* aImage )
|
2008-01-29 16:45:14 +00:00
|
|
|
{
|
|
|
|
int ndx = FindIMAGE( aImage );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-01-29 16:45:14 +00:00
|
|
|
if( ndx == -1 )
|
|
|
|
{
|
|
|
|
AppendIMAGE( aImage );
|
2008-01-29 22:09:09 +00:00
|
|
|
return aImage;
|
2008-01-29 16:45:14 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
return &m_images[ndx];
|
2008-01-29 16:45:14 +00:00
|
|
|
}
|
2008-02-01 01:09:39 +00:00
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Search this LIBRARY for a via which matches the argument.
|
|
|
|
*
|
|
|
|
* @return the index found in the padstack list, else -1.
|
2008-02-01 01:09:39 +00:00
|
|
|
*/
|
|
|
|
int FindVia( PADSTACK* aVia )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
for( unsigned i = 0; i < m_vias.size(); ++i )
|
2008-02-01 01:09:39 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
if( 0 == PADSTACK::Compare( aVia, &m_vias[i] ) )
|
2009-11-02 05:20:58 +00:00
|
|
|
return int( i );
|
2008-02-01 01:09:39 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-02-01 01:09:39 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-11-02 05:20:58 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Add \a aVia to the internal via container.
|
2009-11-02 05:20:58 +00:00
|
|
|
*/
|
|
|
|
void AppendVia( PADSTACK* aVia )
|
|
|
|
{
|
|
|
|
aVia->SetParent( this );
|
2023-04-01 14:14:35 +00:00
|
|
|
m_vias.push_back( aVia );
|
2009-11-02 05:20:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-01 01:09:39 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Add the padstack to the padstack container.
|
2008-02-01 01:09:39 +00:00
|
|
|
*/
|
|
|
|
void AppendPADSTACK( PADSTACK* aPadstack )
|
|
|
|
{
|
|
|
|
aPadstack->SetParent( this );
|
2023-04-01 14:14:35 +00:00
|
|
|
m_padstacks.push_back( aPadstack );
|
2008-02-01 01:09:39 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-02-01 01:09:39 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Add the via only if one exactly like it does not already exist in the padstack container.
|
|
|
|
*
|
|
|
|
* @return the PADSTACK which is registered in the LIBRARY that matches the argument, and
|
|
|
|
* it will be either the argument or a previous padstack which is a duplicate.
|
2008-02-01 01:09:39 +00:00
|
|
|
*/
|
|
|
|
PADSTACK* LookupVia( PADSTACK* aVia )
|
|
|
|
{
|
|
|
|
int ndx = FindVia( aVia );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-02-01 01:09:39 +00:00
|
|
|
if( ndx == -1 )
|
|
|
|
{
|
2009-11-02 05:20:58 +00:00
|
|
|
AppendVia( aVia );
|
2008-02-01 01:09:39 +00:00
|
|
|
return aVia;
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
return &m_vias[ndx];
|
2008-02-01 01:09:39 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-02-09 08:34:45 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Search the padstack container by name.
|
|
|
|
*
|
|
|
|
* @return The PADSTACK with a matching name if it exists, else nullptr.
|
2008-02-09 08:34:45 +00:00
|
|
|
*/
|
|
|
|
PADSTACK* FindPADSTACK( const std::string& aPadstackId )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
for( unsigned i = 0; i < m_padstacks.size(); ++i )
|
2008-02-09 08:34:45 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
PADSTACK* ps = &m_padstacks[i];
|
2021-03-04 21:15:00 +00:00
|
|
|
|
|
|
|
if( ps->GetPadstackId().compare( aPadstackId ) == 0 )
|
2008-02-09 08:34:45 +00:00
|
|
|
return ps;
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
return nullptr;
|
2008-02-09 08:34:45 +00:00
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_unit )
|
|
|
|
m_unit->Format( out, nestLevel );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( IMAGES::iterator i = m_images.begin(); i != m_images.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
i->Format( out, nestLevel );
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( PADSTACKS::iterator i = m_padstacks.begin(); i != m_padstacks.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
i->Format( out, nestLevel );
|
2009-11-02 05:20:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( PADSTACKS::iterator i = m_vias.begin(); i != m_vias.end(); ++i )
|
2009-11-02 05:20:58 +00:00
|
|
|
i->Format( out, nestLevel );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
UNIT_RES* GetUnits() const override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_unit )
|
|
|
|
return m_unit;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
return ELEM::GetUnits();
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
UNIT_RES* m_unit;
|
|
|
|
IMAGES m_images;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
PADSTACKS m_padstacks; ///< all except vias, which are in 'vias'
|
|
|
|
PADSTACKS m_vias;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* A <pin_reference> definition in the specctra dsn spec.
|
2008-01-21 20:53:35 +00:00
|
|
|
*/
|
2008-02-21 06:04:32 +00:00
|
|
|
struct PIN_REF : public ELEM
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
PIN_REF( ELEM* aParent ) :
|
|
|
|
ELEM( T_pin, aParent )
|
|
|
|
{
|
|
|
|
}
|
2008-01-23 22:37:55 +00:00
|
|
|
|
2008-02-21 06:04:32 +00:00
|
|
|
|
2008-01-23 22:37:55 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Like Format() but is not virtual.
|
|
|
|
*
|
|
|
|
* @return the number of characters that were output.
|
2008-01-23 22:37:55 +00:00
|
|
|
*/
|
2017-06-08 21:47:21 +00:00
|
|
|
int FormatIt( OUTPUTFORMATTER* out, int nestLevel )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
// only print the newline if there is a nest level, and make
|
|
|
|
// the quotes unconditional on this one.
|
|
|
|
const char* newline = nestLevel ? "\n" : "";
|
2008-01-30 19:16:46 +00:00
|
|
|
|
|
|
|
const char* cquote = out->GetQuoteChar( component_id.c_str() );
|
|
|
|
const char* pquote = out->GetQuoteChar( pin_id.c_str() );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
return out->Print( nestLevel, "%s%s%s-%s%s%s%s", cquote, component_id.c_str(), cquote,
|
|
|
|
pquote, pin_id.c_str(), pquote, newline );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
std::string component_id;
|
|
|
|
std::string pin_id;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
typedef std::vector<PIN_REF> PIN_REFS;
|
|
|
|
|
|
|
|
|
|
|
|
class FROMTO : public ELEM
|
|
|
|
{
|
2008-02-07 20:23:58 +00:00
|
|
|
public:
|
2008-01-21 20:53:35 +00:00
|
|
|
FROMTO( ELEM* aParent ) :
|
|
|
|
ELEM( T_fromto, aParent )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
m_rules = nullptr;
|
|
|
|
m_fromto_type = DSN_T( T_NONE );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
|
|
|
~FROMTO()
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
delete m_rules;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
// no quoting on these two, the lexer preserved the quotes on input
|
2008-02-07 20:23:58 +00:00
|
|
|
out->Print( nestLevel, "(%s %s %s ",
|
2023-04-01 14:14:35 +00:00
|
|
|
Name(), m_fromText.c_str(), m_toText.c_str() );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_fromto_type != DSN_T( T_NONE ) )
|
|
|
|
out->Print( 0, "(type %s)", GetTokenText( m_fromto_type ) );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_net_id.size() )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
const char* quote = out->GetQuoteChar( m_net_id.c_str() );
|
|
|
|
out->Print( 0, "(net %s%s%s)", quote, m_net_id.c_str(), quote );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool singleLine = true;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_rules || m_layer_rules.size() )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
out->Print( 0, "\n" );
|
|
|
|
singleLine = false;
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_rules )
|
|
|
|
m_rules->Format( out, nestLevel+1 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
/*
|
|
|
|
if( circuit.size() )
|
|
|
|
out->Print( nestLevel, "%s\n", circuit.c_str() );
|
|
|
|
*/
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( LAYER_RULES::iterator i = m_layer_rules.begin(); i != m_layer_rules.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
i->Format( out, nestLevel+1 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
out->Print( singleLine ? 0 : nestLevel, ")" );
|
2021-03-04 21:15:00 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
if( nestLevel || !singleLine )
|
|
|
|
out->Print( 0, "\n" );
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
std::string m_fromText;
|
|
|
|
std::string m_toText;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
DSN_T m_fromto_type;
|
|
|
|
std::string m_net_id;
|
|
|
|
RULE* m_rules;
|
|
|
|
// std::string m_circuit;
|
|
|
|
LAYER_RULES m_layer_rules;
|
2021-07-19 23:56:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef boost::ptr_vector<FROMTO> FROMTOS;
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
/**
|
|
|
|
* The <component_order_descriptor>
|
|
|
|
*/
|
|
|
|
class COMP_ORDER : public ELEM
|
|
|
|
{
|
2008-02-07 20:23:58 +00:00
|
|
|
public:
|
2008-01-21 20:53:35 +00:00
|
|
|
COMP_ORDER( ELEM* aParent ) :
|
|
|
|
ELEM( T_comp_order, aParent )
|
|
|
|
{
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2009-12-11 04:55:24 +00:00
|
|
|
out->Print( nestLevel, "(%s", Name() );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( STRINGS::iterator i = m_placement_ids.begin(); i != m_placement_ids.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
const char* quote = out->GetQuoteChar( i->c_str() );
|
|
|
|
out->Print( 0, " %s%s%s", quote, i->c_str(), quote );
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
out->Print( 0, ")" );
|
2021-03-04 21:15:00 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
if( nestLevel )
|
|
|
|
out->Print( 0, "\n" );
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
STRINGS m_placement_ids;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-02-29 06:49:34 +00:00
|
|
|
typedef boost::ptr_vector<COMP_ORDER> COMP_ORDERS;
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2009-02-07 16:45:07 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* A <net_descriptor> in the DSN spec.
|
2009-02-07 16:45:07 +00:00
|
|
|
*/
|
2008-01-21 20:53:35 +00:00
|
|
|
class NET : public ELEM
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NET( ELEM* aParent ) :
|
|
|
|
ELEM( T_net, aParent )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
m_unassigned = false;
|
|
|
|
m_net_number = T_NONE;
|
|
|
|
m_pins_type = T_pins;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
m_type = T_NONE;
|
|
|
|
m_supply = T_NONE;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
m_rules = nullptr;
|
|
|
|
m_comp_order = nullptr;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
~NET()
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
delete m_rules;
|
|
|
|
delete m_comp_order;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-02-21 06:04:32 +00:00
|
|
|
int FindPIN_REF( const std::string& aComponent )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
for( unsigned i = 0; i < m_pins.size(); ++i )
|
2008-02-21 06:04:32 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
if( aComponent.compare( m_pins[i].component_id ) == 0 )
|
2008-02-21 06:04:32 +00:00
|
|
|
return int(i);
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-02-21 06:04:32 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
const char* quote = out->GetQuoteChar( m_net_id.c_str() );
|
2008-08-05 15:48:30 +00:00
|
|
|
const char* space = " ";
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
out->Print( nestLevel, "(%s %s%s%s", Name(), quote, m_net_id.c_str(), quote );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_unassigned )
|
2008-08-05 15:48:30 +00:00
|
|
|
{
|
|
|
|
out->Print( 0, "%s(unassigned)", space );
|
|
|
|
space = ""; // only needed one space
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_net_number != T_NONE )
|
2008-08-05 15:48:30 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
out->Print( 0, "%s(net_number %d)", space, m_net_number );
|
2008-08-05 15:48:30 +00:00
|
|
|
// space = "";
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
out->Print( 0, "\n" );
|
2008-01-23 22:37:55 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_pins.size() )
|
2008-01-23 22:37:55 +00:00
|
|
|
{
|
2009-02-07 16:45:07 +00:00
|
|
|
const int RIGHTMARGIN = 80;
|
2023-04-01 14:14:35 +00:00
|
|
|
int perLine = out->Print( nestLevel+1, "(%s", GetTokenText( m_pins_type ) );
|
2009-02-07 16:45:07 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( PIN_REFS::iterator i = m_pins.begin(); i != m_pins.end(); ++i )
|
2008-01-23 22:37:55 +00:00
|
|
|
{
|
2009-02-07 16:45:07 +00:00
|
|
|
if( perLine > RIGHTMARGIN )
|
|
|
|
{
|
|
|
|
out->Print( 0, "\n");
|
|
|
|
perLine = out->Print( nestLevel+2, "%s", "" );
|
|
|
|
}
|
|
|
|
else
|
2021-03-04 21:15:00 +00:00
|
|
|
{
|
2009-02-07 16:45:07 +00:00
|
|
|
perLine += out->Print( 0, " " );
|
2021-03-04 21:15:00 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2009-02-07 16:45:07 +00:00
|
|
|
perLine += i->FormatIt( out, 0 );
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2009-02-07 16:45:07 +00:00
|
|
|
out->Print( 0, ")\n" );
|
2008-01-23 22:37:55 +00:00
|
|
|
}
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_comp_order )
|
|
|
|
m_comp_order->Format( out, nestLevel+1 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_type != T_NONE )
|
|
|
|
out->Print( nestLevel+1, "(type %s)\n", GetTokenText( m_type ) );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_rules )
|
|
|
|
m_rules->Format( out, nestLevel+1 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( LAYER_RULES::iterator i = m_layer_rules.begin(); i != m_layer_rules.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
i->Format( out, nestLevel+1 );
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( FROMTOS::iterator i = m_fromtos.begin(); i != m_fromtos.end(); ++i )
|
2008-01-23 22:37:55 +00:00
|
|
|
i->Format( out, nestLevel+1 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
out->Print( nestLevel, ")\n" );
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
private:
|
2008-01-21 20:53:35 +00:00
|
|
|
friend class SPECCTRA_DB;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
std::string m_net_id;
|
|
|
|
bool m_unassigned;
|
|
|
|
int m_net_number;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
DSN_T m_pins_type; ///< T_pins | T_order, type of field 'pins' below
|
|
|
|
PIN_REFS m_pins;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
PIN_REFS m_expose;
|
|
|
|
PIN_REFS m_noexpose;
|
|
|
|
PIN_REFS m_source;
|
|
|
|
PIN_REFS m_load;
|
|
|
|
PIN_REFS m_terminator;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
DSN_T m_type; ///< T_fix | T_normal
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
DSN_T m_supply; ///< T_power | T_ground
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
RULE* m_rules;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
LAYER_RULES m_layer_rules;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
FROMTOS m_fromtos;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
COMP_ORDER* m_comp_order;
|
2021-07-19 23:56:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef boost::ptr_vector<NET> NETS;
|
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
class TOPOLOGY : public ELEM
|
|
|
|
{
|
2008-02-07 20:23:58 +00:00
|
|
|
public:
|
2008-01-21 20:53:35 +00:00
|
|
|
TOPOLOGY( ELEM* aParent ) :
|
|
|
|
ELEM( T_topology, aParent )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
for( FROMTOS::iterator i = m_fromtos.begin(); i != m_fromtos.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
i->Format( out, nestLevel );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( COMP_ORDERS::iterator i = m_comp_orders.begin(); i != m_comp_orders.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
i->Format( out, nestLevel );
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
FROMTOS m_fromtos;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
COMP_ORDERS m_comp_orders;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-22 05:55:06 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* The <class_descriptor> in the specctra spec.
|
2008-03-22 05:55:06 +00:00
|
|
|
*/
|
2008-01-21 20:53:35 +00:00
|
|
|
class CLASS : public ELEM
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CLASS( ELEM* aParent ) :
|
|
|
|
ELEM( T_class, aParent )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
m_rules = nullptr;
|
|
|
|
m_topology = nullptr;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
~CLASS()
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
delete m_rules;
|
|
|
|
delete m_topology;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
const char* quote = out->GetQuoteChar( m_class_id.c_str() );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
int perLine = out->Print( nestLevel, "(%s %s%s%s", Name(), quote, m_class_id.c_str(), quote );
|
2008-01-24 21:47:54 +00:00
|
|
|
|
2008-02-29 06:49:34 +00:00
|
|
|
const int RIGHTMARGIN = 72;
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( STRINGS::iterator i=m_net_ids.begin(); i!=m_net_ids.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2008-02-29 06:49:34 +00:00
|
|
|
const char* space = " ";
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-01-24 21:47:54 +00:00
|
|
|
if( perLine > RIGHTMARGIN )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
out->Print( 0, "\n" );
|
2008-01-24 21:47:54 +00:00
|
|
|
perLine = out->Print( nestLevel+1, "%s", "" );
|
2008-02-29 06:49:34 +00:00
|
|
|
space = ""; // no space at first net_id of the line
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-24 21:47:54 +00:00
|
|
|
quote = out->GetQuoteChar( i->c_str() );
|
2008-02-29 06:49:34 +00:00
|
|
|
perLine += out->Print( 0, "%s%s%s%s", space, quote, i->c_str(), quote );
|
2008-01-24 21:47:54 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-24 21:47:54 +00:00
|
|
|
bool newLine = false;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_circuit.size() || m_rules || m_layer_rules.size() || m_topology )
|
2008-01-24 21:47:54 +00:00
|
|
|
{
|
|
|
|
out->Print( 0, "\n" );
|
|
|
|
newLine = true;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_circuit.size() )
|
2008-02-29 06:49:34 +00:00
|
|
|
{
|
|
|
|
out->Print( nestLevel+1, "(circuit\n" );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( STRINGS::iterator i = m_circuit.begin(); i != m_circuit.end(); ++i )
|
2021-07-19 23:56:05 +00:00
|
|
|
out->Print( nestLevel + 2, "%s\n", i->c_str() );
|
|
|
|
|
2008-02-29 06:49:34 +00:00
|
|
|
out->Print( nestLevel+1, ")\n" );
|
|
|
|
}
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_rules )
|
|
|
|
m_rules->Format( out, nestLevel+1 );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( LAYER_RULES::iterator i = m_layer_rules.begin(); i != m_layer_rules.end(); ++i )
|
2021-07-19 23:56:05 +00:00
|
|
|
i->Format( out, nestLevel + 1 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_topology )
|
|
|
|
m_topology->Format( out, nestLevel+1 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-24 21:47:54 +00:00
|
|
|
out->Print( newLine ? nestLevel : 0, ")\n" );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
std::string m_class_id;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
STRINGS m_net_ids;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
/// circuit descriptor list
|
2023-04-01 14:14:35 +00:00
|
|
|
STRINGS m_circuit;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
RULE* m_rules;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
LAYER_RULES m_layer_rules;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
TOPOLOGY* m_topology;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-02-29 06:49:34 +00:00
|
|
|
typedef boost::ptr_vector<CLASS> CLASSLIST;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
|
|
|
|
class NETWORK : public ELEM
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NETWORK( ELEM* aParent ) :
|
|
|
|
ELEM( T_network, aParent )
|
|
|
|
{
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
for( NETS::iterator i = m_nets.begin(); i != m_nets.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
i->Format( out, nestLevel );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( CLASSLIST::iterator i = m_classes.begin(); i != m_classes.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
i->Format( out, nestLevel );
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
NETS m_nets;
|
|
|
|
CLASSLIST m_classes;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class CONNECT : public ELEM
|
|
|
|
{
|
2008-01-29 16:45:14 +00:00
|
|
|
// @todo not completed.
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-28 05:49:15 +00:00
|
|
|
public:
|
2016-04-22 10:44:08 +00:00
|
|
|
CONNECT( ELEM* aParent ) :
|
|
|
|
ELEM( T_connect, aParent ) {}
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* A <wire_shape_descriptor> in the specctra dsn spec.
|
2008-01-21 20:53:35 +00:00
|
|
|
*/
|
|
|
|
class WIRE : public ELEM
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
WIRE( ELEM* aParent ) :
|
|
|
|
ELEM( T_wire, aParent )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
m_shape = nullptr;
|
|
|
|
m_connect = nullptr;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
m_turret = -1;
|
|
|
|
m_wire_type = T_NONE;
|
|
|
|
m_attr = T_NONE;
|
|
|
|
m_supply = false;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
~WIRE()
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
delete m_shape;
|
|
|
|
delete m_connect;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
|
|
|
|
2008-01-31 01:30:52 +00:00
|
|
|
void SetShape( ELEM* aShape )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
delete m_shape;
|
|
|
|
m_shape = aShape;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-31 01:30:52 +00:00
|
|
|
if( aShape )
|
|
|
|
{
|
2008-02-07 20:23:58 +00:00
|
|
|
wxASSERT(aShape->Type()==T_rect || aShape->Type()==T_circle
|
|
|
|
|| aShape->Type()==T_qarc || aShape->Type()==T_path
|
2008-01-31 01:30:52 +00:00
|
|
|
|| aShape->Type()==T_polygon);
|
2008-02-07 20:23:58 +00:00
|
|
|
|
|
|
|
aShape->SetParent( this );
|
2008-01-31 01:30:52 +00:00
|
|
|
}
|
|
|
|
}
|
2008-01-31 06:46:31 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-31 01:30:52 +00:00
|
|
|
{
|
2009-12-11 04:55:24 +00:00
|
|
|
out->Print( nestLevel, "(%s ", Name() );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_shape )
|
|
|
|
m_shape->Format( out, 0 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_net_id.size() )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
const char* quote = out->GetQuoteChar( m_net_id.c_str() );
|
|
|
|
out->Print( 0, "(net %s%s%s)", quote, m_net_id.c_str(), quote );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_turret >= 0 )
|
|
|
|
out->Print( 0, "(turrent %d)", m_turret );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_wire_type != T_NONE )
|
|
|
|
out->Print( 0, "(type %s)", GetTokenText( m_wire_type ) );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_attr != T_NONE )
|
|
|
|
out->Print( 0, "(attr %s)", GetTokenText( m_attr ) );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_shield.size() )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
const char* quote = out->GetQuoteChar( m_shield.c_str() );
|
|
|
|
out->Print( 0, "(shield %s%s%s)", quote, m_shield.c_str(), quote );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_windows.size() )
|
2008-01-31 06:46:31 +00:00
|
|
|
{
|
|
|
|
out->Print( 0, "\n" );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( WINDOWS::iterator i = m_windows.begin(); i != m_windows.end(); ++i )
|
2021-07-19 23:56:05 +00:00
|
|
|
i->Format( out, nestLevel + 1 );
|
2008-01-31 06:46:31 +00:00
|
|
|
}
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_connect )
|
|
|
|
m_connect->Format( out, 0 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_supply )
|
2008-01-31 06:46:31 +00:00
|
|
|
out->Print( 0, "(supply)" );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-31 06:46:31 +00:00
|
|
|
out->Print( 0, ")\n" );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
private:
|
2008-01-21 20:53:35 +00:00
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
/* <shape_descriptor >::=
|
|
|
|
[<rectangle_descriptor> |
|
|
|
|
<circle_descriptor> |
|
|
|
|
<polygon_descriptor> |
|
|
|
|
<path_descriptor> |
|
|
|
|
<qarc_descriptor> ]
|
|
|
|
*/
|
2023-04-01 14:14:35 +00:00
|
|
|
ELEM* m_shape;
|
|
|
|
|
|
|
|
std::string m_net_id;
|
|
|
|
int m_turret;
|
|
|
|
DSN_T m_wire_type;
|
|
|
|
DSN_T m_attr;
|
|
|
|
std::string m_shield;
|
|
|
|
WINDOWS m_windows;
|
|
|
|
CONNECT* m_connect;
|
|
|
|
bool m_supply;
|
2021-07-19 23:56:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef boost::ptr_vector<WIRE> WIRES;
|
2008-01-23 22:37:55 +00:00
|
|
|
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
/**
|
|
|
|
* A <wire_via_descriptor> in the specctra dsn spec.
|
|
|
|
*/
|
|
|
|
class WIRE_VIA : public ELEM
|
|
|
|
{
|
2008-01-21 20:53:35 +00:00
|
|
|
public:
|
|
|
|
WIRE_VIA( ELEM* aParent ) :
|
|
|
|
ELEM( T_via, aParent )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
m_via_number = -1;
|
|
|
|
m_via_type = T_NONE;
|
|
|
|
m_attr = T_NONE;
|
|
|
|
m_supply = false;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
|
|
|
|
2008-02-09 08:34:45 +00:00
|
|
|
const std::string& GetPadstackId()
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
return m_padstack_id;
|
2008-02-09 08:34:45 +00:00
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
const char* quote = out->GetQuoteChar( m_padstack_id.c_str() );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
|
|
|
const int RIGHTMARGIN = 80;
|
2023-04-01 14:14:35 +00:00
|
|
|
int perLine = out->Print( nestLevel, "(%s %s%s%s", Name(), quote, m_padstack_id.c_str(),
|
2021-07-19 23:56:05 +00:00
|
|
|
quote );
|
2008-01-23 22:37:55 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( POINTS::iterator i = m_vertexes.begin(); i != m_vertexes.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2008-01-23 22:37:55 +00:00
|
|
|
if( perLine > RIGHTMARGIN )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
out->Print( 0, "\n" );
|
2008-01-23 22:37:55 +00:00
|
|
|
perLine = out->Print( nestLevel+1, "%s", "" );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
|
|
|
else
|
2021-07-19 23:56:05 +00:00
|
|
|
{
|
2008-01-23 22:37:55 +00:00
|
|
|
perLine += out->Print( 0, " " );
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
|
|
|
perLine += out->Print( 0, "%.6g %.6g", i->x, i->y );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_net_id.size() || m_via_number!=-1 || m_via_type!=T_NONE || m_attr!=T_NONE || m_supply)
|
2008-01-24 21:47:54 +00:00
|
|
|
out->Print( 0, " " );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_net_id.size() )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2008-01-23 22:37:55 +00:00
|
|
|
if( perLine > RIGHTMARGIN )
|
|
|
|
{
|
|
|
|
out->Print( 0, "\n" );
|
|
|
|
perLine = out->Print( nestLevel+1, "%s", "" );
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
quote = out->GetQuoteChar( m_net_id.c_str() );
|
|
|
|
perLine += out->Print( 0, "(net %s%s%s)", quote, m_net_id.c_str(), quote );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-01-22 20:48:02 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_via_number != -1 )
|
2008-01-23 22:37:55 +00:00
|
|
|
{
|
|
|
|
if( perLine > RIGHTMARGIN )
|
|
|
|
{
|
|
|
|
out->Print( 0, "\n" );
|
|
|
|
perLine = out->Print( nestLevel+1, "%s", "" );
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
perLine += out->Print( 0, "(via_number %d)", m_via_number );
|
2008-01-23 22:37:55 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_via_type != T_NONE )
|
2008-01-23 22:37:55 +00:00
|
|
|
{
|
|
|
|
if( perLine > RIGHTMARGIN )
|
|
|
|
{
|
|
|
|
out->Print( 0, "\n" );
|
|
|
|
perLine = out->Print( nestLevel+1, "%s", "" );
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
perLine += out->Print( 0, "(type %s)", GetTokenText( m_via_type ) );
|
2008-01-23 22:37:55 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_attr != T_NONE )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2008-01-23 22:37:55 +00:00
|
|
|
if( perLine > RIGHTMARGIN )
|
|
|
|
{
|
|
|
|
out->Print( 0, "\n" );
|
|
|
|
perLine = out->Print( nestLevel+1, "%s", "" );
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_attr == T_virtual_pin )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
quote = out->GetQuoteChar( m_virtual_pin_name.c_str() );
|
2021-07-19 23:56:05 +00:00
|
|
|
perLine += out->Print( 0, "(attr virtual_pin %s%s%s)", quote,
|
2023-04-01 14:14:35 +00:00
|
|
|
m_virtual_pin_name.c_str(), quote );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
|
|
|
else
|
2021-07-19 23:56:05 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
perLine += out->Print( 0, "(attr %s)", GetTokenText( m_attr ) );
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2008-01-23 22:37:55 +00:00
|
|
|
}
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_supply )
|
2008-01-23 22:37:55 +00:00
|
|
|
{
|
|
|
|
if( perLine > RIGHTMARGIN )
|
|
|
|
{
|
|
|
|
out->Print( 0, "\n" );
|
|
|
|
perLine = out->Print( nestLevel+1, "%s", "" );
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-01-23 22:37:55 +00:00
|
|
|
perLine += out->Print( 0, "(supply)" );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_contact_layers.size() )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2008-01-23 22:37:55 +00:00
|
|
|
out->Print( 0, "\n" );
|
2008-01-21 20:53:35 +00:00
|
|
|
out->Print( nestLevel+1, "(contact\n" );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
for( STRINGS::iterator i = m_contact_layers.begin(); i != m_contact_layers.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2016-04-22 10:44:08 +00:00
|
|
|
quote = out->GetQuoteChar( i->c_str() );
|
2008-01-21 20:53:35 +00:00
|
|
|
out->Print( nestLevel+2, "%s%s%s\n", quote, i->c_str(), quote );
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-01-23 22:37:55 +00:00
|
|
|
out->Print( nestLevel+1, "))\n" );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-01-23 22:37:55 +00:00
|
|
|
else
|
2021-07-19 23:56:05 +00:00
|
|
|
{
|
2008-01-23 22:37:55 +00:00
|
|
|
out->Print( 0, ")\n" );
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
std::string m_padstack_id;
|
|
|
|
POINTS m_vertexes;
|
|
|
|
std::string m_net_id;
|
|
|
|
int m_via_number;
|
|
|
|
DSN_T m_via_type;
|
|
|
|
DSN_T m_attr;
|
|
|
|
std::string m_virtual_pin_name;
|
|
|
|
STRINGS m_contact_layers;
|
|
|
|
bool m_supply;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
typedef boost::ptr_vector<WIRE_VIA> WIRE_VIAS;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* A <wiring_descriptor> in the specctra dsn spec.
|
2008-01-21 20:53:35 +00:00
|
|
|
*/
|
|
|
|
class WIRING : public ELEM
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
WIRING( ELEM* aParent ) :
|
|
|
|
ELEM( T_wiring, aParent )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
unit = nullptr;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
~WIRING()
|
|
|
|
{
|
|
|
|
delete unit;
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
if( unit )
|
|
|
|
unit->Format( out, nestLevel );
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
for( WIRES::iterator i = wires.begin(); i != wires.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
i->Format( out, nestLevel );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
for( WIRE_VIAS::iterator i = wire_vias.begin(); i != wire_vias.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
i->Format( out, nestLevel );
|
|
|
|
}
|
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
UNIT_RES* GetUnits() const override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
if( unit )
|
2008-02-07 20:23:58 +00:00
|
|
|
return unit;
|
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
return ELEM::GetUnits();
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
|
|
|
UNIT_RES* unit;
|
|
|
|
WIRES wires;
|
|
|
|
WIRE_VIAS wire_vias;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class PCB : public ELEM
|
|
|
|
{
|
|
|
|
public:
|
2023-04-01 14:14:35 +00:00
|
|
|
PCB( ELEM* aParent = nullptr ) :
|
2008-01-21 20:53:35 +00:00
|
|
|
ELEM( T_pcb, aParent )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
m_parser = nullptr;
|
|
|
|
m_resolution = nullptr;
|
|
|
|
m_unit = nullptr;
|
|
|
|
m_structure = nullptr;
|
|
|
|
m_placement = nullptr;
|
|
|
|
m_library = nullptr;
|
|
|
|
m_network = nullptr;
|
|
|
|
m_wiring = nullptr;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
~PCB()
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
delete m_parser;
|
|
|
|
delete m_resolution;
|
|
|
|
delete m_unit;
|
|
|
|
delete m_structure;
|
|
|
|
delete m_placement;
|
|
|
|
delete m_library;
|
|
|
|
delete m_network;
|
|
|
|
delete m_wiring;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
const char* quote = out->GetQuoteChar( m_pcbname.c_str() );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
out->Print( nestLevel, "(%s %s%s%s\n", Name(), quote, m_pcbname.c_str(), quote );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_parser )
|
|
|
|
m_parser->Format( out, nestLevel+1 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_resolution )
|
|
|
|
m_resolution->Format( out, nestLevel+1 );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_unit )
|
|
|
|
m_unit->Format( out, nestLevel+1 );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_structure )
|
|
|
|
m_structure->Format( out, nestLevel+1 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_placement )
|
|
|
|
m_placement->Format( out, nestLevel+1 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_library )
|
|
|
|
m_library->Format( out, nestLevel+1 );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_network )
|
|
|
|
m_network->Format( out, nestLevel+1 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_wiring )
|
|
|
|
m_wiring->Format( out, nestLevel+1 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
|
|
|
out->Print( nestLevel, ")\n" );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
UNIT_RES* GetUnits() const override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_unit )
|
|
|
|
return m_unit;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
if( m_resolution )
|
|
|
|
return m_resolution->GetUnits();
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
return ELEM::GetUnits();
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
private:
|
2008-01-21 20:53:35 +00:00
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
std::string m_pcbname;
|
|
|
|
PARSER* m_parser;
|
|
|
|
UNIT_RES* m_resolution;
|
|
|
|
UNIT_RES* m_unit;
|
|
|
|
STRUCTURE* m_structure;
|
|
|
|
PLACEMENT* m_placement;
|
|
|
|
LIBRARY* m_library;
|
|
|
|
NETWORK* m_network;
|
|
|
|
WIRING* m_wiring;
|
2021-07-19 23:56:05 +00:00
|
|
|
};
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
class ANCESTOR : public ELEM
|
|
|
|
{
|
2008-01-21 20:53:35 +00:00
|
|
|
public:
|
|
|
|
ANCESTOR( ELEM* aParent ) :
|
|
|
|
ELEM( T_ancestor, aParent )
|
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
time_stamp = time(nullptr);
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
char temp[80];
|
|
|
|
struct tm* tmp;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
tmp = localtime( &time_stamp );
|
|
|
|
strftime( temp, sizeof(temp), "%b %d %H : %M : %S %Y", tmp );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
// format the time first to temp
|
|
|
|
// filename may be empty, so quote it just in case.
|
2021-07-19 23:56:05 +00:00
|
|
|
out->Print( nestLevel, "(%s \"%s\" (created_time %s)\n", Name(), filename.c_str(), temp );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
if( comment.size() )
|
|
|
|
{
|
|
|
|
const char* quote = out->GetQuoteChar( comment.c_str() );
|
2021-07-19 23:56:05 +00:00
|
|
|
out->Print( nestLevel+1, "(comment %s%s%s)\n", quote, comment.c_str(), quote );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
out->Print( nestLevel, ")\n" );
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
|
|
|
std::string filename;
|
|
|
|
std::string comment;
|
|
|
|
time_t time_stamp;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
typedef boost::ptr_vector<ANCESTOR> ANCESTORS;
|
|
|
|
|
|
|
|
|
|
|
|
class HISTORY : public ELEM
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
HISTORY( ELEM* aParent ) :
|
|
|
|
ELEM( T_history, aParent )
|
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
time_stamp = time(nullptr);
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
for( ANCESTORS::iterator i=ancestors.begin(); i!=ancestors.end(); ++i )
|
|
|
|
i->Format( out, nestLevel );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
char temp[80];
|
|
|
|
struct tm* tmp;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
tmp = localtime( &time_stamp );
|
2021-07-19 23:56:05 +00:00
|
|
|
strftime( temp, sizeof( temp ), "%b %d %H : %M : %S %Y", tmp );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
// format the time first to temp
|
|
|
|
out->Print( nestLevel, "(self (created_time %s)\n", temp );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
for( STRINGS::iterator i=comments.begin(); i!=comments.end(); ++i )
|
|
|
|
{
|
|
|
|
const char* quote = out->GetQuoteChar( i->c_str() );
|
2021-07-19 23:56:05 +00:00
|
|
|
out->Print( nestLevel+1, "(comment %s%s%s)\n", quote, i->c_str(), quote );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
out->Print( nestLevel, ")\n" );
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
|
|
|
ANCESTORS ancestors;
|
|
|
|
time_t time_stamp;
|
|
|
|
STRINGS comments;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* A <supply_pin_descriptor> in the specctra dsn spec.
|
|
|
|
*/
|
2008-01-21 20:53:35 +00:00
|
|
|
class SUPPLY_PIN : public ELEM
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SUPPLY_PIN( ELEM* aParent ) :
|
|
|
|
ELEM( T_supply_pin, aParent )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
bool singleLine = pin_refs.size() <= 1;
|
2009-12-11 04:55:24 +00:00
|
|
|
out->Print( nestLevel, "(%s", Name() );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
if( singleLine )
|
|
|
|
{
|
|
|
|
out->Print( 0, "%s", " " );
|
|
|
|
pin_refs.begin()->Format( out, 0 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
for( PIN_REFS::iterator i = pin_refs.begin(); i != pin_refs.end(); ++i )
|
|
|
|
i->FormatIt( out, nestLevel + 1 );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
if( net_id.size() )
|
|
|
|
{
|
|
|
|
const char* newline = singleLine ? "" : "\n";
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
const char* quote = out->GetQuoteChar( net_id.c_str() );
|
2021-07-19 23:56:05 +00:00
|
|
|
out->Print( singleLine ? 0 : nestLevel+1, " (net %s%s%s)%s",
|
|
|
|
quote, net_id.c_str(), quote, newline );
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
out->Print( singleLine ? 0 : nestLevel, ")\n");
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
|
|
|
PIN_REFS pin_refs;
|
|
|
|
std::string net_id;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
typedef boost::ptr_vector<SUPPLY_PIN> SUPPLY_PINS;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* A <net_out_descriptor> of the specctra dsn spec.
|
2008-01-21 20:53:35 +00:00
|
|
|
*/
|
|
|
|
class NET_OUT : public ELEM
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NET_OUT( ELEM* aParent ) :
|
|
|
|
ELEM( T_net_out, aParent )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
rules = nullptr;
|
2008-01-21 20:53:35 +00:00
|
|
|
net_number = -1;
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
~NET_OUT()
|
|
|
|
{
|
|
|
|
delete rules;
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
const char* quote = out->GetQuoteChar( net_id.c_str() );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
|
|
|
// cannot use Type() here, it is T_net_out and we need "(net "
|
2021-07-19 23:56:05 +00:00
|
|
|
out->Print( nestLevel, "(net %s%s%s\n", quote, net_id.c_str(), quote );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
|
|
|
if( net_number>= 0 )
|
|
|
|
out->Print( nestLevel+1, "(net_number %d)\n", net_number );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
if( rules )
|
2008-02-07 20:23:58 +00:00
|
|
|
rules->Format( out, nestLevel+1 );
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
for( WIRES::iterator i = wires.begin(); i != wires.end(); ++i )
|
|
|
|
i->Format( out, nestLevel + 1 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
for( WIRE_VIAS::iterator i = wire_vias.begin(); i != wire_vias.end(); ++i )
|
|
|
|
i->Format( out, nestLevel + 1 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
for( SUPPLY_PINS::iterator i = supply_pins.begin(); i != supply_pins.end(); ++i )
|
|
|
|
i->Format( out, nestLevel + 1 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
out->Print( nestLevel, ")\n" );
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
|
|
|
std::string net_id;
|
|
|
|
int net_number;
|
|
|
|
RULE* rules;
|
|
|
|
WIRES wires;
|
|
|
|
WIRE_VIAS wire_vias;
|
|
|
|
SUPPLY_PINS supply_pins;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
typedef boost::ptr_vector<NET_OUT> NET_OUTS;
|
|
|
|
|
|
|
|
|
|
|
|
class ROUTE : public ELEM
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ROUTE( ELEM* aParent ) :
|
|
|
|
ELEM( T_route, aParent )
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
resolution = nullptr;
|
|
|
|
parser = nullptr;
|
|
|
|
structure_out = nullptr;
|
|
|
|
library = nullptr;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
~ROUTE()
|
|
|
|
{
|
|
|
|
delete resolution;
|
|
|
|
delete parser;
|
2009-07-13 22:59:56 +00:00
|
|
|
delete structure_out;
|
2008-01-21 20:53:35 +00:00
|
|
|
delete library;
|
|
|
|
// delete test_points;
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
UNIT_RES* GetUnits() const override
|
2008-02-08 00:16:59 +00:00
|
|
|
{
|
|
|
|
if( resolution )
|
|
|
|
return resolution;
|
|
|
|
|
|
|
|
return ELEM::GetUnits();
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
if( resolution )
|
|
|
|
resolution->Format( out, nestLevel );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
if( parser )
|
|
|
|
parser->Format( out, nestLevel );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2009-07-13 22:59:56 +00:00
|
|
|
if( structure_out )
|
|
|
|
structure_out->Format( out, nestLevel );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
if( library )
|
|
|
|
library->Format( out, nestLevel );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
if( net_outs.size() )
|
|
|
|
{
|
|
|
|
out->Print( nestLevel, "(network_out\n" );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
for( NET_OUTS::iterator i = net_outs.begin(); i != net_outs.end(); ++i )
|
|
|
|
i->Format( out, nestLevel + 1 );
|
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
out->Print( nestLevel, ")\n" );
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
// if( test_poinst )
|
|
|
|
// test_points->Format( out, nestLevel );
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
|
|
|
UNIT_RES* resolution;
|
|
|
|
PARSER* parser;
|
|
|
|
STRUCTURE_OUT* structure_out;
|
|
|
|
LIBRARY* library;
|
|
|
|
NET_OUTS net_outs;
|
|
|
|
// TEST_POINTS* test_points;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Used within the WAS_IS class below to hold a pair of PIN_REFs and corresponds to the (pins
|
|
|
|
* was is) construct within the specctra dsn spec.
|
2008-01-21 20:53:35 +00:00
|
|
|
*/
|
|
|
|
struct PIN_PAIR
|
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
PIN_PAIR( ELEM* aParent = nullptr ) :
|
2008-01-21 20:53:35 +00:00
|
|
|
was( aParent ),
|
|
|
|
is( aParent )
|
|
|
|
{
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
PIN_REF was;
|
|
|
|
PIN_REF is;
|
|
|
|
};
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
typedef std::vector<PIN_PAIR> PIN_PAIRS;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* A <was_is_descriptor> in the specctra dsn spec.
|
2008-01-21 20:53:35 +00:00
|
|
|
*/
|
|
|
|
class WAS_IS : public ELEM
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
WAS_IS( ELEM* aParent ) :
|
|
|
|
ELEM( T_was_is, aParent )
|
|
|
|
{
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void FormatContents( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
for( PIN_PAIRS::iterator i = pin_pairs.begin(); i != pin_pairs.end(); ++i )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
out->Print( nestLevel, "(pins " );
|
|
|
|
i->was.Format( out, 0 );
|
|
|
|
out->Print( 0, " " );
|
|
|
|
i->is.Format( out, 0 );
|
|
|
|
out->Print( 0, ")\n" );
|
|
|
|
}
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
|
|
|
PIN_PAIRS pin_pairs;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* A <session_file_descriptor> in the specctra dsn spec.
|
2008-01-21 20:53:35 +00:00
|
|
|
*/
|
|
|
|
class SESSION : public ELEM
|
|
|
|
{
|
|
|
|
public:
|
2023-04-01 14:14:35 +00:00
|
|
|
SESSION( ELEM* aParent = nullptr ) :
|
2009-12-11 04:55:24 +00:00
|
|
|
ELEM( T_session, aParent )
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2023-04-01 14:14:35 +00:00
|
|
|
history = nullptr;
|
|
|
|
structure = nullptr;
|
|
|
|
placement = nullptr;
|
|
|
|
was_is = nullptr;
|
|
|
|
route = nullptr;
|
2008-01-21 20:53:35 +00:00
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
~SESSION()
|
|
|
|
{
|
|
|
|
delete history;
|
|
|
|
delete structure;
|
|
|
|
delete placement;
|
|
|
|
delete was_is;
|
|
|
|
delete route;
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void Format( OUTPUTFORMATTER* out, int nestLevel ) override
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
|
|
|
const char* quote = out->GetQuoteChar( session_id.c_str() );
|
2021-07-19 23:56:05 +00:00
|
|
|
out->Print( nestLevel, "(%s %s%s%s\n", Name(), quote, session_id.c_str(), quote );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
out->Print( nestLevel+1, "(base_design \"%s\")\n", base_design.c_str() );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
if( history )
|
|
|
|
history->Format( out, nestLevel+1 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
if( structure )
|
|
|
|
structure->Format( out, nestLevel+1 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
if( placement )
|
|
|
|
placement->Format( out, nestLevel+1 );
|
|
|
|
|
|
|
|
if( was_is )
|
|
|
|
was_is->Format( out, nestLevel+1 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
if( route )
|
|
|
|
route->Format( out, nestLevel+1 );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
out->Print( nestLevel, ")\n" );
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class SPECCTRA_DB;
|
|
|
|
|
|
|
|
std::string session_id;
|
|
|
|
std::string base_design;
|
|
|
|
|
|
|
|
HISTORY* history;
|
|
|
|
STRUCTURE* structure;
|
|
|
|
PLACEMENT* placement;
|
|
|
|
WAS_IS* was_is;
|
|
|
|
ROUTE* route;
|
|
|
|
|
|
|
|
/* not supported:
|
|
|
|
FLOOR_PLAN* floor_plan;
|
|
|
|
NET_PIN_CHANGES* net_pin_changes;
|
|
|
|
SWAP_HISTORY* swap_history;
|
|
|
|
*/
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
|
|
|
|
2008-02-14 01:07:52 +00:00
|
|
|
typedef boost::ptr_set<PADSTACK> PADSTACKSET;
|
|
|
|
|
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* A DSN data tree, usually coming from a DSN file. Is essentially a SPECCTRA_PARSER class.
|
2008-01-21 20:53:35 +00:00
|
|
|
*/
|
2011-01-19 20:46:07 +00:00
|
|
|
class SPECCTRA_DB : public SPECCTRA_LEXER
|
2008-01-21 20:53:35 +00:00
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
public:
|
2009-12-11 04:55:24 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
SPECCTRA_DB() :
|
|
|
|
SPECCTRA_LEXER( 0 ) // LINE_READER* == nullptr, no DSNLEXER::PushReader()
|
|
|
|
{
|
|
|
|
// The LINE_READER will be pushed from an automatic instantiation,
|
|
|
|
// we don't own it:
|
|
|
|
wxASSERT( !iOwnReaders );
|
2008-01-29 16:45:14 +00:00
|
|
|
|
2023-04-01 14:14:35 +00:00
|
|
|
m_pcb = nullptr;
|
|
|
|
m_session = nullptr;
|
2021-07-19 23:56:05 +00:00
|
|
|
m_quote_char += '"';
|
|
|
|
m_footprintsAreFlipped = false;
|
2008-02-14 15:34:40 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
SetSpecctraMode( true );
|
2008-01-31 01:30:52 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
// Avoid not initialized members:
|
|
|
|
m_routeResolution = nullptr;
|
|
|
|
m_sessionBoard = nullptr;
|
|
|
|
m_top_via_layer = 0;
|
|
|
|
m_bot_via_layer = 0;
|
|
|
|
}
|
2008-01-31 06:46:31 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
virtual ~SPECCTRA_DB()
|
|
|
|
{
|
|
|
|
delete m_pcb;
|
|
|
|
delete m_session;
|
2008-02-03 15:23:00 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
deleteNETs();
|
|
|
|
}
|
2008-02-08 00:16:59 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
/**
|
|
|
|
* Make a PCB with all the default ELEMs and parts on the heap.
|
|
|
|
*/
|
|
|
|
static PCB* MakePCB();
|
2008-02-08 00:16:59 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
/**
|
|
|
|
* Delete any existing PCB and replaces it with the given one.
|
|
|
|
*/
|
|
|
|
void SetPCB( PCB* aPcb )
|
|
|
|
{
|
|
|
|
delete m_pcb;
|
|
|
|
m_pcb = aPcb;
|
|
|
|
}
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
PCB* GetPCB() { return m_pcb; }
|
2008-02-14 01:07:52 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
/**
|
|
|
|
* Delete any existing SESSION and replaces it with the given one.
|
|
|
|
*/
|
|
|
|
void SetSESSION( SESSION* aSession )
|
|
|
|
{
|
|
|
|
delete m_session;
|
|
|
|
m_session = aSession;
|
|
|
|
}
|
2008-02-14 01:07:52 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
SESSION* GetSESSION() { return m_session; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A recursive descent parser for a SPECCTRA DSN "design" file.
|
|
|
|
*
|
|
|
|
* A design file is nearly a full description of a PCB (seems to be
|
|
|
|
* missing only the silkscreen stuff).
|
|
|
|
*
|
|
|
|
* @param aFilename The name of the dsn file to load.
|
|
|
|
* @throw IO_ERROR if there is a lexer or parser error.
|
|
|
|
*/
|
|
|
|
void LoadPCB( const wxString& aFilename );
|
2008-02-14 01:07:52 +00:00
|
|
|
|
2008-02-08 00:16:59 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* A recursive descent parser for a SPECCTRA DSN "session" file.
|
|
|
|
*
|
|
|
|
* A session file is a file that is fed back from the router to the layout
|
|
|
|
* tool (Pcbnew) and should be used to update a BOARD object with the new
|
|
|
|
* tracks, vias, and component locations.
|
|
|
|
*
|
|
|
|
* @param aFilename The name of the dsn file to load.
|
|
|
|
* @throw IO_ERROR if there is a lexer or parser error.
|
|
|
|
*/
|
|
|
|
void LoadSESSION( const wxString& aFilename );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Write the internal PCB instance out as a SPECTRA DSN format file.
|
|
|
|
*
|
|
|
|
* @param aFilename The file to save to.
|
|
|
|
* @param aNameChange If true, causes the pcb's name to change to "aFilename"
|
|
|
|
* and also to to be changed in the output file.
|
|
|
|
* @throw IO_ERROR, if an i/o error occurs saving the file.
|
|
|
|
*/
|
|
|
|
void ExportPCB( const wxString& aFilename, bool aNameChange=false );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add the entire BOARD to the PCB but does not write it out.
|
|
|
|
*
|
|
|
|
* @note The #BOARD given to this function must have all the FOOTPRINTs on the component
|
|
|
|
* side of the BOARD.
|
|
|
|
*
|
|
|
|
* @see PCB_EDIT_FRAME::ExportToSpecctra() for an example before calling this function.
|
|
|
|
*
|
|
|
|
* @param aBoard The BOARD to convert to a PCB.
|
|
|
|
*/
|
|
|
|
void FromBOARD( BOARD* aBoard );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add the entire #SESSION info to a #BOARD but does not write it out.
|
|
|
|
*
|
|
|
|
* The #BOARD given to this function will have all its tracks and via's replaced, and all
|
|
|
|
* its components are subject to being moved.
|
|
|
|
*
|
|
|
|
* @param aBoard The #BOARD to merge the #SESSION information into.
|
|
|
|
*/
|
|
|
|
void FromSESSION( BOARD* aBoard );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Write the internal #SESSION instance out as a #SPECTRA DSN format file.
|
|
|
|
*
|
|
|
|
* @param aFilename The file to save to.
|
|
|
|
*/
|
|
|
|
void ExportSESSION( const wxString& aFilename );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Build the board outlines and store it in m_brd_outlines.
|
|
|
|
*
|
|
|
|
* Because it calls GetBoardPolygonOutlines() it *must be* called before flipping footprints
|
|
|
|
*
|
|
|
|
* @return false if the board outlines cannot be built (not closed outlines)
|
|
|
|
*/
|
|
|
|
bool BuiltBoardOutlines( BOARD* aBoard );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Flip the footprints which are on the back side of the board to the front.
|
|
|
|
*/
|
|
|
|
void FlipFOOTPRINTs( BOARD* aBoard );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Flip the footprints which were on the back side of the board back to the back.
|
|
|
|
*/
|
|
|
|
void RevertFOOTPRINTs( BOARD* aBoard );
|
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Create a few data translation structures for layer name and number mapping between the
|
|
|
|
* DSN::PCB structure and the KiCad #BOARD structure.
|
|
|
|
*
|
|
|
|
* @param aBoard The #BOARD to create the maps for.
|
2008-02-08 00:16:59 +00:00
|
|
|
*/
|
|
|
|
void buildLayerMaps( BOARD* aBoard );
|
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Return the PCB layer index for a given layer name, within the specctra sessionfile.
|
2013-04-29 16:35:07 +00:00
|
|
|
*
|
2021-07-19 23:56:05 +00:00
|
|
|
* @return the layer index within the specctra session file, or -1 if \a aLayerName is not
|
|
|
|
* found.
|
2008-02-08 00:16:59 +00:00
|
|
|
*/
|
2013-04-29 16:35:07 +00:00
|
|
|
int findLayerName( const std::string& aLayerName ) const;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-01-21 20:53:35 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Read a <pin_reference> and splits it into the two parts which are on either side of
|
|
|
|
* the hyphen.
|
2008-01-21 20:53:35 +00:00
|
|
|
*
|
2021-07-19 23:56:05 +00:00
|
|
|
* This function is specialized because pin_reference may or may not be using double quotes.
|
|
|
|
* Both of these are legal: U2-14 or "U2"-"14". The lexer treats the first one as a single
|
|
|
|
* T_SYMBOL, so in that case we have to split it into two here.
|
|
|
|
* <p>
|
|
|
|
* The caller should have already read in the first token comprising the pin_reference and
|
|
|
|
* it will be tested through CurTok().
|
|
|
|
* </p>
|
2021-06-09 19:32:58 +00:00
|
|
|
* @param component_id Where to put the text preceding the '-' hyphen.
|
2011-06-07 15:29:01 +00:00
|
|
|
* @param pid_id Where to put the text which trails the '-'.
|
2010-11-09 15:45:11 +00:00
|
|
|
* @throw IO_ERROR, if the next token or two do no make up a pin_reference,
|
2021-07-19 23:56:05 +00:00
|
|
|
* or there is an error reading from the input stream.
|
2008-01-21 20:53:35 +00:00
|
|
|
*/
|
2017-06-08 21:47:21 +00:00
|
|
|
void readCOMPnPIN( std::string* component_id, std::string* pid_id );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Read a <time_stamp> which consists of 8 lexer tokens:
|
2008-01-21 20:53:35 +00:00
|
|
|
* "month date hour : minute : second year".
|
2021-07-19 23:56:05 +00:00
|
|
|
*
|
|
|
|
* This function is specialized because time_stamps occur more than once in a session file.
|
|
|
|
* The caller should not have already read in the first token comprising the time stamp.
|
2008-01-21 20:53:35 +00:00
|
|
|
*
|
|
|
|
* @param time_stamp Where to put the parsed time value.
|
2010-11-09 15:45:11 +00:00
|
|
|
* @throw IO_ERROR, if the next token or 8 do no make up a time stamp,
|
2008-01-21 20:53:35 +00:00
|
|
|
* or there is an error reading from the input stream.
|
|
|
|
*/
|
2017-06-08 21:47:21 +00:00
|
|
|
void readTIME( time_t* time_stamp );
|
|
|
|
|
|
|
|
void doPCB( PCB* growth );
|
|
|
|
void doPARSER( PARSER* growth );
|
|
|
|
void doRESOLUTION( UNIT_RES* growth );
|
|
|
|
void doUNIT( UNIT_RES* growth );
|
|
|
|
void doSTRUCTURE( STRUCTURE* growth );
|
|
|
|
void doSTRUCTURE_OUT( STRUCTURE_OUT* growth );
|
|
|
|
void doLAYER_NOISE_WEIGHT( LAYER_NOISE_WEIGHT* growth );
|
|
|
|
void doSPECCTRA_LAYER_PAIR( SPECCTRA_LAYER_PAIR* growth );
|
|
|
|
void doBOUNDARY( BOUNDARY* growth );
|
|
|
|
void doRECTANGLE( RECTANGLE* growth );
|
|
|
|
void doPATH( PATH* growth );
|
|
|
|
void doSTRINGPROP( STRINGPROP* growth );
|
|
|
|
void doTOKPROP( TOKPROP* growth );
|
|
|
|
void doVIA( VIA* growth );
|
|
|
|
void doCONTROL( CONTROL* growth );
|
|
|
|
void doLAYER( LAYER* growth );
|
|
|
|
void doRULE( RULE* growth );
|
|
|
|
void doKEEPOUT( KEEPOUT* growth );
|
|
|
|
void doCIRCLE( CIRCLE* growth );
|
|
|
|
void doQARC( QARC* growth );
|
|
|
|
void doWINDOW( WINDOW* growth );
|
|
|
|
void doCONNECT( CONNECT* growth );
|
|
|
|
void doREGION( REGION* growth );
|
|
|
|
void doCLASS_CLASS( CLASS_CLASS* growth );
|
|
|
|
void doLAYER_RULE( LAYER_RULE* growth );
|
|
|
|
void doCLASSES( CLASSES* growth );
|
|
|
|
void doGRID( GRID* growth );
|
|
|
|
void doPLACE( PLACE* growth );
|
|
|
|
void doCOMPONENT( COMPONENT* growth );
|
|
|
|
void doPLACEMENT( PLACEMENT* growth );
|
|
|
|
void doPROPERTIES( PROPERTIES* growth );
|
|
|
|
void doPADSTACK( PADSTACK* growth );
|
|
|
|
void doSHAPE( SHAPE* growth );
|
|
|
|
void doIMAGE( IMAGE* growth );
|
|
|
|
void doLIBRARY( LIBRARY* growth );
|
|
|
|
void doPIN( PIN* growth );
|
|
|
|
void doNET( NET* growth );
|
|
|
|
void doNETWORK( NETWORK* growth );
|
|
|
|
void doCLASS( CLASS* growth );
|
|
|
|
void doTOPOLOGY( TOPOLOGY* growth );
|
|
|
|
void doFROMTO( FROMTO* growth );
|
|
|
|
void doCOMP_ORDER( COMP_ORDER* growth );
|
|
|
|
void doWIRE( WIRE* growth );
|
|
|
|
void doWIRE_VIA( WIRE_VIA* growth );
|
|
|
|
void doWIRING( WIRING* growth );
|
|
|
|
void doSESSION( SESSION* growth );
|
|
|
|
void doANCESTOR( ANCESTOR* growth );
|
|
|
|
void doHISTORY( HISTORY* growth );
|
|
|
|
void doROUTE( ROUTE* growth );
|
|
|
|
void doWAS_IS( WAS_IS* growth );
|
|
|
|
void doNET_OUT( NET_OUT* growth );
|
|
|
|
void doSUPPLY_PIN( SUPPLY_PIN* growth );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-05-05 19:50:15 +00:00
|
|
|
//-----<FromBOARD>-------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Make the board perimeter for the DSN file by filling the BOUNDARY element
|
2013-04-30 15:25:41 +00:00
|
|
|
* in the specctra element tree.
|
2021-07-19 23:56:05 +00:00
|
|
|
*
|
2008-05-05 19:50:15 +00:00
|
|
|
* @param aBoard The BOARD to get information from in order to make the BOUNDARY.
|
|
|
|
* @param aBoundary The empty BOUNDARY to fill in.
|
|
|
|
*/
|
2017-06-08 21:47:21 +00:00
|
|
|
void fillBOUNDARY( BOARD* aBoard, BOUNDARY* aBoundary );
|
2008-05-05 19:50:15 +00:00
|
|
|
|
2008-01-29 16:45:14 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Allocates an I#MAGE on the heap and creates all the PINs according to the PADs in the
|
2020-11-13 21:07:01 +00:00
|
|
|
* FOOTPRINT.
|
2021-07-19 23:56:05 +00:00
|
|
|
*
|
2020-11-13 21:07:01 +00:00
|
|
|
* @param aBoard The owner of the FOOTPRINT.
|
|
|
|
* @param aFootprint The FOOTPRINT from which to build the IMAGE.
|
2021-07-19 23:56:05 +00:00
|
|
|
* @return not tested for duplication yet.
|
2008-01-29 16:45:14 +00:00
|
|
|
*/
|
2020-11-13 15:15:52 +00:00
|
|
|
IMAGE* makeIMAGE( BOARD* aBoard, FOOTPRINT* aFootprint );
|
2008-01-29 16:45:14 +00:00
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Create a #PADSTACK which matches the given pad.
|
|
|
|
*
|
|
|
|
* @note Only pads which do not satisfy the function isKeepout() should be passed to this
|
|
|
|
* function.
|
|
|
|
*
|
2020-11-12 22:30:02 +00:00
|
|
|
* @param aBoard The owner of the PAD's footprint.
|
|
|
|
* @param aPad The PAD which needs to be made into a PADSTACK.
|
2023-04-01 14:14:35 +00:00
|
|
|
* @return The created padstack, including its m_padstack_id.
|
2008-01-29 16:45:14 +00:00
|
|
|
*/
|
2020-11-12 22:30:02 +00:00
|
|
|
PADSTACK* makePADSTACK( BOARD* aBoard, PAD* aPad );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-02-01 01:09:39 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Make a round through hole #PADSTACK using the given KiCad diameter in deci-mils.
|
|
|
|
*
|
2008-02-01 01:09:39 +00:00
|
|
|
* @param aCopperDiameter The diameter of the copper pad.
|
2008-02-09 08:34:45 +00:00
|
|
|
* @param aDrillDiameter The drill diameter, used on re-import of the session file.
|
2008-02-14 01:07:52 +00:00
|
|
|
* @param aTopLayer The DSN::PCB top most layer index.
|
|
|
|
* @param aBotLayer The DSN::PCB bottom most layer index.
|
2021-07-19 23:56:05 +00:00
|
|
|
* @return The padstack, which is on the heap only, user must save or delete it.
|
2008-02-01 01:09:39 +00:00
|
|
|
*/
|
2008-02-14 01:07:52 +00:00
|
|
|
PADSTACK* makeVia( int aCopperDiameter, int aDrillDiameter,
|
2013-05-05 10:11:30 +00:00
|
|
|
int aTopLayer, int aBotLayer );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-02-01 01:09:39 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Make any kind of #PADSTACK using the given KiCad #VIA.
|
|
|
|
*
|
|
|
|
* @param aVia The #VIA to build the padstack from.
|
|
|
|
* @return The padstack, which is on the heap only, user must save or delete it.
|
2008-02-01 01:09:39 +00:00
|
|
|
*/
|
2021-06-11 21:07:02 +00:00
|
|
|
PADSTACK* makeVia( const ::PCB_VIA* aVia );
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2008-02-14 01:07:52 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Delete all the NETs that may be in here.
|
2008-02-14 01:07:52 +00:00
|
|
|
*/
|
|
|
|
void deleteNETs()
|
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
for( unsigned n = 0; n < m_nets.size(); ++n )
|
2020-11-14 21:21:54 +00:00
|
|
|
delete m_nets[n];
|
2008-02-14 01:07:52 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
m_nets.clear();
|
2008-02-14 01:07:52 +00:00
|
|
|
}
|
2009-09-10 15:22:26 +00:00
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Export \a aNetClass to the DSN file.
|
2009-09-10 15:22:26 +00:00
|
|
|
*/
|
2017-09-23 09:20:10 +00:00
|
|
|
void exportNETCLASS( const std::shared_ptr<NETCLASS>& aNetClass, BOARD* aBoard );
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2008-05-05 19:50:15 +00:00
|
|
|
//-----</FromBOARD>------------------------------------------------------
|
2008-02-14 01:07:52 +00:00
|
|
|
|
2008-02-08 00:16:59 +00:00
|
|
|
//-----<FromSESSION>-----------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Create a #TRACK form the #PATH and #BOARD info.
|
2008-02-08 00:16:59 +00:00
|
|
|
*/
|
2022-03-16 11:31:45 +00:00
|
|
|
PCB_TRACK* makeTRACK( WIRE* wire, PATH* aPath, int aPointIndex, int aNetcode );
|
2008-02-08 00:16:59 +00:00
|
|
|
|
2008-02-12 01:02:53 +00:00
|
|
|
/**
|
2021-07-19 23:56:05 +00:00
|
|
|
* Instantiate a KiCad #VIA on the heap and initializes it with internal
|
|
|
|
* values consistent with the given #PADSTACK, #POINT, and netcode.
|
2008-02-12 01:02:53 +00:00
|
|
|
*/
|
2022-03-16 11:31:45 +00:00
|
|
|
PCB_VIA* makeVIA( WIRE_VIA*aVia, PADSTACK* aPadstack, const POINT& aPoint, int aNetCode,
|
2021-07-19 23:56:05 +00:00
|
|
|
int aViaDrillDefault );
|
2008-02-09 08:34:45 +00:00
|
|
|
|
2008-02-08 00:16:59 +00:00
|
|
|
//-----</FromSESSION>----------------------------------------------------
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
/// specctra DSN keywords
|
|
|
|
static const KEYWORD keywords[];
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
PCB* m_pcb;
|
|
|
|
SHAPE_POLY_SET m_brd_outlines; // the board outlines for DSN export
|
|
|
|
SESSION* m_session;
|
|
|
|
wxString m_filename;
|
|
|
|
std::string m_quote_char;
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
bool m_footprintsAreFlipped;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
STRING_FORMATTER m_sf;
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
STRINGS m_layerIds; ///< indexed by PCB layer number
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
std::vector<int> m_kicadLayer2pcb; ///< maps BOARD layer number to PCB layer numbers
|
|
|
|
std::vector<PCB_LAYER_ID> m_pcbLayer2kicad; ///< maps PCB layer number to BOARD layer numbers
|
2008-01-21 20:53:35 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
/// used during FromSESSION() only, memory for it is not owned here.
|
|
|
|
UNIT_RES* m_routeResolution;
|
2008-02-07 06:49:16 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
/// a copy to avoid passing as an argument, memory for it is not owned here.
|
|
|
|
BOARD* m_sessionBoard;
|
2008-02-07 20:23:58 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
static const KICAD_T scanPADs[];
|
2008-02-14 15:34:40 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
PADSTACKSET m_padstackset;
|
2021-07-07 14:40:19 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
/// we don't want ownership here permanently, so we don't use boost::ptr_vector
|
|
|
|
std::vector<NET*> m_nets;
|
2008-02-29 06:49:34 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
/// specctra cu layers, 0 based index:
|
|
|
|
int m_top_via_layer;
|
|
|
|
int m_bot_via_layer;
|
2008-01-21 20:53:35 +00:00
|
|
|
};
|
|
|
|
|
2023-11-20 03:06:27 +00:00
|
|
|
/**
|
|
|
|
* @brief Helper method to import SES file to a board
|
|
|
|
*
|
|
|
|
* @param aBoard board object
|
|
|
|
* @param aFullFilename specctra file name
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool ImportSpecctraSession( BOARD* aBoard, const wxString& fullFileName );
|
2008-01-21 20:53:35 +00:00
|
|
|
|
|
|
|
} // namespace DSN
|
|
|
|
|
|
|
|
#endif // SPECCTRA_H_
|