void PowerLawWidgetManager::updateConnections() { if (m_Widgets.size() == 0) { return; } auto first = *(m_Widgets.cbegin()); auto last = *(m_Widgets.cend() - 1); if (m_Widgets.size() == 1) { first->lockMin(true); first->lockMax(true); } else if (m_Widgets.size() == 2) { first->lockMin(true); last->lockMax(true); first->setMax(0); last->setMin(0); first->connect(last); } else { auto previousLast = *(m_Widgets.cend() - 2); auto min = previousLast->getMin(); previousLast->setMax(min + 1); last->setMin(min + 1); last->lockMax(true); previousLast->connect(last); } }
void GenericSliderProperties::OnButton(wxCommandEvent& event) { int id = event.GetId(); wxObject *obj = event.GetEventObject(); if(isDecimal)incr = 0.01; else incr = 1; if(id == ID_INCRUP) { if(obj == min_up)setMin(min+incr); if(obj == max_up)setMax(max+incr); if(obj == tick_up)setTick(tick+1); } if(id == ID_INCRDOWN) { if(obj == min_down)setMin(min-incr); if(obj == max_down)setMax(max-incr); if(obj == tick_down)setTick(tick-1); } if(id == ID_ACCEPT2) { winSlider->setCurrentMinMax(min,max); winSlider->setTicks(tick); winSlider->Refresh(false); Close(true); } if(id == ID_CANCEL2) { winSlider->setCurrentMinMax(minOld,maxOld); winSlider->setTicks(tickOld); winSlider->getValueText()->SetBackgroundColour(colorPanelOld); winSlider->Refresh(false); Close(true); } if(id == ID_APPLY) { winSlider->setCurrentMinMax(min,max); winSlider->setTicks(tick); winSlider->Refresh(false); } if(id == ID_COLOR2) { wxColourDialog dial(this); dial.SetTitle(wxT("Color Picker")); if(dial.ShowModal()!= wxID_OK)return; colorPanel = dial.GetColourData().GetColour(); winSlider->getValueText()->SetBackgroundColour(colorPanel); winSlider->Refresh(false); } event.Skip(); }
void k9PlayMPEG2::open (dvd_reader_t *dvd,const QString & device,k9DVDTitle * title,int chapter=0) { m_dvd=dvd; m_chapter=chapter; int ret = 0; struct stat dvd_stat; QString c; m_idxLect=0xFFFFFFFF; stop(); m_title=title; m_device=device; m_startSector=0; m_lastSector=0; ret = stat(device.utf8(), &dvd_stat); /* if ( ret < 0 ) { c=i18n("Can't find device %1\n").arg(device.latin1()); setError(c); return; } */ m_title=title; m_startSector=m_title->getChapter( 0)->getstartSector(); m_lastSector= m_startSector + m_title->getsectors(); //m_title->getChapter(m_title->getchapterCount()-1)->getendSector(); emit setPosition( m_startSector); emit setMax( m_lastSector); emit setMin( m_startSector); m_decoder.start(QThread::LowPriority); start(); }
CHYSTBlock::CHYSTBlock(const char* configString) : CBlock(configString) { CString tempString; float setpoint=0.0, delta=0.0, Min=0.0, Max=0.0; //Get HYST type and parameters m_LibIniReader.GetConfigParamString( configString, "TYPE", &tempString, "HYST"); for (int i = 0; i < HYST_TYPE_NUM_TOT; i++) { if (tempString == HYST_Type_Strings[i]) { m_HYSTType = (e_HYSTType)i; m_LibIniReader.GetConfigParamFloat( configString, "SETPOINT", &setpoint, 0.0); m_LibIniReader.GetConfigParamFloat( configString, "DELTA", &delta, 0.0); m_LibIniReader.GetConfigParamFloat( configString, "MIN", &Min, 0.0); m_LibIniReader.GetConfigParamFloat( configString, "MAX", &Max, 0.0); setSetpoint(&setpoint); setDelta(&delta); setLastOutput(&Min); setMin(&Min); setMax(&Max); } } }
void ofxSelectSlider::setLabels(vector<string> & _labels){ setMax(_labels.size()-1); if(value > getMax()){ value = getMax(); } labels = _labels; }
//------------------------------------------------------------ //------------------------------------------------------------ bool Uniform::setSlotMax(const Number* const x) { bool ok = false; if(x != 0) ok = setMax(x->getDouble()); return ok; }
/** Constructor, derived from coRowToolboxItem. @param name Label text. @param min,max Minimum and maximum slider values. @param init Initial slider value. @see coRowToolboxItem */ coSliderToolboxItem::coSliderToolboxItem(const std::string &name, float min, float max, float init) : coToolboxMenuItem(name) { slider = new coSlider(this); minLabel = new coLabel(); maxLabel = new coLabel(); label = new coLabel(); setLabel(name); // Constrain initialization values: if (max < min) max = min; init = coClamp(init, min, max); setMin(min); setMax(max); setValue(init); menuContainer->setOrientation(coRowContainer::HORIZONTAL); menuContainer->addElement(minLabel); menuContainer->addElement(slider); menuContainer->addElement(maxLabel); menuContainer->addElement(label); // menuContainer->addElement(label); vruiIntersection::getIntersectorForAction("coAction")->add(background->getDCS(), this); }
LoadingBar::LoadingBar(int min, int max, bool autoshow) : QDialog(NULL) { SetupUI(autoshow); setMax(max); setMin(min); SetupConnections(); }
Chunk * Chunk::split( const BSONObj& m ){ uassert( 10165 , "can't split as shard that doesn't have a manager" , _manager ); log(1) << " before split on: " << m << "\n" << "\t self : " << toString() << endl; uassert( 10166 , "locking namespace on server failed" , lockNamespaceOnServer( getShard() , _ns ) ); Chunk * s = new Chunk( _manager ); s->_ns = _ns; s->_shard = _shard; s->setMin(m.getOwned()); s->setMax(_max); s->_markModified(); _markModified(); _manager->_chunks.push_back( s ); setMax(m.getOwned()); log(1) << " after split:\n" << "\t left : " << toString() << "\n" << "\t right: "<< s->toString() << endl; _manager->save(); return s; }
void PowerLawWidgetManager::loadFromXml(TiXmlElement *_root) { std::vector < PowerLawWidget * > widgets; double valFactor, valExponent, valOffset, valMin, valMax; for (auto child = _root->FirstChildElement("PowerLawParameters"); child; child = child->NextSiblingElement()) { auto r0 = child->QueryDoubleAttribute("factor", &valFactor); auto r1 = child->QueryDoubleAttribute("exponent", &valExponent); auto r2 = child->QueryDoubleAttribute("offset", &valOffset); auto r3 = child->QueryDoubleAttribute("rangeMin", &valMin); auto r4 = child->QueryDoubleAttribute("rangeMax", &valMax); if (r0 == TIXML_SUCCESS && r1 == TIXML_SUCCESS && r2 == TIXML_SUCCESS && r3 == TIXML_SUCCESS && r4 == TIXML_SUCCESS) { auto w = new PowerLawWidget(); w->setFactor(valFactor); w->setExponent(valExponent); w->setOffset(valOffset); w->setMin(valMin); w->setMax(valMax); widgets.push_back(w); } else { QMessageBox::warning(0, "failed to load power laws", "could not load power laws: invalid file structure."); return; } } setPowerLawWidgets(widgets); }
//------------------------------------------// // Problem 2: There is a requirement that // at least 400 DOMs launch. I want to look // at the average, and maybe also the average // for given event range. //------------------------------------------// void checkNDOM(TTree* tree) { // Plot the number of DOM's per event TString var = "DetectorResponseEvent_.totalNumberOfDom_"; // Make canvas TCanvas* c = makeCanvas("c"); // Make a vector of TCuts vector<TString> cuts; cuts.push_back("1"); // 1% cuts.push_back("3"); // 3% cuts.push_back("10"); // 10% cuts.push_back("30"); // 30% cuts.push_back("51"); // 51% cuts.push_back("100"); // 100% // Create histogram holders TH1F* hists[6]; int nbins = 100; int min = 0; int max = 2000; TString xtitle = "nDOMs"; TString ytitle = "Entries"; // Make legend TLegend* leg = makeLegend(0.7,0.8,0.6,0.9); leg->SetHeader("Luminosity"); // Loop and draw float maximum = -999; for(unsigned int i=0; i<cuts.size(); ++i){ // get cut value TString cutval = cuts.at(i); // create histogram hists[i] = makeFrame("hist_"+cutval,nbins,min,max, xtitle,ytitle); // cut the TCut object from value TCut cut = lumiCut(cutval); // Draw and set att tree->Draw((var+">>hist_"+cutval).Data(),cut,"hist"); setAtt(hists[i],xtitle,ytitle,m_colors[i],m_markers[i]); setMax(hists[i],maximum); // Add to legend leg->AddEntry(hists[i],(cutval+"%").Data(),"l"); } // Now draw the figures hists[0]->SetMaximum(maximum*1.1); hists[0]->Draw("hist"); for(unsigned int i=1; i<cuts.size(); ++i) hists[i]->Draw("samehist"); leg->Draw("same"); c->SaveAs((savedir+"nDoms_perLumi.png").Data()); }
int notify(int n, void *p) { Q_UNUSED(p); if( !n || n&LH_NOTE_MEM ) { qreal totalMem = 0; if( state()->mem_data.tot_phys ) totalMem += state()->mem_data.tot_phys; if( state()->mem_data.tot_virt ) totalMem += state()->mem_data.tot_virt; setMax(1000.0); qreal *mem = new qreal[ 4 ]; if( mem ) { if(needleCount() != 4) { clearNeedles(); addNeedle("Used Physical Memory",QColor::fromRgb(192,0,0)); addNeedle("Used Virtual Memory",QColor::fromRgb(0,0,192)); addNeedle("Free Virtual Memory",QColor::fromRgb(192,192,255,96)); addNeedle("Free Physical Memory",QColor::fromRgb(255,192,192,96)); } mem[0] = ( !state()->mem_data.tot_phys? 0 : (state()->mem_data.tot_phys - state()->mem_data.free_phys) / totalMem * 1000.0); mem[1] = ( !state()->mem_data.tot_virt? 0 : (state()->mem_data.tot_virt - state()->mem_data.free_virt) / totalMem * 1000.0); mem[2] = ( !state()->mem_data.tot_virt? 0 : (state()->mem_data.free_virt) / totalMem * 1000.0); mem[3] = ( !state()->mem_data.tot_phys? 0 : (state()->mem_data.free_phys) / totalMem * 1000.0); setVal( mem, 4 ); delete[] mem; } } return LH_NOTE_MEM; }
void AABB::moveTo(Vector3 newPosition) { Vector3 change = newPosition - this->origin; setMax(this->origin + change); setMin(this->origin - change); this->origin = newPosition; }
Square::Square(int size, double xc, double yc) { setCenter(xc,yc); setSize(size); setMax(rightX, upY); }
int notify(int code, void *param) { if( !code || code&LH_NOTE_NET ) { bool needrender = setValue( state()->net_cur_in ) | setMax( state()->net_max_in ); // bitwise OR - we need both to execute! if( needrender ) callback(lh_cb_render,NULL); } return LH_TextNumber::notify(code,param) | LH_NOTE_SECOND; }
void MixerCurve::initLinearCurve(int numPoints, double maxValue, double minValue) { setMin(minValue); setMax(maxValue); m_curve->initLinearCurve(numPoints, maxValue, minValue); if (m_spinDelegate) m_spinDelegate->setRange(minValue, maxValue); }
bool LH_NowPlayingBar::setValue(int val,int max) { setMax(max); if(value_ != val) { value_ = val; return true; } else return false; }
DSVector& DSVector::operator=(const Vector& vec) { clear(); setMax(vec.dim()); SVector::operator=(vec); assert(DSVector::isConsistent()); return *this; }
//! Reads attributes of the element void CGUIProgressBar::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) { IGUIProgressBar::deserializeAttributes(in,options); Horizontal = in->getAttributeAsBool("Horizontal"); setMax(in->getAttributeAsInt("Max")); setPos(in->getAttributeAsInt("Value")); setBackground(in->getAttributeAsColor("Background")); setForeground(in->getAttributeAsColor("Foreground")); }
bool coSliderToolboxItem::updateContentRange(float min, float max, float value, bool isInteger, float) { setMax(max); setMin(min); setValue(value); setInteger(isInteger); if (listener) listener->menuEvent(this); return true; }
int ValueWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 2) qt_static_metacall(this, _c, _id, _a); _id -= 2; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 2) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 2; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< float*>(_v) = value(); break; case 1: *reinterpret_cast< float*>(_v) = min(); break; case 2: *reinterpret_cast< float*>(_v) = max(); break; case 3: *reinterpret_cast< int*>(_v) = nbStep(); break; } _id -= 4; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setValue(*reinterpret_cast< float*>(_v)); break; case 1: setMin(*reinterpret_cast< float*>(_v)); break; case 2: setMax(*reinterpret_cast< float*>(_v)); break; case 3: setNbStep(*reinterpret_cast< int*>(_v)); break; } _id -= 4; } else if (_c == QMetaObject::ResetProperty) { _id -= 4; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 4; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 4; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 4; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 4; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 4; } else if (_c == QMetaObject::RegisterPropertyMetaType) { if (_id < 4) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 4; } #endif // QT_NO_PROPERTIES return _id; }
std::vector<unsigned int> primeGen::getPrimes(unsigned long long int max) { if (max != 0) { setMax(max); calc(); } else if (primes.size() == 0) { calc(); } return primes; }
Rpm::Rpm( ) { // set(0.0); // set(100.0); setMax(16000.0); setMin(0.0); /* connect(this, SIGNAL( changed(double) ), this, SLOT( on_changed() ) ); */ }
//! Reads attributes of the element void CGUIScrollBar::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) { IGUIScrollBar::deserializeAttributes(in,options); Horizontal = in->getAttributeAsBool("Horizontal"); setMax(in->getAttributeAsInt("Max")); setPos(in->getAttributeAsInt("Value")); setSmallStep(in->getAttributeAsInt("SmallStep")); setLargeStep(in->getAttributeAsInt("LargeStep")); refreshControls(); }
bool QLCCapability::loadXML(const QDomElement* root) { uchar min; uchar max; QString str; Q_ASSERT(root != NULL); if (root->tagName() != KXMLQLCCapability) { qWarning() << Q_FUNC_INFO << "Capability node not found"; return false; } /* Get low limit attribute (critical) */ str = root->attribute(KXMLQLCCapabilityMin); if (str.isEmpty() == true) { qWarning() << Q_FUNC_INFO << "Capability has no minimum limit."; return false; } else { min = CLAMP(str.toInt(), 0, UCHAR_MAX); } /* Get high limit attribute (critical) */ str = root->attribute(KXMLQLCCapabilityMax); if (str.isEmpty() == true) { qWarning() << Q_FUNC_INFO << "Capability has no maximum limit."; return false; } else { max = CLAMP(str.toInt(), 0, UCHAR_MAX); } if (min <= max) { setName(root->text()); setMin(min); setMax(max); return true; } else { qWarning() << Q_FUNC_INFO << "Capability min(" << min << ") is greater than max(" << max << ")"; return false; } }
void LeapMotionPlugin::init() { loadSettings(); auto preferences = DependencyManager::get<Preferences>(); static const QString LEAPMOTION_PLUGIN { "Leap Motion" }; { auto getter = [this]()->bool { return _enabled; }; auto setter = [this](bool value) { _enabled = value; saveSettings(); if (!_enabled) { auto userInputMapper = DependencyManager::get<controller::UserInputMapper>(); userInputMapper->withLock([&, this]() { _inputDevice->clearState(); }); } }; auto preference = new CheckPreference(LEAPMOTION_PLUGIN, "Enabled", getter, setter); preferences->addPreference(preference); } { auto getter = [this]()->QString { return _sensorLocation; }; auto setter = [this](QString value) { _sensorLocation = value; saveSettings(); applySensorLocation(); }; auto preference = new ComboBoxPreference(LEAPMOTION_PLUGIN, "Sensor location", getter, setter); QStringList list = { SENSOR_ON_DESKTOP, SENSOR_ON_HMD }; preference->setItems(list); preferences->addPreference(preference); } { auto getter = [this]()->float { return _desktopHeightOffset; }; auto setter = [this](float value) { _desktopHeightOffset = value; saveSettings(); applyDesktopHeightOffset(); }; auto preference = new SpinnerPreference(LEAPMOTION_PLUGIN, "Desktop height for horizontal forearms", getter, setter); float MIN_VALUE = 0.0f; float MAX_VALUE = 1.0f; float DECIMALS = 2.0f; float STEP = 0.01f; preference->setMin(MIN_VALUE); preference->setMax(MAX_VALUE); preference->setDecimals(DECIMALS); preference->setStep(STEP); preferences->addPreference(preference); } }
bool SdlJoystick::config(jccl::ConfigElementPtr e) { if (!gadget::Digital::config(e)) return false; if (!gadget::Analog::config(e)) return false; if (!gadget::Input::config(e)) return false; //if (!gadget::Rumble::config(e)) return false; mDeviceNumber = e->getProperty<int>("device"); setMin(-32767.0f); setMax(32767.0f); return true; }
//! Reads attributes of the element void CGUIScrollBar::deserializeAttributes(IAttributes* in, SAttributeReadWriteOptions* options = 0) { IGUIScrollBar::deserializeAttributes(in, options); Horizontal = in->getAttributeAsBool("Horizontal"); setMin(in->getAttributeAsInt("Min")); setMax(in->getAttributeAsInt("Max")); setPos(in->getAttributeAsInt("Value")); setSmallStep(in->getAttributeAsInt("SmallStep")); setLargeStep(in->getAttributeAsInt("LargeStep")); // CurrentIconColor - not serialized as continuiously updated refreshControls(); }
void Observable::setLikelihoodFromHisto(std::string filename, std::string histoname) { this->filename = filename; this->histoname = histoname; TFile *lik = new TFile((filename + ".root").c_str(), "read"); TH1D *htmp = (TH1D*) (lik->Get(histoname.c_str())); if (htmp == NULL) throw std::runtime_error("ERROR: nonexistent histogram called " + histoname + " in " + filename + ".root"); inhisto = (TH1D *) htmp->Clone((filename + "/" + histoname).c_str()); inhisto->SetDirectory(gROOT); setMin(inhisto->GetXaxis()->GetXmin()); setMax(inhisto->GetXaxis()->GetXmax()); lik->Close(); delete lik; }
static Optional<IntConstraint> createIntConstraint(const Dictionary& mediaTrackConstraintSet, const String& name, MediaConstraintType type, ConstraintSetType constraintSetType) { auto constraint = IntConstraint(name, type); // Dictionary constraint value. Dictionary dictionaryValue; if (mediaTrackConstraintSet.get(name, dictionaryValue) && !dictionaryValue.isUndefinedOrNull()) { int minValue; if (dictionaryValue.get("min", minValue)) constraint.setMin(minValue); int maxValue; if (dictionaryValue.get("max", maxValue)) constraint.setMax(maxValue); int exactValue; if (dictionaryValue.get("exact", exactValue)) constraint.setExact(exactValue); int idealValue; if (dictionaryValue.get("ideal", idealValue)) constraint.setIdeal(idealValue); if (constraint.isEmpty()) { LOG(Media, "createIntConstraint() - ignoring long constraint '%s' with dictionary value since it has no valid or supported key/value pairs.", name.utf8().data()); return Nullopt; } return WTFMove(constraint); } // Scalar constraint value. int value; if (mediaTrackConstraintSet.get(name, value)) { if (constraintSetType == ConstraintSetType::Mandatory) constraint.setIdeal(value); else constraint.setExact(value); return WTFMove(constraint); } // Invalid constraint value. LOG(Media, "createIntConstraint() - ignoring long constraint '%s' since it has neither a dictionary nor scalar value.", name.utf8().data()); return Nullopt; }