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   //! Returns string value corresponded to the shape type if it is not null.
52   //! \param theShape a checked shape
53   //! \return string value or empty string value
54   Standard_EXPORT static QVariant ShapeTypeInfo (const TopoDS_Shape& theShape);
55 
56   //! Returns "true" or "false" text for the given boolean state
57   //! \param theValue a boolean value
58   //! \return string value
BoolToStr(const bool theValue)59   Standard_EXPORT static QString BoolToStr (const bool theValue) { return theValue ? "true" : "false"; }
60 
61   //! Converts a Qt string to OCCT extended string
62   //! \param theValue a converted string
63   //! \return the extended string value
ToString(const TCollection_ExtendedString & theValue)64   Standard_EXPORT static QString ToString(const TCollection_ExtendedString& theValue)
65   {
66     return QString::fromUtf16((uint16_t*)theValue.ToExtString());
67   }
68 
69   //! Returns light highlight color
70   //! \returns Qt color
71   static Standard_EXPORT QColor LightHighlightColor();
72 
73   //! Converts enumeration value into string text
74   //! \param theType an enumeration kind
75   //! \param theEnumId an enumeration value
76   //! \return string presentation
77   Standard_EXPORT static TCollection_AsciiString ToName (const DFBrowserPane_OcctEnumType& theType,
78                                                          const Standard_Integer& theEnumId);
79 };
80 
81 #endif
82