void GuiContainer::loadFromXml(string file) { controls.clear(); ofxXmlSettings xml; res.init(file); xml.loadFile(file); loadBaseInfo("view", xml, 0); x = 0; y = 0; load(); //movable = xml.getAttribute("view", "movable", 0, 0); xml.pushTag("view"); int numControls = xml.getNumTags("control"); for(int i = 0; i < numControls; i++) { GuiControl *c = instantiator( xml.getAttribute("control", "type", "", i), xml.getAttribute("control", "name", "", i), xml.getAttribute("control", "id", "", i), &res, this); string valueStr = xml.getAttribute("control", "value", "", i); if(valueStr!="") { c->valueFromString(valueStr); } c->loadBaseInfo("control", xml, i); c->load(); c->listeners = listeners; c->numListeners = numListeners; c->load(xml, i); add(c); } }
GuiControl *GuiContainer::add(string _type, string _name, string _controlId) { GuiControl *ctrl = instantiator(_type, _name, _controlId, &res, this); ctrl->load(); add(ctrl); return ctrl; }
void GuiControl::saveBaseInfo(string tag, ofxXmlSettings xml, int pos) { xml.addAttribute(tag, "type", type, pos); xml.addAttribute(tag, "width", width, pos); xml.addAttribute(tag, "height", height, pos); xml.addAttribute(tag, "x", x, pos); xml.addAttribute(tag, "y", y, pos); xml.addAttribute(tag, "id", controlId, pos); xml.addAttribute(tag, "name", name, pos); xml.addAttribute(tag, "value", this->valueToString(), pos); vector<ParameterInfo> params = this->getParameterInfo(); for(int i = 0; i < params.size(); i++) { GuiControl *g = instantiator(params[i].type, "", "", resources, this); g->value = params[i].value; xml.addAttribute(tag, params[i].xmlName, g->valueToString(), pos); } }
void GuiControl::loadBaseInfo(string tag, ofxXmlSettings xml, int pos) { x = xml.getAttribute(tag, "x", 0.f, pos); y = xml.getAttribute(tag, "y", 0.f, pos); width = xml.getAttribute(tag, "width", 0.f, pos); height = xml.getAttribute(tag, "height", 0.f, pos); controlId = xml.getAttribute(tag, "id", "", pos); name = xml.getAttribute(tag, "name", "", pos); vector<ParameterInfo> params = this->getParameterInfo(); for(int i = 0; i < params.size(); i++) { GuiControl *g = instantiator(params[i].type, "", "", resources, this); g->valueFromString(xml.getAttribute(tag, params[i].xmlName, "", pos)); // this is re-pointing a pointer - what we actually want to do is copy memcpy(params[i].value, g->value, sizeof(void*)); } }
void GuiContainer::duplicateFocusedControl() { if(focusedControl!=NULL) { ofxXmlSettings xml; xml.addTag("control"); focusedControl->saveBaseInfo("control", xml, 0); focusedControl->save(xml, 0); GuiControl *ctrl = instantiator(focusedControl->type, focusedControl->name, focusedControl->controlId+"1", &res, this); ctrl->loadBaseInfo("control", xml, 0); ctrl->load(); ctrl->load(xml, 0); ctrl->x += 20; ctrl->y += 20; ctrl->setEditing(editing); focusedControl->focus = false; focusedControl = ctrl; focusedControl->focus = true; add(focusedControl); } }
int main(int argc, char** argv) { if (argc == 1) { cerr << "Usage: <program> <SDF-file-list>" << endl; return 1; } std::vector<Linker> linkers; std::vector<Rigid> rigids; readInputFiles(argc, argv, linkers, rigids); cerr << "1" << endl; Instantiator instantiator(cout); cerr << "2" << endl; HyperGraph<Molecule, EdgeAnnotationT> graph = instantiator.Instantiate(linkers, rigids); cerr << "3" << endl; PebblerHyperGraph<Molecule, EdgeAnnotationT> pebblerGraph = graph.GetPebblerHyperGraph(); cerr << "4" << endl; if (DEBUG) cout << graph; cerr << "5" << endl; Cleanup(linkers, rigids); cerr << "6" << endl; return 0; }
int main(int argc, char** argv) { if (argc < 2) { std::cerr << "Usage: <program> [SDF-file-list] -o <output-file> -v <validation-file>" << " -pool <#obgen-threads>" << std::endl; return 1; } // // Remove log files from a previous run. // std::string rmString = "rm synth_log*"; system(rmString.c_str()); // // Global options object. // Options options(argc, argv); if (!options.parseCommandLine()) { std::cerr << "Command-line parsing failed; exiting." << std::endl; return 1; } // // Output command-line option information // if (!Options::THREADED) { std::cout << "\'-threaded\' not specified, but will be used." << std::endl; } // Printing the specified Tanimoto value to the user. std::cerr << "Tanimoto Coefficient Threshold Specified: " << Options::TANIMOTO << std::endl; std::cerr << "OBGEN output thread pool size: " << Options::OBGEN_THREAD_POOL_SIZE << std::endl; if (!readInputFiles(options)) return 1; // // Bypass synthesis for acquiring information about the input fragments. // if (g_calculate_lipinski_descriptors_for_input_fragments_only) { std::cout << "Calculated Lipinski Descriptors for input fragments, now exiting early." << " (Flag set in Constants.h)" << std:: endl; return 0; } // Output object for the nodes of the hypergraph. OBWriter* writer = new OBWriter(Options::OBGEN_THREAD_POOL_SIZE); writer->InitializeFile(options.outFile); // The main object that performs synthesis. Instantiator instantiator(writer, cout); // Instantiation build the hypergraph; this is the main data structure for the // resultant molecules. // Also creates the hypergraph using threaded or non-threaded techniques. HyperGraph<Molecule, EdgeAnnotationT>* graph = instantiator.ThreadedInstantiate(linkers, rigids); std::cout << "Hypergraph contains (" << graph->size() << ") nodes" << std::endl; std::cout << OBWriter::compliantMols.size() << " are Lipinski compliant molecules" << std::endl; // // Validate the molecules specified in the validation file (command-line -v) // Validator validator(OBWriter::compliantMols); validator.Validate(options.validationFile); // Deleting the writer will kill the thread pool. delete writer; // For later: pebbling //PebblerHyperGraph<Molecule, EdgeAnnotationT> pebblerGraph = graph->GetPebblerHyperGraph(); Cleanup(linkers, rigids); std::cerr << "Exiting the main thread." << std::endl; return 0; }