void GLRenderer::addMesh(mesh_t *m, sceneobj_t *s, residx_t sh, int meshNum, bool bStatic) {
	
	GLRenderListMeshItem *item = NULL;
	
	if(bStatic) {
		item = new GLRenderListMeshItem();
	} else {
		item = meshpool.get();
		if(!item) {
			Console_DPrintf("^yGLRenderer: meshpool empty!\n");
			return;
		}
	}
	
	item->set(NULL, m, s, meshNum);
	item->setMaterial(sh);

	if(bStatic) {
		if(item->isTranslucentAdditive())
			addListItem(item, sortedStaticRenderList, false);
		else
			addListItem(item, unsortedStaticRenderList, !GL_MeshShouldDeform(s, m));
	} else {
		if(item->isTranslucentAdditive())
			addListItem(item, sortedRenderList, false);
		else
			addListItem(item, unsortedRenderList, /*!GL_MeshShouldDeform(s, m)*/false);
	}
	
	renderer_meshcount++;
}
Beispiel #2
0
void WidgetRecorder::updateStreamList()
{
    ui->list->clear();

    auto& streams = mainWindow.getStreams();
    for (size_t i = 0; i < streams.size(); ++i) if (streams[i] != nullptr) {
        addListItem(ui->list, "Stream " + QString::number(i + 1) + " - Color");
        addListItem(ui->list, "Stream " + QString::number(i + 1) + " - Depth");
        addListItem(ui->list, "Stream " + QString::number(i + 1) + " - Skeleton");
    }
}
void GLRenderer::addSprite(scenelist_t *m, sceneobj_t *s, residx_t sh, bool bStatic) {
	GLRenderListSpriteItem *item = spritepool.get();
	if(!item) {
		Console_DPrintf("^yGLRenderer: spritepool empty!\n");
		return;
	}
	item->set(m, s);
	item->setMaterial(sh);
	if(item->isTranslucentAdditive())
		addListItem(item, sortedRenderList, false);
	else
		addListItem(item, unsortedRenderList);
}
Beispiel #4
0
void Parser::parseTag(const char* tag, size_t len) {
	bool hasAttributes;
	//printf("tag: %i %.*s\n", tagState, (int)len, tag);
	FORMATTING_TAG("b", BOLD);
	FORMATTING_TAG("i", ITALIC);
	FORMATTING_TAG("small", SMALL);
	FORMATTING_TAG("s", SMALL);
	FORMATTING_TAG("u", UNDERLINED);
	SIMPLE_TAG("table", TABLE);
	SIMPLE_TAG("tr", TR);
	SIMPLE_TAG("td", TD);
	//SIMPLE_TAG("li", LIST_ITEM);
	SPECIAL_TAG("li", addListItem());
	SPECIAL_TAG("code", addCodeTag());
	SPECIAL_TAG("quote", addQuoteTag());
	SIMPLE_TAG("ul", LIST);
	SIMPLE_TAG("ol", LIST);

	if(!strncasecmp("url=", tag, 4) || !strncasecmp("url:", tag, 4) || !strncasecmp("url ", tag, 4)) {
		//printf("url tag: %i %.*s\n", tagState, (int)len, tag);
		const char* url = tag + 4;
		size_t urlLen = len - 4;
		parseUrl(url, urlLen);
		return;
	}
	//C_TAG("url", ANCHOR, "a", "/a");
	COMPARE_TAG("url", return;);	// get rid of empty [url] tags.
Beispiel #5
0
LRESULT WebServerPage::onInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) {
	PropPage::translate((HWND)(*this), texts);

	::SetWindowText(GetDlgItem(IDC_WEBSERVER_PORT), Util::toStringW(webMgr->getPlainServerConfig().getPort()).c_str());
	::SetWindowText(GetDlgItem(IDC_WEBSERVER_TLSPORT), Util::toStringW(webMgr->getTlsServerConfig().getPort()).c_str());

	ctrlTlsPort.Attach(GetDlgItem(IDC_WEBSERVER_TLSPORT));
	ctrlPort.Attach(GetDlgItem(IDC_WEBSERVER_PORT));

	ctrlWebUsers.Attach(GetDlgItem(IDC_WEBSERVER_USERS));
	ctrlWebUsers.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT);
	CRect rc;
	ctrlWebUsers.GetClientRect(rc);
	ctrlWebUsers.InsertColumn(0, CTSTRING(NAME), LVCFMT_LEFT, rc.Width() / 2, 0);
	ctrlWebUsers.InsertColumn(1, CTSTRING(PASSWORD), LVCFMT_LEFT, rc.Width() / 2, 1);

	ctrlRemove.Attach(GetDlgItem(IDC_WEBSERVER_REMOVE_USER));
	ctrlAdd.Attach(GetDlgItem(IDC_WEBSERVER_ADD_USER));
	ctrlChange.Attach(GetDlgItem(IDC_WEBSERVER_CHANGE));
	ctrlStart.Attach(GetDlgItem(IDC_WEBSERVER_START));
	ctrlStatus.Attach(GetDlgItem(IDC_WEBSERVER_STATUS));

	currentState = webMgr->isRunning() ? STATE_STARTED : STATE_STOPPED;
	updateStatus();

	webUserList = webMgr->getUserManager().getUsers();
	for (auto u : webUserList) {
		addListItem(u->getUserName(), u->getPassword());
	}
	webMgr->addListener(this);
	return TRUE;
}
void CDMDialog::addBuilder(DMImageGeneric& im)
{
	// find if this image already exists
	bool exists = false;

	std::string title = im.GetTitle();
	long imid = im.getID();
	DMresult << "TP5" << DMendl;

	std::list<boost::shared_ptr<StackBuilder>>::iterator it = builders.begin();
	while (it != builders.end())
	{
		boost::shared_ptr<StackBuilder> current = *it;
		if (current->GetImageID() == imid)
			exists = true;
		++it;
	}

	if (exists)
	{
		DMresult << "Already watching this image." << DMendl;
		return;
	}

	DMresult << "TP6" << DMendl;

	builders.push_back(boost::make_shared<StackBuilder>(StackBuilder(this, dialogmtx, im)));

	DMresult << "TP7" << DMendl;

	// add to the list box showing the watched images
	addListItem(title, boost::lexical_cast<std::string>(imid));
}
Beispiel #7
0
void fileTransferThread::parseFileList( const QByteArray &fl ) {
	parsedSize=0;
	filesParsed=0;
	fc=0;
	allSize=0;
	currentFile=0;
	QTreeWidgetItem *item;
	QStringList finfo;
	QString path = settings->profileValue( QString("filetransfer/%1").arg(rndid) ).toString(), fname;
	memcpy(&fc, fl.leftRef(4).constData(), 4);
	for(quint32 i=0; i<fc; ++i) {
		memcpy(&fs, fl.mid(4+i*260, 4).data(), 4);
		fname=fl.mid(4+i*260+4, 256);
		finfo<<fname<<""<<""<<""<<""<<QString("%L1 kB").arg( (float)qRound( ( (float)fs/1024 )*10 )/10 )<<path<<QString("%1").arg(fs);
		item = new QTreeWidgetItem(finfo);
		item->setIcon(0, QIcon(":offline"));
//		item->setCheckState(0,Qt::Checked);
		fileMap<<item;
		emit addListItem(item);
		allSize+=fs;
		finfo.clear();
	}
	settings->removeProfileValue( QString("filetransfer/%1").arg(rndid) );
	char packet[8];
	quint32 tmp=FileListAck;
	memcpy(&packet, &tmp,4);
	tmp=0;
	memcpy(&packet[4], &tmp,4);
	socket->write(packet,sizeof(packet));
	emit updateFilesData(fc, allSize);
	requestFile();
}
LRESULT FulAdvancedPage::onClickedShortcuts(WORD /* wNotifyCode */, WORD wID, HWND /* hWndCtl */, BOOL& /* bHandled */) {
	if (wID == IDC_WEB_SHORTCUTS_ADD) {
		WebShortcut* ws;
		ws = new WebShortcut();
		WebShortcutsProperties wsp(wsList, ws);
		if (wsp.DoModal() == IDOK) {
			wsList.push_back(ws);
			addListItem(ws);
		} else {
			delete ws;
		}
	} else if (wID == IDC_WEB_SHORTCUTS_PROPERTIES) {
		if (ctrlWebShortcuts.GetSelectedCount() == 1) {
			int sel = ctrlWebShortcuts.GetSelectedIndex();
			WebShortcut* ws = wsList[sel];
			WebShortcutsProperties wsp(wsList, ws);
			if (wsp.DoModal() == IDOK) {
				updateListItem(sel);
			}
		}
	} else if (wID == IDC_WEB_SHORTCUTS_REMOVE) {
		if (ctrlWebShortcuts.GetSelectedCount() == 1) {
			int sel = ctrlWebShortcuts.GetSelectedIndex();
			dcassert(sel >= 0 && sel < (int)wsList.size());

			wsList.erase(find(wsList.begin(), wsList.end(), wsList[sel]));
			ctrlWebShortcuts.DeleteItem(sel);
		}
	}
	return S_OK;
}
void GLRenderer::addOcTree(OcTree *oc) {
	if(oc->children[0])
		for(int i=0;i<8;i++)
			addOcTree(oc->children[i]);
	
	octrees[oci].set(oc);
	addListItem(octrees[oci++].getRef(), unsortedRenderList);
}
Beispiel #10
0
LRESULT WebServerPage::onButton(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
	
	if (wID == IDC_WEBSERVER_ADD_USER) {
		WebUserDlg dlg;
		if (dlg.DoModal() == IDOK) {
			webUserList.emplace_back(make_shared<webserver::WebUser>(dlg.getUserName(), dlg.getPassWord()));
			addListItem(dlg.getUserName(), dlg.getPassWord());
		}
	}
	else if (wID == IDC_WEBSERVER_CHANGE) {
		if (ctrlWebUsers.GetSelectedCount() == 1) {
			int sel = ctrlWebUsers.GetSelectedIndex();
			auto webUser = webUserList[sel];
			WebUserDlg dlg(Text::toT(webUser->getUserName()), Text::toT(webUser->getPassword()));
			if (dlg.DoModal() == IDOK) {
				webUser->setUserName(dlg.getUserName());
				webUser->setPassword(dlg.getPassWord());
				ctrlWebUsers.SetItemText(sel, 0, Text::toT(dlg.getUserName()).c_str());
				ctrlWebUsers.SetItemText(sel, 1, Text::toT(dlg.getPassWord()).c_str());
			}
		}
	}
	else if (wID == IDC_WEBSERVER_REMOVE_USER) {
		if (ctrlWebUsers.GetSelectedCount() == 1) {
			int sel = ctrlWebUsers.GetSelectedIndex();
			webUserList.erase(find(webUserList.begin(), webUserList.end(), webUserList[sel]));
			ctrlWebUsers.DeleteItem(sel);
		}
	}
	else if (wID == IDC_WEBSERVER_START) {
		if (!webMgr->isRunning()) {
			auto plainserverPort = Util::toInt(Text::fromT(WinUtil::getEditText(ctrlPort)));
			auto tlsServerPort = Util::toInt(Text::fromT(WinUtil::getEditText(ctrlTlsPort)));

			if (webMgr->getPlainServerConfig().getPort() != plainserverPort) {
				webMgr->getPlainServerConfig().setPort(plainserverPort);
			}
			if (webMgr->getTlsServerConfig().getPort() != tlsServerPort) {
				webMgr->getTlsServerConfig().setPort(tlsServerPort);
			}

			ctrlStart.EnableWindow(FALSE);
			lastError.clear();
			webMgr->start([&](const string& aError) { lastError += aError + "\n"; });
		} else {
			lastError.clear();
			webserver::WebServerManager::getInstance()->stop();
		}
	}

	return 0;
}
Beispiel #11
0
LRESULT WebServerPage::onAddUser(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
	WebUserDlg dlg;
	if (dlg.DoModal() == IDOK) {
		if (dlg.getUserName().empty() || dlg.getPassWord().empty()) {
			WinUtil::showMessageBox(TSTRING(WEB_ACCOUNT_INCOMPLETE), MB_ICONEXCLAMATION);
			return 0;
		}

		auto user = make_shared<webserver::WebUser>(dlg.getUserName(), dlg.getPassWord(), true);

		webUserList.push_back(user);
		addListItem(user);
	}

	return 0;
}
Beispiel #12
0
LRESULT WebServerPage::onInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) {
	PropPage::translate((HWND)(*this), texts);

	::SetWindowText(GetDlgItem(IDC_WEBSERVER_PORT_LABEL), CTSTRING_F(WEB_SERVER_PORT, "HTTP"));
	::SetWindowText(GetDlgItem(IDC_WEBSERVER_TLSPORT_LABEL), CTSTRING_F(WEB_SERVER_PORT, "HTTPS"));

	::SetWindowText(GetDlgItem(IDC_WEBSERVER_PORT), Util::toStringW(WEBCFG(PLAIN_PORT).num()).c_str());
	::SetWindowText(GetDlgItem(IDC_WEBSERVER_TLSPORT), Util::toStringW(WEBCFG(TLS_PORT).num()).c_str());

	ctrlTlsPort.Attach(GetDlgItem(IDC_WEBSERVER_TLSPORT));
	ctrlPort.Attach(GetDlgItem(IDC_WEBSERVER_PORT));

	url.SubclassWindow(GetDlgItem(IDC_LINK));
	url.SetHyperLinkExtendedStyle(HLINK_UNDERLINEHOVER);

	// TODO: add better help link
	url.SetHyperLink(_T("http://www.airdcpp.net/component/k2/24-web-server"));
	url.SetLabel(CTSTRING(MORE_INFORMATION));

	ctrlWebUsers.Attach(GetDlgItem(IDC_WEBSERVER_USERS));
	ctrlWebUsers.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT);

	CRect rc;
	ctrlWebUsers.GetClientRect(rc);
	ctrlWebUsers.InsertColumn(0, CTSTRING(USERNAME), LVCFMT_LEFT, rc.Width() / 2, 0);
	ctrlWebUsers.InsertColumn(1, CTSTRING(LAST_SEEN), LVCFMT_LEFT, rc.Width() / 2, 1);

	ctrlRemove.Attach(GetDlgItem(IDC_WEBSERVER_REMOVE_USER));
	ctrlAdd.Attach(GetDlgItem(IDC_WEBSERVER_ADD_USER));
	ctrlChange.Attach(GetDlgItem(IDC_WEBSERVER_CHANGE));
	ctrlStart.Attach(GetDlgItem(IDC_WEBSERVER_START));
	ctrlStatus.Attach(GetDlgItem(IDC_WEBSERVER_STATUS));

	updateState(webMgr->isRunning() ? STATE_STARTED : STATE_STOPPED);

	webUserList = webMgr->getUserManager().getUsers();
	for (const auto& u : webUserList) {
		if (!u->isAdmin()) {
			continue;
		}

		addListItem(u);
	}

	webMgr->addListener(this);
	return TRUE;
}
Beispiel #13
0
seqan::ArgumentParser::ParseResult
parseCommandLine(AppOptions & options, int argc, char const ** argv)
{
    // Setup ArgumentParser.
    seqan::ArgumentParser parser("%(NAME)s");
    // Set short description, version, and date.
    setShortDescription(parser, "Put a Short Description Here");
    setVersion(parser, "0.1");
    setDate(parser, "July 2012");

    // Define usage line and long description.
    addUsageLine(parser, "[\\fIOPTIONS\\fP] \"\\fITEXT\\fP\"");
    addDescription(parser, "This is the application skelleton and you should modify this string.");

    // We require one argument.
    addArgument(parser, seqan::ArgParseArgument(seqan::ArgParseArgument::STRING, "TEXT"));

    addOption(parser, seqan::ArgParseOption("q", "quiet", "Set verbosity to a minimum."));
    addOption(parser, seqan::ArgParseOption("v", "verbose", "Enable verbose output."));
    addOption(parser, seqan::ArgParseOption("vv", "very-verbose", "Enable very verbose output."));

    // Add Examples Section.
    addTextSection(parser, "Examples");
    addListItem(parser, "\\fB%(NAME)s\\fP \\fB-v\\fP \\fItext\\fP",
                "Call with \\fITEXT\\fP set to \"text\" with verbose output.");

    // Parse command line.
    seqan::ArgumentParser::ParseResult res = seqan::parse(parser, argc, argv);

    // Only extract  options if the program will continue after parseCommandLine()
    if (res != seqan::ArgumentParser::PARSE_OK)
        return res;

    // Extract option values.
    if (isSet(parser, "quiet"))
        options.verbosity = 0;
    if (isSet(parser, "verbose"))
        options.verbosity = 2;
    if (isSet(parser, "very-verbose"))
        options.verbosity = 3;
    seqan::getArgumentValue(options.text, parser, 0);

    return seqan::ArgumentParser::PARSE_OK;
}
Beispiel #14
0
void fileTransferThread::addFilesToSend() {
	QStringList flist = QFileDialog::getOpenFileNames( static_cast<QWidget*>(parent()), tr("Choose files to send"), QDir::homePath() );

	if( flist.count() ) {
		QStringListIterator it(flist);
		while(it.hasNext()) {
			QString f=it.next();
			QFileInfo fifo(f);
			QStringList info;
			info<<fifo.fileName()<<""<<""<<""<<""<<QString("%L1 kB").arg( (float)qRound( ( (float)fifo.size()/1024 )*10 )/10 )<<fifo.absolutePath()<<QString("%1").arg( fifo.size() );
			fc++;
			allSize+=fifo.size();
			QTreeWidgetItem *item = new QTreeWidgetItem(info);
			fileMap<<item;
			emit addListItem(item);
		}
		emit updateFilesData(fc, allSize);
	}
}
LRESULT FulAdvancedPage::onInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	PropPage::read((HWND)*this, items, listItems, GetDlgItem(IDC_FUL_ADVANCED_BOOLEANS));
	PropPage::translate((HWND)(*this), texts);
	
	wsList = WebShortcuts::getInstance()->copyList();

	CRect rc;
	ctrlWebShortcuts.Attach(GetDlgItem(IDC_WEB_SHORTCUTS_LIST));
	ctrlWebShortcuts.GetClientRect(rc);
	rc.right -= GetSystemMetrics(SM_CXVSCROLL);
	ctrlWebShortcuts.InsertColumn(0, CTSTRING(SETTINGS_NAME), LVCFMT_LEFT, rc.Width() / 5, 0);
	ctrlWebShortcuts.InsertColumn(1, CTSTRING(KEY), LVCFMT_LEFT, rc.Width() / 5, 1);
	ctrlWebShortcuts.InsertColumn(2, CTSTRING(URL), LVCFMT_LEFT, rc.Width() * 3 / 5, 2);
	ctrlWebShortcuts.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);

	for (WebShortcut::Iter i = wsList.begin(); i != wsList.end(); ++i) {
		WebShortcut* ws = *i;
		addListItem(ws);
	}

	// Do specialized reading here
	return TRUE;
}
Beispiel #16
0
seqan::ArgumentParser::ParseResult
parseArgs(FxFaidxOptions & options,
          int argc,
          char const ** argv)
{
    seqan::ArgumentParser parser("fx_faidx");
    setShortDescription(parser, "Indexing FASTA and indexed FASTA access.");
    setVersion(parser, "0.1");
    setDate(parser, "May 2012");
    
    addUsageLine(parser, "[\\fIOPTIONS\\fP] [\\fB-f\\fP \\fIFASTA\\fP] [\\fB-r\\fP \\fIREGION\\fP]+");
    addDescription(parser, "Equivalent program to samtools faidx.");

    // TODO(holtgrew): I want a custom help text!
    // addOption(parser, seqan::ArgParseOption("h", "help", "This helpful screen."));
    addOption(parser, seqan::ArgParseOption("v", "verbose", "Verbose, log to STDERR."));
    addOption(parser, seqan::ArgParseOption("vv", "very-verbose", "Very verbose, log to STDERR."));
    hideOption(parser, "very-verbose");

    addSection(parser, "FASTA / FAIDX Files");
    addOption(parser, seqan::ArgParseOption("f", "fasta-file", "Path to the FASTA file.", seqan::ArgParseArgument::STRING, false, "FASTA"));
    setRequired(parser, "fasta-file");
    addOption(parser, seqan::ArgParseOption("i", "index-file", "Path to the .fai index file.  Defaults to FASTA.fai", seqan::ArgParseArgument::STRING, false, "FASTA"));
    addOption(parser, seqan::ArgParseOption("o", "out-file", "Path to the resulting file.  If omitted, result is printed to stdout.", seqan::ArgParseArgument::STRING, false, "FASTA"));

    addSection(parser, "Regions");
    addOption(parser, seqan::ArgParseOption("r", "region", "Region to retrieve from FASTA file.  You can specify multiple regions with multiple \\fB-r\\fP \\fIREGION\\fP.  Note that regions are one-based, see below for detailed information about the format.", seqan::ArgParseArgument::STRING, true, "REGION"));

    addTextSection(parser, "Regions");
    addText(parser,
            "Regions can be specified in the formats \\fICHR\\fP, \\fICHR\\fP:\\fISTART\\fP, \\fICHR\\fP:\\fISTART\\fP:\\fIEND\\fP.  \\fICHR\\fP is the id of the reference sequence in the FASTA file, \\fISTART\\fP and \\fIEND\\fP are the start end end positions of the region.  These positions are one-based.");
    addTextSection(parser, "Region Examples");
    addListItem(parser, "\\fIchr1\\fP", "All of the sequence with the identifier \"chr1\".");
    addListItem(parser, "\\fIchrX\\fP:\\fI1,000\\fP", "The characters in the X chromsome, starting with the 1,000th base.");
    addListItem(parser, "\\fIchr2\\fP:\\fI1,500,000\\fP-\\fI2,000,000\\fP", "The character 1,500,000 up to and including character 2,000,000 in the same chromosome.");

    addTextSection(parser, "Usage Examples");
    addListItem(parser, "\\fBfx_faidx\\fP \\fB-f\\fP \\fIREF.fa\\fP", "Create index for file \\fIREF.fa\\fP, index is written to \\fIREF.fa.fai\\fP");
    addListItem(parser, "\\fBfx_faidx\\fP \\fB-f\\fP \\fIREF.fa\\fP \\fB-i\\fP \\fIINDEX.fai\\fP", "Create index for file \\fIREF.fa\\fP, index is written to \\fIINDEX.fai\\fP");
    addListItem(parser, "\\fBfx_faidx\\fP \\fB-f\\fP \\fIREF.fa\\fP \\fB-r\\fP \\fIchr1\\fP", "Retrieve sequence named \"chr1\" from file \\fIREF.fa\\fP using the index with the default name \\fIREF.fa.fai\\fP.  The index file name is created if it does not exist.");
    addListItem(parser, "\\fBfx_faidx\\fP \\fB-f\\fP \\fIREF.fa\\fP \\fB-r\\fP \\fIchr1:100-1100\\fP", "Retrieve characters 100 to 1,100 from the sequence named \"chr1\" from file \\fIREF.fa\\fP using the index with the default name \\fIREF.fa.fai\\fP.");
    addListItem(parser, "\\fBfx_faidx\\fP \\fB-f\\fP \\fIREF.fa\\fP \\fB-r\\fP \\fIchr1:100-1100\\fP \\fB-r\\fP \\fIchr2:2,000\\fP", "Retrieve characters 100-1,000 from \"chr1\" and all characters from 2,000 of \"chr2\".");
    
    seqan::ArgumentParser::ParseResult res = parse(parser, argc, argv);

    if (res == seqan::ArgumentParser::PARSE_OK)
    {
        getOptionValue(options.inFastaPath, parser, "fasta-file");

        // Set default FAI file name.
        options.inFaiPath = options.inFastaPath;
        append(options.inFaiPath, ".fai");
        // Get FAI file name from parser if set.
        if (isSet(parser, "index-file"))
            getOptionValue(options.inFaiPath, parser, "index-file");

        if (isSet(parser, "region"))
            options.regions = getOptionValues(parser, "region");

        if (isSet(parser, "out-file"))
            getOptionValue(options.outFastaPath, parser, "out-file");

        if (isSet(parser, "verbose"))
            options.verbosity = 2;
        if (isSet(parser, "very-verbose"))
            options.verbosity = 3;
    }

    return res;
}
void LLPanelNearByMedia::refreshList()
{
	bool all_items_deleted = false;
		
	if(!mMediaList)
	{
		// None of this makes any sense if the media list isn't there.
		return;
	}
	
	// Check whether the debug column has been shown/hidden.
	bool debug_info_visible = gSavedSettings.getBOOL("MediaPerformanceManagerDebug");
	if(debug_info_visible != mDebugInfoVisible)
	{
		mDebugInfoVisible = debug_info_visible;

		// Clear all items so the list gets regenerated.
		mMediaList->deleteAllItems();
		mParcelAudioItem = NULL;
		mParcelMediaItem = NULL;
		all_items_deleted = true;
		
		updateColumns();
	}
	
	refreshParcelItems();
	
	// Get the canonical list from LLViewerMedia
	LLViewerMedia::impl_list impls = LLViewerMedia::getPriorityList();
	LLViewerMedia::impl_list::iterator priority_iter;
	
	U32 enabled_count = 0;
	U32 disabled_count = 0;
	
	// iterate over the impl list, creating rows as necessary.
	for(priority_iter = impls.begin(); priority_iter != impls.end(); priority_iter++)
	{
		LLViewerMediaImpl *impl = *priority_iter;
		
		// If we just emptied out the list, every flag needs to be reset.
		if(all_items_deleted)
		{
			impl->setInNearbyMediaList(false);
		}

		if (!impl->isParcelMedia())
		{
			LLUUID media_id = impl->getMediaTextureID();
			S32 proximity = impl->getProximity();
			// This is expensive (i.e. a linear search) -- don't use it here.  We now use mInNearbyMediaList instead.
			//S32 index = mMediaList->getItemIndex(media_id);
			if (proximity < 0 || !shouldShow(impl))
			{
				if (impl->getInNearbyMediaList())
				{
					// There's a row for this impl -- remove it.
					removeListItem(media_id);
					impl->setInNearbyMediaList(false);
				}
			}
			else
			{
				if (!impl->getInNearbyMediaList())
				{
					// We don't have a row for this impl -- add one.
					addListItem(media_id);
					impl->setInNearbyMediaList(true);
				}
			}
			// Update counts
			if (impl->isMediaDisabled())
			{
				disabled_count++;
			}
			else {
				enabled_count++;
		}
	}
	}	
	mDisableAllCtrl->setEnabled((gSavedSettings.getBOOL("AudioStreamingMusic") || 
		                         gSavedSettings.getBOOL("AudioStreamingMedia")) &&
								(LLViewerMedia::isAnyMediaShowing() || 
								 LLViewerMedia::isParcelMediaPlaying() ||
								 LLViewerMedia::isParcelAudioPlaying()));

	mEnableAllCtrl->setEnabled( (gSavedSettings.getBOOL("AudioStreamingMusic") ||
								gSavedSettings.getBOOL("AudioStreamingMedia")) &&
							   (disabled_count > 0 ||
								// parcel media (if we have it, and it isn't playing, enable "start")
								(LLViewerMedia::hasParcelMedia() && ! LLViewerMedia::isParcelMediaPlaying()) ||
								// parcel audio (if we have it, and it isn't playing, enable "start")
								(LLViewerMedia::hasParcelAudio() && ! LLViewerMedia::isParcelAudioPlaying())));

	// Iterate over the rows in the control, updating ones whose impl exists, and deleting ones whose impl has gone away.
	std::vector<LLScrollListItem*> items = mMediaList->getAllData();

	for (std::vector<LLScrollListItem*>::iterator item_it = items.begin();
		item_it != items.end();
		++item_it)
	{
		LLScrollListItem* item = (*item_it);
		LLUUID row_id = item->getUUID();
		
		if (row_id != PARCEL_MEDIA_LIST_ITEM_UUID &&
			row_id != PARCEL_AUDIO_LIST_ITEM_UUID)
		{
			LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(row_id);
			if(impl)
			{
				updateListItem(item, impl);
			}
			else
			{
				// This item's impl has been deleted -- remove the row.
				// Removing the row won't throw off our iteration, since we have a local copy of the array.
				// We just need to make sure we don't access this item after the delete.
				removeListItem(row_id);
			}
		}
	}
	
	// Set the selection to whatever media impl the media focus/hover is on. 
	// This is an experiment, and can be removed by ifdefing out these 4 lines.
	LLUUID media_target = LLViewerMediaFocus::getInstance()->getControlsMediaID();
	if(media_target.notNull())
	{
		mMediaList->selectByID(media_target);
	}
}
Beispiel #18
0
seqan::ArgumentParser::ParseResult
parseArgs(SakOptions & options,
          int argc,
          char ** argv)
{
    seqan::ArgumentParser parser("sak");
    setShortDescription(parser, "Slicing and dicing of FASTA/FASTQ files..");
    setVersion(parser, SEQAN_APP_VERSION " [" SEQAN_REVISION "]");
    setDate(parser, SEQAN_DATE);
    setCategory(parser, "Utilities");

    addUsageLine(parser, "[\\fIOPTIONS\\fP] [\\fB-o\\fP \\fIOUT.{fa,fq}\\fP] \\fIIN.{fa,fq}\\fP");
    addDescription(parser, "\"It slices, it dices and it makes the laundry!\"");
    addDescription(parser, "Original SAK tool by David Weese. Rewrite by Manuel Holtgrewe.");

    // The only argument is the input file.
    addArgument(parser, seqan::ArgParseArgument(seqan::ArgParseArgument::INPUT_FILE, "IN"));

    // Only FASTA and FASTQ files are allowed as input.
    setValidValues(parser, 0, seqan::SeqFileIn::getFileExtensions());

    // TODO(holtgrew): I want a custom help text!
    // addOption(parser, seqan::ArgParseOption("h", "help", "This helpful screen."));
    addOption(parser, seqan::ArgParseOption("v", "verbose", "Verbose, log to STDERR."));
    hideOption(parser, "verbose");
    addOption(parser, seqan::ArgParseOption("vv", "very-verbose", "Very verbose, log to STDERR."));
    hideOption(parser, "very-verbose");

    addSection(parser, "Output Options");
    addOption(parser, seqan::ArgParseOption("o", "out-path",
                                            "Path to the resulting file.  If omitted, result is printed to stdout in FastQ format.",
                                            seqan::ArgParseOption::OUTPUT_FILE, "FASTX"));
    setValidValues(parser, "out-path", seqan::SeqFileOut::getFileExtensions());
    addOption(parser, seqan::ArgParseOption("rc", "revcomp", "Reverse-complement output."));
    addOption(parser, seqan::ArgParseOption("l", "max-length", "Maximal number of sequence characters to write out.",
                                            seqan::ArgParseOption::INTEGER, "LEN"));

    addSection(parser, "Filter Options");
    addOption(parser, seqan::ArgParseOption("s", "sequence", "Select the given sequence for extraction by 0-based index.",
                                            seqan::ArgParseOption::INTEGER, "NUM", true));
    addOption(parser, seqan::ArgParseOption("sn", "sequence-name", "Select sequence with name prefix being \\fINAME\\fP.",
                                            seqan::ArgParseOption::STRING, "NAME", true));
    addOption(parser, seqan::ArgParseOption("ss", "sequences",
                                            "Select sequences \\fIfrom\\fP-\\fIto\\fP where \\fIfrom\\fP and \\fIto\\fP "
                                            "are 0-based indices.",
                                            seqan::ArgParseArgument::STRING, "RANGE", true));
    addOption(parser, seqan::ArgParseOption("i", "infix",
                                            "Select characters \\fIfrom\\fP-\\fIto\\fP where \\fIfrom\\fP and \\fIto\\fP "
                                            "are 0-based indices.",
                                            seqan::ArgParseArgument::STRING, "RANGE", true));

    addOption(parser, seqan::ArgParseOption("ll", "line-length",
                                            "Set line length in output file.  See section \\fILine Length\\fP for details.",
                                            seqan::ArgParseArgument::INTEGER, "LEN", false));
    setMinValue(parser, "line-length", "-1");

    addTextSection(parser, "Line Length");
    addText(parser,
            "You can use the setting \\fB--line-length\\fP for setting the resulting line length.  By default, "
            "sequences in FASTA files are written with at most 70 characters per line and sequences in FASTQ files are "
            "written without any line breaks.  The quality sequence in FASTQ file is written in the same way as the "
            "residue sequence.");
    addText(parser,
            "The default is selected with a \\fB--line-length\\fP value of \\fI-1\\fP and line breaks can be disabled "
            "with a value of \\fI0\\fP.");

    addTextSection(parser, "Usage Examples");
    addListItem(parser, "\\fBsak\\fP \\fB-s\\fP \\fI10\\fP \\fIIN.fa\\fP",
                "Cut out 11th sequence from \\fIIN.fa\\fP and write to stdout as FASTA.");
    addListItem(parser, "\\fBsak\\fP \\fB-ss\\fP \\fI10-12\\fP \\fB-ss\\fP \\fI100-200\\fP \\fIIN.fq\\fP",
                "Cut out 11th up to and including 12th and 101th up to and including 199th sequence from \\fIIN.fq\\fP "
                "and write to stdout as FASTA.");

    seqan::ArgumentParser::ParseResult res = parse(parser, argc, argv);

    if (res != seqan::ArgumentParser::PARSE_OK)
        return res;

    getArgumentValue(options.inFastxPath, parser, 0);

    seqan::CharString tmp;
    getOptionValue(tmp, parser, "out-path");

    if (isSet(parser, "out-path"))
        getOptionValue(options.outPath, parser, "out-path");

    if (isSet(parser, "verbose"))
        options.verbosity = 2;
    if (isSet(parser, "very-verbose"))
        options.verbosity = 3;

    if (isSet(parser, "sequence"))
    {
        std::vector<std::string> sequenceIds = getOptionValues(parser, "sequence");
        for (unsigned i = 0; i < seqan::length(sequenceIds); ++i)
        {
            unsigned idx = 0;
            if (!seqan::lexicalCast(idx, sequenceIds[i]))
            {
                std::cerr << "ERROR: Invalid sequence index " << sequenceIds[i] << "\n";
                return seqan::ArgumentParser::PARSE_ERROR;
            }
            appendValue(options.seqIndices, idx);
        }
    }

    if (isSet(parser, "sequences"))
    {
        std::vector<std::string> sequenceRanges = getOptionValues(parser, "sequences");
        seqan::CharString buffer;
        for (unsigned i = 0; i < seqan::length(sequenceRanges); ++i)
        {
            seqan::Pair<uint64_t> range;
            if (!parseRange(range.i1, range.i2, sequenceRanges[i]))
            {
                std::cerr << "ERROR: Invalid range " << sequenceRanges[i] << "\n";
                return seqan::ArgumentParser::PARSE_ERROR;
            }
            appendValue(options.seqIndexRanges, range);
        }
    }

    if (isSet(parser, "infix"))
    {
        seqan::CharString buffer;
        getOptionValue(buffer, parser, "infix");
        if (!parseRange(options.seqInfixBegin, options.seqInfixEnd, buffer))
        {
            std::cerr << "ERROR: Invalid range " << buffer << "\n";
            return seqan::ArgumentParser::PARSE_ERROR;
        }
    }

    options.reverseComplement = isSet(parser, "revcomp");

    if (isSet(parser, "max-length"))
        getOptionValue(options.maxLength, parser, "max-length");

    if (isSet(parser, "sequence-name"))
        getOptionValue(options.readPattern, parser, "sequence-name");

    getOptionValue(options.seqOutOptions.lineLength, parser, "line-length");

    return res;
}
void LLPanelNearByMedia::refreshParcelItems()
{
	//
	// First add/remove the "fake" items Parcel Media and Parcel Audio.
	// These items will have special UUIDs 
	//    PARCEL_MEDIA_LIST_ITEM_UUID
	//    PARCEL_AUDIO_LIST_ITEM_UUID
	//
	// Get the filter choice.
	const LLSD &choice_llsd = mShowCtrl->getSelectedValue();
	MediaClass choice = (MediaClass)choice_llsd.asInteger();
	// Only show "special parcel items" if "All" or "Within" filter
	// (and if media is "enabled")
	bool should_include = (choice == MEDIA_CLASS_ALL || choice == MEDIA_CLASS_WITHIN_PARCEL);
	
	// First Parcel Media: add or remove it as necessary
	if (gSavedSettings.getBOOL("AudioStreamingMedia") &&should_include && LLViewerMedia::hasParcelMedia())
	{
		// Yes, there is parcel media.
		if (NULL == mParcelMediaItem)
		{
			mParcelMediaItem = addListItem(PARCEL_MEDIA_LIST_ITEM_UUID);
			mMediaList->setNeedsSort(true);
		}
	}
	else {
		if (NULL != mParcelMediaItem) {
			removeListItem(PARCEL_MEDIA_LIST_ITEM_UUID);
			mParcelMediaItem = NULL;
			mMediaList->setNeedsSort(true);	
		}
	}
	
	// ... then update it
	if (NULL != mParcelMediaItem)
	{
		std::string name, url, tooltip;
		getNameAndUrlHelper(LLViewerParcelMedia::getParcelMedia(), name, url, "");
		if (name.empty() || name == url)
		{
			tooltip = url;
		}
		else
		{
			tooltip = name + " : " + url;
		}
		LLViewerMediaImpl *impl = LLViewerParcelMedia::getParcelMedia();
		updateListItem(mParcelMediaItem,
					   mParcelMediaName,
					   tooltip,
					   -2, // Proximity closer than anything else, before Parcel Audio
					   impl == NULL || impl->isMediaDisabled(),
					   impl != NULL && !LLViewerParcelMedia::getURL().empty(),
					   impl != NULL && impl->isMediaTimeBased() &&	impl->isMediaPlaying(),
					   MEDIA_CLASS_ALL,
					   "parcel media");
	}
	
	// Next Parcel Audio: add or remove it as necessary (don't show if disabled in prefs)
	if (should_include && LLViewerMedia::hasParcelAudio() && gSavedSettings.getBOOL("AudioStreamingMusic"))
	{
		// Yes, there is parcel audio.
		if (NULL == mParcelAudioItem)
		{
			mParcelAudioItem = addListItem(PARCEL_AUDIO_LIST_ITEM_UUID);
			mMediaList->setNeedsSort(true);
		}
	}
	else {
		if (NULL != mParcelAudioItem) {
			removeListItem(PARCEL_AUDIO_LIST_ITEM_UUID);
			mParcelAudioItem = NULL;
			mMediaList->setNeedsSort(true);
		}
	}
	
	// ... then update it
	if (NULL != mParcelAudioItem)
	{
		bool is_playing = LLViewerMedia::isParcelAudioPlaying();
	
		std::string url;
        url = LLViewerMedia::getParcelAudioURL();

		updateListItem(mParcelAudioItem,
					   mParcelAudioName,
					   url,
					   -1, // Proximity after Parcel Media, but closer than anything else
					   (!is_playing),
					   is_playing,
					   is_playing,
					   MEDIA_CLASS_ALL,
					   "parcel audio");
	}
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    readSettings();
    ui->actionSound->setChecked(settings.soundsenabled);

    irc = new QIrc();
    if (!irc->createSession())
    {
        QMessageBox::critical(this, tr("Error"), tr("Can't create session"));
        close();
        return;
    }
    connect(irc, SIGNAL(sigConnected()), this, SLOT(sltConnected()));
    connect(irc, SIGNAL(sigMessage(QString,QString)), this, SLOT(sltMessage(QString,QString)));
    connect(irc, SIGNAL(sigChannelJoined(QString,QString)), this, SLOT(sltChannelJoined(QString,QString)));
    connect(irc, SIGNAL(sigChannelParted(QString,QString,QString)), this, SLOT(sltChannelParted(QString,QString,QString)));
    connect(irc, SIGNAL(sigChannelNames(QString,QString,QStringList)), this, SLOT(sltChannelNames(QString,QString,QStringList)));
    connect(irc, SIGNAL(sigChannelMessage(QString,QString,QString)), this, SLOT(sltChannelMessage(QString,QString,QString)));
    connect(irc, SIGNAL(sigPrivateMessage(QString,QString,QString)), this, SLOT(sltPrivateMessage(QString,QString,QString)));
    connect(irc, SIGNAL(sigNick(QString,QString)), this, SLOT(sltNick(QString,QString)));
    connect(irc, SIGNAL(sigNotice(QString,QString,QString)), this, SLOT(sltNotice(QString,QString,QString)));
    connect(irc, SIGNAL(sigTopic(QString,QString,QString)), this, SLOT(sltTopic(QString,QString,QString)));
    connect(irc, SIGNAL(sigTopicSet(QString,QString,QString,QString)), this, SLOT(sltTopicSet(QString,QString,QString,QString)));
    connect(irc, SIGNAL(sigKick(QString,QString,QString)), this, SLOT(sltKick(QString,QString,QString)));
    connect(irc, SIGNAL(sigQuit(QString,QString)), this, SLOT(sltQuit(QString,QString)));
    connect(irc, SIGNAL(sigChannelModeChanged(QString,QString,QStringList)), this, SLOT(sltChannelModeChanged(QString,QString,QStringList)));
    connect(irc, SIGNAL(sigUmode(QString,QString)), this, SLOT(sltUmode(QString,QString)));
    connect(irc, SIGNAL(sigInvite(QString,QString,QString)), this, SLOT(sltInvite(QString,QString,QString)));
    connect(irc, SIGNAL(sigCtcpAction(QString,QString,QString)), this, SLOT(sltCtcpAction(QString,QString,QString)));
    connect(irc, SIGNAL(sigErrorOccured(QString)), this, SLOT(sltErrorOccured(QString)));

    consolebrowser = new QTextEdit();
    consolebrowser->setReadOnly(true);
    QFont consolefont;
    if (consolefont.fromString(settings.consolefont))
        consolebrowser->setFont(consolefont);

    if (!settings.hideconsole)
        consoleindex =ui->tabWidget->insertTab(0, consolebrowser, tr("Console"));

    setsdlg = 0;

    usercontextmenu = new QMenu(this);
    usercontextmenu->addAction(ui->actionPrivateChat);
    usercontextmenu->addAction(ui->actionInsert_to_editor);
    QMenu *managementmenu = usercontextmenu->addMenu(tr("Management"));
    managementmenu->addAction(ui->actionKick);
    managementmenu->addAction(ui->actionBan);
    managementmenu->addAction(ui->actionKickBan);
    managementmenu->addSeparator();
    managementmenu->addAction(ui->actionOp);
    managementmenu->addAction(ui->actionDeOp);
    managementmenu->addSeparator();
    managementmenu->addAction(ui->actionVoice);
    managementmenu->addAction(ui->actiondeVoice);
    connect(ui->treeWidget, SIGNAL(userContextMenu(QPoint)), this, SLOT(userContextMenuRequested(QPoint)));

    channelcontextmenu = new QMenu(this);
    channelcontextmenu->addAction(ui->actionLeave_channel);
    channelcontextmenu->addAction(ui->actionChannel_settings);
    connect(ui->treeWidget, SIGNAL(channelContextMenu(QPoint)), this, SLOT(channelContextMenuRequested(QPoint)));

    channelsettingsdialog = 0;
    trayicon = 0;
    traymenu = 0;
    setTrayIcon(settings.trayicon);
    connect(ui->actionChannel_settings, SIGNAL(triggered()), this, SLOT(channelSettingsPressed()));

    //smile menu
    smilemenu = new QMenu(this);
    smilewidgetaction = new QWidgetAction(smilemenu);
    smilebar = new SmileBar();
    smilewidgetaction->setDefaultWidget(smilebar);
    smilemenu->addAction(smilewidgetaction);
    connect(smilebar, SIGNAL(smileClicked(QString)), ui->plainTextEditMessage, SLOT(insertPlainText(QString)));
    connect(smilebar, SIGNAL(smileClicked(QString)), ui->plainTextEditMessage, SLOT(setFocus()));
    ui->actionEmoticons->setMenu(smilemenu);
    smilebutton = new QToolButton();
    smilebutton->setDefaultAction(ui->actionEmoticons);
    smilebutton->setPopupMode(QToolButton::InstantPopup);
    ui->mainToolBar->addWidget(smilebutton);

    channellistdialog = new ChannelListDialog();
    connect(irc, SIGNAL(sigChannelListStart()), channellistdialog, SLOT(showAndClear()));
    connect(irc, SIGNAL(sigChannelListAddItem(QString,QString,QString)), channellistdialog,
            SLOT(addListItem(QString,QString,QString)));
    connect(irc, SIGNAL(sigChannelListEnd()), channellistdialog, SLOT(endOfList()));
    connect(channellistdialog, SIGNAL(channelDoubleClicked(QString)), irc, SLOT(joinChannel(QString)));

    connect(ui->pushButtonSend, SIGNAL(clicked()), ui->plainTextEditMessage, SIGNAL(sendKeyPressed()));
    connect(ui->plainTextEditMessage, SIGNAL(sendKeyPressed()), this, SLOT(sendPressed()));
    connect(ui->actionConnect, SIGNAL(triggered()), this, SLOT(connectPressed()));
    connect(ui->actionDisconnect, SIGNAL(triggered()), this, SLOT(disconnectPressed()));
    connect(ui->actionSettings, SIGNAL(triggered()), this, SLOT(settingsPressed()));
    connect(ui->actionJoin, SIGNAL(triggered()), this, SLOT(joinPressed()));
    connect(ui->treeWidget, SIGNAL(userDoubleClicked(QString)), this, SLOT(userDoubleClicked(QString)));
    connect(ui->actionPrivateChat, SIGNAL(triggered()), this, SLOT(privateChatPressed()));
    connect(ui->actionLeave_channel, SIGNAL(triggered()), this, SLOT(leaveChannelPressed()));
    connect(ui->actionKick, SIGNAL(triggered()), this, SLOT(kickPressed()));
    connect(ui->actionBan, SIGNAL(triggered()), this, SLOT(BanPressed()));
    connect(ui->actionKickBan, SIGNAL(triggered()), this, SLOT(kickBanPressed()));
    connect(ui->actionOp, SIGNAL(triggered()), this, SLOT(opPressed()));
    connect(ui->actionDeOp, SIGNAL(triggered()), this, SLOT(deOpPressed()));
    connect(ui->actionVoice, SIGNAL(triggered()), this, SLOT(voicePressed()));
    connect(ui->actiondeVoice, SIGNAL(triggered()), this, SLOT(devoicePressed()));
    connect(ui->pushButtonNick, SIGNAL(clicked()), this, SLOT(nickButtonPressed()));
    connect(ui->actionList_of_channels, SIGNAL(triggered()), irc, SLOT(getChannelsList()));
    connect(ui->actionAbout_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
    connect(ui->tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(tabCloseRequested(int)));
    connect(ui->actionInsert_to_editor, SIGNAL(triggered()), this, SLOT(insertUserToEditorPressed()));
    connect(ui->actionShowHide, SIGNAL(triggered()), this, SLOT(trayIconActivated()));
    connect(ui->actionQuit_program, SIGNAL(triggered()), this, SLOT(quitProgram()));
    connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(aboutPressed()));
    connect(ui->actionSound, SIGNAL(toggled(bool)), this, SLOT(soundActionToogled(bool)));
}
Beispiel #21
0
HRESULT CEffectsListDlg::ListEffects()
{   
	HRESULT hr=S_OK;
	CComPtr<ICreateDevEnum> pSysDevEnum;
	
	hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
		IID_ICreateDevEnum, (void **)&pSysDevEnum);

	if(hr != S_OK)return S_FALSE;
