From ff6dccc6ed747760ef8f7fb14afbf44a643f12cd Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 21 Nov 2005 14:37:56 +0000 Subject: [PATCH] This commit was generated by cvs2git to create branch 'BR-D5-38-2003'. Cherrypick from master 2005-11-21 14:37:55 UTC akk '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 --- Makefile.in | 93 ++ src/OBJECT/VISU_ScalarMapAct.h | 62 ++ src/VISUGUI/VisuGUI_CutLinesDlg.h | 106 +++ src/VISUGUI/VisuGUI_Selection.h | 92 ++ src/VISUGUI/VisuGUI_SetupPlot2dDlg.cxx | 687 ++++++++++++++ src/VISUGUI/VisuGUI_SetupPlot2dDlg.h | 111 +++ src/VISU_I/VISUConfig.cc | 496 ++++++++++ src/VISU_I/VISU_DumpPython.cc | 1189 ++++++++++++++++++++++++ src/VISU_I/VISU_View_i.hh | 306 ++++++ src/VISU_SWIG/VISU_Example_03.py | 60 ++ src/VISU_SWIG/VISU_Example_05.py | 77 ++ src/VISU_SWIG/batchmode_visu_view3d.py | 268 ++++++ src/VISU_SWIG/visu.py | 929 ++++++++++++++++++ src/VISU_SWIG/visu_delete.py | 28 + src/VISU_SWIG/visu_med.py | 70 ++ src/VISU_SWIG/visu_prs_example.py | 71 ++ src/VISU_SWIG/visu_swig_test.py | 6 + src/VISU_SWIG/visu_view3d.py | 275 ++++++ 18 files changed, 4926 insertions(+) create mode 100644 Makefile.in create mode 100644 src/OBJECT/VISU_ScalarMapAct.h create mode 100644 src/VISUGUI/VisuGUI_CutLinesDlg.h create mode 100644 src/VISUGUI/VisuGUI_Selection.h create mode 100644 src/VISUGUI/VisuGUI_SetupPlot2dDlg.cxx create mode 100644 src/VISUGUI/VisuGUI_SetupPlot2dDlg.h create mode 100644 src/VISU_I/VISUConfig.cc create mode 100644 src/VISU_I/VISU_DumpPython.cc create mode 100644 src/VISU_I/VISU_View_i.hh create mode 100644 src/VISU_SWIG/VISU_Example_03.py create mode 100644 src/VISU_SWIG/VISU_Example_05.py create mode 100644 src/VISU_SWIG/batchmode_visu_view3d.py create mode 100644 src/VISU_SWIG/visu.py create mode 100644 src/VISU_SWIG/visu_delete.py create mode 100644 src/VISU_SWIG/visu_med.py create mode 100644 src/VISU_SWIG/visu_prs_example.py create mode 100644 src/VISU_SWIG/visu_swig_test.py create mode 100644 src/VISU_SWIG/visu_view3d.py diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 00000000..519f470b --- /dev/null +++ b/Makefile.in @@ -0,0 +1,93 @@ +# -* 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 + diff --git a/src/OBJECT/VISU_ScalarMapAct.h b/src/OBJECT/VISU_ScalarMapAct.h new file mode 100644 index 00000000..1d8197a1 --- /dev/null +++ b/src/OBJECT/VISU_ScalarMapAct.h @@ -0,0 +1,62 @@ +// 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 diff --git a/src/VISUGUI/VisuGUI_CutLinesDlg.h b/src/VISUGUI/VisuGUI_CutLinesDlg.h new file mode 100644 index 00000000..f196660e --- /dev/null +++ b/src/VISUGUI/VisuGUI_CutLinesDlg.h @@ -0,0 +1,106 @@ +// 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 +#include + +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 diff --git a/src/VISUGUI/VisuGUI_Selection.h b/src/VISUGUI/VisuGUI_Selection.h new file mode 100644 index 00000000..4fc4f265 --- /dev/null +++ b/src/VISUGUI/VisuGUI_Selection.h @@ -0,0 +1,92 @@ +// 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 + +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 diff --git a/src/VISUGUI/VisuGUI_SetupPlot2dDlg.cxx b/src/VISUGUI/VisuGUI_SetupPlot2dDlg.cxx new file mode 100644 index 00000000..120785fa --- /dev/null +++ b/src/VISUGUI/VisuGUI_SetupPlot2dDlg.cxx @@ -0,0 +1,687 @@ +// 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 +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#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 rowTitles = tblIntAttr->GetRowTitles(); + vector 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 rowTitles = tblRealAttr->GetRowTitles(); + vector 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& 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& 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 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 rowTitles = tblIntAttr->GetRowTitles(); + vector 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 rowTitles = tblRealAttr->GetRowTitles(); + vector 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 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 button is clicked +*/ +void VisuGUI_SetupPlot2dDlg::onVBtnToggled( bool on ) +{ + VisuGUI_ItemContainer* item = ( VisuGUI_ItemContainer* )sender(); + QPtrList 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 check box +*/ +void VisuGUI_ItemContainer::onAutoChanged() +{ + updateState(); + emit( autoClicked() ); +} +/*! + button slot, invokes color selection dialog box +*/ +void VisuGUI_ItemContainer::onColorChanged() +{ + QColor color = QColorDialog::getColor( getColor() ); + if ( color.isValid() ) { + setColor( color ); + } +} +/*! + and 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 ); + } +} + + + + + diff --git a/src/VISUGUI/VisuGUI_SetupPlot2dDlg.h b/src/VISUGUI/VisuGUI_SetupPlot2dDlg.h new file mode 100644 index 00000000..1ce1e2aa --- /dev/null +++ b/src/VISUGUI/VisuGUI_SetupPlot2dDlg.h @@ -0,0 +1,111 @@ +// 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 + +#include +#include + +//================================================================================= +// 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& container ); + void getCurvesSource( int& horIndex, QValueList& 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 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 + diff --git a/src/VISU_I/VISUConfig.cc b/src/VISU_I/VISUConfig.cc new file mode 100644 index 00000000..56ef09c5 --- /dev/null +++ b/src/VISU_I/VISUConfig.cc @@ -0,0 +1,496 @@ +// 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 +#include + +#include + +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 : "<lock(); + } + + Mutex::~Mutex(){ + if(!(--mySCnt)) + myMutex->unlock(); + if(MYDEBUG) MESSAGE("Mutex::~Mutex : "<> 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="<second)(theSObject,thePrefix,aMap); + } + }catch(std::logic_error& exc){ + INFOS("Follow exception was occured :\n"<> there is no value for "<> 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 = "<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 = "<StudyId()<<"; anEntry = "<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(); iGetFatherComponent()->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); + } +} diff --git a/src/VISU_I/VISU_DumpPython.cc b/src/VISU_I/VISU_DumpPython.cc new file mode 100644 index 00000000..91b8ef80 --- /dev/null +++ b/src/VISU_I/VISU_DumpPython.cc @@ -0,0 +1,1189 @@ +// 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 +#include +#include + +#include +#include + +//#define COUT + +using namespace std; + +namespace VISU{ + static std::string PREFIX(" "); + + typedef std::map TName2EntryMap; + typedef std::map 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 - "< "<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<GetMeshName()<<"'"<< + ","<GetFieldName()<<"'"<< + ","<GetIteration()<< + ")"<GetScalarMode()<<")"<GetScaling()){ + case LINEAR: + aParam = "VISU.LINEAR"; + break; + case LOGARITHMIC: + aParam = "VISU.LOGARITHMIC"; + break; + } + theStr<GetMin()<<","<GetMax()<<")"<GetBarOrientation()){ + case ScalarMap::HORIZONTAL: + aParam = "VISU.ScalarMap.HORIZONTAL"; + break; + case ScalarMap::VERTICAL: + aParam = "VISU.ScalarMap.VERTICAL"; + break; + } + theStr<GetPosX()<<","<GetPosY()<<")"<GetWidth()<<","<GetHeight()<<")"<GetNbColors()<<")"<GetLabels()<<")"<GetTitle()<<"')"<GetScale()<<")"<IsColored()<<")"<GetColor(); + theStr< + 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<GetTitle(); + theStr<GetNbColumns(); + theStr<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<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(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<FindSubObject(1,aRefSObj)){ + SALOMEDS::SObject_var aTargetRefSObj; + if(aRefSObj->ReferencedObject(aTargetRefSObj)){ + CORBA::String_var aString = aTargetRefSObj->GetName(); + theStr<(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<GetMeshName()<<"'"<< + ","<GetMeshName()<<"'"<< + ","<GetMeshName()<<"'"<< + ",'"<GetNodeColor(); + theStr<GetLinkColor(); + theStr<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<(GetServant(anObj).in())){ + thePrefix = ScalarMapToPython(theSObject,aServant,theStr,aName,"ScalarMapOnField",theArgumentName,thePrefix); + theStr<(GetServant(anObj).in())){ + thePrefix = DeformedShapeToPython(theSObject,aServant,theStr,aName,"DeformedShapeOnField",theArgumentName,thePrefix); + theStr<(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<GetSource(); + if(!CORBA::is_nil(aPrs3d)){ + if(Prs3d_i* aServant3d = dynamic_cast(GetServant(aPrs3d).in())){ + SALOMEDS::SObject_var aSObject = aServant3d->GetSObject(); + CORBA::String_var anID = aSObject->GetID(); + std::string anArg = theEntry2NameMap[anID.in()]; + theStr<GetIntegrationStep()<<","<< + aServant->GetPropagationTime()<<","<< + aServant->GetStepLength()<<","<< + "aPrs3d"<<","<< + aServant->GetUsedPoints()<<","<< + aParam<< + ")"<(GetServant(anObj).in())){ + thePrefix = DeformedShapeToPython(theSObject,aServant,theStr,aName,"VectorsOnField",theArgumentName,thePrefix); + + theStr<GetLineWidth()<<")"<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<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<(GetServant(anObj).in())){ + thePrefix = ScalarMapToPython(theSObject,aServant,theStr,aName,"IsoSurfacesOnField",theArgumentName,thePrefix); + theStr<GetNbSurfaces()<<")"<(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<GetRotateX()<<","<GetRotateY()<<")"<GetDisplacement()<<")"<GetNbPlanes(); + theStr<IsDefault(anId)) + theStr<GetPlanePosition(anId)<<")"<(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<GetRotateX()<<","<GetRotateY()<<")"<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<GetRotateX2()<<","<GetRotateY2()<<")"<GetDisplacement()<<")"<GetDisplacement2()<<")"<IsDefault()) + theStr<GetBasePlanePosition()<<")"<GetNbLines(); + theStr<IsDefaultPosition(anId)) + theStr<GetLinePosition(anId)<<")"<(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<GetRotateX()<<","<GetRotateY()<<")"<GetPlanePosition()<<","<IsPositionRelative()<<")"<GetScaleFactor()<<")"<GetIsContourPrs()<<")"<GetNbOfContours()<<")"<(GetServant(anObj).in())) + { + theStr << thePrefix << "aName2ObjectMap['" << aName << "'] = visu.CreateCurve(" << + theArgumentName<< // table + ","<GetHRow()<< // H row + ","<GetVRow()<< // V row + ",'"<GetTitle()<<"'"; // title + SALOMEDS::Color aColor = aServant->GetColor(); + theStr << ",SALOMEDS.Color("<< + aColor.R<<","<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<<","<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<<","<GetLineWidth()<<")"<(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<Tag(); + theStr<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<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<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<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<>> 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) + +# ============================================================================ diff --git a/src/VISU_SWIG/batchmode_visu_view3d.py b/src/VISU_SWIG/batchmode_visu_view3d.py new file mode 100644 index 00000000..f5154355 --- /dev/null +++ b/src/VISU_SWIG/batchmode_visu_view3d.py @@ -0,0 +1,268 @@ +# 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() diff --git a/src/VISU_SWIG/visu.py b/src/VISU_SWIG/visu.py new file mode 100644 index 00000000..037cc764 --- /dev/null +++ b/src/VISU_SWIG/visu.py @@ -0,0 +1,929 @@ +# 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 diff --git a/src/VISU_SWIG/visu_delete.py b/src/VISU_SWIG/visu_delete.py new file mode 100644 index 00000000..d001d601 --- /dev/null +++ b/src/VISU_SWIG/visu_delete.py @@ -0,0 +1,28 @@ +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) diff --git a/src/VISU_SWIG/visu_med.py b/src/VISU_SWIG/visu_med.py new file mode 100644 index 00000000..04715e52 --- /dev/null +++ b/src/VISU_SWIG/visu_med.py @@ -0,0 +1,70 @@ +# 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) diff --git a/src/VISU_SWIG/visu_prs_example.py b/src/VISU_SWIG/visu_prs_example.py new file mode 100644 index 00000000..1453c5ad --- /dev/null +++ b/src/VISU_SWIG/visu_prs_example.py @@ -0,0 +1,71 @@ +# 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 + diff --git a/src/VISU_SWIG/visu_swig_test.py b/src/VISU_SWIG/visu_swig_test.py new file mode 100644 index 00000000..411e532e --- /dev/null +++ b/src/VISU_SWIG/visu_swig_test.py @@ -0,0 +1,6 @@ +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) diff --git a/src/VISU_SWIG/visu_view3d.py b/src/VISU_SWIG/visu_view3d.py new file mode 100644 index 00000000..d1bf0721 --- /dev/null +++ b/src/VISU_SWIG/visu_view3d.py @@ -0,0 +1,275 @@ +# 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() -- 2.39.2