Commit 7e56bf28 authored by jean-pierre charras's avatar jean-pierre charras

fixing bug 626875. Cleaning code

Try to fix block selection issue with some windows managers.
parents fe6591b2 657f62ab
...@@ -1071,11 +1071,13 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -1071,11 +1071,13 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
#define MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND 5 #define MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND 5
/* Count the drag events. Used to filter mouse moves before starting a /* Count the drag events. Used to filter mouse moves before starting a
* block command. A block command can be started only if MinDragEventCount > * block command. A block command can be started only if
* MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND in order to avoid spurious block * MinDragEventCount > MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND
* commands. */ * and m_CanStartBlock >= 0
* in order to avoid spurious block commands.
*/
static int MinDragEventCount; static int MinDragEventCount;
if( event.Leaving() || event.Entering() ) if( event.Leaving() /*|| event.Entering()*/ )
{ {
m_CanStartBlock = -1; m_CanStartBlock = -1;
} }
...@@ -1118,11 +1120,6 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event ) ...@@ -1118,11 +1120,6 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
if( event.MiddleDown() ) if( event.MiddleDown() )
localbutt = GR_M_MIDDLE_DOWN; localbutt = GR_M_MIDDLE_DOWN;
if( event.ButtonDClick( 2 ) )
{
}
; // Unused
localrealbutt |= localbutt; /* compensation default wxGTK */ localrealbutt |= localbutt; /* compensation default wxGTK */
/* Compute the cursor position in screen (device) units. */ /* Compute the cursor position in screen (device) units. */
......
<<<<<<< TREE
update=31/08/2010 17:56:15
=======
update=22/07/2010 13:46:39 update=22/07/2010 13:46:39
>>>>>>> MERGE-SOURCE
version=1 version=1
last_client=pcbnew last_client=pcbnew
[common] [common]
......
/***************************************************************/ /**************************************************/
/* Edition des Modules: Structures et variables de gestion des */ /* Useful class and functions used to drag tracks */
/* fonctions de "DRAG" des segments de piste */ /**************************************************/
/***************************************************************/
/*** Class to handle a list of track segments to drag ***/ /** Helper class to handle a list of track segments to drag
* and has info to undo/abort the move command
* a DRAG_SEGM manage one track segment or a via
*/
class DRAG_SEGM class DRAG_SEGM
{ {
public: public:
DRAG_SEGM* Pnext; /* Pointeur de chainage */
TRACK* m_Segm; /* pointeur sur le segment a "dragger */ TRACK* m_Segm; /* pointeur sur le segment a "dragger */
D_PAD* m_Pad_Start; /* pointeur sur le Pad origine si origine segment sur pad */ D_PAD* m_Pad_Start; /* pointeur sur le Pad origine si origine segment sur pad */
D_PAD* m_Pad_End; /* pointeur sur le Pad fin si fin segment sur pad */ D_PAD* m_Pad_End; /* pointeur sur le Pad fin si fin segment sur pad */
...@@ -16,31 +16,43 @@ public: ...@@ -16,31 +16,43 @@ public:
private: private:
wxPoint m_StartInitialValue; wxPoint m_StartInitialValue;
wxPoint m_EndInitialValue; /* For abort: initial m_Start and m_End values for m_Segm */ wxPoint m_EndInitialValue; // For abort: initial m_Start and m_End values for m_Segm
public: public:
DRAG_SEGM( TRACK * segm ); DRAG_SEGM( TRACK* segm );
~DRAG_SEGM(); ~DRAG_SEGM() {};
void SetInitialValues(); void SetInitialValues()
{
m_Segm->m_Start = m_StartInitialValue;
m_Segm->m_End = m_EndInitialValue;
}
}; };
/* Variables */ /* Variables */
extern DRAG_SEGM* g_DragSegmentList; /* pointe le debut de la liste // a list of DRAG_SEGM items used to move or drag tracks.
* des structures DRAG_SEGM */ // Each DRAG_SEGM item points a segment to move.
extern std::vector<DRAG_SEGM> g_DragSegmentList;
/* routines specifiques */ /* Functions */
void Dessine_Segments_Dragges( WinEDA_DrawPanel* panel, wxDC* DC ); void Dessine_Segments_Dragges( WinEDA_DrawPanel* panel, wxDC* DC );
void Build_Drag_Liste( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* Module ); void Build_Drag_Liste( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* Module );
void Build_1_Pad_SegmentsToDrag( WinEDA_DrawPanel* panel, wxDC* DC, D_PAD* PtPad ); void Build_1_Pad_SegmentsToDrag( WinEDA_DrawPanel* panel, wxDC* DC, D_PAD* PtPad );
void Collect_TrackSegmentsToDrag( WinEDA_DrawPanel* panel, wxDC* DC, void Collect_TrackSegmentsToDrag( WinEDA_DrawPanel* panel, wxDC* DC,
wxPoint& point, int MasqueLayer, int net_code ); wxPoint& point, int MasqueLayer, int net_code );
void EraseDragListe();
/** function EraseDragList
* clear the .m_Flags of all track segments managed by in g_DragSegmentList
* and clear the list.
* In order to avoid useless memory allocation, the memory is not freed
* and will be reused when creating a new list
*/
void EraseDragList();
/* Add the segment"Track" to the drag list, and erase it from screen /* Add the segment"Track" to the drag list, and erase it from screen
* flag = STARTPOINT (if the point to drag is the start point of Track) * flag = STARTPOINT (if the point to drag is the start point of Track)
* or ENDPOINT * or ENDPOINT
......
This diff is collapsed.
...@@ -112,20 +112,15 @@ void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC ) ...@@ -112,20 +112,15 @@ void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC )
if( GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) ) if( GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
DrawGeneralRatsnest( DC ); DrawGeneralRatsnest( DC );
if( g_DragSegmentList ) /* Should not occur ! */ EraseDragList();
{
EraseDragListe();
}
if( g_Drag_Pistes_On ) if( g_Drag_Pistes_On )
{ {
Build_Drag_Liste( DrawPanel, DC, module ); Build_Drag_Liste( DrawPanel, DC, module );
ITEM_PICKER itemWrapper( NULL, UR_CHANGED ); ITEM_PICKER itemWrapper( NULL, UR_CHANGED );
for( DRAG_SEGM* pt_drag = g_DragSegmentList; for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
pt_drag != NULL;
pt_drag = pt_drag->Pnext )
{ {
TRACK* segm = pt_drag->m_Segm; TRACK* segm = g_DragSegmentList[ii].m_Segm;
itemWrapper.m_PickedItem = segm; itemWrapper.m_PickedItem = segm;
itemWrapper.m_Link = segm->Copy(); itemWrapper.m_Link = segm->Copy();
itemWrapper.m_Link->SetState( EDIT, OFF ); itemWrapper.m_Link->SetState( EDIT, OFF );
...@@ -155,7 +150,6 @@ void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC ) ...@@ -155,7 +150,6 @@ void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC )
*/ */
void Abort_MoveOrCopyModule( WinEDA_DrawPanel* Panel, wxDC* DC ) void Abort_MoveOrCopyModule( WinEDA_DrawPanel* Panel, wxDC* DC )
{ {
DRAG_SEGM* pt_drag;
TRACK* pt_segm; TRACK* pt_segm;
MODULE* module; MODULE* module;
WinEDA_PcbFrame* pcbframe = (WinEDA_PcbFrame*) Panel->GetParent(); WinEDA_PcbFrame* pcbframe = (WinEDA_PcbFrame*) Panel->GetParent();
...@@ -176,24 +170,23 @@ void Abort_MoveOrCopyModule( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -176,24 +170,23 @@ void Abort_MoveOrCopyModule( WinEDA_DrawPanel* Panel, wxDC* DC )
if( g_Drag_Pistes_On ) if( g_Drag_Pistes_On )
{ {
/* Erase on screen dragged tracks */ /* Erase on screen dragged tracks */
pt_drag = g_DragSegmentList; for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
{ {
pt_segm = pt_drag->m_Segm; pt_segm = g_DragSegmentList[ii].m_Segm;
pt_segm->Draw( Panel, DC, GR_XOR ); pt_segm->Draw( Panel, DC, GR_XOR );
} }
} }
/* Go to old position for dragged tracks */ /* Go to old position for dragged tracks */
pt_drag = g_DragSegmentList; for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
{ {
pt_segm = pt_drag->m_Segm; pt_segm->SetState( EDIT, OFF ); pt_segm = g_DragSegmentList[ii].m_Segm;
pt_drag->SetInitialValues(); pt_segm->SetState( EDIT, OFF );
g_DragSegmentList[ii].SetInitialValues();
pt_segm->Draw( Panel, DC, GR_OR ); pt_segm->Draw( Panel, DC, GR_OR );
} }
EraseDragListe(); EraseDragList();
module->m_Flags = 0; module->m_Flags = 0;
} }
...@@ -466,21 +459,19 @@ void WinEDA_BasePcbFrame::Place_Module( MODULE* module, ...@@ -466,21 +459,19 @@ void WinEDA_BasePcbFrame::Place_Module( MODULE* module,
if( DC ) if( DC )
module->Draw( DrawPanel, DC, GR_OR ); module->Draw( DrawPanel, DC, GR_OR );
if( g_DragSegmentList ) if( g_DragSegmentList.size() )
{ {
/* Redraw dragged track segments */ /* Redraw dragged track segments */
for( DRAG_SEGM* pt_drag = g_DragSegmentList; for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
pt_drag != NULL;
pt_drag = pt_drag->Pnext )
{ {
pt_segm = pt_drag->m_Segm; pt_segm = g_DragSegmentList[ii].m_Segm;
pt_segm->SetState( EDIT, OFF ); pt_segm->SetState( EDIT, OFF );
if( DC ) if( DC )
pt_segm->Draw( DrawPanel, DC, GR_OR ); pt_segm->Draw( DrawPanel, DC, GR_OR );
} }
// Delete drag list // Delete drag list
EraseDragListe(); EraseDragList();
} }
g_Drag_Pistes_On = FALSE; g_Drag_Pistes_On = FALSE;
......
...@@ -39,18 +39,17 @@ static void Exit_Move_Pad( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -39,18 +39,17 @@ static void Exit_Move_Pad( WinEDA_DrawPanel* Panel, wxDC* DC )
/* Pad move in progress: the restore origin. */ /* Pad move in progress: the restore origin. */
if( g_Drag_Pistes_On ) if( g_Drag_Pistes_On )
{ {
DRAG_SEGM* pt_drag = g_DragSegmentList; for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
{ {
TRACK* Track = pt_drag->m_Segm; TRACK* Track = g_DragSegmentList[ii].m_Segm;
Track->Draw( Panel, DC, GR_XOR ); Track->Draw( Panel, DC, GR_XOR );
Track->SetState( EDIT, OFF ); Track->SetState( EDIT, OFF );
pt_drag->SetInitialValues(); g_DragSegmentList[ii].SetInitialValues();
Track->Draw( Panel, DC, GR_OR ); Track->Draw( Panel, DC, GR_OR );
} }
} }
EraseDragListe(); EraseDragList();
s_CurrentSelectedPad = NULL; s_CurrentSelectedPad = NULL;
g_Drag_Pistes_On = FALSE; g_Drag_Pistes_On = FALSE;
} }
...@@ -61,7 +60,6 @@ static void Exit_Move_Pad( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -61,7 +60,6 @@ static void Exit_Move_Pad( WinEDA_DrawPanel* Panel, wxDC* DC )
static void Show_Pad_Move( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) static void Show_Pad_Move( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{ {
TRACK* Track; TRACK* Track;
DRAG_SEGM* pt_drag;
BASE_SCREEN* screen = panel->GetScreen(); BASE_SCREEN* screen = panel->GetScreen();
D_PAD* pad = s_CurrentSelectedPad; D_PAD* pad = s_CurrentSelectedPad;
...@@ -74,17 +72,16 @@ static void Show_Pad_Move( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -74,17 +72,16 @@ static void Show_Pad_Move( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
if( !g_Drag_Pistes_On ) if( !g_Drag_Pistes_On )
return; return;
pt_drag = g_DragSegmentList; for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
{ {
Track = pt_drag->m_Segm; Track = g_DragSegmentList[ii].m_Segm;
if( erase ) if( erase )
Track->Draw( panel, DC, GR_XOR ); Track->Draw( panel, DC, GR_XOR );
if( pt_drag->m_Pad_Start ) if( g_DragSegmentList[ii].m_Pad_Start )
{ {
Track->m_Start = pad->m_Pos; Track->m_Start = pad->m_Pos;
} }
if( pt_drag->m_Pad_End ) if( g_DragSegmentList[ii].m_Pad_End )
{ {
Track->m_End = pad->m_Pos; Track->m_End = pad->m_Pos;
} }
...@@ -288,7 +285,7 @@ void WinEDA_BasePcbFrame::StartMovePad( D_PAD* Pad, wxDC* DC ) ...@@ -288,7 +285,7 @@ void WinEDA_BasePcbFrame::StartMovePad( D_PAD* Pad, wxDC* DC )
if( g_Drag_Pistes_On ) if( g_Drag_Pistes_On )
Build_1_Pad_SegmentsToDrag( DrawPanel, DC, Pad ); Build_1_Pad_SegmentsToDrag( DrawPanel, DC, Pad );
else else
EraseDragListe(); EraseDragList();
} }
...@@ -308,18 +305,16 @@ void WinEDA_BasePcbFrame::PlacePad( D_PAD* Pad, wxDC* DC ) ...@@ -308,18 +305,16 @@ void WinEDA_BasePcbFrame::PlacePad( D_PAD* Pad, wxDC* DC )
PICKED_ITEMS_LIST pickList; PICKED_ITEMS_LIST pickList;
/* Save dragged track segments in undo list */ /* Save dragged track segments in undo list */
for( DRAG_SEGM* pt_drag = g_DragSegmentList; for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
pt_drag;
pt_drag = pt_drag->Pnext )
{ {
Track = pt_drag->m_Segm; Track = g_DragSegmentList[ii].m_Segm;
// Set the old state // Set the old state
wxPoint t_start = Track->m_Start; wxPoint t_start = Track->m_Start;
wxPoint t_end = Track->m_End; wxPoint t_end = Track->m_End;
if( pt_drag->m_Pad_Start ) if( g_DragSegmentList[ii].m_Pad_Start )
Track->m_Start = Pad_OldPos; Track->m_Start = Pad_OldPos;
if( pt_drag->m_Pad_End ) if( g_DragSegmentList[ii].m_Pad_End )
Track->m_End = Pad_OldPos; Track->m_End = Pad_OldPos;
picker.m_PickedItem = Track; picker.m_PickedItem = Track;
...@@ -330,32 +325,27 @@ void WinEDA_BasePcbFrame::PlacePad( D_PAD* Pad, wxDC* DC ) ...@@ -330,32 +325,27 @@ void WinEDA_BasePcbFrame::PlacePad( D_PAD* Pad, wxDC* DC )
wxPoint pad_curr_position = Pad->m_Pos; wxPoint pad_curr_position = Pad->m_Pos;
Pad->m_Pos = Pad_OldPos; Pad->m_Pos = Pad_OldPos;
if( g_DragSegmentList == NULL ) if( g_DragSegmentList.size() == 0 )
SaveCopyInUndoList( Module, UR_CHANGED ); SaveCopyInUndoList( Module, UR_CHANGED );
else else
{ {
picker.m_PickedItem = Module; picker.m_PickedItem = Module;
pickList.PushItem( picker ); pickList.PushItem( picker );
}
if( g_DragSegmentList )
SaveCopyInUndoList( pickList, UR_CHANGED ); SaveCopyInUndoList( pickList, UR_CHANGED );
}
Pad->m_Pos = pad_curr_position; Pad->m_Pos = pad_curr_position;
Pad->Draw( DrawPanel, DC, GR_XOR ); Pad->Draw( DrawPanel, DC, GR_XOR );
/* Redraw dragged track segments */ /* Redraw dragged track segments */
for( DRAG_SEGM* pt_drag = g_DragSegmentList; for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
pt_drag;
pt_drag = pt_drag->Pnext )
{ {
Track = pt_drag->m_Segm; Track = g_DragSegmentList[ii].m_Segm;
// Set the new state // Set the new state
if( pt_drag->m_Pad_Start ) if( g_DragSegmentList[ii].m_Pad_Start )
Track->m_Start = Pad->m_Pos; Track->m_Start = Pad->m_Pos;
if( pt_drag->m_Pad_End ) if( g_DragSegmentList[ii].m_Pad_End )
Track->m_End = Pad->m_Pos; Track->m_End = Pad->m_Pos;
Track->SetState( EDIT, OFF ); Track->SetState( EDIT, OFF );
...@@ -380,7 +370,7 @@ void WinEDA_BasePcbFrame::PlacePad( D_PAD* Pad, wxDC* DC ) ...@@ -380,7 +370,7 @@ void WinEDA_BasePcbFrame::PlacePad( D_PAD* Pad, wxDC* DC )
Module->Set_Rectangle_Encadrement(); Module->Set_Rectangle_Encadrement();
Module->m_LastEdit_Time = time( NULL ); Module->m_LastEdit_Time = time( NULL );
EraseDragListe(); EraseDragList();
OnModify(); OnModify();
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
......
This diff is collapsed.
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