本文整理汇总了Python中suit.cf.BaseEditMode类的典型用法代码示例。如果您正苦于以下问题:Python BaseEditMode类的具体用法?Python BaseEditMode怎么用?Python BaseEditMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BaseEditMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, _logic):
BaseEditMode.__init__(self, _logic, "Geometry edit")
# last scroll position
self.last_scroll_pos = None
# grid align mode
self.grid_align = True
self.mouse_pos = (0, 0)
self.objectInfoPanel = geom_controls.ObjectInfoPanel()
# objects we works with
self.highlighted_obj = None
# current edit state
self.state = GeometryEditMode.ES_None
# current object we worked with
self.active_object = None
# candidate object to be processed with mouse
self.candidate_object = None
# line creation mode
self.__pointSpirit = GeometryPoint()
self.__pointSpirit.setState(Object.OS_Normal)
self.__pointSpirit.setScale(ogre.Vector3(0.5, 0.5, 0.5))
self.__lineSpirit = GeometryLineSection()
self.__lineSpirit.setState(Object.OS_Normal)
self.__lineSpirit.setEnd(self.__pointSpirit)
self.__lineBegin = None
示例2: _unselectObject
def _unselectObject(self, _object):
BaseEditMode._unselectObject(self, _object)
selected = self._logic._getSheet().getSelected()
if len(selected) > 0:
self.objectInfoPanel.setObject(selected[-1])
else:
self.objectInfoPanel.setObject(None)
示例3: _onKeyReleased
def _onKeyReleased(self, _evt):
"""Key released event
"""
BaseEditMode._onKeyReleased(self, _evt)
key = _evt.key
if key == ois.KC_LSHIFT:
self._shift = False
return False
示例4: __init__
def __init__(self, _logic):
BaseEditMode.__init__(self, _logic, "Edit mode")
# mouse objects for line creation mode
self.line_mode_beg = None
self.line_mode_obj = scg_alphabet.createSCgNode('mnode')
self.line_mode_obj.setScale(ogre.Vector3(0.1, 0.1, 0.1))
self.line_mode_obj.setPosition(ogre.Vector3(0, 0, 0))
self.line_mode_line = scg_alphabet.createSCgPair('mpair')
self.line_mode_line.setEnd(self.line_mode_obj)
self.line_mode_line.setState(objects.Object.OS_Normal)
# highlighted object
self.highlighted_obj = None
# widgets
self.type_combo = None
self.content_combo = None
# object we worked on in current state
self.object_active = None
# current editor state
self.state = SCgEditMode.ES_None
# current mouse position
self.mouse_pos = (0, 0)
# visual menu
# self.vis_menu = None
# self._createVisualMenu()
# 3d navigation mode
self.rotX = 0.0
self.rotY = 0.0
self.move = ogre.Vector3(0.0, 0.0, 0.0)
self.moveSpeed = 5.0
self.moveScale = 5.0
self.animationState = None
# tool bar
# self.toolbar = ToolBar()
# self.toolbar.setVisible(False)
# self.toolbar.setEnabled(True)
# for idx in xrange(self.EM_Count):
# button = self.toolbar.appendButton("", "scg_toolbar_icons.png", idx, (32, 32), (0, 0, 256, 32))
# button.setCheckable(True)
# button.setUserData(idx)
# button.eventPush = self._onToolBarButtonPush
#
# self.toolbar.setButtonSize(38)
#contour points
self.contour_points = []
self.contour_lines = []
示例5: __init__
def __init__(self, _logic):
BaseEditMode.__init__(self, _logic)
self.mouse_pos = (0, 0)
# objects we works with
self.highlighted_obj = None
# 3d navigation mode
self.rotX = 0.0
self.rotY = 0.0
self.move = ogre.Vector3(0.0, 0.0, 0.0)
self.moveSpeed = 15.0
self.moveScale = 1.0
self.navigation = False
示例6: delete
def delete(self):
"""Deletion message
"""
BaseEditMode.delete(self)
# self.vis_menu.delete()
self.line_mode_beg = None
self.line_mode_line.delete()
self.line_mode_line = None
self.line_mode_obj.delete()
self.line_mode_obj = None
self.object_active = None
示例7: _onMouseMoved
def _onMouseMoved(self, _evt):
"""Mouse moved notification event
"""
if BaseEditMode._onMouseMoved(self, _evt): return True
mstate = _evt.get_state()
mpos = self._getMousePos(mstate)
self.mouse_pos = (mstate.X.abs, mstate.Y.abs)
if self.state is GeometryEditMode.ES_Move:
self.active_object.setPosition(render_engine.pos2dTo3dIsoPos(mpos))
return True
elif self.state is GeometryEditMode.ES_LineCreate:
self.__pointSpirit.setPosition(render_engine.pos2dTo3dIsoPos(mpos))
self._updateLineSpirits()
self._highlight()
return True
elif self.state is GeometryEditMode.ES_CircleCreate:
radius = self.active_object.getPosition().distance(render_engine.pos2dTo3dIsoPos(mpos))
self.active_object.setRadius(radius)
self._highlight()
return False
示例8: _onMouseReleased
def _onMouseReleased(self, _evt, _id):
"""Mouse button released event
"""
if BaseEditMode._onMouseReleased(self, _evt, _id): return True
if _id == ois.MB_Left and self.navigation:
self.navigation = False
return False
示例9: _onKeyReleased
def _onKeyReleased(self, _evt):
"""Key released event
"""
BaseEditMode._onKeyReleased(self, _evt)
key = _evt.key
if key == ois.KC_LSHIFT:
self._shift = False
elif key == ois.KC_B:
if self.state == SCgEditMode.ES_BusCreate:
sheet = self._logic._getSheet()
render_engine.SceneNode.removeChild(sheet.sceneNodeChilds, self.line_mode_line.sceneNode)
self.line_mode_line.setBegin(None)
self.line_mode_beg = None
self.state = SCgEditMode.ES_None
return False
示例10: __init__
def __init__(self, _logic):
BaseEditMode.__init__(self, _logic, "Graph edit")
# last scroll position
self.last_scroll_pos = None
# grid align mode
self.mouse_pos = (0, 0)
# objects we works with
self.highlighted_obj = None
# current edit state
self.state = GraphEditMode.ES_None
# current object we worked with
self.active_object = None
# line creation mode
self.__pointSpirit = GraphVertex()
self.__pointSpirit.setState(Object.OS_Normal)
self.__pointSpirit.setScale(ogre.Vector3(0.5, 0.5, 0.5))
self.__lineSpirit = GraphLink()
self.__lineSpirit.setState(Object.OS_Normal)
self.__lineSpirit.setEnd(self.__pointSpirit)
self.__lineBegin = None
示例11: __init__
def __init__(self, _logic):
BaseEditMode.__init__(self, _logic, "Edit mode")
# mouse objects for line creation mode
self.line_mode_beg = None
self.line_mode_obj = scg_alphabet.createSCgNode('mnode')
self.line_mode_obj.setScale(ogre.Vector3(0.1, 0.1, 0.1))
self.line_mode_obj.setPosition(ogre.Vector3(0, 0, 0))
self.line_mode_line = scg_alphabet.createSCgPair('mpair')
self.line_mode_line.setEnd(self.line_mode_obj)
self.line_mode_line.setState(objects.Object.OS_Normal)
# highlighted object
self.highlighted_obj = None
# widgets
self.type_combo = None
self.content_combo = None
# object we worked on in current state
self.object_active = None
# current editor state
self.state = SCgEditMode.ES_None
# current mouse position
self.mouse_pos = (0, 0)
# visual menu
# self.vis_menu = None
# self._createVisualMenu()
# 3d navigation mode
self.rotX = 0.0
self.rotY = 0.0
self.move = ogre.Vector3(0.0, 0.0, 0.0)
self.moveSpeed = 5.0
self.moveScale = 5.0
self.animationState = None
示例12: _onMouseMoved
def _onMouseMoved(self, _evt):
"""Mouse moved event
"""
if BaseEditMode._onMouseMoved(self, _evt): return True
mstate = _evt.get_state()
self.mouse_pos = (mstate.X.abs, mstate.Y.abs)
self._highlight()
if self.navigation:
self.rotX = ogre.Degree(-mstate.X.rel * 0.13)
self.rotY = ogre.Degree(-mstate.Y.rel * 0.13)
return False
示例13: _onKeyPressed
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
示例14: _onMouseReleased
def _onMouseReleased(self, _evt, _id):
"""Event on mouse button released
"""
if BaseEditMode._onMouseReleased(self, _evt, _id): return True
mstate = _evt.get_state()
mpos = self._getMousePos(mstate)
if _id == ois.MB_Left:
# moving state finishing
if self.state is GeometryEditMode.ES_Move:
self.state = GeometryEditMode.ES_None
# self._selectObject(self.active_object)
self.active_object = None
return False
示例15: _onMousePressed
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