1 // Created on: 2017-06-16
2 // Created by: Natalia ERMOLAEVA
3 // Copyright (c) 2017 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef DFBrowserPane_Tools_H
17 #define DFBrowserPane_Tools_H
19 #include <inspector/DFBrowserPane_OcctEnumType.hxx>
21 #include <Standard.hxx>
22 #include <TCollection_ExtendedString.hxx>
23 #include <TDF_Label.hxx>
24 #include <TopLoc_Location.hxx>
25 #include <TopoDS_Shape.hxx>
28 #pragma warning(disable : 4127) // conditional expression is constant
30 #include <QApplication>
36 #define PROPERTY_TABLE_ROW_COUNT 200
38 //! \class DFBrowserPane_Tools
39 //! \brief The tool that gives auxiliary methods for TDocStd elements manipulation
40 class DFBrowserPane_Tools
44 //! Returns default value for table view model: width[0] = 200, width[others] = 120
45 //! \param theColumnId a column index
47 Standard_EXPORT static int DefaultPanelColumnWidth (const int theColumnId);
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); }
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);
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);
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);
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"; }
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)
80 return QString::fromUtf16((uint16_t*)theValue.ToExtString());
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);