Esempio n. 1
0
	def CreateBlock(*argv, **kwargs):
		""" Create Block from python_file and other info coming from wizard.
		"""
		import Core.Components.Container as Container

		python_file = kwargs['python_file']
		canvas = kwargs['canvas'] if 'canvas' in kwargs else None
		x = kwargs['x'] if 'x' in kwargs else None
		y = kwargs['y'] if 'y' in kwargs else None

		# associated python class
		cls = GetClass(python_file)

		if inspect.isclass(cls):
			# adding devs model on good graphical model
			if issubclass(cls, DomainBehavior.DomainBehavior):
				amd = AMDComponent(*argv, **kwargs)
				m = amd.Create()
				### move AMD model
				if canvas and x and y:
					### convert coordinate depending on the canvas
					x, y = canvas.GetXY(m, x, y)
					# move model from mouse position
					m.move(x, y)
				return m
			elif issubclass(cls, DomainStructure.DomainStructure):
				cmd = CMDComponent(*argv, **kwargs)
				m = cmd.Create()
				### move CMD model
				if canvas and x and y:
					### convert coordinate depending on the canvas
					x, y = canvas.GetXY(m, x, y)
					# move model from mouse position
					m.move(x, y)
				return m
			elif 'IPort' in cls.__name__:
				label = kwargs['label']
				iid = kwargs['id'] if 'id' in kwargs else canvas.GetDiagram().GetiPortCount()
				m = Container.iPort(label="%s %d" % (label, iid))
				m.id = iid
				m.move(x - 70, y - 70)
				return m
			elif 'OPort' in cls.__name__:
				label = kwargs['label']
				oid = kwargs['id'] if 'id' in kwargs else canvas.GetDiagram().GetoPortCount()
				m = Container.oPort(label="%s %d" % (label, oid))
				m.id = oid
				m.move(x - 70, y - 70)
				return m
			else:
				dial = wx.MessageDialog(None, _('Object not instantiated !\n\n Perhaps there is bad imports.'), _('Exclamation'), wx.OK | wx.ICON_EXCLAMATION)
				dial.ShowModal()
				return False

		### inform user of the existance of error and return None
		else:
			MsgBoxError(None, Utilities.GetActiveWindow(), cls)

		return None	
		
Esempio n. 2
0
	def Create(self):
		""" Create CMD from constructor
		"""
		import Core.Components.Container as Container
		# new containerBlock model
		self.__m = Container.ContainerBlock(self._label, self._inputs, self._outputs)

		# input and output ports
		for i in xrange(self._inputs):
			self.__m.nbiPort += i
			id = self.__m.nbiPort
			iport = Container.iPort(label='IPort %d' % id)
			iport.id = id
			self.__m.AddShape(iport)

		for o in xrange(self._outputs):
			self.__m.nboPort += o
			id = self.__m.nboPort
			oport = Container.oPort(label='OPort %d' % id)
			oport.id = id
			self.__m.AddShape(oport)

		self.__m.python_path = self._python_file
		self.__m.model_path = self._model_file

		return self.__m
Esempio n. 3
0
    def Create(self):
        """ Create CMD from constructor
		"""
        import Core.Components.Container as Container
        # new containerBlock model
        self.__m = Container.ContainerBlock(self._label, self._inputs,
                                            self._outputs)

        # input and output ports
        for i in xrange(self._inputs):
            self.__m.nbiPort += i
            id = self.__m.nbiPort
            iport = Container.iPort(label='IPort %d' % id)
            iport.id = id
            self.__m.AddShape(iport)

        for o in xrange(self._outputs):
            self.__m.nboPort += o
            id = self.__m.nboPort
            oport = Container.oPort(label='OPort %d' % id)
            oport.id = id
            self.__m.AddShape(oport)

        self.__m.python_path = self._python_file
        self.__m.model_path = self._model_file

        return self.__m
Esempio n. 4
0
    def CreateBlock(*argv, **kwargs):
        """ Create Block from python_file and other info coming from wizard.
		"""
        import Core.Components.Container as Container

        python_file = kwargs['python_file']
        canvas = kwargs['canvas'] if 'canvas' in kwargs else None
        x = kwargs['x'] if 'x' in kwargs else None
        y = kwargs['y'] if 'y' in kwargs else None

        # associated python class
        cls = GetClass(python_file)

        if inspect.isclass(cls):
            # adding devs model on good graphical model
            if issubclass(cls, DomainBehavior.DomainBehavior):
                amd = AMDComponent(*argv, **kwargs)
                m = amd.Create()
                ### move AMD model
                if canvas and x and y:
                    ### convert coordinate depending on the canvas
                    x, y = canvas.GetXY(m, x, y)
                    # move model from mouse position
                    m.move(x, y)
                return m
            elif issubclass(cls, DomainStructure.DomainStructure):
                cmd = CMDComponent(*argv, **kwargs)
                m = cmd.Create()
                ### move CMD model
                if canvas and x and y:
                    ### convert coordinate depending on the canvas
                    x, y = canvas.GetXY(m, x, y)
                    # move model from mouse position
                    m.move(x, y)
                return m
            elif 'IPort' in cls.__name__:
                label = kwargs['label']
                iid = kwargs['id'] if 'id' in kwargs else canvas.GetDiagram(
                ).GetiPortCount()
                m = Container.iPort(label="%s %d" % (label, iid))
                m.id = iid
                m.move(x - 70, y - 70)
                return m
            elif 'OPort' in cls.__name__:
                label = kwargs['label']
                oid = kwargs['id'] if 'id' in kwargs else canvas.GetDiagram(
                ).GetoPortCount()
                m = Container.oPort(label="%s %d" % (label, oid))
                m.id = oid
                m.move(x - 70, y - 70)
                return m
            else:
                dial = wx.MessageDialog(
                    None,
                    _('Object not instantiated !\n\n Perhaps there is bad imports.'
                      ), _('Exclamation'), wx.OK | wx.ICON_EXCLAMATION)
                dial.ShowModal()
                return False

        ### inform user of the existance of error and return None
        else:
            MsgBoxError(None, Utilities.GetActiveWindow(), cls)

        return None