void TexturePackPanel::OnExportGIFClicked(wxCommandEvent& event) { wxFileName exFileName(m_textureListBox->GetString(m_textureListBox->GetSelection()), wxPATH_UNIX); exFileName.SetExt("gif"); wxString defaultFileName = exFileName.GetFullName(); wxFileDialog fileDlg(this, _("Select target gif"), wxStandardPaths::Get().GetDocumentsDir(), defaultFileName, "*.gif", wxFD_SAVE | wxFD_OVERWRITE_PROMPT); if (fileDlg.ShowModal() == wxID_OK) { wxBusyCursor busyCursor; wxImageArray images; const Texture& tex = m_texturePack->at(m_textureListBox->GetSelection()); for (auto frame = tex.begin(); frame != tex.end(); ++frame) { wxImage frameImg(GetFrameBitmap(*frame).ConvertToImage()); wxQuantize::Quantize(frameImg, frameImg, 256); images.Add(frameImg); } wxGIFHandler* gifHandler = (wxGIFHandler*) wxImage::FindHandler(wxBITMAP_TYPE_GIF); wxTempFileOutputStream oStr(fileDlg.GetPath()); gifHandler->SaveAnimation(images, &oStr, true, m_frameDelaySpinCtrl->GetValue()); oStr.Commit(); } }
CStr CStr::operator+( const CStr &roStr ) const { const unsigned int uiSize0 = m_uiSize - 1; const unsigned int uiSize1 = roStr.m_uiSize - 1; CStr oStr( uiSize0 + uiSize1 ); Copy_( oStr.m_pcData, m_pcData, uiSize0 ); Copy_( oStr.m_pcData + uiSize0, roStr.m_pcData, uiSize1 ); oStr.m_pcData[oStr.m_uiSize-1] = '\0'; return oStr; }
CStr CStr::GetSub( unsigned int uiStart, unsigned int uiSize ) const { CStr oStr( *this ); oStr.Sub( uiStart, uiSize ); return oStr; }
CStr CStr::GetPop() const { CStr oStr( *this ); oStr.Pop(); return oStr; }
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 ]; } }
void NetworkInterface::wifiQuickConnect(QString SSID, QString netKey, QString DeviceName, bool WEPHex){ /* This function uses a set of defaults to connect to a wifi access point with a minimum of information from the user. It does *NOT* (currently) support the WPA-Enterprise encryption */ //do nothing if no SSID given if( SSID.isEmpty() ){ return; } QString tmp; QString ifConfigLine; //Set defaults for quick-connect ifConfigLine="DHCP"; //Use DHCP // Check if we need to enable the device config in rc.conf if ( Utils::getConfFileValue("/etc/rc.conf", "ifconfig_" + DeviceName).isEmpty()) { Utils::setConfFileValue( "/etc/rc.conf", "ifconfig_lagg0", "", -1); Utils::setConfFileValue( "/etc/rc.conf", "ifconfig_" + DeviceName, \ "ifconfig_" + DeviceName + "=\"WPA " + ifConfigLine + "\"", -1); } //Determine if the wpa_supplicant file exists already or is empty bool newWPASup = true; bool existingSSID = false; QStringList tmpFileList; QString tmpEntry; QFile fileout( "/etc/wpa_supplicant.conf" ); if( fileout.open( QIODevice::ReadOnly ) ){ QTextStream streamtmp(&fileout); streamtmp.setCodec("UTF-8"); QString line; bool inEntry = false; bool eStart, eEnd; while ( !streamtmp.atEnd() ) { eStart = false; eEnd = false; line = streamtmp.readLine(); if ( line.contains("ctrl_interface=/var/run/wpa_supplicant") ) { newWPASup = false; }else if(line.contains("ssid=") && line.contains(SSID)){ existingSSID=true; }else if(line.contains("network={")){eStart = true;} else if(line.contains("}")){eEnd = true; } //Save the file by entry temporarily if(eStart){ tmpEntry = line; inEntry = true; } else if(eEnd){ tmpEntry.append(" ::: "+line); tmpFileList << tmpEntry; inEntry=false; } else if(inEntry){ tmpEntry.append(" ::: "+line); } else{ tmpFileList << line; } } fileout.close(); } //If the desired SSID already has an entry, remove it from wpa_supplicant.conf if(existingSSID){ QFile tmpFile( "/etc/wpa_supplicant.conf.tmp" ); if(tmpFile.open(QIODevice::WriteOnly | QIODevice::Text )){ QTextStream oStr(&tmpFile); for(int i=0; i<tmpFileList.length(); i++){ if(tmpFileList[i].contains("network={")){ QStringList tmp = tmpFileList[i].split(" ::: "); //skip it if the new SSID int idx = tmp.indexOf("ssid="); if( (idx!= -1) && !tmp[idx].contains(SSID) ){ for(int j=0; j<tmp.length(); j++){ oStr << tmp[j] + "\n"; } } }else{ oStr << tmpFileList[i] + "\n"; } } } tmpFile.close(); Utils::runShellCommand("mv /etc/wpa_supplicant.conf.tmp /etc/wpa_supplicant.conf"); } // Create the wpa_supplicant file based on saved configuration if ( fileout.open( QIODevice::Append ) ) { QTextStream streamout( &fileout ); // Fix to prevent kernel panic if(newWPASup) streamout << "ctrl_interface=/var/run/wpa_supplicant\n\n"; //Use SSID for network connection streamout << "\nnetwork={\n ssid=\"" + SSID + "\"\n"; streamout << " priority=" << 146 << "\n"; streamout << " scan_ssid=1\n"; //Determine the security type for the given SSID QString SecType = getWifiSecurity(SSID,DeviceName); //Configure the wifi Security Settings for the proper type if ( SecType.contains("None") ){ streamout << " key_mgmt=NONE\n"; } else if ( SecType.contains("WEP") ) { //Set WEP Defaults int WEPIndex = 0; //bool WEPHex = true; //Use Hex WEP key streamout << " key_mgmt=NONE\n"; streamout << " wep_tx_keyidx=" + tmp.setNum(WEPIndex) + "\n"; // Check if we are using a plaintext WEP or not if ( WEPHex ) { streamout << " wep_key" + tmp.setNum(WEPIndex) + "=" + netKey + "\n"; } else { streamout << " wep_key" + tmp.setNum(WEPIndex) + "=\"" + netKey + "\"\n"; } } else if ( SecType.contains("WPA") ) { streamout << " psk=\"" + netKey + "\"\n"; } streamout << "}\n\n"; fileout.close(); } // Flush to disk, so that when we restart network it picks up the changes sync(); Utils::restartNetworking(); return; }
int main( int argc, char* argv[] ) { osg::ArgumentParser arguments( &argc, argv ); arguments.getApplicationUsage()->setApplicationName( arguments.getApplicationName() ); arguments.getApplicationUsage()->setCommandLineUsage( arguments.getApplicationName() + " [options] filename ..." ); arguments.getApplicationUsage()->addCommandLineOption( "--reducer", "Use ReducerOp." ); arguments.getApplicationUsage()->addCommandLineOption( "--shortedge", "Use ShortEdgeOp." ); arguments.getApplicationUsage()->addCommandLineOption( "--decPercent <n>", "Use DecimatorOp (also valid parameter for ShortEdgeOp). <n> is the target percentage of triangles to remain, in the range 0.0 to 1.0. Default 0.6" ); arguments.getApplicationUsage()->addCommandLineOption( "--decMaxError <n>", "Specifies the Decimator maximum error tolerance. Geometry exceeding this tolerance is not reduced. <n> is in the range 0.0 to FLT_MAX. Default FLT_MAX" ); arguments.getApplicationUsage()->addCommandLineOption( "--respectBoundaries", "Will not decimate boundary polygons, will not decimate fully but may fix some mesh errors. Default False" ); arguments.getApplicationUsage()->addCommandLineOption( "--minPrimitives <n>", "Sets the minimum primitives a geometry must have to start Decimation. Default 1." ); arguments.getApplicationUsage()->addCommandLineOption( "--maxFeature <n>", "Specifies the ShortEdgeOp largest feature size to be removed, measured in model units. Can be combined with decPercent to limit the decimation using ShortEdgeOp. Default 0.1" ); arguments.getApplicationUsage()->addCommandLineOption( "--attemptMerge <n>", "Attempts to merge drawables within the model prior to any geometry reduction using a MergeGeometryVisitor. In cases where there are multiple drawables, more functional decimation may result. Default False" ); arguments.getApplicationUsage()->addCommandLineOption( "--numParts <n>", "Controls the geometry building process if user chooses to use a model built in software (see GeometryModifier.h). numParts controls the geometry and can be used to test different aspects of the decimation routines. Default 3. Range 0-4." ); arguments.getApplicationUsage()->addCommandLineOption( "--attemptMerge <n>", "Attempt to merge geometry drawables into one using Optimizer::MergeGeometryVisitor before using specified geometry reduction operator." ); arguments.getApplicationUsage()->addKeyboardMouseBinding("1","Decimate one edge."); arguments.getApplicationUsage()->addKeyboardMouseBinding("2","Decimate two edges."); arguments.getApplicationUsage()->addKeyboardMouseBinding("5","Decimate five edges."); arguments.getApplicationUsage()->addKeyboardMouseBinding("d","Decimate 10 edges."); arguments.getApplicationUsage()->addKeyboardMouseBinding("c","Decimate 100 edges."); arguments.getApplicationUsage()->addKeyboardMouseBinding("k","Decimate 1000 edges."); arguments.getApplicationUsage()->addKeyboardMouseBinding("r","Restore original model, discard decimation."); arguments.getApplicationUsage()->addKeyboardMouseBinding("u","Undo/Restore last decimation step(s)."); arguments.getApplicationUsage()->addKeyboardMouseBinding("y","Swap display between decimated model and original."); bool useReducer( arguments.find( "--reducer" ) >= 0 ); bool useShortEdge( arguments.find( "--shortedge" ) >= 0 ); if( arguments.read( "-h" ) || arguments.read( "--help" ) ) { arguments.getApplicationUsage()->write( osg::notify( osg::ALWAYS ), osg::ApplicationUsage::COMMAND_LINE_OPTION ); return 1; } if (arguments.errors()) { arguments.writeErrorMessages( osg::notify( osg::FATAL ) ); return 1; } float decimatorPercent( .6 ); std::string str; if ( arguments.read( "--decPercent", str ) ) { if( sscanf( str.c_str(), "%f", &decimatorPercent ) != 1 ) { arguments.getApplicationUsage()->write( osg::notify( osg::FATAL ) ); return 1; } } float decimatorMaxError( FLT_MAX ); if ( arguments.read( "--decMaxError", str ) ) { if( sscanf( str.c_str(), "%f", &decimatorMaxError ) != 1 ) { arguments.getApplicationUsage()->write( osg::notify( osg::FATAL ) ); return 1; } } bool decimatorIgnoreBoundaries = (true); if (arguments.read( "--respectBoundaries" )) decimatorIgnoreBoundaries = false; int minprim(1); if (arguments.read("--minPrimitives", str)) { if( sscanf( str.c_str(), "%u", &minprim ) != 1 ) { arguments.getApplicationUsage()->write( osg::notify( osg::FATAL ) ); return 1; } } if (decimatorPercent < 1.f ) osg::notify( osg::INFO ) << "DecimatorOp: " << decimatorPercent << ", " << decimatorMaxError << std::endl; float shortEdgeFeature( .1 ); if ( arguments.read( "--maxFeature", str ) ) { if( sscanf( str.c_str(), "%f", &shortEdgeFeature ) != 1 ) { arguments.getApplicationUsage()->write( osg::notify( osg::FATAL ) ); return 1; } } bool attemptMerge = (false); if (arguments.read( "--attemptMerge" )) attemptMerge = true; bool useAgg = false; unsigned int aggMaxVerticies( 0 ); osg::Vec3 aggMinCellSize( 0., 0., 0. ); if(arguments.read( "--aggMaxVerts", str) ) { if( sscanf( str.c_str(), "%u", &aggMaxVerticies) != 1 ) { arguments.getApplicationUsage()->write( osg::notify( osg::FATAL ) ); } useAgg = true; if ( arguments.read( "--aggMinCellSize", str ) ) { char comma; std::istringstream oStr( str ); oStr >> aggMinCellSize[ 0 ] >> comma >> aggMinCellSize[ 1 ] >> comma >> aggMinCellSize[ 2 ]; } }
int main(int argc, char *argv[]) { Ensemble ensemble; // Note that ensemble is internally converted to pointer-type SyncFiles syncFiles(ensemble); std::string noteOpts; // Annotation *notes=0; std::string annotText; std::string outputText; std::string path; if( argc == 1 ) { syncFiles.description(); return 3; } GetOpt opt; opt.opterr=0; int copt; std::string str; std::string str0; std::string oStr("Ad:Ehl:mMP:p:St:T"); oStr += "<--only-marked>"; oStr += "<--help>"; oStr += "<--line-feed>:"; oStr += "<--note>:"; while( (copt = opt.getopt(argc, argv, oStr.c_str() )) != -1 ) { if( opt.longOption > 0 ) { str0=opt.longOption; if( str0 == "--help" ) { syncFiles.description(); return 3; } if( str0 == "--line-feed" ) { syncFiles.enableNewLine(opt.optarg); continue; } if( str0 == "--note" ) { noteOpts=opt.optarg; continue; } if( str0 == "--only-marked" ) { syncFiles.isPrintOnlyMarked=true; continue; } } switch ( copt ) { case 'A': //obsolete break; case 'd': { str0=opt.optarg; std::string str("_"); size_t p=0; if( (p=str0.find('/')) < std::string::npos ) str = str0.replace(p, 0, "_") ; // is a range else if( (p=str0.find('-')) < std::string::npos ) str = str0.replace(p, 0, "_") ; // is a range else if( hdhC::isNumber(str0) ) str += str0 ; // end time else return 3; syncFiles.setTimeLimit(str) ; } break; case 'E': syncFiles.enablePrintEnsemble(); break; case 'h': syncFiles.description(); return 3; break; case 'l': syncFiles.setTimeLimit(opt.optarg); break; case 'm': syncFiles.enableMixingRefused(); break; case 'M': syncFiles.enableModificationTimeTest(); break; case 'P': path = opt.optarg ; syncFiles.setPath(path) ; break; case 'p': syncFiles.setQA_target(opt.optarg) ; break; case 'S': // printing date range of each file in output requested syncFiles.enablePrintDateRange(); break; case 't': { str0=opt.optarg; std::string str("/"); size_t p=0; if( (p=str0.find('-')) < std::string::npos ) str = str0.replace(p, 0, "/") ; // is a range else if( (p=str0.find('/')) < std::string::npos ) str = str0 ; // is a range separated by '/' else if( hdhC::isNumber(str0) ) str += str0 ; // end time else return 3; syncFiles.setTimeLimit(str) ; } break; case 'T': syncFiles.enablePrintTotalTimeRange() ; break; default: std::ostringstream ostr(std::ios::app); ostr << "syncFiles:getopt() unknown option -" ; ostr << copt; ostr << "\nreturned option -" << copt ; std::cout << ostr.str() << std::endl ; break; } } // Note= argc counts from 1, but argv[0] == this executable if( opt.optind == argc ) syncFiles.readInput(); else syncFiles.readArgv(opt.optind, argc, argv); // this does all return syncFiles.run(); }