tooltip="Distance from selected face to plane"
default="0" />
</case>
- <case id="PlaneByGeneralEquation" title="By palne equation parameters">
- <doublevalue id="A"
- label="A:"
- tooltip="The A parameter from general plane equation (Ax+By+Cz+D=0)"
- default="0" />
- <doublevalue id="B"
- label="B:"
- tooltip="The B parameter from general plane equation (Ax+By+Cz+D=0)"
- default="0" />
- <doublevalue id="C"
- label="C:"
- tooltip="The C parameter from general plane equation (Ax+By+Cz+D=0)"
- default="0" />
- <doublevalue id="D"
- label="D:"
- tooltip="The D parameter from general plane equation (Ax+By+Cz+D=0)"
- default="0" />
- </case>
</switch>
</source>
else {
bool isOk;
double aDefValue = QString::fromStdString(getDefaultValue()).toDouble(&isOk);
- ModuleBase_Tools::setSpinValue(mySpinBox, isOk ? aDefValue : 0.0);
- storeValueCustom();
+ // reset the value just if there is a default value definition in the XML definition
+ // if the double value can not be found by the default value, do nothing
+ if (isOk) {
+ ModuleBase_Tools::setSpinValue(mySpinBox, isOk ? aDefValue : 0.0);
+ storeValueCustom();
+ }
}
}
DataPtr aData = myFeature->data();
AttributeDoublePtr aReal = aData->real(attributeID());
aReal->setValue(mySpinBox->value());
- std::string aTextRepr;
+ std::string aTextRepr = aReal->text();
if (mySpinBox->hasVariable()) {
aTextRepr = mySpinBox->text().toStdString();
}
//********************************************************************
bool ModuleBase_WidgetMultiSelector::setSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
{
- ObjectPtr anObject = myWorkshop->selection()->getSelectableObject(thePrs.owner());
- ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
+ ResultPtr aResult;
+ if (!thePrs.owner().IsNull()) {
+ ObjectPtr anObject = myWorkshop->selection()->getSelectableObject(thePrs.owner());
+ aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
+ }
+ else {
+ aResult = std::dynamic_pointer_cast<ModelAPI_Result>(thePrs.object());
+ }
+
if (myFeature) {
// We can not select a result of our feature
else {
GeomShapePtr aShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
aShape->setImpl(new TopoDS_Shape(aTDSShape));
- aSelectionListAttr->append(aResult, aShape);
+ // We can not select a result of our feature
+ if (aShape->isEqual(aResult->shape()))
+ aSelectionListAttr->append(aResult, GeomShapePtr());
+ else
+ aSelectionListAttr->append(aResult, aShape);
}
return true;
}
}
} else {
AttributeSelectionPtr aSelectAttr = aData->selection(attributeID());
- ResultPtr aBody = std::dynamic_pointer_cast<ModelAPI_Result>(theSelectedObject);
- if (aSelectAttr && aBody && (theShape.get() != NULL)) {
- aSelectAttr->setValue(aBody, theShape);
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theSelectedObject);
+ if (aSelectAttr) {
+ aSelectAttr->setValue(aResult, theShape);
isChanged = true;
}
}
int aSuperCount = ModuleBase_PagedContainer::addPage(thePage, theName, theCaseId);
myCombo->addItem(theName);
int aResultCount = myCombo->count();
- if (aResultCount == 1)
+ if (aResultCount == 2)
myCombo->show();
QFrame* aFrame = dynamic_cast<QFrame*>(thePage);
aFrame->setFrameShape(QFrame::Box);
aSelection->selectedShapes(aShapeList, aObjectsList);
bool aIsDetach = false;
+ // Check that selected shape is not attribute
+ // if at least a one shape is attribute then we can not add auxiliary item
+ bool hasAttribute = false;
+ if (aShapeList.Extent() > 0) {
+ NCollection_List<TopoDS_Shape>::Iterator aIt(aShapeList);
+ std::list<ObjectPtr>::const_iterator aItObj;
+ TopoDS_Shape aShape;
+ ObjectPtr aObj;
+ ResultPtr aResult;
+ for (aItObj = aObjectsList.cbegin(); aIt.More(); aIt.Next(), aItObj++) {
+ aShape = aIt.Value();
+ aObj = (*aItObj);
+ aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
+ if (aResult.get() != NULL) {
+ if (!aShape.IsEqual(aResult->shape()->impl<TopoDS_Shape>())) {
+ hasAttribute = true;
+ break;
+ }
+ }
+ }
+ }
+
if (aShapeList.Extent() == 1) {
TopoDS_Shape aShape = aShapeList.First();
if (aShape.ShapeType() == TopAbs_VERTEX) {
}
}
}
- if ((!aIsDetach) && (aObjectsList.size() > 0)) {
+ QObjectPtrList aObjects = aSelection->selectedPresentations();
+ if ((!aIsDetach) && (aObjects.size() > 0)) {
bool hasFeature = false;
FeaturePtr aFeature;
- std::list<ObjectPtr>::const_iterator aIt;
- ObjectPtr aObject;
- for (aIt = aObjectsList.cbegin(); aIt != aObjectsList.cend(); ++aIt) {
- aObject = (*aIt);
+ foreach (ObjectPtr aObject, aObjects) {
aFeature = ModelAPI_Feature::feature(aObject);
if (aFeature.get() != NULL) {
hasFeature = true;
}
}
- if (hasFeature)
+ if (hasFeature && (!hasAttribute))
theMenu->addAction(theStdActions["DELETE_CMD"]);
}
+ if (hasAttribute)
+ return true;
bool isAuxiliary;
if (canSetAuxiliary(isAuxiliary)) {
QAction* anAction = action("AUXILIARY_CMD");
bool isUseTransaction = false;
// 1. change auxiliary type of a created feature
if (PartSet_SketcherMgr::isNestedCreateOperation(anOperation) &&
- PartSet_SketcherMgr::isEntityOperation(anOperation) ) {
+ PartSet_SketcherMgr::isEntity(anOperation->id().toStdString()) ) {
anObjects.append(anOperation->feature());
}
else {
QObjectPtrList anObjects;
// 1. change auxiliary type of a created feature
if (PartSet_SketcherMgr::isNestedCreateOperation(anOperation) &&
- PartSet_SketcherMgr::isEntityOperation(anOperation) ) {
+ PartSet_SketcherMgr::isEntity(anOperation->id().toStdString()) ) {
anObjects.append(anOperation->feature());
}
else {
ModuleBase_ISelection* aSelection = myModule->workshop()->selection();
anObjects = aSelection->selectedPresentations();
}
- anEnabled = anObjects.size() > 0;
bool isNotAuxiliaryFound = false;
if (anObjects.size() > 0) {
QObjectPtrList::const_iterator anIt = anObjects.begin(), aLast = anObjects.end();
for (; anIt != aLast && !isNotAuxiliaryFound; anIt++) {
FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt);
- if (aFeature.get() != NULL) {
+ if ((aFeature.get() != NULL) && PartSet_SketcherMgr::isEntity(aFeature->getKind())) {
+ anEnabled = true;
std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
if (aSketchFeature.get() != NULL) {
return theOperation && !theOperation->isEditOperation() && isNestedSketchOperation(theOperation);
}
-bool PartSet_SketcherMgr::isEntityOperation(ModuleBase_Operation* theOperation)
+bool PartSet_SketcherMgr::isEntity(const std::string& theId)
{
- std::string aId = theOperation ? theOperation->id().toStdString() : "";
-
- return (aId == SketchPlugin_Line::ID()) ||
- (aId == SketchPlugin_Point::ID()) ||
- (aId == SketchPlugin_Arc::ID()) ||
- (aId == SketchPlugin_Circle::ID());
+ return (theId == SketchPlugin_Line::ID()) ||
+ (theId == SketchPlugin_Point::ID()) ||
+ (theId == SketchPlugin_Arc::ID()) ||
+ (theId == SketchPlugin_Circle::ID());
}
bool PartSet_SketcherMgr::isDistanceOperation(ModuleBase_Operation* theOperation)
/// Returns whether the current operation is a sketch entity - line, point, arc or circle
/// \param the operation
/// \return a boolean value
- static bool isEntityOperation(ModuleBase_Operation* theOperation);
+ static bool isEntity(const std::string& theId);
/// Returns whether the current operation is a sketch distance - lenght, distance or radius
/// \param the operation
<feature id="SketchConstraintParallel" title="Parallel" tooltip="Create constraint defining two parallel lines" icon=":icons/parallel.png">
<sketch_shape_selector id="ConstraintEntityA"
label="First line" tooltip="Select a line" shape_types="edge">
- <validator id="GeomValidators_Edge" parameters="line"/>
- <validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityB"/>
+ <validator id="GeomValidators_Edge" parameters="line"/>
+ <validator id="PartSet_DifferentObjects"/>
+ <validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityB"/>
</sketch_shape_selector>
<sketch_shape_selector id="ConstraintEntityB" label="Second line" tooltip="Select a line"
label="Second object" tooltip="Select line or arc" shape_types="edge">
</sketch_shape_selector>
- <doublevalue_editor label="Value" tooltip="Fillet radius" id="ConstraintValue" min="0">
+ <doublevalue label="Value" tooltip="Fillet radius" id="ConstraintValue" min="0">
<validator id="GeomValidators_Positive"/>
- </doublevalue_editor>
+ </doublevalue>
<validator id="PartSet_FilletSelection"/>
</feature>