28#include <wx/toplevel.h>
36 m_driver = std::make_unique<LIBSPNAV_DRIVER>();
72 wxTopLevelWindow* topLevel =
m_canvas
73 ?
dynamic_cast<wxTopLevelWindow*
>( wxGetTopLevelParent(
m_canvas ) )
79 if( !topLevel || topLevel->IsActive() )
88 wxLogTrace(
"spacenav",
"OnPan: x=%f, y=%f, z=%f", x, y, z );
93 if( std::fabs( x ) > std::numeric_limits<double>::epsilon() ||
94 std::fabs( y ) > std::numeric_limits<double>::epsilon() ||
95 std::fabs( z ) > std::numeric_limits<double>::epsilon() )
97 double tx = x * panFactor;
98 double tz = z * panFactor;
108 m_view->SetCenter( viewPos );
110 double zoom = y * panFactor;
115 double current_pixels =
m_canvas->GetClientSize().GetWidth();
116 double current_scale =
m_view->GetScale();
117 double desired_pixels = current_pixels +
zoom / 10.0;
119 if( desired_pixels < 1 )
122 double new_scale = current_scale * ( current_pixels / desired_pixels);
124 m_view->SetScale( new_scale, viewPos );
128 moveEvent.SetX( msp.
x );
129 moveEvent.SetY( msp.
y );
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
static const wxEventType EVT_REFRESH_MOUSE
Event that forces mouse move event in the dispatcher (eg.
virtual COMMON_SETTINGS * GetCommonSettings() const
void SetFocus(bool aFocus=true)
void onPollTimer(wxTimerEvent &evt)
void SetCanvas(EDA_DRAW_PANEL_GAL *aCanvas)
std::unique_ptr< SPACENAV_DRIVER > m_driver
void OnButton(int button, bool pressed) override
Handle button press/release events.
EDA_DRAW_PANEL_GAL * m_canvas
SPNAV_2D_PLUGIN(EDA_DRAW_PANEL_GAL *aCanvas)
void OnPan(double x, double y, double z) override
Handle translation (pan) events.
void OnRotate(double rx, double ry, double rz) override
Handle rotational events.
PGM_BASE & Pgm()
The global program "get" accessor.
VECTOR2< double > VECTOR2D
WX_VIEW_CONTROLS class definition.