Qt::Orientations SmartVerticalFlowLayout::expandingDirections() const { if (alignment() == 0 || (alignment() == Qt::AlignJustify)) return Qt::Horizontal; return 0; }
/* * gst_registry_binary_write_chunk: * * Write from a memory location to the registry cache file * * Returns: %TRUE for success */ inline static gboolean gst_registry_binary_write_chunk (BinaryRegistryCache * cache, GstRegistryChunk * chunk, unsigned long *file_position) { gchar padder[ALIGNMENT] = { 0, }; int padsize = 0; /* Padding to insert the struct that requiere word alignment */ if ((chunk->align) && (alignment (*file_position) != 0)) { padsize = ALIGNMENT - alignment (*file_position); if (gst_registry_binary_cache_write (cache, *file_position, padder, padsize) != padsize) { GST_ERROR ("Failed to write binary registry padder"); return FALSE; } *file_position += padsize; } if (gst_registry_binary_cache_write (cache, *file_position, chunk->data, chunk->size) != chunk->size) { GST_ERROR ("Failed to write binary registry element"); return FALSE; } *file_position += chunk->size; return TRUE; }
void CaptionLabel::paintEvent( QPaintEvent* /* event */ ) { QRect r = contentsRect(); QPainter p( this ); p.setRenderHint( QPainter::TextAntialiasing ); p.setPen( Qt::black ); p.setBrush( Qt::black ); QTextOption to( alignment() ); p.setOpacity( 0.8 ); p.drawText( r.adjusted( 0, 0, 0, -8 ), text().toUpper(), to ); p.setOpacity( 0.15 ); if ( m_showCloseButton ) { to.setAlignment( alignment() | Qt::AlignRight ); p.setOpacity( 0.15 ); p.drawText( r.adjusted( 0, 0, 0, -8 ), tr( "Close" ).toUpper(), to ); } QRect playBar = r.adjusted( 0, r.height() - 2, 0, 0 ); playBar.setHeight( 2 ); p.drawRect( playBar ); }
Alignment Sampler::alignment_with_error(size_t length, double base_error, double indel_error) { size_t maxiter = 100; Alignment aln; if (base_error > 0 || indel_error > 0) { // sample a longer-than necessary alignment, then trim size_t iter = 0; while (iter++ < maxiter) { aln = mutate( alignment(length + 2 * ((double) length * indel_error)), base_error, indel_error); if (aln.sequence().size() == length) { break; } else if (aln.sequence().size() > length) { aln = strip_from_end(aln, aln.sequence().size() - length); break; } } if (iter == maxiter) { cerr << "[vg::Sampler] Warning: could not generate alignment of sufficient length. " << "Graph may be too small, or indel rate too high." << endl; } } else { aln = alignment(length); } aln.set_identity(identity(aln.path())); return aln; }
int HGLayout::insertItem(QGraphicsLayoutItem* item, const HLayoutConfig& conf) { if (!layout()) return -1; switch (layoutType()) { case HEnums::kVBox: case HEnums::kHBox: { QGraphicsLinearLayout* l = static_cast<QGraphicsLinearLayout*>(layout()); l->insertItem(conf.index(),item); l->setAlignment(item,alignment()); break; } case HEnums::kGrid: { QGraphicsGridLayout* l = static_cast<QGraphicsGridLayout*>(layout()); l->addItem(item,conf.row(),conf.column(),alignment()); break; } case HEnums::kAnchor: { //anchor layout can't add item here, add item in setAnchor QGraphicsAnchorLayout* l = static_cast<QGraphicsAnchorLayout*>(layout()); Q_UNUSED(l); return -1; } default: return -1; } return 0; }
/////////////////////////////////////////////////////////////////////////////// // validateRowSizeInBytes - compute image row size, measured in bytes /////////////////////////////////////////////////////////////////////////////// GLsizei Image::validateRowSizeInBytes() { _rowSizeInBytes = (width() * pixelSizeInBytes() + alignment() - 1) & ~(alignment() - 1); validate(vbRowSizeInBytes); return _rowSizeInBytes; } // Image::calcRowSizeInBytes
int MSToggleButtonBase::computePixmapYCoord(const MSPixmap *pmap_) { int offset=highlightThickness()+shadowThickness()+margin(); int r; if (alignment()&MSTop) r=offset; else if (alignment()&MSBottom) r=height()-offset-pmap_->height(); else r=(height()-pmap_->height())/2; return r; }
Qt::AlignmentFlag LegendItem::getHorPos() const { if(alignment().testFlag(Qt::AlignHCenter)){ return Qt::AlignHCenter; } if(alignment().testFlag(Qt::AlignLeft)){ return Qt::AlignLeft; } return Qt::AlignRight; }
Qt::AlignmentFlag LegendItem::getVerPos() const { if(alignment().testFlag(Qt::AlignVCenter)){ return Qt::AlignVCenter; } if(alignment().testFlag(Qt::AlignTop)){ return Qt::AlignTop; } return Qt::AlignBottom; }
void seissol::checkpoint::posix::Wavefield::write(double time, int timestepWaveField) { EPIK_TRACER("CheckPoint_write"); SCOREP_USER_REGION("CheckPoint_write", SCOREP_USER_REGION_TYPE_FUNCTION); logInfo(rank()) << "Checkpoint backend: Writing."; // Start at the beginning checkErr(lseek64(file(), 0, SEEK_SET)); // Write the header EPIK_USER_REG(r_write_header, "checkpoint_write_header"); SCOREP_USER_REGION_DEFINE(r_write_header); EPIK_USER_START(r_write_header); SCOREP_USER_REGION_BEGIN(r_write_header, "checkpoint_write_header", SCOREP_USER_REGION_TYPE_COMMON); WavefieldHeader header; header.time = time; header.timestepWaveField = timestepWaveField; writeHeader(file(), header); EPIK_USER_END(r_write_header); SCOREP_USER_REGION_END(r_write_header); // Save data EPIK_USER_REG(r_write_wavefield, "checkpoint_write_wavefield"); SCOREP_USER_REGION_DEFINE(r_write_wavefield); EPIK_USER_START(r_write_wavefield); SCOREP_USER_REGION_BEGIN(r_write_wavefield, "checkpoint_write_wavefield", SCOREP_USER_REGION_TYPE_COMMON); // Convert to char* to do pointer arithmetic const char* buffer = reinterpret_cast<const char*>(dofs()); unsigned long left = numDofs()*sizeof(real); if (alignment()) { left = (left + alignment() - 1) / alignment(); left *= alignment(); } while (left > 0) { unsigned long written = ::write(file(), buffer, left); if (written <= 0) checkErr(written, left); buffer += written; left -= written; } EPIK_USER_END(r_write_wavefield); SCOREP_USER_REGION_END(r_write_wavefield); // Finalize the checkpoint finalizeCheckpoint(); logInfo(rank()) << "Checkpoint backend: Writing. Done."; }
int MSToggleButtonBase::computePixmapXCoord(const MSPixmap *pmap_) { int offset=highlightThickness()+shadowThickness()+margin(); int r; if (alignment()&MSLeft) r=offset+textHeight()+spacing(); else if (alignment()&MSRight) r=width()-offset-pmap_->width(); else { int leftOffset=highlightThickness()+shadowThickness()+margin()+textHeight()+spacing(); r=(width()-leftOffset-pmap_->width())/2+leftOffset; } return r; }
/*! \reimp */ QSize QBoxLayout::maximumSize() const { Q_D(const QBoxLayout); if (d->dirty) const_cast<QBoxLayout*>(this)->d_func()->setupGeom(); QSize s = d->maxSize.boundedTo(QSize(QLAYOUTSIZE_MAX, QLAYOUTSIZE_MAX)); if (alignment() & Qt::AlignHorizontal_Mask) s.setWidth(QLAYOUTSIZE_MAX); if (alignment() & Qt::AlignVertical_Mask) s.setHeight(QLAYOUTSIZE_MAX); return s; }
void test_alignment() { xlnt::workbook wb; auto ws = wb.active_sheet(); auto cell = ws.cell("A1"); xlnt::alignment align; align.wrap(true); cell.alignment(align); xlnt_assert(cell.has_format()); xlnt_assert(cell.format().alignment_applied()); xlnt_assert_equals(cell.alignment(), align); }
void TextInput::paintEvent(QPaintEvent* event) { QLineEdit::paintEvent(event); if (!d.hint.isEmpty()) { QStyleOptionFrameV2 option; initStyleOption(&option); QRect r = style()->subElementRect(QStyle::SE_LineEditContents, &option, this); int left, top, right, bottom; getTextMargins(&left, &top, &right, &bottom); left += qMax(0, -fontMetrics().minLeftBearing()); r.adjust(left, top, -right, -bottom); r.adjust(hMargin, vMargin, -hMargin, -vMargin); QString txt = text(); if (!txt.isEmpty()) { if (!txt.endsWith(" ")) txt += " "; r.adjust(fontMetrics().width(txt), 0, 0, 0); } QPainter painter(this); QColor color = palette().text().color(); color.setAlpha(128); painter.setPen(color); QString hint = fontMetrics().elidedText(d.hint, Qt::ElideRight, r.width()); painter.drawText(r, alignment(), hint); } }
int alignment(TYP *tp) { //printf("DIAG: type NULL in alignment()\r\n"); if (tp==NULL) return AL_BYTE; switch(tp->type) { case bt_byte: case bt_ubyte: return AL_BYTE; case bt_char: case bt_uchar: return AL_CHAR; case bt_short: case bt_ushort: return AL_SHORT; case bt_long: case bt_ulong: return AL_LONG; case bt_enum: return AL_CHAR; case bt_pointer: if(tp->val_flag) return alignment(tp->btp); else return AL_POINTER; case bt_float: return AL_FLOAT; case bt_double: return AL_DOUBLE; case bt_triple: return AL_TRIPLE; case bt_struct: case bt_union: return (tp->alignment) ? tp->alignment : AL_STRUCT; default: return AL_CHAR; } }
bool PSVirtualSpace::expand_by(size_t bytes, bool pre_touch) { assert(is_aligned(bytes), "arg not aligned"); DEBUG_ONLY(PSVirtualSpaceVerifier this_verifier(this)); if (uncommitted_size() < bytes) { return false; } char* const base_addr = committed_high_addr(); bool result=os::commit_memory(_account,base_addr,bytes,alignment(),Modules::ParGC_PSVirtualSpace); if (result) { _committed_high_addr += bytes; } if (pre_touch || AlwaysPreTouch) { for (char* curr = base_addr; curr < _committed_high_addr; curr += os::vm_page_size()) { char tmp = *curr; *curr = 0; } } return result; }
double MatchingService::getSongQuality(const QByteArray &pitchAlignment, char transposition) { QString alignment(pitchAlignment); int firstHitChord = alignment.replace(QRegExp("[mwi]"), ".").indexOf("."); int lastHitChord = alignment.replace(QRegExp("[mwi]"), ".").lastIndexOf("."); int open = pitchAlignment.count(NeedlemanWunsch::OPEN); int played = pitchAlignment.count(NeedlemanWunsch::MATCH); //int missed = pitchAlignment.count(NeedlemanWunsch::DELETED); int extra = pitchAlignment.count(NeedlemanWunsch::INSERT); int wrong = pitchAlignment.count(NeedlemanWunsch::WRONG); double rangeFactor = (double)(played+wrong+extra)/(double)(lastHitChord - firstHitChord + 1); double progressFactor = (double)(played+wrong)/(double)(played+wrong+extra+open); double matchFactor = (double)(played)/(double)(played+wrong+extra); double transpositionFactor; if (transposition >= 0) { transpositionFactor = 1.0 - transposition/1100.0; } else { transpositionFactor = 0.99 + transposition/1100.0; } double quality = rangeFactor*matchFactor*MAX2(0.9, progressFactor)*transpositionFactor; if (std::isinf(quality) || std::isnan(quality)) { return 0.0; } else { return quality; } }
void require_new_page() { int m = alignment(); int size = int( page_provider_.page_size() / m * m ); page_header* new_page; if( unused_pages_ ) { // 1枚はがして持ってくる new_page = unused_pages_; unused_pages_ = new_page->next; } else { // 新たに割り当てる new_page = (page_header*)page_provider_.allocate( size ); #if 0 dprintf_real( "new_page: %s\n", name_.c_str() ); #endif } // 先頭に前のページへのポインタを埋め込む new_page->next = pages_head_; pages_head_ = new_page; unformated_beginning_ = ( ( char* )new_page ) + sizeof( page_header ); unformated_end_ = ( ( char* )new_page ) + size; }
void pLineEdit::paintEvent( QPaintEvent* event ) { QLineEdit::paintEvent( event ); if ( !mPromptText.isEmpty() && text().isEmpty() && isEnabled() ) { QStyleOptionFrameV3 option; initStyleOption( &option ); int left; int top; int right; int bottom; getTextMargins( &left, &top, &right, &bottom ); const Qt::Alignment va = style()->visualAlignment( layoutDirection(), alignment() ); const QRect rect = style()->subElementRect( QStyle::SE_LineEditContents, &option, this ).adjusted( 2, 0, 0, 0 ).adjusted( left, top, -right, -bottom ); const QFontMetrics fm( font() ); const QString text = fm.elidedText( mPromptText, Qt::ElideRight, rect.width() ); QPainter painter( this ); painter.setPen( palette().color( QPalette::Disabled, QPalette::Text ) ); painter.drawText( rect, va, text ); } }
/*! Draws the baseline of the scale \param painter Painter \sa drawTick(), drawLabel() */ void QwtScaleDraw::drawBackbone(QPainter *painter) const { const int bw2 = painter->pen().width() / 2; const QPoint &pos = d_data->pos; const int len = d_data->len - 1; switch(alignment()) { case LeftScale: QwtPainter::drawLine(painter, pos.x() - bw2, pos.y(), pos.x() - bw2, pos.y() + len ); break; case RightScale: QwtPainter::drawLine(painter, pos.x() + bw2, pos.y(), pos.x() + bw2, pos.y() + len); break; case TopScale: QwtPainter::drawLine(painter, pos.x(), pos.y() - bw2, pos.x() + len, pos.y() - bw2); break; case BottomScale: QwtPainter::drawLine(painter, pos.x(), pos.y() + bw2, pos.x() + len, pos.y() + bw2); break; } }
void moveBoid(const goalContainer * const goals, boidContainer * boidlist, int index){ directionVector exitVec, cohVec, alignVec, averVec, acceleration; int i; acceleration.x = 0; acceleration.y = 0; //Could possibly make these all execute in parallel as well exitVec = moveToExit(goals, boidlist, index); cohVec = cohesion(boidlist, index); alignVec = alignment(boidlist, index); averVec = aversion(boidlist, index); //Add up vectors with weights addVector(&acceleration, &exitVec, 3); addVector(&acceleration, &cohVec, 1); addVector(&acceleration, &alignVec, 1); addVector(&acceleration, &averVec, 2); //Limit the vector to required speed limitVec(&acceleration); boidlist->boidArr[index].velocity = acceleration; boidlist->boidArr[index].xpos += acceleration.x; boidlist->boidArr[index].ypos += acceleration.y; for(i = 0; i < goals->size; i++){ if(boidlist->boidArr[index].xpos == goals->pos[i][0] && boidlist->boidArr[index].ypos == goals->pos[i][1]){ boidlist->boidArr[index].active = 0; } } }
void KexiDBLabel::paintEvent(QPaintEvent* e) { QPainter p(this); KexiDBTextWidgetInterface::paint(this, &p, text().isEmpty(), alignment(), false); p.end(); QPalette origPal; if (editingMode()) { origPal = palette(); QPalette pal(palette()); pal.setBrush(QPalette::WindowText, Qt::transparent); setPalette(pal); } QLabel::paintEvent(e); if (editingMode()) { setPalette(origPal); } const bool hasFrame = frameWidth() >= 1 && frameShape() != QFrame::NoFrame; if (designMode() && !hasFrame) { p.begin(this); KFormDesigner::paintWidgetFrame(p, rect()); p.end(); } }
/* * Smith-Waterman: devuelve el alineamiento local entre dos secuencias. * Implementar la versión "affine gap penalty (tablas E, F y H)" * smatrix: matriz de sustitución * gap_open: penalidad de abrir una brecha (casi siempre es 10) * gap_extend: penalidad de extender una brecha (casi siempre es 1 en * enteros y 0.5 si se trabaja con float) */ Alignment smith_waterman(Sequence seq1, Sequence seq2, int* smatrix, int gap_open, int gap_extend) { std::string str1 = seq1.value(); std::string str2 = seq2.value(); int m = str1.size() + 1; int n = str1.size() + 1; int* E = new int[m * n]; int* F = new int[m * n]; int* H = new int[m * n]; //TODO: inicializar matrices int max_i, max_j, max_score; sw(str1, str2, E, F, H, smatrix, gap_open, gap_extend, &max_i, &max_j, &max_score); char* aln1 = new char[1000]; //fijar un límite conveniente char* aln2 = new char[1000]; //fijar un límite conveniente int i_0, j_0; //posiciones donde empiezan los alineamientos sw_backtrack(str1, str2, E, F, H, smatrix, gap_open, gap_extend, &i_0, &j_0, max_i, max_j, aln1, aln2); //incluimos la información generada en pasos anteriores Alignment alignment(seq1, seq2, aln1, aln2, i_0, j_0, max_i, max_j, max_score); return alignment; }
QRect QwtPlainText::boundingRect(QPainter *painter) const { const QwtLayoutMetrics metrics(QwtPainter::metricsMap()); if (painter) { painter->save(); painter->setFont(font()); const QRect rect = metrics.boundingRect(text(), alignment(), painter); painter->restore(); return rect; } return metrics.boundingRect(text(), alignment(), fontMetrics()); }
/*! \brief Draw the text in a clipping rectangle \param painter Painter \param rect Clipping rectangle */ void QwtRichText::draw(QPainter *painter, const QRect &rect) const { painter->save(); painter->setPen(rectPen()); painter->setBrush(rectBrush()); QwtPainter::drawRect(painter, rect); painter->restore(); painter->save(); painter->setPen(color()); #if QT_VERSION < 300 const QFont defaultFont = QFont::defaultFont(); QFont::setDefaultFont(font()); #else painter->setFont(font()); #endif QwtPainter::drawSimpleRichText(painter, rect, alignment(), *d_doc); #if QT_VERSION < 300 QFont::setDefaultFont(defaultFont); #endif painter->restore(); }
//! Set the text void QwtRichText::setText(const QString &text) { QwtText::setText(text); delete d_doc; d_doc = new QSimpleRichText(taggedText(text, alignment()), font()); }
size_t PSVirtualSpaceHighToLow::expand_into(PSVirtualSpace* other_space, size_t bytes) { assert(is_aligned(bytes), "arg not aligned"); assert(grows_down(), "this space must grow down"); assert(other_space->grows_up(), "other space must grow up"); assert(reserved_low_addr() == other_space->reserved_high_addr(), "spaces not contiguous"); assert(special() == other_space->special(), "one space is special in memory, the other is not"); DEBUG_ONLY(PSVirtualSpaceVerifier this_verifier(this)); DEBUG_ONLY(PSVirtualSpaceVerifier other_verifier(other_space)); size_t bytes_needed = bytes; // First use the uncommitted region in this space. size_t tmp_bytes = MIN2(uncommitted_size(), bytes_needed); if (tmp_bytes > 0) { if (expand_by(tmp_bytes)) { bytes_needed -= tmp_bytes; } else { return 0; } } // Next take from the uncommitted region in the other space, and commit it. tmp_bytes = MIN2(other_space->uncommitted_size(), bytes_needed); if (tmp_bytes > 0) { char* const commit_base = committed_low_addr() - tmp_bytes; if (other_space->special() || os::commit_memory(commit_base, tmp_bytes, alignment(), !ExecMem)) { // Reduce the reserved region in the other space. other_space->set_reserved(other_space->reserved_low_addr(), other_space->reserved_high_addr() - tmp_bytes, other_space->special()); // Grow both reserved and committed in this space. _reserved_low_addr -= tmp_bytes; _committed_low_addr -= tmp_bytes; bytes_needed -= tmp_bytes; } else { return bytes - bytes_needed; } } // Finally take from the already committed region in the other space. tmp_bytes = bytes_needed; if (tmp_bytes > 0) { // Reduce both committed and reserved in the other space. other_space->set_committed(other_space->committed_low_addr(), other_space->committed_high_addr() - tmp_bytes); other_space->set_reserved(other_space->reserved_low_addr(), other_space->reserved_high_addr() - tmp_bytes, other_space->special()); // Grow both reserved and committed in this space. _reserved_low_addr -= tmp_bytes; _committed_low_addr -= tmp_bytes; } return bytes; }
CurveTree::CurveTree(const Arguments& arguments) : TreeType(AlignedAllocator<void>(System::get_l1_data_cache_line_size())) , m_arguments(arguments) { // Retrieve construction parameters. const MessageContext message_context( format("while building curve tree for assembly \"{0}\"", m_arguments.m_assembly.get_path())); const ParamArray& params = m_arguments.m_assembly.get_parameters().child("acceleration_structure"); const string algorithm = params.get_optional<string>("algorithm", "bvh", make_vector("bvh", "sbvh"), message_context); const double time = params.get_optional<double>("time", 0.5); // Start stopwatch. Stopwatch<DefaultWallclockTimer> stopwatch; stopwatch.start(); // Build the tree. Statistics statistics; if (algorithm == "bvh") build_bvh(params, time, statistics); else throw ExceptionNotImplemented(); // Print curve tree statistics. statistics.insert_size("nodes alignment", alignment(&m_nodes[0])); statistics.insert_time("total time", stopwatch.measure().get_seconds()); RENDERER_LOG_DEBUG("%s", StatisticsVector::make( "curve tree #" + to_string(m_arguments.m_curve_tree_uid) + " statistics", statistics).to_string().c_str()); }
void QElidingLabel::paintEvent( QPaintEvent * ) { QPainter p( this ); int space = frameWidth() + margin(); QRect r = rect().adjusted( space, space, -space, -space ); p.drawText( r, fontMetrics().elidedText( text(), elideMode, r.width() ), alignment() ); }
QRect QLayout::alignmentRect( const QRect &r ) const { QSize s = sizeHint(); int a = alignment(); if ( expanding() & QSizePolicy::Horizontal || !(a & HorAlign ) ) { s.setWidth( r.width() ); } if ( expanding() & QSizePolicy::Vertical || !(a & VerAlign )) { s.setHeight( r.height() ); } else if ( hasHeightForWidth() ) { s.setHeight( QMIN( s.height(), heightForWidth(s.width()) ) ); } int x = r.x(); int y = r.y(); if ( a & Qt::AlignRight ) x = x + ( r.width() - s.width() ); else if ( !(a & Qt::AlignLeft) ) x = x + ( r.width() - s.width() ) / 2; if ( a & Qt::AlignBottom ) y = y + ( r.height() - s.height() ); else if ( !(a & Qt::AlignTop) ) y = y + ( r.height() - s.height() ) / 2; return QRect( x, y, s.width(), s.height() ); }