예제 #1
0
	def createFromXml(node: QDomNode):
		if node.nodeName() != "distributor":
			return None
		if not (node.hasAttributes() and node.attributes().contains("id")):
			return None
		id = node.attributes().namedItem("id").nodeValue()
		childs = node.childNodes()
		graphics = None
		tags = []
		for i in range(childs.count()):
			child = childs.at(i)
			if child.nodeName() == "graphics":
				graphics = PFSXmlBase.getNode(child)
			if child.nodeName() == "tags":
				tags = PFSBasicElement.createFromXml(child)
		if graphics is not None:
			di = PFSDistributorContent()
			di._id = id
			di._x = graphics.rect.x()
			di._y = graphics.rect.y()
			di._width = graphics.rect.width()
			di._height = graphics.rect.height()
			if graphics.line is not None:
				di._pen = graphics.line
			if graphics.brush is not None:
				di._brush = graphics.brush
			di._tags = tags	
			return di			
		return None
예제 #2
0
 def getNode(node: QDomNode):
     if node.nodeName() != "graphics":
         return None
     x = None
     y = None
     w = None
     h = None
     brush = None
     line = None
     childs = node.childNodes()
     for i in range(childs.count()):
         child = childs.at(i)
         if child.nodeName() == "position":
             pos = PFSXmlBase.getPosition(child)
             if pos is not None:
                 x = pos.x
                 y = pos.y
         if child.nodeName() == "dimension":
             pos = PFSXmlBase.getPosition(child)
             if pos is not None:
                 w = pos.x
                 h = pos.y
         if child.nodeName() == "fill":
             brush = PFSXmlBase.getFill(child)
         if child.nodeName() == "line":
             line = PFSXmlBase.getLine(child)
     if x is None or y is None or w is None or h is None:
         return None
     ans = PFSAux()
     ans.rect = QRect(x, y, w, h)
     ans.line = line
     ans.brush = brush
     return ans
예제 #3
0
 def getFill(node: QDomNode):
     if node.nodeName() != "fill":
         return None
     attr = node.attributes()
     if not (node.hasAttributes() and attr.contains("color")):
         return None
     brush = QBrush(Qt.black, Qt.SolidPattern)
     brush.setColor(QColor(attr.namedItem("color").nodeValue()))
     return brush
예제 #4
0
 def getPosition(node: QDomNode):
     if node.nodeName() not in ["position", "dimension", "offset"]:
         return None
     if not (node.hasAttributes() and node.attributes().contains("x")
             and node.attributes().contains("y")):
         return None
     ans = PFSAux()
     ans.x = float(node.attributes().namedItem("x").nodeValue())
     ans.y = float(node.attributes().namedItem("y").nodeValue())
     return ans
예제 #5
0
 def getLine(node: QDomNode):
     if node.nodeName() not in ["line"]:
         return None
     attr = node.attributes()
     if not (node.hasAttributes() and attr.contains("color")):
         return None
     pen = QPen(QColor(attr.namedItem("color").nodeValue()))
     if attr.contains("width"):
         pen.setWidth(int(attr.namedItem("width").nodeValue()))
     if attr.contains("style"):
         if attr.namedItem("style").nodeValue() == "dash":
             pen.setStyle(Qt.DashLine)
         if attr.namedItem("style").nodeValue() == "dot":
             pen.setStyle(Qt.DotLine)
     return pen
예제 #6
0
 def getArc(node: QDomNode):
     if node.nodeName() != "graphics":
         return None
     p = []
     line = None
     childs = node.childNodes()
     for i in range(childs.count()):
         child = childs.at(i)
         if child.nodeName() == "position":
             pos = PFSXmlBase.getPosition(child)
             if pos is not None:
                 p.append(pos)
         if child.nodeName() == "line":
             line = PFSXmlBase.getLine(child)
     ans = PFSAux()
     ans.pos = p
     ans.line = line
     return ans
예제 #7
0
 def createFromXml(node: QDomNode):
     ans = []
     if node.nodeName() != "tags":
         return ans
     childs = node.childNodes()
     for i in range(childs.count()):
         child = childs.at(i)
         if child.nodeName() != "tag":
             continue
         attr = child.attributes()
         if not (child.hasAttributes() and attr.contains("name")):
             continue
         name = attr.namedItem("name").nodeValue()
         use = ""
         if attr.contains("use"):
             use = attr.namedItem("use").nodeValue()
         ans.append(PFSTags(name, use))
     return ans
예제 #8
0
	def createFromXml(node: QDomNode):
		if node.nodeName() != "activity":
			return None
		if not (node.hasAttributes() and node.attributes().contains("id")):
			return None
		id = node.attributes().namedItem("id").nodeValue()
		childs = node.childNodes()
		graphics = None
		text = None
		if node.attributes().contains("inputnum"):
			inputNum =  int(node.attributes().namedItem("inputnum").nodeValue())
		else:
			inputNum = 1
		if node.attributes().contains("outputnum"):
			outputNum =  int(node.attributes().namedItem("outputnum").nodeValue())
		else:
			outputNum = 1
		tags = []
		for i in range(childs.count()):
			child = childs.at(i)
			if child.nodeName() == "graphics":
				graphics = PFSXmlBase.getNode(child)
			if child.nodeName() == "text":
				text = PFSXmlBase.getText(child)
			if child.nodeName() == "tags":
				tags = PFSBasicElement.createFromXml(child)
		if graphics is not None and text is not None:
			ac = PFSActivityContent()
			ac._id = id
			ac._x = graphics.rect.x()
			ac._y = graphics.rect.y()
			ac._text = text.annotation
			ac._width = graphics.rect.width()
			ac._height = graphics.rect.height()		
			if text.font is not None:
				ac._textFont = text.font
				ac._fontMetrics = QFontMetrics(text.font)
			if graphics.line is not None:
				ac._pen = graphics.line
			if graphics.brush is not None:
				ac._brush = graphics.brush
			ac._tags = tags
			ac._inputNum = inputNum
			ac._outputNum = outputNum
			return ac
		return None
예제 #9
0
 def getFont(node: QDomNode):
     if node.nodeName() != "font":
         return None
     attr = node.attributes()
     if not (node.hasAttributes() and attr.contains("family")
             and attr.contains("size")):
         return None
     ans = PFSAux()
     ans.font = QFont(
         attr.namedItem("family").nodeValue(),
         int(attr.namedItem("size").nodeValue()))
     if attr.contains("style"):
         if attr.namedItem("style").nodeValue() == "italic":
             ans.font.setStyle(QFont.StyleItalic)
         elif attr.namedItem("style").nodeValue() == "oblique":
             ans.font.setStyle(QFont.StyleOblique)
     if attr.contains("weight"):
         v = [
             "bold", "bolder", "lighter", "100", "200", "300", "400", "500",
             "600", "700", "800", "900", "900"
         ]
         if attr.namedItem("weight").nodeValue() in v:
             ans.font.setWeight(
                 v.index(attr.namedItem("weight").nodeValue()) * 4 + 50)
     if attr.contains("decoration"):
         decor = attr.namedItem("decoration").nodeValue()
         if decor.find("underline") > 0:
             ans.font.setUnderline(True)
         if decor.find("overline") > 0:
             ans.font.setOverline(True)
         if decor.find("line-through") > 0:
             ans.font.setStrikeOut(True)
     if attr.contains("align"):
         ans.align = attr.namedItem("align").nodeValue()
     else:
         ans.align = None
     if attr.contains("rotation"):
         ans.rotation = int(attr.namedItem("rotation").nodeValue())
     else:
         ans.rotation = None
     return ans
예제 #10
0
 def createFromXml(node: QDomNode):
     if node.nodeName() != "relation":
         return None
     attr = node.attributes()
     if not (node.hasAttributes() and attr.contains("id")):
         return None
     id = attr.namedItem("id").nodeValue()
     if not (attr.contains("source") and attr.contains("target")):
         return None
     source = attr.namedItem("source").nodeValue()
     target = attr.namedItem("target").nodeValue()
     sourceNum = 0
     targetNum = 0
     if attr.contains("sourceport"):
         sourceNum = int(attr.namedItem("sourceport").nodeValue())
     if attr.contains("targetport"):
         targetNum = int(attr.namedItem("targetport").nodeValue())
     graphics = None
     tags = []
     childs = node.childNodes()
     for i in range(childs.count()):
         child = childs.at(i)
         if child.nodeName() == "graphics":
             graphics = PFSXmlBase.getArc(child)
         if child.nodeName() == "tags":
             tags = PFSBasicElement.createFromXml(child)
     re = PFSRelationContent()
     re._id = id
     re._source = source
     re._sourceNum = sourceNum
     re._target = target
     re._targetNum = targetNum
     if graphics is not None and graphics.line is not None:
         re._pen = graphics.line
     re._midPoints = []
     if graphics is not None and graphics.pos is not None:
         for pos in graphics.pos:
             re._midPoints.append(QPointF(pos.x, pos.y))
     re._tags = tags
     return re
예제 #11
0
	def createFromXml(node: QDomNode):
		if node.nodeName() != "closeactivity":
			return None
		if not (node.hasAttributes() and node.attributes().contains("id")):
			return None
		id = node.attributes().namedItem("id").nodeValue()
		childs = node.childNodes()
		graphics = None
		tags = []
		for i in range(childs.count()):
			child = childs.at(i)
			if child.nodeName() == "graphics":
				graphics = PFSXmlBase.getNode(child)
			if child.nodeName() == "tags":
				tags = PFSBasicElement.createFromXml(child)
		if graphics is not None:
			ca = PFSCloseActivityContent()
			ca._id = id
			ca._x = graphics.rect.x() + 6
			ca._y = graphics.rect.y()
			ca._h = graphics.rect.height()
			ca._tags = tags
			return ca
		return None	
예제 #12
0
 def createFromXml(node: QDomNode):
     if node.nodeName() != "secondaryflow":
         return None
     attr = node.attributes()
     if not (node.hasAttributes() and attr.contains("id")):
         return None
     id = attr.namedItem("id").nodeValue()
     if not (attr.contains("source") and attr.contains("target")):
         return None
     source = attr.namedItem("source").nodeValue()
     target = attr.namedItem("target").nodeValue()
     lineX = 0
     if attr.contains("linex"):
         lineX = float(attr.namedItem("linex").nodeValue())
     graphics = None
     tags = []
     childs = node.childNodes()
     for i in range(childs.count()):
         child = childs.at(i)
         if child.nodeName() == "graphics":
             graphics = PFSXmlBase.getArc(child)
         if child.nodeName() == "tags":
             tags = PFSBasicElement.createFromXml(child)
     re = PFSSecondaryFlowContent()
     re._id = id
     re._source = source
     re._target = target
     re._lineX = lineX
     if graphics is not None and graphics.line is not None:
         re._pen = graphics.line
     if graphics is not None and graphics.pos is not None:
         re._midPoints = graphics.pos
     else:
         re._midPoints = []
     re._tags = tags
     return re
예제 #13
0
 def getText(node: QDomNode):
     graphics = None
     text = None
     childs = node.childNodes()
     for i in range(childs.count()):
         child = childs.at(i)
         if child.nodeName() == "annotation":
             text = child.toElement().text()
         if child.nodeName() == "graphics":
             graphics = PFSXmlBase.getGraphicsText(child)
     if text is None or graphics is None:
         return None
     ans = PFSAux()
     ans.annotation = text
     ans.x = graphics.x
     ans.y = graphics.y
     ans.font = graphics.font
     ans.align = graphics.align
     ans.rotation = graphics.rotation
     ans.line = graphics.line
     ans.brush = graphics.brush
     return ans
예제 #14
0
 def toolHasChild(node: QDomNode, value: str) -> bool:
     if node.nodeName() != "toolspecific":
         return False
     attr = node.attributes()
     if not (node.hasAttributes() and attr.contains("tool")
             and attr.namedItem("tool").nodeValue() == "PFS"):
         return False
     if not (node.hasAttributes() and attr.contains("version")
             and attr.namedItem("version").nodeValue() == "1.0.0"):
         return False
     if not node.hasChildNodes():
         return False
     childs = node.childNodes()
     for i in range(childs.count()):
         if childs.at(i).nodeName() == value:
             return True
     return False
예제 #15
0
    def filesDefToArray(self,
                        xml: QtXml.QDomNode) -> Dict[str, Dict[str, str]]:
        """Convert Module MOD xml to array."""
        root = xml.firstChild()
        files = root.childNodes()
        ret = {}
        i = 0
        while i < len(files):
            item = files.item(i)
            fil = {
                "id": item.namedItem(u"name").toElement().text(),
                "module": item.namedItem(u"module").toElement().text(),
                "text": item.namedItem(u"text").toElement().text(),
                "shatext": item.namedItem(u"shatext").toElement().text(),
                "binary": item.namedItem(u"binary").toElement().text(),
                "shabinary": item.namedItem(u"shabinary").toElement().text(),
            }
            i += 1
            if len(fil["id"]) == 0:
                continue
            ret[fil["id"]] = fil

        return ret
예제 #16
0
 def getGraphicsText(node: QDomNode):
     x = None
     y = None
     font = None
     brush = None
     line = None
     align = None
     rotation = None
     childs = node.childNodes()
     for i in range(childs.count()):
         child = childs.at(i)
         if child.nodeName() == "offset":
             pos = PFSXmlBase.getPosition(child)
             if pos is not None:
                 x = pos.x
                 y = pos.y
         if child.nodeName() == "font":
             f = PFSXmlBase.getFont(child)
             if f is not None:
                 font = f.font
                 align = f.align
                 rotation = f.rotation
         if child.nodeName() == "fill":
             brush = PFSXmlBase.getFill(child)
         if child.nodeName() == "line":
             line = PFSXmlBase.getLine(child)
     if x is None or y is None:
         return None
     ans = PFSAux()
     ans.x = x
     ans.y = y
     ans.font = font
     ans.align = align
     ans.rotation = rotation
     ans.line = line
     ans.brush = brush
     return ans
예제 #17
0
 def reportTemplate(self):
     return FLDomNodeInterface.nodeInterface(
         self.rt if self.rt else QtXml.QDomDocument()
     )
예제 #18
0
 def reportData(self):
     return FLDomNodeInterface.nodeInterface(
         self.rd if self.rd else QtXml.QDomDocument()
     )
예제 #19
0
 def createFromXml(node: QDomNode):
     if node.nodeName() != "page":
         return None
     id = None
     mainpage = None
     ref = None
     width = None
     height = None
     activities = []
     openactivities = []
     closeactivities = []
     distributors = []
     relations = []
     secondaries = []
     childs = node.childNodes()
     tags = []
     for i in range(childs.count()):
         child = childs.at(i)
         if PFSXmlBase.toolHasChild(child, "pagetype"):
             confChilds = child.childNodes()
             for j in range(confChilds.count()):
                 confChild = confChilds.at(j)
                 if confChild.nodeName() == "pagetype":
                     if confChild.hasAttributes():
                         attr = confChild.attributes()
                         if attr.contains("id"):
                             id = attr.namedItem("id").nodeValue()
                         if attr.contains("mainpage"):
                             mainpage = attr.namedItem(
                                 "mainpage").nodeValue() == "true"
                         if attr.contains("ref"):
                             ref = attr.namedItem("ref").nodeValue()
                 if confChild.nodeName() == "pagegraphics":
                     for k in range(confChild.childNodes().count()):
                         graph = confChild.childNodes().at(k)
                         if graph.nodeName() == "dimension":
                             graphic = PFSXmlBase.getPosition(graph)
                             if graphic is not None:
                                 width = graphic.x
                                 height = graphic.y
                 if confChild.nodeName() == "tags":
                     tags = PFSBasicElement.createFromXml(confChild)
         elif PFSXmlBase.toolHasChild(child, "activity"):
             confChilds = child.childNodes()
             if confChilds.at(0).nodeName() == "activity":
                 activity = PFSActivity.createFromXml(confChilds.at(0))
                 if activity is not None:
                     activities.append(activity)
         elif PFSXmlBase.toolHasChild(child, "openactivity"):
             confChilds = child.childNodes()
             if confChilds.at(0).nodeName() == "openactivity":
                 openactivity = PFSOpenActivity.createFromXml(
                     confChilds.at(0))
                 if openactivity is not None:
                     openactivities.append(openactivity)
         elif PFSXmlBase.toolHasChild(child, "closeactivity"):
             confChilds = child.childNodes()
             if confChilds.at(0).nodeName() == "closeactivity":
                 closeactivity = PFSCloseActivity.createFromXml(
                     confChilds.at(0))
                 if closeactivity is not None:
                     closeactivities.append(closeactivity)
         elif PFSXmlBase.toolHasChild(child, "distributor"):
             confChilds = child.childNodes()
             if confChilds.at(0).nodeName() == "distributor":
                 distributor = PFSDistributor.createFromXml(
                     confChilds.at(0))
                 if distributor is not None:
                     distributors.append(distributor)
         elif PFSXmlBase.toolHasChild(child, "relation"):
             confChilds = child.childNodes()
             if confChilds.at(0).nodeName() == "relation":
                 relation = PFSRelation.createFromXml(confChilds.at(0))
                 if relation is not None:
                     relations.append(relation)
         elif PFSXmlBase.toolHasChild(child, "secondaryflow"):
             confChilds = child.childNodes()
             if confChilds.at(0).nodeName() == "secondaryflow":
                 secondary = PFSSecondaryFlow.createFromXml(
                     confChilds.at(0))
                 if secondary is not None:
                     secondaries.append(secondary)
     if id is not None and id != "" and mainpage is not None:
         if width is None:
             width = 600
         if height is None:
             height = 120
         page = PFSPageContent()
         page._id = id
         page._width = width
         page._height = height
         page._tags = tags
         page._ref = ref
         page._openActivities = openactivities
         page._closeActivities = closeactivities
         page._activities = activities
         page._distributors = distributors
         page._relations = relations
         page._secondaries = secondaries
         return page
     return None