wxString EffectsPanel::GetRandomEffectStringFromWindow(wxWindow *w, const wxString &prefix) { wxWindowList &ChildList = w->GetChildren(); wxString s; for ( wxWindowList::iterator it = ChildList.begin(); it != ChildList.end(); ++it ) { wxWindow *ChildWin = *it; wxString ChildName = ChildWin->GetName(); wxString AttrName = prefix + ChildName.Mid(3) + "="; if (ChildName.StartsWith("ID_SLIDER")) { wxSlider* ctrl=(wxSlider*)ChildWin; if (ChildName.Contains("Spirograph_r")) { // always set little radius, r, to its minimum value s += AttrName + wxString::Format("%d", 0); } else { s += AttrName + wxString::Format("%d", GetRandomSliderValue(ctrl)); } } else if (ChildName.StartsWith("ID_TEXTCTRL")) { wxSlider * slider = (wxSlider*)w->FindWindowByName("IDD_SLIDER_" + ChildName.SubString(12, ChildName.size())); if (slider != nullptr) { int i = GetRandomSliderValue(slider); slider->SetValue(i); wxScrollEvent event(wxEVT_SLIDER, slider->GetId()); event.SetEventObject(slider); event.SetInt(i); slider->ProcessWindowEvent(event); } wxTextCtrl* ctrl = (wxTextCtrl*)ChildWin; wxString v = ctrl->GetValue(); v.Replace("&", "&", true); v.Replace(",", ",", true); s += AttrName + v; } else if (ChildName.StartsWith("ID_SPINCTRL")) { wxSpinCtrl* ctrl = (wxSpinCtrl*)ChildWin; int v = ctrl->GetValue(); s += AttrName + wxString::Format(wxT("%i"), v); } else if (ChildName.StartsWith("ID_CHOICE")) { wxChoice* ctrl=(wxChoice*)ChildWin; s += AttrName + ctrl->GetString(isRandom(ctrl)? rand()%ctrl->GetCount(): ctrl->GetSelection()); //-DJ } else if (ChildName.StartsWith("ID_CHECKBOX")) { if(ChildName.Contains("Spirograph_Animate")) { // always animate spirograph s+=AttrName+wxString::Format("%d", 1 ); } else { wxCheckBox* ctrl = (wxCheckBox*)ChildWin; int i = isRandom(ctrl)? (rand()%2): ctrl->GetValue(); wxString v = i ? "1" : "0"; //want random? -DJ s += AttrName + v; } } else if (ChildName.StartsWith("ID_NOTEBOOK")) { wxNotebook *notebook = (wxNotebook*)ChildWin; int i = rand() % notebook->GetPageCount(); s += AttrName+notebook->GetPageText(i); s += GetRandomEffectStringFromWindow(notebook->GetPage(i), prefix); } } return s; }
int EffectsPanel::GetRandomSliderValue(wxSlider* slider) { if (isRandom(slider)) { return rand() % (slider->GetMax()-slider->GetMin()) + slider->GetMin(); } return slider->GetValue(); }
// return true if the rule is regular (not a pr-atom, not a random selection) bool PlogGroundProgramBuilder::GRule::isRegular() { // the rule is regular if it is not random and // the last atom in the body of the form ext(id,...) where id a number if(isRandom()) return false; if(body.size()==0) return false; // the loop is needed because gringo may reorder the atoms in the rule's body! Clingo::literal_t lit = body[body.size()-1]; if ((abs(lit)) >= symbols->size() || symbols->at(abs(lit)) == Clingo::Symbol()) { return false; } Clingo::Symbol s = this->symbols->at(abs(lit)); return getExternalSymbolType(s) == ExternalSymbolType::Rule; }
wxString ColorPanel::GetRandomColorString() { wxString ChildName,AttrName; wxString ret; // get palette wxColour color; for (int i=1; i <= PALETTE_SIZE; i++) { color = GetPaletteColor(i); AttrName.Printf("C_BUTTON_Palette%d=", i); ret += AttrName + color.GetAsString(wxC2S_HTML_SYNTAX) + ","; wxString v = (isRandom(GetPaletteButton(i))? rand() % 2: GetPaletteCheckbox(i)->GetValue()) ? "1" : "0"; AttrName.Printf("C_CHECKBOX_Palette%d=", i); ret += AttrName + v + ","; } //TODO: randomize ret += wxString::Format("C_SLIDER_SparkleFrequency=%d,",Slider_SparkleFrequency->GetValue()); ret += wxString::Format("C_SLIDER_Brightness=%d,",Slider_Brightness->GetValue()); ret += wxString::Format("C_SLIDER_Contrast=%d",Slider_Contrast->GetValue()); return ret; }
bool EffectsPanel::isRandom_(void) { return isRandom(EffectChoicebook); }