DrawingArea.Refresh erases the DrawingArea
Posted
#1
(In Topic #1136)
Trainee
I have a drawingarea 900 pixels wide (and 20 pixels high) and a timer that triggers every 5 seconds. Every time the timer trigger it checks the status of three radiobuttons and make a vertical line in the drawingarea with grey, red or green color depending on which radiobutton that is active. It's like a progressbar but with the possibility to see the status of the radiobuttons over time.
The problem is that when I do the drawingarea.refresh it erases the previous lines.
The code:
Code (gambas)
I admit that my knowledge and experience of graphics and the drawingarea functions is very slim. Can anyone point out what I'm doing wrong or have a link to an example?
Posted
Guru

you need to draw all 3 lines in the _Draw() event and make their color show per setting.
Posted
Trainee
This is for monitoring CNC-machines and their performance.
8 machines, 17 hours a day with an check-interval of 15 seconds then I will have to draw up to 32640 lines every 15 seconds at the end of the day. I wonder how fast gambas is on a pi?
Ok, back to the drawing board. Maybe test manipulating an image instead? If anyone have an example of manipulating pixels in an image please let me know.
Posted
Regular

Code (gambas)
- Timer1.Delay = 15000
- Timer1.Start
- Case 0
- colores.Push(Color.LightGray)
- Case 1
- colores.Push(Color.Red)
- Case 2
- colores.Push(Color.Green)
- Paint.LineWidth = 1
- Paint.Brush = Paint.Color(colores[c])
- Paint.MoveTo(lines[c], 0)
- Paint.LineTo(lines[c], 20)
- Paint.Stroke
- StatusValue1 = 0
- StatusValue1 = 1
- StatusValue1 = 2
- DrawingArea1.Refresh
Europaeus sum !
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Posted
Guru

A DrawingArea is used in a lot of gambas controls,
Paint.class is pretty darn fast
A simple drawing of three lines is nothing
Posted
Regular

Perhaps :? this page can help you a little:Zeke99 said
If anyone have an example of manipulating pixels in an image please let me know.
Modificare i colori dei pixel di un'immagine con la proprietà .Data della Classe Image ed i Memory Stream - Gambas-it.org - Wikipedia
Europaeus sum !
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Posted
Trainee
Have a pi 3B+. If it isn't fast enough I can always buy a pi 5.
Vuott, thank's for the link to the example with the pixel manipulation of a picture. My knowledge of the italian language is a bit limited (count from 1 to twelve) but I think I got the hang of it. Will test that too even if it works with the drawingarea and paint.
Again, thank's a lot for the support!
Posted
Regular

You can use a translator on-line, for example:Zeke99 said
My knowledge of the italian language is a bit limited (count from 1 to twelve) but I think I got the hang of it.
DeepL Translate: The world's most accurate translator
Europaeus sum !
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Posted
Guru

You might be able to just paint direct using Paint (possibly this is what you wanted)
Something like this…….
Code (gambas)
That way should paint direct on the Drawingarea and not refresh it
Just a thought
1 guest and 0 members have just viewed this.


