KiCad PCB EDA Suite
controller.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
5  * Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
6  * Copyright (C) 2004-2016 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #include <fctsys.h>
27 #include <gr_basic.h>
28 #include <sch_draw_panel.h>
29 #include <eda_dde.h>
30 #include <sch_edit_frame.h>
31 #include <menus_helpers.h>
32 #include <msgpanel.h>
33 #include <bitmaps.h>
34 
35 #include <eeschema_id.h>
36 #include <general.h>
37 #include <hotkeys.h>
38 #include <lib_edit_frame.h>
39 #include <viewlib_frame.h>
40 #include <lib_draw_item.h>
41 #include <lib_pin.h>
42 #include <sch_sheet.h>
43 #include <sch_sheet_path.h>
44 #include <sch_marker.h>
45 #include <sch_component.h>
46 
47 bool LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
48 {
49  // Filter out the 'fake' mouse motion after a keyboard movement
50  if( !aHotKey && m_movingCursorWithKeyboard )
51  {
53  return false;
54  }
55 
56  // when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed
57  // for next cursor position
58  // ( shift or ctrl key down are PAN command with mouse wheel)
59  bool snapToGrid = true;
60 
61  if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) )
62  snapToGrid = false;
63 
64  // Cursor is left off grid only if no block in progress
65  if( GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK )
66  snapToGrid = true;
67 
68  wxPoint pos = aPosition;
69  bool keyHandled = GeneralControlKeyMovement( aHotKey, &pos, snapToGrid );
70 
72  m_canvas->CrossHairOff( aDC );
73  else
74  m_canvas->CrossHairOn( aDC );
75 
76  SetCrossHairPosition( pos, snapToGrid );
77 
78  if( m_canvas->IsMouseCaptured() )
79  m_canvas->CallMouseCapture( aDC, aPosition, true );
80 
81  if( aHotKey && OnHotKey( aDC, aHotKey, aPosition, NULL ) )
82  keyHandled = true;
83 
84  // Make sure current-part highlighting doesn't get lost in seleciton highlighting
86 
88 
89  return keyHandled;
90 }
91 
Definition of the SCH_SHEET class for Eeschema.
DDE server & client.
bool OnHotKey(wxDC *aDC, int aHotKey, const wxPoint &aPosition, EDA_ITEM *aItem=NULL) override
void ClearSearchTreeSelection()
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool GeneralControl(wxDC *aDC, const wxPoint &aPosition, EDA_KEY aHotKey=0) override
Perform application specific control using aDC at aPosition in logical units.
Definition: controller.cpp:47
int GetState(int type) const
Definition: base_struct.h:240
Pcbnew hotkeys.
bool GeneralControlKeyMovement(int aHotKey, wxPoint *aPos, bool aSnapToGrid)
Handle the common part of GeneralControl dedicated to global cursor keys (i.e.
virtual void CrossHairOn(wxDC *DC=nullptr)
virtual void CallMouseCapture(wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function CallMouseCapture calls the mouse capture callback.
virtual void CrossHairOff(wxDC *DC=nullptr)
uint32_t EDA_KEY
Definition: common.h:73
void UpdateStatusBar() override
Update the status bar information.
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:123
Definition the SCH_COMPONENT class for Eeschema.
int GetToolId() const
Definition: draw_frame.h:519
Definition of class LIB_EDIT_FRAME.
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
void SetCrossHairPosition(const wxPoint &aPosition, bool aSnapToGrid=true)
Set the screen cross hair position to aPosition in logical (drawing) units.
Message panel definition file.
bool m_movingCursorWithKeyboard
One-shot to avoid a recursive mouse event during hotkey movement.
Definition: draw_frame.h:173