-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File: SketcherPrs_Angle.cpp
-// Created: 20 August 2015
-// Author: Vitaly SMETANNIKOV
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
#include <ModelAPI_Tools.h>
#include <ModelAPI_AttributeString.h>
if (!myIsActive)
return;
+ FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+ std::string aFeatureName = aFeature->data()->name();
+
if (myConflictingObjects.find(theObject) != myConflictingObjects.end()) {
theColor = Config_PropManager::color("Visualization", "sketch_overconstraint_color");
}
void PartSet_OverconstraintListener::processEvent(
const std::shared_ptr<Events_Message>& theMessage)
{
- if (!myIsActive)
- return;
+ // #2271 open document: if sketch has confilcting elements, solver sends message with the
+ // elements by opening the document. Sketch is not active, but an internal container should
+ // be updated. So, we should not check whether the listener is active here
+ //if (!myIsActive)
+ // return;
#ifdef DEBUG_FEATURE_OVERCONSTRAINT_LISTENER
bool isRepaired = theMessage->eventID() == Events_Loop::eventByName(EVENT_SOLVER_REPAIRED);
std::set<ObjectPtr> aModifiedObjects;
PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
CompositeFeaturePtr aSketch = aModule->sketchMgr()->activeSketch();
+
+ // check the sketch in the message and the active sketch are the same
+ std::shared_ptr<ModelAPI_SolverFailedMessage> anErrorMsg =
+ std::dynamic_pointer_cast<ModelAPI_SolverFailedMessage>(theMessage);
+ if (aSketch && anErrorMsg && !anErrorMsg->objects().empty()) {
+ ObjectPtr anObject = *anErrorMsg->objects().begin();
+ CompositeFeaturePtr aSketchFromMsg =
+ std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(anObject);
+ if (!aSketchFromMsg || aSketchFromMsg != aSketch)
+ aSketch = CompositeFeaturePtr();
+ }
+
if (aSketch.get()) {
- for (int i = 0; i < aSketch->numberOfSubs(); i++) {
+ int aNumberOfSubs = aSketch->numberOfSubs();
+ for (int i = 0; i < aNumberOfSubs; i++) {
FeaturePtr aFeature = aSketch->subFeature(i);
aModifiedObjects.insert(aFeature); // is necessary to redisplay presentations
std::list<ResultPtr> aResults = aFeature->results();
(anOperation);
if (aFOperation) {
FeaturePtr aFeature = aFOperation->feature();
- if (aFeature.get())
+ // data valid is necessary if the feature has been already deleted
+ // (e.g. Esc of Lenght if lenght value is modified)
+ if (aFeature.get() && aFeature->data()->isValid())
aCurrentFeatureName = aFeature->data()->name();
}
}