int main(int argc, char** argv) { ClockModel* model = new ClockModel(0, 0, 0); ClockApp app(model, argc, argv); ClockLabelWindow window1(model); ClockWindow window2(model); model->setTime(11, 0, 0); /** 1 second interval. */ app.startTimer(1000); window1.show(); window1.raise(); window1.activateWindow(); window1.move(300, 400); window2.show(); window2.raise(); window2.activateWindow(); window2.move(600, 300); return app.exec(); }
int main () { printf ("Results of cursor_test:\n"); try { common::FileSystem::AddSearchPath ("data"); Window window1 (WindowStyle_Overlapped, 400, 300), window2 (WindowStyle_Overlapped, 400, 300); window2.SetCursor ("aero_busy.ani"); window1.HideCursor (); window1.Show (); window2.Show (); window1.RegisterEventHandler (WindowEvent_OnClose, &destroy); window2.RegisterEventHandler (WindowEvent_OnClose, &destroy); Application::Run (); return Application::GetExitCode (); } catch (std::exception& exception) { printf ("exception: %s\n", exception.what ()); } return 0; }
int main(int argc,char * argv[]) { QApplication app(argc,argv); QDesktopWidget * desktopWidget = QApplication::desktop(); int screenNum = desktopWidget->screenCount(); if (screenNum == 3) { QRect rect; int i; Dialog window0; Dialog window1(&window0); Dialog window2(&window1); qDebug()<<"window0 "<<window0.winId(); qDebug()<<"window1 "<<window1.winId(); qDebug()<<"window2 "<<window2.winId(); for (i=0;i<screenNum;i++) { rect = desktopWidget->screenGeometry(i); qDebug()<<i<<" "<<rect; switch(rect.width()) { case SCREEN0: { window0.move(rect.topLeft()); window0.resize(rect.width(),rect.height()); break; } case SCREEN1: { window1.move(rect.topLeft()); window1.resize(rect.width(),rect.height()); break; } case SCREEN2: { window2.move(rect.topLeft()); window2.resize(rect.width(),rect.height()); break; } } } window0.show(); window1.show(); window2.show(); window2.startTimer(); return app.exec(); } }
USING_NAMESPACE_ACADO int main( ){ // INTRODUCE THE VARIABLES: // -------------------------------------------------- DifferentialState xp, yp, zp, phi, theta, psi, vx, vy, vz, p, q, r, cost; Control u1, u2, u3, u4; Parameter T; // DEFINE THE DIMENSIONS OF THE C-FUNCTIONS: // -------------------------------------------------- CFunction F( 13, myDifferentialEquation ); //CFunction M( NJ, myObjectiveFunction ); //CFunction I( NI, myInitialValueConstraint ); //CFunction E( NE, myEndPointConstraint ); //CFunction H( NH, myInequalityPathConstraint ); DifferentialEquation f ; // const double h = 0.01; // DiscretizedDifferentialEquation f(h); // F.setUserData((void*) &h); // DEFINE THE OPTIMIZATION VARIABLES: // -------------------------------------------------- IntermediateState x(17); x(0) = xp; x(1) = yp; x(2) = zp; x(3) = phi; x(4) = theta; x(5) = psi; x(6) = vx; x(7) = vy; x(8) = vz; x(9) = p; x(10) = q; x(11) = r; x(12) = cost; x(13) = u1; x(14) = u2; x(15) = u3; x(16) = u4; // DEFINE AN OPTIMAL CONTROL PROBLEM: // ---------------------------------- OCP ocp( 0.0, T, 20 ); ocp.minimizeMayerTerm(T);//x(12)); ocp.subjectTo( f << F(x)*T ); ocp.subjectTo( 3 <= T <= 15); // Start constraints for (unsigned int k=0 ; k < 13 ; k++) { ocp.subjectTo(AT_START, x(k) == 0.0); } // End constraints ocp.subjectTo( AT_END, x(0) == 10.0 ); ocp.subjectTo( AT_END, x(1) == 0.0 ); ocp.subjectTo( AT_END, x(2) == 0.0 ); for (unsigned int k=3 ; k < 12 ; k++) { ocp.subjectTo(AT_END, x(k) == 0.0 ); } // Limits on commands ocp.subjectTo(0 <= x(13) <= 60); ocp.subjectTo(-5 <= x(14) <= 5); ocp.subjectTo(-5 <= x(15) <= 5); ocp.subjectTo(-5 <= x(16) <= 5); ocp.subjectTo(x(5) == 0.); ocp.subjectTo( -1.57 <= x(3) <= 1.57); ocp.subjectTo( -1.57 <= x(4) <= 1.57); // ocp.subjectTo(x(4) == 0.); // VISUALIZE THE RESULTS IN A GNUPLOT WINDOW: // ------------------------------------------ GnuplotWindow window1(PLOT_AT_EACH_ITERATION); window1.addSubplot( x(0),"x" ); window1.addSubplot( x(1) , "y"); window1.addSubplot( x(2), "z"); window1.addSubplot( x(3),"phi" ); window1.addSubplot( x(4) , "theta"); window1.addSubplot( x(5), "psi"); window1.addSubplot( x(13),"u1" ); window1.addSubplot( x(14),"u2" ); window1.addSubplot( x(15),"u3" ); window1.addSubplot( x(16),"u4" ); // DEFINE AN OPTIMIZATION ALGORITHM AND SOLVE THE OCP: // --------------------------------------------------- OptimizationAlgorithm algorithm(ocp); // algorithm.set( INTEGRATOR_TOLERANCE, 1e-3 ); // algorithm.set( DISCRETIZATION_TYPE, SINGLE_SHOOTING ); //algorithm.set( HESSIAN_APPROXIMATION, FULL_BFGS_UPDATE ); algorithm.set( INTEGRATOR_TYPE, INT_RK45 ); algorithm.set( MAX_NUM_ITERATIONS, 500 ); algorithm.set( KKT_TOLERANCE, 1e-12); algorithm << window1; // double testx[16]; // for (i=0 ; i<12 ; i++) { // testx[i] = 0.; // } // testx[4] = 0; // testx[3] = 1.57; // testx[13] = 0.; // testx[14] = 0.; // testx[15] = 0.; // testx[16] = 1.; // double testf[13]; // for (i=0 ; i<12 ; i++) { // testf[i] = 0; // } // myDifferentialEquation( testx, testf, testf ); // for ( unsigned int k=0 ; k<12 ; k++ ) { // std::cout << testf[k] << std::endl; // } algorithm.solve(); return 0; }
int MenuLoop(){ sf::RenderWindow window1(sf::VideoMode(32*16, 32*8), "Choose your Character"); window1.setMouseCursorVisible(false); int k=1; //a seconda dell'ultimo tasto premuto nel menu ritorna o 1 o 2 o 3 //icon sf::Image icon; if (!icon.loadFromFile(resourcePath()+"icon.png")) { return EXIT_FAILURE; } window1.setIcon(icon.getSize().x, icon.getSize().y, icon.getPixelsPtr()); sf::Text elfName, druidName, paladinName; elfName.setString("Legolas"); druidName.setString("Radagast"); paladinName.setString("Fra il giusto"); //Font sf::Font font; if (!font.loadFromFile(resourcePath()+"Lobster_1.3.otf")) { std::cout<< "failed to open font"<<std::endl; } sf::Text text; text.setFont(font); text.setString("Menu"); text.setCharacterSize(36); // in pixels, not points! text.setColor(sf::Color::Red); text.setPosition(32*7-24, 0); //Label Characters sf::Text Elflabel, Druidlabel, Paladinlabel; Elflabel.setFont(font); Druidlabel.setFont(font); Paladinlabel.setFont(font); Elflabel.setString("Elf"); Druidlabel.setString("Druid"); Paladinlabel.setString("Paladin"); Elflabel.setCharacterSize(20); // in pixels, not points! Druidlabel.setCharacterSize(20); // in pixels, not points! Paladinlabel.setCharacterSize(20); // in pixels, not points! Elflabel.setColor(sf::Color::Blue); Druidlabel.setColor(sf::Color::Green); Paladinlabel.setColor(sf::Color::White); Elflabel.setPosition(34*3, 60); Druidlabel.setPosition(31*7-2, 60); Paladinlabel.setPosition(31*11-3, 60); //Character's stats sf::Text Elfstats; Elfstats.setFont(font); Elfstats.setString("attack: 50 \n life: 80"); Elfstats.setCharacterSize(15); // in pixels, not points! Elfstats.setColor(sf::Color::White); Elfstats.setPosition(30*3, 145); sf::Text Druidstats; Druidstats.setFont(font); Druidstats.setString("attack: 60 \n life: 70"); Druidstats.setCharacterSize(15); // in pixels, not points! Druidstats.setColor(sf::Color::White); Druidstats.setPosition(31*7-5, 145); sf::Text Paladinstats; Paladinstats.setFont(font); Paladinstats.setString("attack: 70 \n life: 60"); Paladinstats.setCharacterSize(15); // in pixels, not points! Paladinstats.setColor(sf::Color::White); Paladinstats.setPosition(32*11-10, 145); //Character frontal sprites sf::Texture elfTexture, druidTexture, paladinTexture; sf::Sprite elfSprite, druidSprite, paladinSprite; if(!elfTexture.loadFromFile(resourcePath()+"Elf.png")) std::cout<<"Error, could not load elf texture"<<std::endl; elfSprite.setTexture(elfTexture); elfSprite.setTextureRect(sf::IntRect(0,64,32,32)); elfSprite.setPosition(32*3,100); if(!druidTexture.loadFromFile(resourcePath()+"Druid.png")) std::cout<<"Error, could not load druid texture"<<std::endl; druidSprite.setTexture(druidTexture); druidSprite.setTextureRect(sf::IntRect(0,32,32,32)); druidSprite.setPosition(32*7,100); if(!paladinTexture.loadFromFile(resourcePath()+"Paladin.png")) std::cout<<"Error, could not load paladin texture"<<std::endl; paladinSprite.setTexture(paladinTexture); paladinSprite.setTextureRect(sf::IntRect(0,32,32,32)); paladinSprite.setPosition(32*11,100); //animazione quadrato di selezione sf::RectangleShape rectangle; rectangle.setSize(sf::Vector2f(40, 40)); rectangle.setOutlineColor(sf::Color::Yellow); rectangle.setOutlineThickness(5); rectangle.setFillColor(sf::Color::Color(0,0,0,0)); rectangle.setPosition(32*3-4, 100); sf::Event eevv; while (window1.isOpen()){ while (window1.pollEvent(eevv)){ if(eevv.type == sf::Event::Closed){ window1.close(); k=-1; } else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)){ window1.close(); } else if (eevv.key.code==sf::Keyboard::Left){ rectangle.setPosition((32*3)-4,100); k=1; } else if(eevv.key.code==sf::Keyboard::Up){ rectangle.setPosition((32*7)-4,100); k=2; } else if(eevv.key.code==sf::Keyboard::Right){ rectangle.setPosition((32*11)-4,100); k=3; } else if(eevv.key.code==sf::Keyboard::Return){ window1.close(); } window1.clear(); window1.draw(text); window1.draw(elfSprite); window1.draw(druidSprite); window1.draw(paladinSprite); window1.draw(Elflabel); window1.draw(Druidlabel); window1.draw(Paladinlabel); window1.draw(Elfstats); window1.draw(Druidstats); window1.draw(Paladinstats); window1.draw(rectangle); window1.display(); } } return k; }