Пример #1
0
QWidget * ExtArgNumber::createEditor(QWidget * parent)
{
    textBox = (QLineEdit *)ExtArgText::createEditor(parent);
    textBox->disconnect(SIGNAL(textChanged(QString)));

    if ( _argument->arg_type == EXTCAP_ARG_INTEGER || _argument->arg_type == EXTCAP_ARG_UNSIGNED )
    {
        QIntValidator * textValidator = new QIntValidator(parent);
        if ( _argument->range_start != NULL )
            textValidator->setBottom(extcap_complex_get_int(_argument->range_start));

        if ( _argument->arg_type == EXTCAP_ARG_UNSIGNED && textValidator->bottom() < 0 )
            textValidator->setBottom(0);

        if ( _argument->range_end != NULL )
            textValidator->setTop(extcap_complex_get_int(_argument->range_end));
        textBox->setValidator(textValidator);
    }
    else if ( _argument->arg_type == EXTCAP_ARG_DOUBLE )
    {
        QDoubleValidator * textValidator = new QDoubleValidator(parent);
        if ( _argument->range_start != NULL )
            textValidator->setBottom(extcap_complex_get_double(_argument->range_start));
        if ( _argument->range_end != NULL )
            textValidator->setTop(extcap_complex_get_double(_argument->range_end));

        textBox->setValidator(textValidator);
    }

    textBox->setText(defaultValue());

    connect(textBox, SIGNAL(textChanged(QString)), SLOT(onStringChanged(QString)));

    return textBox;
}
Пример #2
0
QValidator::State cwClinoValidator::validate ( QString & input, int & pos ) const {
    if(input.isEmpty()) {
        return QValidator::Acceptable;
    }

    QDoubleValidator doubleValidator;
    doubleValidator.setTop(90);
    doubleValidator.setBottom(-90);
    doubleValidator.setNotation(QDoubleValidator::StandardNotation);
    QValidator::State state = doubleValidator.validate(input, pos);

    switch(state) {
    case QValidator::Invalid: {
        QRegExpValidator upDownValidator;
        QRegExp regexp("up|down", Qt::CaseInsensitive);
        upDownValidator.setRegExp(regexp);
        return upDownValidator.validate(input, pos);
    }
    case QValidator::Acceptable: {
        //Just make sure we can convert the input
        bool okay;
        double value = input.toDouble(&okay);
        if(!okay || !check(value)) {
            //The validator is dump ... this handle use case input="5,5"
            return QValidator::Invalid;
        }
        break;
    }
    default:
        break;
    }

    return state;
}
transmitterPayloadDialog::transmitterPayloadDialog( QWidget * parent, Qt::WindowFlags f) : QDialog(parent,f)
{
	setupUi(this);

    QDoubleValidator* positiveDoubleValidator = new QDoubleValidator(this);
    positiveDoubleValidator->setBottom(0.0);

    QDoubleValidator* efficiencyValidator = new QDoubleValidator(this);
    efficiencyValidator->setBottom(0.0);
    efficiencyValidator->setTop(100.0);

    // changed this to range -90, 90 to turn antennas also in direction of space (need it for ground stations with antennas)
    QDoubleValidator* elevationValidator = new QDoubleValidator(this);
    elevationValidator->setRange(-90, 90, 2);

    ElLineEdit->setValidator(elevationValidator);
    //ElLineEdit->setValidator(positiveDoubleValidator);

    TxFeederLossLineEdit->setValidator(positiveDoubleValidator);
    TxDepointingLossLineEdit->setValidator(positiveDoubleValidator);
    GainLineEdit->setValidator(positiveDoubleValidator);
    DiameterLineEdit->setValidator(positiveDoubleValidator);
    BeamLineEdit->setValidator(positiveDoubleValidator);
    TiltLineEdit->setValidator(positiveDoubleValidator);
    EfficiencyLineEdit->setValidator(efficiencyValidator);
    FrequencyLineEdit->setValidator(positiveDoubleValidator);
    PowerLineEdit->setValidator(positiveDoubleValidator);
    DataRateLineEdit->setValidator(positiveDoubleValidator);

    ConeAngleLineEdit->setValidator(positiveDoubleValidator);
    HorAngleLineEdit->setValidator(positiveDoubleValidator);
    VertAngleLineEdit->setValidator(positiveDoubleValidator);
}
/* Dialog box for editing initial state parameters. The dialog
 * has a separate page for each method of entering the initial
 * state. Currently just two methods are supported: state vector
 * and Keplerian elements.
 */
