void GainCanvas::updateGainUI() { SDRDeviceInfo *devInfo = wxGetApp().getDevice(); DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(devInfo->getDeviceId()); gains = devInfo->getGains(SOAPY_SDR_RX, 0); SDRRangeMap::iterator gi; numGains = gains.size(); float i = 0; if (!numGains) { return; } spacing = 2.0/numGains; barWidth = (1.0/numGains)*0.7; startPos = spacing/2.0; barHeight = 1.0f; while (gainPanels.size()) { MeterPanel *mDel = gainPanels.back(); gainPanels.pop_back(); bgPanel.removeChild(mDel); delete mDel; } for (auto gi : gains) { MeterPanel *mPanel = new MeterPanel(gi.first, gi.second.minimum(), gi.second.maximum(), devConfig->getGain(gi.first,wxGetApp().getGain(gi.first))); float midPos = -1.0+startPos+spacing*i; mPanel->setPosition(midPos, 0); mPanel->setSize(barWidth, barHeight); bgPanel.addChild(mPanel); gainPanels.push_back(mPanel); i++; } setThemeColors(); }
void GainCanvas::updateGainUI() { const wxSize ClientSize = GetClientSize(); SDRDeviceInfo *devInfo = wxGetApp().getDevice(); std::vector<SDRDeviceRange> &gains = devInfo->getRxChannel()->getGains(); std::vector<SDRDeviceRange>::iterator gi; numGains = gains.size(); float i = 0; if (!numGains) { return; } spacing = 2.0/numGains; barWidth = (1.0/numGains)*0.7; startPos = spacing/2.0; barHeight = 0.8; RGBA4f c1, c2; while (gainInfo.size()) { GainInfo *giDel; giDel = gainInfo.back(); gainInfo.pop_back(); giDel->panel.removeChild(&giDel->levelPanel); bgPanel.removeChild(&(giDel->labelPanel)); bgPanel.removeChild(&(giDel->valuePanel)); bgPanel.removeChild(&(giDel->panel)); delete giDel; } for (gi = gains.begin(); gi != gains.end(); gi++) { GainInfo *gInfo = new GainInfo; float midPos = -1.0+startPos+spacing*i; gInfo->name = (*gi).getName(); gInfo->low = (*gi).getLow(); gInfo->high = (*gi).getHigh(); gInfo->current = wxGetApp().getGain(gInfo->name); gInfo->panel.setBorderPx(1); gInfo->panel.setFill(GLPanel::GLPANEL_FILL_GRAD_BAR_X); gInfo->panel.setPosition(midPos, 0); gInfo->panel.setSize(barWidth, barHeight); gInfo->panel.setBlend(GL_ONE, GL_ONE); gInfo->levelPanel.setBorderPx(0); gInfo->levelPanel.setMarginPx(1); gInfo->levelPanel.setSize(1.0,0.8); float levelVal = float(gInfo->current-gInfo->low)/float(gInfo->high-gInfo->low); gInfo->levelPanel.setSize(1.0, levelVal); gInfo->levelPanel.setPosition(0.0, (-1.0+(levelVal))); gInfo->levelPanel.setFill(GLPanel::GLPANEL_FILL_GRAD_BAR_X); gInfo->levelPanel.setBlend(GL_ONE, GL_ONE); gInfo->panel.addChild(&gInfo->levelPanel); gInfo->highlightPanel.setBorderPx(0); gInfo->highlightPanel.setMarginPx(1); gInfo->highlightPanel.setSize(1.0,0.8); gInfo->highlightPanel.setPosition(0.0,-0.2); gInfo->highlightPanel.setFill(GLPanel::GLPANEL_FILL_GRAD_BAR_X); gInfo->highlightPanel.setBlend(GL_ONE, GL_ONE); gInfo->highlightPanel.visible = false; gInfo->panel.addChild(&gInfo->highlightPanel); gInfo->labelPanel.setSize(spacing/2.0,(15.0/float(ClientSize.y))); gInfo->labelPanel.setPosition(midPos, -barHeight-(20.0/float(ClientSize.y))); gInfo->labelPanel.setText((*gi).getName()); gInfo->labelPanel.setFill(GLPanel::GLPANEL_FILL_NONE); bgPanel.addChild(&(gInfo->labelPanel)); gInfo->valuePanel.setSize(spacing/2.0,(15.0/float(ClientSize.y))); gInfo->valuePanel.setPosition(midPos, barHeight+(20.0/float(ClientSize.y))); gInfo->valuePanel.setText(std::to_string(int(gInfo->current))); gInfo->valuePanel.setFill(GLPanel::GLPANEL_FILL_NONE); bgPanel.addChild(&(gInfo->valuePanel)); bgPanel.addChild(&(gInfo->panel)); gainInfo.push_back(gInfo); i++; } setThemeColors(); }