Ejemplo n.º 1
0
void SelectDrawWidget::OnAverageValueCalucatedMethodChange(wxCommandEvent &event) {
	int i = GetClicked(event);
	if (i == -1)
		return;
	DrawInfo *d = m_draws_wdg->GetDrawInfo(i);
	AverageValueCalculationMethod qt = d->GetAverageValueCalculationMethod();
	switch (event.GetId()) {
		case seldrawID_CTX_AVERAGE_VALUE:
			if (qt == AVERAGE_VALUE_CALCULATION_AVERAGE) 
				return;
			d->SetAverageValueCalculationMethod(AVERAGE_VALUE_CALCULATION_AVERAGE);
			break;
		case seldrawID_CTX_LAST_VALUE:
			if (qt == AVERAGE_VALUE_CALCULATION_LAST) 
				return;
			d->SetAverageValueCalculationMethod(AVERAGE_VALUE_CALCULATION_LAST);
			break;
		case seldrawID_CTX_DIFFERENCE_VALUE:
			if (qt == AVERAGE_VALUE_CALCULATION_LAST_FIRST) 
				return;
			d->SetAverageValueCalculationMethod(AVERAGE_VALUE_CALCULATION_LAST_FIRST);
			break;
	}

	m_cfg->DrawInfoAverageValueCalculationChanged(d);
}
Ejemplo n.º 2
0
void
SelectDrawValidator::OnMouseRightDown(wxMouseEvent &event) {
	DrawInfo* di = m_draws_wdg->GetDrawInfo(m_index);
	if (di == NULL)
		return;

	wxMenu menu;

	DrawParam* dp = di->GetParam();
	if (di->IsValid() && dp->GetIPKParam()->GetPSC())
		menu.Append(seldrawID_PSC,_("Set parameter"));

	menu.SetClientData(m_cb);

	if (m_draws_wdg->GetDrawBlocked(m_index)) {
		wxMenuItem* item = menu.AppendCheckItem(seldrawID_CTX_BLOCK_MENU, _("Draw blocked\tCtrl-B"));
		item->Check();
	} else {
		int non_blocked_count = 0;
		for (unsigned int i = 0; i < m_draws_wdg->GetDrawsCount(); ++i)
			if (!m_draws_wdg->GetDrawBlocked(i))
				non_blocked_count++;

		//one draw shall be non-blocked
		if (non_blocked_count > 1)
			menu.AppendCheckItem(seldrawID_CTX_BLOCK_MENU, _("Draw blocked\tCtrl-B"));
	}

	menu.Append(seldrawID_CTX_DOC_MENU, _("Parameter documentation\tCtrl-H"));
	menu.Append(seldrawID_CTX_COPY_PARAM_NAME_MENU, _("Copy parameter name\tCtrl+Shift+C"));

	wxMenu* submenu = new wxMenu();
	submenu->SetClientData(m_cb);
	wxMenuItem* averageItem = submenu->AppendRadioItem(seldrawID_CTX_AVERAGE_VALUE, _("Average value for selected period"));
	wxMenuItem* lastItem = submenu->AppendRadioItem(seldrawID_CTX_LAST_VALUE, _("Last value"));
	wxMenuItem* diffItem = submenu->AppendRadioItem(seldrawID_CTX_DIFFERENCE_VALUE, _("Difference between last and first value"));
	menu.AppendSubMenu(submenu, _("Type of average values shown"));

	switch (di->GetAverageValueCalculationMethod()) {
		case AVERAGE_VALUE_CALCULATION_AVERAGE:
			averageItem->Check(true);
			break;
		case AVERAGE_VALUE_CALCULATION_LAST:
			lastItem->Check(true);
			break;
		case AVERAGE_VALUE_CALCULATION_LAST_FIRST:
			diffItem->Check(true);
			break;
	}

	if (dynamic_cast<DefinedParam*>(dp) != NULL)
		menu.Append(seldrawID_CTX_EDIT_PARAM, _("Edit parameter associated with graph\tCtrl-E"));

	m_cb->PopupMenu(&menu);

}