added table and it needed to fix
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use gtk4 as gtk;
|
||||
|
||||
use crate::controller::model_utils::signal_reducer::*;
|
||||
use crate::model::model::SchemeCharacteristics;
|
||||
use gtk::{prelude::*, *};
|
||||
|
||||
@@ -38,7 +39,12 @@ pub fn check_characteristics(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn start_algorithm(error_log_label: &Label, raw_characteristics: &Vec<TextView>) {
|
||||
pub fn start_algorithm(
|
||||
error_log_label: &Label,
|
||||
raw_characteristics: &Vec<TextView>,
|
||||
table: &Frame,
|
||||
header: &ListBoxRow,
|
||||
) {
|
||||
let mut all_inputs_data: Vec<f64> = Vec::new();
|
||||
let mut output: String = String::new();
|
||||
|
||||
@@ -47,6 +53,10 @@ pub fn start_algorithm(error_log_label: &Label, raw_characteristics: &Vec<TextVi
|
||||
} else {
|
||||
error_log_label.set_text("");
|
||||
|
||||
let new_table = ListBox::builder().hexpand(true).halign(Align::Fill).build();
|
||||
|
||||
new_table.append(header);
|
||||
|
||||
let (L, Rm, Cm, Vs, Rs, f): SchemeCharacteristics = (
|
||||
all_inputs_data[0],
|
||||
all_inputs_data[1],
|
||||
@@ -59,5 +69,55 @@ pub fn start_algorithm(error_log_label: &Label, raw_characteristics: &Vec<TextVi
|
||||
let mut frequencies: Vec<usize> = vec![f as usize, 1usize];
|
||||
|
||||
frequencies.append(&mut (0..100).step_by(5).collect());
|
||||
|
||||
for i in frequencies {
|
||||
if i == 0 {
|
||||
continue;
|
||||
}
|
||||
|
||||
let table_row = ListBoxRow::new();
|
||||
|
||||
let columns = ColumnView::builder().reorderable(false).build();
|
||||
|
||||
let frequency_column = ColumnViewColumn::builder()
|
||||
.title(format!("{i}"))
|
||||
.fixed_width(200)
|
||||
.expand(true)
|
||||
.build();
|
||||
|
||||
let Xc: f64 = reactive_resistance_of_capacitor(Cm, L, f);
|
||||
let Z: f64 = full_resistance_of_capacitor(Xc, Vs, Rm, L);
|
||||
let V: f64 = voltage_from_signal_source(Vs, Xc, Z);
|
||||
let xi: f64 = coef_of_signal_reduce(Vs, V);
|
||||
|
||||
let reactive_resistance_column = ColumnViewColumn::builder()
|
||||
.title(format!("{:?}", Xc))
|
||||
.fixed_width(200)
|
||||
.expand(true)
|
||||
.build();
|
||||
|
||||
let voltage_column = ColumnViewColumn::builder()
|
||||
.title(format!("{:?}", V))
|
||||
.fixed_width(200)
|
||||
.expand(true)
|
||||
.build();
|
||||
|
||||
let coef_column = ColumnViewColumn::builder()
|
||||
.title(format!("{:?}", xi))
|
||||
.fixed_width(200)
|
||||
.expand(true)
|
||||
.build();
|
||||
|
||||
columns.append_column(&frequency_column);
|
||||
columns.append_column(&reactive_resistance_column);
|
||||
columns.append_column(&voltage_column);
|
||||
columns.append_column(&coef_column);
|
||||
|
||||
table_row.set_child(Some(&columns));
|
||||
|
||||
new_table.append(&table_row);
|
||||
|
||||
table.set_child(Some(&new_table));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user