Пример #1
0
void ContourLinesEditor::insertLevel()
{
	if (!d_spectrogram)
		return;

	int row = table->currentRow();
	DoubleSpinBox *sb = (DoubleSpinBox*)table->cellWidget(row, 0);
	if (!sb)
		return;

	QwtDoubleInterval range = d_spectrogram->data().range();
	double current_value = sb->value();
	double previous_value = range.minValue ();
	sb = (DoubleSpinBox*)table->cellWidget(row - 1, 0);
	if (sb)
		previous_value = sb->value();

	double val = 0.5*(current_value + previous_value);

	table->blockSignals(true);
	table->insertRow(row);

	sb = new DoubleSpinBox();
	sb->setLocale(d_locale);
	sb->setDecimals(d_precision);
	sb->setValue(val);
	sb->setRange(range.minValue (), range.maxValue ());
	connect(sb, SIGNAL(activated(DoubleSpinBox *)), this, SLOT(spinBoxActivated(DoubleSpinBox *)));
    table->setCellWidget(row, 0, sb);

	QPen pen = d_spectrogram->defaultContourPen();
	if (pen.style() == Qt::NoPen)
		pen = d_spectrogram->contourPen (val);

	int width = 80;
	int height = 20;
	QPixmap pix(width, height);
	pix.fill(Qt::white);
	QPainter paint(&pix);
	paint.setRenderHint(QPainter::Antialiasing);
	paint.setPen(pen);
	paint.drawLine(0, height/2, width, height/2);
	paint.end();

	QLabel *lbl = new QLabel();
	lbl->setPixmap(pix);

	table->setCellWidget(row, 1, lbl);
	table->blockSignals(false);

	enableButtons(table->currentRow());
	d_pen_list.insert(row, pen);
}
Пример #2
0
void ColorMapEditor::insertLevel()
{
  int row = table->currentRow();
  DoubleSpinBox *sb = (DoubleSpinBox*)table->cellWidget(row, 0);
  if (!sb)
    return;

  double current_value = sb->value();
  double previous_value = min_val;
  sb = (DoubleSpinBox*)table->cellWidget(row - 1, 0);
  if (sb)
    previous_value = sb->value();

  double val = 0.5*(current_value + previous_value);
  QwtDoubleInterval range = QwtDoubleInterval(min_val, max_val);
  double mapped_val = (val - min_val)/range.width();

  QColor c = QColor(color_map.rgb(QwtDoubleInterval(0, 1), mapped_val));

  table->blockSignals(true);
  table->insertRow(row);

  sb = new DoubleSpinBox();
  sb->setLocale(d_locale);
  sb->setDecimals(d_precision);
  sb->setValue(val);
  sb->setRange(min_val, max_val);
  connect(sb, SIGNAL(valueChanged(double)), this, SLOT(updateColorMap()));
  connect(sb, SIGNAL(activated(DoubleSpinBox *)), this, SLOT(spinBoxActivated(DoubleSpinBox *)));
  table->setCellWidget(row, 0, sb);

  QTableWidgetItem *it = new QTableWidgetItem(c.name());
// Avoid compiler warning
//#ifdef Q_CC_MSVC
  it->setFlags(it->flags() & (~Qt::ItemIsEditable));
//#else
//  it->setFlags(!Qt::ItemIsEditable);
//#endif
  it->setBackground(QBrush(c));
  it->setForeground(QBrush(c));
  table->setItem(row, 1, it);
  table->blockSignals(false);

  enableButtons(table->currentRow());
  updateColorMap();
}
void DoubleSpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
                                         const QModelIndex &index) const
{
    DoubleSpinBox *spinBox = static_cast<DoubleSpinBox*>(editor);
    spinBox->interpretText();
	double value = spinBox->value();

    model->setData(index, value, Qt::EditRole);
}
Пример #4
0
void ContourLinesEditor::updateContourLevels()
{
	if (!d_spectrogram)
		return;

	int rows = table->rowCount();
	QwtValueList levels;
  for (int i = 0; i < rows; i++) {
    DoubleSpinBox *spinBox =
        dynamic_cast<DoubleSpinBox *>(table->cellWidget(i, 0));
    if (spinBox)
      levels << spinBox->value();
  }

  d_spectrogram->setContourLevels(levels);
}
        void restoreState(const Archive& archive){
            timeScaleRatioSpin.setValue(archive.get("timeScaleRatio", timeScaleRatioSpin.value()));
            preInitialDurationSpin.setValue(archive.get("preInitialDuration", preInitialDurationSpin.value()));
            postFinalDurationSpin.setValue(archive.get("postFinalDuration", postFinalDurationSpin.value()));
            onlyTimeBarRangeCheck.setChecked(archive.get("onlyTimeBarRange", onlyTimeBarRangeCheck.isChecked()));
            newBodyItemCheck.setChecked(archive.get("makeNewBodyItem", newBodyItemCheck.isChecked()));
            stealthyStepCheck.setChecked(archive.get("stealthyStepMode", stealthyStepCheck.isChecked()));
            stealthyHeightRatioThreshSpin.setValue(archive.get("stealthyHeightRatioThresh", stealthyHeightRatioThreshSpin.value()));
            flatLiftingHeightSpin.setValue(archive.get("flatLiftingHeight", flatLiftingHeightSpin.value()));
            flatLandingHeightSpin.setValue(archive.get("flatLandingHeight", flatLandingHeightSpin.value()));
            impactReductionHeightSpin.setValue(archive.get("impactReductionHeight", impactReductionHeightSpin.value()));
            impactReductionTimeSpin.setValue(archive.get("impactReductionTime", impactReductionTimeSpin.value()));

            autoZmpCheck.setChecked(archive.get("autoZmp", autoZmpCheck.isChecked()));
            minZmpTransitionTimeSpin.setValue(archive.get("minZmpTransitionTime", minZmpTransitionTimeSpin.value()));
            zmpCenteringTimeThreshSpin.setValue(archive.get("zmpCenteringTimeThresh", zmpCenteringTimeThreshSpin.value()));
            zmpTimeMarginBeforeLiftingSpin.setValue(archive.get("zmpTimeMarginBeforeLiftingSpin", zmpTimeMarginBeforeLiftingSpin.value()));
            
            se3Check.setChecked(archive.get("allLinkPositions", se3Check.isChecked()));
            lipSyncMixCheck.setChecked(archive.get("lipSyncMix", lipSyncMixCheck.isChecked()));
        }
