Esempio n. 1
0
    def _setup_gui(self):
        """Create the gui for the widget."""
        self._show_average_rotation_radio = QtGui.QRadioButton("Average rot")
        self._show_average_rotation_radio.setChecked(True)
        self._show_single_rotation_radio = QtGui.QRadioButton("Single rot")

        layout = QtGui.QVBoxLayout()
        layout.addWidget(self._show_average_rotation_radio)
        layout.addWidget(self._show_single_rotation_radio)
        self._show_average_rotation_radio.clicked.connect(
            partial(self.set_rotation_type,
                    rotation_type=ROTATION_TYPE.average))
        self._show_single_rotation_radio.clicked.connect(
            partial(self.set_rotation_type,
                    rotation_type=ROTATION_TYPE.single))

        self._rotation_image_number_box = QtGui.QSpinBox()
        self._rotation_image_number_box.setRange(-1, 10000)

        self._single_slice_widget = convenient_widgets.IntegerControll(0)
        self._single_slice_widget.valueChanged.connect(self.set_image_number)

        layout.addWidget(self._single_slice_widget)

        self._widget.setLayout(layout)
        self._single_slice_widget.hide()
Esempio n. 2
0
    def __init__(self, data, parent):
        super(SliceViewer, self).__init__()
        self._data = data
        self._lut = None
        self._actors = {}
        self._camera = None

        #self._slice_generator = SliceGenerator(self._data.get_image_side(), self._data.get_curvature())
        #self._workspace = QtGui.QWorkspace()
        self._widget = QtGui.QWidget(parent)
        self._vtk_widget = QVTKRenderWindowInteractor(self._widget)
        self._vtk_widget.SetInteractorStyle(
            vtk.vtkInteractorStyleRubberBandPick())
        #self._vtk_widget = QtGui.QPushButton("Foo", parent=self._widget)
        layout = QtGui.QVBoxLayout()
        #layout.addWidget(self._workspace)
        layout.addWidget(self._vtk_widget)
        #self._workspace.addWindow(self._vtk_widget)
        self._widget.setLayout(layout)
        # self._vtk_widget.Initialize()
        # self._vtk_widget.Start()
        self._renderer = vtk.vtkRenderer()
        self._renderer.SetDraw(0)
        self._vtk_render_window = self._vtk_widget.GetRenderWindow()
        self._vtk_render_window.AddRenderer(self._renderer)
Esempio n. 3
0
File: viewer.py Progetto: FXIhub/emc
    def _setup_actions(self):
        """Setup actions to be used in menues etc."""
        self._actions = {}

        #exit
        self._actions["exit"] = QtGui.QAction("Exit", self)
        self._actions["exit"].setShortcut("Ctrl+Q")
        self._actions["exit"].triggered.connect(exit)

        #save image
        self._actions["save image"] = QtGui.QAction("Save image", self)
        self._actions["save image"].triggered.connect(self._on_save_image)
Esempio n. 4
0
def get_matplotlib_widget():
    """Returns four objects: A widget, a figure, a canvas an mpl_toolbar."""
    widget = QtGui.QWidget()
    fig = Figure((5., 4.))
    canvas = FigureCanvas(fig)
    canvas.setParent(widget)
    mpl_toolbar = NavigationToolbar(canvas, widget)
    layout = QtGui.QVBoxLayout()
    layout.addWidget(canvas)
    layout.addWidget(mpl_toolbar)
    widget.setLayout(layout)
    return widget, fig, canvas, mpl_toolbar
Esempio n. 5
0
File: viewer.py Progetto: FXIhub/emc
    def _setup_module_select(self):
        """Create a drop down menu for selecting modules. Returns a layout containing it."""
        self._module_box = QtGui.QComboBox()
        self._module_box.activated.connect(self._select_module)
        # self._module_box.activated.connect(self._view_stack.setCurrentIndex)
        # self._module_box.activated.connect(self._controll_stack.setCurrentIndex)

        label = QtGui.QLabel("Display module: ")
        layout = QtGui.QHBoxLayout()
        layout.addWidget(label)
        layout.addWidget(self._module_box)
        layout.addStretch()
        return layout
Esempio n. 6
0
File: viewer.py Progetto: FXIhub/emc
    def _setup_gui(self):
        """Setup the entire gui of the program"""
        self._view_stack = QtGui.QStackedWidget(self)
        self._controll_stack = QtGui.QStackedWidget(self)

        layout = QtGui.QVBoxLayout()
        layout.addWidget(self._view_stack)
        layout.addLayout(self._setup_module_select())

        common_controll_group = QtGui.QGroupBox("Common controlls")
        common_controll_dummy_layout = QtGui.QHBoxLayout()
        common_controll_dummy_layout.addWidget(self._common_controll)
        common_controll_group.setLayout(common_controll_dummy_layout)
        layout.addWidget(common_controll_group)

        module_controll_group = QtGui.QGroupBox("Module controlls")
        module_controll_dummy_layout = QtGui.QHBoxLayout()
        module_controll_dummy_layout.addWidget(self._controll_stack)
        module_controll_group.setLayout(module_controll_dummy_layout)
        layout.addWidget(module_controll_group)

        size_policy_large = self._view_stack.sizePolicy()
        size_policy_large.setVerticalStretch(1)
        self._view_stack.setSizePolicy(size_policy_large)


        # module_controll_group = QtGui.QGroupBox("Module controlls")
        # module_controll_group.setWidget(self._common_controll)
        # layout.addWidget(self.module_cocntroll_group)

        self._central_widget = QtGui.QWidget()
        self._central_widget.setLayout(layout)
        self.setCentralWidget(self._central_widget)
Esempio n. 7
0
File: viewer.py Progetto: FXIhub/emc
 def _setup_dir_chooser(self):
     """Return a directory cooser layout."""
     work_dir_label = QtGui.QLabel("Dir:")
     file_system_completer = QtGui.QCompleter()
     self._file_system_model = QtGui.QFileSystemModel(file_system_completer)
     #file_system_model.setRootPath('/')
     self._file_system_model.setFilter(QtCore.QDir.Dirs | QtCore.QDir.Hidden)
     file_system_completer.setModel(self._file_system_model)
     self._work_dir_edit = QtGui.QLineEdit(os.getcwd())
     self._work_dir_edit.setCompleter(file_system_completer)
     self._work_dir_edit.editingFinished.connect(self.on_work_dir_changed)
     work_dir_layout = QtGui.QHBoxLayout()
     work_dir_layout.addWidget(work_dir_label)
     work_dir_layout.addWidget(self._work_dir_edit)
     return work_dir_layout
Esempio n. 8
0
    def _setup_gui(self):
        """Create the gui for the widget."""
        view_type_radio_surface = QtGui.QRadioButton("Isosurface plot")
        view_type_radio_slice = QtGui.QRadioButton("Slice plot")
        view_type_radio_slice.setChecked(True)
        view_type_layout = QtGui.QVBoxLayout()
        view_type_layout.addWidget(view_type_radio_surface)
        view_type_layout.addWidget(view_type_radio_slice)
        view_type_radio_surface.clicked.connect(
            partial(self.set_view_type, VIEW_TYPE.surface))
        view_type_radio_slice.clicked.connect(
            partial(self.set_view_type, VIEW_TYPE.slice))

        #surface controll setup
        self._surface_level_slider = QtGui.QSlider(QtCore.Qt.Horizontal)
        self._surface_level_slider.setTracking(True)
        self._surface_level_slider.setRange(1, self._slider_length)

        def on_slider_changed(self, slider_level):
            """Handles the signal from a surface level slider change."""
            # surface_level = slider_level/float(cls._slider_length)
            # surface_level = self._slider_length/(float(slider_level))
            # surface_level = ((numpy.exp(float(slider_level)/float(self._slider_length))-1.) /
            #                  (numpy.exp(1.)-1.))
            surface_level = (float(slider_level) /
                             float(self._slider_length))**3
            self._viewer.set_surface_level(surface_level)

        self._surface_level_slider.valueChanged.connect(
            partial(on_slider_changed, self))
        self._surface_level_slider.blockSignals(True)
        self._surface_level_slider.setSliderPosition(self._slider_length *
                                                     INIT_SURFACE_LEVEL)

        # slice controll widget setup
        log_scale_box = QtGui.QCheckBox()
        log_scale_label = QtGui.QLabel('Log Scale')
        log_scale_layout = QtGui.QHBoxLayout()
        log_scale_layout.addWidget(log_scale_label)
        log_scale_layout.addWidget(log_scale_box)
        log_scale_layout.addStretch()
        log_scale_box.stateChanged.connect(self.set_log_scale)
        self._log_scale_widget = QtGui.QWidget()
        self._log_scale_widget.setLayout(log_scale_layout)
        #self._log_scale_widget.hide()

        layout = QtGui.QVBoxLayout()
        layout.addLayout(view_type_layout)
        layout.addWidget(self._surface_level_slider)
        layout.addWidget(self._log_scale_widget)
        #layout.addStretch()
        self._widget.setLayout(layout)
        self._widget.setFixedHeight(120)
Esempio n. 9
0
File: viewer.py Progetto: FXIhub/emc
 def _setup_gui(self):
     """Create the widget gui."""
     layout = QtGui.QVBoxLayout()
     layout.addLayout(self._setup_dir_chooser())
     layout.addWidget(self._setup_iteration_chooser())
     layout.addWidget(self._setup_message_board())
     self.setLayout(layout)
Esempio n. 10
0
File: viewer.py Progetto: FXIhub/emc
def main():
    """Launch program"""
    app = QtGui.QApplication(['Controll window'])
    icon_path = os.path.join(os.path.split(os.path.realpath(__file__))[0], "resources/icon_slices.png")
    app.setWindowIcon(QtGui.QIcon(icon_path))
    app.setApplicationName(PROGRAM_NAME)

    #app = QtGui.QApplication.instance()

    program = StartMain()
    program.show()
    program.initialize()
    #app.setActiveWindow(program)
    program.raise_()

    sys.exit(app.exec_())
Esempio n. 11
0
 def __init__(self, common_controll, viewer, data):
     super(Controll, self).__init__()
     self._common_controll = common_controll
     self._viewer = viewer
     self._data = data
     self._widget = QtGui.QWidget()
     self._active = False
Esempio n. 12
0
File: viewer.py Progetto: FXIhub/emc
 def on_work_dir_changed(self):
     """Handle an attempt to select a new work dir in the
     _work_dir_edit text editor"""
     new_dir = self._work_dir_edit.text()
     self._file_system_model.setRootPath(new_dir)
     if not os.path.isdir(new_dir):
         palette = self._work_dir_edit.palette()
         palette.setColor(QtGui.QPalette.Base, QtGui.QColor(255, 50, 50))
         self._work_dir_edit.setPalette(palette)
         return
     new_dir = self._work_dir_edit.text()
     os.chdir(new_dir)
     palette = self._work_dir_edit.palette()
     palette.setColor(QtGui.QPalette.Base, QtGui.QColor(255, 255, 255))
     self._work_dir_edit.setPalette(palette)
     self._read_run_info()
     self.dirChanged.emit(new_dir)
     self.post_message("Read new directory {0}".format(new_dir))
Esempio n. 13
0
    def _setup_gui(self):
        """Create the gui and set layout."""
        self._spin_box = QtGui.QSpinBox()
        self._update_spinbox_max(self._max_lim)
        #self._spin_box.setRange(self._min_lim, self._max_lim)
        self._spin_box.setValue(self._value)

        self._max_label = QtGui.QLabel("")
        self._update_max_label(self._max_lim)

        self._prev_button = QtGui.QPushButton("Previous")
        self._next_button = QtGui.QPushButton("Next")

        layout = QtGui.QHBoxLayout()
        layout.addWidget(self._spin_box)
        layout.addWidget(self._max_label)
        layout.addWidget(self._prev_button)
        layout.addWidget(self._next_button)

        self.setLayout(layout)
Esempio n. 14
0
    def _setup_gui(self):
        """Create the gui for the widget."""
        layout = QtGui.QVBoxLayout()
        self._image_index_chooser = convenient_widgets.IntegerControll(
            0, max_lim=self._data.get_number_of_images())
        self._image_index_chooser.valueChanged.connect(self.set_image)
        self._data.number_of_images_changed.connect(
            self._image_index_chooser.set_max)
        layout.addWidget(self._image_index_chooser)

        log_scale_box = QtGui.QCheckBox()
        log_scale_label = QtGui.QLabel("Log Scale")
        log_scale_layout = QtGui.QHBoxLayout()
        log_scale_layout.addWidget(log_scale_box)
        log_scale_layout.addWidget(log_scale_label)
        log_scale_layout.addStretch()
        log_scale_box.stateChanged.connect(self.set_log_scale)
        layout.addLayout(log_scale_layout)

        self._widget.setLayout(layout)
Esempio n. 15
0
    def _setup_gui(self):
        """Create the gui for the widget."""
        self._widget = QtGui.QWidget()
        layout = QtGui.QHBoxLayout()

        #pattern list
        self._pattern_list = QtGui.QListWidget()
        self._pattern_list.itemChanged.connect(self._on_list_item_changed)

        #self._set_number_of_images(self._data.get_number_of_images())

        # for i in range(self._data.get_number_of_images()):
        #     this_item = QtGui.QListWidgetItem("Image %d" % i, self._pattern_list)
        #     this_item.setFlags(this_item.flags() | QtCore.Qt.ItemIsUserCheckable)
        #     this_item.setData(QtCore.Qt.CheckStateRole, QtCore.Qt.Unchecked)

        self._check_all_box = QtGui.QCheckBox()
        check_all_layout = QtGui.QHBoxLayout()
        check_all_layout.addWidget(self._check_all_box)
        check_all_layout.addWidget(QtGui.QLabel("Check all"))
        check_all_layout.addStretch()

        self._check_all_box.stateChanged.connect(self._on_check_all_changed)

        layout.addWidget(self._pattern_list)
        layout.addLayout(check_all_layout)
        self._widget.setLayout(layout)
Esempio n. 16
0
 def _set_number_of_images(self, number_of_images):
     old_blocking_state = self._pattern_list.blockSignals(True)
     if number_of_images > self._pattern_list.count():
         for i in range(self._pattern_list.count(), number_of_images):
             this_item = QtGui.QListWidgetItem("Image {0}".format(i),
                                               self._pattern_list)
             this_item.setFlags(this_item.flags()
                                | QtCore.Qt.ItemIsUserCheckable)
             this_item.setData(QtCore.Qt.CheckStateRole,
                               QtCore.Qt.Unchecked)
     elif number_of_images < self._pattern_list.count():
         for __ in range(number_of_images, self._pattern_list.count()):
             self._pattern_list.removeItemWidget(
                 self._pattern_list.item(number_of_images))
     self._pattern_list.blockSignals(old_blocking_state)
Esempio n. 17
0
    def __init__(self, parent=None):
        super(ModelmapViewer, self).__init__(parent)

        self._surface_algorithm = None
        self._surface_actor = None
        self._volume_scalars = None
        self._volume = None
        self._surface_level = 0.5
        self._color = (0.2, 0.8, 0.2)
        self._planes = []
        self._volume_max = 0.
        self._volume_numpy = None

        self._vtk_widget = QVTKRenderWindowInteractor(
            self._widget)  # _vtk_widget is actually the RenderWindowInteractor
        self._vtk_widget.SetInteractorStyle(
            vtk.vtkInteractorStyleRubberBandPick())
        layout = QtGui.QVBoxLayout()
        layout.addWidget(self._vtk_widget)

        self._widget.setLayout(layout)
        #self._vtk_widget.Initialize()
        #self._vtk_widget.Start()

        self._renderer = vtk.vtkRenderer()
        self._renderer.SetDraw(0)
        self._vtk_render_window = self._vtk_widget.GetRenderWindow()
        self._vtk_render_window.AddRenderer(self._renderer)
        #self._renderer = self._vtk_widget.GetRenderWindow().GetRenderer()
        self._lut = vtk_tools.get_lookup_table(0.,
                                               1.,
                                               log=False,
                                               colorscale="jet")

        self._create_volume_map()
        #self._setup_slices()
        #self._setup_surface()

        white = (1., 1., 1.)
        self._renderer.SetBackground(white)
Esempio n. 18
0
    def __init__(self, parent=None):
        super(RotationViewer, self).__init__()
        #self._widget = QtGui.QWidget(parent)
        self._vtk_widget = QVTKRenderWindowInteractor(
            self._widget)  # _vtk_widget is actually the RenderWindowInteractor
        self._vtk_widget.SetInteractorStyle(
            vtk.vtkInteractorStyleRubberBandPick())

        #self._vtk_widget.Initialize()
        layout = QtGui.QVBoxLayout()
        layout.addWidget(self._vtk_widget)
        self._widget.setLayout(layout)

        self._renderer = vtk.vtkRenderer()
        self._renderer.SetDraw(0)
        self._vtk_widget.GetRenderWindow().AddRenderer(self._renderer)

        #self._mlab_widget = embedded_mayavi.MlabWidget()
        self._setup_done = False
        self._points = None
        self._default_sphere_n = 10
        self._sphere = vtk_tools.SphereMap(self._default_sphere_n)
        self._renderer.AddViewProp(self._sphere.get_actor())
        self._renderer.SetBackground(1., 1., 1.)
Esempio n. 19
0
File: viewer.py Progetto: FXIhub/emc
 def _setup_message_board(self):
     self._message_board = QtGui.QLabel("Empty board")
     self._message_board.setWordWrap(True)
     self._message_board.setFrameStyle(QtGui.QFrame.Panel)
     return self._message_board
Esempio n. 20
0
File: viewer.py Progetto: FXIhub/emc
 def on_read_error(self):
     """Handle read error emits"""
     palette = self._work_dir_edit.palette()
     palette.setColor(QtGui.QPalette.Base, QtGui.QColor(255, 250, 50))
     self._work_dir_edit.setPalette(palette)
Esempio n. 21
0
 def __init__(self, parent=None):
     super(Viewer, self).__init__(parent)
     self._widget = QtGui.QWidget(parent)
     self._active = False