Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
vite
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
solverstack
vite
Commits
f36d965e
Commit
f36d965e
authored
7 years ago
by
Mathieu Faverge
Browse files
Options
Downloads
Patches
Plain Diff
fix(zooming): Make sure the zomm stays inside the box, and cleanup spaces
parent
8353717f
Branches
Branches containing commit
No related tags found
1 merge request
!5
Plugins/matrix visualizer
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
plugins/MatrixVisualizer/Common/Zooming.cpp
+112
-89
112 additions, 89 deletions
plugins/MatrixVisualizer/Common/Zooming.cpp
with
112 additions
and
89 deletions
plugins/MatrixVisualizer/Common/Zooming.cpp
+
112
−
89
View file @
f36d965e
...
...
@@ -3,17 +3,17 @@
#include
"../Helper.hpp"
Zooming
::
Zooming
(
symbol_matrix_t
*
matrix
)
:
m_matrix
(
matrix
)
:
m_matrix
(
matrix
)
{
// Fill correct colors
move
(
0.
f
,
1.
f
,
0.
f
,
1.
f
);
// Fill correct colors
move
(
0.
f
,
1.
f
,
0.
f
,
1.
f
);
}
Zooming
::~
Zooming
()
{
// Destroy quadtree
symbol_matrix_deinit
(
m_matrix
);
delete
m_matrix
;
// Destroy quadtree
symbol_matrix_deinit
(
m_matrix
);
delete
m_matrix
;
}
GLfloat
Zooming
::
getColor
(
int
x
,
int
y
)
...
...
@@ -21,88 +21,111 @@ GLfloat Zooming::getColor(int x, int y)
return
m_colors
[
x
][
y
];
}
void
Zooming
::
clean_move
(
double
*
xbeg
,
double
*
xend
,
double
*
ybeg
,
double
*
yend
)
{
double
tmp
;
// Cleanup postions
if
(
*
xbeg
>
*
xend
)
{
double
tmp
=
*
xend
;
*
xbeg
=
*
xend
;
*
xend
=
tmp
;
}
if
(
*
ybeg
>
*
yend
)
{
double
tmp
=
*
yend
;
*
ybeg
=
*
yend
;
*
yend
=
tmp
;
}
*
xbeg
=
(
*
xbeg
<
0.
)
?
0.
:
*
xbeg
;
*
xend
=
(
*
xend
>
1.
)
?
1.
:
*
xend
;
*
ybeg
=
(
*
ybeg
<
0.
)
?
0.
:
*
ybeg
;
*
yend
=
(
*
yend
>
1.
)
?
1.
:
*
yend
;
}
void
Zooming
::
move
(
double
xStart
,
double
xEnd
,
double
yStart
,
double
yEnd
)
{
int
i
,
j
,
m
,
n
;
int
startCol
=
xStart
*
m_matrix
->
m_colsnbr
;
int
endCol
=
xEnd
*
m_matrix
->
m_colsnbr
;
int
diffCols
=
endCol
-
startCol
;
// Find first cblk
int
startCblk
=
0
;
int
endCblk
=
0
;
for
(
i
=
0
;
i
<
m_matrix
->
m_cblknbr
;
++
i
)
{
symbol_cblk_t
*
cblk
=
&
(
m_matrix
->
m_cblktab
[
i
]);
if
(
cblk
->
m_fcolumn
<=
startCol
&&
cblk
->
m_lcolnum
>=
startCol
)
startCblk
=
i
;
if
(
cblk
->
m_fcolumn
<=
endCol
&&
cblk
->
m_lcolnum
>=
endCol
)
endCblk
=
i
;
}
int
diffCblk
=
endCblk
-
startCblk
;
int
startRow
=
yStart
*
m_matrix
->
m_rowsnbr
;
int
endRow
=
yEnd
*
m_matrix
->
m_rowsnbr
;
int
diffRow
=
endRow
-
startRow
;
symbol_cblk_t
*
cblks
=
m_matrix
->
m_cblktab
;
symbol_blok_t
*
bloks
=
m_matrix
->
m_bloktab
;
for
(
i
=
0
;
i
<
DEFAULT_LEVEL_POWER_2
;
++
i
)
{
for
(
j
=
0
;
j
<
DEFAULT_LEVEL_POWER_2
;
++
j
)
{
m_colors
[
i
][
j
]
=
0.
f
;
}
}
float
xCoeff
=
(
float
)
DEFAULT_LEVEL_POWER_2
/
((
float
)
diffCols
+
1
);
float
yCoeff
=
(
float
)
DEFAULT_LEVEL_POWER_2
/
((
float
)
diffRow
+
1
);
for
(
i
=
startCblk
;
i
<=
endCblk
;
++
i
)
{
int
firstBlokNum
=
cblks
[
i
].
m_bloknum
;
int
nextBlokNum
=
(
i
+
1
!=
m_matrix
->
m_cblknbr
?
cblks
[
i
+
1
].
m_bloknum
:
m_matrix
->
m_bloknbr
);
// Get first block size in col from x to xEnd
symbol_cblk_t
*
cblk
=
&
(
cblks
[
i
]);
int
startingCol
=
(
cblk
->
m_fcolumn
<
startCol
?
startCol
:
cblk
->
m_fcolumn
);
int
endingCol
=
(
cblk
->
m_lcolnum
>
endCol
?
endCol
+
1
:
cblk
->
m_lcolnum
);
int
x
=
(
startingCol
-
startCol
)
*
xCoeff
;
int
xEnd
=
(
endingCol
-
startCol
)
*
xCoeff
;
for
(
j
=
firstBlokNum
;
j
<
nextBlokNum
;
++
j
)
{
symbol_blok_t
*
blok
=
&
(
bloks
[
j
]);
if
(
blok
->
m_frownum
>=
startRow
&&
blok
->
m_frownum
<=
endRow
)
{
// Get first block size in row from y to yEnd
int
startingRow
=
(
blok
->
m_frownum
<
startRow
?
startRow
:
blok
->
m_frownum
);
int
endingRow
=
(
blok
->
m_lrownum
>
endRow
?
endRow
+
1
:
blok
->
m_lrownum
);
int
y
=
(
startingRow
-
startRow
)
*
yCoeff
;
int
yEnd
=
(
endingRow
-
startRow
)
*
yCoeff
;
m
=
x
;
do
{
n
=
y
;
do
{
m_colors
[
m
][
n
]
=
1.0
f
;
n
++
;
}
while
(
n
<
yEnd
);
m
++
;
}
while
(
m
<
xEnd
);
}
}
}
}
\ No newline at end of file
int
i
,
j
,
m
,
n
;
clean_move
(
&
xStart
,
&
xEnd
,
&
yStart
,
&
yEnd
);
int
startCol
=
xStart
*
m_matrix
->
m_colsnbr
;
int
endCol
=
xEnd
*
m_matrix
->
m_colsnbr
;
int
startRow
=
yStart
*
m_matrix
->
m_rowsnbr
;
int
endRow
=
yEnd
*
m_matrix
->
m_rowsnbr
;
int
diffCols
=
endCol
-
startCol
;
int
diffRow
=
endRow
-
startRow
;
// Find first cblk
int
startCblk
=
0
;
int
endCblk
=
0
;
for
(
i
=
0
;
i
<
m_matrix
->
m_cblknbr
;
++
i
)
{
symbol_cblk_t
*
cblk
=
&
(
m_matrix
->
m_cblktab
[
i
]);
if
(
cblk
->
m_fcolumn
<=
startCol
&&
cblk
->
m_lcolnum
>=
startCol
)
startCblk
=
i
;
if
(
cblk
->
m_fcolumn
<=
endCol
&&
cblk
->
m_lcolnum
>=
endCol
)
endCblk
=
i
;
}
int
diffCblk
=
endCblk
-
startCblk
;
symbol_cblk_t
*
cblks
=
m_matrix
->
m_cblktab
;
symbol_blok_t
*
bloks
=
m_matrix
->
m_bloktab
;
for
(
i
=
0
;
i
<
DEFAULT_LEVEL_POWER_2
;
++
i
)
{
for
(
j
=
0
;
j
<
DEFAULT_LEVEL_POWER_2
;
++
j
)
{
m_colors
[
i
][
j
]
=
0.
f
;
}
}
float
xCoeff
=
(
float
)
DEFAULT_LEVEL_POWER_2
/
((
float
)
diffCols
+
1
);
float
yCoeff
=
(
float
)
DEFAULT_LEVEL_POWER_2
/
((
float
)
diffRow
+
1
);
for
(
i
=
startCblk
;
i
<=
endCblk
;
++
i
)
{
int
firstBlokNum
=
cblks
[
i
].
m_bloknum
;
int
nextBlokNum
=
(
i
+
1
!=
m_matrix
->
m_cblknbr
?
cblks
[
i
+
1
].
m_bloknum
:
m_matrix
->
m_bloknbr
);
// Get first block size in col from x to xEnd
symbol_cblk_t
*
cblk
=
&
(
cblks
[
i
]);
int
startingCol
=
(
cblk
->
m_fcolumn
<
startCol
?
startCol
:
cblk
->
m_fcolumn
);
int
endingCol
=
(
cblk
->
m_lcolnum
>
endCol
?
endCol
+
1
:
cblk
->
m_lcolnum
);
int
x
=
(
startingCol
-
startCol
)
*
xCoeff
;
int
xEnd
=
(
endingCol
-
startCol
)
*
xCoeff
;
for
(
j
=
firstBlokNum
;
j
<
nextBlokNum
;
++
j
)
{
symbol_blok_t
*
blok
=
&
(
bloks
[
j
]);
if
(
blok
->
m_frownum
>=
startRow
&&
blok
->
m_frownum
<=
endRow
)
{
// Get first block size in row from y to yEnd
int
startingRow
=
(
blok
->
m_frownum
<
startRow
?
startRow
:
blok
->
m_frownum
);
int
endingRow
=
(
blok
->
m_lrownum
>
endRow
?
endRow
+
1
:
blok
->
m_lrownum
);
int
y
=
(
startingRow
-
startRow
)
*
yCoeff
;
int
yEnd
=
(
endingRow
-
startRow
)
*
yCoeff
;
m
=
x
;
do
{
n
=
y
;
do
{
m_colors
[
m
][
n
]
=
1.0
f
;
n
++
;
}
while
(
n
<
yEnd
);
m
++
;
}
while
(
m
<
xEnd
);
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment