Ejemplo n.º 1
0
void KstGuiDialogs::newMatrixDialog(QWidget *parent, const char *createdSlot, const char *selectedSlot, const char *updateSlot) {
  KstMatrixDialogI *ad = new KstMatrixDialogI(parent, "matrix dialog");
  if (createdSlot) {
    QObject::connect(ad, SIGNAL(matrixCreated(KstMatrixPtr)), parent, createdSlot);
  }
  if (selectedSlot) {
    QObject::connect(ad, SIGNAL(matrixCreated(KstMatrixPtr)), parent, selectedSlot);
  }
  if (updateSlot) {
    QObject::connect(ad, SIGNAL(modified()), parent, updateSlot);
  }
  ad->show();
  ad->exec();
  delete ad;
}
Ejemplo n.º 2
0
bool KstMatrixDialog::new_ISMatrix() {
  KstSMatrixPtr matrix;
  QString tagPart = _w->_gradientZAtMin->text() + "-" + _w->_gradientZAtMax->text();
  QString tagName = (_tagName->text() == "<New_Matrix>") ? KST::suggestMatrixName(tagPart) : _tagName->text();
  double zMin, zMax, xStep, yStep, minX, minY;
  bool xDirection, ok1, ok2, ok3, ok4, ok5, ok6;
  int nX, nY;

  if (KstData::self()->matrixTagNameNotUnique(tagName)) {
    _tagName->setFocus();

    return false;
  }

  xDirection = _w->_gradientX->isChecked();
  zMin = _w->_gradientZAtMin->text().toDouble(&ok1);
  zMax = _w->_gradientZAtMax->text().toDouble(&ok2);
  nX = _w->_nX->value();
  nY = _w->_nY->value();

  xStep = _w->_xStep->text().toDouble(&ok3);
  yStep = _w->_yStep->text().toDouble(&ok4);
  minX = _w->_minX->text().toDouble(&ok5);
  minY = _w->_minY->text().toDouble(&ok6);

  if (!checkParameters(ok3, ok4, ok5, ok6, xStep, yStep)) {
    return false;
  }

  if (!ok1 || !ok2) {
    QMessageBox::warning(this, QObject::tr("Kst"), QObject::tr("Invalid gradient bounds.  Ensure only decimal values are entered."));

    return false;
  }

  matrix = new KstSMatrix(KstObjectTag(tagName, KstObjectTag::globalTagContext),
      nX, nY, minX, minY, xStep, yStep, zMin, zMax, xDirection);

  emit matrixCreated(KstMatrixPtr(matrix));

  matrix = 0L; // drop the reference

  emit modified();

  return true;
}
Ejemplo n.º 3
0
bool KstMatrixDialogI::new_ISMatrix() {
  //create a unique name
  QString tagPart = _w->_gradientZAtMin->text() + "-" + _w->_gradientZAtMax->text();
  QString tag_name = (_tagName->text() == "<New_Matrix>") ? KST::suggestMatrixName(tagPart) : _tagName->text();
  if (KstData::self()->matrixTagNameNotUnique(tag_name)) {
    _tagName->setFocus();
    return false;
  }

  // get parameters
  bool xDirection, ok1, ok2, ok3, ok4, ok5, ok6;
  double zMin, zMax, xStep, yStep, minX, minY;
  int nX, nY;

  xDirection = _w->_gradientX->isChecked();
  zMin = _w->_gradientZAtMin->text().toDouble(&ok1);
  zMax = _w->_gradientZAtMax->text().toDouble(&ok2);
  nX = _w->_nX->value();
  nY = _w->_nY->value();

  xStep = _w->_xStep->text().toDouble(&ok3);
  yStep = _w->_yStep->text().toDouble(&ok4);
  minX = _w->_minX->text().toDouble(&ok5);
  minY = _w->_minY->text().toDouble(&ok6);

  if (!checkParameters(ok3, ok4, ok5, ok6, xStep, yStep)) {
    return false;
  }
  if (!ok1 || !ok2) {
    KMessageBox::sorry(this, i18n("Invalid gradient bounds.  Ensure only decimal values are entered."));
    return false;
  }

  KstSMatrixPtr matrix = new KstSMatrix(tag_name, nX, nY, minX, minY, xStep, yStep, zMin, zMax, xDirection);

  KST::addMatrixToList(KstMatrixPtr(matrix));

  emit matrixCreated(KstMatrixPtr(matrix));
  matrix = 0L; // drop the reference
  emit modified();
  return true;
}
Ejemplo n.º 4
0
bool KstMatrixDialog::new_IRMatrix() {
  KstDataSourcePtr file;
  KstRMatrixPtr matrix;
  KstDataSourceList::iterator it;
  QString pField;
  QString tagName;
  bool doSkip;
  bool doAve;
  int xStart = _w->_xStartCountFromEnd->isChecked() ? -1 : _w->_xStart->value();
  int yStart = _w->_yStartCountFromEnd->isChecked() ? -1 : _w->_yStart->value();
  int xNumSteps = _w->_xNumStepsReadToEnd->isChecked() ? -1 : _w->_xNumSteps->value();
  int yNumSteps = _w->_yNumStepsReadToEnd->isChecked() ? -1 : _w->_yNumSteps->value();
  int skip;

  //
  // create a unique name...
  //

  tagName = (_tagName->text() == "<New_Matrix>") ? KST::suggestMatrixName(_w->_field->currentText()) : _tagName->text();
  if (KstData::self()->matrixTagNameNotUnique(tagName)) {
    _tagName->setFocus();

    return false;
  }

  //
  // if there is not an active KstFile, create one...
  //

  KST::dataSourceList.lock().writeLock();
// xxx  it = KST::dataSourceList.findReusableFileName(_w->_fileName->url());

  if (it == KST::dataSourceList.end()) {
// xxx    file = KstDataSource::loadSource(_w->_fileName->url());
    if (!file || !file->isValid()) {
      KST::dataSourceList.lock().unlock();
      QMessageBox::warning(this, QObject::tr("Kst"), QObject::tr("The file could not be opened."));

      return false;
    }

    if (file->isEmpty()) {
      KST::dataSourceList.lock().unlock();
      QMessageBox::warning(this, QObject::tr("Kst"), QObject::tr("The file does not contain data."));

      return false;
    }
    KST::dataSourceList.append(file);
  } else {
    file = *it;
  }
  KST::dataSourceList.lock().unlock();

  pField = _w->_field->currentText();

  if (!file->isValidMatrix(pField)) {
    QMessageBox::warning(this, QObject::tr("Kst"), QObject::tr("The requested matrix is not defined for the requested file."));
    file->unlock();

    return false;
  }

  doSkip = _w->_doSkip->isChecked();
  doAve = _w->_doAve->isChecked();
  skip = _w->_skip->value();

  matrix = new KstRMatrix(file, pField, KstObjectTag(tagName, file->tag(), false),
                          xStart, yStart, xNumSteps, yNumSteps, doAve, doSkip, skip);

  emit matrixCreated(KstMatrixPtr(matrix));

  matrix = 0L; // drop the reference

  emit modified();

  return true;
}
Ejemplo n.º 5
0
bool KstMatrixDialogI::new_IRMatrix() {
  //check the parameters
  int xStart = _w->_xStartCountFromEnd->isChecked() ? -1 : _w->_xStart->value();
  int yStart = _w->_yStartCountFromEnd->isChecked() ? -1 : _w->_yStart->value();
  int xNumSteps = _w->_xNumStepsReadToEnd->isChecked() ? -1 : _w->_xNumSteps->value();
  int yNumSteps = _w->_yNumStepsReadToEnd->isChecked() ? -1 : _w->_yNumSteps->value();

  //create a unique name
  QString tag_name = (_tagName->text() == "<New_Matrix>") ? KST::suggestMatrixName(_w->_field->currentText()) : _tagName->text();
  if (KstData::self()->matrixTagNameNotUnique(tag_name)) {
    _tagName->setFocus();
    return false;
  }

  // get the data source and matrix field from datasource
  KstDataSourcePtr file;
  QString pField;

  /* if there is not an active KstFile, create one */
  KST::dataSourceList.lock().writeLock();
  KstDataSourceList::Iterator it = KST::dataSourceList.findReusableFileName(_w->_fileName->url());

  if (it == KST::dataSourceList.end()) {
    file = KstDataSource::loadSource(_w->_fileName->url());
    if (!file || !file->isValid()) {
      KST::dataSourceList.lock().unlock();
      KMessageBox::sorry(this, i18n("The file could not be opened."));
      return false;
    }
    if (file->isEmpty()) {
      KST::dataSourceList.lock().unlock();
      KMessageBox::sorry(this, i18n("The file does not contain data."));
      return false;
    }
    KST::dataSourceList.append(file);
  } else {
    file = *it;
  }
  KST::dataSourceList.lock().unlock();

  pField = _w->_field->currentText();
  if (!file->isValidMatrix(pField)) {
    KMessageBox::sorry(this, i18n("The requested matrix is not defined for the requested file."));
    file->unlock();
    return false;
  }

  // skipping parameters
  bool doSkip = _w->_doSkip->isChecked();
  bool doAve = _w->_doAve->isChecked();
  int skip = _w->_skip->value();

  KstRMatrixPtr matrix = new KstRMatrix(file, pField, tag_name,
                                        xStart, yStart, xNumSteps, yNumSteps,
                                        doAve, doSkip, skip);

  KST::addMatrixToList(KstMatrixPtr(matrix));
  emit matrixCreated(KstMatrixPtr(matrix));
  matrix = 0L; // drop the reference
  emit modified();

  return true;
}