10 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
22 #define FGFAIL(_expr_) AJA_sERROR (AJA_DebugUnit_DemoCapture, AJAFUNC << ": " << _expr_)
23 #define FGWARN(_expr_) AJA_sWARNING(AJA_DebugUnit_DemoCapture, AJAFUNC << ": " << _expr_)
24 #define FGDBG(_expr_) AJA_sDEBUG (AJA_DebugUnit_DemoCapture, AJAFUNC << ": " << _expr_)
25 #define FGNOTE(_expr_) AJA_sNOTICE (AJA_DebugUnit_DemoCapture, AJAFUNC << ": " << _expr_)
26 #define FGINFO(_expr_) AJA_sINFO (AJA_DebugUnit_DemoCapture, AJAFUNC << ": " << _expr_)
33 : QDialog (parent, flags)
35 if (objectName ().isEmpty ())
36 setObjectName (QString::fromUtf8 (
"Dialog"));
38 mBoardChoiceCombo =
new QComboBox;
41 mInputButtonGroup =
new QButtonGroup ();
43 for (
unsigned ndx (0); ndx < 8; ndx++)
45 for (
unsigned ndx (0); ndx < 4; ndx++)
51 mWithAudioCheckBox =
new QCheckBox (
"With Audio",
this);
52 mCheckFor4kCheckBox =
new QCheckBox (
"Check for 4K Input",
this);
53 mCheckFixedReference =
new QCheckBox (
"Fixed Reference",
this);
60 mFrameGrabber->
SetDeviceIndex (mBoardChoiceCombo->currentIndex ());
63 QVBoxLayout * layout (
new QVBoxLayout);
64 layout->addWidget (mBoardChoiceCombo);
65 layout->addWidget (mVideoPreviewWidget);
67 #if defined (INCLUDE_AJACC)
68 QVBoxLayout * bottomLeftLayout (
new QVBoxLayout);
69 bottomLeftLayout->setContentsMargins (0, 0, 0, 0);
71 for (
QButtonIterator iter (mInputButtonGroup->buttons()); iter.hasNext (); )
72 bottomLeftLayout->addWidget (iter.next());
74 bottomLeftLayout->addWidget (mWithAudioCheckBox);
75 bottomLeftLayout->addWidget (mCheckFor4kCheckBox);
76 bottomLeftLayout->addStretch (1);
78 QVBoxLayout * bottomRightLayout (
new QVBoxLayout);
79 bottomRightLayout->setContentsMargins (0, 0, 0, 0);
81 mCaptionButtonGroup =
new QButtonGroup ();
83 for (
unsigned ndx (1); ndx <= 8; ndx++)
84 mCaptionButtonGroup->addButton (
new QRadioButton (QString (
"%1%2").arg (
string (ndx < 5 ?
"CC" :
"TXT").c_str(),
string (1,
char ((ndx < 5 ? ndx : ndx - 4) +
'0')).c_str())),
88 for (
QButtonIterator iter (mCaptionButtonGroup->buttons()); iter.hasNext (); )
89 bottomRightLayout->addWidget (iter.next());
91 QHBoxLayout * bottomLayout (
new QHBoxLayout);
92 bottomLayout->setContentsMargins (0, 0, 0, 0);
94 bottomLayout->addLayout (bottomLeftLayout);
95 bottomLayout->addLayout (bottomRightLayout);
96 layout->addLayout (bottomLayout);
97 #else // !defined (INCLUDE_AJACC)
98 for (
QButtonIterator iter(mInputButtonGroup->buttons()); iter.hasNext(); )
99 layout->addWidget (iter.next());
100 layout->addWidget (mWithAudioCheckBox);
101 layout->addWidget (mCheckFor4kCheckBox);
102 layout->addWidget (mCheckFixedReference);
103 #endif // !defined (INCLUDE_AJACC)
105 layout->addStretch (1);
108 connect (mBoardChoiceCombo, SIGNAL(currentIndexChanged(
int)),
this, SLOT(RequestDeviceChange(
const int)));
109 connect (mInputButtonGroup, SIGNAL(idReleased(
int)),
this, SLOT(inputChanged(
int)));
110 connect (mWithAudioCheckBox, SIGNAL(stateChanged(
int)),
this, SLOT(withAudioChanged(
int)));
111 connect (mCheckFixedReference, SIGNAL(toggled(
bool)),
this, SLOT(fixedRefChanged(
bool)));
112 connect (mCheckFor4kCheckBox, SIGNAL(stateChanged(
int)),
this, SLOT(checkFor4kChanged(
int)));
113 connect (mFrameGrabber, SIGNAL(newFrame(
const QImage&,
bool)), mVideoPreviewWidget, SLOT(updateFrame(
const QImage &,
bool)));
114 connect (mFrameGrabber, SIGNAL(newStatusString(
const QString)), mVideoPreviewWidget, SLOT(updateStatusString(
const QString)));
115 #if defined (INCLUDE_AJACC)
116 connect (mFrameGrabber, SIGNAL (captionScreenChanged (
const ushort *)), mVideoPreviewWidget, SLOT (updateCaptionScreen (
const ushort *)));
117 connect (mCaptionButtonGroup, SIGNAL (buttonReleased (
int)), mFrameGrabber, SLOT (changeCaptionChannel (
int)));
118 #endif // defined (INCLUDE_AJACC)
121 mFrameGrabber->start ();
122 mTimerID = startTimer (100);
133 delete mFrameGrabber;
138 void NTV2QtPreview::RequestDeviceChange (
const int inDeviceIndexNum)
143 FGNOTE(
"Device changed to " << inDeviceIndexNum);
148 void NTV2QtPreview::inputChanged (
int inputRadioButtonId)
154 {
FGNOTE(
"No device at " << mBoardChoiceCombo->currentIndex());
return;}
166 else FGWARN(
"input source " << inputRadioButtonId <<
" unsupported by device");
171 void NTV2QtPreview::withAudioChanged (
int state)
173 mFrameGrabber->
SetWithAudio (state == Qt::Checked ?
true :
false);
178 void NTV2QtPreview::fixedRefChanged (
bool checked)
185 void NTV2QtPreview::checkFor4kChanged (
int state)
192 void NTV2QtPreview::updateInputs (
void)
194 CNTV2Card ntv2Card (mBoardChoiceCombo->currentIndex());
195 if (ntv2Card.IsOpen())
197 for (
QButtonIterator iter(mInputButtonGroup->buttons()); iter.hasNext(); )
199 QRadioButton * pButton (
reinterpret_cast<QRadioButton*
>(iter.next()));
203 const bool hasInputSource (ntv2Card.features().CanDoInputSource(inputSource));
204 const string videoFormatStr (hasInputSource ? ::
NTV2VideoFormatToString(ntv2Card.GetInputVideoFormat(inputSource)) :
"");
205 const QString buttonLabel (QString(
"%1 %2").arg(::
NTV2InputSourceToString(inputSource,
true).c_str(), videoFormatStr.empty() ?
"No Detected Input" : videoFormatStr.c_str()));
206 pButton->setText(buttonLabel);
207 pButton->setEnabled(hasInputSource);
210 #if defined (INCLUDE_AJACC)
211 const bool hasCustomAnc (mDevice.features().CanDoCustomAnc());
212 for (
QButtonIterator iter (mCaptionButtonGroup->buttons()); iter.hasNext(); )
213 iter.next()->setEnabled(hasCustomAnc);
214 #endif // defined (INCLUDE_AJACC)
219 void NTV2QtPreview::timerEvent (QTimerEvent * event)
221 if (event->timerId() == mTimerID)
224 QWidget::timerEvent(event);
228 void NTV2QtPreview::devicesChanged (
void)
234 mBoardChoiceCombo->clear();
235 for (
ULWord ndx(0); ndx < 100; ndx++)
239 mBoardChoiceCombo->addItem(tr(device.
GetDisplayName().c_str()), QVariant());
241 {mBoardChoiceCombo->addItem(tr(
"No Devices Found"));
break;}
245 mBoardChoiceCombo->setCurrentIndex(0);
249 void NTV2QtPreview::PnpCallback (
AJAPnpMessage inMessage,
void * pUserData)
255 pMainWindow->devicesChanged();