added table and it needed to fix
This commit is contained in:
parent
b6d0eb0508
commit
7c16964b83
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,17 +2,17 @@ use gtk4 as gtk;
|
|||
|
||||
use crate::{
|
||||
controller::event_handlers::button_event_handlers::*,
|
||||
model::{
|
||||
builder_traits::Product,
|
||||
model::{EventHandler, SchemeCharacteristics},
|
||||
},
|
||||
model::{builder_traits::Product, model::*},
|
||||
view::{
|
||||
components::{input::Input, wrapper::Wrapper},
|
||||
properties::*,
|
||||
},
|
||||
view_utils::signal_reduce_input_utils::start_algorithm,
|
||||
};
|
||||
use gtk::{prelude::*, Align, WrapMode, *};
|
||||
use gtk::{
|
||||
prelude::{BoxExt, ListBoxRowExt, WidgetExt},
|
||||
Align, WrapMode, *,
|
||||
};
|
||||
|
||||
pub fn signal_reducing_page(wrapper: &Box) {
|
||||
let (input_height, monospace, input_alignment, input_wrapping): (i32, bool, Align, WrapMode) =
|
||||
|
@ -125,7 +125,9 @@ pub fn signal_reducing_page(wrapper: &Box) {
|
|||
|
||||
let table_header = ColumnView::builder()
|
||||
.focusable(false)
|
||||
.reorderable(true)
|
||||
.reorderable(false)
|
||||
.show_row_separators(true)
|
||||
.show_column_separators(true)
|
||||
.halign(Align::Fill)
|
||||
.hexpand(true)
|
||||
.build();
|
||||
|
@ -140,25 +142,70 @@ pub fn signal_reducing_page(wrapper: &Box) {
|
|||
table_header.append_column(&column);
|
||||
}
|
||||
|
||||
let mut table = ListBox::builder().hexpand(true).halign(Align::Fill).build();
|
||||
|
||||
let header = ListBoxRow::builder().child(&table_header).build();
|
||||
|
||||
table.append(&header);
|
||||
|
||||
for i in (0..=100).step_by(5) {
|
||||
if i == 0 {
|
||||
continue;
|
||||
}
|
||||
|
||||
let table_row = ListBoxRow::new();
|
||||
|
||||
let columns = ColumnView::builder().reorderable(false).build();
|
||||
|
||||
let column = ColumnViewColumn::builder()
|
||||
.title(format!("{i}"))
|
||||
.fixed_width(200)
|
||||
.expand(true)
|
||||
.build();
|
||||
|
||||
columns.append_column(&column);
|
||||
|
||||
for table_row_label in 1..=3 {
|
||||
let column = ColumnViewColumn::builder()
|
||||
.title(format!("{table_row_label}"))
|
||||
.fixed_width(200)
|
||||
.expand(true)
|
||||
.build();
|
||||
|
||||
columns.append_column(&column);
|
||||
}
|
||||
|
||||
table_row.set_child(Some(&columns));
|
||||
|
||||
table.append(&table_row);
|
||||
}
|
||||
|
||||
let table_of_calculated_values = Frame::builder()
|
||||
.height_request(64)
|
||||
.hexpand(true)
|
||||
.child(&table_header)
|
||||
.child(&table)
|
||||
.halign(Align::Fill)
|
||||
.set_margin(MarginData::MultipleMargin((10, 5, 0, 0)))
|
||||
.build();
|
||||
|
||||
let table_frame = table_of_calculated_values.clone();
|
||||
|
||||
let errors_label: Label = Label::new(Some(""));
|
||||
let errors_label_for_handler: Label = errors_label.clone();
|
||||
|
||||
EventHandler::new(calculate_button.clone(), move |_| {
|
||||
start_algorithm(&errors_label_for_handler, &all_text_views)
|
||||
start_algorithm(
|
||||
&errors_label_for_handler,
|
||||
&all_text_views,
|
||||
&table_frame.clone(),
|
||||
&header,
|
||||
)
|
||||
})
|
||||
.on_click();
|
||||
|
||||
main_wrapper.append(&errors_label);
|
||||
main_wrapper.append(&calculate_button);
|
||||
main_wrapper.append(&table_of_calculated_values);
|
||||
main_wrapper.append(&errors_label);
|
||||
|
||||
wrapper.append(&main_wrapper);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue