Skip to content

Commit

Permalink
minor refactor and clean-up on Main_widget
Browse files Browse the repository at this point in the history
  • Loading branch information
denizdiktas committed Aug 18, 2023
1 parent 498778d commit a323352
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
18 changes: 7 additions & 11 deletions Arrangement_on_surface_2/demo/earth/Main_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,9 @@ void Main_widget::initializeGL()
}

//qDebug() << "num triangles = " << triangle_points.size() / 3;
//m_all_triangles = std::make_unique<Triangles>(triangle_points);
//m_gr_all_triangles = std::make_unique<Triangles>(triangle_points);
}




initializeOpenGLFunctions();

Expand Down Expand Up @@ -214,10 +212,10 @@ void Main_widget::init_country_borders(float error)
{
// this part does the same as the code below but using arrangement!
// NOTE: the old code interferes with some logic (NEEDS REFACTORING!!!)
m_gr_country_borders.clear();
m_gr_all_country_borders.reset(nullptr);
qDebug() << "approximating the arcs of each edge of all faces..";
auto all_approx_arcs = Aos::get_approx_arcs_from_faces_edges(m_arrh, error);
m_gr_all_approx_arcs = std::make_unique<Line_strips>(all_approx_arcs);
m_gr_all_country_borders = std::make_unique<Line_strips>(all_approx_arcs);
}


Expand Down Expand Up @@ -333,7 +331,7 @@ void Main_widget::paintGL()
//sp.set_uniform("u_color", face_color);
sp.set_uniform("u_plane", plane);
//glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
//m_all_triangles->draw();
//m_gr_all_triangles->draw();
for (auto& [country_name, country] : m_gr_country_triangles)
{
sp.set_uniform("u_color", country->get_color());
Expand All @@ -342,7 +340,7 @@ void Main_widget::paintGL()

//sp.set_uniform("u_color", QVector4D(0,0,0,1));
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
//m_all_triangles->draw();
//m_gr_all_triangles->draw();
}

sp.unuse();
Expand Down Expand Up @@ -376,12 +374,10 @@ void Main_widget::paintGL()
sp.set_uniform("u_color", QVector4D(0, 1, 1, 1));
m_gr_identification_curve->draw();

// draw all countries
// draw all countries' borders
float a = 0.0;
sp.set_uniform("u_color", QVector4D(a, a, a, 1));
//for(auto& country_border : m_country_borders)
// country_border->draw();
m_gr_all_approx_arcs->draw();
m_gr_all_country_borders->draw();

// MOUSE VERTEX
{
Expand Down
29 changes: 15 additions & 14 deletions Arrangement_on_surface_2/demo/earth/Main_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,34 +83,32 @@ class Main_widget : public QOpenGLWidget, protected OpenGLFunctionsBase
private:
// COUNTRY ARRANGEMENT SPECIFIC DATA
Aos::Arr_handle m_arrh;
std::unique_ptr<Line_strips> m_gr_all_approx_arcs;
std::unique_ptr<Line_strips> m_gr_all_country_borders;

// used when dimming / highlighting selected countries
const float m_dimming_factor = 0.4;

// GUI: event handler for picking with right mouse button
std::unique_ptr<GUI_event_handler> m_pick_handler;

// Objects in the scene
std::unique_ptr<Sphere> m_gr_sphere;
std::unique_ptr<World_coord_axes> m_gr_world_coord_axes;
std::unique_ptr<Line_strips> m_gr_geodesic_arcs;
//std::unique_ptr<Vertices> m_vertices;
std::unique_ptr<Line_strips> m_gr_identification_curve;

std::unique_ptr<GUI_event_handler> m_pick_handler;

// These are used to highlight the picked position by right-mouse click
QVector3D m_mouse_pos;
std::unique_ptr<SingleVertex> m_gr_mouse_vertex;

// COUNTRY DATA
std::vector<std::unique_ptr<Line_strips>> m_gr_country_borders;

// TRIANGLES for rendering the countries in solid
std::unique_ptr<Triangles> m_all_triangles;
std::map<std::string, std::unique_ptr<Triangles>> m_gr_country_triangles;
std::unique_ptr<Triangles> m_gr_all_triangles;
std::map<std::string, std::unique_ptr<Triangles>> m_gr_country_triangles;


// -------------------------------
// --> COMMON SETUP FOR ALL SCENES

// Basic objects in the scene
std::unique_ptr<Sphere> m_gr_sphere;
std::unique_ptr<World_coord_axes> m_gr_world_coord_axes;
std::unique_ptr<Line_strips> m_gr_identification_curve;

// Shaders
Shader_program m_sp_smooth;
Shader_program m_sp_per_vertex_color;
Expand All @@ -134,6 +132,9 @@ class Main_widget : public QOpenGLWidget, protected OpenGLFunctionsBase

// Timer for continuous screen-updates
QBasicTimer m_timer;

// <-- COMMON SETUP FOR ALL SCENES
// -------------------------------
};

#endif

0 comments on commit a323352

Please sign in to comment.