Пример #1
0
from typing import Any, Tuple

from opendrop.app.common.image_processing.image_processor import ImageProcessorPluginViewContext
from opendrop.mvp import ComponentSymbol, View, Presenter
from opendrop.utility.bindablegext import GObjectPropertyBindable
from opendrop.utility.geometry import Vector2, Rect2
from opendrop.widgets.render.objects import RectangleWithLabel, Rectangle
from .model import DefineRegionPluginModel

define_region_plugin_cs = ComponentSymbol()  # type: ComponentSymbol[None]


@define_region_plugin_cs.view(
    options=['view_context', 'tool_id', 'color', 'label', 'z_index'])
class DefineRegionPluginView(View['DefineRegionPluginPresenter', None]):
    def _do_init(
        self,
        view_context: ImageProcessorPluginViewContext,
        tool_id: Any,
        color: Tuple[float, float, float],
        label: str,
        z_index: int,
    ) -> None:
        self._view_context = view_context
        self._tool_ref = view_context.get_tool_item(tool_id)

        view_context.render.connect(
            'cursor-up-event',
            lambda render, pos: self.presenter.cursor_up(pos),
        )
Пример #2
0
from typing import Optional

from gi.repository import Gtk

from opendrop.app.common.footer.linearnav import linear_navigator_footer_cs
from opendrop.app.common.wizard import WizardPageControls
from opendrop.mvp import ComponentSymbol, Presenter, View
from opendrop.utility.bindable import Bindable
from opendrop.utility.bindablegext import GObjectPropertyBindable
from .configurator import configurator_cs
from .model import ImageAcquisitionModel, AcquirerType

image_acquisition_cs = ComponentSymbol()  # type: ComponentSymbol[Gtk.Widget]


@image_acquisition_cs.view(options=['footer_area'])
class ImageAcquisitionView(View['ImageAcquisitionPresenter', Gtk.Widget]):
    def _do_init(self, footer_area: Gtk.Grid) -> Gtk.Widget:
        self._widget = Gtk.Grid(margin=10, column_spacing=10, row_spacing=10)

        image_source_lbl = Gtk.Label('Image source:')
        self._widget.attach(image_source_lbl, 0, 0, 1, 1)

        self._image_source_combobox = Gtk.ComboBoxText(hexpand=True, halign=Gtk.Align.START)
        self._widget.attach(self._image_source_combobox, 1, 0, 1, 1)

        self._populate_combobox()

        self._widget.attach(
            Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL, hexpand=True),
            0, 1, 2, 1
Пример #3
0
# OpenDrop is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE.  See the GNU General Public License for more details.  You
# should have received a copy of the GNU General Public License along
# with this software.  If not, see <https://www.gnu.org/licenses/>.

from typing import Optional

import cv2
import numpy as np
from gi.repository import Gtk

from opendrop.mvp import ComponentSymbol, View, Presenter
from opendrop.utility.bindable.typing import Bindable

drop_fit_cs = ComponentSymbol()  # type: ComponentSymbol[Gtk.Widget]


@drop_fit_cs.view()
class DropFitView(View['DropFitPresenter', Gtk.Widget]):
    def _do_init(self) -> Gtk.Widget:
        from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvas
        from matplotlib.figure import Figure
        from matplotlib.image import AxesImage

        self._widget = Gtk.Grid()

        figure = Figure(tight_layout=True)

        self._figure_canvas = FigureCanvas(figure)
        self._figure_canvas.props.hexpand = True
Пример #4
0
# PURPOSE.  See the GNU General Public License for more details.  You
# should have received a copy of the GNU General Public License along
# with this software.  If not, see <https://www.gnu.org/licenses/>.

import math
from typing import Callable, Any

from gi.repository import Gtk

from opendrop.mvp import ComponentSymbol, View, Presenter
from opendrop.utility.bindable import VariableBindable
from opendrop.utility.bindable.typing import Bindable
from .model import ResultsFooterStatus
from .progress import progress_cs

results_footer_cs = ComponentSymbol()  # type: ComponentSymbol[Gtk.Widget]


@results_footer_cs.view()
class ResultsFooterView(View['ResultsFooterPresenter', Gtk.Widget]):
    def _do_init(self) -> Gtk.Widget:
        self._widget = Gtk.Grid(margin=10, column_spacing=10, vexpand=False)

        self._cancel_or_back_stack = Gtk.Stack(visible=True)
        self._widget.attach(self._cancel_or_back_stack, 0, 0, 1, 1)

        self._cancel_btn = Gtk.Button(hexpand=False,
                                      vexpand=True,
                                      visible=True)
        self._cancel_or_back_stack.add(self._cancel_btn)
Пример #5
0
from gi.repository import Gtk

from opendrop.app.common.image_processing.image_processor import ImageProcessorPluginViewContext
from opendrop.app.common.image_processing.plugins.define_region import define_region_plugin_cs, DefineRegionPluginModel
from opendrop.app.ift.image_processing.plugins import ToolID
from opendrop.mvp import ComponentSymbol, View, Presenter

ift_needle_region_plugin_cs = ComponentSymbol()  # type: ComponentSymbol[None]


@ift_needle_region_plugin_cs.view(options=['view_context', 'z_index'])
class IFTNeedleRegionPluginView(View['IFTNeedleRegionPluginPresenter', None]):
    def _do_init(self, view_context: ImageProcessorPluginViewContext,
                 z_index: int) -> None:
        self._view_context = view_context

        self.new_component(
            define_region_plugin_cs.factory(
                model=self.presenter.define_region_plugin_model,
                view_context=view_context,
                tool_id=ToolID.NEEDLE_REGION,
                color=(0.05, 0.1, 1.0),
                label='Needle region',
                z_index=z_index,
            ), )

        tool_ref = view_context.get_tool_item(ToolID.NEEDLE_REGION)
        self._tool_button_interior = Gtk.Grid(hexpand=True, vexpand=True)
        tool_ref.button_interior.add(self._tool_button_interior)

        tool_button_lbl = Gtk.Label(
Пример #6
0
# continued development of this code and other open source resources.
#
# OpenDrop is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE.  See the GNU General Public License for more details.  You
# should have received a copy of the GNU General Public License along
# with this software.  If not, see <https://www.gnu.org/licenses/>.

from gi.repository import Gtk

from opendrop.app.common.image_processing.image_processor import ImageProcessorPluginViewContext
from opendrop.app.common.image_processing.plugins.define_line import DefineLinePluginModel, define_line_plugin_cs
from opendrop.app.conan.image_processing.services.plugins import ToolID
from opendrop.mvp import ComponentSymbol, View, Presenter

conan_baseline_plugin_cs = ComponentSymbol()  # type: ComponentSymbol[None]


@conan_baseline_plugin_cs.view(options=['view_context', 'z_index'])
class ConanBaselinePluginView(View['ConanBaselinePluginPresenter', None]):
    def _do_init(self, view_context: ImageProcessorPluginViewContext,
                 z_index: int) -> None:
        self._view_context = view_context

        self.new_component(
            define_line_plugin_cs.factory(
                model=self.presenter.define_line_plugin_model,
                view_context=view_context,
                tool_id=ToolID.BASELINE,
                color=(0.1, 0.8, 0.1),
                z_index=z_index,
Пример #7
0
# OpenDrop is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE.  See the GNU General Public License for more details.  You
# should have received a copy of the GNU General Public License along
# with this software.  If not, see <https://www.gnu.org/licenses/>.


import math
from typing import Optional

from gi.repository import Gtk, GObject

from opendrop.mvp import ComponentSymbol, View, Presenter
from opendrop.utility.bindable.typing import Bindable

progress_cs = ComponentSymbol()  # type: ComponentSymbol[Gtk.Widget]


@progress_cs.view()
class ProgressView(View['ProgressPresenter', Gtk.Widget]):
    def _do_init(self) -> Gtk.Widget:
        self._widget = Gtk.Grid(row_spacing=5)

        self._progress_bar = Gtk.ProgressBar(margin_top=5, hexpand=True, visible=True)
        self._widget.attach(self._progress_bar, 0, 0, 3, 1)

        self._time_elapsed_lbl = Gtk.Label(xalign=0, visible=True)
        self._progress_fraction_lbl = Gtk.Label(xalign=0.5, hexpand=True, visible=True)
        self._time_remaining_lbl = Gtk.Label(xalign=1, visible=True)
        self._complete_lbl = Gtk.Label(xalign=0.5, visible=True)
Пример #8
0
from gi.repository import Gtk, Gdk, GObject

from opendrop.mvp import ComponentSymbol, View, Presenter
from opendrop.utility.bindablegext import GObjectPropertyBindable
from opendrop.widgets.float_entry import FloatEntry
from opendrop.widgets.integer_entry import IntegerEntry
from .model import FigureOptions

figure_options_cs = ComponentSymbol()  # type: ComponentSymbol[Gtk.Widget]


@figure_options_cs.view(options=['figure_name'])
class FigureOptionsView(View['FigureOptionsPresenter', Gtk.Widget]):
    STYLE = '''
    .small-pad {
         min-height: 0px;
         min-width: 0px;
         padding: 6px 4px 6px 4px;
    }

    .error {
        color: red;
        border: 1px solid red;
    }

    .error-text {
        color: red;
    }
    '''

    _STYLE_PROV = Gtk.CssProvider()
Пример #9
0
# should have received a copy of the GNU General Public License along
# with this software.  If not, see <https://www.gnu.org/licenses/>.


from typing import Optional, Callable, Any

from gi.repository import Gtk, Gdk, GObject

from opendrop.app.common.image_acquirer import USBCameraAcquirer
from opendrop.mvp import ComponentSymbol, Presenter, View
from opendrop.utility.bindable.typing import Bindable
from opendrop.utility.bindable.gextension import GObjectPropertyBindable
from opendrop.widgets.float_entry import FloatEntry
from opendrop.widgets.integer_entry import IntegerEntry

usb_camera_cs = ComponentSymbol()  # type: ComponentSymbol[Gtk.Widget]


@usb_camera_cs.view()
class USBCameraView(View['USBCameraPresenter', Gtk.Widget]):
    STYLE = '''
    .change-cam-dialog-view-footer {
         background-color: gainsboro;
    }

    .small-pad {
         min-height: 0px;
         min-width: 0px;
         padding: 6px 4px 6px 4px;
    }
Пример #10
0
#
# OpenDrop is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE.  See the GNU General Public License for more details.  You
# should have received a copy of the GNU General Public License along
# with this software.  If not, see <https://www.gnu.org/licenses/>.


from gi.repository import Gtk

from opendrop.app.common.image_processing.image_processor import ImageProcessorPluginViewContext
from opendrop.app.common.image_processing.plugins.define_region import define_region_plugin_cs, DefineRegionPluginModel
from opendrop.app.conan.image_processing.services.plugins import ToolID
from opendrop.mvp import ComponentSymbol, View, Presenter

conan_roi_plugin_cs = ComponentSymbol()  # type: ComponentSymbol[None]


@conan_roi_plugin_cs.view(options=['view_context', 'z_index'])
class ConanRoiPluginView(View['ConanRoiPluginPresenter', None]):
    def _do_init(self, view_context: ImageProcessorPluginViewContext, z_index: int) -> None:
        self._view_context = view_context

        self.new_component(
            define_region_plugin_cs.factory(
                model=self.presenter.define_region_plugin_model,
                view_context=view_context,
                tool_id=ToolID.ROI,
                color=(1.0, 0.1, 0.05),
                label='ROI',
                z_index=z_index,
Пример #11
0
from gi.repository import Gtk

from opendrop.app.common.image_processing.image_processor import ImageProcessorPluginViewContext
from opendrop.app.common.image_processing.plugins.define_region import define_region_plugin_cs, DefineRegionPluginModel
from opendrop.app.ift.image_processing.plugins import ToolID
from opendrop.mvp import ComponentSymbol, View, Presenter

ift_drop_region_plugin_cs = ComponentSymbol()  # type: ComponentSymbol[None]


@ift_drop_region_plugin_cs.view(options=['view_context', 'z_index'])
class IFTDropRegionPluginView(View['IFTDropRegionPluginPresenter', None]):
    def _do_init(self, view_context: ImageProcessorPluginViewContext, z_index: int) -> None:
        self._view_context = view_context

        self.new_component(
            define_region_plugin_cs.factory(
                model=self.presenter.define_region_plugin_model,
                view_context=view_context,
                tool_id=ToolID.DROP_REGION,
                color=(1.0, 0.1, 0.05),
                label='Drop region',
                z_index=z_index,
            ),
        )

        tool_ref = view_context.get_tool_item(ToolID.DROP_REGION)
        self._tool_button_interior = Gtk.Grid(hexpand=True, vexpand=True)
        tool_ref.button_interior.add(self._tool_button_interior)

        tool_button_lbl = Gtk.Label(
Пример #12
0
#
# OpenDrop is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE.  See the GNU General Public License for more details.  You
# should have received a copy of the GNU General Public License along
# with this software.  If not, see <https://www.gnu.org/licenses/>.

from typing import Optional, Sequence, MutableSequence, Callable, Any

from gi.repository import Gtk, Pango

from opendrop.app.ift.analysis import IFTDropAnalysis
from opendrop.mvp import ComponentSymbol, View, Presenter
from opendrop.utility.bindable.typing import Bindable

master_cs = ComponentSymbol()  # type: ComponentSymbol[Gtk.Widget]


@master_cs.view()
class MasterView(View['MasterPresenter', Gtk.Widget]):
    def _do_init(self) -> Gtk.Widget:
        self._widget = Gtk.ScrolledWindow(hexpand=True)

        self._tree_model = Gtk.ListStore(str, str, str)
        self._rows = []  # type: MutableSequence[self.RowManager]

        tree_view = Gtk.TreeView(
            model=self._tree_model,
            enable_search=False,
            enable_grid_lines=Gtk.TreeViewGridLines.BOTH,
        )
Пример #13
0
import math
from typing import Optional

import numpy as np
from gi.repository import Gtk, GObject

from opendrop.mvp import ComponentSymbol, View, Presenter
from opendrop.utility.bindable import Bindable
from opendrop.utility.bindablegext import GObjectPropertyBindable
from opendrop.utility.geometry import Rect2, Vector2, Line2
from opendrop.utility.gmisc import pixbuf_from_array
from opendrop.widgets.render import Render
from opendrop.widgets.render.objects import PixbufFill, Line, Polyline, Angle

info_cs = ComponentSymbol()  # type: ComponentSymbol[Gtk.Widget]


@info_cs.view()
class InfoView(View['InfoPresenter', Gtk.Widget]):
    def _do_init(self) -> Gtk.Widget:
        self._render = Render(hexpand=True, vexpand=True)

        self._background_ro = PixbufFill()
        self._render.add_render_object(self._background_ro)

        surface_line_ro = Line(stroke_color=(0.25, 1.0, 0.25))
        self._render.add_render_object(surface_line_ro)
        self.bn_surface_line = GObjectPropertyBindable(surface_line_ro, 'line')

        drop_contour_ro = Polyline(stroke_color=(0.0, 0.5, 1.0))
        self._render.add_render_object(drop_contour_ro)
Пример #14
0
from typing import Any, Callable, MutableSequence, Mapping

from gi.repository import Gtk, Gdk

from opendrop.mvp import ComponentSymbol, View, Presenter
from opendrop.utility.bindable import Bindable
from .model import ToolItemRef

tool_panel_cs = ComponentSymbol()  # type: ComponentSymbol[Gtk.Widget]


@tool_panel_cs.view(options=['tool_item_refs'])
class ToolPanelView(View['ToolPanelPresenter', Gtk.Widget]):
    STYLE = '''
    .tool-panel {
         background-color: gainsboro;
         padding: 5px;
    }
    '''

    _STYLE_PROV = Gtk.CssProvider()
    _STYLE_PROV.load_from_data(bytes(STYLE, 'utf-8'))
    Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(),
                                             _STYLE_PROV,
                                             Gtk.STYLE_PROVIDER_PRIORITY_USER)

    class _ToolItemManager:
        def __init__(
            self, tool_id: Any, tool_button: Gtk.ToggleButton,
            on_click: Callable[['ToolPanelView._ToolItemManager'],
                               Any]) -> None:
Пример #15
0
from gi.repository import Gtk

from opendrop.mvp import ComponentSymbol, View, Presenter
from .detail import detail_cs
from .master import master_cs
from .model import IndividualModel

individual_cs = ComponentSymbol()  # type: ComponentSymbol[Gtk.Widget]


@individual_cs.view()
class IndividualView(View['IndividualPresenter', Gtk.Widget]):
    def _do_init(self) -> Gtk.Widget:
        self._widget = Gtk.Paned(orientation=Gtk.Orientation.VERTICAL)

        _, detail_area = self.new_component(
            detail_cs.factory(in_analysis=self.presenter.bn_selection, ))
        detail_area.show()
        self._widget.pack1(detail_area, resize=True, shrink=False)

        _, master_area = self.new_component(
            master_cs.factory(
                in_analyses=self.presenter.bn_analyses,
                bind_selection=self.presenter.bn_selection,
            ))
        master_area.show()
        self._widget.pack2(master_area, resize=True, shrink=False)

        return self._widget

    def _do_destroy(self) -> None:
Пример #16
0
# OpenDrop is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE.  See the GNU General Public License for more details.  You
# should have received a copy of the GNU General Public License along
# with this software.  If not, see <https://www.gnu.org/licenses/>.

import gc

from gi.repository import Gtk

from opendrop.app.common.image_processing.plugins.preview.model import ImageSequenceAcquirerController
from opendrop.mvp import ComponentSymbol, View, Presenter
from opendrop.utility.bindable.gextension import GObjectPropertyBindable
from opendrop.widgets.integer_entry import IntegerEntry

image_sequence_navigator_cs = ComponentSymbol(
)  # type: ComponentSymbol[Gtk.Widget]


@image_sequence_navigator_cs.view()
class ImageSequenceNavigatorView(View['ImageSequenceNavigatorPresenter',
                                      Gtk.Widget]):
    def _do_init(self) -> Gtk.Grid:
        self._widget = Gtk.Grid(column_spacing=5)

        left_btn = Gtk.Button('<')
        self._widget.attach(left_btn, 0, 0, 1, 1)

        self._idx_inp = IntegerEntry(lower=1, width_chars=3)
        self._widget.attach(self._idx_inp, 1, 0, 1, 1)

        self._num_images_lbl = Gtk.Label()
Пример #17
0
from typing import Optional, Any

from gi.repository import Gtk

from opendrop.app.common.image_acquirer import ImageAcquirer, LocalStorageAcquirer, USBCameraAcquirer
from opendrop.mvp import ComponentSymbol, View, Presenter
from opendrop.utility.bindable import Bindable
from .local_storage import local_storage_cs
from .usb_camera import usb_camera_cs

configurator_cs = ComponentSymbol()  # type: ComponentSymbol[Gtk.Widget]


@configurator_cs.view()
class ConfiguratorView(View['ConfiguratorPresenter', Gtk.Widget]):
    def _do_init(self) -> Gtk.Widget:
        self._widget = Gtk.Grid()

        self._configurator_cid = None  # type: Optional[Any]

        self.presenter.view_ready()

        return self._widget

    def load_local_storage_configurator(self) -> None:
        self.remove_configurator()
        acquirer = self.presenter.bn_acquirer.get()

        self._configurator_cid, configurator_area = self.new_component(
            local_storage_cs.factory(acquirer=acquirer))
        configurator_area.show()
Пример #18
0
import math
from typing import Optional

from gi.repository import Gtk

from opendrop.app.ift.analysis import IFTDropAnalysis
from opendrop.app.ift.results.individual.detail.log_view import log_cs
from opendrop.app.ift.results.individual.detail.residuals import residuals_plot_cs
from opendrop.mvp import ComponentSymbol, View, Presenter
from opendrop.utility.bindable import Bindable, BoxBindable
from .parameters import parameters_cs
from .profile_fit import drop_fit_cs

detail_cs = ComponentSymbol()  # type: ComponentSymbol[Gtk.Widget]


@detail_cs.view()
class DetailView(View['DetailPresenter', Gtk.Widget]):
    def _do_init(self) -> Gtk.Widget:
        self._widget = Gtk.Stack(margin=10)

        self._body = Gtk.Grid(column_spacing=10)
        self._body.show()
        self._widget.add(self._body)

        _, parameters_area = self.new_component(
            parameters_cs.factory(
                in_interfacial_tension=self.presenter.bn_interfacial_tension,
                in_volume=self.presenter.bn_volume,
                in_surface_area=self.presenter.bn_surface_area,
                in_worthington=self.presenter.bn_worthington,
Пример #19
0
# OpenDrop is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE.  See the GNU General Public License for more details.  You
# should have received a copy of the GNU General Public License along
# with this software.  If not, see <https://www.gnu.org/licenses/>.

import pkg_resources
from gi.repository import Gtk, GdkPixbuf, Gio, GLib

from opendrop.mvp import ComponentSymbol, View, Presenter
from .conan import ConanSession, conan_root_cs
from .ift import IFTSession, ift_root_cs
from .main_menu import main_menu_cs
from .model import AppRootModel, AppMode

app_cs = ComponentSymbol()  # type: ComponentSymbol[None]


@app_cs.view()
class AppRootView(View['AppRootPresenter', None]):
    APP_ICON = GdkPixbuf.Pixbuf.new_from_stream(
        Gio.MemoryInputStream.new_from_bytes(
            GLib.Bytes(
                pkg_resources.resource_stream(
                    'opendrop.res', 'images/icon_256x256.png').read())))

    def _do_init(self) -> None:
        Gtk.Window.set_default_icon(self.APP_ICON)

        _, self._main_menu_window = self.new_component(
            main_menu_cs.factory(model=self.presenter.main_menu_model))
Пример #20
0
from typing import Optional

import numpy as np
from gi.repository import Gtk

from opendrop.mvp import ComponentSymbol, View, Presenter
from opendrop.utility.bindable import Bindable

residuals_plot_cs = ComponentSymbol()  # type: ComponentSymbol[Gtk.Widget]


@residuals_plot_cs.view()
class ResidualsPlotView(View['ResidualsPlotPresenter', Gtk.Widget]):
    def _do_init(self) -> Gtk.Widget:
        from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvas
        from matplotlib.figure import Figure

        self._widget = Gtk.Grid()

        figure = Figure(tight_layout=True)

        self._figure_canvas = FigureCanvas(figure)
        self._figure_canvas.props.hexpand = True
        self._figure_canvas.props.vexpand = True
        self._figure_canvas.show()
        self._widget.add(self._figure_canvas)

        self._axes = figure.add_subplot(1, 1, 1)

        # Set tick labels font size
        for item in (*self._axes.get_xticklabels(),
Пример #21
0
from pathlib import Path
from typing import Optional, Callable, Any

from gi.repository import Gtk, Gdk

from opendrop.app.common.analysis_saver.figure_options import figure_options_cs
from opendrop.mvp import ComponentSymbol, View, Presenter
from opendrop.utility.bindable import AccessorBindable
from opendrop.utility.bindablegext import GObjectPropertyBindable
from opendrop.widgets.error_dialog import ErrorDialog
from opendrop.widgets.yes_no_dialog import YesNoDialog
from .model import IFTAnalysisSaverOptions

ift_save_dialog_cs = ComponentSymbol()  # type: ComponentSymbol[Gtk.Window]


@ift_save_dialog_cs.view(options=['parent_window'])
class IFTSaveDialogView(View['IFTSaveDialogPresenter', Gtk.Window]):
    STYLE = '''
    .small-pad {
         min-height: 0px;
         min-width: 0px;
         padding: 6px 4px 6px 4px;
    }

    .small-combobox .combo {
        min-height: 0px;
        min-width: 0px;
    }

    .ift-analysis-saver-view-footer-button {
Пример #22
0
from collections import OrderedDict
from enum import Enum

from gi.repository import Gtk, Gdk

from opendrop.app.common.image_acquisition import image_acquisition_cs
from opendrop.app.common.wizard import wizard_cs, WizardModel
from opendrop.mvp import ComponentSymbol, View, Presenter
from opendrop.widgets.yes_no_dialog import YesNoDialog
from .image_processing import conan_image_processing_cs
from .model import ConanSession
from .results import conan_results_cs

conan_root_cs = ComponentSymbol()  # type: ComponentSymbol[Gtk.Widget]


@conan_root_cs.view()
class ConanRootView(View['ConanRootPresenter', Gtk.Widget]):
    def _do_init(self) -> Gtk.Widget:
        self._window = Gtk.Window(
            title='Contact Angle',
            window_position=Gtk.WindowPosition.CENTER,
            width_request=800,
            height_request=600,
        )

        _, wizard_area = self.new_component(
            wizard_cs.factory(
                controller=self.presenter.wizard_controller,
                titles=OrderedDict([
                    (
Пример #23
0
import math
from typing import Optional

from gi.repository import Gtk

from opendrop.app.common.footer.results import results_footer_cs, ResultsFooterStatus
from opendrop.app.common.wizard import WizardPageControls
from opendrop.app.conan.analysis_saver import ConanAnalysisSaverOptions, conan_save_dialog_cs
from opendrop.app.conan.results.graphs import graphs_cs
from opendrop.app.conan.results.individual.component import individual_cs
from opendrop.mvp import ComponentSymbol, View, Presenter
from opendrop.utility.bindable import BoxBindable
from opendrop.widgets.yes_no_dialog import YesNoDialog
from .model import ConanResultsModel

conan_results_cs = ComponentSymbol()  # type: ComponentSymbol[Gtk.Widget]


@conan_results_cs.view(options=['footer_area'])
class ConanResultsView(View['ConanResultsPresenter', Gtk.Widget]):
    def _do_init(self, footer_area: Gtk.Grid) -> Gtk.Widget:
        self._widget = Gtk.Grid()

        frame = Gtk.Frame(margin=10, label_xalign=0.5)
        frame.show()
        self._widget.attach(frame, 0, 1, 1, 1)

        self._stack = Gtk.Stack()
        self._stack.show()
        frame.add(self._stack)
Пример #24
0
#
# OpenDrop is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE.  See the GNU General Public License for more details.  You
# should have received a copy of the GNU General Public License along
# with this software.  If not, see <https://www.gnu.org/licenses/>.

from gi.repository import Gtk, Gdk, GObject

from opendrop.app.common.image_acquirer import LocalStorageAcquirer
from opendrop.mvp import ComponentSymbol, Presenter, View
from opendrop.utility.bindable.gextension import GObjectPropertyBindable
from opendrop.widgets.file_chooser_button import FileChooserButton
from opendrop.widgets.float_entry import FloatEntry

local_storage_cs = ComponentSymbol()  # type: ComponentSymbol[Gtk.Widget]


@local_storage_cs.view()
class LocalStorageView(View['LocalStoragePresenter', Gtk.Widget]):
    STYLE = '''
    .small-pad {
         min-height: 0px;
         min-width: 0px;
         padding: 6px 4px 6px 4px;
    }

    .error {
        color: red;
        border: 1px solid red;
    }
Пример #25
0
import math
from typing import Sequence, Tuple

from gi.repository import Gtk
from matplotlib import ticker
from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvas
from matplotlib.figure import Figure

from opendrop.mvp import ComponentSymbol, View, Presenter
from .model import GraphsModel

graphs_cs = ComponentSymbol()  # type: ComponentSymbol[Gtk.Widget]


@graphs_cs.view()
class GraphsView(View['GraphsPresenter', Gtk.Widget]):
    def _do_init(self) -> Gtk.Widget:
        self._widget = Gtk.Stack(margin=5)

        self._waiting_placeholder = Gtk.Label()
        self._waiting_placeholder.set_markup('<b>No data</b>')
        self._widget.add(self._waiting_placeholder)

        figure = Figure(tight_layout=True)

        self._figure_canvas = FigureCanvas(figure)
        self._figure_canvas.props.hexpand = True
        self._figure_canvas.props.vexpand = True
        self._widget.add(self._figure_canvas)

        self._left_angle_axes = figure.add_subplot(2, 1, 1)
Пример #26
0
from typing import Any, Tuple

from gi.repository import Gtk, Gdk

from opendrop.app import keyboard
from opendrop.app.common.image_processing.image_processor import ImageProcessorPluginViewContext
from opendrop.mvp import ComponentSymbol, View, Presenter
from opendrop.utility.bindablegext import GObjectPropertyBindable
from opendrop.utility.geometry import Vector2, Line2
from opendrop.widgets.render.objects import Line
from .model import DefineLinePluginModel

define_line_plugin_cs = ComponentSymbol()  # type: ComponentSymbol[None]


@define_line_plugin_cs.view(
    options=['view_context', 'tool_id', 'color', 'z_index'])
class DefineLinePluginView(View['DefineLinePluginPresenter', None]):
    def _do_init(
        self,
        view_context: ImageProcessorPluginViewContext,
        tool_id: Any,
        color: Tuple[float, float, float],
        z_index: int,
    ) -> None:
        self._view_context = view_context
        self._tool_ref = view_context.get_tool_item(tool_id)

        view_context.render.connect(
            'cursor-up-event',
            lambda render, pos: self.presenter.cursor_up(pos),
Пример #27
0
from typing import Optional, Any

import numpy as np

from opendrop.app.common.image_processing.image_processor import ImageProcessorPluginViewContext
from opendrop.app.common.image_processing.plugins.preview import AcquirerController, ImageSequenceAcquirerController, \
    image_sequence_navigator_cs
from opendrop.mvp import ComponentSymbol, View, Presenter
from opendrop.utility.geometry import Rect2
from opendrop.utility.gmisc import pixbuf_from_array
from opendrop.widgets.render.objects import PixbufFill, Polyline, MaskFill
from .model import ConanPreviewPluginModel

conan_preview_plugin_cs = ComponentSymbol()  # type: ComponentSymbol[None]


@conan_preview_plugin_cs.view(options=['view_context', 'z_index'])
class ConanPreviewPluginView(View['ConanPreviewPluginPresenter', None]):
    def _do_init(self, view_context: ImageProcessorPluginViewContext, z_index: int) -> None:
        self._view_context = view_context
        self._render = self._view_context.render

        self._image_sequence_navigator_cid = None  # type: Optional[Any]

        self._background_ro = PixbufFill(
            z_index=z_index,
        )
        self._render.add_render_object(self._background_ro)

        self._foreground_detection_ro = MaskFill(
            color=(0.5, 0.5, 1.0, 0.5),
Пример #28
0
# OpenDrop is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE.  See the GNU General Public License for more details.  You
# should have received a copy of the GNU General Public License along
# with this software.  If not, see <https://www.gnu.org/licenses/>.

from gi.repository import Gtk

from opendrop.app.common.footer.linearnav import linear_navigator_footer_cs
from opendrop.app.common.wizard import WizardPageControls
from opendrop.mvp import ComponentSymbol, View, Presenter
from opendrop.utility.bindable.gextension import GObjectPropertyBindable
from opendrop.widgets.float_entry import FloatEntry
from .model import PhysicalParametersModel

physical_parameters_cs = ComponentSymbol()  # type: ComponentSymbol[Gtk.Widget]


@physical_parameters_cs.view(options=['footer_area'])
class PhysicalParametersView(View['PhysicalParametersPresenter', Gtk.Widget]):
    def _do_init(self, footer_area: Gtk.Grid) -> Gtk.Widget:
        self._widget = Gtk.Grid(margin=20, row_spacing=10, column_spacing=10)

        # Label widgets
        inner_density_lbl = Gtk.Label('Inner density (kg/m³):', xalign=0)
        self._widget.attach(inner_density_lbl, 0, 0, 1, 1)

        outer_density_lbl = Gtk.Label('Outer density (kg/m³):', xalign=0)
        self._widget.attach(outer_density_lbl, 0, 1, 1, 1)

        needle_width_lbl = Gtk.Label('Needle diameter (mm):', xalign=0)
Пример #29
0
from typing import MutableMapping, Mapping, Any

from gi.repository import Gtk, Gdk, GObject

from opendrop.mvp import ComponentSymbol, View, Presenter
from opendrop.utility.bindable import Bindable

sidebar_cs = ComponentSymbol()  # type: ComponentSymbol[Gtk.Widget]


@sidebar_cs.view(options=['titles'])
class SidebarView(View['SidebarPresenter', Gtk.Widget]):
    STYLE = '''
    .wizard-sidebar {
        background-color: GAINSBORO;
        border-right: 1px solid SILVER;
        padding: 15px;
    }
    '''

    _STYLE_PROV = Gtk.CssProvider()
    _STYLE_PROV.load_from_data(bytes(STYLE, 'utf-8'))
    Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(),
                                             _STYLE_PROV,
                                             Gtk.STYLE_PROVIDER_PRIORITY_USER)

    class _SidebarTitleLabel(Gtk.Label):
        def __init__(self, label: str, **options) -> None:
            super().__init__(label=label, xalign=0, **options)
            self._label = label