Example #1
0
void StelDialogLogBook::setVisible(bool v)
{
    if (v)
    {
        QSize screenSize = StelMainWindow::getInstance().size();
        if (dialog)
        {
            dialog->show();
            StelMainView::getInstance().scene()->setActiveWindow(proxy);
            // If the main window has been resized, it is possible the dialog
            // will be off screen.  Check for this and move it to a visible
            // position if necessary
            QPointF newPos = proxy->pos();
            if (newPos.x()>=screenSize.width())
                newPos.setX(screenSize.width() - dialog->size().width());
            if (newPos.y()>=screenSize.height())
                newPos.setY(screenSize.height() - dialog->size().height());
            if (newPos != dialog->pos())
                proxy->setPos(newPos);

            proxy->setFocus();
            return;
        }
        dialog = new QDialog(NULL);
        connect(dialog, SIGNAL(rejected()), this, SLOT(close()));
        createDialogContent();

        proxy = new CustomProxy(NULL, Qt::Tool);
        proxy->setWidget(dialog);
        QRectF bound = proxy->boundingRect();

        // centre with dialog according to current window size.
        proxy->setPos((int)((screenSize.width()-bound.width())/2), (int)((screenSize.height()-bound.height())/2));
        StelMainView::getInstance().scene()->addItem(proxy);
        proxy->setWindowFrameMargins(2,0,2,2);

        // The caching is buggy on all plateforms with Qt 4.5.2

#if QT_VERSION==0x040502
        proxy->setCacheMode(QGraphicsItem::NoCache);
#else
        proxy->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
#endif

        proxy->setZValue(100);
        StelMainView::getInstance().scene()->setActiveWindow(proxy);
        proxy->setFocus();
    }
    else
    {
        dialog->hide();
        emit visibleChanged(false);
        //proxy->clearFocus();
        StelMainView::getInstance().scene()->setActiveWindow(0);
    }
}
Example #2
0
/**
 * Calcul le point sur la fleche le plus près du point donné en parametre
 * @brief Fleche::PointLePlusPres
 * @param Position  La osition à analyser
 * @return  La position sur la fleche la plus proche
 */
QPointF Fleche::PointLePlusPres(QPointF Position)
{
    //Calcul de la projection orthogonale de la position de la souris sur les segments verticaux de la flèche.
    QPointF Retour ;
    QPointF Projection ;
    qreal   Distance    (0);
    qreal   DistanceMini(INFINITY) ;
    QLineF  LigneBase ;
    QLineF  LigneSourisProj ;

    LigneSourisProj.setPoints(Position, Projection);

    //Pour tout les segments
    for(register int i = 0; i < this->ListePoints.length() -1; i++)
    {
        LigneBase.setPoints(this->ListePoints[i], this->ListePoints[i+1]);

        //S'il sont verticaux
        if(LigneBase.dx() == 0)
        {
            //On calcul les coordonnées du point
            Projection.setX(this->ListePoints[i].x());
            Projection.setY(Position.y());

            //Si le point sort du segment
            if(Projection.y() < this->ListePoints[i].y() || Projection.y() > this->ListePoints[i+1].y())
            {
                QLineF  LigneSourisP1 ;
                QLineF  LigneSourisP2 ;

                LigneSourisP1.setPoints(Position, this->ListePoints[i]);
                LigneSourisP2.setPoints(Position, this->ListePoints[i+1]);

                //On le recale sur l'extrémité la plus proche
                if(LigneSourisP1.length() < LigneSourisP2.length())
                {
                    Projection = this->ListePoints[i] ;
                }
                else
                {
                    Projection = this->ListePoints[i+1] ;
                }
            }

            //On renvois le point le plus proche de la souris
            Distance = LigneSourisProj.length() ;
            if(Distance < DistanceMini)
            {
                Retour          = Projection ;
                DistanceMini    = Distance ;
            }
        }
    }

    return Retour;
}
QVariant PdfFrameHandle::itemChange (GraphicsItemChange change,
                                     const QVariant &value)
{
  QVariant valueFiltered = value;

  if (change == ItemPositionChange && scene()) {

    QPointF sizeAsPointF (boundingRect().size().width(),
                          boundingRect().size().height());

    // New position is in the value argument
    QPointF newPos = valueFiltered.toPointF();
    QPointF oldPos = pos ();

    // This sequence is from http://www.qtcentre.org/threads/47248-How-to-efficiently-get-position-of-a-QGraphicsItem-in-view-coordinates
    QRectF newRectItem (newPos,
                        QSize (boundingRect().size().width(),
                               boundingRect().size().height()));
    QPolygonF newRectScene = mapToScene (newRectItem);
    QPolygon newRectView = m_view.mapFromScene (newRectScene.boundingRect());

    // Skip moving of this handle if it will go outside of the window
    QRectF rectWindow = m_scene.sceneRect();
    if (!rectWindow.contains (newRectView.boundingRect())) {

      // Keep the item inside the scene rectangle
      newPos.setX (qMin (rectWindow.right(), qMax (newPos.x(), rectWindow.left())));
      newPos.setY (qMin (rectWindow.bottom(), qMax (newPos.y(), rectWindow.top())));

      valueFiltered = (newPos);

    }

    // Skip moving of other handles, in response to the move of this handle, if event handling is (temporarily) off,
    // to prevent an infinite loop
    if (!m_disableEventsWhileMovingAutomatically) {

      bool left   = ((m_orientationFlags & PdfCropping::PDF_CROPPING_LEFT  ) != 0);
      bool right  = ((m_orientationFlags & PdfCropping::PDF_CROPPING_RIGHT ) != 0);
      bool top    = ((m_orientationFlags & PdfCropping::PDF_CROPPING_TOP   ) != 0);
      bool bottom = ((m_orientationFlags & PdfCropping::PDF_CROPPING_BOTTOM) != 0);

      if (left && top) {
        m_pdfCropping.moveTL (newPos, oldPos);
      } else if (right && top) {
        m_pdfCropping.moveTR (newPos, oldPos);
      } else if (right && bottom) {
        m_pdfCropping.moveBR (newPos, oldPos);
      } else if (left && bottom) {
        m_pdfCropping.moveBL (newPos, oldPos);
      }
    }
  }

  return QGraphicsItem::itemChange(change, valueFiltered);
}
Example #4
0
void AbstractContent::ensureVisible(const QRectF & rect)
{
    // keep the center inside the scene rect
    QPointF center = pos();
    if (!rect.contains(center)) {
        center.setX(qBound(rect.left(), center.x(), rect.right()));
        center.setY(qBound(rect.top(), center.y(), rect.bottom()));
        setPos(center);
    }
}
Example #5
0
void EllipseTextureGraphicsItem::_setPointOfEllipseAtAngle(QPointF& point, const QPointF& center, float hRadius, float vRadius, float rotation, float circularAngle)
{
  float xCirc = sin(circularAngle) * hRadius;
  float yCirc = cos(circularAngle) * vRadius;
  float distance = sqrt( xCirc*xCirc + yCirc*yCirc );
  float angle    = atan2( xCirc, yCirc );
  rotation = 2*M_PI-rotation; // rotation needs to be inverted (CW <-> CCW)
  point.setX( sin(angle + rotation) * distance + center.x() );
  point.setY( cos(angle + rotation) * distance + center.y() );
}
Example #6
0
QPointF ControlRuler::mapWidgetToItem(QPoint *point)
{
//    double xscale = (double) m_pannedRect.width() / (double) width();
//    double yscale = 1.0f / (double) height();

    QPointF newpoint;
    newpoint.setX(m_xScale*(point->x()) + m_pannedRect.left() - m_xOffset);
    newpoint.setY(-m_yScale*(point->y()) + 1.0f);
    return newpoint;
}
const QPointF QQuickAngleDirection::sample(const QPointF &from)
{
    Q_UNUSED(from);
    QPointF ret;
    qreal theta = m_angle*CONV - m_angleVariation*CONV + rand()/float(RAND_MAX) * m_angleVariation*CONV * 2;
    qreal mag = m_magnitude- m_magnitudeVariation + rand()/float(RAND_MAX) * m_magnitudeVariation * 2;
    ret.setX(mag * cos(theta));
    ret.setY(mag * sin(theta));
    return ret;
}
Example #8
0
/**
 * \brief Convertse QPointF variables from 2-vecs.
 * @return
 */
