/** @file * @author Edouard DUPIN * @copyright 2011, Edouard DUPIN, all right reserved * @license APACHE v2.0 (see license file) */ #include #include #include appl::widget::DisplayFrequency::DisplayFrequency() : m_gainMin(0.0f), m_gainMax(1.0f), m_frequencyMin(0.0f), m_frequencyMax(24000.0f) { addObjectType("appl::widget::DisplayFrequency"); m_text.setFontSize(13); } void appl::widget::DisplayFrequency::init() { ewol::Widget::init(); markToRedraw(); } appl::widget::DisplayFrequency::~DisplayFrequency() { } void appl::widget::DisplayFrequency::setValue(const std::vector >& _data) { m_data.push_back(_data); markToRedraw(); } void appl::widget::DisplayFrequency::setGainRange(float _min, float _max) { m_gainMin = _min; m_gainMax = _max; markToRedraw(); } void appl::widget::DisplayFrequency::setFrequencyRange(float _min, float _max) { m_frequencyMin = _min; m_frequencyMax = _max; markToRedraw(); } void appl::widget::DisplayFrequency::onDraw() { m_draw.draw(); m_text.draw(); } void appl::widget::DisplayFrequency::onRegenerateDisplay() { //!< Check if we really need to redraw the display, if not needed, we redraw the previous data ... if (needRedraw() == false) { return; } // remove previous data m_draw.clear(); m_text.clear(); m_borderSize = m_size * 0.05; // set background m_draw.setColor(etk::color::black); m_draw.setPos(vec2(0,0)); m_draw.rectangleWidth(m_size); m_draw.setColor(etk::color::gray); m_draw.setPos(m_borderSize); m_draw.setThickness(1); vec2 plop = m_size-m_borderSize; m_draw.lineTo(vec2(m_borderSize.x(), plop.y())); m_draw.lineTo(m_size-m_borderSize); m_draw.lineTo(vec2(plop.x(), m_borderSize.y())); m_draw.lineTo(m_borderSize); if (m_data.size() == 0) { return; } // calculate min and Max : m_gainMax = -999999999.9; m_gainMin = 9999999999.9; m_frequencyMin = 99999999.0; m_frequencyMax = -99999999.0; bool displayLog = true; for (size_t kkk=0; kkk::infinity()) { m_gainMax = std::max(m_gainMax, m_data[kkk][iii].second); m_gainMin = std::min(m_gainMin, m_data[kkk][iii].second); //APPL_INFO("plop " << m_data[kkk][iii].second); } if (displayLog == false) { if (std::abs(m_data[kkk][iii].first) != std::numeric_limits::infinity()) { m_frequencyMax = std::max(m_frequencyMax, m_data[kkk][iii].first); m_frequencyMin = std::min(m_frequencyMin, m_data[kkk][iii].first); } } else { if (std::abs(m_data[kkk][iii].first) != std::numeric_limits::infinity()) { if (m_data[kkk][iii].first == 0) { continue; } m_frequencyMax = std::max(m_frequencyMax, std::log(m_data[kkk][iii].first)); m_frequencyMin = std::min(m_frequencyMin, std::log(m_data[kkk][iii].first)); //APPL_INFO("plop " << m_data[kkk][iii].first << " " << std::log(m_data[kkk][iii].first)); } } } } // TODO : limit unit at a unit value. m_gainMin = int32_t(m_gainMin - 1); m_gainMax = int32_t(m_gainMax + 1); /* for (size_t iii=0; iii