コード例 #1
0
/******************************************************************************
    apply a force, and update the position
******************************************************************************/
void ActorDynamics::doDynamics(const hduVector3Dd& appliedForce)
{
    hduVector3Dd newPosition;

    newPosition = m_location[NOW] + (m_location[NOW] - m_location[BEFORE]) + 
                  appliedForce/m_mass;

    setNewPosition(newPosition);
}
コード例 #2
0
ファイル: windowManager.cpp プロジェクト: craftoid/Cstitch
bool windowManager::eventFilter(QObject* target, QEvent* event) {

  //    qDebug() << "e" << event->type();
  if (event->type() == QEvent::Resize) {
    QResizeEvent* resize = static_cast<QResizeEvent*>(event);
    setNewSize(resize->size());
    return true;
  }

  if (event->type() == QEvent::Move) {
    setNewPosition(static_cast<QWidget*>(target)->pos());
    return true;
  }
  return QObject::eventFilter(target, event);
}
コード例 #3
0
ファイル: stepper.c プロジェクト: alimoeeny/binoclean
void NewPosition(int pos)
{
    char buf[256];
#ifdef REVERSED_CABLEA
    int diff = pos - electrodeDepth; 
#else
    int diff = electrodeDepth - pos; 
#endif
    int old = electrodeDepth;
    int portstate;
    
    if(motorinvert){
        while((electrodeDepthOffset-pos) <= 0){
            electrodeDepthOffset += 10000;
        }
    }
    else{
        while((electrodeDepthOffset+pos) <= 0){
            electrodeDepthOffset += 10000;
        }
    }
    
#ifdef OLDCODE
    while((pos - electrodeDepthOffset) >= 0){
        electrodeDepthOffset -= 10000;
    }
#endif
    
    if(fabs(diff) > 9999){
        sprintf(buf,"Thats a big step (%d) Proceed?",diff);
        acknowledge(buf,"/bgc/bgc/c/binoc/help/bigstep.err");
    }
    if(fabs(diff) > 200){
        sprintf(buf,"Thats a big step (%d) Proceed?",diff);
        if(!confirm_yes(buf,NULL))
            return;
        
    }
    
#ifdef DEBUG
    printf("Setting new Postion to %d (%d) %d\n",pos,diff,electrodeDepthOffset);
#endif
#if !defined(WIN32)
    ioctl(motorPort,TIOCMGET,&portstate);
    if(!(portstate & TIOCM_CTS)){
        fprintf(stderr,"Stepper Not Ready\n");
        acknowledge("Stepper Not Ready!");
        if(optionflags[STEP_CLEAR_SPIKES]){
            memcpy(&cleartime,&now,sizeof(struct timeval));
            /* empirical approximation for the duration of the movement artifact */
            cleardelay = 0.2;
        }
        return;
    }
#endif
    
    sprintf(buf,"%d",pos);
    
    electrodeDepth = pos;
    
    selectMotor(motorids[motorid]);
    setCurrentPosition(old);  
    setNewPosition(electrodeDepth,diff);
	gettimeofday(&now,NULL);
    times[totalsteps] = timediff(&now,&progstarttime) + timeoffset;
    depths[totalsteps] = electrodeDepth;
    if(penlog){
        fprintf(penlog,"ed %d at %.1f\n",electrodeDepth,times[totalsteps]);
        if(diff < -200){
            fprintf(penlog,"Step Back at %s\n",binocTimeString());
        }
    }
    times[totalsteps+1] = 0;
    if(totalsteps < MAXDEPTHS-1)
        totalsteps++;
    if(optionflags[STEP_CLEAR_SPIKES]){
        memcpy(&cleartime,&now,sizeof(struct timeval));
        /* empirical approximation for the duration of the movement artifact */
        cleardelay = 0.11 + fabs(diff) * 0.027 - pow(fabs(diff),1.13) * 0.0113;
    }
    notifyPositionChange(electrodeDepth);
}