MCPcopy Create free account
hub / github.com/LibreCAD/LibreCAD / requestPattern

Method requestPattern

librecad/src/lib/engine/rs_patternlist.cpp:72–98  ·  view source on GitHub ↗

* @return Pointer to the pattern with the given name or * \p NULL if no such pattern was found. The pattern will be loaded into * memory if it's not already. */

Source from the content-addressed store, hash-verified

70 * memory if it's not already.
71 */
72std::unique_ptr<RS_Pattern> RS_PatternList::requestPattern(const QString& name) {
73 RS_DEBUG->print("RS_PatternList::requestPattern %s", name.toLatin1().data());
74
75 QString name2 = name.toLower();
76 RS_DEBUG->print("Pattern: name2: %s", name2.toLatin1().data());
77 if (patterns.count(name2) == 0 || patterns.at(name2) == nullptr) {
78 auto p = std::make_unique<RS_Pattern>(name2);
79 if (p!=nullptr) {
80 p->loadPattern();
81 patterns[name2].swap(p);
82 }
83 else {
84 LC_ERR<<"RS_PatternList::"<<__func__<<"(): loading pattern failed: "<<name2;
85 RS_DIALOGFACTORY->commandMessage(QObject::tr("Hatch:: loading pattern failed: %1").arg(name2));
86 return {};
87 }
88 }
89
90 if (patterns.count(name2) == 1) {
91 RS_DEBUG->print("name2: %s, size= %d", name2.toLatin1().data(),
92 patterns[name2]->countDeep());
93 return std::unique_ptr<RS_Pattern>{static_cast<RS_Pattern*>(patterns[name2]->clone())};
94 }
95
96 return {};
97
98}
99
100
101bool RS_PatternList::contains(const QString& name) const {

Callers 3

updateMethod · 0.80
getPatternMethod · 0.80
slotPatternChangedMethod · 0.80

Calls 8

loadPatternMethod · 0.80
printMethod · 0.45
dataMethod · 0.45
countMethod · 0.45
atMethod · 0.45
commandMessageMethod · 0.45
countDeepMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected