bool KstChangeNptsDialogI::updateChangeNptsDialog() {
  QStringList qsl;
  int inserted = 0;

  for (uint i_vector = 0; i_vector < CurveList->count(); i_vector++) {
    if (CurveList->isSelected(i_vector)) {
      qsl.append(CurveList->text(i_vector));
    }
  }
  CurveList->clear();

  KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
  // insert vectors into ChangeNptsCurveList
  CurveList->blockSignals(true); // avoid deadlock
  for (KstRVectorList::ConstIterator i = rvl.begin(); i != rvl.end(); ++i) {
    KstRVectorPtr vector = *i;
    vector->readLock();
    QString tag = vector->tag().displayString();
    CurveList->insertItem(tag, -1);
    if (qsl.contains(tag)) {
      CurveList->setSelected(inserted, true);
    }
    ++inserted;
    vector->unlock();
  }
  CurveList->blockSignals(false);

  return !qsl.isEmpty();
}
示例#2
0
bool KstIfaceImpl::changeDataFile(const QString& fileName) {
  QStringList vl;
  KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
  for (KstRVectorList::ConstIterator i = rvl.begin(); i != rvl.end(); ++i) {
    vl += (*i)->tagName();
  }
  return changeDataFiles(vl, fileName);
}
示例#3
0
void KstVectorDialogI::update(int new_index) {
  int i_vector, index, n_v;
  KstRVectorPtr vector;
  bool isNew = false;

  KstRVectorList vectorList = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
  if (new_index == -1) {
    if (vectorList.findTag(Select->currentText()) != vectorList.end()) {
      QString save = Select->currentText();
      Select->blockSignals(true);
      Select->clear();
      for (KstRVectorList::iterator i = vectorList.begin(); i != vectorList.end(); ++i) {
        Select->insertItem((*i)->tagName());
      }
      Select->setCurrentText(save);
      Select->blockSignals(false);
      return;
    }
  }

  n_v = vectorList.count();
  if (n_v < 1) {
    Select->clear();
    Select->insertItem("V1-" + i18n("<New_Vector>"));
    Delete->setEnabled(false);
    return;
  }

  if (new_index == -2) {
    isNew = true;
    new_index = n_v-1;
  }

  if (new_index >= 0) {
    index = new_index;
  } else if (n_v > 0) {
    index = Select->currentItem();
  } else {
    index = n_v-1;
  }

  /** fill VectorListBox with vector tags */
  Select->clear();
  for (KstRVectorList::iterator i = vectorList.begin(); i != vectorList.end(); ++i) {
    Select->insertItem((*i)->tagName());
  }

  if (index >= 0 && index < n_v) {
    Select->setCurrentItem(index);
  } else if (n_v > 0) {
    Select->setCurrentItem(n_v - 1);
  }

  i_vector = Select->currentItem();
  vector = vectorList[i_vector];

  /* fill the fields */
  Field->clear();
  _fieldCompletion->clear();
  KstDataSourcePtr tf;
  {
    KST::dataSourceList.lock().readLock();
    KstDataSourceList::Iterator it = KST::dataSourceList.findFileName(vector->filename());
    if (it != KST::dataSourceList.end()) {
      tf = *it;
      Field->insertStringList(tf->fieldList());
      _fieldCompletion->insertItems(tf->fieldList());
      //std::cout << "inserting string list: " << tf->fieldList().count() << "\n";
    }
    KST::dataSourceList.lock().readUnlock();
  }
  if (isNew) {
    Field->setCurrentText(QString::null);
  } else {
    Field->setCurrentText(vector->getField());
  }

  /* select the proper file */
  FileName->setURL(vector->filename());

  /* fill the vector range entries */
  if (vector->countFromEOF()) {
    CountFromEnd->setChecked(true);
  } else {
    CountFromEnd->setChecked(false);
  }
  F0->setValue(vector->reqStartFrame());

  /* fill number of frames entries */
  if (vector->readToEOF()) {
    ReadToEnd->setChecked(true);
  } else {
    ReadToEnd->setChecked(false);
  }
  N->setValue(vector->reqNumFrames());

  /* fill in frames to skip box */
  Skip->setValue(vector->skip());
  DoSkip->setChecked(vector->doSkip());
  DoFilter->setChecked(vector->doAve());

  if (isNew) {
    QString new_label;
    new_label.sprintf("V%d-", n_v+1);
    new_label += i18n("<New_Vector>");
    Select->insertItem(new_label);
    Select->setCurrentItem(n_v);
    Delete->setEnabled(false);
  } else {
    Delete->setEnabled(vector->getUsage() == 2);
  }
}
示例#4
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);
  }
}
示例#5
0
void KstDataManagerI::update() {
if (!isShown()) {
  return;
}

QPtrStack<QListViewItem> trash;

  // 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->tagName()) == KST::dataObjectList.end()) {
        trash.push(i);
      }
    } else {
      if (KST::vectorList.findTag(oi->tagName()) == KST::vectorList.end()) {
        trash.push(i);
      }
    }
  }

  trash.setAutoDelete(true);
  trash.clear();

  for (KstDataObjectList::iterator it = KST::dataObjectList.begin();
                                    it != KST::dataObjectList.end();
                                                               ++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->tagName() == (*it)->tagName()) {
        oi->update();
        found = true;
        break;
      }
    }
    if (!found) {
        KstObjectItem *i = new KstObjectItem(DataView, *it, this);
        connect(i, SIGNAL(updated()), this, SLOT(doUpdates()));
    }
  }

  KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
  for (KstRVectorList::iterator it = rvl.begin(); it != rvl.end(); ++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->tagName() == (*it)->tagName()) {
        oi->update();
        found = true;
        break;
      }
    }
    if (!found) {
        KstObjectItem *i = new KstObjectItem(DataView, *it, this);
        connect(i, SIGNAL(updated()), this, SLOT(doUpdates()));
    }
  }

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