Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:24

0001 // Created on: 1991-04-24
0002 // Created by: Arnaud BOUZY
0003 // Copyright (c) 1991-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Draw_Drawable3D_HeaderFile
0018 #define _Draw_Drawable3D_HeaderFile
0019 
0020 #include <Standard_CString.hxx>
0021 #include <Standard_Type.hxx>
0022 #include <Standard_Transient.hxx>
0023 #include <Standard_IStream.hxx>
0024 #include <Standard_OStream.hxx>
0025 #include <Draw_Interpretor.hxx>
0026 
0027 class Draw_Display;
0028 
0029 DEFINE_STANDARD_HANDLE(Draw_Drawable3D, Standard_Transient)
0030 
0031 class Draw_Drawable3D : public Standard_Transient
0032 {
0033   DEFINE_STANDARD_RTTIEXT(Draw_Drawable3D, Standard_Transient)
0034 public:
0035 
0036   //! Function type for restoring drawable from stream.
0037   typedef Handle(Draw_Drawable3D)(*FactoryFunction_t)(Standard_IStream& theStream);
0038 
0039   //! Register factory for restoring drawable from stream (opposite to Draw_Drawable3D::Save()).
0040   //! @param theType [in] class name
0041   //! @param theFactory [in] factory function
0042   Standard_EXPORT static void RegisterFactory (const Standard_CString theType,
0043                                                const FactoryFunction_t& theFactory);
0044 
0045   //! Restore drawable from stream (opposite to Draw_Drawable3D::Save()).
0046   //! @param theType [in] class name
0047   //! @param theStream [in] input stream
0048   //! @return restored drawable or NULL if factory is undefined for specified class
0049   Standard_EXPORT static Handle(Draw_Drawable3D) Restore (const Standard_CString theType,
0050                                                           Standard_IStream& theStream);
0051 
0052   //! @def Draw_Drawable3D_FACTORY
0053   //! Auxiliary macros defining Draw_Drawable3D restoration API to sub-class.
0054   #define Draw_Drawable3D_FACTORY \
0055     static void RegisterFactory() { Draw_Drawable3D::RegisterFactory (get_type_name(), &Restore); } \
0056     Standard_EXPORT static Handle(Draw_Drawable3D) Restore (Standard_IStream& theStream);
0057 
0058 public:
0059 
0060   Standard_EXPORT virtual void DrawOn (Draw_Display& dis) const = 0;
0061   
0062   //! Returns True if the pick is outside the box
0063   Standard_EXPORT virtual Standard_Boolean PickReject (const Standard_Real X, const Standard_Real Y, const Standard_Real Prec) const;
0064   
0065   //! For variable copy.
0066   Standard_EXPORT virtual Handle(Draw_Drawable3D) Copy() const;
0067   
0068   //! For variable dump.
0069   Standard_EXPORT virtual void Dump (Standard_OStream& S) const;
0070 
0071   //! Save drawable into stream; default implementation raises Standard_NotImplemented exception.
0072   Standard_EXPORT virtual void Save (Standard_OStream& theStream) const;
0073 
0074   //! For variable whatis command. Set as a result the type of the variable.
0075   Standard_EXPORT virtual void Whatis (Draw_Interpretor& I) const;
0076   
0077   //! Is a 3D object. (Default True).
0078   virtual bool Is3D() const { return true; }
0079 
0080   //! Return TRUE if object can be displayed.
0081   virtual bool IsDisplayable() const { return true; }
0082 
0083   void SetBounds (const Standard_Real theXMin, const Standard_Real theXMax,
0084                   const Standard_Real theYMin, const Standard_Real theYMax)
0085   {
0086     myXmin = theXMin;
0087     myXmax = theXMax;
0088     myYmin = theYMin;
0089     myYmax = theYMax;
0090   }
0091 
0092   void Bounds (Standard_Real& theXMin, Standard_Real& theXMax,
0093                Standard_Real& theYMin, Standard_Real& theYMax) const
0094   {
0095     theXMin = myXmin;
0096     theXMax = myXmax;
0097     theYMin = myYmin;
0098     theYMax = myYmax;
0099   }
0100 
0101   Standard_Boolean Visible() const { return isVisible; }
0102 
0103   void Visible (const Standard_Boolean V) { isVisible = V; }
0104 
0105   Standard_Boolean Protected() const { return isProtected; }
0106 
0107   void Protected (const Standard_Boolean P) { isProtected = P; }
0108 
0109   Standard_CString Name() const { return myName; }
0110 
0111   virtual void Name (const Standard_CString N) { myName = N; }
0112 
0113 protected:
0114 
0115   Standard_EXPORT Draw_Drawable3D();
0116 
0117 private:
0118 
0119   Standard_Real myXmin;
0120   Standard_Real myXmax;
0121   Standard_Real myYmin;
0122   Standard_Real myYmax;
0123   Standard_CString myName;
0124   Standard_Boolean isVisible;
0125   Standard_Boolean isProtected;
0126 
0127 };
0128 
0129 #endif // _Draw_Drawable3D_HeaderFile