LinearOperator C1Operator::linearization( const ::Spacy::Vector& x ) const { return LinearOperator( derivative_( cast_ref< Vector >( x ).get() ), *operatorSpace_, domain(), range() ); }
qboolean Makron_CheckAttack (edict_t *self) { vec3_t spot1, spot2; vec3_t temp; float chance; trace_t tr; qboolean enemy_infront; int enemy_range; float enemy_yaw; if (self->enemy->health > 0) { // see if any entities are in the way of the shot VectorCopy (self->s.origin, spot1); spot1[2] += self->viewheight; VectorCopy (self->enemy->s.origin, spot2); spot2[2] += self->enemy->viewheight; tr = gi.trace (spot1, NULL, NULL, spot2, self, CONTENTS_SOLID|CONTENTS_MONSTER|CONTENTS_SLIME|CONTENTS_LAVA); // do we have a clear shot? if (tr.ent != self->enemy) return false; } enemy_infront = infront(self, self->enemy); enemy_range = range(self, self->enemy); VectorSubtract (self->enemy->s.origin, self->s.origin, temp); enemy_yaw = vectoyaw(temp); self->ideal_yaw = enemy_yaw; // melee attack if (enemy_range == RANGE_MELEE) { if (self->monsterinfo.melee) self->monsterinfo.attack_state = AS_MELEE; else self->monsterinfo.attack_state = AS_MISSILE; return true; } // missile attack if (!self->monsterinfo.attack) return false; if (level.time < self->monsterinfo.attack_finished) return false; if (enemy_range == RANGE_FAR) return false; if (self->monsterinfo.aiflags & AI_STAND_GROUND) { chance = 0.4; } else if (enemy_range == RANGE_MELEE) { chance = 0.8; } else if (enemy_range == RANGE_NEAR) { chance = 0.4; } else if (enemy_range == RANGE_MID) { chance = 0.2; } else { return false; } if (random () < chance) { self->monsterinfo.attack_state = AS_MISSILE; self->monsterinfo.attack_finished = level.time + 2*random(); return true; } if (self->flags & FL_FLY) { if (random() < 0.3) self->monsterinfo.attack_state = AS_SLIDING; else self->monsterinfo.attack_state = AS_STRAIGHT; } return false; }
list_inserter& range( const SinglePassRange& r ) { return range( boost::begin(r), boost::end(r) ); }
int coll (struct object *objects, struct list *list, double *t_last, double t_now, double dt, int n1_sph, int n1, int n2, int last) { double x1, y1, z1, x2, y2, z2, x12, y12, z12, r12, sig; double ux1, uy1, uz1, ux2, uy2, uz2; double urx, ury, urz, ur, u12, ur2, t12; int n2_sph, n2_obj, f1, f2, n; f1 =(objects[n1_sph].move_flag+1)/2; ux1 = objects[n1_sph].u.x*f1; uy1 = objects[n1_sph].u.y*f1; uz1 = objects[n1_sph].u.z*f1; x1 = objects[n1_sph].r.x + ux1*(t_now-t_last[n1_sph]); y1 = objects[n1_sph].r.y + uy1*(t_now-t_last[n1_sph]); z1 = objects[n1_sph].r.z + uz1*(t_now-t_last[n1_sph]); for (n = 1; n <= objects[n1_sph].list[0]; n++) { n2_sph = objects[n1_sph].list[n]; if (range(n2_sph, n1, n2)) { f2 =(objects[n2_sph].move_flag+1)/2; ux2 = objects[n2_sph].u.x*f2; uy2 = objects[n2_sph].u.y*f2; uz2 = objects[n2_sph].u.z*f2; x2 = objects[n2_sph].r.x + ux2*(t_now-t_last[n2_sph]); y2 = objects[n2_sph].r.y + uy2*(t_now-t_last[n2_sph]); z2 = objects[n2_sph].r.z + uz2*(t_now-t_last[n2_sph]); x12 = n_image(x1 - x2, max_x); y12 = n_image(y1 - y2, max_y); z12 = n_image(z1 - z2, max_z); urx = ux1 - ux2; ury = uy1 - uy2; urz = uz1 - uz2; sig = objects[n1_sph].r_a + objects[n2_sph].r_a; r12 = x12*x12 + y12*y12 + z12*z12 - sig*sig; if (r12 < -Tol) warning ("particle-particle overlap"); ur = urx*x12 + ury*y12 + urz*z12; if (ur < 0.0) { u12 = urx*urx + ury*ury + urz*urz; ur2 = u12*r12; if (ur*ur >= ur2) { t12 = - ur - sqrt(ur*ur - ur2); t12 = t12/u12 + t_now; if (t12 < dt) { list[last].t_coll = t12; list[last].coll_1 = n1_sph; list[last].coll_2 = n2_sph; list[last].next = last + 1; last++; if (last > MAX_C) fatal_err("too many collisions: MAX_C exceeded", -1); } } } } } if (objects[n1_sph].move_flag > 0) { for (n2_obj = num_sph; n2_obj < num_obj; n2_obj++) { x12 = (x1 - objects[n2_obj].r.x)*objects[n2_obj].e.x; y12 = (y1 - objects[n2_obj].r.y)*objects[n2_obj].e.y; z12 = (z1 - objects[n2_obj].r.z)*objects[n2_obj].e.z; sig = objects[n1_sph].r_a; r12 = x12 + y12 + z12 - sig; if (r12 < -Tol) warning ("particle-wall overlap"); urx = objects[n1_sph].u.x*objects[n2_obj].e.x; ury = objects[n1_sph].u.y*objects[n2_obj].e.y; urz = objects[n1_sph].u.z*objects[n2_obj].e.z; ur = urx + ury + urz; if (ur < 0.0) { t12 = -r12/ur + t_now; if (t12 < dt) { list[last].t_coll = t12; list[last].coll_1 = n1_sph; list[last].coll_2 = n2_obj; list[last].next = last + 1; last++; if (last > MAX_C) fatal_err("too many collisions: MAX_C exceeded", -1); } } } } return (last); }
void InputHandler::onButtonReleaseEvent(GdkEventButton * event, PageRef page) { XOJ_CHECK_TYPE(InputHandler); if (!this->tmpStroke) { return; } // Backward compatibility and also easier to handle for me;-) // I cannot draw a line with one point, to draw a visible line I need two points, // twice the same Point is also OK if (this->tmpStroke->getPointCount() == 1) { ArrayIterator<Point> it = this->tmpStroke->pointIterator(); if (it.hasNext()) { this->tmpStroke->addPoint(it.next()); } // No pressure sensitivity this->tmpStroke->clearPressure(); } this->tmpStroke->freeUnusedPointItems(); if (page.getSelectedLayerId() < 1) { // This creates a layer if none exists page.getSelectedLayer(); page.setSelectedLayerId(1); xournal->getControl()->getWindow()->updateLayerCombobox(); } Layer * layer = page.getSelectedLayer(); UndoRedoHandler * undo = xournal->getControl()->getUndoRedoHandler(); undo->addUndoAction(new InsertUndoAction(page, layer, this->tmpStroke, this->redrawable)); ToolHandler * h = xournal->getControl()->getToolHandler(); if (h->isShapeRecognizer()) { if (this->reco == NULL) { this->reco = new ShapeRecognizer(); } ShapeRecognizerResult * result = this->reco->recognizePatterns(this->tmpStroke); if (result != NULL) { UndoRedoHandler * undo = xournal->getControl()->getUndoRedoHandler(); Stroke * recognized = result->getRecognized(); RecognizerUndoAction * recognizerUndo = new RecognizerUndoAction(page, this->redrawable, layer, this->tmpStroke, recognized); undo->addUndoAction(recognizerUndo); layer->addElement(result->getRecognized()); Range range(recognized->getX(), recognized->getY()); range.addPoint(recognized->getX() + recognized->getElementWidth(), recognized->getY() + recognized->getElementHeight()); range.addPoint(this->tmpStroke->getX(), this->tmpStroke->getY()); range.addPoint(this->tmpStroke->getX() + this->tmpStroke->getElementWidth(), this->tmpStroke->getY() + this->tmpStroke->getElementHeight()); ListIterator<Stroke *> l = result->getSources(); while (l.hasNext()) { Stroke * s = l.next(); layer->removeElement(s, false); recognizerUndo->addSourceElement(s); range.addPoint(s->getX(), s->getY()); range.addPoint(s->getX() + s->getElementWidth(), s->getY() + s->getElementHeight()); } this->redrawable->rerenderRange(range); // delete the result object, this is not needed anymore, the stroke are not deleted with this delete result; } else { layer->addElement(this->tmpStroke); this->redrawable->rerenderElement(this->tmpStroke); } } else { layer->addElement(this->tmpStroke); this->redrawable->rerenderElement(this->tmpStroke); } this->tmpStroke = NULL; if (currentInputDevice == event->device) { currentInputDevice = NULL; INPUTDBG("currentInputDevice = NULL\n", 0); } this->tmpStrokeDrawElem = 0; }
void tag_run(void) { // Setup DECAWAVE cph_deca_init_device(); cph_deca_init_network(cph_config->panid, cph_config->shortid); // Set our short id in common messages tx_poll_msg.header.source = cph_config->shortid; tx_discover_msg.header.source = cph_config->shortid; tx_pair_msg.header.source = cph_config->shortid; tx_range_results_msg.header.source = cph_config->shortid; // First, discover anchors uint32_t anchor_refresh_ts = 0; refresh_anchors(); anchor_refresh_ts = cph_get_millis(); // Poll loop while (1) { int ranges_countdown = MAX_RANGES_BEFORE_POLL_TIMEOUT; anchors_status = ANCHORS_MASK; while (anchors_status && (--ranges_countdown)) { // Check for refresh of anchors uint32_t elapsed = cph_get_millis() - anchor_refresh_ts; if (elapsed > ANCHORS_REFRESH_INTERVAL) { printf("Anchors refresh timeout. anchors_status:%02X\r\n", anchors_status); refresh_anchors(); anchor_refresh_ts = cph_get_millis(); // Since we refreshed the anchors, need to range again for ALL anchors during this poll anchors_status = ANCHORS_MASK; } // Range each anchor once during this poll for (int i = 0; i < ANCHORS_MIN; i++) { if (anchors_status & (1 << i)) { anchors[i].range = 0; int result = range(&anchors[i]); if (result == CPH_OK) { anchors_status &= (~(1 << i)); } deca_sleep(RNG_DELAY_MS); } } deca_sleep(RNG_DELAY_MS); } if (ranges_countdown) { send_ranges(MAX_RANGES_BEFORE_POLL_TIMEOUT - ranges_countdown); } else { printf("ranges_countdown expired!\r\n"); } // Execute a delay between ranging exchanges. deca_sleep(POLL_DELAY_MS); } }
static KMAP *kbuild(CAP *cap, KMAP *kmap, unsigned char *seq, void *bind, int *err, unsigned char *capseq, int seql) { int v, w; if (!seql && seq[0] == '.' && seq[1]) { int x, c; unsigned char *s; for (x = 0; seq[x] && seq[x] != ' '; ++x) ; c = seq[x]; seq[x] = 0; #ifdef __MSDOS__ if (!zcmp(seq + 1, "ku")) { capseq = "\0H"; seql = 2; } else if (!zcmp(seq + 1, USTR "kd")) { capseq = "\0P"; seql = 2; } else if (!zcmp(seq + 1, USTR "kl")) { capseq = "\0K"; seql = 2; } else if (!zcmp(seq + 1, USTR "kr")) { capseq = "\0M"; seql = 2; } else if (!zcmp(seq + 1, USTR "kI")) { capseq = "\0R"; seql = 2; } else if (!zcmp(seq + 1, USTR "kD")) { capseq = "\0S"; seql = 2; } else if (!zcmp(seq + 1, USTR "kh")) { capseq = "\0G"; seql = 2; } else if (!zcmp(seq + 1, USTR "kH")) { capseq = "\0O"; seql = 2; } else if (!zcmp(seq + 1, USTR "kP")) { capseq = "\0I"; seql = 2; } else if (!zcmp(seq + 1, USTR "kN")) { capseq = "\0Q"; seql = 2; } else if (!zcmp(seq + 1, USTR "k1")) { capseq = "\0;"; seql = 2; } else if (!zcmp(seq + 1, USTR "k2")) { capseq = "\0<"; seql = 2; } else if (!zcmp(seq + 1, USTR "k3")) { capseq = "\0="; seql = 2; } else if (!zcmp(seq + 1, USTR "k4")) { capseq = "\0>"; seql = 2; } else if (!zcmp(seq + 1, USTR "k5")) { capseq = "\0?"; seql = 2; } else if (!zcmp(seq + 1, USTR "k6")) { capseq = "\0@"; seql = 2; } else if (!zcmp(seq + 1, USTR "k7")) { capseq = "\0A"; seql = 2; } else if (!zcmp(seq + 1, USTR "k8")) { capseq = "\0B"; seql = 2; } else if (!zcmp(seq + 1, USTR "k9")) { capseq = "\0C"; seql = 2; } else if (!zcmp(seq + 1, USTR "k0")) { capseq = "\0D"; seql = 2; } seq[x] = c; if (seql) { for (seq += x; *seq == ' '; ++seq) ; } #else s = jgetstr(cap, seq + 1); seq[x] = c; if (s && (s = tcompile(cap, s, 0, 0, 0, 0)) && (sLEN(s) > 1 || (signed char)s[0] < 0)) { capseq = s; seql = sLEN(s); for (seq += x; *seq == ' '; ++seq) ; } #endif else { *err = -2; return kmap; } } if (seql) { v = w = (unsigned char) *capseq++; --seql; } else { seq = range(seq, &v, &w); if (!seq) { *err = -1; return kmap; } } if (!kmap) kmap = mkkmap(); /* Create new keymap if 'kmap' was NULL */ /* Make bindings between v and w */ while (v <= w) { if (*seq || seql) { if (kmap->keys[v].k == 0) kmap->keys[v].value.submap = NULL; kmap->keys[v].k = 1; kmap->keys[v].value.submap = kbuild(cap, kmap->keys[v].value.submap, seq, bind, err, capseq, seql); if (!kmap->keys[v].value.submap) { /* Error during recursion. Prevent crash later. */ kmap->keys[v].k = 0; } } else { if (kmap->keys[v].k == 1) rmkmap(kmap->keys[v].value.submap); kmap->keys[v].k = 0; kmap->keys[v].value.bind = /* This bit of code sticks the key value in the macro */ (v == w ? macstk(bind, v) : dupmacro(macstk(bind, v))); } ++v; } return kmap; }
int vehicle::automatic_fire_turret( vehicle_part &pt ) { auto gun = turret_query( pt ); if( gun.query() != turret_data::status::ready ) { return 0; } tripoint pos = global_part_pos3( pt ); npc tmp; tmp.set_fake( true ); tmp.name = rmp_format( _( "<veh_player>The %s" ), pt.name().c_str() ); tmp.set_skill_level( gun.base()->gun_skill(), 8 ); tmp.set_skill_level( skill_id( "gun" ), 4 ); tmp.recoil = abs( velocity ) / 100 / 4; tmp.setpos( pos ); tmp.str_cur = 16; tmp.dex_cur = 8; tmp.per_cur = 12; // Assume vehicle turrets are friendly to the player. tmp.attitude = NPCATT_FOLLOW; int area = aoe_size( gun.ammo_effects() ); if( area > 0 ) { area += area == 1 ? 1 : 2; // Pad a bit for less friendly fire } tripoint targ = pos; auto &target = pt.target; if( target.first == target.second ) { // Manual target not set, find one automatically const bool u_see = g->u.sees( pos ); int boo_hoo; // @todo calculate chance to hit and cap range based upon this int range = std::min( gun.range(), 12 ); Creature *auto_target = tmp.auto_find_hostile_target( range, boo_hoo, area ); if( auto_target == nullptr ) { if( u_see && boo_hoo ) { add_msg( m_warning, ngettext( "%s points in your direction and emits an IFF warning beep.", "%s points in your direction and emits %d annoyed sounding beeps.", boo_hoo ), tmp.name.c_str(), boo_hoo ); } return 0; } targ = auto_target->pos(); } else if( target.first != target.second ) { // Target set manually // Make sure we didn't move between aiming and firing (it's a bug if we did) if( targ != target.first ) { target.second = target.first; return 0; } targ = target.second; // Remove the target target.second = target.first; } else { // Shouldn't happen target.first = target.second; return 0; } auto shots = gun.fire( tmp, targ ); if( g->u.sees( pos ) && shots ) { add_msg( _( "The %1$s fires its %2$s!" ), name.c_str(), pt.name().c_str() ); } return shots; }
//void AmplitudeWidget::drawChannelAmplitudeFilled(Channel *ch, QPainter &p) void AmplitudeWidget::drawChannelAmplitudeFilledGL(Channel *ch) { View *view = gdata->view; ChannelLocker channelLocker(ch); ZoomLookup *z = &ch->amplitudeZoomLookup; // baseX is the no. of chunks a pixel must represent. double baseX = view->zoomX() / ch->timePerChunk(); z->setZoomLevel(baseX); double currentChunk = ch->chunkFractionAtTime(view->currentTime()); double leftFrameTime = currentChunk - ((view->currentTime() - view->viewLeft()) / ch->timePerChunk()); int n = 0; int baseElement = int(floor(leftFrameTime / baseX)); if(baseElement < 0) { n -= baseElement; baseElement = 0; } int lastBaseElement = int(floor(double(ch->totalChunks()) / baseX)); //double heightRatio = double(height()) / dBRange(); double heightRatio = double(height()) / range(); //int firstN = n; //int lastN = firstN; //Q3PointArray bottomPoints(width()*2); Array1d<MyGLfloat2d> vertexArray(width()*2); int pointIndex = 0; //int topBottomPointIndex = 0; if (baseX > 1) { // More samples than pixels int theWidth = width(); //if(baseElement + theWidth > z->size()) z->setSize(baseElement + theWidth); if(lastBaseElement > z->size()) z->setSize(lastBaseElement); for(; n < theWidth && baseElement < lastBaseElement; n++, baseElement++) { myassert(baseElement >= 0); ZoomElement &ze = z->at(baseElement); //if(!z->hasValue(baseElement)) { if(!ze.isValid()) { if(!calcZoomElement(ze, ch, baseElement, baseX)) continue; } int y = height() - 1 - toInt((ze.high() - offsetInv()) * heightRatio); //bottomPoints.setPoint(topBottomPointIndex++, n, y); //bottomPoints.setPoint(topBottomPointIndex++, n, height()); vertexArray[pointIndex++] = MyGLfloat2d(n, y); vertexArray[pointIndex++] = MyGLfloat2d(n, height()); //lastN = n; } //p.setPen(Qt::NoPen); //p.setBrush(gdata->shading1Color()); //p.drawRect(firstN, 0, lastN, height()); //p.setPen(gdata->shading2Color()); //p.drawLineSegments(bottomPoints, 0, topBottomPointIndex/2); qglColor(gdata->shading2Color()); glVertexPointer(2, GL_FLOAT, 0, vertexArray.begin()); glDrawArrays(GL_QUAD_STRIP, 0, pointIndex); } else { //baseX <= 1 float err = 0.0; float val = 0.0; int intChunk = (int) floor(leftFrameTime); // Integer version of frame time double stepSize = 1.0 / baseX; // So we skip some pixels float x = 0.0f, y; //double start = 0 - stepSize; double start = (double(intChunk) - leftFrameTime) * stepSize; double stop = width() + (2 * stepSize); //int squareSize = (int(sqrt(stepSize)) / 2) * 2 + 1; //make it an odd number //int halfSquareSize = squareSize/2; double dn = start; int totalChunks = ch->totalChunks(); if(intChunk < 0) { dn += stepSize * -intChunk; intChunk = 0; } //bottomPoints.setPoint(topBottomPointIndex++, toInt(dn), height()); //vertexArray[pointIndex++] = MyGLfloat2d((GLfloat)dn, height()); //firstN = toInt(dn); for(; dn < stop && intChunk < totalChunks; dn += stepSize, intChunk++) { AnalysisData *data = ch->dataAtChunk(intChunk); myassert(data); if(!data) continue; err = data->correlation(); val = calculateElement(data); //p.setPen(QPen(colorBetween(colorGroup().background(), ch->color, val), 1)); x = dn; y = height() - 1 - ((val - offsetInv()) * heightRatio); //bottomPoints.setPoint(topBottomPointIndex++, x, y); vertexArray[pointIndex++] = MyGLfloat2d(x, y); vertexArray[pointIndex++] = MyGLfloat2d(x, height()); //lastN = x; } //bottomPoints.setPoint(topBottomPointIndex, bottomPoints.point(topBottomPointIndex-1).x(), height()); //if(pointIndex > 0) { // vertexArray[pointIndex] = MyGLfloat2d(vertexArray[pointIndex-1].x, height()); // pointIndex++; //} myassert(pointIndex <= width()*2); //p.setPen(Qt::NoPen); //p.setBrush(gdata->shading1Color()); //p.drawRect(firstN, 0, lastN, height()); //p.setPen(gdata->shading2Color()); //p.setBrush(gdata->shading2Color()); //p.drawPolygon(bottomPoints, false, 0, topBottomPointIndex); qglColor(gdata->shading2Color()); glVertexPointer(2, GL_FLOAT, 0, vertexArray.begin()); glDrawArrays(GL_QUAD_STRIP, 0, pointIndex); } }
Ray CCamera::GetEyeRay() { glm::vec2 range(m_Width, m_Height); glm::vec2 s = GetUniformSample2D(range); return GetEyeRay(s.x, s.y); }
Ray CCamera::GetEyeRay(glm::vec2& pixel) { glm::vec2 range(m_Width, m_Height); pixel = GetUniformSample2D(range); return GetEyeRay(pixel.x, pixel.y); }
inline Iter range(Iter first, Iter last) { typedef typename std::iterator_traits<Iter>::value_type value_type; return range(first, last, std::equal_to<value_type>()); } // range
void ReplaceMatches::doReplaceNextMatch() { if ((!m_manager) || (m_cancelReplace)) { m_rootIndex = -1; emit replaceDone(); return; } // NOTE The document managers signal documentWillBeDeleted() must be connected to // cancelReplace(). A closed file could lead to a crash if it is not handled. // Open the file QTreeWidgetItem *rootItem = m_tree->topLevelItem(m_rootIndex); if (!rootItem) { m_rootIndex = -1; emit replaceDone(); return; } if (rootItem->checkState(0) == Qt::Unchecked) { m_rootIndex++; emit replaceNextMatch(); return; } KTextEditor::Document *doc = m_manager->findUrl(rootItem->data(0, Qt::UserRole).toString()); if (!doc) { doc = m_manager->openUrl(rootItem->data(0, Qt::UserRole).toString()); } if (!doc) { m_rootIndex++; emit replaceNextMatch(); return; } QVector<KTextEditor::MovingRange*> rVector; KTextEditor::MovingInterface* miface = qobject_cast<KTextEditor::MovingInterface*>(doc); int line; int column; int len; QTreeWidgetItem *item; // lines might be modified so search the document again for (int i=0; i<rootItem->childCount(); i++) { item = rootItem->child(i); if (item->checkState(0) == Qt::Unchecked) continue; line = item->data(1, Qt::UserRole).toInt(); column = item->data(2, Qt::UserRole).toInt(); len = item->data(3, Qt::UserRole).toInt(); if (m_regExp.indexIn(doc->line(line), column) != column) { kDebug() << "expression does not match"; continue; } QString html = item->data(1, Qt::ToolTipRole).toString(); html += "<i><s>" + item->data(2, Qt::ToolTipRole).toString() + "</s></i> "; html += "<b>" + m_replaceText + "</b>"; html += item->data(3, Qt::ToolTipRole).toString(); item->setData(0, Qt::DisplayRole, i18n("Line: <b>%1</b>: %2",line+1, html)); KTextEditor::Range range(line, column, line, column+len); KTextEditor::MovingRange* mr = miface->newMovingRange(range); rVector.append(mr); } for (int i=0; i<rVector.size(); i++) { line = rVector[i]->start().line(); column = rVector[i]->start().column(); doc->replaceText(*rVector[i], m_replaceText); emit matchReplaced(doc, line, column, m_replaceText.length()); } qDeleteAll(rVector); m_rootIndex++; emit replaceNextMatch(); }
VectorXi range( int end ) { return range( 0, end ); }
/** * Process a sentence with xml annotation * Xml tags may specifiy additional/replacing translation options * and reordering constraints * * \param line in: sentence, out: sentence without the xml * \param res vector with translation options specified by xml * \param reorderingConstraint reordering constraint zones specified by xml * \param walls reordering constraint walls specified by xml * \param lbrackStr xml tag's left bracket string, typically "<" * \param rbrackStr xml tag's right bracket string, typically ">" */ bool ProcessAndStripXMLTags(AllOptions const& opts, string &line, vector<XmlOption const*> &res, ReorderingConstraint &reorderingConstraint, vector< size_t > &walls, std::vector< std::pair<size_t, std::string> > &placeholders, InputType &input) { //parse XML markup in translation line const std::string& lbrackStr = opts.input.xml_brackets.first; const std::string& rbrackStr = opts.input.xml_brackets.second; int offset = is_syntax(opts.search.algo) ? 1 : 0; // const StaticData &staticData = StaticData::Instance(); // hack. What pt should XML trans opt be assigned to? PhraseDictionary *firstPt = NULL; if (PhraseDictionary::GetColl().size() == 0) { firstPt = PhraseDictionary::GetColl()[0]; } // no xml tag? we're done. if (line.find(lbrackStr) == string::npos) { return true; } // break up input into a vector of xml tags and text // example: (this), (<b>), (is a), (</b>), (test .) vector<string> xmlTokens = TokenizeXml(line, lbrackStr, rbrackStr); // we need to store opened tags, until they are closed // tags are stored as tripled (tagname, startpos, contents) typedef pair< string, pair< size_t, string > > OpenedTag; vector< OpenedTag > tagStack; // stack that contains active opened tags string cleanLine; // return string (text without xml) size_t wordPos = 0; // position in sentence (in terms of number of words) const vector<FactorType> &outputFactorOrder = opts.output.factor_order; // loop through the tokens for (size_t xmlTokenPos = 0 ; xmlTokenPos < xmlTokens.size() ; xmlTokenPos++) { // not a xml tag, but regular text (may contain many words) if(!isXmlTag(xmlTokens[xmlTokenPos], lbrackStr, rbrackStr)) { // add a space at boundary, if necessary if (cleanLine.size()>0 && cleanLine[cleanLine.size() - 1] != ' ' && xmlTokens[xmlTokenPos][0] != ' ') { cleanLine += " "; } cleanLine += xmlTokens[xmlTokenPos]; // add to output wordPos = Tokenize(cleanLine).size(); // count all the words } // process xml tag else { // *** get essential information about tag *** // strip extra boundary spaces and "<" and ">" string tag = Trim(TrimXml(xmlTokens[xmlTokenPos], lbrackStr, rbrackStr)); VERBOSE(3,"XML TAG IS: " << tag << std::endl); if (tag.size() == 0) { TRACE_ERR("ERROR: empty tag name: " << line << endl); return false; } // check if unary (e.g., "<wall/>") bool isUnary = ( tag[tag.size() - 1] == '/' ); // check if opening tag (e.g. "<a>", not "</a>")g bool isClosed = ( tag[0] == '/' ); bool isOpen = !isClosed; if (isClosed && isUnary) { TRACE_ERR("ERROR: can't have both closed and unary tag " << lbrackStr << tag << rbrackStr << ": " << line << endl); return false; } if (isClosed) tag = tag.substr(1); // remove "/" at the beginning if (isUnary) tag = tag.substr(0,tag.size()-1); // remove "/" at the end // find the tag name and contents string::size_type endOfName = tag.find_first_of(' '); string tagName = tag; string tagContent = ""; if (endOfName != string::npos) { tagName = tag.substr(0,endOfName); tagContent = tag.substr(endOfName+1); } // *** process new tag *** if (isOpen || isUnary) { // put the tag on the tag stack OpenedTag openedTag = make_pair( tagName, make_pair( wordPos, tagContent ) ); tagStack.push_back( openedTag ); VERBOSE(3,"XML TAG " << tagName << " (" << tagContent << ") added to stack, now size " << tagStack.size() << endl); } // *** process completed tag *** if (isClosed || isUnary) { // pop last opened tag from stack; if (tagStack.size() == 0) { TRACE_ERR("ERROR: tag " << tagName << " closed, but not opened" << ":" << line << endl); return false; } OpenedTag openedTag = tagStack.back(); tagStack.pop_back(); // tag names have to match if (openedTag.first != tagName) { TRACE_ERR("ERROR: tag " << openedTag.first << " closed by tag " << tagName << ": " << line << endl ); return false; } // assemble remaining information about tag size_t startPos = openedTag.second.first; string tagContent = openedTag.second.second; size_t endPos = wordPos; // span attribute overwrites position string span = ParseXmlTagAttribute(tagContent,"span"); if (! span.empty()) { vector<string> ij = Tokenize(span, "-"); if (ij.size() != 1 && ij.size() != 2) { TRACE_ERR("ERROR: span attribute must be of the form \"i-j\" or \"i\": " << line << endl); return false; } startPos = atoi(ij[0].c_str()); if (ij.size() == 1) endPos = startPos + 1; else endPos = atoi(ij[1].c_str()) + 1; } VERBOSE(3,"XML TAG " << tagName << " (" << tagContent << ") spanning " << startPos << " to " << (endPos-1) << " complete, commence processing" << endl); // special tag: wall if (tagName == "wall") { size_t start = (startPos == 0) ? 0 : startPos-1; for(size_t pos = start; pos < endPos; pos++) walls.push_back( pos ); } // special tag: zone else if (tagName == "zone") { if (startPos >= endPos) { TRACE_ERR("ERROR: zone must span at least one word: " << line << endl); return false; } reorderingConstraint.SetZone( startPos, endPos-1 ); } // name-entity placeholder else if (tagName == "ne") { if (startPos != (endPos - 1)) { TRACE_ERR("ERROR: Placeholder must only span 1 word: " << line << endl); return false; } string entity = ParseXmlTagAttribute(tagContent,"entity"); placeholders.push_back(std::pair<size_t, std::string>(startPos, entity)); } // update: add new aligned sentence pair to Mmsapt identified by name else if (tagName == "update") { #if PT_UG // get model name and aligned sentence pair string pdName = ParseXmlTagAttribute(tagContent,"name"); string source = ParseXmlTagAttribute(tagContent,"source"); string target = ParseXmlTagAttribute(tagContent,"target"); string alignment = ParseXmlTagAttribute(tagContent,"alignment"); // find PhraseDictionary by name const vector<PhraseDictionary*> &pds = PhraseDictionary::GetColl(); PhraseDictionary* pd = NULL; for (vector<PhraseDictionary*>::const_iterator i = pds.begin(); i != pds.end(); ++i) { PhraseDictionary* curPd = *i; if (curPd->GetScoreProducerDescription() == pdName) { pd = curPd; break; } } if (pd == NULL) { TRACE_ERR("ERROR: No PhraseDictionary with name " << pdName << ", no update" << endl); return false; } // update model VERBOSE(3,"Updating " << pdName << " ||| " << source << " ||| " << target << " ||| " << alignment << endl); Mmsapt* pdsa = reinterpret_cast<Mmsapt*>(pd); pdsa->add(source, target, alignment); #else TRACE_ERR("ERROR: recompile with --with-mm to update PhraseDictionary at runtime" << endl); return false; #endif } // weight-overwrite: update feature weights, unspecified weights remain unchanged // IMPORTANT: translation models that cache phrases or apply table-limit during load // based on initial weights need to be reset. Sending an empty update will do this // for PhraseDictionaryBitextSampling (Mmsapt) models: // <update name="TranslationModelName" source=" " target=" " alignment=" " /> else if (tagName == "weight-overwrite") { // is a name->ff map stored anywhere so we don't have to build it every time? const vector<FeatureFunction*> &ffs = FeatureFunction::GetFeatureFunctions(); boost::unordered_map<string, FeatureFunction*> map; BOOST_FOREACH(FeatureFunction* const& ff, ffs) { map[ff->GetScoreProducerDescription()] = ff; } // update each weight listed ScoreComponentCollection allWeights = StaticData::Instance().GetAllWeights(); boost::unordered_map<string, FeatureFunction*>::iterator ffi; string ffName(""); vector<float> ffWeights; vector<string> toks = Tokenize(ParseXmlTagAttribute(tagContent,"weights")); BOOST_FOREACH(string const& tok, toks) { if (ends_with(tok, "=")) { // start new feature if (ffName != "") { // set previous feature weights if (ffi != map.end()) { allWeights.Assign(ffi->second, ffWeights); } ffWeights.clear(); } ffName = tok.substr(0, tok.size() - 1); ffi = map.find(ffName); if (ffi == map.end()) { TRACE_ERR("ERROR: No FeatureFunction with name " << ffName << ", no weight update" << endl); } } else { // weight for current feature ffWeights.push_back(Scan<float>(tok)); } } if (ffi != map.end()) { allWeights.Assign(ffi->second, ffWeights); } StaticData::InstanceNonConst().SetAllWeights(allWeights); } // Coord: coordinates of the input sentence in a user-defined space // <coord space="NAME" coord="X Y Z ..." /> // where NAME is the name of the space and X Y Z ... are floats. See // PhraseDistanceFeature for an example of using this information for // feature scoring. else if (tagName == "coord") { // Parse tag string space = ParseXmlTagAttribute(tagContent, "space"); vector<string> tok = Tokenize(ParseXmlTagAttribute(tagContent, "coord")); size_t id = StaticData::Instance().GetCoordSpace(space); if (!id) { TRACE_ERR("ERROR: no models use space " << space << ", will be ignored" << endl); } else { // Init if needed if (!input.m_coordMap) { input.m_coordMap.reset(new map<size_t const, vector<float> >); } vector<float>& coord = (*input.m_coordMap)[id]; Scan<float>(coord, tok); } } // default: opening tag that specifies translation options else { if (startPos > endPos) { TRACE_ERR("ERROR: tag " << tagName << " startPos > endPos: " << line << endl); return false; } else if (startPos == endPos) { TRACE_ERR("WARNING: tag " << tagName << " 0 span: " << line << endl); continue; } // specified translations -> vector of phrases // multiple translations may be specified, separated by "||" vector<string> altTexts = TokenizeMultiCharSeparator(ParseXmlTagAttribute(tagContent,"translation"), "||"); if( altTexts.size() == 1 && altTexts[0] == "" ) altTexts.pop_back(); // happens when nothing specified // deal with legacy annotations: "translation" was called "english" vector<string> moreAltTexts = TokenizeMultiCharSeparator(ParseXmlTagAttribute(tagContent,"english"), "||"); if (moreAltTexts.size()>1 || moreAltTexts[0] != "") { for(vector<string>::iterator translation=moreAltTexts.begin(); translation != moreAltTexts.end(); translation++) { string t = *translation; altTexts.push_back( t ); } } // specified probabilities for the translations -> vector of probs vector<string> altProbs = TokenizeMultiCharSeparator(ParseXmlTagAttribute(tagContent,"prob"), "||"); if( altProbs.size() == 1 && altProbs[0] == "" ) altProbs.pop_back(); // happens when nothing specified // report what we have processed so far VERBOSE(3,"XML TAG NAME IS: '" << tagName << "'" << endl); VERBOSE(3,"XML TAG TRANSLATION IS: '" << altTexts[0] << "'" << endl); VERBOSE(3,"XML TAG PROB IS: '" << altProbs[0] << "'" << endl); VERBOSE(3,"XML TAG SPAN IS: " << startPos << "-" << (endPos-1) << endl); if (altProbs.size() > 0 && altTexts.size() != altProbs.size()) { TRACE_ERR("ERROR: Unequal number of probabilities and translation alternatives: " << line << endl); return false; } // store translation options into members if (opts.input.xml_policy != XmlIgnore) { // only store options if we aren't ignoring them for (size_t i=0; i<altTexts.size(); ++i) { Phrase sourcePhrase; // TODO don't know what the source phrase is // set default probability float probValue = 1; if (altProbs.size() > 0) probValue = Scan<float>(altProbs[i]); // convert from prob to log-prob float scoreValue = FloorScore(TransformScore(probValue)); Range range(startPos + offset,endPos-1 + offset); // span covered by phrase TargetPhrase targetPhrase(firstPt); // targetPhrase.CreateFromString(Output, outputFactorOrder,altTexts[i],factorDelimiter, NULL); targetPhrase.CreateFromString(Output, outputFactorOrder,altTexts[i], NULL); // lhs const UnknownLHSList &lhsList = opts.syntax.unknown_lhs; // staticData.GetUnknownLHS(); if (!lhsList.empty()) { const Factor *factor = FactorCollection::Instance().AddFactor(lhsList[0].first, true); Word *targetLHS = new Word(true); targetLHS->SetFactor(0, factor); // TODO - other factors too? targetPhrase.SetTargetLHS(targetLHS); } targetPhrase.SetXMLScore(scoreValue); targetPhrase.EvaluateInIsolation(sourcePhrase); XmlOption *option = new XmlOption(range,targetPhrase); assert(option); res.push_back(option); } altTexts.clear(); altProbs.clear(); } } } } }
void AmplitudeWidget::mousePressEvent(QMouseEvent *e) { View *view = gdata->view; int timeX = toInt(view->viewOffset() / view->zoomX()); //int pixelAtCurrentNoiseThresholdY = toInt(gdata->noiseThresholdDB() / gdata->dBFloor() / range() * double(height())); int pixelAtCurrentNoiseThresholdY; dragMode = DragNone; //Check if user clicked on center bar, to drag it if(within(4, e->x(), timeX)) { dragMode = DragTimeBar; mouseX = e->x(); return; } //Check if user clicked on a threshold bar for(int j=0; j<2; j++) { pixelAtCurrentNoiseThresholdY = height() - 1 - toInt((getCurrentThreshold(j) - offsetInv()) / range() * double(height())); if(within(4, e->y(), pixelAtCurrentNoiseThresholdY)) { dragMode = DragNoiseThreshold; thresholdIndex = j; //remember which thresholdIndex the user clicked mouseY = e->y(); return; } } //Otherwise user has clicked on background { mouseX = e->x(); mouseY = e->y(); dragMode = DragBackground; downTime = view->currentTime(); downOffset = offset(); } }
ValueBuffer * AutomatableModel::valueBuffer() { QMutexLocker m( &m_valueBufferMutex ); // if we've already calculated the valuebuffer this period, return the cached buffer if( m_lastUpdatedPeriod == s_periodCounter ) { return m_hasSampleExactData ? &m_valueBuffer : NULL; } float val = m_value; // make sure our m_value doesn't change midway ValueBuffer * vb; if( m_controllerConnection && m_controllerConnection->getController()->isSampleExact() ) { vb = m_controllerConnection->valueBuffer(); if( vb ) { float * values = vb->values(); float * nvalues = m_valueBuffer.values(); switch( m_scaleType ) { case Linear: for( int i = 0; i < m_valueBuffer.length(); i++ ) { nvalues[i] = minValue<float>() + ( range() * values[i] ); } break; case Logarithmic: for( int i = 0; i < m_valueBuffer.length(); i++ ) { nvalues[i] = logToLinearScale( values[i] ); } break; default: qFatal("AutomatableModel::valueBuffer() " "lacks implementation for a scale type"); break; } m_lastUpdatedPeriod = s_periodCounter; m_hasSampleExactData = true; return &m_valueBuffer; } } AutomatableModel* lm = NULL; if( hasLinkedModels() ) { lm = m_linkedModels.first(); } if( lm && lm->controllerConnection() && lm->controllerConnection()->getController()->isSampleExact() ) { vb = lm->valueBuffer(); float * values = vb->values(); float * nvalues = m_valueBuffer.values(); for( int i = 0; i < vb->length(); i++ ) { nvalues[i] = fittedValue( values[i] ); } m_lastUpdatedPeriod = s_periodCounter; m_hasSampleExactData = true; return &m_valueBuffer; } if( m_oldValue != val ) { m_valueBuffer.interpolate( m_oldValue, val ); m_oldValue = val; m_lastUpdatedPeriod = s_periodCounter; m_hasSampleExactData = true; return &m_valueBuffer; } // if we have no sample-exact source for a ValueBuffer, return NULL to signify that no data is available at the moment // in which case the recipient knows to use the static value() instead m_lastUpdatedPeriod = s_periodCounter; m_hasSampleExactData = false; return NULL; }
/** constructor; just initialize the base class */ TranslationOptionCollectionConfusionNet::TranslationOptionCollectionConfusionNet( const ConfusionNet &input , size_t maxNoTransOptPerCoverage, float translationOptionThreshold) : TranslationOptionCollection(input, maxNoTransOptPerCoverage, translationOptionThreshold) { const InputFeature *inputFeature = StaticData::Instance().GetInputFeature(); UTIL_THROW_IF2(inputFeature == NULL, "Input feature must be specified"); size_t inputSize = input.GetSize(); m_inputPathMatrix.resize(inputSize); size_t maxSizePhrase = StaticData::Instance().GetMaxPhraseLength(); maxSizePhrase = std::min(inputSize, maxSizePhrase); // 1-word phrases for (size_t startPos = 0; startPos < inputSize; ++startPos) { vector<InputPathList> &vec = m_inputPathMatrix[startPos]; vec.push_back(InputPathList()); InputPathList &list = vec.back(); WordsRange range(startPos, startPos); const NonTerminalSet &labels = input.GetLabelSet(startPos, startPos); const ConfusionNet::Column &col = input.GetColumn(startPos); for (size_t i = 0; i < col.size(); ++i) { const Word &word = col[i].first; Phrase subphrase; subphrase.AddWord(word); const ScorePair &scores = col[i].second; ScorePair *inputScore = new ScorePair(scores); InputPath *path = new InputPath(subphrase, labels, range, NULL, inputScore); list.push_back(path); m_inputPathQueue.push_back(path); } } // subphrases of 2+ words for (size_t phraseSize = 2; phraseSize <= maxSizePhrase; ++phraseSize) { for (size_t startPos = 0; startPos < inputSize - phraseSize + 1; ++startPos) { size_t endPos = startPos + phraseSize -1; WordsRange range(startPos, endPos); const NonTerminalSet &labels = input.GetLabelSet(startPos, endPos); vector<InputPathList> &vec = m_inputPathMatrix[startPos]; vec.push_back(InputPathList()); InputPathList &list = vec.back(); // loop thru every previous path const InputPathList &prevPaths = GetInputPathList(startPos, endPos - 1); int prevNodesInd = 0; InputPathList::const_iterator iterPath; for (iterPath = prevPaths.begin(); iterPath != prevPaths.end(); ++iterPath) { //for (size_t pathInd = 0; pathInd < prevPaths.size(); ++pathInd) { const InputPath &prevPath = **iterPath; //const InputPath &prevPath = *prevPaths[pathInd]; const Phrase &prevPhrase = prevPath.GetPhrase(); const ScorePair *prevInputScore = prevPath.GetInputScore(); UTIL_THROW_IF2(prevInputScore == NULL, "No input score for path: " << prevPath); // loop thru every word at this position const ConfusionNet::Column &col = input.GetColumn(endPos); for (size_t i = 0; i < col.size(); ++i) { const Word &word = col[i].first; Phrase subphrase(prevPhrase); subphrase.AddWord(word); const ScorePair &scores = col[i].second; ScorePair *inputScore = new ScorePair(*prevInputScore); inputScore->PlusEquals(scores); InputPath *path = new InputPath(subphrase, labels, range, &prevPath, inputScore); list.push_back(path); m_inputPathQueue.push_back(path); } // for (size_t i = 0; i < col.size(); ++i) { ++prevNodesInd; } // for (iterPath = prevPaths.begin(); iterPath != prevPaths.end(); ++iterPath) { } } }
void getInterval(T * interval, int i, T max, T min = T(0)){ double diam = range(max,min); double left = diam * i + min; interval[0] = left; interval[1] = left + diam; }
void DSP::serialize(serializer& s) { Thread::serialize(s); s.array(apuram); s.array(state.regs, 128); s.array(state.echoHistory[0]); s.array(state.echoHistory[1]); s.integer(state.echoHistoryOffset); s.integer(state.everyOtherSample); s.integer(state.kon); s.integer(state.noise); s.integer(state.counter); s.integer(state.echoOffset); s.integer(state.echoLength); s.integer(state.konBuffer); s.integer(state.endxBuffer); s.integer(state.envxBuffer); s.integer(state.outxBuffer); s.integer(state._pmon); s.integer(state._non); s.integer(state._eon); s.integer(state._dir); s.integer(state._koff); s.integer(state._brrNextAddress); s.integer(state._adsr0); s.integer(state._brrHeader); s.integer(state._brrByte); s.integer(state._srcn); s.integer(state._esa); s.integer(state._echoDisabled); s.integer(state._dirAddress); s.integer(state._pitch); s.integer(state._output); s.integer(state._looped); s.integer(state._echoPointer); s.array(state._mainOut, 2); s.array(state._echoOut, 2); s.array(state._echoIn, 2); for(auto n : range(8)) { s.array(voice[n].buffer); s.integer(voice[n].bufferOffset); s.integer(voice[n].gaussianOffset); s.integer(voice[n].brrAddress); s.integer(voice[n].brrOffset); s.integer(voice[n].vbit); s.integer(voice[n].vidx); s.integer(voice[n].konDelay); s.integer(voice[n].envelopeMode); s.integer(voice[n].envelope); s.integer(voice[n].hiddenEnvelope); s.integer(voice[n]._envxOut); } }
static tree move_brackets_sub (tree t, bool in) { //cout << t << INDENT << LF; if (is_compound (t)) { int i, n= N(t); tree r= tree (t, n); for (i=0; i<n; i++) r[i]= move_brackets_sub (t[i], in); t= r; } while (true) { tree r= t; bool search= true; if (is_concat (t)) for (int i=0; i<N(t) && search; i++) if (is_compound (t[i], "math")) { array<tree> a= concat_tokenize (t[i][0]); for (int j=0; j<N(a) && search; j++) if (is_atomic (a[j]) && is_simple_opening (a[j]->label)) for (int k= i+1; k<N(t) && search; k++) if (is_atomic (t[k])) { string s= t[k]->label; for (int l=0; l<N(s) && search; tm_char_forwards (s, l)) if (is_simple_matching (a[j]->label, s (l, l+1))) { if (k == i+1 && l == 0 && in) { array<tree> c= concat_decompose (t); a << tree (s (0, 1)); c[i]= compound ("math", concat_recompose (a)); c[i]= upgrade_brackets (c[i]); c[i+1]= s (1, N(s)); r= move_brackets_sub (concat_recompose (c), in); search= false; } else if (j == 0 && !in) { tree x= a[0]; array<tree> c= concat_decompose (t); a= range (a, 1, N(a)); c[i]= compound ("math", concat_recompose (a)); c= append (range (c, 0, i), append (x, range (c, i, N(c)))); r= move_brackets_sub (concat_recompose (c), in); search= false; } } } for (int j=N(a)-1; j>=0 && search; j--) if (is_atomic (a[j]) && is_simple_closing (a[j]->label)) for (int k= i-1; k>=0 && search; k--) if (is_atomic (t[k])) { string s= t[k]->label; for (int l=N(s); l>0 && search; tm_char_backwards (s, l)) if (is_simple_matching (s (l-1, l), a[j]->label)) { if (k == i-1 && l == N(s) && in) { array<tree> c= concat_decompose (t); a= append (tree (s (l-1, l)), a); c[i]= compound ("math", concat_recompose (a)); c[i]= upgrade_brackets (c[i]); c[i-1]= s (0, l-1); r= move_brackets_sub (concat_recompose (c), in); search= false; } else if (j == N(a)-1 && !in) { tree x= a[j]; array<tree> c= concat_decompose (t); a= range (a, 0, j); c[i]= compound ("math", concat_recompose (a)); c= append (range (c, 0, i+1), append (x, range (c, i+1, N(c)))); r= move_brackets_sub (concat_recompose (c), in); search= false; } } } } if (search) break; else { //cout << "< " << t << LF; //cout << "> " << r << LF; t= r; } } //cout << UNINDENT << "Done" << LF; return t; }
void MencoderTranscoding::updateArguments() { QString fontFile = "/Users/doudou/workspaceQT/DLNA_server/exe/LucidaSansRegular.ttf"; QStringList arguments; if (range() != 0 && !range()->isNull()) { if (range()->getStartByte() > 0 && lengthInSeconds() > 0) { double start_position = double(range()->getStartByte())/double(range()->getSize())*double(lengthInSeconds()); arguments << "-ss" << QString("%1.0").arg(long(start_position)); } } else if (timeSeekStart() > 0) { arguments << "-ss" << QString("%1.0").arg(timeSeekStart()); } arguments << url(); if (format() == MPEG2_AC3) { // set container format to MPEG arguments << "-of" << "mpeg"; arguments << "-mpegopts" << "format=mpeg2:muxrate=500000:vbuf_size=1194:abuf_size=64"; // set audio options arguments << "-oac" << "lavc"; arguments << "-channels" << "6"; arguments << "-af" << "lavcresample=48000"; arguments << "-srate" << "48000"; // set video options arguments << "-ovc" << "lavc"; arguments << "-lavcopts" << "autoaspect=1:vcodec=mpeg2video:acodec=ac3:abitrate=448:keyint=25:vrc_maxrate=9800:vrc_buf_size=1835:vbitrate=5000"; // set font file arguments << "-font" << fontFile; // set subtitles options arguments << "-ass" << "-ass-color" << "ffffff00" << "-ass-border-color" << "00000000" << "-ass-font-scale" << "1.4"; arguments << "-ass-force-style" << QString("FontName=%1,Outline=1,Shadow=1,MarginV=10").arg(fontFile); // choose audio and subtitle language if (audioLanguages().contains("fre")) { arguments << "-aid" << QString("%1").arg(audioLanguages().indexOf("fre")); arguments << "-nosub"; } else { if (subtitleLanguages().contains("fre")) { arguments << "-noautosub" << "-sid" << QString("%1").arg(subtitleLanguages().indexOf("fre")); } else if (subtitleLanguages().contains("eng")) { arguments << "-noautosub" << "-sid" << QString("%1").arg(subtitleLanguages().indexOf("eng")); } } // set frame rate if (!frameRate().isEmpty()) { if (frameRate() == "23.976") { arguments << "-ofps" << "24000/1001"; } else if (frameRate() == "29.970") { arguments << "-ofps" << "30000/1001"; } else { // default framerate output arguments << "-ofps" << "25.000"; } } else { // default framerate output arguments << "-ofps" << "25.000"; } } else { logError(QString("Invalid format: %1").arg(format())); } if (range() != 0 && !range()->isNull()) { if (range()->getLength() > 0) { if (range()->getHighRange() >= 0 && lengthInSeconds() > 0) { // calculate the endpos in seconds double endpos = double(range()->getLength())/double(range()->getSize())*double(lengthInSeconds()); arguments << "-endpos" << QString("%1").arg(long(endpos)); } } else { // invalid length arguments << "-endpos 0"; } } else if (timeSeekEnd() > 0) { arguments << "-endpos" << QString("%1").arg(timeSeekEnd()); } // set output = pipe arguments << "-o" << "-"; // set option on loglevel (required to use seek time mode, option -ss) arguments << "-really-quiet"; arguments << "-msglevel" << "statusline=2"; setArguments(arguments); }
/// /// Define all (nuisance) parameters. /// /// scan: defines scan range (for Prob and Plugin methods) /// phys: physically allowed range (needs to be set!) /// bboos: Ranges for Berger-Boos method /// force: min, max used by the force fit method /// void ParametersGammaCombo::defineParameters() { Parameter *p = 0; p = newParameter("g"); p->title = "#gamma"; p->startvalue = DegToRad(70); // p->startvalue = DegToRad(119); p->unit = "Rad"; // p->unit = ""; p->scan = range(DegToRad(0), DegToRad(180)); p->phys = range(-7, 7); p->force = range(DegToRad(0), DegToRad(90)); p->bboos = range(DegToRad(0), DegToRad(180)); p = newParameter("d_dk"); //p->title = "#delta_{B}^{K}"; p->title = "#delta_{B}^{DK}"; p->startvalue = DegToRad(127); p->unit = "Rad"; p->scan = range(DegToRad(0), DegToRad(180)); p->phys = range(-7, 7); p->force = range(DegToRad(0), DegToRad(90)); p->bboos = range(DegToRad(-180), DegToRad(180)); // B -> DK p = newParameter("r_dk"); // p->title = "r_{B}^{K}"; p->title = "r_{B}^{DK}"; p->startvalue = 0.09; p->unit = ""; p->scan = range(0.02, 0.2); p->phys = range(0, 1e4); p->force = range(0.02, 0.16); p->bboos = range(0.01, 0.22); // B -> DK p = newParameter("xm_dk"); p->title = "x- (DK)"; p->startvalue = 0; p->unit = ""; p->scan = range(-0.2, 0.2); p->phys = range(-1e4, 1e4); p->force = range(-0.2, 0.2); p->bboos = range(0.01, 0.22); // B -> DK p = newParameter("ym_dk"); p->title = "y- (DK)"; p->startvalue = 0; p->unit = ""; p->scan = range(0.0, 0.3); p->phys = range(-1e4, 1e4); p->force = range(-0.2, 0.2); p->bboos = range(0.01, 0.22); // B -> DK p = newParameter("xp_dk"); p->title = "x+ (DK)"; p->startvalue = 0; p->unit = ""; p->scan = range(-0.2, 0.2); p->phys = range(-1e4, 1e4); p->force = range(-0.2, 0.2); p->bboos = range(0.01, 0.22); // B -> DK p = newParameter("yp_dk"); p->title = "y+ (DK)"; p->startvalue = 0; p->unit = ""; p->scan = range(-0.2, 0.2); p->phys = range(-1e4, 1e4); p->force = range(-0.2, 0.2); p->bboos = range(0.01, 0.22); // B -> DK p = newParameter("RBRdkdpi"); p->title = "RBRdkdpi"; p->startvalue = 0.076; p->unit = ""; p->scan = range(0.07, 0.09); p->phys = range(0, 1e4); p->force = range(0.07, 0.09); p->bboos = range(0.02, 0.27); // B -> DK / B -> Dpi p = newParameter("d_dpi"); // p->title = "#delta_{B}^{#pi}"; p->title = "#delta_{B}^{D#pi}"; p->startvalue = DegToRad(223);; p->unit = "Rad"; // p->scan = range(DegToRad(0), DegToRad(180)); p->scan = range(DegToRad(180), DegToRad(360)); p->phys = range(-7, 7); p->force = range(DegToRad(0), DegToRad(90)); p->bboos = range(DegToRad(-180), DegToRad(180)); // B -> Dpi p = newParameter("r_dpi"); // p->title = "r_{B}^{#pi}"; p->title = "r_{B}^{D#pi}"; p->startvalue = 0.005; p->unit = ""; p->scan = range(0, 0.1); p->phys = range(0, 1e4); p->force = range(0.001, 0.04); p->bboos = range(0, 0.18); // B -> Dpi p = newParameter("xm_dpi"); p->title = "x- (D#pi)"; p->startvalue = 0; p->unit = ""; p->scan = range(-0.2, 0.2); p->phys = range(-1e4, 1e4); p->force = range(-0.2, 0.2); p->bboos = range(0.01, 0.22); // B -> Dpi p = newParameter("ym_dpi"); p->title = "y- (D#pi)"; p->startvalue = 0; p->unit = ""; p->scan = range(0.0, 0.3); p->phys = range(-1e4, 1e4); p->force = range(-0.2, 0.2); p->bboos = range(0.01, 0.22); // B -> Dpi p = newParameter("xp_dpi"); p->title = "x+ (D#pi)"; p->startvalue = 0; p->unit = ""; p->scan = range(-0.2, 0.2); p->phys = range(-1e4, 1e4); p->force = range(-0.2, 0.2); p->bboos = range(0.01, 0.22); // B -> Dpi p = newParameter("yp_dpi"); p->title = "y+ (D#pi)"; p->startvalue = 0; p->unit = ""; p->scan = range(-0.2, 0.2); p->phys = range(-1e4, 1e4); p->force = range(-0.2, 0.2); p->bboos = range(0.01, 0.22); // B -> Dpi p = newParameter("d_dkpipi"); p->title = "#delta_{B}^{DK#pi#pi}"; p->startvalue = DegToRad(338); p->unit = "Rad"; p->scan = range(DegToRad(0), DegToRad(180)); p->phys = range(-7, 7); p->force = range(DegToRad(0), DegToRad(90)); p->bboos = range(DegToRad(-180), DegToRad(180)); p = newParameter("r_dkpipi"); p->title = "r_{B}^{DK#pi#pi}"; p->startvalue = 0.09; p->unit = ""; p->scan = range(0.02, 0.16); p->phys = range(0, 1e4); p->force = range(0.02, 0.16); p->bboos = range(0.01, 0.22); p = newParameter("k_dkpipi"); p->title = "#kappa_{B}^{DK#pi#pi}"; p->startvalue = 0.3; p->unit = ""; p->scan = range(0.01, 1.0); p->phys = range(0, 1); p->force = range(0.01, 1.5); p->bboos = range(0.01, 1.5); p = newParameter("d_dpipipi"); p->title = "#delta_{B}^{D#pi#pi#pi}"; p->startvalue = DegToRad(330); p->unit = "Rad"; p->scan = range(DegToRad(0), DegToRad(180)); p->phys = range(-7, 7); p->force = range(DegToRad(0), DegToRad(90)); p->bboos = range(DegToRad(-180), DegToRad(180)); p = newParameter("r_dpipipi"); p->title = "r_{B}^{D#pi#pi#pi}"; p->startvalue = 0.015; p->unit = ""; p->scan = range(0.02, 0.16); p->phys = range(0, 1e4); p->force = range(0.02, 0.16); p->bboos = range(0.01, 0.22); p = newParameter("k_dpipipi"); p->title = "#kappa_{B}^{D#pi#pi#pi}"; p->startvalue = 0.3; p->unit = ""; p->scan = range(0.01, 1.0); p->phys = range(0, 1); p->force = range(0.01, 1.5); p->bboos = range(0.01, 1.5); // B -> DKpipi / B -> Dpipipi p = newParameter("RBRdhpipi"); p->title = "R_{cab}^{Dh#pi#pi}"; p->startvalue = 0.03; p->unit = ""; p->scan = range(0.07, 0.09); p->phys = range(0, 1e4); p->force = range(0.07, 0.09); p->bboos = range(0.02, 0.27); // B+ -> D*K+ p = newParameter("d_dstk"); p->title = "#delta_{B}^{D*K}"; p->startvalue = DegToRad(127); p->unit = "Rad"; p->scan = range(DegToRad(0), DegToRad(180)); p->phys = range(-7, 7); p->force = range(DegToRad(0), DegToRad(90)); p->bboos = range(DegToRad(-180), DegToRad(180)); // B -> D*K p = newParameter("r_dstk"); p->title = "r_{B}^{D*K}"; p->startvalue = 0.09; p->unit = ""; p->scan = range(0.02, 0.2); p->phys = range(0, 1e4); p->force = range(0.02, 0.16); p->bboos = range(0.01, 0.22); // B -> D*K // B+ -> DK*+ p = newParameter("d_dkst"); p->title = "#delta_{B}^{DK*}"; p->startvalue = DegToRad(127); p->unit = "Rad"; p->scan = range(DegToRad(0), DegToRad(180)); p->phys = range(-7, 7); p->force = range(DegToRad(0), DegToRad(90)); p->bboos = range(DegToRad(-180), DegToRad(180)); // B -> DK* p = newParameter("k_dkst"); p->title = "#kappa_{B}^{DK*}"; p->startvalue = 0.9; p->unit = ""; p->scan = range(0, 2.5); p->phys = range(0, 1); p->force = range(0.001, 1); p->bboos = range(0, 1); p = newParameter("r_dkst"); p->title = "r_{B}^{DK*}"; p->startvalue = 0.09; p->unit = ""; p->scan = range(0.02, 0.2); p->phys = range(0, 1e4); p->force = range(0.02, 0.16); p->bboos = range(0.01, 0.22); // B -> DK* // B0 -> D0Kst0 p = newParameter("d_dkstz"); p->title = "#delta_{D^{0}K^{*}}"; p->startvalue = DegToRad(200); p->unit = "Rad"; p->scan = range(DegToRad(0), DegToRad(360)); p->phys = range(-7, 7); p->force = range(DegToRad(180), DegToRad(360)); p->bboos = range(DegToRad(0), DegToRad(360)); // B0 -> D0Kst0 p = newParameter("r_dkstz"); p->title = "r_{D^{0}K^{*}}"; p->startvalue = 0.3; p->unit = ""; p->scan = range(0, 1.); p->phys = range(0.001, 1); p->force = range(0.001, 0.6); p->bboos = range(0, 1); p = newParameter("k_dkstz"); p->title = "#kappa_{D^{0}K^{*}}"; p->startvalue = 0.9; p->unit = ""; p->scan = range(0, 2.5); p->phys = range(0, 1); p->force = range(0.001, 1); p->bboos = range(0, 1); // B0 -> D0Kpi //p = newParameter("d_dkpi"); //p->title = "#delta_{D^{0}K#pi}"; //p->startvalue = DegToRad(270); //p->unit = "Rad"; //p->scan = range(DegToRad(0), DegToRad(180)); //p->phys = range(-7, 7); //p->force = range(DegToRad(0), DegToRad(90)); //p->bboos = range(DegToRad(-180), DegToRad(180)); // B0 -> D0Kst0 //p = newParameter("r_dkpi"); //p->title = "r_{D^{0}K#pi}"; //p->startvalue = 0.3; //p->unit = ""; //p->scan = range(0, 1.0); //p->phys = range(0.001, 1); //p->force = range(0.001, 0.5); //p->bboos = range(0, 1); // Special ratio parameters suggested by Tim p = newParameter("delta_dkstz"); p->title = "#bar{#Delta}_{D^{0}K*^{0}}"; p->startvalue = DegToRad(0.2); p->unit = ""; p->scan = range(DegToRad(-20), DegToRad(20)); p->phys = range(-7, 7); p->force = range(DegToRad(-90), DegToRad(90)); p->bboos = range(DegToRad(-180), DegToRad(180)); // B0 -> D0Kst0 p = newParameter("R_dkstz"); p->title = "#bar{R}_{D^{0}K*^{0}}"; p->startvalue = 1.1; p->unit = ""; p->scan = range(0.8, 1.2); p->phys = range(0.001, 10.); p->force = range(0.001, 10.0); p->bboos = range(0, 10); //p = newParameter("k_dkpi"); //p->title = "#kappa_{D^{0}K#pi}"; //p->startvalue = 0.9; //p->unit = ""; //p->scan = range(0, 2.5); //p->phys = range(0, 1); //p->force = range(0.001, 1); //p->bboos = range(0, 1); // Bs -> DsK p = newParameter("l_dsk"); // p->title = "#lambda_{D_{s}K}"; p->title = "r_{D_{s}K}"; // p->startvalue = 0.37; p->startvalue = 0.54; p->unit = ""; p->scan = range(0, 1.4); p->phys = range(0, 1e4); p->force = range(0.01, 1); p->bboos = range(0, 1); p = newParameter("d_dsk"); p->title = "#delta_{D_{s}K}"; // p->startvalue = DegToRad(20); p->startvalue = DegToRad(8); p->unit = "Rad"; p->scan = range(DegToRad(-90), DegToRad(90)); // p->scan = range(DegToRad(-70), DegToRad(290)); p->phys = range(-7, 7); p->force = range(DegToRad(0), DegToRad(90)); p->bboos = range(DegToRad(-90), DegToRad(90)); // Bs mixing phase p = newParameter("phis"); p->title = "#phi_{s}"; p->startvalue = 0.01; //p->unit = "Rad"; // don't use Rad becaus phi cannot wrap around and then bring back angles messes with it p->unit = ""; p->scan = range(-0.25, 0.25); p->phys = range(-7, 7); p->force = range(-0.25, 0.25); p->bboos = range(-0.25, 0.25); // Bs -> DsK p = newParameter("rD_kpi"); p->title = "r_{K#pi}"; p->startvalue = 0.058; p->unit = ""; p->scan = range(0.054, 0.061); p->phys = range(0, 1e4); p->force = range(0.001, 0.15); p->bboos = range(0.01, 0.21); // D -> Kpi p = newParameter("dD_kpi"); p->title = "#delta_{K#pi}"; p->startvalue = DegToRad(188); p->unit = "Rad"; p->scan = range(DegToRad(160), DegToRad(250)); p->phys = range(-7, 7); p->force = range(DegToRad(150), DegToRad(250)); p->bboos = range(DegToRad(150), DegToRad(250)); // D -> Kpi p = newParameter("rD_k3pi"); p->title = "r_{K3#pi}"; p->startvalue = 0.056; p->unit = ""; p->scan = range(0.045, 0.065); p->phys = range(0, 1e4); p->force = range(0.001, 0.15); p->bboos = range(0.01, 0.15); // D -> Kpipipi p = newParameter("dD_k3pi"); p->title = "#delta_{K3#pi}"; // p->startvalue = DegToRad(235); p->startvalue = DegToRad(127); p->unit = "Rad"; p->scan = range(DegToRad(0), DegToRad(360)); p->phys = range(-7, 7); p->force = range(DegToRad(20), DegToRad(180)); p->bboos = range(DegToRad(150), DegToRad(300)); // D -> Kpipipi p = newParameter("kD_k3pi"); p->title = "#kappa_{K3#pi}"; p->startvalue = 0.26; p->unit = ""; p->scan = range(0.01, 1); p->phys = range(0, 1); p->force = range(0.01, 0.8); p->bboos = range(0, 1); // D -> Kpipipi p = newParameter("rD_kpipi0"); p->title = "r_{K#pi#pi^{0}}"; p->startvalue = 0.046; p->unit = ""; p->scan = range(0.035, 0.055); p->phys = range(0, 1e4); p->force = range(0.001, 0.15); p->bboos = range(0.01, 0.15); p = newParameter("dD_kpipi0"); p->title = "#delta_{K#pi#pi^{0}}"; p->startvalue = DegToRad(164); p->unit = "Rad"; p->scan = range(DegToRad(0), DegToRad(360)); p->phys = range(-7, 7); p->force = range(DegToRad(20), DegToRad(180)); p->bboos = range(DegToRad(150), DegToRad(300)); p = newParameter("kD_kpipi0"); p->title = "#kappa_{K#pi#pi^{0}}"; p->startvalue = 0.86; p->unit = ""; p->scan = range(0.01, 1); p->phys = range(0, 1); p->force = range(0.01, 0.8); p->bboos = range(0, 1); p = newParameter("F_pipipi0"); p->title = "F_{pipi#pi^{0}}"; p->startvalue = 0.97; p->unit = ""; p->scan = range(0,1); p->phys = range(0,1); p->force = range(0,1); p->bboos = range(0,1); p = newParameter("F_kkpi0"); p->title = "F_{KK#pi^{0}}"; p->startvalue = 0.73; p->unit = ""; p->scan = range(0,1); p->phys = range(0,1); p->force = range(0,1); p->bboos = range(0,1); p = newParameter("F_pipipipi"); p->title = "F_{4#pi}"; p->startvalue = 0.74; p->unit = ""; p->scan = range(0,1); p->phys = range(0,1); p->force = range(0,1); p->bboos = range(0,1); p = newParameter("BR_D_Kminus3pi"); p->title = "BF(D#rightarrowK^{-}3#pi)"; p->startvalue = 8.29e-2; p->unit = ""; p->scan = range(0.,0.5); p->phys = range(0, 1); p->force = range(0.01, 0.8); p->bboos = range(0, 1); p = newParameter("BR_D_Kplus3pi"); p->title = "BF(D#rightarrowK^{+}3#pi)"; p->startvalue = 2.6e-4; p->unit = ""; p->scan = range(0.,0.01); p->phys = range(0, 1); p->force = range(1.e-5,1.e-3); p->bboos = range(0, 1); p = newParameter("AcpDKK"); p->title = "#A_{CP}(D #rightarrow KK)"; p->startvalue = 0.0; p->unit = ""; p->scan = range(-0.1, 0.1); p->phys = range(-1, 1); p->force = range(-0.1, 0.1); p->bboos = range(-0.1, 0.1); // D->KK p = newParameter("AcpDpipi"); p->title = "#A_{CP}(D #rightarrow pipi)"; p->startvalue = 0.0; p->unit = ""; p->scan = range(-0.1, 0.1); p->phys = range(-1, 1); p->force = range(-0.1, 0.1); p->bboos = range(-0.1, 0.1); // D->pipi p = newParameter("AcpDzKstpKm"); p->title = "#A_{CP}(D^{0} #rightarrow K^{*+}K^{-})"; p->startvalue = 0.0; p->unit = ""; p->scan = range(-0.1, 0.1); p->phys = range(-1, 1); p->force = range(-0.1, 0.1); p->bboos = range(-0.1, 0.1); p = newParameter("AcpDzKstmKp"); p->title = "#A_{CP}(D^{0} #rightarrow K^{*-}K^{+})"; p->startvalue = 0.0; p->unit = ""; p->scan = range(-0.1, 0.1); p->phys = range(-1, 1); p->force = range(-0.1, 0.1); p->bboos = range(-0.1, 0.1); p = newParameter("rD_k2pi"); p->title = "r_{K2#pi}"; p->startvalue = 0.05; p->unit = ""; p->scan = range(0, 0.1); p->phys = range(0, 1e4); p->force = range(0.001, 0.15); p->bboos = range(0, 0.15); // CLEO p = newParameter("kD_k2pi"); p->title = "k_{K2#pi}"; p->startvalue = 0.84; p->unit = ""; p->scan = range(0, 1); p->phys = range(0, 1); p->force = range(0.01, 1); p->bboos = range(0, 1); // CLEO p = newParameter("dD_k2pi"); p->title = "#delta_{K2#pi}"; p->startvalue = 3.96; p->unit = "Rad"; p->scan = range(DegToRad(0), DegToRad(360)); p->phys = range(-7, 7); p->force = range(DegToRad(0), DegToRad(90)); p->bboos = range(DegToRad(0), DegToRad(360)); // CLEO p = newParameter("rD_kskpi"); p->title = "r_{KSK#pi}"; p->startvalue = 0.59; p->unit = ""; p->scan = range(0, 0.1); p->phys = range(0, 1e4); p->force = range(0.001, 0.15); p->bboos = range(0, 0.15); p = newParameter("kD_kskpi"); p->title = "k_{KSK#pi}"; p->startvalue = 1.0; p->unit = ""; p->scan = range(0, 1); p->phys = range(0, 1); p->force = range(0.01, 1); p->bboos = range(0, 1); p = newParameter("dD_kskpi"); p->title = "#delta_{KSK#pi}"; p->startvalue = DegToRad(26.); p->unit = "Rad"; p->scan = range(DegToRad(0), DegToRad(360)); p->phys = range(-7, 7); p->force = range(DegToRad(0), DegToRad(90)); p->bboos = range(DegToRad(0), DegToRad(360)); p = newParameter("xD"); p->title = "x_{D}"; p->startvalue = 4.1e-03; p->unit = ""; p->scan = range(0.002, 0.012); p->phys = range(-1, 1); p->force = range(0.002, 0.012); p->bboos = range(0., 0.016); // D mixing p = newParameter("yD"); p->title = "y_{D}"; p->startvalue = 6.3e-03; p->unit = ""; p->scan = range(0.002, 0.012); p->phys = range(-1, 1); p->force = range(0.002, 0.012); p->bboos = range(0., 0.016); // D mixing p = newParameter("B1"); p->title = "BR(D #rightarrow K#pi)"; p->startvalue = 3.89e-02; p->unit = ""; p->scan = range(0.0380, 0.0395); p->phys = range(0, 1); p->force = range(0.0380, 0.0395); p->bboos = range(0.01, 0.05); // CLEO p = newParameter("B3"); p->title = "BR(D #rightarrow K3#pi)"; p->startvalue = 7.96e-02; p->unit = ""; p->scan = range(0.07, 0.09); p->phys = range(0, 1); p->force = range(0.07, 0.09); p->bboos = range(0.02, 0.3); // CLEO p = newParameter("B5"); p->title = "BR(D #rightarrow K2#pi)"; p->startvalue = 1.38e-01; p->unit = ""; p->scan = range(0.05, 0.2); p->phys = range(0, 1); p->force = range(0.05, 0.2); p->bboos = range(0.01, 0.6); // CLEO p = newParameter("Aprod"); p->title = "Aprod(Bu)"; p->startvalue = 0.0; p->unit = ""; p->scan = range(-0.1, 0.1); p->phys = range(-1, 1); p->force = range(-0.1, 0.1); p->bboos = range(-0.1, 0.1); p = newParameter("a_gaus"); p->title = "a_{Gaus}"; p->startvalue = 0; p->unit = ""; p->scan = range(-2.5, 2.5); p->phys = range(0, 1e4); // to implement a Feldman-Cousins like forbidden region, change this range and use --pr p->force = range(-2, 4); p->bboos = range(-2, 4); p->free = range(-1e4, 1e4); p = newParameter("b_gaus"); p->title = "b_{Gaus}"; p->startvalue = 0; p->unit = ""; p->scan = range(-2, 4); p->phys = range(-1e4, 1e4); p->force = range(-2, 4); p->bboos = range(-2, 4); p = newParameter("B_k3pi_FAV"); p->title = "B(D#rightarrowK3#pi FAV)"; p->startvalue = 8.e-02; p->unit = ""; p->scan = range(0.,1.); p->phys = range(0.,1.); p->force = range(0.,1.); p->bboos = range(0.,1.); p = newParameter("B_k3pi_SUP"); p->title = "B(D#rightarrowK3#pi SUP)"; p->startvalue = 2.65e-04; p->unit = ""; p->scan = range(0.,1.); p->phys = range(0.,1.); p->force = range(0.,1.); p->bboos = range(0.,1.); p = newParameter("B_kpipi0_FAV"); p->title = "B(D#rightarrowK#pi#pi^{0} FAV)"; p->startvalue = 13.8e-02; p->unit = ""; p->scan = range(0.,1.); p->phys = range(0.,1.); p->force = range(0.,1.); p->bboos = range(0.,1.); p = newParameter("B_kpipi0_SUP"); p->title = "B(D#rightarrowK#pi#pi^{0} SUP)"; p->startvalue = 3.e-04; p->unit = ""; p->scan = range(0.,1.); p->phys = range(0.,1.); p->force = range(0.,1.); p->bboos = range(0.,1.); p = newParameter("B_kpi_FAV"); p->title = "B(D#rightarrowK#pi FAV)"; p->startvalue = 4.e-02; p->unit = ""; p->scan = range(0.,1.); p->phys = range(0.,1.); p->force = range(0.,1.); p->bboos = range(0.,1.); p = newParameter("B_kpi_SUP"); p->title = "B(D#rightarrowK#pi SUP)"; p->startvalue = 1.5e-04; p->unit = ""; p->scan = range(0.,1.); p->phys = range(0.,1.); p->force = range(0.,1.); p->bboos = range(0.,1.); // u and v p = newParameter("u_dpi"); p->title = "u^{D#pi}"; p->startvalue = 0.01; p->unit = ""; p->scan = range(-0.05,0.05); p->phys = range(-0.1,0.1); p->force = range(-0.1,0.1); p->bboos = range(-0.1,0.1); p = newParameter("v_dpi"); p->title = "v^{D#pi}"; p->startvalue = -0.01; p->unit = ""; p->scan = range(-0.05,0.05); p->phys = range(-0.1,0.1); p->force = range(-0.1,0.1); p->bboos = range(-0.1,0.1); }
// read zone file, allowing for zones with or without end dates bool Zones::read(QFile &file) { defaults_from_user = false; scheme.zone_default.clear(); scheme.zone_default_is_pct.clear(); scheme.zone_default_name.clear(); scheme.zone_default_desc.clear(); scheme.nzones_default = 0; ranges.clear(); // set up possible warning dialog warning = QString(); int warning_lines = 0; const int max_warning_lines = 100; // macro to append lines to the warning #define append_to_warning(s) \ if (warning_lines < max_warning_lines) \ warning.append(s); \ else if (warning_lines == max_warning_lines) \ warning.append("...\n"); \ warning_lines ++; // read using text mode takes care of end-lines if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { err = "can't open file"; return false; } QTextStream fileStream(&file); QRegExp commentrx("\\s*#.*$"); QRegExp blankrx("^[ \t]*$"); QRegExp rangerx[] = { QRegExp("^\\s*(?:from\\s+)?" // optional "from" "((\\d\\d\\d\\d)[-/](\\d{1,2})[-/](\\d{1,2})|BEGIN)" // begin date "\\s*([,:]?\\s*(FTP|CP)\\s*=\\s*(\\d+))?" // optional {CP/FTP = integer (optional %)} "\\s*:?\\s*$", // optional : Qt::CaseInsensitive), QRegExp("^\\s*(?:from\\s+)?" // optional "from" "((\\d\\d\\d\\d)[-/](\\d{1,2})[-/](\\d{1,2})|BEGIN)" // begin date "\\s+(?:until|to|-)\\s+" // until "((\\d\\d\\d\\d)[-/](\\d{1,2})[-/](\\d{1,2})|END)?" // end date "\\s*:?,?\\s*((FTP|CP)\\s*=\\s*(\\d+))?" // optional {CP/FTP = integer (optional %)} "\\s*:?\\s*$", // optional : Qt::CaseInsensitive) }; QRegExp zonerx("^\\s*([^ ,][^,]*),\\s*([^ ,][^,]*),\\s*" "(\\d+)\\s*(%?)\\s*(?:,\\s*(\\d+|MAX)\\s*(%?)\\s*)?$", Qt::CaseInsensitive); QRegExp zonedefaultsx("^\\s*(?:zone)?\\s*defaults?\\s*:?\\s*$", Qt::CaseInsensitive); int lineno = 0; // the current range in the file // ZoneRange *range = NULL; bool in_range = false; QDate begin = date_zero, end = date_infinity; int cp=0; QList<ZoneInfo> zoneInfos; // true if zone defaults are found in the file (then we need to write them) bool zones_are_defaults = false; while (! fileStream.atEnd() ) { ++lineno; QString line = fileStream.readLine(); int pos = commentrx.indexIn(line, 0); if (pos != -1) line = line.left(pos); if (blankrx.indexIn(line, 0) == 0) goto next_line; // check for default zone range definition (may be followed by zone definitions) if (zonedefaultsx.indexIn(line, 0) != -1) { zones_are_defaults = true; // defaults are allowed only at the beginning of the file if (ranges.size()) { err = "Zone defaults must be specified at head of power.zones file"; return false; } // only one set of defaults is allowed if (scheme.nzones_default) { err = "Only one set of zone defaults may be specified in power.zones file"; return false; } goto next_line; } // check for range specification (may be followed by zone definitions) for (int r=0; r<2; r++) { if (rangerx[r].indexIn(line, 0) != -1) { if (in_range) { // if zones are empty, then generate them ZoneRange range(begin, end, cp); range.zones = zoneInfos; if (range.zones.empty()) { if (range.cp > 0) setZonesFromCP(range); else { err = tr("line %1: read new range without reading " "any zones for previous one").arg(lineno); file.close(); return false; } } else { qSort(range.zones); } ranges.append(range); } in_range = true; zones_are_defaults = false; zoneInfos.clear(); // process the beginning date if (rangerx[r].cap(1) == "BEGIN") begin = date_zero; else { begin = QDate(rangerx[r].cap(2).toInt(), rangerx[r].cap(3).toInt(), rangerx[r].cap(4).toInt()); } // process an end date, if any, else it is null if (rangerx[r].cap(5) == "END") end = date_infinity; else if (rangerx[r].cap(6).toInt() || rangerx[r].cap(7).toInt() || rangerx[r].cap(8).toInt()) { end = QDate(rangerx[r].cap(6).toInt(), rangerx[r].cap(7).toInt(), rangerx[r].cap(8).toInt()); } else { end = QDate(); } // set up the range, capturing CP if it's specified // range = new ZoneRange(begin, end); int nCP = (r ? 11 : 7); if (rangerx[r].numCaptures() == (nCP)) cp = rangerx[r].cap(nCP).toInt(); else cp = 0; // bleck goto next_line; } } // check for zone definition if (zonerx.indexIn(line, 0) != -1) { if (! (in_range || zones_are_defaults)) { err = tr("line %1: read zone without " "preceding date range").arg(lineno); file.close(); return false; } int lo = zonerx.cap(3).toInt(); // allow for zone specified as % of CP bool lo_is_pct = false; if (zonerx.cap(4) == "%") { if (zones_are_defaults) lo_is_pct = true; else if (cp > 0) lo = int(lo * cp / 100); else { err = tr("attempt to set zone based on % of " "CP without setting CP in line number %1.\n"). arg(lineno); file.close(); return false; } } int hi; // if this is not a zone defaults specification, process possible hi end of zones if (zones_are_defaults || zonerx.cap(5).isEmpty()) hi = -1; // signal an undefined number else if (zonerx.cap(5) == "MAX") hi = INT_MAX; else { hi = zonerx.cap(5).toInt(); // allow for zone specified as % of CP if (zonerx.cap(5) == "%") { if (cp > 0) hi = int(hi * cp / 100); else { err = tr("attempt to set zone based on % of CP " "without setting CP in line number %1.\n"). arg(lineno); file.close(); return false; } } } if (zones_are_defaults) { scheme.nzones_default ++; scheme.zone_default_is_pct.append(lo_is_pct); scheme.zone_default.append(lo); scheme.zone_default_name.append(zonerx.cap(1)); scheme.zone_default_desc.append(zonerx.cap(2)); defaults_from_user = true; } else { ZoneInfo zone(zonerx.cap(1), zonerx.cap(2), lo, hi); zoneInfos.append(zone); } } next_line: {} } if (in_range) { ZoneRange range(begin, end, cp); range.zones = zoneInfos; if (range.zones.empty()) { if (range.cp > 0) setZonesFromCP(range); else { err = tr("file ended without reading any zones for last range"); file.close(); return false; } } else { qSort(range.zones); } ranges.append(range); } file.close(); // sort the ranges qSort(ranges); // set the default zones if not in file if (!scheme.nzones_default) { // do we have a zone which is explicitly set? for (int i=0; i<ranges.count(); i++) { if (ranges[i].zonesSetFromCP == false) { // set the defaults using this one! scheme.nzones_default = ranges[i].zones.count(); for (int j=0; j<scheme.nzones_default; j++) { scheme.zone_default.append(((double)ranges[i].zones[j].lo / (double)ranges[i].cp) * 100.00); scheme.zone_default_is_pct.append(true); scheme.zone_default_name.append(ranges[i].zones[j].name); scheme.zone_default_desc.append(ranges[i].zones[j].desc); } } } // still not set then reset to defaults as usual if (!scheme.nzones_default) initializeZoneParameters(); } // resolve undefined endpoints in ranges and zones for (int nr = 0; nr < ranges.size(); nr ++) { // clean up gaps or overlaps in zone ranges if (ranges[nr].end.isNull()) ranges[nr].end = (nr < ranges.size() - 1) ? ranges[nr + 1].begin : date_infinity; else if ((nr < ranges.size() - 1) && (ranges[nr + 1].begin != ranges[nr].end)) { append_to_warning(tr("Setting end date of range %1 " "to start date of range %2.\n"). arg(nr + 1). arg(nr + 2) ); ranges[nr].end = ranges[nr + 1].begin; } else if ((nr == ranges.size() - 1) && (ranges[nr].end < QDate::currentDate())) { append_to_warning(tr("Extending final range %1 to infinite " "to include present date.\n").arg(nr + 1)); ranges[nr].end = date_infinity; } if (ranges[nr].cp <= 0) { err = tr("CP must be greater than zero in zone " "range %1 of power.zones").arg(nr + 1); return false; } if (ranges[nr].zones.size()) { // check that the first zone starts with zero ranges[nr].zones[0].lo = 0; // resolve zone end powers for (int nz = 0; nz < ranges[nr].zones.size(); nz ++) { if (ranges[nr].zones[nz].hi == -1) ranges[nr].zones[nz].hi = (nz < ranges[nr].zones.size() - 1) ? ranges[nr].zones[nz + 1].lo : INT_MAX; else if ((nz < ranges[nr].zones.size() - 1) && (ranges[nr].zones[nz].hi != ranges[nr].zones[nz + 1].lo)) { if (abs(ranges[nr].zones[nz].hi - ranges[nr].zones[nz + 1].lo) > 4) { append_to_warning(tr("Range %1: matching top of zone %2 " "(%3) to bottom of zone %4 (%5).\n"). arg(nr + 1). arg(ranges[nr].zones[nz].name). arg(ranges[nr].zones[nz].hi). arg(ranges[nr].zones[nz + 1].name). arg(ranges[nr].zones[nz + 1].lo) ); } ranges[nr].zones[nz].hi = ranges[nr].zones[nz + 1].lo; } else if ((nz == ranges[nr].zones.size() - 1) && (ranges[nr].zones[nz].hi < INT_MAX)) { append_to_warning(tr("Range %1: setting top of zone %2 from %3 to MAX.\n"). arg(nr + 1). arg(ranges[nr].zones[nz].name). arg(ranges[nr].zones[nz].hi) ); ranges[nr].zones[nz].hi = INT_MAX; } } } } // mark zones as modified so pages which depend on zones can be updated modificationTime = QDateTime::currentDateTime(); return true; }
ChunkMoppDemo::ChunkMoppDemo(hkDemoEnvironment* env) : hkDefaultPhysicsDemo(env) { //setGraphicsState(HKG_ENABLED_WIREFRAME, true); // // Setup the camera // { hkVector4 from(55.0f, 50.0f, 55.0f); hkVector4 to ( 0.0f, 0.0f, 0.0f); hkVector4 up ( 0.0f, 1.0f, 0.0f); setupDefaultCameras(env, from, to, up, 0.1f, 20000.0f); } // // Create the world // { hkpWorldCinfo worldInfo; { worldInfo.m_gravity.set(0.0f, -9.81f, 0.0f); worldInfo.setBroadPhaseWorldSize(10000.0f); worldInfo.setupSolverInfo( hkpWorldCinfo::SOLVER_TYPE_4ITERS_MEDIUM ); worldInfo.m_enableDeactivation = false; } m_world = new hkpWorld(worldInfo); m_world->lock(); // Register ALL agents (though some may not be necessary) hkpAgentRegisterUtil::registerAllAgents(m_world->getCollisionDispatcher()); setupGraphics(); } hkpShapeCollection* meshShape = createMeshShape( VERTS_PER_SIDE, m_delayedCleanup ); m_shape = createMoppShape( meshShape, true ); m_shape->getAabb( hkTransform::getIdentity(), 0.1f, m_bounds ); // // create the ground mopp // { hkpRigidBodyCinfo terrainInfo; { hkVector4 size(100.0f, 1.0f, 100.0f); terrainInfo.m_shape = m_shape; terrainInfo.m_motionType = hkpMotion::MOTION_FIXED; terrainInfo.m_friction = 0.5f; hkpRigidBody* terrainBody = new hkpRigidBody(terrainInfo); m_world->addEntity(terrainBody); terrainBody->removeReference(); } terrainInfo.m_shape->removeReference(); } hkVector4 halfExtents; hkVector4 centre; { m_bounds.getHalfExtents( halfExtents ); m_bounds.getCenter( centre ); m_minIndex = (halfExtents(0) < halfExtents(1)) ? ((halfExtents(0) < halfExtents(2)) ? 0 : 2) : ((halfExtents(1) < halfExtents(2)) ? 1 : 2) ; } // Setup the camera { hkVector4 up; up.setZero4(); up(m_minIndex) = 1.0f; hkVector4 from; from.setAddMul4( m_bounds.m_max, up, 5.0f); setupDefaultCameras(env, from, centre, up, 0.1f, 10000.0f); } // // Create objects at random coordinates // { hkVector4 size(0.5f, 0.5f, 0.5f); hkpBoxShape* boxShape = new hkpBoxShape(size); hkpRigidBodyCinfo boxInfo; { boxInfo.m_mass = 1.0f; boxInfo.m_shape = boxShape; boxInfo.m_motionType = hkpMotion::MOTION_BOX_INERTIA; } hkPseudoRandomGenerator random(15); // // create the boxes // { hkVector4 range; range.setSub4( m_bounds.m_max, m_bounds.m_min ); range.mul4( 1.0f ); const int numObjects = 500; for (int i = 0; i < numObjects; i++) { hkVector4 pos; random.getRandomVector11(pos); pos.mul4(0.1f); pos.mul4(range); pos( m_minIndex ) += m_bounds.m_max( m_minIndex ) + i * (range(m_minIndex)) / numObjects + 4.0f; boxInfo.m_position = pos; hkpRigidBody* shape; shape = new hkpRigidBody(boxInfo); shape->setMaxLinearVelocity( 30 ); m_world->addEntity(shape); shape->removeReference(); } } boxShape->removeReference(); } m_world->unlock(); m_time = 0.0f; }
constexpr auto count(T start, T step) noexcept { // if step is < 0, set the stop to numeric min, otherwise numeric max T stop = step < T(0) ? std::numeric_limits<T>::min() : std::numeric_limits<T>::max(); return range(start, stop, step); }
void Panner::draw ( void ) { int tw, th, tx, ty; bbox( tx, ty, tw, th ); fl_push_clip( x(),y(),w(),h() ); draw_the_box( tx, ty, tw, th ); // draw_box(); draw_label(); /* if ( _bypassed ) */ /* { */ /* draw_box(); */ /* fl_color( 0 ); */ /* fl_font( FL_HELVETICA, 12 ); */ /* fl_draw( "(bypass)", x(), y(), w(), h(), FL_ALIGN_CENTER ); */ /* goto done; */ /* } */ /* tx += b; */ /* ty += b; */ /* tw -= b * 2; */ /* th -= b * 2; */ fl_line_style( FL_SOLID, 1 ); fl_color( FL_WHITE ); for ( unsigned int i = 0; i < _points.size(); i++ ) { Point *p = &_points[i]; if ( ! p->visible ) continue; Fl_Color c = fl_color_add_alpha( p->color, 100 ); fl_color(c); int px, py, pw, ph; point_bbox( p, &px, &py, &pw, &ph ); { float po = 5; fl_push_clip( px - ( po * 12 ), py - ( po * 12 ), pw + ( po * 24 ), ph + (po * 24 )); fl_pie( px + 5, py + 5, pw - 10, ph - 10, 0, 360 ); fl_pie( px, py, pw, ph, 0, 360 ); fl_pop_clip(); if ( projection() == POLAR ) { fl_color( fl_color_average( fl_rgb_color( 127,127,127 ), p->color, 0.50 ) ); fl_begin_loop(); fl_circle( tx + tw/2, ty + th/2, tw/2.0f * ( ( p->radius() / range() ))); fl_end_loop(); } } const char *s = p->label; fl_color( fl_color_add_alpha( fl_rgb_color( 220,255,255 ), 127 ) ); fl_font( FL_HELVETICA_BOLD_ITALIC, 10 ); fl_draw( s, px + 20, py + 1, 50, ph - 1, FL_ALIGN_LEFT ); if ( tw > 100 ) { char pat[50]; snprintf( pat, sizeof(pat), "%.1f°:%.1f° %.1fm", p->azimuth(), p->elevation(), p->radius() ); // fl_color( fl_color_add_alpha( fl_rgb_color( 220,255,255 ), 127 ) ); fl_font( FL_COURIER, 9 ); fl_draw( pat, px + 20, py + 15, 50, ph - 1, FL_ALIGN_LEFT | FL_ALIGN_WRAP ); /* fl_font( FL_HELVETICA_ITALIC, 9 ); */ /* snprintf(pat, sizeof(pat), "range: %.1f meters", range() ); */ /* fl_draw( pat, tx, ty, tw, th, FL_ALIGN_LEFT | FL_ALIGN_BOTTOM | FL_ALIGN_INSIDE ); */ /* if ( _projection == POLAR ) */ /* { */ /* fl_draw( "Polar perspective; azimuth, elevation and radius input. Right click controls radius.", tx, ty, tw, th, FL_ALIGN_BOTTOM | FL_ALIGN_RIGHT | FL_ALIGN_INSIDE ); */ /* } */ /* else */ /* { */ /* fl_draw( "Polar orthographic; angle and distance input.", tx, ty, tw, th, FL_ALIGN_BOTTOM | FL_ALIGN_RIGHT | FL_ALIGN_INSIDE ); */ /* } */ } } if ( tw > 200 ) draw_children(); fl_line_style( FL_SOLID, 0 ); fl_pop_clip(); }
/** * @brief Range in bytes of buffer view */ auto range_bytes() const { return range() * buffer->get_element_size_bytes(); }
// return 0 to do nothing // return 1 to play last_state // return 2 to play silence int update( _DataType control_bit ) { __DEBUG__NORMAL__ printf( "%u: Updating %s\n", timer_counter, GAUtil::Str<_DataType>::str( control_bit ).c_str() ); int result = 0; bool do_commit = false; switch ( control_bit.toggle_type ) { //bool - toggle if( value ) case AudioBitEncodings::commit: do_commit = control_bit.toggle_value; if ( do_commit ) __DEBUG__NORMAL__ printf( "Saving current state:\n%s\n", state.toString().c_str() ); // save our current state for reference; start making changes to our new state last_state = state; has_previous_state = true; break; case AudioBitEncodings::key_rotate: state.key_index += control_bit.toggle_value ? 1 : -1; range( state.key_index, (int) 0, (int) 12, true ); __DEBUG__NORMAL__ printf( "Updated key_index: %u\n", state.key_index ); break; case AudioBitEncodings::key_flip: if ( control_bit.toggle_value ) state.key_is_major = !state.key_is_major; __DEBUG__NORMAL__ printf( "Updated key_is_major: %u\n", state.key_is_major ); break; // int - increment by value case AudioBitEncodings::duration: state.duration_index += control_bit.toggle_value; range( state.duration_index, (int) 0, (int) 4 ); __DEBUG__NORMAL__ printf( "Updated duration_index: %u\n", state.duration_index ); break; case AudioBitEncodings::time: state.beat_frequency_index += control_bit.toggle_value; range( state.beat_frequency_index, (int) 0, (int) 3 ); __DEBUG__NORMAL__ printf( "Updated beat_frequency_index: %u\n", state.beat_frequency_index ); break; case AudioBitEncodings::pitch: state.pitch_index += control_bit.toggle_value; range( state.pitch_index, (int) 21, (int) 68 ); __DEBUG__NORMAL__ printf( "Updated pitch_index: %u\n", state.pitch_index ); break; } if ( timer_enabled ) ++timer_counter; if ( timer_counter == timer_max ) timer_enabled = false; if ( !has_previous_state ) return 0; // commit reached if ( do_commit ) { // our counter now contains the number of cycles for which we should play silence if ( counting_silence ) { result = 2; last_note_duration = timer_counter; __DEBUG__NORMAL__ printf( "We should play silence for %u cycles\n", last_note_duration ); } // we interrupted playback of the previous note; our counter shows how many cycles we should play it for else { result = 1; last_note_duration = timer_counter; __DEBUG__NORMAL__ printf( "Note interrupted. We should play sound for %u cycles\n", last_note_duration ); } // start a timer to count the number of cycles the current note is active startTimer( getDuration( state.duration_index ) ); } // we timed out, store how long we were playing the note for and start tracking how long we should play silence else if ( !timer_enabled ) { result = 1; counting_silence = true; last_note_duration = timer_counter; __DEBUG__NORMAL__ printf( "Note finished playing normally. We should play sound for %u cycles\n", last_note_duration ); startTimer(); } return result; }
::Spacy::Vector C1Operator::d1( const ::Spacy::Vector& x, const ::Spacy::Vector& dx ) const { return Vector( derivative_( cast_ref< Vector >( x ).get() ) * cast_ref< Vector >( dx ).get(), range() ); }