コード例 #1
0
QPixmap symbolChooser::createSymbol(int index, const triC& color) const {

  const int drawDimension = symbolDimension_ - 2 * borderDimension_;
  QPixmap drawSymbol(drawDimension, drawDimension);
  drawSymbol.fill(Qt::white);
  if (index < numberOfSymbols()) {
    QPainter painter(&drawSymbol);
    painter.setRenderHint(QPainter::Antialiasing, true);
    const int interval = unicodeCharacters_.size();
    // type1 symbol doesn't need further editing
    if (index >= interval && index < 2*interval) {
      index -= interval;
      createSymbolType2(&painter, drawDimension);
    }
    else if (index >= 2*interval && index < 3*interval) {
      index -= 2*interval;
      createSymbolType3(&painter, drawDimension);
    }
    else if (index >= 3*interval && index < 4*interval) {
      index -= 3*interval;
      createSymbolType4(&painter, drawDimension);
    }
    const QChar symbolChar = unicodeCharacters_[index];
    const QString symbolString(symbolChar);
    painter.setFont(unicodeFont_.qFont());
    const int heightBuffer = 2;
    ::setFontHeight(&painter, drawDimension - heightBuffer);
    const QRect textRect(0, heightBuffer/2, drawDimension,
                         drawDimension - heightBuffer/2);
    painter.drawText(textRect, Qt::AlignCenter, symbolString);
  }
  else { // no symbols left, so just make it the original color
    QPainter painter(&drawSymbol);
    painter.setRenderHint(QPainter::Antialiasing, true);
    painter.fillRect(0, 0, drawDimension, drawDimension, color.qc());
  }

  if (borderDimension_) {
    QPixmap newSymbol(symbolDimension_, symbolDimension_);
    newSymbol.fill(color.qrgb());
    QPainter painter(&newSymbol);
    painter.setRenderHint(QPainter::Antialiasing, true);
    painter.drawPixmap(QPoint(borderDimension_, borderDimension_),
                       drawSymbol);
    return newSymbol;
  }
  else {
    return drawSymbol;
  }
}
コード例 #2
0
ファイル: SymbolBox.cpp プロジェクト: DanNixon/mantid
int SymbolBox::symbolIndex(const QwtSymbol::Style &style) {
  // Avoid compiler warnings relating to symbols + sizeof(symbols) being out of
  // range
  size_t n = numberOfSymbols();
  for (size_t i = 0; i < n; ++i) {
    if (symbols[i] == style) {
      return int(i);
    }
  }
  return 0;
  //  const QwtSymbol::Style*ite = std::find(symbols, symbols + sizeof(symbols),
  //  style);
  //  if (ite == symbols + sizeof(symbols))
  //    return 0;
  //
  //  return (int(ite - symbols));
}
コード例 #3
0
ファイル: SymbolBox.cpp プロジェクト: DanNixon/mantid
void SymbolBox::setStyle(const QwtSymbol::Style &style) {
  // Avoid compiler warnings relating to symbols + sizeof(symbols) being out of
  // range
  size_t n = numberOfSymbols();
  for (size_t i = 0; i < n; ++i) {
    if (symbols[i] == style) {
      setCurrentIndex(int(i));
      return;
    }
  }
  setCurrentIndex(0);
  //  const QwtSymbol::Style*ite = std::find(symbols, symbols + sizeof(symbols),
  //  style);
  //  if (ite == symbols + sizeof(symbols))
  //    this->setCurrentIndex(0);
  //  else
  //    this->setCurrentIndex(int(ite - symbols));
}
コード例 #4
0
symbolChooser::symbolChooser(int symbolDimension, const QVector<triC>& colors,
                             int borderDimension)
  : colors_(colors), symbolDimension_(symbolDimension),
    borderDimension_(borderDimension) {

  std::sort(colors_.begin(), colors_.end(), triCIntensityDefinite());
  initializeSymbolList();
  const int colorCount = colors_.size();
  const int characterCount = unicodeCharacters_.size();
  // use "just enough" symbols to cover the number of colors we need
  for (int i = 1; i <= MAX_NUM_SYMBOL_TYPES; ++i) {
    numSymbolTypes_ = i;
    if (numSymbolTypes_ * characterCount >= colorCount + 30) {
      break;
    }
  }
  colorIndex_ = stepIndex(0, numberOfSymbols(), 1);
  // it's possible these symbols will never get used with the default values, but
  // we still need to establish the color-->symbol correspondence here
  for (int i = 0, size = colors_.size(); i < size; ++i) {
    createNewSymbolCurDims(colors_[i].qrgb());
  }
}
コード例 #5
0
ファイル: SymbolBox.cpp プロジェクト: DanNixon/mantid
QwtSymbol::Style SymbolBox::style(int index) {
  if (index >= 0 && index < (int)numberOfSymbols())
    return symbols[index];

  return QwtSymbol::NoSymbol;
}