Example #1
0
KPrDocument::KPrDocument(KoPart *part)
: KoPADocument(part)
, m_customSlideShows(new KPrCustomSlideShows())
, m_presentationMonitor( 0 )
, m_presenterViewEnabled( false )
, m_declarations( new KPrDeclarations() )
{
    K_GLOBAL_STATIC( InitOnce, s_initOnce );
    InitOnce * initOnce = s_initOnce;
    // have this is as otherwise we get a warning from the compiler
    // the variable is used and the way it is done is to only call it once
    Q_UNUSED( initOnce );

    KoShapeLoadingContext::addAdditionalAttributeData( KoShapeLoadingContext::AdditionalAttributeData(
                                                       KoXmlNS::presentation, "placeholder",
                                                       "presentation:placeholder" ) );

    KoShapeLoadingContext::addAdditionalAttributeData( KoShapeLoadingContext::AdditionalAttributeData(
                                                       KoXmlNS::presentation, "class",
                                                       "presentation:class" ) );

    QVariant variant;
    variant.setValue(new KPrSoundCollection(this));
    resourceManager()->setResource(KPresenter::SoundCollection, variant);

    variant.setValue(new KPrPageLayouts(this));
    resourceManager()->setResource(KPresenter::PageLayouts, variant);

    loadKPrConfig();
}
void PerVertexColorShader::construct()
{
    QOpenGLFunctions_4_1_Core* f = resourceManager()->functions();

    bool success = create();
    Q_ASSERT(success);

    success = compileFile(ShaderProgram::VertexShader, ":/shaders/pervertexcolor.vert");
    Q_ASSERT(success);

    success = compileFile(ShaderProgram::FragmentShader, ":/shaders/pervertexcolor.frag");
    Q_ASSERT(success);

    link();

    m_iAttributeLocations[Position] = f->glGetAttribLocation(handle(), "vPositionModelSpace");
    m_iAttributeLocations[Normal] = f->glGetAttribLocation(handle(), "vNormal");
    m_iAttributeLocations[Color] = f->glGetAttribLocation(handle(), "vColor");
    m_iAttributeLocations[ColorUniform] = f->glGetUniformLocation(handle(), "fColor");
    m_iAttributeLocations[FogColorUniform] = f->glGetUniformLocation(handle(), "fFogColor");
    m_iAttributeLocations[FogBeginUniform] = f->glGetUniformLocation(handle(), "fFogBegin");
    m_iAttributeLocations[FogEndUniform] = f->glGetUniformLocation(handle(), "fFogEnd");
    m_iAttributeLocations[ModelToWorldMatrix] = f->glGetUniformLocation(handle(), "modelToWorld");
    m_iAttributeLocations[WorldToCameraMatrix] = f->glGetUniformLocation(handle(), "worldToCamera");
    m_iAttributeLocations[CoordinateTransformMatrix] = f->glGetUniformLocation(handle(), "hammerToOpenGL");
    m_iAttributeLocations[CameraProjectionMatrix] = f->glGetUniformLocation(handle(), "projection");
    m_iAttributeLocations[CounterScaleUniform] = f->glGetUniformLocation(handle(), "counterScale");
    m_iAttributeLocations[DirectionalLightUniform] = f->glGetUniformLocation(handle(), "directionalLight");
}
Example #3
0
void KoCanvasBase::disconnectCanvasObserver(QObject *object)
{
    shapeManager()->selection()->disconnect(object);
    resourceManager()->disconnect(object);
    shapeManager()->disconnect(object);
    toolProxy()->disconnect(object);
}
Example #4
0
void
OverlayImpl::connect (beast::IP::Endpoint const& remote_endpoint)
{
    assert(work_);

    auto usage = resourceManager().newOutboundEndpoint (remote_endpoint);
    if (usage.disconnect())
    {
        if (journal_.info) journal_.info <<
            "Over resource limit: " << remote_endpoint;
        return;
    }
    
    auto const slot = peerFinder().new_outbound_slot(remote_endpoint);
    if (slot == nullptr)
    {
        if (journal_.debug) journal_.debug <<
            "Connect: No slot for " << remote_endpoint;
        return;
    }

    auto const p = std::make_shared<ConnectAttempt>(
        io_service_, beast::IPAddressConversion::to_asio_endpoint(remote_endpoint),
            usage, setup_.context, next_id_++, slot,
                deprecatedLogs().journal("Peer"), *this);

    std::lock_guard<decltype(mutex_)> lock(mutex_);
    list_.emplace(p.get(), p);
    p->run();
}
void SectionContainer::initContainer(Section* _section, RootSection* _rootSection)
{
    m_rootSection = _rootSection;
    m_section = _section;
    m_sectionModel = new SectionShapeContainerModel(m_section);
    m_layer = new KoShapeLayer(m_sectionModel);
    resourceManager()->setUndoStack(_rootSection->undoStack());
}
void PerVertexColorShader::release() const
{
    QOpenGLFunctions_4_1_Core* f = resourceManager()->functions();

    f->glDisableVertexAttribArray(m_iAttributeLocations[Position]);
    f->glDisableVertexAttribArray(m_iAttributeLocations[Normal]);
    f->glDisableVertexAttribArray(m_iAttributeLocations[Color]);
}
Example #7
0
bool KPrDocument::loadOdfDocumentStyles( KoPALoadingContext & context )
{
    KPrPageLayouts *layouts = resourceManager()->resource(KPresenter::PageLayouts).value<KPrPageLayouts*>();
    if ( layouts ) {
        layouts->loadOdf( context );
    }
    return true;
}
Example #8
0
void KPrDocument::saveOdfDocumentStyles( KoPASavingContext & context )
{
    KoPADocument::saveOdfDocumentStyles( context );
    KPrPageLayouts *layouts = resourceManager()->resource(KPresenter::PageLayouts).value<KPrPageLayouts*>();

    Q_ASSERT( layouts );
    if ( layouts ) {
        layouts->saveOdf( context );
    }
}
void PerVertexColorShader::apply() const
{
    QOpenGLFunctions_4_1_Core* f = resourceManager()->functions();

    f->glUseProgram(handle());

    f->glEnableVertexAttribArray(m_iAttributeLocations[Position]);
    f->glEnableVertexAttribArray(m_iAttributeLocations[Normal]);
    f->glEnableVertexAttribArray(m_iAttributeLocations[Color]);
}
Example #10
0
KoPADocument::KoPADocument(QWidget* parentWidget, QObject* parent, bool singleViewMode)
    : KoDocument(parentWidget, parent, singleViewMode),
      d(new Private())
{
    d->inlineTextObjectManager = new KInlineTextObjectManager(this);
    d->rulersVisible = false;

    resourceManager()->setUndoStack(undoStack());
    resourceManager()->setOdfDocument(this);
    QVariant variant2;
    variant2.setValue<KInlineTextObjectManager*>(d->inlineTextObjectManager);
    resourceManager()->setResource(KOdfText::InlineTextObjectManager, variant2);
    loadConfig();

    if (!KToolRegistry::instance()->contains("KoPABackgroundTool")) {
        KoPABackgroundToolFactory *f = new KoPABackgroundToolFactory(KToolRegistry::instance());
        KToolRegistry::instance()->add(f);
    }
}
Example #11
0
CL_ResourceManager ResourceManager::loadResourceFile(const std::string &fileName)
{
	ResourceFileMap::const_iterator it = mResourceFiles.find(fileName);
	if (it != mResourceFiles.end())
		return it->second;

	CL_ResourceManager resourceManager(Application::getSingleton().getDataDirectory() + fileName);
	mResourceFiles.insert(std::make_pair(fileName, resourceManager));
	return resourceManager;
}
Example #12
0
KarbonPart::KarbonPart(QWidget* parentWidget, const char* widgetName, QObject* parent, const char* name, bool singleViewMode)
        : KoDocument(parentWidget, parent, singleViewMode), d(new Private())
{
    Q_UNUSED(widgetName);
    d->document.setResourceManager(resourceManager());

    setObjectName(name);
    setComponentData(KarbonFactory::componentData(), false);
    setTemplateType("karbon_template");
    resourceManager()->setUndoStack(undoStack());

    initConfig();

    // set as default paper
    KoPageLayout pl = pageLayout();
    pl.format = KoPageFormat::defaultFormat();
    pl.orientation = KoPageFormat::Portrait;
    pl.width = MM_TO_POINT(KoPageFormat::width(pl.format, pl.orientation));
    pl.height = MM_TO_POINT(KoPageFormat::height(pl.format, pl.orientation));
    setPageLayout(pl);
}
Example #13
0
KWDocument::KWDocument(KoPart *part)
        : KoDocument(part),
        m_isMasterDocument(false),
        m_frameLayout(&m_pageManager, m_frameSets),
        m_mainFramesetEverFinished(false)
{
    m_frameLayout.setDocument(this);
    resourceManager()->setOdfDocument(this);

    connect(&m_frameLayout, SIGNAL(newFrameSet(KWFrameSet*)), this, SLOT(addFrameSet(KWFrameSet*)));
    connect(&m_frameLayout, SIGNAL(removedFrameSet(KWFrameSet*)), this, SLOT(removeFrameSet(KWFrameSet*)));

    // Init shape Factories with our frame based configuration panels.
    m_panelFactories = KWFrameDialog::panels(this);
    foreach (const QString &id, KoShapeRegistry::instance()->keys()) {
        KoShapeFactoryBase *shapeFactory = KoShapeRegistry::instance()->value(id);
        shapeFactory->setOptionPanels(m_panelFactories);
    }
ProgressDialog::ProgressDialog(Widget *parent, const Rect &r) :
    Widget(r, parent),
    m_cancelButton(Rect(rect().w()/2-95/2, 95, 100, 40), this, "Cancel"),
    m_fullProgress(0),
    m_progress(0),
    m_maxFullProgress(0),
    m_maxProgress(0)
{
    m_background = &resourceManager().image("progress");

    m_cancelButton.releasedSignal().connect( [this](Button *self) {

        if(self->isTouched() && !self->isMoved())
            m_onCancelPressed.trigger(self);
    });

    add(&m_cancelButton);
}
 KRES::Manager<KABC::Resource>* getResourceManager()
 {
   return resourceManager();
 }
Example #16
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowSmd)
{
	FileSystem fileSystem("../../Resources");
	Console console(fileSystem, false);
	
	ResourceManager resourceManager(fileSystem, console);

	InputDevice input(console);

	Window window("Void", console, input, resourceManager, fileSystem, 1280, 720, true, false);
	//Window window("Void", console, input, resourceManager, fileSystem);
	if(window.Initialise()) return 0;

	ConsoleEvent shouldQuitConsole(console, input, "Game.Quit");
	input.addDefaultBinding(Key::Q, shouldQuitConsole);
	input.addDefaultBinding(Key::Escape, shouldQuitConsole);

	ConsoleEvent cameraForward(console, input, "Camera.Move.Forward");
	input.addDefaultBinding(Key::W, cameraForward);
	ConsoleEvent cameraBackward(console, input, "Camera.Move.Backward");
	input.addDefaultBinding(Key::S, cameraBackward);
	ConsoleEvent cameraLeft(console, input, "Camera.Move.Left");
	input.addDefaultBinding(Key::A, cameraLeft);
	ConsoleEvent cameraRight(console, input, "Camera.Move.Right");
	input.addDefaultBinding(Key::D, cameraRight);
	ConsoleEvent cameraUp(console, input, "Camera.Move.Up");
	input.addDefaultBinding(Key::Space, cameraUp);
	ConsoleEvent cameraDown(console, input, "Camera.Move.Down");
	input.addDefaultBinding(Key::LCtrl, cameraDown);
	ConsoleEvent cameraSprint(console, input, "Camera.Move.Sprint");
	input.addDefaultBinding(Key::LShift, cameraSprint);

	window.GetGraphicsDevice().getRenderer3D().setSkybox(resourceManager.getResourceReference<TextureResource>("[Texture] Clouds.dds"));

	Camera &camera = window.GetGraphicsDevice().getRenderer3D().getCamera();
	camera.rotateY(Math::DegreesToRadians(90));
	camera.setPosition(-1100.0f, -170.0f, 0.0f);

	std::vector<PointLight> lights;

	ResourceReference<ModelResource> visibleLion = resourceManager.getResourceReference<ModelResource>("[Model] Lion.smdf");

	std::vector<ResourceReference<MaterialResource>> materials;
#define add_model(x) materials.push_back(resourceManager.getResourceReference<MaterialResource>("[Material] " x ".smtf"))
	add_model("Lion");add_model("Lionbackground"); add_model("VaseRound"); add_model("Ceiling");
	add_model("ColumnA"); add_model("ColumnB"); add_model("ColumnC"); add_model("Floor"); add_model("FabricGreen");
	add_model("FabricBlue"); add_model("FabricRed"); add_model("CurtainBlue"); add_model("CurtainRed");
	add_model("CurtainGreen"); add_model("VaseHanging"); add_model("Vase"); add_model("Bricks");
	add_model("Arch"); add_model("Details"); add_model("Roof");	add_model("VasePlant");
	add_model("Chain"); add_model("Thorn");add_model("Vase");

	Timer gameTime;

	bool isMousePressed = false;
	int oldMouseX = 0;
	int oldMouseY = 0;

	for(;;)
	{
		uint64 frameTime = gameTime.getElapsedReset();
		float frameSeconds = frameTime / 1000.0f;

		resourceManager.Update();
		console.update();

		if(window.Update()) break;
		input.Update();

		if(shouldQuitConsole.isPress()) break;

		if(isMousePressed != input.IsKeyDown(Key::LButton))
		{
			isMousePressed = !isMousePressed;
			if(isMousePressed)
			{
				window.setMouseClipping(true);
				oldMouseX = input.GetMouseXPositionAbsolute();
				oldMouseY = input.GetMouseYPositionAbsolute();
				window.setMouseVisibility(true);
			}
			else
			{
				window.setMouseClipping(false);
				window.SetMousePosition(oldMouseX, oldMouseY);
				window.setMouseVisibility(false);
			}
		}

		if(isMousePressed)
		{
			camera.rotateY(Math::DegreesToRadians(input.GetMouseXPositionRelative()));
			camera.rotateX(Math::DegreesToRadians(input.GetMouseYPositionRelative()));
		}

		float distance = 100.0f * frameSeconds;
		if(cameraSprint.isHeld()) distance *= 6;

		if(cameraForward.isHeld()) camera.moveX(distance);
		if(cameraBackward.isHeld()) camera.moveX(-distance);
		if(cameraRight.isHeld()) camera.moveZ(distance);
		if(cameraLeft.isHeld()) camera.moveZ(-distance);
		if(cameraUp.isHeld()) camera.moveY(distance);
		if(cameraDown.isHeld()) camera.moveY(-distance);

		visibleLion->Render();

		if(resourceManager.isLoading())
		{
			if(lights.empty())
				fillLightsGrid(lights, window);
		}
		else if(!lights.empty())
			lights.clear();

		if(input.IsKeyPress(Key::Num1))
			fillLightsGrid(lights, window);

		Vector3 lightChange;
		if(input.IsKeyDown(Key::Up)) lightChange.y += distance;
		if(input.IsKeyDown(Key::Down)) lightChange.y -= distance;
		if(input.IsKeyDown(Key::Left)) lightChange.x += distance;
		if(input.IsKeyDown(Key::Right)) lightChange.x -= distance;

		if(lightChange != Vector3::Zero)
		{
			for(PointLight &light : lights)
				light.setPosition(light.getPosition() + lightChange);
		}
			
		if(window.Render()) break;
	}

	return 0;
}
Example #17
0
bool KoPADocument::loadOdf(KOdfStoreReader &odfStore)
{
    QPointer<KoUpdater> updater;
    if (progressUpdater()) {
        updater = progressUpdater()->startSubtask(1, "KoPADocument::loadOdf");
        updater->setProgress(0);
    }
    KOdfLoadingContext loadingContext(odfStore.styles(), odfStore.store(), componentData());
    KoPALoadingContext paContext(loadingContext, resourceManager());

    KXmlElement content = odfStore.contentDoc().documentElement();
    KXmlElement realBody (KoXml::namedItemNS(content, KOdfXmlNS::office, "body"));

    if (realBody.isNull()) {
        kError(30010) << "No body tag found!" << endl;
        return false;
    }

    KXmlElement body = KoXml::namedItemNS(realBody, KOdfXmlNS::office, odfTagName(false));

    if (body.isNull()) {
        kError(30010) << "No office:" << odfTagName(false) << " tag found!" << endl;
        return false;
    }

    // Load text styles before the corresponding text shapes try to use them!
    KTextSharedLoadingData * sharedData = new KTextSharedLoadingData();
    paContext.addSharedData(KODFTEXT_SHARED_LOADING_ID, sharedData);
    KStyleManager *styleManager = resourceManager()->resource(KOdfText::StyleManager).value<KStyleManager*>();

    sharedData->loadOdfStyles(paContext, styleManager);

    d->masterPages = loadOdfMasterPages(odfStore.styles().masterPages(), paContext);
    if (!loadOdfProlog(body, paContext)) {
        return false;
    }
    d->pages = loadOdfPages(body, paContext);

    // create pages if there are none
    if (d->masterPages.empty()) {
        d->masterPages.append(newMasterPage());
    }
    if (d->pages.empty()) {
        d->pages.append(newPage(static_cast<KoPAMasterPage*>(d->masterPages.first())));
    }

    if (!loadOdfEpilogue(body, paContext)) {
        return false;
    }

    loadOdfDocumentStyles(paContext);

    if (d->pages.size() > 1) {
        setActionEnabled(KoPAView::ActionDeletePage, false);
    }

    updatePageCount();

    if (updater) updater->setProgress(100);
    return true;
}
Example #18
0
int main(int argc, char *argv[])
{
    QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);

    QSurfaceFormat format;
    format.setMajorVersion(4);
    format.setMinorVersion(1);
    format.setProfile(QSurfaceFormat::CoreProfile);
    format.setRenderableType(QSurfaceFormat::OpenGL);
    format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
    format.setSamples(2);

    // Today I learned: the surface itself doesn't need an alpha channel.
    // When we blend colours in OpenGL, the alpha value passed in with the colour
    // is only used internally by OpenGL in order to calculate the physical RGB
    // to write back into the colour buffer. We don't need to set any alpha on the
    // surface itself, since the RGB values will already have been blended by the
    // time they're written back to the colour buffer. If we do set the alpha, that
    // means we'll actually be able to see through the surface and whatever is behind
    // will be visible. This isn't what we want for the application main window!
    // If we want to create a frame buffer later on where the actual colour buffer
    // output should be translucent, override the default alpha buffer size to 8 bits.

    format.setDepthBufferSize(24);
    format.setRedBufferSize(8);
    format.setGreenBufferSize(8);
    format.setBlueBufferSize(8);
    format.setAlphaBufferSize(0);
    format.setStencilBufferSize(8);

    QSurfaceFormat::setDefaultFormat(format);
    qDebug() << "Set default OpenGL format:" << format;

    QApplication a(argc, argv);
    a.setApplicationName("Calliper");
    a.setApplicationDisplayName("Calliper");
    a.setOrganizationName("Infra");
    a.setOrganizationName("Infra");

    // Initialise the resource manager.
    ResourceManager::initialise();

    // Initialise the renderer.
    OpenGLRenderer::initialise();

    // Initialise the over-arching application.
    Application::initialise(new MainWindow());

    // Set up resources.
    resourceManager()->makeCurrent();
    resourceManager()->setUpOpenGLResources();
    renderer()->setUpOpenGLResources();
    resourceManager()->doneCurrent();

    application()->mainWindow()->show();
    
    int ret = a.exec();

    // Shut down the application.
    Application::shutdown();

    // Shut down the renderer.
    OpenGLRenderer::shutdown();

    // Shut down the resource manager.
    ResourceManager::shutdown();

    return ret;

    return a.exec();
}
Example #19
0
int main( void )
{
	//debug:: lets find the path
#ifdef CRAP_COMPILER_MSVC
	crap::string256 data_path("../../../data/");
#else
	crap::string256 data_path("../data/");
#endif

	//logger
    crap::logger< crap::log_time_time, crap::log_channel_core, crap::log_type_debug, crap::log_target_cout, 512 > unit_logger;

    //system
    crap::System system;

	//lets config
	crap::string256 ini_path = data_path + "configuration.ini";
	crap::Configuration config( 1024*10, 100 );

	config.load( ini_path.c_str() );

	//set config as subsystem
	crap::SubSystem config_sys( "Configuration", &config, &system );

	//taskmanager
	const uint32_t tasksMaxNumber = config.getValue<uint32_t>("TASKS_MAX_NUM");
	const uint32_t tasksDeattachedMaxNumber = config.getValue<uint32_t>("TASKS_DEATTACHED_MAX_NUM");
	crap::TaskManager taskManager( tasksMaxNumber, tasksDeattachedMaxNumber );

	//set TaskManager as Subsystem
	crap::SubSystem tasks_sys( "TaskManager", &taskManager, &system );

	//eventsystem
	const uint32_t eventMaxNumber = config.getValue<uint32_t>("EVENTS_MAX_NUM");
	crap::EventSystem eventSystem( eventMaxNumber );

	//set EventSystem as SubSystem
	crap::SubSystem events_sys( "EventSystem", &eventSystem, &system );

	//resourcemanager
	const uint32_t resoureMemory = config.getValue<uint32_t>("RESOURCE_MEMORY");
	const uint32_t resoureNumber = config.getValue<uint32_t>("RESOURCE_NUMBER");
	const crap::string64 resourceFile = config.getValue<crap::string64>("RESOURCE_FILE");
	const bool resourceXML = config.getValue<uint32_t>("RESOURCE_XML") == 1;

	crap::ResourceManager resourceManager( resoureMemory, resoureNumber, data_path, &system );
	if( resourceXML )
		resourceManager.loadXML( resourceFile );
	else
		resourceManager.loadPackage( resourceFile );

	// set resourcemanager as subsystem
	crap::SubSystem resource_sys( "ResourceManager", &resourceManager, &system );

	//AudioSystem
	const uint32_t audioBufferNumber = config.getValue<uint32_t>("AUDIO_BUFFER_NUM");
	const uint32_t audioSourceNumber = config.getValue<uint32_t>("AUDIO_SOURCE_NUM");
	crap::AudioSystem AudioSystem(audioBufferNumber, audioSourceNumber);

	//set AudioSystem as subsystem
	crap::SubSystem audio_sys( "AudioSystem", &AudioSystem, &system );

	//componentsystem
	const uint32_t componentMemory = config.getValue<uint32_t>("COMPONENT_MEMORY");
	const uint32_t componentMaxNodes = config.getValue<uint32_t>("COMPONENT_MAX_NODES");
	crap::ComponentSystem componentSystem( componentMemory, componentMaxNodes , &system );

	//set componentsystem as subsystem
	crap::SubSystem component_sys( "ComponentSystem", &componentSystem, &system );

	//renderwindow
	const crap::string64 windowName = config.getValue<crap::string64>("RENDER_WINDOW_NAME");
	const uint32_t windowWidth = config.getValue<uint32_t>("RENDER_WINDOW_WIDTH");
	const uint32_t windowHeight = config.getValue<uint32_t>("RENDER_WINDOW_HEIGHT");
	const bool windowFullscreen = config.getValue<uint32_t>("RENDER_WINDOW_FULLSCREEN") == 1;
	const uint32_t windowMaxCallbacks = config.getValue<uint32_t>("RENDER_WINDOW_MAX_CALLBACKS");
	crap::RenderWindow renderWindow( windowMaxCallbacks );
	renderWindow.create( windowName.c_str(), windowWidth, windowHeight, windowFullscreen );

	//renderer
	crap::RenderSystem renderer( &renderWindow );
	renderer.init();

	//set renderer as subsystem
	crap::SubSystem renderer_sys("Renderer", &renderer, &system );

	//inputmanager
	const uint32_t inputMemory = config.getValue<uint32_t>("INPUT_MEMORY");
	crap::InputManager inputManager( inputMemory, renderWindow.getHandle() );

	//add keyboard
	crap::KeyboardInput keyboardInput("Keyboard", 20, &inputManager );
	keyboardInput.addListener<&exitFunc>( thekey, 0, true );

	//add mouse
	crap::MouseInput mouseInput("Mouse", 20, 20, 20, 20, &inputManager );
	mouseInput.addButtonListener<&clickFunc>( 0, 0, true );
	mouseInput.addPositionListener<&posFunc>( true );
	mouseInput.addScrollListener<&scrollFunc>( true );
	mouseInput.addEnterListener<&enterFunc>( true );

	//controller
	crap::ControllerInput controllerInput("Controller", 8, &inputManager );
	uint32_t joyID = controllerInput.leaseJoystickID();
	controllerInput.addAxisListener<&joyAxis>( joyID );
	controllerInput.addButtonListener<&joyButton>( joyID );

	/* Add directory update to taskmanager */
	taskManager.addTask<crap::InputManager, &crap::InputManager::update>("InputPolling", &inputManager, 50, true, false );

	/* Physic system 2D */
	crap::PhysicSystem2D physicSystem2D( 1000, 0.f, 10.f, 8, 2, 1.f/200.f );
	crap::SubSystem physic_sys2d( "PhysicSystem2D", &physicSystem2D, &system );

	taskManager.addTask< crap::PhysicSystem2D, &crap::PhysicSystem2D::update>( "Physic2DUpdate", &physicSystem2D, 20, true, false );

	//pluginmanager
	const uint32_t pluginNumber = config.getValue<uint32_t>("PLUGIN_NUMBER");
	const uint32_t pluginMemory = config.getValue<uint32_t>("PLUGIN_MEMORY");
	crap::PluginManager pluginManager(pluginNumber, pluginMemory, &system );

	//set pluginmanager as subsystem
	crap::SubSystem plugin_sys( "PluginManager", &pluginManager, &system );

	//set Directory listener
	const uint32_t pluginFunctionNumber = config.getValue<uint32_t>("PLUGIN_FUNCTION_NUM");
	const uint32_t pluginFileNumber = config.getValue<uint32_t>("PLUGIN_FILES_NUM");
	const crap::string256 pluginDir = data_path + config.getValue<crap::string64>("PLUGIN_SUBDIRECTORY");
	crap::DirectoryListener pluginDirectoryListener( pluginFunctionNumber, pluginFileNumber, pluginDir, false );
	pluginDirectoryListener.addCallback<crap::PluginManager, &crap::PluginManager::callbackFunction>( &pluginManager );

	/* Add directory update to taskmanager */
	taskManager.addTask<crap::DirectoryListener, &crap::DirectoryListener::update>("PluginPath", &pluginDirectoryListener, 1000, true, false );

	//init this.. (do that at last)
	pluginDirectoryListener.init();

	crap::Configuration* testconf = system.getSubSystem<crap::Configuration>( "Configuration" );
	if( testconf != 0 )
	{
		std::cout << "I've worked! " << testconf->getValue<crap::string64>("SOUND_VOLUME") << std::endl;
	}

	float32_t zero[3] = {0.f, 0.f, 0.f};
	float32_t one[3] = {1.f, 1.f, 1.f};
	float32_t dir[6] = {0.f, 0.f, 1.f, 0.f, 1.f, 0.f };

	crap::AudioSystem* am = system.getSubSystem<crap::AudioSystem>( "AudioSystem" );

	resourceManager.loadResource( "Nagut" );
	uint32_t sid = am->leaseSource( "Nagut" );

	am->setListenerData( zero, zero, dir );
	am->playSource( sid );

//	while( am->getIsPlaying(sid) )
//		crap::sleep_mil_sec(100);

	crap::log( LOG_CHANNEL_CORE | LOG_TYPE_INFO | LOG_TARGET_COUT, "We're done!" );

	crap::Renderer2D renderer2D( &renderWindow, 10, 10, 100 );
	crap::SubSystem renderer2d_sys( "Renderer2D", &renderer2D, &system );

	crap::Context2D* gc = renderer2D.getContext();
	resourceManager.loadResource( "Hasi" );
	resourceManager.loadResource( "Mieze" );
	uint32_t guiImage = renderer2D.getImage2D("Hasi");
	uint32_t guiImage2 = renderer2D.getImage2D("Mieze");

	resourceManager.loadResource("CalcFont");
	crap::Font2D font2d = renderer2D.getFont2D("CalcFont");

	crap::Node* cnode = componentSystem.createNode();
	crap::Component* trans2d = componentSystem.createComponent("Attributes2D", cnode );
	componentSystem.setComponentMember( trans2d, "posX", "600" );
	componentSystem.setComponentMember( trans2d, "posY", "600" );
	componentSystem.setComponentMember( trans2d, "rotation", "20" );
	componentSystem.setComponentMember( trans2d, "scale", "1.f" );
	trans2d->init( &system );


	crap::color_argb colorf;
	colorf.r = 0;
	colorf.b = 0;
	colorf.g = 255;
	colorf.a = 128;

	crap::color_argb colorb;

	//black
	colorb.r = 0;
	colorb.b = 0;
	colorb.g = 0;
	colorb.a = 255;

	crap::color_argb col = crap::argb::black;

	crap::string64 colstr("AABBCCDD");
	uint32_t lolali = strtol("AABBCCDD", 0, 16 );
	crap::color_argb colorino = crap::convert<crap::string64, crap::color_argb>( colstr );

	crap::string64 popo = crap::convert<crap::color_argb, crap::string64>( crap::argb::orange );

	crap::string64 buff = crap::convert<crap::color_argb, crap::string64>(colorf);
	crap::string64 bufb = crap::convert<crap::color_argb, crap::string64>(colorb);

	crap::Component* circle2d = componentSystem.createComponent("RoundedRectangle2D", cnode );

	componentSystem.setComponentMember( circle2d, "width", "150" );
	componentSystem.setComponentMember( circle2d, "height", "200" );
	componentSystem.setComponentMember( circle2d, "corner", "20" );
	componentSystem.setComponentMember( circle2d, "color", buff );
	componentSystem.setComponentMember( circle2d, "border", "5" );
	componentSystem.setComponentMember( circle2d, "borderColor", bufb );

	circle2d->init(&system);

	crap::Node* tnode = componentSystem.createNode();


	crap::Component* trans2dt = componentSystem.createComponent("Attributes2D", tnode );
	componentSystem.setComponentMember( trans2dt, "posX", "200" );
	componentSystem.setComponentMember( trans2dt, "posY", "600" );
	componentSystem.setComponentMember( trans2dt, "rotation", "0" );
	componentSystem.setComponentMember( trans2dt, "scale", "1.f" );
	trans2d->init( &system );

	crap::Component* text2d = componentSystem.createComponent("Text2D", tnode );
	componentSystem.setComponentMember( text2d, "fontName", "CalcFont" );
	componentSystem.setComponentMember( text2d, "text", "Hallo ich bin ein Test" );
	componentSystem.setComponentMember( text2d, "fontSize", "50" );
	componentSystem.setComponentMember( text2d, "color", bufb );
	componentSystem.setComponentMember( text2d, "blur", "1" );

	text2d->init(&system);

	//physic test
	crap::Node* pnode = componentSystem.createNode();
	crap::Component* ptrans2d = componentSystem.createComponent("Attributes2D", pnode );
	componentSystem.setComponentMember( ptrans2d, "posX", "770" );
	componentSystem.setComponentMember( ptrans2d, "posY", "550" );
	componentSystem.setComponentMember( ptrans2d, "rotation", "-0.3f" );
	componentSystem.setComponentMember( ptrans2d, "scale", "1.f" );

	crap::Component* rect2d = componentSystem.createComponent("Rectangle2D", pnode );
	componentSystem.setComponentMember( rect2d, "width", "300" );
	componentSystem.setComponentMember( rect2d, "height", "50" );
	componentSystem.setComponentMember( rect2d, "color", buff );
	componentSystem.setComponentMember( rect2d, "border", "0" );
	componentSystem.setComponentMember( rect2d, "borderColor", bufb );

	crap::Component* phys2d = componentSystem.createComponent("Rectangle2DPhysic", pnode );
	componentSystem.setComponentMember( phys2d, "width", "300" );
	componentSystem.setComponentMember( phys2d, "height", "50" );
	componentSystem.setComponentMember( phys2d, "density", "1.f" );
	componentSystem.setComponentMember( phys2d, "friction", "1.f" );
	componentSystem.setComponentMember( phys2d, "dynamic", "0" );

	ptrans2d->init(&system);
	rect2d->init(&system);
	phys2d->init(&system);

	//solid
	crap::Node* pnode2 = componentSystem.createNode();
	crap::Component* ptrans2d2 = componentSystem.createComponent("Attributes2D", pnode2 );
	componentSystem.setComponentMember( ptrans2d2, "posX", "550" );
	componentSystem.setComponentMember( ptrans2d2, "posY", "400" );
	componentSystem.setComponentMember( ptrans2d2, "rotation", "0.2" );
	componentSystem.setComponentMember( ptrans2d2, "scale", "1.f" );

	crap::Component* rect2d2 = componentSystem.createComponent("Rectangle2D", pnode2 );
	componentSystem.setComponentMember( rect2d2, "width", "300" );
	componentSystem.setComponentMember( rect2d2, "height", "50" );
	componentSystem.setComponentMember( rect2d2, "color", bufb );
	componentSystem.setComponentMember( rect2d2, "border", "0" );
	componentSystem.setComponentMember( rect2d2, "borderColor", bufb );

	crap::Component* phys2d2 = componentSystem.createComponent("Rectangle2DPhysic", pnode2 );
	componentSystem.setComponentMember( phys2d2, "width", "300" );
	componentSystem.setComponentMember( phys2d2, "height", "50" );
	componentSystem.setComponentMember( phys2d2, "density", "1.f" );
	componentSystem.setComponentMember( phys2d2, "friction", "1.f" );
	componentSystem.setComponentMember( phys2d2, "dynamic", "0" );

	ptrans2d2->init(&system);
	rect2d2->init(&system);
	phys2d2->init(&system);

	//circle
	crap::Node* pnode3 = componentSystem.createNode();
	crap::Component* ptrans2d3 = componentSystem.createComponent("Attributes2D", pnode3 );
	componentSystem.setComponentMember( ptrans2d3, "posX", "600" );
	componentSystem.setComponentMember( ptrans2d3, "posY", "50" );
	componentSystem.setComponentMember( ptrans2d3, "rotation", "0" );
	componentSystem.setComponentMember( ptrans2d3, "scale", "1.f" );

	crap::Component* rect2d3 = componentSystem.createComponent("Circle2D", pnode3 );
	componentSystem.setComponentMember( rect2d3, "radius", "20" );
	componentSystem.setComponentMember( rect2d3, "color", "FF0080FF" );
	componentSystem.setComponentMember( rect2d3, "border", "0" );
	componentSystem.setComponentMember( rect2d3, "borderColor", "FF0000F" );

	crap::Component* phys2d3 = componentSystem.createComponent("Cirlce2DPhysic", pnode3 );
	componentSystem.setComponentMember( phys2d3, "radius", "20" );
	componentSystem.setComponentMember( phys2d3, "density", "1.f" );
	componentSystem.setComponentMember( phys2d3, "friction", "1.f" );
	componentSystem.setComponentMember( phys2d3, "dynamic", "1" );

	ptrans2d3->init(&system);
	rect2d3->init(&system);
	phys2d3->init(&system);

	crap::color_argb bord;
	bord.value = 0;
	float32_t rot = 0.f;
	while( running && !renderWindow.shouldClose() )
	{
		renderer.drawBegin();
		renderer2D.drawBegin();
//		crap::drawColoredRectangle( gc, 100.f, 100.f, 100.f, 100.f, -rot*0.1, 255, 0, 255, 255 );
//		//crap::drawColoredCircle( gc, 500.f, (int32_t)(rot*100) % renderWindow.getHeight(), 50.f, 255, 0, 0, 255 );
//		rot += 0.1f;
//		crap::drawColoredRoundedRectangle( gc, 150.f, 150.f, 200.f, 200.f, rot, 0, 0, 255, 128, 20.f );
//
//		crap::drawColorTriangle( gc, 400, 400, 140, 100, 0.f, 0, 255, 0, 255 );
//
//		crap::drawImageRectangle( gc, (int32_t)(rot*10) % renderWindow.getWidth(), 400, 100, 100, rot*0.1, guiImage, 100.f, 100.f, 0.f, 0.f, 0.f, 1.f );
//
//		crap::drawImageCircle( gc, 600, 200, 50, guiImage2, 255, 100.f, 100.f, 0.f, -10,10-rot*2, 0.3f);
//
//		crap::drawText(gc, 400, 400, font2d, "Hallo, du Welt.", 30.f ,0.f , 0, 255, 0, 255, 0, 1, 10.f, crap::align::left);

		bord.value++;
		bord.value %= 100;
		componentSystem.setComponentMember( circle2d, "corner", crap::convert<crap::color_argb, crap::string64>(bord) );
		componentSystem.setComponentMember( text2d, "fontSize", "100" );

		renderer2D.render();

		renderer2D.drawEnd();
		renderer.drawEnd();
		//renderWindow.swap();
		taskManager.update();
	}

	renderer2D.removeImage2D( "Mieze" );
	renderer2D.removeImage2D( "Hasi" );

	renderWindow.destroy();

#ifdef CRAP_COMPILER_MSVC
//    std::cout << "Press a button" << std::endl;
//	getchar();
#endif

	pluginDirectoryListener.removeCallback<crap::PluginManager, &crap::PluginManager::callbackFunction>( &pluginManager );
	pluginManager.unloadAll();

	return 0;
}
Example #20
0
void KWCanvasItem::updateSize()
{
    resourceManager()->setResource(Words::CurrentPageCount, m_document->pageCount());
    emit documentSize(m_viewMode->contentsSize());
}
Example #21
0
 graphics::RenderContext * RenderContext::createShared()
 {
   graphics::gl::RenderContext * res = new RenderContext(this);
   res->setResourceManager(resourceManager());
   return res;
 }
Example #22
0
void SceneObject::draw(ShaderStack *stack)
{
    bool shaderOverridden = false;
    if ( !geometry()->isEmpty() )
    {
        // If we have a shader override, push the override.
        QString shaderOverrideName = geometry()->shaderOverride();
        if ( !shaderOverrideName.isNull() )
        {
            ShaderProgram* program = resourceManager()->shader(shaderOverrideName);
            if ( program )
            {
                shaderOverridden = true;
                stack->shaderPush(program);
            }
        }
    }

    // Multiply the modelWorld matrix by our current one.
    // This updates the shader uniform too.
    // We do this even if the geometry is empty, so that the
    // transformation will apply recursively.
    // It is the caller's responsibility to manage pushing
    // and popping of the m2w matrix.
    stack->modelToWorldPostMultiply(localToParent());

    if ( !geometry()->isEmpty() )
    {
        // Upload and bind the geometry.
        geometry()->upload();
        geometry()->bindVertices(true);
        geometry()->bindIndices(true);

        // Apply the data format.
        geometry()->applyDataFormat(stack->shaderTop());

        // If we're selected, set the global colour.
        bool pushedColor = false;
        MapDocument* doc = m_pScene->document();
        if ( doc->selectedSet().contains(this) )
        {
            pushedColor = true;
            stack->globalColorPush();
            stack->globalColorSetTop(doc->selectedColor());
        }

        // Apply the texture.
        QOpenGLTexture* tex = resourceManager()->texture(geometry()->texture(0));
        tex->bind(0);

        // Draw.
        geometry()->draw();

        if ( pushedColor )
        {
            stack->globalColorPop();
        }

        // Pop the shader if we pushed one earlier.
        if ( shaderOverridden )
        {
            stack->shaderPop();
        }
    }
}
Example #23
0
bool KarbonPart::loadOdf(KoOdfReadStore & odfStore)
{
    kDebug(38000) << "Start loading OASIS document..." /*<< doc.toString()*/;

    KoXmlElement contents = odfStore.contentDoc().documentElement();
    kDebug(38000) << "Start loading OASIS document..." << contents.text();
    kDebug(38000) << "Start loading OASIS contents..." << contents.lastChild().localName();
    kDebug(38000) << "Start loading OASIS contents..." << contents.lastChild().namespaceURI();
    kDebug(38000) << "Start loading OASIS contents..." << contents.lastChild().isElement();
    KoXmlElement body(KoXml::namedItemNS(contents, KoXmlNS::office, "body"));
    if (body.isNull()) {
        kDebug(38000) << "No office:body found!";
        setErrorMessage(i18n("Invalid OASIS document. No office:body tag found."));
        return false;
    }

    body = KoXml::namedItemNS(body, KoXmlNS::office, "drawing");
    if (body.isNull()) {
        kDebug(38000) << "No office:drawing found!";
        setErrorMessage(i18n("Invalid OASIS document. No office:drawing tag found."));
        return false;
    }

    KoXmlElement page(KoXml::namedItemNS(body, KoXmlNS::draw, "page"));
    if (page.isNull()) {
        kDebug(38000) << "No office:drawing found!";
        setErrorMessage(i18n("Invalid OASIS document. No draw:page tag found."));
        return false;
    }

    KoXmlElement * master = 0;
    if (odfStore.styles().masterPages().contains("Standard"))
        master = odfStore.styles().masterPages().value("Standard");
    else if (odfStore.styles().masterPages().contains("Default"))
        master = odfStore.styles().masterPages().value("Default");
    else if (! odfStore.styles().masterPages().empty())
        master = odfStore.styles().masterPages().begin().value();

    if (master) {
        const QString pageStyleName = master->attributeNS(KoXmlNS::style, "page-layout-name", QString());
        const KoXmlElement *style = odfStore.styles().findStyle(pageStyleName);
        if (style) {
            KoPageLayout layout;
            layout.loadOdf(*style);
            setPageLayout(layout);
        }
    } else {
        kWarning() << "No master page found!";
        return false;
    }

    KoOdfLoadingContext context(odfStore.styles(), odfStore.store());
    KoShapeLoadingContext shapeContext(context, resourceManager());

    d->document.loadOasis(page, shapeContext);

    if (d->document.pageSize().isEmpty()) {
        QSizeF pageSize = d->document.contentRect().united(QRectF(0, 0, 1, 1)).size();
        setPageSize(pageSize);
    }

    loadOasisSettings(odfStore.settingsDoc());

    return true;
}
Example #24
0
int sectionNumChildren(const std::string &section)
{
    return resourceManager().sectionHandle(section).get_child_nodes().get_length();
}