本文整理汇总了Python中suit.cf.BaseEditMode._onMousePressed方法的典型用法代码示例。如果您正苦于以下问题:Python BaseEditMode._onMousePressed方法的具体用法?Python BaseEditMode._onMousePressed怎么用?Python BaseEditMode._onMousePressed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类suit.cf.BaseEditMode
的用法示例。
在下文中一共展示了BaseEditMode._onMousePressed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _onMousePressed
# 需要导入模块: from suit.cf import BaseEditMode [as 别名]
# 或者: from suit.cf.BaseEditMode import _onMousePressed [as 别名]
def _onMousePressed(self, _evt, _id):
"""Mouse button pressed event
"""
if BaseEditMode._onMousePressed(self, _evt, _id): return True
# getting objects under mouse
mobjects = self._logic._getSheet()._getObjectsUnderMouse(True, True, self.mouse_pos)
if _id == ois.MB_Right:
if len(mobjects) == 0:
if render_engine.viewMode is render_engine.Mode_Perspective:
self._logic.addAtom(render_engine.pos2dToViewPortRay(self.mouse_pos).getPoint(10.0), "H")
else:
self._logic.addAtom(render_engine.pos2dTo3dIsoPos(self.mouse_pos), "H")
elif _id == ois.MB_Left:
if len(mobjects) > 0:
self._selectObject(mobjects[0][1])
else:
if render_engine.viewMode is render_engine.Mode_Perspective:
self.navigation = True
return False
示例2: _onMousePressed
# 需要导入模块: from suit.cf import BaseEditMode [as 别名]
# 或者: from suit.cf.BaseEditMode import _onMousePressed [as 别名]
def _onMousePressed(self, _evt, _id):
"""Event on mouse button pressed
"""
if BaseEditMode._onMousePressed(self, _evt, _id): return True
mstate = _evt.get_state()
original_mpos = (mstate.X.abs, mstate.Y.abs)
mpos = self._getMousePos(mstate)
# getting objects under mouse
mobjects = self._logic._getSheet()._getObjectsUnderMouse(True, True, self.mouse_pos)
if _id == ois.MB_Right:
# none any mode
if self.state is GeometryEditMode.ES_None:
# creating point if there is no any objects under mouse
if len(mobjects) is 0:
obj = self._logic.createPoint(mpos)
sheet = self._logic._getSheet()
sheet.addChild(obj)
return True
else:
# get line sections
line = comutils._getFirstObjectTypeFromList(mobjects, [GeometryLineSection, GeometryCircle])
if line is not None:
# create point
point = self._logic.createPoint(original_mpos)
sheet = self._logic._getSheet()
sheet.addChild(point)
# append it into line section
line.addPoint(point, line._calculatePointRelPosition(render_engine.pos2dTo3dIsoPos(original_mpos)))
self.objectInfoPanel.update()
return True
obj = comutils._getFirstObjectTypeFromList(mobjects, [GeometryPoint])
if obj is not None:
self.state = GeometryEditMode.ES_LineCreate
self.__lineSpirit.setBegin(obj)
sheet = self._logic._getSheet()
sheet.sceneNodeChilds.addChild(self.__lineSpirit.sceneNode)
sheet.sceneNodeChilds.addChild(self.__pointSpirit.sceneNode)
self.__lineBegin = obj
self.__pointSpirit.setPosition(render_engine.pos2dTo3dIsoPos(mpos))
self._updateLineSpirits()
self.objectInfoPanel.update()
return True
# on line creation mode finishing line
elif self.state is GeometryEditMode.ES_LineCreate:
obj = comutils._getFirstObjectTypeFromList(mobjects, [GeometryPoint])
sheet = self._logic._getSheet()
if obj is not None:
# creating line
line = self._logic.createLineSection(self.__lineBegin, obj)
sheet.addChild(line)
# removing state
self.state = GeometryEditMode.ES_None
sheet.sceneNodeChilds.removeChild(self.__lineSpirit.sceneNode)
sheet.sceneNodeChilds.removeChild(self.__pointSpirit.sceneNode)
self.__lineBegin = None
elif _id == ois.MB_Left:
# if there is an any object under mouse, then starts moving
if len(mobjects) > 0 and self.state is GeometryEditMode.ES_None:
if self.candidate_object is not None and self.candidate_object._getSelected() and not self._shift:
self._unselectObject(self.candidate_object)
self._next_candidate()
self.active_object = self.candidate_object#comutils._getFirstObjectTypeFromList(mobjects, [GeometryPoint])
if self.active_object is not None:
self.state = GeometryEditMode.ES_Move
self._selectObject(self.active_object)
else:
# selecting first object under mouse
self._selectObject(mobjects[0][1])
return True
elif self.state is GeometryEditMode.ES_CircleCreate:
_point = comutils._getFirstObjectTypeFromList(mobjects, [GeometryPoint])
if _point is not None:
self.active_object.setRadiusPoint(_point)
self.active_object = None
self.state = GeometryEditMode.ES_None
return False
示例3: _onMousePressed
# 需要导入模块: from suit.cf import BaseEditMode [as 别名]
# 或者: from suit.cf.BaseEditMode import _onMousePressed [as 别名]
def _onMousePressed(self, _evt, _id):
"""Event on mouse button pressed
"""
if BaseEditMode._onMousePressed(self, _evt, _id): return True
mstate = _evt.get_state()
mpos = self._getMousePos(mstate)
# getting objects under mouse
mobjects = self._logic._getSheet()._getObjectsUnderMouse(True, True, self.mouse_pos)
if _id == ois.MB_Right:
# none any mode
if self.state is GraphEditMode.ES_None:
# creating point if there is no any objects under mouse
if len(mobjects) is 0:
obj = self._logic.createVertex(mpos)
sheet = self._logic._getSheet()
sheet.addChild(obj)
return True
else:
obj = comutils._getFirstObjectTypeFromList(mobjects, [GraphVertex])
if obj is not None:
self.state = GraphEditMode.ES_LineCreate
self.__lineSpirit.setBegin(obj)
sheet = self._logic._getSheet()
sheet.sceneNodeChilds.addChild(self.__lineSpirit.sceneNode)
sheet.sceneNodeChilds.addChild(self.__pointSpirit.sceneNode)
self.__lineBegin = obj
self.__pointSpirit.setPosition(render_engine.pos2dTo3dIsoPos(mpos))
self._updateLineSpirits()
return True
# on line creation mode finishing line
elif self.state is GraphEditMode.ES_LineCreate:
obj = comutils._getFirstObjectTypeFromList(mobjects, [GraphVertex])
sheet = self._logic._getSheet()
if obj is not None:
# creating line
line = self._logic.createLink(self.__lineBegin, obj)
sheet.addChild(line)
# removing state
self.state = GraphEditMode.ES_None
sheet.sceneNodeChilds.removeChild(self.__lineSpirit.sceneNode)
sheet.sceneNodeChilds.removeChild(self.__pointSpirit.sceneNode)
self.__lineBegin = None
elif _id == ois.MB_Left:
# if there is an any object under mouse, then starts moving
if len(mobjects) > 0 and self.state is GraphEditMode.ES_None:
self.active_object = comutils._getFirstObjectTypeFromList(mobjects, [GraphVertex])
if self.active_object is not None:
self.state = GraphEditMode.ES_Move
self._selectObject(self.active_object)
else:
# selecting first object under mouse
self.active_object = comutils._getFirstObjectTypeFromList(mobjects, [GraphLink])
self._selectObject(mobjects[0][1])
return True
return False