Class: Layout::PaperView
- Inherits:
-
Object
- Object
- Layout::PaperView
Overview
The paper view callback receives the view: it handles the conversion between paper pixels and paper coordinates (in inches), picks objects, and draws a preview in draw(view). The drawing coordinates are in paper inches (e.g., 20.mm), with line widths, point sizes, and font sizes in pixels. The drawing methods only take effect within draw(view); otherwise, calling them has no effect.
Instance Method Summary # collapse
-
#paper_point(x, y, snap = false) ⇒ Geom::Point2d
The pixel coordinates on the paper plane in inches, with the origin at the top-left corner of the paper, and y directed downward. When snap is true, it snaps to the endpoints, midpoints, intersections, centers, edge points of paper objects, and visible model lines within visible viewports (model lines in viewports must be generated in the background before snapping).
-
#paper_to_screen(point) ⇒ Geom::Point2d
The pixel coordinates corresponding to the paper area on the paper view.
-
#pick_entity(x, y) ⇒ Layout::Entity, nil
The editable PaperView object at the top layer in pixel coordinates (following the selection tool's point selection rules); objects on locked or hidden layers are not considered.
-
#zoom ⇒ Float
Current Paper View Zoom: pixels per inch on the paper.
-
#pixels_to_paper(pixels) ⇒ Length
The pixel length corresponding to the paper length.
-
#invalidate ⇒ Layout::PaperView
Request redrawing the tool preview (call draw(view) later).
-
#document ⇒ Layout::Document
The document containing the tools.
-
#drawing_color= ⇒ ModraUp::Color, String, Array
The color used for drawing after this.
-
#line_width= ⇒ Numeric
The line width (pixels, unchanged with scaling) used for drawing.
-
#line_stipple= ⇒ String
Sets the line pattern for subsequent drawing. Accepts the same values as ModraUp::View#line_stipple=, including "" for solid lines, ".", "-", "_", and "-.-".
-
#draw(mode, points) ⇒ Layout::PaperView
Draw using OpenGL methods: GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP, GL_TRIANGLES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_QUADS, GL_QUAD_STRIP, GL_POLYGON. Points are in paper inches as Geom::Point2d or [x, y].
-
#draw_line(point1, point2, ...) ⇒ Layout::PaperView
Draw a line segment between every two points (GL_LINES).
-
#draw_polyline(point1, point2, ...) ⇒ Layout::PaperView
Connect the points in sequence with a polyline (GL_LINE_STRIP).
-
#draw_points(points, size = 6, style = 3, color = "black") ⇒ Layout::PaperView
Draw point markers, size in pixels, and style as in ModraUp::View#draw_points (1 hollow square, 2 solid square, 3 plus, 4 times, 5 star, 6 hollow triangle, 7 solid triangle).
-
#draw_text(point, text, options = {}) ⇒ Layout::PaperView
Write screen text at a paper view point. options: size (pixels, default 12), bold, align (TextAlignLeft / TextAlignCenter / TextAlignRight), color.
Instance Method Details
view.paper_point(x, y, snap = false) ⇒ Geom::Point2d
The pixel coordinates on the paper plane in inches, with the origin at the top-left corner of the paper, and y directed downward. When snap is true, it snaps to the endpoints, midpoints, intersections, centers, edge points of paper objects, and visible model lines within visible viewports (model lines in viewports must be generated in the background before snapping).
view.paper_to_screen(point) ⇒ Geom::Point2d
The pixel coordinates corresponding to the paper area on the paper view.
view.pick_entity(x, y) ⇒ Layout::Entity or nil
The editable PaperView object at the top layer in pixel coordinates (following the selection tool's point selection rules); objects on locked or hidden layers are not considered.
view.zoom ⇒ Float
Current Paper View Zoom: pixels per inch on the paper.
view.pixels_to_paper(pixels) ⇒ Length
The pixel length corresponding to the paper length.
view.invalidate ⇒ Layout::PaperView
Request redrawing the tool preview (call draw(view) later).
view.document ⇒ Layout::Document
The document containing the tools.
view.drawing_color = color
The color used for drawing after this.
view.line_width = pixels
The line width (pixels, unchanged with scaling) used for drawing.
view.line_stipple = pattern
Sets the line pattern for subsequent drawing. Accepts the same values as ModraUp::View#line_stipple=, including "" for solid lines, ".", "-", "_", and "-.-".
view.draw(mode, points) ⇒ Layout::PaperViewview.draw(mode, point1, point2, ...) ⇒ Layout::PaperView
Draw using OpenGL methods: GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP, GL_TRIANGLES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_QUADS, GL_QUAD_STRIP, GL_POLYGON. Points are in paper inches as Geom::Point2d or [x, y].
view.draw_line(point1, point2, ...) ⇒ Layout::PaperView
Draw a line segment between every two points (GL_LINES).
view.draw_polyline(point1, point2, ...) ⇒ Layout::PaperView
Connect the points in sequence with a polyline (GL_LINE_STRIP).
view.draw_points(points, size = 6, style = 3, color = "black") ⇒ Layout::PaperView
Draw point markers, size in pixels, and style as in ModraUp::View#draw_points (1 hollow square, 2 solid square, 3 plus, 4 times, 5 star, 6 hollow triangle, 7 solid triangle).
view.draw_text(point, text, options = {}) ⇒ Layout::PaperView
Write screen text at a paper view point. options: size (pixels, default 12), bold, align (TextAlignLeft / TextAlignCenter / TextAlignRight), color.