Esempio n. 1
0
def vuetify_layout_factory(viewer):
    def on_click(widget, event, data):
        drawer.v_model = not drawer.v_model

    sidebar_button = v.AppBarNavIcon()
    sidebar_button.on_event('click', on_click)

    options_panel = v.ExpansionPanels(
        v_model=[0, 1],
        multiple=True,
        accordion=True,
        style_='padding-left: 1px; min-width: 200px',
        children=[
            v.ExpansionPanel(children=[
                v.ExpansionPanelHeader(class_='font-weight-bold',
                                       children=['Viewer Options']),
                v.ExpansionPanelContent(children=[viewer.viewer_options])
            ]),
            v.ExpansionPanel(children=[
                v.ExpansionPanelHeader(class_='font-weight-bold',
                                       children=['Layer Options']),
                v.ExpansionPanelContent(children=[viewer.layer_options])
            ])
        ])

    drawer = v.NavigationDrawer(v_model=False,
                                absolute=True,
                                right=True,
                                children=[sidebar_button, options_panel],
                                width="min-content")

    toolbar = v.Toolbar(
        dense=True,
        class_='elevation-0',
        children=[
            v.ToolbarItems(children=[
                viewer.toolbar_selection_tools, viewer.toolbar_selection_mode,
                viewer.toolbar_active_subset
            ]),
            v.Spacer(), sidebar_button
        ])

    layout = v.Html(tag='div',
                    children=[
                        toolbar,
                        v.Row(no_gutters=True,
                              children=[
                                  v.Col(cols=12,
                                        children=[viewer.figure_widget]),
                                  v.Col(cols=12,
                                        children=[viewer.output_widget])
                              ]), drawer
                    ])

    return layout
Esempio n. 2
0
def vuetify_layout_factory(viewer):

    def on_click(widget, event, data):
        drawer.v_model = not drawer.v_model

    sidebar_button = v.AppBarNavIcon()
    sidebar_button.on_event('click', on_click)

    options_panel = v.ExpansionPanels(
        v_model=[0, 1], multiple=True, accordion=True, style_='padding-left: 1px',
        children=[
            v.ExpansionPanel(children=[
                v.ExpansionPanelHeader(class_='font-weight-bold', children=['Viewer Options']),
                v.ExpansionPanelContent(children=[viewer.viewer_options])]),
            v.ExpansionPanel(children=[
                v.ExpansionPanelHeader(class_='font-weight-bold', children=['Layer Options']),
                v.ExpansionPanelContent(children=[viewer.layer_options])])])

    drawer = v.NavigationDrawer(v_model=False, absolute=True, right=True,
                                children=[sidebar_button,
                                          options_panel], width="min-content")

    toolbar_selection_tools = BasicJupyterToolbar(viewer)

    tool_ids, subtool_ids = get_viewer_tools(viewer.__class__)

    if subtool_ids:
        raise ValueError('subtools are not yet supported in Jupyter viewers')

    for tool_id in tool_ids:
        mode_cls = viewer_tool.members[tool_id]
        mode = mode_cls(viewer)
        toolbar_selection_tools.add_tool(mode)

    toolbar_active_subset = SubsetSelect(viewer)

    toolbar_selection_mode = SelectionModeMenu(viewer)

    toolbar = v.Toolbar(dense=True, class_='elevation-0',
                        children=[v.ToolbarItems(children=[toolbar_selection_tools,
                                                           toolbar_selection_mode,
                                                           toolbar_active_subset]),
                                  v.Spacer(),
                                  sidebar_button])

    layout = v.Html(tag='div', children=[
        toolbar,
        v.Row(no_gutters=True, children=[
            v.Col(cols=12, children=[viewer.figure_widget]),
            v.Col(cols=12, children=[viewer.output_widget])
        ]),
        drawer
    ])

    return layout
Esempio n. 3
0
def column(
    children=[],
    cols=None,
    offset=None,
    order=None,
    align_self=None,
    class_="",
    style_="",
):
    """
    Create a column output container

    For details see: https://vuetifyjs.com/en/components/grids/

    Parameters
    ----------
    children : list (default [])
        List of elements to display in container
    cols : None, str, int
        Sets the default number of columns the component extends. Available options are 1 -> 12 and auto.
    offset : None, str, int
        Sets the default offset for the column.
    order: None
        Sets the default order for the column.
    align_self : None, str, int
        Applies the align-items css property. Available options are start, center, end, auto, baseline and stretch. See https://developer.mozilla.org/en-US/docs/Web/CSS/align-items
    class_ : str (optional, default 'icon ma-2')
        CSS classes of button
    style_: str
        CSS style of button
    """

    ret = ipyvuetify.Col(
        children=children,
        cols=cols,
        offset=offset,
        order=order,
        align_self=align_self,
        class_=class_,
        style_=style_,
        justify_space_between=True,
    )

    return ret
Esempio n. 4
0
    def __init__(self, test_case_widget, lb_scheme_widget):
        """
        Widget definition for linear stability of a lattice Boltzmann scheme.

        Parameters
        ==========

        - test_case_widget:
            widget of the test case (see test_case.py).

        - lb_scheme_widget:
            widget of the lattice Boltzmann scheme (see lb_scheme.py).

        This widget is composed by a menu where you can modify the parameters of the
        lattice Boltzmann scheme.

        This widget is also composed by a main widget where the linear stability for the
        states provided by the test case can be tested to check their stability. A user can
        add its own states. A second tab allows to plot the stability region of a given state.

        """
        self.test_case_widget = test_case_widget
        self.lb_scheme_widget = lb_scheme_widget

        ##
        ## The menu
        ##
        self.menu = [self.lb_scheme_widget.panels]

        ##
        ## The main
        ##

        # Tab 1
        test_case = self.test_case_widget.get_case()
        self.state_widget = StateWidget(test_case.state())
        tab1 = v.TabItem(children=[self.state_widget.widget],
                         class_="ma-6")

        # Tab 2
        self.state_list = v.Select(label='States', items=[], v_model=0)

        plot_stab = v.Btn(children=['Plot stability region'], color='primary')
        self.alert = v.Alert(children=['Check the stability for this state...'], dense=True, type='info')
        self.stab_output, self.markers1, self.markers2 = prepare_stab_plot()

        self.container = Container(children=[v.Row(children=[v.Col(children=[self.alert])]),
                                             v.Row(children=[self.stab_output.canvas], align='center', justify='center')],
                                   align_content_center=True,)
        self.container.hide()

        tab2 = v.TabItem(children=[
            v.Card(children=[
                v.CardTitle(children=['Plot the linear stability for a given state']),
                v.CardText(children=[
                    v.Row(children=[
                        v.Col(children=[self.state_list], md=9, sm=12),
                        v.Col(children=[plot_stab], md=3, sm=12),
                        ],
                        align='center',
                        justify='space-around'
                    ),
                    self.container
                ]),
            ],
            class_="ma-6",
            )]
        )

        # main
        tabs = v.Tabs(v_model=None,
                      children=[v.Tab(children=['Check stability']),
                                v.Tab(children=['Plot stability region']),
                                tab1,
                                tab2
                      ])

        self.main = [tabs]

        self.update_states(None)
        self.change_test_case(None)

        ##
        ## Widget events
        ##
        self.test_case_widget.select_case.observe(self.change_test_case, 'v_model')
        self.test_case_widget.select_case.observe(self.hide_plot, 'v_model')
        self.lb_scheme_widget.select_case.observe(self.hide_plot, 'v_model')

        self.state_widget.eval_stab.on_event('click', self.stability_states)
        self.state_widget.item_list.observe(self.update_states, 'children')

        plot_stab.on_event('click', self.plot_stability)
