QSizeF ContentWindowController::getMaxSize() const { QSizeF maxSize = getMaxContentSize(); maxSize.rwidth() *= _contentWindow->getZoomRect().size().width(); maxSize.rheight() *= _contentWindow->getZoomRect().size().height(); return maxSize; }
/** * Reimplemented from UMLWidget::updateGeometry to calculate * minimum size for activity widget. */ void ActivityWidget::updateGeometry() { TextItemGroup *grp = textItemGroupAt(ActivityWidget::TextGroupIndex); QSizeF minSize = grp->minimumSize(); switch(m_activityType) { case Invok: minSize.rheight() += 40; // FIXME: Magic number break; case Initial: case Final: case End: case Branch: minSize = QSizeF(20, 20); break; case Param: case Normal: break; // Nothing to add. } setMinimumSize(minSize); UMLWidget::updateGeometry(); }
/** * Reimplemented from UMLWidget::updateGeometry to calculate * minimum size for signal widget based on the current signal type. */ void SignalWidget::updateGeometry() { QSizeF minSize = textItemGroupAt(GroupIndex)->minimumSize(); if (minSize.width() < SignalWidget::MinimumSize.width()) { minSize.setWidth(SignalWidget::MinimumSize.width()); } if (m_signalType == SignalWidget::Accept) { // We need 1/3rd part for the '>' shape.(hollow or convex) minSize.rwidth() += minSize.width() / 3 + margin(); } else if (m_signalType == SignalWidget::Send) { // Add one third for the '>' shape. minSize.rwidth() += minSize.width() / 3 + margin(); } else if (m_signalType == SignalWidget::Time) { // In case of SignalWidget::Time add minimum height to // calculated as the text appears below drawing. minSize.rheight() += SignalWidget::MinimumSize.height(); } setMinimumSize(minSize); UMLWidget::updateGeometry(); }
QImage GLImageDrawable::applyBorder(const QImage& sourceImg) { if(renderBorder() && m_borderWidth > 0.001) { QSizeF originalSizeWithBorder = sourceImg.size(); double x = m_borderWidth * 2; originalSizeWithBorder.rwidth() += x; originalSizeWithBorder.rheight() += x; QImage cache(originalSizeWithBorder.toSize(),QImage::Format_ARGB32_Premultiplied); memset(cache.scanLine(0),0,cache.byteCount()); QPainter p(&cache); int bw = (int)(m_borderWidth / 2); p.drawImage(bw,bw,sourceImg); //drawImage(bw,bw,sourceImg); p.setPen(QPen(m_borderColor,m_borderWidth)); p.drawRect(sourceImg.rect().adjusted(bw,bw,bw,bw)); //QRectF(sourceImg.rect()).adjusted(-bw,-bw,bw,bw)); m_imageWithBorder = cache; return cache; } if(!m_imageWithBorder.isNull()) m_imageWithBorder = QImage(); return sourceImg; }
void ResolutionCalculator::on_acceptButton_clicked() { if ((hRes>0) && (vRes>0)) { QSizeF s = image->data()->getTransformedSizeData(ImageDataStore::PixelSize); s.rwidth() *= hRes; s.rheight() *= vRes; image->data()->setTransformedSizeData(ImageDataStore::PhysicalSize, s); } rulers.clear(); }
void QgsDiagramRendererV2::convertSizeToMapUnits( QSizeF& size, const QgsRenderContext& context ) const { if ( !size.isValid() ) { return; } double pixelToMap = context.scaleFactor() * context.mapToPixel().mapUnitsPerPixel(); size.rwidth() *= pixelToMap; size.rheight() *= pixelToMap; }
QRect QtopiaPrintEngine::paperRect() const { QSizeF s = qt_paperSizeToQSizeF(d_func()->paperSize); s.rwidth() = MM(s.width()); s.rheight() = MM(s.height()); int w = qRound(s.width()*d_func()->resolution/72.); int h = qRound(s.height()*d_func()->resolution/72.); if (d_func()->orientation == QPrinter::Portrait) return QRect(0, 0, w, h); else return QRect(0, 0, h, w); }
void AbstractDiagram::paintMarker( QPainter* painter, const DataValueAttributes& a, const QModelIndex& index, const QPointF& pos ) { if ( !checkInvariants() || !a.isVisible() ) return; const MarkerAttributes ma = a.markerAttributes(); if ( !ma.isVisible() ) return; const PainterSaver painterSaver( painter ); QSizeF maSize = ma.markerSize(); const qreal diagramWidth = d->diagramSize.width(); const qreal diagramHeight = d->diagramSize.height(); switch( ma.markerSizeMode() ) { case MarkerAttributes::AbsoluteSize: // Unscaled, i.e. without the painter's "zoom" maSize.rwidth() /= painter->matrix().m11(); maSize.rheight() /= painter->matrix().m22(); break; case MarkerAttributes::AbsoluteSizeScaled: // Keep maSize as is. It is specified directly in pixels and desired // to be effected by the painter's "zoom". break; case MarkerAttributes::RelativeToDiagramWidth: maSize *= diagramWidth; break; case MarkerAttributes::RelativeToDiagramHeight: maSize *= diagramHeight; break; case MarkerAttributes::RelativeToDiagramWidthHeightMin: maSize *= qMin( diagramWidth, diagramHeight ); break; } QBrush indexBrush( brush( index ) ); QPen indexPen( ma.pen() ); if ( ma.markerColor().isValid() ) indexBrush.setColor( ma.markerColor() ); paintMarker( painter, ma, indexBrush, indexPen, pos, maSize ); // workaround: BC cannot be changed, otherwise we would pass the // index down to next-lower paintMarker function. So far, we // basically save a circle of radius maSize at pos in the // reverseMapper. This means that ^^^ this version of paintMarker // needs to be called to reverse-map the marker. d->reverseMapper.addCircle( index.row(), index.column(), pos, 2 * maSize ); }
void QgsDiagramRendererV2::convertSizeToMapUnits( QSizeF& size, const QgsRenderContext& context ) const { if ( !size.isValid() ) { return; } int dpi = dpiPaintDevice( context.constPainter() ); if ( dpi < 0 ) { return; } double pixelToMap = dpi / 25.4 * context.mapToPixel().mapUnitsPerPixel(); size.rwidth() *= pixelToMap; size.rheight() *= pixelToMap; }
QSizeF QgsDiagramRenderer::sizeMapUnits( const QgsFeature& feature, const QgsRenderContext& c ) const { QgsDiagramSettings s; if ( !diagramSettings( feature, c, s ) ) { return QSizeF(); } QSizeF size = diagramSize( feature, c ); if ( size.isValid() ) { double width = QgsSymbolLayerUtils::convertToMapUnits( c, size.width(), s.sizeType, s.sizeScale ); size.rheight() *= width / size.width(); size.setWidth( width ); } return size; }
QSizeF QuickGridDefinition::cellSize(QRectF rect, int row, int column, int rowSpan, int columnSpan) { QSizeF size; for(int end = qMin(row + rowSpan, rowCount()); row < end; row++) { size.rheight() += rowWeight(row) * rect.height(); } for(int end = qMin(column + columnSpan, columnCount()); column < end; column++) { size.rwidth() += columnWeight(column) * rect.width(); } return size; }
static inline void combineSize(QSizeF &result, const QSizeF &fallbackSize) { combineHints(result.rwidth(), fallbackSize.width()); combineHints(result.rheight(), fallbackSize.height()); }