void viewGVpropertieslayout::removeSelectedGraph()
{
    // first get a pointer to the current plot!
    QCustomPlot * currPlot = (QCustomPlot *) currentSubWindow->widget();
    if (currPlot->selectedGraphs().size() > 0)
    {
    currPlot->removeGraph(currPlot->selectedGraphs().first());
    currPlot->replot();
  }
}
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));
    }