コード例 #1
0
ファイル: scg_controls.py プロジェクト: victorpylinsky/pyUI
    def run(self):

        # build list of available components
        self.build_list()

        # calculate panel position
        pos = render_engine.pos3dTo2dWindow(self.object.getPosition() +
                                            self.object.getScale() / 2)
        # sure that dialog isn't placed out of screen
        x, y = pos
        x2 = x + self.width
        y2 = y + self.height

        if x2 >= render_engine.Window.width:
            x = render_engine.Window.width - self.width
        elif x < 0:
            x = 0

        if y2 >= render_engine.Window.height:
            y = render_engine.Window.height - self.height
        elif y < 0:
            y = 0

        self.panel.setPosition(x, y)

        # show panel
        self.panel.setVisible(True)
コード例 #2
0
ファイル: geom_qw_list.py プロジェクト: glebgladkiy/pyUI
    def run(self):

        # build list of available components
        self.build_list()

        # calculate panel position
        pos = render_engine.pos3dTo2dWindow(self.object[0].getPosition() + self.object[0].getScale() / 2)
        # sure that dialog isn't placed out of screen
        x, y = pos
        x2 = x + self.width
        y2 = y + self.height

        if x2 >= render_engine.Window.width:
            x = render_engine.Window.width - self.width
        elif x < 0:
            x = 0

        if y2 >= render_engine.Window.height:
            y = render_engine.Window.height - self.height
        elif y < 0:
            y = 0

        self.panel.setPosition(x, y)

        # show panel
        self.panel.setVisible(True)
コード例 #3
0
ファイル: logic_viewer.py プロジェクト: kulex4/pyUI
 def getPosition(self):
     """Calculate widget position
     @return: tuple that contains new widget position 
     """
     if self.isRoot:
         size = self.getSize()
         return ((render_engine.Window.width - size[0]) / 2, (render_engine.Window.height - size[1]) / 2)
         
     pos3d = self._getSheet().getPosition()
     pos2d = render_engine.pos3dTo2dWindow(pos3d)
     return (pos2d[0] - 45, pos2d[1] - 45)
コード例 #4
0
 def getPosition(self):
     """Calculate widget position
     @return: tuple that contains new widget position 
     """
     if self.isRoot:
         size = self.getSize()
         return ((render_engine.Window.width - size[0]) / 2, (render_engine.Window.height - size[1]) / 2)
         
     pos3d = self._getSheet().getPosition()
     pos2d = render_engine.pos3dTo2dWindow(pos3d)
     return (pos2d[0] - 45, pos2d[1] - 45)
コード例 #5
0
ファイル: space_modes.py プロジェクト: Alexandra-H/pyUI
    def _update(self, timeSinceLastFrame):
        """Updates mode
        """
        if FlyMode.isActive(self):
            FlyMode._update(self,timeSinceLastFrame);
#       if self.vis_menu.isShow():
        sel_objects = self._logic._getSheet().getSelected()
        n = len(sel_objects)
        if n == 1:
            obj = sel_objects[0]
            self.vis_menu.move(render_engine.pos3dTo2dWindow(sel_objects[0].getPosition()))
        self.vis_menu._update(timeSinceLastFrame)
コード例 #6
0
ファイル: TextInput.py プロジェクト: Okne/ymapostis
    def start(self):
        """Creates controls to change object identifier
        """
        self.createWidgets()
        pos = render_engine.pos3dTo2dWindow(self.object.getPosition() + self.object.getScale() / 2)
        if pos is not None:
            self.panel.setPosition(pos[0], pos[1])
            # set old text to edit
#            text_value = self.object.getText()
            if self.default_value is not None: self.idtf_edit.setCaption(self.default_value)
            mygui.InputManager.getInstance().setKeyFocusWidget(self.idtf_edit)
        else:
            self.destroyWidgets()
