void viewGVpropertieslayout::contextMenuRequest(QPoint pos)
{
    // first get a pointer to the current plot!
    QCustomPlot * currPlot = (QCustomPlot *) currentSubWindow->widget();
    QMenu *menu = new QMenu(this);
    menu->setAttribute(Qt::WA_DeleteOnClose);

    if (currPlot->legend->selectTest(pos, false) >= 0) // context menu on legend requested
    {
        /*menu->addAction("Move to top left", this, SLOT(moveLegend()))->setData((int)(Qt::AlignTop|Qt::AlignLeft));
        menu->addAction("Move to top center", this, SLOT(moveLegend()))->setData((int)(Qt::AlignTop|Qt::AlignHCenter));
        menu->addAction("Move to top right", this, SLOT(moveLegend()))->setData((int)(Qt::AlignTop|Qt::AlignRight));
        menu->addAction("Move to bottom right", this, SLOT(moveLegend()))->setData((int)(Qt::AlignBottom|Qt::AlignRight));
        menu->addAction("Move to bottom left", this, SLOT(moveLegend()))->setData((int)(Qt::AlignBottom|Qt::AlignLeft));*/
    } else if (currPlot->xAxis->selectTest(pos, false) >= 0 || \
               currPlot->xAxis2->selectTest(pos, false) >= 0)
    {
        // enable / disable zoom
        if (currPlot->axisRect()->rangeZoom() & Qt::Horizontal)
            menu->addAction("Disable zoom on axis", this, SLOT(toggleHorizontalZoom()));
        else
            menu->addAction("Enable zoom on axis", this, SLOT(toggleHorizontalZoom()));

        // enable / diable drag
        if (currPlot->axisRect()->rangeDrag() & Qt::Horizontal)
            menu->addAction("Disable drag on axis", this, SLOT(toggleHorizontalDrag()));
        else
            menu->addAction("Enable drag on axis", this, SLOT(toggleHorizontalDrag()));

    } else if (currPlot->yAxis->selectTest(pos, false) >= 0 || \
               currPlot->yAxis2->selectTest(pos, false) >= 0)
    {

        // enable / disable zoom
        if (currPlot->axisRect()->rangeZoom() & Qt::Vertical)
            menu->addAction("Disable zoom on axis", this, SLOT(toggleVerticalZoom()));
        else
            menu->addAction("Enable zoom on axis", this, SLOT(toggleVerticalZoom()));

        // enable / diable drag
        if (currPlot->axisRect()->rangeDrag() & Qt::Vertical)
            menu->addAction("Disable drag on axis", this, SLOT(toggleVerticalDrag()));
        else
            menu->addAction("Enable drag on axis", this, SLOT(toggleVerticalDrag()));

    } else
    {
        if (currPlot->graphCount() > 0)
          menu->addAction("Scale axes to fit", this, SLOT(rescaleAxes()));
        if (currPlot->selectedGraphs().size() > 0)
          menu->addAction("Remove selected graph", this, SLOT(removeSelectedGraph()));
        if (currPlot->graphCount() > 0)
          menu->addAction("Remove all graphs", this, SLOT(removeAllGraphs()));
    }

    menu->popup(currPlot->mapToGlobal(pos));
    }
Пример #2
0
void FlowViewWindow::updatedFrames(int numFrames)
{
    CANFrame thisFrame;
    if (numFrames == -1) //all frames deleted. Kill the display
    {
        ui->listFrameID->clear();
        foundID.clear();
        currentPosition = 0;
        refreshIDList();
        updateFrameLabel();
        removeAllGraphs();
        memset(refBytes, 0, 8);
        memset(currBytes, 0, 8);
        updateDataView();
    }
    else if (numFrames == -2) //all new set of frames. Reset
    {
        ui->listFrameID->clear();
        foundID.clear();
        currentPosition = 0;
        refreshIDList();
        if (ui->listFrameID->count() > 0)
        {
            changeID(ui->listFrameID->item(0)->text());
            ui->listFrameID->setCurrentRow(0);
        }
        updateFrameLabel();
    }
    else //just got some new frames. See if they are relevant.
    {
        int refID = frameCache[0].ID;
        bool needRefresh = false;
        for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
        {
            thisFrame = modelFrames->at(i);
            if (thisFrame.ID == refID)
            {
                frameCache.append(thisFrame);
                if (ui->cbLiveMode->checkState() == Qt::Checked)
                {
                    currentPosition = frameCache.count() - 1;
                    needRefresh = true;
                }
            }
        }
        if (needRefresh)
        {
            updateDataView();
            if (ui->cbSync->checkState() == Qt::Checked) emit sendCenterTimeID(frameCache[currentPosition].ID, frameCache[currentPosition].timestamp / 1000000.0);
        }
    }
}
Пример #3
0
void LogsDialog::plotLogs()
{
  if (plotLock) return;

  if (!ui->FieldsTW->selectedItems().length()) {
    removeAllGraphs();
    return;
  }

  plotsCollection plots;

  QModelIndexList selection = ui->logTable->selectionModel()->selectedRows();
  int rowCount = selection.length();
  bool hasLogSelection;
  QVarLengthArray<int> selectedRows;

  if (rowCount) {
    hasLogSelection = true;
    foreach (QModelIndex index, selection) {
      selectedRows.append(index.row());
    }
    qSort(selectedRows.begin(), selectedRows.end());
  } else {
Пример #4
0
void FlowViewWindow::changeID(QString newID)
{
    //parse the ID and then load up the frame cache with just messages with that ID.
    int id = Utility::ParseStringToNum(newID);
    frameCache.clear();

    if (modelFrames->count() == 0) return;

    playbackTimer->stop();
    playbackActive = false;
    for (int x = 0; x < modelFrames->count(); x++)
    {
        CANFrame thisFrame = modelFrames->at(x);
        if (thisFrame.ID == id)
        {
            for (int j = thisFrame.len; j < 8; j++) thisFrame.data[j] = 0;
            frameCache.append(thisFrame);
        }
    }
    currentPosition = 0;

    if (frameCache.count() == 0) return;

    removeAllGraphs();
    for (int c = 0; c < frameCache.at(0).len; c++)
    {
        createGraph(c);
    }

    updateGraphLocation();

    memcpy(currBytes, frameCache.at(currentPosition).data, 8);
    memcpy(refBytes, currBytes, 8);

    updateDataView();
}
Пример #5
0
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: SendTotalSamples((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 1: on_butAppBck_clicked(); break;
        case 2: on_butRefresh_clicked(); break;
        case 3: on_butStop_clicked(); break;
        case 4: on_butStart_clicked(); break;
        case 5: on_butZoomIn_clicked(); break;
        case 6: on_butZoomOut_clicked(); break;
        case 7: on_butExit_clicked(); break;
        case 8: on_butRemoveAll_clicked(); break;
        case 9: on_butRemoveSelected_clicked(); break;
        case 10: on_butSine_clicked(); break;
        case 11: on_butSquare_clicked(); break;
        case 12: on_butTriangle_clicked(); break;
        case 13: on_butSawtooth_clicked(); break;
        case 14: on_butPulse_clicked(); break;
        case 15: on_butRandom_clicked(); break;
        case 16: on_butMergeAll_clicked(); break;
        case 17: on_actionZoom_Out_triggered(); break;
        case 18: on_actionZoomin_triggered(); break;
        case 19: on_actionRemove_Selected_triggered(); break;
        case 20: on_actionRemove_All_triggered(); break;
        case 21: on_actionRandom_triggered(); break;
        case 22: on_actionMerge_All_triggered(); break;
        case 23: on_actionPulse_triggered(); break;
        case 24: on_actionSAwtooth_triggered(); break;
        case 25: on_actionTriangle_triggered(); break;
        case 26: on_actionSquare_triggered(); break;
        case 27: on_actionSine_triggered(); break;
        case 28: titleDoubleClick((*reinterpret_cast< QMouseEvent*(*)>(_a[1])),(*reinterpret_cast< QCPPlotTitle*(*)>(_a[2]))); break;
        case 29: axisLabelDoubleClick((*reinterpret_cast< QCPAxis*(*)>(_a[1])),(*reinterpret_cast< QCPAxis::SelectablePart(*)>(_a[2]))); break;
        case 30: legendDoubleClick((*reinterpret_cast< QCPLegend*(*)>(_a[1])),(*reinterpret_cast< QCPAbstractLegendItem*(*)>(_a[2]))); break;
        case 31: selectionChanged(); break;
        case 32: mousePress(); break;
        case 33: mouseWheel(); break;
        case 34: addRandomGraph(); break;
        case 35: addSineGraph(); break;
        case 36: addSquareGraph(); break;
        case 37: addTriangleGraph(); break;
        case 38: addSawtoothGraph(); break;
        case 39: addPulseGraph(); break;
        case 40: removeSelectedGraph(); break;
        case 41: removeAllGraphs(); break;
        case 42: contextMenuRequest((*reinterpret_cast< QPoint(*)>(_a[1]))); break;
        case 43: moveLegend(); break;
        case 44: graphClicked((*reinterpret_cast< QCPAbstractPlottable*(*)>(_a[1]))); break;
        case 45: receiveValue((*reinterpret_cast< double(*)>(_a[1]))); break;
        case 46: receiveValue((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 47: receiveValue((*reinterpret_cast< uint(*)>(_a[1]))); break;
        case 48: callLineEditInput((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 49: openWaveDataWindow(); break;
        case 50: RxSamples((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 51: RxStartTick((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 52: RxStopTick((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 53: RxDutyCycle((*reinterpret_cast< int(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 54;
    }
    return _id;
}