For MSVC compiler (version 12 and above), Handle_Class types are defined as true classes (inheriting corresponding opencascade::handle<Class>) to allow using them in "public" statement of C++/CLI language, to make these classes recognizable by other C++/CLI libraries.
Code to test operations with Handle_ class is added to QAHandleOps test command
//! Sets the texture source. <theTexturePixMap> specifies image data.
//! Please note that the data should be in Bottom-Up order, the flag of Image_PixMap::IsTopDown() will be ignored by graphic driver.
//! Setting texture source using this method resets the source by filename (if was set previously).
- Standard_EXPORT virtual void SetTexturePixMap (const Image_PixMap_Handle& theTexturePixMap);
+ Standard_EXPORT virtual void SetTexturePixMap (const Handle(Image_PixMap)& theTexturePixMap);
//! @return flag to control texture mapping (for presentation mode 3)
Standard_Boolean TextureMapState() const { return myToMapTexture; }
#include <Standard_Real.hxx>
#include <Standard_Integer.hxx>
#include <TColStd_HArray1OfByte.hxx>
-#include <Image_PixMap_Handle.hxx>
+#include <Image_PixMap.hxx>
class Quantity_Color;
//! Creates a context table for marker primitives
//! defined with the specified values.
- Standard_EXPORT Graphic3d_AspectMarker3d(const Image_PixMap_Handle& theTextureImage);
+ Standard_EXPORT Graphic3d_AspectMarker3d(const Handle(Image_PixMap)& theTextureImage);
//! Returns marker's texture size.
Standard_EXPORT void GetTextureSize (Standard_Integer& theWidth, Standard_Integer& theHeight) const;
#include <Graphic3d_NameOfTexture1D.hxx>
#include <Graphic3d_TextureMap.hxx>
#include <Graphic3d_TypeOfTexture.hxx>
-#include <Image_PixMap_Handle.hxx>
+#include <Image_PixMap.hxx>
#include <Standard_Integer.hxx>
class Standard_OutOfRange;
class TCollection_AsciiString;
Standard_EXPORT Graphic3d_Texture1D(const Graphic3d_NameOfTexture1D theName, const Graphic3d_TypeOfTexture theType);
- Standard_EXPORT Graphic3d_Texture1D(const Image_PixMap_Handle& thePixMap, const Graphic3d_TypeOfTexture theType);
+ Standard_EXPORT Graphic3d_Texture1D(const Handle(Image_PixMap)& thePixMap, const Graphic3d_TypeOfTexture theType);
#include <Graphic3d_Texture1D.hxx>
#include <Graphic3d_NameOfTexture1D.hxx>
-#include <Image_PixMap_Handle.hxx>
class TCollection_AsciiString;
Standard_EXPORT Graphic3d_Texture1Dmanual(const Graphic3d_NameOfTexture1D theNOT);
//! Creates a texture from the pixmap.
- Standard_EXPORT Graphic3d_Texture1Dmanual(const Image_PixMap_Handle& thePixMap);
+ Standard_EXPORT Graphic3d_Texture1Dmanual(const Handle(Image_PixMap)& thePixMap);
#include <Standard_ShortReal.hxx>
#include <Graphic3d_Texture1D.hxx>
#include <Graphic3d_NameOfTexture1D.hxx>
-#include <Image_PixMap_Handle.hxx>
class TCollection_AsciiString;
Standard_EXPORT Graphic3d_Texture1Dsegment(const Graphic3d_NameOfTexture1D theNOT);
//! Creates a texture from the pixmap.
- Standard_EXPORT Graphic3d_Texture1Dsegment(const Image_PixMap_Handle& thePixMap);
+ Standard_EXPORT Graphic3d_Texture1Dsegment(const Handle(Image_PixMap)& thePixMap);
//! Sets the texture application bounds. Defines the way
//! the texture is stretched across facets.
#include <Graphic3d_NameOfTexture2D.hxx>
#include <Graphic3d_TextureMap.hxx>
#include <Graphic3d_TypeOfTexture.hxx>
-#include <Image_PixMap_Handle.hxx>
+#include <Image_PixMap.hxx>
#include <Standard_Integer.hxx>
class Standard_OutOfRange;
class TCollection_AsciiString;
Standard_EXPORT Graphic3d_Texture2D(const Graphic3d_NameOfTexture2D theName, const Graphic3d_TypeOfTexture theType);
- Standard_EXPORT Graphic3d_Texture2D(const Image_PixMap_Handle& thePixMap, const Graphic3d_TypeOfTexture theType);
+ Standard_EXPORT Graphic3d_Texture2D(const Handle(Image_PixMap)& thePixMap, const Graphic3d_TypeOfTexture theType);
#include <Graphic3d_Texture2D.hxx>
#include <Graphic3d_NameOfTexture2D.hxx>
-#include <Image_PixMap_Handle.hxx>
class TCollection_AsciiString;
Standard_EXPORT Graphic3d_Texture2Dmanual(const Graphic3d_NameOfTexture2D theNOT);
//! Creates a texture from the pixmap.
- Standard_EXPORT Graphic3d_Texture2Dmanual(const Image_PixMap_Handle& thePixMap);
+ Standard_EXPORT Graphic3d_Texture2Dmanual(const Handle(Image_PixMap)& thePixMap);
#include <Graphic3d_NameOfTexturePlane.hxx>
#include <Graphic3d_Texture2D.hxx>
#include <Graphic3d_NameOfTexture2D.hxx>
-#include <Image_PixMap_Handle.hxx>
#include <Standard_ShortReal.hxx>
class TCollection_AsciiString;
Standard_EXPORT Graphic3d_Texture2Dplane(const Graphic3d_NameOfTexture2D theNOT);
//! Creates a texture from the pixmap.
- Standard_EXPORT Graphic3d_Texture2Dplane(const Image_PixMap_Handle& thePixMap);
+ Standard_EXPORT Graphic3d_Texture2Dplane(const Handle(Image_PixMap)& thePixMap);
//! Defines the texture projection plane for texture coordinate S
//! default is <1.0, 0.0, 0.0, 0.0>
#include <Graphic3d_NameOfTextureEnv.hxx>
#include <Graphic3d_TextureRoot.hxx>
-#include <Image_PixMap_Handle.hxx>
#include <Standard_Integer.hxx>
class Standard_OutOfRange;
class TCollection_AsciiString;
Standard_EXPORT Graphic3d_TextureEnv(const Graphic3d_NameOfTextureEnv theName);
//! Creates an environment texture from the pixmap.
- Standard_EXPORT Graphic3d_TextureEnv(const Image_PixMap_Handle& thePixMap);
+ Standard_EXPORT Graphic3d_TextureEnv(const Handle(Image_PixMap)& thePixMap);
//! Returns the name of the predefined textures or NOT_ENV_UNKNOWN
#include <Graphic3d_TextureRoot.hxx>
#include <Graphic3d_TypeOfTexture.hxx>
-#include <Image_PixMap_Handle.hxx>
#include <Standard_Boolean.hxx>
#include <Graphic3d_LevelOfTextureAnisotropy.hxx>
class TCollection_AsciiString;
Standard_EXPORT Graphic3d_TextureMap(const TCollection_AsciiString& theFileName, const Graphic3d_TypeOfTexture theType);
- Standard_EXPORT Graphic3d_TextureMap(const Image_PixMap_Handle& thePixMap, const Graphic3d_TypeOfTexture theType);
+ Standard_EXPORT Graphic3d_TextureMap(const Handle(Image_PixMap)& thePixMap, const Graphic3d_TypeOfTexture theType);
#include <Standard_Type.hxx>
#include <TCollection_AsciiString.hxx>
-#include <Image_PixMap_Handle.hxx>
+#include <Image_PixMap.hxx>
#include <OSD_Path.hxx>
#include <Graphic3d_TypeOfTexture.hxx>
#include <MMgt_TShared.hxx>
//!
//! @return texture identifier.
Standard_EXPORT const TCollection_AsciiString& GetId() const;
-
//! This method will be called by graphic driver each time when texture resource should be created.
//! Default constructors allow defining the texture source as path to texture image or directly as pixmap.
//! Inheritors may dynamically generate the image.
//! Notice, image data should be in Bottom-Up order (see Image_PixMap::IsTopDown())!
//! @return the image for texture.
- Standard_EXPORT virtual Image_PixMap_Handle GetImage() const;
-
+ Standard_EXPORT virtual Handle(Image_PixMap) GetImage() const;
+
//! @return low-level texture parameters
Standard_EXPORT const Handle(Graphic3d_TextureParams)& GetParams() const;
//! Creates a texture from pixmap.
//! Please note that the implementation expects the image data
//! to be in Bottom-Up order (see Image_PixMap::IsTopDown()).
- Standard_EXPORT Graphic3d_TextureRoot(const Image_PixMap_Handle& thePixmap, const Graphic3d_TypeOfTexture theType);
+ Standard_EXPORT Graphic3d_TextureRoot(const Handle(Image_PixMap)& thePixmap, const Graphic3d_TypeOfTexture theType);
Handle(Graphic3d_TextureParams) myParams;
TCollection_AsciiString myTexId;
- Image_PixMap_Handle myPixMap;
+ Handle(Image_PixMap) myPixMap;
OSD_Path myPath;
Image_Diff.hxx
Image_PixMap.cxx
Image_PixMap.hxx
-Image_PixMap_Handle.hxx
Image_PixMapData.hxx
#define _Image_PixMap_H__
#include <Image_PixMapData.hxx>
-#include <Image_PixMap_Handle.hxx>
#include <Standard_Transient.hxx>
#include <Quantity_Color.hxx>
};
+DEFINE_STANDARD_HANDLE(Image_PixMap, Standard_Transient)
+
#endif // _Image_PixMap_H__
+++ /dev/null
-// Copyright (c) 2013-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _Image_PixMap_Handle_H__
-#define _Image_PixMap_Handle_H__
-
-#include <Standard_Type.hxx>
-#include <Standard_Transient.hxx>
-
-class Image_PixMap;
-DEFINE_STANDARD_HANDLE(Image_PixMap, Standard_Transient)
-typedef Handle(Image_PixMap) Image_PixMap_Handle;
-
-#endif // _Image_PixMap_Handle_H__
const Handle(Geom_Curve)& aTmpRef (Handle(Geom_Line)::DownCast (aCurve2));
CHECK(theDI, ! aTmpRef.IsNull(), "local reference of handle to base type to temporary handle object");
+ // check operations with Handle_* classes
+ Handle(Geom_Line) hLine = aLine;
+ CHECK(theDI, ! hLine.IsNull(), "hhandle for non-null");
+
+ const Handle_Geom_Line& chLine = aLine; // cast to self const ref
+ const Handle_Geom_Curve& chCurve = aLine; // cast to base const ref
+ const Handle_Geom_Line& hhLine = hLine; // cast to self const ref
+ const Handle_Geom_Curve& hhCurve = hLine; // cast to base const ref
+ Handle_Geom_Curve hCurve = aLine; // copy from handle to derived type
+ Handle_Geom_Line phLine (aLine.get()); // construct from pointer
+
+ hLine = Handle_Geom_Line::DownCast (cCurve); // inheritance of downcast
+ CHECK(theDI, ! hLine.IsNull(), "down cast");
+
+ // comparison operators
+ CHECK(theDI, hLine == hLine, "equality of hhandle to itself");
+ CHECK(theDI, hLine == aLine, "equality of hhandle to handle");
+ CHECK(theDI, hhLine == hLine, "equality of hhandle to const");
+ CHECK(theDI, chLine == hLine, "equality of hhandle to const");
+ CHECK(theDI, hhCurve == hLine, "equality of hhandle to const");
+ CHECK(theDI, chCurve == hLine, "equality of hhandle to const");
+ CHECK(theDI, hLine, "cast to bool");
+
+ // passing hhandle as reference to base class
+ f (hLine);
+
+ // passing handle to overloaded function accepting handle to another type
+ // will fail on VC below 12 and GCC below 4.3 due to ambiguity of overloads
+#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) || (defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 3)
+ func (hLine);
+ func (chLine);
+#endif
+
+ Handle_Geom_Line qhLine = cpLine; // constructor from const pointer -- could be made explicit...
+
+ // check whether compiler will destroy reference to temporary handle
+ const Handle_Geom_Curve& hTmpRef (Handle(Geom_Line)::DownCast (aCurve2));
+ CHECK(theDI, ! hTmpRef.IsNull(), "local reference of handle to base type to temporary handle object");
+
Handle(Geom_Surface) aSurf;
(void)aSurf;
Handle(Geom_Line) xLine = cCurve; // copy from handle to base type
Handle(Geom_BSplineCurve) aBSpl (new Geom_Line (gp::Origin(), gp::DX())); // construction from pointer to incompatible type
- CHECK(theDI, aLine == aSurf, "equality of handles of incompatible types");
- CHECK(theDI, aSurf == cLine, "equality of const and non-const handle");
+ CHECK(theDI, aLine == aSurf, "equality of handles of incompatible types");
+ CHECK(theDI, aSurf == cLine, "equality of const and non-const handle");
CHECK(theDI, aSurf == cCurve, "equality of handle and base handle");
CHECK(theDI, aSurf == pLine, "equality of handle and pointer");
CHECK(theDI, pLine == aSurf, "equality of pointer and handle");
- CHECK(theDI, aSurf == cpLine, "equality of handle and const pointer");
- CHECK(theDI, cpLine != aSurf, "equality of const pointer and handle");
+ CHECK(theDI, aSurf == cpLine, "equality of handle and const pointer");
+ CHECK(theDI, cpLine != aSurf, "equality of const pointer and handle");
- CHECK(theDI, aLine != aSurf, "inequality of handles of incompatible types");
- CHECK(theDI, aSurf != cLine, "inequality of const and non-const handle");
+ CHECK(theDI, aLine != aSurf, "inequality of handles of incompatible types");
+ CHECK(theDI, aSurf != cLine, "inequality of const and non-const handle");
CHECK(theDI, aSurf != cCurve, "inequality of handle and base handle");
CHECK(theDI, aSurf != pLine, "inequality of handle and pointer");
CHECK(theDI, pLine != aSurf, "inequality of pointer and handle");
- CHECK(theDI, aSurf != cpLine, "inequality of handle and const pointer");
- CHECK(theDI, cpLine != aSurf, "inequality of const pointer and handle");
+ CHECK(theDI, aSurf != cpLine, "inequality of handle and const pointer");
+ CHECK(theDI, cpLine != aSurf, "inequality of const pointer and handle");
#endif
// ===============================================================
return ::HashCode (const_cast<Standard_Address>(static_cast<const void*>(theHandle.get())), theUpper);
}
-//! For compatibility with previous versions of OCCT, defines typedef opencascade::handle<Class> Handle(Class)
+//! For compatibility with previous versions of OCCT, define Handle_Class alias for opencascade::handle<Class>.
+#if (defined(_MSC_VER) && _MSC_VER >= 1800)
+//! For Visual Studio 2013+, define Handle_Class as non-template class to allow exporting this type in C++/CLI.
+#define DEFINE_STANDARD_HANDLECLASS(C1,C2,BC) class C1; class Handle_##C1 : public Handle(C1) \
+{ \
+public: \
+ Handle_##C1() {} \
+ Handle_##C1(Handle(C1)&& theHandle) : Handle(C1)(theHandle) {} \
+ template <class T2, typename = typename std::enable_if <std::is_base_of <C1,T2>::value>::type> \
+ inline Handle_##C1(const opencascade::handle<T2>& theOther) : Handle(C1)(theOther) {} \
+ template <class T2, typename = typename std::enable_if <std::is_base_of <C1,T2>::value>::type> \
+ inline Handle_##C1(const T2* theOther) : Handle(C1)(theOther) {} \
+ template<typename T> inline Handle_##C1& operator=(T theOther) { Handle(C1)::operator=(theOther); return *this; } \
+};
+#else
+//! For other compilers, use simple typedef
#define DEFINE_STANDARD_HANDLECLASS(C1,C2,BC) class C1; typedef Handle(C1) Handle_##C1;
+#endif
+
#define DEFINE_STANDARD_HANDLE(C1,C2) DEFINE_STANDARD_HANDLECLASS(C1,C2,Standard_Transient)
#define DEFINE_STANDARD_PHANDLE(C1,C2) DEFINE_STANDARD_HANDLECLASS(C1,C2,Standard_Persistent)
class StepRepr_ShapeAspect;
-class StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol;
-DEFINE_STANDARD_HANDLE(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod, StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod)
+DEFINE_STANDARD_HANDLE(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol, StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod)
class StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol : public StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod
{