示例#1
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);

}
示例#2
0
void SelectDrawWidget::OpenParameterDoc(int i) {
	DrawInfo* d;
	if (i == -1)
		d = m_draws_wdg->GetCurrentDrawInfo();
	else
		d = m_draws_wdg->GetDrawInfo(i);

	if (d == NULL)
		return;

	if (DefinedParam* dp = dynamic_cast<DefinedParam*>(d->GetParam()))
		ShowDefinedParamDoc(dp);
	else
		GoToWWWDocumentation(d);
#ifdef __WXMSW__
	m_draws_wdg->SetFocus();
#endif
}
示例#3
0
void SelectDrawWidget::OnEditParam(wxCommandEvent &event) {
	int i = GetClicked(event);
	if (i == -1)
		return;

	DrawInfo *d = m_draws_wdg->GetDrawInfo(i);

	DefinedParam *dp = dynamic_cast<DefinedParam*>(d->GetParam());
	if (dp == NULL)
		return;

	wxWindow *w = this;
	while (!w->IsTopLevel())
		w = w->GetParent();

	ParamEdit pe(w, m_cfg, m_dbmgr, m_remarks_handler);
	pe.SetCurrentConfig(d->GetBasePrefix());
	pe.Edit(dp);

}
示例#4
0
void ParamEdit::OnFormulaInsertParam(wxCommandEvent &event) {

	DrawsSets* drawsets = m_cfg_mgr->GetConfigByPrefix(m_base_prefix);
	assert(drawsets);
	wxString ct = drawsets->GetID();

	if (m_inc_search == NULL)
		m_inc_search = new IncSearch(m_cfg_mgr, m_remarks_handler, ct, this, -1, _("Find"), false, false);
	else
		m_inc_search->SetConfigName(ct);
	

	if (m_inc_search->ShowModal() != wxID_OK)
		return;

	long prev = -1;
	DrawInfo *draw;
	while ((draw = m_inc_search->GetDrawInfo(&prev)) != NULL) {
		DrawParam *p = draw->GetParam();
		wxString pname = p->GetParamName();
		m_formula_input->AddText(wxString::Format(_T("p(\"%s:%s\", t, pt) "), draw->GetBasePrefix().c_str(), pname.c_str()));
	}

}