Global variable removal and coordinate fixes.

* ActiveScreen global variable is gone, yeah!
* Use drawing coordinates instead of screen coordinates when calling
  GeneralControle().
This commit is contained in:
Wayne Stambaugh 2011-02-01 10:46:25 -05:00
parent 6f9fc8d210
commit 85ae0373e3
27 changed files with 353 additions and 478 deletions

View File

@ -13,8 +13,6 @@
#include "id.h"
BASE_SCREEN* ActiveScreen = NULL;
#define CURSOR_SIZE 12 /* size of the cross cursor. */

View File

@ -285,22 +285,19 @@ wxPoint EDA_DRAW_PANEL::GetScreenCenterLogicalPosition()
*/
void EDA_DRAW_PANEL::MouseToCursorSchema()
{
wxPoint Mouse = CursorScreenPosition();
MouseTo( Mouse );
MoveCursor( GetScreen()->m_Curseur );
}
/** Move the mouse cursor to the position "Mouse"
* @param Mouse = mouse cursor position, in pixels units
*/
void EDA_DRAW_PANEL::MouseTo( const wxPoint& Mouse )
void EDA_DRAW_PANEL::MoveCursor( const wxPoint& aPosition )
{
int x, y, xPpu, yPpu;
wxPoint screenPos, drawingPos;
wxRect clientRect( wxPoint( 0, 0 ), GetClientSize() );
CalcScrolledPosition( Mouse.x, Mouse.y, &screenPos.x, &screenPos.y );
INSTALL_UNBUFFERED_DC( dc, this );
screenPos.x = dc.LogicalToDeviceX( aPosition.x );
screenPos.y = dc.LogicalToDeviceY( aPosition.y );
// Scroll if the requested mouse position cursor is outside the drawing area.
if( !clientRect.Contains( screenPos ) )
@ -309,7 +306,7 @@ void EDA_DRAW_PANEL::MouseTo( const wxPoint& Mouse )
GetScrollPixelsPerUnit( &xPpu, &yPpu );
CalcUnscrolledPosition( screenPos.x, screenPos.y, &drawingPos.x, &drawingPos.y );
wxLogDebug( wxT( "MouseTo() initial screen position(%d, %d) " ) \
wxLogDebug( wxT( "MoveCursor() initial screen position(%d, %d) " ) \
wxT( "rectangle(%d, %d, %d, %d) view(%d, %d)" ),
screenPos.x, screenPos.y, clientRect.x, clientRect.y,
clientRect.width, clientRect.height, x, y );
@ -326,7 +323,7 @@ void EDA_DRAW_PANEL::MouseTo( const wxPoint& Mouse )
Scroll( x, y );
CalcScrolledPosition( drawingPos.x, drawingPos.y, &screenPos.x, &screenPos.y );
wxLogDebug( wxT( "MouseTo() scrolled screen position(%d, %d) view(%d, %d)" ),
wxLogDebug( wxT( "MoveCursor() scrolled screen position(%d, %d) view(%d, %d)" ),
screenPos.x, screenPos.y, x, y );
}
@ -1007,7 +1004,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
}
/* Calling the general function on mouse changes (and pseudo key commands) */
m_Parent->GeneralControle( &DC, pos );
m_Parent->GeneralControle( &DC, event.GetLogicalPosition( DC ) );
/*******************************/
/* Control of block commands : */
@ -1221,10 +1218,11 @@ void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event )
}
/* Some key commands use the current mouse position: refresh it */
pos = CalcUnscrolledPosition( wxGetMousePosition() - GetScreenPosition() );
pos = wxGetMousePosition() - GetScreenPosition();
// Compute the cursor position in drawing units. Also known as logical units to wxDC.
Screen->m_MousePosition = CursorRealPosition( pos );
pos = wxPoint( DC.DeviceToLogicalX( pos.x ), DC.DeviceToLogicalY( pos.y ) );
Screen->m_MousePosition = pos;
m_Parent->GeneralControle( &DC, pos );

View File

@ -70,8 +70,6 @@ static void GRSRect( EDA_Rect* aClipBox, wxDC* aDC, int x1, int y1,
/**/
extern BASE_SCREEN* ActiveScreen;
static int GRLastMoveToX, GRLastMoveToY;
static bool s_ForceBlackPen; /* if true: draws in black instead of
* color for printing. */

View File

@ -52,17 +52,18 @@ void EDA_DRAW_FRAME::RedrawScreen( bool aWarpPointer )
void EDA_DRAW_FRAME::PutOnGrid( wxPoint* aCoord , wxRealPoint* aGridSize )
{
wxRealPoint grid_size;
if( aGridSize )
grid_size = *aGridSize;
else
grid_size = GetBaseScreen()->GetGridSize();
grid_size = GetBaseScreen()->GetGridSize();
const wxPoint& grid_origin = GetBaseScreen()->GetGridOrigin();
double offset = fmod(grid_origin.x, grid_size.x);
double offset = fmod( grid_origin.x, grid_size.x );
int tmp = wxRound( (aCoord->x - offset) / grid_size.x );
aCoord->x = wxRound( tmp * grid_size.x + offset );
offset = fmod(grid_origin.y, grid_size.y);
offset = fmod( grid_origin.y, grid_size.y );
tmp = wxRound( (aCoord->y - offset) / grid_size.y );
aCoord->y = wxRound ( tmp * grid_size.y + offset );
}

View File

@ -390,27 +390,19 @@ void DISPLAY_FOOTPRINTS_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
SetToolbars();
}
void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* DC, wxPoint Mouse )
void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* aDC, wxPoint aPosition )
{
wxRealPoint delta;
int flagcurseur = 0;
wxPoint curpos, oldpos;
double scalar = GetScreen()->GetScalingFactor();
wxRealPoint gridSize;
int flagcurseur = 0;
wxPoint oldpos;
wxPoint pos = aPosition;
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetEventObject( this );
curpos = DrawPanel->CursorRealPosition( Mouse );
PutOnGrid( &pos );
oldpos = GetScreen()->m_Curseur;
delta = GetScreen()->GetGridSize();
delta.x *= scalar;
delta.y *= scalar;
if( delta.x <= 0 )
delta.x = 1;
if( delta.y <= 0 )
delta.y = 1;
gridSize = GetScreen()->GetGridSize();
switch( g_KeyPressed )
{
@ -418,14 +410,14 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* DC, wxPoint Mouse )
cmd.SetId( ID_POPUP_ZOOM_IN );
GetEventHandler()->ProcessEvent( cmd );
flagcurseur = 2;
curpos = GetScreen()->m_Curseur;
pos = GetScreen()->m_Curseur;
break;
case WXK_F2:
cmd.SetId( ID_POPUP_ZOOM_OUT );
GetEventHandler()->ProcessEvent( cmd );
flagcurseur = 2;
curpos = GetScreen()->m_Curseur;
pos = GetScreen()->m_Curseur;
break;
case WXK_F3:
@ -438,14 +430,14 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* DC, wxPoint Mouse )
cmd.SetId( ID_POPUP_ZOOM_CENTER );
GetEventHandler()->ProcessEvent( cmd );
flagcurseur = 2;
curpos = GetScreen()->m_Curseur;
pos = GetScreen()->m_Curseur;
break;
case WXK_HOME:
cmd.SetId( ID_ZOOM_PAGE );
GetEventHandler()->ProcessEvent( cmd );
flagcurseur = 2;
curpos = GetScreen()->m_Curseur;
pos = GetScreen()->m_Curseur;
break;
case ' ':
@ -454,32 +446,30 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* DC, wxPoint Mouse )
case WXK_NUMPAD8: /* cursor moved up */
case WXK_UP:
Mouse.y -= wxRound(delta.y);
DrawPanel->MouseTo( Mouse );
pos.y -= wxRound( gridSize.y );
DrawPanel->MoveCursor( pos );
break;
case WXK_NUMPAD2: /* cursor moved down */
case WXK_DOWN:
Mouse.y += wxRound(delta.y);
DrawPanel->MouseTo( Mouse );
pos.y += wxRound( gridSize.y );
DrawPanel->MoveCursor( pos );
break;
case WXK_NUMPAD4: /* cursor moved left */
case WXK_LEFT:
Mouse.x -= wxRound(delta.x);
DrawPanel->MouseTo( Mouse );
pos.x -= wxRound( gridSize.x );
DrawPanel->MoveCursor( pos );
break;
case WXK_NUMPAD6: /* cursor moved right */
case WXK_RIGHT:
Mouse.x += wxRound(delta.x);
DrawPanel->MouseTo( Mouse );
pos.x += wxRound( gridSize.x );
DrawPanel->MoveCursor( pos );
break;
}
GetScreen()->m_Curseur = curpos;
/* Put cursor on grid */
PutOnGrid( &GetScreen()->m_Curseur );
GetScreen()->m_Curseur = pos;
if( GetScreen()->IsRefreshReq() )
{
@ -491,17 +481,16 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* DC, wxPoint Mouse )
{
if( flagcurseur != 2 )
{
curpos = GetScreen()->m_Curseur;
pos = GetScreen()->m_Curseur;
GetScreen()->m_Curseur = oldpos;
DrawPanel->CursorOff( DC );
GetScreen()->m_Curseur = curpos;
DrawPanel->CursorOn( DC );
DrawPanel->CursorOff( aDC );
GetScreen()->m_Curseur = pos;
DrawPanel->CursorOn( aDC );
}
if( DrawPanel->ManageCurseur )
{
DrawPanel->ManageCurseur( DrawPanel, DC, 0 );
DrawPanel->ManageCurseur( DrawPanel, aDC, 0 );
}
}

