std::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
aRes->setImpl(new TopoDS_Shape(aFaceBuilder.Face()));
return aRes;
-}
\ No newline at end of file
+}
// do noth use naming if selected shape is result shape itself, but not sub-shape
TDF_Label aSelLab = selectionLabel();
- if (theContext->shape().get() && theContext->shape()->isEqual(theSubShape)) {
- aSelLab.ForgetAllAttributes(true);
- TDataStd_UAttribute::Set(aSelLab, kSIMPLE_REF_ID);
- } else {
- aSelLab.ForgetAttribute(kSIMPLE_REF_ID);
- if (theContext->groupName() == ModelAPI_ResultBody::group())
+ aSelLab.ForgetAttribute(kSIMPLE_REF_ID);
+ if (theContext->groupName() == ModelAPI_ResultBody::group()) {
+ // do not select the whole shape for body:it is already must be in the data framework
+ if (theContext->shape().get() && theContext->shape()->isEqual(theSubShape)) {
+ aSelLab.ForgetAllAttributes(true);
+ TDataStd_UAttribute::Set(aSelLab, kSIMPLE_REF_ID);
+ } else {
selectBody(theContext, theSubShape);
- else if (theContext->groupName() == ModelAPI_ResultConstruction::group())
- selectConstruction(theContext, theSubShape);
+ }
+ } else if (theContext->groupName() == ModelAPI_ResultConstruction::group()) {
+ selectConstruction(theContext, theSubShape);
}
+ myIsInitialized = true;
std::string aSelName = namingName();
if(!aSelName.empty())
//selectSubShape("EDGE", "Extrusion_1/TopFace|Extrusion_1/LateralFace_1");
//selectSubShape("EDGE", "Sketch_1/Edge_6");
#endif
- myIsInitialized = true;
owner()->data()->sendAttributeUpdated(this);
}
}
}
} else { // simple construction element: the selected is that needed
+ selectConstruction(aContext, aContext->shape());
owner()->data()->sendAttributeUpdated(this);
return true;
}
else if (theShape.ShapeType() == TopAbs_VERTEX) aName<<"Vertex";
if (theRefs.IsNull()) {
- aName<<"_"<<theID;
+ aName<<theID;
} else { // make a compisite name from all sub-elements indexes: "1_2_3_4"
TColStd_MapIteratorOfPackedMapOfInteger aRef(theRefs->GetMap());
for(; aRef.More(); aRef.Next()) {
- aName<<"_"<<aRef.Key();
+ aName<<"-"<<aRef.Key();
}
}
FeaturePtr aContextFeature = theContext->document()->feature(theContext);
CompositeFeaturePtr aComposite =
std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aContextFeature);
+ const TopoDS_Shape& aSubShape = theSubShape->impl<TopoDS_Shape>();
if (!aComposite || aComposite->numberOfSubs() == 0) {
- return; // saving of context is enough: result construction contains exactly the needed shape
+ // saving of context is enough: result construction contains exactly the needed shape
+ TNaming_Builder aBuilder(selectionLabel());
+ aBuilder.Generated(aSubShape);
+ aMyDoc->addNamingName(selectionLabel(), theContext->data()->name());
+ TDataStd_Name::Set(selectionLabel(), theContext->data()->name().c_str());
+ return;
}
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(owner()->data());
TDF_Label aLab = myRef.myRef->Label();
// identify the reuslts of sub-object of the composite by edges
- const TopoDS_Shape& aSubShape = theSubShape->impl<TopoDS_Shape>();
// save type of the selected shape in integer attribute
TopAbs_ShapeEnum aShapeType = aSubShape.ShapeType();
TDataStd_Integer::Set(aLab, (int)aShapeType);
return TDF_Label(); // not found
return aFind->second;
}
+
+ResultPtr Model_Document::findByName(const std::string theName)
+{
+ NCollection_DataMap<TDF_Label, FeaturePtr>::Iterator anObjIter(myObjs);
+ for(; anObjIter.More(); anObjIter.Next()) {
+ FeaturePtr& aFeature = anObjIter.ChangeValue();
+ if (!aFeature) // may be on close
+ continue;
+ const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = aFeature->results();
+ std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
+ for (; aRIter != aResults.cend(); aRIter++) {
+ if (aRIter->get() && (*aRIter)->data() && (*aRIter)->data()->isValid() &&
+ (*aRIter)->data()->name() == theName) {
+ return *aRIter;
+ }
+ }
+ }
+ // not found
+ return ResultPtr();
+}
void addNamingName(const TDF_Label theLabel, std::string theName);
//! Returns the label, keeper of the name for the topological naming needs
TDF_Label findNamingName(std::string theName);
+ //! Returns the result by name of the result (names of results must be unique, used for naming
+ //! selection by name.
+ ResultPtr findByName(const std::string theName);
protected:
//**********************************************
void NewGeom_SalomeViewer::enableSelection(bool isEnabled)
{
- mySelector->viewer()->enableSelection(isEnabled);
- // there is a fix for a black-colored window
- // the viewer rubber band is valid if the values delta is less than 1
- // TODO: remove this row after moving to SALOME 7.5
- //mySelector->viewer()->setInteractionStyle(isEnabled ? SUIT_ViewModel::STANDARD
- // : SUIT_ViewModel::KEY_FREE);
+ //mySelector->viewer()->enableSelection(isEnabled);
+ // The enableSelection() in SALOME 7.5 cause of forced Viewer update(we have blinking)
+ // After this is corrected, the first row should be recommented, the last - removed
+ mySelector->viewer()->setInteractionStyle(isEnabled ? SUIT_ViewModel::STANDARD
+ : SUIT_ViewModel::KEY_FREE);
}
//**********************************************
get2dPoint(theWnd, theEvent, myCurX, myCurY);
myDragDone = false;
- aWorkshop->viewer()->enableMultiselection(false);
launchEditing();
} else if (isSketchOpe && isEditing) {
myIsDragging = true;
get2dPoint(theWnd, theEvent, myCurX, myCurY);
myDragDone = false;
- aWorkshop->viewer()->enableMultiselection(false);
// This is necessary in order to finalize previous operation
QApplication::processEvents();
aWorkshop->viewer()->enableSelection(myPreviousSelectionEnabled);
myIsDragging = false;
if (myDragDone) {
- aViewer->enableMultiselection(true);
//aOp->commit();
myFeature2AttributeMap.clear();
return;
}
}
- if (!aViewer->isMultiSelectionEnabled()) {
- aViewer->enableMultiselection(true);
- }
}
void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
// 4. the features and attributes modification(move)
for (; anIt != aLast; anIt++) {
FeaturePtr aFeature = anIt.key();
- AttributePtr anAttr;
AttributeList anAttributes = anIt.value();
- if (!anAttributes.empty()) {
- anAttr = anAttributes.first();
- }
// Process selection by attribute: the priority to the attribute
- if (anAttr.get() != NULL) {
- std::string aAttrId = anAttr->id();
- DataPtr aData = aFeature->data();
- if (aData.get() != NULL) {
- std::shared_ptr<GeomDataAPI_Point2D> aPoint =
- std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(aAttrId));
- if (aPoint.get() != NULL) {
- bool isImmutable = aPoint->setImmutable(true);
- aPoint->move(dX, dY);
- ModelAPI_EventCreator::get()->sendUpdated(aFeature, aMoveEvent);
- aPoint->setImmutable(isImmutable);
+ if (!anAttributes.empty()) {
+ AttributeList::const_iterator anAttIt = anAttributes.begin(), anAttLast = anAttributes.end();
+ for (; anAttIt != anAttLast; anAttIt++) {
+ AttributePtr anAttr = *anAttIt;
+ if (anAttr.get() == NULL)
+ continue;
+ std::string aAttrId = anAttr->id();
+ DataPtr aData = aFeature->data();
+ if (aData.get() != NULL) {
+ std::shared_ptr<GeomDataAPI_Point2D> aPoint =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(aAttrId));
+ if (aPoint.get() != NULL) {
+ bool isImmutable = aPoint->setImmutable(true);
+ aPoint->move(dX, dY);
+ ModelAPI_EventCreator::get()->sendUpdated(aFeature, aMoveEvent);
+ aPoint->setImmutable(isImmutable);
+ }
}
}
} else {
std::shared_ptr<GeomAPI_Pln> aPlane;
std::shared_ptr<ModelAPI_Data> aData = theSketch->data();
- std::shared_ptr<GeomDataAPI_Point> anOrigin = std::dynamic_pointer_cast<GeomDataAPI_Point>(
- aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
- std::shared_ptr<GeomDataAPI_Dir> aNormal = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
- aData->attribute(SketchPlugin_Sketch::NORM_ID()));
- if (aNormal && anOrigin) {
- double adX = aNormal->x();
- double adY = aNormal->y();
- double adZ = aNormal->z();
-
- if ( (adX != 0) || (adY != 0) || (adZ != 0) ) { // Plane is valid
- double aX = anOrigin->x();
- double aY = anOrigin->y();
- double aZ = anOrigin->z();
- gp_Pln aPln(gp_Pnt(aX, aY, aZ), gp_Dir(adX, adY, adZ));
- double aA, aB, aC, aD;
- aPln.Coefficients(aA, aB, aC, aD);
- aPlane = std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(aA, aB, aC, aD));
+ if (aData) {
+ std::shared_ptr<GeomDataAPI_Point> anOrigin = std::dynamic_pointer_cast<GeomDataAPI_Point>(
+ aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
+ std::shared_ptr<GeomDataAPI_Dir> aNormal = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ aData->attribute(SketchPlugin_Sketch::NORM_ID()));
+ if (aNormal && anOrigin) {
+ double adX = aNormal->x();
+ double adY = aNormal->y();
+ double adZ = aNormal->z();
+
+ if ( (adX != 0) || (adY != 0) || (adZ != 0) ) { // Plane is valid
+ double aX = anOrigin->x();
+ double aY = anOrigin->y();
+ double aZ = anOrigin->z();
+ gp_Pln aPln(gp_Pnt(aX, aY, aZ), gp_Dir(adX, adY, adZ));
+ double aA, aB, aC, aD;
+ aPln.Coefficients(aA, aB, aC, aD);
+ aPlane = std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(aA, aB, aC, aD));
+ }
}
}
return aPlane;
std::dynamic_pointer_cast<SketchPlugin_Sketch>(theFeature);
if (aSketchFeature.get()) {
std::shared_ptr<ModelAPI_Data> aData = aSketchFeature->data();
- std::shared_ptr<GeomDataAPI_Dir> aNormal =
- std::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::NORM_ID()));
- aHasSketchPlane = aNormal && !(aNormal->x() == 0 && aNormal->y() == 0 && aNormal->z() == 0);
-
- aMsg->setState(SketchPlugin_Point::ID(), aHasSketchPlane);
- aMsg->setState(SketchPlugin_Line::ID(), aHasSketchPlane);
- aMsg->setState(SketchPlugin_Circle::ID(), aHasSketchPlane);
- aMsg->setState(SketchPlugin_Arc::ID(), aHasSketchPlane);
- aMsg->setState(SketchPlugin_ConstraintCoincidence::ID(), aHasSketchPlane);
- aMsg->setState(SketchPlugin_ConstraintDistance::ID(), aHasSketchPlane);
- aMsg->setState(SketchPlugin_ConstraintLength::ID(), aHasSketchPlane);
- aMsg->setState(SketchPlugin_ConstraintParallel::ID(), aHasSketchPlane);
- aMsg->setState(SketchPlugin_ConstraintPerpendicular::ID(), aHasSketchPlane);
- aMsg->setState(SketchPlugin_ConstraintRadius::ID(), aHasSketchPlane);
- aMsg->setState(SketchPlugin_ConstraintRigid::ID(), aHasSketchPlane);
+ if (aData) {
+ std::shared_ptr<GeomDataAPI_Dir> aNormal =
+ std::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::NORM_ID()));
+ aHasSketchPlane = aNormal && !(aNormal->x() == 0 && aNormal->y() == 0 && aNormal->z() == 0);
+
+ aMsg->setState(SketchPlugin_Point::ID(), aHasSketchPlane);
+ aMsg->setState(SketchPlugin_Line::ID(), aHasSketchPlane);
+ aMsg->setState(SketchPlugin_Circle::ID(), aHasSketchPlane);
+ aMsg->setState(SketchPlugin_Arc::ID(), aHasSketchPlane);
+ aMsg->setState(SketchPlugin_ConstraintCoincidence::ID(), aHasSketchPlane);
+ aMsg->setState(SketchPlugin_ConstraintDistance::ID(), aHasSketchPlane);
+ aMsg->setState(SketchPlugin_ConstraintLength::ID(), aHasSketchPlane);
+ aMsg->setState(SketchPlugin_ConstraintParallel::ID(), aHasSketchPlane);
+ aMsg->setState(SketchPlugin_ConstraintPerpendicular::ID(), aHasSketchPlane);
+ aMsg->setState(SketchPlugin_ConstraintRadius::ID(), aHasSketchPlane);
+ aMsg->setState(SketchPlugin_ConstraintRigid::ID(), aHasSketchPlane);
+ }
}
return aMsg;
}