예제 #1
0
    def init_window(self):
        """ Method to initialize the main window.
        """
        # First set some meta information
        self.setApplicationName(self._application_name)
        self.setOrganizationName(self._organisation_name)
        self.setApplicationVersion(self._version)

        # Get the user interface description from capsul resources
        ui_file = os.path.join(os.path.dirname(__file__),
                               "activation_inspector.ui")
        #ui_file = os.path.join(resources.__path__[0], "activation_inspector.ui")

        # Create and show the activation/pipeline/controller windows
        self.pipeline_window = PipelineDeveloperView(self.pipeline,
                                                     show_sub_pipelines=True)
        self.controller_window = ScrollControllerWidget(self.pipeline,
                                                        live=True)
        self.activation_window = ActivationInspector(
            self.pipeline,
            ui_file,
            self.record_file,
            developper_view=self.pipeline_window)
        self.pipeline_window.show()
        self.activation_window.show()
        self.controller_window.show()

        return True
예제 #2
0
class ActivationInspectorApp(Application):
    """ ActivationInspector Application.
    While developing a pipeline, nodes are connected through links. Nodes will be automatically activated or disabled depending on their connections (a mandatory link to a disabled node will disable the current one).
    You will often wonder why a node will not be activated. This tool helps to determine when and why by "playing" activation rules sequences step-by-step and displaying nodes which activate or deactivate at each step.
    """
    # Load some meta information
    from capsul.info import __version__ as _version
    from capsul.info import NAME as _application_name
    from capsul.info import ORGANISATION as _organisation_name

    def __init__(self, pipeline_path, record_file=None, *args, **kwargs):
        """ Method to initialize the ActivationInspectorApp class.

        Parameters
        ----------
        pipeline_path: str (mandatory)
            the name of the pipeline we want to load.
        record_file: str (optional)
            a file where the pipeline activation steps are stored.
        """
        # Inhetritance
        super(ActivationInspectorApp, self).__init__(*args, **kwargs)

        # Load the pipeline
        self.pipeline = get_process_instance(pipeline_path)

        # Initialize the application
        self.record_file = record_file
        self.window = None
        self.init_window()

    def init_window(self):
        """ Method to initialize the main window.
        """
        # First set some meta information
        self.setApplicationName(self._application_name)
        self.setOrganizationName(self._organisation_name)
        self.setApplicationVersion(self._version)

        # Get the user interface description from capsul resources
        ui_file = os.path.join(os.path.dirname(__file__),
                               "activation_inspector.ui")
        #ui_file = os.path.join(resources.__path__[0], "activation_inspector.ui")

        # Create and show the activation/pipeline/controller windows
        self.pipeline_window = PipelineDeveloperView(self.pipeline,
                                                     show_sub_pipelines=True)
        self.controller_window = ScrollControllerWidget(self.pipeline,
                                                        live=True)
        self.activation_window = ActivationInspector(
            self.pipeline,
            ui_file,
            self.record_file,
            developper_view=self.pipeline_window)
        self.pipeline_window.show()
        self.activation_window.show()
        self.controller_window.show()

        return True
예제 #3
0
class ActivationInspectorApp(Application):
    """ ActiovationInspector Application.
    """
    # Load some meta informations
    from capsul.info import __version__ as _version
    from capsul.info import NAME as _application_name
    from capsul.info import ORGANISATION as _organisation_name

    def __init__(self, pipeline_path, record_file=None, *args, **kwargs):
        """ Method to initialize the ActivationInspectorApp class.

        Parameters
        ----------
        pipeline_path: str (mandatory)
            the name of the pipeline we want to load.
        record_file: str (optional)
            a file where the pipeline activation steps are stored.
        """
        # Inhetritance
        super(ActivationInspectorApp, self).__init__(*args, **kwargs)

        # Load the pipeline
        self.pipeline = get_process_instance(pipeline_path)

        # Initialize the application
        self.record_file = record_file
        self.window = None
        self.init_window()

    def init_window(self):
        """ Method to initialize the main window.
        """
        # First set some meta informations
        self.setApplicationName(self._application_name)
        self.setOrganizationName(self._organisation_name)
        self.setApplicationVersion(self._version)

        # Get the user interface description from capsul resources
        ui_file = os.path.join(os.path.dirname(__file__),
                               "activation_inspector.ui")
        #ui_file = os.path.join(resources.__path__[0], "activation_inspector.ui")

        # Create and show the activation/pipeline/controller windows
        self.pipeline_window = PipelineDevelopperView(self.pipeline,
                                                      show_sub_pipelines=True)
        self.controller_window = ScrollControllerWidget(self.pipeline,
                                                        live=True)
        self.activation_window = ActivationInspector(
            self.pipeline,
            ui_file,
            self.record_file,
            developper_view=self.pipeline_window)
        self.pipeline_window.show()
        self.activation_window.show()
        self.controller_window.show()

        return True
