0024131: TKOpenGL redesign GPU memory management for markers presentation
[occt.git] / src / Graphic3d / Graphic3d_AspectMarker3d.cxx
index c6599d4..fa602f5 100755 (executable)
 // purpose or non-infringement. Please see the License for the specific terms
 // and conditions governing the rights and limitations under the License.
 
-
-
-
-//-Version     
-
-//-Design      Declaration of variables specific to the context
-//             of trace of markers 3d
-
-// Rappels     Context of trace of markers 3d inherits the context
-//             defined by :
-//             - the color
-//             - the type of marker
-//             - the scale
-
-//-Warning     
-
-//-References  
-
-//-Language    C++ 2.0
-
-//-Declarations
-
-// for the class
 #include <Graphic3d_AspectMarker3d.ixx>
 #include <TColStd_Array1OfByte.hxx>
-
-//-Aliases
-
-//-Global data definitions
-
-//-Constructors
-
-//-Destructors
-
-//-Methods, in order
-
-Graphic3d_AspectMarker3d::Graphic3d_AspectMarker3d ()
-     :Aspect_AspectMarker(), MyTextureWidth(0), MyTextureHeight(0)
-{  
-}
-
-Graphic3d_AspectMarker3d::Graphic3d_AspectMarker3d (const Aspect_TypeOfMarker AType, const Quantity_Color& AColor, const Standard_Real AScaleOrId ):
-Aspect_AspectMarker( AColor, AType, AScaleOrId ), MyTextureWidth(0), MyTextureHeight(0)
-{ 
-}
-
-
-Graphic3d_AspectMarker3d::Graphic3d_AspectMarker3d (const Aspect_TypeOfMarker AType, 
-                                                   const Quantity_Color& AColor, 
-                                                   const Standard_Real AScaleOrId, 
-                                                   const Standard_Integer AWidth,
-                                                   const Standard_Integer AHeight,
-                                                   const Handle(TColStd_HArray1OfByte)& ATexture ):
-Aspect_AspectMarker( AColor, AType, AScaleOrId ), MyTexture( ATexture ), MyTextureWidth(AWidth), MyTextureHeight(AHeight)
-{
-  /*for( Standard_Integer aIndex = ATexture.Lower(); aIndex <= ATexture.Upper(); aIndex++ )
-    {
-      MyTexture.SetValue( aIndex, ATexture.Value( aIndex ) );
-    }
-  */
-  
-}
-
-void Graphic3d_AspectMarker3d::GetTextureSize(Standard_Integer& AWidth, Standard_Integer& AHeight)
+#include <Image_PixMap.hxx>
+#include <Graphic3d_MarkerImage.hxx>
+
+// =======================================================================
+// function : Graphic3d_AspectMarker3d
+// purpose  :
+// =======================================================================
+Graphic3d_AspectMarker3d::Graphic3d_AspectMarker3d()
+: Aspect_AspectMarker()
+{}
+
+// =======================================================================
+// function : Graphic3d_AspectMarker3d
+// purpose  :
+// =======================================================================
+Graphic3d_AspectMarker3d::Graphic3d_AspectMarker3d (const Aspect_TypeOfMarker theType,
+                                                    const Quantity_Color&     theColor,
+                                                    const Standard_Real       theScale)
+: Aspect_AspectMarker (theColor, theType, theScale)
+{}
+
+// =======================================================================
+// function : Graphic3d_AspectMarker3d
+// purpose  :
+// =======================================================================
+Graphic3d_AspectMarker3d::Graphic3d_AspectMarker3d (const Quantity_Color&  theColor,
+                                                    const Standard_Integer theWidth,
+                                                    const Standard_Integer theHeight,
+                                                    const Handle(TColStd_HArray1OfByte)& theTextureBitMap)
+: Aspect_AspectMarker (theColor, Aspect_TOM_USERDEFINED, 1.0),
+  myMarkerImage (new Graphic3d_MarkerImage (theTextureBitMap, theWidth, theHeight))
+{}
+
+// =======================================================================
+// function : Graphic3d_AspectMarker3d
+// purpose  :
+// =======================================================================
+Graphic3d_AspectMarker3d::Graphic3d_AspectMarker3d (const Handle(Image_PixMap)& theTextureImage)
+: Aspect_AspectMarker (Quantity_NOC_YELLOW, Aspect_TOM_USERDEFINED, 1.0),
+  myMarkerImage (new Graphic3d_MarkerImage (theTextureImage))
+{}
+
+// =======================================================================
+// function : GetTextureSize
+// purpose  :
+// =======================================================================
+void Graphic3d_AspectMarker3d::GetTextureSize (Standard_Integer& theWidth,
+                                               Standard_Integer& theHeight) const
 {
-  AWidth = MyTextureWidth;
-  AHeight = MyTextureHeight;
+  if (!myMarkerImage.IsNull())
+  {
+    myMarkerImage->GetTextureSize (theWidth, theHeight);
+  }
+  else
+  {
+    theWidth  = 0;
+    theHeight = 0;
+  }
 }
 
-const Handle(TColStd_HArray1OfByte)& Graphic3d_AspectMarker3d::GetTexture()
+// =======================================================================
+// function : GetMarkerImage
+// purpose  :
+// =======================================================================
+const Handle(Graphic3d_MarkerImage)& Graphic3d_AspectMarker3d::GetMarkerImage() const
 {
-  return MyTexture;
+  return myMarkerImage;
 }
 
-void Graphic3d_AspectMarker3d::SetTexture (const Standard_Integer AWidth,
-                                          const Standard_Integer AHeight,
-                                           const Handle(TColStd_HArray1OfByte)& ATexture )
+// =======================================================================
+// function : SetBitMap
+// purpose  :
+// =======================================================================
+void Graphic3d_AspectMarker3d::SetBitMap (const Standard_Integer theWidth,
+                                          const Standard_Integer theHeight,
+                                          const Handle(TColStd_HArray1OfByte)& theTextureBitMap)
 {
-   MyTextureWidth = AWidth;
-   MyTextureHeight = AHeight;
-     
-   MyTexture = ATexture;
+  myMarkerImage.Nullify();
+  myMarkerImage = new Graphic3d_MarkerImage (theTextureBitMap, theWidth, theHeight);
 }