void mepp_component_CGAL_Example_plugin::step5()
{
	QApplication::setOverrideCursor(Qt::WaitCursor);

	// active viewer
	if (mw->activeMdiChild() != 0)
	{
		Viewer* viewer = (Viewer *)mw->activeMdiChild();
		PolyhedronPtr polyhedron_ptr = viewer->getScenePtr()->get_polyhedron();

		CGAL_Example_ComponentPtr component_ptr = findOrCreateComponentForViewer<CGAL_Example_ComponentPtr, CGAL_Example_Component>(viewer, polyhedron_ptr);
		
		Vec pw(2, 0, 0); viewer->frame(viewer->getScenePtr()->get_current_polyhedron())->setPosition(pw); // position in world coordinate system
		//Vec pl(2, 0, 0); viewer->frame(viewer->getScenePtr()->get_current_polyhedron())->setTranslation(pl); // local frame translation

		Quaternion qw(0, 0, 0, 1); // identity quaternion (i.e., no rotation)
		viewer->frame(viewer->getScenePtr()->get_current_polyhedron())->setOrientation(qw); // rotation in world coordinate system
		/*Quaternion ql(0, 0, 0, 1); // identity quaternion (i.e., no rotation)
		viewer->frame(viewer->getScenePtr()->get_current_polyhedron())->setRotation(ql); // local frame rotation*/

		viewer->updateGL();
	}

	QApplication::restoreOverrideCursor();
}
示例#2
0
void Viewer_mainLoop() {
	long lastTime = currentTimeMillis();
	while(true) {
		bool haveEvent = false;
		SDL_Event event;
		if(viewer.isCurrentlyAnimating()) {
			SDL_Delay(10);
			haveEvent = SDL_PollEvent(&event) > 0;
		}
		else {
			haveEvent = SDL_WaitEvent(&event) > 0;
			lastTime = currentTimeMillis();
		}
		while(haveEvent) {
			if(!HandleEvent(event)) return;
			/* Read further events if there are any. It's important that we do this to keep
			 * the SDL queue as empty as possible. The ReadStdinThread will push a lot of
			 * events into it and we want to keep it responsible to other real input events.
			 */
			haveEvent = SDL_PollEvent(&event) > 0;			
		}
		
		long dt = currentTimeMillis() - lastTime;
		lastTime += dt;
		
		FillSurface(SDL_GetVideoSurface(), backgroundCol);
		viewer.frame(SDL_GetVideoSurface(), dt);
		SDL_Flip(SDL_GetVideoSurface());
	}
}
void mepp_component_Boolean_Operations_plugin::New_Position()
{
    QApplication::setOverrideCursor(Qt::WaitCursor);

    // active viewer
    if (mw->activeMdiChild() != 0)
    {
        float x, y, z;
        double a, b, c, w;
        Viewer* viewer = (Viewer *)mw->activeMdiChild();

        ScenePtr S = viewer->getScenePtr();

        for(int i = 0; i<viewer->getScenePtr()->get_nb_polyhedrons(); i++)
        {
            Vertex_iterator pVertex = NULL;

            PolyhedronPtr P = S->get_polyhedron(i);

            viewer->frame(i)->getPosition(x,y,z);
            viewer->frame(i)->getOrientation(a,b,c,w);

            Vec T(x, y, z);
            Quaternion Q(a, b, c, w);

            for (pVertex = P->vertices_begin(); pVertex != P->vertices_end(); pVertex++)
            {
                Vec V = Q * Vec(pVertex->point().x(), pVertex->point().y(), pVertex->point().z()) + T;
                pVertex->point() = CGAL::ORIGIN + Vector(V[0], V[1], V[2]);
            }

            viewer->frame(i)->setPosition(0,0,0);
            viewer->frame(i)->setOrientation(0,0,0,1);
        }
        viewer->show();
        viewer->recreateListsAndUpdateGL();
    }
    QApplication::restoreOverrideCursor();
}