139 views
in GUI Development by

Hello,

I'm Modifyng the Climate Cabinet example.

I'm printing instead of the humidity value, a temperature value from an external input.

I wanted to add a StrokePath to the graph, so every step of the Running Bar, a point is drawn on the intersection of the Running Bar and the temperature bar.

In the method UpdateLayout of the Diagram in the climate cabinet example, i matched the Bounds of the stroke path with the graph ones.

I'm assuming the coordinates of the  path are related to the pixels in the stroke path rectangle, so after that i made the stoke path begin in the bottom left corner, and the number of sub path items match with the graph width.

Graph.Bounds = rect( 2 * Climate::Spacing.x, y1, aSize.x - Climate::Spacing.x, y2 - Climate::Spacing.y );
StrokePath.Bounds = Graph.Bounds;

TempPath.InitSubPath( 0, Graph.Bounds.w);

TempPath.Begin(0, 0.0 ,StrokePath.Bounds.h);

When adding a new point to the line, i want to add it with  the x coordinates to match the running bar coordinate and y to match the temperature bar y positition.

/* adjust running bar */
RunningBar.Visible = (Application::Device.StartCycle);

RunningBar.Bounds.origin = point( Graph.Bounds.x1 + ((totalTimems - Application::Device.RemainingTime)) * Graph.Bounds.w / (rangeTime*1000), Graph.Bounds.y1 );
//add tempPath Point
//humPos refers to the temperature bar y position, correct in the graph.
TempPath.AddLine(0,RunningBar.Bounds.origin.x, humPos);

The scaling and value rappresentation of the graph are consistent with the data recevied.

I'm getting this behavior:

The Stroke path Runs Ahead of the running bar by i presume a offset constant amount, represented by that initial ramp that i can't explain.

I'm printing the values on screen also:

Text1.String = "Running Bar X: " +string(RunningBar.Bounds.origin.x);
Text2.String = "StrokePath X: " + string(TempPath.GetPathBounds().point2.x);

Text3.String = "Temp Bar Y: " +string(HumidityBar.Bounds.origin.y);
Text4.String = "Stroke Path Y: " +string(TempPath.GetPathBounds().point2.y);

The x Position are the same, but not on the displayed stroke path.

The y position of the strokepath last point is not changing.

 

1 Answer

0 votes
by
 
Best answer

Hello Riccardo,

The Stroke path Runs Ahead of the running bar by i presume a offset constant amount, represented by that initial ramp that i can't explain.

I'm not sure whether I really understood the problem. What do you mean with the initial ramp? Does it correspond to the height of the Stroke Path view?

If yes, this could explain the offset. Please see the section Determine the origin position for the path coordinates. Accordingly to your description, you have configured the Stroke Path view to have the origin of the coordinate system at its bottom-left corner. Hereby, the positive Y-axis of the path coordinate system points downwards, which corresponds to how other positions or coordinates are treated in Embedded Wizard.

To appear above the bottom edge of the Stroke Path view, the value humPos should be negative. Or you configure the Stroke Path view to flip the coordinate system vertically (see the property FlipY from the above mentioned documentation).

Best regards

Paul Banach

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...