Salome HOME
a00c59369cd8f51ba649955f3f01afa612f05a1a
[modules/shaper.git] / src / SketcherPrs / SketcherPrs_SymbolPrs.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        SketcherPrs_SymbolPrs.cpp
4 // Created:     12 March 2015
5 // Author:      Vitaly SMETANNIKOV
6
7 #include "SketcherPrs_SymbolPrs.h"
8 #include "SketcherPrs_Tools.h"
9 #include "SketcherPrs_PositionMgr.h"
10
11 #include <GeomAPI_Edge.h>
12 #include <GeomAPI_Vertex.h>
13 #include <GeomAPI_Curve.h>
14
15 #include <Events_Error.h>
16
17 #include <Graphic3d_ArrayOfSegments.hxx>
18 #include <Graphic3d_BndBox4f.hxx>
19
20 #include <SelectMgr_Selection.hxx>
21 #include <Select3D_SensitivePoint.hxx>
22 #include <TopLoc_Location.hxx>
23 #include <AIS_InteractiveContext.hxx>
24 #include <V3d_Viewer.hxx>
25 #include <Prs3d_Root.hxx>
26 #include <Geom_CartesianPoint.hxx>
27 #include <GeomAdaptor_Curve.hxx>
28 #include <StdPrs_DeflectionCurve.hxx>
29 #include <StdPrs_Point.hxx>
30 #include <StdPrs_Curve.hxx>
31
32 #include <OpenGl_Element.hxx>
33 #include <OpenGl_GraphicDriver.hxx>
34 #include <OpenGl_Context.hxx>
35 #include <OpenGl_View.hxx>
36 #include <OpenGl_PointSprite.hxx>
37 #include <OpenGl_VertexBuffer.hxx>
38 #include <OpenGl_ShaderManager.hxx>
39
40 #ifdef WIN32
41 # define FSEP "\\"
42 #else
43 # define FSEP "/"
44 #endif
45
46 /// Step between icons
47 static const double MyDist = 0.02;
48
49 //#define ICON_TO_DEBUG
50
51 /// Function to convert opengl data type
52 GLenum toGlDataType (const Graphic3d_TypeOfData theType, GLint& theNbComp)
53 {
54   switch (theType) {
55     case Graphic3d_TOD_USHORT:
56       theNbComp = 1;
57       return GL_UNSIGNED_SHORT;
58     case Graphic3d_TOD_UINT:
59       theNbComp = 1;
60       return GL_UNSIGNED_INT;
61     case Graphic3d_TOD_VEC2:
62       theNbComp = 2;
63       return GL_FLOAT;
64     case Graphic3d_TOD_VEC3:
65       theNbComp = 3;
66       return GL_FLOAT;
67     case Graphic3d_TOD_VEC4:
68       theNbComp = 4;
69       return GL_FLOAT;
70     case Graphic3d_TOD_VEC4UB:
71       theNbComp = 4;
72       return GL_UNSIGNED_BYTE;
73   }
74   theNbComp = 0;
75   return GL_NONE;
76 }
77
78
79 //*******************************************************************
80 //! Auxiliary class for Vertex buffer with interleaved attributes.
81 class SketcherPrs_VertexBuffer : public OpenGl_VertexBuffer
82 {
83
84 public:
85
86   //! Create uninitialized VBO..
87   //! \param theAttribs attributes
88   //! \param theStride a flag
89   SketcherPrs_VertexBuffer (const Graphic3d_Attribute* theAttribs,
90                         const Standard_Integer     theStride)
91   : Stride (theStride), NbAttributes(1)
92   {
93
94     memcpy (Attribs, theAttribs, sizeof(Graphic3d_Attribute) * NbAttributes);
95   }
96
97   //! Create uninitialized VBO.
98   SketcherPrs_VertexBuffer (const Graphic3d_Buffer& theAttribs)
99   : Stride (theAttribs.Stride), NbAttributes(1)
100   {
101     memcpy (Attribs, theAttribs.AttributesArray(), sizeof(Graphic3d_Attribute) * NbAttributes);
102   }
103
104   /// Returns True if color attribute is defined
105   virtual bool HasColorAttribute() const
106   {
107     for (Standard_Integer anAttribIter = 0; anAttribIter < NbAttributes; ++anAttribIter) {
108       const Graphic3d_Attribute& anAttrib = Attribs[anAttribIter];
109       if (anAttrib.Id == Graphic3d_TOA_COLOR) {
110         return true;
111       }
112     }
113     return false;
114   }
115
116   /// Returns True if normal attribute is defined
117   virtual bool HasNormalAttribute() const
118   {
119     for (Standard_Integer anAttribIter = 0; anAttribIter < NbAttributes; ++anAttribIter) {
120       const Graphic3d_Attribute& anAttrib = Attribs[anAttribIter];
121       if (anAttrib.Id == Graphic3d_TOA_NORM) {
122         return true;
123       }
124     }
125     return false;
126   }
127
128   /// Bind position of the attribute
129   /// \param theGlCtx OpenGl context
130   virtual void BindPositionAttribute (const Handle(OpenGl_Context)& theGlCtx) const
131   {
132     if (!OpenGl_VertexBuffer::IsValid()) {
133       return;
134     }
135
136     OpenGl_VertexBuffer::Bind (theGlCtx);
137     GLint aNbComp;
138     const GLubyte* anOffset = OpenGl_VertexBuffer::myOffset;
139     for (Standard_Integer anAttribIter = 0; anAttribIter < NbAttributes; ++anAttribIter) {
140       const Graphic3d_Attribute& anAttrib = Attribs[anAttribIter];
141       const GLenum   aDataType = toGlDataType (anAttrib.DataType, aNbComp);
142       if (aDataType == GL_NONE) {
143         continue;
144       } else if (anAttrib.Id == Graphic3d_TOA_POS) {
145         OpenGl_VertexBuffer::bindAttribute (theGlCtx, Graphic3d_TOA_POS, aNbComp, aDataType, Stride, anOffset);
146         break;
147       }
148
149       anOffset += Graphic3d_Attribute::Stride (anAttrib.DataType);
150     }
151   }
152
153   /// Bind all attributes
154   /// \param theGlCtx OpenGl context
155   virtual void BindAllAttributes (const Handle(OpenGl_Context)& theGlCtx) const
156   {
157     if (!OpenGl_VertexBuffer::IsValid())
158       return;
159
160     OpenGl_VertexBuffer::Bind (theGlCtx);
161     GLint aNbComp;
162     const GLubyte* anOffset = OpenGl_VertexBuffer::myOffset;
163     for (Standard_Integer anAttribIter = 0; anAttribIter < NbAttributes; ++anAttribIter)
164     {
165       const Graphic3d_Attribute& anAttrib = Attribs[anAttribIter];
166       const GLenum   aDataType = toGlDataType (anAttrib.DataType, aNbComp);
167       if (aDataType == GL_NONE)
168         continue;
169
170       OpenGl_VertexBuffer::bindAttribute (theGlCtx, anAttrib.Id, aNbComp, aDataType, Stride, anOffset);
171       anOffset += Graphic3d_Attribute::Stride (anAttrib.DataType);
172     }
173   }
174
175   /// Unbind all attributes
176   /// \param theGlCtx OpenGl context
177   virtual void UnbindAllAttributes (const Handle(OpenGl_Context)& theGlCtx) const
178   {
179     if (!OpenGl_VertexBuffer::IsValid())
180       return;
181     OpenGl_VertexBuffer::Unbind (theGlCtx);
182
183     for (Standard_Integer anAttribIter = 0; anAttribIter < NbAttributes; ++anAttribIter) {
184       const Graphic3d_Attribute& anAttrib = Attribs[anAttribIter];
185       OpenGl_VertexBuffer::unbindAttribute (theGlCtx, anAttrib.Id);
186     }
187   }
188
189 public:
190
191   /// Array of attributes
192   Graphic3d_Attribute Attribs[1];
193
194   /// A flag
195   Standard_Integer    Stride;
196
197   /// Number of attributes
198   Standard_Integer NbAttributes;
199 };
200
201 //**************************************************************
202 //! Redefinition of OpenGl_Element
203 class SketcherPrs_Element: public OpenGl_Element
204 {
205 public:
206   /// Constructor
207   /// \param theObj a presentation
208   SketcherPrs_Element(const Handle(SketcherPrs_SymbolPrs)& theObj) : 
209   OpenGl_Element(), myObj(theObj) {}
210
211   /// Render the current presentation
212   /// \param theWorkspace OpenGL workspace
213   virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const
214   {
215     if (!myObj.IsNull())
216       myObj->Render(theWorkspace);
217   }
218
219   /// Releases OpenGL resources
220   /// \param theContext OpenGL context
221   virtual void Release (OpenGl_Context* theContext) 
222   {
223     if (!myObj.IsNull())
224       myObj->Release(theContext);
225   }
226
227 private:
228   Handle(SketcherPrs_SymbolPrs) myObj;
229 };
230
231
232 //**************************************************************
233 //! Definition of call back
234 OpenGl_Element* SymbolPrsCallBack(const CALL_DEF_USERDRAW * theUserDraw)
235 {
236   Handle(SketcherPrs_SymbolPrs) anIObj = (SketcherPrs_SymbolPrs*)theUserDraw->Data;
237   if (anIObj.IsNull()) {
238     std::cout << "VUserDrawCallback error: null object passed, the custom scene element will not be rendered" << std::endl;
239   }
240   return new SketcherPrs_Element(anIObj);
241 }
242
243
244 //*****************************************************************************
245 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_SymbolPrs, AIS_InteractiveObject);
246 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_SymbolPrs, AIS_InteractiveObject);
247
248
249 std::map<const char*, Handle(Image_AlienPixMap)> SketcherPrs_SymbolPrs::myIconsMap;
250
251
252 SketcherPrs_SymbolPrs::SketcherPrs_SymbolPrs(ModelAPI_Feature* theConstraint, 
253                                              const std::shared_ptr<GeomAPI_Ax3>& thePlane)
254  : AIS_InteractiveObject(), myConstraint(theConstraint), myPlane(thePlane), myIsConflicting(false)
255 {
256   SetAutoHilight(Standard_False);
257 }
258
259 SketcherPrs_SymbolPrs::~SketcherPrs_SymbolPrs()
260 {
261   SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
262   // Empty memory in position manager
263   aMgr->deleteConstraint(this);
264 }
265
266 #ifdef _WINDOWS
267 #pragma warning( disable : 4996 )
268 #endif
269
270 Handle(Image_AlienPixMap) SketcherPrs_SymbolPrs::icon()
271 {
272 #ifdef ICON_TO_DEBUG
273   if (myIsConflicting) {
274     if (myErrorIcon.IsNull()) {
275       char* aEnv = getenv("NEWGEOM_ROOT_DIR");
276       if (aEnv != NULL) {
277         TCollection_AsciiString aFile(aEnv);
278         aFile+=FSEP;
279         aFile+="resources";
280         aFile += FSEP;
281         aFile += "conflicting_icon.png";
282         Handle(Image_AlienPixMap) aPixMap = new Image_AlienPixMap();
283         if (aPixMap->Load(aFile)) {
284           myErrorIcon = aPixMap;
285         }
286       }
287     }
288     return myErrorIcon;
289   }
290 #endif
291
292   if (myIconsMap.count(iconName()) == 1) {
293     return myIconsMap[iconName()];
294   }
295   // Load icon for the presentation
296   char* aEnv = getenv("NEWGEOM_ROOT_DIR");
297   if (aEnv != NULL) {
298     TCollection_AsciiString aFile(aEnv);
299     aFile+=FSEP;
300     aFile+="resources";
301     aFile += FSEP;
302     aFile += iconName();
303     Handle(Image_AlienPixMap) aPixMap = new Image_AlienPixMap();
304     if (aPixMap->Load(aFile)) {
305       myIconsMap[iconName()] = aPixMap;
306       return aPixMap;
307     }
308   }
309   // The icon for constraint is not found
310   static const char aMsg[] = "Error! constraint images are not found";
311   cout<<aMsg<<endl;
312   Events_Error::send(aMsg);
313   myIconsMap[iconName()] = Handle(Image_AlienPixMap)();
314   return Handle(Image_AlienPixMap)();
315 }
316
317 void SketcherPrs_SymbolPrs::prepareAspect()
318 {
319   // Create an aspect with the icon
320   if (myAspect.IsNull()) {
321     Handle(Image_AlienPixMap) aIcon = icon();
322     if (aIcon.IsNull()) 
323       myAspect = new Graphic3d_AspectMarker3d();
324     else
325       myAspect = new Graphic3d_AspectMarker3d(aIcon);
326   }
327 }
328
329 void SketcherPrs_SymbolPrs::addLine(const Handle(Graphic3d_Group)& theGroup, std::string theAttrName) const
330 {
331   ObjectPtr aObj = SketcherPrs_Tools::getResult(myConstraint, theAttrName);
332   std::shared_ptr<GeomAPI_Shape> aLine = SketcherPrs_Tools::getShape(aObj);
333   if (aLine.get() == NULL)
334     return;
335   std::shared_ptr<GeomAPI_Edge> aEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(aLine));
336
337   std::shared_ptr<GeomAPI_Pnt> aPnt1 = aEdge->firstPoint();
338   std::shared_ptr<GeomAPI_Pnt> aPnt2 = aEdge->lastPoint();
339
340   // Draw line by two points
341   Handle(Graphic3d_ArrayOfSegments) aLines = new Graphic3d_ArrayOfSegments(2, 1);
342   aLines->AddVertex(aPnt1->impl<gp_Pnt>());
343   aLines->AddVertex(aPnt2->impl<gp_Pnt>());
344   theGroup->AddPrimitiveArray(aLines);
345 }
346
347 void SketcherPrs_SymbolPrs::HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM, 
348                                            const SelectMgr_SequenceOfOwner& theOwners)
349 {
350
351   Handle( Prs3d_Presentation ) aSelectionPrs = GetSelectPresentation( thePM );
352   aSelectionPrs->Clear();
353   drawLines(aSelectionPrs, Quantity_NOC_WHITE);
354
355   aSelectionPrs->SetDisplayPriority(9);
356   aSelectionPrs->Display();
357   thePM->Highlight(this);
358 }
359
360 void SketcherPrs_SymbolPrs::HilightOwnerWithColor(const Handle(PrsMgr_PresentationManager3d)& thePM, 
361                                                  const Quantity_NameOfColor theColor, 
362                                                  const Handle(SelectMgr_EntityOwner)& theOwner)
363 {
364   thePM->Color(this, theColor);
365
366   Handle( Prs3d_Presentation ) aHilightPrs = GetHilightPresentation( thePM );
367   aHilightPrs->Clear();
368   drawLines(aHilightPrs, theColor);
369
370   if (thePM->IsImmediateModeOn())
371     thePM->AddToImmediateList(aHilightPrs);
372 }
373
374 void SketcherPrs_SymbolPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
375                                    const Handle(Prs3d_Presentation)& thePresentation, 
376                                    const Standard_Integer theMode)
377 {
378   // Create an icon
379   prepareAspect();
380
381   Handle(AIS_InteractiveContext) aCtx = GetContext();
382   Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast(aCtx->CurrentViewer()->Driver());
383   if (!aDriver.IsNull()) {
384     // register the custom element factory function
385     aDriver->UserDrawCallback() = SymbolPrsCallBack;
386   }
387
388   // Update points with default shift value
389   if (!updatePoints(20)) {
390     return;
391   }
392
393   int aNbVertex = myPntArray->VertexNumber();
394   if (myOwner.IsNull()) {
395     myOwner = new SelectMgr_EntityOwner(this);
396   }
397
398   // Create sensitive point for each symbol
399   mySPoints.Clear();
400   for (int i = 1; i <= aNbVertex; i++) {
401     Handle(SketcherPrs_SensitivePoint) aSP = new SketcherPrs_SensitivePoint(myOwner, i);
402     mySPoints.Append(aSP);
403   }
404
405   Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePresentation);
406   aGroup->SetPrimitivesAspect(myAspect);
407
408   // Recompute boundary box of the group
409   Graphic3d_BndBox4f& aBnd = aGroup->ChangeBoundingBox();
410   gp_Pnt aVert;
411   aBnd.Clear();
412   for (int i = 1; i <= myPntArray->ItemNumber(); i++) {
413     aVert = myPntArray->Vertice(i);
414     aBnd.Add (Graphic3d_Vec4((float)aVert.X(), (float)aVert.Y(), (float)aVert.Z(), 1.0f));
415   }
416
417   // Pint the group with custom procedure (see Render)
418   aGroup->UserDraw(this, true);
419
420   // Disable frustum culling for this object by marking it as mutable
421   aGroup->Structure()->SetMutable(true);
422   //aGroup->AddPrimitiveArray(myPntArray);
423 }
424
425
426
427 void SketcherPrs_SymbolPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
428                                              const Standard_Integer aMode)
429 {
430   ClearSelected();
431   if ((aMode == 0) || (aMode == SketcherPrs_Tools::Sel_Constraint)) {
432     for (int i = 1; i <= mySPoints.Length(); i++)
433       aSelection->Add(mySPoints.Value(i));
434   }
435 }
436
437 void SketcherPrs_SymbolPrs::SetConflictingConstraint(const bool& theConflicting,
438                                                      const std::vector<int>& theColor)
439 {
440 #ifdef ICON_TO_DEBUG
441   if (myIsConflicting != theConflicting) {
442     myIsConflicting = theConflicting;
443     Handle(Image_AlienPixMap) anIcon = icon();
444     if (!anIcon.IsNull())
445       myAspect->SetMarkerImage(new Graphic3d_MarkerImage(anIcon));
446   }
447 #else
448   if (theConflicting)
449   {
450     if (!myAspect.IsNull())
451       myAspect->SetColor (Quantity_Color (theColor[0] / 255., theColor[1] / 255., theColor[2] / 255.,
452                           Quantity_TOC_RGB));
453     myIsConflicting = true;
454   }
455   else
456   {
457     if (!myAspect.IsNull())
458       myAspect->SetColor (Quantity_Color (1.0, 1.0, 0.0, Quantity_TOC_RGB));
459     myIsConflicting = false;
460   }
461 #endif
462 }
463
464 void SketcherPrs_SymbolPrs::Render(const Handle(OpenGl_Workspace)& theWorkspace) const
465 {
466   // this method is a combination of OCCT OpenGL functions. The main purpose is to have
467   // equal distance from the source object to symbol indpendently of zoom.
468   // It is base on OCCT 6.9.1 and might need changes when using later OCCT versions.
469   // The specific SHAPER modifications are marked by ShaperModification:start/end, other is OCCT code
470
471   // do not update presentation for invalid or already removed objects: the presentation
472   // should be removed soon
473   if (!myConstraint->data().get() || !myConstraint->data()->isValid())
474     return;
475
476   const OpenGl_AspectMarker* anAspectMarker = theWorkspace->AspectMarker(Standard_True);
477   const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
478   Handle(OpenGl_View) aView = theWorkspace->ActiveView();
479   
480   // ShaperModification:start
481   double aScale = aView->Camera()->Scale();
482   // Update points coordinate taking the viewer scale into account
483   if (!updatePoints(MyDist * aScale))
484     return;
485   // ShaperModification:end
486
487   Handle(Graphic3d_Buffer) aAttribs = myPntArray->Attributes();
488
489   if (myVboAttribs.IsNull()) {
490     myVboAttribs = new SketcherPrs_VertexBuffer(*aAttribs);
491   }
492
493   // Update drawing attributes
494   if (!myVboAttribs->init(aCtx, 0, aAttribs->NbElements, aAttribs->Data(), GL_NONE, aAttribs->Stride)) {
495     myVboAttribs->Release (aCtx.operator->());
496     myVboAttribs.Nullify();
497     return;
498   }
499     
500   Handle(OpenGl_Texture) aTextureBack = theWorkspace->DisableTexture();
501
502   const Handle(OpenGl_PointSprite)& aSpriteNorm = anAspectMarker->SpriteRes(aCtx);
503       
504   if (!aSpriteNorm.IsNull() && !aSpriteNorm->IsDisplayList()) {
505 #ifdef ICON_TO_DEBUG
506     const bool toHilight = (theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT) != 0;
507 #else
508     // ShaperModification:start : filling the presentation with color if there is a conflict
509     const bool toHilight = (theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT) != 0 || myIsConflicting;
510     // ShaperModification:end
511 #endif
512
513     const Handle(OpenGl_PointSprite)& aSprite = (toHilight && anAspectMarker->SpriteHighlightRes(aCtx)->IsValid())
514                                               ? anAspectMarker->SpriteHighlightRes(aCtx)
515                                               : aSpriteNorm;
516     theWorkspace->EnableTexture (aSprite);
517     aCtx->ShaderManager()->BindProgram(anAspectMarker, aSprite, Standard_False, Standard_False, anAspectMarker->ShaderProgramRes(aCtx));
518     const TEL_COLOUR* aLineColor  =  &anAspectMarker->Color();
519     if (theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT)
520       aLineColor = theWorkspace->HighlightColor;
521
522     // Set lighting of the symbol
523     if (toHilight)
524       aCtx->core11fwd->glDisable (GL_LIGHTING);
525     else
526       aCtx->core11fwd->glEnable (GL_LIGHTING);
527
528     aCtx->SetColor4fv(*(const OpenGl_Vec4* )(aLineColor->rgb));
529
530
531     myVboAttribs->BindAllAttributes(aCtx);
532     // Textured markers will be drawn with the point sprites
533     aCtx->SetPointSize (anAspectMarker->MarkerSize());
534     aCtx->core11fwd->glEnable (GL_ALPHA_TEST);
535     aCtx->core11fwd->glAlphaFunc (GL_GEQUAL, 0.1f);
536
537     aCtx->core11fwd->glEnable (GL_BLEND);
538     aCtx->core11fwd->glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
539
540     aCtx->core11fwd->glDrawArrays (0, 0, myVboAttribs->GetElemsNb());
541
542     aCtx->core11fwd->glDisable (GL_BLEND);
543     aCtx->core11fwd->glDisable (GL_ALPHA_TEST);
544     aCtx->SetPointSize (1.0f);
545   }
546   theWorkspace->EnableTexture (aTextureBack);
547   aCtx->BindProgram (NULL);
548
549   // Update selection position only if there is no selected object
550   // because it can corrupt selection of other objects
551   if ((GetContext()->NbCurrents() == 0) && (GetContext()->NbSelected() == 0))
552   {
553     GetContext()->MainSelector()->RebuildSensitivesTree (this);
554     GetContext()->MainSelector()->RebuildObjectsTree (false);
555   }
556 }
557
558
559 void SketcherPrs_SymbolPrs::Release (OpenGl_Context* theContext)
560 {
561   // Release OpenGl resources
562   if (!myVboAttribs.IsNull()) {
563     if (theContext) {
564       theContext->DelayedRelease (myVboAttribs);
565     }
566     myVboAttribs.Nullify();
567   }
568 }
569
570 void SketcherPrs_SymbolPrs::drawShape(const std::shared_ptr<GeomAPI_Shape>& theShape, 
571                                       const Handle(Prs3d_Presentation)& thePrs) const
572 {
573   if (theShape->isEdge()) {
574     // The shape is edge
575     std::shared_ptr<GeomAPI_Curve> aCurve = 
576       std::shared_ptr<GeomAPI_Curve>(new GeomAPI_Curve(theShape));
577     if (aCurve->isLine()) {
578       // The shape is line
579       GeomAdaptor_Curve aCurv(aCurve->impl<Handle(Geom_Curve)>(), aCurve->startParam(), aCurve->endParam());
580       StdPrs_Curve::Add(thePrs, aCurv, myDrawer);
581     } else {
582       // The shape is circle or arc
583       GeomAdaptor_Curve aAdaptor(aCurve->impl<Handle(Geom_Curve)>(), aCurve->startParam(), aCurve->endParam());
584       StdPrs_DeflectionCurve::Add(thePrs,aAdaptor,myDrawer);
585     }
586   } else if (theShape->isVertex()) {
587     // draw vertex
588     std::shared_ptr<GeomAPI_Vertex> aVertex = 
589       std::shared_ptr<GeomAPI_Vertex>(new GeomAPI_Vertex(theShape));
590     std::shared_ptr<GeomAPI_Pnt> aPnt = aVertex->point();
591     Handle(Geom_CartesianPoint) aPoint = new Geom_CartesianPoint(aPnt->impl<gp_Pnt>());
592     StdPrs_Point::Add(thePrs, aPoint, myDrawer);
593   }
594 }
595
596 void SketcherPrs_SymbolPrs::drawListOfShapes(const std::shared_ptr<ModelAPI_AttributeRefList>& theListAttr, 
597                                              const Handle(Prs3d_Presentation)& thePrs) const
598 {
599   int aNb = theListAttr->size();
600   if (aNb == 0)
601     return;
602   int i;
603   ObjectPtr aObj;
604   for (i = 0; i < aNb; i++) {
605     aObj = theListAttr->object(i);
606     std::shared_ptr<GeomAPI_Shape> aShape = SketcherPrs_Tools::getShape(aObj);
607     if (aShape.get() != NULL)
608       drawShape(aShape, thePrs);
609   }
610 }
611
612 void SketcherPrs_SymbolPrs::BoundingBox (Bnd_Box& theBndBox)
613 {
614   Select3D_BndBox3d aTmpBox;
615   for (Select3D_EntitySequenceIter aPntIter (mySPoints); aPntIter.More(); aPntIter.Next()) {
616     const Handle(Select3D_SensitiveEntity)& anEnt = aPntIter.Value();
617     aTmpBox.Combine (anEnt->BoundingBox());
618   }
619
620   theBndBox.Update (aTmpBox.CornerMin().x(), aTmpBox.CornerMin().y(), aTmpBox.CornerMin().z(),
621                     aTmpBox.CornerMax().x(), aTmpBox.CornerMax().y(), aTmpBox.CornerMax().z());
622 }
623