Esempio n. 5
0
    def init_widgets(self, tag_type):
        self.all_check = v.Checkbox(v_on='tooltip.on',
                                    prepend_icon='fa-globe',
                                    label="All",
                                    v_model=True,
                                    class_='ma-0 mt-1 pa-0')
        self.all_check_tp = v.Tooltip(bottom=True,
                                      v_slots=[{
                                          'name': 'activator',
                                          'variable': 'tooltip',
                                          'children': self.all_check
                                      }],
                                      children=["Select all"])
        self.all_check.on_event('change', self.check_all)
        all_row = [v.Row(children=[self.all_check_tp], class_='ml-7')]

        tag_rows = []
        treenodelabel = v.Html(
            tag='style',
            children=
            [(".vuetify-styles .v-treeview-node__label {"
              "margin-left: 0px;"
              "overflow: visible;"
              "}"
              ".vuetify-styles .v-input--selection-controls:not(.v-input--hide-details) .v-input__slot {"
              "margin-bottom: 0px;"
              "}"
              ".vuetify-styles .v-treeview-node__root .v-icon.v-icon.v-icon--link {"
              "margin-bottom: 10px;"
              "}"
              ".vuetify-styles .v-treeview-node--leaf {"
              "margin-left: 0px;"
              "}"
              ".vuetify-styles .v-treeview--dense .v-treeview-node__root {"
              "min-height: 21px;"
              "}")])

        for tag in self.model.curr_trace.tags:
            if tag.tag_type == tag_type:
                chk = Checkbox(tag)
                self.checkboxes.append(chk)
                chk.widget.on_event('change', self.update_all_checkbox)
                stats = self.get_stats(tag)
                btn, tooltip = self.create_zoom_button(tag, stats=stats)
                statss = self.tag_tooltip(tag, stats).splitlines()

                tag_row = v.Row(children=[btn, chk.widget], class_='ml-0')
                items = [{
                    'id':
                    1,
                    'name':
                    '',
                    'children': [{
                        'id': i + 2,
                        'name': stat
                    } for i, stat in enumerate(statss)],
                }]
                treeview = v.Treeview(items=items, dense=True)
                tag_rows.append(
                    v.Container(row=False,
                                class_="d-flex justify-start ma-0 pa-0",
                                children=[
                                    v.Col(cols=1,
                                          children=[treeview],
                                          class_="ma-0 pa-0"),
                                    v.Col(cols=12,
                                          children=[tag_row],
                                          class_="pt-0 pb-0")
                                ]))
        tag_rows.append(v.Container(row=False, children=[treenodelabel]))
        return VBox([
            v.List(children=(all_row + tag_rows),
                   dense=True,
                   nav=True,
                   max_height="300px",
                   max_width="300px")
        ])
Esempio n. 6
0
# # Widgets
# # ----------------------------------------------------------------

export_extraction = widgets.Output(layout=layout_output_wgt)

genotypes_selection_extraction = v.Select(items=[],
                                          chips=True,
                                          multiple=True,
                                          counter=True,
                                          v_model="",
                                          label="Select Genotypes",
                                          truncate_length=22)

menu_plant_extraction = v.Col(
    cols=12,
    sm=3,
    md=3,
    children=[genotypes_selection_extraction, export_extraction])

df_modulescale = create_grid()

panel_df = v.Container(fluid=True, children=[df_modulescale])

df_description = create_grid()

panel_description = v.Container(fluid=True, children=[df_description])

tab_extraction_content = v.Row(children=[
    v.Card(style_=layout_card, children=[info.p4_doc_extraction]),
    v.Col(cols=12,
          sm=12,
Esempio n. 7
0
# # Widgets
# # ----------------------------------------------------------------

export_extraction = widgets.Output(layout=layout_output_wgt)

genotypes_selection_extraction = v.Select(items=[],
                                          chips=True,
                                          multiple=True,
                                          counter=True,
                                          v_model="",
                                          label="Select Genotypes",
                                          truncate_length=22)

menu_plant_extraction = v.Col(
    cols=12,
    sm=12,
    md=12,
    children=[genotypes_selection_extraction, export_extraction])

df_plantscale = create_grid()

panel_df = v.Container(fluid=True, children=[df_plantscale])

df_description = create_grid()

panel_description = v.Container(fluid=True, children=[df_description])

tab_extraction_content = v.Row(children=[
    v.Card(style_=layout_card, children=[info.p3_doc_extraction]),
    v.Col(cols=12,
          sm=12,
Esempio n. 8
0
    def __init__(self, test_case_widget, lb_scheme_widget):
        """
        Widget definition for simulation of lattice Boltzmann methods.

        Parameters
        ==========

        - test_case_widget:
            widget of the test case (see test_case.py).

        - lb_scheme_widget:
            widget of the lattice Boltzmann scheme (see lb_scheme.py).

        This widget is composed by a menu where you can modify the discretization parameters,
        the generator used to build the numerical kernel into pylbm and the desired outputs for
        post treatment.

        This widget is also composed by a main widget where the simulation can be started and
        a plot is given in real time for the available fields. A period can be modified to control
        the plot frequency and a snapshot of the current figure can be made.

        """
        self.test_case_widget = test_case_widget
        self.lb_scheme_widget = lb_scheme_widget
        test_case = test_case_widget.get_case()
        tc_param = test_case_widget.parameters
        lb_case = lb_scheme_widget.get_case()
        lb_param = lb_scheme_widget.parameters

        self.stats = {}
        ##
        ## The menu
        ##

        # configure the default simulation name
        self.simulation_name = v.TextField(label='Simulation name', v_model='')
        self.update_name(None)

        self.simu_cfg = v.Select(label='Load simulation configuration',
                                 items=[],
                                 v_model=None)
        self.update_simu_cfg_list()

        self.discret = DiscretizationWidget(test_case_widget, lb_scheme_widget)

        self.codegen = v.Select(items=['auto', 'numpy', 'cython'],
                                v_model='auto')

        self.save_fields = Save_widget(
            list(lb_scheme_widget.get_case().equation.get_fields().keys()))

        self.menu = [
            self.simulation_name, self.simu_cfg,
            v.ExpansionPanels(children=[
                self.discret,
                v.ExpansionPanel(children=[
                    v.ExpansionPanelHeader(children=['Code generator']),
                    v.ExpansionPanelContent(children=[self.codegen]),
                ]),
                v.ExpansionPanel(children=[
                    v.ExpansionPanelHeader(children=['Field output request']),
                    v.ExpansionPanelContent(
                        children=[self.save_fields.widget]),
                ]),
            ],
                              multiple=True,
                              class_='pa-0')
        ]

        ##
        ## The main
        ##

        self.simu = simulation()
        self.simu.reset_fields(
            lb_scheme_widget.get_case().equation.get_fields())

        self.start = v.Btn(v_model=True,
                           children=['Start'],
                           class_='ma-2',
                           style_='width: 100px',
                           color='success')
        self.startTooltip = Tooltip(self.start,
                                    tooltip='click to start the simulation')

        self.pause = v.Btn(children=['Pause'],
                           class_='ma-2',
                           style_='width: 100px',
                           disabled=True,
                           v_model=False)
        self.progress_bar = v.ProgressLinear(height=20,
                                             value=0,
                                             color='light-blue',
                                             striped=True)
        self.result = v.Select(items=list(self.simu.fields.keys()),
                               v_model=list(self.simu.fields.keys())[0])

        self.period = StrictlyPositiveIntField(
            label='Period',
            v_model=round(self.discret['nt'].value / nb_split_period))
        self.snapshot = v.Btn(children=['Snapshot'])

        self.plot = Plot()
        self.iplot = 0
        self.plot_output = v.Row(justify='center')

        self.dialog = DialogPath()

        self.main = [
            v.Row(children=[
                self.startTooltip,
                Tooltip(self.pause, tooltip='click to pause the simulation'),
                self.dialog,
            ]),
            self.progress_bar,
            v.Row(
                children=[
                    v.Col(children=[self.result], md=5, sm=12),
                    v.Col(children=[self.period], md=5, sm=12),
                    v.Col(children=[self.snapshot], md=2, sm=12),
                ],
                align='center',
                justify='space-around',
            ),
            self.plot_output,
        ]

        ##
        ## Widget events
        ##

        self.start.on_event('click', self.start_simulation)
        self.pause.on_event('click', self.on_pause_click)
        self.snapshot.on_event('click', self.take_snapshot)
        self.result.observe(self.replot, 'v_model')
        self.simu_cfg.observe(self.load_simu_cfg, 'v_model')
        self.discret['nt'].observe(self.change_period_by_nt, 'v_model')

        test_case_widget.select_case.observe(self.stop_simulation, 'v_model')
        lb_scheme_widget.select_case.observe(self.stop_simulation, 'v_model')
        lb_scheme_widget.select_case.observe(self.update_result, 'v_model')
        test_case_widget.select_case.observe(self.update_name, 'v_model')
        lb_scheme_widget.select_case.observe(self.update_name, 'v_model')
Esempio n. 9
0
                           v_model=2)

slider_n_plant = v.Slider(max=100,
                          min=1,
                          label="#p",
                          thumb_label=True,
                          v_model="",
                          disabled=True)

box_n_plant = v.TextField(type_="number",
                          class_="mt-0 pt-0",
                          v_model='',
                          disabled=True)

plant_selection = v.Row(children=[
    v.Col(cols=12, sm=7, md=7, children=[slider_n_plant]),
    v.Col(cols=12, sm=1, md=1, children=[box_n_plant])
])

cb_allplants = v.Checkbox(v_model=False,
                          label="Select all plants",
                          disabled=True)

menu_plant = v.Col(cols=12,
                   sm=3,
                   md=3,
                   children=[
                       files_upload,
                       v.Divider(), files_selection,
                       v.Divider(), genotypes_selection,
                       v.Divider(), plant_selection,
Esempio n. 10
0
    def __init__(self, spark_controller, ipywidget_factory, ipython_display,
                 endpoints, refresh_method, state, db):
        super(AddEndpointWidget,
              self).__init__(spark_controller, ipywidget_factory,
                             ipython_display, True)
        self.endpoints = endpoints
        self.refresh_method = refresh_method
        self.state = state
        self.delete_pressed = False
        self.db = db
        self.auth = GoogleAuth()

        add_endpoint_button = v.Btn(class_='ma-2',
                                    color='primary',
                                    children=['Add Endpoint'])
        add_endpoint_button.on_event('click', self._add_endpoint)
        cancel_button = v.Btn(class_='ma-2',
                              color='primary',
                              children=['Cancel'])
        cancel_button.on_event('click', self._on_cancel_click)

        backicon = v.Icon(children=['mdi-arrow-left'])
        backicon.on_event('click', self._on_back_click)
        back_toolbar = v.Toolbar(
            elevation="0",
            children=[
                v.ToolbarItems(children=[backicon]),
                v.ToolbarTitle(children=['Create new endpoint']),
                v.Spacer()
            ],
            app=True,  # If true, the other widgets float under on scroll
        )

        self.create_endpoint_widget = v.Container(
            style_=f'width: {WIDGET_WIDTH};',
            class_='ma-2',
            children=[
                back_toolbar,
                v.Row(class_='ma-2',
                      children=[
                          v.Col(children=[self.auth.account_widget]),
                          v.Col(children=[self.auth.project_widget]),
                          v.Col(children=[self.auth.region_widget])
                      ]),
                v.Row(class_='ma-2',
                      children=[
                          v.Col(children=[self.auth.cluster_widget]),
                          v.Col(children=[self.auth.filter_widget]),
                          v.Col(children=[v.Spacer()]),
                      ]),
                v.Row(class_='ma-2',
                      children=[add_endpoint_button, cancel_button])
            ])

        endpoint_table_values = self._generate_endpoint_values()
        new_endpoint = v.Btn(class_='ma-2',
                             color='primary',
                             children=['New Endpoint'])
        new_endpoint.on_event('click', self._on_new_endpoint_click)

        no_back_toolbar = v.Toolbar(
            elevation="0",
            children=[
                v.ToolbarTitle(titleMarginStart='12dp',
                               contentInsetStartWithNavigation="56dp",
                               children=['Endpoints']),
                v.Spacer()
            ],
            app=True,  # If true, the other widgets float under on scroll
        )
        toolbar = v.Row(children=[no_back_toolbar, new_endpoint])
        delete_icon = v.Icon(children=['mdi-delete'])
        delete_icon.on_event('click', self._on_delete_icon_pressed)

        endpoint_table = v.DataTable(style_=f'width: {WIDGET_WIDTH};',
                                     no_data_text='No endpoints',
                                     hide_default_footer=True,
                                     disable_pagination=True,
                                     item_key='url',
                                     headers=[
                                         {
                                             'text': 'Cluster',
                                             'align': 'start',
                                             'sortable': False,
                                             'value': 'name'
                                         },
                                         {
                                             'text': 'Project',
                                             'sortable': False,
                                             'value': 'project'
                                         },
                                         {
                                             'text': 'Region',
                                             'sortable': False,
                                             'value': 'region'
                                         },
                                         {
                                             'text': 'Account',
                                             'sortable': False,
                                             'value': 'account'
                                         },
                                         {
                                             'text': 'Url',
                                             'sortable': False,
                                             'value': 'url'
                                         },
                                         {
                                             'text': '',
                                             'sortable': False,
                                             'value': 'actions'
                                         },
                                     ],
                                     items=endpoint_table_values,
                                     dense=False,
                                     v_slots=[{
                                         'name': 'item.actions',
                                         'children': [delete_icon]
                                     }, {
                                         'name': 'no-data',
                                         'children': ['No endpoints']
                                     }])
        endpoint_table.on_event('click:row', self._remove_row_from_table)

        self.toolbar_with_table = v.Container(
            style_=f'width: {WIDGET_WIDTH};',
            class_='mx-auto',
            children=[
                v.Row(class_='mx-auto', children=[toolbar]),
                v.Row(class_='mx-auto', children=[endpoint_table])
            ])

        self.children = [self.create_endpoint_widget, self.toolbar_with_table]
        for child in self.children:
            child.parent_widget = self
        self._update_view()
Esempio n. 11
0
                                  multiple=False,
                                  v_model=None,
                                  label="Select Order",
                                  truncate_length=22)

menu_plant_waffle = v.Row(children=[
    genotypes_selection_waffle, date_selection_waffle,
    variable_selection_waffle, order_selection_waffle, plot_type_waffle
])

waffle = widgets.Output(layout=layout_output_wgt)

tab_waffle_content = v.Row(children=[
    v.Card(style_=layout_card, children=[info.p5_doc_waffle]),
    v.Col(col=12, sm=12, md=12, children=[
        menu_plant_waffle,
        waffle,
    ]),
])

p5 = v.Tabs(children=[
    v.Tab(children=['Waffle']),
    v.TabItem(children=[tab_waffle_content]),
])

container_main = v.Container(fluid=True,
                             class_='grid-list-md box',
                             children=[p5])

# # ----------------------------------------------------------------
# # Link widgets - event
# # ----------------------------------------------------------------
id_selection_2d = v.Select(items=[],
                           chips=True,
                           multiple=False,
                           v_model="",
                           label="Select Plant ID",
                           truncate_length=22)

parameter_color = v.Select(items=[True, False],
                           label="Group by color",
                           multiple=False,
                           chips=True,
                           v_model=False)

menu_plant_3d = v.Row(children=[
    v.Col(children=[genotype_selection_3d]),
    v.Col(children=[parameter_color])
])

row_param2d = v.Row(children=[
    v.Col(children=[genotype_selection_2d]),
    v.Col(children=[id_selection_2d])
])

plot3d_growth_developement = widgets.Output(layout=layout_output_wgt)

plot3d_floral_intensity = widgets.Output(layout=layout_output_wgt)

panel_3d = v.Row(children=[
    v.Col(children=[
        v.Container(fluid=True, children=[plot3d_growth_developement])
Esempio n. 13
0
           color='primary',
           x_small=True,
           icon=True,
           children=[
               v.Icon(children=['mdi-pencil']),
           ]),
     v.Btn(class_='ma-2',
           color='primary',
           x_small=True,
           text=True,
           children=['button']),
 ]),
 v.Row(children=[
     v.Col(cols=4,
           children=[
               v.Select(label='Fruits',
                        items=['Apple', 'Pear', 'Cherry'],
                        v_model='Pear')
           ]),
     v.Col(cols=4,
           children=[
               v.Select(label='Fruits',
                        items=['Apple', 'Pear', 'Cherry'],
                        chips=True,
                        multiple=True,
                        v_model=['Pear', 'Cherry'])
           ]),
     v.Col(cols=4,
           children=[
               v.Select(label='Fruits',
                        items=['Apple', 'Pear', 'Cherry'],
                        outlined=True)