X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_OperationSketchBase.cpp;h=d8cd8ec7e860324884ff529f4daa330cc5282783;hb=add875fff5ce228a4914fcc323fdb911a1042b21;hp=2b83d306f3efbe8ab6305e866c7c4be9a7648195;hpb=d0350421b47740df5540b8165ac7643657cccf66;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_OperationSketchBase.cpp b/src/PartSet/PartSet_OperationSketchBase.cpp index 2b83d306f..d8cd8ec7e 100644 --- a/src/PartSet/PartSet_OperationSketchBase.cpp +++ b/src/PartSet/PartSet_OperationSketchBase.cpp @@ -3,11 +3,21 @@ // Author: Natalia ERMOLAEVA #include +#include +#include -#include -#include +#include +#include +#include +#include #include +#include +#include + +#include +#include +#include #ifdef _DEBUG #include @@ -15,9 +25,8 @@ using namespace std; -PartSet_OperationSketchBase::PartSet_OperationSketchBase(const QString& theId, - QObject* theParent) -: ModuleBase_Operation(theId, theParent) +PartSet_OperationSketchBase::PartSet_OperationSketchBase(const QString& theId, QObject* theParent) + : ModuleBase_Operation(theId, theParent) { } @@ -25,64 +34,88 @@ PartSet_OperationSketchBase::~PartSet_OperationSketchBase() { } -boost::shared_ptr PartSet_OperationSketchBase::preview( - boost::shared_ptr theFeature) const +boost::shared_ptr PartSet_OperationSketchBase::preview(FeaturePtr theFeature) { - boost::shared_ptr aFeature = - boost::dynamic_pointer_cast(theFeature); - if (!aFeature) { // if it is reference to a object feature - boost::shared_ptr anObj = - boost::dynamic_pointer_cast(theFeature); - if (anObj) - aFeature = boost::dynamic_pointer_cast(anObj->featureRef()); + boost::shared_ptr aFeature = boost::dynamic_pointer_cast< + SketchPlugin_Feature>(theFeature); + if (aFeature) { + ResultPtr aRes = aFeature->firstResult(); + ResultBodyPtr aBody = boost::dynamic_pointer_cast(aRes); + if (aBody) + return aBody->shape(); } - if (!aFeature) - return boost::shared_ptr(); - return aFeature->preview(); + return boost::shared_ptr(); } -std::map, boost::shared_ptr > - PartSet_OperationSketchBase::subPreview() const +std::list PartSet_OperationSketchBase::subFeatures() const { - return std::map, boost::shared_ptr >(); + return std::list(); } -std::list PartSet_OperationSketchBase::getSelectionModes(boost::shared_ptr theFeature) const -{ - std::list aModes; - aModes.push_back(TopAbs_VERTEX); - aModes.push_back(TopAbs_EDGE); - return aModes; -} -boost::shared_ptr PartSet_OperationSketchBase::createFeature(const bool theFlushMessage) +FeaturePtr PartSet_OperationSketchBase::createFeature(const bool theFlushMessage) { - boost::shared_ptr aFeature = ModuleBase_Operation::createFeature(theFlushMessage); - if (aFeature) - emit featureConstructed(aFeature, FM_Activation); - return aFeature; + ModuleBase_Operation::createFeature(theFlushMessage); + if (myFeature) + emit featureConstructed(myFeature, FM_Activation); + return myFeature; } - -void PartSet_OperationSketchBase::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected) +void PartSet_OperationSketchBase::mousePressed( + QMouseEvent* theEvent, Handle_V3d_View theView, + const std::list& theSelected, + const std::list& theHighlighted) { } -void PartSet_OperationSketchBase::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected) +void PartSet_OperationSketchBase::mouseReleased( + QMouseEvent* theEvent, Handle_V3d_View theView, + const std::list& theSelected, + const std::list& theHighlighted) { } void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView) { } +void PartSet_OperationSketchBase::mouseDoubleClick( + QMouseEvent* theEvent, Handle_V3d_View theView, + const std::list& theSelected, + const std::list& theHighlighted) +{ +} + +void PartSet_OperationSketchBase::restartOperation(const std::string& theType, ObjectPtr theFeature) +{ + FeaturePtr aFeature = ModelAPI_Feature::feature(theFeature); + if (aFeature) { + QStringList aNested = this->nestedFeatures(); + if (!aNested.isEmpty()) { + if (!aNested.contains(QString(aFeature->getKind().c_str()))) + return; + } + } + emit restartRequired(theType, theFeature); +} + + -void PartSet_OperationSketchBase::keyReleased(const int theKey) +void PartSet_OperationSketchBase::activateByPreselection() { - switch (theKey) { - case Qt::Key_Escape: { - abort(); + if (!myPropertyPanel) + return; + ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget(); + if ((myPreSelection.size() > 0) && aActiveWgt) { + const ModuleBase_ViewerPrs& aPrs = myPreSelection.front(); + ModuleBase_WidgetValueFeature aValue; + aValue.setObject(aPrs.object()); + if (aActiveWgt->setValue(&aValue)) { + myPreSelection.remove(aPrs); + if(isValid()) { + //myActiveWidget = NULL; + commit(); + } else { + myPropertyPanel->activateNextWidget(); + //emit activateNextWidget(myActiveWidget); + } } - break; - default: - break; + // If preselection is enough to make a valid feature - apply it immediately } }