Skip to content

Commit

Permalink
Merge GUI for dater/counter equations
Browse files Browse the repository at this point in the history
  • Loading branch information
Lecrapouille committed May 18, 2024
1 parent 8249100 commit b821463
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
55 changes: 28 additions & 27 deletions src/Editor/DearImGui/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,9 @@ void Editor::menu()
{
m_states.do_syslin = true;
}
if (ImGui::MenuItem("Show Dater equation", nullptr, false))
if (ImGui::MenuItem("Show dater or counter equations", nullptr, false))
{
m_states.do_dater = true;
}
if (ImGui::MenuItem("Show Counter equation", nullptr, false))
{
m_states.do_counter = true;
m_states.do_counter_or_dater = true;
}
if (ImGui::MenuItem("Show adjacency matrices", nullptr, false))
{
Expand Down Expand Up @@ -381,7 +377,7 @@ void Editor::menu()
if (m_states.do_import_from != nullptr) { importNetFrom(*m_states.do_import_from); }
if (m_states.do_screenshot) { takeScreenshot(); }
if (m_states.do_adjency) { showAdjacencyMatrices(); }
if (m_states.do_counter || m_states.do_dater) { showCounterOrDaterequation(); }
if (m_states.do_counter_or_dater) { showCounterOrDaterEquation(); }
if (m_states.do_syslin) { showDynamicLinearSystem(); }
if (m_states.do_find_critical_cycle) { showCriticalCycles(); }
if (m_states.request_quitting)
Expand Down Expand Up @@ -437,41 +433,46 @@ void Editor::showAdjacencyMatrices() const
}

//------------------------------------------------------------------------------
void Editor::showCounterOrDaterequation() const
void Editor::showCounterOrDaterEquation() const
{
const char* title = m_states.do_counter ? "Counter Equation": "Dater Equation";
ImGui::OpenPopup(title);
static bool use_caption = false;
static bool tropical_notation = false;
static bool show_matrix = false;

ImGui::OpenPopup("Counter or dater equations");
ImGui::SetNextWindowPos(m_states.viewport_center, ImGuiCond_Appearing,
ImVec2(0.5f, 0.5f));
if (ImGui::BeginPopupModal(title, NULL, ImGuiWindowFlags_AlwaysAutoResize))
if (ImGui::BeginPopupModal("Counter or dater equations", NULL,
ImGuiWindowFlags_AlwaysAutoResize))
{
static bool use_caption = false;
static bool maxplus_notation = false;
static bool show_matrix = false;
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
ImGui::Checkbox(m_states.do_counter
? "Use (min,+) operator"
: "Use (max,+) operator", &maxplus_notation);
ImGui::Checkbox("Use (min,+) operator", &tropical_notation);
ImGui::SameLine();
ImGui::Checkbox("Use caption", &use_caption);
ImGui::PopStyleVar();

ImGui::Separator();
if (m_states.do_counter)
{
ImGui::Text("%s", showCounterEquation(
m_net, "", use_caption, maxplus_notation).str().c_str());
}
else
ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_None;
if (ImGui::BeginTabBar("tab counter or dater", tab_bar_flags))
{
ImGui::Text("%s", showDaterEquation(
m_net, "", use_caption, maxplus_notation).str().c_str());
if (ImGui::BeginTabItem("Counter"))
{
ImGui::Text("%s", showCounterEquation(m_net, "", use_caption, tropical_notation)
.str().c_str());
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Dater"))
{
ImGui::Text("%s", showDaterEquation(m_net, "", use_caption, tropical_notation)
.str().c_str());
ImGui::EndTabItem();
}
ImGui::EndTabBar();
}

if (ImGui::Button("OK", ImVec2(120, 0)))
{
ImGui::CloseCurrentPopup();
m_states.do_counter = m_states.do_dater = false;
m_states.do_counter_or_dater = false;
}
ImGui::EndPopup();
}
Expand Down
5 changes: 2 additions & 3 deletions src/Editor/DearImGui/Editor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class Editor: public PetriNetEditor, public Application

void showCriticalCycles();// const;
void showDynamicLinearSystem() const;
void showCounterOrDaterequation() const;
void showCounterOrDaterEquation() const;
void showAdjacencyMatrices() const;

private: // Petri net services
Expand Down Expand Up @@ -130,8 +130,7 @@ class Editor: public PetriNetEditor, public Application
// ************************************************************************
struct States
{
bool do_dater = false;
bool do_counter = false;
bool do_counter_or_dater = false;
bool do_find_critical_cycle = false;
bool do_syslin = false;
bool do_adjency = false;
Expand Down

0 comments on commit b821463

Please sign in to comment.