Beispiel #1
0
   def changeRobotModel(self,isChecked):
       self.ren.RemoveActor(self.robot.getAssembly())
       if isChecked:
           self.robot = palmModel()
           self.robot.setPosition(-20,-450,0)
       else:
           self.robot = robotModel()
           self.setArmConnect()
       self.ren.AddActor(self.robot.getAssembly())
 
       self.finger = [self.robot.thumb.finger,self.robot.fingerOne,self.robot.fingerTwo,
                      self.robot.fingerThree,self.robot.fingerFour] 
        
       self.setPalmConnect() 
       self.renderWindow.Render()
Beispiel #2
0
    def __init__(self,parent = None):
        super(robotWindow,self).__init__(parent = None)
        self.setupUi(self)
        
        self.robot = palmModel()
               
        self.vtkWidget = QVTKRenderWindowInteractor(self.robotWidget)
        self.ren = vtk.vtkRenderer()
        
        lightPosition = [0,0,1]
        lightFocalPoint = [0,0,0]
        light = vtk.vtkLight()
        light.SetLightTypeToSceneLight()
        light.SetPosition(lightPosition[0], lightPosition[1], lightPosition[2])
        light.SetPositional(True) 
        light.SetConeAngle(10)
        light.SetFocalPoint(lightFocalPoint[0], lightFocalPoint[1], lightFocalPoint[2])
        light.SetDiffuseColor(1,0,0)
        light.SetAmbientColor(0,1,0)
        light.SetSpecularColor(0,0,1)
       

        lightActor = vtk.vtkLightActor()
        lightActor.SetLight(light)
        self.ren.AddViewProp(lightActor)
    
        self.ren.SetBackground(0, 0.6, 0.9)
        self.renderWindow = self.vtkWidget.GetRenderWindow()
        self.renderWindow.AddRenderer(self.ren)
        self.style = vtk.vtkInteractorStyleTrackballCamera()  
        self.vtkWidget.SetInteractorStyle(self.style)
        
        self.checkBox = [self.thumbChectBox,self.foreCheckBox,self.middleCheckBox,
                         self.ringCheckBox,self.littleCheckBox]

        if not self.thumbChectBox.isChecked():
            self.robot = robotModel()
            self.setArmConnect()
        
        self.finger = [self.robot.thumb.finger,self.robot.fingerOne,self.robot.fingerTwo,
                       self.robot.fingerThree,self.robot.fingerFour] 
        
        self.fingerSender = [self.thumbYSlide,self.thumbSlide,self.foreSlide,
                       self.middleSlide,self.ringSlide,self.littleSlide]
        self.setPalmConnect()     
        
        map(self.connectFun,self.checkBox,
            [self.changeCheckBoxConnect for i in range(len(self.checkBox))],
            [SIGNAL("clicked()") for i in range(len(self.checkBox))]) 
        
        self.fingerTogether = []
        self.slideTogether = []
        
        self.connect(self.palmModelCheckBox,SIGNAL("stateChanged(int)"),self.changeRobotModel)
        
        self.ren.AddActor(self.robot.getAssembly())
        self.axes = vtk.vtkAxesActor()
        self.axes.SetTotalLength(100,100,100)
        center = self.ren.GetCenter()
        self.axes.SetPosition(0,0,0)
        #self.ren.AddActor(self.axes)
        self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
        self.iren.Initialize()