void MyPythonQt::evalString(QString * code) { PythonQtObjectPtr context = PythonQt::self()->getMainModule(); PyObject * dict = PyModule_GetDict(context); PyRun_String(code->toLatin1().data(), Py_single_input, dict, dict); delete code; emit(evalDone()); }
int state::updateDynStmts() { static int running = 0; if (running) return 0; // prevent reentrance (single theaded) running = 1; // little hack: call updateConsoleControls() too updateConsoleControls(); int i, e; std::vector<int> evalDone(m_dynStmt.size(), 0); int sw = m_globalScope->supressWarnings(); int se = m_globalScope->supressErrors(); // printf("Update dynamics!\n"); // evaluate each dynamic state once, only once, but do check if other dynamics, earlier in list, have to be reevaled do { e = 0; for (i = 0; i < (int)m_dynStmt.size(); i++) { if ((!evalDone[i]) && m_dynStmt[i].ds()->evalRequired()) { // printf("update %08X %d (%s)\n", m_dynStmt[i].ds(), m_dynStmt[i].ds()->evalRequired(), m_dynStmt[i].name().c_str()); e = 1; evalDone[i] = 1; m_globalScope->supressWarnings(1); m_globalScope->supressErrors(1); /* // if this is not the first evalutation, suppress warning messages m_globalScope->supressWarnings((m_dynStmt[i].ds()->firstEval()) ? sw : 1); m_globalScope->supressErrors((m_dynStmt[i].ds()->firstEval()) ? se : 1);*/ m_globalScope->dynStmtVariableCollect(1); //m_globalScope->noAssignmentDisplay(1); m_globalScope->noAssignmentDisplay(!m_dynStmt[i].ds()->firstEval()); // on first eval _do_ do a [display|hide]ConsoleAssignmentList in consoleGlobalScope::endStatement() consoleVariable *cv = m_dynStmt[i].ds()->execute(m_globalScope); if (cv) delete cv; if (m_globalScope->resetRequested()) { g_state->reset(); running = 0; // allow reentrance return 0; } // transfer the variable names on which m_dynStmt[i] depends std::set<std::string> *dynStmtVariables = m_globalScope->getDynStmtVariables(); /*if (dynStmtVariables) for (std::set<std::string>::iterator X = dynStmtVariables->begin(); X != dynStmtVariables->end(); X++) std::cout << (*X) << std::endl;*/ m_dynStmt[i].ds()->setDynStmtVariables(dynStmtVariables/*m_globalScope->getDynStmtVariables()*/); m_dynStmt[i].ds()->firstEval(0); // first eval done m_dynStmt[i].ds()->evalRequired(0); // no re-eval required anymore evalDone[i] = 1; // keep track of which dyn stmts have been evalled this round } } } while (e); // force all dynamic statements to 'no eval required' for (i = 0; i < (int)m_dynStmt.size(); i++) { m_dynStmt[i].ds()->evalRequired(0); } m_globalScope->supressWarnings(sw); m_globalScope->supressErrors(se); m_globalScope->noAssignmentDisplay(0); m_globalScope->dynStmtVariableCollect(0); if(gui_state && gui_state->m_glWindow) gui_state->m_glWindow->redraw(); running = 0; // allow reentrance //printf("DONE!\n"); return 0; }
void TIGLViewerWindow::connectSignals() { connect(newAction, SIGNAL(triggered()), this, SLOT(newFile())); connect(openAction, SIGNAL(triggered()), this, SLOT(open())); connect(openScriptAction, SIGNAL(triggered()), this, SLOT(openScript())); connect(closeAction, SIGNAL(triggered()), this, SLOT(closeConfiguration())); for (int i = 0; i < MaxRecentFiles; ++i) { recentFileActions[i] = new QAction(this); recentFileActions[i]->setVisible(false); connect(recentFileActions[i], SIGNAL(triggered()), this, SLOT(openRecentFile())); } connect(saveAction, SIGNAL(triggered()), this, SLOT(save())); connect(saveScreenshotAction, SIGNAL(triggered()), this, SLOT(makeScreenShot())); connect(setBackgroundAction, SIGNAL(triggered()), this, SLOT(setBackgroundImage())); connect(exitAction, SIGNAL(triggered()), this, SLOT(close())); connect(aboutAction, SIGNAL(triggered()), this, SLOT(about())); connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); connect(aboutQtAction, SIGNAL(triggered()), this, SLOT(aboutQt())); // Misc drawing actions connect(drawPointAction, SIGNAL(triggered()), this, SLOT(drawPoint())); connect(drawVectorAction, SIGNAL(triggered()), this, SLOT(drawVector())); // view->actions menu connect(fitAction, SIGNAL(triggered()), myOCC, SLOT(fitExtents())); connect(fitAllAction, SIGNAL(triggered()), myOCC, SLOT(fitAll())); //connect(zoomAction, SIGNAL(triggered()), myOCC, SLOT(fitArea())); connect(zoomAction, SIGNAL(triggered()),myOCC, SLOT(zoom())); connect(panAction, SIGNAL(triggered()), myOCC, SLOT(pan())); connect(rotAction, SIGNAL(triggered()), myOCC, SLOT(rotation())); connect(selectAction, SIGNAL(triggered()), myOCC, SLOT(selecting())); // view->grid menu connect(gridOnAction, SIGNAL(toggled(bool)), myScene, SLOT(toggleGrid(bool))); connect(gridXYAction, SIGNAL(triggered()), myScene, SLOT(gridXY())); connect(gridXZAction, SIGNAL(triggered()), myScene, SLOT(gridXZ())); connect(gridYZAction, SIGNAL(triggered()), myScene, SLOT(gridYZ())); connect(gridRectAction, SIGNAL(triggered()), myScene, SLOT(gridRect())); connect(gridCircAction, SIGNAL(triggered()), myScene, SLOT(gridCirc())); // Standard View connect(viewFrontAction, SIGNAL(triggered()), myOCC, SLOT(viewFront())); connect(viewBackAction, SIGNAL(triggered()), myOCC, SLOT(viewBack())); connect(viewTopAction, SIGNAL(triggered()), myOCC, SLOT(viewTop())); connect(viewBottomAction, SIGNAL(triggered()), myOCC, SLOT(viewBottom())); connect(viewLeftAction, SIGNAL(triggered()), myOCC, SLOT(viewLeft())); connect(viewRightAction, SIGNAL(triggered()), myOCC, SLOT(viewRight())); connect(viewAxoAction, SIGNAL(triggered()), myOCC, SLOT(viewAxo())); connect(viewGridAction, SIGNAL(triggered()), myOCC, SLOT(viewGrid())); connect(viewResetAction, SIGNAL(triggered()), myOCC, SLOT(viewReset())); connect(viewZoomInAction, SIGNAL(triggered()), myOCC, SLOT(zoomIn())); connect(viewZoomOutAction, SIGNAL(triggered()), myOCC, SLOT(zoomOut())); connect(showConsoleAction, SIGNAL(toggled(bool)), consoleDockWidget, SLOT(setVisible(bool))); connect(consoleDockWidget, SIGNAL(visibilityChanged(bool)), showConsoleAction, SLOT(setChecked(bool))); connect(showWireframeAction, SIGNAL(toggled(bool)), myScene, SLOT(wireFrame(bool))); connect(openTimer, SIGNAL(timeout()), this, SLOT(reopenFile())); // The co-ordinates from the view connect( myOCC, SIGNAL(mouseMoved(V3d_Coordinate,V3d_Coordinate,V3d_Coordinate)), this, SLOT(xyzPosition(V3d_Coordinate,V3d_Coordinate,V3d_Coordinate)) ); // Add a point from the view connect( myOCC, SIGNAL(pointClicked(V3d_Coordinate,V3d_Coordinate,V3d_Coordinate)), this, SLOT (addPoint (V3d_Coordinate,V3d_Coordinate,V3d_Coordinate)) ); connect( myOCC, SIGNAL(sendStatus(const QString)), this, SLOT (statusMessage(const QString)) ); connect(stdoutStream, SIGNAL(sendString(QString)), console, SLOT(output(QString))); connect(errorStream , SIGNAL(sendString(QString)), console, SLOT(output(QString))); connect(logDirect.get(), SIGNAL(newMessage(QString)), console, SLOT(output(QString))); connect(scriptEngine, SIGNAL(scriptResult(QString)), console, SLOT(output(QString))); connect(scriptEngine, SIGNAL(scriptError(QString)), console, SLOT(outputError(QString))); connect(scriptEngine, SIGNAL(evalDone()), console, SLOT(endCommand())); connect(console, SIGNAL(onChange(QString)), scriptEngine, SLOT(textChanged(QString))); connect(console, SIGNAL(onCommand(QString)), scriptEngine, SLOT(eval(QString))); connect(settingsAction, SIGNAL(triggered()), this, SLOT(changeSettings())); }