SensorLogger::SensorLogger( QWidget *parent, const QString& title, SharedSettings *workSheetSettings )
  : KSGRD::SensorDisplay( parent, title, workSheetSettings )
{
  mModel = new LogSensorModel( this );
  mModel->setForegroundColor( KSGRD::Style->firstForegroundColor() );
  mModel->setBackgroundColor( KSGRD::Style->backgroundColor() );
  mModel->setAlarmColor( KSGRD::Style->alarmColor() );
  
  QLayout *layout = new QHBoxLayout(this);
  mView = new LogSensorView( this );
  layout->addWidget(mView);
  setLayout(layout);

  mView->header()->setStretchLastSection( true );
  mView->setRootIsDecorated( false );
  mView->setItemsExpandable( false );
  mView->setModel( mModel );
  setPlotterWidget( mView );

  connect( mView, SIGNAL(contextMenuRequest(QModelIndex,QPoint)),
           this, SLOT(contextMenuRequest(QModelIndex,QPoint)) );

  QPalette palette = mView->palette();
  palette.setColor( QPalette::Base, KSGRD::Style->backgroundColor() );
  mView->setPalette( palette );

  setTitle( i18n( "Sensor Logger" ) );
  setMinimumSize( 50, 25 );
}
void viewGVpropertieslayout::setupPlot(QCustomPlot * plot) {

    // configure the plot for use

    // range
    plot->setInteraction(QCP::iRangeDrag, true);
    plot->setInteraction(QCP::iRangeZoom, true);

    // default to x-axis drag / zoom only
    plot->axisRect()->setRangeDrag(Qt::Horizontal);
    plot->axisRect()->setRangeZoom(Qt::Horizontal);

    // selections allowed
    plot->setInteraction(QCP::iSelectPlottables, true);
    plot->setInteraction(QCP::iSelectAxes, true);
    plot->setInteraction(QCP::iSelectLegend, true);

    // context menus for deleting graphs / reseting axes etc
    plot->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(plot, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequest(QPoint)));

    // make bottom and left axes transfer their ranges to top and right axes:
    connect(plot->xAxis, SIGNAL(rangeChanged(QCPRange)), plot->xAxis2, SLOT(setRange(QCPRange)));
    connect(plot->yAxis, SIGNAL(rangeChanged(QCPRange)), plot->yAxis2, SLOT(setRange(QCPRange)));


}
DrawInteraction::DrawInteraction(QWidget *parent) :
    QCustomPlot(parent)
{
    resize(600,400);

    statusBar = new QStatusBar(this);

    srand(QDateTime::currentDateTime().toTime_t());

    setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes |
                                      QCP::iSelectLegend | QCP::iSelectPlottables);
    xAxis->setRange(-8, 8);
    yAxis->setRange(-5, 5);
    axisRect()->setupFullAxesBox();

    plotLayout()->insertRow(0);
    plotLayout()->addElement(0, 0, new QCPPlotTitle(this, "Interaction Example"));

    xAxis->setLabel("x Axis");
    yAxis->setLabel("y Axis");
    legend->setVisible(true);
    QFont legendFont = font();
    legendFont.setPointSize(10);
    legend->setFont(legendFont);
    legend->setSelectedFont(legendFont);
    legend->setSelectableParts(QCPLegend::spItems); // legend box shall not be selectable, only legend items

    addRandomGraph();
    addRandomGraph();
    addRandomGraph();
    addRandomGraph();

    // connect slot that ties some axis selections together (especially opposite axes):
    connect(this, SIGNAL(selectionChangedByUser()), this, SLOT(selectionChanged()));
    // connect slots that takes care that when an axis is selected, only that direction can be dragged and zoomed:
    connect(this, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(mousePress()));
    connect(this, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheel()));

    // make bottom and left axes transfer their ranges to top and right axes:
    connect(xAxis, SIGNAL(rangeChanged(QCPRange)), xAxis2, SLOT(setRange(QCPRange)));
    connect(yAxis, SIGNAL(rangeChanged(QCPRange)), yAxis2, SLOT(setRange(QCPRange)));

    // connect some interaction slots:
    connect(this, SIGNAL(titleDoubleClick(QMouseEvent*,QCPPlotTitle*)), this, SLOT(titleDoubleClick(QMouseEvent*,QCPPlotTitle*)));
    connect(this, SIGNAL(axisDoubleClick(QCPAxis*,QCPAxis::SelectablePart,QMouseEvent*)), this, SLOT(axisLabelDoubleClick(QCPAxis*,QCPAxis::SelectablePart)));
    connect(this, SIGNAL(legendDoubleClick(QCPLegend*,QCPAbstractLegendItem*,QMouseEvent*)), this, SLOT(legendDoubleClick(QCPLegend*,QCPAbstractLegendItem*)));

    // connect slot that shows a message in the status bar when a graph is clicked:
    connect(this, SIGNAL(plottableClick(QCPAbstractPlottable*,QMouseEvent*)), this, SLOT(graphClicked(QCPAbstractPlottable*)));

    // setup policy and connect slot for context menu popup:
    setContextMenuPolicy(Qt::CustomContextMenu);
    connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequest(QPoint)));
}
void GLWidget::mouseReleaseEvent( QMouseEvent* event )
{
    switch( event->button() )
    {
        case Qt::LeftButton:
            emit translateClockwise( !translate_cw );
            emit translateClockwiseMoon( !translate_cw_moon );
            break;
        case Qt::RightButton:
            emit contextMenuRequest( event->pos() );
            break;
        default:
            break;
    }
}
Exemple #5
0
void smart_plot::initGraph(QCustomPlot *customPlot)
{
    //Adds axes on the top and right
    customPlot->axisRect()->setupFullAxesBox();

    //Add title
    customPlot->plotLayout()->insertRow(0);
    QCPTextElement *title = new QCPTextElement(customPlot, tr("Open Files to Plot Data"), QFont("sans", 17, QFont::Bold));
    customPlot->plotLayout()->addElement(0, 0, title);

    //Add axes labels
    customPlot->xAxis->setLabel(tr("X Axis"));
    customPlot->yAxis->setLabel(tr("Y Axis"));

    customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes |
                                    QCP::iSelectLegend | QCP::iSelectPlottables | QCP::iSelectItems | QCP::iMultiSelect);

    connect(customPlot, SIGNAL(selectionChangedByUser()),
            this, SLOT(selectionChanged()));

    connect(customPlot->xAxis,SIGNAL(rangeChanged(QCPRange)),
            this, SLOT(rangeChanged(QCPRange)));

    connect(customPlot, SIGNAL(mousePress(QMouseEvent*)),
            this, SLOT(mousePress(QMouseEvent*)));

    connect(title, SIGNAL(doubleClicked(QMouseEvent*)), this, SLOT(titleDoubleClick(QMouseEvent*)));

    connect(customPlot, SIGNAL(axisDoubleClick(QCPAxis*,QCPAxis::SelectablePart,QMouseEvent*)),
            this, SLOT(axisDoubleClick(QCPAxis*,QCPAxis::SelectablePart)));

    connect(customPlot, SIGNAL(legendDoubleClick(QCPLegend*,QCPAbstractLegendItem*,QMouseEvent*)),
            this, SLOT(legendDoubleClick(QCPLegend*,QCPAbstractLegendItem*)));

    // setup policy and connect slot for context menu popup:
    customPlot->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(customPlot, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequest(QPoint)));

    // make bottom x axis transfer its ranges to top x axis which is used for showing events
    connect(customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), customPlot->xAxis2, SLOT(setRange(QCPRange)));

    axisHandler.setAxisType(customPlot->xAxis, axis_handler::fixed);
    //Short Cuts!
    //Rescale to first selected plot
    //new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_R), this, SLOT(close()));
    //Rescale to first selected plot
    //new QShortcut(Qt::Key_Delete, this, SLOT(selected_remove()));
}
Exemple #6
0
void tab::createConnects()
{
    connect(urlAddress, SIGNAL(returnPressed()), this, SLOT(newUrl()));
    connect(addressCompleter, SIGNAL(itemChoosed(QString)), this, SLOT(newUrl(QString)));
    connect(webView, SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanged(QUrl)));
    connect(webView, SIGNAL(titleChanged(QString)), this, SLOT(chTitle(QString)));
    connect(webView, SIGNAL(iconChanged()), this, SLOT(chIcon()));
    connect(webView, SIGNAL(statusBarMessage(QString)), this, SLOT(statusBarMessage(QString)));
    connect(webView, SIGNAL(selectionChanged()), this, SLOT(selectionChange()));
    connect(webView, SIGNAL(loadStarted()), this, SLOT(loadStart()));
    connect(webView, SIGNAL(loadProgress(int)), this, SLOT(loadProgress(int)));
    connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(loadFinish(bool)));
    connect(webView, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClick(QUrl)));
    connect(webView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequest(QPoint)));
    connect(webView->page(), SIGNAL(unsupportedContent(QNetworkReply*)), this, SLOT(downloadRequest(QNetworkReply*)));
    connect(webView->page(), SIGNAL(downloadRequested(QNetworkRequest)), this, SLOT(downloadRequset(QNetworkRequest)));
    connect(webView->page(), SIGNAL(printRequested(QWebFrame*)), this, SLOT(printPage(QWebFrame*)));
}
void CustomPlotRegression::mousePressEvent( QMouseEvent* event )
{
    //qDebug() << Q_FUNC_INFO;
    if(event->button() == Qt::RightButton)
    {
        contextMenuRequest(event->pos());
        //        QRect rec = QApplication::desktop()->screenGeometry();
        //        int height = rec.height();
        //        int width = rec.width();
        //        //TODO controllare geometrie
        //        std::cout << height << std::endl;
        //        std::cout << width << std::endl;
        //        std::cout << event->pos().rx() << std::endl;
        //        std::cout << event->pos().ry() << std::endl;
        //        std::cout << event->pos().x() << std::endl;
        //        std::cout << event->pos().y() << std::endl;
        //std::cout << event->pos() << std::endl;
    }else
        routeMouseEvents( event );
}
Exemple #8
0
void MainWindow::setupRadioTree() {

    qDebug()<<"Initializing radiolist";

    model = new TreeModel();
    radioTree->setModel(model);

    proxyModel = new TreeSortFilterProxyModel;
    proxyModel->setSourceModel(model);
    proxyView = new QTreeView;
    proxyView->setRootIsDecorated(false);
    proxyView->setAlternatingRowColors(true);
    proxyView->setModel(proxyModel);
    proxyView->setSortingEnabled(true);
    proxyModel->sort(0, Qt::AscendingOrder);
    connect(filterPatternLineEdit, SIGNAL(textChanged(QString)),
            this, SLOT(filterRegExpChanged()));

    //radioTree->setModel(proxyModel);
    radioTree->SetProxyModel(proxyModel);

    for (int column = 0; column < model->columnCount(); ++column)
        radioTree->resizeColumnToContents(column);

    radioTree->setContextMenuPolicy(Qt::CustomContextMenu);

    connect(radioTree->selectionModel(),
            SIGNAL(selectionChanged(const QItemSelection &,
                                    const QItemSelection &)),
            this, SLOT(updateActions()));
    connect(radioTree,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(radioDoubleClicked(QModelIndex)));
    connect(radioTree,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(contextMenuRequest(QPoint)));

    connect(insertRowAction, SIGNAL(triggered()), this, SLOT(insertStation()));
    connect(removeRowAction, SIGNAL(triggered()), this, SLOT(removeRow()));
    connect(insertChildAction, SIGNAL(triggered()), this, SLOT(insertSubfolder()));
    connect(editRadioAction,SIGNAL(triggered()),this,SLOT(editRadio()));

    updateActions();
}
Exemple #9
0
/**
 * Construct a line chart widget of a given parent, active measure, low and high range
 * @param parent chosen parent
 * @param meas  active measure
 * @param range low/high range of the data
 */
widgetBarChart::widgetBarChart(QWidget *parent, const Measure &meas, const std::pair<double, double> &range):QWidget(parent),ui(new Ui::widgetBarChart),_meas(new Measure(meas))
{
    ui->setupUi(this);
    _range =range;
    this->setStyleSheet(
                "QPushButton#pushButtonSaveBarData {"
                "background-color: rgb(125,125,175);"
                "border-style: outset;"
                "border-width: 2px;"
                "border-color: rgb(50,50,75);"
                "font: bold 22px;"
                "border-radius: 5px;"
                "min-width: 7em;}"

                "QPushButton#pushButtonSaveBarData:hover:pressed {"
                "background-color: rgb(100,100,145);"
                "border-style:inset;}"

                "QPushButton#pushButtonSaveBarData:hover {"
                "background-color: rgb(130,130,180);}"

                "QPushButton#pushButtonRefresh {"
                "background-color: rgb(125,125,175);"
                "border-style: outset;"
                "border-width: 2px;"
                "border-color: rgb(50,50,75);"
                "font: bold 22px;"
                "border-radius: 5px;"
                "min-width: 7em;}"

                "QPushButton#pushButtonRefresh:hover:pressed {"
                "background-color: rgb(100,100,145);"
                "border-style:inset;}"

                "QPushButton#pushButtonRefresh:hover {"
                "background-color: rgb(130,130,180); }"
                );
    ui->listBarChartMunicipality->setSelectionMode(QAbstractItemView::MultiSelection);
    ui->listBarChartYears->setSelectionMode(QAbstractItemView::MultiSelection);
    //List Stuff
    ui->listBarChartMunicipality->addItems(_meas->stringMuniList());
    ui->listBarChartYears->addItems(_meas->yearRange());

    //Add title to bar chart
    ui->widgetBarChart_2->plotLayout()->insertRow(0);
    QString title = meas.name() + " Over the Years";
    ui->widgetBarChart_2->plotLayout()->addElement(0, 0, new QCPPlotTitle(ui->widgetBarChart_2, title));
    ui->widgetBarChart_2->yAxis->setLabel(_meas->name());


    //*********************set interractions*************************
    srand(QDateTime::currentDateTime().toTime_t());
      ui->widgetBarChart_2->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes |
                                      QCP::iSelectLegend | QCP::iSelectPlottables);

      ui->widgetBarChart_2->axisRect()->setupFullAxesBox();
      ui->widgetBarChart_2->legend->setSelectableParts(QCPLegend::spItems); // legend box shall not be selectable, only legend items

      // connect slot that ties some axis selections together (especially opposite axes):
      connect(ui->widgetBarChart_2, SIGNAL(selectionChangedByUser()), this, SLOT(selectionChanged()));
      // connect slots that takes care that when an axis is selected, only that direction can be dragged and zoomed:
      connect(ui->widgetBarChart_2, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(mousePress()));
      connect(ui->widgetBarChart_2, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheel()));

      // make bottom and left axes transfer their ranges to top and right axes:
      connect(ui->widgetBarChart_2->xAxis, SIGNAL(rangeChanged(QCPRange)), ui->widgetBarChart_2->xAxis2, SLOT(setRange(QCPRange)));
      connect(ui->widgetBarChart_2->yAxis, SIGNAL(rangeChanged(QCPRange)), ui->widgetBarChart_2->yAxis2, SLOT(setRange(QCPRange)));

      // connect some interaction slots:
      connect(ui->widgetBarChart_2, SIGNAL(titleDoubleClick(QMouseEvent*,QCPPlotTitle*)), this, SLOT(titleDoubleClick(QMouseEvent*,QCPPlotTitle*)));
      connect(ui->widgetBarChart_2, SIGNAL(axisDoubleClick(QCPAxis*,QCPAxis::SelectablePart,QMouseEvent*)), this, SLOT(axisLabelDoubleClick(QCPAxis*,QCPAxis::SelectablePart)));
      connect(ui->widgetBarChart_2, SIGNAL(legendDoubleClick(QCPLegend*,QCPAbstractLegendItem*,QMouseEvent*)), this, SLOT(legendDoubleClick(QCPLegend*,QCPAbstractLegendItem*)));

      // setup policy and connect slot for context menu popup:
      ui->widgetBarChart_2->setContextMenuPolicy(Qt::CustomContextMenu);
      connect(ui->widgetBarChart_2, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequest(QPoint)));


    drawChart();

}
Exemple #10
0
Graph::Graph(QMainWindow *parent) :
    QMainWindow(parent)
{
    customPlot = new QCustomPlot;
    customPlot->setEnabled(false);

    srand(QDateTime::currentDateTime().toTime_t());

    customPlot->setInteractions(QCustomPlot::iRangeDrag | QCustomPlot::iRangeZoom | QCustomPlot::iSelectAxes |
                                    QCustomPlot::iSelectLegend | QCustomPlot::iSelectPlottables | QCustomPlot::iSelectTitle);
    customPlot->setRangeDrag(Qt::Horizontal|Qt::Vertical);
    customPlot->setRangeZoom(Qt::Horizontal|Qt::Vertical);
    customPlot->xAxis->setRange(0, 1);
    customPlot->yAxis->setRange(0, 1);
    customPlot->yAxis->setRangeReversed(true);
    customPlot->setupFullAxesBox();
    customPlot->xAxis->setLabel("x Axis");
    customPlot->yAxis->setLabel("y Axis");
    customPlot->legend->setVisible(true);
    QFont legendFont = font();
    legendFont.setPointSize(10);
    customPlot->legend->setFont(legendFont);
    customPlot->legend->setSelectedFont(legendFont);
    customPlot->legend->setSelectable(QCPLegend::spItems); // legend box shall not be selectable, only legend items


    // connect slot that ties some axis selections together (especially opposite axes):
    connect(customPlot, SIGNAL(selectionChangedByUser()), this, SLOT(selectionChanged()));
    // connect slots that takes care that when an axis is selected, only that direction can be dragged and zoomed:
    connect(customPlot, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(mousePress()));
    connect(customPlot, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheel()));

    // make bottom and left axes transfer their ranges to top and right axes:
    connect(customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), customPlot->xAxis2, SLOT(setRange(QCPRange)));
    connect(customPlot->yAxis, SIGNAL(rangeChanged(QCPRange)), customPlot->yAxis2, SLOT(setRange(QCPRange)));

    // connect some interaction slots:
    connect(customPlot, SIGNAL(titleDoubleClick(QMouseEvent*)), this, SLOT(titleDoubleClick()));
    connect(customPlot, SIGNAL(axisDoubleClick(QCPAxis*,QCPAxis::SelectablePart,QMouseEvent*)), this, SLOT(axisLabelDoubleClick(QCPAxis*,QCPAxis::SelectablePart)));
    connect(customPlot, SIGNAL(legendDoubleClick(QCPLegend*,QCPAbstractLegendItem*,QMouseEvent*)), this, SLOT(legendDoubleClick(QCPLegend*,QCPAbstractLegendItem*)));

    // connect slot that shows a message in the status bar when a graph is clicked:
    connect(customPlot, SIGNAL(plottableClick(QCPAbstractPlottable*,QMouseEvent*)), this, SLOT(graphClicked(QCPAbstractPlottable*)));

    // setup policy and connect slot for context menu popup:
    customPlot->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(customPlot, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequest(QPoint)));






    // Oppretter databasen med databasedriver QODBC
    db = QSqlDatabase::addDatabase("QODBC");

    // Setter maksverdiene for x og y aksene til -1 for å være sikker på at de blir overskrevet
    xMax = -1;
    yMax = -1;

    // Setter startverdi for fargevelger variabelen
    colorCounter = 0;
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    this->setWindowTitle("HodgkinHuxley Simulator 1.0.8 - Robin Rump");
    this->setMinimumWidth(800);
    this->setMinimumHeight(630);

    // setup windows and config
    this->p = new Preferences(this);
    this->w = new Welcome(this);
    this->config = new Config();

    // setup variables and sliders
    this->timer = new QTimer(this);

    this->blank.resize(1);
    this->dt       = 0.025;  // ms
    this->interval = 10;     // ms
    this->isPaused = false;
    this->isNShown = false;
    this->isMShown = false;
    this->isHShown = false;
    this->cMode    = currentManual;

    this->VRest  = 0;      // mV
    this->Cm     = 1;      // uF/cm2
    this->gMaxNa = 120;    // mS/cm2
    this->gMaxK  = 36;     // mS/cm2
    this->gMaxL  = 0.3;    // mS/cm2
    this->ENa    = 115;    // mS/cm2
    this->EK     = -12;    // mS/cm2
    this->EL     = 10.613; // mS/cm2

    ui->gNaSlider->setValue(this->gMaxNa);
    ui->gNaValue->setText(QString::number(this->gMaxNa));

    ui->gKSlider->setValue(this->gMaxK);
    ui->gKValue->setText(QString::number(this->gMaxK));

    ui->gLSlider->setValue(this->gMaxL*10);
    ui->gLValue->setText(QString::number(this->gMaxL));

    // prepare simulator
    this->init();

    // define the pointers
    this->values.resize(5);
    this->values[0] = &this->V;
    this->values[1] = &this->I;
    this->values[2] = &this->n;
    this->values[3] = &this->m;
    this->values[4] = &this->h;

    // plot config
    ui->plot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);

    ui->plot->plotLayout()->insertRow(0);
    ui->plot->plotLayout()->addElement(0, 0, new QCPPlotTitle(ui->plot, "HodgkinHuxley"));

    // legend
    ui->plot->legend->setVisible(true);
    QFont legendFont = this->font();
    legendFont.setPointSize(10);
    ui->plot->legend->setFont(legendFont);
    ui->plot->legend->setBrush(QBrush(QColor(255,255,255,230)));
    ui->plot->legend->setIconSize(QSize(10, 3));
    ui->plot->legend->setSelectableParts(QCPLegend::spItems);
    ui->plot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignBottom|Qt::AlignRight);

    // graphes
    ui->plot->addGraph(ui->plot->xAxis, ui->plot->yAxis);  // V
    ui->plot->graph(graphMembrane)->setData(this->time, this->V);
    ui->plot->graph(graphMembrane)->setName("Membrane");

    ui->plot->addGraph(ui->plot->xAxis, ui->plot->yAxis);  // I
    ui->plot->graph(graphCurrent)->setPen(QPen(QColor(255, 100, 0)));
    ui->plot->graph(graphCurrent)->setData(this->time, this->I);
    ui->plot->graph(graphCurrent)->setName("Current");

    ui->plot->addGraph(ui->plot->xAxis, ui->plot->yAxis2); // n
    ui->plot->graph(graphN)->setPen(QPen(QColor(255, 0, 0)));
    ui->plot->graph(graphN)->setName("n");
    ui->plot->addGraph(ui->plot->xAxis, ui->plot->yAxis2); // m
    ui->plot->graph(graphM)->setPen(QPen(QColor(0, 255, 0)));
    ui->plot->graph(graphM)->setName("m");
    ui->plot->addGraph(ui->plot->xAxis, ui->plot->yAxis2); // h
    ui->plot->graph(graphH)->setPen(QPen(QColor(60, 10, 80)));
    ui->plot->graph(graphH)->setName("h");

    // axes configuration
    ui->plot->xAxis->setLabel("Time in ms");
    ui->plot->yAxis->setLabel("Membran potential in mV");
    ui->plot->yAxis2->setLabel("Gatting channels");
    ui->plot->yAxis2->setVisible(true);

    // ranges
    ui->plot->xAxis->setRange(0, 100);
    ui->plot->yAxis->setRange(-50, 150);
    ui->plot->yAxis2->setRange(0, 1);
    ui->plot->replot();

    // connect ui elements with slots
    connect(ui->currentSlider, SIGNAL(valueChanged(int)), this, SLOT(updateCurrent()));
    connect(ui->gNaSlider, SIGNAL(valueChanged(int)), this, SLOT(updateGNa()));
    connect(ui->gKSlider, SIGNAL(valueChanged(int)), this, SLOT(updateGK()));
    connect(ui->gLSlider, SIGNAL(valueChanged(int)), this, SLOT(updateGL()));

    connect(ui->checkN, SIGNAL(stateChanged(int)), this, SLOT(showN()));
    connect(ui->checkM, SIGNAL(stateChanged(int)), this, SLOT(showM()));
    connect(ui->checkH, SIGNAL(stateChanged(int)), this, SLOT(showH()));

    QSignalMapper* signalMapper = new QSignalMapper(this);
    connect(ui->impulseButton, SIGNAL(clicked(bool)), signalMapper, SLOT(map())) ;
    signalMapper->setMapping(ui->impulseButton, currentImpulse);
    connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(changeCurrentMode(int)));

    connect(ui->pause, SIGNAL(clicked(bool)), this, SLOT(switchPause()));
    connect(ui->reset, SIGNAL(clicked(bool)), this, SLOT(reset()));
    connect(ui->clear, SIGNAL(clicked(bool)), this, SLOT(clear()));

    connect(ui->actionSettings, SIGNAL(triggered(bool)), this, SLOT(showPreferences()));
    connect(ui->actionAbout, SIGNAL(triggered(bool)), this, SLOT(about()));
    connect(ui->actionJson, SIGNAL(triggered(bool)), this, SLOT(toJson()));
    connect(ui->actionXml, SIGNAL(triggered(bool)), this, SLOT(toXml()));
    connect(ui->actionPng, SIGNAL(triggered(bool)), this, SLOT(toPng()));
    connect(ui->actionJpg, SIGNAL(triggered(bool)), this, SLOT(toJpg()));
    connect(ui->actionPdf, SIGNAL(triggered(bool)), this, SLOT(toPdf()));
    connect(ui->actionWelcome, SIGNAL(triggered(bool)), this, SLOT(welcome()));
    connect(ui->actionReset, SIGNAL(triggered(bool)), this, SLOT(reset()));
    connect(ui->actionClear, SIGNAL(triggered(bool)), this, SLOT(clear()));

    // set right click
    ui->plot->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(ui->plot, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequest(QPoint)));

    // connect timer
    connect(this->timer, SIGNAL(timeout()), this, SLOT(updatePlot()));

    if (this->config->startup() == true) {
        this->welcome();
    }

    // start timer
    this->timer->start(this->interval);
}
Exemple #12
0
void TableItem::createContextMenu(QWidget *widget)
{
    setContextMenuPolicy(Qt::CustomContextMenu);
    contextMenu = new QMenu(widget);
    QList<QAction *> menuActions;

    /* Reload item: */
    refreshAction = new QAction(tr("Refresh"), this);
    refreshAction->setIcon(QIcon(":/images/reload"));
    connect(refreshAction,SIGNAL(triggered()),this,SLOT(onRefreshTriggered()));
    menuActions << refreshAction;

    /* Hide item: */
    hideUnhideAction = new QAction(tr("Hide"), this);
    hideUnhideAction->setIcon(QIcon(":/images/hide"));
    hideUnhideAction->setShortcut(getHideShorcut());
    connect(hideUnhideAction,SIGNAL(triggered()),this,SLOT(onHideTriggered()));
    menuActions << hideUnhideAction;

    /* Lock item: */
    lockUnlockAction = new QAction(tr("Lock"), this);
    lockUnlockAction->setIcon(QIcon(":/images/lock"));
    lockUnlockAction->setShortcut(getLockShorcut());
    connect(lockUnlockAction,SIGNAL(triggered()),this,SLOT(onLockTriggered()));
    menuActions << lockUnlockAction;

    /* Rotate item: */
    rotateAction = new QAction(tr("Rotate"), this);
    rotateAction->setIcon(QIcon(":/images/rotateRight"));
    connect(rotateAction,SIGNAL(triggered()),this,SLOT(onRotateTriggered()));
    menuActions << rotateAction;

    /* Become owner: */
    setOwnerAction = new QAction(tr("Possess"), this);
    setOwnerAction->setIcon(QIcon(":/images/addUser"));
    setOwnerAction->setShortcut(getOwnerShorcut());
    connect(setOwnerAction,SIGNAL(triggered()),this,SLOT(onSetOwnerTriggered()));
    menuActions << setOwnerAction;

    /* Remove ownership: */
    removeOwnerAction = new QAction(tr("Give away"), this);
    removeOwnerAction->setIcon(QIcon(":/images/removeUser"));
    removeOwnerAction->setShortcut(getRemoveOwnerShorcut());
    connect(removeOwnerAction,SIGNAL(triggered()),this,SLOT(onRemoveOwnerTriggered()));
    menuActions << removeOwnerAction;

    /* Shuffle items: */
    shuffleAction = new QAction(tr("Shuffle"), this);
    shuffleAction->setIcon(QIcon(":/images/shuffle"));
    connect(shuffleAction,SIGNAL(triggered()),this,SLOT(onShuffleTriggered()));
    menuActions << shuffleAction;
    shuffleAction->setDisabled(true);

    /* Remove item: */
    removeAction = new QAction(tr("Remove"), this);
    removeAction->setIcon(QIcon(":/images/remove"));
    removeAction->setShortcut(getRemoveShorcut());
    connect(removeAction,SIGNAL(triggered()),this,SLOT(onRemoveTriggered()));
    menuActions << removeAction;

    /* Execute the context menu in the mouse position: */
    contextMenu->addActions(menuActions);

    connect(this,SIGNAL(customContextMenuRequested(QPoint)),
            this,SLOT(contextMenuRequest(QPoint)));

    handleOwnerContextMenu();
}
void LogSensorView::contextMenuEvent( QContextMenuEvent *event )
{
  const QModelIndex index = indexAt( event->pos() );

  emit contextMenuRequest( index, viewport()->mapToGlobal( event->pos() ) );
}
Exemple #14
0
void MainWindow::initializeLineGraphPlot()
{

    QFont font("Helvetica[Adobe]",15);
    lineGraphTitle = new QCPPlotTitle(lineCustomGraph," ");
    lineGraphTitle->setFont(font);
    lineGraphTitle->setTextColor(QColor(255,51,51));

    lineCustomGraph->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes |
                                     QCP::iSelectLegend | QCP::iSelectPlottables);

    lineCustomGraph->axisRect()->setupFullAxesBox();

    lineCustomGraph->plotLayout()->insertRow(0);
    lineCustomGraph->plotLayout()->addElement(0, 0,lineGraphTitle);

    lineCustomGraph->xAxis->setLabel("Time");
    lineCustomGraph->yAxis->setLabel(" ");
    lineCustomGraph->legend->setVisible(false);


    lineCustomGraph->xAxis->setAutoTicks(false);
    lineCustomGraph->xAxis->setAutoTickLabels(false);

    QVector<double> xAxisTicks;
    QVector<QString> xAxisLabels;

    for(int i =0 ; i < 100 ; ++i)
    {
        xAxisTicks <<i;
        xAxisLabels<<QString::number(i);
    }
    lineCustomGraph->xAxis->setTickVector(xAxisTicks);
    lineCustomGraph->xAxis->setTickVectorLabels(xAxisLabels);
    lineCustomGraph->xAxis->setRange(-1,2);

    QVector<double> yAxisTicks;
    QVector<QString> yAxisLabels;

    for(int i =0 ; i <= 100 ;i+=10)
    {
        yAxisTicks <<i;
        yAxisLabels<<QString::number(i);
    }
    lineCustomGraph->yAxis->setAutoTicks(false);
    lineCustomGraph->yAxis->setAutoTickLabels(false);
    lineCustomGraph->yAxis->setTickStep(10.0);
    lineCustomGraph->yAxis->setTickVector(yAxisTicks);
    lineCustomGraph->yAxis->setTickVectorLabels(yAxisLabels);
    lineCustomGraph->yAxis->setRange(0,100);

    lineCustomGraph->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);

    //    QFont legendFont = font();
    //    legendFont.setPointSize(10);
    //    lineCustomGraph->legend->setFont(legendFont);
    //    lineCustomGraph->legend->setSelectedFont(legendFont);
    //    lineCustomGraph->legend->setSelectableParts(QCPLegend::spItems); // legend box shall not be selectable, only legend items

    //    connect(lineCustomGraph, SIGNAL(legendClick(QCPLegend*,QCPAbstractLegendItem*,QMouseEvent*)), this, SLOT(selectionChanged()));
    // connect slot that ties some axis selections together (especially opposite axes):
    //connect(lineCustomGraph, SIGNAL(selectionChangedByUser()), this, SLOT(selectionChanged()));
    // connect slots that takes care that when an axis is selected, only that direction can be dragged and zoomed:
    connect(lineCustomGraph, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(mousePress()));
    connect(lineCustomGraph, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheel()));

    // make bottom and left axes transfer their ranges to top and right axes:
    connect(lineCustomGraph->xAxis, SIGNAL(rangeChanged(QCPRange)), lineCustomGraph->xAxis2, SLOT(setRange(QCPRange)));
    connect(lineCustomGraph->yAxis, SIGNAL(rangeChanged(QCPRange)), lineCustomGraph->yAxis2, SLOT(setRange(QCPRange)));

    //    // connect some interaction slots:
    //    connect(lineCustomGraph, SIGNAL(titleDoubleClick(QMouseEvent*,QCPPlotTitle*)), this, SLOT(titleDoubleClick(QMouseEvent*,QCPPlotTitle*)));
    //    connect(lineCustomGraph, SIGNAL(axisDoubleClick(QCPAxis*,QCPAxis::SelectablePart,QMouseEvent*)), this, SLOT(axisLabelDoubleClick(QCPAxis*,QCPAxis::SelectablePart)));
    //    connect(lineCustomGraph, SIGNAL(legendDoubleClick(QCPLegend*,QCPAbstractLegendItem*,QMouseEvent*)), this, SLOT(legendDoubleClick(QCPLegend*,QCPAbstractLegendItem*)));

    // connect slot that shows a message in the status bar when a graph is clicked:
    connect(lineCustomGraph, SIGNAL(plottableClick(QCPAbstractPlottable*,QMouseEvent*)), this, SLOT(graphClicked(QCPAbstractPlottable*)));

    // setup policy and connect slot for context menu popup:
    lineCustomGraph->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(lineCustomGraph, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequest(QPoint)));
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    settings(QStandardPaths::writableLocation(QStandardPaths::DataLocation)
             + QDir::separator() + "settings.ini", QSettings::IniFormat),
    first(true),
    started(true)
{
    srand(QDateTime::currentDateTime().toTime_t());
    ui->setupUi(this);

    ui->customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes |
                                    QCP::iSelectLegend | QCP::iSelectPlottables);

    // Axes
    ui->customPlot->xAxis->setTickLabelType(QCPAxis::ltDateTime);
    ui->customPlot->xAxis->setDateTimeFormat("hh:mm:ss");
    ui->customPlot->xAxis->setAutoTickStep(false);
    ui->customPlot->xAxis->setTickStep(2);
    ui->customPlot->xAxis->setLabel("Time");
    ui->customPlot->xAxis->setLabelPadding(0);
    ui->customPlot->xAxis->setSelectableParts(QCPAxis::spAxis);

    ui->customPlot->yAxis->setRange(-20, 20);
    ui->customPlot->yAxis->setLabel("Acceleration (m/s^2)");
    ui->customPlot->yAxis->setLabelPadding(0);
    ui->customPlot->yAxis->setSelectableParts(QCPAxis::spAxis);

    ui->customPlot->axisRect()->setupFullAxesBox();

    // Legend
    ui->customPlot->legend->setVisible(true);
    QFont legendFont = font();
    legendFont.setPointSize(10);
    ui->customPlot->legend->setFont(legendFont);
    ui->customPlot->legend->setSelectedFont(legendFont);
    ui->customPlot->legend->setSelectableParts(QCPLegend::spNone);

    // X, Y, Z reading graphs
    ui->customPlot->addGraph(); // blue line
    ui->customPlot->graph(0)->setPen(QPen(Qt::blue));
    ui->customPlot->graph(0)->setName("X");
    ui->customPlot->graph(0)->setSelectable(false);
    ui->customPlot->addGraph(); // red line
    ui->customPlot->graph(1)->setPen(QPen(Qt::red));
    ui->customPlot->graph(1)->setName("Y");
    ui->customPlot->graph(1)->setSelectable(false);
    ui->customPlot->addGraph(); // green line
    ui->customPlot->graph(2)->setPen(QPen(Qt::green));
    ui->customPlot->graph(2)->setName("Z");
    ui->customPlot->graph(2)->setSelectable(false);

    // Scale in a particular direction when an axis is selected
    connect(ui->customPlot, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(mousePress()));
    connect(ui->customPlot, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheel()));

    // Make bottom and left axes transfer their ranges to top and right axes:
    connect(ui->customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), ui->customPlot->xAxis2, SLOT(setRange(QCPRange)));
    connect(ui->customPlot->yAxis, SIGNAL(rangeChanged(QCPRange)), ui->customPlot->yAxis2, SLOT(setRange(QCPRange)));

    // Adjust the tick marks on x-axis scale
    connect(ui->customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(xAxisChanged(QCPRange)));

    // Context menu popup
    ui->customPlot->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(ui->customPlot, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequest(QPoint)));

    // Buttons
    connect(ui->buttonStartStop, SIGNAL(released()), this, SLOT(pressedStartStop()));
    connect(ui->buttonAnalyze, SIGNAL(released()), this, SLOT(pressedAnalyze()));
    connect(ui->buttonSave, SIGNAL(released()), this, SLOT(pressedSave()));

    // Setup accelerometer
    accelerometer = new QAccelerometer(this);
    accelerometer->setAccelerationMode(QAccelerometer::Combined);
    accelerometer->setDataRate(30);
    accelerometer->addFilter(&filter);

    // We'll always keep it running since on the phone apparently calling
    // stop makes the whole application freeze. Thus, we'll just start/stop
    // recording data not actually requesting data from the accelerometer
    accelerometer->start();

    // Button enabled/disabled coloring
    button_enabled = ui->buttonStartStop->palette();
    button_disabled = ui->buttonStartStop->palette();
    button_enabled.setColor(QPalette::Button, QColor(Qt::white));
    button_disabled.setColor(QPalette::Button, QColor(Qt::lightGray));

    // Load previous settings
    bool timed = settings.value("timed").toBool();
    ui->checkBoxTimed->setChecked(timed);

    // When we start the application, either start it automatically if we're
    // not using a fixed period of time or set it up so we can press Start to
    // start it if we are using a fixed period of time
    if (timed)
        stop();
    else
        start();

    // Setup a timer that repeatedly calls MainWindow::realtimeDataSlot
    connect(&dataTimer, SIGNAL(timeout()), this, SLOT(realtimeDataSlot()));

    // Stop it after a certain period of time
    connect(&finishTimer, SIGNAL(timeout()), this, SLOT(finishSlot()));

    // Start with delay to reduce effect of touching the "Start"
    // button when recording for set amount of time
    connect(&startTimer, SIGNAL(timeout()), this, SLOT(startSlot()));
}
Exemple #16
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;
}
Exemple #17
0
void OverviewView::contextMenuEvent(QContextMenuEvent* e) {
    emit contextMenuRequest(e->pos());
}
Exemple #18
0
OverviewWidget::OverviewWidget(QWidget* parent, NetworkEvaluator* networkEval)
    : QWidget(parent)
    , duration_(1200)
    , zoom_(1)
    , viewportWidth_(500)
    , scrollBarPosition_(0)
    , canvasRenderer_(0)
    , networkEvaluator_(networkEval)
    , currentFrame_(0)
    , fps_(30)
    , autoPreview_(false)
{
    canvasRenderer_ = 0;
    previews_.clear();
    QHBoxLayout* mainLayout = new QHBoxLayout(this);

    mainLayout->setMargin(1);
    mainLayout->setSpacing(1);
    setFixedHeight(110);

    overviewScene_ = new QGraphicsScene(this);

    overviewView_ = new OverviewView(overviewScene_, this);

    highlightBar_ = new QGraphicsRectItem();
    overviewView_->setBar(highlightBar_);
    highlightBar_->setZValue(2);
    highlightBar_->setPen(QPen(Qt::DotLine));
    QLinearGradient gradient1(0,0,0, 40 );
    gradient1.setSpread(QGradient::ReflectSpread);
    gradient1.setColorAt(0.0, QColor(20, 100 ,100, 30));
    gradient1.setColorAt(1.0, QColor(80, 100 ,100, 30));
    QBrush brush(gradient1);
    highlightBar_->setBrush(gradient1);
    overviewScene_->addItem(highlightBar_);
    highlight_ = new QGraphicsRectItem();
    highlight_->setPen(QPen(Qt::DotLine));
    QLinearGradient gradient(0,0,0, 40 );
    gradient.setSpread(QGradient::ReflectSpread);
    gradient.setColorAt(0.0, QColor(120, 100 ,100, 30));
    gradient.setColorAt(1.0, QColor(100, 100 ,100, 30));
    highlight_->setBrush(gradient);
    overviewScene_->addItem(highlight_);

    overviewView_->setStyleSheet("background:transparent");
    connect(overviewView_, SIGNAL(currentFrameChanged(int)), this, SIGNAL(currentFrameChanged(int)));
    connect(overviewView_, SIGNAL(contextMenuRequest(QPoint)), this, SLOT(contextMenuRequest(QPoint)));
    connect(overviewView_, SIGNAL(barMovement(int)), this, SIGNAL(barMovement(int)));
    connect(this, SIGNAL(offsetCorrection(int)), overviewView_, SLOT(offsetCorrection(int)));

    overviewView_->setGeometry(QRect(0, 0, duration_, 50));
    overviewView_->setSceneRect(QRect(0, 0, duration_, 50));
    overviewView_->setCurrentFrame(0);

    mainLayout->addWidget(overviewView_);
    QLabel* nameLabel = new QLabel(this);
    nameLabel->lower();
    nameLabel->move(8, 45);
    nameLabel->setText(QString::fromStdString("Overview"));

    if (canvasRenderer_) {
        const std::vector<Port*> port = canvasRenderer_->getInports();
        if (port.size() == 1) {
            if(dynamic_cast<RenderPort*>(port.at(0)) != 0)
                renderPort_ = dynamic_cast<RenderPort*>(port.at(0));
        }
    }
    setStandardRenderport();
}