void KstMatrixDefaults::sync() {
  KST::matrixList.lock().readLock();
  KstRMatrixList rmatrixList = kstObjectSubList<KstMatrix,KstRMatrix>(KST::matrixList);
  KST::matrixList.lock().unlock();
  int j = rmatrixList.count() - 1;

  // Find a non-stdin source
  while (j >= 0) {
    rmatrixList[j]->readLock();
    KstDataSourcePtr dsp = rmatrixList[j]->dataSource();
    rmatrixList[j]->unlock();
    if (dsp && !kst_cast<KstStdinSource>(dsp)) {
      break;
    }
    --j;
  }

  if (j >= 0) {
    rmatrixList[j]->readLock();

    // get the settings
    _dataSource = rmatrixList[j]->filename();
    _xStart = rmatrixList[j]->reqXStart();
    _yStart = rmatrixList[j]->reqYStart();
    _xNumSteps = rmatrixList[j]->reqXNumSteps();
    _yNumSteps = rmatrixList[j]->reqYNumSteps();
    _skip = rmatrixList[j]->skip();
    _doAve = rmatrixList[j]->doAverage();
    _doSkip = rmatrixList[j]->doSkip();

    rmatrixList[j]->unlock();
  }
}
Beispiel #2
0
void KstMatrixDialog::populateEditMultipleRMatrix() {
  KstRMatrixList mxList;

  mxList = kstObjectSubList<KstMatrix,KstRMatrix>(KST::matrixList);
  _editMultipleWidget->_objectList->insertItems(0, mxList.tagNames());

  //
  // intermediate state for multiple edit...
  //

// xxx  _w->_fileName->clear();
  _w->_xStart->setSpecialValueText(" ");
  _w->_xStart->setMinimum(_w->_xStart->minimum() - 1);
  _w->_xStart->setValue(_w->_xStart->minimum());

  _w->_yStart->setSpecialValueText(" ");
  _w->_yStart->setMinimum(_w->_yStart->minimum() - 1);
  _w->_yStart->setValue(_w->_yStart->minimum());

  _w->_xNumSteps->setSpecialValueText(" ");
  _w->_xNumSteps->setMinimum(_w->_xNumSteps->minimum() - 1);
  _w->_xNumSteps->setValue(_w->_xNumSteps->minimum());

  _w->_yNumSteps->setSpecialValueText(" ");
  _w->_yNumSteps->setMinimum(_w->_yNumSteps->minimum() - 1);
  _w->_yNumSteps->setValue(_w->_yNumSteps->minimum());

  _w->_skip->setSpecialValueText(" ");
  _w->_skip->setMinimum(_w->_skip->minimum() - 1);
  _w->_skip->setValue(_w->_skip->minimum());

  _w->_doSkip->setTristate(true);
  _w->_doSkip->setChecked(Qt::PartiallyChecked);
  _w->_doAve->setTristate(true);
  _w->_doAve->setChecked(Qt::PartiallyChecked);
  _w->_xStartCountFromEnd->setTristate(true);
  _w->_xStartCountFromEnd->setChecked(Qt::PartiallyChecked);
  _w->_yStartCountFromEnd->setTristate(true);
  _w->_yStartCountFromEnd->setChecked(Qt::PartiallyChecked);
  _w->_xNumStepsReadToEnd->setTristate(true);
  _w->_xNumStepsReadToEnd->setChecked(Qt::PartiallyChecked);
  _w->_yNumStepsReadToEnd->setTristate(true);
  _w->_yNumStepsReadToEnd->setChecked(Qt::PartiallyChecked);
  _w->_xStart->setEnabled(true);
  _w->_xNumSteps->setEnabled(true);
  _w->_yStart->setEnabled(true);
  _w->_yNumSteps->setEnabled(true);
}
Beispiel #3
0
void KstChangeFileDialog::updateChangeFileDialog() {
  KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
  KstRMatrixList rml = kstObjectSubList<KstMatrix,KstRMatrix>(KST::matrixList);
  QMap<QString, QString> filesUsed;
  int i;

  // clear list
  ChangeFileCurveList->clear();

  // first add vectors
  for (i = 0; i < (int)rvl.count(); i++) {
    rvl[i]->readLock();
    ChangeFileCurveList->insertItem(rvl[i]->tag().displayString());
    filesUsed.insert(rvl[i]->filename(), rvl[i]->filename()); 
    rvl[i]->unlock();
  }

  // then add matrices
  for (i = 0; i < (int)rml.count(); i++) {
    rml[i]->readLock();
    ChangeFileCurveList->insertItem(rml[i]->tag().displayString());
    filesUsed.insert(rml[i]->filename(), rml[i]->filename()); 
    rml[i]->unlock();  
  }

  QString currentFile = _files->currentText();
  _files->clear();
  KstReadLocker ml(&KST::dataSourceList.lock());
  for (KstDataSourceList::Iterator it = KST::dataSourceList.begin(); it != KST::dataSourceList.end(); ++it) {
    if (filesUsed.contains((*it)->fileName())) {
      _files->insertItem((*it)->fileName());
    }
  }
  if (_files->contains(currentFile)) {
    _files->setCurrentText(currentFile);
  }

  _allFromFile->setEnabled(_files->count() > 0);
  _files->setEnabled(_files->count() > 0);

  if (_first) {
    _dataFile->setURL(KST::vectorDefaults.dataSource());
    _first = false;
  }
}
Beispiel #4
0
void KstMatrixDialogI::populateEditMultipleRMatrix() {
  KstRMatrixList mxList = kstObjectSubList<KstMatrix,KstRMatrix>(KST::matrixList);
  _editMultipleWidget->_objectList->insertStringList(mxList.tagNames());

  // intermediate state for multiple edit
  _w->_fileName->clear();
  _w->_xStart->setSpecialValueText(" ");
  _w->_xStart->setMinValue(_w->_xStart->minValue() - 1);
  _w->_xStart->setValue(_w->_xStart->minValue());

  _w->_yStart->setSpecialValueText(" ");
  _w->_yStart->setMinValue(_w->_yStart->minValue() - 1);
  _w->_yStart->setValue(_w->_yStart->minValue());

  _w->_xNumSteps->setSpecialValueText(" ");
  _w->_xNumSteps->setMinValue(_w->_xNumSteps->minValue() - 1);
  _w->_xNumSteps->setValue(_w->_xNumSteps->minValue());

  _w->_yNumSteps->setSpecialValueText(" ");
  _w->_yNumSteps->setMinValue(_w->_yNumSteps->minValue() - 1);
  _w->_yNumSteps->setValue(_w->_yNumSteps->minValue());

  _w->_skip->setSpecialValueText(" ");
  _w->_skip->setMinValue(_w->_skip->minValue() - 1);
  _w->_skip->setValue(_w->_skip->minValue());

  _w->_doSkip->setTristate(true);
  _w->_doSkip->setNoChange();
  _w->_doAve->setTristate(true);
  _w->_doAve->setNoChange();
  _w->_xStartCountFromEnd->setTristate(true);
  _w->_xStartCountFromEnd->setNoChange();
  _w->_yStartCountFromEnd->setTristate(true);
  _w->_yStartCountFromEnd->setNoChange();
  _w->_xNumStepsReadToEnd->setTristate(true);
  _w->_xNumStepsReadToEnd->setNoChange();
  _w->_yNumStepsReadToEnd->setTristate(true);
  _w->_yNumStepsReadToEnd->setNoChange();
  _w->_xStart->setEnabled(true);
  _w->_xNumSteps->setEnabled(true);
  _w->_yStart->setEnabled(true);
  _w->_yNumSteps->setEnabled(true);
}
Beispiel #5
0
void KstMatrixDefaults::sync() {
  KstRMatrixList::iterator it;
  KstRMatrixList rmatrixList;
  KstRMatrixPtr rmatrix;

  KST::matrixList.lock().readLock();
  rmatrixList = kstObjectSubList<KstMatrix,KstRMatrix>(KST::matrixList);
  KST::matrixList.lock().unlock();
  
  //
  // find a non-stdin source...
  //
  
  for (it=rmatrixList.begin(); it!=rmatrixList.end(); ++it) {
    KstDataSourcePtr dsp;
    
    rmatrix = *it;
    
    rmatrix->readLock();
    dsp = rmatrix->dataSource();
    rmatrix->unlock();
    if (dsp && !kst_cast<KstStdinSource>(dsp)) {
      break;
    }
  }
  
  if (it != rmatrixList.end()) {
    rmatrix->readLock();

    _dataSource = rmatrix->filename();
    _xStart = rmatrix->reqXStart();
    _yStart = rmatrix->reqYStart();
    _xNumSteps = rmatrix->reqXNumSteps();
    _yNumSteps = rmatrix->reqYNumSteps();
    _skip = rmatrix->skip();
    _doAve = rmatrix->doAverage();
    _doSkip = rmatrix->doSkip();

    rmatrix->unlock();
  }
}
Beispiel #6
0
void KstDataManagerI::update() {
  if (!isShown()) {
    return;
  }

  QListViewItem *currentItem = DataView->selectedItem();
  QPtrStack<QListViewItem> trash;

  KST::dataObjectList.lock().writeLock();
  KST::vectorList.lock().writeLock();
  KST::matrixList.lock().writeLock();

  // garbage collect first
  for (QListViewItem *i = DataView->firstChild(); i; i = i->nextSibling()) {
    KstObjectItem *oi = static_cast<KstObjectItem*>(i);
    if (i->rtti() == RTTI_OBJ_OBJECT) {
      if (KST::dataObjectList.findTag(oi->tag().tag()) == KST::dataObjectList.end()) {
        trash.push(i);
      }
    } else if (i->rtti() == RTTI_OBJ_DATA_MATRIX || 
               i->rtti() == RTTI_OBJ_MATRIX ||
               i->rtti() == RTTI_OBJ_STATIC_MATRIX) {
      if (KST::matrixList.findTag(oi->tag().tag()) == KST::matrixList.end()) {
        trash.push(i);  
      }
    } else {
      if (KST::vectorList.findTag(oi->tag().tag()) == KST::vectorList.end()) {
        trash.push(i);
      }
    }
  }

  trash.setAutoDelete(true);
  DataView->blockSignals(true);
  trash.clear();
  DataView->blockSignals(false);

  // update the data objects
  for (KstDataObjectList::iterator it = KST::dataObjectList.begin();
                                    it != KST::dataObjectList.end();
                                                               ++it) {
    KstReadLocker dol(*it);
    bool found = false;
    for (QListViewItem *i = DataView->firstChild(); i; i = i->nextSibling()) {
      KstObjectItem *oi = static_cast<KstObjectItem*>(i);
      if (oi->rtti() == RTTI_OBJ_OBJECT && oi->tag().tag() == (*it)->tag().tag()) {
        oi->update();
        found = true;
        break;
      }
    }
    if (!found) {
      KstObjectItem *i = new KstObjectItem(DataView, *it, this);
      connect(i, SIGNAL(updated()), this, SLOT(doUpdates()));
    }
  }

  KST::dataObjectList.lock().unlock();

  // update the data vectors
  KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
  for (KstRVectorList::iterator it = rvl.begin(); it != rvl.end(); ++it) {
    KstReadLocker vl(*it);
    bool found = false;
    for (QListViewItem *i = DataView->firstChild(); i; i = i->nextSibling()) {
      KstObjectItem *oi = static_cast<KstObjectItem*>(i);
      if (oi->rtti() == RTTI_OBJ_DATA_VECTOR && oi->tag().tag() == (*it)->tag().tag()) {
        oi->update(true, 1);
        found = true;
        break;
      }
    }
    if (!found) {
      KstObjectItem *i = new KstObjectItem(DataView, *it, this, 1);
      connect(i, SIGNAL(updated()), this, SLOT(doUpdates()));
    }
  }

  // update the static vectors
  KstSVectorList svl = kstObjectSubList<KstVector,KstSVector>(KST::vectorList);
  for (KstSVectorList::iterator it = svl.begin(); it != svl.end(); ++it) {
    KstReadLocker vl(*it);
    bool found = false;
    for (QListViewItem *i = DataView->firstChild(); i; i = i->nextSibling()) {
      KstObjectItem *oi = static_cast<KstObjectItem*>(i);
      if (oi->rtti() == RTTI_OBJ_STATIC_VECTOR && oi->tag().tag() == (*it)->tag().tag()) {
        oi->update(true, 1);
        found = true;
        break;
      }
    }
    if (!found) {
      KstObjectItem *i = new KstObjectItem(DataView, *it, this, 1);
      connect(i, SIGNAL(updated()), this, SLOT(doUpdates()));
    }
  }

  KST::vectorList.lock().unlock();

  // update the data matrices 
  KstRMatrixList rml = kstObjectSubList<KstMatrix,KstRMatrix>(KST::matrixList);
  for (KstRMatrixList::iterator it = rml.begin(); it != rml.end(); ++it) {
    KstReadLocker ml(*it);
    bool found = false;
    for (QListViewItem *i = DataView->firstChild(); i; i = i->nextSibling()) {
      KstObjectItem *oi = static_cast<KstObjectItem*>(i);
      if (oi->rtti() == RTTI_OBJ_DATA_MATRIX && oi->tag().tag() == (*it)->tag().tag()) {
        oi->update(true, 1);
        found = true;
        break;
      }
    }
    if (!found) {
      KstObjectItem *i = new KstObjectItem(DataView, *it, this, 1);
      connect(i, SIGNAL(updated()), this, SLOT(doUpdates()));
    }
  }

  // update the static matrices
  KstSMatrixList sml = kstObjectSubList<KstMatrix,KstSMatrix>(KST::matrixList);
  for (KstSMatrixList::iterator it = sml.begin(); it != sml.end(); ++it) {
    KstReadLocker ml(*it);
    bool found = false;
    for (QListViewItem *i = DataView->firstChild(); i; i = i->nextSibling()) {
      KstObjectItem *oi = static_cast<KstObjectItem*>(i);
      if (oi->rtti() == RTTI_OBJ_STATIC_MATRIX && oi->tag().tag() == (*it)->tag().tag()) {
        oi->update(true, 1);
        found = true;
        break;
      }
    }
    if (!found) {
      KstObjectItem *i = new KstObjectItem(DataView, *it, this, 1);
      connect(i, SIGNAL(updated()), this, SLOT(doUpdates()));
    }
  }

  KST::matrixList.lock().unlock();

  // is this really necessary?  I would think not...
  for (QListViewItem *i = DataView->firstChild(); i; i = i->nextSibling()) {
    if (i == currentItem) {
      DataView->setCurrentItem(i);
      DataView->setSelected(i, true);
      break;
    }
  }

  if (DataView->selectedItem()) {
    static_cast<KstObjectItem*>(DataView->currentItem())->updateButtons();
  } else {
    Edit->setEnabled(false);
    Delete->setEnabled(false);
  }
}