Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-16 09:16:53

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 class Draw_Drawable3D : public Standard_Transient
0030 {
0031   DEFINE_STANDARD_RTTIEXT(Draw_Drawable3D, Standard_Transient)
0032 public:
0033   //! Function type for restoring drawable from stream.
0034   typedef occ::handle<Draw_Drawable3D> (*FactoryFunction_t)(Standard_IStream& theStream);
0035 
0036   //! Register factory for restoring drawable from stream (opposite to Draw_Drawable3D::Save()).
0037   //! @param[in] theType  class name
0038   //! @param[in] theFactory  factory function
0039   Standard_EXPORT static void RegisterFactory(const char* const        theType,
0040                                               const FactoryFunction_t& theFactory);
0041 
0042   //! Restore drawable from stream (opposite to Draw_Drawable3D::Save()).
0043   //! @param[in] theType  class name
0044   //! @param[in] theStream  input stream
0045   //! @return restored drawable or NULL if factory is undefined for specified class
0046   Standard_EXPORT static occ::handle<Draw_Drawable3D> Restore(const char* const theType,
0047                                                               Standard_IStream& theStream);
0048 
0049 //! @def Draw_Drawable3D_FACTORY
0050 //! Auxiliary macros defining Draw_Drawable3D restoration API to sub-class.
0051 #define Draw_Drawable3D_FACTORY                                                                    \
0052   static void RegisterFactory() { Draw_Drawable3D::RegisterFactory(get_type_name(), &Restore); }   \
0053   Standard_EXPORT static occ::handle<Draw_Drawable3D> Restore(Standard_IStream& theStream);
0054 
0055 public:
0056   Standard_EXPORT virtual void DrawOn(Draw_Display& dis) const = 0;
0057 
0058   //! Returns True if the pick is outside the box
0059   Standard_EXPORT virtual bool PickReject(const double X, const double Y, const double Prec) const;
0060 
0061   //! For variable copy.
0062   Standard_EXPORT virtual occ::handle<Draw_Drawable3D> Copy() const;
0063 
0064   //! For variable dump.
0065   Standard_EXPORT virtual void Dump(Standard_OStream& S) const;
0066 
0067   //! Save drawable into stream; default implementation raises Standard_NotImplemented exception.
0068   Standard_EXPORT virtual void Save(Standard_OStream& theStream) const;
0069 
0070   //! For variable whatis command. Set as a result the type of the variable.
0071   Standard_EXPORT virtual void Whatis(Draw_Interpretor& I) const;
0072 
0073   //! Is a 3D object. (Default True).
0074   virtual bool Is3D() const { return true; }
0075 
0076   //! Return TRUE if object can be displayed.
0077   virtual bool IsDisplayable() const { return true; }
0078 
0079   void SetBounds(const double theXMin,
0080                  const double theXMax,
0081                  const double theYMin,
0082                  const double theYMax)
0083   {
0084     myXmin = theXMin;
0085     myXmax = theXMax;
0086     myYmin = theYMin;
0087     myYmax = theYMax;
0088   }
0089 
0090   void Bounds(double& theXMin, double& theXMax, double& theYMin, double& theYMax) const
0091   {
0092     theXMin = myXmin;
0093     theXMax = myXmax;
0094     theYMin = myYmin;
0095     theYMax = myYmax;
0096   }
0097 
0098   bool Visible() const { return isVisible; }
0099 
0100   void Visible(const bool V) { isVisible = V; }
0101 
0102   bool Protected() const { return isProtected; }
0103 
0104   void Protected(const bool P) { isProtected = P; }
0105 
0106   const char* Name() const { return myName; }
0107 
0108   virtual void Name(const char* const N) { myName = N; }
0109 
0110 protected:
0111   Standard_EXPORT Draw_Drawable3D();
0112 
0113 private:
0114   double      myXmin;
0115   double      myXmax;
0116   double      myYmin;
0117   double      myYmax;
0118   const char* myName;
0119   bool        isVisible;
0120   bool        isProtected;
0121 };
0122 
0123 #endif // _Draw_Drawable3D_HeaderFile