From: nds Date: Wed, 10 Feb 2016 14:53:52 +0000 (+0300) Subject: 2.5. Select the point of a sketch entity must display the editing point panel X-Git-Tag: V_2.2.0~132 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a8d47776cf43a5535c262115d529e2f9f445cef3;p=modules%2Fshaper.git 2.5. Select the point of a sketch entity must display the editing point panel --- diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index da7ed2b31..75a962dad 100755 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -122,6 +123,13 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject /// It is called as on clearing of property panel as on filling with new widgets virtual void propertyPanelDefined(ModuleBase_Operation* theOperation) {} + /// Have an opportunity to create widgets for the current operation instead of standard creation in workshop + /// \param theOperation a started operation + /// \param theWidgets a list of created widgets + /// \return boolean result, false by default + virtual bool createWidgets(ModuleBase_Operation* theOperation, + QList& theWidgets) const { return false; } + //! Returns True if there are available Undos and there is not an active operation virtual bool canUndo() const; @@ -262,11 +270,6 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject virtual AttributePtr findAttribute(const ObjectPtr& theObject, const GeomShapePtr& theGeomShape) = 0; - /// Returns color of the object - /// \param theObject a result of a feature object - /// \param theColor a vector of three values in [0, 255] range - virtual void getColor(const ObjectPtr& theObject, std::vector& theColor) {} - /// Returns XML information by the feature index /// \param theFeatureId a feature id /// \param theXmlCfg XML configuration diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.cpp b/src/ModuleBase/ModuleBase_WidgetFactory.cpp index 0bca51268..45d6446ca 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFactory.cpp @@ -121,11 +121,44 @@ void ModuleBase_WidgetFactory::createWidget(ModuleBase_PageBase* thePage) thePage->alignToTop(); } +void ModuleBase_WidgetFactory::createWidget(ModuleBase_PageBase* thePage, + const std::string& theWidgetId) +{ + bool aFound = false; + moveToWidgetId(theWidgetId, aFound); + if (aFound) { + std::string aWdgType = myWidgetApi->widgetType(); + + // Create a ModelWidget + ModuleBase_ModelWidget* aWidget = createWidgetByType(aWdgType, thePage->pageWidget()); + if (aWidget) { + if (!myWidgetApi->getBooleanAttribute(ATTR_INTERNAL, false)) { + thePage->addModelWidget(aWidget); + } + else { + aWidget->setVisible(false); + } + } + } + thePage->alignToTop(); +} + void ModuleBase_WidgetFactory::getAttributeTitle(const std::string& theFeatureKind, const std::string& theAttributeId, std::string& theTitle) { - if (!theTitle.empty()) + bool aFound = false; + moveToWidgetId(theAttributeId, aFound); + if (aFound) { + theTitle = QString::fromStdString(myWidgetApi->widgetLabel()).toStdString().c_str(); + if (theTitle.empty()) + theTitle = QString::fromStdString(myWidgetApi->getProperty(CONTAINER_PAGE_NAME)).toStdString().c_str(); + } +} + +void ModuleBase_WidgetFactory::moveToWidgetId(const std::string& theWidgetId, bool& theFound) +{ + if (theFound) return; myParentId = myWidgetApi->widgetId(); @@ -136,28 +169,23 @@ void ModuleBase_WidgetFactory::getAttributeTitle(const std::string& theFeatureKi std::string aWdgType = myWidgetApi->widgetType(); // Find title under PageGroup if (myWidgetApi->isGroupBoxWidget() || - ModuleBase_WidgetCreatorFactory::get()->hasPageWidget(aWdgType)) { - - getAttributeTitle(theFeatureKind, theAttributeId, theTitle); - } else { + ModuleBase_WidgetCreatorFactory::get()->hasPageWidget(aWdgType)) { + moveToWidgetId(theWidgetId, theFound); + } + else { // Find title here std::string anAttributeId = myWidgetApi->widgetId(); - if (anAttributeId == theAttributeId) { - theTitle = QString::fromStdString(myWidgetApi->widgetLabel()).toStdString().c_str(); - if (theTitle.empty()) - theTitle = QString::fromStdString(myWidgetApi->getProperty(CONTAINER_PAGE_NAME)).toStdString().c_str(); - - } - if (myWidgetApi->isPagedWidget()) { + theFound = anAttributeId == theWidgetId; + if (!theFound && myWidgetApi->isPagedWidget()) { //If current widget is toolbox or switch-casebox then fetch all //it's pages recursively and setup into the widget. myWidgetApi->toChildWidget(); do { - getAttributeTitle(theFeatureKind, theAttributeId, theTitle); - } while (myWidgetApi->toNextWidget() && theTitle.empty()); + moveToWidgetId(theWidgetId, theFound); + } while (!theFound && myWidgetApi->toNextWidget()); } } - } while (myWidgetApi->toNextWidget() && theTitle.empty()); + } while (!theFound && myWidgetApi->toNextWidget()); } ModuleBase_PageBase* ModuleBase_WidgetFactory::createPageByType(const std::string& theType, diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.h b/src/ModuleBase/ModuleBase_WidgetFactory.h index f51f541fa..fd416271e 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.h +++ b/src/ModuleBase/ModuleBase_WidgetFactory.h @@ -38,9 +38,14 @@ class MODULEBASE_EXPORT ModuleBase_WidgetFactory virtual ~ModuleBase_WidgetFactory(); /// Creates content widget for property panel - /// \param theParent a parent widget - void createWidget(ModuleBase_PageBase* theParent); + /// \param thePage a parent page + void createWidget(ModuleBase_PageBase* thePage); + /// Creates one widget for property panel for the widget with given index + /// \param theParent a parent widget + /// \param theWidgetId a widget index + void createWidget(ModuleBase_PageBase* thePage, + const std::string& theWidgetId); /// Returns list of model widgets QList getModelWidgets() const @@ -76,6 +81,12 @@ protected: /// \param theStdString is STD string static QString qs(const std::string& theStdString); + /// It updates internal config api to point in the structure to given id of widget + /// The method is recusive and it stops when the found flag is true + /// \param theWidgetId a widget id key value + /// \param theFound a flag about found windget and recursive search should be stopped + void moveToWidgetId(const std::string& theWidgetId, bool& theFound); + private: /// API object for XML reading Config_WidgetAPI* myWidgetApi; diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index e49ff2ce1..aef61e704 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -37,6 +37,8 @@ #include #include #include +#include +#include #include #include @@ -94,6 +96,7 @@ #include #include #include +#include #include #include @@ -250,9 +253,7 @@ void PartSet_Module::operationCommitted(ModuleBase_Operation* theOperation) // the selection is cleared after commit the create operation // in order to do not use the same selected objects in the restarted operation // for common behaviour, the selection is cleared even if the operation is not restarted - XGUI_ModuleConnector* aConnector = dynamic_cast(workshop()); - XGUI_Workshop* aWorkshop = aConnector->workshop(); - aWorkshop->selector()->clearSelection(); + getWorkshop()->selector()->clearSelection(); } } } @@ -420,9 +421,7 @@ void PartSet_Module::grantedOperationIds(ModuleBase_Operation* theOperation, myMenuMgr->grantedOperationIds(theOperation, theIds); if (PartSet_SketcherMgr::isSketchOperation(theOperation)) { - XGUI_ModuleConnector* aConnector = dynamic_cast(workshop()); - XGUI_Workshop* aWorkshop = aConnector->workshop(); - + XGUI_Workshop* aWorkshop = getWorkshop(); theIds.append(aWorkshop->contextMenuMgr()->action("DELETE_CMD")->text()); } } @@ -448,8 +447,7 @@ void PartSet_Module::clearViewer() { myCustomPrs->clearPrs(); - XGUI_ModuleConnector* aConnector = dynamic_cast(myWorkshop); - XGUI_Workshop* aWorkshop = aConnector->workshop(); + XGUI_Workshop* aWorkshop = getWorkshop(); XGUI_Displayer* aDisplayer = aWorkshop->displayer(); aDisplayer->deactivateSelectionFilters(); } @@ -466,6 +464,44 @@ void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation) aPanel->activateWidget(aPanel->modelWidgets().first()); } +bool PartSet_Module::createWidgets(ModuleBase_Operation* theOperation, + QList& theWidgets) const +{ + bool aProcessed = false; + + ModuleBase_OperationFeature* aFOperation = dynamic_cast(theOperation); + XGUI_Workshop* aWorkshop = getWorkshop(); + XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel(); + if (mySketchMgr->activeSketch().get() && aFOperation && aPropertyPanel) { + ModuleBase_ISelection* aSelection = workshop()->selection(); + // click on a point in sketch leads here with the point is highlighted, not yet selected + QList aPreselection = aSelection->getHighlighted(); + if (aPreselection.size() == 1) { + ModuleBase_ViewerPrs aSelectedPrs = aPreselection[0]; + ObjectPtr anObject = aSelectedPrs.object(); + + FeaturePtr aFeature = ModelAPI_Feature::feature(anObject); + FeaturePtr anOpFeature = aFOperation->feature(); + TopoDS_Shape aShape = aSelectedPrs.shape(); + // click on the digit of dimension constrain comes here with an empty shape, so we need the check + if (aFeature == anOpFeature && !aShape.IsNull()) { + AttributePtr anAttribute = PartSet_Tools::findAttributeBy2dPoint(anObject, aShape, + mySketchMgr->activeSketch()); + if (anAttribute.get()) { + QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation(); + ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), workshop()); + + const std::string anAttributeId = anAttribute->id(); + aFactory.createWidget(aPropertyPanel->contentWidget(), anAttributeId); + + theWidgets = aFactory.getModelWidgets(); + aProcessed = true; + } + } + } + } + return aProcessed; +} void PartSet_Module::onSelectionChanged() { @@ -518,8 +554,7 @@ ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& th Config_WidgetAPI* theWidgetApi, std::string theParentId) { ModuleBase_IWorkshop* aWorkshop = workshop(); - XGUI_ModuleConnector* aConnector = dynamic_cast(aWorkshop); - XGUI_Workshop* aXUIWorkshop = aConnector->workshop(); + XGUI_Workshop* aXUIWorkshop = getWorkshop(); ModuleBase_ModelWidget* aWgt = NULL; if (theType == "sketch-start-label") { PartSet_WidgetSketchLabel* aLabelWgt = new PartSet_WidgetSketchLabel(theParent, aWorkshop, @@ -588,8 +623,7 @@ bool PartSet_Module::deleteObjects() { bool isProcessed = false; - XGUI_ModuleConnector* aConnector = dynamic_cast(workshop()); - XGUI_Workshop* aWorkshop = aConnector->workshop(); + XGUI_Workshop* aWorkshop = getWorkshop(); XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr(); //SessionPtr aMgr = ModelAPI_Session::get(); @@ -725,8 +759,7 @@ void PartSet_Module::onViewTransformed(int theTrsfType) //Handle(V3d_View) aView = aViewer->activeView(); - XGUI_ModuleConnector* aConnector = dynamic_cast(myWorkshop); - XGUI_Workshop* aWorkshop = aConnector->workshop(); + XGUI_Workshop* aWorkshop = getWorkshop(); XGUI_Displayer* aDisplayer = aWorkshop->displayer(); Handle(V3d_Viewer) aV3dViewer = aContext->CurrentViewer(); Handle(V3d_View) aView; @@ -787,8 +820,7 @@ bool PartSet_Module::customisePresentation(ResultPtr theResult, AISObjectPtr the if (theResult.get()) return aCustomized; - XGUI_ModuleConnector* aConnector = dynamic_cast(myWorkshop); - XGUI_Workshop* aWorkshop = aConnector->workshop(); + XGUI_Workshop* aWorkshop = getWorkshop(); XGUI_Displayer* aDisplayer = aWorkshop->displayer(); ObjectPtr anObject = aDisplayer->getObject(thePrs); if (anObject.get()) { @@ -858,8 +890,7 @@ void PartSet_Module::onActiveDocPopup(const QPoint& thePnt) SessionPtr aMgr = ModelAPI_Session::get(); QAction* aActivatePartAction = myMenuMgr->action("ACTIVATE_PARTSET_CMD"); - XGUI_ModuleConnector* aConnector = dynamic_cast(myWorkshop); - XGUI_Workshop* aWorkshop = aConnector->workshop(); + XGUI_Workshop* aWorkshop = getWorkshop(); QLabel* aHeader = aWorkshop->objectBrowser()->activeDocLabel(); aActivatePartAction->setEnabled((aMgr->activeDocument() != aMgr->moduleDocument())); @@ -959,8 +990,7 @@ void PartSet_Module::processEvent(const std::shared_ptr& theMess if (myWorkshop->currentOperation() && (!aAllowActivationList.contains(myWorkshop->currentOperation()->id()))) return; - XGUI_ModuleConnector* aConnector = dynamic_cast(myWorkshop); - XGUI_Workshop* aWorkshop = aConnector->workshop(); + XGUI_Workshop* aWorkshop = getWorkshop(); XGUI_DataTree* aTreeView = aWorkshop->objectBrowser()->treeView(); QLabel* aLabel = aWorkshop->objectBrowser()->activeDocLabel(); QPalette aPalet = aLabel->palette(); @@ -1004,8 +1034,7 @@ void PartSet_Module::onTreeViewDoubleClick(const QModelIndex& theIndex) if (theIndex.column() != 0) // Use only first column return; - XGUI_ModuleConnector* aConnector = dynamic_cast(myWorkshop); - XGUI_Workshop* aWorkshop = aConnector->workshop(); + XGUI_Workshop* aWorkshop = getWorkshop(); XGUI_DataModel* aDataModel = aWorkshop->objectBrowser()->dataModel(); // De not use non editable Indexes if ((aDataModel->flags(theIndex) & Qt::ItemIsSelectable) == 0) @@ -1126,14 +1155,6 @@ AttributePtr PartSet_Module::findAttribute(const ObjectPtr& theObject, return anAttribute; } -//****************************************************** -void PartSet_Module::getColor(const ObjectPtr& theObject, std::vector& theColor) -{ - if (myOverconstraintListener->isConflictingObject(theObject)) { - myOverconstraintListener->getConflictingColor(theColor); - } -} - //****************************************************** void PartSet_Module::onBooleanOperationChange(int theOperation) { @@ -1153,3 +1174,10 @@ void PartSet_Module::onBooleanOperationChange(int theOperation) break; } } + +//****************************************************** +XGUI_Workshop* PartSet_Module::getWorkshop() const +{ + XGUI_ModuleConnector* aConnector = dynamic_cast(workshop()); + return aConnector->workshop(); +} diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 3cf93537c..f6c371f1f 100755 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -30,6 +30,7 @@ class ModuleBase_Operation; class ModuleBase_IViewWindow; +class XGUI_Workshop; class PartSet_MenuMgr; class PartSet_CustomPrs; class PartSet_SketcherMgr; @@ -76,6 +77,14 @@ public: /// Call back forlast tuning of property panel before operation performance virtual void propertyPanelDefined(ModuleBase_Operation* theOperation); + /// If there is found selected attribute, widgets are created and contains only a widget for the attribute + /// It is important for Property Panel filling by sketch point attribute + /// \param theOperation a started operation + /// \param theWidgets a list of created widgets + /// \return boolean result, false by default + virtual bool createWidgets(ModuleBase_Operation* theOperation, + QList& theWidgets) const; + /// Creates an operation and send it to loop /// \param theCmdId the operation name virtual void launchOperation(const QString& theCmdId); @@ -268,11 +277,6 @@ public: /// \return theAttribute virtual AttributePtr findAttribute(const ObjectPtr& theObject, const GeomShapePtr& theGeomShape); - /// Returns color of the object - /// \param theObject a result of a feature object - /// \param theColor a vector of three values in [0, 255] range - virtual void getColor(const ObjectPtr& theObject, std::vector& theColor); - public slots: /// Redefines the parent method in order to customize the next case: /// If the sketch nested operation is active and the presentation is not visualized in the viewer, @@ -338,6 +342,9 @@ protected: //! Delete features virtual bool deleteObjects(); + /// Returns the workshop + XGUI_Workshop* getWorkshop() const; + private: SelectMgr_ListOfFilter mySelectionFilters; diff --git a/src/SketchPlugin/SketchPlugin_SketchEntity.h b/src/SketchPlugin/SketchPlugin_SketchEntity.h index 58ac7eb9a..20f1e46f7 100644 --- a/src/SketchPlugin/SketchPlugin_SketchEntity.h +++ b/src/SketchPlugin/SketchPlugin_SketchEntity.h @@ -23,7 +23,7 @@ #define SKETCH_ENTITY_COLOR "225,0,0" #define SKETCH_EXTERNAL_COLOR "170,0,225" #define SKETCH_AUXILIARY_COLOR "0,85,0" -#define SKETCH_OVERCONSTRAINT_COLOR "255,0,0" +#define SKETCH_OVERCONSTRAINT_COLOR "0,0,0" /**\class SketchPlugin_SketchEntity * \ingroup Plugins diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 9d9b89300..eebe7c38b 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -567,13 +567,15 @@ void XGUI_Workshop::setPropertyPanel(ModuleBase_Operation* theOperation) return; showPropertyPanel(); - QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation(); - ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myModuleConnector); - myPropertyPanel->cleanContent(); - aFactory.createWidget(myPropertyPanel->contentWidget()); - QList aWidgets = aFactory.getModelWidgets(); + QList aWidgets; + if (!module()->createWidgets(theOperation, aWidgets)) { + QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation(); + ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myModuleConnector); + aFactory.createWidget(myPropertyPanel->contentWidget()); + aWidgets = aFactory.getModelWidgets(); + } // check compatibility of feature and widgets FeaturePtr aFeature = aFOperation->feature();