~jightuse/inkscape/inkscape

« back to all changes in this revision

Viewing changes to src/document.cpp

  • Committer: tavmjong-free
  • Date: 2015-03-11 14:01:37 UTC
  • Revision ID: tavmjong@free.fr-20150311140137-l8axbbdkrogj9ise
Allow changing document scale (via changing viewBox). Start of GUI.

Show diffs side-by-side

added added

removed removed

Lines of Context:
611
611
    return nv ? nv->getSVGUnit() : *unit_table.getUnit("px");
612
612
}
613
613
 
614
 
/// Returns document scale as defined by width/height and viewBox (real world to user-units).
 
614
/// Sets document scale (by changing viewBox)
 
615
void SPDocument::setDocumentScale( double scaleX, double scaleY ) {
 
616
 
 
617
    root->viewBox = Geom::Rect::from_xywh(
 
618
        root->viewBox.left(),
 
619
        root->viewBox.top(),
 
620
        root->width.computed  * scaleX,
 
621
        root->height.computed * scaleY );
 
622
    root->viewBox_set = true;
 
623
    root->updateRepr();
 
624
}
 
625
 
 
626
/// Sets document scale (by changing viewBox, x and y scaling equal) 
 
627
void SPDocument::setDocumentScale( double scale ) {
 
628
    setDocumentScale( scale, scale );
 
629
}
 
630
 
 
631
/// Returns document scale as defined by width/height (in pixels) and viewBox (real world to
 
632
/// user-units).
615
633
Geom::Scale SPDocument::getDocumentScale() const
616
634
{
617
635
    Geom::Scale scale;
660
678
    root->height.value = height.quantity;
661
679
    root->height.unit = (SVGLength::Unit) height.unit->svgUnit();
662
680
 
663
 
    if (root->viewBox_set && changeSize)
 
681
    // viewBox scaled by relative change in page size (maintains document scale).
 
682
    if (root->viewBox_set && changeSize) {
664
683
        root->viewBox.setMax(Geom::Point(
665
684
        root->viewBox.left() + (root->width.value /  old_width_converted ) * root->viewBox.width(),
666
685
        root->viewBox.top()  + (root->height.value / old_height_converted) * root->viewBox.height()));
 
686
    }
667
687
    root->updateRepr();
668
688
}
669
689