Commit 207abbe0 authored by Olivier Lagrasse's avatar Olivier Lagrasse

Commit d'une structure info

parent bb37e391
/*!
*\file info.hpp
*/
#ifndef INFO_HPP
#define INFO_HPP
struct Info;
#include "resource.hpp"
/*!
* \brief Class used to store informations.
*
* Info class uses static attributes to share informations between ViTE modules. This class cannot be instantiate thus its constructor has a private scope.
*/
class Info{
private:
/*!
* \brief The class constructor.
*/
Info();
public:
/*!
* \brief The class destructor.
*/
virtual ~Info();
/*!
* \brief Sub structure to store container informations.
*/
static struct Container{
/*!
* \brief Minimum x position.
*/
static int x_min;
/*!
* \brief Maximum x position.
*/
static int x_max;
};
/*!
* \brief Sub structure to store state informations.
*/
static struct Entity{
/*!
* \brief Minimum x position.
*/
static int x_min;
/*!
* \brief Maximum x position.
*/
static int x_max;
};
};
#endif
......@@ -405,6 +405,8 @@ void Interface_graphic::on_zoom_box_textChanged(QString s){
if (-1 != reg_exp_number.indexIn(s)){/* match a number */
result = reg_exp_number.cap(1);/* capture number inside parenthesis in the RegExp */
d = 0.01*result.toDouble();
if (0 == d)/* if zoom is null ignore it */
return;
_core->launch_action(Interface_console::_STATE_RENDER_AREA_REPLACE_SCALE, &d);
}else if (QString("Entire") == s){
/* Display the whole trace */
......
......@@ -104,6 +104,8 @@ Render_opengl::Render_opengl(QWidget *parent)
_state_scale = 1;/* for states scaling */
_state_translate = 0;/* for states translation */
_y_state_scale = 1;/* for states scaling */
_y_state_translate = 0;/* for states translation */
_x_scroll_pos = 0;/* horizontal bar placed on 0 */
/* Camera is placed on (0,0,0) and looks to (0,0,-1) */
......@@ -250,15 +252,16 @@ void Render_opengl::paintGL(){
case DRAWING_STATE_DRAWING:/* A trace is drawn */
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPushMatrix();
{
static float a = 0;
a ++;
glTranslated(0.0, _render_height, 100.0);
glRotated(180.0, 1.0, 0.0, 0.0);
......@@ -349,7 +352,7 @@ void Render_opengl::paintGL(){
glTranslated( _default_entity_x_translate - _state_translate , 0.0f, _z_state);
glScalef(_state_scale*((_render_width-_default_entity_x_translate)/(_state_x_max-_state_x_min)), (_render_height-_rule_height)/_container_y_max, 0.0f);
glScalef(_state_scale*((_render_width-_default_entity_x_translate)/(_state_x_max-_state_x_min)), _y_state_scale*(_render_height-_rule_height)/_container_y_max, 0.0f);
......@@ -364,7 +367,7 @@ void Render_opengl::paintGL(){
glPushMatrix();
glTranslated(_default_entity_x_translate - _state_translate , 0.0f, _z_counter);
glScalef(_state_scale*((_render_width-_default_entity_x_translate)/(_state_x_max-_state_x_min)), (_render_height-_rule_height)/_container_y_max, 0.0f);
glScalef(_state_scale*((_render_width-_default_entity_x_translate)/(_state_x_max-_state_x_min)), _y_state_scale*(_render_height-_rule_height)/_container_y_max, 0.0f);
if (glIsList(_list_counters) == GL_FALSE) {
message << "ERROR LIST not exist for counters." << Message::ende;
......@@ -387,10 +390,13 @@ void Render_opengl::paintGL(){
}
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPushMatrix();
{
glTranslated(0.0, _container_y_max- 3*_rule_height, 100.0);/* not accurate */
// glTranslated(0.0, _container_y_max- 3*_rule_height, 100.0);/* not accurate */
glTranslated(0.0, 0.0, 100.0);/* not accurate */
if (true==_mouse_pressed){
......@@ -400,10 +406,10 @@ void Render_opengl::paintGL(){
Element_pos old_x, old_y, new_x, new_y;
old_x = _mouse_x*(_render_width/_screen_width);
old_y = _container_y_max - _mouse_y*(_render_height/_screen_height);
old_y = _render_height - _mouse_y*(_render_height/_screen_height);
new_x = _new_mouse_x*(_render_width/_screen_width);
new_y = _container_y_max - _new_mouse_y*(_render_height/_screen_height);
new_y = _render_height - _new_mouse_y*(_render_height/_screen_height);
#ifdef DEBUG_MODE_RENDER_OPENGL
cerr << __FILE__ << " l." << __LINE__ << ":" << endl;
......@@ -525,6 +531,7 @@ void Render_opengl::mouseMoveEvent(QMouseEvent * event){
void Render_opengl::mouseReleaseEvent(QMouseEvent * event){
Element_pos x_middle_selection;
Element_pos y_middle_selection;
if ( ((_new_mouse_x-_mouse_x) < _minimum_distance_for_selection)
......@@ -549,7 +556,8 @@ void Render_opengl::mouseReleaseEvent(QMouseEvent * event){
* Note: mouse positions are converted to render area coordinate with the coeff _render_width/_screen_width.
*/
x_middle_selection = (_mouse_x + (_new_mouse_x - _mouse_x)/2 )*(_render_width/_screen_width);
y_middle_selection = (_mouse_y + (_new_mouse_y - _mouse_y)/2 )*(_render_height/_screen_height);
/*
* Translate entities.
*
......@@ -563,12 +571,13 @@ void Render_opengl::mouseReleaseEvent(QMouseEvent * event){
* and S = _screen_width/(_new_mouse_x - _mouse_x) -> scale between the selection rectangle width and the widget width.
*/
_state_translate += (x_middle_selection + _state_translate - _default_entity_x_translate)*( _screen_width/(_new_mouse_x - _mouse_x) - 1);
// _y_state_translate += (y_middle_selection + _y_state_translate - _rule_height)*( _screen_height/(_new_mouse_y - _mouse_y) - 1);
/*
* Finally, perform the scale.
*/
_state_scale *= _screen_width/(_new_mouse_x - _mouse_x);
// _y_state_scale *= _screen_height/(_new_mouse_y - _mouse_y);
_mouse_pressed = false;
......@@ -673,7 +682,9 @@ void Render_opengl::replace_translate(Element_pos new_translate){
}else if (-2 == new_translate){/* show the entire trace */
_state_translate = 0;
_y_state_translate = 0;
_state_scale = 1;
_y_state_scale = 1;
}else{/* Default, just replace the current translate the by new_translate value */
_state_translate = new_translate;
......
......@@ -430,11 +430,21 @@ class Render_opengl : public QGLWidget, public Render
*/
Element_pos _state_scale;
/*!
* \brief the y scale of state drawing.
*/
Element_pos _y_state_scale;
/*!
* \brief The x position of camera view for state drawing area.
*/
Element_pos _state_translate;
/*!
* \brief The y position of camera view for state drawing area.
*/
Element_pos _y_state_translate;
/*!
* \brief The x position of the horizontal scroll bar.
*/
......@@ -837,7 +847,7 @@ inline void Render_opengl::draw_stored_arrows(std::vector<Arrow_> &arrows){
/* Manage the event drawing size from state size and render area dimensions */
Element_pos arrow_scale_x = _state_scale*((_render_width-_default_entity_x_translate)/(_state_x_max-_state_x_min));
Element_pos arrow_scale_y = (_render_height-_rule_height)/_container_y_max;
Element_pos arrow_scale_y = _y_state_scale*(_render_height-_rule_height)/_container_y_max;
Element_pos angle;
......@@ -917,7 +927,7 @@ inline void Render_opengl::draw_stored_events(std::vector<Event_> &events){
/* Manage the event drawing size from state size and render area dimensions */
Element_pos event_scale_x = _state_scale*((_render_width-_default_entity_x_translate)/(_state_x_max-_state_x_min));
Element_pos event_scale_y = (_render_height-_rule_height)/_container_y_max;
Element_pos event_scale_y = _y_state_scale*(_render_height-_rule_height)/_container_y_max;
Element_pos radius;/* the circle radius */
Element_pos angle;
......
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