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

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

Print the current developed sail drawings one panel per page with coordinates of key points for handplotting.

Definition at line 1012 of file formmain.cpp.

References CPanel::bottom, CPanel::boundingRect(), CPanel::centroid(), CSailPainter::draw(), flatsail, CSailDisp::getLRect(), CSailDisp::getSail(), CPanel::left, CRect3d::min, CSide::nbpoints(), CSail::panel, CSide::point, CPanel::right, CSailDisp::setSail(), CSailDisp::setVRect(), CSailPainter::setWindow(), CSailDisp::setZoom(), CPanel::top, CVector3d::x(), and CVector3d::y().

Referenced by setupMenuBar().

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

        QPrintDialog printDialog(&myprinter, this);
        if ( printDialog.exec() == QDialog::Accepted )
        {
            CSailPainter painter(&myprinter);
            int x=1, y=1, x1=1, y1=1;
            unsigned int npt;

            real xo=0, yo=0, xp=0, yp=0, dx=0, dy=0;

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

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

            QString text1, text2;
            unsigned int fontsz1 = int(10*scale);
            painter.setFont(QFont ("times", fontsz1));

            // print the panels out one by one
            for (unsigned int i = 0; i < flatsail.panel.size(); i++)
            {
                if ( i > 0 )
                {
                    myprinter.newPage();
                }
                // set coordinate system to match the logical viewport
                painter.setWindow(disp.getLRect());

                CPanel currentPanel = disp.getSail().panel[i];
                CRect3d rp = currentPanel.boundingRect();
                painter.draw(currentPanel);

                // mark corners of cloth rectangle
                painter.setPen(Qt::green);
                /*
                xo = rp.max.x();
                yo = rp.max.y();
                painter.drawLine(int(xo),-int(yo+.5*fontsz1),int(xo),-int(yo-.5*fontsz1));
                painter.drawLine(int(xo+.5*fontsz1),-int(yo),int(xo-.5*fontsz1),-int(yo));
                */
                xo = rp.min.x();
                yo = rp.min.y();
                painter.drawLine(int(xo),-int(yo+.5*fontsz1),int(xo),-int(yo-.5*fontsz1));
                painter.drawLine(int(xo+.5*fontsz1),-int(yo),int(xo-fontsz1),-int(yo));
                x = int( xo - 4*fontsz1);
                y = -int(yo + fontsz1);
                text2 = "X=0";
                painter.drawText(x, y, text2);
                y = y +int(1.5*fontsz1);
                text2 = "Y=0";
                painter.drawText(x, y, text2);

                // print the current panel number
                x = int(currentPanel.centroid().x());
                y = -int(currentPanel.centroid().y());
                text2 = QString::number( i );
                painter.drawText(x, y, text2);

                // add coordinates of inner lines
                painter.setPen(Qt::blue);
                // top fwd corners
                npt = 0;
                x = int(currentPanel.top.point[npt].x() );
                y = -int(currentPanel.top.point[npt].y() );
                x1 = int(x -fontsz1 );
                y1 = int(y - 3* fontsz1);
                painter.drawLine(x,y, x1,y1);
                x1 = x1 - int(5*fontsz1);
                y1 = y1 - int(2* fontsz1);
                xp = .1* int(10 * flatsail.panel[i].top.point[0].x() ) ;
                yp = .1 * int(10* flatsail.panel[i].top.point[0].y() );
                text1 = "X=" + QString::number(xp);
                painter.drawText(x1,y1, text1);
                y1 = y1 +int(1.5*fontsz1);
                text1 = "Y=" + QString::number(yp);
                painter.drawText(x1,y1, text1);

                // top  middle
                npt = int ( (currentPanel.top.nbpoints() -1) /2 );
                if ( CVector3d(flatsail.panel[i].top.point[npt]-flatsail.panel[i].top.point[0]).norm() > 5 )
                {
                    x = int(currentPanel.top.point[npt].x() );
                    y = -int(currentPanel.top.point[npt].y() );
                    x1 = x -int(fontsz1);
                    y1 = y -int(6* fontsz1);
                    painter.drawLine(x,y, x1,y1);
                    x1 = x1- int(4* fontsz1);
                    y1 = y1 -int(2* fontsz1);
                    dx = .1 * int(10 * CVector3d( flatsail.panel[i].top.point[npt] - flatsail.panel[i].top.point[0] ) * CVector3d( flatsail.panel[i].top.point[flatsail.panel[i].top.nbpoints() -1] - flatsail.panel[i].top.point[0] ).unit() );
                    text1 = "dX=" + QString::number( dx );
                    painter.drawText(x1, y1, text1);
                    y1 = y1 +int(1.5*fontsz1);
                    dy = .1 * int(10 * Distance3d(flatsail.panel[i].top.point[npt] , flatsail.panel[i].top.point[0] , flatsail.panel[i].top.point[flatsail.panel[i].top.nbpoints()-1] ) );
                    if ( (dy<.0001) && (dy>-.0001) )  dy = 0;
                    text1 = "dY=" + QString::number(dy );
                    painter.drawText(x1,y1, text1);
                }
                // top aft corner
                npt = currentPanel.top.nbpoints() -1;
                if ( CVector3d(flatsail.panel[i].top.point[npt]-flatsail.panel[i].top.point[0]).norm() > 5 )
                {
                    x = int(currentPanel.top.point[npt].x() );
                    y = -int(currentPanel.top.point[npt].y() );
                    x1 = x + int( fontsz1 );
                    y1 = y - int(3* fontsz1);
                    painter.drawLine(x,y, x1,y1);
                    x1 = x1 -int(3* fontsz1);
                    y1 = y1 -int(2* fontsz1);
                    xp = .1 * int(10 * flatsail.panel[i].top.point[npt].x() );
                    yp = .1 * int(10 * flatsail.panel[i].top.point[npt].y() );
                    text1 = "X=" + QString::number(xp);
                    painter.drawText(x1, y1, text1);
                    y1 = y1 +int(1.5* fontsz1);
                    text1 = "Y=" + QString::number(yp);
                    painter.drawText(x1,y1, text1);
                }
                // right middle
                npt = (currentPanel.right.nbpoints() -1)/2;
                x = int(currentPanel.right.point[npt].x() );
                y = -int(currentPanel.right.point[npt].y() );

                x1 = x +int(2* fontsz1 );
                y1 = y -int( fontsz1);
                painter.drawLine(x,y, x1,y1);
                x1 = x1 -int( fontsz1);
                y1 = y1 -int(2* fontsz1);
                xp = .1 * int(10 * flatsail.panel[i].right.point[npt].x() );
                yp = .1 * int(10 * flatsail.panel[i].right.point[npt].y() );
                text1 = "X=" + QString::number(xp);
                painter.drawText(x1,y1, text1);
                y1 = y1 +int(1.5* fontsz1);
                text1 = "Y=" + QString::number(yp);
                painter.drawText(x1,y1, text1);

                // bottom left corner
                if ( CVector3d(flatsail.panel[i].top.point[0]-flatsail.panel[i].bottom.point[0]).norm() > 5 )
                {
                    npt = 0;
                    x = int(currentPanel.bottom.point[npt].x() );
                    y = -int(currentPanel.bottom.point[npt].y() );
                    x1 = x - int( fontsz1 );
                    y1 = y + int(3* fontsz1);
                    painter.drawLine(x,y, x1,y1);
                    x1 = x1 - int(3* fontsz1);
                    y1 = y1+ int(1.5* fontsz1);
                    xp = .1 * int(10 * flatsail.panel[i].bottom.point[npt].x() );
                    yp = .1 * int(10 * flatsail.panel[i].bottom.point[npt].y() );
                    text1 = "X=" + QString::number(xp);
                    painter.drawText(x1,y1, text1);
                    y1 = y1+ int(1.5* fontsz1);
                    text1 = "Y=" + QString::number(yp);
                    painter.drawText(x1,y1, text1);
                    // mid left
                    npt = (currentPanel.left.nbpoints() -1)/2;
                    x = int(currentPanel.left.point[npt].x() );
                    y = -int(currentPanel.left.point[npt].y() );
                    x1 = x - int(2*fontsz1 );
                    y1 = y - int( fontsz1);
                    painter.drawLine(x,y, x1,y1);
                    x1 = x1 - int(5* fontsz1);
                    y1 = y1 - int(2* fontsz1);
                    xp = .1 * int(10 * flatsail.panel[i].left.point[npt].x() );
                    yp = .1 * int(10 * flatsail.panel[i].left.point[npt].y() );
                    text1 = "X=" + QString::number(xp);
                    painter.drawText(x1,y1, text1);
                    y1 = y1+ int(1.5* fontsz1);
                    text1 = "Y=" + QString::number(yp);
                    painter.drawText(x1,y1, text1);
                    if ( i == flatsail.panel.size() )
                    {
                        npt = 1+(currentPanel.left.nbpoints() -1)/2;
                        x = int(currentPanel.left.point[npt].x() );
                        y = -int(currentPanel.left.point[npt].y() );
                        x1 = x - int(2*fontsz1 );
                        y1 = y - int( fontsz1);
                        painter.drawLine(x,y, x1,y1);
                        x1 = x1 - int(5* fontsz1);
                        y1 = y1 - int(2* fontsz1);
                        xp = .1 * int(10 * flatsail.panel[i].left.point[npt].x() );
                        yp = .1 * int(10 * flatsail.panel[i].left.point[npt].y() );
                        text1 = "X=" + QString::number(xp);
                        painter.drawText(x1,y1, text1);
                        y1 = y1+ int(1.5* fontsz1);
                        text1 = "Y=" + QString::number(yp);
                        painter.drawText(x1,y1, text1);
                    }
                }
                // bottom intermediate fwd
                npt = int ( (currentPanel.bottom.nbpoints() -1) /5 );
                x = int(currentPanel.bottom.point[npt].x() );
                y = -int(currentPanel.bottom.point[npt].y() );
                x1 = x - int( fontsz1);
                y1 = y + int(3* fontsz1);
                painter.drawLine(x,y, x1,y1);
                x1 = x1 - int(2* fontsz1);
                y1 = y1 + int(1.5* fontsz1);
                dx = .1 * int(10 * CVector3d(  flatsail.panel[i].bottom.point[npt] -  flatsail.panel[i].bottom.point[0] ) * CVector3d(  flatsail.panel[i].bottom.point[ flatsail.panel[i].bottom.nbpoints() -1] -  flatsail.panel[i].bottom.point[0] ).unit() );
                text1 = "dX=" + QString::number( dx );
                painter.drawText(x1, y1, text1);
                y1 = y1 +int(1.5*fontsz1);
                dy = .1 * int(10 * Distance3d( flatsail.panel[i].bottom.point[npt] ,  flatsail.panel[i].bottom.point[0] ,  flatsail.panel[i].bottom.point[ flatsail.panel[i].bottom.nbpoints()-1] ) );
                if ( (dy<.01) && (dy>-.01) )  dy = 0;
                text1 = "dY=" + QString::number(dy );
                painter.drawText(x1,y1, text1);
                // bottom intermediate middle
                npt = int ( (currentPanel.bottom.nbpoints() -1) /2 );
                x = int(currentPanel.bottom.point[npt].x() );
                y = -int(currentPanel.bottom.point[npt].y() );
                x1 = x + int( fontsz1 );
                y1 = y - int(3* fontsz1);
                painter.drawLine(x,y, x1,y1);
                x1 = x1 - int(3* fontsz1);
                y1 = y1 - int(2* fontsz1);
                dx = .1 * int(10 * CVector3d(  flatsail.panel[i].bottom.point[npt] -  flatsail.panel[i].bottom.point[0] ) * CVector3d(  flatsail.panel[i].bottom.point[ flatsail.panel[i].bottom.nbpoints() -1] -  flatsail.panel[i].bottom.point[0] ).unit() );
                text1 = "dX=" + QString::number( dx );
                painter.drawText(x1, y1, text1);
                y1 = y1 +int(1.5*fontsz1);
                dy = .1 * int(10 * Distance3d( flatsail.panel[i].bottom.point[npt] ,  flatsail.panel[i].bottom.point[0] ,  flatsail.panel[i].bottom.point[ flatsail.panel[i].bottom.nbpoints()-1] ) );
                if ( (dy<.01) && (dy>-.01) )  dy = 0;
                text1 = "dY=" + QString::number(dy );
                painter.drawText(x1,y1, text1);
                // bottom intermediate aft
                npt = int ( (currentPanel.bottom.nbpoints() -1) *4/5 );
                x = int(currentPanel.bottom.point[npt].x() );
                y = -int(currentPanel.bottom.point[npt].y() );
                x1 = x - int( fontsz1 );
                y1 = y + int( 3* fontsz1);
                painter.drawLine(x,y, x1,y1);
                x1 = x1-int(4* fontsz1);
                y1 = y1 + int(1.5* fontsz1);
                dx = .1 * int(10 * CVector3d(  flatsail.panel[i].bottom.point[npt] -  flatsail.panel[i].bottom.point[0] ) * CVector3d(  flatsail.panel[i].bottom.point[ flatsail.panel[i].bottom.nbpoints() -1] -  flatsail.panel[i].bottom.point[0] ).unit() );
                text1 = "dX=" + QString::number( dx );
                painter.drawText(x1, y1, text1);
                y1 = y1 +int(1.5*fontsz1);
                dy = .1 * int(10 * Distance3d( flatsail.panel[i].bottom.point[npt] ,  flatsail.panel[i].bottom.point[0] ,  flatsail.panel[i].bottom.point[ flatsail.panel[i].bottom.nbpoints()-1] ) );
                if ( (dy<.01) && (dy>-.01) )  dy = 0;
                text1 = "dY=" + QString::number(dy );
                painter.drawText(x1,y1, text1);
                // bottom aft corner
                npt = currentPanel.bottom.nbpoints() -1;
                x = int(currentPanel.bottom.point[npt].x() );
                y = -int(currentPanel.bottom.point[npt].y() );
                x1 = x +int(fontsz1);
                y1 = y +int(2* fontsz1);
                painter.drawLine(x,y, x1,y1);
                x1 = x1-int(2*fontsz1);
                y1 = y1+int(1.5*fontsz1);
                xp = .1 * int(10 * flatsail.panel[i].bottom.point[npt].x() ) ;
                yp = .1 * int(10 * flatsail.panel[i].bottom.point[npt].y() );
                text1 = "X=" + QString::number(xp);
                painter.drawText(x1, y1, text1);
                y1 = y1+ int(1.5*fontsz1);
                text1 = "Y=" + QString::number(yp);
                painter.drawText(x1,y1, text1);

                // reset pen color
                painter.setPen(Qt::black);

            }
            ///
        }
    }
    catch (CException e)
    {
        QMessageBox::information(this, tr("error"), tr("There was a development printing error"));
    }
}


Generated by  Doxygen 1.6.0   Back to index