示例#1
0
    def __init__(self, obj, system, material, part):
        Component.__init__(self, obj, system, material)
        #obj.addProperty("App::PropertyFloat", "BendingStiffness", "Component", "Bending stiffness of the Component")

        obj.addProperty("App::PropertyFloat", "AreaMomentOfInertia",
                        "Structural", "Area moment of intertia.")
        obj.setEditorMode("AreaMomentOfInertia", 1)
        obj.addProperty("App::PropertyFloat", "RadiusOfGyration", "Structural",
                        "Radius of gyration.")
        obj.setEditorMode("RadiusOfGyration", 1)
        obj.addProperty("App::PropertyLink", "Part", "Structural",
                        "Reference to Part")
        obj.setEditorMode("Part", 1)
        obj.addProperty("App::PropertyLinkSub", "ShapeLink", "Structural",
                        "Reference to Shape of Part")

        obj.addProperty("App::PropertyFloatList", "Velocity", "Subsystem",
                        "Mean velocity.")
        obj.setEditorMode('Velocity', 1)
        obj.addProperty("App::PropertyFloatList", "VelocityLevel", "Subsystem",
                        "Velocity level.")
        obj.setEditorMode('VelocityLevel', 1)

        obj.Part = part
        obj.ShapeLink = (obj.Part, ['Shape'])

        obj.Label = part.Label + '_' + obj.ClassName
示例#2
0
 def execute(self, obj):
     Component.execute(self, obj)
     
     obj.AreaMomentOfInertia = obj.Proxy.area_moment_of_inertia
     obj.RadiusOfGyration = obj.Proxy.radius_of_gyration
     obj.Velocity = obj.Proxy.velocity.tolist()
     obj.VelocityLevel = obj.Proxy.velocity_level.tolist()
示例#3
0
    def __init__(self, radius=default_radius, highlight=None, actor=None):
        Component.__init__(self, actor)
        self.radius = radius
        self.highlight = highlight

        self.isHighlighted = False  # a runtime property indicating whether this actor should be highlighted (due to a collision)
        self.normalColor = None  # will be set on first highlight
示例#4
0
    def __init__(self,
                 fanout,
                 depth,
                 spread=default_spread,
                 rootColor=default_rootColor,
                 edgeColor=default_edgeColor,
                 scale=default_scale,
                 actor=None):
        Component.__init__(self, actor)
        self.fanout = fanout
        self.depth = depth
        self.spread = spread
        self.rootColor = rootColor
        self.edgeColor = edgeColor
        self.scale = scale
        self.rootScale = self.scale  # NOTE this will also apply to children
        #self.childScale = np.float32([1.0, 1.0, 1.0])  # NOTE this will get compounded if the radial tree is a true hierarchy, better to use scale = 1 (default)

        # Recursively generate radial tree
        treeRoot = self.createRadialTree(
            self.fanout, self.depth, self.spread,
            isRoot=True)  # creates full hierarchy and returns root actor
        treeRoot.components['Transform'] = Transform(
            rotation=np.random.uniform(-pi / 2, pi / 2, size=3),
            scale=self.rootScale,
            actor=treeRoot
        )  # NOTE random rotation ensures child vectors are not always generated close to the same canonical vectors
        treeRoot.components['Material'] = Material(color=self.rootColor,
                                                   actor=treeRoot)
        treeRoot.components['Mesh'] = Mesh.getMesh(src=self.treeRootModelFile,
                                                   actor=treeRoot)

        # Attach this hierarchy to current actor
        self.actor.children.append(treeRoot)
示例#5
0
    def __init__(self, src, actor=None):
        Component.__init__(self, actor)

        # TODO Include a mesh name (e.g. 'Dragon') as ID as well as src (e.g. '../res/models/Dragon.obj')
        self.src = src
        self.filepath = Context.getInstance().getResourcePath('models', src)
        
        # OpenGL version-dependent code (NOTE assumes major version = 3)
        self.vao = None
        if Context.getInstance().GL_version_minor > 0:  # 3.1 (or greater?)
          self.vao = glGenVertexArrays(1)
        else:  # 3.0 (or less?)
          self.vao = GLuint(0)
          glGenVertexArrays(1, self.vao)
        glBindVertexArray(self.vao)

        self.loadModel(self.filepath)

        self.vbo = VBO(self.meshData, GL_STATIC_DRAW)
        self.vbo.bind()

        glEnableVertexAttribArray(0)
        glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6*4, self.vbo+0)

        glEnableVertexAttribArray(1)
        glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6*4, self.vbo+12)
        
        self.ebo = glGenBuffers(1)
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, self.ebo)
        glBufferData(GL_ELEMENT_ARRAY_BUFFER, len(self.elements)*4, self.elements, GL_STATIC_DRAW)
示例#6
0
 def __init__(self,sschema,xrpr=None):
   Component.__init__(self,sschema,xrpr)
   if xrpr is not None:
     if xrpr.documentation is not None:
       self.documentation=map(lambda a:a.elt.elt,xrpr.documentation)
     if xrpr.appinfo is not None:
       self.appinfo=map(lambda a:a.elt.elt,xrpr.appinfo)
