Back to index

Functions | Variables
edit_graphics.cpp File Reference
#include "Interface/edit_graphics.hpp"
#include "server.hpp"
#include "scheme.hpp"
#include "Graphics/curve.hpp"
#include "Boxes/graphics.hpp"
#include "Bridge/impl_typesetter.hpp"
#include "drd_std.hpp"

Go to the source code of this file.


gr_selection snap_to_guide (point p, gr_selections sels, double eps)


tree the_et

Function Documentation

gr_selection snap_to_guide ( point  p,
gr_selections  sels,
double  eps 

Definition at line 38 of file edit_graphics.cpp.

  if (N(sels) == 0) {
    gr_selection snap;
    snap->type= "free";
    snap->p= p;
    snap->dist= 0;
    return snap;

  sort (sels);
  gr_selection best;
  best->type= "none";
  for (int i=0; i<N(sels); i++)
    if (sels[i]->type == "grid-point")
      best= sels[i];
    else if (is_nil (sels[i]->c))
      return sels[i];

  for (int i=0; i<N(sels); i++)
    for (int j=i+1; j<N(sels); j++) {
      if (!is_nil (sels[i]->c) &&
         !is_nil (sels[j]->c) &&
         (sels[i]->type != "grid-curve-point" ||
          sels[j]->type != "grid-curve-point"))
         array<point> ins= intersection (sels[i]->c, sels[j]->c, p, eps);
         for (int k=0; k<N(ins); k++)
           if (best->type == "none" || norm (ins[k] - p) < best->dist) {
             gr_selection sel;
             sel->type= sels[i]->type * "&" * sels[j]->type;
             sel->p   = ins[k];
             sel->dist= norm (ins[k] - p);
             sel->cp  = append (sels[i]->cp, sels[j]->cp);
             sel->pts = append (sels[i]->pts, sels[j]->pts);
             best= sel;
  if (best->type != "none") return best;
  return sels[0];

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

Definition at line 18 of file new_document.cpp.