1 // Copyright: Matra-Datavision 1995
2 // File: StdSelect_ViewerSelector2d.cxx
3 // Created: Thu Feb 23 17:10:14 1995
9 #include <StdSelect_ViewerSelector2d.ixx>
10 #include <Graphic2d_Array1OfVertex.hxx>
11 #include <Graphic2d_GraphicObject.hxx>
12 #include <SelectMgr_DataMapIteratorOfDataMapOfIntegerSensitive.hxx>
13 #include <Select2D_SensitiveEntity.hxx>
14 #include <StdSelect_TextProjector2d.hxx>
15 #include <SelectBasics_ListOfBox2d.hxx>
16 #include <Bnd_Box2d.hxx>
17 #include <Graphic2d_Vertex.hxx>
18 #include <Graphic2d_Polyline.hxx>
19 #include <Graphic2d_Array1OfVertex.hxx>
20 #include <SelectBasics_ListIteratorOfListOfBox2d.hxx>
22 //==================================================
25 //==================================================
27 StdSelect_ViewerSelector2d::StdSelect_ViewerSelector2d():
31 StdSelect_ViewerSelector2d::StdSelect_ViewerSelector2d(const Handle(Select2D_Projector)& aPrj):
36 //==================================================
39 //==================================================
41 void StdSelect_ViewerSelector2d::Set(const Standard_Integer apixtol)
43 tosort = Standard_True;
46 //==================================================
49 //==================================================
51 void StdSelect_ViewerSelector2d::Set(const Handle(Select2D_Projector)& aPrj)
56 //==================================================
59 //==================================================
61 void StdSelect_ViewerSelector2d::Convert(const Handle(SelectMgr_Selection)& aSel)
63 for(aSel->Init();aSel->More();aSel->Next())
65 if(aSel->Sensitive()->NeedsConversion())
66 Handle(Select2D_SensitiveEntity)::
67 DownCast(aSel->Sensitive())->Convert(myprj);
69 tosort = Standard_True;
73 void StdSelect_ViewerSelector2d::Pick(const Standard_Integer XPix,
74 const Standard_Integer YPix,
75 const Handle(V2d_View)& aViou)
78 aViou->Convert(XPix,YPix,Xr,Yr);
84 void StdSelect_ViewerSelector2d::Pick(const Standard_Integer XPMin,
85 const Standard_Integer YPMin,
86 const Standard_Integer XPMax,
87 const Standard_Integer YPMax,
88 const Handle(V2d_View)& aViou)
90 if(mypixtol!=0) mytolerance = aViou->Convert(mypixtol);
91 Standard_Real X1,Y1,X2,Y2;
92 aViou->Convert(XPMin,YPMin,X1,Y1);
93 aViou->Convert(XPMax,YPMax,X2,Y2);
94 InitSelect(Min(X1,X2),
100 //==================================================
101 // Function: DisplayAreas
103 //==================================================
104 void StdSelect_ViewerSelector2d::
105 DisplayAreas(const Handle(V2d_View)& aViou)
107 mygo = new Graphic2d_GraphicObject(aViou->View());
109 Graphic2d_Array1OfVertex Av1 (1,5);
110 SelectMgr_DataMapIteratorOfDataMapOfIntegerSensitive It(myentities);
111 SelectBasics_ListOfBox2d BoxList;
112 Standard_Real xmin,ymin,xmax,ymax;
113 Handle(Graphic2d_Polyline) pol;
115 for(;It.More();It.Next())
117 It.Value()->Areas(BoxList);
119 SelectBasics_ListIteratorOfListOfBox2d anIterator(BoxList);
120 for (;anIterator.More();anIterator.Next())
122 anIterator.Value().Get(xmin,ymin,xmax,ymax);
125 // BY DEN BoxList.Last().Get(xmin,ymin,xmax,ymax);
126 // construction des vertex graphiques
127 Av1.SetValue(1,Graphic2d_Vertex(xmin-mytolerance,ymin-mytolerance));
128 Av1.SetValue(2,Graphic2d_Vertex(xmax+mytolerance,ymin-mytolerance));
129 Av1.SetValue(3,Graphic2d_Vertex(xmax+mytolerance,ymax+mytolerance));
130 Av1.SetValue(4,Graphic2d_Vertex(xmin-mytolerance,ymax+mytolerance));
131 Av1.SetValue(5,Graphic2d_Vertex(xmin-mytolerance,ymin-mytolerance));
133 pol = new Graphic2d_Polyline(mygo,Av1);
134 pol ->SetColorIndex(4); //vert
135 pol->SetTypeIndex(2);
145 //================================================
146 // function : ClearAreas
148 //================================================
150 void StdSelect_ViewerSelector2d::ClearAreas ()
152 if (mygo.IsNull()) return;
153 mygo->RemovePrimitives();