View File

@ -91,12 +91,11 @@ void DISPLAY_FOOTPRINTS_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
if( !GetBoard() )
return;
ActiveScreen = (PCB_SCREEN*) GetScreen();
DrawPanel->DrawBackGround( DC );
GetBoard()->Draw( DrawPanel, DC, GR_COPY );
MODULE* Module = GetBoard()->m_Modules;
if ( Module )
Module->DisplayInfo( this );

View File

@ -48,11 +48,12 @@ SCH_ITEM* SCH_EDIT_FRAME::SchematicGeneralLocateAndDisplay( bool IncludePin )
SCH_COMPONENT* LibItem = NULL;
DrawStruct = SchematicGeneralLocateAndDisplay( mouse_position, IncludePin );
if( !DrawStruct && ( mouse_position != GetScreen()->m_Curseur) )
{
DrawStruct = SchematicGeneralLocateAndDisplay( GetScreen()->m_Curseur,
IncludePin );
DrawStruct = SchematicGeneralLocateAndDisplay( GetScreen()->m_Curseur, IncludePin );
}
if( !DrawStruct )
return NULL;
@ -235,26 +236,17 @@ SCH_ITEM* SCH_EDIT_FRAME::SchematicGeneralLocateAndDisplay( const wxPoint& refpo
}
void SCH_EDIT_FRAME::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
void SCH_EDIT_FRAME::GeneralControle( wxDC* aDC, wxPoint aPosition )
{
wxRealPoint delta;
wxRealPoint gridSize;
SCH_SCREEN* screen = GetScreen();
wxPoint curpos, oldpos;
wxPoint oldpos;
int hotkey = 0;
double scalar = screen->GetScalingFactor();
wxPoint pos = aPosition;
curpos = screen->m_MousePosition;
PutOnGrid( &pos );
oldpos = screen->m_Curseur;
delta = screen->GetGridSize();
delta.x *= scalar;
delta.y *= scalar;
if( delta.x <= 0 )
delta.x = 1;
if( delta.y <= 0 )
delta.y = 1;
gridSize = screen->GetGridSize();
switch( g_KeyPressed )
{
@ -263,26 +255,26 @@ void SCH_EDIT_FRAME::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
case WXK_NUMPAD8:
case WXK_UP:
MousePositionInPixels.y -= wxRound( delta.y );
DrawPanel->MouseTo( MousePositionInPixels );
pos.y -= wxRound( gridSize.y );
DrawPanel->MoveCursor( pos );
break;
case WXK_NUMPAD2:
case WXK_DOWN:
MousePositionInPixels.y += wxRound( delta.y );
DrawPanel->MouseTo( MousePositionInPixels );
pos.y += wxRound( gridSize.y );
DrawPanel->MoveCursor( pos );
break;
case WXK_NUMPAD4:
case WXK_LEFT:
MousePositionInPixels.x -= wxRound( delta.x );
DrawPanel->MouseTo( MousePositionInPixels );
pos.x -= wxRound( gridSize.x );
DrawPanel->MoveCursor( pos );
break;
case WXK_NUMPAD6:
case WXK_RIGHT:
MousePositionInPixels.x += wxRound( delta.x );
DrawPanel->MouseTo( MousePositionInPixels );
pos.x += wxRound( gridSize.x );
DrawPanel->MoveCursor( pos );
break;
default:
@ -290,11 +282,8 @@ void SCH_EDIT_FRAME::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
break;
}
/* Update cursor position. */
screen->m_Curseur = curpos;
/* Snap cursor to grid. */
PutOnGrid( &(screen->m_Curseur) );
// Update cursor position.
screen->m_Curseur = pos;
if( screen->IsRefreshReq() )
{
@ -304,24 +293,24 @@ void SCH_EDIT_FRAME::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
if( oldpos != screen->m_Curseur )
{
curpos = screen->m_Curseur;
pos = screen->m_Curseur;
screen->m_Curseur = oldpos;
DrawPanel->CursorOff( DC );
screen->m_Curseur = curpos;
DrawPanel->CursorOn( DC );
DrawPanel->CursorOff( aDC );
screen->m_Curseur = pos;
DrawPanel->CursorOn( aDC );
if( DrawPanel->ManageCurseur )
{
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
DrawPanel->ManageCurseur( DrawPanel, aDC, TRUE );
}
}
if( hotkey )
{
if( screen->GetCurItem() && screen->GetCurItem()->m_Flags )
OnHotKey( DC, hotkey, screen->GetCurItem() );
OnHotKey( aDC, hotkey, screen->GetCurItem() );
else
OnHotKey( DC, hotkey, NULL );
OnHotKey( aDC, hotkey, NULL );
}
UpdateStatusBar(); /* Display cursor coordinates info */
@ -329,26 +318,17 @@ void SCH_EDIT_FRAME::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
}
void LIB_EDIT_FRAME::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
void LIB_EDIT_FRAME::GeneralControle( wxDC* aDC, wxPoint aPosition )
{
wxRealPoint delta;
wxRealPoint gridSize;
SCH_SCREEN* screen = GetScreen();
wxPoint curpos, oldpos;
wxPoint oldpos;
int hotkey = 0;
double scalar = screen->GetScalingFactor();
wxPoint pos = aPosition;
curpos = screen->m_MousePosition;
PutOnGrid( &pos );
oldpos = screen->m_Curseur;
delta = screen->GetGridSize();
delta.x *= scalar;
delta.y *= scalar;
if( delta.x <= 0 )
delta.x = 1;
if( delta.y <= 0 )
delta.y = 1;
gridSize = screen->GetGridSize();
switch( g_KeyPressed )
{
@ -357,26 +337,26 @@ void LIB_EDIT_FRAME::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
case WXK_NUMPAD8:
case WXK_UP:
MousePositionInPixels.y -= wxRound( delta.y );
DrawPanel->MouseTo( MousePositionInPixels );
pos.y -= wxRound( gridSize.y );
DrawPanel->MoveCursor( pos );
break;
case WXK_NUMPAD2:
case WXK_DOWN:
MousePositionInPixels.y += wxRound( delta.y );
DrawPanel->MouseTo( MousePositionInPixels );
pos.y += wxRound( gridSize.y );
DrawPanel->MoveCursor( pos );
break;
case WXK_NUMPAD4:
case WXK_LEFT:
MousePositionInPixels.x -= wxRound( delta.x );
DrawPanel->MouseTo( MousePositionInPixels );
pos.x -= wxRound( gridSize.x );
DrawPanel->MoveCursor( pos );
break;
case WXK_NUMPAD6:
case WXK_RIGHT:
MousePositionInPixels.x += wxRound( delta.x );
DrawPanel->MouseTo( MousePositionInPixels );
pos.x += wxRound( gridSize.x );
DrawPanel->MoveCursor( pos );
break;
default:
@ -384,11 +364,8 @@ void LIB_EDIT_FRAME::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
break;
}
/* Update the cursor position. */
screen->m_Curseur = curpos;
/* Snap cursor to grid. */
PutOnGrid( &(screen->m_Curseur) );
// Update the cursor position.
screen->m_Curseur = pos;
if( screen->IsRefreshReq() )
{
@ -398,50 +375,41 @@ void LIB_EDIT_FRAME::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
if( oldpos != screen->m_Curseur )
{
curpos = screen->m_Curseur;
pos = screen->m_Curseur;
screen->m_Curseur = oldpos;
DrawPanel->CursorOff( DC );
screen->m_Curseur = curpos;
DrawPanel->CursorOn( DC );
DrawPanel->CursorOff( aDC );
screen->m_Curseur = pos;
DrawPanel->CursorOn( aDC );
if( DrawPanel->ManageCurseur )
{
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
DrawPanel->ManageCurseur( DrawPanel, aDC, TRUE );
}
}
if( hotkey )
{
if( screen->GetCurItem() && screen->GetCurItem()->m_Flags )
OnHotKey( DC, hotkey, screen->GetCurItem() );
OnHotKey( aDC, hotkey, screen->GetCurItem() );
else
OnHotKey( DC, hotkey, NULL );
OnHotKey( aDC, hotkey, NULL );
}
UpdateStatusBar();
}
void LIB_VIEW_FRAME::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
void LIB_VIEW_FRAME::GeneralControle( wxDC* aDC, wxPoint aPosition )
{
wxRealPoint delta;
wxRealPoint gridSize;
SCH_SCREEN* screen = GetScreen();
wxPoint curpos, oldpos;
wxPoint oldpos;
int hotkey = 0;
double scalar = screen->GetScalingFactor();
wxPoint pos = aPosition;
curpos = screen->m_MousePosition;
PutOnGrid( &pos );
oldpos = screen->m_Curseur;
delta = screen->GetGridSize();
delta.x *= scalar;
delta.y *= scalar;
if( delta.x <= 0 )
delta.x = 1;
if( delta.y <= 0 )
delta.y = 1;
gridSize = screen->GetGridSize();
switch( g_KeyPressed )
{
@ -450,26 +418,26 @@ void LIB_VIEW_FRAME::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
case WXK_NUMPAD8:
case WXK_UP:
MousePositionInPixels.y -= wxRound( delta.y );
DrawPanel->MouseTo( MousePositionInPixels );
pos.y -= wxRound( gridSize.y );
DrawPanel->MoveCursor( pos );
break;
case WXK_NUMPAD2:
case WXK_DOWN:
MousePositionInPixels.y += wxRound( delta.y );
DrawPanel->MouseTo( MousePositionInPixels );
pos.y += wxRound( gridSize.y );
DrawPanel->MoveCursor( pos );
break;
case WXK_NUMPAD4:
case WXK_LEFT:
MousePositionInPixels.x -= wxRound( delta.x );
DrawPanel->MouseTo( MousePositionInPixels );
pos.x -= wxRound( gridSize.x );
DrawPanel->MoveCursor( pos );
break;
case WXK_NUMPAD6:
case WXK_RIGHT:
MousePositionInPixels.x += wxRound( delta.x );
DrawPanel->MouseTo( MousePositionInPixels );
pos.x += wxRound( gridSize.x );
DrawPanel->MoveCursor( pos );
break;
default:
@ -477,11 +445,8 @@ void LIB_VIEW_FRAME::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
break;
}
/* Update cursor position. */
screen->m_Curseur = curpos;
/* Snap cursor to grid. */
PutOnGrid( &screen->m_Curseur );
// Update cursor position.
screen->m_Curseur = pos;
if( screen->IsRefreshReq() )
{
@ -491,24 +456,24 @@ void LIB_VIEW_FRAME::GeneralControle( wxDC* DC, wxPoint MousePositionInPixels )
if( oldpos != screen->m_Curseur )
{
curpos = screen->m_Curseur;
pos = screen->m_Curseur;
screen->m_Curseur = oldpos;
DrawPanel->CursorOff( DC );
screen->m_Curseur = curpos;
DrawPanel->CursorOn( DC );
DrawPanel->CursorOff( aDC );
screen->m_Curseur = pos;
DrawPanel->CursorOn( aDC );
if( DrawPanel->ManageCurseur )
{
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
DrawPanel->ManageCurseur( DrawPanel, aDC, TRUE );
}
}
if( hotkey )
{
if( screen->GetCurItem() && screen->GetCurItem()->m_Flags )
OnHotKey( DC, hotkey, screen->GetCurItem() );
OnHotKey( aDC, hotkey, screen->GetCurItem() );
else
OnHotKey( DC, hotkey, NULL );
OnHotKey( aDC, hotkey, NULL );
}
UpdateStatusBar();

View File

@ -222,7 +222,7 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere
DrawPanel->CursorOff( &dc );
if( mouseWarp )
DrawPanel->MouseTo( curpos );
DrawPanel->MoveCursor( curpos );
EXCHG( old_cursor_position, sheet->LastScreen()->m_Curseur );

View File

@ -13,11 +13,14 @@ GERBER_DRAW_ITEM* WinEDA_GerberFrame::GerberGeneralLocateAndDisplay()
}
void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
void WinEDA_GerberFrame::GeneralControle( wxDC* aDC, wxPoint aPosition )
{
wxRealPoint delta;
wxPoint curpos, oldpos;
int hotkey = 0;
wxRealPoint gridSize;
wxPoint oldpos;
int hotkey = 0;
wxPoint pos = aPosition;
PutOnGrid( &pos );
if( GetScreen()->IsRefreshReq() )
{
@ -34,45 +37,33 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
return;
}
double scalar = GetScreen()->GetScalingFactor();
curpos = DrawPanel->CursorRealPosition( Mouse );
oldpos = GetScreen()->m_Curseur;
delta = GetScreen()->GetGridSize();
delta.x *= scalar;
delta.y *= scalar;
if( delta.x == 0 )
delta.x = 1;
if( delta.y == 0 )
delta.y = 1;
gridSize = GetScreen()->GetGridSize();
switch( g_KeyPressed )
{
case WXK_NUMPAD8:
case WXK_UP:
Mouse.y -= wxRound(delta.y);
DrawPanel->MouseTo( Mouse );
pos.y -= wxRound( gridSize.y );
DrawPanel->MoveCursor( pos );
break;
case WXK_NUMPAD2:
case WXK_DOWN:
Mouse.y += wxRound(delta.y);
DrawPanel->MouseTo( Mouse );
pos.y += wxRound( gridSize.y );
DrawPanel->MoveCursor( pos );
break;
case WXK_NUMPAD4:
case WXK_LEFT:
Mouse.x -= wxRound(delta.x);
DrawPanel->MouseTo( Mouse );
pos.x -= wxRound( gridSize.x );
DrawPanel->MoveCursor( pos );
break;
case WXK_NUMPAD6:
case WXK_RIGHT:
Mouse.x += wxRound(delta.x);
DrawPanel->MouseTo( Mouse );
pos.x += wxRound( gridSize.x );
DrawPanel->MoveCursor( pos );
break;
default:
@ -80,28 +71,25 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
break;
}
GetScreen()->m_Curseur = curpos;
PutOnGrid( &GetScreen()->m_Curseur );
GetScreen()->m_Curseur = pos;
if( oldpos != GetScreen()->m_Curseur )
{
curpos = GetScreen()->m_Curseur;
pos = GetScreen()->m_Curseur;
GetScreen()->m_Curseur = oldpos;
DrawPanel->CursorOff( DC );
GetScreen()->m_Curseur = curpos;
DrawPanel->CursorOn( DC );
DrawPanel->CursorOff( aDC );
GetScreen()->m_Curseur = pos;
DrawPanel->CursorOn( aDC );
if( DrawPanel->ManageCurseur )
{
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
DrawPanel->ManageCurseur( DrawPanel, aDC, TRUE );
}
}
if( hotkey )
{
OnHotKey( DC, hotkey, NULL );
OnHotKey( aDC, hotkey, NULL );
}
if( GetScreen()->IsRefreshReq() )

View File

@ -229,7 +229,13 @@ public:
wxPoint GetScreenCenterLogicalPosition();
void MouseToCursorSchema();
void MouseTo( const wxPoint& Mouse );
/**
* Function MoveCursor
* moves the mouse pointer to \a aPosition in logical (drawing) units.
* @param aPosition The position in logical units to move the cursor.
*/
void MoveCursor( const wxPoint& aPosition );
/* Cursor functions */
/**

View File

@ -190,9 +190,6 @@ extern UserUnitType g_UserUnit; ///< display units
/* Draw color for moving objects: */
extern int g_GhostColor;
/* Current used screen: (not used in eeshema)*/
extern BASE_SCREEN* ActiveScreen;
/* COMMON.CPP */

View File

@ -160,7 +160,7 @@ public:
/**
* Function PrintPage , virtual
* used to print a page
* Print the page pointed by ActiveScreen, set by the calling print function
* Print the page pointed by the current screen, set by the calling print function
* @param aDC = wxDC given by the calling print function
* @param aPrintMaskLayer = a 32 bits mask: bit n = 1 -> layer n is printed
* @param aPrintMirrorMode = true to plot mirrored

View File

@ -365,7 +365,18 @@ public:
virtual void OnSelectGrid( wxCommandEvent& event );
virtual void OnSelectZoom( wxCommandEvent& event );
virtual void GeneralControle( wxDC* DC, wxPoint Mouse ) { /* dummy */ }
/**
* Function GeneralControle
* performs application specific control using \a aDC at \a aPosition in logical units.
* <p>
* Override this function for application specific control. This function gets
* called on every mouse and key event.
*</p>
* @param aDC A device context.
* @param aPosition The cursor position in logical (drawing) units.
*/
virtual void GeneralControle( wxDC* aDC, wxPoint aPosition ) { /* dummy */ }
virtual void OnSize( wxSizeEvent& event );
void OnEraseBackground( wxEraseEvent& SizeEvent );
@ -515,7 +526,7 @@ public:
/** Virtual function PrintPage
* used to print a page
* Print the page pointed by ActiveScreen, set by the calling print function
* Print the page pointed by current screen, set by the calling print function
* @param aDC = wxDC given by the calling print function
* @param aPrintMask = not used here
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode)

View File

@ -18,15 +18,14 @@
extern bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
int aCurrentTool, wxSize grid, wxPoint on_grid, wxPoint* curpos );
/*************************************************************************************/
static BOARD_ITEM* AllAreModulesAndReturnSmallestIfSo( GENERAL_COLLECTOR* aCollector )
/*************************************************************************************/
/**
* Function AllAreModulesAndReturnSmallestIfSo
* tests that all items in the collection are MODULEs and if so, returns the
* smallest MODULE.
* @return BOARD_ITEM* - The smallest or NULL.
*/
static BOARD_ITEM* AllAreModulesAndReturnSmallestIfSo( GENERAL_COLLECTOR* aCollector )
{
int count = aCollector->GetCount();
@ -61,9 +60,7 @@ static BOARD_ITEM* AllAreModulesAndReturnSmallestIfSo( GENERAL_COLLECTOR* aColle
}
/****************************************************************************/
BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )
/****************************************************************************/
{
BOARD_ITEM* item;
@ -133,6 +130,7 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )
for( int ii = 0; ii < m_Collector->GetCount(); ii++ )
{
item = (*m_Collector)[ii];
if( item->Type() != TYPE_ZONE )
continue;
@ -151,7 +149,9 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )
item = (*m_Collector)[0];
SetCurItem( item );
}
// If the count is 2, and first item is a pad or moduletext, and the 2nd item is its parent module:
// If the count is 2, and first item is a pad or moduletext, and the 2nd item is its
// parent module:
else if( m_Collector->GetCount() == 2
&& ( (*m_Collector)[0]->Type() == TYPE_PAD || (*m_Collector)[0]->Type() ==
TYPE_TEXTE_MODULE )
@ -173,12 +173,14 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )
/* Give a title to the selection menu. This is also a cancel menu item */
wxMenuItem * item_title = new wxMenuItem(&itemMenu, -1, _( "Selection Clarification" ) );
#ifdef __WINDOWS__
wxFont bold_font(*wxNORMAL_FONT);
bold_font.SetWeight(wxFONTWEIGHT_BOLD);
bold_font.SetStyle( wxFONTSTYLE_ITALIC);
item_title->SetFont(bold_font);
#endif
itemMenu.Append(item_title);
itemMenu.AppendSeparator();
@ -197,9 +199,11 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )
ADD_MENUITEM( &itemMenu, ID_POPUP_PCB_ITEM_SELECTION_START + i, text, xpm );
}
/* @todo: rather than assignment to TRUE, these should be increment and decrement operators throughout _everywhere_.
/* @todo: rather than assignment to TRUE, these should be increment and decrement
* operators throughout _everywhere_.
* That way we can handle nesting.
* But I tried that and found there cases where the assignment to TRUE (converted to a m_IgnoreMouseEvents++ )
* But I tried that and found there cases where the assignment to TRUE (converted to
* a m_IgnoreMouseEvents++ )
* was not balanced with the -- (now m_IgnoreMouseEvents=FALSE), so I had to revert.
* Somebody should track down these and make them balanced.
* DrawPanel->m_IgnoreMouseEvents = TRUE;
@ -222,15 +226,14 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )
}
/****************************************************************/
void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
/*****************************************************************/
void WinEDA_PcbFrame::GeneralControle( wxDC* aDC, wxPoint aPosition )
{
wxRealPoint delta;
wxPoint curpos, oldpos;
int hotkey = 0;
wxRealPoint gridSize;
wxPoint oldpos;
int hotkey = 0;
wxPoint pos = aPosition;
ActiveScreen = GetScreen();
PutOnGrid( &pos );
// Save the board after the time out :
int CurrentTime = time( NULL );
@ -245,7 +248,7 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
{
wxString tmpFileName = GetScreen()->GetFileName();
wxFileName fn = wxFileName( wxEmptyString, g_SaveFileName, PcbFileExtension );
bool flgmodify = GetScreen()->IsModify();
bool flgmodify = GetScreen()->IsModify();
SavePcbFile( fn.GetFullPath() );
@ -254,50 +257,39 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
OnModify();
GetScreen()->SetSave(); // Set the flags m_FlagSave cleared by SetModify()
}
GetScreen()->SetFileName( tmpFileName );
SetTitle( GetScreen()->GetFileName() );
}
double scalar = GetScreen()->GetScalingFactor();
curpos = DrawPanel->CursorRealPosition( Mouse );
oldpos = GetScreen()->m_Curseur;
delta = GetScreen()->GetGridSize();
delta.x *= scalar;
delta.y *= scalar;
if( delta.x <= 0 )
delta.x = 1;
if( delta.y <= 0 )
delta.y = 1;
gridSize = GetScreen()->GetGridSize();
switch( g_KeyPressed )
{
case WXK_NUMPAD8: /* Deplacement curseur vers le haut */
case WXK_UP:
Mouse.y -= wxRound(delta.y);
DrawPanel->MouseTo( Mouse );
pos.y -= wxRound( gridSize.y );
DrawPanel->MoveCursor( pos );
break;
case WXK_NUMPAD2: /* Deplacement curseur vers le bas */
case WXK_DOWN:
Mouse.y += wxRound(delta.y);
DrawPanel->MouseTo( Mouse );
pos.y += wxRound( gridSize.y );
DrawPanel->MoveCursor( pos );
break;
case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */
case WXK_LEFT:
Mouse.x -= wxRound(delta.x);
DrawPanel->MouseTo( Mouse );
pos.x -= wxRound( gridSize.x );
DrawPanel->MoveCursor( pos );
break;
case WXK_NUMPAD6: /* Deplacement curseur vers la droite */
case WXK_RIGHT:
Mouse.x += wxRound(delta.x);
DrawPanel->MouseTo( Mouse );
pos.x += wxRound( gridSize.x );
DrawPanel->MoveCursor( pos );
break;
default:
@ -305,14 +297,14 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
break;
}
/* Put cursor in new position, according to the zoom keys (if any) */
GetScreen()->m_Curseur = curpos;
// Put cursor in new position, according to the zoom keys (if any).
GetScreen()->m_Curseur = pos;
/* Put cursor on grid or a pad centre if requested
* But if the tool DELETE is active the cursor is left off grid
* this is better to reach items to delete off grid
/* Put cursor on grid or a pad centre if requested. If the tool DELETE is active the
* cursor is left off grid this is better to reach items to delete off grid,
*/
bool keep_on_grid = TRUE;
if( m_ID_current_state == ID_PCB_DELETE_ITEM_BUTT )
keep_on_grid = FALSE;
@ -327,16 +319,16 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
if( keep_on_grid )
{
wxPoint on_grid = curpos;
wxPoint on_grid = pos;
PutOnGrid( &on_grid );
wxSize grid;
grid.x = (int) GetScreen()->GetGridSize().x;
grid.y = (int) GetScreen()->GetGridSize().y;
if( Magnetize(m_Pcb, (WinEDA_PcbFrame *) this, m_ID_current_state,
grid, on_grid, &curpos) )
if( Magnetize( m_Pcb, this, m_ID_current_state, grid, on_grid, &pos ) )
{
GetScreen()->m_Curseur = curpos;
GetScreen()->m_Curseur = pos;
}
else
{
@ -354,32 +346,31 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
if( oldpos != GetScreen()->m_Curseur )
{
curpos = GetScreen()->m_Curseur;
pos = GetScreen()->m_Curseur;
GetScreen()->m_Curseur = oldpos;
DrawPanel->CursorOff( DC );
GetScreen()->m_Curseur = curpos;
DrawPanel->CursorOn( DC );
DrawPanel->CursorOff( aDC );
GetScreen()->m_Curseur = pos;
DrawPanel->CursorOn( aDC );
if( DrawPanel->ManageCurseur )
{
#ifdef USE_WX_OVERLAY
wxDCOverlay oDC( DrawPanel->m_overlay, (wxWindowDC*)DC );
oDC.Clear();
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
wxDCOverlay oDC( DrawPanel->m_overlay, (wxWindowDC*)aDC );
oDC.Clear();
DrawPanel->ManageCurseur( DrawPanel, aDC, FALSE );
#else
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
DrawPanel->ManageCurseur( DrawPanel, aDC, TRUE );
#endif
}
#ifdef USE_WX_OVERLAY
else
DrawPanel->m_overlay.Reset();
DrawPanel->m_overlay.Reset();
#endif
}
if( hotkey )
{
OnHotKey( DC, hotkey, NULL );
OnHotKey( aDC, hotkey, NULL );
}
if( GetScreen()->IsRefreshReq() )

View File

@ -271,9 +271,10 @@ void WinEDA_PcbFrame::Affiche_Status_Net( wxDC* DC )
{
TRACK* pt_segm;
int masquelayer = (1 << getActiveLayer());
wxPoint pos = GetScreen()->RefPos( true );
pt_segm = Locate_Pistes( GetBoard(), GetBoard()->m_Track, pos, masquelayer );
pt_segm = Locate_Pistes( GetBoard(), GetBoard()->m_Track, masquelayer,
CURSEUR_OFF_GRILLE );
if( pt_segm == NULL )
GetBoard()->DisplayInfo( this );
else

View File

@ -139,8 +139,6 @@ bool WinEDA_PcbFrame::LoadOnePcbFile( const wxString& aFileName, bool aAppend,
FILE* source;
wxString msg;
ActiveScreen = GetScreen();
if( GetScreen()->IsModify() && !aAppend )
{
if( !IsOK( this, _( "The current board has been modified. Do you wish to discard \

View File

@ -32,10 +32,11 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* aDC, int aHotkeyCode, EDA_ITEM* aItem )
if( aHotkeyCode == 0 )
return;
wxPoint pos;
bool itemCurrentlyEdited = (GetCurItem() && GetCurItem()->m_Flags);
MODULE* module = NULL;
int evt_type = 0; //Used to post a wxCommandEvent on demand
PCB_SCREEN* screen = GetScreen();
/* Convert lower to upper case
* (the usual toupper function has problem with non ascii codes like function keys
@ -156,8 +157,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* aDC, int aHotkeyCode, EDA_ITEM* aItem )
case HK_REDO:
if( !itemCurrentlyEdited )
{
wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED,
HK_Descr->m_IdMenuEvent );
wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, HK_Descr->m_IdMenuEvent );
wxPostEvent( this, event );
}
break;
@ -244,9 +244,9 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* aDC, int aHotkeyCode, EDA_ITEM* aItem )
case HK_ADD_MICROVIA: // Place a micro via if a track is in progress
if( m_ID_current_state != ID_TRACK_BUTT )
return;
if( !itemCurrentlyEdited ) // no track in progress: nothing to do
if( !itemCurrentlyEdited ) // no track in progress: nothing to do
break;
if( GetCurItem()->Type() != TYPE_TRACK ) // Should not occur
if( GetCurItem()->Type() != TYPE_TRACK ) // Should not occur
return;
if( (GetCurItem()->m_Flags & IS_NEW) == 0 )
return;
@ -318,10 +318,15 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* aDC, int aHotkeyCode, EDA_ITEM* aItem )
case HK_LOCK_UNLOCK_FOOTPRINT: // toggle module "MODULE_is_LOCKED" status:
// get any module, locked or not locked and toggle its locked status
if( !itemCurrentlyEdited )
module = Locate_Prefered_Module( GetBoard(), CURSEUR_OFF_GRILLE
| VISIBLE_ONLY );
{
pos = screen->RefPos( true );
module = Locate_Prefered_Module( GetBoard(), pos, screen->m_Active_Layer, true );
}
else if( GetCurItem()->Type() == TYPE_MODULE )
{
module = (MODULE*) GetCurItem();
}
if( module )
{
SetCurItem( module );
@ -400,11 +405,15 @@ bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* aDC )
case ID_COMPONENT_BUTT:
if( ItemFree )
{
MODULE* module = Locate_Prefered_Module( GetBoard(), CURSEUR_ON_GRILLE );
wxPoint pos = GetScreen()->RefPos( false );
MODULE* module = Locate_Prefered_Module( GetBoard(), pos, ALL_LAYERS, false );
if( module == NULL )
return false;
if( !IsOK( this, _( "Delete module?" ) ) )
return false;
RemoveStruct( module, aDC );
}
else

View File

@ -13,21 +13,6 @@
/**
* Function RefPos
* returns the reference position, coming from either the mouse position or the
* the cursor position, based on whether the typeloc has the CURSEUR_OFF_GRILLE
* flag ORed in or not.
* @param typeloc int with possible CURSEUR_OFF_GRILLE bit on.
* @return wxPoint - The reference point, either the mouse position or
* the cursor position.
*/
wxPoint inline RefPos( int typeloc )
{
return ActiveScreen->RefPos( (typeloc & CURSEUR_OFF_GRILLE) != 0 );
}
/* Locates a via point pX, pY
* If layer < 0 will be located via whatever layer
* If layer = 0 .. 15 Via will be located according to its type:
@ -46,12 +31,16 @@ TRACK* Locate_Via( BOARD* Pcb, const wxPoint& pos, int layer )
{
if( track->Type() != TYPE_VIA )
continue;
if( track->m_Start != pos )
continue;
if( track->GetState( BUSY | DELETED ) )
continue;
if( layer < 0 )
break;
if( track->IsOnLayer( layer ) )
break;
}
@ -68,12 +57,16 @@ TRACK* Locate_Via_Area( TRACK* aStart, const wxPoint& pos, int layer )
{
if( track->Type() != TYPE_VIA )
continue;
if( !track->HitTest(pos) )
continue;
if( track->GetState( BUSY | DELETED ) )
continue;
if( layer < 0 )
break;
if( track->IsOnLayer( layer ) )
break;
}
@ -109,6 +102,7 @@ D_PAD* Locate_Pad_Connecte( BOARD* Pcb, TRACK* ptr_piste, int extr )
for( MODULE* module = Pcb->m_Modules; module; module = module->Next() )
{
ptr_pad = Locate_Pads( module, ref_pos, masque_layer );
if( ptr_pad != NULL )
break;
}
@ -129,36 +123,19 @@ D_PAD* Locate_Pad_Connecte( BOARD* Pcb, TRACK* ptr_piste, int extr )
*
* Priority is the active layer
*/
D_PAD* Locate_Any_Pad( BOARD* Pcb, int typeloc, bool OnlyCurrentLayer )
D_PAD* Locate_Any_Pad( BOARD* Pcb, const wxPoint& ref_pos, int aLayerMask )
{
wxPoint ref_pos = RefPos( typeloc );
return Locate_Any_Pad( Pcb, ref_pos, OnlyCurrentLayer );
}
D_PAD* pad = NULL;
D_PAD* Locate_Any_Pad( BOARD* Pcb, const wxPoint& ref_pos,
bool OnlyCurrentLayer )
{
int layer_mask =
g_TabOneLayerMask[ ( (PCB_SCREEN*) ActiveScreen )->m_Active_Layer];
for( MODULE* module=Pcb->m_Modules; module; module = module->Next() )
for( MODULE* module=Pcb->m_Modules; module && ( pad == NULL ); module = module->Next() )
{
D_PAD* pt_pad;
/* First: Search a pad on the active layer: */
if( ( pt_pad = Locate_Pads( module, ref_pos, layer_mask ) ) != NULL )
return pt_pad;
/* If not found, search on other layers: */
if( !OnlyCurrentLayer )
{
if( ( pt_pad = Locate_Pads( module, ref_pos, ALL_LAYERS ) ) != NULL )
return pt_pad;
}
if( aLayerMask )
pad = Locate_Pads( module, ref_pos, aLayerMask );
else
pad = Locate_Pads( module, ref_pos, ALL_LAYERS );
}
return NULL;
return pad;
}
@ -171,13 +148,6 @@ D_PAD* Locate_Any_Pad( BOARD* Pcb, const wxPoint& ref_pos,
* A pointer to the pad if found
* NULL pointer if pad NOT FOUND
*/
D_PAD* Locate_Pads( MODULE* module, int masque_layer, int typeloc )
{
wxPoint ref_pos = RefPos( typeloc );
return Locate_Pads( module, ref_pos, masque_layer );
}
D_PAD* Locate_Pads( MODULE* module, const wxPoint& ref_pos, int masque_layer )
{
for( D_PAD* pt_pad = module->m_Pads; pt_pad; pt_pad = pt_pad->Next() )
@ -204,11 +174,14 @@ D_PAD* Locate_Pads( MODULE* module, const wxPoint& ref_pos, int masque_layer )
* distance is calculated via manhattan distance from the center of the
* bounding rectangle to the cursor position.
*
* @param Pcb The BOARD to search within.
* @param typeloc Flag bits, tuning the search, see pcbnew.h
* @return MODULE* - the best module or NULL if none.
* @param aPcb The BOARD to search within.
* @param aPosition Flag bits, tuning the search, see pcbnew.h
* @param aActiveLayer Layer to test.
* @param aVisibleOnly Search only the visible layers if true.
* @return MODULE* The best module or NULL if none.
*/
MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc )
MODULE* Locate_Prefered_Module( BOARD* aPcb, const wxPoint& aPosition, int aActiveLayer,
bool aVisibleOnly, bool aIgnoreLocked )
{
MODULE* pt_module;
int lx, ly;
@ -217,20 +190,17 @@ MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc )
int min_dim = 0x7FFFFFFF;
int alt_min_dim = 0x7FFFFFFF;
int layer;
wxPoint ref_pos;
ref_pos = RefPos( typeloc );
pt_module = aPcb->m_Modules;
pt_module = Pcb->m_Modules;
for( ; pt_module; pt_module = (MODULE*) pt_module->Next() )
{
// is the ref point within the module's bounds?
if( !pt_module->HitTest( ref_pos ) )
if( !pt_module->HitTest( aPosition ) )
continue;
// if caller wants to ignore locked modules, and this one is locked,
// skip it.
if( (typeloc & IGNORE_LOCKED) && pt_module->IsLocked() )
// if caller wants to ignore locked modules, and this one is locked, skip it.
if( aIgnoreLocked && pt_module->IsLocked() )
continue;
/* Calculate priority: the priority is given to the layer of the
@ -242,7 +212,6 @@ MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc )
if( layer==ADHESIVE_N_BACK || layer==SILKSCREEN_N_BACK )
layer = LAYER_N_BACK;
else if( layer==ADHESIVE_N_FRONT || layer==SILKSCREEN_N_FRONT )
layer = LAYER_N_FRONT;
@ -251,17 +220,20 @@ MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc )
int offx = pt_module->m_BoundaryBox.m_Size.x / 2 +
pt_module->m_BoundaryBox.m_Pos.x +
pt_module->m_Pos.x;
int offy = pt_module->m_BoundaryBox.m_Size.y / 2
+ pt_module->m_BoundaryBox.m_Pos.y
+ pt_module->m_Pos.y;
//off x & offy point to the middle of the box.
int dist = abs( ref_pos.x - offx ) + abs( ref_pos.y - offy );
int dist = abs( aPosition.x - offx ) + abs( aPosition.y - offy );
lx = pt_module->m_BoundaryBox.GetWidth();
ly = pt_module->m_BoundaryBox.GetHeight();
//int dist = MIN(lx, ly); // to pick the smallest module (kinda
// screwy with same-sized modules -- this is bad!)
if( ( (PCB_SCREEN*) ActiveScreen )->m_Active_Layer == layer )
if( aActiveLayer == layer )
{
if( dist <= min_dim )
{
@ -270,9 +242,7 @@ MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc )
min_dim = dist;
}
}
else if( !( typeloc & MATCH_LAYER )
&& ( !( typeloc & VISIBLE_ONLY )
|| Pcb->IsModuleLayerVisible( layer ) ) )
else if( aVisibleOnly && aPcb->IsModuleLayerVisible( layer ) )
{
if( dist <= alt_min_dim )
{
@ -338,8 +308,7 @@ int dist;
* @param pt_lim = upper limit for search (can be NULL)
* @param extr = START or END = end of ref track segment to use in tests
*/
TRACK* Locate_Piste_Connectee( TRACK* PtRefSegm, TRACK* pt_base,
TRACK* pt_lim, int extr )
TRACK* Locate_Piste_Connectee( TRACK* PtRefSegm, TRACK* pt_base, TRACK* pt_lim, int extr )
{
const int NEIGHTBOUR_COUNT_MAX = 50;
@ -367,6 +336,7 @@ TRACK* Locate_Piste_Connectee( TRACK* PtRefSegm, TRACK* pt_base,
{
if( PtSegmN->GetState( BUSY | DELETED ) )
goto suite;
if( PtSegmN == PtRefSegm )
goto suite;
@ -396,6 +366,7 @@ suite:
{
if( PtSegmB->GetState( BUSY | DELETED ) )
goto suite1;
if( PtSegmB == PtRefSegm )
goto suite1;
@ -429,12 +400,14 @@ suite1:
{
if( PtSegmN == pt_lim )
break;
continue;
}
if( PtSegmN == PtRefSegm )
{
if( PtSegmN == pt_lim )
break;
continue;
}
@ -466,16 +439,7 @@ suite1:
*
* The search begins to address start_adresse
*/
TRACK* Locate_Pistes(BOARD* aPcb, TRACK* start_adresse, int MasqueLayer, int typeloc )
{
wxPoint ref_pos = RefPos( typeloc );
return Locate_Pistes( aPcb, start_adresse, ref_pos, MasqueLayer );
}
TRACK* Locate_Pistes(BOARD* aPcb, TRACK* start_adresse, const wxPoint& ref_pos,
int MasqueLayer )
TRACK* Locate_Pistes( BOARD* aPcb, TRACK* start_adresse, const wxPoint& ref_pos, int MasqueLayer )
{
for( TRACK* track = start_adresse; track; track = track->Next() )
{
@ -510,6 +474,7 @@ TRACK* Locate_Pistes(BOARD* aPcb, TRACK* start_adresse, const wxPoint& ref_pos,
return NULL;
}
/*
* 1 - Locate zone area by the mouse.
* 2 - Locate zone area by point
@ -519,14 +484,6 @@ TRACK* Locate_Pistes(BOARD* aPcb, TRACK* start_adresse, const wxPoint& ref_pos,
*
* The search begins to address start_adresse
*/
TRACK* Locate_Zone( TRACK* start_adresse, int layer, int typeloc )
{
wxPoint ref_pos = RefPos( typeloc );
return Locate_Zone( start_adresse, ref_pos, layer );
}
TRACK* Locate_Zone( TRACK* start_adresse, const wxPoint& ref_pos, int layer )
{
for( TRACK* Zone = start_adresse; Zone; Zone = Zone->Next() )
@ -552,8 +509,7 @@ TRACK* Locate_Zone( TRACK* start_adresse, const wxPoint& ref_pos, int layer )
* Pointer to the structure corresponding descr_pad if pad found
* (Good position and good layer).
*/
D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, const wxPoint& ref_pos,
int masque_layer )
D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, const wxPoint& ref_pos, int masque_layer )
{
for( unsigned i=0; i<Pcb->GetPadsCount(); ++i )
{
@ -578,8 +534,7 @@ D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, const wxPoint& ref_pos,
* The segments of track marks with the flag are not DELETED or taken
* into account
*/
TRACK* Fast_Locate_Piste( TRACK* start_adr, TRACK* end_adr,
const wxPoint& ref_pos, int MaskLayer )
TRACK* Fast_Locate_Piste( TRACK* start_adr, TRACK* end_adr, const wxPoint& ref_pos, int MaskLayer )
{
TRACK* PtSegm;
@ -602,6 +557,7 @@ TRACK* Fast_Locate_Piste( TRACK* start_adr, TRACK* end_adr,
return PtSegm;
}
}
if( PtSegm == end_adr )
break;
}
@ -615,8 +571,7 @@ TRACK* Fast_Locate_Piste( TRACK* start_adr, TRACK* end_adr,
* If end_adr = NULL, end search list
* Vias whose parameter has the State or DELETED bit BUSY = 1 are ignored
*/
TRACK* Fast_Locate_Via( TRACK* start_adr, TRACK* end_adr,
const wxPoint& pos, int MaskLayer )
TRACK* Fast_Locate_Via( TRACK* start_adr, TRACK* end_adr, const wxPoint& pos, int MaskLayer )
{
TRACK* PtSegm;
@ -633,6 +588,7 @@ TRACK* Fast_Locate_Via( TRACK* start_adr, TRACK* end_adr,
}
}
}
if( PtSegm == end_adr )
break;
}

View File

@ -100,8 +100,8 @@ bool Project( wxPoint* res, wxPoint on_grid, const TRACK* track )
* @param curpos The initial position, and what to adjust if a change is needed.
* @return bool - true if the position was adjusted magnetically, else false.
*/
bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
int aCurrentTool, wxSize grid, wxPoint on_grid, wxPoint* curpos )
bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame, int aCurrentTool, wxSize grid,
wxPoint on_grid, wxPoint* curpos )
{
bool doCheckNet = g_MagneticPadOption != capture_always && Drc_On;
bool doTrack = false;
@ -110,6 +110,8 @@ bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
TRACK* currTrack = g_CurrentTrackSegment;
BOARD_ITEM* currItem = frame->GetCurItem();
PCB_SCREEN* screen = frame->GetScreen();
wxPoint pos = screen->RefPos( true );
// D( printf( "currTrack=%p currItem=%p currTrack->Type()=%d currItem->Type()=%d\n", currTrack, currItem, currTrack ? currTrack->Type() : 0, currItem ? currItem->Type() : 0 ); )
@ -150,7 +152,8 @@ bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
if( doPad )
{
D_PAD* pad = Locate_Any_Pad( m_Pcb, CURSEUR_OFF_GRILLE, TRUE );
D_PAD* pad = Locate_Any_Pad( m_Pcb, pos, screen->m_Active_Layer );
if( pad )
{
if( doCheckNet && currTrack && currTrack->GetNet() != pad->GetNet() )
@ -164,7 +167,7 @@ bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
// after pads, only track & via tests remain, skip them if not desired
if( doTrack )
{
int layer = ( (PCB_SCREEN*) ActiveScreen )->m_Active_Layer;
int layer = screen->m_Active_Layer;
for( TRACK* via = m_Pcb->m_Track;
via && (via = Locate_Via_Area( via, *curpos, layer )) != NULL;
@ -189,7 +192,8 @@ bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
{
int layer_mask = g_TabOneLayerMask[layer];
TRACK* track = Locate_Pistes( m_Pcb, m_Pcb->m_Track, layer_mask, CURSEUR_OFF_GRILLE );
TRACK* track = Locate_Pistes( m_Pcb, m_Pcb->m_Track, pos, layer_mask );
if( !track || track->Type() != TYPE_TRACK )
{
// D(printf("!currTrack and track=%p not found, layer_mask=0x%X\n", track, layer_mask );)

View File

@ -176,7 +176,6 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father,
if( s_screenModule == NULL )
s_screenModule = new PCB_SCREEN();
SetBaseScreen( s_screenModule );
ActiveScreen = GetScreen();
GetBoard()->SetBoardDesignSettings( &s_ModuleEditorDesignSetting );
GetScreen()->SetCurItem( NULL );
LoadSettings();
@ -249,7 +248,6 @@ WinEDA_ModuleEditFrame::~WinEDA_ModuleEditFrame()
WinEDA_BasePcbFrame* frame = (WinEDA_BasePcbFrame*) GetParent();
frame->m_ModuleEditFrame = NULL;
ActiveScreen = frame->GetScreen();
}
@ -457,11 +455,12 @@ void WinEDA_ModuleEditFrame::Show3D_Frame( wxCommandEvent& event )
}
void WinEDA_ModuleEditFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
void WinEDA_ModuleEditFrame::GeneralControle( wxDC* aDC, wxPoint aPosition )
{
wxRealPoint delta;
wxPoint curpos, oldpos;
wxRealPoint gridSize;
wxPoint oldpos;
int hotkey = 0;
wxPoint pos = aPosition;
if( GetScreen()->IsRefreshReq() )
{
@ -477,45 +476,34 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
return;
}
double scalar = GetScreen()->GetScalingFactor();
curpos = DrawPanel->CursorRealPosition( Mouse );
PutOnGrid( &pos );
oldpos = GetScreen()->m_Curseur;
delta = GetScreen()->GetGridSize();
delta.x *= scalar;
delta.y *= scalar;
if( delta.x == 0 )
delta.x = 1;
if( delta.y == 0 )
delta.y = 1;
gridSize = GetScreen()->GetGridSize();
switch( g_KeyPressed )
{
case WXK_NUMPAD8:
case WXK_UP:
Mouse.y -= wxRound( delta.y );
DrawPanel->MouseTo( Mouse );
pos.y -= wxRound( gridSize.y );
DrawPanel->MoveCursor( pos );
break;
case WXK_NUMPAD2:
case WXK_DOWN:
Mouse.y += wxRound( delta.y );
DrawPanel->MouseTo( Mouse );
pos.y += wxRound( gridSize.y );
DrawPanel->MoveCursor( pos );
break;
case WXK_NUMPAD4:
case WXK_LEFT:
Mouse.x -= wxRound( delta.x );
DrawPanel->MouseTo( Mouse );
pos.x -= wxRound( gridSize.x );
DrawPanel->MoveCursor( pos );
break;
case WXK_NUMPAD6:
case WXK_RIGHT:
Mouse.x += wxRound( delta.x );
DrawPanel->MouseTo( Mouse );
pos.x += wxRound( gridSize.x );
DrawPanel->MoveCursor( pos );
break;
default:
@ -523,27 +511,25 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
break;
}
GetScreen()->m_Curseur = curpos;
PutOnGrid( &GetScreen()->m_Curseur );
GetScreen()->m_Curseur = pos;
if( oldpos != GetScreen()->m_Curseur )
{
curpos = GetScreen()->m_Curseur;
pos = GetScreen()->m_Curseur;
GetScreen()->m_Curseur = oldpos;
DrawPanel->CursorOff( DC );
GetScreen()->m_Curseur = curpos;
DrawPanel->CursorOn( DC );
DrawPanel->CursorOff( aDC );
GetScreen()->m_Curseur = pos;
DrawPanel->CursorOn( aDC );
if( DrawPanel->ManageCurseur )
{
DrawPanel->ManageCurseur( DrawPanel, DC, true );
DrawPanel->ManageCurseur( DrawPanel, aDC, true );
}
}
if( hotkey )
{
OnHotKey( DC, hotkey, NULL );
OnHotKey( aDC, hotkey, NULL );
}
if( GetScreen()->IsRefreshReq() )
@ -551,6 +537,7 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
DrawPanel->Refresh();
wxSafeYield();
}
SetToolbars();
UpdateStatusBar();
}

View File

@ -1039,12 +1039,14 @@ BOARD_ITEM* LocateLockPoint( BOARD* Pcb, wxPoint pos, int LayerMask )
for( MODULE* module = Pcb->m_Modules; module; module = module->Next() )
{
D_PAD* pad = Locate_Pads( module, pos, LayerMask );
if( pad )
return pad;
}
/* No pad has been located so check for a segment of the trace. */
TRACK* ptsegm = Fast_Locate_Piste( Pcb->m_Track, NULL, pos, LayerMask );
if( ptsegm == NULL )
ptsegm = Locate_Pistes( Pcb, Pcb->m_Track, pos, LayerMask );

View File

@ -465,7 +465,6 @@ void WinEDA_PcbFrame::OnCloseWindow( wxCloseEvent& Event )
// do not show the window because ScreenPcb will be deleted and we do not
// want any paint event
Show( false );
ActiveScreen = ScreenPcb;
Destroy();
}

View File

@ -112,7 +112,6 @@ bool WinEDA_App::OnInit()
}
ScreenPcb = new PCB_SCREEN();
ActiveScreen = ScreenPcb;
// read current setup and reopen last directory if no filename to open in command line
bool reopenLastUsedDirectory = argc == 1;

View File

@ -106,13 +106,10 @@ void BOARD_PRINTOUT_CONTROLER::GetPageInfo( int* minPage, int* maxPage,
}
/****************************************/
void BOARD_PRINTOUT_CONTROLER::DrawPage()
/****************************************/
/*
* This is the real print function: print the active screen
*/
void BOARD_PRINTOUT_CONTROLER::DrawPage()
{
int tmpzoom;
wxPoint tmp_startvisu;
@ -122,21 +119,21 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
double userscale;
double DrawZoom = 1;
wxDC* dc = GetDC();
BASE_SCREEN* screen = m_Parent->GetBaseScreen();
bool printMirror = m_PrintParams.m_PrintMirror;
wxBusyCursor dummy;
/* Save old draw scale and draw offset */
tmp_startvisu = ActiveScreen->m_StartVisu;
tmpzoom = ActiveScreen->GetZoom();
old_org = ActiveScreen->m_DrawOrg;
tmp_startvisu = screen->m_StartVisu;
tmpzoom = screen->GetZoom();
old_org = screen->m_DrawOrg;
/* Change draw scale and offset to draw the whole page */
ActiveScreen->SetScalingFactor( DrawZoom );
ActiveScreen->m_DrawOrg.x = ActiveScreen->m_DrawOrg.y = 0;
ActiveScreen->m_StartVisu.x = ActiveScreen->m_StartVisu.y = 0;
screen->SetScalingFactor( DrawZoom );
screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0;
screen->m_StartVisu.x = screen->m_StartVisu.y = 0;
SheetSize = ActiveScreen->m_CurrentSheetDesc->m_Size; // size in 1/1000 inch
SheetSize = screen->m_CurrentSheetDesc->m_Size; // size in 1/1000 inch
SheetSize.x *= m_Parent->m_InternalUnits / 1000;
SheetSize.y *= m_Parent->m_InternalUnits / 1000; // size in internal units
@ -153,8 +150,10 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
mv_offset.y = SheetSize.y / 2;
brd_BBox.Move( mv_offset );
}
/* Compute the PCB size in internal units*/
userscale = m_PrintParams.m_PrintScale;
if( userscale == 0 ) // fit in page
{
int extra_margin = 4000*2; // Margin = 4000 units pcb = 0.4 inch
@ -228,7 +227,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
DrawOffset.y -= PlotAreaSizeInUserUnits.y / 2;
}
ActiveScreen->m_DrawOrg = DrawOffset;
screen->m_DrawOrg = DrawOffset;
GRResetPenAndBrush( dc );
if( m_PrintParams.m_Print_Black_and_White )
@ -248,7 +247,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
int bg_color = g_DrawBgColor;
if( m_PrintParams.m_Print_Sheet_Ref )
m_Parent->TraceWorkSheet( dc, ActiveScreen, m_PrintParams.m_PenDefaultSize );
m_Parent->TraceWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize );
if( printMirror )
{
@ -279,7 +278,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
if( userscale <= 1.0 )
DrawOffset.y += pcb_centre.y - (ysize / 2);
dc->SetLogicalOrigin( ActiveScreen->m_DrawOrg.x, ActiveScreen->m_DrawOrg.y );
dc->SetLogicalOrigin( screen->m_DrawOrg.x, screen->m_DrawOrg.y );
panel->m_ClipBox.SetOrigin( wxPoint( -MAX_VALUE/2, -MAX_VALUE/2 ) );
}
@ -306,7 +305,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
GRForceBlackPen( false );
ActiveScreen->m_StartVisu = tmp_startvisu;
ActiveScreen->m_DrawOrg = old_org;
ActiveScreen->SetZoom( tmpzoom );
screen->m_StartVisu = tmp_startvisu;
screen->m_DrawOrg = old_org;
screen->SetZoom( tmpzoom );
}

View File

@ -77,23 +77,20 @@ TRACK* Locate_Via( BOARD* Pcb, const wxPoint& pos, int layer = -1 );
* @param aLayer The layer to match, pass -1 for a don't care.
* @return TRACK* - actually a SEGVIA* if found, else NULL.
*/
TRACK* Locate_Via_Area( TRACK* aStart,
const wxPoint& aPos,
int aLayer = -1 );
TRACK* Locate_Via_Area( TRACK* aStart, const wxPoint& aPos, int aLayer = ALL_LAYERS );
/* Locates the center through the point x, y, on layer data
* by masquelayer.
* Search is done to address start_adr has end_adr (not included)
*/
TRACK* Fast_Locate_Via( TRACK* start_adr, TRACK* end_adr,
const wxPoint& pos, int masquelayer );
TRACK* Fast_Locate_Via( TRACK* start_adr, TRACK* end_adr, const wxPoint& pos, int masquelayer );
/* Locates the center through the point x, y, on layer data
* by masquelayer.
* Search is done to address start_adr has end_adr (not included)
*/
TRACK* Fast_Locate_Piste( TRACK* start_adr, TRACK* end_adr,
const wxPoint& ref_pos, int masquelayer );
TRACK* Fast_Locate_Piste( TRACK* start_adr, TRACK* end_adr,
const wxPoint& ref_pos, int masquelayer );
/* Search for segment connected to the segment edge by
* Ptr_piste:
@ -102,8 +99,7 @@ TRACK* Fast_Locate_Piste( TRACK* start_adr, TRACK* end_adr,
* The search is done only on the ends of segments
* The search is limited to the area [... pt_base] pt_lim.
*/
TRACK* Locate_Piste_Connectee( TRACK* ptr_piste, TRACK* pt_base,
TRACK* pt_lim, int extr );
TRACK* Locate_Piste_Connectee( TRACK* ptr_piste, TRACK* pt_base, TRACK* pt_lim, int extr );
/*
* 1 - Locate segment of track leading from the mouse.
@ -114,9 +110,7 @@ TRACK* Locate_Piste_Connectee( TRACK* ptr_piste, TRACK* pt_base,
*
* The search begins to address start_adresse
*/
TRACK* Locate_Pistes( BOARD* aPcb, TRACK* start_adresse, int layer, int typeloc );
TRACK* Locate_Pistes( BOARD* aPcb, TRACK* start_adresse,
const wxPoint& ref_pos, int layer );
TRACK* Locate_Pistes( BOARD* aPcb, TRACK* start_adresse, const wxPoint& ref_pos, int layer );
/* Locate pad connected to the beginning or end of a segment
* Input: pointer to the segment, and flag = START or END
@ -124,8 +118,7 @@ TRACK* Locate_Pistes( BOARD* aPcb, TRACK* start_adresse,
* A pointer to the description of the patch if pad was found.
* NULL pointer if pad was not found.
*/
D_PAD* Locate_Pad_Connecte( BOARD* aPcb, TRACK* ptr_segment, int extr );
D_PAD* Locate_Pad_Connecte( BOARD* aPcb, TRACK* ptr_segment, int extr );
/*
* Locate pad pointed to by the coordinate ref_pX,, ref_pY or the current
@ -137,12 +130,7 @@ D_PAD* Locate_Pad_Connecte( BOARD* aPcb, TRACK* ptr_segment, int extr );
* Pointer to the pad if found
* NULL pointer if pad not found
*/
D_PAD* Locate_Any_Pad( BOARD* aPcb,
int typeloc,
bool OnlyCurrentLayer = FALSE );
D_PAD* Locate_Any_Pad( BOARD* aPcb,
const wxPoint& ref_pos,
bool OnlyCurrentLayer = FALSE );
D_PAD* Locate_Any_Pad( BOARD* aPcb, const wxPoint& aPosition, int aLayerMask = ALL_LAYERS );
/* Locate pad pointed to by the coordinate ref_pX,, ref_pY or the cursor
* position of the current footprint.
@ -152,11 +140,11 @@ D_PAD* Locate_Any_Pad( BOARD* aPcb,
* Returns:
* A pointer to the pad if found otherwise NULL.
*/
D_PAD* Locate_Pads( MODULE* Module, int layer, int typeloc );
D_PAD* Locate_Pads( MODULE* Module, const wxPoint& ref_pos, int layer );
D_PAD* Locate_Pads( MODULE* Module, const wxPoint& ref_pos, int layer );
/* Locate a footprint by its bounding rectangle. */
MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc );
MODULE* Locate_Prefered_Module( BOARD* aPcb, const wxPoint& aPosition, int aActiveLayer,
bool aVisibleOnly, bool aIgnoreLocked = false );
/* Locate a pad pointed to by the cursor on the footprint.
* Module.
@ -165,12 +153,12 @@ MODULE* Locate_Prefered_Module( BOARD* Pcb, int typeloc );
* Returns:
* A pointer to the pad if found otherwise NULL.
*/
D_PAD* Locate_Pads( MODULE* Module, int typeloc );
D_PAD* Locate_Pads( MODULE* Module, int typeloc );
/* Locate a trace segment at the current cursor position.
* The search begins to address start_adresse.
*/
TRACK* Locate_Pistes( TRACK* start_adresse, int typeloc );
TRACK* Locate_Pistes( TRACK* start_adresse, int typeloc );
DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int LayerSearch, int typeloc );
@ -181,9 +169,7 @@ DRAWSEGMENT* Locate_Segment_Pcb( BOARD* Pcb, int LayerSearch, int typeloc );
* Returns:
* Pointer to the pad if found, otherwise NULL.
*/
D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb,
const wxPoint& ref_pos,
int layer );
D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, const wxPoint& ref_pos, int layer );
/*
* 1 - Locate trace segment at the current cursor position.
@ -193,16 +179,13 @@ D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb,
*
* The search begins to address start_adresse
*/
TRACK* Locate_Zone( TRACK* start_adresse, int layer, int typeloc );
TRACK* Locate_Zone( TRACK* start_adresse,
const wxPoint& ref_pos,
int layer );
TRACK* Locate_Zone( TRACK* start_adresse, const wxPoint& ref_pos, int layer );
/*************/
/* MODULES.C */
/*************/
int ChangeSideNumLayer( int oldlayer );
int ChangeSideNumLayer( int oldlayer );
void DrawModuleOutlines( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* module );
void Montre_Position_Empreinte( EDA_DRAW_PANEL* panel, wxDC* DC, bool erase );
@ -213,12 +196,12 @@ void Montre_Position_Empreinte( EDA_DRAW_PANEL* panel, wxDC* DC, bool erase );
TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack, int aLayer, const wxPoint& aRef );
void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* panel, wxDC* DC, bool erase );
void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* panel, wxDC* DC, bool erase );
/* Determine coordinate for a segment direction of 0, 90 or 45 degrees,
* depending on it's position from the origin (ox, oy) and \a aPosiition..
*/
void Calcule_Coord_Extremite_45( const wxPoint& aPosition, int ox, int oy, int* fx, int* fy );
void Calcule_Coord_Extremite_45( const wxPoint& aPosition, int ox, int oy, int* fx, int* fy );
/*****************/

View File

@ -1230,19 +1230,17 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC )
int dx0, dy0, dx1, dy1;
int marge, via_marge;
EDA_DRAW_PANEL* panel = pcbframe->DrawPanel;
PCB_SCREEN* screen = pcbframe->GetScreen();
marge = s_Clearance +
( pcbframe->GetBoard()->GetCurrentTrackWidth() / 2 );
marge = s_Clearance + ( pcbframe->GetBoard()->GetCurrentTrackWidth() / 2 );
via_marge = s_Clearance + ( pcbframe->GetBoard()->GetCurrentViaSize() / 2 );
dx1 = g_CurrentTrackSegment->m_End.x - g_CurrentTrackSegment->m_Start.x;
dy1 = g_CurrentTrackSegment->m_End.y - g_CurrentTrackSegment->m_Start.y;
/* Place on center of pad if off grid. */
dx0 = pt_cur_ch->m_PadStart->GetPosition().x -
g_CurrentTrackSegment->m_Start.x;
dy0 = pt_cur_ch->m_PadStart->GetPosition().y -
g_CurrentTrackSegment->m_Start.y;
dx0 = pt_cur_ch->m_PadStart->GetPosition().x - g_CurrentTrackSegment->m_Start.x;
dy0 = pt_cur_ch->m_PadStart->GetPosition().y - g_CurrentTrackSegment->m_Start.y;
/* If aligned, change the origin point. */
if( abs( dx0 * dy1 ) == abs( dx1 * dy0 ) )
@ -1259,13 +1257,15 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC )
g_CurrentTrackList.PushBack( newTrack );
}
g_FirstTrackSegment->start = Locate_Pad_Connecte(
pcbframe->GetBoard(), g_FirstTrackSegment, START );
g_FirstTrackSegment->start = Locate_Pad_Connecte( pcbframe->GetBoard(),
g_FirstTrackSegment, START );
if( g_FirstTrackSegment->start )
g_FirstTrackSegment->SetState( BEGIN_ONPAD, ON );
g_CurrentTrackSegment->end = Locate_Pad_Connecte(
pcbframe->GetBoard(), g_CurrentTrackSegment, END );
g_CurrentTrackSegment->end = Locate_Pad_Connecte( pcbframe->GetBoard(),
g_CurrentTrackSegment, END );
if( g_CurrentTrackSegment->end )
g_CurrentTrackSegment->SetState( END_ONPAD, ON );
@ -1284,8 +1284,7 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC )
// Put entire new current segment list in BOARD
TRACK* track;
TRACK* insertBeforeMe =
g_CurrentTrackSegment->GetBestInsertPoint( pcbframe->GetBoard() );
TRACK* insertBeforeMe = g_CurrentTrackSegment->GetBestInsertPoint( pcbframe->GetBoard() );
while( ( track = g_CurrentTrackList.PopFront() ) != NULL )
{
@ -1296,5 +1295,5 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC )
pcbframe->test_1_net_connexion( DC, netcode );
ActiveScreen->SetModify();
screen->SetModify();
}

View File

@ -42,7 +42,6 @@ void WinEDA_ModuleEditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
if( !GetBoard() || !screen )
return;
ActiveScreen = screen;
GRSetDrawMode( DC, GR_COPY );
DrawPanel->DrawBackGround( DC );
@ -82,7 +81,6 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
if( !GetBoard() || !screen )
return;
ActiveScreen = screen;
GRSetDrawMode( DC, GR_COPY );
DrawPanel->DrawBackGround( DC );