void Scene_polyhedron_shortest_path_item::initialize(Scene_polyhedron_item* polyhedronItem, Scene_interface* sceneInterface, Messages_interface* messages, QMainWindow* mainWindow) { this->m_mainWindow = mainWindow; this->m_messages = messages; this->poly_item = polyhedronItem; this->m_sceneInterface = sceneInterface; connect(polyhedronItem, SIGNAL(item_is_about_to_be_changed()), this, SLOT(poly_item_changed())); QGLViewer* viewer = *QGLViewer::QGLViewerPool().begin(); viewer->installEventFilter(this); m_mainWindow->installEventFilter(this); recreate_shortest_path_object(); }
Scene_edit_polyhedron_item::Scene_edit_polyhedron_item (Scene_polyhedron_item* poly_item, Ui::DeformMesh* ui_widget, QMainWindow* mw) : Scene_item(NumberOfBuffers,NumberOfVaos), ui_widget(ui_widget), poly_item(poly_item), is_rot_free(true), own_poly_item(true), k_ring_selector(poly_item, mw, Scene_polyhedron_item_k_ring_selection::Active_handle::VERTEX, true) { nb_ROI = 0; nb_sphere = 0; nb_control = 0; nb_axis = 0; nb_bbox = 0; mw->installEventFilter(this); // bind vertex picking connect(&k_ring_selector, SIGNAL(selected(const std::set<Polyhedron::Vertex_handle>&)), this, SLOT(selected(const std::set<Polyhedron::Vertex_handle>&))); poly_item->set_color_vector_read_only(true); // to prevent recomputation of color vector in invalidateOpenGLBuffers() poly_item->update_vertex_indices(); deform_mesh = new Deform_mesh(*(poly_item->polyhedron()), Deform_mesh::Vertex_index_map(), Deform_mesh::Hedge_index_map(), Array_based_vertex_point_map(&positions)); length_of_axis = bbox().diagonal_length() / 15.0; // interleave events of viewer (there is only one viewer) QGLViewer* viewer = *QGLViewer::QGLViewerPool().begin(); viewer->installEventFilter(this); // create an empty group of control vertices for starting create_ctrl_vertices_group(); // start QObject's timer for continuous effects // (deforming mesh while mouse not moving) startTimer(0); // Required for drawing functionality reset_drawing_data(); //Generates an integer which will be used as ID for each buffer const char vertex_shader_source_bbox[] = { "#version 120 \n" "attribute highp vec3 vertex; \n" "attribute highp vec3 colors; \n" "uniform highp mat4 mvp_matrix; \n" "uniform highp mat4 rotations; \n" "uniform highp vec3 translation; \n" "uniform highp vec3 translation_2; \n" "varying highp vec3 fColors; \n" " \n" "void main(void) \n" "{ \n" " fColors = colors; \n" " gl_Position = mvp_matrix * (rotations *(vec4(translation_2,0.0)+vec4(vertex,1.0) )+ vec4(translation,0.0)) ; \n" "} \n" }; const char fragment_shader_source[]= { "#version 120 \n" "varying vec3 fColors; \n" " \n" "void main(void) \n" "{ \n" " gl_FragColor = vec4(fColors, 1.0); \n" "} \n" }; bbox_program.addShaderFromSourceCode(QOpenGLShader::Vertex,vertex_shader_source_bbox); bbox_program.addShaderFromSourceCode(QOpenGLShader::Fragment,fragment_shader_source); bbox_program.link(); ui_widget->remeshing_iterations_spinbox->setValue(1); ui_widget->remeshing_edge_length_spinbox->setValue(length_of_axis); ui_widget->remeshing_edge_length_spinbox->setDisabled(true); ui_widget->remeshingEdgeLengthInput_checkBox->setChecked(false); connect(ui_widget->remeshingEdgeLengthInput_checkBox, SIGNAL(toggled(bool)), ui_widget->remeshing_edge_length_spinbox, SLOT(setEnabled(bool))); //the spheres : create_Sphere(length_of_axis/15.0); invalidateOpenGLBuffers(); }