Skip to content

Commit

Permalink
don't allow changes once exported
Browse files Browse the repository at this point in the history
  • Loading branch information
David Erb committed May 11, 2023
1 parent 65acb36 commit 7a69f6d
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 6 deletions.
16 changes: 14 additions & 2 deletions src/echolocator_lib/composers/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def compose_image_list(self, models: List[CrystalWellNeedingDroplocationModel]):
{"text": "auto x,y", "class": "T_auto_target_x_y"},
{"text": "confirmed x,y", "class": "T_confirmed_target_x_y"},
{"text": "echo coordinate x,y", "class": "T_confirmed_microns_x_y"},
{"text": "use", "class": "T_is_usable"},
{"text": "usable", "class": "T_is_usable"},
{"text": "exported", "class": "T_is_exported_to_soakdb3"},
{"text": "error", "class": "T_error"},
]

Expand Down Expand Up @@ -157,13 +158,24 @@ def compose_image_list(self, models: List[CrystalWellNeedingDroplocationModel]):

t = model.is_usable
if t is None:
t = "-"
t = "undecided"
elif t:
t = "yes"
else:
t = "no"
html_lines.append("<td class='T_is_usable'>" + str(t) + "</td>")

t = model.is_exported_to_soakdb3
if t is None:
t = "no"
elif t:
t = "yes"
else:
t = "no"
html_lines.append(
"<td class='T_is_exported_to_soakdb3'>" + str(t) + "</td>"
)

html_lines.append("<td class='T_error'>" + html.escape(error) + "</td>")

