Apply azimuth to arrows and add arrow for X-rays and
This commit is contained in:
@@ -351,12 +351,26 @@ tilt_horizontal.polling=500
|
||||
manip_x.polling=500
|
||||
manip_y.polling=500
|
||||
fov.polling=5000
|
||||
azimuth_rot.precision=2
|
||||
azimuth_rot.precision=1
|
||||
azimuth_rot.polling=5000
|
||||
bv.polling=1000
|
||||
fil.polling=1000
|
||||
|
||||
|
||||
#Create a listener to the sensor, verifying the readback values.
|
||||
class ListenerAzimuth (DeviceListener):
|
||||
def onCacheChanged(self, device, value, former, timestamp,value_changed):
|
||||
if (device is azimuth_rot) and (value is not None):
|
||||
if value_changed:
|
||||
if self.debug:
|
||||
print "Azimuth angle changed: " + str(value)
|
||||
try:
|
||||
set_azimuth_rot(value)
|
||||
except:
|
||||
if self.debug:
|
||||
self.getLogger().warning(str(sys.exc_info()[1]))
|
||||
listenerAzimuth = ListenerAzimuth()
|
||||
listenerAzimuth.debug=True
|
||||
azimuth_rot.addListener(listenerAzimuth)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,9 @@ FOV_ARROWS = { \
|
||||
run("imaging/FOV_table")
|
||||
|
||||
FOV_ARROWS_SIZE=80
|
||||
FOV_XRAY_ARROW_SIZE=120
|
||||
FOV_LABEL_POS=FOV_ARROWS_SIZE+15
|
||||
FOV_XRAY_LABEL_POS=FOV_XRAY_ARROW_SIZE+15
|
||||
#FOV_ARROWS_ORIGIN=Point(image.getData().width/4, image.getData().height*3/4)
|
||||
#FOV_ARROWS_ORIGIN=Point(image.getData().width*3/4, image.getData().height/4)
|
||||
FOV_ARROWS_ORIGIN=Point(image.getData().width-(FOV_LABEL_POS+5), FOV_LABEL_POS+5)
|
||||
@@ -30,9 +32,15 @@ def set_fov_offset(value):
|
||||
global FOV_OFFSET
|
||||
FOV_OFFSET = value
|
||||
update_arrows()
|
||||
|
||||
def set_azimuth_rot(value):
|
||||
global AZIMUTH_ROT
|
||||
AZIMUTH_ROT = value
|
||||
update_arrows()
|
||||
|
||||
|
||||
def update_arrows():
|
||||
global arrows_renderer, arrow_x, arrow_y, arrow_a, label_x, label_y
|
||||
global arrows_renderer, arrow_x, arrow_y, arrow_a, label_x, label_y, label_a
|
||||
if arrows_renderer is not None:
|
||||
args = FOV_ARROWS.get(fov.take(), None)
|
||||
if args is not None:
|
||||
@@ -41,8 +49,10 @@ def update_arrows():
|
||||
angle=angle+180
|
||||
x,y = FOV_ARROWS_ORIGIN.x, FOV_ARROWS_ORIGIN.y
|
||||
a=math.radians(angle)
|
||||
xa,ya=int(x+FOV_ARROWS_SIZE*math.cos(a)), int(y-FOV_ARROWS_SIZE*math.sin(a))
|
||||
xa,ya=int(x+FOV_XRAY_ARROW_SIZE*math.cos(a)), int(y-FOV_XRAY_ARROW_SIZE*math.sin(a))
|
||||
arrow_a.update(FOV_ARROWS_ORIGIN, Point(xa,ya))
|
||||
xa,ya=int(x+FOV_XRAY_LABEL_POS*math.cos(a)), int(y-FOV_XRAY_LABEL_POS*math.sin(a))
|
||||
label_a.update(Point(xa,ya))
|
||||
angle=angle+azimuth
|
||||
a=math.radians(angle)
|
||||
xa,ya=int(x+FOV_ARROWS_SIZE*math.cos(a)), int(y-FOV_ARROWS_SIZE*math.sin(a))
|
||||
@@ -60,8 +70,10 @@ def update_arrows():
|
||||
arrow_x.update(FOV_ARROWS_ORIGIN, FOV_ARROWS_ORIGIN)
|
||||
arrow_y.update(FOV_ARROWS_ORIGIN, FOV_ARROWS_ORIGIN)
|
||||
arrow_a.update(FOV_ARROWS_ORIGIN, FOV_ARROWS_ORIGIN)
|
||||
label_a.update(label_a.UNDEFINED_POINT)
|
||||
label_x.update(label_x.UNDEFINED_POINT)
|
||||
label_y.update(label_y.UNDEFINED_POINT)
|
||||
arrows_renderer.refresh()
|
||||
|
||||
def task_update_arrows():
|
||||
global arrows_renderer
|
||||
@@ -76,7 +88,7 @@ def task_update_arrows():
|
||||
|
||||
|
||||
def start_arrows(renderer=None):
|
||||
global arrows_renderer, arrow_x, arrow_y, arrow_a, label_x, label_y, FOV_FUTURE
|
||||
global arrows_renderer, arrow_x, arrow_y, arrow_a, label_x, label_y, label_a, FOV_FUTURE
|
||||
if arrows_renderer is None:
|
||||
arrows_renderer = renderer if renderer else show_panel(image)
|
||||
arrow_x = Overlays.Arrow(Pen(FOV_COLOR_X))
|
||||
@@ -84,15 +96,16 @@ def start_arrows(renderer=None):
|
||||
arrow_a = Overlays.Arrow(Pen(FOV_COLOR_A))
|
||||
label_x = Overlays.Text(arrow_x.pen, "X",FOV_LABEL_FONT)
|
||||
label_y = Overlays.Text(arrow_y.pen, "Y",FOV_LABEL_FONT)
|
||||
arrows_renderer.addOverlays([arrow_a, arrow_x,arrow_y,label_x, label_y])
|
||||
label_a = Overlays.Text(arrow_a.pen, "X-rays",FOV_LABEL_FONT)
|
||||
arrows_renderer.addOverlays([arrow_a, label_a, arrow_x,arrow_y,label_x, label_y])
|
||||
#update_arrows()
|
||||
FOV_FUTURE = fork(task_update_arrows,)[0]
|
||||
|
||||
|
||||
def stop_arrows(renderer=None):
|
||||
global arrows_renderer, arrow_x, arrow_y, label_x, label_y, FOV_FUTURE
|
||||
global arrows_renderer, arrow_x, arrow_y, label_x, label_y, label_a, FOV_FUTURE
|
||||
if arrows_renderer is not None:
|
||||
arrows_renderer.removeOverlays([arrow_a, arrow_x,arrow_y, label_x, label_y])
|
||||
arrows_renderer.removeOverlays([arrow_a, label_a, arrow_x,arrow_y, label_x, label_y])
|
||||
arrows_renderer=None
|
||||
if FOV_FUTURE is not None:
|
||||
FOV_FUTURE.cancel(True)
|
||||
|
||||
Reference in New Issue
Block a user