Skip to content

WIP Adapted Qt-relevant files to let Qt version work with the new AbstractDiffractometer - #1659

Open
rhfogh wants to merge 10 commits into
mxcube:developfrom
rhfogh:rhfogh_develop
Open

WIP Adapted Qt-relevant files to let Qt version work with the new AbstractDiffractometer#1659
rhfogh wants to merge 10 commits into
mxcube:developfrom
rhfogh:rhfogh_develop

Conversation

@rhfogh

@rhfogh rhfogh commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

The main work is by Martin Savko, making QtGraphicsManager a subtype of SampleView - which should impact the Qt version only. There are other adjustments, and some GPhL-specific fixes. The version is smoke-tested with both the Qt and web version in mock mode.


logging.getLogger("HWR").debug("X=%s,Y=%s", X, Y)
chi_angle = math.radians(chi_angle)
chi_angle = math.radians(chi_angle) if chi_angle else 0.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Dont think you need if chi_angle else 0 as you use a kwarg for chi_angle above ?

sampx.motor: float(sampx.get_value() + sampx.direction * dx),
sampy.motor: float(sampy.get_value() + sampy.direction * dy),
phiz.motor: (
sampx: float(sampx.get_value() + sampx.direction * dx),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not sure about this one. The previous code used a Motor object as a key while this code would use CentringMotor object. Would that still be compatible with the calling code ? Neither is good practice but I don't think this is the good moment to change that ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Agree with @marcus-oscarsson

pixels_per_mm = diffr.get_pixels_per_mm()
diffr.wait_status_ready(5)

print(f"self.centring_motors {self.centring_motors}")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please Replace with log if the print is needed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Or remove it.

"centringFailed",
self.diffractometer_centring_failed,
)
#self.connect(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this could or most likely will break a number of things ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Indeed.

self.emit("centringAccepted", (True, self.get_centring_status()))
args = (True, self.get_centring_status())
self.emit("centringAccepted", args)
self.create_centring_point(*args)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this should be done in the handler that listens to centringAccepted

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Indeed only the signal emit is needed here.

@marcus-oscarsson

marcus-oscarsson commented Sep 2, 2026

Copy link
Copy Markdown
Member

Looks good overall,

I'm concerned about the changes made to sample_centring.py
and SampleView.py. I think there are some changes that are a bit risky.

  1. sample_centring - I'm not certain about the impact of removing .motor
  2. SampleView - Addition of self.create_centring_point(*args)

@rhfogh rhfogh changed the title Adapted Qt-relevant files to let Qt version work with the new AbstractDiffractometer WIP Adapted Qt-relevant files to let Qt version work with the new AbstractDiffractometer Sep 2, 2026
@rhfogh rhfogh added the wip Work in progress label Sep 2, 2026
@rhfogh

rhfogh commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator Author

@marcus-oscarsson Thanks for checking. I have changed this to WIP, and I think we need to wait for Martin Savko's input. He was the one who did the changes, and I had done a quick smoke test, found it worked, and made the PR. Maybe that was a mistake. Anyway with some of your comments I think we had better hear from Martin either why this is all OK, or that he does not think this is yet ready for merging and what might need doing.
My apologies for jumping the gun.

@marcus-oscarsson

Copy link
Copy Markdown
Member

No problem, its of course very much appreciated that both of you would like to advance. You did well :). We are using both SampleView and sample_centring. I guess others are as well at-least SampleView so its better to a bit cautious. I think your PR on mxcubeweb can still be merged there did not seem to be direct link ?

Martin Savko and others added 8 commits September 2, 2026 15:59
MotorMockup.py:
   default direction is 1
sample_centring.py:
  motor.motor -> motor e.g. sampx.motor -> sampx
queue_model_objects.py:
   call set_diffractometer_motor_names(names) in __init__()
comment out lights for now in the config file for now.

@beteva beteva left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Dear @rhfogh, thanks for doing the adaptation of the Qt. Most of it is fine, just few comments:
The GenericDiffractometer should not be involved if you go for AbstractDiffractometer.
Some of the changes in SampleView will actually break it.

Comment on lines +128 to +132
def accept_centring(self):
return True

def user_confirms_centring(self):
return False

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Everything concerning the centring is now in SampleView.

Suggested change
def accept_centring(self):
return True
def user_confirms_centring(self):
return False

Comment on lines +124 to +127

def use_sample_changer(self):
return True

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this really needed?


CENTRING_MOTORS_NAME = [
"phi",
"omega",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

GenericDiffractometer should be replaced by AbstractDiffractometer.

for key, val in self.centring_motors.items():
motors_dict.update({key: val.motor.get_value()})
motors_dict = dict(
(key, val.get_value()) for key, val in self.centring_motors.items()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
(key, val.get_value()) for key, val in self.centring_motors.items()
(key, val.motor.get_value()) for key, val in self.centring_motors.items()

Do you really need to change this for the sake of a one line less? 😄

pixels_per_mm = diffr.get_pixels_per_mm()
diffr.wait_status_ready(5)

print(f"self.centring_motors {self.centring_motors}")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Or remove it.

self.emit("centringAccepted", (True, self.get_centring_status()))
args = (True, self.get_centring_status())
self.emit("centringAccepted", args)
self.create_centring_point(*args)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Indeed only the signal emit is needed here.

Comment on lines +367 to +368
args = (False, self.get_centring_status())
self.emit("centringAccepted", args)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What was the reason to define args?

for mot in self.motors_hwobj_dict.values():
mot.set_value(random.uniform(0.0, 8.8))
self.omega.set_value(random.uniform(0, 359.9))
self.omega.set_value(random.uniform(0, 360))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

?

Comment on lines +296 to +298

def get_image_scale_list(self):
return [1]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you, please, tell us what is this used for?

@rhfogh

rhfogh commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator Author

@beteva As I said to Marcus, this is (almost) all Martin's work, and it is possible that I went with an incomplete version. I take your comments on board, but I think we need Martin to react to them first before I start making changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wip Work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants