<commit_before>#include "ProbeInteraction.h"

#include "ProbeGlCalls.h"
#include "compositing/CompositingCalls.h"

#include "mmcore/CoreInstance.h"
#include "mmcore/EventCall.h"

#include "ProbeEvents.h"

#include <imgui.h>
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui_internal.h>
#include "imgui_impl_opengl3.h"
#include "imgui_stdlib.h"

megamol::probe_gl::ProbeInteraction::ProbeInteraction()
    : Renderer3DModule_2()
    , m_version(0)
    , m_cursor_x(0)
    , m_cursor_y(0)
    , m_cursor_x_lastRightClick(0)
    , m_cursor_y_lastRightClick(0)
    , m_open_context_menu(false)
    , m_open_showMenu_dropdown(false)
    , m_open_probeMenu_dropdown(false)
    , m_open_dataMenu_dropdown(false)
    , m_open_dataFilterByDepth_popup(false)
    , m_show_probes(true)
    , m_show_hull(true)
    , m_show_glyphs(true)
    , last_active_probe_id(-1)
    , m_probe_fbo_slot("getProbeFBO", "")
    , m_hull_fbo_slot("getHullFBO", "")
    , m_glyph_fbo_slot("getGlyphFBO", "")
    , m_event_write_slot("deployInteractionEvents", "") {
    this->m_probe_fbo_slot.SetCompatibleCall<compositing::CallFramebufferGLDescription>();
    this->MakeSlotAvailable(&this->m_probe_fbo_slot);

    this->m_hull_fbo_slot.SetCompatibleCall<compositing::CallFramebufferGLDescription>();
    this->MakeSlotAvailable(&this->m_hull_fbo_slot);

    this->m_glyph_fbo_slot.SetCompatibleCall<compositing::CallFramebufferGLDescription>();
    this->MakeSlotAvailable(&this->m_glyph_fbo_slot);

    this->m_event_write_slot.SetCompatibleCall<megamol::core::CallEventDescription>();
    this->MakeSlotAvailable(&this->m_event_write_slot);
}

megamol::probe_gl::ProbeInteraction::~ProbeInteraction() { this->Release(); }

bool megamol::probe_gl::ProbeInteraction::OnMouseButton(
    core::view::MouseButton button, core::view::MouseButtonAction action, core::view::Modifiers mods) {

    // Get event storage to queue new events
    auto call_event_storage = this->m_event_write_slot.CallAs<core::CallEvent>();
    if (call_event_storage == NULL) return false;
    if ((!(*call_event_storage)(0))) return false;
    auto event_collection = call_event_storage->getData();

    if (button == core::view::MouseButton::BUTTON_LEFT && action == core::view::MouseButtonAction::PRESS &&
        mods.none()) {
        m_selected_probes.clear();

        if (last_active_probe_id > 0) {
            // create new selection
            auto evt = std::make_unique<ProbeSelectExclusive>(
                this->GetCoreInstance()->GetFrameID(), static_cast<uint32_t>(last_active_probe_id));
            event_collection->add<ProbeSelectExclusive>(std::move(evt));
        } else {
            auto evt = std::make_unique<ProbeClearSelection>(this->GetCoreInstance()->GetFrameID());
            event_collection->add<ProbeClearSelection>(std::move(evt));
        }

        return true;

        m_open_context_menu = false;
    } else if (button == core::view::MouseButton::BUTTON_LEFT && action == core::view::MouseButtonAction::PRESS &&
               mods.test(core::view::Modifier::SHIFT)) {
        if (last_active_probe_id > 0) {
            // add to current selection
            m_selected_probes.push_back(last_active_probe_id);
            auto evt = std::make_unique<ProbeSelectToggle>(
                this->GetCoreInstance()->GetFrameID(), static_cast<uint32_t>(last_active_probe_id));
            event_collection->add<ProbeSelectToggle>(std::move(evt));

            return true;
        }
    } else if (button == core::view::MouseButton::BUTTON_RIGHT) // && action == core::view::MouseButtonAction::PRESS)
    {
        m_mouse_button_states[button] = (action == core::view::MouseButtonAction::PRESS) ? true
                                        : (action == core::view::MouseButtonAction::RELEASE)
                                            ? false
                                            : m_mouse_button_states[button];


        if (action == core::view::MouseButtonAction::PRESS) {<commit_msg>Log probe selection on console<commit_after>#include "ProbeInteraction.h"

#include "ProbeGlCalls.h"
#include "compositing/CompositingCalls.h"

#include "mmcore/CoreInstance.h"
#include "mmcore/EventCall.h"

#include "ProbeEvents.h"

#include <imgui.h>
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui_internal.h>
#include "imgui_impl_opengl3.h"
#include "imgui_stdlib.h"

megamol::probe_gl::ProbeInteraction::ProbeInteraction()
    : Renderer3DModule_2()
    , m_version(0)
    , m_cursor_x(0)
    , m_cursor_y(0)
    , m_cursor_x_lastRightClick(0)
    , m_cursor_y_lastRightClick(0)
    , m_open_context_menu(false)
    , m_open_showMenu_dropdown(false)
    , m_open_probeMenu_dropdown(false)
    , m_open_dataMenu_dropdown(false)
    , m_open_dataFilterByDepth_popup(false)
    , m_show_probes(true)
    , m_show_hull(true)
    , m_show_glyphs(true)
    , last_active_probe_id(-1)
    , m_probe_fbo_slot("getProbeFBO", "")
    , m_hull_fbo_slot("getHullFBO", "")
    , m_glyph_fbo_slot("getGlyphFBO", "")
    , m_event_write_slot("deployInteractionEvents", "") {
    this->m_probe_fbo_slot.SetCompatibleCall<compositing::CallFramebufferGLDescription>();
    this->MakeSlotAvailable(&this->m_probe_fbo_slot);

    this->m_hull_fbo_slot.SetCompatibleCall<compositing::CallFramebufferGLDescription>();
    this->MakeSlotAvailable(&this->m_hull_fbo_slot);

    this->m_glyph_fbo_slot.SetCompatibleCall<compositing::CallFramebufferGLDescription>();
    this->MakeSlotAvailable(&this->m_glyph_fbo_slot);

    this->m_event_write_slot.SetCompatibleCall<megamol::core::CallEventDescription>();
    this->MakeSlotAvailable(&this->m_event_write_slot);
}

megamol::probe_gl::ProbeInteraction::~ProbeInteraction() { this->Release(); }

bool megamol::probe_gl::ProbeInteraction::OnMouseButton(
    core::view::MouseButton button, core::view::MouseButtonAction action, core::view::Modifiers mods) {

    // Get event storage to queue new events
    auto call_event_storage = this->m_event_write_slot.CallAs<core::CallEvent>();
    if (call_event_storage == NULL) return false;
    if ((!(*call_event_storage)(0))) return false;
    auto event_collection = call_event_storage->getData();

    if (button == core::view::MouseButton::BUTTON_LEFT && action == core::view::MouseButtonAction::PRESS &&
        mods.none()) {
        m_selected_probes.clear();

        if (last_active_probe_id > 0) {
            // create new selection
            auto evt = std::make_unique<ProbeSelectExclusive>(
                this->GetCoreInstance()->GetFrameID(), static_cast<uint32_t>(last_active_probe_id));
            event_collection->add<ProbeSelectExclusive>(std::move(evt));
            megamol::core::utility::log::Log::DefaultLog.WriteMsg(megamol::core::utility::log::Log::LEVEL_INFO,
                "Selected probe: %s\n", std::to_string(last_active_probe_id));
        } else {
            auto evt = std::make_unique<ProbeClearSelection>(this->GetCoreInstance()->GetFrameID());
            event_collection->add<ProbeClearSelection>(std::move(evt));
        }

        return true;

        m_open_context_menu = false;
    } else if (button == core::view::MouseButton::BUTTON_LEFT && action == core::view::MouseButtonAction::PRESS &&
               mods.test(core::view::Modifier::SHIFT)) {
        if (last_active_probe_id > 0) {
            // add to current selection
            m_selected_probes.push_back(last_active_probe_id);
            auto evt = std::make_unique<ProbeSelectToggle>(
                this->GetCoreInstance()->GetFrameID(), static_cast<uint32_t>(last_active_probe_id));
            event_collection->add<ProbeSelectToggle>(std::move(evt));

            return true;
        }
    } else if (button == core::view::MouseButton::BUTTON_RIGHT) // && action == core::view::MouseButtonAction::PRESS)
    {
        m_mouse_button_states[button] = (action == core::view::MouseButtonAction::PRESS) ? true
                                        : (action == core::view::MouseButtonAction::RELEASE)
                                            ? false
                                            : m_mouse_button_states[button];


        if (action == core::view::MouseButtonAction::PRESS) {
{'fraction_non_alphanumeric': 0.13299951148021494, 'fraction_numerical': 0.0039081582804103565, 'mean_word_length': 3.8455621301775147, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 85, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1548263', 'n_tokens_mistral': 2646, 'n_tokens_neox': 2611, 'n_words': 309}