class RuboCop::Cop::SketchupSuggestions::ToolDrawingBounds

When drawing 3D geometry to the viewport from a tool, make sure to implement `getExtents` that return a `Geom::BoundingBox` object large enough to encompass what you draw.

With out doing that the drawn content might end up being clipped.

@example

# good
class ExampleTool

  def getExtents
    bounds = Geom::BoundingBox.new
    bounds.add(@points)
    bounds
  end

  def draw(view)
    view.draw(GL_LINES, @points)
  end

end

Constants

MSG_MISSING_GET_EXTENTS

Public Instance Methods

on_tool_class(class_node, body_methods) click to toggle source
# File lib/rubocop/sketchup/cop/suggestions/tool_drawing_bounds.rb, line 34
def on_tool_class(class_node, body_methods)
  return unless find_method(body_methods, :draw)
  return if find_method(body_methods, :getExtents)

  add_offense(class_node, message: MSG_MISSING_GET_EXTENTS)
end