]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Merge from V5_1_main 04/11/2009 (implementation of issue 0020085: Visualize evolution... mergefrom_V5_1_main_04Nov09
authorvsr <vsr@opencascade.com>
Wed, 4 Nov 2009 10:37:46 +0000 (10:37 +0000)
committervsr <vsr@opencascade.com>
Wed, 4 Nov 2009 10:37:46 +0000 (10:37 +0000)
29 files changed:
doc/salome/gui/VISU/images/evolution_context_menu.png [new file with mode: 0755]
doc/salome/gui/VISU/images/evolution_dialog.png [new file with mode: 0755]
doc/salome/gui/VISU/images/evolution_restore.png [new file with mode: 0755]
doc/salome/gui/VISU/images/evolution_result.png [new file with mode: 0755]
doc/salome/gui/VISU/input/3d_management.doc
doc/salome/gui/VISU/input/evolution.doc [new file with mode: 0644]
idl/VISU_Gen.idl
src/ENGINE/VISU_Engine_i.cc
src/ENGINE/VISU_Engine_i.hh
src/VISUGUI/Makefile.am
src/VISUGUI/VISU_msg_en.ts
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI.h
src/VISUGUI/VisuGUI_ActionsDef.h
src/VISUGUI/VisuGUI_Displayer.cxx
src/VISUGUI/VisuGUI_EvolutionDlg.cxx [new file with mode: 0644]
src/VISUGUI/VisuGUI_EvolutionDlg.h [new file with mode: 0644]
src/VISUGUI/VisuGUI_Tools.cxx
src/VISUGUI/VisuGUI_Tools.h
src/VISU_I/Makefile.am
src/VISU_I/VISUConfig.cc
src/VISU_I/VISU_DumpPython.cc
src/VISU_I/VISU_Evolution.cxx [new file with mode: 0644]
src/VISU_I/VISU_Evolution.h [new file with mode: 0644]
src/VISU_I/VISU_Gen_i.cc
src/VISU_I/VISU_Gen_i.hh
src/VISU_I/VISU_Tools.cxx [new file with mode: 0644]
src/VISU_I/VISU_Tools.h [new file with mode: 0644]
src/VISU_I/VISU_View_i.hh

diff --git a/doc/salome/gui/VISU/images/evolution_context_menu.png b/doc/salome/gui/VISU/images/evolution_context_menu.png
new file mode 100755 (executable)
index 0000000..56af0bc
Binary files /dev/null and b/doc/salome/gui/VISU/images/evolution_context_menu.png differ
diff --git a/doc/salome/gui/VISU/images/evolution_dialog.png b/doc/salome/gui/VISU/images/evolution_dialog.png
new file mode 100755 (executable)
index 0000000..90bf9b9
Binary files /dev/null and b/doc/salome/gui/VISU/images/evolution_dialog.png differ
diff --git a/doc/salome/gui/VISU/images/evolution_restore.png b/doc/salome/gui/VISU/images/evolution_restore.png
new file mode 100755 (executable)
index 0000000..97029a9
Binary files /dev/null and b/doc/salome/gui/VISU/images/evolution_restore.png differ
diff --git a/doc/salome/gui/VISU/images/evolution_result.png b/doc/salome/gui/VISU/images/evolution_result.png
new file mode 100755 (executable)
index 0000000..e3df751
Binary files /dev/null and b/doc/salome/gui/VISU/images/evolution_result.png differ
index 7ed20add2b3758e61dcf322ef7687b1681436051..962f0d57365247cffadd0fee24519bdf4306448c 100755 (executable)
@@ -36,6 +36,8 @@ module are:
 <ul>
 <li> \subpage animating_page - another way of animation of
 presentations on fields. </li>
+<li> \subpage evolution_page - tracing of temporal evolution of a
+variable at a given point.</li>
 <li> \subpage translate_presentation_page - displacement of
 presentations in the viewer.</li>
 <li> \subpage recording_page - allows to dump user actions in an AVI
diff --git a/doc/salome/gui/VISU/input/evolution.doc b/doc/salome/gui/VISU/input/evolution.doc
new file mode 100644 (file)
index 0000000..baeef5a
--- /dev/null
@@ -0,0 +1,50 @@
+/*!
+
+\page evolution_page Evolution on Point
+
+This feature allows to trace temporal evolution of a variable at a given point.
+It can be activated by context menu on field:
+
+\image html evolution_context_menu.png
+
+Presence of the <b>Evolution on Point</b> action in the context menu depends on
+the following conditions:
+
+<ul>
+<li>Active view should be VTK view (to choose a point using a preview actor).</li>
+<li>The selected field should be defined on the Node entity.</li>
+<li>The selected field should have multiple time stamps.</li>
+</ul>
+
+After activation of the action the following dialog is displayed together with
+preview actor in the VTK view:
+
+\image html evolution_dialog.png
+
+Three parameters are controlled by this dialog:
+<ul>
+<li><b>Field</b> - name of the field. This parameter is intended for informational
+purpose only and could not be changed by the dialog.</li>
+<li><b>Point</b> - id of the point. It could be set by selection of point on the
+preview actor displayed in the VTK view (note that there is no need to switch to
+the point selection mode manually, because it is turned on automatically during
+the life time of the dialog).</li>
+<li><b>Component</b> - name of the component (scalar mode). This control is
+enabled if there are multiple components in the field data.</li>
+</ul>
+
+Clicking on <b>OK</b> button leads to creation of Plot2d view with a graph
+of the Evolution:
+
+\image html evolution_result.png
+
+X axis of the graph corresponds to values of the time stamps, Y axis - to values
+of the selected component of the field at the specified point.
+
+\note Evolution is automatically published to the study after clicking on <b>OK</b>
+button. It could be restored by clicking on the <b>Show</b> action in the context
+menu on the published object:
+
+\image html evolution_restore.png
+
+*/
index 12efbee1693381753871389c61dfebf681d8dd34..8946a982c5680248c3692229249d38b9c29c39f3 100644 (file)
@@ -114,6 +114,7 @@ module VISU {
     TFIELD, /*!< Field represents the results of calculations (it can be scalar or vector values), grouped together under one physical concept. */
     TTIMESTAMP, /*!<Time stamp represents a subfield: the results of calculations are taken in one definite moment. */
     TANIMATION, /*!< Represents Animation object. */
+    TEVOLUTION, /*!< Represents Evolution object. */
     TCOLOREDPRS3DHOLDER, /*!< Colored 3D presentation holder */
     TCOLOREDPRS3DCACHE, /*!< Colored 3D presentation cache */
     TPART, /*!< MULTIPR: part of a mesh */
@@ -2002,6 +2003,46 @@ module VISU {
   };
 
   
+  //-------------------------------------------------------
+  interface XYPlot;
+
+  //-------------------------------------------------------
+  /*! \brief Interface %Evolution
+   *
+   */
+  interface Evolution : Base 
+  {
+    /*!
+     * Defines the field which will be used as a base for generation of the evolution.
+     * \param theObject The %SObject corresponding to the field.
+     */
+    boolean setField(in SALOMEDS::SObject theObject);
+
+    /*!
+     * Sets id of the point for which the evolution will be generated.
+     * \param thePointId id of the point.
+     */
+    void setPointId(in long thePointId);
+
+    /*!
+     * Sets id of the component for which the evolution will be generated.
+     * \param thePointId id of the component.
+     */
+    void setComponentId(in long theComponentId);
+
+    /*!
+     * Shows the evolution.
+     */
+    boolean showEvolution();
+
+    /*!
+     * Restores the evolution from study.
+     * \param theSObj the study object from which the evolution should be restored.
+     */
+    void restoreFromStudy(in SALOMEDS::SObject theSObj);
+  };
+
+
   /*! \brief Interface %Result
    *
    * This interface serves for inner representation of data generated
@@ -2392,6 +2433,11 @@ module VISU {
      */
     Animation CreateAnimation(in View3D theView3d);
 
+    /*! Creates an evolution in the XY plot.
+     * \param theXYPlot The XY plot, where the evolution will be rendered.
+     */
+    Evolution CreateEvolution(in XYPlot theXYPlot);
+
     void DeleteResult(in Result theResult);
 
     void DeletePrs3d(in Prs3d thePrs3d);
index 7f8731e6d766e0c8d00c0170c35c675b449d3714..2d0f66ad2a4cdd5fe770b9e29db33fcb1af18c47 100644 (file)
@@ -415,6 +415,11 @@ namespace VISU{
   }
 
 
+  Evolution_ptr VISU_Gen_i::CreateEvolution(XYPlot_ptr theXYPlot){
+    return myVisuGen->CreateEvolution(theXYPlot);
+  }
+
+
   void VISU_Gen_i::DeleteResult(Result_ptr theResult){
     myVisuGen->DeleteResult(theResult);
   }
index bf44466e12c67363f921f94665de943c0de4a274..950246d38a81944eebe208deb66e21973d8354f1 100644 (file)
@@ -185,6 +185,7 @@ namespace VISU
     virtual Curve_ptr CreateCurveWithZ(Table_ptr theTable, CORBA::Long theHRow, CORBA::Long theVRow, CORBA::Long theZRow);
     virtual Container_ptr CreateContainer();
     virtual Animation_ptr CreateAnimation(View3D_ptr theView3d);
+    virtual Evolution_ptr CreateEvolution(XYPlot_ptr theXYPlot);
     
     virtual void DeleteResult(Result_ptr theResult);
     virtual void DeletePrs3d(Prs3d_ptr thePrs3d);
index a7519f70b65e6f166b36ab1828b93f1dad264a09..aff94dc941ac0f6fcbd1920c538ea474ecd18f84 100644 (file)
@@ -44,6 +44,7 @@ salomeinclude_HEADERS= \
        VisuGUI_FileDlg.h \
        VisuGUI_CursorDlg.h \
        VisuGUI_TimeAnimation.h \
+       VisuGUI_EvolutionDlg.h \
        VisuGUI_EditContainerDlg.h \
        VisuGUI_ClippingDlg.h \
        VisuGUI_DialogRunner.h \
@@ -90,6 +91,7 @@ dist_libVISU_la_SOURCES= \
        VisuGUI_FileDlg.cxx \
        VisuGUI_CursorDlg.cxx \
        VisuGUI_TimeAnimation.cxx \
+       VisuGUI_EvolutionDlg.cxx \
        VisuGUI_EditContainerDlg.cxx \
        VisuGUI_ClippingDlg.cxx \
        VisuGUI_DialogRunner.cxx \
@@ -138,6 +140,7 @@ MOC_FILES= \
        VisuGUI_FileDlg_moc.cxx \
        VisuGUI_CursorDlg_moc.cxx \
        VisuGUI_TimeAnimation_moc.cxx \
+       VisuGUI_EvolutionDlg_moc.cxx \
        VisuGUI_EditContainerDlg_moc.cxx \
        VisuGUI_ClippingDlg_moc.cxx \
        VisuGUI_DialogRunner_moc.cxx \
index 50b7642a781dd44acfd404db667c4c57687938b0..f8fddcb921b9f4d27991bcfe258bd79c350a8b72 100644 (file)
             <translation>Can't create animation for these fields:
 number of time stamps or number of components is not the same!</translation>
         </message>
+        <message>
+            <source>ERR_CANT_CREATE_EVOLUTION</source>
+            <translation>Can't create evolution for this field!</translation>
+        </message>
         <message>
             <source>ERR_CANT_FIND_MED_COMPONENT</source>
             <translation>Failed to activate MED engine!</translation>
@@ -1229,6 +1233,10 @@ Please, refer to the documentation.</translation>
             <source>MEN_PLOT_3D</source>
             <translation>Plot3D</translation>
         </message>
+        <message>
+            <source>MEN_POINT_EVOLUTION</source>
+            <translation>Evolution on Point</translation>
+        </message>
         <message>
             <source>MEN_POINT_SELECTION</source>
             <translation>Point Selection</translation>
@@ -1293,6 +1301,10 @@ Please, refer to the documentation.</translation>
             <source>MEN_SHOW_ANIMATION</source>
             <translation>Show...</translation>
         </message>
+        <message>
+            <source>MEN_SHOW_EVOLUTION</source>
+            <translation>Show...</translation>
+        </message>
         <message>
             <source>MEN_SHOW_TABLE</source>
             <translation>Show Table</translation>
@@ -1991,6 +2003,37 @@ Please, provide non-empty resulting presentation.</translation>
             <translation>Table</translation>
         </message>
     </context>
+    <context>
+        <name>VisuGUI_EvolutionDlg</name>
+        <message>
+            <source>COMPONENT</source>
+            <translation>Component</translation>
+        </message>
+        <message>
+            <source>ERR_EXTRACTION_OF_DATA_FAILED</source>
+            <translation>Extraction of data failed!</translation>
+        </message>
+        <message>
+            <source>ERR_INVALID_SELECTION</source>
+            <translation>Invalid selection!</translation>
+        </message>
+        <message>
+            <source>FIELD</source>
+            <translation>Field</translation>
+        </message>
+        <message>
+            <source>POINT</source>
+            <translation>Point</translation>
+        </message>
+        <message>
+            <source>PARAMETERS</source>
+            <translation>Parameters</translation>
+        </message>
+        <message>
+            <source>TITLE</source>
+            <translation>Evolution on Point</translation>
+        </message>
+    </context>
     <context>
         <name>VisuGUI_FeatureEdgesPanel</name>
         <message>
index 34d3d0e213cd30667ecc0ad7a8432553c2372d2b..11b369d44152d03d00efb82fb20eef02edd18fb8 100644 (file)
 #include "VisuGUI_CursorDlg.h"
 #include "VisuGUI_Selection.h"
 #include "VisuGUI_TimeAnimation.h"
+#include "VisuGUI_EvolutionDlg.h"
 #include "VisuGUI_EditContainerDlg.h"
 #include "VisuGUI_ClippingDlg.h"
 #include "VisuGUI_Plot3DDlg.h"
@@ -2126,6 +2127,70 @@ VisuGUI
   aAnimationDlg->show();
 }
 
+//----------------------------------------------------------------------------
+void
+VisuGUI
+::OnPointEvolution()
+{
+  SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>( this );
+  if( !aViewWindow )
+    return;
+
+  _PTR(Study) aCStudy = GetCStudy( GetAppStudy( this ) );
+  VisuGUI_EvolutionDlg* aDlg = new VisuGUI_EvolutionDlg( this, aViewWindow, aCStudy );
+
+  LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr( this );
+  SALOME_ListIO aListIO;
+  aSelectionMgr->selectedObjects( aListIO );
+
+  SALOME_ListIteratorOfListIO It( aListIO );
+  for( ; It.More(); It.Next() )
+  {
+    _PTR(SObject) aSObject = aCStudy->FindObjectID( It.Value()->getEntry() );
+    if( !aDlg->setField( aSObject ) )
+    {
+      SUIT_MessageBox::warning( GetDesktop( this ),
+                                tr( "WRN_VISU" ),
+                                tr( "ERR_CANT_CREATE_EVOLUTION" ) );
+      delete aDlg;
+      return;
+    }
+  }
+  aDlg->show();
+}
+
+//----------------------------------------------------------------------------
+void
+VisuGUI
+::OnShowEvolution()
+{
+  SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>( this );
+  if( !aViewWindow )
+    return;
+
+  LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr( this );
+  SALOME_ListIO aListIO;
+  aSelectionMgr->selectedObjects( aListIO );
+
+  if( aListIO.Extent() != 1 )
+    return;
+
+  const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
+
+  _PTR(Study) aCStudy = GetCStudy( GetAppStudy( this ) );
+  _PTR(SObject) aSObj = aCStudy->FindObjectID( anIO->getEntry() );
+  if( !aSObj )
+    return;
+
+  VISU::VISUType aType = VISU::Storable::SObject2Type( aSObj );
+  if( aType != VISU::TEVOLUTION )
+    return;
+
+  VisuGUI_EvolutionDlg* aDlg = new VisuGUI_EvolutionDlg( this, aViewWindow, aCStudy );
+  aDlg->restoreFromStudy( aSObj );
+  aDlg->show();
+}
+
 //----------------------------------------------------------------------------
 void
 VisuGUI
@@ -2714,6 +2779,10 @@ VisuGUI
                 tr("MEN_SUCCCESSIVE_ANIMATION"), "", 0, aParent, false,
                 this, SLOT(OnSucccessiveTimeAnimation()));
 
+  createAction( VISU_POINT_EVOLUTION, tr("MEN_POINT_EVOLUTION"), QIcon(),
+                tr("MEN_POINT_EVOLUTION"), "", 0, aParent, false,
+                this, SLOT(OnPointEvolution()));
+
   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ERASE_ALL"));
   createAction( VISU_ERASE_ALL, tr("MEN_ERASE_ALL"), QIcon(aPixmap),
                 tr("MEN_ERASE_ALL"), "", 0, aParent, false,
@@ -2752,6 +2821,10 @@ VisuGUI
                 tr("MEN_SHOW_ANIMATION"), "", 0, aParent, false,
                 this, SLOT(OnShowAnimation()));
 
+  createAction( VISU_SHOW_EVOLUTION, tr("MEN_SHOW_EVOLUTION"), QIcon(),
+                tr("MEN_SHOW_EVOLUTION"), "", 0, aParent, false,
+                this, SLOT(OnShowEvolution()));
+
   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT_3D"));
   createAction( VISU_PLOT3D_FROM_CUTPLANE, tr("MEN_PLOT3D_FROM_CUTPLANE"), QIcon(aPixmap),
                 tr("MEN_PLOT3D_FROM_CUTPLANE"), "", 0, aParent, false,
@@ -3008,6 +3081,10 @@ VisuGUI
 
   mgr->insert( separator(), -1, -1, -1 );
 
+  mgr->insert( action( VISU_POINT_EVOLUTION ), -1, -1, -1 );
+
+  mgr->insert( separator(), -1, -1, -1 );
+
   // view parameters commands
   mgr->insert( action( VISU_SAVE_VIEW_PARAMS ), -1, -1, -1 ); // save view params
   mgr->insert( action( VISU_SAVE_VIEW_PARAMS_1 ), -1, -1, -1 ); // save view params
@@ -3236,6 +3313,13 @@ VisuGUI
   aRule += " and activeView in {'VTKViewer' 'SVTK'}";
   mgr->setRule( action( VISU_SUCCCESSIVEANIMATION ), aRule );
 
+  aRule = "client='ObjectBrowser' and selcount>0";
+  aRule += " and $type in {'VISU::TFIELD'}";
+  aRule += " and medEntity='NODE_ENTITY'";
+  aRule += " and nbTimeStamps>1";
+  aRule += " and activeView in {'VTKViewer' 'SVTK'}";
+  mgr->setRule( action( VISU_POINT_EVOLUTION ), aRule );
+
   aRule = "client='ObjectBrowser' and $type in {'VISU::TENTITY' 'VISU::TFAMILY' 'VISU::TGROUP'}";
   mgr->setRule( action( VISU_CREATE_PRS ), aRule + " and selcount=1" );
   mgr->setRule( action( VISU_CREATE_MANY_PRS ), aRule + " and selcount>1" );
@@ -3409,6 +3493,8 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QMenu* theMenu, QStrin
   VISU::VISUType aType = VISU::Storable::RestoringMap2Type( aMap );
   if (aType == VISU::TANIMATION) {
     theMenu->addAction( action( VISU_SHOW_ANIMATION ) );
+  } else if (aType == VISU::TEVOLUTION && GetActiveViewWindow<SVTK_ViewWindow>(this)) {
+    theMenu->addAction( action( VISU_SHOW_EVOLUTION ) );
   } else if (isOBClient) {
     if (IsSObjectTable(aSObject)) {
       /*      action( VISU_SHOW_TABLE )->addTo(theMenu);
index e5fa48663373c808214466c746335c31901e8996..53b8064d36d9e29ed0e4043ac1faed4e0e92a1d0 100644 (file)
@@ -179,6 +179,9 @@ protected slots:
   void OnSucccessiveTimeAnimation();
   void OnShowAnimation();
 
+  void OnPointEvolution();
+  void OnShowEvolution();
+
   void OnCopyPresentation();
 
   void OnTranslatePrs();
index be51141ed1dd9777b0979c0c2ca6c1f8ff55f3d9..3b0be7fcc3011c827f090c7cb2379e290a071c00 100644 (file)
 #define VISU_SELECTION_INFO         4065
 #define VISU_PARALLELANIMATION      4066
 #define VISU_SUCCCESSIVEANIMATION   4067
+#define VISU_POINT_EVOLUTION        4068
 
 #define VISU_ERASE_ALL              4070
 #define VISU_GLOBAL_SELECTION       4071
 #define VISU_MERGE_SCALAR_BARS      4080
 #define VISU_FREE_SCALAR_BARS       4081
 #define VISU_SHOW_ANIMATION         4082
+#define VISU_SHOW_EVOLUTION         4086
 
 #define VISU_PLOT3D_FROM_CUTPLANE   4085
 
index 41366ee6b47eee61576d388875d2e550c1f32cd2..c8a65cf7e192656042ee1f7ecb0a209ae8229cf9 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "VisuGUI.h"
 #include "VisuGUI_Tools.h"
+#include "VISU_Tools.h"
 #include "VISU_ViewManager_i.hh"
 #include "VISU_Actor.h"
 
diff --git a/src/VISUGUI/VisuGUI_EvolutionDlg.cxx b/src/VISUGUI/VisuGUI_EvolutionDlg.cxx
new file mode 100644 (file)
index 0000000..07cbefa
--- /dev/null
@@ -0,0 +1,383 @@
+//  Copyright (C) 2007-2008  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
+//
+//  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.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//  File   : VisuGUI_EvolutionDlg.cxx
+//  Author : Oleg UVAROV
+//  Module : VISU
+//
+#include "VisuGUI_EvolutionDlg.h"
+
+#include "VisuGUI.h"
+#include "VisuGUI_Tools.h"
+#include "VisuGUI_ViewTools.h"
+
+#include <VISU_Evolution.h>
+
+#include <VISU_Gen_i.hh>
+#include <VISU_Result_i.hh>
+
+#include <VISU_Convertor.hxx>
+
+#include <SALOME_InteractiveObject.hxx>
+
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+#include <SUIT_Desktop.h>
+
+#include <LightApp_SelectionMgr.h>
+
+#include <SPlot2d_ViewModel.h>
+#include <Plot2d_ViewFrame.h>
+
+#include <QComboBox>
+#include <QGroupBox>
+#include <QKeyEvent>
+#include <QLabel>
+#include <QLayout>
+#include <QLineEdit>
+
+#include <vtkDataSetMapper.h>
+
+VisuGUI_EvolutionDlg::VisuGUI_EvolutionDlg( VisuGUI* theModule,
+                                            SVTK_ViewWindow* theViewWindow,
+                                            _PTR(Study) theStudy ) :
+  QtxDialog( VISU::GetDesktop( theModule ), false, false, QtxDialog::Standard, Qt::Dialog ),
+  myModule( theModule ),
+  myViewWindow( theViewWindow ),
+  myPreviewActor( NULL )
+{
+  setWindowTitle( tr( "TITLE" ) );
+  setAttribute( Qt::WA_DeleteOnClose, true );
+
+  myEngine = new VISU_Evolution( theStudy );
+
+  QFrame* aMainFrame = mainFrame();
+
+  // Parameters
+  QGroupBox* aParamGrp = new QGroupBox( tr( "PARAMETERS" ), aMainFrame );
+
+  QLabel* aFieldLabel = new QLabel( tr( "FIELD" ), aParamGrp );
+  myFieldLE = new QLineEdit( aParamGrp );
+  myFieldLE->setReadOnly( true );
+
+  QLabel* aPointLabel = new QLabel( tr( "POINT" ) );
+  myPointLE = new QLineEdit( aParamGrp );
+  myPointLE->setReadOnly( true );
+
+  QLabel* aComponentLabel = new QLabel( tr( "COMPONENT" ) );
+  myComponentCB = new QComboBox( aParamGrp );
+  myComponentCB->setEditable( false );
+
+  QGridLayout* aParamLayout = new QGridLayout( aParamGrp );
+  aParamLayout->setMargin( 11 );
+  aParamLayout->setSpacing( 6 );
+  aParamLayout->addWidget( aFieldLabel,     0, 0 );
+  aParamLayout->addWidget( myFieldLE,       0, 1 );
+  aParamLayout->addWidget( aPointLabel,     1, 0 );
+  aParamLayout->addWidget( myPointLE,       1, 1 );
+  aParamLayout->addWidget( aComponentLabel, 2, 0 );
+  aParamLayout->addWidget( myComponentCB,   2, 1 );
+
+  // Common
+  QBoxLayout* aMainLayout = new QVBoxLayout( aMainFrame );
+  aMainLayout->setMargin( 0 );
+  aMainLayout->setSpacing( 0 );
+  aMainLayout->addWidget( aParamGrp );
+
+  connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
+
+  connect( myModule->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
+           this,                               SLOT( onSelectionEvent() ) );
+
+  myStoredSelectionMode = ActorSelection;
+}
+
+//------------------------------------------------------------------------
+VisuGUI_EvolutionDlg::~VisuGUI_EvolutionDlg()
+{
+  if( myEngine != NULL )
+  {
+    delete myEngine;
+    myEngine = NULL;
+  }
+}
+
+//------------------------------------------------------------------------
+bool VisuGUI_EvolutionDlg::setField( _PTR(SObject) theField )
+{
+  if( myEngine->setField( theField ) )
+  {
+    updateFromEngine();
+    return true;
+  }
+  return false;
+}
+
+//------------------------------------------------------------------------
+void VisuGUI_EvolutionDlg::updateFromEngine()
+{
+  std::string aFieldName = myEngine->getFieldName();
+  myFieldLE->setText( QString( aFieldName.c_str() ) );
+
+  QStringList aComponentList;
+  VISU::ComponentDataList aComponentDataList = myEngine->getComponentDataList();
+  int aNbComp = aComponentDataList.size();
+
+  bool isModulus;
+  int aComponentId = 0;
+  VISU::ComponentDataListIterator anIter( aComponentDataList );
+  while( anIter.hasNext() )
+  {
+    VISU::ComponentData aComponentData = anIter.next();
+    QString aComponent = aComponentData.first;
+    QString anUnit = aComponentData.second;
+
+    isModulus = aNbComp > 1 && aComponentId == 0;
+    if( !isModulus )
+    {
+      aComponent = "[" + QString::number( aComponentId ) + "] " + aComponent;
+      if( anUnit.isEmpty() )
+        anUnit = "-";
+      aComponent = aComponent + ", " + anUnit;
+    }
+
+    aComponentList << aComponent;
+    aComponentId++;
+  }
+
+  myComponentCB->clear();
+  myComponentCB->addItems( aComponentList );
+
+  bool isScalarMode = ( aNbComp > 1 );
+  myComponentCB->setCurrentIndex( isScalarMode ? 0 : 1 );
+  myComponentCB->setEnabled( isScalarMode );
+}
+
+//------------------------------------------------------------------------
+void VisuGUI_EvolutionDlg::accept()
+{
+  _PTR(Study) aStudy = VISU::GetCStudy( VISU::GetAppStudy( myModule ) );
+  if( VISU::IsStudyLocked( aStudy ) )
+  {
+    SUIT_MessageBox::warning( VISU::GetDesktop( myModule ),
+                              tr( "WRN_VISU_WARNING" ),
+                              tr( "WRN_STUDY_LOCKED" ) );
+    return;
+  }
+
+  bool ok = false;
+  int aPointId = myPointLE->text().toInt( &ok );
+  if( !ok )
+  {
+    SUIT_MessageBox::warning( VISU::GetDesktop( myModule ),
+                              tr( "WRN_VISU_WARNING" ),
+                              tr( "ERR_INVALID_SELECTION" ) );
+    return;
+  }
+  myEngine->setPointId( aPointId );
+
+  int aComponentId = myComponentCB->currentIndex();
+  myEngine->setComponentId( aComponentId );
+
+  // create or get a Plot2d view
+  SPlot2d_Viewer* aView = VISU::GetPlot2dViewer( myModule, true );
+  if( aView )
+  {
+    Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
+    myEngine->setViewer( aPlot );
+  }
+
+  if( !myEngine->showEvolution() )
+  {
+    SUIT_MessageBox::warning( VISU::GetDesktop( myModule ),
+                              tr( "WRN_VISU_WARNING" ),
+                              tr( "ERR_EXTRACTION_OF_DATA_FAILED" ) );
+    return;
+  }
+
+  std::string anEvolutionEntry = myEngine->getEvolutionEntry();
+  if( anEvolutionEntry != "" )
+  {
+    _PTR(SObject) anEvolutionObject = aStudy->FindObjectID( anEvolutionEntry.c_str() );
+    VISU::UpdateObjBrowser( myModule, true, anEvolutionObject );
+  }
+
+  QtxDialog::accept();
+}
+
+//------------------------------------------------------------------------
+void VisuGUI_EvolutionDlg::setVisible( bool theIsVisible )
+{
+  QtxDialog::setVisible( theIsVisible );
+
+  if( !myViewWindow )
+    return;
+
+  VISU::Result_i* aResult = myEngine->getResult();
+  if( !aResult )
+    return;
+
+  if( theIsVisible && !myPreviewActor )
+  {
+    // get an id of the pre-selected point
+    // it should be done before changing of selection mode because
+    // that operation forces onSelectionEvent() and clears myPointLE
+    bool hasPreSelection = false;
+    int aPointId = myPointLE->text().toInt( &hasPreSelection );
+
+    // store current selection mode and switch to point selection
+    myStoredSelectionMode = myViewWindow->SelectionMode();
+    myViewWindow->SetSelectionMode( NodeSelection );
+
+    // create preview actor and display it in the view
+    VISU::PNamedIDMapper aMapper = aResult->GetInput()->GetMeshOnEntity( myEngine->getMeshName(), myEngine->getEntity() );
+
+    vtkDataSetMapper* aPreviewMapper = vtkDataSetMapper::New();
+    aPreviewMapper->SetInput( aMapper->GetOutput() );
+  
+    vtkProperty* aProperty = vtkProperty::New();
+    aProperty->SetColor( 1, 1, 1 );
+    aProperty->SetPointSize( SALOME_POINT_SIZE );
+    aProperty->SetRepresentationToPoints();
+
+    myPreviewActor = SALOME_Actor::New();
+    myPreviewActor->PickableOn();
+    myPreviewActor->SetMapper( aPreviewMapper );
+    myPreviewActor->SetProperty( aProperty );
+
+    aProperty->Delete();
+    aPreviewMapper->Delete();
+
+    Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject( myEngine->getFieldEntry().c_str(), "", "" );
+    myPreviewActor->setIO( anIO );
+
+    myViewWindow->AddActor(myPreviewActor);
+
+    if( hasPreSelection )
+    {
+      myPointLE->setText( QString::number( aPointId ) );
+
+      SVTK_Selector* aSelector = myViewWindow->GetSelector();
+      aSelector->ClearIObjects();
+      aSelector->AddOrRemoveIndex( anIO, aPointId, false );
+      aSelector->AddIObject( anIO );
+
+      myPreviewActor->Highlight( true );
+    }
+
+    myViewWindow->onFitAll();
+  }
+  else if( !theIsVisible && myPreviewActor )
+  {
+    SVTK_Selector* aSelector = myViewWindow->GetSelector();
+    aSelector->ClearIObjects();
+
+    // restore selection mode
+    myViewWindow->SetSelectionMode( myStoredSelectionMode );
+
+    // remove preview actor from the view and delete it
+    myViewWindow->RemoveActor( myPreviewActor );
+    myPreviewActor->Delete();
+    myPreviewActor = 0;
+  }
+}
+
+//------------------------------------------------------------------------
+void VisuGUI_EvolutionDlg::restoreFromStudy( _PTR(SObject) theEvolution )
+{
+  myEngine->restoreFromStudy( theEvolution );
+
+  updateFromEngine();
+
+  myPointLE->setText( QString::number( myEngine->getPointId() ) );
+  myComponentCB->setCurrentIndex( myEngine->getComponentId() );
+}
+
+//------------------------------------------------------------------------
+void VisuGUI_EvolutionDlg::onSelectionEvent()
+{
+  myPointLE->clear();
+
+  if( !myViewWindow || myViewWindow->SelectionMode() != NodeSelection )
+    return;
+
+  if( !myPreviewActor || !myPreviewActor->hasIO() )
+    return;
+
+  SVTK_Selector* aSelector = myViewWindow->GetSelector();
+  LightApp_SelectionMgr* aSelectionMgr = VISU::GetSelectionMgr( myModule );
+  SALOME_ListIO aListIO;
+  aSelectionMgr->selectedObjects( aListIO );
+  SALOME_ListIteratorOfListIO anIter( aListIO );
+  while( anIter.More() )
+  {
+    Handle(SALOME_InteractiveObject) anIO = anIter.Value();
+    if( !anIO.IsNull() && strcmp( anIO->getEntry(), myPreviewActor->getIO()->getEntry() ) == 0 )
+    {
+      TColStd_IndexedMapOfInteger aMapIndex;
+      aSelector->GetIndex( anIO, aMapIndex );
+      if( aMapIndex.Extent() == 1 )
+      {
+        int anId = aMapIndex( 1 );
+        myPointLE->setText( QString::number( anId ) );
+      }
+      break;
+    }
+    anIter.Next();
+  }
+}
+
+//------------------------------------------------------------------------
+void VisuGUI_EvolutionDlg::onHelp()
+{
+  QString aHelpFileName = "evolution_page.html";
+  LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
+  if( app )
+    app->onHelpContextModule( myModule ? app->moduleName( myModule->moduleName() ) : QString( "" ), aHelpFileName );
+  else
+  {
+    QString platform;
+#ifdef WIN32
+    platform = "winapplication";
+#else
+    platform = "application";
+#endif
+    SUIT_MessageBox::warning( VISU::GetDesktop( myModule ),
+                              tr( "WRN_WARNING" ),
+                              tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
+                              arg( app->resourceMgr()->stringValue( "ExternalBrowser", platform ) ).arg( aHelpFileName ),
+                              tr( "BUT_OK" ) );
+  }
+}
+
+//------------------------------------------------------------------------
+void VisuGUI_EvolutionDlg::keyPressEvent( QKeyEvent* e )
+{
+  QDialog::keyPressEvent( e );
+  if ( e->isAccepted() )
+    return;
+
+  if ( e->key() == Qt::Key_F1 )
+  {
+    e->accept();
+    onHelp();
+  }
+}
diff --git a/src/VISUGUI/VisuGUI_EvolutionDlg.h b/src/VISUGUI/VisuGUI_EvolutionDlg.h
new file mode 100644 (file)
index 0000000..0cc5663
--- /dev/null
@@ -0,0 +1,87 @@
+//  Copyright (C) 2007-2008  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
+//
+//  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.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//  File   : VisuGUI_EvolutionDlg.h
+//  Author : Oleg UVAROV
+//  Module : VISU
+//
+#ifndef VISUGUI_EVOLUTIONDLG_H
+#define VISUGUI_EVOLUTIONDLG_H
+
+#include <QtxDialog.h>
+
+#include <SALOMEDSClient_Study.hxx>
+
+#include <SVTK_Selection.h>
+
+class QComboBox;
+class QKeyEvent;
+class QLineEdit;
+
+class SALOME_Actor;
+class SVTK_ViewWindow;
+
+class VisuGUI;
+class VISU_Evolution;
+
+class VisuGUI_EvolutionDlg: public QtxDialog
+{
+  Q_OBJECT
+
+public:
+  VisuGUI_EvolutionDlg( VisuGUI* theModule,
+                        SVTK_ViewWindow* theViewWindow,
+                        _PTR(Study) theStudy );
+  ~VisuGUI_EvolutionDlg();
+
+public:
+  bool                      setField( _PTR(SObject) theField );
+
+  void                      restoreFromStudy( _PTR(SObject) theEvolution );
+
+protected:
+  virtual void              setVisible( bool theIsVisible );
+  virtual void              keyPressEvent( QKeyEvent* theEvent );
+
+protected slots:
+  virtual void              accept();
+
+private:
+  void                      updateFromEngine();
+
+private slots:
+  void                      onSelectionEvent();
+  void                      onHelp();
+
+private:
+  VisuGUI*                  myModule;
+  VISU_Evolution*           myEngine;
+
+  QLineEdit*                myFieldLE;
+  QLineEdit*                myPointLE;
+  QComboBox*                myComponentCB;
+
+  SVTK_ViewWindow*          myViewWindow;
+  SALOME_Actor*             myPreviewActor;
+  Selection_Mode            myStoredSelectionMode;
+};
+
+#endif //VISUGUI_EVOLUTIONDLG_H
index 828fd36bf3c0dc386c58fe628d76f42208f2964a..4f1dbe03749531f285de12e4cb1e83988617f6be 100644 (file)
@@ -31,6 +31,8 @@
 
 #include "VisuGUI.h"
 
+#include "VISU_Tools.h"
+
 #include "VISU_ColoredPrs3dHolder_i.hh"
 #include "VISU_Gen_i.hh"
 #include "VISU_Prs3d_i.hh"
@@ -966,66 +968,16 @@ namespace VISU
     return NULL;
   }
 
-  //------------------------------------------------------------
-  // Internal function used by several public functions below
-  void
-  UpdateCurve(VISU::Curve_i* theCurve,
-              Plot2d_ViewFrame* aPlot,
-              SPlot2d_Curve* plotCurve,
-              int theDisplaying)
-  {
-    if ( theDisplaying == VISU::eErase ) {
-      if ( plotCurve && aPlot )
-        aPlot->eraseCurve( plotCurve, false );
-    }
-    else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
-      if ( plotCurve ) {
-        plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
-        //plotCurve->setVerTitle( ( theCurve->GetVerTitle().c_str() ) );
-        plotCurve->setVerTitle( theCurve->GetName().c_str() );
-        plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
-        plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
-        double* xList = 0;
-        double* yList = 0;
-       QStringList zList;
-        int     nbPoints = theCurve->GetData( xList, yList, zList );
-        if ( nbPoints > 0 && xList && yList ) {
-          plotCurve->setData( xList, yList, nbPoints, zList );
-        }
-        if ( !theCurve->IsAuto() ) {
-          plotCurve->setLine( (Plot2d::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
-          plotCurve->setMarker( (Plot2d::MarkerType)theCurve->GetMarker() );
-          SALOMEDS::Color color = theCurve->GetColor();
-          plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
-        }
-        plotCurve->setAutoAssign( theCurve->IsAuto() );
-       if( aPlot )
-         aPlot->displayCurve( plotCurve, false );
-      }
-      else {
-        Plot2d_Curve* crv = theCurve->CreatePresentation();
-        if ( crv ) {
-         if( aPlot )
-           aPlot->displayCurve( crv, false );
-          theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
-          theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
-          SALOMEDS::Color newColor;
-          newColor.R = crv->getColor().red()/255.;
-          newColor.G = crv->getColor().green()/255.;
-          newColor.B = crv->getColor().blue()/255.;
-          theCurve->SetColor( newColor );
-          crv->setAutoAssign( theCurve->IsAuto() );
-        }
-      }
-    }
-  }
-
   //------------------------------------------------------------
   void
   PlotTable(const SalomeApp_Module* theModule,
             VISU::Table_i* table,
             int theDisplaying)
   {
+    SalomeApp_Study* aStudy = GetAppStudy( theModule );
+    if( !aStudy )
+      return;
+
     SPlot2d_Viewer* aView = GetPlot2dViewer( theModule, true ); // create if necessary
     if ( !aView )
       return;
@@ -1033,41 +985,8 @@ namespace VISU
     if ( !aPlot )
       return;
 
-    if ( theDisplaying == VISU::eDisplayOnly )
-      aPlot->EraseAll();
-    QList<Plot2d_Curve*> clist;
-    aPlot->getCurves( clist );
-    _PTR(Study) aStudy = GetCStudy( GetAppStudy( theModule ) );
-    _PTR(SObject) TableSO = aStudy->FindObjectID( table->GetEntry() );
-    if ( TableSO ) {
-      _PTR(ChildIterator) Iter = aStudy->NewChildIterator( TableSO );
-      for ( ; Iter->More(); Iter->Next() ) {
-        CORBA::Object_var childObject = VISU::ClientSObjectToObject( Iter->Value() );
-        if( !CORBA::is_nil( childObject ) ) {
-          CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
-          if( !CORBA::is_nil( aCurve ) ) {
-            VISU::Curve_i* theCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
-            SPlot2d_Curve* plotCurve = 0;
-            SPlot2d_Curve* tmpCurve;
-            for ( int i = 0; i < clist.count(); i++ ) {
-              tmpCurve = dynamic_cast<SPlot2d_Curve*>( clist.at( i ) );
-              if (tmpCurve && tmpCurve->hasIO() &&
-                  theCurve->GetEntry() == tmpCurve->getIO()->getEntry()) {
-                plotCurve = tmpCurve;
-                break;
-              }
-            }
-
-            UpdateCurve( theCurve, aPlot, plotCurve, theDisplaying );
-
-            if ( theDisplaying == VISU::eErase && plotCurve ) {
-              clist.removeAll(plotCurve );
-            }
-          }
-        }
-      }
-      aPlot->Repaint();
-    }
+    // implementation moved to VISU_I package (see VISU_Tools.h)
+    VISU::PlotTable( aStudy, aPlot, table, theDisplaying );
   }
 
   //------------------------------------------------------------
@@ -1083,40 +1002,8 @@ namespace VISU
     if ( !aPlot )
       return;
 
-//  if ( theDisplaying == VISU::eDisplayOnly )
-//    aPlot->EraseAll();
-    QList<Plot2d_Curve*> clist;
-    aPlot->getCurves( clist );
-    SPlot2d_Curve* plotCurve = 0;
-    SPlot2d_Curve* tmpCurve;
-    if(theDisplaying == VISU::eErase) {
-      // 23.06.2008 skl for IPAL17672
-      for (int i = 0; i < clist.count(); i++) {
-        tmpCurve = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
-        if (tmpCurve && tmpCurve->hasIO() &&
-            theCurve->GetEntry() == tmpCurve->getIO()->getEntry()) {
-          plotCurve = tmpCurve;
-          aPlot->eraseCurve(clist.at(i));
-          break;
-        }
-      }
-      UpdateCurve(theCurve, aPlot, plotCurve, theDisplaying);
-    }
-    else {
-      for (int i = 0; i < clist.count(); i++) {
-        tmpCurve = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
-        if (tmpCurve && tmpCurve->hasIO() &&
-            theCurve->GetEntry() == tmpCurve->getIO()->getEntry()) {
-          plotCurve = tmpCurve;
-        }
-        else if (theDisplaying == VISU::eDisplayOnly) {
-          aPlot->eraseCurve(clist.at(i));
-        }
-      }
-      UpdateCurve(theCurve, aPlot, plotCurve, theDisplaying);
-    }
-
-    aPlot->Repaint();
+    // implementation moved to VISU_I package (see VISU_Tools.h)
+    VISU::PlotCurve( aPlot, theCurve, theDisplaying );
   }
 
   //------------------------------------------------------------
@@ -1124,28 +1011,8 @@ namespace VISU
   PlotRemoveCurve(const SalomeApp_Module* theModule,
                  VISU::Curve_i* pCrv)
   {
-    QString anEntry = pCrv->GetEntry().c_str();
-    ViewManagerList pvm_list;
-    theModule->getApp()->viewManagers( SPlot2d_Viewer::Type(), pvm_list );
-    ViewManagerList::Iterator pvm_it = pvm_list.begin();
-    for( ; pvm_it != pvm_list.end(); pvm_it++ ){
-      Plot2d_ViewManager* pvm = dynamic_cast<Plot2d_ViewManager*>( *pvm_it );
-      if( pvm ){
-       SPlot2d_Viewer* aSPlot2d = dynamic_cast<SPlot2d_Viewer*>( pvm->getViewModel() );
-       if( aSPlot2d ){
-         Plot2d_ViewFrame* aPlot = aSPlot2d->getActiveViewFrame();
-         if(aPlot){
-           QList<Plot2d_Curve*> clist;
-           aPlot->getCurves( clist );
-           for (int i = 0; i < clist.count(); i++) {
-             if(SPlot2d_Curve* plotCurve = dynamic_cast<SPlot2d_Curve*>(clist[i]))
-               if(plotCurve->hasIO() && (plotCurve->getIO()->getEntry() == anEntry))
-                 aPlot->eraseCurve(clist[i]);
-           }
-         }
-       }
-      }
-    }
+    // implementation moved to VISU_I package (see VISU_Tools.h)
+    VISU::PlotRemoveCurve( theModule->getApp(), pCrv );
   }
   
   //------------------------------------------------------------
@@ -1161,31 +1028,8 @@ namespace VISU
     if ( !aPlot )
       return;
 
-    if ( theDisplaying == VISU::eDisplayOnly )
-      aPlot->EraseAll();
-    QList<Plot2d_Curve*> clist;
-    aPlot->getCurves( clist );
-    if ( container->GetNbCurves() > 0 ) {
-      int nbCurves = container->GetNbCurves();
-      for ( int k = 1; k <= nbCurves; k++ ) {
-        VISU::Curve_i* theCurve = container->GetCurve( k );
-        if ( theCurve && theCurve->IsValid() ) {
-          SPlot2d_Curve* plotCurve = dynamic_cast<SPlot2d_Curve*>
-            (aView->getCurveByIO(new SALOME_InteractiveObject(theCurve->GetEntry().c_str(), "", "")));
-
-          UpdateCurve( theCurve, aPlot, plotCurve, theDisplaying );
-
-          if ( plotCurve && theDisplaying == VISU::eErase ) {
-            clist.removeAll( plotCurve );
-          }
-        }
-      }
-    }
-    aPlot->Repaint();
-    if(GetResourceMgr()->booleanValue("VISU","automatic_fit_all",false)){
-      aPlot->fitAll();
-    }
-    qApp->processEvents();
+    // implementation moved to VISU_I package (see VISU_Tools.h)
+    VISU::PlotContainer( aPlot, container, theDisplaying );
   }
 
   //------------------------------------------------------------
@@ -1193,33 +1037,17 @@ namespace VISU
   CreatePlot(SalomeApp_Module* theModule,
              _PTR(SObject) theTableSO)
   {
-    if ( IsSObjectTable(theTableSO) ) {
-      CORBA::Object_var aTable = VISU::ClientSObjectToObject(theTableSO);
-      CORBA::Object_var aContainer = GetVisuGen( theModule )->CreateContainer();
-      if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
-        VISU::Table_i*     pTable     = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
-        VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
-
-        if ( pContainer && pTable ) {
-          for ( int i = 2; i <= pTable->GetNbRows(); i++ ) {
-            CORBA::Object_var aNewCurve = GetVisuGen( theModule )->CreateCurve( pTable->_this(), 1, i );
-            if( !CORBA::is_nil( aNewCurve ) ) {
-              VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aNewCurve).in() );
-              if ( pCrv ) {
-                pContainer->AddCurve( pCrv->_this() );
-              }
-            }
-          }
-          PlotContainer( theModule, pContainer, VISU::eDisplay );
+    SPlot2d_Viewer* aView = GetPlot2dViewer( theModule, true );
+    if ( !aView )
+      return;
+    Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
+    if ( !aPlot )
+      return;
 
-         QString anEntry = pContainer->GetEntry().c_str();
-         _PTR(Study) aStudy = theTableSO->GetStudy();
-         _PTR(SObject) aContainerSO = aStudy->FindObjectID(anEntry.toLatin1().data());
-         _PTR(SObject) aParentSO = aContainerSO->GetFather();
-         UpdateObjBrowser(theModule,true,aParentSO);
-        }
-      }
-    }
+    VISU::VISU_Gen_i* aVisuGen = VISU::GetVisuGen( theModule );
+
+    // implementation moved to VISU_I package (see VISU_Tools.h)
+    VISU::CreatePlot( aVisuGen, aPlot, theTableSO );
   }
 
   //************************************************************
index 8a41bf8c103e9502af744289bd7e37e13ecea2ec..6e0cb98ec11040cb365ac83a9523a0ac3f4fd0dd 100644 (file)
@@ -219,14 +219,6 @@ namespace VISU
   void                                 CreatePlot( SalomeApp_Module* theModule,
                                                   _PTR(SObject) theSobj );
 
-  /*! Display/Erase/Update a curve presentation.
-   *  Parameter \a frame may be NULL, in this case there is only update without display/erase
-   */
-  void                                 UpdateCurve( VISU::Curve_i*,
-                                                   Plot2d_ViewFrame* frame,
-                                                   SPlot2d_Curve*,
-                                                   int theDisplaying );
-
   /*! Create mesh presentation and display it in \a theViewWindow.
    *  If \a theViewWindow is NULL, no displaying will be done.
    */
index 2f3bb8116085fb3b1e29554c0188ce63afb8d893..6d339fbb1b993e47638f7663e4be609a319efaa0 100644 (file)
@@ -32,6 +32,7 @@ salomeinclude_HEADERS = \
        VISU_I.hxx \
        VISUConfig.hh \
        VISU_Gen_i.hh \
+       VISU_Tools.h \
        VISU_Result_i.hh \
        VISU_MultiResult_i.hh \
        VISU_PrsObject_i.hh \
@@ -57,6 +58,7 @@ salomeinclude_HEADERS = \
        VISU_ViewManager_i.hh \
        VISU_View_i.hh \
        VISU_TimeAnimation.h \
+       VISU_Evolution.h \
        VISU_DeformedShapeAndScalarMap_i.hh \
        VISU_ColoredPrs3dCache_i.hh \
        VISU_ColoredPrs3dHolder_i.hh \
@@ -70,6 +72,7 @@ salomeinclude_HEADERS = \
 
 libVISUEngineImpl_la_SOURCES = \
        VISUConfig.cc \
+       VISU_Tools.cxx \
        VISU_Result_i.cc \
        VISU_ResultUtils.cc \
        VISU_MultiResult_i.cc \
@@ -97,6 +100,7 @@ libVISUEngineImpl_la_SOURCES = \
        VISU_Mesh_i.cc \
        VISU_ViewManager_i.cc \
        VISU_TimeAnimation.cxx \
+       VISU_Evolution.cxx \
        VISU_View_i.cc \
        VISU_Table_i.cc \
        VISU_PointMap3d_i.cc \
index 84739c3836fe2941b5366d642401ec7943d23bff..8407799acdfad214e9e1b8d7874fd586871a301c 100644 (file)
@@ -257,6 +257,8 @@ namespace VISU
       return VISU::TTIMESTAMP;
     if ( theComment == "ANIMATION" ) 
       return VISU::TANIMATION;
+    if ( theComment == "EVOLUTION" ) 
+      return VISU::TEVOLUTION;
     if ( theComment == "ALL" ) 
       return VISU::TALL;
     
index 9df871e64d29e635d9d5db825c9082afc441ea08..cc010783b11bb6552e69dad44bce6ba9dbe94bc4 100644 (file)
@@ -892,7 +892,7 @@ namespace VISU
     }
 
     std::string aSObjectName = GetName(theSObject);
-    theStr<<thePrefix<<aSObjectName<<" = aBuilder.NewObject(aSComponent)"<<endl;
+    theStr<<thePrefix<<aSObjectName<<" = aBuilder.NewObject("<<theArgumentName<<")"<<endl;
     theStr<<thePrefix<<"if "<<aSObjectName<<":"<<endl;
     thePrefix += PREFIX;
 
@@ -1994,6 +1994,94 @@ namespace VISU
   }
 
     
+  //---------------------------------------------------------------------------
+  void
+  DumpEvolutionsToPython(SALOMEDS::Study_ptr theStudy,
+                         CORBA::Boolean theIsPublished,
+                         CORBA::Boolean& theIsValidScript,
+                         SALOMEDS::SObject_ptr theSObject,
+                         std::ostream& theStr,
+                         TName2EntryMap& theName2EntryMap,
+                         TEntry2NameMap& theEntry2NameMap,
+                         std::string thePrefix)
+  {
+    if(!theIsPublished) return;
+
+    SALOMEDS::ChildIterator_var aChildItet = theStudy->NewChildIterator(theSObject);
+    for(aChildItet->InitEx(false); aChildItet->More(); aChildItet->Next()){
+      SALOMEDS::SObject_var aSObject = aChildItet->Value();
+          
+      SALOMEDS::GenericAttribute_var anAttr;
+      if (!aSObject->FindAttribute(anAttr, "AttributeString")) continue;
+      
+      SALOMEDS::AttributeString_var aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
+      QString value (aStringAttr->Value());
+      if(value.isEmpty()) continue;
+
+      VISU::Storable::TRestoringMap aMap;
+      VISU::Storable::StringToMap(value, aMap);
+      bool isExist;
+      
+      QString aTypeName = VISU::Storable::FindValue(aMap,"myComment",&isExist);
+      if(!isExist || aTypeName != "EVOLUTION") continue;
+
+      //EVOLUTION
+      theStr<<thePrefix<<endl;
+      QString evolutionName = aSObject->GetName();
+      theStr<<thePrefix<<"#Evolution: "<<evolutionName.toLatin1().data()<<endl;
+      theStr<<thePrefix<<endl;
+      theStr<<thePrefix<<"evolutionSO = aBuilder.NewObject(aSComponent)"<<endl;
+      theStr<<thePrefix<<"aBuilder.SetName(evolutionSO, '"<<evolutionName.toLatin1().data()<<"')"<< endl;
+      theStr<<thePrefix<<"strAttr = aBuilder.FindOrCreateAttribute(evolutionSO, 'AttributeString')"<< endl;
+      theStr<<thePrefix<<"strAttr.SetValue('"<<value.toLatin1().data()<<"')"<< endl;
+
+      SALOMEDS::ChildIterator_var anIter = theStudy->NewChildIterator(aSObject);
+      for (anIter->Init(); anIter->More(); anIter->Next()) {
+        SALOMEDS::SObject_var anObj = anIter->Value();
+
+        //FIELD
+        theStr<<thePrefix<<"fieldSO = aBuilder.NewObject(evolutionSO)"<<endl;
+        if (anObj->FindAttribute(anAttr, "AttributeString")) {
+          aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
+          theStr<<thePrefix<<"strAttr = aBuilder.FindOrCreateAttribute(fieldSO, 'AttributeString')"<< endl;
+          theStr<<thePrefix<<"strAttr.SetValue('"<<aStringAttr->Value()<<"')"<< endl;
+        }
+       
+        SALOMEDS::SObject_var refObj;
+        if(anObj->ReferencedObject(refObj)) {
+          SALOMEDS::SObject_var father = refObj->GetFather();
+          value = refObj->GetName();
+          QString path(theStudy->GetObjectPath(father));
+          //The following code requierd as a field name can contain '/' character
+          theStr<<thePrefix<<"aBuilder.Addreference(fieldSO,getSObjectByFatherPathAndName(theStudy, '"<<path.toLatin1().data()<<"', '"<<value.toLatin1().data()<<"'))"<<endl;
+        }
+        value = anObj->GetName();
+        if(!value.isEmpty()) theStr<<thePrefix<<"aBuilder.SetName(fieldSO, '"<<value.toLatin1().data()<<"')"<< endl;
+
+        //TABLE
+        SALOMEDS::ChildIterator_var aChildItet = theStudy->NewChildIterator(anObj);
+        for(aChildItet->InitEx(false); aChildItet->More(); aChildItet->Next()){
+          SALOMEDS::SObject_var aSObject = aChildItet->Value();
+
+          std::string anArgumentName = "fieldSO";
+          DumpTableAttrToPython(theStudy,
+                                theIsPublished,
+                                theIsValidScript,
+                                aSObject,
+                                theStr,
+                                theName2EntryMap,
+                                theEntry2NameMap,
+                                anArgumentName,
+                                thePrefix);
+        }
+      }
+      
+    }
+
+    theStr<<thePrefix<<endl;
+  }
+
+
   //---------------------------------------------------------------------------
   void
   DumpAnimationsToPython(SALOMEDS::Study_ptr theStudy,
@@ -2171,6 +2259,15 @@ namespace VISU
                               "",
                               aPrefix);
 
+    VISU::DumpEvolutionsToPython(aStudy,
+                                theIsPublished,
+                                theIsValidScript,
+                                aComponent.in(),
+                                aStr,
+                                aName2EntryMap,
+                                aEntry2NameMap,
+                                aPrefix);
+
     VISU::DumpContainersToPython(aStudy,
                                 theIsPublished,
                                 theIsValidScript,
diff --git a/src/VISU_I/VISU_Evolution.cxx b/src/VISU_I/VISU_Evolution.cxx
new file mode 100644 (file)
index 0000000..c930142
--- /dev/null
@@ -0,0 +1,617 @@
+//  Copyright (C) 2007-2008  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
+//
+//  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.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//  File   : VISU_Evolution.cxx
+//  Author : Oleg UVAROV
+//  Module : VISU
+//
+#include "VISU_Evolution.h"
+
+#include "VISU_Tools.h"
+#include "VISU_Gen_i.hh"
+#include "VISU_Result_i.hh"
+#include "VISU_Table_i.hh"
+#include "VISU_View_i.hh"
+
+#include <VISU_MeshValue.hxx>
+#include <VISU_Structures_impl.hxx>
+#include <VISU_VTKTypeList.hxx>
+
+#include <SUIT_Session.h>
+
+#include <SalomeApp_Application.h>
+#include <SalomeApp_Study.h>
+
+#include <SALOME_Event.h>
+
+//------------------------------------------------------------------------
+template<int EDataType> bool ProcessValForTime( VISU::PValForTimeImpl aValForTime,
+                                                VISU::Elem2Comp2Value& theElem2Comp2Value )
+{
+  theElem2Comp2Value.clear();
+
+  typedef typename VISU::TL::TEnum2VTKBasicType< EDataType >::TResult TVTKBasicType;
+  typedef VISU::TTMeshValue< TVTKBasicType > TMeshValue;
+  typedef MED::SharedPtr< TMeshValue > TMeshValuePtr;
+
+  const TMeshValuePtr aMeshValue = aValForTime->GetMeshValue( VISU::ePOINT1 );
+  if( !aMeshValue )
+    return false;
+
+  vtkIdType aNbElem = aMeshValue->GetNbElem();
+  vtkIdType aNbComp = aMeshValue->GetNbComp();
+  vtkIdType aNbGauss = aMeshValue->GetNbGauss();
+
+  for( vtkIdType iElem = 0; iElem < aNbElem; iElem++ )
+  {
+    typename TMeshValue::TCValueSliceArr aMValueSliceArr = aMeshValue->GetCompValueSliceArr( iElem );
+    VISU::Comp2Value& aComp2Value = theElem2Comp2Value[ iElem ];
+
+    vtkFloatingPointType& aModulusValue = aComp2Value[ 0 ];
+    aModulusValue = 0.0;
+
+    for( vtkIdType iComp = 0; iComp < aNbComp; iComp++ )
+    {
+      const typename TMeshValue::TCValueSlice& aMValueSlice = aMValueSliceArr[ iComp ];
+
+      vtkFloatingPointType& aValue = aComp2Value[ iComp+1 ];
+      aValue = 0.0;
+
+      for(vtkIdType iGauss = 0; iGauss < aNbGauss; iGauss++)
+      {
+        const vtkFloatingPointType& aVal = aMValueSlice[iGauss];
+        aValue += aVal;
+      }
+      if( aNbGauss != 0 )
+        aValue /= aNbGauss;
+
+      aModulusValue += aValue * aValue;
+    }
+    aModulusValue = sqrt( aModulusValue );
+  }
+
+  return true;
+}
+
+//------------------------------------------------------------------------
+VISU_Evolution::VISU_Evolution( _PTR(Study) theStudy,
+                                VISU::XYPlot_ptr theXYPlot )
+{
+  myStudy = theStudy;
+  myView = 0;
+
+  if( !CORBA::is_nil( theXYPlot ) )
+  {
+    VISU::XYPlot_i* pPlot = dynamic_cast<VISU::XYPlot_i*>( GetServant( theXYPlot ).in() );
+    Plot2d_ViewFrame* aVF = pPlot->GetView();
+    setViewer( aVF );
+  }
+
+  myFieldEntry = "";
+  myEvolutionEntry = "";
+  myMeshName = "";
+  myEntity = VISU::NODE_ENTITY;
+  myFieldName = "";
+
+  myPointId = 0;
+  myComponentId = 0;
+}
+
+//------------------------------------------------------------------------
+VISU_Evolution::~VISU_Evolution()
+{
+}
+
+//------------------------------------------------------------------------
+bool VISU_Evolution::setField( _PTR(SObject) theField )
+{
+  myField = theField;
+  if( !theField )
+    return false;
+
+  myFieldEntry = theField->GetID();
+
+  VISU::Storable::TRestoringMap aRestoringMap = VISU::Storable::GetStorableMap( theField );
+  if( aRestoringMap.empty() )
+    return false;
+
+  VISU::VISUType aType = VISU::Storable::RestoringMap2Type( aRestoringMap );
+  if( aType != VISU::TFIELD )
+    return false;
+
+  myMeshName = aRestoringMap["myMeshName"].toStdString();
+  myEntity = VISU::TEntity( aRestoringMap["myEntityId"].toInt() );
+  myFieldName = aRestoringMap["myName"].toStdString();
+
+  if( myEntity != VISU::NODE_ENTITY )
+    return false;
+
+  VISU::Result_var aResult = VISU::FindResult( VISU::GetSObject( theField ).in() );
+  if( CORBA::is_nil( aResult.in() ) )
+    return false;
+
+  myResult = dynamic_cast<VISU::Result_i*>( VISU::GetServant( aResult ).in() );
+  if( !myResult )
+    return false;
+
+  const VISU::TMeshMap& aMeshMap = myResult->GetInput()->GetMeshMap();
+  if( aMeshMap.empty() )
+    return false;
+
+  VISU::TMeshMap::const_iterator aMeshIter = aMeshMap.find( myMeshName );
+  if( aMeshIter == aMeshMap.end() )
+    return false;
+  
+  const VISU::PMesh& aMesh = aMeshIter->second;
+  const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+  if( aMeshOnEntityMap.empty() )
+    return false;
+
+  VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityIter = aMeshOnEntityMap.find( myEntity );
+  if( aMeshOnEntityIter == aMeshOnEntityMap.end() )
+    return false;
+
+  const VISU::PMeshOnEntity& aMeshOnEntity = aMeshOnEntityIter->second;
+  const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
+  if( aFieldMap.empty() )
+    return false;
+
+  VISU::TFieldMap::const_iterator aFieldIter = aFieldMap.find( myFieldName );
+  if( aFieldIter == aFieldMap.end() )
+    return false;
+
+  myFieldImpl = aFieldIter->second;
+  const VISU::TNames& aCompNames = myFieldImpl->myCompNames;
+  const VISU::TNames& aUnitNames = myFieldImpl->myUnitNames;
+  int aNbComp = myFieldImpl->myNbComp;
+
+  // fill myComponentDataList
+  myComponentDataList.clear();
+
+  QString aModulusComponent( "<Modulus>" );
+  myComponentDataList.append( VISU::ComponentData( aModulusComponent, "" ) );
+  for( int i = 0; i < aNbComp; i++ )
+  {
+    QString aComponent = QString( aCompNames[i].c_str() ).simplified();
+    if( aComponent.isEmpty() )
+      aComponent = "Component " + QString::number( i+1 );
+
+    QString anUnit = QString( aUnitNames[i].c_str() ).simplified();
+
+    myComponentDataList.append( VISU::ComponentData( aComponent, anUnit ) );
+  }
+
+  return true;
+}
+
+//------------------------------------------------------------------------
+bool VISU_Evolution::setField( SALOMEDS::SObject_ptr theField )
+{
+  SALOMEDS::SObject_var theFieldDup = SALOMEDS::SObject::_duplicate( theField );
+  _PTR(SObject) aField = VISU::GetClientSObject( theFieldDup, myStudy );
+  return setField( aField );
+}
+
+//------------------------------------------------------------------------
+void VISU_Evolution::setPointId( int thePointId )
+{
+  myPointId = thePointId;
+}
+
+//------------------------------------------------------------------------
+void VISU_Evolution::setComponentId( int theComponentId )
+{
+  myComponentId = theComponentId;
+}
+
+//------------------------------------------------------------------------
+bool VISU_Evolution::extractData( int thePointId,
+                                  int theComponentId,
+                                  VISU::TimeStampValueList& theTimeStampValueList )
+{
+  theTimeStampValueList.clear();
+  myTimeStampDataList.clear();
+
+  if( !myFieldImpl )
+    return false;
+
+  vtkIdType aDataType = myFieldImpl->GetDataType();
+  const VISU::TValField& aValField = myFieldImpl->myValField;
+  if( aValField.empty() )
+    return false;
+
+  typedef QList< VISU::Elem2Comp2Value >         TimeStamp2Elem2Comp2Value;
+  typedef QListIterator< VISU::Elem2Comp2Value > TimeStamp2Elem2Comp2ValueIterator;
+  TimeStamp2Elem2Comp2Value aData;
+
+  VISU::TValField::const_iterator aValFieldIter = aValField.begin();
+  for( ; aValFieldIter != aValField.end(); aValFieldIter++ )
+  {
+    const vtkIdType& aTimeStamp = aValFieldIter->first;
+    VISU::PValForTimeImpl aValForTime = aValFieldIter->second;
+    VISU::TTime aTime = aValForTime->myTime;
+    double aTimeValue = aTime.first;
+    std::string aTimeUnits = aTime.second;
+
+    // to force method VISU::MedConvertor::FillValForTime() to be called
+    // (we need data of all timestamps of the result)
+    myResult->GetInput()->GetTimeStampOnMesh( myMeshName, myEntity, myFieldName, aTimeStamp );
+
+    // data should be sorted by time value
+    int anOrder = 0;
+    VISU::TimeStampDataListIterator anIter( myTimeStampDataList );
+    while( anIter.hasNext() )
+    {
+      VISU::TimeStampData aTimeStampData = anIter.next();
+      if( aTimeValue > aTimeStampData.first )
+        anOrder++;
+    }
+
+    VISU::Elem2Comp2Value anElem2Comp2Value;
+
+    bool ok = false;
+    switch( aDataType )
+    {
+      case VTK_DOUBLE : ok = ProcessValForTime<VTK_DOUBLE>( aValForTime, anElem2Comp2Value ); break;
+      case VTK_FLOAT : ok = ProcessValForTime<VTK_FLOAT>( aValForTime, anElem2Comp2Value ); break;
+      case VTK_INT : ok = ProcessValForTime<VTK_INT>( aValForTime, anElem2Comp2Value ); break;
+      case VTK_LONG: ok = ProcessValForTime<VTK_LONG>( aValForTime, anElem2Comp2Value ); break;
+      default: break;
+    }
+
+    if( !ok )
+      return false;
+
+    aData.insert( anOrder, anElem2Comp2Value );
+    myTimeStampDataList.insert( anOrder, VISU::TimeStampData( aTimeValue, aTimeUnits ) );
+  }
+
+  if( theComponentId < 0 || theComponentId >= myComponentDataList.size() )
+    return false;
+
+  int aTimeStamp = 0;
+  TimeStamp2Elem2Comp2ValueIterator it1( aData );
+  while( it1.hasNext() )
+  {
+    VISU::Elem2Comp2Value anElem2Comp2Value = it1.next();
+    VISU::Elem2Comp2Value::const_iterator it2 = anElem2Comp2Value.find( thePointId );
+    if( it2 != anElem2Comp2Value.end() )
+    {
+      VISU::Comp2Value aComp2Value = it2.value();
+      VISU::Comp2Value::const_iterator it3 = aComp2Value.find( theComponentId );
+      if( it3 != aComp2Value.end() )
+      {
+        vtkFloatingPointType aValue = it3.value();
+        theTimeStampValueList.append( aValue );
+      }
+    }
+    aTimeStamp++;
+  }
+
+  if( theTimeStampValueList.size() != myTimeStampDataList.size() )
+    return false;
+
+  return true;
+}
+
+//------------------------------------------------------------------------
+bool VISU_Evolution::showEvolution()
+{
+  return ProcessEvent(new TMemFunEvent<VISU_Evolution,bool>
+                      (this,&VISU_Evolution::_showEvolution));
+}
+
+//------------------------------------------------------------------------
+bool VISU_Evolution::_showEvolution()
+{
+  bool isEdit = ( myEvolutionEntry != "" );
+
+  // 1) extract data
+  VISU::TimeStampValueList aTimeStampValueList;
+  if( !extractData( myPointId, myComponentId, aTimeStampValueList ) )
+    return false;
+
+  // 2) publish new objects in study (or edit them)
+  _PTR(StudyBuilder) aStudyBuilder = myStudy->NewBuilder();
+  aStudyBuilder->NewCommand(); // open transaction
+
+  QString anEvolutionComment;
+  anEvolutionComment.sprintf( "myComment=EVOLUTION;myPointId=%d;myComponentId=%d",
+                              myPointId,
+                              myComponentId );
+
+  _PTR(SObject) anEvolutionObject, aFieldRefObject, aTableObject;
+  if( !isEdit ) // creation mode
+  {
+    _PTR(SComponent) aSComponent = VISU::ClientFindOrCreateVisuComponent( myStudy );
+    std::string aSComponentEntry = aSComponent->GetID();
+
+    // create an evolution object
+    myEvolutionEntry = VISU::CreateAttributes( myStudy,
+                                               aSComponentEntry.c_str(),
+                                               VISU::NO_ICON,
+                                               VISU::NO_IOR,
+                                               VISU::GenerateName( "Evolution", 0 ).toLatin1().constData(),
+                                               VISU::NO_PERFSITENT_REF,
+                                               anEvolutionComment.toLatin1().constData(),
+                                               true );
+    anEvolutionObject = myStudy->FindObjectID( myEvolutionEntry.c_str() );
+
+    // create a reference to the field object
+    aFieldRefObject = aStudyBuilder->NewObject( anEvolutionObject );
+    aStudyBuilder->Addreference( aFieldRefObject, myField );
+
+    // create a table object
+    std::string aTableEntry = VISU::CreateAttributes( myStudy,
+                                                      aFieldRefObject->GetID().c_str(),
+                                                      VISU::NO_ICON,
+                                                      VISU::NO_IOR,
+                                                      VISU::GenerateName( "Table", 0 ).toLatin1().constData(),
+                                                      VISU::NO_PERFSITENT_REF,
+                                                      "myComment=TABLE",
+                                                      true );
+    aTableObject = myStudy->FindObjectID( aTableEntry.c_str() );
+  }
+  else // edition mode
+  {
+    // edit an evolution object
+    anEvolutionObject = myStudy->FindObjectID( myEvolutionEntry.c_str() );
+    _PTR(GenericAttribute) anAttr;
+    anAttr = aStudyBuilder->FindOrCreateAttribute( anEvolutionObject, "AttributeString" );
+    _PTR(AttributeString) aComment( anAttr );
+    aComment->SetValue( anEvolutionComment.toLatin1().constData() );
+
+    // get a reference to the field object
+    _PTR(ChildIterator) anIter = myStudy->NewChildIterator( anEvolutionObject );
+    anIter->Init();
+    if( anIter->More() )
+      aFieldRefObject = anIter->Value();
+
+    // get a table object
+    anIter = myStudy->NewChildIterator( aFieldRefObject );
+    anIter->Init();
+    if( anIter->More() )
+      aTableObject = anIter->Value();
+  }
+
+  aStudyBuilder->CommitCommand(); // commit transaction
+
+  // 3) update table attribute of the table object
+  _PTR(GenericAttribute) anAttr = aStudyBuilder->FindOrCreateAttribute( aTableObject, "AttributeTableOfReal" );
+  _PTR(AttributeTableOfReal) aTableOfReal( anAttr );
+
+  aTableOfReal->SetNbColumns( aTimeStampValueList.size() );
+
+  QString aTimeRowUnits;
+  int aTimeStamp = 0;
+  VISU::TimeStampValueListIterator it( aTimeStampValueList );
+  while( it.hasNext() )
+  {
+    vtkFloatingPointType aValue = it.next();
+
+    VISU::TimeStampData aTimeStampData = myTimeStampDataList[ aTimeStamp ];
+    double aTimeValue = aTimeStampData.first;
+    std::string aTimeUnits = aTimeStampData.second;
+
+    if( aTimeRowUnits.isEmpty() )
+      aTimeRowUnits = QString( aTimeUnits.c_str() ).simplified();
+
+    aTableOfReal->SetColumnTitle( aTimeStamp+1, QString::number( aTimeStamp+1 ).toLatin1().constData() );
+    aTableOfReal->PutValue( aTimeValue, 1, aTimeStamp+1 );
+    aTableOfReal->PutValue( aValue, 2, aTimeStamp+1 );
+
+    aTimeStamp++;
+  }
+
+  if( aTimeRowUnits.isEmpty() )
+    aTimeRowUnits = "s";
+
+  aTableOfReal->SetRowTitle( 1, "Time" );
+  aTableOfReal->SetRowUnit( 1, aTimeRowUnits.toLatin1().constData() );
+
+  const VISU::ComponentData& aComponentData = myComponentDataList[ myComponentId ];
+  QString aValueTitle = QString( "Point %1" ).arg( myPointId );
+  aTableOfReal->SetRowTitle( 2, aValueTitle.toLatin1().constData() );
+  aTableOfReal->SetRowUnit( 2, aComponentData.second.toLatin1().constData() );
+
+  QString aTitle = QString( "%1, %2" ).arg( myFieldName.c_str() ).arg( aComponentData.first );
+  aTableOfReal->SetTitle( aTitle.toLatin1().constData() );
+
+  // 4) get active study
+  SalomeApp_Study* aSalomeStudy = NULL;
+  SUIT_Session* aSession = SUIT_Session::session();
+  QList<SUIT_Application*> anApplications = aSession->applications();
+  QList<SUIT_Application*>::Iterator anIter = anApplications.begin();
+  while ( anIter !=  anApplications.end() ) {
+    SUIT_Application* anApp = *anIter;
+    if (SUIT_Study* aSStudy = anApp->activeStudy()) {
+      if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
+        if (_PTR(Study) aCStudy = aStudy->studyDS()) {
+          if (aCStudy->Name() == myStudy->Name()) {
+            aSalomeStudy = aStudy;
+            break;
+          }
+        }
+      }
+      anIter++;
+    }
+  }
+
+  // 5) create curves and plot
+  if( aSalomeStudy )
+  {
+    // 5.1) remove old curves (edition mode)
+    if( isEdit ) {
+      _PTR(GenericAttribute) anAttr;
+      if(aTableObject->FindAttribute( anAttr, "AttributeName" ) ) {
+        _PTR(ChildIterator) aChildIter = myStudy->NewChildIterator( aTableObject );
+        for( aChildIter->InitEx( false ); aChildIter->More(); aChildIter->Next() ) {
+          aSalomeStudy->deleteReferencesTo( aChildIter->Value() );
+          _PTR(SObject) aCurveObject = aChildIter->Value();
+          if(aCurveObject) {
+            VISU::Storable::TRestoringMap aRestoringMap = VISU::Storable::GetStorableMap(aCurveObject);
+            if (aRestoringMap["myComment"] == "CURVE") {
+              CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aCurveObject);
+              if(!CORBA::is_nil(aCORBAObject)) {
+                PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
+                if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aServant.in())){
+                  if(SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aSalomeStudy->application()))
+                    VISU::PlotRemoveCurve(anApp, aCurve);
+                }
+              }
+            }
+            aStudyBuilder->RemoveObject( aCurveObject );
+          }
+        }
+      }
+    }
+
+    // 5.2) create new curves
+    VISU::VISU_Gen_i* aVisuGen = VISU::VISU_Gen_i::GetVisuGenImpl();
+    aVisuGen->CreateTable( aTableObject->GetID().c_str() );
+
+    // 5.3) create plot
+    VISU::CreatePlot( aVisuGen, getViewer(), aTableObject );
+  }
+
+  return true;
+}
+
+//------------------------------------------------------------------------
+void VISU_Evolution::restoreFromStudy( SALOMEDS::SObject_ptr theObj )
+{
+  _PTR(SObject) anEvolutionObject = VISU::GetClientSObject( theObj, myStudy );
+  restoreFromStudy( anEvolutionObject );
+}
+
+//------------------------------------------------------------------------
+void VISU_Evolution::restoreFromStudy( _PTR(SObject) theObj )
+{
+  VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap( theObj );
+  if( aMap.empty() )
+    return;
+
+  bool isExist;
+  myPointId     = VISU::Storable::FindValue( aMap, "myPointId",     &isExist ).toInt();
+  myComponentId = VISU::Storable::FindValue( aMap, "myComponentId", &isExist ).toInt();
+
+  _PTR(ChildIterator) anIter = myStudy->NewChildIterator( theObj );
+  for( anIter->Init(); anIter->More(); anIter->Next() )
+  {
+    _PTR(SObject) aRefObj = anIter->Value();
+    _PTR(SObject) aFieldObj;
+
+    if( !aRefObj->ReferencedObject( aFieldObj ) ) 
+      continue;
+
+    int nbAttr = aFieldObj->GetAllAttributes().size();
+    if( nbAttr < 1 )
+      continue;
+
+    setField( aFieldObj );
+    break;
+  }
+
+  myEvolutionEntry = theObj->GetID();
+}
+
+//------------------------------------------------------------------------
+struct TNewEvolutionEvent: public SALOME_Event
+{
+  std::string myStudyName;
+  VISU::XYPlot_ptr myXYPlot;
+
+  typedef VISU_Evolution* TResult;
+  TResult myResult;
+
+  TNewEvolutionEvent (std::string theStudyName, VISU::XYPlot_ptr theXYPlot):
+    myStudyName(theStudyName),
+    myXYPlot(VISU::XYPlot::_duplicate(theXYPlot)),
+    myResult(NULL)
+  {}
+
+  virtual
+  void
+  Execute()
+  {
+    SUIT_Session* aSession = SUIT_Session::session();
+    QList<SUIT_Application*> anApplications = aSession->applications();
+    QList<SUIT_Application*>::Iterator anIter = anApplications.begin();
+    while ( anIter !=  anApplications.end() ) {
+      SUIT_Application* anApp = *anIter;
+      if (SUIT_Study* aSStudy = anApp->activeStudy()) {
+        if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
+          if (_PTR(Study) aCStudy = aStudy->studyDS()) {
+            if (myStudyName == aCStudy->Name()) {
+              myResult = new VISU_Evolution (aCStudy, myXYPlot);
+              break;
+            }
+          }
+        }
+      }
+      anIter++;
+    }
+  }
+};
+
+//------------------------------------------------------------------------
+VISU_Evolution_i::VISU_Evolution_i( SALOMEDS::Study_ptr theStudy,
+                                    VISU::XYPlot_ptr theXYPlot )
+{
+  std::string aStudyName = theStudy->Name();
+  myEngine = ProcessEvent( new TNewEvolutionEvent( aStudyName, theXYPlot ) );
+}
+
+//------------------------------------------------------------------------
+VISU_Evolution_i::~VISU_Evolution_i()
+{
+  delete myEngine;
+}
+
+//------------------------------------------------------------------------
+bool VISU_Evolution_i::setField( SALOMEDS::SObject_ptr theField )
+{
+  return myEngine->setField( theField );
+}
+
+//------------------------------------------------------------------------
+void VISU_Evolution_i::setPointId( CORBA::Long thePointId )
+{
+  myEngine->setPointId( thePointId );
+}
+
+//------------------------------------------------------------------------
+void VISU_Evolution_i::setComponentId( CORBA::Long theComponentId )
+{
+  myEngine->setComponentId( theComponentId );
+}
+
+//------------------------------------------------------------------------
+CORBA::Boolean VISU_Evolution_i::showEvolution()
+{
+  return myEngine->showEvolution();
+}
+
+//------------------------------------------------------------------------
+void VISU_Evolution_i::restoreFromStudy( SALOMEDS::SObject_ptr theObj )
+{
+  myEngine->restoreFromStudy( theObj );
+}
diff --git a/src/VISU_I/VISU_Evolution.h b/src/VISU_I/VISU_Evolution.h
new file mode 100644 (file)
index 0000000..2730134
--- /dev/null
@@ -0,0 +1,162 @@
+//  Copyright (C) 2007-2008  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
+//
+//  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.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//  File   : VISU_Evolution.h
+//  Author : Oleg UVAROV
+//  Module : VISU
+//
+#ifndef VISU_EVOLUTION_H
+#define VISU_EVOLUTION_H
+
+#include "VISUConfig.hh"
+
+#include <VISU_ConvertorDef_impl.hxx>
+#include <SALOMEDSClient_Study.hxx>
+
+#include <QList>
+#include <QMap>
+#include <QPair>
+
+#include <vtkType.h>
+
+#include <string>
+
+class Plot2d_ViewFrame;
+
+namespace VISU
+{
+  class Result_i;
+};
+
+namespace VISU
+{
+  typedef QMap< vtkIdType, vtkFloatingPointType >         Comp2Value;
+  typedef QMapIterator< vtkIdType, vtkFloatingPointType > Comp2ValueIterator;
+
+  typedef QMap< vtkIdType, Comp2Value >                   Elem2Comp2Value;
+  typedef QMapIterator< vtkIdType, Comp2Value >           Elem2Comp2ValueIterator;
+
+  typedef QPair< double, std::string >                    TimeStampData;
+  typedef QList< TimeStampData >                          TimeStampDataList;
+  typedef QListIterator< TimeStampData >                  TimeStampDataListIterator;
+
+  typedef QPair< QString, QString >                       ComponentData;
+  typedef QList< ComponentData >                          ComponentDataList;
+  typedef QListIterator< ComponentData >                  ComponentDataListIterator;
+
+  typedef QList< vtkFloatingPointType >                   TimeStampValueList;
+  typedef QListIterator< vtkFloatingPointType >           TimeStampValueListIterator;
+};
+
+class VISU_I_EXPORT VISU_Evolution
+{
+protected:
+  bool _showEvolution();
+
+public:
+  VISU_Evolution( _PTR(Study) theStudy,
+                  VISU::XYPlot_ptr theXYPlot = VISU::XYPlot::_nil() );
+  ~VISU_Evolution();
+
+  virtual VISU::VISUType    GetType() { return VISU::TNONE; }
+
+  _PTR(Study)               getStudy() const { return myStudy; }
+
+  bool                      setField( _PTR(SObject) theField );
+  bool                      setField( SALOMEDS::SObject_ptr theField );
+
+  void                      setPointId( int thePointId );
+  int                       getPointId() const { return myPointId; }
+
+  void                      setComponentId( int theComponentId );
+  int                       getComponentId() const { return myComponentId; }
+
+  bool                      showEvolution();
+
+  void                      setViewer( Plot2d_ViewFrame* theView ) { myView = theView; }
+  Plot2d_ViewFrame*         getViewer() const { return myView; }
+
+  VISU::Result_i*           getResult() const { return myResult; }
+  const VISU::PFieldImpl&   getField() const { return myFieldImpl; }
+
+  std::string               getFieldEntry() const { return myFieldEntry; }
+  std::string               getEvolutionEntry() const { return myEvolutionEntry; }
+  std::string               getMeshName() const { return myMeshName; }
+  VISU::TEntity             getEntity() const { return myEntity; }
+  std::string               getFieldName() const { return myFieldName; }
+
+  const VISU::TimeStampDataList& getTimeStampDataList() const { return myTimeStampDataList; }
+  const VISU::ComponentDataList& getComponentDataList() const { return myComponentDataList; }
+
+  void                      restoreFromStudy( SALOMEDS::SObject_ptr theObj );
+  void                      restoreFromStudy( _PTR(SObject) theObj );
+
+private:
+  bool                      extractData( int thePointId,
+                                         int theComponentId,
+                                         VISU::TimeStampValueList& theTimeStampValueList );
+
+private:
+  _PTR(Study)               myStudy;
+  _PTR(SObject)             myField;
+
+  int                       myPointId;
+  int                       myComponentId;
+
+  Plot2d_ViewFrame*         myView;
+
+  VISU::Result_i*           myResult;
+  VISU::PFieldImpl          myFieldImpl;
+
+  std::string               myFieldEntry;
+  std::string               myEvolutionEntry;
+  std::string               myMeshName;
+  VISU::TEntity             myEntity;
+  std::string               myFieldName;
+
+  VISU::TimeStampDataList   myTimeStampDataList;
+  VISU::ComponentDataList   myComponentDataList;
+};
+
+
+class VISU_I_EXPORT VISU_Evolution_i: public virtual POA_VISU::Evolution,
+                                      public virtual VISU::Base_i
+{
+  VISU_Evolution* myEngine;
+public:
+  VISU_Evolution_i( SALOMEDS::Study_ptr theStudy,
+                    VISU::XYPlot_ptr theXYPlot = VISU::XYPlot::_nil() );
+  ~VISU_Evolution_i();
+
+  virtual VISU::VISUType    GetType() { return VISU::TEVOLUTION; }
+
+  virtual bool              setField(SALOMEDS::SObject_ptr theField);
+
+  virtual void              setPointId(CORBA::Long thePointId);
+
+  virtual void              setComponentId(CORBA::Long theComponentId);
+
+  virtual CORBA::Boolean    showEvolution();
+
+  virtual void              restoreFromStudy(SALOMEDS::SObject_ptr theField);
+};
+
+#endif //VISU_EVOLUTION_H
index c63600c36ba9c4697b4fef992138263e58d4aaad..3c2304e0011a8e114c541bf65283c383072ba0c0 100644 (file)
@@ -34,6 +34,7 @@
 #include "VISU_Table_i.hh"
 #include "VISU_PointMap3d_i.hh"
 #include "VISU_TimeAnimation.h"
