/** * Constructor **/ BinarizationPlugin::BinarizationPlugin(QObject* parent) : QObject(parent) { // create run IDs QVector<QString> runIds; runIds.resize(id_end); runIds[id_binarize_otsu] = "4398d8e26fe9454384432e690b47d4d3"; runIds[id_binarize_su] = "73c1efff27c043d298d8acd99530af1d"; runIds[id_binarize_su_mask] = "051d7f9d278a4c7ab3f97822a288c276"; mRunIDs = runIds.toList(); // create menu actions QVector<QString> menuNames; menuNames.resize(id_end); menuNames[id_binarize_otsu] = tr("&Otsu Threshold"); menuNames[id_binarize_su] = tr("&Su Binarization"); menuNames[id_binarize_su_mask] = tr("&Su Binarization with Mask Estimation"); mMenuNames = menuNames.toList(); // create menu status tips QVector<QString> statusTips; statusTips.resize(id_end); statusTips[id_binarize_otsu] = tr("Thresholds a document with the famous Otsu method"); statusTips[id_binarize_su] = tr("Thresholds a document with the Su method"); statusTips[id_binarize_su_mask] = tr("Thresholds a document with the Su method and estimates the mask"); mMenuStatusTips = statusTips.toList(); mBBSConfig.loadSettings(); mBBSConfig.saveSettings(); // save settings (to write default settings) }
/** * Constructor **/ DkPageExtractionPlugin::DkPageExtractionPlugin(QObject* parent) : QObject(parent) { // create run IDs QVector<QString> runIds; runIds.resize(id_end); for (int idx = 0; idx < id_end; idx++) runIds[idx] = QUuid::createUuid().toString(); mRunIDs = runIds.toList(); // create menu actions QVector<QString> menuNames; menuNames.resize(id_end); menuNames[id_crop_to_page] = tr("Crop to Page"); menuNames[id_crop_to_metadata] = tr("Crop to Metadata"); menuNames[id_draw_to_page] = tr("Draw to Page"); menuNames[id_eval_page] = tr("Evaluate Page"); mMenuNames = menuNames.toList(); // create menu status tips QVector<QString> statusTips; statusTips.resize(id_end); statusTips[id_crop_to_page] = tr("Finds a page in a document image and then crops the image to that page."); statusTips[id_crop_to_metadata] = tr("Finds a page in a document image and then saves the coordinates to the XMP metadata."); statusTips[id_draw_to_page] = tr("Finds a page in a document image and then draws the found document boundaries."); statusTips[id_eval_page] = tr("Loads GT and computes the Jaccard index."); mMenuStatusTips = statusTips.toList(); QFileInfo resPath(QDir("D:/dmrz/numerical-results/"), "results-" + QDateTime::currentDateTime().toString("yyyy-MM-dd HH-mm-ss") + ".txt"); mResultPath = resPath.absoluteFilePath(); }
/** * Constructor **/ DkImageStitchingPlugin::DkImageStitchingPlugin(QObject* parent) : QObject(parent) { // create run IDs QVector<QString> runIds; runIds.resize(id_end); mRunIDs = runIds.toList(); // create menu actions QVector<QString> menuNames; menuNames.resize(id_end); mMenuNames = menuNames.toList(); // create menu status tips QVector<QString> statusTips; statusTips.resize(id_end); mMenuStatusTips = statusTips.toList(); }
OsmAnd::RouteCalculationResult OsmAnd::RoutePlanner::prepareResult( OsmAnd::RoutePlannerContext::CalculationContext* context, std::shared_ptr<RoutePlannerContext::RouteCalculationSegment> finalSegment, bool leftSideNavigation) { // Prepare result QVector< std::shared_ptr<RouteSegment> > route; auto pFinalSegment = dynamic_cast<RoutePlannerContext::RouteCalculationFinalSegment*>(finalSegment.get()); // Get results from opposite direction roads auto segment = pFinalSegment->_reverseWaySearch ? finalSegment : pFinalSegment->opposite->parent; auto parentSegmentStart = pFinalSegment->_reverseWaySearch ? pFinalSegment->opposite->pointIndex : pFinalSegment->opposite->parentEndPointIndex; int i = 0; while (segment) { std::shared_ptr<RouteSegment> routeSegment(new RouteSegment(segment->road, parentSegmentStart, segment->pointIndex)); parentSegmentStart = segment->parentEndPointIndex; segment = segment->parent; addRouteSegmentToRoute(route, routeSegment, false); i++; } // Reverse it just to attach good direction roads std::reverse(route.begin(), route.end()); i = 0; segment = pFinalSegment->_reverseWaySearch ? pFinalSegment->opposite->parent : finalSegment; auto parentSegmentEnd = pFinalSegment->_reverseWaySearch ? pFinalSegment->opposite->parentEndPointIndex : pFinalSegment->opposite->pointIndex; while (segment) { std::shared_ptr<RouteSegment> routeSegment(new RouteSegment(segment->road, segment->pointIndex, parentSegmentEnd)); parentSegmentEnd = segment->parentEndPointIndex; segment = segment->parent; addRouteSegmentToRoute(route, routeSegment, true); i++; } std::reverse(route.begin(), route.end()); if (!validateAllPointsConnected(route)) return OsmAnd::RouteCalculationResult("Calculated route has broken paths"); splitRoadsAndAttachRoadSegments(context, route); calculateTimeSpeedInRoute(context, route); addTurnInfoToRoute(leftSideNavigation, route); printRouteInfo(route); OsmAnd::RouteCalculationResult result; result.list = route.toList(); context->owner->_previouslyCalculatedRoute = result.list; return result; }
/*protected*/ QStringList ImportRollingStock::parseCommaLine(QString line, int arraySize) { QVector<QString> outLine = QVector<QString>(arraySize); if (line.contains("\"")) { // NOI18N // log.debug("line number "+lineNum+" has escape char \""); QStringList parseLine = line.split(","); int j = 0; for (int i = 0; i < parseLine.length(); i++) { if (parseLine[i].contains("\"")) { // NOI18N QString sb = QString(parseLine[i++]); //sb.deleteCharAt(0); // delete the " sb.remove(0,1); outLine.replace(j,sb); while (i < parseLine.length()) { if (parseLine[i].contains("\"")) { // NOI18N sb = QString(parseLine[i]); //sb.deleteCharAt(sb.length() - 1); // delete the " sb.remove(sb.length() - 1,1); outLine.replace(j,outLine[j] + "," + sb); // log.debug("generated string: "+outLine[j]); j++; break; // done! } else { outLine.replace(j, outLine[j] + "," + parseLine[i++]); } } } else { // log.debug("outLine: "+parseLine[i]); outLine.replace(j++, parseLine[i]); } if (j > arraySize - 1) { break; } } } else { outLine = line.split(",").toVector(); } return outLine.toList(); }
/** * Constructor **/ PLUGIN_CLASS_NAME::PLUGIN_CLASS_NAME(QObject* parent) : QObject(parent) { // create run IDs QVector<QString> runIds; runIds.resize(id_end); runIds[ID_ACTION1] = "#RUN_ID_1"; mRunIDs = runIds.toList(); // create menu actions QVector<QString> menuNames; menuNames.resize(id_end); menuNames[ID_ACTION1] = tr("#ACTION_NAME1"); mMenuNames = menuNames.toList(); // create menu status tips QVector<QString> statusTips; statusTips.resize(id_end); statusTips[ID_ACTION1] = tr("#ACTION_TIPP1"); mMenuStatusTips = statusTips.toList(); }
/** * Constructor **/ WriterIdentificationPlugin::WriterIdentificationPlugin(QObject* parent) : QObject(parent) { // create run IDs QVector<QString> runIds; runIds.resize(id_end); runIds[id_calcuate_features] = "1bb00c5713a849eebb9ea16fcf794740"; runIds[id_generate_vocabulary] = "aa8cf182dc4348aa9917cd3c3fc95d8c"; runIds[id_identify_writer] = "b9fc66129483473fa901ddf627bd8b9a"; runIds[id_evaluate_database] = "e247a635ebb3449ba88204abf8d5f089"; runIds[id_extract_patches] = "64b27436f29d461c9148e98dd816f93e"; mRunIDs = runIds.toList(); // create menu actions QVector<QString> menuNames; menuNames.resize(id_end); menuNames[id_calcuate_features] = tr("Calcuate Features"); menuNames[id_generate_vocabulary] = tr("Generate Vocabulary"); menuNames[id_identify_writer] = tr("Identify Writer"); menuNames[id_evaluate_database] = tr("Evaluate Database"); menuNames[id_extract_patches] = tr("Extract Patches"); mMenuNames = menuNames.toList(); // create menu status tips QVector<QString> statusTips; statusTips.resize(id_end); statusTips[id_calcuate_features] = tr("Calculates the features for writer identification on this page"); statusTips[id_generate_vocabulary] = tr("Generates a new vocabulary using the given pages"); statusTips[id_identify_writer] = tr("Identifies the writer of the given page"); statusTips[id_evaluate_database] = tr("Evaluates the selected files"); statusTips[id_extract_patches] = tr("Extract Patches at SIFT keypoints"); mMenuStatusTips = statusTips.toList(); init(); }
QVector< Image< short > > loadTextons(const QString& filename, const QVector< QString >& names) { QSet< QString > snames = QSet< QString >::fromList( names.toList() ); QFile file( filename ); if (!file.open(QFile::ReadOnly)) qFatal( "Failed to load textons to '%s'", qPrintable( filename ) ); QDataStream s( &file ); QMap< QString, Image< short > > texton_map; while(!s.atEnd()){ QString name; Image< short > textons; s >> name >> textons; if (snames.contains( name )) texton_map[ name ] = textons; } file.close(); QVector< Image< short > > r; foreach( QString name, names ) r.append( texton_map[name] ); return r; }
void UmlSequenceMessage::write(FileOut & out, UmlItem * diagram, const QVector< UmlSequenceMessage* > & msgs) { set_reverses(msgs); QList<UmlSequenceMessage*> l; l = msgs.toList(); UmlSequenceMessage * m; //while ((m = l.first()) != 0) { foreach (m,l) { if(m) { if (m->fragment() != 0) m->fragment()->write(out, diagram, l); else m->write_fragment(out, diagram, l); } } }
/*static*/ /*public*/ QList<QMenu*> JMenuUtil::loadMenu(QString path, WindowInterface* wi, QObject* context) { // File file(path); // if(!file.isAbsolute()) // path = FileUtil::getUserFilesPath() + path; XmlFile* xmlFile = new XmlFile(); QDomElement root = xmlFile->rootFromName(path); //QDomNodeList nodes = root.elementsByTagName("node"); QDomNodeList nodes = root.childNodes(); int n = nodes.size(); QVector<QMenu*> retval = QVector<QMenu*>(n); QList<int> mnemonicList = QList<int>(); for (int i = 0; i < nodes.size(); i++) { QDomElement child = nodes.at(i).toElement(); if(child == QDomElement()) continue; QMenu* menuItem = jMenuFromElement( child, wi, context); retval.replace(i, menuItem); if (( !child.firstChildElement("mnemonic").isNull()) && menuItem != NULL) { int mnemonic = convertStringToKeyEvent( child.firstChildElement("mnemonic").text()); if (mnemonicList.contains(mnemonic)) { Logger::error("Menu item '" + menuItem->title() + "' Mnemonic '" + child.firstChildElement("mnemonic").text() + "' has already been assigned"); } else { //menuItem->setMnemonic(mnemonic); // menuItem->setUserData(mnemonic); mnemonicList.append(mnemonic); } } } return retval.toList(); }
void testBreaking() { QFETCH( qreals, widths ); QFETCH( int, pages ); QFETCH( ints, expectedResult ); QFETCH( qreals, expectedWidthPerPage ); KDReports::TableBreakingLogic logic; logic.setColumnWidths( widths.toVector() ); logic.setPageCount( pages ); const QVector<int> res = logic.columnsPerPage(); if (res.toList() != expectedResult) qDebug() << "columnsPerPage:" << res.toList() << "expected" << expectedResult; QCOMPARE( res.toList(), expectedResult ); const QVector<qreal> widthPerPage = logic.widthPerPage( res ); if (widthPerPage.toList() != expectedWidthPerPage) qDebug() << "widthPerPage:" << widthPerPage.toList() << "expected" << expectedWidthPerPage; QCOMPARE( widthPerPage.toList(), expectedWidthPerPage ); }
/*private*/ void BitSet::initWords(int nbits) { //words = new long[wordIndex(nbits-1) + 1]; QVector<long> temp = QVector<long>(wordIndex(nbits-1) + 1); words = temp.toList(); }
void RDHeaderView::resizeSectionsWithHints() { if(m_sectionMinSizes.count() == 0) return; QVector<int> sizes = m_sectionMinSizes; int available = 0; if(orientation() == Qt::Horizontal) available = rect().width(); else available = rect().height(); // see if we even have any extra space to allocate if(available > m_sectionMinSizesTotal) { // this is how much space we can allocate to stretch sections available -= m_sectionMinSizesTotal; // distribute the available space between the sections. Dividing by the total stretch tells us // how many 'whole' multiples we can allocate: int wholeMultiples = available / m_sectionStretchHintTotal; if(wholeMultiples > 0) { for(int i = 0; i < sizes.count() && i < m_sectionStretchHints.count(); i++) { int hint = m_sectionStretchHints[i]; if(hint > 0) sizes[i] += wholeMultiples * hint; } } available -= wholeMultiples * m_sectionStretchHintTotal; // we now have a small amount (less than m_sectionStretchHintTotal) of extra space to allocate. // we still want to assign this leftover proportional to the hints, otherwise we'd end up with a // stair-stepping effect. // To do this we calculate hint/total for each section then loop around adding on fractional // components to the sizes until one is above 1, then it gets a pixel, and we keep going until // all the remainder is allocated QVector<float> fractions, increment; fractions.resize(sizes.count()); increment.resize(sizes.count()); // set up increments for(int i = 0; i < sizes.count(); i++) { // don't assign any space to sections with negative hints, or sections without hints if(i >= m_sectionStretchHints.count() || m_sectionStretchHints[i] <= 0) { increment[i] = 0.0f; continue; } increment[i] = float(m_sectionStretchHints[i]) / float(m_sectionStretchHintTotal); } while(available > 0) { // loop along each section incrementing it. for(int i = 0; i < fractions.count(); i++) { fractions[i] += increment[i]; // if we have a whole pixel now, assign it if(fractions[i] > 1.0f) { fractions[i] -= 1.0f; sizes[i]++; available--; // if we've assigned all pixels, stop if(available == 0) break; } } } for(int pix = 0; pix < available; pix++) { int minSection = 0; for(int i = 1; i < sizes.count(); i++) { // don't assign any space to sections with negative hints if(i < m_sectionStretchHints.count() && m_sectionStretchHints[i] <= 0) continue; if(sizes[i] < sizes[minSection]) minSection = i; } sizes[minSection]++; } } resizeSections(sizes.toList()); }
QByteArray GdbServer::processQueryPacket(const QByteArray &data) { QByteArray ans; if (data.contains( "qSupported:")) { ans.append("PacketSize=3fff"); ans.append(";qXfer:memory-map:read+"); stlink->BreakpointRemoveAll(); MakePacket(ans); } else if (data == ("qC") || data == "qSymbol::") { ans.append("OK"); MakePacket(ans); } else if (data == "qAttached" || data == "qOffsets") { MakePacket(ans); } else if (data == "qTStatus") { MakePacket(ans); } else if (data == ("qXfer:memory-map:read::0,fff")) { ans = stlink->GetMapFile(); ans.prepend('m'); MakePacket(ans); } else if (data.startsWith("qXfer:memory-map:read::27")) { ans = "l"; MakePacket(ans); } else if (data == "qfThreadInfo") { ans = "m1"; MakePacket(ans); } else if (data == "qsThreadInfo") { ans = "l"; MakePacket(ans); } else if (data.startsWith("qThreadExtraInfo")) { params_t pars = ParseParams(data); int id = pars[1].toInt(NULL,16); ans = getHandler().toLocal8Bit(); ans = ans.toHex(); MakePacket(ans); } else if (data.startsWith("qRcmd")) { bool fail = false; params_t pars = ParseParams(data); QByteArray arr = QByteArray::fromHex(pars[1]); if (arr == "reset") { stlink->SysReset(); stlink->BreakpointRemoveAll(); } else if (arr == "Reset") { stlink->SysReset(); } else if (arr == "LOAD") { QFile moje(VeriFile); if (moje.open(QFile::ReadOnly)) stlink->FlashWrite(FLASH_BASE,moje.readAll(),true); } else if (arr.startsWith("verify")) { QFile * file; if (arr == "verify") { file = new QFile(VeriFile); //file.setFileName(VeriFile); } else { arr.remove(0,7); //file.setFileName(arr); file = new QFile(arr); } int temp = 0; if (file->open(QFile::ReadOnly)) { bool ok = stlink->FlashVerify(file->readAll(),0); if (ok) temp = 0; else temp = 1; file->close(); } else { temp = 2; } QString text; switch (temp) { case 0: text = "Verification OK"; break; case 1: text = "Verification failed"; break; case 2: text = "No file found "; break; } qDebug() << text; delete file; } else if (arr == "erase") { stlink->FlashMassClear(); qDebug() << "Erased"; } else if (arr == "PSP") { quint32 psp = stlink->ReadRegister(PSP); QVector<quint32> vec; stlink->UnstackContext(vec,psp); QList<quint32> lst; lst = vec.toList(); qDebug( ) << "PSP: " << QString("0x%1").arg(psp,0,16); while(lst.count()) { qDebug() << QString("0x%1").arg(lst.takeLast(),0,16); } switched = !switched; qDebug() << switched; } else { qDebug() << "unknown remote command" << arr; ans = ""; fail = true; } if (!fail) ans = "OK"; MakePacket(ans); } return ans; }