Commit 79e2a414 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: Fix potential bug in DRAG_SEGM_PICKER (a variable type bool was used...

Pcbnew: Fix potential bug in DRAG_SEGM_PICKER (a variable type bool was used as int. type is now int). Minor code cleanup.
parent 64925bfc
...@@ -652,8 +652,7 @@ int getOptimalModulePlacement( PCB_EDIT_FRAME* aFrame, MODULE* aModule, wxDC* aD ...@@ -652,8 +652,7 @@ int getOptimalModulePlacement( PCB_EDIT_FRAME* aFrame, MODULE* aModule, wxDC* aD
CurrPosition = initialPos; CurrPosition = initialPos;
// Undraw the current footprint // Undraw the current footprint
g_Offset_Module = wxPoint( 0, 0 ); aModule->DrawOutlinesWhenMoving( aFrame->GetCanvas(), aDC, wxPoint( 0, 0 ) );
DrawModuleOutlines( aFrame->GetCanvas(), aDC, aModule );
g_Offset_Module = mod_pos - CurrPosition; g_Offset_Module = mod_pos - CurrPosition;
......
...@@ -532,7 +532,7 @@ static void drawPickedItems( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint aOffset ...@@ -532,7 +532,7 @@ static void drawPickedItems( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint aOffset
{ {
case PCB_MODULE_T: case PCB_MODULE_T:
frame->GetBoard()->m_Status_Pcb &= ~RATSNEST_ITEM_LOCAL_OK; frame->GetBoard()->m_Status_Pcb &= ~RATSNEST_ITEM_LOCAL_OK;
DrawModuleOutlines( aPanel, aDC, (MODULE*) item ); ((MODULE*) item)->DrawOutlinesWhenMoving( aPanel, aDC, g_Offset_Module );
break; break;
case PCB_LINE_T: case PCB_LINE_T:
......
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
#include <3d_struct.h> #include <3d_struct.h>
#include <msgpanel.h> #include <msgpanel.h>
#include <drag.h>
#include <class_board.h> #include <class_board.h>
#include <class_edge_mod.h> #include <class_edge_mod.h>
#include <class_module.h> #include <class_module.h>
......
...@@ -280,6 +280,18 @@ public: ...@@ -280,6 +280,18 @@ public:
GR_DRAWMODE aDrawMode, GR_DRAWMODE aDrawMode,
const wxPoint& aOffset = ZeroOffset ); const wxPoint& aOffset = ZeroOffset );
/**
* Function DrawOutlinesWhenMoving
* draws in XOR mode the footprint when moving it to the \a aDC.
* To speed up the drawing, only a simplified shape is drawn
* @param aPanel = draw panel, Used to know the clip box
* @param aDC = Current Device Context
* @param aMoveVector = the offset between the curr position and
* the draw position.
*/
void DrawOutlinesWhenMoving( EDA_DRAW_PANEL* aPanel,
wxDC* aDC, const wxPoint& aMoveVector );
/** /**
* function ReadandInsert3DComponentShape * function ReadandInsert3DComponentShape
* read the 3D component shape(s) of the footprint (physical shape) * read the 3D component shape(s) of the footprint (physical shape)
......
...@@ -49,10 +49,10 @@ class CONNECTIONS; ...@@ -49,10 +49,10 @@ class CONNECTIONS;
/* /*
* a DRAG_LIST manages the list of track segments to modify * a DRAG_LIST manages the list of track segments to modify
* when the pad or the module is moving * when the pad or the module is moving in drag mode
*/ */
/* /**
* a DRAG_SEGM_PICKER manage one track segment or a via * a DRAG_SEGM_PICKER manage one track segment or a via
*/ */
class DRAG_SEGM_PICKER class DRAG_SEGM_PICKER
...@@ -65,7 +65,7 @@ public: ...@@ -65,7 +65,7 @@ public:
D_PAD* m_Pad_End; // pointer to the moving pad D_PAD* m_Pad_End; // pointer to the moving pad
// if the end point should follow this pad // if the end point should follow this pad
// or NULL // or NULL
bool m_Flag; // flag used in drag vias and drag track segment functions int m_TempFlags; // flag used in drag vias and drag track segment functions
private: private:
double m_RotationOffset; // initial orientation of the parent module double m_RotationOffset; // initial orientation of the parent module
......
...@@ -56,7 +56,7 @@ DRAG_SEGM_PICKER::DRAG_SEGM_PICKER( TRACK* aTrack ) ...@@ -56,7 +56,7 @@ DRAG_SEGM_PICKER::DRAG_SEGM_PICKER( TRACK* aTrack )
m_endInitialValue = m_Track->GetEnd(); m_endInitialValue = m_Track->GetEnd();
m_Pad_Start = m_Track->GetState( START_ON_PAD ) ? (D_PAD*)m_Track->start : NULL; m_Pad_Start = m_Track->GetState( START_ON_PAD ) ? (D_PAD*)m_Track->start : NULL;
m_Pad_End = m_Track->GetState( END_ON_PAD ) ? (D_PAD*)m_Track->end : NULL; m_Pad_End = m_Track->GetState( END_ON_PAD ) ? (D_PAD*)m_Track->end : NULL;
m_Flag = 0; m_TempFlags = 0;
m_RotationOffset = 0.0; m_RotationOffset = 0.0;
m_Flipped = false; m_Flipped = false;
} }
...@@ -320,10 +320,10 @@ void AddSegmentToDragList( int flag, TRACK* aTrack ) ...@@ -320,10 +320,10 @@ void AddSegmentToDragList( int flag, TRACK* aTrack )
DRAG_SEGM_PICKER wrapper( aTrack ); DRAG_SEGM_PICKER wrapper( aTrack );
if( flag & STARTPOINT ) if( flag & STARTPOINT )
wrapper.m_Flag |= 1; wrapper.m_TempFlags |= 1;
if( flag & ENDPOINT ) if( flag & ENDPOINT )
wrapper.m_Flag |= 2; wrapper.m_TempFlags |= 2;
if( flag & STARTPOINT ) if( flag & STARTPOINT )
aTrack->SetFlags( STARTPOINT ); aTrack->SetFlags( STARTPOINT );
...@@ -411,10 +411,10 @@ void UndrawAndMarkSegmentsToDrag( EDA_DRAW_PANEL* aCanvas, wxDC* aDC ) ...@@ -411,10 +411,10 @@ void UndrawAndMarkSegmentsToDrag( EDA_DRAW_PANEL* aCanvas, wxDC* aDC )
track->SetState( IN_EDIT, false ); track->SetState( IN_EDIT, false );
track->SetFlags( IS_DRAGGED ); track->SetFlags( IS_DRAGGED );
if( g_DragSegmentList[ii].m_Flag & STARTPOINT ) if( g_DragSegmentList[ii].m_TempFlags & STARTPOINT )
track->SetFlags( STARTPOINT ); track->SetFlags( STARTPOINT );
if( g_DragSegmentList[ii].m_Flag & ENDPOINT ) if( g_DragSegmentList[ii].m_TempFlags & ENDPOINT )
track->SetFlags( ENDPOINT ); track->SetFlags( ENDPOINT );
track->Draw( aCanvas, aDC, GR_XOR ); track->Draw( aCanvas, aDC, GR_XOR );
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
/* /**
* @file modules.cpp * @file modules.cpp
*/ */
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
#include <class_module.h> #include <class_module.h>
#include <pcbnew.h> #include <pcbnew.h>
#include <protos.h>
#include <drag.h> #include <drag.h>
...@@ -166,7 +165,7 @@ void Abort_MoveOrCopyModule( EDA_DRAW_PANEL* Panel, wxDC* DC ) ...@@ -166,7 +165,7 @@ void Abort_MoveOrCopyModule( EDA_DRAW_PANEL* Panel, wxDC* DC )
if( module ) if( module )
{ {
// Erase the current footprint on screen // Erase the current footprint on screen
DrawModuleOutlines( Panel, DC, module ); module->DrawOutlinesWhenMoving( Panel, DC, g_Offset_Module );
/* If a move command: return to old position /* If a move command: return to old position
* If a copy command, delete the new footprint * If a copy command, delete the new footprint
...@@ -239,12 +238,12 @@ void MoveFootprint( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, ...@@ -239,12 +238,12 @@ void MoveFootprint( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
/* Erase current footprint. */ /* Erase current footprint. */
if( aErase ) if( aErase )
{ {
DrawModuleOutlines( aPanel, aDC, module ); module->DrawOutlinesWhenMoving( aPanel, aDC, g_Offset_Module );
} }
/* Redraw the module at the new position. */ /* Redraw the module at the new position. */
g_Offset_Module = module->GetPosition() - aPanel->GetParent()->GetCrossHairPosition(); g_Offset_Module = module->GetPosition() - aPanel->GetParent()->GetCrossHairPosition();
DrawModuleOutlines( aPanel, aDC, module ); module->DrawOutlinesWhenMoving( aPanel, aDC, g_Offset_Module );
DrawSegmentWhileMovingFootprint( aPanel, aDC ); DrawSegmentWhileMovingFootprint( aPanel, aDC );
} }
...@@ -323,7 +322,7 @@ void PCB_EDIT_FRAME::Change_Side_Module( MODULE* Module, wxDC* DC ) ...@@ -323,7 +322,7 @@ void PCB_EDIT_FRAME::Change_Side_Module( MODULE* Module, wxDC* DC )
/* Erase footprint and draw outline if it has been already drawn. */ /* Erase footprint and draw outline if it has been already drawn. */
if( DC ) if( DC )
{ {
DrawModuleOutlines( m_canvas, DC, Module ); Module->DrawOutlinesWhenMoving( m_canvas, DC, g_Offset_Module );
DrawSegmentWhileMovingFootprint( m_canvas, DC ); DrawSegmentWhileMovingFootprint( m_canvas, DC );
} }
} }
...@@ -347,7 +346,7 @@ void PCB_EDIT_FRAME::Change_Side_Module( MODULE* Module, wxDC* DC ) ...@@ -347,7 +346,7 @@ void PCB_EDIT_FRAME::Change_Side_Module( MODULE* Module, wxDC* DC )
{ {
if( DC ) if( DC )
{ {
DrawModuleOutlines( m_canvas, DC, Module ); Module->DrawOutlinesWhenMoving( m_canvas, DC, g_Offset_Module );
DrawSegmentWhileMovingFootprint( m_canvas, DC ); DrawSegmentWhileMovingFootprint( m_canvas, DC );
} }
...@@ -459,7 +458,7 @@ void PCB_BASE_FRAME::Rotate_Module( wxDC* DC, MODULE* module, double angle, bool ...@@ -459,7 +458,7 @@ void PCB_BASE_FRAME::Rotate_Module( wxDC* DC, MODULE* module, double angle, bool
{ {
if( DC ) if( DC )
{ {
DrawModuleOutlines( m_canvas, DC, module ); module->DrawOutlinesWhenMoving( m_canvas, DC, g_Offset_Module );
DrawSegmentWhileMovingFootprint( m_canvas, DC ); DrawSegmentWhileMovingFootprint( m_canvas, DC );
} }
} }
...@@ -486,7 +485,7 @@ void PCB_BASE_FRAME::Rotate_Module( wxDC* DC, MODULE* module, double angle, bool ...@@ -486,7 +485,7 @@ void PCB_BASE_FRAME::Rotate_Module( wxDC* DC, MODULE* module, double angle, bool
else else
{ {
// Beiing moved: just redraw it // Beiing moved: just redraw it
DrawModuleOutlines( m_canvas, DC, module ); module->DrawOutlinesWhenMoving( m_canvas, DC, g_Offset_Module );
DrawSegmentWhileMovingFootprint( m_canvas, DC ); DrawSegmentWhileMovingFootprint( m_canvas, DC );
} }
...@@ -496,35 +495,31 @@ void PCB_BASE_FRAME::Rotate_Module( wxDC* DC, MODULE* module, double angle, bool ...@@ -496,35 +495,31 @@ void PCB_BASE_FRAME::Rotate_Module( wxDC* DC, MODULE* module, double angle, bool
} }
/*************************************************/ // Redraw in XOR mode the outlines of the module.
/* Redraw in XOR mode the outlines of a module. */ void MODULE::DrawOutlinesWhenMoving( EDA_DRAW_PANEL* panel, wxDC* DC,
/*************************************************/ const wxPoint& aMoveVector )
void DrawModuleOutlines( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* module )
{ {
int pad_fill_tmp; int pad_fill_tmp;
D_PAD* pt_pad; D_PAD* pt_pad;
if( module == NULL ) DrawEdgesOnly( panel, DC, aMoveVector, GR_XOR );
return;
module->DrawEdgesOnly( panel, DC, g_Offset_Module, GR_XOR );
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions(); DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions();
// Show pads in sketch mode to speedu up drawings // Show pads in sketch mode to speedu up drawings
pad_fill_tmp = displ_opts->m_DisplayPadFill; pad_fill_tmp = displ_opts->m_DisplayPadFill;
displ_opts->m_DisplayPadFill = true; displ_opts->m_DisplayPadFill = true;
pt_pad = module->Pads(); pt_pad = Pads();
for( ; pt_pad != NULL; pt_pad = pt_pad->Next() ) for( ; pt_pad != NULL; pt_pad = pt_pad->Next() )
pt_pad->Draw( panel, DC, GR_XOR, g_Offset_Module ); pt_pad->Draw( panel, DC, GR_XOR, aMoveVector );
displ_opts->m_DisplayPadFill = pad_fill_tmp; displ_opts->m_DisplayPadFill = pad_fill_tmp;
if( displ_opts->m_Show_Module_Ratsnest && panel ) if( displ_opts->m_Show_Module_Ratsnest )
{ {
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) panel->GetParent(); PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) panel->GetParent();
frame->build_ratsnest_module( module ); frame->build_ratsnest_module( this );
frame->TraceModuleRatsNest( DC ); frame->TraceModuleRatsNest( DC );
} }
} }
...@@ -61,8 +61,6 @@ void DrawTraces( EDA_DRAW_PANEL* panel, ...@@ -61,8 +61,6 @@ void DrawTraces( EDA_DRAW_PANEL* panel,
int nbsegment, int nbsegment,
GR_DRAWMODE mode_color ); GR_DRAWMODE mode_color );
void DrawModuleOutlines( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* module );
void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase ); bool aErase );
......
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