Fix cross-probing.

This commit is contained in:
Jeff Young 2018-09-08 21:57:56 +01:00
parent 9f9251c11d
commit d9d2822fe0
6 changed files with 53 additions and 62 deletions

View File

@ -90,7 +90,8 @@ void SCH_EDIT_FRAME::OnFindDrcMarker( wxFindDialogEvent& event )
SetCrossHairPosition( lastMarker->GetPosition() ); SetCrossHairPosition( lastMarker->GetPosition() );
RedrawScreen( lastMarker->GetPosition(), warpCursor );
CenterScreen( lastMarker->GetPosition(), warpCursor );
msg.Printf( _( "Design rule check marker found in sheet %s at %s, %s" ), msg.Printf( _( "Design rule check marker found in sheet %s at %s, %s" ),
sheetFoundIn->Path(), sheetFoundIn->Path(),
@ -115,7 +116,6 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& aReference,
SCH_ITEM* item = NULL; SCH_ITEM* item = NULL;
SCH_COMPONENT* Component = NULL; SCH_COMPONENT* Component = NULL;
wxPoint pos; wxPoint pos;
bool centerAndRedraw = false;
bool notFound = true; bool notFound = true;
LIB_PIN* pin; LIB_PIN* pin;
SCH_SHEET_LIST sheetList( g_RootSheet ); SCH_SHEET_LIST sheetList( g_RootSheet );
@ -193,7 +193,6 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& aReference,
*m_CurrentSheet = *sheet; *m_CurrentSheet = *sheet;
m_CurrentSheet->UpdateAllScreenReferences(); m_CurrentSheet->UpdateAllScreenReferences();
sheet->LastScreen()->TestDanglingEnds(); sheet->LastScreen()->TestDanglingEnds();
centerAndRedraw = true;
} }
wxPoint delta; wxPoint delta;
@ -201,25 +200,8 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& aReference,
delta = Component->GetTransform().TransformCoordinate( pos ); delta = Component->GetTransform().TransformCoordinate( pos );
pos = delta + Component->GetPosition(); pos = delta + Component->GetPosition();
SetCrossHairPosition( pos );
/* There may be need to reframe the drawing */ CenterScreen( pos, false );
if( ! m_canvas->IsPointOnDisplay( pos ) )
centerAndRedraw = true;
if( centerAndRedraw )
{
SetCrossHairPosition( pos );
RedrawScreen( pos, false );
}
else
{
/*INSTALL_UNBUFFERED_DC( dc, m_canvas );
m_canvas->CrossHairOff( &dc );
SetCrossHairPosition( pos );
m_canvas->CrossHairOn( &dc );*/
// fixme-gal
}
} }
/* Print diag */ /* Print diag */
@ -439,10 +421,8 @@ void SCH_EDIT_FRAME::updateFindReplaceView( wxFindDialogEvent& aEvent )
sheet->LastScreen()->TestDanglingEnds(); sheet->LastScreen()->TestDanglingEnds();
} }
// careful here
SetCrossHairPosition( data.GetPosition() ); SetCrossHairPosition( data.GetPosition() );
CenterScreen( data.GetPosition(), warpCursor );
RedrawScreen( data.GetPosition(), warpCursor );
msg = m_foundItems.GetText( m_UserUnits ); msg = m_foundItems.GetText( m_UserUnits );

View File

