X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=blobdiff_plain;f=src%2FMeshVS%2FMeshVS_NodalColorPrsBuilder.cxx;h=566f3f7899c661f421e2c8e0bb14f2ae869135b1;hp=8de4fcf5b47e1da8cc16421c3fbb47ecbe6a9aba;hb=bf75be98674edf9cd074ce92ed73675e79283762;hpb=ab8fcacf2854849ee89b30a3d376eea6362c36f8 diff --git a/src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx b/src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx index 8de4fcf5b4..566f3f7899 100755 --- a/src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx +++ b/src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -69,48 +70,46 @@ */ class MeshVS_ImageTexture2D : public Graphic3d_Texture2D { + public: - MeshVS_ImageTexture2D (Handle(Graphic3d_StructureManager) theSM, - const Image_PixMap& theImg); - virtual ~MeshVS_ImageTexture2D(); + + MeshVS_ImageTexture2D (const Handle(Image_PixMap)& theImg) + : Graphic3d_Texture2D ("", Graphic3d_TOT_2D), + myImage (theImg) + { + myParams->SetModulate (Standard_True); + myParams->SetFilter (Graphic3d_TOTF_BILINEAR); + } + + virtual ~MeshVS_ImageTexture2D() + { + // + } + + virtual Standard_Boolean IsDone() const + { + return !myImage.IsNull() && !myImage->IsEmpty(); + } + + virtual Handle(Image_PixMap) GetImage() const + { + return myImage; + } + +private: + + Handle(Image_PixMap) myImage; public: + DEFINE_STANDARD_RTTI(MeshVS_ImageTexture2D) + }; DEFINE_STANDARD_HANDLE (MeshVS_ImageTexture2D, Graphic3d_Texture2D) IMPLEMENT_STANDARD_HANDLE (MeshVS_ImageTexture2D, Graphic3d_Texture2D) IMPLEMENT_STANDARD_RTTIEXT(MeshVS_ImageTexture2D, Graphic3d_Texture2D) -MeshVS_ImageTexture2D::MeshVS_ImageTexture2D (Handle(Graphic3d_StructureManager) theSM, - const Image_PixMap& theImg) -: Graphic3d_Texture2D (theSM, "", Graphic3d_TOT_2D) -{ - MyCInitTexture.doModulate = 1; - MyCInitTexture.doRepeat = 0; - MyCInitTexture.Mode = (int)Graphic3d_TOTM_MANUAL; - MyCInitTexture.doLinear = 1; - MyCInitTexture.sx = 1.0F; - MyCInitTexture.sy = 1.0F; - MyCInitTexture.tx = 0.0F; - MyCInitTexture.ty = 0.0F; - MyCInitTexture.angle = 0.0F; - MyCInitTexture.sparams[0] = 0.0F; - MyCInitTexture.sparams[1] = 0.0F; - MyCInitTexture.sparams[2] = 0.0F; - MyCInitTexture.sparams[3] = 0.0F; - MyCInitTexture.tparams[0] = 0.0F; - MyCInitTexture.tparams[1] = 0.0F; - MyCInitTexture.tparams[2] = 0.0F; - MyCInitTexture.tparams[3] = 0.0F; - Update(); - LoadTexture(theImg); -} - -MeshVS_ImageTexture2D::~MeshVS_ImageTexture2D() -{ -} - //================================================================ // Function : getNearestPow2 // Purpose : Returns the nearest power of two greater than the @@ -723,21 +722,15 @@ Handle(Graphic3d_Texture2D) MeshVS_NodalColorPrsBuilder::CreateTexture() const return NULL; } - Handle(PrsMgr_PresentationManager3d) aPrsMgr = GetPresentationManager(); - if (aPrsMgr.IsNull()) - { - return NULL; - } - // create and fill image with colors - Image_PixMap anImage; - if (!anImage.InitTrash (Image_PixMap::ImgRGBA, Standard_Size(getNearestPow2 (aColorsNb)), 2)) + Handle(Image_PixMap) anImage = new Image_PixMap(); + if (!anImage->InitTrash (Image_PixMap::ImgRGBA, Standard_Size(getNearestPow2 (aColorsNb)), 2)) { return NULL; } - anImage.SetTopDown (false); - Image_PixMapData& aData = anImage.EditData(); + anImage->SetTopDown (false); + Image_PixMapData& aData = anImage->EditData(); for (Standard_Size aCol = 0; aCol < Standard_Size(aColorsNb); ++aCol) { const Quantity_Color& aSrcColor = myTextureColorMap.Value (Standard_Integer(aCol) + 1); @@ -759,7 +752,7 @@ Handle(Graphic3d_Texture2D) MeshVS_NodalColorPrsBuilder::CreateTexture() const }}; // fill second row - for (Standard_Size aCol = (Standard_Size )aColorsNb; aCol < anImage.SizeX(); ++aCol) + for (Standard_Size aCol = (Standard_Size )aColorsNb; aCol < anImage->SizeX(); ++aCol) { aData.ChangeValue (0, aCol) = aLastColor; } @@ -771,11 +764,11 @@ Handle(Graphic3d_Texture2D) MeshVS_NodalColorPrsBuilder::CreateTexture() const int(255.0 * myInvalidColor.Blue()), 0xFF }}; - for (Standard_Size aCol = 0; aCol < anImage.SizeX(); ++aCol) + for (Standard_Size aCol = 0; aCol < anImage->SizeX(); ++aCol) { aData.ChangeValue (1, aCol) = anInvalidColor; } // create texture - return new MeshVS_ImageTexture2D (aPrsMgr->StructureManager(), anImage); + return new MeshVS_ImageTexture2D (anImage); }