]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Provide icons for groups with different shape types
authorvsv <vsv@opencascade.com>
Wed, 6 Dec 2017 11:04:09 +0000 (14:04 +0300)
committervsv <vsv@opencascade.com>
Wed, 6 Dec 2017 11:04:09 +0000 (14:04 +0300)
23 files changed:
src/CollectionPlugin/plugin-Collection.xml
src/Config/Config_FeatureMessage.cpp
src/Config/Config_FeatureMessage.h
src/Config/Config_FeatureReader.cpp
src/Config/Config_Keywords.h
src/GeomAPI/GeomAPI_Shape.cpp
src/GeomAPI/GeomAPI_Shape.h
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_IconFactory.cpp
src/PartSet/PartSet_icons.qrc
src/PartSet/icons/group_edge.png [new file with mode: 0644]
src/PartSet/icons/group_face.png [new file with mode: 0644]
src/PartSet/icons/group_solid.png [new file with mode: 0644]
src/PartSet/icons/group_vertex.png [new file with mode: 0644]
src/XGUI/XGUI_ActionsMgr.cpp
src/XGUI/XGUI_ActionsMgr.h
src/XGUI/XGUI_ErrorMgr.cpp
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_PropertyPanel.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h
src/XGUI/XGUI_pictures.qrc
src/XGUI/pictures/button_ok-plus.png [new file with mode: 0644]

index 215a6b60c80fed94227f2cabb2689fe866630b07..156c1bbd48ef703037e91342bebefc143e5ea0f6 100644 (file)
@@ -25,13 +25,14 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
       <feature id="Group"
         title="Group"
         tooltip="Create named collection of geometry entities"
-        icon="icons/Collection/shape_group.png">
+        icon="icons/Collection/shape_group.png"
+        apply_continue="true">
         <source path="group_widget.xml"/>
       </feature>
 
       <feature id="Field"
         title="Field"
-        tooltip="Create create fields for selected shapes"
+        tooltip="Create fields for selected shapes"
         icon="icons/Collection/field.png">
         <field-panel id="selected">
           <validator id="GeomValidators_BodyShapes"/>
index ae86d8b94d2fa9dc2d12ba6f0a090de51f6b2628..c944bc6d4a0045231d48d2f7af8f758310ef9243 100644 (file)
@@ -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
index a4c6105511b5301f98fc00626e1c5c3fb1a3cfe7..3bbe0a5faee628e12cd11e0b6f97dbb9df9d3ee6 100644 (file)
@@ -52,6 +52,7 @@ class Config_FeatureMessage : public Events_Message
   bool myInternal;  ///<Internal feature without GUI representation
   bool myModal;     ///<True if the feature has to be represented by modal dialog box
   bool myIsAutoPreview; ///< Preview computation is performed automatically
+  bool myIsApplyContinue;  ///<True if the feature can have Apply/Continue button in its property panel
 
   std::string myNestedFeatures; ///<Space separated list of child features
   std::string myActionsWhenNested; ///<Space separated list of actions
@@ -104,6 +105,10 @@ class Config_FeatureMessage : public Events_Message
   CONFIG_EXPORT bool isInternal() const;
   /// If true - the feature will be represented by modal dialog box GUI
   CONFIG_EXPORT bool isModal() const;
+  /// If true - the feature can have Apply/Continue button in its property panel
+  CONFIG_EXPORT bool isApplyContinue() const;
+
+
 
   /// If true - preview of the feature is done by any modification of the feature attributes
   CONFIG_EXPORT bool isAutoPreview() const;
@@ -138,6 +143,8 @@ class Config_FeatureMessage : public Events_Message
   CONFIG_EXPORT void setAutoPreview(bool isAutoPreview);
   ///Set modality state; If true - the feature will be represented by modal dialog box GUI
   CONFIG_EXPORT void setModal(bool isModal);
+  ///Set Apply/Continue state; If true - the feature can have Apply/Continue button in its property panel
+  CONFIG_EXPORT void setApplyContinue(bool isModal);
 };
 
 #endif // CONFIG_MESSAGE_H
index 6115d715f7f76d90593e8bc51bebbc8492b78e3d..c0af30ac45e5c9ed4960cfa46e242c7aebaede56 100644 (file)
@@ -161,6 +161,8 @@ void Config_FeatureReader::fillFeature(xmlNodePtr theFeatureNode,
   outFeatureMessage->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);
index cd2253bfec41d639c3d0d32204b94c78e62a5442..2e8261fef44da4f5ab66f704d7f3703c8911f3db 100644 (file)
@@ -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";
index f66a6a1e6f8e9351cfa20cd7e1d0ed40292f488e..f9b01ceb6359f76219384ba4ef34f759fb39c38a 100644 (file)
@@ -129,6 +129,23 @@ bool GeomAPI_Shape::isCompoundOfSolids() const
   return isAtLeastOne;
 }
 
+GeomAPI_Shape::ShapeType GeomAPI_Shape::typeOfCompoundShapes() const
+{
+  const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
+  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<TopoDS_Shape>& theList)
 {
index 242a85bc7fcabca5368a687a771ae9bd57e27294..7a1f999971e30bd9078319421b3a6b80215c648a 100644 (file)
@@ -147,9 +147,13 @@ public:
   GEOMAPI_EXPORT
   bool isIntersect(const std::shared_ptr<GeomAPI_Shape> 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<GeomAPI_Dir> 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
index 8bb95e123773e96885c16eb3ffa570cad42b2c95..389f4904fb89266639dd814f4d8165a018c1213e 100644 (file)
@@ -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}
 )
index 5543d690201d7e1a49a1dc6224db81312b6ded3b..42b3d4d62f6f65b516232f300dbc7f603d3ba098 100644 (file)
@@ -29,6 +29,8 @@
 #include <Config_FeatureMessage.h>
 #include <Events_Loop.h>
 
+#include <CollectionPlugin_Group.h>
+
 QMap<QString, QString> 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<ModelAPI_ResultBody>(aResult);
           if (aBody.get() && aBody->isConnectedTopology())
             return QIcon(":pictures/compoundofsolids.png");
index ae23920e59fd8439e259b7663450189009f51714..9b19b30a5bd8e5887483f9070d98896f11cadbae 100644 (file)
      <file>icons/sketch_shape.png</file>
      <file>icons/expression.png</file>
      <file>icons/paper_roll.png</file>
+
+     <file>icons/group_edge.png</file>
+     <file>icons/group_face.png</file>
+     <file>icons/group_solid.png</file>
+     <file>icons/group_vertex.png</file>
  </qresource>
  </RCC>
diff --git a/src/PartSet/icons/group_edge.png b/src/PartSet/icons/group_edge.png
new file mode 100644 (file)
index 0000000..b670cd4
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 (file)
index 0000000..68d152e
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 (file)
index 0000000..bb5f6ac
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 (file)
index 0000000..63d9ef1
Binary files /dev/null and b/src/PartSet/icons/group_vertex.png differ
index 050b3cef2ffc5811e061c38485121724fd7d2d4c..0d7a57d33a3d337f815ac27dc47066eaf13d84ea 100644 (file)
@@ -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",
index 66e00d7847464c580aa3e705afc8be8feba1a98e..deeb75433e7ba79ae07ebf18ba042c50ad01a141 100644 (file)
@@ -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.
index 5ead6a91dddb364939f278f5b22d9f550c270704..19c1135b9c8c142986d787eba46b2bebee8c625e 100644 (file)
@@ -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
index bdc4792593ea8b0c9439af775711c4f4daa76d9b..e8735b7307c8fb3498673eb4cc2a4fbc714cc3e0 100755 (executable)
@@ -29,6 +29,7 @@
 #include <ModuleBase_WidgetFactory.h>
 #include <ModuleBase_OperationDescription.h>
 #include <ModuleBase_Events.h>
+#include <ModuleBase_IWorkshop.h>
 
 #include <Events_Loop.h>
 
@@ -44,7 +45,6 @@
 #include <QVBoxLayout>
 #include <QGridLayout>
 #include <QWidget>
-#include <QToolButton>
 #include <QAction>
 
 #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<Config_FeatureMessage> 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<XGUI_ActionsMgr::OperationStateActionId> 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));
index 06dfda814035469dbcd770505a386548adb019be..7f1f0b325a467e0f75199e1862fc14394b6babf8 100644 (file)
@@ -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";
 
index e3e1468c2689aec7e781bd8f77e81c87a930ab92..5ab4e495c20c12fa3289256498e04363b969236f 100755 (executable)
@@ -531,6 +531,21 @@ void XGUI_Workshop::onAcceptActionClicked()
   }
 }
 
+//******************************************************
+void XGUI_Workshop::onAcceptPlusActionClicked()
+{
+  QAction* anAction = dynamic_cast<QAction*>(sender());
+  XGUI_OperationMgr* anOperationMgr = operationMgr();
+  if (anOperationMgr) {
+    ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+                                                    (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()));
 
index 871e2df122e9c1792de47a06f0aaf3b9beaa24f7..de4266d845c933eb14b73e3758a6ada5c54d0fd9 100755 (executable)
@@ -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();
index 02d5d716b40138699e5de0e24e356f6d5c61fdc5..879fa44168e43ce829408a17217999722591e62c 100644 (file)
@@ -30,6 +30,7 @@
      <file>pictures/button_help.png</file>
      <file>pictures/button_ok.png</file>
      <file>pictures/button_ok_error.png</file>
+     <file>pictures/button_ok-plus.png</file>
      <file>pictures/button_plus.png</file>
 
      <file>pictures/assembly.png</file>
diff --git a/src/XGUI/pictures/button_ok-plus.png b/src/XGUI/pictures/button_ok-plus.png
new file mode 100644 (file)
index 0000000..e8df2e6
Binary files /dev/null and b/src/XGUI/pictures/button_ok-plus.png differ