コード例 #7
0
ファイル: text_viewer.py プロジェクト: titenkov/OSTIS-NUMSYS
    def _updateState(self):

        _sheet = self._getSheet()
        if self.isRoot:
            self.statictext.setVisible(True)
        elif not self.isRoot and _sheet.isContentShow and _sheet.isSceneAttached:
            self.statictext.setVisible(True)
            pos3d = self._getSheet().getPosition()
            pos2d = render_engine.pos3dTo2dWindow(pos3d)
            self.statictext.setPosition(pos2d[0] - 45, pos2d[1] - 45)
        elif not _sheet.isContentShow or not _sheet.isSceneAttached and not self.isRoot:
            self.statictext.setVisible(False)

        return True
コード例 #8
0
def mouse_move_object(_params, _segment):

    session = Kernel.session()

    # getting command node
    command = session.search_one_shot(
        session.sc_constraint_new(sc_core.constants.CONSTR_5_f_a_a_a_f,
                                  keynodes.ui.init_base_user_cmd,
                                  sc_core.pm.SC_A_CONST, sc_core.pm.SC_N_CONST,
                                  sc_core.pm.SC_A_CONST, _params), True, 5)
    if not command:
        return
    command = command[2]

    # check if it's a mouse move to object command
    if not sc_utils.checkIncToSets(session, command,
                                   [keynodes.ui.cmd_mouse_move_obj],
                                   sc_core.pm.SC_CONST):
        return

    # remove command from initiated set
    sc_utils.removeFromSet(session, command, keynodes.ui.init_base_user_cmd)

    # make command activated
    sc_utils.appendIntoSet(session, _segment, command,
                           keynodes.ui.active_base_user_cmd,
                           sc_core.pm.SC_CONST | sc_core.pm.SC_POS)

    # get target object
    object = session.search_one_shot(
        session.sc_constraint_new(sc_core.constants.CONSTR_3_f_a_a, command,
                                  sc_core.pm.SC_A_CONST, 0), True, 3)
    if not object:
        return

    object = object[2]

    obj = ScObject._sc2Objects(object)
    if len(obj) == 0:
        return
    obj = obj[0]
    # FIXME: find element in specified window (root window)
    init_pos = (0, 0)
    target_pos = render_engine.pos3dTo2dWindow(obj.getPosition())

    cmd = commands.MouseMove(init_pos, target_pos)
    cmd.eventFinished = finish_callback
    cmds[cmd] = command
    cmd.start()
コード例 #9
0
ファイル: space_modes.py プロジェクト: Alexandra-H/pyUI
 def _updateVisualMenu(self):
     """Updates visual menu depending on selection
     """
     if self._logic is None or self._logic._getSheet() is None:
         return
     
     import types
     sel_objects = [] + self._logic._getSheet().getSelected()
     
     if self.vis_menu.isShow():
         self.vis_menu.hide()
     
     if not self.active: return
     
     n = len(sel_objects)
     if n > 0:   self.vis_menu.show(render_engine.pos3dTo2dWindow(sel_objects[0].getPosition()))
コード例 #10
0
    def _updateVisualMenu(self):
        """Updates visual menu depending on selection
        """
        if self._logic is None or self._logic._getSheet() is None:
            return

        import types
        sel_objects = [] + self._logic._getSheet().getSelected()

        if self.vis_menu.isShow():
            self.vis_menu.hide()

        if not self.active: return

        n = len(sel_objects)
        if n == 1:
            obj = sel_objects[0]

            # check types
            isNode = isinstance(obj, scg_objects.SCgNode)
            isPair = isinstance(obj, scg_objects.SCgPair)
            isContent = isinstance(obj, objects.ObjectSheet)

            # change type
            self.mi_type.setEnabled(isNode or isPair)
            # content
            self.mi_contentChange.setEnabled(isNode)
            # idtf
            self.mi_idtf.setEnabled(obj._getScAddr() is None)

            cs = ch = False
            if isContent:
                cs = not obj.isContentShow
                ch = obj.isContentShow

            self.mi_content_show.setEnabled(cs)
            self.mi_content_hide.setEnabled(ch)
        else:
            self.mi_type.setEnabled(False)
            self.mi_contentChange.setEnabled(False)
            self.mi_idtf.setEnabled(False)
            self.mi_content_show.setEnabled(False)
            self.mi_content_hide.setEnabled(False)

        if n > 0:
            self.vis_menu.show(
                render_engine.pos3dTo2dWindow(sel_objects[0].getPosition()))
コード例 #11
0
ファイル: scg_modes.py プロジェクト: Okne/ymapostis
 def _updateVisualMenu(self):
     """Updates visual menu depending on selection
     """
     if self._logic is None or self._logic._getSheet() is None:
         return
     
     import types
     sel_objects = [] + self._logic._getSheet().getSelected()
     
     if self.vis_menu.isShow():
         self.vis_menu.hide()
     
     if not self.active: return
     
     n = len(sel_objects)
     if n == 1:
         obj = sel_objects[0]
         
         # check types
         isNode = isinstance(obj, scg_objects.SCgNode)
         isPair = isinstance(obj, scg_objects.SCgPair)
         isContent = isinstance(obj, objects.ObjectSheet) 
         
         # change type
         self.mi_type.setEnabled(isNode or isPair)
         # content
         self.mi_contentChange.setEnabled(isNode)
         # idtf
         self.mi_idtf.setEnabled(obj._getScAddr() is None)
         
         cs = ch = False
         if isContent:
             cs = not obj.isContentShow
             ch = obj.isContentShow
             
         self.mi_content_show.setEnabled(cs)
         self.mi_content_hide.setEnabled(ch)
     else:
         self.mi_type.setEnabled(False)
         self.mi_contentChange.setEnabled(False)
         self.mi_idtf.setEnabled(False)
         self.mi_content_show.setEnabled(False)
         self.mi_content_hide.setEnabled(False)
         
     if n > 0:   self.vis_menu.show(render_engine.pos3dTo2dWindow(sel_objects[0].getPosition()))
コード例 #12
0
    def _update(self, timeSinceLastFrame):
        BaseCommand._update(self, timeSinceLastFrame)

        if self.object is None:
            self.finish()
            return

        if self.paused and self.pause <= 0:
            self.finish()
            return
        else:
            self.pause -= timeSinceLastFrame

        target_pos = None
        if isinstance(self.object, objects.ObjectDepth):
            target_pos = render_engine.pos3dTo2dWindow(
                self.object.getPosition())
        else:
            target_pos = self.object.getCenter()

        dist = self.speed * timeSinceLastFrame
        rem_dist = self.distance(self.current_pos, target_pos)

        if dist >= rem_dist:  # end moving
            self.setMousePosition(target_pos)
            self.paused = True
            return
        else:
            self.pause = self.init_pause

        dx = target_pos[0] - self.current_pos[0]
        dy = target_pos[1] - self.current_pos[1]
        d = self.distance((0, 0), (dx, dy))
        new_pos = (self.current_pos[0] + dx / d * dist,
                   self.current_pos[1] + dy / d * dist)

        self.setMousePosition(new_pos)
        self.current_pos = new_pos
コード例 #13
0
ファイル: commands.py プロジェクト: AnastasiaAvramova/pyUI
 def _update(self, timeSinceLastFrame):
     BaseCommand._update(self, timeSinceLastFrame)
     
     if self.object is None:
         self.finish()
         return
     
     if self.paused and self.pause <= 0:
         self.finish()
         return
     else:
         self.pause -= timeSinceLastFrame
     
     target_pos = None
     if isinstance(self.object, objects.ObjectDepth):
         target_pos = render_engine.pos3dTo2dWindow(self.object.getPosition())
     else:
         target_pos = self.object.getCenter()
     
     dist = self.speed * timeSinceLastFrame
     rem_dist = self.distance(self.current_pos, target_pos)
            
     if dist >= rem_dist:    # end moving
         self.setMousePosition(target_pos)
         self.paused = True
         return
     else:
         self.pause = self.init_pause
     
     dx = target_pos[0] - self.current_pos[0]
     dy = target_pos[1] - self.current_pos[1]
     d = self.distance((0, 0), (dx, dy))
     new_pos = (self.current_pos[0] + dx / d * dist,
                self.current_pos[1] + dy / d * dist)
             
     self.setMousePosition(new_pos)
     self.current_pos = new_pos
