reference operator[]( size_t n ) { assert(n < size()); return reference( *this, n, queue); }
void eWindow::hide() { if (m_animation_mode & 0x10) m_desktop->sendHide(position(), size()); eWidget::hide(); }
void WebPage::createWindow() { QSize size(1680, 1050); setViewportSize(size); }
BOOST_FIXTURE_TEST_CASE(test_result_contains_object, WithSphere) { const auto result = hitTest.sphereTest({0.f, 0.f, 0.f}, 1.f); BOOST_ASSERT(result.size() == 1); BOOST_CHECK_EQUAL(result[0].object, object); }
string ofParameterGroup::getType(int position) const { if(position>=size()) return ""; else return obj->parameters[position]->type(); }
objVectorOop objVectorOopClass::grow(fint delta, bool mustAllocate) { objVectorOop v= (objVectorOop) slotsOopClass::grow(size(), delta, mustAllocate); if (oop(v) != failedAllocationOop) v->set_length(length() + delta); return v; }
BOOST_FIXTURE_TEST_CASE(boxTest_returns_result, WithSphere) { auto sphereBoundingBoxEdge = glm::vec3{ 0.f, 0.f, shape.getRadius() }; const auto result = hitTest.boxTest(sphereBoundingBoxEdge, {0.01f, 0.01f, 0.01f}); BOOST_CHECK_EQUAL(result.size(), 1); }
int main(int argc, char* argv[]) { // check for correct number of args if (argc != 2 && argc != 3) { printf("Usage: speller [dictionary] text\n"); return 1; } // structs for timing data struct rusage before, after; // benchmarks double time_load = 0.0, time_check = 0.0, time_size = 0.0, time_unload = 0.0; // determine dictionary to use char* dictionary = (argc == 3) ? argv[1] : DICTIONARY; // load dictionary getrusage(RUSAGE_SELF, &before); bool loaded = load(dictionary); getrusage(RUSAGE_SELF, &after); // abort if dictionary not loaded if (!loaded) { printf("Could not load %s.\n", dictionary); return 1; } // calculate time to load dictionary time_load = calculate(&before, &after); // try to open text char* text = (argc == 3) ? argv[2] : argv[1]; FILE* fp = fopen(text, "r"); if (fp == NULL) { printf("Could not open %s.\n", text); unload(); return 1; } // prepare to report misspellings printf("\nMISSPELLED WORDS\n\n"); // prepare to spell-check int index = 0, misspellings = 0, words = 0; char word[LENGTH+1]; // spell-check each word in text for (int c = fgetc(fp); c != EOF; c = fgetc(fp)) { // allow only alphabetical characters and apostrophes if (isalpha(c) || (c == '\'' && index > 0)) { // append character to word word[index] = c; index++; // ignore alphabetical strings too long to be words if (index > LENGTH) { // consume remainder of alphabetical string while ((c = fgetc(fp)) != EOF && isalpha(c)); // prepare for new word index = 0; } } // ignore words with numbers (like MS Word can) else if (isdigit(c)) { // consume remainder of alphanumeric string while ((c = fgetc(fp)) != EOF && isalnum(c)); // prepare for new word index = 0; } // we must have found a whole word else if (index > 0) { // terminate current word word[index] = '\0'; // update counter words++; // check word's spelling getrusage(RUSAGE_SELF, &before); bool misspelled = !check(word); getrusage(RUSAGE_SELF, &after); // update benchmark time_check += calculate(&before, &after); // print word if misspelled if (misspelled) { printf("%s\n", word); misspellings++; } // prepare for next word index = 0; } } // check whether there was an error if (ferror(fp)) { fclose(fp); printf("Error reading %s.\n", text); unload(); return 1; } // close text fclose(fp); // determine dictionary's size getrusage(RUSAGE_SELF, &before); unsigned int n = size(); getrusage(RUSAGE_SELF, &after); // calculate time to determine dictionary's size time_size = calculate(&before, &after); // unload dictionary getrusage(RUSAGE_SELF, &before); bool unloaded = unload(); getrusage(RUSAGE_SELF, &after); // abort if dictionary not unloaded if (!unloaded) { printf("Could not unload %s.\n", dictionary); return 1; } // calculate time to unload dictionary time_unload = calculate(&before, &after); // report benchmarks printf("\nWORDS MISSPELLED: %d\n", misspellings); printf("WORDS IN DICTIONARY: %d\n", n); printf("WORDS IN TEXT: %d\n", words); printf("TIME IN load: %.2f\n", time_load); printf("TIME IN check: %.2f\n", time_check); printf("TIME IN size: %.2f\n", time_size); printf("TIME IN unload: %.2f\n", time_unload); printf("TIME IN TOTAL: %.2f\n\n", time_load + time_check + time_size + time_unload); // that's all folks return 0; }
void RWsTextCursor::SetL(const TWsWinCmdSetTextCursor &aSet, TBool aClipped) { if (aSet.cursor.iType < TTextCursor::ETypeFirst || (aSet.cursor.iType > TTextCursor::ETypeLast && aSet.cursor.iType <= TTextCursor::ETypeLastBasic) || (aSet.cursor.iFlags&static_cast<TUint>(ETextCursorPrivateFlags))) { Cancel(); iGroupWin->OwnerPanic(EWservPanicInvalidTextCursor); } else { CWsClientWindow* win = NULL; iGroupWin->WsOwner()->HandleToClientWindow(aSet.window, &win); // Check window is a child of the group window CWsWindowBase* searchWin = NULL; for(searchWin=win; searchWin->WinType()!=EWinTypeGroup; searchWin=searchWin->BaseParent()) {} if (iGroupWin != searchWin) { Cancel(); iGroupWin->OwnerPanic(EWservPanicWindow); } TPoint pos(aSet.pos.iX, aSet.pos.iY-aSet.cursor.iAscent); TSize size(aSet.cursor.iWidth, aSet.cursor.iHeight); TUint flags = aSet.cursor.iFlags; TInt type = aSet.cursor.iType; TRect clipRect = iClipRect; TRgb color = aSet.cursor.iColor; CWsCustomTextCursor* customTextCursor = iCustomTextCursor; TBool changed = EFalse; TPoint clipOrigo; TSize clipSize; if (type > TTextCursor::ETypeLastBasic) { changed = ETrue; customTextCursor = CWsClient::FindCustomTextCursor(type); if (!customTextCursor) { Cancel(); iGroupWin->OwnerPanic(EWservPanicNoCustomTextCursor); return; } if( !customTextCursor->HasSpriteMember() ) { iGroupWin->OwnerPanic(EWservPanicNoSpriteMember); return; } TInt yAdjust=0; switch (customTextCursor->Alignment()) { case RWsSession::ECustomTextCursorAlignTop: break; case RWsSession::ECustomTextCursorAlignBaseline: yAdjust = aSet.cursor.iAscent-1; break; case RWsSession::ECustomTextCursorAlignBottom: yAdjust = aSet.cursor.iHeight-1; break; default: Cancel(); iGroupWin->OwnerPanic(EWservPanicCustomTextCursorAlign); return; } pos.iY += yAdjust; // Start with a clipping rect to be the whole window // relative cursor pos and shrink down to what we want clipOrigo = -pos; clipSize = win->Size(); if (flags & TTextCursor::EFlagClipHorizontal) { clipOrigo.iX = 0; clipSize.iWidth = size.iWidth; } if (flags & TTextCursor::EFlagClipVertical) { clipOrigo.iY = -yAdjust; clipSize.iHeight = aSet.cursor.iHeight; } } else { customTextCursor = NULL; } if (aClipped) { flags|=ETextCursorFlagClipped; clipRect=aSet.rect; } if (pos != iPos || size != iSize || iType != type || flags != iFlags || clipRect != iClipRect || color != iColor || customTextCursor != iCustomTextCursor || win != iWin) { // There is a change in the cursor. changed = ETrue; } if (iInternalFlags&EHasFocus && changed) { TCursorSprite::Hide(); } iPos = pos; iSize = size; iType = type; iFlags= flags; iClipRect = clipRect; iColor = color; iCustomTextCursor = customTextCursor; iWin = win; if (customTextCursor && iInternalFlags&EHasFocus) { customTextCursor->CompleteL(win, !(flags&TTextCursor::EFlagNoFlash), flags & (TTextCursor::EFlagClipHorizontal | TTextCursor::EFlagClipVertical), clipOrigo, clipSize); customTextCursor->SetPositionNoRedraw(pos); } if (iInternalFlags&EHasFocus && changed) { TCursorSprite::SetCurrentCursor(this, win); } } }
void kill(Treap *t) { if (!size(t)) return; kill(t->l); kill(t->r); delete t; }
DecoratorDialog::~DecoratorDialog() { previous_size = size(); }
void pull(Treap *t) { push(t->l); push(t->r); t->size = size(t->l) + size(t->r) + 1; }
void push(Treap *t) { if (!size(t)) return; }
iterator end() { return iterator(*this, size(), queue); }
void test(RandomForestImage& randomForest, const std::string& folderTesting, const std::string& folderPrediction, const bool useDepthFilling, const bool writeProbabilityImages) { auto filenames = listImageFilenames(folderTesting); if (filenames.empty()) { throw std::runtime_error(std::string("found no files in ") + folderTesting); } CURFIL_INFO("got " << filenames.size() << " files for prediction"); CURFIL_INFO("label/color map:"); const auto labelColorMap = randomForest.getLabelColorMap(); for (const auto& labelColor : labelColorMap) { const auto color = LabelImage::decodeLabel(labelColor.first); CURFIL_INFO("label: " << static_cast<int>(labelColor.first) << ", color: RGB(" << color << ")"); } // tbb::mutex totalMutex; utils::Average averageAccuracy; utils::Average averageAccuracyWithoutVoid; size_t i = 0; const bool useCIELab = randomForest.getConfiguration().isUseCIELab(); CURFIL_INFO("CIELab: " << useCIELab); CURFIL_INFO("DepthFilling: " << useDepthFilling); const bool useDepthImages = randomForest.getConfiguration().isUseDepthImages(); CURFIL_INFO("useDepthImages: " << useDepthImages); bool onGPU = randomForest.getConfiguration().getAccelerationMode() == GPU_ONLY; size_t grainSize = 1; if (!onGPU) { grainSize = filenames.size(); } bool writeImages = true; if (folderPrediction.empty()) { CURFIL_WARNING("no prediction folder given. will not write images"); writeImages = false; } std::vector<LabelType> ignoredLabels; for (const std::string colorString : randomForest.getConfiguration().getIgnoredColors()) { ignoredLabels.push_back(LabelImage::encodeColor(RGBColor(colorString))); } const LabelType numClasses = randomForest.getNumClasses(); ConfusionMatrix totalConfusionMatrix(numClasses, ignoredLabels); double totalPredictionTime = 0; { // tbb::parallel_for(tbb::blocked_range<size_t>(0, filenames.size(), grainSize), // [&](const tbb::blocked_range<size_t>& range) { for(size_t fileNr = 0; fileNr != filenames.size(); fileNr++) { const std::string& filename = filenames[fileNr]; const auto imageLabelPair = loadImagePair(filename, useCIELab, useDepthImages, useDepthFilling); const RGBDImage& testImage = imageLabelPair.getRGBDImage(); const LabelImage& groundTruth = imageLabelPair.getLabelImage(); LabelImage prediction(testImage.getWidth(), testImage.getHeight()); for(int y = 0; y < groundTruth.getHeight(); y++) { for(int x = 0; x < groundTruth.getWidth(); x++) { const LabelType label = groundTruth.getLabel(x, y); if (label >= numClasses) { const auto msg = (boost::format("illegal label in ground truth image '%s' at pixel (%d,%d): %d RGB(%3d,%3d,%3d) (numClasses: %d)") % filename % x % y % static_cast<int>(label) % LabelImage::decodeLabel(label)[0] % LabelImage::decodeLabel(label)[1] % LabelImage::decodeLabel(label)[2] % static_cast<int>(numClasses) ).str(); throw std::runtime_error(msg); } } } boost::filesystem::path fn(testImage.getFilename()); const std::string basepath = folderPrediction + "/" + boost::filesystem::basename(fn); cuv::ndarray<float, cuv::host_memory_space> probabilities; utils::Timer timer2; prediction = randomForest.predict(testImage, &probabilities, onGPU, useDepthImages); totalPredictionTime += timer2.getMilliseconds(); #ifndef NDEBUG for(LabelType label = 0; label < randomForest.getNumClasses(); label++) { if (!randomForest.shouldIgnoreLabel(label)) { continue; } // ignored classes must not be predicted as we did not sample them for(size_t y = 0; y < probabilities.shape(1); y++) { for(size_t x = 0; x < probabilities.shape(2); x++) { const float& probability = probabilities(label, y, x); assert(probability == 0.0); } } } #endif if (writeImages && writeProbabilityImages) { utils::Profile profile("writeProbabilityImages"); RGBDImage probabilityImage(testImage.getWidth(), testImage.getHeight()); for(LabelType label = 0; label< randomForest.getNumClasses(); label++) { if (randomForest.shouldIgnoreLabel(label)) { continue; } for(int y = 0; y < probabilityImage.getHeight(); y++) { for(int x = 0; x < probabilityImage.getWidth(); x++) { const float& probability = probabilities(label, y, x); Depth depth(probability * std::numeric_limits<int>::max() ); probabilityImage.setDepth(x, y, depth ); } } const std::string filename = (boost::format("%s_label_%d.png") % basepath % static_cast<int>(label)).str(); probabilityImage.saveDepth(filename); } } int thisNumber; { // tbb::mutex::scoped_lock total(totalMutex); thisNumber = i++; } if (writeImages) { utils::Profile profile("writeImages"); testImage.saveColor(basepath + ".png"); if (useDepthImages){ testImage.saveDepth(basepath + "_depth.png");} groundTruth.save(basepath + "_ground_truth.png"); prediction.save(basepath + "_prediction.png"); } ConfusionMatrix confusionMatrix(numClasses); double accuracy = calculatePixelAccuracy(prediction, groundTruth, true, &ignoredLabels); double accuracyWithoutVoid = calculatePixelAccuracy(prediction, groundTruth, false, &ignoredLabels, &confusionMatrix); // tbb::mutex::scoped_lock lock(totalMutex); CURFIL_INFO("prediction " << (thisNumber + 1) << "/" << filenames.size() << " (" << testImage.getFilename() << "): pixel accuracy (without void): " << 100 * accuracy << " (" << 100 * accuracyWithoutVoid << ")"); averageAccuracy.addValue(accuracy); averageAccuracyWithoutVoid.addValue(accuracyWithoutVoid); totalConfusionMatrix += confusionMatrix; } // }); } CURFIL_INFO(totalPredictionTime / filenames.size()<<" ms/image"); // tbb::mutex::scoped_lock lock(totalMutex); double accuracy = averageAccuracy.getAverage(); double accuracyWithoutVoid = averageAccuracyWithoutVoid.getAverage(); CURFIL_INFO(totalConfusionMatrix); CURFIL_INFO("pixel accuracy: " << 100 * accuracy); CURFIL_INFO("pixel accuracy without void: " << 100 * accuracyWithoutVoid); }
void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator op, const FloatRect& destRect, BlendMode blendMode) { if (!nativeImageForCurrentFrame()) return; if (!patternTransform.isInvertible()) return; CGContextRef context = ctxt->platformContext(); GraphicsContextStateSaver stateSaver(*ctxt); CGContextClipToRect(context, destRect); ctxt->setCompositeOperation(op, blendMode); CGContextTranslateCTM(context, destRect.x(), destRect.y() + destRect.height()); CGContextScaleCTM(context, 1, -1); // Compute the scaled tile size. float scaledTileHeight = tileRect.height() * narrowPrecisionToFloat(patternTransform.d()); // We have to adjust the phase to deal with the fact we're in Cartesian space now (with the bottom left corner of destRect being // the origin). float adjustedX = phase.x() - destRect.x() + tileRect.x() * narrowPrecisionToFloat(patternTransform.a()); // We translated the context so that destRect.x() is the origin, so subtract it out. float adjustedY = destRect.height() - (phase.y() - destRect.y() + tileRect.y() * narrowPrecisionToFloat(patternTransform.d()) + scaledTileHeight); CGImageRef tileImage = nativeImageForCurrentFrame(); float h = CGImageGetHeight(tileImage); RetainPtr<CGImageRef> subImage; if (tileRect.size() == size()) subImage = tileImage; else { // Copying a sub-image out of a partially-decoded image stops the decoding of the original image. It should never happen // because sub-images are only used for border-image, which only renders when the image is fully decoded. ASSERT(h == height()); subImage = adoptCF(CGImageCreateWithImageInRect(tileImage, tileRect)); } // Adjust the color space. subImage = Image::imageWithColorSpace(subImage.get(), styleColorSpace); // Leopard has an optimized call for the tiling of image patterns, but we can only use it if the image has been decoded enough that // its buffer is the same size as the overall image. Because a partially decoded CGImageRef with a smaller width or height than the // overall image buffer needs to tile with "gaps", we can't use the optimized tiling call in that case. // FIXME: We cannot use CGContextDrawTiledImage with scaled tiles on Leopard, because it suffers from rounding errors. Snow Leopard is ok. float scaledTileWidth = tileRect.width() * narrowPrecisionToFloat(patternTransform.a()); float w = CGImageGetWidth(tileImage); if (w == size().width() && h == size().height() && !spaceSize().width() && !spaceSize().height()) CGContextDrawTiledImage(context, FloatRect(adjustedX, adjustedY, scaledTileWidth, scaledTileHeight), subImage.get()); else { // On Leopard and newer, this code now only runs for partially decoded images whose buffers do not yet match the overall size of the image. static const CGPatternCallbacks patternCallbacks = { 0, drawPatternCallback, patternReleaseCallback }; CGAffineTransform matrix = CGAffineTransformMake(narrowPrecisionToCGFloat(patternTransform.a()), 0, 0, narrowPrecisionToCGFloat(patternTransform.d()), adjustedX, adjustedY); matrix = CGAffineTransformConcat(matrix, CGContextGetCTM(context)); // The top of a partially-decoded image is drawn at the bottom of the tile. Map it to the top. matrix = CGAffineTransformTranslate(matrix, 0, size().height() - h); #if PLATFORM(IOS) matrix = CGAffineTransformScale(matrix, 1, -1); matrix = CGAffineTransformTranslate(matrix, 0, -h); #endif CGImageRef platformImage = CGImageRetain(subImage.get()); RetainPtr<CGPatternRef> pattern = adoptCF(CGPatternCreate(platformImage, CGRectMake(0, 0, tileRect.width(), tileRect.height()), matrix, tileRect.width() + spaceSize().width() * (1 / narrowPrecisionToFloat(patternTransform.a())), tileRect.height() + spaceSize().height() * (1 / narrowPrecisionToFloat(patternTransform.d())), kCGPatternTilingConstantSpacing, true, &patternCallbacks)); if (!pattern) return; RetainPtr<CGColorSpaceRef> patternSpace = adoptCF(CGColorSpaceCreatePattern(0)); CGFloat alpha = 1; RetainPtr<CGColorRef> color = adoptCF(CGColorCreateWithPattern(patternSpace.get(), pattern.get(), &alpha)); CGContextSetFillColorSpace(context, patternSpace.get()); // FIXME: Really want a public API for this. It is just CGContextSetBaseCTM(context, CGAffineTransformIdentiy). wkSetBaseCTM(context, CGAffineTransformIdentity); CGContextSetPatternPhase(context, CGSizeZero); CGContextSetFillColorWithColor(context, color.get()); CGContextFillRect(context, CGContextGetClipBoundingBox(context)); } stateSaver.restore(); if (imageObserver()) imageObserver()->didDraw(this); }
bool rspfGeneralRasterTileSource::getTile(rspfImageData* result, rspf_uint32 resLevel) { bool status = false; //--- // Not open, this tile source bypassed, or invalid res level, // return a blank tile. //--- if( isOpen() && isSourceEnabled() && isValidRLevel(resLevel) && result && (result->getNumberOfBands() == getNumberOfOutputBands()) ) { //--- // Check for overview tile. Some overviews can contain r0 so always // call even if resLevel is 0. Method returns true on success, false // on error. //--- status = getOverviewTile(resLevel, result); if (status) { if(getOutputScalarType() == RSPF_USHORT11) { //--- // Temp fix: // The overview handler could return a tile of RSPF_UINT16 if // the max sample value was not set to 2047. //--- result->setScalarType(RSPF_USHORT11); } } if (!status) // Did not get an overview tile. { status = true; //--- // Subtract any sub image offset to get the zero based image space // rectangle. //--- rspfIrect tile_rect = result->getImageRectangle(); // This should be the zero base image rectangle for this res level. rspfIrect image_rect = getImageRectangle(resLevel); //--- // See if any point of the requested tile is in the image. //--- if ( tile_rect.intersects(image_rect) ) { // Make the tile rectangle zero base. result->setImageRectangle(tile_rect); // Initialize the tile if needed as we're going to stuff it. if (result->getDataObjectStatus() == RSPF_NULL) { result->initialize(); } rspfIrect clip_rect = tile_rect.clipToRect(image_rect); if ( ! tile_rect.completely_within(m_bufferRect) ) { // A new buffer must be loaded. if ( !tile_rect.completely_within(clip_rect) ) { //--- // Start with a blank tile since the whole tile buffer will // not be // filled. //--- result->makeBlank(); } // Reallocate the buffer if needed. if ( m_bufferSizeInPixels != result->getSize() ) { allocateBuffer( result ); } rspfIpt size(static_cast<rspf_int32>(result->getWidth()), static_cast<rspf_int32>(result->getHeight())); if( !fillBuffer(clip_rect.ul(), size) ) { rspfNotify(rspfNotifyLevel_WARN) << "Error from fill buffer..." << std::endl; //--- // Error in filling buffer. //--- setErrorStatus(); status = false; } } result->loadTile(m_buffer, m_bufferRect, clip_rect, m_bufferInterleave); result->validate(); // Set the rectangle back. result->setImageRectangle(tile_rect); } else // No intersection. { result->makeBlank(); } } } return status; }
bool UniscribeController::shapeAndPlaceItem(const UChar* cp, unsigned i, const SimpleFontData* fontData, GlyphBuffer* glyphBuffer) { // Determine the string for this item. const UChar* str = cp + m_items[i].iCharPos; int len = m_items[i+1].iCharPos - m_items[i].iCharPos; SCRIPT_ITEM item = m_items[i]; // Set up buffers to hold the results of shaping the item. Vector<WORD> glyphs; Vector<WORD> clusters; Vector<SCRIPT_VISATTR> visualAttributes; clusters.resize(len); // Shape the item. // The recommended size for the glyph buffer is 1.5 * the character length + 16 in the uniscribe docs. // Apparently this is a good size to avoid having to make repeated calls to ScriptShape. glyphs.resize(1.5 * len + 16); visualAttributes.resize(glyphs.size()); if (!shape(str, len, item, fontData, glyphs, clusters, visualAttributes)) return true; // We now have a collection of glyphs. Vector<GOFFSET> offsets; Vector<int> advances; offsets.resize(glyphs.size()); advances.resize(glyphs.size()); int glyphCount = 0; HRESULT placeResult = ScriptPlace(0, fontData->scriptCache(), glyphs.data(), glyphs.size(), visualAttributes.data(), &item.a, advances.data(), offsets.data(), 0); if (placeResult == E_PENDING) { // The script cache isn't primed with enough info yet. We need to select our HFONT into // a DC and pass the DC in to ScriptPlace. HWndDC hdc(0); HFONT hfont = fontData->platformData().hfont(); HFONT oldFont = (HFONT)SelectObject(hdc, hfont); placeResult = ScriptPlace(hdc, fontData->scriptCache(), glyphs.data(), glyphs.size(), visualAttributes.data(), &item.a, advances.data(), offsets.data(), 0); SelectObject(hdc, oldFont); } if (FAILED(placeResult) || glyphs.isEmpty()) return true; // Convert all chars that should be treated as spaces to use the space glyph. // We also create a map that allows us to quickly go from space glyphs back to their corresponding characters. Vector<int> spaceCharacters(glyphs.size()); spaceCharacters.fill(-1); const float cLogicalScale = fontData->platformData().useGDI() ? 1.0f : 32.0f; float spaceWidth = fontData->spaceWidth() - fontData->syntheticBoldOffset(); unsigned logicalSpaceWidth = spaceWidth * cLogicalScale; for (int k = 0; k < len; k++) { UChar ch = *(str + k); bool treatAsSpace = Font::treatAsSpace(ch); bool treatAsZeroWidthSpace = Font::treatAsZeroWidthSpace(ch); if (treatAsSpace || treatAsZeroWidthSpace) { // Substitute in the space glyph at the appropriate place in the glyphs // array. glyphs[clusters[k]] = fontData->spaceGlyph(); advances[clusters[k]] = treatAsSpace ? logicalSpaceWidth : 0; if (treatAsSpace) spaceCharacters[clusters[k]] = m_currentCharacter + k + item.iCharPos; } } // Populate our glyph buffer with this information. bool hasExtraSpacing = m_font.letterSpacing() || m_font.wordSpacing() || m_padding; float leftEdge = m_runWidthSoFar; for (unsigned k = 0; k < glyphs.size(); k++) { Glyph glyph = glyphs[k]; float advance = advances[k] / cLogicalScale; float offsetX = offsets[k].du / cLogicalScale; float offsetY = offsets[k].dv / cLogicalScale; // Match AppKit's rules for the integer vs. non-integer rendering modes. float roundedAdvance = roundf(advance); if (!m_font.isPrinterFont() && !fontData->isSystemFont()) { advance = roundedAdvance; offsetX = roundf(offsetX); offsetY = roundf(offsetY); } advance += fontData->syntheticBoldOffset(); if (hasExtraSpacing) { // If we're a glyph with an advance, go ahead and add in letter-spacing. // That way we weed out zero width lurkers. This behavior matches the fast text code path. if (advance && m_font.letterSpacing()) advance += m_font.letterSpacing(); // Handle justification and word-spacing. int characterIndex = spaceCharacters[k]; // characterIndex is left at the initial value of -1 for glyphs that do not map back to treated-as-space characters. if (characterIndex != -1) { // Account for padding. WebCore uses space padding to justify text. // We distribute the specified padding over the available spaces in the run. if (m_padding) { // Use leftover padding if not evenly divisible by number of spaces. if (m_padding < m_padPerSpace) { advance += m_padding; m_padding = 0; } else { m_padding -= m_padPerSpace; advance += m_padPerSpace; } } // Account for word-spacing. if (characterIndex > 0 && !Font::treatAsSpace(*m_run.data16(characterIndex - 1)) && m_font.wordSpacing()) advance += m_font.wordSpacing(); } } m_runWidthSoFar += advance; // FIXME: We need to take the GOFFSETS for combining glyphs and store them in the glyph buffer // as well, so that when the time comes to draw those glyphs, we can apply the appropriate // translation. if (glyphBuffer) { FloatSize size(offsetX, -offsetY); glyphBuffer->add(glyph, fontData, advance, &size); } FloatRect glyphBounds = fontData->boundsForGlyph(glyph); glyphBounds.move(m_glyphOrigin.x(), m_glyphOrigin.y()); m_minGlyphBoundingBoxX = min(m_minGlyphBoundingBoxX, glyphBounds.x()); m_maxGlyphBoundingBoxX = max(m_maxGlyphBoundingBoxX, glyphBounds.maxX()); m_minGlyphBoundingBoxY = min(m_minGlyphBoundingBoxY, glyphBounds.y()); m_maxGlyphBoundingBoxY = max(m_maxGlyphBoundingBoxY, glyphBounds.maxY()); m_glyphOrigin.move(advance + offsetX, -offsetY); // Mutate the glyph array to contain our altered advances. if (m_computingOffsetPosition) advances[k] = advance; } while (m_computingOffsetPosition && m_offsetX >= leftEdge && m_offsetX < m_runWidthSoFar) { // The position is somewhere inside this run. int trailing = 0; ScriptXtoCP(m_offsetX - leftEdge, clusters.size(), glyphs.size(), clusters.data(), visualAttributes.data(), advances.data(), &item.a, &m_offsetPosition, &trailing); if (trailing && m_includePartialGlyphs && m_offsetPosition < len - 1) { m_offsetPosition += m_currentCharacter + m_items[i].iCharPos; m_offsetX += m_run.rtl() ? -trailing : trailing; } else { m_computingOffsetPosition = false; m_offsetPosition += m_currentCharacter + m_items[i].iCharPos; if (trailing && m_includePartialGlyphs) m_offsetPosition++; return false; } } return true; }
BOOST_FIXTURE_TEST_CASE(sphereTest_returns_result, WithSphere) { const auto result = hitTest.sphereTest({0.f, 0.f, 0.f}, 1.f); BOOST_CHECK_EQUAL(result.size(), 1); }
void KPrWebPresentationCreateDialog::resizeEvent( QResizeEvent *e ) { QDialog::resizeEvent( e ); back->resize( size() ); }
BOOST_FIXTURE_TEST_CASE(result_contains_body, WithSphere) { const auto result = hitTest.sphereTest({0.f, 0.f, 0.f}, 1.f); BOOST_ASSERT(result.size() == 1); BOOST_CHECK_EQUAL(result[0].body, target.get()); }
void ManagerModel::OnUpdate(const float dt) { //Exit if score is over rhs. if (GetScore() >= maxScore) { mWonRound = true; } //Add health package if time delta is right timerHealthPackage -= dt; if (timerHealthPackage <= 0) { timerHealthPackage = timePeriodSpawnHealtPackage; AddHealthPackage(); } //Collision ColissionWall(); auto collisions = CollisionEntities(); if (collisions.size() > 0) { ProcessCollisions(collisions); } for (Entity *e : mEntities) { e->OnUpdate(); if (e->Type() == ENTITY_PLAYER) { for (auto view : mViews) { bool btnIsPressed = view->OnPlayerUpdatedAnimation((Player*)e); ((Player*)e)->OnUpdateAnimation(btnIsPressed, dt); ((Player*)e)->OnUpdatePhysics(dt); view->OnPlayerUpdatedPhysics((Player*)e); SetHealth(((Player*)e)->mHealth); } } else if (e->Type() == ENTITY_BULLET) { for (auto view : mViews) { ((Shot*)e)->OnUpdatedPhysics(dt); view->OnShotUpdatePhysics((Shot*)e); } } else if (e->Type() == ENTITY_ASTEROID) { for (auto view : mViews) { ((Asteroid*)e)->OnUpdateAnimation(dt); view->OnAsteroidUpdatedAnimation(((Asteroid*)e)); ((Asteroid*)e)->OnUpdatePhysics(dt); view->OnAsteroidUpdatedPhysics((Asteroid*)e); } } else if (e->Type() == ENTITY_EXPLOSION) { for (auto view : mViews) { ((Explosion*)e)->OnUpdateAnimation(dt); view->OnExplosionUpdateAnimation((Explosion*)e); } } else if (e->Type() == ENTITY_HEALTHPACKAGE) { for (auto view : mViews) { ((HealthPackage*)e)->OnUpdatePhysics(dt); view->OnHealthPackageUpdatedPhysics((HealthPackage*)e); } } else if (e->Type() == ENTITY_ENEMIEBOSS) { for (auto *view : mViews) { ((EnemieBoss*)e)->OnUpdateAnimation(dt, DelayEnemieBossMove(((EnemieBoss*)e), dt)); view->OnEnemieBossUpdatedAnimation((EnemieBoss*)e); ((EnemieBoss*)e)->OnUpdatePhysics(dt); view->OnEnemieBossUpdatedPhysics((EnemieBoss*)e); } } else if (e->Type() == ENTITY_BULLETENEMIEBOSS) { for (auto view : mViews) { ((EnemieBossShot*)e)->OnUpdatedPhysics(dt); view->OnEnemieBossShotUpdatePhysics((EnemieBossShot*)e); } } } EvalRequestNewBullet(dt); RemoveDeadExplosion(); }
void KernelExplorer::Update() { m_tree->DeleteAllItems(); const u32 total_memory_usage = vm::get(vm::user_space)->used.load(); const auto& root = m_tree->AddRoot(fmt::format("Process, ID = 0x00000001, Total Memory Usage = 0x%x (%0.2f MB)", total_memory_usage, (float)total_memory_usage / (1024 * 1024))); union name64 { u64 u64_data; char string[8]; name64(u64 data) : u64_data(data & 0x00ffffffffffffffull) { } const char* operator &() const { return string; } }; // TODO: FileSystem // Semaphores const auto sema_map = idm::get_map<lv2_sema_t>(); if (sema_map.size()) { const auto& node = m_tree->AppendItem(root, fmt::format("Semaphores (%zu)", sema_map.size())); for (const auto& data : sema_map) { const auto& sema = *data.second; m_tree->AppendItem(node, fmt::format("Semaphore: ID = 0x%08x '%s', Count = %d, Max Count = %d, Waiters = %#zu", data.first, &name64(sema.name), sema.value.load(), sema.max, sema.sq.size())); } } // Mutexes const auto mutex_map = idm::get_map<lv2_mutex_t>(); if (mutex_map.size()) { const auto& node = m_tree->AppendItem(root, fmt::format("Mutexes (%zu)", mutex_map.size())); for (const auto& data : mutex_map) { const auto& mutex = *data.second; m_tree->AppendItem(node, fmt::format("Mutex: ID = 0x%08x '%s'", data.first, &name64(mutex.name))); } } // Lightweight Mutexes const auto lwm_map = idm::get_map<lv2_lwmutex_t>(); if (lwm_map.size()) { const auto& node = m_tree->AppendItem(root, fmt::format("Lightweight Mutexes (%zu)", lwm_map.size())); for (const auto& data : lwm_map) { const auto& lwm = *data.second; m_tree->AppendItem(node, fmt::format("LWMutex: ID = 0x%08x '%s'", data.first, &name64(lwm.name))); } } // Condition Variables const auto cond_map = idm::get_map<lv2_cond_t>(); if (cond_map.size()) { const auto& node = m_tree->AppendItem(root, fmt::format("Condition Variables (%zu)", cond_map.size())); for (const auto& data : cond_map) { const auto& cond = *data.second; m_tree->AppendItem(node, fmt::format("Cond: ID = 0x%08x '%s'", data.first, &name64(cond.name))); } } // Lightweight Condition Variables const auto lwc_map = idm::get_map<lv2_lwcond_t>(); if (lwc_map.size()) { const auto& node = m_tree->AppendItem(root, fmt::format("Lightweight Condition Variables (%zu)", lwc_map.size())); for (const auto& data : lwc_map) { const auto& lwc = *data.second; m_tree->AppendItem(node, fmt::format("LWCond: ID = 0x%08x '%s'", data.first, &name64(lwc.name))); } } // Event Queues const auto eq_map = idm::get_map<lv2_event_queue_t>(); if (eq_map.size()) { const auto& node = m_tree->AppendItem(root, fmt::format("Event Queues (%zu)", eq_map.size())); for (const auto& data : eq_map) { const auto& eq = *data.second; m_tree->AppendItem(node, fmt::format("Event Queue: ID = 0x%08x '%s', %s, Key = %#llx, Events = %zu/%d, Waiters = %zu", data.first, &name64(eq.name), eq.type == SYS_SPU_QUEUE ? "SPU" : "PPU", eq.key, eq.events.size(), eq.size, eq.sq.size())); } } // Event Ports const auto ep_map = idm::get_map<lv2_event_port_t>(); if (ep_map.size()) { const auto& node = m_tree->AppendItem(root, fmt::format("Event Ports (%zu)", ep_map.size())); for (const auto& data : ep_map) { const auto& ep = *data.second; m_tree->AppendItem(node, fmt::format("Event Port: ID = 0x%08x, Name = %#llx", data.first, ep.name)); } } // Event Flags const auto ef_map = idm::get_map<lv2_event_flag_t>(); if (ef_map.size()) { const auto& node = m_tree->AppendItem(root, fmt::format("Event Flags (%zu)", ef_map.size())); for (const auto& data : ef_map) { const auto& ef = *data.second; m_tree->AppendItem(node, fmt::format("Event Flag: ID = 0x%08x", data.first)); } } // Reader/writer Locks const auto rwlock_map = idm::get_map<lv2_rwlock_t>(); if (rwlock_map.size()) { const auto& node = m_tree->AppendItem(root, fmt::format("Reader/writer Locks (%zu)", rwlock_map.size())); for (const auto& data : rwlock_map) { const auto& rwlock = *data.second; m_tree->AppendItem(node, fmt::format("RWLock: ID = 0x%08x", data.first)); } } // PRX Libraries const auto prx_map = idm::get_map<lv2_prx_t>(); if (prx_map.size()) { const auto& node = m_tree->AppendItem(root, fmt::format("PRX Libraries (%zu)", prx_map.size())); for (const auto& data : prx_map) { const auto& prx = *data.second; m_tree->AppendItem(node, fmt::format("PRX: ID = 0x%08x", data.first)); } } // Memory Containers const auto ct_map = idm::get_map<lv2_memory_container_t>(); if (ct_map.size()) { const auto& node = m_tree->AppendItem(root, fmt::format("Memory Containers (%zu)", ct_map.size())); for (const auto& data : ct_map) { const auto& ct = *data.second; m_tree->AppendItem(node, fmt::format("Memory Container: ID = 0x%08x", data.first)); } } // Memory Objects const auto mem_map = idm::get_map<lv2_memory_t>(); if (mem_map.size()) { const auto& node = m_tree->AppendItem(root, fmt::format("Memory Objects (%zu)", mem_map.size())); for (const auto& data : mem_map) { const auto& mem = *data.second; m_tree->AppendItem(node, fmt::format("Memory Object: ID = 0x%08x", data.first)); } } // PPU Threads const auto ppu_map = idm::get_map<PPUThread>(); if (ppu_map.size()) { const auto& node = m_tree->AppendItem(root, fmt::format("PPU Threads (%zu)", ppu_map.size())); for (const auto& data : ppu_map) { const auto& ppu = *data.second; m_tree->AppendItem(node, fmt::format("PPU Thread: ID = 0x%08x '%s', - %s", data.first, ppu.get_name().c_str(), ppu.ThreadStatusToString())); } } // SPU Thread Groups const auto spu_map = idm::get_map<lv2_spu_group_t>(); if (spu_map.size()) { const auto& node = m_tree->AppendItem(root, fmt::format("SPU Thread Groups (%d)", spu_map.size())); for (const auto& data : spu_map) { const auto& tg = *data.second; m_tree->AppendItem(node, fmt::format("SPU Thread Group: ID = 0x%08x '%s'", data.first, tg.name.c_str())); } } // RawSPU Threads (TODO) m_tree->Expand(root); }
bool Scenes::Menu::initialize() { Shader.reset(new PMX::PMXShader); assert(Shader); if (!Shader->InitializeBuffers(Renderer->GetDevice(), nullptr)) return false; Shader->SetLightCount(1); Shader->SetLights(DirectX::XMVectorSplatOne(), DirectX::XMVectorSplatOne(), DirectX::XMVectorSplatOne(), DirectX::XMVectorSet(-1.0f, -1.0f, 1.0f, 0.0f), DirectX::XMVectorZero(), 0); auto &Viewport = Renderer->getViewport(); Camera.reset(new Renderer::Camera(DirectX::XM_PIDIV4, (float)Viewport.Width / (float)Viewport.Height, Renderer::SCREEN_NEAR, Renderer::SCREEN_DEPTH)); assert(Camera); Camera->SetPosition(0, 10.0f, 0.0f); Frustum.reset(new Renderer::ViewFrustum); assert(Frustum); // Create a list of motions to be used as idle animations fs::directory_iterator EndIterator; fs::path MotionPath(L"./Data/Motions/Idle/"); for (fs::directory_iterator Entry(MotionPath); Entry != EndIterator; Entry++) { if (fs::is_regular_file(Entry->status()) && Entry->path().extension().wstring().compare(L".vmd") == 0) { KnownMotions.emplace_back(Entry->path().generic_wstring()); } } DirectX::XMMATRIX View, Projection; Camera->setFocalDistance(-35.0f); Camera->update(0.0f); Camera->getViewMatrix(View); Camera->getProjectionMatrix(Projection); Frustum->Construct(Renderer::SCREEN_DEPTH, Projection, View); Shader->SetEyePosition(Camera->GetPosition()); Shader->SetMatrices(DirectX::XMMatrixIdentity(), View, Projection); // Initializes the model // Pause the physics environment, to prevent resource race Physics->pause(); // Select a model to be displayed #if 1 auto ModelList = ModelHandler->getKnownModels(); do { size_t Index = RandomGenerator() % ModelList.size(); for (auto &ModelPath : ModelList) { if (Index-- == 0) { Model = ModelHandler->loadModel(ModelPath.first, Physics); ModelList.erase(ModelPath.first); break; } } } while (!Model); #else Model = ModelHandler->loadModel(L"Tda式改変WIMミク ver.2.9", Physics); Model->SetDebugFlags(PMX::Model::DebugFlags::RenderBones); #endif Model->SetShader(Shader); if (!Model->Initialize(Renderer, Physics)) return false; Physics->resume(); return true; }
void eWindow::show() { if (m_animation_mode & 0x01) m_desktop->sendShow(position(), size()); eWidget::show(); }
/** * Calculate the size of all the component controls stacked vertically. * For Avkon Forms the controls overlap by 2 pixels (hard coded) */ EXPORT_C TSize CEikCapCArray::MinimumSize() { TSize size(0,0); CEikCaptionedControl *firstCapCC = Count() > 0 ? (*this)[0] : NULL; if (firstCapCC && firstCapCC->iIsFormControl) { // we're inside form // Minimumsize needs to be called even though we wouldnt use the result (at least it calculates the number of lines) // TP HACK START (made because MinimumSize() is not good name for situations where content dimensions are desired) TInt height = 0; TInt width = 0; TRect parentRect = Rect(); TSize lineSize; // absolute size, minimumSize = maximumSize = LAF size for(TInt i=0; i<Count(); i++) { TInt gap = 0; // not possible to get this from LAF. (should be 0.5u or something) CEikCaptionedControl *line = (*this)[i]; TAknWindowLineLayout layout; const CEikDialogPage *dialogPage = firstCapCC->DialogPage(); CEikDialogPage::TFormLayoutSelection ret = CEikDialogPage::ESingle; if ( dialogPage ) ret = dialogPage->FormLayout(); if (ret == CEikDialogPage::ESingle) { lineSize = line->MinimumSize(); // ensures NumberOfLines() is valid. } else if (ret == CEikDialogPage::EDouble) { lineSize = line->MinimumSize(); // ensures NumberOfLines() is valid. } height += lineSize.iHeight + gap; width = lineSize.iWidth; } size = TSize(width,height); } else { TInt wholeWidth=0; const TInt count=Count(); const TInt topMargin=iDensePacking ? KAknNoTopMargin : KAknTopMargin; const TInt bottomMargin = iDensePacking ? KAknNoTopMargin : KAknTopMargin ; const TInt verticalSpacing=iDensePacking ? KVerticalSpacingSquash : KVerticalSpacing; TInt deltaHeight=0; CEikCapCArrayExtension *extension = ExtensionOrNull(); if (!extension) return TSize(30,30); // OOM for (TInt ii=0; ii<count; ++ii) { CEikCaptionedControl* line=(*this)[ii]; TSize thisSize=line->MinimumSize(); TInt thisDeltaHeight=thisSize.iHeight+verticalSpacing; if (deltaHeight<thisDeltaHeight) deltaHeight=thisDeltaHeight; const TInt thisCaptionWidth=line->iCaptionWidth; if (!(line->LatentGroupLineFollows())) { size.iHeight+=deltaHeight; deltaHeight=0; } if (!thisCaptionWidth) { if (wholeWidth<thisSize.iWidth) wholeWidth=thisSize.iWidth; } else { thisSize.iWidth-=thisCaptionWidth; if (extension->iCaptionWidth<thisCaptionWidth) extension->iCaptionWidth=thisCaptionWidth; if (size.iWidth<thisSize.iWidth) size.iWidth=thisSize.iWidth; } } size.iWidth+=extension->iCaptionWidth; if (size.iWidth<wholeWidth) size.iWidth=wholeWidth; // If the total height is zero don't bother adding a top margin if ( size.iHeight > 0 ) { size.iHeight+=( topMargin + bottomMargin ) ; size.iHeight+=2 ; // (we have included one too many '-2's) } } return size; }
int GetString( const wchar_t *Title, const wchar_t *Prompt, const wchar_t *HistoryName, const wchar_t *SrcText, string &strDestText, const wchar_t *HelpTopic, DWORD Flags, int *CheckBoxValue, const wchar_t *CheckBoxText, Plugin* PluginNumber, const GUID* Id ) { int Substract=5; // дополнительная величина :-) int ExitCode; bool addCheckBox=Flags&FIB_CHECKBOX && CheckBoxValue && CheckBoxText; int offset=addCheckBox?2:0; FarDialogItem StrDlgData[]= { {DI_DOUBLEBOX, 3, 1, 72, 4, 0, nullptr, nullptr, 0, L""}, {DI_TEXT, 5, 2, 0, 2, 0, nullptr, nullptr, DIF_SHOWAMPERSAND, L""}, {DI_EDIT, 5, 3, 70, 3, 0, nullptr, nullptr, DIF_FOCUS|DIF_DEFAULTBUTTON, L""}, {DI_TEXT, -1, 4, 0, 4, 0, nullptr, nullptr, DIF_SEPARATOR, L""}, {DI_CHECKBOX, 5, 5, 0, 5, 0, nullptr, nullptr, 0, L""}, {DI_TEXT, -1, 6, 0, 6, 0, nullptr, nullptr, DIF_SEPARATOR, L""}, {DI_BUTTON, 0, 7, 0, 7, 0, nullptr, nullptr, DIF_CENTERGROUP, L""}, {DI_BUTTON, 0, 7, 0, 7, 0, nullptr, nullptr, DIF_CENTERGROUP, L""}, }; auto StrDlg = MakeDialogItemsEx(StrDlgData); if (addCheckBox) { Substract-=2; StrDlg[0].Y2+=2; StrDlg[4].Selected = *CheckBoxValue != 0; StrDlg[4].strData = CheckBoxText; } if (Flags&FIB_BUTTONS) { Substract-=3; StrDlg[0].Y2+=2; StrDlg[2].Flags&=~DIF_DEFAULTBUTTON; StrDlg[5+offset].Y1=StrDlg[4+offset].Y1=5+offset; StrDlg[4+offset].Type=StrDlg[5+offset].Type=DI_BUTTON; StrDlg[4+offset].Flags=StrDlg[5+offset].Flags=DIF_CENTERGROUP; StrDlg[4+offset].Flags|=DIF_DEFAULTBUTTON; StrDlg[4+offset].strData = MSG(MOk); StrDlg[5+offset].strData = MSG(MCancel); } if (Flags&FIB_EXPANDENV) { StrDlg[2].Flags|=DIF_EDITEXPAND; } if (Flags&FIB_EDITPATH) { StrDlg[2].Flags|=DIF_EDITPATH; } if (Flags&FIB_EDITPATHEXEC) { StrDlg[2].Flags|=DIF_EDITPATHEXEC; } if (HistoryName) { StrDlg[2].strHistory=HistoryName; StrDlg[2].Flags|=DIF_HISTORY|(Flags&FIB_NOUSELASTHISTORY?0:DIF_USELASTHISTORY); } if (Flags&FIB_PASSWORD) StrDlg[2].Type=DI_PSWEDIT; if (Title) StrDlg[0].strData = Title; if (Prompt) { StrDlg[1].strData = Prompt; TruncStrFromEnd(StrDlg[1].strData, 66); if (Flags&FIB_NOAMPERSAND) StrDlg[1].Flags&=~DIF_SHOWAMPERSAND; } if (SrcText) StrDlg[2].strData = SrcText; { auto Dlg = Dialog::create(make_range(StrDlg.data(), StrDlg.data() + StrDlg.size() - Substract)); Dlg->SetPosition(-1,-1,76,offset+((Flags&FIB_BUTTONS)?8:6)); if(Id) Dlg->SetId(*Id); if (HelpTopic) Dlg->SetHelp(HelpTopic); Dlg->SetPluginOwner(PluginNumber); Dlg->Process(); ExitCode=Dlg->GetExitCode(); if (ExitCode == -2 && Global->CtrlObject->Macro.IsExecuting() != MACROSTATE_NOMACRO) Global->CtrlObject->Macro.SendDropProcess(); } if (ExitCode == 2 || ExitCode == 4 || (addCheckBox && ExitCode == 6)) { if (!(Flags&FIB_ENABLEEMPTY) && StrDlg[2].strData.empty()) return FALSE; strDestText = StrDlg[2].strData; if (addCheckBox) *CheckBoxValue=StrDlg[4].Selected; return TRUE; } return FALSE; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- QVariant ComparisonSelectionTableModel::data(const QModelIndex &index, qint32 role) const { if (!index.isValid()) { return QVariant(); } if (role == Qt::SizeHintRole) { QStyleOptionComboBox comboBox; switch(index.column()) { case FieldName: { comboBox.currentText = QString("Confidence Index"); const QString header = headerData(FieldName, Qt::Horizontal, Qt::DisplayRole).toString(); if (header.length() > comboBox.currentText.length()) { comboBox.currentText = header; } break; } case FieldValue: { comboBox.currentText = QString("0.005"); const QString header = headerData(FieldName, Qt::Horizontal, Qt::DisplayRole).toString(); if (header.length() > comboBox.currentText.length()) {comboBox.currentText = header;} break; } case FieldOperator: { comboBox.currentText = QString(" > "); const QString header = headerData(FieldOperator, Qt::Horizontal, Qt::DisplayRole).toString(); if (header.length() > comboBox.currentText.length()) { comboBox.currentText = header; } break; } // case FieldPhaseValue: // { // comboBox.currentText = QString("1"); // const QString header = headerData(FieldPhaseValue, Qt::Horizontal, Qt::DisplayRole).toString(); // if (header.length() > comboBox.currentText.length()) // { // comboBox.currentText = header; // } // break; // } default: Q_ASSERT(false); } QFontMetrics fontMetrics(data(index, Qt::FontRole) .value<QFont > ()); comboBox.fontMetrics = fontMetrics; QSize size(fontMetrics.width(comboBox.currentText), fontMetrics.height()); return qApp->style()->sizeFromContents(QStyle::CT_ComboBox, &comboBox, size); } else if (role == Qt::TextAlignmentRole) { return int(Qt::AlignRight | Qt::AlignVCenter); } else if (role == Qt::DisplayRole || role == Qt::EditRole) { int col = index.column(); if (col == FieldName) { return QVariant(m_FieldNames[index.row()]); } else if (col == FieldValue) { return QVariant(m_FieldValues[index.row()]); } else if (col == FieldOperator) { return QVariant(m_FieldOperators[index.row()]); } // else if (col == FieldPhaseValue) // { // return QVariant(m_FieldPhaseValues[index.row()]); // } } return QVariant(); }
void WebPage::resize(int width, int height) { QSize size(width, height); setViewportSize(size); }
// Adjust for creation of an internal face from a boundary face forAll(addr, facei) { if (addr[facei] > oldNInternal) { addr[facei] = 0; } } } else { // Interpolative mapping - slice to size interpolationAddrPtr_ = new labelListList ( labelListList::subList(faceMap_.addressing(), size()) ); labelListList& addr = *interpolationAddrPtr_; weightsPtr_ = new scalarListList ( scalarListList::subList(faceMap_.weights(), size()) ); scalarListList& w = *weightsPtr_; // Adjust for creation of an internal face from a boundary face forAll(addr, facei) { if (max(addr[facei]) >= oldNInternal) {