예제 #4
0
파일: fsl.py 프로젝트: servoz/capsul
def edition_widget(engine, environment):
    ''' Edition GUI for FSL config - see
    :class:`~capsul.qt_gui.widgets.settings_editor.SettingsEditor`
    '''
    from soma.qt_gui.controller_widget import ScrollControllerWidget
    from soma.controller import Controller
    import types
    import traits.api as traits

    def validate_config(widget):
        controller = widget.controller_widget.controller
        with widget.engine.settings as session:
            conf = session.config('fsl', widget.environment)
            values = {'config_id': 'fsl'}
            for k in ('directory', 'config', 'prefix'):
                value = getattr(controller, k)
                if value is traits.Undefined:
                    value = None
                values[k] = value
            if conf is None:
                session.new_config('fsl', widget.environment, values)
            else:
                for k, value in values.items():
                    if k == 'config_id':
                        continue
                    setattr(conf, k, values[k])

    controller = Controller()

    controller.add_trait(
        'directory',
        traits.Directory(traits.Undefined,
                         desc='Directory where FSL is installed'))
    controller.add_trait(
        'config',
        traits.File(traits.Undefined,
                    output=False,
                    desc='Parameter to specify the fsl.sh path'))
    controller.add_trait(
        'prefix',
        traits.String(traits.Undefined, desc='Prefix to add to FSL commands'))

    conf = engine.settings.select_configurations(environment, {'fsl': 'any'})
    if conf:
        fconf = conf.get('capsul.engine.module.fsl', {})
        controller.directory = fconf.get('directory', traits.Undefined)
        controller.config = fconf.get('config', traits.Undefined)
        controller.prefix = fconf.get('prefix', traits.Undefined)

    widget = ScrollControllerWidget(controller, live=True)
    widget.engine = engine
    widget.environment = environment
    widget.accept = types.MethodType(validate_config, widget)

    return widget
예제 #5
0
class ActivationInspectorApp(Application):
    """ ActiovationInspector Application.
    """
    # Load some meta informations
    from capsul.info import __version__ as _version
    from capsul.info import NAME as _application_name
    from capsul.info import ORGANISATION as _organisation_name

    def __init__(self, pipeline_path, record_file=None, *args, **kwargs):
        """ Method to initialize the ActivationInspectorApp class.

        Parameters
        ----------
        pipeline_path: str (mandatory)
            the name of the pipeline we want to load.
        record_file: str (optional)
            a file where the pipeline activation steps are stored.
        """
        # Inhetritance
        super(ActivationInspectorApp, self).__init__(*args, **kwargs)

        # Load the pipeline
        self.pipeline = get_process_instance(pipeline_path)

        # Initialize the application
        self.record_file = record_file
        self.window = None
        self.init_window()

    def init_window(self):
        """ Method to initialize the main window.
        """
        # First set some meta informations
        self.setApplicationName(self._application_name)
        self.setOrganizationName(self._organisation_name)
        self.setApplicationVersion(self._version)

        # Get the user interface description from capsul resources
        ui_file = os.path.join(
            os.path.dirname(__file__), "activation_inspector.ui")
        #ui_file = os.path.join(resources.__path__[0], "activation_inspector.ui")

        # Create and show the activation/pipeline/controller windows
        self.pipeline_window = PipelineDevelopperView(self.pipeline)
        self.controller_window = ScrollControllerWidget(self.pipeline,live=True)
        self.activation_window = ActivationInspector(
            self.pipeline, ui_file, self.record_file,
            developper_view=self.pipeline_window)
        self.pipeline_window.show()
        self.activation_window.show()
        self.controller_window.show()

        return True
예제 #6
0
파일: axon.py 프로젝트: servoz/capsul
def edition_widget(engine, environment):
    ''' Edition GUI for axon config - see
    :class:`~capsul.qt_gui.widgets.settings_editor.SettingsEditor`
    '''
    from soma.qt_gui.controller_widget import ScrollControllerWidget
    from soma.controller import Controller
    import types
    import traits.api as traits

    def validate_config(widget):
        controller = widget.controller_widget.controller
        with widget.engine.settings as session:
            conf = session.config('axon', widget.environment)
            values = {'config_id': 'axon', 'user_level': controller.user_level}
            if controller.shared_directory in (None, traits.Undefined, ''):
                values['shared_directory'] = None
            else:
                values['shared_directory'] = controller.shared_directory
            if conf is None:
                session.new_config('axon', widget.environment, values)
            else:
                for k in ('shared_directory', 'user_level'):
                    setattr(conf, k, values[k])

    controller = Controller()
    controller.add_trait(
        'shared_directory',
        traits.Directory(desc='Directory where BrainVisa '
                         'shared data is installed'))
    controller.add_trait(
        'user_level',
        traits.Int(desc='0: basic, 1: advanced, 2: expert, or more. '
                   'used to display or hide some advanced features or '
                   'process parameters that would be confusing to a novice '
                   'user'))

    conf = engine.settings.select_configurations(environment, {'axon': 'any'})
    if conf:
        controller.shared_directory = conf.get('capsul.engine.module.axon',
                                               {}).get('shared_directory',
                                                       traits.Undefined)
        controller.user_level = conf.get('capsul.engine.module.axon',
                                         {}).get('user_level', 0)

    widget = ScrollControllerWidget(controller, live=True)
    widget.engine = engine
    widget.environment = environment
    widget.accept = types.MethodType(validate_config, widget)

    return widget
예제 #7
0
파일: python.py 프로젝트: servoz/capsul
def edition_widget(engine, environment):
    ''' Edition GUI for python config - see
    :class:`~capsul.qt_gui.widgets.settings_editor.SettingsEditor`
    '''
    from soma.qt_gui.qt_backend import Qt
    from soma.qt_gui.controller_widget import ScrollControllerWidget
    from soma.controller import Controller
    import types
    import traits.api as traits

    def validate_config(widget):
        controller = widget.controller_widget.controller
        with widget.engine.settings as session:
            conf = session.config('python', widget.environment)
            values = {'config_id': 'python', 'path': controller.path}
            if controller.executable in (None, traits.Undefined, ''):
                values['executable'] = None
            else:
                values['executable'] = controller.executable
            if conf is None:
                session.new_config('python', widget.environment, values)
            else:
                for k in ('path', 'executable'):
                    setattr(conf, k, values[k])

    controller = Controller()
    controller.add_trait('executable',
                         traits.Str(desc='Full path of the python executable'))
    controller.add_trait(
        'path',
        traits.List(traits.Directory(), [],
                    desc='paths to prepend to sys.path'))

    conf = engine.settings.select_configurations(environment,
                                                 {'python': 'any'})
    if conf:
        controller.executable = conf.get('capsul.engine.module.python',
                                         {}).get('executable',
                                                 traits.Undefined)
        controller.path = conf.get('capsul.engine.module.python',
                                   {}).get('path', [])

    widget = ScrollControllerWidget(controller, live=True)
    widget.engine = engine
    widget.environment = environment
    widget.accept = types.MethodType(validate_config, widget)

    return widget
예제 #8
0
    def onQualityControlClicked(self):
        """ Event to show / hide the board dock widget.
        """
        # Create and show board dock widget
        if self.ui.actionQualityControl.isChecked():

            # Create the board widget associated to the pipeline controller
            # Create on the fly in order to get the last status
            # ToDo: add callbacks
            if self.pipeline is not None:
                # board_widget = BoardWidget(
                #     self.pipeline, parent=self.ui.dockWidgetParameters,
                #     name="board")
                board_widget = ScrollControllerWidget(
                    self.pipeline,
                    name="outputs",
                    live=True,
                    hide_labels=False,
                    select_controls="outputs",
                    disable_controller_widget=True)
                #board_widget.setEnabled(False)
                self.ui.dockWidgetBoard.setWidget(board_widget)

            # Show the board widget
            self.ui.dockWidgetBoard.show()

        # Hide board dock widget
        else:
            self.ui.dockWidgetBoard.hide()
예제 #9
0
    def onLoadSubPipelineClicked(self, name, sub_pipeline, modifiers):
        """ Event to load and display a sub pipeline.
        """
        # Store the pipeline instance in class parameters
        self.pipeline = self.pipeline.nodes[name].process

        # Create the controller widget associated to the sub pipeline
        # controller: if the sub pipeline is a ProcessIteration, disable
        # the correspondind controller widget since this pipeline is generated
        # on the fly an is not directly synchronized with the rest of the
        # pipeline.
        is_iterative_pipeline = False
        if isinstance(self.pipeline, ProcessIteration):
            is_iterative_pipeline = True
        pipeline_widget = ScrollControllerWidget(
            self.pipeline,
            live=True,
            select_controls="inputs",
            disable_controller_widget=is_iterative_pipeline)
        self.ui.dockWidgetParameters.setWidget(pipeline_widget)

        # Store the sub pipeline instance
        self.pipelines[self.pipeline.name] = (self.pipeline, pipeline_widget)

        # Create the widget
        widget = PipelineDevelopperView(self.pipeline)
        self._insert_widget_in_tab(widget)

        # Connect the subpipeline clicked signal to the
        # onLoadSubPipelineClicked slot
        widget.subpipeline_clicked.connect(self.onLoadSubPipelineClicked)
예제 #10
0
파일: afni.py 프로젝트: servoz/capsul
def edition_widget(engine, environment):
    ''' Edition GUI for AFNI config - see
    :class:`~capsul.qt_gui.widgets.settings_editor.SettingsEditor`
    '''
    from soma.qt_gui.controller_widget import ScrollControllerWidget
    from soma.controller import Controller
    import types
    import traits.api as traits

    def validate_config(widget):
        controller = widget.controller_widget.controller
        with widget.engine.settings as session:
            conf = session.config('afni', widget.environment)
            values = {'config_id': 'afni'}
            for k in ['directory']:
                value = getattr(controller, k)
                if value is traits.Undefined:
                    value = None
                values[k] = value
            if conf is None:
                session.new_config('afni', widget.environment, values)
            else:
                for k, value in values.items():
                    if k == 'config_id':
                        continue
                    setattr(conf, k, values[k])

    controller = Controller()

    controller.add_trait(
        'directory',
        traits.Directory(traits.Undefined,
                         desc='Directory where AFNI is installed'))

    conf = engine.settings.select_configurations(environment, {'afni': 'any'})
    if conf:
        fconf = conf.get('capsul.engine.module.afni', {})
        controller.directory = fconf.get('directory', traits.Undefined)

    widget = ScrollControllerWidget(controller, live=True)
    widget.engine = engine
    widget.environment = environment
    widget.accept = types.MethodType(validate_config, widget)

    return widget
예제 #11
0
    def onLoadClicked(self):
        """ Event to load and display a pipeline.
        """
        # Get the pipeline instance from its string description
        item = self.ui.menu_treectrl.currentItem()
        description_list = [
            str(x) for x in [item.text(1), item.text(0)] if x != ""
        ]
        process_description = ".".join(description_list)
        self.pipeline = get_process_instance(process_description)

        # Create the controller widget associated to the pipeline
        # controller
        pipeline_widget = ScrollControllerWidget(self.pipeline,
                                                 live=True,
                                                 select_controls="inputs")
        self.ui.dockWidgetParameters.setWidget(pipeline_widget)

        # Add observer to refresh the run button
        controller_widget = pipeline_widget.controller_widget
        for control_name, control \
                in six.iteritems(controller_widget._controls):

            # Unpack the control item
            trait, control_class, control_instance, control_label = control

            # Add the new callback
            control_class.add_callback(self.onRunStatus, control_instance)

        # Refresh manually the run button status the first time
        self.onRunStatus()

        # Store the pipeline documentation root path
        self.path_to_pipeline_doc[self.pipeline.id] = item.text(2)

        # Store the pipeline instance
        self.pipelines[self.pipeline.name] = (self.pipeline, pipeline_widget)

        # Create the widget
        widget = PipelineDevelopperView(self.pipeline)
        self._insert_widget_in_tab(widget)

        # Connect the subpipeline clicked signal to the
        # onLoadSubPipelineClicked slot
        widget.subpipeline_clicked.connect(self.onLoadSubPipelineClicked)
예제 #12
0
    def init_window(self):
        """ Method to initialize the main window.
        """
        # First set some meta informations
        self.setApplicationName(self._application_name)
        self.setOrganizationName(self._organisation_name)
        self.setApplicationVersion(self._version)

        # Get the user interface description from capsul resources
        ui_file = os.path.join(
            os.path.dirname(__file__), "activation_inspector.ui")
        #ui_file = os.path.join(resources.__path__[0], "activation_inspector.ui")

        # Create and show the activation/pipeline/controller windows
        self.pipeline_window = PipelineDevelopperView(self.pipeline)
        self.controller_window = ScrollControllerWidget(self.pipeline,live=True)
        self.activation_window = ActivationInspector(
            self.pipeline, ui_file, self.record_file,
            developper_view=self.pipeline_window)
        self.pipeline_window.show()
        self.activation_window.show()
        self.controller_window.show()

        return True
예제 #13
0
파일: test.py 프로젝트: populse/soma-base
    # Set the logging level
    logging.basicConfig(level=logging.INFO)

    # Create a qt applicaction
    app = QtGui.QApplication(sys.argv)

    # Create the controller we want to parametrized
    controller = TestControls()

    # Set some values to the controller parameters
    controller.s = ""
    controller.f = 10.2

    # Create to controller widget that are synchronized on the fly
    widget1 = ScrollControllerWidget(controller, live=True)
    widget2 = ControllerWidget(controller, live=True)
    widget1.show()
    widget2.show()

    # Check if the controller widget is valid before edition
    print("Controller widget valid before edition: ", end=' ')
    print(widget1.controller_widget.is_valid())

    # Start the qt loop
    app.exec_()

    # Check if the controller widget is valid after edition
    print("Controller widget valid after edition: ", end=' ')
    print(widget1.controller_widget.is_valid())
예제 #14
0
    def __init__(self,
                 attributed_process,
                 enable_attr_from_filename=False,
                 enable_load_buttons=False):
        """
        Parameters
        ----------
        attributed_process: Process instance
            process with attributes to be displayed
        enable_attr_from_filename: bool (optional)
            if enabled, it will be possible to specify an input filename to
            build attributes from
        """
        super(AttributedProcessWidget, self).__init__()
        self.setLayout(QtGui.QVBoxLayout())
        self.attributed_process = attributed_process
        self._show_completion = False

        process = attributed_process
        completion_engine = getattr(process, 'completion_engine', None)

        if completion_engine is not None:
            splitter = QtGui.QSplitter(QtCore.Qt.Vertical)
            self.layout().addWidget(splitter)
            spl_up = QtGui.QWidget()
            spl_up.setLayout(QtGui.QVBoxLayout())
            splitter.addWidget(spl_up)
            spl_down = QtGui.QWidget()
            spl_down.setLayout(QtGui.QVBoxLayout())
            splitter.addWidget(spl_down)
        else:
            spl_up = self
            spl_down = self

        if enable_attr_from_filename and completion_engine is not None:
            c = Controller()
            c.add_trait('attributes_from_input_filename', File(optional=True))
            cw = ControllerWidget(c, live=True)
            spl_up.layout().addWidget(cw)
            self.input_filename_controller = c
            c.on_trait_change(self.on_input_filename_changed,
                              'attributes_from_input_filename',
                              dispatch='ui')
            cw.setSizePolicy(QtGui.QSizePolicy.Expanding,
                             QtGui.QSizePolicy.Fixed)

        # groupbox area to show attributs
        attrib_widget = QtGui.QGroupBox('Attributes:')
        attrib_widget.setAlignment(QtCore.Qt.AlignLeft)
        attrib_widget.setLayout(QtGui.QVBoxLayout())
        self.attrib_widget = attrib_widget
        spl_up.layout().addWidget(attrib_widget)
        attrib_widget.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                    QtGui.QSizePolicy.Preferred)

        hlay = QtGui.QHBoxLayout()
        spl_up.layout().addLayout(hlay)
        # CheckBox to completion rules or not
        self.checkbox_fom = QtGui.QCheckBox('Follow completion rules')
        self.checkbox_fom.setChecked(True)
        self.checkbox_fom.stateChanged.connect(self.on_use_fom_change)
        hlay.addWidget(self.checkbox_fom)

        # Button Show/Hide completion
        self.btn_show_completion = QtGui.QCheckBox('Show completion')
        self.btn_show_completion.setSizePolicy(QtGui.QSizePolicy.Fixed,
                                               QtGui.QSizePolicy.Fixed)
        hlay.addWidget(self.btn_show_completion)
        self.btn_show_completion.stateChanged.connect(self.on_show_completion)

        # groupbox area to show completion
        param_widget = QtGui.QGroupBox('Parameters:')
        param_widget.setAlignment(QtCore.Qt.AlignLeft)
        spl_down.layout().addWidget(param_widget)
        param_widget.setLayout(QtGui.QVBoxLayout())
        param_widget.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                   QtGui.QSizePolicy.Expanding)

        # Create controller widget for process and object_attribute
        self.controller_widget = ScrollControllerWidget(process,
                                                        live=True,
                                                        parent=param_widget)

        if completion_engine is not None:
            self.controller_widget2 = ScrollControllerWidget(
                completion_engine.get_attribute_values(),
                live=True,
                parent=attrib_widget)
            completion_engine.get_attribute_values().on_trait_change(
                completion_engine.attributes_changed, 'anytrait')
        else:
            self.controller_widget2 = ScrollControllerWidget(Controller())

        # Set controller of attributs and controller of process for each
        # corresponding area
        param_widget.layout().addWidget(self.controller_widget)
        attrib_widget.layout().addWidget(self.controller_widget2)

        if enable_load_buttons and completion_engine is not None:
            io_lay = QtGui.QHBoxLayout()
            self.layout().addLayout(io_lay)
            self.btn_load_json = QtGui.QPushButton('Load attributes')
            io_lay.addWidget(self.btn_load_json)
            self.btn_load_json.clicked.connect(self.on_btn_load_json)
            self.btn_save_json = QtGui.QPushButton('Save attributes')
            io_lay.addWidget(self.btn_save_json)
            self.btn_save_json.clicked.connect(self.on_btn_save_json)

        if completion_engine is None:
            attrib_widget.hide()
            self.checkbox_fom.hide()
            self.btn_show_completion.hide()
            self.show_completion(True)  # hide file parts
        else:
            self.show_completion(False)  # hide file parts

        if completion_engine is not None:
            completion_engine.on_trait_change(
                self._completion_progress_changed,
                'completion_progress',
                dispatch='ui')
예제 #15
0
    def edit_elements(controller_widget, control_instance, edit_button):
        """ Callback to view/edit a 'ListControlWidget'.

        Parameters
        ----------
        control_instance: QFrame (mandatory)
            the list widget item
        edit_button: QToolButton
            the signal sender
        """
        controller_widget = get_ref(controller_widget)
        widget = QtGui.QDialog(controller_widget)
        widget.setModal(True)
        layout = QtGui.QVBoxLayout()
        widget.setLayout(layout)
        #hlayout = QtGui.QHBoxLayout()
        #layout.addLayout(hlayout)

        temp_controller = Controller()
        trait = control_instance.trait

        temp_controller.add_trait(control_instance.trait_name, trait)
        if temp_controller.trait(control_instance.trait_name).groups \
                is not None:
            temp_controller.trait(control_instance.trait_name).groups = None

        value = getattr(controller_widget.controller,
                        control_instance.trait_name)

        try:
            setattr(temp_controller, control_instance.trait_name, value)
        except Exception:
            # invalid value - don't prevent using the GUI
            pass
        control_types = dict(controller_widget._defined_controls)
        control_types['List'] = ListControlWidget
        control_types['List_File'] = ListControlWidget
        temp_controller_widget = ScrollControllerWidget(
            temp_controller,
            live=True,
            override_control_types=control_types,
            user_data=control_instance.user_data)

        layout.addWidget(temp_controller_widget)

        hlayout2 = QtGui.QHBoxLayout()
        layout.addLayout(hlayout2)
        hlayout2.addStretch(1)
        ok = QtGui.QPushButton('OK')
        cancel = QtGui.QPushButton('Cancel')
        hlayout2.addWidget(ok)
        hlayout2.addWidget(cancel)

        ok.pressed.connect(widget.accept)
        cancel.pressed.connect(widget.reject)

        if widget.exec_():

            ctrl = temp_controller_widget.controller_widget._controls.get(
                control_instance.trait_name)[None]
            ListControlWidget.validate_all_values(
                temp_controller_widget.controller_widget, ctrl[2])
            new_trait_value = getattr(temp_controller,
                                      control_instance.trait_name)

            setattr(controller_widget.controller, control_instance.trait_name,
                    new_trait_value)

        del temp_controller_widget
예제 #16
0
    def __init__(self, pipeline_menu, ui_file, default_study_config=None):
        """ Method to initialize the Capsul main window class.

        Parameters
        ----------
        pipeline_menu: hierachic dict
            each key is a sub module of the module. Leafs contain a list with
            the url to the documentation.
        ui_file: str (mandatory)
            a filename containing the user interface description
        default_study_config: ordered dict (madatory)
            some parameters for the study configuration
        """
        # Inheritance: load user interface window
        MyQUiLoader.__init__(self, ui_file)

        # Class parameters
        self.pipeline_menu = pipeline_menu
        self.pipelines = {}
        self.pipeline = None
        self.path_to_pipeline_doc = {}

        # Define dynamic controls
        self.controls = {
            QtGui.QAction: [
                "actionHelp", "actionQuit", "actionBrowse", "actionLoad",
                "actionChangeView", "actionParameters", "actionRun",
                "actionStudyConfig", "actionQualityControl"
            ],
            QtGui.QTabWidget: [
                "display",
            ],
            QtGui.QDockWidget: [
                "dockWidgetBrowse", "dockWidgetParameters",
                "dockWidgetStudyConfig", "dockWidgetBoard"
            ],
            QtGui.QWidget: [
                "dock_browse", "dock_parameters", "dock_study_config",
                "dock_board"
            ],
            QtGui.QTreeWidget: [
                "menu_treectrl",
            ],
            QtGui.QLineEdit: [
                "search",
            ],
        }

        # Add ui class parameter with the dynamic controls and initialize
        # default values
        self.add_controls_to_ui()
        self.ui.display.setTabsClosable(True)

        # Create the study configuration
        self.study_config = StudyConfig(default_study_config)

        # Create the controller widget associated to the study
        # configuration controller
        self.study_config_widget = ScrollControllerWidget(self.study_config,
                                                          live=True)
        self.ui.dockWidgetStudyConfig.setWidget(self.study_config_widget)

        # Create the pipeline menu
        fill_treectrl(self.ui.menu_treectrl, self.pipeline_menu)

        # Signal for window interface
        self.ui.actionHelp.triggered.connect(self.onHelpClicked)
        self.ui.actionChangeView.triggered.connect(self.onChangeViewClicked)

        # Signal for tab widget
        self.ui.display.currentChanged.connect(self.onCurrentTabChanged)
        self.ui.display.tabCloseRequested.connect(self.onCloseTabClicked)

        # Signal for dock widget
        self.ui.actionBrowse.triggered.connect(self.onBrowseClicked)
        self.ui.actionParameters.triggered.connect(self.onParametersClicked)
        self.ui.actionStudyConfig.triggered.connect(self.onStudyConfigClicked)
        self.ui.actionQualityControl.triggered.connect(
            self.onQualityControlClicked)

        # Initialize properly the visibility of each dock widget
        self.onBrowseClicked()
        self.onParametersClicked()
        self.onStudyConfigClicked()
        self.onQualityControlClicked()

        # Signal for the pipeline creation
        self.ui.search.textChanged.connect(self.onSearchClicked)
        self.ui.menu_treectrl.currentItemChanged.connect(
            self.onTreeSelectionChanged)
        self.ui.actionLoad.triggered.connect(self.onLoadClicked)

        # Signal for the execution
        self.ui.actionRun.triggered.connect(self.onRunClicked)
예제 #17
0
def edition_widget(engine, environment):
    ''' Edition GUI for FOM config - see
    :class:`~capsul.qt_gui.widgets.settings_editor.SettingsEditor`
    '''
    from soma.qt_gui.controller_widget import ScrollControllerWidget
    from soma.controller import Controller
    import types

    def validate_config(widget):
        controller = widget.controller_widget.controller
        with widget.engine.settings as session:
            conf = session.config('fom', widget.environment)
            values = {'config_id': 'fom'}
            for k in ('input_fom', 'output_fom', 'shared_fom',
                      'volumes_format', 'meshes_format', 'auto_fom',
                      'fom_path', 'input_directory', 'output_directory'):
                value = getattr(controller, k)
                if value is traits.Undefined:
                    if k in ('fom_path', ):
                        value = []
                    else:
                        value = None
                values[k] = value
            if conf is None:
                session.new_config('fom', widget.environment, values)
            else:
                for k, value in values.items():
                    if k == 'config_id':
                        continue
                    setattr(conf, k, values[k])

    controller = Controller()

    controller.add_trait(
        'input_fom',
        traits.Str(traits.Undefined, output=False, desc='input FOM'))
    controller.add_trait(
        'output_fom',
        traits.Str(traits.Undefined, output=False, desc='output FOM'))
    controller.add_trait(
        'shared_fom',
        traits.Str(traits.Undefined, output=False, desc='shared data FOM'))
    controller.add_trait(
        'volumes_format',
        traits.Str(traits.Undefined,
                   output=False,
                   desc='Format used for volumes'))
    controller.add_trait(
        'meshes_format',
        traits.Str(traits.Undefined,
                   output=False,
                   desc='Format used for meshes'))
    controller.add_trait(
        'auto_fom',
        traits.Bool(
            True,
            output=False,
            desc='Look in all FOMs when a process is not found (in '
            'addition to the standard share/foms). Note that auto_fom '
            'looks for the first FOM matching the process to get '
            'completion for, and does not handle ambiguities. Moreover '
            'it brings an overhead (typically 6-7 seconds) the first '
            'time it is used since it has to parse all available FOMs.'))
    controller.add_trait(
        'fom_path',
        traits.List(
            traits.Directory(output=False),
            desc='list of additional directories where to look for FOMs'))
    # FIXME: until directories are included in another config module
    controller.add_trait(
        'input_directory',
        traits.Directory(traits.Undefined,
                         output=False,
                         desc='input study data directory'))
    controller.add_trait(
        'output_directory',
        traits.Directory(traits.Undefined,
                         output=False,
                         desc='output study data directory'))

    conf = engine.settings.select_configurations(environment, {'fom': 'any'})
    if conf:
        fconf = conf.get('capsul.engine.module.fom', {})
        controller.input_fom = fconf.get('input_fom', traits.Undefined)
        controller.output_fom = fconf.get('output_fom', traits.Undefined)
        controller.shared_fom = fconf.get('shared_fom', traits.Undefined)
        controller.volumes_format = fconf.get('volumes_format',
                                              traits.Undefined)
        controller.meshes_format = fconf.get('meshes_format', traits.Undefined)
        controller.auto_fom = fconf.get('auto_fom', traits.Undefined)
        controller.fom_path = fconf.get('fom_path', traits.Undefined)
        controller.input_directory = fconf.get('input_directory',
                                               traits.Undefined)
        controller.output_directory = fconf.get('output_directory',
                                                traits.Undefined)

    widget = ScrollControllerWidget(controller, live=True)
    widget.engine = engine
    widget.environment = environment
    widget.accept = types.MethodType(validate_config, widget)

    return widget
