File indexing completed on 2024-12-22 04:17:47
0001 /*************************************************************************** 0002 * * 0003 * copyright : (C) 2007 The University of Toronto * 0004 * netterfield@astro.utoronto.ca * 0005 * * 0006 * This program is free software; you can redistribute it and/or modify * 0007 * it under the terms of the GNU General Public License as published by * 0008 * the Free Software Foundation; either version 2 of the License, or * 0009 * (at your option) any later version. * 0010 * * 0011 ***************************************************************************/ 0012 #include "vectordialog.h" 0013 0014 #include "application.h" 0015 #include "dialogpage.h" 0016 #include "datasourceconfiguredialog.h" 0017 #include "editmultiplewidget.h" 0018 0019 #include "datavector.h" 0020 #include "generatedvector.h" 0021 0022 #include "datacollection.h" 0023 #include "document.h" 0024 #include "objectstore.h" 0025 #include "datasourcepluginmanager.h" 0026 #include "dialogdefaults.h" 0027 #include "debug.h" 0028 0029 #include <QDir> 0030 #include <QThreadPool> 0031 0032 namespace Kst { 0033 0034 VectorTab::VectorTab(ObjectStore *store, QWidget *parent) 0035 : DataTab(parent), validating(false), _mode(DataVector), _store(store), _initField(QString()), _requestID(0), _valid(false) { 0036 0037 setupUi(this); 0038 setTabTitle(tr("Vector")); 0039 0040 connect(_generatedVectorGroup, SIGNAL(clicked(bool)), this, SLOT(generateClicked())); 0041 connect(_dataVectorGroup, SIGNAL(clicked(bool)), this, SLOT(readFromSourceClicked())); 0042 connect(_fileName, SIGNAL(changed(QString)), this, SLOT(fileNameChanged(QString))); 0043 connect(_configure, SIGNAL(clicked()), this, SLOT(showConfigWidget())); 0044 connect(_field, SIGNAL(editTextChanged(QString)), this, SIGNAL(fieldChanged())); 0045 0046 connect(_dataRange, SIGNAL(modified()), this, SIGNAL(modified())); 0047 connect(_numberOfSamples, SIGNAL(valueChanged(int)), this, SIGNAL(modified())); 0048 connect(_from, SIGNAL(textChanged(QString)), this, SIGNAL(modified())); 0049 connect(_to, SIGNAL(textChanged(QString)), this, SIGNAL(modified())); 0050 0051 // embed data range in the data source box 0052 _dataRange->groupBox2->setFlat(true); 0053 _dataRange->groupBox2->setTitle(""); 0054 int top_margin; 0055 _dataRange->groupBox2->layout()->getContentsMargins(NULL,&top_margin,NULL,NULL); 0056 _dataRange->groupBox2->layout()->setContentsMargins(0,top_margin,0,0); 0057 0058 _connect->setVisible(false); 0059 0060 _updateBox->addItem(tr("Time Interval", "update periodically")); 0061 _updateBox->addItem(tr("Change Detection", "update when a change is detected")); 0062 _updateBox->addItem(tr("No Update", "do not update the file")); 0063 updateUpdateBox(); 0064 connect(_updateBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTypeActivated(int))); 0065 connect(_updateBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(modified())); 0066 } 0067 0068 0069 VectorTab::~VectorTab() { 0070 } 0071 0072 void VectorTab::updateUpdateBox() 0073 { 0074 if (_dataSource) { 0075 _updateBox->setEnabled(_mode == DataVector); 0076 switch (_dataSource->updateType()) { 0077 case DataSource::Timer: _updateBox->setCurrentIndex(0); break; 0078 case DataSource::File: _updateBox->setCurrentIndex(1); break; 0079 case DataSource::None: _updateBox->setCurrentIndex(2); break; 0080 default: break; 0081 }; 0082 } else { 0083 _updateBox->setEnabled(false); 0084 } 0085 } 0086 0087 void VectorTab::updateTypeActivated(int idx) 0088 { 0089 if (!_dataSource) { 0090 _updateBox->setEnabled(false); 0091 return; 0092 } 0093 //_updateBox->setEnabled(true); 0094 switch (idx) { 0095 case 0: _dataSource->startUpdating(DataSource::Timer); break; 0096 case 1: _dataSource->startUpdating(DataSource::File); break; 0097 case 2: _dataSource->startUpdating(DataSource::None); break; 0098 default: break; 0099 }; 0100 } 0101 0102 DataSourcePtr VectorTab::dataSource() const { 0103 return _dataSource; 0104 } 0105 0106 0107 void VectorTab::setDataSource(DataSourcePtr dataSource) { 0108 _dataSource = dataSource; 0109 } 0110 0111 0112 void VectorTab::setVectorMode(VectorMode mode) { 0113 _mode = mode; 0114 if (mode == DataVector) { 0115 _dataVectorGroup->setChecked(true); 0116 _dataRange->setEnabled(true); 0117 _generatedVectorGroup->setChecked(false); 0118 _field->setEnabled(_valid); 0119 _configure->setEnabled(_valid); 0120 updateUpdateBox(); 0121 } else { 0122 _generatedVectorGroup->setChecked(true); 0123 _dataVectorGroup->setChecked(false); 0124 _dataRange->setEnabled(false); 0125 } 0126 } 0127 0128 0129 QString VectorTab::file() const { 0130 return _fileName->file(); 0131 } 0132 0133 0134 void VectorTab::setFile(const QString &file) { 0135 _fileName->setFile(DataSource::cleanPath(file)); 0136 } 0137 0138 0139 QString VectorTab::field() const { 0140 return _field->currentText(); 0141 } 0142 0143 0144 void VectorTab::setField(const QString &field) { 0145 _initField = field; // for delayed index setting 0146 _field->setCurrentIndex(_field->findText(field)); 0147 } 0148 0149 0150 void VectorTab::setFieldList(const QStringList &fieldList) { 0151 _field->clear(); 0152 _field->addItems(fieldList); 0153 } 0154 0155 0156 DataRange *VectorTab::dataRange() const { 0157 return _dataRange; 0158 } 0159 0160 0161 qreal VectorTab::from() const { 0162 return _from->text().toDouble(); 0163 } 0164 0165 0166 bool VectorTab::fromDirty() const { 0167 return (!_from->text().isEmpty()); 0168 } 0169 0170 0171 void VectorTab::setFrom(qreal from) { 0172 _from->setText(QString::number(from)); 0173 } 0174 0175 0176 qreal VectorTab::to() const { 0177 return _to->text().toDouble(); 0178 } 0179 0180 0181 bool VectorTab::toDirty() const { 0182 return (!_to->text().isEmpty()); 0183 } 0184 0185 0186 void VectorTab::setTo(qreal to) { 0187 _to->setText(QString::number(to)); 0188 } 0189 0190 0191 int VectorTab::numberOfSamples() const { 0192 return _numberOfSamples->value(); 0193 } 0194 0195 0196 bool VectorTab::numberOfSamplesDirty() const { 0197 return (!_numberOfSamples->text().isEmpty()); 0198 } 0199 0200 0201 void VectorTab::setNumberOfSamples(int numberOfSamples) { 0202 _numberOfSamples->setValue(numberOfSamples); 0203 } 0204 0205 void VectorTab::generateClicked() { 0206 if (_generatedVectorGroup->isChecked()) 0207 setVectorMode(GeneratedVector); 0208 else 0209 setVectorMode(DataVector); 0210 0211 emit sourceChanged(); 0212 } 0213 0214 void VectorTab::readFromSourceClicked() { 0215 if (_dataVectorGroup->isChecked()) 0216 setVectorMode(DataVector); 0217 else 0218 setVectorMode(GeneratedVector); 0219 0220 emit sourceChanged(); 0221 } 0222 0223 void VectorTab::hideGeneratedOptions() { 0224 _generatedVectorGroup->setVisible(false); 0225 _dataVectorGroup->setCheckable(false); 0226 _dataVectorGroup->setTitle(""); 0227 _dataVectorGroup->setFlat(true); 0228 int top_margin; 0229 _dataVectorGroup->layout()->getContentsMargins(NULL,&top_margin,NULL,NULL); 0230 _dataVectorGroup->layout()->setContentsMargins(0,top_margin,0,0); 0231 } 0232 0233 0234 void VectorTab::hideDataOptions() { 0235 _dataVectorGroup->setVisible(false); 0236 _dataRange->setVisible(false); 0237 _generatedVectorGroup->setCheckable(false); 0238 _generatedVectorGroup->setTitle(""); 0239 _generatedVectorGroup->setFlat(true); 0240 int top_margin; 0241 _generatedVectorGroup->layout()->getContentsMargins(NULL,&top_margin,NULL,NULL); 0242 _generatedVectorGroup->layout()->setContentsMargins(0,top_margin,0,0); 0243 } 0244 0245 0246 void VectorTab::clearTabValues() { 0247 _numberOfSamples->clear(); 0248 _from->clear(); 0249 _to->clear(); 0250 _dataRange->clearValues(); 0251 } 0252 0253 0254 void VectorTab::enableSingleEditOptions(bool enabled) { 0255 _dataVectorGroup->setEnabled(enabled); 0256 } 0257 0258 0259 void VectorTab::sourceValid(QString filename, int requestID) { 0260 if (_requestID != requestID) { 0261 return; 0262 } 0263 _valid = true; 0264 _dataSource = DataSourcePluginManager::findOrLoadSource(_store, filename); 0265 _field->setEnabled(true); 0266 0267 _dataSource->readLock(); 0268 0269 _field->addItems(_dataSource->vector().list()); 0270 if (!_initField.isEmpty()) { 0271 setField(_initField); 0272 } 0273 _field->setEditable(!_dataSource->vector().isListComplete()); 0274 _configure->setEnabled(_dataSource->hasConfigWidget() && (_mode == DataVector)); 0275 0276 updateUpdateBox(); 0277 updateIndexList(_dataSource); 0278 0279 _dataSource->unlock(); 0280 0281 0282 validating = false; 0283 0284 _store->cleanUpDataSourceList(); 0285 _field->setEnabled(_mode == DataVector); 0286 0287 emit sourceChanged(); 0288 } 0289 0290 0291 void VectorTab::fileNameChanged(const QString &file) { 0292 _field->clear(); 0293 _field->setEnabled(false); 0294 _configure->setEnabled(false); 0295 _valid = false; 0296 0297 clearIndexList(); 0298 emit sourceChanged(); 0299 0300 _requestID += 1; 0301 ValidateDataSourceThread *validateDSThread = new ValidateDataSourceThread(file, _requestID); 0302 connect(validateDSThread, SIGNAL(dataSourceValid(QString,int)), this, SLOT(sourceValid(QString,int))); 0303 validating = true; 0304 QThreadPool::globalInstance()->start(validateDSThread); 0305 } 0306 0307 0308 void VectorTab::showConfigWidget() { 0309 QPointer<DataSourceConfigureDialog> dialog = new DataSourceConfigureDialog(dataDialog()->editMode(), _dataSource, this); 0310 if ( dialog->exec() == QDialog::Accepted ) { 0311 fileNameChanged(_dataSource->fileName()); 0312 } 0313 delete dialog; 0314 } 0315 0316 VectorDialog::VectorDialog(ObjectPtr dataObject, QWidget *parent) 0317 : DataDialog(dataObject, parent, false) { 0318 0319 if (editMode() == Edit) 0320 setWindowTitle(tr("Edit Vector")); 0321 else 0322 setWindowTitle(tr("New Vector")); 0323 0324 Q_ASSERT(_document); 0325 _vectorTab = new VectorTab(_document->objectStore(), this); 0326 addDataTab(_vectorTab); 0327 0328 if (editMode() == Edit) { 0329 configureTab(dataObject); 0330 } else { 0331 configureTab(0); 0332 } 0333 0334 connect(_vectorTab, SIGNAL(sourceChanged()), this, SLOT(updateButtons())); 0335 connect(_vectorTab, SIGNAL(fieldChanged()), this, SLOT(updateButtons())); 0336 0337 connect(this, SIGNAL(editMultipleMode()), this, SLOT(editMultipleMode())); 0338 connect(this, SIGNAL(editSingleMode()), this, SLOT(editSingleMode())); 0339 0340 connect(_vectorTab, SIGNAL(modified()), this, SLOT(modified())); 0341 connect(_vectorTab, SIGNAL(destroyed()), kstApp->mainWindow(), SLOT(cleanUpDataSourceList())); 0342 connect(_vectorTab->dataRange(), SIGNAL(modified()), this, SLOT(updateButtons())); 0343 0344 updateButtons(); 0345 } 0346 0347 0348 VectorDialog::~VectorDialog() { 0349 } 0350 0351 0352 void VectorDialog::editMultipleMode() { 0353 _vectorTab->enableSingleEditOptions(false); 0354 _vectorTab->clearTabValues(); 0355 } 0356 0357 0358 void VectorDialog::editSingleMode() { 0359 _vectorTab->enableSingleEditOptions(true); 0360 configureTab(dataObject()); 0361 } 0362 0363 0364 void VectorDialog::updateButtons() { 0365 0366 bool valid = _vectorTab->vectorMode() == VectorTab::GeneratedVector || !_vectorTab->field().isEmpty(); 0367 0368 valid &= _vectorTab->dataRange()->rangeIsValid(); 0369 0370 _buttonBox->button(QDialogButtonBox::Ok)->setEnabled(valid); 0371 _buttonBox->button(QDialogButtonBox::Apply)->setEnabled(valid); 0372 } 0373 0374 0375 void VectorDialog::configureTab(ObjectPtr vector) { 0376 if (!vector) { 0377 _vectorTab->dataRange()->loadWidgetDefaults(); 0378 _vectorTab->setFile(dialogDefaults().value("vector/datasource",_vectorTab->file()).toString()); 0379 _vectorTab->setFrom(dialogDefaults().value("genVector/first",-10).toInt()); 0380 _vectorTab->setTo(dialogDefaults().value("genVector/last",10).toInt()); 0381 _vectorTab->setNumberOfSamples(dialogDefaults().value("genVector/length",1000).toInt()); 0382 _vectorTab->setVectorMode((VectorTab::VectorMode)dialogDefaults().value("genVector/vectorType",VectorTab::GeneratedVector).toInt()); // FIXME: should be sticky 0383 } else if (DataVectorPtr dataVector = kst_cast<DataVector>(vector)) { 0384 _vectorTab->setVectorMode(VectorTab::DataVector); 0385 _vectorTab->setFile(dataVector->dataSource()->fileName()); 0386 _vectorTab->setDataSource(dataVector->dataSource()); 0387 _vectorTab->updateIndexList(dataVector->dataSource()); 0388 _vectorTab->setField(dataVector->field()); 0389 0390 _vectorTab->dataRange()->setRangeUnits(dataVector->rangeUnits()); 0391 if ( _vectorTab->dataRange()->rangeUnitsIndex()>0) { 0392 double frame_per_index = dataVector->dataSource()->framePerIndex(dataVector->startUnits()); 0393 if (frame_per_index == 0) { 0394 frame_per_index = 1.0; 0395 } 0396 _vectorTab->dataRange()->setRange(dataVector->numFrames()/frame_per_index); 0397 0398 } else { 0399 _vectorTab->dataRange()->setRange(dataVector->numFrames()); 0400 } 0401 0402 _vectorTab->dataRange()->setStartUnits(dataVector->startUnits()); 0403 if (_vectorTab->dataRange()->startUnitsIndex()>0) { 0404 _vectorTab->dataRange()->setStart(dataVector->dataSource()->frameToIndex(dataVector->startFrame(),dataVector->startUnits())); 0405 } else { 0406 _vectorTab->dataRange()->setStart(dataVector->startFrame()); 0407 } 0408 0409 _vectorTab->dataRange()->setCountFromEnd(dataVector->countFromEOF()); 0410 _vectorTab->dataRange()->setReadToEnd(dataVector->readToEOF()); 0411 _vectorTab->dataRange()->setSkip(dataVector->skip()); 0412 _vectorTab->dataRange()->setDoSkip(dataVector->doSkip()); 0413 _vectorTab->dataRange()->setDoFilter(dataVector->doAve()); 0414 _vectorTab->hideGeneratedOptions(); 0415 if (_editMultipleWidget) { 0416 DataVectorList objects = _document->objectStore()->getObjects<DataVector>(); 0417 _editMultipleWidget->clearObjects(); 0418 foreach(DataVectorPtr object, objects) { 0419 _editMultipleWidget->addObject(object->Name(), object->descriptionTip()); 0420 } 0421 } 0422 } else if (GeneratedVectorPtr generatedVector = kst_cast<GeneratedVector>(vector)) { 0423 _vectorTab->setVectorMode(VectorTab::GeneratedVector); 0424 _vectorTab->setFrom(generatedVector->value(0)); 0425 _vectorTab->setTo(generatedVector->value(generatedVector->length()-1)); 0426 _vectorTab->setNumberOfSamples(generatedVector->length()); 0427 _vectorTab->hideDataOptions(); 0428 if (_editMultipleWidget) { 0429 DataVectorList objects = _document->objectStore()->getObjects<DataVector>(); 0430 _editMultipleWidget->clearObjects(); 0431 foreach(DataVectorPtr object, objects) { 0432 _editMultipleWidget->addObject(object->Name(), object->descriptionTip()); 0433 } 0434 } 0435 } 0436 } 0437 0438 0439 ObjectPtr VectorDialog::createNewDataObject() { 0440 switch(_vectorTab->vectorMode()) { 0441 case VectorTab::DataVector: 0442 dialogDefaults().setValue("genVector/vectorType", VectorTab::DataVector); 0443 return createNewDataVector(); 0444 case VectorTab::GeneratedVector: 0445 dialogDefaults().setValue("genVector/vectorType", VectorTab::GeneratedVector); 0446 return createNewGeneratedVector(); 0447 default: 0448 return 0; 0449 } 0450 } 0451 0452 0453 void VectorTab::updateIndexList(DataSourcePtr dataSource) { 0454 dataRange()->updateIndexList(dataSource->indexFields()); 0455 } 0456 0457 0458 void VectorTab::clearIndexList() { 0459 dataRange()->clearIndexList(); 0460 } 0461 0462 0463 ObjectPtr VectorDialog::createNewDataVector() { 0464 DataSourcePtr dataSource = _vectorTab->dataSource(); 0465 0466 //FIXME better validation than this please... 0467 if (!dataSource) 0468 return 0; 0469 0470 // Hook the progress signal when loading a new datasource to get feedback in case it takes long 0471 connect(dataSource, SIGNAL(progress(int,QString)), kstApp->mainWindow(), SLOT(updateProgress(int,QString))); 0472 dataSource->vector().prepareRead(1); 0473 0474 const QString field = _vectorTab->field(); 0475 const DataRange *dataRange = _vectorTab->dataRange(); 0476 0477 Q_ASSERT(_document && _document->objectStore()); 0478 0479 DataVectorPtr vector = _document->objectStore()->createObject<DataVector>(); 0480 0481 double startOffset = dataRange->start(); 0482 double rangeCount = dataRange->range(); 0483 0484 if ((dataRange->_startUnits->currentIndex() != 0) && (!dataRange->countFromEnd())) { 0485 startOffset = _vectorTab->dataSource()->indexToFrame(dataRange->start(), dataRange->startUnits()); 0486 } 0487 0488 if ((dataRange->_rangeUnits->currentIndex() != 0) && (!dataRange->readToEnd())) { 0489 rangeCount = dataRange->range()*_vectorTab->dataSource()->framePerIndex(dataRange->rangeUnits()); 0490 } 0491 0492 vector->writeLock(); 0493 vector->change(dataSource, field, 0494 dataRange->countFromEnd() ? -1 : int(startOffset), 0495 dataRange->readToEnd() ? -1 : int(rangeCount), 0496 dataRange->skip(), 0497 dataRange->doSkip(), 0498 dataRange->doFilter()); 0499 0500 vector->setRangeUnits(dataRange->rangeUnits()); 0501 vector->setStartUnits(dataRange->startUnits()); 0502 0503 if (DataDialog::tagStringAuto()) { 0504 vector->setDescriptiveName(QString()); 0505 } else { 0506 vector->setDescriptiveName(DataDialog::tagString()); 0507 } 0508 0509 setDataVectorDefaults(vector); 0510 _vectorTab->dataRange()->setWidgetDefaults(); 0511 0512 vector->registerChange(); 0513 vector->unlock(); 0514 0515 _dataObjectName = vector->Name(); 0516 0517 //UpdateServer::self()->requestUpdateSignal(); 0518 return vector; 0519 } 0520 0521 0522 ObjectPtr VectorDialog::createNewGeneratedVector() { 0523 const qreal from = _vectorTab->from(); 0524 const qreal to = _vectorTab->to(); 0525 const int numberOfSamples = _vectorTab->numberOfSamples(); 0526 0527 Q_ASSERT(_document && _document->objectStore()); 0528 GeneratedVectorPtr vector = _document->objectStore()->createObject<GeneratedVector>(); 0529 vector->changeRange(from, to, numberOfSamples); 0530 0531 setGenVectorDefaults(vector); 0532 0533 if (DataDialog::tagStringAuto()) { 0534 vector->setDescriptiveName(QString()); 0535 } else { 0536 vector->setDescriptiveName(DataDialog::tagString()); 0537 } 0538 0539 _dataObjectName = vector->Name(); 0540 0541 _vectorTab->setDataSource(0L); 0542 _document->objectStore()->cleanUpDataSourceList(); 0543 0544 //UpdateServer::self()->requestUpdateSignal(); 0545 return vector; 0546 } 0547 0548 0549 ObjectPtr VectorDialog::editExistingDataObject() const { 0550 if (DataVectorPtr dataVector = kst_cast<DataVector>(dataObject())) { 0551 if (editMode() == EditMultiple) { 0552 const DataRange *dataRange = _vectorTab->dataRange(); 0553 QStringList objects = _editMultipleWidget->selectedObjects(); 0554 foreach (const QString &objectName, objects) { 0555 DataVectorPtr vector = kst_cast<DataVector>(_document->objectStore()->retrieveObject(objectName)); 0556 if (vector) { 0557 int start = dataRange->startDirty() ? dataRange->start() : vector->startFrame(); 0558 int range = dataRange->rangeDirty() ? dataRange->range() : vector->numFrames(); 0559 int skip = dataRange->skipDirty() ? dataRange->skip() : vector->skip(); 0560 0561 if (dataRange->countFromEndDirty()) { 0562 start = dataRange->countFromEnd() ? -1 : dataRange->start(); 0563 range = dataRange->readToEnd() ? -1 : dataRange->range(); 0564 } 0565 0566 bool doSkip = dataRange->doSkipDirty() ? dataRange->doSkip() : vector->doSkip(); 0567 bool doAve = dataRange->doFilterDirty() ? dataRange->doFilter() : vector->doAve(); 0568 vector->writeLock(); 0569 vector->changeFrames(start, range, skip, doSkip, doAve); 0570 vector->registerChange(); 0571 vector->unlock(); 0572 } 0573 } 0574 } else { 0575 const DataSourcePtr dataSource = _vectorTab->dataSource(); 0576 0577 //FIXME better validation than this please... 0578 if (!dataSource) 0579 return 0; 0580 0581 const QString field = _vectorTab->field(); 0582 const DataRange *dataRange = _vectorTab->dataRange(); 0583 0584 double startOffset = dataRange->start(); 0585 double rangeCount = dataRange->range(); 0586 0587 if ((dataRange->_startUnits->currentIndex() != 0) && (!dataRange->countFromEnd())) { 0588 startOffset = _vectorTab->dataSource()->indexToFrame(dataRange->start(), dataRange->startUnits()); 0589 } 0590 0591 if ((dataRange->_rangeUnits->currentIndex() != 0) && (!dataRange->readToEnd())) { 0592 rangeCount = dataRange->range()*_vectorTab->dataSource()->framePerIndex(dataRange->rangeUnits()) + 0.0001; 0593 } 0594 0595 0596 dataVector->writeLock(); 0597 dataVector->change(dataSource, field, 0598 dataRange->countFromEnd() ? -1 : int(startOffset), 0599 dataRange->readToEnd() ? -1 : int(rangeCount), 0600 dataRange->skip(), 0601 dataRange->doSkip(), 0602 dataRange->doFilter()); 0603 0604 if (DataDialog::tagStringAuto()) { 0605 dataVector->setDescriptiveName(QString()); 0606 } else { 0607 dataVector->setDescriptiveName(DataDialog::tagString()); 0608 } 0609 0610 dataVector->registerChange(); 0611 dataVector->unlock(); 0612 0613 setDataVectorDefaults(dataVector); 0614 _vectorTab->dataRange()->setWidgetDefaults(); 0615 } 0616 } else if (GeneratedVectorPtr generatedVector = kst_cast<GeneratedVector>(dataObject())) { 0617 if (editMode() == EditMultiple) { 0618 QStringList objects = _editMultipleWidget->selectedObjects(); 0619 foreach (const QString &objectName, objects) { 0620 GeneratedVectorPtr vector = kst_cast<GeneratedVector>(_document->objectStore()->retrieveObject(objectName)); 0621 if (vector) { 0622 double min = _vectorTab->fromDirty() ? _vectorTab->from() : vector->min(); 0623 double max = _vectorTab->toDirty() ? _vectorTab->to() : vector->max(); 0624 double length = _vectorTab->numberOfSamplesDirty() ? _vectorTab->numberOfSamples() : vector->length(); 0625 vector->writeLock(); 0626 vector->changeRange(min, max, length); 0627 vector->registerChange(); 0628 vector->unlock(); 0629 } 0630 } 0631 } else { 0632 const qreal from = _vectorTab->from(); 0633 const qreal to = _vectorTab->to(); 0634 const int numberOfSamples = _vectorTab->numberOfSamples(); 0635 generatedVector->writeLock(); 0636 generatedVector->changeRange(from, to, numberOfSamples); 0637 if (DataDialog::tagStringAuto()) { 0638 generatedVector->setDescriptiveName(QString()); 0639 } else { 0640 generatedVector->setDescriptiveName(DataDialog::tagString()); 0641 } 0642 generatedVector->registerChange(); 0643 generatedVector->unlock(); 0644 setGenVectorDefaults(generatedVector); 0645 } 0646 } 0647 0648 return dataObject(); 0649 } 0650 0651 void VectorDialog::waitForValidation() { 0652 while (_vectorTab->validating && (_vectorTab->vectorMode() == VectorTab::DataVector)) { 0653 Sleep::ms(10); 0654 QApplication::processEvents(); 0655 } 0656 } 0657 0658 } 0659 0660 // vim: ts=2 sw=2 et