This commit is contained in:
@@ -1,95 +1,114 @@
|
|||||||
#include "PivotGui.h"
|
#include "PivotGui.h"
|
||||||
|
|
||||||
|
#include "Matrix.h"
|
||||||
|
#include "Solver.h"
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
std::vector<std::vector<int>> PivotGui::matrixValues;
|
static Matrix LoadMatrixFromStdVect(const std::vector<std::vector<int>>& data) {
|
||||||
int PivotGui::matrixSizeX = 4;
|
Matrix result {data.size(), data.empty() ? 0 : data[0].size()};
|
||||||
int PivotGui::matrixSizeY = 4;
|
for (std::size_t i = 0; i < result.GetRawCount(); i++) {
|
||||||
|
for (std::size_t j = 0; j < result.GetColumnCount(); j++) {
|
||||||
|
result.at(i, j) = static_cast<Matrix::Element>(data[i][j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void PivotGui::Init() {}
|
void PivotGui::Init() {}
|
||||||
|
|
||||||
void PivotGui::Render() {
|
void PivotGui::Render() {
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
// divisions des fenetres
|
static std::vector<std::vector<int>> matrixValues;
|
||||||
ImVec2 topLeftWindowSize(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.8f);
|
static int matrixSizeX = 4;
|
||||||
ImVec2 topRightWindowSize(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.8f);
|
static int matrixSizeY = 4;
|
||||||
ImVec2 bottomWindowSize(io.DisplaySize.x, io.DisplaySize.y * 0.2f);
|
static Solver solver;
|
||||||
|
|
||||||
// Begin fenetre top left
|
// divisions des fenetres
|
||||||
ImGui::SetNextWindowSize(topLeftWindowSize);
|
ImVec2 topLeftWindowSize(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.8f);
|
||||||
ImGui::SetNextWindowPos(ImVec2(0, 0)); // Position at the top-left corner
|
ImVec2 topRightWindowSize(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.8f);
|
||||||
ImGui::Begin("Left Top Window", nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar);
|
ImVec2 bottomWindowSize(io.DisplaySize.x, io.DisplaySize.y * 0.2f);
|
||||||
|
|
||||||
// Get window position
|
// Begin fenetre top left
|
||||||
ImVec2 windowPos = ImGui::GetWindowPos();
|
ImGui::SetNextWindowSize(topLeftWindowSize);
|
||||||
|
ImGui::SetNextWindowPos(ImVec2(0, 0)); // Position at the top-left corner
|
||||||
|
ImGui::Begin("Left Top Window", nullptr,
|
||||||
|
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar);
|
||||||
|
|
||||||
ImGui::Text("Matrice initiale:");
|
// Get window position
|
||||||
|
ImVec2 windowPos = ImGui::GetWindowPos();
|
||||||
|
|
||||||
ImGui::InputInt("##RowsMatriceInitiale", &matrixSizeY);
|
ImGui::Text("Matrice initiale:");
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::Text("Lignes");
|
ImGui::InputInt("##RowsMatriceInitiale", &matrixSizeY);
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Text("Lignes");
|
||||||
|
|
||||||
|
|
||||||
ImGui::InputInt("##ColumnsMatriceInitiale", &matrixSizeX);
|
ImGui::InputInt("##ColumnsMatriceInitiale", &matrixSizeX);
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Text("Colonnes");
|
ImGui::Text("Colonnes");
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
matrixValues.resize(matrixSizeY);
|
matrixValues.resize(matrixSizeY);
|
||||||
for(auto& row : matrixValues) {
|
for (auto& row : matrixValues) {
|
||||||
row.resize(matrixSizeX, 0);
|
row.resize(matrixSizeX, 0);
|
||||||
}
|
|
||||||
|
|
||||||
for (int y = 0; y < matrixSizeY; y++) {
|
|
||||||
for (int x = 0; x < matrixSizeX; x++) {
|
|
||||||
if (x > 0)
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::PushID(y * matrixSizeX + x);
|
|
||||||
ImGui::PushItemWidth(30); // Adjust this value to change the cell size
|
|
||||||
ImGui::InputInt("", &matrixValues[y][x], 0, 0, ImGuiInputTextFlags_CharsDecimal);
|
|
||||||
ImGui::PopItemWidth();
|
|
||||||
ImGui::PopID();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Text("Matrice finale:");
|
for (int y = 0; y < matrixSizeY; y++) {
|
||||||
|
for (int x = 0; x < matrixSizeX; x++) {
|
||||||
|
if (x > 0)
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::PushID(y * matrixSizeX + x);
|
||||||
|
ImGui::PushItemWidth(30); // Adjust this value to change the cell size
|
||||||
|
ImGui::InputInt("", &matrixValues[y][x], 0, 0, ImGuiInputTextFlags_CharsDecimal);
|
||||||
|
ImGui::PopItemWidth();
|
||||||
|
ImGui::PopID();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::EndChild(); // End Matrice initiale
|
ImGui::Text("Matrice finale:");
|
||||||
|
|
||||||
ImGui::End(); // End fenetre top left
|
ImGui::EndChild(); // End Matrice initiale
|
||||||
|
|
||||||
// Begin fenetre top right
|
ImGui::End(); // End fenetre top left
|
||||||
ImGui::SetNextWindowSize(topRightWindowSize);
|
|
||||||
ImGui::SetNextWindowPos(ImVec2(windowPos.x + topLeftWindowSize.x, 0)); // Position at the top-right corner
|
|
||||||
ImGui::Begin("Right Top Window", nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar);
|
|
||||||
|
|
||||||
// rajouter le code pour la partie top right
|
// Begin fenetre top right
|
||||||
|
ImGui::SetNextWindowSize(topRightWindowSize);
|
||||||
|
ImGui::SetNextWindowPos(ImVec2(windowPos.x + topLeftWindowSize.x, 0)); // Position at the top-right corner
|
||||||
|
ImGui::Begin("Right Top Window", nullptr,
|
||||||
|
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar);
|
||||||
|
|
||||||
ImGui::End(); // End fenetre top right
|
// rajouter le code pour la partie top right
|
||||||
|
|
||||||
// Begin fenetre bas
|
ImGui::End(); // End fenetre top right
|
||||||
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);
|
|
||||||
|
|
||||||
// rajouter des boutons clickables
|
// Begin fenetre bas
|
||||||
if (ImGui::Button("Calcul noyeau")) {
|
ImGui::SetNextWindowSize(bottomWindowSize);
|
||||||
// Code de calcul
|
ImGui::SetNextWindowPos(ImVec2(0, io.DisplaySize.y * 0.8f)); // Position at the bottom-left corner
|
||||||
}
|
ImGui::Begin("Bottom Part", nullptr,
|
||||||
ImGui::SameLine(); // Align buttons horizontally
|
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar);
|
||||||
if (ImGui::Button("Calcul rang")) {
|
|
||||||
// Code de calcul
|
|
||||||
}
|
|
||||||
ImGui::SameLine(); // Align buttons horizontally
|
|
||||||
if (ImGui::Button("Calcul image")) {
|
|
||||||
// Code de calcul
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::End(); // End fenetre bas
|
// rajouter des boutons clickables
|
||||||
|
if (ImGui::Button("Calcul noyau")) {
|
||||||
|
// Code de calcul
|
||||||
|
Vect kernel = solver.Kernel(LoadMatrixFromStdVect(matrixValues));
|
||||||
|
}
|
||||||
|
ImGui::SameLine(); // Align buttons horizontally
|
||||||
|
if (ImGui::Button("Calcul rang")) {
|
||||||
|
// Code de calcul
|
||||||
|
std::size_t rank = solver.Rank(LoadMatrixFromStdVect(matrixValues));
|
||||||
|
}
|
||||||
|
ImGui::SameLine(); // Align buttons horizontally
|
||||||
|
if (ImGui::Button("Calcul image")) {
|
||||||
|
// Code de calcul
|
||||||
|
Vect image = solver.Image(LoadMatrixFromStdVect(matrixValues));
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::End(); // End fenetre bas
|
||||||
}
|
}
|
||||||
|
|
||||||
void PivotGui::Destroy() {}
|
void PivotGui::Destroy() {}
|
||||||
@@ -6,7 +6,5 @@ namespace PivotGui {
|
|||||||
void Init();
|
void Init();
|
||||||
void Render();
|
void Render();
|
||||||
void Destroy();
|
void Destroy();
|
||||||
extern std::vector<std::vector<int>> matrixValues;
|
|
||||||
extern int matrixSizeX;
|
|
||||||
extern int matrixSizeY;
|
|
||||||
} // namespace PivotGui
|
} // namespace PivotGui
|
||||||
|
|||||||
Reference in New Issue
Block a user