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
        QPrinter myprinter;
        // set landscape printing

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

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

            // set coordinate system to match the logical viewport

            //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());

                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