void ImageDialog::savePic() { //Change NetPicName if(currentSavePath.isNull()) { if(access("D:/Netpics", 0) == -1) { mkdir("D:\\Netpics"); mkdir("D:\\Netpics\\MyPics"); currentSavePath="D:/Netpics/MyPics"; } else { mkdir("D:\\Netpics\\MyPics"); currentSavePath="D:/Netpics/MyPics"; } //return 0; } QString tempcurrentSavePath(currentSavePath); NetPicName=tempcurrentSavePath.append(QString("/RawH%1.raw").arg(QString::number(NetFileIndex), 3, QLatin1Char('0'))); QFile streamfile(NetPicName); bool OpenOk=streamfile.open(QIODevice::WriteOnly); if(!OpenOk) { QMessageBox::information(this,tr("file"),tr("Can't open The File")); return; } streamfile.write((char*)tjImage.unCorrectedRaw, tjImage.imageSize); // streamfile.write((char*)(&tjSafeJointData),sizeof(SafeJointData)); // streamfile.write((char*)(&tjSafeSensorData),sizeof(SafeSensorData)); /*******************************************/ for (int i=0;i<SafeJointData::numOfJoints;i++) { streamfile.write((char*)(&tjSafeJointData.angles[i]),sizeof(double)); } streamfile.write((char*)(&tjSafeJointData.timeStamp),sizeof(unsigned)); /********************************************/ for (int i=0;i<SafeSensorData::numOfSensors;i++) { streamfile.write((char*)(&tjSafeSensorData.data[i]),sizeof(float)); } for(int i = 0; i < SafeJointData::numOfJoints; ++i) { streamfile.write((char*)(&tjSafeSensorData.loads[i]),sizeof(float)); streamfile.write((char*)(&tjSafeSensorData.temperatures[i]),sizeof(float)); } streamfile.write((char*)(&tjSafeSensorData.timeStamp),sizeof(unsigned)); /**********************************************/ emit updateWindowTitle(tr("Image ***NetPic*** ").append(NetPicName)); //存动作值 streamfile.close(); NetFileIndex++; update(); show(); raise(); activateWindow(); }
//========================================================================== int main(int argc, char* argv[]){ if(argc < 2) { std::cout << "No command line argument supplied\n"; help(); return 1; } std::string streamfile(argv[1]); std::string outfile("/dev/null"); if(argc == 3) { outfile = argv[2]; } readfile(streamfile, outfile); std::cout << "\n\nDiagStreamerFile TEST DONE\n" << std::endl; return 0; }
//------------------------------------------------------------------------------------- void SceneLoader::load(std::string filename, Scene* scene) { try { Ogre::FileInfoListPtr files = Ogre::ResourceGroupManager::getSingletonPtr()->findResourceFileInfo("Essential", filename); if(files->size() < 1) throw NHException("could not find the path to the specified scene"); std::string filePath = files->front().archive->getName() + "/" + files->front().filename; std::ifstream streamfile(filePath); rapidxml::xml_document<> doc; std::vector<char> buffer((std::istreambuf_iterator<char>(streamfile)), std::istreambuf_iterator<char>());//streamfile)), std::istreambuf_iterator<char>()); buffer.push_back('\0');//null terminating the buffer //std::cout << &buffer[0] << std::endl; //test the buffer doc.parse<0>(&buffer[0]); rapidxml::xml_node<>* root = doc.first_node(SCENE_STRING);//"scene"); scene->getSceneGraphicsManager()->setAmbientLight(getXMLColour(root, AMBIENT_RED_STRING, AMBIENT_GREEN_STRING, AMBIENT_BLUE_STRING)); //description attributes //north = boost::lexical_cast<float>(root->first_attribute(NORTH_STRING)->value()); //Architecture rapidxml::xml_node<>* architectureNode = root->first_node(ARCHITECTURE_STRING);//"architecture"); while(architectureNode != NULL) { int id = boost::lexical_cast<int>(architectureNode->first_attribute(ID_STRING)->value()); try { scene->addArchitecture(id, getXMLPosition(architectureNode), getXMLRotation(architectureNode), getXMLScale(architectureNode)); } catch(NHException e) { #ifdef _DEBUG std::cout << e.what() << std::endl; #endif } architectureNode = architectureNode->next_sibling(ARCHITECTURE_STRING); } scene->build();//building static geometry - must do here else we can't use the navigation mesh for creature placement //Lights rapidxml::xml_node<>* lightNode = root->first_node(LIGHT_STRING);//"light"); while(lightNode != NULL) { bool cast_shadows = boost::lexical_cast<bool>(lightNode->first_attribute(CAST_SHADOWS_STRING)->value()); float range = boost::lexical_cast<float>(lightNode->first_attribute(RANGE_STRING)->value()); Ogre::ColourValue colour = getXMLColour(lightNode); scene->addLight(-1, getXMLPosition(lightNode),cast_shadows,range);//TODO: use actual id rather than -1 lightNode = lightNode->next_sibling(LIGHT_STRING); } //Items rapidxml::xml_node<>* itemNode = root->first_node(ITEM_STRING); while(itemNode != NULL) { int id = boost::lexical_cast<int>(itemNode->first_attribute(ID_STRING)->value()); scene->addItem(id, getXMLPosition(itemNode), getXMLRotation(itemNode)); itemNode = itemNode->next_sibling(ITEM_STRING); } //Creatures rapidxml::xml_node<>* creatureNode = root->first_node(CREATURE_STRING); while(creatureNode != NULL) { int id = boost::lexical_cast<int>(creatureNode->first_attribute(ID_STRING)->value()); scene->addCreature(id, getXMLPosition(creatureNode)); creatureNode = creatureNode->next_sibling(CREATURE_STRING); } //Portals rapidxml::xml_node<>* portalNode = root->first_node(PORTAL_STRING); while(portalNode != NULL) { int id = boost::lexical_cast<int>(portalNode->first_attribute(ID_STRING)->value()); int targetSceneID = boost::lexical_cast<int>(portalNode->first_attribute(TARGET_SCENE_ID_STRING)->value()); int targetPortalID = boost::lexical_cast<int>(portalNode->first_attribute(TARGET_PORTAL_ID_STRING)->value()); scene->addPortal(id, getXMLPosition(portalNode), getXMLVector(portalNode, LOOK_AT_X_STRING, LOOK_AT_Y_STRING, LOOK_AT_Z_STRING), Id<Scene>(targetSceneID), Id<Portal>(targetPortalID), Id<Portal>(id)); portalNode = portalNode->next_sibling(PORTAL_STRING);//"portal"); } //Particles //TODO: change to emitter /* rapidxml::xml_node<>* particleNode = root->first_node(PARTICLE_STRING);//"particle"); while(particleNode != NULL) { scene->addParticles(particleNode->first_attribute(NAME_STRING)->value(), particleNode->first_attribute(TEMPLATE_NAME_STRING)->value(),getXMLPosition(particleNode)); particleNode = particleNode->next_sibling(PARTICLE_STRING); } */ } catch (rapidxml::parse_error e) { std::stringstream ss; ss << "could not load the xml scene '" << filename << "': " << e.what() << std::endl; throw NHException(ss.str().c_str()); } }