Logo Search packages:      
Sourcecode: sailcut version File versions  Download package

void CFormMain::slotPrintDwg (  )  [protected, virtual, slot]

Print the current sail drawing.

Definition at line 1299 of file formmain.cpp.

References CPanel::centroid(), CSailPainter::draw(), flatsail, CSailDisp::getLRect(), CSailDisp::getSail(), CSail::panel, sail, CSailDisp::setSail(), CSailDisp::setVRect(), CSailPainter::setWindow(), CSailDisp::setZoom(), CVector3d::x(), and CVector3d::y().

Referenced by setupMenuBar().

{  // try printing
    try
    {
        QPrinter myprinter;
        // set landscape printing
        myprinter.setOrientation(QPrinter::Portrait);
        myprinter.setFullPage(FALSE);

        QPrintDialog printDialog(&myprinter, this);
        if ( printDialog.exec() == QDialog::Accepted )
        {
            CSailPainter painter(&myprinter);

            // set the viewport
            CSailDisp disp;
            disp.setSail(sail);
            QRect vRect = painter.viewport();
            disp.setVRect(vRect.width(), vRect.height());
            disp.setZoom(0.80);

            // set coordinate system to match the logical viewport
            painter.setWindow(disp.getLRect());

            //double aspect = (double)myprinter.widthMM() / (double)myprinter.heightMM();
            unsigned int height = myprinter.heightMM();
            real scale = height/50;

            QString text1, text2;
            unsigned int fontsz1 = int(11*scale);
            int  x=1, y=1;
            painter.setFont(QFont ("times", fontsz1));

            // print the panels one by one
            for (unsigned int i = 0; i < flatsail.panel.size(); i++)
            {
               CPanel currentPanel = disp.getSail().panel[i];
               CPoint3d panelCenter= currentPanel.centroid();
                x = int(panelCenter.x());
                y = -int(panelCenter.y());

                painter.draw(currentPanel);
                text2 = QString::number( i );
                painter.drawText( x, y, text2);
            }
            ///
        }
    }
    catch (CException e)
    {
        QMessageBox::information(this, tr("error"), tr("There was a drawing printing error"));
    }
}


Generated by  Doxygen 1.6.0   Back to index