// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <Draw_Drawable3D.hxx>
+#include <NCollection_DataMap.hxx>
#include <Draw_Display.hxx>
-#include <Draw_Drawable3D.hxx>
-#include <Standard_Type.hxx>
+#include <Standard_NotImplemented.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(Draw_Drawable3D, Standard_Transient)
+
+//! Return the map of factory functions.
+static NCollection_DataMap<Standard_CString, Draw_Drawable3D::FactoryFunction_t>& getFactoryMap()
+{
+ static NCollection_DataMap<Standard_CString, Draw_Drawable3D::FactoryFunction_t> myToolMap;
+ return myToolMap;
+}
+
+//=======================================================================
+//function : RegisterFactory
+//purpose :
+//=======================================================================
+void Draw_Drawable3D::RegisterFactory (const Standard_CString theType,
+ const FactoryFunction_t& theFactory)
+{
+ getFactoryMap().Bind (theType, theFactory);
+}
-IMPLEMENT_STANDARD_RTTIEXT(Draw_Drawable3D,Standard_Transient)
+//=======================================================================
+//function : Restore
+//purpose :
+//=======================================================================
+Handle(Draw_Drawable3D) Draw_Drawable3D::Restore (const Standard_CString theType,
+ Standard_IStream& theStream)
+{
+ FactoryFunction_t aFactory = NULL;
+ if (getFactoryMap().Find (theType, aFactory))
+ {
+ return aFactory (theStream);
+ }
+ return Handle(Draw_Drawable3D)();
+}
//=======================================================================
//function : Draw_Drawable3D
-//purpose :
+//purpose :
//=======================================================================
-Draw_Drawable3D::Draw_Drawable3D() :
- myXmin(0.0),
+Draw_Drawable3D::Draw_Drawable3D()
+: myXmin(0.0),
myXmax(0.0),
myYmin(0.0),
myYmax(0.0),
+ myName(NULL),
isVisible(Standard_False),
- isProtected(Standard_False),
- myName(NULL)
+ isProtected(Standard_False)
{
}
//=======================================================================
//function : PickReject
-//purpose :
+//purpose :
//=======================================================================
-
Standard_Boolean Draw_Drawable3D::PickReject(const Standard_Real X,
const Standard_Real Y,
const Standard_Real Prec) const
return ((X+Prec < myXmin) || (X-Prec > myXmax) ||
(Y+Prec < myYmin) || (Y-Prec > myYmax));
}
-
//=======================================================================
//function : Copy
-//purpose :
+//purpose :
//=======================================================================
-
-Handle(Draw_Drawable3D) Draw_Drawable3D::Copy() const
+Handle(Draw_Drawable3D) Draw_Drawable3D::Copy() const
{
return this;
}
-
//=======================================================================
//function : Dump
-//purpose :
+//purpose :
//=======================================================================
-
-void Draw_Drawable3D::Dump(Standard_OStream& S) const
+void Draw_Drawable3D::Dump (Standard_OStream& S) const
{
S << myXmin << " " << myXmax << "\n";
S << myYmin << " " << myYmax << "\n";
}
-
//=======================================================================
-//function : Whatis
-//purpose :
+//function : Save
+//purpose :
//=======================================================================
-
-void Draw_Drawable3D::Whatis(Draw_Interpretor& S) const
+void Draw_Drawable3D::Save (Standard_OStream& ) const
{
- S << "drawable 3d";
+ throw Standard_NotImplemented ("Draw_Drawable3D::Save() should be redefined in sub-class");
}
//=======================================================================
-//function : Is3D
-//purpose :
-//=======================================================================
-
-Standard_Boolean Draw_Drawable3D::Is3D() const
-{
- return Standard_True;
-}
-
-//=======================================================================
-//function : SetBounds
-//purpose :
-//=======================================================================
-
-void Draw_Drawable3D::SetBounds(const Standard_Real xmin,
- const Standard_Real xmax,
- const Standard_Real ymin,
- const Standard_Real ymax)
-{
- myXmin = xmin;
- myXmax = xmax;
- myYmin = ymin;
- myYmax = ymax;
-}
-
-
-//=======================================================================
-//function : Bounds
-//purpose :
+//function : Whatis
+//purpose :
//=======================================================================
-
-void Draw_Drawable3D::Bounds(Standard_Real& xmin,
- Standard_Real& xmax,
- Standard_Real& ymin,
- Standard_Real& ymax) const
+void Draw_Drawable3D::Whatis(Draw_Interpretor& S) const
{
- xmin = myXmin;
- xmax = myXmax;
- ymin = myYmin;
- ymax = myYmax;
+ S << "drawable 3d";
}
-
-