From: vsv Date: Tue, 23 Sep 2014 08:58:49 +0000 (+0400) Subject: Issue #138: Fixed problem with lines X-Git-Tag: V_0.4.4~32^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d2c8ff5b06c91eb9074ec1aba9e8ba9b54f0c953;p=modules%2Fshaper.git Issue #138: Fixed problem with lines --- diff --git a/src/PartSet/PartSet_Listener.cpp b/src/PartSet/PartSet_Listener.cpp index be392c009..43709df50 100644 --- a/src/PartSet/PartSet_Listener.cpp +++ b/src/PartSet/PartSet_Listener.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -28,7 +29,7 @@ PartSet_Listener::PartSet_Listener(PartSet_Module* theModule) : myModule(theModule) { Events_Loop* aLoop = Events_Loop::loop(); - //aLoop->registerListener(this, aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY)); + aLoop->registerListener(this, aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED)); } @@ -51,12 +52,27 @@ void PartSet_Listener::processEvent(const boost::shared_ptr& the boost::shared_ptr aUpdMsg = boost::dynamic_pointer_cast(theMessage); std::set aFeatures = aUpdMsg->objects(); + + PartSet_OperationSketch* aSketchOp = + dynamic_cast(myModule->workshop()->operationMgr()->currentOperation()); + std::set::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end(); for (; anIt != aLast; anIt++) { - aDisplayer->deactivate(*anIt); - FeaturePtr aFeature = boost::dynamic_pointer_cast(*anIt); - if (aFeature) - myModule->activateFeature(aFeature, false); + ObjectPtr aObj = (*anIt); + aDisplayer->deactivate(aObj); + boost::shared_ptr aSketch = + boost::dynamic_pointer_cast(aObj); + if (aSketch) // Activate sketcher for planes selection + myModule->activateFeature(aSketch, false); + // If current operation is Sketch then there is no active sketching operation + // and possible the object was created by Redo operatgion + else if (aSketchOp) { + XGUI_Displayer* aDisplayer = myModule->workshop()->displayer(); + // Very possible it is not displayed + aDisplayer->display(aObj, false); + std::list aModes = aSketchOp->getSelectionModes(aObj); + aDisplayer->activateInLocalContext(aObj, aModes, false); + } } } else if (aType == EVENT_OBJECT_DELETED) { diff --git a/src/PartSet/PartSet_OperationSketchBase.cpp b/src/PartSet/PartSet_OperationSketchBase.cpp index 398293c61..9dd3141eb 100644 --- a/src/PartSet/PartSet_OperationSketchBase.cpp +++ b/src/PartSet/PartSet_OperationSketchBase.cpp @@ -50,20 +50,16 @@ std::list PartSet_OperationSketchBase::subFeatures() const std::list PartSet_OperationSketchBase::getSelectionModes(ObjectPtr theFeature) const { + //TODO: Define position of selection modes definition std::list aModes; - //FeaturePtr aFeature = boost::dynamic_pointer_cast(theFeature); - //if (aFeature) { - // if (PartSet_Tools::isConstraintFeature(aFeature->getKind())) { - // aModes.clear(); - // aModes.push_back(AIS_DSM_Text); - // aModes.push_back(AIS_DSM_Line); - // return aModes; - // } - //} - aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX)); - aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE)); - aModes.push_back(AIS_DSM_Text); - aModes.push_back(AIS_DSM_Line); + FeaturePtr aFeature = boost::dynamic_pointer_cast(theFeature); + if (aFeature && PartSet_Tools::isConstraintFeature(aFeature->getKind())) { + aModes.push_back(AIS_DSM_Text); + aModes.push_back(AIS_DSM_Line); + } else { + aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX)); + aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE)); + } return aModes; } FeaturePtr PartSet_OperationSketchBase::createFeature(const bool theFlushMessage) diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp index d62098dff..555f0abfe 100644 --- a/src/SketchPlugin/SketchPlugin_Validators.cpp +++ b/src/SketchPlugin/SketchPlugin_Validators.cpp @@ -22,7 +22,7 @@ bool SketchPlugin_DistanceAttrValidator::isValid(const FeaturePtr& theFeature, // If the object is not a line then it is accepted const ModelAPI_ResultValidator* aLineValidator = dynamic_cast(aFactory->validator("SketchPlugin_ResultLine")); - if (aLineValidator && (!aLineValidator->isValid(theObject))) + if (!aLineValidator->isValid(theObject)) return true; // If it is a line then we have to check that first attribute id not a line