GNU TeXmacsUser manualReferenceAboutEnglish
The graphics editor

1.Introduction

TeXmacs pictures are ordinary document trees. A picture is a graphics tag whose children are graphical objects such as point, line, spline, arc or text-at, usually wrapped in with tags which set their color, line width and other attributes. The graphics editor is the part of TeXmacs which lets the user draw and modify such trees with the mouse.

The implementation is split over three layers, which communicate through a small number of glued functions:

  1. Typesetting. The typesetter turns the graphical markup into boxes (graphics_box, curve_box, point_box, grid_box, text_at_box, …). These boxes know their coordinate frame and grid, and they implement graphical_select, which finds the control points, curve points and text borders near a given position. This is the only place where the geometry of the objects is computed.

  2. C++ editor hooks. The class edit_graphics_rep (

    Edit/Interface/edit_graphics.cpp

    ) is a component of the editor. It decides whether the cursor and the mouse are inside a picture, converts mouse positions from screen coordinates to graphical coordinates, snaps them to points, curves and grids, forwards the mouse events to Scheme, and draws the temporary graphical object: an overlay which shows control points, selections and the object being created.

  3. The Scheme state machine. All actual editing decisions are taken in Scheme, in the modules under

    src/TeXmacs/progs/graphics/

    . These implement the editing modes (point mode, group mode, hand drawing), a state machine which remembers what the user is doing (creating a curve, dragging a point, moving a group of objects), the sketch which holds the objects being edited, the menus, toolbars and keyboard shortcuts, and the management of the default properties of new objects.

The user level description of the graphics editor is in the manual chapter creating technical pictures. The graphical markup is documented in graphics primitives and the graphical environment variables in graphics environment variables. The pages under Scheme interface for the graphical mode describe a design of the Scheme interface from 2005; they are only of historical interest, since most of the routines described there do not exist anymore. The present chapter describes the implementation as it is in the source code.

All C++ file names below are relative to

src/src/

, and all Scheme file names are relative to

src/TeXmacs/progs/

.

2.Source map

Graphics/Types/

Geometric types: point (an array<double>, in

point.hpp

), coordinate transformations frame (

frame.hpp

), curves curve (

curve.hpp

,

curve.cpp

,

curve_extras.cpp

for the hand drawing algorithms), and grids grid (

grid.hpp

).

Graphics/Spacial/

Experimental three dimensional objects (spacial): triangulated surfaces, their transformations and their lighting.

Typeset/Concat/concat_graphics.cpp

Typesetting of all graphical primitives (concater_rep::typeset_graphics, typeset_line, typeset_text_at, …), and the support for graphical constraints (set_graphical_value and friends).

Typeset/Boxes/Graphics/

The graphics specific boxes:

graphics_boxes.cpp

(graphics_box, graphics_group_box, point_box, curve_box, spacial_box) and

grid_boxes.cpp

(grid_box). The text_at_box lives in

Typeset/Boxes/Modifier/change_boxes.cpp

. The constructors are declared in

Typeset/Boxes/graphics.hpp

.

Typeset/boxes.hpp
,
Typeset/Boxes/Basic/boxes.cpp

The graphical selection type gr_selection, and the default implementations of box_rep::find_frame, find_grid, find_limits and graphical_select.

Typeset/Env/env_semantics.cpp

Computation of the current frame edit_env_rep::fr and clipping limits from the variables gr-frame and gr-geometry (update_frame, update_geometry) and of the cached graphical attributes (point style, arrows, text alignment, …).

Edit/Interface/edit_graphics.hpp
,
edit_graphics.cpp

The editor component edit_graphics_rep.

Edit/Interface/edit_mouse.cpp
,
edit_repaint.cpp
,
edit_interface.cpp

The places where the generic editor calls the graphics component: mouse dispatch, drawing of the overlay and of the graphical cursor, and the transfer of the snapping parameters.

graphics/graphics-drd.scm

Groups of graphical tags, the table of graphical attributes and their defaults.

graphics/graphics-utils.scm

Access to the innermost graphics, its properties and the objects inside it; insertion of new objects; make-graphics.

graphics/graphics-env.scm

The state graphics-state of the editor, the state stack, the filtering of graphical selections and graphics-reset-context.

graphics/graphics-object.scm

Construction of the graphical object (the overlay) and management of the sketch.

graphics/graphics-edit.scm

Entry points for the mouse events coming from C++, and z-ordering.

graphics/graphics-single.scm

Point mode: creation and modification of single objects, and hand drawing.

graphics/graphics-group.scm

Group mode: selection, moving, resizing, rotating, grouping, properties and the clipboard.

graphics/graphics-main.scm

Global properties of a picture: extents, frame, zoom, grids, editing mode, default properties of new objects and snapping options.

graphics/graphics-markup.scm

User defined graphical macros (define-graphics).

graphics/graphics-animate.scm

Editing of animated pictures.

graphics/graphics-kbd.scm
,
graphics/graphics-menu.scm

Keyboard shortcuts, menus and toolbars.

3.Contents of this chapter

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".