void ChooseColorDialog::apply() {
  CurveList curveList = _store->getObjects<Curve>();
  for (CurveList::iterator curve_iter = curveList.begin(); curve_iter != curveList.end(); ++curve_iter)
  {
    VectorPtr vector;
    CurvePtr curve = kst_cast<Curve>(*curve_iter);
    if (_xVector->isChecked()) {
      vector = curve->xVector();
    } else {
      vector = curve->yVector();
    }
    if (DataVectorPtr dataVector = kst_cast<DataVector>(vector))
    {
      curve->writeLock();
      curve->setColor(getColorForFile(dataVector->filename()));
      curve->registerChange();
      curve->unlock();
    }
  }
  // Store the selected colors in the corresponding datasource objects
  QMutableMapIterator<DataSourcePtr, QColor> itDatasource(_dataSourceColors);
  QListIterator<ColorButton*> itColorButton(_colorButtons);
  DataSourcePtr ds;
  while (itDatasource.hasNext()) {
    ds = itDatasource.next().key();
    ds->setColor(itColorButton.next()->color()); // Per construction there should always be as many color buttons as datasources
  }

  updateColorGroup(); // This will update the _dataSourceColors map

  UpdateManager::self()->doUpdates(true);
  kstApp->mainWindow()->document()->setChanged(true);
}
Beispiel #2
0
void DifferentiateCurvesDialog::apply() {
  bool lineColorOrder  = !_selectedListBox->findItems(tr("Line Color"), Qt::MatchExactly).empty();
  bool pointStyleOrder = !_selectedListBox->findItems(tr("Point Style"), Qt::MatchExactly).empty();
  bool lineStyleOrder  = !_selectedListBox->findItems(tr("Line Style"), Qt::MatchExactly).empty();
  bool lineWidthOrder  = !_selectedListBox->findItems(tr("Line Width"), Qt::MatchExactly).empty();

  int maxLineWidth = _maxLineWidth->value();
  int pointDensity = _pointDensity->currentIndex();

  int sequenceNum = 0;
  CurveList curveList = _store->getObjects<Curve>();
  for (CurveList::iterator curve_iter = curveList.begin(); curve_iter != curveList.end(); ++curve_iter)
  {
    CurvePtr curve = kst_cast<Curve>(*curve_iter);
    curve->writeLock();
    if (lineColorOrder) {
      curve->setColor(ColorSequence::entry(sequenceNum));
    }
    if (pointStyleOrder) {
      curve->setPointType(sequenceNum % KSTPOINT_MAXTYPE);
      curve->setHasPoints(true);
      curve->setPointDensity(pointDensity);
    }
    if (lineStyleOrder) {
      curve->setLineStyle(sequenceNum % LINESTYLE_MAXTYPE);
    }
    if (lineWidthOrder) {
      curve->setLineWidth((sequenceNum + 1) % maxLineWidth);
    }

    curve->registerChange();
    curve->unlock();
    ++sequenceNum;
  }
  resetLists();

  UpdateManager::self()->doUpdates(true);
  kstApp->mainWindow()->document()->setChanged(true);
}
Beispiel #3
0
void VectorSelector::setToLastX(QString field) {
  if (!_store) {
    return;
  }
  int match = -1;
  VectorList vectors = _store->getObjects<Vector>();
  int size = vectors.size();
  for (int i = 0; i < size; ++i) {
    if (vectors.at(i)->descriptiveName() == field) {
      match = i;
    }
  }

  if (match >-1) {
    setSelectedVector(vectors.at(match));
  } else {
    CurveList objects = _store->getObjects<Curve>();
    if (objects.count()>0) {
      setSelectedVector(objects.at(objects.count()-1)->xVector());
    }
  }
}
Beispiel #4
0
void ChooseColorDialog::apply() {
  CurveList curveList = _store->getObjects<Curve>();
  for (CurveList::iterator curve_iter = curveList.begin(); curve_iter != curveList.end(); ++curve_iter)
  {
    VectorPtr vector;
    CurvePtr curve = kst_cast<Curve>(*curve_iter);
    if (_xVector->isChecked()) {
      vector = curve->xVector();
    } else {
      vector = curve->yVector();
    }
    if (DataVectorPtr dataVector = kst_cast<DataVector>(vector))
    {
      curve->writeLock();
      curve->setColor(getColorForFile(dataVector->dp()->filename()));
      curve->registerChange();
      curve->unlock();
    }
  }
  updateColorGroup();

  UpdateManager::self()->doUpdates(true);
  kstApp->mainWindow()->document()->setChanged(true);
}
Beispiel #5
0
  int ReadData(const char * filename, CurveList & curves,
               CGAL::Bbox_2 & bbox)
  {
    Curve_2 cv;
    char dummy[256];

    std::ifstream inp(filename);
    if (!inp.is_open()) {
      std::cerr << "Cannot open file " << filename << "!" << std::endl;
      return -1;
    }
    int count;
    inp >> count;
    inp.getline(dummy, sizeof(dummy));
    for (int i = 0; i < count; i++) {
      ReadCurve(inp, cv);
      curves.push_back(cv);
      CGAL::Bbox_2 curve_bbox = cv.bbox();
      if (i == 0) bbox = curve_bbox;
      else bbox = bbox + curve_bbox;      
    }
    inp.close();
    return 0;
  }