| 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 |
| 5 | // |
| 6 | // This file is part of Open CASCADE Technology software library. |
| 7 | // |
| 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. |
| 13 | // |
| 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
| 15 | // commercial license or contractual agreement. |
| 16 | |
| 17 | #ifndef _Draw_Drawable3D_HeaderFile |
| 18 | #define _Draw_Drawable3D_HeaderFile |
| 19 | |
| 20 | #include <Standard_CString.hxx> |
| 21 | #include <Standard_Type.hxx> |
| 22 | #include <Standard_Transient.hxx> |
| 23 | #include <Standard_IStream.hxx> |
| 24 | #include <Standard_OStream.hxx> |
| 25 | #include <Draw_Interpretor.hxx> |
| 26 | |
| 27 | class Draw_Display; |
| 28 | |
| 29 | DEFINE_STANDARD_HANDLE(Draw_Drawable3D, Standard_Transient) |
| 30 | |
| 31 | class Draw_Drawable3D : public Standard_Transient |
| 32 | { |
| 33 | DEFINE_STANDARD_RTTIEXT(Draw_Drawable3D, Standard_Transient) |
| 34 | public: |
| 35 | |
| 36 | //! Function type for restoring drawable from stream. |
| 37 | typedef Handle(Draw_Drawable3D)(*FactoryFunction_t)(Standard_IStream& theStream); |
| 38 | |
| 39 | //! Register factory for restoring drawable from stream (opposite to Draw_Drawable3D::Save()). |
| 40 | //! @param theType [in] class name |
| 41 | //! @param theFactory [in] factory function |
| 42 | Standard_EXPORT static void RegisterFactory (const Standard_CString theType, |
| 43 | const FactoryFunction_t& theFactory); |
| 44 | |
| 45 | //! Restore drawable from stream (opposite to Draw_Drawable3D::Save()). |
| 46 | //! @param theType [in] class name |
| 47 | //! @param theStream [in] input stream |
| 48 | //! @return restored drawable or NULL if factory is undefined for specified class |
| 49 | Standard_EXPORT static Handle(Draw_Drawable3D) Restore (const Standard_CString theType, |
| 50 | Standard_IStream& theStream); |
| 51 | |
| 52 | //! @def Draw_Drawable3D_FACTORY |
| 53 | //! Auxiliary macros defining Draw_Drawable3D restoration API to sub-class. |
| 54 | #define Draw_Drawable3D_FACTORY \ |
| 55 | static void RegisterFactory() { Draw_Drawable3D::RegisterFactory (get_type_name(), &Restore); } \ |
| 56 | Standard_EXPORT static Handle(Draw_Drawable3D) Restore (Standard_IStream& theStream); |
| 57 | |
| 58 | public: |
| 59 | |
| 60 | Standard_EXPORT virtual void DrawOn (Draw_Display& dis) const = 0; |
| 61 | |
| 62 | //! Returns True if the pick is outside the box |
| 63 | Standard_EXPORT virtual Standard_Boolean PickReject (const Standard_Real X, const Standard_Real Y, const Standard_Real Prec) const; |
| 64 | |
| 65 | //! For variable copy. |
| 66 | Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const; |
| 67 | |
| 68 | //! For variable dump. |
| 69 | Standard_EXPORT virtual void Dump (Standard_OStream& S) const; |
| 70 | |
| 71 | //! Save drawable into stream; default implementation raises Standard_NotImplemented exception. |
| 72 | Standard_EXPORT virtual void Save (Standard_OStream& theStream) const; |
| 73 | |
| 74 | //! For variable whatis command. Set as a result the type of the variable. |
| 75 | Standard_EXPORT virtual void Whatis (Draw_Interpretor& I) const; |
| 76 | |
| 77 | //! Is a 3D object. (Default True). |
| 78 | virtual bool Is3D() const { return true; } |
| 79 | |
| 80 | //! Return TRUE if object can be displayed. |
| 81 | virtual bool IsDisplayable() const { return true; } |
| 82 | |
| 83 | void SetBounds (const Standard_Real theXMin, const Standard_Real theXMax, |
| 84 | const Standard_Real theYMin, const Standard_Real theYMax) |
| 85 | { |
| 86 | myXmin = theXMin; |
| 87 | myXmax = theXMax; |
| 88 | myYmin = theYMin; |
| 89 | myYmax = theYMax; |
| 90 | } |
| 91 | |
| 92 | void Bounds (Standard_Real& theXMin, Standard_Real& theXMax, |
| 93 | Standard_Real& theYMin, Standard_Real& theYMax) const |
| 94 | { |
| 95 | theXMin = myXmin; |
| 96 | theXMax = myXmax; |
| 97 | theYMin = myYmin; |
| 98 | theYMax = myYmax; |
| 99 | } |
| 100 | |
| 101 | Standard_Boolean Visible() const { return isVisible; } |
| 102 | |
| 103 | void Visible (const Standard_Boolean V) { isVisible = V; } |
| 104 | |
| 105 | Standard_Boolean Protected() const { return isProtected; } |
| 106 | |
| 107 | void Protected (const Standard_Boolean P) { isProtected = P; } |
| 108 | |
| 109 | Standard_CString Name() const { return myName; } |
| 110 | |
| 111 | virtual void Name (const Standard_CString N) { myName = N; } |
| 112 | |
| 113 | protected: |
| 114 | |
| 115 | Standard_EXPORT Draw_Drawable3D(); |
| 116 | |
| 117 | private: |
| 118 | |
| 119 | Standard_Real myXmin; |
| 120 | Standard_Real myXmax; |
| 121 | Standard_Real myYmin; |
| 122 | Standard_Real myYmax; |
| 123 | Standard_CString myName; |
| 124 | Standard_Boolean isVisible; |
| 125 | Standard_Boolean isProtected; |
| 126 | |
| 127 | }; |
| 128 | |
| 129 | #endif // _Draw_Drawable3D_HeaderFile |