1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "ModuleBase_Tools.h"
22 #include <ModuleBase_ParamIntSpinBox.h>
23 #include <ModuleBase_ParamSpinBox.h>
24 #include <ModuleBase_WidgetFactory.h>
25 #include <ModuleBase_IWorkshop.h>
26 #include <ModuleBase_IModule.h>
27 #include <ModuleBase_IViewer.h>
28 #include <ModuleBase_IconFactory.h>
29 #include <ModuleBase_ResultPrs.h>
30 #include <ModuleBase_ViewerPrs.h>
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 <ModelAPI_AttributeString.h>
42 #include <ModelAPI_Expression.h>
43 #include <ModelAPI_ResultField.h>
44 #include <Events_Loop.h>
46 #include <ModelAPI_Data.h>
47 #include <ModelAPI_Result.h>
48 #include <ModelAPI_ResultParameter.h>
49 #include <ModelAPI_Tools.h>
50 #include <ModelAPI_Session.h>
51 #include <ModelAPI_Events.h>
52 #include <ModelAPI_Folder.h>
54 #include <ModelGeomAlgo_Point2D.h>
56 #include <StdSelect_BRepOwner.hxx>
57 #include <TopoDS_Iterator.hxx>
58 #include <AIS_InteractiveContext.hxx>
59 #include <Prs3d_LineAspect.hxx>
60 #include <Prs3d_PlaneAspect.hxx>
62 #include <GeomDataAPI_Point2D.h>
63 #include <Events_InfoMessage.h>
64 #include <GeomAPI_ShapeExplorer.h>
66 #include <Config_PropManager.h>
67 #include <Config_Translator.h>
69 #include <Prs3d_PointAspect.hxx>
70 #include <Graphic3d_AspectMarker3d.hxx>
72 #include <Image_AlienPixMap.hxx>
78 #include <QDoubleSpinBox>
79 #include <QGraphicsDropShadowEffect>
81 #include <QApplication>
82 #include <QMessageBox>
90 #pragma warning(disable : 4996) // for getenv
93 const double tolerance = 1e-7;
94 const double DEFAULT_DEVIATION_COEFFICIENT = 1.e-4;
96 //#define DEBUG_ACTIVATE_WINDOW
97 //#define DEBUG_SET_FOCUS
105 namespace ModuleBase_Tools {
107 //******************************************************************
109 //******************************************************************
111 void adjustMargins(QWidget* theWidget)
115 adjustMargins(theWidget->layout());
118 void adjustMargins(QLayout* theLayout)
122 theLayout->setContentsMargins(2, 5, 2, 5);
123 theLayout->setSpacing(4);
126 void zeroMargins(QWidget* theWidget)
130 zeroMargins(theWidget->layout());
133 void zeroMargins(QLayout* theLayout)
137 theLayout->setContentsMargins(0, 0, 0, 0);
138 theLayout->setSpacing(5);
141 void activateWindow(QWidget* theWidget, const QString& theInfo)
144 theWidget->activateWindow();
148 #ifdef DEBUG_ACTIVATE_WINDOW
149 qDebug(QString("activateWindow: %1").arg(theInfo).toStdString().c_str());
153 void setFocus(QWidget* theWidget, const QString& theInfo)
155 activateWindow(theWidget);
156 theWidget->setFocus();
157 // rectangle of focus is not visible on tool button widgets
159 #ifdef DEBUG_SET_FOCUS
160 qDebug(QString("setFocus: %1").arg(theInfo).toStdString().c_str());
164 void setShadowEffect(QWidget* theWidget, const bool isSetEffect)
167 QGraphicsDropShadowEffect* aGlowEffect = new QGraphicsDropShadowEffect();
168 aGlowEffect->setOffset(.0);
169 aGlowEffect->setBlurRadius(10.0);
170 aGlowEffect->setColor(QColor(0, 170, 255)); // Light-blue color, #00AAFF
171 theWidget->setGraphicsEffect(aGlowEffect);
174 QGraphicsEffect* anEffect = theWidget->graphicsEffect();
176 anEffect->deleteLater();
177 theWidget->setGraphicsEffect(NULL);
181 QPixmap composite(const QString& theAdditionalIcon, const QString& theIcon)
183 QImage anIcon = ModuleBase_IconFactory::loadImage(theIcon);
184 QImage anAditional(theAdditionalIcon);
185 return composite(anAditional, anIcon);
188 QPixmap composite(const QImage& theAdditionalIcon, QImage& theIcon)
190 if (theIcon.isNull())
193 int anAddWidth = theAdditionalIcon.width();
194 int anAddHeight = theAdditionalIcon.height();
196 int aWidth = theIcon.width();
197 int aHeight = theIcon.height();
199 int aStartWidthPos = aWidth - anAddWidth;
200 int aStartHeightPos = aHeight - anAddHeight;
202 for (int i = 0; i < anAddWidth && i + aStartWidthPos < aWidth; i++)
204 for (int j = 0; j < anAddHeight && j + aStartHeightPos < aHeight; j++)
206 if (qAlpha(theAdditionalIcon.pixel(i, j)) > 0)
207 theIcon.setPixel(i + aStartWidthPos, j + aStartHeightPos, theAdditionalIcon.pixel(i, j));
210 return QPixmap::fromImage(theIcon);
213 QPixmap lighter(const QString& theIcon, const int theLighterValue)
215 QImage anIcon = ModuleBase_IconFactory::loadImage(theIcon);
219 QImage aResult = ModuleBase_IconFactory::loadImage(theIcon);
220 for (int i = 0; i < anIcon.width(); i++)
222 for (int j = 0; j < anIcon.height(); j++)
224 QRgb anRgb = anIcon.pixel(i, j);
225 QColor aPixelColor(qRed(anRgb), qGreen(anRgb), qBlue(anRgb),
226 qAlpha(aResult.pixel(i, j)));
228 QColor aLighterColor = aPixelColor.lighter(theLighterValue);
229 aResult.setPixel(i, j, qRgba(aLighterColor.red(), aLighterColor.green(),
230 aLighterColor.blue(), aLighterColor.alpha()));
233 return QPixmap::fromImage(aResult);
236 void setSpinText(ModuleBase_ParamSpinBox* theSpin, const QString& theText)
238 if (theSpin->text() == theText)
240 // In order to avoid extra text setting because it will
241 // reset cursor position in control
242 bool isBlocked = theSpin->blockSignals(true);
243 theSpin->setText(theText);
244 theSpin->blockSignals(isBlocked);
247 void setSpinValue(QDoubleSpinBox* theSpin, double theValue)
249 if (fabs(theSpin->value() - theValue) < tolerance)
251 bool isBlocked = theSpin->blockSignals(true);
252 theSpin->setValue(theValue);
253 theSpin->blockSignals(isBlocked);
256 void setSpinValue(ModuleBase_ParamSpinBox* theSpin, double theValue)
258 if (fabs(theSpin->value() - theValue) < tolerance)
260 bool isBlocked = theSpin->blockSignals(true);
261 theSpin->setValue(theValue);
262 theSpin->blockSignals(isBlocked);
265 void setSpinText(ModuleBase_ParamIntSpinBox* theSpin, const QString& theText)
267 // In order to avoid extra text setting because it will
268 // reset cursor position in control
269 if (theSpin->text() == theText)
271 bool isBlocked = theSpin->blockSignals(true);
272 theSpin->setText(theText);
273 theSpin->blockSignals(isBlocked);
276 void setSpinValue(ModuleBase_ParamIntSpinBox* theSpin, int theValue)
278 if (theSpin->value() == theValue)
280 bool isBlocked = theSpin->blockSignals(true);
281 theSpin->setValue(theValue);
282 theSpin->blockSignals(isBlocked);
285 QAction* createAction(const QIcon& theIcon, const QString& theText,
286 QObject* theParent, const QObject* theReceiver,
287 const char* theMember, const QString& theToolTip,
288 const QString& theStatusTip)
290 QAction* anAction = new QAction(theIcon, theText, theParent);
291 anAction->setToolTip(theToolTip.isEmpty() ? theText : theToolTip);
292 anAction->setStatusTip(!theStatusTip.isEmpty() ? theStatusTip :
293 (!theToolTip.isEmpty() ? theToolTip : theText));
295 QObject::connect(anAction, SIGNAL(triggered(bool)), theReceiver, theMember);
301 QString objectName(const ObjectPtr& theObj)
306 return theObj->data()->name().c_str();
309 QString objectInfo(const ObjectPtr& theObj, const bool isUseAttributesInfo)
311 QString aFeatureStr = "feature";
315 std::ostringstream aPtrStr;
316 aPtrStr << "[" << theObj.get() << "]";
318 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObj);
319 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theObj);
321 aFeatureStr.append(QString("(result%1)").arg(aPtrStr.str().c_str()).toStdString() .c_str());
322 if (aRes->isDisabled())
323 aFeatureStr.append("[disabled]");
324 if (aRes->isConcealed())
325 aFeatureStr.append("[concealed]");
326 if (ModelAPI_Tools::hasSubResults(aRes))
327 aFeatureStr.append("[hasSubResults]");
329 aFeature = ModelAPI_Feature::feature(aRes);
332 aFeatureStr.append(aPtrStr.str().c_str());
334 if (aFeature.get()) {
335 aFeatureStr.append(QString(": %1").arg(aFeature->getKind().c_str()).toStdString().c_str());
336 if (aFeature->data()->isValid()) {
337 aFeatureStr.append(QString(", name=%1").arg(theObj->data()->name().c_str()).toStdString()
340 if (isUseAttributesInfo) {
341 std::set<std::shared_ptr<ModelAPI_Attribute> > anAttributes;
342 std::string aPointsInfo = ModelGeomAlgo_Point2D::getPontAttributesInfo(aFeature,
343 anAttributes).c_str();
344 if (!aPointsInfo.empty())
345 aFeatureStr.append(QString(", attributes: %1")
346 .arg(aPointsInfo.c_str()).toStdString().c_str());
354 typedef QMap<QString, int> ShapeTypes;
355 static ShapeTypes myShapeTypes;
357 int shapeType(const QString& theType)
359 if (myShapeTypes.count() == 0) {
360 myShapeTypes["compound"] = TopAbs_COMPOUND;
361 myShapeTypes["compounds"] = TopAbs_COMPOUND;
362 myShapeTypes["compsolid"] = TopAbs_COMPSOLID;
363 myShapeTypes["compsolids"] = TopAbs_COMPSOLID;
364 myShapeTypes["solid"] = TopAbs_SOLID;
365 myShapeTypes["solids"] = TopAbs_SOLID;
366 myShapeTypes["shell"] = TopAbs_SHELL;
367 myShapeTypes["shells"] = TopAbs_SHELL;
368 myShapeTypes["face"] = TopAbs_FACE;
369 myShapeTypes["faces"] = TopAbs_FACE;
370 myShapeTypes["wire"] = TopAbs_WIRE;
371 myShapeTypes["wires"] = TopAbs_WIRE;
372 myShapeTypes["edge"] = TopAbs_EDGE;
373 myShapeTypes["edges"] = TopAbs_EDGE;
374 myShapeTypes["vertex"] = TopAbs_VERTEX;
375 myShapeTypes["vertices"] = TopAbs_VERTEX;
376 myShapeTypes["object"] = ModuleBase_ResultPrs::Sel_Result;
377 myShapeTypes["objects"] = ModuleBase_ResultPrs::Sel_Result;
379 QString aType = theType.toLower();
380 if(myShapeTypes.contains(aType))
381 return myShapeTypes[aType];
382 Events_InfoMessage("ModuleBase_Tools", "Shape type defined in XML is not implemented!").send();
386 void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFeature,
387 bool& hasParameter, bool& hasCompositeOwner, bool& hasResultInHistory,
392 hasParameter = false;
393 hasCompositeOwner = false;
394 hasResultInHistory = false;
396 foreach(ObjectPtr aObj, theObjects) {
397 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
398 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
399 FolderPtr aFolder = std::dynamic_pointer_cast<ModelAPI_Folder>(aObj);
400 ResultParameterPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aResult);
401 FieldStepPtr aStep = std::dynamic_pointer_cast<ModelAPI_ResultField::ModelAPI_FieldStep>(aObj);
403 hasResult |= ((aResult.get() != NULL) || (aStep.get() != NULL));
404 hasFeature |= (aFeature.get() != NULL);
405 hasFolder |= (aFolder.get() != NULL);
406 hasParameter |= (aConstruction.get() != NULL);
408 hasCompositeOwner |= (ModelAPI_Tools::compositeOwner(aFeature) != NULL);
410 if (!hasResultInHistory && aResult.get()) {
411 FeaturePtr aFeature = ModelAPI_Feature::feature(aResult);
412 hasResultInHistory = aFeature.get() && aFeature->isInHistory();
415 if (hasFeature && hasResult && hasParameter && hasCompositeOwner && hasFeature)
420 /*bool setDefaultDeviationCoefficient(std::shared_ptr<GeomAPI_Shape> theGeomShape)
422 if (!theGeomShape.get())
424 // if the shape could not be exploded on faces, it contains only wires, edges, and vertices
425 // correction of deviation for them should not influence to the application performance
426 GeomAPI_ShapeExplorer anExp(theGeomShape, GeomAPI_Shape::FACE);
427 bool anEmpty = anExp.empty();
428 return !anExp.more();
431 /*void setDefaultDeviationCoefficient(const std::shared_ptr<ModelAPI_Result>& theResult,
432 const Handle(Prs3d_Drawer)& theDrawer)
434 if (!theResult.get())
436 bool aUseDeviation = false;
438 std::string aResultGroup = theResult->groupName();
439 if (aResultGroup == ModelAPI_ResultConstruction::group())
440 aUseDeviation = true;
441 else if (aResultGroup == ModelAPI_ResultBody::group()) {
442 GeomShapePtr aGeomShape = theResult->shape();
443 if (aGeomShape.get())
444 aUseDeviation = setDefaultDeviationCoefficient(aGeomShape);
447 theDrawer->SetDeviationCoefficient(DEFAULT_DEVIATION_COEFFICIENT);
450 void setDefaultDeviationCoefficient(const TopoDS_Shape& theShape,
451 const Handle(Prs3d_Drawer)& theDrawer)
453 if (theShape.IsNull())
456 std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape());
457 aGeomShape->setImpl(new TopoDS_Shape(theShape));
459 // if the shape could not be exploded on faces, it contains only wires, edges, and vertices
460 // correction of deviation for them should not influence to the application performance
461 GeomAPI_ShapeExplorer anExp(aGeomShape, GeomAPI_Shape::FACE);
462 bool isConstruction = !anExp.more();
466 aDeflection = Config_PropManager::real("Visualization", "construction_deflection");
468 aDeflection = Config_PropManager::real("Visualization", "body_deflection");
470 theDrawer->SetDeviationCoefficient(aDeflection);
473 Quantity_Color color(const std::string& theSection,
474 const std::string& theName)
476 std::vector<int> aColor = Config_PropManager::color(theSection, theName);
477 return Quantity_Color(aColor[0] / 255., aColor[1] / 255., aColor[2] / 255., Quantity_TOC_RGB);
480 ObjectPtr getObject(const AttributePtr& theAttribute)
483 std::string anAttrType = theAttribute->attributeType();
484 if (anAttrType == ModelAPI_AttributeRefAttr::typeId()) {
485 AttributeRefAttrPtr anAttr =
486 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
487 if (anAttr != NULL && anAttr->isObject())
488 anObject = anAttr->object();
490 if (anAttrType == ModelAPI_AttributeSelection::typeId()) {
491 AttributeSelectionPtr anAttr =
492 std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
494 anObject = anAttr->context();
496 if (anAttrType == ModelAPI_AttributeReference::typeId()) {
497 AttributeReferencePtr anAttr =
498 std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
499 if (anAttr.get() != NULL)
500 anObject = anAttr->value();
505 TopAbs_ShapeEnum getCompoundSubType(const TopoDS_Shape& theShape)
507 TopAbs_ShapeEnum aShapeType = theShape.ShapeType();
509 // for compounds check sub-shapes: it may be compound of needed type:
510 // Booleans may produce compounds of Solids
511 if (aShapeType == TopAbs_COMPOUND) {
512 for(TopoDS_Iterator aSubs(theShape); aSubs.More(); aSubs.Next()) {
513 if (!aSubs.Value().IsNull()) {
514 TopAbs_ShapeEnum aSubType = aSubs.Value().ShapeType();
515 if (aSubType == TopAbs_COMPOUND) { // compound of compound(s)
516 aShapeType = TopAbs_COMPOUND;
519 if (aShapeType == TopAbs_COMPOUND) {
520 aShapeType = aSubType;
521 } else if (aShapeType != aSubType) { // compound of shapes of different types
522 aShapeType = TopAbs_COMPOUND;
531 TopoDS_Shape getSelectedShape(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs)
533 if (thePrs->shape().get())
534 return thePrs->shape()->impl<TopoDS_Shape>();
536 Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(thePrs->owner());
537 if (!anOwner.IsNull())
538 return anOwner->Shape();
540 return TopoDS_Shape();
543 void getParameters(QStringList& theParameters)
545 theParameters.clear();
547 SessionPtr aSession = ModelAPI_Session::get();
548 std::list<DocumentPtr> aDocList;
549 DocumentPtr anActiveDocument = aSession->activeDocument();
550 DocumentPtr aRootDocument = aSession->moduleDocument();
551 aDocList.push_back(anActiveDocument);
552 if (anActiveDocument != aRootDocument) {
553 aDocList.push_back(aRootDocument);
555 std::string aGroupId = ModelAPI_ResultParameter::group();
556 for(std::list<DocumentPtr>::const_iterator it = aDocList.begin(); it != aDocList.end(); ++it) {
557 DocumentPtr aDocument = *it;
558 int aSize = aDocument->size(aGroupId);
559 for (int i = 0; i < aSize; i++) {
560 ObjectPtr anObject = aDocument->object(aGroupId, i);
561 std::string aParameterName = anObject->data()->name();
562 theParameters.append(aParameterName.c_str());
567 std::string findGreedAttribute(ModuleBase_IWorkshop* theWorkshop,
568 const FeaturePtr& theFeature)
570 std::string anAttributeId;
572 std::string aXmlCfg, aDescription;
573 theWorkshop->module()->getXMLRepresentation(theFeature->getKind(), aXmlCfg, aDescription);
575 ModuleBase_WidgetFactory aFactory(aXmlCfg, theWorkshop);
576 std::string anAttributeTitle;
577 aFactory.getGreedAttribute(anAttributeId);
579 return anAttributeId;
582 bool hasObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
583 const std::shared_ptr<GeomAPI_Shape>& theShape,
584 ModuleBase_IWorkshop* theWorkshop,
585 const bool theTemporarily)
587 bool aHasObject = false;
588 if (!theAttribute.get())
591 std::string aType = theAttribute->attributeType();
592 if (aType == ModelAPI_AttributeReference::typeId()) {
593 AttributeReferencePtr aRef =
594 std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
595 ObjectPtr aObject = aRef->value();
596 aHasObject = aObject && aObject->isSame(theObject);
597 //if (!(aObject && aObject->isSame(theObject))) {
598 // aRef->setValue(theObject);
600 } else if (aType == ModelAPI_AttributeRefAttr::typeId()) {
601 AttributeRefAttrPtr aRefAttr =
602 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
604 AttributePtr anAttribute = theWorkshop->module()->findAttribute(theObject, theShape);
605 if (anAttribute.get()) {
606 //aRefAttr->setAttr(anAttribute);
609 ObjectPtr aObject = aRefAttr->object();
610 aHasObject = aObject && aObject->isSame(theObject);
611 //if (!(aObject && aObject->isSame(theObject))) {
612 // aRefAttr->setObject(theObject);
615 } else if (aType == ModelAPI_AttributeSelection::typeId()) {
616 /*AttributeSelectionPtr aSelectAttr =
617 std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
618 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
619 if (aSelectAttr.get() != NULL) {
620 aSelectAttr->setValue(aResult, theShape, theTemporarily);
623 if (aType == ModelAPI_AttributeSelectionList::typeId()) {
624 AttributeSelectionListPtr aSelectionListAttr =
625 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
626 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
627 aHasObject = aSelectionListAttr->isInList(aResult, theShape, theTemporarily);
629 else if (aType == ModelAPI_AttributeRefList::typeId()) {
630 AttributeRefListPtr aRefListAttr =
631 std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
632 aHasObject = aRefListAttr->isInList(theObject);
633 //if (!theCheckIfAttributeHasObject || !aRefListAttr->isInList(theObject))
634 // aRefListAttr->append(theObject);
636 else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
637 AttributeRefAttrListPtr aRefAttrListAttr =
638 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(theAttribute);
639 AttributePtr anAttribute = theWorkshop->module()->findAttribute(theObject, theShape);
641 if (anAttribute.get()) {
642 aHasObject = aRefAttrListAttr->isInList(anAttribute);
643 //if (!theCheckIfAttributeHasObject || !aRefAttrListAttr->isInList(anAttribute))
644 // aRefAttrListAttr->append(anAttribute);
647 aHasObject = aRefAttrListAttr->isInList(theObject);
648 //if (!theCheckIfAttributeHasObject || !aRefAttrListAttr->isInList(theObject))
649 // aRefAttrListAttr->append(theObject);
655 bool setObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
656 const GeomShapePtr& theShape, ModuleBase_IWorkshop* theWorkshop,
657 const bool theTemporarily, const bool theCheckIfAttributeHasObject)
659 if (!theAttribute.get())
663 std::string aType = theAttribute->attributeType();
664 if (aType == ModelAPI_AttributeReference::typeId()) {
665 AttributeReferencePtr aRef =
666 std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
667 ObjectPtr aObject = aRef->value();
668 if (!(aObject && aObject->isSame(theObject))) {
669 aRef->setValue(theObject);
671 } else if (aType == ModelAPI_AttributeRefAttr::typeId()) {
672 AttributeRefAttrPtr aRefAttr =
673 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
675 AttributePtr anAttribute = theWorkshop->module()->findAttribute(theObject, theShape);
676 if (anAttribute.get())
677 aRefAttr->setAttr(anAttribute);
679 ObjectPtr aObject = aRefAttr->object();
680 if (!(aObject && aObject->isSame(theObject))) {
681 aRefAttr->setObject(theObject);
684 } else if (aType == ModelAPI_AttributeSelection::typeId()) {
685 AttributeSelectionPtr aSelectAttr =
686 std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
687 if (aSelectAttr.get() != NULL) {
688 aSelectAttr->setValue(theObject, theShape, theTemporarily);
691 if (aType == ModelAPI_AttributeSelectionList::typeId()) {
692 AttributeSelectionListPtr aSelectionListAttr =
693 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
694 if (!theCheckIfAttributeHasObject ||
695 !aSelectionListAttr->isInList(theObject, theShape, theTemporarily))
696 aSelectionListAttr->append(theObject, theShape, theTemporarily);
698 else if (aType == ModelAPI_AttributeRefList::typeId()) {
699 AttributeRefListPtr aRefListAttr =
700 std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
701 if (!theCheckIfAttributeHasObject || !aRefListAttr->isInList(theObject)) {
703 aRefListAttr->append(theObject);
708 else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
709 AttributeRefAttrListPtr aRefAttrListAttr =
710 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(theAttribute);
711 AttributePtr anAttribute = theWorkshop->module()->findAttribute(theObject, theShape);
713 if (anAttribute.get()) {
714 if (!theCheckIfAttributeHasObject || !aRefAttrListAttr->isInList(anAttribute))
715 aRefAttrListAttr->append(anAttribute);
718 if (!theCheckIfAttributeHasObject || !aRefAttrListAttr->isInList(theObject)) {
720 aRefAttrListAttr->append(theObject);
729 GeomShapePtr getShape(const AttributePtr& theAttribute, ModuleBase_IWorkshop* theWorkshop)
732 if (!theAttribute.get())
735 std::string aType = theAttribute->attributeType();
736 if (aType == ModelAPI_AttributeReference::typeId()) {
737 } else if (aType == ModelAPI_AttributeRefAttr::typeId()) {
738 AttributeRefAttrPtr aRefAttr =
739 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
740 if (aRefAttr.get() && !aRefAttr->isObject()) {
741 AttributePtr anAttribute = aRefAttr->attr();
742 aShape = theWorkshop->module()->findShape(anAttribute);
744 } else if (aType == ModelAPI_AttributeSelection::typeId()) {
745 AttributeSelectionPtr aSelectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
747 aShape = aSelectAttr->value();
749 else // Geom2D point processing
750 aShape = theWorkshop->module()->findShape(theAttribute);
754 void flushUpdated(ObjectPtr theObject)
756 blockUpdateViewer(true);
758 // Fix the problem of not previewed results of constraints applied. Flush Create/Delete
759 // (for the sketch result) to start processing of the sketch in the solver.
760 // TODO: these flushes should be moved in a separate method provided by Model
761 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
762 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
763 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
765 blockUpdateViewer(false);
768 void blockUpdateViewer(const bool theValue)
770 // the viewer update should be blocked in order to avoid the temporary feature content
771 // when the solver processes the feature, the redisplay message can be flushed
772 // what caused the display in the viewer preliminary states of object
773 // e.g. fillet feature, angle value change
774 std::shared_ptr<Events_Message> aMsg;
776 aMsg = std::shared_ptr<Events_Message>(
777 new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED)));
780 // the viewer update should be unblocked
781 aMsg = std::shared_ptr<Events_Message>(
782 new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED)));
784 Events_Loop::loop()->send(aMsg);
787 QString wrapTextByWords(const QString& theValue, QWidget* theWidget,
788 int theMaxLineInPixels)
790 static QFontMetrics tfm(theWidget ? theWidget->font() : QApplication::font());
791 static qreal phi = 2.618;
793 QRect aBounds = tfm.boundingRect(theValue);
794 if(aBounds.width() <= theMaxLineInPixels)
797 qreal s = aBounds.width() * aBounds.height();
798 qreal aGoldWidth = sqrt(s*phi);
800 QStringList aWords = theValue.split(" ", QString::SkipEmptyParts);
802 int n = aWords.count();
804 for (int i = 0; i < n; i++) {
805 QString aLineExt = i == 0 ? aWords[i] : aLine + " " + aWords[i];
806 qreal anWidthNonExt = tfm.boundingRect(aLine).width();
807 qreal anWidthExt = tfm.boundingRect(aLineExt).width();
808 qreal aDeltaNonExt = fabs(anWidthNonExt-aGoldWidth);
809 qreal aDeltaExt = fabs(anWidthExt-aGoldWidth);
810 if(aDeltaNonExt < aDeltaExt) {
812 aLines.append(aLine);
820 aLines.append(aLine);
822 QString aResult = aLines.join("\n");
826 //**************************************************************
827 QLocale doubleLocale()
829 // VSR 01/07/2010: Disable thousands separator for spin box
830 // (to avoid inconsistency of double-2-string and string-2-double conversion)
832 aLocale.setNumberOptions(aLocale.numberOptions() |
833 QLocale::OmitGroupSeparator |
834 QLocale::RejectGroupSeparator);
838 //**************************************************************
839 void refsToFeatureInFeatureDocument(const ObjectPtr& theObject,
840 std::set<FeaturePtr>& theRefFeatures)
842 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
843 if (aFeature.get()) {
844 DocumentPtr aFeatureDoc = aFeature->document();
845 // 1. find references in the current document
846 aFeatureDoc->refsToFeature(aFeature, theRefFeatures, false);
851 //**************************************************************
852 /*bool isSubOfComposite(const ObjectPtr& theObject)
855 std::set<FeaturePtr> aRefFeatures;
856 refsToFeatureInFeatureDocument(theObject, aRefFeatures);
857 std::set<FeaturePtr>::const_iterator anIt = aRefFeatures.begin(),
858 aLast = aRefFeatures.end();
859 for (; anIt != aLast && !isSub; anIt++) {
860 isSub = isSubOfComposite(theObject, *anIt);
865 //**************************************************************
866 /*bool isSubOfComposite(const ObjectPtr& theObject, const FeaturePtr& theFeature)
869 CompositeFeaturePtr aComposite = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theFeature);
870 if (aComposite.get()) {
871 isSub = aComposite->isSub(theObject);
872 // the recursive is possible, the parameters are sketch circle and extrusion cut. They are
873 // separated by composite sketch feature
875 int aNbSubs = aComposite->numberOfSubs();
876 for (int aSub = 0; aSub < aNbSubs && !isSub; aSub++) {
877 isSub = isSubOfComposite(theObject, aComposite->subFeature(aSub));
884 //**************************************************************
885 ResultPtr firstResult(const ObjectPtr& theObject)
887 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
888 if (!aResult.get()) {
889 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
891 aResult = aFeature->firstResult();
896 //**************************************************************
897 bool isFeatureOfResult(const FeaturePtr& theFeature, const std::string& theGroupOfResult)
899 bool isResult = false;
901 if (!theFeature->data()->isValid())
904 ResultPtr aFirstResult = theFeature->firstResult();
905 if (!aFirstResult.get())
908 return aFirstResult->groupName() == theGroupOfResult;
911 //**************************************************************
912 bool hasModuleDocumentFeature(const std::set<FeaturePtr>& theFeatures)
914 bool aFoundModuleDocumentObject = false;
915 DocumentPtr aModuleDoc = ModelAPI_Session::get()->moduleDocument();
917 std::set<FeaturePtr>::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end();
918 for (; anIt != aLast && !aFoundModuleDocumentObject; anIt++) {
919 FeaturePtr aFeature = *anIt;
920 ResultPtr aResult = ModuleBase_Tools::firstResult(aFeature);
921 if (aResult.get() && aResult->groupName() == ModelAPI_ResultPart::group())
923 aFoundModuleDocumentObject = aFeature->document() == aModuleDoc;
926 return aFoundModuleDocumentObject;
929 //**************************************************************
930 bool askToDelete(const std::set<FeaturePtr> theFeatures,
931 const std::map<FeaturePtr, std::set<FeaturePtr> >& theReferences,
933 std::set<FeaturePtr>& theReferencesToDelete,
934 const std::string& thePrefixInfo)
936 QString aNotActivatedDocWrn;
937 std::string aNotActivatedNames;
938 if (!ModelAPI_Tools::allDocumentsActivated(aNotActivatedNames)) {
939 if (ModuleBase_Tools::hasModuleDocumentFeature(theFeatures))
940 aNotActivatedDocWrn =
941 QObject::tr("Selected objects can be used in Part documents which are not loaded:%1.\n")
942 .arg(aNotActivatedNames.c_str());
945 std::set<FeaturePtr> aFeaturesRefsTo;
946 std::set<FeaturePtr> aFeaturesRefsToParameter;
947 std::set<FeaturePtr> aParameterFeatures;
948 QStringList aPartFeatureNames;
949 std::set<FeaturePtr>::const_iterator anIt = theFeatures.begin(),
950 aLast = theFeatures.end();
951 // separate features to references to parameter features and references to others
952 for (; anIt != aLast; anIt++) {
953 FeaturePtr aFeature = *anIt;
954 if (theReferences.find(aFeature) == theReferences.end())
957 if (isFeatureOfResult(aFeature, ModelAPI_ResultPart::group()))
958 aPartFeatureNames.append(aFeature->name().c_str());
960 std::set<FeaturePtr> aRefFeatures;
961 std::set<FeaturePtr> aRefList = theReferences.at(aFeature);
962 std::set<FeaturePtr>::const_iterator aRefIt = aRefList.begin(), aRefLast = aRefList.end();
963 for (; aRefIt != aRefLast; aRefIt++) {
964 FeaturePtr aRefFeature = *aRefIt;
965 if (theFeatures.find(aRefFeature) == theFeatures.end() && // it is not selected
966 aRefFeatures.find(aRefFeature) == aRefFeatures.end()) // it is not added
967 aRefFeatures.insert(aRefFeature);
970 if (isFeatureOfResult(aFeature, ModelAPI_ResultParameter::group())) {
971 aFeaturesRefsToParameter.insert(aRefFeatures.begin(), aRefFeatures.end());
972 aParameterFeatures.insert(aFeature);
975 theReferencesToDelete.insert(aRefFeatures.begin(), aRefFeatures.end());
979 std::set<FeaturePtr> aFeaturesRefsToParameterOnly;
980 anIt = aFeaturesRefsToParameter.begin();
981 aLast = aFeaturesRefsToParameter.end();
982 // separate features to references to parameter features and references to others
983 QStringList aParamFeatureNames;
984 for (; anIt != aLast; anIt++) {
985 FeaturePtr aFeature = *anIt;
986 if (theReferencesToDelete.find(aFeature) == theReferencesToDelete.end()) {
987 aFeaturesRefsToParameterOnly.insert(aFeature);
988 aParamFeatureNames.append(aFeature->name().c_str());
991 aParamFeatureNames.sort();
992 QStringList anOtherFeatureNames;
993 anIt = theReferencesToDelete.begin();
994 aLast = theReferencesToDelete.end();
995 for (; anIt != aLast; anIt++) {
996 FeaturePtr aFeature = *anIt;
997 if (aFeature->getKind() == "RemoveResults")
998 continue; // skip the remove results feature mentioning: result will be removed anyway
999 if (isFeatureOfResult(aFeature, ModelAPI_ResultPart::group()))
1000 aPartFeatureNames.append(aFeature->name().c_str());
1002 anOtherFeatureNames.append(aFeature->name().c_str());
1004 aPartFeatureNames.sort();
1005 anOtherFeatureNames.sort();
1007 bool aCanReplaceParameters = !aFeaturesRefsToParameterOnly.empty();
1009 QMessageBox aMessageBox(theParent);
1010 aMessageBox.setWindowTitle(QObject::tr("Delete features"));
1011 aMessageBox.setIcon(QMessageBox::Warning);
1012 aMessageBox.setStandardButtons(QMessageBox::No | QMessageBox::Yes);
1013 aMessageBox.setDefaultButton(QMessageBox::No);
1016 if (!thePrefixInfo.empty())
1017 aText = thePrefixInfo.c_str();
1018 QString aSep = ", ";
1019 if (!aPartFeatureNames.empty()) {
1020 aText += QString(QObject::tr("The following parts will be deleted: %1.\n"))
1021 .arg(aPartFeatureNames.join(aSep));
1023 if (!aNotActivatedDocWrn.isEmpty())
1024 aText += aNotActivatedDocWrn;
1025 if (!anOtherFeatureNames.empty()) {
1026 const char* aMsg = "Features are used in the following features: %1.\nThese "
1027 "features will be deleted.\n";
1028 aText += QString(QObject::tr(aMsg))
1029 .arg(anOtherFeatureNames.join(aSep));
1031 if (!aParamFeatureNames.empty()) {
1032 const char* aMsg = "Parameters are used directly and through a sequence "
1033 "of dependencies in the following features: %1.\nThese features will "
1034 "be deleted.\nOr parameters could be replaced by their values.\n";
1035 aText += QString(QObject::tr(aMsg))
1036 .arg(aParamFeatureNames.join(aSep));
1037 QPushButton *aReplaceButton =
1038 aMessageBox.addButton(QObject::tr("Replace"), QMessageBox::ActionRole);
1041 if (!aText.isEmpty()) {
1042 aText += "Would you like to continue?";
1043 aMessageBox.setText(aText);
1045 QMessageBox::ButtonRole aButtonRole = aMessageBox.buttonRole(aMessageBox.clickedButton());
1047 if (aButtonRole == QMessageBox::NoRole)
1050 if (aButtonRole == QMessageBox::ActionRole) {
1051 foreach (FeaturePtr aObj, aParameterFeatures)
1052 ModelAPI_ReplaceParameterMessage::send(aObj, 0);
1055 theReferencesToDelete.insert(aFeaturesRefsToParameterOnly.begin(),
1056 aFeaturesRefsToParameterOnly.end());
1061 //**************************************************************
1062 void convertToFeatures(const QObjectPtrList& theObjects, std::set<FeaturePtr>& theFeatures)
1064 QObjectPtrList::const_iterator anIt = theObjects.begin(), aLast = theObjects.end();
1065 for(; anIt != aLast; anIt++) {
1066 ObjectPtr anObject = *anIt;
1067 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anObject);
1068 // for parameter result, use the corresponded reature to be removed
1069 if (!aFeature.get() && anObject->groupName() == ModelAPI_ResultParameter::group()) {
1070 aFeature = ModelAPI_Feature::feature(anObject);
1073 theFeatures.insert(aFeature);
1077 //**************************************************************
1078 void convertToFolders(const QObjectPtrList& theObjects,
1079 std::set<FolderPtr>& theFolders)
1081 QObjectPtrList::const_iterator anIt = theObjects.begin(), aLast = theObjects.end();
1082 for(; anIt != aLast; anIt++) {
1083 ObjectPtr anObject = *anIt;
1084 FolderPtr aFeature = std::dynamic_pointer_cast<ModelAPI_Folder>(anObject);
1086 theFolders.insert(aFeature);
1091 //**************************************************************
1092 QString translate(const Events_InfoMessage& theMessage)
1096 if (!theMessage.empty()) {
1097 std::string aStr = Config_Translator::translate(theMessage);
1098 if (!aStr.empty()) {
1099 std::string aCodec = Config_Translator::codec(theMessage);
1100 aMessage = QTextCodec::codecForName(aCodec.c_str())->toUnicode(aStr.c_str());
1107 QString translate(const std::string& theContext, const std::string& theMessage)
1111 if (!theMessage.empty()) {
1112 std::string aStr = Config_Translator::translate(theContext, theMessage);
1113 if (!aStr.empty()) {
1114 std::string aCodec = Config_Translator::codec(theContext);
1115 aMessage = QTextCodec::codecForName(aCodec.c_str())->toUnicode(aStr.c_str());
1122 void setPointBallHighlighting(AIS_Shape* theAIS)
1124 static Handle(Image_AlienPixMap) aPixMap;
1125 if(aPixMap.IsNull()) {
1126 // Load icon for the presentation
1128 char* anEnv = getenv("SHAPER_ROOT_DIR");
1130 aFile = std::string(anEnv) +
1131 FSEP + "share" + FSEP + "salome" + FSEP + "resources" + FSEP + "shaper";
1133 anEnv = getenv("CADBUILDER_ROOT_DIR");
1135 aFile = std::string(anEnv) + FSEP + "resources";
1139 static const std::string aMarkerName = "marker_dot.png";
1140 aFile += aMarkerName;
1141 aPixMap = new Image_AlienPixMap();
1142 if(!aPixMap->Load(aFile.c_str())) {
1143 // The icon for constraint is not found
1144 static const std::string aMsg =
1145 "Error: Point market not found by path: \"" + aFile + "\". Falling back.";
1146 //Events_InfoMessage("ModuleBase_Tools::setPointBallHighlighting", aMsg).send();
1150 Handle(Graphic3d_AspectMarker3d) anAspect;
1151 Handle(Prs3d_Drawer) aDrawer = theAIS->DynamicHilightAttributes();
1152 if (aDrawer.IsNull()) {
1153 if (ModuleBase_IViewer::DefaultHighlightDrawer.IsNull())
1155 aDrawer = new Prs3d_Drawer(*ModuleBase_IViewer::DefaultHighlightDrawer);
1156 if (!aDrawer->HasOwnPointAspect()) {
1157 aDrawer->SetPointAspect(new Prs3d_PointAspect(Aspect_TOM_BALL, Quantity_NOC_BLACK, 2.0));
1160 if(aDrawer->HasOwnPointAspect()) {
1161 Handle(Prs3d_PointAspect) aPntAspect = aDrawer->PointAspect();
1162 if(aPixMap->IsEmpty()) {
1163 anAspect = aPntAspect->Aspect();
1164 anAspect->SetType(Aspect_TOM_BALL);
1166 if(aPixMap->Format() == Image_PixMap::ImgGray) {
1167 aPixMap->SetFormat (Image_PixMap::ImgAlpha);
1168 } else if(aPixMap->Format() == Image_PixMap::ImgGrayF) {
1169 aPixMap->SetFormat (Image_PixMap::ImgAlphaF);
1171 anAspect = new Graphic3d_AspectMarker3d(aPixMap);
1172 aPntAspect->SetAspect(anAspect);
1174 aDrawer->SetPointAspect(aPntAspect);
1175 theAIS->SetDynamicHilightAttributes(aDrawer);
1179 FeaturePtr createParameter(const QString& theText)
1181 FeaturePtr aParameter;
1182 QStringList aList = theText.split("=");
1183 if (aList.count() != 2) {
1186 QString aParamName = aList.at(0).trimmed();
1188 if (isNameExist(aParamName, FeaturePtr())) {
1192 if (!ModelAPI_Expression::isVariable(aParamName.toStdString())) {
1196 QString aExpression = aList.at(1).trimmed();
1197 if (aExpression.isEmpty()) {
1201 SessionPtr aMgr = ModelAPI_Session::get();
1202 std::shared_ptr<ModelAPI_Document> aDoc = aMgr->activeDocument();
1204 aParameter = aDoc->addFeature("Parameter");
1205 if (aParameter.get()) {
1206 AttributeStringPtr aNameAttr = aParameter->string("variable");
1207 aNameAttr->setValue(aParamName.toStdString());
1209 AttributeStringPtr aExprAttr = aParameter->string("expression");
1210 aExprAttr->setValue(aExpression.toStdString());
1211 aParameter->execute();
1213 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
1214 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
1219 void editParameter(FeaturePtr theParam, const QString& theText)
1221 QStringList aList = theText.split("=");
1222 QString aParamName = aList.at(0).trimmed();
1224 QString aExpression = aList.at(1).trimmed();
1225 if (aExpression.isEmpty()) {
1229 if (isNameExist(aParamName, theParam)) {
1232 AttributeStringPtr aNameAttr = theParam->string("variable");
1233 aNameAttr->setValue(aParamName.toStdString());
1235 AttributeStringPtr aExprAttr = theParam->string("expression");
1236 aExprAttr->setValue(aExpression.toStdString());
1237 theParam->execute();
1239 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
1242 bool isNameExist(const QString& theName, FeaturePtr theIgnoreParameter)
1244 SessionPtr aMgr = ModelAPI_Session::get();
1245 std::shared_ptr<ModelAPI_Document> aDoc = aMgr->activeDocument();
1246 FeaturePtr aParamFeature;
1247 int aNbFeatures = aDoc->numInternalFeatures();
1248 std::string aName = theName.toStdString();
1249 for (int i = 0; i < aNbFeatures; i++) {
1250 aParamFeature = aDoc->internalFeature(i);
1251 if (aParamFeature && aParamFeature->getKind() == "Parameter") {
1252 if ((theIgnoreParameter != aParamFeature) && (aParamFeature->name() == aName))
1259 FeaturePtr findParameter(const QString& theName)
1261 SessionPtr aMgr = ModelAPI_Session::get();
1262 std::shared_ptr<ModelAPI_Document> aDoc = aMgr->activeDocument();
1263 FeaturePtr aParamFeature;
1264 int aNbFeatures = aDoc->numInternalFeatures();
1265 std::string aName = theName.toStdString();
1266 for (int i = 0; i < aNbFeatures; i++) {
1267 aParamFeature = aDoc->internalFeature(i);
1268 if (aParamFeature && aParamFeature->getKind() == "Parameter") {
1269 if (aParamFeature->name() == aName)
1270 return aParamFeature;
1273 return FeaturePtr();
1277 //********************************************************************
1278 std::string generateName(const AttributePtr& theAttribute,
1279 ModuleBase_IWorkshop* theWorkshop)
1282 if (theAttribute.get() != NULL) {
1283 ModuleBase_Operation* anOperation = theWorkshop->currentOperation();
1285 FeaturePtr aFeature = ModelAPI_Feature::feature(theAttribute->owner());
1286 if (aFeature.get()) {
1287 std::string aXmlCfg, aDescription;
1288 theWorkshop->module()->getXMLRepresentation(aFeature->getKind(), aXmlCfg, aDescription);
1290 ModuleBase_WidgetFactory aFactory(aXmlCfg, theWorkshop);
1291 std::string anAttributeTitle;
1292 aFactory.getAttributeTitle(theAttribute->id(), anAttributeTitle);
1294 std::stringstream aStreamName;
1295 aStreamName << theAttribute->owner()->data()->name() << "/" << anAttributeTitle.c_str();
1296 aName = aStreamName.str();
1302 bool isSameShape(const TopoDS_Shape& theShape1, const TopoDS_Shape& theShape2)
1304 // In case of compound we cannot rely on simple comparison method.
1305 // If the compound is generated by Group feature then this compound is alwais new.
1306 // So, we have to compare content of these compounds
1307 if (theShape1.ShapeType() != theShape2.ShapeType())
1310 if (theShape1.ShapeType() != TopAbs_COMPOUND)
1311 return theShape1.IsSame(theShape2);
1313 TopoDS_Iterator aIt1(theShape1);
1314 TopoDS_Iterator aIt2(theShape2);
1316 for (; aIt1.More() && aIt2.More(); aIt1.Next(), aIt2.Next()) {
1317 if (!(aIt1.Value()).IsSame(aIt2.Value()))
1324 } // namespace ModuleBase_Tools