InitialStateThreebodyEditorDialog::InitialStateThreebodyEditorDialog(QWidget* parent) :
    QDialog(parent)
{
    setupUi(this);

    // Set up the coordinate system combo box
    //coordinateSystemCombo->addItem(tr("Planet fixed"), (int) sta::COORDSYS_BODYFIXED);
    coordinateSystemCombo->addItem(tr("Co-Rotating normalized"), (int) sta::COORDSYS_ROT_NORM);
    coordinateSystemCombo->addItem(tr("Co-Rotating"), (int) sta::COORDSYS_ROT);
    coordinateSystemCombo->addItem(tr("Inertial body-centred"), (int) sta::COORDSYS_BODYFIXED);
    //coordinateSystemCombo->addItem(tr("Ecliptic (J2000)"), (int) sta::COORDSYS_ECLIPTIC_J2000);

    // Set up the input validators
    QDoubleValidator* doubleValidator = new QDoubleValidator(this);
    QDoubleValidator* angleValidator = new QDoubleValidator(this);
    angleValidator->setBottom(-360.0);
    angleValidator->setTop(360.0);
    QDoubleValidator* positiveAngleValidator = new QDoubleValidator(this);
    positiveAngleValidator->setBottom(0.0);
    positiveAngleValidator->setTop(360.0);
    QDoubleValidator* positiveDoubleValidator = new QDoubleValidator(this);
    positiveDoubleValidator->setBottom(0.0);
    QDoubleValidator* zeroToOneValidator = new QDoubleValidator(this);
    zeroToOneValidator->setBottom(0.0);
    zeroToOneValidator->setTop(0.9999);

    positionXEdit->setValidator(doubleValidator);
    positionYEdit->setValidator(doubleValidator);
    positionZEdit->setValidator(doubleValidator);
    velocityXEdit->setValidator(doubleValidator);
    velocityYEdit->setValidator(doubleValidator);
    velocityZEdit->setValidator(doubleValidator);

    semimajorAxisEdit->setValidator(positiveDoubleValidator);
    eccentricityEdit->setValidator(zeroToOneValidator);
    inclinationEdit->setValidator(angleValidator);
    raanEdit->setValidator(positiveAngleValidator);
    argOfPeriapsisEdit->setValidator(positiveAngleValidator);
    trueAnomalyEdit->setValidator(positiveAngleValidator);
}
/* Dialog box for editing location parameters: central body,
 * latitude, longitude, and altitude.
 */
