Beispiel #1
0
bool MythFillDatabaseTask::DoCheckRun(QDateTime now)
{
    if (!gCoreContext->GetNumSetting("MythFillEnabled", 1))
    {
        // we don't want to run this manually, so abort early
        LOG(VB_GENERAL, LOG_DEBUG, "MythFillDatabase is disabled. Cannot run.");
        return false;
    }

//    if (m_running)
//        // we're still running from the previous pass, so abort early
//        return false;

    if (UseSuggestedTime())
    {
        QDateTime nextRun = MythDate::fromString(
            gCoreContext->GetSetting("MythFillSuggestedRunTime",
                                     "1970-01-01T00:00:00"));
        LOG(VB_GENERAL, LOG_DEBUG,
                QString("MythFillDatabase scheduled to run at %1.")
                    .arg(nextRun.toString()));
        if (nextRun > now)
            // not yet time
            return false;

        if (InWindow(now))
            // we're inside our permitted window
            return true;

        return false;
    }
    else
    {
        // just let DailyHouseKeeperTask handle things
        LOG(VB_GENERAL, LOG_DEBUG, "Performing daily run check.");
        return DailyHouseKeeperTask::DoCheckRun(now);
    }
}
Beispiel #2
0
//
// ICWindow::HandleEvent
//
// Handle input events
//
U32 ICWindow::HandleEvent(Event &e)
{
  if (e.type == Input::EventID())
  {
    // Input events
    switch (e.subType)
    {
      case Input::MOUSEBUTTONDOWN:
      {
        if (e.input.code == Input::LeftButtonCode())
        {
          if (InWindow(Point<S32>(e.input.mouseX, e.input.mouseY)))
          {
            // Raise window
            SendNotify(this, ICWindowMsg::Raise, FALSE);

            // Handled
            return (TRUE);
          }
        }
        break;
      }

      case Input::KEYDOWN:
      case Input::KEYREPEAT:
      {
        switch (e.input.code)
        {
          case DIK_TAB:
          {
            // If nothing has the focus then activate the first tab stop control
            if (IFace::GetFocus() == NULL)
            {
              SetTabStop(NULL, TRUE);

              // Handled
              return (TRUE);
            }

            // Not handled
            break;
          }

          case DIK_ESCAPE:
          {
            // If modal then issue the Window::Close notification
            if ((controlStyle & STYLE_MODAL) && !(windowStyle & STYLE_NOSYSBUTTONS))
            {
              // Close window
              SendNotify(this, ICWindowMsg::Close, FALSE);

              // Handled
              return (TRUE);
            }

            // Not handled
            break;
          }
        }

        // Not handled
        break;
      }
    }
  }
  else

  if (e.type == IFace::EventID())
  {
    switch (e.subType)
    {
      // Notification events
      case IFace::NOTIFY:
      {
        switch (e.iface.p1)
        {
          case ICWindowMsg::Raise:
          {
            // Raise the window
            SetZPos(0);

            // Handled
            return (TRUE);
          }

          case ICWindowMsg::Close:
          {
            // Close window
            Deactivate();

            // Handled
            return (TRUE);
          }

          case ICWindowMsg::Maximize:
          case ICWindowMsg::Minimize:
          {
            // Not implemented
            break;
          }

          case ICWindowMsg::Destroy:
          {
            // Mark for deletion
            MarkForDeletion();

            // Handled
            return (TRUE);
          }
        }

        // Not handled
        break;
      }
    }
  }

  // This event can't be handled by this control, so pass it to the parent class
  return (IControl::HandleEvent(e));
}
Beispiel #3
0
void TransitiveClosure(void)
{
	// Build RAM using classifiction structure originally
	// generated by the method GridTable::Connect()
	BuildRAM();

	//Step (1a):
	//Compute weights of weight graph using confidence map
	//(if defined)
	// NOT USED ... if(weightMapDefined)	ComputeEdgeStrengths();

	//Step (2):

	//Treat each region Ri as a disjoint set:

	// - attempt to join Ri and Rj for all i != j that are neighbors and
	//   whose associated modes are a normalized distance of < 0.5 from one
	//   another

	// - the label of each region in the raList is treated as a pointer to the
	//   canonical element of that region (e.g. raList[i], initially has raList[i].label = i,
	//   namely each region is initialized to have itself as its canonical element).

	//Traverse RAM attempting to join raList[i] with its neighbors...
	cl_int	iCanEl, neighCanEl;
	cl_float	threshold;
	RAList	*neighbor;
	for(cl_uint i = 0; i < regionCount; i++)
	{
		//aquire first neighbor in region adjacency list pointed to
		//by raList[i]
		neighbor	= raList[i].next;

		//compute edge strenght threshold using global and local
		//epsilon
		if(epsilon > raList[i].edgeStrength)
			threshold   = epsilon;
		else
			threshold   = raList[i].edgeStrength;

		//traverse region adjacency list of region i, attempting to join
		//it with regions whose mode is a normalized distance < 0.5 from
		//that of region i...
		while(neighbor)
		{
			//attempt to join region and neighbor...
			if((InWindow(i, neighbor->label))&&(neighbor->edgeStrength < epsilon))
			{
				//region i and neighbor belong together so join them
				//by:

				// (1) find the canonical element of region i
				iCanEl		= i;
				while(raList[iCanEl].label != iCanEl)
					iCanEl		= raList[iCanEl].label;

				// (2) find the canonical element of neighboring region
				neighCanEl	= neighbor->label;
				while(raList[neighCanEl].label != neighCanEl)
					neighCanEl	= raList[neighCanEl].label;

				// if the canonical elements of are not the same then assign
				// the canonical element having the smaller label to be the parent
				// of the other region...
				if(iCanEl < neighCanEl)
					raList[neighCanEl].label	= iCanEl;
				else
				{
					//must replace the canonical element of previous
					//parent as well
					raList[raList[iCanEl].label].label	= neighCanEl;

					//re-assign canonical element
					raList[iCanEl].label				= neighCanEl;
				}
			}

			//check the next neighbor...
			neighbor	= neighbor->next;

		}
	}

	// Step (3):

	// Level binary trees formed by canonical elements
	for(cl_uint i = 0; i < regionCount; i++)
	{
		iCanEl	= i;
		while(raList[iCanEl].label != iCanEl)
			iCanEl	= raList[iCanEl].label;
		raList[i].label	= iCanEl;
	}

	// Step (4):

	//Traverse joint sets, relabeling image.

	// (a)

	// Accumulate modes and re-compute point counts using canonical
	// elements generated by step 2.

	//allocate memory for mode and point count temporary buffers...
	cl_float	*modes_buffer	= new cl_float	[N*regionCount];
	cl_int		*MPC_buffer		= new cl_int	[regionCount];

	//initialize buffers to zero
	for(cl_uint i = 0; i < regionCount; i++)
		MPC_buffer[i]	= 0;
	for(cl_uint i = 0; i < N*regionCount; i++)
		modes_buffer[i]	= 0;

	//traverse raList accumulating modes and point counts
	//using canoncial element information...
	cl_int iMPC;
	for(cl_uint i = 0; i < regionCount; i++) {
		//obtain canonical element of region i
		iCanEl	= raList[i].label;

		//obtain mode point count of region i
		iMPC	= modePointCounts[i];

		//accumulate modes_buffer[iCanEl]
		for(cl_uint k = 0; k < N; k++)
			modes_buffer[(N*iCanEl)+k] += iMPC*modes[(N*i)+k];

		//accumulate MPC_buffer[iCanEl]
		MPC_buffer[iCanEl] += iMPC;

	}

	// (b)

	// Re-label new regions of the image using the canonical
	// element information generated by step (2)

	// Also use this information to compute the modes of the newly
	// defined regions, and to assign new region point counts in
	// a consecute manner to the modePointCounts array

	//allocate memory for label buffer
	cl_int	*label_buffer	= new cl_int [regionCount];

	//initialize label buffer to -1
	for(cl_uint i = 0; i < regionCount; i++)
		label_buffer[i]	= -1;

	//traverse raList re-labeling the regions
	cl_int	label = -1;
	for(cl_uint i = 0; i < regionCount; i++)
	{
		//obtain canonical element of region i
		iCanEl	= raList[i].label;
		if(label_buffer[iCanEl] < 0)
		{
			//assign a label to the new region indicated by canonical
			//element of i
			label_buffer[iCanEl]	= ++label;

			//recompute mode storing the result in modes[label]...
			iMPC	= MPC_buffer[iCanEl];
			for(cl_uint k = 0; k < N; k++)
				modes[(N*label)+k]	= (modes_buffer[(N*iCanEl)+k])/(iMPC);

			//assign a corresponding mode point count for this region into
			//the mode point counts array using the MPC buffer...
			modePointCounts[label]	= MPC_buffer[iCanEl];
		}
	}

	//re-assign region count using label counter
	// cl_int	oldRegionCount	= regionCount;
	regionCount	= label+1;

	// (c)

	// Use the label buffer to reconstruct the label map, which specified
	// the new image given its new regions calculated above

	for(cl_uint i = 0; i < height*width; i++)
		labels[i]	= label_buffer[raList[labels[i]].label];

	//de-allocate memory
	delete [] modes_buffer;
	delete [] MPC_buffer;
	delete [] label_buffer;

	//done.
	return;

}