Rework on undo/redo and block functions

This commit is contained in:
charras 2009-07-25 07:31:07 +00:00
parent 8ec8cf3f43
commit daceb2e019
19 changed files with 117 additions and 499 deletions

View File

@ -12,7 +12,6 @@ set(COMMON_SRCS
basicframe.cpp
bezier_curves.cpp
block_commande.cpp
class_drawpickedstruct.cpp
class_marker_base.cpp
class_undoredo_container.cpp
common.cpp

View File

@ -11,7 +11,6 @@
#include "common.h"
#include "macros.h"
#include "base_struct.h"
#include "class_drawpickedstruct.h"
#include "class_base_screen.h"
#include "class_drawpanel.h"
#include "confirm.h"

View File

@ -1,81 +0,0 @@
/****************************************************/
/* class_drawpickedstruct.cpp */
/****************************************************/
#include "fctsys.h"
#include "common.h"
#include "class_drawpickedstruct.h"
/* This class has only one useful member: .m_PickedStruct, used as a link.
* It does not describe really an item.
* It is used to create a linked list of selected items (in block selection).
* Each DrawPickedStruct item has is member: .m_PickedStruct pointing the
* real selected item
*/
/*******************************************************************/
DrawPickedStruct::DrawPickedStruct( EDA_BaseStruct* pickedstruct ) :
EDA_BaseStruct( NULL, DRAW_PICK_ITEM_STRUCT_TYPE )
/*******************************************************************/
{
m_PickedStruct = pickedstruct;
}
DrawPickedStruct::~DrawPickedStruct()
{
}
#if defined(DEBUG)
void DrawPickedStruct::Show( int nestLevel, std::ostream& os )
{
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << "/>\n";
}
#endif
EDA_Rect DrawPickedStruct::GetBoundingBox()
{
if( m_PickedStruct )
return m_PickedStruct->GetBoundingBox();
else
{
return EDA_Rect(); // empty rectangle
}
}
EDA_Rect DrawPickedStruct::GetBoundingBoxUnion()
{
EDA_Rect ret;
EDA_BaseStruct* item;
DrawPickedStruct* cur = this;
while( cur && (item = cur->m_PickedStruct) != NULL )
{
ret.Merge( item->GetBoundingBox() );
cur = cur->Next();
}
return ret;
}
/*********************************************/
void DrawPickedStruct::DeleteWrapperList()
/*********************************************/
/* Delete this item all the items of the linked list
* Free the wrapper, but DOES NOT delete the picked items linked by .m_PickedStruct
*/
{
DrawPickedStruct* wrapp_struct, * next_struct;
for( wrapp_struct = Next(); wrapp_struct != NULL; wrapp_struct = next_struct )
{
next_struct = wrapp_struct->Next();
delete wrapp_struct;
}
}

View File

@ -27,7 +27,7 @@ set(EESCHEMA_SRCS
class_pin.cpp
class_sch_cmp_field.cpp
class_schematic_items.cpp
class_screen.cpp
class_sch_screen.cpp
class_text-label.cpp
classes_body_items.cpp
cleanup.cpp

View File

@ -10,7 +10,6 @@
#include "class_drawpanel.h"
#include "confirm.h"
#include "block_commande.h"
#include "class_drawpickedstruct.h"
#include "program.h"
#include "libcmp.h"
@ -22,10 +21,10 @@
/* Variables Locales */
/* Fonctions exportees */
void DeleteItemsInList( WinEDA_DrawPanel* panel,
PICKED_ITEMS_LIST& aItemsList );
/* Fonctions Locales */
static void DeleteItemsInList( WinEDA_DrawPanel* panel,
PICKED_ITEMS_LIST& aItemsList );
static void PlaceItemsInList( SCH_SCREEN* aScreen, PICKED_ITEMS_LIST& aItemsList );
static void MoveListOfItems( SCH_SCREEN* aScreen, PICKED_ITEMS_LIST& aItemsList );
static void CopyItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList );
@ -247,7 +246,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_MOVE: /* Move */
case BLOCK_COPY: /* Copy */
PickStruct( GetScreen()->m_BlockLocate, GetScreen() );
PickItemsInBlock( GetScreen()->m_BlockLocate, GetScreen() );
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
if( block->GetCount() )
@ -268,7 +267,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
break;
case BLOCK_DELETE: /* Delete */
PickStruct( GetScreen()->m_BlockLocate, GetScreen() );
PickItemsInBlock( GetScreen()->m_BlockLocate, GetScreen() );
DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE );
if( block->GetCount() )
{
@ -282,7 +281,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
break;
case BLOCK_SAVE: /* Save */
PickStruct( GetScreen()->m_BlockLocate, GetScreen() );
PickItemsInBlock( GetScreen()->m_BlockLocate, GetScreen() );
DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE );
if( block->GetCount() )
{
@ -380,7 +379,7 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
BreakSegmentOnJunction( GetScreen() );
PickStruct( GetScreen()->m_BlockLocate, GetScreen() );
PickItemsInBlock( GetScreen()->m_BlockLocate, GetScreen() );
if( block->GetCount() )
{
ii = 1;
@ -677,9 +676,6 @@ void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& Center )
MirrorYPoint( DrawSheetLabel->m_Pos, Center );
break;
case DRAW_PICK_ITEM_STRUCT_TYPE:
break;
default:
break;
}
@ -730,7 +726,6 @@ void CopyItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList )
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case DRAW_PICK_ITEM_STRUCT_TYPE:
case DRAW_MARKER_STRUCT_TYPE:
case DRAW_NOCONNECT_STRUCT_TYPE:
default:
@ -786,25 +781,6 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct )
return;
}
if( DrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
{
// Unlink all picked structs from current EEDrawList
for( DrawPickedStruct* cur = (DrawPickedStruct*) DrawStruct;
cur;
cur = cur->Next() )
{
SCH_ITEM* item = (SCH_ITEM*) cur->m_PickedStruct;
screen->RemoveFromDrawList( item );
panel->PostDirtyRect( item->GetBoundingBox() );
item->SetNext( 0 );
item->SetBack( 0 );
item->m_Flags = IS_DELETED;
}
// Removed items are put onto the Undo list
frame->SaveCopyInUndoList( DrawStruct, IS_DELETED );
}
else /* structure classique */
{
screen->RemoveFromDrawList( DrawStruct );
@ -1065,9 +1041,6 @@ void MoveOneStruct( SCH_ITEM* DrawStruct, const wxPoint& move_vector )
DrawSheetLabel->m_Pos += move_vector;
break;
case DRAW_PICK_ITEM_STRUCT_TYPE:
break;
default:
break;
}
@ -1140,27 +1113,6 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct )
NewDrawStruct = ( (DrawSheetStruct*) DrawStruct )->GenCopy();
break;
case DRAW_PICK_ITEM_STRUCT_TYPE:
{
DrawPickedStruct* NewPickedItem, * PickedList = NULL,
* LastPickedItem = NULL;
PickedList = (DrawPickedStruct*) DrawStruct;
while( PickedList )
{
NewPickedItem = new DrawPickedStruct();
if( NewDrawStruct == NULL )
NewDrawStruct = (SCH_ITEM*) NewPickedItem;
if( LastPickedItem )
LastPickedItem->SetNext( NewPickedItem );
LastPickedItem = NewPickedItem;
NewPickedItem->m_PickedStruct =
DuplicateStruct( (SCH_ITEM*) PickedList->m_PickedStruct );
PickedList = PickedList->Next();
}
break;
}
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case DRAW_PART_TEXT_STRUCT_TYPE:
case SCREEN_STRUCT_TYPE:
@ -1417,17 +1369,10 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
break;
case TYPE_SCH_COMPONENT:
break;
case DRAW_SHEET_STRUCT_TYPE:
break;
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
break;
case DRAW_PICK_ITEM_STRUCT_TYPE:
break;
case DRAW_MARKER_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (MARKER_SCH*) Struct )

View File

@ -32,7 +32,6 @@ void SetaParent( EDA_BaseStruct* Struct, BASE_SCREEN* Screen )
break;
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case DRAW_PICK_ITEM_STRUCT_TYPE:
break;
default:

View File

@ -7,7 +7,6 @@
#include "common.h"
#include "trigo.h"
#include "confirm.h"
#include "class_drawpickedstruct.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
@ -115,7 +114,6 @@ void BreakSegmentOnJunction( SCH_SCREEN* Screen )
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_COMPONENT:
case DRAW_PICK_ITEM_STRUCT_TYPE:
case DRAW_POLYLINE_STRUCT_TYPE:
case DRAW_MARKER_STRUCT_TYPE:
case TYPE_SCH_TEXT:
@ -131,78 +129,48 @@ void BreakSegmentOnJunction( SCH_SCREEN* Screen )
}
/*********************************************************/
DrawPickedStruct* BreakSegment( SCH_SCREEN* screen,
wxPoint breakpoint, bool PutInUndoList )
/*********************************************************/
/* Coupe un segment ( BUS, WIRE ) en 2 au point breakpoint,
* - si ce point est sur le segment
* - extremites non comprises
* If PutInUndoList == TRUE, create a list of modifictions, for undo command
/* Break a segment ( BUS, WIRE ) int 2 segments at location aBreakpoint,
* if aBreakpoint in on segment segment
* ( excluding ends)
* fill aPicklist with modified items if non null
*/
void BreakSegment(SCH_SCREEN * aScreen, wxPoint aBreakpoint,
PICKED_ITEMS_LIST * aPicklist)
{
EDA_BaseStruct* DrawList;
EDA_DrawLineStruct* segment, * NewSegment;
DrawPickedStruct* List = NULL;
for( SCH_ITEM* DrawList = aScreen->EEDrawList;DrawList; DrawList = DrawList->Next() )
{
if( DrawList->Type() != DRAW_SEGMENT_STRUCT_TYPE )
continue;
DrawList = screen->EEDrawList;
while( DrawList )
{
switch( DrawList->Type() )
{
case DRAW_SEGMENT_STRUCT_TYPE:
segment = (EDA_DrawLineStruct*) DrawList;
if( !TestSegmentHit( breakpoint, segment->m_Start, segment->m_End, 0 ) )
break;
if( !TestSegmentHit( aBreakpoint, segment->m_Start, segment->m_End, 0 ) )
continue;
/* Segment connecte: doit etre coupe en 2 si px,py n'est
* pas une extremite */
if( (segment->m_Start == breakpoint) || (segment->m_End == breakpoint ) )
break;
if( (segment->m_Start == aBreakpoint) || (segment->m_End == aBreakpoint ) )
continue;
/* Ici il faut couper le segment en 2 */
if( PutInUndoList ) // First: put copy of the old segment in undo list
if( aPicklist ) // First: put copy of the old segment in undo list
{
DrawPickedStruct* wrapper = new DrawPickedStruct();
wrapper->m_Flags = IS_CHANGED;
wrapper->m_PickedStruct = segment->GenCopy();
wrapper->m_Image = segment;
wrapper->m_PickedStruct->m_Image = segment;
wrapper->SetNext( List );
List = wrapper;
ITEM_PICKER picker((SCH_ITEM*) segment->GenCopy(), IS_CHANGED);
picker.m_Link = segment;
aPicklist->PushItem(picker);
}
NewSegment = segment->GenCopy();
NewSegment->m_Start = breakpoint;
NewSegment->m_Start = aBreakpoint;
segment->m_End = NewSegment->m_Start;
NewSegment->SetNext( segment->Next() );
segment->SetNext( NewSegment );
DrawList = NewSegment;
if( PutInUndoList )
if( aPicklist )
{
DrawPickedStruct* wrapper = new DrawPickedStruct();
wrapper->m_Flags = IS_NEW;
wrapper->m_Image = NewSegment;
wrapper->SetNext( List );
List = wrapper;
ITEM_PICKER picker(NewSegment, IS_NEW);
aPicklist->PushItem(picker);
}
break;
case DRAW_JUNCTION_STRUCT_TYPE:
case DRAW_BUSENTRY_STRUCT_TYPE:
case DRAW_POLYLINE_STRUCT_TYPE:
break;
default:
break;
}
DrawList = DrawList->Next();
}
return List;
}

View File

@ -5,7 +5,6 @@
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "class_drawpickedstruct.h"
#include "program.h"
#include "libcmp.h"
@ -13,6 +12,10 @@
#include "protos.h"
#include "class_marker_sch.h"
// Imported function:
void DeleteItemsInList( WinEDA_DrawPanel* panel,
PICKED_ITEMS_LIST& aItemsList );
/********************************************************************************/
static int CountConnectedItems( WinEDA_SchematicFrame* frame,
@ -115,7 +118,7 @@ static bool MarkConnected( WinEDA_SchematicFrame* frame, SCH_ITEM* ListStruct,
/********************************************************************************/
void WinEDA_SchematicFrame::DeleteConnection( wxDC* DC, bool DeleteFullConnection )
void WinEDA_SchematicFrame::DeleteConnection( bool DeleteFullConnection )
/********************************************************************************/
/* Delete a connection, i.e wires or bus connected
@ -124,20 +127,21 @@ void WinEDA_SchematicFrame::DeleteConnection( wxDC* DC, bool DeleteFullConnectio
{
wxPoint refpos = GetScreen()->m_Curseur;
SCH_ITEM* DelStruct;
DrawPickedStruct* PickedItem, * PickedList = NULL;
PICKED_ITEMS_LIST pickList;
/* Clear .m_Flags member for all items */
for( DelStruct = GetScreen()->EEDrawList; DelStruct != NULL; DelStruct = DelStruct->Next() )
DelStruct->m_Flags = 0;
BreakSegmentOnJunction( (SCH_SCREEN*) GetScreen() );
DelStruct = GetScreen()->EEDrawList;
/* Locate all the wires, bus or junction under the mouse cursor, and put them in a list
* of items to delete
*/
ITEM_PICKER picker(NULL, IS_DELETED);
SCH_SCREEN* screen = (SCH_SCREEN*) GetScreen();
SCH_ITEM* savedEEDrawList = screen->EEDrawList;
SCH_ITEM* savedEEDrawList = screen->EEDrawList; // Save the list entry point of this screen
DelStruct = GetScreen()->EEDrawList;
while( DelStruct
&& ( DelStruct = PickStruct( screen->m_Curseur,
screen, JUNCTIONITEM | WIREITEM | BUSITEM ) ) != NULL )
@ -145,10 +149,9 @@ void WinEDA_SchematicFrame::DeleteConnection( wxDC* DC, bool DeleteFullConnectio
DelStruct->m_Flags = SELECTEDNODE | STRUCT_DELETED;
/* Put this structure in the picked list: */
PickedItem = new DrawPickedStruct( DelStruct );
picker.m_Item = DelStruct;
pickList.PushItem(picker);
PickedItem->SetNext( PickedList );
PickedList = PickedItem;
DelStruct = DelStruct->Next();
screen->EEDrawList = DelStruct;
}
@ -234,10 +237,9 @@ void WinEDA_SchematicFrame::DeleteConnection( wxDC* DC, bool DeleteFullConnectio
{
DelStruct->m_Flags |= STRUCT_DELETED;
/* Put this structure in the picked list: */
PickedItem = new DrawPickedStruct( DelStruct );
picker.m_Item = DelStruct;
pickList.PushItem(picker);
PickedItem->SetNext( PickedList );
PickedList = PickedItem;
DelStruct = GetScreen()->EEDrawList;
}
#undef SEGM
@ -262,10 +264,8 @@ void WinEDA_SchematicFrame::DeleteConnection( wxDC* DC, bool DeleteFullConnectio
DelStruct->m_Flags |= STRUCT_DELETED;
/* Put this structure in the picked list: */
PickedItem = new DrawPickedStruct( DelStruct );
PickedItem->SetNext( PickedList );
PickedList = PickedItem;
picker.m_Item = DelStruct;
pickList.PushItem(picker);
}
#undef JUNCTION
}
@ -290,10 +290,8 @@ void WinEDA_SchematicFrame::DeleteConnection( wxDC* DC, bool DeleteFullConnectio
DelStruct->m_Flags |= STRUCT_DELETED;
/* Put this structure in the picked list: */
PickedItem = new DrawPickedStruct( DelStruct );
PickedItem->SetNext( PickedList );
PickedList = PickedItem;
picker.m_Item = DelStruct;
pickList.PushItem(picker);
}
}
@ -303,9 +301,9 @@ void WinEDA_SchematicFrame::DeleteConnection( wxDC* DC, bool DeleteFullConnectio
for( DelStruct = GetScreen()->EEDrawList; DelStruct != NULL; DelStruct = DelStruct->Next() )
DelStruct->m_Flags = 0;
if( PickedList )
if( pickList.GetCount() )
{
DeleteStruct( DrawPanel, DC, (SCH_ITEM*) PickedList );
DeleteItemsInList( DrawPanel, pickList );
GetScreen()->SetModify();
}
}
@ -381,7 +379,6 @@ void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Screen )
*/
{
EDA_BaseStruct* DrawList;
DrawPickedStruct* PickedList = NULL;
Hierarchical_PIN_Sheet_Struct* SheetLabel, * NextLabel;
if( DrawStruct == NULL )
@ -394,16 +391,14 @@ void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Screen )
if( DrawStruct->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
{
/* Cette stucture est rattachee a une feuille, et n'est pas
* accessible par la liste globale directement */
//this structure has a sheet attached, which we must find.
//this structure is attached to a sheet , which we must find.
DrawList = Screen->EEDrawList;
for( ; DrawList != NULL; DrawList = DrawList->Next() )
{
if( DrawList->Type() != DRAW_SHEET_STRUCT_TYPE )
continue;
/* Examen de la Sheet */
/* See if our item is in this Sheet */
SheetLabel = ( (DrawSheetStruct*) DrawList )->m_Label;
if( SheetLabel == NULL )
continue;
@ -431,37 +426,9 @@ void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Screen )
}
}
}
return;
}
if( DrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
{
PickedList = (DrawPickedStruct*) DrawStruct;
while( PickedList )
{
if( PickedList->m_PickedStruct == Screen->EEDrawList )
{
Screen->EEDrawList = Screen->EEDrawList->Next();
SAFE_DELETE( DrawStruct );
}
else
{
DrawList = Screen->EEDrawList;
while( DrawList && DrawList->Next() )
{
if( DrawList->Next() == PickedList->m_PickedStruct )
{
DrawList->SetNext( DrawList->Next()->Next() );
SAFE_DELETE( DrawStruct );
return;
}
DrawList = DrawList->Next();
}
}
PickedList = (DrawPickedStruct*) PickedList->Next();
}
}
else // structure usuelle */
{
if( DrawStruct == Screen->EEDrawList )

View File

@ -7,7 +7,6 @@
#include "gr_basic.h"
#include "common.h"
#include "class_drawpanel.h"
#include "class_drawpickedstruct.h"
#include "appl_wxstruct.h"
#include "program.h"
@ -127,32 +126,18 @@ void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref,
* If the list is of DrawPickStruct types then the picked item are drawn. *
*****************************************************************************/
void RedrawStructList( WinEDA_DrawPanel* panel, wxDC* DC,
SCH_ITEM* Structs, int DrawMode, int Color )
SCH_ITEM* Structlist, int DrawMode, int Color )
{
while( Structs )
while( Structlist )
{
if( Structs->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
{
SCH_ITEM* item =
(SCH_ITEM*) ( (DrawPickedStruct*) Structs )->m_PickedStruct;
// uncomment line below when there is a virtual EDA_BaseStruct::GetBoundingBox()
// if( panel->m_ClipBox.Intersects( item->GetBoundingBox() ) )
{
RedrawOneStruct( panel, DC, item, DrawMode, Color );
}
}
else
{
if( !(Structs->m_Flags & IS_MOVED) )
if( !(Structlist->m_Flags & IS_MOVED) )
{
// uncomment line below when there is a virtual EDA_BaseStruct::GetBoundingBox()
// if( panel->m_ClipBox.Intersects( Structs->GetBoundingBox() ) )
RedrawOneStruct( panel, DC, Structs, DrawMode, Color );
}
RedrawOneStruct( panel, DC, Structlist, DrawMode, Color );
}
Structs = Structs->Next();
Structlist = Structlist->Next();
}
}

View File

@ -11,7 +11,6 @@
#include "general.h"
#include "trigo.h"
#include "macros.h"
#include "class_drawpickedstruct.h"
#include "class_marker_sch.h"
#include "protos.h"
@ -118,9 +117,6 @@ SCH_ITEM* PickStruct( const wxPoint& refpos, BASE_SCREEN* screen, int SearchMask
}
/***********************************************************************/
int PickStruct( BLOCK_SELECTOR& aBlock, BASE_SCREEN* aScreen )
/************************************************************************/
/** Function PickStruct
* Search items in a block
@ -128,6 +124,7 @@ int PickStruct( BLOCK_SELECTOR& aBlock, BASE_SCREEN* aScreen )
* @param aBlock a BLOCK_SELECTOR that gives the search area boundary
* list of items is stored in aBlock
*/
int PickItemsInBlock( BLOCK_SELECTOR& aBlock, BASE_SCREEN* aScreen )
{
int x, y, OrigX, OrigY;
int itemcount = 0;
@ -355,13 +352,10 @@ bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
}
break;
case DRAW_PICK_ITEM_STRUCT_TYPE:
break;
default:
{
wxString msg;
msg.Printf( wxT( "SnapPoint2() error: unexpected strct type %d (" ), DrawList->Type() );
msg.Printf( wxT( "SnapPoint2() error: unexpected struct type %d (" ), DrawList->Type() );
msg << DrawList->GetClass() << wxT( ")" );
DisplayError( NULL, msg );
break;
@ -540,9 +534,6 @@ bool DrawStructInBox( int x1, int y1, int x2, int y2, SCH_ITEM* DrawStruct )
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
break;
case DRAW_PICK_ITEM_STRUCT_TYPE:
break;
default:
msg.Printf(
wxT( "DrawStructInBox() Err: unexpected StructType %d (" ),

View File

@ -533,7 +533,6 @@ static void ListeObjetConnection( DrawSheetPath* sheetlist,
break;
case DRAW_PICK_ITEM_STRUCT_TYPE:
case DRAW_POLYLINE_STRUCT_TYPE:
case DRAW_BUSENTRY_STRUCT_TYPE:
case DRAW_MARKER_STRUCT_TYPE:

View File

@ -55,7 +55,6 @@ void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
return;
case SCREEN_STRUCT_TYPE:
case DRAW_PICK_ITEM_STRUCT_TYPE:
DisplayError( this,
wxT( "OnLeftClick err: unexpected type for Place" ) );
DrawStruct->m_Flags = 0;

View File

@ -750,9 +750,6 @@ void PlotDrawlist( Plotter* plotter, SCH_ITEM* aDrawlist )
PlotLibPart( plotter, DrawLibItem );
break;
case DRAW_PICK_ITEM_STRUCT_TYPE:
break;
case DRAW_POLYLINE_STRUCT_TYPE:
break;

View File

@ -109,10 +109,10 @@ LibDrawPin* LocatePinByNumber( const wxString & ePin_Number,
SCH_COMPONENT * LocateSmallestComponent( SCH_SCREEN * Screen );
/* Recherche du plus petit (en surface) composant pointe par la souris */
int PickStruct(BLOCK_SELECTOR& aBlock, BASE_SCREEN* screen );
SCH_ITEM * PickStruct(const wxPoint & refpos, BASE_SCREEN* screen, int SearchMask);
/* 2 functions PickStruct:
Search in block, or Search at location pos
int PickItemsInBlock(BLOCK_SELECTOR& aBlock, BASE_SCREEN* screen );
/* function PickStruct:
Search at location pos
SearchMask = (bitwise OR):
LIBITEM
@ -145,6 +145,7 @@ SCH_ITEM * PickStruct(const wxPoint & refpos, BASE_SCREEN* screen, int SearchMas
Positon search:
pointeur sur la structure.
Si pas de structures selectionnees: retourne NULL */
SCH_ITEM * PickStruct(const wxPoint & refpos, BASE_SCREEN* screen, int SearchMask);
@ -325,11 +326,14 @@ void SchematicCleanUp(SCH_SCREEN * screen, wxDC * DC);
void BreakSegmentOnJunction( SCH_SCREEN * Screen );
/* Routine creant des debuts / fin de segment (BUS ou WIRES) sur les jonctions
et les raccords */
DrawPickedStruct * BreakSegment(SCH_SCREEN * screen, wxPoint breakpoint,
bool PutInUndoList = FALSE);
/* Coupe un segment ( BUS, WIRE ) en 2 au point breakpoint,
- si ce point est sur le segment
- extremites non comprises */
/* Break a segment ( BUS, WIRE ) int 2 segments at location aBreakpoint,
* if aBreakpoint in on segment segment
* ( excluding ends)
* fill aPicklist with modified items if non null
*/
void BreakSegment(SCH_SCREEN * aScreen, wxPoint aBreakpoint,
PICKED_ITEMS_LIST * aPicklist = NULL);
/**************/
/* EECLASS.CPP */

View File

@ -9,7 +9,6 @@
#include "class_drawpanel.h"
#include "confirm.h"
#include "eda_doc.h"
#include "class_drawpickedstruct.h"
#include "class_marker_sch.h"
#include "program.h"
@ -329,20 +328,20 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_DELETE_NODE:
case ID_POPUP_SCH_DELETE_CONNECTION:
DrawPanel->MouseToCursorSchema();
DeleteConnection( &dc,
id == ID_POPUP_SCH_DELETE_CONNECTION ? TRUE : FALSE );
DeleteConnection( id == ID_POPUP_SCH_DELETE_CONNECTION ? TRUE : FALSE );
screen->SetCurItem( NULL );
g_ItemToRepeat = NULL;
TestDanglingEnds( screen->EEDrawList, &dc );
DrawPanel->Refresh();
break;
case ID_POPUP_SCH_BREAK_WIRE:
{
DrawPickedStruct* ListForUndo;
DrawPanel->MouseToCursorSchema();
ListForUndo = BreakSegment( screen, screen->m_Curseur, TRUE );
if( ListForUndo )
SaveCopyInUndoList( (SCH_ITEM*) ListForUndo, IS_NEW | IS_CHANGED );
PICKED_ITEMS_LIST picklistForUndo;
BreakSegment( screen, screen->m_Curseur, &picklistForUndo );
if( picklistForUndo.GetCount() )
SaveCopyInUndoList( picklistForUndo, IS_NEW | IS_CHANGED );
TestDanglingEnds( screen->EEDrawList, &dc );
}
break;

View File

@ -5,7 +5,6 @@
#include "fctsys.h"
#include "common.h"
#include "confirm.h"
#include "class_drawpickedstruct.h"
#include "program.h"
#include "libcmp.h"
@ -173,8 +172,8 @@ void SwapData( EDA_BaseStruct* aItem, EDA_BaseStruct* aImage )
/***********************************************************************/
void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* ItemToCopy,
int flag_type_command )
void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* aItemToCopy,
int aCommandType )
/***********************************************************************/
/** function SaveCopyInUndoList
@ -201,110 +200,33 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* ItemToCopy,
SCH_ITEM* CopyOfItem;
PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
commandToUndo->m_UndoRedoType = flag_type_command;
ITEM_PICKER itemWrapper( ItemToCopy, flag_type_command );
commandToUndo->m_UndoRedoType = aCommandType;
ITEM_PICKER itemWrapper( aItemToCopy, aCommandType );
if( ItemToCopy )
{
switch( flag_type_command )
switch( aCommandType )
{
case IS_CHANGED: /* Create a copy of schematic */
if( ItemToCopy->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
{
DrawPickedStruct* PickedList = (DrawPickedStruct*) ItemToCopy;
while( PickedList )
{
CopyOfItem = DuplicateStruct( (SCH_ITEM*) PickedList->m_PickedStruct );
CopyOfItem->m_Flags = flag_type_command;
CopyOfItem = DuplicateStruct( aItemToCopy );
itemWrapper.m_Item = CopyOfItem;
itemWrapper.m_Link = (SCH_ITEM*) PickedList->m_PickedStruct;
itemWrapper.m_Link = aItemToCopy;
commandToUndo->PushItem( itemWrapper );
PickedList = PickedList->Next();
}
}
else
{
CopyOfItem = DuplicateStruct( ItemToCopy );
itemWrapper.m_Item = CopyOfItem;
itemWrapper.m_Link = ItemToCopy;
commandToUndo->PushItem( itemWrapper );
}
break;
case IS_NEW:
if( ItemToCopy->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
{
DrawPickedStruct* PickedList = (DrawPickedStruct*) ItemToCopy;
while( PickedList )
{
CopyOfItem = (SCH_ITEM*) PickedList->m_PickedStruct;
PickedList->m_PickedStruct = NULL;
PickedList->m_Flags = flag_type_command;
PickedList = PickedList->Next();
itemWrapper.m_Item = CopyOfItem;
commandToUndo->PushItem( itemWrapper );
}
}
else
{
commandToUndo->PushItem( itemWrapper );
}
break;
case IS_NEW | IS_CHANGED: // when more than one item, some are new, some are changed
if( ItemToCopy->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
{
DrawPickedStruct* PickedList = (DrawPickedStruct*) ItemToCopy;
while( PickedList )
{
CopyOfItem = (SCH_ITEM*) PickedList->m_PickedStruct;
PickedList->m_PickedStruct = NULL;
PickedList = PickedList->Next();
itemWrapper.m_Item = CopyOfItem;
itemWrapper.m_UndoRedoStatus = PickedList->m_Flags;
commandToUndo->PushItem( itemWrapper );
}
}
else
{
commandToUndo->PushItem( itemWrapper );
}
break;
case IS_WIRE_IMAGE:
commandToUndo->PushItem( itemWrapper );
break;
case IS_DELETED:
ItemToCopy->m_Flags = flag_type_command;
if( ItemToCopy->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
{
DrawPickedStruct* PickedList = (DrawPickedStruct*) ItemToCopy;
while( PickedList )
{
CopyOfItem = (SCH_ITEM*) PickedList->m_PickedStruct;
CopyOfItem->m_Flags = flag_type_command;
PickedList->m_Flags = flag_type_command;
PickedList = PickedList->Next();
itemWrapper.m_Item = CopyOfItem;
commandToUndo->PushItem( itemWrapper );
}
}
else
{
commandToUndo->PushItem( itemWrapper );
}
break;
default:
{
wxString msg;
msg.Printf( wxT( "SaveCopyInUndoList() error (unknown code %X)" ), flag_type_command );
msg.Printf( wxT( "SaveCopyInUndoList() error (unknown code %X)" ), aCommandType );
DisplayError( this, msg );
}
break;
}
}
/* Save the copy in undo list */
GetScreen()->PushCommandToUndoList( commandToUndo );

View File

@ -54,7 +54,6 @@ enum KICAD_T {
TYPE_SCH_GLOBALLABEL,
TYPE_SCH_HIERLABEL,
TYPE_SCH_COMPONENT,
DRAW_PICK_ITEM_STRUCT_TYPE,
DRAW_SEGMENT_STRUCT_TYPE,
DRAW_BUSENTRY_STRUCT_TYPE,
DRAW_SHEET_STRUCT_TYPE,

View File

@ -1,73 +0,0 @@
/*****************************************************************************/
/* sch_item_struct.h : Basic classes for most eeschema items descriptions */
/*****************************************************************************/
#ifndef __CLASS_DRAWPICKEDSTRUCT_H__
#define __CLASS_DRAWPICKEDSTRUCT_H__
#include "base_struct.h"
/**
* Class DrawPickedStruct
* holds structures picked by pick events (like block selection).
* This class has only one useful member: .m_PickedStruct, used as a link.
* It is used to create a linked list of selected items (in block selection).
* Each DrawPickedStruct item has is member: .m_PickedStruct pointing the
* real selected item.
*/
class DrawPickedStruct : public EDA_BaseStruct
{
public:
EDA_BaseStruct * m_PickedStruct;
public:
DrawPickedStruct( EDA_BaseStruct * pickedstruct = NULL );
~DrawPickedStruct();
void Place( WinEDA_DrawFrame* frame, wxDC* DC ) { };
void DeleteWrapperList();
DrawPickedStruct* Next() { return (DrawPickedStruct*) Pnext; }
EDA_Rect GetBoundingBox();
/**
* Function GetBoundingBoxUnion
* returns the union of all the BoundingBox rectangles of all held items
* in the picklist whose list head is this DrawPickedStruct.
* @return EDA_Rect - The combined, composite, bounding box.
*/
EDA_Rect GetBoundingBoxUnion();
wxString GetClass() const { return wxT( "DrawPickedStruct" ); }
/**
* Function Draw
* Do nothing, needed for SCH_ITEM compat.
*/
void Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
int draw_mode,
int Color = -1 )
{
}
/**
* Function Save
* Do nothing, needed for SCH_ITEM compat.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const
{
return false;
}
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os );
#endif
};
#endif /* __CLASS_DRAWPICKEDSTRUCT_H__ */

View File

@ -300,7 +300,7 @@ private:
void BeginSegment( wxDC* DC, int type );
void EndSegment( wxDC* DC );
void DeleteCurrentSegment( wxDC* DC );
void DeleteConnection( wxDC* DC, bool DeleteFullConnection );
void DeleteConnection( bool DeleteFullConnection );
// graphic lines
void Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC );