QList<QPointF> QLogicCircuitShapeConnector::defaultConnector() const
{
    QList<QPointF> points;
    QList<QPointF> sections;
    QLineF line(startPos(), endPos());
    QLineF lineEnd;
    QLineF lineStart;

    line = QLineF(startPos(), endPos());

    lineStart.setP1(startPos());
    lineEnd.setP1(endPos());

    switch(orientationAtStart()){
    case QDiagramToolkit::East:
        if (line.dx() < 20){
            lineStart.setP2(startPos() + QPointF(20, 0));

            lineEnd.setP2(lineEnd.p1() - QPointF(20, 0));
            sections << QPointF(lineStart.p2().x(), lineStart.p1().y() + line.dy() / 2)
                          << QPointF(lineEnd.p2().x(), lineEnd.p2().y() - line.dy() / 2);
        } else {
            lineStart.setP2(lineStart.p1() + QPointF(line.dx() / 2 , 0));

            lineEnd.setP2(QPointF(lineStart.p2().x(), lineEnd.p1().y()));
        }
        break;
    case QDiagramToolkit::West:
        if (line.dx() > -20){
            lineStart.setP2(startPos() - QPointF(20, 0));

            lineEnd.setP2(lineEnd.p1() + QPointF(20, 0));
            sections << QPointF(lineStart.p2().x(), lineStart.p1().y() + line.dy() / 2)
                          << QPointF(lineEnd.p2().x(), lineEnd.p2().y() - line.dy() / 2);
        } else {
            lineStart.setP2(lineStart.p1() + QPointF(line.dx() / 2 , 0));

            lineEnd.setP2(QPointF(lineStart.p2().x(), lineEnd.p1().y()));
        }
        break;
    default:
        break;
    }


    points.append(lineStart.p1());
    points.append(lineStart.p2());
    QListIterator<QPointF> it(sections);
    while(it.hasNext()){
        points.append(it.next());
    }
    points.append(lineEnd.p2());
    points.append(lineEnd.p1());
    return points;
}
void Connection::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
    QGraphicsObject::mouseReleaseEvent(event);
    if (drag_state == CONNECTED)
        return;

    ungrabMouse();
    clearFocus();
    setFlag(QGraphicsItem::ItemIsFocusable, false);

    InputPort* t = gscene()->getInputPortAt(endPos());
    Datum* datum = target ? target->getDatum() : NULL;
    if (t && datum->acceptsLink(source->getDatum()))
    {
        target = t;
        t->install(this);

        datum->installLink(source->getDatum());
        drag_state = CONNECTED;
        App::instance()->pushStack(
                new UndoAddLinkCommand(source->getDatum(), datum));
        onPortsMoved();

        emit(changed());
    }
    else
    {
        deleteLater();
    }

    prepareGeometryChange();
}
Beispiel #3
0
bool NavGrid::FindPath(const CU::Vector3f& aStartPoint, const CU::Vector3f& aEndPoint, CU::GrowingArray<CU::Vector2f>& aOutPath)
{
	CU::Vector2i startPos(static_cast<int>(aStartPoint.x), static_cast<int>(aStartPoint.z));
	CU::Vector2i endPos(static_cast<int>(aEndPoint.x), static_cast<int>(aEndPoint.z));

	return FindPath(startPos, endPos, aOutPath);
}
Beispiel #4
0
QPainterPath Connection::path(bool only_bezier) const
{
    QPointF start = startPos();
    QPointF end = endPos();

    float length = 50;
    if (end.x() <= start.x())
    {
        length += (start.x() - end.x()) / 2;
    }

    QPainterPath p;
    p.moveTo(start);
    if (only_bezier)
        p.moveTo(start + QPointF(15, 0));
    else
        p.lineTo(start + QPointF(15, 0));

    p.cubicTo(QPointF(start.x() + length, start.y()),
              QPointF(end.x() - length, end.y()),
              QPointF(end.x() - 15, end.y()));

    if (!only_bezier)
        p.lineTo(end);

   return p;
}
/*
-------------------------------------------------------------------------------

    Class: CStifSectionParser

    Method: GetItemLineL

    Description: Parses a line for items parsing.

    If start tag is empty the parsing starts beging of the section.

    Parameters: const TDesC& aTag: in: Indicates parsing start point.
                TTagToReturnValue aTagIndicator: in: Will aTag included to the
                returned object(For default the tag will be added)

    Return Values:  CStifItemParser* : pointer to CStifItemParser object
                    NULL will return if ParseStartAndEndPos() method returns -1
                    NULL will return if length is 0 or negative
                    NULL will return if iStartPos is 0

    Errors/Exceptions: Leaves if called CStifItemParser::NewL method fails

    Status: Approved

-------------------------------------------------------------------------------
*/
EXPORT_C CStifItemParser* CStifSectionParser::GetItemLineL( const TDesC& aTag,
                                            TTagToReturnValue aTagIndicator )
    {
    TInt startPos( 0 );
    TInt endPos( 0 );
    TInt length( 0 );

    // Indicator that GetItemLineL has been used
    iLineIndicator = ETrue;

    iSkipAndMarkPos = 0;

    TInt ret = ParseStartAndEndPos( iSection, aTag, aTagIndicator,
                                    startPos, endPos, length );

    // No parsing found
    if ( KErrNone != ret || length <= 0 || startPos < 0 )
        {
        __TRACE( 
            KInfo, ( _L( "STIFPARSER: GetItemLineL method returns a NULL" ) ) );
        return NULL;
        }

    CStifItemParser* line = CStifItemParser::NewL(
                                            iSection, startPos, length );

    return line;

    }
bool TextFieldTTFActionTest::onTextFieldDeleteBackward(CCTextFieldTTF * pSender, const char * delText, int nLen)
{
    // create a delete text sprite aScut do some action
    CCLabelTTF * label = CCLabelTTF::create(delText, FONT_NAME, FONT_SIZE);
    this->addChild(label);

    // move the sprite to fly out
    CCPoint beginPos = pSender->getPosition();
    CCSize textfieldSize = pSender->getContentSize();
    CCSize labelSize = label->getContentSize();
    beginPos.x += (textfieldSize.width - labelSize.width) / 2.0f;
    
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    CCPoint endPos(- winSize.width / 4.0f, winSize.height * (0.5 + (float)raScut() / (2.0f * RAScut_MAX)));

    float duration = 1;
    float rotateDuration = 0.2f;
    int repeatTime = 5; 
    label->setPosition(beginPos);

    CCAction * seq = CCSequence::create(
        CCSpawn::create(
            CCMoveTo::create(duration, endPos),
            CCRepeat::create(
                CCRotateBy::create(rotateDuration, (raScut()%2) ? 360 : -360),
                repeatTime),
            CCFadeOut::create(duration),
        0),
        CCCallFuncN::create(this, callfuncN_selector(TextFieldTTFActionTest::callbackRemoveNodeWhendidAction)),
        0);
    label->runAction(seq);
    return false;
}
Beispiel #7
0
bool GameObject::tileCollisions(Vector2D pos){
    for(vector<TileLayer*>::iterator i = collisionLayers->begin(); i != collisionLayers->end(); i++){
        TileLayer* tileLayer = (*i);
        vector<vector<int>> tiles = tileLayer->getTileIDs();

        Vector2D layerPos = tileLayer->getPosition();

        int x, y, tileColumn, tileRow, tileid = 0;

        x = layerPos.X() / tileLayer->getTileSize();
        y = layerPos.Y() / tileLayer->getTileSize();

        Vector2D startPos = pos;
        startPos.setX( startPos.X() + 3);
        startPos.setY( startPos.Y() + 4);
        Vector2D endPos(pos.X() + collisionWidth, pos.Y() + collisionHeight - 4);

        for(int i = startPos.X(); i < endPos.X(); i++) {
            for(int j = startPos.Y(); j < endPos.Y(); j++) {
                tileColumn = i / tileLayer->getTileSize();
                tileRow = j / tileLayer->getTileSize();

                tileid = tiles[tileRow + y][tileColumn + x];

                if(tileid != 0) {
                    return true;
                }
            }
        }
    }
    return false;
}
bool TextFieldTTFActionTest::onTextFieldDeleteBackward(TextFieldTTF * sender, const char * delText, int nLen)
{
    // create a delete text sprite and do some action
    auto label = LabelTTF::create(delText, FONT_NAME, FONT_SIZE);
    this->addChild(label);

    // move the sprite to fly out
    auto beginPos = sender->getPosition();
    auto textfieldSize = sender->getContentSize();
    auto labelSize = label->getContentSize();
    beginPos.x += (textfieldSize.width - labelSize.width) / 2.0f;
    
    auto winSize = Director::getInstance()->getWinSize();
    Point endPos(- winSize.width / 4.0f, winSize.height * (0.5 + (float)kdRand() / (2.0f * KD_RAND_MAX)));

    float duration = 1;
    float rotateDuration = 0.2f;
    int repeatTime = 5; 
    label->setPosition(beginPos);

    auto seq = Sequence::create(
        Spawn::create(
            MoveTo::create(duration, endPos),
            Repeat::create(
                RotateBy::create(rotateDuration, (kdRand()%2) ? 360 : -360),
                repeatTime),
            FadeOut::create(duration),
        NULL),
        CallFuncN::create(CC_CALLBACK_1(TextFieldTTFActionTest::callbackRemoveNodeWhenDidAction, this)),
        NULL);
    label->runAction(seq);
    return false;
}
/*
-------------------------------------------------------------------------------

    Class: CStifSectionParser

    Method: GetNextLine

    Description: Get a line

    Search an item from the section and return rest of the line.

    Parameters: TPtr& aLine: inout: Parsed line

    Return Values: TInt: Error code

    Errors/Exceptions: None

    Status: Approved

-------------------------------------------------------------------------------
*/
EXPORT_C TInt CStifSectionParser::GetNextLine( TPtrC& aLine )
    {
    TInt ret( KErrNone );

    // GetLine() or GetItemLineL() method is not called
    if ( !iLineIndicator )
        {
        return KErrNotReady;
        }

    TInt startPos( 0 );
    TInt endPos( 0 );
    TInt length( 0 );

    // tagIndicator has no meaning in this method
    TTagToReturnValue tagIndicator( ETag );

    ret = ParseStartAndEndPos( iSection, KNullDesC, tagIndicator,
                                startPos, endPos, length );
    if ( KErrNone != ret )
        {
        // Nothing to parse
        return ret;
        }

    aLine.Set( &iSection[startPos], length );

    return KErrNone;

    }
