-// Copyright (C) 2014-2021 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2022 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include <ModelAPI_Folder.h>
#include <ModelGeomAlgo_Point2D.h>
+#include <SUIT_ResourceMgr.h>
#ifdef HAVE_SALOME
#include <SUIT_Application.h>
-#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
#endif
#include <QTextCodec>
#include <QWindow>
#include <QScreen>
+#include <QCheckBox>
#include <sstream>
#include <string>
}
}
-/*bool setDefaultDeviationCoefficient(std::shared_ptr<GeomAPI_Shape> theGeomShape)
-{
- if (!theGeomShape.get())
- return false;
- // if the shape could not be exploded on faces, it contains only wires, edges, and vertices
- // correction of deviation for them should not influence to the application performance
- GeomAPI_ShapeExplorer anExp(theGeomShape, GeomAPI_Shape::FACE);
- bool anEmpty = anExp.empty();
- return !anExp.more();
-}*/
-
-/*void setDefaultDeviationCoefficient(const std::shared_ptr<ModelAPI_Result>& theResult,
- const Handle(Prs3d_Drawer)& theDrawer)
-{
- if (!theResult.get())
- return;
- bool aUseDeviation = false;
-
- std::string aResultGroup = theResult->groupName();
- if (aResultGroup == ModelAPI_ResultConstruction::group())
- aUseDeviation = true;
- else if (aResultGroup == ModelAPI_ResultBody::group()) {
- GeomShapePtr aGeomShape = theResult->shape();
- if (aGeomShape.get())
- aUseDeviation = setDefaultDeviationCoefficient(aGeomShape);
- }
- if (aUseDeviation)
- theDrawer->SetDeviationCoefficient(DEFAULT_DEVIATION_COEFFICIENT);
-}
-*/
void setDefaultDeviationCoefficient(const TopoDS_Shape& theShape,
const Handle(Prs3d_Drawer)& theDrawer)
{
aText += QString(QObject::tr(aMsg));
aDetailedText += QString(QObject::tr(aMsgDetails))
.arg(aParamFeatureNames.join(aSep));
-#ifdef _DEBUG
- QPushButton *aReplaceButton =
-#endif
- aMessageBox.addButton(QObject::tr("Replace"), QMessageBox::ActionRole);
+ aMessageBox.addButton(QObject::tr("Replace"), QMessageBox::ActionRole);
}
if (!aText.isEmpty()) {
return true;
}
+//**************************************************************
+bool warningAboutConflict(QWidget* theParent, const std::string& theWarningText)
+{
+ QMessageBox aMessageBox(theParent);
+ aMessageBox.setWindowTitle(QObject::tr("Conflicts in constraint"));
+ aMessageBox.setIcon(QMessageBox::Warning);
+ aMessageBox.setText((theWarningText + "\nConstraints will be removed or substituted").c_str());
+
+ QCheckBox* aCheckBox = new QCheckBox;
+
+ aCheckBox->setTristate(false);
+ aCheckBox->setText("switch off the notifications.");
+
+ aMessageBox.setCheckBox(aCheckBox);
+ aMessageBox.setStandardButtons(QMessageBox::Ok);
+
+ aMessageBox.exec();
+
+ if (aCheckBox->isChecked())
+ {
+ ModuleBase_Preferences::resourceMgr()->setValue(SKETCH_TAB_NAME,
+ "notify_change_constraint", false);
+ }
+
+ return true;
+}
+
//**************************************************************
void convertToFeatures(const QObjectPtrList& theObjects, std::set<FeaturePtr>& theFeatures)
{
// Set displaying status to every element on group
static void setDisplayingByLoop(DocumentPtr theDoc, int theSize,
- std::string theGroup, bool theDisplayFromScript)
+ std::string theGroup, bool theDisplayFromScript, int theDisplayingId)
+{
+ for (int anIndex = theSize - 1; anIndex >= 0; --anIndex) {
+ ObjectPtr anObject = theDoc->object(theGroup, anIndex);
+ anObject->setDisplayed((theDisplayingId == 1 && anIndex == theSize - 1) ||
+ theDisplayingId == 2);
+ }
+}
+
+void setDisplaying(ResultPartPtr thePart, bool theDisplayFromScript)
{
+ static bool isDoingDisplay = false;
+
+ if (isDoingDisplay)
+ return;
+
+ isDoingDisplay = true;
+ DocumentPtr aDoc = thePart->partDoc();
+ int aConstructionSize = aDoc->size(ModelAPI_ResultConstruction::group());
+ int aGroupSize = aDoc->size(ModelAPI_ResultGroup::group());
+ int aFieldSize = aDoc->size(ModelAPI_ResultField::group());
+ int aResultSize = aDoc->size(ModelAPI_ResultBody::group());
+
int aDisplayingId = -1;
if (theDisplayFromScript) {
aDisplayingId = ModuleBase_Preferences::resourceMgr()->integerValue("General",
return;
}
- for (int anIndex = theSize - 1; anIndex >= 0; --anIndex) {
- ObjectPtr anObject = theDoc->object(theGroup, anIndex);
- anObject->setDisplayed((aDisplayingId == 1 && anIndex == theSize - 1) || aDisplayingId == 2);
- }
-}
-
-void setDisplaying(ResultPartPtr thePart, bool theDisplayFromScript)
-{
- DocumentPtr aDoc = thePart->partDoc();
- int aConstructionSize = aDoc->size(ModelAPI_ResultConstruction::group());
- int aGroupSize = aDoc->size(ModelAPI_ResultGroup::group());
- int aFieldSize = aDoc->size(ModelAPI_ResultField::group());
- int aResultSize = aDoc->size(ModelAPI_ResultBody::group());
- setDisplayingByLoop(aDoc, aConstructionSize,
- ModelAPI_ResultConstruction::group(), theDisplayFromScript);
- setDisplayingByLoop(aDoc, aGroupSize, ModelAPI_ResultGroup::group(), theDisplayFromScript);
- setDisplayingByLoop(aDoc, aFieldSize, ModelAPI_ResultField::group(), theDisplayFromScript);
- setDisplayingByLoop(aDoc, aResultSize, ModelAPI_ResultBody::group(), theDisplayFromScript);
+ setDisplayingByLoop(aDoc, aConstructionSize, ModelAPI_ResultConstruction::group(),
+ theDisplayFromScript, aDisplayingId);
+ setDisplayingByLoop(aDoc, aGroupSize, ModelAPI_ResultGroup::group(),
+ theDisplayFromScript, aDisplayingId);
+ setDisplayingByLoop(aDoc, aFieldSize, ModelAPI_ResultField::group(),
+ theDisplayFromScript, aDisplayingId);
+ setDisplayingByLoop(aDoc, aResultSize, ModelAPI_ResultBody::group(),
+ theDisplayFromScript, aDisplayingId);
+ isDoingDisplay = false;
}
} // namespace ModuleBase_Tools