Skip to content
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

Add information line on SVG export to give information on image size #1147

Closed
wants to merge 1 commit into from

Conversation

lisham2000
Copy link
Contributor

No description provided.

Copy link
Collaborator

@cmeyer cmeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made code comments - but overall, I think the look and feel of this could be improved. The three lines, without spacing, don't look that great. What about expanding the width of the dialog? Maybe bounce this around to other people and see if they have suggestions.

nion/swift/ExportDialog.py Outdated Show resolved Hide resolved
nion/swift/ExportDialog.py Outdated Show resolved Hide resolved
nion/swift/ExportDialog.py Outdated Show resolved Hide resolved
nion/swift/ExportDialog.py Outdated Show resolved Hide resolved
Comment on lines 288 to 295
calibrated_image_size = (self.__display_item.dimensional_shape[0] * self.__display_item.data_item.dimensional_calibrations[0].scale,
self.__display_item.dimensional_shape[1] * self.__display_item.data_item.dimensional_calibrations[1].scale)
data_information += ("(" + str(calibrated_image_size[0]) + " " + self.__display_item.data_item.dimensional_calibrations[0].units + "," +
str(calibrated_image_size[1]) + " " + self.__display_item.data_item.dimensional_calibrations[1].units + ")")
else:
data_information += "Line Plot Size " + str(self.__display_item.dimensional_shape[0])
calibrated_line_plot_size = self.__display_item.dimensional_shape[0] * self.__display_item.data_item.dimensional_calibrations[0].scale
data_information += ("(" + str(calibrated_line_plot_size) + " " + self.__display_item.data_item.dimensional_calibrations[0].units + ")")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid having to look into the display_item.data_item, which is None for composite displays, you can use display_item.displayed_dimensional_calibrations which will give the dimensional calibrations for images, line plots, and composites.

@lisham2000 lisham2000 marked this pull request as draft September 9, 2024 13:31
u = Declarative.DeclarativeUI()
self._float_to_string_converter = Converter.FloatToStringConverter()
self.ui_view = u.create_column(
self.ui_view = u.create_column(u.create_row(
u.create_label(text="@binding(model.image_info)", word_wrap=True), spacing=12),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you have a row to contain a single object (the label)?

nion/swift/ExportDialog.py Show resolved Hide resolved
@lisham2000 lisham2000 marked this pull request as ready for review September 19, 2024 11:00
Copy link
Contributor

@KRLango KRLango left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The excess row should be removed. Otherwise I am happy with this now.

Copy link
Collaborator

@cmeyer cmeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First note is that this PR doesn't rebase cleanly, so you might want to consider closing and opening a new PR with just the one file. Alternatively you can rebase it yourself and force push to your PR branch.

Next, I think you need to have a uniform way of displaying calibrations with the correct precision. The inspector has a way to do this based on the data dimensions.

Review the code in the CalibratedSizeFloatToStringConverter class in Inspector.py, particularly the convert_calibrated_value_to_str method of that class. I think you can use that class directly.

Without that fix, I get results like this (from exporting the Ronchigram simulator image):

image

nion/swift/ExportDialog.py Outdated Show resolved Hide resolved
nion/swift/ExportDialog.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@cmeyer cmeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks very close (see my comments about using displayed_dimensional_calibrations from today; and my comments about using CalibratedSizeFloatToStringConverter from last week), but also needs a clean commit. Easiest way from your branch:

git reset --soft master
git commit -m "Add data info line to SVG export dialog."
git show  # to ensure it's as expected
git push --force

Comment on lines 285 to 295
assert self.__display_item.data_item and self.__display_item.dimensional_shape
calibrated_image_size = (self.__display_item.dimensional_shape[-2] * self.__display_item.data_item.dimensional_calibrations[-2].scale,
self.__display_item.dimensional_shape[-1] * self.__display_item.data_item.dimensional_calibrations[-1].scale)
data_information += ("(" + str(calibrated_image_size[-2]) + " " + self.__display_item.data_item.dimensional_calibrations[-2].units + "," +
str(calibrated_image_size[-1]) + " " + self.__display_item.data_item.dimensional_calibrations[-1].units + ")")
else:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change these lines to use display_item.displayed_dimensional_calibrations like the other clause?

@lisham2000
Copy link
Contributor Author

Overall this looks very close (see my comments about using displayed_dimensional_calibrations from today; and my comments about using CalibratedSizeFloatToStringConverter from last week), but also needs a clean commit. Easiest way from your branch:

git reset --soft master
git commit -m "Add data info line to SVG export dialog."
git show  # to ensure it's as expected
git push --force

I have run these git commands and it has put it to one commit but it now says it has changes 22 files just checking this is right?

@lisham2000
Copy link
Contributor Author

On further review this doesnt look right at all and it is no longer building. With the state of this PR to get it into one clean commit i am closing this PR and it has been replaced by #1192

@lisham2000 lisham2000 closed this Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants