Пример #1
0
void dXorg::setPowerProfile(PowerProfiles newPowerProfile) {
    QString newValue;
    switch (newPowerProfile) {
    case PowerProfiles::BATTERY:
        newValue = dpm_battery;
        break;
    case PowerProfiles::BALANCED:
        newValue = dpm_balanced;
        break;
    case PowerProfiles::PERFORMANCE:
        newValue = dpm_performance;
        break;
    case PowerProfiles::AUTO:
        newValue = profile_auto;
        break;
    case PowerProfiles::DEFAULT:
        newValue = profile_default;
        break;
    case PowerProfiles::HIGH:
        newValue = profile_high;
        break;
    case PowerProfiles::MID:
        newValue = profile_mid;
        break;
    case PowerProfiles::LOW:
        newValue = profile_low;
        break;
    }

    // enum is int, so first three values are dpm, rest are profile
    if (newPowerProfile <= PowerProfiles::PERFORMANCE)
        setNewValue(driverFiles.sysFs.power_dpm_state, newValue);
    else
        setNewValue(driverFiles.sysFs.power_profile, newValue);
}
VtkAlgorithmPropertyLineEdit::VtkAlgorithmPropertyLineEdit(
    const QString& contents,
    QString name,
    QVariant::Type type,
    VtkAlgorithmProperties* algProps,
    QWidget* parent /*= 0*/)
    : QLineEdit(contents, parent),
      _name(std::move(name)),
      _algProps(algProps),
      _type(type)
{
    switch(_type)
    {
    case QVariant::Double:
        this->setValidator(new QDoubleValidator(this));
        break;

    case QVariant::Int:
        this->setValidator(new QIntValidator(this));
        break;

    default:
        break;
    }

    connect(this, SIGNAL(editingFinished()), this, SLOT(setNewValue()));
}
Пример #3
0
/*!
  \brief Specify  range and step size

  \param vmin   lower boundary of the interval
  \param vmax   higher boundary of the interval
  \param vstep  step width
  \param pageSize  page size in steps
  \warning
  \li A change of the range changes the value if it lies outside the
      new range. The current value
      will *not* be adjusted to the new step raster.
  \li vmax < vmin is allowed.
  \li If the step size is left out or set to zero, it will be
      set to 1/100 of the interval length.
  \li If the step size has an absurd value, it will be corrected
      to a better one.
*/
void QwtDoubleRange::setRange(double vmin, double vmax, double vstep, int pageSize)
{
    bool rchg = ((d_maxValue != vmax) || (d_minValue != vmin));

    if (rchg)
    {
        d_minValue = vmin;
        d_maxValue = vmax;
    }

    //
    // look if the step width has an acceptable
    // value or otherwise change it.
    //
    setStep(vstep);

    //
    // limit page size
    //
    d_pageSize = qwtLim(pageSize,0,
                        int(qwtAbs((d_maxValue - d_minValue) / d_step)));

    //
    // If the value lies out of the range, it
    // will be changed. Note that it will not be adjusted to
    // the new step width.
    setNewValue(d_value, false);

    // call notifier after the step width has been
    // adjusted.
    if (rchg)
        rangeChange();
}
SpeciesInitialValueLostFocusCommand::SpeciesInitialValueLostFocusCommand(
  CQSpeciesDetail *pSpecieDetail)
  : CCopasiUndoCommand("Species", SPECIES_TYPE_CHANGE, "Change")
  , mpSpecieDetail(pSpecieDetail)
  , mpSpeciesData(new UndoSpeciesData(mpSpecieDetail->mpMetab))
  , mFirstTime(true)
{

  std::string sName = mpSpecieDetail->mpMetab->getObjectName();
  setText(QString(": Species Initial Value Change for %1").arg(FROM_UTF8(sName)));
  setName(mpSpeciesData->getName());

  {
    double newValue = mpSpecieDetail->mpEditInitialValue->text().toDouble();
    std::ostringstream strs;
    strs.precision(std::numeric_limits< double >::digits10);
    strs << newValue;
    std::string str = strs.str();
    setNewValue(str);
  }
  {
    std::ostringstream strs;
    strs.precision(std::numeric_limits< double >::digits10);
    strs << mpSpecieDetail->mInitialConcentration;
    std::string str = strs.str();
    setOldValue(str);
  }
  setProperty("Initial Value");
}
VtkAlgorithmPropertyVectorEdit::VtkAlgorithmPropertyVectorEdit( const QList<QString> contents,
                                                                const QString& name,
                                                                QVariant::Type type,
                                                                VtkAlgorithmProperties* algProps,
                                                                QWidget* parent /*= 0*/ )
	: QWidget(parent), _name(name), _algProps(algProps), _type(type)
{
	QHBoxLayout* layout = new QHBoxLayout;
	layout->setSpacing(3);
	layout->setContentsMargins(0, 0, 0, 0);

	foreach(QString content, contents)
	{
		QLineEdit* lineEdit = new QLineEdit(content, this);
		layout->addWidget(lineEdit);

		switch(_type)
		{
		case QVariant::Double:
			lineEdit->setValidator(new QDoubleValidator(this));
			break;

		case QVariant::Int:
			lineEdit->setValidator(new QIntValidator(this));

		default:
			break;
		}

		connect(lineEdit, SIGNAL(editingFinished()), this, SLOT(setNewValue()));
	}
Пример #6
0
void dXorg::setForcePowerLevel(ForcePowerLevels newForcePowerLevel) {
    QString newValue;
    switch (newForcePowerLevel) {
        case ForcePowerLevels::F_AUTO:
            newValue = dpm_auto;
            break;
        case ForcePowerLevels::F_HIGH:
            newValue = dpm_high;
            break;
        case ForcePowerLevels::F_LOW:
            newValue = dpm_low;
            break;
        case ForcePowerLevels::F_MANUAL:
            newValue = dpm_manual;
            break;
        case  ForcePowerLevels::F_PROFILE_STANDARD:
            newValue = dpm_profile_standard;
            break;
        case  ForcePowerLevels::F_PROFILE_MIN_SCLK:
            newValue = dpm_profile_min_sclk;
            break;
        case ForcePowerLevels::F_PROFILE_MIN_MCLK:
            newValue = dpm_profile_min_mclk;
            break;
        case ForcePowerLevels::F_PROFILE_PEAK:
            newValue = dpm_profile_peak;
            break;
    }

    setNewValue(driverFiles.sysFs.power_dpm_force_performance_level, newValue);
}
Пример #7
0
bool CPropertyCommand::mergeWith(const QUndoCommand *other)
{
    if(other->id()!=id())
        return  false;

    const CPropertyCommand    *   propertyCommand = static_cast<const CPropertyCommand*>(other);
    if(propertyCommand->fobjects!=fobjects || propertyCommand->propertyName()!=propertyName())
        return  false;

    setNewValue(propertyCommand->newValue());
    updateCommandText();

    return  true;
}
Пример #8
0
/**
 * now - current time in seconds
 */
int getIdle(IdleValveState *idle, int currentRpm, int now) {
	if (currentRpm == 0 || isCranking()) {
		return setNewValue(idle, currentRpm, now, "cranking value: ", DEFAULT_IDLE_DUTY);
	}

	if (currentRpm < 0.7 * idle->targetRpmRangeLeft) {
		return setNewValue(idle, currentRpm, now, "RPMs are seriously low: ", lastGoodValue);
	}

	if (now - idle->timeOfLastIdleChange < IDLE_PERIOD) {
		// too soon to adjust anything - exiting
		return idle->value;
	}

	if (currentRpm > idle->targetRpmRangeLeft && currentRpm < idle->targetRpmRangeRight) {
		// current RPM is good enough
		// todo: need idle signal input
		//lastGoodValue = idle->value;
		return idle->value;
	}

	if (currentRpm >= idle->targetRpmRangeRight + 100)
		return changeValue(idle, currentRpm, now, "idle control: rpm is too high: ", -IDLE_DECREASE_STEP);

	if (currentRpm >= idle->targetRpmRangeRight)
		return changeValue(idle, currentRpm, now, "idle control: rpm is a bit too high: ", -1);

	// we are here if RPM is low, let's see how low
//	if (currentRpm < 0.7 * idle->targetRpmRangeLeft) {
//		// todo: act faster in case of really low RPM?
//		return setNewValue(idle, currentRpm, now, "RPMs are seriously low: ", 15 * IDLE_INCREASE_STEP);
//	} else
	if (currentRpm < idle->targetRpmRangeLeft - 100) {
		return changeValue(idle, currentRpm, now, "idle control: RPMs are low: ", IDLE_INCREASE_STEP);
	}
	return changeValue(idle, currentRpm, now, "idle control: RPMs are a bit low: ", 1);
}
Пример #9
0
void GradientWidgetImpl::intToSpinbox(int var)
{
    gradient_spinbox->blockSignals(true);

    // put int back to double with decimals
    double doublevar = var;
    doublevar = doublevar / MULTIPLIKATOR;

    gradient_spinbox->setValue(doublevar);

    gradient_spinbox->blockSignals(false);

    emit gradientValueChanged(doublevar);

    setNewValue(doublevar);
}
Пример #10
0
void GradientWidgetImpl::doubleToSlider(double doubleVar)
{
    //the signals need to be blocked as both will return to this slot. But no
    //matter which UI elements (slider oder spinbox) was changed, the other
    //has to be set to the same value

    gradient_slider->blockSignals(true);

    // setting the decimals in int
    int intvar = doubleVar * MULTIPLIKATOR;

    gradient_slider->setValue(intvar);

    gradient_slider->blockSignals(false);

    emit gradientValueChanged(doubleVar);

    setNewValue(doubleVar);
}
Пример #11
0
void DoubleRange::setRange(double vmin, double vmax, double vstep, int pageSize, ConversionMode mode)
      {
      vmin = convertFrom(vmin, mode);
      vmax = convertFrom(vmax, mode);
      bool rchg = ((d_maxValue != vmax) || (d_minValue != vmin));

      if(!rchg && vstep == d_step && pageSize == d_pageSize)    // p4.0.45
        return;
      
      if (rchg) {
            d_minValue = vmin;
            d_maxValue = vmax;
            }

      //
      // look if the step width has an acceptable
      // value or otherwise change it.
      //
      setStep(vstep);

      //
      // limit page size
      //
      d_pageSize = MusECore::qwtLim(pageSize,0, int(MusECore::qwtAbs((d_maxValue - d_minValue) / d_step)));

      //
      // If the value lies out of the range, it
      // will be changed. Note that it will not be adjusted to
      // the new step width.
      setNewValue(d_value, false);

      // call notifier after the step width has been
      // adjusted.
      if (rchg)
            rangeChange();
      }
Пример #12
0
EventDataChangeCommand::EventDataChangeCommand(QModelIndex index, const QVariant value, int role, CQEventDM *pEventDM)
{
  // stores the data
  mOld = index.data(Qt::DisplayRole);
  mNew = value;
  mpEventDM = pEventDM;
  mIndex = index;
  mRole = role;

  //mPathIndex = pathFromIndex(index);
  this->setText(eventDataChangeText());

  //set the data for UNDO history
  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
  CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
  assert(pDataModel != NULL);
  CModel * pModel = pDataModel->getModel();
  CEvent *pEvent = pModel->getEvents()[index.row()];
  mType = EVENTDATACHANGE;
  setEntityType("Event");
  setAction("Change");
  setName(pEvent->getObjectName());
  setOldValue(TO_UTF8(mOld.toString()));
  setNewValue(TO_UTF8(mNew.toString()));

  switch (index.column())
    {
      case 0:
        setProperty("");
        break;

      case 1:
        setProperty("Name");
        break;
    }
}
Пример #13
0
void DoubleRange::setValue(double x, ConversionMode mode)
      {
      setNewValue(convertFrom(x, mode), false);
      }
Пример #14
0
/*!
  \brief Set a new value without adjusting to the step raster
  \param x new value
  \warning The value is clipped when it lies outside the range.
  When the range is QwtDoubleRange::periodic, it will
  be mapped to a point in the interval such that
  \verbatim new value := x + n * (max. value - min. value)\endverbatim
  with an integer number n.
*/
void QwtDoubleRange::setValue(double x)
{
    setNewValue(x, false);
}
Пример #15
0
/*!
  \brief  Adjust the value to the closest point in the step raster.
  \param x value
  \warning The value is clipped when it lies outside the range.
  When the range is QwtDoubleRange::periodic, it will
  be mapped to a point in the interval such that
  \verbatim new value := x + n * (max. value - min. value)\endverbatim
  with an integer number n.
*/
void QwtDoubleRange::fitValue(double x)
{
    setNewValue(x, true);
}
Пример #16
0
static int changeValue(IdleValveState *idle, int currentRpm, int now, char * msg, int delta) {
	int newValue = idle->value + delta;
	return setNewValue(idle, currentRpm, now, msg, newValue);
}
Пример #17
0
int main(void)
{
char temp, i;
LCD_Initialize();
DDRB = 0b00000000;
PORTB = 0b00001111;

DDRA = 0xFF;
ADC_Init();
int value = 0;
int calculations = 0;

	char dzialanie = 0;

	
	int digit = 0;




	do{

	int digit  = getADC(0);

	char sw0 = PINB & 0b00000001;
	char sw1 = PINB & 0b00000010;
	if(sw0 != 0b00000001) {
		state++;
		_delay_ms(300);
	}
	

	  char str[15];


	  sprintf(str, "%15d", lastValue);
	LCD_GoTo(1,0);
	LCD_WriteText(str);


	switch(state){
		case 0:		
			if(sw1 != 0b00000010){
				setNewValue(mappingLogToLinear(digit, digitMap, 10));			
				_delay_ms(300);
			}
				sprintf(str, "%15d", mappingLogToLinear(digit, digitMap,10));
				LCD_GoTo(1,1);
				LCD_WriteText(str);	
			break;
		case 1:
			if(sw1 != 0b00000010){
				setSign(mappingLogToLinear(digit, signMap, 2));
				power = 0;				
				_delay_ms(300);
			}
				switch(mappingLogToLinear(digit, signMap,2)){
					case 0:
					LCD_GoTo(1,1);
					LCD_WriteText("-");
					break;
					case 1:
					LCD_GoTo(1,1);
					LCD_WriteText("+");
					break;
				}
			break;
		case 2:
			if(sw1 != 0b00000010){
				doCalculations(mappingLogToLinear(digit, expressionMap, 4));
				power = 0;
				newValue=0;
				state = 0;			
				_delay_ms(300);
			}
				
				switch(mappingLogToLinear(digit, expressionMap,4)){
					case 0:
					LCD_GoTo(1,1);
					LCD_WriteText("+");
					break;
					case 1:
					LCD_GoTo(1,1);
					LCD_WriteText("-");
					break;
					case 2:
					LCD_GoTo(1,1);
					LCD_WriteText("*");
					break;
					case 3:
					LCD_GoTo(1,1);
					LCD_WriteText("/");
					break;
				}
			break;
		}


/*
	char sw0 = PINB & 0b00000001;
	char sw1 = PINB & 0b00000010;
	char sw2 = PINB & 0b00000100;
	char sw3 = PINB & 0b00001000;

	if(sw0 != 0b00000001) value++;
	if(sw1 != 0b00000010) value--;

	if(sw2 != 0b00000100) {
		if(dzialanie == 0) calculations += value;
		if(dzialanie == 1) calculations -= value;
		if(dzialanie == 2) calculations /= value;
		if(dzialanie == 3) calculations *= value;
			value = 0;
	}


	if(sw3 != 0b00001000) {
		dzialanie++;
		dzialanie = dzialanie % 4;
	}




	  char str[15];


	  sprintf(str, "%15d", calculations);
	LCD_GoTo(1,0);
	LCD_WriteText(str);

	  sprintf(str, "%15d", value);
	LCD_GoTo(1,1);
	LCD_WriteText(str);
	_delay_ms(300);

	
	if(dzialanie == 0){
		LCD_GoTo(0,0);
		LCD_WriteText("+");
	}

	if(dzialanie == 1){
		LCD_GoTo(0,0);
		LCD_WriteText("-");
	}
	
	if(dzialanie == 2){
		LCD_GoTo(0,0);
		LCD_WriteText("/");
	}
	
	if(dzialanie == 3){
		LCD_GoTo(0,0);
		LCD_WriteText("*");
	}*/
	}while(1);

return 0;
}
Пример #18
0
/*!
  \brief Increment the value by a specified number of steps
  \param nSteps Number of steps to increment
  \warning As a result of this operation, the new value will always be
       adjusted to the step raster.
*/
void QwtDoubleRange::incValue(int nSteps)
{
    if ( isValid() )
        setNewValue(d_value + double(nSteps) * d_step, true);
}
Пример #19
0
void DoubleRange::fitValue(double x, ConversionMode mode)
      {
      setNewValue(convertFrom(x, mode), true);
      }
Пример #20
0
void DoubleRange::incPages(int nPages)
      {
      setNewValue(d_value + double(nPages) * double(d_pageSize)
         * d_step, true);
      }
Пример #21
0
void DoubleRange::incValue(int nSteps)
      {
      setNewValue(d_value + double(nSteps) * d_step, true);
      }
Пример #22
0
/*!
  \brief Increment the value by a specified number of pages
  \param nPages Number of pages to increment.
        A negative number decrements the value.
  \warning The Page size is specified in the constructor.
*/
void QwtDoubleRange::incPages(int nPages)
{
    if ( isValid() )
        setNewValue(d_value + double(nPages) * double(d_pageSize) * d_step, true);
}
Пример #23
0
CompartmentDataChangeCommand::CompartmentDataChangeCommand(
  const QModelIndex& index,
  const QVariant& value,
  int role,
  CQCompartmentDM *pCompartmentDM)
  : CCopasiUndoCommand("Compartment", COMPARTMENT_DATA_CHANGE, "Change")
  , mNew(value)
  , mOld(index.data(Qt::DisplayRole))
  , mIndex(index)
  , mpCompartmentDM(pCompartmentDM)
  , mRole(role)
  , mPathIndex()
  , mpCompartmentUndoData(NULL)

{
  //set the data for UNDO history
  assert(pCompartmentDM->getDataModel() != NULL);
  CModel * pModel = pCompartmentDM->getDataModel()->getModel();
  assert(pModel != NULL);

  if (pModel->getCompartments().size() <= (size_t)index.row())
    {
      return;
    }

  CCompartment *pCompartment = &pModel->getCompartments()[index.row()];
  setKey(pCompartment->getKey());
  setName(pCompartment->getObjectName());
  setOldValue(TO_UTF8(mOld.toString()));
  setNewValue(TO_UTF8(mNew.toString()));

  switch (index.column())
    {
      case 0:
        setProperty("");
        break;

      case 1:
        setProperty("Name");
        break;

      case 2:
        setProperty("Type");

        switch (mNew.toInt())
          {
            case 0:
              setNewValue("fixed");
              break;

            case 1:
              setNewValue("assignment");
              break;

            case 2:
              setNewValue("ode");
              break;
          }

        break;

      case 3:
        setProperty("Initial Volume");
        // need to store additional undo data to be able to restore
        // species initial concentrations / patricle numbers
        mpCompartmentUndoData = new UndoCompartmentData(pCompartment);
        break;
    }

  setText(QString(": Changed compartment %1").arg(getProperty().c_str()));
}