QPointF RMat::QVec::toQPointF() const
{
	Q_ASSERT( size() == 2);

	QPointF result;

	result.setX( operator[](0));
	result.setY( operator[](1));
	return result;
}
Example #9
0
QPointF Fidelity::GUI::ANodeItem::NodeCenterScenePosition() const
{
	// Get adjusted local center position
	QPointF center = mapFromParent(pos());
	center.setX(center.x() + NodeSize / 2);
	center.setY(center.y() + NodeSize / 2);

	// Return position in scene coordinates
	return(mapToScene(center));
}
Example #10
0
    void computePercentPosition(QPointF &point, const SubParameter &unitSubParameter)
    {
        if(unitSubParameter.value().toInt() == 1)//Percents
        {
            QRect screenGeometry = QApplication::desktop()->screenGeometry();

            point.setX((point.x() * screenGeometry.width()) / 100.0f);
            point.setY((point.y() * screenGeometry.height()) / 100.0f);
        }
    }
Example #11
0
void PixmapItem::topChanged(const QString &top)
{
    if(top.toInt() != pos().y())
        emit itemChange();

    QPointF p = pos();
    p.setY(top.toInt());
    setPos(p);

}
void CIndicatorToolScene::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
{
	QString strXValue;
	QString strYValue;

	m_bDragOver = false;
	if (event->mimeData()->hasColor())
	{
		event->setAccepted(true);
		m_nDragColor = qvariant_cast<QColor>(event->mimeData()->colorData());
		m_nColor = m_nDragColor;
		//strXValue = QString(qvariant_cast<QByteArray>(event->mimeData()->data("xValue")).data());
		//strYValue = QString(qvariant_cast<QByteArray>(event->mimeData()->data("yValue")).data());

		strXValue = QString(event->mimeData()->data("xValue").data());
		strYValue = QString(event->mimeData()->data("yValue").data());
// 		strXValue = "10";
// 		strYValue = "10";
	}


	CRectItem* pItem = NULL;
	QPointF pointMousePos;
	QPointF pointItemPos;
	QPointF pointHot;

	pointMousePos = event->scenePos();
	pointHot.setX(strXValue.toInt());
	pointHot.setY(strYValue.toInt());

	pointItemPos.setX(pointMousePos.x() - pointHot.x());
	pointItemPos.setY(pointMousePos.y() - pointHot.y());

	pItem = new CRectItem();
	pItem->setColor(m_nColor);
	pItem->setItemPos(pointItemPos);
	this->addItem(pItem);
	pItem = NULL;


	//QGraphicsScene::dragLeaveEvent(event);
	update();
}
Example #13
0
QPointF tile2mercator(const QPoint &tile, int z)
{
	QPointF m;

	m.setX(tile.x() / pow(2.0, z) * 360.0 - 180);
	qreal n = M_PI - 2.0 * M_PI * tile.y() / pow(2.0, z);
	m.setY(rad2deg(atan(0.5 * (exp(n) - exp(-n)))));

	return ll2mercator(m);
}
Example #14
0
void AngleVariation::initialise()
{
    // Calculate points positions
    QPointF tempPoint = QPointF();
    tempPoint.setX(branchLine.p2().x() - branchLine.p1().x());
    tempPoint.setY(branchLine.p2().y() - branchLine.p1().y());
    branchAngle = atan2(tempPoint.y(), tempPoint.x());
    origPoint = findPoint(branchAngle - variationAngle);
    variationPoint = calculateOpposingPoint(origPoint);
}
    void updatePos(){
        QPointF c1 = start_->pos() + QPoint(kPeopleNodeRadius, kPeopleNodeRadius);
        QPointF c2 = end_->pos() + QPoint(kPeopleNodeRadius, kPeopleNodeRadius);

        QPointF delta = c2-c1;
        qreal deltaLength = QLineF(c1, c2).length();

        qreal ratio = (kPeopleNodeRadius + kConnectorGap) / deltaLength;

        QPointF p1 = c1 + delta * ratio;
        QPointF p2 = c2 - delta * ratio;

        QLineF line;
        line.setP1(p1);
        line.setP2(p2);

        setLine(line);

        QPointF d = p1-p2;

        {
            static const qreal sinv = sin(kArrowAngle);
            static const qreal cosv = cos(kArrowAngle);

            QPointF vec;
            vec.setX(d.x() * cosv - d.y() * sinv);
            vec.setY(d.x() * sinv + d.y() * cosv);

            qreal ratio = qSqrt(vec.x() * vec.x() + vec.y() * vec.y())/kArrowLength;

            vec /= ratio;

            arrow[0]->setLine(QLineF(p2, p2 + vec));

            vec.setX(d.x() * cosv + d.y() * sinv);
            vec.setY(-d.x() * sinv + d.y() * cosv);
            vec /= ratio;

            arrow[1]->setLine(QLineF(p2, p2 + vec));
        }

        label_->setPos((c1+c2)/2);
    }
