[Kst] branches/work/kst/portto4/kst/src/libkstapp
Mike Fenton
mike at staikos.net
Thu Nov 22 20:14:11 CET 2007
SVN commit 740187 by fenton:
Add functionality to the DifferentiateCurvesDialog.
M +62 -26 differentiatecurvesdialog.cpp
M +9 -0 differentiatecurvesdialog.h
M +3 -91 differentiatecurvesdialog.ui
--- branches/work/kst/portto4/kst/src/libkstapp/differentiatecurvesdialog.cpp #740186:740187
@@ -11,13 +11,26 @@
#include "differentiatecurvesdialog.h"
#include "linestyle.h"
+#include "curve.h"
+#include "colorsequence.h"
+#include "objectstore.h"
+#include "mainwindow.h"
+#include "document.h"
+
namespace Kst {
DifferentiateCurvesDialog::DifferentiateCurvesDialog(QWidget *parent)
: QDialog(parent) {
setupUi(this);
+ if (MainWindow *mw = qobject_cast<MainWindow*>(parent)) {
+ _store = mw->document()->objectStore();
+ } else {
+ // FIXME: we need the object store
+ qFatal("ERROR: can't construct a ChangeDataSampleDialog without the object store");
+ }
+
_availableListBox->clear();
_selectedListBox->clear();
_availableListBox->addItem(tr("Line Color"));
@@ -26,28 +39,24 @@
_availableListBox->addItem(tr("Line Width"));
connect(Cancel, SIGNAL(clicked()), this, SLOT(close()));
- connect(OK, SIGNAL(clicked()), this, SLOT(close()));
+ connect(OK, SIGNAL(clicked()), this, SLOT(OKClicked()));
connect(_add, SIGNAL(clicked()), this, SLOT(addButtonClicked()));
connect(_remove, SIGNAL(clicked()), this, SLOT(removeButtonClicked()));
connect(_up, SIGNAL(clicked()), this, SLOT(upButtonClicked()));
connect(_down, SIGNAL(clicked()), this, SLOT(downButtonClicked()));
- connect(_availableListBox, SIGNAL(currentRowChanged(int)), this, SLOT(updateButtons()));
- connect(_selectedListBox, SIGNAL(currentRowChanged(int)), this, SLOT(updateButtons()));
+ connect(_availableListBox, SIGNAL(itemSelectionChanged()), this, SLOT(updateButtons()));
+ connect(_selectedListBox, SIGNAL(itemSelectionChanged()), this, SLOT(updateButtons()));
// TODO Icons required.
// _up->setIcon(QPixmap(":kst_uparrow.png"));
_up->setText("Up");
- _up->setEnabled(false);
// _down->setIcon(QPixmap(":kst_downarrow.png"));
_down->setText("Down");
- _down->setEnabled(false);
// _add->setIcon(QPixmap(":kst_rightarrow.png"));
_add->setText("Add");
- _add->setEnabled(false);
// _remove->setIcon(QPixmap(":kst_leftarrow.png"));
_remove->setText("Remove");
- _remove->setEnabled(false);
_maxLineWidth->setMaximum(LINEWIDTH_MAX);
@@ -58,6 +67,12 @@
}
+void DifferentiateCurvesDialog::exec() {
+ updateButtons();
+ QDialog::exec();
+}
+
+
void DifferentiateCurvesDialog::updateButtons() {
QList<QListWidgetItem *> selectedItems = _selectedListBox->selectedItems();
@@ -66,29 +81,12 @@
if (selectedItems.count() > 0)
selectedItem = selectedItems.first();
- if (selectedItem) {
- _remove->setEnabled(true);
- } else {
- _remove->setEnabled(false);
- }
+ _remove->setEnabled(selectedItems.count() > 0);
_up->setEnabled(_selectedListBox->row(selectedItem) > 0);
_down->setEnabled(_selectedListBox->row(selectedItem) >= 0 && _selectedListBox->row(selectedItem) < (int)_selectedListBox->count() - 1);
-
- selectedItems = _availableListBox->selectedItems();
- selectedItem = 0;
-
- if (selectedItems.count() > 0) {
- selectedItem = selectedItems.first();
- }
-
- if (selectedItem) {
- _add->setEnabled(true);
- } else {
- _add->setEnabled(false);
- }
-
+ _add->setEnabled(_availableListBox->selectedItems().count() > 0);
}
@@ -140,6 +138,44 @@
}
}
+
+void DifferentiateCurvesDialog::OKClicked() {
+ bool lineColorOrder = !_selectedListBox->findItems(tr("Line Color"), Qt::MatchExactly).empty();
+ bool pointStyleOrder = !_selectedListBox->findItems(tr("Point Style"), Qt::MatchExactly).empty();
+ bool lineStyleOrder = !_selectedListBox->findItems(tr("Line Style"), Qt::MatchExactly).empty();
+ bool lineWidthOrder = !_selectedListBox->findItems(tr("Line Width"), Qt::MatchExactly).empty();
+
+ int maxLineWidth = _maxLineWidth->value();
+ int pointDensity = _pointDensity->currentItem();
+
+ int sequenceNum = 0;
+ CurveList curveList = _store->getObjects<Curve>();
+ for (CurveList::iterator curve_iter = curveList.begin(); curve_iter != curveList.end(); ++curve_iter)
+ {
+ CurvePtr curve = kst_cast<Curve>(*curve_iter);
+ curve->writeLock();
+ if (lineColorOrder) {
+ curve->setColor(ColorSequence::entry(sequenceNum));
+ }
+ if (pointStyleOrder) {
+ curve->setPointType(sequenceNum % KSTPOINT_MAXTYPE);
+ curve->setHasPoints(true);
+ curve->setPointDensity(pointDensity);
+ }
+ if (lineStyleOrder) {
+ curve->setLineStyle(sequenceNum % LINESTYLE_MAXTYPE);
+ }
+ if (lineWidthOrder) {
+ curve->setLineWidth((sequenceNum + 1) % maxLineWidth);
+ }
+
+ curve->update(0);
+ curve->unlock();
+ ++sequenceNum;
+ }
+ accept();
}
+}
+
// vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/differentiatecurvesdialog.h #740186:740187
@@ -20,6 +20,8 @@
namespace Kst {
+class ObjectStore;
+
class KST_EXPORT DifferentiateCurvesDialog : public QDialog, Ui::DifferentiateCurvesDialog
{
Q_OBJECT
@@ -27,12 +29,19 @@
DifferentiateCurvesDialog(QWidget *parent);
virtual ~DifferentiateCurvesDialog();
+ void exec();
+
private slots:
void updateButtons();
void addButtonClicked();
void removeButtonClicked();
void upButtonClicked();
void downButtonClicked();
+ void OKClicked();
+
+ private:
+ ObjectStore *_store;
+
};
}
--- branches/work/kst/portto4/kst/src/libkstapp/differentiatecurvesdialog.ui #740186:740187
@@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>527</width>
- <height>524</height>
+ <width>507</width>
+ <height>401</height>
</rect>
</property>
<property name="windowTitle" >
@@ -302,7 +302,7 @@
</widget>
</item>
<item row="0" column="1" >
- <widget class="QComboBox" name="pointDensity" >
+ <widget class="QComboBox" name="_pointDensity" >
<item>
<property name="text" >
<string>All</string>
@@ -347,89 +347,6 @@
</widget>
</item>
<item>
- <widget class="QGroupBox" name="_buttonGroupRepeat" >
- <property name="title" >
- <string>Repeat Across</string>
- </property>
- <layout class="QHBoxLayout" >
- <property name="leftMargin" >
- <number>0</number>
- </property>
- <property name="topMargin" >
- <number>0</number>
- </property>
- <property name="rightMargin" >
- <number>0</number>
- </property>
- <property name="bottomMargin" >
- <number>0</number>
- </property>
- <item>
- <widget class="QRadioButton" name="_radioButtonRepeatPlot" >
- <property name="text" >
- <string>S&ingle Plot</string>
- </property>
- <property name="checked" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="_radioButtonRepeatWindow" >
- <property name="text" >
- <string>Single &Window</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="_radioButtonRepeatApplication" >
- <property name="text" >
- <string>&All Windows</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="_buttonGroupApplyTo" >
- <property name="title" >
- <string>Apply To</string>
- </property>
- <layout class="QGridLayout" >
- <property name="leftMargin" >
- <number>0</number>
- </property>
- <property name="topMargin" >
- <number>0</number>
- </property>
- <property name="rightMargin" >
- <number>0</number>
- </property>
- <property name="bottomMargin" >
- <number>0</number>
- </property>
- <item row="0" column="0" >
- <widget class="QRadioButton" name="_radioButtonApplyWindow" >
- <property name="text" >
- <string>Current Window</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1" >
- <widget class="QRadioButton" name="_radioButtonApplyAllWindows" >
- <property name="text" >
- <string>All Windows</string>
- </property>
- <property name="checked" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>0</number>
@@ -480,11 +397,6 @@
<layoutdefault spacing="6" margin="11" />
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<tabstops>
- <tabstop>_radioButtonRepeatPlot</tabstop>
- <tabstop>_radioButtonRepeatWindow</tabstop>
- <tabstop>_radioButtonRepeatApplication</tabstop>
- <tabstop>_radioButtonApplyWindow</tabstop>
- <tabstop>_radioButtonApplyAllWindows</tabstop>
<tabstop>OK</tabstop>
<tabstop>Cancel</tabstop>
</tabstops>
More information about the Kst
mailing list