0024927: Getting rid of "Persistent" functionality -- Samples and data
[occt.git] / samples / mfc / standard / 05_ImportExport / src / ColoredShapes.cpp
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
15 CColoredShapes::CColoredShapes()
16 {
17 }
18
19
20 void CColoredShapes::Add(const Quantity_NameOfColor aColor, const TopoDS_Shape& aShape)
21 {
22         m_shapeList.Append(aShape);
23         m_colorMap.Bind(aShape, aColor);
24 }
25
26 void 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
37 IMPLEMENT_SERIAL(CColoredShapes, CObject,1);
38
39 #include <TopoDS_Shape.hxx>
40
41 // Tools to put Persistent Object in an archive
42 #include <FSD_Archive.hxx>
43 #include <Storage_Data.hxx>
44 #include <Storage_HSeqOfRoot.hxx>
45 #include <Storage_Root.hxx>
46
47 void CColoredShapes::Display(Handle(AIS_InteractiveContext)& anAIScontext)
48 {
49         for ( TopoDS_ListIteratorOfListOfShape iter(m_shapeList); iter.More(); iter.Next() )
50         {
51                 Handle(AIS_Shape) ais = new AIS_Shape(iter.Value());
52                 anAIScontext->SetColor(ais, (Quantity_NameOfColor)m_colorMap.Find(iter.Value()));
53                 anAIScontext->SetMaterial(ais, Graphic3d_NOM_GOLD, Standard_False);
54                 anAIScontext->Display(ais, Standard_False);
55         }
56 }