]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
#20442 : Improved algo performance and add translation CEA_2020/Lot2_DuplicatedFaces
authorlucasjerome <jerome.lucas@cegsenslab.fr>
Wed, 23 Dec 2020 19:13:30 +0000 (20:13 +0100)
committerlucasjerome <jerome.lucas@cegsenslab.fr>
Wed, 23 Dec 2020 19:13:30 +0000 (20:13 +0100)
src/FeaturesPlugin/FeaturesPlugin_CommonDuplicatedFaces.cpp
src/FeaturesPlugin/FeaturesPlugin_CommonDuplicatedFaces.h
src/FeaturesPlugin/FeaturesPlugin_DuplicatedFaces.cpp
src/FeaturesPlugin/FeaturesPlugin_DuplicatedFaces.h
src/FeaturesPlugin/FeaturesPlugin_GroupDuplicatedFaces.cpp
src/FeaturesPlugin/FeaturesPlugin_GroupDuplicatedFaces.h
src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts
src/FeaturesPlugin/duplicated_faces_macro_widget.xml
src/FeaturesPlugin/duplicated_faces_widget.xml
src/ModuleBase/ModuleBase_WidgetLabel.cpp
src/ModuleBase/ModuleBase_WidgetLabel.h

index 93e7f4a6676512e4d2bec976747fa3b1c58a2939..4dbf10a126fc22fc391504c63d93876cf420d4cb 100644 (file)
@@ -23,6 +23,7 @@
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeString.h>
 #include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeBoolean.h>
 #include <ModelAPI_Attribute.h>
 
 #include <ModelAPI_Data.h>
@@ -62,15 +63,23 @@ void FeaturesPlugin_CommonDuplicatedFaces::updateFaces()
               std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>
                                                 (attributListFaces());
 
-  if (aFacesListAttr->isInitialized())
-      aFacesListAttr->clear();
-  
+  GeomShapePtr aShape = ancompSolidAttr->value();
+
   AttributeDoublePtr aToleranceAttr =
               std::dynamic_pointer_cast<ModelAPI_AttributeDouble>
                                                 (attributTolerance());
 
-  GeomShapePtr aShape = ancompSolidAttr->value();
-  if (aShape.get() && ancompSolidAttr->context().get() && aToleranceAttr.get()) {
+  AttributeBooleanPtr anIsCompute =
+            std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(attributIsCompute());
+  if (!anIsCompute->value()) {
+    myShape = aShape;
+    anIsCompute->setValue(true);
+  }
+  if (aShape.get() && ancompSolidAttr->context().get()
+                   && aToleranceAttr.get() && !aShape->isEqual(myShape)) {
+
+    if (aFacesListAttr->isInitialized())
+      aFacesListAttr->clear();
 
     aShape = ancompSolidAttr->context()->shape();
     if (aShape) {
@@ -85,6 +94,7 @@ void FeaturesPlugin_CommonDuplicatedFaces::updateFaces()
                               anError))
         setError("Error in duplicated faces calculation :" +  anError);
 
+      myShape = aShape;
       aFacesListAttr->setSelectionType("face");
 
       ListOfShape::const_iterator anIt = aFaces.cbegin();
@@ -98,7 +108,7 @@ void FeaturesPlugin_CommonDuplicatedFaces::updateFaces()
         aFacesListAttr->append(ancompSolidAttr->context(), aFacePtr);
       }
       std::stringstream alabel;
-      alabel << "Number of duplicated faces : " << aFacesListAttr->size();
+      alabel << aFacesListAttr->size();
       AttributeStringPtr aNumberFacesAttr =
                   std::dynamic_pointer_cast<ModelAPI_AttributeString>
                                                       (attributNumberFaces());
index 4333f34c42fabd89c7ae58ecfe81886a406f8735..30ae3211b99b85ae8957fa70581458ebc47da5a6 100644 (file)
@@ -52,6 +52,9 @@ public:
   /// Return Attribut values of tolerance.
   virtual AttributePtr attributTolerance() = 0;
 
+  /// Return Attribut values of IsCompute.
+  virtual AttributePtr attributIsCompute() = 0;
+
   protected:
   FeaturesPlugin_CommonDuplicatedFaces() {}
 
@@ -61,6 +64,9 @@ public:
   // Update the list of faces
   void updateFaces();
 
+  // the shape studied
+  GeomShapePtr myShape;
+
 };
 
 #endif