예제 #18
0
def edition_widget(engine, environment):
    ''' Edition GUI for attributes config - see
    :class:`~capsul.qt_gui.widgets.settings_editor.SettingsEditor`
    '''
    from soma.qt_gui.controller_widget import ScrollControllerWidget
    from soma.controller import Controller
    import types
    import traits.api as traits

    def validate_config(widget):
        controller = widget.controller_widget.controller
        with widget.engine.settings as session:
            conf = session.config('attributes', widget.environment)
            values = {'config_id': 'attributes'}
            values['attributes_schema_paths'] \
                = controller.attributes_schema_paths
            values['attributes_schemas'] = controller.attributes_schemas
            values['process_completion'] = controller.process_completion
            if controller.process_completion is traits.Undefined:
                values['process_completion'] = None
            values['path_completion'] = controller.path_completion
            if controller.path_completion is traits.Undefined:
                values['path_completion'] = None
            if conf is None:
                session.new_config('attributes', widget.environment, values)
            else:
                for k in ('attributes_schema_paths', 'attributes_schemas',
                          'process_completion', 'path_completion'):
                    setattr(conf, k, values[k])

    controller = Controller()
    controller.add_trait(
        'attributes_schema_paths',
        traits.List(traits.Str(), desc='attributes shchemas modules names'))
    controller.add_trait(
        'attributes_schemas',
        traits.DictStrStr(desc='attributes shchemas names'))
    controller.add_trait(
        'process_completion',
        traits.Str(desc='process completion model name'))
    controller.add_trait(
        'path_completion',
        traits.Str(desc='path completion model name',
                   optional=True))

    conf = engine.settings.select_configurations(
        environment, {'attributes': 'any'})
    if conf:
        aconf = conf.get(
            'capsul.engine.module.attributes', {})
        controller.attributes_schema_paths = aconf.get(
            'attributes_schema_paths', [])
        controller.attributes_schemas = aconf.get(
            'attributes_schemas', {})
        controller.process_completion = aconf.get(
            'process_completion', 'builtin')
        controller.path_completion = aconf.get(
            'path_completion', traits.Undefined)

    widget = ScrollControllerWidget(controller, live=True)
    widget.engine = engine
    widget.environment = environment
    widget.accept = types.MethodType(validate_config, widget)

    return widget
예제 #19
0
파일: spm.py 프로젝트: servoz/capsul
def edition_widget(engine, environment):
    ''' Edition GUI for SPM config - see
    :class:`~capsul.qt_gui.widgets.settings_editor.SettingsEditor`
    '''
    from soma.qt_gui.controller_widget import ScrollControllerWidget
    from soma.controller import Controller
    import types
    import traits.api as traits

    def validate_config(widget):
        controller = widget.controller_widget.controller
        with widget.engine.settings as session:
            values = {}
            if controller.directory in (None, traits.Undefined, ''):
                values['directory'] = None
            else:
                values['directory'] = controller.directory
            values['standalone'] = controller.standalone
            values['version'] = controller.version
            id = 'spm%s%s' % (controller.version,
                              '-standalone' if controller.standalone else '')
            values['config_id'] = id
            query = 'config_id == "%s"' % id
            conf = session.config('spm', 'global', selection=query)
            if conf is None:
                session.new_config('spm', widget.environment, values)
            else:
                for k in ('directory', 'standalone', 'version'):
                    setattr(conf, k, values[k])

    controller = Controller()
    controller.add_trait(
        "directory",
        traits.Directory(traits.Undefined,
                         output=False,
                         desc="Directory containing SPM."))
    controller.add_trait(
        "standalone",
        traits.Bool(True, desc="If True, use the standalone version of SPM."))
    controller.add_trait(
        'version',
        traits.Str(traits.Undefined,
                   output=False,
                   desc='Version string for SPM: "12", "8", etc.'))

    conf = engine.settings.select_configurations(environment, {'spm': 'any'})
    if conf:
        controller.directory = conf.get('capsul.engine.module.spm',
                                        {}).get('directory', traits.Undefined)
        controller.standalone = conf.get('capsul.engine.module.spm',
                                         {}).get('standalone', True)
        controller.version = conf.get('capsul.engine.module.spm',
                                      {}).get('version', '12')

    # TODO handle several configs

    widget = ScrollControllerWidget(controller, live=True)
    widget.engine = engine
    widget.environment = environment
    widget.accept = types.MethodType(validate_config, widget)

    return widget