Beispiel #1
0
void Spectrum::wheelEvent(QWheelEvent *event) {
    //qDebug() << __FUNCTION__ << "Delta: " << event->delta() << "y: " << event->pos().y() << " heigth:" << height();

    if(event->pos().x() > 50) {
        // wheel event on the right side
        // change frequency
        float vOfs = (float)event->pos().y() / (float)height();
        //qDebug() << "wheelEvent vOfs: " << vOfs;

        if (vOfs > 0.75) {
            emit frequencyMoved(event->delta()/8/15,100);
        } else if (vOfs > 0.50) {
            emit frequencyMoved(event->delta()/8/15,50);
        } else if (vOfs > 0.25) {
            emit frequencyMoved(event->delta()/8/15,25);
        } else {
            emit frequencyMoved(event->delta()/8/15,10);
        }
    } else {
        // wheel event on the left side, change the vertical axis values
        float shift =  (float)(event->delta()/8/15 * 5)                    // phy steps of wheel * 5
                     * ((float)(spectrumHigh - spectrumLow) / height());   // dBm / pixel on vertical axis
       
        if (event->buttons() == Qt::MidButton) {
           // change the vertical axis range
           //qDebug() << __FUNCTION__ << " change vertical axis scale: " << shift;
           emit spectrumHighChanged (spectrumHigh+(int)shift);
           emit spectrumLowChanged  (spectrumLow-(int)shift);
           emit waterfallHighChanged (spectrumHigh+(int)shift);
           emit waterfallLowChanged  (spectrumLow-(int)shift);

        } else {
          // if middle mouse button pressed shift the spectrum scale
          //qDebug() << __FUNCTION__ << " shift on vertical axis scale: " << shift;
          emit spectrumHighChanged (spectrumHigh+(int)shift);
          emit spectrumLowChanged  (spectrumLow+(int)shift);
          emit waterfallHighChanged (spectrumHigh+(int)shift);
          emit waterfallLowChanged  (spectrumLow+(int)shift);

       }
    }
}
Beispiel #2
0
void Spectrum::mouseReleaseEvent(QMouseEvent* event) {
    int move=event->pos().x()-lastX;
    lastX=event->pos().x();
    //qDebug() << __FUNCTION__ << ": " << event->pos().x() << " move:" << move;

    if(moved) {
        emit frequencyMoved(move,100);
    } else {
        float hzPixel = sampleRate/width();  // spectrum resolution: Hz/pixel

        long freqOffsetPixel;
        long long f = frequency - (sampleRate/2) + (event->pos().x()*hzPixel);
        if(subRx) {    
            freqOffsetPixel = (subRxFrequency-f)/hzPixel;
            if (button == Qt::LeftButton) {
                // set frequency to center of filter
                if(filterLow<0 && filterHigh<0) {
                    freqOffsetPixel+=(((filterLow-filterHigh)/2)+filterHigh)/hzPixel;
                } else if(filterLow>0 && filterHigh>0){
                    freqOffsetPixel-=(((filterHigh-filterLow)/2)-filterHigh)/hzPixel;
                } else {
                    // no adjustment
                }
            }
        } else {
            freqOffsetPixel = (f-frequency)/hzPixel; // compute the offset from the central frequency, in pixel
            if (button == Qt::LeftButton) {
                // set frequency to center of filter
                if(filterLow<0 && filterHigh<0) {
                    freqOffsetPixel-=(((filterLow-filterHigh)/2)+filterHigh)/hzPixel;
                } else if(filterLow>0 && filterHigh>0){
                    freqOffsetPixel+=(((filterHigh-filterLow)/2)-filterHigh)/hzPixel;
                } else {
                    // no adjustment
                }
            }
        }

        emit frequencyMoved(-(long long)(freqOffsetPixel*hzPixel)/100,100);

    }
}
Beispiel #3
0
void vfo::vfohotkey(QString cmd)
{
    if (cmd.compare("FreqDown") == 0){
        emit frequencyMoved(vfohotstep, -1);
        //qDebug() <<"cmd=" <<cmd;
        return;
    }
    if (cmd.compare("FreqUp") == 0){
        emit frequencyMoved(vfohotstep, 1);
        //qDebug() <<"cmd=" <<cmd <<"vfohotstep" <<vfohotstep;
        return;
    }
    static const int mult[7] = {1,10,100,1000,10000,100000,1000000};
    if (cmd.compare("StepUp") == 0  && curstep <6){
        //qDebug() <<"Step Up old =" <<vfohotstep << " curstep" << curstep;
        curstep++;
        vfohotstep = mult[curstep];
        //qDebug() <<"new =" <<vfohotstep;
        setStepMark();
        return;
    }
    if (cmd.compare("StepUp") == 0  && curstep == 6){
        //qDebug() <<"Step Up Wrap old =" <<vfohotstep << " curstep" << curstep;
        curstep = 0;
        vfohotstep = mult[curstep];
        //qDebug() <<"new =" <<vfohotstep;
        setStepMark();
        return;
    }


    if (cmd.compare("StepDown") == 0  && curstep >0){
        //qDebug() <<"old =" <<vfohotstep;
        curstep--;
        vfohotstep = mult[curstep];
        //qDebug() <<"new =" <<vfohotstep;
        setStepMark();
        return;
    }
    return;

}
Beispiel #4
0
void vfo::on_pBtnRIT_clicked()
{
    int chkd = 1;

    if (ui->pBtnRIT->isChecked()) {
        chkd = -1;
    }
    if (ui->hSlider->value() != 0) {
        emit frequencyMoved(ui->hSlider->value() * chkd, 1);
    }
}
Beispiel #5
0
void Waterfall::mouseMoveEvent(QMouseEvent* event){
    int move=event->pos().x()-lastX;
    lastX=event->pos().x();
//    qDebug() << __FUNCTION__ << ": " << event->pos().x() << " move:" << move;

    moved=1;
    float zoom_factor = 1.0f + zoom/25.0f;
    float move_ratio = (float)sampleRate/48000.0f/zoom_factor;
    int move_step;
    if (move_ratio > 10.0f) move_step = 500;
    else if (move_ratio > 5.0f) move_step = 200;
    else if (move_ratio > 2.5f) move_step = 100;
    else if (move_ratio > 1.0f) move_step = 50;
    else if (move_ratio > 0.5f) move_step = 10;
    else if (move_ratio > 0.25f) move_step = 5;
    else move_step = 1;
    if (! move==0) {
        if (subRx) emit frequencyMoved(-move,move_step);
        else emit frequencyMoved(move,move_step);
    }
}
Beispiel #6
0
void vfo::wheelEvent(QWheelEvent *event)
{
    QString str;
    long long x;
    int digit;
    int direction = 1;
    bool isVfoA = true;
    static const int mult[9] = {100000000,10000000,1000000,100000,10000,1000,100,10,1};

    digit = getDigit(event->x(), event->y());
    if (digit != 9) {  // getDigit returns 9 if click was outside display area so we just fall through.
        if (event->delta() < 0) direction = -1;  // x becomes pos or neg depending on wheel rotation.
        if (digit > 9) { // getDigit returns 10 ... 18 if we clicked on vfoB
            digit = digit - 10; // so convert to 1 ... 8.
            isVfoA = false;
        }
        x = mult[digit]*direction;
        if(isVfoA) {    //If true we scrolled on vfoA
//qDebug()<<Q_FUNC_INFO<<"The value of x = "<<", & readA() = "<<readA();
            if(selectedVFO == 'A' || selectedVFO == 'S') {
                emit frequencyMoved(x, 1);
            }
            else {
                writeA(readA() - x);
            }
        }
        else {  //We scrolled on vfoB
//qDebug()<<Q_FUNC_INFO<<"The value of x = "<< x<<", & readB() = "<<readB();
            if(selectedVFO == 'B') {
                emit frequencyMoved(x, 1);
            }
            else {
                writeB(readB() - x);
            }
        }
    }  //We fall through to here without processing the wheel if getDigit returns 9.
}
Beispiel #7
0
void Spectrum::mouseReleaseEvent(QMouseEvent* event) {
    int move=event->pos().x()-lastX;
    lastX=event->pos().x();
    //qDebug() << __FUNCTION__ << ": " << event->pos().x() << " move:" << move;

    if(squelch && settingSquelch) {
        button=-1;
        settingSquelch=false;
    } else {
        float zoom_factor = 1.0f + zoom/25.0f;
        if(moved) {
            float move_ratio = (float)sampleRate/48000.0f/zoom_factor;
            int move_step;
            if (move_ratio > 10.0f) move_step = 500;
            else if (move_ratio > 5.0f) move_step = 200;
            else if (move_ratio > 2.5f) move_step = 100;
            else if (move_ratio > 1.0f) move_step = 50;
            else if (move_ratio > 0.5f) move_step = 10;
            else if (move_ratio > 0.25f) move_step = 5;
            else move_step = 1;
            if (subRx) emit frequencyMoved(-move,move_ratio);
            else emit frequencyMoved(move,move_step);
        } else {
            float hzPixel = (float) sampleRate / width() / zoom_factor;  // spectrum resolution: Hz/pixel
            long freqOffsetPixel;
            long long f = frequency - (sampleRate/2/zoom_factor) + (event->pos().x()*hzPixel)
                    -LO_offset;

            if(subRx) {    
                freqOffsetPixel = (subRxFrequency-f)/hzPixel;
                if (button == Qt::LeftButton) {
                    if((mode!="USB")&&(mode!="LSB")){
                        // set frequency to center of filter
                        if(filterLow<0 && filterHigh<0) {
                            freqOffsetPixel+=(((filterLow-filterHigh)/2)+filterHigh)/hzPixel;
                        } else if(filterLow>0 && filterHigh>0){
                            freqOffsetPixel-=(((filterHigh-filterLow)/2)-filterHigh)/hzPixel;
                        } else {
                        // no adjustment
                        }
                    } // no adjustment needed if USB or LSB mode so we snap to the carrier frequency.      
                }
                emit frequencyMoved((long long)(freqOffsetPixel*hzPixel)/100,100);
            } else {
                freqOffsetPixel = (f-frequency)/hzPixel; // compute the offset from the central frequency, in pixel
                if (button == Qt::LeftButton) {
                    if((mode!="USB")&&(mode!="LSB")){
                        // set frequency to center of filter
                        if(filterLow<0 && filterHigh<0) {
                        freqOffsetPixel-=(((filterLow-filterHigh)/2)+filterHigh)/hzPixel;
                        } else if(filterLow>0 && filterHigh>0){
                            freqOffsetPixel+=(((filterHigh-filterLow)/2)-filterHigh)/hzPixel;
                        } else {
                        // no adjustment if filter extends each side of carrier frequency
                        }
                    } // no adjustment needed if USB or LSB mode so we snap to the carrier frequency.
                }
                emit frequencyMoved(-(long long)(freqOffsetPixel*hzPixel)/100,100);
            }

        }
        button = -1;
    }
}
Beispiel #8
0
void vfo::mousePressEvent(QMouseEvent *event)
{
    bool isVFOa = false;
    int digit, cnt;
    QString myStr = "";
    long long freq;

    if (event->button() == Qt::RightButton) {

//qDebug()<<Q_FUNC_INFO<<": event x/y = "<<event->x()<<"/"<<event->y();

        //Check to see if we have right clicked on the band button group
        if ((event->x() > 414) && (event->x() < 573) &&
            (event->y() > 6) && (event->y() < 111)) {
//            storeVFO(); //make the selected button flash yellow & call store routine
            timer.start(500,this);
            ui->btnGrpBand->checkedButton()->setStyleSheet("background-color: yellow");
            emit rightBandClick();  //connected to Band:quickMemStore via UI:quickMemStore

        }   // Check to see if we have right clicked the RIT slider
        else if ((event->x() > 189) && (event->x() < 403) &&
                 (event->y() > 89) && (event->y() < 111)) {
                ui->hSlider->setValue(0);
        }
        // We have clicked either on the display or somewhere else on the widget

        else {  // Check to see if we have clicked outside the vfo display area
            digit = getDigit(event->x(), event->y());
//qDebug()<<Q_FUNC_INFO<<": The value of digit is ..."<<digit;
            if (digit != 9) {       // getDigit returns 9 if click was outside display area.
                if (digit < 9) {    // getDigit returns 0 ... 8 if we clicked on vfoA
                    freq = readA();
                    isVFOa = true;
                    myStr = ui->lbl_Amhz->text() + ui->lbl_Akhz->text() + ui->lbl_Ahz->text();
                }
                else {                  // getDigit returns 10 ... 18 if we clicked on vfoB
                    digit = digit - 10; // so convert to 1 ... 8.
                    freq = readB();
                    myStr = ui->lbl_Bmhz->text() + ui->lbl_Bkhz->text() + ui->lbl_Bhz->text();
                }
                for (cnt = myStr.length(); cnt < 9; cnt++) {
                    myStr = "0" + myStr;
                }
                for (cnt = digit; cnt < 9; cnt++) {
                    myStr[cnt] = QChar('0');
                    ui->hSlider->setValue(0);
                }
                freq = freq - myStr.toLongLong();
                if (isVFOa) {   //We right clicked on vfoA
                    if(selectedVFO == 'A' || selectedVFO == 'S') {
                        emit frequencyMoved(freq, 1);
//qDebug()<<Q_FUNC_INFO<<": vfoA, emit frequencyChanged(myStr.toLongLong()) = "<<freq;
                    }
                    else {
                        writeA(myStr.toLongLong());
//qDebug()<<Q_FUNC_INFO<<": vfoA, writeA(myStr.toInt()) = "<<freq;
                    }
                }
//                else if(ui->pBtnSubRx->isChecked()) { //We right clicked on vfoB
//qDebug()<<Q_FUNC_INFO<<": vfoB and subRx mode";
//                }
                else if(selectedVFO == 'B') {
                        emit frequencyMoved(freq, 1);
//qDebug()<<Q_FUNC_INFO<<": Line 187 ... vfoB, emit frequencyMoved(freq, 1) = "<<freq;
                }
                else {
                        writeB(myStr.toLongLong());
//qDebug()<<Q_FUNC_INFO<<": vfoB, writeA(myStr.toInt()) = "<<freq;
                }
            }
        }
    }   //If event not right button or getDigit = 9, fall thru to here with no processing.
}
Beispiel #9
0
void vfo::decrease(int n) {
	emit frequencyMoved(vfohotstep, n);
	qDebug()<<Q_FUNC_INFO<<": Powermate rotated";
}