This commit is contained in:
2019-06-19 13:53:29 +02:00
parent ad3948bd43
commit 8dcbe94188
2 changed files with 81 additions and 60 deletions

View File

@@ -1,9 +1,9 @@
#Fri May 24 10:01:14 CEST 2019
colormap=Temperature
#Thu Jun 06 15:17:49 CEST 2019
colormap=Grayscale
colormapAutomatic=true
colormapLogarithmic=false
colormapMax=10000.0
colormapMin=100.0
colormapMax=58981.0
colormapMin=0.0
custom=12345
flipHorizontally=false
flipVertically=false
@@ -23,9 +23,9 @@ rotation=0.0
rotationCrop=false
scale=1.0
serverURL=http\://gfa-lc6-64\:8889
spatialCalOffsetX=-637.6376332190395
spatialCalOffsetX=-637.4980411378614
spatialCalOffsetY=-483.5036425564949
spatialCalScaleX=-35.211268886073576
spatialCalScaleX=-35.21126887460907
spatialCalScaleY=-48.38709552593848
spatialCalUnits=mm
transpose=false

View File

@@ -261,47 +261,40 @@ public class ScreenPanel4 extends Panel {
}
}
Double getServerDouble(String name, StreamValue cache) {
try{
return (Double) Convert.toDouble(cache.__getitem__(name));
} catch (Exception ex){
return null;
}
}
double[] getServerDoubleArray(String name, StreamValue cache) {
try{
return (double[]) Convert.toDouble(cache.__getitem__(name));
} catch (Exception ex){
return null;
}
}
class ImageData {
ImageData() {
if (server != null) {
cache = server.getStream().take();
String prefix = goodRegion ? "gr_" : "";
x_fit_mean = getServerDouble(prefix + "x_fit_mean", cache);
y_fit_mean = getServerDouble(prefix + "y_fit_mean", cache);
x_fit_standard_deviation = getServerDouble(prefix + "x_fit_standard_deviation", cache);
y_fit_standard_deviation = getServerDouble(prefix + "y_fit_standard_deviation", cache);
x_fit_gauss_function = getServerDoubleArray(prefix + "x_fit_gauss_function", cache);
y_fit_gauss_function = getServerDoubleArray(prefix + "y_fit_gauss_function", cache);
x_profile = getServerDoubleArray("x_profile", cache);
y_profile = getServerDoubleArray("y_profile", cache);
x_center_of_mass = getServerDouble("x_center_of_mass", cache);
y_center_of_mass = getServerDouble("y_center_of_mass", cache);
x_rms = getServerDouble("x_rms", cache);
y_rms = getServerDouble("y_rms", cache);
x_fit_mean = getDouble(prefix + "x_fit_mean");
y_fit_mean = getDouble(prefix + "y_fit_mean");
x_fit_standard_deviation = getDouble(prefix + "x_fit_standard_deviation");
y_fit_standard_deviation = getDouble(prefix + "y_fit_standard_deviation");
x_fit_gauss_function = getDoubleArray(prefix + "x_fit_gauss_function");
y_fit_gauss_function = getDoubleArray(prefix + "y_fit_gauss_function");
x_profile = getDoubleArray("x_profile");
y_profile = getDoubleArray("y_profile");
x_center_of_mass = getDouble("x_center_of_mass");
y_center_of_mass = getDouble("y_center_of_mass");
x_rms = getDouble("x_rms");
y_rms = getDouble("y_rms");
if (goodRegion) {
double[] gX2 = new double[x_profile.length];
Arrays.fill(gX2, Double.NaN);
try {
double x = getServerDoubleArray("gr_x_axis", cache)[0];
double[] axis = getDoubleArray("x_axis");
gr_x_axis = getDoubleArray("gr_x_axis");
double x = gr_x_axis[0];
gr_size_x = x_fit_gauss_function.length;
//If gr axis values are not identical, calculate the index...
gr_pos_x = (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageX(x) : x);
//But prefer checking the value to avoid raounding errors
for (int i=0;i<axis.length; i++){
if (almostEqual(axis[i], x, 10e-6)){
gr_pos_x = i;
}
}
System.arraycopy(x_fit_gauss_function, 0, gX2, gr_pos_x, gr_size_x);
} catch (Exception ex) {
}
@@ -309,20 +302,29 @@ public class ScreenPanel4 extends Panel {
double[] gY2 = new double[y_profile.length];
Arrays.fill(gY2, Double.NaN);
try {
double y = getServerDoubleArray("gr_y_axis", cache)[0];
double[] axis = getDoubleArray("y_axis");
gr_y_axis = getDoubleArray("gr_y_axis");
double y = gr_y_axis[0];
gr_size_y = y_fit_gauss_function.length;
//If gr axis values are not identical, calculate the index...
gr_pos_y = (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageY(y) : y);
System.arraycopy(y_fit_gauss_function, 0, gY2, gr_pos_y, y_fit_gauss_function.length);
//But prefer checking the value to avoid raounding errors
for (int i=0;i<axis.length; i++){
if (almostEqual(axis[i], y, 10e-6)){
gr_pos_y = i;
}
}
System.arraycopy(y_fit_gauss_function, 0, gY2, gr_pos_y, gr_size_y);
} catch (Exception ex) {
}
y_fit_gauss_function = gY2;
if (slicing) {
try {
int slices = getServerDouble("slice_amount").intValue();
int slices = getDouble("slice_amount").intValue();
sliceCenters = new PointDouble[slices];
for (int i = 0; i < slices; i++) {
double x = getServerDouble("slice_" + i + "_center_x");
double y = getServerDouble("slice_" + i + "_center_y");
double x = getDouble("slice_" + i + "_center_x");
double y = getDouble("slice_" + i + "_center_y");
sliceCenters[i] = new PointDouble(x, y);
}
} catch (Exception ex) {
@@ -343,14 +345,36 @@ public class ScreenPanel4 extends Panel {
public double[] x_fit_gauss_function;
public double[] y_profile;
public double[] y_fit_gauss_function;
public double[] gr_x_axis;
public double[] gr_y_axis;
public int gr_size_x;
public int gr_pos_x;
public int gr_size_y;
public int gr_pos_y;
public PointDouble[] sliceCenters;
public StreamValue cache;
Double getDouble(String name) {
try{
return (Double) Convert.toDouble(cache.__getitem__(name));
} catch (Exception ex){
return null;
}
}
double[] getDoubleArray(String name) {
try{
return (double[]) Convert.toDouble(cache.__getitem__(name));
} catch (Exception ex){
return null;
}
}
}
public static boolean almostEqual(double a, double b, double eps){
return Math.abs(a-b)<eps;
}
class Frame extends ImageData {
Frame(Data data) {
@@ -1695,10 +1719,10 @@ public class ScreenPanel4 extends Panel {
int height = data.getHeight();
int width = data.getWidth();
int profileSize = renderer.getProfileSize();
ImageData id = null;
if ((useServerStats) && (server != null)) {
try {
ImageData id = getFrame(data);
id = getFrame(data);
if (id == null) {
return null;
}
@@ -1778,7 +1802,7 @@ public class ScreenPanel4 extends Panel {
xp[i] = (int) (((pY[i] - minProfile) / rangeProfile) * profileSize);
}
if (goodRegion && id.gr_size_x > 0) {
if (goodRegion && id.gr_size_y > 0) {
xg = Arrays.copyOfRange(xg, id.gr_pos_y, id.gr_pos_y + id.gr_size_y);
yg = Arrays.copyOfRange(yg, id.gr_pos_y, id.gr_pos_y + id.gr_size_y);
}
@@ -1935,20 +1959,16 @@ public class ScreenPanel4 extends Panel {
textPosition = new Point(textPosition.x, textPosition.y + 34);
fOv = new Overlay[]{hgaussian, vgaussian, cross, textFit};
if (goodRegion) {
try {
double[] x = getServerDoubleArray("gr_x_axis");
double[] y = getServerDoubleArray("gr_y_axis");
double x1 = x[0];
double x2 = x[x.length - 1];
double y1 = y[0];
double y2 = y[y.length - 1];
if (goodRegion && (id != null)) {
try {
double[] x = id.gr_x_axis;
double[] y = id.gr_y_axis;
Overlays.Rect goodRegionOv = new Overlays.Rect(new Pen(penFit.getColor(), 0, Pen.LineStyle.dotted));
goodRegionOv.setCalibration(renderer.getCalibration());
goodRegionOv.setAbsolutePosition(new PointDouble(x1, y1));
goodRegionOv.setAbsoluteSize(new DimensionDouble(x2 - x1, y2 - y1));
goodRegionOv.setPosition(new Point(id.gr_pos_x, id.gr_pos_y));
goodRegionOv.setSize(new Dimension(id.gr_x_axis.length, id.gr_y_axis.length));
fOv = Arr.append(fOv, goodRegionOv);
if (slicing) {
if (sliceCenters != null) {
for (PointDouble sliceCenter : sliceCenters) {
@@ -2061,6 +2081,7 @@ public class ScreenPanel4 extends Panel {
Overlay[] getUserOverlays(Data data) {
ArrayList<Overlay> ret = new ArrayList<>();
if (server != null) {
ImageData id = getFrame(data);
for (UserOverlay uo : userOverlayConfig) {
try {
Overlay ov = uo.obj;
@@ -2068,8 +2089,8 @@ public class ScreenPanel4 extends Panel {
ov.setCalibration(renderer.getCalibration());
boolean valid = false;
if (ov instanceof Overlays.Polyline) {
double[] x = (uo.channels[0].equals("null")) ? null : getServerDoubleArray(uo.channels[0]);
double[] y = (uo.channels[1].equals("null")) ? null : getServerDoubleArray(uo.channels[1]);
double[] x = (uo.channels[0].equals("null")) ? null : id.getDoubleArray(uo.channels[0]);
double[] y = (uo.channels[1].equals("null")) ? null : id.getDoubleArray(uo.channels[1]);
if ((x != null) || (y != null)) {
if (x == null) {
x = (renderer.getCalibration() == null) ? Arr.indexesDouble(y.length) : renderer.getCalibration().getAxisX(y.length);
@@ -2081,14 +2102,14 @@ public class ScreenPanel4 extends Panel {
valid = true;
}
} else {
Double x = getServerDouble(uo.channels[0]);
Double y = getServerDouble(uo.channels[1]);
Double x = id.getDouble(uo.channels[0]);
Double y = id.getDouble(uo.channels[1]);
if ((x != null) && (y != null)) {
PointDouble position = new PointDouble(x, y);
ov.setAbsolutePosition(position);
if (!(ov instanceof Overlays.Crosshairs)) {
Double x2 = getServerDouble(uo.channels[2]);
Double y2 = getServerDouble(uo.channels[3]);
Double x2 = id.getDouble(uo.channels[2]);
Double y2 = id.getDouble(uo.channels[3]);
if ((x != null) && (y != null)) {
DimensionDouble size = new DimensionDouble(x2 - position.x, y2 - position.y);
ov.setAbsoluteSize(size);