html_lines.append("</td>")
Expand Down
5 changes: 5 additions & 0 deletions src/echolocator_lib/guis/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@
<div class="T_input">
<div class="T_is_usable"></div>
</div>
<div class="T_separator"></div>
<div class="T_prompt">is exported?</div>
<div class="T_input">
<div class="T_is_exported_to_soakdb3"></div>
</div>
</div>
<div class="T_field">
<div class="T_prompt">filename:</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class echolocator__ImageEditUx extends echolocator__UxAutoUpdate {
this.#jquery_objects.$crystal_well_count = $(".T_crystal_well_count", this.$interaction_parent);
this.#jquery_objects.$number_of_crystals = $(".T_number_of_crystals", this.$interaction_parent);
this.#jquery_objects.$is_usable = $(".T_is_usable", this.$interaction_parent);
this.#jquery_objects.$is_exported_to_soakdb3 = $(".T_is_exported_to_soakdb3", this.$interaction_parent);

this.#jquery_objects.previous_button = $(".T_previous_button", this.$interaction_parent);
this.#jquery_objects.accept_button = $(".T_accept_button", this.$interaction_parent);
this.#jquery_objects.reject_button = $(".T_reject_button", this.$interaction_parent);
Expand Down Expand Up @@ -296,6 +298,11 @@ class echolocator__ImageEditUx extends echolocator__UxAutoUpdate {
_handle_canvas_left_click(jquery_event_object) {
var F = "echolocator__ImageEditUx::_handle_canvas_left_click";

if (this.#record.is_exported_to_soakdb3) {
console.log(F + ": ignoring canvas left click because is_exported_to_soakdb3 is " + this.#record.is_exported_to_soakdb3);
return;
}

console.log(F + ": seeing canvas left click");

var view_position = {
Expand All @@ -320,6 +327,9 @@ class echolocator__ImageEditUx extends echolocator__UxAutoUpdate {
_handle_canvas_right_click(jquery_event_object) {
var F = "echolocator__ImageEditUx::_handle_canvas_right_click";

if (this.#record.is_exported_to_soakdb3)
return;

// Mark image unusable.
this._send_update(false)

Expand Down Expand Up @@ -416,21 +426,35 @@ class echolocator__ImageEditUx extends echolocator__UxAutoUpdate {
this.#jquery_objects.previous_button.attr("disabled", this.#crystal_well_index == 0);
this.#jquery_objects.next_button.attr("disabled", this.#crystal_well_index >= this.#crystal_well_count - 1);

this.#jquery_objects.accept_button.attr("disabled", record.is_exported_to_soakdb3);
this.#jquery_objects.reject_button.attr("disabled", record.is_exported_to_soakdb3);
this.#jquery_objects.reset_button.attr("disabled", record.is_exported_to_soakdb3);

this.#confirmed_target_ux.enabled(!record.is_exported_to_soakdb3)

// Update the display with the new file's contents.
var src = record.filename;
this.#jquery_objects.$image.prop("src", src)

// Render the set_crystal_well_index stuff.
this.#jquery_objects.$filename.text(record.filename);

if (record.number_of_crystals === null)
record.number_of_crystals = "-";

if (record.is_usable === null)
record.is_usable = "undecided";
if (record.is_usable === true)
record.is_usable = "yes";
if (record.is_usable === false)
record.is_usable = "no";

if (record.number_of_crystals === null)
record.number_of_crystals = "-";
if (record.is_exported_to_soakdb3 === null)
this.#jquery_objects.$is_exported_to_soakdb3.text("no");
if (record.is_exported_to_soakdb3 === true)
this.#jquery_objects.$is_exported_to_soakdb3.text("yes");
if (record.is_exported_to_soakdb3 === false)
this.#jquery_objects.$is_exported_to_soakdb3.text("no");

this.#jquery_objects.$number_of_crystals.text(record.number_of_crystals);
this.#jquery_objects.$is_usable.text(record.is_usable);
Expand Down
13 changes: 13 additions & 0 deletions src/echolocator_lib/guis/html/javascript/echolocator/pixel_ux.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ class echolocator__PixelUx extends echolocator__UxBase {
// We will move the guide to the image's target location.
// We will update the x and y as the guid moves.

enabled(flag) {
var F = "echolocator__PixelUx[" + this.plugin_link_name + "]::enabled"

this.#is_draggable = flag;
this.#guide.set_box({ "enabled": flag });

} // end method

// -------------------------------------------------------------
// When the selected image changes, we get notified.
// We will move the guide to the image's target location.
// We will update the x and y as the guid moves.

set_uuid(uuid, target) {
var F = "echolocator__PixelUx[" + this.plugin_link_name + "]::set_uuid"

Expand Down
18 changes: 16 additions & 2 deletions src/echolocator_lib/guis/html/javascript/webviz/hair/guide2.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class webviz__hair__Guide2 extends common__Base {

// -------------------------------------------------------------

activate(raphael, color, is_draggable) {
activate(raphael, color, is_enabled) {
var F = "webviz__hair__Guide2[" + this.name + "]::activate";

this._raphael = raphael
Expand Down Expand Up @@ -62,7 +62,8 @@ class webviz__hair__Guide2 extends common__Base {
this._ball._group = this._group;
this._ball._parent_object = this;

if (is_draggable)
this.is_enabled = is_enabled;
if (is_enabled)
this._group.drag(this._drag_move, this._drag_start, this._drag_stop);

console.log(F + ": activated")
Expand Down Expand Up @@ -102,6 +103,10 @@ class webviz__hair__Guide2 extends common__Base {
else
this._group.hide();
}
// The setting is for visibility?
else if (k == "enabled") {
this.is_enabled = setting;
}

}
} // end method
Expand All @@ -125,6 +130,9 @@ class webviz__hair__Guide2 extends common__Base {

// -------------------------------------------------------------
_drag_move(dx, dy) {
if (!this._parent_object.is_enabled)
return;

this._group.translate(dx - this.odx, dy - this.ody);
this.odx = dx;
this.ody = dy;
Expand All @@ -137,6 +145,9 @@ class webviz__hair__Guide2 extends common__Base {
_drag_start() {
var F = "webviz__hair__Guide2[" + this._parent_object.name + "]::_drag_start";

if (!this._parent_object.is_enabled)
return;

console.log(F + ": drag start")

// var keys = new Array();
Expand All @@ -155,6 +166,9 @@ class webviz__hair__Guide2 extends common__Base {
_drag_stop() {
var F = "webviz__hair__Guide2[" + this._parent_object.name + "]::_drag_stop";

if (!this._parent_object.is_enabled)
return;

// Not yet started the timeout?
if (this.timeout === undefined) {
console.log(F + ": drag stop");
Expand Down

0 comments on commit 7a69f6d

Please sign in to comment.