Skip to content

Commit

Permalink
Merge pull request #19 from thenlevy/dev
Browse files Browse the repository at this point in the history
v 0.3.1
  • Loading branch information
thenlevy authored Nov 10, 2021
2 parents 6aafa5d + 0359248 commit 6ccc2f3
Show file tree
Hide file tree
Showing 42 changed files with 715 additions and 219 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Changelog


<!-- next-header -->
## 0.3.1

- Improve flexibility of the cross-over suggestions interface. The parameters are in the "Eddition" tab
- Update wgpu to 0.11
- Files that do not have an `.ens` extensions won't be overiden when saving a design. This fixes a problem that caused
ENSnano to overide cadnano files for example.
- Selected/candidate nucleotide are now highlighted in the 2D view.
- Fix a bug that would cause high CPU usage while ENSnano was in the background on MacOS


## 0.3.0
- It is now possible to translate several helices at once.
- It is now possible to change the color of several strands at once. Moreover, the red hilighting
Expand Down
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = [ "ensnano-design", "ensnano-interactor", "ensnano-organizer" ]

[package]
name = "ensnano"
version = "0.3.0"
version = "0.3.1"
authors = ["thenlevy <nicolaspierrelevy@gmail.com>"]
edition = "2018"
license = "GPL-3.0-or-later"
Expand All @@ -12,11 +12,11 @@ resolver = "2"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
iced = { git = "https://github.com/hecrj/iced", rev = "099981c", features=["image"] }
iced_wgpu = { git = "https://github.com/hecrj/iced", rev = "099981c", features = ["spirv"] }
iced_graphics = { git = "https://github.com/hecrj/iced", rev = "099981c" }
iced_winit = { git = "https://github.com/hecrj/iced", rev = "099981c" }
iced_native = { git = "https://github.com/hecrj/iced", rev = "099981c" }
iced = { git = "https://github.com/hecrj/iced", rev = "61c747b53589d98f477fea95f85d2ea5349666d3", features=["image"] }
iced_wgpu = { git = "https://github.com/hecrj/iced", rev = "61c747b53589d98f477fea95f85d2ea5349666d3", features = ["spirv"] }
iced_graphics = { git = "https://github.com/hecrj/iced", rev = "61c747b53589d98f477fea95f85d2ea5349666d3" }
iced_winit = { git = "https://github.com/hecrj/iced", rev = "61c747b53589d98f477fea95f85d2ea5349666d3" }
iced_native = { git = "https://github.com/hecrj/iced", rev = "61c747b53589d98f477fea95f85d2ea5349666d3" }
ultraviolet = { git = "https://github.com/termhn/ultraviolet", rev = "b2fb29e" , features = ["bytemuck", "f64", "serde"] }
bytemuck = "1.2.0"
failure = "0.1.8"
Expand All @@ -40,7 +40,7 @@ ordered-float = "2.0"
rfd = "0.4"
material-icons = "0.1.0"
ensnano_organizer = { path = "ensnano-organizer" }
iced_aw = { git = "https://github.com/thenlevy/iced_aw", rev = "b566bdb" , features = ["tab_bar"]}
iced_aw = { git = "https://github.com/thenlevy/iced_aw", rev = "4ee0a6ac70633" , features = ["tab_bar"]}
num_enum = "0.5.1"
cadnano-format = "0.1.0"
open = "1"
Expand Down
2 changes: 1 addition & 1 deletion ensnano-design/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ensnano_design"
version = "0.3.0"
version = "0.3.1"
authors = ["thenlevy <nicolaspierrelevy@gmail.com>"]
edition = "2018"
license = "GPL-3.0-or-later"
Expand Down
9 changes: 9 additions & 0 deletions ensnano-design/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,15 @@ impl Design {
pub fn prepare_for_save(&mut self, saving_information: SavingInformation) {
self.saved_camera = saving_information.camera;
}

pub fn get_nucl_position(&self, nucl: Nucl) -> Option<Vec3> {
let helix = self.helices.get(&nucl.helix)?;
Some(helix.space_pos(
&self.parameters.unwrap_or_default(),
nucl.position,
nucl.forward,
))
}
}

pub struct SavingInformation {
Expand Down
4 changes: 2 additions & 2 deletions ensnano-interactor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ num_enum = "0.5.1"
open = "1"
ensnano_design = { path = "../ensnano-design" }
ensnano_organizer = { path = "../ensnano-organizer" }
iced_wgpu = { git = "https://github.com/hecrj/iced", rev = "099981c" }
iced_winit = { git = "https://github.com/hecrj/iced", rev = "099981c" }
iced_wgpu = { git = "https://github.com/hecrj/iced", rev = "61c747b53589d98f477fea95f85d2ea5349666d3" }
iced_winit = { git = "https://github.com/hecrj/iced", rev = "61c747b53589d98f477fea95f85d2ea5349666d3" }

46 changes: 46 additions & 0 deletions ensnano-interactor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,3 +450,49 @@ pub struct StrandBuildingStatus {
pub prime5: Nucl,
pub dragged_nucl: Nucl,
}

/// Parameters of strand suggestions
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct SuggestionParameters {
pub include_scaffold: bool,
pub include_intra_strand: bool,
pub include_xover_ends: bool,
pub ignore_groups: bool,
}

impl Default for SuggestionParameters {
fn default() -> Self {
Self {
include_intra_strand: true,
include_scaffold: true,
include_xover_ends: false,
ignore_groups: false,
}
}
}

impl SuggestionParameters {
pub fn with_include_scaffod(&self, include_scaffold: bool) -> Self {
let mut ret = self.clone();
ret.include_scaffold = include_scaffold;
ret
}

pub fn with_intra_strand(&self, intra_strand: bool) -> Self {
let mut ret = self.clone();
ret.include_intra_strand = intra_strand;
ret
}

pub fn with_ignore_groups(&self, ignore_groups: bool) -> Self {
let mut ret = self.clone();
ret.ignore_groups = ignore_groups;
ret
}

pub fn with_xover_ends(&self, include_xover_ends: bool) -> Self {
let mut ret = self.clone();
ret.include_xover_ends = include_xover_ends;
ret
}
}
10 changes: 5 additions & 5 deletions ensnano-organizer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
iced = { git = "https://github.com/hecrj/iced", rev = "099981c", features=["image"] }
iced_wgpu = { git = "https://github.com/hecrj/iced", rev = "099981c" }
iced_graphics = { git = "https://github.com/hecrj/iced", rev = "099981c" }
iced_winit = { git = "https://github.com/hecrj/iced", rev = "099981c" }
iced_native = { git = "https://github.com/hecrj/iced", rev = "099981c" }
iced = { git = "https://github.com/hecrj/iced", rev = "61c747b53589d98f477fea95f85d2ea5349666d3", features=["image"] }
iced_wgpu = { git = "https://github.com/hecrj/iced", rev = "61c747b53589d98f477fea95f85d2ea5349666d3" }
iced_graphics = { git = "https://github.com/hecrj/iced", rev = "61c747b53589d98f477fea95f85d2ea5349666d3" }
iced_winit = { git = "https://github.com/hecrj/iced", rev = "61c747b53589d98f477fea95f85d2ea5349666d3" }
iced_native = { git = "https://github.com/hecrj/iced", rev = "61c747b53589d98f477fea95f85d2ea5349666d3" }
iced_aw = { git = "https://github.com/iced-rs/iced_aw", rev = "84ccfa8", features=["icons", "icon_text"] }
serde = "1.0.116"
serde_derive = "1.0.116"
Expand Down
10 changes: 5 additions & 5 deletions ensnano-organizer/src/drag_drop_target.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use iced::{Container, Element};
use iced_native::{
event, layout, overlay, Align, Clipboard, Event, Hasher, Layout, Length, Point, Rectangle,
event, layout, overlay, Alignment, Clipboard, Event, Hasher, Layout, Length, Point, Rectangle,
Widget,
};
use std::hash::Hash;
Expand All @@ -17,8 +17,8 @@ pub(super) struct DragDropTarget<'a, Message, K> {
height: Length,
max_width: u32,
max_height: u32,
horizontal_alignment: Align,
vertical_alignment: Align,
horizontal_alignment: Alignment,
vertical_alignment: Alignment,
content: Container<'a, Message>,
identifier: Identifier<K>,
}
Expand All @@ -35,8 +35,8 @@ impl<'a, Message, K> DragDropTarget<'a, Message, K> {
height: Length::Shrink,
max_width: u32::MAX,
max_height: u32::MAX,
horizontal_alignment: Align::Start,
vertical_alignment: Align::Start,
horizontal_alignment: Alignment::Start,
vertical_alignment: Alignment::Start,
content: Container::new(content).width(Length::Fill),
identifier,
}
Expand Down
2 changes: 1 addition & 1 deletion ensnano-organizer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,7 @@ impl<E: OrganizerElement> GroupContent<E> {
}

