Пример #1
0
// HELPER
void process(Mesh& mesh,
			 QStringList& vList,
			 QVector<QVector3D>& verts,
			 QVector<QVector2D>& texCords,
			 QVector<QVector3D>& normals)
{
	int vertPosition = vList[0].toInt() - 1; // obj file index starts at '1'
	mesh.indices().append(vertPosition);

	int texPosition = 0;
	int normalPosition = 0;

	if (!texCords.empty())
	{
		// obj texture starts (0,0)->left bottom corner
		// opengl starts (0,0)->left top corner
		texPosition = vList[1].toInt() - 1;
		mesh.uvs()[vertPosition].setX(texCords[texPosition].x());
		mesh.uvs()[vertPosition].setY(1.0 - texCords[texPosition].y());
	}

	if (!normals.empty())
	{
		normalPosition = vList[2].toInt() - 1;
		mesh.normals()[vertPosition] = normals[normalPosition];
	}
}
Пример #2
0
QVector<DkPackage> DkXmlUpdateChecker::updatesAvailable(QXmlStreamReader& localXml, QXmlStreamReader& remoteXml) const {

	QVector<DkPackage> localPackages = parse(localXml);
	QVector<DkPackage> remotePackages = parse(remoteXml);
	QVector<DkPackage> updatePackages;

	for (const DkPackage& p : localPackages) {

		int idx = remotePackages.indexOf(p);

		if (idx != -1) {
			bool isEqual = remotePackages[idx].version() == p.version();
			qDebug() << "checking" << p.name() << "v" << p.version();

			if (!isEqual)	// we assume that the remote is _always_ newer than the local version
				updatePackages.append(remotePackages[idx]);
			else
				qDebug() << "up-to-date";
		}
		else
			qDebug() << "I could not find" << p.name() << "in the repository";
	}

	if (localPackages.empty() || remotePackages.empty())
		qDebug() << "WARNING: I could not find any packages. local (" << localPackages.size() << ") remote (" << remotePackages.size() << ")";

	return updatePackages;
}
Пример #3
0
dockListUpdate mutableSquareImageContainer::replaceRareColors() {

  QHash<QRgb, int> countHash;
  ::colorCounts(image_, originalDimension_, &countHash);

  rareColorsDialog countDialog(countHash);
  const int dialogReturnCode = countDialog.exec();
  QList<QRgbPair> pairs = countDialog.colorsToChange();
  if (dialogReturnCode == QDialog::Accepted && pairs.size() > 0) {
    QList<colorChange> changeHistories;
    QSet<flossColor> oldFloss;
    QVector<triC> oldColors;
    for (int i = 0, size = pairs.size(); i < size; ++i) {
      const QRgb oldColor = pairs[i].first;
      const triC oldTriColor(oldColor);
      oldColors.push_back(oldTriColor);
      oldFloss.insert(getFlossColorFromColor(oldTriColor));
      const QRgb newColor = pairs[i].second;
      const QVector<pairOfInts> changedSquares =
        ::changeColor(&image_, oldColor, newColor, originalDimension_);
      if (!changedSquares.empty()) {
        removeColor(oldColor);
        changeHistories.push_back(colorChange(oldColor, newColor,
                                              changedSquares));
      }
    }
    addToHistory(historyItemPtr(new rareColorsHistoryItem(changeHistories,
                                                          oldFloss)));
    return dockListUpdate(oldColors, true);
  }
  else {
    return dockListUpdate();
  }
}
Пример #4
0
mutableSquareImageContainer::mutableSquareImageContainer(const QString& name,
                                           const QVector<triC>& colors,
                                           const QImage& image,
                                           int dimension, flossType type)
  : squareImageContainer(name, image.size(), type), image_(image),
    toolFlossType_(flossVariable), originalDimension_(dimension),
    widthSquareCount_(image.width()/dimension),
    heightSquareCount_(image.height()/dimension),
    colorListCheckNeeded_(false) {

  if ((!colors.empty()) &&
     colors.size() <= symbolChooser::maxNumberOfSymbols()) {
    valid_ = true;
    invalidColorCount_ = 0;
    for (int i = 0, size = colors.size(); i < size; ++i) {
      flossColors_.push_back(flossColor(colors[i], type));
    }
  }
  else {
    valid_ = false;
    invalidColorCount_ = colors.size();
    flossColors_ = QVector<flossColor>();
  }
  squareImageContainer::setScaledSize(QSize(0, 0));
}
Пример #5
0
bool QgsVectorLayerEditUtils::boundingBoxFromPointList( const QVector<QgsPointXY> &list, double &xmin, double &ymin, double &xmax, double &ymax ) const
{
  if ( list.empty() )
  {
    return false;
  }

  xmin = std::numeric_limits<double>::max();
  xmax = -std::numeric_limits<double>::max();
  ymin = std::numeric_limits<double>::max();
  ymax = -std::numeric_limits<double>::max();

  for ( QVector<QgsPointXY>::const_iterator it = list.constBegin(); it != list.constEnd(); ++it )
  {
    if ( it->x() < xmin )
    {
      xmin = it->x();
    }
    if ( it->x() > xmax )
    {
      xmax = it->x();
    }
    if ( it->y() < ymin )
    {
      ymin = it->y();
    }
    if ( it->y() > ymax )
    {
      ymax = it->y();
    }
  }

  return true;
}
Пример #6
0
    static void tp(int p, int s, BS &b) {
        if (!b.isOut(s)) {
            return;
        }

        int berry = b.poke(s).item();

        QVector<int> stats;
        for (int i = Attack; i <= Evasion; i++) {
            if (fpoke(b,s).boosts[i] < 6) {
                stats.push_back(i);
            }
        }
        if (stats.empty())
            return;

        if (!testpinch(p, s, b, 4, false))
            return;

        int stat = stats[b.randint(stats.size())];
        if (b.hasWorkingAbility(s, Ability::Contrary)) {
            b.sendBerryMessage(9,s,1,s, berry, stat);
        } else {
            b.sendBerryMessage(9,s,0,s, berry, stat);
        }
        b.inflictStatMod(s, stat, 2, s, false);
    }
triState numColorsBaseModes::performProcessing(QImage* image, int numColors,
                                               int numImageColors) {

  colorTransformerPtr transformer =
    colorTransformer::createColorTransformer(flossMode());
  QVector<triC> newColors = ::chooseColors(*image, numColors,
                                           clickedColorList(),
                                           numImageColors,
                                           transformer);
  if (!newColors.empty()) {
    // remove the seed colors from newColors to create generatedColors
    const QVector<triC>& seedColors = clickedColorList();
    QVector<triC> generatedColors = newColors;
    for (int i = 0, size = seedColors.size(); i < size; ++i) {
      generatedColors.remove(generatedColors.indexOf(seedColors[i]));
    }
    setGeneratedColorList(generatedColors);
  }
  else {
    return triNoop;
  }
  if (!::segment(image, newColors, numImageColors).empty()) {
    //return triState(colorList().size() != savedColorsSize);
    return triTrue;
  }
  else {
    return triNoop;
  }
}
Пример #8
0
void ProfileForm::onDeleteClicked()
{
    if (GUI::askQuestion(tr("Really delete profile?", "deletion confirmation title"),
                         tr("Are you sure you want to delete this profile?",
                            "deletion confirmation text"))) {
        Nexus& nexus = Nexus::getInstance();

        QVector<QString> manualDeleteFiles = nexus.getProfile()->remove();

        if (!manualDeleteFiles.empty()) {
            QString message =
                tr("The following files could not be deleted:", "deletion failed text part 1") + "\n\n";

            for (auto& file : manualDeleteFiles) {
                message = message + file + "\n";
            }

            message =
                message + "\n" + tr("Please manually remove them.", "deletion failed text part 2");

            GUI::showError(tr("Files could not be deleted!", "deletion failed title"), message);
        }

        nexus.showLoginLater();
    }
}
Пример #9
0
bool
EditableDenseThreeDimensionalModel::shouldUseLogValueScale() const
{
    QReadLocker locker(&m_lock);

    QVector<float> sample;
    QVector<int> n;
    
    for (int i = 0; i < 10; ++i) {
        size_t index = i * 10;
        if (index < m_data.size()) {
            const Column &c = m_data.at(index);
            while (c.size() > sample.size()) {
                sample.push_back(0.f);
                n.push_back(0);
            }
            for (int j = 0; j < c.size(); ++j) {
                sample[j] += c.at(j);
                ++n[j];
            }
        }
    }

    if (sample.empty()) return false;
    for (int j = 0; j < sample.size(); ++j) {
        if (n[j]) sample[j] /= n[j];
    }
    
    return LogRange::useLogScale(sample.toStdVector());
}
Пример #10
0
double BeatUtils::findFirstCorrectBeat(const QVector<double> rawbeats,
                                       const int SampleRate, const double global_bpm) {
    for (int i = N; i < rawbeats.size(); i++) {
        // get start and end sample of the beats
        double start_sample = rawbeats.at(i-N);
        double end_sample = rawbeats.at(i);

        // The time in seconds represented by this sample range.
        double time = (end_sample - start_sample)/SampleRate;

        // Average BPM within this sample range.
        double avg_bpm = 60.0 * N / time;

        //qDebug() << "Local BPM between beat " << (i-N) << " and " << i << " is " << avg_bpm;

        // If the local BPM is within kCorrectBeatLocalBpmEpsilon of the global
        // BPM then use this window as the first beat.
        if (fabs(global_bpm - avg_bpm) <= kCorrectBeatLocalBpmEpsilon) {
            //qDebug() << "Using beat " << (i-N) << " as first beat";
            return start_sample;
        }
    }

    // If we didn't find any beat that matched the window, return the first
    // beat.
    return !rawbeats.empty() ? rawbeats.first() : 0.0;
}
Пример #11
0
///-------------------------------------------------------------
bool CXMLAnalyser::checkCategories( const QVector< int > &categoriesToCheck )
///-------------------------------------------------------------
{
    bool isOkay = true;

    if ( false == categoriesToCheck.empty( ) )
    {
        QVector< int >::const_iterator current = categoriesToCheck.begin( );
        QVector< int >::const_iterator end     = categoriesToCheck.end( );

        while( current != end )
        {
            if ( false == isInMetaDataCategories( *current ) )
            {
                isOkay      = false;
                mLastError  = eWrongCategory;
                break;
            }

            ++current;
        }
    }
    else
    {
        isOkay = false;
        mLastError = eEmptyCategories;
    }

    return isOkay;
}
Пример #12
0
QList<int>* listview_t::get_selectedIndexes()
{//descending
    QList<int>* result = new QList<int>;
    QVector<int> temp;
    QModelIndexList list = selectedIndexes();
    QModelIndexList::const_iterator it;
    for (it = list.constBegin(); it != list.constEnd(); it++)
        temp.push_back(it->row());

    if (!temp.empty())
    {
        for (int j = 0; j < temp.size() - 1; j++)
        {
            for (int i = 0; i < temp.size() - j - 1; i++)
                if (temp[i] > temp[i+1])
                {
                    int tmp = temp[i];
                    temp[i] = temp[i+1];
                    temp[i+1] = tmp;
                }
            result->push_back(temp[temp.size() - j - 1]);
        }
        result->push_back(temp[0]);
    }
    return result;
}
Пример #13
0
// really generate the cache
void ImageView::generateCache() {
  // disable the one-shot timer
  cacheTimer_->deleteLater();
  cacheTimer_ = nullptr;

  if(!imageItem_ || image_.isNull()) return;

  // generate a cache for "the visible part" of the scaled image
  // rectangle of the whole image in viewport coordinate
  QRect viewportImageRect = sceneToViewport(imageItem_->rect());
  // rect of the image area that's visible in the viewport (in viewport coordinate)
  cachedRect_ = viewportImageRect.intersected(viewport()->rect());

  // convert to the coordinate of the original image
  cachedSceneRect_ = viewportToScene(cachedRect_);
  // create a sub image of the visible without real data copy
  // Reference: http://stackoverflow.com/questions/12681554/dividing-qimage-to-smaller-pieces
  QRect subRect = image_.rect().intersected(cachedSceneRect_);
  const uchar* bits = image_.constBits();
  unsigned int offset = subRect.x() * image_.depth() / 8 + subRect.y() * image_.bytesPerLine();
  QImage subImage = QImage(bits + offset, subRect.width(), subRect.height(), image_.bytesPerLine(), image_.format());

  // If the original image has a color table, also use it for the subImage
  QVector<QRgb> colorTable = image_.colorTable();
  if (!colorTable.empty())
    subImage.setColorTable(colorTable);

  // QImage scaled = subImage.scaled(subRect.width() * scaleFactor_, subRect.height() * scaleFactor_, Qt::KeepAspectRatio, Qt::SmoothTransformation);
  QImage scaled = subImage.scaled(cachedRect_.width(), cachedRect_.height(), Qt::KeepAspectRatio, Qt::SmoothTransformation);

  // convert the cached scaled image to pixmap
  cachedPixmap_ = QPixmap::fromImage(scaled);
  viewport()->update();
}
Пример #14
0
bool GroupExpression::isEmpty(Card* caster, const Event* e) const
{
    QVector<Character*>* group = eval(caster, e);
    bool empty = group->empty();
    delete group;
    return empty;
}
Пример #15
0
    /*virtual*/
    bool ArtworksViewModel::doRemoveSelectedArtworks() {
        LOG_DEBUG << "#";

        int count = (int)m_ArtworksList.size();
        QVector<int> indicesToRemove;
        indicesToRemove.reserve(count);

        for (int i = 0; i < count; ++i) {
            const MetadataElement &item = m_ArtworksList.at(i);
            if (item.isSelected()) {
                indicesToRemove.append(i);
            }
        }

        bool anyItemToRemove = !indicesToRemove.empty();

        if (anyItemToRemove) {
            LOG_INFO << "Removing" << indicesToRemove.size() << "item(s)";

            QVector<QPair<int, int> > rangesToRemove;
            Helpers::indicesToRanges(indicesToRemove, rangesToRemove);
            removeItemsAtIndices(rangesToRemove);

            if (m_ArtworksList.empty()) {
                emit requestCloseWindow();
            }

            emit artworksCountChanged();
        }

        return anyItemToRemove;
    }
