Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CGoGN
CGoGN
Commits
99f83d7e
Commit
99f83d7e
authored
Jun 12, 2012
by
Sylvain Thery
Browse files
debug picking in histogram
add marking/getting cells corresponding to a column of histo or quantiles
parent
e44709ec
Changes
6
Hide whitespace changes
Inline
Side-by-side
Apps/Tuto/tuto_histo.cpp
View file @
99f83d7e
...
...
@@ -268,6 +268,30 @@ void MyQT::cb_redraw()
void
MyQT
::
clickHisto
(
unsigned
int
i
,
unsigned
int
j
)
{
std
::
cout
<<
"CLICK on column Histo: "
<<
i
<<
" / Quantiles: "
<<
j
<<
std
::
endl
;
if
(
i
!=
Utils
::
QT
::
RenderHistogram
::
NONE
)
{
std
::
vector
<
unsigned
int
>
vc
;
l_histo
->
cellsOfHistogramColumn
(
i
,
vc
);
std
::
cout
<<
"Cells of histo: "
<<
std
::
endl
;
for
(
unsigned
int
k
=
0
;
k
<
vc
.
size
();
++
k
)
std
::
cout
<<
vc
[
k
]
<<
"/"
;
std
::
cout
<<
std
::
endl
;
CellMarker
<
VERTEX
>
cm
(
myMap
);
std
::
cout
<<
l_histo
->
markCellsOfHistogramColumn
(
i
,
cm
)
<<
" marked cells"
<<
std
::
endl
;
}
if
(
j
!=
Utils
::
QT
::
RenderHistogram
::
NONE
)
{
std
::
vector
<
unsigned
int
>
vc
;
l_histo
->
cellsOfHistogramColumn
(
j
,
vc
);
std
::
cout
<<
"Cells of quantile: "
<<
std
::
endl
;
for
(
unsigned
int
k
=
0
;
k
<
vc
.
size
();
++
k
)
std
::
cout
<<
vc
[
k
]
<<
"/"
;
std
::
cout
<<
std
::
endl
;
}
}
...
...
include/Algo/Histogram/histogram.h
View file @
99f83d7e
...
...
@@ -26,6 +26,7 @@
#define __HISTOGRAM__
#include
"Topology/generic/attributeHandler.h"
#include
"Topology/generic/cellmarker.h"
#include
"Geometry/vector_gen.h"
#include
"Utils/colorMaps.h"
#include
"Utils/vbo.h"
...
...
@@ -311,24 +312,43 @@ public:
* return cells of histogram's column
* @param c column of histogram
* @param vc vector of cells (indices)
* @return
true if not empty
* @return
number of cells
*/
bool
cellsOfHistogramColumn
(
unsigned
int
c
,
std
::
vector
<
unsigned
int
>
vc
)
const
;
unsigned
int
cellsOfHistogramColumn
(
unsigned
int
c
,
std
::
vector
<
unsigned
int
>
&
vc
)
const
;
/**
* return cells of quantile's column
* @param c column of quantile
* @param vc vector of cells (indices)
* @return
true if not empty
* @return
number of cells
*/
bool
cellsOfQua
u
ntilesColumn
(
unsigned
int
c
,
std
::
vector
<
unsigned
int
>
vc
)
const
;
unsigned
int
cellsOfQuantilesColumn
(
unsigned
int
c
,
std
::
vector
<
unsigned
int
>
&
vc
)
const
;
/**
* mark cells of histogram's column
* @param c column of quantile
* @param cm marker
* @return number of marked cells
*/
template
<
typename
CELLMARKER
>
unsigned
int
markCellsOfHistogramColumn
(
unsigned
int
c
,
CELLMARKER
&
cm
)
const
;
/**
* mark cells of quantile's column
* @param c column of quantile
* @param cm marker
* @return number of marked cells
*/
template
<
typename
CELLMARKER
>
unsigned
int
markCellsOfQuantilesColumn
(
unsigned
int
c
,
CELLMARKER
&
cm
)
const
;
/**
* get the colorMap
*/
const
HistoColorMap
&
colorMap
()
const
;
};
...
...
include/Algo/Histogram/histogram.hpp
View file @
99f83d7e
...
...
@@ -22,7 +22,8 @@
* *
*******************************************************************************/
// forward
#include
<algorithm>
namespace
CGoGN
{
...
...
@@ -224,6 +225,58 @@ inline bool Histogram::dataComp( const std::pair<double, unsigned int>& a, const
}
template
<
typename
CELLMARKER
>
unsigned
int
Histogram
::
markCellsOfHistogramColumn
(
unsigned
int
c
,
CELLMARKER
&
cm
)
const
{
if
(
!
m_sorted
)
{
std
::
sort
(
m_dataIdx
.
begin
(),
m_dataIdx
.
end
(),
dataComp
);
m_sorted
=
true
;
}
double
bi
=
(
m_max
-
m_min
)
/
m_nbclasses
*
c
+
m_min
;
double
bs
=
(
m_max
-
m_min
)
/
m_nbclasses
*
(
c
+
1
)
+
m_min
;
unsigned
int
nb
=
m_dataIdx
.
size
();
unsigned
int
i
=
0
;
while
((
i
<
nb
)
&&
(
data
(
i
)
<
bi
))
++
i
;
unsigned
int
nbc
=
0
;
while
((
i
<
nb
)
&&
(
data
(
i
)
<
bs
))
{
cm
.
mark
(
idx
(
i
++
));
++
nbc
;
}
return
nbc
;
}
template
<
typename
CELLMARKER
>
unsigned
int
Histogram
::
markCellsOfQuantilesColumn
(
unsigned
int
c
,
CELLMARKER
&
cm
)
const
{
double
bi
=
m_interv
[
c
];
double
bs
=
m_interv
[
c
+
1
];
unsigned
int
nb
=
m_dataIdx
.
size
();
unsigned
int
i
=
0
;
while
((
i
<
nb
)
&&
(
data
(
i
)
<
bi
))
++
i
;
unsigned
int
nbc
=
0
;
while
((
i
<
nb
)
&&
(
data
(
i
)
<
bs
))
{
cm
.
mark
(
idx
(
i
++
));
++
nbc
;
}
return
nbc
;
}
}
}
...
...
include/Utils/Qt/qthistodraw.h
View file @
99f83d7e
...
...
@@ -74,6 +74,9 @@ class RenderHistogram : public QWidget
void
axeVals
();
public:
static
const
unsigned
int
NONE
=
0xffffffff
;
/**
* constructor
* @param parent parent widget
...
...
@@ -143,8 +146,8 @@ public:
signals:
/**
* emitted signal when a column of histogram is clicked
* @param i column of histo (
0xffffffff
if none)
* @param j column of quantileq (
0xffffffff
if none)
* @param i column of histo (
NONE
if none)
* @param j column of quantileq (
NONE
if none)
*/
void
clicked
(
unsigned
int
,
unsigned
int
);
...
...
src/Algo/Histogram/histogram.cpp
View file @
99f83d7e
...
...
@@ -23,7 +23,7 @@
*******************************************************************************/
#include
"Algo/Histogram/histogram.h"
#include
<algorithm>
namespace
CGoGN
{
...
...
@@ -157,7 +157,7 @@ void Histogram::histoColorizeVBO(Utils::VBO& vbo)
}
bool
Histogram
::
cellsOfHistogramColumn
(
unsigned
int
c
,
std
::
vector
<
unsigned
int
>
vc
)
const
unsigned
int
Histogram
::
cellsOfHistogramColumn
(
unsigned
int
c
,
std
::
vector
<
unsigned
int
>
&
vc
)
const
{
if
(
!
m_sorted
)
{
...
...
@@ -167,8 +167,8 @@ bool Histogram::cellsOfHistogramColumn(unsigned int c, std::vector<unsigned int>
vc
.
clear
();
double
bi
=
(
m_m
in
+
m_m
ax
)
/
m_nbclasses
*
c
+
m_min
;
double
bs
=
(
m_m
in
+
m_m
ax
)
/
m_nbclasses
*
(
c
+
1
)
+
m_min
;
double
bi
=
(
m_m
ax
-
m_m
in
)
/
m_nbclasses
*
c
+
m_min
;
double
bs
=
(
m_m
ax
-
m_m
in
)
/
m_nbclasses
*
(
c
+
1
)
+
m_min
;
unsigned
int
nb
=
m_dataIdx
.
size
();
unsigned
int
i
=
0
;
...
...
@@ -177,14 +177,12 @@ bool Histogram::cellsOfHistogramColumn(unsigned int c, std::vector<unsigned int>
++
i
;
while
((
i
<
nb
)
&&
(
data
(
i
)
<
bs
))
{
vc
.
push_back
(
idx
(
i
));
}
vc
.
push_back
(
idx
(
i
++
));
return
!
vc
.
empty
();
return
vc
.
size
();
}
bool
Histogram
::
cellsOfQua
u
ntilesColumn
(
unsigned
int
c
,
std
::
vector
<
unsigned
int
>
vc
)
const
unsigned
int
Histogram
::
cellsOfQuantilesColumn
(
unsigned
int
c
,
std
::
vector
<
unsigned
int
>
&
vc
)
const
{
vc
.
clear
();
...
...
@@ -198,14 +196,14 @@ bool Histogram::cellsOfQuauntilesColumn( unsigned int c, std::vector<unsigned in
++
i
;
while
((
i
<
nb
)
&&
(
data
(
i
)
<
bs
))
{
vc
.
push_back
(
idx
(
i
));
}
vc
.
push_back
(
idx
(
i
++
));
return
!
vc
.
empty
();
return
vc
.
size
();
}
}
}
}
...
...
src/Utils/Qt/qthistodraw.cpp
View file @
99f83d7e
...
...
@@ -288,7 +288,7 @@ void RenderHistogram::svgExport(const std::string& filename)
void
RenderHistogram
::
mousePressEvent
(
QMouseEvent
*
event
)
{
int
x
=
-
1
;
int
x
=
NONE
;
int
widthAxl
=
8
*
m_axl_nbd
;
const
std
::
vector
<
unsigned
int
>&
pop
=
m_histo
.
getPopulation
();
...
...
@@ -307,7 +307,7 @@ void RenderHistogram::mousePressEvent(QMouseEvent* event)
}
const
std
::
vector
<
double
>&
interv
=
m_histo
.
getQuantilesIntervals
();
int
xx
=
-
1
;
int
xx
=
NONE
;
if
(
m_drawQuantiles
&&
!
interv
.
empty
())
{
double
lw
=
(
m_histo
.
getMax
()
-
m_histo
.
getMin
())
/
double
(
m_w
);
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment