From: vsv Date: Wed, 5 Nov 2014 13:35:23 +0000 (+0300) Subject: Issie #204: Size of Fixed constraint depends on object size X-Git-Tag: V_0.5~37^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6538b6539abf93cf24183c7cfe8a5800a464178f;p=modules%2Fshaper.git Issie #204: Size of Fixed constraint depends on object size --- diff --git a/src/GeomAPI/GeomAPI_AISObject.cpp b/src/GeomAPI/GeomAPI_AISObject.cpp index de00d5a43..ec84c8c34 100644 --- a/src/GeomAPI/GeomAPI_AISObject.cpp +++ b/src/GeomAPI/GeomAPI_AISObject.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -226,20 +227,32 @@ void GeomAPI_AISObject::createFixed(boost::shared_ptr theShape, { Handle(Geom_Plane) aPlane = new Geom_Plane(thePlane->impl()); Handle(AIS_InteractiveObject) anAIS = impl(); + TopoDS_Shape aShape = theShape->impl(); + Handle(AIS_FixRelation) aFixPrs; if (anAIS.IsNull()) { - Handle(AIS_FixRelation) aFixPrs = - new AIS_FixRelation(theShape->impl(), 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()); + 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.); + } + } } diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index 65e2bb1a5..c813f05e5 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -235,7 +235,7 @@ void ModuleBase_WidgetShapeSelector::onSelectionChanged() return; } setObject(aObject, aShape); - activateSelection(false); + //activateSelection(false); emit focusOutWidget(this); } } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp b/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp index 1b02335df..847ecfc86 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp @@ -5,6 +5,7 @@ #include "SketchPlugin_ConstraintRigid.h" #include +#include #include #include @@ -60,9 +61,9 @@ AISObjectPtr SketchPlugin_ConstraintRigid::getAISObject(AISObjectPtr thePrevious anAIS->createFixed(aShape, aPlane); // Set color from preferences - //std::vector aRGB = Config_PropManager::color("Visualization", "perpendicular_color", - // PERPENDICULAR_COLOR); - //anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]); + std::vector 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 diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRigid.h b/src/SketchPlugin/SketchPlugin_ConstraintRigid.h index 8816ea4b6..7dc6ef8e9 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintRigid.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintRigid.h @@ -10,6 +10,8 @@ #include #include +#define FIXING_COLOR "#ffff00" + /** \class SketchPlugin_ConstraintRigid * \ingroup DataModel * \brief Feature for creation of a new constraint which defines immovable object diff --git a/src/SketchPlugin/SketchPlugin_Plugin.cpp b/src/SketchPlugin/SketchPlugin_Plugin.cpp index cf3cf283b..077685776 100644 --- a/src/SketchPlugin/SketchPlugin_Plugin.cpp +++ b/src/SketchPlugin/SketchPlugin_Plugin.cpp @@ -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)