/*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();
 }
Exemple #2
0
QVector<osg::ref_ptr<Data::Node> >* CameraMath::getViewExtremes( osg::ref_ptr<osg::Camera> camera, std::list<osg::ref_ptr<Data::Node> > selectedCluster )
{
	osg::Matrixd mv = camera->getViewMatrix();
	osg::Matrixd mp = camera->getProjectionMatrix();
	osg::Matrixd mw = camera->getViewport()->computeWindowMatrix();

	QVector<osg::ref_ptr<Data::Node> >* extremes = new QVector<osg::ref_ptr<Data::Node> >;

	osg::Vec3d leftPosition, rightPosition, topPosition, bottomPosition;

	for ( int x = 0; x < 4; x++ ) {
		extremes->push_back( selectedCluster.front() );
	}

	float scale = Util::ApplicationConfig::get()->getValue( "Viewer.Display.NodeDistanceScale" ).toFloat();

	osg::Vec3d p = selectedCluster.front()->getCurrentPosition() * scale;

	// get initial onscreen position
	leftPosition = rightPosition = topPosition = bottomPosition = p * mv * mp * mw;

	std::list<osg::ref_ptr<Data::Node> >::iterator i;

	// find onscreen extremes in cluster
	for ( i = selectedCluster.begin(); i != selectedCluster.end(); ++i ) {
		osg::Vec3d position = ( *i )->getCurrentPosition() * scale * mv * mp * mw;

		if ( position.x() < leftPosition.x() ) {
			extremes->replace( 0, *i );
			leftPosition = position;
		}

		if ( position.x() > rightPosition.x() ) {
			extremes->replace( 1, *i );
			rightPosition = position;
		}

		if ( position.y() < topPosition.y() ) {
			extremes->replace( 2, *i );
			topPosition = position;
		}

		if ( position.y() > bottomPosition.y() ) {
			extremes->replace( 3, *i );
			bottomPosition = position;
		}
	}


	return extremes;
}
void SConnections::createNodes(QList<QVector3D>* allNodes, int offset){

    qDebug() << "allNodes.length: " << allNodes->length();

    qDebug() << "create Nodes in SConnections";

    //initialized with NULL:
    QVector<Node*> *dnv = new QVector<Node*>(allNodes->length(),NULL);

    for (int i = 0; i<icons->length(); i++){
        int f = icons->fs.at(i);
        int t = icons->ts.at(i);
        float v = icons->vs.at(i);

        Connection* acon = new Connection(allNodes->at(f), allNodes->at(t),v);

        Node* n1 = new Node(acon->fn);

        if (dnv->at(f)==NULL) {
            dnv->replace(f,n1);
        }
        dnv->at(f)->ncs << acon;
        dnv->at(f)->sncs << acon;

        acon = new Connection(allNodes->at(t), allNodes->at(f),v);

        Node* n2 = new Node(acon->fn);

        if (dnv->at(t)==NULL) {
            dnv->replace(t,n2);
        }
        dnv->at(t)->ncs << acon;
        dnv->at(t)->sncs << acon;
    }
    qDebug() << "before putting nodes in dn";
    qDebug() << nodes.size();
    for (int i = 0; i<nodes.size(); i++){
        if (dnv->at(i+offset)!=NULL){
            dn << *dnv->at(i+offset);
        }
    }
    //qDebug() << "before sorting nodes";
    for (int i = 0; i<dn.length(); i++){
        //after this, sncs should be sorted by color, but contain the original indexing...
        dn[i].indexCons();
        dn[i].sortNCS();
    }
    delete dnv;
    qDebug() << "done with creating " << dn.length() << " nodes from " << icons->length() << " indexed connections";
}
Exemple #4
0
sqlqueryresultlist searchhandler::perform_grep(QString searchtxt, sqlqueryresultlist searchlist, bool exactmatch)
{
	QVector<QString> strvec;
	sqlqueryresultlist resultlist;
	QFutureWatcher<sqlqueryresultlist> futureWatcher;
	QProgressDialog dialog;
	unsigned int n = searchlist.resultlist.size();
	if (n == 0) return resultlist;
	strvec.resize(n);
	for (unsigned int i=0; i < n; i++)
	{
		strvec.replace(i, str2qt(searchlist.resultlist[i].filepath));
	}
	dialog.setAutoReset(false);
	dialog.setLabelText(QString("Grep ").append(QString(tr("in progress"))).append(QString(" ...")));
	dialog.setCancelButtonText(tr("Cancel"));
	QObject::connect(&futureWatcher, SIGNAL(finished()), &dialog, SLOT(reset()));
	QObject::connect(&dialog, SIGNAL(canceled()), &futureWatcher, SLOT(cancel()));
	QObject::connect(&futureWatcher, SIGNAL(progressRangeChanged(int,int)), &dialog, SLOT(setRange(int,int)));
	QObject::connect(&futureWatcher, SIGNAL(progressValueChanged(int)), &dialog, SLOT(setValue(int)));
	m_grepExactMatch = exactmatch;
	(*m_grepRegExp) = QRegExp(searchtxt.toAscii().data(), Qt::CaseInsensitive);
	m_grepRegExp->setPatternSyntax(QRegExp::RegExp2);
	futureWatcher.setFuture(QtConcurrent::mappedReduced(strvec, doGrep,
				collateGrep, QtConcurrent::SequentialReduce));
	dialog.exec();
	futureWatcher.waitForFinished();
	if (futureWatcher.isCanceled() == false)
		resultlist = futureWatcher.result();
	return resultlist;
}
QVector<Vector3f> CVlib::divideByW(QVector<Vector3f> list)
{
    for(int i = 0 ; i < list.count(); i++){
        list.replace(i, list.at(i)/list.at(i)(2));
    }
    return list;
}
Exemple #6
0
KNMusicNowPlaying::KNMusicNowPlaying(QObject *parent) :
    KNMusicNowPlayingBase(parent),
    m_backend(nullptr),
    m_playingProxyModel(nullptr),
    m_shadowPlayingModel(new KNMusicProxyModel(this)),
    m_temporaryProxyPlaylist(new KNMusicProxyModel(this)),
    m_temporaryPlaylist(new KNMusicTemporaryPlaylistModel(this)),
    m_playingTab(nullptr),
    m_loopState(NoRepeat),
    m_playingIndex(QPersistentModelIndex()),
    m_playingAnalysisItem(KNMusicAnalysisItem()),
    m_manualPlayed(false)
{
    //Set the temporary playlist to the proxy model.
    m_temporaryProxyPlaylist->setSourceModel(m_temporaryPlaylist);
    //Initial the random device and random generator.
    QVector<int> seedData;
    //Generate the random device.
    std::random_device randomDevice;
    //Get the seed array size.
    const int seedCount=(int)std::mt19937::state_size;
    //Resize the seed data.
    seedData.resize(seedCount);
    //Set the data to the seed data.
    for(int i=0; i<seedCount; ++i)
    {
        //Replace the seed data.
        seedData.replace(i, randomDevice());
    }
    //Transform list to seed sequence.
    std::seed_seq seedSequence(std::begin(seedData), std::end(seedData));
    //Initial the Mersenne twister seeds.
    m_mersenneSeed=std::mt19937(seedSequence);
}
Exemple #7
0
 /* -------------------------------------------------------------------------------------------
  *
  * ------------------------------------------------------------------------------------------- */
 void Matrix::reset(const short value) {
    Q_ASSERT(this->grid != 0x0);
   for(int row = 0; row < this->rows; row++){
     QVector<short> *r = this->grid->at(row);
     for(int col =0; col < this->cols; col++){
       r->replace(col,value);
     }
   }
 }
void WidgetAgregarStreamPeru::ponerTabla(int row, int col){
    int pos, n,pos_r,var=0;
    pos=row*12;
    n=rowsp.size();

    if(col==0){
         for(int i=0; i<n;i++){
           if(rowsp[i]==row){
               pos_r=i;
               var=var+1;
           }}

        if(var==0){
            rowsp.append(row);
            BDsperu.replace(pos,"1");
        }else{
            rowsp.remove(pos_r);
            BDsperu.replace(pos,"0"); }
        }}
void FileBuffer::getBytes(long ofs, QVector<uchar>& b, int length)
{
    if (ofs < offset || ((ofs + length) - 1) > offsetEnd)
    {
        readBuffer(ofs);
    }
    for (int i = 0; i < length; ++i)
    {
        b.replace(i, buf[(int)((ofs - offset) + i)]);
    }
}
void QDesktopWidgetPrivate::init(QDesktopWidget *that)
{
    int screenCount=0;

    if (HAL::Get(0, HALData::EDisplayNumberOfScreens, screenCount) == KErrNone)
        QDesktopWidgetPrivate::screenCount = screenCount;
    else
        QDesktopWidgetPrivate::screenCount = 0;

    rects = new QVector<QRect>();
    workrects = new QVector<QRect>();

    rects->resize(QDesktopWidgetPrivate::screenCount);
    workrects->resize(QDesktopWidgetPrivate::screenCount);

    // ### TODO: Implement proper multi-display support
    rects->resize(1);
    rects->replace(0, that->rect());
    workrects->resize(1);
    workrects->replace(0, that->rect());
}
const QVector<QRgb> ImageLoaderFreeImage::colorTable() const
{
    QVector<QRgb> result;

    const RGBQUAD* const palette = FreeImage_GetPalette(m_bitmap);
    if (palette) {
        const int count = FreeImage_GetColorsUsed(m_bitmap);
        result.resize(count);
        for (int i = 0; i < count; i++)
            result.replace(i, qRgb(palette[i].rgbRed, palette[i].rgbGreen, palette[i].rgbBlue));
    }

    return result;
}
Exemple #12
0
QVector<float> ImageProcessor::findOccurrences(QImage input, int offset) {
    QVector<float> returnMe;
    returnMe.fill(0,256);
    float single = 1.0 / (input.width() * input.height());

    for(int x=0;x<input.width();x++) {
        for(int y=0;y<input.height();y++) {
            int pixelIndex = qRed(input.pixel(x,y)) + offset;
            pixelIndex = qMax(pixelIndex,0);
            pixelIndex = qMin(pixelIndex,255);
            float newVal = returnMe.value(pixelIndex)+single;
            returnMe.replace(pixelIndex,newVal);
        }
    }

    return returnMe;
}
void EziDebugScanChain::addToRegChain(QString clock ,int chainNum , const QStringList& reglist)
{
    QVector<QStringList> iregListVec  = m_iregChainStructure.value(clock) ;
    int i = 0 ;

    qDebug() << "EziDebug Info: The insert chain number:" << chainNum  ;

    if(iregListVec.count())
    {
        for(i = 0 ; i < iregListVec.count() ; i++)
        {
            // 加入到 未完毕的链
            if(i == chainNum)
            {
                QStringList ioriginRegList = iregListVec.at(i) ;
                ioriginRegList << reglist ;
                iregListVec.replace(i,ioriginRegList);
                m_iregChainStructure.insert(clock,iregListVec);
                break ;
            }
        }
        // 新增链
        if(i == iregListVec.count())
        {
            // 新增 链
            if(chainNum != iregListVec.count())
            {
                qDebug() << "EziDebug Error: the reglist is insert chain number:" << chainNum  <<" is not equal to total number:" << iregListVec.count() ;
            }
            iregListVec.insert(chainNum ,reglist);
            m_iregChainStructure.insert(clock,iregListVec);
        }
    }
    else
    {
       if(chainNum != 0)
       {
           qDebug() << "EziDebug Error: the reglist is insert chain number:" << chainNum  <<" is not right" ;
       }
       iregListVec.insert(0,reglist);
       m_iregChainStructure.insert(clock,iregListVec);
    }

    return ;
}
Exemple #14
0
// Note: Callgrind sometimes gives different IDs for same file
// (when references to same source file come from different ELF objects)
TraceFile* CachegrindLoader::compressedFile(const QString& name)
{
    if ((name[0] != '(') || !name[1].isDigit()) return _data->file(checkUnknown(name));

    // compressed format using _fileVector
    int p = name.indexOf(')');
    if (p<2) {
        error(QStringLiteral("Invalid compressed file ('%1')").arg(name));
        return 0;
    }
    int index = name.midRef(1, p-1).toUInt();
    TraceFile* f = 0;
    p++;
    while((name.length()>p) && name.at(p).isSpace()) p++;
    if (name.length()>p) {
        if (_fileVector.size() <= index) {
            int newSize = index * 2;
#if TRACE_LOADER
            qDebug() << " CachegrindLoader::fileVector enlarged to "
                     << newSize;
#endif
            _fileVector.resize(newSize);
        }

        QString realName = checkUnknown(name.mid(p));
        f = (TraceFile*) _fileVector.at(index);
        if (f && (f->name() != realName)) {
            error(QStringLiteral("Redefinition of compressed file index %1 (was '%2') to %3")
                  .arg(index).arg(f->name()).arg(realName));
        }

        f = _data->file(realName);
        _fileVector.replace(index, f);
    }
    else {
        if ((_fileVector.size() <= index) ||
            ( (f=(TraceFile*)_fileVector.at(index)) == 0)) {
            error(QStringLiteral("Undefined compressed file index %1").arg(index));
            return 0;
        }
    }

    return f;
}
Exemple #15
0
TraceObject* CachegrindLoader::compressedObject(const QString& name)
{
    if ((name[0] != '(') || !name[1].isDigit()) return _data->object(checkUnknown(name));

    // compressed format using _objectVector
    int p = name.indexOf(')');
    if (p<2) {
        error(QStringLiteral("Invalid compressed ELF object ('%1')").arg(name));
        return 0;
    }
    int index = name.midRef(1, p-1).toInt();
    TraceObject* o = 0;
    p++;
    while((name.length()>p) && name.at(p).isSpace()) p++;
    if (name.length()>p) {
        if (_objectVector.size() <= index) {
            int newSize = index * 2;
#if TRACE_LOADER
            qDebug() << " CachegrindLoader: objectVector enlarged to "
                     << newSize;
#endif
            _objectVector.resize(newSize);
        }

        QString realName = checkUnknown(name.mid(p));
        o = (TraceObject*) _objectVector.at(index);
        if (o && (o->name() != realName)) {
            error(QStringLiteral("Redefinition of compressed ELF object index %1 (was '%2') to %3")
                  .arg(index).arg(o->name()).arg(realName));
        }

        o = _data->object(realName);
        _objectVector.replace(index, o);
    }
    else {
        if ((_objectVector.size() <= index) ||
            ( (o=(TraceObject*)_objectVector.at(index)) == 0)) {
            error(QStringLiteral("Undefined compressed ELF object index %1").arg(index));
            return 0;
        }
    }

    return o;
}
QVector<double> ATCAbstractProfile::mixedInterval(ATCInterpolator2D &interpolator, ATCInterpolator2D &inverseInterpolator, double key, double lvlFrom, QVector<double> &intervals)
{
    //Calculate quantity X from initial level using standard interpolator
    QVector<double> site(1, lvlFrom);
    QVector<double> result(1);
    interpolator.interpolate(key, site, result);

    //Update quantity X for final level using input interval
    for(int i = 0; i < intervals.size(); i++)
    {
        intervals.replace(i, intervals.at(i) + result.at(0));
    }

    //Calculate final level using updated quantity X
    QVector<double> finalResults(intervals.size());
    inverseInterpolator.interpolate(key, intervals, finalResults);

    //Return calculated level
    return finalResults;
}
Exemple #17
0
/*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();
}
Exemple #18
0
void MainWindow::colorCards() {
    QVector<QPair<QColor, int> > *colors = makeColors();

    //Map colors to buttons
    int color;

    QVector<QPair<QPushButton*, QColor> > *buttonColors = new QVector< QPair<QPushButton*, QColor> >();

    QVectorIterator<QPushButton*> it(*buttons);
    while(it.hasNext()) {
        color = rand()%numberOfColors;

        while(colors->at(color).second == 0) {
            color = rand()%numberOfColors;
        }

        buttonColors->push_back(QPair<QPushButton*, QColor>(it.next(), colors->at(color).first));
        colors->replace(color, QPair<QColor, int>(colors->at(color).first, colors->at(color).second-1));;
    }

    for(int i=0; i<buttonColors->size(); ++i) {
        QString style_sheet_btn =" QPushButton:checked {background-color:" + buttonColors->at(i).second.name() + ";border-style:solid;}";
        buttonColors->at(i).first->setStyleSheet(style_sheet_btn);
    }

    //Make pairs of the buttons
    for(int i=0; i<buttonColors->size(); ++i) {
        for(int j=0; j<buttonColors->size(); ++j) {
            if(i!=j) {
                if(buttonColors->at(i).second == buttonColors->at(j).second) {
                    pairs->push_back(QPair<QPushButton*, QPushButton*> (buttonColors->at(i).first, buttonColors->at(j).first));
                }
            }
        }
    }

}
FilterOp::SubSamplingData FilterOp::createSubSampling(int srcSize, int dstSize, float scale)
{
    QVector<int> arrN(dstSize);
    int numContributors;
    QVector<float> arrWeight;
    QVector<int> arrPixel;

    float fwidth = internalFilter.getRadius();

    if (scale < 1.0f)
    {
        // scale down -> subsampling
        float width = fwidth / scale;
        numContributors = (int)((width * 2.0f) + 2); // Heinz: added 1 to be save with the ceilling
        arrWeight = QVector<float>(dstSize * numContributors);
        arrPixel = QVector<int>(dstSize * numContributors);

        float fNormFac = (float)(1.0f / (ceil(width) / fwidth));
        //
        for (int i = 0; i < dstSize; ++i)
        {
            arrN.replace(i, 0);
            int subindex = i * numContributors;
            float center = i / scale;
            int left = (int)floor(center - width);
            int right = (int)ceil(center + width);
            for (int j = left; j <= right; ++j)
            {
                float weight;
                weight = internalFilter.value((center - j) * fNormFac);

                if (weight == 0.0f)
                {
                    continue;
                }
                int n;
                if (j < 0)
                {
                    n = -j;
                }
                else if (j >= srcSize)
                {
                    n = ((srcSize - j) + srcSize) - 1;
                }
                else
                {
                    n = j;
                }

                int k = arrN[i];
                arrN.replace(i, arrN[i] + 1);
                if (n < 0 || n >= srcSize)
                {
                    weight= 0.0f;// Flag that cell should not be used
                }

                arrPixel.replace(subindex + k, n);
                arrWeight.replace(subindex + k, weight);
            }
            // normalize the filter's weight's so the sum equals to 1.0, very important for avoiding box type of artifacts
            int max = arrN[i];
            float tot = 0;
            for (int k = 0; k < max; ++k)
            {
                tot += arrWeight[subindex + k];
            }
            if (tot != 0.0f)
            { // 0 should never happen except bug in filter
                for (int k = 0; k < max; ++k)
                {
                    arrWeight.replace(subindex + k, arrWeight[subindex + k] / tot);
                }
            }
        }
    }
    else
    {
        // scale up -> super-sampling
        numContributors = (int)((fwidth * 2.0f) + 1);
        arrWeight = QVector<float>(dstSize * numContributors);
        arrPixel = QVector<int>(dstSize * numContributors);
        //
        for (int i = 0; i < dstSize; ++i)
        {
            arrN.replace(i, 0);
            int subindex = i * numContributors;
            float center = i / scale;
            int left = (int)floor(center - fwidth);
            int right = (int)ceil(center + fwidth);
            for (int j = left; j <= right; ++j)
            {
                float weight = internalFilter.value(center - j);
                if (weight == 0.0f)
                {
                    continue;
                }
                int n;
                if (j < 0)
                {
                    n = -j;
                }
                else if (j >= srcSize)
                {
                    n = ((srcSize - j) + srcSize) - 1;
                }
                else
                {
                    n = j;
                }

                int k = arrN[i];
                arrN.replace(i, arrN[i]+ 1);
                if (n < 0 || n >= srcSize)
                {
                    weight= 0.0f;// Flag that cell should not be used
                }

                arrPixel.replace(subindex + k, n);
                arrWeight.replace(subindex + k, weight);
            }
            // normalize the filter's weights so the sum equals to 1.0, very important for avoiding box type of artifacts
            int max = arrN[i];
            float tot = 0;
            for (int k = 0; k < max; ++k)
            {
                tot += arrWeight[subindex + k];
            }
            if (tot != 0.0f)
            {
                for (int k = 0; k < max; ++k)
                {
                    arrWeight.replace(subindex + k, arrWeight[subindex + k] / tot);
                }
            }
        }
    }
    return SubSamplingData(arrN, arrPixel, arrWeight, numContributors);
}
void ResultWindow::assembleImage()
{
    bounds realLimit;
    realLimit.left = 0;
    realLimit.right = 0;
    realLimit.bottom = 0;
    realLimit.top = 0 ;
    for(int i = 0; i < list.size(); i++){
        realLimit.left = std::min(realLimit.left, list.at(i)->limits.left);
        realLimit.top = std::min(realLimit.top, list.at(i)->limits.top);
        realLimit.right = std::max(realLimit.right, list.at(i)->limits.right);
        realLimit.bottom = std::max(realLimit.bottom, list.at(i)->limits.bottom);
    }
    float ty = 0;
    if(realLimit.top < 0 ){
        ty = std::abs(realLimit.top);
    }
    float tx = 0;
    if(realLimit.left < 0){
        tx = std::abs(realLimit.left);
    }
    QImage newImage = QImage(realLimit.right + tx,  realLimit.bottom + ty, QImage::Format_ARGB32);
    renderArea->resize(realLimit.right +tx, realLimit.bottom + ty);

    QVector<QVector<QVector<Vector4f>>> imageList;
    for(int k = 0; k < list.count(); k++)
    {
        //QImage img = QImage(newImage.width(), newImage.height(),QImage::Format_ARGB32);
         QVector<QVector<Vector4f>> img;
        for(int j=0; j < newImage.height(); j++)
        {
            QVector<Vector4f> line;
            for(int i=0; i< newImage.width(); i++)
            {
                Vector3f pos;
                pos << i-tx, j-ty, 1;
                pos = list.at(k)->H.inverse() * pos;
                pos/=pos(2);
                QColor color(0, 0, 0, 0);
                int alpha = 0 ;
                if(pos(0)>0 && pos(0)<list.at(k)->pixmap()->width() && pos(1)>0 && pos(1)<list.at(k)->pixmap()->height()){
                    //color = list.at(k)->pixmap()->toImage().pixel(pos(0),pos(1));
                    color = CVlib::interpolate(list.at(k)->pixmap()->toImage(), pos);
                    alpha = 255;
                    //color = CVlib::interpolate(list.at(k)->pixmap()->toImage(), pos);
                    //img.setPixel(i, j,color.rgba());

                }
                color.setAlpha(alpha);
                line.push_back(CVlib::colorToVector(color));
                //img.setPixel(i, j,color.rgba());
            }
            img.push_back(line);
        }
        imageList.push_back(img);
    }
    QVector<QVector<Vector4f>> img;
    for(int j=0; j< newImage.height(); j++)
    {
        QVector<Vector4f> line;
        for(int i=0; i< newImage.width(); i++)
        {
            Vector4f color;
            color << 0, 0, 0, 0;
            line.push_back(color);
        }
        img.push_back(line);
    }
    for(int k =0; k < imageList.count(); k++)
    {
        for(int j=0; j< newImage.height(); j++)
        {
            QVector<Vector4f> line;
            for(int i=0; i< newImage.width(); i++)
            {
                Vector4f color;
                if(img.at(j).at(i)(3) ==0){
                    color =  imageList.at(k).at(j).at(i);
                }else{
                    color = img.at(j).at(i);
                }
                line.push_back(color);
            }
            img.replace(j, line);
        }
    }
    for(int j=0; j< newImage.height(); j++)
    {
        for(int i=0; i< newImage.width(); i++)
        {
            QColor color =CVlib::vectorToColor(img.at(j).at(i));
            newImage.setPixel(i, j, color.rgba());
        }
     }

//    for(int j=0; j < newImage.height(); j++)
//    {
//        for(int i=0; i< newImage.width(); i++)
//        {
//            Vector4f colorVec;
//            colorVec << 0, 0, 0, 0;
//            int ratio = 1;
//            for(int k =0; k < imageList.count(); k++)
//            {
//                Vector4f color = imageList.at(k).at(j).at(i);
//                if(color(3)!=0){
//                    colorVec += color;
//                    //ratio++;
//                }
//            }
//            //std::cout << colorVec.transpose() << std::endl;
//            colorVec /= ratio;
//            colorVec(3) = 255;
//            newImage.setPixel(i,j, CVlib::vectorToColor(colorVec).rgba());
//        }
//    }
    QPixmap pix = QPixmap::fromImage(newImage);
    //pix.scaledToWidth(100);
    QImage finalImage = pix.toImage();
    renderArea->setPixmap(QPixmap::fromImage(finalImage));
    finalImage.save("geometria.png");
}
Exemple #21
0
Data* SumBlock::calculate()
{
    //only 1 input
    if(this->inputData.size()==1)
        return this->inputData.first();


    Data* result;
    int status =1;
    int scalarsCounter=0;
    int vectorsCounter=0;
    int matrixesCounter=0;
    QVector<int> resultSize = QVector<int>();
    resultSize.append(1);
    int resultDimentions=1;
    QMap<ConnectionInterface*,Data*>::iterator it;
    for(it=this->inputData.begin();it!=this->inputData.end();it++)
    {
        if(status)
        {
            if((*it)->dimensions==1 &&(*it)->size.at(0)==1) //scalar
                scalarsCounter++;
            else if((*it)->dimensions==1)   //vector
            {
                vectorsCounter++;
                if(matrixesCounter) //there cannot be a matrix
                    status=0;

                if(vectorsCounter==1)
                {
                    resultDimentions=1;
                    resultSize.replace(0,(*it)->size.at(0));
                }
                else if((*it)->size.at(0)!=resultSize.at(0))
                    status=0;
            }
            else    //matrix
            {
                matrixesCounter++;
                if(vectorsCounter)  //there cannot be a vector
                    status=0;

                if(matrixesCounter==1)
                {
                    resultDimentions = 2;
                    resultSize.resize((*it)->size.size());
                    for(int dimensionSize=0; dimensionSize<(*it)->size.size();dimensionSize++)  //check size of matrixes
                    {
                         resultSize.replace(dimensionSize,(*it)->size.at(dimensionSize));
                    }
                }
                else
                {
                    if(resultSize.size()==(*it)->size.size())
                    {
                        for(int dimensionSize=0; dimensionSize<(*it)->size.size();dimensionSize++)  //check size of matrixes
                        {
                            if(resultSize.at(dimensionSize)!=(*it)->size.at(dimensionSize))
                                status=0;
                        }
                    }
                    else
                        status=0;
                }
            }
        }
    }

    //error             0
    //scalars           1
    //scalar + matrix   2
    //scalar + vector   3
    //vectors           4
    //matrixes          5

    if(status)
    {
        if(matrixesCounter&&scalarsCounter)
        {
            result = new Data(resultDimentions,resultSize, QVector<double>(resultSize.at(0)*resultSize.at(1)));
            status = 2;
        }
        else if(vectorsCounter&&scalarsCounter)
        {
            result = new Data(resultDimentions,resultSize, QVector<double>(resultSize.at(0)));
            status=3;
        }
        else if(scalarsCounter)
        {
            result = new Data(resultDimentions,resultSize, QVector<double>(1));
            status=1;
        }
        else if(matrixesCounter)
        {
            result = new Data(resultDimentions,resultSize, QVector<double>(resultSize.at(0)*resultSize.at(1)));
            status=5;
        }
        else if(vectorsCounter)
        {
            result = new Data(resultDimentions,resultSize, QVector<double>(resultSize.at(0)));
            status=4;
        }
    }

    switch (status) {
    case 1:
    {
        double value=0;
        for(it=this->inputData.begin();it!=this->inputData.end();it++)
        {
            value+=(*it)->dataArray.at(0);
        }
        result->dataArray.replace(0,value);
        return result;
        break;
    }
    case 2:
    case 3:
    {
        for(it=this->inputData.begin();it!=this->inputData.end();it++)
        {
            if((*it)->dimensions==1&&(*it)->size.at(0)==1)
            for(int i =0; i<result->dataArray.size();i++)
            {
                result->dataArray.replace(i,result->dataArray.at(i)+(*it)->dataArray.at(0));
            }
            else
            for(int i =0; i<result->dataArray.size();i++)
            {
                result->dataArray.replace(i,result->dataArray.at(i)+(*it)->dataArray.at(i));
            }
        }
        return result;
        break;
    }
    case 4:
    case 5:
    {
        for(it=this->inputData.begin();it!=this->inputData.end();it++)
        {
            for(int i =0; i<result->dataArray.size();i++)
            {
                result->dataArray.replace(i,result->dataArray.at(i)+(*it)->dataArray.at(i));
            }
        }
        return result;
        break;
    }
    default:
        return new Data();
        break;
    }

//    for(it=this->inputData.begin();it!=this->inputData.end()-1;it++)
//    {
//        if((*it)->dimensions==(*(it+1))->dimensions)
//        {
//            if((*it)->dimensions==1)    //scalar or vector
//            {
//                result = new Data(1,(*it)->size,QVector<double>());
//                QVector<double>::iterator value;
//                QVector<double>::iterator value2;
//                for(value=(*it)->dataArray.begin(),value2=(*(it+1))->dataArray.begin() ;value!=(*it)->dataArray.end()||value2!=(*(it+1))->dataArray.end();value++, value2++)
//                {
//                    result->dataArray.push_back((*value)+(*value2));
//                }
//            }
//            else
//                return new Data();
//            //matrix
//            //TODO:: calc dimension of result and result
//        }
//        else if((*it)->dimensions==1 &&(*it)->size.at(0)==1)    //first is scalar
//        {
//            QVector<double>::iterator value2;
//            for(value2=(*(it+1))->dataArray.begin() ;value2!=(*(it+1))->dataArray.end(); value2++)
//            {
//                result->dataArray.push_back((*value2)+(*it)->dataArray.at(0));
//            }
//        }
//        else if((*(it+1))->dimensions==1 &&(*(it+1))->size.at(0)==1)    //second is scalar
//        {
//            QVector<double>::iterator value;
//            for(value=(*it)->dataArray.begin();value!=(*it)->dataArray.end();value++)
//            {
//                result->dataArray.push_back((*value)+(*(it+1))->dataArray.at(0));
//            }
//        }
//        else
//            return new Data();
//    }
//    return result;
}
void QDesktopWidgetPrivate::init(QDesktopWidget *that)
{
    if (rects)
        return;

    rects = new QVector<QRect>();
    workrects = new QVector<QRect>();
    screenCount = 0;

#ifndef Q_OS_WINCE
    QSystemLibrary user32Lib(QLatin1String("user32"));
    enumDisplayMonitors = (EnumFunc)user32Lib.resolve("EnumDisplayMonitors");
    getMonitorInfo = (InfoFunc)user32Lib.resolve("GetMonitorInfoW");

    if (!enumDisplayMonitors || !getMonitorInfo) {
        screenCount = GetSystemMetrics(80);  // SM_CMONITORS
        rects->resize(screenCount);
        for (int i = 0; i < screenCount; ++i)
            rects->replace(i, that->rect());
        return;
    }
    // Calls enumCallback
    enumDisplayMonitors(0, 0, enumCallback, 0);
    enumDisplayMonitors = 0;
    getMonitorInfo = 0;
#else
    QSystemLibrary coreLib(QLatin1String("coredll"));
    // CE >= 4.0 case
    enumDisplayMonitors = (EnumFunc)coreLib.resolve("EnumDisplayMonitors");
    getMonitorInfo = (InfoFunc)coreLib.resolve("GetMonitorInfo");

    if ((!enumDisplayMonitors || !getMonitorInfo)) {
        screenCount = GetSystemMetrics(SM_CMONITORS);
        return;
    }

    if (!coreLib.isLoaded() || !enumDisplayMonitors || !getMonitorInfo) {
        rects->resize(screenCount);
        for (int i = 0; i < screenCount; ++i)
            (*rects)[i] = that->rect();

        RECT r;
        SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0);
        QRect qr = QRect(QPoint(r.left, r.top), QPoint(r.right - 1, r.bottom - 1));

#if defined(Q_WS_WINCE_WM)
        qt_get_sip_info(qr);
#endif

        workrects->resize(screenCount);
        for (int j = 0; j < screenCount; ++j)
            (*workrects)[j] = qr;
        return;
    }

    // Calls enumCallback
    enumDisplayMonitors(0, 0, enumCallback, 0);
    enumDisplayMonitors = 0;
    getMonitorInfo = 0;
#endif // Q_WS_WINCE
}
Exemple #23
0
void counter(QVector<QVector<bool> > &results)
{
    QVector<bool> tempResult;

    tempResult.fill(false, 9);

    bool isWasLowerLimit = false;
    bool isWasUpperLimit = false;

    while(true) {
        if(tempResult.at(8) && tempResult.at(7) && tempResult.at(6) && tempResult.at(5)
                && tempResult.at(4) && tempResult.at(3) && tempResult.at(2) && tempResult.at(1)
                && tempResult.at(0)) {
            break;
        }
        if(tempResult.at(7) && tempResult.at(6) && tempResult.at(5) && tempResult.at(4)
                && tempResult.at(3) && tempResult.at(2) && tempResult.at(1) && tempResult.at(0)) {
            tempResult.replace(0, false);
            tempResult.replace(1, false);
            tempResult.replace(2, false);
            tempResult.replace(3, false);
            tempResult.replace(4, false);
            tempResult.replace(5, false);
            tempResult.replace(6, false);
            tempResult.replace(7, false);
            tempResult.replace(8, true);
        }
        if(tempResult.at(6) && tempResult.at(5) && tempResult.at(4) && tempResult.at(3)
                && tempResult.at(2) && tempResult.at(1) && tempResult.at(0)) {
            tempResult.replace(0, false);
            tempResult.replace(1, false);
            tempResult.replace(2, false);
            tempResult.replace(3, false);
            tempResult.replace(4, false);
            tempResult.replace(5, false);
            tempResult.replace(6, false);
            tempResult.replace(7, true);
        }
        if(tempResult.at(5) && tempResult.at(4) && tempResult.at(3) && tempResult.at(2)
                && tempResult.at(1) && tempResult.at(0)) {
            tempResult.replace(0, false);
            tempResult.replace(1, false);
            tempResult.replace(2, false);
            tempResult.replace(3, false);
            tempResult.replace(4, false);
            tempResult.replace(5, false);
            tempResult.replace(6, true);
        }
        if(tempResult.at(4) && tempResult.at(3) && tempResult.at(2) && tempResult.at(1)
                && tempResult.at(0)) {
            tempResult.replace(0, false);
            tempResult.replace(1, false);
            tempResult.replace(2, false);
            tempResult.replace(3, false);
            tempResult.replace(4, false);
            tempResult.replace(5, true);
        }
        if(tempResult.at(3) && tempResult.at(2) && tempResult.at(1) && tempResult.at(0)) {
            tempResult.replace(0, false);
            tempResult.replace(1, false);
            tempResult.replace(2, false);
            tempResult.replace(3, false);
            tempResult.replace(4, true);
        }
        if(tempResult.at(2) && tempResult.at(1) && tempResult.at(0)) {
            tempResult.replace(0, false);
            tempResult.replace(1, false);
            tempResult.replace(2, false);
            tempResult.replace(3, true);
        }
        if(tempResult.at(1) && tempResult.at(0)) {
            tempResult.replace(0, false);
            tempResult.replace(1, false);
            tempResult.replace(2, true);
        }
        if(tempResult.at(0)) {
            tempResult.replace(0, false);
            tempResult.replace(1, true);
        }

        qDebug() << "==========>";
        print(tempResult);
        qDebug() << "<==========";

        if(isEqual(tempResult, "111100000")) {
            qDebug() << "isWasLowerLimit" << isWasLowerLimit;
            isWasLowerLimit = true;
        }

        if(isEqual(tempResult, "100011111")) {
            qDebug() << "isWasUpperLimit" << isWasUpperLimit;
            isWasUpperLimit = true;
        }

        if(/*isWasLowerLimit && !isWasUpperLimit && */isValid(tempResult)) {
            results.push_back(tempResult);
        }

        tempResult.replace(0, true);

        if(/*isWasLowerLimit && !isWasUpperLimit && */isValid(tempResult)) {
            results.push_back(tempResult);
        }
    }
}
// 获取波谷的位置
// 参考自:http://www.tuicool.com/articles/2ErqMj
QVector<int> QFilterData::getSlopeIndex(const QVector<int> &vectPressure) const
{
	// 过滤一次原始数据
	QVector<int> vectOriginalData = _filterOrignalData(vectPressure);

	//for(int i = 0; i<vectOriginalData.size(); ++i)
	//{
	//	qDebug()<<vectOriginalData.at(i)<<"\t"<<vectPressure.at(i);
	//}

	int nSize = vectOriginalData.size();

	QVector<int> slopeArr(vectOriginalData.size()-1, 0);
	for(int i=0; i < vectOriginalData.size()-1; ++i)
	{
		int nSlope = vectOriginalData.at(i+1) - vectOriginalData.at(i);
		if(nSlope>0)
		{
			slopeArr.replace(i, 1);
		}
		else if(nSlope<0)
		{
			slopeArr.replace(i, -1);
		}
	}

	for(int i = slopeArr.size() -1; i >= 0; --i)
	{
		if(slopeArr.at(i) == 0 && i == slopeArr.size() - 1)
		{
			slopeArr.replace(i, 1);
		}
		else if(slopeArr.at(i) == 0 && i != slopeArr.size() - 1)
		{
			if(slopeArr.at(i+1) >= 0)
			{
				slopeArr.replace(i, 1);
			}
			else 
			{
				slopeArr.replace(i, -1);
			}
		}
	}

	QVector<int> arrIndex;
	int nLastValley = 0;
	for(int i = 0; i < slopeArr.size() - 1; ++i)
	{
		if(slopeArr.at(i+1) - slopeArr.at(i) == 2)
		{
			if((i+1 - nLastValley)>65 || nLastValley == 0)
			{
				nLastValley = i+1;
				arrIndex.append(i+1);
			}
			else if((i+1 - nLastValley)<10)
			{
				arrIndex.replace(arrIndex.size()-1, i+1);
				nLastValley = i+1;
			}
		}
	}

	if(arrIndex.isEmpty() && vectPressure.size()>200)
	{
		arrIndex.append(0);
		arrIndex.append(vectPressure.size()-1);
	}
	else if (arrIndex.size() == 1 && vectPressure.size()>200)
	{
		arrIndex.append(vectPressure.size()-1);
	}
	return arrIndex;
}
QVector<int> QFilterData::_computeValley(const int &nIndex)
{
	int nLastValley = 0;
	//QVector<int> vectValley;
	//for(int i = 0; i < m_arrSloped[nIndex].size() - 1; ++i)
	//{
	//	if(m_arrSloped[nIndex].at(i+1) - m_arrSloped[nIndex].at(i) == 2)
	//	{
	//		if((i+1 - nLastValley) >= nMIN_WAVE_PRESSURECOUNT || nLastValley == 0)
	//		{
	//			bool bIsValley = true;
	//			for(int j = i+1; j<=i+nSLOPE_CONTINUOUS_COUNT && j<m_arrSloped[nIndex].size() - 1;++j)
	//			{
	//				if(m_arrSloped[nIndex].at(j) != m_arrSloped[nIndex].at(i+1))
	//				{
	//					bIsValley = false;
	//					break;
	//				}
	//			}

	//			if(bIsValley)
	//			{
	//				nLastValley = i+1;
	//				vectValley.append(i+1);
	//			}
	//		}
	//		else if((i+1 - nLastValley)<5)
	//		{
	//			bool bIsValley = true;
	//			for(int j = i+1; j<=i+nSLOPE_CONTINUOUS_COUNT && j<m_arrSloped[nIndex].size() - 1;++j)
	//			{
	//				if(m_arrSloped[nIndex].at(j) != m_arrSloped[nIndex].at(i+1))
	//				{
	//					bIsValley = false;
	//					break;
	//				}
	//			}

	//			if(bIsValley)
	//			{
	//				vectValley.replace(vectValley.size()-1, i+1);
	//				nLastValley = i+1;
	//			}
	//		}
	//	}
	//}

	QVector<int> vectValley;
	for(int i = 0; i < m_arrSloped[nIndex].size() - 1; ++i)
	{
		if(m_arrSloped[nIndex].at(i+1) - m_arrSloped[nIndex].at(i) == 2)
		{
			if((i+1 - nLastValley) >= nMIN_WAVE_PRESSURECOUNT || nLastValley == 0)
			{
				bool bIsValley = _isJudgeValley(nIndex, i+1);
				//for(int j = i+1; j<=i+nSLOPE_CONTINUOUS_COUNT && j<m_arrSloped[nIndex].size() - 1;++j)
				//{
				//	if(m_arrSloped[nIndex].at(j) != m_arrSloped[nIndex].at(i+1))
				//	{
				//		bIsValley = false;
				//		break;
				//	}
				//}

				if(bIsValley)
				{
					nLastValley = i+1;
					vectValley.append(i+1);
				}
			}
			else if((i+1 - nLastValley)<5)
			{
				bool bIsValley = _isJudgeValley(nIndex, i+1);
				//for(int j = i+1; j<=i+nSLOPE_CONTINUOUS_COUNT && j<m_arrSloped[nIndex].size() - 1;++j)
				//{
				//	if(m_arrSloped[nIndex].at(j) != m_arrSloped[nIndex].at(i+1))
				//	{
				//		bIsValley = false;
				//		break;
				//	}
				//}

				if(bIsValley)
				{
					vectValley.replace(vectValley.size()-1, i+1);
					nLastValley = i+1;
				}
			}
		}
	}
	return vectValley;
}
Exemple #26
0
/**
 * @brief TimerWindow::slotUpdateVerticalPlot 更新纵向绘图槽
 * @param data 数据
 * @param labels 文本
 */
void TimerWindow::slotUpdateVerticalPlot(QVector<double> &data, QVector<QString> &labels)
{
    qDebug()<<"slotUpdateVerticalPlot";
    delete(customPlot);
    customPlot = new QCustomPlot();
    customPlot->setFixedSize(500, 250);
    vLayoutMain->addWidget(customPlot);

    //只取labels的month/day
    QDate tmpDate;
    for(int index = 0; index < labels.size(); ++index){
//        qDebug()<<"before"<<labels.at(index);
        tmpDate = QDate::fromString(labels.at(index),"yyyy-MM-dd");
        labels.replace(index, QString::number(tmpDate.month())+"/"+QString::number(tmpDate.day()));
//        qDebug()<<"after"<<labels.at(index);
    }

    // create empty bar chart objects:
    QCPBars *regen = new QCPBars(customPlot->xAxis, customPlot->yAxis);
    customPlot->addPlottable(regen);

    // set names and colors:
    QPen pen;
    regen->setName("Regenerative");
    pen.setColor(QColor("#D26079"));
    regen->setPen(pen);
    regen->setBrush(QColor("#D26079"));

    QVector<double> ticks;
    double maxValue = 0;
    //查找最大值
    for(int i = 0; i < labels.size(); i++){
        ticks << i + 1;
        maxValue = maxValue > data.at(i) ? maxValue : data.at(i);
    }
    customPlot->xAxis->setAutoTicks(false);
    customPlot->xAxis->setAutoTickLabels(false);
    customPlot->xAxis->setTickVector(ticks);
    customPlot->xAxis->setTickVectorLabels(labels);
    customPlot->xAxis->setTickLabelRotation(0);
    customPlot->xAxis->setSubTickCount(0);
    customPlot->xAxis->setTickLength(0, 4);
    customPlot->xAxis->grid()->setVisible(true);
    customPlot->xAxis->setRange(0, ticks.size() + 1);
    customPlot->xAxis->setLabel("日期");

    // prepare y axis:
    customPlot->yAxis->setRange(0, maxValue + maxValue / 10);
    customPlot->yAxis->setPadding(5); // a bit more space to the left border
    customPlot->yAxis->setLabel("时长 (小时)");
    customPlot->yAxis->grid()->setSubGridVisible(true);
    QPen gridPen;
    gridPen.setStyle(Qt::SolidLine);
    gridPen.setColor(QColor(0, 0, 0, 25));
    customPlot->yAxis->grid()->setPen(gridPen);
    gridPen.setStyle(Qt::DotLine);
    customPlot->yAxis->grid()->setSubGridPen(gridPen);

/*
    // setup legend:
    customPlot->legend->setVisible(false);
    customPlot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignTop|Qt::AlignHCenter);
    customPlot->legend->setBrush(QColor(255, 255, 255, 200));
    QPen legendPen;
    legendPen.setColor(QColor(130, 130, 130, 200));
    customPlot->legend->setBorderPen(legendPen);
    QFont legendFont = font();
    legendFont.setPointSize(10);
    customPlot->legend->setFont(legendFont);
    customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
*/

    regen->setData(ticks, data);
    customPlot->replot();

//    for(int i=0; i < labels.size(); i++){
//        qDebug()<<data.at(i)<<labels.at(i);
//    }
    qDebug()<<"slotUpdateVerticalPlot end";
}
Exemple #27
0
// Note: Callgrind gives different IDs even for same function
// when parts of the function are from different source files.
// Thus, it is no error when multiple indexes map to same function.
TraceFunction* CachegrindLoader::compressedFunction(const QString& name,
                                                    TraceFile* file,
                                                    TraceObject* object)
{
    if ((name[0] != '(') || !name[1].isDigit())
        return _data->function(checkUnknown(name), file, object);

    // compressed format using _functionVector
    int p = name.indexOf(')');
    if (p<2) {
        error(QStringLiteral("Invalid compressed function ('%1')").arg(name));
        return 0;
    }


    int index = name.midRef(1, p-1).toUInt();
    TraceFunction* f = 0;
    p++;
    while((name.length()>p) && name.at(p).isSpace()) p++;
    if (name.length()>p) {
        if (_functionVector.size() <= index) {
            int newSize = index * 2;
#if TRACE_LOADER
            qDebug() << " CachegrindLoader::functionVector enlarged to "
                     << newSize;
#endif
            _functionVector.resize(newSize);
        }

        QString realName = checkUnknown(name.mid(p));
        f = (TraceFunction*) _functionVector.at(index);
        if (f && (f->name() != realName)) {
            error(QStringLiteral("Redefinition of compressed function index %1 (was '%2') to %3")
                  .arg(index).arg(f->name()).arg(realName));
        }

        f = _data->function(realName, file, object);
        _functionVector.replace(index, f);

#if TRACE_LOADER
        qDebug() << "compressedFunction: Inserted at Index " << index
                 << "\n  " << f->fullName()
                 << "\n  in " << f->cls()->fullName()
                 << "\n  in " << f->file()->fullName()
                 << "\n  in " << f->object()->fullName();
#endif
    }
    else {
        if ((_functionVector.size() <= index) ||
            ( (f=(TraceFunction*)_functionVector.at(index)) == 0)) {
            error(QStringLiteral("Undefined compressed function index %1").arg(index));
            return 0;
        }

        // there was a check if the used function (returned from KCachegrinds
        // model) has the same object and file as here given to us, but that was wrong:
        // that holds only if we make this assumption on the model...
    }


    return f;
}
void WidgetAgregarEcuador::otro(int pos,string data1){
    // QMessageBox::information(this,"","nia aqui otro");
    BDecuador.replace(pos,data1);
}
Exemple #29
0
void PithExtractor::correctPith( QVector<rCoord2D> &moelle, float *listMax, float seuilHough ) const {
	const int pithSize = moelle.size();
	if ( pithSize < 3 ) return;
	int startSlice, endSlice, i=0, x1, y1, x2, y2, newx, newy;
	float ax, ay;
	std::cerr << "Coupes interpolées :\n";
	while(i < pithSize){
		if(listMax[i] < seuilHough){
			startSlice = i;
			i++;
			while(listMax[i]<seuilHough && i < pithSize) {i++;}
			endSlice = i-1;
			if(!startSlice){
				ax = 9999;
				ay = 9999;
				x1 = moelle[endSlice+1].x;
				y1 = moelle[endSlice+1].y;
			}else if(endSlice == pithSize-1){
				ax = 9999;
				ay = 9999;
				x1 = moelle[startSlice-1].x;
				y1 = moelle[startSlice-1].y;
			}else {
				x1 = moelle[startSlice-1].x;
				x2 = moelle[endSlice+1].x;
				y1 = moelle[startSlice-1].y;
				y2 = moelle[endSlice+1].y;
				if(x1!=x2){
					ax = (float)((endSlice+1) - (startSlice-1) ) / (x2-x1);
				}else{
					ax = 9999;
				}
				if(y1!=y2){
					ay = (float)((endSlice+1) - (startSlice-1) ) / (y2-y1);
				}else{
					ay = 9999;
				}
			}

			if (endSlice > startSlice) {
				std::cerr << startSlice << "-" << endSlice << ' ';
			} else if (endSlice == startSlice) {
				std::cerr << startSlice << ' ';
			}

			for(int j=startSlice; j<=endSlice; j++){
				if(ax != 9999){
					newx = roundf((j-(startSlice-1)+ax*x1)/ax);
				}else{
					newx = x1;
				}
				if(ay != 9999){
					newy = roundf((j-(startSlice-1)+ay*y1)/ay);
				}else{
					newy = y1;
				}
				moelle.replace(j, rCoord2D(newx, newy));
			}
		}
		i++;
	}
	std::cerr << '\n';
}