示例#1
0
void QgsCurveEditorWidget::setHistogramSource( const QgsVectorLayer *layer, const QString &expression )
{
  if ( !mGatherer )
  {
    mGatherer.reset( new QgsHistogramValuesGatherer() );
    connect( mGatherer.get(), &QgsHistogramValuesGatherer::calculatedHistogram, this, [ = ]
    {
      mHistogram.reset( new QgsHistogram( mGatherer->histogram() ) );
      updateHistogram();
    } );
  }

  bool changed = mGatherer->layer() != layer || mGatherer->expression() != expression;
  if ( changed )
  {
    mGatherer->setExpression( expression );
    mGatherer->setLayer( layer );
    mGatherer->start();
    if ( mGatherer->isRunning() )
    {
      //stop any currently running task
      mGatherer->stop();
      while ( mGatherer->isRunning() )
      {
        QCoreApplication::processEvents();
      }
    }
    mGatherer->start();
  }
  else
  {
    updateHistogram();
  }
}
示例#2
0
void REM::buildSampledHistogram() {
	double distance, angle, magnitude;
	int randElem1, randElem2;
	int count, samples;

	samples = (int)((samplePercentage * members.size()) * 2);
	count = 0;

	while (count < samples) {
		randElem1 = rand() % members.size();
		randElem2 = rand() % members.size();

		distance = sqrt(pow(membersArray[randElem1].x - membersArray[randElem2].x, 2))
					+ sqrt(pow(membersArray[randElem1].y - membersArray[randElem2].y, 2));
		angle = fmod(((2 * M_PI) + (membersArray[randElem1].angle - membersArray[randElem2].angle)), (2 * M_PI));

		if (angle > M_PI) {
			angle = (2 * M_PI) - angle;
		}

		magnitude = fabs(membersArray[randElem1].magnitude - membersArray[randElem2].magnitude);
		updateHistogram(distance, angle, magnitude);
		count++;
	}
}
Histogram * histogram(WiggleIterator ** wigs, int count, int width) {
	Histogram * hist = calloc(1, sizeof(Histogram));
	hist->count = count;
	hist->width = width;
	hist->values = calloc(count, sizeof(double*));
	int row;
	for (row = 0; row < count; row++) {
		hist->values[row] = calloc(width, sizeof(double));
		WiggleIterator * wig = wigs[row];
		if (row == 0) {
			while (isnan(wig->value)) {
				pop(wig);
			}
			hist->min = hist->max = wig->value;
			hist->values[0][0] = wig->finish - wig->start;
			pop(wig);
		}

		for (; !wig->done; pop(wig))
			if (!isnan(wig->value))
				updateHistogram(hist, wig, row);
	}

	return hist;
}
示例#4
0
ccColorLevelsDlg::ccColorLevelsDlg(QWidget* parent, ccGenericPointCloud* pointCloud)
	: QDialog(parent, Qt::Tool)
	, Ui::ColorLevelsDialog()
	, m_histogram(0)
	, m_cloud(pointCloud)
{
	setupUi(this);

	//connect GUI elements
	connect(channelComboBox,							SIGNAL(currentIndexChanged(int)),	this,	SLOT(onChannelChanged(int)));
	connect(buttonBox->button(QDialogButtonBox::Apply),	SIGNAL(clicked()),					this,	SLOT(onApply()));

	//create histogram view
	m_histogram = new ccHistogramWindow(this);
	{
		m_histogram->setColorScheme(ccHistogramWindow::USE_SOLID_COLOR);
		m_histogram->setSolidColor(Qt::black);
		//add view
		histoFrame->setLayout(new QHBoxLayout());
		histoFrame->layout()->addWidget(m_histogram);		
	}

	//restore previous parameters
	minInputSpinBox->setValue(s_inputLevels[0]);
	maxInputSpinBox->setValue(s_inputLevels[1]);
	minOutputSpinBox->setValue(s_outputLevels[0]);
	maxOutputSpinBox->setValue(s_outputLevels[1]);
	outputLevelsCheckBox->setChecked(s_outputLevelsEnabled);

	updateHistogram();
}
void DlgSettingsColorFilter::loadForCurveName()
{
  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsColorFilter::loadForCurveName";

  // Get curve name from control
  QString curveName = m_cmbCurveName->currentText();

  // Skip if everything is not set up yet
  if (!curveName.isEmpty () && m_modelColorFilterAfter != 0) {

    // Populate controls
    ColorFilterMode colorFilterMode = m_modelColorFilterAfter->colorFilterMode(curveName);
    m_btnIntensity->setChecked (colorFilterMode == COLOR_FILTER_MODE_INTENSITY);
    m_btnForeground->setChecked (colorFilterMode == COLOR_FILTER_MODE_FOREGROUND);
    m_btnHue->setChecked (colorFilterMode == COLOR_FILTER_MODE_HUE);
    m_btnSaturation->setChecked (colorFilterMode == COLOR_FILTER_MODE_SATURATION);
    m_btnValue->setChecked (colorFilterMode == COLOR_FILTER_MODE_VALUE);

    m_scenePreview->clear();
    m_imagePreview = cmdMediator().document().pixmap().toImage();
    m_scenePreview->addPixmap (QPixmap::fromImage (m_imagePreview));

    QRgb rgbBackground = createThread ();
    m_scale->setBackgroundColor (rgbBackground);
    createThread ();
    updateHistogram();
    updatePreview(); // Needs thread initialized
  }
}
示例#6
0
/*!
  */
void SampleStatistics::update(
    System& system,
    const WavelengthSamples& wavelengths,
    const uint32 /* cycle */) noexcept
{
  auto update_info = [this, &system, &wavelengths](const uint task_id)
  {
    // Set the calculation range
    const auto range = system.calcTaskRange(sampleTable().size(), task_id);
    for (auto pixel_index = range[0]; pixel_index < range[1]; ++pixel_index) {
      if (isEnabled(Type::kVariance))
        updateSampleSquared(wavelengths, pixel_index);

      if (isEnabled(Type::kBayesianCollaborativeValues)) {
        updateHistogram(system, wavelengths, pixel_index);
        updateCovarianceFactor(wavelengths, pixel_index);
      }

      if (isEnabled(Type::kVariance))
        updatePrevSample(wavelengths, pixel_index);
    }
  };

  {
    auto& threads = system.threadManager();
    auto& work_resource = system.globalMemoryManager();
    constexpr uint start = 0;
    const uint end = threads.numOfThreads();
    auto result = threads.enqueueLoop(update_info, start, end, &work_resource);
    result.wait();
  }
}
示例#7
0
const uint* Document::getHistogram(int channel)
{
    if (channel >= NCHANNELS)
        return 0;
    if (!m_histogram_valid)
        updateHistogram();
    return m_freq[channel];
}
void DlgSettingsColorFilter::slotForeground ()
{
  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsColorFilter::slotForeground";

  m_modelColorFilterAfter->setColorFilterMode(m_cmbCurveName->currentText(),
                                         COLOR_FILTER_MODE_FOREGROUND);
  updateHistogram();
  updatePreview();
}
void DlgSettingsColorFilter::slotSaturation ()
{
  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsColorFilter::slotSaturation";

  m_modelColorFilterAfter->setColorFilterMode(m_cmbCurveName->currentText(),
                                         COLOR_FILTER_MODE_SATURATION);
  updateHistogram();
  updatePreview();
}
示例#10
0
void DlgSettingsColorFilter::slotValue ()
{
  LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsColorFilter::slotValue";

  m_modelColorFilterAfter->setColorFilterMode(m_cmbCurveName->currentText(),
                                         COLOR_FILTER_MODE_VALUE);
  updateHistogram();
  updatePreview();
}
示例#11
0
void BloomFilter::insert(unsigned e)
{
  if( !BFBuild )
    return;

  for(int32_t i = 0; i < nVectors; i++) {
    int32_t idx = getIndex(e, i);

    if(countVec[i][idx] == 0) { // it won't be zero anymore
      nonZeroCount[i]++;
      updateHistogram(i);
    }

    countVec[i][idx]++;
  }
  nElements++;
}
示例#12
0
bool RollingValueStore::addRollingValues(char* key,vector<float>* newSamplesPtr)
{
	RollingValueStoreEntry* entry=NULL;

	updateLifeTimeValues(key,newSamplesPtr);
	updateHistogram(key,newSamplesPtr);

	bool exists = store->get(key,(void**)&entry,RollingValue);


	if(exists)
	{
		int numElementsForKey = entry->n;
		int numNewElements = newSamplesPtr->size();
		int numElementsToInsert = numElementsForKey < numNewElements ? numElementsForKey:numNewElements;
		int startPos = numNewElements-numElementsForKey >= 0 ? numNewElements-numElementsForKey :0;



		int i;
		for(i=0;i<numElementsToInsert;i++)
		{

			entry->samples->at((entry->newPosToInsert+i)%numElementsForKey)=newSamplesPtr->at(startPos+i);
		}


		if((entry->newPosToInsert+numElementsToInsert)>=numElementsForKey)
		{
			entry->isFull=true;
		}
		entry->newPosToInsert = (entry->newPosToInsert+numElementsToInsert)%numElementsForKey;

		updateHints(entry);
		return true;
	}
	else
	{
		return false;
	}


}
示例#13
0
void BloomFilter::remove(unsigned e)
{
  if( !BFBuild )
    return;

  for(int32_t i = 0; i < nVectors; i++) {
    int32_t idx = getIndex(e, i);

    countVec[i][idx]--;
    I(countVec[i][idx] >= 0);

    if(countVec[i][idx] == 0) {
      nonZeroCount[i]--;
      updateHistogram(i);
    }
  }

  I(nElements > 0);
  nElements--;
}
void TransferFunctionEditorView::drawBackground(QPainter* painter, const QRectF& rect) {
    painter->fillRect(rect, QColor(89, 89, 89));

    // overlay grid
    int gridSpacing = 25;
    QRectF sRect = sceneRect();
    qreal right = int(sRect.right()) - (int(sRect.right()) % gridSpacing);
    QVarLengthArray<QLineF, 100> lines;

    for (qreal x = sRect.left(); x <= right; x += gridSpacing) {
        lines.append(QLineF(x, sRect.top(), x, sRect.bottom()));
    }

    QPen gridPen;
    gridPen.setColor(QColor(102, 102, 102));
    gridPen.setWidthF(1.0);
    gridPen.setCosmetic(true);
    painter->setPen(gridPen);
    painter->drawLines(lines.data(), lines.size());

    // histogram
    if (showHistogram_ > 0) {
        updateHistogram();
        for (auto& elem : histograms_) {
            QPen pen;
            pen.setColor(QColor(68, 102, 170, 150));
            pen.setWidthF(2.0f);
            pen.setCosmetic(true);
            painter->setPen(pen);

            QBrush brush;
            brush.setColor(QColor(68, 102, 170, 100));
            brush.setStyle(Qt::SolidPattern);
            painter->setBrush(brush);

            painter->drawPolygon(elem);
        }
    }
}
void TransferFunctionEditorView::onVolumeInportChange() {
    if (volumeInport_ && volumeInport_->hasData()) {
        TransferFunctionEditor* editor = dynamic_cast<TransferFunctionEditor*>(this->scene());
        editor->setDataMap(volumeInport_->getData()->dataMap_);
        if (editor) {
            QList<QGraphicsItem*> items = editor->items();
            for (auto& item : items) {
                TransferFunctionEditorControlPoint* cp =
                    qgraphicsitem_cast<TransferFunctionEditorControlPoint*>(item);
                if (cp) {
                    cp->setDataMap(volumeInport_->getData()->dataMap_);
                }
            }
        }
    }

    if (showHistogram_ && volumeInport_ && volumeInport_->hasData()) {
        invalidatedHistogram_ = true;
        updateHistogram();
        this->viewport()->update();
    }
}
示例#16
0
void REM::buildHistogram() {
	list<GroupElement>::iterator xElem, yElem;
	double distance, angle, magnitude;

	if (members.size() > 0) {
		for (xElem = members.begin(); xElem != members.end(); xElem++) {
			for (yElem = members.begin(); yElem != members.end(); yElem++) {

				distance = sqrt(pow((xElem->x - yElem->x), 2) + pow((xElem->y - yElem->y), 2));
				angle = fmod(((2 * M_PI) + (xElem->angle - yElem->angle)), (2 * M_PI));

				if (angle > M_PI) {
					angle = (2 * M_PI) - angle;
				}

				magnitude = fabs(xElem->magnitude - yElem->magnitude); //changed from fabs
				updateHistogram(distance, angle, magnitude);
			}
		}
	} else {
		fprintf(stderr, "REM_ERROR: No members found to build a distribution.\n");
		exit(1);
	}
}
示例#17
0
void MyHistogram::applyLungSegmentation(){
    lungSegmentation->setChecked(false);
    controller->activeLungSegmentation(lungSegmentation->isChecked());
    controller->applyLungSegmentation();
    updateHistogram();
}
示例#18
0
void MyHistogram::applySimpleThreshold(){
    simpleThreshold->setChecked(false);
    controller->activeSimpleThreshold(simpleThreshold->isChecked());
    controller->applySimpleThreshold();
    updateHistogram();
}
void RangeSelectWidget::setStatistic(ndimdata::DataStatistic statistic)
{
	m_statistic = std::move(statistic);
	updateHistogram();
	modeChanged();
}
示例#20
0
void ccColorLevelsDlg::onChannelChanged(int channel)
{
	updateHistogram();
}
示例#21
0
void QgsCurveEditorWidget::setMinHistogramValueRange( double minValueRange )
{
  mMinValueRange = minValueRange;
  updateHistogram();
}
示例#22
0
void QgsCurveEditorWidget::setMaxHistogramValueRange( double maxValueRange )
{
  mMaxValueRange = maxValueRange;
  updateHistogram();
}