void	CSignalGeneratorDlg::StopRunning ()
{
	// Stop the audio and video output streams immediately
	m_deckLinkOutput->StopScheduledPlayback(0, NULL, 0);
	//
	m_deckLinkOutput->DisableAudioOutput();
	m_deckLinkOutput->DisableVideoOutput();
	
	if (m_videoFrameBlack != NULL)
		m_videoFrameBlack->Release();
	m_videoFrameBlack = NULL;
	
	if (m_videoFrameBars != NULL)
		m_videoFrameBars->Release();
	m_videoFrameBars = NULL;
	
	if (m_audioBuffer != NULL)
		HeapFree(GetProcessHeap(), 0, m_audioBuffer);
	m_audioBuffer = NULL;
	
	// Success; update the UI
	m_running = false;
	m_startButton.SetWindowText(_T("Start"));
	// Re-enable the user interface when stopped
	EnableInterface(TRUE);
}
Exemplo n.º 2
0
void PvDualSourceSample::CreateLayout()
{
    CreateMenu();

    mSource1 = new Source( 0 );
    mSource1Widget = new SourceWidget( "Source 1", mSource1 );
    mSource1->SetWidget( mSource1Widget );

    mSource2 = new Source( 1 );
    mSource2Widget = new SourceWidget( "Source 2", mSource2 );
    mSource2->SetWidget( mSource2Widget );

    QHBoxLayout *lLayout = new QHBoxLayout;
    lLayout->addWidget( mSource1Widget );
    lLayout->addWidget( mSource2Widget );

    QFrame *lMainBox = new QFrame;
    lMainBox->setLayout( lLayout );

    setCentralWidget( lMainBox );
    setWindowTitle( tr( "PvDualSourceSample" ) );
    setWindowIcon( QIcon( QPixmap( ":PvDualSourceSample/res/PvDualSourceSample.ico" ) ) );

    EnableInterface();
}
Exemplo n.º 3
0
void PvDualSourceSample::Connect( PvDeviceInfo *aDeviceInfo )
{
    // Just in case we came here still connected...
    Disconnect();

    // Connect to device using device info
    PvResult lResult = mDevice.Connect( aDeviceInfo );
    if ( !lResult.IsOK() )
    {
        PvMessageBox( this, lResult );
        return;
    }

    Source *lSources[ 2 ] = { mSource1, mSource2 };

    // Open channels
    PvGenEnum *lSourceSelector = mDevice.GetGenParameters()->GetEnum( "SourceSelector" );
    PvGenInteger *lSourceStreamChannel = mDevice.GetGenParameters()->GetInteger( "SourceStreamChannel" );
    if ( lSourceSelector != NULL )
    {
        for ( PvUInt16 i = 0; i < 2; i++ )
        {
            QString lValue;
            lValue.sprintf( "Source%d", i + 1 );

            lSourceSelector->SetValue( lValue.toAscii().data() );

            PvInt64 lChannel = 0;
            lSourceStreamChannel->GetValue( lChannel );

            lResult = lSources[i]->Open( &mDevice, aDeviceInfo->GetIPAddress(), static_cast<PvUInt16>( lChannel ) );
            if ( !lResult.IsOK() )
            {
                PvMessageBox( this, lResult );
                return;
            }
        }
    }
    else
    {
        // No source selector, if transmitter assume 1 on channel 0
        lResult = mSource1->Open( &mDevice, aDeviceInfo->GetIPAddress(), 0 );
        if ( !lResult.IsOK() )
        {
            PvMessageBox( this, lResult );
            return;
        }
    }

    // Sync the UI with our new status
    EnableInterface();
}
Exemplo n.º 4
0
int ImageSaveDlg::exec()
{

	switch ( mFormat )
	{
	default:
		assert( 0 );
		break;

	case FORMAT_BMP:
		mFormatCombo->setCurrentIndex( 0 );
		break;

	case FORMAT_RAW:
		mFormatCombo->setCurrentIndex( 1 );
		break;
	}

	QVariant lOneOutOf(mOneOutOf);
	mOneOutOfEdit->setText( lOneOutOf.toString() );
	QVariant lMaxRate(mMaxRate);
	mMaxRateEdit->setText( lMaxRate.toString() );
	QVariant lAverageThroughput(mAverageThroughput);
	mAverageThroughputEdit->setText( lAverageThroughput.toString() );
	switch ( mSaveThrottling )
	{
	default:
		assert( 0 );
		break;

	case ONEOUTOF:
		mOneOutOfRadio->setChecked(true);
		break;
	case MAXRATE:
		mMaxRateRadio->setChecked(true);
		break;
	case AVERAGETHROUGHPUT:
		mAverageThroughputRadio->setChecked(true);
		break;
	case NOTHROTTLE:
		mNoThrottleRadio->setChecked(true);
		break;
	}

	mSavePathEdit->setText( mSavePath );

	mSaveEnabledCheck->setChecked( mSaveEnabled );
	EnableInterface();

	return QDialog::exec();
}
Exemplo n.º 5
0
void PvDualSourceSample::Disconnect()
{
    // Close all configuration child windows
    CloseGenWindow( mDeviceBrowser );
    CloseGenWindow( Stream1Browser );
    CloseGenWindow( Stream2Browser );

    if ( mSource1->IsOpened() )
    {
        PvResult lResult = mSource1->Close();
        if ( !lResult.IsOK() )
        {
            PvMessageBox( this, lResult );
        }
    }

    if ( mSource2->IsOpened() )
    {
        PvResult lResult = mSource2->Close();
        if ( !lResult.IsOK() )
        {
            PvMessageBox( this, lResult );
        }
    }

    if ( mDevice.IsConnected() )
    {
        PvResult lResult = mDevice.Disconnect();
        if ( !lResult.IsOK() )
        {
            PvMessageBox( this, lResult );
        }
    }

    mSource1Widget->GetDisplay()->Clear();
    mSource2Widget->GetDisplay()->Clear();

    // Sync the UI with our new status
    EnableInterface();
}
Exemplo n.º 6
0
bool CAutoDestroyer::CreateInterface(bool bSelect)
{
    Ui::CWindow*    pw;
    Math::Point     pos, ddim;
    float       ox, oy, sx, sy;
    CObject*        scrap;

    CAuto::CreateInterface(bSelect);

    if ( !bSelect )  return true;

    pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
    if ( pw == nullptr )  return false;

    ox = 3.0f/640.0f;
    oy = 3.0f/480.0f;
    sx = 33.0f/640.0f;
    sy = 33.0f/480.0f;

    pos.x = ox+sx*0.0f;
    pos.y = oy+sy*0;
    ddim.x = 66.0f/640.0f;
    ddim.y = 66.0f/480.0f;
    pw->CreateGroup(pos, ddim, 106, EVENT_OBJECT_TYPE);

    pos.x = ox+sx*8.00f;
    pos.y = oy+sy*0.25f;
    ddim.x = (33.0f/640.0f)*1.5f;
    ddim.y = (33.0f/480.0f)*1.5f;
    pw->CreateButton(pos, ddim, 12, EVENT_OBJECT_BDESTROY);

    scrap = SearchPlastic();
    EnableInterface(pw, EVENT_OBJECT_BDESTROY, (scrap != 0));

    return true;
}
Exemplo n.º 7
0
bool CAutoDestroyer::EventProcess(const Event &event)
{
    CObject*        scrap;
    Gfx::CPyro*     pyro;
    Math::Vector    pos, speed;
    Math::Point     dim;
    Ui::CWindow*    pw;

    CAuto::EventProcess(event);

    if ( m_engine->GetPause() )  return true;

    if (m_main->GetSelect() == m_object)
    {
        if ( event.type == EVENT_OBJECT_BDESTROY )
        {
            Error err = StartAction(0);
            if ( err != ERR_OK )
                m_displayText->DisplayError(err, m_object);

            return false;
        }
    }

    if ( event.type != EVENT_FRAME )  return true;

    m_progress += event.rTime*m_speed;
    m_timeVirus -= event.rTime;

    if ( m_object->GetVirusMode() )  // contaminated by a virus?
    {
        if ( m_timeVirus <= 0.0f )
        {
            m_timeVirus = 0.1f+Math::Rand()*0.3f;
        }
        return true;
    }

    pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
    if ( m_phase == ADEP_WAIT )
    {
        if ( m_progress >= 1.0f )
        {
            m_phase    = ADEP_WAIT;  // still waiting ...
            m_progress = 0.0f;
            m_speed    = 1.0f/0.5f;
            if (m_main->GetSelect() == m_object)
            {
                scrap = SearchPlastic();
                if ( pw != 0 ) EnableInterface(pw, EVENT_OBJECT_BDESTROY, (scrap != 0));
            }
        }
    } else if ( pw != 0 ) EnableInterface(pw, EVENT_OBJECT_BDESTROY, false);

    if ( m_phase == ADEP_DOWN )
    {
        if ( m_progress >= 0.3f-0.05f && !m_bExplo )
        {
            scrap = SearchPlastic();
            if ( scrap != nullptr )
            {
                pyro = new Gfx::CPyro();
                pyro->Create(Gfx::PT_FRAGT, scrap);
            }
            m_bExplo = true;
        }

        if ( m_progress < 1.0f )
        {
            pos = Math::Vector(0.0f, -10.0f, 0.0f);
            pos.y = -Math::Bounce(m_progress, 0.3f)*10.0f;
            m_object->SetPosition(1, pos);
        }
        else
        {
            m_object->SetPosition(1, Math::Vector(0.0f, -10.0f, 0.0f));
            m_sound->Play(SOUND_REPAIR, m_object->GetPosition(0));

            m_phase    = ADEP_REPAIR;
            m_progress = 0.0f;
            m_speed    = 1.0f/1.0f;
        }
    }

    if ( m_phase == ADEP_REPAIR )
    {
        if ( m_progress < 1.0f )
        {
        }
        else
        {
            m_sound->Play(SOUND_OPEN, m_object->GetPosition(0), 1.0f, 0.8f);

            m_phase    = ADEP_UP;
            m_progress = 0.0f;
            m_speed    = 1.0f/3.0f;
        }
    }

    if ( m_phase == ADEP_UP )
    {
        if ( m_progress < 1.0f )
        {
            pos = Math::Vector(0.0f, -10.0f, 0.0f);
            pos.y = -(1.0f-m_progress)*10.0f;
            m_object->SetPosition(1, pos);
        }
        else
        {
            m_object->SetPosition(1, Math::Vector(0.0f, 0.0f, 0.0f));

            m_phase    = ADEP_WAIT;
            m_progress = 0.0f;
            m_speed    = 1.0f/0.5f;
        }
    }

    return true;
}
Exemplo n.º 8
0
void CAutoFactory::UpdateButton(Ui::CWindow *pw, EventType event, bool bBusy)
{
    bool        bEnable = true;

    EnableInterface(pw, event, !bBusy);

    if ( event == EVENT_OBJECT_FACTORYta )
    {
        bEnable = g_researchDone&RESEARCH_TANK;
    }
    if ( event == EVENT_OBJECT_FACTORYfa )
    {
        bEnable = g_researchDone&RESEARCH_FLY;
    }
    if ( event == EVENT_OBJECT_FACTORYia )
    {
        bEnable = g_researchDone&RESEARCH_iPAW;
    }

    if ( event == EVENT_OBJECT_FACTORYws )
    {
        bEnable = g_researchDone&RESEARCH_SNIFFER;
    }
    if ( event == EVENT_OBJECT_FACTORYts )
    {
        bEnable = ( (g_researchDone&RESEARCH_SNIFFER) &&
                    (g_researchDone&RESEARCH_TANK)    );
    }
    if ( event == EVENT_OBJECT_FACTORYfs )
    {
        bEnable = ( (g_researchDone&RESEARCH_SNIFFER) &&
                    (g_researchDone&RESEARCH_FLY)     );
    }
    if ( event == EVENT_OBJECT_FACTORYis )
    {
        bEnable = ( (g_researchDone&RESEARCH_SNIFFER) &&
                    (g_researchDone&RESEARCH_iPAW)    );
    }

    if ( event == EVENT_OBJECT_FACTORYwc )
    {
        bEnable = g_researchDone&RESEARCH_CANON;
    }
    if ( event == EVENT_OBJECT_FACTORYtc )
    {
        bEnable = ( (g_researchDone&RESEARCH_CANON) &&
                    (g_researchDone&RESEARCH_TANK)  );
    }
    if ( event == EVENT_OBJECT_FACTORYfc )
    {
        bEnable = ( (g_researchDone&RESEARCH_CANON) &&
                    (g_researchDone&RESEARCH_FLY)   );
    }
    if ( event == EVENT_OBJECT_FACTORYic )
    {
        bEnable = ( (g_researchDone&RESEARCH_CANON) &&
                    (g_researchDone&RESEARCH_iPAW)  );
    }

    if ( event == EVENT_OBJECT_FACTORYwi )
    {
        bEnable = g_researchDone&RESEARCH_iGUN;
    }
    if ( event == EVENT_OBJECT_FACTORYti )
    {
        bEnable = ( (g_researchDone&RESEARCH_iGUN) &&
                    (g_researchDone&RESEARCH_TANK) );
    }
    if ( event == EVENT_OBJECT_FACTORYfi )
    {
        bEnable = ( (g_researchDone&RESEARCH_iGUN) &&
                    (g_researchDone&RESEARCH_FLY)  );
    }
    if ( event == EVENT_OBJECT_FACTORYii )
    {
        bEnable = ( (g_researchDone&RESEARCH_iGUN) &&
                    (g_researchDone&RESEARCH_iPAW) );
    }

    if ( event == EVENT_OBJECT_FACTORYrt )
    {
        bEnable = ( (g_researchDone&RESEARCH_THUMP) &&
                    (g_researchDone&RESEARCH_TANK)  );
    }
    if ( event == EVENT_OBJECT_FACTORYrc )
    {
        bEnable = ( (g_researchDone&RESEARCH_PHAZER) &&
                    (g_researchDone&RESEARCH_TANK)   );
    }
    if ( event == EVENT_OBJECT_FACTORYrr )
    {
        bEnable = ( (g_researchDone&RESEARCH_RECYCLER) &&
                    (g_researchDone&RESEARCH_TANK)     );
    }
    if ( event == EVENT_OBJECT_FACTORYrs )
    {
        bEnable = ( (g_researchDone&RESEARCH_SHIELD) &&
                    (g_researchDone&RESEARCH_TANK)   );
    }

    if ( event == EVENT_OBJECT_FACTORYsa )
    {
        bEnable = g_researchDone&RESEARCH_SUBM;
    }

    DeadInterface(pw, event, bEnable);
}
Exemplo n.º 9
0
void
AppView::MessageReceived(BMessage* message)
{
	//PRINT(("AppView::MessageReceived(BMessage*)\n"));

	switch(message->what)
	{
		case SELECTION_CHANGED:
			SelectionChanged();
			break;
		case MSG_APPLY:
			Apply();
			break;
		case MSG_RESET:
			Reset();
			break;
		case START_APPLY:
			m_applying = true;
			m_status_card->SetVisibleItem(INDEX_STATUSBAR);
			m_apply_button->SetEnabled(false);
			m_reset_button->SetEnabled(false);
			m_pick_list_view->MessageReceived(message);
			break;
		case END_APPLY:
			m_applying = false;
			m_status_card->SetVisibleItem(INDEX_BARBERPOLE);
			m_apply_button->SetEnabled(true);
			m_reset_button->SetEnabled(true);
			SelectionChanged();
			EnableInterface();
			m_pick_list_view->MessageReceived(message);
			break;
		case STATUS_BAR_SET_MAX_VALUE:
			int32 maxValue;
			message->FindInt32("maxValue",&maxValue);
			m_status_bar->SetMaxValue(maxValue);
			break;
		case STATUS_BAR_FILE:
		{
			BString file;
			if (message->FindString("file", &file) == B_OK)
			{
				file.Prepend("  ");
				m_status_bar->SetText(file.String());
			}
			break;
		}
		case STATUS_BAR_UPDATE:
			m_status_bar->Update(1);
			break;
		case STATUS_BAR_RESET:
			m_status_bar->Reset("0%","100%");
			break;
		case INVALIDATE_LIST:
			m_list_view->Invalidate();
			m_list_view->SortItems(&AppView::SortFunc);
			break;
		case B_REFS_RECEIVED:
			AddRefs(message);
			break;
		case B_SIMPLE_DATA:
			AddRefs(message);
			break;

		default:
			BView::MessageReceived(message);
	}
}
void	CSignalGeneratorDlg::StartRunning ()
{
	IDeckLinkDisplayMode*	videoDisplayMode = NULL;
	BMDVideoOutputFlags		videoOutputFlags = bmdVideoOutputFlagDefault;
	int						curSelection;
	CString					videoFormatName;

	curSelection = m_videoFormatCombo.GetCurSel();
	m_videoFormatCombo.GetLBText(curSelection, videoFormatName);
	if (videoFormatName.Find(_T(" 3D"), 0) != -1)
		videoOutputFlags = bmdVideoOutputDualStream3D;
	
	// Determine the audio and video properties for the output stream
	m_outputSignal = (OutputSignal)m_outputSignalCombo.GetCurSel();
	m_audioChannelCount = m_audioChannelCombo.GetItemData(m_audioChannelCombo.GetCurSel());
	m_audioSampleDepth = (BMDAudioSampleType)m_audioSampleDepthCombo.GetItemData(m_audioSampleDepthCombo.GetCurSel());
	m_audioSampleRate = bmdAudioSampleRate48kHz;
	//
	// - Extract the IDeckLinkDisplayMode from the display mode popup menu (stashed in the item's tag)
	videoDisplayMode = (IDeckLinkDisplayMode*)m_videoFormatCombo.GetItemDataPtr(m_videoFormatCombo.GetCurSel());
	m_frameWidth = videoDisplayMode->GetWidth();
	m_frameHeight = videoDisplayMode->GetHeight();
	videoDisplayMode->GetFrameRate(&m_frameDuration, &m_frameTimescale);
	// Calculate the number of frames per second, rounded up to the nearest integer.  For example, for NTSC (29.97 FPS), framesPerSecond == 30.
	m_framesPerSecond = (unsigned long)((m_frameTimescale + (m_frameDuration-1))  /  m_frameDuration);
	
	// Set the video output mode
	if (m_deckLinkOutput->EnableVideoOutput(videoDisplayMode->GetDisplayMode(), videoOutputFlags) != S_OK)
		goto bail;

	// Set the audio output mode
	if (m_deckLinkOutput->EnableAudioOutput(bmdAudioSampleRate48kHz, m_audioSampleDepth, m_audioChannelCount, bmdAudioOutputStreamTimestamped) != S_OK)
		goto bail;
	
	// Generate one second of audio tone
	m_audioSamplesPerFrame = (unsigned long)((m_audioSampleRate * m_frameDuration) / m_frameTimescale);
	m_audioBufferSampleLength = (unsigned long)((m_framesPerSecond * m_audioSampleRate * m_frameDuration) / m_frameTimescale);
	m_audioBuffer = HeapAlloc(GetProcessHeap(), 0, (m_audioBufferSampleLength * m_audioChannelCount * (m_audioSampleDepth / 8)));
	if (m_audioBuffer == NULL)
		goto bail;
	FillSine(m_audioBuffer, m_audioBufferSampleLength, m_audioChannelCount, m_audioSampleDepth);
	
	// Generate a frame of black
	m_videoFrameBlack = CreateBlackFrame();
	if (! m_videoFrameBlack)
		goto bail;

	// Generate a frame of colour bars
	m_videoFrameBars = CreateBarsFrame();
	if (! m_videoFrameBars)
		goto bail;

	// Begin video preroll by scheduling a second of frames in hardware
	m_totalFramesScheduled = 0;
	for (unsigned i = 0; i < m_framesPerSecond; i++)
		ScheduleNextFrame(true);
	
	// Begin audio preroll.  This will begin calling our audio callback, which will start the DeckLink output stream.
	m_totalAudioSecondsScheduled = 0;
	if (m_deckLinkOutput->BeginAudioPreroll() != S_OK)
		goto bail;
	
	// Success; update the UI
	m_running = true;
	m_startButton.SetWindowText(_T("Stop"));
	// Disable the user interface while running (prevent the user from making changes to the output signal)
	EnableInterface(FALSE);
	
	return;
	
bail:
	// *** Error-handling code.  Cleanup any resources that were allocated. *** //
	StopRunning();
}
BOOL CSignalGeneratorDlg::OnInitDialog()
{
	bool			success = false;
	
	CDialog::OnInitDialog();
	
	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// Initialize the DeckLink API
	IDeckLinkIterator*			deckLinkIterator = NULL;
	HRESULT						result;
	
	CoInitializeEx(NULL, COINIT_MULTITHREADED);
	result = CoCreateInstance(CLSID_CDeckLinkIterator, NULL, CLSCTX_ALL, IID_IDeckLinkIterator, (void**)&deckLinkIterator);
	if (FAILED(result))
	{
		MessageBox(_T("This application requires the DeckLink drivers installed.\nPlease install the Blackmagic DeckLink drivers to use the features of this application."), _T("Error"));
		goto bail;
	}
	
	// Connect to the first DeckLink instance
	result = deckLinkIterator->Next(&m_deckLink);
	if (result != S_OK)
	{
		MessageBox(_T("This application requires a DeckLink PCI card.\nYou will not be able to use the features of this application until a DeckLink PCI card is installed."), _T("Error"));
		goto bail;
	}
	
	// Obtain the audio/video output interface (IDeckLinkOutput)
	if (m_deckLink->QueryInterface(IID_IDeckLinkOutput, (void**)&m_deckLinkOutput) != S_OK)
		goto bail;
	
	// Provide this class as a delegate to the audio and video output interfaces
	m_deckLinkOutput->SetScheduledFrameCompletionCallback(this);
	m_deckLinkOutput->SetAudioCallback(this);
	
	// Set the item data for combo box entries to store audio channel count and sample depth information
	m_outputSignalCombo.SetItemData(0, kOutputSignalPip);
	m_outputSignalCombo.SetItemData(1, kOutputSignalDrop);
	//
	m_audioChannelCombo.SetItemData(0, 2);		// 2 channels
	m_audioChannelCombo.SetItemData(1, 8);		// 8 channels
	m_audioChannelCombo.SetItemData(2, 16);		// 16 channels
	//
	m_audioSampleDepthCombo.SetItemData(0, 16);	// 16-bit samples
	m_audioSampleDepthCombo.SetItemData(1, 32);	// 32-bit samples
	
	m_pixelFormatCombo.SetItemData(0, bmdFormat8BitYUV);
	m_pixelFormatCombo.SetItemData(1, bmdFormat10BitYUV);
	m_pixelFormatCombo.SetItemData(2, bmdFormat8BitARGB);
	m_pixelFormatCombo.SetItemData(3, bmdFormat10BitRGB);

	// Select the first item in each combo box
	m_outputSignalCombo.SetCurSel(0);
	m_audioChannelCombo.SetCurSel(0);
	m_audioSampleDepthCombo.SetCurSel(0);
	m_pixelFormatCombo.SetCurSel(0);

	RefreshDisplayModeMenu();

	success = true;
	
bail:
	if (success == false)
	{
		// Release any resources that were partially allocated
		if (m_deckLinkOutput != NULL)
		{
			m_deckLinkOutput->Release();
			m_deckLinkOutput = NULL;
		}
		//
		if (m_deckLink != NULL)
		{
			m_deckLink->Release();
			m_deckLink = NULL;
		}
		
		// Disable the user interface if we could not succsssfully connect to a DeckLink device
		m_startButton.EnableWindow(FALSE);
		EnableInterface(FALSE);
	}
	
	if (deckLinkIterator != NULL)
		deckLinkIterator->Release();
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}
Exemplo n.º 12
0
void CAutoFactory::UpdateButton(Ui::CWindow *pw, EventType event, bool bBusy)
{
    EnableInterface(pw, event, !bBusy);
    DeadInterface(pw, event, m_main->CanFactory(ObjectTypeFromFactoryButton(event), m_object->GetTeam()));
}
Exemplo n.º 13
0
void ImageSaveDlg::OnRadioClicked()
{
   EnableInterface();
}