Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
80fe3e31
Kaydet (Commit)
80fe3e31
authored
Agu 13, 2014
tarafından
Markus Mohrhard
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
consistent variable naming
Change-Id: I81012a46abd6182c04f1939b6451b18fbbdec646
üst
db8c473c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
103 additions
and
103 deletions
+103
-103
GL3DBarChart.cxx
chart2/source/view/charttypes/GL3DBarChart.cxx
+103
-103
No files found.
chart2/source/view/charttypes/GL3DBarChart.cxx
Dosyayı görüntüle @
80fe3e31
...
@@ -324,8 +324,8 @@ void RenderBenchMarkThread::ProcessClickFlyBack()
...
@@ -324,8 +324,8 @@ void RenderBenchMarkThread::ProcessClickFlyBack()
if
(
!
mbNeedFlyBack
)
if
(
!
mbNeedFlyBack
)
return
;
return
;
osl_getSystemTime
(
&
maClickFlyBackEndTime
);
osl_getSystemTime
(
&
maClickFlyBackEndTime
);
int
a
DeltaMs
=
mpChart
->
calcTimeInterval
(
maClickFlyBackStartTime
,
maClickFlyBackEndTime
);
int
n
DeltaMs
=
mpChart
->
calcTimeInterval
(
maClickFlyBackStartTime
,
maClickFlyBackEndTime
);
if
(
a
DeltaMs
>=
10000
)
if
(
n
DeltaMs
>=
10000
)
{
{
mpChart
->
maRenderEvent
=
EVENT_MOVE_TO_DEFAULT
;
mpChart
->
maRenderEvent
=
EVENT_MOVE_TO_DEFAULT
;
}
}
...
@@ -647,10 +647,10 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
...
@@ -647,10 +647,10 @@ void GL3DBarChart::create3DShapes(const boost::ptr_vector<VDataSeries>& rDataSer
mnCornerId
=
0
;
mnCornerId
=
0
;
mbCameraInit
=
true
;
mbCameraInit
=
true
;
float
pi
=
3.1415926
f
;
float
pi
=
3.1415926
f
;
float
a
ngleX
=
-
pi
/
6.5
f
;
float
nA
ngleX
=
-
pi
/
6.5
f
;
float
a
ngleZ
=
-
pi
/
8.0
f
;
float
nA
ngleZ
=
-
pi
/
8.0
f
;
glm
::
mat4
maDefaultRotateMatrix
=
glm
::
eulerAngleYXZ
(
0.0
f
,
angleX
,
a
ngleZ
);
glm
::
mat4
aDefaultRotateMatrix
=
glm
::
eulerAngleYXZ
(
0.0
f
,
nAngleX
,
nA
ngleZ
);
maDefaultCameraPosition
=
glm
::
vec3
(
m
aDefaultRotateMatrix
*
glm
::
vec4
(
maDefaultCameraPosition
,
1.0
f
));
maDefaultCameraPosition
=
glm
::
vec3
(
aDefaultRotateMatrix
*
glm
::
vec4
(
maDefaultCameraPosition
,
1.0
f
));
maCameraPosition
=
maDefaultCameraPosition
;
maCameraPosition
=
maDefaultCameraPosition
;
maCameraDirection
=
maDefaultCameraDirection
;
maCameraDirection
=
maDefaultCameraDirection
;
mpCamera
->
setPosition
(
maCameraPosition
);
mpCamera
->
setPosition
(
maCameraPosition
);
...
@@ -690,7 +690,6 @@ void GL3DBarChart::update()
...
@@ -690,7 +690,6 @@ void GL3DBarChart::update()
mpRenderThread
=
rtl
::
Reference
<
RenderThread
>
(
new
RenderOneFrameThread
(
this
));
mpRenderThread
=
rtl
::
Reference
<
RenderThread
>
(
new
RenderOneFrameThread
(
this
));
mrWindow
.
getContext
().
resetCurrent
();
mrWindow
.
getContext
().
resetCurrent
();
mpRenderThread
->
launch
();
mpRenderThread
->
launch
();
}
}
namespace
{
namespace
{
...
@@ -791,21 +790,21 @@ void GL3DBarChart::clickedAt(const Point& rPos, sal_uInt16 nButtons)
...
@@ -791,21 +790,21 @@ void GL3DBarChart::clickedAt(const Point& rPos, sal_uInt16 nButtons)
return
;
return
;
const
BarInformation
&
rBarInfo
=
itr
->
second
;
const
BarInformation
&
rBarInfo
=
itr
->
second
;
glm
::
vec3
t
extPos
=
glm
::
vec3
(
rBarInfo
.
maPos
.
x
+
BAR_SIZE_X
/
2.0
f
,
glm
::
vec3
aT
extPos
=
glm
::
vec3
(
rBarInfo
.
maPos
.
x
+
BAR_SIZE_X
/
2.0
f
,
rBarInfo
.
maPos
.
y
+
BAR_SIZE_Y
/
2.0
f
,
rBarInfo
.
maPos
.
y
+
BAR_SIZE_Y
/
2.0
f
,
rBarInfo
.
maPos
.
z
);
rBarInfo
.
maPos
.
z
);
maShapes
.
push_back
(
new
opengl3D
::
ScreenText
(
mpRenderer
.
get
(),
*
mpTextCache
,
maShapes
.
push_back
(
new
opengl3D
::
ScreenText
(
mpRenderer
.
get
(),
*
mpTextCache
,
OUString
(
"Value: "
)
+
OUString
::
number
(
rBarInfo
.
mnVal
),
CALC_POS_EVENT_ID
));
OUString
(
"Value: "
)
+
OUString
::
number
(
rBarInfo
.
mnVal
),
CALC_POS_EVENT_ID
));
opengl3D
::
ScreenText
*
pScreenText
=
static_cast
<
opengl3D
::
ScreenText
*>
(
&
maShapes
.
back
());
opengl3D
::
ScreenText
*
pScreenText
=
static_cast
<
opengl3D
::
ScreenText
*>
(
&
maShapes
.
back
());
pScreenText
->
setPosition
(
glm
::
vec2
(
-
0.9
f
,
0.9
f
),
glm
::
vec2
(
-
0.6
f
,
0.8
f
),
t
extPos
);
pScreenText
->
setPosition
(
glm
::
vec2
(
-
0.9
f
,
0.9
f
),
glm
::
vec2
(
-
0.6
f
,
0.8
f
),
aT
extPos
);
pScreenText
->
render
();
pScreenText
->
render
();
glm
::
vec3
m
aTargetPosition
=
rBarInfo
.
maPos
;
glm
::
vec3
aTargetPosition
=
rBarInfo
.
maPos
;
m
aTargetPosition
.
z
+=
240
;
aTargetPosition
.
z
+=
240
;
m
aTargetPosition
.
y
+=
BAR_SIZE_Y
/
2.0
f
;
aTargetPosition
.
y
+=
BAR_SIZE_Y
/
2.0
f
;
Size
aSize
=
mrWindow
.
GetSizePixel
();
Size
aSize
=
mrWindow
.
GetSizePixel
();
mrWindow
.
getContext
().
setWinSize
(
aSize
);
mrWindow
.
getContext
().
setWinSize
(
aSize
);
mpRenderThread
=
rtl
::
Reference
<
RenderThread
>
(
new
RenderAnimationThread
(
this
,
maCameraPosition
,
m
aTargetPosition
,
STEPS
));
mpRenderThread
=
rtl
::
Reference
<
RenderThread
>
(
new
RenderAnimationThread
(
this
,
maCameraPosition
,
aTargetPosition
,
STEPS
));
mrWindow
.
getContext
().
resetCurrent
();
mrWindow
.
getContext
().
resetCurrent
();
mpRenderThread
->
launch
();
mpRenderThread
->
launch
();
...
@@ -830,16 +829,16 @@ void GL3DBarChart::render()
...
@@ -830,16 +829,16 @@ void GL3DBarChart::render()
void
GL3DBarChart
::
mouseDragMove
(
const
Point
&
rStartPos
,
const
Point
&
rEndPos
,
sal_uInt16
)
void
GL3DBarChart
::
mouseDragMove
(
const
Point
&
rStartPos
,
const
Point
&
rEndPos
,
sal_uInt16
)
{
{
long
d
irection
=
rEndPos
.
X
()
-
rStartPos
.
X
();
long
nD
irection
=
rEndPos
.
X
()
-
rStartPos
.
X
();
osl
::
MutexGuard
aGuard
(
maMutex
);
osl
::
MutexGuard
aGuard
(
maMutex
);
if
((
maRenderEvent
==
EVENT_NONE
)
||
(
maRenderEvent
==
EVENT_SHOW_SCROLL
))
if
((
maRenderEvent
==
EVENT_NONE
)
||
(
maRenderEvent
==
EVENT_SHOW_SCROLL
))
maRenderEvent
=
d
irection
>
0
?
EVENT_DRAG_RIGHT
:
EVENT_DRAG_LEFT
;
maRenderEvent
=
nD
irection
>
0
?
EVENT_DRAG_RIGHT
:
EVENT_DRAG_LEFT
;
if
(
d
irection
<
0
)
if
(
nD
irection
<
0
)
{
{
mnCornerId
=
(
mnCornerId
+
1
)
%
4
;
mnCornerId
=
(
mnCornerId
+
1
)
%
4
;
moveToCorner
();
moveToCorner
();
}
}
else
if
(
d
irection
>
0
)
else
if
(
nD
irection
>
0
)
{
{
mnCornerId
=
mnCornerId
-
1
;
mnCornerId
=
mnCornerId
-
1
;
if
(
mnCornerId
<
0
)
if
(
mnCornerId
<
0
)
...
@@ -932,20 +931,20 @@ void GL3DBarChart::contextDestroyed()
...
@@ -932,20 +931,20 @@ void GL3DBarChart::contextDestroyed()
void
GL3DBarChart
::
addScreenTextShape
(
OUString
&
nStr
,
glm
::
vec2
rLeftTop
,
float
nTextHeight
,
glm
::
vec3
rPos
,
sal_uInt32
nEvent
)
void
GL3DBarChart
::
addScreenTextShape
(
OUString
&
nStr
,
glm
::
vec2
rLeftTop
,
float
nTextHeight
,
glm
::
vec3
rPos
,
sal_uInt32
nEvent
)
{
{
maScreenTextShapes
.
push_back
(
new
opengl3D
::
ScreenText
(
mpRenderer
.
get
(),
*
mpTextCache
,
nStr
,
nEvent
));
maScreenTextShapes
.
push_back
(
new
opengl3D
::
ScreenText
(
mpRenderer
.
get
(),
*
mpTextCache
,
nStr
,
nEvent
));
opengl3D
::
TextCacheItem
tmp
TextCache
=
mpTextCache
->
getText
(
nStr
);
opengl3D
::
TextCacheItem
a
TextCache
=
mpTextCache
->
getText
(
nStr
);
float
rectWidth
=
(
float
)
tmpTextCache
.
maSize
.
Width
()
/
(
float
)
tmp
TextCache
.
maSize
.
Height
()
*
0.05
;
float
nRectWidth
=
(
float
)
aTextCache
.
maSize
.
Width
()
/
(
float
)
a
TextCache
.
maSize
.
Height
()
*
0.05
;
opengl3D
::
ScreenText
*
pScreenText
=
static_cast
<
opengl3D
::
ScreenText
*>
(
&
maScreenTextShapes
.
back
());
opengl3D
::
ScreenText
*
pScreenText
=
static_cast
<
opengl3D
::
ScreenText
*>
(
&
maScreenTextShapes
.
back
());
pScreenText
->
setPosition
(
rLeftTop
,
glm
::
vec2
(
rLeftTop
.
x
+
r
ectWidth
,
rLeftTop
.
y
-
nTextHeight
),
rPos
);
pScreenText
->
setPosition
(
rLeftTop
,
glm
::
vec2
(
rLeftTop
.
x
+
nR
ectWidth
,
rLeftTop
.
y
-
nTextHeight
),
rPos
);
}
}
void
GL3DBarChart
::
updateRenderFPS
()
void
GL3DBarChart
::
updateRenderFPS
()
{
{
int
a
DeltaMs
=
calcTimeInterval
(
maFPSRenderStartTime
,
maFPSRenderEndTime
);
int
n
DeltaMs
=
calcTimeInterval
(
maFPSRenderStartTime
,
maFPSRenderEndTime
);
if
(
a
DeltaMs
>=
FPS_TIME
)
if
(
n
DeltaMs
>=
FPS_TIME
)
{
{
osl_getSystemTime
(
&
maFPSRenderEndTime
);
osl_getSystemTime
(
&
maFPSRenderEndTime
);
a
DeltaMs
=
calcTimeInterval
(
maFPSRenderStartTime
,
maFPSRenderEndTime
);
n
DeltaMs
=
calcTimeInterval
(
maFPSRenderStartTime
,
maFPSRenderEndTime
);
int
iFPS
=
miFrameCount
*
1000
/
a
DeltaMs
;
int
iFPS
=
miFrameCount
*
1000
/
n
DeltaMs
;
maFPS
=
OUString
(
"Render FPS: "
)
+
OUString
::
number
(
iFPS
);
maFPS
=
OUString
(
"Render FPS: "
)
+
OUString
::
number
(
iFPS
);
miFrameCount
=
0
;
miFrameCount
=
0
;
osl_getSystemTime
(
&
maFPSRenderStartTime
);
osl_getSystemTime
(
&
maFPSRenderStartTime
);
...
@@ -978,17 +977,17 @@ void GL3DBarChart::updateScreenText()
...
@@ -978,17 +977,17 @@ void GL3DBarChart::updateScreenText()
void
GL3DBarChart
::
updateDataUpdateFPS
()
void
GL3DBarChart
::
updateDataUpdateFPS
()
{
{
int
a
DeltaMs
=
calcTimeInterval
(
maDataUpdateStartTime
,
maDataUpdateEndTime
);
int
n
DeltaMs
=
calcTimeInterval
(
maDataUpdateStartTime
,
maDataUpdateEndTime
);
if
(
a
DeltaMs
>=
DATAUPDATE_FPS_TIME
)
if
(
n
DeltaMs
>=
DATAUPDATE_FPS_TIME
)
{
{
int
iFPS
=
miDataUpdateCounter
*
1000
/
a
DeltaMs
;
int
iFPS
=
miDataUpdateCounter
*
1000
/
n
DeltaMs
;
if
(
iFPS
)
if
(
iFPS
)
{
{
maDataUpdateFPS
=
OUString
(
"Data Update FPS: "
)
+
OUString
::
number
(
iFPS
);
maDataUpdateFPS
=
OUString
(
"Data Update FPS: "
)
+
OUString
::
number
(
iFPS
);
}
}
else
else
{
{
float
fFPS
=
(
float
)
miDataUpdateCounter
*
1000
/
(
float
)
a
DeltaMs
;
float
fFPS
=
(
float
)
miDataUpdateCounter
*
1000
/
(
float
)
n
DeltaMs
;
maDataUpdateFPS
=
OUString
(
"Data Update FPS: "
)
+
OUString
::
number
(
fFPS
);
maDataUpdateFPS
=
OUString
(
"Data Update FPS: "
)
+
OUString
::
number
(
fFPS
);
}
}
miDataUpdateCounter
=
0
;
miDataUpdateCounter
=
0
;
...
@@ -1000,125 +999,125 @@ void GL3DBarChart::updateDataUpdateFPS()
...
@@ -1000,125 +999,125 @@ void GL3DBarChart::updateDataUpdateFPS()
void
GL3DBarChart
::
recordBarHistory
(
sal_uInt32
&
nBarID
,
float
&
nVal
)
void
GL3DBarChart
::
recordBarHistory
(
sal_uInt32
&
nBarID
,
float
&
nVal
)
{
{
std
::
list
<
float
>
&
al
ist
=
maBarHistory
[
nBarID
];
std
::
list
<
float
>
&
aL
ist
=
maBarHistory
[
nBarID
];
if
(
a
l
ist
.
size
()
==
HISTORY_NUM
)
if
(
a
L
ist
.
size
()
==
HISTORY_NUM
)
a
l
ist
.
pop_front
();
a
L
ist
.
pop_front
();
a
l
ist
.
push_back
(
nVal
);
a
L
ist
.
push_back
(
nVal
);
}
}
void
GL3DBarChart
::
updateClickEvent
()
void
GL3DBarChart
::
updateClickEvent
()
{
{
if
(
maRenderEvent
==
EVENT_CLICK
)
if
(
maRenderEvent
==
EVENT_CLICK
)
{
{
std
::
list
<
float
>
&
al
ist
=
maBarHistory
[
mSelectBarId
];
std
::
list
<
float
>
&
aL
ist
=
maBarHistory
[
mSelectBarId
];
sal_uInt32
idex
=
0
;
sal_uInt32
idex
=
0
;
for
(
std
::
list
<
float
>::
iterator
it
=
a
list
.
begin
();
it
!=
al
ist
.
end
();
it
++
)
for
(
std
::
list
<
float
>::
iterator
it
=
a
List
.
begin
();
it
!=
aL
ist
.
end
();
it
++
)
{
{
OUString
b
arValue
;
OUString
aB
arValue
;
if
(
idex
+
1
==
a
l
ist
.
size
())
if
(
idex
+
1
==
a
L
ist
.
size
())
{
{
b
arValue
=
OUString
(
"Value: "
)
+
OUString
::
number
(
*
it
);
aB
arValue
=
OUString
(
"Value: "
)
+
OUString
::
number
(
*
it
);
maScreenTextShapes
.
push_back
(
new
opengl3D
::
ScreenText
(
mpRenderer
.
get
(),
*
mpTextCache
,
b
arValue
,
CALC_POS_EVENT_ID
));
maScreenTextShapes
.
push_back
(
new
opengl3D
::
ScreenText
(
mpRenderer
.
get
(),
*
mpTextCache
,
aB
arValue
,
CALC_POS_EVENT_ID
));
opengl3D
::
TextCacheItem
tmpTextCache
=
mpTextCache
->
getText
(
b
arValue
);
opengl3D
::
TextCacheItem
aTextCache
=
mpTextCache
->
getText
(
aB
arValue
);
float
rectWidth
=
(
float
)
tmpTextCache
.
maSize
.
Width
()
/
(
float
)
tmp
TextCache
.
maSize
.
Height
()
*
0.03
;
float
nRectWidth
=
(
float
)
aTextCache
.
maSize
.
Width
()
/
(
float
)
a
TextCache
.
maSize
.
Height
()
*
0.03
;
std
::
map
<
sal_uInt32
,
const
BarInformation
>::
const_iterator
itr
=
maBarMap
.
find
(
mSelectBarId
);
std
::
map
<
sal_uInt32
,
const
BarInformation
>::
const_iterator
itr
=
maBarMap
.
find
(
mSelectBarId
);
const
BarInformation
&
rBarInfo
=
itr
->
second
;
const
BarInformation
&
rBarInfo
=
itr
->
second
;
glm
::
vec3
t
extPos
=
glm
::
vec3
(
rBarInfo
.
maPos
.
x
+
BAR_SIZE_X
/
2.0
f
,
glm
::
vec3
aT
extPos
=
glm
::
vec3
(
rBarInfo
.
maPos
.
x
+
BAR_SIZE_X
/
2.0
f
,
rBarInfo
.
maPos
.
y
+
BAR_SIZE_Y
/
2.0
f
,
rBarInfo
.
maPos
.
y
+
BAR_SIZE_Y
/
2.0
f
,
rBarInfo
.
maPos
.
z
);
rBarInfo
.
maPos
.
z
);
opengl3D
::
ScreenText
*
pScreenText
=
static_cast
<
opengl3D
::
ScreenText
*>
(
&
maScreenTextShapes
.
back
());
opengl3D
::
ScreenText
*
pScreenText
=
static_cast
<
opengl3D
::
ScreenText
*>
(
&
maScreenTextShapes
.
back
());
pScreenText
->
setPosition
(
glm
::
vec2
(
-
rectWidth
/
2
,
0.03
f
),
glm
::
vec2
(
rectWidth
/
2
,
-
0.03
f
),
t
extPos
);
pScreenText
->
setPosition
(
glm
::
vec2
(
-
nRectWidth
/
2
,
0.03
f
),
glm
::
vec2
(
nRectWidth
/
2
,
-
0.03
f
),
aT
extPos
);
}
}
else
else
{
{
b
arValue
=
OUString
(
"History_"
)
+
OUString
::
number
(
idex
)
+
OUString
(
": "
)
+
OUString
::
number
(
*
it
);
aB
arValue
=
OUString
(
"History_"
)
+
OUString
::
number
(
idex
)
+
OUString
(
": "
)
+
OUString
::
number
(
*
it
);
addScreenTextShape
(
b
arValue
,
glm
::
vec2
(
0.65
f
,
0.99
f
-
(
idex
*
0.1
f
)),
0.1
f
);
addScreenTextShape
(
aB
arValue
,
glm
::
vec2
(
0.65
f
,
0.99
f
-
(
idex
*
0.1
f
)),
0.1
f
);
}
}
idex
++
;
idex
++
;
}
}
}
}
}
}
float
GL3DBarChart
::
calcScrollDistance
(
glm
::
mat4
&
mvp
,
glm
::
vec3
p
os
)
float
GL3DBarChart
::
calcScrollDistance
(
glm
::
mat4
&
rMVP
,
glm
::
vec3
aP
os
)
{
{
glm
::
vec4
screenPos
=
mvp
*
glm
::
vec4
(
p
os
,
1.0
);
glm
::
vec4
aScreenPos
=
rMVP
*
glm
::
vec4
(
aP
os
,
1.0
);
glm
::
vec3
a
ctualPos
=
glm
::
vec3
(
screenPos
.
x
/
screenPos
.
w
,
screenPos
.
y
/
s
creenPos
.
w
,
0.0
);
glm
::
vec3
a
ActualPos
=
glm
::
vec3
(
aScreenPos
.
x
/
aScreenPos
.
w
,
aScreenPos
.
y
/
aS
creenPos
.
w
,
0.0
);
return
glm
::
length
(
actualPos
);
return
glm
::
length
(
a
A
ctualPos
);
}
}
void
GL3DBarChart
::
calcDistance
(
std
::
vector
<
sal_uInt32
>
&
v
ectorNearest
)
void
GL3DBarChart
::
calcDistance
(
std
::
vector
<
sal_uInt32
>
&
rV
ectorNearest
)
{
{
int
i
=
0
;
int
i
=
0
;
glm
::
mat4
p
rojection
=
mpRenderer
->
GetProjectionMatrix
();
glm
::
mat4
aP
rojection
=
mpRenderer
->
GetProjectionMatrix
();
glm
::
mat4
v
iew
=
mpRenderer
->
GetViewMatrix
();
glm
::
mat4
aV
iew
=
mpRenderer
->
GetViewMatrix
();
glm
::
mat4
s
cale
=
mpRenderer
->
GetGlobalScaleMatrix
();
glm
::
mat4
aS
cale
=
mpRenderer
->
GetGlobalScaleMatrix
();
glm
::
mat4
mvp
=
projection
*
view
*
s
cale
;
glm
::
mat4
aMVP
=
aProjection
*
aView
*
aS
cale
;
std
::
map
<
sal_uInt32
,
const
BarInformation
>::
iterator
it
;
std
::
map
<
sal_uInt32
,
const
BarInformation
>::
iterator
it
;
for
(
it
=
maBarMap
.
begin
();
it
!=
maBarMap
.
end
();
++
it
)
for
(
it
=
maBarMap
.
begin
();
it
!=
maBarMap
.
end
();
++
it
)
{
{
sal_uInt32
nId
=
it
->
first
;
sal_uInt32
nId
=
it
->
first
;
if
(
i
<
SHOW_VALUE_COUNT
)
if
(
i
<
SHOW_VALUE_COUNT
)
{
{
v
ectorNearest
.
push_back
(
nId
);
rV
ectorNearest
.
push_back
(
nId
);
i
++
;
i
++
;
}
}
maDistanceMap
[
nId
]
=
calcScrollDistance
(
mvp
,
glm
::
vec3
(
it
->
second
.
maPos
.
x
+
BAR_SIZE_X
/
2.0
f
,
maDistanceMap
[
nId
]
=
calcScrollDistance
(
aMVP
,
glm
::
vec3
(
it
->
second
.
maPos
.
x
+
BAR_SIZE_X
/
2.0
f
,
it
->
second
.
maPos
.
y
+
BAR_SIZE_Y
/
2.0
f
,
it
->
second
.
maPos
.
y
+
BAR_SIZE_Y
/
2.0
f
,
it
->
second
.
maPos
.
z
));
it
->
second
.
maPos
.
z
));
}
}
}
}
void
GL3DBarChart
::
initDistanceHeap
(
std
::
vector
<
sal_uInt32
>
&
v
ectorNearest
)
void
GL3DBarChart
::
initDistanceHeap
(
std
::
vector
<
sal_uInt32
>
&
rV
ectorNearest
)
{
{
for
(
int
i
=
(
v
ectorNearest
.
size
()
-
2
)
/
2
;
i
>=
0
;
i
--
)
for
(
int
i
=
(
rV
ectorNearest
.
size
()
-
2
)
/
2
;
i
>=
0
;
i
--
)
{
{
keepHeap
(
v
ectorNearest
,
i
);
keepHeap
(
rV
ectorNearest
,
i
);
}
}
}
}
void
GL3DBarChart
::
keepHeap
(
std
::
vector
<
sal_uInt32
>
&
vectorNearest
,
int
i
ndex
)
void
GL3DBarChart
::
keepHeap
(
std
::
vector
<
sal_uInt32
>
&
rVectorNearest
,
int
nI
ndex
)
{
{
size_t
parentindex
=
i
ndex
;
size_t
nParentIndex
=
nI
ndex
;
while
(
parentindex
<
v
ectorNearest
.
size
())
while
(
nParentIndex
<
rV
ectorNearest
.
size
())
{
{
size_t
leftindex
=
parenti
ndex
*
2
+
1
;
size_t
nLeftIndex
=
nParentI
ndex
*
2
+
1
;
size_t
rightindex
=
lefti
ndex
+
1
;
size_t
nRightIndex
=
nLeftI
ndex
+
1
;
if
(
leftindex
>=
v
ectorNearest
.
size
())
if
(
nLeftIndex
>=
rV
ectorNearest
.
size
())
break
;
break
;
size_t
farthestindex
=
lefti
ndex
;
size_t
nFarthestIndex
=
nLeftI
ndex
;
float
farthest
=
maDistanceMap
[
vectorNearest
[
lefti
ndex
]];
float
nFarthest
=
maDistanceMap
[
rVectorNearest
[
nLeftI
ndex
]];
if
(
rightindex
<
v
ectorNearest
.
size
())
if
(
nRightIndex
<
rV
ectorNearest
.
size
())
{
{
float
right
=
maDistanceMap
[
vectorNearest
[
righti
ndex
]];
float
nRight
=
maDistanceMap
[
rVectorNearest
[
nRightI
ndex
]];
if
(
right
>
f
arthest
)
if
(
nRight
>
nF
arthest
)
{
{
farthest
=
r
ight
;
nFarthest
=
nR
ight
;
farthestindex
=
righti
ndex
;
nFarthestIndex
=
nRightI
ndex
;
}
}
}
}
float
parent
=
maDistanceMap
[
vectorNearest
[
parenti
ndex
]];
float
nParent
=
maDistanceMap
[
rVectorNearest
[
nParentI
ndex
]];
if
(
parent
>=
f
arthest
)
if
(
nParent
>=
nF
arthest
)
break
;
break
;
else
else
{
{
swapVector
(
parentindex
,
farthestindex
,
v
ectorNearest
);
swapVector
(
nParentIndex
,
nFarthestIndex
,
rV
ectorNearest
);
parentindex
=
farthesti
ndex
;
nParentIndex
=
nFarthestI
ndex
;
}
}
}
}
}
}
void
GL3DBarChart
::
swapVector
(
int
i
,
int
j
,
std
::
vector
<
sal_uInt32
>
&
v
ectorNearest
)
void
GL3DBarChart
::
swapVector
(
int
i
,
int
j
,
std
::
vector
<
sal_uInt32
>
&
rV
ectorNearest
)
{
{
sal_uInt32
tmp
=
v
ectorNearest
[
i
];
sal_uInt32
nTmp
=
rV
ectorNearest
[
i
];
vectorNearest
[
i
]
=
v
ectorNearest
[
j
];
rVectorNearest
[
i
]
=
rV
ectorNearest
[
j
];
vectorNearest
[
j
]
=
t
mp
;
rVectorNearest
[
j
]
=
nT
mp
;
}
}
void
GL3DBarChart
::
getNearestBars
(
std
::
vector
<
sal_uInt32
>
&
v
ectorNearest
)
void
GL3DBarChart
::
getNearestBars
(
std
::
vector
<
sal_uInt32
>
&
rV
ectorNearest
)
{
{
calcDistance
(
v
ectorNearest
);
calcDistance
(
rV
ectorNearest
);
initDistanceHeap
(
v
ectorNearest
);
initDistanceHeap
(
rV
ectorNearest
);
std
::
map
<
sal_uInt32
,
float
>::
iterator
it
;
std
::
map
<
sal_uInt32
,
float
>::
iterator
it
;
int
i
=
0
;
int
i
=
0
;
for
(
it
=
maDistanceMap
.
begin
();
it
!=
maDistanceMap
.
end
();
++
it
)
for
(
it
=
maDistanceMap
.
begin
();
it
!=
maDistanceMap
.
end
();
++
it
)
...
@@ -1126,12 +1125,12 @@ void GL3DBarChart::getNearestBars(std::vector<sal_uInt32> &vectorNearest)
...
@@ -1126,12 +1125,12 @@ void GL3DBarChart::getNearestBars(std::vector<sal_uInt32> &vectorNearest)
i
++
;
i
++
;
if
(
i
<=
SHOW_VALUE_COUNT
)
if
(
i
<=
SHOW_VALUE_COUNT
)
continue
;
continue
;
float
d
istance
=
it
->
second
;
float
nD
istance
=
it
->
second
;
float
Heaphead
=
maDistanceMap
[
v
ectorNearest
[
0
]];
float
nHeaphead
=
maDistanceMap
[
rV
ectorNearest
[
0
]];
if
(
distance
<
Heaphead
)
if
(
nDistance
<
n
Heaphead
)
{
{
v
ectorNearest
[
0
]
=
it
->
first
;
rV
ectorNearest
[
0
]
=
it
->
first
;
keepHeap
(
v
ectorNearest
,
0
);
keepHeap
(
rV
ectorNearest
,
0
);
}
}
}
}
}
}
...
@@ -1140,32 +1139,33 @@ void GL3DBarChart::updateScroll()
...
@@ -1140,32 +1139,33 @@ void GL3DBarChart::updateScroll()
{
{
if
((
maRenderEvent
==
EVENT_SCROLL
)
||
(
maRenderEvent
==
EVENT_SHOW_SCROLL
))
if
((
maRenderEvent
==
EVENT_SCROLL
)
||
(
maRenderEvent
==
EVENT_SHOW_SCROLL
))
{
{
float
m
inDistance
=
0.0
f
;
float
fM
inDistance
=
0.0
f
;
std
::
vector
<
BarInformation
>
b
arInfoList
;
std
::
vector
<
BarInformation
>
aB
arInfoList
;
for
(
size_t
i
=
0
;
i
<
maVectorNearest
.
size
();
i
++
)
for
(
size_t
i
=
0
;
i
<
maVectorNearest
.
size
();
i
++
)
{
{
//get bar height position
//get bar height position
std
::
map
<
sal_uInt32
,
const
BarInformation
>::
const_iterator
itr
=
maBarMap
.
find
(
maVectorNearest
[
i
]);
std
::
map
<
sal_uInt32
,
const
BarInformation
>::
const_iterator
itr
=
maBarMap
.
find
(
maVectorNearest
[
i
]);
const
BarInformation
&
rBarInfo
=
itr
->
second
;
const
BarInformation
&
rBarInfo
=
itr
->
second
;
b
arInfoList
.
push_back
(
rBarInfo
);
aB
arInfoList
.
push_back
(
rBarInfo
);
glm
::
vec3
p
os
=
rBarInfo
.
maPos
;
glm
::
vec3
aP
os
=
rBarInfo
.
maPos
;
minDistance
=
(
minDistance
==
0.0
f
)
?
glm
::
length
(
p
os
-
maCameraPosition
)
:
fMinDistance
=
(
fMinDistance
==
0.0
f
)
?
glm
::
length
(
aP
os
-
maCameraPosition
)
:
std
::
min
(
glm
::
length
(
pos
-
maCameraPosition
),
m
inDistance
);
std
::
min
(
glm
::
length
(
aPos
-
maCameraPosition
),
fM
inDistance
);
}
}
if
(
minDistance
<=
SHOW_SCROLL_TEXT_DISTANCE
)
if
(
fMinDistance
<=
SHOW_SCROLL_TEXT_DISTANCE
)
{
{
//update scroll value
//update scroll value
for
(
size_t
i
=
0
;
i
<
b
arInfoList
.
size
();
i
++
)
for
(
size_t
i
=
0
;
i
<
aB
arInfoList
.
size
();
i
++
)
{
{
OUString
barValue
=
OUString
(
"Value: "
)
+
OUString
::
number
(
b
arInfoList
[
i
].
mnVal
);
OUString
aBarValue
=
OUString
(
"Value: "
)
+
OUString
::
number
(
aB
arInfoList
[
i
].
mnVal
);
maScreenTextShapes
.
push_back
(
new
opengl3D
::
ScreenText
(
mpRenderer
.
get
(),
*
mpTextCache
,
b
arValue
,
CALC_POS_EVENT_ID
));
maScreenTextShapes
.
push_back
(
new
opengl3D
::
ScreenText
(
mpRenderer
.
get
(),
*
mpTextCache
,
aB
arValue
,
CALC_POS_EVENT_ID
));
opengl3D
::
TextCacheItem
tmpTextCache
=
mpTextCache
->
getText
(
b
arValue
);
opengl3D
::
TextCacheItem
aTextCache
=
mpTextCache
->
getText
(
aB
arValue
);
float
rectWidth
=
(
float
)
tmpTextCache
.
maSize
.
Width
()
/
(
float
)
tmp
TextCache
.
maSize
.
Height
()
*
0.03
;
float
nRectWidth
=
(
float
)
aTextCache
.
maSize
.
Width
()
/
(
float
)
a
TextCache
.
maSize
.
Height
()
*
0.03
;
glm
::
vec3
textPos
=
glm
::
vec3
(
b
arInfoList
[
i
].
maPos
.
x
+
BAR_SIZE_X
/
2.0
f
,
glm
::
vec3
aTextPos
=
glm
::
vec3
(
aB
arInfoList
[
i
].
maPos
.
x
+
BAR_SIZE_X
/
2.0
f
,
b
arInfoList
[
i
].
maPos
.
y
+
BAR_SIZE_Y
/
2.0
f
,
aB
arInfoList
[
i
].
maPos
.
y
+
BAR_SIZE_Y
/
2.0
f
,
b
arInfoList
[
i
].
maPos
.
z
);
aB
arInfoList
[
i
].
maPos
.
z
);
opengl3D
::
ScreenText
*
pScreenText
=
static_cast
<
opengl3D
::
ScreenText
*>
(
&
maScreenTextShapes
.
back
());
opengl3D
::
ScreenText
*
pScreenText
=
static_cast
<
opengl3D
::
ScreenText
*>
(
&
maScreenTextShapes
.
back
());
pScreenText
->
setPosition
(
glm
::
vec2
(
-
rectWidth
/
2
,
0.03
f
),
glm
::
vec2
(
rectWidth
/
2
,
-
0.03
f
),
t
extPos
);
pScreenText
->
setPosition
(
glm
::
vec2
(
-
nRectWidth
/
2
,
0.03
f
),
glm
::
vec2
(
nRectWidth
/
2
,
-
0.03
f
),
aT
extPos
);
}
}
}
}
}
}
...
...
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