示例#7
0
    def execute(self, obj):
        Component.execute(self, obj)

        obj.AreaMomentOfInertia = obj.Proxy.area_moment_of_inertia
        obj.RadiusOfGyration = obj.Proxy.radius_of_gyration
        obj.Velocity = obj.Proxy.velocity.tolist()
        obj.VelocityLevel = obj.Proxy.velocity_level.tolist()
示例#8
0
    def __init__(self, src, actor=None):
        Component.__init__(self, actor)

        # TODO Include a mesh name (e.g. 'Dragon') as ID as well as src (e.g. '../res/models/Dragon.obj')
        self.src = src
        self.filepath = Context.getInstance().getResourcePath('models', src)

        # OpenGL version-dependent code (NOTE assumes major version = 3)
        self.vao = None
        if Context.getInstance().GL_version_minor > 0:  # 3.1 (or greater?)
            self.vao = glGenVertexArrays(1)
        else:  # 3.0 (or less?)
            self.vao = GLuint(0)
            glGenVertexArrays(1, self.vao)
        glBindVertexArray(self.vao)

        self.loadModel(self.filepath)

        self.vbo = VBO(self.meshData, GL_STATIC_DRAW)
        self.vbo.bind()

        glEnableVertexAttribArray(0)
        glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * 4, self.vbo + 0)

        glEnableVertexAttribArray(1)
        glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6 * 4, self.vbo + 12)

        self.ebo = glGenBuffers(1)
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, self.ebo)
        glBufferData(GL_ELEMENT_ARRAY_BUFFER,
                     len(self.elements) * 4, self.elements, GL_STATIC_DRAW)
示例#9
0
 def __init__(self, radius=default_radius, highlight=None, actor=None):
   Component.__init__(self, actor)
   self.radius = radius
   self.highlight = highlight
   
   self.isHighlighted = False  # a runtime property indicating whether this actor should be highlighted (due to a collision)
   self.normalColor = None  # will be set on first highlight
示例#10
0
 def __init__(self):
     Component.__init__(self)
     #Any method and property missing will be given user feedback by python's traceback
     self.new(subsysA())
     self.new(subsysB())
     self.link(....)
     ...
示例#11
0
    def __init__(self, plugins):
        """
        @param paths: paths where to look for components
        """
    
        self.__components = []
        self.__devices = []
        self.__whitelist = []
        
        Component.__init__(self)
        
        mods = self.__load_modules(plugins)
        delayed_mods = [ mod for mod in mods if hasattr(mod, "delayed") ]
        other_mods = [ mod for mod in mods if not hasattr(mod, "delayed") ]

        for mod in mods:
            self.__register_messages(mod)

        for mod in other_mods:
            self.__load_components(mod)

        self.__report_loadings()
        #self.emit_message(msgs.COM_EV_APP_STARTED)
        if (delayed_mods):
            gobject.idle_add(self.__load_delayed_modules, delayed_mods)
示例#12
0
文件: KCons.py 项目: vimov/Deployer
 def __init__(self,sschema,xrpr):
   Component.__init__(self,sschema,xrpr)
   if xrpr is not None:
     self.fields=map(lambda x:XPath(x.xpath,x.elt.namespaceDict),
                     xrpr.fields)
     self.selector=XPath(xrpr.selector.xpath,
                               xrpr.selector.elt.namespaceDict)
     self.register('identity constraint', self.schema.keyUniqueTable)
示例#13
0
    def update_batch(self, batch, group):
        Component.update_batch(self, batch, group)

        child_group = pyglet.graphics.OrderedGroup(0, group)

        for child in self._children:
            #Pass children the lower of the layers
            child.update_batch((batch if self.visible else None), child_group)
示例#14
0
def main() :
	backend = SimpleBackend()
	component = Component(
		jid = "posts.cheshir.lit", password = "******",
		server = "cheshir.lit", port = 5347, backend = backend)
	component.start()
	httpFrontend = HTTPFrontend(8080, backend)
	httpFrontend.start()
def main() :
	backend = SimpleBackend()
	component = Component(
		jid = "test@gic", password = "******",
		server = "147.102.6.34", port = 5222, backend = backend)
	component.start()
	httpFrontend = HTTPFrontend(8081, backend)
	httpFrontend.start()
示例#16
0
 def __init__(self,port_type,master_num,slave_num):
     Component.__init__(self)
     for i in range(master_num):
         eval("self.new(m%d=port_type())" %i)
         eval("self.VImpPort(self.m%d)"   %i)
     for i in range(master_num):
         eval("self.new(s%d=port_type())" %i)
         eval("self.VImpPort(self.s%d)"   %i)
示例#17
0
文件: Group.py 项目: vimov/Deployer
 def __init__(self,sschema,xrpr=None,surrogate=None):
   Component.__init__(self,sschema,xrpr)
   if xrpr is not None and self.compositor:
     self.particles=map(lambda p:p.component,
                        filter(lambda p:p.component is not None,xrpr.model))
   elif surrogate is not None:
     # really for errors only
     self.xrpr=surrogate
示例#18
0
    def __init__(self):

        self.__title = ""
        self.__info = ""

        Component.__init__(self)
        Window.__init__(self, Window.TYPE_SUBWINDOW)
        self.connect_closed(self.__on_close_window)
示例#19
0
 def update_batch(self, batch, group):
     Component.update_batch(self, batch, group)
     
     child_group = pyglet.graphics.OrderedGroup(0, group)
     
     for child in self._children:
         #Pass children the lower of the layers
         child.update_batch((batch if self.visible else None), child_group)
示例#20
0
 def __init__(self,sschema,xrpr,attributeDeclaration=None,use=None,vct=None,
              value=None):
   Component.__init__(self,sschema,xrpr,None)
   if use is not None:
     (self.minOccurs,self.maxOccurs)=_attrOccurs[use]
   if vct is not None:
     self.valueConstraint=(vct,value)
   if attributeDeclaration is not None:
     self.attributeDeclaration=attributeDeclaration
示例#21
0
 def __init__(self,sschema,xrpr=None,term=None,surrogate=None):
   Component.__init__(self,sschema,xrpr,None)
   if xrpr is not None:
     self.occurs=_computeMinMax(xrpr.minOccurs or "1",xrpr.maxOccurs,self)
   elif surrogate is not None:
     # for errors only
     self.xrpr=surrogate
   if term is not None:
     self.term=term
示例#22
0
 def __init__(self):
     Component.__init__(self)
     #Users can use any dynamic feature here
     self.new(fab1=AXI_FAB(PortAXI4,1,2))
     self.new(x2x1=X2X(PortAXI4))
     self.new(x2x2=X2X(PortAXI4))
     self.link(....)
     ...
     ..
示例#23
0
    def __init__(self):

        Component.__init__(self)

        # create directory for thumbnails if it doesn't exist yet
        try:
            if (not os.path.exists(self.__THUMB_FOLDER)):
                os.makedirs(self.__THUMB_FOLDER)
        except:
            pass
示例#24
0
    def __init__(self):
        Component.__init__(self)

        # Placeholder parameters for testing.
        # All diameters in mm.
        self.parameters['diameter'] = 77
        # diameter = combustor diameter
        self.parameters['length'] = 77
        # length defined by volume of propellant required
        self.parameters['wall_thickness'] = 77
示例#25
0
def main():
    backend = SimpleBackend()
    component = Component(jid="test@gic",
                          password="******",
                          server="147.102.6.34",
                          port=5222,
                          backend=backend)
    component.start()
    httpFrontend = HTTPFrontend(8081, backend)
    httpFrontend.start()
示例#26
0
文件: Tank.py 项目: TRCSpace/Demo7
 def __init__(self):
   Component.__init__(self)
   
   # Placeholder parameters for testing.
   # All diameters in mm.
   self.parameters['diameter'] = 77
   # diameter = combustor diameter
   self.parameters['length'] = 77
   # length defined by volume of propellant required
   self.parameters['wall_thickness'] = 77
示例#27
0
    def __init__(self, master, **kargs):
        Component.__init__(self, master, 'Battery Bank', **kargs)

        self.chg_cycle_count = [0, 0]
        self.tot_cycles = 0
        self.bnk_vo = 0
        self.soc = 1.0
        self.cur_cap = None
        self.max_dischg_cycles = None
        self.max_dischg_dod = None
示例#28
0
 def __init__(self, master, **kargs):
     self.curloc = None
     self.air_temp = None
     self.wind_spd = None
     self.atmospherics = None
     self.suntimes = None
     Component.__init__(self, master, 'Site Definition', **kargs)
     self.print_order = ['proj', 'client', 'p_desc', 'city', 
                         'cntry', 'lat', 'lon', 'elev', 'tz',
                         'gv', 'gf']               
示例#29
0
 def onChanged(self, obj, prop):
     Component.onChanged(self, obj, prop)
     
     if prop == 'Material':
         if obj.Material == None:
             obj.Proxy.material = None
         #else:
             #obj.Proxy.material = obj.Material.Proxy.model
     
     if prop == 'ShapeLink':
         obj.Shape = getattr(obj.Part, 'Shape')
示例#30
0
    def __init__(self):
        Component.__init__(self)
        self.new(m1=PortAXI4())
        self.new(m2=PortAXI4())
        self.new(s1=PortAXI4())
        self.new(s2=PortAXI4())

        self.VImpPort(self.m1)
        self.VImpPort(self.m2)
        self.VImpPort(self.s1)
        self.VImpPort(self.s2)
示例#31
0
    def onChanged(self, obj, prop):
        Component.onChanged(self, obj, prop)

        if prop == 'Material':
            if obj.Material == None:
                obj.Proxy.material = None
            #else:
            #obj.Proxy.material = obj.Material.Proxy.model

        if prop == 'ShapeLink':
            obj.Shape = getattr(obj.Part, 'Shape')
示例#32
0
文件: Group.py 项目: vimov/Deployer
 def rebuild(self):
   Component.rebuild(self)
   if self.name:
     # really a model group def, merge modelGroup
     self.compositor=self.modelGroup.compositor
     self.particles=self.modelGroup.particles
     self.modelGroup=None
   if self.compositor:
     # cheat like hell
     self.__class__={'sequence':Sequence,
                     'choice':Choice,
                     'all':All}[self.compositor]
示例#33
0
文件: Union.py 项目: vimov/Deployer
 def __init__(self,sschema,xrpr):
   Component.__init__(self,sschema,xrpr)
   if xrpr.memberTypes:
     self.membertypeNames=map(lambda n,e=xrpr.elt,f=sschema:QName(n,e,f),
                              xrpr.memberTypes.split())
   if xrpr.subTypes:
     self.someMembers=map(lambda sub:sub.component,
                          xrpr.subTypes)
   elif not xrpr.memberTypes:
     # no elt means builtin
     if xrpr.elt is not None:
       self.error("union must have 'memberTypes' attribute or some SimpleType children")
示例#34
0
文件: Element.py 项目: vimov/Deployer
 def __init__(self,sschema,xrpr=None,scope=None):
   if (type(scope) is types.StringType or (xrpr and xrpr.form=='qualified')):
     ns='ns'
   else:
     ns=None
   Component.__init__(self,sschema,xrpr,ns)
   if xrpr is not None:
     if type(scope) is types.StringType:
       self.scope=scope
     else:
       self.scopeRepr=scope              # an xrpr, component not available yet
     self.abstract=xrpr.abstract or 'false'
     self.nullable=xrpr.nullable or 'false'
     if xrpr.substitutionGroup is not None:
       self.equivClassName = QName(xrpr.substitutionGroup,xrpr.elt,
                                   sschema)
     if xrpr.final=='':
       self.final=()
     else:
       self.final=xrpr.final.split()
     if '#all' in self.final:
       self.final=('restriction','extension')
     if xrpr.block=='':
       self.prohibitedSubstitutions=()
     else:
       self.prohibitedSubstitutions=xrpr.block.split()
     if '#all' in self.prohibitedSubstitutions:
       self.prohibitedSubstitutions=('restriction','extension','substitution')
     if xrpr.type is not None:
       self.typeDefinitionName=QName(xrpr.type,xrpr.elt,
                                     sschema)
       if xrpr.simpleType or xrpr.complexType:
         self.error("declaration with 'type' attribute must not have nested type declaration")
     elif xrpr.simpleType is not None:
       self.typeDefinition=xrpr.simpleType.component
     elif xrpr.complexType is not None:
       self.typeDefinition=xrpr.complexType.component
     elif not self.equivClassName:
       self.typeDefinition=Type.urType
     if xrpr.fixed is not None:
       # todo: check vc against type
       self.valueConstraint=('fixed',xrpr.fixed)
     elif xrpr.default is not None:
       self.valueConstraint=('default',xrpr.default)
     self.keys=map(lambda e:e.component,xrpr.keys)
     self.keyrefs=map(lambda e:e.component,xrpr.keyrefs)
     self.uniques=map(lambda e:e.component,xrpr.uniques)
   else:
     self.keys=[]
     self.uniques=[]
     self.keyrefs=[]
def FullAdder():
    """
    Retorna un component amb el funcionament d'un full-adder (suma A, B i Cin).

    :return: Un component amb el comportament d'un full-adder
    """
    e1 = Entrada("A")
    e2 = Entrada("B")
    e3 = Entrada("Cin")

    s = Sortida('S')
    s1 = Sortida('Cout')

    componentFullAdder = Component(
        {
            e1.getName(): e1,
            e2.getName(): e2,
            e3.getName(): e3
        }, {
            s.getName(): s,
            s1.getName(): s1
        }, "Full Adder")

    #calcul s
    n1 = Node("N1")
    x = XOR(e1, e2, n1)
    x2 = XOR(e3, n1, s)

    #Cout
    n2 = Node("N2")
    a1 = And(e3, n1, n2)
    n3 = Node("N3")
    a2 = And(e1, e2, n3)
    o = Or(n2, n3, s1)

    sup = Supervisor()
    sup.addNode(n1)
    sup.addNode(n2)
    sup.addNode(n3)
    sup.addNode(s)
    sup.addNode(s1)

    sup.addTickable(x)
    sup.addTickable(x2)
    sup.addTickable(a1)
    sup.addTickable(a2)
    sup.addTickable(o)

    componentFullAdder.AddArchitecture([n1, n2, n3, a1, a2, o, x, x2], sup)
    return componentFullAdder
示例#36
0
    def __init__(self, brick):
        self.brick = brick
        self.queue = Queue()
        
        self.components = {}
        self.sensors = {}
        self.active = Component(self)
        
        self.InitializeHardware()
        self.InitializeComponents()
        self.InitializeSensors()

        self.active.Start()
        self.queue_thread = Thread(target=self.QueueWorker)
        self.queue_thread.start()
示例#37
0
def client_code2(component1: Component, component2: Component) -> None:
    """
        Thanks to the fact that the child-management operations are declared in the
        base Component class, the client code can work with any component, simple or
        complex, without depending on their concrete classes.
        """
    """
        Dank der Tatsache,  dass die Operationen zur Verwaltung der untergeordneten Komponenten 
        in der Basisklasse "Component"  deklariert sind, kann der Client-Code mit jeder beliebigen Komponente,
        ob einfach oder komplex, arbeiten, ohne von ihren konkreten Klassen abhängig zu sein.
        """
    if component1.is_composite():
        component1.add(component2)

    print(f"RESULT: {component1.operation()}", end="")
示例#38
0
    def gen_component(self, parent=None, parent_name=None):

        stop = False

        if parent is not None:
            if (parent.depth >= self.max_depth - 1) or (random.uniform(0, 1) <
                                                        self.stop_prob):
                stop = True
            depth = parent.depth + 1
        else:
            stop = False
            depth = 1

        if stop:
            op_name = random.choice([0, 1])
            op_func = None
            op_inputs = 0
        else:
            op_name, (op_func,
                      op_inputs) = random.choice(list(self.op_dict.items()))

        component = Component(op_name, parent, depth, op_func, op_inputs,
                              self.encode(op_name))

        # if stop:            ### WEIRD BUG
        #     self.leaves.append(component)

        return component
示例#39
0
    def first_component(self):
        comp_ref = icalfileset_get_first_component(self._ref)

        if comp_ref == None:
            return None

        return Component(ref=comp_ref)
示例#40
0
    def __init__(self):
        self.ot = Others()
        self.ot.logDebug(" Application Started !!!!")
        self.st = StyleSheet()
        self.ff = FIFO()

        self.twdl = TWDL()
        self.comp = Component()

        self.ot.app = QtGui.QApplication([self.ot.app_name])

        self.ot.desktop_width = 1280
        self.ot.desktop_height = 640
        print 'desktop resolution -- ', self.ot.app.desktop().geometry().width(
        ), self.ot.app.desktop().geometry().height()

        ret = GUI(self.ot, self.ff, self.st, self.comp)
        t1 = mainPage(self.ot, self.st, self.comp)
        #listener on socket
        self.initListener()

        if self.ff.udpconn.fileno() != 0:
            self.ot.logDebug(" Socket Connection Established !!!")
            self.ot.notifyStatus(" Socket Connection Established !!!", 1)
        else:
            self.ot.logWarning(" Socket Connection Failed !!!")
            self.ot.notifyStatus("Socket Connection Failed", 2)

        sys.exit(self.ot.app.exec_())
示例#41
0
def main():
    # Testing code
    """
    game = Game('large_normal_186')
    game.load_events()
    game.process_events()
    print(game.generate_vote_count(278))
    print('\nNow in RC style!\n')
    print(game.generate_vote_count(278, style='large_normal_186'))
    my_list = Component.create('players_list', game_state=game.game_state, post=game.game_state.post)
    print(my_list.generate())
    print('\nLiving Players:\n')
    my_list = Component.create('players_list', game_state=game.game_state, post=game.game_state.post, filter='living')
    print(my_list.generate())
    print('\nDead Players:\n')
    my_list = Component.create('players_list', game_state=game.game_state, post=game.game_state.post, filter='dead')
    print(my_list.generate())
    print('\nModkilled Players:\n')
    my_list = Component.create('players_list', game_state=game.game_state, post=game.game_state.post, filter='modkilled')
    print(my_list.generate())
    print('breakpoint')
    """

    game = Game('mini_theme_1974')
    game.load_events()
    game.process_events()
    for election in game.game_state.elections:
        for vc in election.vote_counts:
            print(game.generate_vote_count(vc, style='Micc') + '\n\n')
    my_hacked_in_component = Component.create('players_list',
                                              game_state=game.game_state,
                                              post=game.game_state.post,
                                              style='Micc')
    print(my_hacked_in_component.generate())
    print('\n\nbreakpoint')
示例#42
0
 def __init__(self):
     Component.__init__(self)
     self.new(m1 = PortAXI4())
     self.new(m2 = PortAXI4())
     self.new(s1 = PortAXI4())
     self.new(s2 = PortAXI4())
     self.new(fab1 = AXI_FAB_2x2())
     self.new(fab2 = AXI_FAB_2x2())
     self.fab1.bi_direction = True
     self.fab2.bi_direction = True
     self.link(self.m1,fab2.s1)
     self.link(self.m2,fab2.s2)
     self.link(self.s1,fab1.m1)
     self.link(self.s2,fab1.m2)
     self.link(fab1.s1,fab2.m1)
     self.link(fab2.s2,fab2.m2)
示例#43
0
    def Stop(self):
        if not self.__isStarted:
            return

        Component.Stop(self)
        pyplot.close()

        self.__isStarted = False
示例#44
0
 def __init__(self, obj, system, material, position):
     Component.__init__(self, obj, system, material)
     
     obj.addProperty("App::PropertyVector", "Position", "Cavity", "Position within the cavity.")
     obj.setEditorMode("Position", 1)
     obj.addProperty("App::PropertyLink", "Structure", "Structure", "Fused structure.")
     obj.setEditorMode("Structure", 2)
     
     obj.addProperty("App::PropertyFloatList", "Pressure", "Subsystem", "Mean pressure.")
     obj.setEditorMode('Pressure', 1)
     obj.addProperty("App::PropertyFloatList", "PressureLevel", "Subsystem", "Pressure level.")
     obj.setEditorMode('PressureLevel', 1)
     
     
     obj.Structure = system.Structure
     obj.Position = position
     self.execute(obj)
示例#45
0
 def _parse(self, xmlmodel):
     name = xmlmodel.get('name')
     if not name:
         logging.warn("Ignoring component definition with no name")
     else:
         attributes = xmlmodel.attrib
         categories = [category.get('name') for category in xmlmodel.findall("category")]
         self._components[name] = Component(categories, name, attributes)
示例#46
0
 def __getattr__(self, name):
     if name not in self._compDict:
         if name not in self.componentNames:
             raise AttributeError("'%s' object has no attribute '%s'" %
                                  (self.__class__.__name__, name))
         path = os.path.join(self.path, name)
         self._compDict[name] = Component(path)
     return self._compDict[name]
示例#47
0
 def toXMLElement(self):
     xmlElement = Component.toXMLElement(self)
     xmlElement.set('fanout', str(self.fanout))
     xmlElement.set('depth', str(self.depth))
     xmlElement.set('spread', str(self.spread))
     xmlElement.set('rootColor', str(self.rootColor).strip('[ ]'))
     xmlElement.set('edgeColor', str(self.edgeColor).strip('[ ]'))
     xmlElement.set('scale', str(self.scale).strip('[ ]'))
     return xmlElement
示例#48
0
 def toXMLElement(self):
     xmlElement = Component.toXMLElement(self)
     xmlElement.set('fanout', str(self.fanout))
     xmlElement.set('depth', str(self.depth))
     xmlElement.set('spread', str(self.spread))
     xmlElement.set('rootColor', str(self.rootColor).strip('[ ]'))
     xmlElement.set('edgeColor', str(self.edgeColor).strip('[ ]'))
     xmlElement.set('scale', str(self.scale).strip('[ ]'))
     return xmlElement
示例#49
0
 def __init__(self, fanout, depth, spread=default_spread, rootColor=default_rootColor, edgeColor=default_edgeColor, scale=default_scale, actor=None):
   Component.__init__(self, actor)
   self.fanout = fanout
   self.depth = depth
   self.spread = spread
   self.rootColor = rootColor
   self.edgeColor = edgeColor
   self.scale = scale
   self.rootScale = self.scale  # NOTE this will also apply to children
   #self.childScale = np.float32([1.0, 1.0, 1.0])  # NOTE this will get compounded if the radial tree is a true hierarchy, better to use scale = 1 (default)
   
   # Recursively generate radial tree
   treeRoot = self.createRadialTree(self.fanout, self.depth, self.spread, isRoot=True)  # creates full hierarchy and returns root actor
   treeRoot.components['Transform'] = Transform(rotation=np.random.uniform(-pi/2, pi/2, size=3), scale=self.rootScale, actor=treeRoot)  # NOTE random rotation ensures child vectors are not always generated close to the same canonical vectors 
   treeRoot.components['Material'] = Material(color=self.rootColor, actor=treeRoot)
   treeRoot.components['Mesh'] = Mesh.getMesh(src=self.treeRootModelFile, actor=treeRoot)
   
   # Attach this hierarchy to current actor
   self.actor.children.append(treeRoot)
示例#50
0
 def __init__(self, scale=cube_scale, actor=None):
   Component.__init__(self, actor)
   Trackable.__init__(self)
   self.scale = scale
   
   # Scale vertices of base cube, specify edges, and initialize list of markers
   self.vertices = cube_vertices * self.scale
   self.vertex_colors = cube_vertex_colors
   self.vertex_scale = 0.3 * self.scale  # NOTE for rendering only, depends on 3D model
   
   self.edges = cube_edges
   self.edge_scale = 0.1 * self.scale  # NOTE for rendering only, depends on 3D model
   self.edge_color = np.float32([0.8, 0.7, 0.5])  # NOTE for rendering only
   # TODO make some of these parameters come from XML
   
   # NOTE Mark generated child actors (corners and edges) as transient, to prevent them from being exported in XML
   
   # Add spheres at cube corners (vertices) with appropriate color; also add color markers
   for vertex, colorName in zip(self.vertices, self.vertex_colors):
     vertexActor = Actor(self.actor.renderer, isTransient=True)
     vertexActor.components['Transform'] = Transform(translation=vertex, scale=self.vertex_scale, actor=vertexActor)
     vertexActor.components['Material'] = Material(color=colors_by_name[colorName], actor=vertexActor)
     vertexActor.components['Mesh'] = Mesh.getMesh(src="SmallSphere.obj", actor=vertexActor)
     self.actor.children.append(vertexActor)
     marker = ColorMarker(self, colorName)
     marker.worldPos = vertex
     self.markers.append(marker)
   
   # Add edges
   for u, v in self.edges:
     if u < len(self.vertices) and v < len(self.vertices) and self.vertices[u] is not None and self.vertices[v] is not None:  # sanity check
       midPoint = (self.vertices[u] + self.vertices[v]) / 2.0
       diff = self.vertices[v] - self.vertices[u]
       mag = np.linalg.norm(diff, ord=2)
       xy_mag = hypot(diff[0], diff[1])
       #zx_mag = hypot(diff[2], diff[0])
       rotation = np.degrees(np.float32([atan2(diff[1], diff[0]), acos(diff[1] / mag), 0])) if (mag != 0 and xy_mag != 0) else np.float32([0.0, 0.0, 0.0])
       #print "u: ", self.vertices[u], ", v: ", self.vertices[v], ", v-u: ", diff, ", mag: ", mag, ", rot:", rotation
       edgeActor = Actor(self.actor.renderer, isTransient=True)
       edgeActor.components['Transform'] = Transform(translation=midPoint, rotation=rotation, scale=self.edge_scale, actor=edgeActor)
       edgeActor.components['Material'] = Material(color=self.edge_color, actor=edgeActor)
       edgeActor.components['Mesh'] = Mesh.getMesh(src="CubeEdge.obj", actor=edgeActor)  # TODO fix Z-fighting issue and use CubeEdge_cylinder.obj
       self.actor.children.append(edgeActor)
示例#51
0
def AddComponent(self, name, cflags, incpath, lib, dependencies, cflagsSetter=DefaultCFlagsSetter, lflagsSetter=DefaultLFlagsSetter, dllDep=[]):
    global componentList
    comp = Component()
    comp.name = name
    comp.cflags = cflags
    comp.incpath = incpath
    comp.lib = lib
    comp.dependencies = dependencies
    comp.CFlagsSetter = cflagsSetter
    comp.LFlagsSetter = lflagsSetter
    comp.dllDependency = dllDep
    
    if not componentList.has_key(comp.name):
        componentList[comp.name] = comp
    else:
        print "we're adding a component twice?"
示例#52
0
 def __init__(self, obj, system, material, part):
     Component.__init__(self, obj, system, material)
     #obj.addProperty("App::PropertyFloat", "BendingStiffness", "Component", "Bending stiffness of the Component")
     
     obj.addProperty("App::PropertyFloat", "AreaMomentOfInertia", "Structural", "Area moment of intertia.")
     obj.setEditorMode("AreaMomentOfInertia", 1)
     obj.addProperty("App::PropertyFloat", "RadiusOfGyration", "Structural", "Radius of gyration.")
     obj.setEditorMode("RadiusOfGyration", 1)
     obj.addProperty("App::PropertyLink","Part","Structural", "Reference to Part")
     obj.setEditorMode("Part", 1)
     obj.addProperty("App::PropertyLinkSub", "ShapeLink", "Structural", "Reference to Shape of Part")
     
     obj.addProperty("App::PropertyFloatList", "Velocity", "Subsystem", "Mean velocity.")
     obj.setEditorMode('Velocity', 1)
     obj.addProperty("App::PropertyFloatList", "VelocityLevel", "Subsystem", "Velocity level.")
     obj.setEditorMode('VelocityLevel', 1)
     
     
     obj.Part = part
     obj.ShapeLink = (obj.Part, ['Shape'])
     
     obj.Label = part.Label + '_' + obj.ClassName
示例#53
0
    def test_task_creation(self):
        self.driver.get("http://examples.sencha.com/extjs/6.0.2/examples/classic/simple-tasks/index.html")
        self.driver.execute_script('localStorage.clear();')
        self.driver.set_page_load_timeout(10)

        # Common asserts for page loaded
        WebDriverWait(self.driver, 5).until(lambda d: d.execute_script('return Ext.isReady && !Ext.env.Ready.firing'))
        self.assertTrue("SimpleTasks" in self.driver.title)
        self.assertTrue(self.driver.execute_script('return window.SimpleTasks != undefined'))

        new_task_name = 'Test task from selenium'
        # Filling up new test task fields
        new_task_form = Component(self.driver, 'taskForm')
        WebDriverWait(self.driver, 5).until(lambda d: new_task_form.rendered)

        task_title = new_task_form.down('textfield[emptyText="Add a new task"]')
        task_title.get_element().find_element_by_xpath('.//input').send_keys(new_task_name)

        task_list = new_task_form.down('treepicker')
        task_list.get_element().find_element_by_xpath('.//input').click()
        lists_tree = Component(self.driver, 'treepanel[floating=true]')
        lists_tree.get_element().find_element_by_xpath('.//span[text()="All Lists"]').click()

        task_date = new_task_form.down('datefield')
        task_date_input_el = task_date.get_element().find_element_by_xpath('.//input')
        task_date_input_el.clear()
        task_date_input_el.send_keys('01/01/2017')
        task_date_input_el.send_keys(Keys.ENTER)

        # Checking for newly created task record
        tasks_grid_view = Component(self.driver, 'taskGrid gridview')
        elements = tasks_grid_view.safe_call('all.elements')
        self.assertEquals(len(elements), 1)
        new_task_el = tasks_grid_view.safe_call('all.elements[0]')
        new_task_el.find_element_by_xpath('.//td/div[text()="{0}"]'.format(new_task_name))
        new_task_el.find_element_by_xpath('.//td/div[text()="All Lists"]')
示例#54
0
 def __init__(self,sschema,xrpr,scope=None):
   if (type(scope) is types.StringType or (xrpr and xrpr.form)=='qualified'):
     ns='ns'
   else:
     ns=None
   Component.__init__(self,sschema,xrpr,ns)
   if xrpr is not None:
     if type(scope) is types.StringType:
       self.scope=scope
       if xrpr.default!=None:
         self.valueConstraint=('default',xrpr.default)
       elif xrpr.fixed!=None:
         self.valueConstraint=('fixed',xrpr.fixed)
     else:
       self.scopeRepr=scope
     if xrpr.type is not None:
       self.typeDefinitionName=QName(xrpr.type,xrpr.elt,
                                     sschema)
       if xrpr.simpleType is not None:
         self.error("declaration with 'type' attribute must not have nested type declaration")
     elif xrpr.simpleType is not None:
       self.typeDefinition=xrpr.simpleType.component
     else:
       self.typeDefinition=Type.urSimpleType
示例#55
0
 def toXMLElement(self):
     xmlElement = Component.toXMLElement(self)
     xmlElement.set('src', self.src)
     return xmlElement
示例#56
0
 def toXMLElement(self):
     xmlElement = Component.toXMLElement(self)
     xmlElement.set('scale', str(self.scale).strip('[ ]'))
     return xmlElement
