void NoiseReductionWidget::changeEvent(QEvent *event) { if (event->type() == QEvent::EnabledChange) { updateParam(LUX_FILM, LUX_FILM_NOISE_GREYC_ENABLED, m_GREYC_enabled && this->isEnabled()); updateParam(LUX_FILM, LUX_FILM_NOISE_CHIU_ENABLED, m_Chiu_enabled && this->isEnabled()); emit valuesChanged (); } }
void GammaWidget::deactivateCRF() { m_CRF_enabled = false; ui->gamma_label->setText("Gamma"); updateWidgetValue(ui->slider_gamma, (int)((FLOAT_SLIDER_RES / TORGB_GAMMA_RANGE) * m_TORGB_gamma) ); updateWidgetValue(ui->spinBox_gamma, m_TORGB_gamma); updateWidgetValue(ui->checkBox_CRF, m_CRF_enabled); updateParam (LUX_FILM, LUX_FILM_TORGB_GAMMA, m_TORGB_gamma); updateParam(LUX_FILM, LUX_FILM_CAMERA_RESPONSE_ENABLED, m_CRF_enabled); }
void DirectionHypothesis::allocateCommands() { //calculate new opposite TODO allow for oddness int newopposite = (int)(mMainSegment+mNumSegments/2)%mNumSegments; //rotate! osg::Vec3 heading = mParams.at(mMainSegment); calcUnitsAngles(heading); float onesegment = getAngleFromDepth(mDepth) / mNumSegments; float mainsegments = onesegment * (mNumSegments-2); float oppositesegment = (2*osg::PI - mainsegments)/2; osg::Matrix mainangle = osg::Matrix::rotate(onesegment, osg::Vec3(0,0,1)); osg::Matrix oppositeangle = osg::Matrix::rotate(oppositesegment, osg::Vec3(0,0,1)); //find the units in this segment and add them to this call std::vector<int> targets = getUnitsInSegment(0, onesegment); std::ostringstream oss; //oss << "Heading" << mMainSegment << ">" << targetHeading[0] << ','<< targetHeading[1] << ',' << targetHeading[2]; //oss << "Head>0,Angle>" << onesegment << ","; oss << "Targets>"; for (unsigned int i=0; i < targets.size(); i++) { oss << (theApp->getUnitById(targets[i]))->getName() << ','; } //update params updateParam(mMainSegment, heading, oss.str(), targets); float angle = 0; for (int i=1; i < mNumSegments; i++) { int seg = (mMainSegment + i)%mNumSegments; if (mDepth > 0 && (seg == newopposite || (mNumSegments > 2 && seg == (newopposite+1)%mNumSegments))) { heading = oppositeangle * heading; angle += oppositesegment; } else { heading = mainangle * heading; angle += onesegment; } float segmentAngle = onesegment; if (seg == newopposite) { segmentAngle = (2*osg::PI - (onesegment * (mNumSegments-1))); } //find the units in this segment and add them to this call std::vector<int> targets = getUnitsInSegment(angle, segmentAngle); //param string std::ostringstream oss; //oss << "Heading" << seg << ">" << targetHeading[0] << ','<< targetHeading[1] << ',' << targetHeading[2]; //oss << "Head>" << angle << ",Angle>" << segmentAngle << ","; oss << "Targets>"; for (unsigned int i=0; i < targets.size(); i++) { //oss << ((i>0)?",":"") << (theApp->getUnitById(targets[i]))->getName(); oss << (theApp->getUnitById(targets[i]))->getName() << ","; } //update params updateParam(seg, heading, oss.str(), targets); } }
void GammaWidget::changeEvent(QEvent *event) { if (event->type() == QEvent::EnabledChange) { //// Reset from film when enabling in case values were not properly initialized //if (retrieveParam(false, LUX_FILM, LUX_FILM_TORGB_GAMMA) == m_TORGB_gamma) // resetFromFilm(false); updateParam(LUX_FILM, LUX_FILM_TORGB_GAMMA, (this->isEnabled() ? m_TORGB_gamma : 1.0)); updateParam(LUX_FILM, LUX_FILM_CAMERA_RESPONSE_ENABLED, this->isEnabled() && m_CRF_enabled); emit valuesChanged (); } }
void TargetDirectionHypothesis::update() { //called when we have confidences for each separate command //update the parameters and the groups if (!mInit) { std::vector<int> ids = mRedUnits->getUnitIDs(); initCommands(mBlueUnits.size(), (int)Command::GOTO, ids); mInit = true; } mStartPos = mRedUnits->getCentreCurrent(); for (unsigned int i=0; i < mCommands.size(); i++) { if (mBlueUnits[i]->isValidGroup()) { std::ostringstream oss; oss << "TargetGroup" << i << ">" << mBlueUnits[i]->getUnitIDs()[0]; //update params updateParam(i, mBlueUnits[i]->getCentreCurrent(), oss.str(), mBlueUnits[i]->getUnitIDs()); mEndPos[i] = mBlueUnits[i]->getCentreCurrent(); } else { //delete parameter... disableCommand(i); } } }
// Swap params A/B. void synthv1widget::swapParams ( bool bOn ) { if (m_iUpdate > 0 || !bOn) return; #ifdef CONFIG_DEBUG qDebug("synthv1widget::swapParams(%d)", int(bOn)); #endif // resetParamKnobs(); for (uint32_t i = 0; i < synthv1::NUM_PARAMS; ++i) { const synthv1::ParamIndex index = synthv1::ParamIndex(i); synthv1widget_knob *pKnob = paramKnob(index); if (pKnob) { const float fOldValue = pKnob->value(); const float fNewValue = m_params_ab[index]; setParamValue(index, fNewValue); updateParam(index, fNewValue); m_params_ab[index] = fOldValue; } } const bool bSwapA = m_ui.SwapParamsAButton->isChecked(); m_ui.StatusBar->showMessage(tr("Swap %1").arg(bSwapA ? 'A' : 'B'), 5000); updateDirtyPreset(true); }
void NoiseReductionWidget::setInterpolType(int value) { m_GREYC_interp = value; updateParam(LUX_FILM, LUX_FILM_NOISE_GREYC_INTERP, m_GREYC_interp); if (m_GREYC_enabled) emit valuesChanged(); }
void NoiseReductionWidget::regularizationEnabledChanged(int value) { if (value == Qt::Checked) m_GREYC_enabled = true; else m_GREYC_enabled = false; updateParam (LUX_FILM, LUX_FILM_NOISE_GREYC_ENABLED, m_GREYC_enabled); emit valuesChanged(); }
void NoiseReductionWidget::chiuEnabledChanged(int value) { if (value == Qt::Checked) m_Chiu_enabled = true; else m_Chiu_enabled = false; updateParam (LUX_FILM, LUX_FILM_NOISE_CHIU_ENABLED, m_Chiu_enabled); emit valuesChanged(); }
void NoiseReductionWidget::fastApproximationEnabledChanged(int value) { if (value == Qt::Checked) m_GREYC_fast_approx = true; else m_GREYC_fast_approx = false; updateParam (LUX_FILM, LUX_FILM_NOISE_GREYC_FASTAPPROX, m_GREYC_fast_approx); emit valuesChanged(); }
void NoiseReductionWidget::includeCenterEnabledChanged(int value) { if (value == Qt::Checked) m_Chiu_includecenter = true; else m_Chiu_includecenter = false; updateParam (LUX_FILM, LUX_FILM_NOISE_CHIU_INCLUDECENTER, m_Chiu_includecenter); if (m_Chiu_enabled) emit valuesChanged(); }
// Reset all param default values. void synthv1widget::resetParamValues (void) { resetSwapParams(); for (uint32_t i = 0; i < synthv1::NUM_PARAMS; ++i) { const synthv1::ParamIndex index = synthv1::ParamIndex(i); const float fValue = synthv1_param::paramDefaultValue(index); setParamValue(index, fValue, true); updateParam(index, fValue); m_params_ab[index] = fValue; } }
void GammaWidget::gammaChanged (double value) { m_TORGB_gamma = value; int sliderval = (int)((FLOAT_SLIDER_RES / TORGB_GAMMA_RANGE) * m_TORGB_gamma); updateWidgetValue(ui->slider_gamma, sliderval); updateWidgetValue(ui->spinBox_gamma, m_TORGB_gamma); updateParam (LUX_FILM, LUX_FILM_TORGB_GAMMA, m_TORGB_gamma); emit valuesChanged (); }
void NoiseReductionWidget::spatialChanged(double value) { m_GREYC_dl = value; int sliderval = (int)((FLOAT_SLIDER_RES / GREYC_DL_RANGE) * m_GREYC_dl); updateWidgetValue(ui->slider_spatial, sliderval); updateWidgetValue(ui->spinBox_spatial, m_GREYC_dl); updateParam (LUX_FILM, LUX_FILM_NOISE_GREYC_DL, m_GREYC_dl); if (m_GREYC_enabled) emit valuesChanged(); }
void NoiseReductionWidget::angularChanged(double value) { m_GREYC_da = value; int sliderval = (int)((FLOAT_SLIDER_RES / GREYC_DA_RANGE) * m_GREYC_da); updateWidgetValue(ui->slider_angular, sliderval); updateWidgetValue(ui->spinBox_angular, m_GREYC_da); updateParam (LUX_FILM, LUX_FILM_NOISE_GREYC_DA, m_GREYC_da); if (m_GREYC_enabled) emit valuesChanged(); }
void NoiseReductionWidget::sharpnessChanged(double value) { m_GREYC_sharpness = value; int sliderval = (int)((FLOAT_SLIDER_RES / GREYC_SHARPNESS_RANGE) * m_GREYC_sharpness); updateWidgetValue(ui->slider_sharpness, sliderval); updateWidgetValue(ui->spinBox_sharpness, m_GREYC_sharpness); updateParam (LUX_FILM, LUX_FILM_NOISE_GREYC_SHARPNESS, m_GREYC_sharpness); if (m_GREYC_enabled) emit valuesChanged(); }
void NoiseReductionWidget::anisoChanged(double value) { m_GREYC_anisotropy = value; int sliderval = (int)((FLOAT_SLIDER_RES / GREYC_ANISOTROPY_RANGE) * m_GREYC_anisotropy); updateWidgetValue(ui->slider_aniso, sliderval); updateWidgetValue(ui->spinBox_aniso, m_GREYC_anisotropy); updateParam (LUX_FILM, LUX_FILM_NOISE_GREYC_ANISOTROPY, m_GREYC_anisotropy); if (m_GREYC_enabled) emit valuesChanged(); }
void NoiseReductionWidget::amplitudeChanged(double value) { m_GREYC_amplitude = value; int sliderval = (int)((FLOAT_SLIDER_RES / GREYC_AMPLITUDE_RANGE) * m_GREYC_amplitude); updateWidgetValue(ui->slider_amplitude, sliderval); updateWidgetValue(ui->spinBox_amplitude, m_GREYC_amplitude); updateParam (LUX_FILM, LUX_FILM_NOISE_GREYC_AMPLITUDE, m_GREYC_amplitude); if (m_GREYC_enabled) emit valuesChanged(); }
void NoiseReductionWidget::precisionChanged(double value) { m_GREYC_gauss_prec = value; int sliderval = (int)((FLOAT_SLIDER_RES / GREYC_GAUSSPREC_RANGE) * m_GREYC_gauss_prec); updateWidgetValue(ui->slider_precision, sliderval); updateWidgetValue(ui->spinBox_precision, m_GREYC_gauss_prec); updateParam (LUX_FILM, LUX_FILM_NOISE_GREYC_GAUSSPREC, m_GREYC_gauss_prec); if (m_GREYC_enabled) emit valuesChanged(); }
void NoiseReductionWidget::iterationsChanged(double value) { m_GREYC_nb_iter = value; int sliderval = (int)((FLOAT_SLIDER_RES / GREYC_NB_ITER_RANGE) * m_GREYC_nb_iter); updateWidgetValue(ui->slider_iterations, sliderval); updateWidgetValue(ui->spinBox_iterations, m_GREYC_nb_iter); updateParam (LUX_FILM, LUX_FILM_NOISE_GREYC_NBITER, m_GREYC_nb_iter); if (m_GREYC_enabled) emit valuesChanged(); }
// Param knob (widget) slot. void synthv1widget::paramChanged ( float fValue ) { if (m_iUpdate > 0) return; synthv1widget_knob *pKnob = qobject_cast<synthv1widget_knob *> (sender()); if (pKnob) { const synthv1::ParamIndex index = m_knobParams.value(pKnob); updateParam(index, fValue); updateParamEx(index, fValue); m_ui.StatusBar->showMessage(QString("%1: %2") .arg(pKnob->toolTip()) .arg(pKnob->valueText()), 5000); updateDirtyPreset(true); } }
// Update scheduled controllers param/knob widgets. void synthv1widget::updateSchedParam ( synthv1::ParamIndex index, float fValue ) { ++m_iUpdate; synthv1widget_knob *pKnob = paramKnob(index); if (pKnob) { pKnob->setValue(fValue, false); updateParam(index, fValue); updateParamEx(index, fValue); m_ui.StatusBar->showMessage(QString("%1: %2") .arg(pKnob->toolTip()) .arg(pKnob->valueText()), 5000); updateDirtyPreset(true); } --m_iUpdate; }
// Initialize param values. void synthv1widget::updateParamValues (void) { resetSwapParams(); synthv1_ui *pSynthUi = ui_instance(); for (uint32_t i = 0; i < synthv1::NUM_PARAMS; ++i) { const synthv1::ParamIndex index = synthv1::ParamIndex(i); const float fValue = (pSynthUi ? pSynthUi->paramValue(index) : synthv1_param::paramDefaultValue(index)); setParamValue(index, fValue, true); updateParam(index, fValue); // updateParamEx(index, fValue); m_params_ab[index] = fValue; } }
void NoiseReductionWidget::chiuRadiusChanged(double value) { m_Chiu_radius = value; if ( m_Chiu_radius > CHIU_RADIUS_MAX ) m_Chiu_radius = CHIU_RADIUS_MAX; else if ( m_Chiu_radius < CHIU_RADIUS_MIN ) m_Chiu_radius = CHIU_RADIUS_MIN; int sliderval = (int)(( FLOAT_SLIDER_RES / (CHIU_RADIUS_MAX - CHIU_RADIUS_MIN) ) * (m_Chiu_radius - CHIU_RADIUS_MIN) ); updateWidgetValue(ui->slider_chiuRadius, sliderval); updateWidgetValue(ui->spinBox_chiuRadius, m_Chiu_radius); updateParam (LUX_FILM, LUX_FILM_NOISE_CHIU_RADIUS, m_Chiu_radius); if (m_Chiu_enabled) emit valuesChanged(); }
void GammaWidget::activateCRF() { if(!m_CRF_file.isEmpty()) { m_CRF_enabled = true; QFileInfo fi(m_CRF_file); // Validate current selection... if ( m_CRF_file != ui->combo_CRF_List->itemData( ui->combo_CRF_List->currentIndex() ).toString() ) { if ( fi.suffix().toLower() == "crf" || fi.suffix().toLower() == "txt" || fi.exists() ) { ui->combo_CRF_List->insertItem( 1, fi.fileName(), QVariant( m_CRF_file ) ); ui->combo_CRF_List->setCurrentIndex( 1 ); } else // look for existing preset. { int lIndex = ui->combo_CRF_List->findData( QVariant( m_CRF_file ) ); if ( lIndex != -1 ) ui->combo_CRF_List->setCurrentIndex( lIndex ); else // Invalid preset... { m_CRF_enabled = false; } } } updateWidgetValue(ui->checkBox_CRF, m_CRF_enabled); updateParam(LUX_FILM, LUX_FILM_CAMERA_RESPONSE_ENABLED, m_CRF_enabled); if ( m_CRF_enabled ) { #if defined(__APPLE__) // OSX locale is UTF-8, TODO check this for other OS luxSetStringAttribute("film", "CameraResponse", m_CRF_file.toUtf8().data()); #else luxSetStringAttribute("film", "CameraResponse", m_CRF_file.toAscii().data()); #endif } } }
void GammaWidget::LoadSettings( QString fName ) { QSettings settings( fName, QSettings::IniFormat ); settings.beginGroup("gamma"); if ( settings.status() ) return; m_TORGB_gamma = settings.value("TORGB_gamma", 2.2 ).toDouble(); m_CRF_enabled = settings.value("CRF_enabled", false ).toBool(); m_CRF_file = settings.value("CRF_file", "" ).toString(); settings.endGroup(); updateWidgetValues(); updateParam(LUX_FILM, LUX_FILM_TORGB_GAMMA, (this->isEnabled() ? m_TORGB_gamma : 1.0)); if ( m_CRF_enabled ) { activateCRF(); } emit valuesChanged(); }
// Reset all param knobs to default values. void synthv1widget::resetParams (void) { synthv1_ui *pSynthUi = ui_instance(); if (pSynthUi == NULL) return; pSynthUi->reset(); resetSwapParams(); for (uint32_t i = 0; i < synthv1::NUM_PARAMS; ++i) { const synthv1::ParamIndex index = synthv1::ParamIndex(i); float fValue = synthv1_param::paramDefaultValue(index); synthv1widget_knob *pKnob = paramKnob(index); if (pKnob) fValue = pKnob->defaultValue(); setParamValue(index, fValue); updateParam(index, fValue); m_params_ab[index] = fValue; } m_ui.StatusBar->showMessage(tr("Reset preset"), 5000); updateDirtyPreset(false); }
void RenderWindow::fileOpen(const QString & filename) { QDomDocument doc; QString errMsg; int errLine, errColm; QFile file(filename); if(!doc.setContent(&file, &errMsg, &errLine, &errColm)) { QMessageBox::critical(this, tr("Error Loading File"), tr("There was an error opening the file %1." "\n\n%2 on line %3 column %4.") .arg(filename).arg(errMsg).arg(errLine).arg(errColm) ); return; } QDomElement root = doc.documentElement(); if(root.tagName() != "report") { QMessageBox::critical(this, tr("Not a Valid File"), tr("The file %1 does not appear to be a valid file." "\n\nThe root node is not 'report'.").arg(filename) ); return; } _doc = doc; _report->setText(filename); _reportInfo->setEnabled(true); _reportName->setText(QString::null); _reportTitle->setText(QString::null); _reportDescription->setText(QString::null); for(QDomNode n = root.firstChild(); !n.isNull(); n = n.nextSibling()) { if(n.nodeName() == "name") _reportName->setText(n.firstChild().nodeValue()); else if(n.nodeName() == "title") _reportTitle->setText(n.firstChild().nodeValue()); else if(n.nodeName() == "description") _reportDescription->setText(n.firstChild().nodeValue()); else if(n.nodeName() == "parameter") { QDomElement elemSource = n.toElement(); ORParameter param; param.name = elemSource.attribute("name"); if(param.name.isEmpty()) continue; param.type = elemSource.attribute("type"); param.defaultValue = elemSource.attribute("default"); param.active = (elemSource.attribute("active") == "true"); param.listtype = elemSource.attribute("listtype"); QList<QPair<QString,QString> > pairs; if(param.listtype.isEmpty()) param.description = elemSource.text(); else { QDomNodeList section = elemSource.childNodes(); for(int nodeCounter = 0; nodeCounter < section.count(); nodeCounter++) { QDomElement elemThis = section.item(nodeCounter).toElement(); if(elemThis.tagName() == "description") param.description = elemThis.text(); else if(elemThis.tagName() == "query") param.query = elemThis.text(); else if(elemThis.tagName() == "item") param.values.append(qMakePair(elemThis.attribute("value"), elemThis.text())); else qDebug("While parsing parameter encountered an unknown element: %s",(const char*)elemThis.tagName()); } } QVariant defaultVar; if(!param.defaultValue.isEmpty()) defaultVar = QVariant(param.defaultValue); if("integer" == param.type) defaultVar = defaultVar.toInt(); else if("double" == param.type) defaultVar = defaultVar.toDouble(); else if("bool" == param.type) defaultVar = QVariant(defaultVar.toBool(), 0); else defaultVar = defaultVar.toString(); updateParam(param.name, defaultVar, param.active); QList<QPair<QString, QString> > list; if("static" == param.listtype) list = param.values; else if("dynamic" == param.listtype && !param.query.isEmpty()) { QSqlQuery qry(param.query); while(qry.next()) list.append(qMakePair(qry.value(0).toString(), qry.value(1).toString())); } if(!list.isEmpty()) _lists.insert(param.name, list); } } }
bool ParameterEdit::setDocument(const QDomDocument & doc) { QDomElement root = doc.documentElement(); if(root.tagName() != "report") { QMessageBox::critical(this, tr("Not a Valid Report"), tr("The report definition does not appear to be a valid report." "\n\nThe root node is not 'report'.")); return false; } _list->show(); _new->hide(); _delete->hide(); for(QDomNode n = root.firstChild(); !n.isNull(); n = n.nextSibling()) { if(n.nodeName() == "parameter") { QDomElement elemSource = n.toElement(); ORParameter param; param.name = elemSource.attribute("name"); if(param.name.isEmpty()) continue; param.type = elemSource.attribute("type"); param.defaultValue = elemSource.attribute("default"); param.active = (elemSource.attribute("active") == "true"); param.listtype = elemSource.attribute("listtype"); QList<QPair<QString,QString> > pairs; if(param.listtype.isEmpty()) param.description = elemSource.text(); else { QDomNodeList section = elemSource.childNodes(); for(int nodeCounter = 0; nodeCounter < section.count(); nodeCounter++) { QDomElement elemThis = section.item(nodeCounter).toElement(); if(elemThis.tagName() == "description") param.description = elemThis.text(); else if(elemThis.tagName() == "query") param.query = elemThis.text(); else if(elemThis.tagName() == "item") param.values.append(qMakePair(elemThis.attribute("value"), elemThis.text())); else qDebug("While parsing parameter encountered an unknown element: %s",(const char*)elemThis.tagName().toLatin1().data()); } } QVariant defaultVar; if(!param.defaultValue.isEmpty()) defaultVar = QVariant(param.defaultValue); if("integer" == param.type) defaultVar = defaultVar.toInt(); else if("double" == param.type) defaultVar = defaultVar.toDouble(); else if("bool" == param.type) defaultVar = QVariant(defaultVar.toBool()); else defaultVar = defaultVar.toString(); updateParam(param.name, defaultVar, param.active); QList<QPair<QString, QString> > list; if("static" == param.listtype) list = param.values; else if("dynamic" == param.listtype && !param.query.isEmpty()) { QSqlQuery qry(param.query); while(qry.next()) list.append(qMakePair(qry.value(0).toString(), qry.value(1).toString())); } if(!list.isEmpty()) _lists.insert(param.name, list); } } if(_lists.isEmpty()) return false; // no defined parameters else return true; }