Ejemplo n.º 1
0
 def getParentEnt(self, entity):
     """
         get the parent entity
         TODO: To be tested
     """
     _sqlSelect = """SELECT pycad_entity_id,
                         pycad_object_type,
                         pycad_object_definition,
                         pycad_object_style,
                         pycad_entity_state,
                         pycad_index,
                         pycad_visible
                         FROM pycadent
                         WHERE pycad_entity_id IN
                             (
                                 SELECT pycad_parent_id
                                 FROM pycadrel
                                 WHERE pycad_child_id =%s
                             )
                         AND pycad_entity_state NOT LIKE "DELETE"
                         AND pycad_object_type LIKE '%s'
                         AND pycad_undo_visible=1
                         """ % (str(entity.getId()), str(entity.eType))
     _dbEntRow = self.makeSelect(_sqlSelect)
     for _row in _dbEntRow:
         _style = _row[3]
         _dumpObj = pickle.loads(str(_row[2]))
         _objEnt = Entity(_row[1], _dumpObj, _style, _row[0])
         _objEnt.state = _row[4]
         _objEnt.index = _row[5]
         _objEnt.visible = _row[6]
         _objEnt.updateBBox()
         return _objEnt
     return None
Ejemplo n.º 2
0
    def getParentEnt(self,entity):
        """
            get the parent entity
            TODO: To be tested
        """
        _sqlSelect="""SELECT pycad_entity_id,
                            pycad_object_type,
                            pycad_object_definition,
                            pycad_object_style,
                            pycad_entity_state,
                            pycad_index,
                            pycad_visible
                            FROM pycadent
                            WHERE pycad_entity_id IN
                                (
                                    SELECT pycad_parent_id
                                    FROM pycadrel
                                    WHERE pycad_child_id =%s
                                )
                            AND pycad_entity_state NOT LIKE "DELETE"
                            AND pycad_object_type LIKE '%s'
                            AND pycad_undo_visible=1
                            """%(str(entity.getId()), str(entity.eType))

        _dbEntRow=self.makeSelect(_sqlSelect)
        for _row in _dbEntRow:
            _style=pickle.loads(_row[3])
            _dumpObj=pickle.loads(_row[2])
            _objEnt=Entity(_row[1],_dumpObj,_style,_row[0])
            _objEnt.state=_row[4]
            _objEnt.index=_row[5]
            _objEnt.visible=_row[6]
            _objEnt.updateBBox()
            return _objEnt
        return None
Ejemplo n.º 3
0
 def _saveStyle(self, styleObject):
     """
         save the style object
     """
     self.__logger.debug('_saveStyle')
     self.__entId += 1
     _cElements = {}
     _cElements['STYLE'] = styleObject
     #-1 is for all the entity style that do not have style :-)
     _newDbEnt = Entity('STYLE', _cElements, None, self.__entId)
     self.__EntityDb.saveEntity(_newDbEnt, self.__UndoDb.getNewUndo())
     self.saveEntityEvent(self, _newDbEnt)
     self.showEntEvent(self, _newDbEnt)
     return _newDbEnt
Ejemplo n.º 4
0
    def getAllChildrenType(self, parent, childrenType=None):
        """
            get all the children entity of type childrenType
        """
        _outObj=[]
        if not childrenType:
            childrenType='%'
        if childrenType=='ALL':
            childrenType='%' # TODO : controllare questa select pycad_id,
        _sqlSelect="""SELECT 
                            pycad_entity_id,
                            pycad_object_type,
                            pycad_object_definition,
                            pycad_object_style,
                            pycad_entity_state,
                            pycad_index,
                            pycad_visible,
                            pycad_id
                            FROM pycadent
                            WHERE pycad_entity_id IN
                                (
                                    SELECT pycad_child_id
                                    FROM pycadrel
                                    WHERE pycad_parent_id =%s
                                )
                            AND pycad_id IN (
                                SELECT max(pycad_id) 
                                FROM pycadent  
                                WHERE pycad_undo_visible=1  
                                GROUP BY pycad_entity_id ORDER BY pycad_id)
                            AND pycad_entity_state NOT LIKE "DELETE"
                            AND pycad_object_type LIKE '%s'
                            AND pycad_undo_visible=1
                            """%(str(parent.getId()), str(childrenType))
        _dbEntRow=self.makeSelect(_sqlSelect)
        for _row in _dbEntRow:
            _style=pickle.loads(_row[3])
            _dumpObj=pickle.loads(_row[2])
            _objEnt=Entity(_row[1],_dumpObj,_style,_row[0])
            _objEnt.state=_row[4]
            _objEnt.index=_row[5]
            _objEnt.visible=_row[6]
            _objEnt.updateBBox()
            _outObj.append(_objEnt)

        return _outObj
Ejemplo n.º 5
0
    def getAllChildrenType(self, parent, childrenType=None):
        """
            get all the children entity of type childrenType
        """
        _outObj=[]
        if not childrenType:
            childrenType='%'
        if childrenType=='ALL':
            childrenType='%' # TODO : controllare questa select pycad_id,
        _sqlSelect="""SELECT 
                            pycad_entity_id,
                            pycad_object_type,
                            pycad_object_definition,
                            pycad_object_style,
                            pycad_entity_state,
                            pycad_index,
                            pycad_visible,
                            pycad_id
                            FROM pycadent
                            WHERE pycad_entity_id IN
                                (
                                    SELECT pycad_child_id
                                    FROM pycadrel
                                    WHERE pycad_parent_id =%s
                                )
                            AND pycad_id IN (
                                SELECT max(pycad_id) 
                                FROM pycadent  
                                WHERE pycad_undo_visible=1  
                                GROUP BY pycad_entity_id ORDER BY pycad_id)
                            AND pycad_entity_state NOT LIKE "DELETE"
                            AND pycad_object_type LIKE '%s'
                            AND pycad_undo_visible=1
                            """%(str(parent.getId()), str(childrenType))
        _dbEntRow=self.makeSelect(_sqlSelect)
        for _row in _dbEntRow:
            _style=pickle.loads(_row[3])
            _dumpObj=pickle.loads(_row[2])
            _objEnt=Entity(_row[1],_dumpObj,_style,_row[0])
            _objEnt.state=_row[4]
            _objEnt.index=_row[5]
            _objEnt.visible=_row[6]
            _objEnt.updateBBox()
            _outObj.append(_objEnt)

        return _outObj
Ejemplo n.º 6
0
 def _saveDbEnt(self, entType=None, constructorElements=None, entity=None):
     """
         save the DbEnt to db
     """
     self.__logger.debug('_saveDbEnt')
     updateEvent = False
     if entity == None:
         _newDbEnt = Entity(entType, constructorElements,
                            self.__activeStyleObj, self.__entId)
     else:
         if self.entityExsist(entity.getId()):
             updateEvent = True
         _newDbEnt = entity
     if self.__bulkUndoIndex >= 0:
         self.__EntityDb.saveEntity(_newDbEnt, self.__bulkUndoIndex)
     else:
         self.__EntityDb.saveEntity(_newDbEnt, self.__UndoDb.getNewUndo())
     self.saveEntityEvent(self, _newDbEnt)
     if updateEvent:
         self.updateShowEntEvent(self, _newDbEnt)
     else:
         self.showEntEvent(self, _newDbEnt)
     return _newDbEnt