@ -82,7 +82,7 @@ LIB_PART* SchGetLibPart( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable, PART
} }
// Sttaic members: // Static members:
SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent,
FRAME_T aWindowType, const wxString& aTitle, FRAME_T aWindowType, const wxString& aTitle,
@ -335,6 +335,8 @@ bool SCH_BASE_FRAME::saveSymbolLibTables( bool aGlobal, bool aProject )
return success; return success;
} }
// Set the zoom level to show the contents of the view.
void SCH_BASE_FRAME::Zoom_Automatique( bool aWarpPointer ) void SCH_BASE_FRAME::Zoom_Automatique( bool aWarpPointer )
{ {
EDA_DRAW_PANEL_GAL* galCanvas = GetGalCanvas(); EDA_DRAW_PANEL_GAL* galCanvas = GetGalCanvas();
@ -378,11 +380,12 @@ void SCH_BASE_FRAME::Zoom_Automatique( bool aWarpPointer )
galCanvas->Refresh(); galCanvas->Refresh();
} }
/* Set the zoom level to show the area Rect */
void SCH_BASE_FRAME::Window_Zoom( EDA_RECT& Rect ) // Set the zoom level to show the area of aRect
void SCH_BASE_FRAME::Window_Zoom( EDA_RECT& aRect )
{ {
KIGFX::VIEW* view = GetGalCanvas()->GetView(); KIGFX::VIEW* view = GetGalCanvas()->GetView();
BOX2I selectionBox ( Rect.GetPosition(), Rect.GetSize() ); BOX2I selectionBox ( aRect.GetPosition(), aRect.GetSize() );
VECTOR2D screenSize = view->ToWorld( GetGalCanvas()->GetClientSize(), false ); VECTOR2D screenSize = view->ToWorld( GetGalCanvas()->GetClientSize(), false );
@ -418,7 +421,7 @@ void SCH_BASE_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointe
GetCanvas()->GetView()->SetScale( scale ); GetCanvas()->GetView()->SetScale( scale );
if( aWarpPointer ) if( aWarpPointer )
GetCanvas()->GetViewControls()->CenterOnCursor(); GetCanvas()->GetViewControls()->WarpCursor( aCenterPoint );
GetCanvas()->Refresh(); GetCanvas()->Refresh();
} }
@ -438,6 +441,17 @@ void SCH_BASE_FRAME::RedrawScreen2( const wxPoint& posBefore )
} }
void SCH_BASE_FRAME::CenterScreen( const wxPoint& aCenterPoint, bool aWarpPointer )
{
GetCanvas()->GetView()->SetCenter( aCenterPoint );
if( aWarpPointer )
GetCanvas()->GetViewControls()->WarpCursor( aCenterPoint );
GetGalCanvas()->Refresh();
}
void SCH_BASE_FRAME::HardRedraw() void SCH_BASE_FRAME::HardRedraw()
{ {
GetCanvas()->DisplaySheet( GetScreen() ); GetCanvas()->DisplaySheet( GetScreen() );

View File

@ -280,12 +280,14 @@ public:
virtual void Zoom_Automatique( bool aWarpPointer ) override; virtual void Zoom_Automatique( bool aWarpPointer ) override;
/* Set the zoom level to show the area Rect */ /* Set the zoom level to show the area Rect */
virtual void Window_Zoom( EDA_RECT& Rect ) override; virtual void Window_Zoom( EDA_RECT& aRect ) override;
virtual void RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer ) override; virtual void RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer ) override;
virtual void RedrawScreen2( const wxPoint& posBefore ) override; virtual void RedrawScreen2( const wxPoint& posBefore ) override;
virtual void CenterScreen( const wxPoint& aCenterPoint, bool aWarpPointer );
virtual void HardRedraw() override; virtual void HardRedraw() override;
void AddToScreen( SCH_ITEM* aItem ); void AddToScreen( SCH_ITEM* aItem );

View File

