Salome HOME
Debug
authorouv <ouv@opencascade.com>
Fri, 11 Dec 2009 09:38:55 +0000 (09:38 +0000)
committerouv <ouv@opencascade.com>
Fri, 11 Dec 2009 09:38:55 +0000 (09:38 +0000)
13 files changed:
idl/SMESH_Hypothesis.idl
src/SMESHGUI/SMESHGUI_Helper.cxx
src/SMESHGUI/SMESHGUI_Helper.h
src/SMESH_I/SMESH_Gen_i.cxx
src/SMESH_I/SMESH_Gen_i.hxx
src/SMESH_I/SMESH_Gen_i_1.cxx
src/SMESH_I/SMESH_Hypothesis_i.cxx
src/SMESH_I/SMESH_Hypothesis_i.hxx
src/SMESH_I/SMESH_Mesh_i.cxx
src/SMESH_I/SMESH_Mesh_i.hxx
src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx
src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.h
src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx

index d7be98fca8ad487e83b5575654a322f0b7028b8c..14a0dbad9a6911e707d54b47e708769d441bdbe6 100644 (file)
@@ -40,8 +40,6 @@ module SMESH
     DIM_3D
   };
   
-  typedef sequence<string> ListOfParameters;
-
   interface SMESH_Hypothesis : SALOME::ParameterizedObject
   {
     
index 493ca2337b2a3c7a7f38f2dab2ddc81dbdabe4ac..123dc296f16e922aa1c1de53347c056564e2fe23 100644 (file)
 #include <SalomeApp_IntSpinBox.h>
 #include <SalomeApp_Notebook.h>
 
-// IDL includes
-//#include <SALOMEconfig.h>
-//#include CORBA_SERVER_HEADER(SMESH_Mesh)
-//#include CORBA_SERVER_HEADER(SMESH_MeshEditor)
-
 //=================================================================================
 // name    : SMESHGUI_Helper::SMESHGUI_Helper
 // Purpose :
 //=================================================================================
 SMESHGUI_Helper::SMESHGUI_Helper( SMESHGUI* theModule ) :
-  mySMESHGUI( theModule ),
-  myNotebook( 0 )
+  mySMESHGUI( theModule )
 {
+  myNotebook = new SalomeApp_Notebook( mySMESHGUI->activeStudy() );
 }
 
 //=======================================================================
@@ -129,9 +124,7 @@ bool SMESHGUI_Helper::checkParameters( bool theMess, const QList<QAbstractSpinBo
 // Function : getNotebook
 // Purpose  :
 //================================================================
-SalomeApp_Notebook* SMESHGUI_Helper::getNotebook()
+SalomeApp_Notebook* SMESHGUI_Helper::getNotebook() const
 {
-  if ( !myNotebook )
-    myNotebook = new SalomeApp_Notebook( mySMESHGUI->activeStudy() );
   return myNotebook;
 }
index b94ef8239041e8e7f030ca7488e85495395407e3..934be9a8430089ad5fba41e2b7773e0e03bab68d 100644 (file)
@@ -52,7 +52,7 @@ protected:
   bool                checkParameters( bool, int, QAbstractSpinBox*, ... );
   bool                checkParameters( bool, const QList<QAbstractSpinBox*>& );
 
-  SalomeApp_Notebook* getNotebook();
+  SalomeApp_Notebook* getNotebook() const;
 
 private:
   SMESHGUI*           mySMESHGUI;
index 899581804e70624205c88d31e152412faacb85dd..a97fde5c20811085db7be0fb1da978ae87bf27ea 100644 (file)
@@ -4341,6 +4341,29 @@ int SMESH_Gen_i::GetCurrentStudyID()
   return myCurrentStudy->_is_nil() || myCurrentStudy->_non_existent() ? -1 : myCurrentStudy->StudyId();
 }
     
+//=================================================================================
+// function : GetStudy()
+// purpose  : Returns a pointer to SALOMEDS Study object by its id
+//=================================================================================
+SALOMEDS::Study_ptr SMESH_Gen_i::GetStudy(CORBA::Long theStudyID)
+{
+  CORBA::Object_var aSMObject = GetNS()->Resolve( "/myStudyManager" );
+  SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow( aSMObject );
+  SALOMEDS::Study_var aStudy = aStudyManager->GetStudyByID( theStudyID );
+  return aStudy._retn();
+}
+
+//=================================================================================
+// function : GetNotebook()
+// purpose  : Returns a pointer to SALOME Notebook object by an id of the study
+//=================================================================================
+SALOME::Notebook_ptr SMESH_Gen_i::GetNotebook( CORBA::Long theStudyID )
+{
+  SALOMEDS::Study_ptr aStudy = GetStudy( theStudyID );
+  SALOME::Notebook_var aNotebook = aStudy->GetNotebook();
+  return aNotebook._retn();
+}
+
 //=============================================================================
 /*! 
  *  SMESHEngine_factory
index ed872eee3304b8a3db83319b2327002f3c71b021..1a43e4b3e27fa18da6fe06a1c9e48344632931d0 100644 (file)
@@ -505,6 +505,9 @@ public:
    */
   SALOMEDS::SObject_ptr GetAlgoSO(const ::SMESH_Algo* algo);
 
+  SALOMEDS::Study_ptr GetStudy(CORBA::Long theStudyID);
+  SALOME::Notebook_ptr GetNotebook(CORBA::Long theStudyID);
+
 private:
   // Create hypothesis of given type
   SMESH::SMESH_Hypothesis_ptr createHypothesis( const char* theHypName,
index cb761b89befb174d1f1ec3f233a8006a522deee7..c3123b3f5a79293b2f7b5fd0c563799bbdb73615 100644 (file)
@@ -749,6 +749,9 @@ SALOMEDS::SObject_ptr
     SetName( aHypSO, theName, aHypName );
   }
 
+  if( SMESH_Hypothesis_i* aServant = dynamic_cast<SMESH_Hypothesis_i*>( GetServant( theHyp ).in() ) )
+    aServant->UpdateStringAttribute();
+
   if(MYDEBUG) MESSAGE("PublishHypothesis--END")
   return aHypSO._retn();
 }
index e4f3a43c24c1246c5b52ee5902fd56632c1728e9..219c1e12699fe2a141673a6e6ae12639bf2459dd 100644 (file)
@@ -191,6 +191,8 @@ void SMESH_Hypothesis_i::SetParameters( SALOME::Notebook_ptr theNotebook, const
       theNotebook->AddDependency( _this(), aParamPtr );
   }
   myBaseImpl->SetParameters( aParams );
+
+  UpdateStringAttribute();
 }
 
 //=============================================================================
@@ -199,7 +201,6 @@ void SMESH_Hypothesis_i::SetParameters( SALOME::Notebook_ptr theNotebook, const
  *
  */
 //=============================================================================
-//char* SMESH_Hypothesis_i::GetParameters()
 SALOME::StringArray* SMESH_Hypothesis_i::GetParameters()
 {
   std::list<std::string> aParams = myBaseImpl->GetParameters();
@@ -221,6 +222,46 @@ void SMESH_Hypothesis_i::Update( SALOME::Notebook_ptr theNotebook )
 {
 }
 
+//=============================================================================
+/*!
+ * SMESH_Hypothesis_i::UpdateStringAttribute()
+ *
+ */
+//=============================================================================
+void SMESH_Hypothesis_i::UpdateStringAttribute()
+{
+  SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+
+  SALOME::Notebook_ptr aNotebook = aSMESHGen->GetNotebook( myBaseImpl->GetStudyId() );
+
+  SALOME::StringArray* anObjectParameters = aNotebook->GetObjectParameters( GetComponent(), GetEntry() );
+  int aParametersLength = anObjectParameters ? anObjectParameters->length() : 0;
+  if( aParametersLength == 0 )
+    return;
+
+  SALOMEDS::Study_ptr aStudy = aSMESHGen->GetStudy( myBaseImpl->GetStudyId() );
+  SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+  SALOMEDS::SObject_var aSObject = SMESH_Gen_i::ObjectToSObject( aStudy, SMESH::SMESH_Hypothesis::_narrow( _this() ) );
+  if( CORBA::is_nil( aSObject ) )
+    return;
+
+  SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute( aSObject, "AttributeString" );
+  SALOMEDS::AttributeString_var aStringAttrib = SALOMEDS::AttributeString::_narrow( anAttr );
+
+  std::string aString;
+  for( int i = 0, n = anObjectParameters->length(); i < n; i++ ) {
+    std::string aParameter = anObjectParameters->operator[](i).in();
+    if( aParameter != "" )
+    {
+      if( aString != "" )
+        aString += ", ";
+      aString += aParameter;
+    }
+  }
+  aStringAttrib->SetValue( aString.c_str() );
+  aStringAttrib->Destroy();
+}
+
 //=============================================================================
 /*!
  *  SMESH_Hypothesis_i::GetImpl
index 6add2c26395942ece9a98bd210519911cdec70a8..939c55c3a5013986a945eb52b04adc6fab29ac65 100644 (file)
@@ -65,13 +65,13 @@ public:
   // Get unique id of hypothesis
   CORBA::Long GetId();
   
-  // ...
+  // Get internal entry of hypothesis
   virtual char* GetEntry();
 
-  // ...
+  // Get name of the component
   virtual char* GetComponent();
 
-  // ...
+  // Get validity status of hypothesis
   virtual CORBA::Boolean IsValid();
 
   // Set list of parameters, used for Hypothesis creation
@@ -80,9 +80,12 @@ public:
   // Return list of notebook variables used for Hypothesis creation
   virtual SALOME::StringArray* GetParameters();
 
-  // ...
+  // Update hypothesis according to the SALOME Notebook
   virtual void Update( SALOME::Notebook_ptr theNotebook );
 
+  // Update string attribute of hypothesis
+  virtual void UpdateStringAttribute();
+
   //Return true if hypothesis was published in study
   bool IsPublished();
 
index a9235af91d71eafdbc8f4ca1ab0a4f69dd9b7c63..643492dc1a1a367afeea10775de5ab0ab5b6a7cd 100644 (file)
@@ -3380,7 +3380,7 @@ void SMESH_Mesh_i::checkGroupNames()
 
 //=============================================================================
 /*!
- * \brief ...
+ * \brief Get internal entry of mesh
  */
 //=============================================================================
 char* SMESH_Mesh_i::GetEntry()
@@ -3390,7 +3390,7 @@ char* SMESH_Mesh_i::GetEntry()
 
 //=============================================================================
 /*!
- * \brief ...
+ * \brief Get name of the component
  */
 //=============================================================================
 char* SMESH_Mesh_i::GetComponent()
@@ -3400,7 +3400,7 @@ char* SMESH_Mesh_i::GetComponent()
 
 //=============================================================================
 /*!
- * \brief ...
+ * \brief Get validity status of mesh
  */
 //=============================================================================
 CORBA::Boolean SMESH_Mesh_i::IsValid()
@@ -3429,13 +3429,22 @@ SALOME::StringArray* SMESH_Mesh_i::GetParameters()
 
 //=============================================================================
 /*!
- * \brief ...
+ * \brief Update mesh according to the SALOME Notebook
  */
 //=============================================================================
 void SMESH_Mesh_i::Update( SALOME::Notebook_ptr theNotebook )
 {
 }
 
+//=============================================================================
+/*!
+ * \brief Update string attribute of mesh
+ */
+//=============================================================================
+void SMESH_Mesh_i::UpdateStringAttribute()
+{
+}
+
 //=============================================================================
 /*!
  * \brief Returns statistic of mesh elements
index d8fbb6cf1521137dae8f076c9628c4a488798a14..c36146eccd0029fcb63aa91c8238a21179092c28 100644 (file)
@@ -472,17 +472,17 @@ public:
   virtual SALOME_MED::MedFileInfo* GetMEDFileInfo();
 
   /*!
-   * ...
+   * Get internal entry of mesh
    */
   virtual char* GetEntry();
 
   /*!
-   * ...
+   * Get name of the component
    */
   virtual char* GetComponent();
 
   /*!
-   * ...
+   * Get validity status of mesh
    */
   virtual CORBA::Boolean IsValid();
 
@@ -497,10 +497,15 @@ public:
   virtual SALOME::StringArray* GetParameters();
 
   /*!
-   * ...
+   * Update mesh according to the SALOME Notebook
    */
   virtual void Update( SALOME::Notebook_ptr theNotebook );
 
+  /*!
+   * Update string attribute of mesh
+   */
+  virtual void UpdateStringAttribute();
+
   /*!
    * Returns statistic of mesh elements
    * Result array of number enityties
index 805cdae27c527bc6337655584bd667a5ded60c66..f55424795574b5c4966939bba2815a648f5a2708 100644 (file)
@@ -91,8 +91,8 @@ bool StdMeshersGUI_NbSegmentsCreator::checkParams( QString& msg, QStringList& ab
   bool res = true;
   res = myNbSeg->isValid( msg, absentParams, true ) && res;
   res = myScale->isValid( msg, absentParams, true ) && res;
-  res = res && storeParamsToHypo( data_new );
-  res = res && storeParamsToHypo( data_old );
+  res = res && storeParamsToHypo( data_new, true );
+  storeParamsToHypo( data_old, true );
   return res;
 }
 
@@ -342,7 +342,7 @@ bool StdMeshersGUI_NbSegmentsCreator::readParamsFromHypo( NbSegmentsHypothesisDa
   return true;
 }
 
-bool StdMeshersGUI_NbSegmentsCreator::storeParamsToHypo( const NbSegmentsHypothesisData& h_data ) const
+bool StdMeshersGUI_NbSegmentsCreator::storeParamsToHypo( const NbSegmentsHypothesisData& h_data, bool isOnlyCheck ) const
 {
   StdMeshers::StdMeshers_NumberOfSegments_var h =
     StdMeshers::StdMeshers_NumberOfSegments::_narrow( hypothesis() );
@@ -381,9 +381,8 @@ bool StdMeshersGUI_NbSegmentsCreator::storeParamsToHypo( const NbSegmentsHypothe
     //the function will be checked with old conversion mode, so that it may occurs
     //unexpected errors for user
 
-    // temporal workaround
-    StdMeshersGUI_NbSegmentsCreator* that = const_cast<StdMeshersGUI_NbSegmentsCreator*>( this );
-    that->getNotebook()->setParameters( h, aVariablesList );
+    if( !isOnlyCheck )
+      getNotebook()->setParameters( h, aVariablesList );
   }
   catch(const SALOME::SALOME_Exception& ex)
   {
index 34682a25f9f8de0622bc74beeb9b4f81d4bf0c69..1c9612b28fa7c185028b04f142623f1c1125a035 100644 (file)
@@ -77,7 +77,7 @@ protected slots:
 private:
   bool readParamsFromHypo( NbSegmentsHypothesisData& ) const;
   bool readParamsFromWidgets( NbSegmentsHypothesisData& ) const;
-  bool storeParamsToHypo( const NbSegmentsHypothesisData& ) const;
+  bool storeParamsToHypo( const NbSegmentsHypothesisData&, bool = false ) const;
 
 private:
   SalomeApp_IntSpinBox*   myNbSeg;
index f929b5ffafc53b2b5471f01706c25bfd6b643984..3c0075c600a7e73b7507938b96354663b940cc80 100644 (file)
@@ -39,6 +39,7 @@
 
 // SALOME GUI includes
 #include <SUIT_ResourceMgr.h>
+#include <SalomeApp_Notebook.h>
 
 // IDL includes
 #include <SALOMEconfig.h>
@@ -421,9 +422,8 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
         StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
 
       h->SetLength( params[0].myValue.toDouble() );
-      //h->SetParameters(aVariablesList.join(":").toLatin1().constData());
       h->SetPrecision( params[1].myValue.toDouble() );
-      //h->SetParameters(aVariablesList.join(":").toLatin1().constData());
+      getNotebook()->setParameters( h, aVariablesList );
     }
     else if( hypType()=="MaxLength" )
     {
@@ -431,13 +431,13 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
         StdMeshers::StdMeshers_MaxLength::_narrow( hypothesis() );
 
       h->SetLength( params[0].myValue.toDouble() );
-      //h->SetParameters(aVariablesList.join(":").toLatin1().constData());
       h->SetUsePreestimatedLength( widget< QCheckBox >( 1 )->isChecked() );
       if ( !h->HavePreestimatedLength() && !h->_is_equivalent( initParamsHypothesis() )) {
         StdMeshers::StdMeshers_MaxLength_var hInit =
           StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
         h->SetPreestimatedLength( hInit->GetPreestimatedLength() );
       }
+      getNotebook()->setParameters( h, aVariablesList );
     }
     else if( hypType()=="SegmentLengthAroundVertex" )
     {
@@ -445,7 +445,7 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
         StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hypothesis() );
 
       h->SetLength( params[0].myValue.toDouble() );
-      //h->SetParameters(aVariablesList.join(":").toLatin1().constData());
+      getNotebook()->setParameters( h, aVariablesList );
     }
     else if( hypType()=="Arithmetic1D" )
     {
@@ -456,13 +456,12 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
         widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
 
       h->SetStartLength( params[0].myValue.toDouble() );
-      //h->SetParameters(aVariablesList.join(":").toLatin1().constData());
       h->SetEndLength( params[1].myValue.toDouble() );
-      //h->SetParameters(aVariablesList.join(":").toLatin1().constData());
       if (w) {
         h->SetReversedEdges( w->GetListOfIDs() );
         h->SetObjectEntry( w->GetMainShapeEntry() );
       }
+      getNotebook()->setParameters( h, aVariablesList );
     }
     else if( hypType()=="FixedPoints1D" )
     {
@@ -476,9 +475,9 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
         widget< StdMeshersGUI_SubShapeSelectorWdg >( 1 );
 
       if (w1) {
-        //h->SetParameters(aVariablesList.join(":").toLatin1().constData());
         h->SetPoints( w1->GetListOfPoints() );
         h->SetNbSegments( w1->GetListOfSegments() );
+        getNotebook()->setParameters( h, aVariablesList );
       }
       if (w2) {
         h->SetReversedEdges( w2->GetListOfIDs() );
@@ -489,8 +488,8 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
     {
       StdMeshers::StdMeshers_MaxElementArea_var h =
         StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() );
-      //h->SetParameters(aVariablesList.join(":").toLatin1().constData());
       h->SetMaxElementArea( params[0].myValue.toDouble() );
+      getNotebook()->setParameters( h, aVariablesList );
     }
     else if( hypType()=="MaxElementVolume" )
     {
@@ -498,7 +497,7 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
         StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() );
 
       h->SetMaxElementVolume( params[0].myValue.toDouble() );
-      //h->SetParameters(aVariablesList.join(":").toLatin1().constData());
+      getNotebook()->setParameters( h, aVariablesList );
     }
     else if( hypType()=="StartEndLength" )
     {
@@ -509,20 +508,19 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
         widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 );
 
       h->SetStartLength( params[0].myValue.toDouble() );
-      //h->SetParameters(aVariablesList.join(":").toLatin1().constData());
       h->SetEndLength( params[1].myValue.toDouble() );
-      //h->SetParameters(aVariablesList.join(":").toLatin1().constData());
       if (w) {
         h->SetReversedEdges( w->GetListOfIDs() );
         h->SetObjectEntry( w->GetMainShapeEntry() );
       }
+      getNotebook()->setParameters( h, aVariablesList );
     }
     else if( hypType()=="Deflection1D" )
     {
       StdMeshers::StdMeshers_Deflection1D_var h =
         StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() );
-      //h->SetParameters(aVariablesList.join(":").toLatin1().constData());
       h->SetDeflection( params[0].myValue.toDouble() );
+      getNotebook()->setParameters( h, aVariablesList );
     }
     else if( hypType()=="AutomaticLength" )
     {
@@ -537,7 +535,7 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
         StdMeshers::StdMeshers_NumberOfLayers::_narrow( hypothesis() );
 
       h->SetNumberOfLayers( params[0].myValue.toInt() );
-      //h->SetParameters(aVariablesList.join(":").toLatin1().constData());
+      getNotebook()->setParameters( h, aVariablesList );
     }
     else if( hypType()=="LayerDistribution" )
     {
@@ -547,8 +545,10 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
         widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
       
       h->SetLayerDistribution( w->GetHypothesis() );
-      //h->SetParameters(w->GetHypothesis()->GetParameters());
-      //w->GetHypothesis()->ClearParameters();
+      /* ouv: temporarily disabled
+      h->SetParameters(w->GetHypothesis()->GetParameters());
+      w->GetHypothesis()->ClearParameters();
+      */
     }
     else if( hypType()=="NumberOfLayers2D" )
     {
@@ -556,7 +556,7 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
         StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hypothesis() );
 
       h->SetNumberOfLayers( params[0].myValue.toInt() );
-      //h->SetParameters(aVariablesList.join(":").toLatin1().constData());
+      getNotebook()->setParameters( h, aVariablesList );
     }
     else if( hypType()=="LayerDistribution2D" )
     {
@@ -566,8 +566,10 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
         widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 );
       
       h->SetLayerDistribution( w->GetHypothesis() );
-      //h->SetParameters(w->GetHypothesis()->GetParameters());
-      //w->GetHypothesis()->ClearParameters();
+      /* ouv: temporarily disabled
+      h->SetParameters(w->GetHypothesis()->GetParameters());
+      w->GetHypothesis()->ClearParameters();
+      */
     }
     else if( hypType()=="ProjectionSource1D" )
     {
@@ -653,7 +655,6 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
   }
   
   SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
-  //SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters();
   SALOME::StringArray* aParameters = hyp->GetParameters();
 
   if( hypType()=="LocalLength" )