index 6a409fee63043cda4d1b4a5caa61ed0e98b61a83..687ec225ecf116a5bff3048e9b401b3a3d3c2e6e 100644 (file)
@@ -59,10 +59,19 @@ void FeaturesPlugin_DuplicatedFaces::initAttributes()
   data()->addAttribute(TOLERANCE_ID(), ModelAPI_AttributeDouble::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_DuplicatedFaces::attributIsCompute()
+{
+  return attribute(COMPUTE_ID());
+}
 
 //=================================================================================================
 AttributePtr FeaturesPlugin_DuplicatedFaces::attributObject()
@@ -167,6 +176,8 @@ void FeaturesPlugin_DuplicatedFaces::createGroup()
 //=================================================================================================
 void FeaturesPlugin_DuplicatedFaces::updateGroup()
 {
+    myCreateGroupFeature->
+                      boolean(FeaturesPlugin_GroupDuplicatedFaces::COMPUTE_ID())->setValue(false);
     myCreateGroupFeature->string(FeaturesPlugin_GroupDuplicatedFaces::GROUP_NAME_ID())
                           ->setValue(string(GROUP_NAME_ID())->value());
 
@@ -174,6 +185,14 @@ void FeaturesPlugin_DuplicatedFaces::updateGroup()
                           ->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_GroupDuplicatedFaces::TRANSPARENCY_ID())
                           ->setValue(integer(TRANSPARENCY_ID())->value());
 
@@ -181,4 +200,6 @@ void FeaturesPlugin_DuplicatedFaces::updateGroup()
                           ->setValue(real(TOLERANCE_ID())->value());
 
     myCreateGroupFeature->execute();
+    myCreateGroupFeature
+            ->boolean(FeaturesPlugin_GroupDuplicatedFaces::COMPUTE_ID())->setValue(true);
 }
\ No newline at end of file
index b581728792e4843a8654371f29a6383cc3434df4..5081e8ee817c66170f7cfc68d4f4e7c2e2ebe91a 100644 (file)
@@ -55,7 +55,7 @@ public:
     return MY_NUMBER_FACES_ID;
   }
 
-  /// Attribute name for list of faces.
+  /// Attribute name for z coodinate.
   inline static const std::string& LIST_FACES_ID()
   {
     static const std::string MY_LIST_FACES_ID("group_list");
@@ -90,6 +90,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();
 
@@ -120,6 +127,9 @@ public:
   /// Return Attribut values of tolerance.
   virtual AttributePtr attributTolerance();
 
+  /// Return Attribut values of IsCompute.
+  virtual AttributePtr attributIsCompute();
+
   /// Create group
   void createGroup();
 
index bcfa8364820354b260e1fd19631edd6f7a9155bf..7f0d05f1ca9dd3f07fd46a291dc7e7d68ef1d7df 100644 (file)
@@ -60,9 +60,13 @@ void FeaturesPlugin_GroupDuplicatedFaces::initAttributes()
   data()->addAttribute(TRANSPARENCY_ID(), ModelAPI_AttributeInteger::typeId());
   data()->addAttribute(TOLERANCE_ID(), ModelAPI_AttributeDouble::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(), 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);
 }
 
 
@@ -72,6 +76,12 @@ AttributePtr FeaturesPlugin_GroupDuplicatedFaces::attributObject()
   return attribute(OBJECT_ID());
 }
 
+//=================================================================================================
+AttributePtr FeaturesPlugin_GroupDuplicatedFaces::attributIsCompute()
+{
+  return attribute(COMPUTE_ID());
+}
+
 //=================================================================================================
 AttributePtr FeaturesPlugin_GroupDuplicatedFaces::attributListFaces()
 {
@@ -117,7 +127,7 @@ void FeaturesPlugin_GroupDuplicatedFaces::execute()
     if(integer(TRANSPARENCY_ID())->isInitialized()){
       double aTranparency = integer(TRANSPARENCY_ID())->value()/100.0;
       ModelAPI_Tools::setTransparency(aResult, aTranparency);
-    
+
 
       ResultBodyPtr aResultBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aResult);
       std::list<ResultPtr> allRes;
index e8d261ceaa3baf2acb525361ba0b9125eaa7ef93..828137fae0941d294b867ddbddfebb8ec7a30bcc 100644 (file)
@@ -83,6 +83,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();
 
@@ -110,6 +117,9 @@ public:
   /// Return Attribut values of tolerance.
   virtual AttributePtr attributTolerance();
 
+  /// Return Attribut values of IsCompute.
+  virtual AttributePtr attributIsCompute();
+
 };
 
 #endif
index 6f821a2e2fa1c59eadfbf68ab80c4f2e9fbd427a..f14f2fc0b369cf7044bd7b0b29335b90e3022ab6 100644 (file)
       <source>Rotation</source>
       <translation>Rotation</translation>
     </message>
+    <message>
+      <source>Check duplicated faces</source>
+      <translation>Vérifier les faces dupliquées</translation>
+    </message>
     <message>
       <source>Symmetry</source>
       <translation>Symétrie</translation>
     </message>
   </context>
 
