/// The methiod called when widget is deactivated
virtual void deactivate();
- private slots:
- /// Slot which is called on selection event
- void onSelectionChanged();
+// NDS: protected is temporary
+protected slots:
+ /// Slot which is called on selection event
+ // NDS: virtual is temporary
+ virtual void onSelectionChanged();
protected:
/// Update focus after the attribute value change
+ // NDS: has body is temporary
virtual void updateFocus() {};
/// Return the attribute values wrapped in a list of viewer presentations
/// \return a list of viewer presentations, which contains an attribute result and
/// a shape. If the attribute do not uses the shape, it is empty
- virtual QList<ModuleBase_ViewerPrs> getAttributeSelection() const;
+ // NDS: has body is temporary
+ virtual QList<ModuleBase_ViewerPrs> getAttributeSelection() const;
/// Retunrs a list of possible shape types
/// \return a list of shapes
virtual QIntList getShapeTypes() const = 0;
/// Computes and updates name of selected object in the widget
+ // NDS: has body is temporary
virtual void updateSelectionName() {};
/// Store the values to the model attribute of the widget. It casts this attribute to
/// \param theSelectedObject an object
/// \param theShape a selected shape, which is used in the selection attribute
/// \return true if it is succeed
- virtual void setObject(ObjectPtr theSelectedObject, GeomShapePtr theShape) {};
+ virtual void setObject(ObjectPtr theSelectedObject, GeomShapePtr theShape) = 0;
/// The methiod called when widget is activated
virtual void activateCustom();
//setVisibleSelectionControl(true);
}
- else {
- setVisibleSelectionControl(false);
- emit focusOutWidget(this);
- }
+ //else {
+ // setVisibleSelectionControl(false);
+ // emit focusOutWidget(this);
+ //}
}
void PartSet_WidgetSketchCreator::setVisibleSelectionControl(const bool theSelectionControl)
else { // hide current control
if (aWidget == this)
aWidget->setVisible(false);
+ else
+ aWidget->setVisible(true);
}
}
}
return !aHasValueInList;//aHasSub || aHasValueInList;
}
+void PartSet_WidgetSketchCreator::onSelectionChanged()
+{
+ QList<ModuleBase_ViewerPrs> aSelected = getFilteredSelected();
+
+ if (aSelected.size() == 1) { // plane or planar face of not sketch object
+ startSketchOperation();
+ }
+ else if (aSelected.size() > 1) {
+ QList<ModuleBase_ViewerPrs>::const_iterator anIt = aSelected.begin(), aLast = aSelected.end();
+ bool aProcessed;
+ for (; anIt != aLast; anIt++) {
+ ModuleBase_ViewerPrs aValue = *anIt;
+ if (isValidInFilters(aValue))
+ aProcessed = setSelectionCustom(aValue);
+ }
+ if (aProcessed) {
+ emit valuesChanged();
+ updateObject(myFeature);
+ setVisibleSelectionControl(false);
+ emit focusOutWidget(this);
+ }
+ }
+}
+
+//********************************************************************
+void PartSet_WidgetSketchCreator::setObject(ObjectPtr theSelectedObject,
+ GeomShapePtr theShape)
+{
+ std::string anAttributeId = myAttributeListID;
+ DataPtr aData = myFeature->data();
+ AttributePtr anAttribute = aData->attribute(anAttributeId);
+ if (anAttribute.get()) {
+ std::string aType = anAttribute->attributeType();
+ if (aType == ModelAPI_AttributeSelectionList::typeId()) {
+ AttributeSelectionListPtr aSelectionListAttr = aData->selectionList(anAttributeId);
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theSelectedObject);
+ if (!aSelectionListAttr->isInList(aResult, theShape, myIsInValidate))
+ aSelectionListAttr->append(aResult, theShape, myIsInValidate);
+ }
+ }
+}
void PartSet_WidgetSketchCreator::onStarted()
{
disconnect(myModule, SIGNAL(operationLaunched()), this, SLOT(onStarted()));
setVisibleSelectionControl(true);
+}
- /*
+void PartSet_WidgetSketchCreator::startSketchOperation()
+{
// Check that model already has bodies
- XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
+ /*XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
XGUI_Workshop* aWorkshop = aConnector->workshop();
XGUI_Displayer* aDisp = aWorkshop->displayer();
QObjectPtrList aObjList = aDisp->displayedObjects();
break;
}
}
- }
+ }*/
- if (aHasBody) {
+ //if (aHasBody) {
// Launch Sketch operation
CompositeFeaturePtr aCompFeature =
std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
aFOperation->setFeature(aSketch);
myModule->sendOperation(aFOperation);
//connect(anOperation, SIGNAL(aborted()), aWorkshop->operationMgr(), SLOT(abortAllOperations()));
- } else {
+ //}
+ /* else {
// Break current operation
std::string anOperationName = feature()->getKind();
QString aTitle = tr( anOperationName.c_str() );
// if (aCompFeature->numberOfSubs() == 0)
// return ModuleBase_ModelWidget::focusTo();
connect(myModule, SIGNAL(operationLaunched()), SLOT(onStarted()));
+ // we need to call activate here as the widget has no focus accepted controls
+ // if these controls are added here, activate will happens automatically after focusIn()
+ activate();
return true;
}
else {
/// \return a list of shapes
virtual QIntList getShapeTypes() const;
+ /// Store the values to the model attribute of the widget. It casts this attribute to
+ /// the specific type and set the given values
+ /// \param theSelectedObject an object
+ /// \param theShape a selected shape, which is used in the selection attribute
+ /// \return true if it is succeed
+ virtual void setObject(ObjectPtr theSelectedObject, GeomShapePtr theShape);
+
private:
/// Returns true if the selection mode is active. This is when composition feature has no
/// a sub-object and the attribute list is empty
/// \return boolean value
bool isSelectionMode() const;
+protected slots:
+ /// Slot which is called on selection event
+ // NDS: virtual is temporary
+ virtual void onSelectionChanged();
+
private slots:
void onStarted();
void onResumed(ModuleBase_Operation* theOp);
+private:
+ /// Append new Sketch, set the selected plane for the sketch and start Edit operation.
+ void startSketchOperation();
+
private:
std::string myAttributeListID;