[Kst] branches/work/kst/1.6/kst/src/plugins/binnedmap
Andrew Walker
arwalker at sumusltd.com
Fri Jan 18 21:04:08 CET 2008
SVN commit 763170 by arwalker:
format changes
M +50 -37 binnedmap.cpp
M +1 -1 binnedmap.h
M +4 -24 binnedmapdialog_i.cpp
M +0 -1 binnedmapdialog_i.h
--- branches/work/kst/1.6/kst/src/plugins/binnedmap/binnedmap.cpp #763169:763170
@@ -36,8 +36,7 @@
KST_KEY_DATAOBJECT_PLUGIN( binnedmap )
-K_EXPORT_COMPONENT_FACTORY( kstobject_binnedmap,
- KGenericFactory<BinnedMap>( "kstobject_binnedmap" ) )
+K_EXPORT_COMPONENT_FACTORY( kstobject_binnedmap, KGenericFactory<BinnedMap>( "kstobject_binnedmap" ) )
BinnedMap::BinnedMap( QObject */*parent*/, const char */*name*/, const QStringList &/*args*/ )
: KstDataObject() {
@@ -56,42 +55,52 @@
QString BinnedMap::xTag() const {
KstVectorPtr v = X();
+
if (v) {
return v->tagName();
}
+
return QString::null;
}
QString BinnedMap::yTag() const {
KstVectorPtr v = Y();
+
if (v) {
return v->tagName();
}
+
return QString::null;
}
QString BinnedMap::zTag() const {
KstVectorPtr v = Z();
+
if (v) {
return v->tagName();
}
+
return QString::null;
}
QString BinnedMap::mapTag() const {
KstMatrixPtr m = map();
+
if (m) {
return m->tagName();
}
+
return QString::null;
}
QString BinnedMap::hitsMapTag() const {
KstMatrixPtr m = hitsMap();
+
if (m) {
return m->tagName();
}
+
return QString::null;
}
@@ -144,6 +153,7 @@
void BinnedMap::setMap(const QString &name) {
QString tname;
+
if (name.isEmpty()) {
tname = i18n("map");
} else {
@@ -156,6 +166,7 @@
void BinnedMap::setHitsMap(const QString &name) {
QString tname;
+
if (name.isEmpty()) {
tname = i18n("hits map");
} else {
@@ -189,13 +200,12 @@
depUpdated = UPDATE == Z()->update(updateCounter) || depUpdated;
if (depUpdated) {
- binnedmap();
+ binnedmap();
- //matrixRealloced(BinnedMap(), BinnedMap()->value(), real()->length());
- map()->setDirty();
- map()->update(updateCounter);
- hitsMap()->setDirty();
- hitsMap()->update(updateCounter);
+ map()->setDirty();
+ map()->update(updateCounter);
+ hitsMap()->setDirty();
+ hitsMap()->update(updateCounter);
}
unlockInputsAndOutputs();
@@ -214,35 +224,36 @@
if (autoBin()) {
AutoSize(X(),Y(), &_nx, &_xMin, &_xMax, &_ny, &_yMin, &_yMax);
}
-
+
bool needsresize = false;
- if (_nx<2) {
+
+ if (_nx < 2) {
_nx = 2;
needsresize = true;
}
- if (_ny<2) {
+ 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->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));
+ (_xMax - _xMin)/double(_nx-1), (_yMax - _yMin)/double(_ny-1));
hitsMap->resize(_nx, _ny);
}
@@ -251,6 +262,7 @@
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);
@@ -263,17 +275,15 @@
for (int i=0; i<_nx; i++) {
for (int j=0; j<_ny; j++) {
- p = map->valueRaw(i,j);
- n = hitsMap->valueRaw(i,j);
+ p = map->valueRaw(i, j);
+ n = hitsMap->valueRaw(i, j);
if (n>0) {
- map->setValueRaw(i,j,p/n);
+ map->setValueRaw(i, j, p/n);
} else {
- map->setValueRaw(i,j,KST::NOPOINT);
+ map->setValueRaw(i, j, KST::NOPOINT);
}
}
}
-
- //calculate here...
}
@@ -312,24 +322,24 @@
} else if (e.tagName() == "ivector") {
_inputVectorLoadQueue.append(qMakePair(e.attribute("name"), e.text()));
} else if (e.tagName() == "omatrix") {
- KstWriteLocker blockMatrixUpdates(&KST::matrixList.lock());
- KstMatrixPtr m;
- m = new KstMatrix(KstObjectTag(e.text(), tag()), this);
- _outputMatrices.insert(e.attribute("name"), m);
+ KstWriteLocker blockMatrixUpdates(&KST::matrixList.lock());
+ KstMatrixPtr m;
+ m = new KstMatrix(KstObjectTag(e.text(), tag()), this);
+ _outputMatrices.insert(e.attribute("name"), m);
} else if (e.tagName() == "minX") {
- setXMin(e.text().toDouble());
+ setXMin(e.text().toDouble());
} else if (e.tagName() == "maxX") {
- setXMax(e.text().toDouble());
+ setXMax(e.text().toDouble());
} else if (e.tagName() == "minY") {
- setYMin(e.text().toDouble());
+ setYMin(e.text().toDouble());
} else if (e.tagName() == "maxY") {
- setYMax(e.text().toDouble());
+ setYMax(e.text().toDouble());
} else if (e.tagName() == "nX") {
- setNX(e.text().toInt());
+ setNX(e.text().toInt());
} else if (e.tagName() == "nY") {
- setNY(e.text().toInt());
+ setNY(e.text().toInt());
} else if (e.tagName() == "autoBin") {
- setAutoBin(true);
+ setAutoBin(true);
}
}
n = n.nextSibling();
@@ -426,8 +436,12 @@
// use a very simple guess at nx and ny... One could imagine something more
// clever in principle.
*nx = *ny = (int)sqrt(x->length())/2;
- if (*nx<2) *nx = 2;
- if (*ny<2) *ny = 2;
+ if (*nx < 2) {
+ *nx = 2;
+ }
+ if (*ny < 2) {
+ *ny = 2;
+ }
*minx = x->min();
*maxx = x->max();
@@ -437,4 +451,3 @@
#include "binnedmap.moc"
-// vim: ts=2 sw=2 et
--- branches/work/kst/1.6/kst/src/plugins/binnedmap/binnedmap.h #763169:763170
@@ -80,7 +80,7 @@
//Pure virtual slots from KstDataObject
virtual void showNewDialog();
virtual void showEditDialog();
-
+
private:
double _xMin;
double _xMax;
--- branches/work/kst/1.6/kst/src/plugins/binnedmap/binnedmapdialog_i.cpp #763169:763170
@@ -62,8 +62,6 @@
connect(_w->_X, SIGNAL(newVectorCreated(const QString&)), this, SIGNAL(modified()));
connect(_w->_Y, SIGNAL(newVectorCreated(const QString&)), this, SIGNAL(modified()));
connect(_w->_Z, SIGNAL(newVectorCreated(const QString&)), this, SIGNAL(modified()));
- //connect(_w->_binnedMap, SIGNAL(newMatrixCreated()), this, SIGNAL(modified()));
- //connect(_w->_hitsMap, SIGNAL(newMatrixCreated()), this, SIGNAL(modified()));
connect(this, SIGNAL(modified()), _w->_X, SLOT(update()));
connect(this, SIGNAL(modified()), _w->_Y, SLOT(update()));
connect(this, SIGNAL(modified()), _w->_Z, SLOT(update()));
@@ -191,8 +189,7 @@
if (it != KST::vectorList.end()) {
map->setZ(*it);
}
-
- //xxxx
+
map->setXMin(_w->_Xmin->text().toDouble());
map->setXMax(_w->_Xmax->text().toDouble());
map->setYMin(_w->_Ymin->text().toDouble());
@@ -201,10 +198,8 @@
map->setNX(_w->_Xn->value());
map->setNY(_w->_Yn->value());
map->setAutoBin(_w->_realTimeAutoBin->isChecked());
-
}
- // FIXME: set the map properties
return true;
}
@@ -218,7 +213,7 @@
map->readLock();
_tagName->setText(map->tagName());
- _legendText->setText(defaultTag); //FIXME?
+ _legendText->setText(defaultTag);
_w->_X->setSelection(map->xTag());
_w->_Y->setSelection(map->yTag());
@@ -227,16 +222,6 @@
_w->_binnedMap->setText(map->mapTag());
_w->_hitsMap->setText(map->hitsMapTag());
-// _w->_real->setText(map->realTag());
-// _w->_real->setEnabled( false );
-//
-// _w->_imaginary->setText(map->imaginaryTag());
-// _w->_imaginary->setEnabled( false );
-//
-// _w->_frequency->setText(map->frequencyTag());
-// _w->_frequency->setEnabled(false);
-
- // xxxxx
_w->_Xmin->setText(QString::number(map->xMin()));
_w->_Xmax->setText(QString::number(map->xMax()));
_w->_Ymin->setText(QString::number(map->yMin()));
@@ -258,9 +243,6 @@
_tagName->setText(defaultTag);
_legendText->setText(defaultTag);
-// _w->_fft->_scalar->setCurrentText(QString::number(KST::objectDefaults.fftLen()));
-// _w->_sample->_scalar->setCurrentText(QString::number(KST::objectDefaults.psdFreq()));
-
adjustSize();
resize(minimumSizeHint());
setFixedHeight(height());
@@ -271,9 +253,9 @@
double minx, miny, maxx, maxy;
KstVectorPtr vx = *KST::vectorList.findTag(_w->_X->selectedVector());
KstVectorPtr vy = *KST::vectorList.findTag(_w->_Y->selectedVector());
-
+
BinnedMap::AutoSize(vx,vy, &nx, &minx, &maxx, &ny, &miny, &maxy);
-
+
_w->_Xmin->setText(QString::number(minx));
_w->_Xmax->setText(QString::number(maxx));
_w->_Ymin->setText(QString::number(miny));
@@ -284,5 +266,3 @@
}
#include "binnedmapdialog_i.moc"
-
-// vim: ts=2 sw=2 et
--- branches/work/kst/1.6/kst/src/plugins/binnedmap/binnedmapdialog_i.h #763169:763170
@@ -48,4 +48,3 @@
};
#endif
-// vim: ts=2 sw=2 et
More information about the Kst
mailing list