OSDN Git Service

リファクタリング
authorqw_fuku <fkhideaki@gmail.com>
Sat, 5 Mar 2016 14:14:57 +0000 (23:14 +0900)
committerqw_fuku <fkhideaki@gmail.com>
Sat, 5 Mar 2016 14:14:57 +0000 (23:14 +0900)
Src/LibQtGeoViewerCore/GeomObject.h
Src/LibQtGeoViewerCore/Image/GeomTexture.cpp
Src/LibQtGeoViewerCore/Image/GeomTexture.h
Src/LibQtGeoViewerCore/MeshBuf.cpp
Src/LibQtGeoViewerCore/MeshBuf.h
Src/LibQtGeoViewerCore/Transform.cpp
Src/QtGeoViewer/View3D.cpp
Src/QtGeoViewer/View3D.h

index e6d572e..58583d6 100644 (file)
@@ -70,19 +70,21 @@ private:
 
 public:
        // \90e\83R\83\93\83e\83i\8fã\82Å\82Ì\83I\83u\83W\83F\83N\83g\82Ì\83C\83\93\83f\83b\83N\83X
-       int                        m_ObjectIndex;
-       std::string                m_Name;
+       int m_ObjectIndex;
 
-       std::string                m_FilePath;
-       geom::GeomFileFormat       m_FileFormat;
+       std::string m_Name;
 
-       bool                       m_Visible;
-       bool                       m_VertexOnlyMode;
+       // \83t\83@\83C\83\8b\82©\82ç\8dì\82ç\82ê\82½\83I\83u\83W\83F\83N\83g\82Ì\83\\81[\83X\8fî\95ñ
+       std::string m_FilePath;
+       geom::GeomFileFormat m_FileFormat;
+
+       bool m_Visible;
+       bool m_VertexOnlyMode;
 
        boost::ptr_vector<MeshBuf> m_MeshAry;
-       GeoNodeTree                m_GTree;
+       GeoNodeTree m_GTree;
 
-       TextureLib                 m_TextureLib;
+       TextureLib m_TextureLib;
 };
 
 
index f7d47da..8a8f0cd 100644 (file)
@@ -38,5 +38,26 @@ bool GeomTextureSet::IsActiveTexture(gl::GlTexture* tex) const
        return true;
 }
 
+gl::GlTexture* GeomTextureSet::TakeTexture(TextureType type)
+{
+       gl::GlTexture* tex_buf = NULL;
+       if (type == TextureType::Color)
+               std::swap(tex_buf, TexColor);
+       else if (type == TextureType::Normal)
+               std::swap(tex_buf, TexNormal);
+
+       return tex_buf;
+}
+
+bool GeomTextureSet::IsChild(const gl::GlTexture* tex) const
+{
+       if (TexColor == tex)
+               return true;
+       if (TexNormal == tex)
+               return true;
+
+       return false;
+}
+
 
 }
index 4caa52f..9e7a17c 100644 (file)
@@ -27,6 +27,8 @@ public:
        {
                TexColor  = NULL;
                TexNormal = NULL;
+
+               TexScale = 1.0f;
        }
 
        void ReleaseAll(void)
@@ -49,6 +51,9 @@ public:
        gl::GlTexture* GetTexNormal(void) { return TexNormal; }
        gl::MatcapImage& GetTexMatcap(void) { return TexMatcap; }
 
+       gl::GlTexture* TakeTexture(TextureType type);
+       bool IsChild(const gl::GlTexture* tex) const;
+
 private:
        bool IsActiveTexture(gl::GlTexture* tex) const;
 
@@ -57,6 +62,8 @@ public:
        gl::GlTexture* TexNormal;
        gl::MatcapImage TexMatcap;
 
+       float TexScale;
+
 private:
        MeshBuf* Parent;
 };
index 2fdf119..5fe2b72 100644 (file)
@@ -292,12 +292,7 @@ void MeshBuf::ReleaseTextureUnit(int mat_idx, TextureType type)
 
 void MeshBuf::ReleaseTextureUnit(GeomTextureSet* ts, TextureType type)
 {
-       gl::GlTexture* tex_buf = NULL;
-       if (type == TextureType::Color)
-               std::swap(tex_buf, ts->TexColor);
-       else if (type == TextureType::Normal)
-               std::swap(tex_buf, ts->TexNormal);
-
+       gl::GlTexture* tex_buf = ts->TakeTexture(type);
        if (!IsExistTextureLink(tex_buf))
                tex_buf->FinalizeTexture();
 }
@@ -306,9 +301,7 @@ bool MeshBuf::IsExistTextureLink(gl::GlTexture* tex)
 {
        for (GeomTextureSet& ts : m_Textures)
        {
-               if (ts.TexColor == tex)
-                       return true;
-               if (ts.TexNormal == tex)
+               if (ts.IsChild(tex))
                        return true;
        }
 
index 5a4fc60..0db3aae 100644 (file)
@@ -173,14 +173,14 @@ public:
        bool m_Visible;
        std::string m_Name;
 
-       lib_geo::BaseMesh   m_Mesh;
+       lib_geo::BaseMesh m_Mesh;
        std::map<int, bool> m_SelVerts;
 
        std::map<int, FaceGroup> m_FaceMatGroup;
 
        std::vector<VertexLinker> m_VertLinkers;
 
-       lib_geo::CrossSection              m_CrossSection;
+       lib_geo::CrossSection m_CrossSection;
        std::vector<lib_geo::CrossSection> m_CrossSectionLog;
 
        PolylineContext m_PolylineContext;
index f5e05e7..675e34f 100644 (file)
@@ -39,7 +39,7 @@ lm::vec3f SceneTransform::TransformVec(const lm::vec3f& v) const
 
        m_Rotate.vec_rotate(dst);
 
-       if(!IsRightHandCoord())
+       if (!IsRightHandCoord())
                dst.z = -dst.z;
 
        return dst;
@@ -49,7 +49,7 @@ lm::vec3f SceneTransform::InverseTransformVec(const lm::vec3f& v) const
 {
        lm::vec3f dst = v;
 
-       if(!IsRightHandCoord())
+       if (!IsRightHandCoord())
                dst.z = -dst.z;
 
        m_Rotate.get_conjugate().vec_rotate(dst);
@@ -105,7 +105,7 @@ void SceneTransform::GetRotateMatrix(lm::matrix4f& mat)
        mat.at(2, 0) = ez.x; mat.at(2, 1) = ez.y; mat.at(2, 2) = ez.z; mat.at(2, 3) = 0.0f;
        mat.at(3, 0) = 0.0f; mat.at(3, 1) = 0.0f; mat.at(3, 2) = 0.0f; mat.at(3, 3) = 1.0f;
 
-       if(!IsRightHandCoord())
+       if (!IsRightHandCoord())
                mat = mat * lm::matrix4f::get_scale(1.0f, 1.0f, -1.0f);
 }
 
@@ -128,7 +128,7 @@ void SceneTransform::UpdateQuatRotate(void)
        lm::vec3f ey(0.0f, 0.0f, 0.0f);
        lm::vec3f ez(0.0f, 0.0f, 0.0f);
 
-       switch(m_CoordType)
+       switch (m_CoordType)
        {
        case COORD_RUF: ex.x = 1.0f; ey.y = 1.0f; ez.z = 1.0f; break;
        case COORD_RUB: ex.x = 1.0f; ey.y = 1.0f; ez.z = 1.0f; break;
@@ -151,7 +151,7 @@ void SceneTransform::UpdateQuatRotate(void)
 //! RightHand = OpenGL standard coordinate
 bool SceneTransform::IsRightHandCoord(void) const
 {
-       switch(m_CoordType)
+       switch (m_CoordType)
        {
        case COORD_RUF:
        case COORD_UFR:
@@ -165,7 +165,7 @@ bool SceneTransform::IsRightHandCoord(void) const
 
 void SceneTransform::SetGLForeFaceAngle(void)
 {
-       if(IsRightHandCoord())
+       if (IsRightHandCoord())
                glFrontFace(GL_CCW);
        else
                glFrontFace(GL_CW);
@@ -182,9 +182,8 @@ void TextureTransform::SetGLTransform(void)
        glPushAttrib(GL_TRANSFORM_BIT);
 
        glMatrixMode(GL_TEXTURE);
-
        glLoadIdentity();
-       if(m_FlipY)
+       if (m_FlipY)
        {
                glTranslated(0, 1, 0);
                glScaled(1, -1, 1);
index 2a2b704..73559de 100644 (file)
@@ -2597,36 +2597,40 @@ void View3D::DrawAllGeomForShadowbuf(void)
 
 void View3D::PushAndIdentityGLModelProjMatrix(void)
 {
-       glMatrixMode(GL_PROJECTION);
-       glPushMatrix();
-       glLoadIdentity();
-       glMatrixMode(GL_MODELVIEW);
-       glPushMatrix();
-       glLoadIdentity();
+       PushBeginGLMat(GL_PROJECTION);
+       PushBeginGLMat(GL_MODELVIEW);
 }
 
 void View3D::PopGLModelProjMatrix(void)
 {
-       glMatrixMode(GL_MODELVIEW);
-       glPopMatrix();
-       glMatrixMode(GL_PROJECTION);
-       glPopMatrix();
+       PopEndGLMat(GL_MODELVIEW);
+       PopEndGLMat(GL_PROJECTION);
        glMatrixMode(GL_MODELVIEW);
 }
 
 void View3D::PushAndIdentityGLAllMatrix(void)
 {
        PushAndIdentityGLModelProjMatrix();
-       glMatrixMode(GL_TEXTURE);
+       PushBeginGLMat(GL_TEXTURE);
+}
+
+void View3D::PopGLAllMatrix(void)
+{
+       PopEndGLMat(GL_TEXTURE);
+       PopGLModelProjMatrix();
+}
+
+void View3D::PushBeginGLMat(GLenum mode)
+{
+       glMatrixMode(mode);
        glPushMatrix();
        glLoadIdentity();
 }
 
-void View3D::PopGLAllMatrix(void)
+void View3D::PopEndGLMat(GLenum mode)
 {
-       glMatrixMode(GL_TEXTURE);
+       glMatrixMode(mode);
        glPopMatrix();
-       PopGLModelProjMatrix();
 }
 
 void View3D::RenderCurrentTextureToBillboard(int left, int top, int width, int height)
index 3c160ea..01bf3a4 100644 (file)
@@ -213,6 +213,9 @@ protected:
        void PopGLModelProjMatrix(void);
        void PopGLAllMatrix(void);
 
+       void PushBeginGLMat(GLenum mode);
+       void PopEndGLMat(GLenum mode);
+
        void SelectClosestVertOnMouseDown(QMouseEvent *e);
        void SelectObjectOnMouseDown(QMouseEvent *e);