sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Odd behavior of Draw

    Scheduled Pinned Locked Moved Developers' Forum
    17 Posts 6 Posters 657 Views 6 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D Offline
      driven
      last edited by

      I tried one on a guideline...
      seems to work other then the clipping...

      this is one of steves unreleased plugins, but I can PM it, if you want to investigate...

      john

      learn from the mistakes of others, you may not live long enough to make them all yourself...

      1 Reply Last reply Reply Quote 0
      • S Offline
        slbaumgartner
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • sdmitchS Offline
          sdmitch
          last edited by

          @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
          
          

          Nothing is worthless, it can always be used as a bad example.

          http://sdmitch.blogspot.com/

          1 Reply Last reply Reply Quote 0
          • S Offline
            slbaumgartner
            last edited by

            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

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              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.

              Thomas Thomassen — SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

              1 Reply Last reply Reply Quote 0
              • D Offline
                driven
                last edited by

                @TT,

                what is the underlying difference between refresh and invalidate?

                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

                learn from the mistakes of others, you may not live long enough to make them all yourself...

                1 Reply Last reply Reply Quote 0
                • tt_suT Offline
                  tt_su
                  last edited by

                  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.

                  1 Reply Last reply Reply Quote 0
                  • S Offline
                    slbaumgartner
                    last edited by

                    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)!

                    1 Reply Last reply Reply Quote 0
                    • sdmitchS Offline
                      sdmitch
                      last edited by

                      @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.

                      Nothing is worthless, it can always be used as a bad example.

                      http://sdmitch.blogspot.com/

                      1 Reply Last reply Reply Quote 0
                      • TIGT Online
                        TIG Moderator
                        last edited by

                        I think tt mistyped ' redraw' for view.refresh 😒

                        TIG

                        1 Reply Last reply Reply Quote 0
                        • tt_suT Offline
                          tt_su
                          last edited by

                          My bad. What TIG said.

                          1 Reply Last reply Reply Quote 0
                          • sdmitchS Offline
                            sdmitch
                            last edited by

                            Well I have tried all the suggested combinations and nothing seems to solve the "problem". Perhaps it is just my 7 year old laptop!!!!!

                            Nothing is worthless, it can always be used as a bad example.

                            http://sdmitch.blogspot.com/

                            1 Reply Last reply Reply Quote 0
                            • thomthomT Offline
                              thomthom
                              last edited by

                              Do you have a small reproducible snippet?

                              Thomas Thomassen — SketchUp Monkey & Coding addict
                              List of my plugins and link to the CookieWare fund

                              1 Reply Last reply Reply Quote 0
                              • S Offline
                                slbaumgartner
                                last edited by

                                @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.

                                1 Reply Last reply Reply Quote 0
                                • 1 / 1
                                • First post
                                  Last post
                                Buy SketchPlus
                                Buy SUbD
                                Buy WrapR
                                Buy eBook
                                Buy Modelur
                                Buy Vertex Tools
                                Buy SketchCuisine
                                Buy FormFonts

                                Advertisement