float SCurveData::GetCurveValue(float fProgress, float fStartTime, float fEndTime, const SCurveKey* pStartKey, const SCurveKey* pEndKey) const
{
    BEATS_ASSERT(BEATS_FLOAT_GREATER_EQUAL_EPSILON(fProgress, fStartTime, 0.001f) && BEATS_FLOAT_LESS_EQUAL_EPSILON(fProgress, fEndTime, 0.001f));
    BEATS_ASSERT(BEATS_FLOAT_GREATER_EQUAL_EPSILON(fStartTime, 0, 0.001f) && BEATS_FLOAT_LESS_EQUAL_EPSILON(fEndTime, 1.0f, 0.001f));
    static const float UNITY_YX_RATE = 0.625f; // The curve value depends on the coordinate rate: height / width
    CVec2 startPos(fStartTime, pStartKey->m_fValue * UNITY_YX_RATE);
    CVec2 endPos(fEndTime, pEndKey->m_fValue * UNITY_YX_RATE);
    static const float UNITY_MAGIC_FACTOR = 0.333333f;
    float tangLengthX = fabs(fStartTime - fEndTime) * UNITY_MAGIC_FACTOR;
    float tangLengthY = tangLengthX;
    float tgOut = pStartKey->m_fOutSlope * UNITY_YX_RATE;
    float tgIn = pEndKey->m_fInSlope * UNITY_YX_RATE;
    CVec2 startCtrlPos = startPos;
    CVec2 endCtrlPos = endPos;
    startCtrlPos.X() += tangLengthX;
    startCtrlPos.Y() += tangLengthY * tgOut;
    endCtrlPos.X() -= tangLengthX;
    endCtrlPos.Y() -= tangLengthY * tgIn;
    float s = (fProgress - fStartTime) / (fEndTime - fStartTime);
    float s2 = s * s;
    float s3 = s2 * s;
    float h1 = -s3 + 3 * s2 - 3 * s + 1;
    float h2 = s3;
    float h3 = 3 * s3 - 6 * s2 + 3 * s;
    float h4 = -3 * s3 + 3 * s2;
    CVec2 ret = startPos * h1 + endPos * h2 + startCtrlPos * h3 + endCtrlPos * h4;

    BEATS_ASSERT(fabs(fProgress - ret.X()) < 0.0001f);
    return ret.Y() / UNITY_YX_RATE;
}
Beispiel #11
0
ItemInfo AbstractClipItem::info() const
{
    ItemInfo info = m_info;
    info.cropStart = cropStart();
    info.endPos = endPos();
    return info;
}
Beispiel #12
0
void Connection::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
    QGraphicsObject::mouseReleaseEvent(event);
    if (drag_state == CONNECTED)
        return;

    ungrabMouse();
    clearFocus();
    setFlag(QGraphicsItem::ItemIsFocusable, false);

    InputPort* target = gscene()->getInputPortAt(endPos());
    Datum* datum = target ? target->getDatum() : NULL;
    if (target && datum->acceptsLink(link))
    {
        datum->addLink(link);
        drag_state = CONNECTED;

        connect(endInspector(), &NodeInspector::moved,
                this, &Connection::onInspectorMoved);
        connect(endInspector(), &NodeInspector::hiddenChanged,
                this, &Connection::onHiddenChanged);

        App::instance()->pushStack(new UndoAddLinkCommand(link));
    }
    else
    {
        link->deleteLater();
    }

    prepareGeometryChange();
}
Beispiel #13
0
    //-------------------------------------------------------------------------
    size_t ParserPos::operator-(const ParserPos &inPos) const
    {
      ParserPos startPos = inPos;
      ParserPos endPos(*this);

      const char *start = startPos.mPos;

      if (!start)
      {
        if (endPos.isEOF())
          return 0;

        startPos.setSOF();
        startPos.mPos += strlen(startPos.mPos);
        start = startPos.mPos;
      }

      const char *end = endPos.mPos;
      if (!end)
      {
        if (startPos.isEOF())
          return 0;

        endPos.setSOF();
        endPos.mPos += strlen(endPos.mPos);
        end = endPos.mPos;
      }

      return end - start;
    }
