94139dc13ab984edb73c3e050b040538a97817a5
[occt.git] / src / XCAFPrs / XCAFPrs_AISObject.hxx
1 // Copyright (c) 2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #ifndef _XCAFPrs_AISObject_HeaderFile
15 #define _XCAFPrs_AISObject_HeaderFile
16
17 #include <AIS_ColoredShape.hxx>
18
19 #include <TDF_Label.hxx>
20
21 class XCAFPrs_Style;
22
23 //! Implements AIS_InteractiveObject functionality for shape in DECAF document.
24 class XCAFPrs_AISObject : public AIS_ColoredShape
25 {
26 public:
27
28   //! Creates an object to visualise the shape label.
29   Standard_EXPORT XCAFPrs_AISObject (const TDF_Label& theLabel);
30
31   //! Returns the label which was visualised by this presentation
32   const TDF_Label& GetLabel() const { return myLabel; }
33
34   //! Assign the label to this presentation
35   //! (but does not mark it outdated with SetToUpdate()).
36   void SetLabel (const TDF_Label& theLabel)
37   {
38     myLabel = theLabel;
39   }
40
41   //! Fetch the Shape from associated Label and fill the map of sub-shapes styles.
42   //! By default, this method is called implicitly within first ::Compute().
43   //! Application might call this method explicitly to manipulate styles afterwards.
44   //! @param theToSyncStyles flag indicating if method ::Compute() should call this method again
45   //!                        on first compute or re-compute
46   Standard_EXPORT virtual void DispatchStyles (const Standard_Boolean theToSyncStyles = Standard_False);
47
48   //! Sets the material aspect.
49   //! This method assigns the new default material without overriding XDE styles.
50   //! Re-computation of existing presentation is not required after calling this method.
51   Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& theMaterial) Standard_OVERRIDE;
52
53 protected:
54
55   //! Redefined method to compute presentation.
56   Standard_EXPORT virtual  void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
57                                          const Handle(Prs3d_Presentation)&           thePresentation,
58                                          const Standard_Integer                      theMode) Standard_OVERRIDE;
59
60   //! Set colors to drawer
61   Standard_EXPORT void SetColors (const Handle(Prs3d_Drawer)& theDrawer,
62                                   const Quantity_Color&       theColorCurv,
63                                   const Quantity_ColorRGBA&   theColorSurf);
64
65   //! Set colors to drawer
66   void SetColors (const Handle(Prs3d_Drawer)& theDrawer,
67                   const Quantity_Color& theColorCurv,
68                   const Quantity_Color& theColorSurf) { SetColors (theDrawer, theColorCurv, Quantity_ColorRGBA (theColorSurf)); }
69
70   //! Fills out a default style object which is used when styles are
71   //! not explicitly defined in the document.
72   //! By default, the style uses white color for curves and surfaces.
73   Standard_EXPORT virtual  void DefaultStyle (XCAFPrs_Style& theStyle) const;
74
75 protected:
76
77   TDF_Label        myLabel;        //!< label pointing onto the shape
78   Standard_Boolean myToSyncStyles; //!< flag indicating that shape and sub-shapes should be updates within Compute()
79
80 public:
81
82   DEFINE_STANDARD_RTTIEXT(XCAFPrs_AISObject,AIS_ColoredShape)
83
84 };
85
86 DEFINE_STANDARD_HANDLE(XCAFPrs_AISObject, AIS_ColoredShape)
87
88 #endif // _XCAFPrs_AISObject_HeaderFile