void MainWindow::funS()
{
    QLabel* l = new QLabel;
    l->setWindowTitle("Fun");
    l->setFixedSize(765, 500);

    QObject::connect( this, SIGNAL( closeSignal() ), l, SLOT( close() ) );

    QRect rect(l->contentsRect());
    QPainter painter;

    QImage resultImage(rect.size(), QImage::Format_ARGB32_Premultiplied);

    painter.begin(&resultImage);
    painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
    painter.eraseRect(rect);
    painter.drawImage(rect, resultImage);
    painter.end();

    painter.begin(&resultImage);
    painter.setCompositionMode(QPainter::CompositionMode_Darken);

    for(int i = 0; i < 765; i++)
    {
        if(i<256)
            painter.setPen(QPen(QColor(255, i, 0), 1));
        else if(i < 512)
            painter.setPen(QPen(QColor(511-i, 255, i-256), 1));
            else
                painter.setPen(QPen(QColor(i-512, 765-i, 255), 1));

        painter.drawLine(i, 0, i, 500);
    }
    painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
    painter.drawImage(rect, resultImage);
    painter.end();

    l->setPixmap(QPixmap::fromImage(resultImage));
    l->show();

    QObject::connect( this, SIGNAL( closeSignal() ), l, SLOT( close() ) );
}
void AnimationViewerPanel::renderCelSprites(const QPoint& centerPoint, QPainter& painter)
{
    KeyFrame::KeyFramePosition currentPosition = mpAnimationModel->getCurrentKeyFramePosition();

    if (mIsAnimationPlaying)
    {
        mpAnimationModel->executeCommand(currentPosition.mFrameNo);
    }

    QList<const GLSprite*>::Iterator iter = mRenderSpriteList.begin();
    while (iter != mRenderSpriteList.end())
    {
        GLSprite* glSprite = (GLSprite*)*iter;

        if (glSprite->mLineNo == AnimationModel::LINE_target)
        {
            if (!mShowTarget)
            {
                iter++;
                continue;
            }
            GLSprite::Point2 position;
            position.mX = glSprite->mSpriteDescriptor.mPosition.mX + AnimationModel::TARGET_originX;
            position.mY = glSprite->mSpriteDescriptor.mPosition.mY + AnimationModel::TARGET_originY;
            glSprite->mSpriteDescriptor.mPosition = position;
         }

        if (!mShowCamera && glSprite->mLineNo == AnimationModel::LINE_camera)
        {
           iter++;
           continue;
        }

        // render sprite
        // Move rendering position depends on targeting position option
        int dx = 0;
        int dy = 0;
//        if (glSprite->mLineNo == AnimationModel::LINE_target)
//        {
//            dx = glSprite->mSpriteDescriptor.mTextureSrcRect.width() / 2;
//            dy = glSprite->mSpriteDescriptor.mTextureSrcRect.height() / 2;
//        }

        painter.translate(centerPoint.x() + dx, centerPoint.y() + dy);
        if (glSprite)
        {
            glSprite->render(QPoint(0, 0), painter,AnimationModel::getTargetSprite(), mIsAnimationPlaying, mEmittedAnimationList);
        }

        painter.translate(-centerPoint.x() - dx, -centerPoint.y() - dy);


        if (glSprite && !mIsAnimationPlaying && mShowAnimationUI)
        {
            renderCelBox(painter, glSprite, centerPoint - glSprite->mSpriteDescriptor.center());
        }

    iter++;
    }

    if (mIsAnimationPlaying)
    {
        // update emitted animations
        for (int lineNo = 0; lineNo < AnimationModel::LINE_COUNT; lineNo++)
        {
            for (int i = mEmittedAnimationList[lineNo].count() - 1; i >= 0; i--)
            {
                mEmittedAnimationList[lineNo][i]->update();
                if (mEmittedAnimationList[lineNo][i]->isDone())
                {
                    mEmittedAnimationList[lineNo].removeAt(i);
                }
            }
        }
    }
}
Beispiel #3
0
void Node::deinitPainter(QPainter &p) {
	p.rotate(-m_dir);
	p.translate(-int(x()), -int(y()));
}
Beispiel #4
0
//-----------------------------------------------------------
void CenaObjetos::definirGrade(unsigned tam)
{
 if(tam >= 20 || grade.style()==Qt::NoBrush)
 {
  QImage img_grade;
  float larg, alt, x, y;
  QSizeF tam_aux;
  QPrinter printer;
  QPainter painter;
  QPen pen;

  //Caso o tamanho do papel não seja personalizado
  if(tam_papel!=QPrinter::Custom)
  {
   //Configura um dispositivo QPrinter para obter os tamanhos de página
   printer.setPageSize(tam_papel);
   printer.setOrientation(orientacao_pag);
   printer.setPageMargins(margens_pag.left(), margens_pag.top(),
                          margens_pag.right(), margens_pag.bottom(), QPrinter::Millimeter);
   tam_aux=printer.pageRect(QPrinter::DevicePixel).size();
  }
  //Caso o tipo de papel seja personalizado, usa as margens como tamanho do papel
  else
   tam_aux=margens_pag.size();


  larg=fabs(roundf(tam_aux.width()/static_cast<float>(tam)) * tam);
  alt=fabs(roundf(tam_aux.height()/static_cast<float>(tam)) * tam);

  //Cria uma instância de QImage para ser a textura do brush
  tam_grade=tam;
  img_grade=QImage(larg, alt, QImage::Format_ARGB32);

  //Aloca um QPaointer para executar os desenhos sobre a imagem
  painter.begin(&img_grade);

  //Limpa a imagem
  painter.fillRect(QRect(0,0,larg,alt), QColor(255,255,255));

  if(exibir_grade)
  {
   //Cria a grade
   pen.setColor(QColor(225, 225, 225));
   painter.setPen(pen);

   for(x=0; x < larg; x+=tam)
    for(y=0; y < alt; y+=tam)
     painter.drawRect(QRectF(QPointF(x,y),QPointF(x + tam,y + tam)));
  }

  //Cria as linhas que definem o limite do papel
  if(exibir_lim_pagina)
  {
   pen.setColor(QColor(75,115,195));
   pen.setStyle(Qt::DashLine);
   pen.setWidthF(1.85f);
   painter.setPen(pen);
   painter.drawLine(larg-1, 0,larg-1,alt-1);
   painter.drawLine(0, alt-1,larg-1,alt-1);
  }

  painter.end();
  grade.setTextureImage(img_grade);
 }
}
Beispiel #5
0
void HSI::createCard(void){
    QImage _cardImage = QImage(QSize(600,600), QImage::Format_ARGB32);
    _cardImage.fill(0x00ff0000);
    //_cardImage.moveTo(10,10);
    
    uint midx, midy, width, height;
    width = _cardImage.width();
    midx = width/2;
    height = _cardImage.height();
    midy = height/2;
    
    
    QPainter p;
    p.setRenderHint(QPainter::Antialiasing, true);
    p.begin(&_cardImage);
    
    p.translate(midx, midy);
    p.setPen(Qt::black);
    
    p.setBrush(Qt::black);
    p.drawChord(-midx,-midy,width,height,0,360*16);
    
    
    p.setPen(Qt::white);
    p.setBrush(Qt::white);
    if(_thickBars > 0) {
        for (float i = 0 ; i <= 360; i+=_thickBars) {
            p.save();
            p.rotate(value2Angle(i));
            p.drawRect(-2.5, -300, 5.0, 30);
            p.restore();
        }
    }
    if(_thinBars > 0) {
        for (float i = 0 ; i <= 360; i+=_thinBars) {
            p.save();
            p.rotate(value2Angle(i));
            p.drawRect(-1.0, -300, 2.0, 20);
            p.restore();
        }
    }
    p.setPen(QColor(200,200,200));
    p.setFont(QFont(QString("Helvetica"), 48, QFont::Bold, false));
    
    if(1) {
        for (float i = 0 ; i < 360; i+=_numbers) {
            p.save();
            p.rotate(value2Angle(i));
            p.save();
            QString lineNumber;
            switch (int(i)) {
                case 0:
                    lineNumber = QString("N");
                    break;
                case 90:
                    lineNumber = QString("E");
                    break;
                case 180:
                    lineNumber = QString("S");
                    break;
                case 270:
                    lineNumber = QString("W");
                    break;
                default:
                    lineNumber = QString::number(i/10);
                    break;
            }
            p.translate(0,-234);
            int width = p.fontMetrics().width(lineNumber);
            int height = p.fontMetrics().height();
            p.drawText(-width/2,-height/2,width,height, Qt::AlignCenter,  lineNumber);
            p.restore();
            p.restore();
        }
    }
    
    
    
    p.end();    
    _card = QPixmap::fromImage(_cardImage, Qt::AutoColor);
    
}
//---------------------------------------------------------------------------
//  makePixmap
//
//! Create a pixmap representation of the rack.
//
//! @return the pixmap
//---------------------------------------------------------------------------
QPixmap
CrosswordGameRackWidget::makePixmap() const
{
    QPixmap pixmap (getRackSize());
    QPainter painter (&pixmap);

    // FIXME: most of this is duplicated between BoardWidget and here
    QColor backgroundColor = BACKGROUND_COLOR;
    QPalette backgroundPalette;
    backgroundPalette.setColor(QPalette::Light,
                               backgroundColor.light(SQUARE_SHADE_VALUE));
    backgroundPalette.setColor(QPalette::Mid, backgroundColor);
    backgroundPalette.setColor(QPalette::Dark,
                               backgroundColor.dark(SQUARE_SHADE_VALUE));

    for (int i = 0; i < NUM_TILES; ++i) {
        QRect rect (i * COLUMN_WIDTH, 0, COLUMN_WIDTH, ROW_HEIGHT);
        painter.setPen(backgroundColor);
        painter.setBrush(backgroundColor);
        painter.drawRect(rect);

        qDrawShadePanel(&painter, rect, backgroundPalette, false,
                        SQUARE_SHADE_PANEL_WIDTH);


        if (i >= letters.length())
            continue;

        QRect tileRect(i * COLUMN_WIDTH + TILE_MARGIN, TILE_MARGIN,
                       COLUMN_WIDTH - 2 * TILE_MARGIN -
                       SQUARE_SHADE_PANEL_WIDTH,
                       ROW_HEIGHT - 2 * TILE_MARGIN -
                       SQUARE_SHADE_PANEL_WIDTH);

        QColor color = TILE_COLOR;
        QPalette palette;
        palette.setColor(QPalette::Light,
                         color.light(TILE_SHADE_VALUE));
        palette.setColor(QPalette::Mid, color);
        palette.setColor(QPalette::Dark,
                         color.dark(TILE_SHADE_VALUE));

        painter.setPen(QColor("black"));
        painter.setBrush(color);
        painter.drawRect(tileRect);
        qDrawShadePanel(&painter, tileRect, palette, false,
                        TILE_SHADE_PANEL_WIDTH);

        QFont tileFont = font();
        tileFont.setPixelSize(LETTER_HEIGHT);
        tileFont.setWeight(QFont::Black);
        painter.setFont(tileFont);

        switch (playerNum) {
            case 1:  color = PLAYER1_LETTER_COLOR; break;
            case 2:  color = PLAYER2_LETTER_COLOR; break;
            default: color = DEFAULT_LETTER_COLOR; break;
        }
        painter.setPen(QPen(color));

        QChar letter = letters[i];
        if (letter == '?') {
            QPen pen (color);
            pen.setWidth(1);
            painter.setPen(pen);
            painter.setBrush(Qt::NoBrush);
            QRect blankRect(rect.x() + BLANK_SQUARE_MARGIN,
                            rect.y() + BLANK_SQUARE_MARGIN,
                            rect.width() - 2 * BLANK_SQUARE_MARGIN -
                            SQUARE_SHADE_PANEL_WIDTH - 1,
                            rect.height() - 2 * BLANK_SQUARE_MARGIN -
                            SQUARE_SHADE_PANEL_WIDTH - 1);
            painter.drawRect(blankRect);
        }

        else {
            painter.drawText(rect, Qt::AlignCenter, letter);
        }
    }

    return pixmap;
}
Beispiel #7
0
void LightMaps::paintEvent(QPaintEvent *event)
{
    QPainter p;
    p.begin(this);
    m_normalMap->render(&p, event->rect());
    p.setPen(Qt::black);
#if defined(Q_OS_SYMBIAN)
    QFont font = p.font();
    font.setPixelSize(13);
    p.setFont(font);
#endif
    p.drawText(rect(),  Qt::AlignBottom | Qt::TextWordWrap,
                "Map data CCBYSA 2009 OpenStreetMap.org contributors");
    p.end();

    if (zoomed) {
        int dim = qMin(width(), height());
        int magnifierSize = qMin(MAX_MAGNIFIER, dim * 2 / 3);
        int radius = magnifierSize / 2;
        int ring = radius - 15;
        QSize box = QSize(magnifierSize, magnifierSize);

        // reupdate our mask
        if (maskPixmap.size() != box) {
            maskPixmap = QPixmap(box);
            maskPixmap.fill(Qt::transparent);

            QRadialGradient g;
            g.setCenter(radius, radius);
            g.setFocalPoint(radius, radius);
            g.setRadius(radius);
            g.setColorAt(1.0, QColor(255, 255, 255, 0));
            g.setColorAt(0.5, QColor(128, 128, 128, 255));

            QPainter mask(&maskPixmap);
            mask.setRenderHint(QPainter::Antialiasing);
            mask.setCompositionMode(QPainter::CompositionMode_Source);
            mask.setBrush(g);
            mask.setPen(Qt::NoPen);
            mask.drawRect(maskPixmap.rect());
            mask.setBrush(QColor(Qt::transparent));
            mask.drawEllipse(g.center(), ring, ring);
            mask.end();
        }

        QPoint center = dragPos - QPoint(0, radius);
        center = center + QPoint(0, radius / 2);
        QPoint corner = center - QPoint(radius, radius);

        QPoint xy = center * 2 - QPoint(radius, radius);

        // only set the dimension to the magnified portion
        if (zoomPixmap.size() != box) {
            zoomPixmap = QPixmap(box);
            zoomPixmap.fill(Qt::lightGray);
        }
        if (true) {
            QPainter p(&zoomPixmap);
            p.translate(-xy);
            m_largeMap->render(&p, QRect(xy, box));
            p.end();
        }

        QPainterPath clipPath;
        clipPath.addEllipse(center, ring, ring);

        QPainter p(this);
        p.setRenderHint(QPainter::Antialiasing);
        p.setClipPath(clipPath);
        p.drawPixmap(corner, zoomPixmap);
        p.setClipping(false);
        p.drawPixmap(corner, maskPixmap);
        p.setPen(Qt::gray);
        p.drawPath(clipPath);
    }
    if (invert) {
        QPainter p(this);
        p.setCompositionMode(QPainter::CompositionMode_Difference);
        p.fillRect(event->rect(), Qt::white);
        p.end();
    }
}
Beispiel #8
0
void SectionViewWidget::PaintLegend(QPainter &painter)
{
	if(!m_pSailSection) return;
	painter.save();
	MainFrame* pMainFrame = (MainFrame*)s_pMainFrame;
	QString strlength;
	GetLengthUnit(strlength, pMainFrame->m_LengthUnit);

	painter.setFont(pMainFrame->m_TextFont);
	QFontMetrics fm(pMainFrame->m_TextFont);
	int dD = fm.height();//pixels

	QPoint Place(5, rect().bottom()-5*dD);

	if(m_pSail->IsNURBSSail()) Place.ry() -=dD;

	painter.setBackgroundMode(Qt::TransparentMode);

	QPen TextPen(pMainFrame->m_TextColor);
	painter.setPen(TextPen);

	if(m_pSail->IsNURBSSail() && m_pSailSection->IsTipSection())
	{
		QString strtwist = QString("Section chord = %1").arg(m_pSailSection->Chord()*pMainFrame->m_mtoUnit, 6,'f',2) + strlength;
		painter.drawText(Place.x(), Place.y() , strtwist);
	}

	if(m_pSail->IsSailcutSail() || m_pSailSection->IsTipSection())
	{
		double x, c;
		m_pSailSection->GetCamber(c, x);

		QString strc = QString("Camber        = %1").arg(c*100.0, 6, 'f',2);
		QString strx = QString("Camber pos    = %1").arg(x*100.0, 6, 'f',2);
		strc += QString::fromUtf8("%");
		strx += QString::fromUtf8("%");

		painter.drawText(Place.x(), Place.y() + dD, strx);
		painter.drawText(Place.x(), Place.y() + 2*dD, strc);
	}


	double s0,s1;
	m_pSailSection->GetSlopes(s0,s1);
	QString str0 = QString("Luff Slope    = %1").arg(s0,5,'f',1) + QString::fromUtf8("°");
	QString str1 = QString("Leech Slope   = %1").arg(s1,5,'f',1) + QString::fromUtf8("°");

	painter.drawText(Place.x(), Place.y() + 3*dD, str0);
	painter.drawText(Place.x(), Place.y() + 4*dD, str1);

	if(m_pSail->IsNURBSSail())
	{
		QString strtwist = QString("Section twist = %1").arg(m_pSailSection->Twist(), 5,'f',1) + QString::fromUtf8("°");
		painter.drawText(Place.x(), Place.y() + 5*dD, strtwist);
	}

	//right side legend

	if(m_pSail->IsNURBSSail())
	{
		int YPos = rect().bottom()- dD;
		int XPos = rect().right() -5;

		NURBSSail *pNSail =(NURBSSail*)m_pSail;
		CVector LE = pNSail->m_SplineSurface.LeadingEdgeAxis();
		QString strLuffAngle = QString("Luff Angle = %1").arg(atan2(LE.x, LE.z) * 180./PI, 5,'f',1) + QString::fromUtf8("°");
		painter.drawText(XPos-fm.width(strLuffAngle), YPos, strLuffAngle);
	}

	painter.restore();
}
Beispiel #9
0
void SurfaceImpl::PenColour(ColourDesired fore)
{
    Q_ASSERT(painter);

    painter->setPen(convertQColor(fore));
}
QPixmap TaintedPixmap::createTaintedPixmapNotMac(const QString &pixmap_path, const QColor &tint_color)
{
    QPixmap shape(pixmap_path);
    QPixmap result(shape);
    QPainter painter;

    painter.begin(&result);
    painter.fillRect(painter.viewport(), tint_color);
    // Apply the shape on top of the tint
    painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
    painter.drawPixmap(painter.viewport(), shape);
    // Remove unused background
    painter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
    painter.drawPixmap(painter.viewport(), shape);
    painter.end();

    return result;
}
QPixmap TaintedPixmap::createTaintedPixmapMacOnly(const QString &pixmap_path, const QColor &tint_color)
{
    QPixmap shape(pixmap_path);
    QPixmap result(shape);
    QPainter painter;

    painter.begin(&result);
    painter.drawPixmap(painter.viewport(), shape);
    // Create a color mask
    painter.setCompositionMode(QPainter::CompositionMode_SourceIn);
    painter.fillRect(painter.viewport(), tint_color);
    // Apply the shape on top of the mask
    painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
    painter.drawPixmap(painter.viewport(), shape);
    painter.end();

    return result;
}
void CanvasRenderingContext2D::stroke()
{
    GraphicsContext* c = drawingContext();
    if (!c)
        return;
    c->beginPath();
    c->addPath(m_path);

    if (!m_path.isEmpty()) {
        // FIXME: This is insufficient, need to use CGContextReplacePathWithStrokedPath to expand to required bounds
        float lineWidth = state().m_lineWidth;
        float inset = lineWidth / 2;
        FloatRect boundingRect = m_path.boundingRect();
        boundingRect.inflate(inset);
        willDraw(boundingRect);
    }
    
    // FIXME: Do this through platform-independent GraphicsContext API.
#if PLATFORM(CG)
    if (state().m_strokeStyle->canvasGradient()) {
        // Shading works on the entire clip region, so convert the current path to a clip.
        c->save();
        CGContextReplacePathWithStrokedPath(c->platformContext());
        CGContextClip(c->platformContext());
        CGContextDrawShading(c->platformContext(), state().m_strokeStyle->canvasGradient()->gradient().platformGradient());        
        c->restore();
    } else {
        if (state().m_strokeStyle->pattern())
            applyStrokePattern();
        CGContextStrokePath(c->platformContext());
    }
#elif PLATFORM(QT)
    QPainterPath* path = m_path.platformPath();
    QPainter* p = static_cast<QPainter*>(c->platformContext());
    if (state().m_strokeStyle->canvasGradient()) {
        p->save();
        p->setBrush(*(state().m_strokeStyle->canvasGradient()->gradient().platformGradient()));
        p->strokePath(*path, p->pen());
        p->restore();
    } else {
        if (state().m_strokeStyle->pattern())
            applyStrokePattern();
        p->strokePath(*path, p->pen());
    }
#elif PLATFORM(CAIRO) && !PLATFORM(BAL)
    cairo_t* cr = c->platformContext();
    cairo_save(cr);
    if (state().m_strokeStyle->canvasGradient()) {
        cairo_set_source(cr, state().m_strokeStyle->canvasGradient()->gradient().platformGradient());
        c->addPath(m_path);
        cairo_stroke(cr);
    } else {
        if (state().m_strokeStyle->pattern())
            applyStrokePattern();
        c->addPath(m_path);
        cairo_stroke(cr);
    }
    cairo_restore(cr);
#elif PLATFORM(BAL)
    //FIXME
    notImplemented();
#endif

#if ENABLE(DASHBOARD_SUPPORT)
    clearPathForDashboardBackwardCompatibilityMode();
#endif
}
Beispiel #13
0
void Q3PlotAxis::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);

    QPainter painter;
    painter.begin(this);
    painter.setPen(Qt::white);

    QFontMetrics fm(font());
    QVector<int> tp = tickPositions();
    int margin = Q3PlotFrameContainer::Margin;

    switch (position_) {
    case Q3PlotFrame::PositionLeft:
        if (labelsVisible_) {
            for (int i = 0; i < ticks_.count(); ++i) {
                if (tp[i] + margin - fm.height() / 3. < 0
                        || tp[i] + margin + fm.height() / 3. > height()) {
                    continue;
                }
                painter.drawText(QPointF(width() - margin - fm.width(labels_[i]) - 1,
                                         tp[i] + margin + fm.height() / 3),
                                 labels_[i]);
            }
        }
        break;
    case Q3PlotFrame::PositionTop:
        if (labelsVisible_) {
            for (int i = 0; i < ticks_.count(); ++i) {
                if (tp[i] + margin - fm.width(labels_[i]) / 2 < 0
                        || tp[i] + margin + fm.width(labels_[i]) / 2 > width()) {
                    continue;
                }
                painter.drawText(QPointF(tp[i] + margin - fm.width(labels_[i]) / 2,
                                         height() - margin - 1), labels_[i]);
            }
        }
        break;
    case Q3PlotFrame::PositionRight:
        if (labelsVisible_) {
            for (int i = 0; i < ticks_.count(); ++i) {
                if (tp[i] + margin - fm.height() / 3. < 0
                        || tp[i] + margin + fm.height() / 3. > height()) {
                    continue;
                }
                painter.drawText(QPointF(margin, tp[i] + margin + fm.height() / 3),
                                 labels_[i]);
            }
        }
        break;
    case Q3PlotFrame::PositionBottom:
        if (labelsVisible_) {
            for (int i = 0; i < ticks_.count(); ++i) {
                if (tp[i] + margin - fm.width(labels_[i]) / 2 < 0
                        || tp[i] + margin + fm.width(labels_[i]) / 2 > width()) {
                    continue;
                }
                painter.drawText(QPointF(tp[i] + margin - fm.width(labels_[i]) / 2,
                                         margin + 2. / 3. * fm.height()), labels_[i]);
            }
        }
        break;
    }

    painter.end();
}
Beispiel #14
0
void HoverPoints::paintPoints()
{
    QPainter p;
#ifdef QT_OPENGL_SUPPORT
    ArthurFrame *af = qobject_cast<ArthurFrame *>(m_widget);
    if (af && af->usesOpenGL())
        p.begin(af->glWidget());
    else
        p.begin(m_widget);
#else
    p.begin(m_widget);
#endif

    p.setRenderHint(QPainter::Antialiasing);

    if (m_connectionPen.style() != Qt::NoPen && m_connectionType != NoConnection) {
        p.setPen(m_connectionPen);

        if (m_connectionType == CurveConnection) {
            QPainterPath path;
            path.moveTo(m_points.at(0));
            for (int i=1; i<m_points.size(); ++i) {
                QPointF p1 = m_points.at(i-1);
                QPointF p2 = m_points.at(i);
                qreal distance = p2.x() - p1.x();

                path.cubicTo(p1.x() + distance / 2, p1.y(),
                             p1.x() + distance / 2, p2.y(),
                             p2.x(), p2.y());
            }
            p.drawPath(path);
        } else {
            p.drawPolyline(m_points);
        }
    }

    p.setPen(m_pointPen);
    p.setBrush(m_pointBrush);

    for (int i=0; i<m_points.size(); ++i) {
        QRectF bounds = pointBoundingRect(i);
        if (m_shape == CircleShape)
            p.drawEllipse(bounds);
        else
            p.drawRect(bounds);
    }
}
Beispiel #15
0
//---------------------------------------------------------------	
void SkewTWindow::actionsCommonSlot ()
{
	setCursor (Qt::WaitCursor);
	QObject *send = sender ();
	if (send == acExit) {
		this->hide ();
		this->destroy ();
		if (skewt) {
			delete skewt;
            skewt = nullptr;
		}
	}	
	else if (send == cbTempMax) {
		int v = cbTempMax->itemData (cbTempMax->currentIndex()).toInt();
		Util::setSetting ("skewt_tempCMax", v);
		skewt->setTempPressLimits (v, skewt->getHpaMin());
	}
	else if (send == cbHpaMin) {
		int v = cbHpaMin->itemData (cbHpaMin->currentIndex()).toInt();
		Util::setSetting ("skewt_hpaMin", v);
		skewt->setTempPressLimits (skewt->getTempCMax(), v-10);
	}
	else if (send == cbSizeW) {
		double sz = cbSizeW->itemData (cbSizeW->currentIndex()).toDouble();
		Util::setSetting ("skewt_sizeW", sz);
		skewt->setSkewTSize (sz, skewt->height());
	}
	else if (send == cbSizeH) {
		double sz = cbSizeH->itemData (cbSizeH->currentIndex()).toDouble();
		Util::setSetting ("skewt_sizeH", sz);
		skewt->setSkewTSize (skewt->width(), sz);
	}
	else if (send == cbConvBase) {
		QString cbase = cbConvBase->itemData (cbConvBase->currentIndex()).toString();
		Util::setSetting ("skewt_convectiveBase", cbase);
		skewt->setConvectiveBase (cbase);
	}
	else if (send == chkShowConv) {
		Util::setSetting ("skewt_showConvectiveCurves", chkShowConv->isChecked());
		skewt->resetGraphic ();
		cbConvBase->setEnabled (chkShowConv->isChecked());
	}
	else if (send == acPrint) {
		QPrinter printer;
		printer.setOutputFormat (QPrinter::PdfFormat);
		printer.setResolution (150);

		QPrintDialog *dialog = new QPrintDialog(&printer, this);
		dialog->setWindowTitle (tr("Print Document"));
		
		if (dialog->exec() == QDialog::Accepted) 
		{
			QPainter painter;
			painter.begin(&printer);
			double xscale = printer.pageRect().width()/double(skewt->width());
			double yscale = printer.pageRect().height()/double(skewt->height());
			double scale = qMin(xscale, yscale);
			painter.translate(printer.paperRect().x() + printer.pageRect().width()/2,
								printer.paperRect().y() + printer.pageRect().height()/2);
			painter.scale(scale, scale);
			painter.translate(-skewt->width()/2, -skewt->height()/2);
			skewt->setPrinterRendering (true);
			skewt->render (&painter);
			skewt->setPrinterRendering (false);
		}
	}
	else if (send == acSaveImage) {
		QString filename = Util::getSetting("skewt_imageSaveFilename", "").toString();
		filename = Util::getSaveFileName (this,
					tr("Save JPEG image"),
					filename, 
					tr("Images (*.jpg *.jpeg)") );	
		if (filename != "") {
			if (   ! filename.endsWith(".jpg", Qt::CaseInsensitive) 
				&& ! filename.endsWith(".jpeg", Qt::CaseInsensitive) )
						filename += ".jpg";
			Util::setSetting("skewt_imageSaveFilename", filename);
			QImage image (skewt->size(), QImage::Format_RGB32);
			skewt->setPrinterRendering (true);
			skewt->render (&image);
			skewt->setPrinterRendering (false);
			image.save (filename, "JPEG", 96);
		}
	}
	else if (send == acExportData) {
		QString path = Util::getSetting("slkFilePath", "").toString();
		if (path == "")
			path = "./";
		else
			path += "/";
		QString fileName;
		
		fileName = Util::getSaveFileName (this,
						tr("Save SYLK file"), path, "*.slk");
		if (fileName != "")
		{
			if (! fileName.endsWith(".slk", Qt::CaseInsensitive))
				fileName += ".slk";
            SylkFile slk (fileName, "XyGrib");
			if (slk.isOk()) {
				Util::setSetting("slkFilePath", slk.getFileInfo().absolutePath() );
				saveFileSYLK (slk);
				slk.close ();
			}
			else {
				QMessageBox::critical (this,
						tr("Error"),  tr("Can't write file."));
			}
		}
	}
	unsetCursor ();
}
Beispiel #16
0
void SurfaceImpl::drawRect(const PRectangle &rc)
{
    painter->drawRect(
            QRectF(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top));
}
Beispiel #17
0
/** 
    coloridx: 0 - yellow, 1 - red, 2 - green, 3 - blue, if < 0 - only position without bounding box is drawn
 */
