From: vsv Date: Wed, 6 Dec 2017 11:04:09 +0000 (+0300) Subject: Provide icons for groups with different shape types X-Git-Tag: V_2.10.1~22^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5a071521a51578639a6ce7c92786eb9bd7afede6;p=modules%2Fshaper.git Provide icons for groups with different shape types --- diff --git a/src/CollectionPlugin/plugin-Collection.xml b/src/CollectionPlugin/plugin-Collection.xml index 215a6b60c..156c1bbd4 100644 --- a/src/CollectionPlugin/plugin-Collection.xml +++ b/src/CollectionPlugin/plugin-Collection.xml @@ -25,13 +25,14 @@ email : webmaster.salome@opencascade.com + icon="icons/Collection/shape_group.png" + apply_continue="true"> diff --git a/src/Config/Config_FeatureMessage.cpp b/src/Config/Config_FeatureMessage.cpp index ae86d8b94..c944bc6d4 100644 --- a/src/Config/Config_FeatureMessage.cpp +++ b/src/Config/Config_FeatureMessage.cpp @@ -36,6 +36,8 @@ Config_FeatureMessage::Config_FeatureMessage(const Events_ID theId, const void* myInternal = false; myUseInput = false; myNestedFeatures = ""; + myModal = false; + myIsApplyContinue = false; } Config_FeatureMessage::~Config_FeatureMessage() @@ -153,6 +155,12 @@ bool Config_FeatureMessage::isModal() const return myModal; } +bool Config_FeatureMessage::isApplyContinue() const +{ + return myIsApplyContinue; +} + + void Config_FeatureMessage::setUseInput(bool isUseInput) { myUseInput = isUseInput; @@ -192,3 +200,8 @@ void Config_FeatureMessage::setAutoPreview(bool isAutoPreview) { myIsAutoPreview = isAutoPreview; } + +void Config_FeatureMessage::setApplyContinue(bool isModal) +{ + myIsApplyContinue = isModal; +} \ No newline at end of file diff --git a/src/Config/Config_FeatureMessage.h b/src/Config/Config_FeatureMessage.h index a4c610551..3bbe0a5fa 100644 --- a/src/Config/Config_FeatureMessage.h +++ b/src/Config/Config_FeatureMessage.h @@ -52,6 +52,7 @@ class Config_FeatureMessage : public Events_Message bool myInternal; ///setModal(getBooleanAttribute(theFeatureNode, FEATURE_MODAL, false)); bool isAutoPreview = getBooleanAttribute(theFeatureNode, FEATURE_AUTO_PREVIEW, true); outFeatureMessage->setAutoPreview(isAutoPreview); + outFeatureMessage->setApplyContinue( + getBooleanAttribute(theFeatureNode, FEATURE_APPLY_CONTINUE, false)); bool isInternal = getBooleanAttribute(theFeatureNode, ATTR_INTERNAL, false); outFeatureMessage->setInternal(isInternal); diff --git a/src/Config/Config_Keywords.h b/src/Config/Config_Keywords.h index cd2253bfe..2e8261fef 100644 --- a/src/Config/Config_Keywords.h +++ b/src/Config/Config_Keywords.h @@ -77,6 +77,7 @@ const static char* FEATURE_WHEN_NESTED_ACCEPT = "accept"; const static char* FEATURE_WHEN_NESTED_ABORT = "abort"; const static char* FEATURE_DOC = WORKBENCH_DOC; const static char* FEATURE_MODAL = "modal"; +const static char* FEATURE_APPLY_CONTINUE = "apply_continue"; const static char* FEATURE_AUTO_PREVIEW = "auto_preview"; // NODE_VALIDATOR properties const static char* _PARAMETERS = "parameters"; diff --git a/src/GeomAPI/GeomAPI_Shape.cpp b/src/GeomAPI/GeomAPI_Shape.cpp index f66a6a1e6..f9b01ceb6 100644 --- a/src/GeomAPI/GeomAPI_Shape.cpp +++ b/src/GeomAPI/GeomAPI_Shape.cpp @@ -129,6 +129,23 @@ bool GeomAPI_Shape::isCompoundOfSolids() const return isAtLeastOne; } +GeomAPI_Shape::ShapeType GeomAPI_Shape::typeOfCompoundShapes() const +{ + const TopoDS_Shape& aShape = const_cast(this)->impl(); + if (aShape.IsNull() || aShape.ShapeType() != TopAbs_COMPOUND) + return SHAPE; + int aType = -1; + for(TopoDS_Iterator aSubs(aShape); aSubs.More(); aSubs.Next()) { + if (!aSubs.Value().IsNull()) { + if (aType == -1) + aType = aSubs.Value().ShapeType(); + else if (aSubs.Value().ShapeType() != aType) + return SHAPE; + } + } + return (GeomAPI_Shape::ShapeType) aType; +} + // adds the nopt-compound elements recursively to the list static void addSimpleToList(const TopoDS_Shape& theShape, NCollection_List& theList) { diff --git a/src/GeomAPI/GeomAPI_Shape.h b/src/GeomAPI/GeomAPI_Shape.h index 242a85bc7..7a1f99997 100644 --- a/src/GeomAPI/GeomAPI_Shape.h +++ b/src/GeomAPI/GeomAPI_Shape.h @@ -147,9 +147,13 @@ public: GEOMAPI_EXPORT bool isIntersect(const std::shared_ptr theShape) const; - // Translates the shape along the direction for the given offset + /// Translates the shape along the direction for the given offset GEOMAPI_EXPORT void translate(const std::shared_ptr theDir, const double theOffset); + + /// Returns type of shapes in the compound. + // If shapes are of different type then it will return SHAPE type + GEOMAPI_EXPORT ShapeType typeOfCompoundShapes() const; }; //! Pointer on list of shapes diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index 8bb95e123..389f4904f 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -159,6 +159,7 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/XGUI ${PROJECT_SOURCE_DIR}/src/FeaturesPlugin ${PROJECT_SOURCE_DIR}/src/PartSetPlugin ${PROJECT_SOURCE_DIR}/src/GeomAPI + ${PROJECT_SOURCE_DIR}/src/CollectionPlugin ${CAS_INCLUDE_DIRS} ${SUIT_INCLUDE} ) diff --git a/src/PartSet/PartSet_IconFactory.cpp b/src/PartSet/PartSet_IconFactory.cpp index 5543d6902..42b3d4d62 100644 --- a/src/PartSet/PartSet_IconFactory.cpp +++ b/src/PartSet/PartSet_IconFactory.cpp @@ -29,6 +29,8 @@ #include #include +#include + QMap PartSet_IconFactory::myIcons; PartSet_IconFactory::PartSet_IconFactory():ModuleBase_IconFactory() @@ -94,6 +96,19 @@ QIcon PartSet_IconFactory::getIcon(ObjectPtr theObj) if(aShape.get()) { switch(aShape->shapeType()) { case GeomAPI_Shape::COMPOUND: { + FeaturePtr aFeature = ModelAPI_Feature::feature(theObj); + if (aFeature.get() && aFeature->getKind() == CollectionPlugin_Group::ID()) { + switch (aShape->typeOfCompoundShapes()) { + case GeomAPI_Shape::VERTEX: + return QIcon(":icons/group_vertex.png"); + case GeomAPI_Shape::EDGE: + return QIcon(":icons/group_edge.png"); + case GeomAPI_Shape::FACE: + return QIcon(":icons/group_face.png"); + case GeomAPI_Shape::SOLID: + return QIcon(":icons/group_solid.png"); + } + } ResultBodyPtr aBody = std::dynamic_pointer_cast(aResult); if (aBody.get() && aBody->isConnectedTopology()) return QIcon(":pictures/compoundofsolids.png"); diff --git a/src/PartSet/PartSet_icons.qrc b/src/PartSet/PartSet_icons.qrc index ae23920e5..9b19b30a5 100644 --- a/src/PartSet/PartSet_icons.qrc +++ b/src/PartSet/PartSet_icons.qrc @@ -14,5 +14,10 @@ icons/sketch_shape.png icons/expression.png icons/paper_roll.png + + icons/group_edge.png + icons/group_face.png + icons/group_solid.png + icons/group_vertex.png diff --git a/src/PartSet/icons/group_edge.png b/src/PartSet/icons/group_edge.png new file mode 100644 index 000000000..b670cd45f Binary files /dev/null and b/src/PartSet/icons/group_edge.png differ diff --git a/src/PartSet/icons/group_face.png b/src/PartSet/icons/group_face.png new file mode 100644 index 000000000..68d152e37 Binary files /dev/null and b/src/PartSet/icons/group_face.png differ diff --git a/src/PartSet/icons/group_solid.png b/src/PartSet/icons/group_solid.png new file mode 100644 index 000000000..bb5f6ac93 Binary files /dev/null and b/src/PartSet/icons/group_solid.png differ diff --git a/src/PartSet/icons/group_vertex.png b/src/PartSet/icons/group_vertex.png new file mode 100644 index 000000000..63d9ef1ca Binary files /dev/null and b/src/PartSet/icons/group_vertex.png differ diff --git a/src/XGUI/XGUI_ActionsMgr.cpp b/src/XGUI/XGUI_ActionsMgr.cpp index 050b3cef2..0d7a57d33 100644 --- a/src/XGUI/XGUI_ActionsMgr.cpp +++ b/src/XGUI/XGUI_ActionsMgr.cpp @@ -255,6 +255,11 @@ QAction* XGUI_ActionsMgr::operationStateAction(OperationStateActionId theId) "Apply" /*empty to show error*/, aParent); } break; + case AcceptPlus: { + aResult = ModuleBase_Tools::createAction(QIcon(":pictures/button_ok-plus.png"), + "Apply and continue" /*empty to show error*/, aParent); + } + break; case Abort: case AbortAll: { aResult = ModuleBase_Tools::createAction(QIcon(":pictures/button_cancel.png"), "Cancel", diff --git a/src/XGUI/XGUI_ActionsMgr.h b/src/XGUI/XGUI_ActionsMgr.h index 66e00d784..deeb75433 100644 --- a/src/XGUI/XGUI_ActionsMgr.h +++ b/src/XGUI/XGUI_ActionsMgr.h @@ -61,10 +61,11 @@ class XGUI_EXPORT XGUI_ActionsMgr : public QObject, public Events_Listener enum OperationStateActionId { Abort = 0, Accept = 1, - Help = 2, - AbortAll = 3, - AcceptAll = 4, - Preview = 5 + AcceptPlus = 2, + Help = 3, + AbortAll = 4, + AcceptAll = 5, + Preview = 6 }; //! Add a command in the manager. diff --git a/src/XGUI/XGUI_ErrorMgr.cpp b/src/XGUI/XGUI_ErrorMgr.cpp index 5ead6a91d..19c1135b9 100644 --- a/src/XGUI/XGUI_ErrorMgr.cpp +++ b/src/XGUI/XGUI_ErrorMgr.cpp @@ -160,12 +160,15 @@ void XGUI_ErrorMgr::updateAcceptActionState(const QString& theError) { XGUI_ActionsMgr* anActionsMgr = workshop()->actionsMgr(); QAction* anAcceptAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::Accept); + QAction* anAcceptPlusAction = + anActionsMgr->operationStateAction(XGUI_ActionsMgr::AcceptPlus); if (myAcceptAllToolTip.isEmpty() && myAcceptToolTip.isEmpty()) storeInitialActionValues(); bool anEnabled = theError.isEmpty(); anAcceptAction->setEnabled(anEnabled); + anAcceptPlusAction->setEnabled(anEnabled); anAcceptAction->setToolTip(anEnabled ? myAcceptToolTip : theError); anAcceptAction->setStatusTip(anEnabled ? myAcceptStatusTip : theError); // some operations have no property panel, so it is important to check that it is not null diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index bdc479259..e8735b730 100755 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -44,7 +45,6 @@ #include #include #include -#include #include #ifdef _DEBUG @@ -86,6 +86,7 @@ XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent, XGUI_OperationMgr* th QStringList aBtnNames; aBtnNames << QString(PROP_PANEL_HELP) << QString(PROP_PANEL_OK) + << QString(PROP_PANEL_OK_PLUS) << QString(PROP_PANEL_CANCEL); foreach(QString eachBtnName, aBtnNames) { QToolButton* aBtn = new QToolButton(aFrm); @@ -209,6 +210,9 @@ void XGUI_PropertyPanel::createContentPanel(FeaturePtr theFeature) /// Apply button should be update if the feature was modified by the panel myOperationMgr->onValidateOperation(); } + std::shared_ptr aFeatureInfo = + myOperationMgr->workshop()->featureInfo(theFeature->getKind().c_str()); + findButton(PROP_PANEL_OK_PLUS)->setVisible(aFeatureInfo->isApplyContinue()); } void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget) @@ -382,11 +386,11 @@ bool XGUI_PropertyPanel::focusNextPrevChild(bool theIsNext) findDirectChildren(this, aChildren, true); int aChildrenCount = aChildren.count(); int aFocusWidgetIndex = aChildren.indexOf(aFocusWidget); + QToolButton* anOkBtn = findButton(PROP_PANEL_OK); if (aFocusWidgetIndex >= 0) { if (theIsNext) { if (aFocusWidgetIndex == aChildrenCount-1) { // after the last widget focus should be set to "Apply" - QToolButton* anOkBtn = findButton(PROP_PANEL_OK); if (anOkBtn->isEnabled()) aNewFocusWidget = anOkBtn; else { @@ -406,7 +410,6 @@ bool XGUI_PropertyPanel::focusNextPrevChild(bool theIsNext) } else { // before the "Apply" button, the last should accept focus for consistency with "Next" - QToolButton* anOkBtn = findButton(PROP_PANEL_OK); if (aFocusWidget == anOkBtn) { aNewFocusWidget = aChildren[aChildrenCount - 1]; } @@ -515,10 +518,11 @@ void XGUI_PropertyPanel::setEditingMode(bool isEditing) void XGUI_PropertyPanel::setupActions(XGUI_ActionsMgr* theMgr) { QStringList aButtonNames; - aButtonNames << PROP_PANEL_OK << PROP_PANEL_CANCEL << PROP_PANEL_HELP << PROP_PANEL_PREVIEW; + aButtonNames << PROP_PANEL_OK<< PROP_PANEL_OK_PLUS << PROP_PANEL_CANCEL + << PROP_PANEL_HELP << PROP_PANEL_PREVIEW; QList aActionIds; - aActionIds << XGUI_ActionsMgr::Accept << XGUI_ActionsMgr::Abort << XGUI_ActionsMgr::Help - << XGUI_ActionsMgr::Preview; + aActionIds << XGUI_ActionsMgr::Accept << XGUI_ActionsMgr::AcceptPlus << XGUI_ActionsMgr::Abort + << XGUI_ActionsMgr::Help << XGUI_ActionsMgr::Preview; for (int i = 0; i < aButtonNames.size(); ++i) { QToolButton* aBtn = findButton(aButtonNames.at(i).toStdString().c_str()); QAction* anAct = theMgr->operationStateAction(aActionIds.at(i)); diff --git a/src/XGUI/XGUI_PropertyPanel.h b/src/XGUI/XGUI_PropertyPanel.h index 06dfda814..7f1f0b325 100644 --- a/src/XGUI/XGUI_PropertyPanel.h +++ b/src/XGUI/XGUI_PropertyPanel.h @@ -42,6 +42,9 @@ const static char* PROP_PANEL = "property_panel_dock"; /// Internal name of Ok button const static char* PROP_PANEL_OK = "property_panel_ok"; +/// Internal name of Ok button +const static char* PROP_PANEL_OK_PLUS = "property_panel_ok_plus"; + /// Internal name of Cancel button const static char* PROP_PANEL_CANCEL = "property_panel_cancel"; diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index e3e1468c2..5ab4e495c 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -531,6 +531,21 @@ void XGUI_Workshop::onAcceptActionClicked() } } +//****************************************************** +void XGUI_Workshop::onAcceptPlusActionClicked() +{ + QAction* anAction = dynamic_cast(sender()); + XGUI_OperationMgr* anOperationMgr = operationMgr(); + if (anOperationMgr) { + ModuleBase_OperationFeature* aFOperation = dynamic_cast + (anOperationMgr->currentOperation()); + if (aFOperation) { + myOperationMgr->commitOperation(); + module()->launchOperation(aFOperation->id(), false); + } + } +} + //****************************************************** void XGUI_Workshop::onPreviewActionClicked() { @@ -1327,6 +1342,9 @@ void XGUI_Workshop::createDockWidgets() QAction* aOkAct = myActionsMgr->operationStateAction(XGUI_ActionsMgr::Accept); connect(aOkAct, SIGNAL(triggered()), this, SLOT(onAcceptActionClicked())); + QAction* aOkContAct = myActionsMgr->operationStateAction(XGUI_ActionsMgr::AcceptPlus); + connect(aOkContAct, SIGNAL(triggered()), this, SLOT(onAcceptPlusActionClicked())); + QAction* aCancelAct = myActionsMgr->operationStateAction(XGUI_ActionsMgr::Abort); connect(aCancelAct, SIGNAL(triggered()), myOperationMgr, SLOT(onAbortOperation())); diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 871e2df12..de4266d84 100755 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -484,6 +484,10 @@ private: /// the operation can be committed and do it if it returns true. void onAcceptActionClicked(); + /// Called by OkPlus button clicked in the property panel. Asks the error manager whether + /// the operation can be committed and do it if it returns true. + void onAcceptPlusActionClicked(); + /// Called by Preview button clicked in the property panel. Sends signal to model to /// compute preview. void onPreviewActionClicked(); diff --git a/src/XGUI/XGUI_pictures.qrc b/src/XGUI/XGUI_pictures.qrc index 02d5d716b..879fa4416 100644 --- a/src/XGUI/XGUI_pictures.qrc +++ b/src/XGUI/XGUI_pictures.qrc @@ -30,6 +30,7 @@ pictures/button_help.png pictures/button_ok.png pictures/button_ok_error.png + pictures/button_ok-plus.png pictures/button_plus.png pictures/assembly.png diff --git a/src/XGUI/pictures/button_ok-plus.png b/src/XGUI/pictures/button_ok-plus.png new file mode 100644 index 000000000..e8df2e624 Binary files /dev/null and b/src/XGUI/pictures/button_ok-plus.png differ