Exemple #1
0
    def create_slice_dock(self):
        widget = QWidget()
        dock = QDockWidget("Slice", self)
        dock.setAllowedAreas(Qt.TopDockWidgetArea | Qt.BottomDockWidgetArea
                             | Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
        self.addDockWidget(Qt.BottomDockWidgetArea, dock)
        layout = QGridLayout(widget)
        self.slice_index_spin_box = QSpinBox()
        index_max = self.map_.measurement.param.axis3.get_length()
        self.slice_index_spin_box.setRange(0, index_max - 1)

        slice_slider = QSlider(Qt.Horizontal)
        slice_slider.setRange(0, index_max - 1)
        self.connect(self.slice_index_spin_box, SIGNAL("valueChanged(int)"),
                     self.set_slice_index)
        self.connect(slice_slider, SIGNAL("valueChanged(int)"),
                     self.slice_index_spin_box.setValue)
        self.connect(self.slice_index_spin_box, SIGNAL("valueChanged(int)"),
                     slice_slider.setValue)
        self.slice_value_spin_box = QDoubleSpinBox()
        scale = self.map_.measurement.param.axis3.get_scale()
        self.slice_value_spin_box.setRange(scale.min(), scale.max())
        self.slice_value_spin_box.setValue(scale[0])
        self.connect(self.slice_value_spin_box, SIGNAL("valueChanged(double)"),
                     self.set_slice_value)
        unit = self.map_.measurement.param.axis3.unit
        self.slice_value_spin_box.setSuffix(unit)
        layout.addWidget(slice_slider, 0, 0)
        layout.addWidget(self.slice_index_spin_box, 0, 1)
        layout.addWidget(self.slice_value_spin_box, 0, 2)
        dock.setWidget(widget)
Exemple #2
0
    def create_slice_dock(self):
        widget = QWidget()
        dock = QDockWidget("Slice", self)
        dock.setAllowedAreas(Qt.TopDockWidgetArea | Qt.BottomDockWidgetArea |
                             Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
        self.addDockWidget(Qt.BottomDockWidgetArea, dock)
        layout = QGridLayout(widget)
        self.slice_index_spin_box = QSpinBox()
        index_max = self.map_.measurement.param.axis3.get_length()
        self.slice_index_spin_box.setRange(0, index_max-1 )

        slice_slider = QSlider(Qt.Horizontal)
        slice_slider.setRange(0, index_max-1)
        self.connect(self.slice_index_spin_box, SIGNAL("valueChanged(int)"),
                     self.set_slice_index)
        self.connect(slice_slider, SIGNAL("valueChanged(int)"),
                     self.slice_index_spin_box.setValue)
        self.connect(self.slice_index_spin_box, SIGNAL("valueChanged(int)"),
                     slice_slider.setValue)
        self.slice_value_spin_box = QDoubleSpinBox()
        scale = self.map_.measurement.param.axis3.get_scale()
        self.slice_value_spin_box.setRange(scale.min(),scale.max())
        self.slice_value_spin_box.setValue(scale[0])
        self.connect(self.slice_value_spin_box, SIGNAL("valueChanged(double)"),
                     self.set_slice_value)
        unit = self.map_.measurement.param.axis3.unit
        self.slice_value_spin_box.setSuffix(unit)
        layout.addWidget(slice_slider, 0, 0)
        layout.addWidget(self.slice_index_spin_box, 0, 1)
        layout.addWidget(self.slice_value_spin_box, 0, 2)
        dock.setWidget(widget)
Exemple #3
0
class MapWindow(ImageWindow):
    def set_map(self, item):
        self.map_ = item

    def wheelEvent(self, event):

        if self.map_ is None:
            return

        # from qt example
        num_degrees = event.delta() / 8.
        num_steps = int(round(num_degrees / 15.))

        if event.orientation() == Qt.Vertical:
            try:  # maybe the map has not been set
                new_index = self.map_.get_current_index() + num_steps
                max_index = self.map_.measurement.param.axis3.get_length()
                if new_index > max_index:
                    new_index = max_index
                new_index = int(new_index)
                self.slice_index_spin_box.setValue(new_index)
            except NameError:
                pass

    def set_slice_index(self, index):
        self.map_.set_slice_index(index)
        self.replot()

        scale = self.map_.measurement.param.axis3.get_scale()
        value = scale[index]
        self.slice_value_spin_box.blockSignals(True)
        self.slice_value_spin_box.setValue(value)
        self.slice_value_spin_box.blockSignals(False)

    def set_slice_value(self, value):
        self.map_.set_slice_value(value)
        self.replot()

        index = self.map_.get_current_index()
        self.slice_index_spin_box.blockSignals(True)
        self.slice_index_spin_box.setValue(index)
        self.slice_index_spin_box.blockSignals(False)

    def replot(self):
        plot = self.get_plot()
        plot.replot()
        self.update_cross_sections()
        contrast = self.get_contrast_panel()
        if contrast is not None:
            contrast.histogram.selection_changed(plot)
            #self.set_contrast_range(min, max)

    def create_slice_dock(self):
        widget = QWidget()
        dock = QDockWidget("Slice", self)
        dock.setAllowedAreas(Qt.TopDockWidgetArea | Qt.BottomDockWidgetArea
                             | Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
        self.addDockWidget(Qt.BottomDockWidgetArea, dock)
        layout = QGridLayout(widget)
        self.slice_index_spin_box = QSpinBox()
        index_max = self.map_.measurement.param.axis3.get_length()
        self.slice_index_spin_box.setRange(0, index_max - 1)

        slice_slider = QSlider(Qt.Horizontal)
        slice_slider.setRange(0, index_max - 1)
        self.connect(self.slice_index_spin_box, SIGNAL("valueChanged(int)"),
                     self.set_slice_index)
        self.connect(slice_slider, SIGNAL("valueChanged(int)"),
                     self.slice_index_spin_box.setValue)
        self.connect(self.slice_index_spin_box, SIGNAL("valueChanged(int)"),
                     slice_slider.setValue)
        self.slice_value_spin_box = QDoubleSpinBox()
        scale = self.map_.measurement.param.axis3.get_scale()
        self.slice_value_spin_box.setRange(scale.min(), scale.max())
        self.slice_value_spin_box.setValue(scale[0])
        self.connect(self.slice_value_spin_box, SIGNAL("valueChanged(double)"),
                     self.set_slice_value)
        unit = self.map_.measurement.param.axis3.unit
        self.slice_value_spin_box.setSuffix(unit)
        layout.addWidget(slice_slider, 0, 0)
        layout.addWidget(self.slice_index_spin_box, 0, 1)
        layout.addWidget(self.slice_value_spin_box, 0, 2)
        dock.setWidget(widget)
Exemple #4
0
class MapWindow(ImageWindow):

    def set_map(self, item):
        self.map_ = item

    def wheelEvent(self, event):

        if self.map_ is None:
            return

        # from qt example
        num_degrees = event.delta() / 8.
        num_steps = int(round(num_degrees / 15.))

        if event.orientation() == Qt.Vertical :
            try: # maybe the map has not been set
                new_index = self.map_.get_current_index() + num_steps
                max_index = self.map_.measurement.param.axis3.get_length()
                if new_index > max_index:
                    new_index = max_index
                new_index = int(new_index)
                self.slice_index_spin_box.setValue(new_index)
            except NameError:
                pass

    def set_slice_index(self, index):
        self.map_.set_slice_index(index)
        self.replot()

        scale = self.map_.measurement.param.axis3.get_scale()
        value = scale[index]
        self.slice_value_spin_box.blockSignals(True)
        self.slice_value_spin_box.setValue(value)
        self.slice_value_spin_box.blockSignals(False)

    def set_slice_value(self, value):
        self.map_.set_slice_value(value)
        self.replot()

        index = self.map_.get_current_index()
        self.slice_index_spin_box.blockSignals(True)
        self.slice_index_spin_box.setValue(index)
        self.slice_index_spin_box.blockSignals(False)

    def replot(self):
        plot = self.get_plot()
        plot.replot()
        self.update_cross_sections()
        contrast = self.get_contrast_panel()
        if contrast is not None:
            contrast.histogram.selection_changed(plot)
            #self.set_contrast_range(min, max)

    def create_slice_dock(self):
        widget = QWidget()
        dock = QDockWidget("Slice", self)
        dock.setAllowedAreas(Qt.TopDockWidgetArea | Qt.BottomDockWidgetArea |
                             Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
        self.addDockWidget(Qt.BottomDockWidgetArea, dock)
        layout = QGridLayout(widget)
        self.slice_index_spin_box = QSpinBox()
        index_max = self.map_.measurement.param.axis3.get_length()
        self.slice_index_spin_box.setRange(0, index_max-1 )

        slice_slider = QSlider(Qt.Horizontal)
        slice_slider.setRange(0, index_max-1)
        self.connect(self.slice_index_spin_box, SIGNAL("valueChanged(int)"),
                     self.set_slice_index)
        self.connect(slice_slider, SIGNAL("valueChanged(int)"),
                     self.slice_index_spin_box.setValue)
        self.connect(self.slice_index_spin_box, SIGNAL("valueChanged(int)"),
                     slice_slider.setValue)
        self.slice_value_spin_box = QDoubleSpinBox()
        scale = self.map_.measurement.param.axis3.get_scale()
        self.slice_value_spin_box.setRange(scale.min(),scale.max())
        self.slice_value_spin_box.setValue(scale[0])
        self.connect(self.slice_value_spin_box, SIGNAL("valueChanged(double)"),
                     self.set_slice_value)
        unit = self.map_.measurement.param.axis3.unit
        self.slice_value_spin_box.setSuffix(unit)
        layout.addWidget(slice_slider, 0, 0)
        layout.addWidget(self.slice_index_spin_box, 0, 1)
        layout.addWidget(self.slice_value_spin_box, 0, 2)
        dock.setWidget(widget)