@@ -18,7 +18,7 @@ TwoPointBezier::TwoPointBezier(QWidget *parent) :
18
18
19
19
// Initializes IO
20
20
ui->input ->hideKeyWidget ();
21
- ui->input ->setTitle (" input " );
21
+ ui->input ->setTitle (" Input " );
22
22
ui->input ->setPlaceholderText (" Variant Input (2 Offsets)" );
23
23
24
24
// Initializes CustomPlots
@@ -39,7 +39,6 @@ TwoPointBezier::TwoPointBezier(QWidget *parent) :
39
39
connect (ui->customPlot , SIGNAL (addBezierEvent (QVector2D)),
40
40
this , SLOT (addBezier (QVector2D)));
41
41
42
-
43
42
// Activate SV to initialize as SV
44
43
useSV ();
45
44
resetSettings ();
@@ -66,7 +65,6 @@ void TwoPointBezier::initToolTips() {
66
65
" Hover your mouse over and press keys indicated at the top of the plot to create points.\n "
67
66
" If it isn't working, click on the plot to focus it." );
68
67
ui->customPlot ->setToolTipDuration (1000 );
69
- ui->vertZoom ->setToolTip (" Adjusts the zoom of the plot" );
70
68
}
71
69
72
70
QVector<QVector2D> TwoPointBezier::createPlot () {
@@ -119,15 +117,20 @@ void TwoPointBezier::plotFunction() {
119
117
120
118
customPlot->graph (0 )->setData (x, y, false );
121
119
// Set color based on SV or BPM
122
- customPlot->graph (0 )->setPen (ui->svRadio ->isChecked () ?
123
- Color::GREEN : Color::RED);
124
-
125
- // Update range
120
+ QPen pen;
121
+ pen.setColor (ui->svRadio ->isChecked () ? Color::GREEN : Color::RED);
122
+ pen.setWidth (2 );
123
+ customPlot->graph (0 )->setPen (pen);
124
+ customPlot->graph (0 )->setBrush (ui->svRadio ->isChecked () ?
125
+ ColorFade::GREEN : ColorFade::RED);
126
+
127
+ // Updates domain
126
128
auto xMinMax = std::minmax_element (x.begin (), x.end ());
127
- auto yMinMax = std::minmax_element (y.begin (), y.end ());
128
- // qDebug() << *xMinMax.first << "," << *xMinMax.second;
129
129
updatePlotDomain (*xMinMax.first ,*xMinMax.second );
130
- updatePlotRange (*yMinMax.first , *yMinMax.second );
130
+
131
+ // Updates range
132
+ // auto yMinMax = std::minmax_element(y.begin(), y.end());
133
+ // updatePlotRange(*yMinMax.first, *yMinMax.second);
131
134
}
132
135
void TwoPointBezier::plotBezier () {
133
136
auto customPlot = ui->customPlot ;
@@ -141,9 +144,13 @@ void TwoPointBezier::plotBezier() {
141
144
}
142
145
143
146
customPlot->graph (1 )->setData (xs, ys, false );
144
- customPlot->graph (1 )->setPen (Color::PURPLE);
147
+
148
+ QPen pen;
149
+ pen.setColor (Color::WHITE);
150
+ pen.setWidth (1 );
151
+ customPlot->graph (1 )->setPen (pen);
145
152
customPlot->graph (1 )->setLineStyle (QCPGraph::lsNone);
146
- customPlot->graph (1 )->setScatterStyle (QCPScatterStyle (QCPScatterStyle::ssPlusCircle, 5 ));
153
+ customPlot->graph (1 )->setScatterStyle (QCPScatterStyle (QCPScatterStyle::ssCircle, 10 ));
147
154
customPlot->replot ();
148
155
}
149
156
void TwoPointBezier::plotAnchor () {
@@ -158,20 +165,23 @@ void TwoPointBezier::plotAnchor() {
158
165
}
159
166
160
167
customPlot->graph (2 )->setData (xs, ys, false );
161
- customPlot->graph (2 )->setPen (ColorFade::BLUE);
168
+ QPen pen;
169
+ pen.setColor (Color::BLUE);
170
+ pen.setWidth (1 );
171
+ customPlot->graph (2 )->setPen (pen);
162
172
customPlot->graph (2 )->setLineStyle (QCPGraph::lsImpulse);
163
- customPlot->graph (2 )->setScatterStyle (QCPScatterStyle (QCPScatterStyle::ssTriangleInverted, 5 ));
173
+ customPlot->graph (2 )->setScatterStyle (QCPScatterStyle (QCPScatterStyle::ssCircle, 10 ));
164
174
customPlot->replot ();
165
175
}
166
176
167
177
void TwoPointBezier::warning () {
168
178
if (ui->endOffset ->value () - ui->startOffset ->value () <= 0 )
169
179
ui->startOffset ->setStyleSheet (ColorStyleSheet::RED);
170
- else ui->startOffset ->setStyleSheet (ColorStyleSheet::BLACK );
180
+ else ui->startOffset ->setStyleSheet (ColorStyleSheet::WHITE );
171
181
172
182
if (ui->endOffset ->value () - ui->startOffset ->value () <= ui->interval ->value ())
173
183
ui->interval ->setStyleSheet (ColorStyleSheet::RED);
174
- else ui->interval ->setStyleSheet (ColorStyleSheet::BLACK );
184
+ else ui->interval ->setStyleSheet (ColorStyleSheet::WHITE );
175
185
}
176
186
177
187
void TwoPointBezier::updateAverage (QVector<QVector2D> & pts) {
@@ -185,31 +195,7 @@ void TwoPointBezier::updateAverage(QVector<QVector2D> & pts) {
185
195
}
186
196
187
197
void TwoPointBezier::updatePlotRange (double min, double max){
188
- // Zoom from 10 % to 1000 %
189
- double mean = (max - min) / 2 + min;
190
-
191
- // This calculates zoom, zoom [0.1, 10.0]
192
- double zoom = pow (ZOOM_LIMIT, - double (ui->vertZoom ->value () - ZOOM_DEFAULT) / ZOOM_DEFAULT);
193
- ui->vertZoomLabel ->setText (QString::number (1.0 / zoom, ' f' , 2 ) + " x" );
194
-
195
- // Normalizes the range and multiplies the ends respectively
196
- // A buffer is used to prevent too small of a range
197
- double minRange;
198
- double maxRange;
199
- if (ui->svRadio ->isChecked ()){
200
- minRange = (min - mean - ZOOM_SV_BUFFER) * zoom + mean;
201
- maxRange = (max - mean + ZOOM_SV_BUFFER) * zoom + mean;
202
- } else {
203
- minRange = (min - mean - ZOOM_BPM_BUFFER) * zoom + mean;
204
- maxRange = (max - mean + ZOOM_BPM_BUFFER) * zoom + mean;
205
- }
206
-
207
- // Allow negative for easier bezier bending
208
- // minRange = minRange < 0 ? 0 : minRange;
209
- // if (ui->svRadio->isChecked())
210
- // maxRange = maxRange > SV_MAX ? SV_MAX : maxRange;
211
-
212
- ui->customPlot ->yAxis ->setRange (minRange, maxRange);
198
+ ui->customPlot ->yAxis ->setRange (min, max);
213
199
}
214
200
void TwoPointBezier::updatePlotDomain (double min, double max) {
215
201
ui->customPlot ->xAxis ->setRange (min, max);
@@ -353,15 +339,16 @@ void TwoPointBezier::on_generateButton_clicked() {
353
339
}
354
340
ui->output ->write (generateCode (offsets, values, ui->bpmRadio ->isChecked ()));
355
341
}
356
- void TwoPointBezier::on_vertZoom_valueChanged (int /* unused */ ){ plot (); }
357
342
void TwoPointBezier::on_bpmRadio_clicked () {
358
343
resetSettings ();
359
344
useBPM ();
345
+ updatePlotRange (RANGE_MIN_BPM, RANGE_MAX_BPM);
360
346
plot ();
361
347
}
362
348
void TwoPointBezier::on_svRadio_clicked () {
363
349
resetSettings ();
364
350
useSV ();
351
+ updatePlotRange (RANGE_MIN_SV, RANGE_MAX_SV);
365
352
plot ();
366
353
}
367
354
void TwoPointBezier::on_startOffset_valueChanged (int arg1) {
0 commit comments