void ParamEdit::TransferToWindow(DefinedParam *param) { DrawsSets *ds = m_cfg_mgr->GetConfigByPrefix(param->GetBasePrefix()); m_button_base_config->SetLabel(ds->GetID()); m_prec_spin->SetValue(param->GetPrec()); m_formula_input->SetText(param->GetFormula()); m_user_param_label->SetLabel(param->GetParamName().BeforeLast(L':') + L':'); m_param_name_input->SetValue(param->GetParamName().AfterLast(L':')); m_unit_input->SetValue(param->GetUnit()); m_formula_type_choice->SetSelection(param->GetFormulaType() == TParam::LUA_VA ? 0 : 1); if (param->GetStartTime() > 0) { struct tm *start_date; time_t tmp_time = param->GetStartTime(); start_date = localtime(&tmp_time); m_spin_ctrl_start_minutes->SetValue(start_date->tm_min); m_spin_ctrl_start_hours->SetValue(start_date->tm_hour); m_datepicker_ctrl_start_date->SetValue(wxDateTime(param->GetStartTime())); m_checkbox_start->SetValue(true); m_datepicker_ctrl_start_date->Enable(true); m_spin_ctrl_start_hours->Enable(true); m_spin_ctrl_start_minutes->Enable(true); } }
void FrameManager::LoadConfig(DrawFrame *frame) { ConfigDialog *config_dialog = new ConfigDialog(frame, config_manager->GetConfigTitles(), DefinedDrawsSets::DEF_PREFIX); int ret = config_dialog->ShowModal(); if (ret != wxID_OK) { config_dialog->Destroy(); return; } wxString prefix = config_dialog->GetSelectedPrefix(); if (prefix == DefinedDrawsSets::DEF_PREFIX) { DrawsSets *cfg = config_manager->GetConfigByPrefix(prefix); if (cfg == NULL || cfg->GetDrawsSets().size() == 0) { int ret = wxMessageBox(_("The are no user defined sets. Do you want to create one?"), _("Question"), wxICON_QUESTION | wxOK | wxCANCEL, frame); if (ret == wxOK) { DrawPicker* dp = new DrawPicker(frame, config_manager, database_manager, remarks_handler); if (dp->NewSet(prefix, false) == wxID_OK) frame->AddDrawPanel(prefix, wxEmptyString, PERIOD_T_YEAR, 0); dp->Destroy(); } config_dialog->Destroy(); return; } } if (frame) frame->AddDrawPanel(prefix, wxEmptyString, PERIOD_T_YEAR, 0); else CreateFrame(prefix, wxEmptyString, PERIOD_T_YEAR, time_t(-1), wxDefaultSize, wxDefaultPosition); config_dialog->Destroy(); }
bool DrawsWidget::SetSet(wxString sset, wxString prefix, time_t time, PeriodType pt, int selected_draw) { DrawsSets* ds = m_cfg->GetConfigByPrefix(prefix); if (ds == NULL) return false; DrawSet *set = NULL; if (!sset.IsEmpty()) { for (DrawSetsHash::iterator i = ds->GetDrawsSets().begin(); i != ds->GetDrawsSets().end(); i++) if (i->second->GetName() == sset) { set = i->second; break; } } if (set == NULL) if ((set = m_draws_controller->GetSet()) == NULL) { SortedSetsArray ssa = ds->GetSortedDrawSetsNames(); set = ssa[0]; } if (set == NULL) return false; if (time <= 0) time = wxDateTime::Now().GetTicks(); if (pt == PERIOD_T_OTHER) pt = m_draws_controller->GetPeriod(); if (pt == PERIOD_T_OTHER) pt = PERIOD_T_YEAR; if (selected_draw < 0 || selected_draw >= (int)set->GetDraws()->size()) { if (m_draws_controller->GetSelectedDraw()) selected_draw = m_draws_controller->GetSelectedDraw()->GetDrawNo(); else selected_draw = 0; } m_draws_controller->Set(set, pt, time, selected_draw); return true; }
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())); } }
void FrameManager::ShowStatDialog(wxString prefix, TimeInfo time, DrawInfoList user_draws) { DrawsSets* config = config_manager->GetConfigByPrefix(prefix); new StatDialog(NULL, config->GetID(), database_manager, config_manager, remarks_handler, time, user_draws); }
void FrameManager::CreateXYZGraph(wxString prefix, TimeInfo time, DrawInfoList user_draws) { DrawsSets* config = config_manager->GetConfigByPrefix(prefix); new XYZFrame(config->GetID(), database_manager, config_manager, remarks_handler, time, user_draws, this); }