From 014a13340cf7cc60d9b518916d2ed91426fe1803 Mon Sep 17 00:00:00 2001 From: "Ryan@fsunuc" Date: Wed, 26 Jul 2023 20:24:54 -0400 Subject: [PATCH] bug fix on test.html --- index.html | 9 +++++---- test.cpp | 56 +++++++++++++++++++++++++++++++++++------------------- 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/index.html b/index.html index f16242a..6581073 100644 --- a/index.html +++ b/index.html @@ -42,6 +42,7 @@ float: none; padding: 0px; margin-left: var(--navWidth); + height: 1000px; height : 100vh; /* background: #1363A7; */ background: #6DB33E; @@ -49,7 +50,7 @@ a { color : #F7CF3C; } - + .column1{ float : left; width : 50%; @@ -123,10 +124,10 @@ Intructions & Credits - Woods-Saxon (const.) + Woods-Saxon (const.) - Nuclides Chart (const.) + Nuclides Chart (const.) @@ -156,7 +157,7 @@ -
+
diff --git a/test.cpp b/test.cpp index 1c89d36..17249ef 100644 --- a/test.cpp +++ b/test.cpp @@ -20,9 +20,6 @@ #include #include - -//======= Woods-Saxon Library -#include "RK4.h" #include "WS.h" const int nPt = 300; @@ -45,7 +42,6 @@ GLFWwindow* g_window; ImVec4 clear_color = ImVec4(0.427, 0.702f, 0.243f, 1.00f); int g_width; int g_height; - // Function used by c++ to get the size of the html canvas EM_JS(int, canvas_get_width, (), { return Module.canvas.width; @@ -99,6 +95,7 @@ void loop(){ // Woods-Saxon window { ImGui::SetNextWindowSize(ImVec2(600, 1000), ImGuiCond_FirstUseEver); + ImGui::SetNextWindowPos(ImVec2(50, 50), ImGuiCond_FirstUseEver); static float V0 = -45, r0 = 1.25, R0 = 3.5, a0 = 0.6; static float VSO = 28, rSO = 1.25, RSO = 3.5, aSO = 0.6; static int Z = 0, nStep = 300; @@ -109,8 +106,27 @@ void loop(){ ImGui::Begin("Woods-Saxon Calculation"); static int e = 0; - ImGui::RadioButton("Arbitary", &e, 0); ImGui::SameLine(); - ImGui::RadioButton("Isotope", &e, 1); + if( ImGui::RadioButton("Arbitary", &e, 0) ){ + A = 1; + } + ImGui::SameLine(); + if( ImGui::RadioButton("Isotope", &e, 1) ){ + rc = 1.25; + r0 = 1.25; + rSO = 1.25; + } + + if( e == 0){ + rc = Rc / pow(A, 1./3); + r0 = R0 / pow(A, 1./3); + rSO = RSO / pow(A, 1./3); + } + + if( e == 1){ + Rc = rc * pow(A, 1./3); + R0 = r0 * pow(A, 1./3); + RSO = rSO * pow(A, 1./3); + } ImGui::Separator(); ImGui::PushItemWidth(100); @@ -128,14 +144,6 @@ void loop(){ ImGui::DragFloat("rc [fm] ", &rc, 0.01, 1, 10); ImGui::EndDisabled(); - if( e == 0 ) {A = 1; rc = Rc / pow(A, 1./3);} - if( e == 1 ) { - rc = 1.25; - r0 = 1.25; - rSO = 1.25; - Rc = rc * pow(A, 1./3); - } - ImGui::Text("Eff. mass : %.3f ", mass); ImGui::Separator(); @@ -145,16 +153,12 @@ void loop(){ ImGui::BeginDisabled(e==1); ImGui::DragFloat("R0 [fm] ", &R0, 0.01, 1, 10); ImGui::EndDisabled(); ImGui::SameLine(); ImGui::BeginDisabled(e==0); ImGui::DragFloat("r0 [fm] ", &r0, 0.01, 1, 10); ImGui::EndDisabled(); - if( e == 0 ) {A = 1; r0 = R0 / pow(A, 1./3);} - if( e == 1 ) R0 = r0 * pow(A, 1./3); ImGui::DragFloat("a0 [fm]", &a0, 0.01, 0.1, 2); ImGui::DragFloat("VSO [MeV]", &VSO, 0.1, 0, 40); ImGui::BeginDisabled(e==1); ImGui::DragFloat("RSO [fm] ", &RSO, 0.01, 1, 10); ImGui::EndDisabled(); ImGui::SameLine(); ImGui::BeginDisabled(e==0); ImGui::DragFloat("rSO [fm] ", &rSO, 0.01, 1, 10); ImGui::EndDisabled(); - if( e == 0 ) {A = 1; rSO = RSO / pow(A, 1./3);} - if( e == 1 ) RSO = rSO * pow(A, 1./3); ImGui::DragFloat("aSO [fm]", &aSO, 0.01, 0.1, 2); ImGui::Separator(); @@ -258,7 +262,7 @@ void loop(){ //*============= WS Trend { ImGui::SetNextWindowSize(ImVec2(600, 800), ImGuiCond_FirstUseEver); - ImGui::SetNextWindowPos(ImVec2(100, 200), ImGuiCond_FirstUseEver); + ImGui::SetNextWindowPos(ImVec2(680, 50), ImGuiCond_FirstUseEver); static float V0 = -45, r0 = 1.25, a0 = 0.6; static float VSO = 28, rSO = 1.25, aSO = 0.6; static int Z = 0, N = 1, nStep = 300; @@ -479,8 +483,20 @@ void loop(){ ImPlot::EndPlot(); } + + static bool saveDataClicked = false; + if( ImGui::Button("Download data") ){ + // FILE * file_out; + // file_out = fopen("", "w+"); + saveDataClicked = true; + } + + if( saveDataClicked ) { + ImGui::Text("to be impletmented...."); + } } + ImGui::End(); } @@ -509,7 +525,7 @@ int init_gl(){ // Open a window and create its OpenGL context int canvasWidth = g_width; int canvasHeight = g_height; - g_window = glfwCreateWindow(canvasWidth, canvasHeight, "WebGui Demo", NULL, NULL); + g_window = glfwCreateWindow(canvasWidth, canvasHeight, "Woods-Saxon Calculation Demo", NULL, NULL); if( g_window == NULL ){ fprintf( stderr, "Failed to open GLFW window.\n" ); glfwTerminate();