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
CurrPosition = initialPos;
// Undraw the current footprint
g_Offset_Module = wxPoint( 0, 0 );
DrawModuleOutlines( aFrame->GetCanvas(), aDC, aModule );
aModule->DrawOutlinesWhenMoving( aFrame->GetCanvas(), aDC, wxPoint( 0, 0 ) );
g_Offset_Module = mod_pos - CurrPosition;
......
......@@ -532,7 +532,7 @@ static void drawPickedItems( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint aOffset
{
case PCB_MODULE_T:
frame->GetBoard()->m_Status_Pcb &= ~RATSNEST_ITEM_LOCAL_OK;
DrawModuleOutlines( aPanel, aDC, (MODULE*) item );
((MODULE*) item)->DrawOutlinesWhenMoving( aPanel, aDC, g_Offset_Module );
break;
case PCB_LINE_T:
......
......@@ -45,7 +45,6 @@
#include <3d_struct.h>
#include <msgpanel.h>
#include <drag.h>
#include <class_board.h>
#include <class_edge_mod.h>
#include <class_module.h>
......
......@@ -280,6 +280,18 @@ public:
GR_DRAWMODE aDrawMode,
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
* read the 3D component shape(s) of the footprint (physical shape)
......
......@@ -49,10 +49,10 @@ class CONNECTIONS;
/*
* 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
*/
class DRAG_SEGM_PICKER
......@@ -65,7 +65,7 @@ public:
D_PAD* m_Pad_End; // pointer to the moving pad
// if the end point should follow this pad
// 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:
double m_RotationOffset; // initial orientation of the parent module
......
......@@ -56,7 +56,7 @@ DRAG_SEGM_PICKER::DRAG_SEGM_PICKER( TRACK* aTrack )
m_endInitialValue = m_Track->GetEnd();
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_Flag = 0;
m_TempFlags = 0;
m_RotationOffset = 0.0;
m_Flipped = false;
}
......@@ -320,10 +320,10 @@ void AddSegmentToDragList( int flag, TRACK* aTrack )
DRAG_SEGM_PICKER wrapper( aTrack );
if( flag & STARTPOINT )
wrapper.m_Flag |= 1;
wrapper.m_TempFlags |= 1;
if( flag & ENDPOINT )
wrapper.m_Flag |= 2;
wrapper.m_TempFlags |= 2;
if( flag & STARTPOINT )
aTrack->SetFlags( STARTPOINT );
......@@ -411,10 +411,10 @@ void UndrawAndMarkSegmentsToDrag( EDA_DRAW_PANEL* aCanvas, wxDC* aDC )
track->SetState( IN_EDIT, false );
track->SetFlags( IS_DRAGGED );
if( g_DragSegmentList[ii].m_Flag & STARTPOINT )
if( g_DragSegmentList[ii].m_TempFlags & STARTPOINT )
track->SetFlags( STARTPOINT );
if( g_DragSegmentList[ii].m_Flag & ENDPOINT )
if( g_DragSegmentList[ii].m_TempFlags & ENDPOINT )
track->SetFlags( ENDPOINT );
track->Draw( aCanvas, aDC, GR_XOR );
......
......@@ -24,7 +24,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/*
/**
* @file modules.cpp
*/
......@@ -40,7 +40,6 @@
#include <class_module.h>
#include <pcbnew.h>
#include <protos.h>
#include <drag.h>
......@@ -166,7 +165,7 @@ void Abort_MoveOrCopyModule( EDA_DRAW_PANEL* Panel, wxDC* DC )
if( module )
{
// 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 copy command, delete the new footprint
......@@ -239,12 +238,12 @@ void MoveFootprint( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
/* Erase current footprint. */
if( aErase )
{
DrawModuleOutlines( aPanel, aDC, module );
module->DrawOutlinesWhenMoving( aPanel, aDC, g_Offset_Module );
}
/* Redraw the module at the new position. */
g_Offset_Module = module->GetPosition() - aPanel->GetParent()->GetCrossHairPosition();
DrawModuleOutlines( aPanel, aDC, module );
module->DrawOutlinesWhenMoving( aPanel, aDC, g_Offset_Module );
DrawSegmentWhileMovingFootprint( aPanel, aDC );
}
......@@ -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. */
if( DC )
{
DrawModuleOutlines( m_canvas, DC, Module );
Module->DrawOutlinesWhenMoving( m_canvas, DC, g_Offset_Module );
DrawSegmentWhileMovingFootprint( m_canvas, DC );
}
}
......@@ -347,7 +346,7 @@ void PCB_EDIT_FRAME::Change_Side_Module( MODULE* Module, wxDC* DC )
{
if( DC )
{
DrawModuleOutlines( m_canvas, DC, Module );
Module->DrawOutlinesWhenMoving( m_canvas, DC, g_Offset_Module );
DrawSegmentWhileMovingFootprint( m_canvas, DC );
}
......@@ -459,7 +458,7 @@ void PCB_BASE_FRAME::Rotate_Module( wxDC* DC, MODULE* module, double angle, bool
{
if( DC )
{
DrawModuleOutlines( m_canvas, DC, module );
module->DrawOutlinesWhenMoving( m_canvas, DC, g_Offset_Module );
DrawSegmentWhileMovingFootprint( m_canvas, DC );
}
}
......@@ -486,7 +485,7 @@ void PCB_BASE_FRAME::Rotate_Module( wxDC* DC, MODULE* module, double angle, bool
else
{
// Beiing moved: just redraw it
DrawModuleOutlines( m_canvas, DC, module );
module->DrawOutlinesWhenMoving( m_canvas, DC, g_Offset_Module );
DrawSegmentWhileMovingFootprint( m_canvas, DC );
}
......@@ -496,35 +495,31 @@ void PCB_BASE_FRAME::Rotate_Module( wxDC* DC, MODULE* module, double angle, bool
}
/*************************************************/
/* Redraw in XOR mode the outlines of a module. */
/*************************************************/
void DrawModuleOutlines( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* module )
// Redraw in XOR mode the outlines of the module.
void MODULE::DrawOutlinesWhenMoving( EDA_DRAW_PANEL* panel, wxDC* DC,
const wxPoint& aMoveVector )
{
int pad_fill_tmp;
D_PAD* pt_pad;
if( module == NULL )
return;
module->DrawEdgesOnly( panel, DC, g_Offset_Module, GR_XOR );
DrawEdgesOnly( panel, DC, aMoveVector, GR_XOR );
DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions();
// Show pads in sketch mode to speedu up drawings
pad_fill_tmp = displ_opts->m_DisplayPadFill;
displ_opts->m_DisplayPadFill = true;
pt_pad = module->Pads();
pt_pad = Pads();
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;
if( displ_opts->m_Show_Module_Ratsnest && panel )
if( displ_opts->m_Show_Module_Ratsnest )
{
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) panel->GetParent();
frame->build_ratsnest_module( module );
frame->build_ratsnest_module( this );
frame->TraceModuleRatsNest( DC );
}
}
......@@ -61,8 +61,6 @@ void DrawTraces( EDA_DRAW_PANEL* panel,
int nbsegment,
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,
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