Example #16
0
QPointF Box2DBody::getWorldCenter() const
{
    QPointF worldCenter;
    if (mBody) {
        const b2Vec2 &center = mBody->GetWorldCenter();
        worldCenter.setX(center.x * scaleRatio);
        worldCenter.setY(-center.y * scaleRatio);
    }
    return worldCenter;
}
QVariant MixerNode::itemChange(GraphicsItemChange change, const QVariant &val)
{
    QPointF newPos = val.toPointF();
    double h = graph->sceneRect().height();

    switch (change) {
    case ItemPositionChange:
    {
        if (!vertical) {
            break;
        }

        // Force node to move vertically
        newPos.setX(pos().x());

        // Stay inside graph
        if (newPos.y() < 0) {
            newPos.setY(0);
        }
        // qDebug() << h << " - " << newPos.y();
        if (newPos.y() > h) {
            newPos.setY(h);
        }

        return newPos;
    }
    case ItemPositionHasChanged:
    {
        foreach(Edge * edge, edgeList)
        edge->adjust();

        update();

        graph->itemMoved(value());
        break;
    }
    default:
        break;
    }
    ;

    return QGraphicsItem::itemChange(change, val);
}
Example #18
0
void UwMath::getTurningPoints(QPointF &leftTP, QPointF &rightTP,
                              const float &wAngle, const float &layLinesAngle,
                              const QPointF &origin, const QPointF &destiny)
{
    // overloaded for Qt
    double leftTPlon;
    double leftTPlat;
    double rightTPlon;
    double rightTPlat;

    UwMath::getTurningPoints(leftTPlon, leftTPlat, rightTPlon, rightTPlat,
                             wAngle, layLinesAngle,
                             origin.x(), origin.y(), destiny.x(), destiny.y());

    leftTP.setY(leftTPlat);
    leftTP.setX(leftTPlon);
    rightTP.setY(rightTPlat);
    rightTP.setX(rightTPlon);
}
Example #19
0
void RawDelegate::createPlotPath(const QModelIndex &index, QPainterPath& path, QList<RowVectorPair>& listPairs) const
{
    //get maximum range of respective channel type (range value in FiffChInfo does not seem to contain a reasonable value)
    qint32 kind = (static_cast<const RawModel*>(index.model()))->m_chInfolist[index.row()].kind;
    double dMaxValue = 1e-9;

    switch(kind) {
    case FIFFV_MEG_CH: {
        qint32 unit = (static_cast<const RawModel*>(index.model()))->m_pfiffIO->m_qlistRaw[0]->info.chs[index.row()].unit;
        if(unit == FIFF_UNIT_T_M) {
            dMaxValue = m_qSettings.value("RawDelegate/max_meg_grad").toDouble();
        }
        else if(unit == FIFF_UNIT_T)
            dMaxValue = m_qSettings.value("RawDelegate/max_meg_mag").toDouble();
        break;
    }
    case FIFFV_EEG_CH: {
        dMaxValue = m_qSettings.value("RawDelegate/max_eeg").toDouble();
        break;
    }
    case FIFFV_EOG_CH: {
        dMaxValue = m_qSettings.value("RawDelegate/max_eog").toDouble();
        break;
    }
    case FIFFV_STIM_CH: {
        dMaxValue = m_qSettings.value("RawDelegate/max_stim").toDouble();
        break;
    }
    }

    double dValue;
    double dScaleY = m_dPlotHeight/(2*dMaxValue);

    double y_base = path.currentPosition().y();
    QPointF qSamplePosition;

    //plot all rows from list of pairs
    for(qint8 i=0; i < listPairs.size(); ++i) {
        //create lines from one to the next sample
        for(qint32 j=0; j < listPairs[i].second; ++j)
        {
            double val = *(listPairs[i].first+j);
            dValue = val*dScaleY;

            double newY = y_base+dValue;

            qSamplePosition.setY(newY);
            qSamplePosition.setX(path.currentPosition().x()+m_dDx);

            path.lineTo(qSamplePosition);
        }
    }

//    qDebug("Plot-PainterPath created!");
}
void RealTimeMultiSampleArrayDelegate::createPlotPath(const QModelIndex &index, QPainterPath& path, QList< QVector<float> >& data) const
{
    //get maximum range of respective channel type (range value in FiffChInfo does not seem to contain a reasonable value)
    qint32 kind = (static_cast<const RealTimeMultiSampleArrayModel*>(index.model()))->m_qListChInfo[index.row()].getKind();
    float fMaxValue = 1e-9;

//    switch(kind) {
//        case FIFFV_MEG_CH: {
//            qint32 unit = (static_cast<const RealTimeMultiSampleArrayModel*>(index.model()))->m_pfiffIO->m_qlistRaw[0]->info.chs[index.row()].unit;
//            if(unit == FIFF_UNIT_T_M) {
//                dMaxValue = m_qSettings.value("RawDelegate/max_meg_grad").toDouble();
//            }
//            else if(unit == FIFF_UNIT_T)
//                dMaxValue = m_qSettings.value("RawDelegate/max_meg_mag").toDouble();
//            break;
//        }
//        case FIFFV_EEG_CH: {
//            dMaxValue = m_qSettings.value("RawDelegate/max_eeg").toDouble();
//            break;
//        }
//        case FIFFV_EOG_CH: {
//            dMaxValue = m_qSettings.value("RawDelegate/max_eog").toDouble();
//            break;
//        }
//        case FIFFV_STIM_CH: {
//            dMaxValue = m_qSettings.value("RawDelegate/max_stim").toDouble();
//            break;
//        }
//    }

    float fValue;
    float fScaleY = m_fPlotHeight/(2*fMaxValue);

    float y_base = path.currentPosition().y();
    QPointF qSamplePosition;

    //plot all rows from list of pairs
    for(qint8 i=0; i < data.size(); ++i) {
        //create lines from one to the next sample
        for(qint32 j=0; j < data[i].size(); ++j)
        {
            float val = data[i][j];
            fValue = val*fScaleY;

            float newY = y_base+fValue;

            qSamplePosition.setY(newY);
            qSamplePosition.setX(path.currentPosition().x()+m_fDx);

            path.lineTo(qSamplePosition);
        }
    }

//    qDebug("Plot-PainterPath created!");
}
Example #21
0
bool
ViewerNodeOverlay::isNearbyWipeRotateBar(const QPointF& wipeCenter,
                                         double wipeAngle,
                                         const QPointF & pos,
                                         double zoomScreenPixelWidth,
                                         double zoomScreenPixelHeight)
{
    double toleranceX = zoomScreenPixelWidth * 8.;
    double toleranceY = zoomScreenPixelHeight * 8.;
    double rotateX, rotateY, rotateOffsetX, rotateOffsetY;

    rotateX = WIPE_ROTATE_HANDLE_LENGTH * zoomScreenPixelWidth;
    rotateY = WIPE_ROTATE_HANDLE_LENGTH * zoomScreenPixelHeight;
    rotateOffsetX = WIPE_ROTATE_OFFSET * zoomScreenPixelWidth;
    rotateOffsetY = WIPE_ROTATE_OFFSET * zoomScreenPixelHeight;

    QPointF outterPoint;

    outterPoint.setX( wipeCenter.x() + std::cos(wipeAngle) * (rotateX - rotateOffsetX) );
    outterPoint.setY( wipeCenter.y() + std::sin(wipeAngle) * (rotateY - rotateOffsetY) );
    if ( ( ( ( pos.y() >= (wipeCenter.y() - toleranceY) ) && ( pos.y() <= (outterPoint.y() + toleranceY) ) ) ||
          ( ( pos.y() >= (outterPoint.y() - toleranceY) ) && ( pos.y() <= (wipeCenter.y() + toleranceY) ) ) ) &&
        ( ( ( pos.x() >= (wipeCenter.x() - toleranceX) ) && ( pos.x() <= (outterPoint.x() + toleranceX) ) ) ||
         ( ( pos.x() >= (outterPoint.x() - toleranceX) ) && ( pos.x() <= (wipeCenter.x() + toleranceX) ) ) ) ) {
            Point a;
            a.x = ( outterPoint.x() - wipeCenter.x() );
            a.y = ( outterPoint.y() - wipeCenter.y() );
            double norm = sqrt(a.x * a.x + a.y * a.y);

            ///The point is in the bounding box of the segment, if it is vertical it must be on the segment anyway
            if (norm == 0) {
                return false;
            }

            a.x /= norm;
            a.y /= norm;
            Point b;
            b.x = ( pos.x() - wipeCenter.x() );
            b.y = ( pos.y() - wipeCenter.y() );
            norm = sqrt(b.x * b.x + b.y * b.y);

            ///This vector is not vertical
            if (norm != 0) {
                b.x /= norm;
                b.y /= norm;

                double crossProduct = b.y * a.x - b.x * a.y;
                if (std::abs(crossProduct) <  0.1) {
                    return true;
                }
            }
        }

    return false;
} // isNearbyWipeRotateBar
QVariant GridCtrlNode::itemChange(GraphicsItemChange change, const QVariant &value)
{
    switch (change) {
    case ItemPositionHasChanged:
        if (scene()) {
            // value is the new position.
            QPointF newPos = value.toPointF();
            QRectF rect = scene()->sceneRect();

            if(gridPtLocation.x() == 0){
                newPos.setX(0);
            }
            if(gridPtLocation.y() == 0){
                newPos.setY(0);
            }
            if(gridPtLocation.x() == wWidget->getWarpWindow()->getGridSize().width()){
                newPos.setX(wWidget->getWarpWindow()->sizeHint().width()-1);
            }
            if(gridPtLocation.y() == wWidget->getWarpWindow()->getGridSize().height()){
                newPos.setY(wWidget->getWarpWindow()->sizeHint().height()-1);
            }

            if (!rect.contains(newPos)) {
                // Keep the item inside the scene rect.
                newPos.setX(qMin(rect.right()-1, qMax(newPos.x(), rect.left())));
                newPos.setY(qMin(rect.bottom()-1, qMax(newPos.y(), rect.top())));
                this->setPos(newPos);
                return newPos;
            }

            this->setPos(newPos);
            wWidget->getWarpWindow()->setCommonCtrlPnt(gridPtLocation, QVector3D(newPos));
            wWidget->getWarpWindow()->update();
        }
        return QGraphicsItem::itemChange(change, value);
        break;
    default:
        break;
    };

    return QGraphicsItem::itemChange(change, value);
}
void StelAppGraphicsWidget::mousePressEvent(QGraphicsSceneMouseEvent* event)
{
	// Apply distortion on the mouse position.
	// Widget gets focus on clicked
	setFocus();
	QPointF pos = event->scenePos();
	distortPos(&pos);
	pos.setY(scene()->height() - 1 - pos.y());
	QMouseEvent newEvent(QEvent::MouseButtonPress, QPoint(pos.x(),pos.y()), event->button(), event->buttons(), event->modifiers());
	stelApp->handleClick(&newEvent);
}
Example #24
0
/**
 * Generate a treasure to a specified position.
 * @param  random      Random number from 0 to 3.
 * @param  board_width The width of the board.
 * @param  coords      Where to generate the treasure.
 * @return             0 on failure, 1 on success.
 */