LocationEditorDialog::LocationEditorDialog(QWidget* parent) :
    QDialog(parent)
{
    setupUi(this);

    // Set up the input validators
    QDoubleValidator* doubleValidator = new QDoubleValidator(this);
    QDoubleValidator* angleValidator = new QDoubleValidator(this);
    angleValidator->setBottom(-360.0);
    angleValidator->setTop(360.0);
    
    latitudeEdit->setValidator(angleValidator);
    longitudeEdit->setValidator(angleValidator);
    altitudeEdit->setValidator(doubleValidator);
}
Пример #6
0
// Default constructor
QGAppParamInputReal::QGAppParamInputReal(qgar::QgarAppParamDescr * descr,
					 QGAppDialogMediator * med,
					 QWidget * parent,
					 QGridLayout * layout)

  : QGAbstractAppParamInput(descr, med, parent, layout)
{
  //-- create value box and validator

  _value = new QLineEdit(this);
  QDoubleValidator * valid = new QDoubleValidator(_value);
  _value->setValidator(valid);

  _value->setAlignment(Qt::AlignRight);
  _value->setSizePolicy(QSizePolicy(QSizePolicy::Maximum,
				    QSizePolicy::Maximum));

  //-- Set value bounds and default value

  if (_descr->defaultValue() != "")
    _value->setText(_descr->defaultValue().c_str());


  double val;
  bool ok; 

  val = QString(_descr->minValue().c_str()).toDouble(&ok);
 
  if (ok)
    valid->setBottom(val);

  val = QString(_descr->maxValue().c_str()).toDouble(&ok);
  if (ok)
    valid->setTop(val);
  

  this->setEnabled(enabled());
  

  _layout->addWidget(_value);

  // Connect line edit to the slot that fwds notification to the
  // mediator
  connect(_value, 
	  SIGNAL(textChanged(const QString&)),
	  SLOT(valueChanged()));
}
Пример #7
0
void ICParameterRange::UpdateConfigRangeValidator(uint type, double min, double max)
{
    if(!configsRangeCache_.contains(type)) return;
    QDoubleValidator* dv = static_cast<QDoubleValidator*>(configsRangeCache_.value(type));
    if(dv != NULL)
    {
        dv->setBottom(min);
        dv->setTop(max);
        return;
    }
    QIntValidator* iv = static_cast<QIntValidator*>(configsRangeCache_.value(type));
    if(iv != NULL)
    {
        iv->setBottom(min);
        iv->setTop(max);
    }
}
Пример #8
0
void ICParameterRange::UpdateConfigRangeValidator(const ICAddrWrapper *addr, double value)
{
//    QMap<const ICAddrWrapper*, uint>::iterator p = addrToMaxValidator_.find(addr);
    value /= qPow(10, addr->Decimal());
    QList<uint> vs = addrToMaxValidator_.values(addr);
    for(int i = 0; i != vs.size(); ++i)
    {
        if(!configsRangeCache_.contains(vs.at(i))) continue;
        QDoubleValidator* dv = static_cast<QDoubleValidator*>(configsRangeCache_.value(vs.at(i)));
        if(dv != NULL)
        {
            dv->setTop(value);
//            ++p;
            continue;
        }
        QIntValidator* iv = static_cast<QIntValidator*>(configsRangeCache_.value(vs.at(i)));
        if(iv != NULL)
        {
            iv->setTop(value);
        }
    }

    vs  = addrToMinValidator_.values(addr);
    for(int i = 0; i != vs.size(); ++i)
    {
        if(!configsRangeCache_.contains(vs.at(i))) continue;
        QDoubleValidator* dv = static_cast<QDoubleValidator*>(configsRangeCache_.value(vs.at(i)));
        if(dv != NULL)
        {
            dv->setBottom(value);
//            ++p;
            continue;
        }
        QIntValidator* iv = static_cast<QIntValidator*>(configsRangeCache_.value(vs.at(i)));
        if(iv != NULL)
        {
            iv->setBottom(value);
        }
    }

}
Пример #9
0
QWidget * ExtArgNumber::createEditor(QWidget * parent)
{
    QString storeValue;
    QString text = defaultValue();

    if ( _argument->storeval )
    {
        QString storeValue = _argument->storeval;

        if ( storeValue.length() > 0 && storeValue.compare(text) != 0 )
            text = storeValue;
    }

    textBox = (QLineEdit *)ExtArgText::createEditor(parent);
    textBox->disconnect(SIGNAL(textChanged(QString)));

    if ( _argument->arg_type == EXTCAP_ARG_INTEGER || _argument->arg_type == EXTCAP_ARG_UNSIGNED )
    {
        QIntValidator * textValidator = new QIntValidator(parent);
        if ( _argument->range_start != NULL )
        {
            int val = 0;
            if ( _argument->arg_type == EXTCAP_ARG_INTEGER )
                val = extcap_complex_get_int(_argument->range_start);
            else if ( _argument->arg_type == EXTCAP_ARG_UNSIGNED )
            {
                guint tmp = extcap_complex_get_uint(_argument->range_start);
                if ( tmp > G_MAXINT )
                {
                    g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "Defined value for range_start of %s exceeds valid integer range", _argument->call );
                    val = G_MAXINT;
                }
                else
                    val = (gint)tmp;
            }

            textValidator->setBottom(val);
        }
        if ( _argument->arg_type == EXTCAP_ARG_UNSIGNED && textValidator->bottom() < 0 )
        {
            g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "%s sets negative bottom range for unsigned value, setting to 0", _argument->call );
            textValidator->setBottom(0);
        }

        if ( _argument->range_end != NULL )
        {
            int val = 0;
            if ( _argument->arg_type == EXTCAP_ARG_INTEGER )
                val = extcap_complex_get_int(_argument->range_end);
            else if ( _argument->arg_type == EXTCAP_ARG_UNSIGNED )
            {
                guint tmp = extcap_complex_get_uint(_argument->range_end);
                if ( tmp > G_MAXINT )
                {
                    g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "Defined value for range_end of %s exceeds valid integer range", _argument->call );
                    val = G_MAXINT;
                }
                else
                    val = (gint)tmp;
            }

            textValidator->setTop(val);
        }
        textBox->setValidator(textValidator);
    }
    else if ( _argument->arg_type == EXTCAP_ARG_DOUBLE )
    {
        QDoubleValidator * textValidator = new QDoubleValidator(parent);
        if ( _argument->range_start != NULL )
            textValidator->setBottom(extcap_complex_get_double(_argument->range_start));
        if ( _argument->range_end != NULL )
            textValidator->setTop(extcap_complex_get_double(_argument->range_end));

        textBox->setValidator(textValidator);
    }

    textBox->setText(text.trimmed());

    connect(textBox, SIGNAL(textChanged(QString)), SLOT(onStringChanged(QString)));

    return textBox;
}