Esempio n. 1
0
/**
 * Fits drawing on page. Affects DXF variable $PINSBASE.
 */
bool RS_Graphic::fitToPage() {
    bool ret(true);
    double border = RS_Units::convert(25.0, RS2::Millimeter, getUnit());
    RS_Vector ps = getPaperSize();
    if(ps.x>border && ps.y>border) ps -= RS_Vector(border, border);
    RS_Vector s = getSize();
    double fx = RS_MAXDOUBLE;
    double fy = RS_MAXDOUBLE;
    double fxy;
    //ps = RS_Units::convert(ps, getUnit(), RS2::Millimeter);

    // tin-pot 2011-12-30: TODO: can s.x < 0.0 (==> fx < 0.0) happen?
    if (fabs(s.x) > 1.0e-10) {
        fx = ps.x / s.x;
    }
    if (fabs(s.y) > 1.0e-10) {
        fy = ps.y / s.y;
    }

    fxy = std::min(fx, fy);
    if (fxy >= RS_MAXDOUBLE || fxy <= 1.0e-10) {
        setPaperSize(
                    RS_Units::convert(RS_Vector(210.,297.)
                                      , RS2::Millimeter
                                      , getUnit()
                                      )
                    );
        fitToPage();
        ret=false;
    }
    setPaperScale(fxy);
    centerToPage();
    return ret;
}
Esempio n. 2
0
void PageSetup::setPaperSize( double w, double h )
{
    QString s = QString("Custom");
    setPaperSize(s);
    tbPaperWidth->setText(QString::number(w,'f',3));
    tbPaperHeight->setText(QString::number(h,'f',3));
}
Esempio n. 3
0
/**
 * Sets the unit of this graphic to 'u'
 */
void RS_Graphic::setUnit(RS2::Unit u) {

    setPaperSize(RS_Units::convert(getPaperSize(), getUnit(), u));

    addVariable("$INSUNITS", (int)u, 70);

    //unit = u;
}
Esempio n. 4
0
/**
 * Sets the paper format to the given format.
 */
void RS_Graphic::setPaperFormat(RS2::PaperFormat f, bool landscape) {
    RS_Vector size = RS_Units::paperFormatToSize(f);

	if (landscape ^ (size.x > size.y)) {
		std::swap(size.x, size.y);
    }

	setPaperSize(RS_Units::convert(size, RS2::Millimeter, getUnit()));
}
Esempio n. 5
0
/**
 * Sets the paper format to the given format.
 */
void RS_Graphic::setPaperFormat(RS2::PaperFormat f, bool landscape) {
    RS_Vector size = RS_Units::paperFormatToSize(f);

    if (landscape) {
        double tmp = size.x;
        size.x = size.y;
        size.y = tmp;
    }

        if (f!=RS2::Custom) {
        setPaperSize(RS_Units::convert(size, RS2::Millimeter, getUnit()));
        }
}