adding dynamic number input and reading in matrix
Some checks failed
Linux arm64 / Build (push) Has been cancelled
Some checks failed
Linux arm64 / Build (push) Has been cancelled
This commit is contained in:
@@ -2,6 +2,10 @@
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
std::vector<std::vector<int>> PivotGui::matrixValues;
|
||||
int PivotGui::matrixSizeX = 4;
|
||||
int PivotGui::matrixSizeY = 4;
|
||||
|
||||
void PivotGui::Init() {}
|
||||
|
||||
void PivotGui::Render() {
|
||||
@@ -22,11 +26,6 @@ void PivotGui::Render() {
|
||||
|
||||
ImGui::Text("Matrice initiale:");
|
||||
|
||||
// taille matrice
|
||||
static int matrixSizeX = 4;
|
||||
static int matrixSizeY = 4;
|
||||
|
||||
|
||||
ImGui::InputInt("##RowsMatriceInitiale", &matrixSizeY);
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("Lignes");
|
||||
@@ -36,18 +35,22 @@ void PivotGui::Render() {
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("Colonnes");
|
||||
|
||||
// Draw matrix
|
||||
ImGui::BeginChild("MatriceInitiale", ImVec2(topLeftWindowSize.x, io.DisplaySize.y * 0.7f), false);
|
||||
ImGui::BeginChild("MatriceInitiale", ImVec2(topLeftWindowSize.x, io.DisplaySize.y * 0.7f), false);
|
||||
|
||||
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::Selectable("?", false, 0, ImVec2(50, 50));
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
// Resize matrixValues
|
||||
matrixValues.resize(matrixSizeY, std::vector<int>(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:");
|
||||
|
||||
@@ -78,7 +81,7 @@ void PivotGui::Render() {
|
||||
// Code de calcul
|
||||
}
|
||||
ImGui::SameLine(); // Align buttons horizontally
|
||||
if (ImGui::Button("Calcul inverse")) {
|
||||
if (ImGui::Button("Calcul image")) {
|
||||
// Code de calcul
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
|
||||
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