From: vsv Date: Wed, 10 Jun 2015 14:44:01 +0000 (+0300) Subject: Create Extrusion Cut X-Git-Tag: V_1.3.0~255 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=be98c135eadf34424cf100e3fdcedbeaca712885;p=modules%2Fshaper.git Create Extrusion Cut --- diff --git a/src/FeaturesPlugin/extrusioncut_widget.xml b/src/FeaturesPlugin/extrusioncut_widget.xml index 80f1b714c..6a974761f 100755 --- a/src/FeaturesPlugin/extrusioncut_widget.xml +++ b/src/FeaturesPlugin/extrusioncut_widget.xml @@ -5,8 +5,7 @@ - + tooltip="Create or edit a sketch">/> send(aMsg); + SessionPtr aMgr = ModelAPI_Session::get(); if (myIsEditing) { - SessionPtr aMgr = ModelAPI_Session::get(); DocumentPtr aDoc = aMgr->activeDocument(); bool aIsOp = aMgr->isOperation(); if (!aIsOp) @@ -205,7 +205,7 @@ void ModuleBase_Operation::abort() // because abort removes the feature and activated filters should not check it propertyPanel()->cleanContent(); - ModelAPI_Session::get()->abortOperation(); + aMgr->abortOperation(); emit stopped(); // the viewer update should be unblocked in order to avoid the features blinking before they are // hidden diff --git a/src/PartSet/PartSet_WidgetSketchCreator.cpp b/src/PartSet/PartSet_WidgetSketchCreator.cpp index ffccda73a..ac1d449d8 100644 --- a/src/PartSet/PartSet_WidgetSketchCreator.cpp +++ b/src/PartSet/PartSet_WidgetSketchCreator.cpp @@ -14,6 +14,8 @@ #include +#include + #include #include #include @@ -61,6 +63,12 @@ QList PartSet_WidgetSketchCreator::getControls() const bool PartSet_WidgetSketchCreator::restoreValue() { + CompositeFeaturePtr aCompFeature = + std::dynamic_pointer_cast(myFeature); + if (aCompFeature->numberOfSubs() > 0) { + FeaturePtr aSubFeature = aCompFeature->subFeature(0); + myTextLine->setText(QString::fromStdString(aSubFeature->data()->name())); + } return true; } @@ -71,26 +79,18 @@ bool PartSet_WidgetSketchCreator::storeValueCustom() const void PartSet_WidgetSketchCreator::activateCustom() { - connect(myModule, SIGNAL(operationLaunched()), SLOT(onStarted())); - - - //XGUI_ModuleConnector* aConnector = dynamic_cast(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(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(myFeature); + CompositeFeaturePtr aCompFeature = + std::dynamic_pointer_cast(myFeature); FeaturePtr aSketch = aCompFeature->addFeature("Sketch"); ModuleBase_Operation* anOperation = myModule->createOperation("Sketch"); @@ -98,30 +98,19 @@ void PartSet_WidgetSketchCreator::onStarted() 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 aFace(new GeomAPI_Face()); - aFace->setImpl(new TopoDS_Shape(thePrs.shape())); - if (aFace->isPlanar()) - return true; - //CompositeFeaturePtr aCompFeature = std::dynamic_pointer_cast(myFeature); - //FeaturePtr aSketch = aCompFeature->addFeature("Sketch"); - - //ModuleBase_Operation* anOperation = myModule->createOperation("Sketch"); - //anOperation->setFeature(aSketch); - //myModule->sendOperation(anOperation); + CompositeFeaturePtr aCompFeature = + std::dynamic_pointer_cast(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& theValues, int& thePosition) -{ - return true; } \ No newline at end of file diff --git a/src/PartSet/PartSet_WidgetSketchCreator.h b/src/PartSet/PartSet_WidgetSketchCreator.h index 827e6d95c..80e45b496 100644 --- a/src/PartSet/PartSet_WidgetSketchCreator.h +++ b/src/PartSet/PartSet_WidgetSketchCreator.h @@ -29,36 +29,18 @@ Q_OBJECT 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& theValues, int& thePosition); - virtual bool restoreValue(); /// Returns list of widget controls /// \return a control list virtual QList 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;