This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#include "PivotGui.h"
|
#include "PivotGui.h"
|
||||||
|
|
||||||
|
#include "Gauss.h"
|
||||||
#include "Matrix.h"
|
#include "Matrix.h"
|
||||||
#include "Solver.h"
|
#include "Solver.h"
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
@@ -55,9 +56,8 @@ void PivotGui::Render() {
|
|||||||
static bool refresh = true;
|
static bool refresh = true;
|
||||||
|
|
||||||
// divisions des fenetres
|
// divisions des fenetres
|
||||||
ImVec2 topLeftWindowSize(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.8f);
|
ImVec2 topLeftWindowSize(io.DisplaySize.x * 0.5f, io.DisplaySize.y);
|
||||||
ImVec2 topRightWindowSize(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.8f);
|
ImVec2 topRightWindowSize(io.DisplaySize.x * 0.5f, io.DisplaySize.y);
|
||||||
ImVec2 bottomWindowSize(io.DisplaySize.x, io.DisplaySize.y * 0.2f);
|
|
||||||
|
|
||||||
// Begin fenetre top left
|
// Begin fenetre top left
|
||||||
ImGui::SetNextWindowSize(topLeftWindowSize);
|
ImGui::SetNextWindowSize(topLeftWindowSize);
|
||||||
@@ -85,7 +85,7 @@ void PivotGui::Render() {
|
|||||||
|
|
||||||
ImGui::NewLine();
|
ImGui::NewLine();
|
||||||
|
|
||||||
ImGui::BeginChild("MatriceInitiale", ImVec2(topLeftWindowSize.x, io.DisplaySize.y * 0.7f), false);
|
// ImGui::BeginChild("MatriceInitiale", ImVec2(topLeftWindowSize.x, io.DisplaySize.y * 0.7f), false);
|
||||||
|
|
||||||
// Resize matrixValues and initialize new elements to 0
|
// Resize matrixValues and initialize new elements to 0
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ void PivotGui::Render() {
|
|||||||
if (x > 0)
|
if (x > 0)
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::PushID(y * matrixSizeX + x);
|
ImGui::PushID(y * matrixSizeX + x);
|
||||||
ImGui::PushItemWidth(30); // Adjust this value to change the cell size
|
ImGui::PushItemWidth(60); // Adjust this value to change the cell size
|
||||||
if (ImGui::InputInt("", &matrixValues[y][x], 0, 0, ImGuiInputTextFlags_CharsDecimal))
|
if (ImGui::InputInt("", &matrixValues[y][x], 0, 0, ImGuiInputTextFlags_CharsDecimal))
|
||||||
refresh = true;
|
refresh = true;
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
@@ -109,12 +109,30 @@ void PivotGui::Render() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display the equationsResult strings in the GUI if they are not empty
|
// ImGui::EndChild(); // End Matrice initiale
|
||||||
if (!equationsResultImage.empty()) {
|
|
||||||
ImGui::TextWrapped(equationsResultImage.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::EndChild(); // End Matrice initiale
|
ImGui::NewLine();
|
||||||
|
|
||||||
|
ImGui::Text("Matrice échelonnée:");
|
||||||
|
|
||||||
|
// Convert the "result" string back to a matrix
|
||||||
|
Matrix resultMatrix = LoadMatrixFromStdVect(matrixValues);
|
||||||
|
|
||||||
|
// Apply the Gauss-Jordan elimination to the matrix
|
||||||
|
Gauss::GaussJordan(resultMatrix, true, true); // Assuming you want to reduce and normalize the matrix
|
||||||
|
|
||||||
|
// Display the matrix
|
||||||
|
for (std::size_t i = 0; i < resultMatrix.GetRawCount(); i++) {
|
||||||
|
for (std::size_t j = 0; j < resultMatrix.GetColumnCount(); j++) {
|
||||||
|
ImGui::PushID(i * resultMatrix.GetColumnCount() + j);
|
||||||
|
if (ImGui::Button(ElementToString(resultMatrix.at(i, j)).c_str(), ImVec2(70, 70))) { // Adjust the size as needed
|
||||||
|
// Handle button click here if needed
|
||||||
|
}
|
||||||
|
ImGui::PopID();
|
||||||
|
if (j < resultMatrix.GetColumnCount() - 1)
|
||||||
|
ImGui::SameLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::End(); // End fenetre top left
|
ImGui::End(); // End fenetre top left
|
||||||
|
|
||||||
@@ -128,16 +146,6 @@ void PivotGui::Render() {
|
|||||||
|
|
||||||
static std::string result = "";
|
static std::string result = "";
|
||||||
|
|
||||||
ImGui::TextWrapped(result.c_str());
|
|
||||||
|
|
||||||
ImGui::End(); // End fenetre top right
|
|
||||||
|
|
||||||
// Begin fenetre bas
|
|
||||||
ImGui::SetNextWindowSize(bottomWindowSize);
|
|
||||||
ImGui::SetNextWindowPos(ImVec2(0, io.DisplaySize.y * 0.8f)); // Position at the bottom-left corner
|
|
||||||
ImGui::Begin("Bottom Part", nullptr,
|
|
||||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar);
|
|
||||||
|
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
|
|
||||||
// Calculate the kernel and image
|
// Calculate the kernel and image
|
||||||
@@ -160,7 +168,15 @@ void PivotGui::Render() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
refresh = false;
|
refresh = false;
|
||||||
ImGui::End(); // End fenetre bas
|
|
||||||
|
// Display the equationsResult strings in the GUI if they are not empty
|
||||||
|
if (!equationsResultImage.empty()) {
|
||||||
|
ImGui::TextWrapped("%s", equationsResultImage.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::TextWrapped("%s", result.c_str());
|
||||||
|
|
||||||
|
ImGui::End(); // End fenetre top right
|
||||||
}
|
}
|
||||||
|
|
||||||
void PivotGui::Destroy() {}
|
void PivotGui::Destroy() {}
|
||||||
Reference in New Issue
Block a user