CompoundBodiesDemo::CompoundBodiesDemo(hkDemoEnvironment* env) : hkDefaultPhysicsDemo(env) { // // Setup the camera // { hkVector4 from(0.0f, 10.0f, 30.0f); hkVector4 to (0.0f, 0.0f, 0.0f); hkVector4 up (0.0f, 1.0f, 0.0f); setupDefaultCameras( env, from, to, up ); } // // Create the world // { hkpWorldCinfo info; info.setBroadPhaseWorldSize( 100.0f ); info.setupSolverInfo(hkpWorldCinfo::SOLVER_TYPE_4ITERS_MEDIUM); m_world = new hkpWorld( info ); m_world->lock(); // Register ALL agents (though some may not be necessary) hkpAgentRegisterUtil::registerAllAgents(m_world->getCollisionDispatcher()); setupGraphics(); } // Create the base { hkVector4 baseSize( 20.0f, 1.0f, 20.0f); hkVector4 basePos( 0.0f,-0.5f, 0.0f); hkpRigidBody* baseRigidBody = GameUtils::createBox(baseSize, 0.0f, basePos); m_world->addEntity( baseRigidBody ); baseRigidBody->removeReference(); } hkPseudoRandomGenerator generator(747); // Create 10 wibblies for(int i = 0; i < 10; i++) { hkVector4 pos( generator.getRandRange(-3.0f,3.0f) , i * 3.0f + 1.5f, generator.getRandRange(-3.0f,3.0f)); hkpRigidBody* wibbly = createWibbly(pos, &generator); m_world->addEntity( wibbly ); wibbly->removeReference(); hkVector4 vel(generator.getRandRange(-2.0f,2.0f), generator.getRandRange(-2.0f,2.0f), generator.getRandRange(-2.0f,2.0f)); wibbly->setAngularVelocity(vel); } m_world->unlock(); }
void SerializableRLE8AnimationFrame::calculateAndSetSizeFields() { // imageDataSize_ = colormap size + compressed data size int colorMapSize = (1 * ByteSizes::uint32Size) // number of color entries + (internalColorMap.size() * ByteSizes::uint32Size); // colors imageDataSize_ = colorMapSize + loadedCompressedDataSize_; totalSize_ = baseSize() + imageDataSize_; }
QSize SidebarDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { QSize baseSize(option.decorationSize.width(), option.decorationSize.height()); if (m_showText) { QRect fontBoundaries = QFontMetrics(option.font).boundingRect(index.data(Qt::DisplayRole).toString()); baseSize.setWidth(qMax(fontBoundaries.width(), baseSize.width())); baseSize.setHeight(baseSize.height() + fontBoundaries.height() + ITEM_PADDING); } return baseSize + QSize(ITEM_MARGIN_LEFT + ITEM_MARGIN_RIGHT, ITEM_MARGIN_TOP + ITEM_MARGIN_BOTTOM); }
void QPaintEngine::drawImage(const QRectF &r, const QImage &image, const QRectF &sr, Qt::ImageConversionFlags flags) { QRectF baseSize(0, 0, image.width(), image.height()); QImage im = image; if (baseSize != sr) im = im.copy(qFloor(sr.x()), qFloor(sr.y()), qCeil(sr.width()), qCeil(sr.height())); QPixmap pm = QPixmap::fromImage(im, flags); drawPixmap(r, pm, QRectF(QPointF(0, 0), pm.size())); }
void RenderSlider::layout() { ASSERT(needsLayout()); SliderThumbElement* thumbElement = shadowSliderThumb(); RenderBox* thumb = thumbElement ? toRenderBox(thumbElement->renderer()) : 0; IntSize baseSize(borderAndPaddingWidth(), borderAndPaddingHeight()); if (thumb) { // Allow the theme to set the size of the thumb. if (thumb->style()->hasAppearance()) { // FIXME: This should pass the style, not the renderer, to the theme. theme()->adjustSliderThumbSize(thumb); } baseSize.expand(thumb->style()->width().calcMinValue(0), thumb->style()->height().calcMinValue(0)); } LayoutRepainter repainter(*this, checkForRepaintDuringLayout()); IntSize oldSize = size(); setSize(baseSize); computeLogicalWidth(); computeLogicalHeight(); updateLayerTransform(); if (thumb) { if (oldSize != size()) thumb->setChildNeedsLayout(true, false); LayoutStateMaintainer statePusher(view(), this, IntSize(x(), y()), style()->isFlippedBlocksWritingMode()); IntRect oldThumbRect = thumb->frameRect(); thumb->layoutIfNeeded(); IntRect rect = thumbRect(); thumb->setFrameRect(rect); if (thumb->checkForRepaintDuringLayout()) thumb->repaintDuringLayoutIfMoved(oldThumbRect); statePusher.pop(); addOverflowFromChild(thumb); } repainter.repaintAfterLayout(); setNeedsLayout(false); }
int main(int argc, char *argv[]) { QGuiApplication::setAttribute(Qt::AA_UseOpenGLES); QGuiApplication app(argc, argv); QSize baseSize(1280,1024); QSize screenSize(app.primaryScreen()->size()); if(!FKUtility::loadImageset("images",screenSize)){ qDebug("unable load images"); } if(!FKUtility::loadImageset("skillIcons",screenSize)){ qDebug("unable load skillIcons"); } FKUtility::ResourceLocator resources; if(resources.load("music")!=FKUtility::ResourceLocator::loadingSuccess){ qDebug("unable load music resource"); } if(!resources.load("models")!=FKUtility::ResourceLocator::loadingSuccess){ qDebug("unable load models resource"); } if(!resources.load("sprites")!=FKUtility::ResourceLocator::loadingSuccess){ qDebug("unable load sprites resource"); } qreal sizeSet=std::max(((qreal)screenSize.height())/((qreal)baseSize.height()), ((qreal)screenSize.width ())/((qreal)baseSize.width ())); QQmlApplicationEngine engine; ADD_QML_TYPE(BalancedComponent); ADD_QML_TYPE(PlayerBase); ADD_QML_TYPE(HeroObject); ADD_QML_TYPE(PathMap); ADD_QML_TYPE(PathFinder); ADD_QML_ABSTRACT_TYPE(PathFinderAlgorithm); ADD_QML_TYPE(PathFinderAStarAlgorithm); engine.rootContext()->setContextProperty("sizeSet",sizeSet); engine.rootContext()->setContextProperty("baseHeight",baseSize.height()); engine.rootContext()->setContextProperty("baseWidth",baseSize.width()); engine.load(QUrl(QStringLiteral("qrc:///main.qml"))); QMetaObject::invokeMethod(engine.rootObjects().at(0),"show"); return app.exec(); }
static void CreateGroundPlane( hkpWorld* world ) { hkVector4 baseSize( 135.0f, 0.5f, 135.0f); hkpConvexShape* shape = new hkpBoxShape( baseSize , 0 ); hkpRigidBodyCinfo ci; ci.m_shape = shape; ci.m_restitution = 0.5f; ci.m_friction = 0.3f; ci.m_position.set( 0.0f, -0.5f, 0.0f ); ci.m_motionType = hkpMotion::MOTION_FIXED; world->addEntity( new hkpRigidBody( ci ) )->removeReference(); shape->removeReference(); }
NS_IMETHODIMP nsMathMLmsqrtFrame::Reflow(nsPresContext* aPresContext, nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus) { /////////////// // Let the base class format our content like an inferred mrow nsHTMLReflowMetrics baseSize(aDesiredSize); nsresult rv = nsMathMLContainerFrame::Reflow(aPresContext, baseSize, aReflowState, aStatus); //NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status"); if (NS_FAILED(rv)) return rv; nsBoundingMetrics bmSqr, bmBase; bmBase = baseSize.mBoundingMetrics; //////////// // Prepare the radical symbol and the overline bar nsIRenderingContext& renderingContext = *aReflowState.rendContext; renderingContext.SetFont(GetStyleFont()->mFont, nsnull); nsCOMPtr<nsIFontMetrics> fm; renderingContext.GetFontMetrics(*getter_AddRefs(fm)); nscoord ruleThickness, leading, em; GetRuleThickness(renderingContext, fm, ruleThickness); nsBoundingMetrics bmOne; renderingContext.GetBoundingMetrics(NS_LITERAL_STRING("1").get(), 1, bmOne); // get the leading to be left at the top of the resulting frame // this seems more reliable than using fm->GetLeading() on suspicious fonts GetEmHeight(fm, em); leading = nscoord(0.2f * em); // Rule 11, App. G, TeXbook // psi = clearance between rule and content nscoord phi = 0, psi = 0; if (NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags)) fm->GetXHeight(phi); else phi = ruleThickness; psi = ruleThickness + phi/4; // built-in: adjust clearance psi to emulate \mathstrut using '1' (TexBook, p.131) if (bmOne.ascent > bmBase.ascent) psi += bmOne.ascent - bmBase.ascent; // Stretch the radical symbol to the appropriate height if it is not big enough. nsBoundingMetrics contSize = bmBase; contSize.ascent = ruleThickness; contSize.descent = bmBase.ascent + bmBase.descent + psi; // height(radical) should be >= height(base) + psi + ruleThickness nsBoundingMetrics radicalSize; mSqrChar.Stretch(aPresContext, renderingContext, NS_STRETCH_DIRECTION_VERTICAL, contSize, radicalSize, NS_STRETCH_LARGER); // radicalSize have changed at this point, and should match with // the bounding metrics of the char mSqrChar.GetBoundingMetrics(bmSqr); // According to TeX, the ascent of the returned radical should be // the thickness of the overline ruleThickness = bmSqr.ascent; // make sure that the rule appears on the screen nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1); if (ruleThickness < onePixel) { ruleThickness = onePixel; } // adjust clearance psi to get an exact number of pixels -- this // gives a nicer & uniform look on stacked radicals (bug 130282) nscoord delta = psi % onePixel; if (delta) psi += onePixel - delta; // round up nscoord dx = 0, dy = 0; // place the radical symbol and the radical bar dy = leading; // leave a leading at the top mSqrChar.SetRect(nsRect(dx, dy, bmSqr.width, bmSqr.ascent + bmSqr.descent)); dx = bmSqr.width; mBarRect.SetRect(dx, dy, bmBase.width, ruleThickness); // Update the desired size for the container. // the baseline will be that of the base. mBoundingMetrics.ascent = bmBase.ascent + psi + ruleThickness; mBoundingMetrics.descent = PR_MAX(bmBase.descent, (bmSqr.descent - (bmBase.ascent + psi))); mBoundingMetrics.width = bmSqr.width + bmBase.width; mBoundingMetrics.leftBearing = bmSqr.leftBearing; mBoundingMetrics.rightBearing = bmSqr.width + PR_MAX(bmBase.width, bmBase.rightBearing); // take also care of the rule aDesiredSize.ascent = mBoundingMetrics.ascent + leading; aDesiredSize.descent = PR_MAX(baseSize.descent, (mBoundingMetrics.descent + ruleThickness)); aDesiredSize.height = aDesiredSize.ascent + aDesiredSize.descent; aDesiredSize.width = mBoundingMetrics.width; aDesiredSize.mBoundingMetrics = mBoundingMetrics; mReference.x = 0; mReference.y = aDesiredSize.ascent; ////////////////// // Adjust the origins to leave room for the sqrt char and the overline bar dx = radicalSize.width; dy = aDesiredSize.ascent - baseSize.ascent; nsIFrame* childFrame = mFrames.FirstChild(); while (childFrame) { childFrame->SetPosition(childFrame->GetPosition() + nsPoint(dx, dy)); childFrame = childFrame->GetNextSibling(); } if (aDesiredSize.mComputeMEW) { aDesiredSize.mMaxElementWidth = aDesiredSize.width; } aDesiredSize.mBoundingMetrics = mBoundingMetrics; aStatus = NS_FRAME_COMPLETE; NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize); return NS_OK; }
int main( int argc, char *argv[] ) { // try { time_t programStartTime(time(NULL) ); boost::filesystem::path workingDir( boost::filesystem::current_path() ); // ========== PROGRAM PARAMETERS ========== std::string progName( "buildrandctree" ); std::string configFilename( "/home/raid2/moreno/Code/hClustering/config/"+progName+".cfg" ); // program parameters std::string roiFilename, inputFolder, outputFolder; float memory( 0.5 ), maxNbDist( 1 ); unsigned int nbLevel( 26 ), threads( 0 ); bool keepDiscarded( false ), niftiMode( true ), debug( false ); TC_GROWTYPE growType( TC_GROWOFF ); size_t baseSize( 0 ); // Declare a group of options that will be allowed only on command line boost::program_options::options_description genericOptions( "Generic options" ); genericOptions.add_options() ( "version", "Program version" ) ( "help,h", "Produce extended program help message" ) ( "roi,r", boost::program_options::value< std::string >(&roiFilename), "file with the seed voxels coordinates." ) ( "inputf,I", boost::program_options::value< std::string >(&inputFolder), "input data folder (seed tractograms)." ) ( "outputf,O", boost::program_options::value< std::string >(&outputFolder), "output folder" ) ( "maxnbdist,d", boost::program_options::value< float >(&maxNbDist)->implicit_value(1), "[opt] maximum dissimilarity a seed voxel tract must have to its most similar neighbor not be discarded. (0,1]." ) ( "cnbhood,c", boost::program_options::value< unsigned int >(&nbLevel)->implicit_value(26), "[opt] centroid method neighborhood level. Valid values: 6, 18, 26(default), 32, 96, 124." ) ( "basesize,S", boost::program_options::value< size_t >(&baseSize), "[opt] grow homogeneous base nodes (meta-leaves) of size S. (>=2)." ) ( "basenum,N", boost::program_options::value< size_t >(&baseSize), "[opt] grow N homogeneous base nodes (meta-leaves). (>=10)." ) ; // Declare a group of options that will be allowed both on command line and in config file boost::program_options::options_description configOptions( "Configuration" ); configOptions.add_options() ( "verbose,v", "[opt] verbose output." ) ( "vista", "[opt] use vista file format (default is nifti)." ) ( "cache-mem,m", boost::program_options::value< float >(&memory)->implicit_value(0.5), "[opt] maximum of memory (in GBytes) to use for tractogram cache memory. Default: 0.5." ) ( "keep-disc,k", "[opt] keep discarded voxels data in a section of the tree file." ) ( "debugout", "[opt] write additional detailed outputs meant for debug." ) ( "pthreads,p", boost::program_options::value< unsigned int >(&threads), "[opt] number of processing cores to run the program in. Default: all available." ) ; // Hidden options, will be allowed both on command line and in config file, but will not be shown to the user. boost::program_options::options_description hiddenOptions( "Hidden options" ); //hiddenOptions.add_options() ; boost::program_options::options_description cmdlineOptions; cmdlineOptions.add(genericOptions).add(configOptions).add(hiddenOptions); boost::program_options::options_description configFileOptions; configFileOptions.add(configOptions).add(hiddenOptions); boost::program_options::options_description visibleOptions( "Allowed options" ); visibleOptions.add(genericOptions).add(configOptions); boost::program_options::positional_options_description posOpt; //this arguments do not need to specify the option descriptor when typed in //posOpt.add( "roi", -1); boost::program_options::variables_map variableMap; store(boost::program_options::command_line_parser(argc, argv).options(cmdlineOptions).positional(posOpt).run(), variableMap); std::ifstream ifs(configFilename.c_str() ); store(parse_config_file(ifs, configFileOptions), variableMap); notify( variableMap); if ( variableMap.count( "help" ) ) { std::cout << "---------------------------------------------------------------------------" << std::endl; std::cout << std::endl; std::cout << " Project: hClustering" << std::endl; std::cout << std::endl; std::cout << " Whole-Brain Connectivity-Based Hierarchical Parcellation Project" << std::endl; std::cout << " David Moreno-Dominguez" << std::endl; std::cout << " [email protected]" << std::endl; std::cout << " [email protected]" << std::endl; std::cout << " www.cbs.mpg.de/~moreno" << std::endl; std::cout << std::endl; std::cout << " For more reference on the underlying algorithm and research they have been used for refer to:" << std::endl; std::cout << " - Moreno-Dominguez, D., Anwander, A., & Knösche, T. R. (2014)." << std::endl; std::cout << " A hierarchical method for whole-brain connectivity-based parcellation." << std::endl; std::cout << " Human Brain Mapping, 35(10), 5000-5025. doi: http://dx.doi.org/10.1002/hbm.22528" << std::endl; std::cout << " - Moreno-Dominguez, D. (2014)." << std::endl; std::cout << " Whole-brain cortical parcellation: A hierarchical method based on dMRI tractography." << std::endl; std::cout << " PhD Thesis, Max Planck Institute for Human Cognitive and Brain Sciences, Leipzig." << std::endl; std::cout << " ISBN 978-3-941504-45-5" << std::endl; std::cout << std::endl; std::cout << " hClustering is free software: you can redistribute it and/or modify" << std::endl; std::cout << " it under the terms of the GNU Lesser General Public License as published by" << std::endl; std::cout << " the Free Software Foundation, either version 3 of the License, or" << std::endl; std::cout << " (at your option) any later version." << std::endl; std::cout << " http://creativecommons.org/licenses/by-nc/3.0" << std::endl; std::cout << std::endl; std::cout << " hClustering is distributed in the hope that it will be useful," << std::endl; std::cout << " but WITHOUT ANY WARRANTY; without even the implied warranty of" << std::endl; std::cout << " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" << std::endl; std::cout << " GNU Lesser General Public License for more details." << std::endl; std::cout << std::endl; std::cout << "---------------------------------------------------------------------------" << std::endl << std::endl; std::cout << "buildrandctree" << std::endl << std::endl; std::cout << "Build a centroid hierarchical tree from a set of artificially pre-generated set of tractograms yoielding a uniformly random similarity matrix and a seed neighborhood information voxel list." << std::endl << std::endl; std::cout << "* Arguments:" << std::endl << std::endl; std::cout << " --version: Program version." << std::endl << std::endl; std::cout << " -h --help: Produce extended program help message." << std::endl << std::endl; std::cout << " -r --roi: A text file with the seed voxel coordinates and the corresponding tractogram index (if tractogram naming is based on index rather than coordinates)." << std::endl << std::endl; std::cout << " -I --inputf: input data folder (containing the compact tractograms)." << std::endl << std::endl; std::cout << " -O --outputf: Output folder where tree files will be written." << std::endl << std::endl; std::cout << "[-d --maxnbdist]: Maximum dissimilarity a seed voxel tract must have to its most similar neighbor not be discarded." << std::endl; std::cout << " Valid values: (0,1] Use a value of 1 (default) if no discarding is desired." << std::endl << std::endl; std::cout << "[-c --cnbhood]: Use centroid method with C neighborhood level. Valid values: 6, 18, 24(default), 32, 96, 124." << std::endl << std::endl; std::cout << "[-S --basesize]: Merge homogeneous base nodes of size S. (mutually exclusive with -N option). Default: 0 (no homogeneous merging)." << std::endl << std::endl; std::cout << "[-N --basenum]: Grow N homogeneous base nodes. (mutually exclusive with -S option). Default: 0 (no homogeneous merging)." << std::endl << std::endl; std::cout << "[-v --verbose]: Verbose output (recommended)." << std::endl << std::endl; std::cout << "[--vista]: Read/write vista (.v) files [default is nifti (.nii) and compact (.cmpct) files]." << std::endl << std::endl; std::cout << "[-m --cache-mem]: Maximum amount of RAM memory (in GBytes) to use for temporal tractogram cache storing. Valid values [0.1,50]. Default: 0.5." << std::endl << std::endl; std::cout << "[-k --keep-disc]: Keep discarded voxel information in a specialiced section of the tree." << std::endl << std::endl; std::cout << "[--debugout]: Write additional detailed outputs meant to be used for debugging." << std::endl << std::endl; std::cout << "[-p --pthreads]: Number of processing threads to run the program in parallel. Default: use all available processors." << std::endl << std::endl; std::cout << std::endl; std::cout << "* Usage example:" << std::endl << std::endl; std::cout << " buildrandctree -r roi_lh.txt -I tractograms/ -O results/ -c 26 -N 1000 -k -m 2 -v " << std::endl << std::endl; std::cout << std::endl; std::cout << "* Outputs (in output folder defined at option -O):" << std::endl << std::endl; std::cout << " - 'cX_bin_nmt.txt' - (where X is the neighborhood level defined at option -c) non-monotonic binary-branching hierarchical tree without tree processing (if desired use processtree command)." << std::endl; std::cout << " - 'baselist_nmt.txt' - meta-leaves (base nodes defined by the us of option -N or -S) list with IDs corresponding to the non-monotonic tree file." << std::endl; std::cout << " - 'success.txt' - An empty file created when the program has sucessfully exited after completion (to help for automatic re-running scripting after failure)." << std::endl; std::cout << " - 'buildrandtree_log.txt' - A text log file containing the parameter details and in-run and completion information of the program." << std::endl; std::cout << std::endl; std::cout << " [extra outputs when using --debugout option)" << std::endl << std::endl; std::cout << " - 'cX_bin_nmt_debug.txt' - version of the counterpart file without '_debug' suffix with redundant information for debugging purposes." << std::endl; std::cout << std::endl; exit(0); } if ( variableMap.count( "verbose" ) ) { std::cout << "verbose output" << std::endl; verbose=true; } if ( variableMap.count( "pthreads" ) ) { if ( threads == 1 ) { std::cout << "Using a single processor" << std::endl; } else if( threads == 0 || threads >= omp_get_num_procs() ) { threads = omp_get_num_procs(); std::cout << "Using all available processors ( " << threads << " )." << std::endl; } else { std::cout << "Using a maximum of " << threads << " processors " << std::endl; } omp_set_num_threads( threads ); } else { threads = omp_get_num_procs(); omp_set_num_threads( threads ); std::cout << "Using all available processors ( " << threads << " )." << std::endl; } if ( variableMap.count( "vista" ) ) { if( verbose ) { std::cout << "Using vista format" << std::endl; } fileManagerFactory fmf; fmf.setVista(); niftiMode = false; } else { if( verbose ) { std::cout << "Using nifti format" << std::endl; } fileManagerFactory fmf; fmf.setNifti(); niftiMode = true; } if ( variableMap.count( "debugout" ) ) { if( verbose ) { std::cout << "Debug output files activated" << std::endl; } debug = true; } if ( variableMap.count( "version" ) ) { std::cout << progName << ", version 2.0" << std::endl; exit(0); } if ( variableMap.count( "roi" ) ) { if( !boost::filesystem::is_regular_file( boost::filesystem::path( roiFilename ) ) ) { std::cerr << "ERROR: roi file \"" <<roiFilename<< "\" is not a regular file" << std::endl; std::cerr << visibleOptions << std::endl; exit(-1); } else if( verbose ) { std::cout << "Seed voxels roi file: " << roiFilename << std::endl; } } else { std::cerr << "ERROR: no seed voxels roi file stated" << std::endl; std::cerr << visibleOptions << std::endl; exit(-1); } if( verbose ) { std::cout << "Maximum distance to most similar neighbor: " << maxNbDist << std::endl; } if ( maxNbDist <= 0 || maxNbDist > 1 ) { std::cerr << "ERROR: distance value used is out of bounds please use a value within (0,1]" << std::endl; std::cerr << visibleOptions << std::endl; exit(-1); } else if ( maxNbDist == 1 && verbose ) { std::cout << "No neighbor distance restrictions will be applied" << std::endl; } else if( verbose ) { std::cout << "Seed voxels with no neighbors with tract dissimilarity lower than " << maxNbDist << " will be discarded as outliers" << std::endl; } if( verbose ) { std::cout << "Centroid neighborhood level: " << nbLevel << std::endl; } if ( ( nbLevel != 6 ) && ( nbLevel != 18 ) && ( nbLevel != 26 ) && ( nbLevel != 32 ) && ( nbLevel != 92 ) && ( nbLevel != 124 ) ) { std::cerr << "ERROR: invalid nbhood level, only (6,18,26,32,92,124) are accepted" << std::endl; std::cerr << visibleOptions << std::endl; exit(-1); } if ( ( variableMap.count( "basesize" ) && variableMap.count( "basenum" ) ) ) { std::cerr << "ERROR: options --basesize (-S) and --basenum (-N) are mutually exclusive" << std::endl; std::cerr << visibleOptions << std::endl; exit(-1); } if ( variableMap.count( "basesize" ) ) { if( baseSize <= 1 ) { std::cerr << "ERROR: base node (meta-leaf) size must be greater than 1" << std::endl; std::cerr << visibleOptions << std::endl; exit(-1); } else { if( verbose ) { std::cout << "Initial merging stage up to homogeneous base nodes of size: " << baseSize << std::endl; } growType = TC_GROWSIZE; } } if ( variableMap.count( "basenum" ) ) { if( baseSize < 10 ) { std::cerr << "ERROR: base node (meta-leaf) number must be equal or greater than 10" << std::endl; std::cerr << visibleOptions << std::endl; exit(-1); } else { if( verbose ) { std::cout << "Initial merging stage up to " << baseSize << " homogeneous base nodes (meta-leaves)" << std::endl; } growType = TC_GROWNUM; } } if( growType == TC_GROWOFF && verbose ) { std::cout << "No homogeneous merging stage" << std::endl; } if ( variableMap.count( "keep-disc" ) ) { if( verbose ) { std::cout << "Discarded voxel coordinates will be saved in an special section fo the tree file" << std::endl; } keepDiscarded = true; } else { if( verbose ) { std::cout << "Discarded voxel coordinates will not be saved" << std::endl; } keepDiscarded = false; } if ( variableMap.count( "inputf" ) ) { if( !boost::filesystem::is_directory( boost::filesystem::path( inputFolder ) ) ) { std::cerr << "ERROR: input seed tractogram folder \"" <<inputFolder<< "\" is not a directory" << std::endl; std::cerr << visibleOptions << std::endl; exit(-1); } else if( verbose ) { std::cout << "Input seed tractogram folder: " << inputFolder << std::endl; } } else { std::cerr << "ERROR: no input seed tractogram stated" << std::endl; std::cerr << visibleOptions << std::endl; exit(-1); } if ( variableMap.count( "outputf" ) ) { if( !boost::filesystem::is_directory( boost::filesystem::path( outputFolder ) ) ) { std::cerr << "ERROR: output folder \"" <<outputFolder<< "\" is not a directory" << std::endl; std::cerr << visibleOptions << std::endl; exit(-1); } else if( verbose ) { std::cout << "Output folder: " << outputFolder << std::endl; } } else { std::cerr << "ERROR: no output folder stated" << std::endl; std::cerr << visibleOptions << std::endl; exit(-1); } if ( memory < 0.1 || memory > 50) { std::cerr << "ERROR: cache size must be a positive float between 0.1 and 50 (GB)" << std::endl; std::cerr << visibleOptions << std::endl; exit(-1); } else if( verbose ) { std::cout << "Tractogram cache memory: " << memory << " GBytes" << std::endl; } std::string logFilename(outputFolder+"/"+progName+"_log.txt" ); std::ofstream logFile(logFilename.c_str() ); if(!logFile) { std::cerr << "ERROR: unable to open log file: \"" <<logFilename<< "\"" << std::endl; exit(-1); } logFile << "Start Time:\t" << ctime(&programStartTime) << std::endl; logFile << "Working directory:\t" << workingDir.string() << std::endl; logFile << "Verbose:\t" << verbose << std::endl; logFile << "Processors used:\t" << threads << std::endl; if( niftiMode ) { logFile << "Using nifti file format" << std::endl; } else { logFile << "Using vista file format" << std::endl; } logFile << "Vista mode flag:\t" << verbose << std::endl; logFile << "Roi file:\t" << roiFilename << std::endl; logFile << "Max nb distance:\t" << maxNbDist << std::endl; logFile << "Nbhood restriction level:\t" <<nbLevel<< std::endl; switch(growType) { case TC_GROWOFF: logFile << "Region growing: None" << std::endl; break; case TC_GROWSIZE: logFile << "Region growing: Size: " << baseSize << std::endl; break; case TC_GROWNUM: logFile << "Region growing: Number: " << baseSize << std::endl; break; } logFile << "Input seed tract folder:\t" << inputFolder << std::endl; logFile << "Output folder:\t" << outputFolder << std::endl; logFile << "Memory cache size:\t" << memory << " GB" << std::endl; logFile << "Debug outputr:\t" << debug << std::endl; logFile << "-------------" << std::endl; ///////////////////////////////////////////////////////////////// randCnbTreeBuilder builder( roiFilename, verbose ); logFile << "Roi size:\t" << builder.roiSize() << std::endl; builder.log( &logFile ); builder.setInputFolder( inputFolder ); builder.setOutputFolder( outputFolder ); builder.setDebugOutput( debug ); builder.buildRandCentroid( nbLevel, memory, growType, baseSize, keepDiscarded ); ///////////////////////////////////////////////////////////////// // save and print total time time_t programEndTime(time(NULL) ); int totalTime( difftime(programEndTime,programStartTime) ); std::cout << "Program Finished, total time: " << totalTime/3600 << "h " << (totalTime%3600)/60 << "' " << ((totalTime%3600)%60) << "\" " << std::endl; logFile << "-------------" << std::endl; logFile << "Finish Time:\t" << ctime(&programEndTime) << std::endl; logFile << "Elapsed time : " << totalTime/3600 << "h " << (totalTime%3600)/60 << "' " << ((totalTime%3600)%60) << "\"" << std::endl; // create file that indicates process was finished successfully std::string successFilename(outputFolder+"/success.txt" ); std::ofstream successFile(successFilename.c_str() ); if(!successFile) { std::cerr << "ERROR: unable to create success file: \"" <<successFile<< "\"" << std::endl; exit(-1); } successFile << "success"; // } // catch(std::exception& e) // { // std::cout << e.what() << std::endl; // return 1; // } return 0; }
NS_IMETHODIMP nsMathMLmunderoverFrame::Place(nsIRenderingContext& aRenderingContext, PRBool aPlaceOrigin, nsHTMLReflowMetrics& aDesiredSize) { if ( NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags) && !NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags)) { // place like sub-superscript pair return nsMathMLmsubsupFrame::PlaceSubSupScript(GetPresContext(), aRenderingContext, aPlaceOrigin, aDesiredSize, this); } //////////////////////////////////// // Get the children's desired sizes nsBoundingMetrics bmBase, bmUnder, bmOver; nsHTMLReflowMetrics baseSize (nsnull); nsHTMLReflowMetrics underSize (nsnull); nsHTMLReflowMetrics overSize (nsnull); nsIFrame* overFrame = nsnull; nsIFrame* underFrame = nsnull; nsIFrame* baseFrame = mFrames.FirstChild(); if (baseFrame) underFrame = baseFrame->GetNextSibling(); if (underFrame) overFrame = underFrame->GetNextSibling(); if (!baseFrame || !underFrame || !overFrame || overFrame->GetNextSibling()) { // report an error, encourage people to get their markups in order NS_WARNING("invalid markup"); return ReflowError(aRenderingContext, aDesiredSize); } GetReflowAndBoundingMetricsFor(baseFrame, baseSize, bmBase); GetReflowAndBoundingMetricsFor(underFrame, underSize, bmUnder); GetReflowAndBoundingMetricsFor(overFrame, overSize, bmOver); nscoord onePixel = GetPresContext()->IntScaledPixelsToTwips(1); //////////////////// // Place Children aRenderingContext.SetFont(GetStyleFont()->mFont, nsnull); nsCOMPtr<nsIFontMetrics> fm; aRenderingContext.GetFontMetrics(*getter_AddRefs(fm)); nscoord xHeight = 0; fm->GetXHeight (xHeight); nscoord ruleThickness; GetRuleThickness (aRenderingContext, fm, ruleThickness); nscoord correction = 0; GetItalicCorrection (bmBase, correction); // there are 2 different types of placement depending on // whether we want an accented under or not nscoord underDelta1 = 0; // gap between base and underscript nscoord underDelta2 = 0; // extra space beneath underscript if (!NS_MATHML_EMBELLISH_IS_ACCENTUNDER(mEmbellishData.flags)) { // Rule 13a, App. G, TeXbook nscoord bigOpSpacing2, bigOpSpacing4, bigOpSpacing5, dummy; GetBigOpSpacings (fm, dummy, bigOpSpacing2, dummy, bigOpSpacing4, bigOpSpacing5); underDelta1 = PR_MAX(bigOpSpacing2, (bigOpSpacing4 - bmUnder.ascent)); underDelta2 = bigOpSpacing5; } else { // No corresponding rule in TeXbook - we are on our own here // XXX tune the gap delta between base and underscript // Should we use Rule 10 like \underline does? underDelta1 = ruleThickness + onePixel/2; underDelta2 = ruleThickness; } // empty under? if (!(bmUnder.ascent + bmUnder.descent)) underDelta1 = 0; nscoord overDelta1 = 0; // gap between base and overscript nscoord overDelta2 = 0; // extra space above overscript if (!NS_MATHML_EMBELLISH_IS_ACCENTOVER(mEmbellishData.flags)) { // Rule 13a, App. G, TeXbook nscoord bigOpSpacing1, bigOpSpacing3, bigOpSpacing5, dummy; GetBigOpSpacings (fm, bigOpSpacing1, dummy, bigOpSpacing3, dummy, bigOpSpacing5); overDelta1 = PR_MAX(bigOpSpacing1, (bigOpSpacing3 - bmOver.descent)); overDelta2 = bigOpSpacing5; // XXX This is not a TeX rule... // delta1 (as computed abvove) can become really big when bmOver.descent is // negative, e.g., if the content is &OverBar. In such case, we use the height if (bmOver.descent < 0) overDelta1 = PR_MAX(bigOpSpacing1, (bigOpSpacing3 - (bmOver.ascent + bmOver.descent))); } else { // Rule 12, App. G, TeXbook overDelta1 = ruleThickness + onePixel/2; if (bmBase.ascent < xHeight) { overDelta1 += xHeight - bmBase.ascent; } overDelta2 = ruleThickness; } // empty over? if (!(bmOver.ascent + bmOver.descent)) overDelta1 = 0; nscoord dxBase, dxOver = 0, dxUnder = 0; ////////// // pass 1, do what <mover> does: attach the overscript on the base // Ad-hoc - This is to override fonts which have ready-made _accent_ // glyphs with negative lbearing and rbearing. We want to position // the overscript ourselves nscoord overWidth = bmOver.width; if (!overWidth && (bmOver.rightBearing - bmOver.leftBearing > 0)) { overWidth = bmOver.rightBearing - bmOver.leftBearing; dxOver = -bmOver.leftBearing; } if (NS_MATHML_EMBELLISH_IS_ACCENTOVER(mEmbellishData.flags)) { mBoundingMetrics.width = bmBase.width; dxOver += correction + (mBoundingMetrics.width - overWidth)/2; } else { mBoundingMetrics.width = PR_MAX(bmBase.width, overWidth); dxOver += correction/2 + (mBoundingMetrics.width - overWidth)/2; } dxBase = (mBoundingMetrics.width - bmBase.width)/2; mBoundingMetrics.ascent = bmBase.ascent + overDelta1 + bmOver.ascent + bmOver.descent; mBoundingMetrics.descent = bmBase.descent + underDelta1 + bmUnder.ascent + bmUnder.descent; mBoundingMetrics.leftBearing = PR_MIN(dxBase + bmBase.leftBearing, dxOver + bmOver.leftBearing); mBoundingMetrics.rightBearing = PR_MAX(dxBase + bmBase.rightBearing, dxOver + bmOver.rightBearing); ////////// // pass 2, do what <munder> does: attach the underscript on the previous // result. We conceptually view the previous result as an "anynomous base" // from where to attach the underscript. Hence if the underscript is empty, // we should end up like <mover>. If the overscript is empty, we should // end up like <munder>. nsBoundingMetrics bmAnonymousBase = mBoundingMetrics; nscoord ascentAnonymousBase = PR_MAX(mBoundingMetrics.ascent + overDelta2, overSize.ascent + bmOver.descent + overDelta1 + bmBase.ascent); GetItalicCorrection(bmAnonymousBase, correction); nscoord maxWidth = PR_MAX(bmAnonymousBase.width, bmUnder.width); if (NS_MATHML_EMBELLISH_IS_ACCENTUNDER(mEmbellishData.flags)) { dxUnder = (maxWidth - bmUnder.width)/2;; } else { dxUnder = -correction/2 + (maxWidth - bmUnder.width)/2; } nscoord dxAnonymousBase = (maxWidth - bmAnonymousBase.width)/2; // adjust the offsets of the real base and overscript since their // final offsets should be relative to us... dxOver += dxAnonymousBase; dxBase += dxAnonymousBase; mBoundingMetrics.width = PR_MAX(dxAnonymousBase + bmAnonymousBase.width, dxUnder + bmUnder.width); mBoundingMetrics.leftBearing = PR_MIN(dxAnonymousBase + bmAnonymousBase.leftBearing, dxUnder + bmUnder.leftBearing); mBoundingMetrics.rightBearing = PR_MAX(dxAnonymousBase + bmAnonymousBase.rightBearing, dxUnder + bmUnder.rightBearing); aDesiredSize.ascent = ascentAnonymousBase; aDesiredSize.descent = PR_MAX(mBoundingMetrics.descent + underDelta2, bmAnonymousBase.descent + underDelta1 + bmUnder.ascent + underSize.descent); aDesiredSize.height = aDesiredSize.ascent + aDesiredSize.descent; aDesiredSize.width = mBoundingMetrics.width; aDesiredSize.mBoundingMetrics = mBoundingMetrics; mReference.x = 0; mReference.y = aDesiredSize.ascent; if (aPlaceOrigin) { nscoord dy; // place overscript dy = aDesiredSize.ascent - mBoundingMetrics.ascent + bmOver.ascent - overSize.ascent; FinishReflowChild (overFrame, GetPresContext(), nsnull, overSize, dxOver, dy, 0); // place base dy = aDesiredSize.ascent - baseSize.ascent; FinishReflowChild (baseFrame, GetPresContext(), nsnull, baseSize, dxBase, dy, 0); // place underscript dy = aDesiredSize.ascent + mBoundingMetrics.descent - bmUnder.descent - underSize.ascent; FinishReflowChild (underFrame, GetPresContext(), nsnull, underSize, dxUnder, dy, 0); } return NS_OK; }
** $QT_END_LICENSE$ ** ****************************************************************************/ //! [0] w->setWindowState(w->windowState() ^ Qt::WindowFullScreen); //! [0] //! [1] w->setWindowState(w->windowState() & ~Qt::WindowMinimized | Qt::WindowActive); //! [1] //! [2] width = baseSize().width() + i * sizeIncrement().width(); height = baseSize().height() + j * sizeIncrement().height(); //! [2] //! [3] aWidget->window()->setWindowTitle("New Window Title"); //! [3] //! [4] QFont font("Helvetica", 12, QFont::Bold); setFont(font); //! [4]
void QtDockRegion::addView(IView& view) { auto qMainWindow = qtWindow_.window(); assert(qMainWindow != nullptr); auto findIt = dockWidgetMap_.find(&view); if (findIt != dockWidgetMap_.end()) { // already added into the dockWidget return; } // IView will not control qWidget's life-cycle after this call. auto qtFramework = get<IQtFramework>(); assert(qtFramework != nullptr); auto qWidget = qtFramework->toQWidget(view); if (qWidget == nullptr) { return; } auto centralWidget = qMainWindow->centralWidget(); if (centralWidget != nullptr) { centralWidget->layout()->addWidget(qWidget); } qWidget->setSizePolicy(qDockWidget_.sizePolicy()); qWidget->setMinimumSize(qDockWidget_.minimumSize()); qWidget->setMaximumSize(qDockWidget_.maximumSize()); qWidget->setSizeIncrement(qDockWidget_.sizeIncrement()); qWidget->setBaseSize(qDockWidget_.baseSize()); qWidget->resize(qWidget->baseSize()); auto qDockWidget = new NGTDockWidget(&view); qDockWidget->setObjectName(view.id()); IView* pView = &view; QtWindow* pWindow = &qtWindow_; QObject::connect(qDockWidget, &QDockWidget::visibilityChanged, [qDockWidget, pWindow](bool visible) { qDockWidget->visibilityChanged(visible); if (visible) { if (pWindow->isLoadingPreferences()) { return; } QCoreApplication::postEvent(qDockWidget, new QEvent(QEvent::FocusIn)); } }); if (qtWindow_.isReady()) { bool isOk = qMainWindow->restoreDockWidget(qDockWidget); if (!isOk) { setDefaultPreferenceForDockWidget(qDockWidget); } QmlView* qmlView = dynamic_cast<QmlView*>(pView); if (qmlView != nullptr) { if (qDockWidget->isVisible() && qDockWidget->getVisibility()) { qmlView->setNeedsToLoad(true); } } } else { needToRestorePreference_.push_back(std::make_pair(qDockWidget, pView)); } qDockWidget->setWidget(qWidget); std::string actionId("View."); actionId += view.title(); auto action = qtFramework->createAction(actionId.c_str(), view.title(), "View", [pView, qDockWidget](IAction*) { qDockWidget->show(); qDockWidget->raise(); pView->focusInEvent(); }); auto application = get<IUIApplication>(); assert(application != nullptr); application->addAction(*action); dockWidgetMap_[&view] = std::make_pair(std::unique_ptr<QDockWidget>(qDockWidget), std::move(action)); }
void SerializableAnimation::calculateAndUpdateSizeFields() { totalSize_ = baseSize() + calculateFrameDataSize(); }
CharacterDemo::CharacterDemo(hkDemoEnvironment* env) : hkDefaultPhysicsDemo(env) { // // Setup the camera // { hkVector4 from( 0.0f, 20.0f, -80.0f); hkVector4 to ( 0.0f, 0.0f, 0.0f); hkVector4 up ( 0.0f, 1.0f, 0.0f); setupDefaultCameras( env, from, to, up ); // disable back face culling setGraphicsState(HKG_ENABLED_CULLFACE, false); // don't really want shadows as makes it too dark forceShadowState(false); setupLights(m_env); // so that the extra lights are added // float lightDir[] = { 0, -0.5f, -1 }; // setSoleDirectionLight(m_env, lightDir, 0xffffffff ); } // // Create the world // { hkpWorldCinfo info; info.setBroadPhaseWorldSize( 350.0f ); info.m_gravity.set(0,0,-9.8f); info.m_collisionTolerance = 0.1f; m_world = new hkpWorld( info ); m_world->lock(); hkpAgentRegisterUtil::registerAllAgents(m_world->getCollisionDispatcher()); setupGraphics(); } // Load the level { hkVector4 tkScaleFactor(.32f,.32f,.32f); hkString fullname("Resources/Physics/Tk/CharacterController/"); // We load our test case level. //fullname += "testcases.tk"; fullname += "level.tk"; hkpShape* moppShape = GameUtils::loadTK2MOPP(fullname.cString(),tkScaleFactor, -1.0f); HK_ASSERT2(0x64232cc0, moppShape,"TK file failed to load to MOPP in GameUtils::loadTK2MOPP."); hkpRigidBodyCinfo ci; ci.m_shape = moppShape; ci.m_motionType = hkpMotion::MOTION_FIXED; ci.m_collisionFilterInfo = hkpGroupFilter::calcFilterInfo( 0, 1 ); hkpRigidBody* entity = new hkpRigidBody(ci); moppShape->removeReference(); m_world->addEntity(entity); entity->removeReference(); } // Add a ladder hkVector4 baseSize( 1.0f, 0.5f, 3.6f); { hkpRigidBodyCinfo rci; rci.m_shape = new hkpBoxShape( baseSize ); rci.m_position.set(3.4f, 8.f, 2); rci.m_motionType = hkpMotion::MOTION_FIXED; hkpRigidBody* ladder = new hkpRigidBody(rci); rci.m_shape->removeReference(); m_world->addEntity(ladder)->removeReference(); // Add a property so we can identify this as a ladder hkpPropertyValue val(1); ladder->addProperty(HK_OBJECT_IS_LADDER, val); // Color the ladder so we can see it clearly HK_SET_OBJECT_COLOR((hkUlong)ladder->getCollidable(), 0x7f1f3f1f); } // // Create a character proxy object // { // Construct a shape hkVector4 vertexA(0,0, 0.4f); hkVector4 vertexB(0,0,-0.4f); // Create a capsule to represent the character standing m_standShape = new hkpCapsuleShape(vertexA, vertexB, .6f); // Create a capsule to represent the character crouching // Note that we create the smaller capsule with the base at the same position as the larger capsule. // This means we can simply swap the shapes without having to reposition the character proxy, // and if the character is standing on the ground, it will still be on the ground. vertexA.setZero4(); m_crouchShape = new hkpCapsuleShape(vertexA, vertexB, .6f); // Construct a Shape Phantom m_phantom = new hkpSimpleShapePhantom( m_standShape, hkTransform::getIdentity(), hkpGroupFilter::calcFilterInfo(0,2) ); // Add the phantom to the world m_world->addPhantom(m_phantom); m_phantom->removeReference(); // Construct a character proxy hkpCharacterProxyCinfo cpci; cpci.m_position.set(-9.1f, 35, .4f); cpci.m_staticFriction = 0.0f; cpci.m_dynamicFriction = 1.0f; cpci.m_up.setNeg4( m_world->getGravity() ); cpci.m_up.normalize3(); cpci.m_userPlanes = 4; cpci.m_maxSlope = HK_REAL_PI / 3.f; cpci.m_shapePhantom = m_phantom; m_characterProxy = new hkpCharacterProxy( cpci ); } // // Add in a custom friction model // { hkVector4 up( 0.f, 0.f, 1.f ); m_listener = new MyCharacterListener(); m_characterProxy->addCharacterProxyListener(m_listener); } // // Create the Character state machine and context // { hkpCharacterState* state; hkpCharacterStateManager* manager = new hkpCharacterStateManager(); state = new hkpCharacterStateOnGround(); manager->registerState( state, HK_CHARACTER_ON_GROUND); state->removeReference(); state = new hkpCharacterStateInAir(); manager->registerState( state, HK_CHARACTER_IN_AIR); state->removeReference(); state = new hkpCharacterStateJumping(); manager->registerState( state, HK_CHARACTER_JUMPING); state->removeReference(); state = new hkpCharacterStateClimbing(); manager->registerState( state, HK_CHARACTER_CLIMBING); state->removeReference(); m_characterContext = new hkpCharacterContext(manager, HK_CHARACTER_ON_GROUND); manager->removeReference(); } // Current camera angle about up m_currentAngle = HK_REAL_PI * 0.5f; m_world->unlock(); }
int QWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 23) qt_static_metacall(this, _c, _id, _a); _id -= 23; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< bool*>(_v) = isModal(); break; case 1: *reinterpret_cast< Qt::WindowModality*>(_v) = windowModality(); break; case 2: *reinterpret_cast< bool*>(_v) = isEnabled(); break; case 3: *reinterpret_cast< QRect*>(_v) = geometry(); break; case 4: *reinterpret_cast< QRect*>(_v) = frameGeometry(); break; case 5: *reinterpret_cast< QRect*>(_v) = normalGeometry(); break; case 6: *reinterpret_cast< int*>(_v) = x(); break; case 7: *reinterpret_cast< int*>(_v) = y(); break; case 8: *reinterpret_cast< QPoint*>(_v) = pos(); break; case 9: *reinterpret_cast< QSize*>(_v) = frameSize(); break; case 10: *reinterpret_cast< QSize*>(_v) = size(); break; case 11: *reinterpret_cast< int*>(_v) = width(); break; case 12: *reinterpret_cast< int*>(_v) = height(); break; case 13: *reinterpret_cast< QRect*>(_v) = rect(); break; case 14: *reinterpret_cast< QRect*>(_v) = childrenRect(); break; case 15: *reinterpret_cast< QRegion*>(_v) = childrenRegion(); break; case 16: *reinterpret_cast< QSizePolicy*>(_v) = sizePolicy(); break; case 17: *reinterpret_cast< QSize*>(_v) = minimumSize(); break; case 18: *reinterpret_cast< QSize*>(_v) = maximumSize(); break; case 19: *reinterpret_cast< int*>(_v) = minimumWidth(); break; case 20: *reinterpret_cast< int*>(_v) = minimumHeight(); break; case 21: *reinterpret_cast< int*>(_v) = maximumWidth(); break; case 22: *reinterpret_cast< int*>(_v) = maximumHeight(); break; case 23: *reinterpret_cast< QSize*>(_v) = sizeIncrement(); break; case 24: *reinterpret_cast< QSize*>(_v) = baseSize(); break; case 25: *reinterpret_cast< QPalette*>(_v) = palette(); break; case 26: *reinterpret_cast< QFont*>(_v) = font(); break; case 27: *reinterpret_cast< QCursor*>(_v) = cursor(); break; case 28: *reinterpret_cast< bool*>(_v) = hasMouseTracking(); break; case 29: *reinterpret_cast< bool*>(_v) = isActiveWindow(); break; case 30: *reinterpret_cast< Qt::FocusPolicy*>(_v) = focusPolicy(); break; case 31: *reinterpret_cast< bool*>(_v) = hasFocus(); break; case 32: *reinterpret_cast< Qt::ContextMenuPolicy*>(_v) = contextMenuPolicy(); break; case 33: *reinterpret_cast< bool*>(_v) = updatesEnabled(); break; case 34: *reinterpret_cast< bool*>(_v) = isVisible(); break; case 35: *reinterpret_cast< bool*>(_v) = isMinimized(); break; case 36: *reinterpret_cast< bool*>(_v) = isMaximized(); break; case 37: *reinterpret_cast< bool*>(_v) = isFullScreen(); break; case 38: *reinterpret_cast< QSize*>(_v) = sizeHint(); break; case 39: *reinterpret_cast< QSize*>(_v) = minimumSizeHint(); break; case 40: *reinterpret_cast< bool*>(_v) = acceptDrops(); break; case 41: *reinterpret_cast< QString*>(_v) = windowTitle(); break; case 42: *reinterpret_cast< QIcon*>(_v) = windowIcon(); break; case 43: *reinterpret_cast< QString*>(_v) = windowIconText(); break; case 44: *reinterpret_cast< double*>(_v) = windowOpacity(); break; case 45: *reinterpret_cast< bool*>(_v) = isWindowModified(); break; case 46: *reinterpret_cast< QString*>(_v) = toolTip(); break; case 47: *reinterpret_cast< QString*>(_v) = statusTip(); break; case 48: *reinterpret_cast< QString*>(_v) = whatsThis(); break; case 49: *reinterpret_cast< QString*>(_v) = accessibleName(); break; case 50: *reinterpret_cast< QString*>(_v) = accessibleDescription(); break; case 51: *reinterpret_cast< Qt::LayoutDirection*>(_v) = layoutDirection(); break; case 52: *reinterpret_cast< bool*>(_v) = autoFillBackground(); break; case 53: *reinterpret_cast< QString*>(_v) = styleSheet(); break; case 54: *reinterpret_cast< QLocale*>(_v) = locale(); break; case 55: *reinterpret_cast< QString*>(_v) = windowFilePath(); break; case 56: *reinterpret_cast< Qt::InputMethodHints*>(_v) = inputMethodHints(); break; } _id -= 57; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 1: setWindowModality(*reinterpret_cast< Qt::WindowModality*>(_v)); break; case 2: setEnabled(*reinterpret_cast< bool*>(_v)); break; case 3: setGeometry(*reinterpret_cast< QRect*>(_v)); break; case 8: move(*reinterpret_cast< QPoint*>(_v)); break; case 10: resize(*reinterpret_cast< QSize*>(_v)); break; case 16: setSizePolicy(*reinterpret_cast< QSizePolicy*>(_v)); break; case 17: setMinimumSize(*reinterpret_cast< QSize*>(_v)); break; case 18: setMaximumSize(*reinterpret_cast< QSize*>(_v)); break; case 19: setMinimumWidth(*reinterpret_cast< int*>(_v)); break; case 20: setMinimumHeight(*reinterpret_cast< int*>(_v)); break; case 21: setMaximumWidth(*reinterpret_cast< int*>(_v)); break; case 22: setMaximumHeight(*reinterpret_cast< int*>(_v)); break; case 23: setSizeIncrement(*reinterpret_cast< QSize*>(_v)); break; case 24: setBaseSize(*reinterpret_cast< QSize*>(_v)); break; case 25: setPalette(*reinterpret_cast< QPalette*>(_v)); break; case 26: setFont(*reinterpret_cast< QFont*>(_v)); break; case 27: setCursor(*reinterpret_cast< QCursor*>(_v)); break; case 28: setMouseTracking(*reinterpret_cast< bool*>(_v)); break; case 30: setFocusPolicy(*reinterpret_cast< Qt::FocusPolicy*>(_v)); break; case 32: setContextMenuPolicy(*reinterpret_cast< Qt::ContextMenuPolicy*>(_v)); break; case 33: setUpdatesEnabled(*reinterpret_cast< bool*>(_v)); break; case 34: setVisible(*reinterpret_cast< bool*>(_v)); break; case 40: setAcceptDrops(*reinterpret_cast< bool*>(_v)); break; case 41: setWindowTitle(*reinterpret_cast< QString*>(_v)); break; case 42: setWindowIcon(*reinterpret_cast< QIcon*>(_v)); break; case 43: setWindowIconText(*reinterpret_cast< QString*>(_v)); break; case 44: setWindowOpacity(*reinterpret_cast< double*>(_v)); break; case 45: setWindowModified(*reinterpret_cast< bool*>(_v)); break; case 46: setToolTip(*reinterpret_cast< QString*>(_v)); break; case 47: setStatusTip(*reinterpret_cast< QString*>(_v)); break; case 48: setWhatsThis(*reinterpret_cast< QString*>(_v)); break; case 49: setAccessibleName(*reinterpret_cast< QString*>(_v)); break; case 50: setAccessibleDescription(*reinterpret_cast< QString*>(_v)); break; case 51: setLayoutDirection(*reinterpret_cast< Qt::LayoutDirection*>(_v)); break; case 52: setAutoFillBackground(*reinterpret_cast< bool*>(_v)); break; case 53: setStyleSheet(*reinterpret_cast< QString*>(_v)); break; case 54: setLocale(*reinterpret_cast< QLocale*>(_v)); break; case 55: setWindowFilePath(*reinterpret_cast< QString*>(_v)); break; case 56: setInputMethodHints(*reinterpret_cast< Qt::InputMethodHints*>(_v)); break; } _id -= 57; } else if (_c == QMetaObject::ResetProperty) { switch (_id) { case 27: unsetCursor(); break; case 51: unsetLayoutDirection(); break; case 54: unsetLocale(); break; } _id -= 57; } else if (_c == QMetaObject::QueryPropertyDesignable) { bool *_b = reinterpret_cast<bool*>(_a[0]); switch (_id) { case 41: *_b = isWindow(); break; case 42: *_b = isWindow(); break; case 43: *_b = isWindow(); break; case 44: *_b = isWindow(); break; case 45: *_b = isWindow(); break; case 55: *_b = isWindow(); break; } _id -= 57; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 57; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 57; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 57; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 57; } #endif // QT_NO_PROPERTIES return _id; }
NS_IMETHODIMP nsMathMLmrootFrame::Reflow(nsPresContext* aPresContext, nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus) { nsresult rv = NS_OK; nsSize availSize(aReflowState.ComputedWidth(), NS_UNCONSTRAINEDSIZE); nsReflowStatus childStatus; aDesiredSize.Width() = aDesiredSize.Height() = 0; aDesiredSize.SetTopAscent(0); nsBoundingMetrics bmSqr, bmBase, bmIndex; nsRenderingContext& renderingContext = *aReflowState.rendContext; ////////////////// // Reflow Children int32_t count = 0; nsIFrame* baseFrame = nullptr; nsIFrame* indexFrame = nullptr; nsHTMLReflowMetrics baseSize(aReflowState.GetWritingMode()); nsHTMLReflowMetrics indexSize(aReflowState.GetWritingMode()); nsIFrame* childFrame = mFrames.FirstChild(); while (childFrame) { // ask our children to compute their bounding metrics nsHTMLReflowMetrics childDesiredSize(aReflowState.GetWritingMode(), aDesiredSize.mFlags | NS_REFLOW_CALC_BOUNDING_METRICS); nsHTMLReflowState childReflowState(aPresContext, aReflowState, childFrame, availSize); rv = ReflowChild(childFrame, aPresContext, childDesiredSize, childReflowState, childStatus); //NS_ASSERTION(NS_FRAME_IS_COMPLETE(childStatus), "bad status"); if (NS_FAILED(rv)) { // Call DidReflow() for the child frames we successfully did reflow. DidReflowChildren(mFrames.FirstChild(), childFrame); return rv; } if (0 == count) { // base baseFrame = childFrame; baseSize = childDesiredSize; bmBase = childDesiredSize.mBoundingMetrics; } else if (1 == count) { // index indexFrame = childFrame; indexSize = childDesiredSize; bmIndex = childDesiredSize.mBoundingMetrics; } count++; childFrame = childFrame->GetNextSibling(); } if (2 != count) { // report an error, encourage people to get their markups in order ReportChildCountError(); rv = ReflowError(renderingContext, aDesiredSize); aStatus = NS_FRAME_COMPLETE; NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize); // Call DidReflow() for the child frames we successfully did reflow. DidReflowChildren(mFrames.FirstChild(), childFrame); return rv; } //////////// // Prepare the radical symbol and the overline bar nsRefPtr<nsFontMetrics> fm; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm)); renderingContext.SetFont(fm); // For radical glyphs from TeX fonts and some of the radical glyphs from // Mathematica fonts, the thickness of the overline can be obtained from the // ascent of the glyph. Most fonts however have radical glyphs above the // baseline so no assumption can be made about the meaning of the ascent. nscoord ruleThickness, leading, em; GetRuleThickness(renderingContext, fm, ruleThickness); char16_t one = '1'; nsBoundingMetrics bmOne = renderingContext.GetBoundingMetrics(&one, 1); // get the leading to be left at the top of the resulting frame // this seems more reliable than using fm->GetLeading() on suspicious fonts GetEmHeight(fm, em); leading = nscoord(0.2f * em); // Rule 11, App. G, TeXbook // psi = clearance between rule and content nscoord phi = 0, psi = 0; if (StyleFont()->mMathDisplay == NS_MATHML_DISPLAYSTYLE_BLOCK) phi = fm->XHeight(); else phi = ruleThickness; psi = ruleThickness + phi/4; // built-in: adjust clearance psi to emulate \mathstrut using '1' (TexBook, p.131) if (bmOne.ascent > bmBase.ascent) psi += bmOne.ascent - bmBase.ascent; // make sure that the rule appears on on screen nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1); if (ruleThickness < onePixel) { ruleThickness = onePixel; } // adjust clearance psi to get an exact number of pixels -- this // gives a nicer & uniform look on stacked radicals (bug 130282) nscoord delta = psi % onePixel; if (delta) psi += onePixel - delta; // round up // Stretch the radical symbol to the appropriate height if it is not big enough. nsBoundingMetrics contSize = bmBase; contSize.descent = bmBase.ascent + bmBase.descent + psi; contSize.ascent = ruleThickness; // height(radical) should be >= height(base) + psi + ruleThickness nsBoundingMetrics radicalSize; mSqrChar.Stretch(aPresContext, renderingContext, NS_STRETCH_DIRECTION_VERTICAL, contSize, radicalSize, NS_STRETCH_LARGER, StyleVisibility()->mDirection); // radicalSize have changed at this point, and should match with // the bounding metrics of the char mSqrChar.GetBoundingMetrics(bmSqr); // Update the desired size for the container (like msqrt, index is not yet included) // the baseline will be that of the base. mBoundingMetrics.ascent = bmBase.ascent + psi + ruleThickness; mBoundingMetrics.descent = std::max(bmBase.descent, (bmSqr.ascent + bmSqr.descent - mBoundingMetrics.ascent)); mBoundingMetrics.width = bmSqr.width + bmBase.width; mBoundingMetrics.leftBearing = bmSqr.leftBearing; mBoundingMetrics.rightBearing = bmSqr.width + std::max(bmBase.width, bmBase.rightBearing); // take also care of the rule aDesiredSize.SetTopAscent(mBoundingMetrics.ascent + leading); aDesiredSize.Height() = aDesiredSize.TopAscent() + std::max(baseSize.Height() - baseSize.TopAscent(), mBoundingMetrics.descent + ruleThickness); aDesiredSize.Width() = mBoundingMetrics.width; ///////////// // Re-adjust the desired size to include the index. // the index is raised by some fraction of the height // of the radical, see \mroot macro in App. B, TexBook nscoord raiseIndexDelta = NSToCoordRound(0.6f * (bmSqr.ascent + bmSqr.descent)); nscoord indexRaisedAscent = mBoundingMetrics.ascent // top of radical - (bmSqr.ascent + bmSqr.descent) // to bottom of radical + raiseIndexDelta + bmIndex.ascent + bmIndex.descent; // to top of raised index nscoord indexClearance = 0; if (mBoundingMetrics.ascent < indexRaisedAscent) { indexClearance = indexRaisedAscent - mBoundingMetrics.ascent; // excess gap introduced by a tall index mBoundingMetrics.ascent = indexRaisedAscent; nscoord descent = aDesiredSize.Height() - aDesiredSize.TopAscent(); aDesiredSize.SetTopAscent(mBoundingMetrics.ascent + leading); aDesiredSize.Height() = aDesiredSize.TopAscent() + descent; } nscoord dxIndex, dxSqr; GetRadicalXOffsets(bmIndex.width, bmSqr.width, fm, &dxIndex, &dxSqr); mBoundingMetrics.width = dxSqr + bmSqr.width + bmBase.width; mBoundingMetrics.leftBearing = std::min(dxIndex + bmIndex.leftBearing, dxSqr + bmSqr.leftBearing); mBoundingMetrics.rightBearing = dxSqr + bmSqr.width + std::max(bmBase.width, bmBase.rightBearing); aDesiredSize.Width() = mBoundingMetrics.width; aDesiredSize.mBoundingMetrics = mBoundingMetrics; GatherAndStoreOverflow(&aDesiredSize); // place the index nscoord dx = dxIndex; nscoord dy = aDesiredSize.TopAscent() - (indexRaisedAscent + indexSize.TopAscent() - bmIndex.ascent); FinishReflowChild(indexFrame, aPresContext, indexSize, nullptr, MirrorIfRTL(aDesiredSize.Width(), indexSize.Width(), dx), dy, 0); // place the radical symbol and the radical bar dx = dxSqr; dy = indexClearance + leading; // leave a leading at the top mSqrChar.SetRect(nsRect(MirrorIfRTL(aDesiredSize.Width(), bmSqr.width, dx), dy, bmSqr.width, bmSqr.ascent + bmSqr.descent)); dx += bmSqr.width; mBarRect.SetRect(MirrorIfRTL(aDesiredSize.Width(), bmBase.width, dx), dy, bmBase.width, ruleThickness); // place the base dy = aDesiredSize.TopAscent() - baseSize.TopAscent(); FinishReflowChild(baseFrame, aPresContext, baseSize, nullptr, MirrorIfRTL(aDesiredSize.Width(), baseSize.Width(), dx), dy, 0); mReference.x = 0; mReference.y = aDesiredSize.TopAscent(); aStatus = NS_FRAME_COMPLETE; NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize); return NS_OK; }
MassChangerDemo::MassChangerDemo(hkDemoEnvironment* env) : hkDefaultPhysicsDemo(env) { // Disable warnings: hkError::getInstance().setEnabled(0xf0de4356, false); // 'Your m_contactRestingVelocity seems to be too small' // // Setup the camera // { hkVector4 from(0.0f, 8.0f, 24.0f); hkVector4 to (0.0f, 0.0f, 0.0f); hkVector4 up (0.0f, 1.0f, 0.0f); setupDefaultCameras( env, from, to, up ); } // // Create the world // { hkpWorldCinfo info; info.m_gravity.set(0.0f, -9.8f, 0.0f); info.setupSolverInfo(hkpWorldCinfo::SOLVER_TYPE_4ITERS_MEDIUM); info.m_collisionTolerance = 0.01f; info.m_contactRestingVelocity = 0.01f; //info.m_contactRestingVelocity = 10000.01f; m_world = new hkpWorld( info ); m_world->lock(); // Register ALL agents (though some may not be necessary) hkpAgentRegisterUtil::registerAllAgents(m_world->getCollisionDispatcher()); setupGraphics(); } // // Create the base // { hkVector4 baseSize( 15.0f, 0.3f, 15.0f); hkpConvexShape* shape = new hkpBoxShape( baseSize , 0 ); hkpRigidBodyCinfo ci; ci.m_shape = shape; ci.m_motionType = hkpMotion::MOTION_FIXED; m_world->addEntity( new hkpRigidBody( ci ) )->removeReference(); shape->removeReference(); } { // // The dimensions of the boxes etc. // const hkReal boxDim = 1.0f; // This is the size of the cubes const hkReal extBoxDim = 1.1f * boxDim; // This is an extended size (used to shorten the pendulums) const hkReal heightOffGround = 5.0f; // This is the height of the fixed box from the ground //create the shared properties/attributes for the boxes hkVector4 boxRadii(boxDim *.5f, boxDim *.5f, boxDim *.5f); hkpShape* boxShape = new hkpBoxShape( boxRadii , 0 ); hkpMassProperties massProperties; hkpInertiaTensorComputer::computeBoxVolumeMassProperties(boxRadii, 100.0f, massProperties); hkpRigidBodyCinfo boxInfo; boxInfo.m_inertiaTensor = massProperties.m_inertiaTensor; boxInfo.m_mass = massProperties.m_mass; boxInfo.m_shape = boxShape; boxInfo.m_qualityType = HK_COLLIDABLE_QUALITY_CRITICAL; boxInfo.m_motionType = hkpMotion::MOTION_BOX_INERTIA; // create four boxes, one fixed and above the base, two attached by springs // to either side of the fixed box, and one below it. // one of the pendulums will be in a higher position so that it hits the bottom // box later than the first // Note: only one of the "pendulum" boxes will be // able to influence the box on the ground (achieved // with mass changer utility) hkVector4 boxPos; // the box on the base { boxPos.set(0.0f,boxDim,0.0f,0.0f); boxInfo.m_position = boxPos; hkpRigidBody* boxRigidBody = new hkpRigidBody(boxInfo); m_bodies[0] = boxRigidBody; // Now add to world. Body is "ready to go" as soon as this is called, and display // is (as a registered listener) automatically notified to build a new display object. m_world->addEntity( boxRigidBody ); boxRigidBody->removeReference(); // Remove reference, since we no longer want to remember this } // the pendulum boxes, number 1 { float offset = hkMath::sqrtInverse(2.0f) * (heightOffGround - extBoxDim); boxPos.set( offset, heightOffGround + offset , 0.0f, 0.0f ); boxInfo.m_position = boxPos; hkpRigidBody* boxRigidBody = new hkpRigidBody(boxInfo); m_bodies[1] = boxRigidBody; m_world->addEntity( boxRigidBody ); boxRigidBody->removeReference(); // Remove reference, since we no longer want to remember this } // the pendulum boxes, number 2 { boxPos.set(-heightOffGround + extBoxDim,heightOffGround,0.0f,0.0f); boxInfo.m_position = boxPos; hkpRigidBody* boxRigidBody = new hkpRigidBody(boxInfo); m_bodies[2] = boxRigidBody; m_world->addEntity( boxRigidBody ); boxRigidBody->removeReference(); // Remove reference, since we no longer want to remember this } // the fixed box { boxPos.set(0.0f,heightOffGround,0.0f,0.0f); boxInfo.m_position = boxPos; boxInfo.m_motionType = hkpMotion::MOTION_FIXED; boxInfo.m_qualityType = HK_COLLIDABLE_QUALITY_FIXED; hkpRigidBody* boxRigidBody = new hkpRigidBody(boxInfo); m_bodies[3] = boxRigidBody; m_world->addEntity( boxRigidBody ); boxRigidBody->removeReference(); // Remove reference, since we no longer want to remember this } // // create stiff spring constraint for pendulum 1 // { hkpStiffSpringConstraintData* spring = new hkpStiffSpringConstraintData(); // Create constraint spring->setInWorldSpace(m_bodies[3]->getTransform(), m_bodies[1]->getTransform(), m_bodies[3]->getPosition(), m_bodies[1]->getPosition()); m_world->createAndAddConstraintInstance( m_bodies[3], m_bodies[1], spring )->removeReference(); spring->removeReference(); } // // create stiff spring constraint for pendulum 2 // { // Create constraint hkpStiffSpringConstraintData* spring = new hkpStiffSpringConstraintData(); spring->setInWorldSpace(m_bodies[3]->getTransform(), m_bodies[2]->getTransform(), m_bodies[3]->getPosition(), m_bodies[2]->getPosition()); m_world->createAndAddConstraintInstance( m_bodies[3], m_bodies[2], spring )->removeReference(); spring->removeReference(); } //create a mass changer utility for the object const hkReal bodyARelInvMass = 0; const hkReal bodyBRelInvMass = 1; m_cmcu = new hkpCollisionMassChangerUtil( m_bodies[0], m_bodies[2], bodyARelInvMass, bodyBRelInvMass ); boxShape->removeReference(); } m_world->unlock(); }
/* virtual */ nsresult nsMathMLmencloseFrame::PlaceInternal(nsRenderingContext& aRenderingContext, bool aPlaceOrigin, nsHTMLReflowMetrics& aDesiredSize, bool aWidthOnly) { /////////////// // Measure the size of our content using the base class to format like an // inferred mrow. nsHTMLReflowMetrics baseSize(aDesiredSize.GetWritingMode()); nsresult rv = nsMathMLContainerFrame::Place(aRenderingContext, false, baseSize); if (NS_MATHML_HAS_ERROR(mPresentationData.flags) || NS_FAILED(rv)) { DidReflowChildren(GetFirstPrincipalChild()); return rv; } nsBoundingMetrics bmBase = baseSize.mBoundingMetrics; nscoord dx_left = 0, dx_right = 0; nsBoundingMetrics bmLongdivChar, bmRadicalChar; nscoord radicalAscent = 0, radicalDescent = 0; nscoord longdivAscent = 0, longdivDescent = 0; nscoord psi = 0; /////////////// // Thickness of bars and font metrics nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1); nscoord mEmHeight; nsRefPtr<nsFontMetrics> fm; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm)); aRenderingContext.SetFont(fm); GetRuleThickness(aRenderingContext, fm, mRuleThickness); GetEmHeight(fm, mEmHeight); char16_t one = '1'; nsBoundingMetrics bmOne = aRenderingContext.GetBoundingMetrics(&one, 1); /////////////// // General rules: the menclose element takes the size of the enclosed content. // We add a padding when needed. // determine padding & psi nscoord padding = 3 * mRuleThickness; nscoord delta = padding % onePixel; if (delta) padding += onePixel - delta; // round up if (IsToDraw(NOTATION_LONGDIV) || IsToDraw(NOTATION_RADICAL)) { nscoord phi; // Rule 11, App. G, TeXbook // psi = clearance between rule and content if (NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags)) phi = fm->XHeight(); else phi = mRuleThickness; psi = mRuleThickness + phi / 4; delta = psi % onePixel; if (delta) psi += onePixel - delta; // round up } if (mRuleThickness < onePixel) mRuleThickness = onePixel; // Set horizontal parameters if (IsToDraw(NOTATION_ROUNDEDBOX) || IsToDraw(NOTATION_TOP) || IsToDraw(NOTATION_LEFT) || IsToDraw(NOTATION_BOTTOM) || IsToDraw(NOTATION_CIRCLE)) dx_left = padding; if (IsToDraw(NOTATION_ROUNDEDBOX) || IsToDraw(NOTATION_TOP) || IsToDraw(NOTATION_RIGHT) || IsToDraw(NOTATION_BOTTOM) || IsToDraw(NOTATION_CIRCLE)) dx_right = padding; // Set vertical parameters if (IsToDraw(NOTATION_RIGHT) || IsToDraw(NOTATION_LEFT) || IsToDraw(NOTATION_UPDIAGONALSTRIKE) || IsToDraw(NOTATION_UPDIAGONALARROW) || IsToDraw(NOTATION_DOWNDIAGONALSTRIKE) || IsToDraw(NOTATION_VERTICALSTRIKE) || IsToDraw(NOTATION_CIRCLE) || IsToDraw(NOTATION_ROUNDEDBOX) || IsToDraw(NOTATION_RADICAL) || IsToDraw(NOTATION_LONGDIV)) { // set a minimal value for the base height bmBase.ascent = std::max(bmOne.ascent, bmBase.ascent); bmBase.descent = std::max(0, bmBase.descent); } mBoundingMetrics.ascent = bmBase.ascent; mBoundingMetrics.descent = bmBase.descent; if (IsToDraw(NOTATION_ROUNDEDBOX) || IsToDraw(NOTATION_TOP) || IsToDraw(NOTATION_LEFT) || IsToDraw(NOTATION_RIGHT) || IsToDraw(NOTATION_CIRCLE)) mBoundingMetrics.ascent += padding; if (IsToDraw(NOTATION_ROUNDEDBOX) || IsToDraw(NOTATION_LEFT) || IsToDraw(NOTATION_RIGHT) || IsToDraw(NOTATION_BOTTOM) || IsToDraw(NOTATION_CIRCLE)) mBoundingMetrics.descent += padding; /////////////// // updiagonal arrow notation. We need enough space at the top right corner to // draw the arrow head. if (IsToDraw(NOTATION_UPDIAGONALARROW)) { // This is an estimate, see nsDisplayNotation::Paint for the exact head size nscoord arrowHeadSize = kArrowHeadSize * mRuleThickness; // We want that the arrow shaft strikes the menclose content and that the // arrow head does not overlap with that content. Hence we add some space // on the right. We don't add space on the top but only ensure that the // ascent is large enough. dx_right = std::max(dx_right, arrowHeadSize); mBoundingMetrics.ascent = std::max(mBoundingMetrics.ascent, arrowHeadSize); } /////////////// // circle notation: we don't want the ellipse to overlap the enclosed // content. Hence, we need to increase the size of the bounding box by a // factor of at least sqrt(2). if (IsToDraw(NOTATION_CIRCLE)) { double ratio = (sqrt(2.0) - 1.0) / 2.0; nscoord padding2; // Update horizontal parameters padding2 = ratio * bmBase.width; dx_left = std::max(dx_left, padding2); dx_right = std::max(dx_right, padding2); // Update vertical parameters padding2 = ratio * (bmBase.ascent + bmBase.descent); mBoundingMetrics.ascent = std::max(mBoundingMetrics.ascent, bmBase.ascent + padding2); mBoundingMetrics.descent = std::max(mBoundingMetrics.descent, bmBase.descent + padding2); } /////////////// // longdiv notation: if (IsToDraw(NOTATION_LONGDIV)) { if (aWidthOnly) { nscoord longdiv_width = mMathMLChar[mLongDivCharIndex]. GetMaxWidth(PresContext(), aRenderingContext); // Update horizontal parameters dx_left = std::max(dx_left, longdiv_width); } else { // Stretch the parenthesis to the appropriate height if it is not // big enough. nsBoundingMetrics contSize = bmBase; contSize.ascent = mRuleThickness; contSize.descent = bmBase.ascent + bmBase.descent + psi; // height(longdiv) should be >= height(base) + psi + mRuleThickness mMathMLChar[mLongDivCharIndex].Stretch(PresContext(), aRenderingContext, NS_STRETCH_DIRECTION_VERTICAL, contSize, bmLongdivChar, NS_STRETCH_LARGER, false); mMathMLChar[mLongDivCharIndex].GetBoundingMetrics(bmLongdivChar); // Update horizontal parameters dx_left = std::max(dx_left, bmLongdivChar.width); // Update vertical parameters longdivAscent = bmBase.ascent + psi + mRuleThickness; longdivDescent = std::max(bmBase.descent, (bmLongdivChar.ascent + bmLongdivChar.descent - longdivAscent)); mBoundingMetrics.ascent = std::max(mBoundingMetrics.ascent, longdivAscent); mBoundingMetrics.descent = std::max(mBoundingMetrics.descent, longdivDescent); } } /////////////// // radical notation: if (IsToDraw(NOTATION_RADICAL)) { nscoord *dx_leading = StyleVisibility()->mDirection ? &dx_right : &dx_left; if (aWidthOnly) { nscoord radical_width = mMathMLChar[mRadicalCharIndex]. GetMaxWidth(PresContext(), aRenderingContext); // Update horizontal parameters *dx_leading = std::max(*dx_leading, radical_width); } else { // Stretch the radical symbol to the appropriate height if it is not // big enough. nsBoundingMetrics contSize = bmBase; contSize.ascent = mRuleThickness; contSize.descent = bmBase.ascent + bmBase.descent + psi; // height(radical) should be >= height(base) + psi + mRuleThickness mMathMLChar[mRadicalCharIndex].Stretch(PresContext(), aRenderingContext, NS_STRETCH_DIRECTION_VERTICAL, contSize, bmRadicalChar, NS_STRETCH_LARGER, StyleVisibility()->mDirection); mMathMLChar[mRadicalCharIndex].GetBoundingMetrics(bmRadicalChar); // Update horizontal parameters *dx_leading = std::max(*dx_leading, bmRadicalChar.width); // Update vertical parameters radicalAscent = bmBase.ascent + psi + mRuleThickness; radicalDescent = std::max(bmBase.descent, (bmRadicalChar.ascent + bmRadicalChar.descent - radicalAscent)); mBoundingMetrics.ascent = std::max(mBoundingMetrics.ascent, radicalAscent); mBoundingMetrics.descent = std::max(mBoundingMetrics.descent, radicalDescent); } } /////////////// // if (IsToDraw(NOTATION_CIRCLE) || IsToDraw(NOTATION_ROUNDEDBOX) || (IsToDraw(NOTATION_LEFT) && IsToDraw(NOTATION_RIGHT))) { // center the menclose around the content (horizontally) dx_left = dx_right = std::max(dx_left, dx_right); } /////////////// // The maximum size is now computed: set the remaining parameters mBoundingMetrics.width = dx_left + bmBase.width + dx_right; mBoundingMetrics.leftBearing = std::min(0, dx_left + bmBase.leftBearing); mBoundingMetrics.rightBearing = std::max(mBoundingMetrics.width, dx_left + bmBase.rightBearing); aDesiredSize.Width() = mBoundingMetrics.width; aDesiredSize.SetTopAscent(std::max(mBoundingMetrics.ascent, baseSize.TopAscent())); aDesiredSize.Height() = aDesiredSize.TopAscent() + std::max(mBoundingMetrics.descent, baseSize.Height() - baseSize.TopAscent()); if (IsToDraw(NOTATION_LONGDIV) || IsToDraw(NOTATION_RADICAL)) { // get the leading to be left at the top of the resulting frame // this seems more reliable than using fm->GetLeading() on suspicious // fonts nscoord leading = nscoord(0.2f * mEmHeight); nscoord desiredSizeAscent = aDesiredSize.TopAscent(); nscoord desiredSizeDescent = aDesiredSize.Height() - aDesiredSize.TopAscent(); if (IsToDraw(NOTATION_LONGDIV)) { desiredSizeAscent = std::max(desiredSizeAscent, longdivAscent + leading); desiredSizeDescent = std::max(desiredSizeDescent, longdivDescent + mRuleThickness); } if (IsToDraw(NOTATION_RADICAL)) { desiredSizeAscent = std::max(desiredSizeAscent, radicalAscent + leading); desiredSizeDescent = std::max(desiredSizeDescent, radicalDescent + mRuleThickness); } aDesiredSize.SetTopAscent(desiredSizeAscent); aDesiredSize.Height() = desiredSizeAscent + desiredSizeDescent; } if (IsToDraw(NOTATION_CIRCLE) || IsToDraw(NOTATION_ROUNDEDBOX) || (IsToDraw(NOTATION_TOP) && IsToDraw(NOTATION_BOTTOM))) { // center the menclose around the content (vertically) nscoord dy = std::max(aDesiredSize.TopAscent() - bmBase.ascent, aDesiredSize.Height() - aDesiredSize.TopAscent() - bmBase.descent); aDesiredSize.SetTopAscent(bmBase.ascent + dy); aDesiredSize.Height() = aDesiredSize.TopAscent() + bmBase.descent + dy; } // Update mBoundingMetrics ascent/descent if (IsToDraw(NOTATION_TOP) || IsToDraw(NOTATION_RIGHT) || IsToDraw(NOTATION_LEFT) || IsToDraw(NOTATION_UPDIAGONALSTRIKE) || IsToDraw(NOTATION_UPDIAGONALARROW) || IsToDraw(NOTATION_DOWNDIAGONALSTRIKE) || IsToDraw(NOTATION_VERTICALSTRIKE) || IsToDraw(NOTATION_CIRCLE) || IsToDraw(NOTATION_ROUNDEDBOX)) mBoundingMetrics.ascent = aDesiredSize.TopAscent(); if (IsToDraw(NOTATION_BOTTOM) || IsToDraw(NOTATION_RIGHT) || IsToDraw(NOTATION_LEFT) || IsToDraw(NOTATION_UPDIAGONALSTRIKE) || IsToDraw(NOTATION_UPDIAGONALARROW) || IsToDraw(NOTATION_DOWNDIAGONALSTRIKE) || IsToDraw(NOTATION_VERTICALSTRIKE) || IsToDraw(NOTATION_CIRCLE) || IsToDraw(NOTATION_ROUNDEDBOX)) mBoundingMetrics.descent = aDesiredSize.Height() - aDesiredSize.TopAscent(); aDesiredSize.mBoundingMetrics = mBoundingMetrics; mReference.x = 0; mReference.y = aDesiredSize.TopAscent(); if (aPlaceOrigin) { ////////////////// // Set position and size of MathMLChars if (IsToDraw(NOTATION_LONGDIV)) mMathMLChar[mLongDivCharIndex].SetRect(nsRect(dx_left - bmLongdivChar.width, aDesiredSize.TopAscent() - longdivAscent, bmLongdivChar.width, bmLongdivChar.ascent + bmLongdivChar.descent)); if (IsToDraw(NOTATION_RADICAL)) { nscoord dx = (StyleVisibility()->mDirection ? dx_left + bmBase.width : dx_left - bmRadicalChar.width); mMathMLChar[mRadicalCharIndex].SetRect(nsRect(dx, aDesiredSize.TopAscent() - radicalAscent, bmRadicalChar.width, bmRadicalChar.ascent + bmRadicalChar.descent)); } mContentWidth = bmBase.width; ////////////////// // Finish reflowing child frames PositionRowChildFrames(dx_left, aDesiredSize.TopAscent()); } return NS_OK; }
CenterOfMassChangerDemo::CenterOfMassChangerDemo(hkDemoEnvironment* env) : hkDefaultPhysicsDemo(env) { // Disable warnings: hkError::getInstance().setEnabled(0xf0de4356, false); // 'Your m_contactRestingVelocity seems to be too small' // // Setup the camera // { hkVector4 from(0.0f, 8.0f, 24.0f); hkVector4 to (0.0f, 0.0f, 0.0f); hkVector4 up (0.0f, 1.0f, 0.0f); setupDefaultCameras( env, from, to, up ); } // // Create the world // { hkpWorldCinfo info; info.m_gravity.set(0.0f, -9.8f, 0.0f); info.setupSolverInfo(hkpWorldCinfo::SOLVER_TYPE_4ITERS_MEDIUM); info.m_solverIterations = 1; info.m_collisionTolerance = 0.01f; info.m_contactRestingVelocity = 0.01f; // simple response //info.m_contactRestingVelocity = 10000.01f; // solver-only response info.m_enableSimulationIslands = false; info.m_gravity.setZero4(); m_world = new hkpWorld( info ); m_world->lock(); // Register ALL agents (though some may not be necessary) hkpAgentRegisterUtil::registerAllAgents(m_world->getCollisionDispatcher()); setupGraphics(); } // // Create the base // { hkVector4 baseSize( 30.0f, 0.5f, 30.0f); hkpConvexShape* shape = new hkpBoxShape( baseSize , 0 ); hkpRigidBodyCinfo ci; ci.m_shape = shape; ci.m_motionType = hkpMotion::MOTION_FIXED; ci.m_position.set(0.0f, -0.5f, 0.0f); ci.m_friction = 0.0f; //m_world->addEntity( new hkpRigidBody( ci ) )->removeReference(); shape->removeReference(); } hkVector4 rowPositionOffset(0.0f, 0.0f, 2.0f); const int numRows = 10; for (int p = 0; p < numRows; p++) { // // Create 3 boxes // { hkpRigidBody* body; hkpRigidBodyCinfo boxInfo; //boxInfo.m_shape = new hkpCylinderShape(hkVector4::getZero(), hkVector4(0.0f, 0.3f, 0.0f), 0.6f, 0.0f); boxInfo.m_shape = new hkpSphereShape(0.6f); hkpInertiaTensorComputer::setShapeVolumeMassProperties(boxInfo.m_shape, 1.0f, boxInfo); boxInfo.m_qualityType = HK_COLLIDABLE_QUALITY_DEBRIS; boxInfo.m_motionType = hkpMotion::MOTION_BOX_INERTIA; boxInfo.m_friction = 0.0f; boxInfo.m_restitution = 1.0f;//hkReal(p)/hkReal(numRows-1); // box 0 // boxInfo.m_restitution = 0.0f; boxInfo.m_position.set(-5.0f, 0.0f, 0.0f); boxInfo.m_position.addMul4(hkReal(p), rowPositionOffset); boxInfo.m_rotation.setAxisAngle(hkVector4(0.0f, 0.0f, 1.0f), 180.0f * HK_REAL_DEG_TO_RAD); hkpRigidBody* hitBody = body = new hkpRigidBody(boxInfo); m_world->addEntity(body)->removeReference(); boxInfo.m_restitution = 1.0f;//hkReal(p)/hkReal(numRows-1); boxInfo.m_rotation.setIdentity(); // box 1 // boxInfo.m_position.set(0.0f, 0.0f, 0.0f); boxInfo.m_position.addMul4(hkReal(p), rowPositionOffset); hkpRigidBody* hittingBody = body = new hkpRigidBody(boxInfo); m_world->addEntity(body)->removeReference(); // box 2 // boxInfo.m_position.set( 10.0f, 0.0f, 0.0f); boxInfo.m_position.addMul4(hkReal(p), rowPositionOffset); boxInfo.m_linearVelocity.set(-10.0f, 0.0f, 0.0f); body = new hkpRigidBody(boxInfo); m_world->addEntity(body)->removeReference(); //hkVector4 comDisplacement(0.0f, 1.5f, 1.5f); hkVector4 comDisplacement(0.0f, 0.0f + 0.5f * hkReal(p), 0.0f); hkpCenterOfMassChangerUtil* cmcu = new hkpCenterOfMassChangerUtil( hittingBody, hitBody, hkVector4::getZero(), comDisplacement ); m_utils.pushBack(cmcu); boxInfo.m_shape->removeReference(); } } m_world->unlock(); }
/* virtual */ nsresult nsMathMLmunderoverFrame::Place(nsRenderingContext& aRenderingContext, bool aPlaceOrigin, nsHTMLReflowMetrics& aDesiredSize) { nsIAtom* tag = mContent->Tag(); if (NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags) && StyleFont()->mMathDisplay == NS_MATHML_DISPLAYSTYLE_INLINE) { //place like sub sup or subsup if (tag == nsGkAtoms::munderover_) { return nsMathMLmmultiscriptsFrame::PlaceMultiScript(PresContext(), aRenderingContext, aPlaceOrigin, aDesiredSize, this, 0, 0); } else if (tag == nsGkAtoms::munder_) { return nsMathMLmmultiscriptsFrame::PlaceMultiScript(PresContext(), aRenderingContext, aPlaceOrigin, aDesiredSize, this, 0, 0); } else { NS_ASSERTION(tag == nsGkAtoms::mover_, "mContent->Tag() not recognized"); return nsMathMLmmultiscriptsFrame::PlaceMultiScript(PresContext(), aRenderingContext, aPlaceOrigin, aDesiredSize, this, 0, 0); } } //////////////////////////////////// // Get the children's desired sizes nsBoundingMetrics bmBase, bmUnder, bmOver; nsHTMLReflowMetrics baseSize(aDesiredSize.GetWritingMode()); nsHTMLReflowMetrics underSize(aDesiredSize.GetWritingMode()); nsHTMLReflowMetrics overSize(aDesiredSize.GetWritingMode()); nsIFrame* overFrame = nullptr; nsIFrame* underFrame = nullptr; nsIFrame* baseFrame = mFrames.FirstChild(); underSize.SetBlockStartAscent(0); overSize.SetBlockStartAscent(0); bool haveError = false; if (baseFrame) { if (tag == nsGkAtoms::munder_ || tag == nsGkAtoms::munderover_) { underFrame = baseFrame->GetNextSibling(); } else if (tag == nsGkAtoms::mover_) { overFrame = baseFrame->GetNextSibling(); } } if (underFrame && tag == nsGkAtoms::munderover_) { overFrame = underFrame->GetNextSibling(); } if (tag == nsGkAtoms::munder_) { if (!baseFrame || !underFrame || underFrame->GetNextSibling()) { // report an error, encourage people to get their markups in order haveError = true; } } if (tag == nsGkAtoms::mover_) { if (!baseFrame || !overFrame || overFrame->GetNextSibling()) { // report an error, encourage people to get their markups in order haveError = true; } } if (tag == nsGkAtoms::munderover_) { if (!baseFrame || !underFrame || !overFrame || overFrame->GetNextSibling()) { // report an error, encourage people to get their markups in order haveError = true; } } if (haveError) { if (aPlaceOrigin) { ReportChildCountError(); } return ReflowError(aRenderingContext, aDesiredSize); } GetReflowAndBoundingMetricsFor(baseFrame, baseSize, bmBase); if (underFrame) { GetReflowAndBoundingMetricsFor(underFrame, underSize, bmUnder); } if (overFrame) { GetReflowAndBoundingMetricsFor(overFrame, overSize, bmOver); } nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1); //////////////////// // Place Children nsRefPtr<nsFontMetrics> fm; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm)); nscoord xHeight = fm->XHeight(); nscoord oneDevPixel = fm->AppUnitsPerDevPixel(); gfxFont* mathFont = fm->GetThebesFontGroup()->GetFirstMathFont(); nscoord ruleThickness; GetRuleThickness (aRenderingContext, fm, ruleThickness); nscoord correction = 0; GetItalicCorrection (bmBase, correction); // there are 2 different types of placement depending on // whether we want an accented under or not nscoord underDelta1 = 0; // gap between base and underscript nscoord underDelta2 = 0; // extra space beneath underscript if (!NS_MATHML_EMBELLISH_IS_ACCENTUNDER(mEmbellishData.flags)) { // Rule 13a, App. G, TeXbook nscoord bigOpSpacing2, bigOpSpacing4, bigOpSpacing5, dummy; GetBigOpSpacings (fm, dummy, bigOpSpacing2, dummy, bigOpSpacing4, bigOpSpacing5); if (mathFont) { // XXXfredw The Open Type MATH table has some StretchStack* parameters // that we may use when the base is a stretchy horizontal operator. See // bug 963131. bigOpSpacing2 = mathFont->GetMathConstant(gfxFontEntry::LowerLimitGapMin, oneDevPixel); bigOpSpacing4 = mathFont->GetMathConstant(gfxFontEntry::LowerLimitBaselineDropMin, oneDevPixel); bigOpSpacing5 = 0; } underDelta1 = std::max(bigOpSpacing2, (bigOpSpacing4 - bmUnder.ascent)); underDelta2 = bigOpSpacing5; } else { // No corresponding rule in TeXbook - we are on our own here // XXX tune the gap delta between base and underscript // XXX Should we use Rule 10 like \underline does? // XXXfredw Perhaps use the Underbar* parameters of the MATH table. See // bug 963125. underDelta1 = ruleThickness + onePixel/2; underDelta2 = ruleThickness; } // empty under? if (!(bmUnder.ascent + bmUnder.descent)) { underDelta1 = 0; underDelta2 = 0; } nscoord overDelta1 = 0; // gap between base and overscript nscoord overDelta2 = 0; // extra space above overscript if (!NS_MATHML_EMBELLISH_IS_ACCENTOVER(mEmbellishData.flags)) { // Rule 13a, App. G, TeXbook // XXXfredw The Open Type MATH table has some StretchStack* parameters // that we may use when the base is a stretchy horizontal operator. See // bug 963131. nscoord bigOpSpacing1, bigOpSpacing3, bigOpSpacing5, dummy; GetBigOpSpacings (fm, bigOpSpacing1, dummy, bigOpSpacing3, dummy, bigOpSpacing5); if (mathFont) { // XXXfredw The Open Type MATH table has some StretchStack* parameters // that we may use when the base is a stretchy horizontal operator. See // bug 963131. bigOpSpacing1 = mathFont->GetMathConstant(gfxFontEntry::UpperLimitGapMin, oneDevPixel); bigOpSpacing3 = mathFont->GetMathConstant(gfxFontEntry::UpperLimitBaselineRiseMin, oneDevPixel); bigOpSpacing5 = 0; } overDelta1 = std::max(bigOpSpacing1, (bigOpSpacing3 - bmOver.descent)); overDelta2 = bigOpSpacing5; // XXX This is not a TeX rule... // delta1 (as computed abvove) can become really big when bmOver.descent is // negative, e.g., if the content is &OverBar. In such case, we use the height if (bmOver.descent < 0) overDelta1 = std::max(bigOpSpacing1, (bigOpSpacing3 - (bmOver.ascent + bmOver.descent))); } else { // Rule 12, App. G, TeXbook // We are going to modify this rule to make it more general. // The idea behind Rule 12 in the TeXBook is to keep the accent // as close to the base as possible, while ensuring that the // distance between the *baseline* of the accent char and // the *baseline* of the base is atleast x-height. // The idea is that for normal use, we would like all the accents // on a line to line up atleast x-height above the baseline // if possible. // When the ascent of the base is >= x-height, // the baseline of the accent char is placed just above the base // (specifically, the baseline of the accent char is placed // above the baseline of the base by the ascent of the base). // For ease of implementation, // this assumes that the font-designer designs accents // in such a way that the bottom of the accent is atleast x-height // above its baseline, otherwise there will be collisions // with the base. Also there should be proper padding between // the bottom of the accent char and its baseline. // The above rule may not be obvious from a first // reading of rule 12 in the TeXBook !!! // The mathml <mover> tag can use accent chars that // do not follow this convention. So we modify TeX's rule // so that TeX's rule gets subsumed for accents that follow // TeX's convention, // while also allowing accents that do not follow the convention : // we try to keep the *bottom* of the accent char atleast x-height // from the baseline of the base char. we also slap on an extra // padding between the accent and base chars. overDelta1 = ruleThickness + onePixel/2; nscoord accentBaseHeight = xHeight; if (mathFont) { accentBaseHeight = mathFont->GetMathConstant(gfxFontEntry::AccentBaseHeight, oneDevPixel); } if (bmBase.ascent < accentBaseHeight) { // also ensure at least accentBaseHeight above the baseline of the base overDelta1 += accentBaseHeight - bmBase.ascent; } overDelta2 = ruleThickness; } // empty over? if (!(bmOver.ascent + bmOver.descent)) { overDelta1 = 0; overDelta2 = 0; } nscoord dxBase = 0, dxOver = 0, dxUnder = 0; nsAutoString valueAlign; enum { center, left, right } alignPosition = center; if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::align, valueAlign)) { if (valueAlign.EqualsLiteral("left")) { alignPosition = left; } else if (valueAlign.EqualsLiteral("right")) { alignPosition = right; } } ////////// // pass 1, do what <mover> does: attach the overscript on the base // Ad-hoc - This is to override fonts which have ready-made _accent_ // glyphs with negative lbearing and rbearing. We want to position // the overscript ourselves nscoord overWidth = bmOver.width; if (!overWidth && (bmOver.rightBearing - bmOver.leftBearing > 0)) { overWidth = bmOver.rightBearing - bmOver.leftBearing; dxOver = -bmOver.leftBearing; } if (NS_MATHML_EMBELLISH_IS_ACCENTOVER(mEmbellishData.flags)) { mBoundingMetrics.width = bmBase.width; if (alignPosition == center) { dxOver += correction; } } else { mBoundingMetrics.width = std::max(bmBase.width, overWidth); if (alignPosition == center) { dxOver += correction/2; } } if (alignPosition == center) { dxOver += (mBoundingMetrics.width - overWidth)/2; dxBase = (mBoundingMetrics.width - bmBase.width)/2; } else if (alignPosition == right) { dxOver += mBoundingMetrics.width - overWidth; dxBase = mBoundingMetrics.width - bmBase.width; } mBoundingMetrics.ascent = bmBase.ascent + overDelta1 + bmOver.ascent + bmOver.descent; mBoundingMetrics.descent = bmBase.descent; mBoundingMetrics.leftBearing = std::min(dxBase + bmBase.leftBearing, dxOver + bmOver.leftBearing); mBoundingMetrics.rightBearing = std::max(dxBase + bmBase.rightBearing, dxOver + bmOver.rightBearing); ////////// // pass 2, do what <munder> does: attach the underscript on the previous // result. We conceptually view the previous result as an "anynomous base" // from where to attach the underscript. Hence if the underscript is empty, // we should end up like <mover>. If the overscript is empty, we should // end up like <munder>. nsBoundingMetrics bmAnonymousBase = mBoundingMetrics; nscoord ascentAnonymousBase = std::max(mBoundingMetrics.ascent + overDelta2, overSize.BlockStartAscent() + bmOver.descent + overDelta1 + bmBase.ascent); ascentAnonymousBase = std::max(ascentAnonymousBase, baseSize.BlockStartAscent()); // Width of non-spacing marks is zero so use left and right bearing. nscoord underWidth = bmUnder.width; if (!underWidth) { underWidth = bmUnder.rightBearing - bmUnder.leftBearing; dxUnder = -bmUnder.leftBearing; } nscoord maxWidth = std::max(bmAnonymousBase.width, underWidth); if (alignPosition == center && !NS_MATHML_EMBELLISH_IS_ACCENTUNDER(mEmbellishData.flags)) { GetItalicCorrection(bmAnonymousBase, correction); dxUnder += -correction/2; } nscoord dxAnonymousBase = 0; if (alignPosition == center) { dxUnder += (maxWidth - underWidth)/2; dxAnonymousBase = (maxWidth - bmAnonymousBase.width)/2; } else if (alignPosition == right) { dxUnder += maxWidth - underWidth; dxAnonymousBase = maxWidth - bmAnonymousBase.width; } // adjust the offsets of the real base and overscript since their // final offsets should be relative to us... dxOver += dxAnonymousBase; dxBase += dxAnonymousBase; mBoundingMetrics.width = std::max(dxAnonymousBase + bmAnonymousBase.width, dxUnder + bmUnder.width); // At this point, mBoundingMetrics.ascent = bmAnonymousBase.ascent mBoundingMetrics.descent = bmAnonymousBase.descent + underDelta1 + bmUnder.ascent + bmUnder.descent; mBoundingMetrics.leftBearing = std::min(dxAnonymousBase + bmAnonymousBase.leftBearing, dxUnder + bmUnder.leftBearing); mBoundingMetrics.rightBearing = std::max(dxAnonymousBase + bmAnonymousBase.rightBearing, dxUnder + bmUnder.rightBearing); aDesiredSize.SetBlockStartAscent(ascentAnonymousBase); aDesiredSize.Height() = aDesiredSize.BlockStartAscent() + std::max(mBoundingMetrics.descent + underDelta2, bmAnonymousBase.descent + underDelta1 + bmUnder.ascent + underSize.Height() - underSize.BlockStartAscent()); aDesiredSize.Height() = std::max(aDesiredSize.Height(), aDesiredSize.BlockStartAscent() + baseSize.Height() - baseSize.BlockStartAscent()); aDesiredSize.Width() = mBoundingMetrics.width; aDesiredSize.mBoundingMetrics = mBoundingMetrics; mReference.x = 0; mReference.y = aDesiredSize.BlockStartAscent(); if (aPlaceOrigin) { nscoord dy; // place overscript if (overFrame) { dy = aDesiredSize.BlockStartAscent() - mBoundingMetrics.ascent + bmOver.ascent - overSize.BlockStartAscent(); FinishReflowChild (overFrame, PresContext(), overSize, nullptr, dxOver, dy, 0); } // place base dy = aDesiredSize.BlockStartAscent() - baseSize.BlockStartAscent(); FinishReflowChild (baseFrame, PresContext(), baseSize, nullptr, dxBase, dy, 0); // place underscript if (underFrame) { dy = aDesiredSize.BlockStartAscent() + mBoundingMetrics.descent - bmUnder.descent - underSize.BlockStartAscent(); FinishReflowChild (underFrame, PresContext(), underSize, nullptr, dxUnder, dy, 0); } } return NS_OK; }
ThreeWaySqueezeDemo::ThreeWaySqueezeDemo(hkDemoEnvironment* env): hkDefaultPhysicsDemo(env) { // Disable warning hkError::getInstance().setEnabled(0xf0de4356, false); // 'Your m_contactRestingVelocity seems to be too small' // // Setup the camera // { hkVector4 from(0.0f, 10.0f, 10.0f); hkVector4 to (0.0f, 0.0f, 0.0f); hkVector4 up (0.0f, 1.0f, 0.0f); setupDefaultCameras( env, from, to, up ); } // // Create the world // { hkpWorldCinfo info; info.setupSolverInfo( hkpWorldCinfo::SOLVER_TYPE_4ITERS_MEDIUM ); info.setBroadPhaseWorldSize( 350.0f ); info.m_gravity.set(0,-40,0); info.m_collisionTolerance = 0.1f; info.m_numToisTillAllowedPenetrationToi = 1.1f; m_world = new hkpWorld( info ); m_world->lock(); hkpAgentRegisterUtil::registerAllAgents(m_world->getCollisionDispatcher()); setupGraphics(); } { hkpCollisionFilter* cf = new My3WCollisionFilter(); m_world->setCollisionFilter(cf); cf->removeReference(); } // Build a Base hkVector4 baseSize( 50.0f, 1.0f, 50.0f); { hkpRigidBodyCinfo rci; rci.m_shape = new hkpBoxShape( baseSize ); rci.m_position.set(0.0f, -0.5f, 0.0f); rci.m_motionType = hkpMotion::MOTION_FIXED; // Create a rigid body (using the template above). hkpRigidBody* base = new hkpRigidBody(rci); // Remove reference since the body now "owns" the Shape. rci.m_shape->removeReference(); // Finally add body so we can see it, and remove reference since the world now "owns" it. m_world->addEntity( base )->removeReference(); } // Create a circle of keyframed objects // Each of the objects is given a different increasing priority // We set the priority as a property on the object and extract this i nthe callback. hkVector4 blockerSize(1,3,5); hkpShape* blocker = new hkpBoxShape( blockerSize ); { //hkPseudoRandomGenerator ran(100); for (int b = 0; b < NUM_OBJECTS; b++ ) { hkVector4 up(0,1,0); hkReal angle = hkReal(b) / NUM_OBJECTS * HK_REAL_PI * 2; hkpRigidBodyCinfo rci; rci.m_position.set(5,0,0); rci.m_rotation.setAxisAngle( up, angle ); rci.m_position.setRotatedDir( rci.m_rotation, rci.m_position ); rci.m_shape = blocker; // If we set this to true, the body is fixed, and no mass properties need to be computed. rci.m_motionType = hkpMotion::MOTION_KEYFRAMED; if (b < 1) { rci.m_qualityType = HK_COLLIDABLE_QUALITY_KEYFRAMED; } else { rci.m_qualityType = HK_COLLIDABLE_QUALITY_FIXED; } m_objects[b] = new hkpRigidBody( rci ); m_world->addEntity( m_objects[b] ); m_objects[b]->removeReference(); int color = rci.m_qualityType == HK_COLLIDABLE_QUALITY_FIXED ? hkColor::rgbFromFloats(1.0f, 0.0f, 0.0f, 1.0f) : hkColor::rgbFromFloats(0.0f, 1.0f, 0.0f, 1.0f) ; HK_SET_OBJECT_COLOR((hkUlong)m_objects[b]->getCollidable(), color ); } } blocker->removeReference(); // // Crate middle sphere // { hkpShape* shape = new hkpSphereShape(1.5f); hkpRigidBodyCinfo rbInfo; rbInfo.m_shape = shape; rbInfo.m_qualityType = HK_COLLIDABLE_QUALITY_CRITICAL; hkpRigidBody* body = new hkpRigidBody(rbInfo); m_world->addEntity(body); body->removeReference(); shape->removeReference(); } m_prevObj = 0; // Zero current time at start m_currentTime = 0.0f; m_world->unlock(); }