コード例 #1
0
ファイル: qgsattributeform.cpp プロジェクト: asneuvon/QGIS
QgsAttributeForm::QgsAttributeForm( QgsVectorLayer* vl, const QgsFeature &feature, const QgsAttributeEditorContext &context, QWidget* parent )
    : QWidget( parent )
    , mLayer( vl )
    , mContext( context )
    , mButtonBox( nullptr )
    , mFormNr( sFormCounter++ )
    , mIsSaving( false )
    , mIsAddDialog( false )
    , mPreventFeatureRefresh( false )
    , mEditCommandMessage( tr( "Attributes changed" ) )
{
  init();
  initPython();
  setFeature( feature );

  // Using attributeAdded() attributeDeleted() are not emitted on all fields changes (e.g. layer fields changed,
  // joined fields changed) -> use updatedFields() instead
#if 0
  connect( vl, SIGNAL( attributeAdded( int ) ), this, SLOT( onAttributeAdded( int ) ) );
  connect( vl, SIGNAL( attributeDeleted( int ) ), this, SLOT( onAttributeDeleted( int ) ) );
#endif
  connect( vl, SIGNAL( updatedFields() ), this, SLOT( onUpdatedFields() ) );
  connect( vl, SIGNAL( beforeAddingExpressionField( QString ) ), this, SLOT( preventFeatureRefresh() ) );
  connect( vl, SIGNAL( beforeRemovingExpressionField( int ) ), this, SLOT( preventFeatureRefresh() ) );
}
コード例 #2
0
//! Main starting point - initialize Python, set up the embedding, and
//! run the main Python script that sets everything in motion
int main(int argc, char **argv)
{
    saved_argc = argc;
    saved_argv = argv;

    initPython(argc, argv);

    // Expose client-related functions to Python

    exposeToPython("main", client_main);
    exposeToPython("set_transaction_code", setTransactionCode);
    exposeToPython("connect", ClientSystem::connect);
    exposeToPython("disconnect", ClientSystem::doDisconnect);
    exposeToPython("logout", MasterServer::logout);
    exposeToPython("show_message", show_message);
    exposeToPython("intercept_key", interceptkey);
    exposeToPython("get_escape", get_escape);

    exposeToPython("inject_mouse_position", IntensityGUI::injectMousePosition);
    exposeToPython("inject_mouse_click", IntensityGUI::injectMouseClick);
    exposeToPython("inject_key_press", IntensityGUI::injectKeyPress);
    exposeToPython("flush_input_events", checkinput);

    exposeToPython("upload_texture_data", upload_texture_data);

    // Shared exposed stuff stuff with the server module
    #include "shared_module_members.boost"

    // Start the main Python script that runs it all
    EXEC_PYTHON_FILE("../../intensity_client.py");

    return 0;
}
コード例 #3
0
ファイル: Python.cpp プロジェクト: sanguinariojoe/aquagpusph
void Python::setup()
{
    std::ostringstream msg;
    msg << "Loading the tool \"" << name() << "\"..." << std::endl;
    LOG(L_INFO, msg.str());

    initPython();
    load();
}
コード例 #4
0
ファイル: PythonRunner.cpp プロジェクト: wbrenna/xournalpp
void PythonRunner::runScriptInt(String path, String function, String parameter) {
	XOJ_CHECK_TYPE(PythonRunner);

	if(path.isEmpty() || function.isEmpty()) {
		g_warning("runScriptInt::path and function should not be empty!");
		return;
	}

	initPython();

	PyObject * pName = PyString_FromString(path.c_str());
	/* Error checking of pName left out */

	PyObject * pModule = PyImport_Import(pName);
	Py_DECREF(pName);

	if (pModule != NULL) {
		PyObject * pFunc = PyObject_GetAttrString(pModule, function.c_str());
		/* pFunc is a new reference */

		if (pFunc && PyCallable_Check(pFunc)) {
			PyObject * pArgs = NULL;

			if (parameter.c_str() == NULL) {
				pArgs = PyTuple_New(0);
			} else {
				pArgs = PyTuple_New(1);
				PyTuple_SetItem(pArgs, 0, PyString_FromString(parameter.c_str()));
			}

			PyObject * pValue = PyObject_CallObject(pFunc, pArgs);
			Py_DECREF(pArgs);
			if (pValue != NULL) {
				printf("Result of call: %ld\n", PyInt_AsLong(pValue));
				Py_DECREF(pValue);
			} else {
				Py_DECREF(pFunc);
				Py_DECREF(pModule);
				PyErr_Print();
				fprintf(stderr, "Call failed\n");
			}
		} else {
			if (PyErr_Occurred()) {
				PyErr_Print();
			}
			fprintf(stderr, "Cannot find function \"%s\"\n", function.c_str());
		}
		Py_XDECREF(pFunc);
		Py_DECREF(pModule);
	} else {
		PyErr_Print();
		fprintf(stderr, "Failed to load \"%s\"\n", path.c_str());
	}
}
コード例 #5
0
ファイル: qgsattributeform.cpp プロジェクト: Waferix/QGIS
QgsAttributeForm::QgsAttributeForm( QgsVectorLayer* vl, const QgsFeature feature, QgsAttributeEditorContext context, QWidget* parent )
    : QWidget( parent )
    , mLayer( vl )
    , mContext( context )
    , mFormNr( sFormCounter++ )
    , mIsSaving( false )
    , mIsAddDialog( false )
    , mEditCommandMessage( tr( "Attributes changed" ) )
{
  init();
  initPython();
  setFeature( feature );

  connect( vl, SIGNAL( attributeAdded( int ) ), this, SLOT( onAttributeAdded( int ) ) );
  connect( vl, SIGNAL( attributeDeleted( int ) ), this, SLOT( onAttributeDeleted( int ) ) );
}
コード例 #6
0
bool CPythonNode::start()
{
    // Init the PythonQt library.
    initPython();

    // Check if the script exists.
    QString script_name = getConfig().getParameter("input_script")->value.toString();
    QFile script_file(script_name);
    if(!script_file.exists()) {
        qWarning() << "Python script does not exist:"
                   << script_name;
        return false;
    }

    return true;
}
コード例 #7
0
/*static*/
int
_MSFT_nxServiceResource_Self::create (
    _MSFT_nxServiceResource_Self** const ppInstance)
{
    int rval = EXIT_SUCCESS;
    PyObjPtr pModule;
    PyObjPtr pSetFn;
    PyObjPtr pTestFn;
    PyObjPtr pGetFn;
    if (ppInstance &&
        !*ppInstance)
    {
        if (EXIT_SUCCESS == (rval = initPython ("do'h", GetScriptPath().c_str())))
        {
            pModule = loadModule ("nxService");
            if (pModule)
            {
                pSetFn = loadFunctionFromModule (pModule, "Set_Marshall");
                pTestFn = loadFunctionFromModule (pModule, "Test_Marshall");
                pGetFn = loadFunctionFromModule (pModule, "Get_Marshall");
                if (pSetFn && pTestFn && pGetFn)
                {
                    *ppInstance = new _MSFT_nxServiceResource_Self (
                        pModule, pSetFn, pTestFn, pGetFn);
                }
                else
                {
                    rval = EXIT_FAILURE;
                }
            }
            else
            {
                rval = EXIT_FAILURE;
            }
        }
        else
        {
            rval = EXIT_FAILURE;
        }
    }
    else
    {
        rval = EXIT_FAILURE;
    }
    return rval;
}
コード例 #8
0
ファイル: Python.cpp プロジェクト: GameCave/aquagpusph
bool Python::setup()
{
    char msg[1024];
    InputOutput::ScreenManager *S = InputOutput::ScreenManager::singleton();

    sprintf(msg,
            "Loading the tool \"%s\"...\n",
            name());
    S->addMessageF(1, msg);

    if(initPython())
        return true;

    if(load())
        return true;

    return false;
}
コード例 #9
0
ファイル: guimanager.cpp プロジェクト: carriercomm/freeablo
    GuiManager::GuiManager(FAWorld::Inventory & playerInventory, Engine::EngineMain& engine, std::string invClass) : mPythonFuncs(playerInventory, *this, engine), mCurrentGuiType(TitleScreen)
    {

        this->invClass = invClass;
        initPython(mPythonFuncs);

        Input::Hotkey::initpythonwrapper();

        FARender::Renderer* renderer = FARender::Renderer::get();

        Rocket::Core::DecoratorInstancer* animInstancer = Rocket::Core::Factory::RegisterDecoratorInstancer("faanim", (Rocket::Core::DecoratorInstancer*)new AnimatedDecoratorInstancer(renderer->getRocketContext()->GetRenderInterface()));
        animInstancer->RemoveReference();

        menus["titleScreen"] = renderer->getRocketContext()->LoadDocument("resources/gui/titlescreen.rml");
        menus["ingameUi"] = renderer->getRocketContext()->LoadDocument("resources/gui/base.rml");
        menus["mainMenu"] = renderer->getRocketContext()->LoadDocument("resources/gui/mainmenu.rml");
        menus["credits"] = renderer->getRocketContext()->LoadDocument("resources/gui/credits.rml");
        menus["chooseClassMenu"] = renderer->getRocketContext()->LoadDocument("resources/gui/creator/choose_class_menu.rml");
        menus["enterNameMenu"] = renderer->getRocketContext()->LoadDocument("resources/gui/creator/enter_name_menu.rml");
        menus["invalidNameMenu"] = renderer->getRocketContext()->LoadDocument("resources/gui/creator/invalid_name_menu.rml");
        menus["selectHeroMenu"] = renderer->getRocketContext()->LoadDocument("resources/gui/creator/select_hero_menu.rml");
        menus["saveFileExistsMenu"] = renderer->getRocketContext()->LoadDocument("resources/gui/creator/save_file_exists_menu.rml");
    }
コード例 #10
0
ファイル: ogresmartbody.cpp プロジェクト: gsi-upm/SmartSim
bool OgreSmartBody::go(void)
{
#ifdef _DEBUG
    mResourcesCfg = "resources_d.cfg";
	mPluginsCfg = "plugins_d.cfg";
#else
    mResourcesCfg = "resources.cfg";
    mPluginsCfg = "plugins.cfg";
#endif
 
    // construct Ogre::Root
    mRoot = new Ogre::Root(mPluginsCfg);
 
    // setup resources
    // Load resource paths from config file
    Ogre::ConfigFile cf;
    cf.load(mResourcesCfg);
 
    // Go through all sections & settings in the file
    Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
 
    Ogre::String secName, typeName, archName;
    while (seci.hasMoreElements())
    {
        secName = seci.peekNextKey();
        Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
        Ogre::ConfigFile::SettingsMultiMap::iterator i;
        for (i = settings->begin(); i != settings->end(); ++i)
        {
            typeName = i->first;
            archName = i->second;
            Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
                archName, typeName, secName);
        }
    }
    // configure
    // Show the configuration dialog and initialise the system
    if(!(mRoot->restoreConfig() || mRoot->showConfigDialog()))
    {
        return false;
    }
 
    mWindow = mRoot->initialise(true, "OgreSmartBody Render Window");
 
    // Set default mipmap level (NB some APIs ignore this)
    Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
    // initialise all resource groups
    Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
 
    // Create the SceneManager, in this case a generic one
    mSceneMgr = mRoot->createSceneManager("DefaultSceneManager");
 
    // Create the camera
    mCamera = mSceneMgr->createCamera("PlayerCam");
 
    // Position it at 500 in Z direction
    mCamera->setPosition(Ogre::Vector3(0,10,60));
    // Look back along -Z
    mCamera->lookAt(Ogre::Vector3(0,0,-300));
    mCamera->setNearClipDistance(5);
 
    // Create one viewport, entire window
    Ogre::Viewport* vp = mWindow->addViewport(mCamera);
    vp->setBackgroundColour(Ogre::ColourValue(0,0,0));
 
    // Alter the camera aspect ratio to match the viewport
    mCamera->setAspectRatio(
        Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));

	// create a floor for better visualization
		//adding plane entity to the scene
	Ogre::Plane plane;
	plane.normal = Ogre::Vector3::UNIT_Y;
	plane.d = 0;
	Ogre::MeshManager::getSingleton().createPlane( "Myplane", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane, 1500, 1500, 20, 20, true, 1, 60, 60, Ogre::Vector3::UNIT_Z );
	Ogre::Entity * pPlaneEnt = mSceneMgr->createEntity( "plane", "Myplane" );
	//pPlaneEnt->setMaterialName( "Examples/Rockwall" );
	pPlaneEnt->setMaterialName( "Rockwall" );
	pPlaneEnt->setCastShadows( false );
	mSceneMgr->getRootSceneNode()->createChildSceneNode("plane_node", Ogre::Vector3( 0, 0, 0 ) )->attachObject( pPlaneEnt );
	mSceneMgr->getSceneNode("plane_node")->setVisible(true);

	// shadows
	mSceneMgr->setShadowTechnique( Ogre::SHADOWTYPE_TEXTURE_MODULATIVE );
	mSceneMgr->setShadowTextureSize( 4048 );
	mSceneMgr->setShadowColour( Ogre::ColourValue( 0.3f, 0.3f, 0.3f ) );
  
    // Set ambient light
    mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));
 
    // Create a light
    Ogre::Light* l = mSceneMgr->createLight("MainLight");
    l->setPosition(20,80,50);
 
    Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
    OIS::ParamList pl;
    size_t windowHnd = 0;
    std::ostringstream windowHndStr;
 
    mWindow->getCustomAttribute("WINDOW", &windowHnd);
    windowHndStr << windowHnd;
    pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
	
    mInputManager = OIS::InputManager::createInputSystem( pl );
 
    mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, false ));
    mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject( OIS::OISMouse, false ));
 
    //Set initial mouse clipping size
    windowResized(mWindow);
 
    //Register as a Window listener
    Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this);
 
    mRoot->addFrameListener(this);

	// smartbody
	// the root path to SmartBody: change this to your own path
	std::string smartbodyRoot = "..";
	// set the following to the location of the Python libraries. 
	// if you downloaded SmartBody, it will be in core/smartbody/Python26/Lib
