示例#1
0
    def neighborListClicked(self):
        if (self.neighborList.selectedItems() == []): return
        item = self.neighborList.selectedItems()[0]
        if (self.lastDoubleClicked == None):
            self.lastDoubleClicked = self.lastSingleClicked
            self.lastSingleClicked = self.findIndexOfList(
                fixedSurface.findIndexWithName(self.data.tissues, item.text()))
            if (not self.isTraining):
                self.logFile.updateSister(
                    1, self.findIndexOfOri(self.lastDoubleClicked),
                    len(self.neighbors),
                    fixedSurface.outsideOrInside(
                        self.findIndexOfOri(self.lastDoubleClicked)))
                self.logFile.updateSister(
                    2, self.findIndexOfOri(self.lastSingleClicked),
                    self.neighbors.index(
                        self.findIndexOfOri(self.lastSingleClicked)),
                    fixedSurface.outsideOrInside(
                        self.findIndexOfOri(self.lastSingleClicked)))
                self.logFile.recordClick(
                    "Click", "NeighborList",
                    self.findIndexOfOri(self.lastSingleClicked),
                    self.camera.GetPosition(), self.camera.GetFocalPoint(),
                    self.camera.GetDistance())
            # if all cells are shown in the view, not the focused view
            for actor in self.renderer.GetActors():
                index = self.modelActors.index(actor)
                if (index != self.lastDoubleClicked
                        and self.findIndexOfOri(index) not in self.neighbors
                        or index in self.markedTissues):
                    self.renderer.RemoveActor(actor)
            interact.highLightNeighbor(
                self.modelActors[self.lastSingleClicked].GetProperty())
        else:
            if (self.lastSingleClicked != None):
                self.modelActors[
                    self.lastSingleClicked].GetProperty().DeepCopy(
                        self.originalProperty[self.lastSingleClicked])
            self.lastSingleClicked = self.findIndexOfList(
                fixedSurface.findIndexWithName(self.data.tissues, item.text()))
            if (not self.isTraining):
                self.logFile.updateSister(
                    2, self.findIndexOfOri(self.lastSingleClicked),
                    self.neighbors.index(
                        self.findIndexOfOri(self.lastSingleClicked)),
                    fixedSurface.outsideOrInside(
                        self.findIndexOfOri(self.lastSingleClicked)))
                self.logFile.recordClick(
                    "Click", "NeighborList",
                    self.findIndexOfOri(self.lastSingleClicked),
                    self.camera.GetPosition(), self.camera.GetFocalPoint(),
                    self.camera.GetDistance())
            interact.highLightNeighbor(
                self.modelActors[self.lastSingleClicked].GetProperty())

        self.camera.SetFocalPoint(
            self.modelActors[self.lastDoubleClicked].GetCenter())
        self.formNeighborText(
            self.lastSingleClicked,
            self.neighbors.index(self.findIndexOfOri(self.lastSingleClicked)))
        self.vtkWidget.GetRenderWindow().Render()
示例#2
0
    def neighborListClicked(self):
        # if (self.chosenNeighbor != None):
        #     self.renderer.RemoveActor(self.neighborTextActor)
        if (self.neighborList.selectedItems() == []):   return
        item = self.neighborList.selectedItems()[0]

        if (self.focusedViewOn == False):
            for actor in self.renderer.GetActors():
                actorIndex = self.modelActors.index(actor)
                if (self.findIndexOfOri(actorIndex) not in self.neighbors and actorIndex != self.showedNeighborListOwner):
                    self.renderer.RemoveActor(actor)
            self.zoomExtents()
            coordinates = self.explodedViewDisplay()
            position = coordinates[self.existingActorsIndex.index(self.showedNeighborListOwner)]
            for i in range(len(self.existingActorsIndex)):
                self.modelActors[self.existingActorsIndex[i]].SetPosition(self.keepTargetStill(coordinates[i], position))

        if (self.chosenNeighbor):
            self.modelActors[self.chosenNeighbor].GetProperty().DeepCopy(self.originalProperty[self.chosenNeighbor])
        self.chosenNeighbor = self.findIndexOfList(fixedSurface.findIndexWithName(self.data.tissues, item.text()))
        interact.highLightNeighbor(self.modelActors[self.chosenNeighbor].GetProperty())
        indexOfOri = self.findIndexOfOri(self.chosenNeighbor)
        if (not self.isTraining):
            self.logFile.updateSister(2, indexOfOri, self.neighbors.index(indexOfOri), fixedSurface.outsideOrInside(indexOfOri))
            self.logFile.recordClick("Click", "NeighborList", indexOfOri, self.camera.GetPosition(), self.camera.GetFocalPoint(), self.camera.GetDistance())
        self.modelActors[self.chosenNeighbor].SetPosition(self.keepDistanceBetweenTwo())
        # self.camera.SetFocalPoint(self.modelActors[self.showedNeighborListOwner].GetCenter())
        # self.addNeighborText(self.chosenNeighbor, self.neighbors.index(self.findIndexOfOri(self.chosenNeighbor)))
        self.formNeighborText(self.chosenNeighbor, self.neighbors.index(indexOfOri))
        self.vtkWidget.GetRenderWindow().Render()
        self.focusedViewOn = True
示例#3
0
        def leftClickedActorHighlight(obj, ev):
            self.numberOfClicks += 1
            clickPos = obj.GetEventPosition()
            xdist = clickPos[0] - self.prePosition[0]
            ydist = clickPos[1] - self.prePosition[1]
            self.prePosition = clickPos
            moveDistance = int(math.sqrt(xdist * xdist + ydist * ydist))

            picker = vtk.vtkPropPicker()
            picker.Pick(clickPos[0], clickPos[1], 0,
                        obj.FindPokedRenderer(clickPos[0], clickPos[1]))
            NewPickedActor = picker.GetActor()

            if (moveDistance > self.resetPixelDistance):
                self.numberOfClicks = 1
                if (NewPickedActor and NewPickedActor in self.modelActors):
                    index = self.modelActors.index(NewPickedActor)
                    if (index != self.lastDoubleClicked):
                        if (self.lastSingleClicked != None
                                and self.lastSingleClicked != index
                                and self.lastSingleClicked
                                not in self.markedTissues):
                            self.modelActors[
                                self.lastSingleClicked].GetProperty().DeepCopy(
                                    self.originalProperty[
                                        self.lastSingleClicked])
                        # if in focus view, highlight item in the neighbor list. or highlight in tissue list
                        if (self.lastDoubleClicked != None
                                and self.lastSingleClicked != index
                                and self.lastDoubleClicked
                                not in self.markedTissues):
                            self.highlightList(self.neighborList,
                                               self.findIndexOfOri(index))
                            if (self.findIndexOfOri(index) in self.neighbors):
                                self.formNeighborText(
                                    index,
                                    self.neighbors.index(
                                        self.findIndexOfOri(index)))
                            interact.highLightNeighbor(
                                self.modelActors[index].GetProperty())
                            if (not self.isTraining):
                                self.logFile.updateSister(
                                    2, self.findIndexOfOri(index),
                                    self.neighbors.index(
                                        self.findIndexOfOri(index)),
                                    fixedSurface.outsideOrInside(
                                        self.findIndexOfOri(index)))
                        else:
                            self.highlightList(self.tissueList, index)
                            interact.highLightTissue(
                                self.modelActors[index].GetProperty())
                        self.lastSingleClicked = index
                    if (not self.isTraining):
                        self.logFile.recordClick("Click", "MainView",
                                                 self.findIndexOfOri(index),
                                                 self.camera.GetPosition(),
                                                 self.camera.GetFocalPoint(),
                                                 self.camera.GetDistance())

            if (self.numberOfClicks == 2):
                if (NewPickedActor and NewPickedActor in self.modelActors):
                    index = self.modelActors.index(NewPickedActor)
                    if (self.lastDoubleClicked != None
                            and index != self.lastDoubleClicked):
                        self.numberOfClicks = 0
                        return
                    if (self.textOn == True
                            and index == self.lastDoubleClicked):
                        self.renderer.RemoveActor2D(self.neighborTextActor)
                        self.textOn = False
                    self.highlightList(self.tissueList, index)
                    self.showNeighbors(self.findIndexOfOri(index))
                    if (self.lastSingleClicked != None and
                            self.lastSingleClicked not in self.markedTissues):
                        self.modelActors[
                            self.lastSingleClicked].GetProperty().DeepCopy(
                                self.originalProperty[self.lastSingleClicked])
                        self.lastSingleClicked = None
                    # if (self.lastDoubleClicked != None and self.lastDoubleClicked not in self.markedTissues):
                    #     self.modelActors[self.lastDoubleClicked].GetProperty().DeepCopy(self.originalProperty[self.lastDoubleClicked])
                    if (self.lastDoubleClicked == None):
                        for actor in self.renderer.GetActors():
                            self.renderer.RemoveActor(actor)
                        self.renderer.AddActor(self.modelActors[index])
                        interact.highLightTissue(
                            self.modelActors[index].GetProperty())
                        neighbors = self.neighborsInOrderOfCells[
                            self.findIndexOfOri(index)].copy()
                        for neighbor in neighbors:
                            if (self.findIndexOfList(neighbor)
                                    not in self.markedTissues):
                                self.renderer.AddActor(self.modelActors[
                                    self.findIndexOfList(neighbor)])
                        if (not self.isTraining):
                            self.logFile.updateSister(
                                1, self.findIndexOfOri(index), len(neighbors),
                                fixedSurface.outsideOrInside(
                                    self.findIndexOfOri(index)))
                        self.camera.SetFocalPoint(
                            self.modelActors[index].GetCenter())
                        # interact.highLightTissue(self.modelActors[index].GetProperty())
                        self.lastDoubleClicked = index
                    elif (self.lastDoubleClicked == index):
                        if (not self.isTraining):
                            self.logFile.updateSister(1, "-", "-", "-")
                            self.logFile.updateSister(2, "-", "-", "-")
                        for actor in self.modelActors:
                            if (self.modelActors.index(actor)
                                    not in self.markedTissues and actor
                                    not in self.renderer.GetActors()):
                                self.renderer.AddActor(actor)
                        self.modelActors[index].GetProperty().DeepCopy(
                            self.originalProperty[self.lastDoubleClicked])
                        self.lastDoubleClicked = None
                        self.lastSingleClicked = None
                        self.neighborList.clear()
                    self.vtkWidget.GetRenderWindow().Render()
                    if (not self.isTraining):
                        self.logFile.recordClick("DoubleClick", "MainView",
                                                 self.findIndexOfOri(index),
                                                 self.camera.GetPosition(),
                                                 self.camera.GetFocalPoint(),
                                                 self.camera.GetDistance())
                self.numberOfClicks = 0
示例#4
0
 def listPressed(self):
     if (self.tissueList.selectedItems() == []): return
     item = self.tissueList.selectedItems()[0]
     indexOfList = self.tissueList.row(item)
     indexOfOri = self.findIndexOfOri(indexOfList)
     if (not self.isTraining):
         self.logFile.updateSister(1, indexOfOri, len(self.neighborsInOrderOfCells[indexOfOri]), fixedSurface.outsideOrInside(indexOfOri))
         if (self.chosenNeighbor and not self.isTraining):
             self.logFile.updateSister(2, "-", "-", "-")
         self.logFile.recordClick("Click", "TissueList", indexOfOri, self.camera.GetPosition(), self.camera.GetFocalPoint(), self.camera.GetDistance())
     if (self.chosenNeighbor or self.focusedViewOn == True):
         for index in self.neighbors:
             self.modelActors[self.findIndexOfList(index)].SetPosition(0,0,0)
         if (self.chosenNeighbor):
             self.modelActors[self.chosenNeighbor].GetProperty().DeepCopy(self.originalProperty[self.chosenNeighbor])
         if (self.textOn == True):
             self.renderer.RemoveActor2D(self.neighborTextActor)
             self.textOn = False
         for actor in self.modelActors:
             index = self.modelActors.index(actor)
             if (actor not in self.renderer.GetActors() and index not in self.markedTissues):
                 self.renderer.AddActor(actor)
         self.chosenNeighbor = None
     self.zoomExtents()
     interact.highLightTissue(self.modelActors[indexOfList].GetProperty())
     if ((self.showedNeighborListOwner != None) and  (self.showedNeighborListOwner >= 0) and
         self.showedNeighborListOwner not in self.markedTissues):
         self.modelActors[self.showedNeighborListOwner].GetProperty().DeepCopy(self.originalProperty[self.showedNeighborListOwner])
     self.showedNeighborListOwner = indexOfList
     self.showNeighbors(indexOfOri)
     self.vtkWidget.GetRenderWindow().Render()
     self.focusedViewOn = False