Beispiel #14
0
/*
-------------------------------------------------------------------------------

    Class: CStifSectionParser

    Method: GetNextLine

    Description: Get a line with tag

    Search a next line with the required tag from the section. If start tag
    is empty the parsing starts beging of the section.

    Parameters: const TDesC& aTag: in: Indicates parsing start point
                TPtr& aLine: inout: Parsed line
                TTagToReturnValue aTagIndicator: in: Will aTag included to the
                returned value(For default the tag will be added)

    Return Values: TInt: Error code

    Errors/Exceptions: None

    Status: Approved

-------------------------------------------------------------------------------
*/
EXPORT_C TInt CStifSectionParser::GetNextLine( const TDesC& aTag, TPtrC& aLine,
                                            TTagToReturnValue aTagIndicator )
    {
    TInt ret( KErrNone );

    // GetLine() or GetItemLineL() method is not called
    if ( !iLineIndicator )
        {
        return KErrNotReady;
        }

    TInt startPos( 0 );
    TInt endPos( 0 );
    TInt length( 0 );

    ret = ParseStartAndEndPos( iSection, aTag, aTagIndicator,
                                startPos, endPos, length );
    if ( KErrNone != ret )
        {
        // Nothing to parse
        return ret;
        }

    aLine.Set( &iSection[startPos], length );

    return KErrNone;

    }
