File: mayavi_plugin.py

package info (click to toggle)
mayavi2 4.8.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 21,892 kB
  • sloc: python: 49,447; javascript: 32,885; makefile: 129; fortran: 60
file content (57 lines) | stat: -rw-r--r-- 1,692 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""The Mayavi plugin.
"""
# Author: Prabhu Ramachandran <prabhu [at] aero . iitb . ac . in>
# Copyright (c) 2008,  Enthought, Inc.
# License: BSD Style.

from traits.api import List
from envisage.api import Plugin, ServiceOffer

# This module's package.
PKG = '.'.join(__name__.split('.')[:-1])
# The mayavi package ID.
ID = 'mayavi'

###############################################################################
# `MayaviPlugin` class.
###############################################################################
class MayaviPlugin(Plugin):

    # Extension point Ids.
    SERVICE_OFFERS = 'envisage.ui.workbench.service_offers'
    PREFERENCES       = 'envisage.preferences'

    # The plugins name.
    name = 'Mayavi plugin'

    # Our ID.
    id = ID

    ###### Contributions to extension points made by this plugin ######

    # Services we contribute.
    service_offers = List(contributes_to=SERVICE_OFFERS)

    # Preferences.
    preferences = List(contributes_to=PREFERENCES)

    def _preferences_default(self):
        """ Trait initializer. """
        return ['pkgfile://%s/preferences/preferences.ini' % ID]


    ######################################################################
    # Private methods.
    def _service_offers_default(self):
        """ Trait initializer. """
        engine_service_offer = ServiceOffer(
            protocol = 'mayavi.core.engine.Engine',
            factory  = PKG + '.envisage_engine.EnvisageEngine'
        )

        script_service_offer = ServiceOffer(
            protocol = 'mayavi.plugins.script.Script',
            factory  = PKG + '.script.Script'
        )
        return [engine_service_offer, script_service_offer]