ModelAPI_AttributeReference>(data()->attribute(FeaturesPlugin_Extrusion::FACE_ID()));
if (!aFaceRef)
return;
+ boost::shared_ptr<GeomAPI_Shape> aFace;
boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = boost::dynamic_pointer_cast<
ModelAPI_ResultConstruction>(aFaceRef->value());
- if (!aConstr)
- return;
- boost::shared_ptr<GeomAPI_Shape> aFace = aConstr->shape();
- if (!aFace)
+ if (aConstr) {
+ aFace = aConstr->shape();
+ }
+ if (!aFace) {
+ // Check for body
+ boost::shared_ptr<ModelAPI_ResultBody> aBody = boost::dynamic_pointer_cast<
+ ModelAPI_ResultBody>(aFaceRef->value());
+ if (aBody)
+ aFace = aBody->shape();
+ }
+ if (!aFace)
return;
double aSize = data()->real(FeaturesPlugin_Extrusion::SIZE_ID())->value();
ModuleBase_WidgetPoint2D* that = (ModuleBase_WidgetPoint2D*) this;
bool isBlocked = that->blockSignals(true);
- double aX = myXSpin->value();
- double aY = myYSpin->value();
aPoint->setValue(myXSpin->value(), myYSpin->value());
updateObject(myFeature);
that->blockSignals(isBlocked);
AttributeDoublePtr anAttr_Value = boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
aData->attribute(SketchPlugin_Constraint::VALUE()));
- if (!anAttr_Value->isInitialized()) {
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint_A = getFeaturePoint(
- aData, SketchPlugin_Constraint::ENTITY_A());
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint_B = getFeaturePoint(
- aData, SketchPlugin_Constraint::ENTITY_B());
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint_A = getFeaturePoint(
+ aData, SketchPlugin_Constraint::ENTITY_A());
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint_B = getFeaturePoint(
+ aData, SketchPlugin_Constraint::ENTITY_B());
- if (aPoint_A && aPoint_B) { // both points
- anAttr_Value->setValue(aPoint_A->pnt()->distance(aPoint_B->pnt()));
- } else {
- if (!aPoint_A && aPoint_B) { //Line and point
- boost::shared_ptr<SketchPlugin_Line> aLine = getFeatureLine(
- aData, SketchPlugin_Constraint::ENTITY_A());
- if (aLine)
- anAttr_Value->setValue(aLine->distanceToPoint(aPoint_B->pnt()));
- } else if (aPoint_A && !aPoint_B) { // Point and line
- boost::shared_ptr<SketchPlugin_Line> aLine = getFeatureLine(
- aData, SketchPlugin_Constraint::ENTITY_B());
- if (aLine)
- anAttr_Value->setValue(aLine->distanceToPoint(aPoint_A->pnt()));
- }
+ if (aPoint_A && aPoint_B) { // both points
+ anAttr_Value->setValue(aPoint_A->pnt()->distance(aPoint_B->pnt()));
+ } else {
+ if (!aPoint_A && aPoint_B) { //Line and point
+ boost::shared_ptr<SketchPlugin_Line> aLine = getFeatureLine(
+ aData, SketchPlugin_Constraint::ENTITY_A());
+ if (aLine)
+ anAttr_Value->setValue(aLine->distanceToPoint(aPoint_B->pnt()));
+ } else if (aPoint_A && !aPoint_B) { // Point and line
+ boost::shared_ptr<SketchPlugin_Line> aLine = getFeatureLine(
+ aData, SketchPlugin_Constraint::ENTITY_B());
+ if (aLine)
+ anAttr_Value->setValue(aLine->distanceToPoint(aPoint_A->pnt()));
}
}
}
void SketchPlugin_ConstraintLength::execute()
{
- if (data()->attribute(SketchPlugin_Constraint::ENTITY_A())->isInitialized()
- && !data()->attribute(SketchPlugin_Constraint::VALUE())->isInitialized()) {
-
- boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = boost::dynamic_pointer_cast<
- ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
- FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
- if (aFeature) {
- // set length value
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 = boost::dynamic_pointer_cast<
- GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::START_ID()));
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 = boost::dynamic_pointer_cast<
- GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::END_ID()));
-
- double aLenght = aPoint1->pnt()->distance(aPoint2->pnt());
-
- boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = boost::dynamic_pointer_cast<
- ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
- aValueAttr->setValue(aLenght);
- }
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
+ if (aFeature) {
+ // set length value
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::START_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::END_ID()));
+
+ double aLenght = aPoint1->pnt()->distance(aPoint2->pnt());
+
+ boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
+ aValueAttr->setValue(aLenght);
}
}
void SketchPlugin_ConstraintRadius::execute()
{
- if (data()->attribute(SketchPlugin_Constraint::ENTITY_A())->isInitialized()
- && !data()->attribute(SketchPlugin_Constraint::VALUE())->isInitialized()) {
-
- boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = boost::dynamic_pointer_cast<
- ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
- FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
- if (aFeature) {
- double aRadius = 0;
- boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
- if (aFeature->getKind() == SketchPlugin_Circle::ID()) {
- AttributeDoublePtr anAttribute = boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
- aData->attribute(SketchPlugin_Circle::RADIUS_ID()));
- if (anAttribute)
- aRadius = anAttribute->value();
- } else if (aFeature->getKind() == SketchPlugin_Arc::ID()) {
- boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = boost::dynamic_pointer_cast<
- GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::CENTER_ID()));
- boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr = boost::dynamic_pointer_cast<
- GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::START_ID()));
- if (aCenterAttr && aStartAttr)
- aRadius = aCenterAttr->pnt()->distance(aStartAttr->pnt());
- }
- boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = boost::dynamic_pointer_cast<
- ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
- aValueAttr->setValue(aRadius);
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
+ if (aFeature) {
+ double aRadius = 0;
+ boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
+ if (aFeature->getKind() == SketchPlugin_Circle::ID()) {
+ AttributeDoublePtr anAttribute = boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
+ aData->attribute(SketchPlugin_Circle::RADIUS_ID()));
+ if (anAttribute)
+ aRadius = anAttribute->value();
+ } else if (aFeature->getKind() == SketchPlugin_Arc::ID()) {
+ boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::CENTER_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::START_ID()));
+ if (aCenterAttr && aStartAttr)
+ aRadius = aCenterAttr->pnt()->distance(aStartAttr->pnt());
}
+ boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
+ aValueAttr->setValue(aRadius);
}
}
<feature id="SketchConstraintCoincidence" title="Coincident" tooltip="Create constraint for the coincidence of two points" internal="1"/>
<feature id="SketchConstraintDistance" title="Distance" tooltip="Create constraint for the distance from a point to an object">
- <label title="Select point and another object (point or point on line) between which to calculate distance" tooltip="Select point and another feature (point or point on line) between which to calculate distance"/>
- <feature_or_attribute_selector id="ConstraintEntityA" label="First object" tooltip="Select an point in the viewer">
+ <label title="Select objects for distance difinition. Following objects can be accepted: point, line end point, line, center of circle or arc."/>
+ <feature_or_attribute_selector id="ConstraintEntityA" label="First object" tooltip="Select point, line end point, line, center of circle or arc.">
<validator id="SketchPlugin_ResultPointValidator"/>
<validator id="SketchPlugin_ResultLineValidator"/>
</feature_or_attribute_selector>
- <feature_or_attribute_selector id="ConstraintEntityB" label="Last object" tooltip="Select an point in the viewer">
+ <feature_or_attribute_selector id="ConstraintEntityB" label="Last object" tooltip="Select point, line end point, line, center of circle or arc.">
<validator id="SketchPlugin_ResultPointValidator"/>
<validator id="SketchPlugin_ResultLineValidator"/>
<validator id="SketchPlugin_DistanceAttrValidator" parameters="ConstraintEntityA"/>
aAction = new QAction(QIcon(":pictures/eye_pencil.png"), tr("Show"), this);
addAction("SHOW_CMD", aAction);
+ aAction = new QAction(QIcon(":pictures/eye_pencil.png"), tr("Show only"), this);
+ addAction("SHOW_ONLY_CMD", aAction);
+
aAction = new QAction(QIcon(":pictures/eye_pencil_closed.png"), tr("Hide"), this);
addAction("HIDE_CMD", aAction);
}
} else {
if (aDisplayer->isVisible(aObject))
aMenu->addAction(action("HIDE_CMD"));
- else
+ else {
aMenu->addAction(action("SHOW_CMD"));
+ }
+ aMenu->addAction(action("SHOW_ONLY_CMD"));
}
} else { // If feature is 0 the it means that selected root object (document)
if (aMgr->currentDocument() != aMgr->rootDocument())
if (hasResult) {
aMenu->addAction(action("SHOW_CMD"));
aMenu->addAction(action("HIDE_CMD"));
+ aMenu->addAction(action("SHOW_ONLY_CMD"));
}
if (hasFeature)
aMenu->addAction(action("DELETE_CMD"));
updateViewer();
}
-/*void XGUI_Displayer::EraseAll(const bool isUpdateViewer)
+void XGUI_Displayer::eraseAll(const bool isUpdateViewer)
{
- Handle(AIS_InteractiveContext) ic = AISContext();
-
- AIS_ListOfInteractive aList;
- ic->DisplayedObjects(aList);
- AIS_ListIteratorOfListOfInteractive anIter(aList);
- for (; anIter.More(); anIter.Next()) {
- if ((anIter.Value()->DynamicType() == STANDARD_TYPE(AIS_Trihedron)))
- continue;
-
- // erase an object
- Handle(AIS_InteractiveObject) anIO = anIter.Value();
- ic->Erase(anIO, false);
+ Handle(AIS_InteractiveContext) ic = AISContext();
+
+ ResultToAISMap::iterator aIt;
+ for (aIt = myResult2AISObjectMap.begin(); aIt != myResult2AISObjectMap.end(); aIt++) {
+ // erase an object
+ boost::shared_ptr<GeomAPI_AISObject> aAISObj = (*aIt).second;
+ Handle(AIS_InteractiveObject) anIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+ if (!anIO.IsNull())
+ ic->Remove(anIO, false);
+ }
+ myResult2AISObjectMap.clear();
+ if (isUpdateViewer)
+ updateViewer();
}
- myResult2AISObjectMap.clear();
- if (isUpdateViewer)
- updateViewer();
- }*/
void XGUI_Displayer::eraseDeletedResults(const bool isUpdateViewer)
{
/// Erase all presentations
/// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
- //void EraseAll(const bool isUpdateViewer = true);
+ void eraseAll(const bool isUpdateViewer = true);
/// Erase AIS interactive objects, which has an empty feature in the internal map
/// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
void XGUI_OperationMgr::onCommitOperation()
{
ModuleBase_Operation* anOperation = currentOperation();
+ anOperation->onWidgetActivated(NULL);
if (anOperation)
anOperation->commit();
}
/**\class XGUI_OperationMgr
* \ingroup GUI
- * \brief Operation manager. Servers to manupulate to the workshop operations. Contains a stack
- * of started operations. In simple case, if only one operration is started, the stack contains
+ * \brief Operation manager. Servers to manipulate to the workshop operations. Contains a stack
+ * of started operations. In simple case, if only one operation is started, the stack contains
* one operation. It is possible for some kind of operations to start them above already
- * started one. In that case, the previous active operation becames suspended, a new one - active.
+ * started one. In that case, the previous active operation becomes suspended, a new one - active.
* The new operation is added to the top of the stack. Then it is finished, it is removed from
* the stack and the previous operation is activated.
*/
showObjects(aObjects, true);
else if (theId == "HIDE_CMD")
showObjects(aObjects, false);
+ else if (theId == "SHOW_ONLY_CMD")
+ showOnlyObjects(aObjects);
}
//**************************************************************
myDisplayer->updateViewer();
}
+//**************************************************************
+void XGUI_Workshop::showOnlyObjects(const QList<ObjectPtr>& theList)
+{
+ myDisplayer->eraseAll(false);
+ showObjects(theList, true);
+}
+
+
//**************************************************************
void XGUI_Workshop::updateCommandsOnViewSelection()
{
//! Show the given features in 3d Viewer
void showObjects(const QList<ObjectPtr>& theList, bool isVisible);
+ //! Show the given features in 3d Viewer
+ void showOnlyObjects(const QList<ObjectPtr>& theList);
+
ModuleBase_IModule* module() const
{
return myModule;