Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

Why mouse click invoke draw?

For general discussion related FlowStone

Why mouse click invoke draw?

Postby Nowhk » Wed Nov 18, 2015 2:48 pm

The schema is pretty simple:

Immagine.png
Immagine.png (13.56 KiB) Viewed 13285 times

every time I click with mouse on the work space, the counter increment itself: this means that draw function is called.
It is strange when working on the tools, since if I'm making graphic it messes with index/time line of processing.

That's normal? Can I avoid this? Thanks!

Test.fsm
(365 Bytes) Downloaded 761 times
Nowhk
 
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

Re: Why mouse click invoke draw?

Postby Nowhk » Wed Nov 18, 2015 8:43 pm

This is another huge anomaly I reckon:

Bug3.fsm
(1.56 KiB) Downloaded 758 times

open the schema, and click the "Start" Button. Within the first Ruby script, it generates random value every 1/2 second, that I send to another Ruby "draw" script.

Even if the "input" value is at 0.5 sec, draw method is called many times, faster, and I see the first counter run very fast. Redraw should trigger "draw" on every input value.

The strange things is that on a Computer it works correctly (I see both counter go at same speed).
Here, at home (another PC) the first one is faster. Both with Windows 10 Professional.

Is that a bug or am I missing somethings fundamental?
Nowhk
 
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

Re: Why mouse click invoke draw?

Postby tulamide » Wed Nov 18, 2015 8:57 pm

Here on the forums was a talk about it, if I remember correctly. You have to avoid sending to the output from within the draw method. Any output call lets Flowstone redraw the functional elements around the view (the circular inputs/outputs). For some reason, probably to take care the view itself stays intact, a draw call is also sent to Ruby.

Conclusion: Call the output method only from methods that are not connected to the draw method.
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Why mouse click invoke draw?

Postby Nowhk » Wed Nov 18, 2015 9:07 pm

tulamide wrote:Conclusion: Call the output method only from methods that are not connected to the draw method.

But I can't: its on the draw method that I can "draw" element. So, it is drawing lines at a different time/speed than the inputs.

Can I draw inside custom methods? This can't work since "v" doesn't exist:

Code: Select all
def theMyDraw
   @path = GraphicsPath.new
   @pen = Pen.new (Color.new 200,0,200,0), 0.3
   @path.addLine [1, 2],[10, 12]
   v.drawPath @pen, @path   
end

:shock:
Nowhk
 
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

Re: Why mouse click invoke draw?

Postby MyCo » Wed Nov 18, 2015 9:56 pm

The standard method is to calculate any variable you need for drawing in event/mouseXYZ or a method called from there, and in draw you just draw to the view.

The multiple times redraw you see should only happen in the schematic (not on the frontpanel). Basically, FS forces a redraw for the green float box you've connected to the output, this redraw is sent to Ruby as well (maybe it shouldn't but there might be a reason for it)
User avatar
MyCo
 
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany

Re: Why mouse click invoke draw?

Postby Nowhk » Wed Nov 18, 2015 10:48 pm

Not sure if this is what happens in my case! This function for example:

Code: Select all
def draw v
   if(@end == true)
      return
   end

   if(@index == 10)
      @path = GraphicsPath.new   
      @old_x = 0
      @index = 0
   end

   @path.addLine [@old_x, @new_y],[@old_x + @lenght, @new_y]
   @old_x = @old_x + @lenght
   
   v.drawPath @pen, @path

   @index = @index + 1
end

I haven't any "output" from the draw method here, but its called more times than the times I call "redraw 0" from another method.

Here the example:

Bug4.fsm
(1.67 KiB) Downloaded 789 times

as you can see, the step that it "draw" is longer than 5 points in the grid, that's because it is called more times.
Each step (i.e. every time I reckon a "value" inside the Ruby that draw) should be 5 points lenght (@lenght = 5); instead its longer, because draw is retriggered from others elements that I don't know (as I said, there is no output within draw here).
Nowhk
 
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

Re: Why mouse click invoke draw?

Postby tulamide » Wed Nov 18, 2015 11:20 pm

There is no bug:

MyCo wrote:The standard method is to calculate any variable you need for drawing in event/mouseXYZ or a method called from there, and in draw you just draw to the view.


You should stick to this! The draw method is called whenever a redraw is needed - not just when you call it. Calculations don't belong into the draw method.
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Why mouse click invoke draw?

Postby MyCo » Wed Nov 18, 2015 11:25 pm

As long as you don't do anything it's 5 steps. Of course when you interact with FS, FS has to redraw more often.
Attachments
screen.jpg
screen.jpg (22.3 KiB) Viewed 13262 times
User avatar
MyCo
 
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany

Re: Why mouse click invoke draw?

Postby Nowhk » Wed Nov 18, 2015 11:28 pm

MyCo wrote:As long as you don't do anything it's 5 steps. Of course when you interact with FS, FS has to redraw more often.

This is what happens on my other PC. On this, it redraw more ad I said. I do nothing in FS, I just click start :shock:

But on this computer it draw more.
Nowhk
 
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

Re: Why mouse click invoke draw?

Postby Nowhk » Wed Nov 18, 2015 11:36 pm

You can see it in this video:

http://www.fastswf.com/U8s2F4k
every time it got a value, draw has been processed two times (draw step is 10 points long, instead of see progression of 5 points drawf).

The significant draw as you can see happen (on the new 10 points lenght draft) after 5 point, betweem 5° and 10°.
So it seems that draw is called a little bit before the value is coming, drawing again a line with old values plus the new ones.

But the strange thing is that this happens "only" on pc A. If I try it on pc B, it works without any problem.
Nowhk
 
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

Next

Return to General

Who is online

Users browsing this forum: No registered users and 69 guests