Apply azimuth to arrows and add arrow for X-rays and

This commit is contained in:
gac-x11ma
2022-12-23 11:16:39 +01:00
parent c22008e50e
commit 6b5eb4147b
4 changed files with 103 additions and 60 deletions

View File

@@ -34,9 +34,9 @@
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonAbort" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="renderer" max="32767" attributes="0"/>
<Component id="renderer" pref="448" max="32767" attributes="0"/>
</Group>
<EmptySpace pref="17" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -44,8 +44,8 @@
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel4" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Component id="renderer" min="-2" pref="638" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="renderer" max="32767" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="checkMeasurements" alignment="3" min="-2" max="-2" attributes="0"/>
@@ -54,7 +54,7 @@
<Component id="checkArrows" min="-2" max="-2" attributes="0"/>
<Component id="buttonAbort" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace min="-2" pref="10" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -73,28 +73,27 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="jPanel3" alignment="0" max="32767" attributes="0"/>
<Component id="jPanel2" alignment="0" max="32767" attributes="0"/>
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace pref="19" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="jPanel3" alignment="0" max="32767" attributes="0"/>
<Component id="jPanel2" alignment="0" max="32767" attributes="0"/>
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
<Component id="jLabel10" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="deviceValuePanel1" min="-2" pref="78" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel13" min="-2" pref="41" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="deviceValuePanel1" min="-2" pref="70" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jLabel13" min="-2" pref="29" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="deviceValuePanel2" pref="0" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel16" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="panelAzimuth" min="-2" pref="59" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -108,16 +107,13 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="deviceValuePanel1" min="-2" max="-2" attributes="0"/>
<Component id="deviceValuePanel2" min="-2" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<EmptySpace min="9" pref="9" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel10" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel13" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="jLabel10" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="jLabel13" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="jLabel16" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="deviceValuePanel1" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="deviceValuePanel2" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="panelAzimuth" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
@@ -664,6 +660,17 @@
<Property name="deviceName" type="java.lang.String" value="fov"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel16">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Az:"/>
</Properties>
</Component>
<Component class="ch.psi.pshell.swing.DeviceValuePanel" name="panelAzimuth">
<Properties>
<Property name="deviceName" type="java.lang.String" value="azimuth_rot"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JCheckBox" name="checkMeasurements">

View File

@@ -172,6 +172,8 @@ public class Imaging extends Panel {
jLabel10 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
deviceValuePanel2 = new ch.psi.pshell.swing.DeviceValuePanel();
jLabel16 = new javax.swing.JLabel();
panelAzimuth = new ch.psi.pshell.swing.DeviceValuePanel();
checkMeasurements = new javax.swing.JCheckBox();
jLabel11 = new javax.swing.JLabel();
checkArrows = new javax.swing.JCheckBox();
@@ -543,29 +545,35 @@ public class Imaging extends Panel {
deviceValuePanel2.setDeviceName("fov");
jLabel16.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel16.setText("Az:");
panelAzimuth.setDeviceName("azimuth_rot");
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(19, Short.MAX_VALUE))
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel4Layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(jLabel10)
.addGap(0, 0, 0)
.addComponent(deviceValuePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(deviceValuePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)
.addComponent(deviceValuePanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addContainerGap())))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel16)
.addGap(0, 0, 0)
.addComponent(panelAzimuth, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -577,14 +585,13 @@ public class Imaging extends Panel {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel10)
.addComponent(jLabel13)
.addComponent(jLabel16)
.addComponent(deviceValuePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(deviceValuePanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel4Layout.createSequentialGroup()
.addGap(9, 9, 9)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel10)
.addComponent(jLabel13))))
.addComponent(panelAzimuth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
@@ -628,14 +635,14 @@ public class Imaging extends Panel {
.addComponent(checkArrows)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonAbort))
.addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(17, Short.MAX_VALUE))
.addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, 448, Short.MAX_VALUE))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(renderer, javax.swing.GroupLayout.PREFERRED_SIZE, 638, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
@@ -643,7 +650,7 @@ public class Imaging extends Panel {
.addComponent(jLabel11))
.addComponent(checkArrows)
.addComponent(buttonAbort))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(10, 10, 10))
);
}// </editor-fold>//GEN-END:initComponents
@@ -830,6 +837,7 @@ public class Imaging extends Panel {
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
@@ -842,6 +850,7 @@ public class Imaging extends Panel {
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel5;
private ch.psi.pshell.swing.DeviceValuePanel panelAzimuth;
private ch.psi.pshell.swing.ProcessVariablePanel processVariablePanel1;
private ch.psi.pshell.swing.ProcessVariablePanel processVariablePanel2;
private javax.swing.JRadioButton radioAll;

View File

@@ -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)

View File

@@ -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)