<commit_before>""" A TVTK scene editor. """

# Author: <NAME> <<EMAIL>>
# Copyright (c) 2005, Enthought, Inc.
# License: BSD Style.


# Enthought library imports.
from enthought.preferences.api import bind_preference
from enthought.pyface.tvtk.scene import Scene
from enthought.pyface.workbench.api import Editor
from enthought.traits.api import Any, Instance, Str, Event


##############################################################################
# Handy functions
def _id_generator():
    """Returns a sequence of numbers for the title of the scene editor
    window."""
    n = 1
    while True:
        yield(n)
        n += 1

_id_generator = _id_generator()


class SceneEditor(Editor):
    """ A TVTK scene editor. """

    #### 'IWorkbenchPart' interface ###########################################
    
    # The scene manager.
    scene_manager = Instance(
        'enthought.tvtk.plugins_e3.scene.scene_manager.SceneManager'
    )
    
    # The TVTK scene object.
    scene = Instance(Scene)

    #### Events #####

    ## FIXME: These are temporary and should be removed once (and if)
    ## Martin adds them to the framework.

    # The editor has been activated.
    activated = Event

    # The editor is being closed.
    closing = Event

    # The editor has been closed.
    closed = Event

    ###########################################################################
    # `object` interface
    ###########################################################################

    def __init__(self, **traits):
        """ Constructor. """
        
        super(SceneEditor, self).__init__(**traits)

        # Create a unique Id.
        self.id = self.name = 'TVTK Scene %d' % (_id_generator.next())        

        return
    
    ###########################################################################
    # 'IWorkbenchPart' interface.
    ###########################################################################

    def create_control(self, parent):
        """ Create the toolkit-specific control that represents the editor. """

        scene = self._create_decorated_scene(parent)
        scene.render()

        # Hold a reference to the scene itself, to make sure it does not get
        # garbage collected (because we only return the scene's 'control' not
        # the scene itself).
        self.scene = scene

        # Add this editor to the plugin's editors.  We do this only here and
        # not at initialization time because the browser plugin listens for
        # this and requires that the scene attribute be set.<commit_msg>- safety checkin of port of scene and browser plugins to Envisage 3<commit_after>""" A TVTK scene editor. """

# Author: <NAME> <<EMAIL>>
# Copyright (c) 2005, Enthought, Inc.
# License: BSD Style.


# Enthought library imports.
from enthought.preferences.api import bind_preference
from enthought.pyface.tvtk.scene import Scene
from enthought.pyface.workbench.api import Editor
from enthought.traits.api import Any, Instance, Str, Event


##############################################################################
# Handy functions
def _id_generator():
    """Returns a sequence of numbers for the title of the scene editor
    window."""
    n = 1
    while True:
        yield(n)
        n += 1

_id_generator = _id_generator()


class SceneEditor(Editor):
    """ A TVTK scene editor. """

    #### 'IWorkbenchPart' interface ###########################################
    
    # The scene manager.
    scene_manager = Instance(
        'enthought.tvtk.plugins_e3.scene.scene_manager.SceneManager'
    )
    
    # The TVTK scene object.
    scene = Instance(Scene)

    #### Events #####

    ## FIXME: These are temporary and should be removed once (and if)
    ## Martin adds them to the framework.

    # The editor has been activated.
    activated = Event

    # The editor is being closed.
    closing = Event

    # The editor has been closed.
    closed = Event

    ###########################################################################
    # `object` interface
    ###########################################################################

    def __init__(self, **traits):
        """ Constructor. """
        
        super(SceneEditor, self).__init__(**traits)

        # Create a unique Id.
        self.id = self.name = 'TVTK Scene %d' % (_id_generator.next())        

        return
    
    ###########################################################################
    # 'IWorkbenchPart' interface.
    ###########################################################################

    def create_control(self, parent):
        """ Create the toolkit-specific control that represents the editor. """

        scene = self._create_decorated_scene(parent)
        scene.render()

        # Hold a reference to the scene itself, to make sure it does not get
        # garbage collected (because we only return the scene's 'control' not
        # the scene itself).
        self.scene = scene

        # Add this editor to the plugin's editors.  We do this only here and
        # not at initialization time because the browser plugin listens for
        # this and requires that the scene attribute be set.
        #
        # fixme: We don't want editor's to have to know about Envisage!
        self.scene_manager = self.window.application.get_service(
            'enthought.tvtk.plugins_e3.scene.scene_manager.SceneManager'
        )
        
{'fraction_non_alphanumeric': 0.2316001464664958, 'fraction_numerical': 0.0029293299157817647, 'mean_word_length': 3.0829596412556053, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5778838', 'n_tokens_mistral': 1416, 'n_tokens_neox': 1323, 'n_words': 463}