ADDED: models and controllers for page "signal reducing"\n TODO: done table for page "signal reducing"
This commit is contained in:
@@ -2,11 +2,15 @@ use gtk4 as gtk;
|
||||
|
||||
use crate::{
|
||||
controller::event_handlers::button_event_handlers::*,
|
||||
model::{builder_traits::Product, model::EventHandler},
|
||||
model::{
|
||||
builder_traits::Product,
|
||||
model::{EventHandler, SchemeCharacteristics},
|
||||
},
|
||||
view::{
|
||||
components::{input::Input, wrapper::Wrapper},
|
||||
properties::*,
|
||||
},
|
||||
view_utils::signal_reduce_input_utils::start_algorithm,
|
||||
};
|
||||
use gtk::{prelude::*, Align, WrapMode, *};
|
||||
|
||||
@@ -19,26 +23,23 @@ pub fn signal_reducing_page(wrapper: &Box) {
|
||||
vertical: Align::Fill,
|
||||
};
|
||||
|
||||
let wire_length_input = Input::builder()
|
||||
let wire_length_input: Input = Input::builder()
|
||||
.set_label("l, м:")
|
||||
.set_margins(MarginData::EqualsMargin(5))
|
||||
.set_align(input_label_alignment)
|
||||
.build(monospace, input_wrapping, input_height)
|
||||
.get();
|
||||
.build(monospace, input_wrapping, input_height);
|
||||
|
||||
let resistance_per_meter_input = Input::builder()
|
||||
let resistance_per_meter_input: Input = Input::builder()
|
||||
.set_label("Rм, Ом:")
|
||||
.set_margins(MarginData::EqualsMargin(5))
|
||||
.set_align(input_label_alignment)
|
||||
.build(monospace, input_wrapping, input_height)
|
||||
.get();
|
||||
.build(monospace, input_wrapping, input_height);
|
||||
|
||||
let capacity_per_meter_input = Input::builder()
|
||||
let capacity_per_meter_input: Input = Input::builder()
|
||||
.set_label("Cм, пФ:")
|
||||
.set_margins(MarginData::EqualsMargin(5))
|
||||
.set_align(input_label_alignment)
|
||||
.build(monospace, input_wrapping, input_height)
|
||||
.get();
|
||||
.build(monospace, input_wrapping, input_height);
|
||||
|
||||
let wrapper_first_row = Wrapper::col_builder()
|
||||
.halign(Align::Fill)
|
||||
@@ -46,39 +47,38 @@ pub fn signal_reducing_page(wrapper: &Box) {
|
||||
.spacing(5)
|
||||
.build();
|
||||
|
||||
let first_row_elements: Vec<&Box> = vec![
|
||||
let first_row_elements: Vec<&Input> = vec![
|
||||
&wire_length_input,
|
||||
&resistance_per_meter_input,
|
||||
&capacity_per_meter_input,
|
||||
];
|
||||
|
||||
for elem in first_row_elements {
|
||||
elem.set_halign(input_alignment);
|
||||
elem.set_hexpand(true);
|
||||
let input: Box = elem.clone().get();
|
||||
|
||||
wrapper_first_row.append(elem);
|
||||
input.set_halign(input_alignment);
|
||||
input.set_hexpand(true);
|
||||
|
||||
wrapper_first_row.append(&input);
|
||||
}
|
||||
|
||||
let info_signal_voltage_input = Input::builder()
|
||||
let info_signal_voltage_input: Input = Input::builder()
|
||||
.set_label("Vи, мВ:")
|
||||
.set_margins(MarginData::EqualsMargin(5))
|
||||
.set_align(input_label_alignment)
|
||||
.build(monospace, input_wrapping, input_height)
|
||||
.get();
|
||||
.build(monospace, input_wrapping, input_height);
|
||||
|
||||
let resistance_of_info_voltage_source_input = Input::builder()
|
||||
let resistance_of_info_voltage_source_input: Input = Input::builder()
|
||||
.set_label("Rи, Ом:")
|
||||
.set_margins(MarginData::EqualsMargin(5))
|
||||
.set_align(input_label_alignment)
|
||||
.build(monospace, input_wrapping, input_height)
|
||||
.get();
|
||||
.build(monospace, input_wrapping, input_height);
|
||||
|
||||
let info_voltage_source_frequency_input = Input::builder()
|
||||
let info_voltage_source_frequency_input: Input = Input::builder()
|
||||
.set_label("f, мГц:")
|
||||
.set_margins(MarginData::EqualsMargin(5))
|
||||
.set_align(input_label_alignment)
|
||||
.build(monospace, input_wrapping, input_height)
|
||||
.get();
|
||||
.build(monospace, input_wrapping, input_height);
|
||||
|
||||
let wrapper_second_row = Wrapper::col_builder()
|
||||
.halign(Align::Fill)
|
||||
@@ -86,19 +86,30 @@ pub fn signal_reducing_page(wrapper: &Box) {
|
||||
.spacing(5)
|
||||
.build();
|
||||
|
||||
let second_row_elements: Vec<&Box> = vec![
|
||||
let second_row_elements: Vec<&Input> = vec![
|
||||
&info_signal_voltage_input,
|
||||
&resistance_of_info_voltage_source_input,
|
||||
&info_voltage_source_frequency_input,
|
||||
];
|
||||
|
||||
for elem in second_row_elements {
|
||||
elem.set_halign(input_alignment);
|
||||
elem.set_hexpand(true);
|
||||
let input: Box = elem.clone().get();
|
||||
|
||||
wrapper_second_row.append(elem);
|
||||
input.set_halign(input_alignment);
|
||||
input.set_hexpand(true);
|
||||
|
||||
wrapper_second_row.append(&input);
|
||||
}
|
||||
|
||||
let all_text_views: Vec<TextView> = vec![
|
||||
wire_length_input.get_input(),
|
||||
resistance_per_meter_input.get_input(),
|
||||
capacity_per_meter_input.get_input(),
|
||||
info_signal_voltage_input.get_input(),
|
||||
resistance_of_info_voltage_source_input.get_input(),
|
||||
info_voltage_source_frequency_input.get_input(),
|
||||
];
|
||||
|
||||
let main_wrapper = Wrapper::row_builder().spacing(5).build();
|
||||
|
||||
main_wrapper.append(&wrapper_first_row);
|
||||
@@ -112,20 +123,21 @@ pub fn signal_reducing_page(wrapper: &Box) {
|
||||
|
||||
let table_header_labels = vec!["f, Гц", "Xc, пФ", "Vп, мВ", "ζ"];
|
||||
|
||||
let table_header = Wrapper::col_builder()
|
||||
.height_request(24)
|
||||
.spacing(5)
|
||||
.halign(Align::Center)
|
||||
let table_header = ColumnView::builder()
|
||||
.focusable(false)
|
||||
.reorderable(true)
|
||||
.halign(Align::Fill)
|
||||
.hexpand(true)
|
||||
.build();
|
||||
|
||||
for header_label in table_header_labels {
|
||||
let label = Label::builder()
|
||||
.label(header_label)
|
||||
.halign(Align::Fill)
|
||||
.hexpand(true)
|
||||
for table_header_label in table_header_labels {
|
||||
let column = ColumnViewColumn::builder()
|
||||
.title(table_header_label)
|
||||
.fixed_width(200)
|
||||
.expand(true)
|
||||
.build();
|
||||
table_header.append(&label);
|
||||
|
||||
table_header.append_column(&column);
|
||||
}
|
||||
|
||||
let table_of_calculated_values = Frame::builder()
|
||||
@@ -136,13 +148,17 @@ pub fn signal_reducing_page(wrapper: &Box) {
|
||||
.set_margin(MarginData::MultipleMargin((10, 5, 0, 0)))
|
||||
.build();
|
||||
|
||||
let errors_label: Label = Label::new(Some(""));
|
||||
let errors_label_for_handler: Label = errors_label.clone();
|
||||
|
||||
EventHandler::new(calculate_button.clone(), move |_| {
|
||||
println!("button taped");
|
||||
start_algorithm(&errors_label_for_handler, &all_text_views)
|
||||
})
|
||||
.on_click();
|
||||
|
||||
main_wrapper.append(&calculate_button);
|
||||
main_wrapper.append(&table_of_calculated_values);
|
||||
main_wrapper.append(&errors_label);
|
||||
|
||||
wrapper.append(&main_wrapper);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user