void BinnedMap::save(QTextStream& ts, const QString& indent) { QString l2 = indent + " "; ts << indent << "<plugin name=\"Binned Map\">" << endl; ts << l2 << "<tag>" << QStyleSheet::escape(tagName()) << "</tag>" << endl; for (KstVectorMap::Iterator i = _inputVectors.begin(); i != _inputVectors.end(); ++i) { ts << l2 << "<ivector name=\"" << QStyleSheet::escape(i.key()) << "\">" << QStyleSheet::escape(i.data()->tagName()) << "</ivector>" << endl; } for (KstMatrixMap::Iterator i = _outputMatrices.begin(); i != _outputMatrices.end(); ++i) { ts << l2 << "<omatrix name=\"" << QStyleSheet::escape(i.key()); ts << "\">" << QStyleSheet::escape(i.data()->tagName()) << "</omatrix>" << endl; } ts << 12 << "<minX>" << xMin() << "</minX>" << endl; ts << 12 << "<maxX>" << xMax() << "</maxX>" << endl; ts << 12 << "<minY>" << yMin() << "</minY>" << endl; ts << 12 << "<maxY>" << yMax() << "</maxY>" << endl; ts << 12 << "<nX>" << nX() << "</nX>" << endl; ts << 12 << "<nY>" << nY() << "</nY>" << endl; if (autoBin()) { ts << 12 << "<autoBin/>" << endl; } ts << indent << "</plugin>" << endl; }
void KstHsDialog::updateButtons() { if (!_editMultipleMode && _w->_realTimeAutoBin->isChecked()) { autoBin(); } _w->Min->setEnabled(!_w->_realTimeAutoBin->isChecked()); _w->Max->setEnabled(!_w->_realTimeAutoBin->isChecked()); _w->N->setEnabled(!_w->_realTimeAutoBin->isChecked()); _w->AutoBin->setEnabled(!_w->_realTimeAutoBin->isChecked() && !_editMultipleMode); }
KstHsDialogI::KstHsDialogI(QWidget* parent, const char* name, bool modal, WFlags fl) : KstDataDialog(parent, name, modal, fl) { _w = new HistogramDialogWidget(_contents); setMultiple(true); connect(_w->AutoBin, SIGNAL(clicked()), this, SLOT(autoBin())); connect(_w->_vector, SIGNAL(newVectorCreated(const QString&)), this, SIGNAL(modified())); connect(_w->_realTimeAutoBin, SIGNAL(clicked()), this, SLOT(updateButtons())); // signals for multiple edit mode connect(_w->_realTimeAutoBin, SIGNAL(clicked()), this, SLOT(setRealTimeAutoBinDirty())); connect(_w->NormIsPercent, SIGNAL(clicked()), this, SLOT(setNormIsPercentDirty())); connect(_w->NormIsFraction, SIGNAL(clicked()), this, SLOT(setNormIsFractionDirty())); connect(_w->PeakIs1, SIGNAL(clicked()), this, SLOT(setPeakIs1Dirty())); connect(_w->NormIsNumber, SIGNAL(clicked()), this, SLOT(setNormIsNumberDirty())); QColor qc = _w->_curveAppearance->color(); _w->_curveAppearance->setValue(false, false, true, qc, 0, 0, 0, 1, 0); }
KstHsDialog::KstHsDialog(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl) : KstDataDialog(parent) { _w = new Ui::HistogramDialogWidget(); _w->setupUi(_contents); setMultiple(true); connect(_w->AutoBin, SIGNAL(clicked()), this, SLOT(autoBin())); connect(_w->_vector, SIGNAL(newVectorCreated(const QString&)), this, SIGNAL(modified())); connect(_w->_realTimeAutoBin, SIGNAL(clicked()), this, SLOT(updateButtons())); // // connections for multiple edit mode... // connect(_w->_realTimeAutoBin, SIGNAL(clicked()), this, SLOT(setRealTimeAutoBinDirty())); connect(_w->NormIsPercent, SIGNAL(clicked()), this, SLOT(setNormIsPercentDirty())); connect(_w->NormIsFraction, SIGNAL(clicked()), this, SLOT(setNormIsFractionDirty())); connect(_w->PeakIs1, SIGNAL(clicked()), this, SLOT(setPeakIs1Dirty())); connect(_w->NormIsNumber, SIGNAL(clicked()), this, SLOT(setNormIsNumberDirty())); // // connections for apply button... // connect(_w->_vector, SIGNAL(selectionChanged(const QString&)), this, SLOT(wasModifiedApply())); connect(_w->_vector, SIGNAL(selectionChangedLabel(const QString&)), this, SLOT(wasModifiedApply())); connect(_w->Min, SIGNAL(textChanged(const QString&)), this, SLOT(wasModifiedApply())); connect(_w->Max, SIGNAL(textChanged(const QString&)), this, SLOT(wasModifiedApply())); connect(_w->AutoBin, SIGNAL(clicked()), this, SLOT(wasModifiedApply())); connect(_w->_realTimeAutoBin, SIGNAL(clicked()), this, SLOT(wasModifiedApply())); connect(_w->NormIsPercent, SIGNAL(clicked()), this, SLOT(wasModifiedApply())); connect(_w->NormIsFraction, SIGNAL(clicked()), this, SLOT(wasModifiedApply())); connect(_w->NormIsNumber, SIGNAL(clicked()), this, SLOT(wasModifiedApply())); connect(_w->PeakIs1, SIGNAL(clicked()), this, SLOT(wasModifiedApply())); connect(_w->_curveAppearance, SIGNAL(changed()), this, SLOT(wasModifiedApply())); QColor qc = _w->_curveAppearance->color(); _w->_curveAppearance->setValue(false, false, true, qc, 0, 0, 0, 1, 0); _w->N->setMinimumWidth(fontMetrics().width("888888") + QStyle::PM_ScrollBarExtent ); }
void BinnedMap::binnedmap() { KstVectorPtr x = *_inputVectors.find(VECTOR_X); KstVectorPtr y = *_inputVectors.find(VECTOR_Y); KstVectorPtr z = *_inputVectors.find(VECTOR_Z); KstMatrixPtr map = *_outputMatrices.find(MAP); KstMatrixPtr hitsMap = *_outputMatrices.find(HITSMAP); if (autoBin()) { AutoSize(X(),Y(), &_nx, &_xMin, &_xMax, &_ny, &_yMin, &_yMax); } bool needsresize = false; if (_nx<2) { _nx = 2; needsresize = true; } if (_ny<2) { _ny = 2; needsresize = true; } if ((map->xNumSteps() != _nx) || (map->yNumSteps() != _ny) || (map->minX() != _xMin) || (map->minY() != _yMin)) { needsresize = true; } if (map->xStepSize() != (_xMax - _xMin)/double(_nx-1)) { needsresize = true; } if (map->yStepSize() != (_yMax - _yMin)/double(_ny-1)) { needsresize = true; } if (needsresize) { map->change(map->tag(), _nx, _ny, _xMin, _yMin, (_xMax - _xMin)/double(_nx-1), (_yMax - _yMin)/double(_ny-1)); map->resize(_nx, _ny); hitsMap->change(hitsMap->tag(), _nx, _ny, _xMin, _yMin, (_xMax - _xMin)/double(_nx-1), (_yMax - _yMin)/double(_ny-1)); hitsMap->resize(_nx, _ny); } map->zero(); hitsMap->zero(); int ns = z->length(); // the z vector defines the number of points. double n,p, x0, y0, z0; for (int i=0; i<ns; i++) { x0 = x->interpolate(i, ns); y0 = y->interpolate(i, ns); z0 = z->interpolate(i, ns); p = map->value(x0, y0)+z0; map->setValue(x0, y0, p); n = hitsMap->value(x0, y0)+1; hitsMap->setValue(x0, y0, n); } for (int i=0; i<_nx; i++) { for (int j=0; j<_ny; j++) { p = map->valueRaw(i,j); n = hitsMap->valueRaw(i,j); if (n>0) { map->setValueRaw(i,j,p/n); } else { map->setValueRaw(i,j,KST::NOPOINT); } } } //calculate here... }