0030686: Visualization, SelectMgr_ViewerSelector - sorting issues of transformation...
[occt.git] / src / IVtkTools / IVtkTools_ShapeObject.hxx
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
22 // prevent disabling some MSVC warning messages by VTK headers 
23 #ifdef _MSC_VER
24 #pragma warning(push)
25 #endif
26 #include <vtkDataObject.h>
27 #include <vtkSetGet.h>
28 #include <vtkWeakPointer.h>
29 #ifdef _MSC_VER
30 #pragma warning(pop)
31 #endif
32
33 class vtkActor;
34 class vtkDataSet;
35 class vtkInformationObjectBaseKey;
36 class IVtkTools_ShapeDataSource;
37
38 #ifdef _MSC_VER
39 #pragma warning(push)
40 #pragma warning(disable: 4251) // avoid warning C4251: "class needs to have dll-interface..."
41 #endif
42
43 //! @class IVtkTools_ShapeObject
44 //! @brief VTK holder class for OCC shapes to pass them through pipelines.
45 //!
46 //! It is descendent of vtkObject (data). Logically it is a one of milestones of VTK pipeline.
47 //! It stores data of OCC shape (the OccShape instance) in vtkInformation object of vtkDataObject.
48 //! Then pass it to the actors through pipelines,
49 //! so selection logic can access OccShape easily given the actor instance.
50 class Standard_EXPORT IVtkTools_ShapeObject :  public vtkDataObject
51 {
52 public:
53   vtkTypeMacro (IVtkTools_ShapeObject, vtkDataObject)
54
55   static IVtkTools_ShapeObject* New(); 
56
57   //! Get OCC shape source from VTK data from actor's information object by key.
58   static vtkSmartPointer<IVtkTools_ShapeDataSource> GetShapeSource (vtkActor* theActor);
59
60   //! Get OCC shape from VTK data from actor's information object by key.
61   static IVtkOCC_Shape::Handle GetOccShape (vtkActor* theActor);
62
63   //! Static method to set OCC shape source to VTK dataset in information object 
64   //! with key.
65   static void SetShapeSource (IVtkTools_ShapeDataSource* theDataSource, vtkDataSet* theData);
66
67   //! Static method to set OCC shape source to VTK actor in information object 
68   //! with key.
69   static void SetShapeSource (IVtkTools_ShapeDataSource* theDataSource, vtkActor* theActor);
70
71   typedef vtkInformationObjectBaseKey* KeyPtr;
72
73   //! Static method used by shape selection logic in order to establish
74   //! a connection from vtkActor to OccShape instance.
75   //! @return vtkInformationKey for retrieving OccShape instance from the actor
76   static KeyPtr getKey();
77
78   //! OCC shape source setter.
79   void SetShapeSource (IVtkTools_ShapeDataSource* theDataSource);
80
81   //! OCC shape source getter.
82   IVtkTools_ShapeDataSource* GetShapeSource() const;
83
84 protected:
85   IVtkTools_ShapeObject();
86   virtual ~IVtkTools_ShapeObject();
87
88 private: // not copyable
89   IVtkTools_ShapeObject (const IVtkTools_ShapeObject&);
90   IVtkTools_ShapeObject& operator= (const IVtkTools_ShapeObject&);
91
92 private: // OCC
93   vtkWeakPointer<IVtkTools_ShapeDataSource> myShapeSource;
94
95   static KeyPtr myKey;
96 };
97
98 #ifdef _MSC_VER
99 #pragma warning(pop)
100 #endif
101
102 #endif // __IVTKTOOLS_SHAPEOBJECT_H__