Example #1
0
 def setRole(self, role):
   ''' Called by the style editing mechanism when the user changes the role. 
       The role is here only the user-determined part, and does not include the
       hard-coded part from ROLE.'''
   self.details.style_role = role
   self.arrow.setRole(role)
   Text.setRole(self, role)
   self.applyStyle()
Example #2
0
 def mouseMoveEvent(self, event):
   # Get the current position
   p = self.pos()
   Text.mouseMoveEvent(self, event)
   
   # If moved, make it permanent
   if self.pos() != p:
     np = self.pos()
     self.details.Xoffset += np.x() - p.x()
     self.details.Yoffset += np.y() - p.y()
Example #3
0
  def __init__(self, details, fp, anchor, style):
    if details.SequenceNr:
      text = '%s: %s'%(details.SequenceNr, fp.Name)
    else:
      text = fp.Name
    role = details.style_role
    self.anchor = anchor
    self.details = details
    self.fp = fp
    self.arrow = None
    Text.__init__(self, text, style, role, apply=False)
    
    self.setFlag(QtGui.QGraphicsItem.ItemIsSelectable)
    self.setFlag(QtGui.QGraphicsItem.ItemIsMovable)
    
    if isinstance(self.anchor, BlockItem):
      self.arrow = None
    else:
      # Add the arrow.
      length = style.getFloat('%s-arrow-%s-length'%(role, self.ROLE), 1.0)
      self.arrow = Line(-10*length, 0, 0, 0, self, style, (role, self.ROLE))

    self.applyStyle()
Example #4
0
 def exportSvg(self):
   tmplt = '''
              <g transform="translate($x,$y)">
                $arrow
                $txt
              </g>
   '''
   arrow=self.arrow.exportSvg() if self.arrow else ''
   txt = Text.exportSvg(self, NO_POS)  # The text position is the position of the group.
   d = dict(text=str(self.text.toPlainText()),
            x=self.x(), y=self.y(),
            txt=txt,
            arrow = arrow)
   xml = string.Template(tmplt).substitute(d)
   return xml
Example #5
0
 def mouseReleaseEvent(self, event):
   Text.mouseReleaseEvent(self, event)
   self.scene().session.commit()
Example #6
0
 def applyStyle(self):
   Text.applyStyle(self)
   if self.arrow:
     self.arrow.applyStyle()
   self.updatePos()