Example #1
0
std::set<std::set<int> > DrawsPrintout::ChooseDraws() {

	int count;
	if (wxConfig::Get()->Read(_T("MaxPrintedAxesNumber"), &count) == false)
		count = 3;
	if (count < 1)
		count = 1;

	Axis sr;
	std::tr1::unordered_map<Axis, std::set<int>, AxisHasher> ranges;

	for (int i = 0; i < m_draws_count; ++i) {

		Draw* draw = m_draws[i];

		if (!draw->GetEnable())
			continue;

		Axis r;
		r.min = draw->GetDrawInfo()->GetMin();
		r.max = draw->GetDrawInfo()->GetMax();
		r.prec = draw->GetDrawInfo()->GetPrec();
		r.unit = draw->GetDrawInfo()->GetUnit();

		for (auto it = ranges.begin(); it!=ranges.end(); ++it) // for each axis in ranges
		{
			if (it->first.min == r.min && it->first.max == r.max && it->first.unit == r.unit) // check, if they differ only by precision. If so, change the axis
			{
				if (it->first.prec < r.prec) r.prec = it->first.prec;
				else {
					for (auto jt = ranges[it->first].begin(); jt != ranges[it->first].end(); ++jt)
						ranges[r].insert(*jt);

					if (sr == it->first)
						sr = r;
				}
			}
		}

		if (m_draws[i]->GetSelected())
			sr = r;

		ranges[r].insert(i);

	}

	std::set<std::set<int> > ret;
	std::tr1::unordered_map<Axis, std::set<int>, AxisHasher>::iterator it = ranges.begin();
	for (int added = 0; added < count - 1 && it != ranges.end(); it++) {
		if (it->first == sr)
			continue;
		added++;
		ret.insert(it->second);
	}
	ret.insert(ranges[sr]);

	return ret;

}
Example #2
0
wxString DrawsWidget::GetUrl(bool with_infinity) {
	Draw* d = m_draws_controller->GetSelectedDraw();
	if (d == NULL)
		return wxEmptyString;

	time_t t;

	if (with_infinity && m_draws_controller->AtTheNewestValue()) {
		t = std::numeric_limits<time_t>::max();
	} else {
		t = GetCurrentTime().GetTicks();
	}

	wxString prefix = m_draws_controller->GetSet()->GetDrawsSets()->GetPrefix();

	DrawInfo* di = d->GetDrawInfo();

	SetInfoDataObject* wido =
		new SetInfoDataObject(prefix, di->GetSetName(), d->GetPeriod(), t , d->GetDrawNo());

	wxString tmp = wido->GetUrl();

	delete wido;

	return tmp;
}
Example #3
0
void RemarksFetcher::OnRemarksResponse(RemarksResponseEvent &e) {
    std::vector<Remark>& remarks = e.GetRemarks();

    Draw* d = m_draws_controller->GetSelectedDraw();
    if (d == NULL)
        return;

    ConfigNameHash& cnh = d->GetDrawInfo()->GetDrawsSets()->GetParentManager()->GetConfigTitles();
    for (std::vector<Remark>::iterator i = remarks.begin();
            i != remarks.end();
            i++) {
        ConfigNameHash::iterator j = cnh.find(i->GetPrefix());

        if (j != cnh.end())
            i->SetBaseName(j->second.c_str());
    }

    if (e.GetResponseType() == RemarksResponseEvent::BASE_RESPONSE) {
        if (!m_awaiting_for_whole_base)
            return;
        m_awaiting_for_whole_base = false;


        RemarksListDialog *d = new RemarksListDialog(m_draw_frame, m_remarks_handler);
        d->SetViewedRemarks(remarks);
        d->ShowModal();
        d->Destroy();
    } else
        RemarksReceived(remarks);
}
Example #4
0
void RemarksFetcher::RemarksReceived(std::vector<Remark>& remarks) {

    Draw* d = m_draws_controller->GetSelectedDraw();
    if (d == NULL)
        return;

    DrawInfo* di = d->GetDrawInfo();

    wxDateTime start = d->GetTimeOfIndex(0);
    wxDateTime end = d->GetTimeOfIndex(d->GetValuesTable().size());

    wxString prefix = di->GetBasePrefix();
    wxString set = di->GetSetName();
    std::vector<wxDateTime> remarks_times;

    for (std::vector<Remark>::iterator i = remarks.begin(); i != remarks.end(); i++) {
        wxDateTime rt = i->GetTime();

        std::wstring rset = i->GetSet();

        if (prefix != i->GetAttachedPrefix()
                || (!rset.empty() && set != rset)
                || rt < start
                || rt >= end)
            continue;

        remarks_times.push_back(rt);
        m_remarks[i->GetId()] = *i;

    }

    if (remarks_times.size()) {
        d->SetRemarksTimes(remarks_times);
    }
}
Example #5
0
void SelectDrawWidget::InsertSomeDraws(size_t start, size_t count) {
	wxSizer *sizer = GetSizer();
	int width = GetCheckBoxWidth();
	ConfigNameHash& cnm = const_cast<ConfigNameHash&>(m_cfg->GetConfigTitles());

	for (size_t i = start; count; count--, i++) {
		if (i >= m_cb_l.size()) {
			i = m_cb_l.size();
			m_cb_l.push_back(new wxCheckBox());
			m_cb_l[i]->Create(this, drawID_SELDRAWCB,
				wxString::Format(_T("%d."), i + 1),
				wxDefaultPosition, wxSize(width, -1), 0,
				SelectDrawValidator(m_draws_wdg, i, m_cb_l[i]));
			m_cb_l[i]->Enable(FALSE);
			m_cb_l[i]->SetToolTip(wxEmptyString);
			m_cb_l[i]->SetBackgroundColour(DRAW3_BG_COLOR);

			sizer->Add(m_cb_l[i], 0, wxTOP | wxLEFT | wxRIGHT, 1);
		}

		Draw* draw = m_dc->GetDraw(i);
		DrawInfo* draw_info = draw->GetDrawInfo();
		wxString label;
		if (draw_info->IsValid()) {
			m_cb_l[i]->Enable(TRUE);
			m_cb_l[i]->SetValue(draw->GetEnable());
			m_cb_l[i]->SetToolTip(cnm[draw_info->GetBasePrefix()] + _T(":") + draw_info->GetParamName());

			label = wxString::Format(_T("%d."), draw->GetInitialDrawNo() + 1) + draw_info->GetName();
			if (draw_info->GetParam()->GetIPKParam()->GetPSC())
				label += _T("*");
			if (draw->GetBlocked())
				label.Replace(wxString::Format(_T("%d."), draw->GetInitialDrawNo() + 1), wxString::Format(_("%d.[B]"), i + 1), false);
		} else {
			label = _T("***");
		}
		m_cb_l[i]->SetLabel(label);

		wxValidator* validator = m_cb_l[i]->GetValidator();
		if (validator)
			dynamic_cast<SelectDrawValidator*>(validator)->Set(m_draws_wdg, i, m_cb_l[i]);
		else
			m_cb_l[i]->SetValidator(SelectDrawValidator(m_draws_wdg, i, m_cb_l[i]));

		m_cb_l[i]->SetBackgroundColour(draw_info->GetDrawColor());

#ifdef MINGW32
		m_cb_l[i]->Refresh();
#endif

	}

	if (m_cb_l.size() > MIN_DRAWS_COUNT)
		SetScrollRate(10, 10);
	else
		SetScrollRate(0, 0);

	sizer->Layout();
}
Example #6
0
void DrawsWidget::OnCopyParamName(wxCommandEvent &event) {
	Draw *d = m_draws_controller->GetSelectedDraw();

	if (d == NULL)
		return;

	CopyParamName(d->GetDrawInfo());
}
Example #7
0
void RemarksFetcher::ShowRemarks() {
    if (!m_remarks_handler->Configured())
        return;
    m_awaiting_for_whole_base = true;
    Draw* d = m_draws_controller->GetSelectedDraw();
    if (d == NULL)
        return;
    m_remarks_handler->GetStorage()->GetAllRemarks(d->GetDrawInfo()->GetBasePrefix(), this);
}
Example #8
0
int BackgroundPrinter::FindVerticalAxesDistance(wxDC *dc, std::vector<Draw*> draws, const SS& sd) {
	
	int d = 0;

	for (SS::const_iterator ssi = sd.begin(); ssi != sd.end(); ssi++) {
		set<int>::const_iterator si = (*ssi).begin();
		if ((*ssi).end() == si)
			assert(false);

		int di = *si;
		Draw *draw = draws[di];

		double max = draw->GetDrawInfo()->GetMax();
		double min = draw->GetDrawInfo()->GetMin();
		wxString maxs = draw->GetDrawInfo()->GetValueStr(max, _T(""));
		wxString mins = draw->GetDrawInfo()->GetValueStr(min, _T(""));

		wxString unit = draw->GetDrawInfo()->GetUnit();

		int maxext, minext, unitext, texth;
		dc->GetTextExtent(maxs, &maxext, &texth);
		dc->GetTextExtent(mins, &minext, &texth);
		dc->GetTextExtent(unit, &unitext, &texth);

		int msn = 0;
		do {
			int tw, th;
			dc->GetTextExtent(draws[*si]->GetDrawInfo()->GetUnit(), &tw, &th);
			msn = wxMax(msn, tw);
		} while (++si != (*ssi).end());
		

		int ext = wxMax(unitext, wxMax(maxext, minext));
		ext = wxMax(ext, msn) + line_width;

		d = wxMax(d, ext);

	} 

	return d;

}
Example #9
0
void WxGraphs::OnMouseRightDown(wxMouseEvent &event) {
	if (m_draws_wdg->GetSelectedDrawIndex() == -1)
		return;

	Draw *d = m_draws[m_draws_wdg->GetSelectedDrawIndex()];
	DrawInfo *di = d->GetDrawInfo();

	SetInfoDataObject wido(di->GetBasePrefix(), di->GetSetName(), d->GetPeriod(), d->GetCurrentTime().GetTicks(), m_draws_wdg->GetSelectedDrawIndex());
	wxDropSource ds(wido, this);
	ds.DoDragDrop(0);
}
Example #10
0
void GCDCGraphs::DrawUnit(wxGraphicsContext &dc) {
	Draw* draw = m_draws_wdg->GetSelectedDraw();
	if (draw == NULL) 
		return;

	double textw, texth, th, tsel;

	wxString unit = draw->GetDrawInfo()->GetUnit();
	dc.GetTextExtent(unit, &textw, &texth, &th, &tsel);
	dc.DrawText(unit, m_screen_margins.leftmargin - 6 - textw, m_screen_margins.topmargin - 2 - texth);
}
Example #11
0
void GCDCGraphs::DrawSeasonsLimitsInfo(wxGraphicsContext &dc) {
	Draw* draw = m_draws_wdg->GetSelectedDraw();
	if (draw == NULL)
		return;

	DrawsSets *cfg = m_cfg_mgr->GetConfigByPrefix(draw->GetDrawInfo()->GetBasePrefix());

	std::vector<SeasonLimit> limits = get_season_limits_indexes(cfg, draw);
	for (std::vector<SeasonLimit>::iterator i = limits.begin(); i != limits.end(); i++)
		DrawSeasonLimitInfo(dc, i->index, i->month, i->day, i->summer);

}
Example #12
0
void SummaryWindow::StartDisplaying(int no) {
	assert(m_active);
	Draw* draw = m_draws[no]->draw;

	m_draws[no]->update = true;
	m_draws[no]->tooltip = true;

	m_summary_draws_count++;

	m_labels[no] = new TTLabel(this, wxID_ANY);
	m_labels[no]->SetUnitText(draw->GetDrawInfo()->GetShortName() + _T(":"));
	m_labels[no]->SetBackgroundColour(draw->GetDrawInfo()->GetDrawColor());
	m_lines[no] = new wxStaticLine(this, wxID_ANY);

	m_values_sizer->Add(m_labels[no], 0, wxEXPAND);
	m_values_sizer->Add(m_lines[no], 0, wxEXPAND);

	m_tooltip = true;
	m_update = true;

}
Example #13
0
DrawInfoList SelectDrawWidget::GetDrawInfoList() {
	DrawInfoList draw_info;

	DrawSet *selected_set = m_dc->GetSet();

	for (size_t i = 0; i < selected_set->GetDraws()->size(); ++i)
		if (m_cb_l[i]->GetValue()) {
			Draw* draw = m_dc->GetDraw(i);
			draw_info.push_back(draw->GetDrawInfo());
		}

	return draw_info;
}
Example #14
0
void DrawsWidget::CopyToClipboard() {
	Draw *d = m_draws_controller->GetSelectedDraw();

	if (d == NULL)
		return;

	if (wxTheClipboard->Open() == false)
		return;

	DrawInfo *di = d->GetDrawInfo();

	SetInfoDataObject* wido =
		new SetInfoDataObject(di->GetBasePrefix(), di->GetSetName(), d->GetPeriod(), d->GetCurrentTime().GetTicks(), d->GetDrawNo());

	wxTheClipboard->SetData(wido);
	wxTheClipboard->Close();
}
Example #15
0
void RemarksFetcher::Fetch() {
    if (!m_remarks_handler->Configured())
        return;

    Draw* d = m_draws_controller->GetSelectedDraw();
    if (d == NULL)
        return;

    wxDateTime start = d->GetTimeOfIndex(0);
    if (!start.IsValid())
        return;

    wxDateTime end = d->GetTimeOfIndex(d->GetValuesTable().size());
    DrawInfo *di = d->GetDrawInfo();

    m_remarks_handler->GetStorage()->GetRemarks(
        di->GetBasePrefix(),
        di->GetSetName(),
        start.GetTicks(),
        end.GetTicks(),
        this);

}
Example #16
0
void GCDCGraphs::DrawYAxisVals(wxGraphicsContext& dc) {
	Draw* draw = m_draws_wdg->GetSelectedDraw();
	if (draw == NULL) 
		return;
	DrawInfo *di = draw->GetDrawInfo();

	if (!di->IsValid())
		return;

	double min = di->GetMin();
	double max = di->GetMax();
	if( max <= min  ) {
		// FIXME:  Draw3 should atomaticly detect axes in that case, but
		//         it currently doesnt :(
		wxLogWarning(_T("Parameter %s has invalid min/max values: min %f, max %f. Min is set to 0, and max to 100."), di->GetName().c_str(), min, max);
		min = 0;
		max = 100;
	}

	//procedure for calculating distance between marks stolen from SzarpDraw2
	double x = max - min;
	double step;
	int i = 0;

	if (x < 1)
		for (;x < 1; x *=10, --i);
	else
		for (;(int)x / 10; x /=10, ++i);

	if (x <= 1.5)
		step = .1;
	else if (x <= 3.)
		step = .2;
	else if (x <= 7.5)
		step = .5;
	else
		step = 1.;

	double acc = 1;

	int prec = di->GetPrec();
				
	for (int p = prec; p > 0; --p)
		acc /= 10;

	double factor  = (i > 0) ? 10 : .1;

	for (;i; i -= i / abs(i))
		step *= factor;

	if (step < acc)
		step = acc;

    	dc.SetPen(wxPen(*wxWHITE, 1, wxSOLID));

	int w, h;
	GetClientSize(&w, &h);

	h -= m_screen_margins.bottommargin + m_screen_margins.topmargin;

	for (double val = max; (min - val) < acc; val -= step) {

		int y = GetY(val, di);

		dc.StrokeLine(m_screen_margins.leftmargin - 8, y, m_screen_margins.leftmargin, y);

		wxString sval = di->GetValueStr(val, _T("- -"));
		double textw, texth, textd, textel;
		dc.GetTextExtent(sval, &textw, &texth, &textd, &textel);
		dc.DrawText(sval, m_screen_margins.leftmargin - textw - 1, y + 2);
	}

}
Example #17
0
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);
			}
		}
	}

	if (m_tooltip) for (size_t i = 0; i < m_draws.Count(); ++i) {
		ObservedDraw* od = m_draws[i];
		if (od == NULL)
			continue;

		if (od->tooltip == false)
			continue;

		Draw* draw = od->draw;
		DrawInfo* info = draw->GetDrawInfo();

		wxString tooltip = _T("");
		tooltip += info->GetName();
		tooltip += _T("\n");

		PeriodType period = draw->GetPeriod();

		const Draw::VT& vt = draw->GetValuesTable();

		wxDateTime s = draw->GetTimeOfIndex(vt.m_stats.Start() - vt.m_view.Start());
		wxDateTime e = draw->GetTimeOfIndex(vt.m_stats.End() - vt.m_view.Start());

		tooltip += _("From:"); 
		tooltip += _T("\n") + FormatTime(s, period) + _T("\n") + _("To:") + _T("\n") + FormatTime(e, period);

		double data_percentage = od->draw->GetValuesTable().m_data_probes_ratio;
		if (std::isnan(data_percentage))
			data_percentage = 0;
		tooltip += _T("\n\n") + wxString::Format(_("Data contains %.2f%% probes from current period"), data_percentage * 100);

		m_labels[i]->SetToolTip(tooltip);

		od->tooltip = false;
	}

	if (resize) 
		Resize();

	m_update = m_tooltip = false;

}
Example #18
0
void DrawsPrintout::PrintDrawsInfo(wxDC *dc, int leftmargin, int topmargin, int rightmargin, int bottommargin) {
	int w, h;
	int tw, th;
	int maxy = 5;
	int info_print_start;
	dc->GetSize(&w, &h);
	//GetPageSizePixels(&w, &h);
	w -= leftmargin + rightmargin;
	int hw = w / 2;

	info_print_start = h * 2 / 3 + topmargin;
	dc->SetDeviceOrigin(leftmargin, info_print_start);

	Draw* fd = m_draws[0];
	DrawInfo* fdi = m_draws[0]->GetDrawInfo();

	wxFont font = dc->GetFont();
	wxFont f = font;
	//wxFont f(10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, _T("Helvetica"), wxFONTENCODING_ISO8859_2);
#ifdef __WXMSW__
	f.SetPointSize(100);
#else
	f.SetPointSize(16);
#endif
	dc->SetTextForeground(*wxBLACK);
	dc->SetFont(f);

	wxString cn = GetPrintoutConfigTitle();
	dc->GetTextExtent(cn, &tw, &th);
	dc->DrawText(cn, hw - tw / 2, maxy);
	maxy += int(1.4 * th);

#ifdef __WXMSW__
	f.SetPointSize(65);
#else
	f.SetPointSize(8);
#endif
	dc->SetFont(f);

	wxString wt = fdi->GetSetName();
	dc->GetTextExtent(wt, &tw, &th);
	dc->DrawText(wt, hw - tw / 2, maxy);
	maxy += int(1.4 * th);

	PeriodType pt = fd->GetPeriod();
	wxString period = _("For period: ");
	switch (pt) {
		case PERIOD_T_DECADE:
			period += _("DECADE ");
			break;
		case PERIOD_T_YEAR:
			period += _("YEAR ");
			break;
		case PERIOD_T_MONTH:
			period += _("MONTH ");
			break;
		case PERIOD_T_WEEK:
			period += _("WEEK ");
			break;
		case PERIOD_T_DAY:
			period += _("DAY ");
			break;
		case PERIOD_T_30MINUTE:
			period += _("HOUR ");
			break;
		case PERIOD_T_5MINUTE:
			period += _("5MINUTE ");
			break;
		case PERIOD_T_MINUTE:
			period += _("MINUTE ");
			break;
		case PERIOD_T_30SEC:
			period += _("30SEC ");
			break;
		case PERIOD_T_SEASON:
			period += _("SEASON ");
			break;
		default:
			assert(false);
	}

	dc->GetTextExtent(period, &tw, &th);
	dc->DrawText(period, hw - tw / 2, maxy);
	maxy += int(1.4 * th);

	int point_size = f.GetPointSize();
	bool painted = false;
	do {
		wxString time;
		time += _("From: ");
		time += FormatTime(fd->GetTimeOfIndex(0), pt);
		time += _(" to: ");
		time += FormatTime(fd->GetTimeOfIndex(fd->GetValuesTable().size() - 1), pt);

		dc->GetTextExtent(time, &tw, &th);
		if (tw > w && f.GetPointSize() >= 2) {
			f.SetPointSize(f.GetPointSize() - 1);
			dc->SetFont(f);	
		} else {
			dc->DrawText(time, hw - tw / 2, maxy);
			maxy += int(1.4 * th);
			painted = true;
		}
	} while (!painted);

	f.SetPointSize(point_size) ;
	dc->SetFont(f);
	painted = false;
	bool painting = false;
	int pmaxy = maxy;
	do {
		for (int i = 0; i < m_draws_count; ++i) {
			Draw *d = m_draws[i];
			if (!d->GetEnable())
				continue;
	
			DrawInfo* di = d->GetDrawInfo();
	
			int cx = 0.02 * w;
	
			wxString str = wxString::Format(_T("%s = %s "), 
						di->GetShortName().c_str(),
						di->GetName().c_str());
	
			dc->SetTextForeground(di->GetDrawColor());
			dc->GetTextExtent(str, &tw, &th);
			if (painting)
				dc->DrawText(str, cx, maxy);
	
			cx += tw;
	
			const Draw::VT& vt = d->GetValuesTable();
			if (vt.m_count) {
				dc->SetTextForeground(*wxBLACK);
	
				wxString unit = di->GetUnit();
	
				str = wxString(_T(": ")) 
					+ _("min.=") + d->GetDrawInfo()->GetValueStr(vt.m_min, _T("- -")) + 
					+ _T(" ; ") + _("avg.=") + wxString(d->GetDrawInfo()->GetValueStr(vt.m_sum / vt.m_count, _T("- -"))) + 
					+ _T(" ; ") + _("max.=") + wxString(d->GetDrawInfo()->GetValueStr(vt.m_max, _T("- -"))) +
					+ _T(" ") + unit;
	
				if (painting) {
					dc->GetTextExtent(str, &tw, &th);
					dc->DrawText(str, cx, maxy);
				}
				cx += tw;
	
				if (di->GetSpecial() == TDraw::HOURSUM) {
					wxString u = unit;
					if (u.Replace(_T("/h"), _T("")) == 0)
						u += _T("*h");
					wxString vals;
					double val = vt.m_hsum;
					wxString sunit = d->GetDrawInfo()->GetSumUnit();
					if (!sunit.IsEmpty()) {
						vals = wxString(di->GetValueStr(val, _T(""))) + _T(" ") + sunit;
					} else if (unit == _T("kW")) {
						vals = wxString(di->GetValueStr(val, _T(""))) + _T(" ") + _T("kWh") + 
							_T(" (") + wxString(di->GetValueStr(val * 3.6 / 1000, _T(""))) + _T(" GJ)");
					} else if (unit == _T("MW")) {
						vals = wxString(di->GetValueStr(val, _T(""))) + _T(" ") + _T("MWh") + 
							_T(" (") + wxString(di->GetValueStr(val * 3.6, _T(""))) + _T(" GJ)");
					} else if (unit.Replace(_T("/h"), _T("")) == 0) {
						u += _T("*h");
						vals = wxString(di->GetValueStr(val, _T(""))) + _T(" ") + u;
					} else {
						vals = wxString(di->GetValueStr(val, _T(""))) + _T(" ") + u;
					}
					str = wxString::Format(_T(" sum.: %s"), vals.c_str());
	
					if (painting)
						dc->DrawText(str, cx, maxy);
				}
			}
			maxy += int(1.4 * th);
		}

		if (painting)
			painted = true;
		else  {
			if (maxy + info_print_start + topmargin < dc->GetSize().GetHeight() - bottommargin)
				painting = true;
			else {
				f.SetPointSize(f.GetPointSize() - 1);
				if (f.GetPointSize() <= 2)
					painting = true;
				dc->SetFont(f);
			}
			maxy = pmaxy;
		}
		
	} while (!painted);

}