예제 #1
0
void StatesEditorView::removeState(int nodeId)
{
    try {
        if (nodeId > 0 && hasModelNodeForInternalId(nodeId)) {
            ModelNode stateNode(modelNodeForInternalId(nodeId));
            Q_ASSERT(stateNode.metaInfo().isSubclassOf("QtQuick.State", -1, -1));
            NodeListProperty parentProperty = stateNode.parentProperty().toNodeListProperty();

            if (parentProperty.count() <= 1) {
                setCurrentState(baseState());
            } else if (parentProperty.isValid()){
                int index = parentProperty.indexOf(stateNode);
                if (index == 0)
                    setCurrentState(parentProperty.at(1));
                else
                    setCurrentState(parentProperty.at(index - 1));
            }


            stateNode.destroy();
        }
    }  catch (RewritingException &e) {
        QMessageBox::warning(0, "Error", e.description());
    }
}
void RoboState::messageCallback(const nav_simple::mymsg::ConstPtr& msg)
{
  // only accept message if movement is not in progress
  if(getCurrentState()==NEUTRAL)
    {
      if(msg->x==0 && msg->y==0)
	ROS_INFO("No reason to move a distance of 0. Message not sent.");
      else{	  
	ROS_INFO("X and Y coordinates sent were: x:%f y:%f", msg->x, msg->y);
	setX(msg->x);
	setY(msg->y);
	ROS_INFO("xCoord is: %f. yCoord is: %f", getX(), getY());
	
	// we don't need to face backward since initial movement is forward
	if(getX() >= 0){
	  setCurrentState(TURN_LEFT_90);
	}
	// need to face backward since initial movement is backward
	// (want bumper sensors to be useful)
       	else{
	  //setCurrentState(TURN_NEG_X);
	  setCurrentState(TURN_LEFT_90);
	}
	//setErr(sqrt(pow(getX(),2)+pow(getY(),2))*.1);
	setErr(.1);
      }
      // need to determine what direction we will ultimately face
      setYawGoal(90);
      //      determineYawGoal();

    }
  else
    ROS_INFO("Cannot accept message. Movement still in progress.");
}
예제 #3
0
void ConfigChannel::close() {
	setCurrentState(DISCONNECTING);
	if (configSocket != -1) {
		shutdown(configSocket, SHUT_RDWR);
		::close(configSocket);
		configSocket = -1;
	}
	setCurrentState(DISCONNECTED);
	Channel::close();
}
예제 #4
0
void StatesEditorView::synchonizeCurrentStateFromWidget()
{
    if (!model())
        return;
    int internalId = m_statesEditorWidget->currentStateInternalId();

    if (internalId > 0 && hasModelNodeForInternalId(internalId)) {
        ModelNode node = modelNodeForInternalId(internalId);
        QmlModelState modelState(node);
        if (modelState.isValid() && modelState != currentState())
            setCurrentState(modelState);
    } else {
        setCurrentState(baseState());
    }
}
예제 #5
0
void ActionRootState::updateActionState()
{
    if (valid()) {
        ActionStateParser* oldParser = m_actionGroup->actionStateParser();
        m_actionGroup->setActionStateParser(&m_parser);

        QVariantMap state = m_actionGroup->actionState(m_actionName).toMap();

        m_actionGroup->setActionStateParser(oldParser);

        setCurrentState(state);
    } else {
        setCurrentState(QVariantMap());
    }
}
예제 #6
0
void Animal::DoAction(State action)
{
	switch (action)
	{
	case Moving:
		setCurrentState(Moving); break;
	case Attacking:
		setCurrentState(Attacking); break;
	case Eating:
		setCurrentState(Eating); break;
	case SearchFood:
		setCurrentState(SearchFood); break;
	case Sleeping:
		setCurrentState(Sleeping); break;
	}
}
예제 #7
0
SimondConnector::SimondConnector(QObject *parent) :
    QObject(parent), state(Unconnected),
    socket(new QSslSocket(this)),
    timeoutTimer(new QTimer(this)),
    response(new QDataStream(socket)),
    mic(new SoundInput(SOUND_CHANNELS, SOUND_SAMPLERATE, this)),
    passThroughSound(false)
{
    connect(this, SIGNAL(connectionState(ConnectionState)), this, SLOT(setCurrentState(ConnectionState)));
    connect(socket, SIGNAL(readyRead()), this, SLOT(messageReceived()));
    connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError()));
    connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(socketError()));
    connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished()));
    connect(socket, SIGNAL(encrypted()), this, SLOT(connectionEstablished()));
    connect(socket, SIGNAL(disconnected()), this, SLOT(connectionLost()));

    connect(mic, SIGNAL(error(QString)), this, SIGNAL(error(QString)));
    connect(mic, SIGNAL(microphoneLevel(int,int,int)), this, SIGNAL(microphoneLevel(int,int,int)));
    connect(mic, SIGNAL(listening()), this, SLOT(startRecording()));
    connect(mic, SIGNAL(complete()), this, SLOT(commitRecording()));
    connect(mic, SIGNAL(readyRead()), this, SLOT(soundDataAvailable()));

    connect(timeoutTimer, SIGNAL(timeout()), this, SLOT(timeoutReached()));
    timeoutTimer->setSingleShot(true);
    timeoutTimer->setInterval(SOCKET_TIMEOUT);
}
예제 #8
0
파일: zkb.cpp 프로젝트: opieproject/opie
bool Keymap::removeState(const QString& name, bool force) {
    QMap<QString, State*>::Iterator it = states.find(name);

    if (it == states.end()) {
        return false;
    }

    State* state = it.data();
    QList<Action> acts = findStateUsage(state);

    if (!acts.isEmpty()) {
        if (!force) {
            return false;
        } else {
            for(Action* a = acts.first(); a != 0; a = acts.next()) {
                a->setState(0);
            }
        }
    }

    if (state == currentState) {
        if (states.begin() != states.end()) {
            setCurrentState(states.begin().data());
        }
    }

    states.remove(it);
    delete state;

    lsmapInSync = false;

    return true;
}
예제 #9
0
void CAbstractUpdateController::launchUpdate()
{
    QString proc;
    QStringList args;
    QString DLType;
    updateShellCommand(proc, args);


    //if jail is present
    if (mJailPrefix.length())
    {
        args.push_front(proc);
        args.push_front(mJailPrefix);
        proc = "chroot";
    }

    mUpdProc.start(proc,args);
    if (!mUpdProc.waitForStarted())
    {
        reportError(tr("Can not execute update shell command"));
        return;
    }

    DLType = dlType();
    if (DLType.length())
        mUpdProc.setDLType(DLType);

    if (currentState() != eUPDATING)
        setCurrentState(eUPDATING);
}
예제 #10
0
void Widget::OnBtnPressed() {
	setCurrentState(PRESSED);
	EvtFunc *func = funcs[EVT_BTNRELEASED].func;
	void *data = funcs[EVT_BTNRELEASED].data;
	if (func)
		func(this, data);
}
예제 #11
0
void Widget::OnClick() {
	setCurrentState(NORMAL);
	EvtFunc *func = funcs[EVT_CLICK].func;
	void *data = funcs[EVT_CLICK].data;
	if (func)
		func(this, data);
}
예제 #12
0
void Widget::OnEnter() {
	setCurrentState(PRELIGHT);
	EvtFunc *func = funcs[EVT_ENTER].func;
	void *data = funcs[EVT_ENTER].data;
	if (func)
		func(this, data);
}
예제 #13
0
void BaseAnimatedStackedWidget::setCurrentWidget(QWidget* widget)
{
	if (!widget)
		return;

#ifdef ENABLE_YATOOLBOX_ANIMATION
	if (isVisible()) {
		QPixmap pix(normalPage()->size());
		normalPage()->render(&pix);
		animationPage_->setStaticPixmap(pix);
		stackedWidget_->setCurrentWidget(animationPage_);
		setCurrentState(widget);
	}
#endif

#ifndef ENABLE_YATOOLBOX_ANIMATION
	setUpdatesEnabled(false);
#endif
	setCurrentWidget_internal(widget);
#ifndef ENABLE_YATOOLBOX_ANIMATION
	if (isVisible()) {
		activateNormalPageLayout();
		setUpdatesEnabled(true);
	}
#endif

#ifdef ENABLE_YATOOLBOX_ANIMATION
	if (isVisible()) {
		setNewState();
		animationPage_->start();
	}
#endif
}
예제 #14
0
파일: Arrow.cpp 프로젝트: vinhsteven/Hero
void Arrow::updateEnter(float fDeltaTime)
{
    m_bActive = true;
    
    // Updates move
    setCurrentState(Move);
}
예제 #15
0
파일: Arrow.cpp 프로젝트: vinhsteven/Hero
void Arrow::updateMove2(float fDeltaTime)
{
    m_fSpeed -= ACCELERATION_2 * (fDeltaTime / FRAME_DURATION);
    
    if (m_fSpeed < MIN_SPEED)
    {
        // Sets acceleration
        m_fAcceleration = ACCELERATION_3;
        
        // Updates move
        setCurrentState(Move);
    }
    else
    {
        CCPoint deltaPos = m_dir * m_fSpeed * fDeltaTime;
        
        float fLength = deltaPos.getLength();
        
        if (fLength < m_fRemainLength)
        {
            m_fRemainLength -= fLength;
            
            setPosition(m_obPosition + deltaPos);
        }
        else
        {
            m_fRemainLength = 0.0f;
            
            setPosition(m_endPos);
            
            // Disappear
            disappear();
        }
    }
}
예제 #16
0
파일: session.cpp 프로젝트: ashang/fqterm
FQTermUniteSessionContext::FQTermUniteSessionContext(FQTermUniteSession* session) : QObject(session), session_(session) {
  stateTable_[WELCOME] = new FQTermWelcomeState(this);
  stateTable_[EXITING] = new FQTermExitState(this);
  stateTable_[READING] = new FQTermReadingState(this);
  stateTable_[HELP] = new FQTermHelpState(this);
  setCurrentState(WELCOME);
}
예제 #17
0
void StatesEditorView::addState()
{
    // can happen when root node is e.g. a ListModel
    if (!QmlItemNode::isValidQmlItemNode(rootModelNode()))
        return;

    QStringList modelStateNames = rootStateGroup().names();

    QString newStateName;
    int index = 1;
    while (true) {
        newStateName = QString("State%1").arg(index++);
        if (!modelStateNames.contains(newStateName))
            break;
    }

    try {
        if ((rootStateGroup().allStates().count() < 1) && //QtQuick import might be missing
            (!model()->hasImport(Import::createLibraryImport("QtQuick", "1.0"), true, true)))
            model()->changeImports(QList<Import>() << Import::createLibraryImport("QtQuick", "1.0"), QList<Import>());
        ModelNode newState = rootStateGroup().addState(newStateName);
        setCurrentState(newState);
    }  catch (RewritingException &e) {
        QMessageBox::warning(0, "Error", e.description());
    }
}
예제 #18
0
파일: gamescene.cpp 프로젝트: mardy/trg2
GameScene::GameScene()
    : rabbit(NULL)
    , crosshairs(NULL)
    , landscape(NULL)
    , coin(NULL)
    , timeDisplay(NULL)
    , gameThread(NULL)
    , timeManager(new TimeManager())
    , input(GESTURE_NOTHING)
    , currentState(UNDEFINED)
    , stones()
    , gameOver(NULL)
    , menu(NULL)
    , beginAnimation(NULL)
    , tapHelp(NULL)
    , tiltHelp(NULL)
    , currentTint(DEFAULT_TINT_MENU)
    , masterScale(1.)
    , w(0)
    , h(0)
    , viewport_width(0)
    , viewport_height(0)
{
    setCurrentState(INTRO);
    beginAnimation = new BeginAnimation(this);
}
예제 #19
0
파일: player.cpp 프로젝트: mateev/darts
//	Copy constructor
Player::Player(const Player& other)
{
	id = other.id;
	score = other.score;
	dartsUsed = other.dartsUsed;
	setCurrentState();				//	Initialize state
	setBullHitPercent();			//	Calculate hit percent
}
예제 #20
0
void Widget::OnLeave() {
	setCurrentState(NORMAL);
	EvtFunc *func = funcs[EVT_LEAVE].func;
	void *data = funcs[EVT_LEAVE].data;

	if (func)
		func(this, data);
}
예제 #21
0
파일: player.cpp 프로젝트: mateev/darts
//	Default constructor
Player::Player(PlayerID inputID)
{
	id = inputID;
	score = 301;
	dartsUsed = 0;
	setCurrentState();				//	Initialize state
	setBullHitPercent();			//	Calculate hit percent
}
예제 #22
0
void StatesEditorView::renameState(int nodeId, const QString &newName)
{
    if (hasModelNodeForInternalId(nodeId)) {
        QmlModelState state(modelNodeForInternalId(nodeId));
        try {
            if (state.isValid() && state.name() != newName) {
                // Jump to base state for the change
                QmlModelState oldState = currentState();
                setCurrentState(baseState());
                state.setName(newName);
                setCurrentState(oldState);
            }
        }  catch (RewritingException &e) {
            QMessageBox::warning(0, "Error", e.description());
        }
    }
}
XYPenPlotterController::XYPenPlotterController(QObject *parent) :
    QObject(parent)
{
    setCurrentState("STOPPED");
    timer = new QTimer(this);
    timer->setInterval(100);
    connect(timer, SIGNAL(timeout()), this, SLOT(setStoppedState()));
}
예제 #24
0
void StatesEditorView::renameState(int internalNodeId, const QString &newName)
{
    if (hasModelNodeForInternalId(internalNodeId)) {
        QmlModelState state(modelNodeForInternalId(internalNodeId));
        try {
            if (state.isValid() && state.name() != newName) {
                // Jump to base state for the change
                QmlModelState oldState = currentState();
                setCurrentState(baseState());
                state.setName(newName);
                setCurrentState(oldState);
            }
        }  catch (const RewritingException &e) {
            e.showException();
        }
    }
}
예제 #25
0
void Warrior::recycle(Game* game,BotRecycler * recycle){
	game->getGSM()->getPhysics()->destroyBody(this);
	recycle->recycleBot(Warrior::typeID,this);
	targetUnit=NULL;
	targetInRange=0;
	state=standby;
	setCurrentState((wstring)L"IDLE_STATE_NORTH");
	this->generalRelease();
}
void XYPenPlotterController::receivePlotterMessages()
{
    if(receive_msg(&rcv_msg, 100))
        return;

    if(rcv_msg.status == PLOTTER_DRAW)
    {
        qDebug("Plotter start draw!");
        setCurrentState("RUNNING");
    }
    else if(rcv_msg.status == PLOTTER_START)
    {
        qDebug("Plotter running... %d%%", rcv_msg.data);

        // Update progress bar...
        setProgress(rcv_msg.data);
    }
    else if(rcv_msg.status == PLOTTER_UNPAUSE)
    {
        setCurrentState("RUNNING");
    }
    else if(rcv_msg.status == PLOTTER_PAUSE)
    {
        setCurrentState("PAUSED");
    }
    else if(rcv_msg.status == PLOTTER_HOME)
    {
        setCurrentState("STOPPED");
    }
    else if(rcv_msg.status == PLOTTER_STOP)
    {
        if(currentState != "STOPPED")
            setCurrentState("STOPPED");
        // Reset progress bar...
        setProgress(0);
    }
    else
    {
        qDebug("Something went wrong! Plotter status = 0x%x", rcv_msg.status);
    }
    msg.data = 0xff;
    if(send_msg(&msg))
        return;
}
예제 #27
0
void Rock::update(std::vector<std::vector<int>> colMap) {
    moveM(colMap);

    if (currentState == FLYING) {
        if (acceleration.y < 0) {
            movement.update(vertices, mSize);
        } else if (acceleration.y > 0) {
            movement.update(vertices, mSize);
        }

        if (acceleration.x < 0) {
            movement.update(vertices, mSize);
        } else if (acceleration.x > 0) {
            movement.update(vertices, mSize);
        }
        acceleration.x *= .9;
        acceleration.y *= .9;

        if (abs(acceleration.x) <= .1 && abs(acceleration.y) <= .1) {
            acceleration.x = 0;
            acceleration.y = 0;
        }

        if ((abs(velocity.x) == 0 && abs(velocity.y) == 0))
            setCurrentState(GROUND);
    }

    if (currentState == GROUND) {
        setTexCoords(0, 0);
    }

    if (currentState == GRABBING) {
        if (extend.getIndex() == 7) {
            setCurrentState(HELD);
            extend.setIndex(0);
        } else {
            extend.update(vertices, mSize);
        }
    }

    bounds.left = getPosition().x;
    bounds.top = getPosition().y;
}
void MiniBoss::bossDeath2()
{
	health2 = INT_MAX;
	dead2 = true;
	bossBody2->removeFromWorld();
	bossSprite2->removeFromParentAndCleanup(true);

	if (dead1)
		setCurrentState(MiniBossStates::MINI_BOSS_DEAD);
}
예제 #29
0
void StatesEditorView::nodeAboutToBeRemoved(const ModelNode &removedNode)
{
    if (removedNode.hasParentProperty()) {
        const NodeAbstractProperty propertyParent = removedNode.parentProperty();
        if (propertyParent.parentModelNode().isRootNode() && propertyParent.name() == "states")
            m_lastIndex = propertyParent.indexOf(removedNode);
    }
    if (currentState().isValid() && removedNode == currentState())
        setCurrentState(baseState());
}
예제 #30
0
void Widget::OnBtnReleased() {
	EvtFunc *func = funcs[EVT_BTNPRESSED].func;
	void *data = funcs[EVT_BTNPRESSED].data;
	if (func)
		func(this, data);

	if (current == PRESSED) {
		OnClick();
		setCurrentState(PRELIGHT);
	}
}