]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_Tools.cpp
Salome HOME
Improve the correcting orientation in the Filling feature.
[modules/shaper.git] / src / ModuleBase / ModuleBase_Tools.cpp
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #include "ModuleBase_Tools.h"
22
23 #include <ModuleBase_ParamIntSpinBox.h>
24 #include <ModuleBase_ParamSpinBox.h>
25 #include <ModuleBase_WidgetFactory.h>
26 #include <ModuleBase_IWorkshop.h>
27 #include <ModuleBase_IModule.h>
28 #include <ModuleBase_IconFactory.h>
29 #include <ModuleBase_ResultPrs.h>
30 #include <ModuleBase_ViewerPrs.h>
31
32 #include <ModelAPI_Attribute.h>
33 #include <ModelAPI_AttributeRefAttr.h>
34 #include <ModelAPI_AttributeReference.h>
35 #include <ModelAPI_AttributeSelection.h>
36 #include <ModelAPI_AttributeSelectionList.h>
37 #include <ModelAPI_AttributeRefList.h>
38 #include <ModelAPI_AttributeRefAttrList.h>
39 #include <ModelAPI_ResultPart.h>
40 #include <ModelAPI_ResultConstruction.h>
41 #include <Events_Loop.h>
42
43 #include <ModelAPI_Data.h>
44 #include <ModelAPI_Result.h>
45 #include <ModelAPI_ResultCompSolid.h>
46 #include <ModelAPI_ResultParameter.h>
47 #include <ModelAPI_Tools.h>
48 #include <ModelAPI_Session.h>
49 #include <ModelAPI_Events.h>
50 #include <ModelAPI_Folder.h>
51
52 #include <ModelGeomAlgo_Point2D.h>
53
54 #include <StdSelect_BRepOwner.hxx>
55 #include <TopoDS_Iterator.hxx>
56
57 #include <GeomDataAPI_Point2D.h>
58 #include <Events_InfoMessage.h>
59 #include <GeomAPI_ShapeExplorer.h>
60
61 #include <Config_PropManager.h>
62 #include <Config_Translator.h>
63
64 #include <Prs3d_PointAspect.hxx>
65 #include <Graphic3d_AspectMarker3d.hxx>
66
67 #include <Image_AlienPixMap.hxx>
68
69 #include <QWidget>
70 #include <QLayout>
71 #include <QPainter>
72 #include <QBitmap>
73 #include <QDoubleSpinBox>
74 #include <QGraphicsDropShadowEffect>
75 #include <QColor>
76 #include <QApplication>
77 #include <QMessageBox>
78 #include <QAction>
79 #include <QTextCodec>
80
81 #include <sstream>
82 #include <string>
83
84 #ifdef WIN32
85 #pragma warning(disable : 4996) // for getenv
86 #endif
87
88 const double tolerance = 1e-7;
89 const double DEFAULT_DEVIATION_COEFFICIENT = 1.e-4;
90
91 //#define DEBUG_ACTIVATE_WINDOW
92 //#define DEBUG_SET_FOCUS
93
94 #ifdef WIN32
95 # define FSEP "\\"
96 #else
97 # define FSEP "/"
98 #endif
99
100 namespace ModuleBase_Tools {
101
102 //******************************************************************
103
104 //******************************************************************
105
106 void adjustMargins(QWidget* theWidget)
107 {
108   if(!theWidget)
109     return;
110   adjustMargins(theWidget->layout());
111 }
112
113 void adjustMargins(QLayout* theLayout)
114 {
115   if(!theLayout)
116     return;
117   theLayout->setContentsMargins(2, 5, 2, 5);
118   theLayout->setSpacing(4);
119 }
120
121 void zeroMargins(QWidget* theWidget)
122 {
123   if(!theWidget)
124     return;
125   zeroMargins(theWidget->layout());
126 }
127
128 void zeroMargins(QLayout* theLayout)
129 {
130   if(!theLayout)
131     return;
132   theLayout->setContentsMargins(0, 0, 0, 0);
133   theLayout->setSpacing(5);
134 }
135
136 void activateWindow(QWidget* theWidget, const QString& theInfo)
137 {
138   if (theWidget) {
139     theWidget->activateWindow();
140     theWidget->raise();
141   }
142
143 #ifdef DEBUG_ACTIVATE_WINDOW
144   qDebug(QString("activateWindow: %1").arg(theInfo).toStdString().c_str());
145 #endif
146 }
147
148 void setFocus(QWidget* theWidget, const QString& theInfo)
149 {
150   activateWindow(theWidget);
151   theWidget->setFocus();
152   // rectangle of focus is not visible on tool button widgets
153   theWidget->repaint();
154 #ifdef DEBUG_SET_FOCUS
155   qDebug(QString("setFocus: %1").arg(theInfo).toStdString().c_str());
156 #endif
157 }
158
159 void setShadowEffect(QWidget* theWidget, const bool isSetEffect)
160 {
161   if (isSetEffect) {
162     QGraphicsDropShadowEffect* aGlowEffect = new QGraphicsDropShadowEffect();
163     aGlowEffect->setOffset(.0);
164     aGlowEffect->setBlurRadius(10.0);
165     aGlowEffect->setColor(QColor(0, 170, 255)); // Light-blue color, #00AAFF
166     theWidget->setGraphicsEffect(aGlowEffect);
167   }
168   else {
169     QGraphicsEffect* anEffect = theWidget->graphicsEffect();
170     if(anEffect)
171       anEffect->deleteLater();
172     theWidget->setGraphicsEffect(NULL);
173   }
174 }
175
176 QPixmap composite(const QString& theAdditionalIcon, const QString& theIcon)
177 {
178   QImage anIcon = ModuleBase_IconFactory::loadImage(theIcon);
179   QImage anAditional(theAdditionalIcon);
180
181   if (anIcon.isNull())
182     return QPixmap();
183
184   int anAddWidth = anAditional.width();
185   int anAddHeight = anAditional.height();
186
187   int aWidth = anIcon.width();
188   int aHeight = anIcon.height();
189
190   int aStartWidthPos = aWidth - anAddWidth - 1;
191   int aStartHeightPos = aHeight - anAddHeight - 1;
192
193   for (int i = 0; i < anAddWidth && i + aStartWidthPos < aWidth; i++)
194   {
195     for (int j = 0; j < anAddHeight && j + aStartHeightPos < aHeight; j++)
196     {
197       if (qAlpha(anAditional.pixel(i, j)) > 0)
198         anIcon.setPixel(i + aStartWidthPos, j + aStartHeightPos, anAditional.pixel(i, j));
199     }
200   }
201   return QPixmap::fromImage(anIcon);
202 }
203
204 QPixmap lighter(const QString& theIcon, const int theLighterValue)
205 {
206   QImage anIcon = ModuleBase_IconFactory::loadImage(theIcon);
207   if (anIcon.isNull())
208     return QPixmap();
209
210   QImage aResult = ModuleBase_IconFactory::loadImage(theIcon);
211   for (int i = 0; i < anIcon.width(); i++)
212   {
213     for (int j = 0; j < anIcon.height(); j++)
214     {
215       QRgb anRgb = anIcon.pixel(i, j);
216       QColor aPixelColor(qRed(anRgb), qGreen(anRgb), qBlue(anRgb),
217                          qAlpha(aResult.pixel(i, j)));
218
219       QColor aLighterColor = aPixelColor.lighter(theLighterValue);
220       aResult.setPixel(i, j, qRgba(aLighterColor.red(), aLighterColor.green(),
221                                     aLighterColor.blue(), aLighterColor.alpha()));
222     }
223   }
224   return QPixmap::fromImage(aResult);
225 }
226
227 void setSpinText(ModuleBase_ParamSpinBox* theSpin, const QString& theText)
228 {
229   if (theSpin->text() == theText)
230     return;
231   // In order to avoid extra text setting because it will
232   // reset cursor position in control
233   bool isBlocked = theSpin->blockSignals(true);
234   theSpin->setText(theText);
235   theSpin->blockSignals(isBlocked);
236 }
237
238 void setSpinValue(QDoubleSpinBox* theSpin, double theValue)
239 {
240   if (fabs(theSpin->value() - theValue) < tolerance)
241     return;
242   bool isBlocked = theSpin->blockSignals(true);
243   theSpin->setValue(theValue);
244   theSpin->blockSignals(isBlocked);
245 }
246
247 void setSpinValue(ModuleBase_ParamSpinBox* theSpin, double theValue)
248 {
249   if (fabs(theSpin->value() - theValue) < tolerance)
250     return;
251   bool isBlocked = theSpin->blockSignals(true);
252   theSpin->setValue(theValue);
253   theSpin->blockSignals(isBlocked);
254 }
255
256 void setSpinText(ModuleBase_ParamIntSpinBox* theSpin, const QString& theText)
257 {
258   // In order to avoid extra text setting because it will
259   // reset cursor position in control
260   if (theSpin->text() == theText)
261     return;
262   bool isBlocked = theSpin->blockSignals(true);
263   theSpin->setText(theText);
264   theSpin->blockSignals(isBlocked);
265 }
266
267 void setSpinValue(ModuleBase_ParamIntSpinBox* theSpin, int theValue)
268 {
269   if (theSpin->value() == theValue)
270     return;
271   bool isBlocked = theSpin->blockSignals(true);
272   theSpin->setValue(theValue);
273   theSpin->blockSignals(isBlocked);
274 }
275
276 QAction* createAction(const QIcon& theIcon, const QString& theText,
277                       QObject* theParent, const QObject* theReceiver,
278                       const char* theMember, const QString& theToolTip,
279                       const QString& theStatusTip)
280 {
281   QAction* anAction = new QAction(theIcon, theText, theParent);
282   anAction->setToolTip(theToolTip.isEmpty() ? theText : theToolTip);
283   anAction->setStatusTip(!theStatusTip.isEmpty() ? theStatusTip :
284                                                    (!theToolTip.isEmpty() ? theToolTip : theText));
285   if (theReceiver)
286     QObject::connect(anAction, SIGNAL(triggered(bool)), theReceiver, theMember);
287
288   return anAction;
289 }
290
291 #ifdef _DEBUG
292 QString objectName(const ObjectPtr& theObj)
293 {
294   if (!theObj.get())
295     return "";
296
297   return theObj->data()->name().c_str();
298 }
299
300 QString objectInfo(const ObjectPtr& theObj, const bool isUseAttributesInfo)
301 {
302   QString aFeatureStr = "feature";
303   if (!theObj.get())
304     return aFeatureStr;
305
306   std::ostringstream aPtrStr;
307   aPtrStr << "[" << theObj.get() << "]";
308
309   ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObj);
310   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theObj);
311   if(aRes.get()) {
312     aFeatureStr.append(QString("(result%1)").arg(aPtrStr.str().c_str()).toStdString() .c_str());
313     if (aRes->isDisabled())
314       aFeatureStr.append("[disabled]");
315     if (aRes->isConcealed())
316       aFeatureStr.append("[concealed]");
317     if (ModelAPI_Tools::hasSubResults(aRes))
318       aFeatureStr.append("[hasSubResults]");
319
320     aFeature = ModelAPI_Feature::feature(aRes);
321   }
322   else
323     aFeatureStr.append(aPtrStr.str().c_str());
324
325   if (aFeature.get()) {
326     aFeatureStr.append(QString(": %1").arg(aFeature->getKind().c_str()).toStdString().c_str());
327     if (aFeature->data()->isValid()) {
328       aFeatureStr.append(QString(", name=%1").arg(theObj->data()->name().c_str()).toStdString()
329                                                                                        .c_str());
330     }
331     if (isUseAttributesInfo) {
332       std::set<std::shared_ptr<ModelAPI_Attribute> > anAttributes;
333       std::string aPointsInfo = ModelGeomAlgo_Point2D::getPontAttributesInfo(aFeature,
334                                                                           anAttributes).c_str();
335       if (!aPointsInfo.empty())
336         aFeatureStr.append(QString(", attributes: %1")
337           .arg(aPointsInfo.c_str()).toStdString().c_str());
338     }
339   }
340
341   return aFeatureStr;
342 }
343 #endif
344
345 typedef QMap<QString, int> ShapeTypes;
346 static ShapeTypes myShapeTypes;
347
348 int shapeType(const QString& theType)
349 {
350   if (myShapeTypes.count() == 0) {
351     myShapeTypes["compound"]   = TopAbs_COMPOUND;
352     myShapeTypes["compounds"]  = TopAbs_COMPOUND;
353     myShapeTypes["compsolid"]  = TopAbs_COMPSOLID;
354     myShapeTypes["compsolids"] = TopAbs_COMPSOLID;
355     myShapeTypes["solid"]      = TopAbs_SOLID;
356     myShapeTypes["solids"]     = TopAbs_SOLID;
357     myShapeTypes["shell"]      = TopAbs_SHELL;
358     myShapeTypes["shells"]     = TopAbs_SHELL;
359     myShapeTypes["face"]       = TopAbs_FACE;
360     myShapeTypes["faces"]      = TopAbs_FACE;
361     myShapeTypes["wire"]       = TopAbs_WIRE;
362     myShapeTypes["wires"]      = TopAbs_WIRE;
363     myShapeTypes["edge"]       = TopAbs_EDGE;
364     myShapeTypes["edges"]      = TopAbs_EDGE;
365     myShapeTypes["vertex"]     = TopAbs_VERTEX;
366     myShapeTypes["vertices"]   = TopAbs_VERTEX;
367     myShapeTypes["object"]     = ModuleBase_ResultPrs::Sel_Result;
368     myShapeTypes["objects"]    = ModuleBase_ResultPrs::Sel_Result;
369   }
370   QString aType = theType.toLower();
371   if(myShapeTypes.contains(aType))
372     return myShapeTypes[aType];
373   Events_InfoMessage("ModuleBase_Tools", "Shape type defined in XML is not implemented!").send();
374   return TopAbs_SHAPE;
375 }
376
377 void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFeature,
378                   bool& hasParameter, bool& hasCompositeOwner, bool& hasResultInHistory,
379                   bool& hasFolder)
380 {
381   hasResult = false;
382   hasFeature = false;
383   hasParameter = false;
384   hasCompositeOwner = false;
385   hasResultInHistory = false;
386   hasFolder = false;
387   foreach(ObjectPtr aObj, theObjects) {
388     FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
389     ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
390     FolderPtr aFolder = std::dynamic_pointer_cast<ModelAPI_Folder>(aObj);
391     ResultParameterPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aResult);
392
393     hasResult |= (aResult.get() != NULL);
394     hasFeature |= (aFeature.get() != NULL);
395     hasFolder |= (aFolder.get() != NULL);
396     hasParameter |= (aConstruction.get() != NULL);
397     if (hasFeature)
398       hasCompositeOwner |= (ModelAPI_Tools::compositeOwner(aFeature) != NULL);
399
400     if (!hasResultInHistory && aResult.get()) {
401       FeaturePtr aFeature = ModelAPI_Feature::feature(aResult);
402       hasResultInHistory = aFeature.get() && aFeature->isInHistory();
403     }
404
405     if (hasFeature && hasResult  && hasParameter && hasCompositeOwner && hasFeature)
406       break;
407   }
408 }
409
410 /*bool setDefaultDeviationCoefficient(std::shared_ptr<GeomAPI_Shape> theGeomShape)
411 {
412   if (!theGeomShape.get())
413     return false;
414   // if the shape could not be exploded on faces, it contains only wires, edges, and vertices
415   // correction of deviation for them should not influence to the application performance
416   GeomAPI_ShapeExplorer anExp(theGeomShape, GeomAPI_Shape::FACE);
417   bool anEmpty = anExp.empty();
418   return !anExp.more();
419 }*/
420
421 /*void setDefaultDeviationCoefficient(const std::shared_ptr<ModelAPI_Result>& theResult,
422                                     const Handle(Prs3d_Drawer)& theDrawer)
423 {
424   if (!theResult.get())
425     return;
426   bool aUseDeviation = false;
427
428   std::string aResultGroup = theResult->groupName();
429   if (aResultGroup == ModelAPI_ResultConstruction::group())
430     aUseDeviation = true;
431   else if (aResultGroup == ModelAPI_ResultBody::group()) {
432     GeomShapePtr aGeomShape = theResult->shape();
433     if (aGeomShape.get())
434       aUseDeviation = setDefaultDeviationCoefficient(aGeomShape);
435   }
436   if (aUseDeviation)
437     theDrawer->SetDeviationCoefficient(DEFAULT_DEVIATION_COEFFICIENT);
438 }
439 */
440 void setDefaultDeviationCoefficient(const TopoDS_Shape& theShape,
441                                     const Handle(Prs3d_Drawer)& theDrawer)
442 {
443   if (theShape.IsNull())
444     return;
445
446   std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape());
447   aGeomShape->setImpl(new TopoDS_Shape(theShape));
448
449   // if the shape could not be exploded on faces, it contains only wires, edges, and vertices
450   // correction of deviation for them should not influence to the application performance
451   GeomAPI_ShapeExplorer anExp(aGeomShape, GeomAPI_Shape::FACE);
452   bool isConstruction = !anExp.more();
453
454   double aDeflection;
455   if (isConstruction)
456     aDeflection = Config_PropManager::real("Visualization", "construction_deflection");
457   else
458     aDeflection = Config_PropManager::real("Visualization", "body_deflection");
459
460   theDrawer->SetDeviationCoefficient(aDeflection);
461 }
462
463 Quantity_Color color(const std::string& theSection,
464                      const std::string& theName)
465 {
466   std::vector<int> aColor = Config_PropManager::color(theSection, theName);
467   return Quantity_Color(aColor[0] / 255., aColor[1] / 255., aColor[2] / 255., Quantity_TOC_RGB);
468 }
469
470 ObjectPtr getObject(const AttributePtr& theAttribute)
471 {
472   ObjectPtr anObject;
473   std::string anAttrType = theAttribute->attributeType();
474   if (anAttrType == ModelAPI_AttributeRefAttr::typeId()) {
475     AttributeRefAttrPtr anAttr =
476       std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
477     if (anAttr != NULL && anAttr->isObject())
478       anObject = anAttr->object();
479   }
480   if (anAttrType == ModelAPI_AttributeSelection::typeId()) {
481     AttributeSelectionPtr anAttr =
482       std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
483     if (anAttr != NULL)
484       anObject = anAttr->context();
485   }
486   if (anAttrType == ModelAPI_AttributeReference::typeId()) {
487     AttributeReferencePtr anAttr =
488       std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
489     if (anAttr.get() != NULL)
490       anObject = anAttr->value();
491   }
492   return anObject;
493 }
494
495 TopAbs_ShapeEnum getCompoundSubType(const TopoDS_Shape& theShape)
496 {
497   TopAbs_ShapeEnum aShapeType = theShape.ShapeType();
498
499   // for compounds check sub-shapes: it may be compound of needed type:
500   // Booleans may produce compounds of Solids
501   if (aShapeType == TopAbs_COMPOUND) {
502     for(TopoDS_Iterator aSubs(theShape); aSubs.More(); aSubs.Next()) {
503       if (!aSubs.Value().IsNull()) {
504         TopAbs_ShapeEnum aSubType = aSubs.Value().ShapeType();
505         if (aSubType == TopAbs_COMPOUND) { // compound of compound(s)
506           aShapeType = TopAbs_COMPOUND;
507           break;
508         }
509         if (aShapeType == TopAbs_COMPOUND) {
510           aShapeType = aSubType;
511         } else if (aShapeType != aSubType) { // compound of shapes of different types
512           aShapeType = TopAbs_COMPOUND;
513           break;
514         }
515       }
516     }
517   }
518   return aShapeType;
519 }
520
521 TopoDS_Shape getSelectedShape(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs)
522 {
523   if (thePrs->shape().get())
524     return thePrs->shape()->impl<TopoDS_Shape>();
525
526   Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(thePrs->owner());
527   if (!anOwner.IsNull())
528     return anOwner->Shape();
529
530   return TopoDS_Shape();
531 }
532
533 void getParameters(QStringList& theParameters)
534 {
535   theParameters.clear();
536
537   SessionPtr aSession = ModelAPI_Session::get();
538   std::list<DocumentPtr> aDocList;
539   DocumentPtr anActiveDocument = aSession->activeDocument();
540   DocumentPtr aRootDocument = aSession->moduleDocument();
541   aDocList.push_back(anActiveDocument);
542   if (anActiveDocument != aRootDocument) {
543     aDocList.push_back(aRootDocument);
544   }
545   std::string aGroupId = ModelAPI_ResultParameter::group();
546   for(std::list<DocumentPtr>::const_iterator it = aDocList.begin(); it != aDocList.end(); ++it) {
547     DocumentPtr aDocument = *it;
548     int aSize = aDocument->size(aGroupId);
549     for (int i = 0; i < aSize; i++) {
550       ObjectPtr anObject = aDocument->object(aGroupId, i);
551       std::string aParameterName = anObject->data()->name();
552       theParameters.append(aParameterName.c_str());
553     }
554   }
555 }
556
557 std::string findGreedAttribute(ModuleBase_IWorkshop* theWorkshop,
558                                const FeaturePtr& theFeature)
559 {
560   std::string anAttributeId;
561
562   std::string aXmlCfg, aDescription;
563   theWorkshop->module()->getXMLRepresentation(theFeature->getKind(), aXmlCfg, aDescription);
564
565   ModuleBase_WidgetFactory aFactory(aXmlCfg, theWorkshop);
566   std::string anAttributeTitle;
567   aFactory.getGreedAttribute(anAttributeId);
568
569   return anAttributeId;
570 }
571
572 bool hasObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
573                const std::shared_ptr<GeomAPI_Shape>& theShape,
574                ModuleBase_IWorkshop* theWorkshop,
575                const bool theTemporarily)
576 {
577   bool aHasObject = false;
578   if (!theAttribute.get())
579     return aHasObject;
580
581   std::string aType = theAttribute->attributeType();
582   if (aType == ModelAPI_AttributeReference::typeId()) {
583     AttributeReferencePtr aRef =
584       std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
585     ObjectPtr aObject = aRef->value();
586     aHasObject = aObject && aObject->isSame(theObject);
587     //if (!(aObject && aObject->isSame(theObject))) {
588     //  aRef->setValue(theObject);
589     //}
590   } else if (aType == ModelAPI_AttributeRefAttr::typeId()) {
591     AttributeRefAttrPtr aRefAttr =
592       std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
593
594     AttributePtr anAttribute = theWorkshop->module()->findAttribute(theObject, theShape);
595     if (anAttribute.get()) {
596       //aRefAttr->setAttr(anAttribute);
597     }
598     else {
599       ObjectPtr aObject = aRefAttr->object();
600       aHasObject = aObject && aObject->isSame(theObject);
601       //if (!(aObject && aObject->isSame(theObject))) {
602       //  aRefAttr->setObject(theObject);
603       //}
604     }
605   } else if (aType == ModelAPI_AttributeSelection::typeId()) {
606     /*AttributeSelectionPtr aSelectAttr =
607                              std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
608     ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
609     if (aSelectAttr.get() != NULL) {
610       aSelectAttr->setValue(aResult, theShape, theTemporarily);
611     }*/
612   }
613   if (aType == ModelAPI_AttributeSelectionList::typeId()) {
614     AttributeSelectionListPtr aSelectionListAttr =
615                          std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
616     ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
617     aHasObject = aSelectionListAttr->isInList(aResult, theShape, theTemporarily);
618   }
619   else if (aType == ModelAPI_AttributeRefList::typeId()) {
620     AttributeRefListPtr aRefListAttr =
621       std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
622     aHasObject = aRefListAttr->isInList(theObject);
623     //if (!theCheckIfAttributeHasObject || !aRefListAttr->isInList(theObject))
624     //  aRefListAttr->append(theObject);
625   }
626   else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
627     AttributeRefAttrListPtr aRefAttrListAttr =
628       std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(theAttribute);
629     AttributePtr anAttribute = theWorkshop->module()->findAttribute(theObject, theShape);
630
631     if (anAttribute.get()) {
632       aHasObject = aRefAttrListAttr->isInList(anAttribute);
633       //if (!theCheckIfAttributeHasObject || !aRefAttrListAttr->isInList(anAttribute))
634       //  aRefAttrListAttr->append(anAttribute);
635     }
636     else {
637       aHasObject = aRefAttrListAttr->isInList(theObject);
638       //if (!theCheckIfAttributeHasObject || !aRefAttrListAttr->isInList(theObject))
639       //  aRefAttrListAttr->append(theObject);
640     }
641   }
642   return aHasObject;
643 }
644
645 bool setObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
646                const GeomShapePtr& theShape, ModuleBase_IWorkshop* theWorkshop,
647                const bool theTemporarily, const bool theCheckIfAttributeHasObject)
648 {
649   if (!theAttribute.get())
650     return false;
651
652   bool isDone = true;
653   std::string aType = theAttribute->attributeType();
654   if (aType == ModelAPI_AttributeReference::typeId()) {
655     AttributeReferencePtr aRef =
656       std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
657     ObjectPtr aObject = aRef->value();
658     if (!(aObject && aObject->isSame(theObject))) {
659       aRef->setValue(theObject);
660     }
661   } else if (aType == ModelAPI_AttributeRefAttr::typeId()) {
662     AttributeRefAttrPtr aRefAttr =
663       std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
664
665     AttributePtr anAttribute = theWorkshop->module()->findAttribute(theObject, theShape);
666     if (anAttribute.get())
667       aRefAttr->setAttr(anAttribute);
668     else {
669       ObjectPtr aObject = aRefAttr->object();
670       if (!(aObject && aObject->isSame(theObject))) {
671         aRefAttr->setObject(theObject);
672       }
673     }
674   } else if (aType == ModelAPI_AttributeSelection::typeId()) {
675     AttributeSelectionPtr aSelectAttr =
676                              std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
677     ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
678     if (aSelectAttr.get() != NULL) {
679       aSelectAttr->setValue(aResult, theShape, theTemporarily);
680     }
681   }
682   if (aType == ModelAPI_AttributeSelectionList::typeId()) {
683     AttributeSelectionListPtr aSelectionListAttr =
684                          std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
685     ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
686     if (!theCheckIfAttributeHasObject ||
687         !aSelectionListAttr->isInList(aResult, theShape, theTemporarily))
688       aSelectionListAttr->append(aResult, theShape, theTemporarily);
689   }
690   else if (aType == ModelAPI_AttributeRefList::typeId()) {
691     AttributeRefListPtr aRefListAttr =
692       std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
693     if (!theCheckIfAttributeHasObject || !aRefListAttr->isInList(theObject)) {
694       if (theObject.get())
695         aRefListAttr->append(theObject);
696       else
697         isDone = false;
698     }
699   }
700   else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
701     AttributeRefAttrListPtr aRefAttrListAttr =
702       std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(theAttribute);
703     AttributePtr anAttribute = theWorkshop->module()->findAttribute(theObject, theShape);
704
705     if (anAttribute.get()) {
706       if (!theCheckIfAttributeHasObject || !aRefAttrListAttr->isInList(anAttribute))
707         aRefAttrListAttr->append(anAttribute);
708     }
709     else {
710       if (!theCheckIfAttributeHasObject || !aRefAttrListAttr->isInList(theObject)) {
711         if (theObject.get())
712           aRefAttrListAttr->append(theObject);
713         else
714           isDone = false;
715       }
716     }
717   }
718   return isDone;
719 }
720
721 GeomShapePtr getShape(const AttributePtr& theAttribute, ModuleBase_IWorkshop* theWorkshop)
722 {
723   GeomShapePtr aShape;
724   if (!theAttribute.get())
725     return aShape;
726
727   std::string aType = theAttribute->attributeType();
728   if (aType == ModelAPI_AttributeReference::typeId()) {
729   } else if (aType == ModelAPI_AttributeRefAttr::typeId()) {
730     AttributeRefAttrPtr aRefAttr =
731       std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
732     if (aRefAttr.get() && !aRefAttr->isObject()) {
733       AttributePtr anAttribute = aRefAttr->attr();
734       aShape = theWorkshop->module()->findShape(anAttribute);
735     }
736   } else if (aType == ModelAPI_AttributeSelection::typeId()) {
737     AttributeSelectionPtr aSelectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
738                                                                                  (theAttribute);
739     aShape = aSelectAttr->value();
740   }
741   else // Geom2D point processing
742     aShape = theWorkshop->module()->findShape(theAttribute);
743   return aShape;
744 }
745
746 void flushUpdated(ObjectPtr theObject)
747 {
748   blockUpdateViewer(true);
749
750   // Fix the problem of not previewed results of constraints applied. Flush Create/Delete
751   // (for the sketch result) to start processing of the sketch in the solver.
752   // TODO: these flushes should be moved in a separate method provided by Model
753   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
754   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
755   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
756
757   blockUpdateViewer(false);
758 }
759
760 void blockUpdateViewer(const bool theValue)
761 {
762   // the viewer update should be blocked in order to avoid the temporary feature content
763   // when the solver processes the feature, the redisplay message can be flushed
764   // what caused the display in the viewer preliminary states of object
765   // e.g. fillet feature, angle value change
766   std::shared_ptr<Events_Message> aMsg;
767   if (theValue) {
768     aMsg = std::shared_ptr<Events_Message>(
769         new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED)));
770   }
771   else {
772     // the viewer update should be unblocked
773     aMsg = std::shared_ptr<Events_Message>(
774         new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED)));
775   }
776   Events_Loop::loop()->send(aMsg);
777 }
778
779 QString wrapTextByWords(const QString& theValue, QWidget* theWidget,
780                                           int theMaxLineInPixels)
781 {
782   static QFontMetrics tfm(theWidget ? theWidget->font() : QApplication::font());
783   static qreal phi = 2.618;
784
785   QRect aBounds = tfm.boundingRect(theValue);
786   if(aBounds.width() <= theMaxLineInPixels)
787     return theValue;
788
789   qreal s = aBounds.width() * aBounds.height();
790   qreal aGoldWidth = sqrt(s*phi);
791
792   QStringList aWords = theValue.split(" ", QString::SkipEmptyParts);
793   QStringList aLines;
794   int n = aWords.count();
795   QString aLine;
796   for (int i = 0; i < n; i++) {
797     QString aLineExt = aLine + " " + aWords[i];
798     qreal anWidthNonExt = tfm.boundingRect(aLine).width();
799     qreal anWidthExt = tfm.boundingRect(aLineExt).width();
800     qreal aDeltaNonExt = fabs(anWidthNonExt-aGoldWidth);
801     qreal aDeltaExt    = fabs(anWidthExt-aGoldWidth);
802     if(aDeltaNonExt < aDeltaExt) {
803       // new line
804       aLines.append(aLine);
805       aLine = aWords[i];
806     }
807     else
808       aLine = aLineExt;
809   }
810
811   if(!aLine.isEmpty())
812     aLines.append(aLine);
813
814   QString aResult = aLines.join("\n");
815   return aResult;
816 }
817
818 //**************************************************************
819 QLocale doubleLocale()
820 {
821   // VSR 01/07/2010: Disable thousands separator for spin box
822   // (to avoid inconsistency of double-2-string and string-2-double conversion)
823   QLocale aLocale;
824   aLocale.setNumberOptions(aLocale.numberOptions() |
825                            QLocale::OmitGroupSeparator |
826                            QLocale::RejectGroupSeparator);
827   return aLocale;
828 }
829
830 //**************************************************************
831 void refsToFeatureInFeatureDocument(const ObjectPtr& theObject,
832                                     std::set<FeaturePtr>& theRefFeatures)
833 {
834   FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
835   if (aFeature.get()) {
836     DocumentPtr aFeatureDoc = aFeature->document();
837     // 1. find references in the current document
838     aFeatureDoc->refsToFeature(aFeature, theRefFeatures, false);
839   }
840 }
841
842
843 //**************************************************************
844 /*bool isSubOfComposite(const ObjectPtr& theObject)
845 {
846   bool isSub = false;
847   std::set<FeaturePtr> aRefFeatures;
848   refsToFeatureInFeatureDocument(theObject, aRefFeatures);
849   std::set<FeaturePtr>::const_iterator anIt = aRefFeatures.begin(),
850                                        aLast = aRefFeatures.end();
851   for (; anIt != aLast && !isSub; anIt++) {
852     isSub = isSubOfComposite(theObject, *anIt);
853   }
854   return isSub;
855 }*/
856
857 //**************************************************************
858 /*bool isSubOfComposite(const ObjectPtr& theObject, const FeaturePtr& theFeature)
859 {
860   bool isSub = false;
861   CompositeFeaturePtr aComposite = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theFeature);
862   if (aComposite.get()) {
863     isSub = aComposite->isSub(theObject);
864     // the recursive is possible, the parameters are sketch circle and extrusion cut. They are
865     // separated by composite sketch feature
866     if (!isSub) {
867       int aNbSubs = aComposite->numberOfSubs();
868       for (int aSub = 0; aSub < aNbSubs && !isSub; aSub++) {
869         isSub = isSubOfComposite(theObject, aComposite->subFeature(aSub));
870       }
871     }
872   }
873   return isSub;
874 }*/
875
876 //**************************************************************
877 ResultPtr firstResult(const ObjectPtr& theObject)
878 {
879   ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
880   if (!aResult.get()) {
881     FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
882     if (aFeature.get())
883       aResult = aFeature->firstResult();
884   }
885   return aResult;
886 }
887
888 //**************************************************************
889 bool isFeatureOfResult(const FeaturePtr& theFeature, const std::string& theGroupOfResult)
890 {
891   bool isResult = false;
892
893   if (!theFeature->data()->isValid())
894     return isResult;
895
896   ResultPtr aFirstResult = theFeature->firstResult();
897   if (!aFirstResult.get())
898     return isResult;
899
900   return aFirstResult->groupName() == theGroupOfResult;
901 }
902
903 //**************************************************************
904 bool hasModuleDocumentFeature(const std::set<FeaturePtr>& theFeatures)
905 {
906   bool aFoundModuleDocumentObject = false;
907   DocumentPtr aModuleDoc = ModelAPI_Session::get()->moduleDocument();
908
909   std::set<FeaturePtr>::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end();
910   for (; anIt != aLast && !aFoundModuleDocumentObject; anIt++) {
911     FeaturePtr aFeature = *anIt;
912     ResultPtr aResult = ModuleBase_Tools::firstResult(aFeature);
913     if (aResult.get() && aResult->groupName() == ModelAPI_ResultPart::group())
914       continue;
915     aFoundModuleDocumentObject = aFeature->document() == aModuleDoc;
916   }
917
918   return aFoundModuleDocumentObject;
919 }
920
921 //**************************************************************
922 bool askToDelete(const std::set<FeaturePtr> theFeatures,
923                  const std::map<FeaturePtr, std::set<FeaturePtr> >& theReferences,
924                  QWidget* theParent,
925                  std::set<FeaturePtr>& theReferencesToDelete,
926                  const std::string& thePrefixInfo)
927 {
928   QString aNotActivatedDocWrn;
929   std::string aNotActivatedNames;
930   if (!ModelAPI_Tools::allDocumentsActivated(aNotActivatedNames)) {
931     if (ModuleBase_Tools::hasModuleDocumentFeature(theFeatures))
932       aNotActivatedDocWrn =
933         QObject::tr("Selected objects can be used in Part documents which are not loaded:%1.\n")
934                             .arg(aNotActivatedNames.c_str());
935   }
936
937   std::set<FeaturePtr> aFeaturesRefsTo;
938   std::set<FeaturePtr> aFeaturesRefsToParameter;
939   std::set<FeaturePtr> aParameterFeatures;
940   QStringList aPartFeatureNames;
941   std::set<FeaturePtr>::const_iterator anIt = theFeatures.begin(),
942                                        aLast = theFeatures.end();
943   // separate features to references to parameter features and references to others
944   for (; anIt != aLast; anIt++) {
945     FeaturePtr aFeature = *anIt;
946     if (theReferences.find(aFeature) == theReferences.end())
947       continue;
948
949     if (isFeatureOfResult(aFeature, ModelAPI_ResultPart::group()))
950       aPartFeatureNames.append(aFeature->name().c_str());
951
952     std::set<FeaturePtr> aRefFeatures;
953     std::set<FeaturePtr> aRefList = theReferences.at(aFeature);
954     std::set<FeaturePtr>::const_iterator aRefIt = aRefList.begin(), aRefLast = aRefList.end();
955     for (; aRefIt != aRefLast; aRefIt++) {
956       FeaturePtr aRefFeature = *aRefIt;
957       if (theFeatures.find(aRefFeature) == theFeatures.end() && // it is not selected
958           aRefFeatures.find(aRefFeature) == aRefFeatures.end()) // it is not added
959         aRefFeatures.insert(aRefFeature);
960     }
961
962     if (isFeatureOfResult(aFeature, ModelAPI_ResultParameter::group())) {
963       aFeaturesRefsToParameter.insert(aRefFeatures.begin(), aRefFeatures.end());
964       aParameterFeatures.insert(aFeature);
965     }
966     else {
967       theReferencesToDelete.insert(aRefFeatures.begin(), aRefFeatures.end());
968     }
969   }
970
971   std::set<FeaturePtr> aFeaturesRefsToParameterOnly;
972   anIt = aFeaturesRefsToParameter.begin();
973   aLast = aFeaturesRefsToParameter.end();
974   // separate features to references to parameter features and references to others
975   QStringList aParamFeatureNames;
976   for (; anIt != aLast; anIt++) {
977     FeaturePtr aFeature = *anIt;
978     if (theReferencesToDelete.find(aFeature) == theReferencesToDelete.end()) {
979       aFeaturesRefsToParameterOnly.insert(aFeature);
980       aParamFeatureNames.append(aFeature->name().c_str());
981     }
982   }
983   aParamFeatureNames.sort();
984   QStringList anOtherFeatureNames;
985   anIt = theReferencesToDelete.begin();
986   aLast = theReferencesToDelete.end();
987   for (; anIt != aLast; anIt++) {
988     FeaturePtr aFeature = *anIt;
989     if (isFeatureOfResult(aFeature, ModelAPI_ResultPart::group()))
990       aPartFeatureNames.append(aFeature->name().c_str());
991     else
992       anOtherFeatureNames.append(aFeature->name().c_str());
993   }
994   aPartFeatureNames.sort();
995   anOtherFeatureNames.sort();
996
997   bool aCanReplaceParameters = !aFeaturesRefsToParameterOnly.empty();
998
999   QMessageBox aMessageBox(theParent);
1000   aMessageBox.setWindowTitle(QObject::tr("Delete features"));
1001   aMessageBox.setIcon(QMessageBox::Warning);
1002   aMessageBox.setStandardButtons(QMessageBox::No | QMessageBox::Yes);
1003   aMessageBox.setDefaultButton(QMessageBox::No);
1004
1005   QString aText;
1006   if (!thePrefixInfo.empty())
1007     aText = thePrefixInfo.c_str();
1008   QString aSep = ", ";
1009   if (!aPartFeatureNames.empty()) {
1010     aText += QString(QObject::tr("The following parts will be deleted: %1.\n"))
1011              .arg(aPartFeatureNames.join(aSep));
1012   }
1013   if (!aNotActivatedDocWrn.isEmpty())
1014     aText += aNotActivatedDocWrn;
1015   if (!anOtherFeatureNames.empty()) {
1016     const char* aMsg = "Features are used in the following features: %1.\nThese "
1017                        "features will be deleted.\n";
1018     aText += QString(QObject::tr(aMsg))
1019                      .arg(anOtherFeatureNames.join(aSep));
1020   }
1021   if (!aParamFeatureNames.empty()) {
1022     const char* aMsg = "Parameters are used in the following features: %1.\nThese features will "
1023                        "be deleted.\nOr parameters could be replaced by their values.\n";
1024     aText += QString(QObject::tr(aMsg))
1025                      .arg(aParamFeatureNames.join(aSep));
1026     QPushButton *aReplaceButton =
1027       aMessageBox.addButton(QObject::tr("Replace"), QMessageBox::ActionRole);
1028   }
1029
1030   if (!aText.isEmpty()) {
1031     aText += "Would you like to continue?";
1032     aMessageBox.setText(aText);
1033     aMessageBox.exec();
1034     QMessageBox::ButtonRole aButtonRole = aMessageBox.buttonRole(aMessageBox.clickedButton());
1035
1036     if (aButtonRole == QMessageBox::NoRole)
1037       return false;
1038
1039     if (aButtonRole == QMessageBox::ActionRole) {
1040       foreach (FeaturePtr aObj, aParameterFeatures)
1041         ModelAPI_ReplaceParameterMessage::send(aObj, 0);
1042     }
1043     else
1044       theReferencesToDelete.insert(aFeaturesRefsToParameterOnly.begin(),
1045                                    aFeaturesRefsToParameterOnly.end());
1046   }
1047   return true;
1048 }
1049
1050 //**************************************************************
1051 void convertToFeatures(const QObjectPtrList& theObjects, std::set<FeaturePtr>& theFeatures)
1052 {
1053   QObjectPtrList::const_iterator anIt = theObjects.begin(), aLast = theObjects.end();
1054   for(; anIt != aLast; anIt++) {
1055     ObjectPtr anObject = *anIt;
1056     FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anObject);
1057     // for parameter result, use the corresponded reature to be removed
1058     if (!aFeature.get() && anObject->groupName() == ModelAPI_ResultParameter::group()) {
1059       aFeature = ModelAPI_Feature::feature(anObject);
1060     }
1061     if (aFeature.get())
1062       theFeatures.insert(aFeature);
1063   }
1064 }
1065
1066 //**************************************************************
1067 void convertToFolders(const QObjectPtrList& theObjects,
1068                                          std::set<FolderPtr>& theFolders)
1069 {
1070   QObjectPtrList::const_iterator anIt = theObjects.begin(), aLast = theObjects.end();
1071   for(; anIt != aLast; anIt++) {
1072     ObjectPtr anObject = *anIt;
1073     FolderPtr aFeature = std::dynamic_pointer_cast<ModelAPI_Folder>(anObject);
1074     if (aFeature.get())
1075       theFolders.insert(aFeature);
1076   }
1077 }
1078
1079
1080 //**************************************************************
1081 QString translate(const Events_InfoMessage& theMessage)
1082 {
1083   QString aMessage;
1084
1085   if (!theMessage.empty()) {
1086     std::string aStr = Config_Translator::translate(theMessage);
1087     if (!aStr.empty()) {
1088       std::string aCodec = Config_Translator::codec(theMessage);
1089       aMessage = QTextCodec::codecForName(aCodec.c_str())->toUnicode(aStr.c_str());
1090     }
1091   }
1092
1093   return aMessage;
1094 }
1095
1096 QString translate(const std::string& theContext, const std::string& theMessage)
1097 {
1098   QString aMessage;
1099
1100   if (!theMessage.empty()) {
1101     std::string aStr = Config_Translator::translate(theContext, theMessage);
1102     if (!aStr.empty()) {
1103       std::string aCodec = Config_Translator::codec(theContext);
1104       aMessage = QTextCodec::codecForName(aCodec.c_str())->toUnicode(aStr.c_str());
1105     }
1106   }
1107
1108   return aMessage;
1109 }
1110
1111 void setPointBallHighlighting(AIS_Shape* theAIS)
1112 {
1113   static Handle(Image_AlienPixMap) aPixMap;
1114   if(aPixMap.IsNull()) {
1115     // Load icon for the presentation
1116     std::string aFile;
1117     char* anEnv = getenv("SHAPER_ROOT_DIR");
1118     if(anEnv) {
1119       aFile = std::string(anEnv) +
1120         FSEP + "share" + FSEP + "salome" + FSEP + "resources" + FSEP + "shaper";
1121     } else {
1122       anEnv = getenv("OPENPARTS_ROOT_DIR");
1123       if (anEnv)
1124         aFile = std::string(anEnv) + FSEP + "resources";
1125     }
1126
1127     aFile += FSEP;
1128     static const std::string aMarkerName = "marker_dot.png";
1129     aFile += aMarkerName;
1130     aPixMap = new Image_AlienPixMap();
1131     if(!aPixMap->Load(aFile.c_str())) {
1132       // The icon for constraint is not found
1133       static const std::string aMsg =
1134         "Error: Point market not found by path: \"" + aFile + "\". Falling back.";
1135       //Events_InfoMessage("ModuleBase_Tools::setPointBallHighlighting", aMsg).send();
1136     }
1137   }
1138
1139   Handle(Graphic3d_AspectMarker3d) anAspect;
1140   Handle(Prs3d_Drawer) aDrawer = theAIS->HilightAttributes();
1141 #ifdef USE_OCCT_720
1142   // to do: implement ball highlighting, in 7.2.0 this drawer is NULL
1143 #else
1144   if(aDrawer->HasOwnPointAspect()) {
1145     Handle(Prs3d_PointAspect) aPntAspect = aDrawer->PointAspect();
1146     if(aPixMap->IsEmpty()) {
1147       anAspect = aPntAspect->Aspect();
1148       anAspect->SetType(Aspect_TOM_BALL);
1149     } else {
1150       if(aPixMap->Format() == Image_PixMap::ImgGray) {
1151         aPixMap->SetFormat (Image_PixMap::ImgAlpha);
1152       } else if(aPixMap->Format() == Image_PixMap::ImgGrayF) {
1153         aPixMap->SetFormat (Image_PixMap::ImgAlphaF);
1154       }
1155       anAspect = new Graphic3d_AspectMarker3d(aPixMap);
1156       aPntAspect->SetAspect(anAspect);
1157     }
1158     aDrawer->SetPointAspect(aPntAspect);
1159     theAIS->SetHilightAttributes(aDrawer);
1160   }
1161 #endif
1162 }
1163
1164 } // namespace ModuleBase_Tools
1165
1166