mscprocedure.py 2.44 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
#******************************************************************************
#
# TASTE Msc Diagram Editor
# http://taste.tuxfamily.org/
#
#  This file is part of TASTE Msc Editor.
#
#  TASTE Msc Diagram Editor is free software: you can redistribute it and/or
#  modify it under the terms of the GNU LGPL as published
#  by the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  TASTE Msc Diagram Editor is distributed in the hope that it will be
#  useful,(but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU LGPL for more details.
#
#  You should have received a copy of the GNU LGPL
#  along with TASTE Msc Diagram Editor.  If not, see
#  <http://www.gnu.org/licenses/>.
#
#  Author: Angel Esquinas <aesquina@datsi.fi.upm.es>
#  Author of this module: Maxime Perrotin maxime.perrotin@esa.int
#
#  Copyright (c) 2015 UPM and European Space Agency
#
#******************************************************************************
u"""
The :class:`msccore.MscProcedure` class represents a Procedure call
within the MSC.

:class:`msccore.MscProcedure`

"""
from mscelement import MscElement
36 37
import mscregexp
from PySide.QtCore import QRegExp
38 39 40 41 42 43 44 45 46

class MscProcedure(MscElement):
    u"""
    :param unicode name: Text of the procedure call
    :param int orderPos: Absolute pos of symbol, when used as event.
    :param parent:
    :type parent: PySide.QtCore.QObject
    """
    TYPE = u"Procedure"
47 48
    # Label allow more character than basic MscElement
    _NameRegExp = QRegExp('(' + mscregexp.Text + ')')
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78

    def __init__(self, name, orderPos=0, parent=None):
        '''
        Constructor
        '''
        super(MscProcedure, self).__init__(name, parent, self.TYPE)
        self.setAbsPos(orderPos)

    def delete(self):
        """ Delete is the destructor of MscProcedure
        The signal 'deleted' is emitted before destroy himself.
        """
        self.deleted.emit(self)
        self.deleteLater()

    #Order/Graphical Pos
    def setAbsPos(self, pos):
        self._absPos = pos

    def absPos(self):
        return self._absPos

    def accept(self, visitor):
        u""" Visitor Pattern"""
        visitor.visitorMscProcedure(self)

    def __str__(self):
        return """<<{0}:{1}. Pos {3}>>\n
                comment: {4}""".format(self.TYPE, self.getName(),
                                       self.absPos(), self.comment())