0026229: Add the possibility in OCAF to open/save a document from/to a stream object
[occt.git] / samples / mfc / standard / 05_ImportExport / src / ColoredShapes.cpp
CommitLineData
7fd59977 1// ColoredShapes.cpp: implementation of the CColoredShape class.
2//
3//////////////////////////////////////////////////////////////////////
4
5#include "stdafx.h"
6
7#include <afxtempl.h>
8
9#include "ColoredShapes.h"
10
11//////////////////////////////////////////////////////////////////////
12// Construction/Destruction
13//////////////////////////////////////////////////////////////////////
14
15CColoredShapes::CColoredShapes()
16{
17}
18
19
20void CColoredShapes::Add(const Quantity_NameOfColor aColor, const TopoDS_Shape& aShape)
21{
22 m_shapeList.Append(aShape);
23 m_colorMap.Bind(aShape, aColor);
24}
25
b96f3bea 26void CColoredShapes::Remove(const TopoDS_Shape& aShape)
27{
28 m_colorMap.UnBind(aShape);
29 for ( TopoDS_ListIteratorOfListOfShape iter(m_shapeList); iter.More(); iter.Next() ) {
30 if(iter.Value() == aShape) {
31 m_shapeList.Remove(iter);
32 break;
33 }
34 }
35}
36
7fd59977 37IMPLEMENT_SERIAL(CColoredShapes, CObject,1);
38
7fd59977 39#include <TopoDS_Shape.hxx>
40
41// Tools to put Persistent Object in an archive
7fd59977 42
43void CColoredShapes::Display(Handle(AIS_InteractiveContext)& anAIScontext)
44{
45 for ( TopoDS_ListIteratorOfListOfShape iter(m_shapeList); iter.More(); iter.Next() )
46 {
47 Handle(AIS_Shape) ais = new AIS_Shape(iter.Value());
48 anAIScontext->SetColor(ais, (Quantity_NameOfColor)m_colorMap.Find(iter.Value()));
49 anAIScontext->SetMaterial(ais, Graphic3d_NOM_GOLD, Standard_False);
50 anAIScontext->Display(ais, Standard_False);
51 }
52}