Esempio n. 1
0
 def data(self, index):
     if index in [Qt.WhatsThisRole, Qt.AccessibleTextRole]:
         return self.__class__.__name__
     elif index == Qt.AccessibleDescriptionRole:
         designation = self.abstractPart.name.strip()
         if designation.startswith("~Move"):
             # after split, the result is in example: ['~Moved', 'to', '30027a']
             # get absolute path to part plain text file
             partname = designation.split(" ")[2]
             filepath = LDrawFile.getPartFilePath(partname + ".dat")
             designation = ""
             if filepath:
                 # read and parse first line in file or pass silently
                 f = open(filepath,"r")
                 try:
                     designation = f.readline().strip().replace('0 ','').replace('  ',' ')
                 except (IOError, OSError):
                     pass    
                 f.close()
             else:
                 LicHelpers.writeLogEntry("Can not find %s in LDraw library" % partname)
         return designation
     else:        
         if self._dataString:
             return self._dataString
 
         colorName = self.color.name if self.color else "Unnamed"
         if CSITreeManager.showPartGroupings:
             x, y, z = LicHelpers.GLMatrixToXYZ(self.matrix)
             self._dataString = "%s - (%.1f, %.1f, %.1f)" % (colorName, x, y, z)
         else:
             self._dataString = "%s - %s" % (self.abstractPart.name, colorName)
 
         return self._dataString
Esempio n. 2
0
 def data(self, index):
     if index in [Qt.WhatsThisRole, Qt.AccessibleTextRole]:
         return self.__class__.__name__
     elif index == Qt.AccessibleDescriptionRole:
         designation = self.abstractPart.name.strip()
         if designation.startswith("~Move"):
             # after split, the result is in example: ['~Moved', 'to', '30027a']
             # get absolute path to part plain text file
             partname = designation.split(" ")[2]
             filepath = LDrawFile.getPartFilePath(partname + ".dat")
             designation = ""
             if filepath:
                 # read and parse first line in file or pass silently
                 f = open(filepath,"r")
                 try:
                     designation = f.readline().strip().replace('0 ','').replace('  ',' ')
                 except (IOError, OSError):
                     pass    
                 f.close()
             else:
                 LicHelpers.writeLogEntry("Can not find %s in LDraw library" % partname)
         return designation
     else:        
         if self._dataString:
             return self._dataString
 
         colorName = self.color.name if self.color else "Unnamed"
         if CSITreeManager.showPartGroupings:
             x, y, z = LicHelpers.GLMatrixToXYZ(self.matrix)
             self._dataString = "%s - (%.1f, %.1f, %.1f)" % (colorName, x, y, z)
         else:
             self._dataString = "%s - %s" % (self.abstractPart.name, colorName)
 
         return self._dataString
Esempio n. 3
0
 def data(self, index):
     if index in [Qt.WhatsThisRole, Qt.AccessibleTextRole]:
         return self.__class__.__name__
     elif index == Qt.AccessibleDescriptionRole:
         designation = self.abstractPart.name.strip()
         if designation.startswith("~Move"):
             # after split, the result is in example: ['~Moved', 'to', '30027a']
             # get absolute path to part plain text file
             filepath = LDrawFile.getPartFilePath(designation.split(" ")[2] + ".dat")
             designation = ""
             if filepath:
                 # read and parse first line in file or pass silently
                 f = open(filepath,"r")
                 try:
                     designation = f.readline().strip().replace('0 ','').replace('  ',' ')
                 except (IOError, OSError):
                     designation = ""
                     pass    
                 f.close()
         return designation        
     else:      
         colorName = self.color.name if self.color else "Unnamed"
         return "%s - %s" % (self.abstractPart.name, colorName)
Esempio n. 4
0
 def data(self, index):
     if index in [Qt.WhatsThisRole, Qt.AccessibleTextRole]:
         return self.__class__.__name__
     elif index == Qt.AccessibleDescriptionRole:
         designation = self.abstractPart.name.strip()
         if designation.startswith("~Move"):
             # after split, the result is in example: ['~Moved', 'to', '30027a']
             # get absolute path to part plain text file
             filepath = LDrawFile.getPartFilePath(designation.split(" ")[2] + ".dat")
             designation = ""
             if filepath:
                 # read and parse first line in file or pass silently
                 f = open(filepath,"r")
                 try:
                     designation = f.readline().strip().replace('0 ','').replace('  ',' ')
                 except (IOError, OSError):
                     designation = ""
                     pass    
                 f.close()
         return designation        
     else:      
         colorName = self.color.name if self.color else "Unnamed"
         return "%s - %s" % (self.abstractPart.name, colorName)