// Obtain a class enumerator for the video compressor category.
	CComPtr<IEnumMoniker> pEnumCat;
	hr = pSysDevEnum->CreateClassEnumerator(
		(type?CLSID_VideoEffects2Category:CLSID_VideoEffects1Category), 
		&pEnumCat, 0);

    CComPtr<IMoniker> pMoniker;
    ULONG cFetched;
    VARIANT varName={0};
    int nFilters=0;
    // If there are no filters of a requested type, show default string
    if (!pEnumCat)
    {
        return S_FALSE;
    }

    // Enumerate all items associated with the moniker
    while(pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK)
    {
        CComPtr<IPropertyBag> pPropBag;
        if(!pMoniker)continue;
        // Associate moniker with a file
        hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag,(void **)&pPropBag);
        
		if(FAILED(hr))continue;

        // Read filter name from property bag
        varName.vt = VT_BSTR;
        hr = pPropBag->Read(L"FriendlyName", &varName, 0);
        if (FAILED(hr))
            continue;

        // Read filter's CLSID from property bag.  This CLSID string will be
        // converted to a binary CLSID and passed to AddFilter(), which will
        // add the filter's name to the listbox and its CLSID to the listbox
        // item's DataPtr item.  When the user clicks on a filter name in
        // the listbox, we'll read the stored CLSID, convert it to a string,
        // and use it to find the filter's filename in the registry.
        VARIANT varFilterClsid;
        varFilterClsid.vt = VT_BSTR;

        // Read CLSID string from property bag
        hr = pPropBag->Read(L"GUID", &varFilterClsid, 0);
        if(SUCCEEDED(hr))
        {
            GUID* guidFilter = new GUID;

            // Add filter name and CLSID to listbox
            if(CLSIDFromString(varFilterClsid.bstrVal, guidFilter) == S_OK)
            {
			    addListItem(_bstr_t(varName.bstrVal).operator wchar_t*(),
					guidFilter);

				WCHAR sguid[256];
				StringFromGUID2(*guidFilter, sguid, 256);
//				OutputDebugString(_bstr_t(sguid).operator char*());
//				OutputDebugString("\r\n");
            }
			SysFreeString(varName.bstrVal);
            SysFreeString(varFilterClsid.bstrVal);
        }
     
        // Cleanup interfaces
 //       pPropBag->Release();
        pMoniker.Release();
    }

