~centralelyon2010/inkscape/imagelinks2

« back to all changes in this revision

Viewing changes to src/display/canvas-axonomgrid.cpp

  • Committer: cilix42
  • Date: 2008-09-18 17:48:42 UTC
  • Revision ID: cilix42@users.sourceforge.net-20080918174842-1ad33a7d7gqhv2hq
Next roud of NR ==> Geom conversion

Show diffs side-by-side

added added

removed removed

Lines of Context:
197
197
    gridunit = sp_unit_get_by_abbreviation( prefs->getString("options.grids.axonom", "units").data() );
198
198
    if (!gridunit)
199
199
        gridunit = &sp_unit_get_by_id(SP_UNIT_PX);
200
 
    origin[NR::X] = sp_units_get_pixels( prefs->getDouble("options.grids.axonom", "origin_x", 0.0), *gridunit );
201
 
    origin[NR::Y] = sp_units_get_pixels( prefs->getDouble("options.grids.axonom", "origin_y", 0.0), *gridunit );
 
200
    origin[Geom::X] = sp_units_get_pixels( prefs->getDouble("options.grids.axonom", "origin_x", 0.0), *gridunit );
 
201
    origin[Geom::Y] = sp_units_get_pixels( prefs->getDouble("options.grids.axonom", "origin_y", 0.0), *gridunit );
202
202
    color = prefs->getInt("options.grids.axonom", "color", 0x0000ff20);
203
203
    empcolor = prefs->getInt("options.grids.axonom", "empcolor", 0x0000ff40);
204
204
    empspacing = prefs->getInt("options.grids.axonom", "empspacing", 5);
301
301
    /// @todo Replace direct XML preference node manipulation with calls to public prefs API
302
302
    gchar const *value;
303
303
    if ( (value = repr->attribute("originx")) ) {
304
 
        sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[NR::X], &gridunit);
305
 
        origin[NR::X] = sp_units_get_pixels(origin[NR::X], *(gridunit));
 
304
        sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[Geom::X], &gridunit);
 
305
        origin[Geom::X] = sp_units_get_pixels(origin[Geom::X], *(gridunit));
306
306
    }
307
307
    if ( (value = repr->attribute("originy")) ) {
308
 
        sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[NR::Y], &gridunit);
309
 
        origin[NR::Y] = sp_units_get_pixels(origin[NR::Y], *(gridunit));
 
308
        sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[Geom::Y], &gridunit);
 
309
        origin[Geom::Y] = sp_units_get_pixels(origin[Geom::Y], *(gridunit));
310
310
    }
311
311
 
312
312
    if ( (value = repr->attribute("spacingy")) ) {
445
445
    _rumg->setUnit (gridunit);
446
446
 
447
447
    gdouble val;
448
 
    val = origin[NR::X];
 
448
    val = origin[Geom::X];
449
449
    val = sp_pixels_get_units (val, *(gridunit));
450
450
    _rsu_ox->setValue (val);
451
 
    val = origin[NR::Y];
 
451
    val = origin[Geom::Y];
452
452
    val = sp_pixels_get_units (val, *(gridunit));
453
453
    _rsu_oy->setValue (val);
454
454
    val = lengthy;
484
484
    _rumg.setUnit (gridunit);
485
485
 
486
486
    gdouble val;
487
 
    val = origin[NR::X];
 
487
    val = origin[Geom::X];
488
488
    val = sp_pixels_get_units (val, *(gridunit));
489
489
    _rsu_ox.setValue (val);
490
 
    val = origin[NR::Y];
 
490
    val = origin[Geom::Y];
491
491
    val = sp_pixels_get_units (val, *(gridunit));
492
492
    _rsu_oy.setValue (val);
493
493
    val = lengthy;
510
510
 
511
511
 
512
512
void
513
 
CanvasAxonomGrid::Update (NR::Matrix const &affine, unsigned int /*flags*/)
 
513
CanvasAxonomGrid::Update (Geom::Matrix const &affine, unsigned int /*flags*/)
514
514
{
515
515
    ow = origin * affine;
516
 
    sw = NR::Point(fabs(affine[0]),fabs(affine[3]));
 
516
    sw = Geom::Point(fabs(affine[0]),fabs(affine[3]));
517
517
 
518
518
    for(int dim = 0; dim < 2; dim++) {
519
519
        gint scaling_factor = empspacing;
534
534
 
535
535
    }
536
536
 
537
 
    spacing_ylines = sw[NR::X] * lengthy  /(tan_angle[X] + tan_angle[Z]);
538
 
    lyw            = sw[NR::Y] * lengthy;
539
 
    lxw_x          = (lengthy / tan_angle[X]) * sw[NR::X];
540
 
    lxw_z          = (lengthy / tan_angle[Z]) * sw[NR::X];
 
537
    spacing_ylines = sw[Geom::X] * lengthy  /(tan_angle[X] + tan_angle[Z]);
 
538
    lyw            = sw[Geom::Y] * lengthy;
 
539
    lxw_x          = (lengthy / tan_angle[X]) * sw[Geom::X];
 
540
    lxw_z          = (lengthy / tan_angle[Z]) * sw[Geom::X];
541
541
 
542
542
    if (empspacing == 0) {
543
543
        scaled = TRUE;
563
563
    // bc = buffer patch coordinates
564
564
 
565
565
    // tl = topleft ; br = bottomright
566
 
    NR::Point buf_tl_gc;
567
 
    NR::Point buf_br_gc;
568
 
    buf_tl_gc[NR::X] = buf->rect.x0 - ow[NR::X];
569
 
    buf_tl_gc[NR::Y] = buf->rect.y0 - ow[NR::Y];
570
 
    buf_br_gc[NR::X] = buf->rect.x1 - ow[NR::X];
571
 
    buf_br_gc[NR::Y] = buf->rect.y1 - ow[NR::Y];
 
566
    Geom::Point buf_tl_gc;
 
567
    Geom::Point buf_br_gc;
 
568
    buf_tl_gc[Geom::X] = buf->rect.x0 - ow[Geom::X];
 
569
    buf_tl_gc[Geom::Y] = buf->rect.y0 - ow[Geom::Y];
 
570
    buf_br_gc[Geom::X] = buf->rect.x1 - ow[Geom::X];
 
571
    buf_br_gc[Geom::Y] = buf->rect.y1 - ow[Geom::Y];
572
572
 
573
573
    gdouble x;
574
574
    gdouble y;
576
576
    // render the three separate line groups representing the main-axes
577
577
 
578
578
    // x-axis always goes from topleft to bottomright. (0,0) - (1,1)
579
 
    gdouble const xintercept_y_bc = (buf_tl_gc[NR::X] * tan_angle[X]) - buf_tl_gc[NR::Y] ;
 
579
    gdouble const xintercept_y_bc = (buf_tl_gc[Geom::X] * tan_angle[X]) - buf_tl_gc[Geom::Y] ;
580
580
    gdouble const xstart_y_sc = ( xintercept_y_bc - floor(xintercept_y_bc/lyw)*lyw ) + buf->rect.y0;
581
 
    gint const xlinestart = (gint) Inkscape::round( (xstart_y_sc - buf->rect.x0*tan_angle[X] -ow[NR::Y]) / lyw );
 
581
    gint const xlinestart = (gint) Inkscape::round( (xstart_y_sc - buf->rect.x0*tan_angle[X] -ow[Geom::Y]) / lyw );
582
582
    gint xlinenum = xlinestart;
583
583
    // lines starting on left side.
584
584
    for (y = xstart_y_sc; y < buf->rect.y1; y += lyw, xlinenum++) {
610
610
    }
611
611
 
612
612
    // y-axis lines (vertical)
613
 
    gdouble const ystart_x_sc = floor (buf_tl_gc[NR::X] / spacing_ylines) * spacing_ylines + ow[NR::X];
614
 
    gint const  ylinestart = (gint) Inkscape::round((ystart_x_sc - ow[NR::X]) / spacing_ylines);
 
613
    gdouble const ystart_x_sc = floor (buf_tl_gc[Geom::X] / spacing_ylines) * spacing_ylines + ow[Geom::X];
 
614
    gint const  ylinestart = (gint) Inkscape::round((ystart_x_sc - ow[Geom::X]) / spacing_ylines);
615
615
    gint ylinenum = ylinestart;
616
616
    for (x = ystart_x_sc; x < buf->rect.x1; x += spacing_ylines, ylinenum++) {
617
617
        gint const x0 = (gint) Inkscape::round(x);
624
624
    }
625
625
 
626
626
    // z-axis always goes from bottomleft to topright. (0,1) - (1,0)
627
 
    gdouble const zintercept_y_bc = (buf_tl_gc[NR::X] * -tan_angle[Z]) - buf_tl_gc[NR::Y] ;
 
627
    gdouble const zintercept_y_bc = (buf_tl_gc[Geom::X] * -tan_angle[Z]) - buf_tl_gc[Geom::Y] ;
628
628
    gdouble const zstart_y_sc = ( zintercept_y_bc - floor(zintercept_y_bc/lyw)*lyw ) + buf->rect.y0;
629
 
    gint const  zlinestart = (gint) Inkscape::round( (zstart_y_sc + buf->rect.x0*tan_angle[Z] - ow[NR::Y]) / lyw );
 
629
    gint const  zlinestart = (gint) Inkscape::round( (zstart_y_sc + buf->rect.x0*tan_angle[Z] - ow[Geom::Y]) / lyw );
630
630
    gint zlinenum = zlinestart;
631
631
    // lines starting from left side
632
632
    for (y = zstart_y_sc; y < buf->rect.y1; y += lyw, zlinenum++) {