MainDialog.cpp 3.7 KB
Newer Older
jcaceres's avatar
jcaceres committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//
// File: MainDialog.cpp
// Created by: cc <cc@cmn42.Stanford.EDU>
// Created on: Sun Mar  2 10:20:41 2003
//

#include "MainDialog.h"
#include "qapplication.h"
#include "qslider.h"
#include "qcombobox.h"
#include "qradiobutton.h"
#include "ThreadCommEvent.h"
#include <qlabel.h>
#include <qlayout.h>
jcaceres's avatar
jcaceres committed
15
//#include <qwt_slider.h>
16

jcaceres's avatar
jcaceres committed
17
18
MainDialog::MainDialog (QWidget * parent, const char *name):
MainWindow (parent, name)	// generated by designer
jcaceres's avatar
jcaceres committed
19
{
jcaceres's avatar
jcaceres committed
20
  //	plot = new StripChart (plotFrame);
jcaceres's avatar
jcaceres committed
21
22
//	plot->setAxisScale(0,0.0,0.1);
//	plot->setAxisScale(1,0.0,0.1);
jcaceres's avatar
jcaceres committed
23
  //plot->resize (300, 300);
jcaceres's avatar
jcaceres committed
24
25
26
27
28
29
30
31

connect ((QObject *) goButton, SIGNAL (toggled (bool)),
		 SLOT (goThreads (bool)));
	goButton->setChecked (false);
	
}

void
jcaceres's avatar
jcaceres committed
32
33
MainDialog::init(StreamBD *s)
{
jcaceres's avatar
jcaceres committed
34
35
	QString tmp;
	QTextOStream (&tmp) << "sampleRate " << s->args->sampleRate;
jcaceres's avatar
jcaceres committed
36
	sampleRateTextLabel->setText (tmp); tmp = "";
jcaceres's avatar
jcaceres committed
37
	QTextOStream (&tmp) << "netHarpStrings " << s->args->netHarpStrings;
jcaceres's avatar
jcaceres committed
38
	netHarpStringsTextLabel->setText (tmp); tmp = "";
jcaceres's avatar
jcaceres committed
39
	QTextOStream (&tmp) << "audioChannels " << s->args->audioChannels;
jcaceres's avatar
jcaceres committed
40
	audioChannelsTextLabel->setText (tmp); tmp = "";
jcaceres's avatar
jcaceres committed
41
	QTextOStream (&tmp) << "runFifo " << s->args->runFifo;
jcaceres's avatar
jcaceres committed
42
	runFifoTextLabel->setText (tmp); tmp = "";
jcaceres's avatar
jcaceres committed
43
	QTextOStream (&tmp) << "audioDeviceID " << s->args->audioDeviceID;
jcaceres's avatar
jcaceres committed
44
	audioDeviceIDTextLabel->setText (tmp); tmp = "";
jcaceres's avatar
jcaceres committed
45
	QTextOStream (&tmp) << "netInQInPackets " << s->args->networkInputQueueLengthInPackets;
jcaceres's avatar
jcaceres committed
46
	netInQInPacketsTextLabel->setText (tmp); tmp = "";
jcaceres's avatar
jcaceres committed
47
	QTextOStream (&tmp) << "redundancy " << s->args->redundancy;
jcaceres's avatar
jcaceres committed
48
	redundancyTextLabel->setText (tmp); tmp = "";
jcaceres's avatar
jcaceres committed
49
	QTextOStream (&tmp) << "audioInQInAudioBufs " << s->args->audioInputQueueLengthInAudioBuffers;
jcaceres's avatar
jcaceres committed
50
	audioInQInAudioBufsTextLabel->setText (tmp); tmp = "";
jcaceres's avatar
jcaceres committed
51
	QTextOStream (&tmp) << "framesPerAudioBuffer " << s->args->framesPerAudioBuffer;
jcaceres's avatar
jcaceres committed
52
	framesPerAudioBufferTextLabel->setText (tmp); tmp = "";
jcaceres's avatar
jcaceres committed
53
	QTextOStream (&tmp) << "networkPortOffset " << s->args->networkPortOffset;
jcaceres's avatar
jcaceres committed
54
	networkPortOffsetTextLabel->setText (tmp); tmp = "";
jcaceres's avatar
jcaceres committed
55
	QTextOStream (&tmp) << "runMode " << s->args->runMode;
jcaceres's avatar
jcaceres committed
56
	runModeTextLabel->setText (tmp); tmp = "";
jcaceres's avatar
jcaceres committed
57
	QTextOStream (&tmp) << "secondsBetweenPlucks " << s->args->secondsBetweenPlucks;
jcaceres's avatar
jcaceres committed
58
	secondsBetweenPlucksTextLabel->setText (tmp); tmp = "";
jcaceres's avatar
jcaceres committed
59
	QTextOStream (&tmp) << "lowPassFilterCoeff " << s->args->lowPassFilterCoeff;
jcaceres's avatar
jcaceres committed
60
	lowPassFilterCoeffTextLabel->setText (tmp); tmp = "";
jcaceres's avatar
jcaceres committed
61
	QTextOStream (&tmp) << "delayIncBtwnStrings " << s->args->delayIncrementBetweenStrings;
jcaceres's avatar
jcaceres committed
62
	delayIncBtwnStringsTextLabel->setText (tmp); tmp = "";
jcaceres's avatar
jcaceres committed
63
	QTextOStream (&tmp) << "jack " << s->args->jack;
jcaceres's avatar
jcaceres committed
64
	jackTextLabel->setText (tmp);
jcaceres's avatar
jcaceres committed
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103

/*	audioChannels
	runFifo
	audioDeviceID
	networkInputQueueLengthInAudioBuffers
	audioInputQueueLengthInAudioBuffers
	framesPerAudioBuffer
	networkPortOffset
	runMode
	secondsBetweenPlucks
	lowPassFilterCoeff
	delayIncrementBetweenStrings
	jack
*/
 s->cmd(this);
 //		addThread (s);
 //s->start();
}

MainDialog::~MainDialog ()
{
}

void
MainDialog::goThreads (bool go)
{
	if (go)
	{
		emit startThread ();
	}
	else
	{
		emit stopThread ();
		emit joinThread ();
	}
}

void
MainDialog::addThread (QObject * t)
jcaceres's avatar
jcaceres committed
104
/* append thread to mythreads list */
jcaceres's avatar
jcaceres committed
105
106
{
	mythreads.append (t);
jcaceres's avatar
jcaceres committed
107
108
109
	connect (this, SIGNAL (startThread ()), t, SLOT (go ()));
	connect (this, SIGNAL (stopThread ()), t, SLOT (stop ()));
	connect (this, SIGNAL (joinThread ()), t, SLOT (join ()));
jcaceres's avatar
jcaceres committed
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
}

void
MainDialog::closeEvent (QCloseEvent * e)
{
	while (qApp->hasPendingEvents ())
		qApp->processEvents ();
	e->accept ();
}

  /// the Receiving widget

void
MainDialog::customEvent (QCustomEvent * e)
{
jcaceres's avatar
jcaceres committed
125
	if (e->type () == QEvent::User + 117)
jcaceres's avatar
jcaceres committed
126
127
	{
		ThreadCommEvent *ce = (ThreadCommEvent *) e;
jcaceres's avatar
jcaceres committed
128
129
130
		//if (ce->val0 () > 0.0) plot->setV1 (ce->val0 ());
		//if (ce->val0 () > 0.0) plot->dpy();
		//if (ce->val1 () > 0.0) plot->setV2 (ce->val1 ());
jcaceres's avatar
jcaceres committed
131
132
	}
}