-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// 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
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "SketchSolver_Manager.h"
}
static void featuresOrderedByType(const std::set<ObjectPtr>& theOriginalFeatures,
- IndexedFeatureMap& theOrderedFeatures)
+ IndexedFeatureMap& theOrderedFeatures,
+ CompositeFeaturePtr& theSketch)
{
int aFeatureIndex = 0;
int aConstraintIndex = (int)theOriginalFeatures.size();
for (; aFeatIter != theOriginalFeatures.end(); aFeatIter++) {
std::shared_ptr<SketchPlugin_Feature> aFeature =
std::dynamic_pointer_cast<SketchPlugin_Feature>(*aFeatIter);
- if (aFeature && !aFeature->isMacro() && aFeature->data() && aFeature->data()->isValid()) {
- std::shared_ptr<SketchPlugin_Constraint> aConstraint =
- std::dynamic_pointer_cast<SketchPlugin_Constraint>(aFeature);
- if (aConstraint)
- theOrderedFeatures[++aConstraintIndex] = aFeature;
- else
- theOrderedFeatures[++aFeatureIndex] = aFeature;
+ if (aFeature) {
+ if (!aFeature->isMacro() && aFeature->data() && aFeature->data()->isValid()) {
+ std::shared_ptr<SketchPlugin_Constraint> aConstraint =
+ std::dynamic_pointer_cast<SketchPlugin_Constraint>(aFeature);
+ if (aConstraint)
+ theOrderedFeatures[++aConstraintIndex] = aFeature;
+ else
+ theOrderedFeatures[++aFeatureIndex] = aFeature;
+ }
+ }
+ else {
+ CompositeFeaturePtr aSketch =
+ std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(*aFeatIter);
+ if (aSketch && aSketch->getKind() == SketchPlugin_Sketch::ID())
+ theSketch = aSketch;
}
}
}
// update sketch features only
const std::set<ObjectPtr>& aFeatures = anUpdateMsg->objects();
IndexedFeatureMap anOrderedFeatures;
+ CompositeFeaturePtr aSketchFeature;
// try to keep order as features were created if there are several created features: #2229
if (theMessage->eventID() == aCreatedEvent && aFeatures.size() > 1) {
featuresOrderedByCreation(aFeatures, anOrderedFeatures);
} else { // order is not important, just process features before constraints
- featuresOrderedByType(aFeatures, anOrderedFeatures);
+ featuresOrderedByType(aFeatures, anOrderedFeatures, aSketchFeature);
}
IndexedFeatureMap::iterator aFeat;
for (aFeat = anOrderedFeatures.begin(); aFeat != anOrderedFeatures.end(); aFeat++) {
updateFeature(aFeat->second);
}
+ updateSketch(aSketchFeature);
} else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED)) {
std::shared_ptr<ModelAPI_ObjectMovedMessage> aMoveMsg =
Events_Loop::loop()->flush(anUpdateEvent);
}
+// ============================================================================
+// Function: updateSketch
+// Purpose: update sketch plane in appropriate group
+// ============================================================================
+bool SketchSolver_Manager::updateSketch(const CompositeFeaturePtr& theSketch)
+{
+ if (!theSketch)
+ return true;
+
+ bool isOk = true;
+ std::list<SketchGroupPtr>::const_iterator aGroupIt;
+ for (aGroupIt = myGroups.begin(); aGroupIt != myGroups.end(); ++aGroupIt)
+ if ((*aGroupIt)->getWorkplane() == theSketch) {
+ (*aGroupIt)->updateSketch(theSketch);
+ break;
+ }
+ return isOk;
+}
+
// ============================================================================
// Function: updateFeature
// Purpose: create/update constraint or feature in appropriate group