]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
Bug PAL11696 - writing a MESH with FAMILY attributes (identifier, value, description
authorapo <apo@opencascade.com>
Fri, 10 Mar 2006 11:49:31 +0000 (11:49 +0000)
committerapo <apo@opencascade.com>
Fri, 10 Mar 2006 11:49:31 +0000 (11:49 +0000)
12 files changed:
idl/SMESH_Group.idl
src/DriverMED/DriverMED_Family.cxx
src/DriverMED/DriverMED_Family.h
src/SMESH/SMESH_Group.hxx
src/SMESHDS/SMESHDS_GroupBase.hxx
src/SMESHGUI/SMESHGUI_GroupDlg.cxx
src/SMESHGUI/SMESHGUI_GroupDlg.h
src/SMESHGUI/SMESHGUI_Utils.cxx
src/SMESHGUI/SMESHGUI_Utils.h
src/SMESHGUI/SMESH_msg_en.po
src/SMESH_I/SMESH_Group_i.cxx
src/SMESH_I/SMESH_Group_i.hxx

index 37657674bf4f41da09810991f347e283cfa83f62..3cbb606daaa4093272a5b0d5969cfa7ecaa5d989 100644 (file)
@@ -84,6 +84,16 @@ module SMESH
      * Returns the mesh object this group belongs to
      */
     SMESH_Mesh GetMesh();
+
+    /*!
+     * Sets group color number
+     */
+    void SetColorNumber( in long color );
+
+    /*!
+     * Returns group color number
+     */
+    long GetColorNumber();
   }; 
 
   /*!
index 47a923dbd29c0e2809ae13af41a8df7068db7670..0da2c4cffa942131a326e1a762c981e705cd08ed 100644 (file)
 
 using namespace std;
 
+//=============================================================================
+/*!
+ *  Default constructor
+ */
+//=============================================================================
+DriverMED_Family
+::DriverMED_Family():
+  myGroupAttributVal(0)
+{}
+
+
+//=============================================================================
+const ElementsSet& 
+DriverMED_Family
+::GetElements () const 
+{ 
+  return myElements; 
+}
+
+int 
+DriverMED_Family
+::GetId () const 
+{ 
+  return myId; 
+}
+
+void 
+DriverMED_Family
+::SetId (const int theId) 
+{ 
+  myId = theId; 
+}
+
+void
+DriverMED_Family
+::AddElement(const SMDS_MeshElement* theElement)
+{
+  myElements.insert(theElement); 
+}
+
+void
+DriverMED_Family
+::AddGroupName(std::string theGroupName)
+{
+  myGroupNames.insert(theGroupName); 
+}
+
+void
+DriverMED_Family
+::SetType(const SMDSAbs_ElementType theType) 
+{ 
+  myType = theType; 
+}
+
+SMDSAbs_ElementType
+DriverMED_Family
+::GetType()
+{
+  return myType; 
+}
+
+bool
+DriverMED_Family
+::MemberOf(std::string theGroupName) const
+{ 
+  return myGroupNames.find(theGroupName) != myGroupNames.end(); 
+}
+
+const MED::TStringSet& 
+DriverMED_Family
+::GetGroupNames () const 
+{ 
+  return myGroupNames; 
+}
+
+
+int 
+DriverMED_Family
+::GetGroupAttributVal() const 
+{
+  return myGroupAttributVal;
+} 
+
+void
+DriverMED_Family
+::SetGroupAttributVal( int theValue) 
+{
+  myGroupAttributVal = theValue;
+}
+
+bool
+DriverMED_Family
+::IsEmpty () const 
+{ 
+  return myElements.empty(); 
+}
+
 //=============================================================================
 /*!
  *  Split each group from list <aGroups> on some parts (families)
@@ -39,15 +136,16 @@ using namespace std;
  *  Resulting families have no common elements.
  */
 //=============================================================================
-list<DriverMED_FamilyPtr> DriverMED_Family::MakeFamilies
-                         (const map <int, SMESHDS_SubMesh*>& theSubMeshes,
-                          const list<SMESHDS_GroupBase*>& theGroups,
-                          const bool doGroupOfNodes,
-                          const bool doGroupOfEdges,
-                          const bool doGroupOfFaces,
-                          const bool doGroupOfVolumes)
+DriverMED_FamilyPtrList 
+DriverMED_Family
+::MakeFamilies(const SMESHDS_SubMeshPtrMap& theSubMeshes,
+              const SMESHDS_GroupBasePtrList& theGroups,
+              const bool doGroupOfNodes,
+              const bool doGroupOfEdges,
+              const bool doGroupOfFaces,
+              const bool doGroupOfVolumes)
 {
-  list<DriverMED_FamilyPtr> aFamilies;
+  DriverMED_FamilyPtrList aFamilies;
 
   string anAllNodesGroupName = "Group_Of_All_Nodes";
   string anAllEdgesGroupName = "Group_Of_All_Edges";
@@ -61,22 +159,23 @@ list<DriverMED_FamilyPtr> DriverMED_Family::MakeFamilies
   int aElemFamId = FIRST_ELEM_FAMILY;
 
   // Process sub-meshes
-  map<int, SMESHDS_SubMesh*>::const_iterator aSMIter = theSubMeshes.begin();
+  SMESHDS_SubMeshPtrMap::const_iterator aSMIter = theSubMeshes.begin();
   for (; aSMIter != theSubMeshes.end(); aSMIter++)
   {
-    if ( aSMIter->second->IsComplexSubmesh() )
+    const int anId = aSMIter->first;
+    SMESHDS_SubMesh* aSubMesh = aSMIter->second;
+    if ( aSubMesh->IsComplexSubmesh() )
       continue; // submesh containing other submeshs
-    list<DriverMED_FamilyPtr> aSMFams = SplitByType((*aSMIter).second, (*aSMIter).first);
-    list<DriverMED_FamilyPtr>::iterator aSMFamsIter = aSMFams.begin();
+    DriverMED_FamilyPtrList aSMFams = SplitByType(aSubMesh,anId);
+    DriverMED_FamilyPtrList::iterator aSMFamsIter = aSMFams.begin();
     for (; aSMFamsIter != aSMFams.end(); aSMFamsIter++)
     {
       DriverMED_FamilyPtr aFam2 = (*aSMFamsIter);
-
-      list<DriverMED_FamilyPtr>::iterator aFamsIter = aFamilies.begin();
+      DriverMED_FamilyPtrList::iterator aFamsIter = aFamilies.begin();
       while (aFamsIter != aFamilies.end())
       {
         DriverMED_FamilyPtr aFam1 = *aFamsIter;
-        list<DriverMED_FamilyPtr>::iterator aCurrIter = aFamsIter++;
+        DriverMED_FamilyPtrList::iterator aCurrIter = aFamsIter++;
         if (aFam1->myType == aFam2->myType)
         {
           DriverMED_FamilyPtr aCommon (new DriverMED_Family);
@@ -89,7 +188,8 @@ list<DriverMED_FamilyPtr> DriverMED_Family::MakeFamilies
           {
             aFamilies.erase(aCurrIter);
           }
-          if (aFam2->IsEmpty()) break;
+          if (aFam2->IsEmpty()) 
+           break;
         }
       }
       // The rest elements of family
@@ -101,30 +201,32 @@ list<DriverMED_FamilyPtr> DriverMED_Family::MakeFamilies
   }
 
   // Process groups
-  list<SMESHDS_GroupBase*>::const_iterator aGroupsIter = theGroups.begin();
+  SMESHDS_GroupBasePtrList::const_iterator aGroupsIter = theGroups.begin();
   for (; aGroupsIter != theGroups.end(); aGroupsIter++)
   {
     DriverMED_FamilyPtr aFam2 (new DriverMED_Family);
     aFam2->Init(*aGroupsIter);
 
-    list<DriverMED_FamilyPtr>::iterator aFamsIter = aFamilies.begin();
+    DriverMED_FamilyPtrList::iterator aFamsIter = aFamilies.begin();
     while (aFamsIter != aFamilies.end())
     {
       DriverMED_FamilyPtr aFam1 = *aFamsIter;
-      list<DriverMED_FamilyPtr>::iterator aCurrIter = aFamsIter++;
+      DriverMED_FamilyPtrList::iterator aCurrIter = aFamsIter++;
       if (aFam1->myType == aFam2->myType)
       {
         DriverMED_FamilyPtr aCommon (new DriverMED_Family);
         aFam1->Split(aFam2, aCommon);
         if (!aCommon->IsEmpty())
         {
+         aCommon->SetGroupAttributVal(0);
           aFamilies.push_back(aCommon);
         }
         if (aFam1->IsEmpty())
         {
           aFamilies.erase(aCurrIter);
         }
-        if (aFam2->IsEmpty()) break;
+        if (aFam2->IsEmpty()) 
+         break;
       }
     }
     // The rest elements of group
@@ -134,7 +236,7 @@ list<DriverMED_FamilyPtr> DriverMED_Family::MakeFamilies
     }
   }
 
-  list<DriverMED_FamilyPtr>::iterator aFamsIter = aFamilies.begin();
+  DriverMED_FamilyPtrList::iterator aFamsIter = aFamilies.begin();
   for (; aFamsIter != aFamilies.end(); aFamsIter++)
   {
     DriverMED_FamilyPtr aFam = *aFamsIter;
@@ -210,33 +312,33 @@ MED::PFamilyInfo
 DriverMED_Family::GetFamilyInfo(const MED::PWrapper& theWrapper, 
                                const MED::PMeshInfo& theMeshInfo) const
 {
-  string aValue;
-
   ostringstream aStr;
-
   aStr << "FAM_" << myId;
   set<string>::const_iterator aGrIter = myGroupNames.begin();
-  for (; aGrIter != myGroupNames.end(); aGrIter++)
-  {
+  for(; aGrIter != myGroupNames.end(); aGrIter++){
     aStr << "_" << *aGrIter;
   }
 
-  aValue = aStr.str();
-  /*
-  MED::TStringVector anAttrDescs (1, "");  // 1 attribute with empty description,
-  MED::TIntVector anAttrIds (1, myId);        // Id=0,
-  MED::TIntVector anAttrVals (1, myId);       // Value=0
-  */
-  
-  MED::PFamilyInfo anInfo = theWrapper->CrFamilyInfo(theMeshInfo,
-                                                    aValue,
-                                                    myId,
-                                                    myGroupNames);
-/*                                                  
-                                                   anAttrDescs,
-                                                   anAttrIds,
-                                                   anAttrVals);
-*/
+  MED::PFamilyInfo anInfo;
+  string aValue = aStr.str();
+  if(myId == 0){
+    anInfo = theWrapper->CrFamilyInfo(theMeshInfo,
+                                     aValue,
+                                     myId,
+                                     myGroupNames);
+  }else{
+    MED::TStringVector anAttrDescs (1, "");  // 1 attribute with empty description,
+    MED::TIntVector anAttrIds (1, myId);        // Id=0,
+    MED::TIntVector anAttrVals (1);
+    anAttrVals[0] = myGroupAttributVal != 0? myGroupAttributVal: myId;
+    anInfo = theWrapper->CrFamilyInfo(theMeshInfo,
+                                     aValue,
+                                     myId,
+                                     myGroupNames,
+                                     anAttrDescs,
+                                     anAttrIds,
+                                     anAttrVals);
+  }
 
 //  cout << endl;
 //  cout << "Groups: ";
@@ -279,6 +381,14 @@ void DriverMED_Family::Init (SMESHDS_GroupBase* theGroup)
   // Groups list
   myGroupNames.clear();
   myGroupNames.insert(string(theGroup->GetStoreName()));
+
+  myGroupAttributVal = 0;
+  
+  if (theGroup->GetColorGroup()!=0)
+    {
+      myGroupAttributVal = theGroup->GetColorGroup();
+    }
+
 }
 
 //=============================================================================
@@ -287,10 +397,12 @@ void DriverMED_Family::Init (SMESHDS_GroupBase* theGroup)
  *  on the basis of the elements type.
  */
 //=============================================================================
-list<DriverMED_FamilyPtr> DriverMED_Family::SplitByType (SMESHDS_SubMesh* theSubMesh,
-                                                         const int        theId)
+DriverMED_FamilyPtrList 
+DriverMED_Family
+::SplitByType (SMESHDS_SubMesh* theSubMesh,
+              const int        theId)
 {
-  list<DriverMED_FamilyPtr> aFamilies;
+  DriverMED_FamilyPtrList aFamilies;
   DriverMED_FamilyPtr aNodesFamily   (new DriverMED_Family);
   DriverMED_FamilyPtr anEdgesFamily  (new DriverMED_Family);
   DriverMED_FamilyPtr aFacesFamily   (new DriverMED_Family);
@@ -361,7 +473,7 @@ void DriverMED_Family::Split (DriverMED_FamilyPtr by,
                               DriverMED_FamilyPtr common)
 {
   // Elements
-  set<const SMDS_MeshElement *>::iterator anIter = by->myElements.begin();
+  ElementsSet::iterator anIter = by->myElements.begin();
   while ( anIter != by->myElements.end())
   {
     if (myElements.find(*anIter) != myElements.end())
@@ -378,7 +490,7 @@ void DriverMED_Family::Split (DriverMED_FamilyPtr by,
   {
     // Groups list
     common->myGroupNames = myGroupNames;
-    set<string>::iterator aGrNamesIter = by->myGroupNames.begin();
+    MED::TStringSet::iterator aGrNamesIter = by->myGroupNames.begin();
     for (; aGrNamesIter != by->myGroupNames.end(); aGrNamesIter++)
     {
       common->myGroupNames.insert(*aGrNamesIter);
index 1632ccb3b71cc57069ead253065b99bd35d727be..6a362275582a0b43aa44f56f39cf242d386bc818 100644 (file)
 
 class DriverMED_Family;
 typedef boost::shared_ptr<DriverMED_Family> DriverMED_FamilyPtr;
+typedef std::list<DriverMED_FamilyPtr> DriverMED_FamilyPtrList;
+typedef std::map<int,SMESHDS_SubMesh*> SMESHDS_SubMeshPtrMap;
+typedef std::list<SMESHDS_GroupBase*> SMESHDS_GroupBasePtrList;
+typedef std::set<const SMDS_MeshElement*> ElementsSet;
 
 class DriverMED_Family
 {
  public:
 
-  // Methods for groups storing to MED
-
-  static std::list<DriverMED_FamilyPtr> MakeFamilies (const std::map <int, SMESHDS_SubMesh*>& theSubMeshes,
-                                                     const std::list<SMESHDS_GroupBase*>& theGroups,
-                                                     const bool doGroupOfNodes,
-                                                     const bool doGroupOfEdges,
-                                                     const bool doGroupOfFaces,
-                                                     const bool doGroupOfVolumes);
-  // Split each group from list <theGroups> and each sub-mesh from list <theSubMeshes>
-  // on some parts (families) on the basis of the elements membership in other groups
-  // from <theGroups> and other sub-meshes from <theSubMeshes>.
-  // Resulting families have no common elements.
-
-  MED::PFamilyInfo GetFamilyInfo (const MED::PWrapper& theWrapper, 
-                                 const MED::PMeshInfo& theMeshInfo) const;
-  // Create TFamilyInfo for this family
-
-  const std::set<const SMDS_MeshElement *>& GetElements () const { return myElements; }
-  // Returns elements of this family
-
-  int GetId () const { return myId; }
-  // Returns a family ID
+  DriverMED_Family();
+
+  //! Methods for groups storing to MED
+  /*!
+    Split each group from list <theGroups> and each sub-mesh from list <theSubMeshes>
+    on some parts (families) on the basis of the elements membership in other groups
+    from <theGroups> and other sub-meshes from <theSubMeshes>.
+    Resulting families have no common elements.
+  */
+  static 
+  DriverMED_FamilyPtrList
+  MakeFamilies (const SMESHDS_SubMeshPtrMap& theSubMeshes,
+               const SMESHDS_GroupBasePtrList& theGroups,
+               const bool doGroupOfNodes,
+               const bool doGroupOfEdges,
+               const bool doGroupOfFaces,
+               const bool doGroupOfVolumes);
+
+  //! Create TFamilyInfo for this family
+  MED::PFamilyInfo 
+  GetFamilyInfo (const MED::PWrapper& theWrapper, 
+                const MED::PMeshInfo& theMeshInfo) const;
+
+  //! Returns elements of this family
+  const ElementsSet& GetElements () const;
+
+  //! Returns a family ID
+  int GetId () const;
+
+  //! Sets a family ID
+  void SetId (const int theId);
 
  public:
 
   // Methods for groups reading from MED
 
-  void AddElement (const SMDS_MeshElement* theElement) { myElements.insert(theElement); }
+  void AddElement(const SMDS_MeshElement* theElement);
 
-  void AddGroupName (std::string theGroupName) { myGroupNames.insert(theGroupName); }
+  const MED::TStringSet& GetGroupNames() const;
+  void AddGroupName(std::string theGroupName);
 
-  void SetType (const SMDSAbs_ElementType theType) { myType = theType; }
-  SMDSAbs_ElementType GetType () { return myType; }
+  void SetType(const SMDSAbs_ElementType theType);
+  SMDSAbs_ElementType GetType();
 
-  bool MemberOf (std::string theGroupName) const
-    { return (myGroupNames.find(theGroupName) != myGroupNames.end()); }
+  bool MemberOf(std::string theGroupName) const;
 
-  const MED::TStringSet& GetGroupNames () const { return myGroupNames; }
-
-  void SetId (const int theId) { myId = theId; }
-  // Sets a family ID
+  int GetGroupAttributVal() const;
+  void SetGroupAttributVal( int theValue);
 
  private:
+  //! Initialize the tool by SMESHDS_GroupBase
   void Init (SMESHDS_GroupBase* group);
-  // Initialize the tool by SMESHDS_GroupBase
 
-  static std::list<DriverMED_FamilyPtr> SplitByType (SMESHDS_SubMesh* theSubMesh,
-                                                    const int        theId);
-  // Split <theSubMesh> on some parts (families)
-  // on the basis of the elements type.
+  //! Split <theSubMesh> on some parts (families) on the basis of the elements type.
+  static
+  DriverMED_FamilyPtrList 
+  SplitByType(SMESHDS_SubMesh* theSubMesh,
+             const int        theId);
+
 
+  /*! Remove from <Elements> elements, common with <by>,
+    Remove from <by> elements, common with <Elements>,
+    Create family <common> from common elements, with combined groups list.
+  */
   void Split (DriverMED_FamilyPtr by,
              DriverMED_FamilyPtr common);
-  // Remove from <Elements> elements, common with <by>,
-  // Remove from <by> elements, common with <Elements>,
-  // Create family <common> from common elements, with combined groups list.
 
-  bool IsEmpty () const { return myElements.empty(); }
-  // Check, if this family has empty list of elements
+  //! Check, if this family has empty list of elements
+  bool IsEmpty () const;
+
 
  private:
   int                           myId;
   SMDSAbs_ElementType           myType;
-  std::set<const SMDS_MeshElement *> myElements;
+  ElementsSet                   myElements;
   MED::TStringSet               myGroupNames;
+  int                           myGroupAttributVal;
 };
 
 #endif
index 26493e4e085296b3372c71cbdcc262bdaff916f9..3819cd4aac85bdbc14d85e8a596e3146ad5e5c67 100644 (file)
@@ -53,6 +53,9 @@ class SMESH_Group
 
   SMESHDS_GroupBase * GetGroupDS () { return myGroupDS; }
 
+  void SetColorNumber (int theColorNumber) { myColorNumber = theColorNumber; }
+  int GetColorNumber() const { return myColorNumber; }
+
  private:
   SMESH_Group (const SMESH_Group& theOther);
   // prohibited copy constructor
@@ -61,7 +64,7 @@ class SMESH_Group
 
   SMESHDS_GroupBase * myGroupDS;
   std::string         myName;
-
+  int                 myColorNumber;
 };
 
 #endif
index a7aa87cedb79b4b3d21f578e9465617aeeb292a1..1902f8e9d397aee4c2b7560d714e289ce853acb8 100644 (file)
@@ -66,6 +66,12 @@ class SMESHDS_GroupBase
 
   virtual ~SMESHDS_GroupBase() {}
 
+  void SetColorGroup (int theColorGroup)
+  { myColorGroup = theColorGroup;}
+  
+  int GetColorGroup() const
+  { return myColorGroup;}
+  
  protected:
   const SMDS_MeshElement* findInMesh (const int theID) const;
   void resetIterator();
@@ -84,7 +90,7 @@ class SMESHDS_GroupBase
   int                  myCurIndex;
   int                  myCurID;
   SMDS_ElemIteratorPtr myIterator;
-
+  int                  myColorGroup;
 };
 
 #endif
index c9cd3a442ab3538f1cc0effc4375832b2950e1ca..1c2009ff95a792f0c13cfdc2b367efb1c0f13ec4 100644 (file)
@@ -259,7 +259,7 @@ void SMESHGUI_GroupDlg::initDialog(bool create)
   myGroupLine = new QLineEdit(aSelectBox, "group line");
   myGroupLine->setReadOnly(true);
   onSelectGroup(false);
-
+  
   /***************************************************************/
   QGridLayout* wg1Layout = new QGridLayout( wg1, 3, 1, 0, 6 );
   wg1Layout->addWidget(aContentBox, 0, 0);
@@ -291,6 +291,26 @@ void SMESHGUI_GroupDlg::initDialog(bool create)
   myWGStack->addWidget( wg2, myGrpTypeGroup->id(rb2) );
 
   /***************************************************************/
+  QGroupBox* aColorBox = new QGroupBox(this, "color box");
+  aColorBox->setTitle(tr("SMESH_SET_COLOR"));
+
+  mySelectColorGroup = new QCheckBox(aColorBox, "color checkbox");
+  mySelectColorGroup->setText(tr("SMESH_CHECK_COLOR"));
+  mySelectColorGroup->setMinimumSize(50, 0);
+  
+  myColorGroupLine = new QLineEdit(aColorBox, "color line");
+  myColorGroupLine->setReadOnly(false);
+  onSelectColorGroup(false);
+  
+  /***************************************************************/
+  QHBoxLayout* aColorLayout = new QHBoxLayout(aColorBox, 15, 20);
+  aColorLayout->setAutoAdd(false);
+  
+  aColorLayout->addWidget(mySelectColorGroup);
+  aColorLayout->addWidget(myColorGroupLine);
+  
+  /***************************************************************/
+  
   QFrame* aButtons = new QFrame(this, "button box");
   aButtons->setFrameStyle(QFrame::Box | QFrame::Sunken);
   QHBoxLayout* aBtnLayout = new QHBoxLayout(aButtons, 11, 6);
@@ -322,7 +342,8 @@ void SMESHGUI_GroupDlg::initDialog(bool create)
   aMainLayout->addMultiCellWidget(myGrpTypeGroup, 3, 3, 0, 2);
   aMainLayout->addMultiCellWidget(myWGStack,      4, 4, 0, 2);
   aMainLayout->setRowStretch( 5, 5 );
-  aMainLayout->addMultiCellWidget(aButtons,       6, 6, 0, 2);
+  aMainLayout->addMultiCellWidget(aColorBox,   6, 6, 0, 2);
+  aMainLayout->addMultiCellWidget(aButtons,       7, 7, 0, 2);
 
   /* signals and slots connections */
   connect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
@@ -344,6 +365,8 @@ void SMESHGUI_GroupDlg::initDialog(bool create)
   connect(mySubMeshBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
   connect(myGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
   connect(myGeomGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
+  connect(mySelectColorGroup, SIGNAL(toggled(bool)), this, SLOT(onSelectColorGroup(bool)));
+
 
   connect(aOKBtn, SIGNAL(clicked()), this, SLOT(onOK()));
   connect(aApplyBtn, SIGNAL(clicked()), this, SLOT(onApply()));
@@ -439,6 +462,10 @@ void SMESHGUI_GroupDlg::init (SMESH::SMESH_Group_ptr theGroup)
 
   myName->setText(myGroup->GetName());
   myName->home(false);
+
+  myColorGroupLine->setText(QString::number(myGroup->GetColorNumber()));
+  myColorGroupLine->home(false);
+  
   myMeshGroupLine->setText(myGroup->GetName());
 
   myCurrentLineEdit = 0;
@@ -595,6 +622,20 @@ bool SMESHGUI_GroupDlg::onApply()
 
       myGroup = SMESH::AddGroup(myMesh, aType, myName->text());
       myGroup->Add(anIdList.inout());
+      
+      int aColorNumber = myColorGroupLine->text().toInt();
+      myGroup->SetColorNumber(aColorNumber);
+      
+      _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroup);
+
+      SMESH::setFileName (aMeshGroupSO, myColorGroupLine->text());
+      
+      SMESH::setFileType (aMeshGroupSO,"COULEURGROUP");
+      
+      /* init for next operation */
+      myName->setText("");
+
+      myColorGroupLine->setText("");
 
       /* init for next operation */
       myName->setText("");
@@ -603,6 +644,9 @@ bool SMESHGUI_GroupDlg::onApply()
 
     } else {
       myGroup->SetName(myName->text());
+        
+      int aColorNumber = myColorGroupLine->text().toInt();
+      myGroup->SetColorNumber(aColorNumber);
 
       QValueList<int> aAddList;
       QValueList<int>::iterator anIt;
@@ -660,10 +704,20 @@ bool SMESHGUI_GroupDlg::onApply()
     SMESH::SMESH_GroupOnGeom_var aGroupOnGeom =
       myMesh->CreateGroupFromGEOM(aType, myName->text(),myGeomGroup);
 
+    int aColorNumber = myColorGroupLine->text().toInt();
+    aGroupOnGeom->SetColorNumber(aColorNumber);
+    
+    _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(aGroupOnGeom);
+    
+    SMESH::setFileName (aMeshGroupSO, myColorGroupLine->text());
+    
+    SMESH::setFileType (aMeshGroupSO,"COULEURGROUP");
+    
     mySMESHGUI->updateObjBrowser(true);
     mySelectionMgr->clearSelected();
     /* init for next operation */
     myName->setText("");
+    myColorGroupLine->setText("");
     return true;
   }
 
@@ -986,6 +1040,23 @@ void SMESHGUI_GroupDlg::onSelectGeomGroup(bool on)
   }
 }
 
+//=================================================================================
+// function : (onSelectColorGroup)
+// purpose  : Called when setting a color on group
+//=================================================================================
+void SMESHGUI_GroupDlg::onSelectColorGroup(bool on)
+{
+  if (on) {
+    setSelectionMode(7);
+  }
+  else {
+    myColorGroupLine->setText("");
+    myCurrentLineEdit = 0;
+    if (myTypeId != -1)
+      setSelectionMode(myTypeId);
+  }
+  myColorGroupLine->setEnabled(on);
+}
 
 //=================================================================================
 // function : setCurrentSelection()
index af101fcff616ff15cad0dce323e0096c718ce40d..e33e846397d4a72bbe6f89ac228bf7032a7670e0 100644 (file)
@@ -95,6 +95,7 @@ private slots:
     void onSelectSubMesh(bool on);
     void onSelectGroup(bool on);
     void onSelectGeomGroup(bool on);
+    void onSelectColorGroup(bool on);
     void setCurrentSelection();
 
     void setFilters();
@@ -141,6 +142,9 @@ private:
     QPushButton*                  myGroupBtn;
     QLineEdit*                    myGroupLine;
 
+    QCheckBox*                    mySelectColorGroup;
+    QLineEdit*                    myColorGroupLine;
+
     QCheckBox*                    mySelectGeomGroup;
     QPushButton*                  myGeomGroupBtn;
     QLineEdit*                    myGeomGroupLine;
index 94714bcd7aabd3cae95a7ded77c6adf0f6d266db..383b02c5c68d58be3b196eac08b7aa162bb17d63 100644 (file)
@@ -153,6 +153,32 @@ namespace SMESH{
     if (aComment)
       aComment->SetValue(theValue);
   }
+  
+  void setFileName (_PTR(SObject) theSObject, const char* theValue)
+  {
+    _PTR(Study) aStudy = GetActiveStudyDocument();
+    if (aStudy->GetProperties()->IsLocked())
+      return;
+    _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
+    _PTR(GenericAttribute) anAttr =
+      aBuilder->FindOrCreateAttribute(theSObject, "AttributeExternalFileDef");
+    _PTR(AttributeExternalFileDef) aFileName = anAttr;
+    if (aFileName)
+      aFileName->SetValue(theValue);
+  }
+  
+  void setFileType (_PTR(SObject) theSObject, const char* theValue)
+  {
+    _PTR(Study) aStudy = GetActiveStudyDocument();
+    if (aStudy->GetProperties()->IsLocked())
+      return;
+    _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
+    _PTR(GenericAttribute) anAttr =
+      aBuilder->FindOrCreateAttribute(theSObject, "AttributeFileType");
+    _PTR(AttributeFileType) aFileType = anAttr;
+    if (aFileType)
+      aFileType->SetValue(theValue);
+  }
 
   CORBA::Object_var SObjectToObject (_PTR(SObject) theSObject,
                                      _PTR(Study)   theStudy)
index 83278e4a5018a462ff05cfb44c8ac68f385c0ecd..d236533fea2d6cd03041cf9c464c2f3a723bd3b2 100644 (file)
@@ -81,6 +81,8 @@ namespace SMESH {
 
   void SetName  (_PTR(SObject) theSObject, const char* theName);
   void SetValue (_PTR(SObject) theSObject, const char* theValue);
+  void setFileType (_PTR(SObject) theSObject, const char* theValue);
+  void setFileName (_PTR(SObject) theSObject, const char* theValue);
 
   CORBA::Object_var SObjectToObject (_PTR(SObject) theSObject,
                                     _PTR(Study) theStudy);
index 93628ae79481c7c55b5948e86a102be9883d3175..3fcce77aebce24b9e3b4e0831be08ab10a056efd 100644 (file)
@@ -918,6 +918,14 @@ msgstr "Group on geometry"
 msgid "SMESH_GEOM_GROUP"
 msgstr "Geometry group"
 
+#Color group
+msgid "SMESH_SET_COLOR"
+msgstr "Color group"
+
+#Check color group
+msgid "SMESH_CHECK_COLOR"
+msgstr "Color number"
+
 #%1 SubMeshes
 msgid "SMESH_SUBMESH_SELECTED"
 msgstr "%1 SubMeshes"
index 2720a60f5e2080253053995f1b27fa4099d35cfe..9c0a2f52f0459d4056901c69efc53f58ce77a5f6 100644 (file)
@@ -419,3 +419,33 @@ GEOM::GEOM_Object_ptr SMESH_GroupOnGeom_i::GetShape()
   return aGeomObj._retn();
 }
 
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+CORBA::Long SMESH_GroupBase_i::GetColorNumber()
+{
+  SMESHDS_GroupBase* aGroupDS = GetGroupDS();
+  if (aGroupDS)
+    return aGroupDS->GetColorGroup();
+  MESSAGE("get color number of a vague group");
+  return 0;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+void SMESH_GroupBase_i::SetColorNumber(CORBA::Long color)
+{
+  SMESHDS_GroupBase* aGroupDS = GetGroupDS();
+  if (aGroupDS)
+    return aGroupDS->SetColorGroup(color);
+  MESSAGE("set color number of a vague group");
+  return ;
+}
+
+
+
index e9801b258b9eea32e898ff871c100ae7f3621b92..cc7dabe729312cb0bc77d550221853666f58bb9c 100644 (file)
@@ -73,6 +73,9 @@ class SMESH_GroupBase_i:
   SMESH_Group* GetSmeshGroup() const;
   SMESHDS_GroupBase* GetGroupDS() const;
 
+   void SetColorNumber(CORBA::Long color);
+   CORBA::Long GetColorNumber();
+
 private:
   SMESH_Mesh_i* myMeshServant;
   int myLocalID;