コード例 #14
0
    def _update(self, timeSinceLastFrame):
        """Updates mode
        """
        #        if self.vis_menu.isShow():
        sel_objects = self._logic._getSheet().getSelected()
        n = len(sel_objects)
        if n == 1:
            obj = sel_objects[0]
            self.vis_menu.move(
                render_engine.pos3dTo2dWindow(sel_objects[0].getPosition()))
        self.vis_menu._update(timeSinceLastFrame)

        if not self._ctrl and self.state is SCgEditMode.ES_Translate:
            if self._logic._getSheet(
            ).isRoot and render_engine.viewMode is render_engine.Mode_Perspective:
                # processing keyboard input
                if render_engine._oisKeyboard.isKeyDown(ois.KC_A):
                    self.move.x = -self.moveScale  # Move camera left

                if render_engine._oisKeyboard.isKeyDown(ois.KC_D):
                    self.move.x = self.moveScale  # Move camera RIGHT

                if render_engine._oisKeyboard.isKeyDown(ois.KC_W):
                    self.move.z = -self.moveScale  # Move camera forward

                if render_engine._oisKeyboard.isKeyDown(ois.KC_S):
                    self.move.z = self.moveScale  # Move camera backward

                if render_engine._oisKeyboard.isKeyDown(ois.KC_Q):
                    self.move.y = self.moveScale  # Move camera up

                if render_engine._oisKeyboard.isKeyDown(ois.KC_E):
                    self.move.y = -self.moveScale  # Move camera down

                # updating camera position
                camera = render_engine._ogreCamera
                cameraNode = render_engine._ogreCameraNode
                cameraNode.translate(camera.getOrientation() * self.move *
                                     timeSinceLastFrame)
                camera.yaw(self.rotX)
                camera.pitch(self.rotY)
                self.move = ogre.Vector3(0, 0, 0)
                self.rotX = 0
                self.rotY = 0

        needMove = False
        offset = ogre.Vector3(0, 0, 0)
        dv = 1 * timeSinceLastFrame

        if render_engine._oisKeyboard.isKeyDown(ois.KC_LEFT):
            offset.x = -dv
            needMove = True
        if render_engine._oisKeyboard.isKeyDown(ois.KC_RIGHT):
            offset.x = dv
            needMove = True
        if render_engine._oisKeyboard.isKeyDown(ois.KC_UP):
            offset.y = dv
            needMove = True
        if render_engine._oisKeyboard.isKeyDown(ois.KC_DOWN):
            offset.y = -dv
            needMove = True
        if render_engine._oisKeyboard.isKeyDown(ois.KC_Z):
            offset.z = dv
            needMove = True
        if render_engine._oisKeyboard.isKeyDown(ois.KC_X):
            offset.z = -dv
            needMove = True

        if needMove:
            for obj in self._logic._getSheet().getSelected():
                obj.setPosition(obj.getPosition() +
                                render_engine._ogreCamera.getOrientation() *
                                offset)

        if self.animationState is not None:
            self.animationState.addTime(timeSinceLastFrame)