+  <!-- Check duplicated faces -->
+  <context>
+    <name>Duplicated_faces_macro</name>
+    <message>
+      <source>Check duplicated faces</source>
+      <translation>Vérifier les faces dupliquées</translation>
+    </message>
+    <message>
+      <source>Duplicated faces</source>
+      <translation>Faces dupliquées</translation>
+    </message>
+    <message>
+      <source>Number of duplicated faces : </source>
+      <translation>Nombre de faces dupliquées : </translation>
+    </message>
+  </context>
+  <context>
+    <name>Duplicated_faces_macro:create_group</name>
+    <message>
+      <source>Create group</source>
+      <translation>Créer un groupe</translation>
+    </message>
+  </context>
+  <context>
+      <name>Duplicated_faces_macro:group_name</name>
+    <message>
+      <source>Group name</source>
+      <translation>Nom du groupe</translation>
+    </message>
+  </context>
+  <context>
+    <name>Duplicated_faces_macro:main_object</name>
+    <message>
+      <source>Object</source>
+      <translation>Objet</translation>
+    </message>
+    <message>
+      <source>Duplicated faces</source>
+      <translation>Faces dupliquées</translation>
+    </message>
+  </context>
+  <context>
+      <name>Duplicated_faces_macro:group_list</name>
+    <message>
+      <source>Duplicated faces</source>
+      <translation>Faces dupliquées</translation>
+    </message>   
+    <message>
+      <source>List of faces :</source>
+      <translation>Liste des faces :</translation>
+    </message>
+  </context>
+  <context>
+    <name>Duplicated_faces_macro:transparency</name>
+    <message>
+      <source>Transparency</source>
+      <translation>Transparence</translation>
+    </message>
+  </context>
+  <context>
+    <name>Duplicated_faces_macro:tolerance</name>
+    <message>
+      <source>Tolerance</source>
+      <translation>Tolérance</translation>
+    </message>
+  </context>
+  <context>
+    <name>Duplicated_faces</name>
+    <message>
+      <source>Check duplicated faces</source>
+      <translation>Vérifier les faces dupliquées</translation>
+    </message>
+    <message>
+      <source>Duplicated faces</source>
+      <translation>Faces dupliquées</translation>
+    </message>
+    <message>
+      <source>Number of duplicated faces : </source>
+      <translation>Nombre de faces dupliquées : </translation>
+    </message>
+  </context>
+  <context>
+    <name>Duplicated_faces:create_group</name>
+    <message>
+      <source>Create group</source>
+      <translation>Créer un groupe</translation>
+    </message>
+  </context>
+  <context>
+      <name>Duplicated_faces:group_name</name>
+    <message>
+      <source>Group name</source>
+      <translation>Nom du groupe</translation>
+    </message>
+  </context>
+  <context>
+    <name>Duplicated_faces:main_object</name>
+    <message>
+      <source>Object</source>
+      <translation>Objet</translation>
+    </message>
+    <message>
+      <source>Duplicated faces</source>
+      <translation>Faces dupliquées</translation>
+    </message>
+  </context>
+  <context>
+      <name>Duplicated_faces:group_list</name>
+    <message>
+      <source>Duplicatedfaces</source>
+      <translation>Faces dupliquées</translation>
+    </message>   
+    <message>
+      <source>List of faces :</source>
+      <translation>Liste des faces :</translation>
+    </message>
+  </context>
+  <context>
+    <name>Duplicated_faces:transparency</name>
+    <message>
+      <source>Transparency</source>
+      <translation>Transparence</translation>
+    </message>
+  </context>
+  <context>
+    <name>Duplicated_faces:tolerance</name>
+    <message>
+      <source>Tolerance</source>
+      <translation>Tolérance</translation>
+    </message>
+  </context>
+
   <!-- Symmetry -->
   <context>
     <name>Symmetry</name>
index 1e9c245059dcb1f3f925fbc0db0cd493e7c46d67..532fcc37a8992d253e0cb886411079a1074d8a9f 100644 (file)
@@ -9,7 +9,7 @@
     <validator id="GeomValidators_ShapeType" parameters="compsolid,compound"/>
   </shape_selector>
   <groupbox title="Duplicated faces">
-    <label id="number_duplicated_faces"/>
+    <label id="number_duplicated_faces" label="Number of duplicated faces : " />
     <multi_selector id="group_list"
                       label="List of faces :"
                       icon=""
@@ -34,7 +34,7 @@
                     default="1e-7">
   </doublevalue>
   <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 c5dcfa468845562da8ad2d7a272e9001123f94e7..c742ea4a722efaddb17e8033a00da64e295484b9 100644 (file)
@@ -9,7 +9,7 @@
     <validator id="GeomValidators_ShapeType" parameters="compsolid,compound"/>
   </shape_selector>
   <groupbox title="Duplicated faces">
-    <label id="number_duplicated_faces"/>
+    <label id="number_duplicated_faces" label="Number of duplicated faces : "/>
     <multi_selector id="group_list"
                       label="List of faces :"
                       icon=""
@@ -33,5 +33,5 @@
                     step="0.00001"
                     default="1e-7">
   </doublevalue>
-  <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