当前位置: 首页>>代码示例>>Python>>正文


Python BaseEditMode._onKeyPressed方法代码示例

本文整理汇总了Python中suit.cf.BaseEditMode._onKeyPressed方法的典型用法代码示例。如果您正苦于以下问题:Python BaseEditMode._onKeyPressed方法的具体用法?Python BaseEditMode._onKeyPressed怎么用?Python BaseEditMode._onKeyPressed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在suit.cf.BaseEditMode的用法示例。


在下文中一共展示了BaseEditMode._onKeyPressed方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _onKeyPressed

# 需要导入模块: from suit.cf import BaseEditMode [as 别名]
# 或者: from suit.cf.BaseEditMode import _onKeyPressed [as 别名]
    def _onKeyPressed(self, _evt):
        """Keyboard button pressed event
        """
        if BaseEditMode._onKeyPressed(self, _evt):  return True
        
        if _evt.key == ois.KC_F9:
            
            if render_engine.viewMode is render_engine.Mode_Isometric:
                self._logic._getSheet().changeMode(render_engine.Mode_Perspective)
            else:
                self._logic._getSheet().changeMode(render_engine.Mode_Isometric)
            self.navigation = False
            
        # create link between objects    
        if _evt.key == ois.KC_SPACE:
            _args = self._logic._getSheet().getSelected()
            if len(_args) == 2 and isinstance(_args[0], chem_objects.ChemistryAtom) and isinstance(_args[1], chem_objects.ChemistryAtom):
                self._logic.addLink(_args[0], _args[1])
                
        # create random element
        if _evt.key == ois.KC_F1:
            import random
            atoms_num = random.randint(50, 100)
            links_num = random.randint(0, atoms_num)
            names = self.type_bindings.values()
            atoms = []
            for a in xrange(atoms_num):
                _atom = self._logic.addAtom(ogre.Vector3(float(random.randint(-10, 10)), float(random.randint(-10, 10)), 0.0), 'C')
                if len(atoms) > 0:
                    a1 = random.randint(0, len(atoms) - 1)
                    self._logic.addLink(atoms[a1], _atom)
                    
                atoms.append(_atom)
                
#            for l in xrange(links_num):
#                a1 = random.randint(0, atoms_num - 1)
#                a2 = random.randint(0, atoms_num - 1)
#                while a1 == a2:
#                    a2 = random.randint(0, atoms_num - 1)
#                self._logic.addLink(atoms[a1], atoms[a2])
        
        # test type changing
        if self.type_bindings.has_key(_evt.key):
            self.setSelectionName(self.type_bindings[_evt.key])
        
        
        return False
开发者ID:Alexandra-H,项目名称:pyUI,代码行数:49,代码来源:chem_modes.py

示例2: _onKeyPressed

# 需要导入模块: from suit.cf import BaseEditMode [as 别名]
# 或者: from suit.cf.BaseEditMode import _onKeyPressed [as 别名]
    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_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()

        #remove figure's congruence property
        if key == ois.KC_W:
            selected = self._logic._getSheet().getSelected()
            if len(selected) == 2:
                if isinstance(selected[0], selected[1].__class__):
                    selected[0].removeCongruency(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_R:
            selected = self._logic._getSheet().getSelected()
            if len(selected) == 1:
                obj = selected[0]
                if isinstance(obj, GeometryCircle):
                    self.state = GeometryEditMode.ES_RadiusChange
                    self.radius_changer = TextInput(obj, self._radius_change_callback, obj.getPropertyValue(GeometryAbstractObject.PropRadius))

        if key == ois.KC_D:
            selected = self._logic._getSheet().getSelected()
            if len(selected) == 1:
                obj = selected[0]
                if isinstance(obj, GeometryCircle):
                    self.state = GeometryEditMode.ES_DiameterChange
                    self.diameter_changer = TextInput(obj, self._diameter_change_callback, obj.getPropertyValue(GeometryAbstractObject.PropDiameter))
#.........这里部分代码省略.........
开发者ID:aifabregaz,项目名称:pyUI,代码行数:103,代码来源:geom_modes.py

示例3: _onKeyPressed

# 需要导入模块: from suit.cf import BaseEditMode [as 别名]
# 或者: from suit.cf.BaseEditMode import _onKeyPressed [as 别名]
    def _onKeyPressed(self, _evt):
        """Key pressed event
        """
        BaseEditMode._onKeyPressed(self, _evt)
        
        key = _evt.key
        
        if key == ois.KC_LSHIFT:
            self._shift = True
                    
        elif key == ois.KC_T:
            self._handlerChangeType()
            
        elif key == ois.KC_C:
            self._handlerChangeContent()
            
        elif key == ois.KC_H:
            self._handlerContentToogle()
           
        elif key == ois.KC_SPACE:
            layout_group = self._logic._getSheet().getLayoutGroup()
            if layout_group is not None:
                if layout_group.isPlaying():
                    layout_group.stop()
                else:
                    layout_group.play()
                    
        elif _evt.key == ois.KC_F9:
            if render_engine.viewMode is render_engine.Mode_Isometric:
                self._logic._getSheet().changeMode(render_engine.Mode_Perspective)
            else:
                self._logic._getSheet().changeMode(render_engine.Mode_Isometric)
            self.line_mode_line._needModeUpdate()
            
        # test code
        elif _evt.key == ois.KC_F3:# and 0:
            
            self._logic._getSheet().setLayoutGroup(None)
            
            elements = []
            node_center = scg_alphabet.createSCgNode("node/const/binary")
            node_center.setText(u"центр*")
            elements.append(node_center)
            
            node_tchk_O = scg_alphabet.createSCgNode("node/const/real")
            node_tchk_O.setText(u"Тчк О")
            elements.append(node_tchk_O)
            
            node_tchk_A = scg_alphabet.createSCgNode("node/const/real")
            node_tchk_A.setText(u"Тчк А")
            elements.append(node_tchk_A)
            
            node_tchk_B = scg_alphabet.createSCgNode("node/const/real")
            node_tchk_B.setText(u"Тчк B")
            elements.append(node_tchk_B)
            
            node_tchk_C = scg_alphabet.createSCgNode("node/const/real")
            node_tchk_C.setText(u"Тчк C")
            elements.append(node_tchk_C)
            
            node_tchk_A1 = scg_alphabet.createSCgNode("node/const/real")
            node_tchk_A1.setText(u"Тчк А1")
            elements.append(node_tchk_A1)
            
            node_tchk_B1 = scg_alphabet.createSCgNode("node/const/real")
            node_tchk_B1.setText(u"Тчк B1")
            elements.append(node_tchk_B1)
            
            node_tchk_C1 = scg_alphabet.createSCgNode("node/const/real")
            node_tchk_C1.setText(u"Тчк C1")
            elements.append(node_tchk_C1)
            
            node_tchk_A2 = scg_alphabet.createSCgNode("node/const/real")
            node_tchk_A2.setText(u"Тчк А2")
            elements.append(node_tchk_A2)
            
            node_tchk_B2 = scg_alphabet.createSCgNode("node/const/real")
            node_tchk_B2.setText(u"Тчк B2")
            elements.append(node_tchk_B2)
            
            node_tchk_C2 = scg_alphabet.createSCgNode("node/const/real")
            node_tchk_C2.setText(u"Тчк C2")
            elements.append(node_tchk_C2)
            
            node_okr_OA2 = scg_alphabet.createSCgNode("node/const/struct")
            node_okr_OA2.setText(u"Окр(ТчкO;ТчкA2)")
            elements.append(node_okr_OA2)
            
            node_okr = scg_alphabet.createSCgNode("node/const/term")
            node_okr.setText(u"окружность")
            elements.append(node_okr)
            
            node_otr = scg_alphabet.createSCgNode("node/const/term")
            node_otr.setText(u"отрезок")
            elements.append(node_otr)
            
            node_otr_AA1 = scg_alphabet.createSCgNode("node/const/struct")
            node_otr_AA1.setText(u"Отр(ТчкА;ТчкА1)")
            elements.append(node_otr_AA1)
            
#.........这里部分代码省略.........
开发者ID:Okne,项目名称:ymapostis,代码行数:103,代码来源:scg_modes.py

示例4: _onKeyPressed

# 需要导入模块: from suit.cf import BaseEditMode [as 别名]
# 或者: from suit.cf.BaseEditMode import _onKeyPressed [as 别名]
 def _onKeyPressed(self, _evt):
     """Event on key pressed
     """
     if BaseEditMode._onKeyPressed(self, _evt):  return True
             
     return False
开发者ID:Alexandra-H,项目名称:pyUI,代码行数:8,代码来源:graph_modes.py

示例5: _onKeyPressed

# 需要导入模块: from suit.cf import BaseEditMode [as 别名]
# 或者: from suit.cf.BaseEditMode import _onKeyPressed [as 别名]
    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_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_V:
            selected = self._logic._getSheet().getSelected()
            for obj in selected:
                if isinstance(obj, (GeometryTriangle)):

                    incirclePoints = obj._calculateIncirclePoints()

                    # create center point
                    incenterPointCoord = incirclePoints[0]
                    incenter = self._logic.createPoint(incenterPointCoord)
                    sheet = self._logic._getSheet()
                    sheet.addChild(incenter)
                    incenter._updateView()

                    # create tangent point
                    tangentPointCoord = incirclePoints[1]

                    # get tangent point base side line
                    sideObjects = self._logic._getSheet()._getObjectsUnderMouse(True, True, tangentPointCoord)
                    line = comutils._getFirstObjectTypeFromList(sideObjects, [GeometryLineSection])

                    tangent = self._logic.createPoint(tangentPointCoord)
                    sheet = self._logic._getSheet()
                    sheet.addChild(tangent)
#.........这里部分代码省略.........
开发者ID:DenisKlimenko,项目名称:pyUI,代码行数:103,代码来源:geom_modes.py

示例6: _onKeyPressed

# 需要导入模块: from suit.cf import BaseEditMode [as 别名]
# 或者: from suit.cf.BaseEditMode import _onKeyPressed [as 别名]
    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_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_K:
            selected = self._logic._getSheet().getSelected()
            if len(selected) == 1:
                obj = selected[0]
                if isinstance(obj, (GeometryQuadrangle)):
                    from components.geometry.base.geom_qw_list import QuadrangleChanger
                    self.dialog = QuadrangleChanger(obj,self._kind_change_callback,obj.getPropertyValue(GeometryAbstractObject.PropKind))
开发者ID:glebgladkiy,项目名称:pyUI,代码行数:85,代码来源:geom_modes.py

示例7: _onKeyPressed

# 需要导入模块: from suit.cf import BaseEditMode [as 别名]
# 或者: from suit.cf.BaseEditMode import _onKeyPressed [as 别名]
    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()
            if len(_selected) == 1 and isinstance(_selected[0], GeometryTriangle):

                obj = _selected[0]
                circlePoints = obj._calculateCirclePoints()

                CoordinateC = circlePoints[0]
                center = self._logic.createPoint(CoordinateC)
                sheet = self._logic._getSheet()
                sheet.addChild(center)
                center._updateView()

                CoordinateT = circlePoints[1]

                sideObjects = self._logic._getSheet()._getObjectsUnderMouse(True, True, CoordinateT)
                line = comutils._getFirstObjectTypeFromList(sideObjects, [GeometryLineSection])

                tangent = self._logic.createPoint(CoordinateT)
                sheet = self._logic._getSheet()
                sheet.addChild(tangent)

                tangent._updateView()

                _selected = center, tangent

                obj._setCenterPoints(_selected)
                obj._setIsCircleDrawed(True)

            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_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()

        #remove figure's congruence property
        if key == ois.KC_W:
            selected = self._logic._getSheet().getSelected()
            if len(selected) == 2:
                if isinstance(selected[0], selected[1].__class__):
                    selected[0].removeCongruency(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:
#.........这里部分代码省略.........
开发者ID:Plutinsky,项目名称:pyUI,代码行数:103,代码来源:geom_modes.py

示例8: _onKeyPressed

# 需要导入模块: from suit.cf import BaseEditMode [as 别名]
# 或者: from suit.cf.BaseEditMode import _onKeyPressed [as 别名]
    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()
#.........这里部分代码省略.........
开发者ID:burikella,项目名称:pyUI,代码行数:103,代码来源:geom_modes.py


注:本文中的suit.cf.BaseEditMode._onKeyPressed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。