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));
    }
Exemplo n.º 2
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;
}