made netlist entries and netlist update undoable
This commit is contained in:
parent
1d39a2a44b
commit
9e609acae3
|
@ -60,6 +60,7 @@ enum KICAD_T
|
||||||
PCB_TARGET_T, ///< class PCB_TARGET, a target (graphic item)
|
PCB_TARGET_T, ///< class PCB_TARGET, a target (graphic item)
|
||||||
PCB_ZONE_AREA_T, ///< class ZONE_CONTAINER, a zone area
|
PCB_ZONE_AREA_T, ///< class ZONE_CONTAINER, a zone area
|
||||||
PCB_ITEM_LIST_T, ///< class BOARD_ITEM_LIST, a list of board items
|
PCB_ITEM_LIST_T, ///< class BOARD_ITEM_LIST, a list of board items
|
||||||
|
PCB_NETINFO_T, ///< class NETINFO_ITEM, a description of a net
|
||||||
|
|
||||||
// Schematic draw Items. The order of these items effects the sort order.
|
// Schematic draw Items. The order of these items effects the sort order.
|
||||||
// It is currently ordered to mimic the old Eeschema locate behavior where
|
// It is currently ordered to mimic the old Eeschema locate behavior where
|
||||||
|
|
|
@ -89,19 +89,10 @@ class PCB_EDIT_FRAME : public PCB_BASE_EDIT_FRAME
|
||||||
/// The auxiliary right vertical tool bar used to access the microwave tools.
|
/// The auxiliary right vertical tool bar used to access the microwave tools.
|
||||||
wxAuiToolBar* m_microWaveToolBar;
|
wxAuiToolBar* m_microWaveToolBar;
|
||||||
|
|
||||||
/**
|
|
||||||
* Function loadFootprints
|
|
||||||
* loads the footprints for each #COMPONENT in \a aNetlist from the list of libraries.
|
|
||||||
*
|
|
||||||
* @param aNetlist is the netlist of components to load the footprints into.
|
|
||||||
* @param aReporter is the #REPORTER object to report to.
|
|
||||||
* @throw IO_ERROR if an I/O error occurs or a #PARSE_ERROR if a file parsing error
|
|
||||||
* occurs while reading footprint library files.
|
|
||||||
*/
|
|
||||||
void loadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
|
|
||||||
throw( IO_ERROR, PARSE_ERROR );
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
bool m_undoDisabled;
|
||||||
|
|
||||||
PCB_LAYER_WIDGET* m_Layers;
|
PCB_LAYER_WIDGET* m_Layers;
|
||||||
|
|
||||||
DRC* m_drc; ///< the DRC controller, see drc.cpp
|
DRC* m_drc; ///< the DRC controller, see drc.cpp
|
||||||
|
@ -225,6 +216,23 @@ public:
|
||||||
|
|
||||||
virtual ~PCB_EDIT_FRAME();
|
virtual ~PCB_EDIT_FRAME();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function loadFootprints
|
||||||
|
* loads the footprints for each #COMPONENT in \a aNetlist from the list of libraries.
|
||||||
|
*
|
||||||
|
* @param aNetlist is the netlist of components to load the footprints into.
|
||||||
|
* @param aReporter is the #REPORTER object to report to.
|
||||||
|
* @throw IO_ERROR if an I/O error occurs or a #PARSE_ERROR if a file parsing error
|
||||||
|
* occurs while reading footprint library files.
|
||||||
|
*/
|
||||||
|
void LoadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
|
||||||
|
throw( IO_ERROR, PARSE_ERROR );
|
||||||
|
|
||||||
|
void DisableUndo( bool aDisable = true )
|
||||||
|
{
|
||||||
|
m_undoDisabled = aDisable;
|
||||||
|
}
|
||||||
|
|
||||||
void OnQuit( wxCommandEvent& event );
|
void OnQuit( wxCommandEvent& event );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -145,6 +145,10 @@ static bool TestForExistingItem( BOARD* aPcb, BOARD_ITEM* aItem )
|
||||||
for( item = aPcb->m_Zone; item != NULL; item = item->Next() )
|
for( item = aPcb->m_Zone; item != NULL; item = item->Next() )
|
||||||
icnt++;
|
icnt++;
|
||||||
|
|
||||||
|
NETINFO_LIST& netInfo = aPcb->GetNetInfo();
|
||||||
|
|
||||||
|
icnt += netInfo.GetNetCount();
|
||||||
|
|
||||||
// Build candidate list:
|
// Build candidate list:
|
||||||
itemsList.clear();
|
itemsList.clear();
|
||||||
itemsList.reserve(icnt);
|
itemsList.reserve(icnt);
|
||||||
|
@ -170,6 +174,9 @@ static bool TestForExistingItem( BOARD* aPcb, BOARD_ITEM* aItem )
|
||||||
for( item = aPcb->m_Zone; item != NULL; item = item->Next() )
|
for( item = aPcb->m_Zone; item != NULL; item = item->Next() )
|
||||||
itemsList.push_back( item );
|
itemsList.push_back( item );
|
||||||
|
|
||||||
|
for( NETINFO_LIST::iterator i = netInfo.begin(); i != netInfo.end(); ++i )
|
||||||
|
itemsList.push_back( *i );
|
||||||
|
|
||||||
// Sort list
|
// Sort list
|
||||||
std::sort( itemsList.begin(), itemsList.end() );
|
std::sort( itemsList.begin(), itemsList.end() );
|
||||||
return false;
|
return false;
|
||||||
|
@ -310,12 +317,11 @@ void PCB_EDIT_FRAME::SaveCopyInUndoList( BOARD_ITEM* aItem,
|
||||||
if( aItem->Type() == PCB_MODULE_TEXT_T )
|
if( aItem->Type() == PCB_MODULE_TEXT_T )
|
||||||
{
|
{
|
||||||
aItem = aItem->GetParent();
|
aItem = aItem->GetParent();
|
||||||
|
wxASSERT( aItem->Type() == PCB_MODULE_T );
|
||||||
|
aCommandType = UR_CHANGED;
|
||||||
|
|
||||||
if( aItem == NULL )
|
if( aItem == NULL )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxASSERT( aItem->Type() == PCB_MODULE_T );
|
|
||||||
aCommandType = UR_CHANGED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
|
PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
|
||||||
|
@ -380,27 +386,48 @@ void PCB_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
|
||||||
|
|
||||||
commandToUndo->m_TransformPoint = aTransformPoint;
|
commandToUndo->m_TransformPoint = aTransformPoint;
|
||||||
|
|
||||||
// Copy picker list:
|
// First, filter unnecessary stuff from the list (i.e. for multiple pads / labels modified),
|
||||||
commandToUndo->CopyList( aItemsList );
|
// take the first occurence of the module.
|
||||||
|
|
||||||
// Verify list, and creates data if needed
|
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
|
||||||
for( unsigned ii = 0; ii < commandToUndo->GetCount(); ii++ )
|
|
||||||
{
|
{
|
||||||
BOARD_ITEM* item = (BOARD_ITEM*) commandToUndo->GetPickedItem( ii );
|
BOARD_ITEM* item = (BOARD_ITEM*) aItemsList.GetPickedItem( ii );
|
||||||
|
UNDO_REDO_T status = aItemsList.GetPickedItemStatus( ii );
|
||||||
|
|
||||||
// For texts belonging to modules, we need to save state of the parent module
|
// For texts belonging to modules, we need to save state of the parent module
|
||||||
if( item->Type() == PCB_MODULE_TEXT_T || item->Type() == PCB_PAD_T )
|
if( item->Type() == PCB_MODULE_TEXT_T || item->Type() == PCB_PAD_T )
|
||||||
{
|
{
|
||||||
item = item->GetParent();
|
item = item->GetParent();
|
||||||
|
wxASSERT( item->Type() == PCB_MODULE_T );
|
||||||
|
|
||||||
if( item == NULL )
|
if( item == NULL )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
wxASSERT( item->Type() == PCB_MODULE_T );
|
bool found = false;
|
||||||
|
|
||||||
commandToUndo->SetPickedItem( item, ii );
|
for( int j = 0; j < commandToUndo->GetCount(); j++ )
|
||||||
commandToUndo->SetPickedItemStatus( UR_CHANGED, ii );
|
{
|
||||||
|
if( commandToUndo->GetPickedItem( j ) == item && commandToUndo->GetPickedItemStatus( j ) == UR_CHANGED )
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !found )
|
||||||
|
commandToUndo->PushItem( ITEM_PICKER(item, UR_CHANGED ) );
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
commandToUndo->PushItem( ITEM_PICKER( item, status ) );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for( unsigned ii = 0; ii < commandToUndo->GetCount(); ii++ )
|
||||||
|
{
|
||||||
|
BOARD_ITEM* item = (BOARD_ITEM*) commandToUndo->GetPickedItem( ii );
|
||||||
|
UNDO_REDO_T status = commandToUndo->GetPickedItemStatus( ii );
|
||||||
|
|
||||||
UNDO_REDO_T command = commandToUndo->GetPickedItemStatus( ii );
|
UNDO_REDO_T command = commandToUndo->GetPickedItemStatus( ii );
|
||||||
|
|
||||||
|
@ -649,7 +676,6 @@ void PCB_EDIT_FRAME::RestoreCopyFromUndoList( wxCommandEvent& aEvent )
|
||||||
|
|
||||||
/* Get the old list */
|
/* Get the old list */
|
||||||
PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromUndoList();
|
PICKED_ITEMS_LIST* List = GetScreen()->PopCommandFromUndoList();
|
||||||
|
|
||||||
/* Undo the command */
|
/* Undo the command */
|
||||||
PutDataInPreviousState( List, false );
|
PutDataInPreviousState( List, false );
|
||||||
|
|
||||||
|
|
|
@ -737,6 +737,10 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl )
|
||||||
aBoardItem->SetParent( this );
|
aBoardItem->SetParent( this );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PCB_NETINFO_T:
|
||||||
|
m_NetInfo.AppendNet( (NETINFO_ITEM *) aBoardItem );
|
||||||
|
break;
|
||||||
|
|
||||||
// other types may use linked list
|
// other types may use linked list
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
@ -807,6 +811,11 @@ BOARD_ITEM* BOARD::Remove( BOARD_ITEM* aBoardItem )
|
||||||
m_Drawings.Remove( aBoardItem );
|
m_Drawings.Remove( aBoardItem );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PCB_NETINFO_T:
|
||||||
|
printf( "Unimpl! remove netinfo!\n" );
|
||||||
|
assert( false );
|
||||||
|
break;
|
||||||
|
|
||||||
// other types may use linked list
|
// other types may use linked list
|
||||||
default:
|
default:
|
||||||
wxFAIL_MSG( wxT( "BOARD::Remove() needs more ::Type() support" ) );
|
wxFAIL_MSG( wxT( "BOARD::Remove() needs more ::Type() support" ) );
|
||||||
|
|
|
@ -821,6 +821,11 @@ public:
|
||||||
m_NetInfo.AppendNet( aNewNet );
|
m_NetInfo.AppendNet( aNewNet );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NETINFO_LIST& GetNetInfo()
|
||||||
|
{
|
||||||
|
return m_NetInfo;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef SWIG
|
#ifndef SWIG
|
||||||
/**
|
/**
|
||||||
* Function BeginNets
|
* Function BeginNets
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
#include <gr_basic.h>
|
#include <gr_basic.h>
|
||||||
#include <class_netclass.h>
|
#include <class_netclass.h>
|
||||||
|
#include <class_board_item.h>
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
#include <hashtables.h>
|
#include <hashtables.h>
|
||||||
|
|
||||||
|
@ -422,6 +423,11 @@ public:
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
BOARD* GetParent() const
|
||||||
|
{
|
||||||
|
return m_Parent;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Function clear
|
* Function clear
|
||||||
|
@ -468,7 +474,7 @@ private:
|
||||||
* Class NETINFO_ITEM
|
* Class NETINFO_ITEM
|
||||||
* handles the data for a net
|
* handles the data for a net
|
||||||
*/
|
*/
|
||||||
class NETINFO_ITEM
|
class NETINFO_ITEM : public BOARD_ITEM
|
||||||
{
|
{
|
||||||
friend class NETINFO_LIST;
|
friend class NETINFO_LIST;
|
||||||
|
|
||||||
|
@ -485,7 +491,7 @@ private:
|
||||||
// item of the net classes list
|
// item of the net classes list
|
||||||
NETCLASSPTR m_NetClass;
|
NETCLASSPTR m_NetClass;
|
||||||
|
|
||||||
BOARD_ITEM* m_parent; ///< The parent board item object the net belongs to.
|
BOARD* m_parent; ///< The parent board the net belongs to.
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::vector<D_PAD*> m_PadInNetList; ///< List of pads connected to this net
|
std::vector<D_PAD*> m_PadInNetList; ///< List of pads connected to this net
|
||||||
|
@ -498,9 +504,33 @@ public:
|
||||||
unsigned m_RatsnestEndIdx; // Ending point of ratsnests of this net
|
unsigned m_RatsnestEndIdx; // Ending point of ratsnests of this net
|
||||||
// (excluded) in this buffer
|
// (excluded) in this buffer
|
||||||
|
|
||||||
NETINFO_ITEM( BOARD_ITEM* aParent, const wxString& aNetName = wxEmptyString, int aNetCode = -1 );
|
NETINFO_ITEM( BOARD* aParent, const wxString& aNetName = wxEmptyString, int aNetCode = -1 );
|
||||||
~NETINFO_ITEM();
|
~NETINFO_ITEM();
|
||||||
|
|
||||||
|
static inline bool ClassOf( const EDA_ITEM* aItem )
|
||||||
|
{
|
||||||
|
return aItem && PCB_T == aItem->Type();
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString GetClass() const
|
||||||
|
{
|
||||||
|
return wxT( "NETINFO_ITEM" );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Show( int nestLevel, std::ostream& os ) const
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const wxPoint& GetPosition() const
|
||||||
|
{
|
||||||
|
static wxPoint dummy(0, 0);
|
||||||
|
return dummy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetPosition( const wxPoint& aPos )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function SetClass
|
* Function SetClass
|
||||||
* sets \a aNetclass into this NET
|
* sets \a aNetclass into this NET
|
||||||
|
@ -622,6 +652,8 @@ public:
|
||||||
*/
|
*/
|
||||||
int GetNet() const { return m_NetCode; }
|
int GetNet() const { return m_NetCode; }
|
||||||
|
|
||||||
|
void SetNetCode( int aNetCode ) { m_NetCode = aNetCode; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetNodesCount
|
* Function GetNodesCount
|
||||||
* @return int - number of nodes in the net
|
* @return int - number of nodes in the net
|
||||||
|
@ -663,6 +695,12 @@ public:
|
||||||
|
|
||||||
SetClass( NETCLASSPTR() );
|
SetClass( NETCLASSPTR() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOARD* GetParent() const
|
||||||
|
{
|
||||||
|
return m_parent;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,8 @@
|
||||||
/* class NETINFO_ITEM: handle data relative to a given net */
|
/* class NETINFO_ITEM: handle data relative to a given net */
|
||||||
/*********************************************************/
|
/*********************************************************/
|
||||||
|
|
||||||
NETINFO_ITEM::NETINFO_ITEM( BOARD_ITEM* aParent, const wxString& aNetName, int aNetCode ) :
|
NETINFO_ITEM::NETINFO_ITEM( BOARD* aParent, const wxString& aNetName, int aNetCode ) :
|
||||||
|
BOARD_ITEM( aParent, PCB_NETINFO_T ),
|
||||||
m_NetCode( aNetCode ), m_Netname( aNetName ), m_ShortNetname( m_Netname.AfterLast( '/' ) )
|
m_NetCode( aNetCode ), m_Netname( aNetName ), m_ShortNetname( m_Netname.AfterLast( '/' ) )
|
||||||
{
|
{
|
||||||
m_parent = aParent;
|
m_parent = aParent;
|
||||||
|
|
|
@ -87,7 +87,7 @@ void PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFileName,
|
||||||
|
|
||||||
SetLastNetListRead( aNetlistFileName );
|
SetLastNetListRead( aNetlistFileName );
|
||||||
netlistReader->LoadNetlist();
|
netlistReader->LoadNetlist();
|
||||||
loadFootprints( netlist, aReporter );
|
LoadFootprints( netlist, aReporter );
|
||||||
}
|
}
|
||||||
catch( const IO_ERROR& ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
|
@ -205,7 +205,7 @@ MODULE* PCB_EDIT_FRAME::ListAndSelectModuleName()
|
||||||
|
|
||||||
#define ALLOW_PARTIAL_FPID 1
|
#define ALLOW_PARTIAL_FPID 1
|
||||||
|
|
||||||
void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
|
void PCB_EDIT_FRAME::LoadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
|
||||||
throw( IO_ERROR, PARSE_ERROR )
|
throw( IO_ERROR, PARSE_ERROR )
|
||||||
{
|
{
|
||||||
wxString msg;
|
wxString msg;
|
||||||
|
|
|
@ -309,6 +309,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||||
PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB, wxT( "Pcbnew" ), wxDefaultPosition,
|
PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB, wxT( "Pcbnew" ), wxDefaultPosition,
|
||||||
wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, PCB_EDIT_FRAME_NAME )
|
wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, PCB_EDIT_FRAME_NAME )
|
||||||
{
|
{
|
||||||
|
m_undoDisabled = false;
|
||||||
m_showBorderAndTitleBlock = true; // true to display sheet references
|
m_showBorderAndTitleBlock = true; // true to display sheet references
|
||||||
m_showAxis = false; // true to display X and Y axis
|
m_showAxis = false; // true to display X and Y axis
|
||||||
m_showOriginAxis = true;
|
m_showOriginAxis = true;
|
||||||
|
|
Loading…
Reference in New Issue