[Kst] branches/work/kst/portto4/kst/src
Mike Fenton
mike at staikos.net
Tue Dec 11 19:13:11 CET 2007
SVN commit 747322 by fenton:
Add Apply Button and EditMultiple support to ImageDialog.
M +182 -25 libkstapp/imagedialog.cpp
M +18 -0 libkstapp/imagedialog.h
M +15 -0 widgets/colorpalette.cpp
M +3 -0 widgets/colorpalette.h
M +10 -0 widgets/matrixselector.cpp
M +3 -0 widgets/matrixselector.h
--- branches/work/kst/portto4/kst/src/libkstapp/imagedialog.cpp #747321:747322
@@ -12,6 +12,7 @@
#include "imagedialog.h"
#include "dialogpage.h"
+#include "editmultiplewidget.h"
#include "view.h"
#include "plotitem.h"
@@ -32,7 +33,7 @@
namespace Kst {
ImageTab::ImageTab(QWidget *parent)
- : DataTab(parent) {
+ : DataTab(parent), _modeDirty(false) {
setupUi(this);
setTabTitle(tr("Image"));
@@ -60,6 +61,10 @@
connect(_useVariableWeight, SIGNAL(clicked()), this, SIGNAL(modified()));
connect(_colorPalette, SIGNAL(selectionChanged()), this, SIGNAL(modified()));
+
+ connect(_colorOnly, SIGNAL(clicked()), this, SLOT(modeChanged()));
+ connect(_contourOnly, SIGNAL(clicked()), this, SLOT(modeChanged()));
+ connect(_colorAndContour, SIGNAL(clicked()), this, SLOT(modeChanged()));
}
@@ -74,6 +79,16 @@
}
+void ImageTab::modeChanged() {
+ _modeDirty = true;
+}
+
+
+void ImageTab::resetModeDirty() {
+ _modeDirty = false;
+}
+
+
CurvePlacement* ImageTab::curvePlacement() const {
return _curvePlacement;
}
@@ -89,6 +104,11 @@
}
+bool ImageTab::realTimeAutoThresholdDirty() const {
+ return _realTimeAutoThreshold->checkState() != Qt::PartiallyChecked;
+}
+
+
void ImageTab::setRealTimeAutoThreshold(const bool realTimeAutoThreshold) {
_realTimeAutoThreshold->setChecked(realTimeAutoThreshold);
}
@@ -101,6 +121,7 @@
void ImageTab::setColorOnly(const bool colorOnly) {
_colorOnly->setChecked(colorOnly);
+ resetModeDirty();
}
@@ -111,6 +132,7 @@
void ImageTab::setContourOnly(const bool contourOnly) {
_contourOnly->setChecked(contourOnly);
+ resetModeDirty();
}
@@ -121,14 +143,25 @@
void ImageTab::setColorAndContour(const bool colorAndContour) {
_colorAndContour->setChecked(colorAndContour);
+ resetModeDirty();
}
+bool ImageTab::modeDirty() const {
+ return _modeDirty;
+}
+
+
bool ImageTab::useVariableLineWeight() const {
return _useVariableWeight->isChecked();
}
+bool ImageTab::useVariableLineWeightDirty() const {
+ return _useVariableWeight->checkState() != Qt::PartiallyChecked;
+}
+
+
void ImageTab::setUseVariableLineWeight(const bool useVariableLineWeight) {
_useVariableWeight->setChecked(useVariableLineWeight);
}
@@ -139,6 +172,11 @@
}
+bool ImageTab::matrixDirty() const {
+ return _matrix->selectedMatrixDirty();
+}
+
+
void ImageTab::setMatrix(const MatrixPtr matrix) {
_matrix->setSelectedMatrix(matrix);
}
@@ -149,6 +187,11 @@
}
+bool ImageTab::lowerThresholdDirty() const {
+ return !_lowerThreshold->text().isEmpty();
+}
+
+
void ImageTab::setLowerThreshold(const double lowerThreshold) {
_lowerThreshold->setText(QString::number(lowerThreshold));
}
@@ -159,6 +202,11 @@
}
+bool ImageTab::upperThresholdDirty() const {
+ return !_upperThreshold->text().isEmpty();
+}
+
+
void ImageTab::setUpperThreshold(const double upperThreshold) {
_upperThreshold->setText(QString::number(upperThreshold));
}
@@ -169,6 +217,11 @@
}
+bool ImageTab::numberOfContourLinesDirty() const {
+ return !_numContourLines->text().isEmpty();
+}
+
+
void ImageTab::setNumberOfContourLines(const int numberOfContourLines) {
_numContourLines->setValue(numberOfContourLines);
}
@@ -179,6 +232,11 @@
}
+bool ImageTab::contourWeightDirty() const {
+ return !_contourWeight->text().isEmpty();
+}
+
+
void ImageTab::setContourWeight(const int contourWeight) {
_contourWeight->setValue(contourWeight);
}
@@ -189,6 +247,11 @@
}
+bool ImageTab::contourColorDirty() const {
+ return !_contourColor->colorDirty();
+}
+
+
void ImageTab::setContourColor(const QColor contourColor) {
_contourColor->setColor(contourColor);
}
@@ -247,6 +310,21 @@
}
+void ImageTab::clearTabValues() {
+ _matrix->clearSelection();
+ _lowerThreshold->clear();
+ _upperThreshold->clear();
+ _numContourLines->clear();
+ _contourWeight->clear();
+ _contourColor->clearSelection();
+ _colorPalette->clearSelection();
+ _realTimeAutoThreshold->setCheckState(Qt::PartiallyChecked);
+ _useVariableWeight->setCheckState(Qt::PartiallyChecked);
+ _colorOnly->setChecked(true);
+ resetModeDirty();
+}
+
+
ImageDialog::ImageDialog(ObjectPtr dataObject, QWidget *parent)
: DataDialog(dataObject, parent) {
@@ -263,6 +341,9 @@
}
connect(_imageTab, SIGNAL(optionsChanged()), this, SLOT(updateButtons()));
+ connect(this, SIGNAL(editMultipleMode()), this, SLOT(editMultipleMode()));
+ connect(this, SIGNAL(editSingleMode()), this, SLOT(editSingleMode()));
+ connect(_imageTab, SIGNAL(modified()), this, SLOT(modified()));
updateButtons();
}
@@ -276,8 +357,18 @@
}
+void ImageDialog::editMultipleMode() {
+ _imageTab->clearTabValues();
+}
+
+
+void ImageDialog::editSingleMode() {
+ configureTab(dataObject());
+}
+
+
void ImageDialog::updateButtons() {
- _buttonBox->button(QDialogButtonBox::Ok)->setEnabled(_imageTab->matrix());
+ _buttonBox->button(QDialogButtonBox::Ok)->setEnabled(_imageTab->matrix() || (editMode() == EditMultiple));
}
@@ -316,6 +407,14 @@
}
_imageTab->hidePlacementOptions();
+ if (_editMultipleWidget) {
+ QStringList objectList;
+ ImageList objects = _document->objectStore()->getObjects<Image>();
+ foreach(ImagePtr object, objects) {
+ objectList.append(object->tag().displayString());
+ }
+ _editMultipleWidget->addObjects(objectList);
+ }
}
}
@@ -386,31 +485,89 @@
ObjectPtr ImageDialog::editExistingDataObject() const {
if (ImagePtr image = kst_cast<Image>(dataObject())) {
- image->writeLock();
- if (_imageTab->colorOnly()) {
- image->changeToColorOnly(_imageTab->matrix(),
- _imageTab->lowerThreshold(),
- _imageTab->upperThreshold(),
- _imageTab->realTimeAutoThreshold(),
- _imageTab->colorPalette()->selectedPalette());
- } else if (_imageTab->contourOnly()) {
- image->changeToContourOnly(_imageTab->matrix(),
- _imageTab->numberOfContourLines(),
- _imageTab->contourColor(),
- _imageTab->useVariableLineWeight() ? -1 : _imageTab->contourWeight());
+ if (editMode() == EditMultiple) {
+ QStringList objects = _editMultipleWidget->selectedObjects();
+ foreach (QString objectTag, objects) {
+ ImagePtr image = kst_cast<Image>(_document->objectStore()->retrieveObject(ObjectTag::fromString(objectTag)));
+ if (image) {
+ MatrixPtr matrix = _imageTab->matrixDirty() ? _imageTab->matrix() : image->matrix();
+ const double lowerThreshold = _imageTab->lowerThresholdDirty() ? _imageTab->lowerThreshold() : image->lowerThreshold();
+ const double upperThreshold = _imageTab->upperThresholdDirty() ? _imageTab->upperThreshold() : image->upperThreshold();
+
+ const bool realTimeAutoThreshold = _imageTab->realTimeAutoThresholdDirty() ? _imageTab->realTimeAutoThreshold() : image->autoThreshold();
+ const bool useVariableLineWeight = _imageTab->useVariableLineWeightDirty() ? _imageTab->useVariableLineWeight() : (image->contourWeight() == -1);
+
+ const QString colorPalette = _imageTab->colorPalette()->selectedPaletteDirty() ? _imageTab->colorPalette()->selectedPalette() : image->paletteName();
+
+ const int numberOfContourLines = _imageTab->numberOfContourLinesDirty() ? _imageTab->numberOfContourLines() : image->numContourLines();
+ const int contourWeight = _imageTab->contourWeightDirty() ? _imageTab->contourWeight() : image->contourWeight();
+
+ const QColor color = _imageTab->contourColorDirty() ? _imageTab->contourColor() : image->contourColor();
+
+ bool colorMap;
+ bool contourMap;
+ if (_imageTab->modeDirty()) {
+ colorMap = _imageTab->colorOnly() || _imageTab->colorAndContour();
+ contourMap = _imageTab->contourOnly() || _imageTab->colorAndContour();
+ } else {
+ colorMap = image->hasColorMap();
+ contourMap = image->hasContourMap();
+ }
+
+ image->writeLock();
+ if (colorMap && contourMap) {
+ image->changeToColorAndContour(matrix,
+ lowerThreshold,
+ upperThreshold,
+ realTimeAutoThreshold,
+ colorPalette,
+ numberOfContourLines,
+ color,
+ useVariableLineWeight ? -1 : contourWeight);
+ } else if (colorMap) {
+ image->changeToColorOnly(matrix,
+ lowerThreshold,
+ upperThreshold,
+ realTimeAutoThreshold,
+ colorPalette);
+ } else {
+ image->changeToContourOnly(matrix,
+ numberOfContourLines,
+ color,
+ useVariableLineWeight ? -1 : contourWeight);
+ }
+
+ image->update(0);
+ image->unlock();
+ }
+ }
} else {
- image->changeToColorAndContour(_imageTab->matrix(),
- _imageTab->lowerThreshold(),
- _imageTab->upperThreshold(),
- _imageTab->realTimeAutoThreshold(),
- _imageTab->colorPalette()->selectedPalette(),
- _imageTab->numberOfContourLines(),
- _imageTab->contourColor(),
- _imageTab->useVariableLineWeight() ? -1 : _imageTab->contourWeight());
+ image->writeLock();
+ if (_imageTab->colorOnly()) {
+ image->changeToColorOnly(_imageTab->matrix(),
+ _imageTab->lowerThreshold(),
+ _imageTab->upperThreshold(),
+ _imageTab->realTimeAutoThreshold(),
+ _imageTab->colorPalette()->selectedPalette());
+ } else if (_imageTab->contourOnly()) {
+ image->changeToContourOnly(_imageTab->matrix(),
+ _imageTab->numberOfContourLines(),
+ _imageTab->contourColor(),
+ _imageTab->useVariableLineWeight() ? -1 : _imageTab->contourWeight());
+ } else {
+ image->changeToColorAndContour(_imageTab->matrix(),
+ _imageTab->lowerThreshold(),
+ _imageTab->upperThreshold(),
+ _imageTab->realTimeAutoThreshold(),
+ _imageTab->colorPalette()->selectedPalette(),
+ _imageTab->numberOfContourLines(),
+ _imageTab->contourColor(),
+ _imageTab->useVariableLineWeight() ? -1 : _imageTab->contourWeight());
+ }
+
+ image->update(0);
+ image->unlock();
}
-
- image->update(0);
- image->unlock();
}
return dataObject();
}
--- branches/work/kst/portto4/kst/src/libkstapp/imagedialog.h #747321:747322
@@ -39,6 +39,7 @@
void setObjectStore(ObjectStore *store);
bool realTimeAutoThreshold() const;
+ bool realTimeAutoThresholdDirty() const;
void setRealTimeAutoThreshold(const bool realTimeAutoThreshold);
bool colorOnly() const;
@@ -50,41 +51,56 @@
bool colorAndContour() const;
void setColorAndContour(const bool colorAndContour);
+ bool modeDirty() const;
+
double lowerThreshold() const;
+ bool lowerThresholdDirty() const;
void setLowerThreshold(const double lowerThreshold);
double upperThreshold() const;
+ bool upperThresholdDirty() const;
void setUpperThreshold(const double upperThreshold);
int numberOfContourLines() const;
+ bool numberOfContourLinesDirty() const;
void setNumberOfContourLines(const int numberOfContourLines);
int contourWeight() const;
+ bool contourWeightDirty() const;
void setContourWeight(const int contourWeight);
QColor contourColor() const;
+ bool contourColorDirty() const;
void setContourColor(const QColor contourColor);
MatrixPtr matrix() const;
+ bool matrixDirty() const;
void setMatrix(const MatrixPtr matrix);
bool useVariableLineWeight() const;
+ bool useVariableLineWeightDirty() const;
void setUseVariableLineWeight(const bool useVariableLineWeight);
void hidePlacementOptions();
+ void clearTabValues();
+ void resetModeDirty();
+
private Q_SLOTS:
void realTimeAutoThresholdToggled(const bool checked);
void updateEnabled(const bool checked);
void selectionChanged();
void calculateAutoThreshold();
void calculateSmartThreshold();
+ void modeChanged();
Q_SIGNALS:
void optionsChanged();
private:
ObjectStore* _store;
+
+ bool _modeDirty;
};
class KST_EXPORT ImageDialog : public DataDialog {
@@ -102,6 +118,8 @@
private Q_SLOTS:
void updateButtons();
+ void editMultipleMode();
+ void editSingleMode();
private:
void configureTab(ObjectPtr object);
--- branches/work/kst/portto4/kst/src/widgets/colorpalette.cpp #747321:747322
@@ -81,6 +81,21 @@
}
+bool ColorPalette::selectedPaletteDirty() const {
+ return _palette->currentIndex() != -1;
+}
+
+
+void ColorPalette::clearSelection() {
+ _palette->setCurrentIndex(-1);
+
+ QPixmap pix(7 *_palette->height(), _palette->height());
+ QPainter p(&pix);
+ p.fillRect(p.window(), QColor("white"));
+ _paletteDisplay->setPixmap(pix);
+}
+
+
void ColorPalette::refresh( const QString & palette ) {
_palette->clear();
--- branches/work/kst/portto4/kst/src/widgets/colorpalette.h #747321:747322
@@ -27,10 +27,13 @@
~ColorPalette();
QString selectedPalette();
+ bool selectedPaletteDirty() const;
void refresh(const QString &palette = QString());
int currentPaletteIndex();
void setPalette(const QString palette);
+ void clearSelection();
+
public slots:
void updatePalette(const QString &palette = QString());
--- branches/work/kst/portto4/kst/src/widgets/matrixselector.cpp #747321:747322
@@ -55,6 +55,11 @@
}
+bool MatrixSelector::selectedMatrixDirty() const {
+ return _matrix->currentIndex() != -1;
+}
+
+
void MatrixSelector::matrixSelected(int index) {
Q_UNUSED(index)
if (index != -1)
@@ -81,6 +86,11 @@
}
+void MatrixSelector::clearSelection() {
+ _matrix->setCurrentIndex(-1);
+}
+
+
void MatrixSelector::updateMatrices() {
fillMatrices();;
}
--- branches/work/kst/portto4/kst/src/widgets/matrixselector.h #747321:747322
@@ -32,8 +32,11 @@
void setObjectStore(ObjectStore *store);
MatrixPtr selectedMatrix() const;
+ bool selectedMatrixDirty() const;
void setSelectedMatrix(MatrixPtr selectedMatrix);
+ void clearSelection();
+
Q_SIGNALS:
void selectionChanged();
More information about the Kst
mailing list