def mouseMoveEvent(self, event): if self._glyph.getMaterial().getName( ) == self._selected_material.getName(): pos = getGlyphPosition(self._glyph) screen_pos = self._zinc_view.project(pos[0], pos[1], pos[2]) global_cur_pos = self._zinc_view.unproject(event.x(), -event.y(), screen_pos[2]) global_old_pos = self._zinc_view.unproject( self._previous_mouse_position[0], -self._previous_mouse_position[1], screen_pos[2]) global_pos_diff = sub(global_cur_pos, global_old_pos) n = self._plane.getNormal() proj_n = mult(n, dot(global_pos_diff, n)) new_pos = add(pos, proj_n) scene = self._glyph.getScene() scene.beginChange() plane_centre = calculateCentroid(new_pos, self._plane.getNormal(), self._get_dimension_method()) if plane_centre is not None: self._plane.setRotationPoint(plane_centre) setGlyphPosition(self._glyph, plane_centre) scene.endChange() self._previous_mouse_position = [event.x(), event.y()] else: super(Normal, self).mouseMoveEvent(event)
def mouseReleaseEvent(self, event): scene = self._glyph.getScene() scene.beginChange() if self._glyph.getMaterial().getName() == self._selected_material.getName(): point_on_plane = getGlyphPosition(self._glyph) self._plane.setRotationPoint(point_on_plane) super(Orientation, self).mouseReleaseEvent(event) scene.endChange() self.setUndoRedoCommand('Plane Rotation')
def mouseReleaseEvent(self, event): scene = self._glyph.getScene() scene.beginChange() if self._glyph.getMaterial().getName( ) == self._selected_material.getName(): point_on_plane = getGlyphPosition(self._glyph) self._plane.setRotationPoint(point_on_plane) super(Orientation, self).mouseReleaseEvent(event) scene.endChange() self.setUndoRedoCommand('Plane Rotation')
def mouseReleaseEvent(self, event): scene = self._glyph.getScene() scene.beginChange() set_undo_redo_command = False if self._glyph.getMaterial().getName() == self._selected_material.getName(): point_on_plane = getGlyphPosition(self._glyph) self._plane.setRotationPoint(point_on_plane) set_undo_redo_command = True super(Normal, self).mouseReleaseEvent(event) scene.endChange() if set_undo_redo_command: self.setUndoRedoCommand('Plane Normal')
def mouseReleaseEvent(self, event): scene = self._glyph.getScene() scene.beginChange() set_undo_redo_command = False if self._glyph.getMaterial().getName( ) == self._selected_material.getName(): point_on_plane = getGlyphPosition(self._glyph) self._plane.setRotationPoint(point_on_plane) set_undo_redo_command = True super(Normal, self).mouseReleaseEvent(event) scene.endChange() if set_undo_redo_command: self.setUndoRedoCommand('Plane Normal')
def mouseMoveEvent(self, event): if self._glyph.getMaterial().getName() == self._selected_material.getName(): pos = getGlyphPosition(self._glyph) screen_pos = self._zinc_view.project(pos[0], pos[1], pos[2]) global_cur_pos = self._zinc_view.unproject(event.x(), -event.y(), screen_pos[2]) global_old_pos = self._zinc_view.unproject(self._previous_mouse_position[0], -self._previous_mouse_position[1], screen_pos[2]) global_pos_diff = sub(global_cur_pos, global_old_pos) n = self._plane.getNormal() proj_n = mult(n, dot(global_pos_diff, n)) new_pos = add(pos, proj_n) scene = self._glyph.getScene() scene.beginChange() plane_centre = calculateCentroid(new_pos, self._plane.getNormal(), self._get_dimension_method()) if plane_centre is not None: self._plane.setRotationPoint(plane_centre) setGlyphPosition(self._glyph, plane_centre) scene.endChange() self._previous_mouse_position = [event.x(), event.y()] else: super(Normal, self).mouseMoveEvent(event)