Beispiel #15
0
/*
-------------------------------------------------------------------------------

    Class: CStifSectionParser

    Method: GetNextItemLineL

    Description: Parses a next line for items parsing with a tag.

    If start tag is empty the parsing starts beging of the section.

    Parameters: const TDesC& aTag: in: Indicates parsing start point
                TTagToReturnValue aTagIndicator: in: Will aTag included to the
                returned object(For default the tag will be added)

    Return Values:  CStifItemParser* : pointer to CStifItemParser object
                    NULL will return if iLineIndicator is false
                    NULL will return if ParseStartAndEndPos() method returns -1
                    NULL will return if length is 0 or negative
                    NULL will return if iStartPos is 0

    Errors/Exceptions: Leaves if called CStifItemParser::NewL method fails

    Status: Approved

-------------------------------------------------------------------------------
*/
EXPORT_C CStifItemParser* CStifSectionParser::GetNextItemLineL(
                                            const TDesC& aTag,
                                            TTagToReturnValue aTagIndicator )
    {
    // GetLine() or GetItemLineL() method is not called
    if ( !iLineIndicator )
        {
        __TRACE( KInfo, 
            ( _L( "STIFPARSER: GetNextItemLineL method returns a NULL" ) ) );
        return NULL;
        }

    TInt startPos( 0 );
    TInt endPos( 0 );
    TInt length( 0 );

    TInt ret = ParseStartAndEndPos( iSection, aTag, aTagIndicator,
                                    startPos, endPos, length );
    // No parsing found
    if ( KErrNone != ret || length <= 0 || startPos < 0 )
        {
        __TRACE( KInfo, 
            ( _L( "STIFPARSER: GetNextItemLineL method returns a NULL" )  ) );
        return NULL;
        }

    CStifItemParser* line = CStifItemParser::NewL(
                                            iSection, startPos, length );

    return line;

    }
Beispiel #16
0
/*
-------------------------------------------------------------------------------

    Class: CStifSectionParser

    Method: GetLine

    Description: Get a line.

    Search an item from the section and return rest of the line. If start tag 
    is empty the parsing starts beging of the section.

    Parameters: const TDesC& aTag: in: Indicates parsing start point
                TPtr& aLine: inout: Parsed line
                TTagToReturnValue aTagIndicator: in: Will aTag included to the
                returned value(For default the tag will be added)

    Return Values: TInt: Error code

    Errors/Exceptions: None

    Status: Approved

-------------------------------------------------------------------------------
*/
EXPORT_C TInt CStifSectionParser::GetLine( const TDesC& aTag,
                                            TPtrC& aLine,
                                            TTagToReturnValue aTagIndicator )
    {
    TInt ret( KErrNone );

    if ( 0 == iSection.Length() )
        {
        return KErrNotFound;
        }

    // Indicator that GetLine has been used
    iLineIndicator = ETrue;

    TInt startPos( 0 );
    TInt endPos( 0 );
    TInt length( 0 );

    iSkipAndMarkPos = 0;

    ret = ParseStartAndEndPos( iSection, aTag, aTagIndicator,
                                startPos, endPos, length );

    if ( KErrNone != ret )
        {
        // Nothing to parse
        return ret;
        }

    aLine.Set( &iSection[startPos], length );

    return KErrNone;

    }
void KexiAnimatedLayout::Private::animateTo(QWidget* destination)
{
    QWidget *from = q->currentWidget();
    Q_ASSERT(destination && from);
    destinationWidget = destination;
    if (from == destinationWidget)
        return;
    if (!(KexiUtils::graphicEffectsLevel() & KexiUtils::SimpleAnimationEffects))
    {
        // animations not allowed: switch to destination widget immediately
        animationFinished();
        return;
    }
    bool toRight = q->currentIndex() < q->indexOf(destinationWidget);
    hide();
    setParent(from);
    QSize s(from->parentWidget()->size());
    QPoint startPos(toRight ? QPoint(0, 0) : QPoint(s.width(), 0));
    QPoint endPos(toRight ? QPoint(s.width(), 0) : QPoint(0, 0));
    animation.setStartValue(-startPos);
    animation.setEndValue(-endPos);
    buffer = QPixmap(s.width() * 2, s.height());
    buffer.fill(Qt::white);
    from->render(&buffer, startPos);
    //qDebug() << s << from->geometry() << destinationWidget->geometry();
    destinationWidget->resize(from->size()); // needed because destination could
                                               // have been never displayed
    destinationWidget->render(&buffer, endPos);
    resize(buffer.size());
    move(animation.startValue().toPoint().x(), animation.startValue().toPoint().y());
    show();
    animation.start();
}
Beispiel #18
0
void AbstractClipItem::resizeEnd(int posx, bool /*emitChange*/)
{
    GenTime durationDiff = GenTime(posx, m_fps) - endPos();
    if (durationDiff == GenTime()) return;
    if (cropDuration() + durationDiff <= GenTime()) {
        durationDiff = GenTime() - (cropDuration() - GenTime(3, m_fps));
    }

    m_info.cropDuration += durationDiff;
    m_info.endPos += durationDiff;

    setRect(0, 0, cropDuration().frames(m_fps) - 0.02, rect().height());
    if (durationDiff > GenTime()) {
        QList <QGraphicsItem *> collisionList = collidingItems(Qt::IntersectsItemBoundingRect);
        bool fixItem = false;
        for (int i = 0; i < collisionList.size(); ++i) {
            if (!collisionList.at(i)->isEnabled()) continue;
            QGraphicsItem *item = collisionList.at(i);
            if (item->type() == type() && item->pos().x() > pos().x()) {
                //kDebug() << "/////////  COLLISION DETECTED!!!!!!!!!";
                //kDebug() << "/////////  CURRENT: " << startPos().frames(25) << "x" << endPos().frames(25) << ", RECT: " << rect() << "-" << pos();
                //kDebug() << "/////////  COLLISION: " << ((AbstractClipItem *)item)->startPos().frames(25) << "x" << ((AbstractClipItem *)item)->endPos().frames(25) << ", RECT: " << ((AbstractClipItem *)item)->rect() << "-" << item->pos();
                GenTime diff = ((AbstractClipItem *)item)->startPos() - startPos();
                if (fixItem == false || diff < m_info.cropDuration) {
                    fixItem = true;
                    m_info.cropDuration = diff;
                }
            }
        }
        if (fixItem) setRect(0, 0, cropDuration().frames(m_fps) - 0.02, rect().height());
    }
}
Beispiel #19
0
void AbstractClipItem::resizeEnd(int posx, bool /*emitChange*/)
{
    GenTime durationDiff = GenTime(posx, m_fps) - endPos();
    if (durationDiff == GenTime()) return;
    if (cropDuration() + durationDiff <= GenTime()) {
        durationDiff = GenTime() - (cropDuration() - GenTime(3, m_fps));
    }

    m_info.cropDuration += durationDiff;
    m_info.endPos += durationDiff;

    setRect(0, 0, cropDuration().frames(m_fps) - 0.02, rect().height());
    if (durationDiff > GenTime()) {
        QList <QGraphicsItem *> collisionList = collidingItems(Qt::IntersectsItemBoundingRect);
        bool fixItem = false;
        for (int i = 0; i < collisionList.size(); ++i) {
            if (!collisionList.at(i)->isEnabled()) continue;
            QGraphicsItem *item = collisionList.at(i);
            if (item->type() == type() && item->pos().x() > pos().x()) {
                GenTime diff = static_cast<AbstractClipItem*>(item)->startPos() - startPos();
                if (fixItem == false || diff < m_info.cropDuration) {
                    fixItem = true;
                    m_info.cropDuration = diff;
                }
            }
        }
        if (fixItem) setRect(0, 0, cropDuration().frames(m_fps) - 0.02, rect().height());
    }
}
void RegexGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
    // Check if we have moved the mouse enough to start a drag event
    if (QLineF(
                event->screenPos(),
                event->buttonDownScreenPos(Qt::LeftButton)
            ).length() < QApplication::startDragDistance())
        return;

    // Create a new drag event with some mime data
    QDrag *drag = new QDrag(event->widget());
    QMimeData *mime = new QMimeData;

    // Attach the necessary information to handle the event, the position of
    // this element in the token sequence, and the end of this token slice (if
    // different)
    mime->setData("text/x-regexp-start-pos", QVariant(tokenPos()).toByteArray());
    mime->setData("text/x-regexp-end-pos", QVariant(endPos()).toByteArray());
    drag->setMimeData(mime);

    // Create a scaled down image of the regexp item being dragged and use
    // that as the pixmap image to drag around (so it's clear what element
    // is attached to the drag event)
    QPixmap image(this->boundingRect().width()*0.75, this->boundingRect().height()*0.75);
    QPainter painter(&image);
    painter.setRenderHint(QPainter::Antialiasing);
    scene()->render(&painter, QRectF(), this->sceneBoundingRect());
    painter.end();

    // Attach the scaled down image to the drag event
    drag->setPixmap(image);

    // Execute the drag event
    drag->exec();
}
Beispiel #21
0
int
plane::
contains ( const seg& segIn ) const
{
	vec3 pos ( math::vec3::NoInit );
	vec3 dir ( math::vec3::NoInit );
	ValueType len;
	segIn.get ( pos, dir, len );
//	dir.normalize ();
//	vec3 endPos = pos + dir * len;
	vec3 endPos ( dir );
	endPos *= len;
	endPos += pos;

	int c1 = contains ( pos );
	int c2 = contains ( endPos );

	if ( c1 )
	{
		if ( c2 )
			return containsResult::AllIn | containsResult::SomeIn;

		return containsResult::SomeIn;
	}

	if ( c2 )
	{
		return containsResult::SomeIn;
	}

	return containsResult::NoneIn;
}
  QRectF TOPPASEdge::boundingRect() const
  {
    qreal min_x = startPos().x() < endPos().x() ? startPos().x() : endPos().x();
    qreal min_y = startPos().y() < endPos().y() ? startPos().y() : endPos().y();
    qreal max_x = startPos().x() > endPos().x() ? startPos().x() : endPos().x();
    qreal max_y = startPos().y() > endPos().y() ? startPos().y() : endPos().y();

    return QRectF(QPointF(min_x - 11.0, min_y - 11.0), QPointF(max_x + 11.0, max_y + 11.0));
  }
