]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
#20441 : Improved algo performance and add translation
authorlucasjerome <jerome.lucas@cegsenslab.fr>
Wed, 23 Dec 2020 18:21:08 +0000 (19:21 +0100)
committerlucasjerome <jerome.lucas@cegsenslab.fr>
Wed, 23 Dec 2020 18:21:08 +0000 (19:21 +0100)
src/FeaturesPlugin/FeaturesPlugin_CommonSharedFaces.cpp
src/FeaturesPlugin/FeaturesPlugin_CommonSharedFaces.h
src/FeaturesPlugin/FeaturesPlugin_GroupSharedFaces.cpp
src/FeaturesPlugin/FeaturesPlugin_GroupSharedFaces.h
src/FeaturesPlugin/FeaturesPlugin_SharedFaces.cpp
src/FeaturesPlugin/FeaturesPlugin_SharedFaces.h
src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts
src/FeaturesPlugin/shared_Faces_macro_widget.xml
src/FeaturesPlugin/shared_Faces_widget.xml
src/ModuleBase/ModuleBase_WidgetLabel.cpp
src/ModuleBase/ModuleBase_WidgetLabel.h

index 0cd9bc0dfff34aa3448ef0493c2046dab74062aa..f3fe8ca049fc0168152b912eff6b0cb406e330cf 100644 (file)
@@ -22,6 +22,7 @@
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeBoolean.h>
 #include <ModelAPI_Attribute.h>
 
 #include <ModelAPI_Data.h>
@@ -51,11 +52,18 @@ void FeaturesPlugin_CommonSharedFaces::updateFaces()
                   std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>
                                                       (attributListFaces());
 
-  if (aFacesListAttr->isInitialized())
-        aFacesListAttr->clear();
-
   GeomShapePtr aShape = ancompSolidAttr->value();
-  if (aShape.get() && ancompSolidAttr->context().get()) {
+
+  AttributeBooleanPtr anIsCompute =
+            std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(attributIsCompute());
+  if (!anIsCompute->value()) {
+    myShape = aShape;
+    anIsCompute->setValue(true);
+  }
+  if (aShape.get() && ancompSolidAttr->context().get() && !aShape->isEqual(myShape)) {
+
+    if (aFacesListAttr->isInitialized())
+        aFacesListAttr->clear();
 
     aShape = ancompSolidAttr->context()->shape();
     if (aShape) {
@@ -70,6 +78,7 @@ void FeaturesPlugin_CommonSharedFaces::updateFaces()
                           anError))
         setError("Error in GetSharedFaces calculation :" +  anError);
 
+      myShape = aShape;
       aFacesListAttr->setSelectionType("face");
 
       ListOfShape::const_iterator anIt = aFaces.cbegin();
@@ -83,7 +92,7 @@ void FeaturesPlugin_CommonSharedFaces::updateFaces()
         aFacesListAttr->append( ancompSolidAttr->context(), aFacePtr);
       }
       std::stringstream alabel;
-      alabel << "Number of shared faces : " << aFacesListAttr->size();
+      alabel << aFacesListAttr->size();
       AttributeStringPtr aNumberFacesAttr =
                   std::dynamic_pointer_cast<ModelAPI_AttributeString>
                                                       (attributNumberFaces());
index dabe7c706335622c669a503b9f25b72f4b270152..a3ad2b5243cbf8dd210bdae7cf565fe040c19e66 100644 (file)
@@ -49,6 +49,9 @@ public:
   /// Return Attribut values of result.
   virtual AttributePtr attributNumberFaces() = 0;
 
+  /// Return Attribut values of IsCompute.
+  virtual AttributePtr attributIsCompute() = 0;
+
   protected:
   FeaturesPlugin_CommonSharedFaces() {}
 
@@ -58,6 +61,9 @@ public:
   // Update the list of faces
   void updateFaces();
 
+  // the shape studied
+  GeomShapePtr myShape;
+
 };
 
 #endif
index 0bdc7208f898f59e28e8c8b819e13de3af2b7445..0dd6a3609ed91df9258fe3cf4ff2baa0cd363c5d 100644 (file)
@@ -57,8 +57,12 @@ void FeaturesPlugin_GroupSharedFaces::initAttributes()
   data()->addAttribute(NUMBER_FACES_ID(), ModelAPI_AttributeString::typeId());
   data()->addAttribute(TRANSPARENCY_ID(), ModelAPI_AttributeInteger::typeId());
   data()->addAttribute(GROUP_NAME_ID(), ModelAPI_AttributeString::typeId());
+  data()->addAttribute(COMPUTE_ID(), ModelAPI_AttributeBoolean::typeId());
 
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TRANSPARENCY_ID());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), COMPUTE_ID());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), NUMBER_FACES_ID());
+  data()->boolean(COMPUTE_ID())->setValue(true);
 
 }
 
@@ -69,6 +73,12 @@ AttributePtr FeaturesPlugin_GroupSharedFaces::attributObject()
   return attribute(OBJECT_ID());
 }
 
+//=================================================================================================
+AttributePtr FeaturesPlugin_GroupSharedFaces::attributIsCompute()
+{
+  return attribute(COMPUTE_ID());
+}
+
 //=================================================================================================
 AttributePtr FeaturesPlugin_GroupSharedFaces::attributListFaces()
 {
index b243b43d9ed15cba111a77ab1ae7679d98100b4e..fc51d79cb329e18b1a0087f821ed32a009a8395e 100644 (file)
@@ -76,6 +76,13 @@ public:
     return MY_GROUP_NAME_ID;
   }
 
+  /// Attribute name for indicate to launch the algo.
+  inline static const std::string& COMPUTE_ID()
+  {
+    static const std::string MY_COMPUTE_ID("compute");
+    return MY_COMPUTE_ID;
+  }
+
   /// Performs the algorithm and stores results it in the data structure.
   FEATURESPLUGIN_EXPORT virtual void execute();
 
@@ -100,6 +107,9 @@ public:
   /// Return Attribut values of number of faces.
   virtual AttributePtr attributNumberFaces();
 
+  /// Return Attribut values of IsCompute.
+  virtual AttributePtr attributIsCompute();
+
 };
 
 #endif
index e80ecf1a3030a0bf588b12dc5a615315fd947c9e..ba4b9be1dd3fc9236cfffea0b40365c213f7a400 100644 (file)
@@ -60,10 +60,18 @@ void FeaturesPlugin_SharedFaces::initAttributes()
   data()->addAttribute(TRANSPARENCY_ID(), ModelAPI_AttributeInteger::typeId());
   data()->addAttribute(CREATE_GROUP_ID(), ModelAPI_AttributeBoolean::typeId());
   data()->addAttribute(GROUP_NAME_ID(), ModelAPI_AttributeString::typeId());
+  data()->addAttribute(COMPUTE_ID(), ModelAPI_AttributeBoolean::typeId());
 
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), GROUP_NAME_ID());
+  ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), COMPUTE_ID());
+  data()->boolean(COMPUTE_ID())->setValue(true);
 }
 
+//=================================================================================================
+AttributePtr FeaturesPlugin_SharedFaces::attributIsCompute()
+{
+  return attribute(COMPUTE_ID());
+}
 
 //=================================================================================================
 AttributePtr FeaturesPlugin_SharedFaces::attributObject()
@@ -161,15 +169,24 @@ void FeaturesPlugin_SharedFaces::createGroup()
 //=================================================================================================
 void FeaturesPlugin_SharedFaces::updateGroup()
 {
+    myCreateGroupFeature->boolean(FeaturesPlugin_GroupSharedFaces::COMPUTE_ID())->setValue(false);
     myCreateGroupFeature->string(FeaturesPlugin_GroupSharedFaces::GROUP_NAME_ID())
                           ->setValue( string(GROUP_NAME_ID())->value());
 
     myCreateGroupFeature->selection(FeaturesPlugin_GroupSharedFaces::OBJECT_ID())
                           ->setValue( selection(OBJECT_ID())->context() ,
                                       selection(OBJECT_ID())->value() );
+    AttributeSelectionListPtr aFacesFeatures =
+      std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>
+                               (myCreateGroupFeature->attribute(LIST_FACES_ID()));
+    AttributeSelectionListPtr aFaces =
+      std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(attribute(LIST_FACES_ID()));
+
+    aFaces->copyTo(aFacesFeatures);
 
     myCreateGroupFeature->integer(FeaturesPlugin_GroupSharedFaces::TRANSPARENCY_ID())
                           ->setValue( integer(TRANSPARENCY_ID())->value());
 
     myCreateGroupFeature->execute();
+    myCreateGroupFeature->boolean(FeaturesPlugin_GroupSharedFaces::COMPUTE_ID())->setValue(true);
 }
