void RectLayer::updateFillPath() { QPainterPath path; switch (shapeType()) { default: case ShapeTypeRect: path.addRect(rect()); break; case ShapeTypeEllipse: path.addEllipse(rect()); break; } this->setFillPath(path); }
int main( int argc, char* argv[] ) { osg::ArgumentParser arguments( &argc, argv ); const std::string appName = osgDB::getSimpleFileName( arguments.getApplicationName() ); arguments.getApplicationUsage()->setApplicationName( appName ); arguments.getApplicationUsage()->setDescription( appName + " creates a rigid body from model files and tests it in a physics simulation." ); arguments.getApplicationUsage()->setCommandLineUsage( appName + " [options] filename ..." ); arguments.getApplicationUsage()->addCommandLineOption( "--com <x>,<y>,<z>", "Specifies the center of mass. If not specified, osgbpp uses the center of the OSG bounding sphere." ); arguments.getApplicationUsage()->addCommandLineOption( "--box", "This is the default. Creates a box collision shape." ); arguments.getApplicationUsage()->addCommandLineOption( "--sphere", "Creates a sphere collision shape." ); arguments.getApplicationUsage()->addCommandLineOption( "--cylinder", "Creates a cylinder collision shape." ); arguments.getApplicationUsage()->addCommandLineOption( "--axis <a>", "Use this option to specify the cylinder axis X, Y, or Z. Default is Z. This argument is ignored if --cylinder is not specified." ); arguments.getApplicationUsage()->addCommandLineOption( "--triMesh", "It creates a tri mesh collision shape (suitable for static objects)." ); arguments.getApplicationUsage()->addCommandLineOption( "--convexTM", "Creates a convex tri mesh collision shape." ); arguments.getApplicationUsage()->addCommandLineOption( "--convexHull", "Creates a convex hull collision shape." ); arguments.getApplicationUsage()->addCommandLineOption( "--mass <n>", "Specifies the desired rigid body mass value. The default is 1.0." ); arguments.getApplicationUsage()->addCommandLineOption( "--debug", "Use the GLDebugDrawer class to display collision shapes." ); arguments.getApplicationUsage()->addCommandLineOption( "--overall", "Creates a single collision shape for the entire input scene graph, rather than a collision shape per Geode, which is the default." ); arguments.getApplicationUsage()->addCommandLineOption( "-h or --help", "Displays help text and command line documentation." ); arguments.getApplicationUsage()->addCommandLineOption( "-v or --version", "Display the osgBullet version string." ); if( arguments.read( "-v" ) || arguments.read( "--version" ) ) { osg::notify( osg::ALWAYS ) << osgbCollision::getVersionString() << std::endl; osg::notify( osg::ALWAYS ) << " (Bullet version " << BT_BULLET_VERSION; #ifdef BT_USE_DOUBLE_PRECISION osg::notify( osg::ALWAYS ) << " double precision"; #endif osg::notify( osg::ALWAYS ) << ")" << std::endl << std::endl; } const bool briefHelp = arguments.read( "-h" ); const bool fullHelp = arguments.read( "--help" ); if( briefHelp || fullHelp ) osg::notify( osg::ALWAYS ) << arguments.getApplicationUsage()->getDescription() << std::endl; if( briefHelp ) osg::notify( osg::ALWAYS ) << "Usage: " << arguments.getApplicationUsage()->getCommandLineUsage() << std::endl; else if( fullHelp ) arguments.getApplicationUsage()->write( osg::notify( osg::ALWAYS ), osg::ApplicationUsage::COMMAND_LINE_OPTION ); if( briefHelp || fullHelp ) osg::notify( osg::ALWAYS ) << "Use the Delete key to reset the physics simultation." << std::endl; if( arguments.argc() <= 1 ) { if( !briefHelp && !fullHelp ) arguments.getApplicationUsage()->write( osg::notify( osg::FATAL ), osg::ApplicationUsage::COMMAND_LINE_OPTION ); return 1; } // Get all arguments. BroadphaseNativeTypes shapeType( BOX_SHAPE_PROXYTYPE ); if( arguments.read( "--box" ) ) shapeType = BOX_SHAPE_PROXYTYPE; if( arguments.read( "--sphere" ) ) shapeType = SPHERE_SHAPE_PROXYTYPE; if( arguments.read( "--cylinder" ) ) shapeType = CYLINDER_SHAPE_PROXYTYPE; if( arguments.read( "--triMesh" ) ) shapeType = TRIANGLE_MESH_SHAPE_PROXYTYPE; if( arguments.read( "--convexTM" ) ) shapeType = CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE; if( arguments.read( "--convexHull" ) ) shapeType = CONVEX_HULL_SHAPE_PROXYTYPE; switch( shapeType ) { case BOX_SHAPE_PROXYTYPE: osg::notify( osg::INFO ) << "osgbpp: Box" << std::endl; break; case SPHERE_SHAPE_PROXYTYPE: osg::notify( osg::INFO ) << "osgbpp: Sphere" << std::endl; break; case CYLINDER_SHAPE_PROXYTYPE: osg::notify( osg::INFO ) << "osgbpp: Cylinder" << std::endl; break; case TRIANGLE_MESH_SHAPE_PROXYTYPE: osg::notify( osg::INFO ) << "osgbpp: TriMesh" << std::endl; break; case CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE: osg::notify( osg::INFO ) << "osgbpp: ConvexTriMesh" << std::endl; break; case CONVEX_HULL_SHAPE_PROXYTYPE: osg::notify( osg::INFO ) << "osgbpp: ConvexHull" << std::endl; break; default: osg::notify( osg::FATAL ) << "osgbpp: Error, unknown shape type, using tri mesh." << std::endl; shapeType = TRIANGLE_MESH_SHAPE_PROXYTYPE; break; } std::string str; osgbCollision::AXIS axis( osgbCollision::Z ); if ( arguments.read( "--axis", str ) ) { if( (str.find( "X" ) != str.npos) || (str.find( "x" ) != str.npos) ) axis = osgbCollision::X; else if( (str.find( "Y" ) != str.npos) || (str.find( "y" ) != str.npos) ) axis = osgbCollision::Y; else if( (str.find( "Z" ) != str.npos) || (str.find( "z" ) != str.npos) ) axis = osgbCollision::Z; else { arguments.getApplicationUsage()->write( osg::notify( osg::FATAL ) ); return 1; } } switch( axis ) { case osgbCollision::X: osg::notify( osg::INFO ) << "osgbpp: Axis: X" << std::endl; break; case osgbCollision::Y: osg::notify( osg::INFO ) << "osgbpp: Axis: Y" << std::endl; break; case osgbCollision::Z: osg::notify( osg::INFO ) << "osgbpp: Axis: Z" << std::endl; break; } float decimatorPercent( 1. ); float decimatorMaxError( FLT_MAX ); if ( arguments.read( "--decPercent", str ) ) { if( sscanf( str.c_str(), "%f", &decimatorPercent ) != 1 ) { arguments.getApplicationUsage()->write( osg::notify( osg::FATAL ) ); return 1; } if ( arguments.read( "--decMaxError", str ) ) { if( sscanf( str.c_str(), "%f", &decimatorMaxError ) != 1 ) { arguments.getApplicationUsage()->write( osg::notify( osg::FATAL ) ); return 1; } } } if (decimatorPercent != 1.f ) osg::notify( osg::INFO ) << "osgbpp: DecimatorOp: " << decimatorPercent << ", " << decimatorMaxError << std::endl; float simplifyPercent = 1.f; if ( arguments.read( "--simplify", str ) ) { if( sscanf( str.c_str(), "%f", &simplifyPercent ) != 1 ) { arguments.getApplicationUsage()->write( osg::notify( osg::FATAL ) ); return 1; } } if (simplifyPercent != 1.f ) osg::notify( osg::INFO ) << "osgbpp: Simplify: " << simplifyPercent << std::endl; unsigned int vertexAggMaxVerts( 0 ); osg::Vec3 vertexAggMinCellSize( 0., 0., 0. ); if ( arguments.read( "--aggMaxVerts", str ) ) { if( sscanf( str.c_str(), "%u", &vertexAggMaxVerts ) != 1 ) { arguments.getApplicationUsage()->write( osg::notify( osg::FATAL ) ); return 1; } if ( arguments.read( "--aggMinCellSize", str ) ) { char comma; std::istringstream oStr( str ); oStr >> vertexAggMinCellSize[ 0 ] >> comma >> vertexAggMinCellSize[ 1 ] >> comma >> vertexAggMinCellSize[ 2 ]; } }