void draw_bbox(QPainter &painter, const PartBBox &part_bbox, int coloridx, int pen_width)
{    

  if (coloridx >= 0) {
    painter.setPen(Qt::yellow);
  
    int marker_radius = 3;
    int part_axis_length = 10;

    painter.drawEllipse(QRect((int)(part_bbox.part_pos(0) - marker_radius), (int)(part_bbox.part_pos(1) - marker_radius), 
			      2*marker_radius, 2*marker_radius));

    boost_math::double_vector v(2);
    v = part_bbox.part_pos + part_axis_length * part_bbox.part_x_axis;
    painter.drawLine((int)part_bbox.part_pos(0), (int)part_bbox.part_pos(1), (int)v(0), (int)v(1));

    painter.setPen(Qt::red);
    v = part_bbox.part_pos + part_axis_length * part_bbox.part_y_axis;
    painter.drawLine((int)part_bbox.part_pos(0), (int)part_bbox.part_pos(1), (int)v(0), (int)v(1));
    painter.setPen(Qt::yellow);

    QPen pen;

    if (coloridx == 0) 
      pen.setColor(Qt::yellow);
    else if (coloridx == 1)
      pen.setColor(Qt::red);
    else if (coloridx == 2)
      pen.setColor(Qt::green);
    else if (coloridx == 3)
      pen.setColor(Qt::blue);
    else
      pen.setColor(Qt::black);

    pen.setJoinStyle(Qt::RoundJoin);
    pen.setWidth(pen_width);

    painter.setPen(pen);

    QPolygonF polygon;
    get_part_polygon(part_bbox, polygon);
    painter.drawPolygon(polygon);
  }
  else {

    painter.setPen(Qt::yellow);

    if (coloridx == -1) 
      painter.setPen(Qt::yellow);
    else if (coloridx == -2)
      painter.setPen(Qt::red);
    else if (coloridx == -3)
      painter.setPen(Qt::green);
    else
      painter.setPen(Qt::blue);

    int x = part_bbox.part_pos(0);
    int y = part_bbox.part_pos(1);
    
    painter.drawLine(x-1, y, x+1, y);
    painter.drawLine(x, y-1, x, y+1);
  }

}
Beispiel #18
0
void ManoMeter::paintBackground(QPainter & painter)
{
	static const int scaleTriangle[6] = { -6,141,6,141,0,129 };
	initCoordinateSystem(painter);

        // Painting Malowanie obwiedni tarczy. Bia�a tarcza z czarn� skal�
        QPen Pen(QColor(0,0,0)); Pen.setWidth(4);
        painter.setPen(Pen);

        QRadialGradient back1(QPointF(0.0,0.0),180.0,QPointF(-35.0,145.0));
	back1.setColorAt(0.0,QColor(250,250,250));
	back1.setColorAt(1.0,QColor(20,20,20));

	QRadialGradient back2(QPointF(0.0,0.0),225.0,QPointF(76.5,135.0));
	back2.setColorAt(0.0,QColor(10,10,10));
	back2.setColorAt(1.0,QColor(250,250,250));

	painter.setBrush(QBrush(back1));
	painter.drawEllipse(-162,-162,324,324);
	painter.setPen(Qt::NoPen);
        painter.setBrush(QBrush(back2));
        painter.drawEllipse(-152,-152,304,304);

        QRadialGradient shield(QPointF(0,0),182,QPointF(-12.0,-15.0));
	shield.setColorAt(0.0,Qt::white);
	shield.setColorAt(0.5,QColor(240,240,240));
	shield.setColorAt(1.0,QColor(215,215,215));


	// internal scale circle 
	painter.setBrush(QBrush(shield));
	painter.setPen(Pen);
	painter.drawEllipse(-142,-142,284,284);

	  painter.setPen(Qt::NoPen);
          // nominal
	  painter.setBrush(QColor(0,200,0));
	  assert(m_max-m_min != 0);
	  int angle = static_cast<int>( (3840 * ( m_nominal - m_min ))/(m_max-m_min) );
	  if (m_min <= m_nominal && m_nominal < m_max )
           painter.drawPie(QRect(-141,-141,282,282),-480,3840 - angle % 5760 );
	  // Critical

	  painter.setBrush(QBrush(Qt::red));
	  angle = static_cast<int>( (3840 * ( m_critical - m_min ))/(m_max-m_min) );
	  if ( m_min <= m_critical && m_critical < m_max  )
	  painter.drawPie(QRect(-141,-141,282,282),-480, 3840 - angle % 5760  ); //-480, 3840*( m_max-m_min - critical()-abs(m_min) )/static_cast<double>(m_max-m_min));
	  // bia�a obwiednia
	  painter.setBrush(QBrush(shield));
	  painter.drawEllipse(-129,-129,258,258);

        // Ustawienie si� na pocz�tku skali

        painter.rotate(60.0);

 	// Rysowanie skali kreski
	painter.save();
        painter.setBrush(QBrush(Qt::black));
  	int line_length=10;
	for (int i=0;i<33;i++)
	{
	  painter.setPen(Pen);

          if (i % 4) painter.drawLine(0,140,0,140-line_length);
          else {
	    painter.setPen(Qt::NoPen);
	    painter.drawConvexPolygon(QPolygon(3, scaleTriangle));
	  }

	  painter.rotate(7.5);

	Pen.setWidth(3);

 	  if (i % 2)  line_length=10;
	  else        line_length=5;
	}
	painter.restore();

        // Rysowanie skali liczby .

	if (true || digitOffset())
        {
          painter.setPen(Qt::black);
          painter.rotate(-60.0);
	  painter.setFont(digitFont());
	  for (int i=0;i<9;i++)
	  {
	    double v = m_min + i*(m_max - m_min)/8.0;
	    if (fabs(v) < 0.000001 ) v = 0.0;
	    QString val = QString("%1").arg(v);
            QSize Size = painter.fontMetrics().size(Qt::TextSingleLine, val);
            painter.save();
	    painter.translate( digitOffset() * cos((5+i)*PI/6.0), digitOffset() * sin((5+i)*PI/6.0));
	    painter.drawText( QPointF( Size.width()/ -2.0,  Size.height() / 4.0), val);
            painter.restore();
	  }
	}



}// paintBackground
void ESRIShapefile::drawFeature(OGRFeature* ogr_feature, QPainter& painter, const Viewport& viewport) const
{
    // Fetch geometries.
    const auto ogr_geometry(ogr_feature->GetGeometryRef());
    if(ogr_geometry == nullptr)
    {
        // No geometry to fetch!
    }
    // Is it a polygon.
    else if(wkbFlatten(ogr_geometry->getGeometryType()) == wkbPolygon)
    {
        // Cast to a polygon.
        const auto ogr_polygon(static_cast<OGRPolygon*>(ogr_geometry));

        // Fetch the exterior ring.
        const auto ogr_exterior_ring(ogr_polygon->getExteriorRing());
        if(ogr_exterior_ring == nullptr)
        {
            // No exterior ring!
        }
        else
        {
            // Prepare storage for point.
            OGRPoint ogr_point;

            // Create a polygon of the points.
            QPolygonF polygon_px;

            // Loop through the points.
            for(int i = 0; i < ogr_exterior_ring->getNumPoints(); ++i)
            {
                // Fetch the point.
                ogr_exterior_ring->getPoint(i, &ogr_point);

                // Add the point to be drawn.
                polygon_px.append(projection::toPointWorldPx(viewport, util::PointWorldCoord(ogr_point.getX(), ogr_point.getY())));
            }

            // Set the pen to use.
            painter.setPen(penPolygon());

            // Set the brush to use.
            painter.setBrush(brushPolygon());

            // Draw the polygon line.
            painter.drawPolygon(polygon_px);
        }
    }
    else if(wkbFlatten(ogr_geometry->getGeometryType()) == wkbMultiPolygon)
    {
        // Cast to a multi polygon.
        const auto ogr_multi_polygon(static_cast<OGRMultiPolygon*>(ogr_geometry));
        if(ogr_multi_polygon == nullptr)
        {
            // No multi polygons!
        }
        else
        {
            // Loop through each polygon.
            for(int i = 0; i < ogr_multi_polygon->getNumGeometries(); ++i)
            {
                // Cast to a polygon.
                const auto ogr_polygon(static_cast<OGRPolygon*>(ogr_multi_polygon->getGeometryRef(i)));

                // Fetch the exterior ring.
                const auto ogr_exterior_ring(ogr_polygon->getExteriorRing());
                if(ogr_exterior_ring == nullptr)
                {
                    // No exterior ring!
                }
                else
                {
                    // Prepare storage for point.
                    OGRPoint ogr_point;

                    // Create a polygon of the points.
                    QPolygonF polygon_px;

                    // Loop through the points.
                    for(int i = 0; i < ogr_exterior_ring->getNumPoints(); ++i)
                    {
                        // Fetch the point.
                        ogr_exterior_ring->getPoint(i, &ogr_point);

                        // Add the point to be drawn.
                        polygon_px.append(projection::toPointWorldPx(viewport, util::PointWorldCoord(ogr_point.getX(), ogr_point.getY())));
                    }

                    // Set the pen to use.
                    painter.setPen(penPolygon());

                    // Set the brush to use.
                    painter.setBrush(brushPolygon());

                    // Draw the polygon line.
                    painter.drawPolygon(polygon_px);
                }
            }
        }
    }
    else if(wkbFlatten(ogr_geometry->getGeometryType()) == wkbLineString) // wkbLineString
    {
        // Cast to a line string.
        const auto ogr_line_string(static_cast<OGRLineString*>(ogr_geometry));

        // Prepare storage for point.
        OGRPoint ogr_point;

        // Create a polygon of the points.
        QPolygonF polygon_line_px;

        // Loop through the points.
        for(int i = 0; i < ogr_line_string->getNumPoints(); ++i)
        {
            // Fetch the point.
            ogr_line_string->getPoint(i, &ogr_point);

            // Add the point to be drawn.
            polygon_line_px.append(projection::toPointWorldPx(viewport, util::PointWorldCoord(ogr_point.getX(), ogr_point.getY())));
        }

        // Set the pen to use.
        painter.setPen(penLineString());

        // Draw the polygon line.
        painter.drawPolyline(polygon_line_px);
    }
}
void MaxFlowVisualizer::drawEdge(const Edge &edge, QPainter &painter) const {
    QPen pen;
    pen.setWidth(3);
    // Ребро, которое считается "допустимым" по алгоритму, выделяем черным.
    if (relabelToFrontAlgo.getVertexHeight(edge.getFirstVertexIndex())
        == relabelToFrontAlgo.getVertexHeight(edge.getSecondVertexIndex()) + 1) {
        pen.setColor(Qt::black);
    }
    else {
        pen.setColor(Qt::gray);
    }
    if (edge.getFlow() != 0) {
        pen.setColor(Qt::darkBlue);
    }
    // Если в последнем действии алгоритма произошло проталкивание по этому ребру,
    // то выделим его красным.
    if (lastAlgoAction.getType() == AlgoAction::ACTION_PUSH && lastAlgoAction.getEdgeInfo() == edge) {
        pen.setColor(Qt::red);
    }
    painter.setPen(pen);
    QPoint pointFrom(verteciesList[edge.getFirstVertexIndex()].getCenterCoordX(),
                     verteciesList[edge.getFirstVertexIndex()].getCenterCoordY());
    QPoint pointTo(verteciesList[edge.getSecondVertexIndex()].getCenterCoordX(),
                   verteciesList[edge.getSecondVertexIndex()].getCenterCoordY());
    double length = sqrt(pow(pointFrom.x() - pointTo.x(), 2)
                         + pow(pointFrom.y() - pointTo.y(), 2));
    long vertexRaduis = verteciesList[edge.getSecondVertexIndex()].getRadius();
    QPoint offsetVector((pointFrom.x() - pointTo.x()) * vertexRaduis / length,
                        (pointFrom.y() - pointTo.y()) * vertexRaduis / length);
    QPoint arrow((pointFrom.x() - pointTo.x()) * 20 / length,
                 (pointFrom.y() - pointTo.y()) * 20 / length);
    // Рисование стрелки (самих маленьких боковых линий).
    // Перенесем систему координат в точку конца ребра (ориенированного).
    // Возьмем маленький отрезок ребра, и нарисуем его, повернув при этом систуму координат
    // на +30 и -30 градусов соответственно относительно исходного ребра.
    // Получилась стрелка ->
    // После этого восстановим систему координат.
    painter.setPen(pen);
    painter.drawLine(pointFrom, pointTo);
    painter.translate(pointTo.x(), pointTo.y());
    // Еще нужно отступить от конца ребра на радиус вершины
    // (т.к. ребро идет от центра к центру).
    painter.translate(offsetVector.x(), offsetVector.y());
    painter.rotate(30);
    painter.drawLine(QPoint(0, 0), arrow);
    painter.rotate(-60);
    painter.drawLine(QPoint(0, 0), arrow);
    painter.resetTransform();
    // Выводим информацию о ребре (flow | capacity) по середине ребра.
    if (state == ALGORITHM_RUN || (state == ALGORITHM_TERM && edge.flow != 0)) {
        QPen penForEdgeInfo;
        penForEdgeInfo.setColor(Qt::darkGreen);
        painter.setPen(penForEdgeInfo);
        std::string edgeInfo = "(" + std::to_string(edge.getFlow()) + " | " + std::to_string(edge.getCapacity()) + ")";
        painter.drawText(pointFrom.x() + (pointTo.x() - pointFrom.x()) / 2,
                         pointFrom.y() + (pointTo.y() - pointFrom.y()) / 2,
                         edgeInfo.c_str());
    }
}
Beispiel #21
0
void PlastikButtonProvider::drawObject(QPainter &p, Object object, int x, int y, int length, int lineWidth)
{
    switch(object) {
        case DiagonalLine:
            if (lineWidth <= 1) {
                for (int i = 0; i < length; ++i) {
                    p.drawPoint(x+i,y+i);
                }
            } else if (lineWidth <= 2) {
                for (int i = 0; i < length; ++i) {
                    p.drawPoint(x+i,y+i);
                }
                for (int i = 0; i < (length-1); ++i) {
                    p.drawPoint(x+1+i,y+i);
                    p.drawPoint(x+i,y+1+i);
                }
            } else {
                for (int i = 1; i < (length-1); ++i) {
                    p.drawPoint(x+i,y+i);
                }
                for (int i = 0; i < (length-1); ++i) {
                    p.drawPoint(x+1+i,y+i);
                    p.drawPoint(x+i,y+1+i);
                }
                for (int i = 0; i < (length-2); ++i) {
                    p.drawPoint(x+2+i,y+i);
                    p.drawPoint(x+i,y+2+i);
                }
            }
            break;
        case CrossDiagonalLine:
            if (lineWidth <= 1) {
                for (int i = 0; i < length; ++i) {
                    p.drawPoint(x+i,y-i);
                }
            } else if (lineWidth <= 2) {
                for (int i = 0; i < length; ++i) {
                    p.drawPoint(x+i,y-i);
                }
                for (int i = 0; i < (length-1); ++i) {
                    p.drawPoint(x+1+i,y-i);
                    p.drawPoint(x+i,y-1-i);
                }
            } else {
                for (int i = 1; i < (length-1); ++i) {
                    p.drawPoint(x+i,y-i);
                }
                for (int i = 0; i < (length-1); ++i) {
                    p.drawPoint(x+1+i,y-i);
                    p.drawPoint(x+i,y-1-i);
                }
                for (int i = 0; i < (length-2); ++i) {
                    p.drawPoint(x+2+i,y-i);
                    p.drawPoint(x+i,y-2-i);
                }
            }
            break;
        case HorizontalLine:
            for (int i = 0; i < lineWidth; ++i) {
                p.drawLine(x,y+i, x+length-1, y+i);
            }
            break;
        case VerticalLine:
            for (int i = 0; i < lineWidth; ++i) {
                p.drawLine(x+i,y, x+i, y+length-1);
            }
            break;
        default:
            break;
    }
}
Beispiel #22
0
static void draw_arc(QPainter &painter, int x, int y, unsigned int diam)
{
	painter.drawArc(x - diam / 2, y - diam / 2,        /* x,y */
					diam, diam,        /* width, height */
					0, 360 * 64);      /* angle1, angle2 */
}
Beispiel #23
0
void UcClassCanvas::draw(QPainter & p) {
  if (! visible()) return;
  p.setRenderHint(QPainter::Antialiasing, true);
  QRect r = rect();
  QFontMetrics fm(the_canvas()->get_font(UmlNormalFont));
  QFontMetrics fim(the_canvas()->get_font(UmlNormalItalicFont));
  QColor bckgrnd = p.backgroundColor();
  double zoom = the_canvas()->zoom();
  FILE * fp = svg();

  if (fp != 0)
    fputs("<g>\n", fp);

  p.setBackgroundMode((used_color == UmlTransparent) ? ::Qt::TransparentMode : ::Qt::OpaqueMode);

  QColor co = color(used_color);
  
  if (used_view_mode == asClass) {
    if (used_color != UmlTransparent) {
      const int shadow = the_canvas()->shadow();

      if (shadow != 0) {
	r.setRight(r.right() - shadow);
	r.setBottom(r.bottom() - shadow);
	
	p.fillRect (r.right(), r.top() + shadow,
		    shadow, r.height() - 1,
		    ::Qt::darkGray);
	p.fillRect (r.left() + shadow, r.bottom(),
		    r.width() - 1, shadow,
		    ::Qt::darkGray);

	if (fp != 0) {
	  fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		  " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		  QColor(::Qt::darkGray).rgb()&0xffffff,
		  r.right(), r.top() + shadow, shadow - 1, r.height() - 1 - 1);

	  fprintf(fp, "\t<rect fill=\"#%06x\" stroke=\"none\" stroke-opacity=\"1\""
		  " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		  QColor(::Qt::darkGray).rgb()&0xffffff,
		  r.left() + shadow, r.bottom(), r.width() - 1 - 1, shadow - 1);
	}
      }
    }
    
    p.setBackgroundColor(co);
  
    if (used_color != UmlTransparent) {
      p.fillRect(r, co);

      if (fp != 0)
	fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		svg_color(used_color), 
		r.x(), r.y(), r.width() - 1, r.height() - 1);
    }
    else if (fp != 0)
      fprintf(fp, "\t<rect fill=\"none\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	      " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	      r.x(), r.y(), r.width() - 1, r.height() - 1);

    p.drawRect(r);
  }
  
  const ClassData * data = ((ClassData *) browser_node->get_data());
  const int two = (int) (2 * zoom);
  int he = fm.height() + two;
  
  if (data->get_n_formalparams() != 0)
    r.setTop(r.top() + fm.height());
  
  switch (used_view_mode) {
  case asInterface:
    draw_interface_icon(p, r, used_color, zoom);
    r.setTop(r.top() + (int) (INTERFACE_SIZE * zoom) + two);
    break;
  case asControl:
    draw_control_icon(p, r, used_color, zoom);
    r.setTop(r.top() + (int) (CONTROL_HEIGHT * zoom) + two);
    break;
  case asBoundary:
    draw_boundary_icon(p, r, used_color, zoom);
    r.setTop(r.top() + (int) (BOUNDARY_HEIGHT * zoom) + two);
    break;
  case asEntity:
    draw_entity_icon(p, r, used_color, zoom);
    r.setTop(r.top() + (int) (ENTITY_SIZE * zoom) + two);
    break;
  case asActor:
    {
      QRect ra = r;
      
      ra.setHeight((int) (ACTOR_SIZE * zoom));
      ra.setLeft(ra.left() + 
		 (int) ((ra.width() - ACTOR_SIZE * zoom)/2));
      ra.setWidth(ra.height());
      draw_actor(&p, ra);
    }
    r.setTop(r.top() + (int) (ACTOR_SIZE * zoom) + two);
    break;
  case Natural:
    {
      const QPixmap * px = 
	ProfiledStereotypes::diagramPixmap(data->get_stereotype(), zoom);
      int lft = (px->width() < width()) ? r.x() + (width() - px->width())/2 : r.x();

      p.drawPixmap(lft, r.y(), *px);
      if (fp != 0)
	// pixmap not really exported in SVG
	fprintf(fp, "\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
		" x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
		svg_color(UmlBlack), lft, r.y(), px->width() - 1, px->height() - 1);

      r.setTop(r.top() + px->height());
    }
    break;
  default:	// class
    r.setTop(r.top() + two);
    if (data->get_stereotype()[0]) {
      p.setFont(the_canvas()->get_font(UmlNormalFont));
      p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop, 
		 QString("<<") + toUnicode(data->get_short_stereotype()) + ">>");
      if (fp != 0)
	draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop, 
		  QString("<<") + toUnicode(data->get_short_stereotype()) + ">>",
		  p.font(), fp);
      r.setTop(r.top() + he + two);
    }
  }
  
  p.setBackgroundMode(::Qt::TransparentMode);
  p.setFont((data->get_is_abstract())
	    ? the_canvas()->get_font(UmlNormalItalicFont)
	    : the_canvas()->get_font(UmlNormalFont));
  p.drawText(r, ::Qt::AlignHCenter + ::Qt::AlignTop, full_name);
  if (fp != 0)
    draw_text(r, ::Qt::AlignHCenter + ::Qt::AlignTop, full_name, p.font(), fp);

  p.setFont(the_canvas()->get_font(UmlNormalFont));
  
  if (used_view_mode == asClass) {
    r.setTop(r.top() + he);
    p.drawLine(r.topLeft(), r.topRight());
    
    if (fp != 0)
      fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
	      " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
	      r.left(), r.top(), r.right(), r.top());
    
    r.setTop(r.top() + (int) (8 * zoom));
    p.drawLine(r.topLeft(), r.topRight());
    
    if (fp != 0)
      fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
	      " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
	      r.left(), r.top(), r.right(), r.top());
  }
  
  if (fp != 0)
    fputs("</g>\n", fp);
    
  p.setBackgroundColor(bckgrnd);
  
  if (selected())
    show_mark(p, rect());
}
Beispiel #24
0
void TSController::printReport()
{
    QPrinter printer;
    QPrintDialog *dialog = new QPrintDialog(&printer, this);
    dialog->setWindowTitle(tr("Предварительный просмотр"));

    int endIndex=curveBuffer->lenght;

    float listh=printer.widthMM()*printer.resolution()/25.4-60;
    float listw=printer.heightMM()*printer.resolution()/25.4-60;
    printer.setPageMargins(5,5,5,5,QPrinter::Millimeter);
    printer.setOrientation(QPrinter::Landscape);
    printer.setResolution(QPrinter::HighResolution);
    printer.setPaperSize(QPrinter::A4);
    Ui::Form pf;

    pf.setupUi(&wpf);
    pf.mainBox->setMaximumSize((int)listw,(int)listh);
    pf.mainBox->setMinimumSize((int)listw,(int)listh);
    pf.resultsTable->setMinimumWidth(40+(int)listw/3);
    pf.resultsTable->setRowCount(13);
    pf.resultsTable->setColumnCount(2);
    pf.resultsTable->verticalHeader()->setVisible(false);
    pf.resultsTable->setHorizontalHeaderLabels(QString(tr("Параметр; Значение")).split(";"));
    pf.resultsTable->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
    int i=0,j=0;
    for(i=0;i<ui->resultsTable->rowCount();i++){
        for(j=0;j<2;j++){
            pf.resultsTable->setItem(i,j,getQTableWidgetItem(ui->resultsTable->item(i,j)->text()));
        }
    }
    int myH=0,myW=0;
    wpf.resize(pf.mainBox->size());
    wpf.show();

    myH = pf.gVolume->height();
    myW = pf.gVolume->width();

    QPixmap pmTempIn(myW,myH);
    QPixmap pmTempOut(myW,myH);
    QPixmap pmVolume(myW,myH);

    QPainter prTempIn;
    QPainter prTempOut;
    QPainter prVolume;
    prTempIn.begin(&pmTempIn);
    prTempOut.begin(&pmTempOut);
    prVolume.begin(&pmVolume);

    int h = pf.gVolume->height()/2;
    int step = h/10;
    if(h%10>=5)
    {
        h+=step/2;
    }
    prVolume.fillRect(0,0,myW,myH,Qt::white);
    prTempIn.fillRect(0,0,myW,myH,Qt::white);
    prTempOut.fillRect(0,0,myW,myH,Qt::white);

    prVolume.setPen(QColor(225,225,225));
    prTempIn.setPen(QColor(225,225,225));
    prTempOut.setPen(QColor(225,225,225));
    for(i=step;i<h;i+=step)
    {
        prVolume.drawLine(0,h+i,myW,h+i);
        prTempIn.drawLine(0,h+i,myW,h+i);
        prTempOut.drawLine(0,h+i,myW,h+i);
        prVolume.drawLine(0,h-i,myW,h-i);
        prTempIn.drawLine(0,h-i,myW,h-i);
        prTempOut.drawLine(0,h-i,myW,h-i);
    }
    for(i=10;i<myW;i+=10)
    {
        prVolume.drawLine(i,0,i,h<<1);
        prTempIn.drawLine(i,0,i,h<<1);
        prTempOut.drawLine(i,0,i,h<<1);
    }
    prVolume.setPen(QColor(0,0,0));
    prTempIn.setPen(QColor(0,0,0));
    prTempOut.setPen(curveBuffer->toutColor);
    prVolume.setPen(QColor(255,0,0));
    int* tinInt = curveBuffer->getTempInInterval();
    int* toutInt = curveBuffer->getTempOutInterval();
    int* volInt = curveBuffer->getVolumeInterval();
    float tempInK = 1;
    float tempOutK = 1;
    float tempInZ = h;
    float tempOutZ = h;
    tempInAdaptive = (float)myH/(tinInt[1]-tinInt[0]);
    tempOutAdaptive = (float)myH/(toutInt[1]-toutInt[0]);
    volumeAdaptive = (float)myH/(volInt[1]-volInt[0]);
    tempInZ = h + ceil((float)(tinInt[1]+tinInt[0])*tempInAdaptive*tempInK/2);
    tempOutZ = h + ceil((float)(toutInt[1]+toutInt[0])*tempOutAdaptive*tempOutK/2);
    float volumeK =1;

    i=0;
    int k=ceil((float)curveBuffer->lenght/pf.gTempIn->width());
    for(j=0;j<myW-35;j+=1)
    {
        if(i>=k*endIndex)break;
        prVolume.drawLine(
                    j,h-volumeK*volumeAdaptive*volume[i],j+1,h-volumeK*volumeAdaptive*volume[i+k]
                    );
        prTempIn.drawLine(j,tempInZ-tempInK*tempInAdaptive*tempIn[i]
                          ,j+1,tempInZ-tempInK*tempInAdaptive*tempIn[i+k]);
        prTempOut.drawLine(j,tempOutZ-tempOutK*tempOutAdaptive*tempOut[i]
                           ,j+1,tempOutZ-tempOutK*tempOutAdaptive*tempOut[i+k]);
        i+=k;
    }
    pf.gVolume->setPixmap(pmVolume);
    pf.gTempIn->setPixmap(pmTempIn);
    pf.gTempOut->setPixmap(pmTempOut);
    pf.PatientName->setText(patientsModel->record(0).value("sname").toString()+" "+patientsModel->record(0).value("fname").toString());

    wpf.hide();
    if (dialog->exec() == QDialog::Accepted){
        QPainter painter;
        painter.begin(&printer);
        int i=0;
        pf.mainBox->render(&painter);
    }
}
void AnimationViewerPanel::renderCross(QPainter& painter)
{
    painter.setPen(QColor(120, 150, 200));
    painter.drawLine(QPoint(0, height() / 2), QPoint(width(), height() / 2));
    painter.drawLine(QPoint(width() / 2, 0), QPoint(width() / 2, height()));
}
Beispiel #26
0
void SdSelfMsgCanvas::draw(QPainter & p) {
  const QRect r = rect();
  int ah = (r.height() - 1 - 1 - 2 - 1 - 1)/2;
  int he = r.top() + 1 + 2 + ah + 1;
  FILE * fp = svg();
  p.setRenderHint(QPainter::Antialiasing, true);
  if (itsType == UmlSelfReturnMsg)
    p.setPen(::Qt::DotLine);
  
  p.drawLine(r.left() + 1, r.top() + 1, r.right() - 1, r.top() + 1);



  //p.lineTo(r.right() - 1, he);
  p.drawLine(r.right()-1, r.top() + 1, r.right() - 1, he);
  //p.lineTo(r.left() + 1, he);
  p.drawLine(r.right()-1, he, r.left() + 1, he);

  if (fp != 0) {
    fputs("<g>\n\t<path fill=\"none\" stroke=\"black\" stroke-opacity=\"1\"", fp);
    if (itsType == UmlSelfReturnMsg)
      fputs(" stroke-dasharray=\"4,4\"", fp);
    fprintf(fp, " d=\"M %d %d L %d %d L %d %d L %d %d\" />\n",
	    r.left() + 1, r.top() + 1, r.right() - 1, r.top() + 1,
	    r.right() - 1, he,
	    r.left() + 1, he);
  }
  
  if (itsType == UmlSyncSelfMsg) {
    Q3PointArray poly(3);
    QBrush brsh = p.brush();
    
    p.setBrush(Qt::black);
    poly.setPoint(0, r.left() + 1, he);
    poly.setPoint(1, r.left() + 1 + ah, he + ah);
    poly.setPoint(2, r.left() + 1 + ah, he - ah);
    p.drawPolygon(poly/*, TRUE*/);
    p.setBrush(brsh);

    if (fp != 0) {
      draw_poly(fp, poly, UmlBlack, FALSE);
      fputs("</g>\n", fp);
    }
  }
  else {
    if (itsType == UmlSelfReturnMsg)
      p.setPen(::Qt::SolidLine);
    
    //p.lineTo(r.left() + 1 + ah, he + ah);
	p.drawLine(r.left()+1+ah, he - ah, r.left() + 1 + ah, he + ah); // assuming last call poly.setPoint
    p.drawLine(r.left() + 1, he, r.left() + 1 + ah, he - ah);

    if (fp != 0)
      fprintf(fp, "\t<path fill=\"none\" stroke=\"black\" stroke-opacity=\"1\""
	      " d=\"M %d %d L %d %d L %d %d\" />\n"
	      "</g>\n",
	      r.left() + 1 + ah, he + ah,
	      r.left() + 1, he,
	      r.left() + 1 + ah, he - ah);
  }
  
  if (selected())
    show_mark(p, r);
}
Beispiel #27
0
void Node::initPainter(QPainter &p) {
	p.translate(int(x()), int(y()));
	p.rotate(m_dir);
}
Beispiel #28
0
void ZoomWidget::doPainting(QPainter& painter)
{
    //paint the screenshot
    if(!m_pixmap.isNull()) {
        QPixmap scaled = m_pixmap.copy(QRect(QPoint(0, 0), size() / m_zoomFactor));
        scaled = scaled.scaled(scaled.size()*m_zoomFactor);
        painter.drawPixmap(rulerWidth, rulerWidth, scaled);
    }

    //mark active pixels
    QPen pen;
    pen.setStyle(Qt::SolidLine);
    pen.setColor(QColor(255, 0, 0, 100));
    painter.setPen(pen);
    QBrush brush(QColor(255, 0, 0, 100));

    if(m_markColor.isValid())
    {
        QImage image = m_pixmap.toImage();
        for(int x=0;x<m_pixmap.size().width();x++) {
            for(int y=0;y<m_pixmap.size().height();y++) {
                if(image.pixel(x, y)==m_markColor.rgb()) {
                    //painter.drawRect(rulerWidth+x*m_zoomFactor, rulerWidth+y*m_zoomFactor, m_zoomFactor, m_zoomFactor);
                    painter.fillRect(QRect(rulerWidth+x*m_zoomFactor, rulerWidth+y*m_zoomFactor, m_zoomFactor, m_zoomFactor), brush);
                }
            }
        }
    }
    
    //draw grid
    if(m_gridColor.isValid())
    {
        pen.setStyle(Qt::SolidLine);
        
        QColor gridPenColor(m_gridColor);
        gridPenColor.setAlpha(200);
        pen.setColor(gridPenColor);
        painter.setPen(pen); 
        static const int gridSize=10;
        for(int x=rulerWidth;x<width();x+=gridSize*m_zoomFactor) {
            painter.drawLine(x, rulerWidth, x, height()-rulerWidth);
        }
        for(int y=rulerWidth;y<height();y+=gridSize*m_zoomFactor) {
            painter.drawLine(rulerWidth, y, width()-rulerWidth, y);
        }
    }

    pen.setStyle(Qt::SolidLine);
    pen.setColor(QColor(0, 0, 0));
    painter.setPen(pen);
    
    //draw the rulers:
    painter.fillRect (0, 0, width(), rulerWidth, QBrush(QColor(255, 255, 255)));
    painter.fillRect (0, 0, rulerWidth, height(), QBrush(QColor(255, 255, 255)));

    //draw the ruler ticks
    QFont font;
    font.setPointSize(6);
    painter.setFont(font);
    for(int i=0;i<(width()-rulerWidth)/(20);i++) {
        int x = i*20 + rulerWidth;
        if(i%2==0) {
            painter.drawLine(x, rulerWidth-8, x, rulerWidth);
            painter.drawText(QRect(x-9, 2, 18, 10), Qt::AlignCenter, QString("%1").arg(i*20/m_zoomFactor));
        } else {
            painter.drawLine(x, rulerWidth-5, x, rulerWidth);
        }
    }
    for(int i=0;i<(height()-rulerWidth)/(20);i++) {
        int y = i*20 + rulerWidth;
        if(i%2==0) {
            painter.drawLine(rulerWidth-8, y, rulerWidth, y);
            painter.drawText(QRect(2, y-9, 10, 18), Qt::AlignCenter, QString("%1").arg(i*20/m_zoomFactor));
        } else {
            painter.drawLine(rulerWidth-5, y, rulerWidth, y);
        }
    }
    
    //draw the lines
    QList<int> posX;
    QList<int> posY;
    for(int i=0;i<lines.count();i++)
    {
        if(hasCurrentLine && i==currentLine) {
            QPen pen;
            pen.setStyle(Qt::DashLine);
            pen.setColor(QColor(255, 0, 0));
            painter.setPen(pen);
        } else {
            QPen pen;
            pen.setStyle(Qt::SolidLine);
            pen.setColor(QColor(0, 0, 255));
            painter.setPen(pen);
        }
        Line* line = lines.at(i);
        if(line->orientation == Qt::Horizontal) {
            painter.drawLine(line->position*m_zoomFactor + rulerWidth, rulerWidth, line->position*m_zoomFactor + rulerWidth, height());
            posX << line->position;
        } else if (line->orientation == Qt::Vertical) {
            painter.drawLine(rulerWidth, line->position*m_zoomFactor + rulerWidth, width(), line->position*m_zoomFactor + rulerWidth);
            posY << line->position;
        }
    }
    //on the edgre make 30px lighter
    painter.fillRect(rulerWidth, height()-30, width(), 30, QBrush(QColor(255, 255, 255, 200)));
    painter.fillRect(width()-30, rulerWidth, 30, height()-rulerWidth-30, QBrush(QColor(255, 255, 255, 200)));
    
    //array for the pointer <--->
    static const QPoint arrowPoints[3] = {
        QPoint(0, 0),
        QPoint(8, 4),
        QPoint(0, 8)
    };

    //measure the number of px between the lines (x)
    qSort(posX);
    font.setPointSize(8);
    painter.setFont(font);
    painter.setPen(QColor(0, 0, 0));
    int last = 0;
    foreach(int x, posX)
    {
        painter.drawLine(last*m_zoomFactor + rulerWidth, height()-10, x*m_zoomFactor + rulerWidth, height()-10);
        painter.drawText(QRect(last*m_zoomFactor + rulerWidth, height()-30, (x-last)*m_zoomFactor, 20),
                Qt::AlignCenter | Qt::AlignBottom, QString("%1").arg(x-last));

        bool arrowOnOutside = false;
        if((x-last)*m_zoomFactor < 40) {
            qSwap(x, last);
            arrowOnOutside = true;
        }

        painter.save();
        //arrow right
        painter.setBrush(QBrush(QColor(0, 0, 0)));
        painter.translate(x*m_zoomFactor + rulerWidth-8, height()-10 -4);
        painter.drawPolygon(arrowPoints, 3, Qt::WindingFill);
        
        //arrow left
        painter.translate((last-x)*m_zoomFactor+16, 8);
        painter.rotate(180);
        painter.drawPolygon(arrowPoints, 3);
        painter.restore();

        if(!arrowOnOutside) //else qSwaped allready
            last = x;
    }
Beispiel #29
0
void GUIView::initialize() {
    setFixedSize(840, 700);
    setWindowTitle("GUIView");

    srcRect.setRect(0,0,640,480);
    frontCameraRect.setRect(0,0,320,240);
    downCameraRect.setRect(320,0,320,240);

    //frontCameraImage = QImage(":/img/MDA.jpg");

    //Creating an image that holds a gradient of blue

    //Create an image to be painted on
    QImage sub(640,480,QImage::Format_RGB32);

    //Setup the painter to paint/draw on the image
    QPainter subImgPainter;
    subImgPainter.begin(&sub); //Paint on that image

    //Create the gradient
    QLinearGradient blueGradient(0,0,640,480);

    //Set the starting color and end colors
    blueGradient.setColorAt(0.0,QColor(62,58,200));// 0.0 is start position as a qreal
    blueGradient.setColorAt(1.0,QColor(175,80,255)); //1.0 is end position as a qreal

    //Create a brush from the gradient (to paint with)
    QBrush blueGradientBrush(blueGradient);

    //Use the brush
    //subImgPainter.fillRect(sub.rect(), blueGradientBrush);
    //subImgPainter.end();

    downCameraImage = sub;

    // Show Case View Widget initialization
    powerStatus = new QLabel("Power: Off");
    powerButton = new QPushButton("Turn Power On/Off");
    powerButton->setCheckable(true);
    motorButton = new QPushButton("Turn Motors On");

    movement = new QLabel("Movement");
    leftButton = new QPushButton("Veer Left");
    rightButton = new QPushButton("Veer right");

    forwardButton = new QPushButton("Move Forward");
    backwardButton = new QPushButton("Move Backward");
    sinkButton = new QPushButton("Sink");
    riseButton = new QPushButton("Rise");
    stopButton = new QPushButton("Stop");

    specialActions = new QLabel("Special Actions");
    surfaceButton = new QPushButton("Surface");
    gateButton = new QPushButton("Gate Task");
    pathButton = new QPushButton("Path Task");

    systemActions = new QLabel("System Actions");
    menuButton = new QPushButton("Menu");
    exitButton = new QPushButton("Exit");

    depthReading = new QLabel("Depth:");
    yawReading = new QLabel("Yaw:");

    targetDepthLabel = new QLabel("Target:");
    targetYawLabel = new QLabel("Target:");

    // Show Case View layouts
    QVBoxLayout *verticalLayout = new QVBoxLayout();
    QHBoxLayout *mainLayout = new QHBoxLayout(this);
    QGridLayout *readingsLayout = new QGridLayout();

    //Show Case view Widget Positioning
    //Down want to add rects from view to layout
    //What to do? : set other BoxLayouts and add spacing?

    verticalLayout->addWidget(powerStatus);
    verticalLayout->addWidget(powerButton);
    verticalLayout->addWidget(motorButton);
    verticalLayout->addSpacing(10);

    verticalLayout->addWidget(movement);
    verticalLayout->addWidget(leftButton);
    verticalLayout->addWidget(rightButton);
    verticalLayout->addWidget(sinkButton);
    verticalLayout->addWidget(riseButton);
    verticalLayout->addWidget(forwardButton);
    verticalLayout->addWidget(backwardButton);
    verticalLayout->addWidget(stopButton);
    verticalLayout->addSpacing(10); //Spacing size of 20 pixels

    verticalLayout->addWidget(specialActions);
    verticalLayout->addWidget(surfaceButton);
    verticalLayout->addWidget(gateButton);
    verticalLayout->addWidget(pathButton);
    verticalLayout->addSpacing(10); //Spacing size of 20 pixels

    verticalLayout->addWidget(systemActions);
    verticalLayout->addWidget(menuButton);
    verticalLayout->addWidget(exitButton);
    verticalLayout->addSpacing(10);

    readingsLayout->addWidget(yawReading, 0, 0, Qt::AlignLeft);
    readingsLayout->addWidget(targetYawLabel, 0, 1, Qt::AlignLeft);
    readingsLayout->addWidget(depthReading, 1, 0, Qt::AlignLeft);
    readingsLayout->addWidget(targetDepthLabel, 1, 1, Qt::AlignLeft);
    verticalLayout->addLayout(readingsLayout);


    mainLayout->addSpacing(1280);
    mainLayout->addLayout(verticalLayout);
    this->setLayout(mainLayout);

    // Setup connections
    connect(powerButton, SIGNAL(clicked()), controller, SLOT(handlePowerButtonToggled()));
    connect(motorButton, SIGNAL(clicked()), controller, SLOT(handleMotorButtonClick()));
    connect(leftButton, SIGNAL(clicked()), controller, SLOT(handleMoveLeftButtonClick()));
    connect(rightButton, SIGNAL(clicked()), controller, SLOT(handleMoveRightButtonClick()));
    connect(sinkButton, SIGNAL(clicked()), controller, SLOT(handleSinkButtonClick()));
    connect(riseButton, SIGNAL(clicked()), controller, SLOT(handleRiseButtonClick()));
    connect(forwardButton, SIGNAL(clicked()), controller, SLOT(handleMoveForwardButtonClick()));
    connect(backwardButton, SIGNAL(clicked()), controller, SLOT(handleMoveBackwardButtonClick()));
    connect(stopButton, SIGNAL(clicked()), controller, SLOT(handleStopButtonClick()));
    connect(gateButton, SIGNAL(clicked()), controller, SLOT(handleGateTaskClick()));
    connect(pathButton, SIGNAL(clicked()), controller, SLOT(handlePathTaskClick()));
    connect(menuButton, SIGNAL(clicked()), stage, SLOT(switchToMenuView()));
    connect(exitButton, SIGNAL(clicked()), stage, SLOT(exit()));
}
Beispiel #30
0
void paintTree_one::paintNext()
{
    vector<Node> nTemp;
    nTemp=this->m_tree->tree;
    int space_x, space_y;
    int lowCount=0;//树中出现终结符的个数,方便计算空间间隔宽度
    int upCount=0;//树中出现终结符的个数,方便计算空间间隔高度
    for(int j=nTemp.size()-1;j>=0;j--)
    {
        if(nTemp[j].y==0)
        {
            lowCount=nTemp[j].x+1;//x坐标从0开始的,所以要加一
            break;
        }
        else
        {
            lowCount=0;
            continue;
        }

    }
    for(int j=nTemp.size()-1;j>=0;j--)
    {
        char temp=nTemp[j].key;
        if(temp=='A' || temp=='B'  || temp=='S' )
        {
            upCount=nTemp[j].y+1; //y坐标从0开始的,所以要加一
            break;
        }
        else
        {
            upCount=0;
            continue;
        }
    }
//    int space_x=iWidth/(lowCount+1);//横向间隔
//    int space_y=iHeight/(upCount+1);//纵向间隔
    space_x=iWidth/(lowCount+1);//横向间隔
    if(upCount==0)
        space_y=iHeight/3;
    else
          space_y=iHeight/(upCount+1);//纵向间隔
    QString fileName;
    QPainter painter;
    //QPen pen;
    //pen.setWidth(2);//设置线的宽度为2个像素
    int currentX;
    int currentY;
    int x,y,nY;
    if(iCount<nTemp.size()&&iCount>=0)
    {
        for(int i=0;i<=iCount;i++)
        {
            painter.begin(this);
            //painter.setPen(pen);
            fileName=charToName(nTemp[i].key);
            currentX=space_x*(nTemp[i].x+1);
            currentY=iHeight-space_y*(nTemp[i].y+1);
            QPixmap picture;
            picture.load(fileName);
            //        painter.drawPixmap(currentX,currentY,picture);
            if(nTemp[i].key=='A')//画A->Ab或A->b的直线
            {
                if(nTemp[i].y>1)
                {
                    painter.drawPixmap(currentX,currentY,picture);
                    painter.drawLine(space_x*(nTemp[i-2].x+1)+16,iHeight-space_y*(nTemp[i-2].y+1)+16,currentX+16,currentY+16);
                    painter.drawLine(space_x*(nTemp[i-1].x+1)+16,iHeight-space_y*(nTemp[i-1].y+1)+16,currentX+16,currentY+16);
                    painter.end();
                }
                else
                {
                    painter.drawPixmap(currentX,currentY,picture);
                    painter.drawLine(currentX+16,currentY+space_y*nTemp[i].y+16,currentX+16,currentY+16);
                    painter.end();
                }
            }
            else if(nTemp[i].key=='B')//画B->d的直线
            {
                findXY('A',x,y);
                nY=y;
                painter.drawPixmap(currentX,iHeight-space_y*(nY+1),picture);
                painter.drawLine(currentX+16,currentY+space_y*nTemp[i].y+16,currentX+16,iHeight-space_y*(nY+1)+16);
                painter.end();
            }
            else if(nTemp[i].key=='S')//画S->aAcBe的所有直线
            {
                painter.drawPixmap(currentX,currentY,picture);
                findXY('A',x,y);
                nY=y;
                findXY('a',x,y);
                painter.drawLine(space_x*(x+1)+16,iHeight-space_y*(nY+1)+16,currentX+16,currentY+16);
                painter.drawLine(space_x*(x+1)+16,iHeight-space_y*(nY+1)+16,space_x*(x+1)+16,iHeight-space_y*(y+1)+16);
                findXY('A',x,y);
                painter.drawLine(space_x*(x+1)+16,iHeight-space_y*(y+1)+16,currentX+16,currentY+16);
                findXY('c',x,y);
                painter.drawLine(space_x*(x+1)+16,iHeight-space_y*(y+1)+16,currentX+16,currentY+16);
                findXY('B',x,y);
                painter.drawLine(space_x*(x+1)+16,iHeight-space_y*(nY+1)+16,currentX+16,currentY+16);
                findXY('e',x,y);
                painter.drawLine(space_x*(x+1)+16,iHeight-space_y*(nY+1)+16,currentX+16,currentY+16);
                painter.drawLine(space_x*(x+1)+16,iHeight-space_y*(nY+1)+16,space_x*(x+1)+16,iHeight-space_y*(y+1)+16);
                painter.end();
            }
            else
            {
                painter.drawPixmap(currentX,currentY,picture);
                painter.end();
            }
        }
    }
    else if(iCount>=0)
    {
        painter.begin(this);
        for(int i=0;i<=nTemp.size();i++)
        {
            fileName=charToName(nTemp[i].key);
            currentX=space_x*(nTemp[i].x+1);
            currentY=iHeight-space_y*(nTemp[i].y+1);
            QPixmap picture;
            picture.load(fileName);
            //        painter.drawPixmap(currentX,currentY,picture);
            if(nTemp[i].key=='A')//画A->Ab或A->b的直线
            {
                if(nTemp[i].y>1)
                {
                    painter.drawPixmap(currentX,currentY,picture);
                    painter.drawLine(space_x*(nTemp[i-2].x+1)+16,iHeight-space_y*(nTemp[i-2].y+1)+16,currentX+16,currentY+16);
                    painter.drawLine(space_x*(nTemp[i-1].x+1)+16,iHeight-space_y*(nTemp[i-1].y+1)+16,currentX+16,currentY+16);
                }
                else
                {
                    painter.drawPixmap(currentX,currentY,picture);
                    painter.drawLine(currentX+16,currentY+space_y*nTemp[i].y+16,currentX+16,currentY+16);
                }
            }
            else if(nTemp[i].key=='B')//画B->d的直线
            {
                findXY('A',x,y);
                nY=y;
                painter.drawPixmap(currentX,iHeight-space_y*(nY+1),picture);
                painter.drawLine(currentX+16,currentY+space_y*nTemp[i].y+16,currentX+16,iHeight-space_y*(nY+1)+16);
            }
            else if(nTemp[i].key=='S')//画S->aAcBe的所有直线
            {
                painter.drawPixmap(currentX,currentY,picture);
                findXY('A',x,y);
                nY=y;
                findXY('a',x,y);
                painter.drawLine(space_x*(x+1)+16,iHeight-space_y*(nY+1)+16,currentX+16,currentY+16);
                painter.drawLine(space_x*(x+1)+16,iHeight-space_y*(nY+1)+16,space_x*(x+1)+16,iHeight-space_y*(y+1)+16);
                findXY('A',x,y);
                painter.drawLine(space_x*(x+1)+16,iHeight-space_y*(y+1)+16,currentX+16,currentY+16);
                findXY('c',x,y);
                painter.drawLine(space_x*(x+1)+16,iHeight-space_y*(y+1)+16,currentX+16,currentY+16);
                findXY('B',x,y);
                painter.drawLine(space_x*(x+1)+16,iHeight-space_y*(nY+1)+16,currentX+16,currentY+16);
                findXY('e',x,y);
                painter.drawLine(space_x*(x+1)+16,iHeight-space_y*(nY+1)+16,currentX+16,currentY+16);
                painter.drawLine(space_x*(x+1)+16,iHeight-space_y*(nY+1)+16,space_x*(x+1)+16,iHeight-space_y*(y+1)+16);
            }
            else
                painter.drawPixmap(currentX,currentY,picture);
        }
        painter.end();
    }
}