Skip to content

Improvements to the Linear Meter widget#3514

Merged
abrahamwolk merged 36 commits into
masterfrom
CSSTUDIO-3360
Aug 20, 2025
Merged

Improvements to the Linear Meter widget#3514
abrahamwolk merged 36 commits into
masterfrom
CSSTUDIO-3360

Conversation

@abrahamwolk

@abrahamwolk abrahamwolk commented Aug 19, 2025

Copy link
Copy Markdown
Collaborator

This pull request implements several improvements to the Linear Meter widget:

  1. Perhaps most noticeably, it implements a new mode: the indicator can now be drawn as a bar in addition to the existing functionality to be drawn as a needle. The following screenshot shows the bar-mode and the needle-mode side by side:screenshot
  2. With the goal of improving performance and responsiveness on multicore processors, the concurrency of the Linear Meter has been made more fine-grained. Previously, concurrency issues were avoided by both reading and modifying state only on the JavaFX Application thread using Platform.runLater(). This pull request replaces that strategy by instead relying on a ReentrantReadWriteLock, allowing for simultaneous read-accesses while write-operations are sequential.
  3. The widget property "Limits from PV" has been generalized: In addition to allowing for the options "Limits from PV" and "No limits from PV", the property now also allows for the options "Min & max from PV" and "Alarm limits from PV", allowing the user more fine-grained control over this option. This functionality has been implemented in a manner such that OPIs saved using the previous version of the Linear Meter will still be loaded correctly. However, an OPI created using the new version of the Linear Meter implemented in this pull request should not be loaded using an older version of Phoebus.
  4. It is now possible to reduce the width of the widget to 10 pixels at minimum instead of 25 pixels.

…roving the performance on multi-core processors.
…so when the value is larger than the max value of the linear meter.
… when the value is larger than the max value of the linear meter.
…m PV" to the widget property "Limits from PV".
…k instead to use '<T> T withReadLock()' instead of 'void withReadLock()'
@abrahamwolk abrahamwolk requested a review from kasemir August 19, 2025 11:35

@kasemir kasemir left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we should increase the version number, since the behavior of "limits from PV" changes and there's the new bar mode

 1.0.0: ...based on 3rd party library
 2.0.0: Simple linear meter,....
 3.0.0: Meter and bar mode; more ‘LimitsFromPV’ options

@kasemir

kasemir commented Aug 19, 2025

Copy link
Copy Markdown
Collaborator

It is now possible to reduce the width of the widget to 10 pixels at minimum instead of 25 pixels.

Without the scale, is it possible to narrow it further, down to 3 or 1 pixel?

@abrahamwolk

abrahamwolk commented Aug 19, 2025

Copy link
Copy Markdown
Collaborator Author

I think we should increase the version number, since the behavior of "limits from PV" changes and there's the new bar mode

I did increase the version number in the following comment: 729bfa8.

Without the scale, is it possible to narrow it further, down to 3 or 1 pixel?

The limit is currently set to 10: 67de29a. It could probably be lowered further, but I am not sure the logic works for 1 pixel or even 3 pixels. Would a lower limit than 10 be useful for you?

}
// Draw the bar:
gc.fillRect(marginLeft, currentIndicatorPosition, meterBreadth, linearMeterScale.getBounds().height-currentIndicatorPosition-marginBelow);
gc.fillRect(marginLeft, currentIndicatorPosition, meterBreadth - 1, linearMeterScale.getBounds().height-currentIndicatorPosition-marginBelow);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Found in several commits:

Math symbols (minus) could be surrounded by space for better readability.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed: fb5ad09

@kasemir

kasemir commented Aug 19, 2025

Copy link
Copy Markdown
Collaborator

I meant to refer to the LinearMeterWidget.METER_VERSION:

/**
 * 1.0.0: Linear meter by Claudio Rosatti based on 3rd party library
 * 2.0.0: Simple linear meter, based on meter v 3.0.0, drawn in background
 */
public static Version METER_VERSION = new Version(2, 0, 0);

A new version 3.0.0 would allow the LinearMeterConfigurator or other tools that create displays to know if the bar mode and the additional limits-from-pv behavior is available.

As for minimum width, we do have some large and cryptic overview displays full of this:

Screenshot 2025-08-19 at 8 52 06 AM

They are of course only meaningful to those in the know, but they use down to 1-pixel wide bars to indicate information.

@abrahamwolk

abrahamwolk commented Aug 19, 2025

Copy link
Copy Markdown
Collaborator Author

Seting the width or height to 1 pixel doesn't work (no bar is visible), but setting it to 2 pixels results in a 1-pixel wide bar, given that the color "Foreground Color" is set to transparent. I have therefore updated the minimum width & height to be 2 pixels.

@abrahamwolk abrahamwolk merged commit 84d0e93 into master Aug 20, 2025
3 checks passed
@abrahamwolk abrahamwolk deleted the CSSTUDIO-3360 branch August 20, 2025 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants