-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Xywh panel #169
Merged
Merged
Xywh panel #169
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2f4d77e
Initial work
b1031af
Fix template and callback
abde498
Fix page offset
94c07d1
Still needs fixing for negative values
aab1f96
Fix condition for width-height bug
5231e75
Remove console.log statements
cd004ee
Fix negative values and limits and documentation
e44622e
remove console.log issues with -
7d70d96
setting the newvalue properly if the value is too high
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ | |
this.ipv.remove(); | ||
} | ||
if (selected.length > 0) { | ||
this.ipv = new InfoPanelView({models: selected}); | ||
this.ipv = new InfoPanelView({models: selected, figureModel: this.model}); | ||
this.ipv.render(); | ||
$("#infoTab").append(this.ipv.el); | ||
} | ||
|
@@ -674,7 +674,7 @@ | |
initialize: function(opts) { | ||
// if (opts.models) { | ||
this.render = _.debounce(this.render); | ||
|
||
this.figureModel = opts.figureModel; | ||
this.models = opts.models; | ||
if (opts.models.length > 1) { | ||
var self = this; | ||
|
@@ -692,6 +692,33 @@ | |
"click .setId": "setImageId", | ||
"click .set_dpi": "set_dpi", | ||
"click .clear_dpi": "clear_dpi", | ||
"blur .xywh_form input": "handle_xywh", | ||
"keyup .xywh_form input": "handle_xywh", | ||
}, | ||
|
||
handle_xywh: function(event) { | ||
if (event.type === "keyup" && event.which !== 13) { | ||
return; | ||
} | ||
var attr = event.target.getAttribute("name"); | ||
var value = parseInt(event.target.value, 10); | ||
if (isNaN(value)) { | ||
return; | ||
} | ||
this.models.forEach(function(m) { | ||
if (attr === 'x' || attr ==='y'){ | ||
var old = m.get(attr); | ||
var coords = {}; | ||
coords[attr] = old; | ||
var offset = this.figureModel.getPageOffset(coords); | ||
m.set(attr, old - offset[attr] + value); | ||
} | ||
else { | ||
console.log(attr); | ||
console.log(value); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
m.set(attr, value); | ||
} | ||
}.bind(this)); | ||
}, | ||
|
||
set_dpi: function(event) { | ||
|
@@ -717,10 +744,13 @@ | |
// just update x,y,w,h by rendering ONE template | ||
drag_resize: function(xywh) { | ||
$("#xywh_table").remove(); | ||
var json = {'x': xywh[0] >> 0, | ||
'y': xywh[1] >> 0, | ||
'width': xywh[2] >> 0, | ||
'height': xywh[3] >> 0}; | ||
var json = {'x': xywh[0].toFixed(0), | ||
'y': xywh[1].toFixed(0), | ||
'width': xywh[2].toFixed(0), | ||
'height': xywh[3].toFixed(0)}; | ||
var offset = this.figureModel.getPageOffset(json); | ||
json.x = offset.x; | ||
json.y = offset.y; | ||
json.dpi = this.model.getPanelDpi(json.width, json.height); | ||
json.export_dpi = this.model.get('export_dpi'); | ||
this.$el.append(this.xywh_template(json)); | ||
|
@@ -738,17 +768,24 @@ | |
remoteUrl = m.get('baseUrl') + "/img_detail/" + m.get('imageId') + "/"; | ||
} | ||
// start with json data from first Panel | ||
var this_json = m.toJSON(); | ||
// Format floating point values | ||
_.each(["x", "y", "width", "height"], function(a){ | ||
if (this_json[a] != "-") { | ||
this_json[a] = this_json[a].toFixed(0); | ||
} | ||
}); | ||
var offset = this.figureModel.getPageOffset(this_json); | ||
this_json.x = offset.x; | ||
this_json.y = offset.y; | ||
this_json.dpi = m.getPanelDpi(); | ||
this_json.channel_labels = this_json.channels.map(function(c){return c.label}) | ||
if (!json) { | ||
json = m.toJSON(); | ||
json.dpi = m.getPanelDpi(); | ||
json.channel_labels = []; | ||
_.each(json.channels, function(c){ json.channel_labels.push(c.label);}); | ||
json = this_json; | ||
} else { | ||
json.name = title; | ||
// compare json summary so far with this Panel | ||
var this_json = m.toJSON(), | ||
attrs = ["imageId", "orig_width", "orig_height", "sizeT", "sizeZ", "x", "y", "width", "height", "dpi", "export_dpi"]; | ||
this_json.dpi = m.getPanelDpi(); | ||
var attrs = ["imageId", "orig_width", "orig_height", "sizeT", "sizeZ", "x", "y", "width", "height", "dpi", "export_dpi"]; | ||
_.each(attrs, function(a){ | ||
if (json[a] != this_json[a]) { | ||
json[a] = "-"; | ||
|
@@ -766,17 +803,10 @@ | |
} | ||
|
||
} | ||
}); | ||
}.bind(this)); | ||
|
||
json.export_dpi = json.export_dpi || 0; | ||
|
||
// Format floating point values | ||
_.each(["x", "y", "width", "height"], function(a){ | ||
if (json[a] != "-") { | ||
json[a] = json[a].toFixed(0); | ||
} | ||
}); | ||
|
||
// Link IF we have a single remote image, E.g. http://jcb-dataviewer.rupress.org/jcb/img_detail/625679/ | ||
json.imageLink = false; | ||
if (remoteUrl) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed you can remove this
if
check now, sincem.toJSON()
won't give you any-
values.