void ReportWriterWindow::sPrepareWindowMenu() { windowMenu->clear(); int intCascadeid = windowMenu->insertItem(tr("&Cascade"), ws, SLOT(cascade())); int intTileid = windowMenu->insertItem(tr("&Tile"), ws, SLOT(tile())); windowMenu->insertSeparator(); int cnt = 0; QWidgetList windows = ws->windowList(); for (unsigned int intCursor = 0; intCursor < windows.count(); intCursor++) { if(windows.at(intCursor)->isVisible()) { int intMenuid = windowMenu->insertItem(windows.at(intCursor)->caption(), windows.at(intCursor), SLOT(setFocus())); windowMenu->setItemChecked(intMenuid, (ws->activeWindow() == windows.at(intCursor))); cnt++; } } if (cnt < 1) { windowMenu->setItemEnabled(intCascadeid, FALSE); windowMenu->setItemEnabled(intTileid, FALSE); } }
CascadingDescriptor::CascadingDescriptor( GenericDescriptor* firstDescriptor) { initializeCascadingDescriptor(); if (firstDescriptor != NULL) { cascade(firstDescriptor); } }
MdiContainerWidgetTaskMenu::MdiContainerWidgetTaskMenu(QWorkspace *m, QObject *parent) : ContainerWidgetTaskMenu(m, MdiContainer, parent) { initializeActions(); connect(m_nextAction, SIGNAL(triggered()), m, SLOT(activateNextWindow())); connect(m_previousAction, SIGNAL(triggered()), m, SLOT(activatePreviousWindow())); connect(m_tileAction, SIGNAL(triggered()),m , SLOT(tile())); connect(m_cascadeAction, SIGNAL(triggered()), m, SLOT(cascade())); }
void main_menu(int value) { if (value == 666) exit(0); if (value == 777) { cascade(); glutPostRedisplay(); } }
CascadingDescriptor::CascadingDescriptor(CascadingDescriptor* descriptor) { initializeCascadingDescriptor(); int i, size; if (descriptor != NULL) { size = ((CascadingDescriptor*)descriptor)->descriptors->size(); for (i = 0; i < size; i++) { cascade((GenericDescriptor*)((*((CascadingDescriptor*) descriptor)->descriptors)[i])); } size = ((CascadingDescriptor*)descriptor)->unsolvedDescriptors->size(); for (i = 0; i < size; i++) { cascade((GenericDescriptor*)((*((CascadingDescriptor*) descriptor)->unsolvedDescriptors)[i])); } } }
// creates a new game field with random tiles // until the game field is playable void GameField::create(void) { do { // create field with random tiles createRandom(); // cascade tiles until not more than two eqal tiles are next to each other cascade(); } while ( !isPlayable() ); }
int main (int argc, char *argvp[]) { tick_t i; tick_t start; tick_t delta; // printf("%lld\n", cputicks()); // printf("%lld\n", cputicks()); start = cputicks(); for (i = 0; i < 400017LL; i++) { delta = cputicks() - start; start = cputicks(); cascade(delta); } pr_cascade(); return 0; }
void ApplicationWindow::windowsMenuAboutToShow() { windowsMenu->clear(); int cascadeId = windowsMenu->insertItem("&Cascade", ws, SLOT(cascade() ) ); int tileId = windowsMenu->insertItem("&Tile", ws, SLOT(tile() ) ); if ( ws->windowList().isEmpty() ) { windowsMenu->setItemEnabled( cascadeId, FALSE ); windowsMenu->setItemEnabled( tileId, FALSE ); } windowsMenu->insertSeparator(); QWidgetList windows = ws->windowList(); for ( int i = 0; i < int(windows.count()); ++i ) { int id = windowsMenu->insertItem(windows.at(i)->caption(), this, SLOT( windowsMenuActivated( int ) ) ); windowsMenu->setItemParameter( id, i ); windowsMenu->setItemChecked( id, ws->activeWindow() == windows.at(i) ); } }
void dispatch_cascade() { int i; MU_BEGIN_TEST(dispatch_cascade); for (i = 0; i < QUEUES; ++i) { queues[i] = dispatch_queue_create(NULL, NULL); } for (i = 0; i < BLOCKS; ++i) { cascade(&indices[i].index); } dispatch_main(); MU_FAIL("Should never reach this"); MU_END_TEST; }
void SetData() { int i, which; double sum_y, sum_yy; // ndata larger indicates finer level scaling fun/wavelets // value gets larger (due to the required integral property) // mother wavelet corresponds to ndata = ?! // // this line of thoughts is not quite right. ndata represents // the dimension of the space. Any space could be regarded as // V0 and the scaling function be the corresponding mother fun. // different "which" collectively represent the basis // of that space. ndata = 8; which = 1; // must be in [0, ndata-1] for (i = 0; i < ndata; i++) { y[i] = 0; dx = 1.0; // dx = 1 is the fact for V0 // what about the basis for V1? // one should convolve the V0 basis with H again x[i] = i*dx; } y[which] = 1.0; for (i = 0; i < 1; i++) { cascade(); } // print out integral, energy value sum_y = sum_yy = 0; for (i = 0; i < ndata; i++) { sum_y += y[i]; sum_yy += y[i]*y[i]; } printf ("%lf %lf\n", sum_y*dx, sum_yy*dx); }
bool QWorkspace::qt_invoke( int _id, QUObject* _o ) { switch ( _id - staticMetaObject()->slotOffset() ) { case 0: cascade(); break; case 1: tile(); break; case 2: closeActiveWindow(); break; case 3: closeAllWindows(); break; case 4: activateNextWindow(); break; case 5: activatePrevWindow(); break; case 6: normalizeActiveWindow(); break; case 7: minimizeActiveWindow(); break; case 8: showOperationMenu(); break; case 9: popupOperationMenu((const QPoint&)*((const QPoint*)static_QUType_ptr.get(_o+1))); break; case 10: operationMenuActivated((int)static_QUType_int.get(_o+1)); break; case 11: operationMenuAboutToShow(); break; case 12: toolMenuAboutToShow(); break; case 13: activatePreviousWindow(); break; case 14: dockWindowsShow(); break; case 15: scrollBarChanged(); break; default: return QWidget::qt_invoke( _id, _o ); } return TRUE; }
void remastructar(ITG *ipompc, double **coefmpcp, ITG **nodempcp, ITG *nmpc, ITG *mpcfree, ITG *nodeboun, ITG *ndirboun, ITG *nboun, ITG *ikmpc, ITG *ilmpc, ITG *ikboun, ITG *ilboun, char *labmpc, ITG *nk, ITG *memmpc_, ITG *icascade, ITG *maxlenmpc, ITG *kon, ITG *ipkon, char *lakon, ITG *ne, ITG *nactdof, ITG *icol, ITG *jq, ITG **irowp, ITG *isolver, ITG *neq, ITG *nzs,ITG *nmethod, ITG *ithermal, ITG *iperturb, ITG *mass, ITG *mi, ITG *ics, double *cs, ITG *mcs,ITG *mortar){ /* reconstructs the nonzero locations in the stiffness and mass matrix after a change in MPC's or the generation of contact spring elements: version for frequency calculations (called by arpack and arpackcs) */ ITG *nodempc=NULL,*mast1=NULL,*ipointer=NULL,mpcend,mpcmult, callfrommain,i,*irow=NULL,mt; double *coefmpc=NULL; nodempc=*nodempcp;coefmpc=*coefmpcp;irow=*irowp; mt=mi[1]+1; /* decascading the MPC's */ printf(" Decascading the MPC's\n\n"); callfrommain=0; cascade(ipompc,&coefmpc,&nodempc,nmpc, mpcfree,nodeboun,ndirboun,nboun,ikmpc, ilmpc,ikboun,ilboun,&mpcend,&mpcmult, labmpc,nk,memmpc_,icascade,maxlenmpc, &callfrommain,iperturb,ithermal); /* determining the matrix structure */ printf(" Determining the structure of the matrix:\n"); if(nzs[1]<10) nzs[1]=10; mast1=NNEW(ITG,nzs[1]); RENEW(irow,ITG,nzs[1]);for(i=0;i<nzs[1];i++) irow[i]=0; if((*mcs==0)||(cs[1]<0)){ ipointer=NNEW(ITG,mt**nk); mastruct(nk,kon,ipkon,lakon,ne,nodeboun,ndirboun,nboun,ipompc, nodempc,nmpc,nactdof,icol,jq,&mast1,&irow,isolver,neq, ikmpc,ilmpc,ipointer,nzs,nmethod,ithermal, ikboun,ilboun,iperturb,mi,mortar); }else{ ipointer=NNEW(ITG,8**nk); mastructcs(nk,kon,ipkon,lakon,ne,nodeboun,ndirboun,nboun, ipompc,nodempc,nmpc,nactdof,icol,jq,&mast1,&irow,isolver, neq,ikmpc,ilmpc,ipointer,nzs,nmethod, ics,cs,labmpc,mcs,mi,mortar); } free(ipointer);free(mast1); RENEW(irow,ITG,nzs[2]); *nodempcp=nodempc;*coefmpcp=coefmpc;*irowp=irow; return; }
MainWindow::MainWindow() : QMainWindow( 0, "MainWindow", WDestructiveClose ) { QDockWindow * pNMWindow; std::map<QString, ServerCreator>::iterator iterCreator; m_pCentralWidget = new QWorkspace(this, "CENTRALWIDGET"); m_pCentralWidget->setScrollBarsEnabled(true); setIcon(app32x32_xpm); setCentralWidget(m_pCentralWidget); // create menus m_pFileMenu = new QPopupMenu(this, "File Menu"); m_pFileNew = new QAction("&New...", QAccel::stringToKey("Ctrl+N"), this, "file.new"); m_pFileNew->setToolTip("Create a new simulation file, ending the current simulation"); connect(m_pFileNew, SIGNAL(activated()), this, SLOT(OnFileNew())); m_pFileNew->addTo(m_pFileMenu); m_pFileEdit = new QAction("&Edit...", QAccel::stringToKey("Ctrl+E"), this, "file.edit"); m_pFileEdit->setToolTip("Edit the current simulation file, ending the current simulation"); connect(m_pFileEdit, SIGNAL(activated()), this, SLOT(OnFileEdit())); m_pFileEdit->setEnabled(false); m_pFileEdit->addTo(m_pFileMenu); m_pFileOpen = new QAction(QPixmap(fileopen), "&Open...", QAccel::stringToKey("Ctrl+O"), this, "file.open"); m_pFileOpen->setToolTip("Open a simulation file, ending the current simulation"); connect(m_pFileOpen, SIGNAL(activated()), this, SLOT(OnFileOpen())); m_pFileOpen->addTo(m_pFileMenu); m_pFileSave = new QAction(QPixmap(filesave), "&Save As...", QAccel::stringToKey("Ctrl+S"), this, "file.save"); m_pFileSave->setToolTip("Save the current setup to a simulation file (this ends any running simulation)"); connect(m_pFileSave, SIGNAL(activated()), this, SLOT(OnFileSave())); m_pFileSave->setEnabled(false); m_pFileSave->addTo(m_pFileMenu); m_pFileMenu->insertSeparator(); m_pFileConfig = new QAction("&Configure...", QKeySequence(), this, "file.config"); m_pFileConfig->setToolTip("Edit the current configuration"); connect(m_pFileConfig, SIGNAL(activated()), this, SLOT(OnFileConfig())); m_pFileConfig->addTo(m_pFileMenu); m_pFileExit = new QAction("E&xit...", QAccel::stringToKey("Ctrl+Q"), this, "file.exit"); m_pFileExit->setToolTip("Exit the program"); connect(m_pFileExit, SIGNAL(activated()), this, SLOT(OnFileExit())); m_pFileExit->addTo(m_pFileMenu); m_pSimMenu = new QPopupMenu(this, "Sim Menu"); m_pSimRun = new QAction("&Run...", QKeySequence(Qt::Key_F2), this, "sim.run"); m_pSimRun->setToolTip("Start a new simulation"); connect(m_pSimRun, SIGNAL(activated()), this, SLOT(OnSimRun())); m_pSimRun->setEnabled(false); m_pSimRun->addTo(m_pSimMenu); m_pSimPause = new QAction("Pause", QKeySequence(Qt::Key_F3), this, "sim.pause"); m_pSimPause->setToolTip("Pause the currently running simulation"); m_pSimPause->setEnabled(false); connect(m_pSimPause, SIGNAL(activated()), this, SLOT(OnSimPause())); m_pSimPause->addTo(m_pSimMenu); m_pSimSkip = new QAction("Skip to next", QKeySequence(), this, "sim.skip"); m_pSimSkip->setToolTip("Skip to the next Monte Carlo iteration of the simulation"); m_pSimSkip->setEnabled(false); connect(m_pSimSkip, SIGNAL(activated()), this, SLOT(OnSimSkip())); m_pSimSkip->addTo(m_pSimMenu); m_pSimStop = new QAction("&Stop", QKeySequence(Qt::SHIFT | Qt::Key_F2), this, "sim.stop"); m_pSimStop->setToolTip("Stop the currently running simulation"); m_pSimStop->setEnabled(false); connect(m_pSimStop, SIGNAL(activated()), this, SLOT(OnSimStop())); m_pSimStop->addTo(m_pSimMenu); m_pNetMenu = new QPopupMenu(this, "Net Menu"); m_pNetInit = new QAction("&Initialize", QKeySequence(), this, "net.init"); m_pNetInit->setToolTip("Initialize network devices and connections"); m_pNetInit->setEnabled(true); connect(m_pNetInit, SIGNAL(activated()), this, SLOT(OnNetInit())); m_pNetInit->addTo(m_pNetMenu); m_pNetClose = new QAction("&Close", QKeySequence(), this, "net.close"); m_pNetClose->setToolTip("Close network devices and connections"); m_pNetClose->setEnabled(false); connect(m_pNetClose, SIGNAL(activated()), this, SLOT(OnNetClose())); m_pNetClose->addTo(m_pNetMenu); m_pNetServer = new QAction("&Stop Server", QKeySequence(), this, "net.server"); m_pNetServer->setToolTip("Stop GrooveNet server"); connect(m_pNetServer, SIGNAL(activated()), this, SLOT(OnNetServer())); m_pNetServerMenu = new QPopupMenu(this, "startserver"); connect(m_pNetServerMenu, SIGNAL(activated(int)), this, SLOT(OnNetServer(int))); for (iterCreator = g_mapServerCreators.begin(); iterCreator != g_mapServerCreators.end(); ++iterCreator) m_pNetServerMenu->insertItem(iterCreator->first); m_iNetServerMenuID = m_pNetMenu->insertItem("&Start Server", m_pNetServerMenu); m_pWindowMenu = new QPopupMenu(this, "Window Menu"); m_pWindowCascade = new QAction("&Cascade", QKeySequence(), this, "window.cascade"); m_pWindowCascade->setToolTip("Cascade all open windows"); connect(m_pWindowCascade, SIGNAL(activated()), m_pCentralWidget, SLOT(cascade())); m_pWindowCascade->addTo(m_pWindowMenu); m_pWindowTile = new QAction("&Tile", QKeySequence(), this, "window.tile"); m_pWindowTile->setToolTip("Tile all open windows"); connect(m_pWindowTile, SIGNAL(activated()), m_pCentralWidget, SLOT(tile())); m_pWindowTile->addTo(m_pWindowMenu); m_pWindowCloseAll = new QAction("Close &All Windows", QKeySequence(), this, "window.closeall"); m_pWindowCloseAll->setToolTip("Close all open windows"); connect(m_pWindowCloseAll, SIGNAL(activated()), m_pCentralWidget, SLOT(closeAllWindows())); m_pWindowCloseAll->addTo(m_pWindowMenu); menuBar()->insertItem("&File", m_pFileMenu); menuBar()->insertItem("&Simulator", m_pSimMenu); menuBar()->insertItem("&Network", m_pNetMenu); menuBar()->insertItem("&Window", m_pWindowMenu); statusBar()->addWidget(m_pLblStatus = new QLabel("Ready", this, "statusbar.label"), 1); statusBar()->setSizeGripEnabled(true); /* pNMWindow = new QDockWindow(this); pNMWindow->setCaption("Network Manager"); pNMWindow->setHorizontallyStretchable(true); pNMWindow->setVerticallyStretchable(false); pNMWindow->setResizeEnabled(true); pNMWindow->setMovingEnabled(true); pNMWindow->setCloseMode(QDockWindow::Always); m_pNetworkManager = new QNetworkManager(pNMWindow, "network manager"); pNMWindow->setWidget(m_pNetworkManager); addDockWindow(pNMWindow, Qt::DockBottom, true); */ tabsContainer = new QToolBar(this); tabsWidget = new QTabWidget(tabsContainer, "tabs"); tabsWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); tabsWidget->setMargin(8); tabsContainer->setStretchableWidget(tabsWidget); tabsContainer->setLabel(tr("GrooveNet - Tooltabs")); addDockWindow(tabsContainer, Qt::DockBottom, TRUE); m_pNetworkManager = new QNetworkManager(tabsContainer, "network manager"); tabsWidget->addTab(m_pNetworkManager, QString("Network Manager")); m_pMessageList = new QMessageList(tabsContainer, "message list"); tabsWidget->addTab(m_pMessageList, QString("Messages")); setAppropriate(tabsContainer, false); tabsWidget->addTab(NULL, QString("Congestion Info")); tabsWidget->addTab(NULL, QString("Playback")); }
QAction *MainWindow::createAction(const QString icon, const QString toolTip, const QString statusTip, bool scripted) { QAction *ACTION = new QAction(QIcon("icons/" + getSettingsGeneralIconTheme() + "/" + icon + ".png"), toolTip, this); //TODO: Qt4.7 wont load icons without an extension... ACTION->setStatusTip(statusTip); ACTION->setObjectName(icon); // TODO: Set What's This Context Help to statusTip for now so there is some infos there. // Make custom whats this context help popup with more descriptive help than just // the status bar/tip one liner(short but not real long) with a hyperlink in the custom popup // at the bottom to open full help file description. Ex: like wxPython AGW's SuperToolTip. ACTION->setWhatsThis(statusTip); // TODO: Finish All Commands ... <.< if (icon == "donothing") connect(ACTION, SIGNAL(triggered()), this, SLOT(doNothing())); else if(icon == "new") { ACTION->setShortcut(QKeySequence::New); connect(ACTION, SIGNAL(triggered()), this, SLOT(newFile())); } else if(icon == "open") { ACTION->setShortcut(QKeySequence::Open); connect(ACTION, SIGNAL(triggered()), this, SLOT(openFile())); } else if(icon == "save") { ACTION->setShortcut(QKeySequence::Save); connect(ACTION, SIGNAL(triggered()), this, SLOT(savefile())); } else if(icon == "saveas") { ACTION->setShortcut(QKeySequence::SaveAs); connect(ACTION, SIGNAL(triggered()), this, SLOT(saveasfile())); } else if(icon == "print") { ACTION->setShortcut(QKeySequence::Print); connect(ACTION, SIGNAL(triggered()), this, SLOT(print())); } else if(icon == "designdetails") { ACTION->setShortcut(QKeySequence("Ctrl+D")); connect(ACTION, SIGNAL(triggered()), this, SLOT(designDetails())); } else if(icon == "exit") { ACTION->setShortcut(QKeySequence("Ctrl+Q")); connect(ACTION, SIGNAL(triggered()), this, SLOT(exit())); } else if(icon == "cut") { ACTION->setShortcut(QKeySequence::Cut); connect(ACTION, SIGNAL(triggered()), this, SLOT(cut())); } else if(icon == "copy") { ACTION->setShortcut(QKeySequence::Copy); connect(ACTION, SIGNAL(triggered()), this, SLOT(copy())); } else if(icon == "paste") { ACTION->setShortcut(QKeySequence::Paste); connect(ACTION, SIGNAL(triggered()), this, SLOT(paste())); } else if(icon == "windowcascade") connect(ACTION, SIGNAL(triggered()), mdiArea, SLOT(cascade())); else if(icon == "windowtile") connect(ACTION, SIGNAL(triggered()), mdiArea, SLOT(tile())); else if(icon == "windowclose") { ACTION->setShortcut(QKeySequence::Close); connect(ACTION, SIGNAL(triggered()), this, SLOT(onCloseWindow())); } else if(icon == "windowcloseall") connect(ACTION, SIGNAL(triggered()), mdiArea, SLOT(closeAllSubWindows())); else if(icon == "windownext") { ACTION->setShortcut(QKeySequence::NextChild); connect(ACTION, SIGNAL(triggered()), mdiArea, SLOT(activateNextSubWindow())); } else if(icon == "windowprevious") { ACTION->setShortcut(QKeySequence::PreviousChild); connect(ACTION, SIGNAL(triggered()), mdiArea, SLOT(activatePreviousSubWindow())); } else if(icon == "help") connect(ACTION, SIGNAL(triggered()), this, SLOT(help())); else if(icon == "changelog") connect(ACTION, SIGNAL(triggered()), this, SLOT(changelog())); else if(icon == "tipoftheday") connect(ACTION, SIGNAL(triggered()), this, SLOT(tipOfTheDay())); else if(icon == "about") connect(ACTION, SIGNAL(triggered()), this, SLOT(about())); else if(icon == "whatsthis") connect(ACTION, SIGNAL(triggered()), this, SLOT(whatsThisContextHelp())); else if(icon == "icon16") connect(ACTION, SIGNAL(triggered()), this, SLOT(icon16())); else if(icon == "icon24") connect(ACTION, SIGNAL(triggered()), this, SLOT(icon24())); else if(icon == "icon32") connect(ACTION, SIGNAL(triggered()), this, SLOT(icon32())); else if(icon == "icon48") connect(ACTION, SIGNAL(triggered()), this, SLOT(icon48())); else if(icon == "icon64") connect(ACTION, SIGNAL(triggered()), this, SLOT(icon64())); else if(icon == "icon128") connect(ACTION, SIGNAL(triggered()), this, SLOT(icon128())); else if(icon == "settingsdialog") connect(ACTION, SIGNAL(triggered()), this, SLOT(settingsDialog())); else if(icon == "undo") connect(ACTION, SIGNAL(triggered()), this, SLOT(undo())); else if(icon == "redo") connect(ACTION, SIGNAL(triggered()), this, SLOT(redo())); else if(icon == "makelayercurrent") connect(ACTION, SIGNAL(triggered()), this, SLOT(makeLayerActive())); else if(icon == "layers") connect(ACTION, SIGNAL(triggered()), this, SLOT(layerManager())); else if(icon == "layerprevious") connect(ACTION, SIGNAL(triggered()), this, SLOT(layerPrevious())); else if(icon == "textbold") { ACTION->setCheckable(true); connect(ACTION, SIGNAL(toggled(bool)), this, SLOT(setTextBold(bool))); }
int main_Cassys(int argc,char* const argv[]) { if (argc==1) { usage(); return 0; } char transducer_list_file_name[FILENAME_MAX]; bool has_transducer_list = false; char text_file_name[FILENAME_MAX]; bool has_text_file_name = false; char alphabet_file_name[FILENAME_MAX]; char transducer_filename_prefix[FILENAME_MAX]; bool has_alphabet = false; char negation_operator[0x20]; Encoding encoding_output = DEFAULT_ENCODING_OUTPUT; int bom_output = DEFAULT_BOM_OUTPUT; int mask_encoding_compatibility_input = DEFAULT_MASK_ENCODING_COMPATIBILITY_INPUT; int must_create_directory = 1; int in_place = 0; struct transducer_name_and_mode_linked_list* transducer_name_and_mode_linked_list_arg=NULL; // decode the command line int val; int index = 1; negation_operator[0]='\0'; transducer_filename_prefix[0]='\0'; struct OptVars* vars=new_OptVars(); while (EOF != (val = getopt_long_TS(argc, argv, optstring_Cassys, lopts_Cassys, &index, vars))) { switch (val) { case 'h': usage(); free_OptVars(vars); free_transducer_name_and_mode_linked_list(transducer_name_and_mode_linked_list_arg); return 0; case 'k': if (vars->optarg[0]=='\0') { fatal_error("Empty input_encoding argument\n"); } decode_reading_encoding_parameter(&mask_encoding_compatibility_input,vars->optarg); break; case 'q': if (vars->optarg[0]=='\0') { fatal_error("Empty output_encoding argument\n"); } decode_writing_encoding_parameter(&encoding_output,&bom_output,vars->optarg); break; case 't': { if (vars -> optarg[0] == '\0') { fatal_error("Command line error : Empty file name argument\n"); } char extension_text_name[FILENAME_MAX]; get_extension(vars -> optarg, extension_text_name); if (strcmp(extension_text_name, ".snt") != 0) { fatal_error( "Command line error : File name argument %s must be a preprocessed snt file\n", vars -> optarg); } strcpy(text_file_name, vars -> optarg); has_text_file_name = true; break; } case 'l': { if(vars -> optarg[0] == '\0'){ fatal_error("Command line error : Empty transducer list argument\n"); } else { strcpy(transducer_list_file_name, vars -> optarg); has_transducer_list = true; } break; } case 'r': { if(vars -> optarg[0] == '\0'){ fatal_error("Command line error : Empty transducer directory argument\n"); } else { strcpy(transducer_filename_prefix, vars -> optarg); has_transducer_list = true; } break; } case 's': { if(vars -> optarg[0] == '\0'){ fatal_error("Command line error : Empty transducer filename argument\n"); } else { transducer_name_and_mode_linked_list_arg=add_transducer_linked_list_new_name(transducer_name_and_mode_linked_list_arg,vars -> optarg); } break; } case 'm': { if(vars -> optarg[0] == '\0'){ fatal_error("Command line error : Empty transducer mode argument\n"); } else { set_last_transducer_linked_list_mode_by_string(transducer_name_and_mode_linked_list_arg,vars -> optarg); } break; } case 'a':{ if (vars -> optarg[0] == '\0') { fatal_error("Command line error : Empty alphabet argument\n"); } else { strcpy(alphabet_file_name, vars -> optarg); has_alphabet = true; } break; } case 'g': if (vars->optarg[0]=='\0') { fatal_error("You must specify an argument for negation operator\n"); } if ((strcmp(vars->optarg,"minus")!=0) && (strcmp(vars->optarg,"-")!=0) && (strcmp(vars->optarg,"tilde")!=0) && (strcmp(vars->optarg,"~")!=0)) { fatal_error("You must specify a valid argument for negation operator\n"); } strcpy(negation_operator,vars->optarg); break; case 'i': { in_place = 1; break; } case 'd': { must_create_directory = 0; break; } default :{ fatal_error("Unknown option : %c\n",val); break; } } } index = -1; if(has_alphabet == false){ fatal_error("Command line error : no alphabet provided\nRerun with --help\n"); } if(has_text_file_name == false){ fatal_error("Command line error : no text file provided\nRerun with --help\n"); } if((has_transducer_list == false) && (transducer_name_and_mode_linked_list_arg == NULL)){ fatal_error("Command line error : no transducer list provided\nRerun with --help\n"); } // Load the list of transducers from the file transducer list and stores it in a list //struct fifo *transducer_list = load_transducer(transducer_list_file_name); if ((transducer_name_and_mode_linked_list_arg == NULL) && has_transducer_list) transducer_name_and_mode_linked_list_arg = load_transducer_list_file(transducer_list_file_name); struct fifo *transducer_list=load_transducer_from_linked_list(transducer_name_and_mode_linked_list_arg,transducer_filename_prefix); cascade(text_file_name, in_place, must_create_directory, transducer_list, alphabet_file_name,negation_operator,encoding_output,bom_output,mask_encoding_compatibility_input); free_fifo(transducer_list); free_OptVars(vars); free_transducer_name_and_mode_linked_list(transducer_name_and_mode_linked_list_arg); return 0; }
/* The "Window" menu item is created dynamically; This slot creates the menu items for the Window menu before it's shown. */ void CMDIWindow::windowMenuAboutToShow() { #ifdef DEBUG qDebug("CMDIWindow::windowMenuAboutToShow()"); #endif windowMenu->clear(); int consoleWindowId = windowMenu->insertItem(consoleWindow->caption(), this, SLOT(consoleWindowDisplay())); windowMenu->setItemParameter(consoleWindowId, 0); windowMenu->setItemChecked(consoleWindowId, !consoleWindow->isHidden()); windowMenu->insertSeparator(); int closeId = windowMenu->insertItem(getPixmapIcon("closeIcon"), tr("Cl&ose"), this, SLOT(closeActiveWindow())); int closeAllId = windowMenu->insertItem(getPixmapIcon("closeAllIcon"), tr("Close Al&l"), this, SLOT(closeAllWindows())); windowMenu->insertSeparator(); int cascadeId = windowMenu->insertItem(getPixmapIcon("cascadeIcon"), tr("&Cascade"), CApplication::Application()->workSpace(), SLOT(cascade())); int tileId = windowMenu->insertItem(getPixmapIcon("tileIcon"), tr("&Tile"), CApplication::Application()->workSpace(), SLOT(tile())); QWidgetList openWindows = CApplication::Application()->workSpace()->windowList(); if ( ((openWindows.count() <= 1) || (CApplication::Application()->workSpace()->windowList().isEmpty())) && (consoleWindow->isHidden())) { windowMenu->setItemEnabled( closeId, false); windowMenu->setItemEnabled( closeAllId, false); windowMenu->setItemEnabled( cascadeId, false); windowMenu->setItemEnabled( tileId, false); } else if (openWindows.count() > 1) windowMenu->insertSeparator(); for ( int i = 1; i < int(openWindows.count()); ++i ) { int id = windowMenu->insertItem(openWindows.at(i)->caption(), this, SLOT(windowActivated(int))); windowMenu->setItemParameter(id, i); windowMenu->setItemChecked(id, CApplication::Application()->workSpace()->activeWindow() == openWindows.at(i)); } }
int main(int argc, char* argv[]) { gflags::SetUsageMessage("[options] full_path_to_urdf_or_sdf_file"); gflags::ParseCommandLineFlags(&argc, &argv, true); if (argc < 2) { gflags::ShowUsageWithFlags(argv[0]); return 1; } logging::HandleSpdlogGflags(); // todo: consider moving this logic into the RigidBodySystem class so it can // be reused FloatingBaseType floating_base_type = kQuaternion; if (FLAGS_base == "kFixed") { floating_base_type = kFixed; } else if (FLAGS_base == "RPY") { floating_base_type = kRollPitchYaw; } else if (FLAGS_base == "QUAT") { floating_base_type = kQuaternion; } else { throw std::runtime_error(string("Unknown base type") + FLAGS_base + "; must be kFixed, RPY, or QUAT"); } auto rigid_body_sys = make_shared<RigidBodySystem>(); rigid_body_sys->AddModelInstanceFromFile(argv[argc - 1], floating_base_type); auto const& tree = rigid_body_sys->getRigidBodyTree(); if (FLAGS_add_flat_terrain) { SPDLOG_TRACE(drake::log(), "adding flat terrain"); double box_width = 1000; double box_depth = 10; DrakeShapes::Box geom(Vector3d(box_width, box_width, box_depth)); Isometry3d T_element_to_link = Isometry3d::Identity(); T_element_to_link.translation() << 0, 0, -box_depth / 2; // top of the box is at z=0 RigidBody<double>& world = tree->world(); Vector4d color; color << 0.9297, 0.7930, 0.6758, 1; // was hex2dec({'ee','cb','ad'})'/256 in matlab world.AddVisualElement( DrakeShapes::VisualElement(geom, T_element_to_link, color)); tree->addCollisionElement( DrakeCollision::Element(geom, T_element_to_link, &world), world, "terrain"); tree->compile(); } shared_ptr<lcm::LCM> lcm = make_shared<lcm::LCM>(); auto visualizer = make_shared<BotVisualizer<RigidBodySystem::StateVector>>(lcm, tree); auto sys = cascade(rigid_body_sys, visualizer); SimulationOptions options; options.realtime_factor = 1.0; options.timeout_seconds = std::numeric_limits<double>::infinity(); options.initial_step_size = 5e-3; runLCM(sys, lcm, 0, std::numeric_limits<double>::infinity(), getInitialState(*sys), options); // simulate(*sys, 0, std::numeric_limits<double>::max(), // getInitialState(*sys), options); return 0; }
void remastruct(ITG *ipompc, double **coefmpcp, ITG **nodempcp, ITG *nmpc, ITG *mpcfree, ITG *nodeboun, ITG *ndirboun, ITG *nboun, ITG *ikmpc, ITG *ilmpc, ITG *ikboun, ITG *ilboun, char *labmpc, ITG *nk, ITG *memmpc_, ITG *icascade, ITG *maxlenmpc, ITG *kon, ITG *ipkon, char *lakon, ITG *ne, ITG *nactdof, ITG *icol, ITG *jq, ITG **irowp, ITG *isolver, ITG *neq, ITG *nzs,ITG *nmethod, double **fp, double **fextp, double **bp, double **aux2p, double **finip, double **fextinip,double **adbp, double **aubp, ITG *ithermal, ITG *iperturb, ITG *mass, ITG *mi,ITG *iexpl,ITG *mortar, char *typeboun,double **cvp,double **cvinip,ITG *iit){ /* reconstructs the nonzero locations in the stiffness and mass matrix after a change in MPC's */ ITG *nodempc=NULL,*mast1=NULL,*ipointer=NULL,mpcend,mpcmult, callfrommain,i,*irow=NULL,mt,im; double *coefmpc=NULL,*f=NULL,*fext=NULL,*b=NULL,*aux2=NULL, *fini=NULL,*fextini=NULL,*adb=NULL,*aub=NULL,*cv=NULL,*cvini=NULL; nodempc=*nodempcp;coefmpc=*coefmpcp;irow=*irowp; f=*fp;fext=*fextp;b=*bp;aux2=*aux2p;fini=*finip; fextini=*fextinip;adb=*adbp;aub=*aubp;cv=*cvp;cvini=*cvinip; mt=mi[1]+1; /* decascading the MPC's */ printf(" Decascading the MPC's\n\n"); callfrommain=0; cascade(ipompc,&coefmpc,&nodempc,nmpc, mpcfree,nodeboun,ndirboun,nboun,ikmpc, ilmpc,ikboun,ilboun,&mpcend,&mpcmult, labmpc,nk,memmpc_,icascade,maxlenmpc, &callfrommain,iperturb,ithermal); /* determining the matrix structure */ printf(" Determining the structure of the matrix:\n"); if(nzs[1]<10) nzs[1]=10; NNEW(mast1,ITG,nzs[1]); NNEW(ipointer,ITG,mt**nk); RENEW(irow,ITG,nzs[1]);for(i=0;i<nzs[1];i++) irow[i]=0; mastruct(nk,kon,ipkon,lakon,ne,nodeboun,ndirboun,nboun,ipompc, nodempc,nmpc,nactdof,icol,jq,&mast1,&irow,isolver,neq, ikmpc,ilmpc,ipointer,nzs,nmethod,ithermal, ikboun,ilboun,iperturb,mi,mortar,typeboun,labmpc); SFREE(ipointer);SFREE(mast1); RENEW(irow,ITG,nzs[2]); *nodempcp=nodempc;*coefmpcp=coefmpc;*irowp=irow; /* reallocating fields the size of which depends on neq[1] or *nzs */ RENEW(f,double,neq[1]);DMEMSET(f,0,neq[1],0.); RENEW(fext,double,neq[1]);DMEMSET(fext,0,neq[1],0.); RENEW(b,double,neq[1]);DMEMSET(b,0,neq[1],0.); RENEW(fini,double,neq[1]); /* for static calculations fini has to be set to f at the start of the calculation; in dynamic calculations this is not needed, since the initial accelerations has already been calculated */ if((*nmethod!=4)&&(*iit==-1)) DMEMSET(fini,0,neq[1],0.); if(*nmethod==4){ RENEW(aux2,double,neq[1]);DMEMSET(aux2,0,neq[1],0.); RENEW(cv,double,neq[1]); RENEW(cvini,double,neq[1]); RENEW(fextini,double,neq[1]); // for(i=0;i<neq[1];i++) fextini[i]=0.; /* the mass matrix is diagonal in an explicit dynamic calculation and is not changed by contact; this assumes that the number of degrees of freedom does not change */ if(*iexpl<=1){ RENEW(adb,double,neq[1]);for(i=0;i<neq[1];i++) adb[i]=0.; RENEW(aub,double,nzs[1]);for(i=0;i<nzs[1];i++) aub[i]=0.; mass[0]=1; } } *fp=f;*fextp=fext;*bp=b;*aux2p=aux2;*finip=fini; *fextinip=fextini;*adbp=adb;*aubp=aub;*cvp=cv;*cvinip=cvini; return; }
// do-loop for gaming till one player has lost (starting at 1) const unsigned int Game::doStart(const bool contest) { do { #ifdef DEBUG std::cout << "Player's " << m_currentPlayer+1 << " turn!" << std::endl; #endif if ( !writeData() ) { break; } #ifdef DEBUG // print game field m_field.print(); #endif if ( !contest ) { std::cout << "Manually save result.dat and hit enter!" << std::endl; getchar(); } else { // call routine for AI if ( 0 == m_currentPlayer ) { if ( system ("./fm-ai1.bin") ) { std::cout << "Game::doStart() error: calling fm-ai1 failed" << std::endl; // this player will loose the contest m_player[m_currentPlayer].looseAllLife(); break; } } else { if ( system ("./fm-ai2.bin") ) { std::cout << "Game::doStart() error: calling fm-ai2 failed" << std::endl; // this player will loose the contest m_player[m_currentPlayer].looseAllLife(); break; } } } // now we must read the result that has stored to positions FieldPos pos1, pos2; if ( !readResult(pos1, pos2) ) { // file could not be read break; } #ifdef DEBUG std::cout << "Game::doStart() info: swap " << pos1.x() << " " << pos1.y() << " with " << pos2.x() << " " << pos2.y() << std::endl; #endif // delete files deleteFiles(); // switch positions on game field if ( m_field.swapTiles(pos1, pos2) ) { // remove all matching tiles if ( !cascade(contest) ) { break; } } else { #ifdef DEBUG std::cout << "Game::doStart() Illegal move: loose 5 life" << std::endl; #endif m_player[m_currentPlayer].looseLife(5); // getchar(); } // set next player (if necessary) nextPlayer(); // check if gamefield is playable and remove lower lines // until the game is playable again if ( !checkIfPlayable(contest) ) { break; } #ifdef DEBUG // print player info printPlayers(); #endif // getchar(); } while ( !isOnePlayerDead() ); return checkWhosDead(); }
void Portal::construct_actions() { m_open_action = new QAction( Svg_icon( ":/icons/open.svg", this->iconSize() ), tr("&Open"), this); m_open_action->setShortcut(tr("Ctrl+F")); m_open_action->setStatusTip(tr("Open an existing file")); connect(m_open_action, SIGNAL(triggered()), this, SLOT(open())); m_close_action = new QAction( Svg_icon( ":/icons/close.svg", this->iconSize() ), tr("&Close"), this); m_close_action->setShortcut(tr("Ctrl+F4")); m_close_action->setStatusTip(tr("Close window")); connect(m_close_action, SIGNAL(triggered()), this, SLOT(close())); m_help_action = new QAction( Svg_icon( ":/icons/help_book.svg", this->iconSize() ), tr("&Help"), this); m_help_action->setShortcut(tr("F1")); m_help_action->setStatusTip(tr("Help me out there!")); connect(m_help_action, SIGNAL(triggered()), this, SLOT(help())); m_exit_action = new QAction( Svg_icon( ":/icons/exit.svg", this->iconSize() ), tr("E&xit"), this); m_exit_action->setStatusTip(tr("Exit application")); connect(m_exit_action, SIGNAL(triggered()), (QApplication*)QApplication::instance(), SLOT(closeAllWindows())); m_tile_action = new QAction( Svg_icon( ":/icons/tile_horiz.svg", this->iconSize() ), tr("&Tile"), this); m_tile_action->setStatusTip(tr("Tile windows")); connect(m_tile_action, SIGNAL(triggered()), m_workspace, SLOT(tile())); m_cascade_action = new QAction( Svg_icon( ":/icons/cascade.svg", this->iconSize() ), tr("&Cascade"), this); m_cascade_action->setStatusTip(tr("Cascade windows")); connect(m_cascade_action, SIGNAL(triggered()), m_workspace, SLOT(cascade())); m_flat_action = new QAction( Svg_icon( ":/icons/flat.svg", this->iconSize() ), tr("&Flat"), this ); m_flat_action->setCheckable( true ); m_flat_action->setChecked( false ); m_flat_action->setStatusTip(tr("Flat shading")); connect( m_flat_action, SIGNAL(toggled(bool)), this, SLOT(handle_glpad_command()) ); m_phong_action = new QAction( Svg_icon( ":/icons/phong.svg", this->iconSize() ), tr("&Phong"), this ); m_phong_action->setCheckable( true ); m_phong_action->setChecked( true ); m_phong_action->setStatusTip(tr("Phong shading")); connect( m_phong_action, SIGNAL(toggled(bool)), this, SLOT(handle_glpad_command()) ); m_wireframe_action = new QAction( Svg_icon( ":/icons/wireframe.svg", this->iconSize() ), tr("&Wireframe"), this ); m_wireframe_action->setCheckable( true ); m_wireframe_action->setChecked( false ); m_wireframe_action->setStatusTip(tr("Show wireframe")); connect( m_wireframe_action, SIGNAL(toggled(bool)), this, SLOT(handle_glpad_command()) ); m_center_action = new QAction( Svg_icon( ":/icons/center.svg", this->iconSize() ), tr("&Center"), this ); m_center_action->setObjectName(tr("center")); m_center_action->setStatusTip(tr("Center scene")); connect( m_center_action, SIGNAL(triggered()), this, SLOT(handle_glpad_command()) ); m_shading_actions = new QActionGroup(this); m_shading_actions->addAction( m_wireframe_action ); m_shading_actions->addAction( m_flat_action ); m_shading_actions->addAction( m_phong_action ); m_culling_action = new QAction( Svg_icon( ":/icons/culling.svg", this->iconSize() ), tr("&Back Face Culling"), this ); m_culling_action->setCheckable( true ); m_culling_action->setChecked( true ); m_culling_action->setStatusTip(tr("Toggle back-face culling")); connect( m_culling_action, SIGNAL(toggled(bool)), this, SLOT(handle_glpad_command()) ); m_texture_action = new QAction( Svg_icon( ":/icons/texture.svg", this->iconSize() ), tr("&Texture Rendering"), this ); m_texture_action->setCheckable( true ); m_texture_action->setChecked( true ); m_texture_action->setStatusTip(tr("Toggle texture rendering")); connect( m_texture_action, SIGNAL(toggled(bool)), this, SLOT(handle_glpad_command()) ); }
void TVDemo::handleEvent(TEvent &event) { TApplication::handleEvent(event); if (event.what == evCommand) { switch (event.message.command) { case cmAboutCmd: // About Dialog Box aboutDlgBox(); break; case cmCalendarCmd: // Calendar Window calendar(); break; case cmAsciiCmd: // Ascii Table asciiTable(); break; case cmCalcCmd: // Calculator calculator(); break; case cmPuzzleCmd: // Puzzle puzzle(); break; case cmOpenCmd: // View a file openFile("*.*"); break; case cmChDirCmd: // Change directory changeDir(); break; case cmDOS_Cmd: // DOS shell shell(); break; case cmTile: // Tile current file windows tile(); break; case cmCascade: // Cascade current file windows cascade(); break; case cmMouseCmd: // Mouse control dialog box mouse(); break; case cmColorCmd: // Color control dialog box colors(); break; case cmSaveCmd: // Save current desktop saveDesktop(); break; case cmRestoreCmd: // Restore saved desktop retrieveDesktop(); break; default: // Unknown command return; } clearEvent (event); } }
void MainWindow::createActions() { openAction = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this); openAction->setShortcut(tr("Ctrl+O")); openAction->setStatusTip(tr("Open an existing file")); connect(openAction, SIGNAL(triggered()), this, SLOT(open())); saveAction = new QAction(QIcon(":/images/save.png"), tr("&Save"), this); saveAction->setShortcut(tr("Ctrl+S")); saveAction->setStatusTip(tr("Save the file to disk")); connect(saveAction, SIGNAL(triggered()), this, SLOT(save())); saveAsAction = new QAction(tr("Save &As..."), this); saveAsAction->setStatusTip(tr("Save the file under a new name")); connect(saveAsAction, SIGNAL(triggered()), this, SLOT(saveAs())); exitAction = new QAction(tr("E&xit"), this); exitAction->setShortcut(tr("Ctrl+Q")); exitAction->setStatusTip(tr("Exit the application")); connect(exitAction, SIGNAL(triggered()), this, SLOT(close())); closeAction = new QAction(tr("Cl&ose"), this); closeAction->setShortcut(tr("Ctrl+F4")); closeAction->setStatusTip(tr("Close the active window")); connect(closeAction, SIGNAL(triggered()), workspace, SLOT(closeActiveWindow())); closeAllAction = new QAction(tr("Close &All"), this); closeAllAction->setStatusTip(tr("Close all windows")); connect(closeAllAction, SIGNAL(triggered()), workspace, SLOT(closeAllWindows())); tileAction = new QAction(tr("&Tile"), this); tileAction->setStatusTip(tr("Tile the windows")); connect(tileAction, SIGNAL(triggered()), workspace, SLOT(tile())); cascadeAction = new QAction(tr("&Cascade"), this); cascadeAction->setStatusTip(tr("Cascade the windows")); connect(cascadeAction, SIGNAL(triggered()), workspace, SLOT(cascade())); nextAction = new QAction(tr("Ne&xt"), this); nextAction->setShortcut(tr("Ctrl+F6")); nextAction->setStatusTip(tr("Move the focus to the next window")); connect(nextAction, SIGNAL(triggered()), workspace, SLOT(activateNextWindow())); previousAction = new QAction(tr("Pre&vious"), this); previousAction->setShortcut(tr("Ctrl+Shift+F6")); previousAction->setStatusTip(tr("Move the focus to the previous " "window")); connect(previousAction, SIGNAL(triggered()), workspace, SLOT(activatePreviousWindow())); separatorAction = new QAction(this); separatorAction->setSeparator(true); aboutAction = new QAction(tr("&About"), this); aboutAction->setStatusTip(tr("Show the application's About box")); connect(aboutAction, SIGNAL(triggered()), this, SLOT(about())); powerSpectrumFFTAction = new QAction(tr("Power spectrum with &FFT"), this); powerSpectrumFFTAction->setIcon(QIcon(":/images/fft.png")); powerSpectrumFFTAction->setShortcut(tr("Ctrl+F")); powerSpectrumFFTAction->setStatusTip(tr("Get power spectrum using FFT")); connect(powerSpectrumFFTAction, SIGNAL(triggered()), this, SLOT(getPowerSpectrumUsingFFT())); powerSpectrumDCTAction = new QAction(tr("Power spectrum with &DCT"), this); powerSpectrumDCTAction->setIcon(QIcon(":/images/dct.png")); powerSpectrumDCTAction->setShortcut(tr("Ctrl+D")); powerSpectrumDCTAction->setStatusTip(tr("Get power spectrum using DCT")); connect(powerSpectrumDCTAction, SIGNAL(triggered()), this, SLOT(getPowerSpectrumUsingDCT())); linearConvolutionFFTAction = new QAction(tr("Convolution using FFT"), this); linearConvolutionFFTAction->setIcon(QIcon(":/images/cfft.png")); linearConvolutionFFTAction->setShortcut(tr("Ctrl+L")); linearConvolutionFFTAction->setStatusTip(tr("Convolution using FFT")); connect(linearConvolutionFFTAction, SIGNAL(triggered()), this, SLOT(convolutionFFTDialog())); linearConvolutionDCTAction = new QAction(tr("Convolution using DCT"), this); linearConvolutionDCTAction->setIcon(QIcon(":/images/cdct.png")); linearConvolutionDCTAction->setShortcut(tr("Ctrl+K")); linearConvolutionDCTAction->setStatusTip(tr("Convolution using DCT")); connect(linearConvolutionDCTAction, SIGNAL(triggered()), this, SLOT(convolutionDCTDialog())); windowActionGroup = new QActionGroup(this); }
QAction *MainWindow::createAction(const QString icon, const QString toolTip, const QString statusTip, bool scripted) { QAction *ACTION = new QAction(QIcon("icons/" + getSettingsGeneralIconTheme() + "/" + icon + ".png"), toolTip, this); //TODO: Qt4.7 wont load icons without an extension... ACTION->setStatusTip(statusTip); ACTION->setObjectName(icon); // TODO: Finish All Commands ... <.< if (icon == "donothing") connect(ACTION, SIGNAL(triggered()), this, SLOT(doNothing())); else if(icon == "new") { ACTION->setShortcut(QKeySequence::New); connect(ACTION, SIGNAL(triggered()), this, SLOT(newfile())); } else if(icon == "open") { ACTION->setShortcut(QKeySequence::Open); connect(ACTION, SIGNAL(triggered()), this, SLOT(openfile())); } else if(icon == "save") { ACTION->setShortcut(QKeySequence::Save); connect(ACTION, SIGNAL(triggered()), this, SLOT(savefile())); } else if(icon == "saveas") { ACTION->setShortcut(QKeySequence::SaveAs); connect(ACTION, SIGNAL(triggered()), this, SLOT(saveasfile())); } else if(icon == "print") { ACTION->setShortcut(QKeySequence::Print); connect(ACTION, SIGNAL(triggered()), this, SLOT(print())); } else if(icon == "close") { ACTION->setShortcut(QKeySequence::Close); connect(ACTION, SIGNAL(triggered()), this, SLOT(onCloseWindow())); } else if(icon == "designdetails") { ACTION->setShortcut(QKeySequence("Ctrl+D")); connect(ACTION, SIGNAL(triggered()), this, SLOT(designDetails())); } else if(icon == "exit") { ACTION->setShortcut(QKeySequence("Ctrl+Q")); connect(ACTION, SIGNAL(triggered()), this, SLOT(exit())); } else if(icon == "cut") { ACTION->setShortcut(QKeySequence::Cut); connect(ACTION, SIGNAL(triggered()), this, SLOT(cut())); } else if(icon == "copy") { ACTION->setShortcut(QKeySequence::Copy); connect(ACTION, SIGNAL(triggered()), this, SLOT(copy())); } else if(icon == "paste") { ACTION->setShortcut(QKeySequence::Paste); connect(ACTION, SIGNAL(triggered()), this, SLOT(paste())); } else if(icon == "windowcascade") connect(ACTION, SIGNAL(triggered()), mdiArea, SLOT(cascade())); else if(icon == "windowtile") connect(ACTION, SIGNAL(triggered()), mdiArea, SLOT(tile())); else if(icon == "windowcloseall") connect(ACTION, SIGNAL(triggered()), mdiArea, SLOT(closeAllSubWindows())); else if(icon == "windownext") { ACTION->setShortcut(QKeySequence::NextChild); connect(ACTION, SIGNAL(triggered()), mdiArea, SLOT(activateNextSubWindow())); } else if(icon == "windowprevious") { ACTION->setShortcut(QKeySequence::PreviousChild); connect(ACTION, SIGNAL(triggered()), mdiArea, SLOT(activatePreviousSubWindow())); } else if(icon == "help") connect(ACTION, SIGNAL(triggered()), this, SLOT(help())); else if(icon == "changelog") connect(ACTION, SIGNAL(triggered()), this, SLOT(changelog())); else if(icon == "tipoftheday") connect(ACTION, SIGNAL(triggered()), this, SLOT(tipOfTheDay())); else if(icon == "about") connect(ACTION, SIGNAL(triggered()), this, SLOT(about())); else if(icon == "aboutQt") connect(ACTION, SIGNAL(triggered()), qApp, SLOT(aboutQt())); else if(icon == "icon16") connect(ACTION, SIGNAL(triggered()), this, SLOT(icon16())); else if(icon == "icon24") connect(ACTION, SIGNAL(triggered()), this, SLOT(icon24())); else if(icon == "icon32") connect(ACTION, SIGNAL(triggered()), this, SLOT(icon32())); else if(icon == "icon48") connect(ACTION, SIGNAL(triggered()), this, SLOT(icon48())); else if(icon == "icon64") connect(ACTION, SIGNAL(triggered()), this, SLOT(icon64())); else if(icon == "icon128") connect(ACTION, SIGNAL(triggered()), this, SLOT(icon128())); else if(icon == "settingsdialog") connect(ACTION, SIGNAL(triggered()), this, SLOT(settingsDialog())); else if(icon == "undo") connect(ACTION, SIGNAL(triggered()), this, SLOT(undo())); else if(icon == "redo") connect(ACTION, SIGNAL(triggered()), this, SLOT(redo())); else if(icon == "makelayercurrent") connect(ACTION, SIGNAL(triggered()), this, SLOT(makeLayerActive())); else if(icon == "layers") connect(ACTION, SIGNAL(triggered()), this, SLOT(layerManager())); else if(icon == "layerprevious") connect(ACTION, SIGNAL(triggered()), this, SLOT(layerPrevious())); else if(icon == "textbold") { ACTION->setCheckable(true); connect(ACTION, SIGNAL(toggled(bool)), this, SLOT(setTextBold(bool))); }
void TMyApp::handleEvent(TEvent& event) { TApplication::handleEvent(event); // act like base! if (event.what == evCommand) { switch (event.message.command) { case cmMyNewWin: myNewWindow(); break; case cmAboutCmd: aboutDlgBox(); break; case cmCalendarCmd: calendar(); break; case cmAsciiCmd: asciiTable(); break; case cmCalcCmd: calculator(); break; case cmPuzzleCmd: puzzle(); break; case cmTile: tile(); break; case cmCascade: cascade(); break; case cmCO128x75: setVideoMode(TScreen::smCO128x75); break; case cmCO128x60: setVideoMode(TScreen::smCO128x60); break; case cmCO128x37: setVideoMode(TScreen::smCO128x37); break; case cmCO113x75: setVideoMode(TScreen::smCO113x75); break; case cmCO113x37: setVideoMode(TScreen::smCO113x37); break; case cmCO102x30: setVideoMode(TScreen::smCO102x30); break; case cmCO85x37: setVideoMode(TScreen::smCO85x37); break; case cmCO85x26: setVideoMode(TScreen::smCO85x26); break; case cmCO85x25: setVideoMode(TScreen::smCO85x25); break; case cmCO85x22: setVideoMode(TScreen::smCO85x22); break; case cmCO73x20: setVideoMode(TScreen::smCO73x20); break; case cmCO64x18: setVideoMode(TScreen::smCO64x18); break; case cmCO64x16: setVideoMode(TScreen::smCO64x16); break; case cmCO40x22: setVideoMode(TScreen::smCO40x22); break; default: return; } clearEvent(event); // clear event after handling } }
int main (int argc,char *argv[]) { int number, j, i, l, k, n, mid, iter; long idem=-1; char arg[64], outfn[64], *eqptr; double *data, *olddata, h, h1, h2, p, lr, dt, dp, rp; if( argc > 1 ) { for(i = 1; i < argc; i++) { eqptr = strchr(argv[i], '='); strcpy(arg, eqptr + 1); switch(argv[i][0]) { case 'p': case 'P': p = atof(arg); break; case 'n': case 'N': number = atoi(arg); break; case 'h': case 'H': h = atof(arg); break; case 'o': case 'O': strcpy(outfn, arg); break; } } } printf("Input parameters: %f %d %f %s\n", p, number, h, outfn); /* We need number to be odd so it easier to devide to 2 */ if(number%2==0) number++; data=(double*)malloc(sizeof(double)); olddata=(double*)malloc(sizeof(double)); if( (data==NULL)&&(olddata==NULL) ) { printf("Could not allocate memory!\n"); exit(-1); } /* Estimate number of iteration needed to get number points */ iter=(int)(log2(number)); if(argc>0) /* enough arguments? */ { olddata[0]=h; for(i=1; i<=iter; i++) { printf("Iteration %d . ", i); n=(int)pow(2.0, (double)i); mid=n/2; k=0; data=realloc(data, n*sizeof(double)); for(j=0; j<mid; j++) { idem=(long)(-ABSV(ran3(&idem))); lr=ran3(&idem); dp=gasdev((int*)(&idem)); rp=p+(dp/10); cascade(olddata[j], &h1, &h2, rp, lr); /*printf("%.3f %3.3f %3.3f |",rp,h1,h2);*/ data[2*j]=h1; data[2*j+1]=h2; if((j>0)&&(j%(10000*mid)==0)) printf(". "); } printf("completed\n"); olddata=(double*)realloc(olddata, n*sizeof(double)); for(j=0; j<n; j++) olddata[j]=data[j]; } /* Now write this out */ out = fopen(outfn, "w"); dt=1/number; for(i=0; i <number; i++) fprintf(out,"%f %f\n", (double)i, data[i]); } fclose(out); free(data); free(olddata); return (0); /* for lint formalities */ }