本文整理汇总了C++中QLineF函数的典型用法代码示例。如果您正苦于以下问题:C++ QLineF函数的具体用法?C++ QLineF怎么用?C++ QLineF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QLineF函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: if
void Bracket::draw(QPainter* painter) const
{
if (subtype() == BRACKET_AKKOLADE) {
painter->setPen(Qt::NoPen);
painter->setBrush(QBrush(curColor()));
painter->drawPath(path);
}
else if (subtype() == BRACKET_NORMAL) {
qreal h = 2 * h2 + yoff;
qreal _spatium = spatium();
qreal w = score()->styleS(ST_bracketWidth).val() * _spatium;
QPen pen(curColor(), w, Qt::SolidLine, Qt::FlatCap);
painter->setPen(pen);
qreal bd = _spatium * .25;
painter->drawLine(QLineF(0.0, -bd, 0.0, h + bd));
int idx = score()->symIdx();
qreal mags = 1.0;
qreal x = -w * .5;
qreal y1 = -bd;
qreal y2 = h + bd;
symbols[idx][brackettipsRightUp].draw(painter, mags, QPointF(x, y1));
symbols[idx][brackettipsRightDown].draw(painter, mags, QPointF(x, y2));
}
}
开发者ID:cymerio,项目名称:MuseScore,代码行数:24,代码来源:bracket.cpp
示例2: GuideCircle
void ItemCircleAnimation::setupGuides()
{
int x = 0;
int y = 20;
this->qtGuide1 = new GuideCircle(QRectF(x, y, 260, 260), -36, 342);
this->currGuide = 0;
new GuideLine(QPointF(x + 240, y + 268), this->qtGuide1);
new GuideLine(QPointF(x + 265, y + 246), this->qtGuide1);
new GuideLine(QPointF(x + 158, y + 134), this->qtGuide1);
new GuideLine(QPointF(x + 184, y + 109), this->qtGuide1);
new GuideLine(QPointF(x + 160, y + 82), this->qtGuide1);
new GuideLine(QPointF(x + 77, y + 163), this->qtGuide1); // T-top
new GuideLine(QPointF(x + 100, y + 190), this->qtGuide1);
new GuideLine(QPointF(x + 132, y + 159), this->qtGuide1);
new GuideLine(QPointF(x + 188, y + 211), this->qtGuide1);
new GuideCircle(QRectF(x + 30, y + 30, 200, 200), -30, 336, GuideCircle::CW, this->qtGuide1);
new GuideLine(QPointF(x + 238, y + 201), this->qtGuide1);
y = 30;
this->qtGuide2 = new GuideCircle(QRectF(x + 30, y + 30, 200, 200), 135, 270, GuideCircle::CCW);
new GuideLine(QPointF(x + 222, y + 38), this->qtGuide2);
new GuideCircle(QRectF(x, y, 260, 260), 135, 270, GuideCircle::CW, this->qtGuide2);
new GuideLine(QPointF(x + 59, y + 59), this->qtGuide2);
x = 115;
y = 10;
this->qtGuide3 = new GuideLine(QLineF(x, y, x + 30, y));
new GuideLine(QPointF(x + 30, y + 170), this->qtGuide3);
new GuideLine(QPointF(x, y + 170), this->qtGuide3);
new GuideLine(QPointF(x, y), this->qtGuide3);
this->qtGuide1->setFence(QRectF(0, 0, 800, 600));
this->qtGuide2->setFence(QRectF(0, 0, 800, 600));
this->qtGuide3->setFence(QRectF(0, 0, 800, 600));
}
开发者ID:Andreas665,项目名称:qt,代码行数:36,代码来源:itemcircleanimation.cpp
示例3: QGraphicsView
VLCStatsView::VLCStatsView( QWidget *parent ) : QGraphicsView( parent )
{
QColor history(0, 0, 0, 255),
total(237, 109, 0, 160),
content(109, 237, 0, 160);
scale( 1.0, -1.0 ); /* invert our Y axis */
setOptimizationFlags( QGraphicsView::DontAdjustForAntialiasing );
setAlignment( Qt::AlignLeft );
setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
viewScene = new QGraphicsScene( this );
historyShape = viewScene->addPolygon( QPolygonF(), QPen(Qt::NoPen),
QBrush(history) );
totalbitrateShape = viewScene->addPolygon( QPolygonF(), QPen(Qt::NoPen),
QBrush(total) );
setScene( viewScene );
reset();
QPen linepen( Qt::DotLine );
linepen.setBrush( QBrush( QColor( 33, 33, 33 ) ) );
for ( int i=0; i<3; i++ )
rulers[i] = viewScene->addLine( QLineF(), linepen );
}
开发者ID:12307,项目名称:VLC-for-VS2010,代码行数:24,代码来源:info_widgets.cpp
示例4: QLineF
double CanvasMode_EditSpiral::computeRealAngle(double angle, bool fromDia)
{
PageItem *currItem = m_doc->m_Selection->itemAt(0);
double ret = angle;
int rev = static_cast<int>(angle / 360.0);
double part = angle - (rev * 360);
QTransform bb;
bb.scale(currItem->width() / currItem->height(), 1.0);
QLineF inp = QLineF(QPointF(currItem->width() / 2.0, currItem->height() / 2.0), QPointF(currItem->width(), currItem->height() / 2.0));
inp.setAngle(part);
if (fromDia)
{
QLineF res = bb.map(inp);
ret = res.angle();
}
else
{
QTransform bt = bb.inverted();
QLineF res = bt.map(inp);
ret = res.angle();
}
ret += rev * 360;
return ret;
}
开发者ID:gyuris,项目名称:scribus,代码行数:24,代码来源:canvasmode_editspiral.cpp
示例5: body
// ============================================================================
/// Renders
void ControlSurface::render(QPainter& painter, const QRectF&, const RenderingOptions& )
{
painter.save();
painter.setTransform( body()->transform(), true );
painter.setPen( Qt::black );
double angle = ( _value*_step + _inclination ) *parent()->orientation();
double wx = cos( angle ) * _width/2;
double wy = sin( angle ) * _width/2;
painter.drawLine( QLineF( _position.x()-wx, _position.y()-wy, _position.x()+wx, _position.y()+wy ) );
painter.restore();
// draw force (DEBUG )
/*
double fs = 500 ; // force scale
QPointF wf = aerodynamicForce() / fs;
const b2Vec2& pos = body()->b2body()->GetWorldPoint( point2vec( _position ) );
painter.setPen( Qt::green );
painter.drawLine( QLineF( pos.x, pos.y, pos.x + wf.x(), pos.y + wf.y() ) );
*/
}
开发者ID:wot123,项目名称:flyer2d,代码行数:26,代码来源:controlsurface.cpp
示例6: qDeleteAll
void KiviatView::redrawAll()
{
//Delete markers and axes,keep the captions
qDeleteAll(markers);
qDeleteAll(axes);
markers.clear();
axes.clear();
setupAxesCaptions();
//Paint Axes and adjust label position
for(int i=0; i<axisCount; i++)
{
//Draw the axis-line
QGraphicsLineItem * line= scene.addLine(QLineF(QPointF(0,0),calcPosition(i,1)));
line->setZValue(1);
axes.push_back(line);
// Why Position 1.08? Pos 1.0 means end of axis
// label is positioned a litte bit further away from center
// also needed in setAxisLabel
QPointF lPos = calcPosition(i, 1.08);
axisLabels[i]->setPos(QPoint(0,0));
axisLabels[i]->moveBy(lPos.x(),lPos.y());
// If the axis is on the left side, the text has to be moved to the left
if( axisLabels[i]->pos().x()<0 )
axisLabels[i]->moveBy(- axisLabels[i]->boundingRect().width(),0);
}
//Call setMarkerCount with current count, to paint them
setMarkerCount(prop_markerCount);
redrawData();
}
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:36,代码来源:KiviatView.cpp
示例7: mapFromScene
void LineItem::creationPolygonChanged(View::CreationEvent event) {
if (event == View::EscapeEvent) {
ViewItem::creationPolygonChanged(event);
return;
}
if (event == View::MousePress) {
const QPolygonF poly = mapFromScene(view()->creationPolygon(View::MousePress));
setPos(poly.first().x(), poly.first().y());
setViewRect(QRectF(0.0, -sizeOfGrip().height()*0.5, 0.0, sizeOfGrip().height()));
view()->scene()->addItem(this);
return;
}
if (event == View::MouseMove) {
const QPolygonF poly = mapFromScene(view()->creationPolygon(View::MouseMove));
if (!rect().isEmpty()) {
rotateTowards(line().p2(), poly.last());
}
QRectF r = rect();
r.setSize(QSizeF(QLineF(line().p1(), poly.last()).length(), r.height()));
setViewRect(r);
return;
}
if (event == View::MouseRelease) {
const QPolygonF poly = mapFromScene(view()->creationPolygon(View::MouseRelease));
view()->disconnect(this, SLOT(deleteLater())); //Don't delete ourself
view()->disconnect(this, SLOT(creationPolygonChanged(View::CreationEvent)));
view()->setMouseMode(View::Default);
updateViewItemParent();
_created = true;
emit creationComplete();
return;
}
}
开发者ID:jhgorse,项目名称:kst,代码行数:36,代码来源:lineitem.cpp
示例8: p
QPointF SCgNode::cross(const QPointF &from, float dot) const
{
QPointF p(0.f, 0.f);
if (!mContentVisible)
{
QVector2D vec(from - scenePos());
p = vec.normalized().toPointF() * (mSize.width() / 2.f + 5.f);
}else
{
// count intersection with content border
QPolygonF polygon(boundingRect());
QPointF p1 = polygon.last();
QPointF p2, intersectPoint;
QLineF line, pair(p, mapFromScene(from));
bool haveItersect = false;
for (int i = 0; i < polygon.size(); i++)
{
p2 = polygon.at(i);
line = QLineF(p1, p2);
QLineF::IntersectType intersectType = line.intersect(pair, &intersectPoint);
if (intersectType == QLineF::BoundedIntersection)
{
haveItersect = true;
break;
}
p1 = p2;
}
p = haveItersect ? intersectPoint : p;
}
return mapToScene(p);
}
开发者ID:DavidBermuda,项目名称:kbe,代码行数:36,代码来源:scgnode.cpp
示例9: start
void ArcItem::updateArrowPath(){
QPainterPath path;
if((_endItem && _startItem->primaryShape().intersects(_endItem->primaryShape())) ||
(!_endItem && _startItem->primaryShape().contains(_end))){
_cachedArrowPath = path;
return;
}
QPointF start(0,0),
point = _end - pos();
//The arrow line and reverse liune
QLineF revline(point, start);
//Compute various points
QLineF s = revline.normalVector();
s.setAngle(revline.angle() - 45);
s.setLength(ARROW_SIZE);
QPointF side1 = s.p2();
s = revline.normalVector();
s.setAngle(revline.angle() + 45);
s.setLength(ARROW_SIZE);
QPointF side2 = s.p2();
s = QLineF(side1, side2);
QPointF head = point;
s.intersect(revline, &head);
path.moveTo(start);
path.lineTo(head);
path.lineTo(side1);
path.lineTo(point);
path.lineTo(side2);
path.lineTo(head);
_cachedArrowPath = path;
}
开发者ID:jonasfj,项目名称:PeTe,代码行数:36,代码来源:ArcItem.cpp
示例10: drawLine
/**
* @brief ... Draw vertical and horizontal axis on the frame. Marks are placed at step intervals in world reference frame
*
* @param c ... line color
* @param w ... line width
* @param step ...separation among axis marks
* @return void
**/
void RCDraw::drawAxis ( const QColor &c, int w, float step )
{
drawLine ( QLineF ( effWin.left(), effWin.center().y(), effWin.right(), effWin.center().y()), w );
for ( float i=effWin.center().x() ; i< effWin.right(); i+=step )
{
drawLine ( QLineF ( i, effWin.center().y()-step, i , effWin.center().y()+step), c, w );
}
for ( float i=effWin.center().x() ; i> effWin.left(); i-=step )
{
drawLine ( QLineF ( i, effWin.center().y()-step, i , effWin.center().y()+step), c, w );
}
drawLine ( QLineF ( effWin.center().x(), effWin.top(), effWin.center().x(), effWin.bottom()), w );
for ( float i=effWin.center().y() ; i< effWin.bottom(); i+=step )
{
drawLine ( QLineF ( effWin.center().x()-step, i, effWin.center().x()+step, i), c, w );
}
for ( float i=effWin.center().y() ; i> effWin.top(); i-=step )
{
drawLine ( QLineF ( effWin.center().x()-step, i, effWin.center().y()+step, i), c, w );
}
drawText(QPointF(effWin.center().x()+1, effWin.top()), "0.5 m", effWin.width()/20, Qt::black);
}
开发者ID:BasilMVarghese,项目名称:robocomp,代码行数:30,代码来源:rcdraw.cpp
示例11: QWidget
DataWidget::DataWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::DataWidget)
{
ui->setupUi(this);
ui->graphicsView->setScene(&scene_1);
ui->graphicsView_2->setScene(&scene_2);
ui->graphicsView_3->setScene(&scene_3);
QPen pen;
pen.setColor(Qt::white);
pen.setWidth(2);
scene_1.addRect(QRect(0,0,185,20),pen, QBrush(Qt::NoBrush));
scene_1.addRect(QRect(0,40,185,20),pen, QBrush(Qt::NoBrush));
scene_1.addRect(QRect(0,80,185,20),pen, QBrush(Qt::NoBrush));
scene_2.addRect(QRect(0,0,185,20),pen, QBrush(Qt::NoBrush));
scene_2.addRect(QRect(0,40,185,20),pen, QBrush(Qt::NoBrush));
scene_2.addRect(QRect(0,80,185,20),pen, QBrush(Qt::NoBrush));
line1 = scene_1.addLine(QLineF(0.5*185,0,0.5*185,20),pen);
line2 = scene_1.addLine(QLineF(0.5*185,40,0.5*185,60),pen);
line3 = scene_1.addLine(QLineF(0.5*185,80,0.5*185,100),pen);
line4 = scene_2.addLine(QLineF(0.5*185,0,0.5*185,20),pen);
line5 = scene_2.addLine(QLineF(0.5*185,40,0.5*185,60),pen);
line6 = scene_2.addLine(QLineF(0.5*185,80,0.5*185,100),pen);
circle1 = scene_3.addEllipse(QRect(0,0,30,30),pen);
circle2 = scene_3.addEllipse(QRect(0,35,30,30),pen);
circle3 = scene_3.addEllipse(QRect(0,70,30,30),pen);
changeLabelsColor();
drawData();
}
开发者ID:hoboris,项目名称:GloveMotion,代码行数:37,代码来源:datawidget.cpp
示例12: bottomLine
QLineF bottomLine(const QmlItemNode &qmlItemNode)
{
QRectF rectangle = qmlItemNode.instanceSceneTransform().mapRect(qmlItemNode.instanceBoundingRect()).adjusted(1, 0, 0, 0);
return QLineF(rectangle.bottomLeft(), rectangle.bottomRight());
}
开发者ID:darksylinc,项目名称:qt-creator,代码行数:6,代码来源:bindingindicator.cpp
示例13: qDrawShadePanel
void qDrawShadePanel(QPainter *p, int x, int y, int w, int h,
const QPalette &pal, bool sunken,
int lineWidth, const QBrush *fill)
{
if (w == 0 || h == 0)
return;
if (!(w > 0 && h > 0 && lineWidth >= 0)) {
qWarning("qDrawShadePanel: Invalid parameters");
}
QColor shade = pal.dark().color();
QColor light = pal.light().color();
if (fill) {
if (fill->color() == shade)
shade = pal.shadow().color();
if (fill->color() == light)
light = pal.midlight().color();
}
QPen oldPen = p->pen(); // save pen
QVector<QLineF> lines;
lines.reserve(2*lineWidth);
if (sunken)
p->setPen(shade);
else
p->setPen(light);
int x1, y1, x2, y2;
int i;
x1 = x;
y1 = y2 = y;
x2 = x+w-2;
for (i=0; i<lineWidth; i++) { // top shadow
lines << QLineF(x1, y1++, x2--, y2++);
}
x2 = x1;
y1 = y+h-2;
for (i=0; i<lineWidth; i++) { // left shado
lines << QLineF(x1++, y1, x2++, y2--);
}
p->drawLines(lines);
lines.clear();
if (sunken)
p->setPen(light);
else
p->setPen(shade);
x1 = x;
y1 = y2 = y+h-1;
x2 = x+w-1;
for (i=0; i<lineWidth; i++) { // bottom shadow
lines << QLineF(x1++, y1--, x2, y2--);
}
x1 = x2;
y1 = y;
y2 = y+h-lineWidth-1;
for (i=0; i<lineWidth; i++) { // right shadow
lines << QLineF(x1--, y1++, x2--, y2);
}
p->drawLines(lines);
if (fill) // fill with fill color
p->fillRect(x+lineWidth, y+lineWidth, w-lineWidth*2, h-lineWidth*2, *fill);
p->setPen(oldPen); // restore pen
}
开发者ID:crobertd,项目名称:qtbase,代码行数:61,代码来源:qdrawutil.cpp
示例14: qDrawShadeRect
void qDrawShadeRect(QPainter *p, int x, int y, int w, int h,
const QPalette &pal, bool sunken,
int lineWidth, int midLineWidth,
const QBrush *fill)
{
if (w == 0 || h == 0)
return;
if (! (w > 0 && h > 0 && lineWidth >= 0 && midLineWidth >= 0)) {
qWarning("qDrawShadeRect: Invalid parameters");
return;
}
QPen oldPen = p->pen();
if (sunken)
p->setPen(pal.dark().color());
else
p->setPen(pal.light().color());
int x1=x, y1=y, x2=x+w-1, y2=y+h-1;
if (lineWidth == 1 && midLineWidth == 0) {// standard shade rectangle
p->drawRect(x1, y1, w-2, h-2);
if (sunken)
p->setPen(pal.light().color());
else
p->setPen(pal.dark().color());
QLineF lines[4] = { QLineF(x1+1, y1+1, x2-2, y1+1),
QLineF(x1+1, y1+2, x1+1, y2-2),
QLineF(x1, y2, x2, y2),
QLineF(x2,y1, x2,y2-1) };
p->drawLines(lines, 4); // draw bottom/right lines
} else { // more complicated
int m = lineWidth+midLineWidth;
int i, j=0, k=m;
for (i=0; i<lineWidth; i++) { // draw top shadow
QLineF lines[4] = { QLineF(x1+i, y2-i, x1+i, y1+i),
QLineF(x1+i, y1+i, x2-i, y1+i),
QLineF(x1+k, y2-k, x2-k, y2-k),
QLineF(x2-k, y2-k, x2-k, y1+k) };
p->drawLines(lines, 4);
k++;
}
p->setPen(pal.mid().color());
j = lineWidth*2;
for (i=0; i<midLineWidth; i++) { // draw lines in the middle
p->drawRect(x1+lineWidth+i, y1+lineWidth+i, w-j-1, h-j-1);
j += 2;
}
if (sunken)
p->setPen(pal.light().color());
else
p->setPen(pal.dark().color());
k = m;
for (i=0; i<lineWidth; i++) { // draw bottom shadow
QLineF lines[4] = { QLineF(x1+1+i, y2-i, x2-i, y2-i),
QLineF(x2-i, y2-i, x2-i, y1+i+1),
QLineF(x1+k, y2-k, x1+k, y1+k),
QLineF(x1+k, y1+k, x2-k, y1+k) };
p->drawLines(lines, 4);
k++;
}
}
if (fill) {
QBrush oldBrush = p->brush();
int tlw = lineWidth + midLineWidth;
p->setPen(Qt::NoPen);
p->setBrush(*fill);
p->drawRect(x+tlw, y+tlw, w-2*tlw, h-2*tlw);
p->setBrush(oldBrush);
}
p->setPen(oldPen); // restore pen
}
开发者ID:crobertd,项目名称:qtbase,代码行数:70,代码来源:qdrawutil.cpp
示例15: Q_ASSERT
void QcWaveform::paintEvent( QPaintEvent *ev )
{
Q_ASSERT( pixmap != 0 );
QPainter p( this );
// if loading draw progress
if( _cache && _cache->loading() ) {
QRect r( rect() );
p.fillRect( r, QColor(100,100,100) );
r.setRight( r.right() * _cache->loadProgress() / 100 );
p.fillRect( r, QColor( 0, 0, 0 ) );
p.setPen( QColor(255,255,255) );
QTextOption opt;
opt.setAlignment( Qt::AlignCenter );
p.drawText( rect(), "loading...", opt );
return;
}
p.fillRect( rect(), _bkgColor );
// draw waveform on pixmap
if( _drawWaveform && dirty ) {
draw( pixmap, 0, width(), _beg, _dur );
dirty = false;
}
// draw selections
p.save();
p.scale( (double) width() / _dur, 1.0 );
p.translate( _beg * -1.0, 0.0 );
p.setPen( Qt::NoPen );
int i;
for( i = 0; i < 64; ++i ) {
const Selection &s = _selections[i];
if( s.size > 0 ) {
QRectF r ( s.start, 0, s.size, height() );
p.setBrush( s.color );
p.drawRect( r );
}
}
p.restore();
// draw time grid
if( _showGrid && sfInfo.samplerate > 0 && _gridResolution > 0.f ) {
p.save();
double durSecs = (double) _dur / sfInfo.samplerate;
double begSecs = (double) _beg / sfInfo.samplerate;
p.scale( width() / durSecs, 1.0 );
p.setPen( _gridColor );
double offset = _gridOffset - begSecs;
offset -= ( floor( offset / _gridResolution ) * _gridResolution );
while( offset < durSecs ) {
p.drawLine( QLineF( offset, 0.0, offset, height() ) );
offset += _gridResolution;
}
p.restore();
}
// paste the waveform pixmap on screen
if( _drawWaveform )
p.drawPixmap( ev->rect(), *pixmap, ev->rect() );
// draw cursor
if( _showCursor && _cursorPos >= _beg && _cursorPos < _beg + _dur ) {
double cursorX = (_cursorPos - _beg) / _fpp;
p.setPen( _cursorColor );
p.drawLine( QLineF( cursorX, 0, cursorX, height() ) );
}
}
开发者ID:acamari,项目名称:supercollider,代码行数:82,代码来源:view.cpp
示例16: QLineF
QLineF Articulation::dragAnchor() const
{
return QLineF(canvasPos(), parent()->canvasPos());
}
开发者ID:33akash,项目名称:MuseScore,代码行数:4,代码来源:articulation.cpp
示例17: QGraphicsTextItem
void SelectionItem::updateDeltaLines()
{
qreal x1, x2;
x1 = this->leftSelected->x();
x2 = this->rightSelected->sceneBoundingRect().bottomRight().x();
// Text label for the delta between the left selected and the earlier item
if (this->before) {
if (textBefore == NULL && lineBefore == NULL) {
// Create the elements
textBefore = new QGraphicsTextItem(this);
textBefore->setPlainText(QString::number(this->leftSelected->x() - this->before->pos().x()));
textBefore->setPos(this->mapFromScene(x1 - textBefore->sceneBoundingRect().width(), 30.0));
lineBefore = new QGraphicsLineItem(this);
//qDebug() << "new lineBefore "<<this->leftSelected->x()<<this->before->pos().x();
lineBefore->setLine(QLineF(this->mapFromScene(this->leftSelected->x(), 30.0),
this->mapFromScene(this->before->pos().x(), 30.0)));
}
else {
// Update the line and text label
qreal d = this->leftSelected->x() - this->before->pos().x();
//if (d < 0) {
// We have crossed one item, update the atfer and before item
TimelineScene *timeline = qobject_cast<TimelineScene *>(this->leftSelected->scene());
this->before = timeline->getTriggerItemBefore(this->leftSelected);
this->after = timeline->getTriggerItemAfter(this->rightSelected);
if (this->before) {
// Update the before line
d = this->leftSelected->x() - this->before->pos().x();
QLineF line = this->lineBefore->line();
QPointF p2 = line.p2();
p2.setX(this->mapFromScene(this->before->pos()).x());
line.setP2(p2);
line.setLength(d);
this->lineBefore->setLine(line);
textBefore->setPlainText(QString::number(d));
} else {
// No more before item, remove everything
qDebug() << "Remove before item";
timeline->removeItem(this->lineBefore);
delete this->lineBefore;
this->lineBefore = NULL;
timeline->removeItem(this->textBefore);
delete this->textBefore;
this->textBefore = NULL;
}
// the after line will be handled in the next part of this method
/*} else {
textBefore->setPlainText(QString::number(d));
QLineF line = this->lineBefore->line();
line.setLength(d);
this->lineBefore->setLine(line);
}*/
}
}
// Text label for the delta between the right selected and the later item
if (this->after) {
if (textAfter == NULL && lineAfter == NULL) {
// Create
textAfter = new QGraphicsTextItem(this);
textAfter->setPlainText(QString::number(this->after->pos().x() - this->rightSelected->x()));
textAfter->setPos(this->mapFromScene(x2, 40.0));
lineAfter = new QGraphicsLineItem(this);
lineAfter->setLine(QLineF(this->mapFromScene(this->rightSelected->x(), 40.0),
this->mapFromScene(this->after->pos().x(), 40.0)));
qDebug() << "Create lineAfter" << QLineF(this->mapFromScene(this->rightSelected->x(), 40.0),
this->mapFromScene(this->after->pos().x(), 40.0));
}
else {
// Update
qreal d = this->after->pos().x() - this->rightSelected->x();
//if (d < 0) {
// We have crossed one item, update the atfer and before item
TimelineScene *timeline = qobject_cast<TimelineScene *>(this->leftSelected->scene());
this->before = timeline->getTriggerItemBefore(this->leftSelected);
this->after = timeline->getTriggerItemAfter(this->rightSelected);
if (this->after) {
// Update the after line
d = this->after->pos().x() - this->rightSelected->x();
QLineF line = this->lineAfter->line();
QPointF p2 = line.p2();
p2.setX(this->mapFromScene(this->after->pos()).x());
line.setP2(p2);
line.setLength(d);
this->lineAfter->setLine(line);
textAfter->setPlainText(QString::number(d));
qDebug() << "Update lineAfter" << line;
} else {
// No more after item, remove everything
qDebug() << "Remove after item";
timeline->removeItem(this->lineAfter);
delete this->lineAfter;
this->lineAfter = NULL;
timeline->removeItem(this->textAfter);
delete this->textAfter;
//.........这里部分代码省略.........
开发者ID:njustin,项目名称:TestGV,代码行数:101,代码来源:selectionitem.cpp
示例18: switch
//.........这里部分代码省略.........
m_currentIndex = -1;
break;
case QEvent::MouseMove:
if (!m_fingerPointMapping.isEmpty())
return true;
if (m_currentIndex >= 0)
movePoint(m_currentIndex, ((QMouseEvent *)event)->pos());
break;
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
{
const QTouchEvent *const touchEvent = static_cast<const QTouchEvent*>(event);
const QList<QTouchEvent::TouchPoint> points = touchEvent->touchPoints();
const qreal pointSize = qMax(m_pointSize.width(), m_pointSize.height());
Q_FOREACH (const QTouchEvent::TouchPoint &touchPoint, points) {
const int id = touchPoint.id();
switch (touchPoint.state()) {
case Qt::TouchPointPressed:
{
// find the point, move it
QSet<int> activePoints = QSet<int>::fromList(m_fingerPointMapping.values());
int activePoint = -1;
qreal distance = -1;
const int pointsCount = m_points.size();
const int activePointCount = activePoints.size();
if (pointsCount == 2 && activePointCount == 1) { // only two points
activePoint = activePoints.contains(0) ? 1 : 0;
} else {
for (int i=0; i<pointsCount; ++i) {
if (activePoints.contains(i))
continue;
qreal d = QLineF(touchPoint.pos(), m_points.at(i)).length();
if ((distance < 0 && d < 12 * pointSize) || d < distance) {
distance = d;
activePoint = i;
}
}
}
if (activePoint != -1) {
m_fingerPointMapping.insert(touchPoint.id(), activePoint);
movePoint(activePoint, touchPoint.pos());
}
}
break;
case Qt::TouchPointReleased:
{
// move the point and release
QHash<int,int>::iterator it = m_fingerPointMapping.find(id);
movePoint(it.value(), touchPoint.pos());
m_fingerPointMapping.erase(it);
}
break;
case Qt::TouchPointMoved:
{
// move the point
const int pointIdx = m_fingerPointMapping.value(id, -1);
if (pointIdx >= 0) // do we track this point?
movePoint(pointIdx, touchPoint.pos());
}
break;
default:
break;
}
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:67,代码来源:hoverpoints.cpp
示例19: setLine
void EdgeItem::setToPoint( int x, int y )
{
setLine(QLineF( line().p1().x(), line().p1().y(), x, y ));
}
开发者ID:Andreas665,项目名称:qt,代码行数:4,代码来源:canvas.cpp
示例20: QLineF
QLineF Line::line() const
{
return QLineF(mX1, mY1, mX2, mY2);
}
开发者ID:nfrey,项目名称:qreal,代码行数:4,代码来源:line.cpp
注:本文中的QLineF函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论