[Kst] branches/work/kst/portto4/kst/src
Mike Fenton
mike at staikos.net
Wed Oct 17 20:59:40 CEST 2007
SVN commit 726405 by fenton:
Update MatrixDialog to create DataMatrix's and setup GUI options to
interact the same as previous version.
M +16 -16 libkst/datamatrix.cpp
M +1 -1 libkst/datamatrix.h
M +205 -3 libkstapp/matrixdialog.cpp
M +39 -0 libkstapp/matrixdialog.h
M +6 -0 libkstapp/matrixtab.ui
--- branches/work/kst/portto4/kst/src/libkst/datamatrix.cpp #726404:726405
@@ -21,6 +21,7 @@
#include "datacollection.h"
#include "debug.h"
#include "datamatrix.h"
+#include <QXmlStreamWriter>
// xStart, yStart < 0 count from end
@@ -101,26 +102,25 @@
}
-void DataMatrix::save(QTextStream &ts, const QString& indent) {
+void DataMatrix::save(QXmlStreamWriter &xml) {
if (_file) {
+ xml.writeStartElement("datamatrix");
+ xml.writeAttribute("tag", tag().tagString());
- QString indent2 = " ";
-
- ts << indent << "<rmatrix>" << endl;
- ts << indent << indent2 << "<tag>" << Qt::escape(tag().tagString()) << "</tag>" << endl;
_file->readLock();
- ts << indent << indent2 << "<provider>" << Qt::escape(_file->tag().tagString()) << "</provider>" << endl;
- ts << indent << indent2 << "<file>" << Qt::escape(_file->fileName()) << "</file>" << endl;
+ xml.writeAttribute("provider", _file->tag().tagString());
+ xml.writeAttribute("file", _file->fileName());
_file->unlock();
- ts << indent << indent2 << "<field>" << _field << "</field>" << endl;
- ts << indent << indent2 << "<reqxstart>" << _reqXStart << "</reqxstart>" << endl;
- ts << indent << indent2 << "<reqystart>" << _reqYStart << "</reqystart>" << endl;
- ts << indent << indent2 << "<reqnx>" << _reqNX << "</reqnx>" << endl;
- ts << indent << indent2 << "<reqny>" << _reqNY << "</reqny>" << endl;
- ts << indent << indent2 << "<doave>" << _doAve << "</doave>" << endl;
- ts << indent << indent2 << "<doskip>" << _doSkip << "</doskip>" << endl;
- ts << indent << indent2 << "<skip>" << _skip << "</skip>" << endl;
- ts << indent << "</rmatrix>" << endl;
+
+ xml.writeAttribute("field", _field);
+ xml.writeAttribute("reqxstart", QString::number(_reqXStart));
+ xml.writeAttribute("reqystart", QString::number(_reqYStart));
+ xml.writeAttribute("reqnx", QString::number(_reqNX));
+ xml.writeAttribute("reqny", QString::number(_reqNY));
+ xml.writeAttribute("doave", QVariant(_doAve).toString());
+ xml.writeAttribute("doskip", QVariant(_doSkip).toString());
+ xml.writeAttribute("skip", QString::number(_skip));
+ xml.writeEndElement();
}
}
--- branches/work/kst/portto4/kst/src/libkst/datamatrix.h #726404:726405
@@ -34,7 +34,7 @@
DataMatrix(const QDomElement &e);
// save DataMatrix
- virtual void save(QTextStream &ts, const QString& indent = QString::null);
+ virtual void save(QXmlStreamWriter &xml);
virtual ~DataMatrix();
--- branches/work/kst/portto4/kst/src/libkstapp/matrixdialog.cpp #726404:726405
@@ -40,7 +40,16 @@
connect(_configure, SIGNAL(clicked()),
this, SLOT(showConfigWidget()));
- _fileName->setFile(QDir::currentPath());
+ connect(_xStartCountFromEnd, SIGNAL(clicked()), this, SLOT(xStartCountFromEndClicked()));
+ connect(_yStartCountFromEnd, SIGNAL(clicked()), this, SLOT(yStartCountFromEndClicked()));
+ connect(_xNumStepsReadToEnd, SIGNAL(clicked()), this, SLOT(xNumStepsReadToEndClicked()));
+ connect(_yNumStepsReadToEnd, SIGNAL(clicked()), this, SLOT(yNumStepsReadToEndClicked()));
+
+ connect(_readFromSource, SIGNAL(clicked()), this, SLOT(updateEnables()));
+ connect(_generateGradient, SIGNAL(clicked()), this, SLOT(updateEnables()));
+ connect(_doSkip, SIGNAL(clicked()), this, SLOT(updateEnables()));
+
+ _fileName->setFile(QDir::currentPath());
_fileName->setFile(matrixDefaults.dataSource());
//FIXME need a solution for replacing kio for this...
@@ -51,7 +60,51 @@
MatrixTab::~MatrixTab() {
}
+void MatrixTab::xStartCountFromEndClicked() {
+ _xNumStepsReadToEnd->setChecked(_xNumStepsReadToEnd->isChecked() && !_xStartCountFromEnd->isChecked());
+ _xStart->setEnabled(!_xStartCountFromEnd->isChecked());
+ _xNumSteps->setEnabled(!_xNumStepsReadToEnd->isChecked());
+}
+
+void MatrixTab::xNumStepsReadToEndClicked() {
+ _xStartCountFromEnd->setChecked(_xStartCountFromEnd->isChecked() && !_xNumStepsReadToEnd->isChecked());
+ _xNumSteps->setEnabled(!_xNumStepsReadToEnd->isChecked());
+ _xStart->setEnabled(!_xStartCountFromEnd->isChecked());
+}
+
+
+void MatrixTab::yStartCountFromEndClicked() {
+ _yNumStepsReadToEnd->setChecked(_yNumStepsReadToEnd->isChecked() && !_yStartCountFromEnd->isChecked());
+ _yStart->setEnabled(!_yStartCountFromEnd->isChecked());
+ _yNumSteps->setEnabled(!_yNumStepsReadToEnd->isChecked());
+}
+
+
+void MatrixTab::yNumStepsReadToEndClicked() {
+ _yStartCountFromEnd->setChecked(_yStartCountFromEnd->isChecked() && !_yNumStepsReadToEnd->isChecked());
+ _yNumSteps->setEnabled(!_yNumStepsReadToEnd->isChecked());
+ _yStart->setEnabled(!_yStartCountFromEnd->isChecked());
+}
+
+
+void MatrixTab::updateEnables() {
+ _dataSourceGroup->setEnabled(_readFromSource->isChecked());
+ _dataRangeGroup->setEnabled(_readFromSource->isChecked());
+ _gradientGroup->setEnabled(_generateGradient->isChecked());
+ _scalingGroup->setEnabled(_generateGradient->isChecked());
+
+ if (_dataRangeGroup->isEnabled()) {
+ _skip->setEnabled(_doSkip->isChecked());
+ _doAve->setEnabled(_doSkip->isChecked());
+ xStartCountFromEndClicked();
+ xNumStepsReadToEndClicked();
+ yStartCountFromEndClicked();
+ yNumStepsReadToEndClicked();
+ }
+}
+
+
DataSourcePtr MatrixTab::dataSource() const {
return _dataSource;
}
@@ -148,6 +201,56 @@
}
+int MatrixTab::xStart() const {
+ return _xStart->text().toInt();
+}
+
+
+void MatrixTab::setXStart(int xStart) {
+ _xStart->setValue(xStart);
+}
+
+
+int MatrixTab::yStart() const {
+ return _yStart->text().toInt();
+}
+
+
+void MatrixTab::setYStart(int yStart) {
+ _yStart->setValue(yStart);
+}
+
+
+int MatrixTab::xNumSteps() const {
+ return _xNumSteps->text().toInt();
+}
+
+
+void MatrixTab::setXNumSteps(int xNumSteps) {
+ _xNumSteps->setValue(xNumSteps);
+}
+
+
+int MatrixTab::yNumSteps() const {
+ return _yNumSteps->text().toInt();
+}
+
+
+void MatrixTab::setYNumSteps(int yNumSteps) {
+ _yNumSteps->setValue(yNumSteps);
+}
+
+
+int MatrixTab::skip() const {
+ return _skip->text().toInt();
+}
+
+
+void MatrixTab::setSkip(int skip) {
+ _skip ->setValue(skip);
+}
+
+
double MatrixTab::gradientZAtMin() const {
return _gradientZAtMin->text().toDouble();
}
@@ -179,6 +282,65 @@
}
+bool MatrixTab::doAve() const {
+ return _doAve->isChecked();
+}
+
+
+void MatrixTab::setDoAve(bool doAve) {
+ _doAve->setChecked(doAve);
+}
+
+
+bool MatrixTab::doSkip() const {
+ return _doSkip->isChecked();
+}
+
+
+void MatrixTab::setDoSkip(bool doSkip) {
+ _doSkip->setChecked(doSkip);
+}
+
+
+bool MatrixTab::xStartCountFromEnd() const {
+ return _xStartCountFromEnd->isChecked();
+}
+
+
+void MatrixTab::setXStartCountFromEnd(bool xStartCountFromEnd) {
+ _xStartCountFromEnd->setChecked(xStartCountFromEnd);
+}
+
+
+bool MatrixTab::yStartCountFromEnd() const {
+ return _yStartCountFromEnd->isChecked();
+}
+
+
+void MatrixTab::setYStartCountFromEnd(bool yStartCountFromEnd) {
+ _yStartCountFromEnd->setChecked(yStartCountFromEnd);
+}
+
+
+bool MatrixTab::xReadToEnd() const {
+ return _xNumStepsReadToEnd->isChecked();
+}
+
+
+void MatrixTab::setXReadToEnd(bool xReadToEnd) {
+ _xNumStepsReadToEnd->setChecked(xReadToEnd);
+}
+
+
+bool MatrixTab::yReadToEnd() const {
+ return _yNumStepsReadToEnd->isChecked();
+}
+
+
+void MatrixTab::setYReadToEnd(bool yReadToEnd) {
+ _yNumStepsReadToEnd->setChecked(yReadToEnd);
+}
+
void MatrixTab::readFromSourceChanged() {
if (_readFromSource->isChecked())
@@ -269,8 +431,48 @@
ObjectPtr MatrixDialog::createNewDataMatrix() const {
- qDebug() << "createNewDataMatrix" << endl;
- return 0;
+ const DataSourcePtr dataSource = _matrixTab->dataSource();
+
+ //FIXME better validation than this please...
+ if (!dataSource)
+ return 0;
+
+ const QString field = _matrixTab->field();
+ const ObjectTag tag = ObjectTag(tagName(), dataSource->tag(), false);
+ const int skip = _matrixTab->skip();
+ const bool doAve = _matrixTab->doAve();
+ const bool doSkip = _matrixTab->doSkip();
+ const int xStart = _matrixTab->xStartCountFromEnd() ? -1 : _matrixTab->xStart();
+ const int yStart = _matrixTab->yStartCountFromEnd() ? -1 : _matrixTab->yStart();
+ const int xNumSteps = _matrixTab->xReadToEnd() ? -1 : _matrixTab->xNumSteps();
+ const int yNumSteps = _matrixTab->yReadToEnd() ? -1 : _matrixTab->yNumSteps();
+
+// qDebug() << "Creating new data matrix ===>"
+// << "\n\tfileName:" << dataSource->fileName()
+// << "\n\tfileType:" << dataSource->fileType()
+// << "\n\tfield:" << field
+// << "\n\ttag:" << tag.tag()
+// << "\n\txStart:" << xStart
+// << "\n\tyStart:" << yStart
+// << "\n\txNumSteps:" << xNumSteps
+// << "\n\tyNumSteps:" << yNumSteps
+// << "\n\tskip:" << skip
+// << "\n\tdoSkip:" << doSkip
+// << "\n\tdoAve:" << doAve
+// << endl;
+
+ DataMatrixPtr matrix = new DataMatrix(
+ dataSource, field, tag,
+ xStart, yStart,
+ xNumSteps, yNumSteps,
+ doAve,
+ doSkip, skip);
+
+ matrix->writeLock();
+ matrix->update(0);
+ matrix->unlock();
+
+ return static_cast<ObjectPtr>(matrix);
}
--- branches/work/kst/portto4/kst/src/libkstapp/matrixdialog.h #726404:726405
@@ -66,6 +66,18 @@
double stepY() const;
void setStepY(double stepY);
+ int xStart() const;
+ void setXStart(int xStart);
+
+ int yStart() const;
+ void setYStart(int yStart);
+
+ int xNumSteps() const;
+ void setXNumSteps(int xNumSteps);
+
+ int yNumSteps() const;
+ void setYNumSteps(int yNumSteps);
+
double gradientZAtMin() const;
void setGradientZAtMin(double gradientZAtMin);
@@ -75,11 +87,38 @@
bool xDirection() const;
void setXDirection(bool xDirection);
+ bool doAve() const;
+ void setDoAve(bool doAve);
+
+ bool doSkip() const;
+ void setDoSkip(bool doSkip);
+
+ int skip() const;
+ void setSkip(int skip);
+
+ bool xStartCountFromEnd() const;
+ void setXStartCountFromEnd(bool xStartCountFromEnd);
+
+ bool yStartCountFromEnd() const;
+ void setYStartCountFromEnd(bool yStartCountFromEnd);
+
+ bool xReadToEnd() const;
+ void setXReadToEnd(bool xReadToEnd);
+
+ bool yReadToEnd() const;
+ void setYReadToEnd(bool yReadToEnd);
+
private Q_SLOTS:
void readFromSourceChanged();
void fileNameChanged(const QString &file);
void showConfigWidget();
+ void updateEnables();
+ void xStartCountFromEndClicked();
+ void xNumStepsReadToEndClicked();
+ void yStartCountFromEndClicked();
+ void yNumStepsReadToEndClicked();
+
private:
MatrixMode _mode;
DataSourcePtr _dataSource;
--- branches/work/kst/portto4/kst/src/libkstapp/matrixtab.ui #726404:726405
@@ -868,6 +868,9 @@
</item>
<item row="1" column="1" >
<widget class="Kst::ComboBox" name="_field" >
+ <property name="enabled" >
+ <bool>false</bool>
+ </property>
<property name="editable" >
<bool>true</bool>
</property>
@@ -915,6 +918,9 @@
</item>
<item>
<widget class="QPushButton" name="_configure" >
+ <property name="enabled" >
+ <bool>false</bool>
+ </property>
<property name="text" >
<string>Con&figure...</string>
</property>
More information about the Kst
mailing list