Skip to content

Commit

Permalink
Renamed some buttons and fixed zoom/move logic a bit
Browse files Browse the repository at this point in the history
Now when zooming in auto scale it does fixCurrent first
(before this fix it used last fixed scale values which may be unexpected)

Also removed connect to setFixedScale from zoom actions: instead
call setFixedScale in onZoomChanged
  • Loading branch information
NIA committed Jul 23, 2014
1 parent 53facfd commit d5ad3da
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 36 deletions.
48 changes: 24 additions & 24 deletions mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -375,43 +375,23 @@
<item>
<widget class="QGroupBox" name="plotGroup">
<property name="title">
<string>Plot settings</string>
<string>Plot scale</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QRadioButton" name="autoScale">
<property name="text">
<string>Auto scale</string>
<string>Automatic</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="timeInterval">
<property name="suffix">
<string> sec.</string>
</property>
<property name="minimum">
<number>5</number>
</property>
<property name="maximum">
<number>3600</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Time interval:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="fixedScale">
<property name="text">
<string>Fixed scale:</string>
<string>Manual</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -486,7 +466,27 @@
<item row="1" column="1">
<widget class="QPushButton" name="fixNowBtn">
<property name="text">
<string>Fix now</string>
<string>Manual auto</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Time interval:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="timeInterval">
<property name="suffix">
<string> sec.</string>
</property>
<property name="minimum">
<number>5</number>
</property>
<property name="maximum">
<number>3600</number>
</property>
</widget>
</item>
Expand Down
35 changes: 24 additions & 11 deletions seismoreg_ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,21 @@
<source>?</source>
<translation>?</translation>
</message>
<message>
<location filename="mainwindow.ui" line="384"/>
<source>Manual</source>
<translation>Ручной</translation>
</message>
<message>
<location filename="mainwindow.ui" line="391"/>
<source>Automatic</source>
<translation>Авто</translation>
</message>
<message>
<location filename="mainwindow.ui" line="469"/>
<source>Manual auto</source>
<translation>Ручной авто</translation>
</message>
<message>
<location filename="mainwindow.ui" line="579"/>
<source>Time elapsed</source>
Expand Down Expand Up @@ -233,18 +248,17 @@
</message>
<message>
<location filename="mainwindow.ui" line="378"/>
<source>Plot settings</source>
<translation>Настройки графиков</translation>
<source>Plot scale</source>
<oldsource>Plot settings</oldsource>
<translation>Масштаб графиков</translation>
</message>
<message>
<location filename="mainwindow.ui" line="384"/>
<source>Auto scale</source>
<translation>Авто масштаб</translation>
<translation type="vanished">Авто масштаб</translation>
</message>
<message>
<location filename="mainwindow.ui" line="414"/>
<source>Fixed scale:</source>
<translation>Фикс. масштаб:</translation>
<translation type="vanished">Фикс. масштаб:</translation>
</message>
<message>
<location filename="mainwindow.ui" line="329"/>
Expand All @@ -261,19 +275,18 @@
<translation type="vanished">Суффикс (обычно расширение)</translation>
</message>
<message>
<location filename="mainwindow.ui" line="407"/>
<location filename="mainwindow.ui" line="476"/>
<source>Time interval:</source>
<translation>Интервал времени:</translation>
</message>
<message>
<location filename="mainwindow.ui" line="394"/>
<location filename="mainwindow.ui" line="483"/>
<source> sec.</source>
<translation> с.</translation>
</message>
<message>
<location filename="mainwindow.ui" line="489"/>
<source>Fix now</source>
<translation>Фиксировать</translation>
<translation type="vanished">Фиксировать</translation>
</message>
<message>
<location filename="mainwindow.ui" line="611"/>
Expand Down Expand Up @@ -809,7 +822,7 @@
<context>
<name>TimePlot</name>
<message>
<location filename="src/gui/timeplot.cpp" line="220"/>
<location filename="src/gui/timeplot.cpp" line="232"/>
<source>Unequal size of timestamps and items: %1 vs %2</source>
<translation>Неравный размер отсчётов времени и данных: %1 и %2</translation>
</message>
Expand Down
8 changes: 8 additions & 0 deletions src/gui/timeplot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ void TimePlot::zoomOut() {

void TimePlot::zoom(double factor)
{
if ( ! fixedScale ) {
fixCurrent();
}

double mid = (fixedScaleMin + fixedScaleMax) / 2;
double amp = qAbs(fixedScaleMax - fixedScaleMin) / 2;

Expand All @@ -159,6 +163,10 @@ void TimePlot::moveDown() {
}

void TimePlot::move(double factor) {
if ( ! fixedScale ) {
fixCurrent();
}

double delta = (fixedScaleMax - fixedScaleMin)*factor;
fixedScaleMin += delta;
fixedScaleMax += delta;
Expand Down
3 changes: 2 additions & 1 deletion src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ void MainWindow::initPortSettingsAction(QAction * action, QString title, PortSet

void MainWindow::initZoomAction(QAction *action, QToolButton *btn) {
btn->setDefaultAction(action);
connect(action, &QAction::triggered, this, &MainWindow::setFixedScale);
}

void MainWindow::setFixedScale() {
Expand All @@ -465,6 +464,8 @@ void MainWindow::onZoomChanged(double newMin, double newMax) {
ui->fixedScaleMax->blockSignals(false);
ui->fixedScaleMin->blockSignals(false);

setFixedScale();

if (!worker->isStarted()) {
// replot to see the change (when started, it will be replotted when received next data)
for (TimePlot * plot: plots) {
Expand Down

0 comments on commit d5ad3da

Please sign in to comment.