void PlotEntitiesProperty::deletePlotEntitySettings(int index) { if (!dataEmpty()) { if (static_cast<size_t>(index) < value_.size()) value_.erase(value_.begin()+index); notifyAll(); } }
bool PlotEntitiesProperty::setXColumnIndex(int index) { if (dataEmpty() || index < 0 || index >= data_->getColumnCount()) return false; else { xColumnIndex_ = index; notifyAll(); return true; } }
// Pads the buffer with zero samples, and flushes it by converting the remaining samples. void flushBuffer(TRMRingBuffer *ringBuffer) { int index; /* PAD END OF RING BUFFER WITH ZEROS */ for (index = 0; index < (ringBuffer->padSize * 2); index++) dataFill(ringBuffer, 0.0); /* FLUSH UP TO FILL POINTER - PADSIZE */ dataEmpty(ringBuffer); }
bool PlotEntitiesProperty::setYColumnIndex(int index) { if (dataEmpty() || index >= data_->getColumnCount()) return false; else if (entities_ != PlotEntitySettings::SURFACE && entities_ != PlotEntitySettings::SCATTER) return false; else { yColumnIndex_ = index; notifyAll(); return true; } }
// Fills the ring buffer with a single sample, increments // the counters and pointers, and empties the buffer when // full. void dataFill(TRMRingBuffer *ringBuffer, double data) { ringBuffer->buffer[ringBuffer->fillPtr] = data; /* INCREMENT THE FILL POINTER, MODULO THE BUFFER SIZE */ RBIncrement(ringBuffer); /* INCREMENT THE COUNTER, AND EMPTY THE BUFFER IF FULL */ if (++(ringBuffer->fillCounter) >= ringBuffer->fillSize) { dataEmpty(ringBuffer); /* RESET THE FILL COUNTER */ ringBuffer->fillCounter = 0; } }
void PlotEntitiesProperty::setPlotEntitySettings(PlotEntitySettings settings, int index) { if (entities_ == settings.getEntity()) { if (!dataEmpty()) { //new entity if (static_cast<size_t>(index) >= value_.size()) value_.push_back(settings); else { value_.erase(value_.begin()+index); value_.insert(value_.begin()+index, settings); } notifyAll(); } } else throw VoreenException("PlotEntitiesProperty::setPlotEntity: entities do not fit"); }
bool PlotEntitiesProperty::possibleXAxis(int index) { //check if data empty or index out of bounds if (dataEmpty() || index < 0 || index >= data_->getColumnCount()) return false; //for LINE and BAR, label x axis is possible if (data_->getColumnType(index) == PlotBase::STRING) { if (entities_ == PlotEntitySettings::LINE || entities_ == PlotEntitySettings::BAR) return true; else return false; } //number column is good enough (but for LINE it must be a key column) if (data_->getColumnType(index) == PlotBase::NUMBER && (entities_ != PlotEntitySettings::LINE || index <= data_->getKeyColumnCount())) return true; else return false; }
bool PlotEntitiesProperty::possibleYAxis(int index) { //check if data empty or index out of bounds if (dataEmpty() || index < -1 || index >= data_->getColumnCount()) return false; //-1 isn't possible for SURFACE otherwise is it possible if (index == -1) { if (entities_ == PlotEntitySettings::SURFACE) return false; else return true; } if ((entities_ == PlotEntitySettings::SURFACE || entities_ == PlotEntitySettings::SCATTER) && data_->getColumnType(index) == PlotBase::NUMBER) return true; else return false; }
void PlotEntitiesProperty::applyColormap() { if (!dataEmpty()) { ColorMap::GeneratingIterator cmit = colorMap_.getGeneratingIterator(); for (size_t i = 0; i < value_.size(); ++i) { PlotEntitySettings es(value_.at(i)); if(!(data_ && ((int)i < data_->getColumnCount()) && !data_->hasColumnColorHint((int)i))) { es.setFirstColor(*cmit); ++cmit; if (es.getEntity() == PlotEntitySettings::LINE) { es.setSecondColor(*cmit); //++cmit; } else if (es.getEntity() == PlotEntitySettings::SURFACE) { es.setSecondColor(tgt::Color(0.f, 0.f, 0.f, 1.f)); } } setPlotEntitySettings(es, static_cast<int>(i)); } } }
void PlotEntitiesProperty::setPlotData(const PlotData* data) { data_ = data; dataValidFlag_ = false; int possibleXIndex = 0; int possibleYIndex = -1; if (!dataEmpty()) { switch (entities_) { case PlotEntitySettings::LINE: case PlotEntitySettings::BAR: { //check if there is a possible x axis bool xAxisFound = false; //check if there is another number column as y axis bool dataAxisFound = false; for (int i = 0; i < data_->getColumnCount(); ++i) { if (possibleXAxis(i) && !xAxisFound) { xAxisFound = true; possibleXIndex = i; continue; } if (data_->getColumnType(i) == PlotBase::NUMBER) dataAxisFound = true; } dataValidFlag_ = (xAxisFound && dataAxisFound); break; } case PlotEntitySettings::SURFACE: { bool xAxisFound = false; bool yAxisFound = false; bool dataAxisFound = false; for (int i = 0; i < data_->getColumnCount(); ++i) { if (possibleXAxis(i) && !xAxisFound) { xAxisFound = true; possibleXIndex = i; continue; } if (possibleYAxis(i) && !yAxisFound) { yAxisFound = true; possibleYIndex = i; continue; } if (data_->getColumnType(i) == PlotBase::NUMBER) dataAxisFound = true; } dataValidFlag_ = (xAxisFound && yAxisFound && dataAxisFound); break; } case PlotEntitySettings::SCATTER: { bool xAxisFound = false; bool dataAxisFound = false; for (int i = 0; i < data_->getColumnCount(); ++i) { if (possibleXAxis(i) && !xAxisFound) { xAxisFound = true; possibleXIndex = i; continue; } if (data_->getColumnType(i) == PlotBase::NUMBER) dataAxisFound = true; } dataValidFlag_ = (xAxisFound && dataAxisFound); break; } default : break; } } //possible reset if (dataEmpty() || !possibleXAxis(xColumnIndex_) || !possibleYAxis(yColumnIndex_)) { xColumnIndex_ = possibleXIndex; yColumnIndex_ = possibleYIndex; value_.clear(); if (possibleXAxis(xColumnIndex_) && possibleYAxis(yColumnIndex_)){ value_ = createAllEntitySettings(); } } else { switch(loadStrategy_) { case LS_ALL: xColumnIndex_ = possibleXIndex; yColumnIndex_ = possibleYIndex; value_.clear(); if (possibleXAxis(xColumnIndex_) && possibleYAxis(yColumnIndex_)){ value_ = createAllEntitySettings(); } break; case LS_NON: case LS_NEW: bool reset = false; for (size_t i = 0; i < value_.size(); ++i) { if (!value_.at(i).fitsTo(data_)) { xColumnIndex_ = possibleXIndex; yColumnIndex_ = possibleYIndex; value_.clear(); if (possibleXAxis(xColumnIndex_) && possibleYAxis(yColumnIndex_)){ value_ = createAllEntitySettings(); } reset = true; break; } } // adjust colors to color hints: if(!reset) { for (size_t i=0; i<value_.size(); ++i) { int ci = value_.at(i).getMainColumnIndex(); if (data_->hasColumnColorHint(ci)) { value_[i].setFirstColor(data_->getColumnColorHint(ci)); } } } if(loadStrategy_ == LS_NON) break; //FIXME: if size is not well if(value_.size() < static_cast<size_t>(data_->getDataColumnCount())){ value_ = addEntitySettings(); //< function also not well } } } notifyAll(); }