#ifdef WIN32
	initPython(smartbodyRoot + "/Python27/lib");
#else
	initPython("/usr/lib/python2.7");
#endif
	m_pScene = SmartBody::SBScene::getScene();

	m_pScene->startFileLogging("smartbody.log");
	OgreSmartBodyListener* listener = new OgreSmartBodyListener(this);
	m_pScene->addSceneListener(listener);
	m_pScene->start();

	// sets the media path, or root of all the data to be used
	// other paths will be relative to the media path
	m_pScene->setMediaPath(smartbodyRoot + "/data");
	m_pScene->addAssetPath("script", ".");
	// the file 'OgreSmartBody.py' needs to be placed in the media path directory
	m_pScene->runScript("ogresmartbody.py");

	mStartTime = Ogre::Root::getSingleton().getTimer()->getMilliseconds() / 1000.0f;
	mRoot->startRendering();
 
    return true;
}
コード例 #11
0
ファイル: main.cpp プロジェクト: coslyk/moonplayer
int main(int argc, char *argv[])
{
    qputenv("QTWEBENGINE_REMOTE_DEBUGGING", "19260");

#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
    QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif

    detectOpenGLEarly();

    Application a(argc, argv);
    if (!a.parseArgs())
        return 0;

    detectOpenGLLate();


    // Print python error to console on Windows
#ifdef Q_OS_WIN
    qputenv("PYTHONHOME", getAppPath().toUtf8());
    qputenv("PYTHONPATH", getAppPath().toUtf8() + "/Lib;" + getAppPath().toUtf8() + "/DLLs");
    bool win_debug = AttachConsole(ATTACH_PARENT_PROCESS);
    if (win_debug)
    {
        freopen("CON", "w", stdout);
        freopen("CON", "w", stderr);
        freopen("CON", "r", stdin);
    }
#endif

    //for mpv
    setlocale(LC_NUMERIC, "C");

    //init
    access_manager = new NetworkAccessManager(&a);
    printf("Initialize settings...\n");
    initSettings();

    printf("Initialize API for Python...\n");
    initPython();

    // Translate moonplayer
    printf("Initialize language support...\n");
    QTranslator qtTranslator;
    if (qtTranslator.load("qt_" + QLocale::system().name(), getQtTranslationsPath()))
        a.installTranslator(&qtTranslator);

    QTranslator translator;
    if (translator.load("moonplayer_" + QLocale::system().name(), getAppPath() + "/translations"))
        a.installTranslator(&translator);

    // Create window
    PlayerView *player_view = new PlayerView;
    player_view->show();

    // Create video parsers
    parser_ykdl = new ParserYkdl(&a);
    parser_youtubedl = new ParserYoutubeDL(&a);
#ifdef MP_ENABLE_WEBENGINE
    parser_webcatch = new ParserWebCatch(&a);
#endif

    a.exec();
    Py_Finalize();
    delete player_view;
    return 0;
}
コード例 #12
0
ファイル: beagle.c プロジェクト: dzz/ctt2
int main(int argc, char **argv){ 
    
    int fps                                         = -1;
    double frame_millis                             = -1;
    double init_millis                              = 0;
    double tick_millis                              = 0;
    double frame_overflow                           = 0;
    double spf                                      = 0.0;
    int tick_next                                   = 0;
    unsigned int ctt2_state                         = CTT2_EVT_POLL_EVENTS;
    unsigned int render_test = 0;
        finished = 0;
    initialized_modules = 0;


    print_banner();

    if(argc==5 || argc==6) {
        SCREEN_WIDTH    = atoi( argv[1] );
        SCREEN_HEIGHT   = atoi( argv[2] );
        fullscreen      = atoi( argv[3] );
        fps             = atoi( argv[4] );
        spf = 1.0/(double)fps;
        frame_millis    = (double)1000/(double)fps;
        if(argc==6) {
            beagle_application_path = argv[5]; 
            printf("Application path: `%s`\n", beagle_application_path );
        }
    } else {

        print_usage();
        return;
    }


    loadRuntimeModule( &initLog,        &dropLog,           CTT2_RT_MODULE_LOG );
    loadRuntimeModule( &initCore,       &dropCore,          CTT2_RT_MODULE_CORE );
    loadRuntimeModule( &initDisplay,    &dropDisplay,       CTT2_RT_MODULE_DISPLAY );
    loadRuntimeModule( &initOpenGL,     &dropOpenGL,        CTT2_RT_MODULE_OPENGL );

    loadRuntimeModule( &initAudio,      &dropAudio,         CTT2_RT_MODULE_AUDIO );
    loadRuntimeModule( &initWinMsgs,    &dropWinMsgs,       CTT2_RT_MODULE_WINDOW_MSGS );
    loadRuntimeModule( &initTextInput,  &dropTextInput,     CTT2_RT_MODULE_TEXT_INPUT );
    loadRuntimeModule( &initTimer,      &dropTimer,         CTT2_RT_MODULE_TIMER );
    loadRuntimeModule( &initGamepad,    &dropGamepad,       CTT2_RT_MODULE_GAMEPAD);
    loadRuntimeModule( &initPython,     &dropPython,        CTT2_RT_MODULE_PYTHON);

    int run = 1;
    /** MAIN DISPATCH LOOP **/
    if(run) {
        SDL_Event event;
        double base_millis = timer_get_ms();
        tick_millis = timer_get_ms();


        while(finished != CTT2_RT_TERMINATED ) {
            switch(ctt2_state) {
                    case CTT2_EVT_TICK:
                        if(api_tick() == API_FAILURE) { 
                                finished = 1; 
                            } else {
                                tick_millis += frame_millis;
                                if( (timer_get_ms() - tick_millis) > frame_millis ) {
                                    ctt2_state = CTT2_EVT_TICK;
                                } else {
                                ctt2_state = CTT2_EVT_RENDER;
                                }
                            }
                         break;
                    case CTT2_EVT_RENDER:
                         if(render_test == 0) {
                            api_render();
                         } 
                         if(render_test==1) {
                             hwgfx_render_test();
                         }
                         if(render_test==2) {
                            api_render_test();
                         }
                         ctt2_state = CTT2_EVT_SYNC_GFX;
                         break;
                    case CTT2_EVT_SYNC_GFX:
                        updateViewingSurface();  
                        ctt2_state = CTT2_EVT_POLL_EVENTS;
                        break;
                    case CTT2_EVT_POLL_EVENTS:
                        if( (timer_get_ms() - tick_millis) > frame_millis ) {
                            ctt2_state = CTT2_EVT_TICK;
                         } 
                          break;
            }


            while(SDL_PollEvent(&event)) {
                switch (event.type) {
                    case SDL_CONTROLLERDEVICEADDED:
                        dropGamepad();
                        initGamepad();
                        break;
                    case SDL_CONTROLLERDEVICEREMOVED:
                        dropGamepad();
                        initGamepad();
                        break;
                    case SDL_JOYAXISMOTION:
                        GamepadHandleEvent( &event );
                        break; 
                    case SDL_TEXTINPUT:
                        api_dispatch_text( event.text.text );
                        break;
                    case SDL_QUIT:
                        finished = CTT2_RT_TERMINATED;
                        break;
                    case SDL_SYSWMEVENT:
                        #ifdef _WIN32
                            #ifdef WACOM_ENABLED
                                handle_wm_event(event); //used for the wacom tablet module, but currently missing...
                            #endif
                        #endif
                        break;
                    case SDL_KEYDOWN:
                        if( api_dispatch_key(event.key.keysym.sym,1) == API_FAILURE ) finished = CTT2_RT_TERMINATED;
                        if( event.key.keysym.sym == SDLK_F5 && (event.key.keysym.mod & KMOD_CTRL) ) {
                            dropPython();
                            initPython();
                        }
                        if( event.key.keysym.sym == SDLK_F6 && (event.key.keysym.mod & KMOD_CTRL) ) {
                            render_test = (render_test+1)%3;
                        }
                        if( event.key.keysym.sym == SDLK_F4 && (event.key.keysym.mod & KMOD_ALT) ) {
                            finished = CTT2_RT_TERMINATED;
                        }
                        break;
                    case SDL_KEYUP:
                        if( api_dispatch_key(event.key.keysym.sym,0) 
                                == API_FAILURE ) finished = CTT2_RT_TERMINATED;
                        break;
                    case SDL_MOUSEBUTTONDOWN:
                        if(api_dispatch_mousedown(
                                    event.button.button, 
                                    event.button.x, 
                                    event.button.y) == API_FAILURE ) 
                                        finished = CTT2_RT_TERMINATED ;
                        break;
                    case SDL_MOUSEBUTTONUP:
                        if(api_dispatch_mouseup(
                                    event.button.button, 
                                    event.button.x, 
                                    event.button.y) == API_FAILURE ) 
                                        finished = CTT2_RT_TERMINATED;
                        break;
                    case SDL_MOUSEMOTION:
                        if(api_dispatch_mousemotion(
                                    event.motion.x, 
                                    event.motion.y) == API_FAILURE ) 
                                        finished = CTT2_RT_TERMINATED;
                        break;
                }
            }
        }
    }
    
    sequencer_halt();
    dropRuntimeModules(0);
    return 0;
}
コード例 #13
0
ファイル: Helpers.cpp プロジェクト: TeemuAhola/sailelfcloud
void Helpers::init(void)
{
    initConfig();
    prepareCache();
    initPython();
}
コード例 #14
0
ファイル: temp.c プロジェクト: dtbinh/RobotCSimulator
int main(int argc, char *argv[])
{
	initPython();
	studentMain();
	deInitPython();
}