Ejemplo n.º 1
0
void WMain::OnRunButton(wxCommandEvent &event)
{
    // join finished thread
    if (m_thread && !m_thread->IsAlive())
    {
        m_thread->Wait();
        g_algo_running = false;

        delete m_thread;
        m_thread = NULL;
    }

    if (event.IsChecked())
    {
        if (!m_thread)
        {
            RunAlgorithm();
        }
        else
        {
            g_algo_running = true;
            sortview->SetStepwise(false);
            if (m_thread->IsPaused()) m_thread->Resume();
        }
    }
    else
    {
        if (m_thread)
        {
            m_thread->Pause();
            g_algo_running = false;
        }
    }
}
Ejemplo n.º 2
0
void WMain::OnRandomButton(wxCommandEvent&)
{
    AbortAlgorithm();

    algoList->SetSelection( rand() % algoList->GetCount() );
    sortview->FillData( inputTypeChoice->GetSelection(), m_array_size );

    RunAlgorithm();

    algoList->SetSelection(wxNOT_FOUND);
}
Ejemplo n.º 3
0
void WMain::OnAlgoListDClick(wxCommandEvent&)
{
    // terminate running algorithm.
    if (m_thread)
    {
        AbortAlgorithm();

        sortview->FillData( inputTypeChoice->GetSelection(), m_array_size );
    }

    // start new one
    RunAlgorithm();
}
ClusterHierarchyBuilder::ClusterHierarchyBuilder(const Vec2 *pts,int numPts)
{
	mEdges = 0;
	try
	{
		CreateVertexNodes(pts,numPts);
		CreateInitialEdges(pts,numPts);
		RunAlgorithm();
	}
	catch(...)
	{
		delete [] mEdges;
		throw;
	}
}
Ejemplo n.º 5
0
void WMain::OnStepButton(wxCommandEvent&)
{
    // lock thread to one step
    if (!m_thread)
    {
        if (!RunAlgorithm()) return;
        sortview->SetStepwise(true);
    }
    else
    {
        if (m_thread->IsPaused()) m_thread->Resume();
        sortview->SetStepwise(true);    // in case not already set
        runButton->SetValue(false);
        g_algo_running = true;
    }

    // signal to perform one step
    sortview->DoStepwise();
}