comparison widgets/ItemEditDialog.cpp @ 904:e0f08e108064 cxx11

Move to using double rather than float for floating-point calculations (float only for storage); more build fixes
author Chris Cannam
date Mon, 09 Mar 2015 12:02:10 +0000
parents 44675ab217a3
children 4a578a360011
comparison
equal deleted inserted replaced
903:1757933ce5a7 904:e0f08e108064
26 #include <QDialogButtonBox> 26 #include <QDialogButtonBox>
27 27
28 #include <float.h> // for FLT_MIN/MAX 28 #include <float.h> // for FLT_MIN/MAX
29 29
30 30
31 ItemEditDialog::ItemEditDialog(int sampleRate, int options, 31 ItemEditDialog::ItemEditDialog(sv_samplerate_t sampleRate, int options,
32 QString valueUnits, QWidget *parent) : 32 QString valueUnits, QWidget *parent) :
33 QDialog(parent), 33 QDialog(parent),
34 m_sampleRate(sampleRate), 34 m_sampleRate(sampleRate),
35 m_defaultFrame(0), 35 m_defaultFrame(0),
36 m_defaultDuration(0), 36 m_defaultDuration(0),
74 m_frameTimeSpinBox = new QSpinBox; 74 m_frameTimeSpinBox = new QSpinBox;
75 m_frameTimeSpinBox->setMaximum(INT_MAX); 75 m_frameTimeSpinBox->setMaximum(INT_MAX);
76 m_frameTimeSpinBox->setSuffix(tr(" frames")); 76 m_frameTimeSpinBox->setSuffix(tr(" frames"));
77 subgrid->addWidget(m_frameTimeSpinBox, subrow, 1, 1, 2); 77 subgrid->addWidget(m_frameTimeSpinBox, subrow, 1, 1, 2);
78 connect(m_frameTimeSpinBox, SIGNAL(valueChanged(int)), 78 connect(m_frameTimeSpinBox, SIGNAL(valueChanged(int)),
79 this, SLOT(frameTimeChanged(int))); 79 this, SLOT(frameTimeChanged(sv_frame_t)));
80 80
81 ++subrow; 81 ++subrow;
82 82
83 m_realTimeSecsSpinBox = new QSpinBox; 83 m_realTimeSecsSpinBox = new QSpinBox;
84 m_realTimeSecsSpinBox->setMaximum(999999); 84 m_realTimeSecsSpinBox->setMaximum(999999);
105 m_frameDurationSpinBox = new QSpinBox; 105 m_frameDurationSpinBox = new QSpinBox;
106 m_frameDurationSpinBox->setMaximum(INT_MAX); 106 m_frameDurationSpinBox->setMaximum(INT_MAX);
107 m_frameDurationSpinBox->setSuffix(tr(" frames")); 107 m_frameDurationSpinBox->setSuffix(tr(" frames"));
108 subgrid->addWidget(m_frameDurationSpinBox, subrow, 1, 1, 2); 108 subgrid->addWidget(m_frameDurationSpinBox, subrow, 1, 1, 2);
109 connect(m_frameDurationSpinBox, SIGNAL(valueChanged(int)), 109 connect(m_frameDurationSpinBox, SIGNAL(valueChanged(int)),
110 this, SLOT(frameDurationChanged(int))); 110 this, SLOT(frameDurationChanged(sv_frame_t)));
111 111
112 ++subrow; 112 ++subrow;
113 113
114 m_realDurationSecsSpinBox = new QSpinBox; 114 m_realDurationSecsSpinBox = new QSpinBox;
115 m_realDurationSecsSpinBox->setMaximum(999999); 115 m_realDurationSecsSpinBox->setMaximum(999999);
191 connect(cancel, SIGNAL(clicked()), this, SLOT(reject())); 191 connect(cancel, SIGNAL(clicked()), this, SLOT(reject()));
192 m_resetButton->setEnabled(false); 192 m_resetButton->setEnabled(false);
193 } 193 }
194 194
195 void 195 void
196 ItemEditDialog::setFrameTime(int frame) 196 ItemEditDialog::setFrameTime(sv_frame_t frame)
197 { 197 {
198 if (!m_frameTimeSpinBox) return; 198 if (!m_frameTimeSpinBox) return;
199 199
200 RealTime rt(RealTime::frame2RealTime(frame, m_sampleRate)); 200 RealTime rt(RealTime::frame2RealTime(frame, m_sampleRate));
201 m_realTimeSecsSpinBox->setValue(rt.sec); 201 m_realTimeSecsSpinBox->setValue(rt.sec);
203 m_frameTimeSpinBox->setValue(frame); 203 m_frameTimeSpinBox->setValue(frame);
204 m_defaultFrame = frame; 204 m_defaultFrame = frame;
205 m_resetButton->setEnabled(false); 205 m_resetButton->setEnabled(false);
206 } 206 }
207 207
208 int 208 sv_frame_t
209 ItemEditDialog::getFrameTime() const 209 ItemEditDialog::getFrameTime() const
210 { 210 {
211 return m_frameTimeSpinBox->value(); 211 return m_frameTimeSpinBox->value();
212 } 212 }
213 213
222 { 222 {
223 return RealTime::frame2RealTime(getFrameTime(), m_sampleRate); 223 return RealTime::frame2RealTime(getFrameTime(), m_sampleRate);
224 } 224 }
225 225
226 void 226 void
227 ItemEditDialog::setFrameDuration(int duration) 227 ItemEditDialog::setFrameDuration(sv_frame_t duration)
228 { 228 {
229 if (!m_frameDurationSpinBox) return; 229 if (!m_frameDurationSpinBox) return;
230 230
231 RealTime rt(RealTime::frame2RealTime(duration, m_sampleRate)); 231 RealTime rt(RealTime::frame2RealTime(duration, m_sampleRate));
232 m_realDurationSecsSpinBox->setValue(rt.sec); 232 m_realDurationSecsSpinBox->setValue(rt.sec);
234 m_frameDurationSpinBox->setValue(duration); 234 m_frameDurationSpinBox->setValue(duration);
235 m_defaultDuration = duration; 235 m_defaultDuration = duration;
236 m_resetButton->setEnabled(false); 236 m_resetButton->setEnabled(false);
237 } 237 }
238 238
239 int 239 sv_frame_t
240 ItemEditDialog::getFrameDuration() const 240 ItemEditDialog::getFrameDuration() const
241 { 241 {
242 return m_frameDurationSpinBox->value(); 242 return m_frameDurationSpinBox->value();
243 } 243 }
244 244
285 { 285 {
286 return m_textField->text(); 286 return m_textField->text();
287 } 287 }
288 288
289 void 289 void
290 ItemEditDialog::frameTimeChanged(int i) 290 ItemEditDialog::frameTimeChanged(sv_frame_t i)
291 { 291 {
292 m_realTimeSecsSpinBox->blockSignals(true); 292 m_realTimeSecsSpinBox->blockSignals(true);
293 m_realTimeUSecsSpinBox->blockSignals(true); 293 m_realTimeUSecsSpinBox->blockSignals(true);
294 294
295 RealTime rt(RealTime::frame2RealTime(i, m_sampleRate)); 295 RealTime rt(RealTime::frame2RealTime(i, m_sampleRate));
304 void 304 void
305 ItemEditDialog::realTimeSecsChanged(int i) 305 ItemEditDialog::realTimeSecsChanged(int i)
306 { 306 {
307 RealTime rt = getRealTime(); 307 RealTime rt = getRealTime();
308 rt.sec = i; 308 rt.sec = i;
309 int frame = RealTime::realTime2Frame(rt, m_sampleRate); 309 sv_frame_t frame = RealTime::realTime2Frame(rt, m_sampleRate);
310 m_frameTimeSpinBox->setValue(frame); 310 m_frameTimeSpinBox->setValue(frame);
311 m_resetButton->setEnabled(true); 311 m_resetButton->setEnabled(true);
312 } 312 }
313 313
314 void 314 void
315 ItemEditDialog::realTimeUSecsChanged(int i) 315 ItemEditDialog::realTimeUSecsChanged(int i)
316 { 316 {
317 RealTime rt = getRealTime(); 317 RealTime rt = getRealTime();
318 rt.nsec = i * 1000; 318 rt.nsec = i * 1000;
319 int frame = RealTime::realTime2Frame(rt, m_sampleRate); 319 sv_frame_t frame = RealTime::realTime2Frame(rt, m_sampleRate);
320 m_frameTimeSpinBox->setValue(frame); 320 m_frameTimeSpinBox->setValue(frame);
321 m_resetButton->setEnabled(true); 321 m_resetButton->setEnabled(true);
322 } 322 }
323 323
324 void 324 void
325 ItemEditDialog::frameDurationChanged(int i) 325 ItemEditDialog::frameDurationChanged(sv_frame_t i)
326 { 326 {
327 m_realDurationSecsSpinBox->blockSignals(true); 327 m_realDurationSecsSpinBox->blockSignals(true);
328 m_realDurationUSecsSpinBox->blockSignals(true); 328 m_realDurationUSecsSpinBox->blockSignals(true);
329 329
330 RealTime rt(RealTime::frame2RealTime(i, m_sampleRate)); 330 RealTime rt(RealTime::frame2RealTime(i, m_sampleRate));
339 void 339 void
340 ItemEditDialog::realDurationSecsChanged(int i) 340 ItemEditDialog::realDurationSecsChanged(int i)
341 { 341 {
342 RealTime rt = getRealDuration(); 342 RealTime rt = getRealDuration();
343 rt.sec = i; 343 rt.sec = i;
344 int frame = RealTime::realTime2Frame(rt, m_sampleRate); 344 sv_frame_t frame = RealTime::realTime2Frame(rt, m_sampleRate);
345 m_frameDurationSpinBox->setValue(frame); 345 m_frameDurationSpinBox->setValue(frame);
346 m_resetButton->setEnabled(true); 346 m_resetButton->setEnabled(true);
347 } 347 }
348 348
349 void 349 void
350 ItemEditDialog::realDurationUSecsChanged(int i) 350 ItemEditDialog::realDurationUSecsChanged(int i)
351 { 351 {
352 RealTime rt = getRealDuration(); 352 RealTime rt = getRealDuration();
353 rt.nsec = i * 1000; 353 rt.nsec = i * 1000;
354 int frame = RealTime::realTime2Frame(rt, m_sampleRate); 354 sv_frame_t frame = RealTime::realTime2Frame(rt, m_sampleRate);
355 m_frameDurationSpinBox->setValue(frame); 355 m_frameDurationSpinBox->setValue(frame);
356 m_resetButton->setEnabled(true); 356 m_resetButton->setEnabled(true);
357 } 357 }
358 358
359 void 359 void