Beispiel #23
0
U2MsaGap U2MsaGap::intersect(const U2MsaGap &anotherGap) const {
    const qint64 newOffset = qMax(offset, anotherGap.offset);
    const qint64 newEnd = qMin(endPos(), anotherGap.endPos());
    if (newOffset > newEnd) {
        return U2MsaGap();
    }
    return U2MsaGap(newOffset, newEnd - newOffset);
}
Beispiel #24
0
bool gkRecast::findPath(PDT_NAV_MESH navMesh, const gkVector3& from, const gkVector3& to, const gkVector3& polyPickExt, int maxPathPolys, PATH_POINTS& path, unsigned short includeFlags, unsigned short excludeFlags)
{
	GK_ASSERT(!(includeFlags & excludeFlags) && "includeFlags with excludeFlags cannot overlap");

	if (navMesh.get() && navMesh->m_p)
	{
		gkVector3 startPos(from);
		gkVector3 endPos(to);

		std::swap(startPos.y, startPos.z);
		std::swap(endPos.y, endPos.z);

		dtQueryFilter filter;
		filter.includeFlags = includeFlags;
		filter.excludeFlags = excludeFlags;

		dtPolyRef startRef = navMesh->m_p->findNearestPoly(startPos.ptr(), polyPickExt.ptr(), &filter, 0);

		dtPolyRef endRef = navMesh->m_p->findNearestPoly(endPos.ptr(), polyPickExt.ptr(), &filter, 0);

		if (startRef && endRef)
		{
			utArray<dtPolyRef> polys;
			polys.resize(maxPathPolys);

			int npolys = navMesh->m_p->findPath(startRef, endRef, startPos.ptr(), endPos.ptr(), &filter, polys.ptr(), maxPathPolys);

			if (npolys > 1)
			{
				path.clear();

				utArray<gkScalar> straightPath;
				straightPath.resize(maxPathPolys * 3);

				int nstraightPath = navMesh->m_p->findStraightPath(startPos.ptr(), endPos.ptr(), polys.ptr(), npolys, straightPath.ptr(), 0, 0, maxPathPolys);

				std::swap(startPos.y, startPos.z);
				std::swap(endPos.y, endPos.z);

				gkVector3 point;

				for (int i = 0; i < nstraightPath * 3; i += 3)
				{
					point.x = straightPath[i];
					point.y = straightPath[i+2];
					point.z = straightPath[i+1];

					path.push_back(point);
				}

				return true;
			}
		}
	}

	return false;
}
  QPainterPath TOPPASEdge::shape() const
  {
    QPainterPath shape_1;
    shape_1.moveTo(startPos() + QPointF(-10, -10));
    shape_1.lineTo(endPos() + QPointF(-10, -10));
    shape_1.lineTo(endPos() + QPointF(10, 10));
    shape_1.lineTo(startPos() + QPointF(10, 10));
    shape_1.closeSubpath();

    QPainterPath shape_2;
    shape_2.moveTo(startPos() + QPointF(-10, 10));
    shape_2.lineTo(endPos() + QPointF(-10, 10));
    shape_2.lineTo(endPos() + QPointF(10, -10));
    shape_2.lineTo(startPos() + QPointF(10, -10));
    shape_2.closeSubpath();

    return shape_1.united(shape_2);
  }
