[Kst] branches/work/kst/portto4/kst/src
Mike Fenton
mike at staikos.net
Wed Oct 17 16:31:51 CEST 2007
SVN commit 726331 by fenton:
Add creation of generated matrix to MatrixDialog. Also added save of
generated matrix.
M +15 -16 libkst/generatedmatrix.cpp
M +1 -1 libkst/generatedmatrix.h
M +125 -4 libkstapp/matrixdialog.cpp
M +27 -0 libkstapp/matrixdialog.h
M +42 -2 libkstapp/matrixtab.ui
--- branches/work/kst/portto4/kst/src/libkst/generatedmatrix.cpp #726330:726331
@@ -13,6 +13,8 @@
#include "generatedmatrix.h"
#include <qtextstream.h>
#include <qtextdocument.h>
+#include <QXmlStreamWriter>
+#include <QVariant>
namespace Kst {
@@ -70,22 +72,19 @@
change(tag, nX, nY, minX, minY, stepX, stepY, gradZMin, gradZMax, xDirection);
}
-void GeneratedMatrix::save(QTextStream &ts, const QString& indent) {
-
- QString indent2 = " ";
-
- ts << indent << "<smatrix>" << endl;
- ts << indent << indent2 << "<tag>" << Qt::escape(tag().tagString()) << "</tag>" << endl;
- ts << indent << indent2 << "<xmin>" << minX() << "</xmin>" << endl;
- ts << indent << indent2 << "<ymin>" << minY() << "</ymin>" << endl;
- ts << indent << indent2 << "<nx>" << xNumSteps() << "</nx>" << endl;
- ts << indent << indent2 << "<ny>" << yNumSteps() << "</ny>" << endl;
- ts << indent << indent2 << "<xstep>" << xStepSize() << "</xstep>" << endl;
- ts << indent << indent2 << "<ystep>" << xStepSize() << "</ystep>" << endl;
- ts << indent << indent2 << "<gradzmin>" << _gradZMin << "</gradzmin>" << endl;
- ts << indent << indent2 << "<gradzmax>" << _gradZMax << "</gradzmax>" << endl;
- ts << indent << indent2 << "<xdirection>" << _xDirection << "</xdirection>" << endl;
- ts << indent << "</smatrix>" << endl;
+void GeneratedMatrix::save(QXmlStreamWriter &xml) {
+ xml.writeStartElement("generatedmatrix");
+ xml.writeAttribute("tag", tag().tagString());
+ xml.writeAttribute("xmin", QString::number(minX()));
+ xml.writeAttribute("ymin", QString::number(minY()));
+ xml.writeAttribute("nx", QString::number(xNumSteps()));
+ xml.writeAttribute("ny", QString::number(yNumSteps()));
+ xml.writeAttribute("xstep", QString::number(xStepSize()));
+ xml.writeAttribute("ystep", QString::number(yStepSize()));
+ xml.writeAttribute("gradzmin", QString::number(_gradZMin));
+ xml.writeAttribute("gradzmax", QString::number(_gradZMax));
+ xml.writeAttribute("xdirection", QVariant(_xDirection).toString());
+ xml.writeEndElement();
}
void GeneratedMatrix::change(ObjectTag tag, uint nX,
--- branches/work/kst/portto4/kst/src/libkst/generatedmatrix.h #726330:726331
@@ -25,7 +25,7 @@
double minX, double minY, double stepX, double stepY,
double gradZMin, double gradZMax, bool xDirection);
- virtual void save(QTextStream &ts, const QString& indent = QString::null);
+ virtual void save(QXmlStreamWriter &xml);
void change(ObjectTag tag, uint nX, uint nY,
double minX, double minY, double stepX, double stepY,
--- branches/work/kst/portto4/kst/src/libkstapp/matrixdialog.cpp #726330:726331
@@ -88,6 +88,97 @@
}
+uint MatrixTab::nX() const {
+ return _nX->text().toInt();
+}
+
+
+void MatrixTab::setNX(uint nX) {
+ _nX->setValue(nX);
+}
+
+
+uint MatrixTab::nY() const {
+ return _nY->text().toInt();
+}
+
+
+void MatrixTab::setNY(uint nY) {
+ _nY->setValue(nY);
+}
+
+
+double MatrixTab::minX() const {
+ return _minX->text().toDouble();
+}
+
+
+void MatrixTab::setMinX(double minX) {
+ _minX->setText(QString::number(minX));
+}
+
+
+double MatrixTab::minY() const {
+ return _minY->text().toDouble();
+}
+
+
+void MatrixTab::setMinY(double minY) {
+ _minY->setText(QString::number(minY));
+}
+
+
+double MatrixTab::stepX() const {
+ return _xStep->text().toDouble();
+}
+
+
+void MatrixTab::setStepX(double stepX) {
+ _xStep->setText(QString::number(stepX));
+}
+
+
+double MatrixTab::stepY() const {
+ return _yStep->text().toDouble();
+}
+
+
+void MatrixTab::setStepY(double stepY) {
+ _yStep->setText(QString::number(stepY));
+}
+
+
+double MatrixTab::gradientZAtMin() const {
+ return _gradientZAtMin->text().toDouble();
+}
+
+
+void MatrixTab::setGradientZAtMin(double gradientZAtMin) {
+ _gradientZAtMin->setText(QString::number(gradientZAtMin));
+}
+
+
+double MatrixTab::gradientZAtMax() const {
+ return _gradientZAtMax->text().toDouble();
+}
+
+
+void MatrixTab::setGradientZAtMax(double gradientZAtMax) {
+ _gradientZAtMax->setText(QString::number(gradientZAtMax));
+}
+
+
+bool MatrixTab::xDirection() const {
+ return _gradientX->isChecked();
+}
+
+
+void MatrixTab::setXDirection(bool xDirection) {
+ _gradientX->setChecked(xDirection);
+ _gradientY->setChecked(!xDirection);
+}
+
+
void MatrixTab::readFromSourceChanged() {
if (_readFromSource->isChecked())
@@ -166,8 +257,14 @@
ObjectPtr MatrixDialog::createNewDataObject() const {
- qDebug() << "createNewDataObject" << endl;
- return 0;
+ switch(_matrixTab->matrixMode()) {
+ case MatrixTab::DataMatrix:
+ return createNewDataMatrix();
+ case MatrixTab::GeneratedMatrix:
+ return createNewGeneratedMatrix();
+ default:
+ return 0;
+ }
}
@@ -178,8 +275,32 @@
ObjectPtr MatrixDialog::createNewGeneratedMatrix() const {
- qDebug() << "createNewGeneratedMatrix" << endl;
- return 0;
+ const uint nX = _matrixTab->nX();
+ const uint nY = _matrixTab->nY();
+ const double minX = _matrixTab->minX();
+ const double minY = _matrixTab->minY();
+ const double stepX = _matrixTab->stepX();
+ const double stepY = _matrixTab->stepY();
+ const double gradZMin = _matrixTab->gradientZAtMin();
+ const double gradZMax = _matrixTab->gradientZAtMax();
+ const bool xDirection = _matrixTab->xDirection();
+ const ObjectTag tag = ObjectTag(tagName(), ObjectTag::globalTagContext);
+
+// qDebug() << "Creating new generated matrix ===>"
+// << "\n\ttag:" << tag.tag()
+// << "\n\tnX:" << nX
+// << "\n\tnY:" << nY
+// << "\n\tminX:" << minX
+// << "\n\tminY:" << minY
+// << "\n\tstepX:" << stepX
+// << "\n\tstepY:" << stepY
+// << "\n\tgradZMin:" << gradZMin
+// << "\n\tgradZMax:" << gradZMax
+// << "\n\txDirection:" << xDirection
+// << endl;
+
+ GeneratedMatrixPtr matrix = new GeneratedMatrix(tag, nX, nY, minX, minY, stepX, stepY, gradZMin, gradZMax, xDirection);
+ return static_cast<ObjectPtr>(matrix);
}
--- branches/work/kst/portto4/kst/src/libkstapp/matrixdialog.h #726330:726331
@@ -48,6 +48,33 @@
void setFieldList(const QStringList &fieldList);
+ uint nX() const;
+ void setNX(uint nX);
+
+ uint nY() const;
+ void setNY(uint nY);
+
+ double minX() const;
+ void setMinX(double minX);
+
+ double minY() const;
+ void setMinY(double minY);
+
+ double stepX() const;
+ void setStepX(double stepX);
+
+ double stepY() const;
+ void setStepY(double stepY);
+
+ double gradientZAtMin() const;
+ void setGradientZAtMin(double gradientZAtMin);
+
+ double gradientZAtMax() const;
+ void setGradientZAtMax(double gradientZAtMax);
+
+ bool xDirection() const;
+ void setXDirection(bool xDirection);
+
private Q_SLOTS:
void readFromSourceChanged();
void fileNameChanged(const QString &file);
--- branches/work/kst/portto4/kst/src/libkstapp/matrixtab.ui #726330:726331
@@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>516</width>
- <height>591</height>
+ <height>623</height>
</rect>
</property>
<layout class="QGridLayout" >
@@ -131,6 +131,9 @@
<height>0</height>
</size>
</property>
+ <property name="text" >
+ <string>1</string>
+ </property>
</widget>
</item>
</layout>
@@ -201,6 +204,9 @@
<height>0</height>
</size>
</property>
+ <property name="text" >
+ <string>1</string>
+ </property>
</widget>
</item>
<item>
@@ -217,6 +223,9 @@
<height>0</height>
</size>
</property>
+ <property name="text" >
+ <string>1</string>
+ </property>
</widget>
</item>
</layout>
@@ -274,6 +283,9 @@
<property name="text" >
<string>X axis</string>
</property>
+ <property name="checked" >
+ <bool>true</bool>
+ </property>
</widget>
</item>
<item row="0" column="3" >
@@ -323,6 +335,9 @@
<property name="maximum" >
<number>999999999</number>
</property>
+ <property name="value" >
+ <number>100</number>
+ </property>
</widget>
</item>
<item row="1" column="3" >
@@ -330,6 +345,9 @@
<property name="maximum" >
<number>999999999</number>
</property>
+ <property name="value" >
+ <number>100</number>
+ </property>
</widget>
</item>
<item row="0" column="1" >
@@ -388,7 +406,11 @@
</widget>
</item>
<item row="0" column="3" >
- <widget class="QLineEdit" name="_gradientZAtMax" />
+ <widget class="QLineEdit" name="_gradientZAtMax" >
+ <property name="text" >
+ <string>100</string>
+ </property>
+ </widget>
</item>
</layout>
</item>
@@ -445,6 +467,9 @@
</item>
<item row="2" column="1" >
<widget class="QSpinBox" name="_xNumSteps" >
+ <property name="enabled" >
+ <bool>false</bool>
+ </property>
<property name="minimum" >
<number>1</number>
</property>
@@ -522,6 +547,9 @@
</item>
<item row="3" column="1" >
<widget class="QSpinBox" name="_yNumSteps" >
+ <property name="enabled" >
+ <bool>false</bool>
+ </property>
<property name="minimum" >
<number>1</number>
</property>
@@ -554,6 +582,9 @@
<property name="text" >
<string>Read to end</string>
</property>
+ <property name="checked" >
+ <bool>true</bool>
+ </property>
</widget>
</item>
<item row="1" column="2" >
@@ -605,6 +636,9 @@
<property name="text" >
<string>Read to end</string>
</property>
+ <property name="checked" >
+ <bool>true</bool>
+ </property>
</widget>
</item>
<item row="1" column="3" >
@@ -683,6 +717,9 @@
</property>
<item row="0" column="1" >
<widget class="QSpinBox" name="_skip" >
+ <property name="enabled" >
+ <bool>false</bool>
+ </property>
<property name="suffix" >
<string> frames</string>
</property>
@@ -696,6 +733,9 @@
</item>
<item row="0" column="2" >
<widget class="QCheckBox" name="_doAve" >
+ <property name="enabled" >
+ <bool>false</bool>
+ </property>
<property name="text" >
<string>Boxcar filter first</string>
</property>
More information about the Kst
mailing list