0029025: TInspector include files are not installed to inc directory by CMake
[occt.git] / tools / DFBrowserPane / DFBrowserPane_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 DFBrowserPane_Tools_H
17 #define DFBrowserPane_Tools_H
18
19 #include <inspector/DFBrowserPane_OcctEnumType.hxx>
20
21 #include <Standard.hxx>
22 #include <TCollection_ExtendedString.hxx>
23 #include <TDF_Label.hxx>
24 #include <TopLoc_Location.hxx>
25 #include <TopoDS_Shape.hxx>
26
27 #ifdef _MSC_VER
28 #pragma warning(disable : 4127) // conditional expression is constant
29 #endif
30 #include <QApplication>
31 #include <QString>
32 #include <QStyle>
33 #include <QString>
34 #include <QVariant>
35
36 #define PROPERTY_TABLE_ROW_COUNT 200
37
38 //! \class DFBrowserPane_Tools
39 //! \brief The tool that gives auxiliary methods for TDocStd elements manipulation
40 class DFBrowserPane_Tools
41 {
42 public:
43
44   //! Returns default value for table view model: width[0] = 200, width[others] = 120
45   //! \param theColumnId a column index
46   //! \returns value
47   Standard_EXPORT static int DefaultPanelColumnWidth (const int theColumnId);
48
49   //! Returns header margin, defined in style settings of application
50   //! \return integer value
51   Standard_EXPORT static int HeaderSectionMargin() { return qApp->style()->pixelMetric (QStyle::PM_HeaderMargin); }
52
53   //! Returns a string presentation of the label
54   //! \param theLabel a label object
55   //! \return the string value
56   Standard_EXPORT static TCollection_AsciiString GetEntry (const TDF_Label& theLabel);
57
58   //! Convert pointer to string value
59   //! \param thePointer a pointer
60   //! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
61   //! \return the string value
62   Standard_EXPORT static TCollection_AsciiString GetPointerInfo (const Handle(Standard_Transient)& thePointer,
63                                                                  const bool isShortInfo = true);
64
65   //! Returns string value corresponded to the shape type if it is not null.
66   //! \param theShape a checked shape
67   //! \return string value or empty string value
68   Standard_EXPORT static QVariant ShapeTypeInfo (const TopoDS_Shape& theShape);
69
70   //! Returns "true" or "false" text for the given boolean state
71   //! \param theValue a boolean value
72   //! \return string value
73   Standard_EXPORT static QString BoolToStr (const bool theValue) { return theValue ? "true" : "false"; }
74
75   //! Converts a Qt string to OCCT extended string
76   //! \param theValue a converted string
77   //! \return the extended string value
78   Standard_EXPORT static QString ToString(const TCollection_ExtendedString& theValue)
79   {
80     return QString::fromUtf16((uint16_t*)theValue.ToExtString());
81   }
82
83   //! Converts enumeration value into string text
84   //! \param theType an enumeration kind
85   //! \param theEnumId an enumeration value
86   //! \return string presentation
87   Standard_EXPORT static TCollection_AsciiString ToName (const DFBrowserPane_OcctEnumType& theType,
88                                                          const Standard_Integer& theEnumId);
89 };
90
91 #endif