コード例 #15
0
ファイル: geom_modes.py プロジェクト: burikella/pyUI
    def _onKeyPressed(self, _evt):
        """Event on key pressed
        """
        
        if BaseEditMode._onKeyPressed(self, _evt):  return True
        
        key = _evt.key
        
        if key == ois.KC_C:
            _selected = self._logic._getSheet().getSelected()
            self.active_object = self._logic.createCircle()
            if self.active_object.makeBasedOnObjects(_selected):
                self._logic._getSheet().addChild(self.active_object)
            else:
                self.active_object.delete()
            self.active_object = None
            
        if key == ois.KC_A:
            _selected = self._logic._getSheet().getSelected()
            self.active_object = self._logic.createAngle()
            if self.active_object.makeBasedOnObjects(_selected):
                self._logic._getSheet().addChild(self.active_object)
            else:
                self.active_object.delete()
            self.active_object = None
            
        if key == ois.KC_T:
            _selected = self._logic._getSheet().getSelected()
            self.active_object = self._logic.createTriangle()
            if self.active_object.makeBasedOnObjects(_selected):
                self._logic._getSheet().addChild(self.active_object)
            else:
                self.active_object.delete()
            self.active_object = None
            
        if key == ois.KC_Q:
            _selected = self._logic._getSheet().getSelected()
            self.active_object = self._logic.createQuadrangle()
            if self.active_object.makeBasedOnObjects(_selected):
                self._logic._getSheet().addChild(self.active_object)
            else:
                self.active_object.delete()
            self.active_object = None

        if key == ois.KC_M:
            _selected = self._logic._getSheet().getSelected()
            self.active_object = self._logic.createPolygon()
            if self.active_object.makeBasedOnObjects(_selected):
                self._logic._getSheet().addChild(self.active_object)
            else:
                self.active_object.delete()
            self.active_object = None
                    
        if key == ois.KC_L:
            selected = self._logic._getSheet().getSelected()
            if len(selected) == 1:
                obj = selected[0]
                if isinstance(selected[0], (GeometryLineSection, GeometryCircle)):
                    self.state = GeometryEditMode.ES_LengthChange
                    self.length_changer = TextInput(obj, self._length_change_callback, obj.getPropertyValue(GeometryAbstractObject.PropLength))
                
        if key == ois.KC_E:
            selected = self._logic._getSheet().getSelected()
            if len(selected) == 2:
                if isinstance(selected[0], selected[1].__class__):
                    selected[0].setEqualTo(selected[1])
                    if self.objectInfoPanel.getObject() is selected[0] or self.objectInfoPanel.getObject() is selected[1]:
                        self.objectInfoPanel.update()              
        
        if key == ois.KC_S:
            selected = self._logic._getSheet().getSelected()
            if len(selected) == 1:
                obj = selected[0]
                if isinstance(obj, (GeometryCircle, GeometryTriangle, GeometryQuadrangle)):
                    self.state = GeometryEditMode.ES_SquareChange
                    self.square_changer = TextInput(obj, self._square_change_callback, obj.getPropertyValue(GeometryAbstractObject.PropSquare))
                    
        if key == ois.KC_P:
            selected = self._logic._getSheet().getSelected()
            if len(selected) == 1:
                obj = selected[0]
                if isinstance(obj, (GeometryTriangle, GeometryQuadrangle)):
                    self.state = GeometryEditMode.ES_PerimeterChange
                    self.perimetr_changer = TextInput(obj, self._perimeter_change_callback, obj.getPropertyValue(GeometryAbstractObject.PropPerimeter))

        if key == ois.KC_O:
            selected = self._logic._getSheet().getSelected()
            for obj in selected:
                if isinstance(obj, GeometryQuadrangle):

                    sheet = self._logic._getSheet()
                    c = obj.getCircumCircleCenter()

                    c = self._logic.createPoint(render_engine.pos3dTo2dWindow(c))
                    sheet.addChild(c)
                    c._updateView()

                    p = obj.getSides()[0].getBegin()

                    self.active_object = self._logic.createCircle()
                    if self.active_object.makeBasedOnObjects([c, p]):
                        sheet.addChild(self.active_object)
                        obj.setCircumCircle(self.active_object)
                    else:
                        self.active_object.delete()
                    self.active_object = None

        if key == ois.KC_V:
            selected = self._logic._getSheet().getSelected()
            for obj in selected:
                if isinstance(obj, GeometryQuadrangle):

                    points = obj.getInCirclePoints()
                    sheet = self._logic._getSheet()

                    c = self._logic.createPoint(render_engine.pos3dTo2dWindow(points[0]))
                    sheet.addChild(c)
                    c._updateView()

                    p = self._logic.createPoint(render_engine.pos3dTo2dWindow(points[1]))
                    sheet.addChild(p)
                    p._updateView()

                    self.active_object = self._logic.createCircle()
                    if self.active_object.makeBasedOnObjects([c, p]):
                        sheet.addChild(self.active_object)
                    else:
                        self.active_object.delete()
                    self.active_object = None

        return False
コード例 #16
0
ファイル: scg_controls.py プロジェクト: victorpylinsky/pyUI
    def run(self):
        """Runs type changing dialog
        """
        split_old_type = self.old_type.split("/")
        types_list = None

        if isinstance(self.object, scg_objects.SCgNode):
            types_list = scg_alphabet.get_node_types()
        elif isinstance(self.object, scg_objects.SCgPair):
            types_list = scg_alphabet.get_pair_types()
        else:
            raise Exception("Unknown object type %s" % str(self.object))

        assert len(types_list) > 0

        split_types = []
        for _type in types_list:
            split_types.append(_type.split("/"))

        # parse possible values and create controls for changing them
        for idx in xrange(0, len(split_types[0])):
            values = []
            for _type in split_types:
                if not _type[idx] in values:
                    values.append(_type[idx])

            ctrl = ChoiceControl(values, split_old_type[idx], self.panel,
                                 self.updateType)

            self.controls.append(ctrl)

        # layout created controls
        height = 5

        for ctrl in self.controls:
            ctrl.panel.setPosition(3, height)
            height += ctrl.panel.getHeight() + 5
            width = ctrl.panel.getWidth()

        self.button_ok.setPosition(10, height + 10)
        self.button_cancel.setPosition(65, height + 10)

        pos = render_engine.pos3dTo2dWindow(self.object.getPosition() +
                                            self.object.getScale() / 2)
        # make some offset
        width += 20
        height += 45
        self.panel.setSize(width, height)

        # sure that dialog isn't placed out of screen
        x, y = pos
        x2 = x + width
        y2 = y + height

        if x2 >= render_engine.Window.width:
            x = render_engine.Window.width - width
        elif x < 0:
            x = 0

        if y2 >= render_engine.Window.height:
            y = render_engine.Window.height - height
        elif y < 0:
            y = 0

        self.panel.setPosition(x, y)

        # show panel
        self.panel.setVisible(True)
コード例 #17
0
ファイル: scg_controls.py プロジェクト: Alexandra-H/pyUI
 def run(self):
     """Runs type changing dialog
     """
     split_old_type = self.old_type.split("/")
     types_list = None
     
     if isinstance(self.object, scg_objects.SCgNode):
         types_list = scg_alphabet.get_node_types()
     elif isinstance(self.object, scg_objects.SCgPair):
         types_list = scg_alphabet.get_pair_types()
     else:
         raise Exception("Unknown object type %s" % str(self.object))
     
     assert len(types_list) > 0
     
     split_types = []        
     for _type in types_list:
         split_types.append(_type.split("/"))
     
     # parse possible values and create controls for changing them
     for idx in xrange(0, len(split_types[0])):
         values = []
         for _type in split_types:
             if not _type[idx] in values:
                 values.append(_type[idx])
         
         ctrl = ChoiceControl(values, split_old_type[idx], self.panel, self.updateType)
         
         self.controls.append(ctrl)
         
     # layout created controls
     height = 5
     
     for ctrl in self.controls:
         ctrl.panel.setPosition(3, height)
         height += ctrl.panel.getHeight() + 5
         width = ctrl.panel.getWidth()
     
     self.button_ok.setPosition(10, height + 10)
     self.button_cancel.setPosition(65, height + 10)
     
     pos = render_engine.pos3dTo2dWindow(self.object.getPosition() + self.object.getScale() / 2)
     # make some offset
     width += 20
     height += 45   
     self.panel.setSize(width, height)
     
     # sure that dialog isn't placed out of screen  
     x, y = pos
     x2 = x + width
     y2 = y + height
     
     if x2 >= render_engine.Window.width:
         x = render_engine.Window.width - width
     elif x < 0:
         x = 0
         
     if y2 >= render_engine.Window.height:
         y = render_engine.Window.height - height
     elif y < 0:
         y = 0    
     
     self.panel.setPosition(x, y)
     
     # show panel
     self.panel.setVisible(True)