int Treasure::generateTreasure(int random, int board_width, QList<QPointF>& coords)
{
    int random_row = (rand() % (board_width));
    int random_col = (rand() % (board_width));
    int stone_width = 60;
    int stone_height = 60;

    // new point to test with
    QPointF current;
    current.setX(random_row*stone_width);
    current.setY(random_col*stone_height);

    // if there's anything inside
    if(coords.size() > 0)
    {
        // iterate over the treasure coords
        for(int i = 0; i < coords.size(); i++)
        {
            // if there is the same position as another treasure, return 0
            if((coords.at(i).x() == current.x()) && (coords.at(i).y() == current.y()))
            {
                return 0;
            }
        }
    }

    // if we have unique coords, append
    coords.append(current);

    switch(random)
    {
        case 0:
            setPixmap(QPixmap(":/images/treasure1.png"));
            type = 1;
            this->setPos(random_row*stone_width, random_col*stone_height);
            break;
        case 1:
            type = 2;
            setPixmap(QPixmap(":/images/treasure2.png"));
            this->setPos(random_row*stone_width, random_col*stone_height);
            break;
        case 2:
            type = 3;
            setPixmap(QPixmap(":/images/treasure3.png"));
            this->setPos(random_row*stone_width, random_col*stone_height);
            break;
        case 3:
            type = 4;
            setPixmap(QPixmap(":/images/treasure4.png"));
            this->setPos(random_row*stone_width, random_col*stone_height);
            break;
    }
    return 1;
}
Example #25
0
void BrainPlot::appendPoint( QPointF point, int Channel )
{
    /*Adds new point - with proper index and offset - to the data series*/
    CurveData *data = static_cast<CurveData *>( d_curves[Channel]->data() );
    point.setY(minusExpectedAmplitude*(2*Channel+1)+point.y());
    data->replace(sample%plotLength, point);
    setClipRegion(d_curves[Channel], point);

    d_directPainter->drawSeries( d_curves[Channel],
                                 data->size() - 1, data->size() - 1 );
}
Example #26
0
bool DiagramList::getPoint(QPointF &p, size_t i)
{
	if (i < _coords.size())
	{
		p.setX(_coords[i].first);
		p.setY(_coords[i].second);
		return true;
	}
	else
		return false;
}
Example #27
0
void picPunto::drawCircle(QString x, QString y, QString radius)
{
    QPointF center;
    qreal rad;
    
    center.setX(getPValue(x));
    center.setY(getPValue(y));
    rad = getPValue(radius);
    currDoc->addCircle(&center, rad);
    cnt++;
}    
Example #28
0
void GameItem::paint()
{
    b2Vec2 pos = g_body->GetPosition();
    //std::cout << g_body->GetAngle() << std::endl;
    QPointF mappedPoint;
    mappedPoint.setX(((pos.x-g_size.width()/2) * g_windowsize.width())/g_worldsize.width());
    mappedPoint.setY((1.0f - (pos.y+g_size.height()/2)/g_worldsize.height()) * g_windowsize.height());
    g_pixmap.setPos(mappedPoint);
    g_pixmap.resetTransform();
    g_pixmap.setRotation(-(g_body->GetAngle()*180/3.14159));
}
/*!
    \internal
*/
void QDeclarativeGeoMapGestureArea::updatePan()
{
    QPointF startPoint = map_->coordinateToScreenPosition(startCoord_, false).toPointF();
    int dx = static_cast<int>(sceneCenter_.x() - startPoint.x());
    int dy = static_cast<int>(sceneCenter_.y() - startPoint.y());
    QPointF mapCenterPoint;
    mapCenterPoint.setY(map_->height() / 2.0  - dy);
    mapCenterPoint.setX(map_->width() / 2.0 - dx);
    QGeoCoordinate animationStartCoordinate = map_->screenPositionToCoordinate(QDoubleVector2D(mapCenterPoint), false);
    map_->mapController()->setCenter(animationStartCoordinate);
}
Example #30
0
    /**
     * Converts a comma separated string to point.
     */
    QPointF stringToPoint(const QString& str)
    {
        QPointF retVal;
        QStringList list = str.split(QLatin1Char(','));

        if(list.size() == 2) {
            retVal.setX(list.first().toDouble());
            retVal.setY(list.last().toDouble());
        }
        return retVal;
    }