Example #1
0
 def _addObjectToGroup(self, _object): 
     """Appends object to layout group
     """ 
     res = LayoutGroupDepth._addObjectToGroup(self, _object)
     self.need_layout = True
     
     return res
Example #2
0
 def _addObjectToGroup(self, _object):
     """Append object to layout group
     """
     #if lastAddedObject == None:            
     #param = session.search_one_shot(session.sc_constraint_new(sc_constants.CONSTR_5_f_a_a_a_f, desc_prm, 0, 0, 0, attr_), True, 5)
     res = LayoutGroupDepth._addObjectToGroup(self, _object)
     self.need_layout = True
     return res
    def _addObjectToGroup(self, _object):
        """Append object to layout group
        """
        res = LayoutGroupDepth._addObjectToGroup(self, _object)
        
        if (isinstance(_object, objects.ObjectLine)):
            return True
        
#        self.step = self.step_max
        self.need_layout = True
                
        # calculate object position as an geometrical center of connected to it objects
        pos = None
        count = 0
        objs = _object.getLinkedObjects(Object.LS_IN)
        for obj in objs:
            if obj.getBegin() in self.objects:
                if pos is None:
                    pos = obj.getBegin().getPosition()
                    count += 1
                else:
                    pos += obj.getPosition()
                    count += 1
                
            
        objs = _object.getLinkedObjects(Object.LS_OUT)
        for obj in objs:
            if obj.getEnd() in self.objects:
                if pos is None:
                    pos = obj.getBegin().getPosition()
                    count += 1
                else:
                    pos += obj.getPosition()
                    count += 1
       
        if pos is not None:
            pos = pos / float(count)
        else:
            pos = ogre.Vector3(0, 0, 0)
            
        if render_engine.viewMode is render_engine.Mode_Isometric:
            pos = pos + ogre.Vector3(math.cos(len(self.objects) * (math.pi**2)), math.sin(len(self.objects)* (math.pi**2)), 0.0)
        else:
            dx = math.cos(len(self.objects) * (math.pi**2))
            dy = math.sin(len(self.objects)* (math.pi**2))
            pos = pos + ogre.Vector3(dx, dy, dx + dy)
                
        _object.setPosition(pos)
   
        return res
    def _addObjectToGroup(self, _object):
        """Append object to layout group
        """
        res = LayoutGroupDepth._addObjectToGroup(self, _object)
#        self.step = self.step_max
        self.need_layout = True
        
#        if render_engine.viewMode is render_engine.Mode_Isometric:
#            _object.setPosition(ogre.Vector3(math.cos(self.angle), math.sin(self.angle), 0.0) * self.radius)
#        else:
#            _object.setPosition(ogre.Vector3(math.cos(self.angle), math.sin(self.angle), math.sin(self.angle) + math.cos(self.angle)) * self.radius)
        #self.radius += 1.0 / 36.0
        #self.angle += 0.17
        
        # calculate object position as an geometrical center of connected to it objects
        pos = None
        count = 0
        objs = _object.getLinkedObjects(Object.LS_IN)
        for obj in objs:
            if obj.getBegin() in self.objects:
                if pos is None:
                    pos = obj.getPosition()
                    count += 1
                else:
                    pos += obj.getPosition()
                    count += 1
                
            
        objs = _object.getLinkedObjects(Object.LS_OUT)
        for obj in objs:
            if obj.getBegin() in self.objects:
                if pos is None:
                    pos = obj.getPosition()
                    count += 1
                else:
                    pos += obj.getPosition()
                    count += 1
                    
        if pos is not None:
            pos = pos / float(count)
        else:
            pos = ogre.Vector3(0, 0, 0)
            
        if render_engine.viewMode is render_engine.Mode_Isometric:
            pos = pos + ogre.Vector3(math.cos(len(self.nodes) * (math.pi**2)), math.sin(len(self.nodes)* (math.pi**2)), 0.0) * 2
        else:
            pos = pos + ogre.Vector3(2 * math.cos(len(objs)), 2 * math.sin(len(objs)), math.cos(len(objs)) + math.sin(len(objs)))
        _object.setPosition(pos)
   
        return res