1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
// Created on: 2017-06-16
// Created by: Natalia ERMOLAEVA
// Copyright (c) 2017 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef ShapeView_ItemRoot_H
#define ShapeView_ItemRoot_H
#include <NCollection_List.hxx>
#include <inspector/TreeModel_ItemBase.hxx>
#include <Standard.hxx>
#include <TopoDS_Shape.hxx>
class ShapeView_ItemRoot;
typedef QExplicitlySharedDataPointer<ShapeView_ItemRoot> ShapeView_ItemRootPtr;
//! \class ShapeView_ItemRoot
//! Collects shapes that should be visualized in tree view. Shapes are cached and if shapes are not
//! needed, cache should be cleared using RemoveAllShapes. Parent is NULL, children are
//! ShapeView_ItemShape items.
class ShapeView_ItemRoot : public TreeModel_ItemBase
{
public:
//! Creates an item wrapped by a shared pointer
static ShapeView_ItemRootPtr CreateItem(TreeModel_ItemBasePtr theParent,
const int theRow,
const int theColumn)
{
return ShapeView_ItemRootPtr(new ShapeView_ItemRoot(theParent, theRow, theColumn));
}
//! Destructor
virtual ~ShapeView_ItemRoot() {}
//! Appends new shape
//! \param theShape a shape instance
void AddShape(const TopoDS_Shape& theShape) { myShapes.Append(theShape); }
//! Clears internal container of added shapes
void RemoveAllShapes() { myShapes.Clear(); }
//! Returns shape by the number
//! \param theRowId an index of the shape in the internal container.
Standard_EXPORT const TopoDS_Shape& Shape(const int theRowId);
protected:
//! Returns data value for the role.
//! \param theItemRole a value role
//! \return the value
virtual QVariant initValue(const int theItemRole) const Standard_OVERRIDE;
//! \return number of children.
virtual int initRowCount() const Standard_OVERRIDE { return myShapes.Size(); }
//! Creates a child item in the given position.
//! \param theRow the child row position
//! \param theColumn the child column position
//! \return the created item
virtual TreeModel_ItemBasePtr createChild(int theRow, int theColumn) Standard_OVERRIDE;
private:
//! Constructor
//! \param theParent a parent item
ShapeView_ItemRoot(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
: TreeModel_ItemBase(theParent, theRow, theColumn)
{
}
private:
NCollection_List<TopoDS_Shape> myShapes; //!< shapes presented in tree view
};
#endif
|