Commit 85ae0373 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Global variable removal and coordinate fixes.

* ActiveScreen global variable is gone, yeah!
* Use drawing coordinates instead of screen coordinates when calling
  GeneralControle().
parent 6f9fc8d2
...@@ -13,8 +13,6 @@ ...@@ -13,8 +13,6 @@
#include "id.h" #include "id.h"
BASE_SCREEN* ActiveScreen = NULL;
#define CURSOR_SIZE 12 /* size of the cross cursor. */ #define CURSOR_SIZE 12 /* size of the cross cursor. */
......
...@@ -285,22 +285,19 @@ wxPoint EDA_DRAW_PANEL::GetScreenCenterLogicalPosition() ...@@ -285,22 +285,19 @@ wxPoint EDA_DRAW_PANEL::GetScreenCenterLogicalPosition()
*/ */
void EDA_DRAW_PANEL::MouseToCursorSchema() void EDA_DRAW_PANEL::MouseToCursorSchema()
{ {
wxPoint Mouse = CursorScreenPosition(); MoveCursor( GetScreen()->m_Curseur );
MouseTo( Mouse );
} }
/** Move the mouse cursor to the position "Mouse" void EDA_DRAW_PANEL::MoveCursor( const wxPoint& aPosition )
* @param Mouse = mouse cursor position, in pixels units
*/
void EDA_DRAW_PANEL::MouseTo( const wxPoint& Mouse )
{ {
int x, y, xPpu, yPpu; int x, y, xPpu, yPpu;
wxPoint screenPos, drawingPos; wxPoint screenPos, drawingPos;
wxRect clientRect( wxPoint( 0, 0 ), GetClientSize() ); 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. // Scroll if the requested mouse position cursor is outside the drawing area.
if( !clientRect.Contains( screenPos ) ) if( !clientRect.Contains( screenPos ) )
...@@ -309,7 +306,7 @@ void EDA_DRAW_PANEL::MouseTo( const wxPoint& Mouse ) ...@@ -309,7 +306,7 @@ void EDA_DRAW_PANEL::MouseTo( const wxPoint& Mouse )
GetScrollPixelsPerUnit( &xPpu, &yPpu ); GetScrollPixelsPerUnit( &xPpu, &yPpu );
CalcUnscrolledPosition( screenPos.x, screenPos.y, &drawingPos.x, &drawingPos.y ); 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)" ), wxT( "rectangle(%d, %d, %d, %d) view(%d, %d)" ),
screenPos.x, screenPos.y, clientRect.x, clientRect.y, screenPos.x, screenPos.y, clientRect.x, clientRect.y,
clientRect.width, clientRect.height, x, y ); clientRect.width, clientRect.height, x, y );
...@@ -326,7 +323,7 @@ void EDA_DRAW_PANEL::MouseTo( const wxPoint& Mouse ) ...@@ -326,7 +323,7 @@ void EDA_DRAW_PANEL::MouseTo( const wxPoint& Mouse )
Scroll( x, y ); Scroll( x, y );
CalcScrolledPosition( drawingPos.x, drawingPos.y, &screenPos.x, &screenPos.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 ); screenPos.x, screenPos.y, x, y );
} }
...@@ -1007,7 +1004,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) ...@@ -1007,7 +1004,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
} }
/* Calling the general function on mouse changes (and pseudo key commands) */ /* 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 : */ /* Control of block commands : */
...@@ -1221,10 +1218,11 @@ void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event ) ...@@ -1221,10 +1218,11 @@ void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event )
} }
/* Some key commands use the current mouse position: refresh it */ /* 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. // 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 ); m_Parent->GeneralControle( &DC, pos );
......
...@@ -70,8 +70,6 @@ static void GRSRect( EDA_Rect* aClipBox, wxDC* aDC, int x1, int y1, ...@@ -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 int GRLastMoveToX, GRLastMoveToY;
static bool s_ForceBlackPen; /* if true: draws in black instead of static bool s_ForceBlackPen; /* if true: draws in black instead of
* color for printing. */ * color for printing. */
......
...@@ -52,17 +52,18 @@ void EDA_DRAW_FRAME::RedrawScreen( bool aWarpPointer ) ...@@ -52,17 +52,18 @@ void EDA_DRAW_FRAME::RedrawScreen( bool aWarpPointer )
void EDA_DRAW_FRAME::PutOnGrid( wxPoint* aCoord , wxRealPoint* aGridSize ) void EDA_DRAW_FRAME::PutOnGrid( wxPoint* aCoord , wxRealPoint* aGridSize )
{ {
wxRealPoint grid_size; wxRealPoint grid_size;
if( aGridSize ) if( aGridSize )
grid_size = *aGridSize; grid_size = *aGridSize;
else else
grid_size = GetBaseScreen()->GetGridSize(); grid_size = GetBaseScreen()->GetGridSize();
const wxPoint& grid_origin = GetBaseScreen()->GetGridOrigin(); 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 ); int tmp = wxRound( (aCoord->x - offset) / grid_size.x );
aCoord->x = wxRound( tmp * grid_size.x + offset ); 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 ); tmp = wxRound( (aCoord->y - offset) / grid_size.y );
aCoord->y = wxRound ( tmp * grid_size.y + offset ); aCoord->y = wxRound ( tmp * grid_size.y + offset );
} }
......
...@@ -390,27 +390,19 @@ void DISPLAY_FOOTPRINTS_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) ...@@ -390,27 +390,19 @@ void DISPLAY_FOOTPRINTS_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
SetToolbars(); SetToolbars();
} }
void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* DC, wxPoint Mouse ) void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* aDC, wxPoint aPosition )
{ {
wxRealPoint delta; wxRealPoint gridSize;
int flagcurseur = 0; int flagcurseur = 0;
wxPoint curpos, oldpos; wxPoint oldpos;
double scalar = GetScreen()->GetScalingFactor(); wxPoint pos = aPosition;
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetEventObject( this ); cmd.SetEventObject( this );
curpos = DrawPanel->CursorRealPosition( Mouse ); PutOnGrid( &pos );
oldpos = GetScreen()->m_Curseur; oldpos = GetScreen()->m_Curseur;
gridSize = GetScreen()->GetGridSize();
delta = GetScreen()->GetGridSize();
delta.x *= scalar;
delta.y *= scalar;
if( delta.x <= 0 )
delta.x = 1;
if( delta.y <= 0 )
delta.y = 1;
switch( g_KeyPressed ) switch( g_KeyPressed )
{ {
...@@ -418,14 +410,14 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -418,14 +410,14 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* DC, wxPoint Mouse )
cmd.SetId( ID_POPUP_ZOOM_IN ); cmd.SetId( ID_POPUP_ZOOM_IN );
GetEventHandler()->ProcessEvent( cmd ); GetEventHandler()->ProcessEvent( cmd );
flagcurseur = 2; flagcurseur = 2;
curpos = GetScreen()->m_Curseur; pos = GetScreen()->m_Curseur;
break; break;
case WXK_F2: case WXK_F2:
cmd.SetId( ID_POPUP_ZOOM_OUT ); cmd.SetId( ID_POPUP_ZOOM_OUT );
GetEventHandler()->ProcessEvent( cmd ); GetEventHandler()->ProcessEvent( cmd );
flagcurseur = 2; flagcurseur = 2;
curpos = GetScreen()->m_Curseur; pos = GetScreen()->m_Curseur;
break; break;
case WXK_F3: case WXK_F3:
...@@ -438,14 +430,14 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -438,14 +430,14 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* DC, wxPoint Mouse )
cmd.SetId( ID_POPUP_ZOOM_CENTER ); cmd.SetId( ID_POPUP_ZOOM_CENTER );
GetEventHandler()->ProcessEvent( cmd ); GetEventHandler()->ProcessEvent( cmd );
flagcurseur = 2; flagcurseur = 2;
curpos = GetScreen()->m_Curseur; pos = GetScreen()->m_Curseur;
break; break;
case WXK_HOME: case WXK_HOME:
cmd.SetId( ID_ZOOM_PAGE ); cmd.SetId( ID_ZOOM_PAGE );
GetEventHandler()->ProcessEvent( cmd ); GetEventHandler()->ProcessEvent( cmd );
flagcurseur = 2; flagcurseur = 2;
curpos = GetScreen()->m_Curseur; pos = GetScreen()->m_Curseur;
break; break;
case ' ': case ' ':
...@@ -454,32 +446,30 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -454,32 +446,30 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* DC, wxPoint Mouse )
case WXK_NUMPAD8: /* cursor moved up */ case WXK_NUMPAD8: /* cursor moved up */
case WXK_UP: case WXK_UP:
Mouse.y -= wxRound(delta.y); pos.y -= wxRound( gridSize.y );
DrawPanel->MouseTo( Mouse ); DrawPanel->MoveCursor( pos );
break; break;
case WXK_NUMPAD2: /* cursor moved down */ case WXK_NUMPAD2: /* cursor moved down */
case WXK_DOWN: case WXK_DOWN:
Mouse.y += wxRound(delta.y); pos.y += wxRound( gridSize.y );
DrawPanel->MouseTo( Mouse ); DrawPanel->MoveCursor( pos );
break; break;
case WXK_NUMPAD4: /* cursor moved left */ case WXK_NUMPAD4: /* cursor moved left */
case WXK_LEFT: case WXK_LEFT:
Mouse.x -= wxRound(delta.x); pos.x -= wxRound( gridSize.x );
DrawPanel->MouseTo( Mouse ); DrawPanel->MoveCursor( pos );
break; break;
case WXK_NUMPAD6: /* cursor moved right */ case WXK_NUMPAD6: /* cursor moved right */
case WXK_RIGHT: case WXK_RIGHT:
Mouse.x += wxRound(delta.x); pos.x += wxRound( gridSize.x );
DrawPanel->MouseTo( Mouse ); DrawPanel->MoveCursor( pos );
break; break;
} }
GetScreen()->m_Curseur = curpos; GetScreen()->m_Curseur = pos;
/* Put cursor on grid */
PutOnGrid( &GetScreen()->m_Curseur );
if( GetScreen()->IsRefreshReq() ) if( GetScreen()->IsRefreshReq() )
{ {
...@@ -491,17 +481,16 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -491,17 +481,16 @@ void DISPLAY_FOOTPRINTS_FRAME::GeneralControle( wxDC* DC, wxPoint Mouse )
{ {
if( flagcurseur != 2 ) if( flagcurseur != 2 )
{ {
curpos = GetScreen()->m_Curseur; pos = GetScreen()->m_Curseur;
GetScreen()->m_Curseur = oldpos; GetScreen()->m_Curseur = oldpos;
DrawPanel->CursorOff( DC ); DrawPanel->CursorOff( aDC );
GetScreen()->m_Curseur = pos;
GetScreen()->m_Curseur = curpos; DrawPanel->CursorOn( aDC );
DrawPanel->CursorOn( DC );
} }
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
{ {
DrawPanel->ManageCurseur( DrawPanel, DC, 0 ); DrawPanel->ManageCurseur( DrawPanel, aDC, 0 );
} }
} }
......
...@@ -91,12 +91,11 @@ void DISPLAY_FOOTPRINTS_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -91,12 +91,11 @@ void DISPLAY_FOOTPRINTS_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
if( !GetBoard() ) if( !GetBoard() )
return; return;
ActiveScreen = (PCB_SCREEN*) GetScreen();
DrawPanel->DrawBackGround( DC ); DrawPanel->DrawBackGround( DC );
GetBoard()->Draw( DrawPanel, DC, GR_COPY ); GetBoard()->Draw( DrawPanel, DC, GR_COPY );
MODULE* Module = GetBoard()->m_Modules; MODULE* Module = GetBoard()->m_Modules;
if ( Module ) if ( Module )
Module->DisplayInfo( this ); Module->DisplayInfo( this );
......
This diff is collapsed.
...@@ -222,7 +222,7 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere ...@@ -222,7 +222,7 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere
DrawPanel->CursorOff( &dc ); DrawPanel->CursorOff( &dc );
if( mouseWarp ) if( mouseWarp )
DrawPanel->MouseTo( curpos ); DrawPanel->MoveCursor( curpos );
EXCHG( old_cursor_position, sheet->LastScreen()->m_Curseur ); EXCHG( old_cursor_position, sheet->LastScreen()->m_Curseur );
......
...@@ -13,11 +13,14 @@ GERBER_DRAW_ITEM* WinEDA_GerberFrame::GerberGeneralLocateAndDisplay() ...@@ -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; wxRealPoint gridSize;
wxPoint curpos, oldpos; wxPoint oldpos;
int hotkey = 0; int hotkey = 0;
wxPoint pos = aPosition;
PutOnGrid( &pos );
if( GetScreen()->IsRefreshReq() ) if( GetScreen()->IsRefreshReq() )
{ {
...@@ -34,45 +37,33 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -34,45 +37,33 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
return; return;
} }
double scalar = GetScreen()->GetScalingFactor();
curpos = DrawPanel->CursorRealPosition( Mouse );
oldpos = GetScreen()->m_Curseur; oldpos = GetScreen()->m_Curseur;
gridSize = GetScreen()->GetGridSize();
delta = GetScreen()->GetGridSize();
delta.x *= scalar;
delta.y *= scalar;
if( delta.x == 0 )
delta.x = 1;
if( delta.y == 0 )
delta.y = 1;
switch( g_KeyPressed ) switch( g_KeyPressed )
{ {
case WXK_NUMPAD8: case WXK_NUMPAD8:
case WXK_UP: case WXK_UP:
Mouse.y -= wxRound(delta.y); pos.y -= wxRound( gridSize.y );
DrawPanel->MouseTo( Mouse ); DrawPanel->MoveCursor( pos );
break; break;
case WXK_NUMPAD2: case WXK_NUMPAD2:
case WXK_DOWN: case WXK_DOWN:
Mouse.y += wxRound(delta.y); pos.y += wxRound( gridSize.y );
DrawPanel->MouseTo( Mouse ); DrawPanel->MoveCursor( pos );
break; break;
case WXK_NUMPAD4: case WXK_NUMPAD4:
case WXK_LEFT: case WXK_LEFT:
Mouse.x -= wxRound(delta.x); pos.x -= wxRound( gridSize.x );
DrawPanel->MouseTo( Mouse ); DrawPanel->MoveCursor( pos );
break; break;
case WXK_NUMPAD6: case WXK_NUMPAD6:
case WXK_RIGHT: case WXK_RIGHT:
Mouse.x += wxRound(delta.x); pos.x += wxRound( gridSize.x );
DrawPanel->MouseTo( Mouse ); DrawPanel->MoveCursor( pos );
break; break;
default: default:
...@@ -80,28 +71,25 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -80,28 +71,25 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
break; break;
} }
GetScreen()->m_Curseur = curpos; GetScreen()->m_Curseur = pos;
PutOnGrid( &GetScreen()->m_Curseur );
if( oldpos != GetScreen()->m_Curseur ) if( oldpos != GetScreen()->m_Curseur )
{ {
curpos = GetScreen()->m_Curseur; pos = GetScreen()->m_Curseur;
GetScreen()->m_Curseur = oldpos; GetScreen()->m_Curseur = oldpos;
DrawPanel->CursorOff( DC ); DrawPanel->CursorOff( aDC );
GetScreen()->m_Curseur = pos;
GetScreen()->m_Curseur = curpos; DrawPanel->CursorOn( aDC );
DrawPanel->CursorOn( DC );
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
{ {
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE ); DrawPanel->ManageCurseur( DrawPanel, aDC, TRUE );
} }
} }
if( hotkey ) if( hotkey )
{ {
OnHotKey( DC, hotkey, NULL ); OnHotKey( aDC, hotkey, NULL );
} }
if( GetScreen()->IsRefreshReq() ) if( GetScreen()->IsRefreshReq() )
......
...@@ -229,7 +229,13 @@ public: ...@@ -229,7 +229,13 @@ public:
wxPoint GetScreenCenterLogicalPosition(); wxPoint GetScreenCenterLogicalPosition();
void MouseToCursorSchema(); 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 */ /* Cursor functions */
/** /**
......
...@@ -190,9 +190,6 @@ extern UserUnitType g_UserUnit; ///< display units ...@@ -190,9 +190,6 @@ extern UserUnitType g_UserUnit; ///< display units
/* Draw color for moving objects: */ /* Draw color for moving objects: */
extern int g_GhostColor; extern int g_GhostColor;
/* Current used screen: (not used in eeshema)*/
extern BASE_SCREEN* ActiveScreen;
/* COMMON.CPP */ /* COMMON.CPP */
......
...@@ -160,7 +160,7 @@ public: ...@@ -160,7 +160,7 @@ public:
/** /**
* Function PrintPage , virtual * Function PrintPage , virtual
* used to print a page * 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 aDC = wxDC given by the calling print function
* @param aPrintMaskLayer = a 32 bits mask: bit n = 1 -> layer n is printed * @param aPrintMaskLayer = a 32 bits mask: bit n = 1 -> layer n is printed
* @param aPrintMirrorMode = true to plot mirrored * @param aPrintMirrorMode = true to plot mirrored
......
...@@ -365,7 +365,18 @@ public: ...@@ -365,7 +365,18 @@ public:
virtual void OnSelectGrid( wxCommandEvent& event ); virtual void OnSelectGrid( wxCommandEvent& event );
virtual void OnSelectZoom( 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 ); virtual void OnSize( wxSizeEvent& event );
void OnEraseBackground( wxEraseEvent& SizeEvent ); void OnEraseBackground( wxEraseEvent& SizeEvent );
...@@ -515,7 +526,7 @@ public: ...@@ -515,7 +526,7 @@ public:
/** Virtual function PrintPage /** Virtual function PrintPage
* used to print a page * 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 aDC = wxDC given by the calling print function
* @param aPrintMask = not used here * @param aPrintMask = not used here
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode) * @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
......
...@@ -18,15 +18,14 @@ ...@@ -18,15 +18,14 @@
extern bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame, extern bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
int aCurrentTool, wxSize grid, wxPoint on_grid, wxPoint* curpos ); int aCurrentTool, wxSize grid, wxPoint on_grid, wxPoint* curpos );
/*************************************************************************************/
static BOARD_ITEM* AllAreModulesAndReturnSmallestIfSo( GENERAL_COLLECTOR* aCollector )
/*************************************************************************************/
/** /**
* Function AllAreModulesAndReturnSmallestIfSo * Function AllAreModulesAndReturnSmallestIfSo
* tests that all items in the collection are MODULEs and if so, returns the * tests that all items in the collection are MODULEs and if so, returns the
* smallest MODULE. * smallest MODULE.
* @return BOARD_ITEM* - The smallest or NULL. * @return BOARD_ITEM* - The smallest or NULL.
*/ */
static BOARD_ITEM* AllAreModulesAndReturnSmallestIfSo( GENERAL_COLLECTOR* aCollector )
{ {
int count = aCollector->GetCount(); int count = aCollector->GetCount();
...@@ -61,9 +60,7 @@ static BOARD_ITEM* AllAreModulesAndReturnSmallestIfSo( GENERAL_COLLECTOR* aColle ...@@ -61,9 +60,7 @@ static BOARD_ITEM* AllAreModulesAndReturnSmallestIfSo( GENERAL_COLLECTOR* aColle
} }
/****************************************************************************/
BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode ) BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )
/****************************************************************************/
{ {
BOARD_ITEM* item; BOARD_ITEM* item;
...@@ -133,6 +130,7 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode ) ...@@ -133,6 +130,7 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )
for( int ii = 0; ii < m_Collector->GetCount(); ii++ ) for( int ii = 0; ii < m_Collector->GetCount(); ii++ )
{ {
item = (*m_Collector)[ii]; item = (*m_Collector)[ii];
if( item->Type() != TYPE_ZONE ) if( item->Type() != TYPE_ZONE )
continue; continue;
...@@ -151,7 +149,9 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode ) ...@@ -151,7 +149,9 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )
item = (*m_Collector)[0]; item = (*m_Collector)[0];
SetCurItem( item ); 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 else if( m_Collector->GetCount() == 2
&& ( (*m_Collector)[0]->Type() == TYPE_PAD || (*m_Collector)[0]->Type() == && ( (*m_Collector)[0]->Type() == TYPE_PAD || (*m_Collector)[0]->Type() ==
TYPE_TEXTE_MODULE ) TYPE_TEXTE_MODULE )
...@@ -173,12 +173,14 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode ) ...@@ -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 */ /* Give a title to the selection menu. This is also a cancel menu item */
wxMenuItem * item_title = new wxMenuItem(&itemMenu, -1, _( "Selection Clarification" ) ); wxMenuItem * item_title = new wxMenuItem(&itemMenu, -1, _( "Selection Clarification" ) );
#ifdef __WINDOWS__ #ifdef __WINDOWS__
wxFont bold_font(*wxNORMAL_FONT); wxFont bold_font(*wxNORMAL_FONT);
bold_font.SetWeight(wxFONTWEIGHT_BOLD); bold_font.SetWeight(wxFONTWEIGHT_BOLD);
bold_font.SetStyle( wxFONTSTYLE_ITALIC); bold_font.SetStyle( wxFONTSTYLE_ITALIC);
item_title->SetFont(bold_font); item_title->SetFont(bold_font);
#endif #endif
itemMenu.Append(item_title); itemMenu.Append(item_title);
itemMenu.AppendSeparator(); itemMenu.AppendSeparator();
...@@ -197,9 +199,11 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode ) ...@@ -197,9 +199,11 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )
ADD_MENUITEM( &itemMenu, ID_POPUP_PCB_ITEM_SELECTION_START + i, text, xpm ); 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. * 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. * was not balanced with the -- (now m_IgnoreMouseEvents=FALSE), so I had to revert.
* Somebody should track down these and make them balanced. * Somebody should track down these and make them balanced.
* DrawPanel->m_IgnoreMouseEvents = TRUE; * DrawPanel->m_IgnoreMouseEvents = TRUE;
...@@ -222,15 +226,14 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode ) ...@@ -222,15 +226,14 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )
} }
/****************************************************************/ void WinEDA_PcbFrame::GeneralControle( wxDC* aDC, wxPoint aPosition )
void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
/*****************************************************************/
{ {
wxRealPoint delta; wxRealPoint gridSize;
wxPoint curpos, oldpos; wxPoint oldpos;
int hotkey = 0; int hotkey = 0;
wxPoint pos = aPosition;
ActiveScreen = GetScreen(); PutOnGrid( &pos );
// Save the board after the time out : // Save the board after the time out :
int CurrentTime = time( NULL ); int CurrentTime = time( NULL );
...@@ -254,50 +257,39 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -254,50 +257,39 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
OnModify(); OnModify();
GetScreen()->SetSave(); // Set the flags m_FlagSave cleared by SetModify() GetScreen()->SetSave(); // Set the flags m_FlagSave cleared by SetModify()
} }
GetScreen()->SetFileName( tmpFileName ); GetScreen()->SetFileName( tmpFileName );
SetTitle( GetScreen()->GetFileName() ); SetTitle( GetScreen()->GetFileName() );
} }
double scalar = GetScreen()->GetScalingFactor();
curpos = DrawPanel->CursorRealPosition( Mouse );
oldpos = GetScreen()->m_Curseur; oldpos = GetScreen()->m_Curseur;
delta = GetScreen()->GetGridSize(); gridSize = GetScreen()->GetGridSize();
delta.x *= scalar;
delta.y *= scalar;
if( delta.x <= 0 )
delta.x = 1;
if( delta.y <= 0 )
delta.y = 1;
switch( g_KeyPressed ) switch( g_KeyPressed )
{ {
case WXK_NUMPAD8: /* Deplacement curseur vers le haut */ case WXK_NUMPAD8: /* Deplacement curseur vers le haut */
case WXK_UP: case WXK_UP:
Mouse.y -= wxRound(delta.y); pos.y -= wxRound( gridSize.y );
DrawPanel->MouseTo( Mouse ); DrawPanel->MoveCursor( pos );
break; break;
case WXK_NUMPAD2: /* Deplacement curseur vers le bas */ case WXK_NUMPAD2: /* Deplacement curseur vers le bas */
case WXK_DOWN: case WXK_DOWN:
Mouse.y += wxRound(delta.y); pos.y += wxRound( gridSize.y );
DrawPanel->MouseTo( Mouse ); DrawPanel->MoveCursor( pos );
break; break;
case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */ case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */
case WXK_LEFT: case WXK_LEFT:
Mouse.x -= wxRound(delta.x); pos.x -= wxRound( gridSize.x );
DrawPanel->MouseTo( Mouse ); DrawPanel->MoveCursor( pos );
break; break;
case WXK_NUMPAD6: /* Deplacement curseur vers la droite */ case WXK_NUMPAD6: /* Deplacement curseur vers la droite */
case WXK_RIGHT: case WXK_RIGHT:
Mouse.x += wxRound(delta.x); pos.x += wxRound( gridSize.x );
DrawPanel->MouseTo( Mouse ); DrawPanel->MoveCursor( pos );
break; break;
default: default:
...@@ -305,14 +297,14 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -305,14 +297,14 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
break; break;
} }
/* Put cursor in new position, according to the zoom keys (if any) */ // Put cursor in new position, according to the zoom keys (if any).
GetScreen()->m_Curseur = curpos; GetScreen()->m_Curseur = pos;
/* Put cursor on grid or a pad centre if requested /* Put cursor on grid or a pad centre if requested. If the tool DELETE is active the
* But if the tool DELETE is active the cursor is left off grid * cursor is left off grid this is better to reach items to delete off grid,
* this is better to reach items to delete off grid
*/ */
bool keep_on_grid = TRUE; bool keep_on_grid = TRUE;
if( m_ID_current_state == ID_PCB_DELETE_ITEM_BUTT ) if( m_ID_current_state == ID_PCB_DELETE_ITEM_BUTT )
keep_on_grid = FALSE; keep_on_grid = FALSE;
...@@ -327,16 +319,16 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -327,16 +319,16 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
if( keep_on_grid ) if( keep_on_grid )
{ {
wxPoint on_grid = curpos; wxPoint on_grid = pos;
PutOnGrid( &on_grid ); PutOnGrid( &on_grid );
wxSize grid; wxSize grid;
grid.x = (int) GetScreen()->GetGridSize().x; grid.x = (int) GetScreen()->GetGridSize().x;
grid.y = (int) GetScreen()->GetGridSize().y; 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 else
{ {
...@@ -354,21 +346,20 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -354,21 +346,20 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
if( oldpos != GetScreen()->m_Curseur ) if( oldpos != GetScreen()->m_Curseur )
{ {
curpos = GetScreen()->m_Curseur; pos = GetScreen()->m_Curseur;
GetScreen()->m_Curseur = oldpos; GetScreen()->m_Curseur = oldpos;
DrawPanel->CursorOff( DC ); DrawPanel->CursorOff( aDC );
GetScreen()->m_Curseur = pos;
GetScreen()->m_Curseur = curpos; DrawPanel->CursorOn( aDC );
DrawPanel->CursorOn( DC );
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
{ {
#ifdef USE_WX_OVERLAY #ifdef USE_WX_OVERLAY
wxDCOverlay oDC( DrawPanel->m_overlay, (wxWindowDC*)DC ); wxDCOverlay oDC( DrawPanel->m_overlay, (wxWindowDC*)aDC );
oDC.Clear(); oDC.Clear();
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, aDC, FALSE );
#else #else
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE ); DrawPanel->ManageCurseur( DrawPanel, aDC, TRUE );
#endif #endif
} }
#ifdef USE_WX_OVERLAY #ifdef USE_WX_OVERLAY
...@@ -379,7 +370,7 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -379,7 +370,7 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
if( hotkey ) if( hotkey )
{ {
OnHotKey( DC, hotkey, NULL ); OnHotKey( aDC, hotkey, NULL );
} }
if( GetScreen()->IsRefreshReq() ) if( GetScreen()->IsRefreshReq() )
......
...@@ -271,9 +271,10 @@ void WinEDA_PcbFrame::Affiche_Status_Net( wxDC* DC ) ...@@ -271,9 +271,10 @@ void WinEDA_PcbFrame::Affiche_Status_Net( wxDC* DC )
{ {
TRACK* pt_segm; TRACK* pt_segm;
int masquelayer = (1 << getActiveLayer()); 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 ) if( pt_segm == NULL )
GetBoard()->DisplayInfo( this ); GetBoard()->DisplayInfo( this );
else else
......
...@@ -139,8 +139,6 @@ bool WinEDA_PcbFrame::LoadOnePcbFile( const wxString& aFileName, bool aAppend, ...@@ -139,8 +139,6 @@ bool WinEDA_PcbFrame::LoadOnePcbFile( const wxString& aFileName, bool aAppend,
FILE* source; FILE* source;
wxString msg; wxString msg;
ActiveScreen = GetScreen();
if( GetScreen()->IsModify() && !aAppend ) if( GetScreen()->IsModify() && !aAppend )
{ {
if( !IsOK( this, _( "The current board has been modified. Do you wish to discard \ if( !IsOK( this, _( "The current board has been modified. Do you wish to discard \
......
...@@ -32,10 +32,11 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* aDC, int aHotkeyCode, EDA_ITEM* aItem ) ...@@ -32,10 +32,11 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* aDC, int aHotkeyCode, EDA_ITEM* aItem )
if( aHotkeyCode == 0 ) if( aHotkeyCode == 0 )
return; return;
wxPoint pos;
bool itemCurrentlyEdited = (GetCurItem() && GetCurItem()->m_Flags); bool itemCurrentlyEdited = (GetCurItem() && GetCurItem()->m_Flags);
MODULE* module = NULL; MODULE* module = NULL;
int evt_type = 0; //Used to post a wxCommandEvent on demand int evt_type = 0; //Used to post a wxCommandEvent on demand
PCB_SCREEN* screen = GetScreen();
/* Convert lower to upper case /* Convert lower to upper case
* (the usual toupper function has problem with non ascii codes like function keys * (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 ) ...@@ -156,8 +157,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* aDC, int aHotkeyCode, EDA_ITEM* aItem )
case HK_REDO: case HK_REDO:
if( !itemCurrentlyEdited ) if( !itemCurrentlyEdited )
{ {
wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, HK_Descr->m_IdMenuEvent );
HK_Descr->m_IdMenuEvent );
wxPostEvent( this, event ); wxPostEvent( this, event );
} }
break; break;
...@@ -318,10 +318,15 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* aDC, int aHotkeyCode, EDA_ITEM* aItem ) ...@@ -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: case HK_LOCK_UNLOCK_FOOTPRINT: // toggle module "MODULE_is_LOCKED" status:
// get any module, locked or not locked and toggle its locked status // get any module, locked or not locked and toggle its locked status
if( !itemCurrentlyEdited ) 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 ) else if( GetCurItem()->Type() == TYPE_MODULE )
{
module = (MODULE*) GetCurItem(); module = (MODULE*) GetCurItem();
}
if( module ) if( module )
{ {
SetCurItem( module ); SetCurItem( module );
...@@ -400,11 +405,15 @@ bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* aDC ) ...@@ -400,11 +405,15 @@ bool WinEDA_PcbFrame::OnHotkeyDeleteItem( wxDC* aDC )
case ID_COMPONENT_BUTT: case ID_COMPONENT_BUTT:
if( ItemFree ) 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 ) if( module == NULL )
return false; return false;
if( !IsOK( this, _( "Delete module?" ) ) ) if( !IsOK( this, _( "Delete module?" ) ) )
return false; return false;
RemoveStruct( module, aDC ); RemoveStruct( module, aDC );
} }
else else
......
This diff is collapsed.
...@@ -100,8 +100,8 @@ bool Project( wxPoint* res, wxPoint on_grid, const TRACK* track ) ...@@ -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. * @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. * @return bool - true if the position was adjusted magnetically, else false.
*/ */
bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame, bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame, int aCurrentTool, wxSize grid,
int aCurrentTool, wxSize grid, wxPoint on_grid, wxPoint* curpos ) wxPoint on_grid, wxPoint* curpos )
{ {
bool doCheckNet = g_MagneticPadOption != capture_always && Drc_On; bool doCheckNet = g_MagneticPadOption != capture_always && Drc_On;
bool doTrack = false; bool doTrack = false;
...@@ -110,6 +110,8 @@ bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame, ...@@ -110,6 +110,8 @@ bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
TRACK* currTrack = g_CurrentTrackSegment; TRACK* currTrack = g_CurrentTrackSegment;
BOARD_ITEM* currItem = frame->GetCurItem(); 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 ); ) // 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, ...@@ -150,7 +152,8 @@ bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
if( doPad ) 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( pad )
{ {
if( doCheckNet && currTrack && currTrack->GetNet() != pad->GetNet() ) if( doCheckNet && currTrack && currTrack->GetNet() != pad->GetNet() )
...@@ -164,7 +167,7 @@ bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame, ...@@ -164,7 +167,7 @@ bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
// after pads, only track & via tests remain, skip them if not desired // after pads, only track & via tests remain, skip them if not desired
if( doTrack ) if( doTrack )
{ {
int layer = ( (PCB_SCREEN*) ActiveScreen )->m_Active_Layer; int layer = screen->m_Active_Layer;
for( TRACK* via = m_Pcb->m_Track; for( TRACK* via = m_Pcb->m_Track;
via && (via = Locate_Via_Area( via, *curpos, layer )) != NULL; via && (via = Locate_Via_Area( via, *curpos, layer )) != NULL;
...@@ -189,7 +192,8 @@ bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame, ...@@ -189,7 +192,8 @@ bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
{ {
int layer_mask = g_TabOneLayerMask[layer]; 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 ) if( !track || track->Type() != TYPE_TRACK )
{ {
// D(printf("!currTrack and track=%p not found, layer_mask=0x%X\n", track, layer_mask );) // D(printf("!currTrack and track=%p not found, layer_mask=0x%X\n", track, layer_mask );)
......
...@@ -176,7 +176,6 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father, ...@@ -176,7 +176,6 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father,
if( s_screenModule == NULL ) if( s_screenModule == NULL )
s_screenModule = new PCB_SCREEN(); s_screenModule = new PCB_SCREEN();
SetBaseScreen( s_screenModule ); SetBaseScreen( s_screenModule );
ActiveScreen = GetScreen();
GetBoard()->SetBoardDesignSettings( &s_ModuleEditorDesignSetting ); GetBoard()->SetBoardDesignSettings( &s_ModuleEditorDesignSetting );
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
LoadSettings(); LoadSettings();
...@@ -249,7 +248,6 @@ WinEDA_ModuleEditFrame::~WinEDA_ModuleEditFrame() ...@@ -249,7 +248,6 @@ WinEDA_ModuleEditFrame::~WinEDA_ModuleEditFrame()
WinEDA_BasePcbFrame* frame = (WinEDA_BasePcbFrame*) GetParent(); WinEDA_BasePcbFrame* frame = (WinEDA_BasePcbFrame*) GetParent();
frame->m_ModuleEditFrame = NULL; frame->m_ModuleEditFrame = NULL;
ActiveScreen = frame->GetScreen();
} }
...@@ -457,11 +455,12 @@ void WinEDA_ModuleEditFrame::Show3D_Frame( wxCommandEvent& event ) ...@@ -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; wxRealPoint gridSize;
wxPoint curpos, oldpos; wxPoint oldpos;
int hotkey = 0; int hotkey = 0;
wxPoint pos = aPosition;
if( GetScreen()->IsRefreshReq() ) if( GetScreen()->IsRefreshReq() )
{ {
...@@ -477,45 +476,34 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -477,45 +476,34 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
return; return;
} }
double scalar = GetScreen()->GetScalingFactor(); PutOnGrid( &pos );
curpos = DrawPanel->CursorRealPosition( Mouse );
oldpos = GetScreen()->m_Curseur; oldpos = GetScreen()->m_Curseur;
gridSize = GetScreen()->GetGridSize();
delta = GetScreen()->GetGridSize();
delta.x *= scalar;
delta.y *= scalar;
if( delta.x == 0 )
delta.x = 1;
if( delta.y == 0 )
delta.y = 1;
switch( g_KeyPressed ) switch( g_KeyPressed )
{ {
case WXK_NUMPAD8: case WXK_NUMPAD8:
case WXK_UP: case WXK_UP:
Mouse.y -= wxRound( delta.y ); pos.y -= wxRound( gridSize.y );
DrawPanel->MouseTo( Mouse ); DrawPanel->MoveCursor( pos );
break; break;
case WXK_NUMPAD2: case WXK_NUMPAD2:
case WXK_DOWN: case WXK_DOWN:
Mouse.y += wxRound( delta.y ); pos.y += wxRound( gridSize.y );
DrawPanel->MouseTo( Mouse ); DrawPanel->MoveCursor( pos );
break; break;
case WXK_NUMPAD4: case WXK_NUMPAD4:
case WXK_LEFT: case WXK_LEFT:
Mouse.x -= wxRound( delta.x ); pos.x -= wxRound( gridSize.x );
DrawPanel->MouseTo( Mouse ); DrawPanel->MoveCursor( pos );
break; break;
case WXK_NUMPAD6: case WXK_NUMPAD6:
case WXK_RIGHT: case WXK_RIGHT:
Mouse.x += wxRound( delta.x ); pos.x += wxRound( gridSize.x );
DrawPanel->MouseTo( Mouse ); DrawPanel->MoveCursor( pos );
break; break;
default: default:
...@@ -523,27 +511,25 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -523,27 +511,25 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
break; break;
} }
GetScreen()->m_Curseur = curpos; GetScreen()->m_Curseur = pos;
PutOnGrid( &GetScreen()->m_Curseur );
if( oldpos != GetScreen()->m_Curseur ) if( oldpos != GetScreen()->m_Curseur )
{ {
curpos = GetScreen()->m_Curseur; pos = GetScreen()->m_Curseur;
GetScreen()->m_Curseur = oldpos; GetScreen()->m_Curseur = oldpos;
DrawPanel->CursorOff( DC ); DrawPanel->CursorOff( aDC );
GetScreen()->m_Curseur = pos;
GetScreen()->m_Curseur = curpos; DrawPanel->CursorOn( aDC );
DrawPanel->CursorOn( DC );
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
{ {
DrawPanel->ManageCurseur( DrawPanel, DC, true ); DrawPanel->ManageCurseur( DrawPanel, aDC, true );
} }
} }
if( hotkey ) if( hotkey )
{ {
OnHotKey( DC, hotkey, NULL ); OnHotKey( aDC, hotkey, NULL );
} }
if( GetScreen()->IsRefreshReq() ) if( GetScreen()->IsRefreshReq() )
...@@ -551,6 +537,7 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) ...@@ -551,6 +537,7 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
DrawPanel->Refresh(); DrawPanel->Refresh();
wxSafeYield(); wxSafeYield();
} }
SetToolbars(); SetToolbars();
UpdateStatusBar(); UpdateStatusBar();
} }
......
...@@ -1039,12 +1039,14 @@ BOARD_ITEM* LocateLockPoint( BOARD* Pcb, wxPoint pos, int LayerMask ) ...@@ -1039,12 +1039,14 @@ BOARD_ITEM* LocateLockPoint( BOARD* Pcb, wxPoint pos, int LayerMask )
for( MODULE* module = Pcb->m_Modules; module; module = module->Next() ) for( MODULE* module = Pcb->m_Modules; module; module = module->Next() )
{ {
D_PAD* pad = Locate_Pads( module, pos, LayerMask ); D_PAD* pad = Locate_Pads( module, pos, LayerMask );
if( pad ) if( pad )
return pad; return pad;
} }
/* No pad has been located so check for a segment of the trace. */ /* No pad has been located so check for a segment of the trace. */
TRACK* ptsegm = Fast_Locate_Piste( Pcb->m_Track, NULL, pos, LayerMask ); TRACK* ptsegm = Fast_Locate_Piste( Pcb->m_Track, NULL, pos, LayerMask );
if( ptsegm == NULL ) if( ptsegm == NULL )
ptsegm = Locate_Pistes( Pcb, Pcb->m_Track, pos, LayerMask ); ptsegm = Locate_Pistes( Pcb, Pcb->m_Track, pos, LayerMask );
......
...@@ -465,7 +465,6 @@ void WinEDA_PcbFrame::OnCloseWindow( wxCloseEvent& Event ) ...@@ -465,7 +465,6 @@ void WinEDA_PcbFrame::OnCloseWindow( wxCloseEvent& Event )
// do not show the window because ScreenPcb will be deleted and we do not // do not show the window because ScreenPcb will be deleted and we do not
// want any paint event // want any paint event
Show( false ); Show( false );
ActiveScreen = ScreenPcb;
Destroy(); Destroy();
} }
......
...@@ -112,7 +112,6 @@ bool WinEDA_App::OnInit() ...@@ -112,7 +112,6 @@ bool WinEDA_App::OnInit()
} }
ScreenPcb = new PCB_SCREEN(); ScreenPcb = new PCB_SCREEN();
ActiveScreen = ScreenPcb;
// read current setup and reopen last directory if no filename to open in command line // read current setup and reopen last directory if no filename to open in command line
bool reopenLastUsedDirectory = argc == 1; bool reopenLastUsedDirectory = argc == 1;
......
...@@ -106,13 +106,10 @@ void BOARD_PRINTOUT_CONTROLER::GetPageInfo( int* minPage, int* maxPage, ...@@ -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 * This is the real print function: print the active screen
*/ */
void BOARD_PRINTOUT_CONTROLER::DrawPage()
{ {
int tmpzoom; int tmpzoom;
wxPoint tmp_startvisu; wxPoint tmp_startvisu;
...@@ -122,21 +119,21 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage() ...@@ -122,21 +119,21 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
double userscale; double userscale;
double DrawZoom = 1; double DrawZoom = 1;
wxDC* dc = GetDC(); wxDC* dc = GetDC();
BASE_SCREEN* screen = m_Parent->GetBaseScreen();
bool printMirror = m_PrintParams.m_PrintMirror; bool printMirror = m_PrintParams.m_PrintMirror;
wxBusyCursor dummy; wxBusyCursor dummy;
/* Save old draw scale and draw offset */ /* Save old draw scale and draw offset */
tmp_startvisu = ActiveScreen->m_StartVisu; tmp_startvisu = screen->m_StartVisu;
tmpzoom = ActiveScreen->GetZoom(); tmpzoom = screen->GetZoom();
old_org = ActiveScreen->m_DrawOrg; old_org = screen->m_DrawOrg;
/* Change draw scale and offset to draw the whole page */ /* Change draw scale and offset to draw the whole page */
ActiveScreen->SetScalingFactor( DrawZoom ); screen->SetScalingFactor( DrawZoom );
ActiveScreen->m_DrawOrg.x = ActiveScreen->m_DrawOrg.y = 0; screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0;
ActiveScreen->m_StartVisu.x = ActiveScreen->m_StartVisu.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.x *= m_Parent->m_InternalUnits / 1000;
SheetSize.y *= m_Parent->m_InternalUnits / 1000; // size in internal units SheetSize.y *= m_Parent->m_InternalUnits / 1000; // size in internal units
...@@ -153,8 +150,10 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage() ...@@ -153,8 +150,10 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
mv_offset.y = SheetSize.y / 2; mv_offset.y = SheetSize.y / 2;
brd_BBox.Move( mv_offset ); brd_BBox.Move( mv_offset );
} }
/* Compute the PCB size in internal units*/ /* Compute the PCB size in internal units*/
userscale = m_PrintParams.m_PrintScale; userscale = m_PrintParams.m_PrintScale;
if( userscale == 0 ) // fit in page if( userscale == 0 ) // fit in page
{ {
int extra_margin = 4000*2; // Margin = 4000 units pcb = 0.4 inch int extra_margin = 4000*2; // Margin = 4000 units pcb = 0.4 inch
...@@ -228,7 +227,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage() ...@@ -228,7 +227,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
DrawOffset.y -= PlotAreaSizeInUserUnits.y / 2; DrawOffset.y -= PlotAreaSizeInUserUnits.y / 2;
} }
ActiveScreen->m_DrawOrg = DrawOffset; screen->m_DrawOrg = DrawOffset;
GRResetPenAndBrush( dc ); GRResetPenAndBrush( dc );
if( m_PrintParams.m_Print_Black_and_White ) if( m_PrintParams.m_Print_Black_and_White )
...@@ -248,7 +247,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage() ...@@ -248,7 +247,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
int bg_color = g_DrawBgColor; int bg_color = g_DrawBgColor;
if( m_PrintParams.m_Print_Sheet_Ref ) 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 ) if( printMirror )
{ {
...@@ -279,7 +278,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage() ...@@ -279,7 +278,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
if( userscale <= 1.0 ) if( userscale <= 1.0 )
DrawOffset.y += pcb_centre.y - (ysize / 2); 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 ) ); panel->m_ClipBox.SetOrigin( wxPoint( -MAX_VALUE/2, -MAX_VALUE/2 ) );
} }
...@@ -306,7 +305,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage() ...@@ -306,7 +305,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
GRForceBlackPen( false ); GRForceBlackPen( false );
ActiveScreen->m_StartVisu = tmp_startvisu; screen->m_StartVisu = tmp_startvisu;
ActiveScreen->m_DrawOrg = old_org; screen->m_DrawOrg = old_org;
ActiveScreen->SetZoom( tmpzoom ); screen->SetZoom( tmpzoom );
} }
...@@ -77,16 +77,13 @@ TRACK* Locate_Via( BOARD* Pcb, const wxPoint& pos, int layer = -1 ); ...@@ -77,16 +77,13 @@ TRACK* Locate_Via( BOARD* Pcb, const wxPoint& pos, int layer = -1 );
* @param aLayer The layer to match, pass -1 for a don't care. * @param aLayer The layer to match, pass -1 for a don't care.
* @return TRACK* - actually a SEGVIA* if found, else NULL. * @return TRACK* - actually a SEGVIA* if found, else NULL.
*/ */
TRACK* Locate_Via_Area( TRACK* aStart, TRACK* Locate_Via_Area( TRACK* aStart, const wxPoint& aPos, int aLayer = ALL_LAYERS );
const wxPoint& aPos,
int aLayer = -1 );
/* Locates the center through the point x, y, on layer data /* Locates the center through the point x, y, on layer data
* by masquelayer. * by masquelayer.
* Search is done to address start_adr has end_adr (not included) * Search is done to address start_adr has end_adr (not included)
*/ */
TRACK* Fast_Locate_Via( TRACK* start_adr, TRACK* end_adr, TRACK* Fast_Locate_Via( TRACK* start_adr, TRACK* end_adr, const wxPoint& pos, int masquelayer );
const wxPoint& pos, int masquelayer );
/* Locates the center through the point x, y, on layer data /* Locates the center through the point x, y, on layer data
* by masquelayer. * by masquelayer.
...@@ -102,8 +99,7 @@ TRACK* Fast_Locate_Piste( TRACK* start_adr, TRACK* end_adr, ...@@ -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 done only on the ends of segments
* The search is limited to the area [... pt_base] pt_lim. * The search is limited to the area [... pt_base] pt_lim.
*/ */
TRACK* Locate_Piste_Connectee( TRACK* ptr_piste, TRACK* pt_base, TRACK* Locate_Piste_Connectee( TRACK* ptr_piste, TRACK* pt_base, TRACK* pt_lim, int extr );
TRACK* pt_lim, int extr );
/* /*
* 1 - Locate segment of track leading from the mouse. * 1 - Locate segment of track leading from the mouse.
...@@ -114,9 +110,7 @@ TRACK* Locate_Piste_Connectee( TRACK* ptr_piste, TRACK* pt_base, ...@@ -114,9 +110,7 @@ TRACK* Locate_Piste_Connectee( TRACK* ptr_piste, TRACK* pt_base,
* *
* The search begins to address start_adresse * 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 /* Locate pad connected to the beginning or end of a segment
* Input: pointer to the segment, and flag = START or END * Input: pointer to the segment, and flag = START or END
...@@ -126,7 +120,6 @@ TRACK* Locate_Pistes( BOARD* aPcb, TRACK* start_adresse, ...@@ -126,7 +120,6 @@ TRACK* Locate_Pistes( BOARD* aPcb, TRACK* start_adresse,
*/ */
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 * Locate pad pointed to by the coordinate ref_pX,, ref_pY or the current
* cursor position, search done on all tracks. * cursor position, search done on all tracks.
...@@ -137,12 +130,7 @@ D_PAD* Locate_Pad_Connecte( BOARD* aPcb, TRACK* ptr_segment, int extr ); ...@@ -137,12 +130,7 @@ D_PAD* Locate_Pad_Connecte( BOARD* aPcb, TRACK* ptr_segment, int extr );
* Pointer to the pad if found * Pointer to the pad if found
* NULL pointer if pad not found * NULL pointer if pad not found
*/ */
D_PAD* Locate_Any_Pad( BOARD* aPcb, D_PAD* Locate_Any_Pad( BOARD* aPcb, const wxPoint& aPosition, int aLayerMask = ALL_LAYERS );
int typeloc,
bool OnlyCurrentLayer = FALSE );
D_PAD* Locate_Any_Pad( BOARD* aPcb,
const wxPoint& ref_pos,
bool OnlyCurrentLayer = FALSE );
/* Locate pad pointed to by the coordinate ref_pX,, ref_pY or the cursor /* Locate pad pointed to by the coordinate ref_pX,, ref_pY or the cursor
* position of the current footprint. * position of the current footprint.
...@@ -152,11 +140,11 @@ D_PAD* Locate_Any_Pad( BOARD* aPcb, ...@@ -152,11 +140,11 @@ D_PAD* Locate_Any_Pad( BOARD* aPcb,
* Returns: * Returns:
* A pointer to the pad if found otherwise NULL. * 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. */ /* 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. /* Locate a pad pointed to by the cursor on the footprint.
* Module. * Module.
...@@ -181,9 +169,7 @@ 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: * Returns:
* Pointer to the pad if found, otherwise NULL. * Pointer to the pad if found, otherwise NULL.
*/ */
D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, const wxPoint& ref_pos, int layer );
const wxPoint& ref_pos,
int layer );
/* /*
* 1 - Locate trace segment at the current cursor position. * 1 - Locate trace segment at the current cursor position.
...@@ -193,10 +179,7 @@ D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb, ...@@ -193,10 +179,7 @@ D_PAD* Fast_Locate_Pad_Connecte( BOARD* Pcb,
* *
* The search begins to address start_adresse * 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 );
/*************/ /*************/
......
...@@ -1230,19 +1230,17 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC ) ...@@ -1230,19 +1230,17 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC )
int dx0, dy0, dx1, dy1; int dx0, dy0, dx1, dy1;
int marge, via_marge; int marge, via_marge;
EDA_DRAW_PANEL* panel = pcbframe->DrawPanel; EDA_DRAW_PANEL* panel = pcbframe->DrawPanel;
PCB_SCREEN* screen = pcbframe->GetScreen();
marge = s_Clearance + marge = s_Clearance + ( pcbframe->GetBoard()->GetCurrentTrackWidth() / 2 );
( pcbframe->GetBoard()->GetCurrentTrackWidth() / 2 );
via_marge = s_Clearance + ( pcbframe->GetBoard()->GetCurrentViaSize() / 2 ); via_marge = s_Clearance + ( pcbframe->GetBoard()->GetCurrentViaSize() / 2 );
dx1 = g_CurrentTrackSegment->m_End.x - g_CurrentTrackSegment->m_Start.x; dx1 = g_CurrentTrackSegment->m_End.x - g_CurrentTrackSegment->m_Start.x;
dy1 = g_CurrentTrackSegment->m_End.y - g_CurrentTrackSegment->m_Start.y; dy1 = g_CurrentTrackSegment->m_End.y - g_CurrentTrackSegment->m_Start.y;
/* Place on center of pad if off grid. */ /* Place on center of pad if off grid. */
dx0 = pt_cur_ch->m_PadStart->GetPosition().x - dx0 = pt_cur_ch->m_PadStart->GetPosition().x - g_CurrentTrackSegment->m_Start.x;
g_CurrentTrackSegment->m_Start.x; dy0 = pt_cur_ch->m_PadStart->GetPosition().y - g_CurrentTrackSegment->m_Start.y;
dy0 = pt_cur_ch->m_PadStart->GetPosition().y -
g_CurrentTrackSegment->m_Start.y;
/* If aligned, change the origin point. */ /* If aligned, change the origin point. */
if( abs( dx0 * dy1 ) == abs( dx1 * dy0 ) ) if( abs( dx0 * dy1 ) == abs( dx1 * dy0 ) )
...@@ -1259,13 +1257,15 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC ) ...@@ -1259,13 +1257,15 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC )
g_CurrentTrackList.PushBack( newTrack ); g_CurrentTrackList.PushBack( newTrack );
} }
g_FirstTrackSegment->start = Locate_Pad_Connecte( g_FirstTrackSegment->start = Locate_Pad_Connecte( pcbframe->GetBoard(),
pcbframe->GetBoard(), g_FirstTrackSegment, START ); g_FirstTrackSegment, START );
if( g_FirstTrackSegment->start ) if( g_FirstTrackSegment->start )
g_FirstTrackSegment->SetState( BEGIN_ONPAD, ON ); g_FirstTrackSegment->SetState( BEGIN_ONPAD, ON );
g_CurrentTrackSegment->end = Locate_Pad_Connecte( g_CurrentTrackSegment->end = Locate_Pad_Connecte( pcbframe->GetBoard(),
pcbframe->GetBoard(), g_CurrentTrackSegment, END ); g_CurrentTrackSegment, END );
if( g_CurrentTrackSegment->end ) if( g_CurrentTrackSegment->end )
g_CurrentTrackSegment->SetState( END_ONPAD, ON ); g_CurrentTrackSegment->SetState( END_ONPAD, ON );
...@@ -1284,8 +1284,7 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC ) ...@@ -1284,8 +1284,7 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC )
// Put entire new current segment list in BOARD // Put entire new current segment list in BOARD
TRACK* track; TRACK* track;
TRACK* insertBeforeMe = TRACK* insertBeforeMe = g_CurrentTrackSegment->GetBestInsertPoint( pcbframe->GetBoard() );
g_CurrentTrackSegment->GetBestInsertPoint( pcbframe->GetBoard() );
while( ( track = g_CurrentTrackList.PopFront() ) != NULL ) while( ( track = g_CurrentTrackList.PopFront() ) != NULL )
{ {
...@@ -1296,5 +1295,5 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC ) ...@@ -1296,5 +1295,5 @@ static void Place_Piste_en_Buffer( WinEDA_PcbFrame* pcbframe, wxDC* DC )
pcbframe->test_1_net_connexion( DC, netcode ); pcbframe->test_1_net_connexion( DC, netcode );
ActiveScreen->SetModify(); screen->SetModify();
} }
...@@ -42,7 +42,6 @@ void WinEDA_ModuleEditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -42,7 +42,6 @@ void WinEDA_ModuleEditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
if( !GetBoard() || !screen ) if( !GetBoard() || !screen )
return; return;
ActiveScreen = screen;
GRSetDrawMode( DC, GR_COPY ); GRSetDrawMode( DC, GR_COPY );
DrawPanel->DrawBackGround( DC ); DrawPanel->DrawBackGround( DC );
...@@ -82,7 +81,6 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -82,7 +81,6 @@ void WinEDA_PcbFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
if( !GetBoard() || !screen ) if( !GetBoard() || !screen )
return; return;
ActiveScreen = screen;
GRSetDrawMode( DC, GR_COPY ); GRSetDrawMode( DC, GR_COPY );
DrawPanel->DrawBackGround( DC ); DrawPanel->DrawBackGround( DC );
......
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