Commit c07b677a authored by Wayne Stambaugh's avatar Wayne Stambaugh

Schematic editor locate item changes and other minor fixes.

* Move locate function code into schematic screen object.
* Move test for junction needed into schematic screen object.
* Move test for marking connected items into schematic screen object.
* Move delete item function code into schematic screen object.
* Move delete all markers code into schematic screen object.
* Add method for locating multiple items in schematic screen object.
* Fix minor bug in schematic field object hit test declaration.
* Initial encapsulation work on item picker object.
* Remove duplicate doxygen comments from item picker object source file.
parent 628e5240
......@@ -2,6 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2009 jean-pierre.charras@gipsa-lab.inpg.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2009 Kicad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
......@@ -26,7 +27,6 @@
#include "common.h"
#include "base_struct.h"
//#include "sch_item_struct.h"
#include "base_struct.h"
#include "class_undoredo_container.h"
......@@ -51,20 +51,12 @@ PICKED_ITEMS_LIST::~PICKED_ITEMS_LIST()
}
/** PushItem
* push a picker to the top of the list
* @param aItem = picker to push
*/
void PICKED_ITEMS_LIST::PushItem( ITEM_PICKER& aItem )
{
m_ItemsList.push_back( aItem );
}
/** PopItem
* @return the picker from the top of the list
* the picker is removed from the list
*/
ITEM_PICKER PICKED_ITEMS_LIST::PopItem()
{
ITEM_PICKER item;
......@@ -74,25 +66,29 @@ ITEM_PICKER PICKED_ITEMS_LIST::PopItem()
item = m_ItemsList.back();
m_ItemsList.pop_back();
}
return item;
}
/**
* Function ClearItemsList
* delete only the list of pickers, NOT the picked data itself
*/
bool PICKED_ITEMS_LIST::ContainsItem( EDA_ITEM* aItem ) const
{
for( size_t i = 0; i < m_ItemsList.size(); i++ )
{
if( m_ItemsList[ i ].m_PickedItem == aItem )
return true;
}
return false;
}
void PICKED_ITEMS_LIST::ClearItemsList()
{
m_ItemsList.clear();
}
/**
* Function ClearListAndDeleteItems
* delete the list of pickers, AND the data pointed
* by m_PickedItem or m_PickedItemLink, according to the type of undo/redo command recorded
*/
void PICKED_ITEMS_LIST::ClearListAndDeleteItems()
{
bool show_error_message = true;
......@@ -108,13 +104,14 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems()
case UR_UNSPECIFIED:
if( show_error_message )
wxMessageBox( wxT( "ClearUndoORRedoList() error: UR_UNSPECIFIED command type" ) );
show_error_message = false;
break;
case UR_WIRE_IMAGE:
{
// Specific to eeschema: a linked list of wires is stored.
// the wrapper picks only the first item (head of list), and is owner of all picked items
// Specific to eeschema: a linked list of wires is stored. The wrapper picks only
// the first item (head of list), and is owner of all picked items.
EDA_ITEM* item = wrapper.m_PickedItem;
while( item )
......@@ -144,9 +141,9 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems()
case UR_LIBEDIT: /* Libedit save always a copy of the current item
* So, the picker is always owner of the picked item
*/
case UR_MODEDIT: /* Specific to the module editor
* (modedit creates a full copy of the current module when changed),
* and the picker is owner of this item
case UR_MODEDIT: /* Specific to the module editor (modedit creates a full
* copy of the current module when changed),
* and the picker is owner of this item
*/
delete wrapper.m_PickedItem;
break;
......@@ -164,13 +161,6 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems()
}
/**
* Function GetItemWrapper
* @return the picker of a picked item
* @param aIdx = index of the picker in the picked list
* if this picker does not exist, a picker is returned,
* with its members set to 0 or NULL
*/
ITEM_PICKER PICKED_ITEMS_LIST::GetItemWrapper( unsigned int aIdx )
{
ITEM_PICKER picker;
......@@ -182,11 +172,6 @@ ITEM_PICKER PICKED_ITEMS_LIST::GetItemWrapper( unsigned int aIdx )
}
/**
* Function GetPickedItem
* @return a pointer to the picked item, or null if does not exist
* @param aIdx = index of the picked item in the picked list
*/
EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItem( unsigned int aIdx )
{
if( aIdx < m_ItemsList.size() )
......@@ -196,11 +181,6 @@ EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItem( unsigned int aIdx )
}
/**
* Function GetPickedItemLink
* @return link of the picked item, or null if does not exist
* @param aIdx = index of the picked item in the picked list
*/
EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItemLink( unsigned int aIdx )
{
if( aIdx < m_ItemsList.size() )
......@@ -210,12 +190,6 @@ EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItemLink( unsigned int aIdx )
}
/**
* Function GetPickedItemStatus
* @return the type of undo/redo opertaion associated to the picked item,
* or UR_UNSPECIFIED if does not exist
* @param aIdx = index of the picked item in the picked list
*/
UndoRedoOpType PICKED_ITEMS_LIST::GetPickedItemStatus( unsigned int aIdx )
{
if( aIdx < m_ItemsList.size() )
......@@ -224,12 +198,7 @@ UndoRedoOpType PICKED_ITEMS_LIST::GetPickedItemStatus( unsigned int aIdx )
return UR_UNSPECIFIED;
}
/**
* Function GetPickerFlags
* return the value of the picker flag
* @param aIdx = index of the picker in the picked list
* @return the value stored in the picker, if the picker exists, or 0 if does not exist
*/
int PICKED_ITEMS_LIST::GetPickerFlags( unsigned aIdx )
{
if( aIdx < m_ItemsList.size() )
......@@ -238,12 +207,7 @@ int PICKED_ITEMS_LIST::GetPickerFlags( unsigned aIdx )
return 0;
}
/**
* Function SetPickedItem
* @param aItem = a pointer to the item to pick
* @param aIdx = index of the picker in the picked list
* @return true if the picker exists, or false if does not exist
*/
bool PICKED_ITEMS_LIST::SetPickedItem( EDA_ITEM* aItem, unsigned aIdx )
{
if( aIdx < m_ItemsList.size() )
......@@ -256,13 +220,6 @@ bool PICKED_ITEMS_LIST::SetPickedItem( EDA_ITEM* aItem, unsigned aIdx )
}
/**
* Function SetPickedItemLink
* Set the link associated to a given picked item
* @param aLink = the link to the item associated to the picked item
* @param aIdx = index of the picker in the picked list
* @return true if the picker exists, or false if does not exist
*/
bool PICKED_ITEMS_LIST::SetPickedItemLink( EDA_ITEM* aLink, unsigned aIdx )
{
if( aIdx < m_ItemsList.size() )
......@@ -275,13 +232,6 @@ bool PICKED_ITEMS_LIST::SetPickedItemLink( EDA_ITEM* aLink, unsigned aIdx )
}
/**
* Function SetPickedItem
* @param aItem = a pointer to the item to pick
* @param aStatus = the type of undo/redo operation associated to the item to pick
* @param aIdx = index of the picker in the picked list
* @return true if the picker exists, or false if does not exist
*/
bool PICKED_ITEMS_LIST::SetPickedItem( EDA_ITEM* aItem, UndoRedoOpType aStatus, unsigned aIdx )
{
if( aIdx < m_ItemsList.size() )
......@@ -295,13 +245,6 @@ bool PICKED_ITEMS_LIST::SetPickedItem( EDA_ITEM* aItem, UndoRedoOpType aStatus,
}
/**
* Function SetPickedItemStatus
* Set the the type of undo/redo operation for a given picked item
* @param aStatus = the type of undo/redo operation associated to the picked item
* @param aIdx = index of the picker in the picked list
* @return true if the picker exists, or false if does not exist
*/
bool PICKED_ITEMS_LIST::SetPickedItemStatus( UndoRedoOpType aStatus, unsigned aIdx )
{
if( aIdx < m_ItemsList.size() )
......@@ -312,13 +255,8 @@ bool PICKED_ITEMS_LIST::SetPickedItemStatus( UndoRedoOpType aStatus, unsigned aI
else
return false;
}
/**
* Function SetPickerFlags
* Set the flags of the picker (usually to the picked item m_Flags value)
* @param aFlags = the value to save in picker
* @param aIdx = index of the picker in the picked list
* @return true if the picker exists, or false if does not exist
*/
bool PICKED_ITEMS_LIST::SetPickerFlags( int aFlags, unsigned aIdx )
{
if( aIdx < m_ItemsList.size() )
......@@ -331,12 +269,6 @@ bool PICKED_ITEMS_LIST::SetPickerFlags( int aFlags, unsigned aIdx )
}
/**
* Function RemovePicker
* rem�ove one entry (one picker) from the list of picked items
* @param aIdx = index of the picker in the picked list
* @return true if ok, or false if did not exist
*/
bool PICKED_ITEMS_LIST::RemovePicker( unsigned aIdx )
{
if( aIdx >= m_ItemsList.size() )
......@@ -346,24 +278,12 @@ bool PICKED_ITEMS_LIST::RemovePicker( unsigned aIdx )
}
/**
* Function CopyList
* copy all data from aSource
* Picked items are not copied. just pointers on them are copied
*/
void PICKED_ITEMS_LIST::CopyList( const PICKED_ITEMS_LIST& aSource )
{
m_ItemsList = aSource.m_ItemsList; // Vector's copy
}
/**
* Function ReversePickersListOrder
* reverses the order of pickers stored in this list
* Useful when pop a list from Undo to Redo (and vice-versa)
* because sometimes undo (or redo) a command needs to keep the
* order of successive changes.
* and obviously, undo and redo are in reverse order
*/
void PICKED_ITEMS_LIST::ReversePickersListOrder()
{
std::vector <ITEM_PICKER> tmp;
......
......@@ -33,7 +33,6 @@ extern void MoveItemsInList( PICKED_ITEMS_LIST& aItemsList, const wxPoint aMoveV
extern void RotateListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& Center );
extern void Mirror_X_ListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& aMirrorPoint );
extern void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& Center );
extern void DeleteItemsInList( EDA_DRAW_PANEL* panel, PICKED_ITEMS_LIST& aItemsList );
extern void DuplicateItemsInList( SCH_SCREEN* screen,
PICKED_ITEMS_LIST& aItemsList,
const wxPoint aMoveVector );
......@@ -522,22 +521,19 @@ void SCH_EDIT_FRAME::copyBlockItems( PICKED_ITEMS_LIST& aItemsList )
{
m_blockItems.ClearListAndDeleteItems(); // delete previous saved list, if exists
/* save the new list: */
ITEM_PICKER item;
// In list the wrapper is owner of the schematic item, we can use the UR_DELETED
// status for the picker because pickers with this status are owner of the picked item
// (or TODO ?: create a new status like UR_DUPLICATE)
item.m_UndoRedoStatus = UR_DELETED;
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{
// Clear m_Flag member of selected items:
aItemsList.GetPickedItem( ii )->m_Flags = 0;
aItemsList.GetPickedItem( ii )->ClearFlags();
/* Make a copy of the original picked item. */
SCH_ITEM* DrawStructCopy = DuplicateStruct( (SCH_ITEM*) aItemsList.GetPickedItem( ii ) );
DrawStructCopy->SetParent( NULL );
item.m_PickedItem = DrawStructCopy;
SCH_ITEM* copy = DuplicateStruct( (SCH_ITEM*) aItemsList.GetPickedItem( ii ) );
copy->SetParent( NULL );
// In list the wrapper is owner of the schematic item, we can use the UR_DELETED
// status for the picker because pickers with this status are owner of the picked item
// (or TODO ?: create a new status like UR_DUPLICATE)
ITEM_PICKER item( copy, UR_DELETED );
m_blockItems.PushItem( item );
}
}
......@@ -559,13 +555,12 @@ void SCH_EDIT_FRAME::PasteListOfItems( wxDC* DC )
PICKED_ITEMS_LIST picklist;
// Creates data, and push it as new data in undo item list buffer
ITEM_PICKER picker( NULL, UR_NEW );
for( unsigned ii = 0; ii < m_blockItems.GetCount(); ii++ )
{
Struct = DuplicateStruct( (SCH_ITEM*) m_blockItems.m_ItemsSelection.GetPickedItem( ii ) );
picker.m_PickedItem = Struct;
// Creates data, and push it as new data in undo item list buffer
ITEM_PICKER picker( Struct, UR_NEW );
picklist.PushItem( picker );
// Clear annotation and init new time stamp for the new components:
......@@ -574,6 +569,7 @@ void SCH_EDIT_FRAME::PasteListOfItems( wxDC* DC )
( (SCH_COMPONENT*) Struct )->m_TimeStamp = GetTimeStamp();
( (SCH_COMPONENT*) Struct )->ClearAnnotation( NULL );
}
SetSchItemParent( Struct, GetScreen() );
Struct->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
Struct->SetNext( GetScreen()->GetDrawItems() );
......@@ -584,7 +580,7 @@ void SCH_EDIT_FRAME::PasteListOfItems( wxDC* DC )
MoveItemsInList( picklist, GetScreen()->m_BlockLocate.m_MoveVector );
/* clear .m_Flags member for all items */
// Clear flags for all items.
GetScreen()->ClearDrawingState();
OnModify();
......
......@@ -26,7 +26,6 @@
static void AbortCreateNewLine( EDA_DRAW_PANEL* Panel, wxDC* DC );
static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer );
static bool IsJunctionNeeded( SCH_EDIT_FRAME* frame, wxPoint& pos );
static void ComputeBreakPoint( SCH_LINE* segment, const wxPoint& new_pos );
SCH_ITEM* s_OldWiresList;
......@@ -92,7 +91,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
SCH_LINE* oldsegment, * newsegment, * nextsegment;
wxPoint cursorpos = GetScreen()->GetCrossHairPosition();
if( GetScreen()->GetCurItem() && (GetScreen()->GetCurItem()->m_Flags == 0) )
if( GetScreen()->GetCurItem() && (GetScreen()->GetCurItem()->GetFlags() == 0) )
GetScreen()->SetCurItem( NULL );
if( GetScreen()->GetCurItem() )
......@@ -134,12 +133,12 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
break;
}
newsegment->m_Flags = IS_NEW;
newsegment->SetFlags( IS_NEW );
if( g_HVLines ) // We need 2 segments to go from a given start pin to an end point
{
nextsegment = new SCH_LINE( *newsegment );
nextsegment->m_Flags = IS_NEW;
nextsegment->SetFlags( IS_NEW );
newsegment->SetNext( nextsegment );
nextsegment->SetBack( newsegment );
}
......@@ -199,8 +198,9 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
}
newsegment->m_End = cursorpos;
oldsegment->m_Flags = SELECTED;
newsegment->m_Flags = IS_NEW;
oldsegment->ClearFlags( IS_NEW );
oldsegment->SetFlags( SELECTED );
newsegment->SetFlags( IS_NEW );
GetScreen()->SetCurItem( newsegment );
DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false );
......@@ -210,7 +210,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
* (tested when the connection will be finished)*/
if( oldsegment->m_Start == s_ConnexionStartPoint )
{
if( IsJunctionNeeded( this, s_ConnexionStartPoint ) )
if( GetScreen()->IsJunctionNeeded( s_ConnexionStartPoint ) )
AddJunction( DC, s_ConnexionStartPoint );
}
}
......@@ -291,28 +291,28 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC )
while( segment )
{
if( segment->m_Flags )
if( segment->GetFlags() )
{
if( !m_itemToRepeat )
m_itemToRepeat = segment;
}
segment->m_Flags = 0;
segment->ClearFlags();
segment = segment->Next();
}
// Automatic place of a junction on the end point, if needed
if( lastsegment )
{
if( IsJunctionNeeded( this, end_point ) )
if( GetScreen()->IsJunctionNeeded( end_point ) )
AddJunction( DC, end_point );
else if( IsJunctionNeeded( this, alt_end_point ) )
else if( GetScreen()->IsJunctionNeeded( alt_end_point ) )
AddJunction( DC, alt_end_point );
}
/* Automatic place of a junction on the start point if necessary because
* the cleanup can suppress intermediate points by merging wire segments */
if( IsJunctionNeeded( this, s_ConnexionStartPoint ) )
if( GetScreen()->IsJunctionNeeded( s_ConnexionStartPoint ) )
AddJunction( DC, s_ConnexionStartPoint );
GetScreen()->TestDanglingEnds( DrawPanel, DC );
......@@ -500,14 +500,8 @@ static void AbortCreateNewLine( EDA_DRAW_PANEL* Panel, wxDC* DC )
parent->SetRepeatItem( NULL );
}
/* Clear m_Flags which is used in edit functions: */
SCH_ITEM* item = screen->GetDrawItems();
while( item )
{
item->m_Flags = 0;
item = item->Next();
}
// Clear flags used in edit functions.
screen->ClearDrawingState();
}
......@@ -526,7 +520,7 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
{
wxPoint pos = GetScreen()->GetCrossHairPosition() -
( (SCH_COMPONENT*) m_itemToRepeat )->m_Pos;
m_itemToRepeat->m_Flags = IS_NEW;
m_itemToRepeat->SetFlags( IS_NEW );
( (SCH_COMPONENT*) m_itemToRepeat )->m_TimeStamp = GetTimeStamp();
m_itemToRepeat->Move( pos );
m_itemToRepeat->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
......@@ -546,7 +540,7 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
GetScreen()->TestDanglingEnds();
m_itemToRepeat->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
SaveCopyInUndoList( m_itemToRepeat, UR_NEW );
m_itemToRepeat->m_Flags = 0;
m_itemToRepeat->ClearFlags();
}
}
......@@ -601,7 +595,7 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
switch( layer )
{
case LAYER_BUS:
item = PickStruct( pos, screen, BUS_T );
item = screen->GetItem( pos, 0, BUS_T );
if( item )
return true;
......@@ -618,13 +612,14 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
break;
case LAYER_NOTES:
item = PickStruct( pos, screen, DRAW_ITEM_T );
item = screen->GetItem( pos, 0, DRAW_ITEM_T );
if( item )
return true;
break;
case LAYER_WIRE:
item = PickStruct( pos, screen, BUS_ENTRY_T | JUNCTION_T );
item = screen->GetItem( pos, MAX( g_DrawDefaultLineThickness, 3 ),
BUS_ENTRY_T | JUNCTION_T );
if( item )
return true;
......@@ -643,12 +638,12 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
return true;
}
item = PickStruct( pos, screen, WIRE_T );
item = screen->GetItem( pos, 0, WIRE_T );
if( item )
return true;
item = PickStruct( pos, screen, LABEL_T );
item = screen->GetItem( pos, 0, LABEL_T );
if( item && (item->Type() != SCH_TEXT_T)
&& ( ( (SCH_GLOBALLABEL*) item )->m_Pos.x == pos.x )
&& ( ( (SCH_GLOBALLABEL*) item )->m_Pos.y == pos.y ) )
......@@ -672,29 +667,3 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
return false;
}
/* Return True when a wire is located at pos "pos" if
* - there is no junction.
* - The wire has no ends at pos "pos",
* and therefore it is considered as no connected.
* - One (or more) wire has one end at pos "pos"
* or
* - a pin is on location pos
*/
bool IsJunctionNeeded( SCH_EDIT_FRAME* frame, wxPoint& pos )
{
if( PickStruct( pos, frame->GetScreen(), JUNCTION_T ) )
return false;
if( PickStruct( pos, frame->GetScreen(), WIRE_T | EXCLUDE_ENDPOINTS_T ) )
{
if( PickStruct( pos, frame->GetScreen(), WIRE_T | ENDPOINTS_ONLY_T ) )
return true;
if( frame->GetScreen()->GetPin( pos, NULL, true ) )
return true;
}
return false;
}
......@@ -120,7 +120,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin
wxString Text;
wxString msg;
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), MARKER_T );
item = GetScreen()->GetItem( aPosition, 0, MARKER_T );
if( item )
{
......@@ -128,7 +128,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin
return item;
}
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), NO_CONNECT_T );
item = GetScreen()->GetItem( aPosition, 0, NO_CONNECT_T );
if( item )
{
......@@ -136,7 +136,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin
return item;
}
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), JUNCTION_T );
item = GetScreen()->GetItem( aPosition, 0, JUNCTION_T );
if( item )
{
......@@ -144,7 +144,8 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin
return item;
}
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), WIRE_T | BUS_T | BUS_ENTRY_T );
item = GetScreen()->GetItem( aPosition, MAX( g_DrawDefaultLineThickness, 3 ),
WIRE_T | BUS_T | BUS_ENTRY_T );
if( item ) // We have found a wire: Search for a connected pin at the same location
{
......@@ -164,17 +165,20 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin
return item;
}
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), DRAW_ITEM_T );
item = GetScreen()->GetItem( aPosition, 0, DRAW_ITEM_T );
if( item )
{
ClearMsgPanel();
return item;
}
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), FIELD_T );
item = GetScreen()->GetItem( aPosition, 0, FIELD_T );
if( item )
{
wxASSERT( item->Type() == SCH_FIELD_T );
SCH_FIELD* Field = (SCH_FIELD*) item;
LibItem = (SCH_COMPONENT*) Field->GetParent();
LibItem->DisplayInfo( this );
......@@ -182,7 +186,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin
return item;
}
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), LABEL_T | TEXT_T );
item = GetScreen()->GetItem( aPosition, 0, LABEL_T | TEXT_T );
if( item )
{
......@@ -204,7 +208,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin
return LibItem;
}
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), COMPONENT_T );
item = GetScreen()->GetItem( aPosition, 0, COMPONENT_T );
if( item )
{
......@@ -214,7 +218,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin
return item;
}
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), SHEET_T );
item = GetScreen()->GetItem( aPosition, 0, SHEET_T );
if( item )
{
......@@ -222,7 +226,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin
return item;
}
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), NO_FILTER_T );
item = GetScreen()->GetItem( aPosition );
if( item )
return item;
......@@ -295,7 +299,7 @@ void SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
if( aHotKey )
{
if( screen->GetCurItem() && screen->GetCurItem()->m_Flags )
if( screen->GetCurItem() && screen->GetCurItem()->GetFlags() )
OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() );
else
OnHotKey( aDC, aHotKey, aPosition, NULL );
......@@ -368,7 +372,7 @@ void LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
if( aHotKey )
{
if( screen->GetCurItem() && screen->GetCurItem()->m_Flags )
if( screen->GetCurItem() && screen->GetCurItem()->GetFlags() )
OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() );
else
OnHotKey( aDC, aHotKey, aPosition, NULL );
......@@ -441,7 +445,7 @@ void LIB_VIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
if( aHotKey )
{
if( screen->GetCurItem() && screen->GetCurItem()->m_Flags )
if( screen->GetCurItem() && screen->GetCurItem()->GetFlags() )
OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() );
else
OnHotKey( aDC, aHotKey, aPosition, NULL );
......
This diff is collapsed.
......@@ -85,7 +85,8 @@ void DIALOG_ERC::OnEraseDrcMarkersClick( wxCommandEvent& event )
{
/* Delete the old ERC markers, over the whole hierarchy
*/
DeleteAllMarkers( MARK_ERC );
SCH_SCREENS ScreenList;
ScreenList.DeleteAllMarkers( MARK_ERC );
m_MarkersList->ClearList();
m_Parent->DrawPanel->Refresh();
}
......@@ -427,14 +428,13 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
}
/* Erase all DRC markers */
DeleteAllMarkers( MARK_ERC );
SCH_SCREENS ScreenList;
ScreenList.DeleteAllMarkers( MARK_ERC );
g_EESchemaVar.NbErrorErc = 0;
g_EESchemaVar.NbWarningErc = 0;
/* Cleanup the entire hierarchy */
SCH_SCREENS ScreenList;
for( SCH_SCREEN* Screen = ScreenList.GetFirst();
Screen != NULL;
Screen = ScreenList.GetNext() )
......
......@@ -79,8 +79,8 @@ void SCH_EDIT_FRAME::StartMoveTexte( SCH_TEXT* aTextItem, wxDC* aDC )
void SCH_EDIT_FRAME::ChangeTextOrient( SCH_TEXT* aTextItem, wxDC* aDC )
{
if( aTextItem == NULL )
aTextItem = (SCH_TEXT*) PickStruct( GetScreen()->GetCrossHairPosition(),
GetScreen(), TEXT_T | LABEL_T );
aTextItem = (SCH_TEXT*) GetScreen()->GetItem( GetScreen()->GetCrossHairPosition(), 0,
TEXT_T | LABEL_T );
if( aTextItem == NULL )
return;
......@@ -348,7 +348,7 @@ void SCH_EDIT_FRAME::OnConvertTextType( wxCommandEvent& aEvent )
if( (flags & IS_NEW) == 0 ) // Remove old text from current list and save it in undo list
{
text->ClearFlags();
DeleteStruct( DrawPanel, &dc, text ); // old text is really saved in undo list
DeleteItem( text ); // old text is really saved in undo list
GetScreen()->SetCurItem( NULL );
m_itemToRepeat = NULL;
}
......
......@@ -265,7 +265,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
SCH_SCREEN* screen = GetScreen();
// itemInEdit == false means no item currently edited. We can ask for editing a new item
bool itemInEdit = screen->GetCurItem() && screen->GetCurItem()->m_Flags;
bool itemInEdit = screen->GetCurItem() && screen->GetCurItem()->GetFlags();
// notBusy == true means no item currently edited and no other command in progress
// We can change active tool and ask for editing a new item
bool notBusy = (!itemInEdit) && (screen->m_BlockLocate.m_State == STATE_NO_BLOCK);
......@@ -342,7 +342,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
case HK_DELETE:
if( notBusy)
{
LocateAndDeleteItem( this, aDC );
DeleteItemAtCrossHair( aDC );
OnModify();
GetScreen()->SetCurItem( NULL );
GetScreen()->TestDanglingEnds( DrawPanel, aDC );
......@@ -350,7 +350,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
break;
case HK_REPEAT_LAST:
if( notBusy && m_itemToRepeat && ( m_itemToRepeat->m_Flags == 0 ) )
if( notBusy && m_itemToRepeat && ( m_itemToRepeat->GetFlags() == 0 ) )
RepeatDrawItem( aDC );
break;
......@@ -701,7 +701,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
if( aItem->Type() == SCH_JUNCTION_T )
{
// If it's a junction, pick the underlying wire instead
aItem = PickStruct( GetScreen()->GetCrossHairPosition(), GetScreen(), WIRE_T );
aItem = screen->GetItem( screen->GetCrossHairPosition(), 0, WIRE_T );
}
if( aItem == NULL )
......@@ -716,7 +716,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
break;
}
if( aItem && (aItem->m_Flags == 0) )
if( aItem && (aItem->GetFlags() == 0) )
{
GetScreen()->SetCurItem( (SCH_ITEM*) aItem );
......@@ -777,8 +777,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
if( aItem == NULL )
{
aItem = PickStruct( GetScreen()->GetCrossHairPosition(), GetScreen(),
COMPONENT_T | TEXT_T | LABEL_T | SHEET_T );
aItem = screen->GetItem( screen->GetCrossHairPosition(), 0,
COMPONENT_T | TEXT_T | LABEL_T | SHEET_T );
if( aItem == NULL )
break;
......@@ -857,7 +857,7 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
cmd.SetEventObject( this );
bool itemInEdit = GetScreen()->GetCurItem() && GetScreen()->GetCurItem()->m_Flags;
bool itemInEdit = GetScreen()->GetCurItem() && GetScreen()->GetCurItem()->GetFlags();
if( aHotKey == 0 )
return;
......@@ -932,8 +932,8 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
break;
case HK_REPEAT_LAST:
if( m_lastDrawItem && (m_lastDrawItem->m_Flags == 0)
&& ( m_lastDrawItem->Type() == LIB_PIN_T ) )
if( m_lastDrawItem && (m_lastDrawItem->GetFlags() == 0)
&& ( m_lastDrawItem->Type() == LIB_PIN_T ) )
RepeatPinItem( aDC, (LIB_PIN*) m_lastDrawItem );
break;
......
This diff is collapsed.
......@@ -31,12 +31,12 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
SCH_ITEM* item = GetScreen()->GetCurItem();
wxPoint gridPosition = GetGridPosition( aPosition );
if( ( GetToolId() == ID_NO_TOOL_SELECTED ) || ( item && item->m_Flags ) )
if( ( GetToolId() == ID_NO_TOOL_SELECTED ) || ( item && item->GetFlags() ) )
{
DrawPanel->m_AutoPAN_Request = false;
m_itemToRepeat = NULL;
if( item && item->m_Flags )
if( item && item->GetFlags() )
{
switch( item->Type() )
{
......@@ -77,7 +77,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break;
case ID_HIERARCHY_PUSH_POP_BUTT:
if( ( item && item->m_Flags ) || ( g_RootSheet->CountSheets() == 0 ) )
if( ( item && item->GetFlags() ) || ( g_RootSheet->CountSheets() == 0 ) )
break;
item = LocateAndShowItem( aPosition );
......@@ -99,7 +99,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break;
case ID_NOCONN_BUTT:
if( ( item == NULL ) || ( item->m_Flags == 0 ) )
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
{
m_itemToRepeat = AddNoConnect( aDC, gridPosition );
GetScreen()->SetCurItem( m_itemToRepeat );
......@@ -116,7 +116,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break;
case ID_JUNCTION_BUTT:
if( ( item == NULL ) || ( item->m_Flags == 0 ) )
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
{
m_itemToRepeat = AddJunction( aDC, gridPosition, true );
GetScreen()->SetCurItem( m_itemToRepeat );
......@@ -134,7 +134,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
case ID_WIRETOBUS_ENTRY_BUTT:
case ID_BUSTOBUS_ENTRY_BUTT:
if( ( item == NULL ) || ( item->m_Flags == 0 ) )
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
{
item = CreateBusEntry( aDC, ( GetToolId() == ID_WIRETOBUS_ENTRY_BUTT ) ?
WIRE_TO_BUS : BUS_TO_BUS );
......@@ -152,7 +152,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break;
case ID_SCHEMATIC_DELETE_ITEM_BUTT:
LocateAndDeleteItem( this, aDC );
DeleteItemAtCrossHair( aDC );
OnModify();
GetScreen()->SetCurItem( NULL );
GetScreen()->TestDanglingEnds();
......@@ -175,7 +175,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break;
case ID_TEXT_COMMENT_BUTT:
if( ( item == NULL ) || ( item->m_Flags == 0 ) )
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
{
GetScreen()->SetCurItem( CreateNewText( aDC, LAYER_NOTES ) );
DrawPanel->m_AutoPAN_Request = true;
......@@ -188,7 +188,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break;
case ID_LABEL_BUTT:
if( ( item == NULL ) || ( item->m_Flags == 0 ) )
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
{
GetScreen()->SetCurItem( CreateNewText( aDC, LAYER_LOCLABEL ) );
DrawPanel->m_AutoPAN_Request = true;
......@@ -204,7 +204,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
case ID_GLABEL_BUTT:
case ID_HIERLABEL_BUTT:
if( (item == NULL) || (item->m_Flags == 0) )
if( (item == NULL) || (item->GetFlags() == 0) )
{
if( GetToolId() == ID_GLABEL_BUTT )
GetScreen()->SetCurItem( CreateNewText( aDC, LAYER_GLOBLABEL ) );
......@@ -224,7 +224,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break;
case ID_SHEET_SYMBOL_BUTT:
if( ( item == NULL ) || ( item->m_Flags == 0 ) )
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
{
GetScreen()->SetCurItem( CreateSheet( aDC ) );
DrawPanel->m_AutoPAN_Request = true;
......@@ -240,20 +240,20 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
case ID_IMPORT_HLABEL_BUTT:
case ID_SHEET_LABEL_BUTT:
if( ( item == NULL ) || ( item->m_Flags == 0 ) )
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
item = LocateAndShowItem( aPosition );
if( item == NULL )
break;
if( (item->Type() == SCH_SHEET_T) && (item->m_Flags == 0) )
if( (item->Type() == SCH_SHEET_T) && (item->GetFlags() == 0) )
{
if( GetToolId() == ID_IMPORT_HLABEL_BUTT )
GetScreen()->SetCurItem( Import_PinSheet( (SCH_SHEET*) item, aDC ) );
else
GetScreen()->SetCurItem( Create_PinSheet( (SCH_SHEET*) item, aDC ) );
}
else if( (item->Type() == SCH_SHEET_LABEL_T) && (item->m_Flags != 0) )
else if( (item->Type() == SCH_SHEET_LABEL_T) && (item->GetFlags() != 0) )
{
item->Place( this, aDC );
GetScreen()->TestDanglingEnds();
......@@ -262,7 +262,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break;
case ID_SCH_PLACE_COMPONENT:
if( (item == NULL) || (item->m_Flags == 0) )
if( (item == NULL) || (item->GetFlags() == 0) )
{
GetScreen()->SetCurItem( Load_Component( aDC, wxEmptyString, s_CmpNameList, true ) );
DrawPanel->m_AutoPAN_Request = true;
......@@ -277,7 +277,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break;
case ID_PLACE_POWER_BUTT:
if( ( item == NULL ) || ( item->m_Flags == 0 ) )
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
{
GetScreen()->SetCurItem( Load_Component( aDC, wxT( "power" ),
s_PowerNameList, false ) );
......@@ -317,12 +317,12 @@ void SCH_EDIT_FRAME::OnLeftDClick( wxDC* aDC, const wxPoint& aPosition )
switch( GetToolId() )
{
case ID_NO_TOOL_SELECTED:
if( ( item == NULL ) || ( item->m_Flags == 0 ) )
if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
{
item = LocateAndShowItem( aPosition );
}
if( ( item == NULL ) || ( item->m_Flags != 0 ) )
if( ( item == NULL ) || ( item->GetFlags() != 0 ) )
break;
switch( item->Type() )
......
......@@ -64,7 +64,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
}
// Try to locate items at cursor position.
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
if( (DrawStruct == NULL) || (DrawStruct->GetFlags() == 0) )
{
DrawStruct = LocateAndShowItem( aPosition, false );
......@@ -81,7 +81,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
// If Command in progress: add "cancel" and "end tool" menu
if( GetToolId() != ID_NO_TOOL_SELECTED )
{
if( DrawStruct && DrawStruct->m_Flags )
if( DrawStruct && DrawStruct->GetFlags() )
{
ADD_MENUITEM( PopMenu, ID_CANCEL_CURRENT_COMMAND, _( "Cancel" ), cancel_xpm );
}
......@@ -93,7 +93,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
}
else
{
if( DrawStruct && DrawStruct->m_Flags )
if( DrawStruct && DrawStruct->GetFlags() )
{
ADD_MENUITEM( PopMenu, ID_CANCEL_CURRENT_COMMAND, _( "Cancel" ), cancel_xpm );
PopMenu->AppendSeparator();
......@@ -112,7 +112,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
GetScreen()->SetCurItem( DrawStruct );
int flags = DrawStruct->m_Flags;
int flags = DrawStruct->GetFlags();
bool is_new = (flags & IS_NEW) ? TRUE : FALSE;
switch( DrawStruct->Type() )
......@@ -228,7 +228,7 @@ void AddMenusForComponentField( wxMenu* PopMenu, SCH_FIELD* Field )
{
wxString msg;
if( !Field->m_Flags )
if( !Field->GetFlags() )
{
msg = AddHotkeyName( _( "Move Field" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM );
......@@ -259,7 +259,7 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
if( libEntry )
libComponent = libEntry->GetComponent();
if( !Component->m_Flags )
if( !Component->GetFlags() )
{
msg = _( "Move Component" );
msg << wxT( " " ) << Component->GetField( REFERENCE )->m_Text;
......@@ -325,7 +325,7 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
ADD_MENUITEM_WITH_SUBMENU( PopMenu, editmenu, ID_POPUP_SCH_GENERIC_EDIT_CMP,
_( "Edit Component" ), edit_component_xpm );
if( !Component->m_Flags )
if( !Component->GetFlags() )
{
msg = AddHotkeyName( _( "Copy Component" ), s_Schematic_Hokeys_Descr,
HK_COPY_COMPONENT_OR_LABEL );
......@@ -344,7 +344,7 @@ void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel )
wxMenu* menu_change_type = new wxMenu;
wxString msg;
if( !GLabel->m_Flags )
if( !GLabel->GetFlags() )
{
msg = AddHotkeyName( _( "Move Global Label" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM );
......@@ -381,7 +381,7 @@ void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* HLabel )
wxMenu* menu_change_type = new wxMenu;
wxString msg;
if( !HLabel->m_Flags )
if( !HLabel->GetFlags() )
{
msg = AddHotkeyName( _( "Move Hierarchical Label" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM );
......@@ -417,7 +417,7 @@ void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label )
wxMenu* menu_change_type = new wxMenu;
wxString msg;
if( !Label->m_Flags )
if( !Label->GetFlags() )
{
msg = AddHotkeyName( _( "Move Label" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM );
......@@ -453,7 +453,7 @@ void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text )
wxString msg;
wxMenu* menu_change_type = new wxMenu;
if( !Text->m_Flags )
if( !Text->GetFlags() )
{
msg = AddHotkeyName( _( "Move Text" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM );
......@@ -490,19 +490,20 @@ void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text )
void AddMenusForJunction( wxMenu* PopMenu, SCH_JUNCTION* Junction, SCH_EDIT_FRAME* frame )
{
bool is_new = Junction->IsNew();
SCH_SCREEN* screen = frame->GetScreen();
wxString msg;
if( !is_new )
{
if( PickStruct( frame->GetScreen()->GetCrossHairPosition(), frame->GetScreen(),
WIRE_T | BUS_T | EXCLUDE_ENDPOINTS_T ) )
if( screen->GetItem( screen->GetCrossHairPosition(), 0,
WIRE_T | BUS_T | EXCLUDE_ENDPOINTS_T ) )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ), break_line_xpm );
}
msg = AddHotkeyName( _( "Delete Junction" ), s_Schematic_Hokeys_Descr, HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, msg, delete_xpm );
if( PickStruct( frame->GetScreen()->GetCrossHairPosition(), frame->GetScreen(), WIRE_T | BUS_T ) )
if( screen->GetItem( screen->GetCrossHairPosition(), 0, WIRE_T | BUS_T ) )
{
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete Node" ), delete_node_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( "Delete Connection" ),
......@@ -514,7 +515,8 @@ void AddMenusForJunction( wxMenu* PopMenu, SCH_JUNCTION* Junction, SCH_EDIT_FRAM
void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame )
{
bool is_new = Wire->IsNew();
wxPoint pos = frame->GetScreen()->GetCrossHairPosition();
SCH_SCREEN* screen = frame->GetScreen();
wxPoint pos = screen->GetCrossHairPosition();
wxString msg;
if( is_new )
......@@ -532,8 +534,8 @@ void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( "Delete Connection" ),
delete_connection_xpm );
if( PickStruct( frame->GetScreen()->GetCrossHairPosition(), frame->GetScreen(),
WIRE_T | BUS_T | EXCLUDE_ENDPOINTS_T ) )
if( screen->GetItem( screen->GetCrossHairPosition(), 0,
WIRE_T | BUS_T | EXCLUDE_ENDPOINTS_T ) )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ), break_line_xpm );
PopMenu->AppendSeparator();
......@@ -582,7 +584,7 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet )
{
wxString msg;
if( !Sheet->m_Flags )
if( !Sheet->GetFlags() )
{
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ENTER_SHEET, _( "Enter Sheet" ), enter_sheet_xpm );
PopMenu->AppendSeparator();
......@@ -594,7 +596,7 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DRAG_CMP_REQUEST, msg, move_sheet_xpm );
}
if( Sheet->m_Flags )
if( Sheet->GetFlags() )
{
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_END_SHEET, _( "Place Sheet" ), apply_xpm );
}
......@@ -623,7 +625,7 @@ void AddMenusForPinSheet( wxMenu* PopMenu, SCH_SHEET_PIN* PinSheet )
{
wxString msg;
if( !PinSheet->m_Flags )
if( !PinSheet->GetFlags() )
{
msg = AddHotkeyName( _( "Move PinSheet" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM );
......@@ -632,7 +634,7 @@ void AddMenusForPinSheet( wxMenu* PopMenu, SCH_SHEET_PIN* PinSheet )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_PINSHEET, _( "Edit PinSheet" ), edit_xpm );
if( !PinSheet->m_Flags )
if( !PinSheet->GetFlags() )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete PinSheet" ), delete_pinsheet_xpm );
}
......
......@@ -57,7 +57,7 @@ void RotateListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& rotationPoint )
{
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii );
item->Rotate( rotationPoint ); // Place it in its new position.
item->m_Flags = 0;
item->ClearFlags();
}
}
......@@ -73,7 +73,7 @@ void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& aMirrorPoint )
{
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii );
item->Mirror_Y( aMirrorPoint.x ); // Place it in its new position.
item->m_Flags = 0;
item->ClearFlags();
}
}
......@@ -84,7 +84,7 @@ void Mirror_X_ListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& aMirrorPoint
{
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii );
item->Mirror_X( aMirrorPoint.y ); // Place it in its new position.
item->m_Flags = 0;
item->ClearFlags();
}
}
......@@ -115,13 +115,11 @@ void DeleteItemsInList( EDA_DRAW_PANEL* panel, PICKED_ITEMS_LIST& aItemsList )
SCH_SCREEN* screen = (SCH_SCREEN*) panel->GetScreen();
SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) panel->GetParent();
PICKED_ITEMS_LIST itemsList;
ITEM_PICKER itemWrapper;
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii );
itemWrapper.m_PickedItem = item;
itemWrapper.m_UndoRedoStatus = UR_DELETED;
ITEM_PICKER itemWrapper( item, UR_DELETED );
if( item->Type() == SCH_SHEET_LABEL_T )
{
......@@ -143,37 +141,31 @@ void DeleteItemsInList( EDA_DRAW_PANEL* panel, PICKED_ITEMS_LIST& aItemsList )
}
/* Routine to delete an object from global drawing object list.
* Object is put in Undo list
*/
void DeleteStruct( EDA_DRAW_PANEL* panel, wxDC* DC, SCH_ITEM* DrawStruct )
void SCH_EDIT_FRAME::DeleteItem( SCH_ITEM* aItem )
{
SCH_SCREEN* screen = (SCH_SCREEN*) panel->GetScreen();
SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) panel->GetParent();
wxCHECK_RET( aItem != NULL, wxT( "Cannot delete invalid item." ) );
if( !DrawStruct )
return;
SCH_SCREEN* screen = GetScreen();
if( DrawStruct->Type() == SCH_SHEET_LABEL_T )
if( aItem->Type() == SCH_SHEET_LABEL_T )
{
/* This structure is attached to a node, and is not accessible by
* the global list directly. */
frame->SaveCopyInUndoList( (SCH_ITEM*)( (SCH_SHEET_PIN*) DrawStruct )->GetParent(),
UR_CHANGED );
frame->DeleteSheetLabel( DC ? true : false, (SCH_SHEET_PIN*) DrawStruct );
return;
// This iten is attached to a node, and is not accessible by the global list directly.
SCH_SHEET* sheet = (SCH_SHEET*) aItem->GetParent();
wxCHECK_RET( (sheet != NULL) && (sheet->Type() == SCH_SHEET_T),
wxT( "Sheet label has invalid parent item." ) );
SaveCopyInUndoList( (SCH_ITEM*) sheet, UR_CHANGED );
sheet->RemoveLabel( (SCH_SHEET_PIN*) aItem );
DrawPanel->RefreshDrawingRect( sheet->GetBoundingBox() );
}
else
{
screen->RemoveFromDrawList( DrawStruct );
panel->RefreshDrawingRect( DrawStruct->GetBoundingBox() );
screen->RemoveFromDrawList( aItem );
/* Unlink the structure */
DrawStruct->SetNext( 0 );
DrawStruct->SetBack( 0 ); // Only one struct -> no link
aItem->SetNext( NULL );
aItem->SetBack( NULL ); // Only one struct -> no link
frame->SaveCopyInUndoList( DrawStruct, UR_DELETED );
SaveCopyInUndoList( aItem, UR_DELETED );
DrawPanel->RefreshDrawingRect( aItem->GetBoundingBox() );
}
}
......
......@@ -2,6 +2,8 @@
#ifndef __PROTOS_H__
#define __PROTOS_H__
#include "class_undoredo_container.h"
#include "colors.h"
......@@ -50,13 +52,9 @@ void SnapLibItemPoint( int OrigX,
bool LibItemInBox( int x1, int y1, int x2, int y2, SCH_COMPONENT* DrawLibItem );
/************/
/* BLOCK.CPP */
/************/
void DeleteStruct( EDA_DRAW_PANEL* panel, wxDC* DC, SCH_ITEM* DrawStruct );
// operations_on_item_lists.cpp
void DeleteItemsInList( EDA_DRAW_PANEL* panel, PICKED_ITEMS_LIST& aItemsList );
/**
* Function DuplicateStruct
......@@ -75,38 +73,6 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct, bool aClone = false );
SCH_COMPONENT* LocateSmallestComponent( SCH_SCREEN* Screen );
/* function PickStruct:
* Search at location pos
*
* SearchMask = (bitwise OR):
* LIBITEM
* WIREITEM
* BUSITEM
* RACCORDITEM
* JUNCTIONITEM
* DRAWITEM
* TEXTITEM
* LABELITEM
* SHEETITEM
* MARKERITEM
* NOCONNECTITEM
* SEARCH_PINITEM
* SHEETLABELITEM
* FIELDCMPITEM
*
* if EXCLUDE_WIRE_BUS_ENDPOINTS is set, in wire ou bus search and locate,
* start and end points are not included in search
* if WIRE_BUS_ENDPOINTS_ONLY is set, in wire ou bus search and locate,
* only start and end points are included in search
*
*
* Return:
* Pointer to list of pointers to structures if several items are selected.
* Pointer to the structure if only 1 item is selected.
* NULL if no items are selects.
*/
SCH_ITEM* PickStruct( const wxPoint& refpos, SCH_SCREEN* screen, int SearchMask );
/***************/
/* EEREDRAW.CPP */
......@@ -142,14 +108,6 @@ bool ClearProjectDrawList( SCH_SCREEN* FirstWindow, bool confirm_deletion );
* clear the screen datas (filenames ..)
*/
/*************/
/* DELETE.CPP */
/*************/
bool LocateAndDeleteItem( SCH_EDIT_FRAME* frame, wxDC* DC );
void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Window );
void DeleteAllMarkers( int type );
/**************/
/* PINEDIT.CPP */
......
......@@ -447,10 +447,10 @@ void SCH_FIELD::Rotate( wxPoint rotationPoint )
}
bool SCH_FIELD::doHitTest( const wxPoint& aPoint, int aAccuracy ) const
bool SCH_FIELD::doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const
{
// Do not hit test hidden fields.
if( !IsVisible() )
// Do not hit test hidden or empty fields.
if( !(aFilter & FIELD_T) || !IsVisible() || IsVoid() )
return false;
EDA_Rect rect = GetBoundingBox();
......
......@@ -164,7 +164,7 @@ public:
void* aAuxData, wxPoint * aFindLocation );
private:
virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy ) const;
virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy, SCH_FILTER_T aFilter ) const;
virtual bool doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const;
virtual EDA_ITEM* doClone() const;
};
......
This diff is collapsed.
......@@ -204,7 +204,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( item == NULL )
break;
DeleteStruct( DrawPanel, &dc, item );
DeleteItem( item );
screen->SetCurItem( NULL );
m_itemToRepeat = NULL;
screen->TestDanglingEnds( DrawPanel, &dc );
......
......@@ -209,7 +209,7 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem,
if( aItem )
{
itemWrapper.m_PickedItemType = aItem->Type();
itemWrapper.m_PickerFlags = aItem->m_Flags;
itemWrapper.m_PickerFlags = aItem->GetFlags();
}
switch( aCommandType )
......@@ -329,12 +329,14 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
// complex command
for( int ii = aList->GetCount() - 1; ii >= 0; ii-- )
{
ITEM_PICKER itemWrapper = aList->GetItemWrapper( ii );
item = (SCH_ITEM*) itemWrapper.m_PickedItem;
item = (SCH_ITEM*) aList->GetPickedItem( ii );
if( item )
item->m_Flags = 0;
SCH_ITEM* image = (SCH_ITEM*) itemWrapper.m_Link;
switch( itemWrapper.m_UndoRedoStatus )
item->ClearFlags();
SCH_ITEM* image = (SCH_ITEM*) aList->GetPickedItemLink( ii );
switch( aList->GetPickedItemStatus( ii ) )
{
case UR_CHANGED: /* Exchange old and new data for each item */
SwapData( item, image );
......@@ -352,10 +354,10 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
break;
case UR_MOVED:
item->m_Flags = aList->GetPickerFlags( ii );
item->Move( aRedoCommand ?
aList->m_TransformPoint : -aList->m_TransformPoint );
item->m_Flags = 0;
item->ClearFlags();
item->SetFlags( aList->GetPickerFlags( ii ) );
item->Move( aRedoCommand ? aList->m_TransformPoint : -aList->m_TransformPoint );
item->ClearFlags();
break;
case UR_MIRRORED_Y:
......@@ -385,12 +387,13 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
/* Exchange the current wires and the old wires */
alt_item = GetScreen()->ExtractWires( false );
aList->SetPickedItem( alt_item, ii );
while( item )
{
SCH_ITEM* nextitem = item->Next();
item->SetNext( GetScreen()->GetDrawItems() );
GetScreen()->SetDrawItems( item );
item->m_Flags = 0;
item->ClearFlags();
item = nextitem;
}
......@@ -400,7 +403,7 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
{
wxString msg;
msg.Printf( wxT( "PutDataInPreviousState() error (unknown code %X)" ),
itemWrapper.m_UndoRedoStatus );
aList->GetPickedItemStatus( ii ) );
wxMessageBox( msg );
}
break;
......
......@@ -244,36 +244,3 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::Import_PinSheet( SCH_SHEET* Sheet, wxDC* DC )
return NewSheetLabel;
}
/*
* Remove sheet label.
*
* This sheet label can not be put in a pile "undelete" because it would not
* Possible to link it back it's 'SCH_SHEET' parent.
*/
void SCH_EDIT_FRAME::DeleteSheetLabel( bool aRedraw, SCH_SHEET_PIN* aSheetLabelToDel )
{
SCH_SHEET* parent = (SCH_SHEET*) aSheetLabelToDel->GetParent();
wxASSERT( parent );
wxASSERT( parent->Type() == SCH_SHEET_T );
#if 0 && defined(DEBUG)
std::cout << "\n\nbefore deleting:\n" << std::flush;
parent->Show( 0, std::cout );
std::cout << "\n\n\n" << std::flush;
#endif
parent->RemoveLabel( aSheetLabelToDel );
if( aRedraw )
DrawPanel->RefreshDrawingRect( parent->GetBoundingBox() );
#if 0 && defined(DEBUG)
std::cout << "\n\nafter deleting:\n" << std::flush;
parent->Show( 0, std::cout );
std::cout << "~after deleting\n\n" << std::flush;
#endif
}
......@@ -14,6 +14,7 @@ class LIB_PIN;
class SCH_COMPONENT;
class SCH_SHEET_PATH;
class SCH_SHEET_PIN;
class SCH_LINE;
/* Max number of sheets in a hierarchy project: */
......@@ -94,6 +95,29 @@ public:
*/
int GetItems( const wxPoint& aPosition, SCH_ITEMS& aItemList ) const;
/**
* Function FindItem
* checks \a aPosition within a distance of \a aAccuracy for items of type \a aFilter.
* @param aPosition Position in drawing units.
* @param aAccuracy The maximum distance within \a Position to check for an item.
* @param aFilter The type of items to find.
* @return The item found that meets the search criteria or NULL if none found.
*/
SCH_ITEM* GetItem( const wxPoint& aPosition, int aAccuracy = 0,
int aFilter = NO_FILTER_T ) const;
/**
* Function GetItems
* checks \a aPosition within a distance of \a aAccuracy for items of type \a aFilter.
* @param aPosition Position in drawing units.
* @param aItemList The list to add found items to.
* @param aAccuracy The maximum distance within \a Position to check for an item.
* @param aFilter The type of items to find.
* @return The number of items found that meets the search criteria.
*/
int GetItems( const wxPoint& aPosition, PICKED_ITEMS_LIST& aItemList, int aAccuracy = 0,
int aFilter = NO_FILTER_T ) const;
void Place( SCH_EDIT_FRAME* frame, wxDC* DC ) { };
/**
......@@ -113,6 +137,15 @@ public:
*/
void RemoveFromDrawList( SCH_ITEM* aItem );
/**
* Function DeleteItem
* removes \a aItem from the linked list and deletes the object. If \a aItem is
* is a schematic sheet label, it is removed from the screen associated with the
* sheet that contains the label to be deleted.
* @param aItem The schematic object to be deleted from the screen.
*/
void DeleteItem( SCH_ITEM* aItem );
bool CheckIfOnDrawList( SCH_ITEM* st );
void AddToDrawList( SCH_ITEM* st );
......@@ -149,6 +182,15 @@ public:
*/
void ReplaceWires( SCH_ITEM* aWireList );
/**
* Functions MarkConnections
* add all wires and junctions connected to \a aSegment which are not connected any
* component pin to \a aItemList.
* @param aSegment The segment to test for connections.
* @param aItemList List of items to add connections.
*/
void MarkConnections( SCH_LINE* aSegment );
/**
* Function BreakSegment
* checks every wire and bus for a intersection at \a aPoint and break into two segments
......@@ -227,7 +269,7 @@ public:
* @return The pin item if found, otherwise NULL.
*/
LIB_PIN* GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponent = NULL,
bool aEndPointOnly = false );
bool aEndPointOnly = false ) const;
/**
* Function GetSheetLabel
......@@ -268,6 +310,7 @@ public:
int UpdatePickList();
virtual void AddItem( SCH_ITEM* aItem ) { BASE_SCREEN::AddItem( (EDA_ITEM*) aItem ); }
virtual void InsertItem( EDA_ITEMS::iterator aIter, SCH_ITEM* aItem )
{
BASE_SCREEN::InsertItem( aIter, (EDA_ITEM*) aItem );
......@@ -323,9 +366,17 @@ public:
*/
void SetDate( const wxString& aDate );
/**
* Function DeleteAllMarkers
* deletes all electronic rules check markers of \a aMarkerType from all the screens in
* the list.
* @param aType Type of markers to be deleted.
*/
void DeleteAllMarkers( int aMarkerType );
private:
void AddScreenToList( SCH_SCREEN* aScreen );
void BuildScreenList( EDA_ITEM* aItem );
void AddScreenToList( SCH_SCREEN* aScreen );
void BuildScreenList( EDA_ITEM* aItem );
};
#endif /* CLASS_SCREEN_H */
This diff is collapsed.
......@@ -123,7 +123,6 @@ public:
*/
static wxString GetDefaultFieldName( int aFieldNdx );
/**
* Function AddTemplateFieldName
* inserts or appends a wanted symbol field name into the fieldnames
......@@ -208,6 +207,26 @@ public:
SCH_ITEM* LocateAndShowItem( const wxPoint& aPosition, bool aIncludePin = true );
SCH_ITEM* LocateItem( const wxPoint& aPosition, bool aIncludePin );
/**
* Function DeleteItemAtCrossHair
* delete the item found under the cross hair.
* <p>
* If more than one item found, the priority order is:
* <ol>
* Marker
* Junction
* No connect
* Wire or bus
* Graphic item
* Text
* Component
* Sheet
* </ol></p>
* @param aDC The device context to update if and item is deleted.
* @return True if an item was deleted.
*/
bool DeleteItemAtCrossHair( wxDC* DC );
/**
* Function FillFootprintFieldForAllInstancesofComponent
* searches for component "aReference", and places a Footprint in
......@@ -508,8 +527,12 @@ private:
SCH_SHEET_PIN* Import_PinSheet( SCH_SHEET* Sheet, wxDC* DC );
public:
void DeleteSheetLabel( bool aRedraw,
SCH_SHEET_PIN* aSheetLabelToDel );
/**
* Function DeleteItem
* removes \a aItem from the current screen and saves it in the undo list.
* @param aItem The item to remove from the current screen.
*/
void DeleteItem( SCH_ITEM* aItem );
int GetLabelIncrement() const { return m_repeatLabelDelta; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment