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 @@ ...@@ -2,6 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application. * 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) 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. * Copyright (C) 2009 Kicad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -26,7 +27,6 @@ ...@@ -26,7 +27,6 @@
#include "common.h" #include "common.h"
#include "base_struct.h" #include "base_struct.h"
//#include "sch_item_struct.h"
#include "base_struct.h" #include "base_struct.h"
#include "class_undoredo_container.h" #include "class_undoredo_container.h"
...@@ -51,20 +51,12 @@ PICKED_ITEMS_LIST::~PICKED_ITEMS_LIST() ...@@ -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 ) void PICKED_ITEMS_LIST::PushItem( ITEM_PICKER& aItem )
{ {
m_ItemsList.push_back( 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 PICKED_ITEMS_LIST::PopItem()
{ {
ITEM_PICKER item; ITEM_PICKER item;
...@@ -74,25 +66,29 @@ ITEM_PICKER PICKED_ITEMS_LIST::PopItem() ...@@ -74,25 +66,29 @@ ITEM_PICKER PICKED_ITEMS_LIST::PopItem()
item = m_ItemsList.back(); item = m_ItemsList.back();
m_ItemsList.pop_back(); m_ItemsList.pop_back();
} }
return item; return item;
} }
/** bool PICKED_ITEMS_LIST::ContainsItem( EDA_ITEM* aItem ) const
* Function ClearItemsList {
* delete only the list of pickers, NOT the picked data itself 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() void PICKED_ITEMS_LIST::ClearItemsList()
{ {
m_ItemsList.clear(); 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() void PICKED_ITEMS_LIST::ClearListAndDeleteItems()
{ {
bool show_error_message = true; bool show_error_message = true;
...@@ -108,13 +104,14 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems() ...@@ -108,13 +104,14 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems()
case UR_UNSPECIFIED: case UR_UNSPECIFIED:
if( show_error_message ) if( show_error_message )
wxMessageBox( wxT( "ClearUndoORRedoList() error: UR_UNSPECIFIED command type" ) ); wxMessageBox( wxT( "ClearUndoORRedoList() error: UR_UNSPECIFIED command type" ) );
show_error_message = false; show_error_message = false;
break; break;
case UR_WIRE_IMAGE: case UR_WIRE_IMAGE:
{ {
// Specific to eeschema: a linked list of wires is stored. // Specific to eeschema: a linked list of wires is stored. The wrapper picks only
// the wrapper picks only the first item (head of list), and is owner of all picked items // the first item (head of list), and is owner of all picked items.
EDA_ITEM* item = wrapper.m_PickedItem; EDA_ITEM* item = wrapper.m_PickedItem;
while( item ) while( item )
...@@ -144,9 +141,9 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems() ...@@ -144,9 +141,9 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems()
case UR_LIBEDIT: /* Libedit save always a copy of the current item case UR_LIBEDIT: /* Libedit save always a copy of the current item
* So, the picker is always owner of the picked item * So, the picker is always owner of the picked item
*/ */
case UR_MODEDIT: /* Specific to the module editor case UR_MODEDIT: /* Specific to the module editor (modedit creates a full
* (modedit creates a full copy of the current module when changed), * copy of the current module when changed),
* and the picker is owner of this item * and the picker is owner of this item
*/ */
delete wrapper.m_PickedItem; delete wrapper.m_PickedItem;
break; break;
...@@ -164,13 +161,6 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems() ...@@ -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 PICKED_ITEMS_LIST::GetItemWrapper( unsigned int aIdx )
{ {
ITEM_PICKER picker; ITEM_PICKER picker;
...@@ -182,11 +172,6 @@ ITEM_PICKER PICKED_ITEMS_LIST::GetItemWrapper( unsigned int aIdx ) ...@@ -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 ) EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItem( unsigned int aIdx )
{ {
if( aIdx < m_ItemsList.size() ) if( aIdx < m_ItemsList.size() )
...@@ -196,11 +181,6 @@ EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItem( unsigned int aIdx ) ...@@ -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 ) EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItemLink( unsigned int aIdx )
{ {
if( aIdx < m_ItemsList.size() ) if( aIdx < m_ItemsList.size() )
...@@ -210,12 +190,6 @@ EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItemLink( unsigned int aIdx ) ...@@ -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 ) UndoRedoOpType PICKED_ITEMS_LIST::GetPickedItemStatus( unsigned int aIdx )
{ {
if( aIdx < m_ItemsList.size() ) if( aIdx < m_ItemsList.size() )
...@@ -224,12 +198,7 @@ UndoRedoOpType PICKED_ITEMS_LIST::GetPickedItemStatus( unsigned int aIdx ) ...@@ -224,12 +198,7 @@ UndoRedoOpType PICKED_ITEMS_LIST::GetPickedItemStatus( unsigned int aIdx )
return UR_UNSPECIFIED; 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 ) int PICKED_ITEMS_LIST::GetPickerFlags( unsigned aIdx )
{ {
if( aIdx < m_ItemsList.size() ) if( aIdx < m_ItemsList.size() )
...@@ -238,12 +207,7 @@ int PICKED_ITEMS_LIST::GetPickerFlags( unsigned aIdx ) ...@@ -238,12 +207,7 @@ int PICKED_ITEMS_LIST::GetPickerFlags( unsigned aIdx )
return 0; 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 ) bool PICKED_ITEMS_LIST::SetPickedItem( EDA_ITEM* aItem, unsigned aIdx )
{ {
if( aIdx < m_ItemsList.size() ) if( aIdx < m_ItemsList.size() )
...@@ -256,13 +220,6 @@ bool PICKED_ITEMS_LIST::SetPickedItem( EDA_ITEM* aItem, unsigned aIdx ) ...@@ -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 ) bool PICKED_ITEMS_LIST::SetPickedItemLink( EDA_ITEM* aLink, unsigned aIdx )
{ {
if( aIdx < m_ItemsList.size() ) if( aIdx < m_ItemsList.size() )
...@@ -275,13 +232,6 @@ bool PICKED_ITEMS_LIST::SetPickedItemLink( EDA_ITEM* aLink, unsigned aIdx ) ...@@ -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 ) bool PICKED_ITEMS_LIST::SetPickedItem( EDA_ITEM* aItem, UndoRedoOpType aStatus, unsigned aIdx )
{ {
if( aIdx < m_ItemsList.size() ) if( aIdx < m_ItemsList.size() )
...@@ -295,13 +245,6 @@ bool PICKED_ITEMS_LIST::SetPickedItem( EDA_ITEM* aItem, UndoRedoOpType aStatus, ...@@ -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 ) bool PICKED_ITEMS_LIST::SetPickedItemStatus( UndoRedoOpType aStatus, unsigned aIdx )
{ {
if( aIdx < m_ItemsList.size() ) if( aIdx < m_ItemsList.size() )
...@@ -312,13 +255,8 @@ bool PICKED_ITEMS_LIST::SetPickedItemStatus( UndoRedoOpType aStatus, unsigned aI ...@@ -312,13 +255,8 @@ bool PICKED_ITEMS_LIST::SetPickedItemStatus( UndoRedoOpType aStatus, unsigned aI
else else
return false; 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 ) bool PICKED_ITEMS_LIST::SetPickerFlags( int aFlags, unsigned aIdx )
{ {
if( aIdx < m_ItemsList.size() ) if( aIdx < m_ItemsList.size() )
...@@ -331,12 +269,6 @@ bool PICKED_ITEMS_LIST::SetPickerFlags( int aFlags, unsigned aIdx ) ...@@ -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 ) bool PICKED_ITEMS_LIST::RemovePicker( unsigned aIdx )
{ {
if( aIdx >= m_ItemsList.size() ) if( aIdx >= m_ItemsList.size() )
...@@ -346,24 +278,12 @@ bool PICKED_ITEMS_LIST::RemovePicker( unsigned aIdx ) ...@@ -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 ) void PICKED_ITEMS_LIST::CopyList( const PICKED_ITEMS_LIST& aSource )
{ {
m_ItemsList = aSource.m_ItemsList; // Vector's copy 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() void PICKED_ITEMS_LIST::ReversePickersListOrder()
{ {
std::vector <ITEM_PICKER> tmp; std::vector <ITEM_PICKER> tmp;
......
...@@ -33,7 +33,6 @@ extern void MoveItemsInList( PICKED_ITEMS_LIST& aItemsList, const wxPoint aMoveV ...@@ -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 RotateListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& Center );
extern void Mirror_X_ListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& aMirrorPoint ); extern void Mirror_X_ListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& aMirrorPoint );
extern void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& Center ); 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, extern void DuplicateItemsInList( SCH_SCREEN* screen,
PICKED_ITEMS_LIST& aItemsList, PICKED_ITEMS_LIST& aItemsList,
const wxPoint aMoveVector ); const wxPoint aMoveVector );
...@@ -522,22 +521,19 @@ void SCH_EDIT_FRAME::copyBlockItems( PICKED_ITEMS_LIST& aItemsList ) ...@@ -522,22 +521,19 @@ void SCH_EDIT_FRAME::copyBlockItems( PICKED_ITEMS_LIST& aItemsList )
{ {
m_blockItems.ClearListAndDeleteItems(); // delete previous saved list, if exists 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++ ) for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{ {
// Clear m_Flag member of selected items: // 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. */ /* Make a copy of the original picked item. */
SCH_ITEM* DrawStructCopy = DuplicateStruct( (SCH_ITEM*) aItemsList.GetPickedItem( ii ) ); SCH_ITEM* copy = DuplicateStruct( (SCH_ITEM*) aItemsList.GetPickedItem( ii ) );
DrawStructCopy->SetParent( NULL ); copy->SetParent( NULL );
item.m_PickedItem = DrawStructCopy;
// 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 ); m_blockItems.PushItem( item );
} }
} }
...@@ -559,13 +555,12 @@ void SCH_EDIT_FRAME::PasteListOfItems( wxDC* DC ) ...@@ -559,13 +555,12 @@ void SCH_EDIT_FRAME::PasteListOfItems( wxDC* DC )
PICKED_ITEMS_LIST picklist; 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++ ) for( unsigned ii = 0; ii < m_blockItems.GetCount(); ii++ )
{ {
Struct = DuplicateStruct( (SCH_ITEM*) m_blockItems.m_ItemsSelection.GetPickedItem( 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 ); picklist.PushItem( picker );
// Clear annotation and init new time stamp for the new components: // Clear annotation and init new time stamp for the new components:
...@@ -574,6 +569,7 @@ void SCH_EDIT_FRAME::PasteListOfItems( wxDC* DC ) ...@@ -574,6 +569,7 @@ void SCH_EDIT_FRAME::PasteListOfItems( wxDC* DC )
( (SCH_COMPONENT*) Struct )->m_TimeStamp = GetTimeStamp(); ( (SCH_COMPONENT*) Struct )->m_TimeStamp = GetTimeStamp();
( (SCH_COMPONENT*) Struct )->ClearAnnotation( NULL ); ( (SCH_COMPONENT*) Struct )->ClearAnnotation( NULL );
} }
SetSchItemParent( Struct, GetScreen() ); SetSchItemParent( Struct, GetScreen() );
Struct->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); Struct->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
Struct->SetNext( GetScreen()->GetDrawItems() ); Struct->SetNext( GetScreen()->GetDrawItems() );
...@@ -584,7 +580,7 @@ void SCH_EDIT_FRAME::PasteListOfItems( wxDC* DC ) ...@@ -584,7 +580,7 @@ void SCH_EDIT_FRAME::PasteListOfItems( wxDC* DC )
MoveItemsInList( picklist, GetScreen()->m_BlockLocate.m_MoveVector ); MoveItemsInList( picklist, GetScreen()->m_BlockLocate.m_MoveVector );
/* clear .m_Flags member for all items */ // Clear flags for all items.
GetScreen()->ClearDrawingState(); GetScreen()->ClearDrawingState();
OnModify(); OnModify();
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
static void AbortCreateNewLine( EDA_DRAW_PANEL* Panel, wxDC* DC ); static void AbortCreateNewLine( EDA_DRAW_PANEL* Panel, wxDC* DC );
static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer ); 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 ); static void ComputeBreakPoint( SCH_LINE* segment, const wxPoint& new_pos );
SCH_ITEM* s_OldWiresList; SCH_ITEM* s_OldWiresList;
...@@ -92,7 +91,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type ) ...@@ -92,7 +91,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
SCH_LINE* oldsegment, * newsegment, * nextsegment; SCH_LINE* oldsegment, * newsegment, * nextsegment;
wxPoint cursorpos = GetScreen()->GetCrossHairPosition(); wxPoint cursorpos = GetScreen()->GetCrossHairPosition();
if( GetScreen()->GetCurItem() && (GetScreen()->GetCurItem()->m_Flags == 0) ) if( GetScreen()->GetCurItem() && (GetScreen()->GetCurItem()->GetFlags() == 0) )
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
if( GetScreen()->GetCurItem() ) if( GetScreen()->GetCurItem() )
...@@ -134,12 +133,12 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type ) ...@@ -134,12 +133,12 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
break; 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 if( g_HVLines ) // We need 2 segments to go from a given start pin to an end point
{ {
nextsegment = new SCH_LINE( *newsegment ); nextsegment = new SCH_LINE( *newsegment );
nextsegment->m_Flags = IS_NEW; nextsegment->SetFlags( IS_NEW );
newsegment->SetNext( nextsegment ); newsegment->SetNext( nextsegment );
nextsegment->SetBack( newsegment ); nextsegment->SetBack( newsegment );
} }
...@@ -199,8 +198,9 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type ) ...@@ -199,8 +198,9 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
} }
newsegment->m_End = cursorpos; newsegment->m_End = cursorpos;
oldsegment->m_Flags = SELECTED; oldsegment->ClearFlags( IS_NEW );
newsegment->m_Flags = IS_NEW; oldsegment->SetFlags( SELECTED );
newsegment->SetFlags( IS_NEW );
GetScreen()->SetCurItem( newsegment ); GetScreen()->SetCurItem( newsegment );
DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false ); DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false );
...@@ -210,7 +210,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type ) ...@@ -210,7 +210,7 @@ void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type )
* (tested when the connection will be finished)*/ * (tested when the connection will be finished)*/
if( oldsegment->m_Start == s_ConnexionStartPoint ) if( oldsegment->m_Start == s_ConnexionStartPoint )
{ {
if( IsJunctionNeeded( this, s_ConnexionStartPoint ) ) if( GetScreen()->IsJunctionNeeded( s_ConnexionStartPoint ) )
AddJunction( DC, s_ConnexionStartPoint ); AddJunction( DC, s_ConnexionStartPoint );
} }
} }
...@@ -291,28 +291,28 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC ) ...@@ -291,28 +291,28 @@ void SCH_EDIT_FRAME::EndSegment( wxDC* DC )
while( segment ) while( segment )
{ {
if( segment->m_Flags ) if( segment->GetFlags() )
{ {
if( !m_itemToRepeat ) if( !m_itemToRepeat )
m_itemToRepeat = segment; m_itemToRepeat = segment;
} }
segment->m_Flags = 0; segment->ClearFlags();
segment = segment->Next(); segment = segment->Next();
} }
// Automatic place of a junction on the end point, if needed // Automatic place of a junction on the end point, if needed
if( lastsegment ) if( lastsegment )
{ {
if( IsJunctionNeeded( this, end_point ) ) if( GetScreen()->IsJunctionNeeded( end_point ) )
AddJunction( DC, 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 ); AddJunction( DC, alt_end_point );
} }
/* Automatic place of a junction on the start point if necessary because /* Automatic place of a junction on the start point if necessary because
* the cleanup can suppress intermediate points by merging wire segments */ * the cleanup can suppress intermediate points by merging wire segments */
if( IsJunctionNeeded( this, s_ConnexionStartPoint ) ) if( GetScreen()->IsJunctionNeeded( s_ConnexionStartPoint ) )
AddJunction( DC, s_ConnexionStartPoint ); AddJunction( DC, s_ConnexionStartPoint );
GetScreen()->TestDanglingEnds( DrawPanel, DC ); GetScreen()->TestDanglingEnds( DrawPanel, DC );
...@@ -500,14 +500,8 @@ static void AbortCreateNewLine( EDA_DRAW_PANEL* Panel, wxDC* DC ) ...@@ -500,14 +500,8 @@ static void AbortCreateNewLine( EDA_DRAW_PANEL* Panel, wxDC* DC )
parent->SetRepeatItem( NULL ); parent->SetRepeatItem( NULL );
} }
/* Clear m_Flags which is used in edit functions: */ // Clear flags used in edit functions.
SCH_ITEM* item = screen->GetDrawItems(); screen->ClearDrawingState();
while( item )
{
item->m_Flags = 0;
item = item->Next();
}
} }
...@@ -526,7 +520,7 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC ) ...@@ -526,7 +520,7 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
{ {
wxPoint pos = GetScreen()->GetCrossHairPosition() - wxPoint pos = GetScreen()->GetCrossHairPosition() -
( (SCH_COMPONENT*) m_itemToRepeat )->m_Pos; ( (SCH_COMPONENT*) m_itemToRepeat )->m_Pos;
m_itemToRepeat->m_Flags = IS_NEW; m_itemToRepeat->SetFlags( IS_NEW );
( (SCH_COMPONENT*) m_itemToRepeat )->m_TimeStamp = GetTimeStamp(); ( (SCH_COMPONENT*) m_itemToRepeat )->m_TimeStamp = GetTimeStamp();
m_itemToRepeat->Move( pos ); m_itemToRepeat->Move( pos );
m_itemToRepeat->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode ); m_itemToRepeat->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
...@@ -546,7 +540,7 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC ) ...@@ -546,7 +540,7 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
GetScreen()->TestDanglingEnds(); GetScreen()->TestDanglingEnds();
m_itemToRepeat->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); m_itemToRepeat->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
SaveCopyInUndoList( m_itemToRepeat, UR_NEW ); 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 ) ...@@ -601,7 +595,7 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
switch( layer ) switch( layer )
{ {
case LAYER_BUS: case LAYER_BUS:
item = PickStruct( pos, screen, BUS_T ); item = screen->GetItem( pos, 0, BUS_T );
if( item ) if( item )
return true; return true;
...@@ -618,13 +612,14 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer ) ...@@ -618,13 +612,14 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
break; break;
case LAYER_NOTES: case LAYER_NOTES:
item = PickStruct( pos, screen, DRAW_ITEM_T ); item = screen->GetItem( pos, 0, DRAW_ITEM_T );
if( item ) if( item )
return true; return true;
break; break;
case LAYER_WIRE: 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 ) if( item )
return true; return true;
...@@ -643,12 +638,12 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer ) ...@@ -643,12 +638,12 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
return true; return true;
} }
item = PickStruct( pos, screen, WIRE_T ); item = screen->GetItem( pos, 0, WIRE_T );
if( item ) if( item )
return true; return true;
item = PickStruct( pos, screen, LABEL_T ); item = screen->GetItem( pos, 0, LABEL_T );
if( item && (item->Type() != SCH_TEXT_T) if( item && (item->Type() != SCH_TEXT_T)
&& ( ( (SCH_GLOBALLABEL*) item )->m_Pos.x == pos.x ) && ( ( (SCH_GLOBALLABEL*) item )->m_Pos.x == pos.x )
&& ( ( (SCH_GLOBALLABEL*) item )->m_Pos.y == pos.y ) ) && ( ( (SCH_GLOBALLABEL*) item )->m_Pos.y == pos.y ) )
...@@ -672,29 +667,3 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer ) ...@@ -672,29 +667,3 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
return false; 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 ...@@ -120,7 +120,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin
wxString Text; wxString Text;
wxString msg; wxString msg;
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), MARKER_T ); item = GetScreen()->GetItem( aPosition, 0, MARKER_T );
if( item ) if( item )
{ {
...@@ -128,7 +128,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin ...@@ -128,7 +128,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin
return item; return item;
} }
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), NO_CONNECT_T ); item = GetScreen()->GetItem( aPosition, 0, NO_CONNECT_T );
if( item ) if( item )
{ {
...@@ -136,7 +136,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin ...@@ -136,7 +136,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin
return item; return item;
} }
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), JUNCTION_T ); item = GetScreen()->GetItem( aPosition, 0, JUNCTION_T );
if( item ) if( item )
{ {
...@@ -144,7 +144,8 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin ...@@ -144,7 +144,8 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin
return item; 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 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 ...@@ -164,17 +165,20 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin
return item; return item;
} }
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), DRAW_ITEM_T ); item = GetScreen()->GetItem( aPosition, 0, DRAW_ITEM_T );
if( item ) if( item )
{ {
ClearMsgPanel(); ClearMsgPanel();
return item; return item;
} }
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), FIELD_T ); item = GetScreen()->GetItem( aPosition, 0, FIELD_T );
if( item ) if( item )
{ {
wxASSERT( item->Type() == SCH_FIELD_T );
SCH_FIELD* Field = (SCH_FIELD*) item; SCH_FIELD* Field = (SCH_FIELD*) item;
LibItem = (SCH_COMPONENT*) Field->GetParent(); LibItem = (SCH_COMPONENT*) Field->GetParent();
LibItem->DisplayInfo( this ); LibItem->DisplayInfo( this );
...@@ -182,7 +186,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin ...@@ -182,7 +186,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin
return item; return item;
} }
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), LABEL_T | TEXT_T ); item = GetScreen()->GetItem( aPosition, 0, LABEL_T | TEXT_T );
if( item ) if( item )
{ {
...@@ -204,7 +208,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin ...@@ -204,7 +208,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin
return LibItem; return LibItem;
} }
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), COMPONENT_T ); item = GetScreen()->GetItem( aPosition, 0, COMPONENT_T );
if( item ) if( item )
{ {
...@@ -214,7 +218,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin ...@@ -214,7 +218,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin
return item; return item;
} }
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), SHEET_T ); item = GetScreen()->GetItem( aPosition, 0, SHEET_T );
if( item ) if( item )
{ {
...@@ -222,7 +226,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin ...@@ -222,7 +226,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, bool aIncludePin
return item; return item;
} }
item = (SCH_ITEM*) PickStruct( aPosition, GetScreen(), NO_FILTER_T ); item = GetScreen()->GetItem( aPosition );
if( item ) if( item )
return item; return item;
...@@ -295,7 +299,7 @@ void SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH ...@@ -295,7 +299,7 @@ void SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
if( aHotKey ) if( aHotKey )
{ {
if( screen->GetCurItem() && screen->GetCurItem()->m_Flags ) if( screen->GetCurItem() && screen->GetCurItem()->GetFlags() )
OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() ); OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() );
else else
OnHotKey( aDC, aHotKey, aPosition, NULL ); OnHotKey( aDC, aHotKey, aPosition, NULL );
...@@ -368,7 +372,7 @@ void LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH ...@@ -368,7 +372,7 @@ void LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
if( aHotKey ) if( aHotKey )
{ {
if( screen->GetCurItem() && screen->GetCurItem()->m_Flags ) if( screen->GetCurItem() && screen->GetCurItem()->GetFlags() )
OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() ); OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() );
else else
OnHotKey( aDC, aHotKey, aPosition, NULL ); OnHotKey( aDC, aHotKey, aPosition, NULL );
...@@ -441,7 +445,7 @@ void LIB_VIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH ...@@ -441,7 +445,7 @@ void LIB_VIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
if( aHotKey ) if( aHotKey )
{ {
if( screen->GetCurItem() && screen->GetCurItem()->m_Flags ) if( screen->GetCurItem() && screen->GetCurItem()->GetFlags() )
OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() ); OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() );
else else
OnHotKey( aDC, aHotKey, aPosition, NULL ); OnHotKey( aDC, aHotKey, aPosition, NULL );
......
This diff is collapsed.
...@@ -85,7 +85,8 @@ void DIALOG_ERC::OnEraseDrcMarkersClick( wxCommandEvent& event ) ...@@ -85,7 +85,8 @@ void DIALOG_ERC::OnEraseDrcMarkersClick( wxCommandEvent& event )
{ {
/* Delete the old ERC markers, over the whole hierarchy /* Delete the old ERC markers, over the whole hierarchy
*/ */
DeleteAllMarkers( MARK_ERC ); SCH_SCREENS ScreenList;
ScreenList.DeleteAllMarkers( MARK_ERC );
m_MarkersList->ClearList(); m_MarkersList->ClearList();
m_Parent->DrawPanel->Refresh(); m_Parent->DrawPanel->Refresh();
} }
...@@ -427,14 +428,13 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) ...@@ -427,14 +428,13 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
} }
/* Erase all DRC markers */ /* Erase all DRC markers */
DeleteAllMarkers( MARK_ERC ); SCH_SCREENS ScreenList;
ScreenList.DeleteAllMarkers( MARK_ERC );
g_EESchemaVar.NbErrorErc = 0; g_EESchemaVar.NbErrorErc = 0;
g_EESchemaVar.NbWarningErc = 0; g_EESchemaVar.NbWarningErc = 0;
/* Cleanup the entire hierarchy */
SCH_SCREENS ScreenList;
for( SCH_SCREEN* Screen = ScreenList.GetFirst(); for( SCH_SCREEN* Screen = ScreenList.GetFirst();
Screen != NULL; Screen != NULL;
Screen = ScreenList.GetNext() ) Screen = ScreenList.GetNext() )
......
...@@ -79,8 +79,8 @@ void SCH_EDIT_FRAME::StartMoveTexte( SCH_TEXT* aTextItem, wxDC* aDC ) ...@@ -79,8 +79,8 @@ void SCH_EDIT_FRAME::StartMoveTexte( SCH_TEXT* aTextItem, wxDC* aDC )
void SCH_EDIT_FRAME::ChangeTextOrient( SCH_TEXT* aTextItem, wxDC* aDC ) void SCH_EDIT_FRAME::ChangeTextOrient( SCH_TEXT* aTextItem, wxDC* aDC )
{ {
if( aTextItem == NULL ) if( aTextItem == NULL )
aTextItem = (SCH_TEXT*) PickStruct( GetScreen()->GetCrossHairPosition(), aTextItem = (SCH_TEXT*) GetScreen()->GetItem( GetScreen()->GetCrossHairPosition(), 0,
GetScreen(), TEXT_T | LABEL_T ); TEXT_T | LABEL_T );
if( aTextItem == NULL ) if( aTextItem == NULL )
return; return;
...@@ -348,7 +348,7 @@ void SCH_EDIT_FRAME::OnConvertTextType( wxCommandEvent& aEvent ) ...@@ -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 if( (flags & IS_NEW) == 0 ) // Remove old text from current list and save it in undo list
{ {
text->ClearFlags(); 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 ); GetScreen()->SetCurItem( NULL );
m_itemToRepeat = NULL; m_itemToRepeat = NULL;
} }
......
...@@ -265,7 +265,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, ...@@ -265,7 +265,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
SCH_SCREEN* screen = GetScreen(); SCH_SCREEN* screen = GetScreen();
// itemInEdit == false means no item currently edited. We can ask for editing a new item // 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 // 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 // We can change active tool and ask for editing a new item
bool notBusy = (!itemInEdit) && (screen->m_BlockLocate.m_State == STATE_NO_BLOCK); 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, ...@@ -342,7 +342,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
case HK_DELETE: case HK_DELETE:
if( notBusy) if( notBusy)
{ {
LocateAndDeleteItem( this, aDC ); DeleteItemAtCrossHair( aDC );
OnModify(); OnModify();
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
GetScreen()->TestDanglingEnds( DrawPanel, aDC ); GetScreen()->TestDanglingEnds( DrawPanel, aDC );
...@@ -350,7 +350,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, ...@@ -350,7 +350,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
break; break;
case HK_REPEAT_LAST: case HK_REPEAT_LAST:
if( notBusy && m_itemToRepeat && ( m_itemToRepeat->m_Flags == 0 ) ) if( notBusy && m_itemToRepeat && ( m_itemToRepeat->GetFlags() == 0 ) )
RepeatDrawItem( aDC ); RepeatDrawItem( aDC );
break; break;
...@@ -701,7 +701,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, ...@@ -701,7 +701,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
if( aItem->Type() == SCH_JUNCTION_T ) if( aItem->Type() == SCH_JUNCTION_T )
{ {
// If it's a junction, pick the underlying wire instead // 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 ) if( aItem == NULL )
...@@ -716,7 +716,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, ...@@ -716,7 +716,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
break; break;
} }
if( aItem && (aItem->m_Flags == 0) ) if( aItem && (aItem->GetFlags() == 0) )
{ {
GetScreen()->SetCurItem( (SCH_ITEM*) aItem ); GetScreen()->SetCurItem( (SCH_ITEM*) aItem );
...@@ -777,8 +777,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, ...@@ -777,8 +777,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
if( aItem == NULL ) if( aItem == NULL )
{ {
aItem = PickStruct( GetScreen()->GetCrossHairPosition(), GetScreen(), aItem = screen->GetItem( screen->GetCrossHairPosition(), 0,
COMPONENT_T | TEXT_T | LABEL_T | SHEET_T ); COMPONENT_T | TEXT_T | LABEL_T | SHEET_T );
if( aItem == NULL ) if( aItem == NULL )
break; break;
...@@ -857,7 +857,7 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, ...@@ -857,7 +857,7 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
cmd.SetEventObject( this ); cmd.SetEventObject( this );
bool itemInEdit = GetScreen()->GetCurItem() && GetScreen()->GetCurItem()->m_Flags; bool itemInEdit = GetScreen()->GetCurItem() && GetScreen()->GetCurItem()->GetFlags();
if( aHotKey == 0 ) if( aHotKey == 0 )
return; return;
...@@ -932,8 +932,8 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, ...@@ -932,8 +932,8 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
break; break;
case HK_REPEAT_LAST: case HK_REPEAT_LAST:
if( m_lastDrawItem && (m_lastDrawItem->m_Flags == 0) if( m_lastDrawItem && (m_lastDrawItem->GetFlags() == 0)
&& ( m_lastDrawItem->Type() == LIB_PIN_T ) ) && ( m_lastDrawItem->Type() == LIB_PIN_T ) )
RepeatPinItem( aDC, (LIB_PIN*) m_lastDrawItem ); RepeatPinItem( aDC, (LIB_PIN*) m_lastDrawItem );
break; break;
......
This diff is collapsed.
...@@ -31,12 +31,12 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) ...@@ -31,12 +31,12 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
SCH_ITEM* item = GetScreen()->GetCurItem(); SCH_ITEM* item = GetScreen()->GetCurItem();
wxPoint gridPosition = GetGridPosition( aPosition ); 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; DrawPanel->m_AutoPAN_Request = false;
m_itemToRepeat = NULL; m_itemToRepeat = NULL;
if( item && item->m_Flags ) if( item && item->GetFlags() )
{ {
switch( item->Type() ) switch( item->Type() )
{ {
...@@ -77,7 +77,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) ...@@ -77,7 +77,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break; break;
case ID_HIERARCHY_PUSH_POP_BUTT: case ID_HIERARCHY_PUSH_POP_BUTT:
if( ( item && item->m_Flags ) || ( g_RootSheet->CountSheets() == 0 ) ) if( ( item && item->GetFlags() ) || ( g_RootSheet->CountSheets() == 0 ) )
break; break;
item = LocateAndShowItem( aPosition ); item = LocateAndShowItem( aPosition );
...@@ -99,7 +99,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) ...@@ -99,7 +99,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break; break;
case ID_NOCONN_BUTT: case ID_NOCONN_BUTT:
if( ( item == NULL ) || ( item->m_Flags == 0 ) ) if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
{ {
m_itemToRepeat = AddNoConnect( aDC, gridPosition ); m_itemToRepeat = AddNoConnect( aDC, gridPosition );
GetScreen()->SetCurItem( m_itemToRepeat ); GetScreen()->SetCurItem( m_itemToRepeat );
...@@ -116,7 +116,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) ...@@ -116,7 +116,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break; break;
case ID_JUNCTION_BUTT: case ID_JUNCTION_BUTT:
if( ( item == NULL ) || ( item->m_Flags == 0 ) ) if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
{ {
m_itemToRepeat = AddJunction( aDC, gridPosition, true ); m_itemToRepeat = AddJunction( aDC, gridPosition, true );
GetScreen()->SetCurItem( m_itemToRepeat ); GetScreen()->SetCurItem( m_itemToRepeat );
...@@ -134,7 +134,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) ...@@ -134,7 +134,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
case ID_WIRETOBUS_ENTRY_BUTT: case ID_WIRETOBUS_ENTRY_BUTT:
case ID_BUSTOBUS_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 ) ? item = CreateBusEntry( aDC, ( GetToolId() == ID_WIRETOBUS_ENTRY_BUTT ) ?
WIRE_TO_BUS : BUS_TO_BUS ); WIRE_TO_BUS : BUS_TO_BUS );
...@@ -152,7 +152,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) ...@@ -152,7 +152,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break; break;
case ID_SCHEMATIC_DELETE_ITEM_BUTT: case ID_SCHEMATIC_DELETE_ITEM_BUTT:
LocateAndDeleteItem( this, aDC ); DeleteItemAtCrossHair( aDC );
OnModify(); OnModify();
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
GetScreen()->TestDanglingEnds(); GetScreen()->TestDanglingEnds();
...@@ -175,7 +175,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) ...@@ -175,7 +175,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break; break;
case ID_TEXT_COMMENT_BUTT: case ID_TEXT_COMMENT_BUTT:
if( ( item == NULL ) || ( item->m_Flags == 0 ) ) if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
{ {
GetScreen()->SetCurItem( CreateNewText( aDC, LAYER_NOTES ) ); GetScreen()->SetCurItem( CreateNewText( aDC, LAYER_NOTES ) );
DrawPanel->m_AutoPAN_Request = true; DrawPanel->m_AutoPAN_Request = true;
...@@ -188,7 +188,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) ...@@ -188,7 +188,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break; break;
case ID_LABEL_BUTT: case ID_LABEL_BUTT:
if( ( item == NULL ) || ( item->m_Flags == 0 ) ) if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
{ {
GetScreen()->SetCurItem( CreateNewText( aDC, LAYER_LOCLABEL ) ); GetScreen()->SetCurItem( CreateNewText( aDC, LAYER_LOCLABEL ) );
DrawPanel->m_AutoPAN_Request = true; DrawPanel->m_AutoPAN_Request = true;
...@@ -204,7 +204,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) ...@@ -204,7 +204,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
case ID_GLABEL_BUTT: case ID_GLABEL_BUTT:
case ID_HIERLABEL_BUTT: case ID_HIERLABEL_BUTT:
if( (item == NULL) || (item->m_Flags == 0) ) if( (item == NULL) || (item->GetFlags() == 0) )
{ {
if( GetToolId() == ID_GLABEL_BUTT ) if( GetToolId() == ID_GLABEL_BUTT )
GetScreen()->SetCurItem( CreateNewText( aDC, LAYER_GLOBLABEL ) ); GetScreen()->SetCurItem( CreateNewText( aDC, LAYER_GLOBLABEL ) );
...@@ -224,7 +224,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) ...@@ -224,7 +224,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break; break;
case ID_SHEET_SYMBOL_BUTT: case ID_SHEET_SYMBOL_BUTT:
if( ( item == NULL ) || ( item->m_Flags == 0 ) ) if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
{ {
GetScreen()->SetCurItem( CreateSheet( aDC ) ); GetScreen()->SetCurItem( CreateSheet( aDC ) );
DrawPanel->m_AutoPAN_Request = true; DrawPanel->m_AutoPAN_Request = true;
...@@ -240,20 +240,20 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) ...@@ -240,20 +240,20 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
case ID_IMPORT_HLABEL_BUTT: case ID_IMPORT_HLABEL_BUTT:
case ID_SHEET_LABEL_BUTT: case ID_SHEET_LABEL_BUTT:
if( ( item == NULL ) || ( item->m_Flags == 0 ) ) if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
item = LocateAndShowItem( aPosition ); item = LocateAndShowItem( aPosition );
if( item == NULL ) if( item == NULL )
break; 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 ) if( GetToolId() == ID_IMPORT_HLABEL_BUTT )
GetScreen()->SetCurItem( Import_PinSheet( (SCH_SHEET*) item, aDC ) ); GetScreen()->SetCurItem( Import_PinSheet( (SCH_SHEET*) item, aDC ) );
else else
GetScreen()->SetCurItem( Create_PinSheet( (SCH_SHEET*) item, aDC ) ); 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 ); item->Place( this, aDC );
GetScreen()->TestDanglingEnds(); GetScreen()->TestDanglingEnds();
...@@ -262,7 +262,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) ...@@ -262,7 +262,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break; break;
case ID_SCH_PLACE_COMPONENT: 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 ) ); GetScreen()->SetCurItem( Load_Component( aDC, wxEmptyString, s_CmpNameList, true ) );
DrawPanel->m_AutoPAN_Request = true; DrawPanel->m_AutoPAN_Request = true;
...@@ -277,7 +277,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) ...@@ -277,7 +277,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break; break;
case ID_PLACE_POWER_BUTT: 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" ), GetScreen()->SetCurItem( Load_Component( aDC, wxT( "power" ),
s_PowerNameList, false ) ); s_PowerNameList, false ) );
...@@ -317,12 +317,12 @@ void SCH_EDIT_FRAME::OnLeftDClick( wxDC* aDC, const wxPoint& aPosition ) ...@@ -317,12 +317,12 @@ void SCH_EDIT_FRAME::OnLeftDClick( wxDC* aDC, const wxPoint& aPosition )
switch( GetToolId() ) switch( GetToolId() )
{ {
case ID_NO_TOOL_SELECTED: case ID_NO_TOOL_SELECTED:
if( ( item == NULL ) || ( item->m_Flags == 0 ) ) if( ( item == NULL ) || ( item->GetFlags() == 0 ) )
{ {
item = LocateAndShowItem( aPosition ); item = LocateAndShowItem( aPosition );
} }
if( ( item == NULL ) || ( item->m_Flags != 0 ) ) if( ( item == NULL ) || ( item->GetFlags() != 0 ) )
break; break;
switch( item->Type() ) switch( item->Type() )
......
...@@ -64,7 +64,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) ...@@ -64,7 +64,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
} }
// Try to locate items at cursor position. // Try to locate items at cursor position.
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) if( (DrawStruct == NULL) || (DrawStruct->GetFlags() == 0) )
{ {
DrawStruct = LocateAndShowItem( aPosition, false ); DrawStruct = LocateAndShowItem( aPosition, false );
...@@ -81,7 +81,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) ...@@ -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 Command in progress: add "cancel" and "end tool" menu
if( GetToolId() != ID_NO_TOOL_SELECTED ) 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 ); ADD_MENUITEM( PopMenu, ID_CANCEL_CURRENT_COMMAND, _( "Cancel" ), cancel_xpm );
} }
...@@ -93,7 +93,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) ...@@ -93,7 +93,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
} }
else else
{ {
if( DrawStruct && DrawStruct->m_Flags ) if( DrawStruct && DrawStruct->GetFlags() )
{ {
ADD_MENUITEM( PopMenu, ID_CANCEL_CURRENT_COMMAND, _( "Cancel" ), cancel_xpm ); ADD_MENUITEM( PopMenu, ID_CANCEL_CURRENT_COMMAND, _( "Cancel" ), cancel_xpm );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
...@@ -112,7 +112,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) ...@@ -112,7 +112,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
GetScreen()->SetCurItem( DrawStruct ); GetScreen()->SetCurItem( DrawStruct );
int flags = DrawStruct->m_Flags; int flags = DrawStruct->GetFlags();
bool is_new = (flags & IS_NEW) ? TRUE : FALSE; bool is_new = (flags & IS_NEW) ? TRUE : FALSE;
switch( DrawStruct->Type() ) switch( DrawStruct->Type() )
...@@ -228,7 +228,7 @@ void AddMenusForComponentField( wxMenu* PopMenu, SCH_FIELD* Field ) ...@@ -228,7 +228,7 @@ void AddMenusForComponentField( wxMenu* PopMenu, SCH_FIELD* Field )
{ {
wxString msg; wxString msg;
if( !Field->m_Flags ) if( !Field->GetFlags() )
{ {
msg = AddHotkeyName( _( "Move Field" ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Move Field" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM ); HK_MOVE_COMPONENT_OR_ITEM );
...@@ -259,7 +259,7 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component ) ...@@ -259,7 +259,7 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
if( libEntry ) if( libEntry )
libComponent = libEntry->GetComponent(); libComponent = libEntry->GetComponent();
if( !Component->m_Flags ) if( !Component->GetFlags() )
{ {
msg = _( "Move Component" ); msg = _( "Move Component" );
msg << wxT( " " ) << Component->GetField( REFERENCE )->m_Text; msg << wxT( " " ) << Component->GetField( REFERENCE )->m_Text;
...@@ -325,7 +325,7 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component ) ...@@ -325,7 +325,7 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component )
ADD_MENUITEM_WITH_SUBMENU( PopMenu, editmenu, ID_POPUP_SCH_GENERIC_EDIT_CMP, ADD_MENUITEM_WITH_SUBMENU( PopMenu, editmenu, ID_POPUP_SCH_GENERIC_EDIT_CMP,
_( "Edit Component" ), edit_component_xpm ); _( "Edit Component" ), edit_component_xpm );
if( !Component->m_Flags ) if( !Component->GetFlags() )
{ {
msg = AddHotkeyName( _( "Copy Component" ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Copy Component" ), s_Schematic_Hokeys_Descr,
HK_COPY_COMPONENT_OR_LABEL ); HK_COPY_COMPONENT_OR_LABEL );
...@@ -344,7 +344,7 @@ void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel ) ...@@ -344,7 +344,7 @@ void AddMenusForGLabel( wxMenu* PopMenu, SCH_GLOBALLABEL* GLabel )
wxMenu* menu_change_type = new wxMenu; wxMenu* menu_change_type = new wxMenu;
wxString msg; wxString msg;
if( !GLabel->m_Flags ) if( !GLabel->GetFlags() )
{ {
msg = AddHotkeyName( _( "Move Global Label" ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Move Global Label" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM ); HK_MOVE_COMPONENT_OR_ITEM );
...@@ -381,7 +381,7 @@ void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* HLabel ) ...@@ -381,7 +381,7 @@ void AddMenusForHLabel( wxMenu* PopMenu, SCH_HIERLABEL* HLabel )
wxMenu* menu_change_type = new wxMenu; wxMenu* menu_change_type = new wxMenu;
wxString msg; wxString msg;
if( !HLabel->m_Flags ) if( !HLabel->GetFlags() )
{ {
msg = AddHotkeyName( _( "Move Hierarchical Label" ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Move Hierarchical Label" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM ); HK_MOVE_COMPONENT_OR_ITEM );
...@@ -417,7 +417,7 @@ void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label ) ...@@ -417,7 +417,7 @@ void AddMenusForLabel( wxMenu* PopMenu, SCH_LABEL* Label )
wxMenu* menu_change_type = new wxMenu; wxMenu* menu_change_type = new wxMenu;
wxString msg; wxString msg;
if( !Label->m_Flags ) if( !Label->GetFlags() )
{ {
msg = AddHotkeyName( _( "Move Label" ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Move Label" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM ); HK_MOVE_COMPONENT_OR_ITEM );
...@@ -453,7 +453,7 @@ void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text ) ...@@ -453,7 +453,7 @@ void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text )
wxString msg; wxString msg;
wxMenu* menu_change_type = new wxMenu; wxMenu* menu_change_type = new wxMenu;
if( !Text->m_Flags ) if( !Text->GetFlags() )
{ {
msg = AddHotkeyName( _( "Move Text" ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Move Text" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM ); HK_MOVE_COMPONENT_OR_ITEM );
...@@ -490,19 +490,20 @@ void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text ) ...@@ -490,19 +490,20 @@ void AddMenusForText( wxMenu* PopMenu, SCH_TEXT* Text )
void AddMenusForJunction( wxMenu* PopMenu, SCH_JUNCTION* Junction, SCH_EDIT_FRAME* frame ) void AddMenusForJunction( wxMenu* PopMenu, SCH_JUNCTION* Junction, SCH_EDIT_FRAME* frame )
{ {
bool is_new = Junction->IsNew(); bool is_new = Junction->IsNew();
SCH_SCREEN* screen = frame->GetScreen();
wxString msg; wxString msg;
if( !is_new ) if( !is_new )
{ {
if( PickStruct( frame->GetScreen()->GetCrossHairPosition(), frame->GetScreen(), if( screen->GetItem( screen->GetCrossHairPosition(), 0,
WIRE_T | BUS_T | EXCLUDE_ENDPOINTS_T ) ) WIRE_T | BUS_T | EXCLUDE_ENDPOINTS_T ) )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ), break_line_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ), break_line_xpm );
} }
msg = AddHotkeyName( _( "Delete Junction" ), s_Schematic_Hokeys_Descr, HK_DELETE ); msg = AddHotkeyName( _( "Delete Junction" ), s_Schematic_Hokeys_Descr, HK_DELETE );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, msg, delete_xpm ); 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_NODE, _( "Delete Node" ), delete_node_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( "Delete Connection" ), ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( "Delete Connection" ),
...@@ -514,7 +515,8 @@ void AddMenusForJunction( wxMenu* PopMenu, SCH_JUNCTION* Junction, SCH_EDIT_FRAM ...@@ -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 ) void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame )
{ {
bool is_new = Wire->IsNew(); bool is_new = Wire->IsNew();
wxPoint pos = frame->GetScreen()->GetCrossHairPosition(); SCH_SCREEN* screen = frame->GetScreen();
wxPoint pos = screen->GetCrossHairPosition();
wxString msg; wxString msg;
if( is_new ) if( is_new )
...@@ -532,8 +534,8 @@ void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame ) ...@@ -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" ), ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( "Delete Connection" ),
delete_connection_xpm ); delete_connection_xpm );
if( PickStruct( frame->GetScreen()->GetCrossHairPosition(), frame->GetScreen(), if( screen->GetItem( screen->GetCrossHairPosition(), 0,
WIRE_T | BUS_T | EXCLUDE_ENDPOINTS_T ) ) WIRE_T | BUS_T | EXCLUDE_ENDPOINTS_T ) )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ), break_line_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ), break_line_xpm );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
...@@ -582,7 +584,7 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet ) ...@@ -582,7 +584,7 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet )
{ {
wxString msg; wxString msg;
if( !Sheet->m_Flags ) if( !Sheet->GetFlags() )
{ {
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ENTER_SHEET, _( "Enter Sheet" ), enter_sheet_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_ENTER_SHEET, _( "Enter Sheet" ), enter_sheet_xpm );
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
...@@ -594,7 +596,7 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet ) ...@@ -594,7 +596,7 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DRAG_CMP_REQUEST, msg, move_sheet_xpm ); 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 ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_END_SHEET, _( "Place Sheet" ), apply_xpm );
} }
...@@ -623,7 +625,7 @@ void AddMenusForPinSheet( wxMenu* PopMenu, SCH_SHEET_PIN* PinSheet ) ...@@ -623,7 +625,7 @@ void AddMenusForPinSheet( wxMenu* PopMenu, SCH_SHEET_PIN* PinSheet )
{ {
wxString msg; wxString msg;
if( !PinSheet->m_Flags ) if( !PinSheet->GetFlags() )
{ {
msg = AddHotkeyName( _( "Move PinSheet" ), s_Schematic_Hokeys_Descr, msg = AddHotkeyName( _( "Move PinSheet" ), s_Schematic_Hokeys_Descr,
HK_MOVE_COMPONENT_OR_ITEM ); HK_MOVE_COMPONENT_OR_ITEM );
...@@ -632,7 +634,7 @@ void AddMenusForPinSheet( wxMenu* PopMenu, SCH_SHEET_PIN* PinSheet ) ...@@ -632,7 +634,7 @@ void AddMenusForPinSheet( wxMenu* PopMenu, SCH_SHEET_PIN* PinSheet )
ADD_MENUITEM( PopMenu, ID_POPUP_SCH_EDIT_PINSHEET, _( "Edit PinSheet" ), edit_xpm ); 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 ); ADD_MENUITEM( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete PinSheet" ), delete_pinsheet_xpm );
} }
......
...@@ -57,7 +57,7 @@ void RotateListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& rotationPoint ) ...@@ -57,7 +57,7 @@ void RotateListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& rotationPoint )
{ {
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii ); SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii );
item->Rotate( rotationPoint ); // Place it in its new position. 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 ) ...@@ -73,7 +73,7 @@ void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& aMirrorPoint )
{ {
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii ); SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii );
item->Mirror_Y( aMirrorPoint.x ); // Place it in its new position. 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 ...@@ -84,7 +84,7 @@ void Mirror_X_ListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& aMirrorPoint
{ {
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii ); SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii );
item->Mirror_X( aMirrorPoint.y ); // Place it in its new position. 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 ) ...@@ -115,13 +115,11 @@ void DeleteItemsInList( EDA_DRAW_PANEL* panel, PICKED_ITEMS_LIST& aItemsList )
SCH_SCREEN* screen = (SCH_SCREEN*) panel->GetScreen(); SCH_SCREEN* screen = (SCH_SCREEN*) panel->GetScreen();
SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) panel->GetParent(); SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) panel->GetParent();
PICKED_ITEMS_LIST itemsList; PICKED_ITEMS_LIST itemsList;
ITEM_PICKER itemWrapper;
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ ) for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{ {
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii ); SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii );
itemWrapper.m_PickedItem = item; ITEM_PICKER itemWrapper( item, UR_DELETED );
itemWrapper.m_UndoRedoStatus = UR_DELETED;
if( item->Type() == SCH_SHEET_LABEL_T ) if( item->Type() == SCH_SHEET_LABEL_T )
{ {
...@@ -143,37 +141,31 @@ void DeleteItemsInList( EDA_DRAW_PANEL* panel, PICKED_ITEMS_LIST& aItemsList ) ...@@ -143,37 +141,31 @@ void DeleteItemsInList( EDA_DRAW_PANEL* panel, PICKED_ITEMS_LIST& aItemsList )
} }
/* Routine to delete an object from global drawing object list. void SCH_EDIT_FRAME::DeleteItem( SCH_ITEM* aItem )
* Object is put in Undo list
*/
void DeleteStruct( EDA_DRAW_PANEL* panel, wxDC* DC, SCH_ITEM* DrawStruct )
{ {
SCH_SCREEN* screen = (SCH_SCREEN*) panel->GetScreen(); wxCHECK_RET( aItem != NULL, wxT( "Cannot delete invalid item." ) );
SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) panel->GetParent();
if( !DrawStruct ) SCH_SCREEN* screen = GetScreen();
return;
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 // This iten is attached to a node, and is not accessible by the global list directly.
* the global list directly. */ SCH_SHEET* sheet = (SCH_SHEET*) aItem->GetParent();
frame->SaveCopyInUndoList( (SCH_ITEM*)( (SCH_SHEET_PIN*) DrawStruct )->GetParent(), wxCHECK_RET( (sheet != NULL) && (sheet->Type() == SCH_SHEET_T),
UR_CHANGED ); wxT( "Sheet label has invalid parent item." ) );
frame->DeleteSheetLabel( DC ? true : false, (SCH_SHEET_PIN*) DrawStruct ); SaveCopyInUndoList( (SCH_ITEM*) sheet, UR_CHANGED );
return; sheet->RemoveLabel( (SCH_SHEET_PIN*) aItem );
DrawPanel->RefreshDrawingRect( sheet->GetBoundingBox() );
} }
else else
{ {
screen->RemoveFromDrawList( DrawStruct ); screen->RemoveFromDrawList( aItem );
panel->RefreshDrawingRect( DrawStruct->GetBoundingBox() );
/* Unlink the structure */ aItem->SetNext( NULL );
DrawStruct->SetNext( 0 ); aItem->SetBack( NULL ); // Only one struct -> no link
DrawStruct->SetBack( 0 ); // Only one struct -> no link
frame->SaveCopyInUndoList( DrawStruct, UR_DELETED ); SaveCopyInUndoList( aItem, UR_DELETED );
DrawPanel->RefreshDrawingRect( aItem->GetBoundingBox() );
} }
} }
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#ifndef __PROTOS_H__ #ifndef __PROTOS_H__
#define __PROTOS_H__ #define __PROTOS_H__
#include "class_undoredo_container.h"
#include "colors.h" #include "colors.h"
...@@ -50,13 +52,9 @@ void SnapLibItemPoint( int OrigX, ...@@ -50,13 +52,9 @@ void SnapLibItemPoint( int OrigX,
bool LibItemInBox( int x1, int y1, int x2, int y2, SCH_COMPONENT* DrawLibItem ); 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 // operations_on_item_lists.cpp
void DeleteItemsInList( EDA_DRAW_PANEL* panel, PICKED_ITEMS_LIST& aItemsList );
/** /**
* Function DuplicateStruct * Function DuplicateStruct
...@@ -75,38 +73,6 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct, bool aClone = false ); ...@@ -75,38 +73,6 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct, bool aClone = false );
SCH_COMPONENT* LocateSmallestComponent( SCH_SCREEN* Screen ); 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 */ /* EEREDRAW.CPP */
...@@ -142,14 +108,6 @@ bool ClearProjectDrawList( SCH_SCREEN* FirstWindow, bool confirm_deletion ); ...@@ -142,14 +108,6 @@ bool ClearProjectDrawList( SCH_SCREEN* FirstWindow, bool confirm_deletion );
* clear the screen datas (filenames ..) * 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 */ /* PINEDIT.CPP */
......
...@@ -447,10 +447,10 @@ void SCH_FIELD::Rotate( wxPoint rotationPoint ) ...@@ -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. // Do not hit test hidden or empty fields.
if( !IsVisible() ) if( !(aFilter & FIELD_T) || !IsVisible() || IsVoid() )
return false; return false;
EDA_Rect rect = GetBoundingBox(); EDA_Rect rect = GetBoundingBox();
......
...@@ -164,7 +164,7 @@ public: ...@@ -164,7 +164,7 @@ public:
void* aAuxData, wxPoint * aFindLocation ); void* aAuxData, wxPoint * aFindLocation );
private: 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 bool doHitTest( const EDA_Rect& aRect, bool aContained, int aAccuracy ) const;
virtual EDA_ITEM* doClone() const; virtual EDA_ITEM* doClone() const;
}; };
......
This diff is collapsed.
...@@ -204,7 +204,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -204,7 +204,7 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( item == NULL ) if( item == NULL )
break; break;
DeleteStruct( DrawPanel, &dc, item ); DeleteItem( item );
screen->SetCurItem( NULL ); screen->SetCurItem( NULL );
m_itemToRepeat = NULL; m_itemToRepeat = NULL;
screen->TestDanglingEnds( DrawPanel, &dc ); screen->TestDanglingEnds( DrawPanel, &dc );
......
...@@ -209,7 +209,7 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem, ...@@ -209,7 +209,7 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem,
if( aItem ) if( aItem )
{ {
itemWrapper.m_PickedItemType = aItem->Type(); itemWrapper.m_PickedItemType = aItem->Type();
itemWrapper.m_PickerFlags = aItem->m_Flags; itemWrapper.m_PickerFlags = aItem->GetFlags();
} }
switch( aCommandType ) switch( aCommandType )
...@@ -329,12 +329,14 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed ...@@ -329,12 +329,14 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
// complex command // complex command
for( int ii = aList->GetCount() - 1; ii >= 0; ii-- ) for( int ii = aList->GetCount() - 1; ii >= 0; ii-- )
{ {
ITEM_PICKER itemWrapper = aList->GetItemWrapper( ii ); item = (SCH_ITEM*) aList->GetPickedItem( ii );
item = (SCH_ITEM*) itemWrapper.m_PickedItem;
if( item ) if( item )
item->m_Flags = 0; item->ClearFlags();
SCH_ITEM* image = (SCH_ITEM*) itemWrapper.m_Link;
switch( itemWrapper.m_UndoRedoStatus ) SCH_ITEM* image = (SCH_ITEM*) aList->GetPickedItemLink( ii );
switch( aList->GetPickedItemStatus( ii ) )
{ {
case UR_CHANGED: /* Exchange old and new data for each item */ case UR_CHANGED: /* Exchange old and new data for each item */
SwapData( item, image ); SwapData( item, image );
...@@ -352,10 +354,10 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed ...@@ -352,10 +354,10 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
break; break;
case UR_MOVED: case UR_MOVED:
item->m_Flags = aList->GetPickerFlags( ii ); item->ClearFlags();
item->Move( aRedoCommand ? item->SetFlags( aList->GetPickerFlags( ii ) );
aList->m_TransformPoint : -aList->m_TransformPoint ); item->Move( aRedoCommand ? aList->m_TransformPoint : -aList->m_TransformPoint );
item->m_Flags = 0; item->ClearFlags();
break; break;
case UR_MIRRORED_Y: case UR_MIRRORED_Y:
...@@ -385,12 +387,13 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed ...@@ -385,12 +387,13 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
/* Exchange the current wires and the old wires */ /* Exchange the current wires and the old wires */
alt_item = GetScreen()->ExtractWires( false ); alt_item = GetScreen()->ExtractWires( false );
aList->SetPickedItem( alt_item, ii ); aList->SetPickedItem( alt_item, ii );
while( item ) while( item )
{ {
SCH_ITEM* nextitem = item->Next(); SCH_ITEM* nextitem = item->Next();
item->SetNext( GetScreen()->GetDrawItems() ); item->SetNext( GetScreen()->GetDrawItems() );
GetScreen()->SetDrawItems( item ); GetScreen()->SetDrawItems( item );
item->m_Flags = 0; item->ClearFlags();
item = nextitem; item = nextitem;
} }
...@@ -400,7 +403,7 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed ...@@ -400,7 +403,7 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
{ {
wxString msg; wxString msg;
msg.Printf( wxT( "PutDataInPreviousState() error (unknown code %X)" ), msg.Printf( wxT( "PutDataInPreviousState() error (unknown code %X)" ),
itemWrapper.m_UndoRedoStatus ); aList->GetPickedItemStatus( ii ) );
wxMessageBox( msg ); wxMessageBox( msg );
} }
break; break;
......
...@@ -244,36 +244,3 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::Import_PinSheet( SCH_SHEET* Sheet, wxDC* DC ) ...@@ -244,36 +244,3 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::Import_PinSheet( SCH_SHEET* Sheet, wxDC* DC )
return NewSheetLabel; 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; ...@@ -14,6 +14,7 @@ class LIB_PIN;
class SCH_COMPONENT; class SCH_COMPONENT;
class SCH_SHEET_PATH; class SCH_SHEET_PATH;
class SCH_SHEET_PIN; class SCH_SHEET_PIN;
class SCH_LINE;
/* Max number of sheets in a hierarchy project: */ /* Max number of sheets in a hierarchy project: */
...@@ -94,6 +95,29 @@ public: ...@@ -94,6 +95,29 @@ public:
*/ */
int GetItems( const wxPoint& aPosition, SCH_ITEMS& aItemList ) const; 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 ) { }; void Place( SCH_EDIT_FRAME* frame, wxDC* DC ) { };
/** /**
...@@ -113,6 +137,15 @@ public: ...@@ -113,6 +137,15 @@ public:
*/ */
void RemoveFromDrawList( SCH_ITEM* aItem ); 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 ); bool CheckIfOnDrawList( SCH_ITEM* st );
void AddToDrawList( SCH_ITEM* st ); void AddToDrawList( SCH_ITEM* st );
...@@ -149,6 +182,15 @@ public: ...@@ -149,6 +182,15 @@ public:
*/ */
void ReplaceWires( SCH_ITEM* aWireList ); 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 * Function BreakSegment
* checks every wire and bus for a intersection at \a aPoint and break into two segments * checks every wire and bus for a intersection at \a aPoint and break into two segments
...@@ -227,7 +269,7 @@ public: ...@@ -227,7 +269,7 @@ public:
* @return The pin item if found, otherwise NULL. * @return The pin item if found, otherwise NULL.
*/ */
LIB_PIN* GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponent = NULL, LIB_PIN* GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponent = NULL,
bool aEndPointOnly = false ); bool aEndPointOnly = false ) const;
/** /**
* Function GetSheetLabel * Function GetSheetLabel
...@@ -268,6 +310,7 @@ public: ...@@ -268,6 +310,7 @@ public:
int UpdatePickList(); int UpdatePickList();
virtual void AddItem( SCH_ITEM* aItem ) { BASE_SCREEN::AddItem( (EDA_ITEM*) aItem ); } virtual void AddItem( SCH_ITEM* aItem ) { BASE_SCREEN::AddItem( (EDA_ITEM*) aItem ); }
virtual void InsertItem( EDA_ITEMS::iterator aIter, SCH_ITEM* aItem ) virtual void InsertItem( EDA_ITEMS::iterator aIter, SCH_ITEM* aItem )
{ {
BASE_SCREEN::InsertItem( aIter, (EDA_ITEM*) aItem ); BASE_SCREEN::InsertItem( aIter, (EDA_ITEM*) aItem );
...@@ -323,9 +366,17 @@ public: ...@@ -323,9 +366,17 @@ public:
*/ */
void SetDate( const wxString& aDate ); 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: private:
void AddScreenToList( SCH_SCREEN* aScreen ); void AddScreenToList( SCH_SCREEN* aScreen );
void BuildScreenList( EDA_ITEM* aItem ); void BuildScreenList( EDA_ITEM* aItem );
}; };
#endif /* CLASS_SCREEN_H */ #endif /* CLASS_SCREEN_H */
This diff is collapsed.
...@@ -123,7 +123,6 @@ public: ...@@ -123,7 +123,6 @@ public:
*/ */
static wxString GetDefaultFieldName( int aFieldNdx ); static wxString GetDefaultFieldName( int aFieldNdx );
/** /**
* Function AddTemplateFieldName * Function AddTemplateFieldName
* inserts or appends a wanted symbol field name into the fieldnames * inserts or appends a wanted symbol field name into the fieldnames
...@@ -208,6 +207,26 @@ public: ...@@ -208,6 +207,26 @@ public:
SCH_ITEM* LocateAndShowItem( const wxPoint& aPosition, bool aIncludePin = true ); SCH_ITEM* LocateAndShowItem( const wxPoint& aPosition, bool aIncludePin = true );
SCH_ITEM* LocateItem( const wxPoint& aPosition, bool aIncludePin ); 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 * Function FillFootprintFieldForAllInstancesofComponent
* searches for component "aReference", and places a Footprint in * searches for component "aReference", and places a Footprint in
...@@ -508,8 +527,12 @@ private: ...@@ -508,8 +527,12 @@ private:
SCH_SHEET_PIN* Import_PinSheet( SCH_SHEET* Sheet, wxDC* DC ); SCH_SHEET_PIN* Import_PinSheet( SCH_SHEET* Sheet, wxDC* DC );
public: 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; } 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