X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_Module.cpp;h=8e05584b9cb6e9bdf84d4e31990b6c9216e803f4;hb=0c10db12692c21f2ce38b9eebd27981a8eee6b41;hp=30be9bac2624eb525150753b32132c3845c611d1;hpb=61426e6b8df62675d42ec9b5e59bbf90b6833135;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 30be9bac2..8e05584b9 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -1,18 +1,24 @@ #include #include -#include -#include -#include -#include +#include +#include +#include #include #include #include #include #include -#include +#include +#include #include #include +#include +#include + +#include +#include +#include #include #include @@ -20,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -38,20 +45,29 @@ #include #include - -#include -//#include +#include +#include #include #include #include +#include +#include + #ifdef _DEBUG #include #endif + +//const int SKETCH_PLANE_COLOR = Colors::COLOR_BROWN; /// the plane edge color +const double SKETCH_WIDTH = 4.0; /// the plane edge width +// face of the square-face displayed for selection of general plane +const double PLANE_SIZE = 200; + + /*!Create and return new instance of XGUI_Module*/ -extern "C" PARTSET_EXPORT XGUI_Module* createModule(XGUI_Workshop* theWshop) +extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(XGUI_Workshop* theWshop) { return new PartSet_Module(theWshop); } @@ -83,7 +99,6 @@ PartSet_Module::PartSet_Module(XGUI_Workshop* theWshop) this, SLOT(onKeyRelease(QKeyEvent*))); connect(myWorkshop->viewer(), SIGNAL(mouseDoubleClick(QMouseEvent*)), this, SLOT(onMouseDoubleClick(QMouseEvent*))); - } PartSet_Module::~PartSet_Module() @@ -100,6 +115,15 @@ void PartSet_Module::createFeatures() Config_ModuleReader aXMLReader = Config_ModuleReader(); aXMLReader.readAll(); myFeaturesInFiles = aXMLReader.featuresInFiles(); + + //!! Test registering of validators + PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); + aFactory->registerValidator("PartSet_DistanceValidator", new PartSet_DistanceValidator); + aFactory->registerValidator("PartSet_LengthValidator", new PartSet_LengthValidator); + aFactory->registerValidator("PartSet_PerpendicularValidator", new PartSet_PerpendicularValidator); + aFactory->registerValidator("PartSet_ParallelValidator", new PartSet_ParallelValidator); + aFactory->registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator); } void PartSet_Module::featureCreated(QAction* theFeature) @@ -137,6 +161,14 @@ void PartSet_Module::onFeatureTriggered() void PartSet_Module::launchOperation(const QString& theCmdId) { ModuleBase_Operation* anOperation = createOperation(theCmdId.toStdString()); + PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); + if (aPreviewOp) { + XGUI_Selection* aSelection = myWorkshop->selector()->selection(); + // Initialise operation with preliminary selection + std::list aSelected = aSelection->getSelected(); + std::list aHighlighted = aSelection->getHighlighted(); + aPreviewOp->initSelection(aSelected, aHighlighted); + } sendOperation(anOperation); } @@ -146,8 +178,8 @@ void PartSet_Module::onOperationStarted() myWorkshop->operationMgr()->currentOperation()); if (aPreviewOp) { XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel(); - connect(aPreviewOp, SIGNAL(focusActivated(const std::string&)), - aPropPanel, SLOT(onFocusActivated(const std::string&))); + connect(aPropPanel, SIGNAL(storedPoint2D(FeaturePtr, const std::string&)), + this, SLOT(onStorePoint2D(FeaturePtr, const std::string&)), Qt::UniqueConnection); } } @@ -158,16 +190,18 @@ void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation) PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(theOperation); if (aPreviewOp) { XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel(); - disconnect(aPreviewOp, SIGNAL(focusActivated(const std::string&)), - aPropPanel, SLOT(onFocusActivated(const std::string&))); + //disconnect(aPropPanel, SIGNAL(storedPoint2D(FeaturePtr, const std::string&)), + // this, SLOT(onStorePoint2D(FeaturePtr, const std::string&))); } } void PartSet_Module::onContextMenuCommand(const QString& theId, bool isChecked) { - QFeatureList aFeatures = myWorkshop->selector()->selectedFeatures(); + QList aFeatures = myWorkshop->selector()->selection()->selectedObjects(); if (theId == "EDIT_CMD" && (aFeatures.size() > 0)) { - editFeature(aFeatures.first()); + FeaturePtr aFeature = boost::dynamic_pointer_cast(aFeatures.first()); + if (aFeature) + editFeature(aFeature); } } @@ -175,11 +209,11 @@ void PartSet_Module::onMousePressed(QMouseEvent* theEvent) { PartSet_OperationSketchBase* aPreviewOp = dynamic_cast( myWorkshop->operationMgr()->currentOperation()); - if (aPreviewOp) - { - XGUI_Displayer* aDisplayer = myWorkshop->displayer(); - std::list aSelected = aDisplayer->getSelected(); - std::list aHighlighted = aDisplayer->getHighlighted(); + if (aPreviewOp) { + XGUI_Selection* aSelection = myWorkshop->selector()->selection(); + // Initialise operation with preliminary selection + std::list aSelected = aSelection->getSelected(); + std::list aHighlighted = aSelection->getHighlighted(); aPreviewOp->mousePressed(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted); } @@ -189,13 +223,26 @@ void PartSet_Module::onMouseReleased(QMouseEvent* theEvent) { PartSet_OperationSketchBase* aPreviewOp = dynamic_cast( myWorkshop->operationMgr()->currentOperation()); - if (aPreviewOp) - { - XGUI_Displayer* aDisplayer = myWorkshop->displayer(); - std::list aSelected = aDisplayer->getSelected(); - std::list aHighlighted = aDisplayer->getHighlighted(); + if (aPreviewOp) { + XGUI_Selection* aSelection = myWorkshop->selector()->selection(); + // Initialise operation with preliminary selection + std::list aSelected = aSelection->getSelected(); + std::list aHighlighted = aSelection->getHighlighted(); - aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted); + PartSet_OperationSketch* aSketchOp = dynamic_cast(aPreviewOp); + if (aSketchOp) { + if ((!aSketchOp->hasSketchPlane()) && (aSelected.size() > 0)) { + Handle(AIS_InteractiveObject) aAIS = aSelected.front().interactive(); + if ((aAIS == myXPlane->impl()) || + (aAIS == myYPlane->impl()) || + (aAIS == myZPlane->impl()) ) { + + Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(aAIS); + aSketchOp->setSketchPlane(aAISShape->Shape()); + } + } + } else + aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted); } } @@ -222,9 +269,10 @@ void PartSet_Module::onMouseDoubleClick(QMouseEvent* theEvent) myWorkshop->operationMgr()->currentOperation()); if (aPreviewOp) { - XGUI_Displayer* aDisplayer = myWorkshop->displayer(); - std::list aSelected = aDisplayer->getSelected(); - std::list aHighlighted = aDisplayer->getHighlighted(); + XGUI_Selection* aSelection = myWorkshop->selector()->selection(); + // Initialise operation with preliminary selection + std::list aSelected = aSelection->getSelected(); + std::list aHighlighted = aSelection->getHighlighted(); aPreviewOp->mouseDoubleClick(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted); } @@ -232,6 +280,7 @@ void PartSet_Module::onMouseDoubleClick(QMouseEvent* theEvent) void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ) { + erasePlanes(); myWorkshop->viewer()->setViewProjection(theX, theY, theZ); myWorkshop->actionsMgr()->update(); @@ -250,11 +299,12 @@ void PartSet_Module::onLaunchOperation(std::string theName, FeaturePtr theFeatur PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); if (aPreviewOp) { - XGUI_Displayer* aDisplayer = myWorkshop->displayer(); - // refill the features list with avoiding of the features, obtained only by vertex shape (TODO) - std::list aSelected = aDisplayer->getSelected(TopAbs_VERTEX); - std::list aHighlighted = aDisplayer->getHighlighted(TopAbs_VERTEX); - aPreviewOp->init(theFeature, aSelected, aHighlighted); + XGUI_Selection* aSelection = myWorkshop->selector()->selection(); + // Initialise operation with preliminary selection + std::list aSelected = aSelection->getSelected(); + std::list aHighlighted = aSelection->getHighlighted(); + aPreviewOp->initFeature(theFeature); + aPreviewOp->initSelection(aSelected, aHighlighted); } else { anOperation->setEditingFeature(theFeature); } @@ -268,17 +318,25 @@ void PartSet_Module::onMultiSelectionEnabled(bool theEnabled) aViewer->enableMultiselection(theEnabled); } -void PartSet_Module::onStopSelection(const std::list& theFeatures, const bool isStop) +void PartSet_Module::onStopSelection(const QFeatureList& theFeatures, const bool isStop) { XGUI_Displayer* aDisplayer = myWorkshop->displayer(); if (!isStop) { - std::list::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end(); - FeaturePtr aFeature; + QFeatureList::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end(); for (; anIt != aLast; anIt++) { - activateFeature((*anIt).feature(), false); + activateFeature((*anIt), false); + } + } + QResultList aResults; + foreach(FeaturePtr aFeature, theFeatures) { + if (aFeature->results().size() > 0) { + const std::list& aResList = aFeature->results(); + std::list::const_iterator aIt; + for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt) + aResults.append(*aIt); } } - aDisplayer->stopSelection(theFeatures, isStop, false); + aDisplayer->stopSelection(aResults, isStop, false); XGUI_ViewerProxy* aViewer = myWorkshop->viewer(); aViewer->enableSelection(!isStop); @@ -286,7 +344,7 @@ void PartSet_Module::onStopSelection(const std::list& theFeature aDisplayer->updateViewer(); } -void PartSet_Module::onSetSelection(const std::list& theFeatures) +void PartSet_Module::onSetSelection(const QResultList& theFeatures) { XGUI_Displayer* aDisplayer = myWorkshop->displayer(); aDisplayer->setSelected(theFeatures, false); @@ -302,22 +360,20 @@ void PartSet_Module::onCloseLocalContext() void PartSet_Module::onFeatureConstructed(FeaturePtr theFeature, int theMode) { bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide; - visualizePreview(theFeature, isDisplay, false); + // TODO visualizePreview(theFeature, isDisplay, false); if (!isDisplay) { ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation(); FeaturePtr aSketch; PartSet_OperationSketchBase* aPrevOp = dynamic_cast(aCurOperation); if (aPrevOp) { - std::map > aList = aPrevOp->subPreview(); + std::list aList = aPrevOp->subFeatures(); XGUI_Displayer* aDisplayer = myWorkshop->displayer(); std::list aModes = aPrevOp->getSelectionModes(aPrevOp->feature()); - std::map >::const_iterator - anIt = aList.begin(), aLast = aList.end(); - for (; anIt != aLast; anIt++) { - FeaturePtr aFeature = (*anIt).first; - visualizePreview(aFeature, false, false); - } + std::list::const_iterator anIt = aList.begin(), + aLast = aList.end(); + for (; anIt != aLast; anIt++) + visualizePreview((*anIt), false, false); aDisplayer->updateViewer(); } } @@ -341,14 +397,12 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI PartSet_OperationSketchBase* aPrevOp = dynamic_cast(aCurOperation); if (aPrevOp) aSketch = aPrevOp->sketch(); - if (PartSet_OperationCreateFeature::canProcessKind(theCmdId)) - anOperation = new PartSet_OperationCreateFeature(theCmdId.c_str(), this, aSketch); - else if (theCmdId == PartSet_OperationEditFeature::Type()) - anOperation = new PartSet_OperationEditFeature(theCmdId.c_str(), this, aSketch); - else if (PartSet_OperationCreateConstraint::canProcessKind(theCmdId)) - anOperation = new PartSet_OperationCreateConstraint(theCmdId.c_str(), this, aSketch); - else if (theCmdId == PartSet_OperationEditConstraint::Type()) - anOperation = new PartSet_OperationEditConstraint(theCmdId.c_str(), theFeatureKind, this, aSketch); + if (PartSet_OperationFeatureCreate::canProcessKind(theCmdId)) + anOperation = new PartSet_OperationFeatureCreate(theCmdId.c_str(), this, aSketch); + else if (theCmdId == PartSet_OperationFeatureEditMulti::Type()) + anOperation = new PartSet_OperationFeatureEditMulti(theCmdId.c_str(), this, aSketch); + else if (theCmdId == PartSet_OperationFeatureEdit::Type()) + anOperation = new PartSet_OperationFeatureEdit(theCmdId.c_str(), this, aSketch); } if (!anOperation) { @@ -364,16 +418,17 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI std::string aXmlCfg = aWdgReader.featureWidgetCfg(aFeatureKind); std::string aDescription = aWdgReader.featureDescription(aFeatureKind); - QString aXmlRepr = QString::fromStdString(aXmlCfg); - ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aXmlRepr.toStdString(), - myWorkshop->moduleConnector()); - QWidget* aContent = myWorkshop->propertyPanel()->contentWidget(); - qDeleteAll(aContent->children()); - aFactory.createWidget(aContent); + //QString aXmlRepr = QString::fromStdString(aXmlCfg); + //ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aXmlRepr.toStdString(), + // myWorkshop->moduleConnector()); + //QWidget* aContent = myWorkshop->propertyPanel()->contentWidget(); + //qDeleteAll(aContent->children()); + //aFactory.createWidget(aContent); anOperation->getDescription()->setDescription(QString::fromStdString(aDescription)); + anOperation->getDescription()->setXmlRepresentation(QString::fromStdString(aXmlCfg)); - anOperation->setModelWidgets(aXmlRepr.toStdString(), aFactory.getModelWidgets()); + //anOperation->setModelWidgets(aXmlRepr.toStdString(), aFactory.getModelWidgets()); // connect the operation PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); @@ -385,12 +440,10 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)), this, SLOT(onMultiSelectionEnabled(bool))); - connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)), - this, SLOT(onMultiSelectionEnabled(bool))); - connect(aPreviewOp, SIGNAL(stopSelection(const std::list&, const bool)), - this, SLOT(onStopSelection(const std::list&, const bool))); - connect(aPreviewOp, SIGNAL(setSelection(const std::list&)), - this, SLOT(onSetSelection(const std::list&))); + connect(aPreviewOp, SIGNAL(stopSelection(const QFeatureList&, const bool)), + this, SLOT(onStopSelection(const QFeatureList&, const bool))); + connect(aPreviewOp, SIGNAL(setSelection(const QFeatureList&)), + this, SLOT(onSetSelection(const QFeatureList&))); connect(aPreviewOp, SIGNAL(closeLocalContext()), this, SLOT(onCloseLocalContext())); @@ -409,13 +462,59 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI void PartSet_Module::sendOperation(ModuleBase_Operation* theOperation) { - //TODO(sbh): Implement static method to extract event id [SEID] - static Events_ID aModuleEvent = Events_Loop::eventByName("PartSetModuleEvent"); + static Events_ID aModuleEvent = Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED); Config_PointerMessage aMessage(aModuleEvent, this); aMessage.setPointer(theOperation); Events_Loop::loop()->send(aMessage); } +boost::shared_ptr getPlane(double theX, double theY, double theZ) +{ + boost::shared_ptr anOrigin(new GeomAPI_Pnt(0, 0, 0)); + boost::shared_ptr aNormal(new GeomAPI_Dir(theX, theY, theZ)); + return GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal, PLANE_SIZE); +} + +void PartSet_Module::showPlanes() +{ + XGUI_Displayer* aDisplayer = myWorkshop->displayer(); + // Show selection planes + if (!myXPlane) { + boost::shared_ptr aPlaneX = getPlane(1, 0, 0); + myXPlane = boost::shared_ptr(new GeomAPI_AISObject()); + myXPlane->createShape(aPlaneX); + myXPlane->setColor(Colors::COLOR_RED); + myXPlane->setWidth(SKETCH_WIDTH); + } + if (!myYPlane) { + boost::shared_ptr aPlaneY = getPlane(0, 1, 0); + myYPlane = boost::shared_ptr(new GeomAPI_AISObject()); + myYPlane->createShape(aPlaneY); + myYPlane->setColor(Colors::COLOR_GREEN); + myYPlane->setWidth(SKETCH_WIDTH); + } + if (!myZPlane) { + boost::shared_ptr aPlaneZ = getPlane(0, 0, 1); + myZPlane = boost::shared_ptr(new GeomAPI_AISObject()); + myZPlane->createShape(aPlaneZ); + myZPlane->setColor(Colors::COLOR_BLUE); + myZPlane->setWidth(SKETCH_WIDTH); + } + aDisplayer->display(myXPlane, false); + aDisplayer->display(myYPlane, false); + aDisplayer->display(myZPlane, false); + aDisplayer->updateViewer(); +} + +void PartSet_Module::erasePlanes() +{ + XGUI_Displayer* aDisplayer = myWorkshop->displayer(); + aDisplayer->erase(myXPlane, false); + aDisplayer->erase(myYPlane, false); + aDisplayer->erase(myZPlane, false); + aDisplayer->updateViewer(); +} + void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay, const bool isUpdateViewer) { @@ -427,18 +526,20 @@ void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay, if (!aPreviewOp) return; + ResultPtr aResult = theFeature->firstResult(); XGUI_Displayer* aDisplayer = myWorkshop->displayer(); if (isDisplay) { - boost::shared_ptr aPreview = aPreviewOp->preview(theFeature); - Handle(AIS_InteractiveObject) anAIS = PartSet_Presentation::createPresentation( - theFeature, aPreviewOp->sketch(), - aPreview ? aPreview->impl() : TopoDS_Shape(), - aDisplayer->getAISObject(theFeature)); - - aDisplayer->redisplay(theFeature, anAIS, false); + boost::shared_ptr aSPFeature = + boost::dynamic_pointer_cast(theFeature); + if (aSPFeature) { + showPlanes(); + //boost::shared_ptr anAIS = + // aSPFeature->getAISObject(aDisplayer->getAISObject(aResult)); + //aDisplayer->redisplay(aResult, anAIS, false); + } } else - aDisplayer->erase(theFeature, false); + aDisplayer->erase(aResult, false); if (isUpdateViewer) aDisplayer->updateViewer(); @@ -448,11 +549,11 @@ void PartSet_Module::activateFeature(FeaturePtr theFeature, const bool isUpdateV { ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation(); PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); - if (aPreviewOp) { +/* TODO if (aPreviewOp) { XGUI_Displayer* aDisplayer = myWorkshop->displayer(); - aDisplayer->activateInLocalContext(theFeature, aPreviewOp->getSelectionModes(theFeature), + aDisplayer->activateInLocalContext(theFeature->firstResult(), aPreviewOp->getSelectionModes(theFeature), isUpdateViewer); - } + }*/ } void PartSet_Module::updateCurrentPreview(const std::string& theCmdId) @@ -469,22 +570,19 @@ void PartSet_Module::updateCurrentPreview(const std::string& theCmdId) if (!aFeature || aFeature->getKind() != theCmdId) return; - std::map > aList = aPreviewOp->subPreview(); + std::list aList = aPreviewOp->subFeatures(); XGUI_Displayer* aDisplayer = myWorkshop->displayer(); std::list aModes = aPreviewOp->getSelectionModes(aPreviewOp->feature()); - std::map >::const_iterator - anIt = aList.begin(), aLast = aList.end(); + std::list::const_iterator anIt = aList.begin(), + aLast = aList.end(); for (; anIt != aLast; anIt++) { - FeaturePtr aFeature = (*anIt).first; - boost::shared_ptr aPreview = (*anIt).second; - Handle(AIS_InteractiveObject) anAIS = PartSet_Presentation::createPresentation( - aFeature, aPreviewOp->sketch(), - aPreview ? aPreview->impl() : TopoDS_Shape(), - aDisplayer->getAISObject(aFeature)); - if (!anAIS.IsNull()) - aDisplayer->redisplay(aFeature, anAIS, false); - aDisplayer->activateInLocalContext(aFeature, aModes, false); + boost::shared_ptr aSPFeature = + boost::dynamic_pointer_cast(*anIt); + if (!aSPFeature) + continue; + visualizePreview((*anIt), true, false); + aDisplayer->activateInLocalContext((*anIt)->firstResult(), aModes, false); } aDisplayer->updateViewer(); } @@ -495,15 +593,61 @@ void PartSet_Module::editFeature(FeaturePtr theFeature) return; // if (theFeature->getKind() == SKETCH_KIND) { - FeaturePtr aFeature = theFeature; - if (XGUI_Tools::isModelObject(aFeature)) { - ObjectPtr aObject = boost::dynamic_pointer_cast(aFeature); - aFeature = aObject->featureRef(); - } - - if (aFeature) { - onLaunchOperation(aFeature->getKind(), aFeature); - updateCurrentPreview(aFeature->getKind()); - } + //FeaturePtr aFeature = theFeature; + //if (XGUI_Tools::isModelObject(aFeature)) { + // ObjectPtr aObject = boost::dynamic_pointer_cast(aFeature); + // aFeature = aObject->featureRef(); + //} + + //if (aFeature) { + onLaunchOperation(theFeature->getKind(), theFeature); + updateCurrentPreview(theFeature->getKind()); + //} // } } + +void PartSet_Module::onStorePoint2D(FeaturePtr theFeature, const std::string& theAttribute) +{ + PartSet_OperationSketchBase* aPreviewOp = dynamic_cast( + myWorkshop->operationMgr()->currentOperation()); + if (!aPreviewOp) + return; + + boost::shared_ptr aPoint = + boost::dynamic_pointer_cast(theFeature->data()->attribute(theAttribute)); + + PartSet_Tools::setConstraints(aPreviewOp->sketch(), theFeature, theAttribute, + aPoint->x(), aPoint->y()); +} + +/*bool PartSet_Module::isFeatureEnabled(const QString& theCmdId) const +{ + XGUI_OperationMgr* aOpMgr = myWorkshop->operationMgr(); + XGUI_ActionsMgr* aActMgr = myWorkshop->actionsMgr(); + + ModuleBase_Operation* aOperation = aOpMgr->currentOperation(); + if (!aOperation) + return !aActMgr->isNested(theCmdId); + + PartSet_OperationFeatureEdit* aSketchEdtOp = dynamic_cast(aOperation); + if (aSketchEdtOp) { + QStringList aConstraintList; + aConstraintList<<"SketchConstraintDistance"<<"SketchConstraintLength" + <<"SketchConstraintRadius"<<"SketchConstraintParallel"<<"SketchConstraintPerpendicular"; + return aConstraintList.contains(theCmdId); + } + QStringList aList = aActMgr->nestedCommands(aOperation->id()); + return aList.contains(theCmdId); +}*/ + +QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent, + Config_WidgetAPI* theWidgetApi, QList& theModelWidgets) +{ + if (theType == "sketch-start-label") { + PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi); + aWgt->setOperationsMgr(myWorkshop->operationMgr()); + theModelWidgets.append(aWgt); + return aWgt->getControl(); + } else + return 0; +}