//----------------------------------------------------------------------------- MyWindow* createWindow( int width, int height ) //----------------------------------------------------------------------------- { MyWindow* pWindow = new MyWindow( width, height ); if( pWindow->can_do() == 0 ) { cout << "OpenGL not possible!!" << endl; } else { cout << "Using OpenGL." << endl; if( pWindow->can_do_overlay() == 0 ) { cout << "OpenGL Overlays not possible!!" << endl; } else { cout << "Using OpenGL Overlays." << endl; } //window->clear_border(); gl_font( FL_TIMES, 12 ); Fl::gl_visual( FL_RGB ); pWindow->end(); pWindow->show(); } return pWindow; }
int main(int argc, char** argv) { CrazyContainer *container = new CrazyContainer(); container->loadXML(); MyWindow *window = new MyWindow(); window->setCrazyContainer(container); Fl_Button *b1 = new Fl_Button(20, 20, 80, 25, "Connect"); b1->callback(connect,(void *)container); Fl_Button *b2 = new Fl_Button(100, 20, 80, 25, "Go 11000"); b2->callback(run,(void *)container); FLContainer::thrustOutput = new Fl_Value_Slider(100,50,250,25,"Thrust meter"); FLContainer::thrustOutput->type(FL_HOR_FILL_SLIDER); FLContainer::thrustOutput->scrollvalue(5000, 100, 5000, 100000); FLContainer::thrustOutput->callback(runCustomThrust,(void *)container); FLContainer::pitch = new Fl_Value_Slider(100,100,250,25,"Pitch"); FLContainer::pitch->type(FL_HORIZONTAL); FLContainer::pitch->scrollvalue(0,10,-180,370); FLContainer::pitch->precision(2); FLContainer::roll = new Fl_Value_Slider(100,140,250,25,"Roll"); FLContainer::roll->type(FL_HORIZONTAL); FLContainer::roll->scrollvalue(0,10,-180,370); FLContainer::roll->precision(2); FLContainer::yaw = new Fl_Value_Slider(100,180,250,25,"Yaw"); FLContainer::yaw->type(FL_HORIZONTAL); FLContainer::yaw->scrollvalue(0,10,-180,370); FLContainer::yaw->precision(2); FLContainer::offsetPitch = new Fl_Value_Slider(100,220,250,25,"Offset Pitch"); FLContainer::offsetPitch->type(FL_HORIZONTAL); FLContainer::offsetPitch->scrollvalue(container->getOffsetPitch(),10,-20,50); FLContainer::offsetPitch->precision(2); FLContainer::offsetPitch->callback(setOffsetPitch,(void *)container); FLContainer::offsetRoll = new Fl_Value_Slider(100,260,250,25,"Offset Roll"); FLContainer::offsetRoll->type(FL_HORIZONTAL); FLContainer::offsetRoll->scrollvalue(container->getOffsetRoll(),10,-20,50); FLContainer::offsetRoll->precision(2); FLContainer::offsetRoll->callback(setOffsetRoll,(void *)container); Fl_Button *b3 = new Fl_Button(200, 20, 80, 25, "Stop"); b3->callback(stop,(void *)container); Fl_Button *bfocus = new Fl_Button(20, 45, 80, 25, "Focus"); Fl_Button *b5 = new Fl_Button(400, 20, 80, 25, "Kill n' Exit"); b5->callback(killnstop,(void *)container); Fl_Button *bsave = new Fl_Button(500, 20, 80, 25, "Plot"); bsave->callback(save,(void *)container); Fl_Button *bload = new Fl_Button(500, 50, 80, 25, "Load"); bload->callback(load,(void *)container); window->end(); window->show(argc,argv); return Fl::run(); }
int main(int argc, char *argv[]) { QGuiApplication a(argc, argv); MyWindow *window = new MyWindow(); window->show(); return a.exec(); }
int main(int argc, char **argv) { int num = 1024; if(argc > 1){ num = atoi(argv[1]); } MyWindow *window = new MyWindow(20,40,300,180,"Hellow, World!", num); // Fl_Box *box = new Fl_Box(20,40,260,100,"Hello, World!"); window->show(argc, argv); return Fl::run(); }
TX_MAIN(argc, argv) { TX_STATIC_ENTRY HbApplication app(argc, argv); app.setApplicationName("Cache proxy model demo"); MyWindow mainWindow; mainWindow.show(); // Enter event loop int ret = app.exec(); TX_STATIC_EXIT return ret; }
int main(int argc, char **argv) { if (!initSDL()) return 1; MyWindow *window = new MyWindow("Running animation"); window->show(); quitSDL(); return 0; }
int main(int argc, char **argv) { MyWindow *window = new MyWindow(); vector<string> args; for(int i = 0; i < argc; ++i) args.push_back(argv[i]); process(args, window); window->show(); return Fl::run(); }
int main(int argc,char *argv[]) { QApplication app(argc, argv); QTranslator translate; translate.load("ucg_fr"); app.installTranslator(&translate); // QHBoxLayout *hbox = new QHBoxLayout; MyWindow fenetre; // LayoutTabArme widget1; // hbox->addWidget(&widget1); // fenetre.setLayout(hbox); fenetre.show(); return app.exec(); }
int main(int argc, char *argv[]) { if (argc <= 1) init_parameters(100,1, 5, 5000.0,5000.0,1000.0, 4,"TDD", 3); else { init_parameters(atoi(argv[2]), atoi(argv[3]), atoi(argv[4]), atof(argv[5]),atof(argv[6]),atof(argv[7]),atoi(argv[8]), argv[9], atoi(argv[10])); pfd[0]= atoi(argv[1]); } QApplication app(argc, argv); MyWindow window; window.move(*(new QPoint(150,100))); window.show(); int end_value = app.exec(); return end_value; }
virtual void onKeyboardButtonPressed(Keyboard& source, const KeyboardEvent& e) { if(e.getButton() == KeyboardButtonType::KEY_F1) { std::cout << "Camera Position:" << std::endl << " X: " << camera->position.x << std::endl << " Y: " << camera->position.y << std::endl << " Z: " << camera->position.z << std::endl << " X Rotation: " << camera->rotation.x << std::endl << " Y Rotation: " << camera->rotation.y << std::endl; } if(e.getButton() == KeyboardButtonType::KEY_F) { if(cameraLight->diffuse.r == 0) { cameraLight->diffuse = Color(1, 1, 1, 1); } else { cameraLight->diffuse = Color(0, 0, 0, 0); } } if(source.isPressed(KeyboardButtonType::KEY_CONTROL)) { if(e.getButton() == KeyboardButtonType::KEY_ADD) { this->setSize(this->getWidth() + 16, this->getHeight() + 12); std::cout << "Window enlarged!" << std::endl; } else if(e.getButton() == KeyboardButtonType::KEY_SUBTRACT) { this->setSize(this->getWidth() - 16, this->getHeight() - 12); std::cout << "Window shrinked!" << std::endl; } else if(e.getButton() == KeyboardButtonType::KEY_R) { this->setResizable(!this->isResizable()); std::cout << "This window is " << (this->isResizable() ? "now resizable." : "not resizable anymore.") << std::endl; } else if(e.getButton() == KeyboardButtonType::KEY_I) { this->showWindowInformation(); } else if(e.getButton() == KeyboardButtonType::KEY_Q) { showHelp(); } else if(e.getButton() == KeyboardButtonType::KEY_X) { this->close(); std::cout << "Window closed!" << std::endl; } else if(e.getButton() == KeyboardButtonType::KEY_H) { if(other == NULL) { std::cout << "Can't hide the window, reason: There is no other window!" << std::endl << "Use CTRL+X to close this window." << std::endl; } else if(!other->isVisible()) { std::cout << "Can't hide the window, reason: The other window is not visible!" << std::endl << "Use CTRL+S to show the other window." << std::endl; } else { this->hide(); std::cout << "Window hidden!" << std::endl; } } else if(e.getButton() == KeyboardButtonType::KEY_S) { if(other == NULL) { std::cout << "Can't show the other window, reason: There is no other window!" << std::endl; } else { other->show(); std::cout << "Showing the other window!" << std::endl; } } } }
//----------------------------------------------------------------------------- int main( int argc, char* argv[] ) //----------------------------------------------------------------------------- { DeviceManager devMgr; cout << "This sample is meant for mvBlueLYNX-M7 devices only. Other devices might be installed" << endl << "but won't be recognized by the application." << endl << endl; int exposureTime_us = 20000; int frameRate_Hz = 5; int width = -1; int height = -1; int interPacketDelay = 25; // scan command line if( argc > 1 ) { for( int i = 1; i < argc; i++ ) { string param( argv[i] ), key, value; string::size_type keyEnd = param.find_first_of( "=" ); if( ( keyEnd == string::npos ) || ( keyEnd == param.length() - 1 ) ) { cout << "Invalid command line parameter: '" << param << "' (ignored)." << endl; } else { key = param.substr( 0, keyEnd ); value = param.substr( keyEnd + 1 ); if( ( key == "exposureTime" ) || ( key == "et" ) ) { exposureTime_us = static_cast<int>( atoi( value.c_str() ) ); } else if( ( key == "frameRate" ) || ( key == "fr" ) ) { frameRate_Hz = static_cast<int>( atoi( value.c_str() ) ); } else if( ( key == "width" ) || ( key == "w" ) ) { width = static_cast<int>( atoi( value.c_str() ) ); } else if( ( key == "height" ) || ( key == "h" ) ) { height = static_cast<int>( atoi( value.c_str() ) ); } else if( key == "scpd" ) { interPacketDelay = static_cast<int>( atoi( value.c_str() ) ); } else { cout << "Invalid command line parameter: '" << param << "' (ignored)." << endl; } } } } else { cout << "No command line parameters specified. Available parameters:" << endl << " 'frameRate' or 'fr' to specify the frame rate(frames per second per sensor head) of the resulting data stream" << endl << " 'exposureTime' or 'et' to specifiy the exposure time per frame in us" << endl << " 'width' or 'w' to specifiy the width of the AOI" << endl << " 'height' or 'h' to specifiy the height of the AOI" << endl << endl << "USAGE EXAMPLE:" << endl << " SynchronousCaptureMultipleInputs et=5000 frameRate=5" << endl << endl; } Device* pDev = getDeviceFromUserInput( devMgr, isDeviceSupportedBySample ); if( !pDev ) { cout << "Unable to continue!"; cout << "Press [ENTER] to end the application" << endl; cin.get(); return 0; } try { cout << "Please note, that this sample (depending on the selected frame rate and resolution) might require a lot" << endl << "of network bandwidth, thus to achieve optimal results, it's crucial to have" << endl << " - a good, reliable network controller (we recommed the Intel PRO/1000 series)" << endl << " - the latest driver for the network controller installed" << endl << " - jumbo frames enabled and the receive and transmit buffer for the network controller set to max. values" << endl << " - the InterfaceMTU on the mvBlueLYNX-M7 set to its maximum value" << endl << endl << "In case of 'rrFrameIncomplete' errors the reason is most certainly to be found in one of" << "the requirments listed above not being met." << endl; cout << "Will try to synchronize sensor heads(" << frameRate_Hz << " fps per head with " << exposureTime_us << "us exposure time per frame) now" << endl << "During this operation the device will be initialised. This might take some time..." << endl; Connector connector( pDev ); CameraSettingsBlueCOUGAR cs( pDev ); try { if( width != -1 ) { cs.aoiWidth.write( width ); } if( height != -1 ) { cs.aoiHeight.write( height ); } } catch( const ImpactAcquireException& e ) { cout << "Failed to set up AOI: " << e.getErrorString() << "(" << e.getErrorCodeAsString() << ")" << endl; } const int SENSOR_HEAD_COUNT = connector.videoChannel.read( plMaxValue ) + 1; setupHRTC( pDev, frameRate_Hz, exposureTime_us, SENSOR_HEAD_COUNT ); // initialise display windows // IMPORTANT: It's NOT save to create multiple display windows in multiple threads!!! ThreadParameter threadParam( pDev, SENSOR_HEAD_COUNT ); DeviceComponentLocator locator( pDev, dltSystemSettings ); PropertyI64 gevStreamChannelSelector; locator.bindComponent( gevStreamChannelSelector, "GevStreamChannelSelector" ); PropertyI64 gevSCPD; locator.bindComponent( gevSCPD, "GevSCPD" ); for( int i = 0; i < SENSOR_HEAD_COUNT; i++ ) { gevStreamChannelSelector.write( i ); gevSCPD.write( interPacketDelay ); MyWindow* p = createWindow( cs.aoiWidth.read(), cs.aoiHeight.read() ); p->show(); p->callback( windowCallback ); threadParam.displayData.push_back( new DisplayInfo( p ) ); } // start the execution of the 'live' thread. cout << "Close any of the display windows to end the application" << endl; liveLoop( &threadParam ); vector<DisplayInfo*>::size_type displayCount = threadParam.displayData.size(); for( vector<DisplayInfo*>::size_type i = 0; i < displayCount; i++ ) { delete threadParam.displayData[i]->pDisp; delete threadParam.displayData[i]; threadParam.displayData[i] = 0; } } catch( const ImpactAcquireException& e ) { // this e.g. might happen if the same device is already opened in another process... cout << "An error occurred while configuring device " << pDev->serial.read() << "(error code: " << e.getErrorCodeAsString() << "). Press [ENTER] to end the application..." << endl; cin.get(); } return 0; }
int main(int argc, char *argv[]) { // setup GPIO interface - uncomment when needed // needs to run with root via sudo in terminal. wiringPiSetup(); pinMode(Physical::OM0, OUTPUT); pinMode(Physical::OM1, OUTPUT); pinMode(Physical::OM2, OUTPUT); pinMode(Physical::OM3, OUTPUT); pinMode(Physical::OM4, OUTPUT); pinMode(Physical::OM5, OUTPUT); pinMode(Physical::OM6, OUTPUT); pinMode(Physical::ORL, OUTPUT); pinMode(Physical::OSL, OUTPUT); pinMode(Physical::OAL, OUTPUT); pinMode(Physical::IM0, INPUT); pinMode(Physical::IM1, INPUT); pinMode(Physical::IM2, INPUT); pinMode(Physical::IM3, INPUT); pinMode(Physical::IM4, INPUT); pinMode(Physical::IM5, INPUT); pinMode(Physical::IM6, INPUT); pinMode(Physical::IRL, INPUT); pinMode(Physical::ISL, INPUT); pinMode(Physical::IAL, INPUT); digitalWrite(Physical::OM0, false); // defaulted to false digitalWrite(Physical::OM1, false); // defaulted to false digitalWrite(Physical::OM2, false); // defaulted to false digitalWrite(Physical::OM3, false); // defaulted to false digitalWrite(Physical::OM4, false); // defaulted to false digitalWrite(Physical::OM5, false); // defaulted to false digitalWrite(Physical::OM6, false); // defaulted to false digitalWrite(Physical::ORL, false); // in case turn off prgm before it returend to false digitalWrite(Physical::OSL, false); digitalWrite(Physical::OAL, false); // defaulted to f pthread_mutex_init(&changingCableMutex, NULL); pthread_cond_init(&cableChangedCondition, NULL); // Just for the sake of 3.4 shared bool variables: TO REMOVE FOR 3.5 qRegisterMetaType<QVector<bool> >("QVector<bool>"); // setup Qt GUI QApplication a(argc, argv); MyWindow w; w.show(); // starting worker thread(s) int rc; pthread_t send_thread; rc = pthread_create(&send_thread, NULL, send, (void*) w.network()); if (rc) { qDebug() << "main.h/main: Unable to start send thread."; exit(1); } pthread_t read_thread; rc = pthread_create(&read_thread, NULL, read, (void*) w.network()); if (rc) { qDebug() << "main.h/main: Unable to start read thread."; exit(1); } // start window event loop qDebug() << "main.h/main: Starting event loop..."; int ret = a.exec(); qDebug() << "main.h/main: Event loop stopped."; // cleanup pthreads // pthread_exit(NULL); // exit return ret; }
//----------------------------------------------------------------------------- unsigned int liveLoop( Device* pDev, bool boStoreFrames, const string& settingName, int iWidth, int iHeight, bool boSingleShotMode ) //----------------------------------------------------------------------------- { cout << " == " << __FUNCTION__ << " - establish access to the statistic properties...." << endl; // establish access to the statistic properties Statistics statistics( pDev ); cout << " == " << __FUNCTION__ << " - create an interface to the device found...." << endl; // create an interface to the device found FunctionInterface fi( pDev ); if( !settingName.empty() ) { cout << "Trying to load setting " << settingName << "..." << endl; int result = fi.loadSetting( settingName ); if( result != DMR_NO_ERROR ) { cout << "loadSetting( \"" << settingName << "\" ); call failed: " << ImpactAcquireException::getErrorCodeAsString( result ) << endl; } } // depending on the device and its sensor, we set an appropriate output format for displaying mvIMPACT::acquire::ImageDestination id( pDev ); if( !std::string( "mvBlueFOX" ).compare( pDev->family.readS() ) ) { mvIMPACT::acquire::InfoBlueFOX ibf( pDev ); if( !std::string( "BayerMosaic" ).compare( ibf.sensorColorMode.readS() ) ) { id.pixelFormat.writeS( "BGR888Packed" ); } } else if( !std::string( "mvBlueCOUGAR" ).compare( pDev->family.readS() ) ) { mvIMPACT::acquire::GenICam::ImageFormatControl ifc( pDev ); if( s_boGreySensor ) { ifc.pixelFormat.writeS( "Mono8" ); } else { GenICamDeviceSetColorPixelFormat( pDev ); id.pixelFormat.writeS( "BGR888Packed" ); } } else if( !std::string( "mvBlueLYNX" ).compare( pDev->family.readS() ) ) { mvIMPACT::acquire::GenICam::ImageFormatControl ifc( pDev ); if( s_boGreySensor ) { ifc.pixelFormat.writeS( "Mono8" ); } else { GenICamDeviceSetColorPixelFormat( pDev ); id.pixelFormat.writeS( "BGR888Packed" ); } } // Pre-fill the capture queue with ALL buffers currently available. In case the acquisition engine is operated // manually, buffers can only be queued when they have been queued before the acquisition engine is started as well. // Even though there can be more than 1, for this sample we will work with the default capture queue int requestResult = DMR_NO_ERROR; int requestCount = 0; if( boSingleShotMode ) { fi.imageRequestSingle(); ++requestCount; } else { while( ( requestResult = fi.imageRequestSingle() ) == DMR_NO_ERROR ) { ++requestCount; } } if( requestResult != DEV_NO_FREE_REQUEST_AVAILABLE ) { cout << "Last result: " << requestResult << "(" << ImpactAcquireException::getErrorCodeAsString( requestResult ) << "), "; } cout << requestCount << " buffers requested"; SystemSettings ss( pDev ); if( ss.requestCount.hasMaxValue() ) { cout << ", max request count: " << ss.requestCount.getMaxValue(); } cout << endl; cout << "Press <<ENTER>> to end the application!!" << endl; MyWindow* pWindow = createWindow( iWidth, iHeight ); pWindow->show(); pWindow->callback( windowCallback ); manuallyStartAcquisitionIfNeeded( pDev, fi ); // run thread loop const Request* pRequest = 0; const unsigned int timeout_ms = 8000; // USB 1.1 on an embedded system needs a large timeout for the first image int requestNr = -1; bool boLoopRunning = true; unsigned int cnt = 0; while( boLoopRunning ) { // wait for results from the default capture queue requestNr = fi.imageRequestWaitFor( timeout_ms ); if( fi.isRequestNrValid( requestNr ) ) { pRequest = fi.getRequest( requestNr ); if( pRequest->isOK() ) { ++cnt; // here we can display some statistical information every 20th image if( cnt % 20 == 0 ) { ostringstream out; out << pDev->serial.read() << ": " << statistics.framesPerSecond.name() << ": " << statistics.framesPerSecond.readS(); pWindow->setOverlayString( out.str() ); cout << cnt << ": Info from " << pDev->serial.read() << ": " << statistics.framesPerSecond.name() << ": " << statistics.framesPerSecond.readS() << ", " << statistics.errorCount.name() << ": " << statistics.errorCount.readS() << ", " << statistics.captureTime_s.name() << ": " << statistics.captureTime_s.readS() << " Image count: " << cnt << " (dimensions: " << pRequest->imageWidth.read() << "x" << pRequest->imageHeight.read() << ", format: " << pRequest->imagePixelFormat.readS(); if( pRequest->imageBayerMosaicParity.read() != bmpUndefined ) { cout << ", " << pRequest->imageBayerMosaicParity.name() << ": " << pRequest->imageBayerMosaicParity.readS(); } cout << ")" << endl; } // here we can store an image every 100th frame if( boStoreFrames && ( cnt % 100 == 0 ) ) { ostringstream oss; oss << "Image" << cnt << "." << pRequest->imageWidth.read() << "x" << pRequest->imageHeight.read() << "." << pRequest->imagePixelFormat.readS(); if( pRequest->imageBayerMosaicParity.read() != bmpUndefined ) { oss << "(BayerPattern=" << pRequest->imageBayerMosaicParity.readS() << ")"; } oss << ".raw"; FILE* fp = fopen( oss.str().c_str(), "wb" ); if( fp ) { unsigned char* pImageData = ( unsigned char* ) pRequest->imageData.read(); for( int h = 0; h < pRequest->imageHeight.read(); h++ ) { // write one line fwrite( pImageData, pRequest->imageWidth.read(), pRequest->imageBytesPerPixel.read(), fp ); // respect image line pitch pImageData += pRequest->imageLinePitch.read(); } fclose( fp ); } } // everything went well. Display the result pWindow->NewRequest( pRequest ); pWindow->redraw(); Fl::check(); } else { cout << "*** Error: A request has been returned with the following result: " << pRequest->requestResult << endl; } // this image has been displayed thus the buffer is no longer needed... fi.imageRequestUnlock( requestNr ); // send a new image request into the capture queue fi.imageRequestSingle(); if( boSingleShotMode ) { manuallyStartAcquisitionIfNeeded( pDev, fi ); } } else { cout << "*** Error: Result of waiting for a finished request: " << requestNr << "(" << ImpactAcquireException::getErrorCodeAsString( requestNr ) << "). Timeout value too small?" << endl; } boLoopRunning = waitForInput( 0, STDOUT_FILENO ) == 0 ? true : false; // break by STDIN // Exit when window was cloesd if( s_boTerminated ) { break; } } if( !boSingleShotMode ) { manuallyStopAcquisitionIfNeeded( pDev, fi ); } cout << " == " << __FUNCTION__ << " - free resources...." << endl; // free resources fi.imageRequestReset( 0, 0 ); return 0; }
int main(int argc, char** argv){ QApplication app(argc, argv); MyWindow window; window.show(); return app.exec(); }