示例#57
0
    
    # Add edges
    for u, v in self.edges:
      if u < len(self.vertices) and v < len(self.vertices) and self.vertices[u] is not None and self.vertices[v] is not None:  # sanity check
        midPoint = (self.vertices[u] + self.vertices[v]) / 2.0
        diff = self.vertices[v] - self.vertices[u]
        mag = np.linalg.norm(diff, ord=2)
        xy_mag = hypot(diff[0], diff[1])
        #zx_mag = hypot(diff[2], diff[0])
        rotation = np.degrees(np.float32([atan2(diff[1], diff[0]), acos(diff[1] / mag), 0])) if (mag != 0 and xy_mag != 0) else np.float32([0.0, 0.0, 0.0])
        #print "u: ", self.vertices[u], ", v: ", self.vertices[v], ", v-u: ", diff, ", mag: ", mag, ", rot:", rotation
        edgeActor = Actor(self.actor.renderer, isTransient=True)
        edgeActor.components['Transform'] = Transform(translation=midPoint, rotation=rotation, scale=self.edge_scale, actor=edgeActor)
        edgeActor.components['Material'] = Material(color=self.edge_color, actor=edgeActor)
        edgeActor.components['Mesh'] = Mesh.getMesh(src="CubeEdge.obj", actor=edgeActor)  # TODO fix Z-fighting issue and use CubeEdge_cylinder.obj
        self.actor.children.append(edgeActor)
  
  def toXMLElement(self):
      xmlElement = Component.toXMLElement(self)
      xmlElement.set('scale', str(self.scale).strip('[ ]'))
      return xmlElement
  
  def toString(self, indent=""):
      return indent + "Cube: { scale: " + str(self.scale) + " }"
  
  def __str__(self):
      return self.toString()

# Register component type for automatic delegation (e.g. when inflating from XML)
Component.registerType(Cube)
    def calculate(self):
        """\
		calculate() -> Interpretor, Design

		Calculates all the properties on a design. 
		Returns the Interpretor (used to create the design and the actual design).
		"""
        if hasattr(self, "_calculate"):
            return self._calculate
        i = scheme.make_interpreter()

        # Step 1 -------------------------------------

        ranks = self.rank()
        print "The order I need to calculate stuff in is,", ranks

        # Step 2 -------------------------------------

        # The design object
        class Design(dict):
            pass

        design = Design()
        scheme.environment.defineVariable(scheme.symbol.Symbol("design"), design, i.get_environment())

        # Step 3 -------------------------------------
        for rank in ranks.keys():
            for property_id in ranks[rank]:
                property = Property(property_id)

                # Where we will store the values as calculated
                bits = []

                # Get all the components we contain
                for component_id, amount in self.components:
                    # Create the component object
                    component = Component(component_id)

                    # Calculate the actual value for this design
                    value = component.property(property_id)
                    if value:
                        print "Now evaluating", value
                        value = i.eval(scheme.parse("""( %s design)""" % value))

                        print "The value calculated for component %i was %r" % (component_id, value)

                        for x in range(0, amount):
                            bits.append(value)

                print "All the values calculated where", bits
                bits_scheme = "(list"
                for bit in bits:
                    bits_scheme += " " + str(bit).replace("L", "")
                bits_scheme += ")"
                print "In scheme that is", bits_scheme

                print """(let ((bits %s)) (%s design bits))""" % (bits_scheme, property.calculate)
                total = i.eval(
                    scheme.parse("""(let ((bits %s)) (%s design bits))""" % (bits_scheme, property.calculate))
                )
                value, display = scheme.pair.car(total), scheme.pair.cdr(total)

                print "In total I got '%i' which will be displayed as '%s'" % (value, display)
                design[property.name] = (property_id, value, display)

                def t(design, name=property.name):
                    return design[name][1]

                i.install_function("designtype." + property.name, t)

        print "The final properties we have are", design.items()
        self._calculate = (i, design)
        return i, design
示例#59
0
                    for i in xrange(1, 4):
                        l = s[i].split('/')
                        self.meshData.append(float(vertices[int(l[0]) - 1][0]))
                        self.meshData.append(float(vertices[int(l[0]) - 1][1]))
                        self.meshData.append(float(vertices[int(l[0]) - 1][2]))
                        self.meshData.append(float(normals[int(l[2]) - 1][0]))
                        self.meshData.append(float(normals[int(l[2]) - 1][1]))
                        self.meshData.append(float(normals[int(l[2]) - 1][2]))
                        self.elements.append(len(self.elements))

        self.meshData = np.array(self.meshData, dtype = np.float32)
        self.elements = np.array(self.elements, dtype = np.uint32)

    def render(self):
        glBindVertexArray(self.vao)
        glDrawElements(GL_TRIANGLES, self.elements.size, GL_UNSIGNED_INT, None)
    
    def toXMLElement(self):
        xmlElement = Component.toXMLElement(self)
        xmlElement.set('src', self.src)
        return xmlElement
    
    def toString(self, indent=""):
        return indent + "Mesh: { src: \"" + self.src + "\" }"
    
    def __str__(self):
        return self.toString()

# Register component type for automatic delegation (e.g. when inflating from XML)
Component.registerType(Mesh)
示例#60
0
 def __init__(self,sschema,xrpr=None,extra=0):
   Component.__init__(self,sschema,xrpr)
   if xrpr is not None:
     self.processContents=xrpr.processContents