2012-03-19 11:21:29 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Miguel Angel Ajo <miguelangel@nbee.es>
|
|
|
|
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file board_item.i
|
2016-09-21 01:07:41 +00:00
|
|
|
* @brief board_item helpers, mainly for casting down to all derived classes
|
2012-03-19 11:21:29 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2016-09-21 01:07:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
%include class_board_item.h // generate code for this interface
|
|
|
|
|
|
|
|
%rename(Get) operator BOARD_ITEM*;
|
|
|
|
|
|
|
|
%{
|
|
|
|
#include <class_board_item.h>
|
|
|
|
%}
|
|
|
|
|
2012-03-19 11:21:29 +00:00
|
|
|
|
|
|
|
%inline
|
|
|
|
{
|
2016-09-21 01:07:41 +00:00
|
|
|
/// Cast down from EDA_ITEM/BOARD_ITEM to child
|
2014-10-02 17:09:32 +00:00
|
|
|
BOARD_ITEM* Cast_to_BOARD_ITEM(EDA_ITEM* base) { return dynamic_cast<BOARD_ITEM*>(base); }
|
2012-03-19 11:21:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-21 01:07:41 +00:00
|
|
|
%{
|
|
|
|
class TEXTE_PCB;
|
|
|
|
class DIMENSION;
|
|
|
|
class MODULE;
|
|
|
|
class TEXTE_MODULE;
|
|
|
|
class DRAWSEGMENT;
|
|
|
|
class MARKER_PCB;
|
|
|
|
class BOARD;
|
|
|
|
class EDGE_MODULE;
|
|
|
|
class D_PAD;
|
|
|
|
class TRACK;
|
|
|
|
class VIA;
|
|
|
|
class ZONE_CONTAINER;
|
|
|
|
class PCB_TARGET;
|
|
|
|
|
2016-09-21 21:26:44 +00:00
|
|
|
// Anthing targeted to the %wrapper section is extern "C" whereas code targeted
|
|
|
|
// to %header section is C++.
|
2016-09-21 01:07:41 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static TEXTE_PCB* Cast_to_TEXTE_PCB( BOARD_ITEM* );
|
|
|
|
static DIMENSION* Cast_to_DIMENSION( BOARD_ITEM* );
|
|
|
|
static MODULE* Cast_to_MODULE( BOARD_ITEM* );
|
|
|
|
static TEXTE_MODULE* Cast_to_TEXTE_MODULE( BOARD_ITEM* );
|
|
|
|
static DRAWSEGMENT* Cast_to_DRAWSEGMENT( BOARD_ITEM* );
|
|
|
|
static MARKER_PCB* Cast_to_MARKER_PCB( BOARD_ITEM* );
|
|
|
|
static BOARD* Cast_to_BOARD( BOARD_ITEM* );
|
|
|
|
static EDGE_MODULE* Cast_to_EDGE_MODULE( BOARD_ITEM* );
|
|
|
|
static D_PAD* Cast_to_D_PAD( BOARD_ITEM* );
|
|
|
|
static TRACK* Cast_to_TRACK( BOARD_ITEM* );
|
|
|
|
static VIA* Cast_to_VIA( BOARD_ITEM* );
|
|
|
|
static ZONE_CONTAINER* Cast_to_ZONE_CONTAINER( BOARD_ITEM* );
|
|
|
|
static PCB_TARGET* Cast_to_PCB_TARGET( BOARD_ITEM* );
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
%}
|
|
|
|
|
|
|
|
|
|
|
|
static TEXTE_PCB* Cast_to_TEXTE_PCB( BOARD_ITEM* );
|
|
|
|
static DIMENSION* Cast_to_DIMENSION( BOARD_ITEM* );
|
|
|
|
static MODULE* Cast_to_MODULE( BOARD_ITEM* );
|
|
|
|
static TEXTE_MODULE* Cast_to_TEXTE_MODULE( BOARD_ITEM* );
|
|
|
|
static DRAWSEGMENT* Cast_to_DRAWSEGMENT( BOARD_ITEM* );
|
|
|
|
static MARKER_PCB* Cast_to_MARKER_PCB( BOARD_ITEM* );
|
|
|
|
static BOARD* Cast_to_BOARD( BOARD_ITEM* );
|
|
|
|
static EDGE_MODULE* Cast_to_EDGE_MODULE( BOARD_ITEM* );
|
|
|
|
static D_PAD* Cast_to_D_PAD( BOARD_ITEM* );
|
|
|
|
static TRACK* Cast_to_TRACK( BOARD_ITEM* );
|
|
|
|
static VIA* Cast_to_VIA( BOARD_ITEM* );
|
|
|
|
static ZONE_CONTAINER* Cast_to_ZONE_CONTAINER( BOARD_ITEM* );
|
|
|
|
static PCB_TARGET* Cast_to_PCB_TARGET( BOARD_ITEM* );
|
2012-03-19 11:21:29 +00:00
|
|
|
|
2016-09-21 01:07:41 +00:00
|
|
|
|
|
|
|
%extend BOARD_ITEM
|
|
|
|
{
|
2014-10-02 17:09:32 +00:00
|
|
|
%pythoncode
|
2016-09-21 01:07:41 +00:00
|
|
|
%{
|
2012-03-19 11:21:29 +00:00
|
|
|
def Cast(self):
|
2014-04-25 06:43:14 +00:00
|
|
|
|
2014-10-02 17:09:32 +00:00
|
|
|
ct = self.GetClass()
|
2014-04-25 06:43:14 +00:00
|
|
|
|
2014-10-02 17:09:32 +00:00
|
|
|
if ct=="PTEXT":
|
2016-09-21 01:07:41 +00:00
|
|
|
return Cast_to_TEXTE_PCB(self)
|
2014-10-02 17:09:32 +00:00
|
|
|
elif ct=="BOARD":
|
2016-09-21 01:07:41 +00:00
|
|
|
return Cast_to_BOARD(self)
|
2014-10-02 17:09:32 +00:00
|
|
|
elif ct=="DIMENSION":
|
2016-09-21 01:07:41 +00:00
|
|
|
return Cast_to_DIMENSION(self)
|
2014-10-02 17:09:32 +00:00
|
|
|
elif ct=="DRAWSEGMENT":
|
2016-09-21 01:07:41 +00:00
|
|
|
return Cast_to_DRAWSEGMENT(self)
|
2014-10-02 17:09:32 +00:00
|
|
|
elif ct=="MGRAPHIC":
|
2016-09-21 01:07:41 +00:00
|
|
|
return Cast_to_EDGE_MODULE(self)
|
2014-10-02 17:09:32 +00:00
|
|
|
elif ct=="MODULE":
|
2016-09-21 01:07:41 +00:00
|
|
|
return Cast_to_MODULE(self)
|
2014-10-02 17:09:32 +00:00
|
|
|
elif ct=="PAD":
|
2016-09-21 01:07:41 +00:00
|
|
|
return Cast_to_D_PAD(self)
|
2014-10-02 17:09:32 +00:00
|
|
|
elif ct=="MTEXT":
|
2016-09-21 01:07:41 +00:00
|
|
|
return Cast_to_TEXTE_MODULE(self)
|
2014-10-02 17:09:32 +00:00
|
|
|
elif ct=="VIA":
|
2016-09-21 01:07:41 +00:00
|
|
|
return Cast_to_VIA(self)
|
2014-10-02 17:09:32 +00:00
|
|
|
elif ct=="TRACK":
|
2016-09-21 01:07:41 +00:00
|
|
|
return Cast_to_TRACK(self)
|
2014-10-13 11:14:02 +00:00
|
|
|
elif ct=="PCB_TARGET":
|
2016-09-21 01:07:41 +00:00
|
|
|
return Cast_to_PCB_TARGET(self)
|
2014-10-02 17:09:32 +00:00
|
|
|
elif ct=="ZONE_CONTAINER":
|
2016-09-21 01:07:41 +00:00
|
|
|
return Cast_to_ZONE_CONTAINER(self)
|
2014-10-02 17:09:32 +00:00
|
|
|
else:
|
2019-06-03 02:50:26 +00:00
|
|
|
return none
|
2014-10-02 17:09:32 +00:00
|
|
|
|
|
|
|
def Duplicate(self):
|
|
|
|
ct = self.GetClass()
|
|
|
|
if ct=="BOARD":
|
|
|
|
return None
|
|
|
|
else:
|
|
|
|
return Cast_to_BOARD_ITEM(self.Clone()).Cast()
|
2016-09-21 01:07:41 +00:00
|
|
|
|
|
|
|
def SetPos(self,p):
|
|
|
|
self.SetPosition(p)
|
|
|
|
self.SetPos0(p)
|
|
|
|
|
|
|
|
def SetStartEnd(self,start,end):
|
|
|
|
self.SetStart(start)
|
|
|
|
self.SetStart0(start)
|
|
|
|
self.SetEnd(end)
|
|
|
|
self.SetEnd0(end)
|
|
|
|
%}
|
2012-03-19 11:21:29 +00:00
|
|
|
}
|
2016-09-21 01:07:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Use %wrapper code generation section so that this block of C++ comes after all referenced
|
|
|
|
// classes and therefore will C++ compile due to the respective headers which will go into
|
|
|
|
// the %header section. See section 5.6.2 of SWIG 3.0 documentation.
|
|
|
|
%wrapper %{
|
|
|
|
static TEXTE_PCB* Cast_to_TEXTE_PCB( BOARD_ITEM* self ) { return dynamic_cast<TEXTE_PCB*>(self); }
|
|
|
|
static DIMENSION* Cast_to_DIMENSION( BOARD_ITEM* self ) { return dynamic_cast<DIMENSION*>(self); }
|
|
|
|
static MODULE* Cast_to_MODULE( BOARD_ITEM* self ) { return dynamic_cast<MODULE*>(self); }
|
|
|
|
static TEXTE_MODULE* Cast_to_TEXTE_MODULE( BOARD_ITEM* self ) { return dynamic_cast<TEXTE_MODULE*>(self); }
|
|
|
|
static DRAWSEGMENT* Cast_to_DRAWSEGMENT( BOARD_ITEM* self ) { return dynamic_cast<DRAWSEGMENT*>(self); }
|
|
|
|
static MARKER_PCB* Cast_to_MARKER_PCB( BOARD_ITEM* self ) { return dynamic_cast<MARKER_PCB*>(self); }
|
|
|
|
static BOARD* Cast_to_BOARD( BOARD_ITEM* self ) { return dynamic_cast<BOARD*>(self); }
|
|
|
|
static EDGE_MODULE* Cast_to_EDGE_MODULE( BOARD_ITEM* self ) { return dynamic_cast<EDGE_MODULE*>(self); }
|
|
|
|
static D_PAD* Cast_to_D_PAD( BOARD_ITEM* self ) { return dynamic_cast<D_PAD*>(self); }
|
|
|
|
static TRACK* Cast_to_TRACK( BOARD_ITEM* self ) { return dynamic_cast<TRACK*>(self); }
|
|
|
|
static VIA* Cast_to_VIA( BOARD_ITEM* self ) { return dynamic_cast<VIA*>(self); }
|
|
|
|
static ZONE_CONTAINER* Cast_to_ZONE_CONTAINER( BOARD_ITEM* self ) { return dynamic_cast<ZONE_CONTAINER*>(self); }
|
|
|
|
static PCB_TARGET* Cast_to_PCB_TARGET( BOARD_ITEM* self ) { return dynamic_cast<PCB_TARGET*>(self); }
|
|
|
|
%}
|