Skip to content

Commit c1f0189

Browse files
authored
Merge pull request #2344 from ControlSystemStudio/image_offset
PVA: Support NTNDArray's 'reverse' and 'offset'
2 parents 0214c07 + 5734c9d commit c1f0189

File tree

14 files changed

+348
-50
lines changed

14 files changed

+348
-50
lines changed

app/display/model/.classpath

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<classpathentry combineaccessrules="false" kind="src" path="/core-util"/>
99
<classpathentry combineaccessrules="false" kind="src" path="/core-ui"/>
1010
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
11-
<classpathentry kind="lib" path="/phoebus-target/target/lib/epics-util-1.0.4.jar"/>
12-
<classpathentry kind="lib" path="/phoebus-target/target/lib/vtype-1.0.4.jar"/>
11+
<classpathentry kind="lib" path="/phoebus-target/target/lib/epics-util-1.0.5.jar"/>
12+
<classpathentry kind="lib" path="/phoebus-target/target/lib/vtype-1.0.5.jar"/>
1313
<classpathentry kind="output" path="target/classes"/>
1414
</classpath>

app/display/representation-javafx/src/main/java/org/csstudio/display/builder/representation/javafx/widgets/plots/ImageRepresentation.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,30 @@ else if (value instanceof VImage)
454454
final int width = image.getWidth();
455455
final int height = image.getHeight();
456456
if (model_widget.propLimitsFromPV().getValue())
457-
image_plot.setAxisRange(0.0, width, height, 0.0);
457+
{
458+
final int x0, x1, y0, y1;
459+
if (image.isXReversed())
460+
{
461+
x1 = image.getXOffset();
462+
x0 = image.getXOffset() + width;
463+
}
464+
else
465+
{
466+
x0 = image.getXOffset();
467+
x1 = image.getXOffset() + width;
468+
}
469+
if (image.isYReversed())
470+
{
471+
y1 = image.getYOffset() + height;
472+
y0 = image.getYOffset();
473+
}
474+
else
475+
{
476+
y0 = image.getYOffset() + height;
477+
y1 = image.getYOffset();
478+
}
479+
image_plot.setAxisRange(x0, x1, y0, y1);
480+
}
458481
image_plot.setValue(width, height, image.getData(),
459482
isUnsigned, image.getVImageType());
460483
}

app/display/representation-javafx/src/main/java/org/csstudio/display/builder/representation/javafx/widgets/plots/XYPlotRepresentation.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2015-2020 Oak Ridge National Laboratory.
2+
* Copyright (c) 2015-2022 Oak Ridge National Laboratory.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
@@ -44,6 +44,8 @@
4444
import org.csstudio.javafx.rtplot.internal.NumericAxis;
4545
import org.epics.util.array.ArrayDouble;
4646
import org.epics.util.array.ListNumber;
47+
import org.epics.vtype.Display;
48+
import org.epics.vtype.VImage;
4749
import org.epics.vtype.VNumber;
4850
import org.epics.vtype.VNumberArray;
4951
import org.epics.vtype.VType;
@@ -286,11 +288,22 @@ private void computeTrace()
286288
return;
287289

288290
final ListNumber x_data, y_data, error;
289-
final VType y_value = model_trace.traceYValue().getValue();
291+
VType y_value = model_trace.traceYValue().getValue();
292+
293+
if (y_value instanceof VImage)
294+
{ // Extract VNumberArray from image, then continue with that
295+
final VImage image = (VImage) y_value;
296+
y_value = VNumberArray.of(image.getData(), image.getAlarm(), image.getTime(), Display.none());
297+
}
290298

291299
if (y_value instanceof VNumberArray)
292300
{
293-
final VType x_value = model_trace.traceXValue().getValue();
301+
VType x_value = model_trace.traceXValue().getValue();
302+
if (x_value instanceof VImage)
303+
{ // Extract VNumberArray from image, then continue with that
304+
final VImage image = (VImage) x_value;
305+
x_value = VNumberArray.of(image.getData(), image.getAlarm(), image.getTime(), Display.none());
306+
}
294307
x_data = (x_value instanceof VNumberArray) ? ((VNumberArray)x_value).getData() : null;
295308

296309
final VNumberArray y_array = (VNumberArray)y_value;
@@ -323,7 +336,12 @@ else if (y_value instanceof VNumber)
323336
else
324337
{ // No Y Data.
325338
// Do we have X data?
326-
final VType x_value = model_trace.traceXValue().getValue();
339+
VType x_value = model_trace.traceXValue().getValue();
340+
if (x_value instanceof VImage)
341+
{ // Extract VNumberArray from image, then continue with that
342+
final VImage image = (VImage) x_value;
343+
x_value = VNumberArray.of(image.getData(), image.getAlarm(), image.getTime(), Display.none());
344+
}
327345
if (x_value instanceof VNumberArray)
328346
{
329347
x_data = ((VNumberArray)x_value).getData();

app/rtplot/.classpath

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<classpathentry combineaccessrules="false" kind="src" path="/core-framework"/>
99
<classpathentry combineaccessrules="false" kind="src" path="/core-util"/>
1010
<classpathentry combineaccessrules="false" kind="src" path="/core-ui"/>
11-
<classpathentry kind="lib" path="/phoebus-target/target/lib/epics-util-1.0.4.jar"/>
12-
<classpathentry kind="lib" path="/phoebus-target/target/lib/vtype-1.0.4.jar"/>
11+
<classpathentry kind="lib" path="/phoebus-target/target/lib/epics-util-1.0.5.jar"/>
12+
<classpathentry kind="lib" path="/phoebus-target/target/lib/vtype-1.0.5.jar"/>
1313
<classpathentry kind="output" path="target/classes"/>
1414
</classpath>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2022 Oak Ridge National Laboratory.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
******************************************************************************/
8+
package org.csstudio.apputil.formula.areadetector;
9+
10+
import java.util.Arrays;
11+
import java.util.List;
12+
13+
import org.csstudio.apputil.formula.spi.FormulaFunction;
14+
import org.epics.vtype.Display;
15+
import org.epics.vtype.VImage;
16+
import org.epics.vtype.VNumberArray;
17+
import org.epics.vtype.VType;
18+
19+
/** A formula function for fetching VImage array data
20+
* @author Kay Kasemir
21+
*/
22+
public class ImageValueFunction implements FormulaFunction
23+
{
24+
@Override
25+
public String getCategory()
26+
{
27+
return "areaDetector";
28+
}
29+
30+
@Override
31+
public String getName()
32+
{
33+
return "imageValue";
34+
}
35+
36+
@Override
37+
public String getDescription()
38+
{
39+
return "Fetch array data of image";
40+
}
41+
42+
@Override
43+
public List<String> getArguments()
44+
{
45+
return List.of("image");
46+
}
47+
48+
/** Fetch info from image
49+
* @param image Image
50+
* @return VType to return from function
51+
*/
52+
protected VType getImageData(final VImage image)
53+
{
54+
return VNumberArray.of(image.getData(), image.getAlarm(), image.getTime(), Display.none());
55+
}
56+
57+
@Override
58+
public VType compute(final VType... args) throws Exception
59+
{
60+
if (args.length != 1 || ! (args[0] instanceof VImage))
61+
throw new Exception("Function " + getName() +
62+
" takes VImage but received " + Arrays.toString(args));
63+
return getImageData((VImage) args[0]);
64+
}
65+
}

core/formula/src/main/java/org/csstudio/apputil/formula/areadetector/ImageWidthFunction.java

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
******************************************************************************/
88
package org.csstudio.apputil.formula.areadetector;
99

10-
import java.util.Arrays;
11-
import java.util.List;
12-
13-
import org.csstudio.apputil.formula.spi.FormulaFunction;
1410
import org.epics.vtype.Display;
1511
import org.epics.vtype.VImage;
1612
import org.epics.vtype.VInt;
@@ -19,14 +15,8 @@
1915
/** A formula function for fetching width of VImage
2016
* @author Kay Kasemir
2117
*/
22-
public class ImageWidthFunction implements FormulaFunction
18+
public class ImageWidthFunction extends ImageValueFunction
2319
{
24-
@Override
25-
public String getCategory()
26-
{
27-
return "areaDetector";
28-
}
29-
3020
@Override
3121
public String getName()
3222
{
@@ -39,12 +29,6 @@ public String getDescription()
3929
return "Fetch width of image";
4030
}
4131

42-
@Override
43-
public List<String> getArguments()
44-
{
45-
return List.of("image");
46-
}
47-
4832
/** Fetch info (width, height, ...) from image
4933
*
5034
* Subclass can override
@@ -58,13 +42,8 @@ protected int getImageInfo(final VImage image)
5842
}
5943

6044
@Override
61-
public VType compute(final VType... args) throws Exception
45+
protected VType getImageData(final VImage image)
6246
{
63-
if (args.length != 1 || ! (args[0] instanceof VImage))
64-
throw new Exception("Function " + getName() +
65-
" takes VImage but received " + Arrays.toString(args));
66-
67-
final VImage image = (VImage) args[0];
6847
return VInt.of(getImageInfo(image), image.getAlarm(), image.getTime(), Display.none());
6948
}
7049
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2022 Oak Ridge National Laboratory.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
******************************************************************************/
8+
package org.csstudio.apputil.formula.areadetector;
9+
10+
import org.epics.vtype.VImage;
11+
12+
/** A formula function for fetching offset of VImage
13+
* @author Kay Kasemir
14+
*/
15+
public class ImageXOffsetFunction extends ImageWidthFunction
16+
{
17+
@Override
18+
public String getName()
19+
{
20+
return "imageXOffset";
21+
}
22+
23+
@Override
24+
public String getDescription()
25+
{
26+
return "Fetch horizontal offset of image";
27+
}
28+
29+
@Override
30+
protected int getImageInfo(final VImage image)
31+
{
32+
return image.getXOffset();
33+
}
34+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2022 Oak Ridge National Laboratory.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
******************************************************************************/
8+
package org.csstudio.apputil.formula.areadetector;
9+
10+
import java.util.Arrays;
11+
import java.util.List;
12+
13+
import org.csstudio.apputil.formula.spi.FormulaFunction;
14+
import org.epics.vtype.VBoolean;
15+
import org.epics.vtype.VImage;
16+
import org.epics.vtype.VType;
17+
18+
/** A formula function for fetching horizontal reversal of VImage
19+
* @author Kay Kasemir
20+
*/
21+
public class ImageXReversedFunction implements FormulaFunction
22+
{
23+
@Override
24+
public String getCategory()
25+
{
26+
return "areaDetector";
27+
}
28+
29+
@Override
30+
public String getName()
31+
{
32+
return "imageXReversed";
33+
}
34+
35+
@Override
36+
public String getDescription()
37+
{
38+
return "Fetch horizontal reversal of image";
39+
}
40+
41+
@Override
42+
public List<String> getArguments()
43+
{
44+
return List.of("image");
45+
}
46+
47+
/** Fetch boolean info from image
48+
*
49+
* Subclass can override
50+
*
51+
* @param image Image
52+
* @return info
53+
*/
54+
protected boolean getImageInfo(final VImage image)
55+
{
56+
return image.isXReversed();
57+
}
58+
59+
@Override
60+
public VType compute(final VType... args) throws Exception
61+
{
62+
if (args.length != 1 || ! (args[0] instanceof VImage))
63+
throw new Exception("Function " + getName() +
64+
" takes VImage but received " + Arrays.toString(args));
65+
66+
final VImage image = (VImage) args[0];
67+
return VBoolean.of(getImageInfo(image), image.getAlarm(), image.getTime());
68+
}
69+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2022 Oak Ridge National Laboratory.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
******************************************************************************/
8+
package org.csstudio.apputil.formula.areadetector;
9+
10+
import org.epics.vtype.VImage;
11+
12+
/** A formula function for fetching offset of VImage
13+
* @author Kay Kasemir
14+
*/
15+
public class ImageYOffsetFunction extends ImageWidthFunction
16+
{
17+
@Override
18+
public String getName()
19+
{
20+
return "imageYOffset";
21+
}
22+
23+
@Override
24+
public String getDescription()
25+
{
26+
return "Fetch vertical offset of image";
27+
}
28+
29+
@Override
30+
protected int getImageInfo(final VImage image)
31+
{
32+
return image.getYOffset();
33+
}
34+
}

0 commit comments

Comments
 (0)