refactoredCPPNeuronMesher
|
GLFW input handling callbacks for neuron visualization. More...
#include <GLFW/glfw3.h>
#include <iostream>
#include <vector>
#include "neurongraph.h"
#include "globals.h"
#include "opgl_utils.h"
Go to the source code of this file.
Functions | |
void | keyCallback (GLFWwindow *window, int key, int scancode, int action, int mods) |
Handles keyboard input events. More... | |
void | mouseButtonCallback (GLFWwindow *window, int button, int action, int mods) |
Handles mouse button input events. More... | |
void | cursorPosCallback (GLFWwindow *window, double xpos, double ypos) |
Handles mouse cursor movement. More... | |
void | scrollCallback (GLFWwindow *window, double xoffset, double yoffset) |
Handles mouse scroll events. More... | |
GLFW input handling callbacks for neuron visualization.
This header defines the callback functions that handle user input through GLFW, including keyboard, mouse, and scroll wheel interactions for the neuron viewer. These callbacks modify the global state in globals.h to control the visualization.
void cursorPosCallback | ( | GLFWwindow * | window, |
double | xpos, | ||
double | ypos | ||
) |
Handles mouse cursor movement.
Updates camera orientation or position based on mouse movement when:
window | The GLFW window that received the event |
xpos | The new cursor x-coordinate, relative to the left edge of the content area |
ypos | The new cursor y-coordinate, relative to the top edge of the content area |
Handles mouse cursor movement.
[in] | window | The GLFW window that received the event |
[in] | xpos | The new x-coordinate of the cursor, in screen coordinates |
[in] | ypos | The new y-coordinate of the cursor, in screen coordinates |
This callback function processes mouse movement to implement interactive 3D view manipulation. It provides the following functionality:
The function uses the difference between the current and last cursor positions to calculate the amount of rotation or panning to apply. The actual view transformation is applied in the main rendering loop using the global state variables modified by this function.
void keyCallback | ( | GLFWwindow * | window, |
int | key, | ||
int | scancode, | ||
int | action, | ||
int | mods | ||
) |
Handles keyboard input events.
Processes key presses and releases to control the visualization:
window | The GLFW window that received the event |
key | The keyboard key that was pressed or released |
scancode | The system-specific scancode of the key |
action | GLFW_PRESS, GLFW_RELEASE or GLFW_REPEAT |
mods | Bit field describing which modifier keys were held down |
Handles keyboard input events.
[in] | window | The GLFW window that received the event |
[in] | key | The keyboard key that was pressed or released |
[in] | scancode | The system-specific scancode of the key |
[in] | action | The key action (GLFW_PRESS, GLFW_RELEASE, or GLFW_REPEAT) |
[in] | mods | Bit field describing which modifier keys were held down |
This callback function processes keyboard input for controlling the neuron viewer. It implements the following keyboard shortcuts:
The function modifies global state for view parameters and triggers updates to the neuron visualization when geometry is refined or coarsened.
void mouseButtonCallback | ( | GLFWwindow * | window, |
int | button, | ||
int | action, | ||
int | mods | ||
) |
Handles mouse button input events.
Processes mouse button presses and releases for:
window | The GLFW window that received the event |
button | The mouse button that was pressed or released |
action | GLFW_PRESS or GLFW_RELEASE |
mods | Bit field describing which modifier keys were held down |
Handles mouse button input events.
[in] | window | The GLFW window that received the event |
[in] | button | The mouse button that was pressed or released |
[in] | action | The button action (GLFW_PRESS or GLFW_RELEASE) |
[in] | mods | Bit field describing which modifier keys were held down |
This callback function processes mouse button events to enable interactive 3D view manipulation. It tracks the following interactions:
The function updates global state variables (dragging, rightDragging) that are used by cursorPosCallback to implement the actual view transformations.
void scrollCallback | ( | GLFWwindow * | window, |
double | xoffset, | ||
double | yoffset | ||
) |
Handles mouse scroll events.
Zooms the view in/out based on vertical scroll input.
window | The GLFW window that received the event |
xoffset | The scroll offset along the x-axis (unused) |
yoffset | The scroll offset along the y-axis (positive = scroll up, negative = scroll down) |
Handles mouse scroll events.
[in] | window | The GLFW window that received the event |
[in] | xoffset | The scroll offset along the x-axis (unused in this implementation) |
[in] | yoffset | The scroll offset along the y-axis (positive for scroll up, negative for scroll down) |
This callback function processes mouse scroll wheel input to implement smooth zooming of the 3D view. It modifies the global zoom factor based on the vertical scroll amount.
The zoom factor is adjusted using an exponential scale (1.1^yoffset) to provide natural-feeling zoom behavior. The zoom level is clamped between 0.05 and 10.0 to prevent extreme zoom levels that might cause rendering issues or numerical instability.