Commit 657f62ab 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.
parent fe6591b2
......@@ -1071,11 +1071,13 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
#define MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND 5
/* Count the drag events. Used to filter mouse moves before starting a
* block command. A block command can be started only if MinDragEventCount >
* MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND in order to avoid spurious block
* commands. */
* block command. A block command can be started only if
* MinDragEventCount > MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND
* and m_CanStartBlock >= 0
* in order to avoid spurious block commands.
*/
static int MinDragEventCount;
if( event.Leaving() || event.Entering() )
if( event.Leaving() /*|| event.Entering()*/ )
{
m_CanStartBlock = -1;
}
......@@ -1118,11 +1120,6 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
if( event.MiddleDown() )
localbutt = GR_M_MIDDLE_DOWN;
if( event.ButtonDClick( 2 ) )
{
}
; // Unused
localrealbutt |= localbutt; /* compensation default wxGTK */
/* Compute the cursor position in screen (device) units. */
......
update=22/07/2010 13:46:39
update=31/08/2010 17:44:34
version=1
last_client=pcbnew
[common]
......
/***************************************************************/
/* Edition des Modules: Structures et variables de gestion des */
/* fonctions de "DRAG" des segments de piste */
/***************************************************************/
/**************************************************/
/* Useful class and functions used to drag tracks */
/**************************************************/
/*** 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
{
public:
DRAG_SEGM* Pnext; /* Pointeur de chainage */
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_End; /* pointeur sur le Pad fin si fin segment sur pad */
......@@ -16,31 +16,43 @@ public:
private:
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:
DRAG_SEGM( TRACK * segm );
~DRAG_SEGM();
DRAG_SEGM( TRACK* segm );
~DRAG_SEGM() {};
void SetInitialValues();
void SetInitialValues()
{
m_Segm->m_Start = m_StartInitialValue;
m_Segm->m_End = m_EndInitialValue;
}
};
/* Variables */
extern DRAG_SEGM* g_DragSegmentList; /* pointe le debut de la liste
* des structures DRAG_SEGM */
// a list of DRAG_SEGM items used to move or drag tracks.
// 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 Build_Drag_Liste( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* Module );
void Build_1_Pad_SegmentsToDrag( WinEDA_DrawPanel* panel, wxDC* DC, D_PAD* PtPad );
void Collect_TrackSegmentsToDrag( WinEDA_DrawPanel* panel, wxDC* DC,
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
* flag = STARTPOINT (if the point to drag is the start point of Track)
* or ENDPOINT
......
/*********************************************************/
/* Routines relatives a la gestions des pistes en "DRAG" */
/*********************************************************/
/*********************************/
/* functions used to drag tracks */
/*********************************/
/* Fichier dragsegm.cpp */
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
#include "class_drawpanel.h"
#include "pcbnew.h"
#include "autorout.h"
#include "protos.h"
#include "drag.h"
/* a list of DRAG_SEGM items used to move or drag tracks */
std::vector<DRAG_SEGM> g_DragSegmentList;
DRAG_SEGM* g_DragSegmentList = NULL; /* pointe le debut de la liste
* des structures DRAG_SEGM */
/* helper class to handle a list of track segments to drag or move
*/
DRAG_SEGM::DRAG_SEGM( TRACK* segm )
{
m_Segm = segm;
m_StartInitialValue = m_Segm->m_Start;
m_EndInitialValue = m_Segm->m_End;
m_Pad_Start = m_Pad_End = NULL;
m_Flag = 0;
}
DRAG_SEGM::~DRAG_SEGM()
{
}
void DRAG_SEGM::SetInitialValues()
{
m_Segm->m_Start = m_StartInitialValue;
m_Segm->m_End = m_EndInitialValue;
}
/*******************************************************************/
void Dessine_Segments_Dragges( WinEDA_DrawPanel* panel, wxDC* DC )
/*******************************************************************/
......@@ -49,38 +33,28 @@ void Dessine_Segments_Dragges( WinEDA_DrawPanel* panel, wxDC* DC )
{
D_PAD* pt_pad;
TRACK* Track;
DRAG_SEGM* pt_drag;
if( g_DragSegmentList == NULL )
if( g_DragSegmentList.size() == 0 )
return;
pt_drag = g_DragSegmentList;
for( ; pt_drag; pt_drag = pt_drag->Pnext )
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
int px, py;
Track = pt_drag->m_Segm;
wxPoint pos;
Track = g_DragSegmentList[ii].m_Segm;
Track->Draw( panel, DC, GR_XOR ); // erase from screen at old position
pt_pad = pt_drag->m_Pad_Start;
pt_pad = g_DragSegmentList[ii].m_Pad_Start;
if( pt_pad )
{
px = pt_pad->m_Pos.x - g_Offset_Module.x;
py = pt_pad->m_Pos.y - g_Offset_Module.y;
Track->m_Start.x = px;
Track->m_Start.y = py;
pos = pt_pad->m_Pos - g_Offset_Module;
Track->m_Start = pos;
}
pt_pad = pt_drag->m_Pad_End;
pt_pad = g_DragSegmentList[ii].m_Pad_End;
if( pt_pad )
{
px = pt_pad->m_Pos.x - g_Offset_Module.x;
py = pt_pad->m_Pos.y - g_Offset_Module.y;
Track->m_End.x = px;
Track->m_End.y = py;
pos = pt_pad->m_Pos - g_Offset_Module;
Track->m_End = pos;
}
Track->Draw( panel, DC, GR_XOR );
......@@ -91,13 +65,10 @@ void Dessine_Segments_Dragges( WinEDA_DrawPanel* panel, wxDC* DC )
/*************************************************************************/
void Build_Drag_Liste( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* Module )
/*************************************************************************/
/* Construit la liste des segments connectes aus pads du module Module
* pour le drag de ces segments
* la liste est mise a l'adresse pointee par pt_drag.
* la variable globale nb_drag_segment est incrementee du nombre de segments
* Met l'attribut EDIT sur les segments selectionnes
* et les affiche en mode EDIT (sketch)
/** Build the list of track segments connected to pads of a given module
* by populate the std::vector<DRAG_SEGM> g_DragSegmentList
* For each selected track segment set the EDIT flag
* and redraw them in EDIT mode (sketch mode)
*/
{
D_PAD* pt_pad;
......@@ -115,16 +86,18 @@ void Build_Drag_Liste( WinEDA_DrawPanel* panel, wxDC* DC, MODULE* Module )
/**********************************************************************************/
void Build_1_Pad_SegmentsToDrag( WinEDA_DrawPanel* panel, wxDC* DC, D_PAD* PtPad )
/**********************************************************************************/
/* Routine construisant la liste les segments de piste connectes au pad PtPad
* Les net_codes sont supposes a jour.
/** Build the list of track segments connected to a given pad
* by populate the std::vector<DRAG_SEGM> g_DragSegmentList
* For each selected track segment set the EDIT flag
* and redraw them in EDIT mode (sketch mode)
* Net codes must be OK.
*/
{
TRACK* Track;
int net_code = PtPad->GetNet();
int MasqueLayer;
wxPoint pos;
BOARD* pcb = ( (WinEDA_BasePcbFrame*) (panel->GetParent()) )->GetBoard();
BOARD* pcb = ( (WinEDA_BasePcbFrame*)( panel->GetParent() ) )->GetBoard();
Track = pcb->m_Track->GetStartNetCode( net_code );
......@@ -133,21 +106,21 @@ void Build_1_Pad_SegmentsToDrag( WinEDA_DrawPanel* panel, wxDC* DC, D_PAD* PtPad
for( ; Track; Track = Track->Next() )
{
if( Track->GetNet() != net_code )
break; /* hors zone */
break;
if( ( MasqueLayer & Track->ReturnMaskLayer() ) == 0 )
continue; /* couches differentes */
continue;
if( pos == Track->m_Start )
{
AddSegmentToDragList( panel, DC, STARTPOINT, Track );
g_DragSegmentList->m_Pad_Start = PtPad;
g_DragSegmentList.back().m_Pad_Start = PtPad;
}
if( pos == Track->m_End )
{
AddSegmentToDragList( panel, DC, ENDPOINT, Track );
g_DragSegmentList->m_Pad_End = PtPad;
g_DragSegmentList.back().m_Pad_End = PtPad;
}
}
}
......@@ -157,23 +130,17 @@ void Build_1_Pad_SegmentsToDrag( WinEDA_DrawPanel* panel, wxDC* DC, D_PAD* PtPad
void AddSegmentToDragList( WinEDA_DrawPanel* panel, wxDC* DC,
int flag, TRACK* Track )
/******************************************************************/
/* 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) or ENDPOINT
*/
{
DRAG_SEGM* pt_drag;
pt_drag = new DRAG_SEGM( Track );
pt_drag->Pnext = g_DragSegmentList;
g_DragSegmentList = pt_drag;
DRAG_SEGM wrapper( Track );
if( (flag & STARTPOINT) )
pt_drag->m_Flag |= 1;
wrapper.m_Flag |= 1;
if( (flag & ENDPOINT) )
pt_drag->m_Flag |= 2;
wrapper.m_Flag |= 2;
Track->Draw( panel, DC, GR_XOR );
Track->SetState( EDIT, ON );
......@@ -185,66 +152,68 @@ void AddSegmentToDragList( WinEDA_DrawPanel* panel, wxDC* DC,
Track->m_Flags |= ENDPOINT;
Track->Draw( panel, DC, GR_XOR );
g_DragSegmentList.push_back( wrapper );
}
/**********************************************************************************/
void Collect_TrackSegmentsToDrag( WinEDA_DrawPanel* panel, wxDC* DC,
wxPoint& point, int MasqueLayer, int net_code )
wxPoint& aRefPos, int MasqueLayer, int net_code )
/**********************************************************************************/
/* Routine construisant la liste les segments de piste connectes a la via Via
* Les net_codes sont supposes a jour.
/* Build the list of tracks connected to the ref point
* Net codes must be OK.
* @param aRefPos = reference point of connection
*/
{
BOARD* pcb = ( (WinEDA_BasePcbFrame*) (panel->GetParent()) )->GetBoard();
BOARD* pcb = ( (WinEDA_BasePcbFrame*)( panel->GetParent() ) )->GetBoard();
TRACK* track = pcb->m_Track->GetStartNetCode( net_code );
for( ; track; track = track->Next() )
{
if( track->GetNet() != net_code )
break; /* hors zone */
if( track->GetNet() != net_code ) // Bad net, not connected
break;
if( ( MasqueLayer & track->ReturnMaskLayer() ) == 0 )
continue; /* couches differentes */
continue; // Cannot be connected, not on the same layer
if( track->m_Flags & IS_DRAGGED )
continue; // already in list
continue; // already put in list
if( track->m_Start == point )
{
AddSegmentToDragList( panel, DC, STARTPOINT, track );
}
int flag = 0;
if( track->m_End == point )
if( (track->m_Start == aRefPos) && ((track->m_Flags & STARTPOINT) == 0) )
flag |= STARTPOINT;
if( track->m_End == aRefPos && ((track->m_Flags & ENDPOINT) == 0) )
flag |= ENDPOINT;
// Note: vias will be flagged with both STARTPOINT and ENDPOINT
// and must not be entered twice.
if( flag )
{
AddSegmentToDragList( panel, DC, ENDPOINT, track );
AddSegmentToDragList( panel, DC, flag, track );
// If a connected via is found at location aRefPos,
// collect also tracks connected by this via.
if( track->Type() == TYPE_VIA )
Collect_TrackSegmentsToDrag( panel, DC, aRefPos,
track->ReturnMaskLayer(),
net_code );
}
}
}
/*****************************/
void EraseDragListe()
/*****************************/
/* Routine de liberation memoire de la liste des structures DRAG_SEGM
* remet a zero le pointeur global g_DragSegmentList
/** function EraseDragList
* clear the .m_Flags of all track segments found in g_DragSegmentList
* and clear the list.
* the memory is not freed and will be reused when creating a new list
*/
void EraseDragList()
{
DRAG_SEGM* pt_drag;
DRAG_SEGM* NextStruct;
if( g_DragSegmentList == NULL )
return;
pt_drag = g_DragSegmentList;
for( ; pt_drag != NULL; pt_drag = NextStruct )
{
NextStruct = pt_drag->Pnext;
pt_drag->m_Segm->m_Flags = 0;
delete pt_drag;
}
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
g_DragSegmentList[ii].m_Segm->m_Flags = 0;
g_DragSegmentList = NULL;
g_DragSegmentList.clear();
}
......@@ -112,20 +112,15 @@ void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC )
if( GetBoard()->IsElementVisible( RATSNEST_VISIBLE ) )
DrawGeneralRatsnest( DC );
if( g_DragSegmentList ) /* Should not occur ! */
{
EraseDragListe();
}
EraseDragList();
if( g_Drag_Pistes_On )
{
Build_Drag_Liste( DrawPanel, DC, module );
ITEM_PICKER itemWrapper( NULL, UR_CHANGED );
for( DRAG_SEGM* pt_drag = g_DragSegmentList;
pt_drag != NULL;
pt_drag = pt_drag->Pnext )
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
TRACK* segm = pt_drag->m_Segm;
TRACK* segm = g_DragSegmentList[ii].m_Segm;
itemWrapper.m_PickedItem = segm;
itemWrapper.m_Link = segm->Copy();
itemWrapper.m_Link->SetState( EDIT, OFF );
......@@ -155,7 +150,6 @@ void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC )
*/
void Abort_MoveOrCopyModule( WinEDA_DrawPanel* Panel, wxDC* DC )
{
DRAG_SEGM* pt_drag;
TRACK* pt_segm;
MODULE* module;
WinEDA_PcbFrame* pcbframe = (WinEDA_PcbFrame*) Panel->GetParent();
......@@ -176,24 +170,23 @@ void Abort_MoveOrCopyModule( WinEDA_DrawPanel* Panel, wxDC* DC )
if( g_Drag_Pistes_On )
{
/* Erase on screen dragged tracks */
pt_drag = g_DragSegmentList;
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
pt_segm = pt_drag->m_Segm;
pt_segm = g_DragSegmentList[ii].m_Segm;
pt_segm->Draw( Panel, DC, GR_XOR );
}
}
/* Go to old position for dragged tracks */
pt_drag = g_DragSegmentList;
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
pt_segm = pt_drag->m_Segm; pt_segm->SetState( EDIT, OFF );
pt_drag->SetInitialValues();
pt_segm = g_DragSegmentList[ii].m_Segm;
pt_segm->SetState( EDIT, OFF );
g_DragSegmentList[ii].SetInitialValues();
pt_segm->Draw( Panel, DC, GR_OR );
}
EraseDragListe();
EraseDragList();
module->m_Flags = 0;
}
......@@ -466,21 +459,19 @@ void WinEDA_BasePcbFrame::Place_Module( MODULE* module,
if( DC )
module->Draw( DrawPanel, DC, GR_OR );
if( g_DragSegmentList )
if( g_DragSegmentList.size() )
{
/* Redraw dragged track segments */
for( DRAG_SEGM* pt_drag = g_DragSegmentList;
pt_drag != NULL;
pt_drag = pt_drag->Pnext )
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
pt_segm = pt_drag->m_Segm;
pt_segm = g_DragSegmentList[ii].m_Segm;
pt_segm->SetState( EDIT, OFF );
if( DC )
pt_segm->Draw( DrawPanel, DC, GR_OR );
}
// Delete drag list
EraseDragListe();
EraseDragList();
}
g_Drag_Pistes_On = FALSE;
......
......@@ -39,18 +39,17 @@ static void Exit_Move_Pad( WinEDA_DrawPanel* Panel, wxDC* DC )
/* Pad move in progress: the restore origin. */
if( g_Drag_Pistes_On )
{
DRAG_SEGM* pt_drag = g_DragSegmentList;
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
TRACK* Track = pt_drag->m_Segm;
TRACK* Track = g_DragSegmentList[ii].m_Segm;
Track->Draw( Panel, DC, GR_XOR );
Track->SetState( EDIT, OFF );
pt_drag->SetInitialValues();
g_DragSegmentList[ii].SetInitialValues();
Track->Draw( Panel, DC, GR_OR );
}
}
EraseDragListe();
EraseDragList();
s_CurrentSelectedPad = NULL;
g_Drag_Pistes_On = FALSE;
}
......@@ -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 )
{
TRACK* Track;
DRAG_SEGM* pt_drag;
BASE_SCREEN* screen = panel->GetScreen();
D_PAD* pad = s_CurrentSelectedPad;
......@@ -74,17 +72,16 @@ static void Show_Pad_Move( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
if( !g_Drag_Pistes_On )
return;
pt_drag = g_DragSegmentList;
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
Track = pt_drag->m_Segm;
Track = g_DragSegmentList[ii].m_Segm;
if( erase )
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;
}
if( pt_drag->m_Pad_End )
if( g_DragSegmentList[ii].m_Pad_End )
{
Track->m_End = pad->m_Pos;
}
......@@ -288,7 +285,7 @@ void WinEDA_BasePcbFrame::StartMovePad( D_PAD* Pad, wxDC* DC )
if( g_Drag_Pistes_On )
Build_1_Pad_SegmentsToDrag( DrawPanel, DC, Pad );
else
EraseDragListe();
EraseDragList();
}
......@@ -308,18 +305,16 @@ void WinEDA_BasePcbFrame::PlacePad( D_PAD* Pad, wxDC* DC )
PICKED_ITEMS_LIST pickList;
/* Save dragged track segments in undo list */
for( DRAG_SEGM* pt_drag = g_DragSegmentList;
pt_drag;
pt_drag = pt_drag->Pnext )
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
Track = pt_drag->m_Segm;
Track = g_DragSegmentList[ii].m_Segm;
// Set the old state
wxPoint t_start = Track->m_Start;
wxPoint t_end = Track->m_End;
if( pt_drag->m_Pad_Start )
if( g_DragSegmentList[ii].m_Pad_Start )
Track->m_Start = Pad_OldPos;
if( pt_drag->m_Pad_End )
if( g_DragSegmentList[ii].m_Pad_End )
Track->m_End = Pad_OldPos;
picker.m_PickedItem = Track;
......@@ -330,32 +325,27 @@ void WinEDA_BasePcbFrame::PlacePad( D_PAD* Pad, wxDC* DC )
wxPoint pad_curr_position = Pad->m_Pos;
Pad->m_Pos = Pad_OldPos;
if( g_DragSegmentList == NULL )
if( g_DragSegmentList.size() == 0 )
SaveCopyInUndoList( Module, UR_CHANGED );
else
{
picker.m_PickedItem = Module;
pickList.PushItem( picker );
}
if( g_DragSegmentList )
SaveCopyInUndoList( pickList, UR_CHANGED );
}
Pad->m_Pos = pad_curr_position;
Pad->Draw( DrawPanel, DC, GR_XOR );
/* Redraw dragged track segments */
for( DRAG_SEGM* pt_drag = g_DragSegmentList;
pt_drag;
pt_drag = pt_drag->Pnext )
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
Track = pt_drag->m_Segm;
Track = g_DragSegmentList[ii].m_Segm;
// Set the new state
if( pt_drag->m_Pad_Start )
if( g_DragSegmentList[ii].m_Pad_Start )
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->SetState( EDIT, OFF );
......@@ -380,7 +370,7 @@ void WinEDA_BasePcbFrame::PlacePad( D_PAD* Pad, wxDC* DC )
Module->Set_Rectangle_Encadrement();
Module->m_LastEdit_Time = time( NULL );
EraseDragListe();
EraseDragList();
OnModify();
DrawPanel->ManageCurseur = NULL;
......
......@@ -61,7 +61,7 @@ static void Abort_MoveTrack( WinEDA_DrawPanel* Panel, wxDC* DC )
Panel->ManageCurseur( Panel, DC, true );
Panel->GetScreen()->m_Curseur = oldpos;
g_HighLight_Status = FALSE;
g_HighLight_Status = false;
( (WinEDA_PcbFrame*) Panel->GetParent() )->GetBoard()->DrawHighLight(
Panel,
DC,
......@@ -110,11 +110,10 @@ static void Abort_MoveTrack( WinEDA_DrawPanel* Panel, wxDC* DC )
( (WinEDA_PcbFrame*) Panel->GetParent() )->SetCurItem( NULL );
/* Undo move and redraw trace segments. */
DRAG_SEGM* pt_drag = g_DragSegmentList;
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
for( unsigned jj=0 ; jj < g_DragSegmentList.size(); jj++ )
{
TRACK* Track = pt_drag->m_Segm;
pt_drag->SetInitialValues();
TRACK* Track = g_DragSegmentList[jj].m_Segm;
g_DragSegmentList[jj].SetInitialValues();
Track->SetState( EDIT, OFF );
Track->m_Flags = 0;
Track->Draw( Panel, DC, GR_OR );
......@@ -127,11 +126,9 @@ static void Abort_MoveTrack( WinEDA_DrawPanel* Panel, wxDC* DC )
g_HighLight_Status = Old_HighLigt_Status;
if( g_HighLight_Status )
( (WinEDA_PcbFrame*) Panel->GetParent() )->GetBoard()->DrawHighLight(
Panel,
DC,
g_HighLight_NetCode );
Panel, DC, g_HighLight_NetCode );
EraseDragListe();
EraseDragList();
}
......@@ -145,7 +142,7 @@ static void Show_MoveNode( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
int track_fill_copy = DisplayOpt.DisplayPcbTrackFill;
int draw_mode = GR_XOR | GR_SURBRILL;
DisplayOpt.DisplayPcbTrackFill = FALSE;
DisplayOpt.DisplayPcbTrackFill = false;
erase = true;
......@@ -175,10 +172,9 @@ static void Show_MoveNode( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/* Redraw the current moved track segments */
Trace_Une_Piste( panel, DC, NewTrack, NbPtNewTrack, draw_mode );
DRAG_SEGM* pt_drag = g_DragSegmentList;
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
Track = pt_drag->m_Segm;
Track = g_DragSegmentList[ii].m_Segm;
if( erase )
Track->Draw( panel, DC, draw_mode );
......@@ -250,32 +246,35 @@ static void Show_Drag_Track_Segment_With_Cte_Slope( WinEDA_DrawPanel* panel,
BASE_SCREEN* screen = panel->GetScreen();
bool update = true;
TRACK* Track;
DRAG_SEGM* TrackSegWrapper = g_DragSegmentList;
TRACK* tSegmentToStart = NULL, * tSegmentToEnd = NULL;
if( TrackSegWrapper == NULL )
if( g_DragSegmentList.size() == 0 )
return;
Track = TrackSegWrapper->m_Segm;
/* get the segments :
* from last to first in list are:
* the segment to move
* the segment connected to its end point (if exists)
* the segment connected to its start point (if exists)
*/
int ii = g_DragSegmentList.size() - 1;
Track = g_DragSegmentList[ii].m_Segm;
if( Track == NULL )
return;
TrackSegWrapper = TrackSegWrapper->Pnext;
if( TrackSegWrapper )
ii--;
if( ii >= 0)
{
if( s_EndSegmentPresent )
{
tSegmentToEnd = TrackSegWrapper->m_Segm; // Get the segment
// connected to the end
// point
TrackSegWrapper = TrackSegWrapper->Pnext;
// Get the segment connected to the end point
tSegmentToEnd = g_DragSegmentList[ii].m_Segm;
ii--;
}
if( s_StartSegmentPresent )
{
if( TrackSegWrapper )
tSegmentToStart = TrackSegWrapper->m_Segm; // Get the segment
// connected to the
// start point
// Get the segment connected to the start point
if( ii >= 0 )
tSegmentToStart = g_DragSegmentList[ii].m_Segm;
}
}
......@@ -461,36 +460,42 @@ static void Show_Drag_Track_Segment_With_Cte_Slope( WinEDA_DrawPanel* panel,
/* Init variables (slope, Y intersect point, flags) for
* Show_Drag_Track_Segment_With_Cte_Slope()
* return true if Ok, FALSE if dragging is not possible
* return true if Ok, false if dragging is not possible
* (2 colinear segments)
*/
bool InitialiseDragParameters()
{
double tx1, tx2, ty1, ty2; // temporary storage of points
TRACK* Track;
DRAG_SEGM* TrackSegWrapper = g_DragSegmentList;
TRACK* tSegmentToStart = NULL, * tSegmentToEnd = NULL;
if( TrackSegWrapper == NULL )
return FALSE;
Track = TrackSegWrapper->m_Segm;
if( Track == NULL )
return FALSE;
if( g_DragSegmentList.size() == 0 )
return false;
TrackSegWrapper = TrackSegWrapper->Pnext;
if( TrackSegWrapper )
/* get the segments :
* from last to first in list are:
* the segment to move
* the segment connected to its end point (if exists)
* the segment connected to its start point (if exists)
*/
int ii = g_DragSegmentList.size() - 1;
Track = g_DragSegmentList[ii].m_Segm;
if( Track == NULL )
return false;
ii--;
if( ii >= 0)
{
if( s_EndSegmentPresent )
{
tSegmentToEnd = TrackSegWrapper->m_Segm; // Get the segment
tSegmentToEnd = g_DragSegmentList[ii].m_Segm; // Get the segment
// connected to the end
// point
TrackSegWrapper = TrackSegWrapper->Pnext;
ii--;
}
if( s_StartSegmentPresent )
{
if( TrackSegWrapper )
tSegmentToStart = TrackSegWrapper->m_Segm; // Get the segment
if( ii >= 0 )
tSegmentToStart = g_DragSegmentList[ii].m_Segm; // Get the segment
// connected to the
// start point
}
......@@ -644,7 +649,7 @@ void WinEDA_PcbFrame::Start_MoveOneNodeOrSegment( TRACK* track,
NewTrack = NULL;
NbPtNewTrack = 0;
EraseDragListe();
EraseDragList();
/* Change highlighted net: the new one will be highlighted */
Old_HighLigt_Status = g_HighLight_Status;
......@@ -653,7 +658,7 @@ void WinEDA_PcbFrame::Start_MoveOneNodeOrSegment( TRACK* track,
High_Light( DC );
PosInit = GetScreen()->m_Curseur;
if( track->Type() == TYPE_VIA )
if( track->Type() == TYPE_VIA ) // For a via: always drag it
{
track->m_Flags = IS_DRAGGED | STARTPOINT | ENDPOINT;
if( command != ID_POPUP_PCB_MOVE_TRACK_SEGMENT )
......@@ -673,12 +678,12 @@ void WinEDA_PcbFrame::Start_MoveOneNodeOrSegment( TRACK* track,
switch( command )
{
case ID_POPUP_PCB_MOVE_TRACK_SEGMENT:
case ID_POPUP_PCB_MOVE_TRACK_SEGMENT: // Move segment
track->m_Flags |= IS_DRAGGED | ENDPOINT | STARTPOINT;
AddSegmentToDragList( DrawPanel, DC, track->m_Flags, track );
break;
case ID_POPUP_PCB_DRAG_TRACK_SEGMENT:
case ID_POPUP_PCB_DRAG_TRACK_SEGMENT: // drag a segment
pos = track->m_Start;
Collect_TrackSegmentsToDrag( DrawPanel, DC, pos,
track->ReturnMaskLayer(),
......@@ -690,7 +695,7 @@ void WinEDA_PcbFrame::Start_MoveOneNodeOrSegment( TRACK* track,
track->GetNet() );
break;
case ID_POPUP_PCB_MOVE_TRACK_NODE:
case ID_POPUP_PCB_MOVE_TRACK_NODE: // Drag via or move node
pos = (diag & STARTPOINT) ? track->m_Start : track->m_End;
Collect_TrackSegmentsToDrag( DrawPanel, DC, pos,
track->ReturnMaskLayer(),
......@@ -706,10 +711,9 @@ void WinEDA_PcbFrame::Start_MoveOneNodeOrSegment( TRACK* track,
ITEM_PICKER picker( track, UR_CHANGED );
picker.m_Link = track->Copy();
s_ItemsListPicker.PushItem( picker );
DRAG_SEGM* pt_drag = g_DragSegmentList;
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
TRACK* draggedtrack = pt_drag->m_Segm;
TRACK* draggedtrack = g_DragSegmentList[ii].m_Segm;
picker.m_PickedItem = draggedtrack;
picker.m_Link = draggedtrack->Copy();
s_ItemsListPicker.PushItem( picker );
......@@ -824,7 +828,7 @@ void WinEDA_PcbFrame::Start_DragTrackSegmentAndKeepSlope( TRACK* track,
{
TRACK* TrackToStartPoint = NULL;
TRACK* TrackToEndPoint = NULL;
bool error = FALSE;
bool error = false;
if( !track )
return;
......@@ -835,14 +839,10 @@ void WinEDA_PcbFrame::Start_DragTrackSegmentAndKeepSlope( TRACK* track,
// Broken functions: see comments
while( MergeCollinearTracks( track, DC, START ) )
{
}
;
};
while( MergeCollinearTracks( track, DC, END ) )
{
}
;
};
#endif
s_StartSegmentPresent = s_EndSegmentPresent = true;
......@@ -885,10 +885,10 @@ void WinEDA_PcbFrame::Start_DragTrackSegmentAndKeepSlope( TRACK* track,
}
if( !TrackToStartPoint || ( TrackToStartPoint->Type() != TYPE_TRACK ) )
s_StartSegmentPresent = FALSE;
s_StartSegmentPresent = false;
if( !TrackToEndPoint || ( TrackToEndPoint->Type() != TYPE_TRACK ) )
s_EndSegmentPresent = FALSE;
s_EndSegmentPresent = false;
/* Change high light net: the new one will be highlighted */
Old_HighLigt_Status = g_HighLight_Status;
......@@ -896,7 +896,7 @@ void WinEDA_PcbFrame::Start_DragTrackSegmentAndKeepSlope( TRACK* track,
if( g_HighLight_Status )
High_Light( DC );
EraseDragListe();
EraseDragList();
NewTrack = NULL;
NbPtNewTrack = 0;
......@@ -933,11 +933,10 @@ void WinEDA_PcbFrame::Start_DragTrackSegmentAndKeepSlope( TRACK* track,
GetBoard()->DrawHighLight( DrawPanel, DC, g_HighLight_NetCode );
// Prepare the Undo command
DRAG_SEGM* pt_drag = g_DragSegmentList;
ITEM_PICKER picker( NULL, UR_CHANGED );
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
TRACK* draggedtrack = pt_drag->m_Segm;
TRACK* draggedtrack = g_DragSegmentList[ii].m_Segm;
picker.m_PickedItem = draggedtrack;
picker.m_Link = draggedtrack->Copy();
s_ItemsListPicker.PushItem( picker );
......@@ -961,10 +960,9 @@ void WinEDA_PcbFrame::Start_DragTrackSegmentAndKeepSlope( TRACK* track,
bool WinEDA_PcbFrame::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC )
{
int errdrc;
DRAG_SEGM* pt_drag;
if( Track == NULL )
return FALSE;
return false;
int current_net_code = Track->GetNet();
......@@ -973,14 +971,13 @@ bool WinEDA_PcbFrame::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC )
{
errdrc = m_drc->Drc( Track, GetBoard()->m_Track );
if( errdrc == BAD_DRC )
return FALSE;
return false;
/* Redraw the dragged segments */
pt_drag = g_DragSegmentList;
for( ; pt_drag != NULL; pt_drag = pt_drag->Pnext )
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
errdrc = m_drc->Drc( pt_drag->m_Segm, GetBoard()->m_Track );
errdrc = m_drc->Drc( g_DragSegmentList[ii].m_Segm, GetBoard()->m_Track );
if( errdrc == BAD_DRC )
return FALSE;
return false;
}
}
......@@ -992,10 +989,9 @@ bool WinEDA_PcbFrame::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC )
Track->Draw( DrawPanel, DC, draw_mode );
/* Draw dragged tracks */
pt_drag = g_DragSegmentList;
for( ; pt_drag; pt_drag = pt_drag->Pnext )
for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ )
{
Track = pt_drag->m_Segm;
Track = g_DragSegmentList[ii].m_Segm;
Track->SetState( EDIT, OFF );
Track->m_Flags = 0;
Track->Draw( DrawPanel, DC, draw_mode );
......@@ -1010,7 +1006,7 @@ bool WinEDA_PcbFrame::PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC )
GetBoard(), Track->m_End, masque_layer );
}
EraseDragListe();
EraseDragList();
SaveCopyInUndoList( s_ItemsListPicker, UR_UNSPECIFIED );
s_ItemsListPicker.ClearItemsList(); // s_ItemsListPicker is no more owner
......
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