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

engraved color! #186

Closed
Evil-Nemesis opened this issue Nov 28, 2017 · 8 comments
Closed

engraved color! #186

Evil-Nemesis opened this issue Nov 28, 2017 · 8 comments

Comments

@Evil-Nemesis
Copy link

hello there.
I thank you again and again for this perfect project.

I want to change the color of the places that are engraved!
In other words, draw something on preview bitmap while the machine is engraving.
How can I do that?

@arkypita
Copy link
Owner

LaserGRBL use GDI+ to draw preview. GDI+ performance is not so fast to allow the redraw of a complex image in small times, so it is not so easy to perform a real-time drawing of the progress.
#158

However, if you want to try something, feel free to do your changes on file GrblPanel.cs

The function protected override void OnPaint(PaintEventArgs e) is called periodically and can be used to compose the image. Currently the OnPaint compose an image with a cached bitmap with the preview and the cursor position positioned over it

@arkypita
Copy link
Owner

It would be very nice to replace the GDI + design with something more powerful (like opengl or directx).
I looked for open .net libraries that were compatible with framework 3.5 (xp compatible) but i have not found something easy to use in lasergrbl.

If you have suggestion...

@arkypita
Copy link
Owner

Thanks for the hint! Since it is not a priority I add to dev roadmap but cannot know when and if could be developed :-)

@irkmandeer
Copy link

irkmandeer commented May 2, 2020

I know this issue is closed, but just an FIY.

I started implementing a couple of features for personal use. Adding this was simple enough but since I'm not a C# dev it's most likely not up to anyone's standards.

It only redraws what is needed, so nice and quick.

The 3.6MB file below (220k lines) updates in real-time. The original code takes about 4 seconds for a full redraw.

LaserGRBL progress example

Commands sent (pending) in yellow, commands completed in green.

LaserGRBL progress example 2

@arkypita
Copy link
Owner

arkypita commented May 2, 2020

Awesome!
If you are want to share your work with the community feel free to let me know when you think it is stable and "production ready". If you are able you can send changes with a github push, or sending source code to me at [email protected]

I will be happy to examine it and insert it into the program

@irkmandeer
Copy link

Sure thing, not problem sharing.

The code won't be up to standard, so I pushed the related changes into a fork. The commit can be found here.

In short, I added a command number to GrblCommand, then keeping track of that number for the last queued and ack'ed commands. This is used determine what color should be used when drawing the graphic.

@arkypita
Copy link
Owner

arkypita commented Jun 2, 2020

Hi @irkmandeer
I experimented with your code but I ran into several problems including

  • increased CPU usage
  • memory leak (cumulative effect of redraw that does not free memory)
  • misalignment on restarting work, in the face of interruptions or multiple passes

I tried to rewrite your code according to a different approach, instead of using the index in the list I proceeded to generate a numeric "id" code of each gcode line in order to recognize the point where it arrived etc but I still had problems therefore I temporarily gave up this job.

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

4 participants