本文整理汇总了C++中DrawInfo::GetSumUnit方法的典型用法代码示例。如果您正苦于以下问题:C++ DrawInfo::GetSumUnit方法的具体用法?C++ DrawInfo::GetSumUnit怎么用?C++ DrawInfo::GetSumUnit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DrawInfo
的用法示例。
在下文中一共展示了DrawInfo::GetSumUnit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnIdle
void SummaryWindow::OnIdle(wxIdleEvent &event) {
if (!m_active)
return;
bool resize = false;
#define SHOW(wdg, show) \
wdg->Show(show); \
m_values_sizer->Show(wdg, show, true);
if (m_update) {
if (m_summary_draws_count == 0) {
SHOW(m_no_draws_label, true)
SHOW(m_no_draws_line, true)
resize = true;
} else {
for (size_t i = 0; i < m_draws.Count(); ++i) {
ObservedDraw* od = m_draws[i];
if (od == NULL)
continue;
TTLabel *l = m_labels[i];
wxStaticLine *li = m_lines[i];
double val = od->draw->GetValuesTable().m_hsum;
double data_percentage = od->draw->GetValuesTable().m_data_probes_ratio;
if (std::isnan(val) && l->IsShown()) {
SHOW(l, false);
SHOW(li, false);
resize = true;
continue;
}
if (od->draw->GetEnable() == false) {
SHOW(l, false);
SHOW(li, false);
resize = true;
continue;
}
if (!std::isnan(val) && !l->IsShown()) {
SHOW(l, true);
SHOW(li, true);
resize = true;
od->tooltip = true;
m_tooltip = true;
}
od->update = false;
if (l->IsShown() == false)
continue;
Draw* draw = od->draw;
assert(draw);
DrawInfo* info = draw->GetDrawInfo();
assert(info);
//convert unit, idea taken from draw2 :)
wxString sunit = info->GetSumUnit();
wxString unit = info->GetUnit();
wxString text;
if (!sunit.IsEmpty()) {
text = wxString(info->GetValueStr(val, _T(""))) + _T(" ") + sunit;
} else if (unit == _T("kW")) {
text = wxString(info->GetValueStr(val, _T(""))) + _T(" ") + _T("kWh") +
_T(" (") + wxString(info->GetValueStr(val * 3.6 / 1000, _T(""))) + _T(" GJ)");
} else if (unit == _T("MW")) {
text = wxString(info->GetValueStr(val, _T(""))) + _T(" ") + _T("MWh") +
_T(" (") + wxString(info->GetValueStr(val * 3.6, _T(""))) + _T(" GJ)");
} else if (unit.Replace(_T("/h"), _T("")) == 0) {
unit += _T("*h");
text = wxString(info->GetValueStr(val, _T(""))) + _T(" ") + unit;
} else {
text = wxString(info->GetValueStr(val, _T(""))) + _T(" ") + unit;
}
if (!std::isnan(data_percentage) && !(data_percentage > 0.9999))
text += wxString::Format(_T(" (%.2f%%)"), data_percentage * 100);
l->SetValueText(text);
resize = true;
}
if (m_no_draws_label->IsShown()) {
SHOW(m_no_draws_label, false);
SHOW(m_no_draws_line, false);
}
}
}
//.........这里部分代码省略.........