Exemple #1
0
void PianoView::leaveEvent(QEvent* event)
      {
      emit pitchChanged(-1);
      pos.setInvalid();
      emit posChanged(pos);
      QGraphicsView::leaveEvent(event);
      }
Exemple #2
0
void Piano::leaveEvent(QEvent*)
      {
      if (curPitch != -1) {
            curPitch = -1;
            emit pitchChanged(-1);
            update();
            }
      }
Exemple #3
0
void Piano::leaveEvent(QEvent*)
{
    if (keyDown != -1) {
        emit keyReleased(keyDown, shift);
        keyDown = -1;
    }
    emit pitchChanged(-1);
    setPitch(-1);
}
Exemple #4
0
void Piano::mouseMoveEvent(QMouseEvent* event)
      {
      int pitch = y2pitch(event->pos().y());
      if (pitch != curPitch) {
            curPitch = pitch;
            emit pitchChanged(curPitch);
            if ((curKeyPressed != -1) && (curKeyPressed != pitch)) {
                  emit keyReleased(curKeyPressed);
                  curKeyPressed = pitch;
                  emit keyPressed(curKeyPressed);
                  }
            update();
            }
      }
Exemple #5
0
void PianoView::mouseMoveEvent(QMouseEvent* event)
      {
      QPointF p(mapToScene(event->pos()));
      int pitch = y2pitch(int(p.y()));
      emit pitchChanged(pitch);
      int tick = int(p.x()) -480;
      if (tick < 0) {
            tick = 0;
            pos.setTick(tick);
            pos.setInvalid();
            }
      else
            pos.setTick(tick);
      emit posChanged(pos);
      QGraphicsView::mouseMoveEvent(event);
      }
void MovementAnalyzer::calculateOriantationAndVelocity( const int timestamp )
{
    unsigned int d = timestamp - m_velocityInterval;
    if( m_boudingGeometries.at( 0 ) && m_boudingGeometries.at( 1 ) )
    {
        QVector3D diff ( m_boudingGeometries.first()->m_geometry->x() - m_boudingGeometries.at( 1 )->m_geometry->x(),
                         m_boudingGeometries.first()->m_geometry->y() - m_boudingGeometries.at( 1 )->m_geometry->y(),
                         m_boudingGeometries.first()->m_geometry->z() - m_boudingGeometries.at( 1 )->m_geometry->z() );

        m_velocity =  diff.length();
//        qDebug()<< QString( "diff: %1, %2, %3" ).arg( diff.x() )
//                                                .arg( diff.y() )
//                                                .arg( diff.z() );
        emit veloctiyChanged();
        AMath::anglesFromSphericalCoordinates( m_yaw, m_pitch, diff );
        emit yawChanged();
        emit rollChanged();
        emit pitchChanged();
    }

//    for ( int i = 0; i < m_maxBoudingGeometryCount; ++i )
//    {
//        if ( m_boudingGeometries.at( i ) &&
//             m_boudingGeometries.at( i )->m_timestamp < d )
//        {
//            // Calculate the catersian norm.
//            QVector3D diff ( m_boudingGeometries.first()->m_geometry->x() - m_boudingGeometries.at( i )->m_geometry->x(),
//                             m_boudingGeometries.first()->m_geometry->y() - m_boudingGeometries.at( i )->m_geometry->y(),
//                             m_boudingGeometries.first()->m_geometry->z() - m_boudingGeometries.at( i )->m_geometry->z() );
//            m_velocity =  diff.length();
//            emit veloctiyChanged();

//            AMath::anglesFromSphericalCoordinates( m_yaw, m_pitch, diff );
//            emit yawChanged();
//            emit rollChanged();
//            emit pitchChanged();
//        }
//    }
}
Exemple #7
0
void Piano::viewMouseMoveEvent(QMouseEvent* event)
{
    int pitch = y2pitch(event->y());
    emit pitchChanged(pitch);
    setPitch(pitch);

    if (button != Qt::NoButton) {
        int nk = y2pitch(event->y());
        if (nk < 0 || nk > 127)
            nk = -1;
        if (nk != keyDown) {
            if (keyDown != -1) {
                emit keyReleased(keyDown, shift);
            }
            keyDown = nk;
            if (keyDown != -1) {
                int velocity = event->x()*127/40;
                emit keyPressed(keyDown, velocity>127 ? 127 : velocity, shift);
            }
        }
    }
}
Exemple #8
0
BarChartCore::BarChartCore(QQuickItem* parent) :
    ChartCore(parent)
{
    connect(this, SIGNAL(pitchChanged()), SIGNAL(barWidthChanged()));
}
Exemple #9
0
void CompassPort::on()// метод для чтения из порта и его открытия, если не открыт
{

    emit timerStop();
    if(!portSensor->isOpen())
    {       

        if (portSensor->open(QIODevice::ReadWrite))// открываем порт если он еще не открыт
        {

            QSerialPortInfo *info = new QSerialPortInfo(*portSensor);//информация о порте для отладки
            m_state=1;// порт открыт


            delete info;
        }
        else
        {
            if(portSensor->isOpen())// если что-то пошло не так, закрываем порт
                portSensor->close();
        }
    }

    if(portSensor->isOpen() && portSensor->waitForReadyRead(100))// работа с открытым портом
    {

        QString data;
        QByteArray ByteArray,ByteArrayStart,ByteArrayFinish;
        bool startFinded = false;
        m_state = 1;
        while(m_state)// пока порт открыт
        {
            //if(portSensor->waitForReadyRead(1))
            {
                qint64 byteAvail = portSensor->bytesAvailable();// просматриваем кол-во доступных байн для чтения
                qApp->processEvents();
                QThread::msleep(10);//усыпляем поток, чтобы не занимал времени( данные раз в 10 секунд)
                if(byteAvail >=23)// проверка кол-ва байт, для их обработки
                {
                    ByteArray = portSensor->readAll();// чтение из буфера порта
                    data = data.fromLocal8Bit(ByteArray).trimmed();
                    if(ByteArray[3]=='p')//то ли сообщение пришло(смотри даташит хоневеловского датчика)
                    {
                        QBitArray bitdata(184),two_bytes(16);
                        for(int i = 0,j; i < 184; ++i)//формирование массива бит для парсинга сообщения
                        {
                            j=i/8;
                            if(j<=18)
                                bitdata[i] = ByteArray[j] & (1 << i%8);
                            else

                                break;
                        }

//                            //m_roll = Round(toDec(two_bytes,1)*1.41,1);
                            m_roll = QString::number((short)((ByteArray.at(6)<<8) + (ByteArray.at(5)))*360.0/65536.0,10,1).toDouble();
                            emit rollChanged(m_roll);
//                            for(int i=56,j=15;i<72&&j>=0;i++,j--){two_bytes[j]=bitdata[i];} //Pitch

//                            m_pitch = Round(toDec(two_bytes,1)*1.41,1);
                            m_pitch = QString::number((short)((ByteArray.at(8)<<8) + (ByteArray.at(7)))*360.0/65536.0,10,1).toDouble();
                            emit pitchChanged(m_pitch);
                            for(int i=72,j=15;i<88&&j>=0;i++,j--){two_bytes[j]=bitdata[i];} //Azimuth

                           // m_angle = Round(toDec(two_bytes,0)*1.41,1);
                            for(int i=72,j=15;i<88&&j>=0;i++,j--){two_bytes[j]=bitdata[i];} //Azimuth
                            m_angle = Round(toDec(two_bytes,0)*1.41,1);
                            static int i=0;
                            if(i<=1)
                            {
                                i++;
                            }
                            else
                            {
                                emit angleChanged(m_angle);
                                i=0;
                            }


                            m_B= QString::number((short)((ByteArray.at(18)<<8) + (ByteArray.at(17)))*750.0/65536.0,10,1).toDouble();
                            emit BChanged(m_B);

//                            for(int i=152,j=15;i<168&&j>=0;i++,j--){two_bytes[j]=bitdata[i];} //coef C
//                            m_C = Round(toDec(two_bytes,1)*3,1);
                            m_C= QString::number((short)((ByteArray.at(20)<<8) + (ByteArray.at(19)))*750.0/65536.0,10,1).toDouble();

                            emit CChanged(m_C);

//                            for(int i=168,j=15;i<184&&j>=0;i++,j--){two_bytes[j]=bitdata[i];} //coef Z
//                            m_Z = Round(toDec(two_bytes,1)*1.41,1);
                            m_Z= QString::number((short)((ByteArray.at(22)<<8) + (ByteArray.at(21)))*750.0/65536.0,10,1).toDouble();
                            emit ZChanged(m_Z);


                        m_state=0;
                        qApp->processEvents();
                    }
                }
                // внимательно посмотреть этот код, кажется косяк с выбросами полей и курса в нем(!)
                else if(byteAvail >=4 && byteAvail <=23)// если сообщение не полное( разбито на два)
                {
                    ByteArray= portSensor->readAll();
                    data = data.fromLocal8Bit(ByteArray).trimmed();
                    if(ByteArray[3]=='p' && startFinded == false)
                    {
                        ByteArrayStart = ByteArray;
                        startFinded = true;

                    }
                    else if(startFinded == true)
                    {
                        ByteArrayFinish += ByteArray;
                        ByteArray = ByteArrayStart + ByteArrayFinish;
                        if(ByteArray.size() >= 23)
                        {
                            QBitArray bitdata(184),two_bytes(16);
                            for(int i = 0,j; i < 184; ++i)
                            {
                                j=i/8;
                                if(j<=23)
                                    bitdata[i] = ByteArray[j] & (1 << i%8);
                                else
                                    break;
                            }
//                            //m_roll = Round(toDec(two_bytes,1)*1.41,1);
                            m_roll = QString::number((short)((ByteArray.at(6)<<8) + (ByteArray.at(5)))*360.0/65536.0,10,1).toDouble();
                            emit rollChanged(m_roll);
//                            for(int i=56,j=15;i<72&&j>=0;i++,j--){two_bytes[j]=bitdata[i];} //Pitch

//                            m_pitch = Round(toDec(two_bytes,1)*1.41,1);
                            m_pitch = QString::number((short)((ByteArray.at(8)<<8) + (ByteArray.at(7)))*360.0/65536.0,10,1).toDouble();
                            emit pitchChanged(m_pitch);
                            for(int i=72,j=15;i<88&&j>=0;i++,j--){two_bytes[j]=bitdata[i];} //Azimuth

                           // m_angle = Round(toDec(two_bytes,0)*1.41,1);
                            for(int i=72,j=15;i<88&&j>=0;i++,j--){two_bytes[j]=bitdata[i];} //Azimuth
                            m_angle = Round(toDec(two_bytes,0)*1.41,1);
                            static int i=0;
                            if(i<=1)
                            {
                                i++;
                            }
                            else
                            {
                                emit angleChanged(m_angle);
                                i=0;
                            }


                            m_B= QString::number((short)((ByteArray.at(18)<<8) + (ByteArray.at(17)))*750.0/65536.0,10,1).toDouble();
                            emit BChanged(m_B);

//                            for(int i=152,j=15;i<168&&j>=0;i++,j--){two_bytes[j]=bitdata[i];} //coef C
//                            m_C = Round(toDec(two_bytes,1)*3,1);
                            m_C= QString::number((short)((ByteArray.at(20)<<8) + (ByteArray.at(19)))*750.0/65536.0,10,1).toDouble();

                            emit CChanged(m_C);

//                            for(int i=168,j=15;i<184&&j>=0;i++,j--){two_bytes[j]=bitdata[i];} //coef Z
//                            m_Z = Round(toDec(two_bytes,1)*1.41,1);
                            m_Z= QString::number((short)((ByteArray.at(22)<<8) + (ByteArray.at(21)))*750.0/65536.0,10,1).toDouble();
                            emit ZChanged(m_Z);

                            m_state=0;
                            startFinded = false;
                        }
                    }
                }
            }
        }
    }
    else
    {

    }
    emit timerStart(10);
}
/*!
   \brief MovementAnalyzer::setPitch
   Sets the pitch angle to \a pitch.
 */
void MovementAnalyzer::setPitch( const float pitch )
{
    m_pitch = pitch;
    emit pitchChanged();
}
Exemple #11
0
void MidiSequencer::setPitchShift(unsigned int value)
{
    m_midiSequencerOutputThread->setPitchShift(value);
    emit allNotesOff();
    emit pitchChanged(value);
}
Exemple #12
0
void Kompas::setPitch(double st)
{
    m_pitch=Round(st,1);
    emit pitchChanged();
}
Exemple #13
0
void EventCanvas::leaveEvent(QEvent*)
{
    emit pitchChanged(-1);
    emit timeChanged(MAXINT);
}
Exemple #14
0
void EventCanvas::mouseMove(QMouseEvent* event)
{
    emit pitchChanged(y2pitch(event->pos().y()));
    int x = event->pos().x();
    emit timeChanged(editor->rasterVal(x));
}