Dialog::Dialog(QWidget *parent) : QDialog(parent) { displayW = 480; displayH = 360; statusBox = new QTextEdit; statusBox->setReadOnly(true); //Initialize Porta m_porta = new porta; centralAngle =37.5; //To home the motor go here: The probes.xml file contains the motor FOV info numLines = 128; int sel, code; char str[1024]; if(m_porta->init(CINE_SIZE, FIRMWARE_PATH, SETTINGS_PATH, LICENSE_PATH, LUT_PATH, 3, 3, 0, 0, 64) ) statusBox->setText("Porta successfully Initialized"); code = m_porta->getProbeID(0); m_porta->selectProbe(code); m_porta->activateProbeConnector(0); m_porta->findMasterPreset(str, 1024, code); m_porta->loadPreset(str); m_porta->initImagingMode((imagingMode)RfMode); m_porta->setParam(prmRfMode, 1); m_porta->setParam(prmRfDecim, 0); m_porta->setParam(prmMotorStatus, 0); m_porta->setParam(prmBLineDensity, numLines); // try 128 and 256, may need 128 to achieve sufficient frame rate m_porta->setParam(prmBTxFreq, 4500000); //Units are hz m_porta->setParam(prmBImageDepth, 100); //Units are mm m_porta->setParam(prmBFocusDepth, 70000); //units are microns m_porta->setParam("b-pulse repeat", 1); //turn on the imaging so I can get the parameters I need //initialize linear array data collection rfInPlaneButton = new QPushButton(tr("Collect RF in plane") ); //Volume Acquisition Controls initialization QPushButton *rfVolumeButton = new QPushButton(tr("Collect RF data Volume") ); ///////////File Naming fileNameBox = new QLineEdit; fNameLabel = new QLabel; fNameLabel->setText("RF data file Name: " ); fNameString = "D:"; fNameString += '/'; fNameString += "defaultName.rf"; fileNameBox->insert(fNameString); ////// ////// ////// ////// //////B-mode image initialization ////// ////// ////// ////// ////// bModeOnButton = new QPushButton(tr("Start B-mode Imaging") ); bModeOffButton = new QPushButton(tr("Stop B-mode Imaging") ); bModeDisplay = new QLabel; bModeTimer = new QTimer; volumeRefreshTimer = new QTimer; strainTimer = new QTimer; bModeImage = new QImage(displayW,displayH, QImage::Format_Indexed8); bModeImage->setNumColors(256); //Assign an RGB value to the 256 indexes in the image color table for ( int i = 0; i < 256; i++ ) { bModeImage->setColor( i, qRgb( i, i, i )) ; } bModeImage->fill(100); QPixmap bModePix = QPixmap::fromImage(*bModeImage); bModeDisplay->setPixmap(bModePix); int szFrm = (displayW * displayH * (8 / 8)); //(16 bit ints/8 bits per char)*10 frames per angle buffer = new unsigned char[szFrm]; rfBuffer = NULL; //Initialize RF buffer to NULL ////// ////// ////// ////// ///// ///// /////Strain Image initialization ///// ///// ///// ////// ////// ////// ////// /*int w = 200;//m_porta->getParam(prmRfNumLines); int h = 200;//m_porta->getParam(prmRfNumSamples); //Adjust block matching parameters blockMatchParams.windowY = 81; blockMatchParams.windowX = 7; blockMatchParams.overlap = .75; blockMatchParams.halfY = (81 - 1)/2; blockMatchParams.halfX = (7 - 1)/2; blockMatchParams.rangeY = 45; blockMatchParams.rangeX = 7; blockMatchParams.smallRangeY = 3; blockMatchParams.smallRangeX = 1; blockMatchParams.strainWin = 13; //Work out displacement image geometry info //bounds on X displacement geom.startX = blockMatchParams.halfX + blockMatchParams.rangeX; geom.stopX = (w - 1) - blockMatchParams.halfX - blockMatchParams.rangeX; geom.numX = geom.stopX - geom.startX + 1; //bounds on blocks in Y direction geom.stepY = ( (float)1 - blockMatchParams.overlap )*blockMatchParams.windowY; geom.startY = blockMatchParams.halfY + blockMatchParams.rangeY; int maxY = (h - 1) - blockMatchParams.rangeY - blockMatchParams.halfY; geom.numY = (maxY - geom.startY)/geom.stepY; geom.stopY = geom.startY + (geom.numY-1)*geom.stepY; geom.numSY = geom.numY - blockMatchParams.strainWin; //Initialize array to hold strain image strainImagePtr = new float[geom.numSY*geom.numX]; //scanConvert = new NeHeChapter2; strainOnButton = new QPushButton(tr("Start Strain Imaging") ); strainOffButton = new QPushButton(tr("Stop Strain Imaging") ); strainDisplay = new QLabel; strainImage = new QImage(geom.numX,geom.numSY, QImage::Format_Indexed8); strainImage->setNumColors(256); //Assign an RGB value to the 256 indexes in the image color table for ( int i = 0; i < 256; i++ ) { strainImage->setColor( i, qRgb( i, i, i )) ; } strainImage->fill(100); QPixmap strainPix = QPixmap::fromImage(*strainImage); strainDisplay->setPixmap(strainPix); */ ///// ///// ///// ///// /////Image/Focus Depth and angle Initialization ///// ///// ///// ///// ///// ///// ///// depthLabel = new QLabel; depthLabel->setText("Imaging Depth (mm)"); QComboBox *imageDepthBox = new QComboBox; imageDepthBox->insertItem(0,"20"); imageDepthBox->insertItem(1,"30"); imageDepthBox->insertItem(2,"40"); imageDepthBox->insertItem(3,"50"); imageDepthBox->insertItem(4,"60"); imageDepthBox->insertItem(5,"70"); imageDepthBox->insertItem(6,"80"); imageDepthBox->insertItem(7,"90"); imageDepthBox->insertItem(8,"100"); imageDepthBox->insertItem(9, "110"); imageDepthBox->insertItem(10,"120"); imageDepthBox->setCurrentIndex(8); //Focus Depth initialization focusLabel = new QLabel; focusLabel->setText("Focal Depth (mm)"); QComboBox *focusDepthBox = new QComboBox; focusDepthBox ->insertItem(0,"30"); focusDepthBox ->insertItem(1,"40"); focusDepthBox ->insertItem(2,"50"); focusDepthBox ->insertItem(3,"60"); focusDepthBox ->insertItem(4,"70"); focusDepthBox ->insertItem(5,"80"); focusDepthBox ->insertItem(6,"90"); focusDepthBox->setCurrentIndex(4); //Go to angle box angleLabel = new QLabel; angleLabel->setText("Wobbler Position (Degrees)"); QComboBox *angleBox = new QComboBox; angleBox ->insertItem(0,"-10"); angleBox ->insertItem(1,"-5"); angleBox ->insertItem(2,"0"); angleBox ->insertItem(3,"5"); angleBox ->insertItem(4,"10"); angleBox->setCurrentIndex(2); ///// ///// ///// ///// ///// Signals/Slots and layout ///// ///// ///// ///// ///// connect(rfVolumeButton, SIGNAL(clicked() ), this, SLOT(collectRfVolume() ) ) ; connect(volumeRefreshTimer, SIGNAL( timeout() ), this, SLOT( acquireAngleInRfVolume() ) ); connect(this, SIGNAL( volumeAcquisitionComplete() ), this, SLOT( writeRfVolume() ) ); connect(this, SIGNAL( updateImageWhileVolumeAcquisition() ), this, SLOT( showImageDuringVolumeSlot() ) ); connect(bModeOnButton, SIGNAL(clicked() ), this, SLOT(stopStrainTimer() ) ); connect(bModeOnButton, SIGNAL(clicked() ), this, SLOT(startBModeTimer() ) ); connect(bModeOffButton, SIGNAL(clicked() ), this, SLOT(stopBModeTimer() ) ); connect(bModeTimer, SIGNAL(timeout()), this, SLOT(updateBModeImage() ) ) ; connect(imageDepthBox, SIGNAL(currentIndexChanged(int) ), this, SLOT( changeImageDepth(int) ) ); connect(focusDepthBox, SIGNAL(currentIndexChanged(int) ), this, SLOT( changeFocusDepth(int) ) ); connect(angleBox, SIGNAL(currentIndexChanged(int) ), this, SLOT(changeStaticAngle(int) ) ); /* connect(strainOnButton, SIGNAL(clicked() ), this, SLOT(stopBModeTimer() ) ); //stop B-mode imaging connect(strainOnButton, SIGNAL(clicked() ), this, SLOT(startStrainTimer() ) ); //begin strain imaging connect(strainOffButton, SIGNAL(clicked() ), this, SLOT(stopStrainTimer() ) ); connect(strainTimer, SIGNAL(timeout()), this, SLOT(updateStrainImage() ) ); */ /////Arrange controls in Horizontal Grid///// QGridLayout *controlsLayout = new QGridLayout; controlsLayout->addWidget(depthLabel, 0, 0); controlsLayout->addWidget(imageDepthBox, 1,0); controlsLayout->addWidget(focusLabel, 0, 1); controlsLayout->addWidget(focusDepthBox, 1, 1); controlsLayout->addWidget(angleLabel, 0, 2); controlsLayout->addWidget(angleBox, 1, 2); controlsLayout->addWidget(fNameLabel, 0, 3); controlsLayout->addWidget(fileNameBox, 1, 3); controlsLayout->addWidget(rfInPlaneButton, 0, 4); controlsLayout->addWidget(rfVolumeButton, 1, 4); controlsLayout->addWidget(bModeOnButton, 0, 5); controlsLayout->addWidget(bModeOffButton,1, 5); // controlsLayout->addWidget(strainOnButton, 0, 6); // controlsLayout->addWidget(strainOffButton, 1, 6); //Arrange the B-mode and Strain imaging in a horizontal layout QHBoxLayout *imagingLayout = new QHBoxLayout; imagingLayout->addWidget(bModeDisplay); // imagingLayout->addWidget(strainDisplay); //Put the imaging controls underneath the images QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout(imagingLayout); mainLayout->addLayout(controlsLayout); mainLayout->setSpacing(30); mainLayout->addWidget(statusBox, Qt::AlignCenter); setLayout(mainLayout); // setLayout(controlsLayout); statusBox->resize(150, 150); statusBox->setMaximumHeight(150); statusBox->setMinimumHeight(150); statusBox->setMaximumWidth(150); statusBox->setMinimumWidth(150); }
void ApplicationWindow::addTpgTab(int m_winWidth) { QWidget *t = new QWidget(m_tabs); QVBoxLayout *vbox = new QVBoxLayout(t); QWidget *w = new QWidget(t); QCheckBox *check; QComboBox *combo; QSpinBox *spin; m_col = m_row = 0; m_cols = 4; for (int j = 0; j < m_cols; j++) { m_maxw[j] = 0; } vbox->addWidget(w); QGridLayout *grid = new QGridLayout(w); QLabel *title_tab = new QLabel("Test Pattern Generator", parentWidget()); QFont f = title_tab->font(); f.setBold(true); title_tab->setFont(f); grid->addWidget(title_tab, m_row, m_col, 1, m_cols, Qt::AlignLeft); grid->setRowMinimumHeight(m_row, 25); m_row++; QFrame *m_line = new QFrame(grid->parentWidget()); m_line->setFrameShape(QFrame::HLine); m_line->setFrameShadow(QFrame::Sunken); grid->addWidget(m_line, m_row, m_col, 1, m_cols, Qt::AlignVCenter); m_row++; m_tabs->addTab(t, "Test Pattern Generator"); grid->addWidget(new QWidget(w), grid->rowCount(), 0, 1, m_cols); addLabel(grid, "Test Pattern"); combo = new QComboBox(w); for (int i = 0; tpg_pattern_strings[i]; i++) combo->addItem(tpg_pattern_strings[i]); addWidget(grid, combo); connect(combo, SIGNAL(activated(int)), SLOT(testPatternChanged(int))); m_row++; m_col = 0; addLabel(grid, "Horizontal Movement"); combo = new QComboBox(w); combo->addItem("Move Left Fast"); combo->addItem("Move Left"); combo->addItem("Move Left Slow"); combo->addItem("No Movement"); combo->addItem("Move Right Slow"); combo->addItem("Move Right"); combo->addItem("Move Right Fast"); combo->setCurrentIndex(3); addWidget(grid, combo); connect(combo, SIGNAL(activated(int)), SLOT(horMovementChanged(int))); addLabel(grid, "Video Aspect Ratio"); combo = new QComboBox(w); combo->addItem("Source Width x Height"); combo->addItem("4x3"); combo->addItem("14x9"); combo->addItem("16x9"); combo->addItem("16x9 Anamorphic"); addWidget(grid, combo); connect(combo, SIGNAL(activated(int)), SLOT(videoAspectRatioChanged(int))); addLabel(grid, "Vertical Movement"); combo = new QComboBox(w); combo->addItem("Move Up Fast"); combo->addItem("Move Up"); combo->addItem("Move Up Slow"); combo->addItem("No Movement"); combo->addItem("Move Down Slow"); combo->addItem("Move Down"); combo->addItem("Move Down Fast"); combo->setCurrentIndex(3); addWidget(grid, combo); connect(combo, SIGNAL(activated(int)), SLOT(vertMovementChanged(int))); addLabel(grid, "Show Border"); check = new QCheckBox(w); addWidget(grid, check); connect(check, SIGNAL(stateChanged(int)), SLOT(showBorderChanged(int))); addLabel(grid, "Insert SAV Code in Image"); check = new QCheckBox(w); addWidget(grid, check); connect(check, SIGNAL(stateChanged(int)), SLOT(insSAVChanged(int))); addLabel(grid, "Show Square"); check = new QCheckBox(w); addWidget(grid, check); connect(check, SIGNAL(stateChanged(int)), SLOT(showSquareChanged(int))); addLabel(grid, "Insert EAV Code in Image"); check = new QCheckBox(w); addWidget(grid, check); connect(check, SIGNAL(stateChanged(int)), SLOT(insEAVChanged(int))); addLabel(grid, "Fill Percentage of Frame"); spin = new QSpinBox(w); spin->setRange(0, 100); spin->setValue(100); addWidget(grid, spin); connect(spin, SIGNAL(valueChanged(int)), SLOT(fillPercentageChanged(int))); addLabel(grid, "Colorspace"); m_tpgColorspace = new QComboBox(w); m_tpgColorspace->addItem("Use Format", QVariant(0)); m_tpgColorspace->addItem("SMPTE 170M", QVariant(V4L2_COLORSPACE_SMPTE170M)); m_tpgColorspace->addItem("Rec. 709", QVariant(V4L2_COLORSPACE_REC709)); m_tpgColorspace->addItem("sRGB", QVariant(V4L2_COLORSPACE_SRGB)); m_tpgColorspace->addItem("Adobe RGB", QVariant(V4L2_COLORSPACE_ADOBERGB)); m_tpgColorspace->addItem("BT.2020", QVariant(V4L2_COLORSPACE_BT2020)); m_tpgColorspace->addItem("DCI-P3", QVariant(V4L2_COLORSPACE_DCI_P3)); m_tpgColorspace->addItem("SMPTE 240M", QVariant(V4L2_COLORSPACE_SMPTE240M)); m_tpgColorspace->addItem("470 System M", QVariant(V4L2_COLORSPACE_470_SYSTEM_M)); m_tpgColorspace->addItem("470 System BG", QVariant(V4L2_COLORSPACE_470_SYSTEM_BG)); addWidget(grid, m_tpgColorspace); connect(m_tpgColorspace, SIGNAL(activated(int)), SLOT(tpgColorspaceChanged())); addLabel(grid, "Transfer Function"); m_tpgXferFunc = new QComboBox(w); m_tpgXferFunc->addItem("Use Format", QVariant(V4L2_XFER_FUNC_DEFAULT)); m_tpgXferFunc->addItem("Rec. 709", QVariant(V4L2_XFER_FUNC_709)); m_tpgXferFunc->addItem("sRGB", QVariant(V4L2_XFER_FUNC_SRGB)); m_tpgXferFunc->addItem("Adobe RGB", QVariant(V4L2_XFER_FUNC_ADOBERGB)); m_tpgXferFunc->addItem("DCI-P3", QVariant(V4L2_XFER_FUNC_DCI_P3)); m_tpgXferFunc->addItem("SMPTE 2084", QVariant(V4L2_XFER_FUNC_SMPTE2084)); m_tpgXferFunc->addItem("SMPTE 240M", QVariant(V4L2_XFER_FUNC_SMPTE240M)); m_tpgXferFunc->addItem("None", QVariant(V4L2_XFER_FUNC_NONE)); addWidget(grid, m_tpgXferFunc); connect(m_tpgXferFunc, SIGNAL(activated(int)), SLOT(tpgXferFuncChanged())); addLabel(grid, "Y'CbCr Encoding"); m_tpgYCbCrEnc = new QComboBox(w); m_tpgYCbCrEnc->addItem("Use Format", QVariant(V4L2_YCBCR_ENC_DEFAULT)); m_tpgYCbCrEnc->addItem("ITU-R 601", QVariant(V4L2_YCBCR_ENC_601)); m_tpgYCbCrEnc->addItem("Rec. 709", QVariant(V4L2_YCBCR_ENC_709)); m_tpgYCbCrEnc->addItem("xvYCC 601", QVariant(V4L2_YCBCR_ENC_XV601)); m_tpgYCbCrEnc->addItem("xvYCC 709", QVariant(V4L2_YCBCR_ENC_XV709)); m_tpgYCbCrEnc->addItem("sYCC", QVariant(V4L2_YCBCR_ENC_SYCC)); m_tpgYCbCrEnc->addItem("BT.2020", QVariant(V4L2_YCBCR_ENC_BT2020)); m_tpgYCbCrEnc->addItem("BT.2020 Constant Luminance", QVariant(V4L2_YCBCR_ENC_BT2020_CONST_LUM)); m_tpgYCbCrEnc->addItem("SMPTE 240M", QVariant(V4L2_YCBCR_ENC_SMPTE240M)); addWidget(grid, m_tpgYCbCrEnc); connect(m_tpgYCbCrEnc, SIGNAL(activated(int)), SLOT(tpgColorspaceChanged())); addLabel(grid, "Quantization"); m_tpgQuantRange = new QComboBox(w); m_tpgQuantRange->addItem("Use Format", QVariant(V4L2_QUANTIZATION_DEFAULT)); m_tpgQuantRange->addItem("Full Range", QVariant(V4L2_QUANTIZATION_FULL_RANGE)); m_tpgQuantRange->addItem("Limited Range", QVariant(V4L2_QUANTIZATION_LIM_RANGE)); addWidget(grid, m_tpgQuantRange); connect(m_tpgQuantRange, SIGNAL(activated(int)), SLOT(tpgColorspaceChanged())); addLabel(grid, "Limited RGB Range (16-235)"); m_tpgLimRGBRange = new QCheckBox(w); addWidget(grid, m_tpgLimRGBRange); connect(m_tpgLimRGBRange, SIGNAL(stateChanged(int)), SLOT(limRGBRangeChanged(int))); addLabel(grid, "Alpha Component"); spin = new QSpinBox(w); spin->setRange(0, 255); spin->setValue(0); addWidget(grid, spin); connect(spin, SIGNAL(valueChanged(int)), SLOT(alphaComponentChanged(int))); addLabel(grid, "Apply Alpha To Red Only"); check = new QCheckBox(w); addWidget(grid, check); connect(check, SIGNAL(stateChanged(int)), SLOT(applyToRedChanged(int))); m_row++; m_col = 0; addWidget(grid, new QWidget(w)); grid->setRowStretch(grid->rowCount() - 1, 1); w = new QWidget(t); vbox->addWidget(w); fixWidth(grid); int totalw = 0; int diff = 0; for (int i = 0; i < m_cols; i++) { totalw += m_maxw[i] + m_pxw; } if (totalw > m_winWidth) m_winWidth = totalw; else { diff = m_winWidth - totalw; grid->setHorizontalSpacing(diff/5); } }
bool CDlgSetOthers::eventFilter(QObject *o,QEvent *e) { QObject *obj[]= { m_cmbb_light ,m_cmbb_warning_volume ,m_cmbb_smoth ,m_btn_ok ,m_btn_cancel }; int iTotalObj = 5;//11 int iOkPos = iTotalObj -2; int iCancelPos = iTotalObj -1; if(e->type() == QEvent::KeyPress) { QKeyEvent *event=(QKeyEvent *)e; switch (event->key()) { case Qt::Key_Up: case Qt::Key_Left: if(bCursorSta == false) { if(iCursor == 0) { iCursor = iTotalObj-1; } else { iCursor -=1; } if((iCursor>=0) &&(iCursor<iOkPos)) { QComboBox *p = (QComboBox *)obj[iCursor]; p->setFocus(); } else { QPushButton *p = (QPushButton *)obj[iCursor]; p->setFocus(); } } else { } return true; break; case Qt::Key_Down: case Qt::Key_Right: if(bCursorSta == false) { if(iCursor == iTotalObj-1) { iCursor = 0; } else { iCursor +=1; } if((iCursor>=0) &&(iCursor<iOkPos)) { QComboBox *p = (QComboBox *)obj[iCursor]; p->setFocus(); } else { QPushButton *p = (QPushButton *)obj[iCursor]; p->setFocus(); } } else { } return true; break; case Qt::Key_Return: if(bCursorSta == false) { if(iCursor == iOkPos) { do_ok_clicked(); } else if(iCursor == iCancelPos) { do_cancel_clicked(); } else if((iCursor>=0) &&(iCursor<iOkPos)) { //btn[iCursor]->showPopup(); bCursorSta = false; QComboBox *p = (QComboBox *)obj[iCursor]; p->showPopup(); //p->setStyleSheet("background-color: rgb(35, 53, 234,255);"); } } else { } return true; break; default: CMainForm *p = (CMainForm *)pMainForm; p->f_process_key(event->key()); return true; break; } } else { return false; } }
void QtComboBoxDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const { QComboBox* comboBox = static_cast<QComboBox*>(editor); model->setData(index, comboBox->currentText(), Qt::EditRole); model->setData(index, comboBox->currentData(Qt::UserRole), Qt::UserRole); }
void CUcontent_Adjustments::setupAdjustmentsTable() { bool enable = false; bool ok = false; unsigned char k = 0; QTableWidgetItem *tableItem = NULL; ModQDoubleSpinBox *spinBox = NULL; QComboBox *comboBox = NULL; QIdPushButton *saveButton = NULL; QPushButton *resetButton = NULL; QPixmap leftIcon, rightIcon; QPixmap mergedIcon(54, 22); QStringList selectableScaledValueStr; QString helpScaledValueStr = 0; double minScaledValue = 0; double maxScaledValue = 0; double defaultScaledValue = 0; double minSingleStepFromPrecision = 0; double minSingleStepFromRaw = 0; bool calcerror = false; // Create "Save"-icon: leftIcon.load( QString::fromUtf8(":/icons/oxygen/22x22/go-next.png") ); rightIcon.load( QString::fromUtf8(":/icons/oxygen/22x22/drive-harddisk.png") ); mergedIcon.fill(Qt::transparent); QPainter painter(&mergedIcon); painter.drawTiledPixmap( 0, 0, 22, 22, leftIcon ); painter.drawTiledPixmap( 32, 0, 22, 22, rightIcon ); QIcon saveButton_icon( mergedIcon ); // Create "Reset"-icon: leftIcon.load( QString::fromUtf8(":/icons/oxygen/22x22/go-first.png") ); mergedIcon.fill(Qt::transparent); painter.drawTiledPixmap( 0, 0, 22, 22, leftIcon ); painter.drawTiledPixmap( 32, 0, 22, 22, rightIcon ); QIcon resetButton_icon( mergedIcon ); // Clear Table: adjustments_tableWidget->clearContents(); // Enable/Disable GUI-elements: title_label->setEnabled( enable ); adjustments_tableWidget->setEnabled( enable ); nonPermanentInfo_label->setEnabled( enable ); // Increase nr. of table rows if necessary: if (_supportedAdjustments.size() && (static_cast<unsigned int>(adjustments_tableWidget->rowCount()) < _supportedAdjustments.size())) adjustments_tableWidget->setRowCount( _supportedAdjustments.size() + 2 ); // Fill Table: for (k=0; k<_supportedAdjustments.size(); k++) { // Title: tableItem = new QTableWidgetItem( _supportedAdjustments.at(k).title ); adjustments_tableWidget->setItem(k, 0, tableItem); // Current Value: tableItem = new QTableWidgetItem( "???" ); tableItem->setTextAlignment(Qt::AlignCenter); adjustments_tableWidget->setItem(k, 1, tableItem); // New Value: if (_newValueSelWidgetType.at(k)) { // Get selectable scaled values: selectableScaledValueStr.clear(); getSelectableScaledValueStrings(_supportedAdjustments.at(k).formula, &selectableScaledValueStr); // Setup and insert selection-Combobox: comboBox = new QComboBox(); comboBox->addItems( selectableScaledValueStr ); adjustments_tableWidget->setCellWidget ( k, 2, comboBox ); } else { // Calculate and set min/max: ok = libFSSM::raw2scaled(_supportedAdjustments.at(k).rawMin, _supportedAdjustments.at(k).formula, _supportedAdjustments.at(k).precision, &helpScaledValueStr); if (ok) minScaledValue = helpScaledValueStr.toDouble(&ok); if (ok) ok = libFSSM::raw2scaled(_supportedAdjustments.at(k).rawMax, _supportedAdjustments.at(k).formula, _supportedAdjustments.at(k).precision, &helpScaledValueStr); if (ok) maxScaledValue = helpScaledValueStr.toDouble(&ok); if (ok) ok = libFSSM::raw2scaled(_supportedAdjustments.at(k).rawDefault, _supportedAdjustments.at(k).formula, _supportedAdjustments.at(k).precision, &helpScaledValueStr); if (ok) defaultScaledValue = helpScaledValueStr.toDouble(&ok); if (!ok) { calcerror = true; continue; // continue with next adjustment value } spinBox = new ModQDoubleSpinBox(); // put spinbox into the table: adjustments_tableWidget->setCellWidget ( k, 2, spinBox ); /* NOTE: we do this here, because some spinbox functions don't work as expected (Qt-bugs ?) if spinBox is not visible yet */ // Set adjustable range: if (minScaledValue > maxScaledValue) spinBox->setRange(maxScaledValue, minScaledValue); else spinBox->setRange(minScaledValue, maxScaledValue); // Calculate and set step size: minSingleStepFromPrecision = pow(10, (-1*_supportedAdjustments.at(k).precision)); minSingleStepFromRaw = (maxScaledValue - minScaledValue) / (_supportedAdjustments.at(k).rawMax - _supportedAdjustments.at(k).rawMin); /* NOTE: this only works for constant step size ! */ if (minSingleStepFromRaw > minSingleStepFromPrecision) spinBox->setSingleStep( minSingleStepFromRaw ); else spinBox->setSingleStep( minSingleStepFromPrecision ); // Set base value for "discrete values mode": spinBox->setDiscreteValuesModeBaseValue(defaultScaledValue); // Enable "discrete values mode": spinBox->setDiscreteValuesModeEnabled(true); // Set decimals: spinBox->setDecimals(_supportedAdjustments.at(k).precision); // Set suffix (unit): spinBox->setSuffix(" " + _supportedAdjustments.at(k).unit); // Set alignement: spinBox->setAlignment(Qt::AlignCenter); } // "Save"-button: saveButton = new QIdPushButton("", k, adjustments_tableWidget); saveButton->setIcon(saveButton_icon); saveButton->setIconSize( QSize(54,22) ); connect (saveButton, SIGNAL( released(unsigned int) ), this, SLOT( saveAdjustmentValue(unsigned int) )); adjustments_tableWidget->setCellWidget ( k, 3, saveButton ); } // Setup "Reset all"-elements: if (_supportedAdjustments.size() > 0) { // Title: tableItem = new QTableWidgetItem( tr("Reset all: ") ); tableItem->setTextAlignment(Qt::AlignVCenter | Qt::AlignRight); adjustments_tableWidget->setItem(_supportedAdjustments.size()+1, 2, tableItem); // "Reset all"-button: resetButton = new QPushButton(adjustments_tableWidget); resetButton->setIcon( resetButton_icon ); resetButton->setIconSize( QSize(54, 22) ); connect (resetButton, SIGNAL( released() ), this, SLOT( resetAllAdjustmentValues() )); adjustments_tableWidget->setCellWidget ( _supportedAdjustments.size()+1, 3, resetButton ); } // Check for calculation error(s): if (calcerror) calculationError(tr("One or more values will not be adjustable to prevent\nwrong data being written to the Control Unit.")); // NOTE: using released() instead of pressed() for buttons as workaround for a Qt-Bug occuring under MS Windows }
void MainWindow::callOptionDialog (QVector<ConsoleInterface::optionDialogEntry> * options,bool * ret) { if (options->isEmpty()) return; QVectorIterator<ConsoleInterface::optionDialogEntry> it(*options); QDialog * d = new QDialog(this); d->setModal(true); QVBoxLayout * dbl = new QVBoxLayout(); d->setLayout(dbl); QList <QWidget * > ents; QHBoxLayout * sl; QLabel * l; QLineEdit * lew; QCheckBox * chw; QComboBox * cbl; for(int i=0;i< (*options).size();i++) { sl = new QHBoxLayout(); l = new QLabel(d); l->setText(it.next().text); sl->addWidget(l); if((*options)[i].type == ConsoleInterface::OPT_DEC) { lew = new QLineEdit(d); lew->setValidator(new QIntValidator( d )); QString s; s.setNum((*options)[i].valueInt); lew->setText(s); sl->addWidget(lew); ents.append(lew); } if((*options)[i].type == ConsoleInterface::OPT_HEX) { lew = new QLineEdit(d); lew->setValidator(new QRegExpValidator(QRegExp("([A-Fa-f0-9][A-Fa-f0-9])+"),d)); QString s; s.setNum((*options)[i].valueInt,16); lew->setText(s); sl->addWidget(lew); ents.append(lew); } if((*options)[i].type == ConsoleInterface::OPT_STR) { lew = new QLineEdit(d); lew->setValidator(NULL); QString s = (*options)[i].valueStr; lew->setText(s); sl->addWidget(lew); ents.append(lew); } if((*options)[i].type == ConsoleInterface::OPT_CHK) { chw = new QCheckBox(d); chw->setChecked((*options)[i].valueInt == 0 ? false : true); sl->addWidget(chw); ents.append(chw); } if((*options)[i].type == ConsoleInterface::OPT_LIST) { cbl = new QComboBox(d); cbl->addItems((*options)[i].variants); sl->addWidget(cbl); ents.append(cbl); } dbl->addLayout(sl); } QHBoxLayout * hbl = new QHBoxLayout(d); QPushButton * obOK = new QPushButton(tr("OK"),d); QPushButton * obCancel = new QPushButton(tr("Cancel"),d); QPushButton * obAbort = new QPushButton(tr("Abort"),d); connect(obOK,SIGNAL(clicked()),d,SLOT(accept())); connect(obCancel,SIGNAL(clicked()),d,SLOT(reject())); connect(obAbort,SIGNAL(clicked()),d,SLOT(reject())); connect(obAbort,SIGNAL(clicked()),this,SLOT(on_stopButton_clicked()),Qt::QueuedConnection); hbl->addStretch(10); hbl->addWidget(obOK); hbl->addWidget(obCancel); hbl->addWidget(obAbort); dbl->addLayout(hbl); if(d->exec()==QDialog::Accepted) { for(int i=0;i< (*options).size();i++) { if((*options)[i].type == ConsoleInterface::OPT_DEC) { (*options)[i].valueInt = dynamic_cast<QLineEdit*>(ents[i])->text().toInt(); } if((*options)[i].type == ConsoleInterface::OPT_HEX) { (*options)[i].valueInt = dynamic_cast<QLineEdit*>(ents[i])->text().toInt(0,16); } if((*options)[i].type == ConsoleInterface::OPT_STR) { QString t = dynamic_cast<QLineEdit*>(ents[i])->text(); (*options)[i].valueStr = t; } if((*options)[i].type == ConsoleInterface::OPT_CHK) { (*options)[i].valueInt = dynamic_cast<QCheckBox*>(ents[i])->isChecked(); } if((*options)[i].type == ConsoleInterface::OPT_LIST) { (*options)[i].valueInt = dynamic_cast<QComboBox*>(ents[i])->currentIndex(); } } *ret =true; } else { *ret =false; } delete d; }
bool WulforUtil::getUserCommandParams(const UserCommand& uc, StringMap& params) { StringList names; string::size_type i = 0, j = 0; const string cmd_str = uc.getCommand(); while((i = cmd_str.find("%[line:", i)) != string::npos) { if ((j = cmd_str.find("]", (i += 7))) == string::npos) break; names.push_back(cmd_str.substr(i, j - i)); i = j + 1; } if (names.empty()) return true; QDialog dlg(MainWindow::getInstance()); dlg.setWindowTitle(_q(uc.getDisplayName().back())); QVBoxLayout *vlayout = new QVBoxLayout(&dlg); std::vector<std::function<void ()> > valueFs; for (const auto &name : names) { QString caption = _q(name); if (uc.adc()) { caption.replace("\\\\", "\\"); caption.replace("\\s", " "); } int combo_sel = -1; QString combo_caption = caption; combo_caption.replace("//", "\t"); QStringList combo_values = combo_caption.split("/"); if (combo_values.size() > 2) { QString tmp = combo_values.takeFirst(); bool isNumber = false; combo_sel = combo_values.takeFirst().toInt(&isNumber); if (!isNumber || combo_sel >= combo_values.size()) combo_sel = -1; else caption = tmp; } QGroupBox *box = new QGroupBox(caption, &dlg); QHBoxLayout *hlayout = new QHBoxLayout(box); if (combo_sel >= 0) { for (auto &val : combo_values) val.replace("\t", "/"); QComboBox *combo = new QComboBox(box); hlayout->addWidget(combo); combo->addItems(combo_values); combo->setEditable(true); combo->setCurrentIndex(combo_sel); combo->lineEdit()->setReadOnly(true); valueFs.push_back([combo, name, ¶ms] { params["line:" + name] = combo->currentText().toStdString(); }); } else { QLineEdit *line = new QLineEdit(box); hlayout->addWidget(line); valueFs.push_back([line, name, ¶ms] { params["line:" + name] = line->text().toStdString(); }); } vlayout->addWidget(box); } QDialogButtonBox *buttonBox = new QDialogButtonBox(&dlg); buttonBox->setOrientation(Qt::Horizontal); buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); vlayout->addWidget(buttonBox); dlg.setFixedHeight(vlayout->sizeHint().height()); connect(buttonBox, SIGNAL(accepted()), &dlg, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), &dlg, SLOT(reject())); if (dlg.exec() != QDialog::Accepted) return false; for (const auto &fs : valueFs) fs(); return true; }
void QgsSnappingDialog::update() { if ( !mMapCanvas ) return; QSettings myQsettings; bool myDockFlag = myQsettings.value( "/qgis/dockSnapping", false ).toBool(); double defaultSnappingTolerance = myQsettings.value( "/qgis/digitizing/default_snapping_tolerance", 0 ).toDouble(); int defaultSnappingUnit = myQsettings.value( "/qgis/digitizing/default_snapping_tolerance_unit", 0 ).toInt(); QString defaultSnappingString = myQsettings.value( "/qgis/digitizing/default_snap_mode", "to vertex" ).toString(); int defaultSnappingStringIdx = 0; if ( defaultSnappingString == "to vertex" ) { defaultSnappingStringIdx = 0; } else if ( defaultSnappingString == "to segment" ) { defaultSnappingStringIdx = 1; } else //to vertex and segment { defaultSnappingStringIdx = 2; } bool layerIdListOk, enabledListOk, toleranceListOk, toleranceUnitListOk, snapToListOk, avoidIntersectionListOk; QStringList layerIdList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingList", &layerIdListOk ); QStringList enabledList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingEnabledList", &enabledListOk ); QStringList toleranceList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceList", & toleranceListOk ); QStringList toleranceUnitList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceUnitList", & toleranceUnitListOk ); QStringList snapToList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnapToList", &snapToListOk ); QStringList avoidIntersectionsList = QgsProject::instance()->readListEntry( "Digitizing", "/AvoidIntersectionsList", &avoidIntersectionListOk ); mLayerTreeWidget->clear(); QMap< QString, QgsMapLayer *> mapLayers = QgsMapLayerRegistry::instance()->mapLayers(); QMap< QString, QgsMapLayer *>::iterator it; for ( it = mapLayers.begin(); it != mapLayers.end() ; ++it ) { QgsVectorLayer *currentVectorLayer = qobject_cast<QgsVectorLayer *>( it.value() ); if ( !currentVectorLayer || currentVectorLayer->geometryType() == QGis::NoGeometry ) continue; //snap to layer yes/no QTreeWidgetItem *item = new QTreeWidgetItem( mLayerTreeWidget ); QCheckBox *cbxEnable = new QCheckBox( mLayerTreeWidget ); mLayerTreeWidget->setItemWidget( item, 0, cbxEnable ); item->setData( 0, Qt::UserRole, currentVectorLayer->getLayerID() ); item->setText( 1, currentVectorLayer->name() ); //snap to vertex/ snap to segment QComboBox *cbxSnapTo = new QComboBox( mLayerTreeWidget ); cbxSnapTo->insertItem( 0, tr( "to vertex" ) ); cbxSnapTo->insertItem( 1, tr( "to segment" ) ); cbxSnapTo->insertItem( 2, tr( "to vertex and segment" ) ); cbxSnapTo->setCurrentIndex( defaultSnappingStringIdx ); mLayerTreeWidget->setItemWidget( item, 2, cbxSnapTo ); //snapping tolerance QLineEdit *leTolerance = new QLineEdit( mLayerTreeWidget ); QDoubleValidator *validator = new QDoubleValidator( leTolerance ); leTolerance->setValidator( validator ); leTolerance->setText( QString::number( defaultSnappingTolerance, 'f' ) ); mLayerTreeWidget->setItemWidget( item, 3, leTolerance ); //snap to vertex/ snap to segment QComboBox *cbxUnits = new QComboBox( mLayerTreeWidget ); cbxUnits->insertItem( 0, tr( "map units" ) ); cbxUnits->insertItem( 1, tr( "pixels" ) ); cbxUnits->setCurrentIndex( defaultSnappingUnit ); mLayerTreeWidget->setItemWidget( item, 4, cbxUnits ); QCheckBox *cbxAvoidIntersection = 0; if ( currentVectorLayer->geometryType() == QGis::Polygon ) { cbxAvoidIntersection = new QCheckBox( mLayerTreeWidget ); mLayerTreeWidget->setItemWidget( item, 5, cbxAvoidIntersection ); } int idx = layerIdList.indexOf( currentVectorLayer->getLayerID() ); if ( idx < 0 ) { // no settings for this layer yet continue; } cbxEnable->setChecked( enabledList[ idx ] == "enabled" ); int snappingStringIdx = 0; if ( snapToList[idx] == "to_vertex" ) { snappingStringIdx = 0; } else if ( snapToList[idx] == "to_segment" ) { snappingStringIdx = 1; } else //to vertex and segment { snappingStringIdx = 2; } cbxSnapTo->setCurrentIndex( snappingStringIdx ); leTolerance->setText( QString::number( toleranceList[idx].toDouble(), 'f' ) ); cbxUnits->setCurrentIndex( toleranceUnitList[idx].toInt() ); if ( cbxAvoidIntersection ) { cbxAvoidIntersection->setChecked( avoidIntersectionsList.contains( currentVectorLayer->getLayerID() ) ); } } // read the digitizing settings int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 ); if ( topologicalEditing != 0 ) { cbxEnableTopologicalEditingCheckBox->setCheckState( Qt::Checked ); } else { cbxEnableTopologicalEditingCheckBox->setCheckState( Qt::Unchecked ); } if ( myDockFlag ) { for ( int i = 0; i < mLayerTreeWidget->topLevelItemCount(); ++i ) { QTreeWidgetItem *item = mLayerTreeWidget->topLevelItem( i ); connect( mLayerTreeWidget->itemWidget( item, 0 ), SIGNAL( stateChanged( int ) ), this, SLOT( apply() ) ); connect( mLayerTreeWidget->itemWidget( item, 2 ), SIGNAL( currentIndexChanged( int ) ), this, SLOT( apply() ) ); connect( mLayerTreeWidget->itemWidget( item, 3 ), SIGNAL( textEdited( const QString ) ), this, SLOT( apply() ) ); connect( mLayerTreeWidget->itemWidget( item, 4 ), SIGNAL( currentIndexChanged( int ) ), this, SLOT( apply() ) ); QCheckBox *cbxAvoidIntersection = qobject_cast<QCheckBox*>( mLayerTreeWidget->itemWidget( item, 5 ) ); if ( cbxAvoidIntersection ) { connect( cbxAvoidIntersection, SIGNAL( stateChanged( int ) ), this, SLOT( apply() ) ); } } } }
void SCgWindow::createToolBar() { mToolBar = new QToolBar(this); mToolBar->setIconSize(QSize(32, 32)); QActionGroup* group = new QActionGroup(mToolBar); // Select mode QAction *action = new QAction(findIcon("tool-select.png"), tr("Selection mode"), mToolBar); action->setCheckable(true); action->setChecked(true); action->setShortcut(QKeySequence(tr("1", "Selection mode"))); group->addAction(action); mToolBar->addAction(action); mMode2Action[SCgScene::Mode_Select] = action; connect(action, SIGNAL(triggered()), this, SLOT(onSelectMode())); //Pair creation mode action = new QAction(findIcon("tool-pair.png"), tr("Pair creation mode"), mToolBar); action->setCheckable(true); action->setShortcut(QKeySequence(tr("2", "Pair creation mode"))); group->addAction(action); mToolBar->addAction(action); mMode2Action[SCgScene::Mode_Pair] = action; connect(action, SIGNAL(triggered()), this, SLOT(onPairMode())); //Bus creation mode action = new QAction(findIcon("tool-bus.png"), tr("Bus creation mode"), mToolBar); action->setCheckable(true); action->setShortcut(QKeySequence(tr("3", "Bus creation mode"))); group->addAction(action); mToolBar->addAction(action); mMode2Action[SCgScene::Mode_Bus] = action; connect(action, SIGNAL(triggered()), this, SLOT(onBusMode())); //Contour creation mode action = new QAction(findIcon("tool-contour.png"), tr("Contour creation mode"), mToolBar); action->setCheckable(true); action->setShortcut(QKeySequence(tr("4", "Contour creation mode"))); group->addAction(action); mToolBar->addAction(action); mMode2Action[SCgScene::Mode_Contour] = action; connect(action, SIGNAL(triggered()), this, SLOT(onContourMode())); // mToolBar->addSeparator(); // // align group button QToolButton *alignButton = new QToolButton(mToolBar); alignButton->setIcon(findIcon("tool-align.png")); alignButton->setPopupMode(QToolButton::InstantPopup); mToolBar->addWidget(alignButton); //Grid alignment action = new QAction(findIcon("tool-align-grid.png"), tr("Grid alignment"), mToolBar); action->setCheckable(false); action->setShortcut(QKeySequence(tr("5", "Grid alignment"))); alignButton->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(onGridAlignment())); // tuple alignment action = new QAction(findIcon("tool-align-tuple.png"), tr("Tuple alignment"), mToolBar); action->setCheckable(false); action->setShortcut(QKeySequence(tr("6", "Tuple alignment"))); alignButton->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(onTupleAlignment())); //Vertical alignment action = new QAction(findIcon("tool-align-vert.png"), tr("Vertical alignment"), mToolBar); action->setCheckable(false); action->setShortcut(QKeySequence(tr("7", "Vertical alignment"))); alignButton->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(onVerticalAlignment())); //Horizontal alignment action = new QAction(findIcon("tool-align-horz.png"), tr("Horizontal alignment"), mToolBar); action->setCheckable(false); action->setShortcut(QKeySequence(tr("8", "Horizontal alignment"))); alignButton->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(onHorizontalAlignment())); // Energy-based layout action = new QAction(findIcon("tool-align-energy.png"), tr("Energy-based layout"), mToolBar); action->setCheckable(false); action->setShortcut(QKeySequence(tr("9", "Energy-based layout"))); alignButton->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(onEnergyBasedLayout())); // selection group button QToolButton *selectButton = new QToolButton(mToolBar); selectButton->setIcon(findIcon("tool-select-group.png")); selectButton->setPopupMode(QToolButton::InstantPopup); mToolBar->addWidget(selectButton); // input/output selection action = new QAction(findIcon("tool-select-inout.png"), tr("Select input/output"), mToolBar); action->setCheckable(false); selectButton->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(onSelectInputOutput())); // sbgraph selection action = new QAction(findIcon("tool-select-subgraph.png"), tr("Select subgraph"), mToolBar); action->setCheckable(false); selectButton->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(onSelectSubgraph())); mToolBar->addSeparator(); action = new QAction(findIcon("tool-export-image.png"), tr("Export image"), mToolBar); action->setCheckable(false); action->setShortcut(QKeySequence(tr("0", "Export image"))); mToolBar->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(onExportImage())); action = new QAction(findIcon("tool-print.png"), tr("Print"), mToolBar); action->setCheckable(false); action->setShortcut(QKeySequence(tr("0", "Print"))); mToolBar->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(onPrint())); // mToolBar->addSeparator(); //Scale combobox QComboBox* b = new QComboBox(mToolBar); b->setFixedWidth(55); b->setEditable(true); b->setInsertPolicy(QComboBox::NoInsert); b->addItems(SCgWindow::mScales); b->setCurrentIndex(mScales.indexOf("100")); mZoomFactorLine = b->lineEdit(); mZoomFactorLine->setInputMask("D90%"); mToolBar->addWidget(b); connect(mZoomFactorLine, SIGNAL(textChanged(const QString&)), mView, SLOT(setScale(const QString&))); connect(mView, SIGNAL(scaleChanged(qreal)), this, SLOT(onViewScaleChanged(qreal))); // //Zoom in //action = new QAction(findIcon("tool-zoom-in.png"), tr("Zoom in"), mToolBar); action = new QAction("+",mToolBar); action->setToolTip(tr("Zoom in")); action->setCheckable(false); action->setShortcut(QKeySequence(tr("+", "Zoom in"))); mToolBar->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(onZoomIn())); //slider scale mZoomSlider = new QSlider(); mZoomSlider->setFixedWidth(40); mZoomSlider->setSizeIncrement(25,180/25); mZoomSlider->setFixedHeight(180); mZoomSlider->setToolTip(tr("Scale")); mZoomSlider->setMinimum(mZoomSliderMinValue); mZoomSlider->setValue(100); mZoomSlider->setMaximum(mZoomSliderMaxValue); mToolBar->addWidget(mZoomSlider); connect(mZoomSlider,SIGNAL(valueChanged(int)),this,SLOT(onmZoomSliderMove(int))); //Zoom out // action = new QAction(findIcon("tool-zoom-out.png"), tr("Zoom out"), mToolBar); action = new QAction("-", mToolBar); action->setToolTip(tr("Zoom out")); action->setCheckable(false); action->setShortcut(QKeySequence(tr("-", "Zoom out"))); mToolBar->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(onZoomOut())); mToolBar->setWindowTitle(tr("SCg Tools")); mToolBar->setObjectName("SCgMainToolBar"); //! @bug toolbar state is not saved mToolBar->setMovable(false); }
void PropertiesManager::createImpulsePortProperties(ImpulsePortTextItem *ip) { //move up down root->actionMove_Up->setEnabled(true); root->actionMove_Down->setEnabled(true); root->actionDeleteItems->setEnabled(true); QLabel *label = new QLabel("<b>Edit Impulse Port</b>"); addRow(label); ImpulsePortMode m = ip->getPortMode(); //if mode == send if (m == ImpulseSendPort){ QComboBox *param = new QComboBox(); for (uint i=0; i< root->al->ParameterList.size(); i++) { param->addItem(root->al->ParameterList[i]->getName()); if (ip->getParameter() != NULL){ if (root->al->ParameterList[i]->getName().compare(ip->getParameter()->getName()) == 0) param->setCurrentIndex(i); } } for (uint i=0; i< root->al->StateVariableList.size(); i++) { param->addItem(root->al->StateVariableList[i]->getName()); if (ip->getParameter() != NULL){ if (root->al->StateVariableList[i]->getName().compare(ip->getParameter()->getName()) == 0) param->setCurrentIndex(i); } } for (uint i=0; i< root->al->AliasList.size(); i++) { param->addItem(root->al->AliasList[i]->getName()); if (ip->getParameter() != NULL){ if (root->al->AliasList[i]->getName().compare(ip->getParameter()->getName()) == 0) param->setCurrentIndex(i); } } if (ip->getParameter() == NULL) param->setCurrentIndex(-1); connect(param, SIGNAL(currentIndexChanged(QString)), ip, SLOT(setParameter(QString))); addRow(tr("&Par/Var:"),param); } //otherwise m == Recv else { QLineEdit *name = new QLineEdit(); name->installEventFilter(&eventFilterObject); name->setText(ip->getName()); name->setValidator(validator); connect(name, SIGNAL(textEdited(QString)), ip, SLOT(setName(QString))); addRow(tr("&Name:"),name); } QComboBox *mode = new QComboBox(); mode->addItem("Send"); mode->addItem("Receive"); switch(m){ case(ImpulseSendPort): mode->setCurrentIndex(0); break; case(ImpulseRecvPort): mode->setCurrentIndex(1); break; } connect(mode, SIGNAL(currentIndexChanged(QString)), ip, SLOT(setPortMode(QString))); addRow(tr("Impulse &Mode"), mode); if (m == ImpulseRecvPort){ QComboBox *dims_prefix = getPrefixCombo(ip->port->dims->getPrefix()); connect(dims_prefix, SIGNAL(currentIndexChanged(QString)), ip, SLOT(setDimsPrefix(QString))); addRow(tr("Dimensionality &Prefix:"),dims_prefix); QComboBox *dims_unit = getUnitCombo(ip->port->dims->getUnit()); connect(dims_unit, SIGNAL(currentIndexChanged(QString)), ip, SLOT(setDimsUnit(QString))); addRow(tr("Dimensionality &Unit:"),dims_unit); } }
void PropertiesManager::createAnalogPortProperties(AnalogPortTextItem *ap) { //move up down root->actionMove_Up->setEnabled(true); root->actionMove_Down->setEnabled(true); root->actionDeleteItems->setEnabled(true); QLabel *label = new QLabel("<b>Edit Analog Port</b>"); addRow(label); //if mode == send if (ap->getPortMode() == AnalogSendPort){ QComboBox *var = new QComboBox(); for (uint i=0; i< root->al->StateVariableList.size(); i++) { var->addItem(root->al->StateVariableList[i]->getName()); if (ap->getVariable() != NULL){ if (root->al->StateVariableList[i]->getName().compare(ap->getVariable()->getName()) == 0) var->setCurrentIndex(i); } } for (uint i=0; i< root->al->AliasList.size(); i++) { var->addItem(root->al->AliasList[i]->getName()); if (ap->getVariable() != NULL){ if (root->al->AliasList[i]->getName().compare(ap->getVariable()->getName()) == 0) var->setCurrentIndex(i+root->al->StateVariableList.size()); } } if (ap->getVariable() == NULL) var->setCurrentIndex(-1); connect(var, SIGNAL(currentIndexChanged(QString)), ap, SLOT(setVariable(QString))); addRow(tr("&Variable:"),var); } //otherwise else { QLineEdit *name = new QLineEdit(); name->installEventFilter(&eventFilterObject); name->setText(ap->getName()); name->setValidator(validator); connect(name, SIGNAL(textEdited(QString)), ap, SLOT(setName(QString))); addRow(tr("&Name:"),name); } QComboBox *mode = new QComboBox(); mode->addItem("Send"); mode->addItem("Receive"); mode->addItem("Reduce"); AnalogPortMode m = ap->getPortMode(); switch(m){ case(AnalogSendPort): mode->setCurrentIndex(0); break; case(AnalogRecvPort): mode->setCurrentIndex(1); break; case(AnalogReducePort): mode->setCurrentIndex(2); break; } connect(mode, SIGNAL(currentIndexChanged(QString)), ap, SLOT(setPortMode(QString))); addRow(tr("Analog &Mode"), mode); if(m == AnalogReducePort){ QComboBox *reduce = new QComboBox(); reduce->addItem("None"); reduce->addItem("Addition"); ReduceOperation r = ap->getPortReduceOp(); switch(r){ case(ReduceOperationNone): reduce->setCurrentIndex(0); break; case(ReduceOperationAddition): reduce->setCurrentIndex(1); break; } connect(reduce, SIGNAL(currentIndexChanged(QString)), ap, SLOT(setPortReduceOp(QString))); addRow(tr("&Reduce Operation:"), reduce); } if ((m == AnalogRecvPort)||(m == AnalogReducePort)){ QComboBox *dims_prefix = getPrefixCombo(ap->port->dims->getPrefix()); connect(dims_prefix, SIGNAL(currentIndexChanged(QString)), ap, SLOT(setDimsPrefix(QString))); addRow(tr("Dimensionality &Prefix:"),dims_prefix); QComboBox *dims_unit = getUnitCombo(ap->port->dims->getUnit()); connect(dims_unit, SIGNAL(currentIndexChanged(QString)), ap, SLOT(setDimsUnit(QString))); addRow(tr("Dimensionality &Unit:"),dims_unit); } }
void PropertiesManager::createTimeDerivativeProperties(TimeDerivativeTextItem *td) { //move up down root->actionMove_Up->setEnabled(true); root->actionMove_Down->setEnabled(true); root->actionDeleteItems->setEnabled(true); QLabel *label = new QLabel("<b>Edit Time Derivative</b>"); addRow(label); QComboBox *var = new QComboBox(); for (uint i=0; i< root->al->StateVariableList.size(); i++) { var->addItem(root->al->StateVariableList[i]->getName()); if (td->getVariable() != NULL){ if (root->al->StateVariableList[i]->getName().compare(td->getVariable()->getName()) == 0) { var->setCurrentIndex(i); } } else var->setCurrentIndex(-1); } connect(var, SIGNAL(currentIndexChanged(QString)), td, SLOT(setVariable(QString))); addRow(tr("&Variable:"),var); QLineEdit *maths = new QLineEdit(); maths->installEventFilter(&eventFilterObject); maths->setText(td->getMaths()->equation); connect(maths, SIGNAL(textEdited(QString)), td, SLOT(setMaths(QString))); addRow(tr("&Maths:"),maths); addWidget(new QLabel(tr("<i>in physiological units</i>"))); QStringList errs; td->time_derivative->maths->validateMathInLine(root->al, &errs); // sort out errors QSettings settings; int num_errs = settings.beginReadArray("warnings"); settings.endArray(); if (num_errs != 0) { // show errors by changing lineedit colour QPalette p = maths->palette(); p.setColor( QPalette::Normal, QPalette::Base, QColor(255, 200, 200) ); maths->setPalette(p); // clear errors settings.remove("warnings"); } if (num_errs == 0) { // show no errors by changing lineedit colour QPalette p = maths->palette(); p.setColor( QPalette::Normal, QPalette::Base, QColor(255, 255, 255) ); maths->setPalette(p); // clear errors settings.remove("warnings"); } }
QWidget* ComboBoxDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const { QComboBox *comboDelegate = new QComboBox(parent); comboDelegate->setModel(model); comboDelegate->setEditable(true); comboDelegate->setAutoCompletion(true); comboDelegate->setAutoCompletionCaseSensitivity(Qt::CaseInsensitive); comboDelegate->completer()->setCompletionMode(QCompleter::PopupCompletion); comboDelegate->view()->setEditTriggers(QAbstractItemView::AllEditTriggers); comboDelegate->lineEdit()->installEventFilter( const_cast<QObject*>(qobject_cast<const QObject*>(this))); comboDelegate->view()->installEventFilter( const_cast<QObject*>(qobject_cast<const QObject*>(this))); connect(comboDelegate, SIGNAL(highlighted(QString)), this, SLOT(testActivation(QString))); connect(comboDelegate->lineEdit(), SIGNAL(editingFinished()), this, SLOT(testActivation())); connect(comboDelegate, SIGNAL(activated(QString)), this, SLOT(fakeActivation())); currCombo.comboEditor = comboDelegate; currCombo.currRow = index.row(); currCombo.model = const_cast<QAbstractItemModel*>(index.model()); // Current display of things on Gnome3 looks like shit, so // let`s fix that. if (isGnome3Session()) { QPalette p; p.setColor(QPalette::Window, QColor(Qt::white)); p.setColor(QPalette::Base, QColor(Qt::white)); comboDelegate->lineEdit()->setPalette(p); comboDelegate->setPalette(p); } return comboDelegate; }
int InputConvertUnitsParametersDialog::getEMode()const { return m_emode->currentIndex(); }
DynamicSetupWidget::DynamicSetupWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget* parent ) : QWidget( parent ) , m_playlist( playlist ) , m_headerText( 0 ) , m_layout( new QHBoxLayout ) , m_generatorCombo( 0 ) , m_logo( 0 ) , m_generateButton( 0 ) , m_genNumber( 0 ) { setContentsMargins( 0, 0, 0, 0 ); m_headerText = new QLabel( tr( "Type:" ), this ); m_layout->addWidget( m_headerText ); QComboBox * genCombo = new QComboBox( this ); foreach( const QString& type, GeneratorFactory::types() ) genCombo->addItem( type ); m_generatorCombo = new ReadOrWriteWidget( genCombo, m_playlist->author()->isLocal(), this ); m_generatorCombo->setLabel( playlist->generator()->type().replace( 0, 1, playlist->generator()->type().at( 0 ).toUpper() ) ); m_layout->addWidget( m_generatorCombo ); // TODO until there are more... no point in choices m_headerText->hide(); m_generatorCombo->hide(); m_generateButton = new QPushButton( tr( "Generate" ), this ); m_generateButton->setAttribute( Qt::WA_LayoutUsesWidgetRect ); connect( m_generateButton, SIGNAL( clicked( bool ) ), this, SLOT( generatePressed( bool ) ) ); if( m_playlist->mode() == OnDemand ) m_generateButton->hide(); else m_layout->addWidget( m_generateButton ); m_genNumber = new QSpinBox( this ); m_genNumber->setValue( 15 ); m_genNumber->setMinimum( 0 ); if( m_playlist->mode() == OnDemand ) m_genNumber->hide(); else m_layout->addWidget( m_genNumber ); if( m_playlist->mode() == Static ) m_layout->addSpacing( 30 ); m_logo = new QLabel( this ); if( !m_playlist->generator()->logo().isNull() ) { QPixmap p = m_playlist->generator()->logo().scaledToHeight( 22, Qt::SmoothTransformation ); m_logo->setPixmap( p ); } m_layout->addWidget(m_logo); setLayout( m_layout ); m_fadeAnim = new QPropertyAnimation( this, "opacity" ); m_fadeAnim->setDuration( 250 ); m_fadeAnim->setStartValue( 0.00 ); m_fadeAnim->setEndValue( .70 ); setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); resize( QWidget::sizeHint() ); }
int main(int argc, char **argv) { //! [0] QApplication app(argc, argv); Q3DScatter *graph = new Q3DScatter(); QWidget *container = QWidget::createWindowContainer(graph); //! [0] if (!graph->hasContext()) { QMessageBox msgBox; msgBox.setText("Couldn't initialize the OpenGL context."); msgBox.exec(); return -1; } QSize screenSize = graph->screen()->size(); container->setMinimumSize(QSize(screenSize.width() / 2, screenSize.height() / 1.5)); container->setMaximumSize(screenSize); container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); container->setFocusPolicy(Qt::StrongFocus); //! [1] QWidget *widget = new QWidget; QHBoxLayout *hLayout = new QHBoxLayout(widget); QVBoxLayout *vLayout = new QVBoxLayout(); hLayout->addWidget(container, 1); hLayout->addLayout(vLayout); //! [1] widget->setWindowTitle(QStringLiteral("A Cosine Wave")); //! [4] QComboBox *themeList = new QComboBox(widget); themeList->addItem(QStringLiteral("Qt")); themeList->addItem(QStringLiteral("Primary Colors")); themeList->addItem(QStringLiteral("Digia")); themeList->addItem(QStringLiteral("Stone Moss")); themeList->addItem(QStringLiteral("Army Blue")); themeList->addItem(QStringLiteral("Retro")); themeList->addItem(QStringLiteral("Ebony")); themeList->addItem(QStringLiteral("Isabelle")); themeList->setCurrentIndex(6); QPushButton *labelButton = new QPushButton(widget); labelButton->setText(QStringLiteral("Change label style")); QCheckBox *smoothCheckBox = new QCheckBox(widget); smoothCheckBox->setText(QStringLiteral("Smooth dots")); smoothCheckBox->setChecked(true); QComboBox *itemStyleList = new QComboBox(widget); itemStyleList->addItem(QStringLiteral("Sphere"), int(QAbstract3DSeries::MeshSphere)); itemStyleList->addItem(QStringLiteral("Cube"), int(QAbstract3DSeries::MeshCube)); itemStyleList->addItem(QStringLiteral("Minimal"), int(QAbstract3DSeries::MeshMinimal)); itemStyleList->addItem(QStringLiteral("Point"), int(QAbstract3DSeries::MeshPoint)); itemStyleList->setCurrentIndex(0); QPushButton *cameraButton = new QPushButton(widget); cameraButton->setText(QStringLiteral("Change camera preset")); QPushButton *itemCountButton = new QPushButton(widget); itemCountButton->setText(QStringLiteral("Toggle item count")); QCheckBox *backgroundCheckBox = new QCheckBox(widget); backgroundCheckBox->setText(QStringLiteral("Show background")); backgroundCheckBox->setChecked(true); QCheckBox *gridCheckBox = new QCheckBox(widget); gridCheckBox->setText(QStringLiteral("Show grid")); gridCheckBox->setChecked(true); QComboBox *shadowQuality = new QComboBox(widget); shadowQuality->addItem(QStringLiteral("None")); shadowQuality->addItem(QStringLiteral("Low")); shadowQuality->addItem(QStringLiteral("Medium")); shadowQuality->addItem(QStringLiteral("High")); shadowQuality->addItem(QStringLiteral("Low Soft")); shadowQuality->addItem(QStringLiteral("Medium Soft")); shadowQuality->addItem(QStringLiteral("High Soft")); shadowQuality->setCurrentIndex(4); QFontComboBox *fontList = new QFontComboBox(widget); fontList->setCurrentFont(QFont("Arial")); //! [4] //! [5] vLayout->addWidget(labelButton, 0, Qt::AlignTop); vLayout->addWidget(cameraButton, 0, Qt::AlignTop); vLayout->addWidget(itemCountButton, 0, Qt::AlignTop); vLayout->addWidget(backgroundCheckBox); vLayout->addWidget(gridCheckBox); vLayout->addWidget(smoothCheckBox, 0, Qt::AlignTop); vLayout->addWidget(new QLabel(QStringLiteral("Change dot style"))); vLayout->addWidget(itemStyleList); vLayout->addWidget(new QLabel(QStringLiteral("Change theme"))); vLayout->addWidget(themeList); vLayout->addWidget(new QLabel(QStringLiteral("Adjust shadow quality"))); vLayout->addWidget(shadowQuality); vLayout->addWidget(new QLabel(QStringLiteral("Change font"))); vLayout->addWidget(fontList, 1, Qt::AlignTop); //! [5] //! [2] ScatterDataModifier *modifier = new ScatterDataModifier(graph); //! [2] //! [6] QObject::connect(cameraButton, &QPushButton::clicked, modifier, &ScatterDataModifier::changePresetCamera); QObject::connect(labelButton, &QPushButton::clicked, modifier, &ScatterDataModifier::changeLabelStyle); QObject::connect(itemCountButton, &QPushButton::clicked, modifier, &ScatterDataModifier::toggleItemCount); QObject::connect(backgroundCheckBox, &QCheckBox::stateChanged, modifier, &ScatterDataModifier::setBackgroundEnabled); QObject::connect(gridCheckBox, &QCheckBox::stateChanged, modifier, &ScatterDataModifier::setGridEnabled); QObject::connect(smoothCheckBox, &QCheckBox::stateChanged, modifier, &ScatterDataModifier::setSmoothDots); QObject::connect(modifier, &ScatterDataModifier::backgroundEnabledChanged, backgroundCheckBox, &QCheckBox::setChecked); QObject::connect(modifier, &ScatterDataModifier::gridEnabledChanged, gridCheckBox, &QCheckBox::setChecked); QObject::connect(itemStyleList, SIGNAL(currentIndexChanged(int)), modifier, SLOT(changeStyle(int))); QObject::connect(themeList, SIGNAL(currentIndexChanged(int)), modifier, SLOT(changeTheme(int))); QObject::connect(shadowQuality, SIGNAL(currentIndexChanged(int)), modifier, SLOT(changeShadowQuality(int))); QObject::connect(modifier, &ScatterDataModifier::shadowQualityChanged, shadowQuality, &QComboBox::setCurrentIndex); QObject::connect(graph, &Q3DScatter::shadowQualityChanged, modifier, &ScatterDataModifier::shadowQualityUpdatedByVisual); QObject::connect(fontList, &QFontComboBox::currentFontChanged, modifier, &ScatterDataModifier::changeFont); QObject::connect(modifier, &ScatterDataModifier::fontChanged, fontList, &QFontComboBox::setCurrentFont); //! [6] //! [3] widget->show(); return app.exec(); //! [3] }
void Spice_Graphics::setDataDescription(QString &_xmlDesc) { //qDebug()<<_xmlDesc; QDomDocument doc; int idx; QDomElement _device, _listen, _streaming, _clipboard, _mouse, _filetransfer, _image, _jpeg, _zlib, _playback, _channel; doc.setContent(_xmlDesc); _device = doc.firstChildElement("device") .firstChildElement("graphics"); autoPort->setChecked( _device.attribute("autoport")=="yes"); if ( !autoPort->isChecked() ) port->setValue( _device.attribute("port").toInt()); tlsPortLabel->setChecked( _device.hasAttribute("tlsPort") ); if ( tlsPortLabel->isChecked() ) tlsPort->setValue( _device.attribute("tlsPort").toInt()); usePassw->setChecked( _device.hasAttribute("passwd") ); if ( _device.hasAttribute("passwd") ) { QString _password = _device.attribute("passwd"); passw->setText(_password); idx = keymap->findText( _device.attribute("keymap"), Qt::MatchContains); keymap->setCurrentIndex( (idx<0)? 0:idx ); }; _listen = _device.firstChildElement("listen"); if ( !_listen.isNull() ) { QString _type, _data; _type = _listen.attribute("type"); _data = _listen.attribute(_type); if ( !_type.isEmpty() ) { idx = address->findData( _type, Qt::UserRole, Qt::MatchContains); address->setCurrentIndex( (idx<0)? 3:idx ); if ( _type=="address" ) { if ( address->currentIndex()==3 ) address->setEditText(_data); } else if ( _type=="network" ) { idx = networks->findText( _data, Qt::MatchContains); networks->setCurrentIndex( (idx<0)? 0:idx ); } else address->setCurrentIndex(0); } else address->setCurrentIndex(0); } else address->setCurrentIndex(0); QString _defaultPolicy = _device.attribute("defaultPolicy"); idx = defaultPolicy->findText( _defaultPolicy, Qt::MatchContains); defaultPolicy->setCurrentIndex( (idx<0)? 0:idx ); _channel = _device.firstChildElement("channel"); while ( !_channel.isNull() ) { QComboBox *obj = NULL; QString _name, _mode; _name = _channel.attribute("name"); _mode = _channel.attribute("mode"); if ( _name=="main" ) { mainLabel->setChecked(true); obj = main; } else if ( _name=="display" ) { displayLabel->setChecked(true); obj = display; } else if ( _name=="inputs" ) { inputsLabel->setChecked(true); obj = inputs; } else if ( _name=="cursor" ) { cursorLabel->setChecked(true); obj = cursor; } else if ( _name=="playback" ) { playbackLabel->setChecked(true); obj = playback; } else if ( _name=="record" ) { recordLabel->setChecked(true); obj = record; } else if ( _name=="smartcard" ) { smartcardLabel->setChecked(true); obj = smartcard; } else if ( _name=="usbredir" ) { usbredirLabel->setChecked(true); obj = usbredir; }; if ( NULL!=obj ) { idx = obj->findText(_mode, Qt::MatchContains); obj->setCurrentIndex( (idx<0)? 0:idx); }; _channel = _channel.nextSiblingElement("channel"); }; _streaming = _device.firstChildElement("streaming"); _clipboard = _device.firstChildElement("clipboard"); _mouse = _device.firstChildElement("mouse"); _filetransfer = _device.firstChildElement("filetransfer"), _image = _device.firstChildElement("image"); _jpeg = _device.firstChildElement("jpeg"); _zlib = _device.firstChildElement("zlib"); _playback = _device.firstChildElement("playback "); streaming->setChecked( !_streaming.isNull() ); clipboard->setChecked( !_clipboard.isNull() ); mouse->setChecked( !_mouse.isNull() ); filetransfer->setChecked( !_filetransfer.isNull() ); compressImage->setChecked( !_image.isNull() ); compressJpeg->setChecked( !_jpeg.isNull() ); compressZlib->setChecked( !_zlib.isNull() ); compressPlayback->setChecked( !_playback.isNull() ); if ( !_streaming.isNull() || !_clipboard.isNull() || !_mouse.isNull() || !_filetransfer.isNull() ) { addition->setChecked(true); if ( !_streaming.isNull() ) { idx = streamingElement->findText( _streaming.attribute("mode")); streamingElement->setCurrentIndex( (idx<0)? 0:idx ); }; if ( !_clipboard.isNull() ) { idx = clipboardElement->findText( _clipboard.attribute("copypaste")); clipboardElement->setCurrentIndex( (idx<0)? 0:idx ); }; if ( !_mouse.isNull() ) { idx = mouseElement->findText( _mouse.attribute("mode")); mouseElement->setCurrentIndex( (idx<0)? 0:idx ); }; if ( !_filetransfer.isNull() ) { idx = filetransferElement->findText( _filetransfer.attribute("enable")); filetransferElement->setCurrentIndex( (idx<0)? 0:idx ); } } else { addition->setChecked(false); }; if ( !_image.isNull() || !_jpeg.isNull() || !_zlib.isNull() || !_playback.isNull() ) { compress->setChecked(true); if ( !_image.isNull() ) { idx = imageElement->findText( _image.attribute("compression")); imageElement->setCurrentIndex( (idx<0)? 0:idx ); }; if ( !_jpeg.isNull() ) { idx = jpegElement->findText( _jpeg.attribute("compression")); jpegElement->setCurrentIndex( (idx<0)? 0:idx ); }; if ( !_zlib.isNull() ) { idx = zlibElement->findText( _zlib.attribute("compression")); zlibElement->setCurrentIndex( (idx<0)? 0:idx ); }; if ( !_playback.isNull() ) { idx = playbackElement->findText( _playback.attribute("compression")); playbackElement->setCurrentIndex( (idx<0)? 0:idx ); } } else { compress->setChecked(false); }; }
void WidgetCtrlParameters::update(QMap<QString,ModPlusCtrls *> ctrlsMap) { QStringList models = ctrlsMap.keys(); // delete old widgets for(int i=0;i<_widgetsCreated.size();i++) delete _widgetsCreated.at(i); _widgetsCreated.clear(); // clear layout delete _layout; _layout = new QGridLayout(this); this->setLayout(_layout); // empty maps _ctrls.clear(); _comboBoxs.clear(); _parametersPbs.clear(); _compilePbs.clear(); QString curmodel; ModPlusCtrls *curCtrls; int iRow; for(int i=0;i<models.size();i++) { curmodel = models.at(i); curCtrls = ctrlsMap.value(curmodel); // insert in _ctrls _ctrls.insert(curmodel,curCtrls); // add model combobox QComboBox *newCb = new QComboBox(this); //Ctrl box ModPlusCtrl::Type curCtrlType; ModPlusCtrl *curCtrl; for(int i=0;i< curCtrls->keys().size();i++) { curCtrlType = curCtrls->keys().at(i); curCtrl = curCtrls->value(curCtrlType); newCb->addItem(curCtrl->name(),curCtrlType); if(curCtrlType == curCtrls->currentCtrlType()) { newCb->setCurrentIndex(i); } } newCb->setEnabled(!_isResult); _comboBoxs.insert(curmodel,newCb); iRow = _layout->rowCount()+1; QLabel *newLabel = new QLabel(curmodel,this); _layout->addWidget(newLabel,iRow,0); _layout->addWidget(newCb,iRow,1); // add push buttons QPushButton* newParamPb = new QPushButton("Parameters ...",this); _layout->addWidget(newParamPb,iRow,2); _parametersPbs.insert(curmodel,newParamPb); QPushButton* newCompilePb = new QPushButton("Compile",this); _layout->addWidget(newCompilePb,iRow,3); _compilePbs.insert(curmodel,newCompilePb); connect(newCb, SIGNAL(currentIndexChanged(int)),this, SLOT(changedCtrl())); connect(newParamPb, SIGNAL(clicked()),this,SLOT(openCtrlParameters())); connect(newCompilePb, SIGNAL(clicked()),this,SLOT(compile())); // horizontal spacer // QSpacerItem* spacer = new QSpacerItem(10,10,QSizePolicy::Expanding,QSizePolicy::Ignored); // _layout->addItem(spacer,iRow,4); _layout->setColumnStretch(4,10); _widgetsCreated.push_back(newLabel); _widgetsCreated.push_back(newCb); _widgetsCreated.push_back(newParamPb); _widgetsCreated.push_back(newCompilePb); //_widgetsCreated.push_back(spacer); } }
/*! Adds the GWS specified by the combo box in the parameter area of the dialog box to the grasp associated with this qm. The grasp will take care of creating it if it doesn't already exist. */ QualVolume::QualVolume(qmDlgDataT *data) : QualityMeasure(data) { QComboBox *gwsType = (QComboBox *)data->paramPtr; gws = grasp->addGWS(gwsType->currentText().latin1()); }
void Data3DTreeDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const { const Data3DTreeModel* pData3DTreeModel = static_cast<const Data3DTreeModel*>(index.model()); const AbstractTreeItem* pAbstractItem = static_cast<const AbstractTreeItem*>(pData3DTreeModel->itemFromIndex(index)); switch(pAbstractItem->type()) { case MetaTreeItemTypes::SurfaceColorGyri: { QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor); QColor color = pColorDialog->currentColor(); QVariant data; data.setValue(color); model->setData(index, data, MetaTreeItemRoles::SurfaceColorGyri); model->setData(index, data, Qt::DecorationRole); return; } case MetaTreeItemTypes::SurfaceColorSulci: { QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor); QColor color = pColorDialog->currentColor(); QVariant data; data.setValue(color); model->setData(index, data, MetaTreeItemRoles::SurfaceColorSulci); model->setData(index, data, Qt::DecorationRole); return; } case MetaTreeItemTypes::RTDataColormapType: { QComboBox* pColorMapType = static_cast<QComboBox*>(editor); QVariant data; data.setValue(pColorMapType->currentText()); model->setData(index, data, MetaTreeItemRoles::RTDataColormapType); model->setData(index, data, Qt::DisplayRole); return; } case MetaTreeItemTypes::RTDataNormalizationValue: { Spline* pSpline = static_cast<Spline*>(editor); QVector3D returnVector; returnVector = pSpline->getThreshold(); QString displayThreshold; displayThreshold = QString("%1,%2,%3").arg(returnVector.x()).arg(returnVector.y()).arg(returnVector.z()); QVariant dataDisplay; dataDisplay.setValue(displayThreshold); model->setData(index, dataDisplay, Qt::DisplayRole); model->setData(index, returnVector, MetaTreeItemRoles::RTDataNormalizationValue); return; } case MetaTreeItemTypes::RTDataTimeInterval: { QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor); QVariant data; data.setValue(pSpinBox->value()); model->setData(index, data, MetaTreeItemRoles::RTDataTimeInterval); model->setData(index, data, Qt::DisplayRole); break; } case MetaTreeItemTypes::RTDataVisualizationType: { QComboBox* pVisType = static_cast<QComboBox*>(editor); QVariant data; data.setValue(pVisType->currentText()); model->setData(index, data, MetaTreeItemRoles::RTDataVisualizationType); model->setData(index, data, Qt::DisplayRole); return; } case MetaTreeItemTypes::SurfaceColor: { QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor); QColor color = pColorDialog->currentColor(); QVariant data; data.setValue(color); model->setData(index, data, MetaTreeItemRoles::SurfaceColor); model->setData(index, data, Qt::DecorationRole); return; } case MetaTreeItemTypes::PointColor: { QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor); QColor color = pColorDialog->currentColor(); QVariant data; data.setValue(color); model->setData(index, data, MetaTreeItemRoles::PointColor); model->setData(index, data, Qt::DecorationRole); return; } case MetaTreeItemTypes::RTDataNumberAverages: { QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor); QVariant data; data.setValue(pSpinBox->value()); model->setData(index, data, MetaTreeItemRoles::RTDataNumberAverages); model->setData(index, data, Qt::DisplayRole); break; } case MetaTreeItemTypes::SurfaceAlpha: { QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor); QVariant data; data.setValue(pDoubleSpinBox->value()); model->setData(index, data, MetaTreeItemRoles::SurfaceAlpha); model->setData(index, data, Qt::DisplayRole); break; } case MetaTreeItemTypes::SurfaceTranslateX: { QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor); QVariant data; data.setValue(pDoubleSpinBox->value()); model->setData(index, data, MetaTreeItemRoles::SurfaceTranslateX); model->setData(index, data, Qt::DisplayRole); break; } case MetaTreeItemTypes::SurfaceTranslateY: { QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor); QVariant data; data.setValue(pDoubleSpinBox->value()); model->setData(index, data, MetaTreeItemRoles::SurfaceTranslateY); model->setData(index, data, Qt::DisplayRole); break; } case MetaTreeItemTypes::SurfaceTranslateZ: { QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor); QVariant data; data.setValue(pDoubleSpinBox->value()); model->setData(index, data, MetaTreeItemRoles::SurfaceTranslateZ); model->setData(index, data, Qt::DisplayRole); break; } case MetaTreeItemTypes::NetworkThreshold: { Spline* pSpline = static_cast<Spline*>(editor); QVector3D returnVector; returnVector = pSpline->getThreshold(); QString displayThreshold; displayThreshold = QString("%1,%2,%3").arg(returnVector.x()).arg(returnVector.y()).arg(returnVector.z()); QVariant dataDisplay; dataDisplay.setValue(displayThreshold); model->setData(index, dataDisplay, Qt::DisplayRole); model->setData(index, returnVector, MetaTreeItemRoles::NetworkThreshold); return; } default: // do nothing; break; } QItemDelegate::setModelData(editor, model, index); }
QWidget *Data3DTreeDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option , const QModelIndex& index) const { const Data3DTreeModel* pData3DTreeModel = static_cast<const Data3DTreeModel*>(index.model()); const AbstractTreeItem* pAbstractItem = static_cast<const AbstractTreeItem*>(pData3DTreeModel->itemFromIndex(index)); switch(pAbstractItem->type()) { case MetaTreeItemTypes::SurfaceColorGyri: { QColorDialog *pColorDialog = new QColorDialog(parent); connect(pColorDialog, &QColorDialog::currentColorChanged, this, &Data3DTreeDelegate::onEditorEdited); pColorDialog->setWindowTitle("Select Gyri Color"); pColorDialog->show(); return pColorDialog; } case MetaTreeItemTypes::SurfaceColorSulci: { QColorDialog *pColorDialog = new QColorDialog(); connect(pColorDialog, &QColorDialog::currentColorChanged, this, &Data3DTreeDelegate::onEditorEdited); pColorDialog->setWindowTitle("Select Sulci Color"); pColorDialog->show(); return pColorDialog; } case MetaTreeItemTypes::RTDataColormapType: { QComboBox* pComboBox = new QComboBox(parent); connect(pComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &Data3DTreeDelegate::onEditorEdited); pComboBox->addItem("Hot Negative 1"); pComboBox->addItem("Hot Negative 2"); pComboBox->addItem("Hot"); return pComboBox; } case MetaTreeItemTypes::RTDataNormalizationValue: { Spline* pSpline = new Spline("Spline Histogram", 0); connect(pSpline, static_cast<void (Spline::*)(double, double, double)>(&Spline::borderChanged), this, &Data3DTreeDelegate::onEditorEdited); QStandardItem* pParentItem = static_cast<QStandardItem*>(pAbstractItem->QStandardItem::parent()); QModelIndex indexParent = pData3DTreeModel->indexFromItem(pParentItem); MatrixXd matRTData = index.model()->data(indexParent, Data3DTreeModelItemRoles::RTData).value<MatrixXd>(); Eigen::VectorXd resultClassLimit; Eigen::VectorXi resultFrequency; MNEMath::histcounts(matRTData, false, 50, resultClassLimit, resultFrequency, 0.0, 0.0); pSpline->setData(resultClassLimit, resultFrequency, 0); QVector3D vecThresholdValues = index.model()->data(index, MetaTreeItemRoles::RTDataNormalizationValue).value<QVector3D>(); pSpline->setThreshold(vecThresholdValues); AbstractTreeItem* pParentItemAbstract = static_cast<AbstractTreeItem*>(pParentItem); QList<QStandardItem*> pColormapItem = pParentItemAbstract->findChildren(MetaTreeItemTypes::RTDataColormapType); for(int i = 0; i < pColormapItem.size(); ++i) { QModelIndex indexColormapItem = pData3DTreeModel->indexFromItem(pColormapItem.at(i)); QString colorMap = index.model()->data(indexColormapItem, MetaTreeItemRoles::RTDataColormapType).value<QString>(); pSpline->setColorMap(colorMap); } return pSpline; } case MetaTreeItemTypes::RTDataTimeInterval: { QSpinBox* pSpinBox = new QSpinBox(parent); connect(pSpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &Data3DTreeDelegate::onEditorEdited); pSpinBox->setSuffix(" mSec"); pSpinBox->setMinimum(17); pSpinBox->setMaximum(50000); pSpinBox->setSingleStep(10); pSpinBox->setValue(index.model()->data(index, MetaTreeItemRoles::RTDataTimeInterval).toInt()); return pSpinBox; } case MetaTreeItemTypes::RTDataVisualizationType: { QComboBox* pComboBox = new QComboBox(parent); pComboBox->addItem("Vertex based"); pComboBox->addItem("Smoothing based"); pComboBox->addItem("Annotation based"); return pComboBox; } case MetaTreeItemTypes::SurfaceColor: { QColorDialog *pColorDialog = new QColorDialog(); connect(pColorDialog, &QColorDialog::currentColorChanged, this, &Data3DTreeDelegate::onEditorEdited); pColorDialog->setWindowTitle("Select Surface Color"); pColorDialog->show(); return pColorDialog; } case MetaTreeItemTypes::PointColor: { QColorDialog *pColorDialog = new QColorDialog(); connect(pColorDialog, &QColorDialog::currentColorChanged, this, &Data3DTreeDelegate::onEditorEdited); pColorDialog->setWindowTitle("Select Point Color"); pColorDialog->show(); return pColorDialog; } case MetaTreeItemTypes::RTDataNumberAverages: { QSpinBox* pSpinBox = new QSpinBox(parent); connect(pSpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &Data3DTreeDelegate::onEditorEdited); pSpinBox->setMinimum(1); pSpinBox->setMaximum(100); pSpinBox->setSingleStep(1); pSpinBox->setValue(index.model()->data(index, MetaTreeItemRoles::RTDataNumberAverages).toInt()); return pSpinBox; } case MetaTreeItemTypes::SurfaceAlpha: { QDoubleSpinBox* pDoubleSpinBox = new QDoubleSpinBox(parent); connect(pDoubleSpinBox, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), this, &Data3DTreeDelegate::onEditorEdited); pDoubleSpinBox->setMinimum(0.01); pDoubleSpinBox->setMaximum(1.0); pDoubleSpinBox->setSingleStep(0.01); pDoubleSpinBox->setValue(index.model()->data(index, MetaTreeItemRoles::SurfaceAlpha).toDouble()); return pDoubleSpinBox; } case MetaTreeItemTypes::SurfaceTranslateX: { QDoubleSpinBox* pDoubleSpinBox = new QDoubleSpinBox(parent); connect(pDoubleSpinBox, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), this, &Data3DTreeDelegate::onEditorEdited); pDoubleSpinBox->setMinimum(-10000.0); pDoubleSpinBox->setMaximum(10000.0); pDoubleSpinBox->setSingleStep(0.01); pDoubleSpinBox->setValue(index.model()->data(index, MetaTreeItemRoles::SurfaceTranslateX).toDouble()); return pDoubleSpinBox; } case MetaTreeItemTypes::SurfaceTranslateY: { QDoubleSpinBox* pDoubleSpinBox = new QDoubleSpinBox(parent); connect(pDoubleSpinBox, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), this, &Data3DTreeDelegate::onEditorEdited); pDoubleSpinBox->setMinimum(-10000.0); pDoubleSpinBox->setMaximum(10000.0); pDoubleSpinBox->setSingleStep(0.01); pDoubleSpinBox->setValue(index.model()->data(index, MetaTreeItemRoles::SurfaceTranslateY).toDouble()); return pDoubleSpinBox; } case MetaTreeItemTypes::SurfaceTranslateZ: { QDoubleSpinBox* pDoubleSpinBox = new QDoubleSpinBox(parent); connect(pDoubleSpinBox, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), this, &Data3DTreeDelegate::onEditorEdited); pDoubleSpinBox->setMinimum(-10000.0); pDoubleSpinBox->setMaximum(10000.0); pDoubleSpinBox->setSingleStep(0.01); pDoubleSpinBox->setValue(index.model()->data(index, MetaTreeItemRoles::SurfaceTranslateZ).toDouble()); return pDoubleSpinBox; } case MetaTreeItemTypes::NetworkThreshold: { Spline* pSpline = new Spline("Spline Histogram", 0); connect(pSpline, static_cast<void (Spline::*)(double, double, double)>(&Spline::borderChanged), this, &Data3DTreeDelegate::onEditorEdited); QStandardItem* pParentItem = static_cast<QStandardItem*>(pAbstractItem->QStandardItem::parent()); QModelIndex indexParent = pData3DTreeModel->indexFromItem(pParentItem); MatrixXd matRTData = index.model()->data(indexParent, Data3DTreeModelItemRoles::NetworkDataMatrix).value<MatrixXd>(); Eigen::VectorXd resultClassLimit; Eigen::VectorXi resultFrequency; MNEMath::histcounts(matRTData, false, 50, resultClassLimit, resultFrequency, 0.0, 0.0); pSpline->setData(resultClassLimit, resultFrequency, 0); QVector3D vecThresholdValues = index.model()->data(index, MetaTreeItemRoles::NetworkThreshold).value<QVector3D>(); pSpline->setThreshold(vecThresholdValues); return pSpline; } case MetaTreeItemTypes::NetworkMatrix: { QStandardItem* pParentItem = static_cast<QStandardItem*>(pAbstractItem->QStandardItem::parent()); QModelIndex indexParent = pData3DTreeModel->indexFromItem(pParentItem); MatrixXd matRTData = index.model()->data(indexParent, Data3DTreeModelItemRoles::NetworkDataMatrix).value<MatrixXd>(); ImageSc* pPlotLA = new ImageSc(matRTData); pPlotLA->show(); //return pPlotLA; } default: // do nothing; break; } return QItemDelegate::createEditor(parent, option, index); }
bool CDlgAlmCO2::eventFilter(QObject *o,QEvent *e) { QObject *obj[]={ m_cmbb_huxilv ,m_spb_huxi_high ,m_spb_huxi_low ,m_cmbb_hu ,m_spb_hu_high ,m_spb_hu_low ,m_cmbb_xi ,m_spb_xi_high ,m_spb_xi_low ,m_btn_ok, m_btn_cancel }; int iTotalObj = 11;//11 int iOkPos = iTotalObj -2; int iCancelPos = iTotalObj -1; if(e->type() == QEvent::KeyPress) { QKeyEvent *event=(QKeyEvent *)e; switch (event->key()) { case Qt::Key_Up: case Qt::Key_Left: if(bCursorSta == false) { if(iCursor == 0) { iCursor = iTotalObj-1; } else { iCursor -=1; } if((iCursor>=0) &&(iCursor<iOkPos)) { QComboBox *p = (QComboBox *)obj[iCursor]; p->setFocus(); } else { QPushButton *p = (QPushButton *)obj[iCursor]; p->setFocus(); } } else { if((iCursor == 1)|| (iCursor == 5)|| (iCursor == 2)|| (iCursor == 4)|| (iCursor == 7)|| (iCursor == 8) ) { QSpinBox *p = (QSpinBox *)obj[iCursor]; if(p->value()!= p->minimum()) { p->setValue(p->value()-1); } else { p->setValue(p->maximum()); } } } return true; break; case Qt::Key_Down: case Qt::Key_Right: if(bCursorSta == false) { if(iCursor == iTotalObj-1) { iCursor = 0; } else { iCursor +=1; } if((iCursor>=0) &&(iCursor<(iOkPos-1))) { QComboBox *p = (QComboBox *)obj[iCursor]; p->setFocus(); } else { QPushButton *p = (QPushButton *)obj[iCursor]; p->setFocus(); } } else { if((iCursor == 1)|| (iCursor == 5)|| (iCursor == 2)|| (iCursor == 4)|| (iCursor == 7)|| (iCursor == 8) ) { QSpinBox *p = (QSpinBox *)obj[iCursor]; if(p->value()!= p->maximum()) { p->setValue(p->value()+1); } else { p->setValue(p->minimum()); } } } return true; break; case Qt::Key_Return: if(bCursorSta == false) { if(iCursor == iOkPos) { do_ok_clicked(); } else if(iCursor == iCancelPos) { do_cancel_clicked(); } else if((iCursor==0) ||(iCursor==3)||(iCursor==6)) { //btn[iCursor]->showPopup(); bCursorSta = false; QComboBox *p = (QComboBox *)obj[iCursor]; p->showPopup(); //p->setStyleSheet("background-color: rgb(35, 53, 234,255);"); } else if((iCursor == 1)|| (iCursor == 5)|| (iCursor == 2)|| (iCursor == 4)|| (iCursor == 7)|| (iCursor == 8) ) { bCursorSta = true; QSpinBox *p = (QSpinBox *)obj[iCursor]; } } else { bCursorSta = false; } return true; break; default: CMainForm *p = (CMainForm *)pMainForm; p->f_process_key(event->key()); return true; break; } } else { return false; } }
void Data3DTreeDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const { const Data3DTreeModel* pData3DTreeModel = static_cast<const Data3DTreeModel*>(index.model()); const AbstractTreeItem* pAbstractItem = static_cast<const AbstractTreeItem*>(pData3DTreeModel->itemFromIndex(index)); switch(pAbstractItem->type()) { case MetaTreeItemTypes::SurfaceColorGyri: { QColor color = index.model()->data(index, MetaTreeItemRoles::SurfaceColorGyri).value<QColor>(); QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor); pColorDialog->setCurrentColor(color); break; } case MetaTreeItemTypes::SurfaceColorSulci: { QColor color = index.model()->data(index, MetaTreeItemRoles::SurfaceColorSulci).value<QColor>(); QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor); pColorDialog->setCurrentColor(color); break; } case MetaTreeItemTypes::RTDataColormapType: { QString colormap = index.model()->data(index, MetaTreeItemRoles::RTDataColormapType).toString(); QComboBox* pComboBox = static_cast<QComboBox*>(editor); pComboBox->setCurrentText(colormap); break; } case MetaTreeItemTypes::RTDataNormalizationValue: { Spline* pSpline = static_cast<Spline*>(editor); int width = pSpline->size().width(); int height = pSpline->size().height(); if (pSpline->size().width() < 200 && pSpline->size().height() < 200) { pSpline->resize(600,400); //resize histogram to be readable with default size } else { width = pSpline->size().width(); //keeps the size of the histogram height = pSpline->size().height(); pSpline->resize(width,height); } return; } case MetaTreeItemTypes::RTDataTimeInterval: { int value = index.model()->data(index, MetaTreeItemRoles::RTDataTimeInterval).toInt(); QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor); pSpinBox->setValue(value); break; } case MetaTreeItemTypes::RTDataVisualizationType: { QString visType = index.model()->data(index, MetaTreeItemRoles::RTDataVisualizationType).toString(); QComboBox* pComboBox = static_cast<QComboBox*>(editor); pComboBox->setCurrentText(visType); break; } case MetaTreeItemTypes::SurfaceColor: { QColor color = index.model()->data(index, MetaTreeItemRoles::SurfaceColor).value<QColor>(); QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor); pColorDialog->setCurrentColor(color); break; } case MetaTreeItemTypes::PointColor: { QColor color = index.model()->data(index, MetaTreeItemRoles::PointColor).value<QColor>(); QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor); pColorDialog->setCurrentColor(color); break; } case MetaTreeItemTypes::RTDataNumberAverages: { int value = index.model()->data(index, MetaTreeItemRoles::RTDataNumberAverages).toInt(); QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor); pSpinBox->setValue(value); break; } case MetaTreeItemTypes::SurfaceAlpha: { int value = index.model()->data(index, MetaTreeItemRoles::SurfaceAlpha).toDouble(); QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor); pSpinBox->setValue(value); break; } case MetaTreeItemTypes::SurfaceTranslateX: { double value = index.model()->data(index, MetaTreeItemRoles::SurfaceTranslateX).toDouble(); QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor); pDoubleSpinBox->setValue(value); break; } case MetaTreeItemTypes::SurfaceTranslateY: { double value = index.model()->data(index, MetaTreeItemRoles::SurfaceTranslateY).toDouble(); QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor); pDoubleSpinBox->setValue(value); break; } case MetaTreeItemTypes::SurfaceTranslateZ: { double value = index.model()->data(index, MetaTreeItemRoles::SurfaceTranslateZ).toDouble(); QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor); pDoubleSpinBox->setValue(value); break; } case MetaTreeItemTypes::NetworkThreshold: { Spline* pSpline = static_cast<Spline*>(editor); int width = pSpline->size().width(); int height = pSpline->size().height(); if (pSpline->size().width() < 200 && pSpline->size().height() < 200) //pSpline initializes with size (137,15) { pSpline->resize(800,600); //resize histogram to be readable with default size } else { width = pSpline->size().width(); //keeps the size of the histogram height = pSpline->size().height(); pSpline->resize(width,height); } return; } default: // do nothing; break; } QItemDelegate::setEditorData(editor, index); }
void HardDiskDialog::userSetupChangedIndex(int index) { QComboBox* box = (QComboBox*) sender(); QStringList userData = box->itemData(index).toStringList(); userMapping.insert(userData.at(0), userData.at(1)); }
Player::Player(QWidget* parent) { src = NULL; audio = NULL; volume = 10; elapsedSec = 0; layout = new QVBoxLayout(parent); QHBoxLayout* h = new QHBoxLayout(parent); layout->addLayout(h); // source name label QLabel* l = new QLabel(parent); l->setFont(QFont("Courier")); connect(this, SIGNAL(showElapsed(const QString&)) , l, SLOT(setText(const QString&))); h->addWidget(l); // Play/Pause button QIcon ico; QStyle* style = QApplication::style(); QIcon ic = style->standardIcon(QStyle::SP_MediaPlay); QPixmap px = ic.pixmap(16); ico.addPixmap(px, QIcon::Normal, QIcon::On); ic = style->standardIcon(QStyle::SP_MediaPause); px = ic.pixmap(16); ico.addPixmap(px, QIcon::Normal, QIcon::Off); QPushButton* b = new QPushButton(parent); b->setCheckable(true); b->setIcon(ico); connect(b, SIGNAL(toggled(bool)), this, SLOT(onPlayToggled(bool))); connect(this, SIGNAL(setEnabled(bool)), b, SLOT(setEnabled(bool))); connect(this, SIGNAL(setPaused(bool)), b, SLOT(setChecked(bool))); h->addWidget(b); // Stop button ico = style->standardIcon(QStyle::SP_MediaStop); b = new QPushButton(parent); b->setIcon(ico); connect(b, SIGNAL(clicked()), this, SLOT(onStopClicked())); connect(this, SIGNAL(setEnabled(bool)), b, SLOT(setEnabled(bool))); h->addWidget(b); // Volume slider ico = style->standardIcon(QStyle::SP_MediaVolume); l = new QLabel(parent); l->setPixmap(ico.pixmap(16)); h->addWidget(l); QSlider* slider = new QSlider(Qt::Horizontal); connect(slider, SIGNAL(valueChanged(int)), this, SLOT(onVolumeChanged(int))); h->addWidget(slider); //QStyle::SP_MediaVolumeMuted QList<QAudioDeviceInfo> al = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput); if (al.size() > 1) { QComboBox* cb = new QComboBox(parent); for (QList<QAudioDeviceInfo>::const_iterator i = al.begin(); i != al.end(); i++) { const QAudioDeviceInfo& info = *i; cb->addItem(info.deviceName()); } connect(cb, SIGNAL(currentIndexChanged(const QString&)) , this, SLOT(onDeviceChanged(const QString&))); h->addWidget(cb); }
OperatorOverlay::OperatorOverlay() : GUIPlugin() { init(); this->counter = 0; // Set the frame background and foreground colors this->setStyleSheet( "QFrame { background-color : rgba(100, 100, 100, 255); color : white; }"); // Create the main layout QHBoxLayout *mainLayout = new QHBoxLayout; // Create the frame to hold all the widgets QFrame *mainFrame = new QFrame(); // Create the layout that sits inside the frame QVBoxLayout *frameLayout = new QVBoxLayout(); // ACTIONS chooser QLabel *operatorLabel = new QLabel(tr("Operator:")); frameLayout->addWidget(operatorLabel); QPushButton *setTargetButton = new QPushButton(tr("Selection to Target")); connect(setTargetButton, SIGNAL(clicked()), this, SLOT(setTarget())); frameLayout->addWidget(setTargetButton); targetLabel = new QLineEdit(tr("target_name")); targetLabel->setEnabled(false); frameLayout->addWidget(targetLabel); QPushButton *MoveToButton = new QPushButton( "Move To"); MoveToButton->setCheckable( true ); connect(MoveToButton, SIGNAL(clicked()), this, SLOT(moveOperator())); frameLayout->addWidget(MoveToButton); // ROBOT chooser QLabel *robotLabel = new QLabel(tr("Robot:")); frameLayout->addWidget(robotLabel); QComboBox *robotChooser = new QComboBox(); robotChooser->addItem("ALL"); robotChooser->addItem("A"); robotChooser->addItem("Donkey"); robotChooser->addItem("Hawk"); robotChooser->addItem("Wasp1"); robotChooser->addItem("Wasp2"); robotChooser->addItem("Wasp3"); robotChooser->addItem("Wasp4"); ///FIXME add SIGNAL frameLayout->addWidget(robotChooser); // ACTIONS chooser QLabel *actionLabel = new QLabel(tr("Commands:")); frameLayout->addWidget(actionLabel); QComboBox *actionChooser = new QComboBox(); actionChooser->addItem("Perceive"); actionChooser->addItem("Search"); actionChooser->addItem("Recharge"); actionChooser->addItem("Drop box"); actionChooser->addItem("Pick up box"); actionChooser->addItem("Follow e"); actionChooser->addItem("Come Here"); frameLayout->addWidget(actionChooser); QPushButton *executeAction = new QPushButton(tr("Execute")); //connect(button2, SIGNAL(clicked()), this, SLOT(OnButton())); frameLayout->addWidget(executeAction); ///LOGGING QLabel *logLayout = new QLabel("Logging:"); frameLayout->addWidget(logLayout); QPushButton *logButton = new QPushButton( "Logging!"); logButton->setCheckable( true ); frameLayout->addWidget(logButton); QPushButton *exportButton = new QPushButton(tr("Export log")); //connect(button2, SIGNAL(clicked()), this, SLOT(OnButton())); frameLayout->addWidget(exportButton); // Add frameLayout to the frame mainFrame->setLayout(frameLayout); // Add the frame to the main layout mainLayout->addWidget(mainFrame); // Remove margins to reduce space frameLayout->setContentsMargins(0, 0, 0, 0); mainLayout->setContentsMargins(0, 0, 0, 0); this->setLayout(mainLayout); // Position and resize this widget this->move(10, 10); this->resize(120, 300); // Create a node for transportation this->node = transport::NodePtr(new transport::Node()); this->node->Init(); selectionSub = this->node->Subscribe("~/selection", & OperatorOverlay::selectionChanged, this); this->factoryPub = this->node->Advertise<msgs::Factory>("~/factory"); this->setMouseTracking(true); this->updateConnection = event::Events::ConnectWorldUpdateBegin( boost::bind(&OperatorOverlay::onUpdate, this, _1)); }
FollowStreamDialog::FollowStreamDialog(QWidget &parent, CaptureFile &cf, follow_type_t type) : WiresharkDialog(parent, cf), ui(new Ui::FollowStreamDialog), follow_type_(type), follower_(NULL), show_type_(SHOW_ASCII), truncated_(false), save_as_(false) { ui->setupUi(this); switch(type) { case FOLLOW_TCP: follower_ = get_follow_by_name("TCP"); break; case FOLLOW_SSL: follower_ = get_follow_by_name("SSL"); break; case FOLLOW_UDP: follower_ = get_follow_by_name("UDP"); break; case FOLLOW_HTTP: follower_ = get_follow_by_name("HTTP"); break; default : g_assert_not_reached(); } memset(&follow_info_, 0, sizeof(follow_info_)); follow_info_.show_stream = BOTH_HOSTS; ui->teStreamContent->installEventFilter(this); // XXX Use recent settings instead resize(parent.width() * 2 / 3, parent.height()); QComboBox *cbcs = ui->cbCharset; cbcs->blockSignals(true); cbcs->addItem(tr("ASCII"), SHOW_ASCII); cbcs->addItem(tr("C Arrays"), SHOW_CARRAY); cbcs->addItem(tr("EBCDIC"), SHOW_EBCDIC); cbcs->addItem(tr("Hex Dump"), SHOW_HEXDUMP); cbcs->addItem(tr("UTF-8"), SHOW_UTF8); cbcs->addItem(tr("YAML"), SHOW_YAML); cbcs->addItem(tr("Raw"), SHOW_RAW); cbcs->blockSignals(false); b_filter_out_ = ui->buttonBox->addButton(tr("Hide this stream"), QDialogButtonBox::ActionRole); connect(b_filter_out_, SIGNAL(clicked()), this, SLOT(filterOut())); b_print_ = ui->buttonBox->addButton(tr("Print"), QDialogButtonBox::ActionRole); connect(b_print_, SIGNAL(clicked()), this, SLOT(printStream())); b_save_ = ui->buttonBox->addButton(tr("Save as" UTF8_HORIZONTAL_ELLIPSIS), QDialogButtonBox::ActionRole); connect(b_save_, SIGNAL(clicked()), this, SLOT(saveAs())); ProgressFrame::addToButtonBox(ui->buttonBox, &parent); connect(ui->buttonBox, SIGNAL(helpRequested()), this, SLOT(helpButton())); connect(ui->teStreamContent, SIGNAL(mouseMovedToTextCursorPosition(int)), this, SLOT(fillHintLabel(int))); connect(ui->teStreamContent, SIGNAL(mouseClickedOnTextCursorPosition(int)), this, SLOT(goToPacketForTextPos(int))); connect(&cap_file_, SIGNAL(captureFileClosing()), this, SLOT(captureFileClosing())); fillHintLabel(-1); }
QList<QPair<QLabel*, QWidget*> > QgsVectorLayerSaveAsDialog::createControls( const QMap<QString, QgsVectorFileWriter::Option*>& options ) { QList<QPair<QLabel*, QWidget*> > controls; QMap<QString, QgsVectorFileWriter::Option*>::ConstIterator it; for ( it = options.constBegin(); it != options.constEnd(); ++it ) { QgsVectorFileWriter::Option *option = it.value(); QLabel *label = new QLabel( it.key() ); QWidget *control = nullptr; switch ( option->type ) { case QgsVectorFileWriter::Int: { QgsVectorFileWriter::IntOption *opt = dynamic_cast<QgsVectorFileWriter::IntOption*>( option ); if ( opt ) { QSpinBox *sb = new QSpinBox(); sb->setObjectName( it.key() ); sb->setValue( opt->defaultValue ); control = sb; } break; } case QgsVectorFileWriter::Set: { QgsVectorFileWriter::SetOption *opt = dynamic_cast<QgsVectorFileWriter::SetOption*>( option ); if ( opt ) { QComboBox* cb = new QComboBox(); cb->setObjectName( it.key() ); Q_FOREACH ( const QString& val, opt->values ) { cb->addItem( val, val ); } if ( opt->allowNone ) cb->addItem( tr( "<Default>" ), QVariant( QVariant::String ) ); int idx = cb->findText( opt->defaultValue ); if ( idx == -1 ) idx = cb->findData( QVariant( QVariant::String ) ); cb->setCurrentIndex( idx ); control = cb; } break; } case QgsVectorFileWriter::String: { QgsVectorFileWriter::StringOption *opt = dynamic_cast<QgsVectorFileWriter::StringOption*>( option ); if ( opt ) { QLineEdit* le = new QLineEdit( opt->defaultValue ); le->setObjectName( it.key() ); control = le; } break; } case QgsVectorFileWriter::Hidden: control = nullptr; break; } if ( control ) { // Pack the tooltip in some html element, so it gets linebreaks. label->setToolTip( QString( "<p>%1</p>" ).arg( option->docString ) ); control->setToolTip( QString( "<p>%1</p>" ).arg( option->docString ) ); controls << QPair<QLabel*, QWidget*>( label, control ); } } return controls; }
SequenceDialog::SequenceDialog(QWidget &parent, CaptureFile &cf, SequenceInfo *info) : WiresharkDialog(parent, cf), ui(new Ui::SequenceDialog), info_(info), num_items_(0), packet_num_(0), sequence_w_(1) { ui->setupUi(this); loadGeometry(parent.width(), parent.height() * 4 / 5); QCustomPlot *sp = ui->sequencePlot; setWindowSubtitle(info_ ? tr("Call Flow") : tr("Flow")); if (!info_) { info_ = new SequenceInfo(sequence_analysis_info_new()); info_->sainfo()->type = SEQ_ANALYSIS_ANY; info_->sainfo()->all_packets = TRUE; } else { info_->ref(); num_items_ = sequence_analysis_get_nodes(info_->sainfo()); } seq_diagram_ = new SequenceDiagram(sp->yAxis, sp->xAxis2, sp->yAxis2); sp->addPlottable(seq_diagram_); // When dragging is enabled it's easy to drag past the lower and upper // bounds of each axis. Disable it for now. //sp->axisRect()->setRangeDragAxes(sp->xAxis2, sp->yAxis); //sp->setInteractions(QCP::iRangeDrag); sp->xAxis->setVisible(false); sp->xAxis->setPadding(0); sp->xAxis->setLabelPadding(0); sp->xAxis->setTickLabelPadding(0); QPen base_pen(ColorUtils::alphaBlend(palette().text(), palette().base(), 0.25)); base_pen.setWidthF(0.5); sp->xAxis2->setBasePen(base_pen); sp->yAxis->setBasePen(base_pen); sp->yAxis2->setBasePen(base_pen); sp->xAxis2->setVisible(true); sp->yAxis2->setVisible(true); key_text_ = new QCPItemText(sp); key_text_->setText(tr("Time")); sp->addItem(key_text_); key_text_->setPositionAlignment(Qt::AlignRight | Qt::AlignVCenter); key_text_->position->setType(QCPItemPosition::ptAbsolute); key_text_->setClipToAxisRect(false); comment_text_ = new QCPItemText(sp); comment_text_->setText(tr("Comment")); sp->addItem(comment_text_); comment_text_->setPositionAlignment(Qt::AlignLeft | Qt::AlignVCenter); comment_text_->position->setType(QCPItemPosition::ptAbsolute); comment_text_->setClipToAxisRect(false); one_em_ = QFontMetrics(sp->yAxis->labelFont()).height(); ui->horizontalScrollBar->setSingleStep(100 / one_em_); ui->verticalScrollBar->setSingleStep(100 / one_em_); ui->gridLayout->setSpacing(0); connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), sp->yAxis2, SLOT(setRange(QCPRange))); ctx_menu_.addAction(ui->actionReset); ctx_menu_.addSeparator(); ctx_menu_.addAction(ui->actionMoveRight10); ctx_menu_.addAction(ui->actionMoveLeft10); ctx_menu_.addAction(ui->actionMoveUp10); ctx_menu_.addAction(ui->actionMoveDown10); ctx_menu_.addAction(ui->actionMoveRight1); ctx_menu_.addAction(ui->actionMoveLeft1); ctx_menu_.addAction(ui->actionMoveUp1); ctx_menu_.addAction(ui->actionMoveDown1); ctx_menu_.addSeparator(); ctx_menu_.addAction(ui->actionGoToPacket); ctx_menu_.addAction(ui->actionGoToNextPacket); ctx_menu_.addAction(ui->actionGoToPreviousPacket); ui->showComboBox->setCurrentIndex(0); ui->addressComboBox->setCurrentIndex(0); QComboBox *fcb = ui->flowComboBox; fcb->addItem(ui->actionFlowAny->text(), SEQ_ANALYSIS_ANY); fcb->addItem(ui->actionFlowTcp->text(), SEQ_ANALYSIS_TCP); ui->flowComboBox->setCurrentIndex(info_->sainfo()->type); if (info_->sainfo()->type == SEQ_ANALYSIS_VOIP) { ui->flowComboBox->blockSignals(true); ui->controlFrame->hide(); } QPushButton *save_bt = ui->buttonBox->button(QDialogButtonBox::Save); save_bt->setText(tr("Save As" UTF8_HORIZONTAL_ELLIPSIS)); ProgressFrame::addToButtonBox(ui->buttonBox, &parent); connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(hScrollBarChanged(int))); connect(ui->verticalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(vScrollBarChanged(int))); connect(sp->xAxis2, SIGNAL(rangeChanged(QCPRange)), this, SLOT(xAxisChanged(QCPRange))); connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(yAxisChanged(QCPRange))); connect(sp, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(diagramClicked(QMouseEvent*))); connect(sp, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoved(QMouseEvent*))); connect(sp, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheeled(QWheelEvent*))); connect(this, SIGNAL(goToPacket(int)), seq_diagram_, SLOT(setSelectedPacket(int))); disconnect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); }
void PropertiesManager::createEmptySelectionProperties() { root->addItemsToolbar->addAction(root->actionAddRegime); root->actionMove_Up->setEnabled(false); root->actionMove_Down->setEnabled(false); root->actionDeleteItems->setEnabled(false); //component name QLabel *label = new QLabel("<b>Component Class</b>"); addRow(label); QLineEdit *edit_name = new QLineEdit(); edit_name->installEventFilter(&eventFilterObject); edit_name->setValidator(componentNameValidator); edit_name->setText(root->al->name); connect(edit_name, SIGNAL(textEdited(QString)), root, SLOT(setComponentClassName(QString))); addRow(tr("&Name:"),edit_name); //component type QComboBox *type = new QComboBox(); type->addItem("neuron_body"); type->addItem("weight_update"); type->addItem("postsynapse"); type->addItem("generic_component"); int typeVal; if (root->al->type == "neuron_body") typeVal = 0; if (root->al->type == "weight_update") typeVal = 1; if (root->al->type == "postsynapse") typeVal = 2; if (root->al->type == "generic_component") typeVal = 3; type->setCurrentIndex(typeVal); connect(type, SIGNAL(currentIndexChanged(QString)), root, SLOT(setComponentClassType(QString))); addRow(tr("&Component Type:"),type); //initial regime QComboBox *initial_regime = new QComboBox(); bool match_init_r = false; for (uint i=0; i<root->al->RegimeList.size(); i++){ initial_regime->addItem(root->al->RegimeList[i]->name); if (root->al->initial_regime == root->al->RegimeList[i]){ initial_regime->setCurrentIndex(i); match_init_r = true; } } if (!match_init_r){ initial_regime->setCurrentIndex(-1); } connect(initial_regime, SIGNAL(currentIndexChanged(QString)), root, SLOT(setInitialRegime(QString))); addRow(tr("&Initial Regime:"),initial_regime); // add path combobox - NO LONGER USED /*QComboBox * path = new QComboBox; path->addItem("model"); path->addItem("temp"); path->addItem("lib"); path->setToolTip("Store the component externally as a file (temp) or internally in the library (lib)"); // select current path - NO LONGER USED if (root->al->path == "") root->al->path = "temp"; if (root->al->path == "model") path->setCurrentIndex(0); else if (root->al->path == "temp") path->setCurrentIndex(1); else if (root->al->path == "lib") path->setCurrentIndex(2); // disable model path QModelIndex ind = path->model()->index(0,0); path->model()->setData(ind, QVariant(0), Qt::UserRole-1); addRow(tr("Path"), path); connect(path, SIGNAL(currentIndexChanged(QString)), root, SLOT(setPath(QString)));*/ QPushButton * duplicate = new QPushButton("Duplicate component"); connect(duplicate, SIGNAL(clicked()), root->main, SLOT(duplicate_component())); addWidget(duplicate); QPushButton * remove = new QPushButton("Remove component"); connect(remove, SIGNAL(clicked()), root, SLOT(deleteComponent())); addWidget(remove); }