Loading common/drawpanel.cpp +6 −9 Original line number Original line Diff line number Diff line Loading @@ -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; } } Loading Loading @@ -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. */ Loading demos/interf_u/interf_u.pro +1 −1 Original line number Original line Diff line number Diff line update=22/07/2010 13:46:39 update=31/08/2010 17:44:34 version=1 version=1 last_client=pcbnew last_client=pcbnew [common] [common] Loading pcbnew/drag.h +41 −29 Original line number Original line Diff line number Diff line /***************************************************************/ /**************************************************/ /* 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 */ Loading @@ -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 Loading pcbnew/dragsegm.cpp +72 −103 Original line number Original line Diff line number Diff line /*********************************************************/ /*********************************/ /* Routines relatives a la gestions des pistes en "DRAG" */ /* functions used to drag tracks */ /*********************************************************/ /*********************************/ /* Fichier dragsegm.cpp */ /* Fichier dragsegm.cpp */ #include "fctsys.h" #include "fctsys.h" #include "gr_basic.h" #include "common.h" #include "common.h" #include "class_drawpanel.h" #include "class_drawpanel.h" #include "pcbnew.h" #include "pcbnew.h" #include "autorout.h" #include "protos.h" #include "drag.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 /* helper class to handle a list of track segments to drag or move * des structures DRAG_SEGM */ */ DRAG_SEGM::DRAG_SEGM( TRACK* segm ) DRAG_SEGM::DRAG_SEGM( TRACK* segm ) { { m_Segm = segm; m_Segm = segm; m_StartInitialValue = m_Segm->m_Start; m_StartInitialValue = m_Segm->m_Start; m_EndInitialValue = m_Segm->m_End; m_EndInitialValue = m_Segm->m_End; m_Pad_Start = m_Pad_End = NULL; m_Pad_Start = m_Pad_End = NULL; m_Flag = 0; 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 ) void Dessine_Segments_Dragges( WinEDA_DrawPanel* panel, wxDC* DC ) /*******************************************************************/ /*******************************************************************/ Loading @@ -49,38 +33,28 @@ void Dessine_Segments_Dragges( WinEDA_DrawPanel* panel, wxDC* DC ) { { D_PAD* pt_pad; D_PAD* pt_pad; TRACK* Track; TRACK* Track; DRAG_SEGM* pt_drag; if( g_DragSegmentList == NULL ) if( g_DragSegmentList.size() == 0 ) return; return; pt_drag = g_DragSegmentList; for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) for( ; pt_drag; pt_drag = pt_drag->Pnext ) { { int px, py; wxPoint pos; Track = g_DragSegmentList[ii].m_Segm; Track = pt_drag->m_Segm; Track->Draw( panel, DC, GR_XOR ); // erase from screen at old position 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 ) if( pt_pad ) { { px = pt_pad->m_Pos.x - g_Offset_Module.x; pos = pt_pad->m_Pos - g_Offset_Module; py = pt_pad->m_Pos.y - g_Offset_Module.y; Track->m_Start = pos; Track->m_Start.x = px; Track->m_Start.y = py; } } pt_pad = pt_drag->m_Pad_End; pt_pad = g_DragSegmentList[ii].m_Pad_End; if( pt_pad ) if( pt_pad ) { { px = pt_pad->m_Pos.x - g_Offset_Module.x; pos = pt_pad->m_Pos - g_Offset_Module; py = pt_pad->m_Pos.y - g_Offset_Module.y; Track->m_End = pos; Track->m_End.x = px; Track->m_End.y = py; } } Track->Draw( panel, DC, GR_XOR ); Track->Draw( panel, DC, GR_XOR ); Loading @@ -91,13 +65,10 @@ 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 ) /*************************************************************************/ /*************************************************************************/ /** Build the list of track segments connected to pads of a given module /* Construit la liste des segments connectes aus pads du module Module * by populate the std::vector<DRAG_SEGM> g_DragSegmentList * pour le drag de ces segments * For each selected track segment set the EDIT flag * la liste est mise a l'adresse pointee par pt_drag. * and redraw them in EDIT mode (sketch mode) * 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) */ */ { { D_PAD* pt_pad; D_PAD* pt_pad; Loading @@ -115,9 +86,11 @@ 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 ) /**********************************************************************************/ /**********************************************************************************/ /** Build the list of track segments connected to a given pad /* Routine construisant la liste les segments de piste connectes au pad PtPad * by populate the std::vector<DRAG_SEGM> g_DragSegmentList * Les net_codes sont supposes a jour. * For each selected track segment set the EDIT flag * and redraw them in EDIT mode (sketch mode) * Net codes must be OK. */ */ { { TRACK* Track; TRACK* Track; Loading @@ -133,21 +106,21 @@ void Build_1_Pad_SegmentsToDrag( WinEDA_DrawPanel* panel, wxDC* DC, D_PAD* PtPad for( ; Track; Track = Track->Next() ) for( ; Track; Track = Track->Next() ) { { if( Track->GetNet() != net_code ) if( Track->GetNet() != net_code ) break; /* hors zone */ break; if( ( MasqueLayer & Track->ReturnMaskLayer() ) == 0 ) if( ( MasqueLayer & Track->ReturnMaskLayer() ) == 0 ) continue; /* couches differentes */ continue; if( pos == Track->m_Start ) if( pos == Track->m_Start ) { { AddSegmentToDragList( panel, DC, STARTPOINT, Track ); AddSegmentToDragList( panel, DC, STARTPOINT, Track ); g_DragSegmentList->m_Pad_Start = PtPad; g_DragSegmentList.back().m_Pad_Start = PtPad; } } if( pos == Track->m_End ) if( pos == Track->m_End ) { { AddSegmentToDragList( panel, DC, ENDPOINT, Track ); AddSegmentToDragList( panel, DC, ENDPOINT, Track ); g_DragSegmentList->m_Pad_End = PtPad; g_DragSegmentList.back().m_Pad_End = PtPad; } } } } } } Loading @@ -157,23 +130,17 @@ void Build_1_Pad_SegmentsToDrag( WinEDA_DrawPanel* panel, wxDC* DC, D_PAD* PtPad void AddSegmentToDragList( WinEDA_DrawPanel* panel, wxDC* DC, void AddSegmentToDragList( WinEDA_DrawPanel* panel, wxDC* DC, int flag, TRACK* Track ) int flag, TRACK* Track ) /******************************************************************/ /******************************************************************/ /* 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) or ENDPOINT * flag = STARTPOINT (if the point to drag is the start point of Track) or ENDPOINT */ */ { { DRAG_SEGM* pt_drag; DRAG_SEGM wrapper( Track ); pt_drag = new DRAG_SEGM( Track ); pt_drag->Pnext = g_DragSegmentList; g_DragSegmentList = pt_drag; if( (flag & STARTPOINT) ) if( (flag & STARTPOINT) ) pt_drag->m_Flag |= 1; wrapper.m_Flag |= 1; if( (flag & ENDPOINT) ) if( (flag & ENDPOINT) ) pt_drag->m_Flag |= 2; wrapper.m_Flag |= 2; Track->Draw( panel, DC, GR_XOR ); Track->Draw( panel, DC, GR_XOR ); Track->SetState( EDIT, ON ); Track->SetState( EDIT, ON ); Loading @@ -185,66 +152,68 @@ void AddSegmentToDragList( WinEDA_DrawPanel* panel, wxDC* DC, Track->m_Flags |= ENDPOINT; Track->m_Flags |= ENDPOINT; Track->Draw( panel, DC, GR_XOR ); Track->Draw( panel, DC, GR_XOR ); g_DragSegmentList.push_back( wrapper ); } } /**********************************************************************************/ /**********************************************************************************/ void Collect_TrackSegmentsToDrag( WinEDA_DrawPanel* panel, wxDC* DC, 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 /* Build the list of tracks connected to the ref point * Les net_codes sont supposes a jour. * 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 ); TRACK* track = pcb->m_Track->GetStartNetCode( net_code ); for( ; track; track = track->Next() ) for( ; track; track = track->Next() ) { { if( track->GetNet() != net_code ) if( track->GetNet() != net_code ) // Bad net, not connected break; /* hors zone */ break; if( ( MasqueLayer & track->ReturnMaskLayer() ) == 0 ) if( ( MasqueLayer & track->ReturnMaskLayer() ) == 0 ) continue; /* couches differentes */ continue; // Cannot be connected, not on the same layer if( track->m_Flags & IS_DRAGGED ) if( track->m_Flags & IS_DRAGGED ) continue; // already in list continue; // already put in list if( track->m_Start == point ) int flag = 0; { AddSegmentToDragList( panel, DC, STARTPOINT, track ); } 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 ); } } } } } } /*****************************/ /** function EraseDragList void EraseDragListe() * 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 /* Routine de liberation memoire de la liste des structures DRAG_SEGM * remet a zero le pointeur global g_DragSegmentList */ */ void EraseDragList() { { DRAG_SEGM* pt_drag; for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) DRAG_SEGM* NextStruct; g_DragSegmentList[ii].m_Segm->m_Flags = 0; 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; } g_DragSegmentList = NULL; g_DragSegmentList.clear(); } } pcbnew/modules.cpp +15 −24 Original line number Original line Diff line number Diff line Loading @@ -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 ); Loading Loading @@ -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(); Loading @@ -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; } } Loading Loading @@ -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; Loading Loading
common/drawpanel.cpp +6 −9 Original line number Original line Diff line number Diff line Loading @@ -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; } } Loading Loading @@ -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. */ Loading
demos/interf_u/interf_u.pro +1 −1 Original line number Original line Diff line number Diff line update=22/07/2010 13:46:39 update=31/08/2010 17:44:34 version=1 version=1 last_client=pcbnew last_client=pcbnew [common] [common] Loading
pcbnew/drag.h +41 −29 Original line number Original line Diff line number Diff line /***************************************************************/ /**************************************************/ /* 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 */ Loading @@ -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 Loading
pcbnew/dragsegm.cpp +72 −103 Original line number Original line Diff line number Diff line /*********************************************************/ /*********************************/ /* Routines relatives a la gestions des pistes en "DRAG" */ /* functions used to drag tracks */ /*********************************************************/ /*********************************/ /* Fichier dragsegm.cpp */ /* Fichier dragsegm.cpp */ #include "fctsys.h" #include "fctsys.h" #include "gr_basic.h" #include "common.h" #include "common.h" #include "class_drawpanel.h" #include "class_drawpanel.h" #include "pcbnew.h" #include "pcbnew.h" #include "autorout.h" #include "protos.h" #include "drag.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 /* helper class to handle a list of track segments to drag or move * des structures DRAG_SEGM */ */ DRAG_SEGM::DRAG_SEGM( TRACK* segm ) DRAG_SEGM::DRAG_SEGM( TRACK* segm ) { { m_Segm = segm; m_Segm = segm; m_StartInitialValue = m_Segm->m_Start; m_StartInitialValue = m_Segm->m_Start; m_EndInitialValue = m_Segm->m_End; m_EndInitialValue = m_Segm->m_End; m_Pad_Start = m_Pad_End = NULL; m_Pad_Start = m_Pad_End = NULL; m_Flag = 0; 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 ) void Dessine_Segments_Dragges( WinEDA_DrawPanel* panel, wxDC* DC ) /*******************************************************************/ /*******************************************************************/ Loading @@ -49,38 +33,28 @@ void Dessine_Segments_Dragges( WinEDA_DrawPanel* panel, wxDC* DC ) { { D_PAD* pt_pad; D_PAD* pt_pad; TRACK* Track; TRACK* Track; DRAG_SEGM* pt_drag; if( g_DragSegmentList == NULL ) if( g_DragSegmentList.size() == 0 ) return; return; pt_drag = g_DragSegmentList; for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) for( ; pt_drag; pt_drag = pt_drag->Pnext ) { { int px, py; wxPoint pos; Track = g_DragSegmentList[ii].m_Segm; Track = pt_drag->m_Segm; Track->Draw( panel, DC, GR_XOR ); // erase from screen at old position 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 ) if( pt_pad ) { { px = pt_pad->m_Pos.x - g_Offset_Module.x; pos = pt_pad->m_Pos - g_Offset_Module; py = pt_pad->m_Pos.y - g_Offset_Module.y; Track->m_Start = pos; Track->m_Start.x = px; Track->m_Start.y = py; } } pt_pad = pt_drag->m_Pad_End; pt_pad = g_DragSegmentList[ii].m_Pad_End; if( pt_pad ) if( pt_pad ) { { px = pt_pad->m_Pos.x - g_Offset_Module.x; pos = pt_pad->m_Pos - g_Offset_Module; py = pt_pad->m_Pos.y - g_Offset_Module.y; Track->m_End = pos; Track->m_End.x = px; Track->m_End.y = py; } } Track->Draw( panel, DC, GR_XOR ); Track->Draw( panel, DC, GR_XOR ); Loading @@ -91,13 +65,10 @@ 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 ) /*************************************************************************/ /*************************************************************************/ /** Build the list of track segments connected to pads of a given module /* Construit la liste des segments connectes aus pads du module Module * by populate the std::vector<DRAG_SEGM> g_DragSegmentList * pour le drag de ces segments * For each selected track segment set the EDIT flag * la liste est mise a l'adresse pointee par pt_drag. * and redraw them in EDIT mode (sketch mode) * 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) */ */ { { D_PAD* pt_pad; D_PAD* pt_pad; Loading @@ -115,9 +86,11 @@ 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 ) /**********************************************************************************/ /**********************************************************************************/ /** Build the list of track segments connected to a given pad /* Routine construisant la liste les segments de piste connectes au pad PtPad * by populate the std::vector<DRAG_SEGM> g_DragSegmentList * Les net_codes sont supposes a jour. * For each selected track segment set the EDIT flag * and redraw them in EDIT mode (sketch mode) * Net codes must be OK. */ */ { { TRACK* Track; TRACK* Track; Loading @@ -133,21 +106,21 @@ void Build_1_Pad_SegmentsToDrag( WinEDA_DrawPanel* panel, wxDC* DC, D_PAD* PtPad for( ; Track; Track = Track->Next() ) for( ; Track; Track = Track->Next() ) { { if( Track->GetNet() != net_code ) if( Track->GetNet() != net_code ) break; /* hors zone */ break; if( ( MasqueLayer & Track->ReturnMaskLayer() ) == 0 ) if( ( MasqueLayer & Track->ReturnMaskLayer() ) == 0 ) continue; /* couches differentes */ continue; if( pos == Track->m_Start ) if( pos == Track->m_Start ) { { AddSegmentToDragList( panel, DC, STARTPOINT, Track ); AddSegmentToDragList( panel, DC, STARTPOINT, Track ); g_DragSegmentList->m_Pad_Start = PtPad; g_DragSegmentList.back().m_Pad_Start = PtPad; } } if( pos == Track->m_End ) if( pos == Track->m_End ) { { AddSegmentToDragList( panel, DC, ENDPOINT, Track ); AddSegmentToDragList( panel, DC, ENDPOINT, Track ); g_DragSegmentList->m_Pad_End = PtPad; g_DragSegmentList.back().m_Pad_End = PtPad; } } } } } } Loading @@ -157,23 +130,17 @@ void Build_1_Pad_SegmentsToDrag( WinEDA_DrawPanel* panel, wxDC* DC, D_PAD* PtPad void AddSegmentToDragList( WinEDA_DrawPanel* panel, wxDC* DC, void AddSegmentToDragList( WinEDA_DrawPanel* panel, wxDC* DC, int flag, TRACK* Track ) int flag, TRACK* Track ) /******************************************************************/ /******************************************************************/ /* 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) or ENDPOINT * flag = STARTPOINT (if the point to drag is the start point of Track) or ENDPOINT */ */ { { DRAG_SEGM* pt_drag; DRAG_SEGM wrapper( Track ); pt_drag = new DRAG_SEGM( Track ); pt_drag->Pnext = g_DragSegmentList; g_DragSegmentList = pt_drag; if( (flag & STARTPOINT) ) if( (flag & STARTPOINT) ) pt_drag->m_Flag |= 1; wrapper.m_Flag |= 1; if( (flag & ENDPOINT) ) if( (flag & ENDPOINT) ) pt_drag->m_Flag |= 2; wrapper.m_Flag |= 2; Track->Draw( panel, DC, GR_XOR ); Track->Draw( panel, DC, GR_XOR ); Track->SetState( EDIT, ON ); Track->SetState( EDIT, ON ); Loading @@ -185,66 +152,68 @@ void AddSegmentToDragList( WinEDA_DrawPanel* panel, wxDC* DC, Track->m_Flags |= ENDPOINT; Track->m_Flags |= ENDPOINT; Track->Draw( panel, DC, GR_XOR ); Track->Draw( panel, DC, GR_XOR ); g_DragSegmentList.push_back( wrapper ); } } /**********************************************************************************/ /**********************************************************************************/ void Collect_TrackSegmentsToDrag( WinEDA_DrawPanel* panel, wxDC* DC, 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 /* Build the list of tracks connected to the ref point * Les net_codes sont supposes a jour. * 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 ); TRACK* track = pcb->m_Track->GetStartNetCode( net_code ); for( ; track; track = track->Next() ) for( ; track; track = track->Next() ) { { if( track->GetNet() != net_code ) if( track->GetNet() != net_code ) // Bad net, not connected break; /* hors zone */ break; if( ( MasqueLayer & track->ReturnMaskLayer() ) == 0 ) if( ( MasqueLayer & track->ReturnMaskLayer() ) == 0 ) continue; /* couches differentes */ continue; // Cannot be connected, not on the same layer if( track->m_Flags & IS_DRAGGED ) if( track->m_Flags & IS_DRAGGED ) continue; // already in list continue; // already put in list if( track->m_Start == point ) int flag = 0; { AddSegmentToDragList( panel, DC, STARTPOINT, track ); } 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 ); } } } } } } /*****************************/ /** function EraseDragList void EraseDragListe() * 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 /* Routine de liberation memoire de la liste des structures DRAG_SEGM * remet a zero le pointeur global g_DragSegmentList */ */ void EraseDragList() { { DRAG_SEGM* pt_drag; for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) DRAG_SEGM* NextStruct; g_DragSegmentList[ii].m_Segm->m_Flags = 0; 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; } g_DragSegmentList = NULL; g_DragSegmentList.clear(); } }
pcbnew/modules.cpp +15 −24 Original line number Original line Diff line number Diff line Loading @@ -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 ); Loading Loading @@ -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(); Loading @@ -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; } } Loading Loading @@ -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; Loading