]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issie #204: Size of Fixed constraint depends on object size
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 5 Nov 2014 13:35:23 +0000 (16:35 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 5 Nov 2014 13:35:23 +0000 (16:35 +0300)
src/GeomAPI/GeomAPI_AISObject.cpp
src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp
src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp
src/SketchPlugin/SketchPlugin_ConstraintRigid.h
src/SketchPlugin/SketchPlugin_Plugin.cpp

index de00d5a436b33a88144ec9e07bca6a0b11ce77f5..ec84c8c3460660c9974f0f190773700aff4f613e 100644 (file)
@@ -15,6 +15,7 @@
 #include <Geom_Plane.hxx>
 #include <TopoDS_Shape.hxx>
 #include <Quantity_NameOfColor.hxx>
+#include <BRepBndLib.hxx>
 
 #include <AIS_InteractiveObject.hxx>
 #include <AIS_LengthDimension.hxx>
@@ -226,20 +227,32 @@ void GeomAPI_AISObject::createFixed(boost::shared_ptr<GeomAPI_Shape> theShape,
 {
   Handle(Geom_Plane) aPlane = new Geom_Plane(thePlane->impl<gp_Pln>());
   Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
+  TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
+  Handle(AIS_FixRelation) aFixPrs;
   if (anAIS.IsNull()) {
-    Handle(AIS_FixRelation) aFixPrs = 
-      new AIS_FixRelation(theShape->impl<TopoDS_Shape>(), aPlane);
+    aFixPrs = new AIS_FixRelation(aShape, aPlane);
 
     setImpl(new Handle(AIS_InteractiveObject)(aFixPrs));
   } else {
-    Handle(AIS_PerpendicularRelation) aFixPrs = 
-      Handle(AIS_PerpendicularRelation)::DownCast(anAIS);
+    aFixPrs = Handle(AIS_FixRelation)::DownCast(anAIS);
     if (!aFixPrs.IsNull()) {
-      aFixPrs->SetFirstShape(theShape->impl<TopoDS_Shape>());
+      aFixPrs->SetFirstShape(aShape);
       aFixPrs->SetPlane(aPlane);
       aFixPrs->Redisplay(Standard_True);
     }
   }
+  if (!aFixPrs.IsNull()) {
+    Bnd_Box aBox;
+    BRepBndLib::Add(aShape, aBox);
+    double aXmin, aXmax, aYmin, aYmax, aZmin, aZmax;
+    aBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
+    gp_Pnt aXYZ1(aXmin, aXmax, aYmin);
+    gp_Pnt aXYZ2(aXmax, aYmax, aZmax);
+    double aDist = aXYZ1.Distance(aXYZ2);
+    if (aDist > Precision::Confusion()) {
+      aFixPrs->SetArrowSize(aDist/8.);
+    }
+  }
 }
 
 
index 65e2bb1a5bce4dd163be7d8b60176d09e40bab32..c813f05e5b59ef7ca1cda200f19344f2870c02fe 100644 (file)
@@ -235,7 +235,7 @@ void ModuleBase_WidgetShapeSelector::onSelectionChanged()
         return;
     }
     setObject(aObject, aShape);
-    activateSelection(false);
+    //activateSelection(false);
     emit focusOutWidget(this);
   }
 }
index 1b02335dffd69fe730f98ee3c8f62e476ecfb920..847ecfc86238c86c59afe562b3d7b1adb2151727 100644 (file)
@@ -5,6 +5,7 @@
 #include "SketchPlugin_ConstraintRigid.h"
 
 #include <ModelAPI_ResultConstruction.h>
+#include <Config_PropManager.h>
 
 #include <GeomDataAPI_Point2D.h>
 #include <GeomAlgoAPI_PointBuilder.h>
@@ -60,9 +61,9 @@ AISObjectPtr SketchPlugin_ConstraintRigid::getAISObject(AISObjectPtr thePrevious
   anAIS->createFixed(aShape, aPlane);
 
   // Set color from preferences
-  //std::vector<int> aRGB = Config_PropManager::color("Visualization", "perpendicular_color",
-  //                                                  PERPENDICULAR_COLOR);
-  //anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
+  std::vector<int> aRGB = Config_PropManager::color("Visualization", "fixing_color",
+                                                    FIXING_COLOR);
+  anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
 
   return anAIS;
 }
\ No newline at end of file
index 8816ea4b632d9658bb38748db79b24e0a3e3fade..7dc6ef8e9771ed44ca74e2959e066c0b9053a798 100644 (file)
@@ -10,6 +10,8 @@
 #include <SketchPlugin_Sketch.h>
 #include <list>
 
+#define FIXING_COLOR "#ffff00"
+
 /** \class SketchPlugin_ConstraintRigid
  *  \ingroup DataModel
  *  \brief Feature for creation of a new constraint which defines immovable object
index cf3cf283b9e6780efd3f882697d3a9c4182b00ef..07768577649ec2cd8d3a8c974c111350f987817e 100644 (file)
@@ -58,6 +58,8 @@ SketchPlugin_Plugin::SketchPlugin_Plugin()
                                    Config_Prop::Color, LENGTH_COLOR);
   Config_PropManager::registerProp("Visualization", "radius_color", "Radius color",
                                    Config_Prop::Color, RADIUS_COLOR);
+  Config_PropManager::registerProp("Visualization", "fixing_color", "Fixing color",
+                                   Config_Prop::Color, FIXING_COLOR);
 }
 
 FeaturePtr SketchPlugin_Plugin::createFeature(string theFeatureID)