示例#1
0
void temperatureCalcWindow::doUpdate()
{
    if( _running )
    {
        if( _ui->chb_linear->isChecked() )
        {
            double temperature = (_lastResistance/_linearInitResistance - 1.0)/
                    (_ui->dsb_alpha->value()*1E-3) + _linearInitTemperature;

            _ui->txt_linearCalcTemperatureCelsius->setText(
                        QString::number( temperature - 273.15) );
            _ui->txt_linearCalcTemperatureKelvin->setText(
                        QString::number( temperature ) );
            emit newValue( this->windowTitle() + ": temperature (linear)",
                           temperature );
        }
        if( _ui->chb_quadratic->isChecked() )
        {
            double temperature = -a1/(2.0*a2) + std::sqrt(
                        std::pow( a1/(2.0*a2), 2.0 ) - (a0 - _lastResistance*
                        (std::pow( _ui->dsb_diameter->value()*(1E-3)/2.0, 2.0 )*
                         M_PI/(_ui->dsb_length->value()*1E-3)))/a2 );

            _ui->txt_quadraticCalcTemperatureCelsius->setText(
                        QString::number( temperature - 273.15) );
            _ui->txt_quatraticCalcTemperatureKelvin->setText(
                        QString::number( temperature ) );
            emit newValue( this->windowTitle() + ": temperature (quadratic)",
                           temperature );
        }
    }
}
示例#2
0
void CPropertyCommand::redo()
{
    if(newValue().isValid() && !propertyName().isEmpty())
    {
        foreach (QObject * object, fobjects)
            object->setProperty(qPrintable(propertyName()),newValue());
    }
}
bool QDateTimeEdit::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: setDateTime((const QDateTime&)*((const QDateTime*)static_QUType_ptr.get(_o+1))); break;
    case 1: newValue((const QDate&)*((const QDate*)static_QUType_ptr.get(_o+1))); break;
    case 2: newValue((const QTime&)*((const QTime*)static_QUType_ptr.get(_o+1))); break;
    default:
	return QWidget::qt_invoke( _id, _o );
    }
    return TRUE;
}
示例#4
0
PMRuleCompare::PMRuleCompare( QDomElement& e,
                              QPtrList<PMRuleDefineGroup>& globalGroups,
                              QPtrList<PMRuleDefineGroup>& localGroups )
      : PMRuleCondition( )
{
   m_pValue[0] = 0;
   m_pValue[1] = 0;

   int i = 0;
   QDomNode m = e.firstChild( );
   while( !m.isNull( ) && !m_pValue[1] )
   {
      if( m.isElement( ) )
      {
         QDomElement me = m.toElement( );
         if( isValue( me ) )
         {
            m_pValue[i] = newValue( me, globalGroups, localGroups );
            m_children.append( m_pValue[i] );
            i++;
         }
      }
      m = m.nextSibling( );
   }
   if( !m_pValue[1] )
      kdError( PMArea ) << "RuleSystem: Comparison needs two values" << endl;
}
示例#5
0
//TODO: requires values to be added in time order
void DataSeries::addValue(double time, double value, bool scale) {
	if (timestamps.size() > 0 && time < timestamps.last())  {//qDebug() << time << "vs." << timestamps.last();
		qWarning() << time << timestamps.last();
	}
	if (scale) value *= descriptor->factor();
	//qDebug() << descriptor->str() << ": Adding " << value << "at time" << time;
	if (value < _min) {
		_min = value;
		emit newMin(value);
	}
	if (value > _max) {
		_max = value;
		emit newMax(value);
	}
	double _oldavg = _avg;
	if (values.size() > 0) {
		//double t = time - timestamps.last();
		//double v1 = values.last();
		double avgval = value; //v1*t+(value-v1)*t/2;
		_avg += (avgval-_avg)/(values.size()+1);
		//qWarning() << _avg << avgval;
	} else {
		_avg = value;
	}
	values.append(value);
	timestamps.append(time);
	if (_oldavg != _avg) {
		emit newAvg(_avg);
	}
	emit newValue(time,value);
	emit valuesUpdated(timestamps,values);
}
//! Sets the data.
bool LookupListModel::setData( const QModelIndex &index, const QVariant &value, int role )
{
	// Skip setting any data if we do not have any values to show.
	if( role != LookupListModel::LookupRole )
		return false;
	if( ! index.isValid() )
		return false;

	// The value given should be valid.
	Q_ASSERT( value.isValid() );

	// We can only convert variant maps at the moment.
	// JSON objects are returned as variant maps from QML.
	if( value.type() != QVariant::Map )
	{
		// TODO: Report error.
		qCritical( value.typeName() );
		return false;
	}

	// Check if the value has changed.
	const QJsonValue& previousValue = m_lookups[ index.row() ];
	QJsonValue newValue( QJsonObject::fromVariantMap( qvariant_cast< QVariantMap >( value ) ) );
	if( previousValue == newValue )
		return false;

	// The value denoted by the index has changed. Update it with the new value and signal the change.
	qDebug( "Updating lookup model data." );
	m_lookups[ index.row() ] = newValue;
	this->updatePropertyValueFromLookups();
	emit dataChanged( index, index );
	return true;
}
示例#7
0
PassRefPtr<SimpleFontData> FontDataCache::get(const FontPlatformData* platformData, ShouldRetain shouldRetain)
{
    if (!platformData)
        return 0;

    Cache::iterator result = m_cache.find(*platformData);
    if (result == m_cache.end()) {
        pair<RefPtr<SimpleFontData>, unsigned> newValue(SimpleFontData::create(*platformData), shouldRetain == Retain ? 1 : 0);
        m_cache.set(*platformData, newValue);
        if (shouldRetain == DoNotRetain)
            m_inactiveFontData.add(newValue.first);
        return newValue.first.release();
    }

    if (!result.get()->value.second) {
        ASSERT(m_inactiveFontData.contains(result.get()->value.first));
        m_inactiveFontData.remove(result.get()->value.first);
    }

    if (shouldRetain == Retain) {
        result.get()->value.second++;
    } else if (!result.get()->value.second) {
        // If shouldRetain is DoNotRetain and count is 0, we want to remove the fontData from
        // m_inactiveFontData (above) and re-add here to update LRU position.
        m_inactiveFontData.add(result.get()->value.first);
    }

    return result.get()->value.first;
}
示例#8
0
void CrossWidget::mousePressEvent(QMouseEvent* e) {
  if (e->buttons() == Qt::LeftButton){
    mouseLeftButton = true;
    calcMousePos(e);
    emit newValue(doubleX, doubleY, mouseLeftButton);
  }
}
示例#9
0
SimpleFontData* FontCache::getCachedFontData(const FontPlatformData* platformData)
{
    if (!platformData)
        return 0;

    if (!gFontDataCache) {
        gFontDataCache = new FontDataCache;
        gInactiveFontData = new InactiveFontDataHashSet;
    }
    
    FontDataCache::iterator result = gFontDataCache->find(*platformData);
    if (result == gFontDataCache->end()) {
        if (gInactiveFontData->size() > cMaxInactiveFontData)
            purgeInactiveFontData((int)(cMaxInactiveFontData * cInactiveFontDataPurgeRatio));

        pair<SimpleFontData*, unsigned> newValue(new SimpleFontData(*platformData), 1);

        // 6/15/09 CSidhall  -Moved the add ref into the constructor of SimpleFontData 

        gFontDataCache->set(*platformData, newValue);
        return newValue.first;
    }
    if (!result.get()->second.second++) {
        if(gInactiveFontData->contains(result.get()->second.first))
            gInactiveFontData->remove(result.get()->second.first);
    }

    return result.get()->second.first;
}
示例#10
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimCommandIssueFieldChanged::redo()
{
    RiaApplication* app = RiaApplication::instance();
    PdmObject* project = app->project();

    caf::PdmObjectHandle* pdmObject = findObjectByName(project, this->objectName);

    if (pdmObject)
    {
        caf::PdmFieldHandle* fieldHandle = findFieldByKeyword(pdmObject, this->fieldName);

        if (fieldHandle && fieldHandle->uiCapability())
        {
            caf::PdmValueField* valueField = dynamic_cast<caf::PdmValueField*>(fieldHandle);
            CVF_ASSERT(valueField);

            QVariant oldValue = valueField->toQVariant();
            QVariant newValue(this->fieldValueToApply);

            valueField->setFromQVariant(newValue);

            caf::PdmUiFieldHandle* uiFieldHandle = fieldHandle->uiCapability();
            uiFieldHandle->notifyFieldChanged(oldValue, newValue);
        }
    }
}
void PivotPropertyTableDelegate::setModelData (
    QWidget* editor,
    QAbstractItemModel* model,
    const QModelIndex& index ) const
{
    // set data for material cell
    if ( index.column() != 0 ) {
        MaterialComboBox *comboBox = dynamic_cast<MaterialComboBox*>(editor);
        const TrussMaterial* m = comboBox->getCurrentMaterial();
        if ( ! m )
            return;
        QVariant material;
        qVariantSetValue<const TrussMaterial*>( material, m );
        model->setData( index, material );
        emit const_cast<PivotPropertyTableDelegate*>(this)->
                cellWasChanged( index.row(), index.column() );
        return;
    }

    // set data for thickness cell
    QLineEdit* lineEdit = dynamic_cast<QLineEdit*>( editor );
    Q_ASSERT( lineEdit );
    QVariant newValue( lineEdit->text() );
    model->setData( index, newValue );
    emit const_cast<PivotPropertyTableDelegate*>(this)->
            cellWasChanged( index.row(), index.column() );

    return;
}
void EditRatioWindow::shiftB(Coord delta)
 {
  Coord new_b=b+delta;

  if( new_b>0 )
    {
     b=new_b;

     newValue();
    }
  else if( b>1 )
    {
     b=1;

     newValue();
    }
 }
// NB: This algorithm should be in sync with Workshare.Configuration.Shell.Model.OptionGroupInstance.RemoveInvalidChars
CStdString InterwovenServers::RemoveInvalidChars(const CStdString& value)
{	
	std::wstring newValue(L"instance");
	newValue.append(value);
	std::wstring::iterator it = std::remove_if(newValue.begin(), newValue.end(), InvalidChars);	
	newValue.erase(it, newValue.end());
	return newValue;
}
 bool validateValue(const QVariant& value, QVariant& convertedValue) const {
     QVariant newValue(value);
     if (!newValue.convert(defaultValue.type()))
         return false;
     if (validationFunc && !(*validationFunc)(newValue))
         return false;
     convertedValue = newValue;
     return true;
 }
void KSimBaseIntSpinBox::stepDown()
{
	KSimBaseInt newValue(value());
	int res;
	newValue = newValue.value() - lineStep(); // Base is not changed!

	res = setValueInternal(newValue);
	KSimSpinBox::setValue(res);
}
示例#16
0
void QuteSlider::setMidiValue(int value)
{
	double max = property("QCS_maximum").toDouble();
	double min = property("QCS_minimum").toDouble();
	double newval = min + ((value / 127.0)* (max - min));
	setValue(newval);
	QPair<QString, double> channelValue(m_channel, newval);
	emit newValue(channelValue);
}
示例#17
0
 /**
   * Set the normalized value [-1, 1]
   */
 void  BrainOut::setValue(btScalar value) {
     // Un noramlization
     this->value = (value + 1.0f) / 2.0f * (max - min) + min;
     if(this->value > max) {
         this->value = max;
     }
     if(this->value < min) {
         this->value = min;
     }
     emit newValue(this->value);
 }
void EditRatioWindow::pin(Point point)
 {
  point-=base;

  if( point.y<0 )
    {
     a=point.x;
     b=-point.y;

     newValue();
    }
 }
示例#19
0
void eaps8000UsbWindow::powerUpdate( double power )
{
    CLOG(INFO, "v") << this->windowTitle().toStdString()
                    << ": power = " << power << " W";
    LOG(INFO) << this->windowTitle().toStdString() << ": power update: "
              << power;
    _ui->txt_power->setText( QString::number( power ) + " " + UNIT_WATT );

    if( _ui->chb_sharePower->isChecked() )
    {
        emit newValue( this->windowTitle() + ": " + POWER, power );
    }
}
示例#20
0
void eaps8000UsbWindow::currentUpdate( double current )
{
    CLOG(INFO, "v") << this->windowTitle().toStdString()
                    << ": current = " << current << " A";
    LOG(INFO) << this->windowTitle().toStdString() << ": current update: "
              << current;
    _ui->txt_current->setText( QString::number( current ) + " " + UNIT_AMPERE );

    if( _ui->chb_shareCurrent->isChecked() )
    {
        emit newValue( this->windowTitle() + ": " + CURRENT, current );
    }
}
示例#21
0
void eaps8000UsbWindow::voltageUpdate( double voltage )
{
    CLOG(INFO, "v") << this->windowTitle().toStdString()
                    << ": voltage = " << voltage << " V";
    LOG(INFO) << this->windowTitle().toStdString() << ": voltage update: "
              << voltage;
    _ui->txt_voltage->setText( QString::number( voltage ) + " " + UNIT_VOLT );

    if( _ui->chb_shareVoltage->isChecked() )
    {
        emit newValue( this->windowTitle() + ": " + VOLTAGE, voltage );
    }
}
示例#22
0
void PivotTableDelegate::setModelData ( QWidget* editor, 
                                        QAbstractItemModel* model, 
                                        const QModelIndex& index ) const
{
    if ( index.column() == 2 )
        return;
    
    QComboBox *comboBox = dynamic_cast<QComboBox*>(editor);
    QVariant newValue( comboBox->currentText() );
    model->setData( index, newValue );
    emit const_cast<PivotTableDelegate*>(this)->
            cellWasChanged( index.row(), index.column() );
    return;
}
示例#23
0
void elFlowWindow::pressureUpdate( double pressure )
{
    CLOG(INFO, "v") << this->windowTitle().toStdString()
               << ": pressure = " << pressure << " mbar";
    LOG(INFO) << this->windowTitle().toStdString() << ": pressure update: "
              << pressure;
    _ui->txt_pressure->setText( QString::number( pressure ) + " "
                                + UNIT_MBAR );

    if( _ui->chb_sharePressure->isChecked() )
    {
        emit newValue( this->windowTitle() + ": " + PRESSURE, pressure );
    }
}
示例#24
0
void elFlowWindow::temperatureUpdate( double temperature )
{
    CLOG(INFO, "v") << this->windowTitle().toStdString()
               << ": temperature = " << temperature << " C";
    LOG(INFO) << this->windowTitle().toStdString() << ": temperature update: "
              << temperature;
    _ui->txt_temperature->setText( QString::number( temperature ) + " "
                                   + UNIT_DEGC );

    if( _ui->chb_shareTemperature->isChecked() )
    {
        emit newValue( this->windowTitle() + ": " + TEMPERATURE, temperature );
    }
}
示例#25
0
void BoolSetting::setChecked(bool checked)
{
    if(checked)
        boolBox->setIcon(QIcon(":/Settings/CheckChecked"));
    else
        boolBox->setIcon(QIcon(":/Settings/CheckUnchecked"));
    if(checked == checkedDefault)
        boolReset->setChecked(false);
    else
        boolReset->setChecked(true);
    boolBox->setChecked(checked);
    this->checked = checked;
    emit newValue(checked);
}
示例#26
0
文件: enums.cpp 项目: Jinxiaohai/QT
void Enums::setValue(int item)
{
//    PropertyInterface::setValue(cb->itemData(item));
    QVariant data = cb->itemData(item);

    QVariant old_data = object()->metaObject()->property(objectProperty()).read(object());
    QVariant newValue(old_data);
    int * intData = reinterpret_cast<int*>(newValue.data());
    *intData = data.toInt();
    bool ret = object()->metaObject()->property(objectProperty()).write(object(), newValue);

    if (ret)
        emit(propertyChanged(object(), QString(object()->metaObject()->property(objectProperty()).name()), old_data, data));
}
示例#27
0
void eaps8000UsbWindow::resistanceUpdate( double resistance )
{
    CLOG(INFO, "v") << this->windowTitle().toStdString()
                    << ": resistance = " << resistance << " Ohm";
    LOG(INFO) << this->windowTitle().toStdString() << ": resistance update: "
              << resistance;
    _ui->txt_resistance->setText( QString::number( resistance )
                                  + " " + UNIT_OHM );

    if( _ui->chb_shareResistance->isChecked() )
    {
        emit newValue( this->windowTitle() + ": " + RESISTANCE, resistance );
    }
}
示例#28
0
//---------------------------------------------------------------
// Purpose: 
//---------------------------------------------------------------
void CEntityDialogClassInfo::UpdateCurrentParam( void )
{
	if( !m_editEnt )
		return;

	CString csNewValue;
	m_ecValueRaw.GetWindowText( csNewValue );

	std::string newValue( CT2A(csNewValue).m_psz );

	m_editEnt->SetValue( m_currentKey->name, newValue );

	//GetActiveDocument()->UpdateAllViews(NULL);
}
示例#29
0
std::string JsVm::call(const Db::Interface::Key &key, const Db::Interface::Value &value)
{
    v8::Local<v8::Value> args[] = {
        newUtf8String(key.c_str()),
        newUtf8String(value.c_str())
    };

    v8::Local<v8::Value> ret = m_function->Call(m_context->Global(), 2, args);
    if (ret.IsEmpty()) {
        fillTryCatch();
        throw Exception("Error while calling function");
    }
    v8::String::Utf8Value newValue(ret);
    return std::string(*newValue);
}
void tst_QScriptValueIterator::setValue()
{
    QFETCH(QString, code);
    QScriptEngine engine;
    QScriptValue object = engine.evaluate(code);
    Q_ASSERT(object.isObject());

    QScriptValueIterator it(object);
    it.next();
    QScriptValue newValue(&engine, 456);
    QBENCHMARK {
        for (int i = 0; i < 50000; ++i)
            it.setValue(newValue);
    }
}