+#include "VISU_Evolution.h"
 
 #include "VISU_ColoredPrs3dFactory.hh"
 #include "VISU_ColoredPrs3dCache_i.hh"
@@ -1267,6 +1268,21 @@ namespace VISU
   }
 
 
+  //---------------------------------------------------------------
+  Evolution_ptr
+  VISU_Gen_i
+  ::CreateEvolution(XYPlot_ptr theXYPlot)
+  {
+    if(myStudyDocument->GetProperties()->IsLocked())
+      return Evolution::_nil();
+    Mutex mt(myMutex);
+    if(VISU_Evolution_i* anEvolution = new VISU_Evolution_i(myStudyDocument,theXYPlot)){
+      return anEvolution->_this();
+    }else
+      return VISU::Evolution::_nil();
+  }
+
+
   //---------------------------------------------------------------
   void
   VISU_Gen_i
index 26a42a5b428eb642821264df3761f9a571e2d728..32eec815397bb2a4119dd0bd7eb361887f4326cb 100644 (file)
@@ -280,6 +280,10 @@ namespace VISU
     Animation_ptr
     CreateAnimation(View3D_ptr theView3d);
 
+    virtual
+    Evolution_ptr
+    CreateEvolution(XYPlot_ptr theXYPLot);
+
     virtual
     void 
     DeleteResult(Result_ptr theResult);
