ParameterStereogram::ParameterStereogram(std::tr1::shared_ptr<AbstractTexture> texture)
	: ParameterAbstractTexture(texture)
{
	QGroupBox * b = new QGroupBox(this);
	QGridLayout * g = new QGridLayout(b);
	b->setTitle(tr("Stereogram"));
	b->setLayout(g);
	g->addWidget(new QLabel(tr("Depth:")), 0, 0);
	g->addWidget(new QLabel(tr("Left:")), 1, 0);
	g->addWidget(new QLabel(tr("Right:")), 2, 0);
	g->addWidget(new QLabel(tr("Offset:")), 3, 0);
	linePathDepth_ = new QLineEdit();
	linePathLeft_ = new QLineEdit();
	linePathRight_ = new QLineEdit();
	pbDepth_ = new QPushButton("...");
	pbLeft_ = new QPushButton("...");
	pbRight_ = new QPushButton("...");
	pbDepth_->resize(26, 26);
	pbLeft_->resize(26, 26);
	pbRight_->resize(26, 26);
	lineOffset_ = new QLineEdit();
	lineOffset_->setAlignment(Qt::AlignRight);
	comboStyle_ = new QComboBox(this);
	comboStyle_->addItem("Convex");
	comboStyle_->addItem("Concave");
	g->addWidget(linePathDepth_, 0, 2, 1, 2);
	g->addWidget(linePathLeft_, 1, 2, 1, 2);
	g->addWidget(linePathRight_, 2, 2, 1, 2);
	g->addWidget(pbDepth_, 0, 4);
	g->addWidget(pbLeft_, 1, 4);
	g->addWidget(pbRight_, 2, 4);
	g->addWidget(lineOffset_, 3, 2, 1, 3);
	g->addWidget(comboStyle_, 4, 2, 1, 3);
	g->setRowStretch(5, 1);

	addWidget(b);

	connect(linePathDepth_, SIGNAL(editingFinished()),
			this, SLOT(pathDepthEdited()));
	connect(linePathLeft_, SIGNAL(editingFinished()),
			this, SLOT(pathLeftEdited()));
	connect(linePathRight_, SIGNAL(editingFinished()),
			this, SLOT(pathRightEdited()));
	connect(lineOffset_, SIGNAL(editingFinished()),
			this, SLOT(offsetEdited()));
	connect(comboStyle_, SIGNAL(activated(int)),
			this, SLOT(styleActivated(int)));
	connect(pbDepth_, SIGNAL(clicked()),
			this, SLOT(openDepth()));
	connect(pbLeft_, SIGNAL(clicked()),
			this, SLOT(openLeft()));
	connect(pbRight_, SIGNAL(clicked()),
			this, SLOT(openRight()));

	reloadData();
}
Beispiel #2
0
Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, FirmwareInterface * firmware):
  ModelPanel(parent, model, generalSettings, firmware)
{
  QGridLayout * gridLayout = new QGridLayout(this);
  bool minimize = false;

  int col = 1;
  if (firmware->getCapability(ChannelsName))
  {
    minimize=true;
    addLabel(gridLayout, tr("Name"), col++);
  }
  addLabel(gridLayout, tr("Subtrim"), col++, minimize);
  addLabel(gridLayout, tr("Min"), col++, minimize);
  addLabel(gridLayout, tr("Max"), col++, minimize);
  addLabel(gridLayout, tr("Direction"), col++, minimize);
  if (IS_TARANIS(GetEepromInterface()->getBoard()))
    addLabel(gridLayout, tr("Curve"), col++, minimize);
  if (firmware->getCapability(PPMCenter))
    addLabel(gridLayout, tr("PPM Center"), col++, minimize);
  if (firmware->getCapability(SYMLimits))
    addLabel(gridLayout, tr("Linear Subtrim"), col++, true);

  for (int i=0; i<firmware->getCapability(Outputs); i++) {
    col = 0;

    // Channel label
    QLabel *label = new QLabel(this);
    label->setText(tr("Channel %1").arg(i+1));
    label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
    gridLayout->addWidget(label, i+1, col++, 1, 1);

    // Channel name
    int nameLen = firmware->getCapability(ChannelsName);
    if (nameLen > 0) {
      QLineEdit * name = new QLineEdit(this);
      name->setProperty("index", i);
      name->setMaxLength(nameLen);
      QRegExp rx(CHAR_FOR_NAMES_REGEX);
      name->setValidator(new QRegExpValidator(rx, this));
      name->setText(model.limitData[i].name);
      connect(name, SIGNAL(editingFinished()), this, SLOT(nameEdited()));
      gridLayout->addWidget(name, i+1, col++, 1, 1);
    }

    // Channel offset
    QDoubleSpinBox * offset = new QDoubleSpinBox(this);
    offset->setProperty("index", i);
    offset->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
    offset->setAccelerated(true);
    offset->setDecimals(1);
    offset->setMinimum(-100);
    offset->setSingleStep(0.1);
    offset->setValue(float(model.limitData[i].offset) / 10);
    connect(offset, SIGNAL(editingFinished()), this, SLOT(offsetEdited()));
    gridLayout->addWidget(offset, i+1, col++, 1, 1);

    // Channel min
    QDoubleSpinBox * minSB = new QDoubleSpinBox(this);
    minSB->setProperty("index", i);
    minSB->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
    minSB->setAccelerated(true);
    minSB->setDecimals(1);
    minSB->setMinimum(-model.getChannelsMax());
    minSB->setSingleStep(0.1);
    minSB->setMaximum(0);
    minSB->setValue(float(model.limitData[i].min) / 10);
    connect(minSB, SIGNAL(editingFinished()), this, SLOT(minEdited()));
    gridLayout->addWidget(minSB, i+1, col++, 1, 1);
    minSpins << minSB;

    // Channel max
    QDoubleSpinBox * maxSB = new QDoubleSpinBox(this);
    maxSB->setProperty("index", i);
    maxSB->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
    maxSB->setAccelerated(true);
    maxSB->setDecimals(1);
    maxSB->setMinimum(0);
    maxSB->setSingleStep(0.1);
    maxSB->setMaximum(model.getChannelsMax());
    maxSB->setValue(float(model.limitData[i].max) / 10);
    connect(maxSB, SIGNAL(editingFinished()), this, SLOT(maxEdited()));
    gridLayout->addWidget(maxSB, i+1, col++, 1, 1);
    maxSpins << maxSB;

    // Channel inversion
    QComboBox * invCB = new QComboBox(this);
    invCB->insertItems(0, QStringList() << tr("---") << tr("INV"));
    invCB->setProperty("index", i);
    invCB->setCurrentIndex((model.limitData[i].revert) ? 1 : 0);
    connect(invCB, SIGNAL(currentIndexChanged(int)), this, SLOT(invEdited()));
    gridLayout->addWidget(invCB, i+1, col++, 1, 1);

    // Curve
    if (IS_TARANIS(GetEepromInterface()->getBoard())) {
      QComboBox * curveCB = new QComboBox(this);
      curveCB->setProperty("index", i);
      int numcurves = firmware->getCapability(NumCurves);
      for (int j=-numcurves; j<=numcurves; j++) {
        curveCB->addItem(CurveReference(CurveReference::CURVE_REF_CUSTOM, j).toString(), j);
      }
      curveCB->setCurrentIndex(model.limitData[i].curve.value+numcurves);
      connect(curveCB, SIGNAL(currentIndexChanged(int)), this, SLOT(curveEdited()));
      gridLayout->addWidget(curveCB, i+1, col++, 1, 1);
    }

    // PPM center
    if (firmware->getCapability(PPMCenter)) {
      QSpinBox * center = new QSpinBox(this);
      center->setProperty("index", i);
      center->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
      center->setMinimum(1375);
      center->setMaximum(1625);
      center->setValue(1500);
      center->setValue(model.limitData[i].ppmCenter + 1500);
      connect(center, SIGNAL(editingFinished()), this, SLOT(ppmcenterEdited()));
      gridLayout->addWidget(center, i+1, col++, 1, 1);
    }

    // Symetrical limits
    if (firmware->getCapability(SYMLimits)) {
      QCheckBox * symlimits = new QCheckBox(this);
      symlimits->setProperty("index", i);
      symlimits->setChecked(model.limitData[i].symetrical);
      connect(symlimits, SIGNAL(toggled(bool)), this, SLOT(symlimitsEdited()));
      gridLayout->addWidget(symlimits, i+1, col++, 1, 1);
    }
  }