0024131: TKOpenGL redesign GPU memory management for markers presentation
[occt.git] / samples / mfc / standard / Common / Primitive / Sample2D_Markers.cpp
CommitLineData
7fd59977 1#include "stdafx.h"
2
3#include "Sample2D_Markers.h"
4
5c1f974e 5IMPLEMENT_STANDARD_HANDLE(Sample2D_Markers,AIS_InteractiveObject)
6IMPLEMENT_STANDARD_RTTIEXT(Sample2D_Markers,AIS_InteractiveObject)
7fd59977 7
8// generic marker
5c1f974e 9Sample2D_Markers::Sample2D_Markers (const Quantity_Length theXPosition ,
10 const Quantity_Length theYPosition ,
11 const Aspect_TypeOfMarker theMarkerType,
12 const Quantity_Color theColor,
13 const Standard_Real theScaleOrId)
a577aaab 14 :AIS_InteractiveObject(),myArrayOfPoints (new Graphic3d_ArrayOfPoints (1))
7fd59977 15{
5c1f974e 16 myXPosition = theXPosition;
17 myYPosition = theYPosition;
18 myMarkerType = theMarkerType;
19 myColor = theColor;
20 myIndex = theScaleOrId;
7fd59977 21}
22
5c1f974e 23Sample2D_Markers::Sample2D_Markers (const Quantity_Length theXPosition ,
24 const Quantity_Length theYPosition ,
a577aaab 25 const Handle(Graphic3d_ArrayOfPoints)& theArrayOfPoints,
5c1f974e 26 const Aspect_TypeOfMarker theMarkerType,
27 const Quantity_Color theColor,
28 const Standard_Real theScaleOrId)
a577aaab 29 :AIS_InteractiveObject(),myArrayOfPoints (new Graphic3d_ArrayOfPoints (6))
7fd59977 30{
5c1f974e 31 myXPosition = theXPosition;
32 myYPosition = theYPosition;
33 myMarkerType = theMarkerType;
34 myColor = theColor;
35 myIndex = theScaleOrId;
a577aaab 36 myArrayOfPoints = theArrayOfPoints;
7fd59977 37}
38
7fd59977 39
5c1f974e 40void Sample2D_Markers::Compute ( const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
41 const Handle(Prs3d_Presentation)& aPresentation,
42 const Standard_Integer aMode)
7fd59977 43{
5c1f974e 44 if(myMarkerType == Aspect_TOM_USERDEFINED)
45 {
46 Handle(Graphic3d_AspectMarker3d) aMarker = new Graphic3d_AspectMarker3d(Aspect_TOM_POINT,myColor,myIndex);
47 Prs3d_Root::CurrentGroup(aPresentation)->SetGroupPrimitivesAspect(aMarker);
a577aaab 48 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (myArrayOfPoints);
5c1f974e 49 }
50 else
51 {
52 Handle(Graphic3d_AspectMarker3d) aMarker = new Graphic3d_AspectMarker3d(myMarkerType,myColor,myIndex);
53 aPresentation->SetPrimitivesAspect(aMarker);
a577aaab 54 Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
55 anArrayOfPoints->AddVertex (myXPosition, myYPosition, 0);
56 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints);
5c1f974e 57 }
7fd59977 58}