Ejemplo n.º 1
0
/**
    * Callback invoked when user pressed the "back" button
    */
void WebFrame::OnBack(wxCommandEvent& WXUNUSED(evt))
{
    m_browser->GoBack();
    UpdateState();
}
Ejemplo n.º 2
0
void ProfileWizard::OnNext(wxCommandEvent& evt)
{
    UpdateState(1);
}
Ejemplo n.º 3
0
ProfileWizard::ProfileWizard(wxWindow *parent, bool firstLight) :
    wxDialog(parent, wxID_ANY, _("New Profile Wizard"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX),
    m_launchDarks(true)
{
    TitlePrefix = _("New Profile Wizard - ");

    // Create overall vertical sizer
    m_pvSizer = new wxBoxSizer(wxVERTICAL);

#   include "icons/phd2_48.png.h"
    wxBitmap phd2(wxBITMAP_PNG_FROM_DATA(phd2_48));
    m_bitmaps[STATE_GREETINGS] = new wxBitmap(phd2);
    m_bitmaps[STATE_WRAPUP] = new wxBitmap(phd2);
#   include "icons/cam2.xpm"
    m_bitmaps[STATE_CAMERA] = new wxBitmap(cam_icon);
#   include "icons/scope1.xpm"
    m_bitmaps[STATE_MOUNT] = new wxBitmap(scope_icon);
    m_bitmaps[STATE_AUXMOUNT] = new wxBitmap(scope_icon);
#   include "icons/ao.xpm"
    m_bitmaps[STATE_AO] = new wxBitmap(ao_xpm);
#ifndef  __WXGTK__  // this resizing make a later crash in UpdateState with wxGtk
    m_bitmaps[STATE_CAMERA]->SetWidth(55);
    m_bitmaps[STATE_CAMERA]->SetHeight(55);
    m_bitmaps[STATE_MOUNT]->SetWidth(55);
    m_bitmaps[STATE_MOUNT]->SetHeight(55);
    m_bitmaps[STATE_AUXMOUNT]->SetWidth(55);
    m_bitmaps[STATE_AUXMOUNT]->SetHeight(55);
#endif // __WXGTK__

    // Build the superset of UI controls, minus state-specific labels and data
    // User instructions at top
    wxBoxSizer *instrSizer = new wxBoxSizer(wxHORIZONTAL);
    m_bitmap = new wxStaticBitmap(this, wxID_ANY, *m_bitmaps[STATE_GREETINGS], wxDefaultPosition, wxSize(55, 55));
    instrSizer->Add(m_bitmap, 0, wxALIGN_CENTER_VERTICAL | wxFIXED_MINSIZE, 5);

    m_pInstructions = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(DialogWidth, 40), wxALIGN_LEFT | wxST_NO_AUTORESIZE);
    wxFont font = m_pInstructions->GetFont();
    font.SetWeight(wxFONTWEIGHT_BOLD);
    m_pInstructions->SetFont(font);
    instrSizer->Add(m_pInstructions, wxSizerFlags().Border(wxALL, 10));
    m_pvSizer->Add(instrSizer);

    // Verbose help block
    m_pHelpGroup = new wxStaticBoxSizer(wxVERTICAL, this, _("More Info"));
    m_pHelpText = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(DialogWidth, -1));
    // Vertical sizing of help text will be handled in state machine
    m_pHelpGroup->Add(m_pHelpText, wxSizerFlags().Border(wxLEFT, 10).Border(wxBOTTOM, 10));
    m_pvSizer->Add(m_pHelpGroup, wxSizerFlags().Border(wxALL, 5));

    // Gear label and combo box
    m_pGearGrid = new wxFlexGridSizer(1, 2, 5, 15);
    m_pGearLabel = new wxStaticText(this, wxID_ANY, "Temp:", wxDefaultPosition, wxDefaultSize);
    m_pGearChoice = new wxChoice(this, ID_COMBO, wxDefaultPosition, wxDefaultSize,
                              GuideCamera::List(), 0, wxDefaultValidator, _("Gear"));
    m_pGearGrid->Add(m_pGearLabel, 1, wxALL, 5);
    m_pGearGrid->Add(m_pGearChoice, 1, wxLEFT, 10);
    m_pvSizer->Add(m_pGearGrid, wxSizerFlags().Center().Border(wxALL, 5));

    // Control for pixel-size and focal length
    m_pUserProperties = new wxFlexGridSizer(2, 2, 5, 15);
    m_pPixelSize = new wxSpinCtrlDouble(this, ID_PIXELSIZE, wxEmptyString, wxDefaultPosition,
                                          wxDefaultSize, wxSP_ARROW_KEYS, 1.0, 20.0, 5.0, 0.1);
    m_pPixelSize->SetDigits(2);
    m_PixelSize = m_pPixelSize->GetValue();
    m_pPixelSize->SetToolTip(_("Click Detect to read the pixel size from the camera. Otherwise, you can get this value from your camera documentation or from an online source.  You can use the up/down control "
        "or type in a value directly."));
    m_detectPixelSizeBtn = new wxButton(this, ID_DETECT_PIXELSIZE, _("Detect"));
    m_detectPixelSizeBtn->Enable(false);
    m_detectPixelSizeBtn->SetToolTip(_("Connect to camera and detect pixel size"));
    wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
    sizer->Add(m_pPixelSize, 1);
    sizer->Add(m_detectPixelSizeBtn, 0, wxLEFT, 10);
    AddTableEntryPair(this, m_pUserProperties, _("Guide camera pixel size (microns)"), sizer);
    m_pFocalLength = new wxSpinCtrlDouble(this, ID_FOCALLENGTH, _T("foo2"), wxDefaultPosition,
        wxDefaultSize, wxSP_ARROW_KEYS, 50, 3000, 300, 50);
    m_pFocalLength->SetValue(300);
    m_pFocalLength->SetDigits(0);
    m_pFocalLength->SetToolTip(_("This is the focal length of the guide scope - or the imaging scope if you are using an off-axis-guider or "
        "an adaptive optics device.  You can use the up/down control or type in a value directly."));
    m_FocalLength = (int) m_pFocalLength->GetValue();
    AddTableEntryPair(this, m_pUserProperties, _("Guide scope focal length (mm)"), m_pFocalLength);
    m_pvSizer->Add(m_pUserProperties, wxSizerFlags().Center().Border(wxALL, 5));

    // Wrapup panel
    m_pWrapUp = new wxFlexGridSizer(2, 2, 5, 15);
    m_pProfileName = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(250,-1));
    m_pLaunchDarks = new wxCheckBox(this, wxID_ANY, _("Build dark library"));
    m_pLaunchDarks->SetValue(m_launchDarks);
    m_pLaunchDarks->SetToolTip(_("Check this to automatically start the process of building a dark library for this profile."));
    AddTableEntryPair(this, m_pWrapUp, _("Profile Name"), m_pProfileName);
    m_pWrapUp->Add(m_pLaunchDarks, wxSizerFlags().Border(wxTOP, 5).Border(wxLEFT, 10));
    m_pvSizer->Add(m_pWrapUp, wxSizerFlags().Border(wxALL, 10).Expand().Center());

    // Row of buttons for prev, help, next
    wxBoxSizer *pButtonSizer = new wxBoxSizer(wxHORIZONTAL);
    m_pPrevBtn = new wxButton(this, ID_PREV, _("< Back"));
    m_pPrevBtn->SetToolTip(_("Back up to the previous screen"));

    m_pNextBtn = new wxButton(this, ID_NEXT, _("Next >"));
    m_pNextBtn->SetToolTip(_("Move forward to next screen"));

    pButtonSizer->AddStretchSpacer();
    pButtonSizer->Add(
        m_pPrevBtn,
        wxSizerFlags(0).Align(0).Border(wxALL, 5));
    pButtonSizer->Add(
        m_pNextBtn,
        wxSizerFlags(0).Align(0).Border(wxALL, 5));
    m_pvSizer->Add(pButtonSizer, wxSizerFlags().Expand().Border(wxALL, 10));

    // Status bar for error messages
    m_pStatusBar = new wxStatusBar(this, -1);
    m_pStatusBar->SetFieldsCount(1);
    m_pvSizer->Add(m_pStatusBar, 0, wxGROW);

    SetAutoLayout(true);
    SetSizerAndFit(m_pvSizer);
    // Special cases - neither AuxMount nor AO requires an explicit user choice
    m_SelectedAuxMount = _("None");
    m_SelectedAO = _("None");
    if (firstLight)
        m_State = STATE_GREETINGS;
    else
        m_State = STATE_CAMERA;
    UpdateState(0);
}
Ejemplo n.º 4
0
/**************************************************************************
 CostMap handler
 updates costmap for D* path planning
 **************************************************************************/
void CostMapHandler(void *data)
{
	LARGE_INTEGER frequency, start, finish;
	QueryPerformanceFrequency(&frequency);
	QueryPerformanceCounter(&start);

	CostMapConvert(*(reinterpret_cast<CostMapType*>(data)));
	receivedCostMap = true;
	receivedNew = true;

	static bool **cellsUpdated;
	if(costmap == NULL || !costmap->equals(cmpInt))
	{
		//Todo: actually delete memory here, not just resetting them
		cout << "Creating new costmap...\n";
		if (costmap != NULL) {
			delete costmap;
			delete [] cellsUpdated[0];
			delete [] cellsUpdated;
		}

		/* save the original number for back conversion in the end */
		CostMapType *costmapUpdate = reinterpret_cast<CostMapType*>(data);
		
		//TODO: Hack this for IGVC 2010
		//costmapXMax = costmapUpdate->xMax; 
		//costmapXMin = costmapUpdate->xMin;
		//costmapXUnit = costmapUpdate->xUnitSize;
		//costmapYMax = costmapUpdate->yMax;
		//costmapYMin = costmapUpdate->yMin;
		//costmapYUnit = costmapUpdate->yUnitSize;

		xMax = cmpInt->xMax;
		yMax = cmpInt->yMax;
		costmap = new CostMapInt(xMax+1, yMax+1);

		// Variables and arrays to keep track of which cells have been updated and what their old values are
		cellsUpdated = new bool*[xMax+1];    //cells changed in both cmpInt and squarecosts
		bool *curPtr1 = new bool[(xMax+1) * (yMax+1)]();
		for( int i = 0; i < xMax+1; i++) { 
			*(cellsUpdated + i) = curPtr1; 
			curPtr1 += yMax + 1; 
		} 
	}

	static vector<int> cellsUpdatedXs;
	static vector<int> cellsUpdatedYs;

	int cellUpdateCount = 0;   //take out in release!!!
	static const double cellsD = 6;
	static int cells = 5;

	costmap->update(cmpInt); 

	//QueryPerformanceCounter(&finish);
	//double timeelapsed = ((double)(finish.QuadPart - start.QuadPart))/frequency.QuadPart;
	//cout << "Map Update Time: " << timeelapsed << " s\n";

	// Clears cellsUpdated, cellsUpdatedXs, and cellsUpdatedYs.
	//cout << "Cells Updated: " << cellUpdateCount << endl;

	if (!isInitialSearch) {
		for (size_t i = 0; i < costmap->cellsUpdatedXs.size(); ++i) {
			int x = costmap->cellsUpdatedXs[i];
			int y = costmap->cellsUpdatedYs[i];

			for (int j = 0; j < lattice.update_n; ++j) {
				//for each corner of updated cell
				int m = x + lattice.update_dx[j];
				int n = y + lattice.update_dy[j];
				if (!isInMap(m, n)) continue;
				if (memory[m][n] == 0) continue;
				Node *s = GetOrCreateNode(m, n);
				if (s->bptr == 0) continue;
				if (s != startNode) {
					UpdateRHSandBptr(s);
					UpdateState(s); 
				}
			}
			//update itself		
			if (!isInMap(x, y)) continue;
			if (memory[x][y] == 0) continue;
			Node *s = GetOrCreateNode(x, y);
			if (s->bptr == 0) continue;
			if (s != startNode) {
				UpdateRHSandBptr(s);
				UpdateState(s);
			}
		}
	}

	//use resize() instead of clear() to keep capacity unchanged
	//this is also done in the costmap internal function, but I'm keeping this here in case no points are updated
	costmap->cellsUpdatedXs.resize(0);
	costmap->cellsUpdatedYs.resize(0);

	QueryPerformanceCounter(&finish);
	double timeelapsed = ((double)(finish.QuadPart - start.QuadPart))/frequency.QuadPart;
	cout << "Map Update Time: " << timeelapsed << " s\n";

}
Ejemplo n.º 5
0
unsigned char SSS_PADpoll (const unsigned char value)
{
	const int pad = global.curPad;
	const int cur = global.curByte;
	static u8 buf[20];
	if (cur == 0)
	{
		global.curByte++;
		global.curCmd = value;
		switch (value)
		{
		case 0x40:
			global.cmdLen = sizeof (cmd40);
			memcpy (buf, cmd40, sizeof (cmd40));
			return 0xf3;
		case 0x41:
			global.cmdLen = sizeof (cmd41);
			memcpy (buf, cmd41, sizeof (cmd41));
			return 0xf3;
		case 0x42:
		case 0x43:
			if (value == 0x42) UpdateState (pad);
			global.cmdLen = 2 + 2 * (global.padID[pad] & 0x0f);
			buf[1] = global.padModeC[pad] ? 0x00 : 0x5a;
			*(u16*)&buf[2] = global.padStat[pad];
			if (value == 0x43 && global.padModeE[pad])
			{
				buf[4] = 0;
				buf[5] = 0;
				buf[6] = 0;
				buf[7] = 0;
				return 0xf3;
			}
			else
			{
				buf[ 4] = pad ? lastport2.rightJoyX : lastport1.rightJoyX ; 
				buf[ 5] = pad ? lastport2.rightJoyY : lastport1.rightJoyY ; 
				buf[ 6] = pad ? lastport2.leftJoyX : lastport1.leftJoyX ; 
				buf[ 7] = pad ? lastport2.leftJoyY : lastport1.leftJoyY ; 
				if (global.padID[pad] == 0x79)
				{ 
  				// do some pressure stuff (this is for PS2 only!)
				}
				return (u8)global.padID[pad];
			}
			break;
		case 0x44:
			global.cmdLen = sizeof (cmd44);
			memcpy (buf, cmd44, sizeof (cmd44));
			return 0xf3;
		case 0x45:
			global.cmdLen = sizeof (cmd45);
			memcpy (buf, cmd45, sizeof (cmd45));
			buf[4] = (u8)global.padMode1[pad];
			return 0xf3;
		case 0x46:
			global.cmdLen = sizeof (cmd46);
			memcpy (buf, cmd46, sizeof (cmd46));
			return 0xf3;
		case 0x47:
			global.cmdLen = sizeof (cmd47);
			memcpy (buf, cmd47, sizeof (cmd47));
			return 0xf3;
		case 0x4c:
			global.cmdLen = sizeof (cmd4c);
			memcpy (buf, cmd4c, sizeof (cmd4c));
			return 0xf3;
		case 0x4d:
			global.cmdLen = sizeof (cmd4d);
			memcpy (buf, cmd4d, sizeof (cmd4d));
			return 0xf3;
		case 0x4f:
			global.padID[pad] = 0x79;
			global.padMode2[pad] = 1;
			global.cmdLen = sizeof (cmd4f);
			memcpy (buf, cmd4f, sizeof (cmd4f));
			return 0xf3;
		}
	}
	switch (global.curCmd)
	{
	case 0x42:
		if (cur == global.padVib0[pad])
			global.padVibF[pad][0] = value;
		if (cur == global.padVib1[pad])
			global.padVibF[pad][1] = value;
		break;
	case 0x43:
		if (cur == 2)
		{
			global.padModeE[pad] = value; // cmd[3]==1 ? enter : exit escape mode
			global.padModeC[pad] = 0;
		}
		break;
	case 0x44:
		if (cur == 2)
			PADsetMode (pad, value);	// cmd[3]==1 ? analog : digital
		if (cur == 3)
			global.padModeF[pad] = (value == 3); //cmd[4]==3 ? lock : don't log analog/digital button
		break;
	case 0x46:
		if (cur == 2)
		{
			switch(value)
			{
			case 0:
				buf[5] = 0x02;
				buf[6] = 0x00;
				buf[7] = 0x0A;
				break;
			case 1:
				buf[5] = 0x01;
				buf[6] = 0x01;
				buf[7] = 0x14;
				break;
			}
		}
		break;
	case 0x4c:
		if (cur == 2)
		{
			static const u8 buf5[] = { 0x04, 0x07, 0x02, 0x05 };
			buf[5] = buf5[value & 3];
		}
		break;
	case 0x4d:
		if (cur >= 2)
		{
			if (cur == global.padVib0[pad])
				buf[cur] = 0x00;
			if (cur == global.padVib1[pad])
				buf[cur] = 0x01;
			if (value == 0x00)
			{
				global.padVib0[pad] = cur;
				if ((global.padID[pad] & 0x0f) < (cur - 1) / 2)
					 global.padID[pad] = (global.padID[pad] & 0xf0) + (cur - 1) / 2;
			}
			else if (value == 0x01)
			{
				global.padVib1[pad] = cur;
				if ((global.padID[pad] & 0x0f) < (cur - 1) / 2)
					 global.padID[pad] = (global.padID[pad] & 0xf0) + (cur - 1) / 2;
			}
		}
		break;
	}
	if (cur >= global.cmdLen)
		return 0;
	return buf[global.curByte++];
}
Ejemplo n.º 6
0
DSPDebuggerLLE::DSPDebuggerLLE(wxWindow* parent, wxWindowID id)
	: wxPanel(parent, id, wxDefaultPosition, wxDefaultSize,
			wxTAB_TRAVERSAL, _("DSP LLE Debugger"))
	, m_CachedStepCounter(-1)
{
	Bind(wxEVT_CLOSE_WINDOW, &DSPDebuggerLLE::OnClose, this);
	Bind(wxEVT_MENU, &DSPDebuggerLLE::OnChangeState, this, ID_RUNTOOL, ID_SHOWPCTOOL);

	m_DebuggerFrame = this;

	// notify wxAUI which frame to use
	m_mgr.SetManagedWindow(this);
	m_mgr.SetFlags(wxAUI_MGR_DEFAULT | wxAUI_MGR_LIVE_RESIZE);

	m_Toolbar = new wxAuiToolBar(this, ID_TOOLBAR,
		wxDefaultPosition, wxDefaultSize, wxAUI_TB_HORZ_TEXT);
	m_Toolbar->AddTool(ID_RUNTOOL, _("Pause"),
		wxArtProvider::GetBitmap(wxART_TICK_MARK, wxART_OTHER, wxSize(10,10)));
	m_Toolbar->AddTool(ID_STEPTOOL, _("Step"),
		wxArtProvider::GetBitmap(wxART_GO_DOWN, wxART_OTHER, wxSize(10,10)));
	m_Toolbar->AddTool(ID_SHOWPCTOOL, _("Show PC"),
		wxArtProvider::GetBitmap(wxART_GO_TO_PARENT, wxART_OTHER, wxSize(10,10)));
	m_Toolbar->AddSeparator();

	m_addr_txtctrl = new wxTextCtrl(m_Toolbar, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
	m_addr_txtctrl->Bind(wxEVT_TEXT_ENTER, &DSPDebuggerLLE::OnAddrBoxChange, this);

	m_Toolbar->AddControl(m_addr_txtctrl);
	m_Toolbar->Realize();

	m_SymbolList = new wxListBox(this, wxID_ANY, wxDefaultPosition,
		wxSize(140, 100), 0, nullptr, wxLB_SORT);
	m_SymbolList->Bind(wxEVT_LISTBOX, &DSPDebuggerLLE::OnSymbolListChange, this);

	m_MainNotebook = new wxAuiNotebook(this, wxID_ANY,
		wxDefaultPosition, wxDefaultSize,
		wxAUI_NB_TOP | wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_MOVE);

	wxPanel *code_panel = new wxPanel(m_MainNotebook, wxID_ANY);
	wxBoxSizer *code_sizer = new wxBoxSizer(wxVERTICAL);
	m_CodeView = new CCodeView(&debug_interface, &DSPSymbols::g_dsp_symbol_db, code_panel);
	m_CodeView->SetPlain();
	code_sizer->Add(m_CodeView, 1, wxALL | wxEXPAND);
	code_panel->SetSizer(code_sizer);
	m_MainNotebook->AddPage(code_panel, _("Disassembly"), true);

	wxPanel *mem_panel = new wxPanel(m_MainNotebook, wxID_ANY);
	wxBoxSizer *mem_sizer = new wxBoxSizer(wxVERTICAL);
	// TODO insert memViewer class
	m_MemView = new CMemoryView(&debug_interface, mem_panel);
	mem_sizer->Add(m_MemView, 1, wxALL | wxEXPAND);
	mem_panel->SetSizer(mem_sizer);
	m_MainNotebook->AddPage(mem_panel, _("Memory"));

	m_Regs = new DSPRegisterView(this, ID_DSP_REGS);

	// add the panes to the manager
	m_mgr.AddPane(m_Toolbar, wxAuiPaneInfo().
		ToolbarPane().Top().
		LeftDockable(false).RightDockable(false));

	m_mgr.AddPane(m_SymbolList, wxAuiPaneInfo().
		Left().CloseButton(false).
		Caption(_("Symbols")).Dockable(true));

	m_mgr.AddPane(m_MainNotebook, wxAuiPaneInfo().
		Name("m_MainNotebook").Center().
		CloseButton(false).MaximizeButton(true));

	m_mgr.AddPane(m_Regs, wxAuiPaneInfo().Right().
		CloseButton(false).Caption(_("Registers")).
		Dockable(true));

	UpdateState();

	m_mgr.Update();
}
Ejemplo n.º 7
0
void ComputeOrImprovePath()
{
	while (1) {

		if (timesExpanded > MAX_TIMES_EXPANDED) {
			planningFailed = true;
			return;
		}

		Node *s1 = open->peekTop();
		if (s1 == 0) {
			planningFailed = true;
			return;
		}

		if (less_than(s1->key.k1, startNode->key.k1) || (equals(s1->key.k1, startNode->key.k1) && less_than(s1->key.k2, startNode->key.k2))
			|| (greater_than(startNode->rhs, startNode->g)) || (startNode->rhs == DOUBLE_INF && startNode->g == DOUBLE_INF))
			;
		else
			break; 

		Node *s = open->removeTop();

		if (greater_than(s->g, s->rhs)) {
			s->g = s->rhs;
			if (!s->inClosed) {
				s->inClosed = true;
				closed.push_back(s);
			}
			for (int i = 0; i < lattice.n; ++i) {
				int x = s->x + lattice.dx[i];  
				int y = s->y + lattice.dy[i];
				if (!isInMap(x, y)) 
					continue;
				Node *v = GetOrCreateNode(x, y);
				if (s->bptr == v) continue;

				double newRhs = ComputeCost(v, s->x, s->y);
				if (greater_than(v->rhs, newRhs)) {
					v->bptr = s;
					v->rhs = newRhs;
					UpdateState(v);
				}
			}
			++timesExpanded;

		} else {
			s->g = DOUBLE_INF;
			UpdateState(s);

			for (int i = 0; i < lattice.n; ++i) {
				int x = s->x + lattice.dx[i];
				int y = s->y + lattice.dy[i];
				Node *v = GetOrCreateNode(x, y);
				if (v != goalNode && v->bptr == s) {
					UpdateRHSandBptr(v);
					UpdateState(v);
				}
				
			}
			++timesExpanded;
			
		}
	}

}
Ejemplo n.º 8
0
/**
  * Callback invoked when a navigation request was accepted
  */
void WebFrame::OnNavigationComplete(wxWebViewEvent& evt)
{
    wxLogMessage("%s", "Navigation complete; url='" + evt.GetURL() + "'");
    UpdateState();
}
Ejemplo n.º 9
0
	void AbstractSocket::OnClose()
	{
		UpdateState(SocketState_NotConnected);
	}
Ejemplo n.º 10
0
void WebFrame::OnClearHistory(wxCommandEvent& WXUNUSED(evt))
{
    m_browser->ClearHistory();
    UpdateState();
}
Ejemplo n.º 11
0
void WebFrame::OnEnableHistory(wxCommandEvent& WXUNUSED(evt))
{
    m_browser->EnableHistory(m_tools_enable_history->IsChecked());
    UpdateState();
}
Ejemplo n.º 12
0
/**
  * Callback invoked when user pressed the "reload" button
  */
void WebFrame::OnReload(wxCommandEvent& WXUNUSED(evt))
{
    m_browser->Reload();
    UpdateState();
}
Ejemplo n.º 13
0
/**
  * Callback invoked when user pressed the "stop" button
  */
void WebFrame::OnStop(wxCommandEvent& WXUNUSED(evt))
{
    m_browser->Stop();
    UpdateState();
}
Ejemplo n.º 14
0
/**
  * Callback invoked when user pressed the "forward" button
  */
void WebFrame::OnForward(wxCommandEvent& WXUNUSED(evt))
{
    m_browser->GoForward();
    UpdateState();
}
Ejemplo n.º 15
0
/***********************************************************************
 * syncVideoWork
 ***********************************************************************
 *
 **********************************************************************/
int syncVideoWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
              hb_buffer_t ** buf_out )
{
    hb_buffer_t * cur, * next, * sub = NULL;
    hb_work_private_t * pv = w->private_data;
    hb_job_t          * job = pv->job;
    hb_subtitle_t     * subtitle;
    hb_sync_video_t   * sync = &pv->type.video;
    int i;
    int64_t next_start;

    *buf_out = NULL;
    next = *buf_in;
    *buf_in = NULL;

    /* Wait till we can determine the initial pts of all streams */
    if( next->size != 0 && pv->common->pts_offset == INT64_MIN )
    {
        pv->common->first_pts[0] = next->s.start;
        hb_lock( pv->common->mutex );
        while( pv->common->pts_offset == INT64_MIN )
        {
            // Full fifos will make us wait forever, so get the
            // pts offset from the available streams if full
            if ( hb_fifo_is_full( job->fifo_raw ) )
            {
                getPtsOffset( w );
                hb_cond_broadcast( pv->common->next_frame );
            }
            else if ( checkPtsOffset( w ) )
                hb_cond_broadcast( pv->common->next_frame );
            else
                hb_cond_timedwait( pv->common->next_frame, pv->common->mutex, 200 );
        }
        hb_unlock( pv->common->mutex );
    }

    hb_lock( pv->common->mutex );
    next_start = next->s.start - pv->common->video_pts_slip;
    hb_unlock( pv->common->mutex );

    /* Wait for start of point-to-point encoding */
    if( !pv->common->start_found )
    {
        hb_sync_video_t   * sync = &pv->type.video;

        if( next->size == 0 )
        {
            *buf_out = next;
            pv->common->start_found = 1;
            pv->common->first_pts[0] = INT64_MAX - 1;
            hb_cond_broadcast( pv->common->next_frame );

            /*
             * Push through any subtitle EOFs in case they 
             * were not synced through.
             */
            for( i = 0; i < hb_list_count( job->list_subtitle ); i++)
            {
                subtitle = hb_list_item( job->list_subtitle, i );
                if( subtitle->config.dest == PASSTHRUSUB )
                {
                    hb_fifo_push( subtitle->fifo_out, hb_buffer_init( 0 ) );
                }
            }
            return HB_WORK_DONE;
        }
        if ( pv->common->count_frames < job->frame_to_start ||
             next->s.start < job->pts_to_start )
        {
            // Flush any subtitles that have pts prior to the
            // current frame
            for( i = 0; i < hb_list_count( job->list_subtitle ); i++)
            {
                subtitle = hb_list_item( job->list_subtitle, i );
                while( ( sub = hb_fifo_see( subtitle->fifo_raw ) ) )
                {
                    if ( sub->s.start > next->s.start )
                        break;
                    sub = hb_fifo_get( subtitle->fifo_raw );
                    hb_buffer_close( &sub );
                }
            }
            hb_lock( pv->common->mutex );
            // Tell the audio threads what must be dropped
            pv->common->audio_pts_thresh = next_start + pv->common->video_pts_slip;
            hb_cond_broadcast( pv->common->next_frame );
            hb_unlock( pv->common->mutex );

            UpdateSearchState( w, next_start );
            hb_buffer_close( &next );

            return HB_WORK_OK;
        }
        hb_lock( pv->common->mutex );
        pv->common->audio_pts_thresh = 0;
        pv->common->audio_pts_slip += next_start;
        pv->common->video_pts_slip += next_start;
        next_start = 0;
        pv->common->start_found = 1;
        pv->common->count_frames = 0;
        hb_cond_broadcast( pv->common->next_frame );
        hb_unlock( pv->common->mutex );
        sync->st_first = 0;
    }

    if( !sync->cur )
    {
        sync->cur = next;
        if (next->size == 0)
        {
            /* we got an end-of-stream as our first video packet? 
             * Feed it downstream & signal that we're done. 
             */
            *buf_out = next;
            sync->cur = NULL;

            pv->common->start_found = 1;
            pv->common->first_pts[0] = INT64_MAX - 1;
            hb_cond_broadcast( pv->common->next_frame );

            /*
             * Push through any subtitle EOFs in case they 
             * were not synced through.
             */
            for( i = 0; i < hb_list_count( job->list_subtitle ); i++)
            {
                subtitle = hb_list_item( job->list_subtitle, i );
                if( subtitle->config.dest == PASSTHRUSUB )
                {
                    hb_fifo_push( subtitle->fifo_out, hb_buffer_init( 0 ) );
                }
            }
            return HB_WORK_DONE;
        }
        return HB_WORK_OK;
    }
    cur = sync->cur;
    /* At this point we have a frame to process. Let's check
        1) if we will be able to push into the fifo ahead
        2) if the next frame is there already, since we need it to
           compute the duration of the current frame*/
    if( next->size == 0 )
    {
        hb_buffer_close( &next );

        pv->common->first_pts[0] = INT64_MAX - 1;
        cur->s.start = sync->next_start;
        cur->s.stop = cur->s.start + 90000. / ((double)job->vrate / (double)job->vrate_base);
        sync->next_start += cur->s.stop - cur->s.start;;

        /* Make sure last frame is reflected in frame count */
        pv->common->count_frames++;

        /* Push the frame to the renderer */
        *buf_out = cur;
        sync->cur = NULL;

        /* we got an end-of-stream. Feed it downstream & signal that
         * we're done. Note that this means we drop the final frame of
         * video (we don't know its duration). On DVDs the final frame
         * is often strange and dropping it seems to be a good idea. */
        (*buf_out)->next = hb_buffer_init( 0 );

        /*
         * Push through any subtitle EOFs in case they were not synced through.
         */
        for( i = 0; i < hb_list_count( job->list_subtitle ); i++)
        {
            subtitle = hb_list_item( job->list_subtitle, i );
            if( subtitle->config.dest == PASSTHRUSUB )
            {
                hb_fifo_push( subtitle->fifo_out, hb_buffer_init( 0 ) );
            }
        }
        pv->common->start_found = 1;
        hb_cond_broadcast( pv->common->next_frame );
        return HB_WORK_DONE;
    }

    /* Check for end of point-to-point frame encoding */
    if( job->frame_to_stop && pv->common->count_frames > job->frame_to_stop )
    {
        // Drop an empty buffer into our output to ensure that things
        // get flushed all the way out.
        hb_buffer_close( &sync->cur );
        hb_buffer_close( &next );
        *buf_out = hb_buffer_init( 0 );
        hb_log( "sync: reached %d frames, exiting early",
                pv->common->count_frames );

        /*
         * Push through any subtitle EOFs in case they were not synced through.
         */
        for( i = 0; i < hb_list_count( job->list_subtitle ); i++)
        {
            subtitle = hb_list_item( job->list_subtitle, i );
            if( subtitle->config.dest == PASSTHRUSUB )
            {
                hb_fifo_push( subtitle->fifo_out, hb_buffer_init( 0 ) );
            }
        }
        return HB_WORK_DONE;
    }

    /* Check for end of point-to-point pts encoding */
    if( job->pts_to_stop && sync->next_start >= job->pts_to_stop )
    {
        // Drop an empty buffer into our output to ensure that things
        // get flushed all the way out.
        hb_log( "sync: reached pts %"PRId64", exiting early", cur->s.start );
        hb_buffer_close( &sync->cur );
        hb_buffer_close( &next );
        *buf_out = hb_buffer_init( 0 );

        /*
         * Push through any subtitle EOFs in case they were not synced through.
         */
        for( i = 0; i < hb_list_count( job->list_subtitle ); i++)
        {
            subtitle = hb_list_item( job->list_subtitle, i );
            if( subtitle->config.dest == PASSTHRUSUB )
            {
                hb_fifo_push( subtitle->fifo_out, hb_buffer_init( 0 ) );
            }
        }
        return HB_WORK_DONE;
    }

    if( sync->first_frame )
    {
        /* This is our first frame */
        if ( cur->s.start > 0 )
        {
            /*
             * The first pts from a dvd should always be zero but
             * can be non-zero with a transport or program stream since
             * we're not guaranteed to start on an IDR frame. If we get
             * a non-zero initial PTS extend its duration so it behaves
             * as if it started at zero so that our audio timing will
             * be in sync.
             */
            hb_log( "sync: first pts is %"PRId64, cur->s.start );
            cur->s.start = 0;
        }
        sync->first_frame = 0;
    }

    /*
     * since the first frame is always 0 and the upstream reader code
     * is taking care of adjusting for pts discontinuities, we just have
     * to deal with the next frame's start being in the past. This can
     * happen when the PTS is adjusted after data loss but video frame
     * reordering causes some frames with the old clock to appear after
     * the clock change. This creates frames that overlap in time which
     * looks to us like time going backward. The downstream muxing code
     * can deal with overlaps of up to a frame time but anything larger
     * we handle by dropping frames here.
     */
    if ( next_start - cur->s.start <= 0 )
    {
        if ( sync->first_drop == 0 )
        {
            sync->first_drop = next_start;
        }
        ++sync->drop_count;
        if ( next->s.new_chap )
        {
            // don't drop a chapter mark when we drop the buffer
            sync->chap_mark = next->s.new_chap;
        }
        hb_buffer_close( &next );
        return HB_WORK_OK;
    }
    if ( sync->first_drop )
    {
        hb_log( "sync: video time didn't advance - dropped %d frames "
                "(delta %d ms, current %"PRId64", next %"PRId64", dur %d)",
                sync->drop_count, (int)( cur->s.start - sync->first_drop ) / 90,
                cur->s.start, next_start, (int)( next_start - cur->s.start ) );
        sync->first_drop = 0;
        sync->drop_count = 0;
    }

    /*
     * Track the video sequence number locally so that we can sync the audio
     * to it using the sequence number as well as the PTS.
     */
    sync->video_sequence = cur->sequence;
    
    /* Process subtitles that apply to this video frame */
    // NOTE: There is no logic in either subtitle-sync algorithm that waits
    // for the subtitle-decoder if it is lagging behind the video-decoder.
    //       
    // Therefore there is the implicit assumption that the subtitle-decoder 
    // is always faster than the video-decoder. This assumption is definitely 
    // incorrect in some cases where the SSA subtitle decoder is used.

    for( i = 0; i < hb_list_count( job->list_subtitle ); i++)
    {
        int64_t sub_start, sub_stop, duration;

        subtitle = hb_list_item( job->list_subtitle, i );
        
        // Sanitize subtitle start and stop times, then pass to 
        // muxer or renderer filter.
        while ( ( sub = hb_fifo_see( subtitle->fifo_raw ) ) != NULL )
        {
            hb_lock( pv->common->mutex );
            sub_start = sub->s.start - pv->common->video_pts_slip;
            hb_unlock( pv->common->mutex );

            if (sub->s.stop == -1)
            {
                if (subtitle->config.dest != RENDERSUB &&
                    hb_fifo_size( subtitle->fifo_raw ) < 2)
                {
                    // For passthru subs, we want to wait for the
                    // next subtitle so that we can fill in the stop time.
                    // This way the muxer can compute the duration of
                    // the subtitle.
                    //
                    // For render subs, we need to ensure that they
                    // get to the renderer before the associated video
                    // that they are to be applied to.  It is the 
                    // responsibility of the renderer to handle
                    // stop == -1.
                    break;
                }
            }

            sub = hb_fifo_get( subtitle->fifo_raw );
            if ( sub->s.stop == -1 )
            {
                hb_buffer_t *next;
                next = hb_fifo_see( subtitle->fifo_raw );
                if (next != NULL)
                    sub->s.stop = next->s.start;
            }
            // Need to re-write subtitle timestamps to account
            // for any slippage.
            sub_stop = -1;
            if ( sub->s.stop != -1 )
            {
                duration = sub->s.stop - sub->s.start;
                sub_stop = sub_start + duration;
            }

            sub->s.start = sub_start;
            sub->s.stop = sub_stop;

            hb_fifo_push( subtitle->fifo_out, sub );
        }
    }

    /*
     * Adjust the pts of the current frame so that it's contiguous
     * with the previous frame. The start time of the current frame
     * has to be the end time of the previous frame and the stop
     * time has to be the start of the next frame.  We don't
     * make any adjustments to the source timestamps other than removing
     * the clock offsets (which also removes pts discontinuities).
     * This means we automatically encode at the source's frame rate.
     * MP2 uses an implicit duration (frames end when the next frame
     * starts) but more advanced containers like MP4 use an explicit
     * duration. Since we're looking ahead one frame we set the
     * explicit stop time from the start time of the next frame.
     */
    *buf_out = cur;
    int64_t duration = next_start - cur->s.start;
    sync->cur = cur = next;
    cur->sub = NULL;
    cur->s.start -= pv->common->video_pts_slip;
    cur->s.stop -= pv->common->video_pts_slip;
    sync->pts_skip = 0;
    if ( duration <= 0 )
    {
        hb_log( "sync: invalid video duration %"PRId64", start %"PRId64", next %"PRId64"",
                duration, cur->s.start, next_start );
    }

    (*buf_out)->s.start = sync->next_start;
    sync->next_start += duration;
    (*buf_out)->s.stop = sync->next_start;

    if ( sync->chap_mark )
    {
        // we have a pending chapter mark from a recent drop - put it on this
        // buffer (this may make it one frame late but we can't do any better).
        (*buf_out)->s.new_chap = sync->chap_mark;
        sync->chap_mark = 0;
    }

    /* Update UI */
    UpdateState( w );

    return HB_WORK_OK;
}
Ejemplo n.º 16
0
void COXDragDockContext::OnKey(int nChar, BOOL bDown)
	{
	if (nChar == VK_CONTROL)
		UpdateState(&m_bForceFrame, bDown);
	}
Ejemplo n.º 17
0
void HTMLTextAreaElement::SetCustomValidity(const nsAString& aError) {
  nsIConstraintValidation::SetCustomValidity(aError);

  UpdateState(true);
}
Ejemplo n.º 18
0
void TestAARHUD::SetupGUI(dtCore::DeltaWin& win,
                          dtCore::Keyboard& keyboard,
                          dtCore::Mouse& mouse)
{
   char clin[HUDCONTROLMAXTEXTSIZE]; // general buffer to print
   float curYPos;
   float helpTextWidth = 400;
   float taskTextWidth = 300;

   try
   {
      // Initialize CEGUI
      mGUI = new dtGUI::CEUIDrawable(&win, &keyboard, &mouse);

      std::string scheme = "gui/schemes/WindowsLook.scheme";
      std::string path = dtCore::FindFileInPathList(scheme);
      if (path.empty())
      {
         throw dtUtil::Exception(ARRHUDException::INIT_ERROR,
            "Failed to find the scheme file.", __FILE__, __LINE__);
      }

      std::string dir = path.substr(0, path.length() - (scheme.length() - 3));
      dtUtil::FileUtils::GetInstance().PushDirectory(dir);
      CEGUI::SchemeManager::getSingleton().loadScheme(path);
      dtUtil::FileUtils::GetInstance().PopDirectory();

      CEGUI::WindowManager* wm = CEGUI::WindowManager::getSingletonPtr();
      CEGUI::System::getSingleton().setDefaultFont("DejaVuSans-10");
      CEGUI::System::getSingleton().getDefaultFont()->setProperty("PointSize", "14");

      mMainWindow = wm->createWindow("DefaultGUISheet", "root");
      CEGUI::System::getSingleton().setGUISheet(mMainWindow);

      // MEDIUM FIELDS - on in Medium or max

      mHUDOverlay = wm->createWindow("WindowsLook/StaticImage", "medium_overlay");
      mMainWindow->addChildWindow(mHUDOverlay);
      mHUDOverlay->setPosition(CEGUI::UVector2(cegui_reldim(0.0f),cegui_reldim(0.0f)));
      mHUDOverlay->setSize(CEGUI::UVector2(cegui_reldim(1.0f), cegui_reldim(1.0f)));
      mHUDOverlay->setProperty("FrameEnabled", "false");
      mHUDOverlay->setProperty("BackgroundEnabled", "false");

      // Main State - idle/playback/record
      mStateText = CreateText("State Text", mHUDOverlay, "", 10.0f, 20.0f, 120.0f, mTextHeight + 5);
      mStateText->setProperty("TextColours", "tl:FFFF1919 tr:FFFF1919 bl:FFFF1919 br:FFFF1919");
      //mStateText->setFont("DejaVuSans-10");

      // Core sim info
      mSimTimeText = CreateText("Sim Time", mHUDOverlay, "Sim Time",
         0.0f, 0.0f, mRightTextXOffset - 2, mTextHeight);
      mSpeedFactorText = CreateText("Speed Factor", mHUDOverlay, "Speed",
         0.0f, 0.0f, mRightTextXOffset - 2, mTextHeight);

      // Detailed record/playback info
      mRecordDurationText = CreateText(std::string("Duration"), mHUDOverlay, std::string("Duration"),
         0, 0, mRightTextXOffset - 2, mTextHeight);
      mNumMessagesText = CreateText(std::string("Num Msgs"), mHUDOverlay, std::string("Num Msgs"),
         0, 0, mRightTextXOffset - 2, mTextHeight);
      mNumTagsText = CreateText(std::string("Num Tags"), mHUDOverlay, std::string("Num Tags"),
         0, 0, mRightTextXOffset - 2, mTextHeight);
      mLastTagText = CreateText(std::string("Last Tag"), mHUDOverlay, std::string("LastTag:"),
         0, 0, mRightTextXOffset - 2, mTextHeight);
      mNumFramesText = CreateText(std::string("Num Frames"), mHUDOverlay, std::string("Num Frames"),
         0, 0, mRightTextXOffset - 2, mTextHeight);
      mLastFrameText = CreateText(std::string("Last Frame"), mHUDOverlay, std::string("Last Frame"),
         0, 0, mRightTextXOffset - 2, mTextHeight);
      mCurLogText = CreateText(std::string("Cur Log"), mHUDOverlay, std::string("Cur Log"),
         0, 0, mRightTextXOffset - 2, mTextHeight);
      mCurMapText = CreateText(std::string("Cur Map"), mHUDOverlay, std::string("Cur Map"),
         0, 0, mRightTextXOffset - 2, mTextHeight);

      // Core Tips at top of screen (HUD Toggle and Help)
      mFirstTipText = CreateText(std::string("First Tip"), mHUDOverlay, std::string("(F2 for MED HUD)"),
         0, mTextYTopOffset, 160, mTextHeight + 2);
      mFirstTipText->setHorizontalAlignment(CEGUI::HA_CENTRE);
      mSecondTipText = CreateText(std::string("Second Tip"), mHUDOverlay, std::string("  (F1 for Help)"),
         0, mTextYTopOffset + mTextHeight + 3, 160, mTextHeight + 2);
      mSecondTipText->setHorizontalAlignment(CEGUI::HA_CENTRE);


      // TASK FIELDS

      // task header
      curYPos = 70;
      mTasksHeaderText = CreateText(std::string("Task Header"), mHUDOverlay, std::string("Tasks:"),
         4, curYPos, taskTextWidth - 2, mTextHeight + 2);
      //mTasksHeaderText->setFont("DejaVuSans-10");
      curYPos += 2;

      // 11 placeholders for tasks
      for (int i = 0; i < 11; i++)
      {
         snprintf(clin, HUDCONTROLMAXTEXTSIZE, "Task %i", i);
         curYPos += mTextHeight + 2;
         mTaskTextList.push_back(CreateText(std::string(clin), mHUDOverlay, std::string(clin),
            12, curYPos, taskTextWidth - 2, mTextHeight + 2));
      }

      // HELP FIELDS

      mHelpOverlay = static_cast<CEGUI::Window*>(wm->createWindow
         ("WindowsLook/StaticImage", "Help Overlay"));
      mMainWindow->addChildWindow(mHelpOverlay);
      mHelpOverlay->setPosition(CEGUI::UVector2(cegui_reldim(0.0f), cegui_reldim(0.0f)));
      mHelpOverlay->setSize(CEGUI::UVector2(cegui_reldim(1.0f), cegui_reldim(1.0f)));
      mHelpOverlay->setProperty("FrameEnabled", "false");
      mHelpOverlay->setProperty("BackgroundEnabled", "false");
      mHelpOverlay->hide();

      // help tip
      mHelpTipText = CreateText(std::string("Help Tip"), mHelpOverlay, std::string("(F2 to Toggle HUD)"),
         0, mTextYTopOffset, 160, mTextHeight + 2);
      mHelpTipText->setHorizontalAlignment(CEGUI::HA_CENTRE);

      // HELP - Speed Settings
      curYPos = mTextYTopOffset;
      mHelp1Text = CreateText(std::string("Help1"), mHelpOverlay, std::string("[-] Slower (min 0.1X)"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight + 2;
      mHelp2Text = CreateText(std::string("Help2"), mHelpOverlay, std::string("[+] Faster (max 10.0X)"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight + 2;
      mHelp3Text = CreateText(std::string("Help3"), mHelpOverlay, std::string("[0] Normal Speed (1.0X)"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight + 2;
      mHelp7Text = CreateText(std::string("Help7"), mHelpOverlay, std::string("[P] Pause/Unpause"),
         5, curYPos, helpTextWidth, mTextHeight + 2);

      // HELP - Camera Movement
      curYPos += mTextHeight * 2;
      mHelp17Text = CreateText(std::string("Help17"), mHelpOverlay, std::string("[Mouse] Turn Camera"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight + 2;
      mHelp13Text = CreateText(std::string("Help13"), mHelpOverlay, std::string("[A & D] Move Camera Left & Right"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight + 2;
      mHelp14Text = CreateText(std::string("Help14"), mHelpOverlay, std::string("[W & S] Move Camera Forward and Back"),
         5, curYPos, helpTextWidth, mTextHeight + 2);

      // HELP - Player Movement
      curYPos += mTextHeight * 2;
      mHelp15Text = CreateText(std::string("Help15"), mHelpOverlay, std::string("[J & L] Turn Player Left & Right"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight + 2;
      mHelp16Text = CreateText(std::string("Help16"), mHelpOverlay, std::string("[I & K] Move Player Forward and Back"),
         5, curYPos, helpTextWidth, mTextHeight + 2);

      // HELP - Idle, Record, and playback
      curYPos += mTextHeight * 2;
      mHelp4Text = CreateText(std::string("Help4"), mHelpOverlay, std::string("[1] Goto IDLE Mode (Ends record & playback)"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight + 2;
      mHelp5Text = CreateText(std::string("Help5"), mHelpOverlay, std::string("[2] Begin RECORD Mode (From Idle ONLY)"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight + 2;
      mHelp6Text = CreateText(std::string("Help6"), mHelpOverlay, std::string("[3] Begin PLAYBACK Mode (From Idle ONLY)"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight + 2;
      mHelp18Text = CreateText(std::string("Help18"), mHelpOverlay, std::string("[< & >] Prev & Next Keyframe (From Playback ONLY)"),
         5, curYPos, helpTextWidth, mTextHeight + 2);

      // HELP - Misc
      curYPos += mTextHeight * 2;
      mHelp8Text = CreateText(std::string("Help8"), mHelpOverlay, std::string("[B] Place Object"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight * 2;
      mHelp19Text = CreateText(std::string("Help19"), mHelpOverlay, std::string("[G] Place Ignorable Object"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight + 2;
      mHelp11Text = CreateText(std::string("Help11"), mHelpOverlay, std::string("[F] Insert Keyframe"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight + 2;
      mHelp12Text = CreateText(std::string("Help12"), mHelpOverlay, std::string("[T] Insert Tag"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight + 2;
      mHelp9Text = CreateText(std::string("Help9"), mHelpOverlay, std::string("[Enter] Toggle Statistics"),
         5, curYPos, helpTextWidth, mTextHeight + 2);
      curYPos += mTextHeight + 2;
      mHelp10Text = CreateText(std::string("Help10"), mHelpOverlay, std::string("[Space] Update Logger Status"),
         5, curYPos, helpTextWidth, mTextHeight + 2);

      // finally, update our state - disable/hide to make it match current state
      UpdateState();

      // Note - don't forget to add the cegui drawable to the scene after this method, or you get nothing.
   }
   catch (CEGUI::Exception& e)
   {
      std::ostringstream oss;
      oss << "CEGUI while setting up AAR GUI: " << e.getMessage().c_str();
      throw dtUtil::Exception(ARRHUDException::INIT_ERROR,oss.str(), __FILE__, __LINE__);
   }

}
void CFootBotForaging::Explore() {
   /* We switch to 'return to nest' in two situations:
    * 1. if we have a food item
    * 2. if we have not found a food item for some time;
    *    in this case, the switch is probabilistic
    */
   bool bReturnToNest(false);
   /*
    * Test the first condition: have we found a food item?
    * NOTE: the food data is updated by the loop functions, so
    * here we just need to read it
    */
   if(m_sFoodData.HasFoodItem) {
      /* Apply the food rule, decreasing ExploreToRestProb and increasing
       * RestToExploreProb */
      m_sStateData.ExploreToRestProb -= m_sStateData.FoodRuleExploreToRestDeltaProb;
      m_sStateData.ProbRange.TruncValue(m_sStateData.ExploreToRestProb);
      m_sStateData.RestToExploreProb += m_sStateData.FoodRuleRestToExploreDeltaProb;
      m_sStateData.ProbRange.TruncValue(m_sStateData.RestToExploreProb);
      /* Store the result of the expedition */
      m_eLastExplorationResult = LAST_EXPLORATION_SUCCESSFUL;
      /* Switch to 'return to nest' */
      bReturnToNest = true;
   }
   /* Test the second condition: we probabilistically switch to 'return to
    * nest' if we have been wandering for some time and found nothing */
   else if(m_sStateData.TimeExploringUnsuccessfully > m_sStateData.MinimumUnsuccessfulExploreTime) {
      if (m_pcRNG->Uniform(m_sStateData.ProbRange) < m_sStateData.ExploreToRestProb) {
         /* Store the result of the expedition */
         m_eLastExplorationResult = LAST_EXPLORATION_UNSUCCESSFUL;
         /* Switch to 'return to nest' */
         bReturnToNest = true;
      }
      else {
         /* Apply the food rule, increasing ExploreToRestProb and
          * decreasing RestToExploreProb */
         m_sStateData.ExploreToRestProb += m_sStateData.FoodRuleExploreToRestDeltaProb;
         m_sStateData.ProbRange.TruncValue(m_sStateData.ExploreToRestProb);
         m_sStateData.RestToExploreProb -= m_sStateData.FoodRuleRestToExploreDeltaProb;
         m_sStateData.ProbRange.TruncValue(m_sStateData.RestToExploreProb);
      }
   }
   /* So, do we return to the nest now? */
   if(bReturnToNest) {
      /* Yes, we do! */
      m_sStateData.TimeExploringUnsuccessfully = 0;
      m_sStateData.TimeSearchingForPlaceInNest = 0;
      m_pcLEDs->SetAllColors(CColor::BLUE);
      m_sStateData.State = SStateData::STATE_RETURN_TO_NEST;
   }
   else {
      /* No, perform the actual exploration */
      ++m_sStateData.TimeExploringUnsuccessfully;
      UpdateState();
      /* Get the diffusion vector to perform obstacle avoidance */
      bool bCollision;
      CVector2 cDiffusion = DiffusionVector(bCollision);
      /* Apply the collision rule, if a collision avoidance happened */
      if(bCollision) {
         /* Collision avoidance happened, increase ExploreToRestProb and
          * decrease RestToExploreProb */
         m_sStateData.ExploreToRestProb += m_sStateData.CollisionRuleExploreToRestDeltaProb;
         m_sStateData.ProbRange.TruncValue(m_sStateData.ExploreToRestProb);
         m_sStateData.RestToExploreProb -= m_sStateData.CollisionRuleExploreToRestDeltaProb;
         m_sStateData.ProbRange.TruncValue(m_sStateData.RestToExploreProb);
      }
      /*
       * If we are in the nest, we combine antiphototaxis with obstacle
       * avoidance
       * Outside the nest, we just use the diffusion vector
       */
      if(m_sStateData.InNest) {
         /*
          * The vector returned by CalculateVectorToLight() points to
          * the light. Thus, the minus sign is because we want to go away
          * from the light.
          */
         SetWheelSpeedsFromVector(
            m_sWheelTurningParams.MaxSpeed * cDiffusion -
            m_sWheelTurningParams.MaxSpeed * 0.25f * CalculateVectorToLight());
      }
      else {
         /* Use the diffusion vector only */
         SetWheelSpeedsFromVector(m_sWheelTurningParams.MaxSpeed * cDiffusion);
      }
   }
}
Ejemplo n.º 20
0
bool fairCTF::SlashCommand (int playerID, bz_ApiString /*command*/, bz_ApiString message, bz_APIStringList * /*params*/)
{
  std::string cs = "UNKNOWN";
  bz_BasePlayerRecord* pr = bz_getPlayerByIndex(playerID);
  if (pr != NULL)
  {
    cs = pr->callsign.c_str();
    bz_freePlayerRecord (pr);
  }

  if (!bz_hasPerm(playerID, "FAIRCTF"))
  {
    bz_sendTextMessage(BZ_SERVER, playerID, (cs + ", you do not have permission to use the /ctf command.").c_str());
  }
  else
  {
    if (message == "on")
    {
      if (!autoMode && allowCTF)
      {
	bz_sendTextMessage(BZ_SERVER, playerID, "CTF is already set to \"on\".");
      }
      else
      {
	autoMode = false;
	bz_sendTextMessage (BZ_SERVER, eAdministrators, ("CTF setting has been changed to \"on\" by " + cs + ".").c_str());
	if (!allowCTF)
	{
	  bz_sendTextMessage (BZ_SERVER, BZ_ALLUSERS, ("CTF has been enabled by " + cs + ".").c_str());
	  allowCTF = true;
	  droptime = 0.0;
	}
      }
    }
    else if (message == "off")
    {
      if (!autoMode && !allowCTF)
      {
	bz_sendTextMessage(BZ_SERVER, playerID, "CTF is already set to \"off\".");
      }
      else
      {
	autoMode = false;
	bz_sendTextMessage (BZ_SERVER, eAdministrators, ("CTF setting has been changed to \"off\" by " + cs + ".").c_str());
	if (allowCTF)
	{
	  bz_sendTextMessage (BZ_SERVER, BZ_ALLUSERS, ("CTF has been disabled by " + cs + ".").c_str());
	  allowCTF = false;
	  SetDropTime();
	}
      }
    }
    else if (message == "auto")
    {
      if (autoMode)
      {
	bz_sendTextMessage(BZ_SERVER, playerID, "CTF is already set to \"auto\".");
      }
      else
      {
	autoMode = true;
	bz_sendTextMessage (BZ_SERVER, eAdministrators, ("CTF setting has been changed to \"auto\" by " + cs + ".").c_str());
	UpdateState(eNoTeam);
      }
    }
    else
    {
      bz_sendTextMessage (BZ_SERVER, playerID, "Usage: /ctf on|off|auto");
    }
  }
  return true;
}
Ejemplo n.º 21
0
void FindPath(void *data, unsigned long a, unsigned long b)
{

	if (isInitialSearch) {
		startX = (int)((stateEstimationUpdate.Easting - costmapXMin) / costmapXUnit);
		startY = (int)((stateEstimationUpdate.Northing - costmapYMin) / costmapYUnit);

		//startX = 1940;
		//startY = 1093;

		//goalX = 1850;
		//goalY = 2150;
		InitialSearch();
	} else {

#ifdef DEBUGMAP
		static bool searched = false;
		if (searched == true) return;
		searched = true;

		vector<int> cellsUpdatedXs, cellsUpdatedYs;
		for (int i = 11; i < 20; ++i) 
			for (int j = 7; j < 17; ++j) {
				cellsUpdatedXs.push_back(i);
				cellsUpdatedYs.push_back(j);
				costmap->set(i, j, 3000, 0);
			}

		//for (int i = 2; i < 9; ++i) 
		//	for (int j = 5; j < 9; ++j) {
		//		cellsUpdatedXs.push_back(i);
		//		cellsUpdatedYs.push_back(j);
		//		costmap->set(i, j, 3000, 2);
		//	}


		for (size_t i = 0; i < cellsUpdatedXs.size(); ++i) {
			int x = cellsUpdatedXs[i];
			int y = cellsUpdatedYs[i];

			for (int j = 0; j < lattice.update_n; ++j) {
				//for each corner of updated cell
				int m = x + lattice.update_dx[j];
				int n = y + lattice.update_dy[j];
				if (!isInMap(m, n)) return;
				Node *s = GetOrCreateNode(m, n);
				if (s != startNode)
					UpdateRHSandBptr(s);
				UpdateState(s); 

			}
			//update itself		
			if (!isInMap(x, y)) return;
			Node *s = GetOrCreateNode(x, y);
			if (s != startNode)
				UpdateRHSandBptr(s);
			UpdateState(s);
		}

#else
		if (goalX == -1 || goalY == -1) return;    //no new waypoints

		if (receivedWaypoints) {
			InitialSearch();
			receivedWaypoints = false;
			return;
		}

		if(!receivedNew || !receivedCostMap || !receivedStateEstimation )
			return;
		receivedNew = false;

		LARGE_INTEGER frequency, start, finish;
		QueryPerformanceFrequency(&frequency);
		QueryPerformanceCounter(&start);

		int oldStartX = startX;
		int oldStartY = startY;

		startX = (int)((stateEstimationUpdate.Easting - costmapXMin) / costmapXUnit);
		startY = (int)((stateEstimationUpdate.Northing - costmapYMin) / costmapYUnit);

		//startX = 1940;
		//startY = 1093;

		//spinCounter++;
		//if (spinCounter >= 20) spinCounter = 0;
		//if (spinCounter == 0) {
		//	startX = 2000;
		//	startY = 2000;

		//	goalX = 1700;
		//	goalY = 2300;
		//	receivedNew = true;
		//	receivedCostMap = true;
		//	InitialSearch();
		//	return;
		//} else if (spinCounter == 10) {
		//	startX = 2000;
		//	startY = 2000;

		//	goalX = 2500;
		//	goalY = 2500;
		//	receivedNew = true;
		//	receivedCostMap = true;
		//	InitialSearch();
		//	return;
		//}

		//Avoid Oscillations
		int closestX , closestY, closestIndex;
		int closestDistSquare = LARGE_INT;
		for (int i = 0; i < 50; ++i) {
			if (i == prevPath.size()) break;
			int prevPathX = int((prevPath[i].x - costmapXMin) / costmapXUnit + 0.5f);
			int prevPathY = int((prevPath[i].y - costmapYMin) / costmapYUnit + 0.5f);
			int prevDistSquare = (prevPathX - startX) * (prevPathX - startX) + (prevPathY - startY) * (prevPathY - startY);
			if (prevDistSquare < closestDistSquare) {
				closestDistSquare = prevDistSquare;
				closestX = prevPathX;
				closestY = prevPathY;
				closestIndex = i;
			}
		}
		
		if (closestDistSquare < 40) {
			startX = int((prevPath[max(closestIndex-20, 0)].x - costmapXMin) / costmapXUnit + 0.5f);
			startY = int((prevPath[max(closestIndex-20, 0)].y - costmapYMin) / costmapYUnit + 0.5f);
		}
	

		// planning failure if we start in an obstacle
		if ((*costmap)(startX, startY) > 280){
			startX = (int)((stateEstimationUpdate.Easting - costmapXMin) / costmapXUnit);
			startY = (int)((stateEstimationUpdate.Northing - costmapYMin) / costmapYUnit);
		}
			
		if ((*costmap)(startX, startY) > 280 || (*costmap)(goalX, goalY) > 280) {
			cout << "Planning failed before it began." << endl;
			return;
		}
			
		if (memory[startX][startY] != 0) {
			startNode = memory[startX][startY];
		} else {
			startNode = new Node(startX, startY, DOUBLE_INF, DOUBLE_INF);
			memory[startX][startY] = startNode;
			usedXs.push_back(startX);
			usedYs.push_back(startY);
		}
		if (memory[oldStartX][oldStartY] != 0 && memory[oldStartX][oldStartY]->used == false) {
			usedXs.push_back(oldStartX);
			usedYs.push_back(oldStartY);
			memory[oldStartX][oldStartY]->used = true;
		}
		if (startNode->used == false) {
			usedXs.push_back(startX);
			usedYs.push_back(startY);
			memory[startX][startY]->used = true;
		}

		Node::currStart = startNode;

#endif
		//if (Node::epsilon == 1.9)
		//	Node::epsilon = 1.5;
		//else if (Node::epsilon == 1.5)
		//	Node::epsilon = 1.1;
		//else if (Node::epsilon == 1.1)
		//	Node::epsilon = 1.05;
		//else if (Node::epsilon == 1.05)
		//	Node::epsilon = 1.03;
		//else if (Node::epsilon == 1.03)
		//	Node::epsilon = 1.02;
		//else if (Node::epsilon == 1.02)
		//	Node::epsilon = 1.01;
		//else if (Node::epsilon == 1.01)
		//	Node::epsilon = 1.0;
		//else if (Node::epsilon == 1.0) {
		//	isInitialSearch = true;
		//	//Node::epsilon = 2.5;
		//	return;
		//}

		Node::epsilon = 1.0;
			

		vector<Node*> oldOpen = open->clear();
		for (size_t i = 0; i < oldOpen.size(); ++i ) {
			oldOpen[i]->recalcKey();
			open->add(oldOpen[i]);
		}

		for (list<Node*>::iterator it = incons.begin(); it != incons.end(); ++it) {
			(*it)->inIncons = false;	
			if (!(*it)->inOpen) {
				(*it)->recalcKey();
				open->add(*it);
			}
		}
		incons.clear();
		
		for (list<Node*>::iterator it = closed.begin(); it != closed.end(); ++it) {
			(*it)->inClosed = false;
		}
		closed.clear();

		//cout << "Replanning..." << endl;
		ComputeOrImprovePath();
#ifdef DEBUGMAP
		print(memory, 0, 0, xMax, yMax);
#else

		QueryPerformanceCounter(&finish);

		if (planningFailed) {
			planningFailed = false;
			cout << "Planning Failed with " << timesExpanded << " times expanded." << endl;
			double timeelapsed = ((double)(finish.QuadPart - start.QuadPart))/frequency.QuadPart;
			cout << "Time: " << timeelapsed << "s" << endl;
			timesExpanded = 0;
			return;
		}

		if (timesExpanded > 0) {
			cout << timesExpanded << " times expanded, epsilon = " << Node::epsilon << endl;
			timesExpanded = 0;
			double timeelapsed = ((double)(finish.QuadPart - start.QuadPart))/frequency.QuadPart;
			cout << "Time: " << timeelapsed << "s" << endl;
		}
		//cout << "Making path..." << endl;
		ExtractPath();
#endif
	}
}
Ejemplo n.º 22
0
void fairCTF::Init ( const char* config )
{
  // Initialize defaults
  allowCTF = true;
  autoMode = true;
  max_ratio = .25;
  max_gap_by_1 = 2;
  max_gap = 3;
  drop_delay = 5;
  
  // Parse out args

  std::string rawparams = config;
  
  std::string params[4];
  params[0] = "";
  params[1] = "";
  params[2] = "";
  params[3] = "";

  unsigned int n = 0;
  
  for(unsigned int i = 0; i < rawparams.length(); i++)
  {
    if (rawparams.at(i) == ':')
    {
      n++;
      
      if (n > 3)
      {
	break;
      }
    }
    else
    {
      params[n] += rawparams.at(i);
    }
  }
  
  if(params[0].length() > 0)
  {
    float tempratio = atof(params[0].c_str());
    if (tempratio > 0.0)
    {
      max_ratio = tempratio;
    }
  }
  
  if(params[1].length() > 0)
  {
    int tempmax1gap = atoi(params[1].c_str());
    if (tempmax1gap > 0)
    {
      max_gap_by_1 = tempmax1gap;
    }
  }
  
  if(params[2].length() > 0)
  {
    int tempmaxgap = atoi(params[2].c_str());
    if (tempmaxgap > 0)
    {
      max_gap = tempmaxgap;
    }
  }
  
  if(params[3].length() > 0)
  {
    int tempdelay = atoi(params[3].c_str());
    if (tempdelay > 0)
    {
      drop_delay = tempdelay;
    }
  }
  
  Register(bz_eAllowFlagGrab);
  Register(bz_ePlayerJoinEvent);
  Register(bz_ePlayerPartEvent);
  Register(bz_eTickEvent);
  
  bz_registerCustomSlashCommand ("ctf", this);

  bz_debugMessage(4,"fairCTF plugin loaded");
  
  UpdateState(eNoTeam);
}
Ejemplo n.º 23
0
void CClientState::OnTimer(UINT_PTR nIDEvent) 
{
	UpdateState();
	CDialog::OnTimer(nIDEvent);
}
Ejemplo n.º 24
0
/* called when kart leaves the track */
extern "C" __declspec(dllexport) void RunDeinit()
{
	if (pBuf) UpdateState(STATE_IN_GARAGE);
}
Ejemplo n.º 25
0
// State machine manager.  Layout and content of dialog panel will be changed here based on state.
void ProfileWizard::UpdateState(const int change)
{
    ShowStatus(wxEmptyString);
    if (SemanticCheck(m_State, change))
    {
        m_State = (DialogState) RangeCheck(((int)m_State + change));

        if (m_State >= 0 && m_State < NUM_PAGES)
        {
            const wxBitmap& bmp = *m_bitmaps[m_State];
            m_bitmap->SetSize(bmp.GetSize());
            m_bitmap->SetBitmap(bmp);
        }

        switch (m_State)
        {
        case STATE_GREETINGS:
            SetTitle(TitlePrefix + _("Introduction"));
            m_pPrevBtn->Enable(false);
            m_pGearLabel->Show(false);
            m_pGearChoice->Show(false);
            m_pUserProperties->Show(false);
            m_pWrapUp->Show(false);
            m_pInstructions->SetLabel(_("Welcome to the PHD2 'first light' wizard"));
            m_pHelpText->SetSizeHints(wxSize(-1, TallHelpHeight));
            SetSizerAndFit(m_pvSizer);
            break;
        case STATE_CAMERA:
            SetTitle(TitlePrefix + _("Choose a Guide Camera"));
            m_pPrevBtn->Enable(true);
            m_pGearLabel->SetLabel(_("Guide Camera:"));
            m_pGearChoice->Clear();
            m_pGearChoice->Append(GuideCamera::List());
            if (m_SelectedCamera.length() > 0)
                m_pGearChoice->SetStringSelection(m_SelectedCamera);
            m_pGearLabel->Show(true);
            m_pGearChoice->Show(true);
            m_pUserProperties->Show(true);
            m_pWrapUp->Show(false);
            m_pHelpText->SetSizeHints(wxSize(-1, NormalHelpHeight));
            SetSizerAndFit(m_pvSizer);
            m_pInstructions->SetLabel(_("Select your guide camera and specify the optical properties of your guiding set-up"));
            m_pInstructions->Wrap(TextWrapPoint);
            break;
        case STATE_MOUNT:
            SetTitle(TitlePrefix + _("Choose a Mount Connection"));
            m_pPrevBtn->Enable(true);
            m_pGearLabel->SetLabel(_("Mount:"));
            m_pGearChoice->Clear();
            m_pGearChoice->Append(Scope::List());
            if (m_SelectedMount.length() > 0)
                m_pGearChoice->SetStringSelection(m_SelectedMount);
            m_pUserProperties->Show(false);
            m_pInstructions->SetLabel(_("Select your mount connection - this will determine how guide signals are transmitted"));
            break;
        case STATE_AUXMOUNT:
            if (m_PositionAware)                        // Skip this state if the selected mount is already position aware
            {
                UpdateState(change);
            }
            else
            {
                SetTitle(TitlePrefix + _("Choose an Auxillary Mount Connection (optional)"));
                m_pGearLabel->SetLabel(_("Aux Mount:"));
                m_pGearChoice->Clear();
                m_pGearChoice->Append(Scope::AuxMountList());
                m_pGearChoice->SetStringSelection(m_SelectedAuxMount);      // SelectedAuxMount is never null
                m_pInstructions->SetLabel(_("Since your primary mount connection does not report pointing position, you may want to choose an 'Aux Mount' connection"));
            }
            break;
        case STATE_AO:
            SetTitle(TitlePrefix + _("Choose an Adaptive Optics Device (optional)"));
            m_pGearLabel->SetLabel(_("AO:"));
            m_pGearChoice->Clear();
            m_pGearChoice->Append(StepGuider::List());
            m_pGearChoice->SetStringSelection(m_SelectedAO);            // SelectedAO is never null
            m_pInstructions->SetLabel(_("Specify your adaptive optics device if desired"));
            if (change == -1)                   // User is backing up in wizard dialog
            {
                // Assert UI state for gear selection
                m_pGearGrid->Show(true);
                m_pNextBtn->SetLabel(_("Next >"));
                m_pNextBtn->SetToolTip(_("Move forward to next screen"));
                m_pWrapUp->Show(false);
            }
            break;
        case STATE_WRAPUP:
            SetTitle(TitlePrefix + _("Finish Creating Your New Profile"));
            m_pGearGrid->Show(false);
            m_pWrapUp->Show(true);
            m_pNextBtn->SetLabel(_("Finish"));
            m_pNextBtn->SetToolTip(_("Finish creating the equipment profile"));
            m_pInstructions->SetLabel(_("Enter a name for your profile and optionally launch the process to build a dark library"));
            SetSizerAndFit(m_pvSizer);
            break;
        case STATE_DONE:
            WrapUp();
            break;
        }
    }

    ShowHelp(m_State);
}
Ejemplo n.º 26
0
/* called when simulation is started / resumed */
extern "C" __declspec(dllexport) void RunStart()
{
	if (pBuf) UpdateState(STATE_ON_TRACK);
}
Ejemplo n.º 27
0
void ProfileWizard::OnPrev(wxCommandEvent& evt)
{
    UpdateState(-1);
}
Ejemplo n.º 28
0
/* called when simulation is paused */
extern "C" __declspec(dllexport) void RunStop()
{
	if (pBuf) UpdateState(STATE_ON_TRACK_PAUSED);
}
/* virtual */ void PaletteHolderCtrl::OnPalHideBtnClick( wxCommandEvent& event )
{
	mPaletteCtrl->Show( !mPaletteCtrl->IsShown() );
	UpdateState();
	event.Skip();
}
Ejemplo n.º 30
0
/**
  * Callback invoked when user entered an URL and pressed enter
  */
void WebFrame::OnUrl(wxCommandEvent& WXUNUSED(evt))
{
    m_browser->LoadURL( m_url->GetValue() );
    m_browser->SetFocus();
    UpdateState();
}