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 DFBROWSER_ThreadItemUsedShapesMap_H
17 #define DFBROWSER_ThreadItemUsedShapesMap_H
19 #include <DFBrowser_ThreadItem.hxx>
20 #include <NCollection_DataMap.hxx>
21 #include <Standard.hxx>
22 #include <TCollection_AsciiString.hxx>
23 #include <TDF_Attribute.hxx>
26 #pragma warning(disable : 4127) // conditional expression is constant
28 #include <QStringList>
31 class DFBrowser_Module;
33 //! \class DFBrowser_ThreadItemUsedShapesMap
34 //! Collects and sorts map values of TNaming_UsedShape attributes. Applies values to the OCAF tree view model
35 class DFBrowser_ThreadItemUsedShapesMap : public DFBrowser_ThreadItem
40 DFBrowser_ThreadItemUsedShapesMap() : myModule (0) {}
43 virtual ~DFBrowser_ThreadItemUsedShapesMap() {}
45 //! Sets the current module
46 void SetModule (DFBrowser_Module* theModule) { myModule = theModule; }
48 //! Iterates by application documents and for TNaming_UsedShape attribute collects container of sorted values.
49 Standard_EXPORT virtual void Run() Standard_OVERRIDE;
51 //! Initialize tree view model of OCAF by internal container of sorted values.
52 Standard_EXPORT virtual void ApplyValues() Standard_OVERRIDE;
54 //! Set empty cache into tree view model of OCAF. Calls Init of these item by usual values (not sorted)
55 Standard_EXPORT static void ClearSortedReferences (DFBrowser_Module* theModule);
59 //! Collects sorted values of the attribute if the attribute has TNaming_UsedShape type
60 //! \param theAttribute a processed attribute
61 //! \param theReferences a output container of sorted references
62 void findReferences (Handle(TDF_Attribute) theAttribute, std::list<TCollection_AsciiString>& theReferences);
64 //! Checks whether the left path is less than the right path
65 //! \param theLeft path to label
66 //! \param theRight path to label
67 //! \returns true if the left path is less(not equal) than right path
68 static bool isLessThan (const QStringList& theLeft, const QStringList& theRight);
70 //! Insert entry into container of entries using sorting. It is split by ":" separator to perform soring
71 //! \param theEntry a label entry
72 //! \param theEntries a result container
73 void addValue (const TCollection_AsciiString& theEntry, QList<QPair<TCollection_AsciiString, QStringList > >& theEntries);
77 DFBrowser_Module* myModule; //!< the current module
78 NCollection_DataMap<Handle(TDF_Attribute), std::list<TCollection_AsciiString> > myAttributeRefs; //!< sorted references