mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 12:41:20 -06:00 
			
		
		
		
	ENABLE_3DCONNEXION_DEVICES -> Experimental input queues with max size
This commit is contained in:
		
							parent
							
								
									3a5823bc2e
								
							
						
					
					
						commit
						aae1250921
					
				
					 2 changed files with 190 additions and 27 deletions
				
			
		|  | @ -54,10 +54,10 @@ namespace Slic3r { | |||
| namespace GUI { | ||||
|      | ||||
| const double Mouse3DController::State::DefaultTranslationScale = 2.5; | ||||
| const double Mouse3DController::State::MaxTranslationDeadzone = 0.1; | ||||
| const double Mouse3DController::State::MaxTranslationDeadzone = 0.2; | ||||
| const double Mouse3DController::State::DefaultTranslationDeadzone = 0.5 * Mouse3DController::State::MaxTranslationDeadzone; | ||||
| const float Mouse3DController::State::DefaultRotationScale = 1.0f; | ||||
| const float Mouse3DController::State::MaxRotationDeadzone = 0.1f; | ||||
| const float Mouse3DController::State::MaxRotationDeadzone = (float)Mouse3DController::State::MaxTranslationDeadzone; | ||||
| const float Mouse3DController::State::DefaultRotationDeadzone = 0.5f * Mouse3DController::State::MaxRotationDeadzone; | ||||
| 
 | ||||
| Mouse3DController::State::State() | ||||
|  | @ -78,7 +78,15 @@ bool Mouse3DController::State::process_mouse_wheel() | |||
| { | ||||
|     if (m_mouse_wheel_counter == 0) | ||||
|         return false; | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| #if ENABLE_QUEUE_MAX_SIZE | ||||
|     else if (!m_rotation.queue.empty()) | ||||
| #else | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     else if (!m_rotation.empty()) | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| #endif // ENABLE_QUEUE_MAX_SIZE
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     { | ||||
|         --m_mouse_wheel_counter; | ||||
|         return true; | ||||
|  | @ -99,14 +107,35 @@ bool Mouse3DController::State::apply(Camera& camera) | |||
| 
 | ||||
|     if (has_translation()) | ||||
|     { | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| #if ENABLE_QUEUE_MAX_SIZE | ||||
|         const Vec3d& translation = m_translation.queue.front(); | ||||
|         camera.set_target(camera.get_target() + m_translation_params.scale * (translation(0) * camera.get_dir_right() + translation(1) * camera.get_dir_forward() + translation(2) * camera.get_dir_up())); | ||||
|         m_translation.queue.pop(); | ||||
| #else | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         const Vec3d& translation = m_translation.front(); | ||||
|         camera.set_target(camera.get_target() + m_translation_params.scale * (translation(0) * camera.get_dir_right() + translation(1) * camera.get_dir_forward() + translation(2) * camera.get_dir_up())); | ||||
|         m_translation.pop(); | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| #endif // ENABLE_QUEUE_MAX_SIZE
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         ret = true; | ||||
|     } | ||||
| 
 | ||||
|     if (has_rotation()) | ||||
|     { | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| #if ENABLE_QUEUE_MAX_SIZE | ||||
|         const Vec3f& rotation = m_rotation.queue.front(); | ||||
|         float theta = m_rotation_params.scale * rotation(0); | ||||
|         float phi = m_rotation_params.scale * rotation(2); | ||||
|         float sign = camera.inverted_phi ? -1.0f : 1.0f; | ||||
|         camera.phi += sign * phi; | ||||
|         camera.set_theta(camera.get_theta() + theta, wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA); | ||||
|         m_rotation.queue.pop(); | ||||
| #else | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         const Vec3f& rotation = m_rotation.front(); | ||||
|         float theta = m_rotation_params.scale * rotation(0); | ||||
|         float phi = m_rotation_params.scale * rotation(2); | ||||
|  | @ -114,12 +143,27 @@ bool Mouse3DController::State::apply(Camera& camera) | |||
|         camera.phi += sign * phi; | ||||
|         camera.set_theta(camera.get_theta() + theta, wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA); | ||||
|         m_rotation.pop(); | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| #endif // ENABLE_QUEUE_MAX_SIZE
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| 
 | ||||
|         ret = true; | ||||
|     } | ||||
| 
 | ||||
|     if (has_button()) | ||||
|     { | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| #if ENABLE_QUEUE_MAX_SIZE | ||||
|         unsigned int button = m_buttons.queue.front(); | ||||
|         switch (button) | ||||
|         { | ||||
|         case 0: { camera.update_zoom(1.0); break; } | ||||
|         case 1: { camera.update_zoom(-1.0); break; } | ||||
|         default: { break; } | ||||
|         } | ||||
|         m_buttons.queue.pop(); | ||||
| #else | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         unsigned int button = m_buttons.front(); | ||||
|         switch (button) | ||||
|         { | ||||
|  | @ -128,6 +172,9 @@ bool Mouse3DController::State::apply(Camera& camera) | |||
|         default: { break; } | ||||
|         } | ||||
|         m_buttons.pop(); | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| #endif // ENABLE_QUEUE_MAX_SIZE
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         ret = true; | ||||
|     } | ||||
| 
 | ||||
|  | @ -271,21 +318,14 @@ void Mouse3DController::render_settings_dialog(unsigned int canvas_width, unsign | |||
|     ImGui::InputInt2("Rotation##4", rotation_size, ImGuiInputTextFlags_ReadOnly); | ||||
|     ImGui::InputInt2("Buttons", buttons_size, ImGuiInputTextFlags_ReadOnly); | ||||
| 
 | ||||
| /*
 | ||||
|     int translation_size = (int)m_state.get_translation_queue_size(); | ||||
|     int translation_max_size = (int)m_state.get_translation_queue_max_size(); | ||||
|     int rotation_size = (int)m_state.get_rotation_queue_size(); | ||||
|     int rotation_max_size = (int)m_state.get_rotation_queue_max_size(); | ||||
|     int buttons_size = (int)m_state.get_buttons_queue_size(); | ||||
|     int buttons_max_size = (int)m_state.get_buttons_queue_max_size(); | ||||
| 
 | ||||
|     ImGui::InputInt("Translation size", &translation_size, 0, 0, ImGuiInputTextFlags_ReadOnly); | ||||
|     ImGui::InputInt("Translation max", &translation_max_size, 0, 0, ImGuiInputTextFlags_ReadOnly); | ||||
|     ImGui::InputInt("Rotation size", &rotation_size, 0, 0, ImGuiInputTextFlags_ReadOnly); | ||||
|     ImGui::InputInt("Rotation max", &rotation_max_size, 0, 0, ImGuiInputTextFlags_ReadOnly); | ||||
|     ImGui::InputInt("Button size", &buttons_size, 0, 0, ImGuiInputTextFlags_ReadOnly); | ||||
|     ImGui::InputInt("Button max", &buttons_max_size, 0, 0, ImGuiInputTextFlags_ReadOnly); | ||||
| */ | ||||
| #if ENABLE_QUEUE_MAX_SIZE | ||||
|     int queue_size = (int)m_state.get_queues_max_size(); | ||||
|     if (ImGui::InputInt("Max size", &queue_size, 1, 1, ImGuiInputTextFlags_ReadOnly)) | ||||
|     { | ||||
|         if (queue_size > 0) | ||||
|             m_state.set_queues_max_size(queue_size); | ||||
|     } | ||||
| #endif // ENABLE_QUEUE_MAX_SIZE
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| #endif // ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
 | ||||
| 
 | ||||
|  | @ -312,6 +352,10 @@ bool Mouse3DController::connect_device() | |||
|     unsigned short product_id = 0; | ||||
| 
 | ||||
| #if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     unsigned short usage_page = 0; | ||||
|     unsigned short usage = 0; | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|     hid_device_info* cur = devices; | ||||
|     while (cur != nullptr) | ||||
|     { | ||||
|  | @ -344,6 +388,12 @@ bool Mouse3DController::connect_device() | |||
|                 if (_3DCONNEXION_DEVICES[i] == current->product_id) | ||||
|                 { | ||||
|                     product_id = current->product_id; | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| #if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT | ||||
|                     usage_page = current->usage_page; | ||||
|                     usage = current->usage; | ||||
| #endif // ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|                     break; | ||||
|                 } | ||||
|             } | ||||
|  | @ -369,11 +419,31 @@ bool Mouse3DController::connect_device() | |||
| 
 | ||||
|     if (m_device != nullptr) | ||||
|     { | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         std::vector<wchar_t> manufacturer(1024, 0); | ||||
|         hid_get_manufacturer_string(m_device, manufacturer.data(), 1024); | ||||
|         m_device_str = boost::nowide::narrow(manufacturer.data()); | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| 
 | ||||
|         std::vector<wchar_t> product(1024, 0); | ||||
|         hid_get_product_string(m_device, product.data(), 1024); | ||||
|         m_device_str = boost::nowide::narrow(product.data()); | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         m_device_str += "/" + boost::nowide::narrow(product.data()); | ||||
| //        m_device_str = boost::nowide::narrow(product.data());
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| 
 | ||||
|         BOOST_LOG_TRIVIAL(info) << "Connected device: " << m_device_str; | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| #if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT | ||||
|         std::cout << std::endl << "Connected device:" << std::endl; | ||||
|         std::cout << "Manufacturer/product..........: " << m_device_str << std::endl; | ||||
|         std::cout << "Manufacturer id/product id....: " << vendor_id << "/" << product_id << std::endl; | ||||
|         std::cout << "Manufacturer id/product id hex: " << std::hex << vendor_id << "/" << product_id << std::dec << std::endl; | ||||
|         std::cout << "Usage page....................: " << usage_page << std::endl; | ||||
|         std::cout << "Usage.........................: " << usage << std::endl; | ||||
| #endif // ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| 
 | ||||
| 
 | ||||
|         // get device parameters from the config, if present
 | ||||
|         double translation_speed = 1.0; | ||||
|  |  | |||
|  | @ -11,6 +11,10 @@ | |||
| #include <mutex> | ||||
| #include <vector> | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| #define ENABLE_QUEUE_MAX_SIZE 1 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| 
 | ||||
| namespace Slic3r { | ||||
| namespace GUI { | ||||
| 
 | ||||
|  | @ -38,9 +42,27 @@ class Mouse3DController | |||
|             CustomParameters(Number scale, Number deadzone) : scale(scale), deadzone(deadzone) {} | ||||
|         }; | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| #if ENABLE_QUEUE_MAX_SIZE | ||||
|         template <class T> | ||||
|         struct InputQueue | ||||
|         { | ||||
|             size_t max_size{ 20 }; | ||||
|             std::queue<T> queue; | ||||
|         }; | ||||
| 
 | ||||
|         InputQueue<Vec3d> m_translation; | ||||
|         InputQueue<Vec3f> m_rotation; | ||||
|         InputQueue<unsigned int> m_buttons; | ||||
| #else | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         std::queue<Vec3d> m_translation; | ||||
|         std::queue<Vec3f> m_rotation; | ||||
|         std::queue<unsigned int> m_buttons; | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| #endif // ENABLE_QUEUE_MAX_SIZE
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| 
 | ||||
| 
 | ||||
|         CustomParameters<double> m_translation_params; | ||||
|         CustomParameters<float> m_rotation_params; | ||||
|  | @ -68,48 +90,92 @@ class Mouse3DController | |||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         void append_translation(const Vec3d& translation) | ||||
|         { | ||||
| #if ENABLE_QUEUE_MAX_SIZE | ||||
|             while (m_translation.queue.size() >= m_translation.max_size) | ||||
|             { | ||||
|                 m_translation.queue.pop(); | ||||
|             } | ||||
|             m_translation.queue.push(translation); | ||||
| #if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT | ||||
|             m_translation_queue_max_size = std::max(m_translation_queue_max_size, (unsigned int)m_translation.queue.size()); | ||||
| #endif // ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
 | ||||
| #else | ||||
|             m_translation.push(translation); | ||||
| #if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT | ||||
|             m_translation_queue_max_size = std::max(m_translation_queue_max_size, (unsigned int)m_translation.size()); | ||||
| #endif // ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
 | ||||
| #endif // ENABLE_QUEUE_MAX_SIZE
 | ||||
|         } | ||||
| 
 | ||||
|         void append_rotation(const Vec3f& rotation) | ||||
|         { | ||||
| #if ENABLE_QUEUE_MAX_SIZE | ||||
|             while (m_rotation.queue.size() >= m_rotation.max_size) | ||||
|             { | ||||
|                 m_rotation.queue.pop(); | ||||
|             } | ||||
|             m_rotation.queue.push(rotation); | ||||
| #if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT | ||||
|             m_rotation_queue_max_size = std::max(m_rotation_queue_max_size, (unsigned int)m_rotation.queue.size()); | ||||
| #endif // ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
 | ||||
|             if (rotation(0) != 0.0f) | ||||
|                 ++m_mouse_wheel_counter; | ||||
| #else | ||||
|             m_rotation.push(rotation); | ||||
| #if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT | ||||
|             m_rotation_queue_max_size = std::max(m_rotation_queue_max_size, (unsigned int)m_rotation.size()); | ||||
| #endif // ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
 | ||||
|             if (rotation(0) != 0.0f) | ||||
|                 ++m_mouse_wheel_counter; | ||||
| #endif // ENABLE_QUEUE_MAX_SIZE
 | ||||
|         } | ||||
|          | ||||
|         void append_button(unsigned int id) | ||||
|         { | ||||
| #if ENABLE_QUEUE_MAX_SIZE | ||||
|             while (m_buttons.queue.size() >= m_buttons.max_size) | ||||
|             { | ||||
|                 m_buttons.queue.pop(); | ||||
|             } | ||||
|             m_buttons.queue.push(id); | ||||
| #if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT | ||||
|             m_buttons_queue_max_size = std::max(m_buttons_queue_max_size, (unsigned int)m_buttons.queue.size()); | ||||
| #endif // ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
 | ||||
| #else | ||||
|             m_buttons.push(id); | ||||
| #if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT | ||||
|             m_buttons_queue_max_size = std::max(m_buttons_queue_max_size, (unsigned int)m_buttons.size()); | ||||
| #endif // ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
 | ||||
| #endif // ENABLE_QUEUE_MAX_SIZE
 | ||||
|         } | ||||
| 
 | ||||
| //        void append_translation(const Vec3d& translation) { m_translation.push(translation); }
 | ||||
| //        void append_rotation(const Vec3f& rotation)
 | ||||
| //        {
 | ||||
| //            m_rotation.push(rotation);
 | ||||
| //            if (rotation(0) != 0.0f)
 | ||||
| //                ++m_mouse_wheel_counter;
 | ||||
| //        }
 | ||||
| //        void append_button(unsigned int id) { m_buttons.push(id); }
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| #if ENABLE_QUEUE_MAX_SIZE | ||||
|         bool has_translation() const { return !m_translation.queue.empty(); } | ||||
|         bool has_rotation() const { return !m_rotation.queue.empty(); } | ||||
|         bool has_button() const { return !m_buttons.queue.empty(); } | ||||
| #else | ||||
|         bool has_translation() const { return !m_translation.empty(); } | ||||
|         bool has_rotation() const { return !m_rotation.empty(); } | ||||
|         bool has_button() const { return !m_buttons.empty(); } | ||||
| #endif // ENABLE_QUEUE_MAX_SIZE
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| 
 | ||||
| #if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| #if ENABLE_QUEUE_MAX_SIZE | ||||
|         Vec3d get_translation() const { return has_translation() ? m_translation.queue.front() : Vec3d::Zero(); } | ||||
|         Vec3f get_rotation() const { return has_rotation() ? m_rotation.queue.front() : Vec3f::Zero(); } | ||||
|         unsigned int get_button() const { return has_button() ? m_buttons.queue.front() : 0; } | ||||
| #else | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
|         Vec3d get_translation() const { return has_translation() ? m_translation.front() : Vec3d::Zero(); } | ||||
|         Vec3f get_rotation() const { return has_rotation() ? m_rotation.front() : Vec3f::Zero(); } | ||||
|         unsigned int get_button() const { return has_button() ? m_buttons.front() : 0; } | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| #endif // ENABLE_QUEUE_MAX_SIZE
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| #endif // ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
 | ||||
| 
 | ||||
|         bool process_mouse_wheel(); | ||||
|  | @ -128,14 +194,41 @@ class Mouse3DController | |||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| #if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT | ||||
| #if ENABLE_QUEUE_MAX_SIZE | ||||
|         unsigned int get_translation_queue_size() const { return (unsigned int)m_translation.queue.size(); } | ||||
|         unsigned int get_rotation_queue_size() const { return (unsigned int)m_rotation.queue.size(); } | ||||
|         unsigned int get_buttons_queue_size() const { return (unsigned int)m_buttons.queue.size(); } | ||||
| #else | ||||
|         unsigned int get_translation_queue_size() const { return (unsigned int)m_translation.size(); } | ||||
|         unsigned int get_rotation_queue_size() const { return (unsigned int)m_rotation.size(); } | ||||
|         unsigned int get_buttons_queue_size() const { return (unsigned int)m_buttons.size(); } | ||||
| #endif // ENABLE_QUEUE_MAX_SIZE
 | ||||
| 
 | ||||
|         unsigned int get_translation_queue_max_size() const { return m_translation_queue_max_size; } | ||||
|         unsigned int get_rotation_queue_max_size() const { return m_rotation_queue_max_size; } | ||||
|         unsigned int get_buttons_queue_max_size() const { return m_buttons_queue_max_size; } | ||||
| #endif // ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| 
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| #if ENABLE_QUEUE_MAX_SIZE | ||||
|         size_t get_queues_max_size() const { return m_translation.max_size; } | ||||
|         void set_queues_max_size(size_t size) | ||||
|         { | ||||
|             if (size > 0) | ||||
|             { | ||||
|                 std::cout << "New queues max size: " << size << std::endl; | ||||
| 
 | ||||
|                 m_translation.max_size = size; | ||||
|                 m_rotation.max_size = size; | ||||
|                 m_buttons.max_size = size; | ||||
| 
 | ||||
|                 m_translation_queue_max_size = 0; | ||||
|                 m_rotation_queue_max_size = 0; | ||||
|                 m_buttons_queue_max_size = 0; | ||||
|             } | ||||
|         } | ||||
| #endif // ENABLE_QUEUE_MAX_SIZE
 | ||||
| //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 | ||||
| 
 | ||||
|         // return true if any change to the camera took place
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Enrico Turri
						Enrico Turri