Histogram<> Spectrum1DWidget::createMetaDistribution_(const String& name) const
  {
    Histogram<> tmp;
    //float arrays
    const ExperimentType::SpectrumType::FloatDataArrays& f_arrays = (*canvas_->getCurrentLayer().getPeakData())[0].getFloatDataArrays();
    for (ExperimentType::SpectrumType::FloatDataArrays::const_iterator it = f_arrays.begin(); it != f_arrays.end(); ++it)
    {
      if (it->getName() == name)
      {
        //determine min and max of the data
        float min = numeric_limits<float>::max(), max = -numeric_limits<float>::max();
        for (Size i = 0; i < it->size(); ++i)
        {
          if ((*it)[i] < min)
            min = (*it)[i];
          if ((*it)[i] > max)
            max = (*it)[i];
        }
        if (min >= max)
          return tmp;

        //create histogram
        tmp.reset(min, max, (max - min) / 500.0);
        for (Size i = 0; i < it->size(); ++i)
        {
          tmp.inc((*it)[i]);
        }
      }
    }
    //integer arrays
    const ExperimentType::SpectrumType::IntegerDataArrays& i_arrays = (*canvas_->getCurrentLayer().getPeakData())[0].getIntegerDataArrays();
    for (ExperimentType::SpectrumType::IntegerDataArrays::const_iterator it = i_arrays.begin(); it != i_arrays.end(); ++it)
    {
      if (it->getName() == name)
      {
        //determine min and max of the data
        float min = numeric_limits<float>::max(), max = -numeric_limits<float>::max();
        for (Size i = 0; i < it->size(); ++i)
        {
          if ((*it)[i] < min)
            min = (*it)[i];
          if ((*it)[i] > max)
            max = (*it)[i];
        }
        if (min >= max)
          return tmp;

        //create histogram
        tmp.reset(min, max, (max - min) / 500.0);
        for (Size i = 0; i < it->size(); ++i)
        {
          tmp.inc((*it)[i]);
        }
      }
    }
    //fallback if no array with that name exists
    return tmp;
  }
  Histogram<> Spectrum2DWidget::createMetaDistribution_(const String& name) const
  {
    Histogram<> tmp;

    if (canvas_->getCurrentLayer().type == LayerData::DT_PEAK)
    {
      //determine min and max of the data
      float min = numeric_limits<float>::max(), max = -numeric_limits<float>::max();
      for (ExperimentType::const_iterator s_it = canvas_->getCurrentLayer().getPeakData()->begin(); s_it != canvas_->getCurrentLayer().getPeakData()->end(); ++s_it)
      {
        if (s_it->getMSLevel() != 1)
          continue;
        //float arrays
        for (ExperimentType::SpectrumType::FloatDataArrays::const_iterator it = s_it->getFloatDataArrays().begin(); it != s_it->getFloatDataArrays().end(); ++it)
        {
          if (it->getName() == name)
          {
            for (Size i = 0; i < it->size(); ++i)
            {
              if ((*it)[i] < min)
                min = (*it)[i];
              if ((*it)[i] > max)
                max = (*it)[i];
            }
            break;
          }
        }
        //integer arrays
        for (ExperimentType::SpectrumType::IntegerDataArrays::const_iterator it = s_it->getIntegerDataArrays().begin(); it != s_it->getIntegerDataArrays().end(); ++it)
        {
          if (it->getName() == name)
          {
            for (Size i = 0; i < it->size(); ++i)
            {
              if ((*it)[i] < min)
                min = (*it)[i];
              if ((*it)[i] > max)
                max = (*it)[i];
            }
            break;
          }
        }
      }
      if (min >= max)
        return tmp;

      //create histogram
      tmp.reset(min, max, (max - min) / 500.0);
      for (ExperimentType::const_iterator s_it = canvas_->getCurrentLayer().getPeakData()->begin(); s_it != canvas_->getCurrentLayer().getPeakData()->end(); ++s_it)
      {
        if (s_it->getMSLevel() != 1)
          continue;
        //float arrays
        for (ExperimentType::SpectrumType::FloatDataArrays::const_iterator it = s_it->getFloatDataArrays().begin(); it != s_it->getFloatDataArrays().end(); ++it)
        {
          if (it->getName() == name)
          {
            for (Size i = 0; i < it->size(); ++i)
            {
              tmp.inc((*it)[i]);
            }
            break;
          }
        }
        //integer arrays
        for (ExperimentType::SpectrumType::IntegerDataArrays::const_iterator it = s_it->getIntegerDataArrays().begin(); it != s_it->getIntegerDataArrays().end(); ++it)
        {
          if (it->getName() == name)
          {
            for (Size i = 0; i < it->size(); ++i)
            {
              tmp.inc((*it)[i]);
            }
            break;
          }
        }
      }
    }
    else //Features
    {
      //determine min and max
      float min = numeric_limits<float>::max(), max = -numeric_limits<float>::max();
      for (Spectrum2DCanvas::FeatureMapType::ConstIterator it = canvas_->getCurrentLayer().getFeatureMap()->begin(); it != canvas_->getCurrentLayer().getFeatureMap()->end(); ++it)
      {
        if (it->metaValueExists(name))
        {
          float value = it->getMetaValue(name);
          if (value < min)
            min = value;
          if (value > max)
            max = value;
        }
      }
      //create histogram
      tmp.reset(min, max, (max - min) / 500.0);
      for (Spectrum2DCanvas::FeatureMapType::ConstIterator it = canvas_->getCurrentLayer().getFeatureMap()->begin(); it != canvas_->getCurrentLayer().getFeatureMap()->end(); ++it)
      {
        if (it->metaValueExists(name))
        {
          tmp.inc((float)(it->getMetaValue(name)));
        }
      }

    }

    return tmp;
  }
Example #3
0
  Histogram<> Spectrum3DWidget::createMetaDistribution_(const String & name) const
  {
    Histogram<> tmp;

    //determine min and max of the data
    Real m_min = (numeric_limits<Real>::max)(), m_max = -(numeric_limits<Real>::max)();
    for (ExperimentType::const_iterator s_it = canvas_->getCurrentLayer().getPeakData()->begin(); s_it != canvas_->getCurrentLayer().getPeakData()->end(); ++s_it)
    {
      if (s_it->getMSLevel() != 1)
        continue;
      //float arrays
      for (ExperimentType::SpectrumType::FloatDataArrays::const_iterator it = s_it->getFloatDataArrays().begin(); it != s_it->getFloatDataArrays().end(); ++it)
      {
        if (it->getName() == name)
        {
          for (Size i = 0; i < it->size(); ++i)
          {
            if ((*it)[i] < m_min)
              m_min = (*it)[i];
            if ((*it)[i] > m_max)
              m_max = (*it)[i];
          }
          break;
        }
      }
      //integer arrays
      for (ExperimentType::SpectrumType::IntegerDataArrays::const_iterator it = s_it->getIntegerDataArrays().begin(); it != s_it->getIntegerDataArrays().end(); ++it)
      {
        if (it->getName() == name)
        {
          for (Size i = 0; i < it->size(); ++i)
          {
            if ((*it)[i] < m_min)
              m_min = (*it)[i];
            if ((*it)[i] > m_max)
              m_max = (*it)[i];
          }
          break;
        }
      }
    }
    if (m_min >= m_max)
      return tmp;

    //create histogram
    tmp.reset(m_min, m_max, (m_max - m_min) / 500.0);
    for (ExperimentType::const_iterator s_it = canvas_->getCurrentLayer().getPeakData()->begin(); s_it != canvas_->getCurrentLayer().getPeakData()->end(); ++s_it)
    {
      if (s_it->getMSLevel() != 1)
        continue;
      //float arrays
      for (ExperimentType::SpectrumType::FloatDataArrays::const_iterator it = s_it->getFloatDataArrays().begin(); it != s_it->getFloatDataArrays().end(); ++it)
      {
        if (it->getName() == name)
        {
          for (Size i = 0; i < it->size(); ++i)
          {
            tmp.inc((*it)[i]);
          }
          break;
        }
      }
      //integer arrays
      for (ExperimentType::SpectrumType::IntegerDataArrays::const_iterator it = s_it->getIntegerDataArrays().begin(); it != s_it->getIntegerDataArrays().end(); ++it)
      {
        if (it->getName() == name)
        {
          for (Size i = 0; i < it->size(); ++i)
          {
            tmp.inc((*it)[i]);
          }
          break;
        }
      }
    }

    return tmp;
  }