Beispiel #26
0
void Connection::checkDragTarget()
{
    target = gscene()->getInputPortAt(endPos());

    if (target && target->getDatum()->acceptsLink(link))
        drag_state = VALID;
    else if (target)
        drag_state = INVALID;
    else
        drag_state = NONE;
}
Beispiel #27
0
QDomElement Transition::toXML()
{
    m_parameters.setAttribute(QStringLiteral("type"), transitionTag());
    //m_transitionParameters.setAttribute("inverted", invertTransition());
    m_parameters.setAttribute(QStringLiteral("transition_atrack"), track());
    m_parameters.setAttribute(QStringLiteral("transition_btrack"), m_transitionTrack);
    m_parameters.setAttribute(QStringLiteral("start"), startPos().frames(m_fps));
    m_parameters.setAttribute(QStringLiteral("end"), endPos().frames(m_fps));
    m_parameters.setAttribute(QStringLiteral("force_track"), m_forceTransitionTrack);
    m_parameters.setAttribute(QStringLiteral("automatic"), m_automaticTransition);
    return m_parameters.cloneNode().toElement();
}
void RefactorerWindow::setSelectionInfo()
{
    QString sel = "Inter: ";
    sel += QString::number( startPos());
    sel += " - ";
    sel += QString::number( endPos() );
    sel += " Impl: ";
    sel += QString::number( ui->implementationText->textCursor().selectionStart());
    sel += " - ";
    sel += QString::number( ui->implementationText->textCursor().selectionEnd() );
     statusBar()->showMessage(sel);
}
Beispiel #29
0
void MythUIScrollBar::CalculatePosition(void)
{
    if (m_maximum > 0)
        Show();
    else
    {
        Hide();
        return;
    }

    MythUIType *slider = GetChild("slider");

    if (!slider)
    {
        LOG(VB_GENERAL, LOG_ERR, "Slider element doesn't exist");
        return;
    }

    float percentage = (float)m_sliderPosition / m_maximum;
    float relativeSize = (float)m_pageStep / (m_maximum + m_pageStep);

    MythRect newSliderArea = slider->GetArea();
    MythRect fillArea = GetArea();
    QPoint endPos(newSliderArea.left(), newSliderArea.top());

    if (m_layout == LayoutHorizontal)
    {
        int width = qMax((int)(fillArea.width() * relativeSize + 0.5),
                         m_sliderArea.width());
        newSliderArea.setWidth(width);
        endPos.setX((int)((fillArea.width() - width) * percentage + 0.5));
    }
    else
    {
        int height = qMax((int)(fillArea.height() * relativeSize + 0.5),
                          m_sliderArea.height());
        newSliderArea.setHeight(height);
        endPos.setY((int)((fillArea.height() - height) * percentage + 0.5));
    }

    slider->SetArea(newSliderArea);
    slider->SetPosition(endPos);

    if (m_hideDelay > 0)
    {
        if (m_timerId)
            killTimer(m_timerId);
        m_timerId = startTimer(m_hideDelay);

        AdjustAlpha(1, 10, 0, 255);
    }
}
    // /////////////////////////////////////////////////////////////////
    //
    // /////////////////////////////////////////////////////////////////
    void SliderControl::RebuildSliderLine()
    {
        const F32 halfHeight = VGetHeight() / 2.0f;
        Point3 beginPos(VGetPosition()), endPos(VGetPosition());
        beginPos.SetY(beginPos.GetY() - halfHeight);
        endPos.SetX(endPos.GetX() + VGetWidth());
        endPos.SetY(endPos.GetY() - halfHeight);

        m_sliderLineBatch.reset(GCC_NEW GLBatch());
        m_sliderLineBatch->Begin(GL_LINES, 2);
        m_sliderLineBatch->Vertex3f(beginPos.GetX(), beginPos.GetY(), beginPos.GetZ());
        m_sliderLineBatch->Vertex3f(endPos.GetX(), endPos.GetY(), endPos.GetZ());
        m_sliderLineBatch->End();
    }