ItemBase* ScenePickingHandler::pick(const QPoint& point) { if (!m_project.has_trace_context()) { RENDERER_LOG_INFO("the scene must be rendering or must have been rendered at least once for picking to be available."); return 0; } const Vector2i pix = m_mouse_tracker.widget_to_pixel(point); const Vector2d ndc = m_mouse_tracker.widget_to_ndc(point); const ScenePicker scene_picker(m_project.get_trace_context()); const ScenePicker::PickingResult result = scene_picker.pick(ndc); stringstream sstr; sstr << "picking details:" << endl; sstr << " pixel coords " << pix.x << ", " << pix.y << endl; sstr << " ndc coords " << ndc.x << ", " << ndc.y << endl; sstr << " world coords " << result.m_point.x << ", " << result.m_point.y << ", " << result.m_point.z << endl; sstr << " depth " << result.m_distance << endl; sstr << " primitive type " << get_primitive_type_name(result.m_primitive_type) << endl; sstr << print_entity(" camera ", result.m_camera) << endl; sstr << print_entity(" assembly inst. ", result.m_assembly_instance) << endl; sstr << print_entity(" assembly ", result.m_assembly) << endl; sstr << print_entity(" object inst. ", result.m_object_instance) << endl; sstr << print_entity(" object ", result.m_object) << endl; sstr << print_entity(" material ", result.m_material) << endl; sstr << print_entity(" surface shader ", result.m_surface_shader) << endl; sstr << print_entity(" bsdf ", result.m_bsdf) << endl; sstr << print_entity(" bssrdf ", result.m_bssrdf) << endl; sstr << print_entity(" edf ", result.m_edf); RENDERER_LOG_INFO("%s", sstr.str().c_str()); emit signal_entity_picked(result); const QString picking_mode = m_picking_mode_combo->itemData(m_picking_mode_combo->currentIndex()).value<QString>(); const Entity* picked_entity = get_picked_entity(result, picking_mode); ItemBase* item; if (picked_entity) { item = m_project_explorer.select_entity(picked_entity->get_uid()); } else { m_project_explorer.clear_selection(); item = 0; } m_widget->setFocus(); return item; }
void RubberTool::execute() { sp_->bind_select(rb_); sp_->set_scene_tool(tool_); if (Oc::helpmode()) { rb_->help(); }else if (sel_) { sel_->execute(); } }
void HandlerTool::execute() { sp_->bind_select(h_); sp_->set_scene_tool(tool_); if (Oc::helpmode()) { if (h_) { h_->help(); }else{ sp_->help(); } } }
void ScenePickingHandler::pick(const QPoint& point) { if (!m_project.has_trace_context()) { RENDERER_LOG_INFO("the scene must be rendering or must have been rendered at least once for picking to be available."); return; } const Vector2i pix = m_mouse_tracker.widget_to_pixel(point); const Vector2d ndc = m_mouse_tracker.widget_to_ndc(point); const ScenePicker scene_picker(m_project.get_trace_context()); const ScenePicker::PickingResult result = scene_picker.pick(ndc); stringstream sstr; sstr << "picking details:" << endl; sstr << " pixel coords " << pix.x << ", " << pix.y << endl; sstr << " ndc coords " << ndc.x << ", " << ndc.y << endl; print_entity(sstr, " camera ", result.m_camera); print_entity(sstr, " assembly inst. ", result.m_assembly_instance); print_entity(sstr, " assembly ", result.m_assembly); print_entity(sstr, " object inst. ", result.m_object_instance); print_entity(sstr, " object ", result.m_object); print_entity(sstr, " material ", result.m_material); print_entity(sstr, " surface shader ", result.m_surface_shader); print_entity(sstr, " bsdf ", result.m_bsdf); print_entity(sstr, " edf ", result.m_edf); RENDERER_LOG_INFO("%s", sstr.str().c_str()); const QString picking_mode = m_picking_mode_combo->itemData(m_picking_mode_combo->currentIndex()).value<QString>(); const Entity* picked_entity = get_picked_entity(result, picking_mode); if (picked_entity) m_project_explorer.highlight_entity(picked_entity->get_uid()); else m_project_explorer.clear_highlighting(); }