0030268: Inspectors - improvements in VInspector plugin
[occt.git] / tools / DFBrowserPane / DFBrowserPane_HelperExport.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_HelperExport_H
17 #define DFBrowserPane_HelperExport_H
18
19 #include <TopoDS_Shape.hxx>
20
21 #include <Standard_WarningsDisable.hxx>
22 #include <QObject>
23 #include <QModelIndex>
24 #include <Standard_WarningsRestore.hxx>
25
26 //! \class DFBrowserPane_HelperExport
27 //! \brief It performs export to BREP of a shape by button is pressed
28 //! It contains a conainer of shapes for model indices. If button is pressed for index where the 
29 //! shape exists, this shape is exported to BREP file.
30 //! It contains a container of shapes, it is important to clear this helper after using.
31 class DFBrowserPane_HelperExport : public QObject
32 {
33   Q_OBJECT
34 public:
35   //! Constructor
36   DFBrowserPane_HelperExport (QObject* theParent) { (void)theParent; }
37
38   //! Destructor
39   virtual ~DFBrowserPane_HelperExport() Standard_OVERRIDE {}
40
41   //! Clears current shapes
42   void Clear() { myShapes.clear(); }
43
44   //! Append a shape to be exported if pressed button on item from the given list
45   //! \param theShape a shape
46   //! \param theIndicies a list of indices for this shape
47   void AddShape (const TopoDS_Shape& theShape, const QModelIndexList& theIndices);
48
49   //! Returns whether the map of shapes contains a shape for the index
50   //! \param theIndex a model index
51   //! \return true if the map contains shape
52   bool HasShape (const QModelIndex& theIndex) const { return myShapes.contains (theIndex); }
53
54   //! Returns shape for the index
55   //! \param theIndex a model view index
56   //! \return a cached shape
57   const TopoDS_Shape& Shape (const QModelIndex& theIndex) { return myShapes[theIndex]; }
58
59 public slots:
60
61   //! Slot that processing button press for the model index
62   //! \param theIndex a model index
63   void OnButtonPressed (const QModelIndex& theIndex);
64
65 private:
66 #ifdef _MSC_VER
67 #pragma warning(push, 0) // 4251: class 'QMap<QModelIndex,TopoDS_Shape>' needs to have dll-interface...
68 #endif
69   QMap<QModelIndex, TopoDS_Shape> myShapes; //!< a container of shapes
70 #ifdef _MSC_VER
71 #pragma warning(pop)
72 #endif
73 };
74
75 #endif