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>
92 #pragma warning(disable : 4996) // for getenv
95 const double tolerance = 1e-7;
96 const double DEFAULT_DEVIATION_COEFFICIENT = 1.e-4;
98 //#define DEBUG_ACTIVATE_WINDOW
99 //#define DEBUG_SET_FOCUS
107 namespace ModuleBase_Tools {
109 //******************************************************************
111 //******************************************************************
113 void adjustMargins(QWidget* theWidget)
117 adjustMargins(theWidget->layout());
120 void adjustMargins(QLayout* theLayout)
124 theLayout->setContentsMargins(2, 5, 2, 5);
125 theLayout->setSpacing(4);
128 void zeroMargins(QWidget* theWidget)
132 zeroMargins(theWidget->layout());
135 void zeroMargins(QLayout* theLayout)
139 theLayout->setContentsMargins(0, 0, 0, 0);
140 theLayout->setSpacing(5);
143 void activateWindow(QWidget* theWidget, const QString& theInfo)
146 theWidget->activateWindow();
150 #ifdef DEBUG_ACTIVATE_WINDOW
151 qDebug(QString("activateWindow: %1").arg(theInfo).toStdString().c_str());
155 void setFocus(QWidget* theWidget, const QString& theInfo)
157 theWidget->setFocus();
158 // rectangle of focus is not visible on tool button widgets
160 #ifdef DEBUG_SET_FOCUS
161 qDebug(QString("setFocus: %1").arg(theInfo).toStdString().c_str());
165 void setShadowEffect(QWidget* theWidget, const bool isSetEffect)
168 QGraphicsDropShadowEffect* aGlowEffect = new QGraphicsDropShadowEffect();
169 aGlowEffect->setOffset(.0);
170 aGlowEffect->setBlurRadius(10.0);
171 aGlowEffect->setColor(QColor(0, 170, 255)); // Light-blue color, #00AAFF
172 theWidget->setGraphicsEffect(aGlowEffect);
175 QGraphicsEffect* anEffect = theWidget->graphicsEffect();
177 anEffect->deleteLater();
178 theWidget->setGraphicsEffect(NULL);
182 QPixmap composite(const QString& theAdditionalIcon, const QString& theIcon)
184 QImage anIcon = ModuleBase_IconFactory::loadImage(theIcon);
185 QImage anAditional(theAdditionalIcon);
186 return composite(anAditional, anIcon);
189 QPixmap composite(const QImage& theAdditionalIcon, QImage& theIcon)
191 if (theIcon.isNull())
194 int anAddWidth = theAdditionalIcon.width();
195 int anAddHeight = theAdditionalIcon.height();
197 int aWidth = theIcon.width();
198 int aHeight = theIcon.height();
200 int aStartWidthPos = aWidth - anAddWidth;
201 int aStartHeightPos = aHeight - anAddHeight;
203 for (int i = 0; i < anAddWidth && i + aStartWidthPos < aWidth; i++)
205 for (int j = 0; j < anAddHeight && j + aStartHeightPos < aHeight; j++)
207 if (qAlpha(theAdditionalIcon.pixel(i, j)) > 0)
208 theIcon.setPixel(i + aStartWidthPos, j + aStartHeightPos, theAdditionalIcon.pixel(i, j));
211 return QPixmap::fromImage(theIcon);
214 QPixmap lighter(const QString& theIcon, const int theLighterValue)
216 QImage anIcon = ModuleBase_IconFactory::loadImage(theIcon);
220 QImage aResult = ModuleBase_IconFactory::loadImage(theIcon);
221 for (int i = 0; i < anIcon.width(); i++)
223 for (int j = 0; j < anIcon.height(); j++)
225 QRgb anRgb = anIcon.pixel(i, j);
226 QColor aPixelColor(qRed(anRgb), qGreen(anRgb), qBlue(anRgb),
227 qAlpha(aResult.pixel(i, j)));
229 QColor aLighterColor = aPixelColor.lighter(theLighterValue);
230 aResult.setPixel(i, j, qRgba(aLighterColor.red(), aLighterColor.green(),
231 aLighterColor.blue(), aLighterColor.alpha()));
234 return QPixmap::fromImage(aResult);
237 void setSpinText(ModuleBase_ParamSpinBox* theSpin, const QString& theText)
239 if (theSpin->text() == theText)
241 // In order to avoid extra text setting because it will
242 // reset cursor position in control
243 bool isBlocked = theSpin->blockSignals(true);
244 theSpin->setText(theText);
245 theSpin->blockSignals(isBlocked);
248 void setSpinValue(QDoubleSpinBox* theSpin, double theValue)
250 if (fabs(theSpin->value() - theValue) < tolerance)
252 bool isBlocked = theSpin->blockSignals(true);
253 theSpin->setValue(theValue);
254 theSpin->blockSignals(isBlocked);
257 void setSpinValue(ModuleBase_ParamSpinBox* theSpin, double theValue)
259 if (fabs(theSpin->value() - theValue) < tolerance)
261 bool isBlocked = theSpin->blockSignals(true);
262 theSpin->setValue(theValue);
263 theSpin->blockSignals(isBlocked);
266 void setSpinText(ModuleBase_ParamIntSpinBox* theSpin, const QString& theText)
268 // In order to avoid extra text setting because it will
269 // reset cursor position in control
270 if (theSpin->text() == theText)
272 bool isBlocked = theSpin->blockSignals(true);
273 theSpin->setText(theText);
274 theSpin->blockSignals(isBlocked);
277 void setSpinValue(ModuleBase_ParamIntSpinBox* theSpin, int theValue)
279 if (theSpin->value() == theValue)
281 bool isBlocked = theSpin->blockSignals(true);
282 theSpin->setValue(theValue);
283 theSpin->blockSignals(isBlocked);
286 QAction* createAction(const QIcon& theIcon, const QString& theText,
287 QObject* theParent, const QObject* theReceiver,
288 const char* theMember, const QString& theToolTip,
289 const QString& theStatusTip)
291 QAction* anAction = new QAction(theIcon, theText, theParent);
292 anAction->setToolTip(theToolTip.isEmpty() ? theText : theToolTip);
293 anAction->setStatusTip(!theStatusTip.isEmpty() ? theStatusTip :
294 (!theToolTip.isEmpty() ? theToolTip : theText));
296 QObject::connect(anAction, SIGNAL(triggered(bool)), theReceiver, theMember);
302 QString objectName(const ObjectPtr& theObj)
307 return theObj->data()->name().c_str();
310 QString objectInfo(const ObjectPtr& theObj, const bool isUseAttributesInfo)
312 QString aFeatureStr = "feature";
316 std::ostringstream aPtrStr;
317 aPtrStr << "[" << theObj.get() << "]";
319 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObj);
320 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theObj);
322 aFeatureStr.append(QString("(result%1)").arg(aPtrStr.str().c_str()).toStdString() .c_str());
323 if (aRes->isDisabled())
324 aFeatureStr.append("[disabled]");
325 if (aRes->isConcealed())
326 aFeatureStr.append("[concealed]");
327 if (ModelAPI_Tools::hasSubResults(aRes))
328 aFeatureStr.append("[hasSubResults]");
330 aFeature = ModelAPI_Feature::feature(aRes);
333 aFeatureStr.append(aPtrStr.str().c_str());
335 if (aFeature.get()) {
336 aFeatureStr.append(QString(": %1").arg(aFeature->getKind().c_str()).toStdString().c_str());
337 if (aFeature->data()->isValid()) {
338 aFeatureStr.append(QString(", name=%1").arg(theObj->data()->name().c_str()).toStdString()
341 if (isUseAttributesInfo) {
342 std::set<std::shared_ptr<ModelAPI_Attribute> > anAttributes;
343 std::string aPointsInfo = ModelGeomAlgo_Point2D::getPontAttributesInfo(aFeature,
344 anAttributes).c_str();
345 if (!aPointsInfo.empty())
346 aFeatureStr.append(QString(", attributes: %1")
347 .arg(aPointsInfo.c_str()).toStdString().c_str());
355 typedef QMap<QString, int> ShapeTypes;
356 static ShapeTypes myShapeTypes;
358 int shapeType(const QString& theType)
360 if (myShapeTypes.count() == 0) {
361 myShapeTypes["compound"] = TopAbs_COMPOUND;
362 myShapeTypes["compounds"] = TopAbs_COMPOUND;
363 myShapeTypes["compsolid"] = TopAbs_COMPSOLID;
364 myShapeTypes["compsolids"] = TopAbs_COMPSOLID;
365 myShapeTypes["solid"] = TopAbs_SOLID;
366 myShapeTypes["solids"] = TopAbs_SOLID;
367 myShapeTypes["shell"] = TopAbs_SHELL;
368 myShapeTypes["shells"] = TopAbs_SHELL;
369 myShapeTypes["face"] = TopAbs_FACE;
370 myShapeTypes["faces"] = TopAbs_FACE;
371 myShapeTypes["wire"] = TopAbs_WIRE;
372 myShapeTypes["wires"] = TopAbs_WIRE;
373 myShapeTypes["edge"] = TopAbs_EDGE;
374 myShapeTypes["edges"] = TopAbs_EDGE;
375 myShapeTypes["vertex"] = TopAbs_VERTEX;
376 myShapeTypes["vertices"] = TopAbs_VERTEX;
377 myShapeTypes["object"] = ModuleBase_ResultPrs::Sel_Result;
378 myShapeTypes["objects"] = ModuleBase_ResultPrs::Sel_Result;
380 QString aType = theType.toLower();
381 if(myShapeTypes.contains(aType))
382 return myShapeTypes[aType];
383 Events_InfoMessage("ModuleBase_Tools", "Shape type defined in XML is not implemented!").send();
387 void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFeature,
388 bool& hasParameter, bool& hasCompositeOwner, bool& hasResultInHistory,
393 hasParameter = false;
394 hasCompositeOwner = false;
395 hasResultInHistory = false;
397 foreach(ObjectPtr aObj, theObjects) {
398 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
399 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
400 FolderPtr aFolder = std::dynamic_pointer_cast<ModelAPI_Folder>(aObj);
401 ResultParameterPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aResult);
402 FieldStepPtr aStep = std::dynamic_pointer_cast<ModelAPI_ResultField::ModelAPI_FieldStep>(aObj);
404 hasResult |= ((aResult.get() != NULL) || (aStep.get() != NULL));
405 hasFeature |= (aFeature.get() != NULL);
406 hasFolder |= (aFolder.get() != NULL);
407 hasParameter |= (aConstruction.get() != NULL);
409 hasCompositeOwner |= (ModelAPI_Tools::compositeOwner(aFeature) != NULL);
411 if (!hasResultInHistory && aResult.get()) {
412 FeaturePtr aFeature = ModelAPI_Feature::feature(aResult);
413 hasResultInHistory = aFeature.get() && aFeature->isInHistory();
416 if (hasFeature && hasResult && hasParameter && hasCompositeOwner && hasFeature)
421 /*bool setDefaultDeviationCoefficient(std::shared_ptr<GeomAPI_Shape> theGeomShape)
423 if (!theGeomShape.get())
425 // if the shape could not be exploded on faces, it contains only wires, edges, and vertices
426 // correction of deviation for them should not influence to the application performance
427 GeomAPI_ShapeExplorer anExp(theGeomShape, GeomAPI_Shape::FACE);
428 bool anEmpty = anExp.empty();
429 return !anExp.more();
432 /*void setDefaultDeviationCoefficient(const std::shared_ptr<ModelAPI_Result>& theResult,
433 const Handle(Prs3d_Drawer)& theDrawer)
435 if (!theResult.get())
437 bool aUseDeviation = false;
439 std::string aResultGroup = theResult->groupName();
440 if (aResultGroup == ModelAPI_ResultConstruction::group())
441 aUseDeviation = true;
442 else if (aResultGroup == ModelAPI_ResultBody::group()) {
443 GeomShapePtr aGeomShape = theResult->shape();
444 if (aGeomShape.get())
445 aUseDeviation = setDefaultDeviationCoefficient(aGeomShape);
448 theDrawer->SetDeviationCoefficient(DEFAULT_DEVIATION_COEFFICIENT);
451 void setDefaultDeviationCoefficient(const TopoDS_Shape& theShape,
452 const Handle(Prs3d_Drawer)& theDrawer)
454 if (theShape.IsNull())
457 std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape());
458 aGeomShape->setImpl(new TopoDS_Shape(theShape));
460 // if the shape could not be exploded on faces, it contains only wires, edges, and vertices
461 // correction of deviation for them should not influence to the application performance
462 GeomAPI_ShapeExplorer anExp(aGeomShape, GeomAPI_Shape::FACE);
463 bool isConstruction = !anExp.more();
467 aDeflection = Config_PropManager::real("Visualization", "construction_deflection");
469 aDeflection = Config_PropManager::real("Visualization", "body_deflection");
471 theDrawer->SetDeviationCoefficient(aDeflection);
474 Quantity_Color color(const std::string& theSection,
475 const std::string& theName)
477 std::vector<int> aColor = Config_PropManager::color(theSection, theName);
478 return Quantity_Color(aColor[0] / 255., aColor[1] / 255., aColor[2] / 255., Quantity_TOC_RGB);
481 ObjectPtr getObject(const AttributePtr& theAttribute)
484 std::string anAttrType = theAttribute->attributeType();
485 if (anAttrType == ModelAPI_AttributeRefAttr::typeId()) {
486 AttributeRefAttrPtr anAttr =
487 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
488 if (anAttr != NULL && anAttr->isObject())
489 anObject = anAttr->object();
491 if (anAttrType == ModelAPI_AttributeSelection::typeId()) {
492 AttributeSelectionPtr anAttr =
493 std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
495 anObject = anAttr->context();
497 if (anAttrType == ModelAPI_AttributeReference::typeId()) {
498 AttributeReferencePtr anAttr =
499 std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
500 if (anAttr.get() != NULL)
501 anObject = anAttr->value();
506 TopAbs_ShapeEnum getCompoundSubType(const TopoDS_Shape& theShape)
508 TopAbs_ShapeEnum aShapeType = theShape.ShapeType();
510 // for compounds check sub-shapes: it may be compound of needed type:
511 // Booleans may produce compounds of Solids
512 if (aShapeType == TopAbs_COMPOUND) {
513 for(TopoDS_Iterator aSubs(theShape); aSubs.More(); aSubs.Next()) {
514 if (!aSubs.Value().IsNull()) {
515 TopAbs_ShapeEnum aSubType = aSubs.Value().ShapeType();
516 if (aSubType == TopAbs_COMPOUND) { // compound of compound(s)
517 aShapeType = TopAbs_COMPOUND;
520 if (aShapeType == TopAbs_COMPOUND) {
521 aShapeType = aSubType;
522 } else if (aShapeType != aSubType) { // compound of shapes of different types
523 aShapeType = TopAbs_COMPOUND;
532 TopoDS_Shape getSelectedShape(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs)
534 if (thePrs->shape().get())
535 return thePrs->shape()->impl<TopoDS_Shape>();
537 Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(thePrs->owner());
538 if (!anOwner.IsNull())
539 return anOwner->Shape();
541 return TopoDS_Shape();
544 void getParameters(QStringList& theParameters)
546 theParameters.clear();
548 SessionPtr aSession = ModelAPI_Session::get();
549 std::list<DocumentPtr> aDocList;
550 DocumentPtr anActiveDocument = aSession->activeDocument();
551 DocumentPtr aRootDocument = aSession->moduleDocument();
552 aDocList.push_back(anActiveDocument);
553 if (anActiveDocument != aRootDocument) {
554 aDocList.push_back(aRootDocument);
556 std::string aGroupId = ModelAPI_ResultParameter::group();
557 for(std::list<DocumentPtr>::const_iterator it = aDocList.begin(); it != aDocList.end(); ++it) {
558 DocumentPtr aDocument = *it;
559 int aSize = aDocument->size(aGroupId);
560 for (int i = 0; i < aSize; i++) {
561 ObjectPtr anObject = aDocument->object(aGroupId, i);
562 std::string aParameterName = anObject->data()->name();
563 theParameters.append(aParameterName.c_str());
568 std::string findGreedAttribute(ModuleBase_IWorkshop* theWorkshop,
569 const FeaturePtr& theFeature)
571 std::string anAttributeId;
573 std::string aXmlCfg, aDescription;
574 theWorkshop->module()->getXMLRepresentation(theFeature->getKind(), aXmlCfg, aDescription);
576 ModuleBase_WidgetFactory aFactory(aXmlCfg, theWorkshop);
577 std::string anAttributeTitle;
578 aFactory.getGreedAttribute(anAttributeId);
580 return anAttributeId;
583 bool hasObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
584 const std::shared_ptr<GeomAPI_Shape>& theShape,
585 ModuleBase_IWorkshop* theWorkshop,
586 const bool theTemporarily)
588 bool aHasObject = false;
589 if (!theAttribute.get())
592 std::string aType = theAttribute->attributeType();
593 if (aType == ModelAPI_AttributeReference::typeId()) {
594 AttributeReferencePtr aRef =
595 std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
596 ObjectPtr aObject = aRef->value();
597 aHasObject = aObject && aObject->isSame(theObject);
598 //if (!(aObject && aObject->isSame(theObject))) {
599 // aRef->setValue(theObject);
601 } else if (aType == ModelAPI_AttributeRefAttr::typeId()) {
602 AttributeRefAttrPtr aRefAttr =
603 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
605 AttributePtr anAttribute = theWorkshop->module()->findAttribute(theObject, theShape);
606 if (anAttribute.get()) {
607 //aRefAttr->setAttr(anAttribute);
610 ObjectPtr aObject = aRefAttr->object();
611 aHasObject = aObject && aObject->isSame(theObject);
612 //if (!(aObject && aObject->isSame(theObject))) {
613 // aRefAttr->setObject(theObject);
616 } else if (aType == ModelAPI_AttributeSelection::typeId()) {
617 /*AttributeSelectionPtr aSelectAttr =
618 std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
619 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
620 if (aSelectAttr.get() != NULL) {
621 aSelectAttr->setValue(aResult, theShape, theTemporarily);
624 if (aType == ModelAPI_AttributeSelectionList::typeId()) {
625 AttributeSelectionListPtr aSelectionListAttr =
626 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
627 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
628 aHasObject = aSelectionListAttr->isInList(aResult, theShape, theTemporarily);
630 else if (aType == ModelAPI_AttributeRefList::typeId()) {
631 AttributeRefListPtr aRefListAttr =
632 std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
633 aHasObject = aRefListAttr->isInList(theObject);
634 //if (!theCheckIfAttributeHasObject || !aRefListAttr->isInList(theObject))
635 // aRefListAttr->append(theObject);
637 else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
638 AttributeRefAttrListPtr aRefAttrListAttr =
639 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(theAttribute);
640 AttributePtr anAttribute = theWorkshop->module()->findAttribute(theObject, theShape);
642 if (anAttribute.get()) {
643 aHasObject = aRefAttrListAttr->isInList(anAttribute);
644 //if (!theCheckIfAttributeHasObject || !aRefAttrListAttr->isInList(anAttribute))
645 // aRefAttrListAttr->append(anAttribute);
648 aHasObject = aRefAttrListAttr->isInList(theObject);
649 //if (!theCheckIfAttributeHasObject || !aRefAttrListAttr->isInList(theObject))
650 // aRefAttrListAttr->append(theObject);
656 bool setObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
657 const GeomShapePtr& theShape, ModuleBase_IWorkshop* theWorkshop,
658 const bool theTemporarily, const bool theCheckIfAttributeHasObject)
660 if (!theAttribute.get())
664 std::string aType = theAttribute->attributeType();
665 if (aType == ModelAPI_AttributeReference::typeId()) {
666 AttributeReferencePtr aRef =
667 std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
668 ObjectPtr aObject = aRef->value();
669 if (!(aObject && aObject->isSame(theObject))) {
670 aRef->setValue(theObject);
672 } else if (aType == ModelAPI_AttributeRefAttr::typeId()) {
673 AttributeRefAttrPtr aRefAttr =
674 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
676 AttributePtr anAttribute = theWorkshop->module()->findAttribute(theObject, theShape);
677 if (anAttribute.get())
678 aRefAttr->setAttr(anAttribute);
680 ObjectPtr aObject = aRefAttr->object();
681 if (!(aObject && aObject->isSame(theObject))) {
682 aRefAttr->setObject(theObject);
685 } else if (aType == ModelAPI_AttributeSelection::typeId()) {
686 AttributeSelectionPtr aSelectAttr =
687 std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
688 if (aSelectAttr.get() != NULL) {
689 aSelectAttr->setValue(theObject, theShape, theTemporarily);
692 if (aType == ModelAPI_AttributeSelectionList::typeId()) {
693 AttributeSelectionListPtr aSelectionListAttr =
694 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
695 if (!theCheckIfAttributeHasObject ||
696 !aSelectionListAttr->isInList(theObject, theShape, theTemporarily))
697 aSelectionListAttr->append(theObject, theShape, theTemporarily);
699 else if (aType == ModelAPI_AttributeRefList::typeId()) {
700 AttributeRefListPtr aRefListAttr =
701 std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
702 if (!theCheckIfAttributeHasObject || !aRefListAttr->isInList(theObject)) {
704 aRefListAttr->append(theObject);
709 else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
710 AttributeRefAttrListPtr aRefAttrListAttr =
711 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(theAttribute);
712 AttributePtr anAttribute = theWorkshop->module()->findAttribute(theObject, theShape);
714 if (anAttribute.get()) {
715 if (!theCheckIfAttributeHasObject || !aRefAttrListAttr->isInList(anAttribute))
716 aRefAttrListAttr->append(anAttribute);
719 if (!theCheckIfAttributeHasObject || !aRefAttrListAttr->isInList(theObject)) {
721 aRefAttrListAttr->append(theObject);
730 GeomShapePtr getShape(const AttributePtr& theAttribute, ModuleBase_IWorkshop* theWorkshop)
733 if (!theAttribute.get())
736 std::string aType = theAttribute->attributeType();
737 if (aType == ModelAPI_AttributeReference::typeId()) {
738 } else if (aType == ModelAPI_AttributeRefAttr::typeId()) {
739 AttributeRefAttrPtr aRefAttr =
740 std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
741 if (aRefAttr.get() && !aRefAttr->isObject()) {
742 AttributePtr anAttribute = aRefAttr->attr();
743 aShape = theWorkshop->module()->findShape(anAttribute);
745 } else if (aType == ModelAPI_AttributeSelection::typeId()) {
746 AttributeSelectionPtr aSelectAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
748 aShape = aSelectAttr->value();
750 else // Geom2D point processing
751 aShape = theWorkshop->module()->findShape(theAttribute);
755 void flushUpdated(ObjectPtr theObject)
757 blockUpdateViewer(true);
759 // Fix the problem of not previewed results of constraints applied. Flush Create/Delete
760 // (for the sketch result) to start processing of the sketch in the solver.
761 // TODO: these flushes should be moved in a separate method provided by Model
762 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
763 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
764 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
766 blockUpdateViewer(false);
769 void blockUpdateViewer(const bool theValue)
771 // the viewer update should be blocked in order to avoid the temporary feature content
772 // when the solver processes the feature, the redisplay message can be flushed
773 // what caused the display in the viewer preliminary states of object
774 // e.g. fillet feature, angle value change
775 std::shared_ptr<Events_Message> aMsg;
777 aMsg = std::shared_ptr<Events_Message>(
778 new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED)));
781 // the viewer update should be unblocked
782 aMsg = std::shared_ptr<Events_Message>(
783 new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_UNBLOCKED)));
785 Events_Loop::loop()->send(aMsg);
788 QString wrapTextByWords(const QString& theValue, QWidget* theWidget,
789 int theMaxLineInPixels)
791 static QFontMetrics tfm(theWidget ? theWidget->font() : QApplication::font());
792 static qreal phi = 2.618;
794 QRect aBounds = tfm.boundingRect(theValue);
795 if(aBounds.width() <= theMaxLineInPixels)
798 qreal s = aBounds.width() * aBounds.height();
799 qreal aGoldWidth = sqrt(s*phi);
801 QStringList aWords = theValue.split(" ", QString::SkipEmptyParts);
803 int n = aWords.count();
805 for (int i = 0; i < n; i++) {
806 QString aLineExt = i == 0 ? aWords[i] : aLine + " " + aWords[i];
807 qreal anWidthNonExt = tfm.boundingRect(aLine).width();
808 qreal anWidthExt = tfm.boundingRect(aLineExt).width();
809 qreal aDeltaNonExt = fabs(anWidthNonExt-aGoldWidth);
810 qreal aDeltaExt = fabs(anWidthExt-aGoldWidth);
811 if(aDeltaNonExt < aDeltaExt) {
813 aLines.append(aLine);
821 aLines.append(aLine);
823 QString aResult = aLines.join("\n");
827 //**************************************************************
828 QLocale doubleLocale()
830 // VSR 01/07/2010: Disable thousands separator for spin box
831 // (to avoid inconsistency of double-2-string and string-2-double conversion)
833 aLocale.setNumberOptions(aLocale.numberOptions() |
834 QLocale::OmitGroupSeparator |
835 QLocale::RejectGroupSeparator);
839 //**************************************************************
840 void refsToFeatureInFeatureDocument(const ObjectPtr& theObject,
841 std::set<FeaturePtr>& theRefFeatures)
843 FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
844 if (aFeature.get()) {
845 DocumentPtr aFeatureDoc = aFeature->document();
846 // 1. find references in the current document
847 aFeatureDoc->refsToFeature(aFeature, theRefFeatures, false);
852 //**************************************************************
853 /*bool isSubOfComposite(const ObjectPtr& theObject)
856 std::set<FeaturePtr> aRefFeatures;
857 refsToFeatureInFeatureDocument(theObject, aRefFeatures);
858 std::set<FeaturePtr>::const_iterator anIt = aRefFeatures.begin(),
859 aLast = aRefFeatures.end();
860 for (; anIt != aLast && !isSub; anIt++) {
861 isSub = isSubOfComposite(theObject, *anIt);
866 //**************************************************************
867 /*bool isSubOfComposite(const ObjectPtr& theObject, const FeaturePtr& theFeature)
870 CompositeFeaturePtr aComposite = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theFeature);
871 if (aComposite.get()) {
872 isSub = aComposite->isSub(theObject);
873 // the recursive is possible, the parameters are sketch circle and extrusion cut. They are
874 // separated by composite sketch feature
876 int aNbSubs = aComposite->numberOfSubs();
877 for (int aSub = 0; aSub < aNbSubs && !isSub; aSub++) {
878 isSub = isSubOfComposite(theObject, aComposite->subFeature(aSub));
885 //**************************************************************
886 ResultPtr firstResult(const ObjectPtr& theObject)
888 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
889 if (!aResult.get()) {
890 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
892 aResult = aFeature->firstResult();
897 //**************************************************************
898 bool isFeatureOfResult(const FeaturePtr& theFeature, const std::string& theGroupOfResult)
900 bool isResult = false;
902 if (!theFeature->data()->isValid())
905 ResultPtr aFirstResult = theFeature->firstResult();
906 if (!aFirstResult.get())
909 return aFirstResult->groupName() == theGroupOfResult;
912 //**************************************************************
913 bool hasModuleDocumentFeature(const std::set<FeaturePtr>& theFeatures)
915 bool aFoundModuleDocumentObject = false;
916 DocumentPtr aModuleDoc = ModelAPI_Session::get()->moduleDocument();
918 std::set<FeaturePtr>::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end();
919 for (; anIt != aLast && !aFoundModuleDocumentObject; anIt++) {
920 FeaturePtr aFeature = *anIt;
921 ResultPtr aResult = ModuleBase_Tools::firstResult(aFeature);
922 if (aResult.get() && aResult->groupName() == ModelAPI_ResultPart::group())
924 aFoundModuleDocumentObject = aFeature->document() == aModuleDoc;
927 return aFoundModuleDocumentObject;
930 //**************************************************************
931 bool askToDelete(const std::set<FeaturePtr> theFeatures,
932 const std::map<FeaturePtr, std::set<FeaturePtr> >& theReferences,
934 std::set<FeaturePtr>& theReferencesToDelete,
935 const std::string& thePrefixInfo)
937 QString aNotActivatedDocWrn;
938 std::string aNotActivatedNames;
939 if (!ModelAPI_Tools::allDocumentsActivated(aNotActivatedNames)) {
940 if (ModuleBase_Tools::hasModuleDocumentFeature(theFeatures))
941 aNotActivatedDocWrn =
942 QObject::tr("Selected objects can be used in Part documents which are not loaded: %1.\n")
943 .arg(aNotActivatedNames.c_str());
946 std::set<FeaturePtr> aFeaturesRefsTo;
947 std::set<FeaturePtr> aFeaturesRefsToParameter;
948 std::set<FeaturePtr> aParameterFeatures;
949 QStringList aPartFeatureNames;
950 std::set<FeaturePtr>::const_iterator anIt = theFeatures.begin(),
951 aLast = theFeatures.end();
952 // separate features to references to parameter features and references to others
953 for (; anIt != aLast; anIt++) {
954 FeaturePtr aFeature = *anIt;
955 if (theReferences.find(aFeature) == theReferences.end())
958 if (isFeatureOfResult(aFeature, ModelAPI_ResultPart::group()))
959 aPartFeatureNames.append(aFeature->name().c_str());
961 std::set<FeaturePtr> aRefFeatures;
962 std::set<FeaturePtr> aRefList = theReferences.at(aFeature);
963 std::set<FeaturePtr>::const_iterator aRefIt = aRefList.begin(), aRefLast = aRefList.end();
964 for (; aRefIt != aRefLast; aRefIt++) {
965 FeaturePtr aRefFeature = *aRefIt;
966 if (theFeatures.find(aRefFeature) == theFeatures.end() && // it is not selected
967 aRefFeatures.find(aRefFeature) == aRefFeatures.end()) // it is not added
968 aRefFeatures.insert(aRefFeature);
971 if (isFeatureOfResult(aFeature, ModelAPI_ResultParameter::group())) {
972 aFeaturesRefsToParameter.insert(aRefFeatures.begin(), aRefFeatures.end());
973 aParameterFeatures.insert(aFeature);
976 theReferencesToDelete.insert(aRefFeatures.begin(), aRefFeatures.end());
980 std::set<FeaturePtr> aFeaturesRefsToParameterOnly;
981 anIt = aFeaturesRefsToParameter.begin();
982 aLast = aFeaturesRefsToParameter.end();
983 // separate features to references to parameter features and references to others
984 QStringList aParamFeatureNames;
985 for (; anIt != aLast; anIt++) {
986 FeaturePtr aFeature = *anIt;
987 if (theReferencesToDelete.find(aFeature) == theReferencesToDelete.end()) {
988 aFeaturesRefsToParameterOnly.insert(aFeature);
989 aParamFeatureNames.append(aFeature->name().c_str());
992 aParamFeatureNames.sort();
993 QStringList anOtherFeatureNames;
994 anIt = theReferencesToDelete.begin();
995 aLast = theReferencesToDelete.end();
996 for (; anIt != aLast; anIt++) {
997 FeaturePtr aFeature = *anIt;
998 if (aFeature->getKind() == "RemoveResults")
999 continue; // skip the remove results feature mentioning: result will be removed anyway
1000 if (isFeatureOfResult(aFeature, ModelAPI_ResultPart::group()))
1001 aPartFeatureNames.append(aFeature->name().c_str());
1003 anOtherFeatureNames.append(aFeature->name().c_str());
1005 aPartFeatureNames.sort();
1006 anOtherFeatureNames.sort();
1008 bool aCanReplaceParameters = !aFeaturesRefsToParameterOnly.empty();
1010 QMessageBox aMessageBox(theParent);
1011 aMessageBox.setWindowTitle(QObject::tr("Delete features"));
1012 aMessageBox.setIcon(QMessageBox::Warning);
1013 aMessageBox.setStandardButtons(QMessageBox::No | QMessageBox::Yes);
1014 aMessageBox.setDefaultButton(QMessageBox::No);
1017 if (!thePrefixInfo.empty())
1018 aText = thePrefixInfo.c_str();
1019 QString aSep = ", ";
1020 if (!aPartFeatureNames.empty()) {
1021 aText += QString(QObject::tr("The following parts will be deleted: %1.\n"))
1022 .arg(aPartFeatureNames.join(aSep));
1024 if (!aNotActivatedDocWrn.isEmpty())
1025 aText += aNotActivatedDocWrn;
1026 if (!anOtherFeatureNames.empty()) {
1027 const char* aMsg = "Features are used in the following features: %1.\nThese "
1028 "features will be deleted.\n";
1029 aText += QString(QObject::tr(aMsg))
1030 .arg(anOtherFeatureNames.join(aSep));
1032 if (!aParamFeatureNames.empty()) {
1033 const char* aMsg = "Parameters are used directly and through a sequence "
1034 "of dependencies in the following features: %1.\nThese features will "
1035 "be deleted.\nOr parameters could be replaced by their values.\n";
1036 aText += QString(QObject::tr(aMsg))
1037 .arg(aParamFeatureNames.join(aSep));
1038 QPushButton *aReplaceButton =
1039 aMessageBox.addButton(QObject::tr("Replace"), QMessageBox::ActionRole);
1042 if (!aText.isEmpty()) {
1043 aText += "Would you like to continue?";
1044 aMessageBox.setText(aText);
1046 QMessageBox::ButtonRole aButtonRole = aMessageBox.buttonRole(aMessageBox.clickedButton());
1048 if (aButtonRole == QMessageBox::NoRole)
1051 if (aButtonRole == QMessageBox::ActionRole) {
1052 foreach (FeaturePtr aObj, aParameterFeatures)
1053 ModelAPI_ReplaceParameterMessage::send(aObj, 0);
1056 theReferencesToDelete.insert(aFeaturesRefsToParameterOnly.begin(),
1057 aFeaturesRefsToParameterOnly.end());
1062 //**************************************************************
1063 void convertToFeatures(const QObjectPtrList& theObjects, std::set<FeaturePtr>& theFeatures)
1065 QObjectPtrList::const_iterator anIt = theObjects.begin(), aLast = theObjects.end();
1066 for(; anIt != aLast; anIt++) {
1067 ObjectPtr anObject = *anIt;
1068 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anObject);
1069 // for parameter result, use the corresponded reature to be removed
1070 if (!aFeature.get() && anObject->groupName() == ModelAPI_ResultParameter::group()) {
1071 aFeature = ModelAPI_Feature::feature(anObject);
1074 theFeatures.insert(aFeature);
1078 //**************************************************************
1079 void convertToFolders(const QObjectPtrList& theObjects,
1080 std::set<FolderPtr>& theFolders)
1082 QObjectPtrList::const_iterator anIt = theObjects.begin(), aLast = theObjects.end();
1083 for(; anIt != aLast; anIt++) {
1084 ObjectPtr anObject = *anIt;
1085 FolderPtr aFeature = std::dynamic_pointer_cast<ModelAPI_Folder>(anObject);
1087 theFolders.insert(aFeature);
1092 //**************************************************************
1093 QString translate(const Events_InfoMessage& theMessage)
1097 if (!theMessage.empty()) {
1098 std::string aStr = Config_Translator::translate(theMessage);
1099 if (!aStr.empty()) {
1100 std::string aCodec = Config_Translator::codec(theMessage);
1101 aMessage = QTextCodec::codecForName(aCodec.c_str())->toUnicode(aStr.c_str());
1108 QString translate(const std::string& theContext, const std::string& theMessage)
1112 if (!theMessage.empty()) {
1113 std::string aStr = Config_Translator::translate(theContext, theMessage);
1114 if (!aStr.empty()) {
1115 std::string aCodec = Config_Translator::codec(theContext);
1116 aMessage = QTextCodec::codecForName(aCodec.c_str())->toUnicode(aStr.c_str());
1123 void setPointBallHighlighting(AIS_Shape* theAIS)
1125 static Handle(Image_AlienPixMap) aPixMap;
1126 if(aPixMap.IsNull()) {
1127 // Load icon for the presentation
1129 char* anEnv = getenv("SHAPER_ROOT_DIR");
1131 aFile = std::string(anEnv) +
1132 FSEP + "share" + FSEP + "salome" + FSEP + "resources" + FSEP + "shaper";
1134 anEnv = getenv("CADBUILDER_ROOT_DIR");
1136 aFile = std::string(anEnv) + FSEP + "resources";
1140 static const std::string aMarkerName = "marker_dot.png";
1141 aFile += aMarkerName;
1142 aPixMap = new Image_AlienPixMap();
1143 if(!aPixMap->Load(aFile.c_str())) {
1144 // The icon for constraint is not found
1145 static const std::string aMsg =
1146 "Error: Point market not found by path: \"" + aFile + "\". Falling back.";
1147 //Events_InfoMessage("ModuleBase_Tools::setPointBallHighlighting", aMsg).send();
1151 Handle(Graphic3d_AspectMarker3d) anAspect;
1152 Handle(Prs3d_Drawer) aDrawer = theAIS->DynamicHilightAttributes();
1153 if (aDrawer.IsNull()) {
1154 if (ModuleBase_IViewer::DefaultHighlightDrawer.IsNull())
1156 aDrawer = new Prs3d_Drawer(*ModuleBase_IViewer::DefaultHighlightDrawer);
1157 if (!aDrawer->HasOwnPointAspect()) {
1158 aDrawer->SetPointAspect(new Prs3d_PointAspect(Aspect_TOM_BALL, Quantity_NOC_BLACK, 2.0));
1161 if(aDrawer->HasOwnPointAspect()) {
1162 Handle(Prs3d_PointAspect) aPntAspect = aDrawer->PointAspect();
1163 if(aPixMap->IsEmpty()) {
1164 anAspect = aPntAspect->Aspect();
1165 anAspect->SetType(Aspect_TOM_BALL);
1167 if(aPixMap->Format() == Image_PixMap::ImgGray) {
1168 aPixMap->SetFormat (Image_PixMap::ImgAlpha);
1169 } else if(aPixMap->Format() == Image_PixMap::ImgGrayF) {
1170 aPixMap->SetFormat (Image_PixMap::ImgAlphaF);
1172 anAspect = new Graphic3d_AspectMarker3d(aPixMap);
1173 aPntAspect->SetAspect(anAspect);
1175 aDrawer->SetPointAspect(aPntAspect);
1176 theAIS->SetDynamicHilightAttributes(aDrawer);
1180 FeaturePtr createParameter(const QString& theText)
1182 FeaturePtr aParameter;
1183 QStringList aList = theText.split("=");
1184 if (aList.count() != 2) {
1187 QString aParamName = aList.at(0).trimmed();
1189 if (isNameExist(aParamName, FeaturePtr())) {
1193 if (!ModelAPI_Expression::isVariable(aParamName.toStdString())) {
1197 QString aExpression = aList.at(1).trimmed();
1198 if (aExpression.isEmpty()) {
1202 SessionPtr aMgr = ModelAPI_Session::get();
1203 std::shared_ptr<ModelAPI_Document> aDoc = aMgr->activeDocument();
1205 aParameter = aDoc->addFeature("Parameter");
1206 if (aParameter.get()) {
1207 AttributeStringPtr aNameAttr = aParameter->string("variable");
1208 aNameAttr->setValue(aParamName.toStdString());
1210 AttributeStringPtr aExprAttr = aParameter->string("expression");
1211 aExprAttr->setValue(aExpression.toStdString());
1212 aParameter->execute();
1214 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
1215 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
1220 void editParameter(FeaturePtr theParam, const QString& theText)
1222 QStringList aList = theText.split("=");
1223 QString aParamName = aList.at(0).trimmed();
1225 QString aExpression = aList.at(1).trimmed();
1226 if (aExpression.isEmpty()) {
1230 if (isNameExist(aParamName, theParam)) {
1233 AttributeStringPtr aNameAttr = theParam->string("variable");
1234 aNameAttr->setValue(aParamName.toStdString());
1236 AttributeStringPtr aExprAttr = theParam->string("expression");
1237 aExprAttr->setValue(aExpression.toStdString());
1238 theParam->execute();
1240 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
1243 bool isNameExist(const QString& theName, FeaturePtr theIgnoreParameter)
1245 SessionPtr aMgr = ModelAPI_Session::get();
1246 std::shared_ptr<ModelAPI_Document> aDoc = aMgr->activeDocument();
1247 FeaturePtr aParamFeature;
1248 int aNbFeatures = aDoc->numInternalFeatures();
1249 std::string aName = theName.toStdString();
1250 for (int i = 0; i < aNbFeatures; i++) {
1251 aParamFeature = aDoc->internalFeature(i);
1252 if (aParamFeature && aParamFeature->getKind() == "Parameter") {
1253 if ((theIgnoreParameter != aParamFeature) && (aParamFeature->name() == aName))
1260 FeaturePtr findParameter(const QString& theName)
1262 SessionPtr aMgr = ModelAPI_Session::get();
1263 std::shared_ptr<ModelAPI_Document> aDoc = aMgr->activeDocument();
1264 FeaturePtr aParamFeature;
1265 int aNbFeatures = aDoc->numInternalFeatures();
1266 std::string aName = theName.toStdString();
1267 for (int i = 0; i < aNbFeatures; i++) {
1268 aParamFeature = aDoc->internalFeature(i);
1269 if (aParamFeature && aParamFeature->getKind() == "Parameter") {
1270 if (aParamFeature->name() == aName)
1271 return aParamFeature;
1274 return FeaturePtr();
1278 //********************************************************************
1279 std::string generateName(const AttributePtr& theAttribute,
1280 ModuleBase_IWorkshop* theWorkshop)
1283 if (theAttribute.get() != NULL) {
1284 ModuleBase_Operation* anOperation = theWorkshop->currentOperation();
1286 FeaturePtr aFeature = ModelAPI_Feature::feature(theAttribute->owner());
1287 if (aFeature.get()) {
1288 std::string aXmlCfg, aDescription;
1289 theWorkshop->module()->getXMLRepresentation(aFeature->getKind(), aXmlCfg, aDescription);
1291 ModuleBase_WidgetFactory aFactory(aXmlCfg, theWorkshop);
1292 std::string anAttributeTitle;
1293 aFactory.getAttributeTitle(theAttribute->id(), anAttributeTitle);
1295 std::stringstream aStreamName;
1296 aStreamName << theAttribute->owner()->data()->name() << "/" << anAttributeTitle.c_str();
1297 aName = aStreamName.str();
1303 bool isSameShape(const TopoDS_Shape& theShape1, const TopoDS_Shape& theShape2)
1305 // In case of compound we cannot rely on simple comparison method.
1306 // If the compound is generated by Group feature then this compound is alwais new.
1307 // So, we have to compare content of these compounds
1308 if (theShape1.ShapeType() != theShape2.ShapeType())
1311 if (theShape1.ShapeType() != TopAbs_COMPOUND)
1312 return theShape1.IsSame(theShape2);
1314 TopoDS_Iterator aIt1(theShape1);
1315 TopoDS_Iterator aIt2(theShape2);
1317 for (; aIt1.More() && aIt2.More(); aIt1.Next(), aIt2.Next()) {
1318 if (!(aIt1.Value()).IsSame(aIt2.Value()))
1324 qreal currentPixelRatio()
1326 QWindowList aWnds = qApp->topLevelWindows();
1327 if (aWnds.size() > 0)
1328 return aWnds.first()->devicePixelRatio();
1329 return qApp->primaryScreen()->devicePixelRatio();
1333 } // namespace ModuleBase_Tools