Beispiel #1
0
void GuiContainer::update(float dt)
{
	if(updateHandler)
	{
		updateHandler(dt);
	}
	for(auto const & info : infos)
	{
		if(info.active)
		{
			info.element->update(dt);
		}
	}
}
Beispiel #2
0
void Mirobot::loop(){
  marcel.loop();
  ledHandler();
  servoHandler();
  autoHandler();
  calibrateHandler();
  sensorNotifier();
#ifdef ESP8266
  if(wifiEnabled){
    sendDiscovery();
    updateHandler();
  }
#endif
  checkReady();
}
Beispiel #3
0
/*!
  Notifies accessibility clients about a change in \a object's
  accessibility information.

  \a reason specifies the cause of the change, for example,
  \c ValueChange when the position of a slider has been changed. \a
  child is the (1-based) index of the child element that has changed.
  When \a child is 0, the object itself has changed.

  Call this function whenever the state of your accessible object or
  one of its sub-elements has been changed either programmatically
  (e.g. by calling QLabel::setText()) or by user interaction.

  If there are no accessibility tools listening to this event, the
  performance penalty for calling this function is small, but if determining
  the parameters of the call is expensive you can test isActive() to
  avoid unnecessary computations.
*/
void QAccessible::updateAccessibility(QObject *object, int child, Event reason)
{
    Q_ASSERT(object);

    if (updateHandler) {
        updateHandler(object, child, reason);
        return;
    }

    if (!isActive())
        return;

    if (QPlatformAccessibility *pfAccessibility = platformAccessibility())
        pfAccessibility->notifyAccessibilityUpdate(object, child, reason);
}
Beispiel #4
0
void CCProcessBase::update(float dt)
{

    if (m_bIsComplete || m_bIsPause)
    {
        return;
    }

    /*
     *  Fileter the m_iDuration <=0 and dt >1
     *  If dt>1, generally speaking  the reason is the device is stuck.
     */
    if(m_iRawDuration <= 0 || dt > 1)
    {
        return;
    }

    if (m_iNextFrameIndex <= 0)
    {
        m_fCurrentPercent = 1;
        m_fCurrentFrame = 0;
    }
    else
    {
        /*
        *  update m_fCurrentFrame, every update add the frame passed.
        *  dt/m_fAnimationInternal determine it is not a frame animation. If frame speed changed, it will not make our
        *  animation speed slower or quicker.
        */
        m_fCurrentFrame += m_fProcessScale * (dt / m_fAnimationInternal);


        m_fCurrentPercent = m_fCurrentFrame / m_iNextFrameIndex;

        /*
        *	if m_fCurrentFrame is bigger or equal than m_iTotalFrames, then reduce it util m_fCurrentFrame is
        *  smaller than m_iTotalFrames
        */
        m_fCurrentFrame = fmodf(m_fCurrentFrame, m_iNextFrameIndex);
    }

    updateHandler();
}
Beispiel #5
0
void ProcessBase::update(float dt)
{

    if (_isComplete || _isPause)
    {
        return;
    }

    /*
     *  Filter the m_iDuration <=0 and dt >1
     *  If dt>1, generally speaking  the reason is the device is stuck.
     */
    if(_rawDuration <= 0 || dt > 1)
    {
        return;
    }

    if (_nextFrameIndex <= 0)
    {
        _currentPercent = 1;
        _currentFrame = 0;
    }
    else
    {
        /*
        *  update _currentFrame, every update add the frame passed.
        *  dt/_animationInternal determine it is not a frame animation. If frame speed changed, it will not make our
        *  animation speed slower or quicker.
        */
        _currentFrame += _processScale * (dt / _animationInternal);


        _currentPercent = _currentFrame / _nextFrameIndex;

        /*
        *	if _currentFrame is bigger or equal than m_iTotalFrames, then reduce it until _currentFrame is
        *  smaller than m_iTotalFrames
        */
        _currentFrame = fmodf(_currentFrame, _nextFrameIndex);
    }

    updateHandler();
}
Beispiel #6
0
void QAccessible::updateAccessibility(QObject *o, int who, Event reason)
{
    Q_ASSERT(o);

    if (updateHandler) {
        updateHandler(o, who, reason);
        return;
    }

    initialize();
    if (bridges()->isEmpty())
        return;

    QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(o);
    if (!iface)
        return;

    for (int i = 0; i < bridges()->count(); ++i)
        bridges()->at(i)->notifyAccessibilityUpdate(reason, iface, who);
    delete iface;
}
Beispiel #7
0
void QAccessible::updateAccessibility(QObject *o, int who, Event reason)
{
    Q_ASSERT(o);

    if (updateHandler) {
        updateHandler(o, who, reason);
        return;
    }

    QByteArray soundName;
    switch (reason) {
    case PopupMenuStart:
        soundName = "MenuPopup";
        break;

    case MenuCommand:
        soundName = "MenuCommand";
        break;

    case Alert:
        {
#ifndef QT_NO_MESSAGEBOX
            QMessageBox *mb = ::qobject_cast<QMessageBox*>(o);
            if (mb) {
                switch (mb->icon()) {
                case QMessageBox::Warning:
                    soundName = "SystemExclamation";
                    break;
                case QMessageBox::Critical:
                    soundName = "SystemHand";
                    break;
                case QMessageBox::Information:
                    soundName = "SystemAsterisk";
                    break;
                default:
                    break;
                }
            } else
#endif // QT_NO_MESSAGEBOX
            {
                soundName = "SystemAsterisk";
            }

        }
        break;
    default:
        break;
    }

    if (soundName.size()) {
        QSettings settings(QLatin1String("HKEY_CURRENT_USER\\AppEvents\\Schemes\\Apps\\.Default\\") +
                                         QString::fromLatin1(soundName.constData()), QSettings::NativeFormat);
        QString file = settings.value(QLatin1String(".Current/.")).toString();
        if (!file.isEmpty())
            PlaySoundA(soundName.constData(), 0, SND_ALIAS | SND_ASYNC | SND_NODEFAULT | SND_NOWAIT );
    }

    if (!isActive())
        return;

    typedef void (WINAPI *PtrNotifyWinEvent)(DWORD, HWND, LONG, LONG);

    static PtrNotifyWinEvent ptrNotifyWinEvent = 0;
    static bool resolvedNWE = false;
    if (!resolvedNWE) {
        resolvedNWE = true;
        ptrNotifyWinEvent = (PtrNotifyWinEvent)QLibrary::resolve(QLatin1String("user32"), "NotifyWinEvent");
    }
    if (!ptrNotifyWinEvent)
        return;

    // An event has to be associated with a window,
    // so find the first parent that is a widget.
    QWidget *w = 0;
    if (o->isWidgetType()) {
        w = (QWidget*)o;
    } else {
        QObject *p = o;
        while ((p = p->parent()) != 0) {
            if (p->isWidgetType()) {
                w = (QWidget*)p;
                break;
            }
        }
    }

    if (!w) {
        if (reason != QAccessible::ContextHelpStart &&
             reason != QAccessible::ContextHelpEnd)
            w = qApp->focusWidget();
        if (!w) {
            w = qApp->activeWindow();

            if (!w)
                return;

// ### Fixme
//             if (!w) {
//                 w = qApp->mainWidget();
//                 if (!w)
//                     return;
//             }
        }
    }

    if (reason != MenuCommand) { // MenuCommand is faked
        ptrNotifyWinEvent(reason, w->winId(), OBJID_CLIENT, who);
    }
}
void QAccessible::updateAccessibility(QObject *o, int who, Event reason)
{
    Q_ASSERT(o);

    if (updateHandler) {
        updateHandler(o, who, reason);
        return;
    }

    QString soundName;
    switch (reason) {
    case PopupMenuStart:
        soundName = QLatin1String("MenuPopup");
        break;

    case MenuCommand:
        soundName = QLatin1String("MenuCommand");
        break;

    case Alert:
        {
#ifndef QT_NO_MESSAGEBOX
            QMessageBox *mb = qobject_cast<QMessageBox*>(o);
            if (mb) {
                switch (mb->icon()) {
                case QMessageBox::Warning:
                    soundName = QLatin1String("SystemExclamation");
                    break;
                case QMessageBox::Critical:
                    soundName = QLatin1String("SystemHand");
                    break;
                case QMessageBox::Information:
                    soundName = QLatin1String("SystemAsterisk");
                    break;
                default:
                    break;
                }
            } else
#endif // QT_NO_MESSAGEBOX
            {
                soundName = QLatin1String("SystemAsterisk");
            }

        }
        break;
    default:
        break;
    }

    if (soundName.size()) {
#ifndef QT_NO_SETTINGS
        QSettings settings(QLatin1String("HKEY_CURRENT_USER\\AppEvents\\Schemes\\Apps\\.Default\\") + soundName,
                           QSettings::NativeFormat);
        QString file = settings.value(QLatin1String(".Current/.")).toString();
#else
        QString file;
#endif
        if (!file.isEmpty()) {
				    PlaySound(reinterpret_cast<const wchar_t *>(soundName.utf16()), 0, SND_ALIAS | SND_ASYNC | SND_NODEFAULT | SND_NOWAIT);
        }
    }

    if (!isActive())
        return;

    typedef void (WINAPI *PtrNotifyWinEvent)(DWORD, HWND, LONG, LONG);

#if defined(Q_WS_WINCE) // ### TODO: check for NotifyWinEvent in CE 6.0
    // There is no user32.lib nor NotifyWinEvent for CE
    return;
#else
    static PtrNotifyWinEvent ptrNotifyWinEvent = 0;
    static bool resolvedNWE = false;
    if (!resolvedNWE) {
        ptrNotifyWinEvent = (PtrNotifyWinEvent)QSystemLibrary::resolve(QLatin1String("user32"), "NotifyWinEvent");
        resolvedNWE = true;
    }
    if (!ptrNotifyWinEvent)
        return;

    // An event has to be associated with a window,
    // so find the first parent that is a widget.
    QWidget *w = 0;
    QObject *p = o;
    do {
        if (p->isWidgetType()) {
            w = static_cast<QWidget*>(p);
            if (w->internalWinId())
                break;
        }
        if (QGraphicsObject *gfxObj = qobject_cast<QGraphicsObject*>(p)) {
            QGraphicsItem *parentItem = gfxObj->parentItem();
            if (parentItem) {
                p = parentItem->toGraphicsObject();
            } else {
                QGraphicsView *view = 0;
                if (QGraphicsScene *scene = gfxObj->scene()) {
                    QWidget *fw = QApplication::focusWidget();
                    const QList<QGraphicsView*> views = scene->views();
                    for (int i = 0 ; i < views.count() && view != fw; ++i) {
                        view = views.at(i);
                    }
                }
                p = view;
            }
        } else {
            p = p->parent();
        }

    } while (p);

    //qDebug() << "updateAccessibility(), hwnd:" << w << ", object:" << o << "," << eventString(reason);
    if (!w) {
        if (reason != QAccessible::ContextHelpStart &&
             reason != QAccessible::ContextHelpEnd)
            w = QApplication::focusWidget();
        if (!w) {
            w = QApplication::activeWindow();

            if (!w)
                return;

// ### Fixme
//             if (!w) {
//                 w = qApp->mainWidget();
//                 if (!w)
//                     return;
//             }
        }
    }

    WId wid = w->internalWinId();
    if (reason != MenuCommand) { // MenuCommand is faked
        if (w != o) {
            // See comment "SENDING EVENTS TO OBJECTS WITH NO WINDOW HANDLE"
            if (reason != QAccessible::ObjectDestroyed) {
                /* In some rare occasions, the server (Qt) might get a ::get_accChild call with a
                   childId that references an entry in the cache where there was a dangling
                   QObject-pointer. Previously we crashed on this.

                   There is no point in actually notifying the AT client that the object got destroyed,
                   because the AT client won't query for get_accChild if the event is ObjectDestroyed
                   anyway, and we have no other way of mapping the eventId argument to the actual
                   child/descendant object. (Firefox seems to simply completely ignore
                   EVENT_OBJECT_DESTROY).

                   We therefore guard each QObject in the cache with a QPointer, and only notify the AT
                   client if the type is not ObjectDestroyed.
                */
                eventNum %= 50;              //[0..49]
                int eventId = - eventNum - 1;
                qAccessibleRecentSentEvents()->insert(eventId, qMakePair(QPointer<QObject>(o), who));
                ptrNotifyWinEvent(reason, wid, OBJID_CLIENT, eventId );
                ++eventNum;
            }
        } else {
            ptrNotifyWinEvent(reason, wid, OBJID_CLIENT, who);
        }
    }
#endif // Q_WS_WINCE
}
Beispiel #9
0
void CtrlRegisterList::paintEvent(wxPaintEvent & evt)
{
    updateHandler();
    evt.Skip();
}
Beispiel #10
0
void initializeDriverRouter(::izenelib::driver::Router& router, IService* service, bool enableTest)
{
    {
        CommandsController commands;
        const std::string controllerName("commands");
        typedef ::izenelib::driver::ActionHandler<CommandsController> handler_type;
        typedef std::auto_ptr<handler_type> handler_ptr;

        handler_ptr indexHandler(
            new handler_type(
                commands,
                &CommandsController::index
            )
        );

        router.map(
            controllerName,
            "index",
            indexHandler.get()
        );
        indexHandler.release();

        handler_ptr miningHandler(
            new handler_type(
                commands,
                &CommandsController::mining
            )
        );

        router.map(
            controllerName,
            "mining",
            miningHandler.get()
        );
        miningHandler.release();

        handler_ptr optimize_indexHandler(
            new handler_type(
                commands,
                &CommandsController::optimize_index
            )
        );

        router.map(
            controllerName,
            "optimize_index",
            optimize_indexHandler.get()
        );
        optimize_indexHandler.release();

        handler_ptr train_ctr_modelHandler(
            new handler_type(
                commands,
                &CommandsController::train_ctr_model
            )
        );

        router.map(
            controllerName,
            "train_ctr_model",
            train_ctr_modelHandler.get()
        );
        train_ctr_modelHandler.release();
    }

    {
        DocumentsController documents;
        const std::string controllerName("documents");
        typedef ::izenelib::driver::ActionHandler<DocumentsController> handler_type;
        typedef std::auto_ptr<handler_type> handler_ptr;

        handler_ptr createHandler(
            new handler_type(
                documents,
                &DocumentsController::create
            )
        );

        router.map(
            controllerName,
            "create",
            createHandler.get()
        );
        createHandler.release();

        handler_ptr destroyHandler(
            new handler_type(
                documents,
                &DocumentsController::destroy
            )
        );

        router.map(
            controllerName,
            "destroy",
            destroyHandler.get()
        );
        destroyHandler.release();

        handler_ptr getHandler(
            new handler_type(
                documents,
                &DocumentsController::get
            )
        );

        router.map(
            controllerName,
            "get",
            getHandler.get()
        );
        getHandler.release();

        handler_ptr get_doc_countHandler(
            new handler_type(
                documents,
                &DocumentsController::get_doc_count
            )
        );

        router.map(
            controllerName,
            "get_doc_count",
            get_doc_countHandler.get()
        );
        get_doc_countHandler.release();

        handler_ptr get_freq_group_labelsHandler(
            new handler_type(
                documents,
                &DocumentsController::get_freq_group_labels
            )
        );

        router.map(
            controllerName,
            "get_freq_group_labels",
            get_freq_group_labelsHandler.get()
        );
        get_freq_group_labelsHandler.release();

        handler_ptr get_key_countHandler(
            new handler_type(
                documents,
                &DocumentsController::get_key_count
            )
        );

        router.map(
            controllerName,
            "get_key_count",
            get_key_countHandler.get()
        );
        get_key_countHandler.release();

        handler_ptr indexHandler(
            new handler_type(
                documents,
                &DocumentsController::index
            )
        );

        router.map(
            controllerName,
            "index",
            indexHandler.get()
        );
        indexHandler.release();

        handler_ptr log_group_labelHandler(
            new handler_type(
                documents,
                &DocumentsController::log_group_label
            )
        );

        router.map(
            controllerName,
            "log_group_label",
            log_group_labelHandler.get()
        );
        log_group_labelHandler.release();

        handler_ptr searchHandler(
            new handler_type(
                documents,
                &DocumentsController::search
            )
        );

        router.map(
            controllerName,
            "search",
            searchHandler.get()
        );
        searchHandler.release();

        handler_ptr set_top_group_labelHandler(
            new handler_type(
                documents,
                &DocumentsController::set_top_group_label
            )
        );

        router.map(
            controllerName,
            "set_top_group_label",
            set_top_group_labelHandler.get()
        );
        set_top_group_labelHandler.release();

        handler_ptr updateHandler(
            new handler_type(
                documents,
                &DocumentsController::update
            )
        );

        router.map(
            controllerName,
            "update",
            updateHandler.get()
        );
        updateHandler.release();

        handler_ptr update_inplaceHandler(
            new handler_type(
                documents,
                &DocumentsController::update_inplace
            )
        );

        router.map(
            controllerName,
            "update_inplace",
            update_inplaceHandler.get()
        );
        update_inplaceHandler.release();

        handler_ptr visitHandler(
            new handler_type(
                documents,
                &DocumentsController::visit
            )
        );

        router.map(
            controllerName,
            "visit",
            visitHandler.get()
        );
        visitHandler.release();
    }

    {
        StatusController status;
        const std::string controllerName("status");
        typedef ::izenelib::driver::ActionHandler<StatusController> handler_type;
        typedef std::auto_ptr<handler_type> handler_ptr;

        handler_ptr get_distribute_statusHandler(
            new handler_type(
                status,
                &StatusController::get_distribute_status
            )
        );

        router.map(
            controllerName,
            "get_distribute_status",
            get_distribute_statusHandler.get()
        );
        get_distribute_statusHandler.release();

        handler_ptr indexHandler(
            new handler_type(
                status,
                &StatusController::index
            )
        );

        router.map(
            controllerName,
            "index",
            indexHandler.get()
        );
        indexHandler.release();
    }

    {
        CollectionController collection;
        const std::string controllerName("collection");
        typedef ::izenelib::driver::ActionHandler<CollectionController> handler_type;
        typedef std::auto_ptr<handler_type> handler_ptr;

        handler_ptr add_sharding_nodesHandler(
            new handler_type(
                collection,
                &CollectionController::add_sharding_nodes
            )
        );

        router.map(
            controllerName,
            "add_sharding_nodes",
            add_sharding_nodesHandler.get()
        );
        add_sharding_nodesHandler.release();

        handler_ptr backup_allHandler(
            new handler_type(
                collection,
                &CollectionController::backup_all
            )
        );

        router.map(
            controllerName,
            "backup_all",
            backup_allHandler.get()
        );
        backup_allHandler.release();

        handler_ptr check_collectionHandler(
            new handler_type(
                collection,
                &CollectionController::check_collection
            )
        );

        router.map(
            controllerName,
            "check_collection",
            check_collectionHandler.get()
        );
        check_collectionHandler.release();

        handler_ptr create_collectionHandler(
            new handler_type(
                collection,
                &CollectionController::create_collection
            )
        );

        router.map(
            controllerName,
            "create_collection",
            create_collectionHandler.get()
        );
        create_collectionHandler.release();

        handler_ptr delete_collectionHandler(
            new handler_type(
                collection,
                &CollectionController::delete_collection
            )
        );

        router.map(
            controllerName,
            "delete_collection",
            delete_collectionHandler.get()
        );
        delete_collectionHandler.release();

        handler_ptr rebuild_collectionHandler(
            new handler_type(
                collection,
                &CollectionController::rebuild_collection
            )
        );

        router.map(
            controllerName,
            "rebuild_collection",
            rebuild_collectionHandler.get()
        );
        rebuild_collectionHandler.release();

        handler_ptr rebuild_from_scdHandler(
            new handler_type(
                collection,
                &CollectionController::rebuild_from_scd
            )
        );

        router.map(
            controllerName,
            "rebuild_from_scd",
            rebuild_from_scdHandler.get()
        );
        rebuild_from_scdHandler.release();

        handler_ptr start_collectionHandler(
            new handler_type(
                collection,
                &CollectionController::start_collection
            )
        );

        router.map(
            controllerName,
            "start_collection",
            start_collectionHandler.get()
        );
        start_collectionHandler.release();

        handler_ptr stop_collectionHandler(
            new handler_type(
                collection,
                &CollectionController::stop_collection
            )
        );

        router.map(
            controllerName,
            "stop_collection",
            stop_collectionHandler.get()
        );
        stop_collectionHandler.release();

        handler_ptr update_collection_confHandler(
            new handler_type(
                collection,
                &CollectionController::update_collection_conf
            )
        );

        router.map(
            controllerName,
            "update_collection_conf",
            update_collection_confHandler.get()
        );
        update_collection_confHandler.release();

        handler_ptr update_sharding_confHandler(
            new handler_type(
                collection,
                &CollectionController::update_sharding_conf
            )
        );

        router.map(
            controllerName,
            "update_sharding_conf",
            update_sharding_confHandler.get()
        );
        update_sharding_confHandler.release();
    }

}