cb194777a9b77f79bdb1b25f78d6f19fef98995a
[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 #include <Standard_WarningsDisable.hxx>
28 #include <QString>
29 #include <QString>
30 #include <QVariant>
31 #include <Standard_WarningsRestore.hxx>
32
33 #define PROPERTY_TABLE_ROW_COUNT 200
34
35 //! \class DFBrowserPane_Tools
36 //! \brief The tool that gives auxiliary methods for TDocStd elements manipulation
37 class DFBrowserPane_Tools
38 {
39 public:
40
41   //! Returns default value for table view model: width[0] = 200, width[others] = 120
42   //! \param theColumnId a column index
43   //! \returns value
44   Standard_EXPORT static int DefaultPanelColumnWidth (const int theColumnId);
45
46   //! Returns a string presentation of the label
47   //! \param theLabel a label object
48   //! \return the string value
49   Standard_EXPORT static TCollection_AsciiString GetEntry (const TDF_Label& theLabel);
50
51   //! Convert pointer to string value
52   //! \param thePointer a pointer
53   //! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
54   //! \return the string value
55   Standard_EXPORT static TCollection_AsciiString GetPointerInfo (const Handle(Standard_Transient)& thePointer,
56                                                                  const bool isShortInfo = true);
57
58   //! Returns string value corresponded to the shape type if it is not null.
59   //! \param theShape a checked shape
60   //! \return string value or empty string value
61   Standard_EXPORT static QVariant ShapeTypeInfo (const TopoDS_Shape& theShape);
62
63   //! Returns "true" or "false" text for the given boolean state
64   //! \param theValue a boolean value
65   //! \return string value
66   Standard_EXPORT static QString BoolToStr (const bool theValue) { return theValue ? "true" : "false"; }
67
68   //! Converts a Qt string to OCCT extended string
69   //! \param theValue a converted string
70   //! \return the extended string value
71   Standard_EXPORT static QString ToString(const TCollection_ExtendedString& theValue)
72   {
73     return QString::fromUtf16((uint16_t*)theValue.ToExtString());
74   }
75
76   //! Returns light highlight color
77   //! \returns Qt color
78   static Standard_EXPORT QColor LightHighlightColor();
79
80   //! Converts enumeration value into string text
81   //! \param theType an enumeration kind
82   //! \param theEnumId an enumeration value
83   //! \return string presentation
84   Standard_EXPORT static TCollection_AsciiString ToName (const DFBrowserPane_OcctEnumType& theType,
85                                                          const Standard_Integer& theEnumId);
86 };
87
88 #endif