Odd behavior of Draw
-
What causes the draw output to stop when the cursor in on a guideline or component?
-
a wild guess is it's trying to draw the inference points, and blocking both...
is inference active in your tool?
I've had issues with the clipping plane before today, but never noticed that one...
john
-
Inferencing is always active isn't it at least I have never found an effective way to turn it off. I use multiple view.lock_inference statement, which is suppose unlock any inferences, to no avail. But inferencing doesn't explain why it is ok to be on a face and/or edge.
-
I tried one on a guideline...
this is one of steves unreleased plugins, but I can PM it, if you want to investigate...
john
-
Just speculating here...
Could it be an order issue between the drawing of the tooltip and your drawing operations? I draw the tooltip first (via view.tooltip=InputPoint.tooltip and InputPoint.draw view) and then do my view.draw operations.
Steve
-
@slbaumgartner said:
Just speculating here...
Could it be an order issue between the drawing of the tooltip and your drawing operations? I draw the tooltip first (via view.tooltip=InputPoint.tooltip and InputPoint.draw view) and then do my view.draw operations.
Steve
This is my standard onMouseMove
def onMouseMove(flags, x, y, view) @ip.pick view,x,y; view.tooltip = @ip.tooltip; view.refresh Sketchup;;set_status_text @status_text view.lock_inference end
and draw
def draw(view) if( @ip.valid? && @ip.display? ) @ip.draw(view) end . . end
-
Here's what I did:
def onMouseMove(flags, x, y, view) @ip.pick(view, x, y, @ip1) view.invalidate view.refresh end def draw(view) view.tooltip = @ip.tooltip @ip.draw view # draw other stuff to the view...
There are some minor differences, but it's not obvious to me why yours doesn't seem to work.
Steve
-
It's recommended to use invalidate instead of refresh unless you have a good specific reason to use refresh. Otherwise you end up unnecessarily redrawing the viewport too often which might impact performance.
-
@TT,
what is the underlying difference between
refresh
andinvalidate
?the API has the same description for both and they are used interchangeably by many...
On one of my plugins, using both was the only way to guarantee it worked...
john
-
View.invalidate marks the view for redraw but it might not be updated immediately. It'll be throttled.
View.redraw force a redraw immediately.View.invalidate should be the first choice - View.redraw should be used when you know you really need it.
I've had to use view.redraw in cases where I make mesh updates in the mouse events (for live mesh preview). There I had to force a redraw otherwise things would appear choppy. But even then I'd try to manually throttle view.redraw.
-
TT: any idea what logic or basis SketchUp uses to decide when to conduct the next redraw after view.invalidate? That is, I take your answer to mean that SU queues up the draw and then waits for an appropriate opportunity to do it. But what is an "appropriate opportunity"? Is there something besides view.redraw that a Tool can or should do to encourage it? Waiting a random, indeterminate amount of time before the next draw is sure to cause an interactive Tool to be jittery! I'm drawing a "rubber band" tracking the mouse cursor to show dynamically what is happening. Jitters in that would make it quite unusable (maybe on a complex model with a slow redraw it is already so)!
-
@tt_su said:
View.invalidate marks the view for redraw but it might not be updated immediately. It'll be throttled.
View.redraw force a redraw immediately.View.invalidate should be the first choice - View.redraw should be used when you know you really need it.
I've had to use view.redraw in cases where I make mesh updates in the mouse events (for live mesh preview). There I had to force a redraw otherwise things would appear choppy. But even then I'd try to manually throttle view.redraw.
I don't find view.redraw in the API and it caused an "undefined method" error when I tried to use it.
-
I think tt mistyped '
redraw
' forview.refresh
-
My bad. What TIG said.
-
Well I have tried all the suggested combinations and nothing seems to solve the "problem". Perhaps it is just my 7 year old laptop!!!!!
-
Do you have a small reproducible snippet?
-
@sdmitch said:
Well I have tried all the suggested combinations and nothing seems to solve the "problem". Perhaps it is just my 7 year old laptop!!!!!
Since these draw operations go directly to OpenGL, this explanation seems quite possible! There could be a bug in either your laptop's OpenGL drivers or an incompatibility in how SketchUp uses OpenGL.
Advertisement