diff --git a/src/VISU_I/VISU_Tools.cxx b/src/VISU_I/VISU_Tools.cxx
new file mode 100644 (file)
index 0000000..e2963b9
--- /dev/null
@@ -0,0 +1,310 @@
+//  Copyright (C) 2007-2008  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
+//
+//  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.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//  File   : VISU_Tools.cxx
+//  Author : Oleg UVAROV
+//  Module : VISU
+//
+#include "VISU_Tools.h"
+
+#include "VISU_Gen_i.hh"
+#include "VISU_Table_i.hh"
+#include "VISU_ViewManager_i.hh"
+
+#include <SalomeApp_Study.h>
+#include <SalomeApp_Application.h>
+
+#include <SPlot2d_ViewModel.h>
+#include <Plot2d_ViewFrame.h>
+#include <Plot2d_ViewManager.h>
+
+#include <SUIT_ResourceMgr.h>
+
+//=============================================================================
+namespace VISU
+{
+  //------------------------------------------------------------
+  // Internal function used by several public functions below
+  void
+  UpdateCurve(VISU::Curve_i* theCurve,
+              Plot2d_ViewFrame* thePlot,
+              SPlot2d_Curve* plotCurve,
+              int theDisplaying)
+  {
+    if ( theDisplaying == VISU::eErase ) {
+      if ( plotCurve && thePlot )
+        thePlot->eraseCurve( plotCurve, false );
+    }
+    else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
+      if ( plotCurve ) {
+        plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
+        //plotCurve->setVerTitle( ( theCurve->GetVerTitle().c_str() ) );
+        plotCurve->setVerTitle( theCurve->GetName().c_str() );
+        plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
+        plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
+        double* xList = 0;
+        double* yList = 0;
+        QStringList zList;
+        int     nbPoints = theCurve->GetData( xList, yList, zList );
+        if ( nbPoints > 0 && xList && yList ) {
+          plotCurve->setData( xList, yList, nbPoints, zList );
+        }
+        if ( !theCurve->IsAuto() ) {
+          plotCurve->setLine( (Plot2d::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
+          plotCurve->setMarker( (Plot2d::MarkerType)theCurve->GetMarker() );
+          SALOMEDS::Color color = theCurve->GetColor();
+          plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
+        }
+        plotCurve->setAutoAssign( theCurve->IsAuto() );
+        if( thePlot )
+          thePlot->displayCurve( plotCurve, false );
+      }
+      else {
+        Plot2d_Curve* crv = theCurve->CreatePresentation();
+        if ( crv ) {
+          if( thePlot )
+            thePlot->displayCurve( crv, false );
+          theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
+          theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
+          SALOMEDS::Color newColor;
+          newColor.R = crv->getColor().red()/255.;
+          newColor.G = crv->getColor().green()/255.;
+          newColor.B = crv->getColor().blue()/255.;
+          theCurve->SetColor( newColor );
+          crv->setAutoAssign( theCurve->IsAuto() );
+        }
+      }
+    }
+  }
+
+  //------------------------------------------------------------
+  void
+  PlotTable(SalomeApp_Study* theStudy,
+            Plot2d_ViewFrame* thePlot,
+            VISU::Table_i* table,
+            int theDisplaying)
+  {
+    if ( !thePlot )
+      return;
+
+    if ( theDisplaying == VISU::eDisplayOnly )
+      thePlot->EraseAll();
+    QList<Plot2d_Curve*> clist;
+    thePlot->getCurves( clist );
+    _PTR(Study) aStudy = theStudy->studyDS();
+    _PTR(SObject) TableSO = aStudy->FindObjectID( table->GetEntry() );
+    if ( TableSO ) {
+      _PTR(ChildIterator) Iter = aStudy->NewChildIterator( TableSO );
+      for ( ; Iter->More(); Iter->Next() ) {
+        CORBA::Object_var childObject = VISU::ClientSObjectToObject( Iter->Value() );
+        if( !CORBA::is_nil( childObject ) ) {
+          CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
+          if( !CORBA::is_nil( aCurve ) ) {
+            VISU::Curve_i* theCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
+            SPlot2d_Curve* plotCurve = 0;
+            SPlot2d_Curve* tmpCurve;
+            for ( int i = 0; i < clist.count(); i++ ) {
+              tmpCurve = dynamic_cast<SPlot2d_Curve*>( clist.at( i ) );
+              if (tmpCurve && tmpCurve->hasIO() &&
+                  theCurve->GetEntry() == tmpCurve->getIO()->getEntry()) {
+                plotCurve = tmpCurve;
+                break;
+              }
+            }
+
+            UpdateCurve( theCurve, thePlot, plotCurve, theDisplaying );
+
+            if ( theDisplaying == VISU::eErase && plotCurve ) {
+              clist.removeAll(plotCurve );
+            }
+          }
+        }
+      }
+      thePlot->Repaint();
+    }
+  }
+
+  //------------------------------------------------------------
+  void
+  PlotCurve(Plot2d_ViewFrame* thePlot,
+            VISU::Curve_i* theCurve,
+            int theDisplaying)
+  {
+    if ( !thePlot )
+      return;
+
+//  if ( theDisplaying == VISU::eDisplayOnly )
+//    thePlot->EraseAll();
+    QList<Plot2d_Curve*> clist;
+    thePlot->getCurves( clist );
+    SPlot2d_Curve* plotCurve = 0;
+    SPlot2d_Curve* tmpCurve;
+    if(theDisplaying == VISU::eErase) {
+      // 23.06.2008 skl for IPAL17672
+      for (int i = 0; i < clist.count(); i++) {
+        tmpCurve = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
+        if (tmpCurve && tmpCurve->hasIO() &&
+            theCurve->GetEntry() == tmpCurve->getIO()->getEntry()) {
+          plotCurve = tmpCurve;
+          thePlot->eraseCurve(clist.at(i));
+          break;
+        }
+      }
+      UpdateCurve(theCurve, thePlot, plotCurve, theDisplaying);
+    }
+    else {
+      for (int i = 0; i < clist.count(); i++) {
+        tmpCurve = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
+        if (tmpCurve && tmpCurve->hasIO() &&
+            theCurve->GetEntry() == tmpCurve->getIO()->getEntry()) {
+          plotCurve = tmpCurve;
+        }
+        else if (theDisplaying == VISU::eDisplayOnly) {
+          thePlot->eraseCurve(clist.at(i));
+        }
+      }
+      UpdateCurve(theCurve, thePlot, plotCurve, theDisplaying);
+    }
+
+    thePlot->Repaint();
+  }
+
+  //------------------------------------------------------------
+  void
+  PlotRemoveCurve(SalomeApp_Application* theApp,
+                  VISU::Curve_i* pCrv)
+  {
+    QString anEntry = pCrv->GetEntry().c_str();
+    ViewManagerList pvm_list;
+    theApp->viewManagers( SPlot2d_Viewer::Type(), pvm_list );
+    ViewManagerList::Iterator pvm_it = pvm_list.begin();
+    for( ; pvm_it != pvm_list.end(); pvm_it++ ){
+      Plot2d_ViewManager* pvm = dynamic_cast<Plot2d_ViewManager*>( *pvm_it );
+      if( pvm ){
+        SPlot2d_Viewer* aSPlot2d = dynamic_cast<SPlot2d_Viewer*>( pvm->getViewModel() );
+        if( aSPlot2d ){
+          Plot2d_ViewFrame* thePlot = aSPlot2d->getActiveViewFrame();
+          if(thePlot){
+            QList<Plot2d_Curve*> clist;
+            thePlot->getCurves( clist );
+            for (int i = 0; i < clist.count(); i++) {
+              if(SPlot2d_Curve* plotCurve = dynamic_cast<SPlot2d_Curve*>(clist[i]))
+                if(plotCurve->hasIO() && (plotCurve->getIO()->getEntry() == anEntry))
+                  thePlot->eraseCurve(clist[i]);
+            }
+          }
+        }
+      }
+    }
+  }
+  
+  //------------------------------------------------------------
+  // Internal function used by the function below
+  SPlot2d_Curve* GetCurveByIO( const Handle(SALOME_InteractiveObject)& theIObject,
+                               Plot2d_ViewFrame* thePlot )
+  {
+    if ( !theIObject.IsNull() && thePlot ) {
+      CurveDict aCurves = thePlot->getCurves();
+      CurveDict::Iterator it = aCurves.begin();
+      for( ; it != aCurves.end(); ++it ) {
+        SPlot2d_Curve* aCurve = dynamic_cast<SPlot2d_Curve*>( it.value() );
+        if(aCurve) {
+          if ( aCurve->hasIO() && aCurve->getIO()->isSame( theIObject ) )
+            return aCurve;
+        }
+      }
+    }
+    return NULL;
+  }
+
+  //------------------------------------------------------------
+  void
+  PlotContainer(Plot2d_ViewFrame* thePlot,
+                VISU::Container_i* container,
+                int theDisplaying)
+  {
+    if ( !thePlot )
+      return;
+
+    if ( theDisplaying == VISU::eDisplayOnly )
+      thePlot->EraseAll();
+    QList<Plot2d_Curve*> clist;
+    thePlot->getCurves( clist );
+    if ( container->GetNbCurves() > 0 ) {
+      int nbCurves = container->GetNbCurves();
+      for ( int k = 1; k <= nbCurves; k++ ) {
+        VISU::Curve_i* theCurve = container->GetCurve( k );
+        if ( theCurve && theCurve->IsValid() ) {
+          SPlot2d_Curve* plotCurve = GetCurveByIO(new SALOME_InteractiveObject(theCurve->GetEntry().c_str(), "", ""), thePlot);
+
+          UpdateCurve( theCurve, thePlot, plotCurve, theDisplaying );
+
+          if ( plotCurve && theDisplaying == VISU::eErase ) {
+            clist.removeAll( plotCurve );
+          }
+        }
+      }
+    }
+    thePlot->Repaint();
+    if(GetResourceMgr()->booleanValue("VISU","automatic_fit_all",false)){
+      thePlot->fitAll();
+    }
+    qApp->processEvents();
+  }
+
+  //------------------------------------------------------------
+  void
+  CreatePlot(VISU_Gen_i* theVisuGen,
+             Plot2d_ViewFrame* thePlot,
+             _PTR(SObject) theTableSO)
+  {
+    _PTR(GenericAttribute) anAttr;
+    if ( theTableSO &&
+         ( theTableSO->FindAttribute( anAttr, "AttributeTableOfInteger" ) ||
+           theTableSO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) {
+      CORBA::Object_var aTable = VISU::ClientSObjectToObject(theTableSO);
+      CORBA::Object_var aContainer = theVisuGen->CreateContainer();
+
+      if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
+        VISU::Table_i*     pTable     = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
+        VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
+
+        if ( pContainer && pTable ) {
+          for ( int i = 2; i <= pTable->GetNbRows(); i++ ) {
+            CORBA::Object_var aNewCurve = theVisuGen->CreateCurve( pTable->_this(), 1, i );
+            if( !CORBA::is_nil( aNewCurve ) ) {
+              VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aNewCurve).in() );
+              if ( pCrv ) {
+                pContainer->AddCurve( pCrv->_this() );
+              }
+            }
+          }
+          PlotContainer( thePlot, pContainer, VISU::eDisplay );
+
+          QString anEntry = pContainer->GetEntry().c_str();
+          _PTR(Study) aStudy = theTableSO->GetStudy();
+          _PTR(SObject) aContainerSO = aStudy->FindObjectID(anEntry.toLatin1().data());
+          _PTR(SObject) aParentSO = aContainerSO->GetFather();
+        }
+      }
+    }
+  }
+}
diff --git a/src/VISU_I/VISU_Tools.h b/src/VISU_I/VISU_Tools.h
new file mode 100644 (file)
index 0000000..128d755
--- /dev/null
@@ -0,0 +1,74 @@
+//  Copyright (C) 2007-2008  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
+//
+//  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.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//  File   : VISU_Tools.h
+//  Author : Oleg UVAROV
+//  Module : VISU
+//
+#ifndef VISU_TOOLS_H
+#define VISU_TOOLS_H
+
+#include "VISUConfig.hh"
+
+#include <SALOMEDSClient_Study.hxx>
+
+class SPlot2d_Curve;
+class Plot2d_ViewFrame;
+class SalomeApp_Study;
+class SalomeApp_Application;
+
+namespace VISU 
+{
+  class Gen_i;
+  class Table_i;
+  class Curve_i;
+  class Container_i;
+
+  /*! Display/Erase/Update a curve presentation.
+   *  Parameter \a frame may be NULL, in this case there is only update without display/erase
+   */
+  void                                 UpdateCurve( VISU::Curve_i*,
+                                                    Plot2d_ViewFrame*,
+                                                    SPlot2d_Curve*,
+                                                    int theDisplaying );
+
+  void                                 PlotTable( SalomeApp_Study*,
+                                                  Plot2d_ViewFrame*,
+                                                  VISU::Table_i*,
+                                                  int theDisplaying );
+
+  void                                 PlotCurve( Plot2d_ViewFrame*,
+                                                  VISU::Curve_i*,
+                                                  int theDisplaying );
+
+  void                                 PlotRemoveCurve(SalomeApp_Application*,
+                                                       VISU::Curve_i* );
+
+  void                                 PlotContainer( Plot2d_ViewFrame*,
+                                                      VISU::Container_i*,
+                                                      int theDisplaying );
+
+  void                                 CreatePlot( VISU_Gen_i*,
+                                                   Plot2d_ViewFrame*,
+                                                   _PTR(SObject) theTableSO );
+}
+
+#endif
index 7b1e8672fe14e3af885a07ceaa8f45be20441f30..6e644af50ef50c879db80659027123f4d4e0c8c5 100644 (file)
@@ -186,6 +186,8 @@ namespace VISU
     virtual void GetFitRanges(double& xMin, double& xMax, double& yMin, double& yMax);
 
     virtual void Close();
+
+    Plot2d_ViewFrame* GetView() { return myView; }
   protected:
     Plot2d_ViewFrame* myView;
   public: