// increment given range [l,r] by diff void updateRange(Int node, int start, int end, int l, int r, int diff) { // lazy propagation if (lazy[node] != 0) { tree[node] += (end-start+1)*lazy[node]; if (start != end) { lazy[2*node] += lazy[node]; lazy[2*node+1] += lazy[node]; } lazy[node] = 0; } if (r < start || end < l) return; if (l <= start && end <= r) { tree[node] += (end-start+1)*diff; if (start != end) { lazy[2*node] += diff; lazy[2*node+1] += diff; } return; } Int mid = (start + end)/2; updateRange(2*node, start, mid, l, r, diff); updateRange(2*node+1, mid+1, end, l, r, diff); tree[node] = tree[2*node] + tree[2*node+1]; }
/*! Zoom the plot until \a lowerTime and \a upperTime will be visible in the range. */ void UiTimeAxis::zoomAll(double lowerTime, double upperTime) { double interval = upperTime - lowerTime; if (interval <= 0) return; setReference(mMajorStepTime); updateRange(); while (upperTime < mRangeUpper) { zoom(1, 0); setReference(mMajorStepTime); updateRange(); } while (upperTime > mRangeUpper) { zoom(-1, 0); setReference(mMajorStepTime); updateRange(); } setReference(mMajorStepTime-(mRangeUpper-upperTime)/2); updateRange(); }
void updateRange(int x, int l, int r, int ql, int qr, ll v) { resolve(x, l, r); if(l > qr || r < ql) return; if(l >= ql && r <= qr) { T[x].val = v; T[x].push = true; resolve(x, l, r); return; } int m = (l + r) >> 1; updateRange(l(x), l, m, ql, qr, v); updateRange(r(x), m + 1, r, ql, qr, v); T[x].combine(T[l(x)], T[r(x)]); }
Flipbook::Flipbook(QWidget *parent) : QDialog(parent), m_ui(new Ui_Flipbook), m_layers(nullptr) { m_ui->setupUi(this); m_timer = new QTimer(this); connect(m_ui->rewindButton, &QToolButton::clicked, this, &Flipbook::rewind); connect(m_ui->playButton, &QToolButton::clicked, this, &Flipbook::playPause); connect(m_ui->layerIndex, QOverload<int>::of(&QSpinBox::valueChanged), this, &Flipbook::loadFrame); connect(m_ui->loopStart, QOverload<int>::of(&QSpinBox::valueChanged), this, &Flipbook::updateRange); connect(m_ui->loopEnd, QOverload<int>::of(&QSpinBox::valueChanged), this, &Flipbook::updateRange); connect(m_ui->fps, QOverload<int>::of(&QSpinBox::valueChanged), this, &Flipbook::updateFps); connect(m_timer, &QTimer::timeout, m_ui->layerIndex, &QSpinBox::stepUp); connect(m_ui->view, &FlipbookView::cropped, this, &Flipbook::setCrop); connect(m_ui->zoomButton, &QToolButton::clicked, this, &Flipbook::resetCrop); updateRange(); m_ui->playButton->setFocus(); // Load default settings QSettings cfg; cfg.beginGroup("flipbook"); m_ui->fps->setValue(cfg.value("fps", 15).toInt()); QRect geom = cfg.value("window", QRect()).toRect(); if(geom.isValid()) { setGeometry(geom); } // Autoplay m_ui->playButton->click(); }
/*! Zoom by specified number of \a steps centered around the given x coordinate \a xCenter. */ void UiTimeAxis::zoom(int steps, double xCenter) { double center = pixelToTimeRelativeRef(xCenter); double newValue = 0; double factor = 0.5; int majorUnitValue = closestUnitDigit(mMajorStepTime); if (steps < 0) { steps = -steps; factor = 2.0; if (majorUnitValue == 2) factor = 2.5; } else { factor = 0.5; if (majorUnitValue == 5) factor = 0.4; } factor = factor*steps; newValue = mMajorStepTime * factor; // lower and upper limit on the major step if (factor < 1 && newValue < qPow(10, MinStepAsPowOf10)) return; if (factor > 1 && newValue > qPow(10, MaxStepAsPowOf10)) return; // zoom around the center point mMajorStepTime = newValue; //mRefTime = center - (center-mRefTime)*factor; setReference(center - (center-mRefTime)*factor); updateRange(); }
SliderComp (LivePropertyEditorBase& e, bool useFloat) : editor (e), isFloat (useFloat) { slider.setTextBoxStyle (Slider::NoTextBox, true, 0, 0); addAndMakeVisible (slider); updateRange(); slider.addListener (this); }
void ColorMap::setIndex(int _index) { if(_index >= 0) { index = _index; updateRange(); } }
void ColorMap::setDataCube(DataCube * _cube) { if(_cube) { dc = _cube; updateRange(); } }
void GanttWidget::prevLimits() { if(m_stackLimits.isEmpty()) return; std::pair<UtcDateTime,UtcDateTime> limits = m_stackLimits.last(); m_stackLimits.pop_back(); updateRange(limits.first,limits.second); }
/*! Move the time axis \a differenceInPixels number of pixels */ void UiTimeAxis::moveAxis(int differenceInPixels) { setReference(mRefTime + (differenceInPixels*(mMajorStepTime/MajorStepPixelWidth))); updateRange(); update(); }
// ---------------------------------------------------------------------------- void ctkVTKVolumePropertyWidget::updateFromVolumeProperty() { Q_D(ctkVTKVolumePropertyWidget); vtkColorTransferFunction* colorTransferFunction = 0; vtkPiecewiseFunction* opacityFunction = 0; vtkPiecewiseFunction* gradientFunction = 0; if (d->VolumeProperty) { colorTransferFunction = d->VolumeProperty->GetRGBTransferFunction()->GetSize() ? d->VolumeProperty->GetRGBTransferFunction() : 0; opacityFunction = d->VolumeProperty->GetScalarOpacity()->GetSize() ? d->VolumeProperty->GetScalarOpacity() : 0; gradientFunction = d->VolumeProperty->GetGradientOpacity()->GetSize() ? d->VolumeProperty->GetGradientOpacity() : 0; } d->ScalarOpacityThresholdWidget->setPiecewiseFunction(this->isThresholdVisible() ? opacityFunction : 0); this->qvtkDisconnect(0, vtkCommand::EndInteractionEvent, this, SLOT(updateRange())); this->qvtkConnect(opacityFunction, vtkCommand::EndInteractionEvent, this, SLOT(updateRange()), 0., Qt::QueuedConnection); this->qvtkConnect(opacityFunction, vtkCommand::EndEvent, this, SLOT(updateRange()), 0., Qt::QueuedConnection); this->qvtkConnect(colorTransferFunction, vtkCommand::EndInteractionEvent, this, SLOT(updateRange()), 0., Qt::QueuedConnection); this->qvtkConnect(colorTransferFunction, vtkCommand::EndEvent, this, SLOT(updateRange()), 0., Qt::QueuedConnection); this->qvtkConnect(gradientFunction, vtkCommand::EndInteractionEvent, this, SLOT(updateRange()), 0., Qt::QueuedConnection); this->qvtkConnect(gradientFunction, vtkCommand::EndEvent, this, SLOT(updateRange()), 0., Qt::QueuedConnection); d->ScalarOpacityWidget->view()->setOpacityFunctionToPlots(opacityFunction); d->ScalarOpacityWidget->view()->setColorTransferFunctionToPlots(colorTransferFunction); d->ScalarColorWidget->view()->setColorTransferFunctionToPlots(colorTransferFunction); d->GradientWidget->view()->setPiecewiseFunctionToPlots(gradientFunction); if (d->VolumeProperty) { d->InterpolationComboBox->setCurrentIndex( d->VolumeProperty->GetInterpolationType() == VTK_NEAREST_INTERPOLATION ? 0 : 1); d->ShadeCheckBox->setChecked( d->VolumeProperty->GetShade(d->CurrentComponent)); d->MaterialPropertyWidget->setAmbient( d->VolumeProperty->GetAmbient(d->CurrentComponent)); d->MaterialPropertyWidget->setDiffuse( d->VolumeProperty->GetDiffuse(d->CurrentComponent)); d->MaterialPropertyWidget->setSpecular( d->VolumeProperty->GetSpecular(d->CurrentComponent)); d->MaterialPropertyWidget->setSpecularPower( d->VolumeProperty->GetSpecularPower(d->CurrentComponent)); } this->updateRange(); }
BOOL CEditableRange::OnInitDialog() { CDialog::OnInitDialog(); updateRange(); updateValueFromReader(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
SpectrumEditor SpectrumEditor_create (const wchar_t *title, Spectrum data) { try { autoSpectrumEditor me = Thing_new (SpectrumEditor); FunctionEditor_init (me.peek(), title, data); my cursorHeight = -1000; updateRange (me.peek()); return me.transfer(); } catch (MelderError) { Melder_throw ("Spectrum window not created."); } }
/* ダンジョンをすすめる map : x : 現在座標X y : 現在座標Y plen: ダンジョンの進めた長さ max : 最大値 [x, y] min : 最小値 [x, y] */ void dig(uchar map[FIELD_SZ][FIELD_SZ], uchar* x, uchar* y, uchar dir, uint* plen, uchar max[2], uchar min[2]){ switch(dir){ case DIR_RIGHT: map[*y][++(*x)] = ID_PASSAGE; break; case DIR_UP: map[++(*y)][*x] = ID_PASSAGE; break; case DIR_LEFT: map[*y][--(*x)] = ID_PASSAGE; break; case DIR_DOWN: map[--(*y)][*x] = ID_PASSAGE; break; } (*plen)++; updateRange(*x, *y, max, min); }
static void menu_cb_setDynamicRange (EDITOR_ARGS) { EDITOR_IAM (SpectrumEditor); EDITOR_FORM (L"Set dynamic range", 0) POSITIVE (L"Dynamic range (dB)", my default_dynamicRange ()) EDITOR_OK SET_REAL (L"Dynamic range", my p_dynamicRange) EDITOR_DO my pref_dynamicRange () = my p_dynamicRange = GET_REAL (L"Dynamic range"); updateRange (me); FunctionEditor_redraw (me); EDITOR_END }
/*! Sets the reference time/position. */ void UiTimeAxis::setReference(double value) { if (value < 0 && -value < qPow(10, MinRefTimeAsPowOf10)) { value = 0; } else if (value > 0 && value < qPow(10, MinRefTimeAsPowOf10)) { value = 0; } mRefTime = value; updateRange(); update(); }
void KNAbstractSlider::setRange(float min, float max) { //Check is the value avaliable. if(min>max || (min==m_minimal && max==m_maximum)) { return; } //Set value. m_minimal=min; m_maximum=max; //Update range. updateRange(); //Reset the current value to change the data. setValue(m_value); }
void KeyframeImport::updateDataDisplay() { QString data = m_dataCombo->currentData().toString(); m_maximas = m_keyframeView->loadKeyframes(data); updateRange(); if (!m_inPoint->isValid()) { m_inPoint->blockSignals(true); m_outPoint->blockSignals(true); m_inPoint->setRange(0, m_keyframeView->duration); m_outPoint->setRange(0, m_keyframeView->duration); m_inPoint->setPosition(0); m_outPoint->setPosition(m_keyframeView->duration); m_inPoint->blockSignals(false); m_outPoint->blockSignals(false); } }
/// Plot a data set. /// @param index :: Index (row) of the data set in the table. void PlotController::plotDataSet(int index) { if ( index < 0 || index >= m_table->rowCount() ) { clear(); owner()->checkSpectra(); m_plot->replot(); return; } bool resetZoom = m_plotData.isEmpty(); auto plotData = getData(index); // hide the previously shown data if ( m_currentIndex > -1 ) { m_plotData[m_currentIndex]->hide(); } // try to keep the zooming from the previous view // but if zoom rect doesn't show any data reset zoom base to show all auto dataRect = m_plotData[index]->boundingRect(); auto zoomRect = m_zoomer->zoomRect(); if ( !zoomRect.intersects( dataRect ) ) { m_plot->setAxisAutoScale(QwtPlot::xBottom); m_plot->setAxisAutoScale(QwtPlot::yLeft); } // change the current data set index m_currentIndex = index; updateRange(index); // show the new data plotData->show( m_plot ); m_plot->replot(); // the idea is to set the zoom base (the largest view) to the data's bounding rect // but it looks like the base is set to the union of dataRect and current zoomRect m_zoomer->setZoomBase( dataRect ); // if it's first data set ever set the zoomer's base // if it's not done the base is set to some default rect that has nothing to do with the data if ( resetZoom ) { m_zoomer->setZoomBase(true); } emit currentIndexChanged( index ); }
//callback closures void sample_ready_callback(FDRuntime* self, gpointer user_data) { //for (int x = 0; x < self->samplesSize[0]; x++) //g_message("%i\t%f\t",x,self->samples[0][x]); updateRange(0.0, 1.0); //updatePointer(self->triggerPoint*HANTEK_CHANNELS); //updateRange(0.0,(double)self->ranges[self->currGain[0]]); int retVal = pthread_mutex_trylock(&self->samplesMutex); if (retVal != 0) { g_message("Ah! Samples already locked!"); return; } //pthread_mutex_lock(&self->samplesMutex); updateYList(self->samples[0],self->samplesSize[0]); pthread_mutex_unlock(&self->samplesMutex); }
bool SingleRemap::update() { switch (_type) { case kRemapNone: break; case kRemapByRange: return updateRange(); case kRemapByPercent: return updateBrightness(); case kRemapToGray: return updateSaturation(); case kRemapToPercentGray: return updateSaturationAndBrightness(); default: error("Illegal remap type %d", _type); } return false; }
void KNAbstractSlider::setMaximum(float maximum) { float preferMaximum=maximum; //Check the low bound. if(preferMaximum<m_minimal) { preferMaximum=m_minimal; } //Check is the prefer value still the same or not. if(preferMaximum==m_maximum) { return; } //Set maximum. m_maximum=preferMaximum; //Update slider range. updateRange(); //Reset the value to make it in the range. setValue(m_value); }
void KNAbstractSlider::setMinimal(float minimal) { float preferMinimal=minimal; //Check the up bound. if(preferMinimal>m_maximum) { preferMinimal=m_maximum; } //Check is the prefer value still the same or not. if(preferMinimal==m_minimal) { return; } //Set minimal. m_minimal=preferMinimal; //Update range. updateRange(); //Reset the value to make it in the range. setValue(m_value); }
void Ambitus::setTrack(int t) { Segment* segm = segment(); Staff* stf = score()->staff(track2staff(t)); Element::setTrack(t); // if not initialized and there is a segment and a staff, // initialize pitches and tpc's to first and last staff line // (for use in palettes) if (_topPitch == INVALID_PITCH || _topTpc == Tpc::TPC_INVALID || _bottomPitch == INVALID_PITCH ||_bottomTpc == Tpc::TPC_INVALID) { if (segm && stf) { updateRange(); _topAccid.setTrack(t); _bottomAccid.setTrack(t); } // else { // _topPitch = _bottomPitch = INVALID_PITCH; // _topTpc = _bottomTpc = Tpc::TPC_INVALID; } }
int main() { // get input Int n, m, k; scanf("%lld%lld%lld", &n, &m, &k); for (Int i=1; i<=n; i++) { scanf("%lld", &num[i]); } build(1, 1, n); Int a, b, c, d; for (Int i=0; i<m+k; i++) { scanf("%lld%lld%lld", &a, &b, &c); if (a==1) { scanf("%lld", &d); updateRange(1,1,n,b,c,d); } else { printf("%lld\n", queryRange(1,1,n,b,c)); } } return 0; }
/*! Called when the info width has changed. */ void UiTimeAxis::infoWidthChanged() { updateRange(); }
/*! Paint event handler responsible for painting this widget. */ void UiTimeAxis::resizeEvent(QResizeEvent* event) { (void)event; updateRange(); }
InspectorAmbitus::InspectorAmbitus(QWidget* parent) : InspectorBase(parent) { b.setupUi(addWidget()); r.setupUi(addWidget()); s.setupUi(addWidget()); static const NoteHead::Group heads[] = { NoteHead::Group::HEAD_NORMAL, NoteHead::Group::HEAD_CROSS, NoteHead::Group::HEAD_DIAMOND, NoteHead::Group::HEAD_TRIANGLE, NoteHead::Group::HEAD_SLASH, NoteHead::Group::HEAD_XCIRCLE, NoteHead::Group::HEAD_DO, NoteHead::Group::HEAD_RE, NoteHead::Group::HEAD_MI, NoteHead::Group::HEAD_FA, NoteHead::Group::HEAD_SOL, NoteHead::Group::HEAD_LA, NoteHead::Group::HEAD_TI, NoteHead::Group::HEAD_BREVIS_ALT }; static const Tpc tpcs[] = { Tpc::TPC_INVALID, Tpc::TPC_C_BB, Tpc::TPC_C_B, Tpc::TPC_C, Tpc::TPC_C_S, Tpc::TPC_C_SS, Tpc::TPC_D_BB, Tpc::TPC_D_B, Tpc::TPC_D, Tpc::TPC_D_S, Tpc::TPC_D_SS, Tpc::TPC_E_BB, Tpc::TPC_E_B, Tpc::TPC_E, Tpc::TPC_E_S, Tpc::TPC_E_SS, Tpc::TPC_F_BB, Tpc::TPC_F_B, Tpc::TPC_F, Tpc::TPC_F_S, Tpc::TPC_F_SS, Tpc::TPC_G_BB, Tpc::TPC_G_B, Tpc::TPC_G, Tpc::TPC_G_S, Tpc::TPC_G_SS, Tpc::TPC_A_BB, Tpc::TPC_A_B, Tpc::TPC_A, Tpc::TPC_A_S, Tpc::TPC_A_SS, Tpc::TPC_B_BB, Tpc::TPC_B_B, Tpc::TPC_B, Tpc::TPC_B_S, Tpc::TPC_B_SS, }; // // fix order of noteheads and tpc's // for (int i = 0; i < int(NoteHead::Group::HEAD_GROUPS); ++i) r.noteHeadGroup->setItemData(i, int(heads[i])); // noteHeadType starts at -1 for (int i = 0; i < 5; ++i) r.noteHeadType->setItemData(i, i-1); // set proper itemdata for TPC combos for (int i = 0; i < Tpc::TPC_MAX-Tpc::TPC_MIN+2; ++i) { r.topTpc-> setItemData(i, tpcs[i]); r.bottomTpc->setItemData(i, tpcs[i]); } // make first item of each TPC combo ("[undefined]") unselectable const QStandardItemModel* model = qobject_cast<const QStandardItemModel*>(r.topTpc->model()); QStandardItem* item = model->item(0); item->setFlags(item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled)); model = qobject_cast<const QStandardItemModel*>(r.bottomTpc->model()); item = model->item(0); item->setFlags(item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled)); iList = { { P_ID::COLOR, 0, 0, b.color, b.resetColor }, { P_ID::VISIBLE, 0, 0, b.visible, b.resetVisible }, { P_ID::USER_OFF, 0, 0, b.offsetX, b.resetX }, { P_ID::USER_OFF, 1, 0, b.offsetY, b.resetY }, { P_ID::HEAD_GROUP, 0, 0, r.noteHeadGroup, r.resetNoteHeadGroup }, { P_ID::HEAD_TYPE, 0, 0, r.noteHeadType, r.resetNoteHeadType }, { P_ID::MIRROR_HEAD, 0, 0, r.direction, r.resetDirection }, { P_ID::GHOST, 0, 0, r.hasLine, r.resetHasLine }, // recycled property { P_ID::LINE_WIDTH, 0, 0, r.lineWidth, r.resetLineWidth }, { P_ID::TPC1, 0, 0, r.topTpc, nullptr }, { P_ID::FBPARENTHESIS1, 0, 0, r.bottomTpc, nullptr }, // recycled property { P_ID::FBPARENTHESIS3, 0, 0, r.topOctave, nullptr }, // recycled property { P_ID::FBPARENTHESIS4, 0, 0, r.bottomOctave, nullptr }, // recycled property { P_ID::LEADING_SPACE, 0, 1, s.leadingSpace, s.resetLeadingSpace }, }; mapSignals(); connect(r.updateRange, SIGNAL(clicked()), this, SLOT(updateRange()) ); }
void PointLight::setIntensity(float intensity) { m_intensity = std::max(.0f, intensity); updateRange(); }
PointLight::PointLight(const glm::vec3& color, float intensity, Attenuation* attenuation) : PointLight(color, intensity, attenuation, 0) { updateRange(); }