This commit is contained in:
@@ -1,95 +1,114 @@
|
||||
#include "PivotGui.h"
|
||||
|
||||
#include "Matrix.h"
|
||||
#include "Solver.h"
|
||||
#include <imgui.h>
|
||||
|
||||
std::vector<std::vector<int>> PivotGui::matrixValues;
|
||||
int PivotGui::matrixSizeX = 4;
|
||||
int PivotGui::matrixSizeY = 4;
|
||||
static Matrix LoadMatrixFromStdVect(const std::vector<std::vector<int>>& data) {
|
||||
Matrix result {data.size(), data.empty() ? 0 : data[0].size()};
|
||||
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::Render() {
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
|
||||
// divisions des fenetres
|
||||
ImVec2 topLeftWindowSize(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.8f);
|
||||
ImVec2 topRightWindowSize(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.8f);
|
||||
ImVec2 bottomWindowSize(io.DisplaySize.x, io.DisplaySize.y * 0.2f);
|
||||
static std::vector<std::vector<int>> matrixValues;
|
||||
static int matrixSizeX = 4;
|
||||
static int matrixSizeY = 4;
|
||||
static Solver solver;
|
||||
|
||||
// Begin fenetre top left
|
||||
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);
|
||||
// divisions des fenetres
|
||||
ImVec2 topLeftWindowSize(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.8f);
|
||||
ImVec2 topRightWindowSize(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.8f);
|
||||
ImVec2 bottomWindowSize(io.DisplaySize.x, io.DisplaySize.y * 0.2f);
|
||||
|
||||
// Get window position
|
||||
ImVec2 windowPos = ImGui::GetWindowPos();
|
||||
// Begin fenetre top left
|
||||
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::SameLine();
|
||||
ImGui::Text("Lignes");
|
||||
ImGui::Text("Matrice initiale:");
|
||||
|
||||
ImGui::InputInt("##RowsMatriceInitiale", &matrixSizeY);
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("Lignes");
|
||||
|
||||
|
||||
ImGui::InputInt("##ColumnsMatriceInitiale", &matrixSizeX);
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("Colonnes");
|
||||
ImGui::InputInt("##ColumnsMatriceInitiale", &matrixSizeX);
|
||||
ImGui::SameLine();
|
||||
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);
|
||||
for(auto& row : matrixValues) {
|
||||
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();
|
||||
}
|
||||
matrixValues.resize(matrixSizeY);
|
||||
for (auto& row : matrixValues) {
|
||||
row.resize(matrixSizeX, 0);
|
||||
}
|
||||
|
||||
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::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 left
|
||||
|
||||
// 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::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);
|
||||
ImGui::End(); // End fenetre top right
|
||||
|
||||
// rajouter des boutons clickables
|
||||
if (ImGui::Button("Calcul noyeau")) {
|
||||
// Code de calcul
|
||||
}
|
||||
ImGui::SameLine(); // Align buttons horizontally
|
||||
if (ImGui::Button("Calcul rang")) {
|
||||
// Code de calcul
|
||||
}
|
||||
ImGui::SameLine(); // Align buttons horizontally
|
||||
if (ImGui::Button("Calcul image")) {
|
||||
// Code de calcul
|
||||
}
|
||||
// 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);
|
||||
|
||||
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() {}
|
||||
@@ -6,7 +6,5 @@ namespace PivotGui {
|
||||
void Init();
|
||||
void Render();
|
||||
void Destroy();
|
||||
extern std::vector<std::vector<int>> matrixValues;
|
||||
extern int matrixSizeX;
|
||||
extern int matrixSizeY;
|
||||
|
||||
} // namespace PivotGui
|
||||
|
||||
Reference in New Issue
Block a user