summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorweigao <weigao@multicorewareinc.com>2014-08-02 16:35:48 +0800
committerMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-08-06 20:45:11 +0200
commit22b45c0adc4693075d3958e1b2d696cb40619f3a (patch)
treed40d00b0e416133043e9b0afa62f9d16507432ef /chart2
parent7dcc31ed61bad3d3d649667f2fb890c878ac69c3 (diff)
add high light bar code for click
Change-Id: I412173d01fe6611027b45169fe4cd9be5b4cc4df
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/view/charttypes/GL3DBarChart.cxx3
-rw-r--r--chart2/source/view/inc/GL3DRenderer.hxx10
-rw-r--r--chart2/source/view/main/GL3DRenderer.cxx57
3 files changed, 70 insertions, 0 deletions
diff --git a/chart2/source/view/charttypes/GL3DBarChart.cxx b/chart2/source/view/charttypes/GL3DBarChart.cxx
index 36319372c878..5cba5177ebae 100644
--- a/chart2/source/view/charttypes/GL3DBarChart.cxx
+++ b/chart2/source/view/charttypes/GL3DBarChart.cxx
@@ -230,6 +230,8 @@ void RenderBenchMarkThread::MoveCamera()
{
mnStep = 0;
mbExecuting = false;
+ if (mpChart->maRenderEvent == EVENT_CLICK)
+ mpChart->mpRenderer->EndClick();
mpChart->maRenderEvent = EVENT_NONE;
}
}
@@ -282,6 +284,7 @@ void RenderBenchMarkThread::MoveToBar()
maStepDirection = (maTargetDirection - mpChart->maCameraDirection)/((float)mnStepsTotal);
mpChart->maClickCond.set();
mbExecuting = true;
+ mpChart->mpRenderer->StartClick(mpChart->mSelectBarId);
}
MoveCamera();
}
diff --git a/chart2/source/view/inc/GL3DRenderer.hxx b/chart2/source/view/inc/GL3DRenderer.hxx
index 3e731a3b8eae..9ada8f8ebccc 100644
--- a/chart2/source/view/inc/GL3DRenderer.hxx
+++ b/chart2/source/view/inc/GL3DRenderer.hxx
@@ -93,6 +93,7 @@ struct Extrude3DInfo
bool twoSidesLighting;
glm::vec4 extrudeColor;
glm::vec4 id;
+ sal_uInt32 orgID;
float xScale;
float yScale;
float zScale;
@@ -165,6 +166,8 @@ struct BatchBarInfo
std::vector <glm::mat4> modelMatrixList;
std::vector <glm::mat3> normalMatrixList;
std::vector <glm::vec4> colorList;
+ std::map<sal_uInt32, unsigned int> mapId2Color;
+ glm::vec4 selectBarColor;
};
class OpenGL3DRenderer
@@ -204,6 +207,8 @@ public:
void ReleaseShapes();
void ReleaseScreenTextShapes();
void ReleaseTextTexture();
+ void StartClick(sal_uInt32 &selectID);
+ void EndClick();
private:
void MoveModelf( const PosVecf3& trans, const PosVecf3& angle, const PosVecf3& scale);
@@ -263,6 +268,8 @@ private:
glm::vec3 vTopLeft,glm::vec3 vTopRight,
glm::vec3 vBottomRight, glm::vec3 vBottomLeft,
sal_uInt32 nUniqueId);
+ void SetHighLightBar(BatchBarInfo &barInfo);
+ void DisableHighLightBar(BatchBarInfo &barInfo);
private:
struct ShaderResources
@@ -436,7 +443,10 @@ private:
glm::vec4 m_LightColor[MAX_LIGHT_NUM];
glm::vec4 m_PositionWorldspace[MAX_LIGHT_NUM];
float m_fLightPower[MAX_LIGHT_NUM];
+ //for 3.0 end
std::vector<GLuint> m_Texturelist;
+ bool m_bHighLighting;
+ sal_uInt32 m_uiSelectID;
};
}
diff --git a/chart2/source/view/main/GL3DRenderer.cxx b/chart2/source/view/main/GL3DRenderer.cxx
index 693a8f9f5b53..e6f5e95d9d72 100644
--- a/chart2/source/view/main/GL3DRenderer.cxx
+++ b/chart2/source/view/main/GL3DRenderer.cxx
@@ -107,6 +107,8 @@ OpenGL3DRenderer::OpenGL3DRenderer():
, m_Batch3DUBOBuffer(0)
, m_Batch3DActualSizeLight(0)
, m_iLightNum(0)
+ , m_bHighLighting(false)
+ , m_uiSelectID(0)
{
m_Polygon3DInfo.lineOnly = false;
m_Polygon3DInfo.twoSidesLighting = false;
@@ -1140,6 +1142,7 @@ void OpenGL3DRenderer::EndAddPolygon3DObjectPoint()
void OpenGL3DRenderer::AddShape3DExtrudeObject(bool roundedCorner, sal_uInt32 nColor, sal_uInt32 specular, const glm::mat4& modelMatrix, sal_uInt32 nUniqueId)
{
m_Extrude3DInfo.id = getColorAsVector(nUniqueId);
+ m_Extrude3DInfo.orgID = nUniqueId;
glm::vec4 tranform = modelMatrix * glm::vec4(0.0, 0.0, 0.0, 1.0);
glm::vec4 DirX = modelMatrix * glm::vec4(1.0, 0.0, 0.0, 0.0);
glm::vec4 DirY = modelMatrix * glm::vec4(0.0, 1.0, 0.0, 0.0);
@@ -2107,6 +2110,7 @@ void OpenGL3DRenderer::ReleaseBatchBarInfo()
m_BarSurface[i].modelMatrixList.clear();
m_BarSurface[i].normalMatrixList.clear();
m_BarSurface[i].colorList.clear();
+ m_BarSurface[i].mapId2Color.clear();
}
}
@@ -2145,6 +2149,7 @@ void OpenGL3DRenderer::GetBatchMiddleInfo(const Extrude3DInfo &extrude3D)
m_BarSurface[MIDDLE_SURFACE].modelMatrixList.push_back(m_Model);
m_BarSurface[MIDDLE_SURFACE].normalMatrixList.push_back(normalInverseTranspos);
m_BarSurface[MIDDLE_SURFACE].colorList.push_back(extrude3D.material.materialColor);
+ m_BarSurface[MIDDLE_SURFACE].mapId2Color[extrude3D.orgID] = m_BarSurface[MIDDLE_SURFACE].colorList.size() - 1;
}
void OpenGL3DRenderer::GetBatchTopAndFlatInfo(const Extrude3DInfo &extrude3D)
@@ -2181,6 +2186,7 @@ void OpenGL3DRenderer::GetBatchTopAndFlatInfo(const Extrude3DInfo &extrude3D)
m_BarSurface[TOP_SURFACE].modelMatrixList.push_back(m_Model);
m_BarSurface[TOP_SURFACE].normalMatrixList.push_back(normalInverseTranspos);
m_BarSurface[TOP_SURFACE].colorList.push_back(extrude3D.material.materialColor);
+ m_BarSurface[TOP_SURFACE].mapId2Color[extrude3D.orgID] = m_BarSurface[TOP_SURFACE].colorList.size() - 1;
glm::mat4 aTranslationMatrix = glm::translate(glm::vec3(trans.x, trans.y, trans.z));
glm::mat4 flatScale = glm::scale(glm::vec3(xyScale, xyScale, xyScale));
@@ -2192,6 +2198,7 @@ void OpenGL3DRenderer::GetBatchTopAndFlatInfo(const Extrude3DInfo &extrude3D)
m_BarSurface[FLAT_BOTTOM_SURFACE].modelMatrixList.push_back(m_Model);
m_BarSurface[FLAT_BOTTOM_SURFACE].normalMatrixList.push_back(normalInverseTranspos);
m_BarSurface[FLAT_BOTTOM_SURFACE].colorList.push_back(extrude3D.material.materialColor);
+ m_BarSurface[FLAT_BOTTOM_SURFACE].mapId2Color[extrude3D.orgID] = m_BarSurface[FLAT_BOTTOM_SURFACE].colorList.size() - 1;
}
void OpenGL3DRenderer::GetBatchBarsInfo()
@@ -2215,14 +2222,64 @@ void OpenGL3DRenderer::GetBatchBarsInfo()
m_BarSurface[0].modelMatrixList.push_back(m_Model);
m_BarSurface[0].normalMatrixList.push_back(normalInverseTranspos);
m_BarSurface[0].colorList.push_back(extrude3DInfo.material.materialColor);
+ m_BarSurface[0].mapId2Color[extrude3DInfo.orgID] = m_BarSurface[0].colorList.size() - 1;
}
}
}
+void OpenGL3DRenderer::SetHighLightBar(BatchBarInfo &barInfo)
+{
+ std::map<sal_uInt32, unsigned int> ::iterator it = barInfo.mapId2Color.find(m_uiSelectID);
+ if (it != barInfo.mapId2Color.end())
+ {
+ unsigned int idx = it->second;
+ barInfo.selectBarColor = barInfo.colorList[idx];
+ barInfo.colorList[idx] = glm::vec4(1.0, 1.0, 1.0, 1.0);
+ }
+}
+
+void OpenGL3DRenderer::DisableHighLightBar(BatchBarInfo &barInfo)
+{
+ std::map<sal_uInt32, unsigned int> ::iterator it = barInfo.mapId2Color.find(m_uiSelectID);
+ if (it != barInfo.mapId2Color.end())
+ {
+ unsigned int idx = it->second;
+ barInfo.colorList[idx] = barInfo.selectBarColor;
+ }
+}
+
+void OpenGL3DRenderer::StartClick(sal_uInt32 &selectID)
+{
+ m_bHighLighting = true;
+ m_uiSelectID = selectID;
+ for (unsigned int i = 0; i < 3; i++)
+ {
+ SetHighLightBar(m_BarSurface[i]);
+ }
+}
+
+void OpenGL3DRenderer::EndClick()
+{
+ m_bHighLighting = false;
+ for (unsigned int i = 0; i < 3; i++)
+ {
+ DisableHighLightBar(m_BarSurface[i]);
+ }
+}
+
void OpenGL3DRenderer::RenderBatchBars(bool bNewScene)
{
if(bNewScene)
+ {
GetBatchBarsInfo();
+ if (m_bHighLighting)
+ {
+ for (unsigned int i = 0; i < 3; i++)
+ {
+ SetHighLightBar(m_BarSurface[i]);
+ }
+ }
+ }
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);