]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Conflicting coincidence constraint is visualized in black color.
authornds <nds@opencascade.com>
Tue, 7 Jun 2016 05:56:59 +0000 (08:56 +0300)
committernds <nds@opencascade.com>
Fri, 10 Jun 2016 06:50:54 +0000 (09:50 +0300)
src/ModuleBase/ModuleBase_FilterValidated.cpp
src/PartSet/PartSet_Module.cpp
src/SketcherPrs/SketcherPrs_Coincident.cpp
src/SketcherPrs/SketcherPrs_Coincident.h

index bb56ba1491318356fcf5f9d62a5ebfd7983c01ca..097eb60cb82d4e7dc7acd52169c3ade72c17f5bd 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "ModuleBase_FilterValidated.h"
 #include "ModuleBase_IWorkshop.h"
+#include "ModuleBase_IViewer.h"
 
 #include <ModuleBase_IModule.h>
 #include <ModuleBase_IPropertyPanel.h>
 IMPLEMENT_STANDARD_HANDLE(ModuleBase_FilterValidated, SelectMgr_Filter);
 IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_FilterValidated, SelectMgr_Filter);
 
-//#define DEBUG_CURRENT_SELECTION
-
 Standard_Boolean ModuleBase_FilterValidated::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
 {
   bool aValid = true;
   ModuleBase_Operation* anOperation = myWorkshop->module()->currentOperation();
   if (anOperation) {
-#ifdef DEBUG_CURRENT_SELECTION
-    QString aPrefix = "ModuleBase_FilterValidated::IsOk: ";
-    QList<ModuleBase_ViewerPrsPtr> aSelected = myWorkshop->selection()->getSelected(ModuleBase_ISelection::Viewer);
-    QList<ModuleBase_ViewerPrsPtr>::const_iterator anIt = aSelected.begin(), aLast = aSelected.end();
-    QStringList anInfo;
-    ModuleBase_ViewerPrsPtr aPrs;
-    for (; anIt != aLast; anIt++) {
-      aPrs = (*anIt);
-      if (!aPrs.get())
-        continue;
+    ModuleBase_IViewer* aViewer = myWorkshop->viewer();
+    Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
 
-      //GeomShapePtr aShape = aPrs->shape();
-      ObjectPtr anObject = aPrs->object();
-      QString anObjectInfo = anObject.get() ? ModuleBase_Tools::objectInfo(anObject) : "";
-      anInfo.append(anObjectInfo);
-    }
-    QString anInfoStr = anInfo.join(";\t");
-    qDebug(QString("%1: %2, %3").arg(aPrefix).arg(anInfo.size()).arg(anInfoStr).toStdString().c_str());
-#endif
+    ModuleBase_Tools::selectionInfo(aContext, "ModuleBase_FilterValidated::IsOk");
 
     ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
     ModuleBase_ModelWidget* aCurrentWidget = aPanel->preselectionWidget();
index f53edf79b0b553ce577e56f3702a4375b11d7592..37754a8b16c9009df7e7ec62425097164df1c62f 100755 (executable)
@@ -80,6 +80,7 @@
 #include <SketchPlugin_ConstraintRadius.h>
 
 #include <SketcherPrs_SymbolPrs.h>
+#include <SketcherPrs_Coincident.h>
 #include <SketcherPrs_Tools.h>
 
 #include <Events_Loop.h>
@@ -968,6 +969,14 @@ bool PartSet_Module::customisePresentation(ResultPtr theResult, AISObjectPtr the
             aPrs->SetConflictingConstraint(isConflicting, aColor);
             aCustomized = true;
           }
+        } else if (!Handle(SketcherPrs_Coincident)::DownCast(anAISIO).IsNull()) {
+          Handle(SketcherPrs_Coincident) aPrs = Handle(SketcherPrs_Coincident)::DownCast(anAISIO);
+          if (!aPrs.IsNull()) {
+            std::vector<int> aColor;
+            myOverconstraintListener->getConflictingColor(aColor);
+            aPrs->SetConflictingConstraint(isConflicting, aColor);
+            aCustomized = true;
+          }
         }
       }
     }
index e7ae5a144043c45ace700547fe039cdccc6fb8e8..c4539bf63f4faf837bc4aa47da53f5d75ad0b8d9 100644 (file)
@@ -35,7 +35,7 @@ IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Coincident, AIS_InteractiveObject);
 SketcherPrs_Coincident::SketcherPrs_Coincident(ModelAPI_Feature* theConstraint, 
                                                const std::shared_ptr<GeomAPI_Ax3>& thePlane) 
 : AIS_InteractiveObject(), myConstraint(theConstraint), mySketcherPlane(thePlane),
-  myPoint(gp_Pnt(0.0, 0.0, 0.0))
+  myPoint(gp_Pnt(0.0, 0.0, 0.0)), myIsConflicting(false)
 {
 }
 
@@ -82,10 +82,11 @@ void SketcherPrs_Coincident::Compute(const Handle(PrsMgr_PresentationManager3d)&
   }
   // Create the presentation as a combination of standard point markers
 
+  bool aValid = !myIsConflicting;
   // The external yellow contour
   aPtA->SetType(Aspect_TOM_RING3);
   aPtA->SetScale(2.);
-  aPtA->SetColor(Quantity_NOC_YELLOW);
+  aPtA->SetColor(aValid ? Quantity_NOC_YELLOW : Quantity_NOC_BLACK);
 
   Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
   aGroup->SetPrimitivesAspect(aPtA);
@@ -128,3 +129,23 @@ void SketcherPrs_Coincident::SetColor(const Quantity_Color &aCol)
   hasOwnColor=Standard_True;
   myOwnColor=aCol;
 }
+
+void SketcherPrs_Coincident::SetConflictingConstraint(const bool& theConflicting,
+                                                     const std::vector<int>& theColor)
+{
+  myIsConflicting = theConflicting;
+
+    /*if (theConflicting)
+  {
+    if (!myAspect.IsNull())
+      myAspect->SetColor (Quantity_Color (theColor[0] / 255., theColor[1] / 255., theColor[2] / 255.,
+                          Quantity_TOC_RGB));
+    myIsConflicting = true;
+  }
+  else
+  {
+    if (!myAspect.IsNull())
+      myAspect->SetColor (Quantity_Color (1.0, 1.0, 0.0, Quantity_TOC_RGB));
+    myIsConflicting = false;
+  }*/
+}
index 082016c81b7ae69347531ee13db790898e419eb5..d041cac9d8210d592913215627afa1a60fbb9ee6 100644 (file)
@@ -38,6 +38,13 @@ public:
   /// \param aColor a color name
   Standard_EXPORT virtual void SetColor(const Quantity_NameOfColor aColor);
 
+  /// 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
+  /// \param theColor a color for conflicting object
+  Standard_EXPORT void SetConflictingConstraint(const bool& theConflicting, const std::vector<int>& theColor);
+
   /// Returns true if the constraint feature arguments are correcly filled to build AIS presentation
   /// \param theConstraint a constraint feature
   /// \param thePlane a coordinate plane of current sketch
@@ -64,6 +71,7 @@ private:
   ModelAPI_Feature* myConstraint;
   std::shared_ptr<GeomAPI_Ax3> mySketcherPlane;
   gp_Pnt myPoint;
+  bool myIsConflicting; /// state if the presentation is visualized in error state
 };