Salome HOME
IPAL16934: Selection works incorrectly if Source and Target Vertices in Projection...
[modules/smesh.git] / src / StdMeshersGUI / StdMeshersGUI_StdHypothesisCreator.cxx
index 342f66fc418e775d9f7f94b9cb5b95d7c18b2917..e912e113d1d337b55483d397ac80483c2b4aff4a 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -47,6 +47,7 @@
 
 // SALOME GUI includes
 #include <SUIT_ResourceMgr.h>
+#include <SUIT_MessageBox.h>
 
 // IDL includes
 #include <SALOMEconfig.h>
@@ -407,7 +408,7 @@ bool StdMeshersGUI_StdHypothesisCreator::checkParams( QString& msg ) const
       srcV = w1->GetValue();
       tgtV = w2->GetValue();
       ok = (( srcV.isEmpty()  && tgtV.isEmpty() ) ||
-            ( !srcV.isEmpty() && !tgtV.isEmpty() && srcV != tgtV ));
+            ( !srcV.isEmpty() && !tgtV.isEmpty() /*&& srcV != tgtV*/ ));
       if ( !ok ) {
         w1->SetObject( CORBA::Object::_nil() );
         w2->SetObject( CORBA::Object::_nil() );
@@ -744,23 +745,23 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
         h->SetEdges( idsWg->GetListOfIDs(), params[3].myValue.toInt() );
       }
     }
-    else if( hypType()=="QuadrangleParams" )
-    {
-      StdMeshers::StdMeshers_QuadrangleParams_var h =
-        StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() );
-      StdMeshersGUI_SubShapeSelectorWdg* w1 =
-        widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
-      StdMeshersGUI_QuadrangleParamWdg* w2 =
-        widget< StdMeshersGUI_QuadrangleParamWdg >( 1 );
-      if (w1 && w2) {
-        if (w1->GetListSize() > 0) {
-          h->SetTriaVertex(w1->GetListOfIDs()[0]); // getlist must be called once
-          const char * entry = w1->GetMainShapeEntry();
-          h->SetObjectEntry(entry);
-        }
-        h->SetQuadType(StdMeshers::QuadType(w2->GetType()));
-      }
-    }
+    // else if( hypType()=="QuadrangleParams" )
+    // {
+    //   StdMeshers::StdMeshers_QuadrangleParams_var h =
+    //     StdMeshers::StdMeshers_QuadrangleParams::_narrow( hypothesis() );
+    //   StdMeshersGUI_SubShapeSelectorWdg* w1 =
+    //     widget< StdMeshersGUI_SubShapeSelectorWdg >( 0 );
+    //   StdMeshersGUI_QuadrangleParamWdg* w2 =
+    //     widget< StdMeshersGUI_QuadrangleParamWdg >( 1 );
+    //   if (w1 && w2) {
+    //     if (w1->GetListSize() > 0) {
+    //       h->SetTriaVertex(w1->GetListOfIDs()[0]); // getlist must be called once
+    //       const char * entry = w1->GetMainShapeEntry();
+    //       h->SetObjectEntry(entry);
+    //     }
+    //     h->SetQuadType(StdMeshers::QuadType(w2->GetType()));
+    //   }
+    // }
   }
   return valueStr;
 }
@@ -1242,6 +1243,7 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
     customWidgets()->append (0);
 
     QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
+    QString aSubEntry  = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
     if ( !aMainEntry.isEmpty() )
     {
       item.myName = tr( "TO_IGNORE_FACES_OR_NOT" );
@@ -1262,10 +1264,17 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
       StdMeshersGUI_SubShapeSelectorWdg* idsWg =
         new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_FACE);
 
-      idsWg->SetGeomShapeEntry( aMainEntry );
       idsWg->SetMainShapeEntry( aMainEntry );
-      idsWg->SetListOfIDs( h->GetFaces() );
-      idsWg->showPreview( true );
+      idsWg->SetGeomShapeEntry( aSubEntry.isEmpty() ? aMainEntry : aSubEntry );
+      if ( idsWg->SetListOfIDs( h->GetFaces() ))
+      {
+        idsWg->showPreview( true );
+      }
+      else
+      {
+        SUIT_MessageBox::warning( dlg(),tr( "SMESH_WRN_WARNING" ),tr( "BAD_FACES_WARNING" ));
+        idsWg->setEnabled( false );
+      }
       customWidgets()->append ( idsWg );
     }
   }
@@ -1293,6 +1302,7 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
     customWidgets()->append (0);
 
     QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
+    QString aSubEntry  = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
     if ( !aMainEntry.isEmpty() )
     {
       item.myName = tr("TO_IGNORE_EDGES_OR_NOT");
@@ -1313,53 +1323,60 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
       StdMeshersGUI_SubShapeSelectorWdg* idsWg =
         new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_EDGE);
 
-      idsWg->SetGeomShapeEntry( aMainEntry );
       idsWg->SetMainShapeEntry( aMainEntry );
-      idsWg->SetListOfIDs( h->GetEdges() );
-      idsWg->showPreview( true );
-      customWidgets()->append ( idsWg );
-    }
-  }
-  else if (hypType() == "QuadrangleParams")
-  {
-    StdMeshers::StdMeshers_QuadrangleParams_var h =
-      StdMeshers::StdMeshers_QuadrangleParams::_narrow(hyp);
-
-    item.myName = tr("SMESH_BASE_VERTEX");
-    p.append(item);
-
-    StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
-      new StdMeshersGUI_SubShapeSelectorWdg(0, TopAbs_VERTEX);
-    aDirectionWidget->SetMaxSize(1);
-    QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
-    QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
-    if (anEntry == "")
-      anEntry = h->GetObjectEntry();
-    aDirectionWidget->SetGeomShapeEntry(anEntry);
-    aDirectionWidget->SetMainShapeEntry(aMainEntry);
-    if (!isCreation()) {
-      SMESH::long_array_var aVec = new SMESH::long_array;
-      int vertID = h->GetTriaVertex();
-      if (vertID > 0) {
-        aVec->length(1);
-        aVec[0] = vertID;
-        aDirectionWidget->SetListOfIDs(aVec);
+      idsWg->SetGeomShapeEntry( aSubEntry.isEmpty() ? aMainEntry : aSubEntry );
+      if ( idsWg->SetListOfIDs( h->GetEdges() ))
+      {
+        idsWg->showPreview( true );
       }
+      else
+      {
+        SUIT_MessageBox::warning( dlg(),tr( "SMESH_WRN_WARNING" ),tr( "BAD_EDGES_WARNING" ));
+        idsWg->setEnabled( false );
+      }
+      customWidgets()->append ( idsWg );
     }
-    aDirectionWidget->showPreview(true);
-
-    item.myName = tr("SMESH_QUAD_TYPE");
-    p.append(item);
-
-    StdMeshersGUI_QuadrangleParamWdg* aTypeWidget =
-      new StdMeshersGUI_QuadrangleParamWdg();
-    if (!isCreation()) {
-      aTypeWidget->SetType(int(h->GetQuadType()));
-    }
-
-    customWidgets()->append(aDirectionWidget);
-    customWidgets()->append(aTypeWidget);
   }
+  // else if (hypType() == "QuadrangleParams")
+  // {
+  //   StdMeshers::StdMeshers_QuadrangleParams_var h =
+  //     StdMeshers::StdMeshers_QuadrangleParams::_narrow(hyp);
+
+  //   item.myName = tr("SMESH_BASE_VERTEX");
+  //   p.append(item);
+
+  //   StdMeshersGUI_SubShapeSelectorWdg* aDirectionWidget =
+  //     new StdMeshersGUI_SubShapeSelectorWdg(0, TopAbs_VERTEX);
+  //   aDirectionWidget->SetMaxSize(1);
+  //   QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
+  //   QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
+  //   if (anEntry == "")
+  //     anEntry = h->GetObjectEntry();
+  //   aDirectionWidget->SetGeomShapeEntry(anEntry);
+  //   aDirectionWidget->SetMainShapeEntry(aMainEntry);
+  //   if (!isCreation()) {
+  //     SMESH::long_array_var aVec = new SMESH::long_array;
+  //     int vertID = h->GetTriaVertex();
+  //     if (vertID > 0) {
+  //       aVec->length(1);
+  //       aVec[0] = vertID;
+  //       aDirectionWidget->SetListOfIDs(aVec);
+  //     }
+  //   }
+  //   aDirectionWidget->showPreview(true);
+
+  //   item.myName = tr("SMESH_QUAD_TYPE");
+  //   p.append(item);
+
+  //   StdMeshersGUI_QuadrangleParamWdg* aTypeWidget =
+  //     new StdMeshersGUI_QuadrangleParamWdg();
+  //   if (!isCreation()) {
+  //     aTypeWidget->SetType(int(h->GetQuadType()));
+  //   }
+
+  //   customWidgets()->append(aDirectionWidget);
+  //   customWidgets()->append(aTypeWidget);
+  // }
   else
     res = false;
   return res;
@@ -1591,13 +1608,11 @@ bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & pa
     param.myValue = w->GetValue();
     return true;
   }
-  if ( widget->inherits( "StdMeshersGUI_QuadrangleParamWdg" ))
-  {
-    //const StdMeshersGUI_QuadrangleParamWdg * w =
-    //  static_cast<const StdMeshersGUI_QuadrangleParamWdg*>( widget );
-    param.myValue = "QuadType";
-    return true;
-  }
+  // if ( widget->inherits( "StdMeshersGUI_QuadrangleParamWdg" ))
+  // {
+  //   param.myValue = "QuadType";
+  //   return true;
+  // }
   if ( widget->inherits( "StdMeshersGUI_FixedPointsParamWdg" ))
   {
     const StdMeshersGUI_FixedPointsParamWdg * w =