pcbnew: remove the last dlist components from pcbnew
This commit is contained in:
parent
6ddc2fe02d
commit
1f30d0c803
|
@ -1,77 +0,0 @@
|
||||||
/*
|
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2012 NBEE Embedded Systems, 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* DLIST python iteration code, to allow standard iteration over DLIST */
|
|
||||||
|
|
||||||
%include <dlist.h>
|
|
||||||
|
|
||||||
%{
|
|
||||||
#include <dlist.h>
|
|
||||||
%}
|
|
||||||
|
|
||||||
|
|
||||||
%extend DLIST
|
|
||||||
{
|
|
||||||
%pythoncode
|
|
||||||
%{
|
|
||||||
class DLISTIter:
|
|
||||||
def __init__(self,aList):
|
|
||||||
self.last = aList # last item is the start of list
|
|
||||||
|
|
||||||
def next(self): # get the next item, Python 2 way to implement an iterator
|
|
||||||
return self.__next__()
|
|
||||||
|
|
||||||
def __next__(self): # get the next item
|
|
||||||
|
|
||||||
item = self.last
|
|
||||||
try:
|
|
||||||
item = item.Get()
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if item is None: # if the item is None, then finish the iteration
|
|
||||||
raise StopIteration
|
|
||||||
else:
|
|
||||||
ret = None
|
|
||||||
|
|
||||||
# first item in list has "Get" as a DLIST
|
|
||||||
try:
|
|
||||||
ret = self.last.Get()
|
|
||||||
except:
|
|
||||||
ret = self.last # next items do not..
|
|
||||||
|
|
||||||
self.last = self.last.Next()
|
|
||||||
|
|
||||||
# when the iterated object can be casted down in inheritance, just do it..
|
|
||||||
|
|
||||||
if 'Cast' in dir(ret):
|
|
||||||
ret = ret.Cast()
|
|
||||||
|
|
||||||
return ret
|
|
||||||
|
|
||||||
def __iter__(self):
|
|
||||||
return self.DLISTIter(self)
|
|
||||||
|
|
||||||
%}
|
|
||||||
}
|
|
|
@ -76,8 +76,6 @@ principle should be easily implemented by adapting the current STL containers.
|
||||||
%ignore operator <<;
|
%ignore operator <<;
|
||||||
%ignore operator=;
|
%ignore operator=;
|
||||||
|
|
||||||
%include dlist.i
|
|
||||||
|
|
||||||
// headers/imports that must be included in the _wrapper.cpp at top
|
// headers/imports that must be included in the _wrapper.cpp at top
|
||||||
|
|
||||||
%{
|
%{
|
||||||
|
|
|
@ -114,8 +114,6 @@ public:
|
||||||
*/
|
*/
|
||||||
static wxPoint ZeroOffset;
|
static wxPoint ZeroOffset;
|
||||||
|
|
||||||
BOARD_ITEM* Next() const { return static_cast<BOARD_ITEM*>( Pnext ); }
|
|
||||||
BOARD_ITEM* Back() const { return static_cast<BOARD_ITEM*>( Pback ); }
|
|
||||||
BOARD_ITEM_CONTAINER* GetParent() const { return (BOARD_ITEM_CONTAINER*) m_Parent; }
|
BOARD_ITEM_CONTAINER* GetParent() const { return (BOARD_ITEM_CONTAINER*) m_Parent; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -32,10 +32,7 @@
|
||||||
|
|
||||||
%include class_board_item.h // generate code for this interface
|
%include class_board_item.h // generate code for this interface
|
||||||
|
|
||||||
// this is to help python with the * accessor of DLIST templates
|
|
||||||
%rename(Get) operator BOARD_ITEM*;
|
%rename(Get) operator BOARD_ITEM*;
|
||||||
%template(BOARD_ITEM_List) DLIST<BOARD_ITEM>;
|
|
||||||
|
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include <class_board_item.h>
|
#include <class_board_item.h>
|
||||||
|
@ -138,7 +135,7 @@ static PCB_TARGET* Cast_to_PCB_TARGET( BOARD_ITEM* );
|
||||||
elif ct=="ZONE_CONTAINER":
|
elif ct=="ZONE_CONTAINER":
|
||||||
return Cast_to_ZONE_CONTAINER(self)
|
return Cast_to_ZONE_CONTAINER(self)
|
||||||
else:
|
else:
|
||||||
return None
|
return none
|
||||||
|
|
||||||
def Duplicate(self):
|
def Duplicate(self):
|
||||||
ct = self.GetClass()
|
ct = self.GetClass()
|
||||||
|
|
|
@ -35,7 +35,6 @@
|
||||||
%feature("flatnested", "");
|
%feature("flatnested", "");
|
||||||
|
|
||||||
%rename(Get) operator MODULE*;
|
%rename(Get) operator MODULE*;
|
||||||
%template(MODULE_List) DLIST<MODULE>;
|
|
||||||
%{
|
%{
|
||||||
#include <class_module.h>
|
#include <class_module.h>
|
||||||
%}
|
%}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
%include class_pad.h
|
%include class_pad.h
|
||||||
|
|
||||||
%rename(Get) operator D_PAD*;
|
%rename(Get) operator D_PAD*;
|
||||||
%template(PAD_List) DLIST<D_PAD>;
|
|
||||||
%{
|
%{
|
||||||
#include <class_pad.h>
|
#include <class_pad.h>
|
||||||
%}
|
%}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
%include class_track.h
|
%include class_track.h
|
||||||
%rename(Get) operator TRACK*;
|
%rename(Get) operator TRACK*;
|
||||||
%template(TRACK_List) DLIST<TRACK>;
|
|
||||||
%{
|
%{
|
||||||
#include <class_track.h>
|
#include <class_track.h>
|
||||||
%}
|
%}
|
||||||
|
|
|
@ -764,21 +764,6 @@ int PCBNEW_CONTROL::AppendBoardFromFile( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Helper function for PCBNEW_CONTROL::placeBoardItems()
|
|
||||||
template<typename T>
|
|
||||||
static void moveNoFlagToVector( DLIST<T>& aList, std::vector<BOARD_ITEM*>& aTarget, bool aIsNew )
|
|
||||||
{
|
|
||||||
for( auto obj = aIsNew ? aList.PopFront() : aList.GetFirst(); obj;
|
|
||||||
obj = aIsNew ? aList.PopFront() : obj->Next() )
|
|
||||||
{
|
|
||||||
if( obj->GetFlags() & FLAG0 )
|
|
||||||
obj->ClearFlags( FLAG0 );
|
|
||||||
else
|
|
||||||
aTarget.push_back( obj );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Helper function for PCBNEW_CONTROL::placeBoardItems()
|
// Helper function for PCBNEW_CONTROL::placeBoardItems()
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static void moveNoFlagToVector( std::deque<T>& aList, std::vector<BOARD_ITEM*>& aTarget, bool aIsNew )
|
static void moveNoFlagToVector( std::deque<T>& aList, std::vector<BOARD_ITEM*>& aTarget, bool aIsNew )
|
||||||
|
|
|
@ -169,18 +169,12 @@ static void SwapItemData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
|
||||||
// mainly pointers in chain and time stamp, which is set to new, unique value.
|
// mainly pointers in chain and time stamp, which is set to new, unique value.
|
||||||
// So we have to use the current values of these parameters.
|
// So we have to use the current values of these parameters.
|
||||||
|
|
||||||
EDA_ITEM* pnext = aItem->Next();
|
|
||||||
EDA_ITEM* pback = aItem->Back();
|
|
||||||
DHEAD* mylist = aItem->GetList();
|
|
||||||
timestamp_t timestamp = aItem->GetTimeStamp();
|
timestamp_t timestamp = aItem->GetTimeStamp();
|
||||||
EDA_ITEM* parent = aItem->GetParent();
|
EDA_ITEM* parent = aItem->GetParent();
|
||||||
|
|
||||||
aItem->SwapData( aImage );
|
aItem->SwapData( aImage );
|
||||||
|
|
||||||
// Restore pointers and time stamp, to be sure they are not broken
|
// Restore pointers and time stamp, to be sure they are not broken
|
||||||
aItem->SetNext( pnext );
|
|
||||||
aItem->SetBack( pback );
|
|
||||||
aItem->SetList( mylist );
|
|
||||||
aItem->SetTimeStamp( timestamp );
|
aItem->SetTimeStamp( timestamp );
|
||||||
aItem->SetParent( parent );
|
aItem->SetParent( parent );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue