void GeometricRecognizer::loadTemplates() { SampleGestures samples; addTemplate("Arrow", samples.getGestureArrow()); addTemplate("Caret", samples.getGestureCaret()); addTemplate("CheckMark", samples.getGestureCheckMark()); //addTemplate("Circle", samples.getGestureCircle()); //addTemplate("Delete", samples.getGestureDelete()); //addTemplate("Diamond", samples.getGestureDiamond()); //addTemplate("LeftCurlyBrace", samples.getGestureLeftCurlyBrace()); //addTemplate("LeftSquareBracket", samples.getGestureLeftSquareBracket()); //addTemplate("LeftToRightLine", samples.getGestureLeftToRightLine()); //addTemplate("LineDownDiagonal", samples.getGestureLineDownDiagonal()); addTemplate("Pigtail", samples.getGesturePigtail()); //addTemplate("QuestionMark", samples.getGestureQuestionMark()); addTemplate("Rectangle", samples.getGestureRectangle()); //addTemplate("RightCurlyBrace", samples.getGestureRightCurlyBrace()); //addTemplate("RightSquareBracket", samples.getGestureRightSquareBracket()); //addTemplate("RightToLeftLine", samples.getGestureRightToLeftLine()); //addTemplate("RightToLeftLine2", samples.getGestureRightToLeftLine2()); //addTemplate("RightToLeftSlashDown", samples.getGestureRightToLeftSlashDown()); //addTemplate("Spiral", samples.getGestureSpiral()); //addTemplate("Star", samples.getGestureStar()); //addTemplate("Triangle", samples.getGestureTriangle()); //addTemplate("V", samples.getGestureV()); //addTemplate("X", samples.getGestureX()); }
PageVariableFactory::PageVariableFactory() : KoInlineObjectFactoryBase("page", TextVariable) { KoInlineObjectTemplate var1; var1.id = "pagecount"; var1.name = i18n("Page Count"); KoProperties *props = new KoProperties(); props->setProperty("vartype", 1); var1.properties = props; addTemplate(var1); KoInlineObjectTemplate var2; var2.id = "pagenumber"; var2.name = i18n("Page Number"); props = new KoProperties(); props->setProperty("vartype", 2); var2.properties = props; addTemplate(var2); //KoInlineObjectTemplate var3; //var3.id = "pagecontinuation"; //var3.name = i18n("Page Continuation"); //props = new KoProperties(); //props->setProperty("vartype", 3); //var3.properties = props; //addTemplate(var3); QStringList elementNames; elementNames << "page-count" << "page-number" << "page-continuation-string"; setOdfElementNames(KoXmlNS::text, elementNames); }
DrawableSelector::DrawableSelector(Level& level) : level(&level) { index = 0; addTemplate(createDefaultDoodad()); addTemplate(createOtherDoodad()); addTemplate(createOtherOtherDoodad()); }
CaptureObject* CaptureWorld::addTemplateRigid(int rigidID, bool attachRigid, const char* filename, std::string name) { ClientHandler* client = AppData::getInstance()->getClient(); CaptureObject* object = NULL; if (client) { RigidBody* rb = client->getRigidBody(rigidID); // if attempting to attach to rigid body, make sure it belongs to the world if (rb && (!attachRigid || (rb->getWorldID() < 0 || rb->getWorldID() == this->id) )) { osg::Vec3 pos = rb->getPosition(); osg::Quat rot = rb->getRotation(); object = addTemplate(pos, rot, filename, name); if (object && attachRigid) { if (rb->getWorldID() < 0) rb->setWorldID(this->id); // use relative transformation w.r.t. rigid body // so when rigid body detached, will keep initial position object->setRigidBody(rb, true); updateObjectsNode(); } } } return object; }
ObjectTypeTemplate &Module::newTemplate(const std::string &name, const std::vector<std::string> ¶meters) { ObjectTypeTemplate* temp = new ObjectTypeTemplate(name, parameters); _ownedTemplates.push_back(std::unique_ptr<ObjectTypeTemplate>(temp)); addTemplate(*temp); return *temp; }
AssetTemplatesDialog::AssetTemplatesDialog( QWidget * parent ) : QDialog( parent ) { setupUi( this ); ProjectList pl = Project::select().filter( "fkeyProjectStatus", 4 ).sorted( "name" ); Project none; none.setName( "None (Global Templates)" ); pl.insert( pl.begin(), none ); mProjectCombo->setColumn( "name" ); mProjectCombo->setItems( pl ); AssetTypeList atl = AssetType::select().filter( "disabled", 0 ).sorted( "timesheetcategory" ); mTypeCombo->setColumn( "name" ); mTypeCombo->setItems( atl ); connect( mProjectCombo, SIGNAL( currentChanged( const Record & ) ), SLOT( projectChanged( const Record & ) ) ); connect( mTypeCombo, SIGNAL( currentChanged( const Record & ) ), SLOT( assetTypeChanged( const Record & ) ) ); connect( mAddButton, SIGNAL( clicked() ), SLOT( addTemplate() ) ); connect( mEditButton, SIGNAL( clicked() ), SLOT( editTemplate() ) ); connect( mRemoveButton, SIGNAL( clicked() ), SLOT( removeTemplate() ) ); connect( mTemplateList, SIGNAL( currentChanged( const Record & ) ), SLOT( slotCurrentChanged( const Record & ) ) ); RecordListModel * model = new RecordListModel( this ); model->setColumn( "name" ); mTemplateList->setModel( model ); assetTypeChanged( mTypeCombo->current() ); }
void CObjectClassesHandler::loadObjectEntry(const JsonNode & entry, ObjectContainter * obj) { if (!handlerConstructors.count(obj->handlerName)) { logGlobal->errorStream() << "Handler with name " << obj->handlerName << " was not found!"; return; } si32 id = selectNextID(entry["index"], obj->objects, 1000); auto handler = handlerConstructors.at(obj->handlerName)(); handler->setType(obj->id, id); if (customNames.count(obj->id) && customNames.at(obj->id).size() > id) handler->init(entry, customNames.at(obj->id).at(id)); else handler->init(entry); if (handler->getTemplates().empty()) { auto range = legacyTemplates.equal_range(std::make_pair(obj->id, id)); for (auto & templ : boost::make_iterator_range(range.first, range.second)) { handler->addTemplate(templ.second); } legacyTemplates.erase(range.first, range.second); } logGlobal->debugStream() << "Loaded object " << obj->id << ":" << id; assert(!obj->objects.count(id)); // DO NOT override obj->objects[id] = handler; }
UserVariableFactory::UserVariableFactory() : KoInlineObjectFactoryBase("user", TextVariable) { KoInlineObjectTemplate var1; var1.id = "userfieldget"; var1.name = i18n("Custom"); KoProperties *props = new KoProperties(); props->setProperty("varproperty", KoInlineObject::UserGet); props->setProperty("varname", QString()); var1.properties = props; addTemplate(var1); /* KoInlineObjectTemplate var2; var2.id = "userfieldinput"; var2.name = i18n("User Input"); props = new KProperties(); props->setProperty("varproperty", KoInlineObject::UserField); var2.properties = props; addTemplate(var2); */ QStringList elementNames; elementNames << "user-field-get" << "user-field-input"; setOdfElementNames(KoXmlNS::text, elementNames); }
void AObjectTypeHandler::addTemplate(JsonNode config) { config.setType(JsonNode::DATA_STRUCT); // ensure that input is not null JsonUtils::inherit(config, base); ObjectTemplate tmpl; tmpl.id = Obj(type); tmpl.subid = subtype; tmpl.stringID = ""; // TODO? tmpl.readJson(config); addTemplate(tmpl); }
void CDiagramTemplateManager::saveAsTemplate(CDiagram *d, const QString &type, const QString &title) { QDir dir(m_templatesRoot); QString fileName, filePath; QDomDocument templateDoc; QDomElement root, element; QIcon icon; QByteArray iconData; QByteArray unzipData; QDataStream iconStream(&iconData, QIODevice::WriteOnly); CDiagramTemplate *tpl = NULL; if (!d || title.isEmpty()) return; icon = genIconFromDiagram(d); iconStream << icon; root = templateDoc.createElement("template"); element = templateDoc.createElement("type"); element.appendChild( templateDoc.createTextNode(type) ); root.appendChild(element); element = templateDoc.createElement("icon"); element.appendChild(templateDoc.createTextNode( QString(iconData.toBase64()) )); root.appendChild(element); element = templateDoc.createElement("title"); element.appendChild(templateDoc.createTextNode(title)); root.appendChild(element); // transform the content of the diagram to xml element = templateDoc.createElement("content"); d->toXml(element); // append it to the end of the whole template document root.appendChild(element); templateDoc.appendChild(root); unzipData = templateDoc.toString().toAscii(); fileName = QString( QCryptographicHash::hash(unzipData, QCryptographicHash::Md5).toBase64() ); filePath = dir.absoluteFilePath( QString("%1.%2").arg( fileName ).arg( TEMPLATE_SUFFIX ) ); tpl = new CDiagramTemplate(); tpl->title = title; tpl->icon = icon; tpl->type = type; tpl->filePath = filePath; saveTemplateData(unzipData, filePath); addTemplate(tpl); }
PresentationVariableFactory::PresentationVariableFactory() : KoInlineObjectFactoryBase("PresentationVariable", Other) { KoInlineObjectTemplate var1; var1.id = "Header"; var1.name = i18n("Header"); KoProperties *props = new KoProperties(); props->setProperty("vartype", 1); var1.properties = props; addTemplate(var1); KoInlineObjectTemplate var2; var2.id = "Footer"; var2.name = i18n("Footer"); props = new KoProperties(); props->setProperty("vartype", 2); var2.properties = props; addTemplate(var2); QStringList elementNames; elementNames << "footer" << "header" << "date-time"; setOdfElementNames(KoXmlNS::presentation, elementNames); }
/** Create a new particle system template. @remarks This method is similar to the addTemplate method, except this just creates a new template and returns a pointer to it to be populated. Use this when you don't already have a system to add as a template and just want to create a new template which you will build up in-place. @param name The name of the template. Must be unique across all templates. @param resourceGroup The name of the resource group which will be used to load any dependent resources. */ CGUIParticleSystem* CGUIParticleSystemManager::createTemplate(const CGUIString& name, const CGUIString& resourceGroup) { // check name if (mSystemTemplates.find(name) != mSystemTemplates.end()) { OGRE_EXCEPT(Exception::ERR_DUPLICATE_ITEM, "CGUIParticleSystem template with name '" + name + "' already exists.", "CGUIParticleSystemManager::createTemplate"); } CGUIParticleSystem* tpl = new CGUIParticleSystem(name, resourceGroup); addTemplate(name, tpl); return tpl; }
DateVariableFactory::DateVariableFactory() : KoVariableFactory("date") { KoVariableTemplate var; var.id = "fixed"; var.name = i18n("Fixed"); KoProperties *props = new KoProperties(); props->setProperty("id", DateVariable::Fixed); props->setProperty("definition", "dd/MM/yy"); var.properties = props; addTemplate(var); QStringList elementNames; elementNames << "date" << "time"; setOdfElementNames(KoXmlNS::text, elementNames); }
int CDiagramTemplateManager::loadPackage(const QString &zipFileName) { int count = 0; QDir dir(m_templatesRoot); QString fileName, filePath; QuaZip zip(zipFileName); QuaZipFile zipFile(&zip); CDiagramTemplate *tpl = NULL; if (zip.open(QuaZip::mdUnzip)) { for(bool more = zip.goToFirstFile(); more; more = zip.goToNextFile()) { fileName = zip.getCurrentFileName(); if (fileName.toLower().endsWith(TEMPLATE_SUFFIX) && zipFile.open(QIODevice::ReadOnly)) { int len = 0; char chs[1026]; QByteArray zipData, unzipData; QDataStream stream(&zipFile); while ( (len = stream.readRawData(chs, 1024)) > 0) { zipData.append(chs, len); } unzipData = qUncompress( zipData ); tpl = loadStringAsTemplate( unzipData ); if (tpl) { fileName = QString( QCryptographicHash::hash(unzipData, QCryptographicHash::Md5).toBase64() ); filePath = dir.absoluteFilePath( QString("%1.%2").arg(fileName).arg(TEMPLATE_SUFFIX) ); saveTemplateData(unzipData, filePath); tpl->filePath = filePath; addTemplate(tpl); ++count; } zipFile.close(); } } zip.close(); } return count; }
AnnotationTextShapeFactory::AnnotationTextShapeFactory() : KoShapeFactoryBase(AnnotationShape_SHAPEID, i18n("Annotation")) { setToolTip(i18n("Annotation shape to show annotation content")); QList<QPair<QString, QStringList> > odfElements; odfElements.append(QPair<QString, QStringList>(KoXmlNS::office, QStringList("annotation"))); setXmlElements(odfElements); KoShapeTemplate t; t.name = i18n("Annotation"); t.iconName = koIconName("x-shape-text"); // Any icon for now :) t.toolTip = i18n("Annotation Shape"); KoProperties *props = new KoProperties(); t.properties = props; props->setProperty("demo", true); addTemplate(t); }
TextShapeFactory::TextShapeFactory(QObject *parent) : KShapeFactoryBase(parent, TextShape_SHAPEID, i18n("Text")) { setToolTip(i18n("A shape that shows text")); QList<QPair<QString, QStringList> > odfElements; odfElements.append(QPair<QString, QStringList>(KOdfXmlNS::draw, QStringList("text-box"))); odfElements.append(QPair<QString, QStringList>(KOdfXmlNS::table, QStringList("table"))); setOdfElements(odfElements); setLoadingPriority(1); KoShapeTemplate t; t.name = i18n("Text"); t.icon = "x-shape-text"; t.toolTip = i18n("Text Shape"); KProperties *props = new KProperties(); t.properties = props; props->setProperty("demo", true); addTemplate(t); }
//----------------------------- // Name : initFromBuffer() //----------------------------- void PoetryGen::initFromBuffer( const char * f_buff ) { char line[BUFFER_LENGTH]; int offset; while( sscanf( f_buff, "%100[^\n]%n", line, &offset ) != EOF ) { strcpy(m_buffer, line); switch (line[0]) { case 't': addTemplate(); break; case 'c': addWrdToCat(); break; } f_buff += offset + 1; offset = 0; } }
//----------------------------- // Name : processCmd() //----------------------------- void PoetryGen::processCmd( int cmd_ind ) { switch ( cmd_ind ) { case help: printHelp(); break; case clr: clearAll(); break; case ac: addWrdToCat(); break; case at: addTemplate(); break; case gen: printPoem(); break; case ln: setLinesNumber(); break; case ls: listAll(); break; case inv: default: WARNING( UNKNOWN_COMMAND ); break; } printf("\n"); }
//----------------------------------------------------------------------- ParticleSystem* ParticleSystemManager::createTemplate(const String& name, const String& resourceGroup) { OGRE_LOCK_AUTO_MUTEX; // check name if (mSystemTemplates.find(name) != mSystemTemplates.end()) { #if OGRE_PLATFORM == OGRE_PLATFORM_WINRT LogManager::getSingleton().logMessage("ParticleSystem template with name '" + name + "' already exists."); return NULL; #else OGRE_EXCEPT(Exception::ERR_DUPLICATE_ITEM, "ParticleSystem template with name '" + name + "' already exists.", "ParticleSystemManager::createTemplate"); #endif } ParticleSystem* tpl = OGRE_NEW ParticleSystem(name, resourceGroup); addTemplate(name, tpl); return tpl; }
void FromFileModule::nameScan(Program& declarations) { #ifdef LOAD_TRACE std::cerr<<"Load templates :"<<std::endl; #endif for(Program declaration : declarations) { if(declaration.tag() == HMC_CLASS_DECLARATION) { ObjectTypeTemplate& objectTypeTemplate = addTemplate(new FromFileTemplate(declaration, *this, _collector, _evaluator)); #ifdef LOAD_TRACE std::cerr<<" "<<objectTypeTemplate<<std::endl; #endif } else if(declaration.tag() == HMC_FUNCTION_DECLARATION) { const std::string& name = declaration.node(0).payload().toString(); const Program& arguments = declaration.node(1); const Program& definition = declaration.node(2); std::vector<MethodArgument> signature; for(const Program& argument: arguments) { signature.emplace_back(MethodArgument(argument.node(1).payload().toString(), !argument.node(0).payload().toBool(), _evaluator.rightValue(argument.node(2)).value())); } addMethod(name, new FromFileMethod(definition, signature, *this)); // TO DELETE _functions[name] = declaration; } } #ifdef LOAD_TRACE std::cerr<<std::endl; #endif }
CDiagramTemplate* CDiagramTemplateManager::loadStringAsTemplate(const QString &value) { QDomDocument doc; QDomElement root; CDiagramTemplate *tpl = NULL; QString title, type; QIcon icon; QByteArray iconData; QDataStream iconStream(&iconData, QIODevice::ReadOnly); if (doc.setContent(value)) { tpl = new CDiagramTemplate(); root = doc.documentElement(); tpl->type = root.firstChildElement("type").text(); tpl->title = root.firstChildElement("title").text(); // retrieve icon iconData = QByteArray::fromBase64( root.firstChildElement("icon").text().toAscii() ); iconStream >> icon; tpl->icon = icon; addTemplate(tpl); }
void CObjectClassesHandler::loadObjectEntry(const std::string & identifier, const JsonNode & entry, ObjectContainter * obj) { if (!handlerConstructors.count(obj->handlerName)) { logGlobal->error("Handler with name %s was not found!", obj->handlerName); return; } std::string convertedId = VLC->modh->normalizeIdentifier(entry.meta, "core", identifier); si32 id = selectNextID(entry["index"], obj->subObjects, 1000); auto handler = handlerConstructors.at(obj->handlerName)(); handler->setType(obj->id, id); handler->setTypeName(obj->identifier, convertedId); if (customNames.count(obj->id) && customNames.at(obj->id).size() > id) handler->init(entry, customNames.at(obj->id).at(id)); else handler->init(entry); if (handler->getTemplates().empty()) { auto range = legacyTemplates.equal_range(std::make_pair(obj->id, id)); for (auto & templ : boost::make_iterator_range(range.first, range.second)) { handler->addTemplate(templ.second); } legacyTemplates.erase(range.first, range.second); } logGlobal->debug("Loaded object %s(%d)::%s(%d)", obj->identifier, obj->id, convertedId, id); assert(!obj->subObjects.count(id)); // DO NOT override obj->subObjects[id] = handler; obj->subIds[convertedId] = id; }
nsresult txStylesheet::doneCompiling() { nsresult rv = NS_OK; // Collect all importframes into a single ordered list txListIterator frameIter(&mImportFrames); rv = frameIter.addAfter(mRootFrame); NS_ENSURE_SUCCESS(rv, rv); mRootFrame = nullptr; frameIter.next(); rv = addFrames(frameIter); NS_ENSURE_SUCCESS(rv, rv); // Loop through importframes in decreasing-precedence-order and process // all items frameIter.reset(); ImportFrame* frame; while ((frame = static_cast<ImportFrame*>(frameIter.next()))) { nsTArray<txStripSpaceTest*> frameStripSpaceTests; txListIterator itemIter(&frame->mToplevelItems); itemIter.resetToEnd(); txToplevelItem* item; while ((item = static_cast<txToplevelItem*>(itemIter.previous()))) { switch (item->getType()) { case txToplevelItem::attributeSet: { rv = addAttributeSet(static_cast<txAttributeSetItem*> (item)); NS_ENSURE_SUCCESS(rv, rv); break; } case txToplevelItem::dummy: case txToplevelItem::import: { break; } case txToplevelItem::output: { mOutputFormat.merge(static_cast<txOutputItem*>(item)->mFormat); break; } case txToplevelItem::stripSpace: { rv = addStripSpace(static_cast<txStripSpaceItem*>(item), frameStripSpaceTests); NS_ENSURE_SUCCESS(rv, rv); break; } case txToplevelItem::templ: { rv = addTemplate(static_cast<txTemplateItem*>(item), frame); NS_ENSURE_SUCCESS(rv, rv); break; } case txToplevelItem::variable: { rv = addGlobalVariable(static_cast<txVariableItem*> (item)); NS_ENSURE_SUCCESS(rv, rv); break; } } delete item; itemIter.remove(); //remove() moves to the previous itemIter.next(); } if (!mStripSpaceTests.AppendElements(frameStripSpaceTests)) { return NS_ERROR_OUT_OF_MEMORY; } frameStripSpaceTests.Clear(); } if (!mDecimalFormats.get(txExpandedName())) { nsAutoPtr<txDecimalFormat> format(new txDecimalFormat); NS_ENSURE_TRUE(format, NS_ERROR_OUT_OF_MEMORY); rv = mDecimalFormats.add(txExpandedName(), format); NS_ENSURE_SUCCESS(rv, rv); format.forget(); } return NS_OK; }
bool LLNotifications::loadTemplates() { const std::string xml_filename = "notifications.xml"; LLXMLNodePtr root; BOOL success = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root); if (!success || root.isNull() || !root->hasName( "notifications" )) { llerrs << "Problem reading UI Notifications file: " << xml_filename << llendl; return false; } clearTemplates(); for (LLXMLNodePtr item = root->getFirstChild(); item.notNull(); item = item->getNextSibling()) { // we do this FIRST so that item can be changed if we // encounter a usetemplate -- we just replace the // current xml node and keep processing item = checkForXMLTemplate(item); if (item->hasName("global")) { std::string global_name; if (item->getAttributeString("name", global_name)) { mGlobalStrings[global_name] = item->getTextContents(); } continue; } if (item->hasName("template")) { // store an xml template; templates must have a single node (can contain // other nodes) std::string name; item->getAttributeString("name", name); LLXMLNodePtr ptr = item->getFirstChild(); mXmlTemplates[name] = ptr; continue; } if (!item->hasName("notification")) { llwarns << "Unexpected entity " << item->getName()->mString << " found in " << xml_filename << llendl; continue; } // now we know we have a notification entry, so let's build it LLNotificationTemplatePtr pTemplate(new LLNotificationTemplate()); if (!item->getAttributeString("name", pTemplate->mName)) { llwarns << "Unable to parse notification with no name" << llendl; continue; } //llinfos << "Parsing " << pTemplate->mName << llendl; pTemplate->mMessage = item->getTextContents(); pTemplate->mDefaultFunctor = pTemplate->mName; item->getAttributeString("type", pTemplate->mType); item->getAttributeString("icon", pTemplate->mIcon); item->getAttributeString("label", pTemplate->mLabel); item->getAttributeU32("duration", pTemplate->mExpireSeconds); item->getAttributeU32("expireOption", pTemplate->mExpireOption); std::string priority; item->getAttributeString("priority", priority); pTemplate->mPriority = NOTIFICATION_PRIORITY_NORMAL; if (!priority.empty()) { if (priority == "low") pTemplate->mPriority = NOTIFICATION_PRIORITY_LOW; if (priority == "normal") pTemplate->mPriority = NOTIFICATION_PRIORITY_NORMAL; if (priority == "high") pTemplate->mPriority = NOTIFICATION_PRIORITY_HIGH; if (priority == "critical") pTemplate->mPriority = NOTIFICATION_PRIORITY_CRITICAL; } item->getAttributeString("functor", pTemplate->mDefaultFunctor); BOOL persist = false; item->getAttributeBOOL("persist", persist); pTemplate->mPersist = persist; std::string sound; item->getAttributeString("sound", sound); if (!sound.empty()) { // TODO: test for bad sound effect name / missing effect pTemplate->mSoundEffect = LLUUID(LLUI::sConfigGroup->getString(sound.c_str())); } for (LLXMLNodePtr child = item->getFirstChild(); !child.isNull(); child = child->getNextSibling()) { child = checkForXMLTemplate(child); // <url> if (child->hasName("url")) { pTemplate->mURL = child->getTextContents(); child->getAttributeU32("option", pTemplate->mURLOption); } if (child->hasName("unique")) { pTemplate->mUnique = true; for (LLXMLNodePtr formitem = child->getFirstChild(); !formitem.isNull(); formitem = formitem->getNextSibling()) { if (formitem->hasName("context")) { std::string key; formitem->getAttributeString("key", key); pTemplate->mUniqueContext.push_back(key); //llwarns << "adding " << key << " to unique context" << llendl; } else { llwarns << "'unique' has unrecognized subelement " << formitem->getName()->mString << llendl; } } } // <form> if (child->hasName("form")) { pTemplate->mForm = LLNotificationFormPtr(new LLNotificationForm(pTemplate->mName, child)); } } addTemplate(pTemplate->mName, pTemplate); } //std::ostringstream ostream; //root->writeToOstream(ostream, "\n "); //llwarns << ostream.str() << llendl; return true; }
StarShapeFactory::StarShapeFactory() : KoShapeFactoryBase(StarShapeId, i18n("A star shape")) { setToolTip(i18n("A star")); setIconName(koIconNameCStr("star-shape")); QStringList elementNames; elementNames << "regular-polygon" << "custom-shape"; setXmlElementNames(KoXmlNS::draw, elementNames); setLoadingPriority(5); KoShapeTemplate t; t.id = KoPathShapeId; t.templateId = "star"; t.name = i18n("Star"); t.family = "geometric"; t.toolTip = i18n("A star"); t.iconName = koIconName("star-shape"); KoProperties *props = new KoProperties(); props->setProperty("corners", 5); QVariant v; v.setValue(QColor(Qt::yellow)); props->setProperty("background", v); t.properties = props; addTemplate(t); t.id = KoPathShapeId; t.templateId = "flower"; t.name = i18n("Flower"); t.family = "funny"; t.toolTip = i18n("A flower"); t.iconName = koIconName("flower-shape"); props = new KoProperties(); props->setProperty("corners", 5); props->setProperty("baseRadius", 10.0); props->setProperty("tipRadius", 50.0); props->setProperty("baseRoundness", 0.0); props->setProperty("tipRoundness", 40.0); v.setValue(QColor(Qt::magenta)); props->setProperty("background", v); t.properties = props; addTemplate(t); t.id = KoPathShapeId; t.templateId = "pentagon"; t.name = i18n("Pentagon"); t.family = "geometric"; t.toolTip = i18n("A pentagon"); t.iconName = koIconName("pentagon-shape"); props = new KoProperties(); props->setProperty("corners", 5); props->setProperty("convex", true); props->setProperty("tipRadius", 50.0); props->setProperty("tipRoundness", 0.0); v.setValue(QColor(Qt::blue)); props->setProperty("background", v); t.properties = props; addTemplate(t); t.id = KoPathShapeId; t.templateId = "hexagon"; t.name = i18n("Hexagon"); t.family = "geometric"; t.toolTip = i18n("A hexagon"); t.iconName = koIconName("hexagon-shape"); props = new KoProperties(); props->setProperty("corners", 6); props->setProperty("convex", true); props->setProperty("tipRadius", 50.0); props->setProperty("tipRoundness", 0.0); v.setValue(QColor(Qt::blue)); props->setProperty("background", v); t.properties = props; addTemplate(t); }
ExtOscPatternEditor::ExtOscPatternEditor(QWidget *parent) : QWidget(parent), ui(new Ui::ExtOscPatternEditor) { ui->setupUi(this); textLock = false; itemLock = false; isTrigger = false; patternNbValues = 0; trees.clear(); trees << qMakePair(ui->argument1Combo, qMakePair(ui->argument1Label, ui->argument1Clear)); trees << qMakePair(ui->argument2Combo, qMakePair(ui->argument2Label, ui->argument2Clear)); trees << qMakePair(ui->argument3Combo, qMakePair(ui->argument3Label, ui->argument3Clear)); trees << qMakePair(ui->argument4Combo, qMakePair(ui->argument4Label, ui->argument4Clear)); trees << qMakePair(ui->argument5Combo, qMakePair(ui->argument5Label, ui->argument5Clear)); trees << qMakePair(ui->argument6Combo, qMakePair(ui->argument6Label, ui->argument6Clear)); trees << qMakePair(ui->argument7Combo, qMakePair(ui->argument7Label, ui->argument7Clear)); trees << qMakePair(ui->argument8Combo, qMakePair(ui->argument8Label, ui->argument8Clear)); trees << qMakePair(ui->argument9Combo, qMakePair(ui->argument9Label, ui->argument9Clear)); trees << qMakePair(ui->argument10Combo, qMakePair(ui->argument10Label, ui->argument10Clear)); foreach(const HelpInfo &info, Help::categories["protocols"].infos) ui->protocolCombo->addItem(info.keyword + QString(" - ") + info.title); foreach(const HelpInfo &info, Help::categories["hostIp"].infos) ui->hostIpCombo->addItem(info.keyword + QString(" - ") + info.title); foreach(const HelpInfo &info, Help::categories["hostMidi"].infos) ui->hostMidiCombo->addItem(info.keyword + QString(" - ") + info.title); foreach(const HelpInfo &info, Help::categories["port"].infos) ui->portCombo->addItem(info.keyword + QString(" - ") + info.title); foreach(const HelpInfo &info, Help::categories["addressOsc"].infos) ui->addressOscCombo->addItem(info.keyword + QString(" - ") + info.title); foreach(const HelpInfo &info, Help::categories["addressMidi"].infos) ui->addressMidiCombo->addItem(info.keyword + QString(" - ") + info.title); for(quint16 treeIndex = 0 ; treeIndex < trees.count() ; treeIndex++) { QStringList completerHelp; foreach(const HelpInfo &info, Help::categories["values"].infos) { trees.at(treeIndex).first->addItem(info.keyword + QString(" - ") + info.title); completerHelp << info.keyword + QString(" - ") + info.title; } QCompleter *completer = new QCompleter(completerHelp, this); completer->setCaseSensitivity(Qt::CaseInsensitive); trees.at(treeIndex).first->setCompleter(completer); } //Templates ui->templates->clear(); addTemplate("Templates", true); addTemplate("--"); QFileInfoList files = QDir(Application::pathApplication.absoluteFilePath() + "/Tools/Templates/").entryInfoList(QStringList() << "*.txt", QDir::Files | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase); files << QDir(Application::pathDocuments.absoluteFilePath() + "/Templates/").entryInfoList(QStringList() << "*.txt", QDir::Files | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase); bool firstTemplate = true; QString title; foreach(const QFileInfo &file, files) { QString header; QHash<QString, QString> params; QFile templateFile(file.absoluteFilePath()); if(templateFile.open(QFile::ReadOnly)) { QStringList templatesLong = QString(templateFile.readAll()).split("\n", QString::SkipEmptyParts); foreach(const QString &templateLong, templatesLong) { if(templateLong.startsWith("[")) header = templateLong.toLower(); else if(header == "[general]") { QStringList templateLongSplit = templateLong.split("="); if(templateLongSplit.count() > 1) { QString key = templateLongSplit.at(0).toLower(), value = templateLongSplit.at(1); params.insert(key, value); if(key == "name") title = value; } } else if(header == "[messages]") { if(!title.isEmpty()) { if(!firstTemplate) addTemplate("--"); firstTemplate = false; addTemplate(title); title.clear(); } addTemplate(" " + templateLong.trimmed(), true); } } }
void createWorkspace(){ gSystem->Load("libHiggsAnalysisCombinedLimit.so"); TFile *outfile = new TFile("workspace.root","RECREATE"); RooWorkspace wspace("w","w"); RooRealVar met("met","E_{T}^{miss}",200,1000); RooArgList vars(met); // Templates TFile* templatesfile = new TFile("templates.root"); // ---------------------------- SIGNAL REGION -------------------------------------------------------------------// // Data addTemplate("data_obs_SR", vars, wspace, (TH1F*)templatesfile->Get("datahist")); // Signal shape addTemplate("DM_SR", vars, wspace, (TH1F*)templatesfile->Get("sig1hist")); // Znunu background TH1F* znn_SR_hist = (TH1F*)templatesfile->Get("zinvhist"); RooArgList znn_SR_bins; makeBinList("Znunu_SR", met, wspace, znn_SR_hist, znn_SR_bins); // WJets background TH1F* wln_SR_hist = (TH1F*)templatesfile->Get("wjethist"); RooArgList wln_SR_bins; vector<pair<RooRealVar*, TH1*> > wln_SR_syst; RooRealVar* wln_SR_re1 = new RooRealVar("WJets_SR_RenScale1" , "", 0., -5., 5.); RooRealVar* wln_SR_fa1 = new RooRealVar("WJets_SR_FactScale1", "", 0., -5., 5.); RooRealVar* wln_SR_re2 = new RooRealVar("WJets_SR_RenScale2" , "", 0., -5., 5.); RooRealVar* wln_SR_fa2 = new RooRealVar("WJets_SR_FactScale2", "", 0., -5., 5.); RooRealVar* wln_SR_pdf = new RooRealVar("WJets_SR_PDF" , "", 0., -5., 5.); wln_SR_syst.push_back(pair<RooRealVar*, TH1*>(NULL , (TH1F*)templatesfile->Get("ZW_EWK"))); wln_SR_syst.push_back(pair<RooRealVar*, TH1*>(wln_SR_re1, (TH1F*)templatesfile->Get("ZW_RenScale1"))); wln_SR_syst.push_back(pair<RooRealVar*, TH1*>(wln_SR_fa1, (TH1F*)templatesfile->Get("ZW_FactScale1"))); wln_SR_syst.push_back(pair<RooRealVar*, TH1*>(wln_SR_re2, (TH1F*)templatesfile->Get("ZW_RenScale2"))); wln_SR_syst.push_back(pair<RooRealVar*, TH1*>(wln_SR_fa2, (TH1F*)templatesfile->Get("ZW_FactScale2"))); wln_SR_syst.push_back(pair<RooRealVar*, TH1*>(wln_SR_pdf, (TH1F*)templatesfile->Get("ZW_PDF"))); if (!connectWZ) makeBinList("WJets_SR", met, wspace, wln_SR_hist, wln_SR_bins); else makeConnectedBinList("WJets_SR", met, wspace, (TH1F*)templatesfile->Get("zwjcorewkhist"), wln_SR_syst, znn_SR_bins, &wln_SR_bins); TH1F* qcdhist = (TH1F*)templatesfile->Get("qbkghist"); qcdhist->Scale(2.0); // Other MC backgrounds addTemplate("ZJets_SR" , vars, wspace, (TH1F*)templatesfile->Get("zjethist")); addTemplate("Top_SR" , vars, wspace, (TH1F*)templatesfile->Get("tbkghist")); //addTemplate("QCD_SR" , vars, wspace, (TH1F*)templatesfile->Get("qbkghist")); addTemplate("QCD_SR" , vars, wspace, qcdhist); addTemplate("Dibosons_SR" , vars, wspace, (TH1F*)templatesfile->Get("dbkghist")); // ---------------------------- CONTROL REGION (Dimuon) -----------------------------------------------------------------// addTemplate("data_obs_ZM", vars, wspace, (TH1F*)templatesfile->Get("datahistzmm")); vector<pair<RooRealVar*, TH1*> > znn_ZM_syst; makeConnectedBinList("Znunu_ZM", met, wspace, (TH1F*)templatesfile->Get("zmmcorhist"), znn_ZM_syst, znn_SR_bins); // Other MC backgrounds in dimuon control region addTemplate("WJets_ZM" , vars, wspace, (TH1F*)templatesfile->Get("lbkghistzmm")); addTemplate("Top_ZM" , vars, wspace, (TH1F*)templatesfile->Get("tbkghistzmm")); addTemplate("QCD_ZM" , vars, wspace, (TH1F*)templatesfile->Get("qbkghistzmm")); addTemplate("Dibosons_ZM" , vars, wspace, (TH1F*)templatesfile->Get("dbkghistzmm")); // ---------------------------- CONTROL REGION (Dielectron) -----------------------------------------------------------------// addTemplate("data_obs_ZE" , vars, wspace, (TH1F*)templatesfile->Get("datahistzee")); vector<pair<RooRealVar*, TH1*> > znn_ZE_syst; makeConnectedBinList("Znunu_ZE", met, wspace, (TH1F*)templatesfile->Get("zeecorhist"), znn_ZE_syst, znn_SR_bins); // Other MC backgrounds in dielectron control region addTemplate("WJets_ZE" , vars, wspace, (TH1F*)templatesfile->Get("lbkghistzee")); addTemplate("Top_ZE" , vars, wspace, (TH1F*)templatesfile->Get("tbkghistzee")); addTemplate("QCD_ZE" , vars, wspace, (TH1F*)templatesfile->Get("qbkghistzee")); addTemplate("Dibosons_ZE" , vars, wspace, (TH1F*)templatesfile->Get("dbkghistzee")); // ---------------------------- CONTROL REGION (Photon+Jets) -----------------------------------------------------------------// addTemplate("data_obs_GJ" , vars, wspace, (TH1F*)templatesfile->Get("datahistgam")); vector<pair<RooRealVar*, TH1*> > znn_GJ_syst; RooRealVar* znn_GJ_re1 = new RooRealVar("Znunu_GJ_RenScale1" , "", 0., -5., 5.); RooRealVar* znn_GJ_fa1 = new RooRealVar("Znunu_GJ_FactScale1", "", 0., -5., 5.); RooRealVar* znn_GJ_re2 = new RooRealVar("Znunu_GJ_RenScale2" , "", 0., -5., 5.); RooRealVar* znn_GJ_fa2 = new RooRealVar("Znunu_GJ_FactScale2", "", 0., -5., 5.); RooRealVar* znn_GJ_pdf = new RooRealVar("Znunu_GJ_PDF" , "", 0., -5., 5.); RooRealVar* znn_GJ_fpc = new RooRealVar("Znunu_GJ_Footprint" , "", 0., -5., 5.); znn_GJ_syst.push_back(pair<RooRealVar*, TH1*>(NULL , (TH1F*)templatesfile->Get("ZG_EWK"))); znn_GJ_syst.push_back(pair<RooRealVar*, TH1*>(znn_GJ_re1, (TH1F*)templatesfile->Get("ZG_RenScale1"))); znn_GJ_syst.push_back(pair<RooRealVar*, TH1*>(znn_GJ_fa1, (TH1F*)templatesfile->Get("ZG_FactScale1"))); znn_GJ_syst.push_back(pair<RooRealVar*, TH1*>(znn_GJ_re2, (TH1F*)templatesfile->Get("ZG_RenScale2"))); znn_GJ_syst.push_back(pair<RooRealVar*, TH1*>(znn_GJ_fa2, (TH1F*)templatesfile->Get("ZG_FactScale2"))); znn_GJ_syst.push_back(pair<RooRealVar*, TH1*>(znn_GJ_pdf, (TH1F*)templatesfile->Get("ZG_PDF"))); znn_GJ_syst.push_back(pair<RooRealVar*, TH1*>(znn_GJ_fpc, (TH1F*)templatesfile->Get("ZG_Footprint"))); makeConnectedBinList("Znunu_GJ", met, wspace, (TH1F*)templatesfile->Get("gamcorewkhist"), znn_GJ_syst, znn_SR_bins); // Other MC backgrounds photon+jets control region addTemplate("QCD_GJ" , vars, wspace, (TH1F*)templatesfile->Get("qbkghistgam")); // ---------------------------- CONTROL REGION (Single muon) -----------------------------------------------------------------// addTemplate("data_obs_WM" , vars, wspace, (TH1F*)templatesfile->Get("datahistwmn")); vector<pair<RooRealVar*, TH1*> > wln_WM_syst; makeConnectedBinList("WJets_WM", met, wspace, (TH1F*)templatesfile->Get("wmncorhist"), wln_WM_syst, wln_SR_bins); // Other MC backgrounds in single muon control region addTemplate("ZJets_WM" , vars, wspace, (TH1F*)templatesfile->Get("lbkghistwmn")); addTemplate("Top_WM" , vars, wspace, (TH1F*)templatesfile->Get("tbkghistwmn")); addTemplate("QCD_WM" , vars, wspace, (TH1F*)templatesfile->Get("qbkghistwmn")); addTemplate("Dibosons_WM" , vars, wspace, (TH1F*)templatesfile->Get("dbkghistwmn")); // ---------------------------- CONTROL REGION (Single electron) -----------------------------------------------------------------// addTemplate("data_obs_WE" , vars, wspace, (TH1F*)templatesfile->Get("datahistwen")); vector<pair<RooRealVar*, TH1*> > wln_WE_syst; makeConnectedBinList("WJets_WE", met, wspace, (TH1F*)templatesfile->Get("wencorhist"), wln_WE_syst, wln_SR_bins); // Other MC backgrounds in single electron control region addTemplate("ZJets_WE" , vars, wspace, (TH1F*)templatesfile->Get("lbkghistwen")); addTemplate("Top_WE" , vars, wspace, (TH1F*)templatesfile->Get("tbkghistwen")); addTemplate("QCD_WE" , vars, wspace, (TH1F*)templatesfile->Get("qbkghistwen")); addTemplate("Dibosons_WE" , vars, wspace, (TH1F*)templatesfile->Get("dbkghistwen")); // ---------------------------- Write out the workspace -----------------------------------------------------------------// outfile->cd(); wspace.Write(); outfile->Close(); }
void SettingsDialog::setupTemplates() { for (auto &i: *s->templates()) addTemplate(i, ""); }
Core::GeneratedFiles QmlApp::generateFiles(QString *errorMessage) { Core::GeneratedFiles files; QTC_ASSERT(errorMessage, return files); errorMessage->clear(); setReplacementVariables(); const QFileInfoList templateFiles = allFilesRecursive(templateDirectory()); foreach (const QFileInfo &templateFile, templateFiles) { const QString targetSubDirectory = templateFile.path().mid(templateDirectory().length()); const QString targetDirectory = projectDirectory() + targetSubDirectory + QLatin1Char('/'); QString targetFileName = templateFile.fileName(); if (templateFile.fileName() == QLatin1String("main.pro")) { targetFileName = projectName() + QLatin1String(".pro"); m_creatorFileName = Core::BaseFileWizard::buildFileName(projectDirectory(), projectName(), QLatin1String("pro")); } else if (templateFile.fileName() == QLatin1String("main.qmlproject")) { targetFileName = projectName() + QLatin1String(".qmlproject"); m_creatorFileName = Core::BaseFileWizard::buildFileName(projectDirectory(), projectName(), QLatin1String("qmlproject")); } else if (templateFile.fileName() == QLatin1String("main.qbp")) { targetFileName = projectName() + QLatin1String(".qbp"); } else if (targetFileName == QLatin1String("template.xml") || targetFileName == QLatin1String("template.png")) { continue; } else { targetFileName = renameQmlFile(templateFile.fileName()); } if (binaryFiles().contains(templateFile.suffix())) { bool canAddBinaryFile = addBinaryFile(templateFile.absolutePath(), templateFile.fileName(), targetDirectory, targetFileName, &files, errorMessage); if (!canAddBinaryFile) return Core::GeneratedFiles(); } else { bool canAddTemplate = addTemplate(templateFile.absolutePath(), templateFile.fileName(), targetDirectory, targetFileName, &files, errorMessage); if (!canAddTemplate) return Core::GeneratedFiles(); if (templateFile.fileName() == QLatin1String("main.pro")) { files.last().setAttributes(Core::GeneratedFile::OpenProjectAttribute); } else if (templateFile.fileName() == QLatin1String("main.qmlproject")) { files.last().setAttributes(Core::GeneratedFile::OpenProjectAttribute); } else if (templateFile.fileName() == m_templateInfo.openFile) { files.last().setAttributes(Core::GeneratedFile::OpenEditorAttribute); } } } return files; }