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>
|
2021-06-11 16:59:28 +00:00
|
|
|
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-03-19 11:21:29 +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.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
2022-12-18 18:02:17 +00:00
|
|
|
%include board_item.h // generate code for this interface
|
2021-06-14 16:57:05 +00:00
|
|
|
%include eda_item_flags.h // generate code for this interface
|
2022-12-18 18:02:17 +00:00
|
|
|
// Provide also interface for UNIT_PROVIDER as BOARD_ITEM uses it
|
|
|
|
%include base_units.h
|
|
|
|
%include eda_units.h
|
|
|
|
%include units_provider.h
|
2016-09-21 01:07:41 +00:00
|
|
|
|
|
|
|
%rename(Get) operator BOARD_ITEM*;
|
|
|
|
|
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
|
|
|
%{
|
2020-11-12 22:30:02 +00:00
|
|
|
class PCB_TEXT;
|
2022-02-03 12:55:37 +00:00
|
|
|
class PCB_TEXTBOX;
|
2021-06-11 16:59:28 +00:00
|
|
|
class PCB_DIM_ALIGNED;
|
|
|
|
class PCB_DIM_ORTHOGONAL;
|
|
|
|
class PCB_DIM_LEADER;
|
|
|
|
class PCB_DIM_CENTER;
|
2022-01-14 04:55:50 +00:00
|
|
|
class PCB_DIM_RADIAL;
|
2020-11-13 15:15:52 +00:00
|
|
|
class FOOTPRINT;
|
2020-08-12 11:23:30 +00:00
|
|
|
class PCB_GROUP;
|
2020-11-12 22:30:02 +00:00
|
|
|
class PCB_SHAPE;
|
2016-09-21 01:07:41 +00:00
|
|
|
class MARKER_PCB;
|
|
|
|
class BOARD;
|
2020-11-12 22:30:02 +00:00
|
|
|
class PAD;
|
2021-06-11 21:07:02 +00:00
|
|
|
class PCB_TRACK;
|
|
|
|
class PCB_VIA;
|
|
|
|
class PCB_ARC;
|
2020-11-11 23:05:59 +00:00
|
|
|
class ZONE;
|
2016-09-21 01:07:41 +00:00
|
|
|
class PCB_TARGET;
|
2023-10-23 17:23:24 +00:00
|
|
|
class PCB_REFERENCE_IMAGE;
|
2016-09-21 01:07:41 +00:00
|
|
|
|
2021-06-09 19:32:58 +00:00
|
|
|
// Anything targeted to the %wrapper section is extern "C" whereas code targeted
|
2016-09-21 21:26:44 +00:00
|
|
|
// to %header section is C++.
|
2016-09-21 01:07:41 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
static PCB_TEXT* Cast_to_PCB_TEXT( BOARD_ITEM* );
|
2022-02-03 12:55:37 +00:00
|
|
|
static PCB_TEXTBOX* Cast_to_PCB_TEXTBOX( BOARD_ITEM* );
|
2021-06-11 16:59:28 +00:00
|
|
|
static PCB_DIM_ALIGNED* Cast_to_PCB_DIM_ALIGNED( BOARD_ITEM* );
|
|
|
|
static PCB_DIM_ORTHOGONAL* Cast_to_PCB_DIM_ORTHOGONAL( BOARD_ITEM* );
|
|
|
|
static PCB_DIM_LEADER* Cast_to_PCB_DIM_LEADER( BOARD_ITEM* );
|
|
|
|
static PCB_DIM_CENTER* Cast_to_PCB_DIM_CENTER( BOARD_ITEM* );
|
2022-01-14 04:55:50 +00:00
|
|
|
static PCB_DIM_RADIAL* Cast_to_PCB_DIM_RADIAL( BOARD_ITEM* );
|
2020-11-13 15:15:52 +00:00
|
|
|
static FOOTPRINT* Cast_to_FOOTPRINT( BOARD_ITEM* );
|
2020-09-22 02:32:40 +00:00
|
|
|
static PCB_GROUP* Cast_to_PCB_GROUP( BOARD_ITEM* );
|
2020-10-04 23:34:59 +00:00
|
|
|
static PCB_SHAPE* Cast_to_PCB_SHAPE( BOARD_ITEM* );
|
2020-11-14 18:11:28 +00:00
|
|
|
static PCB_MARKER* Cast_to_PCB_MARKER( BOARD_ITEM* );
|
2020-09-22 02:32:40 +00:00
|
|
|
static BOARD* Cast_to_BOARD( BOARD_ITEM* );
|
2020-11-12 22:30:02 +00:00
|
|
|
static PAD* Cast_to_PAD( BOARD_ITEM* );
|
2021-06-11 21:07:02 +00:00
|
|
|
static PCB_TRACK* Cast_to_PCB_TRACK( BOARD_ITEM* );
|
|
|
|
static PCB_VIA* Cast_to_PCB_VIA( BOARD_ITEM* );
|
|
|
|
static PCB_ARC* Cast_to_PCB_ARC( BOARD_ITEM* );
|
2020-11-11 23:05:59 +00:00
|
|
|
static ZONE* Cast_to_ZONE( BOARD_ITEM* );
|
2020-09-22 02:32:40 +00:00
|
|
|
static PCB_TARGET* Cast_to_PCB_TARGET( BOARD_ITEM* );
|
2023-10-23 17:23:24 +00:00
|
|
|
static PCB_REFERENCE_IMAGE* Cast_to_PCB_REFERENCE_IMAGE( BOARD_ITEM* );
|
2016-09-21 01:07:41 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
%}
|
|
|
|
|
|
|
|
|
2020-10-04 23:34:59 +00:00
|
|
|
static PCB_TEXT* Cast_to_PCB_TEXT( BOARD_ITEM* );
|
2022-02-03 12:55:37 +00:00
|
|
|
static PCB_TEXTBOX* Cast_to_PCB_TEXTBOX( BOARD_ITEM* );
|
2021-06-11 16:59:28 +00:00
|
|
|
static PCB_DIM_ALIGNED* Cast_to_PCB_DIM_ALIGNED( BOARD_ITEM* );
|
|
|
|
static PCB_DIM_ORTHOGONAL* Cast_to_PCB_DIM_ORTHOGONAL( BOARD_ITEM* );
|
|
|
|
static PCB_DIM_LEADER* Cast_to_PCB_DIM_LEADER( BOARD_ITEM* );
|
|
|
|
static PCB_DIM_CENTER* Cast_to_PCB_DIM_CENTER( BOARD_ITEM* );
|
2022-01-14 04:55:50 +00:00
|
|
|
static PCB_DIM_RADIAL* Cast_to_PCB_DIM_RADIAL( BOARD_ITEM* );
|
2020-11-13 15:15:52 +00:00
|
|
|
static FOOTPRINT* Cast_to_FOOTPRINT( BOARD_ITEM* );
|
2020-09-22 02:32:40 +00:00
|
|
|
static PCB_GROUP* Cast_to_PCB_GROUP( BOARD_ITEM* );
|
2020-10-04 23:34:59 +00:00
|
|
|
static PCB_SHAPE* Cast_to_PCB_SHAPE( BOARD_ITEM* );
|
2020-11-14 18:11:28 +00:00
|
|
|
static PCB_MARKER* Cast_to_PCB_MARKER( BOARD_ITEM* );
|
2020-09-22 02:32:40 +00:00
|
|
|
static BOARD* Cast_to_BOARD( BOARD_ITEM* );
|
2020-11-12 22:30:02 +00:00
|
|
|
static PAD* Cast_to_PAD( BOARD_ITEM* );
|
2021-06-11 21:07:02 +00:00
|
|
|
static PCB_TRACK* Cast_to_PCB_TRACK( BOARD_ITEM* );
|
|
|
|
static PCB_VIA* Cast_to_PCB_VIA( BOARD_ITEM* );
|
|
|
|
static PCB_ARC* Cast_to_PCB_ARC( BOARD_ITEM* );
|
2020-11-11 23:05:59 +00:00
|
|
|
static ZONE* Cast_to_ZONE( BOARD_ITEM* );
|
2020-09-22 02:32:40 +00:00
|
|
|
static PCB_TARGET* Cast_to_PCB_TARGET( BOARD_ITEM* );
|
2023-10-23 17:23:24 +00:00
|
|
|
static PCB_REFERENCE_IMAGE* Cast_to_PCB_REFERENCE_IMAGE( 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
|
|
|
|
2022-02-03 12:55:37 +00:00
|
|
|
if ct=="PCB_TEXT":
|
2020-10-04 23:34:59 +00:00
|
|
|
return Cast_to_PCB_TEXT(self)
|
2022-02-03 12:55:37 +00:00
|
|
|
if ct=="PCB_TEXTBOX":
|
|
|
|
return Cast_to_PCB_TEXTBOX(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)
|
2021-06-15 08:59:52 +00:00
|
|
|
elif ct=="PCB_DIM_ALIGNED":
|
2021-06-11 16:59:28 +00:00
|
|
|
return Cast_to_PCB_DIM_ALIGNED(self)
|
2021-06-15 08:59:52 +00:00
|
|
|
elif ct=="PCB_DIM_LEADER":
|
2021-06-11 16:59:28 +00:00
|
|
|
return Cast_to_PCB_DIM_LEADER(self)
|
2021-06-15 08:59:52 +00:00
|
|
|
elif ct=="PCB_DIM_CENTER":
|
2021-06-11 16:59:28 +00:00
|
|
|
return Cast_to_PCB_DIM_CENTER(self)
|
2022-01-14 04:55:50 +00:00
|
|
|
elif ct=="PCB_DIM_RADIAL":
|
|
|
|
return Cast_to_PCB_DIM_RADIAL(self)
|
2021-06-15 08:59:52 +00:00
|
|
|
elif ct=="PCB_DIM_ORTHOGONAL":
|
2021-06-11 16:59:28 +00:00
|
|
|
return Cast_to_PCB_DIM_ORTHOGONAL(self)
|
2020-10-09 08:41:11 +00:00
|
|
|
elif ct=="PCB_SHAPE":
|
2020-10-04 23:34:59 +00:00
|
|
|
return Cast_to_PCB_SHAPE(self)
|
2022-01-04 18:49:01 +00:00
|
|
|
elif ct=="FOOTPRINT":
|
2021-06-11 16:59:28 +00:00
|
|
|
return Cast_to_FOOTPRINT(self)
|
2020-08-12 11:23:30 +00:00
|
|
|
elif ct=="PCB_GROUP":
|
|
|
|
return Cast_to_PCB_GROUP(self)
|
2014-10-02 17:09:32 +00:00
|
|
|
elif ct=="PAD":
|
2020-11-14 12:38:44 +00:00
|
|
|
return Cast_to_PAD(self)
|
2021-06-13 15:19:19 +00:00
|
|
|
elif ct=="PCB_VIA":
|
2021-06-11 21:07:02 +00:00
|
|
|
return Cast_to_PCB_VIA(self)
|
2021-06-13 15:19:19 +00:00
|
|
|
elif ct=="PCB_TRACK":
|
2021-06-11 21:07:02 +00:00
|
|
|
return Cast_to_PCB_TRACK(self)
|
2021-06-13 15:19:19 +00:00
|
|
|
elif ct=="PCB_ARC":
|
2021-06-11 21:07:02 +00:00
|
|
|
return Cast_to_PCB_ARC(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)
|
2023-10-23 17:23:24 +00:00
|
|
|
elif ct=="PCB_REFERENCE_IMAGE":
|
|
|
|
return Cast_to_PCB_REFERENCE_IMAGE(self)
|
2020-11-11 23:05:59 +00:00
|
|
|
elif ct=="ZONE":
|
|
|
|
return Cast_to_ZONE(self)
|
2014-10-02 17:09:32 +00:00
|
|
|
else:
|
2020-09-18 05:27:06 +00:00
|
|
|
raise TypeError("Unsupported drawing class: %s" % ct)
|
2014-10-02 17:09:32 +00:00
|
|
|
|
2023-04-15 08:30:33 +00:00
|
|
|
"""
|
|
|
|
Needed to cast BOARD_ITEM::Duplicate() to the suitable type
|
|
|
|
"""
|
|
|
|
def Duplicate(self):
|
|
|
|
ct = self.GetClass()
|
|
|
|
if ct=="BOARD":
|
|
|
|
return None
|
|
|
|
else:
|
|
|
|
return Cast_to_BOARD_ITEM( _pcbnew.BOARD_ITEM_Duplicate(self) ).Cast()
|
|
|
|
|
2016-09-21 01:07:41 +00:00
|
|
|
def SetPos(self,p):
|
|
|
|
self.SetPosition(p)
|
2023-04-15 08:30:33 +00:00
|
|
|
#self.SetPos0(p)
|
2016-09-21 01:07:41 +00:00
|
|
|
|
|
|
|
def SetStartEnd(self,start,end):
|
|
|
|
self.SetStart(start)
|
2023-04-15 08:30:33 +00:00
|
|
|
#self.SetStart0(start)
|
2016-09-21 01:07:41 +00:00
|
|
|
self.SetEnd(end)
|
2023-04-15 08:30:33 +00:00
|
|
|
#self.SetEnd0(end)
|
2016-09-21 01:07:41 +00:00
|
|
|
%}
|
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 %{
|
2020-11-13 15:15:52 +00:00
|
|
|
static PCB_TEXT* Cast_to_PCB_TEXT( BOARD_ITEM* self ) { return dynamic_cast<PCB_TEXT*>(self); }
|
2022-02-03 12:55:37 +00:00
|
|
|
static PCB_TEXTBOX* Cast_to_PCB_TEXTBOX( BOARD_ITEM* self ) { return dynamic_cast<PCB_TEXTBOX*>(self); }
|
2021-06-11 16:59:28 +00:00
|
|
|
static PCB_DIM_ALIGNED* Cast_to_PCB_DIM_ALIGNED( BOARD_ITEM* self ) { return dynamic_cast<PCB_DIM_ALIGNED *>(self); }
|
|
|
|
static PCB_DIM_ORTHOGONAL* Cast_to_PCB_DIM_ORTHOGONAL( BOARD_ITEM* self ) { return dynamic_cast<PCB_DIM_ORTHOGONAL *>(self); }
|
|
|
|
static PCB_DIM_LEADER* Cast_to_PCB_DIM_LEADER( BOARD_ITEM* self ) { return dynamic_cast<PCB_DIM_LEADER *>(self); }
|
|
|
|
static PCB_DIM_CENTER* Cast_to_PCB_DIM_CENTER( BOARD_ITEM* self ) { return dynamic_cast<PCB_DIM_CENTER *>(self); }
|
2022-01-14 04:55:50 +00:00
|
|
|
static PCB_DIM_RADIAL* Cast_to_PCB_DIM_RADIAL( BOARD_ITEM* self ) { return dynamic_cast<PCB_DIM_RADIAL *>(self); }
|
2020-11-13 15:15:52 +00:00
|
|
|
static FOOTPRINT* Cast_to_FOOTPRINT( BOARD_ITEM* self ) { return dynamic_cast<FOOTPRINT*>(self); }
|
2020-09-22 02:32:40 +00:00
|
|
|
static PCB_GROUP* Cast_to_PCB_GROUP( BOARD_ITEM* self ) { return dynamic_cast<PCB_GROUP*>(self); }
|
2020-11-12 22:30:02 +00:00
|
|
|
static PCB_SHAPE* Cast_to_PCB_SHAPE( BOARD_ITEM* self ) { return dynamic_cast<PCB_SHAPE*>(self); }
|
2020-11-14 18:11:28 +00:00
|
|
|
static PCB_MARKER* Cast_to_PCB_MARKER( BOARD_ITEM* self ) { return dynamic_cast<PCB_MARKER*>(self); }
|
2020-09-22 02:32:40 +00:00
|
|
|
static BOARD* Cast_to_BOARD( BOARD_ITEM* self ) { return dynamic_cast<BOARD*>(self); }
|
2020-11-13 15:15:52 +00:00
|
|
|
static PAD* Cast_to_PAD( BOARD_ITEM* self ) { return dynamic_cast<PAD*>(self); }
|
2021-06-11 21:07:02 +00:00
|
|
|
static PCB_TRACK* Cast_to_PCB_TRACK( BOARD_ITEM* self ) { return dynamic_cast<PCB_TRACK *>(self); }
|
|
|
|
static PCB_VIA* Cast_to_PCB_VIA( BOARD_ITEM* self ) { return dynamic_cast<PCB_VIA *>(self); }
|
|
|
|
static PCB_ARC* Cast_to_PCB_ARC( BOARD_ITEM* self ) { return dynamic_cast<PCB_ARC *>(self); }
|
2020-11-13 15:15:52 +00:00
|
|
|
static ZONE* Cast_to_ZONE( BOARD_ITEM* self ) { return dynamic_cast<ZONE*>(self); }
|
2020-09-22 02:32:40 +00:00
|
|
|
static PCB_TARGET* Cast_to_PCB_TARGET( BOARD_ITEM* self ) { return dynamic_cast<PCB_TARGET*>(self); }
|
2023-10-23 17:23:24 +00:00
|
|
|
static PCB_REFERENCE_IMAGE* Cast_to_PCB_REFERENCE_IMAGE( BOARD_ITEM* self ) { return dynamic_cast<PCB_REFERENCE_IMAGE*>(self); }
|
2016-09-21 01:07:41 +00:00
|
|
|
%}
|