2011-11-28 04:32:29 +00:00
|
|
|
#ifndef KICAD_PLUGIN_H_
|
|
|
|
#define KICAD_PLUGIN_H_
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1992-2011 KiCad Developers, see change_log.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <io_mgr.h>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
typedef int BIU;
|
|
|
|
|
|
|
|
class PCB_TARGET;
|
|
|
|
class MODULE;
|
|
|
|
class DRAWSEGMENT;
|
|
|
|
class NETINFO;
|
|
|
|
class TEXTE_PCB;
|
|
|
|
class TRACK;
|
|
|
|
class NETCLASS;
|
|
|
|
class ZONE_CONTAINER;
|
|
|
|
class DIMENSION;
|
|
|
|
class NETINFO_ITEM;
|
2011-12-01 06:04:23 +00:00
|
|
|
class TEXTE_MODULE;
|
2011-12-10 05:33:24 +00:00
|
|
|
class EDGE_MODULE;
|
|
|
|
class TRACK;
|
|
|
|
class SEGZONE;
|
2011-12-12 08:37:05 +00:00
|
|
|
class D_PAD;
|
2011-11-28 04:32:29 +00:00
|
|
|
|
2011-12-01 06:04:23 +00:00
|
|
|
/**
|
|
|
|
* Class KICAD_PLUGIN
|
|
|
|
* is a PLUGIN derivation which could possibly be put into a DLL/DSO.
|
|
|
|
* It is not thread safe, but it is re-entrant multiple times in sequence.
|
|
|
|
*/
|
2011-11-28 04:32:29 +00:00
|
|
|
class KICAD_PLUGIN : public PLUGIN
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2011-12-01 06:04:23 +00:00
|
|
|
//-----<PLUGIN>-------------------------------------------------------------
|
2011-11-28 04:32:29 +00:00
|
|
|
|
2011-11-30 07:43:46 +00:00
|
|
|
const wxString& PluginName()
|
2011-11-28 04:32:29 +00:00
|
|
|
{
|
|
|
|
static const wxString name = wxT( "KiCad" );
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties = NULL ); // overload
|
|
|
|
|
|
|
|
void Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties = NULL ); // overload
|
|
|
|
|
2011-12-01 06:04:23 +00:00
|
|
|
//-----</PLUGIN>------------------------------------------------------------
|
2011-11-28 04:32:29 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2011-11-29 03:08:14 +00:00
|
|
|
wxString m_error; ///< for throwing exceptions
|
|
|
|
BOARD* m_board; ///< which BOARD, no ownership here
|
2011-11-28 04:32:29 +00:00
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
LINE_READER* m_reader; ///< no ownership here.
|
2011-12-07 05:28:49 +00:00
|
|
|
FILE* m_fp; ///< no ownership here.
|
2011-12-10 05:33:24 +00:00
|
|
|
wxString m_filename; ///< for saves only, name is in m_reader for loads
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
|
|
|
|
wxString m_field; ///< reused to stuff MODULE fields.
|
2011-11-28 04:32:29 +00:00
|
|
|
|
|
|
|
/// initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed.
|
2011-11-29 03:08:14 +00:00
|
|
|
void init( PROPERTIES* aProperties );
|
2011-11-28 04:32:29 +00:00
|
|
|
|
2011-11-29 03:08:14 +00:00
|
|
|
double biuToDisk; ///< convert from BIUs to disk engineering units with this scale factor
|
|
|
|
double diskToBiu; ///< convert from disk engineering units to BIUs with this scale factor
|
2011-11-28 04:32:29 +00:00
|
|
|
|
2011-11-29 03:08:14 +00:00
|
|
|
/**
|
|
|
|
* Function biuParse
|
|
|
|
* parses an ASCII decimal floating point value and scales it into a BIU
|
|
|
|
* according to the current value of diskToBui.
|
|
|
|
*
|
2011-12-01 06:04:23 +00:00
|
|
|
* @param aValue is the ASCII value in C locale form with possible leading whitespace
|
2011-11-29 03:08:14 +00:00
|
|
|
*
|
|
|
|
* @param nptrptr may be NULL, but if not, then it tells where to put a
|
2011-12-01 06:04:23 +00:00
|
|
|
* pointer to the next unconsumed input text. See "man strtod" for more information.
|
2011-11-29 03:08:14 +00:00
|
|
|
*
|
|
|
|
* @return BIU - the converted Board Internal Unit.
|
|
|
|
*/
|
|
|
|
BIU biuParse( const char* aValue, const char** nptrptr = NULL );
|
|
|
|
|
2011-12-01 22:50:41 +00:00
|
|
|
/**
|
2011-12-02 21:56:47 +00:00
|
|
|
* Function degParse
|
|
|
|
* parses an ASCII decimal floating point value which is certainy an angle. This
|
|
|
|
* is a dedicated function for encapsulating support for the migration from
|
|
|
|
* tenths of degrees to degrees in floating point.
|
2011-12-01 22:50:41 +00:00
|
|
|
*
|
|
|
|
* @param aValue is the ASCII value in C locale form with possible leading whitespace
|
|
|
|
*
|
|
|
|
* @param nptrptr may be NULL, but if not, then it tells where to put a
|
|
|
|
* pointer to the next unconsumed input text. See "man strtod" for more information.
|
|
|
|
*
|
|
|
|
* @return double - the string converted to a primitive double type
|
|
|
|
*/
|
2011-12-02 21:56:47 +00:00
|
|
|
double degParse( const char* aValue, const char** nptrptr = NULL );
|
2011-12-01 22:50:41 +00:00
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
//-----<load/parse functions>-----------------------------------------------
|
|
|
|
|
|
|
|
void checkVersion();
|
2011-11-28 04:32:29 +00:00
|
|
|
|
2011-11-29 03:08:14 +00:00
|
|
|
void loadAllSections( bool doAppend );
|
|
|
|
|
|
|
|
void loadGENERAL();
|
|
|
|
void loadSETUP();
|
|
|
|
void loadSHEET();
|
2011-11-28 04:32:29 +00:00
|
|
|
|
2011-11-29 03:08:14 +00:00
|
|
|
void loadMODULE();
|
2011-12-01 06:04:23 +00:00
|
|
|
void load3D( MODULE* aModule );
|
|
|
|
void loadPAD( MODULE* aModule );
|
2011-12-10 05:33:24 +00:00
|
|
|
void loadMODULE_TEXT( TEXTE_MODULE* aText );
|
2011-12-14 04:29:25 +00:00
|
|
|
void loadMODULE_EDGE( MODULE* aModule );
|
2011-12-01 06:04:23 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
void loadPCB_LINE();
|
2011-11-29 03:08:14 +00:00
|
|
|
void loadNETINFO_ITEM();
|
2011-12-10 05:33:24 +00:00
|
|
|
void loadPCB_TEXT();
|
2011-11-30 07:43:46 +00:00
|
|
|
void loadNETCLASS();
|
2011-11-29 03:08:14 +00:00
|
|
|
|
2011-11-30 07:43:46 +00:00
|
|
|
/**
|
|
|
|
* Function loadTrackList
|
2011-11-30 21:15:56 +00:00
|
|
|
* reads a list of segments (Tracks and Vias, or Segzones)
|
|
|
|
*
|
|
|
|
* @param aInsertBeforeMe may be either NULL indicating append, or it may
|
|
|
|
* be an insertion point before which all the segments are inserted.
|
|
|
|
*
|
|
|
|
* @param aStructType is either PCB_TRACE_T to indicate tracks and vias, or
|
|
|
|
* PCB_ZONE_T to indicate oldschool zone segments (before polygons came to be).
|
2011-11-30 07:43:46 +00:00
|
|
|
*/
|
2011-11-30 21:15:56 +00:00
|
|
|
void loadTrackList( TRACK* aInsertBeforeMe, int aStructType );
|
|
|
|
|
|
|
|
void loadZONE_CONTAINER(); // "$CZONE_OUTLINE"
|
|
|
|
void loadDIMENSION(); // "$COTATION"
|
2011-12-01 06:04:23 +00:00
|
|
|
void loadPCB_TARGET(); // "$PCB_TARGET"
|
2011-11-30 07:43:46 +00:00
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
//-----</ load/parse functions>---------------------------------------------
|
2011-12-10 05:33:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
//-----<save functions>-----------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
2011-12-12 08:37:05 +00:00
|
|
|
* Function writeError
|
|
|
|
* returns an error message wxString containing the filename being
|
|
|
|
* currently written.
|
2011-12-10 05:33:24 +00:00
|
|
|
*/
|
2011-12-12 08:37:05 +00:00
|
|
|
wxString writeError() const;
|
|
|
|
|
|
|
|
int biuSprintf( char* buf, BIU aValue ) const;
|
2011-12-10 05:33:24 +00:00
|
|
|
|
|
|
|
/// convert a BIU to engineering units by scaling and formatting to ASCII.
|
2011-12-12 08:37:05 +00:00
|
|
|
std::string fmtBIU( BIU aValue ) const;
|
|
|
|
|
|
|
|
std::string fmtBIUPair( BIU first, BIU second ) const;
|
|
|
|
|
|
|
|
std::string fmtBIUPoint( const wxPoint& aPoint ) const
|
|
|
|
{
|
|
|
|
return fmtBIUPair( aPoint.x, aPoint.y );
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string fmtBIUSize( const wxSize& aSize ) const
|
|
|
|
{
|
|
|
|
// unfortunately there is inconsistency in the order of saving wxSize,
|
|
|
|
// so sometimes we use fmtBIUPair() directly in the saveXXX() functions.
|
|
|
|
return fmtBIUPair( aSize.x, aSize.y );
|
|
|
|
}
|
2011-12-10 05:33:24 +00:00
|
|
|
|
|
|
|
void saveAllSections() const;
|
|
|
|
void saveGENERAL() const;
|
|
|
|
void saveSHEET() const;
|
|
|
|
void saveSETUP() const;
|
|
|
|
void saveBOARD() const;
|
2011-12-12 08:37:05 +00:00
|
|
|
|
2011-12-10 05:33:24 +00:00
|
|
|
void saveMODULE( const MODULE* aModule ) const;
|
2011-12-12 08:37:05 +00:00
|
|
|
void saveMODULE_TEXT( const TEXTE_MODULE* aText ) const;
|
|
|
|
void saveMODULE_EDGE( const EDGE_MODULE* aGraphic ) const;
|
|
|
|
void savePAD( const D_PAD* aPad ) const;
|
|
|
|
void save3D( const MODULE* aModule ) const;
|
|
|
|
|
2011-12-10 05:33:24 +00:00
|
|
|
void saveNETINFO_ITEM( const NETINFO_ITEM* aNet ) const;
|
|
|
|
void saveNETCLASSES() const;
|
|
|
|
void saveNETCLASS( const NETCLASS* aNetclass ) const;
|
|
|
|
|
|
|
|
void savePCB_TEXT( const TEXTE_PCB* aText ) const;
|
2011-12-14 04:29:25 +00:00
|
|
|
void savePCB_TARGET( const PCB_TARGET* aTarget ) const;
|
|
|
|
void savePCB_LINE( const DRAWSEGMENT* aStroke ) const;
|
2011-12-10 05:33:24 +00:00
|
|
|
void saveDIMENTION( const DIMENSION* aDimension ) const;
|
|
|
|
void saveTRACK( const TRACK* aTrack ) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function saveZONE_CONTAINER
|
|
|
|
* saves the new polygon zones.
|
|
|
|
*/
|
|
|
|
void saveZONE_CONTAINER( const ZONE_CONTAINER* aZone ) const;
|
|
|
|
|
|
|
|
//-----</save functions>----------------------------------------------------
|
|
|
|
|
2011-11-28 04:32:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // KICAD_PLUGIN_H_
|