本文整理汇总了C++中QTransform函数的典型用法代码示例。如果您正苦于以下问题:C++ QTransform函数的具体用法?C++ QTransform怎么用?C++ QTransform使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QTransform函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: itemAt
void Scene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
{
auto hoverItem = itemAt(e->scenePos(), QTransform());
if (!hoverItem && _nodesInteractable) {
auto node = new Node;
node->setInteractable(_nodesInteractable);
node->setSelected(true);
node->setPos(e->scenePos());
addItem(node);
} else if (!_nodesInteractable && _currentEdge) {
auto nodeItem = dynamic_cast<Node *>(hoverItem);
if (nodeItem) {
_currentEdge->setEndNode(nodeItem);
} else {
removeItem(_currentEdge);
delete _currentEdge;
}
_currentEdge = nullptr;
}
QGraphicsScene::mouseReleaseEvent(e);
}
示例2: setCacheMode
void DesktopWidget::spin()
{
d->angle += 18;
setCacheMode(ItemCoordinateCache);
QPointF center = boundingRect().center();
QTransform mat = QTransform();
mat.translate(center.x() , center.y());
mat.rotate(d->angle, Qt::YAxis);
mat.translate(- center.x() , - center.y());
setTransform(mat);
if (d->angle >= 180) {
if (state() == BACKSIDE) {
setState(NORMALSIDE);
} else {
setState(BACKSIDE);
}
d->spintimer->stop();
resetMatrix();
setCacheMode(DeviceCoordinateCache);
d->angle = 0;
}
}
示例3: device
void svg_renderer::update_cache_item (const renderable_item *item, const render_cache_id &cache_id, const QTransform &transform,
renderer_config &cfg, int total_x, int total_y)
{
int block_size = rendered_items_cache::block_pixel_size ();
SkBitmap bitmap;
bitmap.setConfig (SkBitmap::kARGB_8888_Config, block_size * total_x, block_size * total_y);
bitmap.allocPixels ();
SkBitmapDevice device (bitmap);
SkCanvas canvas (&device);
canvas.drawColor (SK_ColorTRANSPARENT, SkXfermode::kSrc_Mode);
QRectF local_rect = cache_id.pixel_rect (transform);
QTransform last_inverted = transform.inverted ();
QPointF last_pos_local = last_inverted.map (QPointF (0, 0));
QPointF cur_pos_local = last_inverted.map (QPointF (local_rect.x (), local_rect.y ()));
QPointF diff = -cur_pos_local + last_pos_local;
QTransform pixmap_transform = QTransform (transform).translate (diff.x (), diff.y ());
renderer_state state (QRect (0, 0, block_size * total_x, block_size * total_y), pixmap_transform);
draw_item (item, canvas, state, cfg);
if (m_queue->is_interrupted ())
return;
if (total_x == total_y && total_x == 1)
m_cache->add_bitmap (cache_id, bitmap, cfg.use_new_cache ());
else
{
for (int i = 0; i < total_x; i++)
for (int j = 0; j < total_y; j++)
{
render_cache_id cur_id (cache_id.x () + i, cache_id.y () + j, cache_id.object_type ());
SkBitmap bitmap_part;
DEBUG_ASSERT (bitmap.extractSubset (&bitmap_part, SkIRect::MakeXYWH (i * block_size, j * block_size, block_size, block_size)));
m_cache->add_bitmap (cur_id, bitmap_part, cfg.use_new_cache ());
}
}
}
示例4: imageForGlyph
QImage QWindowsFontEngineDirectWrite::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition)
{
QImage im = imageForGlyph(glyph, subPixelPosition, 0, QTransform());
QImage indexed(im.width(), im.height(), QImage::Format_Indexed8);
QVector<QRgb> colors(256);
for (int i=0; i<256; ++i)
colors[i] = qRgba(0, 0, 0, i);
indexed.setColorTable(colors);
for (int y=0; y<im.height(); ++y) {
uint *src = (uint*) im.scanLine(y);
uchar *dst = indexed.scanLine(y);
for (int x=0; x<im.width(); ++x) {
*dst = 255 - (m_fontEngineData->pow_gamma[qGray(0xffffffff - *src)] * 255. / 2047.);
++dst;
++src;
}
}
return indexed;
}
示例5: Georeferencing
bool TemplateTrack::loadTemplateFileImpl(bool configuring)
{
if (!track.loadFrom(template_path, false))
return false;
if (!configuring)
{
Georeferencing* track_crs = new Georeferencing();
if (!track_crs_spec.isEmpty())
track_crs->setProjectedCRS(QString{}, track_crs_spec);
track_crs->setTransformationDirectly(QTransform());
track.setTrackCRS(track_crs);
bool crs_is_geographic = track_crs_spec.contains(QLatin1String("+proj=latlong"));
if (!is_georeferenced && crs_is_geographic)
calculateLocalGeoreferencing();
else
track.changeMapGeoreferencing(map->getGeoreferencing());
}
return true;
}
示例6: switch
void CGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
{
// static int nbMove=0;
//qDebug("CGraphicsScene::mouseMoveEvent %i", m_mode);
switch (m_mode)
{
case MODE_IDLE:
QGraphicsScene::mouseMoveEvent(event);
if (m_itemRect != NULL)
{
m_itemRect->setMoveablePoint(event->scenePos());
setSelectionArea(m_itemRect->path(), QTransform());
}
break;
case MODE_CREATE_ITEM:
//Q_ASSERT(false); //Normallement ne doit jamais arrive...
QGraphicsScene::mouseMoveEvent(event);
break;
case MODE_IN_ITEM_CREATION:
Q_ASSERT(m_currentItem != NULL);
m_currentItem->updateCurrentPoint(event->scenePos());
//QGraphicsScene::mouseMoveEvent(event); pas d'appel a la classe de base pour eviter les moves en meme temps que les creations d'item
break;
case MODE_IN_ITEM_EVOLUTION:
Q_ASSERT(m_currentItem != NULL);
m_currentItem->onMouseEventOnAnchor(event, m_pressedAnchor);
break;
default:
Q_ASSERT(false);
break;
}
}
示例7: getRobot
void MapWidget::setViewOnRobot(std::string robot_id)
{
if (active_view_on_robot_ == robot_id)
{
return;
}
RobotGraphicsItem* robot = getRobot(robot_id);
QPointF position;
double heading;
getRobotPosition("/"+robot_id+"/base_link", position, heading);
graphicsView_->setTransform(QTransform());
graphicsView_->centerOn(position.x(),position.y());
// graphicsView_->scale(1, -1);
graphicsView_->scale(56, -56);
active_view_on_robot_ = robot_id;
}
示例8: qSin
void BlurPicker::setIndex(qreal index)
{
m_index = index;
qreal baseline = 0;
for (int i = 0; i < m_icons.count(); ++i) {
ImageItem *icon = m_icons[i];
qreal a = ((i + m_index) * 2 * M_PI) / m_icons.count();
qreal xs = 380 * qSin(a);
qreal ys = 230 * qCos(a);
QPointF pos(xs, ys);
// pos = QTransform::scale(0,0.2).map(pos);
// pos = QTransform().rotate(-20).map(pos);
pos = QTransform().rotate(-5).map(pos);
pos -= QPointF(40, 40);
// pos -= QPoint(10,10);
icon->setPos(pos);
baseline = qMax(baseline, ys);
static_cast<BlurEffect *>(icon->graphicsEffect())->setBaseLine(baseline);
}
scene()->update();
}
示例9: editListUpdateGraphics
void MainWindow::editListUpdateGraphics()
{
editListChordScene->clear();
editListChordScene->addPixmap(*guitarArm);
ui->editChordGraphicsView->setTransform(QTransform());
QString mainChord = ui->editNormalChordsComboBox->currentText();
QString modifier = ui->editChordsModificatorsComboBox->currentText();
QVarLengthArray<int> frets = getFrets(mainChord, modifier);
Braco * braco = new Braco(648, 6, 144);
Point * point = NULL;
for (int i = 0; i < frets.size(); i++)
if (frets.at(i) != 0 && frets.at(i) != -1)
{
point = braco->getPoint(i, frets.at(i));
editListChordScene->addEllipse(point->X, point->Y, 9, 9, QPen(Qt::NoPen), QBrush(QColor(255, 153, 0)));
}
delete point;
delete braco;
}
示例10: QTransform
void ScreeniePixmapItem::updateItemGeometry()
{
QTransform transform;
QTransform scale;
QTransform translateBack;
qreal centerScale = 1.0 - 0.9 * d->screenieModel.getDistance() / SceneLimits::MaxDistance;
scale = QTransform().scale(centerScale, centerScale);
QPixmap pixmap = this->pixmap();
qreal dx = pixmap.width() / 2.0;
qreal dy;
if (d->screenieModel.isReflectionEnabled()) {
dy = pixmap.height() / 4.0;
} else {
dy = pixmap.height() / 2.0;
}
transform.translate(dx, dy);
transform.rotate(d->screenieModel.getRotation(), Qt::YAxis);
translateBack.translate(-dx, -dy);
transform = translateBack * scale * transform;
setTransform(transform, false);
}
示例11: Q_D
/*!
\reimp
*/
void QGraphicsDropShadowEffect::draw(QPainter *painter)
{
Q_D(QGraphicsDropShadowEffect);
if (d->filter->blurRadius() <= 0 && d->filter->offset().isNull()) {
drawSource(painter);
return;
}
PixmapPadMode mode = PadToEffectiveBoundingRect;
if (painter->paintEngine()->type() == QPaintEngine::OpenGL2)
mode = NoPad;
// Draw pixmap in device coordinates to avoid pixmap scaling.
QPoint offset;
const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset, mode);
if (pixmap.isNull())
return;
QTransform restoreTransform = painter->worldTransform();
painter->setWorldTransform(QTransform());
d->filter->draw(painter, offset, pixmap);
painter->setWorldTransform(restoreTransform);
}
示例12: prepareGeometryChange
void NodeLabel::updateStyle()
{
prepareGeometryChange();
// update the text position
m_text.prepare(QTransform(), s_font);
QSizeF textSize = m_text.size();
m_textPos = QPointF(textSize.width() / -2., textSize.height() / -2.);
// update the label
QSizeF labelSize =
QSizeF(qMax(textSize.width(), Node::getCoreRadius() * 2.),
textSize.height());
m_outlineRect =
QRectF((labelSize.width() / -2.) - s_horizontalMargin,
m_textPos.y() - s_verticalMargin,
labelSize.width() + (s_horizontalMargin * 2.),
textSize.height() + (s_verticalMargin * 2.));
// update bounding rectangle
qreal halfLine = s_outlineWidth * 0.5;
m_boundingRect =
m_outlineRect.
marginsAdded(QMarginsF(halfLine, halfLine, halfLine, halfLine));
update();
}
示例13: QTransform
void VideoItem::paintExtDockFace(QPainter *p, const QStyleOptionGraphicsItem *e,
QWidget *widget) {
p->setRenderHints(QPainter::SmoothPixmapTransform | QPainter::Antialiasing |
QPainter::HighQualityAntialiasing);
p->setPen(QColor(215, 255, 98));
p->setFont(QFont("Bitstream Charter", 12));
// p->drawText(QRect(8,5,64,64), Qt::AlignCenter ,"Video" ) ;
p->save();
QPointF center = e->exposedRect.center();
QTransform mat = QTransform();
mat.translate(center.x(), center.y());
mat.rotate(-9.44, Qt::ZAxis);
mat.translate(-center.x(), -center.y());
// mat.shear(0.02,-0.01);
p->setTransform(mat);
p->setOpacity(0.8);
if (snapped == true)
p->drawPixmap(15, 43, e->exposedRect.width() - 30,
e->exposedRect.height() - 63, snap);
p->restore();
}
示例14: SYNC_WITH
void ImageWidget::paint(QPainter& painter)
{
SYNC_WITH(imageView.console);
const DebugImage* image = nullptr;
RobotConsole::Images& currentImages = imageView.upperCam ? imageView.console.upperCamImages : imageView.console.lowerCamImages;
RobotConsole::Images::const_iterator i = currentImages.find(imageView.background);
if(i != currentImages.end())
{
image = i->second.image;
imageWidth = image->getImageWidth();
imageHeight = image->height;
}
else if(!currentImages.empty())
{
imageWidth = currentImages.begin()->second.image->getImageWidth();
imageHeight = currentImages.begin()->second.image->height;
}
const QSize& size = painter.window().size();
float xScale = float(size.width()) / float(imageWidth);
float yScale = float(size.height()) / float(imageHeight);
scale = xScale < yScale ? xScale : yScale;
scale *= zoom;
float imageXOffset = (float(size.width()) - float(imageWidth) * scale) * 0.5f + float(offset.x()) * scale;
float imageYOffset = (float(size.height()) - float(imageHeight) * scale) * 0.5f + float(offset.y()) * scale;
painter.setTransform(QTransform(scale, 0, 0, scale, imageXOffset, imageYOffset));
if(image)
paintImage(painter, *image);
else
lastImageTimeStamp = 0;
paintDrawings(painter);
}
示例15: switch
bool
MozQOrientationSensorFilter::filter(QOrientationReading* reading)
{
switch (reading->orientation()) {
//The Top edge of the device is pointing up.
case QOrientationReading::TopDown:
mWindowRotationAngle = 90;
break;
//The Top edge of the device is pointing down.
case QOrientationReading::TopUp:
mWindowRotationAngle = 270;
break;
//The Left edge of the device is pointing up.
case QOrientationReading::LeftUp:
mWindowRotationAngle = 180;
break;
//The Right edge of the device is pointing up.
case QOrientationReading::RightUp:
mWindowRotationAngle = 0;
break;
//The Face of the device is pointing up.
case QOrientationReading::FaceUp:
//The Face of the device is pointing down.
case QOrientationReading::FaceDown:
//The orientation is unknown.
case QOrientationReading::Undefined:
default:
return true;
}
mWindowRotationTransform = QTransform();
mWindowRotationTransform.rotate(mWindowRotationAngle);
emit orientationChanged();
return true; // don't store the reading in the sensor
}