// does not update name void ModelDialog::UpdateXml(wxXmlNode* e) { int ii; long numStrings; wxString tempStr; if(e->HasAttribute(wxT("Advanced"))) { e->DeleteAttribute(wxT("Advanced")); tempStr = e->GetAttribute(wxT("parm1")); tempStr.ToLong(&numStrings); for(ii=0; ii < numStrings; ii++) { e->DeleteAttribute(StartChanAttrName(ii)); } } if (e->HasAttribute(wxT("CustomModel"))); { e->DeleteAttribute(wxT("CustomModel")); } if (cbIndividualStartNumbers->IsChecked()) { e->AddAttribute(wxT("Advanced"), wxT("1")); for(ii=0; ii < gridStartChannels->GetNumberRows(); ii++) { e->AddAttribute(StartChanAttrName(ii),gridStartChannels->GetCellValue(ii,0)); } } if (e->HasAttribute(wxT("StartSide"))) e->DeleteAttribute(wxT("StartSide")); e->DeleteAttribute(wxT("DisplayAs")); e->DeleteAttribute(wxT("parm1")); e->DeleteAttribute(wxT("parm2")); e->DeleteAttribute(wxT("parm3")); e->DeleteAttribute(wxT("StartChannel")); e->DeleteAttribute(wxT("Order")); e->DeleteAttribute(wxT("Dir")); e->DeleteAttribute(wxT("Antialias")); e->AddAttribute(wxT("DisplayAs"), Choice_DisplayAs->GetStringSelection()); e->AddAttribute(wxT("parm1"), wxString::Format(wxT("%d"),SpinCtrl_parm1->GetValue())); e->AddAttribute(wxT("parm2"), wxString::Format(wxT("%d"),SpinCtrl_parm2->GetValue())); e->AddAttribute(wxT("parm3"), wxString::Format(wxT("%d"),SpinCtrl_parm3->GetValue())); e->AddAttribute(wxT("StartChannel"), wxString::Format(wxT("%d"),SpinCtrl_StartChannel->GetValue())); e->AddAttribute(wxT("Order"), Choice_Order->GetStringSelection()); if (RadioButton_TopLeft->GetValue() || RadioButton_TopRight->GetValue() ) e->AddAttribute(wxT("StartSide"),wxT("T")); else e->AddAttribute(wxT("StartSide"),wxT("B")); if (RadioButton_TopLeft->GetValue() || RadioButton_BotLeft->GetValue() ) e->AddAttribute(wxT("Dir"),wxT("L")); else e->AddAttribute(wxT("Dir"),wxT("R")); e->AddAttribute(wxT("Antialias"), wxString::Format(wxT("%d"),Choice_Antialias->GetSelection())); if (Choice_DisplayAs->GetStringSelection() == wxT("Custom")) { e->AddAttribute(wxT("CustomModel"),GetCustomGridData()); } ModelClass::SetMyDisplay(e,CheckBox_MyDisplay->GetValue()); }
void ModelDialog::SetFromXml(wxXmlNode* e, const wxString& NameSuffix) { long n; wxString name, direction, startSide, tempStr; name=e->GetAttribute(wxT("name")) + NameSuffix; TextCtrl_Name->SetValue(name); Choice_DisplayAs->SetStringSelection(e->GetAttribute(wxT("DisplayAs"))); SpinCtrl_parm1->SetValue(e->GetAttribute(wxT("parm1"))); SpinCtrl_parm2->SetValue(e->GetAttribute(wxT("parm2"))); SpinCtrl_parm3->SetValue(e->GetAttribute(wxT("parm3"))); SpinCtrl_StartChannel->SetValue(e->GetAttribute(wxT("StartChannel"))); Choice_Order->SetStringSelection(e->GetAttribute(wxT("Order"))); tempStr=e->GetAttribute(wxT("Antialias"),wxT("0")); tempStr.ToLong(&n); Choice_Antialias->SetSelection(n); direction=e->GetAttribute(wxT("Dir")); if(e->HasAttribute(wxT("StartSide"))) { startSide=e->GetAttribute(wxT("StartSide")); } else { startSide = wxT("B"); } if(e->HasAttribute(wxT("Advanced"))) { cbIndividualStartNumbers->SetValue(true); tempStr = e->GetAttribute(wxT("parm1")); tempStr.ToLong(&n); // number of strings for(int ii=0; ii < n; ii++) { gridStartChannels->AppendRows(); gridStartChannels->SetCellValue(ii,0,e->GetAttribute(StartChanAttrName(ii))); } } if (direction == wxT("R") ) { if(startSide == wxT("B")) RadioButton_BotRight->SetValue(true); else RadioButton_TopRight->SetValue(true); } else { if(startSide == wxT("B")) RadioButton_BotLeft->SetValue(true); else RadioButton_TopLeft->SetValue(true); } if (e->HasAttribute(wxT("CustomModel"))) { e->GetAttribute(wxT("CustomModel"),&tempStr); SetCustomGridData(tempStr); } CheckBox_MyDisplay->SetValue(ModelClass::IsMyDisplay(e)); UpdateLabels(); }
void ModelClass::SetFromXml(wxXmlNode* ModelNode, bool zeroBased) { wxString tempstr,channelstr; wxString customModel,RGBorder; long degrees, StartChannel, channel; size_t i; ModelXml=ModelNode; TreeDegrees=0; StrobeRate=0; Nodes.clear(); name=ModelNode->GetAttribute("name"); DisplayAs=ModelNode->GetAttribute("DisplayAs"); if (ModelNode->HasAttribute("StringType")) { // post 3.1.4 StringType=ModelNode->GetAttribute("StringType"); } else { // 3.1.4 and earlier StringType=ModelNode->GetAttribute("Order","RGB")+" Nodes"; } SingleNode=HasSingleNode(StringType); SingleChannel=HasSingleChannel(StringType); RGBorder=SingleNode ? "RGB" : RGBorder=StringType.Left(3); rgbidx[0]=std::max(RGBorder.Find('R'),0); rgbidx[1]=std::max(RGBorder.Find('G'),0); rgbidx[2]=std::max(RGBorder.Find('B'),0); tempstr=ModelNode->GetAttribute("parm1"); tempstr.ToLong(&parm1); tempstr=ModelNode->GetAttribute("parm2"); tempstr.ToLong(&parm2); tempstr=ModelNode->GetAttribute("parm3"); tempstr.ToLong(&parm3); tempstr=ModelNode->GetAttribute("StartChannel","1"); tempstr.ToLong(&StartChannel); tempstr=ModelNode->GetAttribute("Dir"); IsLtoR=tempstr != "R"; if (ModelNode->HasAttribute("StartSide")) { tempstr=ModelNode->GetAttribute("StartSide"); isBotToTop = (tempstr == "B"); } else { isBotToTop=true; } tempstr=ModelNode->GetAttribute("Antialias","0"); tempstr.ToLong(&Antialias); AliasFactor=1 << Antialias; MyDisplay=IsMyDisplay(ModelNode); tempstr=ModelNode->GetAttribute("offsetXpct","0"); tempstr.ToDouble(&offsetXpct); tempstr=ModelNode->GetAttribute("offsetYpct","0"); tempstr.ToDouble(&offsetYpct); tempstr=ModelNode->GetAttribute("PreviewScale","0.333"); tempstr.ToDouble(&PreviewScale); tempstr=ModelNode->GetAttribute("PreviewRotation","0"); tempstr.ToLong(°rees); PreviewRotation=degrees; // calculate starting channel numbers for each string size_t NumberOfStrings= HasOneString(DisplayAs) ? 1 : parm1; int ChannelsPerString=parm2*3; if (SingleChannel) ChannelsPerString=1; else if (SingleNode) ChannelsPerString=3; if (ModelNode->HasAttribute("CustomModel")) { customModel = ModelNode->GetAttribute("CustomModel"); int maxval=GetCustomMaxChannel(customModel); // fix NumberOfStrings if (SingleNode) { NumberOfStrings=maxval; } else { ChannelsPerString=maxval*3; } } tempstr=ModelNode->GetAttribute("Advanced","0"); bool HasIndividualStartChans=tempstr == "1"; stringStartChan.clear(); stringStartChan.resize(NumberOfStrings); for (i=0; i<NumberOfStrings; i++) { tempstr=StartChanAttrName(i); if (!zeroBased && HasIndividualStartChans && ModelNode->HasAttribute(tempstr)) { ModelNode->GetAttribute(tempstr, &channelstr); channelstr.ToLong(&channel); stringStartChan[i] = channel-1; } else { stringStartChan[i] = (zeroBased? 0 : StartChannel-1) + i*ChannelsPerString; } } // initialize model based on the DisplayAs value wxStringTokenizer tkz(DisplayAs, " "); wxString token = tkz.GetNextToken(); if (token == "Tree") { InitVMatrix(); token = tkz.GetNextToken(); token.ToLong(°rees); SetTreeCoord(degrees); } else if (DisplayAs == "Custom") { InitCustomMatrix(customModel); CopyBufCoord2ScreenCoord(); } else if (DisplayAs == "Vert Matrix") { InitVMatrix(); CopyBufCoord2ScreenCoord(); } else if (DisplayAs == "Horiz Matrix") { InitHMatrix(); CopyBufCoord2ScreenCoord(); } else if (DisplayAs == "Single Line") { InitLine(); SetLineCoord(); } else if (DisplayAs == "Arches") { InitHMatrix(); // Old call was InitLine(); SetArchCoord(); } else if (DisplayAs == "Window Frame") { InitFrame(); CopyBufCoord2ScreenCoord(); } else if (DisplayAs == "Star") { InitStar(); CopyBufCoord2ScreenCoord(); } else if (DisplayAs == "Wreath") { InitWreath(); CopyBufCoord2ScreenCoord(); } size_t NodeCount=GetNodeCount(); for(size_t i=0; i<NodeCount; i++) { Nodes[i]->sparkle = rand() % 10000; } }