/*protected*/ QWidget* ReporterItemPanel::instructions() { QWidget* blurb = new QWidget(); QVBoxLayout* layout; blurb->setLayout(layout = new QVBoxLayout(blurb/*, BoxLayout.Y_AXIS*/)); //blurb.add(Box.createVerticalStrut(ItemPalette.STRUT_SIZE)); layout->addStrut(ItemPalette::STRUT_SIZE); blurb->layout()->addWidget(new JLabel(tr("To Add an Icon to your control panel:"))); blurb->layout()->addWidget(new JLabel(tr("--drag an icon from the display panel below to your control panel"))); //blurb.add(Box.createVerticalStrut(ItemPalette.STRUT_SIZE)); layout->addStrut(ItemPalette::STRUT_SIZE); QWidget* panel = new QWidget(); panel->setLayout(new FlowLayout); panel->layout()->addWidget(blurb); return panel; }
FilterWrapper::FilterWrapper(IFilter *filter, QWidget *parent) : QWidget(parent), m_filter(filter), m_button(0), m_controlButtons(0), m_applyButton(0) { QVBoxLayout *layout = new QVBoxLayout; layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); setLayout(layout); m_controlButtons = new QWidget(this); QHBoxLayout *cbLayout = new QHBoxLayout(); cbLayout->setContentsMargins(0, 0, 0, 0); cbLayout->setSpacing(0); m_controlButtons->setLayout(cbLayout); layout->addWidget(m_controlButtons); // Main button m_button = new QToolButton(this); m_button->setText(m_filter->filterName()); m_button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); m_button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); cbLayout->addWidget(m_button); if (m_filter->hasSettings()) { // Main button: toggle settings m_button->setArrowType(Qt::RightArrow); m_button->setCheckable(true); connect(m_button, SIGNAL(toggled(bool)), SLOT(buttonToggled(bool))); // Apply button needed m_applyButton = new QToolButton(this); m_applyButton->setText(tr("Apply")); QFont fnt = m_applyButton->font(); fnt.setBold(true); m_applyButton->setFont(fnt); m_applyButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); cbLayout->addWidget(m_applyButton); connect(m_applyButton, SIGNAL(clicked()), SIGNAL(apply())); m_applyButton->hide(); // Insert settings widget m_filter->settingsWidget()->setParent(this); layout->addWidget(m_filter->settingsWidget()); layout->addStrut(m_filter->settingsWidget()->minimumSizeHint().width()); // Fix size hopping m_filter->settingsWidget()->hide(); } else // Main button: apply filter connect(m_button, SIGNAL(clicked()), SIGNAL(apply())); }
/*protected*/ QWidget* IconItemPanel::instructions() { //QWidget* blurb = new QWidget(); QVBoxLayout* blurbLayout = new QVBoxLayout; //blurb->setLayout(blurbLayout = new QVBoxLayout(blurb/*, BoxLayout.Y_AXIS*/)); //blurb.add(Box.createVerticalStrut(ItemPalette.STRUT_SIZE)); blurbLayout->addStrut(ItemPalette::STRUT_SIZE); blurbLayout->addWidget(new QLabel(tr("To Add an Icon to your control panel:"))); blurbLayout->addWidget(new QLabel(tr("--drag an icon from the display panel below to your control panel"))); blurbLayout->addWidget(new QLabel(tr("--or press [%1] and drag an icon from the catalog to your control panel").arg( tr("Icon Catalog")))); //blurb.add(Box.createVerticalStrut(ItemPalette.STRUT_SIZE)); blurbLayout->addStrut(ItemPalette::STRUT_SIZE); blurbLayout->addWidget(new QLabel(tr("To modify an icon in the display panel below, drag an icon from the catalog."))); blurbLayout->addWidget(new QLabel(tr("To change the name of an icon below, Double Click on the name."))); blurbLayout->addWidget(new QLabel(tr("To delete the icon, Click on the name, then press [%1].").arg( tr("deleteIcon")))); //blurb.add(Box.createVerticalStrut(ItemPalette.STRUT_SIZE)); blurbLayout->addStrut(ItemPalette::STRUT_SIZE); QWidget* panel = new QWidget(); // panel->setLayout(new QVBoxLayout()); // panel->layout()->addWidget(blurb); panel->setLayout(blurbLayout); return panel; }
ConfirmWindow::ConfirmWindow(QWidget *parent) : QWidget(parent) { QVBoxLayout *v = new QVBoxLayout(this); QHBoxLayout *h = new QHBoxLayout(); confirmText = new QLabel("Вы точно хотите это сделать?", this); okButton = new QPushButton("OK",this); cancelButton = new QPushButton("Отмена",this); v->addWidget(confirmText); v->addStrut(10); v->addItem(h); h->addWidget(okButton); h->addWidget(cancelButton); this->setLayout(v); QObject::connect(cancelButton,SIGNAL(clicked()),this,SLOT(cancelAction())); QObject::connect(okButton,SIGNAL(clicked()),this,SLOT(confirmAction())); }
/* * This dialog is designed to unify the old word, view, and graph type dialogs * into a cohesive whole. * */ ViewDimensions::ViewDimensions(MainWindow *parent) : Dialog(parent, "Dimensions", true) { WorldDimProp::add(this); viewXMin = getUnitDoubleSpinBox(); connect(viewXMin, SIGNAL(valueChanged(double)), this, SLOT(readjXMax())); viewXMax = getUnitDoubleSpinBox(); connect(viewXMax, SIGNAL(valueChanged(double)), this, SLOT(readjXMin())); viewYMin = getUnitDoubleSpinBox(); connect(viewYMin, SIGNAL(valueChanged(double)), this, SLOT(readjYMax())); viewYMax = getUnitDoubleSpinBox(); connect(viewYMax, SIGNAL(valueChanged(double)), this, SLOT(readjYMin())); worldXMin = new QLineEdit(); connect(worldXMin, SIGNAL(textEdited(QString)), this, SLOT(updateScale())); worldXMax = new QLineEdit(); connect(worldXMax, SIGNAL(textEdited(QString)), this, SLOT(updateScale())); worldYMin = new QLineEdit(); connect(worldYMin, SIGNAL(textEdited(QString)), this, SLOT(updateScale())); worldYMax = new QLineEdit(); connect(worldYMax, SIGNAL(textEdited(QString)), this, SLOT(updateScale())); worldType = new QComboBox(); for (int k=0;k<OPTS_LEN;k++) { worldType->addItem(opts[k].iname); } connect(worldType, SIGNAL(currentIndexChanged(int)), this, SLOT(updateScale())); viewSelect = makeButton("Rect Select", SLOT(viewRect())); setButtonBold(viewSelect); rescaleAxes = makeButton("Autoscale", SLOT(rescaleTicks())); setButtonBold(rescaleAxes); autoHook(viewXMin); autoHook(viewXMax); autoHook(viewYMin); autoHook(viewYMax); autoHook(worldXMin); autoHook(worldXMax); autoHook(worldYMin); autoHook(worldYMax); autoHook(worldType); QHBoxLayout* header = new QHBoxLayout(); header->addWidget(makeLabel("Graph Type"), 0); header->addWidget(worldType, 0); header->addStretch(1); QGridLayout* wrldl = new QGridLayout(); addPair(wrldl, 0, makeLabel("X Min"), worldXMin); addPair(wrldl, 1, makeLabel("X Max"), worldXMax); addPair(wrldl, 2, makeLabel("Y Min"), worldYMin); addPair(wrldl, 3, makeLabel("Y Max"), worldYMax); wrldl->setRowMinimumHeight(4, 12); wrldl->addWidget(rescaleAxes, 5, 0, 1, 2, Qt::AlignCenter); wrldl->setColumnMinimumWidth(1, 100); wrldl->setColumnStretch(0, 0); wrldl->setColumnStretch(1, 2); QGroupBox* wrldb = makeGroupBox("World Coords"); wrldb->setLayout(wrldl); QVBoxLayout* wrld = new QVBoxLayout(); wrld->addWidget(wrldb, 0); wrld->addStretch(1); QGridLayout* viewl = new QGridLayout(); addPair(viewl, 0, makeLabel("X Min"), viewXMin); addPair(viewl, 1, makeLabel("X Max"), viewXMax); addPair(viewl, 2, makeLabel("Y Min"), viewYMin); addPair(viewl, 3, makeLabel("Y Max"), viewYMax); viewl->setRowMinimumHeight(4, 12); viewl->addWidget(viewSelect, 5, 0, 1, 2, Qt::AlignCenter); viewl->setColumnMinimumWidth(1, 120); viewl->setColumnStretch(0, 0); viewl->setColumnStretch(1, 2); QGroupBox* viewb = makeGroupBox("View Coords"); viewb->setLayout(viewl); QVBoxLayout* view = new QVBoxLayout(); view->addWidget(viewb, 0); view->addStretch(1); QHBoxLayout* bot = new QHBoxLayout(); bot->addLayout(wrld); bot->addLayout(view); QVBoxLayout* ovr = new QVBoxLayout(); ovr->addLayout(header); ovr->addStrut(12); ovr->addLayout(bot); this->setDialogLayout(ovr); }
MainWindow::MainWindow( QWidget *parent ) : QWidget(parent), adChannel(0), psthLength(1000), psthBinw(20), spikeThres(1), psthOn(0), spikeDetected(false), time(0), linearAverage(0) { // initialize comedi const char *filename = "/dev/comedi0"; /* open the device */ if( (dev = comedi_open(filename)) == 0 ) { comedi_perror(filename); exit(1); } // do not produce NAN for out of range behaviour comedi_set_global_oor_behavior(COMEDI_OOR_NUMBER); maxdata = comedi_get_maxdata(dev, COMEDI_SUB_DEVICE, 0); crange = comedi_get_range(dev,COMEDI_SUB_DEVICE,0,0); numChannels = comedi_get_n_channels(dev, COMEDI_SUB_DEVICE); chanlist = new unsigned[numChannels]; /* Set up channel list */ for( int i=0; i<numChannels; i++ ) chanlist[i] = CR_PACK(i, COMEDI_RANGE_ID, AREF_GROUND); int ret = comedi_get_cmd_generic_timed( dev, COMEDI_SUB_DEVICE, &comediCommand, numChannels, (int)(1e9/(SAMPLING_RATE)) ); if(ret < 0) { printf("comedi_get_cmd_generic_timed failed\n"); exit(-1); } /* Modify parts of the command */ comediCommand.chanlist = chanlist; comediCommand.stop_src = TRIG_NONE; comediCommand.stop_arg = 0; /* comedi_command_test() tests a command to see if the * trigger sources and arguments are valid for the subdevice. * If a trigger source is invalid, it will be logically ANDed * with valid values (trigger sources are actually bitmasks), * which may or may not result in a valid trigger source. * If an argument is invalid, it will be adjusted to the * nearest valid value. In this way, for many commands, you * can test it multiple times until it passes. Typically, * if you can't get a valid command in two tests, the original * command wasn't specified very well. */ ret = comedi_command_test(dev, &comediCommand); if(ret < 0) { comedi_perror("comedi_command_test"); exit(-1); } fprintf(stderr, "first test returned %d\n", ret); ret = comedi_command_test(dev, &comediCommand); if(ret < 0) { comedi_perror("comedi_command_test"); exit(-1); } fprintf(stderr, "second test returned %d\n", ret); if(ret != 0) { fprintf(stderr,"Error preparing command\n"); exit(-1); } // the timing is done channel by channel // this means that the actual sampling rate is divided by // number of channels if ((comediCommand.convert_src == TRIG_TIMER)&&(comediCommand.convert_arg)) { sampling_rate=(((double)1E9 / comediCommand.convert_arg)/numChannels); } // the timing is done scan by scan (all channels at once) // the sampling rate is equivalent of the scan_begin_arg if ((comediCommand.scan_begin_src == TRIG_TIMER)&&(comediCommand.scan_begin_arg)) { sampling_rate=(double)1E9 / comediCommand.scan_begin_arg; } // 50Hz or 60Hz mains notch filter iirnotch = new Iir::Butterworth::BandStop<IIRORDER>; assert( iirnotch != NULL ); iirnotch->setup (IIRORDER, sampling_rate, NOTCH_F, NOTCH_F/10.0); /* start the command */ ret = comedi_command(dev, &comediCommand); if(ret < 0) { comedi_perror("comedi_command"); exit(1); } int subdev_flags = comedi_get_subdevice_flags(dev, COMEDI_SUB_DEVICE); if( (sigmaBoard = subdev_flags & SDF_LSAMPL) ) readSize = sizeof(lsampl_t) * numChannels; else readSize = sizeof(sampl_t) * numChannels; // Initialize data for plots for(int i=0; i<MAX_PSTH_LENGTH; i++) { xData[i] = i; // time axis yData[i] = 0; timeData[i] = double(i)*psthBinw; // psth time axis spikeCountData[i] = 0; psthData[i] = 0; } // the gui, straight forward QT/Qwt resize(640,420); QHBoxLayout *mainLayout = new QHBoxLayout( this ); QVBoxLayout *controlLayout = new QVBoxLayout; mainLayout->addLayout(controlLayout); QVBoxLayout *plotLayout = new QVBoxLayout; plotLayout->addStrut(400); mainLayout->addLayout(plotLayout); // two plots RawDataPlot = new DataPlot(xData, yData, psthLength, crange->max, crange->min, this); plotLayout->addWidget(RawDataPlot); RawDataPlot->show(); plotLayout->addSpacing(20); MyPsthPlot = new PsthPlot(timeData, psthData, psthLength/psthBinw, this); plotLayout->addWidget(MyPsthPlot); MyPsthPlot->show(); /*---- Buttons ----*/ // AD group QGroupBox *ADcounterGroup = new QGroupBox( "A/D Channel", this ); QVBoxLayout *ADcounterLayout = new QVBoxLayout; ADcounterGroup->setLayout(ADcounterLayout); ADcounterGroup->setAlignment(Qt::AlignJustify); ADcounterGroup->setSizePolicy( QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed) ); controlLayout->addWidget( ADcounterGroup ); QwtCounter *cntChannel = new QwtCounter(ADcounterGroup); cntChannel->setRange(0, numChannels-1, 1); cntChannel->setValue(adChannel); ADcounterLayout->addWidget(cntChannel); connect(cntChannel, SIGNAL(valueChanged(double)), SLOT(slotSetChannel(double))); filter50HzCheckBox = new QCheckBox( "50Hz filter" ); filter50HzCheckBox->setEnabled( true ); ADcounterLayout->addWidget(filter50HzCheckBox); // psth functions QGroupBox *PSTHfunGroup = new QGroupBox( "Actions", this ); QVBoxLayout *PSTHfunLayout = new QVBoxLayout; PSTHfunGroup->setLayout(PSTHfunLayout); PSTHfunGroup->setAlignment(Qt::AlignJustify); PSTHfunGroup->setSizePolicy( QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed) ); controlLayout->addWidget( PSTHfunGroup ); averagePsth = new QComboBox(PSTHfunGroup); averagePsth->addItem(tr("PSTH")); averagePsth->addItem(tr("VEP")); PSTHfunLayout->addWidget(averagePsth); connect( averagePsth, SIGNAL(currentIndexChanged(int)), SLOT(slotAveragePsth(int)) ); triggerPsth = new QPushButton(PSTHfunGroup); triggerPsth->setText("PSTH on"); triggerPsth->setCheckable(true); PSTHfunLayout->addWidget(triggerPsth); connect(triggerPsth, SIGNAL(clicked()), SLOT(slotTriggerPsth())); QPushButton *clearPsth = new QPushButton(PSTHfunGroup); clearPsth->setText("clear data"); PSTHfunLayout->addWidget(clearPsth); connect(clearPsth, SIGNAL(clicked()), SLOT(slotClearPsth())); QPushButton *savePsth = new QPushButton(PSTHfunGroup); savePsth->setText("save data"); PSTHfunLayout->addWidget(savePsth); connect(savePsth, SIGNAL(clicked()), SLOT(slotSavePsth())); // psth params QGroupBox *PSTHcounterGroup = new QGroupBox( "Parameters", this ); QVBoxLayout *PSTHcounterLayout = new QVBoxLayout; PSTHcounterGroup->setLayout(PSTHcounterLayout); PSTHcounterGroup->setAlignment(Qt::AlignJustify); PSTHcounterGroup->setSizePolicy( QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed) ); controlLayout->addWidget( PSTHcounterGroup ); QLabel *psthLengthLabel = new QLabel("Sweep length", PSTHcounterGroup); PSTHcounterLayout->addWidget(psthLengthLabel); QwtCounter *cntSLength = new QwtCounter(PSTHcounterGroup); cntSLength->setNumButtons(2); cntSLength->setIncSteps(QwtCounter::Button1, 10); cntSLength->setIncSteps(QwtCounter::Button2, 100); cntSLength->setRange(1, MAX_PSTH_LENGTH, 1); cntSLength->setValue(psthLength); PSTHcounterLayout->addWidget(cntSLength); connect(cntSLength, SIGNAL(valueChanged(double)), SLOT(slotSetPsthLength(double))); QLabel *binwidthLabel = new QLabel("Binwidth", PSTHcounterGroup); PSTHcounterLayout->addWidget(binwidthLabel); cntBinw = new QwtCounter(PSTHcounterGroup); cntBinw->setNumButtons(2); cntBinw->setIncSteps(QwtCounter::Button1, 1); cntBinw->setIncSteps(QwtCounter::Button2, 10); cntBinw->setRange(1, 100, 1); cntBinw->setValue(psthBinw); PSTHcounterLayout->addWidget(cntBinw); connect(cntBinw, SIGNAL(valueChanged(double)), SLOT(slotSetPsthBinw(double))); QLabel *thresholdLabel = new QLabel("Spike Threshold", PSTHcounterGroup); PSTHcounterLayout->addWidget(thresholdLabel); editSpikeT = new QTextEdit("0"); QFont editFont("Courier",14); QFontMetrics editMetrics(editFont); editSpikeT->setMaximumHeight ( editMetrics.height()*1.2 ); editSpikeT->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); editSpikeT->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); editSpikeT->setFont(editFont); PSTHcounterLayout->addWidget(editSpikeT); connect(editSpikeT, SIGNAL(textChanged()), SLOT(slotSetSpikeThres())); thresholdMarker = new QwtPlotMarker(); thresholdMarker->setValue(0,0); thresholdMarker->attach(RawDataPlot); thresholdMarker->setLineStyle(QwtPlotMarker::HLine); // Generate timer event every 50ms (void)startTimer(50); }