Cherrypick from master 2005-11-21 14:37:55 UTC akk <akk@opencascade.com> 'Fix for 10531.':
Makefile.in
src/OBJECT/VISU_ScalarMapAct.h
src/VISUGUI/VisuGUI_CutLinesDlg.h
src/VISUGUI/VisuGUI_Selection.h
src/VISUGUI/VisuGUI_SetupPlot2dDlg.cxx
src/VISUGUI/VisuGUI_SetupPlot2dDlg.h
src/VISU_I/VISUConfig.cc
src/VISU_I/VISU_DumpPython.cc
src/VISU_I/VISU_View_i.hh
src/VISU_SWIG/VISU_Example_03.py
src/VISU_SWIG/VISU_Example_05.py
src/VISU_SWIG/batchmode_visu_view3d.py
src/VISU_SWIG/visu.py
src/VISU_SWIG/visu_delete.py
src/VISU_SWIG/visu_med.py
src/VISU_SWIG/visu_prs_example.py
src/VISU_SWIG/visu_swig_test.py
src/VISU_SWIG/visu_view3d.py
--- /dev/null
+# -* Makefile *-
+#
+# Author : Patrick GOLDBRONN (CEA)
+# Date : 28/06/2001
+# $Header$
+#
+
+# source path
+top_srcdir=@top_srcdir@
+top_builddir=.
+srcdir=@srcdir@
+VPATH=.:@srcdir@:@top_srcdir@/bin:@top_srcdir@/resources:./bin:@top_srcdir@/idl:${KERNEL_ROOT_DIR}/idl/salome
+
+
+@COMMENCE@
+
+SUBDIRS = idl src doc
+
+BIN_SCRIPT= \
+VERSION
+
+
+# copy header files in common directory
+ifeq ($(HAVE_SSTREAM),yes)
+ include_list=include/salome/SALOMEconfig.h
+else
+ include_list=include/salome/SALOMEconfig.h include/salome/sstream
+endif
+
+inc: idl $(include_list)
+
+include/salome/SALOMEconfig.h: salome_adm/unix/SALOMEconfig.ref
+ -$(RM) $@
+ $(LN_S) ../../$< $@
+
+# test if SALOMEconfig.h has changed (contents)
+salome_adm/unix/SALOMEconfig.ref: salome_adm/unix/SALOMEconfig.h
+ @if ! [ -a $@ ]; then \
+ cp -p -f $< $@; \
+ fi; \
+ if ! cmp $< $@; then \
+ cp -p -f $< $@; \
+ fi; \
+
+include/salome/sstream: salome_adm/unix/sstream
+ -$(RM) $@
+ $(LN_S) ../../$< $@
+
+depend: depend_idl
+
+depend_idl:
+ (cd idl ; $(MAKE) $@) || exit 1
+
+# doc is already build : if you want to had documents, go manually to doc and run 'make doc'
+#doc:
+# (cd doc && $(MAKE) $@) || exit 1
+
+install-end:
+# finish libtool install
+# @$(LT) --mode=finish $(libdir)
+
+install-include: $(include_list)
+ $(INSTALL) -d $(includedir)
+ @for f in X $(include_list); do \
+ if test $$f != X; then \
+ ($(INSTALL_DATA) -p $$f $(includedir)/. || exit 1); \
+ fi; \
+ done
+
+# install script in $(bindir) :
+install-bin: $(BIN_SCRIPT)
+ $(INSTALL) -d $(bindir)
+ if test $(BIN_SCRIPT)X != X; then \
+ $(INSTALL_PROGRAM) $^ $(bindir); \
+ fi
+
+uninstall: uninstall-idl
+
+uninstall-idl:
+ $(RM) $(idldir)/*.idl
+
+distclean: distclean-other
+
+distclean-other:
+ -$(RM) salome_adm/unix/*~ salome_adm/unix/*% salome_adm/unix/*.bak salome_adm/unix/*.new salome_adm/unix/*.old
+ -$(RM) salome_adm/unix/make_*
+ -$(RM) salome_adm/unix/depend salome_adm/unix/SALOMEconfig.h
+ -$(RM) config.cache config.log config.status
+
+@MODULE@
+
+install: install-bin install-include install-end
+
--- /dev/null
+// VISU OBJECT : interactive object for VISU entities implementation
+//
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : VISU_ScalarMapAct.h
+// Author : Laurent CORNABE with help of Nicolas REJNERI
+// Module : VISU
+// $Header$
+
+#ifndef VISU_ScalarMapAct_HeaderFile
+#define VISU_ScalarMapAct_HeaderFile
+
+#include "VISU_Actor.h"
+
+class VISU_ScalarBarActor;
+
+class VTKOCC_EXPORT VISU_ScalarMapAct : public VISU_Actor {
+ public:
+ vtkTypeMacro(VISU_ScalarMapAct,VISU_Actor);
+ static VISU_ScalarMapAct* New();
+ ~VISU_ScalarMapAct();
+
+ virtual void AddToRender(vtkRenderer* theRenderer);
+ virtual void RemoveFromRender(vtkRenderer* theRenderer);
+
+ virtual void SetVisibility(int theMode);
+ virtual int GetVisibility();
+
+ virtual VISU_ScalarBarActor* GetScalarBar(){ return myScalarBar;}
+
+ virtual void SetBarVisibility(bool theMode);
+ virtual bool GetBarVisibility(){ return myBarVisibility;}
+
+ virtual void SetShading(bool theOn = true);
+ virtual bool IsShading();
+
+ protected:
+ VISU_ScalarMapAct();
+ bool myBarVisibility;
+ VISU_ScalarBarActor* myScalarBar;
+};
+
+#endif
--- /dev/null
+// VISU VISUGUI : GUI of VISU component
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : VisuGUI_CutLinesDlg.h
+// Author : VSV
+// Module : VISU
+
+#ifndef VISUGUI_CUTLINESDLG_H
+#define VISUGUI_CUTLINESDLG_H
+
+#include "VisuGUI_CutPlanesDlg.h"
+
+#include <qhbuttongroup.h>
+#include <qvalidator.h>
+
+class SUIT_ViewManager;
+class SalomeApp_Module;
+
+namespace VISU{
+ class CutLines_i;
+}
+
+class VisuGUI_CutLinesDlg: public QDialog
+{
+ Q_OBJECT
+
+public:
+ VisuGUI_CutLinesDlg (SalomeApp_Module* theModule);
+ ~VisuGUI_CutLinesDlg();
+
+ void initFromPrsObject (VISU::CutLines_i* thePrs);
+ int storeToPrsObject (VISU::CutLines_i* thePrs);
+
+ bool isGenerateTable() { return myCreateTable->isChecked(); }
+ bool isGenerateCurves() { return myCreateTable->isChecked() && myCurvesCheck->isChecked(); }
+
+protected slots:
+ void accept();
+ void reject();
+
+private slots:
+ void onPlaneSelect (int theId);
+ void onCutSelect (int theId, bool theUpdate = true);
+ void setBaseDefault (bool theUpdate = true);
+ void setDefault (int all = -1);
+ void DrawTable();
+ void onValueChanged (int theRow, int theCol);
+ void onPreviewCheck (bool thePreview);
+ void onAllCurvesInvertedCheck(bool theInvert);
+ void onRotation (double theValue);
+ void onPlanePos (const QString& theValue);
+ //jfa tmp:void onWindowActivated (SUIT_ViewWindow*);
+
+private:
+ void createPlanes();
+ void deletePlanes();
+ void updateGlyphs(bool update);
+
+ QHButtonGroup* mySelPlane;
+ QtxDblSpinBox* myRotXSpn;
+ QtxDblSpinBox* myRotYSpn;
+ QLabel* myRotXLbl;
+ QLabel* myRotYLbl;
+ QtxDblSpinBox* myPosSpn;
+ QLineEdit* myBasePlanePos;
+ QCheckBox* myCBSetDef;
+ QCheckBox* myCreateTable;
+ QCheckBox* myCurvesCheck;
+
+ QHButtonGroup* mySelPlane2;
+ QtxDblSpinBox* myNbSpn;
+ QtxDblSpinBox* myRotXSpn2;
+ QtxDblSpinBox* myRotYSpn2;
+ QLabel* myRotXLbl2;
+ QLabel* myRotYLbl2;
+ QtxDblSpinBox* myPosSpn2;
+ QTable* myPosTable;
+ bool hasInit;
+
+ QDoubleValidator *mydvalidator;
+ VISU::CutLines_i* myCutLines;
+
+ VisuGUI_ScalarBarPane* myScalarPane;
+
+ VISU::CutPlanes::Orientation getOrientaion (bool IsBasePlane = true);
+ void setOrientation (const VISU::CutPlanes::Orientation orient);
+ void setOrientation2 (const VISU::CutPlanes::Orientation orient);
+
+ SALOME_Actor* myPreviewActor;
+ SALOME_Actor* myPreviewActorGlyphs;
+ QCheckBox* myPreviewCheck;
+ QCheckBox* myAllCurvesInvertedCheck;
+
+ VISU::CutLines_i* myPrs;
+
+ //jfa tmp:SUIT_ViewManager *myMgr;
+ //jfa tmp:SUIT_ViewWindow *myStudyWnd;
+
+ static bool MYGenerateTable;
+ static bool MYGenerateCurve;
+};
+
+#endif // VISUGUI_CUTLINESDLG_H
--- /dev/null
+// VISU VISUGUI : GUI of VISU component
+//
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : VisuGUI_Selection.h
+// Author : Laurent CORNABE & Hubert ROLLAND
+// Module : VISU
+// $Header$
+
+#ifndef VisuGUI_Selection_HeaderFile
+#define VisuGUI_Selection_HeaderFile
+
+#include <qdialog.h>
+
+class QLabel;
+class QWidgetStack;
+class QVBox;
+class QLineEdit;
+class QTable;
+class LightApp_SelectionMgr;
+class SalomeApp_Application;
+
+class VisuGUI_SelectionDlg: public QDialog {
+ Q_OBJECT
+
+public:
+ VisuGUI_SelectionDlg (QWidget*);
+ virtual ~VisuGUI_SelectionDlg ();
+
+protected:
+ void closeEvent (QCloseEvent* theEvent);
+
+private slots:
+ void onSelectionChange (int theId);
+ void onSelectionEvent ();
+ void onPointIdEdit (const QString& theText);
+ void onCellIdEdit (const QString& theText);
+
+ private:
+ void clearFields ();
+
+ QLabel* myMeshName;
+ QLabel* myFieldName;
+
+ QWidgetStack* myWidgetStack;
+ QVBox* myPointsPane;
+ QWidget* myCellsPane;
+ QLabel* myXValLbl;
+ QLabel* myYValLbl;
+ QLabel* myZValLbl;
+
+ QLineEdit* myIDValLbl;
+ QLabel* myScalarValLbl;
+ QLabel* myVectorValLbl;
+
+ QTable* myListPoints;
+ QLineEdit* myCellIDValLbl;
+ QLabel* myCellScalarValLbl;
+ QLabel* myCellVectorValLbl;
+
+ QVBox* myActorsPane;
+ QLabel* myXPosLbl;
+ QLabel* myYPosLbl;
+ QLabel* myZPosLbl;
+ QLabel* myDXLbl;
+ QLabel* myDYLbl;
+ QLabel* myDZLbl;
+
+ LightApp_SelectionMgr* mySelectionMgr;
+ bool myFl;
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : VisuGUI_SetupPlot2dDlg.cxx
+// Author : Vadim SANDLER
+// Module : SALOME
+// $Header$
+
+#include "VisuGUI_SetupPlot2dDlg.h"
+#include "SPlot2d_Curve.h"
+
+#include "SUIT_Tools.h"
+#include "SUIT_MessageBox.h"
+
+#include <SALOMEDSClient_AttributeTableOfInteger.hxx>
+#include <SALOMEDSClient_AttributeTableOfReal.hxx>
+
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qcheckbox.h>
+#include <qtoolbutton.h>
+#include <qcombobox.h>
+#include <qscrollview.h>
+#include <qlayout.h>
+#include <qcolordialog.h>
+#include <qspinbox.h>
+
+#include <vector>
+#include <string>
+
+#include "utilities.h"
+
+using namespace std;
+
+#define DLG_SIZE_WIDTH 500
+#define DLG_SIZE_HEIGHT 400
+#define MAX_LINE_WIDTH 100
+#define MARGIN_SIZE 11
+#define SPACING_SIZE 6
+
+/*!
+ Constructor
+*/
+VisuGUI_SetupPlot2dDlg::VisuGUI_SetupPlot2dDlg( _PTR(SObject) object, QWidget* parent )
+ : QDialog( parent,
+ "VisuGUI_SetupPlot2dDlg",
+ true,
+ WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+{
+ setCaption( tr("TLT_SETUP_PLOT2D") );
+ setSizeGripEnabled( TRUE );
+ QGridLayout* topLayout = new QGridLayout( this );
+ topLayout->setSpacing( SPACING_SIZE );
+ topLayout->setMargin( MARGIN_SIZE );
+
+ myItems.setAutoDelete( false );
+
+ myObject = object;
+
+ /* Top scroll view */
+ myView = new QScrollView( this );
+ QFrame* frame = new QFrame( myView );
+ frame->setFrameStyle( QFrame::Plain | QFrame::NoFrame );
+ QGridLayout* frameLayout = new QGridLayout( frame, 1, 12 );
+ frameLayout->setMargin( MARGIN_SIZE ); frameLayout->setSpacing( SPACING_SIZE );
+
+ QFrame* lin;
+
+ QLabel* labAxis = new QLabel( tr( "AXIS_LBL" ), frame );
+ QLabel* labData = new QLabel( tr( "DATA_LBL" ), frame );
+ QLabel* labUnit = new QLabel( tr( "UNITS_LBL" ), frame );
+ QLabel* labAttr = new QLabel( tr( "ATTRIBUTES_LBL" ), frame );
+ labAxis->setAlignment( AlignCenter );
+ labData->setAlignment( AlignCenter );
+ labUnit->setAlignment( AlignCenter );
+ labAttr->setAlignment( AlignCenter );
+ QFont font = labAxis->font(); font.setBold( true );
+ labAxis->setFont( font );
+ labData->setFont( font );
+ labUnit->setFont( font );
+ labAttr->setFont( font );
+
+ frameLayout->addMultiCellWidget( labAxis, 0, 0, 0, 1 );
+ lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
+ frameLayout->addWidget( lin, 0, 2 );
+ frameLayout->addWidget( labData, 0, 3 );
+ lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
+ frameLayout->addWidget( lin, 0, 4 );
+ frameLayout->addWidget( labUnit, 0, 5 );
+ lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
+ frameLayout->addWidget( lin, 0, 6 );
+ frameLayout->addMultiCellWidget( labAttr, 0, 0, 7, 11 );
+ frameLayout->setColStretch( 12, 5 );
+ lin = new QFrame( frame ); lin->setFrameStyle( QFrame::HLine | QFrame::Sunken );
+ frameLayout->addMultiCellWidget( lin, 1, 1, 0, 12 );
+
+ int row = 2;
+ _PTR(GenericAttribute) anAttr;
+ _PTR(AttributeTableOfInteger) tblIntAttr;
+ _PTR(AttributeTableOfReal) tblRealAttr;
+
+ /* Try table of integer */
+ if ( myObject->FindAttribute( anAttr, "AttributeTableOfInteger" ) ) {
+ tblIntAttr = anAttr;
+ if ( tblIntAttr ) {
+ try {
+ int nbRows = tblIntAttr->GetNbRows() ;
+ vector<string> rowTitles = tblIntAttr->GetRowTitles();
+ vector<string> rowUnits = tblIntAttr->GetRowUnits();
+ for ( int i = 0; i < nbRows; i++ ) {
+ VisuGUI_ItemContainer* item = new VisuGUI_ItemContainer( this );
+ item->createWidgets( frame );
+ frameLayout->addWidget( item->myHBtn, row, 0 );
+ frameLayout->addWidget( item->myVBtn, row, 1 );
+ frameLayout->addWidget( item->myTitleLab, row, 3 );
+ if ( rowTitles.size() > 0 )
+ item->myTitleLab->setText( QString( rowTitles[ i ].c_str() ) );
+ frameLayout->addWidget( item->myUnitLab, row, 5 );
+ if ( rowUnits.size() > 0 )
+ item->myUnitLab->setText( QString( rowUnits[ i ].c_str() ) );
+ frameLayout->addWidget( item->myAutoCheck, row, 7 );
+ frameLayout->addWidget( item->myLineCombo, row, 8 );
+ frameLayout->addWidget( item->myLineSpin, row, 9 );
+ frameLayout->addWidget( item->myMarkerCombo, row, 10 );
+ frameLayout->addWidget( item->myColorBtn, row, 11 );
+ connect( item, SIGNAL( horToggled( bool ) ), this, SLOT( onHBtnToggled( bool ) ) );
+ connect( item, SIGNAL( verToggled( bool ) ), this, SLOT( onVBtnToggled( bool ) ) );
+ myItems.append( item );
+ row++;
+ }
+ }
+ catch( ... ) {
+ MESSAGE("VisuGUI_SetupPlot2dDlg::VisuGUI_SetupPlot2dDlg : Exception has been caught (int)!!!");
+ }
+ }
+ }
+ /* Try table of real */
+ else if ( myObject->FindAttribute( anAttr, "AttributeTableOfReal" ) ) {
+ tblRealAttr = anAttr;
+ if ( tblRealAttr ) {
+ try {
+ int nbRows = tblRealAttr->GetNbRows() ;
+ vector<string> rowTitles = tblRealAttr->GetRowTitles();
+ vector<string> rowUnits = tblRealAttr->GetRowUnits();
+ for ( int i = 0; i < nbRows; i++ ) {
+ VisuGUI_ItemContainer* item = new VisuGUI_ItemContainer( this );
+ item->createWidgets( frame );
+ frameLayout->addWidget( item->myHBtn, row, 0 );
+ frameLayout->addWidget( item->myVBtn, row, 1 );
+ frameLayout->addWidget( item->myTitleLab, row, 3 );
+ if ( rowTitles.size() > 0 )
+ item->myTitleLab->setText( QString( rowTitles[ i ].c_str() ) );
+ frameLayout->addWidget( item->myUnitLab, row, 5 );
+ if ( rowUnits.size() > 0 )
+ item->myUnitLab->setText( QString( rowUnits[ i ].c_str() ) );
+ frameLayout->addWidget( item->myAutoCheck, row, 7 );
+ frameLayout->addWidget( item->myLineCombo, row, 8 );
+ frameLayout->addWidget( item->myLineSpin, row, 9 );
+ frameLayout->addWidget( item->myMarkerCombo, row, 10 );
+ frameLayout->addWidget( item->myColorBtn, row, 11 );
+ connect( item, SIGNAL( horToggled( bool ) ), this, SLOT( onHBtnToggled( bool ) ) );
+ connect( item, SIGNAL( verToggled( bool ) ), this, SLOT( onVBtnToggled( bool ) ) );
+ myItems.append( item );
+ row++;
+ }
+ }
+ catch( ... ) {
+ MESSAGE("VisuGUI_SetupPlot2dDlg::VisuGUI_SetupPlot2dDlg : Exception has been caught (real)!!!");
+ }
+ }
+ }
+ lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
+ frameLayout->addMultiCellWidget( lin, 2, row+1, 2, 2 );
+ lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
+ frameLayout->addMultiCellWidget( lin, 2, row+1, 4, 4 );
+ lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken );
+ frameLayout->addMultiCellWidget( lin, 2, row+1, 6, 6 );
+ frameLayout->setRowStretch( row+1, 5 );
+
+ myView->addChild( frame, 0, 0 );
+ myView->setResizePolicy( QScrollView::AutoOneFit );
+
+ myView->setMinimumWidth( frame->sizeHint().width() + MARGIN_SIZE * 2 );
+
+ /* OK/Cancel buttons */
+ myOkBtn = new QPushButton( tr( "BUT_OK" ), this, "buttonOk" );
+ myOkBtn->setAutoDefault( TRUE );
+ myOkBtn->setDefault( TRUE );
+ myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), this, "buttonCancel" );
+ myCancelBtn->setAutoDefault( TRUE );
+
+ topLayout->addMultiCellWidget( myView, 0, 0, 0, 2 );
+ topLayout->addWidget( myOkBtn, 1, 0 );
+ topLayout->setColStretch( 1, 5 );
+ topLayout->addWidget( myCancelBtn, 1, 2 );
+
+ connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) );
+ connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
+
+ enableControls();
+
+ /* Center widget inside it's parent widget */
+ resize( DLG_SIZE_WIDTH, DLG_SIZE_HEIGHT );
+ SUIT_Tools::centerWidget( this, parentWidget() );
+}
+/*!
+ Destructor
+*/
+VisuGUI_SetupPlot2dDlg::~VisuGUI_SetupPlot2dDlg()
+{
+}
+/*!
+ Gets curves info ( indexes of row data in the table for horizontal and verical axes )
+*/
+void VisuGUI_SetupPlot2dDlg::getCurvesSource( int& horIndex, QValueList<int>& verIndexes )
+{
+ /* collecting horizontal and vertical axis items */
+ horIndex = -1;
+ int i;
+ for ( i = 0; i < myItems.count(); i++ ) {
+ if ( myItems.at( i )->isHorizontalOn() ) {
+ horIndex = i;
+ }
+ else if ( myItems.at( i )->isVerticalOn() ) {
+ verIndexes.append( i );
+ }
+ }
+}
+/*!
+ Gets curve attributes
+*/
+bool VisuGUI_SetupPlot2dDlg::getCurveAttributes( const int vIndex,
+ bool& isAuto,
+ int& marker,
+ int& line,
+ int& lineWidth,
+ QColor& color)
+{
+ if ( vIndex >= 0 && vIndex < myItems.count() ) {
+ isAuto = myItems.at( vIndex )->isAutoAssign();
+ marker = myItems.at( vIndex )->getMarker();
+ line = myItems.at( vIndex )->getLine();
+ lineWidth = myItems.at( vIndex )->getLineWidth();
+ color = myItems.at( vIndex )->getColor();
+ return true;
+ }
+ return false;
+}
+/*!
+ Creates and returns curves presentations
+*/
+void VisuGUI_SetupPlot2dDlg::getCurves( QPtrList<Plot2d_Curve>& container )
+{
+ _PTR(GenericAttribute) anAttr;
+ _PTR(AttributeTableOfInteger) tblIntAttr;
+ _PTR(AttributeTableOfReal) tblRealAttr;
+
+ /* clearing container contents */
+ container.clear();
+
+ /* collecting horizontal and vertical axis items */
+ int horIndex;
+ int i, j;
+ QValueList<int> verIndex;
+ getCurvesSource( horIndex, verIndex );
+ if ( horIndex < 0 || verIndex.isEmpty() ) /* no curves can be created */
+ return;
+
+ /* Try table of integer */
+ if ( myObject->FindAttribute( anAttr, "AttributeTableOfInteger" ) ) {
+ tblIntAttr = anAttr;
+ if ( tblIntAttr ) {
+ try {
+ int nbCols = tblIntAttr->GetNbColumns() ;
+ vector<string> rowTitles = tblIntAttr->GetRowTitles();
+ vector<string> rowUnits = tblIntAttr->GetRowUnits();
+
+ for ( i = 0; i < verIndex.count(); i++ ) {
+ SPlot2d_Curve* curve = new SPlot2d_Curve();
+ // curve titles
+ if ( rowTitles.size() > 0 ) {
+ curve->setHorTitle( QString( rowTitles[ horIndex ].c_str() ) );
+ curve->setVerTitle( QString( rowTitles[ verIndex[i] ].c_str() ) );
+ }
+ // curve units
+ if ( rowUnits.size() > 0 ) {
+ curve->setHorUnits( QString( rowUnits[ horIndex ].c_str() ) );
+ curve->setVerUnits( QString( rowUnits[ verIndex[i] ].c_str() ) );
+ }
+ // curve data
+ int nbPoints = 0;
+ for ( j = 1; j <= nbCols; j++ ) {
+ if ( tblIntAttr->HasValue( horIndex+1, j ) && tblIntAttr->HasValue( verIndex[i]+1, j ) )
+ nbPoints++;
+ }
+ if ( nbPoints > 0 ) {
+ double* xList = new double[ nbPoints ];
+ double* yList = new double[ nbPoints ];
+ for ( j = 1; j <= nbCols; j++ ) {
+ if ( tblIntAttr->HasValue( horIndex+1, j ) && tblIntAttr->HasValue( verIndex[i]+1, j ) ) {
+ xList[j-1] = tblIntAttr->GetValue( horIndex +1, j );
+ yList[j-1] = tblIntAttr->GetValue( verIndex[i]+1, j );
+ }
+ }
+ curve->setData( xList, yList, nbPoints );
+ }
+ // curve attributes
+ curve->setLine( (Plot2d_Curve::LineType)myItems.at( verIndex[i] )->getLine(), myItems.at( verIndex[i] )->getLineWidth() );
+ curve->setMarker( (Plot2d_Curve::MarkerType)myItems.at( verIndex[i] )->getMarker() );
+ curve->setColor( myItems.at( verIndex[i] )->getColor() );
+ curve->setAutoAssign( myItems.at( verIndex[i] )->isAutoAssign() );
+ // add curve into container
+ container.append( curve );
+ }
+ }
+ catch( ... ) {
+ MESSAGE("VisuGUI_SetupPlot2dDlg::getCurves : Exception has been caught (int)!!!");
+ }
+ }
+ }
+ /* Try table of real */
+ else if ( myObject->FindAttribute( anAttr, "AttributeTableOfReal" ) ) {
+ tblRealAttr = anAttr;
+ if ( tblRealAttr ) {
+ try {
+ int nbCols = tblRealAttr->GetNbColumns() ;
+ vector<string> rowTitles = tblRealAttr->GetRowTitles();
+ vector<string> rowUnits = tblRealAttr->GetRowUnits();
+
+ for ( i = 0; i < verIndex.count(); i++ ) {
+ SPlot2d_Curve* curve = new SPlot2d_Curve();
+ // curve titles
+ if ( rowTitles.size() > 0 ) {
+ curve->setHorTitle( QString( rowTitles[ horIndex ].c_str() ) );
+ curve->setVerTitle( QString( rowTitles[ verIndex[i] ].c_str() ) );
+ }
+ // curve units
+ if ( rowUnits.size() > 0 ) {
+ curve->setHorUnits( QString( rowUnits[ horIndex ].c_str() ) );
+ curve->setVerUnits( QString( rowUnits[ verIndex[i] ].c_str() ) );
+ }
+ // curve data
+ int nbPoints = 0;
+ for ( j = 1; j <= nbCols; j++ ) {
+ if ( tblRealAttr->HasValue( horIndex+1, j ) && tblRealAttr->HasValue( verIndex[i]+1, j ) )
+ nbPoints++;
+ }
+ if ( nbPoints > 0 ) {
+ double* xList = new double[ nbPoints ];
+ double* yList = new double[ nbPoints ];
+ for ( j = 1; j <= nbCols; j++ ) {
+ if ( tblRealAttr->HasValue( horIndex+1, j ) && tblRealAttr->HasValue( verIndex[i]+1, j ) ) {
+ xList[j-1] = tblRealAttr->GetValue( horIndex +1, j );
+ yList[j-1] = tblRealAttr->GetValue( verIndex[i]+1, j );
+ }
+ }
+ curve->setData( xList, yList, nbPoints );
+ }
+ // curve attributes
+ curve->setLine( (Plot2d_Curve::LineType)myItems.at( verIndex[i] )->getLine(), myItems.at( verIndex[i] )->getLineWidth() );
+ curve->setMarker( (Plot2d_Curve::MarkerType)myItems.at( verIndex[i] )->getMarker() );
+ curve->setColor( myItems.at( verIndex[i] )->getColor() );
+ curve->setAutoAssign( myItems.at( verIndex[i] )->isAutoAssign() );
+ // add curve into container
+ container.append( curve );
+ }
+ }
+ catch( ... ) {
+ MESSAGE("VisuGUI_SetupPlot2dDlg::getCurves : Exception has been caught (real)!!!");
+ }
+ }
+ }
+}
+/*!
+ Slot, called when any <H> button is clicked
+*/
+void VisuGUI_SetupPlot2dDlg::onHBtnToggled( bool on )
+{
+ VisuGUI_ItemContainer* item = ( VisuGUI_ItemContainer* )sender();
+ if ( on ) {
+ for ( int i = 0; i < myItems.count(); i++ ) {
+ if ( myItems.at( i ) != item )
+ myItems.at( i )->setHorizontalOn( false );
+ }
+ }
+ enableControls();
+}
+/*!
+ Slot, called when any <V> button is clicked
+*/
+void VisuGUI_SetupPlot2dDlg::onVBtnToggled( bool on )
+{
+ VisuGUI_ItemContainer* item = ( VisuGUI_ItemContainer* )sender();
+ QPtrList<VisuGUI_ItemContainer> itemList;
+ itemList.setAutoDelete( false );
+ int i;
+ if ( on ) {
+ int totalOn = 0;
+ for ( i = 0; i < myItems.count(); i++ ) {
+ if ( myItems.at( i ) != item && !myItems.at( i )->isHorizontalOn() ) {
+ if ( myItems.at( i )->myUnitLab->text() == item->myUnitLab->text() ) {
+ if ( myItems.at( i )->isVerticalOn() )
+ totalOn++;
+ else
+ itemList.append( myItems.at( i ) );
+ }
+ else {
+ myItems.at( i )->setVerticalOn( false );
+ }
+ }
+ }
+ if ( totalOn == 0 && !itemList.isEmpty() &&
+ SUIT_MessageBox::info2( this,
+ this->caption(),
+ tr( "QUE_WANT_SAME_UNITS" ),
+ tr( "BUT_YES" ),
+ tr( "BUT_NO" ),
+ 0, 1, 1 ) == 0 ) {
+ for ( i = 0; i < itemList.count(); i++ ) {
+ itemList.at( i )->blockSignals( true );
+ itemList.at( i )->setVerticalOn( true );
+ itemList.at( i )->blockSignals( false );
+ }
+ }
+ }
+ enableControls();
+}
+/*!
+ Enables/disables buttons
+*/
+void VisuGUI_SetupPlot2dDlg::enableControls()
+{
+ bool bHSet = false;
+ bool bVSet = false;
+ for ( int i = 0; i < myItems.count(); i++ ) {
+ if ( myItems.at( i )->isHorizontalOn() ) {
+ bHSet = true;
+ break;
+ }
+ }
+#ifndef WNT
+ for ( int i = 0; i < myItems.count(); i++ ) {
+#else
+ for ( i = 0; i < myItems.count(); i++ ) {
+#endif
+ if ( myItems.at( i )->isVerticalOn() )
+ bVSet = true;
+ myItems.at( i )->enableWidgets( bHSet && myItems.at( i )->isVerticalOn() );
+ }
+ myOkBtn->setEnabled( bHSet && bVSet );
+}
+
+// ====================================================================================
+/*!
+ Constructor
+*/
+VisuGUI_ItemContainer::VisuGUI_ItemContainer( QObject* parent, const char* name )
+ : QObject( parent, name ),
+ myEnabled( true )
+{
+}
+/*!
+ Creates widgets
+*/
+void VisuGUI_ItemContainer::createWidgets( QWidget* parentWidget )
+{
+ myHBtn = new QToolButton( parentWidget );
+ myHBtn->setText( tr( "H" ) );
+ myHBtn->setToggleButton( true );
+ myHBtn->setOn( false );
+
+ myVBtn = new QToolButton( parentWidget );
+ myVBtn->setText( tr( "V" ) );
+ myVBtn->setToggleButton( true );
+ myVBtn->setOn( false );
+
+ myTitleLab = new QLabel( parentWidget );
+ myUnitLab = new QLabel( parentWidget );
+ myUnitLab->setAlignment( AlignCenter);
+
+ myAutoCheck = new QCheckBox( tr( "AUTO_CHECK_LBL" ), parentWidget );
+ myAutoCheck->setChecked( true );
+
+ myLineCombo = new QComboBox( false, parentWidget );
+ myLineCombo->insertItem( tr( "NONE_LINE_LBL" ) );
+ myLineCombo->insertItem( tr( "SOLID_LINE_LBL" ) );
+ myLineCombo->insertItem( tr( "DASH_LINE_LBL" ) );
+ myLineCombo->insertItem( tr( "DOT_LINE_LBL" ) );
+ myLineCombo->insertItem( tr( "DASHDOT_LINE_LBL" ) );
+ myLineCombo->insertItem( tr( "DAHSDOTDOT_LINE_LBL" ) );
+ myLineCombo->setCurrentItem( 1 ); // SOLID by default
+
+ myLineSpin = new QSpinBox( 0, MAX_LINE_WIDTH, 1, parentWidget );
+ myLineSpin->setValue( 0 ); // width = 0 by default
+
+ myMarkerCombo = new QComboBox( false, parentWidget );
+ myMarkerCombo->insertItem( tr( "NONE_MARKER_LBL" ) );
+ myMarkerCombo->insertItem( tr( "CIRCLE_MARKER_LBL" ) );
+ myMarkerCombo->insertItem( tr( "RECTANGLE_MARKER_LBL" ) );
+ myMarkerCombo->insertItem( tr( "DIAMOND_MARKER_LBL" ) );
+ myMarkerCombo->insertItem( tr( "DTRIANGLE_MARKER_LBL" ) );
+ myMarkerCombo->insertItem( tr( "UTRIANGLE_MARKER_LBL" ) );
+ myMarkerCombo->insertItem( tr( "LTRIANGLE_MARKER_LBL" ) );
+ myMarkerCombo->insertItem( tr( "RTRIANGLE_MARKER_LBL" ) );
+ myMarkerCombo->insertItem( tr( "CROSS_MARKER_LBL" ) );
+ myMarkerCombo->insertItem( tr( "XCROSS_MARKER_LBL" ) );
+ myMarkerCombo->setCurrentItem( 1 ); // CIRCLE by default
+
+ myColorBtn = new QToolButton( parentWidget );
+ myColorBtn->setMinimumWidth( 20 );
+
+ connect( myAutoCheck, SIGNAL( clicked() ), this, SLOT( onAutoChanged() ) );
+ connect( myColorBtn, SIGNAL( clicked() ), this, SLOT( onColorChanged() ) );
+ connect( myHBtn, SIGNAL( toggled( bool ) ), this, SLOT( onHVToggled( bool ) ) );
+ connect( myVBtn, SIGNAL( toggled( bool ) ), this, SLOT( onHVToggled( bool ) ) );
+ setColor( QColor( 0, 0, 0 ) );
+ updateState();
+}
+/*!
+ Enables attributes widgets
+*/
+void VisuGUI_ItemContainer::enableWidgets( bool enable )
+{
+ myEnabled = enable;
+ updateState();
+}
+/*!
+ Sets horizontal button's state on
+*/
+void VisuGUI_ItemContainer::setHorizontalOn( bool on )
+{
+ myHBtn->setOn( on );
+}
+/*!
+ Gets horizontal button's state
+*/
+bool VisuGUI_ItemContainer::isHorizontalOn() const
+{
+ return myHBtn->isOn();
+}
+/*!
+ Sets vertical button's state on
+*/
+void VisuGUI_ItemContainer::setVerticalOn( bool on )
+{
+ myVBtn->setOn( on );
+}
+/*!
+ Gets vertical button's state
+*/
+bool VisuGUI_ItemContainer::isVerticalOn() const
+{
+ return myVBtn->isOn();
+}
+/*!
+ Sets item AutoAssign flag state
+*/
+void VisuGUI_ItemContainer::setAutoAssign( bool on )
+{
+ myAutoCheck->setChecked( on );
+ updateState();
+}
+/*!
+ Gets item AutoAssign flag state
+*/
+bool VisuGUI_ItemContainer::isAutoAssign() const
+{
+ return myAutoCheck->isChecked();
+}
+/*!
+ Sets item line type and width
+*/
+void VisuGUI_ItemContainer::setLine( const int line, const int width )
+{
+ myLineCombo->setCurrentItem( line );
+}
+/*!
+ Gets item line type
+*/
+int VisuGUI_ItemContainer::getLine() const
+{
+ return myLineCombo->currentItem();
+}
+/*!
+ Gets item line width
+*/
+int VisuGUI_ItemContainer::getLineWidth() const
+{
+ return myLineSpin->value();
+}
+/*!
+ Sets item marker type
+*/
+void VisuGUI_ItemContainer::setMarker( const int marker )
+{
+ myMarkerCombo->setCurrentItem( marker );
+}
+/*!
+ Gets item marker type
+*/
+int VisuGUI_ItemContainer::getMarker() const
+{
+ return myMarkerCombo->currentItem();
+}
+/*!
+ Sets item color
+*/
+void VisuGUI_ItemContainer::setColor( const QColor& color )
+{
+ QPalette pal = myColorBtn->palette();
+ QColorGroup ca = pal.active();
+ ca.setColor( QColorGroup::Button, color );
+ QColorGroup ci = pal.inactive();
+ ci.setColor( QColorGroup::Button, color );
+ pal.setActive( ca );
+ pal.setInactive( ci );
+ myColorBtn->setPalette( pal );
+}
+/*!
+ Gets item color
+*/
+QColor VisuGUI_ItemContainer::getColor() const
+{
+ return myColorBtn->palette().active().button();
+}
+/*!
+ Enables/disables widgets
+*/
+void VisuGUI_ItemContainer::updateState()
+{
+ myAutoCheck->setEnabled( myEnabled );
+ myLineCombo->setEnabled( myEnabled && !myAutoCheck->isChecked() );
+ myLineSpin->setEnabled( myEnabled && !myAutoCheck->isChecked() );
+ myMarkerCombo->setEnabled( myEnabled && !myAutoCheck->isChecked() );
+ myColorBtn->setEnabled( myEnabled && !myAutoCheck->isChecked() );
+}
+/*!
+ Slot, called when user clickes <Auto assign> check box
+*/
+void VisuGUI_ItemContainer::onAutoChanged()
+{
+ updateState();
+ emit( autoClicked() );
+}
+/*!
+ <Color> button slot, invokes color selection dialog box
+*/
+void VisuGUI_ItemContainer::onColorChanged()
+{
+ QColor color = QColorDialog::getColor( getColor() );
+ if ( color.isValid() ) {
+ setColor( color );
+ }
+}
+/*!
+ <H> and <V> buttons slot
+*/
+void VisuGUI_ItemContainer::onHVToggled( bool on )
+{
+ const QObject* snd = sender();
+ if ( snd == myHBtn ) {
+ if ( on ) {
+ if ( myVBtn->isOn() ) {
+// blockSignals( true );
+ myVBtn->setOn( false );
+// blockSignals( false );
+ }
+ }
+ emit horToggled( on );
+ }
+ else {
+ if ( on ) {
+ if ( myHBtn->isOn() ) {
+// blockSignals( true );
+ myHBtn->setOn( false );
+// blockSignals( false );
+ }
+ }
+ emit verToggled( on );
+ }
+}
+
+
+
+
+
--- /dev/null
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : VisuGUI_SetupPlot2dDlg.h
+// Author : Vadim SANDLER
+// Module : SALOME
+// $Header$
+
+#ifndef VISUGUI_SetupPlot2dDlg_H
+#define VISUGUI_SetupPlot2dDlg_H
+
+#include "Plot2d_Curve.h"
+
+#include <SALOMEDSClient_SObject.hxx>
+
+#include <qdialog.h>
+#include <qptrlist.h>
+
+//=================================================================================
+// class : VisuGUI_SetupPlot2dDlg
+// purpose : Dialog box for setup Plot2d view
+//=================================================================================
+
+class QScrollView;
+class QPushButton;
+class QLabel;
+class QCheckBox;
+class QComboBox;
+class QSpinBox;
+class QToolButton;
+class VisuGUI_ItemContainer;
+
+class VisuGUI_SetupPlot2dDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ VisuGUI_SetupPlot2dDlg( _PTR(SObject) object, QWidget* parent = 0 );
+ ~VisuGUI_SetupPlot2dDlg();
+
+ void getCurves( QPtrList<Plot2d_Curve>& container );
+ void getCurvesSource( int& horIndex, QValueList<int>& verIndexes );
+ bool getCurveAttributes( const int vIndex, bool& isAuto, int& marker, int& line, int& lineWidth, QColor& color);
+
+private slots:
+ void onHBtnToggled( bool );
+ void onVBtnToggled( bool );
+ void enableControls();
+
+private:
+ QScrollView* myView;
+ QPushButton* myOkBtn;
+ QPushButton* myCancelBtn;
+ QPtrList<VisuGUI_ItemContainer> myItems;
+
+ _PTR(SObject) myObject;
+};
+
+class VisuGUI_ItemContainer : public QObject
+{
+ Q_OBJECT
+
+public:
+ VisuGUI_ItemContainer( QObject* parent = 0, const char* name = 0 );
+
+ void createWidgets( QWidget* parentWidget );
+ void enableWidgets( bool enable );
+
+ void setHorizontalOn( bool on );
+ bool isHorizontalOn() const;
+ void setVerticalOn( bool on );
+ bool isVerticalOn() const;
+ bool isAutoAssign() const;
+ void setAutoAssign( bool on );
+ void setLine( const int line, const int width );
+ int getLine() const;
+ int getLineWidth() const;
+ void setMarker( const int marker );
+ int getMarker() const;
+ void setColor( const QColor& color );
+ QColor getColor() const;
+
+protected:
+ void updateState();
+
+signals:
+ void autoClicked();
+ void horToggled( bool );
+ void verToggled( bool );
+
+public slots:
+ void onAutoChanged();
+ void onColorChanged();
+ void onHVToggled( bool );
+
+public:
+ bool myEnabled;
+ QToolButton* myHBtn;
+ QToolButton* myVBtn;
+ QLabel* myTitleLab;
+ QLabel* myUnitLab;
+ QCheckBox* myAutoCheck;
+ QComboBox* myLineCombo;
+ QSpinBox* myLineSpin;
+ QComboBox* myMarkerCombo;
+ QToolButton* myColorBtn;
+};
+
+#endif // VISUGUI_SetupPlot2dDlg_H
+
--- /dev/null
+// VISU OBJECT : interactive object for VISU entities implementation
+//
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+// File : VISUConfig.cc
+// Author : Alexey PETROV
+// Module : VISU
+
+#include "VISUConfig.hh"
+
+#include "SUIT_ResourceMgr.h"
+#include "SUIT_Session.h"
+
+#include <SALOMEDSClient_GenericAttribute.hxx>
+#include <SALOMEDSClient_AttributeIOR.hxx>
+
+#include <SalomeApp_Application.h>
+
+using namespace std;
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+namespace VISU{
+
+ SUIT_Session*
+ GetSession()
+ {
+ return SUIT_Session::session();
+ }
+
+ SUIT_ResourceMgr*
+ GetResourceMgr()
+ {
+ return GetSession()->resourceMgr();
+ }
+
+ //===========================================================================
+
+ QMutex* Base_i::myMutex = NULL; //apo - &VISUMutex;
+ CORBA::ORB_var Base_i::myOrb;
+ PortableServer::POA_var Base_i::myPoa;
+ SALOME_NamingService* Base_i::myNamingService;
+ SALOME_LifeCycleCORBA* Base_i::myEnginesLifeCycle;
+ VISU_Gen_i* Base_i::myVisuGenImpl;
+
+ Base_i::Base_i() {}
+
+ Base_i::~Base_i() {}
+
+ char* Base_i::GetID(){
+ if(myID == ""){
+ CORBA::Object_var anObject = _this();
+ CORBA::String_var anIOR = myOrb->object_to_string(anObject);
+ myID = anIOR.in();
+ }
+ return CORBA::string_dup(myID.c_str());
+ }
+
+ //===========================================================================
+ static int mySCnt = 0;
+ static QMutex aMutex(TRUE);
+
+ Mutex::Mutex(QMutex* theMutex): myMutex(&aMutex){
+ if(MYDEBUG) MESSAGE("Mutex::Mutex : "<<!mySCnt);
+ if(!mySCnt++)
+ myMutex->lock();
+ }
+
+ Mutex::~Mutex(){
+ if(!(--mySCnt))
+ myMutex->unlock();
+ if(MYDEBUG) MESSAGE("Mutex::~Mutex : "<<!mySCnt);
+ }
+
+
+ //===========================================================================
+ static Storable::TCallbackMap VisuStoreMap;
+ string Storable::ToString(){
+ ostringstream strOut;
+ Storable::DataToStream( strOut, "myComment", GetComment() );
+ ToStream(strOut);
+ strOut<<ends;
+ if(MYDEBUG) MESSAGE("Storable::ToString - "<<strOut.str());
+ return strOut.str();
+ }
+
+ void Storable::Registry(const char* theComment, TStorableEngine theEngine)
+ {
+ if(!VisuStoreMap.insert(TCallbackMap::value_type(theComment,theEngine)).second){
+ if(MYDEBUG) MESSAGE("Storable::Registry >> dupliacte registring !!!");
+ throw std::logic_error("Storable::Registry >> dupliacte registring !!!");
+ }
+ }
+
+ void Storable::StrToMap(const QString& theStr, VISU::Storable::TRestoringMap& theMap){
+ if(0 && MYDEBUG) MESSAGE("Storable::StrToMap : string="<<theStr);
+ QStringList strList = QStringList::split( ";", theStr, false );
+ for ( int i = 0; i < strList.count(); i++ ) {
+ QString next = strList[ i ];
+ int pos = next.find("=");
+ QString aName, aValue;
+ if ( pos < 0 ) {
+ aName = next.stripWhiteSpace();
+ aValue = "";
+ }
+ else {
+ aName = next.left( pos ).stripWhiteSpace();
+ aValue = next.mid( pos+1 );
+ if ( aValue.isNull() )
+ aValue = "";
+ }
+ if ( !aName.isEmpty() )
+ theMap.insert( TRestoringMap::value_type( aName.latin1(), aValue ) );
+ }
+ }
+
+ void Storable::DataToStream(ostringstream& theStr, const QString& theName, const QString& theVal) {
+ QString output = ( !theName.isNull() ? theName : QString("") )
+ + QString( "=" )
+ + ( !theVal.isNull() ? theVal : QString("") );
+ theStr<<output.latin1()<<";";
+ }
+
+ void Storable::DataToStream(ostringstream& theStr, const QString& theName, const int theVal) {
+ QString output = ( !theName.isNull() ? theName : QString("") )
+ + QString( "=" )
+ + QString::number( theVal );
+ theStr<<output.latin1()<<";";
+ }
+
+ void Storable::DataToStream(ostringstream& theStr, const QString& theName, const double theVal) {
+ QString output = ( !theName.isNull() ? theName : QString("") )
+ + QString( "=" )
+ + QString::number( theVal );
+ theStr<<output.latin1()<<";";
+ }
+ Storable* Storable::Create(SALOMEDS::SObject_ptr theSObject,
+ const string& thePrefix, const string& theLocalPersistentID)
+ {
+ try{
+ QString strIn( theLocalPersistentID.c_str() );
+ TRestoringMap aMap;
+ StrToMap(strIn,aMap);
+ bool isExist;
+ QString aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist);
+ if ( isExist ) {
+ TCallbackMap::const_iterator i = VisuStoreMap.find(aComment.latin1());
+ if(MYDEBUG) MESSAGE("Storable::Create - "<<aComment.latin1()<<" "<<(i != VisuStoreMap.end()));
+ if(i == VisuStoreMap.end()) return NULL;
+ return (i->second)(theSObject,thePrefix,aMap);
+ }
+ }catch(std::logic_error& exc){
+ INFOS("Follow exception was occured :\n"<<exc.what());
+ }catch(...){
+ INFOS("Unknown exception was occured!");
+ }
+ return NULL;
+ }
+
+ QString Storable::FindValue(const TRestoringMap& theMap, const string& theArg, bool* isFind)
+ {
+ TRestoringMap::const_iterator i = theMap.find(theArg);
+ if(i == theMap.end()) {
+ if(MYDEBUG) MESSAGE("Storable::Init >> there is no value for "<<theArg);
+ if(isFind != NULL) *isFind = false;
+ //throw std::logic_error(string("Storable::Init >> there is no value for ") + theArg);
+ static QString BAD_VALUE("NULL");
+ return BAD_VALUE;
+ }
+ if(isFind != NULL) *isFind = true;
+ return i->second;
+ }
+
+
+ //===========================================================================
+ PortableServer::ServantBase_var GetServant(CORBA::Object_ptr theObject){
+ if(CORBA::is_nil(theObject)) return NULL;
+ try{
+ PortableServer::POA_ptr aPOA = Base_i::GetPOA();
+ PortableServer::Servant aServant = aPOA->reference_to_servant(theObject);
+ return aServant;
+ } catch (...) {
+ INFOS("GetServant - Unknown exception was occured!!!");
+ return NULL;
+ }
+ }
+
+
+ //===========================================================================
+ CORBA::Object_var SObjectToObject(SALOMEDS::SObject_ptr theSObject){
+ SALOMEDS::GenericAttribute_var anAttr;
+ CORBA::Object_var anObj;
+ try{
+ if(theSObject->FindAttribute(anAttr, "AttributeIOR")){
+ SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ CORBA::String_var aValue = anIOR->Value();
+ CORBA::ORB_ptr anORB = Base_i::GetORB();
+ if(strcmp(aValue,"") != 0)
+ anObj = anORB->string_to_object(aValue);
+ }
+ }catch(...){
+ INFOS("SObjectToObject - Unknown exception was occured!!!");
+ }
+ return anObj;
+ }
+
+ //===========================================================================
+ CORBA::Object_var ClientSObjectToObject(_PTR(SObject) theSObject){
+ _PTR(GenericAttribute) anAttr;
+ CORBA::Object_var anObj;
+ try{
+ if(theSObject->FindAttribute(anAttr, "AttributeIOR")){
+ _PTR(AttributeIOR) anIOR = anAttr;
+ CORBA::String_var aValue = anIOR->Value().c_str();
+ CORBA::ORB_ptr anORB = Base_i::GetORB();
+ if(strcmp(aValue,"") != 0)
+ anObj = anORB->string_to_object(aValue);
+ }
+ }catch(...){
+ INFOS("ClientSObjectToObject - Unknown exception was occured!!!");
+ }
+ return anObj;
+ }
+
+
+ //===========================================================================
+ string FindEntryWithComment(SALOMEDS::Study_ptr theStudyDocument, const char* theStartEntry,
+ const char* theComment, int IsAllLevels)
+ {
+ SALOMEDS::ChildIterator_var anIter =
+ theStudyDocument->NewChildIterator(theStudyDocument->FindObjectID(theStartEntry));
+ anIter->InitEx(IsAllLevels);
+ SALOMEDS::SObject_var aFieldSO;
+ for(;anIter->More();anIter->Next()) {
+ SALOMEDS::GenericAttribute_var anAttr;
+ if (anIter->Value()->FindAttribute(anAttr,"AttributeComment")) {
+ SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
+ CORBA::String_var aString = aCmnt->Value();
+ string aValue(aString);
+ if (aValue == theComment) {
+ aFieldSO = anIter->Value();
+ aString = aFieldSO->GetID();
+ aValue = aString;
+ return aValue;
+ }
+ }
+ }
+ return "";
+ }
+ //===========================================================================
+ string CreateAttributes(SALOMEDS::Study_ptr theStudyDocument,
+ const char* theFatherEntry, const char* theRefFatherEntry,
+ const char* theIOR, const char* theName,
+ const char* thePersistentRef, const char* theComment,
+ CORBA::Boolean theCreateNew)
+ {
+ SALOMEDS::StudyBuilder_var aStudyBuilder = theStudyDocument->NewBuilder();
+ SALOMEDS::SObject_var aFather = theStudyDocument->FindObjectID(theFatherEntry);
+ SALOMEDS::SObject_var newObj;
+ if (theCreateNew) newObj = aStudyBuilder->NewObject(aFather);
+ else newObj = aFather;
+ SALOMEDS::GenericAttribute_var anAttr;
+ if(strcmp(theIOR,"") != 0){
+ anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
+ SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ anIOR->SetValue(theIOR);
+ }
+ if(strcmp(theName,"") != 0){
+ anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
+ SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ aName->SetValue(theName);
+ }
+ if(strcmp(thePersistentRef,"") != 0){
+ anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePersistentRef");
+ SALOMEDS::AttributePersistentRef_var aPRef = SALOMEDS::AttributePersistentRef::_narrow(anAttr);
+ aPRef->SetValue(thePersistentRef);
+ }
+ if(strcmp(theComment,"") != 0){
+ anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeComment");
+ SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
+ aCmnt->SetValue(theComment);
+ if(MYDEBUG) INFOS("CreateAttributes - Comment = "<<theComment);
+ }
+ if(strcmp(theRefFatherEntry,"") != 0){
+ SALOMEDS::SObject_var aRefFather = theStudyDocument->FindObjectID(theRefFatherEntry);
+ SALOMEDS::SObject_var anObj = aStudyBuilder->NewObject(aRefFather);
+ aStudyBuilder->Addreference(anObj,newObj);
+ }
+ CORBA::String_var anEntry = newObj->GetID();
+ string aRet(anEntry);
+ if(MYDEBUG)
+ INFOS("CreateAttributes - StudyId = "<<theStudyDocument->StudyId()<<"; anEntry = "<<aRet<<"; IOR = '"<<theIOR<<"'");
+ return aRet;
+ }
+ string CreateAttributes(_PTR(Study) theStudyDocument,
+ const char* theFatherEntry, const char* theRefFatherEntry,
+ const char* theIOR, const char* theName,
+ const char* thePersistentRef, const char* theComment,
+ CORBA::Boolean theCreateNew)
+ {
+ _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder();
+ _PTR(SObject) aFather = theStudyDocument->FindObjectID(theFatherEntry);
+ _PTR(SObject) newObj;
+ if (theCreateNew)
+ newObj = aStudyBuilder->NewObject(aFather);
+ else
+ newObj = aFather;
+
+ _PTR(GenericAttribute) anAttr;
+ if (strcmp(theIOR, "") != 0) {
+ anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
+ _PTR(AttributeIOR) anIOR (anAttr);
+ anIOR->SetValue(theIOR);
+ }
+ if (strcmp(theName, "") != 0) {
+ anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
+ _PTR(AttributeName) aName (anAttr);
+ aName->SetValue(theName);
+ }
+ if (strcmp(thePersistentRef, "") != 0) {
+ anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePersistentRef");
+ _PTR(AttributePersistentRef) aPRef (anAttr);
+ aPRef->SetValue(thePersistentRef);
+ }
+ if (strcmp(theComment, "") != 0) {
+ anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeComment");
+ _PTR(AttributeComment) aCmnt (anAttr);
+ aCmnt->SetValue(theComment);
+ if (MYDEBUG) INFOS("CreateAttributes - Comment = " << theComment);
+ }
+ if (strcmp(theRefFatherEntry, "") != 0) {
+ _PTR(SObject) aRefFather = theStudyDocument->FindObjectID(theRefFatherEntry);
+ _PTR(SObject) anObj = aStudyBuilder->NewObject(aRefFather);
+ aStudyBuilder->Addreference(anObj, newObj);
+ }
+ string aRet = newObj->GetID();
+ if (MYDEBUG)
+ INFOS("CreateAttributes - StudyId = " << theStudyDocument->StudyId()
+ << "; anEntry = " << aRet << "; IOR = '" << theIOR << "'");
+ return aRet;
+ }
+
+ QString GenerateName(const string& theFmt, int theId){
+ static QString aName;
+ if(theId > 0)
+ aName.sprintf("%s:%d",theFmt.c_str(),theId);
+ else
+ aName.sprintf("%s",theFmt.c_str());
+ return aName;
+ }
+
+
+ SALOMEDS::StudyManager_var GetStudyManager()
+ {
+ static SALOMEDS::StudyManager_var aStudyManager;
+ if(CORBA::is_nil(aStudyManager)){
+ SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
+ CORBA::Object_var anObject = aNamingService->Resolve("/myStudyManager");
+ aStudyManager = SALOMEDS::StudyManager::_narrow(anObject);
+ }
+ return aStudyManager;
+ }
+
+
+ SALOMEDS::Study_var GetDSStudy(_PTR(Study) theStudy)
+ {
+ //std::string aStudyName = theStudy->Name();
+ //return GetStudyManager()->GetStudyByName(aStudyName.c_str());
+ int aStudyID = theStudy->StudyId();
+ return GetStudyManager()->GetStudyByID(aStudyID);
+ }
+
+ SALOMEDS::SObject_var GetSObject( _PTR(SObject) obj )
+ {
+ _PTR(Study) aStudy = obj->GetStudy();
+ SALOMEDS::Study_var aSalomeDSStudy = GetDSStudy( aStudy );
+ std::string id = obj->GetID();
+ return aSalomeDSStudy->FindObjectID( id.c_str() );
+ }
+
+ _PTR(SObject) GetClientSObject( SALOMEDS::SObject_var obj,
+ _PTR(Study) study )
+ {
+ return study->FindObjectID( obj->GetID() );
+
+ }
+
+
+ void RemoveFromStudy (SALOMEDS::SObject_ptr theSObject,
+ bool theIsAttrOnly,
+ bool theDestroySubObjects)
+ {
+ if (theSObject->_is_nil()) return;
+
+ SALOMEDS::Study_var aStudyDocument = theSObject->GetStudy();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudyDocument->NewBuilder();
+ if (theIsAttrOnly) {
+ aStudyBuilder->RemoveAttribute(theSObject,"AttributeIOR");
+ return;
+ }
+
+ // Remove possible sub-objects
+ SALOMEDS::ChildIterator_var aChildIter = aStudyDocument->NewChildIterator(theSObject);
+ for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
+ SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
+ CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
+ if (CORBA::is_nil(aChildObj)) continue;
+
+ VISU::RemovableObject_var aRemovableObject = VISU::RemovableObject::_narrow(aChildObj);
+ if (CORBA::is_nil(aRemovableObject)) continue;
+
+ aRemovableObject->RemoveFromStudy();
+
+ // Destroy
+ if (theDestroySubObjects) {
+ VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aRemovableObject);
+ if (CORBA::is_nil(aPrs3d)) continue;
+ aPrs3d->Destroy();
+ }
+ }
+
+ // asl, fix for PAL10455: Remove references to SObject
+ SALOMEDS::Study::ListOfSObject* aRefs = aStudyDocument->FindDependances( theSObject );
+ for( int i=0, n=aRefs->length(); i<n; i++ )
+ {
+ SALOMEDS::SObject_var o = (*aRefs)[i];
+ if( o->GetFatherComponent()->ComponentDataType()==theSObject->GetFatherComponent()->ComponentDataType() )
+ {
+ aStudyBuilder->RemoveReference( o );
+ aStudyBuilder->RemoveObjectWithChildren( o );
+ }
+ }
+
+ // Remove the SObject itself
+ aStudyBuilder->RemoveObjectWithChildren(theSObject);
+ }
+
+ void RemoveFromStudy (_PTR(SObject) theSObject,
+ bool theIsAttrOnly,
+ bool theDestroySubObjects)
+ {
+ if (!theSObject) return;
+
+ _PTR(Study) aStudyDocument = theSObject->GetStudy();
+ _PTR(StudyBuilder) aStudyBuilder = aStudyDocument->NewBuilder();
+ if (theIsAttrOnly) {
+ aStudyBuilder->RemoveAttribute(theSObject,"AttributeIOR");
+ return;
+ }
+
+ // Remove possible sub-objects
+ _PTR(ChildIterator) aChildIter = aStudyDocument->NewChildIterator(theSObject);
+ for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
+ _PTR(SObject) aChildSObject = aChildIter->Value();
+ CORBA::Object_var aChildObj = VISU::ClientSObjectToObject(aChildSObject);
+ if (CORBA::is_nil(aChildObj)) continue;
+
+ VISU::RemovableObject_var aRemovableObject = VISU::RemovableObject::_narrow(aChildObj);
+ if (CORBA::is_nil(aRemovableObject)) continue;
+
+ aRemovableObject->RemoveFromStudy();
+
+ // Destroy
+ if (theDestroySubObjects) {
+ VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aRemovableObject);
+ if (CORBA::is_nil(aPrs3d)) continue;
+ aPrs3d->Destroy();
+ }
+ }
+
+ // Remove the SObject itself
+ aStudyBuilder->RemoveObjectWithChildren(theSObject);
+ }
+}
--- /dev/null
+// VISU OBJECT : interactive object for VISU entities implementation
+//
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+// File : VISU_DumpPython.cc
+// Author : Alexey PETROV
+// Module : VISU
+
+#include "VISU_Gen_i.hh"
+#include "VISU_Result_i.hh"
+#include "VISU_PrsObject_i.hh"
+
+#include "VISU_Prs3d_i.hh"
+#include "VISU_Mesh_i.hh"
+#include "VISU_ScalarMap_i.hh"
+#include "VISU_IsoSurfaces_i.hh"
+#include "VISU_DeformedShape_i.hh"
+#include "VISU_CutPlanes_i.hh"
+#include "VISU_CutLines_i.hh"
+#include "VISU_Vectors_i.hh"
+#include "VISU_StreamLines_i.hh"
+#include "VISU_Plot3D_i.hh"
+#include "VISU_Table_i.hh"
+
+#include "utilities.h"
+
+#include <cctype>
+#include <strstream>
+#include <functional>
+
+#include <qstring.h>
+#include <qfileinfo.h>
+
+//#define COUT
+
+using namespace std;
+
+namespace VISU{
+ static std::string PREFIX(" ");
+
+ typedef std::map<std::string,std::string> TName2EntryMap;
+ typedef std::map<std::string,std::string> TEntry2NameMap;
+
+ inline
+ std::string
+ GenerateName(std::string theName,
+ SALOMEDS::SObject_ptr theSObject,
+ TName2EntryMap& theName2EntryMap,
+ TEntry2NameMap& theEntry2NameMap,
+ char theSuffix)
+ {
+ if(theName2EntryMap.find(theName) != theName2EntryMap.end()){
+ theName = GenerateName(theName + theSuffix, theSObject, theName2EntryMap, theEntry2NameMap, theSuffix);
+ }else{
+ CORBA::String_var anID = theSObject->GetID();
+ theName2EntryMap[theName] = anID.in();
+ theEntry2NameMap[anID.in()] = theName;
+ //cout<<"GenerateName - "<<theName<<" => "<<anID.in()<<endl;
+ }
+
+ return theName;
+ }
+
+ struct TReplacePredicate{
+ bool operator()(char theChar) const
+ {
+ return !(isdigit(theChar) || isalpha(theChar) || theChar == '_');
+ }
+ };
+
+ inline
+ std::string
+ GetName(SALOMEDS::SObject_ptr theSObject)
+ {
+ CORBA::String_var aString = theSObject->GetName();
+
+ std::string aName = QString(aString.in()).simplifyWhiteSpace().latin1();
+
+ //replace_if(aName.begin(),aName.end(),not1(ptr_fun(isxdigit)),'_');
+ replace_if(aName.begin(),aName.end(),TReplacePredicate(),'_');
+
+ if ( isdigit( aName[0] ))
+ aName.insert( 0, 1, 'a' );
+
+ return aName;
+ }
+
+ inline
+ std::string
+ GenerateName(SALOMEDS::SObject_ptr theSObject,
+ TName2EntryMap& theName2EntryMap,
+ TEntry2NameMap& theEntry2NameMap)
+ {
+ std::string aName = GetName(theSObject);
+
+ return GenerateName(aName,theSObject,theName2EntryMap,theEntry2NameMap,'X');
+ }
+
+
+ //===========================================================================
+ typedef void (*TDumpToPython)(SALOMEDS::Study_ptr theStudy,
+ CORBA::Boolean theIsPublished,
+ CORBA::Boolean& theIsValidScript,
+ SALOMEDS::SObject_ptr theSObject,
+ std::ostream& theStr,
+ TName2EntryMap& theName2EntryMap,
+ TEntry2NameMap& theEntry2NameMap,
+ std::string theArgumentName,
+ std::string thePrefix);
+
+
+ void
+ DumpToPython(SALOMEDS::Study_ptr theStudy,
+ CORBA::Boolean theIsPublished,
+ CORBA::Boolean& theIsValidScript,
+ SALOMEDS::SObject_ptr theSObject,
+ std::ostream& theStr,
+ TName2EntryMap& theName2EntryMap,
+ TEntry2NameMap& theEntry2NameMap,
+ std::string theArgumentName,
+ std::string thePrefix);
+
+
+ //===========================================================================
+ std::string
+ ScalarMapToPython(SALOMEDS::SObject_ptr theSObject,
+ VISU::ScalarMap_i* theServant,
+ std::ostream& theStr,
+ std::string& theName,
+ const std::string& theConstructorName,
+ const std::string& theArgumentName,
+ std::string thePrefix)
+ {
+ std::string aParam;
+ switch(theServant->GetEntity()){
+ case NODE:
+ aParam = "VISU.NODE";
+ break;
+ case EDGE:
+ aParam = "VISU.EDGE";
+ break;
+ case FACE:
+ aParam = "VISU.FACE";
+ break;
+ case CELL:
+ aParam = "VISU.CELL";
+ break;
+ }
+
+ theStr<<thePrefix<<theName<<" = aVisu."<<theConstructorName<<"("<<theArgumentName<<
+ ",'"<<theServant->GetMeshName()<<"'"<<
+ ","<<aParam<<
+ ",'"<<theServant->GetFieldName()<<"'"<<
+ ","<<theServant->GetIteration()<<
+ ")"<<endl;
+
+ theStr<<thePrefix<<"if "<<theName<<":"<<endl;
+ thePrefix += PREFIX;
+
+ theStr<<thePrefix<<"aName2ObjectMap['"<<theName<<"'] = "<<theName<<endl;
+
+ theStr<<thePrefix<<theName<<".SetScalarMode("<<theServant->GetScalarMode()<<")"<<endl;
+
+ switch(theServant->GetScaling()){
+ case LINEAR:
+ aParam = "VISU.LINEAR";
+ break;
+ case LOGARITHMIC:
+ aParam = "VISU.LOGARITHMIC";
+ break;
+ }
+ theStr<<thePrefix<<theName<<".SetScaling("<<aParam<<")"<<endl;
+ theStr<<thePrefix<<theName<<".SetRange("<<theServant->GetMin()<<","<<theServant->GetMax()<<")"<<endl;
+
+ switch(theServant->GetBarOrientation()){
+ case ScalarMap::HORIZONTAL:
+ aParam = "VISU.ScalarMap.HORIZONTAL";
+ break;
+ case ScalarMap::VERTICAL:
+ aParam = "VISU.ScalarMap.VERTICAL";
+ break;
+ }
+ theStr<<thePrefix<<theName<<".SetBarOrientation("<<aParam<<")"<<endl;
+
+ theStr<<thePrefix<<theName<<".SetPosition("<<theServant->GetPosX()<<","<<theServant->GetPosY()<<")"<<endl;
+ theStr<<thePrefix<<theName<<".SetSize("<<theServant->GetWidth()<<","<<theServant->GetHeight()<<")"<<endl;
+ theStr<<thePrefix<<theName<<".SetNbColors("<<theServant->GetNbColors()<<")"<<endl;
+ theStr<<thePrefix<<theName<<".SetLabels("<<theServant->GetLabels()<<")"<<endl;
+ theStr<<thePrefix<<theName<<".SetTitle('"<<theServant->GetTitle()<<"')"<<endl;
+
+ return thePrefix;
+ }
+
+
+ //===========================================================================
+ std::string
+ DeformedShapeToPython(SALOMEDS::SObject_ptr theSObject,
+ VISU::DeformedShape_i* theServant,
+ std::ostream& theStr,
+ std::string& theName,
+ const std::string& theConstructorName,
+ const std::string& theArgumentName,
+ std::string thePrefix)
+ {
+ thePrefix = ScalarMapToPython(theSObject,theServant,theStr,theName,theConstructorName,theArgumentName,thePrefix);
+ theStr<<thePrefix<<theName<<".SetScale("<<theServant->GetScale()<<")"<<endl;
+ theStr<<thePrefix<<theName<<".ShowColored("<<theServant->IsColored()<<")"<<endl;
+ SALOMEDS::Color aColor = theServant->GetColor();
+ theStr<<thePrefix<<theName<<".SetColor(SALOMEDS.Color("<<
+ aColor.R<<","<<aColor.G<<","<<aColor.B<<"))"<<endl;
+
+ return thePrefix;
+ }
+
+ //===========================================================================
+ // declaration
+ void DumpChildrenToPython(SALOMEDS::Study_ptr theStudy,
+ CORBA::Boolean theIsPublished,
+ CORBA::Boolean& theIsValidScript,
+ SALOMEDS::SObject_ptr theSObject,
+ std::ostream& theStr,
+ TName2EntryMap& theName2EntryMap,
+ TEntry2NameMap& theEntry2NameMap,
+ std::string theArgumentName,
+ std::string thePrefix);
+
+ //===========================================================================
+ template<class TTableAttr>
+ void
+ TableAttrToPython(SALOMEDS::Study_ptr theStudy,
+ CORBA::Boolean theIsPublished,
+ CORBA::Boolean& theIsValidScript,
+ SALOMEDS::SObject_ptr theSObject,
+ TTableAttr theTableAttr,
+ const std::string& theAttrName,
+ std::ostream& theStr,
+ TName2EntryMap& theName2EntryMap,
+ TEntry2NameMap& theEntry2NameMap,
+ std::string theArgumentName,
+ std::string thePrefix)
+ {
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::SObject_var aFatherSObject = theSObject->GetFather();
+ if(aFatherSObject->FindAttribute(anAttr,"AttributeComment")){
+ SALOMEDS::AttributeComment_var aComment =
+ SALOMEDS::AttributeComment::_narrow(anAttr);
+ CORBA::String_var aValue = aComment->Value();
+ Storable::TRestoringMap aMap;
+ Storable::StrToMap(aValue.in(),aMap);
+ bool anIsExist;
+ QString aMethodName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist);
+ if(anIsExist){
+ if(strcmp(aMethodName.latin1(),"ImportTables") == 0){
+ return;
+ }
+ }
+ }
+
+ std::string aSObjectName = GetName(theSObject);
+ theStr<<thePrefix<<aSObjectName<<" = aBuilder.NewObject(aSComponent)"<<endl;
+ theStr<<thePrefix<<"if "<<aSObjectName<<":"<<endl;
+ thePrefix += PREFIX;
+
+ std::string aName = "aTableAttr";
+ theStr<<thePrefix<<aName<<" = aBuilder.FindOrCreateAttribute("<<
+ aSObjectName<<",'"<<theAttrName<<"')"<<endl;
+
+ theStr<<thePrefix<<"if "<<aName<<":"<<endl;
+ std::string aPrefix = thePrefix;
+ thePrefix += PREFIX;
+
+ CORBA::String_var aString = theTableAttr->GetTitle();
+ theStr<<thePrefix<<aName<<".SetTitle('"<<aString.in()<<"')"<<endl;
+
+ CORBA::Long aNbColumns = theTableAttr->GetNbColumns();
+ theStr<<thePrefix<<aName<<".SetNbColumns("<<aNbColumns<<")"<<endl;
+
+ CORBA::Long aNbRows = theTableAttr->GetNbRows();
+
+ // push values and their indices into streams
+ strstream values, rows, columns;
+ string comma = "";
+ for(CORBA::Long i = 1; i <= aNbColumns; i++){
+ for(CORBA::Long j = aNbRows; j > 0; j--){
+ if(theTableAttr->HasValue(j,i)){
+ values << comma << theTableAttr->GetValue(j,i);
+ rows << comma << j;
+ columns << comma << i;
+ if ( comma.empty() )
+ comma = ",";
+ }
+ }
+ }
+ // push titles and units into streams
+ strstream rowUnits, rowTitles, colTitles;
+ SALOMEDS::StringSeq_var aRowUnits = theTableAttr->GetRowUnits();
+ SALOMEDS::StringSeq_var aRowTitles = theTableAttr->GetRowTitles();
+ comma = "";
+ for(CORBA::Long j = 1; j <= aNbRows; j++){
+ rowUnits << comma << "'" << aRowUnits [ j - 1 ] << "'";
+ rowTitles << comma << "'" << aRowTitles[ j - 1 ] << "'";
+ if ( comma.empty() )
+ comma = ",";
+ }
+ SALOMEDS::StringSeq_var aColumnTitles = theTableAttr->GetColumnTitles();
+ comma = "";
+ for(CORBA::Long j = 1; j <= aNbColumns; j++){
+ colTitles << comma << "'" << aColumnTitles[ j - 1 ] << "'";
+ if ( comma.empty() )
+ comma = ",";
+ }
+ values << '\0';
+ rows << '\0';
+ columns << '\0';
+ rowUnits << '\0';
+ rowTitles << '\0';
+ colTitles << '\0';
+ // write FillTable command
+ theStr<< thePrefix << aName << "_values = [" << values.str() << "]" << endl;
+ theStr<< thePrefix << aName << "_rows = [" << rows.str() << "]" << endl;
+ theStr<< thePrefix << aName << "_columns = [" << columns.str() << "]" << endl;
+ theStr<< thePrefix << aName << "_rUnits = [" << rowUnits.str() << "]" << endl;
+ theStr<< thePrefix << aName << "_rTitles = [" << rowTitles.str() << "]" << endl;
+ theStr<< thePrefix << aName << "_cTitles = [" << colTitles.str() << "]" << endl;
+ theStr<< thePrefix << "visu.FillTable( "
+ << aName << ", "
+ << aName << "_values, "
+ << aName << "_rows, "
+ << aName << "_columns, "
+ << aName << "_rTitles, "
+ << aName << "_rUnits, "
+ << aName << "_cTitles )" << endl;
+
+ if(theSObject->FindAttribute(anAttr,"AttributeIOR")){
+ theStr<<endl;
+ std::string aName = "aTable";
+ theStr<<thePrefix<<"anID = "<<aSObjectName<<".GetID()"<<endl;
+ theStr<<thePrefix<<aName<<" = aVisu.CreateTable(anID)"<<endl;
+ theArgumentName = aName;
+
+ theStr<<thePrefix<<"if "<<aName<<":"<<endl;
+ std::string aPrefix2 = thePrefix + PREFIX;
+
+ DumpChildrenToPython(theStudy,
+ theIsPublished,
+ theIsValidScript,
+ theSObject,
+ theStr,
+ theName2EntryMap,
+ theEntry2NameMap,
+ theArgumentName,
+ aPrefix2);
+
+ theStr<<aPrefix2<<"pass"<<endl<<endl;
+ }
+
+ theStr<<thePrefix<<"pass"<<endl<<endl;
+ theStr<<aPrefix<<"pass"<<endl<<endl;
+ }
+
+
+ //===========================================================================
+ void
+ DumpChildrenToPython(SALOMEDS::Study_ptr theStudy,
+ CORBA::Boolean theIsPublished,
+ CORBA::Boolean& theIsValidScript,
+ SALOMEDS::SObject_ptr theSObject,
+ std::ostream& theStr,
+ TName2EntryMap& theName2EntryMap,
+ TEntry2NameMap& theEntry2NameMap,
+ std::string theArgumentName,
+ std::string thePrefix)
+ {
+ SALOMEDS::ChildIterator_var aChildItet = theStudy->NewChildIterator(theSObject);
+ for(aChildItet->InitEx(false); aChildItet->More(); aChildItet->Next()){
+ SALOMEDS::SObject_var aSObject = aChildItet->Value();
+ DumpToPython(theStudy,
+ theIsPublished,
+ theIsValidScript,
+ aSObject,
+ theStr,
+ theName2EntryMap,
+ theEntry2NameMap,
+ theArgumentName,
+ thePrefix);
+ }
+ }
+
+
+ //===========================================================================
+ void
+ DumpTableAttrToPython(SALOMEDS::Study_ptr theStudy,
+ CORBA::Boolean theIsPublished,
+ CORBA::Boolean& theIsValidScript,
+ SALOMEDS::SObject_ptr theSObject,
+ std::ostream& theStr,
+ TName2EntryMap& theName2EntryMap,
+ TEntry2NameMap& theEntry2NameMap,
+ std::string theArgumentName,
+ std::string thePrefix)
+ {
+ SALOMEDS::GenericAttribute_var anAttr;
+ if(theSObject->FindAttribute(anAttr,"AttributeTableOfInteger")){
+ SALOMEDS::AttributeTableOfInteger_var aTableAttr =
+ SALOMEDS::AttributeTableOfInteger::_narrow(anAttr);
+
+ TableAttrToPython(theStudy,
+ theIsPublished,
+ theIsValidScript,
+ theSObject,
+ aTableAttr,
+ "AttributeTableOfInteger",
+ theStr,
+ theName2EntryMap,
+ theEntry2NameMap,
+ theArgumentName,
+ thePrefix);
+
+ }else if(theSObject->FindAttribute(anAttr,"AttributeTableOfReal")){
+ SALOMEDS::AttributeTableOfReal_var aTableAttr =
+ SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
+
+ TableAttrToPython(theStudy,
+ theIsPublished,
+ theIsValidScript,
+ theSObject,
+ aTableAttr,
+ "AttributeTableOfReal",
+ theStr,
+ theName2EntryMap,
+ theEntry2NameMap,
+ theArgumentName,
+ thePrefix);
+ }
+ }
+
+
+ //===========================================================================
+ void
+ DumpToPython(SALOMEDS::Study_ptr theStudy,
+ CORBA::Boolean theIsPublished,
+ CORBA::Boolean& theIsValidScript,
+ SALOMEDS::SObject_ptr theSObject,
+ std::ostream& theStr,
+ TName2EntryMap& theName2EntryMap,
+ TEntry2NameMap& theEntry2NameMap,
+ std::string theArgumentName,
+ std::string thePrefix)
+ {
+ std::string aName = GetName(theSObject);
+ if(aName == "")
+ return;
+
+ CORBA::Object_var anObj = SObjectToObject(theSObject);
+ if(!CORBA::is_nil(anObj)){
+ VISU::Base_var aBase = VISU::Base::_narrow(anObj);
+ if(!CORBA::is_nil(aBase)){
+ std::string aName = GenerateName(theSObject,theName2EntryMap,theEntry2NameMap);
+ CORBA::String_var anID = theSObject->GetID();
+
+ VISU::VISUType aType = aBase->GetType();
+ switch(aType){
+ case VISU::TRESULT:
+ if(Result_i* aServant = dynamic_cast<Result_i*>(GetServant(anObj).in())){
+ std::string aFileName = aServant->GetFileName();
+ Result_i::ECreationId anId = aServant->GetCreationId();
+ if(anId == Result_i::eImportFile || anId == Result_i::eCopyAndImportFile){
+ switch(anId){
+ case Result_i::eImportFile:
+ theStr<<thePrefix<<aName<<" = aVisu.ImportFile('"<<aFileName<<"')"<<endl;
+ break;
+ case Result_i::eCopyAndImportFile:
+ theStr<<thePrefix<<aName<<" = aVisu.CopyAndImportFile('"<<aFileName<<"')"<<endl;
+ break;
+ }
+
+ theStr<<thePrefix<<"if "<<aName<<":"<<endl;
+ thePrefix += PREFIX;
+
+ theArgumentName = aName;
+ DumpChildrenToPython(theStudy,
+ theIsPublished,
+ theIsValidScript,
+ theSObject,
+ theStr,
+ theName2EntryMap,
+ theEntry2NameMap,
+ theArgumentName,
+ thePrefix);
+
+ theStr<<thePrefix<<"pass"<<endl<<endl;
+ }else{
+ SALOMEDS::SObject_var aRefSObj;
+ if(theSObject->FindSubObject(1,aRefSObj)){
+ SALOMEDS::SObject_var aTargetRefSObj;
+ if(aRefSObj->ReferencedObject(aTargetRefSObj)){
+ CORBA::String_var aString = aTargetRefSObj->GetName();
+ theStr<<thePrefix<<"aSObject = theStudy.FindObject('"<<aString.in()<<"')"<<endl;
+ theStr<<thePrefix<<"if aSObject:"<<endl;
+ thePrefix += PREFIX;
+ theStr<<thePrefix<<"anObject = aSObject.GetObject()"<<endl;
+ theStr<<thePrefix<<"if anObject:"<<endl;
+ std::string aPrefix1 = thePrefix;
+ thePrefix += PREFIX;
+
+ switch(anId){
+ case Result_i::eImportMed:
+ theStr<<thePrefix<<aName<<" = aVisu.ImportMed(aSObject)"<<endl;
+ break;
+ case Result_i::eImportMedField:
+ theStr<<thePrefix<<aName<<" = aVisu.ImportMedField(anObject)"<<endl;
+ break;
+ }
+
+ theStr<<thePrefix<<"if "<<aName<<":"<<endl;
+ std::string aPrefix2 = thePrefix;
+ thePrefix += PREFIX;
+
+ theArgumentName = aName;
+ DumpChildrenToPython(theStudy,
+ theIsPublished,
+ theIsValidScript,
+ theSObject,
+ theStr,
+ theName2EntryMap,
+ theEntry2NameMap,
+ theArgumentName,
+ thePrefix);
+
+ theStr<<thePrefix<<"pass"<<endl<<endl;
+ theStr<<aPrefix2<<"pass"<<endl<<endl;
+ theStr<<aPrefix1<<"pass"<<endl<<endl;
+ }
+ }
+ }
+ }
+ return;
+ case VISU::TMESH:
+ if(Mesh_i* aServant = dynamic_cast<Mesh_i*>(GetServant(anObj).in())){
+ VISU::Entity anEntity = aServant->GetEntity();
+ const std::string& aSubMeshName = aServant->GetSubMeshName();
+ if(anEntity >= 0){
+ std::string aParam;
+ switch(anEntity){
+ case NODE:
+ aParam = "VISU.NODE";
+ break;
+ case EDGE:
+ aParam = "VISU.EDGE";
+ break;
+ case FACE:
+ aParam = "VISU.FACE";
+ break;
+ case CELL:
+ aParam = "VISU.CELL";
+ break;
+ }
+
+ if(aSubMeshName == "")
+ theStr<<thePrefix<<aName<<" = aVisu.MeshOnEntity("<<theArgumentName<<
+ ",'"<<aServant->GetMeshName()<<"'"<<
+ ","<<aParam<<
+ ")"<<endl;
+ else
+ theStr<<thePrefix<<aName<<" = aVisu.FamilyMeshOnEntity("<<theArgumentName<<
+ ",'"<<aServant->GetMeshName()<<"'"<<
+ ","<<aParam<<
+ ",'"<<aSubMeshName<<"'"<<
+ ")"<<endl;
+ }else
+ theStr<<thePrefix<<aName<<" = aVisu.GroupMesh("<<theArgumentName<<
+ ",'"<<aServant->GetMeshName()<<"'"<<
+ ",'"<<aSubMeshName<<"'"<<
+ ")"<<endl;
+
+ theStr<<thePrefix<<"if "<<aName<<":"<<endl;
+ thePrefix += PREFIX;
+
+ theStr<<thePrefix<<"aName2ObjectMap['"<<aName<<"'] = "<<aName<<endl;
+
+ SALOMEDS::Color aColor;
+ aColor = aServant->GetCellColor();
+ theStr<<thePrefix<<aName<<".SetCellColor(SALOMEDS.Color("<<
+ aColor.R<<","<<aColor.G<<","<<aColor.B<<"))"<<endl;
+
+ aColor = aServant->GetNodeColor();
+ theStr<<thePrefix<<aName<<".SetNodeColor(SALOMEDS.Color("<<
+ aColor.R<<","<<aColor.G<<","<<aColor.B<<"))"<<endl;
+
+ aColor = aServant->GetLinkColor();
+ theStr<<thePrefix<<aName<<".SetLinkColor(SALOMEDS.Color("<<
+ aColor.R<<","<<aColor.G<<","<<aColor.B<<"))"<<endl;
+
+ std::string aParam;
+ switch(aServant->GetPresentationType()){
+ case POINT:
+ aParam = "VISU.POINT";
+ break;
+ case WIREFRAME:
+ aParam = "VISU.WIREFRAME";
+ break;
+ case SHADED:
+ aParam = "VISU.SHADED";
+ break;
+ case INSIDEFRAME:
+ aParam = "VISU.INSIDEFRAME";
+ break;
+ case SURFACEFRAME:
+ aParam = "VISU.SURFACEFRAME";
+ break;
+ case SHRINK:
+ aParam = "VISU.SHRINK";
+ break;
+ }
+ theStr<<thePrefix<<aName<<".SetPresentationType("<<aParam<<")"<<endl;
+ theStr<<endl;
+
+ DumpChildrenToPython(theStudy,
+ theIsPublished,
+ theIsValidScript,
+ theSObject,
+ theStr,
+ theName2EntryMap,
+ theEntry2NameMap,
+ theArgumentName,
+ thePrefix);
+
+ theStr<<thePrefix<<"pass"<<endl<<endl;
+ return;
+ }
+ break;
+ case VISU::TSCALARMAP:
+ if(ScalarMap_i* aServant = dynamic_cast<ScalarMap_i*>(GetServant(anObj).in())){
+ thePrefix = ScalarMapToPython(theSObject,aServant,theStr,aName,"ScalarMapOnField",theArgumentName,thePrefix);
+ theStr<<thePrefix<<"pass"<<endl<<endl;
+ }
+ return;
+ case VISU::TDEFORMEDSHAPE:
+ if(DeformedShape_i* aServant = dynamic_cast<DeformedShape_i*>(GetServant(anObj).in())){
+ thePrefix = DeformedShapeToPython(theSObject,aServant,theStr,aName,"DeformedShapeOnField",theArgumentName,thePrefix);
+ theStr<<thePrefix<<"pass"<<endl<<endl;
+ }
+ return;
+ case VISU::TSTREAMLINES:
+ if(StreamLines_i* aServant = dynamic_cast<StreamLines_i*>(GetServant(anObj).in())){
+ thePrefix = DeformedShapeToPython(theSObject,aServant,theStr,aName,"StreamLinesOnField",theArgumentName,thePrefix);
+
+ std::string aParam;
+ switch(aServant->GetDirection()){
+ case StreamLines::FORWARD:
+ aParam = "VISU.StreamLines.FORWARD";
+ break;
+ case StreamLines::BACKWARD:
+ aParam = "VISU.StreamLines.BACKWARD";
+ break;
+ case StreamLines::BOTH:
+ aParam = "VISU.StreamLines.BOTH";
+ break;
+ }
+
+ theStr<<thePrefix<<"aPrs3d = None"<<endl;
+ VISU::Prs3d_var aPrs3d = aServant->GetSource();
+ if(!CORBA::is_nil(aPrs3d)){
+ if(Prs3d_i* aServant3d = dynamic_cast<Prs3d_i*>(GetServant(aPrs3d).in())){
+ SALOMEDS::SObject_var aSObject = aServant3d->GetSObject();
+ CORBA::String_var anID = aSObject->GetID();
+ std::string anArg = theEntry2NameMap[anID.in()];
+ theStr<<thePrefix<<"if aName2ObjectMap.has_key('"<<anArg<<"'):"<<endl;
+ thePrefix += PREFIX;
+ theStr<<thePrefix<<"aPrs3d = aName2ObjectMap['"<<anArg<<"']"<<endl;
+ }
+ }
+
+ theStr<<thePrefix<<aName<<".SetParams("<<
+ aServant->GetIntegrationStep()<<","<<
+ aServant->GetPropagationTime()<<","<<
+ aServant->GetStepLength()<<","<<
+ "aPrs3d"<<","<<
+ aServant->GetUsedPoints()<<","<<
+ aParam<<
+ ")"<<endl;
+
+ theStr<<thePrefix<<"pass"<<endl<<endl;
+ }
+ return;
+ case VISU::TVECTORS:
+ if(Vectors_i* aServant = dynamic_cast<Vectors_i*>(GetServant(anObj).in())){
+ thePrefix = DeformedShapeToPython(theSObject,aServant,theStr,aName,"VectorsOnField",theArgumentName,thePrefix);
+
+ theStr<<thePrefix<<aName<<".SetLineWidth("<<aServant->GetLineWidth()<<")"<<endl;
+
+ std::string aParam;
+ switch(aServant->GetGlyphType()){
+ case Vectors::ARROW:
+ aParam = "VISU.Vectors.ARROW";
+ break;
+ case Vectors::CONE2:
+ aParam = "VISU.Vectors.CONE2";
+ break;
+ case Vectors::CONE6:
+ aParam = "VISU.Vectors.CONE6";
+ break;
+ case Vectors::NONE:
+ aParam = "VISU.Vectors.NONE";
+ break;
+ }
+ theStr<<thePrefix<<aName<<".SetGlyphType("<<aParam<<")"<<endl;
+
+ switch(aServant->GetGlyphPos()){
+ case Vectors::CENTER:
+ aParam = "VISU.Vectors.CENTER";
+ break;
+ case Vectors::TAIL:
+ aParam = "VISU.Vectors.TAIL";
+ break;
+ case Vectors::HEAD:
+ aParam = "VISU.Vectors.HEAD";
+ break;
+ }
+ theStr<<thePrefix<<aName<<".SetGlyphPos("<<aParam<<")"<<endl;
+
+ theStr<<thePrefix<<"pass"<<endl<<endl;
+ }
+ return;
+ case VISU::TISOSURFACE:
+ if(IsoSurfaces_i* aServant = dynamic_cast<IsoSurfaces_i*>(GetServant(anObj).in())){
+ thePrefix = ScalarMapToPython(theSObject,aServant,theStr,aName,"IsoSurfacesOnField",theArgumentName,thePrefix);
+ theStr<<thePrefix<<aName<<".SetNbSurfaces("<<aServant->GetNbSurfaces()<<")"<<endl;
+ theStr<<thePrefix<<"pass"<<endl<<endl;
+ }
+ return;
+ case VISU::TCUTPLANES:
+ if(CutPlanes_i* aServant = dynamic_cast<CutPlanes_i*>(GetServant(anObj).in())){
+ thePrefix = ScalarMapToPython(theSObject,aServant,theStr,aName,"CutPlanesOnField",theArgumentName,thePrefix);
+
+ std::string aParam;
+ switch(aServant->GetOrientationType()){
+ case CutPlanes::XY:
+ aParam = "VISU.CutPlanes.XY";
+ break;
+ case CutPlanes::YZ:
+ aParam = "VISU.CutPlanes.YZ";
+ break;
+ case CutPlanes::ZX:
+ aParam = "VISU.CutPlanes.ZX";
+ break;
+ }
+ theStr<<thePrefix<<aName<<".SetOrientation("<<aParam<<","<<aServant->GetRotateX()<<","<<aServant->GetRotateY()<<")"<<endl;
+
+ theStr<<thePrefix<<aName<<".SetDisplacement("<<aServant->GetDisplacement()<<")"<<endl;
+ CORBA::Long aNbPlanes = aServant->GetNbPlanes();
+ theStr<<thePrefix<<aName<<".SetNbPlanes("<<aNbPlanes<<")"<<endl;
+
+ for(CORBA::Long anId = 0; anId < aNbPlanes; anId++){
+ if(!aServant->IsDefault(anId))
+ theStr<<thePrefix<<aName<<".SetPlanePosition("<<anId<<","<<aServant->GetPlanePosition(anId)<<")"<<endl;
+ }
+
+ theStr<<thePrefix<<"pass"<<endl<<endl;
+ }
+ return;
+ case VISU::TCUTLINES:
+ if(CutLines_i* aServant = dynamic_cast<CutLines_i*>(GetServant(anObj).in())){
+ thePrefix = ScalarMapToPython(theSObject,aServant,theStr,aName,"CutLinesOnField",theArgumentName,thePrefix);
+
+ std::string aParam;
+ switch(aServant->GetOrientationType()){
+ case CutPlanes::XY:
+ aParam = "VISU.CutPlanes.XY";
+ break;
+ case CutPlanes::YZ:
+ aParam = "VISU.CutPlanes.YZ";
+ break;
+ case CutPlanes::ZX:
+ aParam = "VISU.CutPlanes.ZX";
+ break;
+ }
+ theStr<<thePrefix<<aName<<".SetOrientation("<<aParam<<","<<aServant->GetRotateX()<<","<<aServant->GetRotateY()<<")"<<endl;
+
+ switch(aServant->GetOrientationType2()){
+ case CutPlanes::XY:
+ aParam = "VISU.CutPlanes.XY";
+ break;
+ case CutPlanes::YZ:
+ aParam = "VISU.CutPlanes.YZ";
+ break;
+ case CutPlanes::ZX:
+ aParam = "VISU.CutPlanes.ZX";
+ break;
+ }
+ theStr<<thePrefix<<aName<<".SetOrientation2("<<aParam<<","<<aServant->GetRotateX2()<<","<<aServant->GetRotateY2()<<")"<<endl;
+
+ theStr<<thePrefix<<aName<<".SetDisplacement("<<aServant->GetDisplacement()<<")"<<endl;
+ theStr<<thePrefix<<aName<<".SetDisplacement2("<<aServant->GetDisplacement2()<<")"<<endl;
+
+ if(!aServant->IsDefault())
+ theStr<<thePrefix<<aName<<".SetBasePlanePosition("<<aServant->GetBasePlanePosition()<<")"<<endl;
+
+ CORBA::Long aNbLines = aServant->GetNbLines();
+ theStr<<thePrefix<<aName<<".SetNbLines("<<aNbLines<<")"<<endl;
+ for(CORBA::Long anId = 0; anId < aNbLines; anId++){
+ if(!aServant->IsDefaultPosition(anId))
+ theStr<<thePrefix<<aName<<".SetLinePosition("<<anId<<","<<aServant->GetLinePosition(anId)<<")"<<endl;
+ }
+
+ theStr<<endl;
+
+ theArgumentName = aName;
+ DumpChildrenToPython(theStudy,
+ theIsPublished,
+ theIsValidScript,
+ theSObject,
+ theStr,
+ theName2EntryMap,
+ theEntry2NameMap,
+ theArgumentName,
+ thePrefix);
+
+ theStr<<thePrefix<<"pass"<<endl<<endl;
+ }
+ return;
+ case VISU::TPLOT3D:
+ if (Plot3D_i* aServant = dynamic_cast<Plot3D_i*>(GetServant(anObj).in())) {
+ thePrefix = ScalarMapToPython(theSObject, aServant, theStr, aName,
+ "Plot3DOnField", theArgumentName, thePrefix);
+
+ std::string aParam;
+ switch(aServant->GetOrientationType()){
+ case CutPlanes::XY: aParam = "VISU.Plot3D.XY"; break;
+ case CutPlanes::YZ: aParam = "VISU.Plot3D.YZ"; break;
+ case CutPlanes::ZX: aParam = "VISU.Plot3D.ZX"; break;
+ }
+ theStr<<thePrefix<<aName<<".SetOrientation("<<aParam<<","<<aServant->GetRotateX()<<","<<aServant->GetRotateY()<<")"<<endl;
+
+ theStr<<thePrefix<<aName<<".SetPlanePosition("<<aServant->GetPlanePosition()<<","<<aServant->IsPositionRelative()<<")"<<endl;
+ theStr<<thePrefix<<aName<<".SetScaleFactor("<<aServant->GetScaleFactor()<<")"<<endl;
+ theStr<<thePrefix<<aName<<".SetContourPrs("<<aServant->GetIsContourPrs()<<")"<<endl;
+ theStr<<thePrefix<<aName<<".SetNbOfContours("<<aServant->GetNbOfContours()<<")"<<endl;
+ theStr<<thePrefix<<"pass"<<endl<<endl;
+ }
+ return;
+ case VISU::TCURVE:
+ if(Curve_i* aServant = dynamic_cast<Curve_i*>(GetServant(anObj).in()))
+ {
+ theStr << thePrefix << "aName2ObjectMap['" << aName << "'] = visu.CreateCurve(" <<
+ theArgumentName<< // table
+ ","<<aServant->GetHRow()<< // H row
+ ","<<aServant->GetVRow()<< // V row
+ ",'"<<aServant->GetTitle()<<"'"; // title
+ SALOMEDS::Color aColor = aServant->GetColor();
+ theStr << ",SALOMEDS.Color("<<
+ aColor.R<<","<<aColor.G<<","<<aColor.B<<")"; // color
+
+ std::string aParam;
+ switch(aServant->GetMarker()){
+ case Curve::NONE: aParam = "VISU.Curve.NONE"; break;
+ case Curve::CIRCLE: aParam = "VISU.Curve.CIRCLE"; break;
+ case Curve::RECTANGLE: aParam = "VISU.Curve.RECTANGLE"; break;
+ case Curve::DIAMOND: aParam = "VISU.Curve.DIAMOND"; break;
+ case Curve::DTRIANGLE: aParam = "VISU.Curve.DTRIANGLE"; break;
+ case Curve::UTRIANGLE: aParam = "VISU.Curve.UTRIANGLE"; break;
+ case Curve::LTRIANGLE: aParam = "VISU.Curve.LTRIANGLE"; break;
+ case Curve::RTRIANGLE: aParam = "VISU.Curve.RTRIANGLE"; break;
+ case Curve::CROSS: aParam = "VISU.Curve.CROSS"; break;
+ case Curve::XCROSS: aParam = "VISU.Curve.XCROSS"; break;
+ }
+ theStr<<","<<aParam; // marker
+
+ switch(aServant->GetLine()){
+ case Curve::VOIDLINE: aParam = "VISU.Curve.VOIDLINE"; break;
+ case Curve::SOLIDLINE: aParam = "VISU.Curve.SOLIDLINE"; break;
+ case Curve::DASHLINE: aParam = "VISU.Curve.DASHLINE"; break;
+ case Curve::DOTLINE: aParam = "VISU.Curve.DOTLINE"; break;
+ case Curve::DASHDOTLINE: aParam = "VISU.Curve.DASHDOTLINE"; break;
+ case Curve::DASHDOTDOTLINE: aParam = "VISU.Curve.DASHDOTDOTLINE"; break;
+ }
+ theStr<<","<<aParam<<","<<aServant->GetLineWidth()<<")"<<endl; // line type,width
+ }
+ return;
+ case VISU::TTABLE:
+ if(Table_i* aServant = dynamic_cast<Table_i*>(GetServant(anObj).in())){
+ SALOMEDS::SObject_var aSObject = aServant->GetSObject();
+ SALOMEDS::GenericAttribute_var anAttr;
+ if(theSObject->FindAttribute(anAttr,"AttributeComment")){
+ using namespace SALOMEDS;
+ AttributeComment_var aComment = AttributeComment::_narrow(anAttr);
+ CORBA::String_var aValue = aComment->Value();
+ Storable::TRestoringMap aMap;
+ Storable::StrToMap(aValue.in(),aMap);
+ bool anIsExist;
+ QString aSourceId = VISU::Storable::FindValue(aMap,"mySourceId",&anIsExist);
+ if(anIsExist){
+ if(strcmp(aSourceId.latin1(),"CutLines") == 0){
+ theStr<<thePrefix<<"if aName2ObjectMap.has_key('"<<theArgumentName<<"'):"<<endl;
+ thePrefix += PREFIX;
+
+ theStr<<thePrefix<<"anObject = aName2ObjectMap['"<<theArgumentName<<"']"<<endl;
+ theStr<<thePrefix<<"anIOR = anObject.GetID()"<<endl;
+ theStr<<thePrefix<<"aSObject = theStudy.FindObjectIOR(anIOR)"<<endl;
+ theStr<<thePrefix<<"if aSObject:"<<endl;
+ std::string aPrefix = thePrefix;
+ thePrefix += PREFIX;
+
+ theStr<<thePrefix<<"anID = aSObject.GetID()"<<endl;
+ theStr<<thePrefix<<aName<<" = aVisu.CreateTable(anID)"<<endl;
+ theStr<<endl;
+
+ theArgumentName = aName;
+ DumpChildrenToPython(theStudy,
+ theIsPublished,
+ theIsValidScript,
+ theSObject,
+ theStr,
+ theName2EntryMap,
+ theEntry2NameMap,
+ theArgumentName,
+ thePrefix);
+
+ theStr<<thePrefix<<"pass"<<endl<<endl;
+ theStr<<aPrefix<<"pass"<<endl<<endl;
+ }else if(strcmp(aSourceId.latin1(),"TableFile") == 0){
+ CORBA::Short aTag = theSObject->Tag();
+ theStr<<thePrefix<<"anIsFound, aSObject = "<<theArgumentName<<".FindSubObject("<<aTag<<")"<<endl;
+ theStr<<thePrefix<<"if anIsFound:"<<endl;
+ thePrefix += PREFIX;
+
+ theStr<<thePrefix<<"anID = aSObject.GetID()"<<endl;
+ theStr<<thePrefix<<aName<<" = aVisu.CreateTable(anID)"<<endl;
+ theStr<<endl;
+
+ theArgumentName = aName;
+ DumpChildrenToPython(theStudy,
+ theIsPublished,
+ theIsValidScript,
+ theSObject,
+ theStr,
+ theName2EntryMap,
+ theEntry2NameMap,
+ theArgumentName,
+ thePrefix);
+
+ theStr<<thePrefix<<"pass"<<endl<<endl;
+ }else if(strcmp(aSourceId.latin1(),"TableAttr") == 0){
+ theArgumentName = aName;
+ DumpTableAttrToPython(theStudy,
+ theIsPublished,
+ theIsValidScript,
+ theSObject,
+ theStr,
+ theName2EntryMap,
+ theEntry2NameMap,
+ theArgumentName,
+ thePrefix);
+ }
+ }
+ }
+ }
+ return;
+ }
+ }
+ }else{
+ SALOMEDS::GenericAttribute_var anAttr;
+ if(theSObject->FindAttribute(anAttr,"AttributeComment")){
+ SALOMEDS::AttributeComment_var aComment =
+ SALOMEDS::AttributeComment::_narrow(anAttr);
+ CORBA::String_var aValue = aComment->Value();
+ Storable::TRestoringMap aMap;
+ Storable::StrToMap(aValue.in(),aMap);
+ bool anIsExist;
+ QString aTypeName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist);
+ if(anIsExist){
+ if(strcmp(aTypeName.latin1(),"ImportTables") == 0){
+ QString aFileName = VISU::Storable::FindValue(aMap,"myFileName",&anIsExist);
+ if(anIsExist){
+ std::string aName = GenerateName(theSObject,theName2EntryMap,theEntry2NameMap);
+ theStr<<thePrefix<<aName<<" = aVisu.ImportTables('"<<aFileName.latin1()<<"')"<<endl;
+ theStr<<thePrefix<<"if "<<aName<<":"<<endl;
+ thePrefix += PREFIX;
+
+ theArgumentName = aName;
+ DumpChildrenToPython(theStudy,
+ theIsPublished,
+ theIsValidScript,
+ theSObject,
+ theStr,
+ theName2EntryMap,
+ theEntry2NameMap,
+ theArgumentName,
+ thePrefix);
+
+ theStr<<thePrefix<<"pass"<<endl<<endl;
+ return;
+ }
+ }else if(strcmp(aTypeName.latin1(),"VIEW3D") == 0){
+ std::string aName = GetName(theSObject);
+ theStr<<thePrefix<<aName<<" = aBuilder.NewObject(aSComponent)"<<endl;
+
+ theStr<<thePrefix<<"if "<<aName<<":"<<endl;
+ thePrefix += PREFIX;
+
+ theStr<<thePrefix<<"anAttr = aBuilder.FindOrCreateAttribute("<<aName<<",'AttributeName')"<<endl;
+ theStr<<thePrefix<<"anAttr.SetValue('"<<aName<<"')"<<endl;
+
+ theStr<<thePrefix<<"anAttr = aBuilder.FindOrCreateAttribute("<<aName<<",'AttributeComment')"<<endl;
+ theStr<<thePrefix<<"anAttr.SetValue('"<<aValue.in()<<"')"<<endl;
+
+ theStr<<thePrefix<<"pass"<<endl<<endl;
+ return;
+ }
+ }
+ }else{
+ DumpTableAttrToPython(theStudy,
+ theIsPublished,
+ theIsValidScript,
+ theSObject,
+ theStr,
+ theName2EntryMap,
+ theEntry2NameMap,
+ theArgumentName,
+ thePrefix);
+ }
+ }
+
+ DumpChildrenToPython(theStudy,
+ theIsPublished,
+ theIsValidScript,
+ theSObject,
+ theStr,
+ theName2EntryMap,
+ theEntry2NameMap,
+ theArgumentName,
+ thePrefix);
+ }
+
+
+ //===========================================================================
+ void
+ DumpCurveToPython(SALOMEDS::Study_ptr theStudy,
+ CORBA::Boolean theIsPublished,
+ CORBA::Boolean& theIsValidScript,
+ SALOMEDS::SObject_ptr theSObject,
+ std::ostream& theStr,
+ TName2EntryMap& theName2EntryMap,
+ TEntry2NameMap& theEntry2NameMap,
+ std::string theArgumentName,
+ std::string thePrefix)
+ {
+ SALOMEDS::SObject_var aTargetRefSObj;
+ if(theSObject->ReferencedObject(aTargetRefSObj)){
+ CORBA::Object_var anObj = SObjectToObject(aTargetRefSObj);
+ if(CORBA::is_nil(anObj))
+ return;
+
+ VISU::Base_var aBase = VISU::Base::_narrow(anObj);
+ if(CORBA::is_nil(aBase))
+ return;
+
+ if(aBase->GetType() == VISU::TCURVE){
+ CORBA::String_var anID = aTargetRefSObj->GetID();
+ std::string anArg = theEntry2NameMap[anID.in()];
+ theStr<<thePrefix<<"if aName2ObjectMap.has_key('"<<anArg<<"'):"<<endl;
+ thePrefix += PREFIX;
+ theStr<<thePrefix<<"anObject = aName2ObjectMap['"<<anArg<<"']"<<endl;
+ theStr<<thePrefix<<"if anObject: " <<theArgumentName<<".AddCurve(anObject)"<<endl;
+ theStr<<thePrefix<<"pass"<<endl<<endl;
+ }
+ }
+ }
+
+
+ //===========================================================================
+ void
+ DumpContainersToPython(SALOMEDS::Study_ptr theStudy,
+ CORBA::Boolean theIsPublished,
+ CORBA::Boolean& theIsValidScript,
+ SALOMEDS::SObject_ptr theSObject,
+ std::ostream& theStr,
+ TName2EntryMap& theName2EntryMap,
+ TEntry2NameMap& theEntry2NameMap,
+ std::string theArgumentName,
+ std::string thePrefix)
+ {
+ SALOMEDS::ChildIterator_var aChildItet = theStudy->NewChildIterator(theSObject);
+ for(aChildItet->InitEx(false); aChildItet->More(); aChildItet->Next()){
+ SALOMEDS::SObject_var aSObject = aChildItet->Value();
+ CORBA::Object_var anObj = SObjectToObject(aSObject);
+ if(CORBA::is_nil(anObj))
+ continue;
+
+ VISU::Base_var aBase = VISU::Base::_narrow(anObj);
+ if(CORBA::is_nil(aBase))
+ continue;
+
+ if(aBase->GetType() == VISU::TCONTAINER){
+ theStr<<endl;
+ std::string aName = GenerateName(aSObject,theName2EntryMap,theEntry2NameMap);
+ theStr<<thePrefix<<aName<<" = aVisu.CreateContainer()"<<endl;
+ theStr<<thePrefix<<"if "<<aName<<":"<<endl;
+ std::string aPrefix = thePrefix + PREFIX;
+ theArgumentName = aName;
+
+ SALOMEDS::ChildIterator_var aCurveIter = theStudy->NewChildIterator(aSObject);
+ for(aCurveIter->InitEx(false); aCurveIter->More(); aCurveIter->Next()){
+ SALOMEDS::SObject_var aRefSObj = aCurveIter->Value();
+ DumpCurveToPython(theStudy,theIsPublished,theIsValidScript,aRefSObj,theStr,theName2EntryMap,theEntry2NameMap,theArgumentName,aPrefix);
+ }
+
+ theStr<<aPrefix<<"pass"<<endl<<endl;
+ }
+ }
+ }
+
+
+ //===========================================================================
+ Engines::TMPFile*
+ VISU_Gen_i::
+ DumpPython(CORBA::Object_ptr theStudy,
+ CORBA::Boolean theIsPublished,
+ CORBA::Boolean& theIsValidScript)
+ {
+ SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
+ if(CORBA::is_nil(aStudy))
+ return new Engines::TMPFile(0);
+
+ TName2EntryMap aName2EntryMap;
+ TEntry2NameMap aEntry2NameMap;
+
+#ifndef COUT
+ ostringstream aStr;
+#else
+#define aStr cout
+#endif
+
+ std::string aPrefix(PREFIX);
+ aStr<<"### This file is generated by SALOME automatically by dump python funcitonality"
+ " of VISU component"<<endl<<endl;
+ aStr<<"def RebuildData(theStudy):"<<endl;
+ aStr<<aPrefix<<"from batchmode_salome import orb, naming_service, lcc, myStudyManager"<<endl;
+ aStr<<aPrefix<<"import SALOME_MED"<<endl;
+ aStr<<aPrefix<<"import SALOMEDS"<<endl;
+ aStr<<aPrefix<<"import VISU"<<endl;
+ aStr<<aPrefix<<"import visu"<<endl;
+ aStr<<endl;
+ aStr<<aPrefix<<"aVisu = visu.Initialize(orb,naming_service,lcc,myStudyManager,theStudy,0)"<<endl;
+ aStr<<aPrefix<<"aSComponent = visu.PublishComponent(theStudy)"<<endl;
+ aStr<<aPrefix<<"aMed = lcc.FindOrLoadComponent('FactoryServer','MED')"<<endl;
+ aStr<<aPrefix<<"aBuilder = theStudy.NewBuilder()"<<endl;
+ aStr<<aPrefix<<"aName2ObjectMap = {}"<<endl;
+ aStr<<endl;
+
+ SALOMEDS::SComponent_var aComponent = FindOrCreateVisuComponent(aStudy);
+ VISU::DumpChildrenToPython(aStudy,theIsPublished,theIsValidScript,aComponent.in(),aStr,aName2EntryMap,aEntry2NameMap,"",aPrefix);
+ VISU::DumpContainersToPython(aStudy,theIsPublished,theIsValidScript,aComponent.in(),aStr,aName2EntryMap,aEntry2NameMap,"",aPrefix);
+
+ aStr<<aPrefix<<"pass"<<endl;
+
+#ifndef COUT
+ std::string aResult = aStr.str();
+ //ofstream anFStream("/tmp/dump.py");
+ //anFStream<<aResult<<endl;
+
+ CORBA::ULong aSize = aResult.size() + 1;
+ char* aBuffer = new char[aSize];
+ strcpy(aBuffer,&aResult[0]);
+ return new Engines::TMPFile(aSize,aSize,(CORBA::Octet*)aBuffer,1);
+#else
+#undef aStr
+ return new Engines::TMPFile(0);
+#endif
+ }
+}
--- /dev/null
+// VISU OBJECT : interactive object for VISU entities implementation
+//
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+// File : VISU_View_i.hh
+// Author : Alexey PETROV
+// Module : VISU
+
+#ifndef VISU_View_i_HeaderFile
+#define VISU_View_i_HeaderFile
+
+#include "VISUConfig.hh"
+
+class QWidget;
+
+class VisuGUI_TableDlg;
+
+class SalomeApp_Application;
+
+class SUIT_ViewManager;
+class SUIT_ViewWindow;
+
+class Plot2d_ViewFrame;
+
+namespace VISU
+{
+ class Prs3d_i;
+ class Curve_i;
+
+ class View_i : public virtual POA_VISU::View,
+ public virtual Storable
+ {
+ public:
+ View_i (SalomeApp_Application *theApplication,
+ SUIT_ViewManager* theViewManager);
+ virtual ~View_i();
+
+ public:
+ virtual void ShowPart( VISU::View::ViewRepresentation ViewRepr, CORBA::Boolean state );
+ virtual CORBA::Boolean IsPartShown( VISU::View::ViewRepresentation ViewRepr );
+
+ // Begin: New methods for view parameters management
+ virtual void SplitRight();
+ virtual void SplitLeft();
+ virtual void SplitBottom();
+ virtual void SplitTop();
+
+ virtual void OnTop();
+
+ virtual void Attract (VISU::View_ptr theView);
+ virtual void AttractAll(VISU::View_ptr theView);
+
+ virtual void SetRelativePositionInSplitter(CORBA::Double thePosition);
+ virtual void SetRelativeSizeInSplitter(CORBA::Double theSize);
+
+ virtual void SetRelativePositionX(CORBA::Double thePosition);
+ virtual void SetRelativePositionY(CORBA::Double thePosition);
+
+ virtual void SetRelativeSizeX(CORBA::Double theSize);
+ virtual void SetRelativeSizeY(CORBA::Double theSize);
+ // End: New methods for view parameters management
+
+ // Begin: Old methods for view parameters management, they don't work now
+ virtual void SetViewWidth(CORBA::Long Width);
+ virtual void SetViewHeight(CORBA::Long Height);
+ virtual CORBA::Long GetViewWidth();
+ virtual CORBA::Long GetViewHeight();
+ virtual void SetViewPositionHorizontal(VISU::View::ViewPosition ViewPosHor);
+ virtual void SetViewPositionVertical(VISU::View::ViewPosition ViewPosVer);
+ virtual void SetRelativePosition( CORBA::Double x, CORBA::Double y );
+ virtual void SetRelativeSize( CORBA::Double x, CORBA::Double y );
+ virtual void Minimize();
+ virtual void Restore();
+ virtual void Maximize();
+ // End: Old methods for view parameters management, they don't work now
+
+ virtual void SetBackground(const SALOMEDS::Color& theColor);
+ virtual SALOMEDS::Color GetBackground();
+
+ virtual void EraseAll();
+ virtual void DisplayAll();
+ virtual void Erase(PrsObject_ptr thePrsObj);
+ virtual void Display(PrsObject_ptr thePrsObj);
+ virtual void DisplayOnly(PrsObject_ptr thePrsObj);
+
+ virtual void Update();
+
+ virtual CORBA::Boolean SavePicture(const char* theFileName);
+
+ virtual void Close() = 0;
+ virtual void ToStream(std::ostringstream& theStr);
+ virtual const char* GetComment() const;
+
+ SUIT_ViewWindow* GetViewWindow();
+ void SetViewWindow(SUIT_ViewWindow* theViewWindow);
+
+ public:
+ QWidget *myWorkspace;
+
+ SalomeApp_Application *myApplication;
+ SUIT_ViewManager *myViewManager;
+
+ private:
+ SUIT_ViewWindow *myViewWindow;
+ };
+
+
+ //===========================================================================
+ class XYPlot_i : public virtual POA_VISU::XYPlot,
+ public virtual View_i
+ {
+ public:
+ typedef VISU::XYPlot TInterface;
+
+ XYPlot_i (SalomeApp_Application *theApplication);
+ virtual ~XYPlot_i();
+
+ virtual VISU::VISUType GetType() { return VISU::TXYPLOT; };
+
+ virtual void SetTitle (const char* theTitle);
+ virtual char* GetTitle();
+
+ virtual void SetSubTitle (const char* theTitle);
+ virtual char* GetSubTitle();
+
+ virtual void SetCurveType (VISU::XYPlot::CurveType theType);
+ virtual VISU::XYPlot::CurveType GetCurveType();
+
+ virtual void SetMarkerSize (CORBA::Long theSize);
+ virtual CORBA::Long GetMarkerSize();
+
+ virtual void EnableXGrid (CORBA::Boolean theMajor, CORBA::Long theNumMajor,
+ CORBA::Boolean theMinor, CORBA::Long theNumMinor);
+ virtual void EnableYGrid (CORBA::Boolean theMajor, CORBA::Long theNumMajor,
+ CORBA::Boolean theMinor, CORBA::Long theNumMinor);
+
+ virtual void SetHorScaling (VISU::Scaling theScaling);
+ virtual VISU::Scaling GetHorScaling();
+ virtual void SetVerScaling (VISU::Scaling theScaling);
+ virtual VISU::Scaling GetVerScaling();
+
+ virtual void SetXTitle (const char* theTitle);
+ virtual char* GetXTitle();
+
+ virtual void SetYTitle (const char* theTitle);
+ virtual char* GetYTitle();
+
+ virtual void ShowLegend (CORBA::Boolean theShowing);
+
+ virtual void EraseAll();
+ virtual void Erase (PrsObject_ptr thePrsObj);
+ virtual void Display (PrsObject_ptr thePrsObj);
+ virtual void DisplayOnly (PrsObject_ptr thePrsObj);
+ virtual void Update();
+
+ virtual void FitAll();
+ virtual void FitXRange(const CORBA::Double xMin,const CORBA::Double xMax);
+ virtual void FitYRange(const CORBA::Double yMin,const CORBA::Double yMax);
+ virtual void FitRange(const CORBA::Double xMin,const CORBA::Double xMax,
+ const CORBA::Double yMin,const CORBA::Double yMax);
+ virtual void GetFitRanges(double& xMin, double& xMax, double& yMin, double& yMax);
+
+ virtual void Close();
+ protected:
+ Plot2d_ViewFrame* myView;
+ public:
+ virtual Storable* Create (int theNew);
+ };
+
+
+ //===========================================================================
+ class TableView_i : public virtual POA_VISU::TableView,
+ public virtual View_i
+ {
+ public:
+ typedef VISU::TableView TInterface;
+
+ TableView_i (SalomeApp_Application *theApplication);
+ virtual ~TableView_i();
+
+ virtual VISU::VISUType GetType() { return VISU::TTABLEVIEW; };
+
+ virtual void SetTitle (const char* theTitle);
+ virtual char* GetTitle();
+
+ virtual void Close();
+ protected:
+ VisuGUI_TableDlg* myView;
+ public:
+ virtual Storable* Create (VISU::Table_ptr theTable);
+ };
+
+
+ //===========================================================================
+ class View3D_i : public virtual POA_VISU::View3D,
+ public virtual View_i
+ {
+ public:
+ typedef VISU::View3D TInterface;
+
+ View3D_i (SalomeApp_Application *theApplication);
+ virtual ~View3D_i();
+
+ virtual VISU::VISUType GetType() { return VISU::TVIEW3D; };
+
+ //View interface
+ virtual void SetTitle (const char* theTitle);
+ virtual char* GetTitle();
+
+ static void SetBackground (SUIT_ViewWindow* theViewWindow,
+ const SALOMEDS::Color& theColor);
+
+ static SALOMEDS::Color GetBackground (SUIT_ViewWindow* theViewWindow);
+
+ virtual void EraseAll();
+ virtual void DisplayAll();
+ virtual void Erase (PrsObject_ptr thePrsObj);
+ virtual void Display (PrsObject_ptr thePrsObj);
+ virtual void DisplayOnly (PrsObject_ptr thePrsObj);
+ virtual void Update();
+
+ //View3D interface
+ virtual void FitAll();
+ virtual void SetView (VISU::View3D::ViewType theType);
+
+ static void SetPointOfView (SUIT_ViewWindow* theViewWindow,
+ const CORBA::Double thePosition[3]);
+ virtual void SetPointOfView (const VISU::View3D::XYZ theCoord);
+
+ static void GetPointOfView (SUIT_ViewWindow* theViewWindow,
+ CORBA::Double thePosition[3]);
+ virtual VISU::View3D::XYZ_slice* GetPointOfView();
+
+ static void SetViewUp (SUIT_ViewWindow* theViewWindow,
+ const CORBA::Double theViewUp[3]);
+ virtual void SetViewUp (const VISU::View3D::XYZ theDir);
+
+ static void GetViewUp (SUIT_ViewWindow* theViewWindow, CORBA::Double theViewUp[3]);
+ virtual VISU::View3D::XYZ_slice* GetViewUp();
+
+ static void SetFocalPoint (SUIT_ViewWindow* theViewWindow, const CORBA::Double theFocalPnt[3]);
+ virtual void SetFocalPoint (const VISU::View3D::XYZ theCoord);
+
+ static void View3D_i::GetFocalPoint (SUIT_ViewWindow* theViewWindow, CORBA::Double theFocalPnt[3]);
+ virtual VISU::View3D::XYZ_slice* GetFocalPoint();
+
+ static void SetParallelScale (SUIT_ViewWindow* theViewWindow, CORBA::Double theScale);
+ virtual void SetParallelScale (CORBA::Double theScale);
+
+ static CORBA::Double GetParallelScale (SUIT_ViewWindow* theViewWindow);
+ virtual CORBA::Double GetParallelScale ();
+
+ static void ScaleView (SUIT_ViewWindow* theViewWindow,
+ VISU::View3D::Axis theAxis, CORBA::Double theParam);
+ virtual void ScaleView (VISU::View3D::Axis theAxis, CORBA::Double theParam);
+ virtual void RemoveScale();
+
+ static std::string ToString (SUIT_ViewWindow* theViewWindow);
+
+ static void ToStream (SUIT_ViewWindow* theViewWindow, std::ostringstream& theStr);
+
+ static bool SaveViewParams (SUIT_ViewManager* theViewManager,
+ const char* theName);
+ virtual CORBA::Boolean SaveViewParams (const char* theName);
+
+ static bool RestoreViewParams (SUIT_ViewManager* theViewManager,
+ const char* theName);
+ virtual CORBA::Boolean RestoreViewParams (const char* theName);
+
+ static QString GenerateViewParamsName();
+
+ static void Restore (SUIT_ViewWindow* theViewWindow,
+ const Storable::TRestoringMap& theMap);
+
+ virtual void Close();
+
+ protected:
+ static int myNbViewParams;
+
+ public:
+ virtual Storable* Create (int theNew);
+ virtual void ToStream (std::ostringstream& theStr);
+ virtual const char* GetComment() const;
+ static const std::string myComment;
+ };
+}
+
+#endif
--- /dev/null
+# Animation of "vitesse" field, stored in file TimeStamps.med
+#
+# This script is equivalent to non-regression test script 003/A5
+
+import salome
+import visu_gui
+import SALOMEDS
+import VISU
+import os
+import time
+
+medFile = os.getenv("DATA_DIR") + "/MedFiles/TimeStamps.med"
+
+print 'Importing "TimeStamps.med"................',
+myVisu = visu_gui.myVisu
+myResult = myVisu.ImportFile(medFile)
+if myResult is None : print "Error"
+else : print "OK"
+
+print "Creating Cut Lines........................",
+medMesh = 'dom'
+medField = "vitesse"
+aCutLines = myVisu.CutLinesOnField(myResult,'dom',VISU.NODE,medField,1.0)
+aCutLines.SetOrientation(VISU.CutPlanes.XY, 0, 0)
+aCutLines.SetOrientation2(VISU.CutPlanes.ZX, 0, 0)
+aCutLines.SetNbLines(20)
+if aCutLines is None : print "Error"
+else : print "OK"
+
+print "Creating a Viewer.........................",
+myViewManager = myVisu.GetViewManager();
+myView = myViewManager.Create3DView();
+if myView is None : print "Error"
+else : print "OK"
+myView.Display(aCutLines);
+myView.FitAll();
+
+aCutLinesSObj = salome.myStudy.FindObjectIOR(aCutLines.GetID())
+aFather = aCutLinesSObj.GetFather().GetFather();
+
+print "Creating an Animation.....................",
+myAnim = myVisu.CreateAnimation(myView);
+if myAnim is None : print "Error"
+else : print "OK"
+
+print "Animation.................................",
+myAnim.addField(aFather);
+myAnim.generatePresentations(0);
+myAnim.generateFrames();
+myAnim.setSpeed(33)
+myAnim.startAnimation();
+
+myView.FitAll()
+while 1:
+ time.sleep(1)
+ if not myAnim.isRunning():
+ myAnim.stopAnimation()
+ break
+
+print "OK"
--- /dev/null
+# Create a table and show it in Plot2d viewer
+#
+# This script is equivalent to script VISU_SWIG/visu_big_table.py
+
+import salome
+import math
+import SALOMEDS
+import VISU
+#from visu_gui import *
+
+# >>> Getting study builder ==================================================
+myStudy = salome.myStudy
+myBuilder = myStudy.NewBuilder()
+
+# >>> Getting (loading) VISU component =======================================
+myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU")
+myComponent = myStudy.FindComponent("VISU")
+myVisu.SetCurrentStudy(myStudy)
+if not myComponent:
+ myComponent = myBuilder.NewComponent("VISU")
+ aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName")
+ aName.SetValue( salome.sg.getComponentUserName("VISU") )
+
+ A2 = myBuilder.FindOrCreateAttribute(myComponent, "AttributePixMap");
+ aPixmap = A2._narrow(SALOMEDS.AttributePixMap);
+ aPixmap.SetPixMap( "ICON_OBJBROWSER_Visu" );
+
+ myBuilder.DefineComponentInstance(myComponent,myVisu)
+
+# >>> Creating object with Table of real[ 200 * 20 ] =========================
+myTRealObject = myBuilder.NewObject(myComponent)
+AName = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeName")
+AName.SetValue("Table Of Real")
+ARealTable = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeTableOfReal")
+myHorNb = 10
+myVerNb = 200
+
+k={}
+for j in range(0,myHorNb):
+ k[j] = j*10+1
+ARealTable.AddRow(k.values())
+ARealTable.SetRowTitle(1, "Frequency")
+ARealTable.SetRowUnit(1, "Hz")
+
+for i in range(1,myVerNb+1):
+ for j in range(0,myHorNb):
+ if j % 2 == 1:
+ k[j] = math.log10(j*30*math.pi/180) * 20 + i * 15 + j*5
+ else:
+ k[j] = math.sin(j*30*math.pi/180) * 20 + i * 15 + j*5
+ ARealTable.AddRow(k.values())
+ ARealTable.SetRowTitle(i+1, "Power " + str(i))
+ ARealTable.SetRowUnit(i+1, "Wt")
+
+ARealTable.SetTitle("Very useful data")
+
+# >>> Create Visu table ======================================================
+myVisuTableReal = myVisu.CreateTable( myTRealObject.GetID() )
+
+# >>> Create container and insert curves
+myContainer = myVisu.CreateContainer()
+
+# >>> Create curves ==========================================================
+for i in range(1,myVerNb+1):
+ myCurve = myVisu.CreateCurve( myVisuTableReal, 1, i+1 )
+ myContainer.AddCurve(myCurve)
+
+# >>> Updating Object Browser ================================================
+salome.sg.updateObjBrowser(1)
+
+# >>> Display curves in Plot2d viewer ========================================
+myViewManager = myVisu.GetViewManager();
+myView = myViewManager.CreateXYPlot();
+myView.SetTitle("The viewer for Curves from the Table")
+myView.Display(myContainer)
+
+# ============================================================================
--- /dev/null
+# VISU VISU_SWIG : binding of C++ implementation and Python
+#
+# Copyright (C) 2003 CEA/DEN, EDF R&D
+#
+#
+#
+# File : batchmode_visu_view3d.py
+# Module : VISU
+
+import os
+import time
+import math
+import VISU
+import SALOMEDS
+from batchmode_visu import *
+
+aDelay = 0
+
+#mySession = batchmode_visu.mySession
+
+myViewManager = myVisu.GetViewManager();
+
+myView = myViewManager.Create3DView();
+myView.SetTitle("The window will be soon destroyed!")
+print "myViewManager.Create3DView()"
+time.sleep(aDelay)
+
+myView.Maximize()
+print "myView.Maximize()"
+time.sleep(aDelay)
+
+myView.Restore()
+print "myView.Restore()"
+time.sleep(aDelay)
+
+myView.Minimize()
+print "myView.Minimize()"
+time.sleep(aDelay)
+
+myViewManager.Destroy(myView)
+print "myViewManager.Destroy(myView)"
+time.sleep(aDelay)
+
+
+
+medFile = "fra.med"
+myFieldName = "VITESSE";
+
+aMeshName ="LE VOLUME"
+anEntity = VISU.NODE
+aTimeStampId = 1
+
+medFile = os.getenv('DATA_DIR') + '/MedFiles/' + medFile
+myResult = myVisu.ImportFile(medFile)
+
+
+
+myView = myViewManager.Create3DView();
+
+print "myView.SetBackground(...)"
+aColor = SALOMEDS.Color(0.0,0.3,1.0)
+myView.SetBackground(aColor);
+
+myView.SetTitle("The viewer will display ScalarMap")
+print "myViewManager.Create3DView()"
+
+aScalarMap = myVisu.ScalarMapOnField(myResult,aMeshName,anEntity,myFieldName,aTimeStampId)
+
+myView.Display(aScalarMap);
+print "myView.Display(aScalarMap)"
+myView.SetFocalPoint([0,0,0]);
+print "myView.SetFocalPoint(...)"
+myView.SetParallelScale(2);
+print "myView.SetParallelScale(...)"
+myView.FitAll();
+
+aMax = aScalarMap.GetMax()
+aMin = aScalarMap.GetMin()
+aDelta = (aMax - aMin)/2.0
+aNbColors = aScalarMap.GetNbColors()
+aNbColors = 64
+for i in range(2,aNbColors) :
+ aScalarMap.SetNbColors(i)
+ aX = aMin + aDelta*i/aNbColors
+ aY = aMax - aDelta*i/aNbColors
+ aScalarMap.SetRange(aX,aY)
+ myView.Update();
+ time.sleep(aDelay)
+
+aScalarMap.SetRange(aMin,aMax)
+
+print "myView.Update()"
+myView.Update();
+print "myView.FitAll()"
+myView.FitAll();
+
+
+
+myView = myViewManager.Create3DView();
+myView.SetTitle("Here we will display CutPlanes")
+
+print "myView.SetBackground(...)"
+aColor = SALOMEDS.Color(0.0,0.7,0.0)
+myView.SetBackground(aColor);
+
+aCutPlanes = myVisu.CutPlanesOnField(myResult,aMeshName,anEntity,myFieldName,aTimeStampId)
+print "myVisu.CutPlanesOnField(...)"
+
+myView.DisplayOnly(aCutPlanes);
+print "myView.DisplayOnly(aCutPlanes)"
+
+aPoint = myView.GetPointOfView();
+aPoint[0] = aPoint[0] + 10;
+myView.SetPointOfView(aPoint);
+print "myView.SetPointOfView(...)"
+myView.ScaleView(VISU.View3D.YAxis,10.0);
+myView.ScaleView(VISU.View3D.XAxis,3.0);
+print "myView.ScaleView(...)"
+time.sleep(aDelay)
+
+myView.FitAll();
+
+aNbPlanes = aCutPlanes.GetNbPlanes()
+aNbPlanes = 30
+aXAngle = aCutPlanes.GetRotateX()
+aYAngle = aCutPlanes.GetRotateY()
+anOrientation = aCutPlanes.GetOrientationType()
+for i in range(aNbPlanes,1,-1) :
+ aCutPlanes.SetNbPlanes(i)
+ aX = math.pi/2.0*(aNbPlanes-i)/aNbPlanes
+ aY = math.pi/2.0*(aNbPlanes-i)/aNbPlanes
+ aCutPlanes.SetOrientation(anOrientation,aX,aY)
+ myView.Update();
+ time.sleep(aDelay)
+
+aNbPlanes = 10
+aCutPlanes.SetOrientation(VISU.CutPlanes.ZX,0,0)
+for i in range(1,aNbPlanes) :
+ aCutPlanes.SetNbPlanes(i)
+ myView.Update();
+ time.sleep(aDelay)
+
+myView.SaveViewParams('AAA')
+print "myView.SaveViewParams('AAA')"
+time.sleep(aDelay)
+
+aCutPlanes.SetOrientation(VISU.CutPlanes.XY,0,0)
+myView.RemoveScale();
+
+print "myView.Update()"
+myView.Update();
+print "myView.FitAll()"
+myView.FitAll();
+
+
+
+myView = myViewManager.Create3DView();
+print "myViewManager.Create3DView()"
+
+myView.SetTitle("IsoSurface's viewer")
+
+print "myView.SetBackground(...)"
+aColor = SALOMEDS.Color(1.0,0.7,0.0)
+myView.SetBackground(aColor);
+time.sleep(aDelay)
+
+aIsoSurfaces = myVisu.IsoSurfacesOnField(myResult, aMeshName, anEntity, myFieldName, aTimeStampId)
+
+myView.DisplayOnly(aIsoSurfaces);
+myView.FitAll();
+print "myView.DisplayOnly(aCutPlanes)"
+time.sleep(aDelay)
+
+aNbSurfaces = aIsoSurfaces.GetNbSurfaces()
+aNbSurfaces = 32
+for i in range(2,aNbSurfaces) :
+ aIsoSurfaces.SetNbSurfaces(i)
+ myView.Update();
+ time.sleep(aDelay)
+
+aIsoSurfaces.SetNbSurfaces(10)
+
+print "myView.Update()"
+myView.Update();
+print "myView.FitAll()"
+myView.FitAll();
+
+
+
+myView = myViewManager.Create3DView();
+myView.SetTitle("The viewer for CutLines")
+print "myViewManager.Create3DView()"
+time.sleep(aDelay)
+
+print "myView.SetBackground(...)"
+aColor = SALOMEDS.Color(0.7,0.7,0.7)
+myView.SetBackground(aColor);
+time.sleep(aDelay)
+
+aCutLines = myVisu.CutLinesOnField(myResult, aMeshName, anEntity, myFieldName, aTimeStampId)
+aCutLines.SetOrientation(VISU.CutPlanes.ZX,0,0)
+aCutLines.SetOrientation2(VISU.CutPlanes.YZ,0,0)
+
+myView.DisplayOnly(aCutLines);
+myView.FitAll();
+print "myView.DisplayOnly(aCutLines)"
+time.sleep(aDelay)
+
+aSObj = myStudy.FindObjectIOR(aCutLines.GetID())
+aTable = myVisu.CreateTable( aSObj.GetID() )
+print "myVisu.CreateTable(...)"
+
+aTableView = myViewManager.CreateTableView(aTable)
+aTableView.SetTitle('Changed Title')
+
+aContainer = myVisu.CreateContainer()
+print "myVisu.CreateContainer(...)"
+
+aNbCurve = aTable.GetNbRows() - 1
+for i in range(2,aNbCurve):
+ aCurve = myVisu.CreateCurve( aTable, 1, i )
+ print i, aCurve
+ aContainer.AddCurve(aCurve)
+
+
+myView = myViewManager.CreateXYPlot();
+myView.SetTitle("The viewer for Curves from CutLines")
+print "myViewManager.CreateXYPlot()"
+time.sleep(aDelay)
+
+myView.Display(aContainer)
+
+
+
+myView = myViewManager.Create3DView();
+myView.SetTitle("The viewer for Animation")
+print "myViewManager.Create3DView()"
+time.sleep(aDelay)
+
+medFile = "TimeStamps.med"
+myFieldName = "vitesse";
+
+medFile = os.getenv('DATA_DIR') + '/MedFiles/' + medFile
+myResult = myVisu.ImportFile(medFile)
+
+anAnim = myVisu.CreateAnimation(myView);
+aSObj = myStudy.FindObjectIOR(myResult.GetID())
+aSObj = aSObj.FindSubObject(1)[1]
+aSObj = aSObj.FindSubObject(2)[1]
+aSObj = aSObj.FindSubObject(2)[1]
+anAnim.addField(aSObj)
+anAnim.setPresentationType(0,VISU.TISOSURFACE)
+print "Generate presentations"
+anAnim.generatePresentations(0)
+print "Generate frames"
+anAnim.generateFrames()
+print "Start Animation"
+anAnim.setSpeed(99)
+#anAnim.setCycling(1)
+anAnim.startAnimation()
+myView.FitAll()
+while 1:
+ time.sleep(1+aDelay)
+ if not anAnim.isRunning():
+ anAnim.stopAnimation()
+ break
+
+#anAnim.clearView()
--- /dev/null
+# VISU VISU_SWIG : binding of C++ implementation and Python
+#
+# Copyright (C) 2003 CEA/DEN, EDF R&D
+#
+#
+#
+# File : visu.py
+# Module : VISU
+
+import os
+import re
+from time import sleep
+
+import VISU
+import SALOME
+import SALOME_Session_idl
+import SALOMEDS
+import SALOME_MED
+from omniORB import CORBA
+from string import *
+from time import sleep
+
+myORB = None
+myNamingService = None
+myLifeCycleCORBA = None
+myNamingService = None
+myLocalStudyManager = None
+myLocalStudy = None
+myLocalVisu = None
+myDelay = None
+mySession = None
+
+def Initialize(theORB, theNamingService, theLifeCycleCORBA, theStudyManager, theStudy, theDelay) :
+ global myORB, myNamingService, myLifeCycleCORBA, myLocalStudyManager, myLocalStudy
+ global mySession, myLocalVisu, myDelay
+ myDelay = theDelay
+ myORB = theORB
+ myNamingService = theNamingService
+ myLifeCycleCORBA = theLifeCycleCORBA
+ myLocalStudyManager = theStudyManager
+ while mySession == None:
+ mySession = myNamingService.Resolve("/Kernel/Session")
+ mySession = mySession._narrow(SALOME.Session)
+ mySession.GetInterface()
+ myDelay = theDelay
+ sleep(myDelay)
+ myLocalVisu = myLifeCycleCORBA.FindOrLoadComponent("FactoryServer", "VISU")
+ myLocalStudy = theStudy
+ myLocalVisu.SetCurrentStudy(myLocalStudy)
+ return myLocalVisu
+
+def PublishComponent(theStudyDocument):
+ aComponentDataType = myLocalVisu.ComponentDataType()
+ aSComponent = theStudyDocument.FindComponent(aComponentDataType)
+ if aSComponent == None:
+ aStudyBuilder = theStudyDocument.NewBuilder()
+ aStudyBuilder.NewCommand()
+ aLocked = theStudyDocument.GetProperties().IsLocked()
+ if aLocked:
+ theStudyDocument.GetProperties().SetLocked(0)
+ pass
+
+ aSComponent = aStudyBuilder.NewComponent(aComponentDataType);
+ aName = aStudyBuilder.FindOrCreateAttribute(aSComponent,"AttributeName")
+ aModuleCatalog = myNamingService.Resolve("/Kernel/ModulCatalog");
+ aComponent = aModuleCatalog.GetComponent(aComponentDataType);
+ if aComponent != None:
+ aComponentUserName = aComponent._get_componentusername()
+ aName.SetValue(aComponentUserName)
+ pass
+
+ aPixMap = aStudyBuilder.FindOrCreateAttribute(aSComponent,"AttributePixMap")
+ aPixMap.SetPixMap("ICON_OBJBROWSER_Visu")
+
+ aStudyBuilder.DefineComponentInstance(aSComponent,myLocalVisu);
+ if aLocked:
+ theStudyDocument.GetProperties().SetLocked(1);
+ pass
+
+ aStudyBuilder.CommitCommand();
+ pass
+
+ return aSComponent;
+
+def StrToMap(theString) :
+ aPairList = split(theString,";")
+ aMap = {}
+ iEnd = len(aPairList)
+ for i in range(iEnd) :
+ aPair = split(aPairList[i],"=")
+ aMap[aPair[0]] = aPair[1]
+ return aMap
+
+def IntToEntity(theInt) :
+ theInt = atoi(theInt)
+ if theInt == 0 :
+ return VISU.NODE;
+ elif theInt == 1 :
+ return VISU.EDGE;
+ elif theInt == 2 :
+ return VISU.FACE;
+ else :
+ return VISU.CELL;
+
+def HasValue(theList, theValue) :
+ try :
+ return theList.index(theValue) + 1
+ except StandardError, e :
+ return 0
+
+def CreateStudyForMed(theVisu, theFileName) :
+ print "CreateStudyForMed ", theFileName,
+ if os.path.isfile(theFileName) :
+ if re.search("\.med$", theFileName) is not None :
+ print "OK"
+ aStudyName = os.path.basename(theFileName)
+ aStudyName = re.sub(r'\.med', "", aStudyName)
+ aStudyName = generateName(aStudyName)
+ print "myLocalStudyManager.NewStudy -", aStudyName, "...",
+ aStudy = myLocalStudyManager.NewStudy(aStudyName)
+ if aStudy is None : raise RuntimeError, "Error"
+ else : print "OK"
+
+ print "CreateStudyForMed - Creating a 3D viewer...",
+ theVisu.SetCurrentStudy(aStudy)
+ myViewManager = theVisu.GetViewManager()
+ if myViewManager is None : raise RuntimeError, "Error - theVisu.GetViewManager"
+ myView = myViewManager.Create3DView()
+ if myView is None : raise RuntimeError, "Error - myViewManager.Create3DView"
+ myView.Maximize()
+ print "OK"
+
+ return [aStudy, myViewManager, myView]
+ raise RuntimeError, "Error: There is no shuch file."
+
+def getMedSObject(theStudy = myLocalStudy ):
+ if theStudy is None:
+ theStudy = myLocalStudy
+ aSO = theStudy.FindObject("Med")
+ anIsPresetn, aSObject = aSO.FindSubObject(1)
+ return aSObject
+
+def getMedObjectFromStudy(theStudy = myLocalStudy):
+ aSObject = getMedSObject(theStudy)
+ if aSObject:
+ anAttr = aSObject.FindAttribute("AttributeIOR")[1]
+ anObj = myORB.string_to_object(anAttr.Value())
+ return anObj._narrow(SALOME_MED.MED)
+ return None
+
+def getFieldObjectFromStudy(number, subnumber, theStudy = myLocalStudy):
+ if theStudy is None:
+ theStudy = myLocalStudy
+ mySO = theStudy.FindObject("MEDFIELD")
+ if mySO is None:
+ raise Runtime, "getFieldObjectFromStudy mySO is None"
+ mysub = mySO.FindSubObject(number)[1]
+ if mysub:
+ mysubsub = mysub.FindSubObject(subnumber)[1]
+ if mysubsub:
+ Builder = theStudy.NewBuilder()
+ anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeIOR")
+ obj = myORB.string_to_object(anAttr.Value())
+ myObj = obj._narrow(SALOME_MED.FIELDINT)
+ if (myObj == None):
+ myObj = obj._narrow(SALOME_MED.FIELDDOUBLE)
+ return myObj
+ else:
+ print "ERROR: No Field Object stored in this Study"
+ return None
+
+def SObjectToObject(theSObject) :
+ # global myORB
+ if theSObject is None :
+ print "SObjectToObject : argument is None"
+ anObj = None
+ res,Attr = theSObject.FindAttribute("AttributeIOR")
+ if (res != 0) and (Attr is not None) :
+ anIOR = Attr._narrow(SALOMEDS.AttributeIOR);
+ aValue = anIOR.Value();
+ if(len(aValue) != 0) :
+ anObj = myORB.string_to_object(aValue);
+ else:
+ print "SObjectToObject - IOR = ''"
+ return anObj;
+
+def CreatePrsForMed(theVisu, theFileName, thePrsTypeList, thePictureDir, thePictureExt) :
+# try:
+ global myLifeCycleCORBA
+ print "lcc.FindOrLoadComponent...",
+ aMedComp = myLifeCycleCORBA.FindOrLoadComponent("FactoryServer", "MED")
+ if aMedComp is None : print "Error"
+ else : print "OK"
+
+ aVISUObjList = [myLocalStudy, myViewManager, myView] = CreateStudyForMed(theVisu, theFileName)
+
+ print "aMedComp.readStructFileWithFieldType...",
+ aMedComp.readStructFileWithFieldType(theFileName,myLocalStudy._get_Name())
+ aMedSObj = getMedSObject(myLocalStudy)
+ if aMedSObj is None : raise RuntimeError, "Error"
+ else : print "OK"
+
+ print "theVisu.ImportMed...",
+ aResult = theVisu.ImportMed(aMedSObj)
+ if aResult is None : raise RuntimeError, "Error"
+ else : print "OK"
+ aVISUObjList.append(aResult)
+ aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt))
+
+ aFolderIter = myLocalStudy.NewChildIterator(aMedSObj.GetFather());
+ while aFolderIter.More() :
+ aFolderSObj = aFolderIter.Value()
+ aFolderIter.Next()
+ anAttr = aFolderSObj.FindAttribute("AttributeName")[1]
+ anAttr = anAttr._narrow(SALOMEDS.AttributeName);
+ aFolderName = anAttr.Value()
+ print " ", aFolderName
+
+ if aFolderName == 'MEDMESH' :
+ aMeshIter = myLocalStudy.NewChildIterator(aFolderSObj);
+ while aMeshIter.More() :
+ aMeshSObj = aMeshIter.Value()
+ aMeshIter.Next()
+ anAttr = aMeshSObj.FindAttribute("AttributeName")[1]
+ anAttr = anAttr._narrow(SALOMEDS.AttributeName);
+ aMeshName = anAttr.Value()
+ print " ", aMeshName
+
+ aSupportIter = myLocalStudy.NewChildIterator(aMeshSObj);
+ while aSupportIter.More() :
+ aSupportSObj = aSupportIter.Value()
+ aSupportIter.Next()
+ anAttr = aSupportSObj.FindAttribute("AttributeName")[1]
+ anAttr = anAttr._narrow(SALOMEDS.AttributeName);
+ aSupportName = anAttr.Value()
+ print " ", aSupportName
+
+ if aFolderName == 'MEDFIELD' :
+ aFieldIter = myLocalStudy.NewChildIterator(aFolderSObj);
+ while aFieldIter.More() :
+ aFieldSObj = aFieldIter.Value()
+ aFieldIter.Next()
+ anAttr = aFieldSObj.FindAttribute("AttributeName")[1]
+ anAttr = anAttr._narrow(SALOMEDS.AttributeName);
+ aFieldName = anAttr.Value()
+ print " ", aFieldName
+
+ print "theVisu.ImportMed...",
+ aResult = theVisu.ImportMed(aFieldSObj)
+ if aResult is None : raise RuntimeError, "Error"
+ else : print "OK"
+ aVISUObjList.append(aResult)
+ aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt))
+
+ aTimeStampIter = myLocalStudy.NewChildIterator(aFieldSObj);
+ if aTimeStampIter.More() :
+ aTimeStampIter.Next()
+ while aTimeStampIter.More() :
+ aTimeStampSObj = aTimeStampIter.Value()
+ aTimeStampIter.Next()
+ anAttr = aTimeStampSObj.FindAttribute("AttributeName")[1]
+ anAttr = anAttr._narrow(SALOMEDS.AttributeName);
+ aTimeStampName = anAttr.Value()
+ print " ", aTimeStampName
+
+ print "theVisu.ImportMed...",
+ aMedField = SObjectToObject(aTimeStampSObj)
+ aResult = theVisu.ImportMedField(aMedField)
+ if aResult is None : raise RuntimeError, "Error"
+ else : print "OK"
+ aVISUObjList.append(aResult)
+ aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt))
+
+ return aVISUObjList
+
+# except Exception, e:
+# print str(e)
+
+def CreatePrsForFile(theVisu, theFileName, thePrsTypeList, thePictureDir, thePictureExt) :
+ # try:
+ aVISUObjList = [myLocalStudy, myViewManager, myView] = CreateStudyForMed(theVisu, theFileName)
+
+ print "theVisu.ImportMed...",
+ aResult = theVisu.ImportFile(theFileName)
+ if aResult is None : raise RuntimeError, "Error"
+ else : print "OK"
+
+ aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt))
+
+ return aVISUObjList
+
+# except Exception, e:
+# print str(e)
+
+def CreatePrsForResult(theVisu, theResult, theView, thePrsTypeList, thePictureDir, thePictureExt) :
+ aVISUObjList = []
+ print "CreatePrsForResult - myLocalStudy.FindObjectIOR...",
+ myLocalStudy = theVisu.GetCurrentStudy()
+ aSObj = myLocalStudy.FindObjectIOR(theResult.GetID())
+ if aSObj is None : raise RuntimeError, "Error"
+ else : print "OK"
+ aMeshIter = myLocalStudy.NewChildIterator(aSObj);
+ while aMeshIter.More() :
+ aMeshSObj = aMeshIter.Value()
+ aMeshIter.Next()
+ anAttr = aMeshSObj.FindAttribute("AttributeName")[1]
+ if anAttr is None :
+ aMeshSObj = aMeshIter.Value()
+ aMeshIter.Next()
+ anAttr = aMeshSObj.FindAttribute("AttributeName")[1]
+ anAttr = anAttr._narrow(SALOMEDS.AttributeName);
+ aMeshName = anAttr.Value()
+ aMeshNamePic = re.sub(".","_",aMeshName)
+ print " ", aMeshName
+
+ aFolderIter = myLocalStudy.NewChildIterator(aMeshSObj);
+ while aFolderIter.More() :
+ aFolderSObj = aFolderIter.Value()
+ aFolderIter.Next()
+ anAttr = aFolderSObj.FindAttribute("AttributeName")[1]
+ anAttr = anAttr._narrow(SALOMEDS.AttributeName);
+ aFolderName = anAttr.Value()
+ print " ", aFolderName
+
+ if aFolderName == 'Families' :
+ anEntityIter = myLocalStudy.NewChildIterator(aFolderSObj);
+ while anEntityIter.More() :
+ anEntitySObj = anEntityIter.Value()
+ anEntityIter.Next()
+ anAttr = anEntitySObj.FindAttribute("AttributeName")[1]
+ anAttr = anAttr._narrow(SALOMEDS.AttributeName);
+ anEntityName = anAttr.Value()
+
+ anEntityId = "3"
+ if anEntityName == 'onNodes' :
+ anEntity = VISU.NODE
+ anEntityId = "0"
+ if anEntityName == 'onEdges' :
+ anEntity = VISU.EDGE
+ anEntityId = "1"
+ if anEntityName == 'onFaces' :
+ anEntity = VISU.FACE
+ anEntityId = "2"
+ if anEntityName == 'onCells' :
+ anEntity = VISU.CELL
+ anEntityId = "3"
+
+ if HasValue(thePrsTypeList,VISU.TMESH) :
+ print " ", anEntityName, aMeshName,
+ aMesh = theVisu.MeshOnEntity(theResult,aMeshName,anEntity)
+ if aMesh is None : print "Error"
+ else :
+ print ",OK"
+ theView.DisplayOnly(aMesh)
+ theView.FitAll()
+ aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "." + thePictureExt
+ aPictureName = re.sub("\s+","_", aPictureName);
+ theView.SavePicture(aPictureName)
+ aVISUObjList.append(aMesh)
+
+ anFamilyIter = myLocalStudy.NewChildIterator(anEntitySObj);
+ while anFamilyIter.More() :
+ aFamilySObj = anFamilyIter.Value()
+ anFamilyIter.Next()
+ anAttr = aFamilySObj.FindAttribute("AttributeName")[1]
+ anAttr = anAttr._narrow(SALOMEDS.AttributeName);
+ anFamilyName = anAttr.Value()
+ if HasValue(thePrsTypeList,VISU.TMESH) :
+ print " ", anFamilyName,
+ aMesh = theVisu.FamilyMeshOnEntity(theResult,aMeshName,anEntity,anFamilyName)
+ if aMesh is None : print "Error"
+ else :
+ print ",OK"
+ theView.DisplayOnly(aMesh)
+ theView.FitAll()
+ aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + anFamilyName + "." + thePictureExt
+ aPictureName = re.sub("\s+","_", aPictureName);
+ theView.SavePicture(aPictureName)
+ aVISUObjList.append(aMesh)
+
+ if aFolderName == 'Groups' :
+ aGroupIter = myLocalStudy.NewChildIterator(aFolderSObj);
+ while aGroupIter.More() :
+ aGroupSObj = aGroupIter.Value()
+ aGroupIter.Next()
+ anAttr = aGroupSObj.FindAttribute("AttributeName")[1]
+ anAttr = anAttr._narrow(SALOMEDS.AttributeName);
+ aGroupName = anAttr.Value()
+ if HasValue(thePrsTypeList,VISU.TMESH) :
+ print " ", aGroupName,
+ aMesh = theVisu.GroupMesh(theResult,aMeshName,aGroupName)
+ if aMesh is None : print "Error"
+ else :
+ print ",OK"
+ theView.DisplayOnly(aMesh)
+ theView.FitAll()
+ aPictureName = thePictureDir + aMeshNamePic + "_" + aGroupName + "." + thePictureExt
+ aPictureName = re.sub("\s+","_", aPictureName);
+ theView.SavePicture(aPictureName)
+ aVISUObjList.append(aMesh)
+
+ if aFolderName == 'Fields' :
+ aFieldIter = myLocalStudy.NewChildIterator(aFolderSObj);
+ while aFieldIter.More() :
+ aFieldSObj = aFieldIter.Value()
+ aFieldIter.Next()
+ anAttr = aFieldSObj.FindAttribute("AttributeName")[1]
+ anAttr = anAttr._narrow(SALOMEDS.AttributeName);
+ aFieldName = anAttr.Value()
+ print " ", aFieldName
+
+ anAttr = aFieldSObj.FindAttribute("AttributeComment")[1]
+ anAttr = anAttr._narrow(SALOMEDS.AttributeComment);
+ aFieldComment = anAttr.Value()
+ aMap = StrToMap(aFieldComment)
+
+ aTimeStampIter = myLocalStudy.NewChildIterator(aFieldSObj);
+ if aTimeStampIter.More() :
+ aTimeStampIter.Next()
+ while aTimeStampIter.More() :
+ aTimeStampSObj = aTimeStampIter.Value()
+ aTimeStampIter.Next()
+ anAttr = aTimeStampSObj.FindAttribute("AttributeName")[1]
+ anAttr = anAttr._narrow(SALOMEDS.AttributeName);
+ aTimeStampName = anAttr.Value()
+ print " ", aTimeStampName
+
+ anAttr = aTimeStampSObj.FindAttribute("AttributeComment")[1]
+ anAttr = anAttr._narrow(SALOMEDS.AttributeComment);
+ aTimeStampComment = anAttr.Value()
+ aMap = StrToMap(aTimeStampComment)
+ aMeshName = aMap["myMeshName"]
+ aFieldName = aMap["myFieldName"]
+ aTimeStampId = atoi(aMap["myTimeStampId"])
+ anEntity = IntToEntity(aMap["myEntityId"])
+ anEntityId = str(aMap["myEntityId"]);
+ #print aMeshName, aFieldName, anEntity, aTimeStampId
+ if HasValue(thePrsTypeList,VISU.TSCALARMAP) :
+ print " Creating ScalarMapOnField",
+ aPrsObj = theVisu.ScalarMapOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
+ if aPrsObj is None : print "Error"
+ else :
+ print ",OK"
+ theView.DisplayOnly(aPrsObj)
+ theView.FitAll()
+ aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TSCALARMAP." + thePictureExt
+ aPictureName = re.sub("\s+","_", aPictureName);
+ theView.SavePicture(aPictureName)
+ aVISUObjList.append(aPrsObj)
+
+ if HasValue(thePrsTypeList,VISU.TISOSURFACE) :
+ print " Creating IsoSurfacesOnField",
+ aPrsObj = theVisu.IsoSurfacesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
+ if aPrsObj is None : print "Error"
+ else :
+ print ",OK"
+ theView.DisplayOnly(aPrsObj)
+ theView.FitAll()
+ aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TISOSURFACE." + thePictureExt
+ aPictureName = re.sub("\s+","_", aPictureName);
+ theView.SavePicture(aPictureName)
+ aVISUObjList.append(aPrsObj)
+
+ if HasValue(thePrsTypeList,VISU.TCUTPLANES) :
+ print " Creating CutPlanesOnField",
+ aPrsObj = theVisu.CutPlanesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
+ if aPrsObj is None : print "Error"
+ else :
+ print ",OK"
+ aPrsObj.SetOrientation(VISU.CutPlanes.ZX,aPrsObj.GetRotateX(),aPrsObj.GetRotateY())
+ theView.DisplayOnly(aPrsObj)
+ theView.FitAll()
+ aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TCUTPLANES." + thePictureExt
+ aPictureName = re.sub("\s+","_", aPictureName)
+ theView.SavePicture(aPictureName)
+ aVISUObjList.append(aPrsObj)
+
+ if HasValue(thePrsTypeList,VISU.TCUTLINES) :
+ print " Creating CutLinesOnField",
+ aPrsObj = theVisu.CutLinesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
+ if aPrsObj is None : print "Error"
+ else :
+ print ",OK"
+ aPrsObj.SetOrientation(VISU.CutPlanes.XY,aPrsObj.GetRotateX(),aPrsObj.GetRotateY())
+ aPrsObj.SetOrientation2(VISU.CutPlanes.ZX,aPrsObj.GetRotateX2(),aPrsObj.GetRotateY2())
+ theView.DisplayOnly(aPrsObj)
+ theView.FitAll()
+ aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TCUTLINES." + thePictureExt
+ aPictureName = re.sub("\s+","_", aPictureName)
+ theView.SavePicture(aPictureName)
+ aVISUObjList.append(aPrsObj)
+
+ if HasValue(thePrsTypeList,VISU.TPLOT3D) :
+ print " Creating Plot3DOnField",
+ aPrsObj = theVisu.Plot3DOnField(theResult,aMeshName,anEntity,
+ aFieldName,aTimeStampId)
+ if aPrsObj is None : print "Error"
+ else :
+ print ",OK"
+ #aPrsObj.SetOrientation(VISU.CutPlanes.ZX,
+ # aPrsObj.GetRotateX(),
+ # aPrsObj.GetRotateY())
+ theView.DisplayOnly(aPrsObj)
+ theView.FitAll()
+ aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TPLOT3D." + thePictureExt
+ aPictureName = re.sub("\s+","_", aPictureName)
+ theView.SavePicture(aPictureName)
+ aVISUObjList.append(aPrsObj)
+
+ aNumComponent = atoi(aMap["myNumComponent"])
+ if aNumComponent > 1 :
+ if HasValue(thePrsTypeList,VISU.TDEFORMEDSHAPE) :
+ print " Creating DeformedShapeOnField",
+ aPrsObj = theVisu.DeformedShapeOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
+ if aPrsObj is None : print "Error"
+ else :
+ print ",OK"
+ theView.DisplayOnly(aPrsObj)
+ theView.FitAll()
+ aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TDEFORMEDSHAPE." + thePictureExt
+ aPictureName = re.sub("\s+","_", aPictureName)
+ theView.SavePicture(aPictureName)
+ aVISUObjList.append(aPrsObj)
+
+ if HasValue(thePrsTypeList,VISU.TVECTORS) :
+ print " Creating VectorsOnField",
+ aPrsObj = theVisu.VectorsOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
+ if aPrsObj is None : print "Error"
+ else :
+ print ",OK"
+ theView.DisplayOnly(aPrsObj)
+ theView.FitAll()
+ aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TVECTORS." + thePictureExt
+ aPictureName = re.sub("\s+","_", aPictureName)
+ theView.SavePicture(aPictureName)
+ aVISUObjList.append(aPrsObj)
+
+ if HasValue(thePrsTypeList,VISU.TSTREAMLINES) :
+ print " Creating StreamLinesOnField",
+ aPrsObj = theVisu.StreamLinesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
+ if aPrsObj is None : print "Error"
+ else :
+ print ",OK"
+ theView.DisplayOnly(aPrsObj)
+ theView.FitAll()
+ aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TSTREAMLINES." + thePictureExt
+ aPictureName = re.sub("\s+","_", aPictureName)
+ theView.SavePicture(aPictureName)
+ aVISUObjList.append(aPrsObj)
+
+ return aVISUObjList
+
+
+def generateName(prefix = None):
+ import whrandom;
+ int = whrandom.randint(1,1000);
+ if prefix is None:
+ return "Study" + str(int)
+ else :
+ return prefix + str(int)
+
+
+
+# ----------------------
+# MESH
+# ----------------------
+def try_mesh_parameters(theMeshPattern):
+ aResult = []
+ if theMeshPattern is None : return aResult ;
+ theMeshPattern = theMeshPattern._narrow(VISU.Mesh)
+ if theMeshPattern is None : return aResult ;
+
+ aTYPES = [VISU.POINT, VISU.WIREFRAME, VISU.SHADED, VISU.INSIDEFRAME, VISU.SHRINK]
+ import copy; import os;
+ for ind in aTYPES:
+ aNewMesh = copy.deepcopy(theMeshPattern);
+ aNewMesh.SetPresentationType(ind)
+ aResult.append(aNewMesh)
+
+ return aResult
+
+
+# ----------------------------
+# SCALAR MAP
+# ----------------------------
+ind=1 #try safe way
+def try_scalarmap_parameters(thePattern, dump = 0):
+
+ if thePattern is None : return None
+
+ SCALING = [VISU.LINEAR, VISU.LOGARITHMIC]
+ import copy
+ import random
+
+ anObj = thePattern#copy.deepcopy(thePattern);
+ #ind = random.randint(1,2)
+ if ind%2 :
+ #try incorrect value deliberately (but allowed by idl description)
+ #try SetScalarMode(long)
+ mode = random.randint(-100000,100000); #incorrect value deliberately
+ else:
+ #correct value of ScalarMode
+ mode = random.randint(0, 3)
+
+ if dump : print "\tSetScalarMode(" + str(mode) +")"
+ anObj.SetScalarMode(mode)
+
+ # --- SCALING ---
+ scal = random.randint(0,1)
+ if dump : print "\tSetScaling(" + str(SCALING[scal]) +")"
+ anObj.SetScaling(SCALING[scal])
+
+ # --- BOUNDARIES ---
+ if ind%2 :
+ alfa = random.random()*random.randint(-100000,100000)
+ betta = random.random()*random.randint(-100000,100000)
+ aMin = alfa; aMax = betta
+ else:
+ #more correct set
+ aPMin = thePattern.GetMin()
+ aPMax = thePattern.GetMax()
+ aLen = aPMax - aPMin
+ alfa = random.random()%0.5
+ betta = random.random()%0.5
+ aMin = alfa*aLen*random.randint(-1,1) + aPMin
+ aMax = betta*aLen*random.randint(-1,1) + aPMax
+ if dump : print "\tSetRange(" + str(aMin) + ", " + str(aMax) + ")"
+ anObj.SetRange(aMin, aMax)
+
+ # --- POSITION ---
+ if ind%2:
+ X=random.random()*random.randint(-100000,100000)
+ Y=random.random()*random.randint(-100000,100000)
+ else :
+ X=random.random()
+ Y=random.random()
+ if dump : print "SetPosition("+ str(X) + ", " + str(Y) + " )"
+ anObj.SetPosition(X, Y)
+
+ # --- SCALAR BAR SIZE ---
+ if ind%2:
+ aWidth=random.random()*random.randint(-100000,100000)
+ aHeight=random.random()*random.randint(-100000,100000)
+ else :
+ aWidth=random.random()
+ aHeight=random.random()
+ if dump : print " SCALAR BAR Width = " + str(aWidth) + " Height = ", str(aHeight)
+ anObj.SetSize(aWidth, aHeight)
+
+ return anObj
+
+
+def dump_scalarmap_parameters(anObj):
+
+ print "\tGetScalarMode() = " + str(anObj.GetScalarMode())
+ print "\tGetScaling() = " + str(anObj.GetScaling())
+ print "\tGetMin() = " + str(anObj.GetMin()) + " GetMax() = " + str (anObj.GetMax())
+ print "\tGetOrientation() = " + str(anObj.GetOrientation())
+ print "\tGetPosX() = ", str(anObj.GetPosX()) + " GetPosY() = ", str(anObj.GetPosY())
+ print "\tGetWidth() = ", str ( anObj.GetWidth()) + " GetHeight() = " + str(anObj.GetHeight())
+
+# ----------------------
+# DEFORMED SHAPE
+# ----------------------
+def try_deformedshape_parameters(thePattern) :
+
+ if thePattern is None : return None
+ import copy
+ import random
+
+ anObj = try_scalarmap_parameters(thePattern)
+
+ # --- SCALING ---
+ if ind%2:
+ anObj.SetScale( random.random()*random.randint(-100000, 100000))
+ else :
+ anObj.SetScale( anObj.GetScale()*random.random())
+
+ return anObj
+
+
+def dump_deformedshape_parameters(theObject):
+ dump_scalarmap_parameters(theObject)
+ print "GetScale() = ", theObject.GetScale()
+
+# ----------------------
+# CUT PLANES
+# ----------------------
+def try_cutplanes_parameters(thePattern) :
+
+ if thePattern is None : return aList
+ import copy
+ import random
+
+ ORIENT = [VISU.CutPlanes.XY, VISU.CutPlanes.YZ, VISU.CutPlanes.ZX]
+
+ ind = random.randint(1,2)
+ anObj = try_scalarmap_parameters(thePattern)
+
+ if ind%2 : anObj.SetNbPlanes(random.randint(-40,40))
+ else : anObj.SetNbPlanes(random.randint(0,10)) #try behaivor if NbPlanes=0
+
+ # --- DISPLACEMENT ---
+ anObj.SetDisplacement(random.randint(-100000,100000))
+
+ # --- PLANE POSITION ---
+ if ind%2:
+ PlaneNb = random.randint(-100000,100000) #incorrect value is possible
+ else : PlaneNb = random.randint(0, anObj.GetNbPlanes())
+
+ anObj.SetPlanePosition(PlaneNb, random.random()*random.randint(-100000,100000))
+
+ # --- SET DEFAULT ---
+ anObj.SetDefault(PlaneNb)
+
+ # --- SET X,Y,Z ROTATION ---
+ if ind%2 :
+ angle1 = random.random()*random.randint(-100000,100000)
+ angle2 = random.random()*random.randint(-100000,100000)
+ else :
+ angle1 = random.random()*3.14
+ angle2 = random.random()*3.14
+
+ # --- ORIENTATION ---
+ anObj.SetOrientation(ORIENT[random.randint(0,2)],angle1,angle2)
+
+ return anObj
+
+def dump_cutplanes_parameters(theObject):
+ dump_saclarmap_parameters(theObject)
+
+ print "GetOrientationType = " + str(theObject.GetOrientationType())
+ PlanesNb = theObject.GetNbPlanes()
+ print "GetNbPlanes() = ", str(PlanesNb)
+ for i in range(0,PlanesNb+1):
+ if theObject.IsDefault(i) :
+ print "Default plane : "+str(i); break
+ print "GetPlanePosition(" + str(i) + ") = ", theObject.GetPlanePosition(i)
+ print "GetDisplacement() = ", str(theObject.GetDisplacement())
+ print "GetRotateX() = ", str(theObject.GetRotateX())
+ print "GetRotateY() = ", str(theObject.GetRotateY())
+ print "GetRotateZ() = ", str(theObject.GetRotateZ())
+
+# ----------------------
+# CUT LINES
+# ----------------------
+def try_cutlines_parameters(thePattern):
+
+ if thePattern is None : return None
+ import copy
+ import random
+
+ ORIENT = [VISU.CutPlanes.XY, VISU.CutPlanes.YZ, VISU.CutPlanes.ZX]
+ ind = random.randint(1,2)
+ anObj = try_scalarmap_parameters(thePattern)
+
+ # --- ORIENTATION ---
+ anObj.SetOrientation(ORIENT[random.randint(0,2)],
+ random.randint(-100,100)*random.random(),
+ random.randint(-100,100)*random.random())
+ anObj.SetOrientation2(ORIENT[random.randint(0,2)],
+ random.randint(-100,100)*random.random(),
+ random.randint(-100,100)*random.random())
+
+ # --- Base Plane Position ---
+ anObj.SetBasePlanePosition( random.random()*random.randint(-100000,100000))
+
+ # --- NUMBER OF LINES ---
+ if ind%2:
+ anObj.SetNbLines(random.randint(-5, 50))
+
+ return anObj
+
+def dump_cutlines_parameters(theObject):
+ dump_scalarmap_parameters(theObject)
+
+ print "GetOrientationType() = " + str(theObject.GetOrientationType())
+ print "GetOrientationType2() = " + str(theObject.GetOrientationType2())
+ print "GetBasePlanePosition() = "+ str(theObject.GetBasePlanePosition())
+ print "GetNbLines() = " + str(theObject.GetNbLines())
+ print "GetRotateX() = ", str(theObject.GetRotateX())
+ print "GetRotateX2() = ", str(theObject.GetRotateX2())
+ print "GetRotateY() = ", str(theObject.GetRotateY())
+ print "GetRotateY2() = ", str(theObject.GetRotateY2())
+
+# ----------------------
+# STREAM LINES
+# ----------------------
+def try_streamlines_parameters(thePattern):
+
+ if thePattern is None : return None
+ import copy
+ import random
+
+ DIRECTION = [VISU.StreamLines.FORWARD, VISU.StreamLines.BACKWARD, VISU.StreamLines.BOTH]
+
+ ind = random.randint(1,2)
+ anObj = (try_deformedshape_parameters(thePattern))[0]
+
+ # --- DIREACTION ---
+ anObj.SetDirection(DIRECTION[random.randint(0,2)])
+
+ # --- STEP LENGTH ---
+ if ind%2 : anObj.SetStepLength(random.random()*random.randint(-1000,1000))
+ else :
+ aLen = anObj.GetMax() - anObj.GetMin()
+ anObj.SetStepLength(aLen/random.randint(1,100))
+
+ # --- PROPAGATION TIME ---
+ anObj.SetPropagationTime(random.random()*random.randint(1,100))
+
+ # --- INTEGRATION STEP ---
+ if ind%2 :
+ anObj.SetIntegrationStep(random.random()*random.randint(-1000,1000))
+ else:
+ anObj.SetIntegrationStep(random.random())
+
+ # --- USED POINT ---
+ anObj.SetUsedPoints(random.random()*random.randint(-10000,10000))
+
+ return anObj
+
+def dump_streamlines_parameters(theObject):
+
+ dump_deformedshape_parameters(theObject)
+
+ print "GetDirection() = " + str(theObject.GetDirection())
+ print "GetStepLength() = " + str(theObject.GetStepLength())
+ print "GetPropagationTime() =" + str(theObject.GetPropagationTime())
+ print "GetIntegrationStep() =" + str(theObject.GetIntegrationStep())
+ print "GetUsedPoints() =" + str(theObject.GetUsedPoints())
+
+# ----------------------
+# VECTORS
+# ----------------------
+def try_vectors_parameters(thePattern, theNum):
+
+ if thePattern is None : return None
+ import copy
+ import random
+ GLIPH_TYPE = [VISU.Vectors.ARROW, VISU.Vectors.CONE2, VISU.Vectors.CONE6, VISU.Vectors.NONE]
+ GLIPH_POS = [VISU.Vectors.CENTER, VISU.Vectors.TAIL, VISU.Vectors.HEAD]
+ ind = random.randint(1,2)
+ anObj = (try_deformedshape_parameters(thePattern))[0]
+
+ # --- LINE WIDTH ---
+ if ind%2 :
+ anObj.SetLineWidth(random.random()*random.randint(-10000,10000))
+ else :
+ anObj.SetLineWidth(random.randint(1, 10))
+
+ # --- GLIPH TYPE ---
+ anObj.SetGlyphType(GLIPH_TYPE[random.randint(0, len(GLIPH_TYPE)-1)])
+
+ # --- GLIPH POS ---
+ anObj.SetGlyphPos(GLIPH_POS[random.randint(0, len(GLIPH_POS)-1)])
+
+ return anObj
+
+def dump_vetctors_parameters(theObject):
+
+ dump_deformedshape_parameters(theObject)
+
+ print "GetLineWidth() = " +str(theObject.GetLineWidth())
+ print "GetGlyphType() = " +str(theObject.GetGlyphType())
+ print "GetGlyphPos() = " +str(theObject.GetGlyphPos())
+
+
+# ----------------------
+# ISO SURFACES
+# ----------------------
+
+def try_isosurfaces_parameters(thePattern) :
+ if thePattern is None : return None
+ import copy
+ import random
+
+ anObj = try_scalarmap_parameters(thePattern)
+ ind = random.randint(1,2)
+ # --- SURFACES NUMBER ---
+ if ind%2 :
+ anObj.SetNbSurfaces(random.randint(-100000,100000))
+ else:
+ anObj.SetNbSurfaces(random.randint(1, 50))
+
+ return anObj
+
+def dump_isosurfaces_parameters(theObject):
+
+ dump_scalarmap_parameters(theObject)
+ print "GetNbSurfaces() = "+ str(theObject.GetNbSurfaces())
+
+
+# ----------------------
+# TABLES AND CURVES
+# ----------------------
+
+def FillTable( theTable, theValues, theRows, theColumns, theRowTitles, theRowUnits, theColumnTitles ):
+ if theTable is None: return
+ if len(theRows) != len(theColumns): return
+ if len(theRows) != len(theValues): return
+ i = 0
+ for value in theValues:
+ theTable.PutValue( value, theRows[ i ], theColumns[ i ])
+ i = i + 1
+ pass
+ i = 1
+ for title in theRowTitles:
+ theTable.SetRowTitle( i, title )
+ theTable.SetRowUnit( i, theRowUnits[ i - 1 ])
+ i = i + 1
+ pass
+ i = 1
+ for title in theColumnTitles:
+ theTable.SetColumnTitle( i, title )
+ i = i + 1
+ pass
+ pass
+
+def CreateCurve( theTable, theHRow, theVRow, theTitle, theColor, theMarker, theLineType, theLineWidth ):
+ if theTitle is None: return
+ curve = myLocalVisu.CreateCurve( theTable, theHRow, theVRow );
+ if curve:
+ curve.SetTitle( theTitle )
+ curve.SetColor( theColor )
+ curve.SetMarker( theMarker )
+ curve.SetLine( theLineType, theLineWidth )
+ pass
+ return curve
--- /dev/null
+import VISU
+import SALOMEDS
+from visu_gui import *
+
+myViewManager = myVisu.GetViewManager();
+myView = myViewManager.Create3DView();
+
+medFile = "fra.med"
+myFieldName = "VITESSE";
+
+aMeshName ="LE VOLUME"
+anEntity = VISU.NODE
+aTimeStampId = 1
+
+medFile = os.getenv('DATA_DIR') + '/MedFiles/' + medFile
+myResult = myVisu.ImportFile(medFile)
+
+aScalarMap = myVisu.ScalarMapOnField(myResult,aMeshName,anEntity,myFieldName,aTimeStampId)
+myView.Display(aScalarMap);
+myView.FitAll();
+
+aCutPlanes = myVisu.CutPlanesOnField(myResult,aMeshName,anEntity,myFieldName,aTimeStampId)
+myView = myViewManager.Create3DView();
+myView.Display(aCutPlanes);
+myView.FitAll();
+
+myVisu.DeletePrs3d(aScalarMap)
+myVisu.DeleteResult(myResult)
--- /dev/null
+# VISU VISU_SWIG : binding of C++ implementation and Python
+#
+# Copyright (C) 2003 CEA/DEN, EDF R&D
+#
+#
+#
+# File : visu_med.py
+# Module : VISU
+
+import os
+import salome
+import SALOMEDS
+import SALOME_MED
+import VISU
+
+from libSALOME_Swig import *
+sg = SALOMEGUI_Swig()
+
+def getMedObjectFromStudy():
+ mySO = salome.myStudy.FindObject("Objet MED")
+ anAttr = mySO.FindAttribute("AttributeIOR")[1]
+ obj = salome.orb.string_to_object(anAttr.Value())
+ myObj = obj._narrow(SALOME_MED.MED)
+ return myObj
+
+def getFieldObjectFromStudy(number,subnumber):
+ mySO = salome.myStudy.FindObject("MEDFIELD")
+ mysub = mySO.FindSubObject(number)[1]
+ if mysub:
+ mysubsub = mysub.FindSubObject(subnumber)[1]
+ if mysubsub:
+ Builder = salome.myStudy.NewBuilder()
+ anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeIOR")
+ obj = salome.orb.string_to_object(anAttr.Value())
+ myObj = obj._narrow(SALOME_MED.FIELDINT)
+ if (myObj == None):
+ myObj = obj._narrow(SALOME_MED.FIELDDOUBLE)
+ return myObj
+ else:
+ print "ERROR: No Field Object stored in this Study"
+ return None
+
+med_comp = salome.lcc.FindOrLoadComponent("FactoryServer", "MED")
+
+medDir = os.getenv('DATA_DIR') + '/MedFiles/'
+
+def importMedFrom(medDir,medFile):
+ medFile = medDir + medFile
+ med_comp.readStructFileWithFieldType(medFile,salome.myStudyName)
+ sg.updateObjBrowser(1)
+
+def importMed(medFile):
+ importMedFrom(medDir,medFile)
+
+#med_obj = getMedObjectFromStudy()
+myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU")
+print "Use importMed(medFile) or importMedFrom(medDir,medFile) functions !"
+
+#myField = getFieldObjectFromStudy(2,1)
+#myResult = myVisu.ImportMed(myField)
+#aMesh = myVisu.CreateMesh(myResult);
+#aScalarMap = myVisu.CreateScalarMap(myResult,myField.getName(),0)
+#if(myField.getNumberOfComponents() > 1) :
+# aScalarMap = myVisu.CreateVectors(myResult,myField.getName(),0)
+
+#myResult = myVisu.ImportFile(medFile)
+#aMesh = myVisu.CreateMesh(myResult);
+#aScalarMap = myVisu.CreateScalarMap(myResult,myField.getName(),0)
+#if(myField.getNumberOfComponents() > 1) :
+# aScalarMap = myVisu.CreateCutPlanes(myResult,myField.getName(),0)
--- /dev/null
+# VISU VISU_SWIG : binding of C++ implementation and Python
+#
+# Copyright (C) 2003 CEA/DEN, EDF R&D
+#
+#
+#
+# File : visu_prs_exam.py
+# Module : VISU
+
+import sys
+import os
+import salome
+import SALOMEDS
+import SALOME
+import SALOME_MED
+import VISU
+
+from libSALOME_Swig import *
+sg = SALOMEGUI_Swig()
+
+import visu_gui
+myVisu = visu_gui.myVisu
+
+medFile = "pointe.med"
+medFile = os.getenv('DATA_DIR') + '/MedFiles/' + medFile
+print medFile
+
+studyCurrent = salome.myStudyName
+
+med_comp = salome.lcc.FindOrLoadComponent("FactoryServer", "MED")
+#myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "Visu")
+
+try:
+ if os.access(medFile, os.R_OK) :
+ if os.access(medFile, os.W_OK) :
+ med_comp.readStructFileWithFieldType(medFile,studyCurrent)
+ med_obj = visu_gui.visu.getMedObjectFromStudy()
+ print "med_obj - ", med_obj
+
+ myField = visu_gui.visu.getFieldObjectFromStudy(2,1)
+ aMeshName = "FILED_DOUBLE_MESH"
+ anEntity = VISU.NODE
+ aTimeStampId = 0
+
+ myResult1 = myVisu.ImportMedField(myField)
+ aMesh1 = myVisu.MeshOnEntity(myResult1, aMeshName, anEntity);
+
+ aScalarMap1= myVisu.ScalarMapOnField(myResult1, aMeshName, anEntity, myField.getName(), aTimeStampId)
+ if(myField.getNumberOfComponents() > 1) :
+ aVectors = myVisu.VectorsOnField(myResult1, aMeshName, anEntity, myField.getName(), aTimeStampId)
+
+ myResult2 = myVisu.ImportFile(medFile)
+ aMeshName = "maa1"
+ anEntity = VISU.NODE
+ aMesh2 = myVisu.MeshOnEntity(myResult2, aMeshName, anEntity)
+
+ aScalarMap2 = myVisu.ScalarMapOnField(myResult2, aMeshName, anEntity, myField.getName(), aTimeStampId)
+ if(myField.getNumberOfComponents() > 1) :
+ aCutPlanes = myVisu.CutPlanesOnField(myResult2, aMeshName, anEntity, myField.getName(), aTimeStampId)
+
+ sg.updateObjBrowser(0)
+ else : print "We have no permission to rewrite medFile, so readStructFileWithFieldType can't open this file";
+ else : print "We have no permission to read medFile, it will not be opened";
+except:
+ if sys.exc_type == SALOME.SALOME_Exception :
+ print "There is no permission to read " + medFile
+ else :
+ print sys.exc_type
+ print sys.exc_value
+ print sys.exc_traceback
+
--- /dev/null
+from libVISU_Swig import *
+medFile = os.getenv('DATA_DIR') + '/MedFiles/fra.med'
+myCon=Convertor(medFile)
+myPrs=ScalarMap(myCon,"LE VOLUME",0,"VITESSE",1)
+myView=View3D()
+myView.Display(myPrs)
--- /dev/null
+# VISU VISU_SWIG : binding of C++ implementation and Python
+#
+# Copyright (C) 2003 CEA/DEN, EDF R&D
+#
+#
+#
+# File : batchmode_visu_view3d.py
+# Module : VISU
+
+import os
+import time
+import math
+import VISU
+import SALOMEDS
+from visu_gui import *
+
+aDelay = 0
+
+#mySession = batchmode_visu.mySession
+
+myViewManager = myVisu.GetViewManager();
+
+myView = myViewManager.Create3DView();
+myView.SetTitle("The window will be soon destroyed!")
+print "myViewManager.Create3DView()"
+time.sleep(aDelay)
+
+myView.Maximize()
+print "myView.Maximize()"
+time.sleep(aDelay)
+
+myView.Restore()
+print "myView.Restore()"
+time.sleep(aDelay)
+
+myView.Minimize()
+print "myView.Minimize()"
+time.sleep(aDelay)
+
+myViewManager.Destroy(myView)
+print "myViewManager.Destroy(myView)"
+time.sleep(aDelay)
+
+
+
+medFile = "fra.med"
+myFieldName = "VITESSE";
+
+aMeshName ="LE VOLUME"
+anEntity = VISU.NODE
+aTimeStampId = 1
+
+medFile = os.getenv('DATA_DIR') + '/MedFiles/' + medFile
+myResult = myVisu.ImportFile(medFile)
+
+
+
+myView = myViewManager.Create3DView();
+
+print "myView.SetBackground(...)"
+aColor = SALOMEDS.Color(0.0,0.3,1.0)
+myView.SetBackground(aColor);
+
+myView.SetTitle("The viewer will display ScalarMap")
+print "myViewManager.Create3DView()"
+
+aScalarMap = myVisu.ScalarMapOnField(myResult,aMeshName,anEntity,myFieldName,aTimeStampId)
+
+myView.Display(aScalarMap);
+print "myView.Display(aScalarMap)"
+myView.SetFocalPoint([0,0,0]);
+print "myView.SetFocalPoint(...)"
+myView.SetParallelScale(2);
+print "myView.SetParallelScale(...)"
+myView.FitAll();
+
+aMax = aScalarMap.GetMax()
+aMin = aScalarMap.GetMin()
+aDelta = (aMax - aMin)/2.0
+aNbColors = aScalarMap.GetNbColors()
+aNbColors = 64
+for i in range(2,aNbColors) :
+ aScalarMap.SetNbColors(i)
+ aX = aMin + aDelta*i/aNbColors
+ aY = aMax - aDelta*i/aNbColors
+ aScalarMap.SetRange(aX,aY)
+ myView.Update();
+ time.sleep(aDelay)
+
+aScalarMap.SetRange(aMin,aMax)
+
+print "myView.Update()"
+myView.Update();
+print "myView.FitAll()"
+myView.FitAll();
+
+#aWidth = myView.GetViewWidth()
+#print "a View Width before = ", aWidth
+#myView.SetViewWidth(aWidth/2)
+#aWidth = myView.GetViewWidth()
+#print "a View Width after = ", aWidth
+
+
+myView = myViewManager.Create3DView();
+myView.SetTitle("Here we will display CutPlanes")
+
+myView.SplitRight()
+
+print "myView.SetBackground(...)"
+aColor = SALOMEDS.Color(0.0,0.7,0.0)
+myView.SetBackground(aColor);
+
+aCutPlanes = myVisu.CutPlanesOnField(myResult,aMeshName,anEntity,myFieldName,aTimeStampId)
+print "myVisu.CutPlanesOnField(...)"
+
+myView.DisplayOnly(aCutPlanes);
+print "myView.DisplayOnly(aCutPlanes)"
+
+aPoint = myView.GetPointOfView();
+aPoint[0] = aPoint[0] + 10;
+myView.SetPointOfView(aPoint);
+print "myView.SetPointOfView(...)"
+myView.ScaleView(VISU.View3D.YAxis,10.0);
+myView.ScaleView(VISU.View3D.XAxis,3.0);
+print "myView.ScaleView(...)"
+time.sleep(aDelay)
+
+myView.FitAll();
+
+aNbPlanes = aCutPlanes.GetNbPlanes()
+aNbPlanes = 30
+aXAngle = aCutPlanes.GetRotateX()
+aYAngle = aCutPlanes.GetRotateY()
+anOrientation = aCutPlanes.GetOrientationType()
+for i in range(aNbPlanes,1,-1) :
+ aCutPlanes.SetNbPlanes(i)
+ aX = math.pi/2.0*(aNbPlanes-i)/aNbPlanes
+ aY = math.pi/2.0*(aNbPlanes-i)/aNbPlanes
+ aCutPlanes.SetOrientation(anOrientation,aX,aY)
+ myView.Update();
+ time.sleep(aDelay)
+
+aNbPlanes = 10
+aCutPlanes.SetOrientation(VISU.CutPlanes.ZX,0,0)
+for i in range(1,aNbPlanes) :
+ aCutPlanes.SetNbPlanes(i)
+ myView.Update();
+ time.sleep(aDelay)
+
+myView.SaveViewParams('AAA')
+print "myView.SaveViewParams('AAA')"
+time.sleep(aDelay)
+
+aCutPlanes.SetOrientation(VISU.CutPlanes.XY,0,0)
+myView.RemoveScale();
+
+print "myView.Update()"
+myView.Update();
+print "myView.FitAll()"
+myView.FitAll();
+
+
+
+myView = myViewManager.Create3DView();
+print "myViewManager.Create3DView()"
+
+myView.SetTitle("IsoSurface's viewer")
+
+print "myView.SetBackground(...)"
+aColor = SALOMEDS.Color(1.0,0.7,0.0)
+myView.SetBackground(aColor);
+time.sleep(aDelay)
+
+aIsoSurfaces = myVisu.IsoSurfacesOnField(myResult, aMeshName, anEntity, myFieldName, aTimeStampId)
+
+myView.DisplayOnly(aIsoSurfaces);
+myView.FitAll();
+print "myView.DisplayOnly(aCutPlanes)"
+time.sleep(aDelay)
+
+aNbSurfaces = aIsoSurfaces.GetNbSurfaces()
+aNbSurfaces = 32
+for i in range(2,aNbSurfaces) :
+ aIsoSurfaces.SetNbSurfaces(i)
+ myView.Update();
+ time.sleep(aDelay)
+
+aIsoSurfaces.SetNbSurfaces(10)
+
+print "myView.Update()"
+myView.Update();
+print "myView.FitAll()"
+myView.FitAll();
+
+
+
+myView = myViewManager.Create3DView();
+myView.SetTitle("The viewer for CutLines")
+print "myViewManager.Create3DView()"
+time.sleep(aDelay)
+
+print "myView.SetBackground(...)"
+aColor = SALOMEDS.Color(0.7,0.7,0.7)
+myView.SetBackground(aColor);
+time.sleep(aDelay)
+
+aCutLines = myVisu.CutLinesOnField(myResult, aMeshName, anEntity, myFieldName, aTimeStampId)
+aCutLines.SetOrientation(VISU.CutPlanes.ZX,0,0)
+aCutLines.SetOrientation2(VISU.CutPlanes.YZ,0,0)
+
+myView.DisplayOnly(aCutLines);
+myView.FitAll();
+print "myView.DisplayOnly(aCutLines)"
+time.sleep(aDelay)
+
+aSObj = myStudy.FindObjectIOR(aCutLines.GetID())
+aTable = myVisu.CreateTable( aSObj.GetID() )
+print "myVisu.CreateTable(...)"
+
+aTableView = myViewManager.CreateTableView(aTable)
+aTableView.SetTitle('Changed Title')
+
+aContainer = myVisu.CreateContainer()
+print "myVisu.CreateContainer(...)"
+
+aNbCurve = aTable.GetNbRows() - 1
+for i in range(2,aNbCurve):
+ aCurve = myVisu.CreateCurve( aTable, 1, i )
+ print i, aCurve
+ aContainer.AddCurve(aCurve)
+
+
+myView = myViewManager.CreateXYPlot();
+myView.SetTitle("The viewer for Curves from CutLines")
+print "myViewManager.CreateXYPlot()"
+time.sleep(aDelay)
+
+myView.Display(aContainer)
+
+
+
+myView = myViewManager.Create3DView();
+myView.SetTitle("The viewer for Animation")
+print "myViewManager.Create3DView()"
+time.sleep(aDelay)
+
+medFile = "TimeStamps.med"
+myFieldName = "vitesse";
+
+medFile = os.getenv('DATA_DIR') + '/MedFiles/' + medFile
+myResult = myVisu.ImportFile(medFile)
+
+anAnim = myVisu.CreateAnimation(myView);
+aSObj = myStudy.FindObjectIOR(myResult.GetID())
+aSObj = aSObj.FindSubObject(1)[1]
+aSObj = aSObj.FindSubObject(2)[1]
+aSObj = aSObj.FindSubObject(2)[1]
+anAnim.addField(aSObj)
+anAnim.setPresentationType(0,VISU.TISOSURFACE)
+print "Generate presentations"
+anAnim.generatePresentations(0)
+print "Generate frames"
+anAnim.generateFrames()
+print "Start Animation"
+anAnim.setSpeed(99)
+#anAnim.setCycling(1)
+anAnim.startAnimation()
+myView.FitAll()
+while 1:
+ time.sleep(1+aDelay)
+ if not anAnim.isRunning():
+ anAnim.stopAnimation()
+ break
+
+#anAnim.clearView()