1 // Created on: 1991-04-24
2 // Created by: Arnaud BOUZY
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <Draw_Drawable3D.hxx>
19 #include <NCollection_DataMap.hxx>
20 #include <Draw_Display.hxx>
21 #include <Standard_CStringHasher.hxx>
22 #include <Standard_NotImplemented.hxx>
24 IMPLEMENT_STANDARD_RTTIEXT(Draw_Drawable3D, Standard_Transient)
26 //! Return the map of factory functions.
27 static NCollection_DataMap<Standard_CString, Draw_Drawable3D::FactoryFunction_t, Standard_CStringHasher>& getFactoryMap()
29 static NCollection_DataMap<Standard_CString, Draw_Drawable3D::FactoryFunction_t, Standard_CStringHasher> myToolMap;
33 //=======================================================================
34 //function : RegisterFactory
36 //=======================================================================
37 void Draw_Drawable3D::RegisterFactory (const Standard_CString theType,
38 const FactoryFunction_t& theFactory)
40 getFactoryMap().Bind (theType, theFactory);
43 //=======================================================================
46 //=======================================================================
47 Handle(Draw_Drawable3D) Draw_Drawable3D::Restore (const Standard_CString theType,
48 Standard_IStream& theStream)
50 FactoryFunction_t aFactory = NULL;
51 if (getFactoryMap().Find (theType, aFactory))
53 return aFactory (theStream);
55 return Handle(Draw_Drawable3D)();
58 //=======================================================================
59 //function : Draw_Drawable3D
61 //=======================================================================
62 Draw_Drawable3D::Draw_Drawable3D()
68 isVisible(Standard_False),
69 isProtected(Standard_False)
73 //=======================================================================
74 //function : PickReject
76 //=======================================================================
77 Standard_Boolean Draw_Drawable3D::PickReject(const Standard_Real X,
78 const Standard_Real Y,
79 const Standard_Real Prec) const
81 return ((X+Prec < myXmin) || (X-Prec > myXmax) ||
82 (Y+Prec < myYmin) || (Y-Prec > myYmax));
85 //=======================================================================
88 //=======================================================================
89 Handle(Draw_Drawable3D) Draw_Drawable3D::Copy() const
94 //=======================================================================
97 //=======================================================================
98 void Draw_Drawable3D::Dump (Standard_OStream& S) const
100 S << myXmin << " " << myXmax << "\n";
101 S << myYmin << " " << myYmax << "\n";
104 //=======================================================================
107 //=======================================================================
108 void Draw_Drawable3D::Save (Standard_OStream& ) const
110 throw Standard_NotImplemented ("Draw_Drawable3D::Save() should be redefined in sub-class");
113 //=======================================================================
116 //=======================================================================
117 void Draw_Drawable3D::Whatis(Draw_Interpretor& S) const