@ -27,7 +27,6 @@
#include <worksheet_viewitem.h> #include <worksheet_viewitem.h>
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
#include <sch_draw_panel.h> #include <sch_draw_panel.h>
#include <sch_view.h> #include <sch_view.h>
#include <sch_painter.h> #include <sch_painter.h>
@ -42,6 +41,26 @@
using namespace std::placeholders; using namespace std::placeholders;
// Events used by EDA_DRAW_PANEL
// GAL TODO: some (most?) of these need to be implemented...
BEGIN_EVENT_TABLE( SCH_DRAW_PANEL, wxScrolledWindow )
// EVT_LEAVE_WINDOW( EDA_DRAW_PANEL::OnMouseLeaving )
// EVT_ENTER_WINDOW( EDA_DRAW_PANEL::OnMouseEntering )
// EVT_MOUSEWHEEL( EDA_DRAW_PANEL::OnMouseWheel )
#if wxCHECK_VERSION( 3, 1, 0 ) || defined( USE_OSX_MAGNIFY_EVENT )
// EVT_MAGNIFY( EDA_DRAW_PANEL::OnMagnify )
#endif
// EVT_MOUSE_EVENTS( EDA_DRAW_PANEL::OnMouseEvent )
EVT_CHAR( SCH_DRAW_PANEL::OnKeyEvent )
EVT_CHAR_HOOK( SCH_DRAW_PANEL::OnCharHook )
EVT_PAINT( SCH_DRAW_PANEL::onPaint )
// EVT_ERASE_BACKGROUND( EDA_DRAW_PANEL::OnEraseBackground )
// EVT_SCROLLWIN( EDA_DRAW_PANEL::OnScroll )
// EVT_ACTIVATE( EDA_DRAW_PANEL::OnActivate )
// EVT_MENU_RANGE( ID_PAN_UP, ID_PAN_RIGHT, EDA_DRAW_PANEL::OnPan )
END_EVENT_TABLE()
SCH_DRAW_PANEL::SCH_DRAW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId, SCH_DRAW_PANEL::SCH_DRAW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId,
const wxPoint& aPosition, const wxSize& aSize, const wxPoint& aPosition, const wxSize& aSize,
KIGFX::GAL_DISPLAY_OPTIONS& aOptions, GAL_TYPE aGalType ) : KIGFX::GAL_DISPLAY_OPTIONS& aOptions, GAL_TYPE aGalType ) :
@ -85,8 +104,7 @@ SCH_DRAW_PANEL::SCH_DRAW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId,
for( auto e : events ) for( auto e : events )
{ {
Connect( e, wxMouseEventHandler( SCH_DRAW_PANEL::OnMouseEvent ), Connect( e, wxMouseEventHandler( SCH_DRAW_PANEL::OnMouseEvent ), NULL, this );
NULL, this );
} }
Connect( wxEVT_CHAR, wxKeyEventHandler( SCH_DRAW_PANEL::OnKeyEvent ), NULL, this ); Connect( wxEVT_CHAR, wxKeyEventHandler( SCH_DRAW_PANEL::OnKeyEvent ), NULL, this );
@ -111,11 +129,9 @@ SCH_DRAW_PANEL::SCH_DRAW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId,
m_enableBlockCommands = false; m_enableBlockCommands = false;
m_minDragEventCount = 0; m_minDragEventCount = 0;
m_cursorLevel = 0; m_cursorLevel = 0;
m_PrintIsMirrored = false; m_PrintIsMirrored = false;
m_ClickTimer = (wxTimer*) NULL;
m_doubleClickInterval = 250; m_doubleClickInterval = 250;
m_gal->SetGridColor( COLOR4D(0.0, 0.0, 0.0, 1.0) ); m_gal->SetGridColor( COLOR4D(0.0, 0.0, 0.0, 1.0) );
@ -251,7 +267,6 @@ void SCH_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
auto controls = GetViewControls(); auto controls = GetViewControls();
auto vcp = VECTOR2I( controls->GetCursorPosition() ); auto vcp = VECTOR2I( controls->GetCursorPosition() );
auto vmp = VECTOR2I( controls->GetMousePosition() ); auto vmp = VECTOR2I( controls->GetMousePosition() );
wxPoint cursorPos ( vcp.x, vcp.y );
wxPoint mousePos ( vmp.x, vmp.y ); wxPoint mousePos ( vmp.x, vmp.y );
event.Skip(); event.Skip();
@ -313,11 +328,6 @@ void SCH_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
// Calling Double Click and Click functions : // Calling Double Click and Click functions :
if( localbutt == (int) ( GR_M_LEFT_DOWN | GR_M_DCLICK ) ) if( localbutt == (int) ( GR_M_LEFT_DOWN | GR_M_DCLICK ) )
{ {
if( m_ClickTimer )
{
m_ClickTimer->Stop();
wxDELETE( m_ClickTimer );
}
GetParent()->OnLeftDClick( nullptr, mousePos ); GetParent()->OnLeftDClick( nullptr, mousePos );
// inhibit a response to the mouse left button release, // inhibit a response to the mouse left button release,
@ -335,20 +345,7 @@ void SCH_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
m_ignoreNextLeftButtonRelease = false; m_ignoreNextLeftButtonRelease = false;
if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK && !ignoreEvt ) if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK && !ignoreEvt )
{ GetParent()->OnLeftClick( nullptr, mousePos );
EDA_ITEM* item = screen->GetCurItem();
// If we have an item already selected, or we are using a tool,
// we won't use the disambiguation menu so process the click immediately
if( ( item && item->GetFlags() ) || GetParent()->GetToolId() != ID_NO_TOOL_SELECTED )
GetParent()->OnLeftClick( nullptr, mousePos );
else
{
wxDELETE( m_ClickTimer );
m_ClickTimer = new wxTimer(this, ID_MOUSE_DOUBLECLICK);
m_ClickTimer->StartOnce( m_doubleClickInterval );
}
}
} }
else if( !event.LeftIsDown() ) else if( !event.LeftIsDown() )
@ -527,13 +524,12 @@ void SCH_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
} }
bool SCH_DRAW_PANEL::OnRightClick( wxMouseEvent& event ) bool SCH_DRAW_PANEL::OnRightClick( wxMouseEvent& event )
{ {
auto controls = GetViewControls(); auto controls = GetViewControls();
auto vmp = controls->GetMousePosition(); auto vmp = controls->GetMousePosition();
auto vsp = GetView()->ToScreen( vmp );
wxPoint mouseWorldPos ( (int) vmp.x, (int) vmp.y ); wxPoint mouseWorldPos ( (int) vmp.x, (int) vmp.y );
wxPoint mouseScreenPos ( (int) vsp.x, (int) vsp.y );
wxMenu MasterMenu; wxMenu MasterMenu;
@ -559,7 +555,6 @@ void SCH_DRAW_PANEL::CallMouseCapture( wxDC* aDC, const wxPoint& aPosition, bool
void SCH_DRAW_PANEL::CallEndMouseCapture( wxDC* aDC ) void SCH_DRAW_PANEL::CallEndMouseCapture( wxDC* aDC )
{ {
// CallEndMouseCapture is sometimes called with m_endMouseCaptureCallback == NULL // CallEndMouseCapture is sometimes called with m_endMouseCaptureCallback == NULL
// for instance after an ABORT in block paste. // for instance after an ABORT in block paste.
if( m_endMouseCaptureCallback ) if( m_endMouseCaptureCallback )

View File

@ -61,6 +61,7 @@ public:
bool OnRightClick( wxMouseEvent& event ); bool OnRightClick( wxMouseEvent& event );
void OnKeyEvent( wxKeyEvent& event ); void OnKeyEvent( wxKeyEvent& event );
void OnCharHook( wxKeyEvent& event ); void OnCharHook( wxKeyEvent& event );
void OnTimer( wxTimerEvent& event );
void SetEnableMousewheelPan( bool aEnable ) override; void SetEnableMousewheelPan( bool aEnable ) override;
void SetEnableZoomNoCenter( bool aEnable ) override; void SetEnableZoomNoCenter( bool aEnable ) override;
@ -101,6 +102,8 @@ protected:
void setDefaultLayerDeps(); void setDefaultLayerDeps();
wxWindow* m_parent; wxWindow* m_parent;
DECLARE_EVENT_TABLE()
}; };
#endif #endif

View File

@ -35,9 +35,6 @@ protected:
wxPoint m_PanStartCenter; ///< Initial scroll center position when pan started wxPoint m_PanStartCenter; ///< Initial scroll center position when pan started
wxPoint m_PanStartEventPosition; ///< Initial position of mouse event when pan started wxPoint m_PanStartEventPosition; ///< Initial position of mouse event when pan started
wxPoint m_CursorClickPos; ///< Used for maintaining click position
wxTimer *m_ClickTimer;
/// The drawing area used to redraw the screen which is usually the visible area /// The drawing area used to redraw the screen which is usually the visible area
/// of the drawing in internal units. /// of the drawing in internal units.
EDA_RECT m_ClipBox; EDA_RECT m_ClipBox;