def key_press_U(self,obj,event):
     '''
     Key event u: last solution data - show last soultion data set
     '''
     key = obj.GetKeyCode()
     if key=='u' or key=='U':
         self.solutionPosition = self.solutionPosition - 1
         if self.solutionPosition < 0:
             self.solutionPosition = len(self.solutionName) - 1
         # recalculate the range of the lookuptable ## 
         self.scalarPosition = 0
         minL = []
         maxL = []
         for array in self.scalarSolution[self.solutionPosition][self.scalarPosition].itervalues(): 
             minL.append(array.min())
             maxL.append(array.max())
         self.SourceMin = min(minL)
         self.SourceMax = max(maxL)
 
         #set time
         self.endTime = len(self.areaSolution[self.solutionPosition][0])
         
         #set name of the solution
         if self.pauseBool == False: self.engine.scenes[0].name = str(self.vascularNetwork.name +' - '+'paused'+' - '+self.solutionName[self.solutionPosition])
         else: self.engine.scenes[0].name = str(self.vascularNetwork.name +' - '+'running'+' - '+'t = 0.000' +' - '+self.solutionName[self.solutionPosition])
 
         #restart simulation
         self.currentTime = 0
    def visualize(self):
        '''
        Start the visualisation of the simulation result.
        Set up Upgrade method and starts the main loop.
        Use only if the simulation result was set!
        '''
        # update the lookuptables and set them
        minL = []
        maxL = []
       
        for array in self.scalarSolution[self.solutionPosition][self.scalarPosition].itervalues(): 
            minL.append(array.min())
            maxL.append(array.max())
        self.SourceMin = min(minL)
        self.SourceMax = max(maxL)

        for actor in self.vizActors.itervalues():
            actor.module_manager.scalar_lut_manager.data_range = [self.SourceMin, self.SourceMax]
        #self.vizActors[0].module_manager.scalar_lut_manager.data_name = self.scalarNames[self.solutionPosition][self.scalarPosition]
        #self.vizActors[0].module_manager.scalar_lut_manager.show_scalar_bar = True

        timer = Timer(0.03, self.update)
        gui = GUI()
        gui.busy = True
        gui.start_event_loop()
예제 #3
0
    def add_array(self, array, bounds=False, normalized=False):

        a = {}
        a['count'] = array.shape[0]
        if len(array.shape) == 1:
            t = 'SCALAR'
        elif array.shape[1] == 3:
            t = 'VEC3'
        elif array.shape[1] == 4:
            t = 'VEC4'
        else:
            raise glTFError(
                'glTF buffer shape %s not allowed, must be 1 dimensional or N by 3'
                % repr(tuple(array.shape)))
        a['type'] = t
        a['componentType'] = self.value_types[array.dtype.type]
        a['bufferView'] = len(self.buffer_views)
        if normalized:
            a['normalized'] = True  # Required for COLOR_0

        if bounds:
            nd = array.ndim
            # TODO: Handle integer min/max
            if nd == 2:
                a['min'], a['max'] = (tuple(
                    float(x) for x in array.min(axis=0)),
                                      tuple(
                                          float(x) for x in array.max(axis=0)))
            else:
                a['min'], a['max'] = float(array.min(axis=0)), float(
                    array.max(axis=0))

        self.accessors.append(a)

        b = array.tobytes()
        nb = len(b)
        self.buffer_bytes.append(b)
        bv = {"byteLength": nb, "byteOffset": self.nbytes, "buffer": 0}
        self.buffer_views.append(bv)
        self.nbytes += nb

        return len(self.accessors) - 1
 def key_press_V(self,obj,event):
     '''
     Key event V: open vessels and show vectorfields
     '''
     key = obj.GetKeyCode()
     if key=='v' or key=='V':
         if self.vecBool == False: 
             self.vecBool = True
             for glyph in self.glyph.itervalues(): glyph.actor.actor.visibility = self.vecBool
             self.scalarPosition = 3
             
             minL = []
             maxL = []
             for array in self.scalarSolution[self.solutionPosition][self.scalarPosition].itervalues(): 
                 minL.append(array.min())
                 maxL.append(array.max())
                 
             self.SourceMin = min(minL)
             self.SourceMax = max(maxL)
             
             self.vizActors[0].module_manager.scalar_lut_manager.show_scalar_bar = False
             self.glyph[0].module_manager.scalar_lut_manager.data_range = [0, self.SourceMax]
             self.glyph[0].module_manager.scalar_lut_manager.show_scalar_bar = True
             self.glyph[0].module_manager.scalar_lut_manager.data_name = self.scalarNames[self.solutionPosition][self.scalarPosition]
             
             print " .. velocity profile enabled"
         else: 
             self.vecBool = False
             for glyph in self.glyph.itervalues(): glyph.actor.actor.visibility = self.vecBool
             print " .. velocity profile disabled"
             self.scalarPosition = 3
             minL = []
             maxL = []
             for array in self.scalarSolution[self.solutionPosition][self.scalarPosition].itervalues(): 
                 minL.append(array.min())
                 maxL.append(array.max())
             self.SourceMin = min(minL)
             self.SourceMax = max(maxL)
             self.vizActors[0].module_manager.scalar_lut_manager.data_name = self.scalarNames[self.solutionPosition][3]
             self.vizActors[0].module_manager.scalar_lut_manager.show_scalar_bar = True
 def key_press_N(self,obj,event):
     '''
     Key event n: next lookup table - change the lookup and scalar mapping
     '''
     key = obj.GetKeyCode()
     if key=='n' or key=='N':
         self.scalarPosition = self.scalarPosition + 1
         if self.scalarPosition == len(self.scalarNames[self.solutionPosition]):
             self.scalarPosition = 0
         minL = []
         maxL = []
         for array in self.scalarSolution[self.solutionPosition][self.scalarPosition].itervalues(): 
             minL.append(array.min())
             maxL.append(array.max())
         self.SourceMin = min(minL)
         self.SourceMax = max(maxL)
 def key_press_J(self,obj,event):
     '''
     Key event j: last lookup table - change the lookup and scalar mapping
     '''
     key = obj.GetKeyCode()
     if key=='j' or key=='J':
         self.scalarPosition = self.scalarPosition - 1
         if self.scalarPosition < 0:
             self.scalarPosition = len(self.scalarNames[self.solutionPosition]) - 1
         # recalculate the range of the lookuptable ## Note: change this in further version to save memory -> (list)
         minL = []
         maxL = []
         for array in self.scalarSolution[self.solutionPosition][self.scalarPosition].itervalues(): 
             minL.append(array.min())
             maxL.append(array.max())
         self.SourceMin = min(minL)
         self.SourceMax = max(maxL)