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


C++ QTransform::map方法代码示例

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


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

示例1: paintEvent

            void TruckMapWidget::paintEvent(QPaintEvent *evt) {
                Lock l(m_scaleFactorMutex);

                QPainter painter(this);
                painter.setRenderHint(QPainter::Antialiasing);

                const double scaleMax = 5;
                const double scaleMin = 1e-4;
                const double offsetViewMaxFactor = 8;

                if (m_scaleFactor < scaleMin) {
                    m_scaleFactor = scaleMin;
                } else if (m_scaleFactor > scaleMax) {
                    m_scaleFactor = scaleMax;
                }

                // White background.
                painter.fillRect(evt->rect(), QBrush(Qt::white));

                // Variables for displaying labels on the map.
                QString description;
                QPointF pt_description;
                QRectF rect_description;
                QFont fontSettings = this->font();

                QPen pen;

                // Map coordinate system transformation according to DIN 70000: x = 12am, y = 9am --> m_rotation = +90 (http://www.isupia.de/download/Fahrdynamische%20Größen.pdf)
                QTransform transformationDIN70000;
                transformationDIN70000.translate(evt->rect().width() / 2, evt->rect().height() / 2);
                transformationDIN70000.scale(m_scaleFactor, -m_scaleFactor);
                transformationDIN70000.rotate(m_rotation);

                // Transformation into the regular coordinate system.
                QTransform transformationCartesianCoordinateSystem;
                transformationCartesianCoordinateSystem.translate(evt->rect().width() / 2, evt->rect().height() / 2);
                transformationCartesianCoordinateSystem.scale(m_scaleFactor, -m_scaleFactor);
                transformationCartesianCoordinateSystem.rotate(m_rotation - 90);

                // Transformation into the regular coordinate system for descriptions.
                QTransform transformationCartesianCoordinateSystemForDescriptions;
                transformationCartesianCoordinateSystemForDescriptions.translate(evt->rect().width() / 2, evt->rect().height() / 2);
                transformationCartesianCoordinateSystemForDescriptions.scale(1, 1);
                transformationCartesianCoordinateSystemForDescriptions.rotate(m_rotation - 90);

                // Transformation for descriptions label in image coordinates.
                QTransform descriptionTrans;
                descriptionTrans.translate(0, 0);
                descriptionTrans.scale(1, 1);
                descriptionTrans.rotate(0);

                // Setup fonts.
                fontSettings.setPointSize(10);
                painter.setFont(fontSettings);

                // Setup axes parameters.
                const double scaleMultiplier = ceil((1 / ((m_scaleFactor * 100) / 50)));
                const double step = 100 * scaleMultiplier;
                const double zeroAxisWidth = 3;
                const QColor zeroAxisColor = Qt::black;
                const QColor gridAxisColor = Qt::gray;
                const QColor textColor = QPalette::Foreground;
                const double xStepFact = ceil(width() * offsetViewMaxFactor / step / m_scaleFactor);
                const double yStepFact = ceil(height() * offsetViewMaxFactor / step / m_scaleFactor);

                // Draw X-axes.
                for (double i = -yStepFact * step;i < yStepFact * step;i += step) {
                    if ((int)(i / step) % 2) {
                        painter.setPen(gridAxisColor);
                    }
                    else {
                        description.sprintf("%.0f", i/1000.0);

                        pt_description.setY(i);
                        painter.setTransform(descriptionTrans);
                        pt_description = transformationCartesianCoordinateSystem.map(pt_description);
                        pt_description.setX(10);
                        pt_description.setY(pt_description.y() - 5);

                        painter.setPen(QPen(textColor));
                        painter.drawText(pt_description, description);

                        if (fabs(i) < 1e-5) {
                            pen.setWidthF(zeroAxisWidth / m_scaleFactor);
                            pen.setColor(zeroAxisColor);
                        }
                        else {
                            pen.setWidth(0);
                        }
                        painter.setPen(pen);
                    }
                    painter.setTransform(transformationDIN70000);
                    painter.drawLine(-xStepFact * step, i, xStepFact * step, i);
                }

                // Draw Y-axis segments
                for (double i = -xStepFact * step;i < xStepFact * step;i += step) {
                    if ((int)(i / step) % 2) {
                        painter.setPen(gridAxisColor);
                    }
//.........这里部分代码省略.........
开发者ID:andriuskinas,项目名称:OpenDaVINCI,代码行数:101,代码来源:TruckMapWidget.cpp

示例2: getVisualBoundingRect

void PageItem_Line::getVisualBoundingRect(double * x1, double * y1, double * x2, double * y2) const
{
	double minx =  std::numeric_limits<double>::max();
	double miny =  std::numeric_limits<double>::max();
	double maxx = -std::numeric_limits<double>::max();
	double maxy = -std::numeric_limits<double>::max();
	double extraSpace = 0.0;
	if (NamedLStyle.isEmpty())
	{
		if ((lineColor() != CommonStrings::None) || (!patternStrokeVal.isEmpty()) || (GrTypeStroke > 0))
		{
			extraSpace = m_lineWidth / 2.0;
			if ((extraSpace == 0) && m_Doc->view()) // Hairline case
				extraSpace = 0.5 / m_Doc->view()->scale();
		}
		if ((!patternStrokeVal.isEmpty()) && (m_Doc->docPatterns.contains(patternStrokeVal)) && (patternStrokePath))
		{
			ScPattern *pat = &m_Doc->docPatterns[patternStrokeVal];
			QTransform mat;
			mat.rotate(patternStrokeRotation);
			mat.scale(patternStrokeScaleX / 100.0, patternStrokeScaleY / 100.0);
			QRectF p1R = QRectF(0, 0, pat->width / 2.0, pat->height / 2.0);
			QRectF p2R = mat.map(p1R).boundingRect();
			extraSpace = p2R.height();
		}
	}
	else
	{
		multiLine ml = m_Doc->MLineStyles[NamedLStyle];
		const SingleLine& sl = ml.last();
		if (sl.Color != CommonStrings::None)
		{
			extraSpace = sl.Width / 2.0;
			if ((extraSpace == 0) && m_Doc->view()) // Hairline case
				extraSpace = 0.5 / m_Doc->view()->scale();
		}
	}
	if (m_rotation != 0)
	{
		FPointArray pb;
		pb.resize(0);
		pb.addPoint(FPoint(0.0,           -extraSpace, xPos(), yPos(), m_rotation, 1.0, 1.0));
		pb.addPoint(FPoint(visualWidth(), -extraSpace, xPos(), yPos(), m_rotation, 1.0, 1.0));
		pb.addPoint(FPoint(visualWidth(), +extraSpace, xPos(), yPos(), m_rotation, 1.0, 1.0));
		pb.addPoint(FPoint(0.0,           +extraSpace, xPos(), yPos(), m_rotation, 1.0, 1.0));
		for (uint pc = 0; pc < 4; ++pc)
		{
			minx = qMin(minx, pb.point(pc).x());
			miny = qMin(miny, pb.point(pc).y());
			maxx = qMax(maxx, pb.point(pc).x());
			maxy = qMax(maxy, pb.point(pc).y());
		}
		*x1 = minx;
		*y1 = miny;
		*x2 = maxx;
		*y2 = maxy;
	}
	else
	{
		*x1 = m_xPos;
		*y1 = m_yPos - extraSpace;
		*x2 = m_xPos + visualWidth();
		*y2 = m_yPos + extraSpace;
	}

	QRectF totalRect(QPointF(*x1, *y1), QPointF(*x2, *y2));
	if (m_startArrowIndex != 0)
	{
		QTransform arrowTrans;
		FPointArray arrow = m_Doc->arrowStyles().at(m_startArrowIndex-1).points.copy();
		arrowTrans.translate(m_xPos, m_yPos);
		arrowTrans.rotate(m_rotation);
		arrowTrans.translate(0, 0);
		arrowTrans.scale(m_startArrowScale / 100.0, m_startArrowScale / 100.0);
		if (NamedLStyle.isEmpty())
		{
			if (m_lineWidth != 0.0)
				arrowTrans.scale(m_lineWidth, m_lineWidth);
		}
		else
		{
			multiLine ml = m_Doc->MLineStyles[NamedLStyle];
			if (ml[ml.size()-1].Width != 0.0)
				arrowTrans.scale(ml[ml.size()-1].Width, ml[ml.size()-1].Width);
		}
		arrowTrans.scale(-1,1);
		arrow.map(arrowTrans);
		FPoint minAr = getMinClipF(&arrow);
		FPoint maxAr = getMaxClipF(&arrow);
		totalRect = totalRect.united(QRectF(QPointF(minAr.x(), minAr.y()), QPointF(maxAr.x(), maxAr.y())));
	}
	if (m_endArrowIndex != 0)
	{
		QTransform arrowTrans;
		FPointArray arrow = m_Doc->arrowStyles().at(m_endArrowIndex-1).points.copy();
		arrowTrans.translate(m_xPos, m_yPos);
		arrowTrans.rotate(m_rotation);
		arrowTrans.translate(m_width, 0);
		arrowTrans.scale(m_endArrowScale / 100.0, m_endArrowScale / 100.0);
		if (NamedLStyle.isEmpty())
//.........这里部分代码省略.........
开发者ID:luzpaz,项目名称:scribus,代码行数:101,代码来源:pageitem_line.cpp

示例3: drawPainterPath


//.........这里部分代码省略.........
          TechDrawGeometry::Circle *geom = static_cast<TechDrawGeometry::Circle *>(baseGeom);

          double x = geom->center.fX - geom->radius;
          double y = geom->center.fY - geom->radius;

          path.addEllipse(x, y, geom->radius * 2, geom->radius * 2);            //[email protected](x,y) radx,rady
          //Base::Console().Message("TRACE -drawPainterPath - making an CIRCLE @(%.3f,%.3f) R:%.3f\n",x, y, geom->radius);

        } break;
        case TechDrawGeometry::ARCOFCIRCLE: {
          TechDrawGeometry::AOC  *geom = static_cast<TechDrawGeometry::AOC *>(baseGeom);

          //double x = geom->center.fX - geom->radius;
          //double y = geom->center.fY - geom->radius;
          pathArc(path, geom->radius, geom->radius, 0., geom->largeArc, geom->cw,
                  geom->endPnt.fX, geom->endPnt.fY,
                  geom->startPnt.fX, geom->startPnt.fY);
          //Base::Console().Message("TRACE -drawPainterPath - making an ARCOFCIRCLE @(%.3f,%.3f) R:%.3f\n",x, y, geom->radius);
        } break;
        case TechDrawGeometry::ELLIPSE: {
          TechDrawGeometry::Ellipse *geom = static_cast<TechDrawGeometry::Ellipse *>(baseGeom);

          // Calculate start and end points as ellipse with theta = 0 and pi
          double startX = geom->center.fX + geom->major * cos(geom->angle),
                 startY = geom->center.fY + geom->major * sin(geom->angle),
                 endX = geom->center.fX - geom->major * cos(geom->angle),
                 endY = geom->center.fY - geom->major * sin(geom->angle);

          pathArc(path, geom->major, geom->minor, geom->angle, false, false,
                  endX, endY, startX, startY);

          pathArc(path, geom->major, geom->minor, geom->angle, false, false,
                  startX, startY, endX, endY);

          //Base::Console().Message("TRACE -drawPainterPath - making an ELLIPSE @(%.3f,%.3f) R1:%.3f R2:%.3f\n",x, y, geom->major, geom->minor);
        } break;
        case TechDrawGeometry::ARCOFELLIPSE: {
          TechDrawGeometry::AOE *geom = static_cast<TechDrawGeometry::AOE *>(baseGeom);

          pathArc(path, geom->major, geom->minor, geom->angle, geom->largeArc, geom->cw,
                        geom->endPnt.fX, geom->endPnt.fY,
                        geom->startPnt.fX, geom->startPnt.fY);
          //Base::Console().Message("TRACE -drawPainterPath - making an ARCOFELLIPSE R1:%.3f R2:%.3f From: (%.3f,%.3f) To: (%.3f,%.3f)\n",geom->major, geom->minor,geom->startPnt.fX, geom->startPnt.fY,geom->endPnt.fX, geom->endPnt.fY);

        } break;
        case TechDrawGeometry::BSPLINE: {
          TechDrawGeometry::BSpline *geom = static_cast<TechDrawGeometry::BSpline *>(baseGeom);

          std::vector<TechDrawGeometry::BezierSegment>::const_iterator it = geom->segments.begin();

          // Move painter to the beginning of our first segment
          path.moveTo(it->pnts[0].fX, it->pnts[0].fY);
          //Base::Console().Message("TRACE -drawPainterPath - making an BSPLINE From: (%.3f,%.3f)\n",it->pnts[0].fX,it->pnts[0].fY);

          for ( ; it != geom->segments.end(); ++it) {
              // At this point, the painter is either at the beginning
              // of the first segment, or end of the last
              if ( it->poles == 2 ) {
                  // Degree 1 bezier = straight line...
                  path.lineTo(it->pnts[1].fX, it->pnts[1].fY);

              } else if ( it->poles == 3 ) {
                  path.quadTo(it->pnts[1].fX, it->pnts[1].fY,
                              it->pnts[2].fX, it->pnts[2].fY);

              } else if ( it->poles == 4 ) {
                  path.cubicTo(it->pnts[1].fX, it->pnts[1].fY,
                               it->pnts[2].fX, it->pnts[2].fY,
                               it->pnts[3].fX, it->pnts[3].fY);
              } else {                                                 //can only handle lines,quads,cubes
                  Base::Console().Error("Bad pole count (%d) for BezierSegment of BSpline geometry\n",it->poles);
                  path.lineTo(it->pnts[1].fX, it->pnts[1].fY);         //show something for debugging
              }
          }
        } break;
        case TechDrawGeometry::GENERIC: {
          TechDrawGeometry::Generic *geom = static_cast<TechDrawGeometry::Generic *>(baseGeom);

          path.moveTo(geom->points[0].fX, geom->points[0].fY);
          std::vector<Base::Vector2D>::const_iterator it = geom->points.begin();
          //Base::Console().Message("TRACE -drawPainterPath - making an GENERIC From: (%.3f,%.3f)\n",geom->points[0].fX, geom->points[0].fY);
          for(++it; it != geom->points.end(); ++it) {
              path.lineTo((*it).fX, (*it).fY);
              //Base::Console().Message(">>>> To: (%.3f,%.3f)\n",(*it).fX, (*it).fY);
          }
        } break;
        default:
          Base::Console().Error("Error - drawPainterPath - UNKNOWN geomType: %d\n",baseGeom->geomType);
          break;
      }

    double rot = getViewObject()->Rotation.getValue();
    if (rot) {
        QTransform t;
        t.rotate(-rot);
        path = t.map(path);
    }

    return path;
}
开发者ID:joseprous,项目名称:FreeCAD,代码行数:101,代码来源:QGIViewPart.cpp

示例4: computeBezier

void Tie::computeBezier(SlurSegment* ss, QPointF p6o)
      {
      qreal _spatium  = spatium();
      qreal shoulderW;              // height as fraction of slur-length
      qreal shoulderH;

      //
      // pp1      start of slur
      // pp2      end of slur
      // pp3      bezier 1
      // pp4      bezier 2
      // pp5      drag
      // pp6      shoulder
      //
      QPointF pp1 = ss->ups[GRIP_START].p + ss->ups[GRIP_START].off * _spatium;
      QPointF pp2 = ss->ups[GRIP_END].p   + ss->ups[GRIP_END].off   * _spatium;

      QPointF p2 = pp2 - pp1;       // normalize to zero
      if (p2.x() == 0.0) {
            qDebug("zero tie");
            return;
            }

      qreal sinb = atan(p2.y() / p2.x());
      QTransform t;
      t.rotateRadians(-sinb);
      p2  = t.map(p2);
      p6o = t.map(p6o);

      double smallH = 0.38;
      qreal d   = p2.x() / _spatium;
      shoulderH = d * 0.4 * smallH;
      if (shoulderH > 1.3)            // maximum tie shoulder height
            shoulderH = 1.3;
      shoulderH *= _spatium;
      shoulderW = .6;

      shoulderH -= p6o.y();

      if (!up())
            shoulderH = -shoulderH;

      qreal c    = p2.x();
      qreal c1   = (c - c * shoulderW) * .5 + p6o.x();
      qreal c2   = c1 + c * shoulderW       + p6o.x();

      QPointF p5 = QPointF(c * .5, 0.0);

      QPointF p3(c1, -shoulderH);
      QPointF p4(c2, -shoulderH);

      qreal w = (score()->styleS(ST_SlurMidWidth).val() - score()->styleS(ST_SlurEndWidth).val()) * _spatium;
      QPointF th(0.0, w);    // thickness of slur

      QPointF p3o = p6o + t.map(ss->ups[GRIP_BEZIER1].off * _spatium);
      QPointF p4o = p6o + t.map(ss->ups[GRIP_BEZIER2].off * _spatium);

      if(!p6o.isNull()) {
            QPointF p6i = t.inverted().map(p6o) / _spatium;
            ss->ups[GRIP_BEZIER1].off += p6i ;
            ss->ups[GRIP_BEZIER2].off += p6i;
            }

      //-----------------------------------calculate p6
      QPointF pp3  = p3 + p3o;
      QPointF pp4  = p4 + p4o;
      QPointF ppp4 = pp4 - pp3;

      qreal r2 = atan(ppp4.y() / ppp4.x());
      t.reset();
      t.rotateRadians(-r2);
      QPointF p6  = QPointF(t.map(ppp4).x() * .5, 0.0);

      t.rotateRadians(2 * r2);
      p6 = t.map(p6) + pp3 - p6o;
      //-----------------------------------

      ss->path = QPainterPath();
      ss->path.moveTo(QPointF());
      ss->path.cubicTo(p3 + p3o - th, p4 + p4o - th, p2);
      if (lineType() == 0)
            ss->path.cubicTo(p4 +p4o + th, p3 + p3o + th, QPointF());

      th = QPointF(0.0, 3.0 * w);
      ss->shapePath = QPainterPath();
      ss->shapePath.moveTo(QPointF());
      ss->shapePath.cubicTo(p3 + p3o - th, p4 + p4o - th, p2);
      ss->shapePath.cubicTo(p4 +p4o + th, p3 + p3o + th, QPointF());

      // translate back
      t.reset();
      t.translate(pp1.x(), pp1.y());
      t.rotateRadians(sinb);
      ss->path                 = t.map(ss->path);
      ss->shapePath            = t.map(ss->shapePath);
      ss->ups[GRIP_BEZIER1].p  = t.map(p3);
      ss->ups[GRIP_BEZIER2].p  = t.map(p4);
      ss->ups[GRIP_END].p      = t.map(p2) - ss->ups[GRIP_END].off * _spatium;
      ss->ups[GRIP_DRAG].p     = t.map(p5);
      ss->ups[GRIP_SHOULDER].p = t.map(p6);
//.........这里部分代码省略.........
开发者ID:33akash,项目名称:MuseScore,代码行数:101,代码来源:tie.cpp

示例5: digitalPattern_Rotate

bool DataConverter::digitalPattern_Rotate(QPolygonF &points, qreal angle)
{
	if (angle == 0.0)
		return true;

	if (angle < -180.0 || angle > 180.0)
	{
		qDebug("[DataConverter::digitalPattern_Rotate] Error: Angle: [%f]", angle);
		return false;
	}

	if (points.size() < 10)
	{
		qDebug("[DataConverter::digitalPattern_Rotate] Error: Polygon Point Count: [%d]", points.size());
		return false;
	}

	//
	QTransform transform;

	transform.rotate(angle);

	points = transform.map(points);

	//
	int bottomIndex = 0;

	{
		qreal tmpX = -9999.99;

		for (int i = 0; i < points.size(); i++)
		{
			if (points.at(i).y() < 0.0)
				continue;

			if (points.at(i).x() > 0.0)
				continue;

			if (points.at(i).x() > tmpX)
			{
				tmpX = points.at(i).x();
				bottomIndex = i;
			}
		}
	}

	qDebug("** bottomIndex: [%d]", bottomIndex);

	if (bottomIndex > 0)
	{
		QPointF tmpPoint;

		for (int i = points.size() - 1; i >= bottomIndex; i--)
		{
			tmpPoint = points.last();
			points.pop_back();
			points.push_front(tmpPoint);
		}
	}

	return true;
}
开发者ID:new5244,项目名称:qt,代码行数:62,代码来源:dataconverter.cpp

示例6: mousePressEvent

void CanvasMode_Rotate::mousePressEvent(QMouseEvent *m)
{
	const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
	m_canvasPressCoord = mousePointDoc;
	
	double Rxp = 0,  Ryp = 0;
	PageItem *currItem;
	m_canvas->PaintSizeRect(QRect());
	QRect tx;
	QTransform pm;
	m_canvas->m_viewMode.m_MouseButtonPressed = true;
	m_canvas->m_viewMode.operItemMoving = false;
	m_view->HaveSelRect = false;
	m_doc->leaveDrag = false;
	m->accept();
	m_view->registerMousePress(m->globalPos());
	QRect mpo(m->x()-m_doc->guidesPrefs().grabRadius, m->y()-m_doc->guidesPrefs().grabRadius, m_doc->guidesPrefs().grabRadius*2, m_doc->guidesPrefs().grabRadius*2);
	Rxp  = m_doc->ApplyGridF(m_canvasPressCoord).x();
	m_canvasPressCoord.setX( qRound(Rxp) );
	Ryp  = m_doc->ApplyGridF(m_canvasPressCoord).y();
	m_canvasPressCoord.setY( qRound(Ryp) );
	if (m->button() == Qt::MidButton)
	{
		m_view->MidButt = true;
		if (m->modifiers() & Qt::ControlModifier)
			m_view->DrawNew();
		return;
	}
	if (m->button() != Qt::LeftButton)
		return;
	if (GetItem(&currItem))
	{
		m_inItemRotation = true;
		m_oldRotMode   = m_rotMode   = m_doc->RotMode();
		m_oldRotCenter = m_rotCenter = m_view->RCenter;
		if (m_doc->m_Selection->isMultipleSelection())
		{
			double gx, gy, gh, gw;
			double gxR, gyR, ghR, gwR;
			m_view->getGroupRectScreen(&gx, &gy, &gw, &gh);
			m_doc->m_Selection->getGroupRect(&gxR, &gyR, &gwR, &ghR);
			if (QRect(static_cast<int>(gx), static_cast<int>(gy), static_cast<int>(gw), static_cast<int>(gh)).intersects(mpo))
			{
				m_rotMode   = 2;
				m_rotCenter = FPoint(gxR+gwR/2.0, gyR+ghR/2.0);
				if (QRect(static_cast<int>(gx+gw)-6, static_cast<int>(gy+gh)-6, 6, 6).intersects(mpo))
				{
					m_rotCenter = FPoint(gxR, gyR);
					m_rotMode   = 0;
				}
				m_doc->RotMode  ( m_rotMode );
				m_view->RCenter = m_rotCenter;
			}
			m_startAngle = xy2Deg(mousePointDoc.x() - m_view->RCenter.x(), mousePointDoc.y() - m_view->RCenter.y());
			m_view->oldW = m_startAngle;
		}
		else
		{
			QTransform mat;
			m_canvas->Transform(currItem, mat);
			m_rotMode   = 2;
			m_rotCenter = FPoint(currItem->width()/2, currItem->height()/2, 0, 0, currItem->rotation(), 1, 1, false);
//			if (!currItem->asLine())
//			{
				if (QRegion(mat.map(QPolygon(QRect(0, 0, static_cast<int>(currItem->width()), static_cast<int>(currItem->height()))))).contains(mpo))
				{
					if (mat.mapRect(QRect(0, 0, 6, 6)).intersects(mpo))
					{
						m_rotCenter = FPoint(currItem->width(), currItem->height(), 0, 0, currItem->rotation(), 1, 1, false);
						m_rotMode   = 4;
					}
					else if (mat.mapRect(QRect(static_cast<int>(currItem->width())-6, 0, 6, 6)).intersects(mpo))
					{
						m_rotCenter = FPoint(0, currItem->height(), 0, 0, currItem->rotation(), 1, 1, false);
						m_rotMode   = 3;
					}
					else if (mat.mapRect(QRect(static_cast<int>(currItem->width())-6, static_cast<int>(currItem->height())-6, 6, 6)).intersects(mpo))
					{
						m_rotCenter = FPoint(0, 0);
						m_rotMode   = 0;
					}
					else if (mat.mapRect(QRect(0, static_cast<int>(currItem->height())-6, 6, 6)).intersects(mpo))
					{
						m_rotCenter = FPoint(currItem->width(), 0, 0, 0, currItem->rotation(), 1, 1, false);
						m_rotMode   = 1;
					}	
				}
				m_doc->RotMode  ( m_rotMode );
				m_view->RCenter = m_rotCenter;
//			}
			m_view->RCenter = m_rotCenter = FPoint(currItem->xPos()+ m_view->RCenter.x(), currItem->yPos()+ m_view->RCenter.y()); //?????
			m_view->oldW = m_startAngle = xy2Deg(mousePointDoc.x() - m_view->RCenter.x(), mousePointDoc.y() - m_view->RCenter.y());
		}
	}
}
开发者ID:andreas-vox,项目名称:ScribusCTL,代码行数:95,代码来源:canvasmode_rotate.cpp

示例7: drawPrimitive

void MiamStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *opt, QPainter *painter, const QWidget *widget) const
{
    switch (element) {
    // On Linux, don't fill the rectangular area where lives the PE_IndicatorBranch. Keep this area transparent
    // On Windows, this is the default behaviour
    case PE_PanelItemViewRow: {
        if (widget && widget->inherits("Playlist")) {
            QProxyStyle::drawPrimitive(element, opt, painter, widget);
        }
        break;
    }
    case PE_IndicatorTabClose: {
        if (opt->state.testFlag(State_MouseOver)) {
            QFileSelector fs;
            painter->drawPixmap(0, 0, 16, 16, QPixmap(fs.select(":/icons/config/close_tabs_hover.png")));
        } else {
            painter->drawPixmap(0, 0, 16, 16, QPixmap(":/icons/closeTabs"));
        }
        break;
    }
    case PE_IndicatorBranch: {

        // Draw sort indicator
        static const QPointF downArrow[3] = { QPointF(0.0, 0.0), QPointF(2.0, 0.0), QPointF(1.0, 1.0) };
        static const QPointF leftArrow[3] = { QPointF(0.0, 1.0), QPointF(1.0, 0.0), QPointF(1.0, 2.0) };
        static const QPointF rightArrow[3] = { QPointF(0.0, 0.0), QPointF(1.0, 1.0), QPointF(0.0, 2.0) };

        QTransform t;
        float ratio = opt->rect.width() / 4.0;
        //qDebug() << "ratio" << ratio << opt->rect << opt->fontMetrics.height();
        t.scale(ratio, ratio);

        QPolygonF arrow;
        if (QGuiApplication::isLeftToRight()) {
            QPolygonF right;
            right.append(t.map(rightArrow[0]));
            right.append(t.map(rightArrow[1]));
            right.append(t.map(rightArrow[2]));
            arrow = right;
        } else {
            QPolygonF left;
            left.append(t.map(leftArrow[0]));
            left.append(t.map(leftArrow[1]));
            left.append(t.map(leftArrow[2]));
            arrow = left;
        }

        if (opt->state.testFlag(State_Children)) {
            painter->save();
            if (opt->state.testFlag(State_MouseOver)) {
                painter->setPen(opt->palette.highlight().color());
                painter->setBrush(opt->palette.highlight().color().lighter());
            } else {
                painter->setPen(opt->palette.mid().color());
                painter->setBrush(Qt::NoBrush);
            }
            if (opt->state.testFlag(State_Open)) {
                QPolygonF down;
                down.append(t.map(downArrow[0]));
                down.append(t.map(downArrow[1]));
                down.append(t.map(downArrow[2]));
                painter->translate(opt->rect.x() + opt->rect.width() / 2 - down.boundingRect().width() / 2,
                                   opt->rect.y() + opt->rect.height() / 2 - down.boundingRect().height() / 2);
                painter->drawPolygon(down);
            } else {
                painter->translate(opt->rect.x() + opt->rect.width() / 2 - arrow.boundingRect().width() / 2,
                                   opt->rect.y() + opt->rect.height() / 2 - arrow.boundingRect().height() / 2);
                painter->drawPolygon(arrow);
            }
            painter->restore();
        }
        break;
    }
    case PE_PanelLineEdit: {
        QPen pen = opt->palette.window().color();
        QBrush brush = opt->palette.base();
        painter->setPen(pen);
        painter->setBrush(brush);
        painter->drawRect(widget->rect().adjusted(0, 0, -1, -1));
        break;
    }
    case PE_FrameGroupBox: {
        QPen pen = opt->palette.window().color();
        QBrush brush = opt->palette.base();
        painter->setPen(pen);
        painter->setBrush(brush);
        //painter->drawRect(widget->rect());
        QProxyStyle::drawPrimitive(element, opt, painter, widget);

        break;
    }
    case PE_FrameStatusBarItem:
    case PE_FrameButtonTool:
    case PE_FrameButtonBevel:
    case PE_FrameFocusRect:
        break;
    case PE_FrameMenu: {
        QPen pen = opt->palette.mid().color();
        QBrush brush = opt->palette.window();
        painter->setPen(pen);
//.........这里部分代码省略.........
开发者ID:VengefulVeggie,项目名称:Miam-Player,代码行数:101,代码来源:miamstyle.cpp

示例8: main

int main(int argc, char **argv)
{
  if (argc < 4) {
    fprintf(stderr, "import <maps.json> <map id> <file.tif>\n");
    return -1;
  }

  OGRRegisterAll();
  GDALAllRegister();

  QFile rootFile(argv[1]);
  QString mapId(argv[2]);
  QFileInfo filename(argv[3]);

  RootData rootData(NULL);
  Map *map = rootData.maps()[mapId];

  Projection *pjGeo = Geographic::getProjection(NAD27);
  Projection *pj = map->projection();


  readQuadIndex(0, "/Users/hawkinsp/geo/drg/index/drg100.shp", "drg100", pj);
  readQuadIndex(1, "/Users/hawkinsp/geo/drg/index/drg24.shp", "drg24", pj);

  // Index information seems buggy for these quads -- just use the regular grid.
  quads.remove("o37122g4"); // San Francisco North
  quads.remove("o37122g5"); // Point Bonita




  GDALDataset *ds = (GDALDataset *)GDALOpen(filename.filePath().toLatin1().data(),
                                            GA_ReadOnly);
  if (!ds) {
    fprintf(stderr, "ERROR: Could not open dataset.\n");
    return -1;
  }

  const char *proj = ds->GetProjectionRef();

  Quad quad;
  getQuadInfo(filename, pj, quad);

  // Read projection
  OGRSpatialReference srs;
  srs.importFromWkt((char **)&proj);

  // Size of the DRG
  QSize drgSize = QSize(ds->GetRasterXSize(), ds->GetRasterYSize());
  printf("DRG id: %s, name %s, size %dx%d\n", quad.id.toLatin1().data(),
         quad.name.toLatin1().data(), drgSize.width(), drgSize.height());

  // ------------------------------------------
  // Read geotransform coefficients. The geotransform describe the mapping from
  // DRG image space to projection space.
  double geoTransformCoeff[6];
  ds->GetGeoTransform(geoTransformCoeff);

  // Top left coordinate of the drg in projection space
  QPointF fProjTopLeft = QPointF(geoTransformCoeff[0], geoTransformCoeff[3]);

  // Size of a drg pixel in projection space
  QSizeF fPixelSize = QSizeF(geoTransformCoeff[1], geoTransformCoeff[5]);

  // Check Y pixel size is the negation of the X pixel size
  if (fabs(fPixelSize.width() + fPixelSize.height()) >= epsilon) {
    fprintf(stderr, "Invalid pixel sizes\n");
    return -1;
  }

  // We assume the geotransform consists of only translation and scaling. 
  // We'd need to do a more general image transformation to handle shearing.
  if (fabs(geoTransformCoeff[2]) >= epsilon 
      || fabs(geoTransformCoeff[4]) >= epsilon) {
    fprintf(stderr, "ERROR: DRG geotransform has shear component.\n");
    return -1;
  }

  // Transforms from drg space to projection space and vice versa
  QTransform drgProjTransform;
  drgProjTransform.translate(fProjTopLeft.x(), fProjTopLeft.y());
  drgProjTransform.scale(fPixelSize.width(), fPixelSize.height());
  QTransform projDrgTransform = drgProjTransform.inverted();


  // Size of the DRG in projection space
  QSizeF fProjSize = QSizeF(qreal(ds->GetRasterXSize()) * fPixelSize.width(),
                            qreal(ds->GetRasterYSize()) * fPixelSize.height());
  QRectF projRect = QRectF(fProjTopLeft, fProjSize);

  // Rectangle covered by the entire map image
  QRectF mapRect = map->projToMap().mapRect(projRect);

  printf("Map Rect: %lf %lf %lf %lf\n", mapRect.left(), mapRect.top(),
         mapRect.right(), mapRect.bottom());


  // Compute the initial scale factor and tile level
  QSizeF mapPixelSize = map->mapPixelSize();
  assert(mapPixelSize.width() + mapPixelSize.height() < epsilon);
//.........这里部分代码省略.........
开发者ID:djdarkbeat,项目名称:ZTopo,代码行数:101,代码来源:import.cpp

示例9: drawScrollBar

/// XXX
void MiamStyle::drawScrollBar(QPainter *p, const QWidget *widget) const
{
    QStyleOptionSlider scrollbar;
    scrollbar.palette = QApplication::palette();

    const QScrollBar *sc = qobject_cast<const QScrollBar *>(widget);
    scrollbar.initFrom(sc);


    QRect subLineRect = QApplication::style()->subControlRect(QStyle::CC_ScrollBar, &scrollbar, QStyle::SC_ScrollBarSubLine, sc);
    QRect addLineRect = QApplication::style()->subControlRect(QStyle::CC_ScrollBar, &scrollbar, QStyle::SC_ScrollBarAddLine, sc);
    QRect sliderRect = QApplication::style()->subControlRect(QStyle::CC_ScrollBar, &scrollbar, QStyle::SC_ScrollBarSlider, sc);

    //qDebug() << subLineRect << sliderRect << addLineRect;


    if (sc->orientation() == Qt::Vertical) {
        subLineRect.adjust(0, 0, -1, 0);
        addLineRect.adjust(0, 0, -1, 0);
        sliderRect.adjust(0, 0, -1, 0);
    } else {
        subLineRect.adjust(0, 0, 0, -1);
        addLineRect.adjust(0, 0, 0, -1);
        sliderRect.adjust(0, 0, 0, -1);
    }

    p->setPen(Qt::NoPen);
    p->setBrush(scrollbar.palette.window());
    p->drawRect(sc->rect());

    p->setBrush(scrollbar.palette.base().color().darker(125));
    p->drawRect(sliderRect);

    // Highlight
    p->save();
    QPoint pos = sc->mapFromGlobal(QCursor::pos());
    p->setPen(scrollbar.palette.highlight().color());

    if (!sc->isSliderDown()) {
        p->setBrush(scrollbar.palette.highlight().color().lighter());
        if (subLineRect.contains(pos)) {
            p->drawRect(subLineRect);
        } else if (sliderRect.contains(pos)) {
            p->drawRect(sliderRect);
        } else if (addLineRect.contains(pos)) {
            p->drawRect(addLineRect);
        }
    } else {
        p->setBrush(scrollbar.palette.highlight().color());
        //if (_isDown == 0) {
        //	p->drawRect(subLineRect);
        //} else if (_isDown == 1) {
        //	p->drawRect(sliderRect);
        //} else if (_isDown == 2) {
        //	p->drawRect(addLineRect);
        //}
    }
    p->restore();

    // Draw sort indicator
    static const QPointF upArrow[3] = {
        QPointF(0.0, 1.0),
        QPointF(1.0, 0.0),
        QPointF(2.0, 1.0)
    };
    static const QPointF downArrow[3] = {
        QPointF(0.0, 0.0),
        QPointF(2.0, 0.0),
        QPointF(1.0, 1.0)
    };
    static const QPointF leftArrow[3] = {
        QPointF(0.0, 1.0),
        QPointF(1.0, 0.0),
        QPointF(1.0, 2.0)
    };
    static const QPointF rightArrow[3] = {
        QPointF(0.0, 0.0),
        QPointF(1.0, 1.0),
        QPointF(0.0, 2.0)
    };

    // Arrows
    p->save();
    if (scrollbar.palette.windowText().color().value() < 128) {
        p->setPen(scrollbar.palette.dark().color());
        p->setBrush(scrollbar.palette.dark());
    } else {
        p->setPen(scrollbar.palette.mid().color());
        p->setBrush(scrollbar.palette.mid());
    }

    QTransform t;
    float ratio = (float) subLineRect.height() / 4.0;
    t.scale(ratio, ratio);

    if (sc->orientation() == Qt::Vertical) {
        QPolygonF up, down;
        up.append(t.map(upArrow[0]));
        up.append(t.map(upArrow[1]));
//.........这里部分代码省略.........
开发者ID:VengefulVeggie,项目名称:Miam-Player,代码行数:101,代码来源:miamstyle.cpp

示例10: computeBezier

void Slur::computeBezier(SlurSegment* ss, QPointF p6o)
      {
      qreal _spatium  = spatium();
      qreal shoulderW;              // height as fraction of slur-length
      qreal shoulderH;
      //
      // p1 and p2 are the end points of the slur
      //
      QPointF pp1 = ss->ups[GRIP_START].p + ss->ups[GRIP_START].off * _spatium;
      QPointF pp2 = ss->ups[GRIP_END].p   + ss->ups[GRIP_END].off   * _spatium;

      QPointF p2 = pp2 - pp1;
      if ((p2.x() == 0.0) && (p2.y() == 0.0)) {
            qDebug("zero slur");
abort();
            Measure* m1 = startChord()->segment()->measure();
            Measure* m2 = endChord()->segment()->measure();
            Page* page = m1->system()->page();
            qDebug("   at tick %d in measure %d-%d page %d",
               m1->tick(), m1->no(), m2->no(), page->no());
            return;
            }

      qreal sinb = atan(p2.y() / p2.x());
      QTransform t;
      t.rotateRadians(-sinb);
      p2  = t.map(p2);
      p6o = t.map(p6o);

      double smallH = 0.5;
      qreal d = p2.x() / _spatium;
      if (d <= 2.0) {
            shoulderH = d * 0.5 * smallH * _spatium;
            shoulderW = .6;
            }
      else {
            qreal dd = log10(1.0 + (d - 2.0) * .5) * 2.0;
            if (dd > 3.0)
                  dd = 3.0;
            shoulderH = (dd + smallH) * _spatium;
            if (d > 18.0)
                  shoulderW = 0.7; // 0.8;
            else if (d > 10)
                  shoulderW = 0.6; // 0.7;
            else
                  shoulderW = 0.5; // 0.6;
            }

      shoulderH -= p6o.y();

      if (!up())
            shoulderH = -shoulderH;

      qreal c    = p2.x();
      qreal c1   = (c - c * shoulderW) * .5 + p6o.x();
      qreal c2   = c1 + c * shoulderW       + p6o.x();

      QPointF p5 = QPointF(c * .5, 0.0);

      QPointF p3(c1, -shoulderH);
      QPointF p4(c2, -shoulderH);

      qreal w = (score()->styleS(ST_SlurMidWidth).val() - score()->styleS(ST_SlurEndWidth).val()) * _spatium;
      if (((c2 - c1) / _spatium) <= _spatium)
            w *= .5;
      QPointF th(0.0, w);    // thickness of slur

      QPointF p3o = p6o + t.map(ss->ups[GRIP_BEZIER1].off * _spatium);
      QPointF p4o = p6o + t.map(ss->ups[GRIP_BEZIER2].off * _spatium);

      if(!p6o.isNull()) {
            QPointF p6i = t.inverted().map(p6o) / _spatium;
            ss->ups[GRIP_BEZIER1].off += p6i ;
            ss->ups[GRIP_BEZIER2].off += p6i;
            }

      //-----------------------------------calculate p6
      QPointF pp3  = p3 + p3o;
      QPointF pp4  = p4 + p4o;
      QPointF ppp4 = pp4 - pp3;

      qreal r2 = atan(ppp4.y() / ppp4.x());
      t.reset();
      t.rotateRadians(-r2);
      QPointF p6  = QPointF(t.map(ppp4).x() * .5, 0.0);

      t.rotateRadians(2 * r2);
      p6 = t.map(p6) + pp3 - p6o;
      //-----------------------------------

      ss->path = QPainterPath();
      ss->path.moveTo(QPointF());
      ss->path.cubicTo(p3 + p3o - th, p4 + p4o - th, p2);
      if (lineType() == 0)
            ss->path.cubicTo(p4 +p4o + th, p3 + p3o + th, QPointF());

      th = QPointF(0.0, 3.0 * w);
      ss->shapePath = QPainterPath();
      ss->shapePath.moveTo(QPointF());
      ss->shapePath.cubicTo(p3 + p3o - th, p4 + p4o - th, p2);
//.........这里部分代码省略.........
开发者ID:elerouxx,项目名称:MuseScore,代码行数:101,代码来源:slur.cpp

示例11: gradientBrush

int QPdfEnginePrivate::gradientBrush(const QBrush &b, const QMatrix &matrix, int *gStateObject)
{
    const QGradient *gradient = b.gradient();
    if (!gradient)
        return 0;

    QTransform inv = matrix.inverted();
    QPointF page_rect[4] = { inv.map(QPointF(0, 0)),
                             inv.map(QPointF(width_, 0)),
                             inv.map(QPointF(0, height_)),
                             inv.map(QPointF(width_, height_)) };

    bool opaque = b.isOpaque();

    QByteArray shader;
    QByteArray alphaShader;
    if (gradient->type() == QGradient::LinearGradient) {
        const QLinearGradient *lg = static_cast<const QLinearGradient *>(gradient);
        shader = QPdf::generateLinearGradientShader(lg, page_rect);
        if (!opaque)
            alphaShader = QPdf::generateLinearGradientShader(lg, page_rect, true);
    } else {
        // #############
        return 0;
    }
    int shaderObject = addXrefEntry(-1);
    write(shader);

    QByteArray str;
    QPdf::ByteStream s(&str);
    s << "<<\n"
        "/Type /Pattern\n"
        "/PatternType 2\n"
        "/Shading " << shaderObject << "0 R\n"
        "/Matrix ["
      << matrix.m11()
      << matrix.m12()
      << matrix.m21()
      << matrix.m22()
      << matrix.dx()
      << matrix.dy() << "]\n";
    s << ">>\n"
        "endobj\n";

    int patternObj = addXrefEntry(-1);
    write(str);
    currentPage->patterns.append(patternObj);

    if (!opaque) {
        bool ca = true;
        QGradientStops stops = gradient->stops();
        int a = stops.at(0).second.alpha();
        for (int i = 1; i < stops.size(); ++i) {
            if (stops.at(i).second.alpha() != a) {
                ca = false;
                break;
            }
        }
        if (ca) {
            *gStateObject = addConstantAlphaObject(stops.at(0).second.alpha());
        } else {
            int alphaShaderObject = addXrefEntry(-1);
            write(alphaShader);

            QByteArray content;
            QPdf::ByteStream c(&content);
            c << "/Shader" << alphaShaderObject << "sh\n";

            QByteArray form;
            QPdf::ByteStream f(&form);
            f << "<<\n"
                "/Type /XObject\n"
                "/Subtype /Form\n"
                "/BBox [0 0 " << width_ << height_ << "]\n"
                "/Group <</S /Transparency >>\n"
                "/Resources <<\n"
                "/Shading << /Shader" << alphaShaderObject << alphaShaderObject << "0 R >>\n"
                ">>\n";

            f << "/Length " << content.length() << "\n"
                ">>\n"
                "stream\n"
              << content
              << "endstream\n"
                "endobj\n";

            int softMaskFormObject = addXrefEntry(-1);
            write(form);
            *gStateObject = addXrefEntry(-1);
            xprintf("<< /SMask << /S /Alpha /G %d 0 R >> >>\n"
                    "endobj\n", softMaskFormObject);
            currentPage->graphicStates.append(*gStateObject);
        }
    }

    return patternObj;
}
开发者ID:BGmot,项目名称:Qt,代码行数:97,代码来源:qprintengine_pdf.cpp

示例12: drawMapObject

void IsometricRenderer::drawMapObject(QPainter *painter,
                                      const MapObject *object,
                                      const QColor &color) const
{
    painter->save();

    QPen pen(Qt::black);

    if (object->tile()) {
        const QPixmap &img = object->tile()->image();
        QPointF paintOrigin(-img.width() / 2, -img.height());
        paintOrigin += tileToPixelCoords(object->position()).toPoint();
        painter->drawPixmap(paintOrigin, img);

        const QFontMetrics fm = painter->fontMetrics();
        QString name = fm.elidedText(object->name(), Qt::ElideRight,
                                     img.width() + 2);
        if (!name.isEmpty())
            painter->drawText(QPoint(paintOrigin.x(), paintOrigin.y() - 5 + 1), name);

        pen.setStyle(Qt::SolidLine);
        painter->setPen(pen);
        painter->drawRect(QRectF(paintOrigin, img.size()));
        pen.setStyle(Qt::DotLine);
        pen.setColor(color);
        painter->setPen(pen);
        painter->drawRect(QRectF(paintOrigin, img.size()));

        if (!name.isEmpty())
            painter->drawText(QPoint(paintOrigin.x(), paintOrigin.y() - 5), name);

    } else {
        QColor brushColor = color;
        brushColor.setAlpha(50);
        QBrush brush(brushColor);

        pen.setJoinStyle(Qt::RoundJoin);
        pen.setCapStyle(Qt::RoundCap);
        pen.setWidth(2);

        painter->setPen(pen);
        painter->setRenderHint(QPainter::Antialiasing);

        // TODO: Draw the object name
        // TODO: Do something sensible to make null-sized objects usable

        switch (object->shape()) {
        case MapObject::Ellipse: {
            QPointF topLeft(tileToPixelCoords(object->bounds().topLeft()));
            QPointF bottomLeft(tileToPixelCoords(object->bounds().bottomLeft()));
            QPointF topRight(tileToPixelCoords(object->bounds().topRight()));

            const qreal headerX = bottomLeft.x();
            const qreal headerY = topLeft.y();

            QRectF rect(bottomLeft, topRight);

            const QFontMetrics fm = painter->fontMetrics();
            QString name = fm.elidedText(object->name(), Qt::ElideRight,
                                         rect.width() + 2);

            QPolygonF polygon = tileRectToPolygon(object->bounds());

            float tw = map()->tileWidth();
            float th = map()->tileHeight();
            QPointF transformScale(1, 1);
            if (tw > th)
                transformScale = QPointF(1, th/tw);
            else
                transformScale = QPointF(tw/th, 1);

            QPointF l1 = polygon.at(1) - polygon.at(0);
            QPointF l2 = polygon.at(3) - polygon.at(0);
            QTransform trans;
            trans.scale(transformScale.x(), transformScale.y());
            trans.rotate(45);
            QTransform iTrans = trans.inverted();
            QPointF l1x = iTrans.map(l1);
            QPointF l2x = iTrans.map(l2);
            QSizeF ellipseSize(l1x.manhattanLength(), l2x.manhattanLength());

            painter->save();
            painter->setPen(pen);
            painter->translate(polygon.at(0));
            painter->scale(transformScale.x(), transformScale.y());
            painter->rotate(45);
            painter->drawEllipse(QRectF(QPointF(0, 0), ellipseSize));
            painter->restore();

            painter->setBrush(Qt::NoBrush);
            painter->drawPolygon(polygon);

            if (!name.isEmpty())
                painter->drawText(QPoint(headerX, headerY - 5), name);

            pen.setColor(color);
            painter->setPen(pen);
            painter->setBrush(Qt::NoBrush);
            painter->translate(QPointF(0, -1));
            painter->drawPolygon(polygon);
//.........这里部分代码省略.........
开发者ID:brun01,项目名称:tiled,代码行数:101,代码来源:isometricrenderer.cpp

示例13: applyValues

void CanvasMode_EditArc::applyValues(double start, double end, double height, double width)
{
	PageItem *currItem = m_doc->m_Selection->itemAt(0);
	QRectF oldR = currItem->getBoundingRect().adjusted(-5, -5, 10, 10);
	PageItem_Arc *item = currItem->asArc();
	QTransform bb;
	bb.scale(height / width, 1.0);
	QLineF inp = QLineF(QPointF(width / 2.0, height / 2.0), QPointF(width, height / 2.0));
	inp.setAngle(start);
	QLineF res = bb.map(inp);
	inp.setAngle(end);
	QLineF ena = bb.map(inp);
	m_startAngle = res.angle();
	m_endAngle = ena.angle();
	double nSweep = m_endAngle - m_startAngle;
	if (nSweep < 0)
		nSweep += 360;
	double oldX = currItem->xPos();
	double oldY = currItem->yPos();
	double newX = oldX + m_centerPoint.x() - (width / 2.0);
	double newY = oldY + m_centerPoint.y() - (height / 2.0);
	item->setXYPos(newX, newY, true);
	FPointArray old = item->PoLine;
	QPainterPath pp;
	pp.moveTo(width / 2.0, height / 2.0);
	pp.arcTo(QRectF(0, 0, width, height), m_startAngle, nSweep);
	pp.closeSubpath();
	currItem->PoLine.fromQPainterPath(pp, true);
	FPoint wh = getMaxClipF(&currItem->PoLine);
	currItem->setWidthHeight(wh.x(),wh.y());
	m_doc->adjustItemSize(currItem);
	currItem->OldB2 = currItem->width();
	currItem->OldH2 = currItem->height();
	if (UndoManager::undoEnabled())
	{
		ScItemState<QPair<FPointArray, FPointArray> > *ss = new ScItemState<QPair<FPointArray, FPointArray> >(Um::EditArc,"",Um::IPolygon);
		ss->set("ARC");
		ss->set("OLD_WIDTH",item->arcWidth);
		ss->set("NEW_WIDTH",width);
		ss->set("OLD_XPOS",oldX);
		ss->set("OLD_YPOS",oldY);
		ss->set("OLD_HEIGHT",item->arcHeight);
		ss->set("NEW_HEIGHT",height);
		ss->set("OLD_START",item->arcStartAngle);
		ss->set("NEW_START",m_startAngle);
		ss->set("OLD_SWEEP",item->arcSweepAngle);
		ss->set("NEW_SWEEP",nSweep);
		ss->setItem(qMakePair(old,item->PoLine));
		ss->set("NEW_XPOS",item->xPos());
		ss->set("NEW_YPOS",item->yPos());
		undoManager->action(currItem,ss);
	}
	item->arcStartAngle = m_startAngle;
	item->arcSweepAngle = nSweep;
	item->arcWidth = width;
	item->arcHeight = height;
	m_startPoint = currItem->PoLine.pointQF(2);
	m_endPoint = currItem->PoLine.pointQF(currItem->PoLine.size() - 4);
	m_centerPoint = currItem->PoLine.pointQF(0);
	m_widthPoint = QPointF(m_centerPoint.x() - item->arcWidth / 2.0, m_centerPoint.y());
	m_heightPoint = QPointF(m_centerPoint.x(), m_centerPoint.y() - item->arcHeight / 2.0);
	m_doc->setRedrawBounding(currItem);
	QRectF newR(currItem->getBoundingRect());
	m_doc->regionsChanged()->update(newR.united(oldR));

//	QTransform itemMatrix = currItem->getTransform();
//	m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-currItem->width() / 2.0, -currItem->height() / 2.0, currItem->width(), currItem->height()));
}
开发者ID:nitramr,项目名称:scribus,代码行数:68,代码来源:canvasmode_editarc.cpp

示例14:

void QgsLineStringV2::transform( const QTransform& t )
{
  mCoords = t.map( mCoords );
}
开发者ID:GiordanoPezzola,项目名称:QGIS,代码行数:4,代码来源:qgslinestringv2.cpp

示例15: if


//.........这里部分代码省略.........
  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;
  if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_ROTATION ) )
  {
    context->setOriginalValueVariable( mAngle );
    rotation = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_ROTATION, *context, mAngle ).toDouble() + mLineAngle;
  }
  else if ( !qgsDoubleNear( mAngle + mLineAngle, 0.0 ) )
  {
    rotation = mAngle + mLineAngle;
  }
  rotation = -rotation; //rotation in Qt is counterclockwise
  if ( rotation )
    off = _rotatedOffset( off, rotation );

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

  if ( !qgsDoubleNear( rotation, 0.0 ) )
    t.rotate( rotation );

  double halfWidth = symbolWidth / 2.0;
  double halfHeight = symbolHeight / 2.0;

  if ( symbolName == "circle" )
  {
    if ( qgsDoubleNear( halfWidth, halfHeight ) )
    {
      QPointF pt( t.map( QPointF( 0, 0 ) ) );
      e.writeFilledCircle( layerName, oc, pt, halfWidth );
    }
    else
    {
      QgsPolyline line;
      line.reserve( 40 );
      double stepsize = 2 * M_PI / 40;
      for ( int i = 0; i < 39; ++i )
      {
        double angle = stepsize * i;
        double x = halfWidth * cos( angle );
        double y = halfHeight * sin( angle );
        QPointF pt( t.map( QPointF( x, y ) ) );
        line.push_back( pt );
      }
      //close ellipse with first point
      line.push_back( line.at( 0 ) );
      if ( mBrush.style() != Qt::NoBrush )
        e.writePolygon( QgsPolygon() << line, layerName, "SOLID", fc );
      if ( mPen.style() != Qt::NoPen )
        e.writePolyline( line, layerName, "CONTINUOUS", oc, outlineWidth );
    }
  }
  else if ( symbolName == "rectangle" )
  {
    QgsPolygon p( 1 );
    p[0].resize( 5 );
    p[0][0] = t.map( QPointF( -halfWidth, -halfHeight ) );
    p[0][1] = t.map( QPointF( halfWidth, -halfHeight ) );
    p[0][2] = t.map( QPointF( halfWidth, halfHeight ) );
    p[0][3] = t.map( QPointF( -halfWidth, halfHeight ) );
    p[0][4] = p[0][0];
开发者ID:asneuvon,项目名称:QGIS,代码行数:67,代码来源:qgsellipsesymbollayerv2.cpp


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