Commit 40c633d1 authored by Thibault Soucarre's avatar Thibault Soucarre

Links can be rendered with differents type of head : triangles, points or no...

Links can be rendered with differents type of head : triangles, points or no head. It can be chosen in the settings menu.
parent 6f337793
......@@ -76,7 +76,7 @@ Element_pos Info::Render::_x_max = 0.0;
Element_pos Info::Render::_info_x = 0.0;
Element_pos Info::Render::_info_y = 0.0;
Element_pos Info::Render::_info_accurate = 0.0;
int Info::Render::_arrows_shape = 0;
bool Info::Render::_no_arrows = false;
bool Info::Render::_no_events = false;
bool Info::Render::_shaded_states = Session::getSession().get_shaded_states_setting();
......
......@@ -174,6 +174,12 @@ public:
*/
static bool _key_ctrl;
/*!
* \brief Specify the shape of arrows heads. 0 is triangle, 1 is a point and 2 is none.
*/
static int _arrows_shape;
/*!
* \brief Prevent arrows to be displayed (used with Display List since it should highly decreased performance).
*/
......
......@@ -964,7 +964,9 @@ void Interface_graphic::on_no_warning_triggered(){
Session::update_hide_warnings_settings(_no_warning);
}
void Interface_graphic::on_no_arrows_triggered(){
std::cout << "no_arrows triggered" << std::endl;
Info::Render::_no_arrows = !Info::Render::_no_arrows;
_core->launch_action(Core::_STATE_RENDER_UPDATE);
}
......
......@@ -645,7 +645,7 @@ protected slots:
*/
void on_reload_from_file_triggered();
/*!
/*!
*\brief A slot called when 'no_arrows' in the menu is clicked.
*/
void on_no_arrows_triggered();
......
......@@ -62,6 +62,8 @@
/* -- */
#include "common/Palette.hpp"
#include "common/Session.hpp"
#include "common/common.hpp"
#include "common/Info.hpp"
/* -- */
#include "interface/Interface.hpp"
#include "core/Core.hpp"
......@@ -680,3 +682,9 @@ void Settings_window::on_ok_clicked(){
on_apply_clicked();
hide();
}
void Settings_window::on_pointe_currentIndexChanged(int index){
std::cout << "Slot pointe appelé" << std::endl;
Info::Render::_arrows_shape = index;
//_core->launch_action(Core::_STATE_RENDER_UPDATE);
}
......@@ -322,6 +322,12 @@ private slots:
*/
void on_use_palette_cb_stateChanged();
/*!
*\brief A slot called when 'arrows_shape' in the menu is modified
*/
void on_pointe_currentIndexChanged(int index);
signals:
void settings_changed();
};
......
This diff is collapsed.
......@@ -6,13 +6,13 @@
** use, modify and/or redistribute the software under the terms of the
** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following
** URL: "http://www.cecill.info".
**
**
** As a counterpart to the access to the source code and rights to copy,
** modify and redistribute granted by the license, users are provided
** only with a limited warranty and the software's author, the holder of
** the economic rights, and the successive licensors have only limited
** liability.
**
**
** In this respect, the user's attention is drawn to the risks associated
** with loading, using, modifying and/or developing or reproducing the
** software by the user in light of its specific status of free software,
......@@ -23,7 +23,7 @@
** their requirements in conditions enabling the security of their
** systems and/or data to be ensured and, more generally, to use and
** operate it in the same conditions as regards security.
**
**
** The fact that you are presently reading this means that you have had
** knowledge of the CeCILL-A license and that you accept its terms.
**
......@@ -37,7 +37,7 @@
** - MARCOUEILLE Jule
** - NOISETTE Pascal
** - REDONDY Arthur
** - VUCHENER Clément
** - VUCHENER Clément
**
*/
......@@ -66,7 +66,7 @@ private:
std::vector<Plugin *> _plugins;
int _current_index;
Core *_core;
QStringList _plugin_directories;
public:
......
......@@ -246,26 +246,41 @@ void Render_alternate::paintGL(){
_modelview = glm::rotate(_modelview, (float) _links[4*i], glm::vec3(0,0,1));
_modelview = glm::scale(_modelview, glm::vec3(_links[4*i+1], _links[4*i+1/10], 1));*/
//draw the arrow
mvp = _projection * _modelview;
glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "MVP"), 1, GL_FALSE, glm::value_ptr(mvp));
mvp = _projection * _modelview;
glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "MVP"), 1, GL_FALSE, glm::value_ptr(mvp));
//glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "modelview"), 1, GL_FALSE, glm::value_ptr(_modelview));
//glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "projection"), 1, GL_FALSE, glm::value_ptr(_projection));
glDrawArrays(GL_LINES, 0, _arrows.getNbVertex());
glDrawArrays(GL_LINES, 0, _arrows.getNbVertex());
//_modelview = tmp2;
//}
_arrows.unlock();
_arrows2.lock();
//_modelview = glm::scale(_modelview, glm::vec3(1/_x_state_scale, 1/_y_state_scale, 1));
//tmp2 = _modelview;
//for(int i=0; i<n ; i++) {
//_modelview = glm::translate(_modelview, glm::vec3(_x_state_scale*_links[4*i+2], _y_state_scale*_links[4*i+3], 0));
// _modelview = glm::rotate(_modelview, (float) _links[4*i], glm::vec3(0,0,1));
// mvp = _projection * _modelview;
// glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "MVP"), 1, GL_FALSE, glm::value_ptr(mvp));
glDrawArrays(GL_TRIANGLES, 0, _arrows2.getNbVertex());
int n = _links.size()/4;
switch(Info::Render::_arrows_shape){
case 0: //triangles
_arrows3.lock();
_modelview = glm::scale(_modelview, glm::vec3(1/_x_state_scale, 1/_y_state_scale, 1));
tmp2 = _modelview;
for(int i=0; i<n ; i++) {
_modelview = glm::translate(_modelview, glm::vec3(_x_state_scale*_links[4*i+2], _y_state_scale*_links[4*i+3], 0));
_modelview = glm::rotate(_modelview, (float) _links[4*i], glm::vec3(0,0,1));
mvp = _projection * _modelview;
glUniformMatrix4fv(glGetUniformLocation(_shader.getProgramID(), "MVP"), 1, GL_FALSE, glm::value_ptr(mvp));
glDrawArrays(GL_TRIANGLES, 0, _arrows3.getNbVertex());
_modelview = tmp2;
}
_arrows3.unlock();
// _modelview = tmp2;
//}
_arrows2.unlock();
_arrows2.unlock();
break;
case 1: //points
_arrows2.lock();
glDrawArrays(GL_POINTS, 0, _arrows2.getNbVertex());
_arrows2.unlock();
break;
default: //no head
break;
}
_modelview = tmp;
//_arrows.unlock();
//restore matrix with changes needed for all links
......@@ -818,7 +833,7 @@ void Render_alternate::draw_arrow(const Element_pos start_time, const Element_po
l = sqrt(pow(x1-x0,2)+pow(y1-y0,2));
//calculate angle beetween arrow and horizontal axe
cosa = (x1-x0)/l;
sina = (y0-y1)/l;
sina = (y1-y0)/l;
alpha = acos(cosa);
if(sina<0) alpha*= -1;
Element_pos cos30 = cos(PI/6.0);
......@@ -829,12 +844,12 @@ void Render_alternate::draw_arrow(const Element_pos start_time, const Element_po
_arrows.add(x1, y1, 1, 1, 1);
//_arrows2.add(x1, y1, 1, 1, 1);
_arrows2.add(x1, y1, 1, 1, 1);
_arrows2.add(x1 - cosa*cos30 - sina*sin30,
y1 + sina*cos30 - cosa*sin30,
1, 1, 1);
_arrows2.add(x1 - cosa*cos30 + sina*sin30,
y1 + sina*cos30 + cosa*sin(30),
1, 1, 1);
//_arrows2.add(x1 - cosa*cos30 - sina*sin30,
// y1 + sina*cos30 - cosa*sin30,
// 1, 1, 1);
//_arrows2.add(x1 - cosa*cos30 + sina*sin30,
// y1 + sina*cos30 + cosa*sin(30),
//1, 1, 1);
/*glm::mat4 m(1.0);
m = glm::translate(m, glm::vec3(x0, y0, 0));
m = glm::rotate(m, alpha, glm::vec3(0,0,1));
......@@ -855,19 +870,19 @@ void Render_alternate::draw_arrow(const Element_pos start_time, const Element_po
_arrows2.add(v4.x, v4.y, 1, 1, 1);
_arrows.add(x0, y0, 0, 1, 1);
_arrows.add(x1, y1, 0, 1, 1);*/
//_links.push_back(alpha);
//_links.push_back(l);
//_links.push_back(x1);
//_links.push_back(y1);
_links.push_back(alpha);
_links.push_back(l);
_links.push_back(x1);
_links.push_back(y1);
//_arrows.add(x0, y0, 1, 1, 1);
//_arrows.add(x1, y1, 1, 1, 1);
}
void Render_alternate::end_draw_arrows(){
//coordinates that we use for all arrows, we will change the angle and scale of using the modelview matrix
//_arrows2.add(0,0,1,1,1);
//_arrows2.add(-1.2, -0.4, 1, 1, 1);
//_arrows2.add(-1.2, 0.4, 1, 1, 1);
_arrows3.add(0,0,1,1,1);
_arrows3.add(-1.2, -0.4, 1, 1, 1);
_arrows3.add(-1.2, 0.4, 1, 1, 1);
//_arrows.add(0,0,1,1,1);
//_arrows.add(-1,0,1,1,1);
//_arrows.add(0,0,1,1,1);
......@@ -877,6 +892,7 @@ void Render_alternate::end_draw_arrows(){
//_arrows.add(cos(PI/8), sin(PI/8), 1, 1, 1);
_arrows.config();
_arrows2.config();
_arrows3.config();
_draw_arrow = false;
cout << "end_draw_arrows " << _links.size() << endl;
}
......
......@@ -116,6 +116,7 @@ private:
Vbo _events2;
Vbo _arrows;
Vbo _arrows2;
Vbo _arrows3;
Vbo _counters;
Vbo _ruler;
Vbo *_current;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment