Mentions légales du service

Skip to content
Snippets Groups Projects
Commit e296d207 authored by Mathieu Faverge's avatar Mathieu Faverge
Browse files

Merge branch 'mv/color_blocks' into 'master'

Mv/color blocks

See merge request !6
parents 15b5b10c fcec3833
No related branches found
Tags V7-1
1 merge request!6Mv/color blocks
#include <assert.h>
#include <math.h>
#include "Zooming.hpp"
#include "../Helper.hpp"
......@@ -91,10 +92,10 @@ void Zooming::move(double xStart, double xEnd, double yStart, double yEnd)
int lbloknum = cblk[1].m_bloknum;
// Get first block size in col from x to xEnd
int x = (cblk->m_fcolnum - startCol) * xCoeff;
int xEnd = (cblk->m_lcolnum - startCol) * xCoeff;
int x = (cblk->m_fcolnum - startCol) * xCoeff;
int xEnd = (cblk->m_lcolnum + 1 - startCol) * xCoeff;
xEnd = ( xEnd > x+1 ) ? xEnd : x+1;
float cblk_color = cblk->m_color;
blok = m_matrix->m_bloktab + fbloknum;
for (j = fbloknum; j < lbloknum; ++j, blok++)
......@@ -106,16 +107,16 @@ void Zooming::move(double xStart, double xEnd, double yStart, double yEnd)
}
// Get first block size in row from y to yEnd
int y = (blok->m_frownum - startRow) * yCoeff;
int yEnd = (blok->m_lrownum - startRow) * yCoeff;
int y = (blok->m_frownum - startRow) * yCoeff;
int yEnd = (blok->m_lrownum + 1 - startRow) * yCoeff;
yEnd = ( yEnd > y+1 ) ? yEnd : y+1;
float color = blok->m_color == -1. ? cblk_color : blok->m_color;
for( m=x; m<xEnd; m++ )
{
for( n=y; n<yEnd; n++ )
{
m_colors[m][n] = 0.0f;
m_colors[m][n] = color;
}
}
}
......
......@@ -10,6 +10,7 @@ typedef struct symbol_cblk_s
int32_t m_lcolnum; // Last column index (inclusive)
int32_t m_bloknum; // First blok in column
int32_t m_flags; // Flags
float m_color;
} symbol_cblk_t;
typedef struct symbol_blok_s
......@@ -19,8 +20,9 @@ typedef struct symbol_blok_s
int32_t m_lcblknm; // Local column blok
int32_t m_fcblknm; // Facing column blok
uint32_t m_localization; // Localization
uint32_t m_localization; // Localization
int32_t m_flags;
float m_color;
} symbol_blok_t;
#define BLOK_FLAG_IN_TREE 1
......
......@@ -30,7 +30,7 @@ Matrix_visualizer::Matrix_visualizer() {
s_plugin = this;
// For windows dev (pc: orange)
this->line_edit_symbol->setText("/home/mathieu/1-PaStiX/pastix/build/pastix-JLjWM5/symbgen");
this->line_edit_symbol->setText("/home/mathieu/1-PaStiX/pastix/build/symbol_rank");
}
Matrix_visualizer::~Matrix_visualizer(){
......
......@@ -22,7 +22,7 @@ int pastix_read_symbol(FILE* stream, symbol_matrix_t* matrix)
matrix->m_sndenbr = matrix->m_cblknbr;
if ((result != 5) ||
(versval < 0) ||
(versval < -1) ||
(versval > 1) ||
(matrix->m_bloknbr < matrix->m_cblknbr) ||
(nodenbr < matrix->m_cblknbr))
......@@ -63,6 +63,7 @@ int pastix_read_symbol(FILE* stream, symbol_matrix_t* matrix)
return 1;
}
cblk->m_color = 0.f;
cblk->m_flags = 0;
*snde = 0;
}
......@@ -88,6 +89,22 @@ int pastix_read_symbol(FILE* stream, symbol_matrix_t* matrix)
blok->m_localization = 0;
blok->m_flags = 0;
if (versval == -1) {
int32_t rk, rkmax;
result = pastix_read_int(stream, &rk);
result += pastix_read_int(stream, &rkmax);
if (result != 2)
{
Helper::log(LogStatus::FATAL, "Bad input while reading blok %d ranks !", bloknum);
return 1;
}
blok->m_color = (double)(rkmax - rk) / (double)rkmax;
}
else {
blok->m_color = -1.f;
}
// Compatibility block
{
......@@ -105,17 +122,17 @@ int pastix_read_symbol(FILE* stream, symbol_matrix_t* matrix)
matrix->m_rowsnbr = nodenbr;
Helper::log(LogStatus::MESSAGE,
"Loaded header:\n"
" File Version: %10d\n"
" Number of cblk: %10d\n"
" Number of rows: %10d\n"
" Number of blok: %10d\n"
" Number of nodes: %10d\n"
" Base value: %10d\n",
versval,
matrix->m_cblknbr, matrix->m_rowsnbr,
matrix->m_bloknbr, nodenbr,
matrix->m_baseval
"Loaded header:\n"
" File Version: %10d\n"
" Number of cblk: %10d\n"
" Number of rows: %10d\n"
" Number of blok: %10d\n"
" Number of nodes: %10d\n"
" Base value: %10d\n",
versval,
matrix->m_cblknbr, matrix->m_rowsnbr,
matrix->m_bloknbr, nodenbr,
matrix->m_baseval
);
return 0;
......
......@@ -2,9 +2,9 @@
#include "MatrixWindow.hpp"
#define BACKGROUND_COLOR_R 0.2f
#define BACKGROUND_COLOR_G 0.2f
#define BACKGROUND_COLOR_B 0.2f
#define BACKGROUND_COLOR_R 0.9f
#define BACKGROUND_COLOR_G 0.9f
#define BACKGROUND_COLOR_B 0.9f
/* Helpers */
static void drawSquare(GLfloat x, GLfloat y, GLfloat dx, GLfloat dy, GLfloat r, GLfloat g, GLfloat b)
......@@ -40,25 +40,18 @@ static void drawTemporarySelection(int x, int y, int dx, int dy)
}
MatrixGLWidget::MatrixGLWidget(QWidget* parent, symbol_matrix_t* matrix, QLabel* label)
:
#ifdef USE_QT5
: QOpenGLWidget(parent)
QOpenGLWidget(parent)
#else
: QGLWidget(parent)
QGLWidget(parent)
#endif
, m_label(label)
, m_frameCount(0)
{
this->setFixedSize(MATRIX_WINDOW_LENGTH, MATRIX_WINDOW_HEIGHT);
m_zooming = new Zooming(matrix);
#ifdef USE_QT5
connect(&m_updateTimer, &QTimer::timeout, this, &MatrixGLWidget::updateTimer);
#else
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateTimer()));
#endif
m_updateTimer.start(1000 / 60);
m_zooming = new Zooming( matrix );
m_qtToGLWidthCoeff = 1.f;
m_qtToGLHeightCoeff = 1.f;
......@@ -139,8 +132,13 @@ void MatrixGLWidget::paintGL()
{
GLfloat grey = m_zooming->getColor(i, j);
if (grey != 0.f) {
drawSquare(i, j, 1, 1, grey, grey, grey);
if (grey != 1.f) {
if (grey != 0.f) {
drawSquare(i, j, 1, 1, 0., 0., grey);
}
else {
drawSquare(i, j, 1, 1, grey, grey, grey);
}
}
}
}
......@@ -152,13 +150,6 @@ void MatrixGLWidget::paintGL()
m_frameCount++;
}
void MatrixGLWidget::updateTimer()
{
// Need to do this because the connect function cannot
// differenciate overloaded cases of update
update();
}
void MatrixGLWidget::keyPressEvent(QKeyEvent *keyEvent)
{
switch (keyEvent->key())
......@@ -203,12 +194,15 @@ void MatrixGLWidget::mouseMoveEvent(QMouseEvent* mouseEvent)
m_tempSelectionY = m_mouseYClicked;
m_tempSelectionDx = glPosX - m_mouseXClicked;
m_tempSelectionDy = glPosY - m_mouseYClicked;
update();
}
}
void MatrixGLWidget::mouseReleaseEvent(QMouseEvent* mouseEvent)
{
if (m_mouseXClicked != -1 && m_mouseYClicked != -1)
if ( (m_mouseXClicked != -1) &&
(m_mouseYClicked != -1) )
{
int xmin, xmax, ymin, ymax;
int glPosX = mouseEvent->x() * m_qtToGLWidthCoeff;
......@@ -254,15 +248,17 @@ void MatrixGLWidget::mouseReleaseEvent(QMouseEvent* mouseEvent)
dX = dX * m_camera.m_cameraDx;
dY = dY * m_camera.m_cameraDy;
m_drawTempSelection = 0;
// Return if in the upper triangular part
if ( (Y + dY) < X )
{
update();
return;
}
// Position is valid, we save it
m_savedPositions.push(m_camera);
m_drawTempSelection = 0;
m_camera.m_cameraX = X;
m_camera.m_cameraY = Y;
......@@ -278,6 +274,7 @@ void MatrixGLWidget::mouseReleaseEvent(QMouseEvent* mouseEvent)
void MatrixGLWidget::refreshCamera()
{
m_zooming->move(m_camera.m_cameraX, m_camera.m_cameraX + m_camera.m_cameraDx,
m_camera.m_cameraY, m_camera.m_cameraY + m_camera.m_cameraDy);
m_zooming->move( m_camera.m_cameraX, m_camera.m_cameraX + m_camera.m_cameraDx,
m_camera.m_cameraY, m_camera.m_cameraY + m_camera.m_cameraDy );
update();
}
......@@ -52,14 +52,9 @@ private:
private:
void refreshCamera();
private slots:
/* Helpers */
void updateTimer();
private:
uint32_t m_frameCount;
QTime m_time;
QTimer m_updateTimer;
QLabel* m_label;
char m_fpsString[256];
......
......@@ -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
**
*/
/*!
......@@ -45,7 +45,7 @@
*/
#ifdef _WIN32
#include <Windows.h>
#include <Windows.h>
#endif
#include <cstdio>
......@@ -86,7 +86,7 @@ void Render_stats_opengl::initializeGL(){
void Render_stats_opengl::resizeGL(int width, int height){
glViewport(0, 0, width, height);
/* update informations about widget size */
_screen_width = width;
_screen_height = height;
......@@ -104,7 +104,7 @@ void Render_stats_opengl::paintGL(){
glClearDepth(1.0);
glClearColor(1.f, 1.f, 1.f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
......@@ -121,7 +121,7 @@ void Render_stats_opengl::paintGL(){
list<string>::const_iterator it_txt;
Element_pos buf_x;
Element_pos buf_y;
string buf_txt;
string buf_txt;
if (glIsList(_rect_list) == GL_FALSE)
printf("ERROR LIST not exist for stats\n");
......@@ -129,7 +129,7 @@ void Render_stats_opengl::paintGL(){
glCallList(_rect_list);
glFlush();
/* Check the errors */
GLenum glerror;
glerror = glGetError();
......@@ -139,11 +139,11 @@ void Render_stats_opengl::paintGL(){
const QFont &arial_font = QFont("Arial", 10);
qglColor(QColor(0, 0, 0)); // We put the text in black
for (it_txt=_text_value.begin(), it_pos=_text_pos.begin() ; it_txt!=_text_value.end() ; it_txt ++, it_pos ++) {
for (it_txt=_text_value.begin(), it_pos=_text_pos.begin() ; it_txt!=_text_value.end() ; it_txt ++, it_pos ++) {
buf_x = *it_pos - _translated_x;
it_pos ++;
buf_y = *it_pos - _translated_y + height() - _size_for_one_container;
buf_txt = *it_txt;
......
......@@ -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
**
*/
/*!
......@@ -67,12 +67,12 @@ class Render_stats_opengl : public QGLWidget, public Render_stats {
Q_OBJECT
private:
/*!
* \brief Contains container text coordinates.
*/
std::list<Element_pos> _text_pos;
/*!
* \brief Contains container strings.
*/
......@@ -81,7 +81,7 @@ private:
GLuint _rect_list;
double _translated_y;
double _translated_x;
bool _stats_beginned_drawed;
......@@ -92,7 +92,7 @@ public:
* \brief The default constructor
*/
Render_stats_opengl(QWidget *parent);
/*!
* \brief The destructor
*/
......@@ -102,23 +102,23 @@ public:
* \brief Call by the system to initialize the OpenGL render area.
*/
void initializeGL();
/*!
* \brief Call by the system when the render area was resized (occurs during a window resizement).
* \param width : the new width of the render area.
* \param height : the new height of the render area.
* \param height : the new height of the render area.
*/
void resizeGL(int width, int height);
/*!
* \brief Call by the system each time the render area need to be updated.
*/
void paintGL();
/*!
* \brief Proceeds with the initialization of draw functions.
*/
void start_draw();
/*!
......@@ -183,7 +183,7 @@ public:
* \brief Proceeds with the end of draw functions.
*/
void end_draw();
/*!
* \fn translate_y(int value)
* \brief Translate the window on the vertical axis.
......@@ -238,7 +238,7 @@ inline void Render_stats_opengl::start_draw(){
inline void Render_stats_opengl::draw_text(const Element_pos x, const Element_pos y, const std::string value) {
_text_pos.push_back(x);
_text_pos.push_back(x);
_text_pos.push_back(y);
_text_value.push_back(value);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment