]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
2.17. Improved management of overconstraint situation: temporary modification to...
authornds <nds@opencascade.com>
Tue, 9 Feb 2016 08:46:47 +0000 (11:46 +0300)
committerdbv <dbv@opencascade.com>
Tue, 16 Feb 2016 14:04:39 +0000 (17:04 +0300)
It is checked in case of making two lines parallel and perpendicular simultaneously

src/PartSet/PartSet_OverconstraintListener.cpp
src/PartSet/PartSet_icons.qrc
src/PartSet/icons/conflicting_icon.png [new file with mode: 0755]
src/SketcherPrs/CMakeLists.txt
src/SketcherPrs/SketcherPrs_SymbolPrs.cpp
src/SketcherPrs/SketcherPrs_SymbolPrs.h
src/SketcherPrs/icons/conflicting_icon.png [new file with mode: 0755]

index a9c5dc2adc16b8fd0340c5eeeff1ec164db9cb34..b4468f395540ce02f1f318ddfd379193cd48b78c 100755 (executable)
@@ -51,16 +51,6 @@ void PartSet_OverconstraintListener::processEvent(
 {
 
 #ifdef DEBUG_FEATURE_OVERCONSTRAINT_LISTENER
-
-  /*
-  anIt = theConflictingObjects.begin();
-  aLast = theConflictingObjects.end();
-
-  QStringList anInfo;
-  for (; anIt != aLast; ++anIt) {
-    anInfo.append(ModuleBase_Tools::objectInfo((*anIt)));
-  }
-  QString anInfoStr = anInfo.join(";\n");*/
   bool isRepaired = theMessage->eventID() == Events_Loop::eventByName(EVENT_SOLVER_REPAIRED);
   qDebug(QString("PartSet_OverconstraintListener::processEvent:\n %1").arg(isRepaired ? "REPAIRED" : "FAILED").toStdString().c_str());
 #endif
@@ -103,7 +93,7 @@ bool PartSet_OverconstraintListener::updateConflictingObjects(
   for (anIt = myConflictingObjects.begin(), aLast = myConflictingObjects.end() ; anIt != aLast; anIt++) {
     ObjectPtr anObject = *anIt;
     if (theConflictingObjects.find(anObject) == theConflictingObjects.end()) { // it is not found
-      //setConflictingObject(anObject, false);
+      setConflictingObject(anObject, false);
       aModifiedObjects.insert(anObject);
     }
   }
@@ -117,7 +107,7 @@ bool PartSet_OverconstraintListener::updateConflictingObjects(
   for (anIt = theConflictingObjects.begin(), aLast = theConflictingObjects.end() ; anIt != aLast; anIt++) {
     ObjectPtr anObject = *anIt;
     if (myConflictingObjects.find(anObject) == myConflictingObjects.end()) { // it is not found
-      //setConflictingObject(anObject, true);
+      setConflictingObject(anObject, true);
       aModifiedObjects.insert(anObject);
       myConflictingObjects.insert(anObject);
     }
@@ -149,13 +139,10 @@ void PartSet_OverconstraintListener::redisplayObjects(
   aLoop->flush(EVENT_DISP);*/
 
   XGUI_Displayer* aDisplayer = workshop()->displayer();
-  //QObjectPtrList aObjects = aDisplayer->displayedObjects();
   bool aHidden;
   std::set<ObjectPtr>::const_iterator anIt = theObjects.begin(), aLast = theObjects.end();
   for (; anIt != aLast; anIt++) {
     ObjectPtr anObject = *anIt;
-  //foreach(ObjectPtr aObj, aObjects) {
-    //TODO: replace by redisplay event.
     aHidden = !anObject->data() || !anObject->data()->isValid() || 
                anObject->isDisabled() || (!anObject->isDisplayed());
     if (!aHidden)
@@ -167,8 +154,6 @@ void PartSet_OverconstraintListener::redisplayObjects(
 void PartSet_OverconstraintListener::setConflictingObject(const ObjectPtr& theObject,
                                                           const bool theConflicting)
 {
-  return;
-
   AISObjectPtr anAISObject;
   GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
 
@@ -182,8 +167,8 @@ void PartSet_OverconstraintListener::setConflictingObject(const ObjectPtr& theOb
       if (!anAISIO.IsNull()) {
         if (!Handle(SketcherPrs_SymbolPrs)::DownCast(anAISIO).IsNull()) {
           Handle(SketcherPrs_SymbolPrs) aPrs = Handle(SketcherPrs_SymbolPrs)::DownCast(anAISIO);
-          //if (!aPrs.IsNull())
-          //  aPrs->setConflictingConstraint(theConflicting);
+          if (!aPrs.IsNull())
+            aPrs->SetConflictingConstraint(theConflicting);
         }
       }
     }
index 30e6b1b354dee44d9b0012aed510a2a72d6e7735..1741c89466599d1197aa331a22de75b20dc636b3 100644 (file)
@@ -59,6 +59,7 @@
      <file>icons/tangent.png</file>
      <file>icons/fillet.png</file>
      <file>icons/coincedence.png</file>
+     <file>icons/conflicting_icon.png</file>
      <file>icons/mirror.png</file>
      <file>icons/translate.png</file>
      <file>icons/translate_32x32.png</file>
diff --git a/src/PartSet/icons/conflicting_icon.png b/src/PartSet/icons/conflicting_icon.png
new file mode 100755 (executable)
index 0000000..58a187e
Binary files /dev/null and b/src/PartSet/icons/conflicting_icon.png differ
index 148f332ad5a0c8f6831a1110ff1bc487dbb7934f..4d5692902a76c3b40a22dc200795b96627827932 100644 (file)
@@ -77,6 +77,7 @@ SET(PROJECT_PICTURES
     icons/equal.png
     icons/tangent.png
     icons/mirror.png
+    icons/conflicting_icon.png
     icons/rotate.png
     icons/translate.png
 )
index b66ecbd035211b72fca1adfb8ef989cb2e022c7f..d4d0df3cee43eb7916c819d32fa5fde35c08032e 100644 (file)
@@ -249,7 +249,7 @@ std::map<const char*, Handle(Image_AlienPixMap)> SketcherPrs_SymbolPrs::myIconsM
 
 SketcherPrs_SymbolPrs::SketcherPrs_SymbolPrs(ModelAPI_Feature* theConstraint, 
                                              const std::shared_ptr<GeomAPI_Ax3>& thePlane)
- : AIS_InteractiveObject(), myConstraint(theConstraint), myPlane(thePlane)
+ : AIS_InteractiveObject(), myConstraint(theConstraint), myPlane(thePlane), myIsConflicting(false)
 {
   SetAutoHilight(Standard_False);
 }
@@ -267,6 +267,24 @@ SketcherPrs_SymbolPrs::~SketcherPrs_SymbolPrs()
 
 Handle(Image_AlienPixMap) SketcherPrs_SymbolPrs::icon()
 {
+  if (myIsConflicting) {
+    if (myErrorIcon.IsNull()) {
+      char* aEnv = getenv("NEWGEOM_ROOT_DIR");
+      if (aEnv != NULL) {
+        TCollection_AsciiString aFile(aEnv);
+        aFile+=FSEP;
+        aFile+="resources";
+        aFile += FSEP;
+        aFile += "conflicting_icon.png";
+        Handle(Image_AlienPixMap) aPixMap = new Image_AlienPixMap();
+        if (aPixMap->Load(aFile)) {
+          myErrorIcon = aPixMap;
+        }
+      }
+    }
+    return myErrorIcon;
+  }
+
   if (myIconsMap.count(iconName()) == 1) {
     return myIconsMap[iconName()];
   }
@@ -412,6 +430,15 @@ void SketcherPrs_SymbolPrs::ComputeSelection(const Handle(SelectMgr_Selection)&
   }
 }
 
+void SketcherPrs_SymbolPrs::SetConflictingConstraint(const bool& theConflicting)
+{
+  if (myIsConflicting != theConflicting) {
+    myIsConflicting = theConflicting;
+    Handle(Image_AlienPixMap) anIcon = icon();
+    if (!anIcon.IsNull())
+      myAspect->SetMarkerImage(new Graphic3d_MarkerImage(anIcon));
+  }
+}
 
 void SketcherPrs_SymbolPrs::Render(const Handle(OpenGl_Workspace)& theWorkspace) const
 {
index ee88f55bc82818ef0b99e6f3c566274440d7446d..56fc52770f1a1f6dd22fdad8307809c6652ef756 100644 (file)
@@ -62,6 +62,12 @@ public:
   /// Return array of points where symbols will be placed
   const Handle(Graphic3d_ArrayOfPoints)& pointsArray() const { return myPntArray; }
 
+  /// Set state of the presentation, in case of conflicting state, the icon of the presentation is
+  /// visualized in error color. The state is stored in an internal field, so should be changed when
+  /// constraint become not conflicting
+  /// \param theConflicting a state
+  Standard_EXPORT void SetConflictingConstraint(const bool& theConflicting);
+
   /// Render of the presentation
   /// \param theWorkspace is OpenGl workspace
   void Render(const Handle(OpenGl_Workspace)& theWorkspace) const;
@@ -146,6 +152,10 @@ private:
   mutable Handle(OpenGl_VertexBuffer) myVboAttribs;
 
   Select3D_EntitySequence mySPoints;
+
+  bool myIsConflicting; /// state if the presentation is visualized in error state
+  Handle(Image_AlienPixMap) myErrorIcon;
+  Handle(Graphic3d_MarkerImage) myErrorImage;
 };
 
 #endif
\ No newline at end of file
diff --git a/src/SketcherPrs/icons/conflicting_icon.png b/src/SketcherPrs/icons/conflicting_icon.png
new file mode 100755 (executable)
index 0000000..58a187e
Binary files /dev/null and b/src/SketcherPrs/icons/conflicting_icon.png differ