#include <GeomAPI_Face.h>
+#include <ModelAPI_Session.h>
+
#include <ModuleBase_Tools.h>
#include <ModuleBase_Operation.h>
#include <ModuleBase_IPropertyPanel.h>
bool PartSet_WidgetSketchCreator::restoreValue()
{
+ CompositeFeaturePtr aCompFeature =
+ std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+ if (aCompFeature->numberOfSubs() > 0) {
+ FeaturePtr aSubFeature = aCompFeature->subFeature(0);
+ myTextLine->setText(QString::fromStdString(aSubFeature->data()->name()));
+ }
return true;
}
void PartSet_WidgetSketchCreator::activateCustom()
{
- connect(myModule, SIGNAL(operationLaunched()), SLOT(onStarted()));
-
-
- //XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
- //XGUI_Workshop* aWorkshop = aConnector->workshop();
- //XGUI_Displayer* aDisp = aWorkshop->displayer();
-
- //QIntList aModes;
- //aModes << TopAbs_FACE;
- //aDisp->activateObjects(aModes);
- //
- //connect(aWorkshop->selector(), SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
- //activateFilters(myModule->workshop(), true);
+ CompositeFeaturePtr aCompFeature =
+ std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+ if (aCompFeature->numberOfSubs() == 0)
+ connect(myModule, SIGNAL(operationLaunched()), SLOT(onStarted()));
}
void PartSet_WidgetSketchCreator::onStarted()
{
disconnect(myModule, SIGNAL(operationLaunched()), this, SLOT(onStarted()));
- CompositeFeaturePtr aCompFeature = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+ CompositeFeaturePtr aCompFeature =
+ std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
FeaturePtr aSketch = aCompFeature->addFeature("Sketch");
ModuleBase_Operation* anOperation = myModule->createOperation("Sketch");
myModule->sendOperation(anOperation);
}
-void PartSet_WidgetSketchCreator::storeAttributeValue()
-{
-}
-
-void PartSet_WidgetSketchCreator::restoreAttributeValue(const bool theValid)
+bool PartSet_WidgetSketchCreator::focusTo()
{
-}
-
-bool PartSet_WidgetSketchCreator::setSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
-{
- std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face());
- aFace->setImpl(new TopoDS_Shape(thePrs.shape()));
- if (aFace->isPlanar())
- return true;
- //CompositeFeaturePtr aCompFeature = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
- //FeaturePtr aSketch = aCompFeature->addFeature("Sketch");
-
- //ModuleBase_Operation* anOperation = myModule->createOperation("Sketch");
- //anOperation->setFeature(aSketch);
- //myModule->sendOperation(anOperation);
+ CompositeFeaturePtr aCompFeature =
+ std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+ if (aCompFeature->numberOfSubs() == 0)
+ return ModuleBase_ModelWidget::focusTo();
+
+ SessionPtr aMgr = ModelAPI_Session::get();
+ bool aIsOp = aMgr->isOperation();
+ // Open transaction if it was closed before
+ if (!aIsOp)
+ aMgr->startOperation();
+
+ restoreValue();
return false;
-}
-
-bool PartSet_WidgetSketchCreator::setSelection(const QList<ModuleBase_ViewerPrs>& theValues, int& thePosition)
-{
- return true;
}
\ No newline at end of file
virtual ~PartSet_WidgetSketchCreator();
- /// Set the given wrapped value to the current widget
- /// This value should be processed in the widget according to the needs
- /// The method is called by the current operation to process the operation preselection.
- /// It is redefined to do nothing if the plane of the sketch has been already set.
- /// \param theValues the wrapped selection values
- /// \param thePosition an index in the list of values, the values should be get from the index
- virtual bool setSelection(const QList<ModuleBase_ViewerPrs>& theValues, int& thePosition);
-
virtual bool restoreValue();
/// Returns list of widget controls
/// \return a control list
virtual QList<QWidget*> getControls() const;
-protected:
- /// Creates a backup of the current values of the attribute
- /// It should be realized in the specific widget because of different
- /// parameters of the current attribute
- virtual void storeAttributeValue();
-
- /// Creates a backup of the current values of the attribute
- /// It should be realized in the specific widget because of different
- /// parameters of the current attribute
- /// \param theValid a boolean flag, if restore happens for valid parameters
- virtual void restoreAttributeValue(const bool theValid);
-
- /// Fills the attribute with the value of the selected owner
- /// \param theOwner a selected owner
- virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
+ /// Set focus to the first control of the current widget. The focus policy of the control is checked.
+ /// If the widget has the NonFocus focus policy, it is skipped.
+ /// \return the state whether the widget can accept the focus
+ virtual bool focusTo();
+protected:
/// Saves the internal parameters to the given feature
/// \return True in success
virtual bool storeValueCustom() const;