-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-// File: SketchPlugin_Sketch.cxx
-// Created: 27 Mar 2014
-// Author: Mikhail PONIKAROV
+// Copyright (C) 2014-2017 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<mailto:webmaster.salome@opencascade.com>
+//
#include <Config_PropManager.h>
#include <SketchPlugin_Sketch.h>
#include <SketchPlugin_Feature.h>
+#include <SketchPlugin_Projection.h>
#include <SketchPlugin_SketchEntity.h>
#include <SketchPlugin_Tools.h>
#include <math.h>
#include <vector>
-using namespace std;
-
SketchPlugin_Sketch::SketchPlugin_Sketch()
{
}
if (aFeature) {
if (!aFeature->sketch()) // on load document the back references are missed
aFeature->setSketch(this);
- // do not include the external edges into the result
+ // do not include into the result the external edges with disabled flag "Include into result"
if (aFeature->data()->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID())) {
- if (aFeature->data()->selection(SketchPlugin_SketchEntity::EXTERNAL_ID())->context())
- continue;
+ if (aFeature->data()->selection(SketchPlugin_SketchEntity::EXTERNAL_ID())->context()) {
+ AttributeBooleanPtr aKeepResult =
+ aFeature->boolean(SketchPlugin_Projection::INCLUDE_INTO_RESULT());
+ if (!aKeepResult || !aKeepResult->value())
+ continue;
+ }
}
// do not include the construction entities in the result
if (aFeature->data()->attribute(SketchPlugin_SketchEntity::AUXILIARY_ID())) {
}
// set as current also after it becomes sub to set correctly enabled for other sketch subs
document()->setCurrentFeature(aNew, false);
+
return aNew;
}
void SketchPlugin_Sketch::attributeChanged(const std::string& theID) {
if (theID == SketchPlugin_SketchEntity::EXTERNAL_ID()) {
- std::shared_ptr<GeomAPI_Shape> aSelection =
- data()->selection(SketchPlugin_SketchEntity::EXTERNAL_ID())->value();
- if (aSelection) { // update arguments due to the selection value
+ AttributeSelectionPtr aSelAttr = selection(SketchPlugin_SketchEntity::EXTERNAL_ID());
+ if (aSelAttr->context().get()) { // update arguments due to the selection value
+ std::shared_ptr<GeomAPI_Shape> aSelection = aSelAttr->value();
+ if (!aSelection.get()) aSelection = aSelAttr->context()->shape();
// update the sketch plane
std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(aSelection));
std::shared_ptr<GeomAPI_Pln> aPlane = aFace->getPlane();
theFeature->data()->copyTo(aNewFeature->data());
// external state should not be copied as a new object is an object of the current sketch
if (theFeature->selection(SketchPlugin_SketchEntity::EXTERNAL_ID()).get())
- theFeature->selection(SketchPlugin_SketchEntity::EXTERNAL_ID())->setValue(ResultPtr(),
- GeomShapePtr());
+ aNewFeature->selection(SketchPlugin_SketchEntity::EXTERNAL_ID())->setValue(ResultPtr(),
+ GeomShapePtr());
aNewFeature->data()->setName(aUniqueFeatureName);
// text expressions could block setValue of some attributes
SketchPlugin_Tools::clearExpressions(aNewFeature);