fn icon(unicode: char) -> Text {
use iced::HorizontalAlignment;
use iced::alignment::Horizontal as HorizontalAlignment;
Text::new(&unicode.to_string())
.font(ICONS)
.size(ICON_SIZE)
Expand Down
27 changes: 24 additions & 3 deletions src/app_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use crate::apply_update;
use crate::controller::SimulationRequest;
use address_pointer::AddressPointer;
use ensnano_design::Design;
use ensnano_interactor::{DesignOperation, RigidBodyConstants};
use ensnano_interactor::{DesignOperation, RigidBodyConstants, SuggestionParameters};
use ensnano_organizer::GroupId;

pub use design_interactor::controller::ErrOperation;
Expand Down Expand Up @@ -65,6 +65,13 @@ impl std::fmt::Debug for AppState {
}
}

impl std::fmt::Pointer for AppState {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let ptr = self.0.get_ptr();
std::fmt::Pointer::fmt(&ptr, f)
}
}

impl Default for AppState {
fn default() -> Self {
let ret = AppState(Default::default());
Expand Down Expand Up @@ -128,6 +135,12 @@ impl AppState {
Self(AddressPointer::new(new_state))
}

pub fn with_suggestion_parameters(&self, suggestion_parameters: SuggestionParameters) -> Self {
let mut new_state = (*self.0).clone();
new_state.suggestion_parameters = suggestion_parameters;
Self(AddressPointer::new(new_state))
}

pub fn with_action_mode(&self, action_mode: ActionMode) -> Self {
let mut new_state = (*self.0).clone();
new_state.action_mode = action_mode;
Expand Down Expand Up @@ -200,9 +213,15 @@ impl AppState {
}

fn updated(self) -> Self {
let old_self = self.clone();
let mut interactor = self.0.design.clone_inner();
interactor = interactor.with_updated_design_reader();
self.with_interactor(interactor)
interactor = interactor.with_updated_design_reader(&self.0.suggestion_parameters);
let new = self.with_interactor(interactor);
if old_self.design_was_modified(&new) {
new
} else {
old_self
}
}

fn with_interactor(self, interactor: DesignInteractor) -> Self {
Expand Down Expand Up @@ -313,6 +332,7 @@ impl AppState {
*self = self.with_candidates(vec![]);
*self = self.with_action_mode(source.0.action_mode.clone());
*self = self.with_selection_mode(source.0.selection_mode.clone());
*self = self.with_suggestion_parameters(source.0.suggestion_parameters.clone());
}

pub(super) fn is_pasting(&self) -> PastingStatus {
Expand Down Expand Up @@ -448,6 +468,7 @@ struct AppState_ {
widget_basis: WidgetBasis,
strand_on_new_helix: Option<NewHelixStrand>,
center_of_selection: Option<CenterOfSelection>,
suggestion_parameters: SuggestionParameters,
}

#[derive(Clone, Default)]
Expand Down
4 changes: 4 additions & 0 deletions src/app_state/address_pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ impl<T: Default> AddressPointer<T> {
pub fn show_address(&self) {
println!("{:p}", Arc::as_ptr(&self.0))
}

pub fn get_ptr(&self) -> *const T {
Arc::as_ptr(&self.0)
}
}

use std::ops::Deref;
Expand Down
33 changes: 21 additions & 12 deletions src/app_state/design_interactor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use super::AddressPointer;
use ensnano_design::{group_attributes::GroupAttribute, Design, Parameters};
use ensnano_interactor::{
operation::Operation, DesignOperation, RigidBodyConstants, Selection, SimulationState,
StrandBuilder,
StrandBuilder, SuggestionParameters,
};

mod presenter;
Expand Down Expand Up @@ -200,12 +200,16 @@ impl DesignInteractor {
ret
}

pub(super) fn with_updated_design_reader(mut self) -> Self {
pub(super) fn with_updated_design_reader(
mut self,
suggestion_parameters: &SuggestionParameters,
) -> Self {
if cfg!(test) {
print!("Old design: ");
self.design.show_address();
}
let (new_presenter, new_design) = update_presenter(&self.presenter, self.design.clone());
let (new_presenter, new_design) =
update_presenter(&self.presenter, self.design.clone(), suggestion_parameters);
self.presenter = new_presenter;
if cfg!(test) {
print!("New design: ");
Expand All @@ -216,7 +220,7 @@ impl DesignInteractor {
if !self.controller.get_simulation_state().is_runing() {
self.simulation_update = None;
}
self.after_applying_simulation_update(update)
self.after_applying_simulation_update(update, suggestion_parameters)
} else {
self
}
Expand All @@ -230,9 +234,17 @@ impl DesignInteractor {
self
}

fn after_applying_simulation_update(mut self, update: Arc<dyn SimulationUpdate>) -> Self {
let (new_presenter, new_design) =
apply_simulation_update(&self.presenter, self.design.clone(), update);
fn after_applying_simulation_update(
mut self,
update: Arc<dyn SimulationUpdate>,
suggestion_parameters: &SuggestionParameters,
) -> Self {
let (new_presenter, new_design) = apply_simulation_update(
&self.presenter,
self.design.clone(),
update,
suggestion_parameters,
);
self.presenter = new_presenter;
self.design = new_design;
self
Expand Down Expand Up @@ -425,7 +437,8 @@ mod tests {
fn read_one_helix() {
let path = one_helix_path();
let interactor = DesignInteractor::new_with_path(&path).ok().unwrap();
let interactor = interactor.with_updated_design_reader();
let suggestion_parameters = Default::default();
let interactor = interactor.with_updated_design_reader(&suggestion_parameters);
let reader = interactor.get_design_reader();
assert_eq!(reader.get_all_visible_nucl_ids().len(), 24)
}
Expand Down Expand Up @@ -817,7 +830,6 @@ mod tests {

#[test]
fn positioning_xovers_paste() {
use crate::flatscene::DesignReader;
let mut app_state = pastable_design();
let (n1, n2) = app_state.get_design_reader().get_xover_with_id(0).unwrap();
app_state
Expand Down Expand Up @@ -851,7 +863,6 @@ mod tests {

#[test]
fn pasting_when_positioning_xovers() {
use crate::flatscene::DesignReader;
let mut app_state = pastable_design();
let (n1, n2) = app_state.get_design_reader().get_xover_with_id(0).unwrap();
app_state
Expand All @@ -865,7 +876,6 @@ mod tests {

#[test]
fn duplicating_xovers() {
use crate::flatscene::DesignReader;
let mut app_state = pastable_design();
let (n1, n2) = app_state.get_design_reader().get_xover_with_id(0).unwrap();
app_state
Expand Down Expand Up @@ -899,7 +909,6 @@ mod tests {

#[test]
fn duplicating_xovers_pasting_status() {
use crate::flatscene::DesignReader;
let mut app_state = pastable_design();
let (n1, n2) = app_state.get_design_reader().get_xover_with_id(0).unwrap();
app_state
Expand Down
6 changes: 3 additions & 3 deletions src/app_state/design_interactor/controller/clipboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ impl Controller {
let mut domains_vec = vec![domains_0];
for n in 1..clipboard.templates.len() {
let t = clipboard.templates.get(n);
println!("updated template {:?}", t);
log::info!("updated template {:?}", t);
let domains = t.as_ref().and_then(|t| {
clipboard
.template_edges
Expand Down Expand Up @@ -760,9 +760,9 @@ impl Controller {
let (edge, shift) = copy_edge;
for (n1, n2) in xovers.iter() {
let copy_1 = self.translate_nucl_by_edge(n1, &edge, shift, design, grid_manager);
println!("copy 1 {:?}", copy_1);
log::debug!("copy 1 {:?}", copy_1);
let copy_2 = self.translate_nucl_by_edge(n2, &edge, shift, design, grid_manager);
println!("copy 2 {:?}", copy_2);
log::debug!("copy 2 {:?}", copy_2);
if let Some((copy_1, copy_2)) = copy_1.zip(copy_2) {
if !design.is_true_xover_end(&copy_1) && !design.is_true_xover_end(&copy_2) {
// If general_cross_over returns an error we simply ignore this cross_over
Expand Down
Loading

0 comments on commit 6ccc2f3

Please sign in to comment.