mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-02 16:44:16 +02:00
2e4bb486bb
Implements discussion #599's phase 1 (Linux, libspnav): a 3Dconnexion 6-DOF device pans and zooms the active diagram view, via spacenavd. ## Off by default, zero cost when off QET_ENABLE_SPACEMOUSE (cmake/developer_options.cmake) is OFF. Verified in two separate build directories from a clean configure: with it off, the new cmake/find_spacemouse.cmake step runs and does nothing (no library lookup, no definition, no new source files compiled), and qetapp.cpp/.h produce zero new object code -- both are entirely #ifdef'd out. The default build is byte-for-byte the same shape as before this commit. With it on, libspnav is located via its pkg-config file (spnav.pc, shipped by libspnav-dev on Debian/Ubuntu and equivalent packages elsewhere). If the option is on but the library isn't found, this does not hard-fail configure: it downgrades back to off with a warning, so an opt-in feature never blocks a developer who doesn't have the library installed. ## No new navigation logic -- a new input source for the existing one DiagramView::wheelEvent() already turns a physical wheel's delta into horizontalScrollBar()/verticalScrollBar() calls for pan and a zoom(1 + value/1000) call for zoom -- see diagramview.cpp:661-687. SpaceMouseListener calls exactly those same primitives from spnav motion events instead of wheel events. It does not reimplement panning or zooming. ## Safe by construction even when compiled in The overwhelming majority of users of a build with the option on still won't have spacenavd running or a device attached -- that must never surface as an error dialog or a startup warning. SpaceMouseListener:: isAvailable() reflects this: spnav_open() failing is treated as the ordinary case, not an error, and the object then does nothing at all. Verified for real in this environment, which genuinely has no spacenavd running: built with the option on, ran the resulting binary to completion, and confirmed zero crashes and zero spnav-related output of any kind -- the silence is the point. Motion is read via a QSocketNotifier on spnav_fd() (event-driven, no polling loop, no idle cost) and applied to whichever DiagramView is currently active, found via qApp->activeWindow() -> QETDiagramEditor -> currentProjectView() -> currentDiagram(): a 6-DOF device is one ambient input source for the whole application, not something tied to a particular window, so there is exactly one listener, owned by QETApp. ## What could not be verified without hardware The Z-axis-to-zoom-factor mapping (SpaceMouseListener::zoomFactorForZAxis) is a pure function specifically so it could be tested without a live device: confirmed a centered device (z=0) yields exactly 1.0 (an exact no-op, not an epsilon-off value that could trip DiagramView::zoom()'s >=1 branch), and that push/pull produce symmetric zoom-in/out factors. What genuinely cannot be checked in this environment: which physical axis is "left/right" vs "up/down" vs "push/forward", their sign, and whether the ZOOM_DIVISOR/PAN_SCALE constants feel right on real hardware. Both are named constants specifically so recalibrating them is a one-line change once someone with a device tries it -- flagged plainly in the PR rather than presented as verified. ## Not in this commit Windows/macOS (proprietary 3DxWare SDK, materially bigger lift) and device button mapping are both explicitly out of scope for this phase per the discussion.
48 lines
2.1 KiB
CMake
48 lines
2.1 KiB
CMake
# Copyright 2006 The QElectroTech Team
|
|
# This file is part of QElectroTech.
|
|
#
|
|
# QElectroTech is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# QElectroTech is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
message(" - find_spacemouse")
|
|
|
|
# QET_ENABLE_SPACEMOUSE (cmake/developer_options.cmake) is off by default,
|
|
# so none of this runs, and the default build is entirely unaffected: no new
|
|
# dependency, no new source files, no new symbols.
|
|
#
|
|
# When it is on, libspnav is looked for via its pkg-config file (present on
|
|
# every distro package of it this was checked against: Debian/Ubuntu's
|
|
# libspnav-dev ships /usr/share/pkgconfig/spnav.pc). If it isn't found, this
|
|
# does not hard-fail the whole configure -- it downgrades the option back to
|
|
# off with a clear message, so a developer who doesn't have the library
|
|
# installed still gets a normal build instead of a configure error for an
|
|
# opt-in feature they didn't ask to block on.
|
|
set(QET_SPACEMOUSE_ENABLED FALSE)
|
|
|
|
if(QET_ENABLE_SPACEMOUSE)
|
|
find_package(PkgConfig)
|
|
if(PkgConfig_FOUND)
|
|
pkg_check_modules(SPNAV IMPORTED_TARGET spnav)
|
|
endif()
|
|
|
|
if(SPNAV_FOUND)
|
|
set(QET_SPACEMOUSE_ENABLED TRUE)
|
|
add_definitions(-DQET_SPACEMOUSE_SUPPORT)
|
|
message("QET_ENABLE_SPACEMOUSE ON (libspnav ${SPNAV_VERSION} found)")
|
|
else()
|
|
message(WARNING "QET_ENABLE_SPACEMOUSE is ON but libspnav was not found via pkg-config "
|
|
"(install libspnav-dev, or the equivalent for your distribution) -- "
|
|
"building WITHOUT 3D mouse support.")
|
|
endif()
|
|
endif()
|