0029559: Samples - wrong copyright statement in FuncDemo
[occt.git] / tools / VInspector / VInspector_Tools.hxx
1 // Created on: 2017-06-16
2 // Created by: Natalia ERMOLAEVA
3 // Copyright (c) 2017 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 VInspector_Tools_H
17 #define VInspector_Tools_H
18
19 #include <AIS_InteractiveContext.hxx>
20 #include <SelectMgr_EntityOwner.hxx>
21 #include <Standard.hxx>
22 #include <TCollection_AsciiString.hxx>
23 #include <TopAbs_Orientation.hxx>
24 #include <TopAbs_ShapeEnum.hxx>
25 #include <TopLoc_Location.hxx>
26 #include <TopoDS_Shape.hxx>
27
28 #include <inspector/VInspector_CallBackMode.hxx>
29 #include <inspector/VInspector_SelectionType.hxx>
30
31 #ifdef _MSC_VER
32 #pragma warning(disable : 4127) // conditional expression is constant
33 #endif
34
35 #include <QList>
36 #include <QVariant>
37
38 //! \class VInspector_Tools
39 //! The class that gives auxiliary methods for Visualization elements manipulation
40 class VInspector_Tools
41 {
42
43 public:
44
45   //! Returns string value of enumeration value
46   //! \param theType a shape type
47   //! \return text value
48   Standard_EXPORT static TCollection_AsciiString GetShapeTypeInfo (const TopAbs_ShapeEnum& theType);
49
50   //! Convert pointer to string value
51   //! \param thePointer a pointer
52   //! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
53   //! \return the string value 
54   Standard_EXPORT static TCollection_AsciiString GetPointerInfo (const Handle(Standard_Transient)& thePointer,
55                                                                  const bool isShortInfo);
56
57   //! Returns number of selected owners for presentation
58   //! \param theContext an interactive context
59   //! \param theObject a presentation
60   //! \param theShapeInfoOnly if true, only BRep owners are taken
61   Standard_EXPORT static int SelectedOwners (const Handle(AIS_InteractiveContext)& theContext,
62                                              const Handle(AIS_InteractiveObject)& theObject,
63                                              const bool theShapeInfoOnly);
64
65   //! Returns true if the owner is selected in the context
66   //! \param theContext an interactive context
67   //! \param theOwner a selectable owner
68   //! \return boolean value
69   Standard_EXPORT static bool IsOwnerSelected (const Handle(AIS_InteractiveContext)& theContext,
70                                                const Handle(SelectBasics_EntityOwner)& theOwner);
71
72   //! Returns all owners present in the context
73   //! \param theContext an interactive context
74   //! \return container of owners
75   Standard_EXPORT static NCollection_List<Handle(SelectBasics_EntityOwner)> ContextOwners (
76                                                  const Handle(AIS_InteractiveContext)& theContext);
77
78   //! Returns active owners in main selector of context
79   //! \param theContext an interactive context
80   //! \param theEmptySelectableOwners container of owners with NULL presentation or not displayed presentation
81   //! \return container of owners
82   Standard_EXPORT static NCollection_List<Handle(SelectBasics_EntityOwner)> ActiveOwners (
83                             const Handle(AIS_InteractiveContext)& theContext,
84                             NCollection_List<Handle(SelectBasics_EntityOwner)>& theEmptySelectableOwners);
85
86   //! Unhighlight selected, set selected the owners
87   //! \param theContext an interactive context
88   //! \param theOwners a container of owners
89   Standard_EXPORT static void AddOrRemoveSelectedShapes (const Handle(AIS_InteractiveContext)& theContext,
90                                          const NCollection_List<Handle(SelectBasics_EntityOwner)>& theOwners);
91
92   //! Unhighlight selected, set selected presentations
93   //! \param theContext an interactive context
94   //! \param thePresentations a container of presentations
95   Standard_EXPORT static void AddOrRemovePresentations (const Handle(AIS_InteractiveContext)& theContext,
96                                         const NCollection_List<Handle(AIS_InteractiveObject)>& thePresentations);
97
98   //! Returns information about presentation: Dynamic Type, Pointer info, Shape type info
99   //! \param theObject a presentation
100   //! \return container of values
101   Standard_EXPORT static QList<QVariant> GetInfo (Handle(AIS_InteractiveObject)& theObject);
102
103   //! Returns information about current highlight: Names, Owners, Pointers, Owners
104   //! \param theContext an interactive context
105   //! \return container of values
106   Standard_EXPORT static QList<QVariant> GetHighlightInfo (const Handle(AIS_InteractiveContext)& theContext);
107
108   //! Returns information about current selection: Names, Owners, Pointers, Owners
109   //! \param theContext an interactive context
110   //! \return container of values
111   Standard_EXPORT static QList<QVariant> GetSelectedInfo (const Handle(AIS_InteractiveContext)& theContext);
112
113   //! Returns the first pointer of selection in the context
114   Standard_EXPORT static QString GetSelectedInfoPointers (const Handle(AIS_InteractiveContext)& theContext);
115
116   //! Returns string information of call back mode
117   //! \param theMode type of selection
118   //! \param theValue a value in selection enumeration
119   //! \return information text
120   Standard_EXPORT static TCollection_AsciiString ToName (const VInspector_SelectionType theType, const int theValue);
121
122   //! Returns selection information 
123   //! \param theMode a selection mode
124   //! \param thePresentation a presentation
125   //! \return text value
126   Standard_EXPORT static TCollection_AsciiString SelectionModeToName (int theMode, const Handle(AIS_InteractiveObject)& thePresentation);
127
128   //! Returns text of orientation
129   //! \param theOrientation an orientation value
130   //! \return text value
131   Standard_EXPORT static TCollection_AsciiString OrientationToName (const TopAbs_Orientation& theOrientation);
132
133   //! Returns text of orientation
134   //! \param theLocation a location value
135   //! \return text value
136   Standard_EXPORT static TCollection_AsciiString LocationToName (const TopLoc_Location& theLocation);
137
138   //! Read Shape using BREP reader
139   //! \param theFileName a file name
140   //! \return shape or NULL
141   Standard_EXPORT static TopoDS_Shape ReadShape (const TCollection_AsciiString& theFileName);
142 };
143
144 #endif