void ContentBoxCtrol::CacheItem(size_t n) const { if ( !m_cache->Has(n) ) { if ( !m_htmlParser ) { ContentBoxCtrol *self = wxConstCast(this, ContentBoxCtrol); self->m_htmlParser = LENMUS_NEW wxHtmlWinParser(self); LMB_TagHandler* pTagHandler = LENMUS_NEW LMB_TagHandler(m_appScope); m_htmlParser->AddTagHandler(pTagHandler); m_htmlParser->SetDC(LENMUS_NEW wxClientDC(self)); m_htmlParser->SetFS(&self->m_filesystem); // use system's default GUI font by default: m_htmlParser->SetFontFace("Tahoma"); m_htmlParser->SetFontSize(10); //m_htmlParser->SetStandardFonts(); } wxHtmlContainerCell *cell = (wxHtmlContainerCell *)m_htmlParser-> Parse(OnGetItemMarkup(n)); wxCHECK_RET( cell, "wxHtmlParser::Parse() returned NULL?" ); // set the cell's ID to item's index so that CellCoordsToPhysical() // can quickly find the item: cell->SetId(wxString::Format("%lu", (unsigned long)n)); cell->Layout(GetClientSize().x - 2*GetMargins().x); m_cache->Store(n, cell); } }
pxStaticText &pxStaticText::WrapAt(int width) { m_autowrap = false; if ((width <= 1) || (width == m_wrappedWidth)) return *this; wxString wrappedLabel; m_wrappedWidth = width; if (width > 1) wrappedLabel = pxTextWrapper().Wrap(this, m_label, width).GetResult(); if (m_wrappedLabel != wrappedLabel) { m_wrappedLabel = wrappedLabel; wxSize area = wxClientDC(this).GetMultiLineTextExtent(m_wrappedLabel); SetMinSize(wxSize( area.GetWidth() + calcPaddingWidth(area.GetWidth()), area.GetHeight() + calcPaddingHeight(area.GetHeight()))); } return *this; }
void WaterfallCanvas::processInputQueue() { tex_update.lock(); gTimer.update(); double targetVis = 1.0 / (double)linesPerSecond; lpsIndex += gTimer.lastUpdateSeconds(); bool updated = false; if (linesPerSecond) { if (lpsIndex >= targetVis) { while (lpsIndex >= targetVis) { SpectrumVisualData *vData; if (!visualDataQueue.empty()) { visualDataQueue.pop(vData); if (vData) { if (vData->spectrum_points.size() == fft_size * 2) { waterfallPanel.setPoints(vData->spectrum_points); } waterfallPanel.step(); vData->decRefCount(); updated = true; } lpsIndex-=targetVis; } else { break; } } } } if (updated) { wxClientDC(this); glContext->SetCurrent(*this); waterfallPanel.update(); } tex_update.unlock(); }
bool MyApp::OnInit() { wxCmdLineParser parser(argc,argv); parser.AddOption(wxT("c"), wxT("config-file")); parser.Parse(); simThread = new SimulationThread(); simThread->Create(); simThread->SetPriority(100); // Populate GUI { //cout << "Frame" << endl; frame = new MainFrame(wxT("Huboplus Control Test 1"), wxPoint(50,50), wxSize(600,400)); } frame->Show(); wxClientDC(frame->glPane); frame->glPane->SetCurrent(); // Load configurations { // load robot stuff const char *filename; wxString configFileName; if(parser.Found(wxT("c"), &configFileName)) { //filename = configFileName.mb_str(); //not working on Linux char cstring[256]; strncpy(cstring, (const char*)configFileName.mb_str(wxConvUTF8), 255); filename = (const char *) cstring; } else { cout<< "Error: cfg file not supplied !\n\n"; exit(1); } cout<<filename<<endl; ifstream cfg_ptr; cfg_ptr.open(filename); Float tmp; // Read simulation timing information. readConfigParameterLabel(cfg_ptr,"Integration_Stepsize"); cfg_ptr >> tmp; simThread->idt = tmp; if (simThread->idt <= 0.0) { cerr << "main error: invalid integration stepsize: " << simThread->idt << endl; exit(3); } readConfigParameterLabel(cfg_ptr,"Control_Stepsize"); cfg_ptr >> tmp; simThread->cdt = tmp; simThread->last_control_time = -2*simThread->cdt; if (simThread->cdt <= 0.0) { cerr << "main error: invalid control stepsize: " << simThread->cdt << endl; exit(3); } readConfigParameterLabel(cfg_ptr,"Display_Update_Rate"); cfg_ptr >> frame->glPane->render_rate; if (frame->glPane->render_rate < 1) frame->glPane->render_rate = 1; // ------------------------------------------------------------------ // Initialize DynaMechs environment - must occur before any linkage systems char env_flname[FILENAME_SIZE]; readConfigParameterLabel(cfg_ptr,"Environment_Parameter_File"); readFilename(cfg_ptr, env_flname); dmEnvironment *environment = dmuLoadFile_env(env_flname); dmEnvironment::setEnvironment(environment); // ------------------------------------------------------------------ // Initialize a DynaMechs linkage system char robot_flname[FILENAME_SIZE]; readConfigParameterLabel(cfg_ptr,"Robot_Parameter_File"); readFilename(cfg_ptr, robot_flname); cout<<"Robot parameter file: [\033[1;34m"<< robot_flname<< "\033[0m]"<<endl; G_robot = dynamic_cast<dmArticulation*>(dmuLoadFile_dm(robot_flname)); cout << "Robot created" << endl; huboCtrl = (HuboController *) new HuboBalanceController(G_robot); cout << "Robot controller created" << endl; // set status bar wxString s; s.Printf(wxT("idt = %1.1e s"), simThread->idt); frame->SetStatusText(s,1); s.Printf(_T("cdt = %f s" ), simThread->cdt); frame->SetStatusText(s,2); s.Printf(_T("refresh every %.2f ms"), 1000/(frame->glPane->render_rate) ); frame->SetStatusText(s,3); // ------------------------ // Read in data directory char data_dir[FILENAME_SIZE]; readConfigParameterLabel(cfg_ptr, "Data_Save_Directory"); readFilename(cfg_ptr, data_dir); // std::string(data_dir) // ... cout<<"Add robot to integrator "<<endl; simThread->G_integrator->addSystem(G_robot); } // ----------------------- { cout<<"Initilize scene..."<<endl; frame->glPane->camera->setRadius(8.0); frame->glPane->camera->setCOI(3.0, 3.0, 0.0); frame->glPane->camera->setTranslationScale(0.02f); frame->glPane->glInit(); dmEnvironment::getEnvironment()->drawInit(); frame->glPane->model_loaded = true; } cout << "Restart Timer" << endl; frame->glPane->restartTimer(); cout << "Start Sim Thread" << endl; simThread->Run(); return true; }
bool MyApp::OnInit() { wxCmdLineParser parser(argc,argv); parser.AddOption(wxT("c"), wxT("Config File")); parser.Parse(); simThread = new SimulationThread(); simThread->Create(); simThread->SetPriority(100); // Populate GUI { //cout << "Frame" << endl; frame = new MainFrame(wxT("Hello GL World"), wxPoint(50,50), wxSize(600,400)); } frame->Show(); wxClientDC(frame->glPane); frame->glPane->SetCurrent(); // Load DM File { // load robot stuff const char *filename; wxString configFileName; if(parser.Found(wxT("c"), &configFileName)) { filename = "humanoid.cfg";//configFileName.mb_str(); } else { filename = (char *) "config.cfg"; } cout<<filename<<endl; ifstream cfg_ptr; cfg_ptr.open(filename); Float tmp; // Read simulation timing information. readConfigParameterLabel(cfg_ptr,"Integration_Stepsize"); cfg_ptr >> tmp; simThread->idt = tmp; if (simThread->idt <= 0.0) { cerr << "main error: invalid integration stepsize: " << simThread->idt << endl; exit(3); } readConfigParameterLabel(cfg_ptr,"Control_Stepsize"); cfg_ptr >> tmp; simThread->cdt = tmp; simThread->last_control_time = -2*simThread->cdt; if (simThread->cdt <= 0.0) { cerr << "main error: invalid control stepsize: " << simThread->cdt << endl; exit(3); } readConfigParameterLabel(cfg_ptr,"Display_Update_Rate"); cfg_ptr >> frame->glPane->render_rate; if (frame->glPane->render_rate < 1) frame->glPane->render_rate = 1; // ------------------------------------------------------------------ // Initialize DynaMechs environment - must occur before any linkage systems char env_flname[FILENAME_SIZE]; readConfigParameterLabel(cfg_ptr,"Environment_Parameter_File"); readFilename(cfg_ptr, env_flname); dmEnvironment *environment = dmuLoadFile_env(env_flname); dmEnvironment::setEnvironment(environment); // ------------------------------------------------------------------ // Initialize a DynaMechs linkage system char robot_flname[FILENAME_SIZE]; readConfigParameterLabel(cfg_ptr,"Robot_Parameter_File"); readFilename(cfg_ptr, robot_flname); G_robot = dynamic_cast<dmArticulation*>(dmuLoadFile_dm(robot_flname)); humanoid = (HumanoidDataLogger *) new BalanceDemoStateMachine(G_robot); // -------- // Read in data directory char data_dir[FILENAME_SIZE]; readConfigParameterLabel(cfg_ptr, "Data_Save_Directory"); readFilename(cfg_ptr, data_dir); humanoid->dataSaveDirectory = std::string(data_dir); simThread->G_integrator->addSystem(G_robot); grfInfo.localContacts = 0; } // -- Project specific -- //initControl(); // ----------------------- { cout<<"initilize scene..."<<endl; frame->glPane->camera->setRadius(8.0); frame->glPane->camera->setCOI(3.0, 3.0, 0.0); frame->glPane->camera->setTranslationScale(0.02f); frame->glPane->glInit(); dmEnvironment::getEnvironment()->drawInit(); frame->glPane->model_loaded = true; } frame->glPane->restartTimer(); simThread->Run(); return true; }