913a4c4a |
1 | // Created on: 2011-10-27 |
2 | // Created by: Roman KOZLOV |
3 | // Copyright (c) 2011-2014 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
16 | #ifndef __IVTKTOOLS_SHAPEOBJECT_H__ |
17 | #define __IVTKTOOLS_SHAPEOBJECT_H__ |
18 | |
19 | #include <IVtkTools.hxx> |
20 | #include <IVtkOCC_Shape.hxx> |
21 | #include <vtkDataObject.h> |
22 | #include <vtkSetGet.h> |
a2f76b15 |
23 | #include <vtkWeakPointer.h> |
913a4c4a |
24 | |
25 | class vtkActor; |
26 | class vtkDataSet; |
27 | class vtkInformationObjectBaseKey; |
28 | class IVtkTools_ShapeDataSource; |
29 | |
896faa72 |
30 | #ifdef _MSC_VER |
31 | #pragma warning(push) |
32 | #pragma warning(disable: 4251) // avoid warning C4251: "class needs to have dll-interface..." |
33 | #endif |
34 | |
913a4c4a |
35 | //! @class IVtkTools_ShapeObject |
36 | //! @brief VTK holder class for OCC shapes to pass them through pipelines. |
37 | //! |
38 | //! It is descendent of vtkObject (data). Logically it is a one of milestones of VTK pipeline. |
39 | //! It stores data of OCC shape (the OccShape instance) in vtkInformation object of vtkDataObject. |
40 | //! Then pass it to the actors through pipelines, |
41 | //! so selection logic can access OccShape easily given the actor instance. |
42 | class IVtkTools_EXPORT IVtkTools_ShapeObject : public vtkDataObject |
43 | { |
44 | public: |
68858c7d |
45 | vtkTypeMacro (IVtkTools_ShapeObject, vtkObject) |
913a4c4a |
46 | |
47 | static IVtkTools_ShapeObject* New(); |
48 | |
49 | //! Get OCC shape source from VTK data from actor's information object by key. |
a2f76b15 |
50 | static vtkSmartPointer<IVtkTools_ShapeDataSource> GetShapeSource (vtkActor* theActor); |
913a4c4a |
51 | |
52 | //! Get OCC shape from VTK data from actor's information object by key. |
53 | static IVtkOCC_Shape::Handle GetOccShape (vtkActor* theActor); |
54 | |
55 | //! Static method to set OCC shape source to VTK dataset in information object |
56 | //! with key. |
57 | static void SetShapeSource (IVtkTools_ShapeDataSource* theDataSource, vtkDataSet* theData); |
58 | |
59 | //! Static method to set OCC shape source to VTK actor in information object |
60 | //! with key. |
61 | static void SetShapeSource (IVtkTools_ShapeDataSource* theDataSource, vtkActor* theActor); |
62 | |
63 | typedef vtkInformationObjectBaseKey* KeyPtr; |
64 | |
65 | //! Static method used by shape selection logic in order to establish |
66 | //! a connection from vtkActor to OccShape instance. |
67 | //! @return vtkInformationKey for retrieving OccShape instance from the actor |
68 | static KeyPtr getKey(); |
69 | |
70 | //! OCC shape source setter. |
71 | void SetShapeSource (IVtkTools_ShapeDataSource* theDataSource); |
72 | |
73 | //! OCC shape source getter. |
a2f76b15 |
74 | IVtkTools_ShapeDataSource* GetShapeSource() const; |
913a4c4a |
75 | |
76 | protected: |
77 | IVtkTools_ShapeObject(); |
a2f76b15 |
78 | virtual ~IVtkTools_ShapeObject(); |
913a4c4a |
79 | |
80 | private: // not copyable |
81 | IVtkTools_ShapeObject (const IVtkTools_ShapeObject&); |
82 | IVtkTools_ShapeObject& operator= (const IVtkTools_ShapeObject&); |
83 | |
84 | private: // OCC |
a2f76b15 |
85 | vtkWeakPointer<IVtkTools_ShapeDataSource> myShapeSource; |
913a4c4a |
86 | |
87 | static KeyPtr myKey; |
88 | }; |
89 | |
896faa72 |
90 | #ifdef _MSC_VER |
91 | #pragma warning(pop) |
92 | #endif |
93 | |
913a4c4a |
94 | #endif // __IVTKTOOLS_SHAPEOBJECT_H__ |