Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Radial Progress Bar #113

Closed
JacoFourie opened this issue Jul 16, 2021 · 30 comments
Closed

Issue with Radial Progress Bar #113

JacoFourie opened this issue Jul 16, 2021 · 30 comments

Comments

@JacoFourie
Copy link

Hi. I am running the new version of Lazarus.

Lazarus 2.3.0 r65462 FPC 3.2.2 arm-linux-gtk2

The progress bar is not in the center anymore.

image

@JacoFourie
Copy link
Author

Hi. Anyone else with this issue?

@lainz
Copy link
Member

lainz commented Jul 27, 2021

Hi, I currently use only releases of FPC and Lazarus.

@JacoFourie
Copy link
Author

JacoFourie commented Aug 5, 2021

Hi, I currently use only releases of FPC and Lazarus.

Hi. Sorry what does that mean? So are you saying this version of Lazarus is not supported? Up to what version is supported?
I am not sure how all the Lazarus version work? I used a installer to install Lazarus. https://wiki.freepascal.org/fpcupdeluxe

Is the version that the installer installs not supported?

@circular17
Copy link
Contributor

Hello,

I cannot reproduce the bug, though I tried on Linux amd64 with Lazarus 2.2.0RC1 and did not get any problem.

The bug may be related to the trunk branch.

fpcupdeluxe can install latest trunk version though it is experimental. I suggest you try with the regular installer on SourceForge:
https://www.lazarus-ide.org/index.php?page=downloads

@JacoFourie
Copy link
Author

JacoFourie commented Aug 8, 2021

OK I have now installed version Lazarus 2.2.0RC2 ra829c6f1f0 FPC 3.2.2 arm-linux-gtk2

And I have the same issue. I had a look at the code and it seems the issue is with the y axis of the arc function. It no longer has any effect. If I change the values it does nothing.

image

@lainz
Copy link
Member

lainz commented Aug 8, 2021 via email

@JacoFourie
Copy link
Author

It looks like the Height value is null. If I hard code it to 100 it shows at the correct place.

@lainz
Copy link
Member

lainz commented Aug 8, 2021 via email

@JacoFourie
Copy link
Author

OK so Height does have a value in it. I am still looking where this is coming from. I will install this version on Windows and look if I get the same issue.

@JacoFourie
Copy link
Author

Version Lazarus 2.1.0 r61697M FPC 3.3.1 arm-linux-gtk2 works fine BTW.

image

@JacoFourie
Copy link
Author

I see other controls also has issues on the newer versions. Here is the analog Clock.

image

It should look like this.

image

@JacoFourie
Copy link
Author

OK so RC1 on Windows works fine also. So is this then a arm Linux issue?

image

@JacoFourie
Copy link
Author

If this is a arm linux issue where do I report it?

@JacoFourie
Copy link
Author

OK so it definitely has something to do with the value y = Height / 2. If I hard code the y value in my app with 80 then all works fine on version 2.3.0 and version 2.2.0 RC 2

@JacoFourie
Copy link
Author

OK so if I use a variable of type single and round it so the divide is not an issue then it works.

If you do the calculation (Height / 2) in the pass to the arc function then it does not work

temp_height : single;
begin

temp_height := round(Height / 2);

FreeAndNil(FBitmap);
FBitmap := TBGRABitmap.Create(Width , Height);

FBitmap.Canvas2D.beginPath;
//FBitmap.Canvas2D.arc(Width / 2, (Height / 2) , Height / 2.5, 0, pi * 2, False);
FBitmap.Canvas2D.arc((Width / 2), temp_height , Height / 2.5, 0, pi * 2, False);
FBitmap.Canvas2D.fillStyle(Color);
FBitmap.Canvas2D.fill;

@JacoFourie
Copy link
Author

So is this a dataype issue? Is there not some setting that I need to set in the IDE for compiling?

@lainz
Copy link
Member

lainz commented Aug 8, 2021 via email

@JacoFourie
Copy link
Author

When you say a bug in FPC is there a bug in the version of FPC I am using? Where should I ask about it?

@lainz
Copy link
Member

lainz commented Aug 8, 2021 via email

@JacoFourie
Copy link
Author

OK I am trying diffrent versions of FPC with Lazarus. Version 3.2.0 does the same

image

@JacoFourie
Copy link
Author

FPC 3.2.3 also has the issue on Arm. But on Windows it is fine. So is there an issue with FPC on Arm Linux according to you?

image

@lainz
Copy link
Member

lainz commented Aug 8, 2021 via email

@circular17
Copy link
Contributor

Where to declare the bug: https://gitlab.com/freepascal.org/fpc/source/-/issues
The closest I could find, but might be different: https://gitlab.com/freepascal.org/fpc/source/-/issues/28140

It might help if you can reproduce the bug with a simple program, without any library, just with one a function with the same signature. Note that if it works in FPC 3.3.1 and not in FPC 3.2.2, it might already have been fixed in trunk.

@JacoFourie
Copy link
Author

JacoFourie commented Aug 8, 2021

Thanks. I am trying to install FPC 3.3.1 but the installer now has an error and bombs out. They moved all the stuff over from svn to GitLab and now TRUNK does not seem to work with Fpcupdeluxe.

I tried to make a small program but it works in the small program. Will update as I progress. I don't need to have this working yet. I am just making sure stuff still works in the new version so when I do move over it still works and I do not have an issue then.

@JacoFourie
Copy link
Author

Mmmmm I am not sure what to say, I got FPC 3.3.1 working but now it even does worse.

image

@JacoFourie
Copy link
Author

JacoFourie commented Aug 9, 2021

So using the latest Lazarus IDE and the Latest FPC I have to replace all the calculations in the arc call. Then the control works at run time.

`procedure TBCRadialProgressBar.RenderControl;
var
textBmp: TBGRABitmap;
textStr: string;
EffectiveLineWidth:single;
temp_height : single;
temp_width : single;
temp_height2 : single;
temp_pi : single;
temp_arc : single;

begin

temp_height := Height;

FreeAndNil(FBitmap);
FBitmap := TBGRABitmap.Create(Width, Height);

temp_width := Width / 2;
temp_height := Height / 2;
temp_height2 := Height / 2.5;
temp_pi := pi * 2;

FBitmap.Canvas2D.beginPath;
FBitmap.Canvas2D.arc(temp_width, temp_height, temp_height2, 0, temp_pi, False);
FBitmap.Canvas2D.fillStyle(Color);
FBitmap.Canvas2D.fill;

if LineWidth=0 then
EffectiveLineWidth:=Height / 50
else
EffectiveLineWidth:=LineWidth;

FBitmap.Canvas2D.lineWidth := EffectiveLineWidth;
FBitmap.Canvas2D.strokeStyle(LineBkgColor);
FBitmap.Canvas2D.stroke;

FBitmap.Canvas2D.beginPath;
temp_pi := pi * 1.5;
temp_arc := (pi * 1.5) + ((pi * 2) * Value / MaxValue);
if Value <> MinValue then
FBitmap.Canvas2D.arc(temp_width, temp_height, temp_height2, temp_pi, temp_arc , False);
FBitmap.Canvas2D.fillStyle(BGRAPixelTransparent);
FBitmap.Canvas2D.fill;

FBitmap.Canvas2D.lineWidth := EffectiveLineWidth;
FBitmap.Canvas2D.strokeStyle(LineColor);
FBitmap.Canvas2D.stroke;

if MaxValue = 0 then
textStr := '0%'
else
textStr := FloatToStr((Value / MaxValue) * 100) + '%';

textBmp := TextShadow(Width, Height, textStr, Font.Height,
Font.Color, FontShadowColor, FontShadowOFfsetX,
FontShadowOffsetY, FontSHadowRadius, Font.Style, Font.Name) as TBGRABitmap;
FBitmap.PutImage(0, 0, textBmp, dmDrawWithTransparency);
textBmp.Free;
end;`

image

But at design time in the GUI builder it is still wrong. Is the same code not called in the design time interface to create the control?

image

@JacoFourie
Copy link
Author

JacoFourie commented Aug 9, 2021

This is so scary. How can FPC do this?

I print the value of Height and Width before I call arc. And then again inside arc.

Before the call

writeln('Width : ' + floattostr(Width));
writeln('Height : ' + floattostr(Height));

writeln('Half Width : ' + floattostr(Width / 2));
writeln('Half Height : ' + floattostr(Height / 2));

// FBitmap.Canvas2D.arc(temp_width, temp_height, temp_height2, 0, temp_pi, False);
FBitmap.Canvas2D.arc(Width / 2, Height / 2, Height / 2.5, 0, pi * 2, False);

and then inside the arc procedure at th start of the proc.

procedure TBGRACanvas2D.arc(x, y, radius, startAngleRadCW, endAngleRadCW: single;
anticlockwise: boolean);
var pts: array of TPointF;
temp: single;
pt: TPointF;
rx,ry: single;
len1,len2: single;
unitAffine: TAffineMatrix;
v1orig,v2orig,v1ortho,v2ortho: TPointF;
startRadCCW,endRadCCW: single;
begin
writeln('X in arc : ' + floattostr(x));
writeln('Y in arc : ' + floattostr(y));
v1orig := PointF(currentState.matrix[1,1],currentState.matrix[2,1]);
v2orig := PointF(currentState.matrix[1,2],currentState.matrix[2,2]);

And here is the output. This is very scary that FPC does this. Y should be 100, yet it is 3.390625

Width : 200
Height : 200
Half Width : 100
Half Height : 100
X in arc : 100
Y in arc : 3.390625

@circular17
Copy link
Contributor

Hello Jaco

To see the changes in the designer you need to recompile Lazarus. As you did when you installed BGRAControls in the first place.

About trunk I understand it is frightening. I cannot help with that, but it is common to have bugs in trunk

@JacoFourie
Copy link
Author

OK cool thanks that did the trick. I have these issues on non TRUNK versions also on ARM so it is not just on TRUNK.
But at least I now know what is the reason for it and how to get around it.

image

@circular17
Copy link
Contributor

Cool glad you have a solution

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

No branches or pull requests

3 participants