merge stable version #2

Merged
doryan merged 97 commits from experimental into main 2024-08-28 18:54:00 +03:00
2 changed files with 38 additions and 27 deletions
Showing only changes of commit 5cc92eb8ae - Show all commits

View File

@ -55,12 +55,7 @@ pub fn column_view_setup_factory(_factory: &SignalListItemFactory, list_item: &O
.set_child(Some(&Label::new(None))); .set_child(Some(&Label::new(None)));
} }
pub fn column_view_bind_factory( pub fn get_cell_data(list_item: &Object) -> (Frequency, Label) {
_factory: &SignalListItemFactory,
list_item: &Object,
values: SignalReduce,
label: &str,
) {
let cell_value = list_item let cell_value = list_item
.downcast_ref::<ListItem>() .downcast_ref::<ListItem>()
.expect("Needs to be ListItem") .expect("Needs to be ListItem")
@ -75,12 +70,30 @@ pub fn column_view_bind_factory(
.and_downcast::<Label>() .and_downcast::<Label>()
.expect("The child has to be a `Label`."); .expect("The child has to be a `Label`.");
(cell_value, cell_label)
}
pub fn frequency_column_fabric(list_item: &Object) {
let (cell_value, cell_label) = get_cell_data(list_item);
cell_label.set_label(&cell_value.frequency().to_string());
}
pub fn reactive_resist_fabric(list_item: &Object, values: SignalReduce) {
let (cell_value, cell_label) = get_cell_data(list_item);
cell_value.set_reactive_resist(reactive_resistance_of_capacitor( cell_value.set_reactive_resist(reactive_resistance_of_capacitor(
values.wire_capacity * 10f64.powi(-12), values.wire_capacity * 10f64.powi(-12),
values.length, values.length,
cell_value.frequency() * 10f64.powi(6), cell_value.frequency() * 10f64.powi(6),
)); ));
cell_label.set_label(format!("{0:.1$}", cell_value.reactive_resist(), 6).as_str());
}
pub fn signal_source_voltage_fabric(list_item: &Object, values: SignalReduce) {
let (cell_value, cell_label) = get_cell_data(list_item);
cell_value.set_full_resistance(full_resistance_of_capacitor( cell_value.set_full_resistance(full_resistance_of_capacitor(
cell_value.reactive_resist(), cell_value.reactive_resist(),
values.source_resistance, values.source_resistance,
@ -96,23 +109,14 @@ pub fn column_view_bind_factory(
) * 1000.0, ) * 1000.0,
); );
match label { cell_label.set_label(format!("{0:.1$}", cell_value.signal_source_voltage(), 6).as_str());
"f, МГц" => { }
cell_label.set_label(&cell_value.frequency().to_string());
} pub fn coef_fabric(list_item: &Object, values: SignalReduce) {
"Xc, Ом" => { let (cell_value, cell_label) = get_cell_data(list_item);
cell_label.set_label(format!("{0:.1$}", cell_value.reactive_resist(), 6).as_str());
} let coef: f64 =
"Vп, мВ" => { coef_of_signal_reduce(values.source_voltage, cell_value.signal_source_voltage());
cell_label
.set_label(format!("{0:.1$}", cell_value.signal_source_voltage(), 6).as_str()); cell_label.set_label(format!("{0:.1$}", coef, 6).as_str());
}
"ζ" => {
let coef: f64 =
coef_of_signal_reduce(values.source_voltage, cell_value.signal_source_voltage());
cell_label.set_label(format!("{0:.1$}", coef, 6).as_str());
}
_ => {}
}
} }

View File

@ -94,7 +94,15 @@ pub fn signal_reducing_page(wrapper: &Box) {
factory.connect_bind(clone!( factory.connect_bind(clone!(
#[strong] #[strong]
values, values,
move |factory, list| column_view_bind_factory(factory, list, values.get(), label) move |_, list| {
match label {
"f, МГц" => frequency_column_fabric(list),
"Xc, Ом" => reactive_resist_fabric(list, values.get()),
"Vп, мВ" => signal_source_voltage_fabric(list, values.get()),
"ζ" => coef_fabric(list, values.get()),
_ => {}
}
}
)); ));
let column = ColumnViewColumn::builder() let column = ColumnViewColumn::builder()
@ -135,7 +143,6 @@ pub fn signal_reducing_page(wrapper: &Box) {
if find_by_frequency_value(&model, &new_elem).is_none() { if find_by_frequency_value(&model, &new_elem).is_none() {
model.append(&new_elem); model.append(&new_elem);
} }
update_column_view(&result_table); update_column_view(&result_table);
} }
} }