void UndoDiagramModuleCutActionFn(void *info) { TransformNode *dgmNode = ((UndoDiagramModuleCut *)info)->mpDiagramNode; CDiagramClipboard *clipboard = ((UndoDiagramModuleCut *)info)->mpClipboard; CDiagram dgm(dgmNode); int nModule = clipboard->getNModuleNodes(); ScriptNode* (*moduleNode)[2] = new (ScriptNode *[nModule][2]); for (int n=0; n<nModule; n++) { CModule orgModule(clipboard->getModuleNode(n)); CModule copyModule(orgModule.getModuleType()); copyModule.setPositionX(orgModule.getPositionX()); copyModule.setPositionY(orgModule.getPositionY()); dgm.addModule(©Module); moduleNode[n][0] = orgModule.getScriptNode(); moduleNode[n][1] = copyModule.getScriptNode(); } int nRoute = clipboard->getNRoutes(); for (n=0; n<nRoute; n++) { Route *route = clipboard->getRoute(n); ScriptNode *outModule = (ScriptNode *)route->getEventOutNode(); for (int i=0; i<nModule; i++) { if (moduleNode[i][0] == outModule) { outModule = moduleNode[i][1]; break; } } ScriptNode *inModule = (ScriptNode *)route->getEventInNode(); for (i=0; i<nModule; i++) { if (moduleNode[i][0] == inModule) { inModule = moduleNode[i][1]; break; } } GetWorld()->getSceneGraph()->addRoute(outModule->getName(), route->getEventOutField()->getName(), inModule->getName(), route->getEventInField()->getName()); } delete []moduleNode; delete clipboard; }
void UndoDiagramModulePasteActionFn(void *info) { TransformNode *dgmNode = ((UndoDiagramModuleCut *)info)->mpDiagramNode; int nScriptNode = ((UndoDiagramModulePaste *)info)->mnScriptNode; ScriptNode **scriptNode = ((UndoDiagramModulePaste *)info)->mpScriptNode; int nRoute = ((UndoDiagramModulePaste *)info)->mnRoute; Route **route = ((UndoDiagramModulePaste *)info)->mpRoute; for (int n=0; n<nRoute; n++) { GetWorld()->getSceneGraph()->removeRoute(route[n]); } CDiagram dgm(dgmNode); for (n=0; n<nScriptNode; n++) { CModule module(scriptNode[n]); dgm.removeModule(&module); } delete []scriptNode; delete []route; }
int main(int argc, char * argv[]) { put_flog(LOG_INFO, ""); // get base directory if(getenv("DISPLAYCLUSTER_DIR") == NULL) { put_flog(LOG_FATAL, "DISPLAYCLUSTER_DIR environment variable must be set"); return -1; } g_displayClusterDir = std::string(getenv("DISPLAYCLUSTER_DIR")); put_flog(LOG_DEBUG, "base directory is %s", g_displayClusterDir.c_str()); #if ENABLE_TUIO_TOUCH_LISTENER // we need X multithreading support if we're running the TouchListener thread and creating X events XInitThreads(); #endif MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &g_mpiRank); MPI_Comm_size(MPI_COMM_WORLD, &g_mpiSize); MPI_Comm_split(MPI_COMM_WORLD, g_mpiRank != 0, g_mpiRank, &g_mpiRenderComm); #if 0 if (g_mpiRank == 0) { std::stringstream s; pid_t pid = getpid(); s << "~/dbg_script " << (const char *)argv[0] << " " << pid << " " << g_mpiRank << " &"; std::cerr << "running " << s.str().c_str() << "\n"; system(s.str().c_str()); int dbg = 1; while(dbg) sleep(1); } #endif if (g_mpiRank == 0) g_app = (QApplication *) new QSSApplication(argc, argv); else g_app = new QApplication(argc, argv); g_configuration = new Configuration((std::string(g_displayClusterDir) + std::string("/configuration.xml")).c_str()); setenv("DISPLAY", g_configuration->getMyDisplay().c_str(), 1); boost::shared_ptr<DisplayGroupManager> dgm(new DisplayGroupManager); g_displayGroupManager = dgm; // calibrate timestamp offset between rank 0 and rank 1 clocks g_displayGroupManager->calibrateTimestampOffset(); #if ENABLE_TUIO_TOUCH_LISTENER if(g_mpiRank == 0) { new TouchListener(); } #endif #if ENABLE_JOYSTICK_SUPPORT if(g_mpiRank == 0) { // do this before the thread starts to avoid X callback race conditions // we need SDL_INIT_VIDEO for events to work if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) { put_flog(LOG_ERROR, "could not initial SDL joystick subsystem"); return -2; } // create thread to monitor joystick events (all joysticks handled in same event queue) JoystickThread * joystickThread = new JoystickThread(); joystickThread->start(); // wait for thread to start while(joystickThread->isRunning() == false || joystickThread->isFinished() == true) { usleep(1000); } } #endif #if ENABLE_SKELETON_SUPPORT if(g_mpiRank == 0) { g_skeletonThread = new SkeletonThread(); g_skeletonThread->start(); // wait for thread to start while(g_skeletonThread->isRunning() == false || g_skeletonThread->isFinished() == true) { usleep(1000); } } #endif if(g_mpiRank == 0) { g_networkListener = new NetworkListener(); g_Remote = new Remote(); } g_mainWindow = new MainWindow(); // enter Qt event loop g_app->exec(); put_flog(LOG_DEBUG, "quitting"); // wait for all threads to finish QThreadPool::globalInstance()->waitForDone(); // call finalize cleanup actions g_mainWindow->finalize(); // destruct the main window delete g_mainWindow; if(g_mpiRank == 0) { g_displayGroupManager->sendQuit(); } // clean up the MPI environment after the Qt event loop exits MPI_Finalize(); return 0; }