refactor(fabrics): one fabric is divided into several parts
This commit is contained in:
parent
cc4ba6168f
commit
5cc92eb8ae
|
@ -55,12 +55,7 @@ pub fn column_view_setup_factory(_factory: &SignalListItemFactory, list_item: &O
|
|||
.set_child(Some(&Label::new(None)));
|
||||
}
|
||||
|
||||
pub fn column_view_bind_factory(
|
||||
_factory: &SignalListItemFactory,
|
||||
list_item: &Object,
|
||||
values: SignalReduce,
|
||||
label: &str,
|
||||
) {
|
||||
pub fn get_cell_data(list_item: &Object) -> (Frequency, Label) {
|
||||
let cell_value = list_item
|
||||
.downcast_ref::<ListItem>()
|
||||
.expect("Needs to be ListItem")
|
||||
|
@ -75,12 +70,30 @@ pub fn column_view_bind_factory(
|
|||
.and_downcast::<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(
|
||||
values.wire_capacity * 10f64.powi(-12),
|
||||
values.length,
|
||||
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.reactive_resist(),
|
||||
values.source_resistance,
|
||||
|
@ -96,23 +109,14 @@ pub fn column_view_bind_factory(
|
|||
) * 1000.0,
|
||||
);
|
||||
|
||||
match label {
|
||||
"f, МГц" => {
|
||||
cell_label.set_label(&cell_value.frequency().to_string());
|
||||
}
|
||||
"Xc, Ом" => {
|
||||
cell_label.set_label(format!("{0:.1$}", cell_value.reactive_resist(), 6).as_str());
|
||||
}
|
||||
"Vп, мВ" => {
|
||||
cell_label
|
||||
.set_label(format!("{0:.1$}", cell_value.signal_source_voltage(), 6).as_str());
|
||||
}
|
||||
"ζ" => {
|
||||
cell_label.set_label(format!("{0:.1$}", cell_value.signal_source_voltage(), 6).as_str());
|
||||
}
|
||||
|
||||
pub fn coef_fabric(list_item: &Object, values: SignalReduce) {
|
||||
let (cell_value, cell_label) = get_cell_data(list_item);
|
||||
|
||||
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());
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,7 +94,15 @@ pub fn signal_reducing_page(wrapper: &Box) {
|
|||
factory.connect_bind(clone!(
|
||||
#[strong]
|
||||
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()
|
||||
|
@ -135,7 +143,6 @@ pub fn signal_reducing_page(wrapper: &Box) {
|
|||
if find_by_frequency_value(&model, &new_elem).is_none() {
|
||||
model.append(&new_elem);
|
||||
}
|
||||
|
||||
update_column_view(&result_table);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue