Viewer *NotifyManager::onNotifyAdd(const QJsonObject &value) {
    m_clearButton->setVisible(true);

    Viewer* viewer = new Viewer(value, this);

    viewer->setFixedHeight(80);
    viewer->setContentsMargins(0, 0, 0, 0);

    viewer->adjustSize();

    m_viewerList.insert(viewer, value);
    connect(viewer, &Viewer::requestClose, this, &NotifyManager::onNotifyRemove);
    update();

    return viewer;
}
void NotifyManager::onNotifyRemove(const QString &id)
{
    // main key is time;

    Viewer *viewer = qobject_cast<Viewer*>(sender());

    Q_ASSERT(viewer);

    m_connectLayout->removeWidget(viewer);
    m_viewerList.remove(viewer);
    m_dbus->RemoveRecord(id);

    viewer->deleteLater();

    update();
}
Exemple #3
0
int main(int argc, char **argv) {
    if (argc < 2) {
        printf("Usage: \n\ttxtview <file.txt>\n");
        return 1;
    }

    Viewer viewer = Viewer();
    MyRenderer *xyzRenderer = new MyRenderer();
    viewer.set_renderer(xyzRenderer);
    viewer.init();
    char *xyz_file = argv[1];
    xyzRenderer->load(xyz_file);
    viewer.start();

    return 0;
}
Exemple #4
0
void OverlaysComp::SelectClipboard (Clipboard* cb, Editor* ed) {
    Selection* s = ed->GetSelection();
    s->Clear();
    Viewer* viewer;
    Iterator i;

    for (int j = 0; (viewer = ed->GetViewer(j)) != nil; ++j) {
        for (cb->First(i); !cb->Done(i); cb->Next(i)) {
            GraphicView* views = viewer->GetGraphicView();
            GraphicView* view = views->GetGraphicView(cb->GetComp(i));

            if (view != nil) s->Append(view);
        }
    }
    ((OverlaySelection*)s)->Reserve();
}
Exemple #5
0
void reshape( int w, int h ){
								glViewport( 0, 0, w, h );
								glMatrixMode( GL_PROJECTION );
								glLoadIdentity();
								gluPerspective( 45.0, GLdouble(w)/GLdouble(h), 1.0, 10000.0 );
								View.lookAt( 0, 0, 40,  0, 0, 0,  0, 1, 0 ); //eye, target, up
}
Exemple #6
0
int main(int argc, char** argv)
{
  QApplication application(argc, argv);

  Viewer viewer;

#if QT_VERSION < 0x040000
  application.setMainWidget(&viewer);
#else
  viewer.setWindowTitle("drawLight");
#endif

  viewer.show();

  return application.exec();
}
Exemple #7
0
int main(int argc, char** argv){
    // Read command lines arguments.
    QApplication application(argc,argv);
    // Instantiate the viewer.
    Viewer viewer;
#if QT_VERSION < 0x040000
    // Set the viewer as the application main widget.
    //application.setMainWidget(&viewer);
#else
    viewer.setWindowTitle("simpleViewer");
#endif
    // Make the viewer window visible on screen.
    viewer.show();
    // Run main loop.
    return application.exec();
}
Exemple #8
0
void
MainThread::work() 
{
    setMaxHeartbeatInterval( 1.0 );

    // get 1 image
    // and check it's description for the particular image configuration
    getImage();
    
    //set up the viewer according to the configuration
    Viewer viewer = Viewer( imageData_->description->width,
                            imageData_->description->height,
                            imageData_->description->format,
                            context_ );

    while ( !isStopping() )
    {
        try 
        {
            // this blocks until a new image arrives and then
            // copies into a member variable
            getImage();
            
            // pass the image to the viewer
            viewer.display( imageData_ );
            
            //pushing too fast will cause the gui to not respond, sleep to prevent that
            // TODO: dodgy hack... needs to be fixed
            // The GUI diplay should be independent of incoming data. If the GUI dies,
            // then this code should be in the Viewer.
            IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(5));
        }
        catch ( ... ) 
        {
            orcaice::catchMainLoopExceptions( health() );

            // Re-create the viewer, unless we are stopping
            if ( !isStopping() ) {
                // TODO: make opencv window handle exception safe so we can create
                // another viewer here. At the moment, if an exception is thrown, 
                // the viewer will not self destruct. 
                // createViewer();
            }
        }

    } // end of while
}
void mepp_component_Boolean_Operations_plugin::Union()
{
    QApplication::setOverrideCursor(Qt::WaitCursor);

    // active viewer
    if (mw->activeMdiChild() != 0)
    {
        Viewer* viewer = (Viewer *)mw->activeMdiChild();
        Viewer* viewerU = NULL;

        if (viewer->getScenePtr()->get_nb_polyhedrons() == 2)
        {
            ScenePtr S = viewer->getScenePtr();
            PolyhedronPtr polyhedron_ptr_in1 = viewer->getScenePtr()->get_polyhedron(0);
            PolyhedronPtr polyhedron_ptr_in2 = viewer->getScenePtr()->get_polyhedron(1);
            PolyhedronPtr polyhedron_ptr_out;

            emit(mw->get_actionNewEmpty()->trigger());

            for (int i=0; i<lwindow.size(); i++) // all viewers
            {
                viewerU = (Viewer *)qobject_cast<QWidget *>(lwindow[i]->widget());
                if (viewerU->getScenePtr()->get_polyhedron()->empty())
                {
                    polyhedron_ptr_out = viewerU->getScenePtr()->get_polyhedron();
                }
            }

            Boolean_Operations_ComponentPtr component_ptr = findOrCreateComponentForViewer<Boolean_Operations_ComponentPtr, Boolean_Operations_Component>(viewer, polyhedron_ptr_in1);
            component_ptr->Boolean_Union(polyhedron_ptr_in1, polyhedron_ptr_in2, polyhedron_ptr_out);
            component_ptr->cpt_U++;

            polyhedron_ptr_out->compute_bounding_box();
            polyhedron_ptr_out->compute_normals();
            polyhedron_ptr_out->compute_type();
            (void)polyhedron_ptr_out->calc_nb_components();
            (void)polyhedron_ptr_out->calc_nb_boundaries();

            viewerU->showAllScene();

            viewerU->getScenePtr()->setcurrentFile(tr("Union %1 from vid %2").arg(component_ptr->cpt_U).arg((qlonglong)viewer, 0, 16));
            viewerU->setDynTitle();
        }
    }

    QApplication::restoreOverrideCursor();
}
Exemple #10
0
int main(int argc, char** argv)
{
  // Read command lines arguments.
  QApplication application(argc,argv);

  // Instantiate the viewer.
  Viewer viewer;
  //for Windows
  application.setAttribute(Qt::AA_UseDesktopOpenGL);
  viewer.setWindowTitle("Intersection points of randomly generated circles.");

  // Make the viewer window visible on screen.
  viewer.show();

  // Run main loop.
  return application.exec();
}
Exemple #11
0
void Editor::save(const bool all)
{
    int index = all ? 0 : files->currentIndex();
    if (index < 0)
        return;
    do {
        Coder *coder = qobject_cast<Coder *>(tabs->widget(index));
        if (coder != nullptr)
            coder->save();
        else {
            Viewer *viewer = qobject_cast<Viewer *>(tabs->widget(index));
            if (viewer != nullptr)
                viewer->save();
        }
        index++;
    } while (all && (index < files->count()));
}
void mepp_component_Various_Processing_plugin::LaplacianSmoothing()
{
	// active viewer
	if (mw->activeMdiChild() != 0)
	{
		Viewer* viewer = (Viewer *)mw->activeMdiChild();
		PolyhedronPtr polyhedron_ptr = viewer->getScenePtr()->get_polyhedron();

		Various_Processing_ComponentPtr component_ptr = findOrCreateComponentForViewer<Various_Processing_ComponentPtr, Various_Processing_Component>(viewer, polyhedron_ptr);

		SettingsDialog_Various_Processing_Smoothing dial;
		if (dial.exec() == QDialog::Accepted)
		{
			QApplication::setOverrideCursor(Qt::WaitCursor);

			/*char deformFactorChar[256];
			strcpy(deformFactorChar, dial.m_textCtrlDeformFactor->GetValue().ToAscii());*/
			double deformFactor = dial.DeformFactor->value();

			/*char IteraNumChar[256];
			strcpy(IteraNumChar, dial.m_textCtrlIteraNum->GetValue().ToAscii());*/
			int iteraNum = dial.IteraNum->value();

			bool preserveBoundaries = dial.PreserveBoundaries->isChecked();

			//wxBusyInfo busy(_T("Laplacian smoothing..."));
			//m_frame->set_status_message(_T("Laplacian smoothing..."));
			mw->statusBar()->showMessage(tr("Laplacian smoothing..."));
			//double start = clock();

			component_ptr->LaplacianSmoothing(polyhedron_ptr,deformFactor,iteraNum,preserveBoundaries);

			/*float duration = (float)((clock()-start)/CLOCKS_PER_SEC);
			m_frame->update_mesh_properties();
			m_frame->Refresh();
			wxString msg;
			msg.Printf(_T("Laplacian smoothing...done (%g s)"), duration);
			m_frame->set_status_message(msg);*/
			mw->statusBar()->showMessage(tr("Laplacian smoothing...done"));

			viewer->recreateListsAndUpdateGL();
		}
	}

	QApplication::restoreOverrideCursor();
}
void mepp_component_Partition_plugin::step5()
{
    if (mw->activeMdiChild() != 0)
    {
        Viewer* viewer = (Viewer *)mw->activeMdiChild();
        PolyhedronPtr polyhedron_ptr = viewer->getScenePtr()->get_polyhedron();
        Partition_ComponentPtr component_ptr = findOrCreateComponentForViewer<Partition_ComponentPtr, Partition_Component>(viewer, polyhedron_ptr);

        QApplication::setOverrideCursor(Qt::WaitCursor);

        component_ptr->faceLabelToColorMap();
        viewer->recreateListsAndUpdateGL();

        mw->statusBar()->showMessage(tr("face label to color map...done"));
        QApplication::restoreOverrideCursor();
    }
}
Exemple #14
0
int main( int argc, char** argv ) {

  // create viewer
  Viewer viewer = Viewer();

  // defined a user space renderer
  Renderer* renderer = new TextDrawer();

  // set user space renderer
  viewer.set_renderer(renderer);

  // start the viewer
  viewer.init();
  viewer.start();

  return 0;
}
Exemple #15
0
int main(int argc, char** argv)
{
  QApplication application(argc,argv);

  Viewer viewer;

#if QT_VERSION < 0x040000
  // Set the viewer as the application main widget.
  application.setMainWidget(&viewer);
#else
  viewer.setWindowTitle("select");
#endif

  viewer.show();

  return application.exec();
}
Exemple #16
0
/**
 * Quit if viewer was closed.
 */
void check_quit() {
#ifdef USE_GUI
  if (viewer.exit_requested()) {
    cout << endl << "Aborted by user..." << endl;
    exit(0);
  }
#endif
}
Exemple #17
0
/**
 * Everything starts here.
 */
int main(int argc, char* argv[]) {

  tic("all");

  process_arguments(argc, argv);

  cout << intro;

  if (!prop.quiet) {
    cout << "Reading " << fname;
    if (parse_num_lines > 0) {
      cout << " (only " << parse_num_lines << " lines)";
    }
    cout << endl;
  }
  // parse all data and get into suitable format for incremental processing
  Loader loader_(fname, parse_num_lines, prop.verbose);
  loader = &loader_;
  if (!prop.quiet) {
    loader_.print_stats();
    cout << endl;
  }

  if (!prop.quiet) {
    if (batch_processing) {
      cout << "Performing SAM (batch processing)\n";
    } else {
      cout << "Performing iSAM with parameters:\n";
      cout << "  Draw/send every " << mod_draw << " steps\n";
      cout << "  Update every " << prop.mod_update << " steps\n";
      cout << "  Solve every " << prop.mod_solve << " steps\n";
      cout << "  Batch every " << prop.mod_batch << " steps\n";
    }
    cout << endl;
  }

#ifdef USE_GUI
  if (use_gui) {
    cout << "3D viewer:\n";
    cout << "  Exit: Esc or \"q\"\n";
    cout << "  Reset view: \"r\"\n";
    cout << "  Toggle background color \"c\"\n";
    cout << "  Rotate: left mouse button\n";
    cout << "  Translate: middle mouse button or CTRL+left mouse button\n";
    cout << "  Scale: right mouse button or SHIFT+left mouse button or mouse wheel\n";
    cout << endl;
    // process will be run in separate thread
    viewer.init(process);
  } else {
    process(NULL);
  }
#else
  // no threads needed, simply run process
  process(NULL);
#endif

  return 0;
}
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();
}
int
main(int argc, char * argv[])
{
  if (argc < 2)
    return usage(argc, argv);

  std::string in_path = argv[1];

  long target_num_faces = -1;
  std::string out_path;
  if (argc >= 3)
  {
    target_num_faces = std::atoi(argv[2]);

    if (argc >= 4)
      out_path = argv[3];
  }

  Mesh mesh;
  if (!mesh.load(in_path))
    return -1;

  DGP_CONSOLE << "Read mesh '" << mesh.getName() << "' with " << mesh.numVertices() << " vertices, " << mesh.numEdges()
              << " edges and " << mesh.numFaces() << " faces from " << in_path;

  if (target_num_faces >= 0 && mesh.numFaces() > target_num_faces)
  {
    mesh.decimateQuadricEdgeCollapse(target_num_faces);
    mesh.updateBounds();
  }

  if (!out_path.empty())
  {
    if (!mesh.save(out_path))
      return -1;

    DGP_CONSOLE << "Saved mesh to " << out_path;
  }

  Viewer viewer;
  viewer.setObject(&mesh);
  viewer.launch(argc, argv);

  return 0;
}
void mepp_component_Compression_Valence_plugin::OnMouseWheel(QWheelEvent *event)
{
	if (mw->activeMdiChild() != 0)
	{
		Viewer* viewer = (Viewer *)mw->activeMdiChild();
		PolyhedronPtr polyhedron_ptr = viewer->getScenePtr()->get_polyhedron();

		if (doesExistComponentForViewer<Compression_Valence_ComponentPtr, Compression_Valence_Component>(viewer, polyhedron_ptr)) // important !!!
		{
			int rot = event->delta();

			if (rot<0)
				OnMouseLeftUp(NULL);	// todo: NULL
			else
				OnMouseRightUp(NULL);	// todo: NULL
		}
	}
}
Exemple #21
0
int main(int argc, char** argv)
{
  QApplication application(argc,argv);

  // Set the default OpenGL format with stereo capabilities.
  // An alternative is to pass this parameter to the QGLWidget constructor.
  QGLFormat format;
  format.setStereo(true);
  QGLFormat::setDefaultFormat(format);

  Viewer viewer;

  viewer.setWindowTitle("stereoViewer");

  viewer.show();

  return application.exec();
}
void mepp_component_CGAL_Example_plugin::step4()
{
	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);
		
		component_ptr->set_init(3);
		viewer->updateGL();
	}

	QApplication::restoreOverrideCursor();
}
void mepp_component_CGAL_Example_plugin::OnMouseWheel(QWheelEvent *event)
{
	if (mw->activeMdiChild() != 0)
	{
		Viewer* viewer = (Viewer *)mw->activeMdiChild();
		PolyhedronPtr polyhedron_ptr = viewer->getScenePtr()->get_polyhedron();

		if (doesExistComponentForViewer<CGAL_Example_ComponentPtr, CGAL_Example_Component>(viewer, polyhedron_ptr)) // important !!!
		{
			int rot = event->delta();

			if (rot<0)
				mw->statusBar()->showMessage(tr("mepp_component_CGAL_Example_plugin: OnMouseWheel Up"), 1000);
			else
				mw->statusBar()->showMessage(tr("mepp_component_CGAL_Example_plugin: OnMouseWheel Down"), 1000);
		}
	}
}
void mepp_component_Boolean_Operations_plugin::Subdiviser()
{
    QApplication::setOverrideCursor(Qt::WaitCursor);

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

        Boolean_Operations_ComponentPtr component_ptr = findOrCreateComponentForViewer<Boolean_Operations_ComponentPtr, Boolean_Operations_Component>(viewer, polyhedron_ptr);
        component_ptr->SubdiviserPolyedre(polyhedron_ptr);

        viewer->recreateListsAndUpdateGL();
    }

    QApplication::restoreOverrideCursor();
}
Exemple #25
0
int main( int argc, char** argv )
{
   if( argc != 2 )
   {
      cerr << "usage: " << argv[0] << " in.obj" << endl;
      return 1;
   }

   Viewer viewer;
   viewer.mesh.read( argv[1] );
   viewer.mesh.init();
   
   DirectionField field;
   field.generate( viewer.mesh, viewer.angle );
   
   viewer.init();

   return 0;
}
Exemple #26
0
void Correspondence::draw(Viewer &viewer, double radius)
{
	// draw the edge plane
	viewer.drawEdgePlaneDetails(p,Vec3d(0,0,0),Quaternion(),radius,2,6); // color by camera ID

	// draw the 3D line
	if (l == NULL)
		return;

	viewer.drawLine(l->_a->getPosition(),l->_b->getPosition(),PINK,6); // color by camera ID

	// for debug info, draw the projection line in yellow
	double lambda;
	Vec3d m = intersectRayPlane(l->_a->getPosition(),p._normal,p._s,p._normal,lambda);
	viewer.drawLine(l->_a->getPosition(),m,YELLOW,3);
	m = intersectRayPlane(l->_b->getPosition(),p._normal,p._s,p._normal,lambda);
	viewer.drawLine(l->_b->getPosition(),m,YELLOW,3);
	double distance = p.distance(l);
}
Exemple #27
0
void CBDS::parseViewerData(const QVariantList &data)
{
    Viewer def("def");
    QList<Viewer*> list;
    bool ownerset = false;
    for (auto i = data.constBegin(); i != data.constEnd(); ++i)
    {
        QVariantMap o = (*i).toMap();
        Viewer *v = new Viewer(o.value("name").toString(), o.value("tipped", def.getTipped()).toInt(), o.value("fanclub", def.isFanclubmember()).toBool(), o.value("mod", def.isModerator()).toBool(), o.value("hastokens", def.hasTokens()).toBool(), o.value("gender", def.getGender()).toString().at(0).toLatin1());
        if (o.value("roomowner", false).toBool())
        {
            if (!ownerset)
            {
                v->setRoomOwner(true);
                setRoomOwner(v->getName());
                ownerset = true;
            }
            else
                emit error(QString("Can't have more than 1 room owner. Owner: \"%1\" second: \"%2\"").arg(m_roomowner, v->getName()));
        }
        list << v;
    }

    if (!ownerset && !list.isEmpty())
    {
        list.first()->setRoomOwner(true);
        setRoomOwner(list.first()->getName());
        emit error("No Viewer is set as the room owner. Automatically set \"" + list.first()->getName() + "\" as the owner.");
    }

    m_viewers.populate(list);
    for (auto i = list.constBegin(); i != list.constEnd(); ++i)
    {
        if ((*i)->parent())
            connectViewer((*i));
        else
        {
            emit error("Can't add \"" + (*i)->getName() + "\". Name already exists or is reserved.");
            (*i)->deleteLater();
        }
    }
}
Exemple #28
0
int main( int argc, char **argv )
{
   if( argc < 3 || argc > 4 )
   {
      cerr << "usage: " << argv[0] << " mesh.obj image.tga [result.obj]" << endl;
      return 1;
   }

   if( argc == 4 ) // batch mode
   {
      // load mesh
      Mesh mesh;
      mesh.read( argv[1] );

      // load image
      Image image;
      image.read( argv[2] );

      // apply transformation
      const double scale = 5.;
      mesh.setCurvatureChange( image, scale );
      mesh.updateDeformation();

      // write result
      mesh.write( argv[3] );
   }
   else // interactive mode
   {
      Viewer viewer;

      // load mesh
      viewer.mesh.read( argv[1] );

      // load image
      viewer.image.read( argv[2] );

      // start viewer
      viewer.init();
   }

   return 0;
}
Exemple #29
0
void folding(Vector source, Vector destination)
{
	// Origami.listVertex();
	// printf("\n");

	// source.print();
	View.world2window( source, Cursor3D.x, Cursor3D.y, Cursor3D.z );

	Line line = View.cursorLine( Cursor3D.x, Cursor3D.y );
	// line.print();
	source = Origami.pickVertex( line );

	glutWarpPointer( Cursor3D.x, Cursor3D.y );
	// destination.print();
	// printf("\n");

	Origami.moveVertex( destination, View.eyePosition(), false);
	View.world2window( destination, Cursor3D.x, Cursor3D.y, Cursor3D.z );
	Origami.releaseVertex();
}
void mepp_component_CGAL_Example_plugin::pre_draw_all_scene()
{
	// active viewer
	//if (mw->activeMdiChild() != 0)
	{
		Viewer* viewer = (Viewer *)mw->activeMdiChild();
		PolyhedronPtr polyhedron_ptr = viewer->getScenePtr()->get_polyhedron();

		if (doesExistComponentForViewer<CGAL_Example_ComponentPtr, CGAL_Example_Component>(viewer, polyhedron_ptr)) // important !!!
		{
			CGAL_Example_ComponentPtr component_ptr = findOrCreateComponentForViewer<CGAL_Example_ComponentPtr, CGAL_Example_Component>(viewer, polyhedron_ptr);
			if (component_ptr->get_init() == 3)
			{
				glPushMatrix();
					// here your code
				glPopMatrix();
			}
		}
	}
}