diff --git a/PreCourlis/ui/profile_dialog_base.ui b/PreCourlis/ui/profile_dialog_base.ui index cfcbe3c0ff116d1e2afa1a5bf3e417c58bf75d2d..d4d1fcc2e834a4573221f7c9060dbd82d16b2b6a 100644 --- a/PreCourlis/ui/profile_dialog_base.ui +++ b/PreCourlis/ui/profile_dialog_base.ui @@ -323,7 +323,14 @@ </widget> </item> <item> - <widget class="QgsSpinBox" name="secondarySectionsOffsetSpinBox"/> + <widget class="QgsDoubleSpinBox" name="secondarySectionsOffsetSpinBox"> + <property name="minimumSize"> + <size> + <width>120</width> + <height>26</height> + </size> + </property> + </widget> </item> </layout> </item> diff --git a/PreCourlis/widgets/graph_widget.py b/PreCourlis/widgets/graph_widget.py index 002edae32a586bb664277d7dd045be1ac366fbf9..564b2164fc948e2b84e048f79dbac743173a473a 100644 --- a/PreCourlis/widgets/graph_widget.py +++ b/PreCourlis/widgets/graph_widget.py @@ -119,7 +119,7 @@ class GraphWidget(FigureCanvas): for section in self.secondary_sections: self.draw_section( section, - self.secondary_sections_offset / 10.0, + self.secondary_sections_offset, color=self.secondary_sections_color, linewidth=0.5, ) diff --git a/PreCourlis/widgets/profile_dialog.py b/PreCourlis/widgets/profile_dialog.py index 4bd405de7826205c149da61f9d5f8c7afd79b829..5bb023b1534daa6250d612f8d8087124a658b63f 100644 --- a/PreCourlis/widgets/profile_dialog.py +++ b/PreCourlis/widgets/profile_dialog.py @@ -193,8 +193,8 @@ class ProfileDialog(QtWidgets.QDialog, FORM_CLASS): self.points_selection.open() # Secondary sections offset slider and spin boxinit - self.secondarySectionsOffsetSlider.setRange(-1000, 1000) - self.secondarySectionsOffsetSpinBox.setRange(-1000, 1000) + self.secondarySectionsOffsetSlider.setRange(-100000, 100000) + self.secondarySectionsOffsetSpinBox.setRange(-1000.0, 1000.0) self.secondarySectionsOffsetSlider.setSingleStep(1) self.secondarySectionsOffsetSlider.setPageStep(10) @@ -205,6 +205,7 @@ class ProfileDialog(QtWidgets.QDialog, FORM_CLASS): self.secondarySectionsOffsetSpinBox.setValue( round(self.graphWidget.secondary_sections_offset) ) + self.secondarySectionsOffsetSpinBox.setClearValue(0) self.secondarySectionsOffsetSlider.valueChanged.connect( self.handle_secondary_sections_offset_slider_value_changed @@ -461,6 +462,14 @@ class ProfileDialog(QtWidgets.QDialog, FORM_CLASS): self.set_section(index) self.compute_buffered_sections() + spinBoxOffset = 2 * round( + self.current_section.distances[-1] - self.current_section.distances[0] + ) + sliderOffset = spinBoxOffset * 100 + + self.secondarySectionsOffsetSlider.setRange(-sliderOffset, sliderOffset) + self.secondarySectionsOffsetSpinBox.setRange(-spinBoxOffset, spinBoxOffset) + def set_section(self, index): if index == -1: self.graphWidget.clear() @@ -775,11 +784,12 @@ class ProfileDialog(QtWidgets.QDialog, FORM_CLASS): ) def handle_secondary_sections_offset_slider_value_changed(self, value): - self.secondarySectionsOffsetSpinBox.setValue(value) - self.graphWidget.set_secondary_sections_offset(value) + self.secondarySectionsOffsetSpinBox.setValue(round(value / 100.0, 2)) def handle_secondary_sections_offset_spin_box_value_changed(self, value): - self.secondarySectionsOffsetSlider.setValue(value) + if round(self.secondarySectionsOffsetSlider.value() / 100.0, 2) != value: + self.secondarySectionsOffsetSlider.setValue(round(value * 100)) + self.graphWidget.set_secondary_sections_offset(value) def set_layer_color_button_color(self, color):