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