Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
solverstack
vite
Commits
bb05352a
Commit
bb05352a
authored
Mar 01, 2018
by
Mathieu Faverge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add structure to provide ordering and values files
parent
5af6fc5c
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
310 additions
and
63 deletions
+310
-63
plugins/MatrixVisualizer/CMakeLists.txt
plugins/MatrixVisualizer/CMakeLists.txt
+4
-0
plugins/MatrixVisualizer/MatrixVisualizer.cpp
plugins/MatrixVisualizer/MatrixVisualizer.cpp
+98
-16
plugins/MatrixVisualizer/MatrixVisualizer.hpp
plugins/MatrixVisualizer/MatrixVisualizer.hpp
+13
-0
plugins/MatrixVisualizer/Parsers/OrderParser.cpp
plugins/MatrixVisualizer/Parsers/OrderParser.cpp
+37
-0
plugins/MatrixVisualizer/Parsers/OrderParser.hpp
plugins/MatrixVisualizer/Parsers/OrderParser.hpp
+25
-0
plugins/MatrixVisualizer/Parsers/Parser.hpp
plugins/MatrixVisualizer/Parsers/Parser.hpp
+1
-1
plugins/MatrixVisualizer/Parsers/SymbolParser.cpp
plugins/MatrixVisualizer/Parsers/SymbolParser.cpp
+1
-2
plugins/MatrixVisualizer/Parsers/SymbolParser.hpp
plugins/MatrixVisualizer/Parsers/SymbolParser.hpp
+1
-1
plugins/MatrixVisualizer/Parsers/ValuesParser.cpp
plugins/MatrixVisualizer/Parsers/ValuesParser.cpp
+37
-0
plugins/MatrixVisualizer/Parsers/ValuesParser.hpp
plugins/MatrixVisualizer/Parsers/ValuesParser.hpp
+25
-0
plugins/MatrixVisualizer/Plugin.ui
plugins/MatrixVisualizer/Plugin.ui
+27
-2
plugins/MatrixVisualizer/Windows/MatrixGLWidget.hpp
plugins/MatrixVisualizer/Windows/MatrixGLWidget.hpp
+40
-40
plugins/MatrixVisualizer/Windows/MatrixWindow.hpp
plugins/MatrixVisualizer/Windows/MatrixWindow.hpp
+1
-1
No files found.
plugins/MatrixVisualizer/CMakeLists.txt
View file @
bb05352a
...
...
@@ -35,6 +35,8 @@ set (MATRIXVISUALIZER_hdrs
Parsers/Parser.hpp
Parsers/SymbolParser.hpp
Parsers/OrderParser.hpp
Parsers/ValuesParser.hpp
Formats/SymbolMatrix.hpp
Parsers/Readers/Pastix.hpp
...
...
@@ -52,6 +54,8 @@ set (MATRIXVISUALIZER_srcs
Formats/SymbolMatrix.cpp
Parsers/SymbolParser.cpp
Parsers/OrderParser.cpp
Parsers/ValuesParser.cpp
Parsers/Readers/Pastix.cpp
Windows/MatrixWindow.cpp
...
...
plugins/MatrixVisualizer/MatrixVisualizer.cpp
View file @
bb05352a
...
...
@@ -5,7 +5,10 @@
Matrix_visualizer
*
Matrix_visualizer
::
s_plugin
=
nullptr
;
SymbolParser
Matrix_visualizer
::
s_symbol_parser
;
OrderParser
Matrix_visualizer
::
s_order_parser
;
ValuesParser
Matrix_visualizer
::
s_values_parser
;
Matrix_window
*
Matrix_visualizer
::
s_matrix_window
=
nullptr
;
symbol_matrix_t
*
Matrix_visualizer
::
s_matrix
=
nullptr
;
// Functions to initialize the plugin in ViTE
Plugin
*
create
()
{
return
Matrix_visualizer
::
get_instance
();
}
...
...
@@ -49,37 +52,116 @@ std::string Matrix_visualizer::get_name(){
return
"Matrix visualizer"
;
}
void
Matrix_visualizer
::
execute
(){
QString
symbol_filepath
=
this
->
line_edit_symbol
->
text
();
QString
values_filepath
=
this
->
line_edit_values
->
text
()
;
int
Matrix_visualizer
::
update_matrix
(
QString
filepath
)
{
symbol_matrix_t
*
new_matrix
;
if
(
symbol_filepath
.
size
()
==
0
)
// Check if there is a symbol file
if
(
filepath
.
size
()
==
0
)
{
Helper
::
log
(
LogStatus
::
FATAL
,
"Empty filepath for symbol matrix file..."
);
return
;
return
-
1
;
}
if
(
values_filepath
.
size
()
==
0
)
// Parse the symbol file if any
Helper
::
log
(
LogStatus
::
MESSAGE
,
"Parsing symbol file..."
);
new_matrix
=
s_symbol_parser
.
parse
(
filepath
.
toStdString
(),
nullptr
);
if
(
new_matrix
==
nullptr
)
{
Helper
::
log
(
LogStatus
::
WARNING
,
"Empty filepath for values file..."
);
Helper
::
log
(
LogStatus
::
FATAL
,
"Parsed matrix is empty"
);
return
-
1
;
}
// Parse the symbol file
Helper
::
log
(
LogStatus
::
MESSAGE
,
"Parsing symbol file..."
);
Helper
::
log
(
LogStatus
::
MESSAGE
,
"Successfully read symbol file"
);
symbol_matrix_print_stats
(
s_matrix
);
if
(
s_matrix
!=
nullptr
)
{
symbol_matrix_deinit
(
s_matrix
);
}
s_matrix
=
new_matrix
;
return
0
;
}
int
Matrix_visualizer
::
update_order
(
QString
filepath
)
{
void
*
rc
;
if
(
s_matrix
==
nullptr
)
{
Helper
::
log
(
LogStatus
::
FATAL
,
"No symbol matrix has been loaded"
);
return
-
1
;
}
// Check if there is a symbol file
if
(
filepath
.
size
()
==
0
)
{
Helper
::
log
(
LogStatus
::
FATAL
,
"Empty filepath for order file..."
);
return
-
1
;
}
// Parse the symbol file if any
Helper
::
log
(
LogStatus
::
MESSAGE
,
"Parsing order file..."
);
rc
=
s_order_parser
.
parse
(
filepath
.
toStdString
(),
s_matrix
);
if
(
rc
!=
nullptr
)
{
Helper
::
log
(
LogStatus
::
FATAL
,
"Error parsing order file"
);
return
-
1
;
}
Helper
::
log
(
LogStatus
::
MESSAGE
,
"Successfully read order file"
);
//symbol_matrix_print_stats(matrix);
return
0
;
}
int
Matrix_visualizer
::
update_values
(
QString
filepath
)
{
void
*
rc
;
if
(
s_matrix
==
nullptr
)
{
Helper
::
log
(
LogStatus
::
FATAL
,
"No symbol matrix has been loaded"
);
return
-
1
;
}
// Check if there is a symbol file
if
(
filepath
.
size
()
==
0
)
{
Helper
::
log
(
LogStatus
::
FATAL
,
"Empty filepath for values file..."
);
return
-
1
;
}
symbol_matrix_t
*
matrix
=
s_symbol_parser
.
parse
(
symbol_filepath
.
toStdString
());
// Parse the symbol file if any
Helper
::
log
(
LogStatus
::
MESSAGE
,
"Parsing values file..."
);
rc
=
s_values_parser
.
parse
(
filepath
.
toStdString
(),
s_matrix
);
if
(
matrix
=
=
nullptr
)
if
(
rc
!
=
nullptr
)
{
return
;
Helper
::
log
(
LogStatus
::
FATAL
,
"Error parsing values file"
);
return
-
1
;
}
Helper
::
log
(
LogStatus
::
MESSAGE
,
"Successfully readed symbol file"
);
symbol_matrix_print_stats
(
matrix
);
Helper
::
log
(
LogStatus
::
MESSAGE
,
"Successfully read values file"
);
//symbol_matrix_print_stats(matrix);
return
0
;
}
void
Matrix_visualizer
::
execute
(){
QString
symbol_filepath
=
this
->
line_edit_symbol
->
text
();
QString
order_filepath
=
this
->
line_edit_order
->
text
();
QString
values_filepath
=
this
->
line_edit_values
->
text
();
update_matrix
(
this
->
line_edit_symbol
->
text
()
);
update_order
(
this
->
line_edit_order
->
text
()
);
update_values
(
this
->
line_edit_values
->
text
()
);
// Open window for opengl drawing
s_matrix_window
=
new
Matrix_window
(
matrix
);
s_matrix_window
->
show
();
if
(
s_matrix
!=
nullptr
)
{
s_matrix_window
=
new
Matrix_window
(
s_matrix
);
s_matrix_window
->
show
();
}
}
void
Matrix_visualizer
::
log
(
LogStatus
status
,
const
char
*
format
,
va_list
ap
)
...
...
plugins/MatrixVisualizer/MatrixVisualizer.hpp
View file @
bb05352a
...
...
@@ -3,6 +3,8 @@
#include "Windows/MatrixWindow.hpp"
#include "Parsers/SymbolParser.hpp"
#include "Parsers/OrderParser.hpp"
#include "Parsers/ValuesParser.hpp"
#include "plugin/Plugin.hpp"
#include "Helper.hpp"
...
...
@@ -27,6 +29,10 @@ private:
Matrix_visualizer
();
~
Matrix_visualizer
();
int
update_matrix
(
QString
filepath
);
int
update_order
(
QString
filepath
);
int
update_values
(
QString
filepath
);
void
connect_widgets
();
public
slots
:
...
...
@@ -40,10 +46,17 @@ private slots:
private:
static
Matrix_visualizer
*
s_plugin
;
// Parsers
static
SymbolParser
s_symbol_parser
;
static
OrderParser
s_order_parser
;
static
ValuesParser
s_values_parser
;
// Windows
static
Matrix_window
*
s_matrix_window
;
// Matrix
static
symbol_matrix_t
*
s_matrix
;
};
extern
"C"
...
...
plugins/MatrixVisualizer/Parsers/OrderParser.cpp
0 → 100644
View file @
bb05352a
#include "OrderParser.hpp"
#include "Readers/Pastix.hpp"
OrderParser
::
OrderParser
()
{
m_percentage_loaded
=
0
;
}
symbol_matrix_t
*
OrderParser
::
parse
(
std
::
string
path
,
symbol_matrix_t
*
matrix
)
{
return
matrix
;
}
float
OrderParser
::
get_percent_loaded
()
const
{
return
m_percentage_loaded
;
}
bool
OrderParser
::
is_finished
()
const
{
return
m_is_finished
;
}
bool
OrderParser
::
is_cancelled
()
const
{
return
m_is_canceled
;
}
void
OrderParser
::
set_canceled
()
{
m_is_canceled
=
true
;
}
void
OrderParser
::
finish
()
{
m_is_finished
=
true
;
}
plugins/MatrixVisualizer/Parsers/OrderParser.hpp
0 → 100644
View file @
bb05352a
#ifndef ORDER_PARSER_MATRIX_VISUALIZER_HPP
#define ORDER_PARSER_MATRIX_VISUALIZER_HPP
#include "../Formats/SymbolMatrix.hpp"
#include "Parser.hpp"
class
OrderParser
:
public
Parser
<
symbol_matrix_t
>
{
public:
OrderParser
();
symbol_matrix_t
*
parse
(
std
::
string
path
,
symbol_matrix_t
*
m
);
float
get_percent_loaded
()
const
;
bool
is_finished
()
const
;
bool
is_cancelled
()
const
;
void
set_canceled
();
void
finish
();
private:
float
m_percentage_loaded
;
};
#endif
plugins/MatrixVisualizer/Parsers/Parser.hpp
View file @
bb05352a
...
...
@@ -9,7 +9,7 @@ class Parser
public:
Parser
(){}
virtual
T
*
parse
(
std
::
string
path
)
=
0
;
virtual
T
*
parse
(
std
::
string
path
,
T
*
m
)
=
0
;
virtual
float
get_percent_loaded
()
const
=
0
;
virtual
bool
is_finished
()
const
=
0
;
...
...
plugins/MatrixVisualizer/Parsers/SymbolParser.cpp
View file @
bb05352a
#include "SymbolParser.hpp"
#include "Readers/Pastix.hpp"
SymbolParser
::
SymbolParser
()
...
...
@@ -7,7 +6,7 @@ SymbolParser::SymbolParser()
m_percentage_loaded
=
0
;
}
symbol_matrix_t
*
SymbolParser
::
parse
(
std
::
string
path
)
symbol_matrix_t
*
SymbolParser
::
parse
(
std
::
string
path
,
symbol_matrix_t
*
mtx
=
nullptr
)
{
symbol_matrix_t
*
matrix
;
FILE
*
stream
;
...
...
plugins/MatrixVisualizer/Parsers/SymbolParser.hpp
View file @
bb05352a
...
...
@@ -9,7 +9,7 @@ class SymbolParser : public Parser<symbol_matrix_t>
public:
SymbolParser
();
symbol_matrix_t
*
parse
(
std
::
string
path
);
symbol_matrix_t
*
parse
(
std
::
string
path
,
symbol_matrix_t
*
m
);
float
get_percent_loaded
()
const
;
bool
is_finished
()
const
;
...
...
plugins/MatrixVisualizer/Parsers/ValuesParser.cpp
0 → 100644
View file @
bb05352a
#include "ValuesParser.hpp"
#include "Readers/Pastix.hpp"
ValuesParser
::
ValuesParser
()
{
m_percentage_loaded
=
0
;
}
symbol_matrix_t
*
ValuesParser
::
parse
(
std
::
string
path
,
symbol_matrix_t
*
matrix
)
{
return
matrix
;
}
float
ValuesParser
::
get_percent_loaded
()
const
{
return
m_percentage_loaded
;
}
bool
ValuesParser
::
is_finished
()
const
{
return
m_is_finished
;
}
bool
ValuesParser
::
is_cancelled
()
const
{
return
m_is_canceled
;
}
void
ValuesParser
::
set_canceled
()
{
m_is_canceled
=
true
;
}
void
ValuesParser
::
finish
()
{
m_is_finished
=
true
;
}
plugins/MatrixVisualizer/Parsers/ValuesParser.hpp
0 → 100644
View file @
bb05352a
#ifndef VALUES_PARSER_MATRIX_VISUALIZER_HPP
#define VALUES_PARSER_MATRIX_VISUALIZER_HPP
#include "../Formats/SymbolMatrix.hpp"
#include "Parser.hpp"
class
ValuesParser
:
public
Parser
<
symbol_matrix_t
>
{
public:
ValuesParser
();
symbol_matrix_t
*
parse
(
std
::
string
path
,
symbol_matrix_t
*
m
);
float
get_percent_loaded
()
const
;
bool
is_finished
()
const
;
bool
is_cancelled
()
const
;
void
set_canceled
();
void
finish
();
private:
float
m_percentage_loaded
;
};
#endif
plugins/MatrixVisualizer/Plugin.ui
View file @
bb05352a
...
...
@@ -42,7 +42,32 @@
</layout>
</item>
<item>
<widget
class=
"QLabel"
name=
"label_symbol"
>
<widget
class=
"QLabel"
name=
"label_order"
>
<property
name=
"text"
>
<string>
Matrix order file:
</string>
</property>
</widget>
</item>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontal_layout_order"
>
<item>
<widget
class=
"QLineEdit"
name=
"line_edit_order"
>
<property
name=
"placeholderText"
>
<string>
Matrix order filepath...
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QToolButton"
name=
"tool_button_order"
>
<property
name=
"text"
>
<string>
...
</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget
class=
"QLabel"
name=
"label_values"
>
<property
name=
"text"
>
<string>
Matrix values file:
</string>
</property>
...
...
@@ -53,7 +78,7 @@
<item>
<widget
class=
"QLineEdit"
name=
"line_edit_values"
>
<property
name=
"placeholderText"
>
<string>
Matrix value filepath...
</string>
<string>
Matrix value
s
filepath...
</string>
</property>
</widget>
</item>
...
...
plugins/MatrixVisualizer/Windows/MatrixGLWidget.hpp
View file @
bb05352a
...
...
@@ -6,10 +6,10 @@
#include <QtOpenGL/QtOpenGL>
#ifdef USE_QT5
#include <QOpenGLFunctions>
#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#include <QOpenGLWidget>
#else
#include <QGLWidget>
#include <QGLWidget>
#endif
#include <QKeyEvent>
...
...
@@ -34,53 +34,53 @@ protected:
void
resizeGL
(
int
w
,
int
h
)
override
;
void
paintGL
()
override
;
void
keyPressEvent
(
QKeyEvent
*
keyEvent
);
void
keyPressEvent
(
QKeyEvent
*
keyEvent
);
void
mousePressEvent
(
QMouseEvent
*
mouseEvent
);
void
mouseReleaseEvent
(
QMouseEvent
*
mouseEvent
);
void
mouseMoveEvent
(
QMouseEvent
*
mouseEvent
);
void
mousePressEvent
(
QMouseEvent
*
mouseEvent
);
void
mouseReleaseEvent
(
QMouseEvent
*
mouseEvent
);
void
mouseMoveEvent
(
QMouseEvent
*
mouseEvent
);
private:
typedef
struct
CameraPosition
{
double
m_cameraX
;
double
m_cameraY
;
double
m_cameraDx
;
double
m_cameraDy
;
}
CameraPosition
;
typedef
struct
CameraPosition
{
double
m_cameraX
;
double
m_cameraY
;
double
m_cameraDx
;
double
m_cameraDy
;
}
CameraPosition
;
private:
void
refreshCamera
();
void
refreshCamera
();
private
slots
:
/* Helpers */
void
updateTimer
();
void
updateTimer
();
private:
uint32_t
m_frameCount
;
QTime
m_time
;
QTimer
m_updateTimer
;
QLabel
*
m_label
;
char
m_fpsString
[
256
];
double
m_qtToGLWidthCoeff
;
double
m_qtToGLHeightCoeff
;
// Zoom
Zooming
*
m_zooming
;
int
m_mouseXClicked
;
int
m_mouseYClicked
;
CameraPosition
m_camera
;
int
m_drawTempSelection
;
int
m_tempSelectionX
;
int
m_tempSelectionY
;
int
m_tempSelectionDx
;
int
m_tempSelectionDy
;
// Zoom stack
std
::
stack
<
CameraPosition
>
m_savedPositions
;
uint32_t
m_frameCount
;
QTime
m_time
;
QTimer
m_updateTimer
;
QLabel
*
m_label
;
char
m_fpsString
[
256
];
double
m_qtToGLWidthCoeff
;
double
m_qtToGLHeightCoeff
;
// Zoom
Zooming
*
m_zooming
;
int
m_mouseXClicked
;
int
m_mouseYClicked
;
CameraPosition
m_camera
;
int
m_drawTempSelection
;
int
m_tempSelectionX
;
int
m_tempSelectionY
;
int
m_tempSelectionDx
;
int
m_tempSelectionDy
;
// Zoom stack
std
::
stack
<
CameraPosition
>
m_savedPositions
;
};
#endif
plugins/MatrixVisualizer/Windows/MatrixWindow.hpp
View file @
bb05352a
...
...
@@ -20,7 +20,7 @@ public:
protected:
void
closeEvent
(
QCloseEvent
*
event
);
void
keyPressEvent
(
QKeyEvent
*
keyEvent
);
void
keyPressEvent
(
QKeyEvent
*
keyEvent
);
private:
MatrixGLWidget
*
m_gl
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment