当前位置: 首页>>代码示例>>C++>>正文


C++ QPointF::x方法代码示例

本文整理汇总了C++中QPointF::x方法的典型用法代码示例。如果您正苦于以下问题:C++ QPointF::x方法的具体用法?C++ QPointF::x怎么用?C++ QPointF::x使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QPointF的用法示例。


在下文中一共展示了QPointF::x方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: move

void Plugin_Entity::move(QPointF offset){
    entity->move( RS_Vector(offset.x(), offset.y()) );
}
开发者ID:absorb-it,项目名称:LibreCAD,代码行数:3,代码来源:doc_plugin_interface.cpp

示例2: handleDrag

/** Handle the mouse move event when the line is being dragged
 * @param event mouse event info */
void LineOverlay::handleDrag(QMouseEvent *event) {
  // Is the shift key pressed?
  bool shiftPressed = (event->modifiers() & Qt::ShiftModifier);
  // Currently dragging!
  QPointF current = this->invTransform(event->pos());
  QPointF currentSnap = this->snap(current);
  QPointF diff = m_pointB - m_pointA;
  QPointF dragAmount = current - this->m_dragStart;
  dragAmount = snap(dragAmount);
  double width = 0;

  // Adjust the current mouse position if needed.
  if ((m_snapLength > 0) || shiftPressed || m_angleSnapMode) {
    // This is the distance between the fixed and dragged point
    QPointF currentDiff;
    if (m_dragHandle == HandleA)
      currentDiff = current - m_pointB;
    else if (m_dragHandle == HandleB)
      currentDiff = current - m_pointA;

    // calculate angle
    double angle = atan2(currentDiff.y(), currentDiff.x());

    // Round angle to closest 45 degrees, if in angle snap mode (shift pressed)
    if (shiftPressed || m_angleSnapMode) {
      if (m_angleSnap == 90.0) {
        // special case for 90 snap (axis aligned snapping)
        // use screen coords to determine snap angle
        QPointF currentScreenDiff;
        if (m_dragHandle == HandleA)
          currentScreenDiff = event->pos() - transform(m_pointB);
        else if (m_dragHandle == HandleB)
          currentScreenDiff = event->pos() - transform(m_pointA);

        // Limit angles to 90 based on screen coords, not data coords
        //-y is because the screen y coords are inverted to the data coords
        angle = atan2(-currentScreenDiff.y(), currentScreenDiff.x());
      }
      // convert snap angle to radians
      double angleSnapRad = m_angleSnap / (180.0 / M_PI);
      // round current angle to snap angle
      angle = Utils::rounddbl(angle / angleSnapRad) * angleSnapRad;
    }

    double length;
    // for axis aligned angles just use respective distance for the length
    if (fmod(angle, M_PI) == 0) {
      length = fabs(currentDiff.x());
    } else if (fmod(angle, M_PI) == M_PI / 2) {
      length = fabs(currentDiff.y());
    } else {
      length = sqrt(currentDiff.x() * currentDiff.x() +
                    currentDiff.y() * currentDiff.y());
    }

    // Round length to m_snapLength, if specified
    if (m_snapLength > 0)
      length = Utils::rounddbl(length / m_snapLength) * m_snapLength;

    // Rebuild the mouse position
    currentDiff = QPointF(cos(angle) * length, sin(angle) * length);
    if (m_dragHandle == HandleA)
      currentSnap = snap(m_pointB + currentDiff);
    else if (m_dragHandle == HandleB)
      currentSnap = snap(m_pointA + currentDiff);
  }

  switch (m_dragHandle) {
  case HandleA:
    setPointA(currentSnap);
    break;

  case HandleB:
    setPointB(currentSnap);
    break;

  case HandleWidthBottom:
  case HandleWidthTop:
    // Find the distance between the mouse and the line (see
    // http://mathworld.wolfram.com/Point-LineDistance2-Dimensional.html )
    width = fabs(diff.x() * (current.y() - m_pointA.y()) -
                 (current.x() - m_pointA.x()) * diff.y()) /
            sqrt(diff.x() * diff.x() + diff.y() * diff.y());
    setWidth(width);
    break;

  case HandleCenter:
    // Move the whole line around
    m_pointA = m_dragStart_PointA + dragAmount;
    m_pointB = m_dragStart_PointB + dragAmount;
    this->update();
    emit lineChanging(m_pointA, m_pointB, m_width);
    break;

  default:
    break;
  }
}
开发者ID:rosswhitfield,项目名称:mantid,代码行数:100,代码来源:LineOverlay.cpp

示例3: split

int Shell::split(QVariantList points)
{
	QPointF point;

	//omit last value, because it is always zero
	int dataSize = points.size()-1;

	Eigen::MatrixXf x; x.resize(dataSize,2);
	Eigen::VectorXf y(dataSize);

  //create the linear eq system in the form of y = beta1*x + beta2*1
	for( int i = 0; i < dataSize; i++)
	{
		point = points[i].toPointF();
		x(i, 0) = 1.0f; //beta for y-intercept
		x(i, 1) = point.x(); //beta for slope (dependent on x)

		y(i) = point.y(); 
	}

	//Error function (least squares of ax+b)
	auto error = [](Regression reg, int b, int a)->float
	{
		float result = 0;
		for(int i=0 ; i< reg.y.size(); i++)
		{
			float functionValue = a*reg.x(i, 1)+ b;
			float squarederror = std::pow(reg.y(i) - functionValue, 2);
			result+=squarederror;
		}
		return result;

	};

	//Perform all pairs of regressions
	float lowestError = std::numeric_limits<float>::max();
	float r1a, r1b;
	float r2a, r2b;
	int splitIndex = 0;

	for( int i = 2; i < dataSize; i++)
	{
		Regression reg1; reg1.x = x.topRows(i); reg1.y = y.head(i);
		Regression reg2; reg2.x = x.bottomRows(dataSize-i); reg2.y = y.tail(dataSize-i);

		Eigen::MatrixXf reg1Result = ((reg1.x.transpose() * reg1.x).inverse() * reg1.x.transpose()) * reg1.y;
		Eigen::MatrixXf reg2Result = ((reg2.x.transpose() * reg2.x).inverse() * reg2.x.transpose()) * reg2.y;

		float currentError = error(reg1,reg1Result(0),reg1Result(1)) + error(reg2,reg2Result(0),reg2Result(1));
		if (currentError < lowestError)
		{
			r1a = reg1Result(1); r1b = reg1Result(0);
			r2a = reg2Result(1); r2b = reg2Result(0);
			lowestError = currentError;
			splitIndex = i;
		}

	}
	std::cout << "r1:" << r1a << "x + " << r1b << std::endl;
	std::cout << "r2:" << r2a << "x + " << r2b << std::endl;
	std::cout << "(smallest error:" << lowestError << ")" << std::endl;

	return splitIndex;
}
开发者ID:chsterz,项目名称:performance-tools,代码行数:64,代码来源:Shell.cpp

示例4: generateTilePixmap

QPixmap TileWidget::generateTilePixmap()
{
    const QSize currentSize(size());

    if (currentSize.isEmpty())
        return QPixmap();

    const QRect borderRect(0, 0, currentSize.width(), currentSize.height());
    const int maxSideLength = qMax(currentSize.width(), currentSize.height());
    const int borderWidth = 1;

    const QPointF midpoint((double)(currentSize.width() + borderWidth) / 2, (double)(currentSize.height() + borderWidth) / 2);
    const QColor color(tileColor());

    QPixmap ret(currentSize);

    if (PixmapCacher::self()->contains(color))
        ret = PixmapCacher::self()->get(color);
    else
    {
        //UVcout << "cache miss for color " << color.rgb() << endl;
        double radius = maxSideLength / 2 * 1.41 + maxSideLength / 10 + 2;

        // could be used for cool effect -- the color of the bonus square we're obscuring
        //const QColor outerColor(backgroundColor());

        QRadialGradient gradient(QPointF(radius, radius), radius * 3, QPointF(radius / 3, radius / 3));
        gradient.setColorAt(0, color.light(GraphicalBoardFrame::s_highlightFactor));
        gradient.setColorAt(.95, color.dark(GraphicalBoardFrame::s_highlightFactor));

        QPainter painter(&ret);
        painter.setBrush(gradient);
    
        painter.drawEllipse((int)(midpoint.x() - radius), (int)(midpoint.y() - radius), (int)(radius * 2), (int)(radius * 2));

        QPalette customPalette;
        customPalette.setColor(QPalette::Light, color.light(GraphicalBoardFrame::s_highlightFactor));
        customPalette.setColor(QPalette::Dark, color);
        customPalette.setColor(QPalette::Mid, color);

        qDrawShadePanel(&painter, borderRect.x(), borderRect.y(), borderRect.width(), borderRect.height(), customPalette, false, borderWidth);

        PixmapCacher::self()->put(color, ret);
    }

    const QString nanism = miniText();
    const bool hasNanism = !nanism.isEmpty();

    const QString text = letterText();
    if (!text.isEmpty())
    {
        QPainter painter(&ret);
        painter.setFont(letterFont());
        QPen pen(letterTextColor());
        painter.setPen(pen);
        painter.setBrush(Qt::NoBrush);

        const QRectF textSize(painter.boundingRect(borderRect, text));
        const QPointF startPoint(midpoint - textSize.bottomRight() / 2);
        const QPointF roundedStartPoint(floor(startPoint.x()), floor(startPoint.y()));

        QRectF textRect(textSize);
        textRect.moveTo(roundedStartPoint);

        painter.drawText(textRect, Qt::TextDontClip, text);

        if (m_information.isBlank)
        {
            painter.setBrush(Qt::NoBrush);
            pen.setWidth(1);
            painter.setPen(pen);

            const int border = currentSize.width() / 5;
            painter.drawRect(QRect(border, border, currentSize.width() - 2 * border, currentSize.height() - 2 * border));
        }
    }

    if (hasNanism)
    {
        QPainter painter(&ret);
        painter.setFont(miniFont());
        QPen pen(miniTextColor());
        painter.setPen(pen);
        painter.setBrush(Qt::NoBrush);

        const QRectF textSize(painter.boundingRect(borderRect, nanism));
        const QPointF startPoint((midpoint * (nanism.length() > 1? 1.65 : 1.68)) - textSize.bottomRight() / 2);
        const QPointF roundedStartPoint(floor(startPoint.x()), floor(startPoint.y()));

        QRectF textRect(textSize);
        textRect.moveTo(roundedStartPoint);

        painter.drawText(textRect, Qt::TextDontClip, nanism);
    }

    return ret;
}
开发者ID:gokceneraslan,项目名称:quackle,代码行数:97,代码来源:graphicalboard.cpp

示例5: transform

/** Tranform from plot coordinates to pixel coordinates
 * @param coords :: coordinate point in plot coordinates
 * @return pixel coordinates */
QPoint LineOverlay::transform(QPointF coords) const {
  int xA = m_plot->transform(QwtPlot::xBottom, coords.x());
  int yA = m_plot->transform(QwtPlot::yLeft, coords.y());
  return QPoint(xA, yA);
}
开发者ID:rosswhitfield,项目名称:mantid,代码行数:8,代码来源:LineOverlay.cpp

示例6: QPoint

QPoint QtfeCanal::listPos2WidgetPos(QPointF pf)
{
	return QPoint(pf.x()*width(), height() * (1.0 - pf.y()));
}
开发者ID:theShmoo,项目名称:medvis2,代码行数:4,代码来源:QtfeCanal.cpp

示例7: if

bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, const QgsSymbolV2RenderContext* context, const QgsFeature* f, const QPointF& shift ) const
{
  //width
  double symbolWidth = mSymbolWidth;
  QgsExpression* widthExpression = expression( "width" );
  if ( widthExpression ) //1. priority: data defined setting on symbol layer level
  {
    symbolWidth = widthExpression->evaluate( const_cast<QgsFeature*>( f ) ).toDouble();
  }
  else if ( context->renderHints() & QgsSymbolV2::DataDefinedSizeScale ) //2. priority: is data defined size on symbol level
  {
    symbolWidth = mSize;
  }
  if ( mSymbolWidthUnit == QgsSymbolV2::MM )
  {
    symbolWidth *= mmMapUnitScaleFactor;
  }

  //height
  double symbolHeight = mSymbolHeight;
  QgsExpression* heightExpression = expression( "height" );
  if ( heightExpression ) //1. priority: data defined setting on symbol layer level
  {
    symbolHeight =  heightExpression->evaluate( const_cast<QgsFeature*>( f ) ).toDouble();
  }
  else if ( context->renderHints() & QgsSymbolV2::DataDefinedSizeScale ) //2. priority: is data defined size on symbol level
  {
    symbolHeight = mSize;
  }
  if ( mSymbolHeightUnit == QgsSymbolV2::MM )
  {
    symbolHeight *= mmMapUnitScaleFactor;
  }

  //outline width
  double outlineWidth = mOutlineWidth;
  QgsExpression* outlineWidthExpression = expression( "outline_width" );
  if ( outlineWidthExpression )
  {
    outlineWidth = outlineWidthExpression->evaluate( const_cast<QgsFeature*>( context->feature() ) ).toDouble();
  }
  if ( mOutlineWidthUnit == QgsSymbolV2::MM )
  {
    outlineWidth *= outlineWidth;
  }

  //fill color
  QColor fc = mFillColor;
  QgsExpression* fillColorExpression = expression( "fill_color" );
  if ( fillColorExpression )
  {
    fc = QColor( fillColorExpression->evaluate( const_cast<QgsFeature*>( context->feature() ) ).toString() );
  }
  int fillColorIndex = e.closestColorMatch( fc.rgb() );

  //outline color
  QColor oc = mOutlineColor;
  QgsExpression* outlineColorExpression = expression( "outline_color" );
  if ( outlineColorExpression )
  {
    oc = QColor( outlineColorExpression->evaluate( const_cast<QgsFeature*>( context->feature() ) ).toString() );
  }
  int outlineColorIndex = e.closestColorMatch( oc.rgb() );


  //symbol name
  QString symbolName =  mSymbolName;
  QgsExpression* symbolNameExpression = expression( "symbol_name" );
  if ( symbolNameExpression )
  {
    QgsExpression* symbolNameExpression = expression( "symbol_name" );
    symbolName = symbolNameExpression->evaluate( const_cast<QgsFeature*>( context->feature() ) ).toString();
  }

  //offset
  double offsetX = 0;
  double offsetY = 0;
  markerOffset( *context, offsetX, offsetY );
  QPointF off( offsetX, offsetY );

  //priority for rotation: 1. data defined symbol level, 2. symbol layer rotation (mAngle)
  double rotation = 0.0;
  QgsExpression* rotationExpression = expression( "rotation" );
  if ( rotationExpression )
  {
    rotation = rotationExpression->evaluate( const_cast<QgsFeature*>( context->feature() ) ).toDouble();
  }
  else if ( !qgsDoubleNear( mAngle, 0.0 ) )
  {
    rotation = mAngle;
  }
  rotation = -rotation; //rotation in Qt is counterclockwise
  if ( rotation )
    off = _rotatedOffset( off, rotation );

  QTransform t;
  t.translate( shift.x() + offsetX, shift.y() + offsetY );

  if ( rotation != 0 )
    t.rotate( rotation );
//.........这里部分代码省略.........
开发者ID:Aladar64,项目名称:QGIS,代码行数:101,代码来源:qgsellipsesymbollayerv2.cpp

示例8: qDebug

void MainView2D::createFixtureItem(quint32 fxID, quint16 headIndex, quint16 linkedIndex,
                                   QVector3D pos, bool mmCoords)
{
    if (isEnabled() == false)
        return;

    if (m_gridItem == NULL)
       initialize2DProperties();

    qDebug() << "[MainView2D] Creating fixture with ID" << fxID << headIndex << linkedIndex << "pos:" << pos;

    Fixture *fixture = m_doc->fixture(fxID);
    if (fixture == NULL)
        return;

    quint32 itemID = FixtureUtils::fixtureItemID(fxID, headIndex, linkedIndex);
    QLCFixtureMode *fxMode = fixture->fixtureMode();
    QQuickItem *newFixtureItem = qobject_cast<QQuickItem*>(fixtureComponent->create());
    quint32 itemFlags = m_monProps->fixtureFlags(fxID, headIndex, linkedIndex);

    newFixtureItem->setParentItem(m_gridItem);
    newFixtureItem->setProperty("itemID", itemID);

    if (itemFlags & MonitorProperties::HiddenFlag)
        newFixtureItem->setProperty("visible", false);

    if (fxMode != NULL && fixture->type() != QLCFixtureDef::Dimmer)
    {
        QLCPhysical phy = fxMode->physical();

        //qDebug() << "Current mode fixture heads:" << fxMode->heads().count();
        newFixtureItem->setProperty("headsNumber", fxMode->heads().count());

        if (fixture->channelNumber(QLCChannel::Pan, QLCChannel::MSB) != QLCChannel::invalid())
        {
            int panDeg = phy.focusPanMax();
            if (panDeg == 0) panDeg = 360;
            newFixtureItem->setProperty("panMaxDegrees", panDeg);
        }
        if (fixture->channelNumber(QLCChannel::Tilt, QLCChannel::MSB) != QLCChannel::invalid())
        {
            int tiltDeg = phy.focusTiltMax();
            if (tiltDeg == 0) tiltDeg = 270;
            newFixtureItem->setProperty("tiltMaxDegrees", tiltDeg);
        }
    }

    QPointF itemPos;
    QSizeF size = FixtureUtils::item2DDimension(fixture->type() == QLCFixtureDef::Dimmer ? NULL : fxMode,
                                                m_monProps->pointOfView());

    if (mmCoords == false && (pos.x() != 0 || pos.y() != 0))
    {
        float gridUnits = m_monProps->gridUnits() == MonitorProperties::Meters ? 1000.0 : 304.8;
        itemPos.setX((pos.x() * gridUnits) / m_cellPixels);
        itemPos.setY((pos.y() * gridUnits) / m_cellPixels);
    }

    if (m_monProps->containsItem(fxID, headIndex, linkedIndex))
    {
        itemPos = FixtureUtils::item2DPosition(m_monProps, m_monProps->pointOfView(), pos);
        newFixtureItem->setProperty("rotation",
                                    FixtureUtils::item2DRotation(m_monProps->pointOfView(),
                                                                 m_monProps->fixtureRotation(fxID, headIndex, linkedIndex)));
    }
    else
    {
        itemPos = FixtureUtils::available2DPosition(m_doc, m_monProps->pointOfView(),
                                                    QRectF(itemPos.x(), itemPos.y(), size.width(), size.height()));
        // add the new fixture to the Doc monitor properties
        QVector3D newPos = FixtureUtils::item3DPosition(m_monProps, itemPos, 1000.0);
        m_monProps->setFixturePosition(fxID, headIndex, linkedIndex, newPos);
        m_monProps->setFixtureFlags(fxID, headIndex, linkedIndex, 0);
        Tardis::instance()->enqueueAction(Tardis::FixtureSetPosition, itemID, QVariant(QVector3D(0, 0, 0)), QVariant(newPos));
    }

    newFixtureItem->setProperty("mmXPos", itemPos.x());
    newFixtureItem->setProperty("mmYPos", itemPos.y());
    newFixtureItem->setProperty("mmWidth", size.width());
    newFixtureItem->setProperty("mmHeight", size.height());
    newFixtureItem->setProperty("fixtureName", fixture->name());

    // and finally add the new item to the items map
    m_itemsMap[itemID] = newFixtureItem;

    QByteArray values;
    updateFixture(fixture, values);
}
开发者ID:exmatrikulator,项目名称:qlcplus,代码行数:88,代码来源:mainview2d.cpp

示例9: setColorFromPoint

void ColorRing::setColorFromPoint(float x, float y)
{
	float r2 = x*x + y*y;
	QRect r = contentsRect();
	if(grabring && grabtriangle) {
		grabring = grabtriangle = false;
	}
	if(!grabring && !grabtriangle) {
		if(r2 > RING2) {
			grabring = true;
		} else {
			grabtriangle = true;
		}
	}
	if(grabring) {
		float angle = (atan2f(y,-x)/M_PI);
		angle = (angle * 0.5f) + 0.5f;
		col.setHsvF(angle, col.saturationF(), col.valueF());
	} else if(grabtriangle) {
		QMatrix m;
		m.scale(1.f/RING, 1.f/RING);
		m.rotate(col.hueF() * 360);
		if(triangleMode) {
			QPointF p = m.map(QPointF(x, y)), p2;
			QLineF satL(points[0], points[1]);
			QLineF l1(points[2], p);
			switch(satL.intersect(l1, &p2)) {
			case QLineF::BoundedIntersection:
			case QLineF::UnboundedIntersection:
				{
					float sat = QLineF(points[1], p2).length()/satL.length();
					if(satL.length() < QLineF(points[0], p2).length()) sat = 0;
					float val = QLineF(points[2], p).length()/QLineF(points[2], p2).length();
					if(QLineF(p, p2).length() > QLineF(points[2], p2).length()) val = .0f;
					if(sat > 1.f) sat = 1.f;
					if(sat < .0f) sat = 0.f;
					if(val > 1.f) val = 1.f;
					if(val < .0f) val = .0f;
					col.setHsvF(col.hueF(), sat, val);
					break;
				}
			case QLineF::NoIntersection:
				break;
			}
		} else { // box mode
			QMatrix m2;
			m2.rotate(45);
			m.rotate(45);
			QPointF p = m.map(QPointF(x, y)), p1  = m2.map(points2[1]), p2 = m2.map(points2[2]), p0 = m2.map(points2[0]);
			float sat = (p.x() - p1.x()) / (p0.x() - p1.x());
			float val = (p.y() - p1.y()) / (p2.y() - p1.y());
			if(sat > 1.f) sat = 1.f;
			if(sat < .0f) sat = 0.f;
			if(val > 1.f) val = 1.f;
			if(val < .0f) val = .0f;
			col.setHsvF(col.hueF(), sat, val);
			//QMessageBox::information(0, "", QString("x=%1, y=%2, p1.x=%3, p1.y=%4, p2.x=%5, p2.y=%6").arg(QString::number(p.x())).arg(QString::number(p.y())).arg(QString::number(p1.x())).arg(QString::number(p1.y())).arg(QString::number(p2.x())).arg(QString::number(p2.y())));
		}
	}
	emit hChanged(col.hueF());
	emit colorChanged(col);
	repaint();
}
开发者ID:nopper,项目名称:quadro,代码行数:63,代码来源:colorring.cpp

示例10:

void
FormText::moveResizable( const QPointF & delta )
{
	moveBy( delta.x(), delta.y() );
}
开发者ID:igormironchik,项目名称:prototyper,代码行数:5,代码来源:form_text.cpp

示例11: updatePath

void PlotObject::updatePath()
{
    _path = QPainterPath();
    if (((SelectProperty*) properties()["mode"])->currentIndex() == 0) {
        QList<qreal> xValues;
        QList<qreal> yValues;
        qreal start = ((RealProperty*) properties()["start"])->value();
        qreal end = ((RealProperty*) properties()["end"])->value();
        qreal pointCount = ((IntegerProperty*) properties()["points"])->value();

        qreal step = (end - start) / pointCount;
        if (step > 0) {
            for (qreal x = start; x <= end; x += step) {
                xValues.append(x);
           }
        } else if (step < 0) {
            for (qreal x = start; x >= end; x += step) {
                xValues.append(x);
            }
        } else {
            return;
        }
        if (xValues.isEmpty()) return;


        yValues = MathUtility::parse(((PropertyString*) properties()["formular"])->string(), xValues);
        _path = QPainterPath(QPointF(xValues.first(), yValues.first()));
        for (int i = 1; i < xValues.size(); i++) {
            _path.lineTo(xValues[i], yValues[i]);
        }
    } else {
        QList<qreal> alphas;
        QList<qreal> radius;
        qreal start = ((RealProperty*) properties()["polar-start"])->value() * M_PI/180.0;
        qreal end = ((RealProperty*) properties()["polar-end"])->value() * M_PI/180.0;
        qreal pointCount = ((IntegerProperty*) properties()["points"])->value();
        qreal step = (end - start) / pointCount;
        if (step > 0) {
            for (qreal x = start; x <= end; x += step) {
                alphas.append(x);
           }
        } else if (step < 0) {
            for (qreal x = start; x >= end; x += step) {
                alphas.append(x);
            }
        } else {
            return;
        }
        radius = MathUtility::parse(((PropertyString*) properties()["formular"])->string(), alphas);

        auto polarToCart = [](qreal alpha, qreal radius) {
            return QPointF(qCos(alpha) * radius,
                           qSin(alpha) * radius);
        };

        _path = QPainterPath(polarToCart(alphas.first(), radius.first()));
        for (int i = 1; i < alphas.size(); i++) {
            QPointF p = polarToCart(alphas[i], radius[i]);
            _path.lineTo(p.x(), p.y());
        }

    }
}
开发者ID:oVooVo,项目名称:freezing-happiness,代码行数:63,代码来源:plotobject.cpp

示例12: paint

void Arrow::paint(QPainter *painter, const QStyleOptionGraphicsItem *,
          QWidget *)
{
    qDebug() << "Arrow: paint";

    if (myStartItem->collidesWithItem(myEndItem))
        return;
/*
    QPen myPen = pen();
    myPen.setColor(myColor);
    qreal arrowSize = 20;
    painter->setPen(myPen);
    painter->setBrush(myColor);


    QLineF centerLine(myStartItem->pos(), myEndItem->pos());
    QPolygonF endPolygon = myEndItem->polygon();
    //p1 = coordinates of first pointer of enditem in
    //scene coordinates
    QPointF p1 = endPolygon.first() + myEndItem->pos();
    QPointF p2;
    QPointF intersectPoint;
    QLineF polyLine;
    //.count()=.size()
    for (int i = 1; i < endPolygon.count(); ++i) {
        p2 = endPolygon.at(i) + myEndItem->pos();
        polyLine = QLineF(p1, p2);
        QLineF::IntersectType intersectType =
            polyLine.intersect(centerLine, &intersectPoint);
        if (intersectType == QLineF::BoundedIntersection)
            break;
            p1 = p2;
    }
    */

    //qreal comp1=intersectPoint.x();
    //qreal comp2;

    //TODO:
    //This is my patch to define input and output points for lines
    //All code above this point is rendered useless and should be removed

    QPointF intersectPoint;
    QPen myPen = pen();
    myPen.setColor(myColor);
    qreal arrowSize = 20;
    painter->setPen(myPen);
    painter->setBrush(myColor);

    intersectPoint=myEndItem->pos();
    intersectPoint.setX(intersectPoint.x()-myEndItem->boundingRect().width()/2);

    QPointF otherPoint;
    otherPoint=myStartItem->pos();
    otherPoint.setX(otherPoint.x()+myStartItem->boundingRect().width()/2);
    //original
    setLine(QLineF(otherPoint, intersectPoint));

    if(isZone2()){
        zone2(otherPoint);
    }
    else{
        zone1(otherPoint);
    }

    //double angle = ::acos(line().dx() / line().length());
    double angle=Pi;
    if (line().dy() >= 0)
        angle = (Pi * 2) - angle;


    QPointF arrowP1 = line().p2() + QPointF(sin(angle + Pi / 3) * arrowSize,
                                    cos(angle + Pi / 3) * arrowSize);
    QPointF arrowP2 = line().p2() + QPointF(sin(angle + Pi - Pi / 3) * arrowSize,
                                    cos(angle + Pi - Pi / 3) * arrowSize);

    arrowHead.clear();
    arrowHead << line().p2() << arrowP1 << arrowP2;

    for(int i=0;i<part.size();++i)
        painter->drawLine(*part[i]);

    //setLine(*part[0]);
    //painter->drawLine(line());
    painter->drawPolygon(arrowHead);
    if (isSelected()) {
        painter->setPen(QPen(myColor, 1, Qt::DashLine));

        QLineF myLine = line();
        myLine.translate(0, 4.0);
        painter->drawLine(myLine);
        myLine.translate(0,-8.0);
        painter->drawLine(myLine);
    }

    //qDebug() << "PAINT ORDER FINISH";
}
开发者ID:AceXIE,项目名称:xenomai-lab,代码行数:97,代码来源:arrow.cpp

示例13: scale

void Plugin_Entity::scale(QPointF center, QPointF factor){
    entity->scale( RS_Vector(center.x(), center.y()),
                RS_Vector(factor.x(), factor.y()) );
}
开发者ID:absorb-it,项目名称:LibreCAD,代码行数:4,代码来源:doc_plugin_interface.cpp

示例14: rotate

void Plugin_Entity::rotate(QPointF center, double angle){
    entity->rotate( RS_Vector(center.x(), center.y()) , angle);
}
开发者ID:absorb-it,项目名称:LibreCAD,代码行数:3,代码来源:doc_plugin_interface.cpp

示例15: paintValueTracker

void paintValueTracker( PaintContext* ctx, const ValueTrackerAttributes& vt, const QPointF& at )
{
    CartesianCoordinatePlane* plane = qobject_cast<CartesianCoordinatePlane*>( ctx->coordinatePlane() );
    if ( !plane )
        return;

    DataDimensionsList gridDimensions = ctx->coordinatePlane()->gridDimensionsList();
    const QPointF bottomLeft( ctx->coordinatePlane()->translate(
                              QPointF( plane->isHorizontalRangeReversed() ?
                                           gridDimensions.at( 0 ).end :
                                           gridDimensions.at( 0 ).start,
                                       plane->isVerticalRangeReversed() ?
                                           gridDimensions.at( 1 ).end :
                                           gridDimensions.at( 1 ).start ) ) );
    const QPointF topRight( ctx->coordinatePlane()->translate(
                            QPointF( plane->isHorizontalRangeReversed() ?
                                         gridDimensions.at( 0 ).start :
                                         gridDimensions.at( 0 ).end,
                                     plane->isVerticalRangeReversed() ?
                                         gridDimensions.at( 1 ).start :
                                         gridDimensions.at( 1 ).end ) ) );
    const QPointF markerPoint = at;

    QPointF startPoint;
    if ( vt.orientations() & Qt::Horizontal ) {
        startPoint = QPointF( bottomLeft.x(), at.y() );
    } else {
        startPoint = QPointF( at.x(), topRight.y() );
    }

    QPointF endPoint;
    if ( vt.orientations() & Qt::Vertical ) {
        endPoint = QPointF( at.x(), bottomLeft.y() );
    } else {
        endPoint = QPointF( topRight.x(), at.y() );
    }

    const QSizeF markerSize = vt.markerSize();
    const QRectF ellipseMarker = QRectF( at.x() - markerSize.width() / 2,
                                         at.y() - markerSize.height() / 2,
                                         markerSize.width(), markerSize.height() );

    QPointF startMarker[3];
    if ( vt.orientations() & Qt::Horizontal ) {
        startMarker[0] = startPoint + QPointF( 0,  markerSize.height() / 2 );
        startMarker[1] = startPoint + QPointF( markerSize.width() / 2, 0 );
        startMarker[2] = startPoint - QPointF( 0, markerSize.height() / 2 );
    } else {
        startMarker[0] = startPoint + QPointF( 0, markerSize.height() / 2 );
        startMarker[1] = startPoint + QPointF( markerSize.width() / 2, 0 );
        startMarker[2] = startPoint - QPointF( markerSize.width() / 2, 0 );
    }

    QPointF endMarker[3];

    if ( vt.orientations() & Qt::Vertical ) {
        endMarker[0] = endPoint + QPointF( markerSize.width() / 2, 0 );
        endMarker[1] = endPoint - QPointF( 0, markerSize.height() / 2 );
        endMarker[2] = endPoint - QPointF( markerSize.width() / 2, 0 );
    } else {
        endMarker[0] = endPoint + QPointF( 0,  markerSize.width() / 2 );
        endMarker[1] = endPoint - QPointF( 0, markerSize.height() / 2 );
        endMarker[2] = endPoint - QPointF( markerSize.width() / 2, 0 );
    }

    QPointF topLeft = startPoint;
    QPointF bottomRightOffset = endPoint - topLeft;
    QSizeF size( bottomRightOffset.x(), bottomRightOffset.y() );
    QRectF area( topLeft, size );

    PainterSaver painterSaver( ctx->painter() );
    ctx->painter()->setPen( PrintingParameters::scalePen( vt.linePen() ) );
    ctx->painter()->setBrush( QBrush() );
    ctx->painter()->drawLine( markerPoint, startPoint );
    ctx->painter()->drawLine( markerPoint, endPoint );

    ctx->painter()->fillRect( area, vt.areaBrush() );

    ctx->painter()->setPen( PrintingParameters::scalePen( vt.markerPen() ) );
    ctx->painter()->setBrush( vt.markerBrush() );
    ctx->painter()->drawEllipse( ellipseMarker );

    ctx->painter()->setPen( PrintingParameters::scalePen( vt.arrowBrush().color() ) );
    ctx->painter()->setBrush( vt.arrowBrush() );
    ctx->painter()->drawPolygon( startMarker, 3 );
    ctx->painter()->drawPolygon( endMarker, 3 );
}
开发者ID:Wushaowei001,项目名称:mksPlanner,代码行数:87,代码来源:PaintingHelpers_p.cpp


注:本文中的QPointF::x方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。