//	pEnumCat->Release();
//	pSysDevEnum->Release();
    return hr;
}
Beispiel #22
0
/**
 *\fn        int updateFileList(HTREEITEM hItem)
 *\brief     更新该节点的文件列表
 *\param[in] HTREEITEM hItem 树节点
 *\return    int 0成功,其它失败
 */
int CBrowseWnd::updateFileList(HTREEITEM hItem)
{
    if (NULL == hItem || 1 == (int)hItem) return -1;

    // 连接已断开,重连
    if (ssh_param_.exit)
    {
        _beginthread(sftp_thread_func, 0, &ssh_param_);
        return 0;
    }

    // 得到当前路径
    char path[1024] = "";
    getPath(hItem, path); // 得到路径

    // 目录连接
    if (isLink(hItem))
    {
        list_.SetFocus();
        sftp_get_link_path(&ssh_param_, path, path, sizeof(path)-1);
        hItem = createItem(path);
    }

    // 得到子树
    mapStrHtreeitem map;
    getSubtree(hItem, map);

    // 设置路径
    path_.SetWindowText(path);

    // 得到文件列表
    char *dir = new char[1024*1024];
    int ret = sftp_get_dir(&ssh_param_, path, dir, 1024*1024);

    if (0 != ret)
    {
        ssh_param_.exit = TRUE;
        map.clear();
        delete[] dir;
        return ret;
    }

    // 不刷新窗体
    tree_.SetRedraw(FALSE);
    list_.SetRedraw(FALSE);
    list_.SendMessage(LVM_DELETEALLITEMS, 0, 0);

    char line[1024];
    char filename[1024];

    for (int i = 0; 0 != dir[i]; )
    {
        strncpy_s(line, &dir[i+1], dir[i]);
        line[dir[i]] = '\0';

        VECTOR_STR data;
        CStrConver::TokenizeData(line, " ", data);

        if (data.size() < 9) continue;

        // 文件名
        strcpy_s(filename, sizeof(filename)-1, data[8].c_str());

        for (UINT j = 9; j < data.size(); j++) // 可能文件名中包含空格,再重新组成完整文件名
        {
            strcat_s(filename, " ");
            strcat_s(filename, data[j].c_str());
        }

        // 目录或连接
        bool isDir = ('d' == data[0].c_str()[0]);
        bool isLink = ('l' == data[0].c_str()[0]);
        bool isDirLnk = false;

        if (isLink)
        {
            char src[1024];
            sprintf_s(src, "%s%s", path, filename);

            char des[1024];
            isDirLnk = (1 == sftp_get_link_path(&ssh_param_, src, des, sizeof(des)-1));
        }

        if (isDir || isDirLnk)
        {
            mapStrHtreeitem::iterator iter = map.find(filename);

            if (map.end() == iter)
            {
                addTreeItem(hItem, filename, isLink);
            }
            else
            {
                map.erase(filename);
            }
        }
        else // 文件
        {
            addListItem(filename, data[4].c_str(),
                        data[5].c_str(), data[6].c_str(), data[7].c_str(),
                        &data[0][1], data[2].c_str(), data[3].c_str(),
                        hItem, isLink);
        }

        i += dir[i] + 1;
    }

    delete[] dir;

    // 删除多余的子节点
    for (mapStrHtreeitem::iterator iter = map.begin(); iter != map.end(); ++iter)
    {
        tree_.SendMessage(TVM_DELETEITEM, 0, (LPARAM)iter->second);
    }

    tree_.SendMessage(TVM_EXPAND, TVE_EXPAND, (LPARAM)hItem);
    tree_.SendMessage(TVM_SELECTITEM, TVGN_CARET, (LPARAM)hItem);
    list_.SendMessage(LVM_SORTITEMSEX, 0, (LPARAM)CompareFunc);

    tree_.SetRedraw(TRUE);
    list_.SetRedraw(TRUE);

    return 0;
}
Beispiel #23
0
seqan::ArgumentParser::ParseResult
parseCommandLine(SeqConsOptions & options, int argc, char const ** argv)
{
    // Setup ArgumentParser.
    seqan::ArgumentParser parser("seqcons2");
    // Set short description, version, and date.
    setShortDescription(parser, "Compute consensus from sequences.");
    setVersion(parser, SEQAN_APP_VERSION " [" SEQAN_REVISION "]");
    setDate(parser, SEQAN_DATE);

    // Define usage line and long description.
    addUsageLine(parser,
                 "\\fB-i\\fP \\fIINPUT.{fa,sam}\\fP [\\fB-oa\\fP \\fIOUT_ALIGN.{fa,sam}\\fP] "
                 "[\\fB-oc\\fP \\fIOUT_CONSENSUS.fa\\fP]");
    addDescription(parser,
                   "Compute consensus from sequences with and without approximate alignment information.");

    // Overall Program Options
    addOption(parser, seqan::ArgParseOption("q", "quiet", "Set verbosity to a minimum."));
    addOption(parser, seqan::ArgParseOption("v", "verbose", "Enable verbose output."));
    addOption(parser, seqan::ArgParseOption("vv", "very-verbose", "Enable very verbose output."));

    addOption(parser, seqan::ArgParseOption("m", "method", "Method to perform.  See section \\fIMethods\\fP "
                                            "below for details.", seqan::ArgParseOption::STRING, "METHOD"));
    setValidValues(parser, "method", "nop realign align_consensus overlap_consensus contig_consensus pos_consensus");
    setDefaultValue(parser, "method", "pos_consensus");

    // I/O Options
    addSection(parser, "I/O Options");

    addOption(parser, seqan::ArgParseOption("i", "input-file", "Input file.", seqan::ArgParseOption::INPUT_FILE,
                                            "INPUT"));
    setRequired(parser, "input-file", true);
    setValidValues(parser, "input-file", "sam fa fasta");

    addOption(parser, seqan::ArgParseOption("oa", "output-alignment-file", "Output file with alignment.",
                                            seqan::ArgParseOption::OUTPUT_FILE, "OUT_ALIGNMENT"));
    setRequired(parser, "output-alignment-file", false);
    setValidValues(parser, "output-alignment-file", "sam txt");

    addOption(parser, seqan::ArgParseOption("oc", "output-consensus-file", "Output file with consensus sequence.",
                                            seqan::ArgParseOption::OUTPUT_FILE, "OUT_CONSENSUS"));
    setRequired(parser, "output-consensus-file", false);
    setValidValues(parser, "output-consensus-file", "fa fasta");

    // Alignment Quality Filter Options
    addSection(parser, "Alignment Quality Filter Options");

    addOption(parser, seqan::ArgParseOption("", "overlap-min-length", "Minimal overlap length.",
                                            seqan::ArgParseOption::INTEGER, "LENGTH"));
    setMinValue(parser, "overlap-min-length", "0");
    setDefaultValue(parser, "overlap-min-length", "20");

    addOption(parser, seqan::ArgParseOption("", "overlap-max-error", "Maximal error rate in overlap as percentage.",
                                            seqan::ArgParseOption::DOUBLE, "RATE"));
    setMinValue(parser, "overlap-max-error", "0.0");
    setDefaultValue(parser, "overlap-max-error", "5.0");

    addOption(parser, seqan::ArgParseOption("", "overlap-min-count", "Minimal overlap count.",
                                            seqan::ArgParseOption::INTEGER, "COUNT"));
    setMinValue(parser, "overlap-min-count", "0");
    setDefaultValue(parser, "overlap-min-count", "3");

    addOption(parser, seqan::ArgParseOption("", "overlap-window-size", "Window size to look for alignments.",
                                            seqan::ArgParseOption::INTEGER, "SIZE"));
    setMinValue(parser, "overlap-window-size", "0");
    setDefaultValue(parser, "overlap-window-size", "20");

    // K-mer Filter Options
    addSection(parser, "K-Mer Filter Options");

    addOption(parser, seqan::ArgParseOption("", "k-mer-size", "The k-mer size to use.",
                                            seqan::ArgParseOption::INTEGER, "LENGTH"));
    setMinValue(parser, "k-mer-size", "5");
    setDefaultValue(parser, "k-mer-size", "20");

    addOption(parser, seqan::ArgParseOption("", "k-mer-max-occ", "Ignore k-mer with higher occurence count, 0 to disable.",
                                            seqan::ArgParseOption::INTEGER, "COUNT"));
    setMinValue(parser, "k-mer-max-occ", "0");
    setDefaultValue(parser, "k-mer-max-occ", "200");

    // Realignment Options
    addSection(parser, "Realignment Options");

    addOption(parser, seqan::ArgParseOption("", "realign-bandwidth",
                                            "Bandwidth to use for pairwise alignments in realignment.",
                                            seqan::ArgParseOption::INTEGER, "LENGTH"));
    setMinValue(parser, "realign-bandwidth", "5");
    setDefaultValue(parser, "realign-bandwidth", "10");

    addOption(parser, seqan::ArgParseOption("", "realign-environment",
                                            "Environment for extraction in realignment.",
                                            seqan::ArgParseOption::INTEGER, "COUNT"));
    setMinValue(parser, "realign-environment", "5");
    setDefaultValue(parser, "realign-environment", "20");

    // Add Methods Section
    addTextSection(parser, "Methods");
    addListItem(parser, "\\fBnop\\fP",
                "Perform no action, just perform file conversion if possible.");
    addListItem(parser, "\\fBrealign\\fP",
                "Perform realignment, requires input to be a SAM file to provide approximate position "
                "information, creates consensus sequence after realignment.");
    addListItem(parser, "\\fBoverlap_consensus\\fP",
                "Perform MSA with overlap alignments of the input ignoring any given coordinates, then realign. "
                "This is most suited when computing the consensus of reads where the underlying sequence is very "
                "similar and most differences stem from sequencing errors and not genomic variation. All "
                "pairwise alignments computed here are banded.");
    addListItem(parser, "\\fBalign_consensus\\fP",
                "Perform MSA with global alignments of the input ignoring any given coordinates, then realign. "
                "This will computed unbanded global ends-gap free pairwise alignments.  This is also suitable "
                "when aligning different sequences, e.g. clustered transcripts.  Using this method, seqcons "
                "will be similar to calling SeqAn::T-Coffee, followed by realignment and consensus computation.");
    addListItem(parser, "\\fBcontig_consensus\\fP",
                "Perform MSA of the input, contig by contig, requires contig information, then realign. Input "
                "must be SAM.");
    addListItem(parser, "\\fBpos_consensus\\fP",
                "Perform consensus of the input, then realign. Requires approximate coordinate information in "
                "SAM file.");

    // Add Output Section
    addTextSection(parser, "Output Formats");
    addText(parser,
            "The program can write out the consensus sequence in FASTA format and optionally the alignment of the "
            "input sequences against the consensus in SAM/BAM format.  When using the extension \\fI.txt\\fP, seqcons "
            "will write out the MSA as a plain text visualization.");

    // Add Examples Section
    addTextSection(parser, "Examples");
    addListItem(parser,
                "\\fBseqcons\\fP \\fB-m\\fP \\fIovl_consensus\\fP \\fB-i\\fP \\fIreads.fa\\fP \\fB-oa\\fP "
                "\\fIout.sam\\fP \\fB-oc\\fP \\fIcons.fa\\fP",
                "Compute MSA of the sequences in \\fIreads.fa\\fP.  The consensus sequence is written to "
                "\\fIcons.fa\\fP and the alignment of the sequences in \\fIreads.fa\\fP is written to "
                "\\fIout.sam\\fP.");
    addListItem(parser,
                "\\fBseqcons\\fP \\fB-m\\fP \\fIrealign\\fP \\fB-i\\fP \\fIin.sam\\fP \\fB-oa\\fP \\fIout.sam\\fP",
                "Read in multi-read alignment from \\fIin.sam\\fP, refine it using Anson-Myers realignment and "
                "write out the refined alignment to \\fIout.sam\\fP");

    // Parse command line.
    seqan::ArgumentParser::ParseResult res = seqan::parse(parser, argc, argv);

    // Only extract  options if the program will continue after parseCommandLine()
    if (res != seqan::ArgumentParser::PARSE_OK)
        return res;

    // Extract option values.

    if (isSet(parser, "quiet"))
        options.verbosity = 0;
    if (isSet(parser, "verbose"))
        options.verbosity = 2;
    if (isSet(parser, "very-verbose"))
        options.verbosity = 3;

    std::string opStr;
    getOptionValue(opStr, parser, "method");
    options.operation = strToMethod(opStr.c_str());

    getOptionValue(options.inputFile, parser, "input-file");
    getOptionValue(options.outputFileAlignment, parser, "output-alignment-file");
    getOptionValue(options.outputFileConsensus, parser, "output-consensus-file");

    getOptionValue(options.overlapMinLength, parser, "overlap-min-length");
    getOptionValue(options.overlapMaxErrorRate, parser, "overlap-max-error");
    getOptionValue(options.overlapWindowSize, parser, "overlap-window-size");

    getOptionValue(options.kMerSize, parser, "k-mer-size");
    getOptionValue(options.kMerMaxOcc, parser, "k-mer-max-occ");

    getOptionValue(options.reAlignmentBandwidth, parser, "realign-bandwidth");
    getOptionValue(options.reAlignmentEnvironment, parser, "realign-environment");

    return seqan::ArgumentParser::PARSE_OK;
}
seqan::ArgumentParser::ParseResult
parseCommandLine(ModifyStringOptions & options, int argc, char const ** argv)
{
    // Setup ArgumentParser.
    seqan::ArgumentParser parser("modify_string");
    // Set short description, version, and date.
    setShortDescription(parser, "String Modifier");
    setVersion(parser, "1.0");
    setDate(parser, "July 2012");

    // Define usage line and long description.
    addUsageLine(parser,
                 "[\\fIOPTIONS\\fP] \"\\fITEXT\\fP\"");
    addDescription(parser,
                   "This program allows simple character modifications to "
                           "each i-th character.");

    // We require one argument.
    addArgument(parser, seqan::ArgParseArgument(
            seqan::ArgParseArgument::STRING, "TEXT"));

    // Define Options -- Section Modification Options
    addSection(parser, "Modification Options");
    addOption(parser, seqan::ArgParseOption(
            "i", "period", "Period to use for the index.",
            seqan::ArgParseArgument::INTEGER, "INT"));
    setDefaultValue(parser, "period", "1");
    addOption(parser, seqan::ArgParseOption(
            "U", "uppercase", "Select to-uppercase as operation."));
    addOption(parser, seqan::ArgParseOption(
            "L", "lowercase", "Select to-lowercase as operation."));

    // Add Examples Section.
    addTextSection(parser, "Examples");
    addListItem(parser,
                "\\fBmodify_string\\fP \\fB-U\\fP \\fIveryverylongword\\fP",
                "Print upper case version of \"veryverylongword\"");
    addListItem(parser,
                "\\fBmodify_string\\fP \\fB-L\\fP \\fB-i\\fP \\fI3\\fP "
                        "\\fIveryverylongword\\fP",
                "Print \"veryverylongword\" with every third character "
                        "converted to upper case.");

    // Parse command line.
    seqan::ArgumentParser::ParseResult res = seqan::parse(parser, argc, argv);

    // Only extract  options if the program will continue after parseCommandLine()
    if (res != seqan::ArgumentParser::PARSE_OK)
        return res;

    // Extract option values.
    getOptionValue(options.period, parser, "period");
    options.toUppercase = isSet(parser, "uppercase");
    options.toLowercase = isSet(parser, "lowercase");
    seqan::getArgumentValue(options.text, parser, 0);

    // If both to-uppercase and to-lowercase were selected then this is an error.
    if (options.toUppercase && options.toLowercase)
    {
        std::cerr << "ERROR: You cannot specify both to-uppercase and to-lowercase!\n";
        return seqan::ArgumentParser::PARSE_ERROR;
    }

    return seqan::ArgumentParser::PARSE_OK;
}
Beispiel #25
0
seqan::ArgumentParser::ParseResult
parseCommandLine(MasonGenomeOptions & options, int argc, char const ** argv)
{
    // Setup ArgumentParser.
    seqan::ArgumentParser parser("mason_genome");
    // Set short description, version, and date.
    setShortDescription(parser, "Random Genome Simulation");
    setVersion(parser, "2.1");
    setDate(parser, "March 2013");
    setCategory(parser, "Simulators");

    // Define usage line and long description.
    addUsageLine(parser, "[\\fIOPTIONS\\fP] [\\fB-l\\fP \\fILEN\\fP]+ \\fB-o\\fP \\fIOUT.fa\\fP");
    addDescription(parser,
                   "Simulate a random genome to the output file.  For each \\fB-l\\fP/\\fB--contig-length\\fP "
                   "entry, a contig with the given length will be simulated.");

    // We require one argument.
    addOption(parser, seqan::ArgParseOption("q", "quiet", "Set verbosity to a minimum."));
    addOption(parser, seqan::ArgParseOption("v", "verbose", "Enable verbose output."));
    addOption(parser, seqan::ArgParseOption("vv", "very-verbose", "Enable very verbose output."));

    addSection(parser, "Simulation Configuration");
    addOption(parser, seqan::ArgParseOption("l", "contig-length",
                                            "Length of the contig to simulate. Give one \\fB-l\\fP "
                                            "value for each contig to simulate.",
                                            seqan::ArgParseOption::INTEGER, "LENGTH", true));
    setMinValue(parser, "contig-length", "1");
    setRequired(parser, "contig-length");

    addOption(parser, seqan::ArgParseOption("s", "seed", "The seed to use for the random number generator.",
                                            seqan::ArgParseOption::INTEGER, "INT"));
    setDefaultValue(parser, "seed", 0);

    addSection(parser, "Output Options");
    addOption(parser, seqan::ArgParseOption("o", "out-file", "Output file.",
                                            seqan::ArgParseOption::OUTPUTFILE, "FILE"));
    setValidValues(parser, "out-file", "fa fasta");
    setRequired(parser, "out-file");

    // Add Examples Section.
    addTextSection(parser, "Examples");
    addListItem(parser, "\\fBmason_genome\\fP \\fB-l\\fP 1000 \\fB-l\\fP 4000 \\fB-o\\fP \\fIgenome.fa\\fP",
                "Simulate a genome with two contigs of lengths 1000 and 4000 and write it to genome.fa.");

    // Parse command line.
    seqan::ArgumentParser::ParseResult res = seqan::parse(parser, argc, argv);

    // Only extract  options if the program will continue after parseCommandLine()
    if (res != seqan::ArgumentParser::PARSE_OK)
        return res;

    // Extract option values.
    if (isSet(parser, "quiet"))
        options.verbosity = 0;
    if (isSet(parser, "verbose"))
        options.verbosity = 2;
    if (isSet(parser, "very-verbose"))
        options.verbosity = 3;

    getOptionValue(options.outputFilename, parser, "out-file");
    getOptionValue(options.seed, parser, "seed");

    for (unsigned i = 0; i < getOptionValueCount(parser, "contig-length"); ++i)
    {
        int len = 0;
        getOptionValue(len, parser, "contig-length", i);
        appendValue(options.contigLengths, len);
    }

    return seqan::ArgumentParser::PARSE_OK;
}