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


C++ QSizeF::height方法代码示例

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


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

示例1: setVisible

void StelDialog::setVisible(bool v)
{
	if (v)
	{
		QSize screenSize = StelMainView::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;
		}

		QGraphicsWidget* parent = qobject_cast<QGraphicsWidget*>(this->parent());
		dialog = new QDialog(NULL);
		// dialog->setParent(parent);
		StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui());
		Q_ASSERT(gui);
		//dialog->setAttribute(Qt::WA_OpaquePaintEvent, true);
		connect(dialog, SIGNAL(rejected()), this, SLOT(close()));
		createDialogContent();
		dialog->setStyleSheet(gui->getStelStyle().qtStyleSheet);

		// Ensure that tooltip get rendered in red in night mode.
		connect(&StelApp::getInstance(), SIGNAL(visionNightModeChanged(bool)), this, SLOT(updateNightModeProperty()));
		updateNightModeProperty();

		proxy = new CustomProxy(parent, Qt::Tool);
		proxy->setWidget(dialog);
		QSizeF size = proxy->size();

		// centre with dialog according to current window size.
		int newX = (int)((screenSize.width() - size.width())/2);
		int newY = (int)((screenSize.height() - size.height())/2);
		// Make sure that the window's title bar is accessible
		if (newY <-0)
			newY = 0;
		proxy->setPos(newX, newY);
		proxy->setWindowFrameMargins(2,0,2,2);
		// (this also changes the bounding rectangle size)

		// The caching is buggy on all plateforms with Qt 4.5.2
		proxy->setCacheMode(QGraphicsItem::ItemCoordinateCache);

		proxy->setZValue(100);
		StelMainView::getInstance().scene()->setActiveWindow(proxy);
		proxy->setFocus();
	}
	else
	{
开发者ID:gcalderone,项目名称:PlanetC,代码行数:61,代码来源:StelDialog.cpp

示例2: 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

示例3: paintLine

void PSV_TreeItem::paintLine(const QLineF &parentVLine, PSV_TreeItemData *itemData)
{
    if(itemData == NULL)
    {
        return;
    }
    QPointF point2 = parentVLine.p2();
    QList<PSV_TreeItemData*> children = itemData->children();
    int leafCount = itemData->leafCount();
    int count = children.count();
    QPen pen;
    pen.setColor(QColor(Qt::red));
    QPen pen_vLine;
    pen_vLine.setColor(QColor(Qt::blue));
    QPen pen_hLine;
    QString tempText = itemData->text().trimmed();
    QString text;
    for(int i = 0; i < tempText.length(); ++i)
    {
        text.append(tempText.at(i));
        if(i != tempText.length() - 1)
        {
            text.append("\n");
        }
    }
    QGraphicsItem* nodeItem = new QGraphicsEllipseItem(QRectF(0,0,1,1),this);
    nodeItem->setToolTip(tempText);

    QSizeF size = nodeItem->boundingRect().size();
    nodeItem->setPos(point2.x() - size.width() * 0.5,point2.y() - size.height() * 0.5);
    QRectF rect = QRectF(nodeItem->pos().x(),nodeItem->pos().y(),size.width(),size.height());

//    QGraphicsRectItem* rectItem = new QGraphicsRectItem(rect,this);
//    rectItem->setPen(pen);
    if(parentVLine.length() > PSV_ZEOR)
    {
        QLineF line = parentVLine;
        line.setP2(QPointF(line.x2(),rect.top()));
        QGraphicsLineItem* item = new QGraphicsLineItem(line,this);
        PSV_NOUSED(item);
    }
    if(count > 0)
    {
        QLineF leftHLine(point2.x() - leafCount * 0.5 * m_dw
                      ,point2.y()
                      ,rect.left()
                      ,point2.y());

        QLineF rightHLine(rect.right()
                      ,point2.y()
                      ,point2.x() + leafCount * 0.5 * m_dw
                      ,point2.y());

        double curX1 = leftHLine.x1();
        for(int i = 0; i < count; ++i)
        {
            PSV_TreeItemData* tempItemData = children.at(i);
            int tempLeafCount = tempItemData->leafCount();
            curX1 += tempLeafCount * 0.5 * m_dw;
            if(i == 0)
            {
                leftHLine.setP1(QPointF(curX1,leftHLine.y1()));
            }
            if(i == count - 1)
            {
                rightHLine.setP2(QPointF(curX1,leftHLine.y2()));
            }
            double y1 = point2.y();
            double y2 = point2.y() + tempItemData->distance() * m_dhRatio;
            if(curX1 > rect.left() && curX1 < rect.right())
            {
                y1 = rect.bottom();
            }
            QLineF lineV(curX1,y1,curX1,y2);
            curX1 += tempLeafCount * 0.5 * m_dw;
            paintLine(lineV,tempItemData);
        }
        if(count > 1)
        {
            QGraphicsLineItem* leftHLineItem = new QGraphicsLineItem(leftHLine,this);
            leftHLineItem->setPen(pen_hLine);
            QGraphicsLineItem* rightHLineItem = new QGraphicsLineItem(rightHLine,this);
            rightHLineItem->setPen(pen_hLine);
        }
    }
}
开发者ID:BIbiLion,项目名称:LSWuqiankun,代码行数:86,代码来源:psv_treeitem.cpp

示例4: applyFillStyle

void SvgParser::applyFillStyle(KoShape *shape)
{
    SvgGraphicsContext *gc = m_context.currentGC();
    if (! gc)
        return;

    if (gc->fillType == SvgGraphicsContext::None) {
        shape->setBackground(QSharedPointer<KoShapeBackground>(0));
    } else if (gc->fillType == SvgGraphicsContext::Solid) {
        shape->setBackground(QSharedPointer<KoColorBackground>(new KoColorBackground(gc->fillColor)));
    } else if (gc->fillType == SvgGraphicsContext::Complex) {
        // try to find referenced gradient
        SvgGradientHelper *gradient = findGradient(gc->fillId);
        if (gradient) {
            // great, we have a gradient fill
            QSharedPointer<KoGradientBackground> bg;
            if (gradient->gradientUnits() == SvgGradientHelper::ObjectBoundingBox) {
                bg = QSharedPointer<KoGradientBackground>(new KoGradientBackground(*gradient->gradient()));
                bg->setTransform(gradient->transform());
            } else {
                QGradient *convertedGradient = SvgGradientHelper::convertGradient(gradient->gradient(), shape->size());
                bg = QSharedPointer<KoGradientBackground>(new KoGradientBackground(convertedGradient));
                QTransform invShapematrix = shape->transformation().inverted();
                bg->setTransform(gradient->transform() * gc->matrix * invShapematrix);
            }
            shape->setBackground(bg);
        } else {
            // try to find referenced pattern
            SvgPatternHelper *pattern = findPattern(gc->fillId);
            KoImageCollection *imageCollection = m_documentResourceManager->imageCollection();
            if (pattern && imageCollection) {
                // great we have a pattern fill
                QRectF objectBound = QRectF(QPoint(), shape->size());
                QRectF currentBoundbox = gc->currentBoundbox;

                // properties from the object are not inherited
                // so we are creating a new context without copying
                SvgGraphicsContext *gc = m_context.pushGraphicsContext(pattern->content(), false);

                // the pattern establishes a new coordinate system with its
                // origin at the patterns x and y attributes
                gc->matrix = QTransform();
                // object bounding box units are relative to the object the pattern is applied
                if (pattern->patternContentUnits() == SvgPatternHelper::ObjectBoundingBox) {
                    gc->currentBoundbox = objectBound;
                    gc->forcePercentage = true;
                } else {
                    // inherit the current bounding box
                    gc->currentBoundbox = currentBoundbox;
                }

                applyStyle(0, pattern->content());

                // parse the pattern content elements
                QList<KoShape*> patternContent = parseContainer(pattern->content());

                // generate the pattern image from the shapes and the object bounding rect
                QImage image = pattern->generateImage(objectBound, patternContent);

                m_context.popGraphicsContext();

                // delete the shapes created from the pattern content
                qDeleteAll(patternContent);

                if (!image.isNull()) {
                    QSharedPointer<KoPatternBackground> bg(new KoPatternBackground(imageCollection));
                    bg->setPattern(image);

                    QPointF refPoint = shape->documentToShape(pattern->position(objectBound));
                    QSizeF tileSize = pattern->size(objectBound);

                    bg->setPatternDisplaySize(tileSize);
                    if (pattern->patternUnits() == SvgPatternHelper::ObjectBoundingBox) {
                        if (tileSize == objectBound.size())
                            bg->setRepeat(KoPatternBackground::Stretched);
                    }

                    // calculate pattern reference point offset in percent of tileSize
                    // and relative to the topleft corner of the shape
                    qreal fx = refPoint.x() / tileSize.width();
                    qreal fy = refPoint.y() / tileSize.height();
                    if (fx < 0.0)
                        fx = floor(fx);
                    else if (fx > 1.0)
                        fx = ceil(fx);
                    else
                        fx = 0.0;
                    if (fy < 0.0)
                        fy = floor(fy);
                    else if (fx > 1.0)
                        fy = ceil(fy);
                    else
                        fy = 0.0;
                    qreal offsetX = 100.0 * (refPoint.x() - fx * tileSize.width()) / tileSize.width();
                    qreal offsetY = 100.0 * (refPoint.y() - fy * tileSize.height()) / tileSize.height();
                    bg->setReferencePointOffset(QPointF(offsetX, offsetY));

                    shape->setBackground(bg);
                }
            } else {
//.........这里部分代码省略.........
开发者ID:loveq369,项目名称:calligra,代码行数:101,代码来源:SvgParser.cpp

示例5:

QTCEXPORT(void,qtc_QSizeF_expandedTo_qth)(void* x0, double x1_w, double x1_h, double* _ret_w, double* _ret_h) {
  QSizeF tx1(x1_w, x1_h);
  QSizeF tc = ((QSizeF*)x0)->expandedTo(tx1);
  *_ret_w = tc.width(); *_ret_h = tc.height();
  return;
}
开发者ID:bennofs,项目名称:hsQt,代码行数:6,代码来源:QSizeF.cpp

示例6: niceInterval

QSizeF niceInterval(QSizeF interval)
{
	return QSizeF(niceInterval(interval.width()), niceInterval(interval.height()));
}
开发者ID:dejfh,项目名称:nicos-livewidget-ng,代码行数:4,代码来源:griditem.cpp

示例7: QGraphicsScene

MLWebKit::MLWebKit(int overscanw, int overscanh, qreal zoom, int rotationMode)
{
#ifdef _INSPECTOR_
    pWebKit = this;
#endif

    // Create elements

    pScene = new QGraphicsScene();

    if ( pScene == NULL ) return;

    pView = new QGraphicsView(pScene);

    pWebview = new GraphicsWebView();

    pPage =  new WebPage();

    pFrame = pPage->mainFrame();

    QApplication* pApp = (QApplication *)QApplication::instance();

    QDesktopWidget* pDesktop = QApplication::desktop();

    if ( pScene == NULL || pView == NULL || pWebview == NULL || pPage == NULL || pFrame == NULL || pApp == NULL || pDesktop == NULL )
    {
        qDebug () << "unable to construct browser (elements)";
        return;
    }

    // Rotate View according to rotationMode
    pView->rotate(90*rotationMode);

#ifdef QT_OPENGL_LIB
    pWidget = NULL;
//	pWidget = new QGLWidget();
//	pWidget = new QGLWidget(pView);
#endif

#ifdef _INSPECTOR_
    pInspector = new QWebInspector;
    pInspector->setPage(pPage);
    pInspector->resize(QApplication::desktop()->screenGeometry().size());
#endif

    // Configuration, settings and alike
//	pScene->setItemIndexMethod( QGraphicsScene::NoIndex);
//	pView->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
    pView->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
//	pView->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
//	pView->setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate);

    // Disable some 'browser features / elements'
    pView->setFrameShape(QFrame::NoFrame);
    pView->setHorizontalScrollBarPolicy ( Qt::ScrollBarAlwaysOff );
    pView->setVerticalScrollBarPolicy ( Qt::ScrollBarAlwaysOff );

//	pView->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
    pView->setWindowFlags(Qt::FramelessWindowHint);
    pView->showFullScreen();

    // Overrule the 'foreground' and 'background' defaults with transparent colors
    QPalette palette;
    palette.setBrush(QPalette::Active, QPalette::Window, Qt::SolidPattern);
    palette.setBrush(QPalette::Active, QPalette::Base, Qt::SolidPattern);
    palette.setBrush(QPalette::Inactive, QPalette::Window, Qt::SolidPattern);
    palette.setBrush(QPalette::Inactive, QPalette::Base, Qt::SolidPattern);
    palette.setColor(QPalette::Active, QPalette::Window, QColor(0, 0, 0x80, 255));
    // Nice light grey default backgroundcolor. Change to bright red if you want to see overscan borders.
    palette.setColor(QPalette::Active, QPalette::Base, QColor(0xC0, 0xc0, 0xc0, 255));
    palette.setColor(QPalette::Inactive, QPalette::Window, QColor(0, 0, 0, 255));
    palette.setColor(QPalette::Inactive, QPalette::Base, QColor(0, 0, 0, 255));

    pApp->setPalette(palette);


//TODO: implement check
    QSizeF screenSize = pDesktop->screenGeometry().size();
    qDebug () << "screen geometry : " << screenSize;

    QSizeF displaySize;
    switch (rotationMode) {
        break;
    case 1:
    case 3:
        displaySize = QSizeF(
                          screenSize.height() - overscanw,
                          screenSize.width() - overscanh
                      );
        break;
    case 0:
    case 2:
    default:
        displaySize = QSizeF(
                          screenSize.width() - overscanw,
                          screenSize.height() - overscanh
                      );
    }
    qDebug () << "display geometry : " << displaySize;

//.........这里部分代码省略.........
开发者ID:jakobwesthoff,项目名称:mlbrowser,代码行数:101,代码来源:mlwebkit.cpp

示例8: renderText

QImage RichTextRenderer::renderText()
{
// 	qDebug()<<itemName()<<"TextBoxWarmingThread::run(): htmlCode:"<<htmlCode;
	//qDebug() << "RichTextRenderer::renderText(): HTML:"<<html();
	//qDebug() << "RichTextRenderer::update(): Update Start...";
 	//qDebug() << "RichTextRenderer::renderText(): \t in thread:"<<QThread::currentThreadId();
	if(m_updateTimer.isActive())
		m_updateTimer.stop();
		
	QTime renderTime;
	renderTime.start();
	
	QTextDocument doc;
	QTextDocument shadowDoc;
	
	if (Qt::mightBeRichText(html()))
	{
		doc.setHtml(html());
		shadowDoc.setHtml(html());
	}
	else
	{
		doc.setPlainText(html());
		shadowDoc.setPlainText(html());
	}
	
	int textWidth = m_textWidth;

	doc.setTextWidth(textWidth);
	shadowDoc.setTextWidth(textWidth);
	
	// Apply outline pen to the html
	QTextCursor cursor(&doc);
	cursor.select(QTextCursor::Document);

	QTextCharFormat format;

	QPen p(Qt::NoPen);
	if(outlineEnabled())
	{
		p = outlinePen();
		p.setJoinStyle(Qt::MiterJoin);
	}

	format.setTextOutline(p);
	//format.setForeground(fillEnabled() ? fillBrush() : Qt::NoBrush); //Qt::white);

	cursor.mergeCharFormat(format);
	
	// Setup the shadow text formatting if enabled
	if(shadowEnabled())
	{
		if(shadowBlurRadius() <= 0.05)
		{
			QTextCursor cursor(&shadowDoc);
			cursor.select(QTextCursor::Document);
	
			QTextCharFormat format;
			format.setTextOutline(Qt::NoPen);
			format.setForeground(shadowBrush());
	
			cursor.mergeCharFormat(format);
		}
	}
	
			
	QSizeF shadowSize = shadowEnabled() ? QSizeF(shadowOffsetX(),shadowOffsetY()) : QSizeF(0,0);
	QSizeF docSize = doc.size();
	QSizeF padSize(12.,12.);
	QSizeF sumSize = (docSize + shadowSize + padSize);//.toSize();
	
	QSizeF scaledSize = QSizeF(sumSize.width() * m_scaling.x(), sumSize.height() * m_scaling.y());
	if(m_scaling.x() != 1. || m_scaling.y() != 1.)
	{
		//qDebug() << "RichTextRenderer::renderText(): Orig size:"<<sumSize<<", scaled size:"<<scaledSize<<", scaling:"<<m_scaling;
		m_rawSize = sumSize;
	}
	//qDebug() << "RichTextRenderer::update(): textWidth: "<<textWidth<<", shadowSize:"<<shadowSize<<", docSize:"<<docSize<<", sumSize:"<<sumSize;
	QImage cache(scaledSize.toSize(),QImage::Format_ARGB32); //_Premultiplied);
	memset(cache.scanLine(0),0,cache.byteCount());
	
	double padSizeHalfX = padSize.width() / 2;
	double padSizeHalfY = padSize.height() / 2;
			
	
	QPainter textPainter(&cache);
	textPainter.scale(m_scaling.x(), m_scaling.y());
	//textPainter.fillRect(cache.rect(),Qt::transparent);
	
	QAbstractTextDocumentLayout::PaintContext pCtx;

	//qDebug() << "RichTextRenderer::renderText(): shadowEnabled():"<<shadowEnabled()<<", shadowBlurRadius():"<<shadowBlurRadius(); 
	if(shadowEnabled())
	{
		if(shadowBlurRadius() <= 0.05)
		{
			// render a "cheap" version of the shadow using the shadow text document
			textPainter.save();

			textPainter.translate(shadowOffsetX(),shadowOffsetY());
//.........这里部分代码省略.........
开发者ID:TritonSailor,项目名称:livepro,代码行数:101,代码来源:RichTextRenderer.cpp

示例9: 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

示例10: boundingRect

QRectF SCgVisualControl::boundingRect() const
{
    QSizeF size = baseObject()->size();
    return QRectF(-size.width() / 2.f, -size.height() / 2.f, size.width(), size.height());
}
开发者ID:mcdir,项目名称:sui,代码行数:5,代码来源:scgvisualcontrol.cpp

示例11: legendIcon

/*!
   \return Icon representing the curve on the legend

   \param index Index of the legend entry 
                ( ignored as there is only one )
   \param size Icon size

   \sa QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()
 */
QwtGraphic QwtPlotCurve::legendIcon( int index, 
    const QSizeF &size ) const
{
    Q_UNUSED( index );

    if ( size.isEmpty() )
        return QwtGraphic();

    QwtGraphic graphic;
    graphic.setDefaultSize( size );
    graphic.setRenderHint( QwtGraphic::RenderPensUnscaled, true );

    QPainter painter( &graphic );
    painter.setRenderHint( QPainter::Antialiasing,
        testRenderHint( QwtPlotItem::RenderAntialiased ) );

    if ( d_data->legendAttributes == 0 ||
        d_data->legendAttributes & QwtPlotCurve::LegendShowBrush )
    {
        QBrush brush = d_data->brush;

        if ( brush.style() == Qt::NoBrush &&
            d_data->legendAttributes == 0 )
        {
            if ( style() != QwtPlotCurve::NoCurve )
            {
                brush = QBrush( pen().color() );
            }
            else if ( d_data->symbol &&
                ( d_data->symbol->style() != QwtSymbol::NoSymbol ) )
            {
                brush = QBrush( d_data->symbol->pen().color() );
            }
        }

        if ( brush.style() != Qt::NoBrush )
        {
            QRectF r( 0, 0, size.width(), size.height() );
            painter.fillRect( r, brush );
        }
    }

    if ( d_data->legendAttributes & QwtPlotCurve::LegendShowLine )
    {
        if ( pen() != Qt::NoPen )
        {
            QPen pn = pen();
            pn.setCapStyle( Qt::FlatCap );

            painter.setPen( pn );

            const double y = 0.5 * size.height();
            QwtPainter::drawLine( &painter, 0.0, y, size.width(), y );
        }
    }

    if ( d_data->legendAttributes & QwtPlotCurve::LegendShowSymbol )
    {
        if ( d_data->symbol )
        {
            QRectF r( 0, 0, size.width(), size.height() );
            d_data->symbol->drawSymbol( &painter, r );
        }
    }

    return graphic;
}
开发者ID:Au-Zone,项目名称:qwt,代码行数:76,代码来源:qwt_plot_curve.cpp

示例12: boundingRect

QRectF DebugPropertyItem::boundingRect() const
  {
  qreal penWidth = 1;
  QSizeF size = _info.size();

  QRectF bnds(-5 - (penWidth / 2), - 5 - (penWidth / 2), size.width() + 10 + penWidth, size.height() + 10  + penWidth);

  return bnds;
  }
开发者ID:jorj1988,项目名称:Shift,代码行数:9,代码来源:sdebugger.cpp

示例13: text

void
IncompleteThumbnail::drawQuestionMark(QPainter& painter, QRectF const& bounding_rect)
{
	QString const text(QString::fromAscii("?"));
	
	// Because painting happens only from the main thread, we don't
	// need to care about concurrent access.
	if (m_sCachedPath.isEmpty()) {
#if 0
		QFont font(painter.font());
		font.setWeight(QFont::DemiBold);
		font.setStyleStrategy(QFont::ForceOutline);
		m_sCachedPath.addText(0, 0, font, text);
#else
		m_sCachedPath.moveTo(QPointF(4.42188, -2.40625));
		m_sCachedPath.cubicTo(
			QPointF(4.42188, -3.20312),
			QPointF(4.51562, -3.32812),
			QPointF(5.23438, -3.84375)
		);
		m_sCachedPath.cubicTo(
			QPointF(6.34375, -4.625),
			QPointF(6.67188, -5.15625),
			QPointF(6.67188, -6.17188)
		);
		m_sCachedPath.cubicTo(
			QPointF(6.67188, -7.79688),
			QPointF(5.4375, -8.92188),
			QPointF(3.6875, -8.92188)
		);
		m_sCachedPath.cubicTo(
			QPointF(2.65625, -8.92188),
			QPointF(1.84375, -8.5625),
			QPointF(1.32812, -7.85938)
		);
		m_sCachedPath.cubicTo(
			QPointF(0.9375, -7.32812),
			QPointF(0.78125, -6.75),
			QPointF(0.765625, -5.76562)
		);
		m_sCachedPath.lineTo(QPointF(2.40625, -5.76562));
		m_sCachedPath.lineTo(QPointF(2.40625, -5.79688));
		m_sCachedPath.cubicTo(
			QPointF(2.34375, -6.76562),
			QPointF(2.92188, -7.51562),
			QPointF(3.71875, -7.51562)
		);
		m_sCachedPath.cubicTo(
			QPointF(4.4375, -7.51562),
			QPointF(4.98438, -6.90625),
			QPointF(4.98438, -6.125)
		);
		m_sCachedPath.cubicTo(
			QPointF(4.98438, -5.59375),
			QPointF(4.82812, -5.35938),
			QPointF(4.125, -4.78125)
		);
		m_sCachedPath.cubicTo(
			QPointF(3.17188, -3.96875),
			QPointF(2.90625, -3.4375),
			QPointF(2.9375, -2.40625)
		);
		m_sCachedPath.lineTo(QPointF(4.42188, -2.40625));
		m_sCachedPath.moveTo(QPointF(4.625, -1.75));
		m_sCachedPath.lineTo(QPointF(2.8125, -1.75));
		m_sCachedPath.lineTo(QPointF(2.8125, 0.0));
		m_sCachedPath.lineTo(QPointF(4.625, 0.0));
		m_sCachedPath.lineTo(QPointF(4.625, -1.75));
#endif
	}
	
	QRectF const text_rect(m_sCachedPath.boundingRect());
	
	QTransform xform1;
	xform1.translate(-text_rect.left(), -text_rect.top());
	
	QSizeF const unscaled_size(text_rect.size());
	QSizeF scaled_size(unscaled_size);
	scaled_size.scale(bounding_rect.size() * 0.9, Qt::KeepAspectRatio);
	
	double const hscale = scaled_size.width() / unscaled_size.width();
	double const vscale = scaled_size.height() / unscaled_size.height();
	QTransform xform2;
	xform2.scale(hscale, vscale);
	
	// Position the text at the center of our bounding rect.
	QSizeF const translation(bounding_rect.size() * 0.5 - scaled_size * 0.5);
	QTransform xform3;
	xform3.translate(translation.width(), translation.height());
	
	painter.setWorldTransform(xform1 * xform2 * xform3, true);
	painter.setRenderHint(QPainter::Antialiasing);
	
	QPen pen(QColor(0x00, 0x00, 0x00, 60));
	pen.setWidth(2);
	pen.setCosmetic(true);
	painter.setPen(pen);
	
	painter.drawPath(m_sCachedPath);
}
开发者ID:4sp1r3,项目名称:scantailor,代码行数:100,代码来源:IncompleteThumbnail.cpp

示例14: draw

void QSvgText::draw(QPainter *p, QSvgExtraStates &states)
{
    applyStyle(p, states);
    qreal oldOpacity = p->opacity();
    p->setOpacity(oldOpacity * states.fillOpacity);

    // Force the font to have a size of 100 pixels to avoid truncation problems
    // when the font is very small.
    qreal scale = 100.0 / p->font().pointSizeF();
    Qt::Alignment alignment = states.textAnchor;

    QTransform oldTransform = p->worldTransform();
    p->scale(1 / scale, 1 / scale);

    qreal y = 0;
    bool initial = true;
    qreal px = m_coord.x() * scale;
    qreal py = m_coord.y() * scale;
    QSizeF scaledSize = m_size * scale;

    if (m_type == TEXTAREA) {
        if (alignment == Qt::AlignHCenter)
            px += scaledSize.width() / 2;
        else if (alignment == Qt::AlignRight)
            px += scaledSize.width();
    }

    QRectF bounds;
    if (m_size.height() != 0)
        bounds = QRectF(0, py, 1, scaledSize.height()); // x and width are not used.

    bool appendSpace = false;
    QVector<QString> paragraphs;
    QStack<QTextCharFormat> formats;
    QVector<QList<QTextLayout::FormatRange> > formatRanges;
    paragraphs.push_back(QString());
    formatRanges.push_back(QList<QTextLayout::FormatRange>());

    for (int i = 0; i < m_tspans.size(); ++i) {
        if (m_tspans[i] == LINEBREAK) {
            if (m_type == TEXTAREA) {
                if (paragraphs.back().isEmpty()) {
                    QFont font = p->font();
                    font.setPixelSize(font.pointSizeF() * scale);

                    QTextLayout::FormatRange range;
                    range.start = 0;
                    range.length = 1;
                    range.format.setFont(font);
                    formatRanges.back().append(range);

                    paragraphs.back().append(QLatin1Char(' '));;
                }
                appendSpace = false;
                paragraphs.push_back(QString());
                formatRanges.push_back(QList<QTextLayout::FormatRange>());
            }
        } else {
            WhitespaceMode mode = m_tspans[i]->whitespaceMode();
            m_tspans[i]->applyStyle(p, states);

            QFont font = p->font();
            font.setPixelSize(font.pointSizeF() * scale);

            QString newText(m_tspans[i]->text());
            newText.replace(QLatin1Char('\t'), QLatin1Char(' '));
            newText.replace(QLatin1Char('\n'), QLatin1Char(' '));

            bool prependSpace = !appendSpace && !m_tspans[i]->isTspan() && (mode == Default) && !paragraphs.back().isEmpty() && newText.startsWith(QLatin1Char(' '));
            if (appendSpace || prependSpace)
                paragraphs.back().append(QLatin1Char(' '));

            bool appendSpaceNext = (!m_tspans[i]->isTspan() && (mode == Default) && newText.endsWith(QLatin1Char(' ')));

            if (mode == Default) {
                newText = newText.simplified();
                if (newText.isEmpty())
                    appendSpaceNext = false;
            }

            QTextLayout::FormatRange range;
            range.start = paragraphs.back().length();
            range.length = newText.length();
            range.format.setFont(font);
            range.format.setTextOutline(p->pen());
            range.format.setForeground(p->brush());

            if (appendSpace) {
                Q_ASSERT(!formatRanges.back().isEmpty());
                ++formatRanges.back().back().length;
            } else if (prependSpace) {
                --range.start;
                ++range.length;
            }
            formatRanges.back().append(range);

            appendSpace = appendSpaceNext;
            paragraphs.back() += newText;

            m_tspans[i]->revertStyle(p, states);
//.........这里部分代码省略.........
开发者ID:MarianMMX,项目名称:MarianMMX,代码行数:101,代码来源:qsvggraphics.cpp

示例15: drawDisplay

void QItemDelegate::drawDisplay(QPainter *painter, const QStyleOptionViewItem &option,
                                const QRect &rect, const QString &text) const
{
    Q_D(const QItemDelegate);

    QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
                              ? QPalette::Normal : QPalette::Disabled;
    if (cg == QPalette::Normal && !(option.state & QStyle::State_Active))
        cg = QPalette::Inactive;
    if (option.state & QStyle::State_Selected) {
        painter->fillRect(rect, option.palette.brush(cg, QPalette::Highlight));
        painter->setPen(option.palette.color(cg, QPalette::HighlightedText));
    } else {
        painter->setPen(option.palette.color(cg, QPalette::Text));
    }

    if (text.isEmpty())
        return;

    if (option.state & QStyle::State_Editing) {
        painter->save();
        painter->setPen(option.palette.color(cg, QPalette::Text));
        painter->drawRect(rect.adjusted(0, 0, -1, -1));
        painter->restore();
    }

    const QStyleOptionViewItem opt = option;

    const QWidget *widget = d->widget(option);
    QStyle *style = widget ? widget->style() : QApplication::style();
    const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1;
    QRect textRect = rect.adjusted(textMargin, 0, -textMargin, 0); // remove width padding
    const bool wrapText = opt.features & QStyleOptionViewItem::WrapText;
    d->textOption.setWrapMode(wrapText ? QTextOption::WordWrap : QTextOption::ManualWrap);
    d->textOption.setTextDirection(option.direction);
    d->textOption.setAlignment(QStyle::visualAlignment(option.direction, option.displayAlignment));
    d->textLayout.setTextOption(d->textOption);
    d->textLayout.setFont(option.font);
    d->textLayout.setText(QItemDelegatePrivate::replaceNewLine(text));

    QSizeF textLayoutSize = d->doTextLayout(textRect.width());

    if (textRect.width() < textLayoutSize.width()
        || textRect.height() < textLayoutSize.height()) {
        QString elided;
        int start = 0;
        int end = text.indexOf(QChar::LineSeparator, start);
        if (end == -1) {
            elided += option.fontMetrics.elidedText(text, option.textElideMode, textRect.width());
        } else {
            while (end != -1) {
                elided += option.fontMetrics.elidedText(text.mid(start, end - start),
                                                        option.textElideMode, textRect.width());
                elided += QChar::LineSeparator;
                start = end + 1;
                end = text.indexOf(QChar::LineSeparator, start);
            }
            //let's add the last line (after the last QChar::LineSeparator)
            elided += option.fontMetrics.elidedText(text.mid(start),
                                                    option.textElideMode, textRect.width());
        }
        d->textLayout.setText(elided);
        textLayoutSize = d->doTextLayout(textRect.width());
    }

    const QSize layoutSize(textRect.width(), int(textLayoutSize.height()));
    const QRect layoutRect = QStyle::alignedRect(option.direction, option.displayAlignment,
                                                  layoutSize, textRect);
    // if we still overflow even after eliding the text, enable clipping
    if (!hasClipping() && (textRect.width() < textLayoutSize.width()
                           || textRect.height() < textLayoutSize.height())) {
        painter->save();
        painter->setClipRect(layoutRect);
        d->textLayout.draw(painter, layoutRect.topLeft(), QVector<QTextLayout::FormatRange>(), layoutRect);
        painter->restore();
    } else {
        d->textLayout.draw(painter, layoutRect.topLeft(), QVector<QTextLayout::FormatRange>(), layoutRect);
    }
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:79,代码来源:qitemdelegate.cpp


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