Beispiel #1
0
 def setData(self, idx, value, role):
     entry = self.get(idx.row())
     if idx.column() == COL_VERB:
         verbIdx = convertVariant(value)
         entry.verb = self.verbDelegate.valueForIdx(verbIdx)
         self.emit(SIGNAL("dataChanged"), (idx, idx))
         return True
     elif idx.column() == COL_COMMAND:
         entry.command = convertVariant(value)
         return True
     else:
         return False
Beispiel #2
0
 def setData(self, idx, value, role):
     if idx.column() == COL_TURTLE:
         turtleIdx = convertVariant(value)
         self.setTurtle(idx.row(), self._turtleClasses[turtleIdx])
         self.emit(SIGNAL("dataChanged"), (idx, idx))
         return True
     else:
         return False
    def selectDescriptionCandidate(self, idx):
        dc = self.model.selectedData()
        feature = tkloader.featureForPolygon(self.tagLayer, dc.landmark)
        self.tagLayer.setSelectedFeatures([feature.id()])

        print "selected", dc, feature.id()
        print "selectedFeatures", self.tagLayer.selectedFeatureCount()
        print "features"
        self.editorWindow.setPreposition(dc.engine.name())
        self.editorWindow.newGeometry(**dc.geometry)
        for f in self.tagLayer.selectedFeatures():
            print "f", f, f.id()
            print "name", qt_utils.convertVariant(
                layers.attribute(self.tagLayer, f, 'name'))
        self.rubberBand.clear()
        self.rubberBand.setPoints(dc.landmark.vertices)
        self.generateInstructions(dc.path)
def loadAnnotations(dirName, engineMap, maxExamples=None):
    tagLayer = layers.openLayer(dirName + "/tags", "tags", "ogr")
    tagFeatures = [
        layers.getGeometry(f.geometry()) for f in layers.features(tagLayer)
    ]
    tagNames = [
        convertVariant(layers.attribute(tagLayer, f, "name"))
        for f in layers.features(tagLayer)
    ]
    annotations = []
    for i, dir in enumerate(sorted(glob.glob("%s/landmark.*.ex.*" % dirName))):
        print "dir", dir

        landmark, landmarkId, ex, exId = basename(dir).split(".")
        print "landmark", landmarkId
        landmarkId = int(landmarkId)
        annotations.append(PathAnnotation(dir, tagNames[landmarkId],
                                          engineMap))
        if not (maxExamples is None) and i > maxExamples:
            break

    return tagLayer, annotations
Beispiel #5
0
 def testConvertVariant(self):
     self.assertEqual(convertVariant(QVariant(True)), True)
     self.assertEqual(convertVariant(QVariant("Hi")), "Hi")
     self.assertEqual(
         convertVariant(QVariant("Hi")).__class__, "Hi".__class__)