DiskLoc MmapV1ExtentManager::_createExtent( OperationContext* txn, int size, bool enforceQuota ) { size = quantizeExtentSize( size ); if ( size > maxSize() ) size = maxSize(); verify( size < DataFile::maxSize() ); for ( int i = numFiles() - 1; i >= 0; i-- ) { DataFile* f = _getOpenFile(i); invariant(f); if ( f->getHeader()->unusedLength >= size ) { return _createExtentInFile( txn, i, f, size, enforceQuota ); } } _checkQuota( enforceQuota, numFiles() ); // no space in an existing file // allocate files until we either get one big enough or hit maxSize for ( int i = 0; i < 8; i++ ) { DataFile* f = _addAFile( txn, size, false ); if ( f->getHeader()->unusedLength >= size ) { return _createExtentInFile( txn, numFiles() - 1, f, size, enforceQuota ); } } // callers don't check for null return code, so assert msgasserted(14810, "couldn't allocate space for a new extent" ); }
int GomokuCore::judge() { if (maxSize(&this->board[0][0], GO_SIZE, GO_SIZE, '*') == 5) return 1; else if (maxSize(&this->board[0][0], GO_SIZE, GO_SIZE, '#') == 5) return 2; return 0; }
void Set_List::add(int item) { assert(item < maxSize()); if(!contains(item)) { assert(_numItems < maxSize()); Mapping::setMap(_numItems, item); _numItems++; } }
void PopupWindow::onPreferredSize(PreferredSizeEvent& ev) { ScreenGraphics g; g.setFont(getFont()); Size resultSize(0, 0); if (hasText()) resultSize = g.fitString(getText(), (getClientBounds() - getBorder()).w, getAlign()); resultSize.w += border_width.l + border_width.r; resultSize.h += border_width.t + border_width.b; if (!getChildren().empty()) { Size maxSize(0, 0); Size reqSize; UI_FOREACH_WIDGET(getChildren(), it) { Widget* child = *it; reqSize = child->getPreferredSize(); maxSize.w = MAX(maxSize.w, reqSize.w); maxSize.h = MAX(maxSize.h, reqSize.h); }
void LocalStack::finalize() { m_sp->setArgOperand(2, m_builder.getInt64(minSize())); m_sp->setArgOperand(3, m_builder.getInt64(maxSize())); m_sp->setArgOperand(4, m_builder.getInt64(size())); if (auto term = m_builder.GetInsertBlock()->getTerminator()) m_builder.SetInsertPoint(term); // Insert before terminator auto inputIt = m_input.rbegin(); auto localIt = m_local.begin(); for (auto globalIdx = -static_cast<ssize_t>(m_input.size()); globalIdx < size(); ++globalIdx) { llvm::Value* item = nullptr; if (globalIdx < -m_globalPops) { item = *inputIt++; // update input items (might contain original value) if (!item) // some items are skipped continue; } else item = *localIt++; // store new items auto slot = m_builder.CreateConstGEP1_64(m_sp, globalIdx); m_builder.CreateAlignedStore(item, slot, 16); // TODO: Handle malloc alignment. Also for 32-bit systems. } }
/** * @brief Reload smileys and size information. */ void UserInterfaceForm::reloadSmileys() { QList<QStringList> emoticons = SmileyPack::getInstance().getEmoticons(); // sometimes there are no emoticons available, don't crash in this case if (emoticons.isEmpty()) { qDebug() << "reloadSmilies: No emoticons found"; return; } QStringList smileys; for (int i = 0; i < emoticons.size(); ++i) smileys.push_front(emoticons.at(i).first()); const QSize size(18, 18); for (int i = 0; i < smileLabels.size(); ++i) { QIcon icon = SmileyPack::getInstance().getAsIcon(smileys[i]); smileLabels[i]->setPixmap(icon.pixmap(size)); smileLabels[i]->setToolTip(smileys[i]); } // set maximum size of emoji QDesktopWidget desktop; // 8 is the count of row and column in emoji's in widget const int sideSize = 8; int maxSide = qMin(desktop.geometry().height() / sideSize, desktop.geometry().width() / sideSize); QSize maxSize(maxSide, maxSide); QIcon icon = SmileyPack::getInstance().getAsIcon(smileys[0]); QSize actualSize = icon.actualSize(maxSize); bodyUI->emoticonSize->setMaximum(actualSize.width()); }
void Window::onPreferredSize(PreferredSizeEvent& ev) { Widget* manager = getManager(); if (m_isDesktop) { Rect cpos = manager->getChildrenBounds(); ev.setPreferredSize(cpos.w, cpos.h); } else { Size maxSize(0, 0); Size reqSize; UI_FOREACH_WIDGET(getChildren(), it) { Widget* child = *it; if (!child->isDecorative()) { reqSize = child->getPreferredSize(); maxSize.w = MAX(maxSize.w, reqSize.w); maxSize.h = MAX(maxSize.h, reqSize.h); } } if (hasText()) maxSize.w = MAX(maxSize.w, jwidget_get_text_length(this)); ev.setPreferredSize(this->border_width.l + maxSize.w + this->border_width.r, this->border_width.t + maxSize.h + this->border_width.b); }
DiskLoc MmapV1ExtentManager::_createExtentInFile( TransactionExperiment* txn, int fileNo, DataFile* f, int size, int maxFileNoForQuota ) { size = MmapV1ExtentManager::quantizeExtentSize( size ); if ( maxFileNoForQuota > 0 && fileNo - 1 >= maxFileNoForQuota ) { if ( cc().hasWrittenSinceCheckpoint() ) { warning() << "quota exceeded, but can't assert" << endl; } else { _quotaExceeded(); } } massert( 10358, "bad new extent size", size >= minSize() && size <= maxSize() ); DiskLoc loc = f->allocExtentArea( txn, size ); loc.assertOk(); Extent *e = getExtent( loc, false ); verify( e ); *txn->writing(&e->magic) = Extent::extentSignature; *txn->writing(&e->myLoc) = loc; *txn->writing(&e->length) = size; return loc; }
int ExtentManager::initialSize( int len ) const { invariant( len <= maxSize() ); long long sz = len * 16; if ( len < 1000 ) sz = len * 64; if ( sz >= maxSize() ) return maxSize(); if ( sz <= minSize() ) return minSize(); int z = ExtentManager::quantizeExtentSize( sz ); verify( z >= len ); return z; }
void PageCache::prune(PruningReason pruningReason) { while (pageCount() > maxSize()) { auto oldestItem = m_items.takeFirst(); oldestItem->m_cachedPage = nullptr; oldestItem->m_pruningReason = pruningReason; } }
// MaxSize BSize ColorField::MaxSize() { BSize maxSize(4 + MAX_X, 4 + MAX_Y); return BLayoutUtils::ComposeSize(ExplicitMaxSize(), maxSize); // return BLayoutUtils::ComposeSize(ExplicitMaxSize(), // BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED)); }
void Separator::onPreferredSize(PreferredSizeEvent& ev) { Size maxSize(0, 0); UI_FOREACH_WIDGET(getChildren(), it) { Widget* child = *it; Size reqSize = child->getPreferredSize(); maxSize.w = MAX(maxSize.w, reqSize.w); maxSize.h = MAX(maxSize.h, reqSize.h); }
rSize Face::MeasureString(const rString& text){ rSize maxSize(INT_MAX, INT_MAX); rSize measuredSize(0, 0); Font::WrapText(this, text, maxSize, [&](Font::Glyph** glyphs, size_t glyphCount, int startX, int startY){ MeasureWord(glyphs, glyphCount, measuredSize, startX, startY); }); return measuredSize; }
std::vector<std::string::size_type> generateMaxLengthList() const { std::vector<std::string::size_type> list(maxSize()); for (auto& raw : table_) { int index = 0; for (auto& column : raw) { list[index] = std::max(list[index], column.length()); index++; } } return list; }
int ExtentManager::followupSize(int len, int lastExtentLen) const { invariant(len < maxSize()); int x = initialSize(len); // changed from 1.20 to 1.35 in v2.1.x to get to larger extent size faster int y = (int)(lastExtentLen < 4000000 ? lastExtentLen * 4.0 : lastExtentLen * 1.35); int sz = y > x ? y : x; if (sz < lastExtentLen) { // this means there was an int overflow // so we should turn it into maxSize return maxSize(); } else if (sz > maxSize()) { return maxSize(); } sz = quantizeExtentSize(sz); verify(sz >= len); return sz; }
BSONObj ShardType::toBSON() const { BSONObjBuilder builder; if (_name) builder.append(name(), getName()); if (_host) builder.append(host(), getHost()); if (_draining) builder.append(draining(), getDraining()); if (_maxSize) builder.append(maxSize(), getMaxSize()); if (_tags) builder.append(tags(), getTags()); return builder.obj(); }
int ExtentManager::quantizeExtentSize(int size) const { if (size == maxSize()) { // no point doing quantizing for the entire file return size; } invariant(size <= maxSize()); // make sizes align with VM page size int newSize = (size + 0xfff) & 0xfffff000; if (newSize > maxSize()) { return maxSize(); } if (newSize < minSize()) { return minSize(); } return newSize; }
/** @function detectAndDisplay */ vector<PlateRegion> RegionDetector::doCascade(Mat frame) { //float scale_factor = 1; int w = frame.size().width; int h = frame.size().height; vector<Rect> plates; equalizeHist( frame, frame ); resize(frame, frame, Size(w * this->scale_factor, h * this->scale_factor)); //-- Detect plates timespec startTime; getTime(&startTime); Size minSize(config->minPlateSizeWidthPx * this->scale_factor, config->minPlateSizeHeightPx * this->scale_factor); Size maxSize(w * config->maxPlateWidthPercent * this->scale_factor, h * config->maxPlateHeightPercent * this->scale_factor); if (config->opencl_enabled) { ocl::oclMat openclFrame(frame); ((ocl::OclCascadeClassifier*) plate_cascade)->detectMultiScale(openclFrame, plates, config->detection_iteration_increase, 3, 0, minSize, maxSize); } else { plate_cascade->detectMultiScale( frame, plates, config->detection_iteration_increase, 3, 0, //0|CV_HAAR_SCALE_IMAGE, minSize, maxSize ); } if (config->debugTiming) { timespec endTime; getTime(&endTime); cout << "LBP Time: " << diffclock(startTime, endTime) << "ms." << endl; } for( int i = 0; i < plates.size(); i++ ) { plates[i].x = plates[i].x / scale_factor; plates[i].y = plates[i].y / scale_factor; plates[i].width = plates[i].width / scale_factor; plates[i].height = plates[i].height / scale_factor; } vector<PlateRegion> orderedRegions = aggregateRegions(plates); return orderedRegions; }
void updateMinMaxSizes() { QSizeDimension dimension = oppositeDimension(); int scrollBarSize = (scrollBar()->sizeHint().*dimension)(); QSize minSize(0, mRowCount * 48 + scrollBarSize); QSize maxSize(QWIDGETSIZE_MAX, mRowCount * 256 + scrollBarSize); if (mOrientation == Qt::Vertical) { minSize.transpose(); maxSize.transpose(); } q->setMinimumSize(minSize); q->setMaximumSize(maxSize); }
DiskLoc MmapV1ExtentManager::_createExtent( TransactionExperiment* txn, int size, int maxFileNoForQuota ) { size = quantizeExtentSize( size ); if ( size > maxSize() ) size = maxSize(); verify( size < DataFile::maxSize() ); for ( int i = numFiles() - 1; i >= 0; i-- ) { DataFile* f = getFile( txn, i ); if ( f->getHeader()->unusedLength >= size ) { return _createExtentInFile( txn, i, f, size, maxFileNoForQuota ); } } if ( maxFileNoForQuota > 0 && static_cast<int>( numFiles() ) >= maxFileNoForQuota && !cc().hasWrittenSinceCheckpoint() ) { _quotaExceeded(); } // no space in an existing file // allocate files until we either get one big enough or hit maxSize for ( int i = 0; i < 8; i++ ) { DataFile* f = _addAFile( txn, size, false ); if ( f->getHeader()->unusedLength >= size ) { return _createExtentInFile( txn, numFiles() - 1, f, size, maxFileNoForQuota ); } } // callers don't check for null return code, so assert msgasserted(14810, "couldn't allocate space for a new extent" ); }
int main(int argc, char *argv[]) { if (argc != 6) { std::cerr << "Usage: " << argv[0] << " deploy.prototxt network.caffemodel" << " mean.binaryproto labels.txt img.jpg" << std::endl; return 1; } ::google::InitGoogleLogging(argv[0]); std::string model_file = argv[1]; std::string trained_file = argv[2]; std::string mean_file = argv[3]; std::string label_file = argv[4]; //CaffeClassifier <cv::Mat> classifier(model_file, trained_file, mean_file, label_file, 64 ); std::string file = argv[5]; cv::Mat inputImg = cv::imread(file, -1); CHECK(!inputImg.empty()) << "Unable to decode image " << file; // min and max size of object we're looking for. The input // image will be scaled so that these min and max sizes // line up with the classifier input size. Other scales will // fill in the range between those two end points. cv::Size minSize(100,100); cv::Size maxSize(700,700); std::vector<cv::Rect> rectsOut; detectMultiscale<cv::gpu::GpuMat>(model_file, trained_file, mean_file, label_file, inputImg, minSize, maxSize, rectsOut); #if 1 namedWindow("Image", cv::WINDOW_AUTOSIZE); for (std::vector<cv::Rect>::const_iterator it = rectsOut.begin(); it != rectsOut.end(); ++it) { std::cout << *it << std::endl; rectangle(inputImg, *it, cv::Scalar(0,0,255)); } //std::vector<cv::Rect> filteredRects; /*fastNMS(detected, 0.4f, filteredRects); for (std::vector<cv::Rect>::const_iterator it = filteredRects.begin(); it != filteredRects.end(); ++it) { std::cout << *it << std::endl; rectangle(inputImg, *it, cv::Scalar(0,255,255)); }*/ imshow("Image", inputImg); imwrite("detect.png", inputImg); cv::waitKey(0); #endif return 0; }
void MultiLayer::printAllLayers(QPainter *painter) { if (!painter) return; QPaintDeviceMetrics metrics(painter->device()); int dpiy = metrics.logicalDpiY(); int margin = (int) ( (1/2.54)*dpiy ); // 1 cm margins QSize size=maxSize(); double scaleFactorX=(double)(metrics.width()-2*margin)/(double)size.width(); double scaleFactorY=(double)(metrics.height()-2*margin)/(double)size.height(); for (int i=0; i<(int)graphsList->count(); i++) { Graph *gr=(Graph *)graphsList->at(i); Plot *myPlot= gr->plotWidget(); PrintFilter filter(myPlot); filter.setOptions(QwtPlotPrintFilter::PrintAll | QwtPlotPrintFilter::PrintTitle | QwtPlotPrintFilter::PrintCanvasBackground); QPoint pos=gr->pos(); pos=QPoint(margin + int(pos.x()*scaleFactorX), margin + int(pos.y()*scaleFactorY)); int width=int(myPlot->frameGeometry().width()*scaleFactorX); int height=int(myPlot->frameGeometry().height()*scaleFactorY); QRect rect = QRect(pos,QSize(width,height)); if (myPlot->paletteBackgroundColor() != QColor(white)) painter->fillRect(rect, myPlot->paletteBackgroundColor()); int lw = myPlot->lineWidth(); if ( lw > 0) { myPlot->printFrame(painter, rect); rect.moveBy (lw, lw); rect.setWidth(rect.width() - 2*lw); rect.setHeight(rect.height() - 2*lw); } myPlot->print(painter, rect, filter); } if (hasOverlapingLayers()) updateTransparency(); }
nsSize nsBox::GetMaxSize(nsBoxLayoutState& aState) { NS_ASSERTION(aState.GetRenderingContext(), "must have rendering context"); nsSize maxSize(NS_INTRINSICSIZE, NS_INTRINSICSIZE); DISPLAY_MAX_SIZE(this, maxSize); if (IsCollapsed(aState)) return maxSize; AddBorderAndPadding(maxSize); nsIBox::AddCSSMaxSize(aState, this, maxSize); return maxSize; }
bool ZLQtDialog::run() { QSize maxSize(0, 0); for (std::vector<QButton*>::const_iterator it = myButtons.begin(); it != myButtons.end(); ++it) { QSize buttonSize = (*it)->sizeHint(); maxSize = QSize( std::max(maxSize.width(), buttonSize.width()), std::max(maxSize.height(), buttonSize.height()) ); } for (std::vector<QButton*>::iterator it = myButtons.begin(); it != myButtons.end(); ++it) { (*it)->setFixedSize(maxSize); } ((ZLQtDialogContent*)myTab)->close(); return exec(); }
vec2 Label::CalculateSize() { //Safety check that the font pointer is null if(m_Font == nullptr) { Error(false, "Unable to calculate the size of the Label, the font pointer is null"); return vec2(0.0f, 0.0f); } //Used to track the max width and height float x = 0.0f; vec2 maxSize(0.0f, m_Font->GetLineHeight()); //Clear the line width's vector m_LineWidth.clear(); //Cycle through all the characters in the text string for(unsigned int i = 0; i < m_Text.length(); i++) { //Did we reach a new line? if(m_Text.at(i) == '\n') { //Add the line width to the line widths vector m_LineWidth.push_back(x); //Calculate the max width and increment the max height maxSize.x = fmaxf(x, maxSize.x); maxSize.y += m_Font->GetLineHeight(); //Set x back to zero x = 0.0f; continue; } //Advance the x, by the x-advance of the character x += m_Font->GetAdvanceXForCharacter(m_Text.at(i)) + GetCharacterSpacing(); } //We are done, add the line width to the line widths vector m_LineWidth.push_back(x); //Calculate the max width maxSize.x = fmaxf(x, maxSize.x); //And return the max width and height return vec2(maxSize.x, maxSize.y); }
void LayoutRoot::layout() { m_frame->setDocument(m_document.get()); m_document->setFrame(m_frame.get()); LayoutUnit maxWidth = std::max(m_minWidth, m_maxWidth); LayoutUnit maxHeight = std::max(m_minHeight, m_maxHeight); IntSize maxSize(maxWidth, maxHeight); m_frame->view()->setFrameRect(IntRect(IntPoint(), maxSize)); m_frame->view()->setLayoutSize(maxSize); m_document->updateLayout(); m_document->setFrame(nullptr); m_frame->setDocument(nullptr); }
/** @function detectAndDisplay */ vector<Rect> RegionDetector::doCascade(Mat frame) { //float scale_factor = 1; int w = frame.size().width; int h = frame.size().height; vector<Rect> plates; equalizeHist( frame, frame ); resize(frame, frame, Size(w * this->scale_factor, h * this->scale_factor)); //-- Detect plates timespec startTime; getTime(&startTime); Size minSize(config->minPlateSizeWidthPx * this->scale_factor, config->minPlateSizeHeightPx * this->scale_factor); Size maxSize(w * config->maxPlateWidthPercent * this->scale_factor, h * config->maxPlateHeightPercent * this->scale_factor); plate_cascade.detectMultiScale( frame, plates, 1.1, 3, 0, //0|CV_HAAR_SCALE_IMAGE, minSize, maxSize ); if (config->debugTiming) { timespec endTime; getTime(&endTime); cout << "LBP Time: " << diffclock(startTime, endTime) << "ms." << endl; } for( int i = 0; i < plates.size(); i++ ) { plates[i].x = plates[i].x / scale_factor; plates[i].y = plates[i].y / scale_factor; plates[i].width = plates[i].width / scale_factor; plates[i].height = plates[i].height / scale_factor; } return plates; }
void paintEvent(QPaintEvent* event) { if(!image) return; painter.begin(this); const QRect& windowRect(painter.window()); QSizeF maxSize(windowRect.size()); maxSize *= scale; QSizeF size(image->size()); size -= QSizeF(offset.x(), offset.y()); if(size.width() > maxSize.width()) size.setWidth(maxSize.width()); if(size.height() > maxSize.height()) size.setHeight(maxSize.height()); painter.drawPixmap(QRectF(QPointF(0, 0), size / scale), *image, QRectF(offset, size)); painter.end(); }
DiskLoc MmapV1ExtentManager::_createExtentInFile( OperationContext* txn, int fileNo, DataFile* f, int size, bool enforceQuota) { _checkQuota(enforceQuota, fileNo - 1); massert(10358, "bad new extent size", size >= minSize() && size <= maxSize()); DiskLoc loc = f->allocExtentArea(txn, size); loc.assertOk(); Extent* e = getExtent(loc, false); verify(e); *txn->recoveryUnit()->writing(&e->magic) = Extent::extentSignature; *txn->recoveryUnit()->writing(&e->myLoc) = loc; *txn->recoveryUnit()->writing(&e->length) = size; return loc; }
QSizeF FlowLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const { QSizeF sh = constraint; switch (which) { case Qt::PreferredSize: sh = prefSize(); break; case Qt::MinimumSize: sh = minSize(constraint); break; case Qt::MaximumSize: sh = maxSize(); break; default: break; } return sh; }