Пример #16
0
void MainWindow::convertToProjection()
{
    Q_D(MainWindow);
    const auto contents = d->_document->toContents();
    if (contents.header().type() != ImageResource::Type::CubeTexture) {
        QMessageBox::warning(this,
                             tr("Convert to projection"),
                             tr("Can't convert to projection, not a cube texture"));
    }

    QVector<QImage> images;
    images.reserve(contents.header().imageCount() * contents.header().mipmapCount());
    for (int index = 0; index < contents.header().imageCount(); ++index) {
        for (int level = 0; level < contents.header().mipmapCount(); ++level) {
            auto texture = contents.resource(index, level).cubeTexture();
            auto image = texture.toProjection(CubeTexture::Projection::HorizonalCross);
            images.append(image);
        }
    }
    if (images.empty())
        return;
    ImageHeader header(contents.header());
    header.setType(ImageResource::Type::Image);
    header.setSize(images.at(0).size());
    ImageContents newContents(header);
    auto it = images.begin();
    for (int index = 0; index < contents.header().imageCount(); ++index) {
        for (int level = 0; level < contents.header().mipmapCount(); ++level) {
            newContents.setResource(*it++);
        }
    }

    d->_document->setContents(newContents);
}
Пример #17
0
void buttonGrid::constructorHelper(const QVector<QPixmap>& icons,
                                   const QString& windowTitle,
                                   int rowWidth) {

  buttonDim_ = icons.empty() ? 12 : icons[0].width() + 12;
  const QPalette palette(QApplication::palette());
  const QColor windowColor(palette.color(QPalette::Window));
  const QColor darkColor(palette.color(QPalette::Dark));
  for (int i = 0, size = icons.size(); i < size; ++i) {
    QPixmap pixmap(buttonDim_, buttonDim_);
    pixmap.fill(windowColor);
    QPainter painter(&pixmap);
    painter.setPen(QPen(darkColor, 2));
    painter.setRenderHint(QPainter::Antialiasing);
    painter.drawPixmap(QPoint(6, 6), icons[i]);
    painter.drawRoundedRect(QRect(1, 1, buttonDim_-2, buttonDim_-2),
                            3.5, 3.5);
    icons_.push_back(pixmap);
  }
  const int numIcons = icons_.size();
  buttonsPerRow_ = rowWidth ? rowWidth : ceil(sqrt(numIcons));
  if (!rowWidth) {
    buttonsPerRow_ += buttonsPerRow_/4;
  }
  int gridRows = numIcons/buttonsPerRow_;
  if (numIcons % buttonsPerRow_ != 0) {
    ++gridRows;
  }
  setFixedSize(buttonsPerRow_ * buttonDim_, gridRows * buttonDim_);
  setWindowTitle(windowTitle);
}
Пример #18
0
QValidator::State Private::FileSystemPathValidator::validate(const QString &path, const QVector<QStringRef> &pathComponents, bool strict,
                                                             int firstComponentToTest, int lastComponentToTest) const
{
    Q_ASSERT(firstComponentToTest >= 0);
    Q_ASSERT(lastComponentToTest >= firstComponentToTest);
    Q_ASSERT(lastComponentToTest < pathComponents.size());

    m_lastTestResult = TestResult::DoesNotExist;
    if (pathComponents.empty())
        return strict ? QValidator::Invalid : QValidator::Intermediate;

    for (int i = firstComponentToTest; i < lastComponentToTest; ++i) {
        if (pathComponents[i].isEmpty()) continue;

        QStringRef componentPath(&path, 0, pathComponents[i].position() + pathComponents[i].size());
        m_lastTestResult = testPath(componentPath, false);
        if (m_lastTestResult != TestResult::OK) {
            m_lastTestedPath = componentPath.toString();
            return strict ? QValidator::Invalid : QValidator::Intermediate;
        }
    }

    const bool finalPath = (lastComponentToTest == (pathComponents.size() - 1));
    QStringRef componentPath(&path, 0, pathComponents[lastComponentToTest].position()
                                + pathComponents[lastComponentToTest].size());
    m_lastTestResult = testPath(componentPath, finalPath);
    if (m_lastTestResult != TestResult::OK) {
        m_lastTestedPath = componentPath.toString();
        return strict ? QValidator::Invalid : QValidator::Intermediate;
    }
    return QValidator::Acceptable;
}
Пример #19
0
void Scene::render()
{
    for(int i = -CWIDTH / 2; i < CWIDTH / 2; i ++)
    {
        qDebug() << i;
        for(int j = -CHEIGHT / 2; j < CHEIGHT / 2; j ++)
        {
            QVector<Ray*> rSeq = camera->pixelLight(i, j);
            int s = rSeq.size();
            Intensity rgb(0, 0, 0);
            while(!rSeq.empty())
            {
                Ray* tmp = rSeq.front();

                rgb = rgb + (1.0 / s) * getIntensity(tmp);
                rSeq.pop_front();
                if(tmp != NULL)
                {
                    delete tmp;
                    tmp = NULL;
                }
            }
            pixels[i + CWIDTH / 2][j + CHEIGHT / 2] = rgb.toRGB();

        }

    }
}
Пример #20
0
void UpdateLevelOfDetailJob::updateEntityLod(Entity *entity)
{
    if (!entity->isEnabled())
        return; // skip disabled sub-trees, since their bounding box is probably not valid anyway

    QVector<LevelOfDetail *> lods = entity->renderComponents<LevelOfDetail>();
    if (!lods.empty()) {
        LevelOfDetail* lod = lods.front();  // other lods are ignored

        if (lod->isEnabled() && !lod->thresholds().isEmpty()) {
            switch (lod->thresholdType()) {
            case QLevelOfDetail::DistanceToCameraThreshold:
                updateEntityLodByDistance(entity, lod);
                break;
            case QLevelOfDetail::ProjectedScreenPixelSizeThreshold:
                updateEntityLodByScreenArea(entity, lod);
                break;
            default:
                Q_ASSERT(false);
                break;
            }
        }
    }

    const auto children = entity->children();
    for (Qt3DRender::Render::Entity *child : children)
        updateEntityLod(child);
}
Пример #21
0
void AreaInfo::reset(int w, int h) {
    _useEntireScreen = true;
    _rectInitialized = false;
    _vdimX = w;
    _vdimY = h;


    QVector<QString> vertices = _parms != nullptr ? getVertices(_parms->m_CurrentFilename) : QVector<QString>();

    if ( vertices == DEFAULT_PAIR  //couldn't find entry
        || vertices.empty()) //biotracker just started
    {
        std::vector<cv::Point> v{
            cv::Point(0,0),
            cv::Point(0,_vdimY),
            cv::Point(_vdimX,_vdimY),
            cv::Point(_vdimX,0)
        };
        _apperture->setVertices(v);
        _rect->setVertices(v);
    }
    else
    {
        std::vector<QPoint> pts = toQPointVector(vertices[0]);
        std::vector<QPoint> pts2 = toQPointVector(vertices[1]);
        _apperture->setVertices(QVecToCvVec(pts2));
        _rect->setVertices(QVecToCvVec(pts));
    }
}
Пример #22
0
TextureFile::TextureFile(const QImage &image) :
	_image(image), _currentColorTable(0)
{
	QVector<QRgb> colorTable = _image.colorTable();
	if(!colorTable.empty()) {
		_colorTables.append(colorTable);
	}
}
Пример #23
0
bool TagsModel::setData(const QModelIndex& index, const QVariant& value, int role)
{
    const QVector<int> touchedRoles = setDataInternal(index, value, role);
    const bool set = touchedRoles.empty() == false;

    if (set)
        emit dataChanged(index, index, touchedRoles);

    return set;
}
Пример #24
0
void DcOptions::processFromList(const QVector<MTPDcOption> &options, bool overwrite) {
	if (options.empty() || _immutable) {
		return;
	}

	auto idsChanged = std::vector<DcId>();
	idsChanged.reserve(options.size());
	auto shiftedIdsProcessed = std::vector<ShiftedDcId>();
	shiftedIdsProcessed.reserve(options.size());
	{
		QWriteLocker lock(&_mutex);
		if (overwrite) {
			idsChanged.reserve(_data.size());
		}
		for (auto &mtpOption : options) {
			if (mtpOption.type() != mtpc_dcOption) {
				LOG(("Wrong type in DcOptions: %1").arg(mtpOption.type()));
				continue;
			}

			auto &option = mtpOption.c_dcOption();
			auto dcId = option.vid.v;
			auto flags = option.vflags.v;
			auto dcIdWithShift = MTP::shiftDcId(dcId, flags);
			if (base::contains(shiftedIdsProcessed, dcIdWithShift)) {
				continue;
			}

			shiftedIdsProcessed.push_back(dcIdWithShift);
			auto ip = std::string(option.vip_address.v.constData(), option.vip_address.v.size());
			auto port = option.vport.v;
			if (applyOneGuarded(dcId, flags, ip, port)) {
				if (!base::contains(idsChanged, dcId)) {
					idsChanged.push_back(dcId);
				}
			}
		}
		if (overwrite && shiftedIdsProcessed.size() < _data.size()) {
			for (auto i = _data.begin(); i != _data.end();) {
				if (base::contains(shiftedIdsProcessed, i->first)) {
					++i;
				} else {
					if (!base::contains(idsChanged, i->second.id)) {
						idsChanged.push_back(i->second.id);
					}
					i = _data.erase(i);
				}
			}
		}
	}

	if (!idsChanged.empty()) {
		_changed.notify(std::move(idsChanged));
	}
}
Пример #25
0
void MainWindow::on_listView_clicked(const QModelIndex &index)
{
    //QModelIndex a = ui->listView->selectedIndexes().back();
    QVariant selected = dataModel->compNameList->data(index,Qt::DisplayRole);
    dataModel->dataViewComp = selected.toString();
    QVector<double> dataViewPrice = dataModel->priceBuff.value(selected.toString());
    QVector<double> xval;
    QVector<double> baseVal;
    if(dataViewPrice.empty()) return;
    double min = dataViewPrice[0];
    for(auto &i : dataViewPrice) min = std::fmin(min,i);
    for(int i = 0; i<dataViewPrice.size(); i++){
        xval<<i;
        baseVal<<min;
    }
    QCustomPlot* p = ui->qcpDataView;;
    p->clearGraphs();

    QCPGraph* timeline = new QCPGraph(p->xAxis,p->yAxis);
    timeline->addData(xval,dataViewPrice);
    QCPGraph* base = new QCPGraph(p->xAxis,p->yAxis);
    base->setData(xval,baseVal);

    p->addPlottable(timeline);
    p->addPlottable(base);

    timeline->setChannelFillGraph(base);
    timeline->setPen(QPen(QColor(0,0,0,0)));
    timeline->setBrush(QColor(0,0,255,100));

    //QVector<double> ticks;
    QVector<QString> labels;

    int L = this->dataModel->dateBuff.values()[0].size()-1;
    int len = 6;
    float step = (float)L/(float)len;
    for(int i = 0; i<= len; i++){
        labels<<this->dataModel->dateBuff.values()[0][i*step].toString("MM/yy");
    }

    p->xAxis->setTickVectorLabels(labels);
    p->xAxis->setAutoTicks(true);
    p->xAxis->setAutoTickLabels(false);

    p->xAxis->setTickLabelRotation(-60);
    //p->xAxis->setSubTickCount(0);
    //p->xAxis->setTickLength(0, len-1);

    p->xAxis->grid()->setVisible(true);
    //p->xAxis->setRange(0, len-2);
    //p->xAxis->setTickVector(ticks);

    p->rescaleAxes();
    p->replot();
}
Пример #26
0
bool IOWorker::write_ldr_frame(pfs::Frame* ldr_input,
                               const QString& filename,
                               const QString& inputFileName,
                               const QVector<float>& expoTimes,
                               TonemappingOptions* tmopts,
                               const pfs::Params& params)
{
    bool status = true;
    emit IO_init();

    QScopedPointer<TMOptionsOperations> operations;
    if (tmopts != NULL) {
        operations.reset(new TMOptionsOperations(tmopts));
    }
    
    QFileInfo qfi(filename);
    QString absoluteFileName = qfi.absoluteFilePath();
    QByteArray encodedName = QFile::encodeName(absoluteFileName);

    try
    {
        FrameWriterPtr writer = FrameWriterFactory::open(encodedName.constData(), params);
        writer->write(*ldr_input, params);
    }
    catch (pfs::io::UnsupportedFormat& exUnsupported) {
        qDebug() << "Exception: " << exUnsupported.what();

        QString format = qfi.suffix();
        // QScopedPointer will call delete when this object goes out of scope
        QScopedPointer<QImage> image(fromLDRPFStoQImage(ldr_input, 0.f, 1.f));
        status = image->save(filename, format.toLocal8Bit(), -1);
    }
    catch (pfs::io::InvalidFile& /*exInvalid*/) {
        status = false;
    }
    catch (pfs::io::WriteException& /*exWrite*/) {
        status = false;
    }

    if ( status )
    {
        // copy EXIF tags from the 1st bracketed image
        if ( !inputFileName.isEmpty() )
        {
            QFileInfo fileinfo(inputFileName);
            QString absoluteInputFileName = fileinfo.absoluteFilePath();
            QByteArray encodedInputFileName = QFile::encodeName(absoluteInputFileName);
            QString comment = operations->getExifComment();
            if ( !expoTimes.empty() ) {
                comment += "\nBracketed images exposure times:\n";
                foreach (float e, expoTimes) {
                    comment += QString("%1").arg(e) + "\n";
                }
            }
Пример #27
0
TopoDS_Shape Assembly::lookupShape ( QVector<uint>& id_path ) const
{
  QMap<uint,Figure*>::const_iterator figure = figures_.find( id_path[0] );

  if ( figure != figures_.end() ) {
    id_path.erase( id_path.begin() );
    if ( !id_path.empty() )
      return figure.value()->lookupShape( id_path );
  }

  return TopoDS_Shape();	// Really an error...
}
Пример #28
0
//Выброчное среднее
double sample_mean(QVector<double> X)
{
    double sum=0;
    if(X.empty())
    {
        //throw length_error("sample_mean: error empty vector!");
    }
    for(auto i : X)
    {
        sum+=i;
    }
    return sum/X.size();
}
Пример #29
0
QString Subassembly::idPath ( QVector<uint> id_path ) const
{
  if ( subassembly_->id() != id_path[0] )
    return QString::null;	// Really an error...

  id_path.erase( id_path.begin() );

  if ( id_path.empty() )
    return subassembly_->name() + '.' + subassembly_->type();

  return subassembly_->name() + '.' + subassembly_->type() + '/' +
    subassembly_->idPath( id_path );
}
triState fixedListBaseMode::performProcessing(QImage* image, int ,
                                              int numImageColors) {

  QVector<triC> segmentColors = ::segment(image, clickedColorList(),
                                          numImageColors);
  if (!segmentColors.empty()) {
    setGeneratedColorList(segmentColors);
    return triTrue;
  }
  else {
    return triNoop;
  }
}