MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ui->PixelDisplay1->setSize(DISPLAY_XSIZE, DISPLAY_YSIZE); ui->PixelDisplay1->setDataEncoding(PixelDisplay::MONOCHROME_3310_8bit); ui->PixelDisplay1->setScale(3.0); ui->PixelDisplay2->setSize(DISPLAY_XSIZE, DISPLAY_YSIZE); ui->PixelDisplay2->setDataEncoding(PixelDisplay::MONOCHROME_3310_8bit); ui->PixelDisplay2->setScale(3.0); StatusLabel_LCD0 = new QLabel(this); StatusLabel_LCD1 = new QLabel(this); ui->statusBar->addWidget(StatusLabel_LCD0); ui->statusBar->addWidget(StatusLabel_LCD1); keyDriver1 = new keyDriver(this, 10, 300, 50); // size of enum buttons ? // Signals and slots mapping // View viewSignalMapper = new QSignalMapper(this); viewSignalMapper->setMapping(ui->actionX1, 1); viewSignalMapper->setMapping(ui->actionX2, 2); viewSignalMapper->setMapping(ui->actionX3, 3); viewSignalMapper->setMapping(ui->actionX4, 4); viewSignalMapper->setMapping(ui->actionX5, 5); connect(ui->actionX1, SIGNAL(triggered()), viewSignalMapper, SLOT (map())); connect(ui->actionX2, SIGNAL(triggered()), viewSignalMapper, SLOT (map())); connect(ui->actionX3, SIGNAL(triggered()), viewSignalMapper, SLOT (map())); connect(ui->actionX4, SIGNAL(triggered()), viewSignalMapper, SLOT (map())); connect(ui->actionX5, SIGNAL(triggered()), viewSignalMapper, SLOT (map())); connect(viewSignalMapper, SIGNAL(mapped(const int &)), this, SLOT(on_viewScale_changed(const int &))); // Control buttons press btnPressSignalMapper = new QSignalMapper(this); btnPressSignalMapper->setMapping(ui->pushButton_esc, APP_KEY_ESC); btnPressSignalMapper->setMapping(ui->pushButton_left, APP_KEY_LEFT); btnPressSignalMapper->setMapping(ui->pushButton_right, APP_KEY_RIGHT); btnPressSignalMapper->setMapping(ui->pushButton_ok, APP_KEY_OK); btnPressSignalMapper->setMapping(ui->pushButton_encoder, APP_KEY_ENCODER); connect(ui->pushButton_esc, SIGNAL(pressed()), btnPressSignalMapper, SLOT(map())); connect(ui->pushButton_left, SIGNAL(pressed()), btnPressSignalMapper, SLOT(map())); connect(ui->pushButton_right, SIGNAL(pressed()), btnPressSignalMapper, SLOT(map())); connect(ui->pushButton_ok, SIGNAL(pressed()), btnPressSignalMapper, SLOT(map())); connect(ui->pushButton_encoder, SIGNAL(pressed()), btnPressSignalMapper, SLOT(map())); connect(btnPressSignalMapper, SIGNAL(mapped(const int &)), keyDriver1, SLOT(keyPress(const int &))); // Control buttons release btnReleaseSignalMapper = new QSignalMapper(this); btnReleaseSignalMapper->setMapping(ui->pushButton_esc, APP_KEY_ESC); btnReleaseSignalMapper->setMapping(ui->pushButton_left, APP_KEY_LEFT); btnReleaseSignalMapper->setMapping(ui->pushButton_right, APP_KEY_RIGHT); btnReleaseSignalMapper->setMapping(ui->pushButton_ok, APP_KEY_OK); btnReleaseSignalMapper->setMapping(ui->pushButton_encoder, APP_KEY_ENCODER); connect(ui->pushButton_esc, SIGNAL(released()), btnReleaseSignalMapper, SLOT(map())); connect(ui->pushButton_left, SIGNAL(released()), btnReleaseSignalMapper, SLOT(map())); connect(ui->pushButton_right, SIGNAL(released()), btnReleaseSignalMapper, SLOT(map())); connect(ui->pushButton_ok, SIGNAL(released()), btnReleaseSignalMapper, SLOT(map())); connect(ui->pushButton_encoder, SIGNAL(released()), btnReleaseSignalMapper, SLOT(map())); connect(btnReleaseSignalMapper, SIGNAL(mapped(const int &)), keyDriver1, SLOT(keyRelease(const int &))); connect(keyDriver1, SIGNAL(onKeyEvent(int,int)), this, SLOT(onKeyDriverEvent(int, int))); connect(ui->updateButton,SIGNAL(clicked()),this, SLOT(on_LCD_update())); connect(&updateTimer,SIGNAL(timeout()),this,SLOT(on_LCD_update())); connect(&secondsTimer,SIGNAL(timeout()),this,SLOT(on_secondsTimer())); connect(ui->PixelDisplay1, SIGNAL(touchMove()), this, SLOT(on_touchMove()) ); connect(ui->PixelDisplay1, SIGNAL(touchPress()), this, SLOT(on_touchPress()) ); connect(ui->PixelDisplay1, SIGNAL(touchRelease()), this, SLOT(on_touchRelease()) ); connect(ui->PixelDisplay2, SIGNAL(touchMove()), this, SLOT(on_touchMove()) ); connect(ui->PixelDisplay2, SIGNAL(touchPress()), this, SLOT(on_touchPress()) ); connect(ui->PixelDisplay2, SIGNAL(touchRelease()), this, SLOT(on_touchRelease()) ); qApp->installEventFilter( this ); // This does shrinking of a form when inner widgets are resized //layout()->setSizeConstraint(QLayout::SetFixedSize); pt2Myself = this; registerLogCallback((cbLogPtr)&MainWindow::addLogWrapper); registerLcdUpdateCallback((cbLcdUpdatePtr)&MainWindow::updateDisplayWrapper); guiInitialize(); // Start seconds timer //secondsTimer.start(1000); // Start update timer if (ui->updateCheckBox->checkState()) { updateTimer.start(ui->updateSpinBox->value()); } }
int main(int ac,char **av) { /*****************************************/ /* COMMANDHANDLER is the function type */ /* of the engine's panel command handler */ /* this MUST be resolved at run time */ /* since some HDL module might have */ /* redirected the initial engine function*/ /*****************************************/ COMMANDHANDLER ch; char *str,*bfr; #if defined( OPTION_DYNAMIC_LOAD ) && defined( HDL_USE_LIBTOOL ) /* LTDL Preloaded symbols for HDL using libtool */ LTDL_SET_PRELOADED_SYMBOLS(); #endif /******************************************/ /* Register the 'mywrite' function as the */ /* log callback routine */ /******************************************/ registerLogCallback(mywrite); /******************************************/ /* Initialize the HERCULE Engine */ /******************************************/ impl(ac,av); /******************************************/ /* Get the command handler function */ /* This MUST be done after IML */ /******************************************/ ch=getCommandHandler(); /******************************************/ /* Read STDIN and pass to Command Handler */ /******************************************/ bfr=(char *)malloc(1024); while ( #ifdef _MSVC_ !hLogCallbackThread || WaitForSingleObject(hLogCallbackThread,0) != WAIT_OBJECT_0 #else 1 #endif ) { #ifdef _MSVC_ if (!kbhit()) Sleep(50); else #endif if ((str=fgets(bfr,1024,stdin))) { str[strlen(str)-1]=0; ch(str); } } #ifdef _MSVC_ CloseHandle(hLogCallbackThread); #endif return 0; }