def test_add_transformation_alt_1(): data_under_test = FakeInstrument([]) under_test = ComponentTreeModel(data_under_test) under_test.add_component(get_component()) component_index = under_test.index(0, 0, QModelIndex()) transformation_list_index = under_test.index(1, 0, component_index) assert under_test.rowCount(transformation_list_index) == 0 under_test.add_translation(transformation_list_index) assert under_test.rowCount(transformation_list_index) == 1
def test_add_translation(): data_under_test = FakeInstrument([]) under_test = ComponentTreeModel(data_under_test) under_test.add_component(get_component()) component_index = under_test.index(0, 0, QModelIndex()) transformation_list_index = under_test.index(1, 0, component_index) assert under_test.rowCount(transformation_list_index) == 0 under_test.add_translation(component_index) assert under_test.rowCount(transformation_list_index) == 1 transform_index = under_test.index(0, 0, transformation_list_index) assert transform_index.internalPointer().type == "Translation"
def add_transformation( transformation_type: TransformationType, component_tree_view: QTreeView, component_model: ComponentTreeModel, ): selected = component_tree_view.selectedIndexes() if len(selected) > 0: current_index = selected[0] if transformation_type == TransformationType.TRANSLATION: component_model.add_translation(current_index) elif transformation_type == TransformationType.ROTATION: component_model.add_rotation(current_index) else: raise ValueError(f"Unknown transformation type: {transformation_type}") expand_transformation_list(current_index, component_tree_view, component_model)