Commit 8ec8cf3f authored by charras's avatar charras

Rework on undo/redo and block functions

parent 6d14766e
...@@ -4,6 +4,14 @@ KiCad ChangeLog 2009 ...@@ -4,6 +4,14 @@ KiCad ChangeLog 2009
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2009-july-25 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================
++all
Rework on undo/redo and block functions
Better and simpler coding of block and undo/redo functions
The goal is to have the same functions in eeschema and pcbnew.
and have a full undo/redo in pcbnew.
2009-july-18 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr> 2009-july-18 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
================================================================================ ================================================================================
++pcbnew ++pcbnew
......
/****************************************************/ /****************************************************/
/* Routines de gestion des commandes sur blocks */ /* Routines de gestion des commandes sur blocks */
/* (section commune eeschema/pcbnew... */ /* (section commune eeschema/pcbnew... */
/****************************************************/ /****************************************************/
/* Fichier common.cpp */ /* Fichier common.cpp */
...@@ -19,31 +19,30 @@ ...@@ -19,31 +19,30 @@
/*******************/ /*******************/
/* DrawBlockStruct */ /* BLOCK_SELECTOR */
/*******************/ /*******************/
/****************************************************************************/ /****************************************************************************/
DrawBlockStruct::DrawBlockStruct() : BLOCK_SELECTOR::BLOCK_SELECTOR() :
EDA_BaseStruct( BLOCK_LOCATE_STRUCT_TYPE ) EDA_BaseStruct( BLOCK_LOCATE_STRUCT_TYPE ),
, EDA_Rect() EDA_Rect()
/****************************************************************************/ /****************************************************************************/
{ {
m_State = STATE_NO_BLOCK; /* Etat (enum BlockState) du block */ m_State = STATE_NO_BLOCK; /* Etat (enum BlockState) du block */
m_Command = BLOCK_IDLE; /* Type (enum CmdBlockType) d'operation */ m_Command = BLOCK_IDLE; /* Type (enum CmdBlockType) d'operation */
m_BlockDrawStruct = NULL; /* pointeur sur la structure */ m_Color = BROWN;
m_Color = BROWN;
} }
/****************************************/ /****************************************/
DrawBlockStruct::~DrawBlockStruct() BLOCK_SELECTOR::~BLOCK_SELECTOR()
/****************************************/ /****************************************/
{ {
} }
/***************************************************************/ /***************************************************************/
void DrawBlockStruct::SetMessageBlock( WinEDA_DrawFrame* frame ) void BLOCK_SELECTOR::SetMessageBlock( WinEDA_DrawFrame* frame )
/***************************************************************/ /***************************************************************/
/* /*
...@@ -112,34 +111,82 @@ void DrawBlockStruct::SetMessageBlock( WinEDA_DrawFrame* frame ) ...@@ -112,34 +111,82 @@ void DrawBlockStruct::SetMessageBlock( WinEDA_DrawFrame* frame )
/**************************************************************/ /**************************************************************/
void DrawBlockStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC ) void BLOCK_SELECTOR::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
const wxPoint& aOffset,
int aDrawMode,
int aColor )
/**************************************************************/ /**************************************************************/
{ {
int w = panel->GetScreen()->Scale( GetWidth() ); int w = aPanel->GetScreen()->Scale( GetWidth() );
int h = panel->GetScreen()->Scale( GetHeight() ); int h = aPanel->GetScreen()->Scale( GetHeight() );
GRSetDrawMode( aDC, aDrawMode );
if( w == 0 || h == 0 ) if( w == 0 || h == 0 )
GRLine( &panel->m_ClipBox, DC, GetX(), GetY(), GRLine( &aPanel->m_ClipBox, aDC, GetX() + aOffset.x, GetY() + aOffset.y,
GetRight(), GetBottom(), 0, m_Color ); GetRight() + aOffset.x, GetBottom() + aOffset.y, 0, aColor );
else else
GRRect( &panel->m_ClipBox, DC, GetX(), GetY(), GRRect( &aPanel->m_ClipBox, aDC, GetX() + aOffset.x, GetY() + aOffset.y,
GetRight(), GetBottom(), 0, m_Color ); GetRight() + aOffset.x, GetBottom() + aOffset.y, 0, aColor );
} }
/*************************************************************************/
void BLOCK_SELECTOR::InitData( WinEDA_DrawPanel* aPanel, const wxPoint& startpos )
/*************************************************************************/
/** function InitData
* Init the initial values of a BLOCK_SELECTOR, before starting a block command
*/
{
m_State = STATE_BLOCK_INIT;
SetOrigin( startpos );
SetSize( wxSize( 0, 0 ) );
m_ItemsSelection.ClearItemsList();
aPanel->ManageCurseur = DrawAndSizingBlockOutlines;
aPanel->ForceCloseManageCurseur = AbortBlockCurrentCommand;
}
/** Function ClearItemsList
* delete only the list of EDA_BaseStruct * pointers, NOT the pointed data itself
*/
void BLOCK_SELECTOR::ClearItemsList()
{
m_ItemsSelection.ClearItemsList();
}
/** Function ClearListAndDeleteItems
* delete only the list of EDA_BaseStruct * pointers, AND the data pinted by m_Item
*/
void BLOCK_SELECTOR::ClearListAndDeleteItems()
{
m_ItemsSelection.ClearListAndDeleteItems();
}
/** Function PushItem
* Add aItem to the list of items
* @param aItem = an ITEM_PICKER to add to the list
*/
void BLOCK_SELECTOR::PushItem( ITEM_PICKER& aItem )
{
m_ItemsSelection.PushItem( aItem );
}
/*************************************************************************/ /*************************************************************************/
bool WinEDA_DrawFrame::HandleBlockBegin( wxDC* DC, int key, bool WinEDA_DrawFrame::HandleBlockBegin( wxDC* DC, int key,
const wxPoint& startpos ) const wxPoint& startpos )
/*************************************************************************/ /*************************************************************************/
/* First command block function: /* First command block function:
* Init the Block infos: command type, initial position, and other variables.. * Init the Block infos: command type, initial position, and other variables..
*/ */
{ {
DrawBlockStruct* Block = & GetBaseScreen()->BlockLocate; BLOCK_SELECTOR* Block = &GetBaseScreen()->m_BlockLocate;
if( ( Block->m_Command != BLOCK_IDLE ) if( ( Block->m_Command != BLOCK_IDLE )
|| ( Block->m_State != STATE_NO_BLOCK ) ) || ( Block->m_State != STATE_NO_BLOCK ) )
return FALSE; return FALSE;
Block->m_Flags = 0; Block->m_Flags = 0;
...@@ -163,26 +210,26 @@ bool WinEDA_DrawFrame::HandleBlockBegin( wxDC* DC, int key, ...@@ -163,26 +210,26 @@ bool WinEDA_DrawFrame::HandleBlockBegin( wxDC* DC, int key,
case BLOCK_MIRROR_X: case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y: /* mirror */ case BLOCK_MIRROR_Y: /* mirror */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
InitBlockLocateDatas( DrawPanel, startpos ); Block->InitData( DrawPanel, startpos );
break; break;
case BLOCK_PASTE: case BLOCK_PASTE:
InitBlockLocateDatas( DrawPanel, startpos ); Block->InitData( DrawPanel, startpos );
Block->m_BlockLastCursorPosition.x = 0; Block->m_BlockLastCursorPosition.x = 0;
Block->m_BlockLastCursorPosition.y = 0; Block->m_BlockLastCursorPosition.y = 0;
InitBlockPasteInfos(); InitBlockPasteInfos();
if( Block->m_BlockDrawStruct == NULL ) /* No data to paste */ if( Block->m_ItemsSelection.GetCount() == 0 ) /* No data to paste */
{ {
DisplayError( this, wxT( "No Block to paste" ), 20 ); DisplayError( this, wxT( "No Block to paste" ), 20 );
GetBaseScreen()->BlockLocate.m_Command = BLOCK_IDLE; GetBaseScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
return TRUE; return TRUE;
} }
if( DrawPanel->ManageCurseur == NULL ) if( DrawPanel->ManageCurseur == NULL )
{ {
Block->m_BlockDrawStruct = NULL; Block->m_ItemsSelection.ClearItemsList();
DisplayError( this, DisplayError( this,
wxT( "WinEDA_DrawFrame::HandleBlockBegin() Err: ManageCurseur NULL" ) ); wxT( "WinEDA_DrawFrame::HandleBlockBegin() Err: ManageCurseur NULL" ) );
return TRUE; return TRUE;
} }
Block->m_State = STATE_BLOCK_MOVE; Block->m_State = STATE_BLOCK_MOVE;
...@@ -196,102 +243,37 @@ bool WinEDA_DrawFrame::HandleBlockBegin( wxDC* DC, int key, ...@@ -196,102 +243,37 @@ bool WinEDA_DrawFrame::HandleBlockBegin( wxDC* DC, int key,
Block->m_Command; Block->m_Command;
DisplayError( this, msg ); DisplayError( this, msg );
} }
break; break;
} }
Block->SetMessageBlock( this ); Block->SetMessageBlock( this );
return TRUE; return TRUE;
} }
/******************************************************************/
void AbortBlockCurrentCommand( WinEDA_DrawPanel* Panel, wxDC* DC )
/******************************************************************/
/*
* Cancel Current block operation.
*/
{
BASE_SCREEN* screen = Panel->GetScreen();
if( Panel->ManageCurseur ) /* Erase current drawing on screen */
{
Panel->ManageCurseur( Panel, DC, FALSE ); /* Efface dessin fantome */
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
screen->SetCurItem( NULL );
/* Delete the picked wrapper if this is a picked list. */
if( (screen->BlockLocate.m_Command != BLOCK_PASTE)
&& screen->BlockLocate.m_BlockDrawStruct )
{
if( screen->BlockLocate.m_BlockDrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
{
DrawPickedStruct* PickedList;
PickedList = (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct;
PickedList->DeleteWrapperList();
}
screen->BlockLocate.m_BlockDrawStruct = NULL;
}
}
screen->BlockLocate.m_Flags = 0;
screen->BlockLocate.m_State = STATE_NO_BLOCK;
screen->BlockLocate.m_Command = BLOCK_ABORT;
Panel->m_Parent->HandleBlockEnd( DC );
screen->BlockLocate.m_Command = BLOCK_IDLE;
Panel->m_Parent->DisplayToolMsg( wxEmptyString );
}
/*************************************************************************/
void InitBlockLocateDatas( WinEDA_DrawPanel* Panel, const wxPoint& startpos )
/*************************************************************************/
/*
* Init the initial values of a BlockLocate, before starting a block command
*/
{
BASE_SCREEN* screen = Panel->GetScreen();
screen->BlockLocate.m_State = STATE_BLOCK_INIT;
screen->BlockLocate.SetOrigin( startpos );
screen->BlockLocate.SetSize( wxSize( 0, 0 ) );
screen->BlockLocate.SetNext( NULL );
screen->BlockLocate.m_BlockDrawStruct = NULL;
Panel->ManageCurseur = DrawAndSizingBlockOutlines;
Panel->ForceCloseManageCurseur = AbortBlockCurrentCommand;
}
/********************************************************************************/ /********************************************************************************/
void DrawAndSizingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) void DrawAndSizingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/********************************************************************************/ /********************************************************************************/
/* Redraw the outlines of the block which shows the search area for block commands /* Redraw the outlines of the block which shows the search area for block commands
* The first point of the rectangle showing the area is initialised * The first point of the rectangle showing the area is initialised
* by InitBlockLocateDatas(). * by Initm_BlockLocateDatas().
* The other point of the rectangle is the mouse cursor * The other point of the rectangle is the mouse cursor
*/ */
{ {
DrawBlockStruct* PtBlock; BLOCK_SELECTOR* PtBlock;
PtBlock = &panel->GetScreen()->BlockLocate; PtBlock = &panel->GetScreen()->m_BlockLocate;
PtBlock->m_MoveVector = wxPoint( 0, 0 ); PtBlock->m_MoveVector = wxPoint( 0, 0 );
GRSetDrawMode( DC, g_XorMode );
/* Effacement ancien cadre */ /* Effacement ancien cadre */
if( erase ) if( erase )
PtBlock->Draw( panel, DC ); PtBlock->Draw( panel, DC, wxPoint( 0, 0 ), g_XorMode, PtBlock->m_Color );
PtBlock->m_BlockLastCursorPosition = panel->GetScreen()->m_Curseur; PtBlock->m_BlockLastCursorPosition = panel->GetScreen()->m_Curseur;
PtBlock->SetEnd( panel->GetScreen()->m_Curseur ); PtBlock->SetEnd( panel->GetScreen()->m_Curseur );
PtBlock->Draw( panel, DC ); PtBlock->Draw( panel, DC, wxPoint( 0, 0 ), g_XorMode, PtBlock->m_Color );
if( PtBlock->m_State == STATE_BLOCK_INIT ) if( PtBlock->m_State == STATE_BLOCK_INIT )
{ {
...@@ -300,3 +282,37 @@ void DrawAndSizingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -300,3 +282,37 @@ void DrawAndSizingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
PtBlock->m_State = STATE_BLOCK_END; PtBlock->m_State = STATE_BLOCK_END;
} }
} }
/******************************************************************/
void AbortBlockCurrentCommand( WinEDA_DrawPanel* Panel, wxDC* DC )
/******************************************************************/
/*
* Cancel Current block operation.
*/
{
BASE_SCREEN* screen = Panel->GetScreen();
if( Panel->ManageCurseur ) /* Erase current drawing on screen */
{
Panel->ManageCurseur( Panel, DC, FALSE ); /* Efface dessin fantome */
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
screen->SetCurItem( NULL );
/* Delete the picked wrapper if this is a picked list. */
if( screen->m_BlockLocate.m_Command != BLOCK_PASTE )
screen->m_BlockLocate.ClearItemsList();
}
screen->m_BlockLocate.m_Flags = 0;
screen->m_BlockLocate.m_State = STATE_NO_BLOCK;
screen->m_BlockLocate.m_Command = BLOCK_ABORT;
Panel->m_Parent->HandleBlockEnd( DC );
screen->m_BlockLocate.m_Command = BLOCK_IDLE;
Panel->m_Parent->DisplayToolMsg( wxEmptyString );
}
...@@ -67,6 +67,14 @@ void PICKED_ITEMS_LIST::PICKED_ITEMS_LIST::ClearItemsList() ...@@ -67,6 +67,14 @@ void PICKED_ITEMS_LIST::PICKED_ITEMS_LIST::ClearItemsList()
m_ItemsList.clear(); m_ItemsList.clear();
} }
void PICKED_ITEMS_LIST::ClearListAndDeleteItems()
{
for(unsigned ii = 0; ii < m_ItemsList.size(); ii++ )
delete m_ItemsList[ii].m_Item;
m_ItemsList.clear();
}
ITEM_PICKER PICKED_ITEMS_LIST::GetItemWrapper( unsigned int aIdx ) ITEM_PICKER PICKED_ITEMS_LIST::GetItemWrapper( unsigned int aIdx )
{ {
ITEM_PICKER picker; ITEM_PICKER picker;
...@@ -160,6 +168,20 @@ bool PICKED_ITEMS_LIST::RemoveItem( unsigned aIdx ) ...@@ -160,6 +168,20 @@ bool PICKED_ITEMS_LIST::RemoveItem( unsigned aIdx )
return true; return true;
} }
/** Function CopyList
* copy all data from aSource
* Items picked are not copied. just pointer on them are copied
*/
void PICKED_ITEMS_LIST::CopyList(const PICKED_ITEMS_LIST & aSource)
{
ITEM_PICKER picker;
for(unsigned ii = 0; ii < aSource.GetCount(); ii++ )
{
picker = aSource.m_ItemsList[ii];
PushItem(picker);
}
}
/**********************************************/ /**********************************************/
/********** UNDO_REDO_CONTAINER ***************/ /********** UNDO_REDO_CONTAINER ***************/
......
...@@ -35,7 +35,7 @@ void WinEDA_DrawFrame::CopyToClipboard( wxCommandEvent& event ) ...@@ -35,7 +35,7 @@ void WinEDA_DrawFrame::CopyToClipboard( wxCommandEvent& event )
if( event.GetId() == ID_GEN_COPY_BLOCK_TO_CLIPBOARD ) if( event.GetId() == ID_GEN_COPY_BLOCK_TO_CLIPBOARD )
{ {
if( GetBaseScreen()->BlockLocate.m_Command != BLOCK_IDLE ) if( GetBaseScreen()->m_BlockLocate.m_Command != BLOCK_IDLE )
DrawPanel->SetCursor( wxCursor( DrawPanel->m_PanelCursor = DrawPanel->SetCursor( wxCursor( DrawPanel->m_PanelCursor =
DrawPanel->m_PanelDefaultCursor ) ); DrawPanel->m_PanelDefaultCursor ) );
...@@ -74,13 +74,13 @@ bool DrawPage( WinEDA_DrawPanel* panel ) ...@@ -74,13 +74,13 @@ bool DrawPage( WinEDA_DrawPanel* panel )
/* scale is the ratio resolution/internal units */ /* scale is the ratio resolution/internal units */
float scale = 82.0 / panel->m_Parent->m_InternalUnits; float scale = 82.0 / panel->m_Parent->m_InternalUnits;
if( ActiveScreen->BlockLocate.m_Command != BLOCK_IDLE ) if( ActiveScreen->m_BlockLocate.m_Command != BLOCK_IDLE )
{ {
DrawBlock = TRUE; DrawBlock = TRUE;
DrawArea.SetX( (int) ( ActiveScreen->BlockLocate.GetX() ) ); DrawArea.SetX( ActiveScreen->m_BlockLocate.GetX() );
DrawArea.SetY( (int) ( ActiveScreen->BlockLocate.GetY() ) ); DrawArea.SetY( ActiveScreen->m_BlockLocate.GetY() );
DrawArea.SetWidth( (int) ( ActiveScreen->BlockLocate.GetWidth() ) ); DrawArea.SetWidth( ActiveScreen->m_BlockLocate.GetWidth() );
DrawArea.SetHeight( (int) ( ActiveScreen->BlockLocate.GetHeight() ) ); DrawArea.SetHeight( ActiveScreen->m_BlockLocate.GetHeight() );
} }
/* modification des cadrages et reglages locaux */ /* modification des cadrages et reglages locaux */
......
...@@ -488,7 +488,7 @@ int WinEDA_DrawFrame::ReturnBlockCommand( int key ) ...@@ -488,7 +488,7 @@ int WinEDA_DrawFrame::ReturnBlockCommand( int key )
void WinEDA_DrawFrame::InitBlockPasteInfos() void WinEDA_DrawFrame::InitBlockPasteInfos()
{ {
GetBaseScreen()->BlockLocate.m_BlockDrawStruct = NULL; GetBaseScreen()->m_BlockLocate.ClearItemsList();
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
} }
...@@ -652,7 +652,31 @@ void WinEDA_DrawFrame::SetLanguage( wxCommandEvent& event ) ...@@ -652,7 +652,31 @@ void WinEDA_DrawFrame::SetLanguage( wxCommandEvent& event )
} }
} }
/* used in UpdateStatusBar() when coordinates are in mm
* try to approximate a coordinate (in 0.001 mm) to an easy to read number
* ie round the unit value to 0 if unit is 1 or 2, or 8 or 9
*/
double Round_To_0(double x)
{
long long ix = wxRound(x * 1000); // ix is in 0.001 mm
if ( x < 0 ) NEGATE(ix);
int remainder = ix%10; // remainder is in 0.001 mm
if ( remainder <= 2 )
ix -= remainder; // truncate to the near number
else if (remainder >= 8 )
ix += 10 - remainder; // round to near number
if ( x < 0 ) NEGATE(ix);
return (double)ix/1000.0;
}
/** Function UpdateStatusBar()
* Displays in the bottom of the main window a stust:
* - Absolute Cursor coordinates
* - Relative Cursor coordinates (relative to the last coordinate stored when actiavte the space bar)
* ( in this status is also displayed the zoom level, but this is not made by this function)
*/
void WinEDA_DrawFrame::UpdateStatusBar() void WinEDA_DrawFrame::UpdateStatusBar()
{ {
wxString Line; wxString Line;
...@@ -670,20 +694,30 @@ void WinEDA_DrawFrame::UpdateStatusBar() ...@@ -670,20 +694,30 @@ void WinEDA_DrawFrame::UpdateStatusBar()
SetStatusText( Line, 1 ); SetStatusText( Line, 1 );
/* Display absolute coordinates: */ /* Display absolute coordinates: */
Line.Printf( g_UnitMetric ? wxT( "X %.3f Y %.3f" ) : wxT( "X %.4f Y %.4f" ), double dXpos = To_User_Unit( g_UnitMetric, screen->m_Curseur.x, m_InternalUnits );
To_User_Unit( g_UnitMetric, screen->m_Curseur.x, double dYpos = To_User_Unit( g_UnitMetric, screen->m_Curseur.y, m_InternalUnits );
m_InternalUnits ), /* When using mm the conversion from 1/10000 inch to mm can give some non easy to read numbers,
To_User_Unit( g_UnitMetric, screen->m_Curseur.y, * like 1.999 or 2.001 that be better if displayed 2.000, so small diffs are filtered here.
m_InternalUnits ) ); */
if ( g_UnitMetric )
{
dXpos = Round_To_0(dXpos);
dYpos = Round_To_0(dYpos);
}
Line.Printf( g_UnitMetric ? wxT( "X %.3f Y %.3f" ) : wxT( "X %.4f Y %.4f" ), dXpos, dYpos );
SetStatusText( Line, 2 ); SetStatusText( Line, 2 );
/* Display relative coordinates: */ /* Display relative coordinates: */
dx = screen->m_Curseur.x - screen->m_O_Curseur.x; dx = screen->m_Curseur.x - screen->m_O_Curseur.x;
dy = screen->m_Curseur.y - screen->m_O_Curseur.y; dy = screen->m_Curseur.y - screen->m_O_Curseur.y;
dXpos = To_User_Unit( g_UnitMetric, dx, m_InternalUnits );
Line.Printf( g_UnitMetric ? wxT( "x %.3f y %.3f" ) : wxT( "x %.4f y %.4f" ), dYpos = To_User_Unit( g_UnitMetric, dy, m_InternalUnits );
To_User_Unit( g_UnitMetric, dx, m_InternalUnits ), if ( g_UnitMetric )
To_User_Unit( g_UnitMetric, dy, m_InternalUnits ) ); {
dXpos = Round_To_0(dXpos);
dYpos = Round_To_0(dYpos);
}
Line.Printf( g_UnitMetric ? wxT( "x %.3f y %.3f" ) : wxT( "x %.4f y %.4f" ), dXpos, dYpos );
SetStatusText( Line, 3 ); SetStatusText( Line, 3 );
} }
......
...@@ -1095,7 +1095,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -1095,7 +1095,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
} }
else if( event.LeftUp() ) else if( event.LeftUp() )
{ {
if( screen->BlockLocate.m_State==STATE_NO_BLOCK // A block command is in progress: a left up is the end of block if( screen->m_BlockLocate.m_State==STATE_NO_BLOCK // A block command is in progress: a left up is the end of block
&& !s_IgnoreNextLeftButtonRelease ) // This is the end of a double click, already seen && !s_IgnoreNextLeftButtonRelease ) // This is the end of a double click, already seen
m_Parent->OnLeftClick( &DC, screen->m_MousePositionInPixels ); m_Parent->OnLeftClick( &DC, screen->m_MousePositionInPixels );
...@@ -1111,7 +1111,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -1111,7 +1111,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
s_IgnoreNextLeftButtonRelease = false; s_IgnoreNextLeftButtonRelease = false;
} }
if( event.ButtonUp( 2 ) && (screen->BlockLocate.m_State == STATE_NO_BLOCK) ) if( event.ButtonUp( 2 ) && (screen->m_BlockLocate.m_State == STATE_NO_BLOCK) )
{ {
// The middle button has been released, with no block command: // The middle button has been released, with no block command:
// We use it for a zoom center at cursor position command // We use it for a zoom center at cursor position command
...@@ -1158,14 +1158,14 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -1158,14 +1158,14 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
if( m_Block_Enable && !(localbutt & GR_M_DCLICK) ) if( m_Block_Enable && !(localbutt & GR_M_DCLICK) )
{ {
if( (screen->BlockLocate.m_Command == BLOCK_IDLE) if( (screen->m_BlockLocate.m_Command == BLOCK_IDLE)
|| (screen->BlockLocate.m_State == STATE_NO_BLOCK) ) || (screen->m_BlockLocate.m_State == STATE_NO_BLOCK) )
{ {
screen->BlockLocate.SetOrigin( m_CursorStartPos ); screen->m_BlockLocate.SetOrigin( m_CursorStartPos );
} }
if( event.LeftDown() || event.MiddleDown() ) if( event.LeftDown() || event.MiddleDown() )
{ {
if( screen->BlockLocate.m_State == STATE_BLOCK_MOVE ) if( screen->m_BlockLocate.m_State == STATE_BLOCK_MOVE )
{ {
m_AutoPAN_Request = FALSE; m_AutoPAN_Request = FALSE;
m_Parent->HandleBlockPlace( &DC ); m_Parent->HandleBlockPlace( &DC );
...@@ -1177,7 +1177,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -1177,7 +1177,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
&& ManageCurseur == NULL && ManageCurseur == NULL
&& ForceCloseManageCurseur == NULL ) && ForceCloseManageCurseur == NULL )
{ // Mouse is dragging: if no block in progress: start a block command { // Mouse is dragging: if no block in progress: start a block command
if( screen->BlockLocate.m_State == STATE_NO_BLOCK ) if( screen->m_BlockLocate.m_State == STATE_NO_BLOCK )
{ // Start a block command { // Start a block command
int cmd_type = kbstat; int cmd_type = kbstat;
...@@ -1217,10 +1217,10 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -1217,10 +1217,10 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
*/ */
#define BLOCK_MINSIZE_LIMIT 1 #define BLOCK_MINSIZE_LIMIT 1
bool BlockIsSmall = bool BlockIsSmall =
( ABS( screen->Scale( screen->BlockLocate.GetWidth() ) ) < BLOCK_MINSIZE_LIMIT) ( ABS( screen->Scale( screen->m_BlockLocate.GetWidth() ) ) < BLOCK_MINSIZE_LIMIT)
&& ( ABS( screen->Scale( screen->BlockLocate.GetHeight() ) ) < BLOCK_MINSIZE_LIMIT); && ( ABS( screen->Scale( screen->m_BlockLocate.GetHeight() ) ) < BLOCK_MINSIZE_LIMIT);
if( (screen->BlockLocate.m_State != STATE_NO_BLOCK) && BlockIsSmall ) if( (screen->m_BlockLocate.m_State != STATE_NO_BLOCK) && BlockIsSmall )
{ {
if( ForceCloseManageCurseur ) if( ForceCloseManageCurseur )
{ {
...@@ -1229,12 +1229,12 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -1229,12 +1229,12 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
} }
SetCursor( m_PanelCursor = m_PanelDefaultCursor ); SetCursor( m_PanelCursor = m_PanelDefaultCursor );
} }
else if( screen->BlockLocate.m_State == STATE_BLOCK_END ) else if( screen->m_BlockLocate.m_State == STATE_BLOCK_END )
{ {
m_AutoPAN_Request = FALSE; m_AutoPAN_Request = FALSE;
m_Parent->HandleBlockEnd( &DC ); m_Parent->HandleBlockEnd( &DC );
SetCursor( m_PanelCursor = m_PanelDefaultCursor ); SetCursor( m_PanelCursor = m_PanelDefaultCursor );
if( screen->BlockLocate.m_State == STATE_BLOCK_MOVE ) if( screen->m_BlockLocate.m_State == STATE_BLOCK_MOVE )
{ {
m_AutoPAN_Request = TRUE; m_AutoPAN_Request = TRUE;
SetCursor( m_PanelCursor = wxCURSOR_HAND ); SetCursor( m_PanelCursor = wxCURSOR_HAND );
...@@ -1244,10 +1244,10 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -1244,10 +1244,10 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
} }
// End of block command on a double click // End of block command on a double click
// To avoid an unwanted block move command if the move is moved while double click // To avoid an unwanted block move command if the mouse is moved while double clicking
if( localbutt == (int) (GR_M_LEFT_DOWN | GR_M_DCLICK) ) if( localbutt == (int) (GR_M_LEFT_DOWN | GR_M_DCLICK) )
{ {
if( screen->BlockLocate.m_Command != BLOCK_IDLE ) if( screen->m_BlockLocate.m_Command != BLOCK_IDLE )
{ {
if( ForceCloseManageCurseur ) if( ForceCloseManageCurseur )
{ {
...@@ -1261,7 +1261,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -1261,7 +1261,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
#if 0 #if 0
wxString msg_debug; wxString msg_debug;
msg_debug.Printf( " block state %d, cmd %d", msg_debug.Printf( " block state %d, cmd %d",
screen->BlockLocate.m_State, screen->BlockLocate.m_Command ); screen->m_BlockLocate.m_State, screen->m_BlockLocate.m_Command );
m_Parent->PrintMsg( msg_debug ); m_Parent->PrintMsg( msg_debug );
#endif #endif
......
...@@ -24,22 +24,23 @@ ...@@ -24,22 +24,23 @@
/* Fonctions exportees */ /* Fonctions exportees */
/* Fonctions Locales */ /* Fonctions Locales */
static SCH_ITEM* CopyStruct( WinEDA_DrawPanel* panel, static void DeleteItemsInList( WinEDA_DrawPanel* panel,
wxDC* DC, PICKED_ITEMS_LIST& aItemsList );
BASE_SCREEN* screen, static void PlaceItemsInList( SCH_SCREEN* aScreen, PICKED_ITEMS_LIST& aItemsList );
SCH_ITEM* DrawStruct ); static void MoveListOfItems( SCH_SCREEN* aScreen, PICKED_ITEMS_LIST& aItemsList );
static void CollectStructsToDrag( SCH_SCREEN* screen ); static void CopyItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList );
static void AddPickedItem( SCH_SCREEN* screen, wxPoint aPosition ); static void CollectStructsToDrag( SCH_SCREEN* screen );
static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, static void AddPickedItem( SCH_SCREEN* screen, wxPoint aPosition );
wxPoint& aPosition ); static LibEDA_BaseStruct* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxPoint& aPosition );
wxDC* DC, static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel,
bool erase ); wxDC* DC,
static SCH_ITEM* SaveStructListForPaste( SCH_ITEM* DrawStruct ); bool erase );
static bool MirrorStruct( WinEDA_DrawPanel* panel, wxDC* DC, static void SaveStructListForPaste( PICKED_ITEMS_LIST& aItemsList );
SCH_ITEM* DrawStruct, wxPoint& Center );
static void MirrorOneStruct( SCH_ITEM* DrawStruct, static void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& Center );
wxPoint& Center ); static void MirrorOneStruct( SCH_ITEM* DrawStruct,
wxPoint& Center );
/*************************************************************************/ /*************************************************************************/
int WinEDA_SchematicFrame::ReturnBlockCommand( int key ) int WinEDA_SchematicFrame::ReturnBlockCommand( int key )
...@@ -90,9 +91,9 @@ void WinEDA_SchematicFrame::InitBlockPasteInfos() ...@@ -90,9 +91,9 @@ void WinEDA_SchematicFrame::InitBlockPasteInfos()
/* Init the parameters used by the block paste command /* Init the parameters used by the block paste command
*/ */
{ {
DrawBlockStruct* block = &GetScreen()->BlockLocate; BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
block->m_BlockDrawStruct = g_BlockSaveDataList; block->m_ItemsSelection.CopyList( g_BlockSaveDataList.m_ItemsSelection );
DrawPanel->ManageCurseur = DrawMovingBlockOutlines; DrawPanel->ManageCurseur = DrawMovingBlockOutlines;
} }
...@@ -107,10 +108,8 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) ...@@ -107,10 +108,8 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
* - block copie & paste * - block copie & paste
*/ */
{ {
bool err = FALSE; bool err = FALSE;
DrawBlockStruct* block = &GetScreen()->BlockLocate; BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
SCH_ITEM* NewStruct = NULL;
if( DrawPanel->ManageCurseur == NULL ) if( DrawPanel->ManageCurseur == NULL )
{ {
...@@ -118,11 +117,11 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) ...@@ -118,11 +117,11 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
DisplayError( this, wxT( "HandleBlockPLace() : ManageCurseur = NULL" ) ); DisplayError( this, wxT( "HandleBlockPLace() : ManageCurseur = NULL" ) );
} }
if( block->m_BlockDrawStruct == NULL ) if( block->GetCount() == 0 )
{ {
wxString msg; wxString msg;
err = TRUE; err = TRUE;
msg.Printf( wxT( "HandleBlockPLace() : m_BlockDrawStruct = NULL (cmd %d, state %d)" ), msg.Printf( wxT( "HandleBlockPLace() error : no items to place (cmd %d, state %d)" ),
block->m_Command, block->m_State ); block->m_Command, block->m_State );
DisplayError( this, msg ); DisplayError( this, msg );
} }
...@@ -131,7 +130,7 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) ...@@ -131,7 +130,7 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
switch( block->m_Command ) switch( block->m_Command )
{ {
case BLOCK_IDLE: case BLOCK_IDLE:
err = TRUE; err = TRUE;
break; break;
...@@ -140,11 +139,10 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) ...@@ -140,11 +139,10 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
SaveCopyInUndoList( (SCH_ITEM*) block->m_BlockDrawStruct, IS_CHANGED ); SaveCopyInUndoList( block->m_ItemsSelection, IS_CHANGED );
MoveStruct( DrawPanel, DC, (SCH_ITEM*) block->m_BlockDrawStruct ); MoveListOfItems( GetScreen(), block->m_ItemsSelection );
block->m_BlockDrawStruct = NULL; block->ClearItemsList();
DrawPanel->Refresh( TRUE );
break; break;
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
...@@ -152,23 +150,19 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) ...@@ -152,23 +150,19 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
NewStruct = CopyStruct( DrawPanel, DC, CopyItemsInList( GetScreen(), block->m_ItemsSelection );
GetScreen(),
(SCH_ITEM*) block->m_BlockDrawStruct );
SaveCopyInUndoList( SaveCopyInUndoList( block->m_ItemsSelection,
NewStruct, (block->m_Command == BLOCK_PRESELECT_MOVE) ? IS_CHANGED : IS_NEW );
(block->m_Command ==
BLOCK_PRESELECT_MOVE) ? IS_CHANGED : IS_NEW );
block->m_BlockDrawStruct = NULL; block->ClearItemsList();
break; break;
case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */ case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
PasteStruct( DC ); PasteListOfItems( DC );
block->m_BlockDrawStruct = NULL; block->ClearItemsList();
break; break;
case BLOCK_ZOOM: // Handled by HandleBlockEnd() case BLOCK_ZOOM: // Handled by HandleBlockEnd()
...@@ -199,15 +193,15 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) ...@@ -199,15 +193,15 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
TestDanglingEnds( GetScreen()->EEDrawList, DC ); TestDanglingEnds( GetScreen()->EEDrawList, DC );
if( block->m_BlockDrawStruct ) if( block->GetCount() )
{ {
DisplayError( this, DisplayError( this, wxT( "HandleBlockPLace() error: some items left in buffer" ) );
wxT( "HandleBlockPLace() error: DrawStruct != Null" ) ); block->ClearItemsList();
block->m_BlockDrawStruct = NULL;
} }
SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor,
wxEmptyString ); wxEmptyString );
DrawPanel->Refresh( );
} }
...@@ -222,11 +216,11 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) ...@@ -222,11 +216,11 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
* -1 si commande terminee et composants trouves (block delete, block save) * -1 si commande terminee et composants trouves (block delete, block save)
*/ */
{ {
int ii = 0; int ii = 0;
bool zoom_command = FALSE; bool zoom_command = FALSE;
DrawBlockStruct* block = &GetScreen()->BlockLocate; BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
if( block->m_BlockDrawStruct ) if( block->GetCount() )
{ {
BlockState state = block->m_State; BlockState state = block->m_State;
CmdBlockType command = block->m_Command; CmdBlockType command = block->m_Command;
...@@ -236,8 +230,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) ...@@ -236,8 +230,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
block->m_Command = command; block->m_Command = command;
DrawPanel->ManageCurseur = DrawAndSizingBlockOutlines; DrawPanel->ManageCurseur = DrawAndSizingBlockOutlines;
DrawPanel->ForceCloseManageCurseur = AbortBlockCurrentCommand; DrawPanel->ForceCloseManageCurseur = AbortBlockCurrentCommand;
GetScreen()->m_Curseur.x = block->GetRight(); GetScreen()->m_Curseur = block->GetEnd();
GetScreen()->m_Curseur.y = block->GetBottom();
if( block->m_Command != BLOCK_ABORT ) if( block->m_Command != BLOCK_ABORT )
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
} }
...@@ -245,7 +238,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) ...@@ -245,7 +238,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
if( DrawPanel->ManageCurseur != NULL ) if( DrawPanel->ManageCurseur != NULL )
switch( block->m_Command ) switch( block->m_Command )
{ {
case BLOCK_IDLE: case BLOCK_IDLE:
DisplayError( this, wxT( "Error in HandleBlockPLace()" ) ); DisplayError( this, wxT( "Error in HandleBlockPLace()" ) );
break; break;
...@@ -254,14 +247,13 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) ...@@ -254,14 +247,13 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_MOVE: /* Move */ case BLOCK_MOVE: /* Move */
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
block->m_BlockDrawStruct = PickStruct( GetScreen()->m_BlockLocate, GetScreen() );
PickStruct( GetScreen()->BlockLocate, GetScreen(), SEARCHALL );
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
if( block->m_BlockDrawStruct != NULL ) if( block->GetCount() )
{ {
ii = 1; ii = 1;
CollectStructsToDrag( (SCH_SCREEN*) GetScreen() ); CollectStructsToDrag( GetScreen() );
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
DrawPanel->ManageCurseur = DrawMovingBlockOutlines; DrawPanel->ManageCurseur = DrawMovingBlockOutlines;
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
...@@ -276,39 +268,32 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) ...@@ -276,39 +268,32 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
break; break;
case BLOCK_DELETE: /* Delete */ case BLOCK_DELETE: /* Delete */
block->m_BlockDrawStruct = PickStruct( GetScreen()->m_BlockLocate, GetScreen() );
PickStruct( GetScreen()->BlockLocate,
GetScreen(), SEARCHALL );
DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE ); DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE );
if( block->m_BlockDrawStruct != NULL ) if( block->GetCount() )
{ {
ii = -1; ii = -1;
DeleteStruct( DrawPanel, DeleteItemsInList( DrawPanel, block->m_ItemsSelection );
DC,
(SCH_ITEM*) block->m_BlockDrawStruct );
GetScreen()->SetModify(); GetScreen()->SetModify();
} }
block->m_BlockDrawStruct = NULL; block->ClearItemsList();
TestDanglingEnds( GetScreen()->EEDrawList, DC ); TestDanglingEnds( GetScreen()->EEDrawList, DC );
DrawPanel->Refresh();
break; break;
case BLOCK_SAVE: /* Save */ case BLOCK_SAVE: /* Save */
block->m_BlockDrawStruct = PickStruct( GetScreen()->m_BlockLocate, GetScreen() );
PickStruct( GetScreen()->BlockLocate,
GetScreen(), SEARCHALL );
DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE ); DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE );
if( block->m_BlockDrawStruct != NULL ) if( block->GetCount() )
{ {
wxPoint oldpos = GetScreen()->m_Curseur; wxPoint oldpos = GetScreen()->m_Curseur;
GetScreen()->m_Curseur = wxPoint( 0, 0 ); GetScreen()->m_Curseur = wxPoint( 0, 0 );
SCH_ITEM* DrawStructCopy = SaveStructListForPaste( block->m_ItemsSelection );
SaveStructListForPaste( PlaceItemsInList( GetScreen(), g_BlockSaveDataList.m_ItemsSelection );
(SCH_ITEM*) block->m_BlockDrawStruct );
PlaceStruct( GetScreen(), DrawStructCopy );
GetScreen()->m_Curseur = oldpos; GetScreen()->m_Curseur = oldpos;
ii = -1; ii = -1;
} }
block->m_BlockDrawStruct = NULL; block->ClearItemsList();
break; break;
case BLOCK_PASTE: case BLOCK_PASTE:
...@@ -333,11 +318,10 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) ...@@ -333,11 +318,10 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
} }
if( block->m_Command == BLOCK_ABORT ) if( block->m_Command == BLOCK_ABORT )
{ /* clear struct.m_Flags */ {
/* clear struct.m_Flags */
EDA_BaseStruct* Struct; EDA_BaseStruct* Struct;
for( Struct = GetScreen()->EEDrawList; for( Struct = GetScreen()->EEDrawList; Struct != NULL; Struct = Struct->Next() )
Struct != NULL;
Struct = Struct->Next() )
Struct->m_Flags = 0; Struct->m_Flags = 0;
} }
...@@ -349,13 +333,11 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) ...@@ -349,13 +333,11 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
SetToolID( m_ID_current_state, SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString );
DrawPanel->m_PanelDefaultCursor,
wxEmptyString );
} }
if( zoom_command ) if( zoom_command )
Window_Zoom( GetScreen()->BlockLocate ); Window_Zoom( GetScreen()->m_BlockLocate );
return ii; return ii;
} }
...@@ -370,8 +352,8 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) ...@@ -370,8 +352,8 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
* A partir de la commande bloc move, peut executer une commande autre que bloc move. * A partir de la commande bloc move, peut executer une commande autre que bloc move.
*/ */
{ {
int ii = 0; int ii = 0;
DrawBlockStruct* block = &GetScreen()->BlockLocate; BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
if( block->m_Command != BLOCK_MOVE ) if( block->m_Command != BLOCK_MOVE )
return; return;
...@@ -394,21 +376,12 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) ...@@ -394,21 +376,12 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
* qui est devenue erronnee */ * qui est devenue erronnee */
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
if( block->m_BlockDrawStruct ) block->ClearItemsList();
{
if( block->m_BlockDrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE ) BreakSegmentOnJunction( GetScreen() );
{ /* Delete the picked wrapper if this is a picked list. */
DrawPickedStruct* PickedList; PickStruct( GetScreen()->m_BlockLocate, GetScreen() );
PickedList = (DrawPickedStruct*) block->m_BlockDrawStruct; if( block->GetCount() )
PickedList->DeleteWrapperList();
}
block->m_BlockDrawStruct = NULL;
}
BreakSegmentOnJunction( (SCH_SCREEN*) GetScreen() );
block->m_BlockDrawStruct =
PickStruct( GetScreen()->BlockLocate,
GetScreen(), SEARCHALL );
if( block->m_BlockDrawStruct != NULL )
{ {
ii = 1; ii = 1;
CollectStructsToDrag( (SCH_SCREEN*) GetScreen() ); CollectStructsToDrag( (SCH_SCREEN*) GetScreen() );
...@@ -421,25 +394,26 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) ...@@ -421,25 +394,26 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
case BLOCK_DELETE: /* move to Delete */ case BLOCK_DELETE: /* move to Delete */
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
if( block->m_BlockDrawStruct != NULL ) if( block->GetCount() )
{ {
ii = -1; ii = -1;
DeleteStruct( DrawPanel, DC, (SCH_ITEM*) block->m_BlockDrawStruct ); DeleteItemsInList( DrawPanel, block->m_ItemsSelection );
GetScreen()->SetModify(); GetScreen()->SetModify();
} }
TestDanglingEnds( GetScreen()->EEDrawList, DC ); TestDanglingEnds( GetScreen()->EEDrawList, DC );
DrawPanel->Refresh();
DrawPanel->Refresh();
break; break;
case BLOCK_SAVE: /* Save */ case BLOCK_SAVE: /* Save */
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
if( block->m_BlockDrawStruct != NULL ) if( block->GetCount() )
{ {
wxPoint oldpos = GetScreen()->m_Curseur; wxPoint oldpos = GetScreen()->m_Curseur;
GetScreen()->m_Curseur = wxPoint( 0, 0 ); GetScreen()->m_Curseur = wxPoint( 0, 0 );
SCH_ITEM* DrawStructCopy = SaveStructListForPaste( block->m_ItemsSelection );
SaveStructListForPaste( (SCH_ITEM*) block->m_BlockDrawStruct ); PlaceItemsInList( GetScreen(), g_BlockSaveDataList.m_ItemsSelection );
PlaceStruct( GetScreen(), DrawStructCopy );
GetScreen()->m_Curseur = oldpos; GetScreen()->m_Curseur = oldpos;
ii = -1; ii = -1;
} }
...@@ -449,7 +423,7 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) ...@@ -449,7 +423,7 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
DrawPanel->ForceCloseManageCurseur( DrawPanel, DC ); DrawPanel->ForceCloseManageCurseur( DrawPanel, DC );
DrawPanel->SetCursor( DrawPanel->SetCursor(
DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor ); DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor );
Window_Zoom( GetScreen()->BlockLocate ); Window_Zoom( GetScreen()->m_BlockLocate );
break; break;
...@@ -460,22 +434,19 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) ...@@ -460,22 +434,19 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
case BLOCK_MIRROR_Y: case BLOCK_MIRROR_Y:
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
if( block->m_BlockDrawStruct != NULL ) if( block->GetCount() )
{ {
SaveCopyInUndoList( (SCH_ITEM*) block->m_BlockDrawStruct, SaveCopyInUndoList( block->m_ItemsSelection, IS_CHANGED );
IS_CHANGED );
ii = -1; ii = -1;
/* Compute the mirror centre and put it on grid */ /* Compute the mirror centre and put it on grid */
wxPoint Center = block->Centre(); wxPoint Center = block->Centre();
PutOnGrid( &Center ); PutOnGrid( &Center );
MirrorStruct( DrawPanel, MirrorListOfItems( block->m_ItemsSelection, Center );
DC,
(SCH_ITEM*) block->m_BlockDrawStruct,
Center );
GetScreen()->SetModify(); GetScreen()->SetModify();
} }
TestDanglingEnds( GetScreen()->EEDrawList, DC ); TestDanglingEnds( GetScreen()->EEDrawList, DC );
DrawPanel->Refresh();
break; break;
default: default:
...@@ -484,16 +455,14 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) ...@@ -484,16 +455,14 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
if( ii <= 0 ) if( ii <= 0 )
{ {
block->m_BlockDrawStruct = NULL; block->ClearItemsList();
block->m_Flags = 0; block->m_Flags = 0;
block->m_State = STATE_NO_BLOCK; block->m_State = STATE_NO_BLOCK;
block->m_Command = BLOCK_IDLE; block->m_Command = BLOCK_IDLE;
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
SetToolID( m_ID_current_state, SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString );
DrawPanel->m_PanelDefaultCursor,
wxEmptyString );
} }
} }
...@@ -507,121 +476,53 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -507,121 +476,53 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
* L'ensemble du block suit le curseur * L'ensemble du block suit le curseur
*/ */
{ {
DrawBlockStruct* PtBlock; BLOCK_SELECTOR* block = &panel->GetScreen()->m_BlockLocate;;
DrawPickedStruct* PickedList;
BASE_SCREEN* screen = panel->GetScreen();
PtBlock = &panel->GetScreen()->BlockLocate; BASE_SCREEN* screen = panel->GetScreen();
GRSetDrawMode( DC, g_XorMode ); SCH_ITEM* schitem;
/* Effacement ancien cadre */ /* Effacement ancien cadre */
if( erase && PtBlock->m_BlockDrawStruct ) if( erase )
{ {
PtBlock->Offset( PtBlock->m_MoveVector ); block->Draw( panel, DC, block->m_MoveVector, g_XorMode, block->m_Color );
PtBlock->Draw( panel, DC ); for( unsigned ii = 0; ii < block->GetCount(); ii++ )
PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y );
/* Effacement ancien affichage */
if( PtBlock->m_BlockDrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
{ {
PickedList = (DrawPickedStruct*) PtBlock->m_BlockDrawStruct; schitem = (SCH_ITEM*) block->m_ItemsSelection.GetItemData( ii );
while( PickedList ) DrawStructsInGhost( panel, DC, schitem,
{ block->m_MoveVector.x,
DrawStructsInGhost( panel, block->m_MoveVector.y );
DC,
(SCH_ITEM*) PickedList->m_PickedStruct,
PtBlock->m_MoveVector.x,
PtBlock->m_MoveVector.y );
PickedList = (DrawPickedStruct*) PickedList->Next();
}
} }
else
DrawStructsInGhost( panel,
DC,
(SCH_ITEM*) PtBlock->m_BlockDrawStruct,
PtBlock->m_MoveVector.x,
PtBlock->m_MoveVector.y );
} }
/* Redessin nouvel affichage */ /* Redessin nouvel affichage */
PtBlock->m_MoveVector.x = screen->m_Curseur.x - block->m_MoveVector = screen->m_Curseur - block->m_BlockLastCursorPosition;
PtBlock->m_BlockLastCursorPosition.x;
PtBlock->m_MoveVector.y = screen->m_Curseur.y -
PtBlock->m_BlockLastCursorPosition.y;
GRSetDrawMode( DC, g_XorMode ); block->Draw( panel, DC, block->m_MoveVector, g_XorMode, block->m_Color );
PtBlock->Offset( PtBlock->m_MoveVector );
PtBlock->Draw( panel, DC );
PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y );
if( PtBlock->m_BlockDrawStruct ) for( unsigned ii = 0; ii < block->GetCount(); ii++ )
{ {
if( PtBlock->m_BlockDrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE ) schitem = (SCH_ITEM*) block->m_ItemsSelection.GetItemData( ii );
{ DrawStructsInGhost( panel, DC, schitem,
PickedList = (DrawPickedStruct*) PtBlock->m_BlockDrawStruct; block->m_MoveVector.x,
while( PickedList ) block->m_MoveVector.y );
{
DrawStructsInGhost( panel,
DC,
(SCH_ITEM*) PickedList->m_PickedStruct,
PtBlock->m_MoveVector.x,
PtBlock->m_MoveVector.y );
PickedList = (DrawPickedStruct*) PickedList->Next();
}
}
else
DrawStructsInGhost( panel,
DC,
(SCH_ITEM*) PtBlock->m_BlockDrawStruct,
PtBlock->m_MoveVector.x,
PtBlock->m_MoveVector.y );
} }
} }
/***************************************************************************** /*****************************************************************************
* Routine to move an object(s) to a new position. * * Routine to move objects to a new position. *
* If DrawStruct is of type DrawPickedStruct, a list of objects picked is *
* assumed, otherwise exactly one structure is assumed been picked. *
*****************************************************************************/ *****************************************************************************/
bool MoveStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct ) void MoveListOfItems( SCH_SCREEN* aScreen, PICKED_ITEMS_LIST& aItemsList )
{ {
if( !DrawStruct ) PlaceItemsInList( aScreen, aItemsList ); /* Place it in its new position. */
return FALSE;
if( DrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
{
DrawPickedStruct* pickedList = (DrawPickedStruct*) DrawStruct;
if( DC )
panel->PostDirtyRect( pickedList->GetBoundingBoxUnion() );
PlaceStruct( panel->GetScreen(), (SCH_ITEM *) pickedList ); // Place it in its new position.
if( DC )
RedrawStructList( panel, DC, (SCH_ITEM *) pickedList,
GR_DEFAULT_DRAWMODE );
// Free the wrapper DrawPickedStruct chain
pickedList->DeleteWrapperList();
}
else
{
if( DC )
panel->PostDirtyRect( DrawStruct->GetBoundingBox() );
PlaceStruct( panel->GetScreen(), DrawStruct ); /* Place it in its new position. */
if( DC )
RedrawOneStruct( panel, DC, DrawStruct, GR_DEFAULT_DRAWMODE );
}
return TRUE;
} }
static void MirrorYPoint( wxPoint& point, wxPoint& Center ) static void MirrorYPoint( wxPoint& point, wxPoint& Center )
{ {
point.x -= Center.x; point.x -= Center.x;
NEGATE(point.x); NEGATE( point.x );
point.x += Center.x; point.x += Center.x;
} }
...@@ -641,7 +542,7 @@ void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& Center ) ...@@ -641,7 +542,7 @@ void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& Center )
SCH_COMPONENT* DrawLibItem; SCH_COMPONENT* DrawLibItem;
DrawSheetStruct* DrawSheet; DrawSheetStruct* DrawSheet;
Hierarchical_PIN_Sheet_Struct* DrawSheetLabel; Hierarchical_PIN_Sheet_Struct* DrawSheetLabel;
MARKER_SCH* DrawMarker; MARKER_SCH* DrawMarker;
DrawNoConnectStruct* DrawNoConnect; DrawNoConnectStruct* DrawNoConnect;
SCH_TEXT* DrawText; SCH_TEXT* DrawText;
wxPoint px; wxPoint px;
...@@ -684,7 +585,7 @@ void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& Center ) ...@@ -684,7 +585,7 @@ void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& Center )
case DRAW_BUSENTRY_STRUCT_TYPE: case DRAW_BUSENTRY_STRUCT_TYPE:
DrawRaccord = (DrawBusEntryStruct*) DrawStruct; DrawRaccord = (DrawBusEntryStruct*) DrawStruct;
MirrorYPoint( DrawRaccord->m_Pos, Center ); MirrorYPoint( DrawRaccord->m_Pos, Center );
NEGATE(DrawRaccord->m_Size.x); NEGATE( DrawRaccord->m_Size.x );
break; break;
case DRAW_JUNCTION_STRUCT_TYPE: case DRAW_JUNCTION_STRUCT_TYPE:
...@@ -711,9 +612,9 @@ void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& Center ) ...@@ -711,9 +612,9 @@ void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& Center )
DrawText = (SCH_TEXT*) DrawStruct; DrawText = (SCH_TEXT*) DrawStruct;
px = DrawText->m_Pos; px = DrawText->m_Pos;
if( DrawText->m_Orient == 0 ) /* horizontal text */ if( DrawText->m_Orient == 0 ) /* horizontal text */
dx = DrawText->LenSize(DrawText->m_Text) / 2; dx = DrawText->LenSize( DrawText->m_Text ) / 2;
else if( DrawText->m_Orient == 2 ) /* invert horizontal text*/ else if( DrawText->m_Orient == 2 ) /* invert horizontal text*/
dx = -DrawText->LenSize(DrawText->m_Text) / 2; dx = -DrawText->LenSize( DrawText->m_Text ) / 2;
else else
dx = 0; dx = 0;
px.x += dx; px.x += dx;
...@@ -786,165 +687,76 @@ void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& Center ) ...@@ -786,165 +687,76 @@ void MirrorOneStruct( SCH_ITEM* DrawStruct, wxPoint& Center )
/***************************************************************************** /*****************************************************************************
* Routine to Mirror an object(s). * * Routine to Mirror objects. *
* If DrawStruct is of type DrawPickedStruct, a list of objects picked is *
* assumed, otherwise exactly one structure is assumed been picked. *
*****************************************************************************/ *****************************************************************************/
bool MirrorStruct( WinEDA_DrawPanel* panel, void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList, wxPoint& Center )
wxDC* DC,
SCH_ITEM* DrawStruct,
wxPoint& Center )
{ {
if( !DrawStruct ) for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
return FALSE;
if( DrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
{ {
DrawPickedStruct* pickedList = (DrawPickedStruct*) DrawStruct; SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetItemData( ii );
MirrorOneStruct( item, Center ); // Place it in its new position.
if( DC ) item->m_Flags = 0;
panel->PostDirtyRect( pickedList->GetBoundingBoxUnion() );
for( DrawPickedStruct* cur = pickedList; cur; cur = cur->Next() )
{
MirrorOneStruct( (SCH_ITEM*) cur->m_PickedStruct, Center );
cur->m_PickedStruct->m_Flags = 0;
}
if( DC )
RedrawStructList( panel, DC, (SCH_ITEM*) pickedList,
GR_DEFAULT_DRAWMODE );
// Free the wrapper DrawPickedStruct chain
pickedList->DeleteWrapperList();
}
else
{
if( DC )
panel->PostDirtyRect( DrawStruct->GetBoundingBox() );
MirrorOneStruct( DrawStruct, Center ); // Place it in its new position.
if( DC )
RedrawOneStruct( panel, DC, DrawStruct, GR_DEFAULT_DRAWMODE );
DrawStruct->m_Flags = 0;
} }
return true;
} }
/*****************************************************************************/ /*****************************************************************************/
static SCH_ITEM* CopyStruct( WinEDA_DrawPanel* panel, void CopyItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList )
wxDC* DC,
BASE_SCREEN* screen,
SCH_ITEM* DrawStruct )
/*****************************************************************************/ /*****************************************************************************/
/* Routine to copy a new entity of an object and reposition it. /* Routine to copy a new entity of an object for each object in list and reposition it.
* If DrawStruct is of type DrawPickedStruct, a list of objects picked is * Return the new created object list in aItemsList
* assumed, otherwise exactly one structure is assumed been picked.
* Return the new created struct
*/ */
{ {
SCH_ITEM* NewDrawStruct; SCH_ITEM* newitem;
DrawPickedStruct* PickedList = NULL;
if( !DrawStruct )
return FALSE;
NewDrawStruct = DuplicateStruct( DrawStruct ); if( aItemsList.GetCount() == 0 )
if( NewDrawStruct == NULL ) return;
return NULL;
PlaceStruct( screen, NewDrawStruct ); for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
/* Draw the new structure and chain it in: */
if( NewDrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
{ {
PickedList = (DrawPickedStruct*) NewDrawStruct; newitem = DuplicateStruct( (SCH_ITEM*) aItemsList.GetItemData( ii ) );
while( PickedList ) // Clear annotation for new components aItemsList.SetItem( newitem, ii );
aItemsList.SetItemStatus( IS_NEW, ii );
{ {
EDA_BaseStruct* Struct = PickedList->m_PickedStruct; switch( newitem->Type() )
switch( Struct->Type() )
{ {
case TYPE_SCH_COMPONENT: case DRAW_POLYLINE_STRUCT_TYPE:
( (SCH_COMPONENT*) Struct )->m_TimeStamp = GetTimeStamp(); case DRAW_JUNCTION_STRUCT_TYPE:
( (SCH_COMPONENT*) Struct )->ClearAnnotation( NULL ); case DRAW_SEGMENT_STRUCT_TYPE:
case DRAW_BUSENTRY_STRUCT_TYPE:
case TYPE_SCH_TEXT:
case TYPE_SCH_LABEL:
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:
break; break;
case DRAW_SHEET_STRUCT_TYPE: case DRAW_SHEET_STRUCT_TYPE:
//DuplicateStruct calls GenCopy, which should handle {
//m_AssociatedScreen, m_TimeStamp and m_sRefCount properly. DrawSheetStruct* sheet = (DrawSheetStruct*) newitem;
sheet->m_TimeStamp = GetTimeStamp();
sheet->SetSon( NULL );
break; break;
default:
;
} }
SetaParent( Struct, screen ); case TYPE_SCH_COMPONENT:
PickedList = (DrawPickedStruct*) PickedList->Next(); ( (SCH_COMPONENT*) newitem )->m_TimeStamp = GetTimeStamp();
} ( (SCH_COMPONENT*) newitem )->ClearAnnotation( NULL );
break;
RedrawStructList( panel, DC, NewDrawStruct, GR_DEFAULT_DRAWMODE ); }
/* Chain the new items */
PickedList = (DrawPickedStruct*) NewDrawStruct;
while( PickedList )
{
PickedList->m_PickedStruct->SetNext( screen->EEDrawList );
screen->EEDrawList = (SCH_ITEM*) PickedList->m_PickedStruct;
PickedList = PickedList->Next();
}
}
else
{
switch( NewDrawStruct->Type() )
{
case DRAW_POLYLINE_STRUCT_TYPE:
case DRAW_JUNCTION_STRUCT_TYPE:
case DRAW_SEGMENT_STRUCT_TYPE:
case DRAW_BUSENTRY_STRUCT_TYPE:
case TYPE_SCH_TEXT:
case TYPE_SCH_LABEL:
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:
break;
case DRAW_SHEET_STRUCT_TYPE:
{
DrawSheetStruct* sheet = (DrawSheetStruct*) NewDrawStruct;
sheet->m_TimeStamp = GetTimeStamp();
sheet->SetSon( NULL );
break;
}
case TYPE_SCH_COMPONENT: SetaParent( newitem, screen );
( (SCH_COMPONENT*) NewDrawStruct )->m_TimeStamp = GetTimeStamp(); newitem->SetNext( screen->EEDrawList );
( (SCH_COMPONENT*) NewDrawStruct )->ClearAnnotation( NULL ); screen->EEDrawList = newitem;
break;
} }
RedrawOneStruct( panel, DC, NewDrawStruct, GR_DEFAULT_DRAWMODE );
SetaParent( NewDrawStruct, screen );
NewDrawStruct->SetNext( screen->EEDrawList );
screen->EEDrawList = NewDrawStruct;
}
/* Free the original DrawPickedStruct chain: */
if( DrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
{
PickedList = (DrawPickedStruct*) DrawStruct;
PickedList->DeleteWrapperList();
} }
return NewDrawStruct; PlaceItemsInList( screen, aItemsList );
} }
...@@ -966,8 +778,8 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct ) ...@@ -966,8 +778,8 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct )
{ {
/* Cette stucture est rattachee a une feuille, et n'est pas /* Cette stucture est rattachee a une feuille, et n'est pas
* accessible par la liste globale directement */ * accessible par la liste globale directement */
frame->SaveCopyInUndoList( (SCH_ITEM*) ( (Hierarchical_PIN_Sheet_Struct frame->SaveCopyInUndoList( (SCH_ITEM*)( (Hierarchical_PIN_Sheet_Struct
*) DrawStruct )->GetParent(), *) DrawStruct )->GetParent(),
IS_CHANGED ); IS_CHANGED );
frame->DeleteSheetLabel( DC ? true : false, frame->DeleteSheetLabel( DC ? true : false,
(Hierarchical_PIN_Sheet_Struct*) DrawStruct ); (Hierarchical_PIN_Sheet_Struct*) DrawStruct );
...@@ -982,7 +794,7 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct ) ...@@ -982,7 +794,7 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct )
cur; cur;
cur = cur->Next() ) cur = cur->Next() )
{ {
SCH_ITEM* item = (SCH_ITEM*)cur->m_PickedStruct; SCH_ITEM* item = (SCH_ITEM*) cur->m_PickedStruct;
screen->RemoveFromDrawList( item ); screen->RemoveFromDrawList( item );
panel->PostDirtyRect( item->GetBoundingBox() ); panel->PostDirtyRect( item->GetBoundingBox() );
item->SetNext( 0 ); item->SetNext( 0 );
...@@ -1003,18 +815,13 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct ) ...@@ -1003,18 +815,13 @@ void DeleteStruct( WinEDA_DrawPanel* panel, wxDC* DC, SCH_ITEM* DrawStruct )
DrawStruct->SetNext( 0 ); DrawStruct->SetNext( 0 );
DrawStruct->SetBack( 0 ); // Only one struct -> no link DrawStruct->SetBack( 0 ); // Only one struct -> no link
if( DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE ) frame->SaveCopyInUndoList( DrawStruct, IS_DELETED );
{
frame->SaveCopyInUndoList( DrawStruct, IS_DELETED ); // Currently In TEST
}
else
frame->SaveCopyInUndoList( DrawStruct, IS_DELETED );
} }
} }
/*****************************************************************/ /*****************************************************************/
SCH_ITEM* SaveStructListForPaste( SCH_ITEM* DrawStruct ) void SaveStructListForPaste( PICKED_ITEMS_LIST& aItemsList )
/*****************************************************************/ /*****************************************************************/
/* Routine to Save an object from global drawing object list. /* Routine to Save an object from global drawing object list.
...@@ -1023,109 +830,64 @@ SCH_ITEM* SaveStructListForPaste( SCH_ITEM* DrawStruct ) ...@@ -1023,109 +830,64 @@ SCH_ITEM* SaveStructListForPaste( SCH_ITEM* DrawStruct )
* - List is saved in g_BlockSaveDataList * - List is saved in g_BlockSaveDataList
*/ */
{ {
DrawPickedStruct* PickedList; g_BlockSaveDataList.ClearListAndDeleteItems(); // delete previous saved list, if exists
SCH_ITEM* DrawStructCopy;
if( !DrawStruct ) /* save the new list: */
return NULL; ITEM_PICKER item;
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
/* Make a copy of the original picked item. */
DrawStructCopy = DuplicateStruct( DrawStruct );
if( DrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
{ {
/* Delete the picked wrapper if this is a picked list. */ /* Make a copy of the original picked item. */
PickedList = (DrawPickedStruct*) DrawStruct; SCH_ITEM* DrawStructCopy = DuplicateStruct( (SCH_ITEM*) aItemsList.GetItemData( ii ) );
PickedList->DeleteWrapperList(); DrawStructCopy->SetParent( NULL );
} item.m_Item = DrawStructCopy;
g_BlockSaveDataList.PushItem( item );
/* And delete old list and save the new list: */
if( g_BlockSaveDataList ) /* Delete last deleted item or item list */
{
EDA_BaseStruct* item = g_BlockSaveDataList, * next_item;
while( item )
{
next_item = item->Next();
delete item;
item = next_item;
}
} }
g_BlockSaveDataList = DrawStructCopy;
DrawStructCopy->SetParent( NULL );
return DrawStructCopy;
} }
/***************************************************************************** /*****************************************************************************
* Routine to paste a structure from the g_BlockSaveDataList stack. * * Routine to paste a structure from the g_BlockSaveDataList stack.
* This routine is the same as undelete but original list is NOT removed. * * This routine is the same as undelete but original list is NOT removed.
*****************************************************************************/ *****************************************************************************/
void WinEDA_SchematicFrame::PasteStruct( wxDC* DC ) void WinEDA_SchematicFrame::PasteListOfItems( wxDC* DC )
{ {
SCH_ITEM* DrawStruct; SCH_ITEM* Struct;
DrawPickedStruct* PickedList = NULL;
if( g_BlockSaveDataList == NULL ) if( g_BlockSaveDataList.GetCount() == 0 )
{ {
DisplayError( this, wxT( "No struct to paste" ) ); DisplayError( this, wxT( "No struct to paste" ) );
return; return;
} }
DrawStruct = DuplicateStruct( g_BlockSaveDataList ); PICKED_ITEMS_LIST picklist;
picklist.m_UndoRedoType = IS_NEW;
PlaceStruct( GetScreen(), DrawStruct ); // Creates data, and push it as new data in undo item list buffer
ITEM_PICKER picker( NULL, IS_NEW );
RedrawStructList( DrawPanel, DC, DrawStruct, GR_DEFAULT_DRAWMODE ); for( unsigned ii = 0; ii < g_BlockSaveDataList.GetCount(); ii++ )
// Clear annotation and init new time stamp for the new components:
if( DrawStruct->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
{ {
for( PickedList = (DrawPickedStruct*) DrawStruct; PickedList != NULL; ) // Clear annotation for new components Struct = DuplicateStruct( (SCH_ITEM*) g_BlockSaveDataList.m_ItemsSelection.GetItemData( ii ) );
{ picker.m_Item = Struct;
EDA_BaseStruct* Struct = PickedList->m_PickedStruct; picklist.PushItem( picker );
if( Struct->Type() == TYPE_SCH_COMPONENT )
{
( (SCH_COMPONENT*) Struct )->m_TimeStamp = GetTimeStamp();
( (SCH_COMPONENT*) Struct )->ClearAnnotation( NULL );
SetaParent( Struct, GetScreen() );
}
PickedList = (DrawPickedStruct*) PickedList->Next();
}
RedrawStructList( DrawPanel, DC, DrawStruct, GR_DEFAULT_DRAWMODE );
for( PickedList = (DrawPickedStruct*) DrawStruct; PickedList != NULL; )
{
SCH_ITEM* Struct = (SCH_ITEM*) PickedList->m_PickedStruct;
Struct->SetNext( GetScreen()->EEDrawList );
SetaParent( Struct, GetScreen() );
GetScreen()->EEDrawList = Struct;
PickedList = PickedList->Next();
}
/* Save wrapper list in undo stack */ // Clear annotation and init new time stamp for the new components:
SaveCopyInUndoList( DrawStruct, IS_NEW ); if( Struct->Type() == TYPE_SCH_COMPONENT )
}
else
{
if( DrawStruct->Type() == TYPE_SCH_COMPONENT )
{ {
( (SCH_COMPONENT*) DrawStruct )->m_TimeStamp = GetTimeStamp(); ( (SCH_COMPONENT*) Struct )->m_TimeStamp = GetTimeStamp();
( (SCH_COMPONENT*) DrawStruct )->ClearAnnotation( NULL ); ( (SCH_COMPONENT*) Struct )->ClearAnnotation( NULL );
} }
SetaParent( DrawStruct, GetScreen() ); SetaParent( Struct, GetScreen() );
RedrawOneStruct( DrawPanel, DC, DrawStruct, GR_DEFAULT_DRAWMODE ); RedrawOneStruct( DrawPanel, DC, Struct, GR_DEFAULT_DRAWMODE );
DrawStruct->SetNext( GetScreen()->EEDrawList ); Struct->SetNext( GetScreen()->EEDrawList );
GetScreen()->EEDrawList = DrawStruct; GetScreen()->EEDrawList = Struct;
SaveCopyInUndoList( DrawStruct, IS_NEW );
} }
SaveCopyInUndoList( picklist, IS_NEW );
PlaceItemsInList( GetScreen(), picklist );
/* clear .m_Flags member for all items */ /* clear .m_Flags member for all items */
SCH_ITEM* Struct; for( Struct = GetScreen()->EEDrawList; Struct != NULL; Struct = Struct->Next() )
for( Struct = GetScreen()->EEDrawList;
Struct != NULL;
Struct = Struct->Next() )
Struct->m_Flags = 0; Struct->m_Flags = 0;
GetScreen()->SetModify(); GetScreen()->SetModify();
...@@ -1134,54 +896,63 @@ void WinEDA_SchematicFrame::PasteStruct( wxDC* DC ) ...@@ -1134,54 +896,63 @@ void WinEDA_SchematicFrame::PasteStruct( wxDC* DC )
} }
/***************************************************************************** /** function DeleteItemsInList
* Routine to place a given object. * * delete schematic items in aItemsList
*****************************************************************************/ * deleted items are put in undo list
bool PlaceStruct( BASE_SCREEN* screen, SCH_ITEM* DrawStruct ) */
void DeleteItemsInList( WinEDA_DrawPanel* panel, PICKED_ITEMS_LIST& aItemsList )
{ {
DrawPickedStruct* DrawStructs; SCH_SCREEN* screen = (SCH_SCREEN*) panel->GetScreen();
wxPoint move_vector; WinEDA_SchematicFrame* frame = (WinEDA_SchematicFrame*) panel->m_Parent;
PICKED_ITEMS_LIST itemsList;
if( !DrawStruct ) ITEM_PICKER itemWrapper;
return FALSE;
move_vector = screen->m_Curseur - screen->BlockLocate.m_BlockLastCursorPosition;
switch( DrawStruct->Type() ) for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{ {
default: SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetItemData( ii );
case TYPE_NOT_INIT: itemWrapper.m_Item = item;
return FALSE; itemWrapper.m_UndoRedoStatus = IS_DELETED;
if( item->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
case DRAW_POLYLINE_STRUCT_TYPE:
case DRAW_JUNCTION_STRUCT_TYPE:
case DRAW_SEGMENT_STRUCT_TYPE:
case DRAW_BUSENTRY_STRUCT_TYPE:
case TYPE_SCH_TEXT:
case TYPE_SCH_LABEL:
case TYPE_SCH_GLOBALLABEL:
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_COMPONENT:
case DRAW_SHEET_STRUCT_TYPE:
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
case DRAW_MARKER_STRUCT_TYPE:
case DRAW_NOCONNECT_STRUCT_TYPE:
MoveOneStruct( DrawStruct, move_vector );
break;
case DRAW_PICK_ITEM_STRUCT_TYPE:
DrawStructs = (DrawPickedStruct*) DrawStruct;
while( DrawStructs )
{ {
MoveOneStruct( (SCH_ITEM*) DrawStructs->m_PickedStruct, /* this item is depending on a sheet, and is not in global list */
move_vector ); wxMessageBox( wxT(
DrawStructs = DrawStructs->Next(); "DeleteItemsInList() err: unexpected DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE" ) );
#if 0
Hierarchical_PIN_Sheet_Struct* pinlabel = (Hierarchical_PIN_Sheet_Struct*) item;
frame->DeleteSheetLabel( false, pinlabel->m_Parent );
itemWrapper.m_Item = pinlabel->m_Parent;
itemWrapper.m_UndoRedoStatus = IS_CHANGED;
itemsList.PushItem( itemWrapper );
#endif
} }
else
{
screen->RemoveFromDrawList( item );
break; /* Unlink the structure */
item->SetNext( 0 );
item->SetBack( 0 );
itemsList.PushItem( itemWrapper );
}
} }
return TRUE; frame->SaveCopyInUndoList( itemsList, IS_DELETED );
}
/*****************************************************************************
* Routine to place a given object. *
*****************************************************************************/
void PlaceItemsInList( SCH_SCREEN* aScreen, PICKED_ITEMS_LIST& aItemsList )
{
wxPoint move_vector;
move_vector = aScreen->m_Curseur - aScreen->m_BlockLocate.m_BlockLastCursorPosition;
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetItemData( ii );
MoveOneStruct( item, move_vector );
}
} }
...@@ -1199,7 +970,7 @@ void MoveOneStruct( SCH_ITEM* DrawStruct, const wxPoint& move_vector ) ...@@ -1199,7 +970,7 @@ void MoveOneStruct( SCH_ITEM* DrawStruct, const wxPoint& move_vector )
SCH_COMPONENT* DrawLibItem; SCH_COMPONENT* DrawLibItem;
DrawSheetStruct* DrawSheet; DrawSheetStruct* DrawSheet;
Hierarchical_PIN_Sheet_Struct* DrawSheetLabel; Hierarchical_PIN_Sheet_Struct* DrawSheetLabel;
MARKER_SCH* DrawMarker; MARKER_SCH* DrawMarker;
DrawNoConnectStruct* DrawNoConnect; DrawNoConnectStruct* DrawNoConnect;
if( !DrawStruct ) if( !DrawStruct )
...@@ -1400,7 +1171,7 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct ) ...@@ -1400,7 +1171,7 @@ SCH_ITEM* DuplicateStruct( SCH_ITEM* DrawStruct )
DrawStruct->Type() << wxT( " " ) << DrawStruct->GetClass(); DrawStruct->Type() << wxT( " " ) << DrawStruct->GetClass();
DisplayError( NULL, msg ); DisplayError( NULL, msg );
} }
break; break;
} }
NewDrawStruct->m_Image = DrawStruct; NewDrawStruct->m_Image = DrawStruct;
...@@ -1413,71 +1184,61 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) ...@@ -1413,71 +1184,61 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
/****************************************************/ /****************************************************/
/* creates the list of items found when a drag block is initiated. /* creates the list of items found when a drag block is initiated.
* items are those slected in window block an some items outside this area but connected * items are those selected in window block an some items outside this area but connected
* to a selected item (connected wires to a component or an entry ) * to a selected item (connected wires to a component or an entry )
*/ */
{ {
DrawPickedStruct* DrawStructs, * FirstPicked;
SCH_ITEM* Struct; SCH_ITEM* Struct;
EDA_DrawLineStruct* SegmStruct; EDA_DrawLineStruct* SegmStruct;
int ox, oy, fx, fy; int ox, oy, fx, fy;
/* .m_Flags member is used to handle how a wire is exactly slected PICKED_ITEMS_LIST* pickedlist = &screen->m_BlockLocate.m_ItemsSelection;
if( pickedlist->GetCount() == 0 )
return;
/* .m_Flags member is used to handle how a wire is exactly selected
* (fully selected, or partially selected by an end point ) * (fully selected, or partially selected by an end point )
*/ */
for( Struct = screen->EEDrawList; Struct != NULL; Struct = Struct->Next() ) for( Struct = screen->EEDrawList; Struct != NULL; Struct = Struct->Next() )
Struct->m_Flags = 0; Struct->m_Flags = 0;
// Sel .m_Flags to selected for a wire or buss in selected area if there is only one item: // Sel .m_Flags to selected for a wire or bus in selected area if there is only one item:
if( screen->BlockLocate.m_BlockDrawStruct->Type() == DRAW_SEGMENT_STRUCT_TYPE ) if( pickedlist->GetCount() == 1 )
screen->BlockLocate.m_BlockDrawStruct->m_Flags = SELECTED; {
Struct = (SCH_ITEM*) pickedlist->GetItemData( 0 );
// Sel .m_Flags to selected for a wire or buss in selected area for a list of items: if( Struct->Type() == DRAW_SEGMENT_STRUCT_TYPE )
else if( screen->BlockLocate.m_BlockDrawStruct->Type() == Struct->m_Flags = SELECTED;
DRAW_PICK_ITEM_STRUCT_TYPE ) }
// Sel .m_Flags to selected for a wire or bus in selected area for a list of items:
else
{ {
DrawStructs = for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
(DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct;
while( DrawStructs )
{ {
Struct = (SCH_ITEM*) DrawStructs->m_PickedStruct; Struct = (SCH_ITEM*)(SCH_ITEM*) pickedlist->GetItemData( ii );
DrawStructs = DrawStructs->Next();
Struct->m_Flags = SELECTED; Struct->m_Flags = SELECTED;
} }
} }
if( screen->BlockLocate.m_Command != BLOCK_DRAG ) if( screen->m_BlockLocate.m_Command != BLOCK_DRAG )
return; return;
ox = screen->BlockLocate.GetX(); ox = screen->m_BlockLocate.GetX();
oy = screen->BlockLocate.GetY(); oy = screen->m_BlockLocate.GetY();
fx = screen->BlockLocate.GetRight(); fx = screen->m_BlockLocate.GetRight();
fy = screen->BlockLocate.GetBottom(); fy = screen->m_BlockLocate.GetBottom();
if( fx < ox ) if( fx < ox )
EXCHG( fx, ox ); EXCHG( fx, ox );
if( fy < oy ) if( fy < oy )
EXCHG( fy, oy ); EXCHG( fy, oy );
/* For drag block only:
* If only one item, change for a list of one item
* in order to have always a list to handle.
*/
if( screen->BlockLocate.m_BlockDrawStruct->Type() !=
DRAW_PICK_ITEM_STRUCT_TYPE )
{
DrawStructs = new DrawPickedStruct(
(SCH_ITEM*) screen->BlockLocate.m_BlockDrawStruct );
screen->BlockLocate.m_BlockDrawStruct = DrawStructs;
}
/* Suppression du deplacement des extremites de segments hors cadre /* Suppression du deplacement des extremites de segments hors cadre
* de selection */ * de selection */
DrawStructs = (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
while( DrawStructs )
{ {
Struct = (SCH_ITEM*) DrawStructs->m_PickedStruct; Struct = (SCH_ITEM*)(SCH_ITEM*) pickedlist->GetItemData( ii );
DrawStructs = DrawStructs->Next();
if( Struct->Type() == DRAW_SEGMENT_STRUCT_TYPE ) if( Struct->Type() == DRAW_SEGMENT_STRUCT_TYPE )
{ {
SegmStruct = (EDA_DrawLineStruct*) Struct; SegmStruct = (EDA_DrawLineStruct*) Struct;
...@@ -1494,21 +1255,20 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) ...@@ -1494,21 +1255,20 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
/* Search for other items to drag. They are end wires connected to selected items /* Search for other items to drag. They are end wires connected to selected items
*/ */
FirstPicked = DrawStructs = for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
(DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct;
while( DrawStructs )
{ {
Struct = (SCH_ITEM*) DrawStructs->m_PickedStruct; Struct = (SCH_ITEM*)(SCH_ITEM*) pickedlist->GetItemData( ii );
DrawStructs = DrawStructs->Next();
if( Struct->Type() == TYPE_SCH_COMPONENT ) if( Struct->Type() == TYPE_SCH_COMPONENT )
{ // Add all pins of the selected component to list {
// Add all pins of the selected component to list
LibEDA_BaseStruct* DrawItem; LibEDA_BaseStruct* DrawItem;
wxPoint pos; wxPoint pos;
DrawItem = GetNextPinPosition( (SCH_COMPONENT*) Struct, pos ); DrawItem = GetNextPinPosition( (SCH_COMPONENT*) Struct, pos );
while( DrawItem ) while( DrawItem )
{ {
if( (pos.x < ox) || (pos.x > fx) || (pos.y < oy) || (pos.y > fy) ) if( (pos.x < ox) || (pos.x > fx) || (pos.y < oy) || (pos.y > fy) )
{ // This pin is outside area, {
// This pin is outside area,
// but because it it the pin of a selected component // but because it it the pin of a selected component
// we must also select connected items to this pin // we must also select connected items to this pin
AddPickedItem( screen, pos ); AddPickedItem( screen, pos );
...@@ -1519,7 +1279,8 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) ...@@ -1519,7 +1279,8 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
} }
if( Struct->Type() == DRAW_SHEET_STRUCT_TYPE ) if( Struct->Type() == DRAW_SHEET_STRUCT_TYPE )
{ // Add all pins sheets of a selected hierarchical sheet to the list {
// Add all pins sheets of a selected hierarchical sheet to the list
Hierarchical_PIN_Sheet_Struct* SLabel = Hierarchical_PIN_Sheet_Struct* SLabel =
( (DrawSheetStruct*) Struct )->m_Label; ( (DrawSheetStruct*) Struct )->m_Label;
while( SLabel ) while( SLabel )
...@@ -1543,16 +1304,21 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) ...@@ -1543,16 +1304,21 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
/******************************************************************/ /******************************************************************/
static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
/******************************************************************/ /******************************************************************/
/** AddPickedItem
* add to the picked list in screen->m_BlockLocate items found at location position
* @param screen = the screen to consider
* @param position = the wxPoint where items must be located to be select
*/
{ {
DrawPickedStruct* DrawStructs; SCH_ITEM* Struct;
SCH_ITEM* Struct;
/* Examen de la liste des elements deja selectionnes */ /* Examen de la liste des elements deja selectionnes */
DrawStructs = (DrawPickedStruct*) screen->BlockLocate.m_BlockDrawStruct; PICKED_ITEMS_LIST* pickedlist = &screen->m_BlockLocate.m_ItemsSelection;
while( DrawStructs )
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
{ {
Struct = (SCH_ITEM*) DrawStructs->m_PickedStruct; Struct = (SCH_ITEM*) pickedlist->GetItemData( ii );
DrawStructs = (DrawPickedStruct*) DrawStructs->Next();
switch( Struct->Type() ) switch( Struct->Type() )
{ {
...@@ -1573,6 +1339,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) ...@@ -1573,6 +1339,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
/* Examen de la liste des elements non selectionnes */ /* Examen de la liste des elements non selectionnes */
ITEM_PICKER picker;
Struct = screen->EEDrawList; Struct = screen->EEDrawList;
while( Struct ) while( Struct )
{ {
...@@ -1593,10 +1360,8 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) ...@@ -1593,10 +1360,8 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
break; /* Deja en liste */ break; /* Deja en liste */
if( STRUCT->m_Pos != position ) if( STRUCT->m_Pos != position )
break; break;
DrawStructs = new DrawPickedStruct( Struct ); picker.m_Item = Struct;
DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct ); pickedlist->PushItem( picker );
screen->BlockLocate.m_BlockDrawStruct =
(EDA_BaseStruct*) DrawStructs;
break; break;
case DRAW_SEGMENT_STRUCT_TYPE: case DRAW_SEGMENT_STRUCT_TYPE:
...@@ -1606,21 +1371,17 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) ...@@ -1606,21 +1371,17 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
break; /* Deja en liste */ break; /* Deja en liste */
if( STRUCT->m_Start == position ) if( STRUCT->m_Start == position )
{ {
DrawStructs = new DrawPickedStruct( Struct );
DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct );
screen->BlockLocate.m_BlockDrawStruct =
(EDA_BaseStruct*) DrawStructs;
Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT; Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT;
Struct->m_Flags &= ~STARTPOINT; Struct->m_Flags &= ~STARTPOINT;
picker.m_Item = Struct;
pickedlist->PushItem( picker );
} }
else if( STRUCT->m_End == position ) else if( STRUCT->m_End == position )
{ {
DrawStructs = new DrawPickedStruct( Struct );
DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct );
screen->BlockLocate.m_BlockDrawStruct =
(EDA_BaseStruct*) DrawStructs;
Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT; Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT;
Struct->m_Flags &= ~ENDPOINT; Struct->m_Flags &= ~ENDPOINT;
picker.m_Item = Struct;
pickedlist->PushItem( picker );
} }
break; break;
...@@ -1637,11 +1398,9 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) ...@@ -1637,11 +1398,9 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
break; /* Already in list */ break; /* Already in list */
if( STRUCT->m_Pos != position ) if( STRUCT->m_Pos != position )
break; break;
DrawStructs = new DrawPickedStruct( Struct );
DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct );
screen->BlockLocate.m_BlockDrawStruct =
(EDA_BaseStruct*) DrawStructs;
Struct->m_Flags |= SELECTED; Struct->m_Flags |= SELECTED;
picker.m_Item = Struct;
pickedlist->PushItem( picker );
break; break;
case TYPE_SCH_HIERLABEL: case TYPE_SCH_HIERLABEL:
...@@ -1652,11 +1411,9 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) ...@@ -1652,11 +1411,9 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
break; /* Already in list */ break; /* Already in list */
if( STRUCT->m_Pos != position ) if( STRUCT->m_Pos != position )
break; break;
DrawStructs = new DrawPickedStruct( Struct );
DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct );
screen->BlockLocate.m_BlockDrawStruct =
(EDA_BaseStruct*) DrawStructs;
Struct->m_Flags |= SELECTED; Struct->m_Flags |= SELECTED;
picker.m_Item = Struct;
pickedlist->PushItem( picker );
break; break;
case TYPE_SCH_COMPONENT: case TYPE_SCH_COMPONENT:
...@@ -1678,11 +1435,9 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) ...@@ -1678,11 +1435,9 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
break; /* Already in list */ break; /* Already in list */
if( STRUCT->m_Pos != position ) if( STRUCT->m_Pos != position )
break; break;
DrawStructs = new DrawPickedStruct( Struct );
DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct );
screen->BlockLocate.m_BlockDrawStruct =
(EDA_BaseStruct*) DrawStructs;
Struct->m_Flags |= SELECTED; Struct->m_Flags |= SELECTED;
picker.m_Item = Struct;
pickedlist->PushItem( picker );
break; break;
case DRAW_NOCONNECT_STRUCT_TYPE: case DRAW_NOCONNECT_STRUCT_TYPE:
...@@ -1692,11 +1447,9 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) ...@@ -1692,11 +1447,9 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
break; /* Already in list */ break; /* Already in list */
if( STRUCT->m_Pos != position ) if( STRUCT->m_Pos != position )
break; break;
DrawStructs = new DrawPickedStruct( Struct );
DrawStructs->SetNext( screen->BlockLocate.m_BlockDrawStruct );
screen->BlockLocate.m_BlockDrawStruct =
(EDA_BaseStruct*) DrawStructs;
Struct->m_Flags |= SELECTED; Struct->m_Flags |= SELECTED;
picker.m_Item = Struct;
pickedlist->PushItem( picker );
break; break;
default: default:
......
...@@ -255,21 +255,21 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -255,21 +255,21 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
{ {
int ItemsCount = 0, MustDoPlace = 0; int ItemsCount = 0, MustDoPlace = 0;
if( GetScreen()->BlockLocate.m_BlockDrawStruct ) if( GetScreen()->m_BlockLocate.GetCount() )
{ {
BlockState state = GetScreen()->BlockLocate.m_State; BlockState state = GetScreen()->m_BlockLocate.m_State;
CmdBlockType command = GetScreen()->BlockLocate.m_Command; CmdBlockType command = GetScreen()->m_BlockLocate.m_Command;
DrawPanel->ForceCloseManageCurseur( DrawPanel, DC ); DrawPanel->ForceCloseManageCurseur( DrawPanel, DC );
GetScreen()->BlockLocate.m_State = state; GetScreen()->m_BlockLocate.m_State = state;
GetScreen()->BlockLocate.m_Command = command; GetScreen()->m_BlockLocate.m_Command = command;
DrawPanel->ManageCurseur = DrawAndSizingBlockOutlines; DrawPanel->ManageCurseur = DrawAndSizingBlockOutlines;
DrawPanel->ForceCloseManageCurseur = AbortBlockCurrentCommand; DrawPanel->ForceCloseManageCurseur = AbortBlockCurrentCommand;
GetScreen()->m_Curseur.x = GetScreen()->BlockLocate.GetRight(); GetScreen()->m_Curseur.x = GetScreen()->m_BlockLocate.GetRight();
GetScreen()->m_Curseur.y = GetScreen()->BlockLocate.GetBottom(); GetScreen()->m_Curseur.y = GetScreen()->m_BlockLocate.GetBottom();
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
} }
switch( GetScreen()->BlockLocate.m_Command ) switch( GetScreen()->m_BlockLocate.m_Command )
{ {
case BLOCK_IDLE: case BLOCK_IDLE:
DisplayError( this, wxT( "Error in HandleBlockPLace" ) ); DisplayError( this, wxT( "Error in HandleBlockPLace" ) );
...@@ -278,7 +278,7 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -278,7 +278,7 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_DRAG: /* Drag */ case BLOCK_DRAG: /* Drag */
case BLOCK_MOVE: /* Move */ case BLOCK_MOVE: /* Move */
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
ItemsCount = MarkItemsInBloc( CurrentLibEntry, GetScreen()->BlockLocate ); ItemsCount = MarkItemsInBloc( CurrentLibEntry, GetScreen()->m_BlockLocate );
if( ItemsCount ) if( ItemsCount )
{ {
MustDoPlace = 1; MustDoPlace = 1;
...@@ -288,7 +288,7 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -288,7 +288,7 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
DrawPanel->ManageCurseur = DrawMovingBlockOutlines; DrawPanel->ManageCurseur = DrawMovingBlockOutlines;
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
} }
GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE;
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
} }
break; break;
...@@ -296,11 +296,11 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -296,11 +296,11 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
MustDoPlace = 1; MustDoPlace = 1;
DrawPanel->ManageCurseur = DrawMovingBlockOutlines; DrawPanel->ManageCurseur = DrawMovingBlockOutlines;
GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE;
break; break;
case BLOCK_DELETE: /* Delete */ case BLOCK_DELETE: /* Delete */
ItemsCount = MarkItemsInBloc( CurrentLibEntry, GetScreen()->BlockLocate ); ItemsCount = MarkItemsInBloc( CurrentLibEntry, GetScreen()->m_BlockLocate );
if( ItemsCount ) if( ItemsCount )
SaveCopyInUndoList( CurrentLibEntry ); SaveCopyInUndoList( CurrentLibEntry );
DeleteMarkedItems( CurrentLibEntry ); DeleteMarkedItems( CurrentLibEntry );
...@@ -315,14 +315,14 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -315,14 +315,14 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_INVERT: case BLOCK_INVERT:
ItemsCount = MarkItemsInBloc( CurrentLibEntry, GetScreen()->BlockLocate ); ItemsCount = MarkItemsInBloc( CurrentLibEntry, GetScreen()->m_BlockLocate );
if( ItemsCount ) if( ItemsCount )
SaveCopyInUndoList( CurrentLibEntry ); SaveCopyInUndoList( CurrentLibEntry );
MirrorMarkedItems( CurrentLibEntry, GetScreen()->BlockLocate.Centre() ); MirrorMarkedItems( CurrentLibEntry, GetScreen()->m_BlockLocate.Centre() );
break; break;
case BLOCK_ZOOM: /* Window Zoom */ case BLOCK_ZOOM: /* Window Zoom */
Window_Zoom( GetScreen()->BlockLocate ); Window_Zoom( GetScreen()->m_BlockLocate );
break; break;
case BLOCK_ABORT: case BLOCK_ABORT:
...@@ -334,13 +334,13 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -334,13 +334,13 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
if( MustDoPlace <= 0 ) if( MustDoPlace <= 0 )
{ {
if( GetScreen()->BlockLocate.m_Command != BLOCK_SELECT_ITEMS_ONLY ) if( GetScreen()->m_BlockLocate.m_Command != BLOCK_SELECT_ITEMS_ONLY )
{ {
ClearMarkItems( CurrentLibEntry ); ClearMarkItems( CurrentLibEntry );
} }
GetScreen()->BlockLocate.m_Flags = 0; GetScreen()->m_BlockLocate.m_Flags = 0;
GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
...@@ -371,9 +371,9 @@ void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC ) ...@@ -371,9 +371,9 @@ void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC )
DisplayError( this, wxT( "HandleBlockPLace : ManageCurseur = NULL" ) ); DisplayError( this, wxT( "HandleBlockPLace : ManageCurseur = NULL" ) );
} }
GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP;
switch( GetScreen()->BlockLocate.m_Command ) switch( GetScreen()->m_BlockLocate.m_Command )
{ {
case BLOCK_IDLE: case BLOCK_IDLE:
err = TRUE; err = TRUE;
...@@ -382,25 +382,25 @@ void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC ) ...@@ -382,25 +382,25 @@ void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC )
case BLOCK_DRAG: /* Drag */ case BLOCK_DRAG: /* Drag */
case BLOCK_MOVE: /* Move */ case BLOCK_MOVE: /* Move */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; GetScreen()->m_BlockLocate.ClearItemsList();
SaveCopyInUndoList( CurrentLibEntry ); SaveCopyInUndoList( CurrentLibEntry );
MoveMarkedItems( CurrentLibEntry, GetScreen()->BlockLocate.m_MoveVector ); MoveMarkedItems( CurrentLibEntry, GetScreen()->m_BlockLocate.m_MoveVector );
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
break; break;
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; GetScreen()->m_BlockLocate.ClearItemsList();
SaveCopyInUndoList( CurrentLibEntry ); SaveCopyInUndoList( CurrentLibEntry );
CopyMarkedItems( CurrentLibEntry, GetScreen()->BlockLocate.m_MoveVector ); CopyMarkedItems( CurrentLibEntry, GetScreen()->m_BlockLocate.m_MoveVector );
break; break;
case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */ case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */
GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; GetScreen()->m_BlockLocate.ClearItemsList();
break; break;
case BLOCK_INVERT: /* Invert by popup menu, from block move */ case BLOCK_INVERT: /* Invert by popup menu, from block move */
SaveCopyInUndoList( CurrentLibEntry ); SaveCopyInUndoList( CurrentLibEntry );
MirrorMarkedItems( CurrentLibEntry, GetScreen()->BlockLocate.Centre() ); MirrorMarkedItems( CurrentLibEntry, GetScreen()->m_BlockLocate.Centre() );
break; break;
case BLOCK_ZOOM: // Handled by HandleBlockEnd case BLOCK_ZOOM: // Handled by HandleBlockEnd
...@@ -417,9 +417,9 @@ void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC ) ...@@ -417,9 +417,9 @@ void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC )
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->BlockLocate.m_Flags = 0; GetScreen()->m_BlockLocate.m_Flags = 0;
GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
...@@ -436,20 +436,17 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -436,20 +436,17 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
* L'ensemble du block suit le curseur * L'ensemble du block suit le curseur
*/ */
{ {
DrawBlockStruct* PtBlock; BLOCK_SELECTOR* PtBlock;
BASE_SCREEN* screen = panel->GetScreen(); BASE_SCREEN* screen = panel->GetScreen();
LibEDA_BaseStruct* item; LibEDA_BaseStruct* item;
wxPoint move_offset; wxPoint move_offset;
PtBlock = &panel->GetScreen()->BlockLocate; PtBlock = &screen->m_BlockLocate;
GRSetDrawMode( DC, g_XorMode );
/* Effacement ancien cadre */ /* Effacement ancien cadre */
if( erase ) if( erase )
{ {
PtBlock->Offset( PtBlock->m_MoveVector ); PtBlock->Draw( panel, DC, PtBlock->m_MoveVector, g_XorMode, PtBlock->m_Color );
PtBlock->Draw( panel, DC );
PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y );
if( CurrentLibEntry ) if( CurrentLibEntry )
{ {
...@@ -474,9 +471,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -474,9 +471,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
PtBlock->m_MoveVector.y = screen->m_Curseur.y - PtBlock->m_BlockLastCursorPosition.y; PtBlock->m_MoveVector.y = screen->m_Curseur.y - PtBlock->m_BlockLastCursorPosition.y;
GRSetDrawMode( DC, g_XorMode ); GRSetDrawMode( DC, g_XorMode );
PtBlock->Offset( PtBlock->m_MoveVector ); PtBlock->Draw( panel, DC, PtBlock->m_MoveVector, g_XorMode, PtBlock->m_Color );
PtBlock->Draw( panel, DC );
PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y );
if( CurrentLibEntry ) if( CurrentLibEntry )
......
...@@ -40,7 +40,7 @@ bool g_LastSearchIsMarker; /* True if last seach is a marker serach ...@@ -40,7 +40,7 @@ bool g_LastSearchIsMarker; /* True if last seach is a marker serach
* Used for hotkey next search */ * Used for hotkey next search */
/* Block operation (copy, paste) */ /* Block operation (copy, paste) */
SCH_ITEM* g_BlockSaveDataList; // List of items to paste (Created by Block Save) BLOCK_SELECTOR g_BlockSaveDataList; // List of items to paste (Created by Block Save)
// Gestion d'options // Gestion d'options
bool g_HVLines = true; // Bool: force H or V directions (Wires, Bus ..) bool g_HVLines = true; // Bool: force H or V directions (Wires, Bus ..)
......
...@@ -112,7 +112,7 @@ extern bool g_LastSearchIsMarker; // True if last seach is a marker se ...@@ -112,7 +112,7 @@ extern bool g_LastSearchIsMarker; // True if last seach is a marker se
// Used for hotkey next search // Used for hotkey next search
/* Block operation (copy, paste) */ /* Block operation (copy, paste) */
extern SCH_ITEM* g_BlockSaveDataList; // List of items to paste (Created by Block Save) extern BLOCK_SELECTOR g_BlockSaveDataList; // List of items to paste (Created by Block Save)
// Gestion d'options // Gestion d'options
extern bool g_HVLines; extern bool g_HVLines;
......
...@@ -252,7 +252,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -252,7 +252,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
break; break;
case HK_DELETE: case HK_DELETE:
if( !ItemInEdit && screen->BlockLocate.m_State == STATE_NO_BLOCK ) if( !ItemInEdit && screen->m_BlockLocate.m_State == STATE_NO_BLOCK )
{ {
RefreshToolBar = LocateAndDeleteItem( this, DC ); RefreshToolBar = LocateAndDeleteItem( this, DC );
GetScreen()->SetModify(); GetScreen()->SetModify();
...@@ -290,7 +290,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -290,7 +290,7 @@ void WinEDA_SchematicFrame::OnHotKey( wxDC* DC, int hotkey,
case HK_BEGIN_WIRE: case HK_BEGIN_WIRE:
/* An item is selected. If edited and not a wire, a new command is not /* An item is selected. If edited and not a wire, a new command is not
* possible */ * possible */
if( !ItemInEdit && screen->BlockLocate.m_State == STATE_NO_BLOCK ) if( !ItemInEdit && screen->m_BlockLocate.m_State == STATE_NO_BLOCK )
{ {
if( DrawStruct && DrawStruct->m_Flags ) if( DrawStruct && DrawStruct->m_Flags )
{ {
......
...@@ -29,7 +29,7 @@ bool WinEDA_LibeditFrame::OnRightClick(const wxPoint& MousePos, wxMenu * PopMenu ...@@ -29,7 +29,7 @@ bool WinEDA_LibeditFrame::OnRightClick(const wxPoint& MousePos, wxMenu * PopMenu
/********************************************************************************/ /********************************************************************************/
{ {
LibEDA_BaseStruct* DrawEntry = LocateItemUsingCursor(); LibEDA_BaseStruct* DrawEntry = LocateItemUsingCursor();
bool BlockActive = (GetScreen()->BlockLocate.m_Command != BLOCK_IDLE); bool BlockActive = (GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE);
if ( CurrentLibEntry == NULL ) return true; if ( CurrentLibEntry == NULL ) return true;
...@@ -232,14 +232,14 @@ void AddMenusForBlock(wxMenu * PopMenu, WinEDA_LibeditFrame * frame) ...@@ -232,14 +232,14 @@ void AddMenusForBlock(wxMenu * PopMenu, WinEDA_LibeditFrame * frame)
{ {
ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_CANCEL_EDITING, _("Cancel Block"), cancel_xpm); ADD_MENUITEM(PopMenu, ID_POPUP_LIBEDIT_CANCEL_EDITING, _("Cancel Block"), cancel_xpm);
if( frame->GetScreen()->BlockLocate.m_Command == BLOCK_MOVE ) if( frame->GetScreen()->m_BlockLocate.m_Command == BLOCK_MOVE )
ADD_MENUITEM(PopMenu, ID_POPUP_ZOOM_BLOCK, _("Zoom Block (drag middle mouse)"), zoom_selected_xpm); ADD_MENUITEM(PopMenu, ID_POPUP_ZOOM_BLOCK, _("Zoom Block (drag middle mouse)"), zoom_selected_xpm);
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
ADD_MENUITEM(PopMenu, ID_POPUP_PLACE_BLOCK, _("Place Block"), apply_xpm ); ADD_MENUITEM(PopMenu, ID_POPUP_PLACE_BLOCK, _("Place Block"), apply_xpm );
if( frame->GetScreen()->BlockLocate.m_Command == BLOCK_MOVE ) if( frame->GetScreen()->m_BlockLocate.m_Command == BLOCK_MOVE )
{ {
ADD_MENUITEM(PopMenu, ID_POPUP_SELECT_ITEMS_BLOCK, _("Select Items"), green_xpm); ADD_MENUITEM(PopMenu, ID_POPUP_SELECT_ITEMS_BLOCK, _("Select Items"), green_xpm);
ADD_MENUITEM(PopMenu, ID_POPUP_COPY_BLOCK, ADD_MENUITEM(PopMenu, ID_POPUP_COPY_BLOCK,
......
...@@ -730,34 +730,34 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -730,34 +730,34 @@ void WinEDA_LibeditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_ZOOM_BLOCK: case ID_POPUP_ZOOM_BLOCK:
DrawPanel->m_AutoPAN_Request = false; DrawPanel->m_AutoPAN_Request = false;
GetScreen()->BlockLocate.m_Command = BLOCK_ZOOM; GetScreen()->m_BlockLocate.m_Command = BLOCK_ZOOM;
HandleBlockEnd( &dc ); HandleBlockEnd( &dc );
break; break;
case ID_POPUP_DELETE_BLOCK: case ID_POPUP_DELETE_BLOCK:
DrawPanel->m_AutoPAN_Request = false; DrawPanel->m_AutoPAN_Request = false;
GetScreen()->BlockLocate.m_Command = BLOCK_DELETE; GetScreen()->m_BlockLocate.m_Command = BLOCK_DELETE;
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
HandleBlockEnd( &dc ); HandleBlockEnd( &dc );
break; break;
case ID_POPUP_COPY_BLOCK: case ID_POPUP_COPY_BLOCK:
DrawPanel->m_AutoPAN_Request = false; DrawPanel->m_AutoPAN_Request = false;
GetScreen()->BlockLocate.m_Command = BLOCK_COPY; GetScreen()->m_BlockLocate.m_Command = BLOCK_COPY;
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
HandleBlockPlace( &dc ); HandleBlockPlace( &dc );
break; break;
case ID_POPUP_SELECT_ITEMS_BLOCK: case ID_POPUP_SELECT_ITEMS_BLOCK:
DrawPanel->m_AutoPAN_Request = false; DrawPanel->m_AutoPAN_Request = false;
GetScreen()->BlockLocate.m_Command = BLOCK_SELECT_ITEMS_ONLY; GetScreen()->m_BlockLocate.m_Command = BLOCK_SELECT_ITEMS_ONLY;
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
HandleBlockEnd( &dc ); HandleBlockEnd( &dc );
break; break;
case ID_POPUP_INVERT_BLOCK: case ID_POPUP_INVERT_BLOCK:
DrawPanel->m_AutoPAN_Request = false; DrawPanel->m_AutoPAN_Request = false;
GetScreen()->BlockLocate.m_Command = BLOCK_INVERT; GetScreen()->m_BlockLocate.m_Command = BLOCK_INVERT;
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
HandleBlockPlace( &dc ); HandleBlockPlace( &dc );
break; break;
......
...@@ -18,11 +18,10 @@ ...@@ -18,11 +18,10 @@
/* Routines Locales */ /* Routines Locales */
static SCH_ITEM* LastSnappedStruct = NULL; static SCH_ITEM* LastSnappedStruct = NULL;
static int PickedBoxMinX, PickedBoxMinY, PickedBoxMaxX, PickedBoxMaxY;
static bool IsBox1InBox2( int StartX1, int StartY1, int EndX1, int EndY1, static bool IsBox1InBox2( int StartX1, int StartY1, int EndX1, int EndY1,
int StartX2, int StartY2, int EndX2, int EndY2 ); int StartX2, int StartY2, int EndX2, int EndY2 );
static bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, static bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
SCH_ITEM* DrawList, DrawPickedStruct* DontSnapList, double aScaleFactor ); SCH_ITEM* DrawList, double aScaleFactor );
/*********************************************************************/ /*********************************************************************/
...@@ -43,10 +42,10 @@ SCH_COMPONENT* LocateSmallestComponent( SCH_SCREEN* Screen ) ...@@ -43,10 +42,10 @@ SCH_COMPONENT* LocateSmallestComponent( SCH_SCREEN* Screen )
while( DrawList ) while( DrawList )
{ {
if( ( SnapPoint2( Screen->m_MousePosition, LIBITEM, if( ( SnapPoint2( Screen->m_MousePosition, LIBITEM,
DrawList, NULL, Screen->GetZoom() ) ) == FALSE ) DrawList, Screen->GetZoom() ) ) == FALSE )
{ {
if( ( SnapPoint2( Screen->m_Curseur, LIBITEM, if( ( SnapPoint2( Screen->m_Curseur, LIBITEM,
DrawList, NULL, Screen->GetScalingFactor() ) ) == FALSE ) DrawList, Screen->GetScalingFactor() ) ) == FALSE )
break; break;
} }
component = (SCH_COMPONENT*) LastSnappedStruct; component = (SCH_COMPONENT*) LastSnappedStruct;
...@@ -111,7 +110,7 @@ SCH_ITEM* PickStruct( const wxPoint& refpos, BASE_SCREEN* screen, int SearchMask ...@@ -111,7 +110,7 @@ SCH_ITEM* PickStruct( const wxPoint& refpos, BASE_SCREEN* screen, int SearchMask
return NULL; return NULL;
if( ( Snapped = SnapPoint2( refpos, SearchMask, if( ( Snapped = SnapPoint2( refpos, SearchMask,
screen->EEDrawList, NULL, screen->GetScalingFactor() ) ) != FALSE ) screen->EEDrawList, screen->GetScalingFactor() ) ) != FALSE )
{ {
return LastSnappedStruct; return LastSnappedStruct;
} }
...@@ -120,62 +119,45 @@ SCH_ITEM* PickStruct( const wxPoint& refpos, BASE_SCREEN* screen, int SearchMask ...@@ -120,62 +119,45 @@ SCH_ITEM* PickStruct( const wxPoint& refpos, BASE_SCREEN* screen, int SearchMask
/***********************************************************************/ /***********************************************************************/
SCH_ITEM* PickStruct( EDA_Rect& block, BASE_SCREEN* screen, int SearchMask ) int PickStruct( BLOCK_SELECTOR& aBlock, BASE_SCREEN* aScreen )
/************************************************************************/ /************************************************************************/
/* Search items in block /** Function PickStruct
* Return: * Search items in a block
* pointeur sur liste de pointeurs de structures si Plusieurs * @return items count
* structures selectionnees. * @param aBlock a BLOCK_SELECTOR that gives the search area boundary
* pointeur sur la structure si 1 seule * list of items is stored in aBlock
*
*/ */
{ {
int x, y, OrigX, OrigY; int x, y, OrigX, OrigY;
DrawPickedStruct* PickedList = NULL, * PickedItem; int itemcount = 0;
SCH_ITEM* DrawStruct;
if( aScreen == NULL )
return itemcount;
OrigX = block.GetX(); OrigX = aBlock.GetX();
OrigY = block.GetY(); OrigY = aBlock.GetY();
x = block.GetRight(); x = aBlock.GetRight();
y = block.GetBottom(); y = aBlock.GetBottom();
if( x < OrigX ) if( x < OrigX )
EXCHG( x, OrigX ); EXCHG( x, OrigX );
if( y < OrigY ) if( y < OrigY )
EXCHG( y, OrigY ); EXCHG( y, OrigY );
SCH_ITEM* DrawList = screen->EEDrawList; ITEM_PICKER picker;
if( screen==NULL || DrawList == NULL ) SCH_ITEM* DrawStruct = aScreen->EEDrawList;
return NULL; for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
for( DrawStruct = DrawList; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
{ {
if( DrawStructInBox( OrigX, OrigY, x, y, DrawStruct ) ) if( DrawStructInBox( OrigX, OrigY, x, y, DrawStruct ) )
{ {
/* Put this structure in the picked list: */ /* Put this structure in the picked list: */
PickedItem = new DrawPickedStruct( DrawStruct ); picker.m_Item = DrawStruct;
aBlock.PushItem(picker);
PickedItem->SetNext( PickedList ); itemcount++;
PickedList = PickedItem;
} }
} }
return itemcount;
if( PickedList && PickedList->Next() == NULL )
{
/* Only one item was picked - convert to scalar form (no list): */
PickedItem = PickedList;
PickedList = (DrawPickedStruct*) PickedList->m_PickedStruct;
SAFE_DELETE( PickedItem );
}
if( PickedList != NULL )
{
PickedBoxMinX = OrigX; PickedBoxMinY = OrigY;
PickedBoxMaxX = x; PickedBoxMaxY = y;
}
return (SCH_ITEM*) PickedList;
} }
...@@ -185,26 +167,13 @@ SCH_ITEM* PickStruct( EDA_Rect& block, BASE_SCREEN* screen, int SearchMask ) ...@@ -185,26 +167,13 @@ SCH_ITEM* PickStruct( EDA_Rect& block, BASE_SCREEN* screen, int SearchMask )
* Note we use L1 norm as distance measure, as it is the fastest. * * Note we use L1 norm as distance measure, as it is the fastest. *
* This routine updates LastSnappedStruct to the last object used in to snap * * This routine updates LastSnappedStruct to the last object used in to snap *
* a point. This variable is global to this module only (see above). * * a point. This variable is global to this module only (see above). *
* If DontSnapList is not NULL, structes in this list are skipped. *
* The routine returns TRUE if point was snapped. * * The routine returns TRUE if point was snapped. *
*****************************************************************************/ *****************************************************************************/
bool SnapPoint2( const wxPoint& aPosRef, int SearchMask, bool SnapPoint2( const wxPoint& aPosRef, int SearchMask,
SCH_ITEM* DrawList, DrawPickedStruct* DontSnapList, double aScaleFactor ) SCH_ITEM* DrawList, double aScaleFactor )
{ {
DrawPickedStruct* DontSnap;
for( ; DrawList != NULL; DrawList = DrawList->Next() ) for( ; DrawList != NULL; DrawList = DrawList->Next() )
{ {
/* Make sure this structure is NOT in the dont snap list: */
DontSnap = DontSnapList;
for( ; DontSnap != NULL; DontSnap = DontSnap->Next() )
if( DontSnap->m_PickedStruct == DrawList )
break;
if( DontSnap )
if( DontSnap->m_PickedStruct == DrawList )
continue;
int hitminDist = MAX( g_DrawDefaultLineThickness, 3 ) ; int hitminDist = MAX( g_DrawDefaultLineThickness, 3 ) ;
switch( DrawList->Type() ) switch( DrawList->Type() )
{ {
......
...@@ -54,7 +54,7 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, ...@@ -54,7 +54,7 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos,
*/ */
{ {
SCH_ITEM* DrawStruct = (SCH_ITEM*) GetScreen()->GetCurItem(); SCH_ITEM* DrawStruct = (SCH_ITEM*) GetScreen()->GetCurItem();
bool BlockActive = (GetScreen()->BlockLocate.m_Command != BLOCK_IDLE); bool BlockActive = (GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE);
DrawPanel->m_CanStartBlock = -1; // Ne pas engager un debut de bloc sur validation menu DrawPanel->m_CanStartBlock = -1; // Ne pas engager un debut de bloc sur validation menu
...@@ -608,13 +608,13 @@ void AddMenusForBlock( wxMenu* PopMenu, WinEDA_SchematicFrame* frame ) ...@@ -608,13 +608,13 @@ void AddMenusForBlock( wxMenu* PopMenu, WinEDA_SchematicFrame* frame )
PopMenu->AppendSeparator(); PopMenu->AppendSeparator();
if( frame->GetScreen()->BlockLocate.m_Command == BLOCK_MOVE ) if( frame->GetScreen()->m_BlockLocate.m_Command == BLOCK_MOVE )
ADD_MENUITEM( PopMenu, ID_POPUP_ZOOM_BLOCK, ADD_MENUITEM( PopMenu, ID_POPUP_ZOOM_BLOCK,
_( "Window Zoom" ), zoom_selected_xpm ); _( "Window Zoom" ), zoom_selected_xpm );
ADD_MENUITEM( PopMenu, ID_POPUP_PLACE_BLOCK, _( "Place Block" ), apply_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_PLACE_BLOCK, _( "Place Block" ), apply_xpm );
if( frame->GetScreen()->BlockLocate.m_Command == BLOCK_MOVE ) if( frame->GetScreen()->m_BlockLocate.m_Command == BLOCK_MOVE )
{ // After a block move (that is also a block selection) one can reselect a block function: { // After a block move (that is also a block selection) one can reselect a block function:
ADD_MENUITEM( PopMenu, wxID_COPY, _( "Save Block" ), copy_button ); ADD_MENUITEM( PopMenu, wxID_COPY, _( "Save Block" ), copy_button );
ADD_MENUITEM( PopMenu, ID_POPUP_COPY_BLOCK, ADD_MENUITEM( PopMenu, ID_POPUP_COPY_BLOCK,
......
...@@ -96,22 +96,20 @@ SCH_ITEM * DuplicateStruct(SCH_ITEM *DrawStruct); ...@@ -96,22 +96,20 @@ SCH_ITEM * DuplicateStruct(SCH_ITEM *DrawStruct);
void MoveOneStruct(SCH_ITEM *DrawStructs, const wxPoint & move_vector); void MoveOneStruct(SCH_ITEM *DrawStructs, const wxPoint & move_vector);
/* Given a structure move it by move_vector. */ /* Given a structure move it by move_vector. */
bool PlaceStruct(BASE_SCREEN * screen, SCH_ITEM *DrawStruct);
bool MoveStruct(WinEDA_DrawPanel * panel, wxDC * DC, SCH_ITEM *DrawStruct);
void DeleteStruct(WinEDA_DrawPanel * panel, wxDC * DC, SCH_ITEM *DrawStruct); void DeleteStruct(WinEDA_DrawPanel * panel, wxDC * DC, SCH_ITEM *DrawStruct);
bool DrawStructInBox(int x1, int y1, int x2, int y2,
SCH_ITEM *DrawStruct);
/*************/ /*************/
/* LOCATE.CPP */ /* LOCATE.CPP */
/*************/ /*************/
bool DrawStructInBox(int x1, int y1, int x2, int y2,
SCH_ITEM *DrawStruct);
LibDrawPin* LocatePinByNumber( const wxString & ePin_Number, LibDrawPin* LocatePinByNumber( const wxString & ePin_Number,
SCH_COMPONENT* eComponent ); SCH_COMPONENT* eComponent );
SCH_COMPONENT * LocateSmallestComponent( SCH_SCREEN * Screen ); SCH_COMPONENT * LocateSmallestComponent( SCH_SCREEN * Screen );
/* Recherche du plus petit (en surface) composant pointe par la souris */ /* Recherche du plus petit (en surface) composant pointe par la souris */
SCH_ITEM * PickStruct(EDA_Rect & block, BASE_SCREEN* screen, int SearchMask ); int PickStruct(BLOCK_SELECTOR& aBlock, BASE_SCREEN* screen );
SCH_ITEM * PickStruct(const wxPoint & refpos, BASE_SCREEN* screen, int SearchMask); SCH_ITEM * PickStruct(const wxPoint & refpos, BASE_SCREEN* screen, int SearchMask);
/* 2 functions PickStruct: /* 2 functions PickStruct:
Search in block, or Search at location pos Search in block, or Search at location pos
......
...@@ -127,7 +127,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -127,7 +127,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_CANCEL_CURRENT_COMMAND: case ID_POPUP_CANCEL_CURRENT_COMMAND:
if( screen->BlockLocate.m_Command != BLOCK_IDLE ) if( screen->m_BlockLocate.m_Command != BLOCK_IDLE )
DrawPanel->SetCursor( wxCursor( DrawPanel->m_PanelCursor = DrawPanel->SetCursor( wxCursor( DrawPanel->m_PanelCursor =
DrawPanel-> DrawPanel->
m_PanelDefaultCursor ) ); m_PanelDefaultCursor ) );
...@@ -137,11 +137,11 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -137,11 +137,11 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
} }
/* ne devrait pas etre execute, sauf bug: */ /* ne devrait pas etre execute, sauf bug: */
if( screen->BlockLocate.m_Command != BLOCK_IDLE ) if( screen->m_BlockLocate.m_Command != BLOCK_IDLE )
{ {
screen->BlockLocate.m_Command = BLOCK_IDLE; screen->m_BlockLocate.m_Command = BLOCK_IDLE;
screen->BlockLocate.m_State = STATE_NO_BLOCK; screen->m_BlockLocate.m_State = STATE_NO_BLOCK;
screen->BlockLocate.m_BlockDrawStruct = NULL; screen->m_BlockLocate.ClearItemsList();
} }
break; break;
...@@ -174,7 +174,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -174,7 +174,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case wxID_CUT: case wxID_CUT:
if( screen->BlockLocate.m_Command != BLOCK_MOVE ) if( screen->m_BlockLocate.m_Command != BLOCK_MOVE )
break; break;
HandleBlockEndByPopUp( BLOCK_DELETE, &dc ); HandleBlockEndByPopUp( BLOCK_DELETE, &dc );
g_ItemToRepeat = NULL; g_ItemToRepeat = NULL;
...@@ -389,7 +389,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -389,7 +389,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_EDIT_SHEET: case ID_POPUP_SCH_EDIT_SHEET:
EditSheet( (DrawSheetStruct*) screen->GetCurItem(), &dc ); EditSheet( (DrawSheetStruct*) screen->GetCurItem(), &dc );
break; break;
case ID_POPUP_IMPORT_GLABEL: case ID_POPUP_IMPORT_GLABEL:
if ( screen->GetCurItem() && screen->GetCurItem()->Type() == DRAW_SHEET_STRUCT_TYPE ) if ( screen->GetCurItem() && screen->GetCurItem()->Type() == DRAW_SHEET_STRUCT_TYPE )
GetScreen()->SetCurItem( Import_PinSheet( (DrawSheetStruct*)screen->GetCurItem(), &dc ) ); GetScreen()->SetCurItem( Import_PinSheet( (DrawSheetStruct*)screen->GetCurItem(), &dc ) );
...@@ -426,7 +426,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -426,7 +426,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
{ {
// The easiest way to handle a drag component is simulate a // The easiest way to handle a drag component is simulate a
// block drag command // block drag command
if( screen->BlockLocate.m_State == STATE_NO_BLOCK ) if( screen->m_BlockLocate.m_State == STATE_NO_BLOCK )
{ {
if( !HandleBlockBegin( &dc, BLOCK_DRAG, if( !HandleBlockBegin( &dc, BLOCK_DRAG,
screen->m_Curseur ) ) screen->m_Curseur ) )
......
/********************************************/ /*************************************************************/
/* library editor: undo and redo functions */ /* eeschema: undo and redo functions for schematic editor */
/********************************************/ /*************************************************************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h"
#include "common.h" #include "common.h"
#include "confirm.h" #include "confirm.h"
#include "class_drawpickedstruct.h" #include "class_drawpickedstruct.h"
...@@ -11,18 +10,20 @@ ...@@ -11,18 +10,20 @@
#include "program.h" #include "program.h"
#include "libcmp.h" #include "libcmp.h"
#include "general.h" #include "general.h"
#include "id.h"
#include "protos.h" #include "protos.h"
#include "class_marker_sch.h" #include "class_marker_sch.h"
/* Functions to undo and redo edit commands. /* Functions to undo and redo edit commands.
* commmands to undo are in CurrentScreen->m_UndoList * commmands to undo are stored in CurrentScreen->m_UndoList
* commmands to redo are in CurrentScreen->m_RedoList * commmands to redo are stored in CurrentScreen->m_RedoList
* *
* m_UndoList and m_RedoList are a linked list of DrawPickedStruct. * m_UndoList and m_RedoList handle a std::vector of PICKED_ITEMS_LIST
* each DrawPickedStruct has its .m_Son member pointing to an item to undo or redo, * Each PICKED_ITEMS_LIST handle a std::vector of pickers (class ITEM_PICKER),
* or to a list of DrawPickedStruct which points (.m_PickedStruct membre) * that store the list of schematic items that are concerned by the command to undo or redo
* the items to undo or redo * and is created for each command to undo (handle also a command to redo).
* each picker has a pointer pointing to an item to undo or redo (in fact: deleted, added or modified),
* and has a pointer to a copy of this item, when this item has been modified
* (the old values of parameters are therefore saved)
* *
* there are 3 cases: * there are 3 cases:
* - delete item(s) command * - delete item(s) command
...@@ -31,45 +32,45 @@ ...@@ -31,45 +32,45 @@
* *
* Undo command * Undo command
* - delete item(s) command: * - delete item(s) command:
* deleted items are moved in undo list * => deleted items are moved in undo list
* *
* - change item(s) command * - change item(s) command
* A copy of item(s) is made (a DrawPickedStruct list of wrappers) * => A copy of item(s) is made (a DrawPickedStruct list of wrappers)
* the .m_Image member of each wrapper points the modified item. * the .m_Link member of each wrapper points the modified item.
* the .m_Item member of each wrapper points the old copy of this item.
* *
* - add item(s) command * - add item(s) command
* A list of item(s) is made * =>A list of item(s) is made. The .m_Item member of each wrapper points the new item.
* the .m_Image member of each wrapper points the new item.
* *
* Redo command * Redo command
* - delete item(s) old command: * - delete item(s) old command:
* deleted items are moved in EEDrawList list * => deleted items are moved in EEDrawList list, and in
* *
* - change item(s) command * - change item(s) command
* the copy of item(s) is moved in Undo list * => the copy of item(s) is moved in Undo list
* *
* - add item(s) command * - add item(s) command
* The list of item(s) is used to create a deleted list in undo list * => The list of item(s) is used to create a deleted list in undo list(same as a delete command)
* (same as a delete command)
* *
* A problem is the hierarchical sheet handling. * A problem is the hierarchical sheet handling.
* the data associated (subhierarchy, uno/redo list) is deleted only * the data associated (subhierarchy, uno/redo list) is deleted only
* when the sheet is really deleted (i.e. when deleted from undo or redo list) * when the sheet is really deleted (i.e. when deleted from undo or redo list)
* and not when it is a copy. * This is handled by its destructor.
*/ */
/************************************/ /**************************************************************/
void SwapData( EDA_BaseStruct* aItem, EDA_BaseStruct* aImage ) void SwapData( EDA_BaseStruct* aItem, EDA_BaseStruct* aImage )
/************************************/ /***************************************************************/
/* Used if undo / redo command: /* Used if undo / redo command:
* swap data between Item and its copy, pointed by its .m_Image member * swap data between Item and its copy, pointed by its .m_Image member
* swapped data is data modified by edition, so not all values are swapped
*/ */
{ {
if( aItem == NULL || aImage == NULL ) if( aItem == NULL || aImage == NULL )
{ {
wxMessageBox(wxT("SwapData error: NULL pointer")); wxMessageBox( wxT( "SwapData error: NULL pointer" ) );
return; return;
} }
...@@ -176,19 +177,15 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* ItemToCopy, ...@@ -176,19 +177,15 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* ItemToCopy,
int flag_type_command ) int flag_type_command )
/***********************************************************************/ /***********************************************************************/
/* Create a copy of the current schematic draw list, and put it in the undo list. /** function SaveCopyInUndoList
* A DrawPickedStruct wrapper is created to handle the draw list. * Create a copy of the current schematic item, and put it in the undo list.
* the .m_Son of this wrapper points the list of items
* *
* flag_type_command = * flag_type_command =
* 0 (unspecified)
* IS_CHANGED * IS_CHANGED
* IS_NEW * IS_NEW
* IS_DELETED * IS_DELETED
* IS_WIRE_IMAGE * IS_WIRE_IMAGE
* *
* for 0: only a wrapper is created. The used must init the .Flags member of the
* wrapper, and add the item list to the wrapper
* If it is a delete command, items are put on list with the .Flags member set to IS_DELETED. * If it is a delete command, items are put on list with the .Flags member set to IS_DELETED.
* When it will be really deleted, the EEDrawList and the subhierarchy will be deleted. * When it will be really deleted, the EEDrawList and the subhierarchy will be deleted.
* If it is only a copy, the EEDrawList and the subhierarchy must NOT be deleted. * If it is only a copy, the EEDrawList and the subhierarchy must NOT be deleted.
...@@ -205,33 +202,30 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* ItemToCopy, ...@@ -205,33 +202,30 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* ItemToCopy,
PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST(); PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
commandToUndo->m_UndoRedoType = flag_type_command; commandToUndo->m_UndoRedoType = flag_type_command;
ITEM_PICKER itemWrapper( ItemToCopy, flag_type_command ); ITEM_PICKER itemWrapper( ItemToCopy, flag_type_command );
if( ItemToCopy ) if( ItemToCopy )
{ {
switch( flag_type_command ) switch( flag_type_command )
{ {
case 0:
break;
case IS_CHANGED: /* Create a copy of schematic */ case IS_CHANGED: /* Create a copy of schematic */
if( ItemToCopy->Type() == DRAW_PICK_ITEM_STRUCT_TYPE ) if( ItemToCopy->Type() == DRAW_PICK_ITEM_STRUCT_TYPE )
{ {
DrawPickedStruct* PickedList = (DrawPickedStruct*) ItemToCopy; DrawPickedStruct* PickedList = (DrawPickedStruct*) ItemToCopy;
while( PickedList ) while( PickedList )
{ {
CopyOfItem = DuplicateStruct( (SCH_ITEM*) PickedList->m_PickedStruct); CopyOfItem = DuplicateStruct( (SCH_ITEM*) PickedList->m_PickedStruct );
CopyOfItem->m_Flags = flag_type_command; CopyOfItem->m_Flags = flag_type_command;
itemWrapper.m_Item = CopyOfItem; itemWrapper.m_Item = CopyOfItem;
itemWrapper.m_Link = (SCH_ITEM*) PickedList->m_PickedStruct; itemWrapper.m_Link = (SCH_ITEM*) PickedList->m_PickedStruct;
commandToUndo->PushItem( itemWrapper ); commandToUndo->PushItem( itemWrapper );
PickedList = PickedList->Next(); PickedList = PickedList->Next();
} }
} }
else else
{ {
CopyOfItem = DuplicateStruct(ItemToCopy); CopyOfItem = DuplicateStruct( ItemToCopy );
itemWrapper.m_Item = CopyOfItem; itemWrapper.m_Item = CopyOfItem;
itemWrapper.m_Link = ItemToCopy; itemWrapper.m_Link = ItemToCopy;
commandToUndo->PushItem( itemWrapper ); commandToUndo->PushItem( itemWrapper );
} }
...@@ -305,12 +299,71 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* ItemToCopy, ...@@ -305,12 +299,71 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* ItemToCopy,
default: default:
{ {
wxString msg; wxString msg;
msg.Printf(wxT( "SaveCopyInUndoList() error (unknown code %X)" ), flag_type_command); msg.Printf( wxT( "SaveCopyInUndoList() error (unknown code %X)" ), flag_type_command );
DisplayError( this, msg); DisplayError( this, msg );
}
break;
}
}
/* Save the copy in undo list */
GetScreen()->PushCommandToUndoList( commandToUndo );
/* Clear redo list, because after new save there is no redo to do */
GetScreen()->ClearUndoORRedoList( GetScreen()->m_RedoList );
}
/** function SaveCopyInUndoList
* @param aItemsList = a PICKED_ITEMS_LIST of items to save
* @param aTypeCommand = type of comand ( IS_CHANGED, IS_NEW, IS_DELETED ...
*/
void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, int aTypeCommand )
{
SCH_ITEM* CopyOfItem;
PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
commandToUndo->m_UndoRedoType = aTypeCommand;
ITEM_PICKER itemWrapper;
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{
SCH_ITEM* ItemToCopy = (SCH_ITEM*) aItemsList.GetItemData( ii );
int command = aItemsList.GetItemStatus( ii );
if( command == 0 )
{
command = aTypeCommand;
} }
itemWrapper.m_Item = ItemToCopy;
itemWrapper.m_UndoRedoStatus = command;
switch( command )
{
case IS_CHANGED: /* Create a copy of schematic */
CopyOfItem = DuplicateStruct( ItemToCopy );
itemWrapper.m_Item = CopyOfItem;
itemWrapper.m_Link = ItemToCopy;
commandToUndo->PushItem( itemWrapper );
break;
case IS_NEW:
case IS_NEW | IS_CHANGED: // when more than one item, some are new, some are changed
commandToUndo->PushItem( itemWrapper );
break;
case IS_DELETED:
ItemToCopy->m_Flags = IS_DELETED;
commandToUndo->PushItem( itemWrapper );
break; break;
default:
{
wxString msg;
msg.Printf( wxT( "SaveCopyInUndoList() error (unknown code %X)" ), command );
DisplayError( this, msg );
}
break;
} }
} }
/* Save the copy in undo list */ /* Save the copy in undo list */
GetScreen()->PushCommandToUndoList( commandToUndo ); GetScreen()->PushCommandToUndoList( commandToUndo );
...@@ -358,14 +411,15 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList ) ...@@ -358,14 +411,15 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
* Put data pointed by List in the previous state, i.e. the state memorised by List * Put data pointed by List in the previous state, i.e. the state memorised by List
*/ */
{ {
SCH_ITEM* item; SCH_ITEM* item;
SCH_ITEM* alt_item; SCH_ITEM* alt_item;
for( unsigned ii = 0; ii < aList->GetCount(); ii++ ) for( unsigned ii = 0; ii < aList->GetCount(); ii++ )
{ {
ITEM_PICKER itemWrapper = aList->GetItemWrapper( ii ); ITEM_PICKER itemWrapper = aList->GetItemWrapper( ii );
item = (SCH_ITEM*) itemWrapper.m_Item; item = (SCH_ITEM*) itemWrapper.m_Item;
SCH_ITEM * image = (SCH_ITEM*) itemWrapper.m_Link; wxASSERT ( item );
SCH_ITEM* image = (SCH_ITEM*) itemWrapper.m_Link;
switch( itemWrapper.m_UndoRedoStatus ) switch( itemWrapper.m_UndoRedoStatus )
{ {
case IS_CHANGED: /* Exchange old and new data for each item */ case IS_CHANGED: /* Exchange old and new data for each item */
...@@ -399,15 +453,18 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList ) ...@@ -399,15 +453,18 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList )
item->m_Flags = 0; item->m_Flags = 0;
item = nextitem; item = nextitem;
} }
break; break;
default: default:
{ {
wxString msg; wxString msg;
msg.Printf(wxT( "PutDataInPreviousState() error (unknown code %X)" ), itemWrapper.m_UndoRedoStatus); msg.Printf( wxT(
DisplayError( this, msg); "PutDataInPreviousState() error (unknown code %X)" ),
itemWrapper.m_UndoRedoStatus );
DisplayError( this, msg );
} }
break; break;
} }
} }
} }
...@@ -458,7 +515,7 @@ void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount ...@@ -458,7 +515,7 @@ void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount
* So this function can be called to remove old commands * So this function can be called to remove old commands
*/ */
{ {
int CmdType; int CmdType;
if( aItemCount == 0 ) if( aItemCount == 0 )
return; return;
...@@ -468,17 +525,17 @@ void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount ...@@ -468,17 +525,17 @@ void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount
icnt = aItemCount; icnt = aItemCount;
for( unsigned ii = 0; ii < icnt; ii++ ) for( unsigned ii = 0; ii < icnt; ii++ )
{ {
if ( aList.m_CommandsList.size() == 0 ) if( aList.m_CommandsList.size() == 0 )
break; break;
PICKED_ITEMS_LIST* curr_cmd = aList.m_CommandsList[0]; PICKED_ITEMS_LIST* curr_cmd = aList.m_CommandsList[0];
aList.m_CommandsList.erase( aList.m_CommandsList.begin() ); aList.m_CommandsList.erase( aList.m_CommandsList.begin() );
CmdType = curr_cmd->m_UndoRedoType; CmdType = curr_cmd->m_UndoRedoType;
// Delete items is they are not flagged IS_NEW // Delete items is they are not flagged IS_NEW
while(1) while( 1 )
{ {
ITEM_PICKER wrapper = curr_cmd->PopItem(); ITEM_PICKER wrapper = curr_cmd->PopItem();
EDA_BaseStruct* item = wrapper.m_Item; EDA_BaseStruct* item = wrapper.m_Item;
if( item == NULL ) // No more item in list. if( item == NULL ) // No more item in list.
break; break;
if( wrapper.m_UndoRedoStatus == IS_WIRE_IMAGE ) if( wrapper.m_UndoRedoStatus == IS_WIRE_IMAGE )
...@@ -498,6 +555,7 @@ void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount ...@@ -498,6 +555,7 @@ void SCH_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount
} }
} }
} }
delete curr_cmd; // Delete command delete curr_cmd; // Delete command
} }
} }
......
...@@ -416,7 +416,7 @@ wxString WinEDA_SchematicFrame::GetUniqueFilenameForCurrentSheet( ) ...@@ -416,7 +416,7 @@ wxString WinEDA_SchematicFrame::GetUniqueFilenameForCurrentSheet( )
void WinEDA_SchematicFrame::OnUpdateBlockSelected( wxUpdateUIEvent& event ) void WinEDA_SchematicFrame::OnUpdateBlockSelected( wxUpdateUIEvent& event )
{ {
bool enable = ( GetScreen() && bool enable = ( GetScreen() &&
GetScreen()->BlockLocate.m_Command == BLOCK_MOVE ); GetScreen()->m_BlockLocate.m_Command == BLOCK_MOVE );
event.Enable(enable); event.Enable(enable);
m_HToolBar->EnableTool( wxID_CUT, enable ); m_HToolBar->EnableTool( wxID_CUT, enable );
m_HToolBar->EnableTool( wxID_COPY, enable ); m_HToolBar->EnableTool( wxID_COPY, enable );
...@@ -424,8 +424,8 @@ void WinEDA_SchematicFrame::OnUpdateBlockSelected( wxUpdateUIEvent& event ) ...@@ -424,8 +424,8 @@ void WinEDA_SchematicFrame::OnUpdateBlockSelected( wxUpdateUIEvent& event )
void WinEDA_SchematicFrame::OnUpdatePaste( wxUpdateUIEvent& event ) void WinEDA_SchematicFrame::OnUpdatePaste( wxUpdateUIEvent& event )
{ {
event.Enable( g_BlockSaveDataList != NULL ); event.Enable( g_BlockSaveDataList.GetCount() > 0 );
m_HToolBar->EnableTool( wxID_PASTE, g_BlockSaveDataList != NULL ); m_HToolBar->EnableTool( wxID_PASTE, g_BlockSaveDataList.GetCount() > 0 );
} }
void WinEDA_SchematicFrame::OnUpdateSchematicUndo( wxUpdateUIEvent& event ) void WinEDA_SchematicFrame::OnUpdateSchematicUndo( wxUpdateUIEvent& event )
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static TRACK* IsSegmentInBox( DrawBlockStruct& blocklocate, TRACK* PtSegm ); static TRACK* IsSegmentInBox( BLOCK_SELECTOR& blocklocate, TRACK* PtSegm );
/* Variables locales :*/ /* Variables locales :*/
...@@ -79,9 +79,9 @@ void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC ) ...@@ -79,9 +79,9 @@ void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC )
err = TRUE; err = TRUE;
DisplayError( this, wxT( "Error in HandleBlockPLace : ManageCurseur = NULL" ) ); DisplayError( this, wxT( "Error in HandleBlockPLace : ManageCurseur = NULL" ) );
} }
GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP;
switch( GetScreen()->BlockLocate.m_Command ) switch( GetScreen()->m_BlockLocate.m_Command )
{ {
case BLOCK_IDLE: case BLOCK_IDLE:
err = TRUE; err = TRUE;
...@@ -93,14 +93,14 @@ void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC ) ...@@ -93,14 +93,14 @@ void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC )
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
Block_Move( DC ); Block_Move( DC );
GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; GetScreen()->m_BlockLocate.ClearItemsList();
break; break;
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
Block_Duplicate( DC ); Block_Duplicate( DC );
GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; GetScreen()->m_BlockLocate.ClearItemsList();
break; break;
case BLOCK_PASTE: case BLOCK_PASTE:
...@@ -122,13 +122,13 @@ void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC ) ...@@ -122,13 +122,13 @@ void WinEDA_GerberFrame::HandleBlockPlace( wxDC* DC )
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->BlockLocate.m_Flags = 0; GetScreen()->m_BlockLocate.m_Flags = 0;
GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
if( GetScreen()->BlockLocate.m_BlockDrawStruct ) if( GetScreen()->m_BlockLocate.GetCount() )
{ {
DisplayError( this, wxT( "Error in HandleBlockPLace DrawStruct != NULL" ) ); DisplayError( this, wxT( "HandleBlockPLace error: some items left" ) );
GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; GetScreen()->m_BlockLocate.ClearItemsList();
} }
DisplayToolMsg( wxEmptyString ); DisplayToolMsg( wxEmptyString );
...@@ -151,7 +151,7 @@ int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC ) ...@@ -151,7 +151,7 @@ int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC )
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
switch( GetScreen()->BlockLocate.m_Command ) switch( GetScreen()->m_BlockLocate.m_Command )
{ {
case BLOCK_IDLE: case BLOCK_IDLE:
DisplayError( this, wxT( "Error in HandleBlockPLace" ) ); DisplayError( this, wxT( "Error in HandleBlockPLace" ) );
...@@ -161,7 +161,7 @@ int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC ) ...@@ -161,7 +161,7 @@ int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_MOVE: /* Move */ case BLOCK_MOVE: /* Move */
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE;
endcommande = FALSE; endcommande = FALSE;
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
DrawPanel->ManageCurseur = DrawMovingBlockOutlines; DrawPanel->ManageCurseur = DrawMovingBlockOutlines;
...@@ -169,13 +169,13 @@ int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC ) ...@@ -169,13 +169,13 @@ int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC )
break; break;
case BLOCK_DELETE: /* Delete */ case BLOCK_DELETE: /* Delete */
GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP;
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
Block_Delete( DC ); Block_Delete( DC );
break; break;
case BLOCK_MIRROR_X: /* Mirror*/ case BLOCK_MIRROR_X: /* Mirror*/
GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP;
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
Block_Mirror_X( DC ); Block_Mirror_X( DC );
break; break;
...@@ -204,17 +204,17 @@ int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC ) ...@@ -204,17 +204,17 @@ int WinEDA_GerberFrame::HandleBlockEnd( wxDC* DC )
if( endcommande == TRUE ) if( endcommande == TRUE )
{ {
GetScreen()->BlockLocate.m_Flags = 0; GetScreen()->m_BlockLocate.m_Flags = 0;
GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; GetScreen()->m_BlockLocate.ClearItemsList();
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
DisplayToolMsg( wxEmptyString ); DisplayToolMsg( wxEmptyString );
} }
if( zoom_command ) if( zoom_command )
Window_Zoom( GetScreen()->BlockLocate ); Window_Zoom( GetScreen()->m_BlockLocate );
return endcommande; return endcommande;
} }
...@@ -230,34 +230,28 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool era ...@@ -230,34 +230,28 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool era
int Color; int Color;
BASE_SCREEN* screen = panel->GetScreen(); BASE_SCREEN* screen = panel->GetScreen();
Color = YELLOW; GRSetDrawMode( DC, g_XorMode ); Color = YELLOW;
/* Effacement ancien cadre */ /* Effacement ancien cadre */
if( erase ) if( erase )
{ {
screen->BlockLocate.Draw( panel, DC ); screen->m_BlockLocate.Draw( panel, DC, wxPoint(0,0),g_XorMode, Color );
if( screen->BlockLocate.m_MoveVector.x || screen->BlockLocate.m_MoveVector.y ) if( screen->m_BlockLocate.m_MoveVector.x || screen->m_BlockLocate.m_MoveVector.y )
{ {
screen->BlockLocate.Offset( screen->BlockLocate.m_MoveVector ); screen->m_BlockLocate.Draw( panel, DC, screen->m_BlockLocate.m_MoveVector,g_XorMode, Color );
screen->BlockLocate.Draw( panel, DC );
screen->BlockLocate.Offset( -screen->BlockLocate.m_MoveVector.x,
-screen->BlockLocate.m_MoveVector.y );
} }
} }
if( panel->GetScreen()->BlockLocate.m_State != STATE_BLOCK_STOP ) if( panel->GetScreen()->m_BlockLocate.m_State != STATE_BLOCK_STOP )
{ {
screen->BlockLocate.m_MoveVector.x = screen->m_Curseur.x - screen->BlockLocate.GetRight(); screen->m_BlockLocate.m_MoveVector.x = screen->m_Curseur.x - screen->m_BlockLocate.GetRight();
screen->BlockLocate.m_MoveVector.y = screen->m_Curseur.y - screen->BlockLocate.GetBottom(); screen->m_BlockLocate.m_MoveVector.y = screen->m_Curseur.y - screen->m_BlockLocate.GetBottom();
} }
screen->BlockLocate.Draw( panel, DC ); screen->m_BlockLocate.Draw( panel, DC, wxPoint(0,0),g_XorMode, Color );
if( screen->BlockLocate.m_MoveVector.x || screen->BlockLocate.m_MoveVector.y ) if( screen->m_BlockLocate.m_MoveVector.x || screen->m_BlockLocate.m_MoveVector.y )
{ {
screen->BlockLocate.Offset( screen->BlockLocate.m_MoveVector ); screen->m_BlockLocate.Draw( panel, DC, screen->m_BlockLocate.m_MoveVector,g_XorMode, Color );
screen->BlockLocate.Draw( panel, DC );
screen->BlockLocate.Offset( -screen->BlockLocate.m_MoveVector.x,
-screen->BlockLocate.m_MoveVector.y );
} }
} }
...@@ -274,7 +268,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) ...@@ -274,7 +268,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
return; return;
GetScreen()->SetModify(); GetScreen()->SetModify();
GetScreen()->BlockLocate.Normalize(); GetScreen()->m_BlockLocate.Normalize();
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
/* Effacement des Pistes */ /* Effacement des Pistes */
...@@ -282,7 +276,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) ...@@ -282,7 +276,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = NextS ) for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = NextS )
{ {
NextS = pt_segm->Next(); NextS = pt_segm->Next();
if( IsSegmentInBox( GetScreen()->BlockLocate, pt_segm ) ) if( IsSegmentInBox( GetScreen()->m_BlockLocate, pt_segm ) )
{ {
/* la piste est ici bonne a etre efface */ /* la piste est ici bonne a etre efface */
pt_segm->Draw( DrawPanel, DC, GR_XOR ); pt_segm->Draw( DrawPanel, DC, GR_XOR );
...@@ -294,7 +288,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) ...@@ -294,7 +288,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
for( pt_segm = m_Pcb->m_Zone; pt_segm != NULL; pt_segm = NextS ) for( pt_segm = m_Pcb->m_Zone; pt_segm != NULL; pt_segm = NextS )
{ {
NextS = pt_segm->Next(); NextS = pt_segm->Next();
if( IsSegmentInBox( GetScreen()->BlockLocate, pt_segm ) ) if( IsSegmentInBox( GetScreen()->m_BlockLocate, pt_segm ) )
{ {
/* la piste est ici bonne a etre efface */ /* la piste est ici bonne a etre efface */
pt_segm->Draw( DrawPanel, DC, GR_XOR ); pt_segm->Draw( DrawPanel, DC, GR_XOR );
...@@ -324,16 +318,16 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) ...@@ -324,16 +318,16 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC )
GetScreen()->m_Curseur = oldpos; GetScreen()->m_Curseur = oldpos;
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
GetScreen()->SetModify(); GetScreen()->SetModify();
GetScreen()->BlockLocate.Normalize(); GetScreen()->m_BlockLocate.Normalize();
/* calcul du vecteur de deplacement pour les deplacements suivants */ /* calcul du vecteur de deplacement pour les deplacements suivants */
delta = GetScreen()->BlockLocate.m_MoveVector; delta = GetScreen()->m_BlockLocate.m_MoveVector;
/* Move the Track segments in block */ /* Move the Track segments in block */
TRACK* track = m_Pcb->m_Track; TRACK* track = m_Pcb->m_Track;
while( track ) while( track )
{ {
if( IsSegmentInBox( GetScreen()->BlockLocate, track ) ) if( IsSegmentInBox( GetScreen()->m_BlockLocate, track ) )
{ {
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
track->Draw( DrawPanel, DC, GR_XOR ); // erase the display track->Draw( DrawPanel, DC, GR_XOR ); // erase the display
...@@ -353,7 +347,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) ...@@ -353,7 +347,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC )
SEGZONE * zsegment= m_Pcb->m_Zone; SEGZONE * zsegment= m_Pcb->m_Zone;
while( zsegment ) while( zsegment )
{ {
if( IsSegmentInBox( GetScreen()->BlockLocate, zsegment ) ) if( IsSegmentInBox( GetScreen()->m_BlockLocate, zsegment ) )
{ {
zsegment->Draw( DrawPanel, DC, GR_XOR ); // erase the display zsegment->Draw( DrawPanel, DC, GR_XOR ); // erase the display
zsegment->m_Start += delta; zsegment->m_Start += delta;
...@@ -388,16 +382,16 @@ void WinEDA_BasePcbFrame::Block_Mirror_X( wxDC* DC ) ...@@ -388,16 +382,16 @@ void WinEDA_BasePcbFrame::Block_Mirror_X( wxDC* DC )
GetScreen()->m_Curseur = oldpos; GetScreen()->m_Curseur = oldpos;
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
GetScreen()->SetModify(); GetScreen()->SetModify();
GetScreen()->BlockLocate.Normalize(); GetScreen()->m_BlockLocate.Normalize();
/* Calculate offset to mirror track points from block edges */ /* Calculate offset to mirror track points from block edges */
xoffset = GetScreen()->BlockLocate.m_Pos.x + GetScreen()->BlockLocate.m_Pos.x xoffset = GetScreen()->m_BlockLocate.m_Pos.x + GetScreen()->m_BlockLocate.m_Pos.x
+ GetScreen()->BlockLocate.m_Size.x; + GetScreen()->m_BlockLocate.m_Size.x;
/* Move the Track segments in block */ /* Move the Track segments in block */
for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() ) for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() )
{ {
if( IsSegmentInBox( GetScreen()->BlockLocate, track ) ) if( IsSegmentInBox( GetScreen()->m_BlockLocate, track ) )
{ {
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
track->Draw( DrawPanel, DC, GR_XOR ); // erase the display track->Draw( DrawPanel, DC, GR_XOR ); // erase the display
...@@ -414,7 +408,7 @@ void WinEDA_BasePcbFrame::Block_Mirror_X( wxDC* DC ) ...@@ -414,7 +408,7 @@ void WinEDA_BasePcbFrame::Block_Mirror_X( wxDC* DC )
/* Move the Zone segments in block */ /* Move the Zone segments in block */
for( SEGZONE* zsegment = m_Pcb->m_Zone; zsegment; zsegment = zsegment->Next() ) for( SEGZONE* zsegment = m_Pcb->m_Zone; zsegment; zsegment = zsegment->Next() )
{ {
if( IsSegmentInBox( GetScreen()->BlockLocate, zsegment ) ) if( IsSegmentInBox( GetScreen()->m_BlockLocate, zsegment ) )
{ {
zsegment->Draw( DrawPanel, DC, GR_XOR ); // erase the display zsegment->Draw( DrawPanel, DC, GR_XOR ); // erase the display
zsegment->m_Start.x = xoffset - zsegment->m_Start.x; zsegment->m_Start.x = xoffset - zsegment->m_Start.x;
...@@ -426,7 +420,7 @@ void WinEDA_BasePcbFrame::Block_Mirror_X( wxDC* DC ) ...@@ -426,7 +420,7 @@ void WinEDA_BasePcbFrame::Block_Mirror_X( wxDC* DC )
zsegment->Draw( DrawPanel, DC, GR_OR ); // redraw the moved zone zegment zsegment->Draw( DrawPanel, DC, GR_OR ); // redraw the moved zone zegment
} }
} }
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
} }
...@@ -448,18 +442,18 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) ...@@ -448,18 +442,18 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
GetScreen()->m_Curseur = oldpos; GetScreen()->m_Curseur = oldpos;
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
GetScreen()->SetModify(); GetScreen()->SetModify();
GetScreen()->BlockLocate.Normalize(); GetScreen()->m_BlockLocate.Normalize();
/* calcul du vecteur de deplacement pour les deplacements suivants */ /* calcul du vecteur de deplacement pour les deplacements suivants */
delta = GetScreen()->BlockLocate.m_MoveVector; delta = GetScreen()->m_BlockLocate.m_MoveVector;
/* Copy selected track segments and move the new track its new location */ /* Copy selected track segments and move the new track its new location */
TRACK* track = m_Pcb->m_Track; TRACK* track = m_Pcb->m_Track;
while( track ) while( track )
{ {
TRACK* next_track = track->Next(); TRACK* next_track = track->Next();
if( IsSegmentInBox( GetScreen()->BlockLocate, track ) ) if( IsSegmentInBox( GetScreen()->m_BlockLocate, track ) )
{ {
/* this track segment must be duplicated */ /* this track segment must be duplicated */
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
...@@ -480,7 +474,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) ...@@ -480,7 +474,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
while( zsegment ) while( zsegment )
{ {
SEGZONE * next_zsegment = zsegment->Next(); SEGZONE * next_zsegment = zsegment->Next();
if( IsSegmentInBox( GetScreen()->BlockLocate, zsegment ) ) if( IsSegmentInBox( GetScreen()->m_BlockLocate, zsegment ) )
{ {
/* this zone segment must be duplicated */ /* this zone segment must be duplicated */
SEGZONE * new_zsegment = (SEGZONE*) zsegment->Copy(); SEGZONE * new_zsegment = (SEGZONE*) zsegment->Copy();
...@@ -498,7 +492,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) ...@@ -498,7 +492,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
/**************************************************************************/ /**************************************************************************/
static TRACK* IsSegmentInBox( DrawBlockStruct& blocklocate, TRACK* PtSegm ) static TRACK* IsSegmentInBox( BLOCK_SELECTOR& blocklocate, TRACK* PtSegm )
/**************************************************************************/ /**************************************************************************/
/* Teste si la structure PtStruct est inscrite dans le block selectionne /* Teste si la structure PtStruct est inscrite dans le block selectionne
......
...@@ -108,11 +108,11 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -108,11 +108,11 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
} }
/* ne devrait pas etre execute, sauf bug */ /* ne devrait pas etre execute, sauf bug */
if( GetScreen()->BlockLocate.m_Command != BLOCK_IDLE ) if( GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE )
{ {
GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; GetScreen()->m_BlockLocate.ClearItemsList();
} }
if( m_ID_current_state == 0 ) if( m_ID_current_state == 0 )
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
...@@ -250,34 +250,34 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -250,34 +250,34 @@ void WinEDA_GerberFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_PLACE_BLOCK: case ID_POPUP_PLACE_BLOCK:
GetScreen()->BlockLocate.m_Command = BLOCK_MOVE; GetScreen()->m_BlockLocate.m_Command = BLOCK_MOVE;
DrawPanel->m_AutoPAN_Request = FALSE; DrawPanel->m_AutoPAN_Request = FALSE;
HandleBlockPlace( &dc ); HandleBlockPlace( &dc );
break; break;
case ID_POPUP_COPY_BLOCK: case ID_POPUP_COPY_BLOCK:
GetScreen()->BlockLocate.m_Command = BLOCK_COPY; GetScreen()->m_BlockLocate.m_Command = BLOCK_COPY;
GetScreen()->BlockLocate.SetMessageBlock( this ); GetScreen()->m_BlockLocate.SetMessageBlock( this );
DrawPanel->m_AutoPAN_Request = FALSE; DrawPanel->m_AutoPAN_Request = FALSE;
HandleBlockEnd( &dc ); HandleBlockEnd( &dc );
break; break;
case ID_POPUP_ZOOM_BLOCK: case ID_POPUP_ZOOM_BLOCK:
GetScreen()->BlockLocate.m_Command = BLOCK_ZOOM; GetScreen()->m_BlockLocate.m_Command = BLOCK_ZOOM;
GetScreen()->BlockLocate.SetMessageBlock( this ); GetScreen()->m_BlockLocate.SetMessageBlock( this );
GetScreen()->BlockLocate.SetMessageBlock( this ); GetScreen()->m_BlockLocate.SetMessageBlock( this );
HandleBlockEnd( &dc ); HandleBlockEnd( &dc );
break; break;
case ID_POPUP_DELETE_BLOCK: case ID_POPUP_DELETE_BLOCK:
GetScreen()->BlockLocate.m_Command = BLOCK_DELETE; GetScreen()->m_BlockLocate.m_Command = BLOCK_DELETE;
GetScreen()->BlockLocate.SetMessageBlock( this ); GetScreen()->m_BlockLocate.SetMessageBlock( this );
HandleBlockEnd( &dc ); HandleBlockEnd( &dc );
break; break;
case ID_POPUP_MIRROR_X_BLOCK: case ID_POPUP_MIRROR_X_BLOCK:
GetScreen()->BlockLocate.m_Command = BLOCK_MIRROR_X; GetScreen()->m_BlockLocate.m_Command = BLOCK_MIRROR_X;
GetScreen()->BlockLocate.SetMessageBlock( this ); GetScreen()->m_BlockLocate.SetMessageBlock( this );
HandleBlockEnd( &dc ); HandleBlockEnd( &dc );
break; break;
......
...@@ -214,7 +214,7 @@ void WinEDA_GerberFrame::SetToolbars() ...@@ -214,7 +214,7 @@ void WinEDA_GerberFrame::SetToolbars()
if( m_HToolBar == NULL ) if( m_HToolBar == NULL )
return; return;
if( GetScreen()->BlockLocate.m_Command == BLOCK_MOVE ) if( GetScreen()->m_BlockLocate.m_Command == BLOCK_MOVE )
{ {
m_HToolBar->EnableTool( wxID_CUT, TRUE ); m_HToolBar->EnableTool( wxID_CUT, TRUE );
m_HToolBar->EnableTool( wxID_COPY, TRUE ); m_HToolBar->EnableTool( wxID_COPY, TRUE );
......
...@@ -22,7 +22,7 @@ bool WinEDA_GerberFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ...@@ -22,7 +22,7 @@ bool WinEDA_GerberFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu
{ {
BOARD_ITEM* DrawStruct = GetScreen()->GetCurItem(); BOARD_ITEM* DrawStruct = GetScreen()->GetCurItem();
wxString msg; wxString msg;
bool BlockActive = (GetScreen()->BlockLocate.m_Command != BLOCK_IDLE); bool BlockActive = (GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE);
DrawPanel->m_CanStartBlock = -1; // Ne pas engager un debut de bloc sur validation menu DrawPanel->m_CanStartBlock = -1; // Ne pas engager un debut de bloc sur validation menu
......
...@@ -8,18 +8,108 @@ ...@@ -8,18 +8,108 @@
#define __INCLUDE__BLOCK_COMMANDE_H__ 1 #define __INCLUDE__BLOCK_COMMANDE_H__ 1
void AbortBlockCurrentCommand( WinEDA_DrawPanel* Panel, wxDC* DC ); #include "base_struct.h"
#include "class_undoredo_container.h"
/* Cancel Current block operation. */
void InitBlockLocateDatas( WinEDA_DrawPanel* Panel, const wxPoint& startpos );
/* Init the initial values of a BlockLocate, before starting a block command */ // Forward declarations:
void DrawAndSizingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
/**************************/
/* class BLOCK_SELECTOR */
/**************************/
/**
* class BLOCK_SELECTOR is used to handle block selection and commands
*/
typedef enum {
/* definition de l'etat du block */
STATE_NO_BLOCK, /* Block non initialise */
STATE_BLOCK_INIT, /* Block initialise: 1er point defini */
STATE_BLOCK_END, /* Block initialise: 2eme point defini */
STATE_BLOCK_MOVE, /* Block en deplacement */
STATE_BLOCK_STOP /* Block fixe (fin de deplacement) */
} BlockState;
/* codes des differentes commandes sur block: */
typedef enum {
BLOCK_IDLE,
BLOCK_MOVE,
BLOCK_COPY,
BLOCK_SAVE,
BLOCK_DELETE,
BLOCK_PASTE,
BLOCK_DRAG,
BLOCK_ROTATE,
BLOCK_INVERT,
BLOCK_ZOOM,
BLOCK_ABORT,
BLOCK_PRESELECT_MOVE,
BLOCK_SELECT_ITEMS_ONLY,
BLOCK_MIRROR_X,
BLOCK_MIRROR_Y
} CmdBlockType;
class BLOCK_SELECTOR : public EDA_BaseStruct, public EDA_Rect
{
public:
BlockState m_State; /* Stae (enum BlockState) of the block */
CmdBlockType m_Command; /* Type (enum CmdBlockType) d'operation */
PICKED_ITEMS_LIST m_ItemsSelection; /* list of items selected in this block */
int m_Color; /* Block Color (for drawings) */
wxPoint m_MoveVector; /* Move distance in move, drag, copy ... command */
wxPoint m_BlockLastCursorPosition; /* Last Mouse position in block command
* = last cursor position in move commands
* = 0,0 in block paste */
public:
BLOCK_SELECTOR();
~BLOCK_SELECTOR();
/** function InitData
* Init the initial values of a BLOCK_SELECTOR, before starting a block command
*/
void InitData( WinEDA_DrawPanel* Panel, const wxPoint& startpos );
/** Function SetMessageBlock
* Displays the type of block command in the status bar of the window
*/
void SetMessageBlock( WinEDA_DrawFrame* frame );
void Draw( WinEDA_DrawPanel* aPanel,
wxDC* aDC, const wxPoint& aOffset,
int aDrawMode,
int aColor );
/** Function PushItem
* Add aItem to the list of items
* @param aItem = an ITEM_PICKER to add to the list
*/
void PushItem( ITEM_PICKER& aItem );
/** Function ClearListAndDeleteItems
* delete only the list of EDA_BaseStruct * pointers, AND the data pinted by m_Item
*/
void ClearListAndDeleteItems();
void ClearItemsList();
unsigned GetCount()
{
return m_ItemsSelection.GetCount();
}
};
/* Cancel Current block operation.
*/
void AbortBlockCurrentCommand( WinEDA_DrawPanel* Panel, wxDC* DC );
/* Redraw the outlines of the block which shows the search area for block commands /* Redraw the outlines of the block which shows the search area for block commands
* The first point of the rectangle showing the area is initialised * The first point of the rectangle showing the area is initialised
* by InitBlockLocateDatas(). * by InitBlockLocateDatas().
* The other point of the rectangle is the mouse cursor */ * The other point of the rectangle is the mouse cursor
*/
void DrawAndSizingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
#endif /* __INCLUDE__BLOCK_COMMANDE_H__ */ #endif /* __INCLUDE__BLOCK_COMMANDE_H__ */
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
**********************/ **********************/
/* define : /* define :
* class DrawBlockStruct used to handle block commands
* class BASE_SCREEN to handle how to draw a screen (a board, a schematic ...) * class BASE_SCREEN to handle how to draw a screen (a board, a schematic ...)
*/ */
...@@ -12,6 +11,7 @@ ...@@ -12,6 +11,7 @@
#include "base_struct.h" #include "base_struct.h"
#include "class_undoredo_container.h" #include "class_undoredo_container.h"
#include "block_commande.h"
// Forward declarations: // Forward declarations:
...@@ -19,65 +19,11 @@ class SCH_ITEM; ...@@ -19,65 +19,11 @@ class SCH_ITEM;
class Ki_PageDescr; class Ki_PageDescr;
/**************************/
/* class DrawBlockStruct */
/**************************/
/* Definition d'un block pour les fonctions sur block (block move, ..) */
typedef enum {
/* definition de l'etat du block */
STATE_NO_BLOCK, /* Block non initialise */
STATE_BLOCK_INIT, /* Block initialise: 1er point defini */
STATE_BLOCK_END, /* Block initialise: 2eme point defini */
STATE_BLOCK_MOVE, /* Block en deplacement */
STATE_BLOCK_STOP /* Block fixe (fin de deplacement) */
} BlockState;
/* codes des differentes commandes sur block: */
typedef enum {
BLOCK_IDLE,
BLOCK_MOVE,
BLOCK_COPY,
BLOCK_SAVE,
BLOCK_DELETE,
BLOCK_PASTE,
BLOCK_DRAG,
BLOCK_ROTATE,
BLOCK_INVERT,
BLOCK_ZOOM,
BLOCK_ABORT,
BLOCK_PRESELECT_MOVE,
BLOCK_SELECT_ITEMS_ONLY,
BLOCK_MIRROR_X,
BLOCK_MIRROR_Y
} CmdBlockType;
class DrawBlockStruct : public EDA_BaseStruct, public EDA_Rect
{
public:
BlockState m_State; /* Etat (enum BlockState) du block */
CmdBlockType m_Command; /* Type (enum CmdBlockType) d'operation */
EDA_BaseStruct* m_BlockDrawStruct; /* pointeur sur la structure
* selectionnee dans le bloc */
int m_Color; /* Block Color */
wxPoint m_MoveVector; /* Move distance in move, drag, copy ... command */
wxPoint m_BlockLastCursorPosition; /* Last Mouse position in block command
* = last cursor position in move commands
* = 0,0 in block paste */
public:
DrawBlockStruct();
~DrawBlockStruct();
void SetMessageBlock( WinEDA_DrawFrame* frame );
void Draw( WinEDA_DrawPanel* panel, wxDC* DC );
};
/* Simple class for handling grid arrays. */ /* Simple class for handling grid arrays. */
class GRID_TYPE class GRID_TYPE
{ {
public: public:
int m_Id; int m_Id;
wxRealPoint m_Size; wxRealPoint m_Size;
}; };
...@@ -93,9 +39,9 @@ WX_DECLARE_OBJARRAY( GRID_TYPE, GridArray ); ...@@ -93,9 +39,9 @@ WX_DECLARE_OBJARRAY( GRID_TYPE, GridArray );
class BASE_SCREEN : public EDA_BaseStruct class BASE_SCREEN : public EDA_BaseStruct
{ {
public: public:
wxPoint m_DrawOrg; /* offsets pour tracer le circuit sur l'ecran */ wxPoint m_DrawOrg; /* offsets pour tracer le circuit sur l'ecran */
wxPoint m_Curseur; /* Screen cursor coordinate (on grid) in user units. */ wxPoint m_Curseur; /* Screen cursor coordinate (on grid) in user units. */
wxPoint m_MousePosition; /* Mouse cursor coordinate (off grid) in user units. */ wxPoint m_MousePosition; /* Mouse cursor coordinate (off grid) in user units. */
wxPoint m_MousePositionInPixels; wxPoint m_MousePositionInPixels;
wxPoint m_O_Curseur; /* Relative Screen cursor coordinate (on grid) in user units. wxPoint m_O_Curseur; /* Relative Screen cursor coordinate (on grid) in user units.
* (coordinates from last reset position)*/ * (coordinates from last reset position)*/
...@@ -115,32 +61,32 @@ public: ...@@ -115,32 +61,32 @@ public:
* > 0 all but schematic * > 0 all but schematic
* FALSE: when coordinates can be only >= 0 * FALSE: when coordinates can be only >= 0
* Schematic */ * Schematic */
bool m_FirstRedraw; bool m_FirstRedraw;
SCH_ITEM* EEDrawList; /* Object list (main data) for schematic */ SCH_ITEM* EEDrawList; /* Object list (main data) for schematic */
// Undo/redo list of commands // Undo/redo list of commands
UNDO_REDO_CONTAINER m_UndoList; /* Object list for the undo command (old data) */ UNDO_REDO_CONTAINER m_UndoList; /* Objects list for the undo command (old data) */
UNDO_REDO_CONTAINER m_RedoList; /* Object list for the redo command (old data) */ UNDO_REDO_CONTAINER m_RedoList; /* Objects list for the redo command (old data) */
unsigned m_UndoRedoCountMax; // undo/Redo command Max depth unsigned m_UndoRedoCountMax; // undo/Redo command Max depth
/* block control */ /* block control */
DrawBlockStruct BlockLocate; /* Bock description for block commands */ BLOCK_SELECTOR m_BlockLocate; /* Block description for block commands */
/* Page description */ /* Page description */
Ki_PageDescr* m_CurrentSheetDesc; Ki_PageDescr* m_CurrentSheetDesc;
int m_ScreenNumber; int m_ScreenNumber;
int m_NumberOfScreen; int m_NumberOfScreen;
wxString m_FileName; wxString m_FileName;
wxString m_Title; /* titre de la feuille */ wxString m_Title; /* titre de la feuille */
wxString m_Date; /* date de mise a jour */ wxString m_Date; /* date de mise a jour */
wxString m_Revision; /* code de revision */ wxString m_Revision; /* code de revision */
wxString m_Company; /* nom du proprietaire */ wxString m_Company; /* nom du proprietaire */
wxString m_Commentaire1; wxString m_Commentaire1;
wxString m_Commentaire2; wxString m_Commentaire2;
wxString m_Commentaire3; wxString m_Commentaire3;
wxString m_Commentaire4; wxString m_Commentaire4;
private: private:
/* indicateurs divers */ /* indicateurs divers */
...@@ -151,14 +97,14 @@ private: ...@@ -151,14 +97,14 @@ private:
/* Valeurs du pas de grille et du zoom */ /* Valeurs du pas de grille et du zoom */
public: public:
wxRealPoint m_Grid; /* Current grid. */ wxRealPoint m_Grid; /* Current grid. */
GridArray m_GridList; GridArray m_GridList;
bool m_UserGridIsON; bool m_UserGridIsON;
wxArrayInt m_ZoomList; /* Array of standard zoom coefficients. */ wxArrayInt m_ZoomList; /* Array of standard zoom coefficients. */
int m_Zoom; /* Current zoom coefficient. */ int m_Zoom; /* Current zoom coefficient. */
int m_ZoomScalar; /* Allow zooming to non-integer increments. */ int m_ZoomScalar; /* Allow zooming to non-integer increments. */
bool m_IsPrinting; bool m_IsPrinting;
public: public:
BASE_SCREEN( KICAD_T aType = SCREEN_STRUCT_TYPE ); BASE_SCREEN( KICAD_T aType = SCREEN_STRUCT_TYPE );
...@@ -176,32 +122,36 @@ public: ...@@ -176,32 +122,36 @@ public:
void SetCurItem( EDA_BaseStruct* current ) { m_CurrentItem = current; } void SetCurItem( EDA_BaseStruct* current ) { m_CurrentItem = current; }
EDA_BaseStruct* GetCurItem() const { return m_CurrentItem; } EDA_BaseStruct* GetCurItem() const { return m_CurrentItem; }
void InitDatas(); /* Inits completes des variables */ void InitDatas(); /* Inits completes des variables */
wxSize ReturnPageSize( void ); wxSize ReturnPageSize( void );
virtual int GetInternalUnits( void ); virtual int GetInternalUnits( void );
/** Function CursorRealPosition /** Function CursorRealPosition
* @return the position in user units of location ScreenPos * @return the position in user units of location ScreenPos
* @param ScreenPos = the screen (in pixel) position co convert * @param ScreenPos = the screen (in pixel) position co convert
*/ */
wxPoint CursorRealPosition( const wxPoint& ScreenPos ); wxPoint CursorRealPosition( const wxPoint& ScreenPos );
/* general Undo/Redo command control */ /* general Undo/Redo command control */
virtual void ClearUndoRedoList(); virtual void ClearUndoRedoList();
virtual void PushCommandToUndoList( PICKED_ITEMS_LIST* aItem ); virtual void PushCommandToUndoList( PICKED_ITEMS_LIST* aItem );
virtual void PushCommandToRedoList( PICKED_ITEMS_LIST* aItem ); virtual void PushCommandToRedoList( PICKED_ITEMS_LIST* aItem );
virtual PICKED_ITEMS_LIST* PopCommandFromUndoList(); virtual PICKED_ITEMS_LIST* PopCommandFromUndoList();
virtual PICKED_ITEMS_LIST* PopCommandFromRedoList(); virtual PICKED_ITEMS_LIST* PopCommandFromRedoList();
int GetUndoCommandCount( )
int GetUndoCommandCount()
{ {
return m_UndoList.m_CommandsList.size(); return m_UndoList.m_CommandsList.size();
} }
int GetRedoCommandCount( )
int GetRedoCommandCount()
{ {
return m_RedoList.m_CommandsList.size(); return m_RedoList.m_CommandsList.size();
} }
/* Manipulation des flags */ /* Manipulation des flags */
void SetRefreshReq() { m_FlagRefreshReq = 1; } void SetRefreshReq() { m_FlagRefreshReq = 1; }
void ClrRefreshReq() { m_FlagRefreshReq = 0; } void ClrRefreshReq() { m_FlagRefreshReq = 0; }
...@@ -230,51 +180,51 @@ public: ...@@ -230,51 +180,51 @@ public:
* @param the the current scale used to draw items on screen * @param the the current scale used to draw items on screen
* draw coordinates are user coordinates * GetScalingFactor( ) * draw coordinates are user coordinates * GetScalingFactor( )
*/ */
void SetScalingFactor( double aScale ); void SetScalingFactor( double aScale );
/** Function GetZoom /** Function GetZoom
* @return the current zoom factor * @return the current zoom factor
* Note: the zoom factor is NOT the scaling factor * Note: the zoom factor is NOT the scaling factor
* the scaling factor is m_ZoomScalar * GetZoom() * the scaling factor is m_ZoomScalar * GetZoom()
*/ */
int GetZoom() const; int GetZoom() const;
/** /**
* Function SetZoom * Function SetZoom
* adjusts the current zoom factor * adjusts the current zoom factor
*/ */
bool SetZoom( int coeff ); bool SetZoom( int coeff );
/** /**
* Function SetZoomList * Function SetZoomList
* sets the list of zoom factors. * sets the list of zoom factors.
* @param aZoomList An array of zoom factors in ascending order, zero terminated * @param aZoomList An array of zoom factors in ascending order, zero terminated
*/ */
void SetZoomList( const wxArrayInt& zoomlist ); void SetZoomList( const wxArrayInt& zoomlist );
int Scale( int coord ); int Scale( int coord );
double Scale( double coord ); double Scale( double coord );
void Scale( wxPoint& pt ); void Scale( wxPoint& pt );
void Scale( wxSize& sz ); void Scale( wxSize& sz );
void Scale( wxRealPoint& sz ); void Scale( wxRealPoint& sz );
int Unscale( int coord ); int Unscale( int coord );
void Unscale( wxPoint& pt ); void Unscale( wxPoint& pt );
void Unscale( wxSize& sz ); void Unscale( wxSize& sz );
bool SetNextZoom(); /* ajuste le prochain coeff de zoom */ bool SetNextZoom(); /* ajuste le prochain coeff de zoom */
bool SetPreviousZoom(); /* ajuste le precedent coeff de zoom */ bool SetPreviousZoom(); /* ajuste le precedent coeff de zoom */
bool SetFirstZoom(); /* ajuste le coeff de zoom a 1*/ bool SetFirstZoom(); /* ajuste le coeff de zoom a 1*/
bool SetLastZoom(); /* ajuste le coeff de zoom au max */ bool SetLastZoom(); /* ajuste le coeff de zoom au max */
//----<grid stuff>---------------------------------------------------------- //----<grid stuff>----------------------------------------------------------
wxRealPoint GetGrid(); /* retourne la grille */ wxRealPoint GetGrid(); /* retourne la grille */
void SetGrid( const wxRealPoint& size ); void SetGrid( const wxRealPoint& size );
void SetGrid( int ); void SetGrid( int );
void SetGridList( GridArray& sizelist ); void SetGridList( GridArray& sizelist );
void AddGrid( const GRID_TYPE& grid ); void AddGrid( const GRID_TYPE& grid );
void AddGrid( const wxRealPoint& size, int id ); void AddGrid( const wxRealPoint& size, int id );
void AddGrid( const wxRealPoint& size, int units, int id ); void AddGrid( const wxRealPoint& size, int units, int id );
/** /**
......
...@@ -88,9 +88,18 @@ public: ...@@ -88,9 +88,18 @@ public:
~PICKED_ITEMS_LIST(); ~PICKED_ITEMS_LIST();
void PushItem( ITEM_PICKER& aItem ); void PushItem( ITEM_PICKER& aItem );
ITEM_PICKER PopItem(); ITEM_PICKER PopItem();
/** Function ClearItemsList
* delete only the list of EDA_BaseStruct * pointers, NOT the pointed data itself
*/
void ClearItemsList(); void ClearItemsList();
unsigned GetCount() /** Function ClearListAndDeleteItems
* delete only the list of EDA_BaseStruct * pointers, AND the data pinted by m_Item
*/
void ClearListAndDeleteItems();
unsigned GetCount() const
{ {
return m_ItemsList.size(); return m_ItemsList.size();
} }
...@@ -105,6 +114,12 @@ public: ...@@ -105,6 +114,12 @@ public:
bool SetLink( EDA_BaseStruct* aItem, unsigned aIdx ); bool SetLink( EDA_BaseStruct* aItem, unsigned aIdx );
bool SetItemStatus( int aStatus, unsigned aIdx ); bool SetItemStatus( int aStatus, unsigned aIdx );
bool RemoveItem( unsigned aIdx ); bool RemoveItem( unsigned aIdx );
/** Function CopyList
* copy all data from aSource
* Items picked are not copied. just pointer on them are copied
*/
void CopyList(const PICKED_ITEMS_LIST & aSource);
}; };
/** /**
......
...@@ -364,12 +364,12 @@ private: ...@@ -364,12 +364,12 @@ private:
void RotateCmpField( SCH_CMP_FIELD* Field, wxDC* DC ); void RotateCmpField( SCH_CMP_FIELD* Field, wxDC* DC );
/* Operations sur bloc */ /* Operations sur bloc */
void PasteStruct( wxDC* DC ); void PasteListOfItems( wxDC* DC );
/* Undo - redo */ /* Undo - redo */
public: public:
void SaveCopyInUndoList( SCH_ITEM* ItemToCopy, void SaveCopyInUndoList( SCH_ITEM* ItemToCopy, int aTypeCommand );
int flag_type_command = 0 ); void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, int aTypeCommand );
private: private:
void PutDataInPreviousState( PICKED_ITEMS_LIST* aList ); void PutDataInPreviousState( PICKED_ITEMS_LIST* aList );
......
...@@ -247,9 +247,9 @@ void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC ) ...@@ -247,9 +247,9 @@ void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC )
err = TRUE; err = TRUE;
DisplayError( this, wxT( "Error in HandleBlockPLace : ManageCurseur = NULL" ) ); DisplayError( this, wxT( "Error in HandleBlockPLace : ManageCurseur = NULL" ) );
} }
GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP;
switch( GetScreen()->BlockLocate.m_Command ) switch( GetScreen()->m_BlockLocate.m_Command )
{ {
case BLOCK_IDLE: case BLOCK_IDLE:
err = TRUE; err = TRUE;
...@@ -261,14 +261,14 @@ void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC ) ...@@ -261,14 +261,14 @@ void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC )
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
Block_Move( DC ); Block_Move( DC );
GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; GetScreen()->m_BlockLocate.ClearItemsList();
break; break;
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
Block_Duplicate( DC ); Block_Duplicate( DC );
GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; GetScreen()->m_BlockLocate.ClearItemsList();
break; break;
case BLOCK_PASTE: case BLOCK_PASTE:
...@@ -283,13 +283,13 @@ void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC ) ...@@ -283,13 +283,13 @@ void WinEDA_PcbFrame::HandleBlockPlace( wxDC* DC )
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->BlockLocate.m_Flags = 0; GetScreen()->m_BlockLocate.m_Flags = 0;
GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
if( GetScreen()->BlockLocate.m_BlockDrawStruct ) if( GetScreen()->m_BlockLocate.GetCount() )
{ {
DisplayError( this, wxT( "Error in HandleBlockPLace DrawStruct != NULL" ) ); DisplayError( this, wxT( "Error in HandleBlockPLace some items left in list" ) );
GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; GetScreen()->m_BlockLocate.ClearItemsList();
} }
DisplayToolMsg( wxEmptyString ); DisplayToolMsg( wxEmptyString );
...@@ -310,7 +310,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) ...@@ -310,7 +310,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
int endcommande = TRUE; int endcommande = TRUE;
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
switch( GetScreen()->BlockLocate.m_Command ) switch( GetScreen()->m_BlockLocate.m_Command )
{ {
case BLOCK_IDLE: case BLOCK_IDLE:
DisplayError( this, wxT( "Error in HandleBlockPLace" ) ); DisplayError( this, wxT( "Error in HandleBlockPLace" ) );
...@@ -320,7 +320,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) ...@@ -320,7 +320,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_MOVE: /* Move */ case BLOCK_MOVE: /* Move */
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE;
endcommande = FALSE; endcommande = FALSE;
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
DrawPanel->ManageCurseur = DrawMovingBlockOutlines; DrawPanel->ManageCurseur = DrawMovingBlockOutlines;
...@@ -331,7 +331,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) ...@@ -331,7 +331,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
// Turn off the block rectangle now so it is not redisplayed // Turn off the block rectangle now so it is not redisplayed
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP;
DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE ); DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE );
Block_Delete( DC ); Block_Delete( DC );
break; break;
...@@ -340,7 +340,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) ...@@ -340,7 +340,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
// Turn off the block rectangle now so it is not redisplayed // Turn off the block rectangle now so it is not redisplayed
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP;
DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE ); DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE );
Block_Rotate( DC ); Block_Rotate( DC );
break; break;
...@@ -349,18 +349,18 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) ...@@ -349,18 +349,18 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
// Turn off the block rectangle now so it is not redisplayed // Turn off the block rectangle now so it is not redisplayed
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP;
DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE ); DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE );
Block_Invert( DC ); Block_Invert( DC );
break; break;
case BLOCK_SAVE: /* Save (not used, for future enhancements)*/ case BLOCK_SAVE: /* Save (not used, for future enhancements)*/
GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP;
if( GetScreen()->BlockLocate.m_BlockDrawStruct != NULL ) if( GetScreen()->m_BlockLocate.GetCount() )
{ {
DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE ); DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE );
// SaveStruct(GetScreen()->BlockLocate.m_BlockDrawStruct); // SaveStruct(GetScreen()->m_BlockLocate.m_BlockDrawStruct);
} }
break; break;
...@@ -372,7 +372,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) ...@@ -372,7 +372,7 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
//Turn off the redraw block routine now so it is not displayed //Turn off the redraw block routine now so it is not displayed
// with one corner at the new center of the screen // with one corner at the new center of the screen
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
Window_Zoom( GetScreen()->BlockLocate ); Window_Zoom( GetScreen()->m_BlockLocate );
break; break;
default: default:
...@@ -381,10 +381,10 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC ) ...@@ -381,10 +381,10 @@ int WinEDA_PcbFrame::HandleBlockEnd( wxDC* DC )
if( endcommande == TRUE ) if( endcommande == TRUE )
{ {
GetScreen()->BlockLocate.m_Flags = 0; GetScreen()->m_BlockLocate.m_Flags = 0;
GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; GetScreen()->m_BlockLocate.ClearItemsList();
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
DisplayToolMsg( wxEmptyString ); DisplayToolMsg( wxEmptyString );
...@@ -405,34 +405,27 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool era ...@@ -405,34 +405,27 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool era
BASE_SCREEN* screen = panel->GetScreen(); BASE_SCREEN* screen = panel->GetScreen();
Color = YELLOW; Color = YELLOW;
GRSetDrawMode( DC, g_XorMode );
/* Effacement ancien cadre */ /* Effacement ancien cadre */
if( erase ) if( erase )
{ {
screen->BlockLocate.Draw( panel, DC ); screen->m_BlockLocate.Draw( panel, DC, wxPoint(0,0), g_XorMode, Color );
if( screen->BlockLocate.m_MoveVector.x || screen->BlockLocate.m_MoveVector.y ) if( screen->m_BlockLocate.m_MoveVector.x || screen->m_BlockLocate.m_MoveVector.y )
{ {
screen->BlockLocate.Offset( screen->BlockLocate.m_MoveVector ); screen->m_BlockLocate.Draw( panel, DC, screen->m_BlockLocate.m_MoveVector, g_XorMode, Color );
screen->BlockLocate.Draw( panel, DC );
screen->BlockLocate.Offset( -screen->BlockLocate.m_MoveVector.x,
-screen->BlockLocate.m_MoveVector.y );
} }
} }
if( screen->BlockLocate.m_State != STATE_BLOCK_STOP ) if( screen->m_BlockLocate.m_State != STATE_BLOCK_STOP )
{ {
screen->BlockLocate.m_MoveVector.x = screen->m_Curseur.x - screen->BlockLocate.GetRight(); screen->m_BlockLocate.m_MoveVector.x = screen->m_Curseur.x - screen->m_BlockLocate.GetRight();
screen->BlockLocate.m_MoveVector.y = screen->m_Curseur.y - screen->BlockLocate.GetBottom(); screen->m_BlockLocate.m_MoveVector.y = screen->m_Curseur.y - screen->m_BlockLocate.GetBottom();
} }
screen->BlockLocate.Draw( panel, DC ); screen->m_BlockLocate.Draw( panel, DC, wxPoint(0,0), g_XorMode, Color );
if( screen->BlockLocate.m_MoveVector.x || screen->BlockLocate.m_MoveVector.y ) if( screen->m_BlockLocate.m_MoveVector.x || screen->m_BlockLocate.m_MoveVector.y )
{ {
screen->BlockLocate.Offset( screen->BlockLocate.m_MoveVector ); screen->m_BlockLocate.Draw( panel, DC, screen->m_BlockLocate.m_MoveVector, g_XorMode, Color );
screen->BlockLocate.Draw( panel, DC );
screen->BlockLocate.Offset( -screen->BlockLocate.m_MoveVector.x,
-screen->BlockLocate.m_MoveVector.y );
} }
} }
...@@ -452,7 +445,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) ...@@ -452,7 +445,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
return; return;
GetScreen()->SetModify(); GetScreen()->SetModify();
GetScreen()->BlockLocate.Normalize(); GetScreen()->m_BlockLocate.Normalize();
SetCurItem( NULL ); SetCurItem( NULL );
/* Effacement des modules */ /* Effacement des modules */
...@@ -463,7 +456,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) ...@@ -463,7 +456,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
for( ; module != NULL; module = (MODULE*) NextS ) for( ; module != NULL; module = (MODULE*) NextS )
{ {
NextS = module->Next(); NextS = module->Next();
if( module->HitTest( GetScreen()->BlockLocate ) ) if( module->HitTest( GetScreen()->m_BlockLocate ) )
{ {
module->m_Flags = 0; module->m_Flags = 0;
module->DeleteStructure(); module->DeleteStructure();
...@@ -480,7 +473,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) ...@@ -480,7 +473,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = (TRACK*) NextS ) for( pt_segm = m_Pcb->m_Track; pt_segm != NULL; pt_segm = (TRACK*) NextS )
{ {
NextS = pt_segm->Next(); NextS = pt_segm->Next();
if( pt_segm->HitTest( GetScreen()->BlockLocate ) ) if( pt_segm->HitTest( GetScreen()->m_BlockLocate ) )
{ {
/* la piste est ici bonne a etre efface */ /* la piste est ici bonne a etre efface */
pt_segm->DeleteStructure(); pt_segm->DeleteStructure();
...@@ -506,7 +499,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) ...@@ -506,7 +499,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
case TYPE_DRAWSEGMENT: case TYPE_DRAWSEGMENT:
if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
break; break;
/* l'element est ici bon a etre efface */ /* l'element est ici bon a etre efface */
...@@ -517,7 +510,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) ...@@ -517,7 +510,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
case TYPE_TEXTE: case TYPE_TEXTE:
if( !Block_Include_PcbTextes ) if( !Block_Include_PcbTextes )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
break; break;
/* le texte est ici bon a etre efface */ /* le texte est ici bon a etre efface */
PtStruct->Draw( DrawPanel, DC, GR_XOR ); PtStruct->Draw( DrawPanel, DC, GR_XOR );
...@@ -528,7 +521,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) ...@@ -528,7 +521,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
case TYPE_MIRE: case TYPE_MIRE:
if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
break; break;
/* l'element est ici bon a etre efface */ /* l'element est ici bon a etre efface */
PtStruct->DeleteStructure(); PtStruct->DeleteStructure();
...@@ -537,7 +530,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) ...@@ -537,7 +530,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
case TYPE_COTATION: case TYPE_COTATION:
if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[PtStruct->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
break; break;
PtStruct->DeleteStructure(); PtStruct->DeleteStructure();
break; break;
...@@ -556,7 +549,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) ...@@ -556,7 +549,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
for( pt_segm = m_Pcb->m_Zone; pt_segm != NULL; pt_segm = NextSegZ ) for( pt_segm = m_Pcb->m_Zone; pt_segm != NULL; pt_segm = NextSegZ )
{ {
NextSegZ = pt_segm->Next(); NextSegZ = pt_segm->Next();
if( pt_segm->HitTest( GetScreen()->BlockLocate ) ) if( pt_segm->HitTest( GetScreen()->m_BlockLocate ) )
{ {
pt_segm->DeleteStructure(); pt_segm->DeleteStructure();
} }
...@@ -564,7 +557,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC ) ...@@ -564,7 +557,7 @@ void WinEDA_BasePcbFrame::Block_Delete( wxDC* DC )
for ( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ ) for ( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{ {
if( m_Pcb->GetArea(ii)->HitTest( GetScreen()->BlockLocate ) ) if( m_Pcb->GetArea(ii)->HitTest( GetScreen()->m_BlockLocate ) )
{ {
m_Pcb->Delete(m_Pcb->GetArea(ii)); m_Pcb->Delete(m_Pcb->GetArea(ii));
ii--; // because the current data was removed, ii points actually the next data ii--; // because the current data was removed, ii points actually the next data
...@@ -597,9 +590,9 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC ) ...@@ -597,9 +590,9 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC )
return; return;
oldpos = GetScreen()->m_Curseur; oldpos = GetScreen()->m_Curseur;
GetScreen()->BlockLocate.Normalize(); GetScreen()->m_BlockLocate.Normalize();
centre = GetScreen()->BlockLocate.Centre(); // This is the rotation centre centre = GetScreen()->m_BlockLocate.Centre(); // This is the rotation centre
GetScreen()->SetModify(); GetScreen()->SetModify();
...@@ -611,7 +604,7 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC ) ...@@ -611,7 +604,7 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC )
module = m_Pcb->m_Modules; module = m_Pcb->m_Modules;
for( ; module != NULL; module = module->Next() ) for( ; module != NULL; module = module->Next() )
{ {
if( ! module->HitTest( GetScreen()->BlockLocate ) ) if( ! module->HitTest( GetScreen()->m_BlockLocate ) )
continue; continue;
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
module->m_Flags = 0; module->m_Flags = 0;
...@@ -635,7 +628,7 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC ) ...@@ -635,7 +628,7 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC )
track = m_Pcb->m_Track; track = m_Pcb->m_Track;
while( track ) while( track )
{ {
if( track->HitTest( GetScreen()->BlockLocate ) ) if( track->HitTest( GetScreen()->m_BlockLocate ) )
{ /* la piste est ici bonne a etre deplacee */ { /* la piste est ici bonne a etre deplacee */
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
RotatePoint( &track->m_Start, centre, 900 ); RotatePoint( &track->m_Start, centre, 900 );
...@@ -654,7 +647,7 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC ) ...@@ -654,7 +647,7 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC )
track = (TRACK*) m_Pcb->m_Zone; track = (TRACK*) m_Pcb->m_Zone;
while( track ) while( track )
{ {
if( track->HitTest( GetScreen()->BlockLocate ) ) if( track->HitTest( GetScreen()->m_BlockLocate ) )
{ {
RotatePoint( &track->m_Start, centre, 900 ); RotatePoint( &track->m_Start, centre, 900 );
RotatePoint( &track->m_End, centre, 900 ); RotatePoint( &track->m_End, centre, 900 );
...@@ -663,7 +656,7 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC ) ...@@ -663,7 +656,7 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC )
} }
for ( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ ) for ( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{ {
if( m_Pcb->GetArea(ii)->HitTest( GetScreen()->BlockLocate ) ) if( m_Pcb->GetArea(ii)->HitTest( GetScreen()->m_BlockLocate ) )
{ {
m_Pcb->GetArea(ii)->Rotate(centre, 900); m_Pcb->GetArea(ii)->Rotate(centre, 900);
} }
...@@ -687,7 +680,7 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC ) ...@@ -687,7 +680,7 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC )
#define STRUCT ( (DRAWSEGMENT*) PtStruct ) #define STRUCT ( (DRAWSEGMENT*) PtStruct )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
break; break;
RotatePoint( &STRUCT->m_Start, centre, 900 ); RotatePoint( &STRUCT->m_Start, centre, 900 );
RotatePoint( &STRUCT->m_End, centre, 900 ); RotatePoint( &STRUCT->m_End, centre, 900 );
...@@ -698,7 +691,7 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC ) ...@@ -698,7 +691,7 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC )
#define STRUCT ( (TEXTE_PCB*) PtStruct ) #define STRUCT ( (TEXTE_PCB*) PtStruct )
if( !Block_Include_PcbTextes ) if( !Block_Include_PcbTextes )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
break; break;
RotatePoint( &STRUCT->m_Pos, centre, 900 ); RotatePoint( &STRUCT->m_Pos, centre, 900 );
STRUCT->m_Orient += 900; STRUCT->m_Orient += 900;
...@@ -711,7 +704,7 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC ) ...@@ -711,7 +704,7 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC )
#define STRUCT ( (MIREPCB*) PtStruct ) #define STRUCT ( (MIREPCB*) PtStruct )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
break; break;
/* l'element est ici bon a etre modifie */ /* l'element est ici bon a etre modifie */
RotatePoint( &STRUCT->m_Pos, centre, 900 ); RotatePoint( &STRUCT->m_Pos, centre, 900 );
...@@ -722,7 +715,7 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC ) ...@@ -722,7 +715,7 @@ void WinEDA_BasePcbFrame::Block_Rotate( wxDC* DC )
#define STRUCT ( (COTATION*) PtStruct ) #define STRUCT ( (COTATION*) PtStruct )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
break; break;
STRUCT->Rotate(centre, 900); STRUCT->Rotate(centre, 900);
break; break;
...@@ -759,10 +752,10 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) ...@@ -759,10 +752,10 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC )
return; return;
memo = GetScreen()->m_Curseur; memo = GetScreen()->m_Curseur;
GetScreen()->BlockLocate.Normalize(); GetScreen()->m_BlockLocate.Normalize();
/* calcul du centre d'inversion */ /* calcul du centre d'inversion */
centerY = GetScreen()->BlockLocate.Centre().y; centerY = GetScreen()->m_BlockLocate.Centre().y;
GetScreen()->SetModify(); GetScreen()->SetModify();
...@@ -773,7 +766,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) ...@@ -773,7 +766,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC )
module = m_Pcb->m_Modules; module = m_Pcb->m_Modules;
for( ; module != NULL; module = module->Next() ) for( ; module != NULL; module = module->Next() )
{ {
if( ! module->HitTest( GetScreen()->BlockLocate ) ) if( ! module->HitTest( GetScreen()->m_BlockLocate ) )
continue; continue;
/* le module est ici bon a etre efface */ /* le module est ici bon a etre efface */
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
...@@ -804,7 +797,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) ...@@ -804,7 +797,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC )
track = m_Pcb->m_Track; track = m_Pcb->m_Track;
while( track ) while( track )
{ {
if( track->HitTest( GetScreen()->BlockLocate ) ) if( track->HitTest( GetScreen()->m_BlockLocate ) )
{ /* la piste est ici bonne a etre deplacee */ { /* la piste est ici bonne a etre deplacee */
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
INVERT( track->m_Start.y ); INVERT( track->m_Start.y );
...@@ -826,7 +819,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) ...@@ -826,7 +819,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC )
track = (TRACK*) m_Pcb->m_Zone; track = (TRACK*) m_Pcb->m_Zone;
while( track ) while( track )
{ {
if( track->HitTest( GetScreen()->BlockLocate ) ) if( track->HitTest( GetScreen()->m_BlockLocate ) )
{ /* la piste est ici bonne a etre deplacee */ { /* la piste est ici bonne a etre deplacee */
INVERT( track->m_Start.y ); INVERT( track->m_Start.y );
INVERT( track->m_End.y ); INVERT( track->m_End.y );
...@@ -836,7 +829,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) ...@@ -836,7 +829,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC )
} }
for ( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ ) for ( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{ {
if( m_Pcb->GetArea(ii)->HitTest( GetScreen()->BlockLocate ) ) if( m_Pcb->GetArea(ii)->HitTest( GetScreen()->m_BlockLocate ) )
{ {
m_Pcb->GetArea(ii)->Mirror( wxPoint(0, centerY) ); m_Pcb->GetArea(ii)->Mirror( wxPoint(0, centerY) );
m_Pcb->GetArea(ii)->SetLayer( ChangeSideNumLayer( m_Pcb->GetArea(ii)->GetLayer() ) ); m_Pcb->GetArea(ii)->SetLayer( ChangeSideNumLayer( m_Pcb->GetArea(ii)->GetLayer() ) );
...@@ -860,7 +853,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) ...@@ -860,7 +853,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC )
#define STRUCT ( (DRAWSEGMENT*) PtStruct ) #define STRUCT ( (DRAWSEGMENT*) PtStruct )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
break; break;
/* l'element est ici bon a etre selectionne */ /* l'element est ici bon a etre selectionne */
if( STRUCT->m_Shape == S_ARC ) if( STRUCT->m_Shape == S_ARC )
...@@ -877,7 +870,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) ...@@ -877,7 +870,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC )
#define STRUCT ( (TEXTE_PCB*) PtStruct ) #define STRUCT ( (TEXTE_PCB*) PtStruct )
if( !Block_Include_PcbTextes ) if( !Block_Include_PcbTextes )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
break; break;
/* le texte est ici bon a etre selectionne*/ /* le texte est ici bon a etre selectionne*/
INVERT( STRUCT->m_Pos.y ); INVERT( STRUCT->m_Pos.y );
...@@ -894,7 +887,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) ...@@ -894,7 +887,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC )
#define STRUCT ( (MIREPCB*) PtStruct ) #define STRUCT ( (MIREPCB*) PtStruct )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
break; break;
/* l'element est ici bon a etre modifie */ /* l'element est ici bon a etre modifie */
INVERT( STRUCT->m_Pos.y ); INVERT( STRUCT->m_Pos.y );
...@@ -906,7 +899,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC ) ...@@ -906,7 +899,7 @@ void WinEDA_BasePcbFrame::Block_Invert( wxDC* DC )
#define STRUCT ( (COTATION*) PtStruct ) #define STRUCT ( (COTATION*) PtStruct )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! PtStruct->HitTest( GetScreen()->BlockLocate ) ) if( ! PtStruct->HitTest( GetScreen()->m_BlockLocate ) )
break; break;
/* l'element est ici bon a etre modifie */ /* l'element est ici bon a etre modifie */
...@@ -934,7 +927,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) ...@@ -934,7 +927,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC )
{ {
int masque_layer; int masque_layer;
wxPoint oldpos; wxPoint oldpos;
wxPoint MoveVector = GetScreen()->BlockLocate.m_MoveVector; wxPoint MoveVector = GetScreen()->m_BlockLocate.m_MoveVector;
oldpos = GetScreen()->m_Curseur; oldpos = GetScreen()->m_Curseur;
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
...@@ -945,7 +938,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) ...@@ -945,7 +938,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC )
GetScreen()->m_Curseur = oldpos; GetScreen()->m_Curseur = oldpos;
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
GetScreen()->SetModify(); GetScreen()->SetModify();
GetScreen()->BlockLocate.Normalize(); GetScreen()->m_BlockLocate.Normalize();
/* Deplacement des modules */ /* Deplacement des modules */
if( Block_Include_Modules ) if( Block_Include_Modules )
...@@ -955,7 +948,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) ...@@ -955,7 +948,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC )
for( MODULE* module = m_Pcb->m_Modules; module; module = module->Next() ) for( MODULE* module = m_Pcb->m_Modules; module; module = module->Next() )
{ {
if( ! module->HitTest( GetScreen()->BlockLocate ) ) if( ! module->HitTest( GetScreen()->m_BlockLocate ) )
continue; continue;
/* le module est ici bon a etre deplace */ /* le module est ici bon a etre deplace */
...@@ -974,7 +967,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) ...@@ -974,7 +967,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC )
{ {
for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() ) for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() )
{ {
if( track->HitTest( GetScreen()->BlockLocate ) ) if( track->HitTest( GetScreen()->m_BlockLocate ) )
{ /* la piste est ici bonne a etre deplacee */ { /* la piste est ici bonne a etre deplacee */
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
track->m_Start += MoveVector; track->m_Start += MoveVector;
...@@ -988,7 +981,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) ...@@ -988,7 +981,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC )
{ {
for( TRACK* track = m_Pcb->m_Zone; track; track = track->Next() ) for( TRACK* track = m_Pcb->m_Zone; track; track = track->Next() )
{ {
if( track->HitTest( GetScreen()->BlockLocate ) ) if( track->HitTest( GetScreen()->m_BlockLocate ) )
{ /* la piste est ici bonne a etre deplacee */ { /* la piste est ici bonne a etre deplacee */
track->m_Start += MoveVector; track->m_Start += MoveVector;
track->m_End += MoveVector; track->m_End += MoveVector;
...@@ -996,7 +989,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) ...@@ -996,7 +989,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC )
} }
for ( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ ) for ( int ii = 0; ii < m_Pcb->GetAreaCount(); ii++ )
{ {
if( m_Pcb->GetArea(ii)->HitTest( GetScreen()->BlockLocate ) ) if( m_Pcb->GetArea(ii)->HitTest( GetScreen()->m_BlockLocate ) )
{ {
m_Pcb->GetArea(ii)->Move( MoveVector ); m_Pcb->GetArea(ii)->Move( MoveVector );
} }
...@@ -1018,7 +1011,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) ...@@ -1018,7 +1011,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC )
#define STRUCT ( (DRAWSEGMENT*) item ) #define STRUCT ( (DRAWSEGMENT*) item )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! item->HitTest( GetScreen()->BlockLocate ) ) if( ! item->HitTest( GetScreen()->m_BlockLocate ) )
break; break;
/* l'element est ici bon a etre efface */ /* l'element est ici bon a etre efface */
STRUCT->m_Start += MoveVector; STRUCT->m_Start += MoveVector;
...@@ -1030,7 +1023,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) ...@@ -1030,7 +1023,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC )
#define STRUCT ( (TEXTE_PCB*) item ) #define STRUCT ( (TEXTE_PCB*) item )
if( !Block_Include_PcbTextes ) if( !Block_Include_PcbTextes )
break; break;
if( ! item->HitTest( GetScreen()->BlockLocate ) ) if( ! item->HitTest( GetScreen()->m_BlockLocate ) )
break; break;
/* le texte est ici bon a etre deplace */ /* le texte est ici bon a etre deplace */
/* Redessin du Texte */ /* Redessin du Texte */
...@@ -1042,7 +1035,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) ...@@ -1042,7 +1035,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC )
#define STRUCT ( (MIREPCB*) item ) #define STRUCT ( (MIREPCB*) item )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! item->HitTest( GetScreen()->BlockLocate ) ) if( ! item->HitTest( GetScreen()->m_BlockLocate ) )
break; break;
/* l'element est ici bon a etre efface */ /* l'element est ici bon a etre efface */
STRUCT->m_Pos += MoveVector; STRUCT->m_Pos += MoveVector;
...@@ -1053,7 +1046,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC ) ...@@ -1053,7 +1046,7 @@ void WinEDA_BasePcbFrame::Block_Move( wxDC* DC )
#define STRUCT ( (COTATION*) item ) #define STRUCT ( (COTATION*) item )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! item->HitTest( GetScreen()->BlockLocate ) ) if( ! item->HitTest( GetScreen()->m_BlockLocate ) )
break; break;
/* l'element est ici bon a etre efface */ /* l'element est ici bon a etre efface */
( (COTATION*) item )->Move( wxPoint(MoveVector) ); ( (COTATION*) item )->Move( wxPoint(MoveVector) );
...@@ -1079,7 +1072,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) ...@@ -1079,7 +1072,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
{ {
int masque_layer; int masque_layer;
wxPoint oldpos; wxPoint oldpos;
wxPoint MoveVector = GetScreen()->BlockLocate.m_MoveVector; wxPoint MoveVector = GetScreen()->m_BlockLocate.m_MoveVector;
oldpos = GetScreen()->m_Curseur; oldpos = GetScreen()->m_Curseur;
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
...@@ -1090,7 +1083,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) ...@@ -1090,7 +1083,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
GetScreen()->m_Curseur = oldpos; GetScreen()->m_Curseur = oldpos;
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
GetScreen()->SetModify(); GetScreen()->SetModify();
GetScreen()->BlockLocate.Normalize(); GetScreen()->m_BlockLocate.Normalize();
/* Module copy */ /* Module copy */
if( Block_Include_Modules ) if( Block_Include_Modules )
...@@ -1102,7 +1095,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) ...@@ -1102,7 +1095,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
for( MODULE* module= m_Pcb->m_Modules; module; module = module->Next() ) for( MODULE* module= m_Pcb->m_Modules; module; module = module->Next() )
{ {
MODULE* new_module; MODULE* new_module;
if( ! module->HitTest( GetScreen()->BlockLocate ) ) if( ! module->HitTest( GetScreen()->m_BlockLocate ) )
continue; continue;
/* le module est ici bon a etre deplace */ /* le module est ici bon a etre deplace */
...@@ -1130,7 +1123,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) ...@@ -1130,7 +1123,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
while( track ) while( track )
{ {
next_track = track->Next(); next_track = track->Next();
if( track->HitTest( GetScreen()->BlockLocate ) ) if( track->HitTest( GetScreen()->m_BlockLocate ) )
{ {
/* la piste est ici bonne a etre deplacee */ /* la piste est ici bonne a etre deplacee */
m_Pcb->m_Status_Pcb = 0; m_Pcb->m_Status_Pcb = 0;
...@@ -1150,7 +1143,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) ...@@ -1150,7 +1143,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
{ {
for( SEGZONE* segzone = m_Pcb->m_Zone; segzone; segzone = segzone->Next() ) for( SEGZONE* segzone = m_Pcb->m_Zone; segzone; segzone = segzone->Next() )
{ {
if( segzone->HitTest( GetScreen()->BlockLocate ) ) if( segzone->HitTest( GetScreen()->m_BlockLocate ) )
{ {
SEGZONE* new_segzone = (SEGZONE*) segzone->Copy(); SEGZONE* new_segzone = (SEGZONE*) segzone->Copy();
...@@ -1164,7 +1157,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) ...@@ -1164,7 +1157,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
unsigned imax = m_Pcb->GetAreaCount(); unsigned imax = m_Pcb->GetAreaCount();
for ( unsigned ii = 0; ii < imax; ii++ ) for ( unsigned ii = 0; ii < imax; ii++ )
{ {
if( m_Pcb->GetArea(ii)->HitTest( GetScreen()->BlockLocate ) ) if( m_Pcb->GetArea(ii)->HitTest( GetScreen()->m_BlockLocate ) )
{ {
ZONE_CONTAINER * new_zone = new ZONE_CONTAINER(m_Pcb); ZONE_CONTAINER * new_zone = new ZONE_CONTAINER(m_Pcb);
new_zone->Copy( m_Pcb->GetArea(ii) ); new_zone->Copy( m_Pcb->GetArea(ii) );
...@@ -1191,7 +1184,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) ...@@ -1191,7 +1184,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
#define STRUCT ( (DRAWSEGMENT*) item ) #define STRUCT ( (DRAWSEGMENT*) item )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! item->HitTest( GetScreen()->BlockLocate ) ) if( ! item->HitTest( GetScreen()->m_BlockLocate ) )
break; break;
/* l'element est ici bon a etre copie */ /* l'element est ici bon a etre copie */
...@@ -1211,7 +1204,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) ...@@ -1211,7 +1204,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
#define STRUCT ( (TEXTE_PCB*) item ) #define STRUCT ( (TEXTE_PCB*) item )
if( !Block_Include_PcbTextes ) if( !Block_Include_PcbTextes )
break; break;
if( ! item->HitTest( GetScreen()->BlockLocate ) ) if( ! item->HitTest( GetScreen()->m_BlockLocate ) )
break; break;
/* le texte est ici bon a etre deplace */ /* le texte est ici bon a etre deplace */
TEXTE_PCB* new_pcbtext = new TEXTE_PCB( m_Pcb ); TEXTE_PCB* new_pcbtext = new TEXTE_PCB( m_Pcb );
...@@ -1230,7 +1223,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) ...@@ -1230,7 +1223,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
#define STRUCT ( (MIREPCB*) item ) #define STRUCT ( (MIREPCB*) item )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! item->HitTest( GetScreen()->BlockLocate ) ) if( ! item->HitTest( GetScreen()->m_BlockLocate ) )
break; break;
/* l'element est ici bon a etre efface */ /* l'element est ici bon a etre efface */
MIREPCB* new_mire = new MIREPCB( m_Pcb ); MIREPCB* new_mire = new MIREPCB( m_Pcb );
...@@ -1248,7 +1241,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC ) ...@@ -1248,7 +1241,7 @@ void WinEDA_BasePcbFrame::Block_Duplicate( wxDC* DC )
#define STRUCT ( (COTATION*) item ) #define STRUCT ( (COTATION*) item )
if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 ) if( (g_TabOneLayerMask[STRUCT->GetLayer()] & masque_layer) == 0 )
break; break;
if( ! item->HitTest( GetScreen()->BlockLocate ) ) if( ! item->HitTest( GetScreen()->m_BlockLocate ) )
break; break;
/* l'element est ici bon a etre copie */ /* l'element est ici bon a etre copie */
COTATION* new_cotation = new COTATION( m_Pcb ); COTATION* new_cotation = new COTATION( m_Pcb );
......
...@@ -104,21 +104,21 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -104,21 +104,21 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
int ItemsCount = 0, MustDoPlace = 0; int ItemsCount = 0, MustDoPlace = 0;
MODULE* Currentmodule = GetBoard()->m_Modules; MODULE* Currentmodule = GetBoard()->m_Modules;
if( GetScreen()->BlockLocate.m_BlockDrawStruct ) if( GetScreen()->m_BlockLocate.GetCount() )
{ {
BlockState state = GetScreen()->BlockLocate.m_State; BlockState state = GetScreen()->m_BlockLocate.m_State;
CmdBlockType command = GetScreen()->BlockLocate.m_Command; CmdBlockType command = GetScreen()->m_BlockLocate.m_Command;
DrawPanel->ForceCloseManageCurseur( DrawPanel, DC ); DrawPanel->ForceCloseManageCurseur( DrawPanel, DC );
GetScreen()->BlockLocate.m_State = state; GetScreen()->m_BlockLocate.m_State = state;
GetScreen()->BlockLocate.m_Command = command; GetScreen()->m_BlockLocate.m_Command = command;
DrawPanel->ManageCurseur = DrawAndSizingBlockOutlines; DrawPanel->ManageCurseur = DrawAndSizingBlockOutlines;
DrawPanel->ForceCloseManageCurseur = AbortBlockCurrentCommand; DrawPanel->ForceCloseManageCurseur = AbortBlockCurrentCommand;
GetScreen()->m_Curseur.x = GetScreen()->BlockLocate.GetRight(); GetScreen()->m_Curseur.x = GetScreen()->m_BlockLocate.GetRight();
GetScreen()->m_Curseur.y = GetScreen()->BlockLocate.GetBottom(); GetScreen()->m_Curseur.y = GetScreen()->m_BlockLocate.GetBottom();
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
} }
switch( GetScreen()->BlockLocate.m_Command ) switch( GetScreen()->m_BlockLocate.m_Command )
{ {
case BLOCK_IDLE: case BLOCK_IDLE:
DisplayError( this, wxT( "Error in HandleBlockPLace" ) ); DisplayError( this, wxT( "Error in HandleBlockPLace" ) );
...@@ -127,7 +127,7 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -127,7 +127,7 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_DRAG: /* Drag */ case BLOCK_DRAG: /* Drag */
case BLOCK_MOVE: /* Move */ case BLOCK_MOVE: /* Move */
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
ItemsCount = MarkItemsInBloc( Currentmodule, GetScreen()->BlockLocate ); ItemsCount = MarkItemsInBloc( Currentmodule, GetScreen()->m_BlockLocate );
if( ItemsCount ) if( ItemsCount )
{ {
MustDoPlace = 1; MustDoPlace = 1;
...@@ -137,7 +137,7 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -137,7 +137,7 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
DrawPanel->ManageCurseur = DrawMovingBlockOutlines; DrawPanel->ManageCurseur = DrawMovingBlockOutlines;
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
} }
GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE;
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
} }
break; break;
...@@ -145,11 +145,11 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -145,11 +145,11 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
MustDoPlace = 1; MustDoPlace = 1;
DrawPanel->ManageCurseur = DrawMovingBlockOutlines; DrawPanel->ManageCurseur = DrawMovingBlockOutlines;
GetScreen()->BlockLocate.m_State = STATE_BLOCK_MOVE; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_MOVE;
break; break;
case BLOCK_DELETE: /* Delete */ case BLOCK_DELETE: /* Delete */
ItemsCount = MarkItemsInBloc( Currentmodule, GetScreen()->BlockLocate ); ItemsCount = MarkItemsInBloc( Currentmodule, GetScreen()->m_BlockLocate );
if( ItemsCount ) if( ItemsCount )
SaveCopyInUndoList( Currentmodule ); SaveCopyInUndoList( Currentmodule );
DeleteMarkedItems( Currentmodule ); DeleteMarkedItems( Currentmodule );
...@@ -160,24 +160,24 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -160,24 +160,24 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
break; break;
case BLOCK_ROTATE: case BLOCK_ROTATE:
ItemsCount = MarkItemsInBloc( Currentmodule, GetScreen()->BlockLocate ); ItemsCount = MarkItemsInBloc( Currentmodule, GetScreen()->m_BlockLocate );
if( ItemsCount ) if( ItemsCount )
SaveCopyInUndoList( Currentmodule ); SaveCopyInUndoList( Currentmodule );
RotateMarkedItems( Currentmodule, GetScreen()->BlockLocate.Centre() ); RotateMarkedItems( Currentmodule, GetScreen()->m_BlockLocate.Centre() );
break; break;
case BLOCK_MIRROR_X: case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y: case BLOCK_MIRROR_Y:
case BLOCK_INVERT: /* mirror */ case BLOCK_INVERT: /* mirror */
ItemsCount = MarkItemsInBloc( Currentmodule, GetScreen()->BlockLocate ); ItemsCount = MarkItemsInBloc( Currentmodule, GetScreen()->m_BlockLocate );
if( ItemsCount ) if( ItemsCount )
SaveCopyInUndoList( Currentmodule ); SaveCopyInUndoList( Currentmodule );
MirrorMarkedItems( Currentmodule, GetScreen()->BlockLocate.Centre() ); MirrorMarkedItems( Currentmodule, GetScreen()->m_BlockLocate.Centre() );
break; break;
case BLOCK_ZOOM: /* Window Zoom */ case BLOCK_ZOOM: /* Window Zoom */
Window_Zoom( GetScreen()->BlockLocate ); Window_Zoom( GetScreen()->m_BlockLocate );
break; break;
case BLOCK_ABORT: case BLOCK_ABORT:
...@@ -189,19 +189,17 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -189,19 +189,17 @@ int WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
if( MustDoPlace <= 0 ) if( MustDoPlace <= 0 )
{ {
if( GetScreen()->BlockLocate.m_Command != BLOCK_SELECT_ITEMS_ONLY ) if( GetScreen()->m_BlockLocate.m_Command != BLOCK_SELECT_ITEMS_ONLY )
{ {
ClearMarkItems( Currentmodule ); ClearMarkItems( Currentmodule );
} }
GetScreen()->BlockLocate.m_Flags = 0; GetScreen()->m_BlockLocate.m_Flags = 0;
GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
SetCurItem( NULL ); SetCurItem( NULL );
SetToolID( m_ID_current_state, SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString );
DrawPanel->m_PanelDefaultCursor,
wxEmptyString );
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
} }
...@@ -229,9 +227,9 @@ void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC ) ...@@ -229,9 +227,9 @@ void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC )
DisplayError( this, wxT( "HandleBlockPLace : ManageCurseur = NULL" ) ); DisplayError( this, wxT( "HandleBlockPLace : ManageCurseur = NULL" ) );
} }
GetScreen()->BlockLocate.m_State = STATE_BLOCK_STOP; GetScreen()->m_BlockLocate.m_State = STATE_BLOCK_STOP;
switch( GetScreen()->BlockLocate.m_Command ) switch( GetScreen()->m_BlockLocate.m_Command )
{ {
case BLOCK_IDLE: case BLOCK_IDLE:
err = TRUE; err = TRUE;
...@@ -240,32 +238,32 @@ void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC ) ...@@ -240,32 +238,32 @@ void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC )
case BLOCK_DRAG: /* Drag */ case BLOCK_DRAG: /* Drag */
case BLOCK_MOVE: /* Move */ case BLOCK_MOVE: /* Move */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; GetScreen()->m_BlockLocate.ClearItemsList();
SaveCopyInUndoList( Currentmodule ); SaveCopyInUndoList( Currentmodule );
MoveMarkedItems( Currentmodule, GetScreen()->BlockLocate.m_MoveVector ); MoveMarkedItems( Currentmodule, GetScreen()->m_BlockLocate.m_MoveVector );
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
break; break;
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; GetScreen()->m_BlockLocate.ClearItemsList();
SaveCopyInUndoList( Currentmodule ); SaveCopyInUndoList( Currentmodule );
CopyMarkedItems( Currentmodule, GetScreen()->BlockLocate.m_MoveVector ); CopyMarkedItems( Currentmodule, GetScreen()->m_BlockLocate.m_MoveVector );
break; break;
case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */ case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */
GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; GetScreen()->m_BlockLocate.ClearItemsList();
break; break;
case BLOCK_MIRROR_X: case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y: case BLOCK_MIRROR_Y:
case BLOCK_INVERT: /* Mirror by popup menu, from block move */ case BLOCK_INVERT: /* Mirror by popup menu, from block move */
SaveCopyInUndoList( Currentmodule ); SaveCopyInUndoList( Currentmodule );
MirrorMarkedItems( Currentmodule, GetScreen()->BlockLocate.Centre() ); MirrorMarkedItems( Currentmodule, GetScreen()->m_BlockLocate.Centre() );
break; break;
case BLOCK_ROTATE: case BLOCK_ROTATE:
SaveCopyInUndoList( Currentmodule ); SaveCopyInUndoList( Currentmodule );
RotateMarkedItems( Currentmodule, GetScreen()->BlockLocate.Centre() ); RotateMarkedItems( Currentmodule, GetScreen()->m_BlockLocate.Centre() );
break; break;
case BLOCK_ZOOM: // Handled by HandleBlockEnd case BLOCK_ZOOM: // Handled by HandleBlockEnd
...@@ -280,9 +278,9 @@ void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC ) ...@@ -280,9 +278,9 @@ void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC )
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->BlockLocate.m_Flags = 0; GetScreen()->m_BlockLocate.m_Flags = 0;
GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
SetCurItem( NULL ); SetCurItem( NULL );
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
...@@ -301,22 +299,20 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -301,22 +299,20 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
* L'ensemble du block suit le curseur * L'ensemble du block suit le curseur
*/ */
{ {
DrawBlockStruct* PtBlock; BLOCK_SELECTOR* PtBlock;
BASE_SCREEN* screen = panel->GetScreen(); BASE_SCREEN* screen = panel->GetScreen();
BOARD_ITEM* item; BOARD_ITEM* item;
wxPoint move_offset; wxPoint move_offset;
MODULE* Currentmodule = MODULE* Currentmodule =
( (WinEDA_BasePcbFrame*) wxGetApp().GetTopWindow() )->m_ModuleEditFrame->GetBoard()->m_Modules; ( (WinEDA_BasePcbFrame*) wxGetApp().GetTopWindow() )->m_ModuleEditFrame->GetBoard()->m_Modules;
PtBlock = &screen->BlockLocate; PtBlock = &screen->m_BlockLocate;
GRSetDrawMode( DC, g_XorMode ); GRSetDrawMode( DC, g_XorMode );
/* Effacement ancien cadre */ /* Effacement ancien cadre */
if( erase ) if( erase )
{ {
PtBlock->Offset( PtBlock->m_MoveVector ); PtBlock->Draw( panel, DC, PtBlock->m_MoveVector, g_XorMode, PtBlock->m_Color );
PtBlock->Draw( panel, DC );
PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y );
if( Currentmodule ) if( Currentmodule )
{ {
...@@ -356,10 +352,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -356,10 +352,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
PtBlock->m_MoveVector.y = screen->m_Curseur.y - PtBlock->m_MoveVector.y = screen->m_Curseur.y -
PtBlock->m_BlockLastCursorPosition.y; PtBlock->m_BlockLastCursorPosition.y;
GRSetDrawMode( DC, g_XorMode ); PtBlock->Draw( panel, DC, PtBlock->m_MoveVector, g_XorMode, PtBlock->m_Color );
PtBlock->Offset( PtBlock->m_MoveVector );
PtBlock->Draw( panel, DC );
PtBlock->Offset( -PtBlock->m_MoveVector.x, -PtBlock->m_MoveVector.y );
if( Currentmodule ) if( Currentmodule )
......
...@@ -500,10 +500,10 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -500,10 +500,10 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
if( (CurrentTime - g_SaveTime) > g_TimeOut ) if( (CurrentTime - g_SaveTime) > g_TimeOut )
{ {
wxString tmpFileName = GetScreen()->m_FileName; wxString tmpFileName = GetScreen()->m_FileName;
wxString filename = g_SaveFileName + PcbExtBuffer; wxFileName fn = wxFileName( wxEmptyString, g_SaveFileName, PcbExtBuffer );
bool flgmodify = GetScreen()->IsModify(); bool flgmodify = GetScreen()->IsModify();
( (WinEDA_PcbFrame*) this )->SavePcbFile( filename ); SavePcbFile( fn.GetFullPath() );
if( flgmodify ) // Set the flags m_Modify cleared by SavePcbFile() if( flgmodify ) // Set the flags m_Modify cleared by SavePcbFile()
{ {
...@@ -569,7 +569,7 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -569,7 +569,7 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
keep_on_grid = FALSE; keep_on_grid = FALSE;
/* Cursor is left off grid if no block in progress and no moving object */ /* Cursor is left off grid if no block in progress and no moving object */
if( GetScreen()->BlockLocate.m_State != STATE_NO_BLOCK ) if( GetScreen()->m_BlockLocate.m_State != STATE_NO_BLOCK )
keep_on_grid = TRUE; keep_on_grid = TRUE;
EDA_BaseStruct* DrawStruct = GetScreen()->GetCurItem(); EDA_BaseStruct* DrawStruct = GetScreen()->GetCurItem();
......
...@@ -28,14 +28,14 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -28,14 +28,14 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
/* Traite les selections d'outils et les commandes appelees du menu POPUP /* Traite les selections d'outils et les commandes appelees du menu POPUP
*/ */
{ {
int id = event.GetId(); int id = event.GetId();
wxPoint pos; wxPoint pos;
int itmp; int itmp;
wxClientDC dc( DrawPanel ); wxClientDC dc( DrawPanel );
BOARD_ITEM* DrawStruct = GetCurItem(); BOARD_ITEM* DrawStruct = GetCurItem();
int toggle = 0; int toggle = 0;
DrawPanel->CursorOff( &dc ); DrawPanel->CursorOff( &dc );
DrawPanel->PrepareGraphicContext( &dc ); DrawPanel->PrepareGraphicContext( &dc );
...@@ -151,26 +151,29 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -151,26 +151,29 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
} }
/* Should not be executed, just in case */ /* Should not be executed, just in case */
if( GetScreen()->BlockLocate.m_Command != BLOCK_IDLE ) if( GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE )
{ {
GetScreen()->BlockLocate.m_Command = BLOCK_IDLE; GetScreen()->m_BlockLocate.m_Command = BLOCK_IDLE;
GetScreen()->BlockLocate.m_State = STATE_NO_BLOCK; GetScreen()->m_BlockLocate.m_State = STATE_NO_BLOCK;
GetScreen()->BlockLocate.m_BlockDrawStruct = NULL; GetScreen()->m_BlockLocate.ClearItemsList();
} }
if( m_ID_current_state == 0 ) if( m_ID_current_state == 0 )
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
else else
SetCursor( DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor ); SetCursor( DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor );
break; break;
case ID_TOGGLE_PRESENT_COMMAND: case ID_TOGGLE_PRESENT_COMMAND:
/* if( DrawPanel->ManageCurseur
&& DrawPanel->ForceCloseManageCurseur ) /* if( DrawPanel->ManageCurseur
{ * && DrawPanel->ForceCloseManageCurseur )
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); * {
} * DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
*/ * }
*/
break; break;
default: // Finish (abort ) the command default: // Finish (abort ) the command
if( DrawPanel->ManageCurseur if( DrawPanel->ManageCurseur
&& DrawPanel->ForceCloseManageCurseur ) && DrawPanel->ForceCloseManageCurseur )
...@@ -178,168 +181,103 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -178,168 +181,103 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
} }
if( m_ID_current_state != id ){ if( m_ID_current_state != id )
if (m_ID_last_state != m_ID_current_state) {
m_ID_last_state = m_ID_current_state; if( m_ID_last_state != m_ID_current_state )
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString ); m_ID_last_state = m_ID_current_state;
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
} }
break; break;
} }
switch( id ) // Execute command switch( id ) // Execute command
{ {
case 0: break; case 0:
break;
case ID_EXIT: case ID_EXIT:
Close( true ); Close( true );
break; break;
case ID_TOGGLE_PRESENT_COMMAND: case ID_TOGGLE_PRESENT_COMMAND:
switch( m_ID_current_state ) switch( m_ID_current_state )
{ {
case 0: case 0:
/* if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) toggle = 1;
{ break;
DrawStruct = PcbGeneralLocateAndDisplay();
}
if( (DrawStruct == NULL) || (DrawStruct->m_Flags != 0) )
break;
SendMessageToEESCHEMA( DrawStruct );
// An item is found
SetCurItem( DrawStruct );
switch( DrawStruct->Type() )
{
case TYPE_TRACK:
case TYPE_VIA:
if( DrawStruct->m_Flags & IS_NEW )
{
End_Route( (TRACK*) DrawStruct, DC );
DrawPanel->m_AutoPAN_Request = false;
}
else if( DrawStruct->m_Flags == 0 )
{
Edit_TrackSegm_Width( DC, (TRACK*) DrawStruct );
}
break;
case TYPE_TEXTE:
InstallTextPCBOptionsFrame( (TEXTE_PCB*) DrawStruct, DC );
DrawPanel->MouseToCursorSchema();
break;
case TYPE_PAD:
InstallPadOptionsFrame( (D_PAD*) DrawStruct, &dc, pos );
DrawPanel->MouseToCursorSchema();
break;
case TYPE_MODULE:
InstallModuleOptionsFrame( (MODULE*) DrawStruct, &dc );
DrawPanel->MouseToCursorSchema();
break;
case TYPE_MIRE:
InstallMireOptionsFrame( (MIREPCB*) DrawStruct, &dc, pos );
DrawPanel->MouseToCursorSchema();
break;
case TYPE_COTATION:
Install_Edit_Cotation( (COTATION*) DrawStruct, &dc, pos );
DrawPanel->MouseToCursorSchema();
break;
case TYPE_TEXTE_MODULE:
InstallTextModOptionsFrame( (TEXTE_MODULE*) DrawStruct, &dc, pos );
DrawPanel->MouseToCursorSchema();
break;
case TYPE_DRAWSEGMENT:
InstallGraphicItemPropertiesDialog((DRAWSEGMENT*)DrawStruct, &dc);
break;
case TYPE_ZONE_CONTAINER:
if( DrawStruct->m_Flags )
break;
Edit_Zone_Params( &dc, (ZONE_CONTAINER*) DrawStruct );
break;
default:
break;
}
break; // end case 0
*/
toggle = 1;
break;
case ID_TRACK_BUTT:
if( DrawStruct && (DrawStruct->m_Flags & IS_NEW) )
{
End_Route( (TRACK*) DrawStruct, &dc );
DrawPanel->m_AutoPAN_Request = false;
}
else
toggle = 1;
break;
case ID_PCB_ZONES_BUTT:
if ( End_Zone( &dc ) )
{
DrawPanel->m_AutoPAN_Request = false;
SetCurItem( NULL );
}
else
toggle = 1;
break;
case ID_LINE_COMMENT_BUTT:
case ID_PCB_ARC_BUTT:
case ID_PCB_CIRCLE_BUTT:
if( DrawStruct == NULL )
{}
else if( DrawStruct->Type() != TYPE_DRAWSEGMENT )
{
DisplayError( this, wxT( "DrawStruct Type error" ) );
DrawPanel->m_AutoPAN_Request = false;
}
else if( (DrawStruct->m_Flags & IS_NEW) )
{
End_Edge( (DRAWSEGMENT*) DrawStruct, &dc );
DrawPanel->m_AutoPAN_Request = false;
SetCurItem( NULL );
}
else
toggle = 1;
break;
default:
toggle = 1;
break;
}
if (toggle){
int swap = m_ID_last_state;
m_ID_last_state = m_ID_current_state;
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
m_ID_current_state = swap;
}
case ID_TRACK_BUTT:
if( DrawStruct && (DrawStruct->m_Flags & IS_NEW) )
{
End_Route( (TRACK*) DrawStruct, &dc );
DrawPanel->m_AutoPAN_Request = false;
}
else
toggle = 1;
break;
//SetCursor( DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor ); case ID_PCB_ZONES_BUTT:
if( End_Zone( &dc ) )
{
DrawPanel->m_AutoPAN_Request = false;
SetCurItem( NULL );
}
else
toggle = 1;
break;
event.SetId(m_ID_current_state); case ID_LINE_COMMENT_BUTT:
Process_Special_Functions(event); case ID_PCB_ARC_BUTT:
case ID_PCB_CIRCLE_BUTT:
if( DrawStruct == NULL )
{
}
else if( DrawStruct->Type() != TYPE_DRAWSEGMENT )
{
DisplayError( this, wxT( "DrawStruct Type error" ) );
DrawPanel->m_AutoPAN_Request = false;
}
else if( (DrawStruct->m_Flags & IS_NEW) )
{
End_Edge( (DRAWSEGMENT*) DrawStruct, &dc );
DrawPanel->m_AutoPAN_Request = false;
SetCurItem( NULL );
}
else
toggle = 1;
break;
default:
toggle = 1;
break;
}
if( toggle )
{
int swap = m_ID_last_state;
m_ID_last_state = m_ID_current_state;
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
m_ID_current_state = swap;
}
//SetCursor( DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor );
event.SetId( m_ID_current_state );
Process_Special_Functions( event );
break; break;
case ID_OPEN_MODULE_EDITOR: case ID_OPEN_MODULE_EDITOR:
if( m_ModuleEditFrame == NULL ) if( m_ModuleEditFrame == NULL )
{ {
m_ModuleEditFrame = m_ModuleEditFrame =
new WinEDA_ModuleEditFrame( this, new WinEDA_ModuleEditFrame( this,
_( "Module Editor" ), _( "Module Editor" ),
wxPoint( -1, -1 ), wxPoint( -1, -1 ),
wxSize( 600, 400 ) ); wxSize( 600, 400 ) );
m_ModuleEditFrame->Show( true ); m_ModuleEditFrame->Show( true );
m_ModuleEditFrame->Zoom_Automatique( true ); m_ModuleEditFrame->Zoom_Automatique( true );
} }
...@@ -357,40 +295,40 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -357,40 +295,40 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_PLACE_BLOCK: case ID_POPUP_PLACE_BLOCK:
GetScreen()->BlockLocate.m_Command = BLOCK_MOVE; GetScreen()->m_BlockLocate.m_Command = BLOCK_MOVE;
DrawPanel->m_AutoPAN_Request = false; DrawPanel->m_AutoPAN_Request = false;
HandleBlockPlace( &dc ); HandleBlockPlace( &dc );
break; break;
case ID_POPUP_COPY_BLOCK: case ID_POPUP_COPY_BLOCK:
GetScreen()->BlockLocate.m_Command = BLOCK_COPY; GetScreen()->m_BlockLocate.m_Command = BLOCK_COPY;
GetScreen()->BlockLocate.SetMessageBlock( this ); GetScreen()->m_BlockLocate.SetMessageBlock( this );
DrawPanel->m_AutoPAN_Request = false; DrawPanel->m_AutoPAN_Request = false;
HandleBlockPlace( &dc ); HandleBlockPlace( &dc );
break; break;
case ID_POPUP_ZOOM_BLOCK: case ID_POPUP_ZOOM_BLOCK:
GetScreen()->BlockLocate.m_Command = BLOCK_ZOOM; GetScreen()->m_BlockLocate.m_Command = BLOCK_ZOOM;
GetScreen()->BlockLocate.SetMessageBlock( this ); GetScreen()->m_BlockLocate.SetMessageBlock( this );
GetScreen()->BlockLocate.SetMessageBlock( this ); GetScreen()->m_BlockLocate.SetMessageBlock( this );
HandleBlockEnd( &dc ); HandleBlockEnd( &dc );
break; break;
case ID_POPUP_DELETE_BLOCK: case ID_POPUP_DELETE_BLOCK:
GetScreen()->BlockLocate.m_Command = BLOCK_DELETE; GetScreen()->m_BlockLocate.m_Command = BLOCK_DELETE;
GetScreen()->BlockLocate.SetMessageBlock( this ); GetScreen()->m_BlockLocate.SetMessageBlock( this );
HandleBlockEnd( &dc ); HandleBlockEnd( &dc );
break; break;
case ID_POPUP_ROTATE_BLOCK: case ID_POPUP_ROTATE_BLOCK:
GetScreen()->BlockLocate.m_Command = BLOCK_ROTATE; GetScreen()->m_BlockLocate.m_Command = BLOCK_ROTATE;
GetScreen()->BlockLocate.SetMessageBlock( this ); GetScreen()->m_BlockLocate.SetMessageBlock( this );
HandleBlockEnd( &dc ); HandleBlockEnd( &dc );
break; break;
case ID_POPUP_INVERT_BLOCK: case ID_POPUP_INVERT_BLOCK:
GetScreen()->BlockLocate.m_Command = BLOCK_INVERT; GetScreen()->m_BlockLocate.m_Command = BLOCK_INVERT;
GetScreen()->BlockLocate.SetMessageBlock( this ); GetScreen()->m_BlockLocate.SetMessageBlock( this );
HandleBlockEnd( &dc ); HandleBlockEnd( &dc );
break; break;
...@@ -617,13 +555,13 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -617,13 +555,13 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
if( GetCurItem() == NULL ) if( GetCurItem() == NULL )
break; break;
{ {
SEGZONE* zsegm = (SEGZONE*) GetCurItem(); SEGZONE* zsegm = (SEGZONE*) GetCurItem();
int netcode = zsegm->GetNet(); int netcode = zsegm->GetNet();
Delete_Zone_Fill( &dc, zsegm ); Delete_Zone_Fill( &dc, zsegm );
SetCurItem( NULL ); SetCurItem( NULL );
test_1_net_connexion( NULL, netcode ); test_1_net_connexion( NULL, netcode );
GetScreen()->SetModify(); GetScreen()->SetModify();
GetBoard()->DisplayInfo(this ); GetBoard()->DisplayInfo( this );
} }
break; break;
...@@ -648,11 +586,11 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -648,11 +586,11 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_DELETE_ZONE_CUTOUT: case ID_POPUP_PCB_DELETE_ZONE_CUTOUT:
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
{ {
int netcode = ((ZONE_CONTAINER*) GetCurItem())->GetNet(); int netcode = ( (ZONE_CONTAINER*) GetCurItem() )->GetNet();
Delete_Zone_Contour( &dc, (ZONE_CONTAINER*) GetCurItem() ); Delete_Zone_Contour( &dc, (ZONE_CONTAINER*) GetCurItem() );
SetCurItem( NULL ); SetCurItem( NULL );
test_1_net_connexion( NULL, netcode ); test_1_net_connexion( NULL, netcode );
GetBoard()->DisplayInfo(this ); GetBoard()->DisplayInfo( this );
} }
break; break;
...@@ -730,7 +668,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -730,7 +668,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_FILL_ALL_ZONES: case ID_POPUP_PCB_FILL_ALL_ZONES:
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
Fill_All_Zones(); Fill_All_Zones();
GetBoard()->DisplayInfo(this ); GetBoard()->DisplayInfo( this );
break; break;
case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_CURRENT_ZONE: case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_CURRENT_ZONE:
...@@ -740,24 +678,26 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -740,24 +678,26 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
Delete_Zone_Fill( &dc, NULL, zone_container->m_TimeStamp ); Delete_Zone_Fill( &dc, NULL, zone_container->m_TimeStamp );
test_1_net_connexion( NULL, zone_container->GetNet() ); test_1_net_connexion( NULL, zone_container->GetNet() );
GetScreen()->SetModify(); GetScreen()->SetModify();
GetBoard()->DisplayInfo(this ); GetBoard()->DisplayInfo( this );
DrawPanel->Refresh(); DrawPanel->Refresh();
} }
SetCurItem( NULL ); SetCurItem( NULL );
break; break;
case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_ALL_ZONES: // Remove all zones : case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_ALL_ZONES: // Remove all zones :
GetBoard()->m_Zone.DeleteAll(); // remove zone segments used to fill zones. GetBoard()->m_Zone.DeleteAll(); // remove zone segments used to fill zones.
for( int ii = 0; ii < GetBoard()->GetAreaCount(); ii++ ) for( int ii = 0; ii < GetBoard()->GetAreaCount(); ii++ )
{ // Remove filled aresa in zone {
// Remove filled aresa in zone
ZONE_CONTAINER* zone_container = GetBoard()->GetArea( ii ); ZONE_CONTAINER* zone_container = GetBoard()->GetArea( ii );
zone_container->m_FilledPolysList.clear();; zone_container->m_FilledPolysList.clear();;
} }
SetCurItem(NULL); // CurItem might be deleted by this command, clear the pointer
SetCurItem( NULL ); // CurItem might be deleted by this command, clear the pointer
test_connexions( NULL ); test_connexions( NULL );
Tst_Ratsnest( NULL, 0 ); // Recalculate the active ratsnest, i.e. the unconnected links */ Tst_Ratsnest( NULL, 0 ); // Recalculate the active ratsnest, i.e. the unconnected links */
GetScreen()->SetModify(); GetScreen()->SetModify();
GetBoard()->DisplayInfo(this ); GetBoard()->DisplayInfo( this );
DrawPanel->Refresh(); DrawPanel->Refresh();
break; break;
...@@ -765,7 +705,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -765,7 +705,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
Fill_Zone( NULL, (ZONE_CONTAINER*) GetCurItem() ); Fill_Zone( NULL, (ZONE_CONTAINER*) GetCurItem() );
test_1_net_connexion( NULL, ( (ZONE_CONTAINER*) GetCurItem() )->GetNet() ); test_1_net_connexion( NULL, ( (ZONE_CONTAINER*) GetCurItem() )->GetNet() );
GetBoard()->DisplayInfo(this ); GetBoard()->DisplayInfo( this );
DrawPanel->Refresh(); DrawPanel->Refresh();
break; break;
...@@ -927,19 +867,19 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -927,19 +867,19 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_SELECT_LAYER: case ID_POPUP_PCB_SELECT_LAYER:
itmp = SelectLayer( itmp = SelectLayer(
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer, -1, -1 ); ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer, -1, -1 );
if( itmp >= 0 ) if( itmp >= 0 )
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = itmp; ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = itmp;
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
break; break;
case ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR: case ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR:
SelectLayerPair(); SelectLayerPair();
break; break;
case ID_POPUP_PCB_SELECT_NO_CU_LAYER: case ID_POPUP_PCB_SELECT_NO_CU_LAYER:
itmp = SelectLayer( itmp = SelectLayer(
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer, ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer,
FIRST_NO_COPPER_LAYER, FIRST_NO_COPPER_LAYER,
-1 ); -1 );
if( itmp >= 0 ) if( itmp >= 0 )
...@@ -949,7 +889,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -949,7 +889,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_SELECT_CU_LAYER: case ID_POPUP_PCB_SELECT_CU_LAYER:
itmp = SelectLayer( itmp = SelectLayer(
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer, -1, ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer, -1,
LAST_COPPER_LAYER ); LAST_COPPER_LAYER );
if( itmp >= 0 ) if( itmp >= 0 )
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = itmp; ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = itmp;
...@@ -1022,7 +962,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -1022,7 +962,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_GETINFO_MARKER: case ID_POPUP_PCB_GETINFO_MARKER:
if( GetCurItem() && GetCurItem()->Type() == TYPE_MARKER ) if( GetCurItem() && GetCurItem()->Type() == TYPE_MARKER )
((MARKER*)GetCurItem())->DisplayMarkerInfo( this ); ( (MARKER*) GetCurItem() )->DisplayMarkerInfo( this );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
break; break;
...@@ -1033,7 +973,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -1033,7 +973,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_PCB_EDIT_DRAWING: case ID_POPUP_PCB_EDIT_DRAWING:
InstallGraphicItemPropertiesDialog( (DRAWSEGMENT*)GetCurItem(), &dc); InstallGraphicItemPropertiesDialog( (DRAWSEGMENT*) GetCurItem(), &dc );
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
break; break;
...@@ -1084,6 +1024,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -1084,6 +1024,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
g_DesignSettings.m_UseConnectedTrackWidth = false; g_DesignSettings.m_UseConnectedTrackWidth = false;
} }
break; break;
case ID_AUX_TOOLBAR_PCB_CLR_WIDTH: case ID_AUX_TOOLBAR_PCB_CLR_WIDTH:
{ {
int ii = m_SelClrWidthBox->GetChoice(); int ii = m_SelClrWidthBox->GetChoice();
...@@ -1091,7 +1032,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -1091,7 +1032,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
g_DesignSettings.m_TrackClearenceHistory[ii]; g_DesignSettings.m_TrackClearenceHistory[ii];
DisplayTrackSettings(); DisplayTrackSettings();
m_SelTrackWidthBox_Changed = false; m_SelTrackWidthBox_Changed = false;
m_SelClrWidthBox_Changed = false; m_SelClrWidthBox_Changed = false;
m_SelViaSizeBox_Changed = false; m_SelViaSizeBox_Changed = false;
g_DesignSettings.m_UseConnectedTrackWidth = false; g_DesignSettings.m_UseConnectedTrackWidth = false;
} }
...@@ -1225,7 +1166,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -1225,7 +1166,7 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
default: default:
wxString msg; wxString msg;
msg.Printf( msg.Printf(
wxT( "WinEDA_PcbFrame::Process_Special_Functions() id %d error" ), wxT( "WinEDA_PcbFrame::Process_Special_Functions() id %d error" ),
DrawStruct->Type() ); DrawStruct->Type() );
...@@ -1252,7 +1193,7 @@ static void Process_Move_Item( WinEDA_PcbFrame* frame, ...@@ -1252,7 +1193,7 @@ static void Process_Move_Item( WinEDA_PcbFrame* frame,
switch( DrawStruct->Type() ) switch( DrawStruct->Type() )
{ {
case TYPE_TEXTE: case TYPE_TEXTE:
frame->StartMoveTextePcb( (TEXTE_PCB*) DrawStruct, DC ); frame->StartMoveTextePcb( (TEXTE_PCB*) DrawStruct, DC );
break; break;
...@@ -1314,14 +1255,14 @@ void WinEDA_PcbFrame::RemoveStruct( BOARD_ITEM* Item, wxDC* DC ) ...@@ -1314,14 +1255,14 @@ void WinEDA_PcbFrame::RemoveStruct( BOARD_ITEM* Item, wxDC* DC )
break; break;
case TYPE_ZONE_CONTAINER: case TYPE_ZONE_CONTAINER:
{ {
SetCurItem( NULL ); SetCurItem( NULL );
int netcode = ((ZONE_CONTAINER*) Item)->GetNet(); int netcode = ( (ZONE_CONTAINER*) Item )->GetNet();
Delete_Zone_Contour( DC, (ZONE_CONTAINER*) Item ); Delete_Zone_Contour( DC, (ZONE_CONTAINER*) Item );
test_1_net_connexion( NULL, netcode ); test_1_net_connexion( NULL, netcode );
GetBoard()->DisplayInfo(this ); GetBoard()->DisplayInfo( this );
} }
break; break;
case TYPE_MARKER: case TYPE_MARKER:
if( Item == GetCurItem() ) if( Item == GetCurItem() )
......
...@@ -2,10 +2,6 @@ ...@@ -2,10 +2,6 @@
/* modedit.cpp */ /* modedit.cpp */
/****************/ /****************/
#ifdef __GNUG__
#pragma implementation
#endif
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "class_drawpanel.h" #include "class_drawpanel.h"
...@@ -637,7 +633,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -637,7 +633,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_PLACE_BLOCK: case ID_POPUP_PLACE_BLOCK:
GetScreen()->BlockLocate.m_Command = BLOCK_MOVE; GetScreen()->m_BlockLocate.m_Command = BLOCK_MOVE;
DrawPanel->m_AutoPAN_Request = FALSE; DrawPanel->m_AutoPAN_Request = FALSE;
{ {
SET_DC; SET_DC;
...@@ -646,8 +642,8 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -646,8 +642,8 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_COPY_BLOCK: case ID_POPUP_COPY_BLOCK:
GetScreen()->BlockLocate.m_Command = BLOCK_COPY; GetScreen()->m_BlockLocate.m_Command = BLOCK_COPY;
GetScreen()->BlockLocate.SetMessageBlock( this ); GetScreen()->m_BlockLocate.SetMessageBlock( this );
DrawPanel->m_AutoPAN_Request = FALSE; DrawPanel->m_AutoPAN_Request = FALSE;
{ {
SET_DC; SET_DC;
...@@ -656,8 +652,8 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -656,8 +652,8 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_ZOOM_BLOCK: case ID_POPUP_ZOOM_BLOCK:
GetScreen()->BlockLocate.m_Command = BLOCK_ZOOM; GetScreen()->m_BlockLocate.m_Command = BLOCK_ZOOM;
GetScreen()->BlockLocate.SetMessageBlock( this ); GetScreen()->m_BlockLocate.SetMessageBlock( this );
{ {
SET_DC; SET_DC;
HandleBlockEnd( &dc ); HandleBlockEnd( &dc );
...@@ -665,8 +661,8 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -665,8 +661,8 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_DELETE_BLOCK: case ID_POPUP_DELETE_BLOCK:
GetScreen()->BlockLocate.m_Command = BLOCK_DELETE; GetScreen()->m_BlockLocate.m_Command = BLOCK_DELETE;
GetScreen()->BlockLocate.SetMessageBlock( this ); GetScreen()->m_BlockLocate.SetMessageBlock( this );
{ {
SET_DC; SET_DC;
HandleBlockEnd( &dc ); HandleBlockEnd( &dc );
...@@ -674,8 +670,8 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -674,8 +670,8 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_ROTATE_BLOCK: case ID_POPUP_ROTATE_BLOCK:
GetScreen()->BlockLocate.m_Command = BLOCK_ROTATE; GetScreen()->m_BlockLocate.m_Command = BLOCK_ROTATE;
GetScreen()->BlockLocate.SetMessageBlock( this ); GetScreen()->m_BlockLocate.SetMessageBlock( this );
{ {
SET_DC; SET_DC;
HandleBlockEnd( &dc ); HandleBlockEnd( &dc );
...@@ -685,8 +681,8 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -685,8 +681,8 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_MIRROR_X_BLOCK: case ID_POPUP_MIRROR_X_BLOCK:
case ID_POPUP_MIRROR_Y_BLOCK: case ID_POPUP_MIRROR_Y_BLOCK:
case ID_POPUP_INVERT_BLOCK: case ID_POPUP_INVERT_BLOCK:
GetScreen()->BlockLocate.m_Command = BLOCK_INVERT; GetScreen()->m_BlockLocate.m_Command = BLOCK_INVERT;
GetScreen()->BlockLocate.SetMessageBlock( this ); GetScreen()->m_BlockLocate.SetMessageBlock( this );
{ {
SET_DC; SET_DC;
HandleBlockEnd( &dc ); HandleBlockEnd( &dc );
......
...@@ -177,7 +177,7 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos, ...@@ -177,7 +177,7 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos,
BOARD_ITEM* DrawStruct = GetCurItem(); BOARD_ITEM* DrawStruct = GetCurItem();
wxString msg; wxString msg;
bool append_set_width = FALSE; bool append_set_width = FALSE;
bool BlockActive = (GetScreen()->BlockLocate.m_Command != BLOCK_IDLE); bool BlockActive = (GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE);
// Simple localisation des elements si possible // Simple localisation des elements si possible
if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) )
......
...@@ -97,7 +97,7 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) ...@@ -97,7 +97,7 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
wxString msg; wxString msg;
int flags = 0; int flags = 0;
bool locate_track = FALSE; bool locate_track = FALSE;
bool BlockActive = (GetScreen()->BlockLocate.m_Command != BLOCK_IDLE); bool BlockActive = (GetScreen()->m_BlockLocate.m_Command != BLOCK_IDLE);
wxClientDC dc( DrawPanel ); wxClientDC dc( DrawPanel );
......
...@@ -384,7 +384,7 @@ void WinEDA_PcbFrame::SetToolbars() ...@@ -384,7 +384,7 @@ void WinEDA_PcbFrame::SetToolbars()
m_HToolBar->EnableTool( ID_SAVE_BOARD, GetScreen()->IsModify() ); m_HToolBar->EnableTool( ID_SAVE_BOARD, GetScreen()->IsModify() );
if( GetScreen()->BlockLocate.m_Command == BLOCK_MOVE ) if( GetScreen()->m_BlockLocate.m_Command == BLOCK_MOVE )
{ {
m_HToolBar->EnableTool( wxID_CUT, TRUE ); m_HToolBar->EnableTool( wxID_CUT, TRUE );
m_HToolBar->EnableTool( wxID_COPY, TRUE ); m_HToolBar->EnableTool( wxID_COPY, TRUE );
......
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