Пример #6
0
void SettingsDelegate::setModelData(QWidget* editor,
                                    QAbstractItemModel* model,
                                    const QModelIndex& index) const
{
    // Get the setting type.
    int type = index.model()->data(index, SettingsModel::TypeRole).toInt();

    // Get the editor data.
    QVariant value;
    switch (type)
    {
        case SettingsValue::INT:
        case SettingsValue::UNSIGNED_INT:
        case SettingsValue::INT_POSITIVE:
        {
            // Spin box editors.
            value = static_cast<QSpinBox*>(editor)->value();
            break;
        }
        case SettingsValue::DOUBLE:
        case SettingsValue::UNSIGNED_DOUBLE:
        case SettingsValue::DOUBLE_RANGE:
        {
            // Double spin box editors.
            value = static_cast<DoubleSpinBox*>(editor)->cleanText();
            break;
        }
        case SettingsValue::DOUBLE_RANGE_EXT:
        {
            // Double spin box editors.
            DoubleSpinBox* e = static_cast<DoubleSpinBox*>(editor);
            double v = e->value();
            value = e->value();
            if (v <= e->rangeMin())
                value = e->minText();
            else
                value = e->cleanText();
            break;
        }
        case SettingsValue::DATE_TIME:
        {
            // Date and time editors.
            value = static_cast<QLineEdit*>(editor)->text();
            // Validate these strings...
            //      d-M-yyyy h:m:s.z
            //      yyyy/M/d/h:m:s.z
            //      yyyy-M-d h:m:s.z
            //      yyyy-M-dTh:m:s.z
            //      MJD.fraction
            QString h = "([01]?[0-9]|2[0-3])";       // 00-23
            QString m = "[0-5]?[0-9]";               // 00-59
            QString s = m;
            QString z = "(\\.\\d{1,3})?";            // 000-999
            QString d = "(0?[1-9]|[12][0-9]|3[01])"; // 01-31
            QString M = "(|1[0-2]|0?[1-9]|)";        // 01-12
            QString y = "\\d{4,4}";                  // yyyy
            QString rtime  = h+":"+m+":"+s+z;        // h:m:s.zzz
            QString rdate1 = "("+d+"-"+M+"-"+y+"\\s"+rtime+")";
            QString rdate2 = "("+y+"/"+M+"/"+d+"/"+rtime+")";
            QString rdate3 = "("+y+"-"+M+"-"+d+"\\s"+rtime+")";
            QString rdate4 = "("+y+"-"+M+"-"+d+"T"+rtime+")";
            QString rdate5 = "(\\d+\\.?\\d*)";
            QString rdate6 = "(\\d+\\.?\\d*[e|E]-?\\d{1,2})";
            QString rdatetime = rdate1+"|"+rdate2+"|"+rdate3+"|"+rdate4+
                            "|"+rdate5+"|"+rdate6;
            QRegExpValidator validator(QRegExp(rdatetime), 0);
            int pos = 0;
            QString v = value.toString();
            if (validator.validate(v, pos) != QValidator::Acceptable &&
                            !v.isEmpty()) {
                cerr << "WARNING: DateTime value failed to validate." << endl;
                return;
            }
            break;
        }
        case SettingsValue::TIME:
        {
            // Time editors.
            value = static_cast<QLineEdit*>(editor)->text();
            QString h = "(\\d+)";                    // >= 0
            QString m = "[0-5]?[0-9]";               // 00-59
            QString s = m;
            QString z = "(\\.\\d{1,8})?";            // 000-99999999
            QString rtime  = h+":"+m+":"+s+z;        // h:m:s.zzz
            QString sec    = "(\\d+\\.?\\d*)";
            QString exp_sec = "(\\d+\\.?\\d*[e|E]-?\\d{1,2})";
            QRegExpValidator validator(QRegExp(rtime+"|"+sec+"|"+exp_sec), 0);
            int pos = 0;
            QString v = value.toString();
            if (validator.validate(v, pos) != QValidator::Acceptable &&
                            !v.isEmpty()) {
                cerr << "WARNING: Time value failed to validate." << endl;
                return;
            }
            break;
        }
        case SettingsValue::RANDOM_SEED:
        {
            // Random seed editors.
            int val = static_cast<QSpinBox*>(editor)->value();
            if (val < 1)
                value = static_cast<QSpinBox*>(editor)->specialValueText();
            else
                value = val;
            break;
        }
        case SettingsValue::INT_RANGE_EXT:
        {
            // Random seed editors.
            int val = static_cast<QSpinBox*>(editor)->value();
            if (val < 0)
                value = static_cast<QSpinBox*>(editor)->specialValueText();
            else
                value = val;
            break;
        }
        case SettingsValue::OPTION_LIST:
        {
            // Options list.
            value = static_cast<QComboBox*>(editor)->currentText();
            break;
        }
        default:
        {
            value = static_cast<QLineEdit*>(editor)->text();
            break;
        }
    }

    model->setData(index, value, Qt::EditRole);
}
Пример #7
0
 void restoreState(const Archive& archive){
     snapDistanceSpin.setValue(archive.get("snapDistance", snapDistanceSpin.value()));
     penetrationBlockDepthSpin.setValue(archive.get("penetrationBlockDepth", penetrationBlockDepthSpin.value()));
     lazyCollisionDetectionModeCheck.setChecked(archive.get("lazyCollisionDetectionMode", lazyCollisionDetectionModeCheck.isChecked()));
 }
Пример #8
0
 void storeState(Archive& archive){
     archive.write("snapDistance", snapDistanceSpin.value());
     archive.write("penetrationBlockDepth", penetrationBlockDepthSpin.value());
     archive.write("lazyCollisionDetectionMode", lazyCollisionDetectionModeCheck.isChecked());
 }