Spaces:
Sleeping
Sleeping
Commit 路
e2e8018
1
Parent(s): b9df344
Improve radius and n management
Browse files- mieWeb/main.py +5 -1
- mieWeb/src/negocio/presenter.py +5 -5
- mieWeb/src/presentacion/view.py +15 -32
mieWeb/main.py
CHANGED
|
@@ -1,7 +1,11 @@
|
|
| 1 |
from src.negocio.presenter import Presenter
|
| 2 |
from src.presentacion.view import View
|
| 3 |
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
view = View(presenter)
|
| 6 |
|
| 7 |
presenter.view = view
|
|
|
|
| 1 |
from src.negocio.presenter import Presenter
|
| 2 |
from src.presentacion.view import View
|
| 3 |
|
| 4 |
+
default_radius_value = 50
|
| 5 |
+
default_n_surrounding_value = 1
|
| 6 |
+
|
| 7 |
+
presenter = Presenter(default_radius_value, default_n_surrounding_value)
|
| 8 |
+
|
| 9 |
view = View(presenter)
|
| 10 |
|
| 11 |
presenter.view = view
|
mieWeb/src/negocio/presenter.py
CHANGED
|
@@ -6,12 +6,14 @@ from src.persistencia.acceso_datos import db_path
|
|
| 6 |
|
| 7 |
|
| 8 |
class Presenter(IPresenter):
|
| 9 |
-
def __init__(self, radius_value
|
| 10 |
self.view: IView = None
|
|
|
|
| 11 |
self.radius_value = radius_value
|
|
|
|
|
|
|
| 12 |
self.n_surrounding_value = n_surrounding_value
|
| 13 |
-
self.
|
| 14 |
-
self.valid_n_surrounding = False
|
| 15 |
|
| 16 |
# Obtener los nombres de los materiales y el diccionario de materiales
|
| 17 |
self.nombres_materiales = []
|
|
@@ -40,8 +42,6 @@ class Presenter(IPresenter):
|
|
| 40 |
def get_radius_value(self):
|
| 41 |
return self.radius_value
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
def remove_from_material_data(self, nombre):
|
| 46 |
self.material_data.pop(nombre)
|
| 47 |
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
class Presenter(IPresenter):
|
| 9 |
+
def __init__(self, radius_value, n_surrounding_value):
|
| 10 |
self.view: IView = None
|
| 11 |
+
|
| 12 |
self.radius_value = radius_value
|
| 13 |
+
self.valid_radius = True
|
| 14 |
+
|
| 15 |
self.n_surrounding_value = n_surrounding_value
|
| 16 |
+
self.valid_n_surrounding = True
|
|
|
|
| 17 |
|
| 18 |
# Obtener los nombres de los materiales y el diccionario de materiales
|
| 19 |
self.nombres_materiales = []
|
|
|
|
| 42 |
def get_radius_value(self):
|
| 43 |
return self.radius_value
|
| 44 |
|
|
|
|
|
|
|
| 45 |
def remove_from_material_data(self, nombre):
|
| 46 |
self.material_data.pop(nombre)
|
| 47 |
|
mieWeb/src/presentacion/view.py
CHANGED
|
@@ -18,10 +18,10 @@ class View(IView):
|
|
| 18 |
|
| 19 |
# Crear un widget de selecci贸n m煤ltiple con Panel
|
| 20 |
self.multi_choice = pn.widgets.MultiChoice(
|
| 21 |
-
name="
|
| 22 |
options= self.presenter.get_nombres_materiales(),
|
| 23 |
width=320,
|
| 24 |
-
placeholder="
|
| 25 |
)
|
| 26 |
|
| 27 |
# Contenedor para los widgets de selecci贸n de p谩ginas
|
|
@@ -65,37 +65,19 @@ class View(IView):
|
|
| 65 |
self.radius_input = pn.widgets.TextInput(
|
| 66 |
name='Radius (nm)',
|
| 67 |
placeholder='Enter the radius value in nanometers',
|
| 68 |
-
value=
|
| 69 |
width=300
|
| 70 |
)
|
| 71 |
-
|
| 72 |
-
# Bot贸n para confirmar el radio
|
| 73 |
-
self.confirm_radius_button = pn.widgets.Button(
|
| 74 |
-
name='Confirm radius',
|
| 75 |
-
button_type='primary',
|
| 76 |
-
width=50
|
| 77 |
-
)
|
| 78 |
-
|
| 79 |
-
# Adjuntar la funci贸n store_radius al evento del bot贸n
|
| 80 |
-
self.confirm_radius_button.on_click(self.store_radius)
|
| 81 |
|
| 82 |
# Crear una entrada de texto para el n del medio
|
| 83 |
self.n_surrounding_input = pn.widgets.TextInput(
|
| 84 |
name='Refractive index of the medium',
|
| 85 |
placeholder='Enter value',
|
| 86 |
-
value=
|
| 87 |
width=300,
|
| 88 |
)
|
| 89 |
-
|
| 90 |
-
# Bot贸n para confirmar el n del medio
|
| 91 |
-
self.confirm_n_surrounding_button = pn.widgets.Button(
|
| 92 |
-
name='Confirm value',
|
| 93 |
-
button_type='primary',
|
| 94 |
-
width=50
|
| 95 |
-
)
|
| 96 |
-
|
| 97 |
-
# Adjuntar la funci贸n store_n_surrounding al evento del bot贸n
|
| 98 |
-
self.confirm_n_surrounding_button.on_click(self.store_n_surrounding)
|
| 99 |
|
| 100 |
# Bot贸n para descargar los resultados
|
| 101 |
self.download_button_txt = pn.widgets.FileDownload(
|
|
@@ -118,10 +100,11 @@ class View(IView):
|
|
| 118 |
# Inicializar la gr谩fica
|
| 119 |
self.actualizar_plot()
|
| 120 |
|
| 121 |
-
sidebar = [self.radius_input,
|
| 122 |
-
self.n_surrounding_input,
|
| 123 |
self.error_message,
|
| 124 |
-
self.multi_choice,
|
|
|
|
| 125 |
|
| 126 |
main = [self.plot_option,
|
| 127 |
self.plot_pane,
|
|
@@ -137,8 +120,8 @@ class View(IView):
|
|
| 137 |
self.template.modal.append(
|
| 138 |
"""
|
| 139 |
# How to use the app:
|
| 140 |
-
1.
|
| 141 |
-
2.
|
| 142 |
3. Choose the metric (qext, qsca, or qabs) to visualize on the graph.
|
| 143 |
4. Download the computed results in TXT or SVG format.
|
| 144 |
"""
|
|
@@ -188,14 +171,14 @@ class View(IView):
|
|
| 188 |
|
| 189 |
|
| 190 |
# Funci贸n para manejar la entrada del radio
|
| 191 |
-
def store_radius(self,event):
|
| 192 |
-
self.presenter.radius_store(
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
# Funci贸n para manejar la entrada del n del medio
|
| 197 |
def store_n_surrounding(self, event):
|
| 198 |
-
self.presenter.n_surrounding_store(
|
| 199 |
|
| 200 |
|
| 201 |
|
|
|
|
| 18 |
|
| 19 |
# Crear un widget de selecci贸n m煤ltiple con Panel
|
| 20 |
self.multi_choice = pn.widgets.MultiChoice(
|
| 21 |
+
name="Materials",
|
| 22 |
options= self.presenter.get_nombres_materiales(),
|
| 23 |
width=320,
|
| 24 |
+
placeholder="Type to search"
|
| 25 |
)
|
| 26 |
|
| 27 |
# Contenedor para los widgets de selecci贸n de p谩ginas
|
|
|
|
| 65 |
self.radius_input = pn.widgets.TextInput(
|
| 66 |
name='Radius (nm)',
|
| 67 |
placeholder='Enter the radius value in nanometers',
|
| 68 |
+
value=str(self.presenter.get_radius_value()), # Valor predeterminado
|
| 69 |
width=300
|
| 70 |
)
|
| 71 |
+
self.radius_input.param.watch(lambda event: self.store_radius(event), 'value')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
# Crear una entrada de texto para el n del medio
|
| 74 |
self.n_surrounding_input = pn.widgets.TextInput(
|
| 75 |
name='Refractive index of the medium',
|
| 76 |
placeholder='Enter value',
|
| 77 |
+
value=str(self.presenter.get_n_surrounding_value()), # Valor predeterminado
|
| 78 |
width=300,
|
| 79 |
)
|
| 80 |
+
self.n_surrounding_input.param.watch(lambda event: self.store_n_surrounding(event), 'value')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
# Bot贸n para descargar los resultados
|
| 83 |
self.download_button_txt = pn.widgets.FileDownload(
|
|
|
|
| 100 |
# Inicializar la gr谩fica
|
| 101 |
self.actualizar_plot()
|
| 102 |
|
| 103 |
+
sidebar = [self.radius_input,
|
| 104 |
+
self.n_surrounding_input,
|
| 105 |
self.error_message,
|
| 106 |
+
self.multi_choice,
|
| 107 |
+
self.page_selectors]
|
| 108 |
|
| 109 |
main = [self.plot_option,
|
| 110 |
self.plot_pane,
|
|
|
|
| 120 |
self.template.modal.append(
|
| 121 |
"""
|
| 122 |
# How to use the app:
|
| 123 |
+
1. Adjust the radius and/or the surrounding refractive index as needed.
|
| 124 |
+
2. Select the materials you want to compare.
|
| 125 |
3. Choose the metric (qext, qsca, or qabs) to visualize on the graph.
|
| 126 |
4. Download the computed results in TXT or SVG format.
|
| 127 |
"""
|
|
|
|
| 171 |
|
| 172 |
|
| 173 |
# Funci贸n para manejar la entrada del radio
|
| 174 |
+
def store_radius(self, event):
|
| 175 |
+
self.presenter.radius_store(event.new)
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
# Funci贸n para manejar la entrada del n del medio
|
| 180 |
def store_n_surrounding(self, event):
|
| 181 |
+
self.presenter.n_surrounding_store(event.new)
|
| 182 |
|
| 183 |
|
| 184 |
|