Hi everyone, my name is Dave, a Mechanical Engineer by profession, working in the field of Noise and Vibration, and over the years have used programming for writing dynamics programs for my own and others' use. My programming background is linear Fortran and Visual Basic, but it's all been a 'means to an end' exercise so I wouldn't call myself an expert in programming and struggle with this new-fangled object-oriented programming (I wrote my first programs on punched cards you know and handed them to a white-coated 'operator' through a hatch in a wall through which I never actually saw 'the computer' ), but the stuff I write generally involves matrices and complex numbers in programs for eigenvalue extraction for rotor critical speeds, or time step integration for transient analysis for example which all means that it's easy enough to get tied in knots. Recently, I decided that soon to retire, I would keep sharp by doing something with Android, and being pre-Java and having dread of learning it brought me to B4A.
So that brings me to my cry for help on XUI graphics, what am I doing wrong?
I am writing a program that generates a window of data, plots it in a Panel x, time and y, vibration, and carries on to plot the next. Of course, I need to erase the first before I can plot the next, and that is where I am stuck.
Here is the meat of the issue
I have declared as follows in Sub Globals;
Private xui As XUI 'Invoke XUI graphics package
Private xpnlGraph As B4XView
Private Panel1 As B4XView
Private xcvsGraph As B4XCanvas
Private rect1 As B4XRect
Then in Sub Activity_Create
Activity.LoadLayout("HomeScreen")
xpnlGraph = Panel1 'Link Panel1 as container for the Canvas
xcvsGraph.Initialize(xpnlGraph)
Another Sub is called where some calculation occurs and in which the result is plotted piecewise
xcvsGraph.DrawLine(x1(0), x1(2), x2(0), x2(2), xui.Color_RGB(255, 0, 0), 2dip) ' Draw a line
xcvsGraph.Invalidate
The above draws the data fine, but when I want to erase before the next plot I can't seem to make DrawRect below work, even if I put it in the same sub, between Drawline and Invalidate
xcvsGraph.DrawRect(rect1,xui.Color_RGB(0, 0, 255),True,2dip)
so the successive plots just add to what's already there and I can't seem to fix it, so probably a beginners' error.
If the above doesn't encapsulate the issue, please let me know what more is needed.
Thanks in advance
Dave
So that brings me to my cry for help on XUI graphics, what am I doing wrong?
I am writing a program that generates a window of data, plots it in a Panel x, time and y, vibration, and carries on to plot the next. Of course, I need to erase the first before I can plot the next, and that is where I am stuck.
Here is the meat of the issue
I have declared as follows in Sub Globals;
Private xui As XUI 'Invoke XUI graphics package
Private xpnlGraph As B4XView
Private Panel1 As B4XView
Private xcvsGraph As B4XCanvas
Private rect1 As B4XRect
Then in Sub Activity_Create
Activity.LoadLayout("HomeScreen")
xpnlGraph = Panel1 'Link Panel1 as container for the Canvas
xcvsGraph.Initialize(xpnlGraph)
Another Sub is called where some calculation occurs and in which the result is plotted piecewise
xcvsGraph.DrawLine(x1(0), x1(2), x2(0), x2(2), xui.Color_RGB(255, 0, 0), 2dip) ' Draw a line
xcvsGraph.Invalidate
The above draws the data fine, but when I want to erase before the next plot I can't seem to make DrawRect below work, even if I put it in the same sub, between Drawline and Invalidate
xcvsGraph.DrawRect(rect1,xui.Color_RGB(0, 0, 255),True,2dip)
so the successive plots just add to what's already there and I can't seem to fix it, so probably a beginners' error.
If the above doesn't encapsulate the issue, please let me know what more is needed.
Thanks in advance
Dave