\ No newline at end of file
index 5fc5d45aaf531babc16992e651ae0de2efa52b65..815515c764a4a62684b4b97869b79ea43386d49e 100644 (file)
@@ -76,6 +76,13 @@ public:
     return MY_CREATE_GROUP_ID;
   }
 
+  /// Attribute name for indicate to launch the algo.
+  inline static const std::string& COMPUTE_ID()
+  {
+    static const std::string MY_COMPUTE_ID("compute");
+    return MY_COMPUTE_ID;
+  }
+
   /// Attribute name for group name.
   inline static const std::string& GROUP_NAME_ID()
   {
@@ -110,6 +117,9 @@ public:
   /// Return Attribut values of number of faces.
   virtual AttributePtr attributNumberFaces();
 
+  /// Return Attribut values of IsCompute.
+  virtual AttributePtr attributIsCompute();
+
   /// Create group
   void createGroup();
 
index 6f821a2e2fa1c59eadfbf68ab80c4f2e9fbd427a..55be09ba6a926f2e47bc7e9a59f252ea07edb349 100644 (file)
       <source>Rotation</source>
       <translation>Rotation</translation>
     </message>
+    <message>
+      <source>Check shared faces</source>
+      <translation>Vérifier les faces partagées</translation>
+    </message>
     <message>
       <source>Symmetry</source>
       <translation>Symétrie</translation>
     </message>
   </context>
 
+  <!-- Check shared faces -->
+  <context>
+    <name>Shared_faces_macro</name>
+    <message>
+      <source>Check shared faces</source>
+      <translation>Vérifier les faces partagées</translation>
+    </message>
+    <message>
+      <source>Shared faces</source>
+      <translation>Faces partagées</translation>
+    </message>
+    <message>
+      <source>Number of shared faces : </source>
+      <translation>Nombre de face partagées : </translation>
+    </message>
+  </context>
+  <context>
+    <name>Shared_faces_macro:create_group</name>
+    <message>
+      <source>Create group</source>
+      <translation>Créer un groupe</translation>
+    </message>
+  </context>
+  <context>
+      <name>Shared_faces_macro:group_name</name>
+    <message>
+      <source>Group name</source>
+      <translation>Nom du groupe</translation>
+    </message>
+  </context>
+  <context>
+    <name>Shared_faces_macro:main_object</name>
+    <message>
+      <source>Object</source>
+      <translation>Objet</translation>
+    </message>
+    <message>
+      <source>Shared faces</source>
+      <translation>Faces partagées</translation>
+    </message>
+  </context>
+  <context>
+      <name>Shared_faces_macro:group_list</name>
+    <message>
+      <source>Shared faces</source>
+      <translation>Faces partagées</translation>
+    </message>   
+    <message>
+      <source>List of faces :</source>
+      <translation>Liste des faces :</translation>
+    </message>
+  </context>
+  <context>
+    <name>Shared_faces_macro:transparency</name>
+    <message>
+      <source>Transparency</source>
+      <translation>Transparence</translation>
+    </message>
+  </context>
+  <context>
+    <name>Shared_faces</name>
+    <message>
+      <source>Check shared faces</source>
+      <translation>Vérifier les faces partagées</translation>
+    </message>
+    <message>
+      <source>Shared faces</source>
+      <translation>Faces partagées</translation>
+    </message>
+    <message>
+      <source>Number of shared faces : </source>
+      <translation>Nombre de face partagées : </translation>
+    </message>
+  </context>
+  <context>
+    <name>Shared_faces:create_group</name>
+    <message>
+      <source>Create group</source>
+      <translation>Créer un groupe</translation>
+    </message>
+  </context>
+  <context>
+      <name>Shared_faces:group_name</name>
+    <message>
+      <source>Group name</source>
+      <translation>Nom du groupe</translation>
+    </message>
+  </context>
+  <context>
+    <name>Shared_faces:main_object</name>
+    <message>
+      <source>Object</source>
+      <translation>Objet</translation>
+    </message>
+    <message>
+      <source>Shared faces</source>
+      <translation>Faces partagées</translation>
+    </message>
+  </context>
+  <context>
+      <name>Shared_faces:group_list</name>
+    <message>
+      <source>Shared faces</source>
+      <translation>Faces partagées</translation>
+    </message>   
+    <message>
+      <source>List of faces :</source>
+      <translation>Liste des faces :</translation>
+    </message>
+  </context>
+  <context>
+    <name>Shared_faces:transparency</name>
+    <message>
+      <source>Transparency</source>
+      <translation>Transparence</translation>
+    </message>
+  </context>
+
   <!-- Symmetry -->
   <context>
     <name>Symmetry</name>
index 9fc5197f53ae2d0fae77ce9e851ea0db5e7f7709..99dd120ceb128fab45ff2e2f050ea34afa484a9e 100644 (file)
@@ -9,9 +9,9 @@
     <validator id="GeomValidators_ShapeType" parameters="compsolid,compound"/>
   </shape_selector>
   <groupbox title="Shared faces">
-    <label id="number_shared_faces"/>
+    <label id="number_shared_faces" label="Number of shared faces : "/>
     <multi_selector id="group_list"
-                      label="Liste of faces :"
+                      label="List of faces :"
                       icon=""
                       shape_types="faces"
                       Block_selection = "true"
@@ -28,7 +28,7 @@
                     default="50">
   </integervalue>
   <optionalbox id="create_group" title="Create group" show_title="true">
-    <stringvalue id="group_name" label="Group Name"/>
+    <stringvalue id="group_name" label="Group name"/>
     <label/>
   </optionalbox>
 </source>
index 6ab30bd94e007112a170b4a460f30359d5521688..802831b8a21d1faca21d290e8812d60cf6ecb162 100644 (file)
@@ -9,9 +9,9 @@
     <validator id="GeomValidators_ShapeType" parameters="compsolid,compound"/>
   </shape_selector>
   <groupbox title="Shared faces">
-    <label id="number_shared_faces"/>
+    <label id="number_shared_faces" label="Number of shared faces : "/>
     <multi_selector id="group_list"
-                      label="Liste of faces :"
+                      label="List of faces :"
                       icon=""
                       shape_types="faces"
                       Block_selection = "true"
@@ -27,5 +27,5 @@
                     step="10"
                     default="50">
   </integervalue>
-  <stringvalue id="group_name" label="Group Name"/>
+  <stringvalue id="group_name" label="Group name"/>
 </source>
index 7a47835c8a1b984de1fdc6aa9939ef5db144f1f2..9ae109591b4da8a01b3fcfaa6804fd9afd555510 100644 (file)
@@ -37,6 +37,9 @@ ModuleBase_WidgetLabel::ModuleBase_WidgetLabel(QWidget* theParent,
 : ModuleBase_ModelWidget(theParent, theData)
 {
   QString aText = translate(theData->getProperty("title"));
+
+  myPrefix  = theData->getProperty(ATTR_LABEL);
+
   bool aIsHtml = theData->getBooleanAttribute(ATTR_HTML_STYLE, false);
 
   QString aLabelIcon = QString::fromStdString(theData->getProperty("icon"));
@@ -95,7 +98,11 @@ bool ModuleBase_WidgetLabel::restoreValueCustom()
         aText = ModuleBase_Tools::translate(myFeature->getKind(), aMsg);
       }
     }
-    myLabel->setText(aText);
+    if (myPrefix == "") {
+      myLabel->setText(aText);
+    } else {
+      myLabel->setText( ModuleBase_Tools::translate(myFeature->getKind(), myPrefix) + aText);
+    }
   }
   return true;
 }
index be90456c0c49989f467758f874bb8d37fdfc4592..6c01efad9cd49faf5ee4409c8e76e89af21e33f6 100644 (file)
@@ -61,6 +61,8 @@ protected:
 
   /// A label control
   QLabel* myLabel;
+  /// prefix for label
+  std::string myPrefix;
 };
 
 #endif