task LCD_ButtonPress() { int buttonPress = 0; int title = 2; while(lcdRun) { buttonPress = titles(title); title = updateTitle(buttonPress); batteryVoltagle(buttonPress); updateAuto(buttonPress); } }
const string Package::FullTitle(bool localized) const { string expanded = ExpandedTitle(localized); if ( !expanded.empty() ) return expanded; auto items = PropertiesMatching(DCType::Title); if ( items.size() == 1 ) return items[0]->Value(); IRI displaySeqIRI(MakePropertyIRI("display-seq")); // http://idpf.org/epub/vocab/package/#display-seq std::vector<string> titles(items.size()); auto sequencedItems = PropertiesMatching(displaySeqIRI); if ( !sequencedItems.empty() ) { // all these have a 1-based sequence number for ( auto item : sequencedItems ) { PropertyExtensionPtr extension = item->ExtensionWithIdentifier(displaySeqIRI); size_t sz = strtoul(extension->Value().c_str(), nullptr, 10) - 1; titles[sz] = (localized ? item->LocalizedValue() : item->Value()); } } else { titles.clear(); // insert any non-sequenced items at the head of the list, in order for ( auto item : items ) { titles.emplace_back((localized ? item->LocalizedValue() : item->Value())); } } // put them all together now auto pos = titles.begin(); // TODO: this ought to be localized based on the value of Language(). std::stringstream ss; ss << *(pos++) << ": " << *(pos++); while ( pos != titles.end() ) { ss << ", " << *(pos++); } return string(ss.str()); }
const string Package::FullTitle() const { MetadataMap items = MetadataItemsWithDCType(Metadata::DCType::Title); if ( items.size() == 1 ) return items[0]->Value(); IRI displaySeqIRI(MakePropertyIRI("display-seq")); // http://idpf.org/epub/vocab/package/#display-seq std::vector<string> titles(items.size()); MetadataMap sequencedItems = MetadataItemsWithProperty(displaySeqIRI); if ( !sequencedItems.empty() ) { // all these have a 1-based sequence number for ( auto item : sequencedItems ) { const Metadata::Extension* extension = item->ExtensionWithProperty(displaySeqIRI); size_t sz = strtoul(extension->Value().c_str(), nullptr, 10) - 1; titles[sz] = item->Value(); } } else { titles.clear(); // insert any non-sequenced items at the head of the list, in order for ( auto item : items ) { titles.emplace_back(item->Value()); } } // put them all together now auto pos = titles.begin(); // TODO: this ought to be localized based on the value of Language(). std::stringstream ss; ss << *(pos++) << ": " << *(pos++); while ( pos != titles.end() ) { ss << ", " << *(pos++); } return string(ss.str()); }
http::doc urlhandle(const std::string &url, const std::string &querystr, const uint32_t remoteip) { //std::cout << url << "\n"; const uint32_t localip = util::str2ip("127.0.0.1"); // TODO Make this configurable std::vector<std::string> path = util::strsplit(url, '/'); if (path.size() && path[0] == "") path.erase(path.begin()); for (std::string &elem : path) elem = util::urldecode(elem); std::unordered_map<std::string, std::string> query{}; if (querystr.size() > 0) for (const std::string &qu : util::strsplit(querystr, '&')) { std::string::size_type idx = qu.find("="); if (idx == qu.npos) query[util::urldecode(qu)] = ""; else query[util::urldecode(qu.substr(0, idx), true)] = util::urldecode(qu.substr(idx + 1), true); } try { if (path.size() == 0 || path[0] == "") return home(remoteip == localip); if (path[0] == "search" || path[0] == "view" || path[0] == "content" || path[0] == "complete" || path[0] == "titles" || path[0] == "shuffle") { if (path.size() < 2) return error("Bad Request", "Missing volume ID"); if (! volumes.check(path[1])) return error("Not Found", "No volume with ID “" + path[1] + "” exists"); std::string input{}; std::string::const_iterator start = util::find_nth(url.begin(), url.end(), '/', 3) + 1; if (start > url.end()) input = ""; else input = util::urldecode(std::string{start, url.end()}); std::string input_qstr = input + (querystr.size() ? "?" + querystr : ""); if (path[0] == "search") return search(volumes.get(path[1]), input_qstr); else if (path[0] == "view") return content(volumes.get(path[1]), input, true); else if (path[0] == "complete") return complete(volumes.get(path[1]), input_qstr); else if (path[0] == "titles") return titles(volumes.get(path[1]), input_qstr); else if (path[0] == "shuffle") return shuffle(volumes.get(path[1])); else return content(volumes.get(path[1]), input); } else if (path[0] == "load" || path[0] == "unload") { if (path.size() < 2) return error("Bad Request", "Missing category name"); if (path[0] == "load") return loadcat(path[1]); else return unloadcat(path[1]); } else if (path[0] == "external") { if (path.size() < 2) return error("Bad Request", "Missing external path"); if (remoteip != localip) return error("Denied", "You do not have permission to access this functionality"); return http::doc{"text/plain", volumes.load_external(path[1])}; } else if (path[0] == "pref") return pref(); else if (path[0] == "rsrc") return rsrc(util::strjoin(path, '/', 1)); else if (path[0] == "add") return http::doc{resource("html/add.html")}; else if (path[0] == "action") { if (path.size() < 2) return error("Bad Request", "No action selected"); if (remoteip != localip) return error("Denied", "You do not have permission to access this functionality"); return action(path[1], query); } else throw handle_error{"Unknown action “" + path[0] + "”"}; } catch (std::exception &e) { return error("Error", e.what()); } }
static void DumpText(bool doHTML, const BlockMultipleAlignment *alignment, const vector < int >& rowOrder, BlockMultipleAlignment::eUnalignedJustification justification, CNcbiOstream& os) { #define LEFT_JUSTIFY resetiosflags(IOS_BASE::right) << setiosflags(IOS_BASE::left) #define RIGHT_JUSTIFY resetiosflags(IOS_BASE::left) << setiosflags(IOS_BASE::right) // do whole alignment for now unsigned int firstCol = 0, lastCol = alignment->AlignmentWidth() - 1, nColumns = 60; if (lastCol >= alignment->AlignmentWidth() || firstCol > lastCol || nColumns < 1) { ERRORMSG("DumpText() - nonsensical display region parameters"); return; } // HTML colors static const string bgColor("#FFFFFF"), rulerColor("#700777"), numColor("#229922"); // set up the titles and uids, figure out how much space any seqLoc string will take vector < string > titles(alignment->NRows()), uids(doHTML ? alignment->NRows() : 0); unsigned int alnRow, row, maxTitleLength = 0, maxSeqLocStrLength = 0, leftMargin, decimalLength; for (alnRow=0; alnRow<alignment->NRows(); ++alnRow) { row = rowOrder[alnRow]; // translate display row -> data row const Sequence *sequence = alignment->GetSequenceOfRow(row); titles[row] = sequence->identifier->ToString(); if (titles[row].size() > maxTitleLength) maxTitleLength = titles[row].size(); decimalLength = ((int) log10((double) sequence->Length())) + 1; if (decimalLength > maxSeqLocStrLength) maxSeqLocStrLength = decimalLength; // uid for link to entrez if (doHTML) { // prefer gi's, since accessions can be outdated if (sequence->identifier->gi != MoleculeIdentifier::VALUE_NOT_SET) { uids[row] = NStr::IntToString(sequence->identifier->gi); } else if (sequence->identifier->pdbID.size() > 0) { if (sequence->identifier->pdbID != "query" && sequence->identifier->pdbID != "consensus") { uids[row] = sequence->identifier->pdbID; if (sequence->identifier->pdbChain != ' ') uids[row] += string("_") + (char) sequence->identifier->pdbChain; } } else { uids[row] = sequence->identifier->GetLabel(); } } } leftMargin = maxTitleLength + maxSeqLocStrLength + 2; // need to keep track of first, last seqLocs for each row in each paragraph; // find seqLoc of first residue >= firstCol vector < int > lastShownSeqLocs(alignment->NRows()); unsigned int alnLoc, i; char ch; Vector color, bgCol; bool highlighted, drawBG; for (alnRow=0; alnRow<alignment->NRows(); ++alnRow) { row = rowOrder[alnRow]; // translate display row -> data row lastShownSeqLocs[row] = -1; for (alnLoc=0; alnLoc<firstCol; ++alnLoc) { if (!alignment->GetCharacterTraitsAt(alnLoc, row, justification, &ch, &color, &highlighted, &drawBG, &bgCol)) ch = '~'; if (ch != '~') lastShownSeqLocs[row]++; } } // header if (doHTML) os << "<HTML><TITLE>Alignment Exported From Cn3D</TITLE>\n" << "<BODY BGCOLOR=" << bgColor << ">\n"; // split alignment up into "paragraphs", each with nColumns if (doHTML) os << "<TABLE>\n"; int paragraphStart, nParags = 0; for (paragraphStart=0; (firstCol+paragraphStart)<=lastCol; paragraphStart+=nColumns, ++nParags) { // start table row if (doHTML) os << "<tr><td><pre>\n"; else if (paragraphStart > 0) os << '\n'; // do ruler unsigned int nMarkers = 0, width; if (doHTML) os << "<font color=" << rulerColor << '>'; for (i=0; i<nColumns && (firstCol+paragraphStart+i)<=lastCol; ++i) { if ((paragraphStart+i+1)%10 == 0) { if (nMarkers == 0) width = leftMargin + i + 1; else width = 10; os << RIGHT_JUSTIFY << setw(width) << (paragraphStart+i+1); ++nMarkers; } } if (doHTML) os << "</font>"; os << '\n'; if (doHTML) os << "<font color=" << rulerColor << '>'; for (i=0; i<leftMargin; ++i) os << ' '; for (i=0; i<nColumns && (firstCol+paragraphStart+i)<=lastCol; ++i) { if ((paragraphStart+i+1)%10 == 0) os << '|'; else if ((paragraphStart+i+1)%5 == 0) os << '*'; else os << '.'; } if (doHTML) os << "</font>"; os << '\n'; int nDisplayedResidues; // output each alignment row for (alnRow=0; alnRow<alignment->NRows(); ++alnRow) { row = rowOrder[alnRow]; // translate display row -> data row const Sequence *sequence = alignment->GetSequenceOfRow(row); // actual sequence characters and colors; count how many non-gaps in each row nDisplayedResidues = 0; string rowChars; vector < string > rowColors; for (i=0; i<nColumns && (firstCol+paragraphStart+i)<=lastCol; ++i) { if (!alignment->GetCharacterTraitsAt(firstCol+paragraphStart+i, row, justification, &ch, &color, &highlighted, &drawBG, &bgCol)) ch = '?'; rowChars += ch; wxString colorStr; colorStr.Printf("#%02x%02x%02x", (int) (color[0]*255), (int) (color[1]*255), (int) (color[2]*255)); rowColors.push_back(WX_TO_STD(colorStr)); if (ch != '~') ++nDisplayedResidues; } // title if (doHTML && uids[row].size() > 0) { string descr = sequence->GetDescription(); os << "<a href=\"http://www.ncbi.nlm.nih.gov/protein/" << uids[row] << "\" onMouseOut=\"window.status=''\"\n" << "onMouseOver=\"window.status='" << ShortAndEscapedString((descr.size() > 0) ? descr : titles[row]) << "';return true\">" << setw(0) << titles[row] << "</a>"; } else { os << setw(0) << titles[row]; } os << setw(maxTitleLength+1-titles[row].size()) << ' '; // left start pos (output 1-numbered for humans...) if (doHTML) os << "<font color=" << numColor << '>'; if (nDisplayedResidues > 0) os << RIGHT_JUSTIFY << setw(maxSeqLocStrLength) << (lastShownSeqLocs[row]+2) << ' '; else os << RIGHT_JUSTIFY << setw(maxSeqLocStrLength) << ' ' << ' '; // dump sequence, applying color changes only when necessary if (doHTML) { string prevColor; for (i=0; i<rowChars.size(); ++i) { if (rowColors[i] != prevColor) { os << "</font><font color=" << rowColors[i] << '>'; prevColor = rowColors[i]; } os << rowChars[i]; } os << "</font>"; } else os << rowChars; // right end pos if (nDisplayedResidues > 0) { os << ' '; if (doHTML) os << "<font color=" << numColor << '>'; os << LEFT_JUSTIFY << setw(0) << (lastShownSeqLocs[row]+nDisplayedResidues+1); if (doHTML) os << "</font>"; } os << '\n'; // setup to begin next parag lastShownSeqLocs[row] += nDisplayedResidues; } // end table row if (doHTML) os << "</pre></td></tr>\n"; } if (doHTML) os << "</TABLE>\n" << "</BODY></HTML>\n"; // additional sanity check on seqloc markers if (firstCol == 0 && lastCol == alignment->AlignmentWidth()-1) { for (alnRow=0; alnRow<alignment->NRows(); ++alnRow) { row = rowOrder[alnRow]; // translate display row -> data row if (lastShownSeqLocs[row] != (int)alignment->GetSequenceOfRow(row)->Length() - 1) { ERRORMSG("DumpText: full display - seqloc markers don't add up for row " << row); break; } } if (alnRow != alignment->NRows()) ERRORMSG("DumpText: full display - seqloc markers don't add up correctly"); } }
int main(int argc, char *argv[]) { char hqet_file[80] ; char hqet_file_one[80] ; Real *velocity , *velocity_one ; int *momentum , *momentum_one ; complex *corr , *corr_one ; int *corr_oper_list; int *corr_copy_list; int nt , nt_one ; int novel , novel_one ; int no_mom , no_mom_one ; int no_oper , no_oper_one; int no_zonked = 1 ; int no_spectator = 1 ; int no_zonked_one = 1 ; int no_spectator_one = 1 ; /***--------------------------------------------------*****/ printf("==================================================\n"); printf(" Comparison of the hqet heavy --> light three pt \n"); printf("==================================================\n"); if( argc != 3 ) { printf("usage:: %s [hqet 3pt file ] [hqet 3pt file ] \n",argv[0]); exit(1); } strcpy(hqet_file,argv[1]); strcpy(hqet_file_one,argv[2]); /*** read and reserve memory for the three point function ******/ read_hqet_form_corr(&corr,&corr_oper_list,&corr_copy_list, &momentum , &velocity, &nt, &novel, &no_mom , &no_oper, &no_spectator , &no_zonked , hqet_file ); read_hqet_form_corr(&corr_one,&corr_oper_list, &corr_copy_list, &momentum_one , &velocity_one, &nt_one, &novel_one, &no_mom_one , &no_oper_one, &no_spectator_one , &no_zonked_one , hqet_file_one ); /*** check the parameters of the two files ****/ if( nt != nt_one ) { printf("ERROR: mismatch between the timeslices of the two files %d != %d \n",nt,nt_one); exit(1); } if( novel != novel_one ) { printf("ERROR: mismatch between the velocites of the two files %d != %d \n",novel,novel_one); exit(1); } if( no_oper != no_oper_one ) { printf("ERROR: mismatch between the number of operators of the two files %d != %d \n",no_oper,no_oper_one); exit(1); } if( no_mom != no_mom_one ) { printf("ERROR: mismatch between the momentum of the two files %d != %d \n",no_mom,no_mom_one); exit(1); } /*** write out some titles *****/ titles(nt, novel,no_mom, no_oper,velocity,momentum) ; /*** write the two point function to the terminal ****/ diff_hl_form(corr,corr_one,corr_oper_list,corr_copy_list, no_zonked,no_spectator,no_mom,novel,no_oper,nt) ; /*** free up the reserved memory **/ free(corr); free(corr_one); free(corr_oper_list); free(corr_copy_list); free(velocity) ; free(velocity_one) ; free(momentum) ; free(momentum_one) ; return 0 ; }
void K3bVideoDVDRippingDialog::slotStartClicked() { // // check if the selected audio codec is usable for all selected audio streams // We can only use the AC3 pass-through mode for AC3 streams // if( m_w->selectedAudioCodec() == K3bVideoDVDTitleTranscodingJob::AUDIO_CODEC_AC3_PASSTHROUGH ) { for( QMap<QCheckListItem*, K3bVideoDVDRippingJob::TitleRipInfo>::iterator it = m_titleRipInfos.begin(); it != m_titleRipInfos.end(); ++it ) { if( m_dvd[it.data().title-1].numAudioStreams() > 0 && m_dvd[it.data().title-1].audioStream(it.data().audioStream).format() != K3bVideoDVD::AUDIO_FORMAT_AC3 ) { KMessageBox::sorry( this, i18n("<p>When using the <em>AC3 pass-through</em> audio codec all selected audio " "streams need to be in AC3 format. Please select another audio codec or " "choose AC3 audio streams for all ripped titles."), i18n("AC3 Pass-through") ); return; } } } // check if we need to overwrite some files... QStringList filesToOverwrite; for( QMap<QCheckListItem*, K3bVideoDVDRippingJob::TitleRipInfo>::iterator it = m_titleRipInfos.begin(); it != m_titleRipInfos.end(); ++it ) { if( QFile::exists( it.data().filename ) ) filesToOverwrite.append( it.data().filename ); } if( !filesToOverwrite.isEmpty() ) if( KMessageBox::questionYesNoList( this, i18n("Do you want to overwrite these files?"), filesToOverwrite, i18n("Files Exist"), i18n("Overwrite"), KStdGuiItem::cancel() ) == KMessageBox::No ) return; QSize videoSize = m_w->selectedPictureSize(); int i = 0; QValueVector<K3bVideoDVDRippingJob::TitleRipInfo> titles( m_titleRipInfos.count() ); for( QMapConstIterator<QCheckListItem*, K3bVideoDVDRippingJob::TitleRipInfo> it = m_titleRipInfos.begin(); it != m_titleRipInfos.end(); ++it ) { titles[i] = it.data(); titles[i].videoBitrate = 0; // use the global bitrate set below titles[i].width = videoSize.width(); titles[i].height = videoSize.height(); ++i; } // sort the titles which come from a map and are thus not sorted properly // simple bubble sort for these small arrays is sufficient for( unsigned int i = 0; i < titles.count(); ++i ) { for( unsigned int j = i+1; j < titles.count(); ++j ) { if( titles[i].title > titles[j].title ) { K3bVideoDVDRippingJob::TitleRipInfo tmp = titles[i]; titles[i] = titles[j]; titles[j] = tmp; } } } // start the job K3bJobProgressDialog dlg( parentWidget() ); K3bVideoDVDRippingJob* job = new K3bVideoDVDRippingJob( &dlg, &dlg ); job->setVideoDVD( m_dvd ); job->setTitles( titles ); job->setVideoBitrate( m_w->m_spinVideoBitrate->value() ); job->setTwoPassEncoding( m_w->m_checkTwoPassEncoding->isChecked() ); job->setResampleAudioTo44100( m_w->m_checkAudioResampling->isChecked() ); job->setAutoClipping( m_w->m_checkAutoClipping->isChecked() ); job->setVideoCodec( m_w->selectedVideoCodec() ); job->setAudioCodec( m_w->selectedAudioCodec() ); job->setLowPriority( m_w->m_checkLowPriority->isChecked() ); job->setAudioBitrate( m_w->selectedAudioBitrate() ); job->setAudioVBR( m_w->m_checkAudioVBR->isChecked() ); hide(); dlg.startJob( job ); close(); }