void SubjectViewer::setFiles(const FileList &files) { currentIndex = 0; this->files = files; if (!files.empty()) { info.setText(QString::number(currentIndex+1) + "/" + QString::number(files.size())); viewer.setFile(this->files[currentIndex]); } else { info.setText("-"); viewer.setFile(File()); } }
void scanDirectory(const char* path, const char* ext, FileList& list) { fileListClear(list); #ifdef WIN32 _finddata_t dir; char pathWithExt[260]; intptr_t fh; strcpy(pathWithExt, path); strcat(pathWithExt, "/*"); strcat(pathWithExt, ext); fh = _findfirst(pathWithExt, &dir); if (fh == -1L) return; do { fileListAdd(list, std::string(dir.name)); } while (_findnext(fh, &dir) == 0); _findclose(fh); #else dirent* current = 0; DIR* dp = opendir(path); if (!dp) return; while ((current = readdir(dp)) != 0) { int len = strlen(current->d_name); if (len > 4 && strncmp(current->d_name+len-4, ext, 4) == 0) { fileListAdd(list, current->d_name); } } closedir(dp); #endif if (!list.empty()) std::sort(list.begin(), list.end()); }
void QueueEditor::PauseParsInGroups(ItemList* pItemList, bool bExtraParsOnly) { while (true) { FileList GroupFileList; GroupFileList.clear(); FileInfo* pFirstFileInfo = NULL; for (ItemList::iterator it = pItemList->begin(); it != pItemList->end(); ) { EditItem* pItem = *it; if (!pFirstFileInfo || (pFirstFileInfo->GetNZBInfo() == pItem->m_pFileInfo->GetNZBInfo())) { GroupFileList.push_back(pItem->m_pFileInfo); if (!pFirstFileInfo) { pFirstFileInfo = pItem->m_pFileInfo; } delete pItem; pItemList->erase(it); it = pItemList->begin(); continue; } it++; } if (!GroupFileList.empty()) { PausePars(&GroupFileList, bExtraParsOnly); } else { break; } } }
int main( int argc, char **argv ) { // use an ArgumentParser object to manage the program arguments. osg::ArgumentParser arguments(&argc,argv); // set up the usage document, in case we need to print out how to use this program. arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates use node masks to create stereo images."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] image_file_left_eye image_file_right_eye"); arguments.getApplicationUsage()->addCommandLineOption("-d <float>","Time delay in seconds between the display of successive image pairs when in auto advance mode."); arguments.getApplicationUsage()->addCommandLineOption("-a","Enter auto advance of image pairs on start up."); arguments.getApplicationUsage()->addCommandLineOption("-x <float>","Horizontal offset of left and right images."); arguments.getApplicationUsage()->addCommandLineOption("-y <float>","Vertical offset of left and right images."); arguments.getApplicationUsage()->addCommandLineOption("--disk","Keep images on disk"); arguments.getApplicationUsage()->addCommandLineOption("-files <filename>","Load filenames from a file"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("--SingleThreaded","Select SingleThreaded threading model for viewer."); arguments.getApplicationUsage()->addCommandLineOption("--CullDrawThreadPerContext","Select CullDrawThreadPerContext threading model for viewer."); arguments.getApplicationUsage()->addCommandLineOption("--DrawThreadPerContext","Select DrawThreadPerContext threading model for viewer."); arguments.getApplicationUsage()->addCommandLineOption("--CullThreadPerCameraDrawThreadPerContext","Select CullThreadPerCameraDrawThreadPerContext threading model for viewer."); // construct the viewer. osgViewer::Viewer viewer(arguments); // register the handler to add keyboard and mouse handling. SlideEventHandler* seh = new SlideEventHandler(); viewer.addEventHandler(seh); // read any time delay argument. float timeDelayBetweenSlides = 5.0f; while (arguments.read("-d",timeDelayBetweenSlides)) {} bool autoSteppingActive = false; while (arguments.read("-a")) autoSteppingActive = true; float offsetX=0.0f; while (arguments.read("-x",offsetX)) {} float offsetY=0.0f; while (arguments.read("-y",offsetY)) {} bool onDisk=false; while (arguments.read("--disk")) { onDisk=true; } std::string filename=""; FileList fileList; // extract the filenames from the a file, one filename per line. while (arguments.read("-files",filename)) { osgDB::ifstream is(filename.c_str()); if (is) { std::string line; while (std::getline(is,line,'\n')) fileList.push_back(line); is.close(); } } // if user request help write it out to cout. if (arguments.read("-h") || arguments.read("--help")) { arguments.getApplicationUsage()->write(std::cout); return 1; } osgViewer::Viewer::ThreadingModel threading = osgViewer::Viewer::SingleThreaded; while (arguments.read("--SingleThreaded")) threading = osgViewer::Viewer::SingleThreaded; while (arguments.read("--CullDrawThreadPerContext")) threading = osgViewer::Viewer::CullDrawThreadPerContext; while (arguments.read("--DrawThreadPerContext")) threading = osgViewer::Viewer::DrawThreadPerContext; while (arguments.read("--CullThreadPerCameraDrawThreadPerContext")) threading = osgViewer::Viewer::CullThreadPerCameraDrawThreadPerContext; viewer.setThreadingModel(threading); // any option left unread are converted into errors to write out later. arguments.reportRemainingOptionsAsUnrecognized(); // report any errors if they have occurred when parsing the program arguments. if (arguments.errors()) { arguments.writeErrorMessages(std::cout); return 1; } // extract the filenames from the arguments list. for(int pos=1; pos<arguments.argc(); ++pos) { if (arguments.isString(pos)) fileList.push_back(arguments[pos]); } if (fileList.empty()) { fileList.push_back("Images/dog_left_eye.jpg"); fileList.push_back("Images/dog_right_eye.jpg"); } else if (fileList.size()<2) { arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); return 1; } // now the windows have been realized we switch off the cursor to prevent it // distracting the people seeing the stereo images. double fovy, aspectRatio, zNear, zFar; viewer.getCamera()->getProjectionMatrixAsPerspective(fovy, aspectRatio, zNear, zFar); float radius = 1.0f; float height = 2*radius*tan(osg::DegreesToRadians(fovy)*0.5f); float length = osg::PI*radius; // half a cylinder. // use a texture matrix to control the placement of the image. osg::TexMat* texmatLeft = new osg::TexMat; osg::TexMat* texmatRight = new osg::TexMat; // creat the scene from the file list. osg::ref_ptr<osg::Switch> rootNode; if (!onDisk) rootNode = createScene(fileList,texmatLeft,texmatRight,radius,height,length); else rootNode=new osg::Switch(); //osgDB::writeNodeFile(*rootNode,"test.osg"); viewer.getCamera()->setCullMask(0xffffffff); viewer.getCamera()->setCullMaskLeft(0x00000001); viewer.getCamera()->setCullMaskRight(0x00000002); // set up the use of stereo by default. osg::DisplaySettings::instance()->setStereo(true); if (osg::DisplaySettings::instance()->getStereoMode()==osg::DisplaySettings::ANAGLYPHIC) { rootNode->setStateSet(createColorToGreyscaleStateSet()); } // set the scene to render viewer.setSceneData(rootNode.get()); // create the windows and run the threads. viewer.realize(); // switch off the cursor osgViewer::Viewer::Windows windows; viewer.getWindows(windows); for(osgViewer::Viewer::Windows::iterator itr = windows.begin(); itr != windows.end(); ++itr) { (*itr)->useCursor(false); } viewer.setFusionDistance(osgUtil::SceneView::USE_FUSION_DISTANCE_VALUE,radius); // set up the SlideEventHandler. if (onDisk) seh->set(fileList,rootNode.get(),offsetX,offsetY,texmatLeft,texmatRight,radius,height,length,timeDelayBetweenSlides,autoSteppingActive); else seh->set(rootNode.get(),offsetX,offsetY,texmatLeft,texmatRight,timeDelayBetweenSlides,autoSteppingActive); osg::Matrix homePosition; homePosition.makeLookAt(osg::Vec3(0.0f,0.0f,0.0f),osg::Vec3(0.0f,1.0f,0.0f),osg::Vec3(0.0f,0.0f,1.0f)); while( !viewer.done() ) { viewer.getCamera()->setViewMatrix(homePosition); // fire off the cull and draw traversals of the scene. viewer.frame(); } return 0; }