예제 #1
0
double Cell::getDistance()const
{
    double minDistance=1000000.0;
    QList<Cell*>::const_iterator i;
    for (i = finalNodes.constBegin(); i != finalNodes.constEnd(); ++i)
    {
        minDistance=std::min(getDistanceFrom(**i), minDistance);
    }
    return minDistance;
}
예제 #2
0
void TooltipWindow::timerCallback()
{
    auto& desktop = Desktop::getInstance();
    auto mouseSource = desktop.getMainMouseSource();
    auto now = Time::getApproximateMillisecondCounter();

    auto* newComp = mouseSource.isTouch() ? nullptr : mouseSource.getComponentUnderMouse();
    auto newTip = newComp != nullptr ? getTipFor (*newComp) : String();
    bool tipChanged = (newTip != lastTipUnderMouse || newComp != lastComponentUnderMouse);
    lastComponentUnderMouse = newComp;
    lastTipUnderMouse = newTip;

    auto clickCount = desktop.getMouseButtonClickCounter();
    auto wheelCount = desktop.getMouseWheelMoveCounter();
    bool mouseWasClicked = (clickCount > mouseClicks || wheelCount > mouseWheelMoves);
    mouseClicks = clickCount;
    mouseWheelMoves = wheelCount;

    auto mousePos = mouseSource.getScreenPosition();
    bool mouseMovedQuickly = mousePos.getDistanceFrom (lastMousePos) > 12;
    lastMousePos = mousePos;

    if (tipChanged || mouseWasClicked || mouseMovedQuickly)
        lastCompChangeTime = now;

    if (isVisible() || now < lastHideTime + 500)
    {
        // if a tip is currently visible (or has just disappeared), update to a new one
        // immediately if needed..
        if (newComp == nullptr || mouseWasClicked || newTip.isEmpty())
        {
            if (isVisible())
            {
                lastHideTime = now;
                hideTip();
            }
        }
        else if (tipChanged)
        {
            displayTip (mousePos.roundToInt(), newTip);
        }
    }
    else
    {
        // if there isn't currently a tip, but one is needed, only let it
        // appear after a timeout..
        if (newTip.isNotEmpty()
             && newTip != tipShowing
             && now > lastCompChangeTime + (uint32) millisecondsBeforeTipAppears)
        {
            displayTip (mousePos.roundToInt(), newTip);
        }
    }
}
예제 #3
0
void Timeline::render(Track* track)
{
	CCSize * timeLineSize=new CCSize(CCDirector::sharedDirector()->getVisibleSize().width,CCDirector::sharedDirector()->getVisibleSize().height/20);
	CCPoint *timelineTrackRatio=new CCPoint(getTimelineTrackRatio(track,timeLineSize));
	float * addtionalDistance=new float(getDistanceFrom(track));
	drawTimeLine(track,timeLineSize);
	drawTBars(track,timelineTrackRatio,timeLineSize,addtionalDistance);
	drawTItems(track,timelineTrackRatio,timeLineSize,addtionalDistance);
	drawTPlayer(track,timelineTrackRatio,timeLineSize,addtionalDistance);
	ccDrawColor4F(0xFF,0xFF,0xFF,0xFF);
	glLineWidth(1.0f);
}
예제 #4
0
double Cell::getPortalDistance()const
{
    double minDistance=1000000.0;
    QList<Cell*>::const_iterator i;
    for (i = portalNodes.constBegin(); i != portalNodes.constEnd(); ++i)
    {
        if((**i).getState()!=visited)
            minDistance=std::min(getDistanceFrom(**i)+(**i).portalEstimate, minDistance);
    }


    return minDistance;
}
void MouseInactivityDetector::wakeUp (const MouseEvent& e, bool alwaysWake)
{
    auto newPos = e.getEventRelativeTo (&targetComp).getPosition();

    if ((! isActive) && (alwaysWake || e.source.isTouch() || newPos.getDistanceFrom (lastMousePos) > toleranceDistance))
        setActive (true);

    if (lastMousePos != newPos)
    {
        lastMousePos = newPos;
        startTimer (delayMs);
    }
}
예제 #6
0
 float distanceFrom( const TilePos& other ) { return getDistanceFrom( other );}
예제 #7
0
 virtual float3 getPowerDensityAt (float3 x) {
     float surfaceArea = 4*M_PI*pow(getDistanceFrom(x),2.0);
     return float3(power.x/surfaceArea, power.y/surfaceArea, power.z/surfaceArea);
 }