From: admin Date: Wed, 1 Dec 2004 10:50:47 +0000 (+0000) Subject: Merge with version on tag OCC-V2_1_0d X-Git-Tag: V2_1_0b1~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=55d716c5e69656916a6070607a89fb446144fea8;p=modules%2Fvisu.git Merge with version on tag OCC-V2_1_0d --- diff --git a/INSTALL b/INSTALL index a1ae4a8a..56f49b1d 100644 --- a/INSTALL +++ b/INSTALL @@ -1,4 +1,4 @@ -This is the version 2.0.0 of VISU +This is the version 2.1.0 of VISU Compatible with : - - KERNEL 2.0.0 - - MED 2.0.0 + - KERNEL 2.1.0 + - MED 2.1.0 diff --git a/adm_local/unix/config_files/check_Med.m4 b/adm_local/unix/config_files/check_Med.m4 index 49272705..727bf438 100644 --- a/adm_local/unix/config_files/check_Med.m4 +++ b/adm_local/unix/config_files/check_Med.m4 @@ -22,20 +22,11 @@ if test "x$MED_DIR" == "x" ; then # MED_ROOT_DIR environment variable defined MED_DIR=$MED_ROOT_DIR - else - - # search Med binaries in PATH variable - AC_PATH_PROG(TEMP, libMEDMEM_Swig.py) - if test "x$TEMP" != "x" ; then - MED_BIN_DIR=`dirname $TEMP` - MED_DIR=`dirname $MED_BIN_DIR` - fi - fi # fi -if test -f ${MED_DIR}/bin/salome/libMEDMEM_Swig.py ; then +if test -f ${MED_DIR}/idl/salome/MED.idl ; then Med_ok=yes AC_MSG_RESULT(Using Med module distribution in ${MED_DIR}) diff --git a/bin/VERSION b/bin/VERSION index 5b88fed5..1369d8c2 100755 --- a/bin/VERSION +++ b/bin/VERSION @@ -1 +1 @@ -THIS IS SALOME - VISU VERSION: 2.0.0 +THIS IS SALOME - VISU VERSION: 2.1.0 diff --git a/doc/salome/tui/VISU/HTML/VISU_Gen.html b/doc/salome/tui/VISU/HTML/VISU_Gen.html index 13cb79ce..5d4af0b6 100644 --- a/doc/salome/tui/VISU/HTML/VISU_Gen.html +++ b/doc/salome/tui/VISU/HTML/VISU_Gen.html @@ -130,10 +130,6 @@
IDL file
Python
- -
void Destroy ( )
-
Destroy ( )
-
@@ -183,8 +179,8 @@ - - + + @@ -211,12 +207,12 @@ - - + + - - + + @@ -307,14 +303,22 @@ - - + + + + + + + + + + @@ -346,22 +350,6 @@ - - - - - - - - - - - - - - - -
Python
void SetScalarMode ( in long theScaling )
SetScalarMode ( theScaling )
void SetScalarMode ( in long theScalarMode )
SetScalarMode ( theScalarMode )
long GetScalarMode ( )
return_value = GetMax ( )
void SetOrientation ( in Orientation theOrientation )
SetOrientation ( theOrientation )
void SetBarOrientation ( in Orientation theOrientation )
SetBarOrientation ( theOrientation )
Orientation GetOrientation ( )
return_value = GetOrientation ( )
Orientation GetBarOrientation ( )
return_value = GetBarOrientation ( )
void SetPosition ( in double X, in double Y )
Python
void SetOrientationType ( in Orientation theNb )
SetOrientationType ( theNb )
void SetOrientation ( in Orientation theOrientation, in double theXAngle, in double theYAngle )
SetOrientation ( theOrientation, theXAngle, theYAngle )
Orientation GetOrientationType ( )
return_value = GetOrientationType ( )
double GetRotateX ( )
return_value = GetRotateX ( )
double GetRotateY ( )
return_value = GetRotateY ( )
void SetDisplacement ( in double theDisp )
SetDisplacement ( theDisp )
long GetNbPlanes ( )
return_value = GetNbPlanes ( )
void SetRotateX ( in double theAngle )
SetRotateX ( theAngle )
double GetRotateX ( )
return_value = GetRotateX ( )
void SetRotateY ( in double theAngle )
SetRotateY ( theAngle )
double GetRotateY ( )
return_value = GetRotateY ( )

@@ -371,12 +359,12 @@ - - + + - - + + @@ -387,6 +375,22 @@ + + + + + + + + + + + + + + + + @@ -442,38 +446,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Python
void SetOrientationType ( in Orientation theNb )
SetOrientationType ( theNb )
void SetOrientation ( in Orientation theOrientation, in double theXAngle, in double theYAngle )
SetOrientation ( theOrientation, theXAngle, theYAngle )
void SetOrientationType2 ( in Orientation theNb )
SetOrientationType2 ( theNb )
void SetOrientation2 ( in Orientation theOrientation, in double theXAngle, in double theYAngle )
SetOrientation2 ( theOrientation, theXAngle, theYAngle )
Orientation GetOrientationType ( )
return_value = GetOrientationType2 ( )
double GetRotateX ( )
return_value = GetRotateX ( )
double GetRotateX2 ( )
return_value = GetRotateX2 ( )
double GetRotateY ( )
return_value = GetRotateY ( )
double GetRotateY2 ( )
return_value = GetRotateY2 ( )
void SetDisplacement ( in double theDisp )
SetDisplacement ( theDisp )
long GetNbLines ( )
return_value = GetNbLines ( )
void SetRotateX ( in double theAngle )
SetRotateX ( theAngle )
void SetRotateX2 ( in double theAngle )
SetRotateX2 ( theAngle )
double GetRotateX ( )
return_value = GetRotateX ( )
double GetRotateX2 ( )
return_value = GetRotateX2 ( )
void SetRotateY ( in double theAngle )
SetRotateY ( theAngle )
void SetRotateY2 ( in double theAngle )
SetRotateY2 ( theAngle )
double GetRotateY ( )
return_value = GetRotateY ( )
double GetRotateY2 ( )
return_value = GetRotateY2 ( )

@@ -483,53 +455,33 @@ - - - - - - - - - - - - - - + + - - + + - - - - - - - - - - + + - - - - + + + +
Python
void SetDirection ( in Direction theDirection )
SetDirection ( theDirection )
Direction GetDirection ( )
return_value = GetDirection ( )
void SetStepLength ( in double theStep )
SetStepLength ( theStep )
double GetStepLength ( )
return_value = GetStepLength ( )
boolean SetParams ( in double theIntStep, in double thePropogationTime, in double theStepLength, in Prs3d thePrs3d, in double thePercents, in Direction theDirection )
return_value = SetParams ( theIntStep, thePropogationTime, theStepLength, thePrs3d, thePercents, theDirection )
void SetPropagationTime ( in double theTime )
SetPropagationTime ( theTime )
double GetIntegrationStep ( )
return_value = GetIntegrationStep ( )
double GetPropagationTime ( )
return_value = GetPropagationTime ( )
void SetIntegrationStep ( in double theStep )
SetIntegrationStep ( theStep )
double GetIntegrationStep ( )
return_value = GetIntegrationStep ( )
void SetSource ( in Prs3d thePrs3d )
SetSource ( thePrs3d )
double GetStepLength ( )
return_value = GetStepLength ( )
Prs3d GetSource ( )
return_value = GetSource ( )
void SetUsedPoints ( in double thePercents )
SetUsedPoints ( thePercents )
double GetUsedPoints ( )
return_value = GetUsedPoints ( )
Direction GetDirection ( )
return_value = GetDirection ( )

@@ -747,10 +699,18 @@ + + + + + + + + @@ -814,6 +774,14 @@ + + + + + + + +
return_value = ImportTables ( theFileName )
boolean ExportTableToFile ( in SObject theTable, in string theFileName )
return_value = ExportTableToFile ( theTable, theFileName )
Result ImportFile ( in string theFileName )
return_value = ImportFile ( theFileName )
Result CopyAndImportFile ( in string theFileName )
return_value = CopyAndImportFile ( theFileName )
Result ImportMed ( in SObject theMedSObject )
return_value = ImportMed ( theMedSObject )
Animation CreateAnimation ( in View3D theView3d )
return_value = CreateAnimation ( theView3d )
void DeleteResult ( in Result theResult )
DeleteResult ( theResult )
void DeletePrs3d ( in Prs3d thePrs3d )
DeletePrs3d ( thePrs3d )

@@ -823,6 +791,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1058,9 +1066,5 @@ - - - -
Python
void ShowPart ( in ViewRepresentation ViewRepr, in boolean state )
ShowPart ( ViewRepr, state )
boolean IsPartShown ( in ViewRepresentation ViewRepr )
return_value = IsPartShown ( ViewRepr )
void SetViewWidth ( in long Width )
SetViewWidth ( Width )
void SetViewHeight ( in long Height )
SetViewHeight ( Height )
long GetViewWidth ( )
return_value = GetViewWidth ( )
long GetViewHeight ( )
return_value = GetViewHeight ( )
void SetViewPositionHorizontal ( in ViewPosition ViewPosHor )
SetViewPositionHorizontal ( ViewPosHor )
void SetViewPositionVertical ( in ViewPosition ViewPosVer )
SetViewPositionVertical ( ViewPosVer )
void SetRelativePosition ( in double x, in double y )
SetRelativePosition ( x, y )
void SetRelativeSize ( in double x, in double y )
SetRelativeSize ( x, y )
void SetTitle ( in string theTitle )
SetTitle ( theTitle )
void Destroy ( in View theView )
Destroy ( theView )
void ProcessEvents ( )
ProcessEvents ( )

diff --git a/doc/salome/tui/VISU/doxyfile b/doc/salome/tui/VISU/doxyfile index 81569276..3ee35aea 100755 --- a/doc/salome/tui/VISU/doxyfile +++ b/doc/salome/tui/VISU/doxyfile @@ -3,7 +3,7 @@ #--------------------------------------------------------------------------- # General configuration options #--------------------------------------------------------------------------- -PROJECT_NAME = "SALOME - VISU - v.2.0.0" +PROJECT_NAME = "SALOME - VISU - v.2.1.0" PROJECT_NUMBER = id#1.1 OUTPUT_DIRECTORY = ../ OUTPUT_LANGUAGE = English diff --git a/doc/salome/tui/VISU/sources/static/tree.js b/doc/salome/tui/VISU/sources/static/tree.js index 264bfe2d..72b94f7c 100755 --- a/doc/salome/tui/VISU/sources/static/tree.js +++ b/doc/salome/tui/VISU/sources/static/tree.js @@ -1,4 +1,4 @@ -foldersTree = gFld("SALOME v.2.0.0 ", "", "") +foldersTree = gFld("SALOME v.2.1.0 ", "", "") insDoc(foldersTree, gLnk("Main Page", "", "main.html")) aux1 = insFld(foldersTree, gFld("TUI Reference Guide", "")) diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index a01a2bb9..f27a904b 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -961,14 +961,6 @@ post-processing presentations from given %Result and %Table object reference, us provided by %ViewManager. */ interface VISU_Gen : Engines::Component, SALOMEDS::Driver, Base{ -/*! SAN & VSR : Test QT_EVENT ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -*/ - void CreateTestView(); - void ShowTestObject(); -/*! SAN & VSR : Test QT_EVENT -<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -*/ /*! Sets a definite study to be current. */ void SetCurrentStudy(in SALOMEDS::Study theStudy); @@ -1123,6 +1115,11 @@ Creates a presentation form containing an array of references to the curves. \param theView3d The 3D view, where the animation will be rendered. */ Animation CreateAnimation(in View3D theView3d); + + void DeleteResult(in Result theResult); + + void DeletePrs3d(in Prs3d thePrs3d); + }; /*! \brief %View interface @@ -1131,6 +1128,29 @@ Creates a presentation form containing an array of references to the curves. %View interface is a base for all types of %view interfaces. */ interface View: Base{ + + enum ViewRepresentation { OBJECTBROWSER, VIEWER, PYTHON, MESSAGES }; // displaying part ("ALL" isn't setable) + + void ShowPart (in ViewRepresentation ViewRepr, in boolean state ); + + boolean IsPartShown( in ViewRepresentation ViewRepr ); + + void SetViewWidth (in long Width); //setting width of view + + void SetViewHeight (in long Height); //setting height of view + + long GetViewWidth(); //getting view width + + long GetViewHeight(); //getting view height + + enum ViewPosition {TOP, CENTER, BOTTOM, RIGHT, LEFT}; //position of the study frame + + void SetViewPositionHorizontal (in ViewPosition ViewPosHor); //setting of the horizontal view position + + void SetViewPositionVertical (in ViewPosition ViewPosVer); //setting of the vertical view position + + void SetRelativePosition( in double x, in double y ); + void SetRelativeSize( in double x, in double y ); /*! Sets the title of the %View frame. \param theTitle String parameter defining the title of the %View frame. diff --git a/resources/VISUCatalog.xml b/resources/VISUCatalog.xml index 46eb84b2..7c59871e 100644 --- a/resources/VISUCatalog.xml +++ b/resources/VISUCatalog.xml @@ -16,7 +16,7 @@ Post-Pro VISU NRI - 1.0 + 2.1.0 Visu component - Maquette septembre 1 ModuleVisu.png diff --git a/src/CONVERTOR/VISUConvertor.cxx b/src/CONVERTOR/VISUConvertor.cxx index 79856149..24f787c2 100644 --- a/src/CONVERTOR/VISUConvertor.cxx +++ b/src/CONVERTOR/VISUConvertor.cxx @@ -45,7 +45,7 @@ static int MYDEBUG = 0; void parseFile(const char* theFileName) { try{ - cout<<"'"< aCon(CreateConvertor(theFileName)); //aCon->GetSize(); //return; @@ -104,11 +104,11 @@ void parseFile(const char* theFileName) { } } OK: - cout<<"OK"<DebugOn(); try{ LoadMeshOnEntity(*pVTKMeshOnEntity); - }catch(std::runtime_error& exc){ + }catch(std::exception& exc){ pVTKMeshOnEntity = pMeshOnEntity; - MESSAGE("Follow exception was accured :\n"<myMeshName,pVTKMeshOnEntity->myEntity); diff --git a/src/ENGINE/Makefile.in b/src/ENGINE/Makefile.in index 320f6a4b..d26a08ba 100644 --- a/src/ENGINE/Makefile.in +++ b/src/ENGINE/Makefile.in @@ -24,7 +24,7 @@ LIB_MOC = LIB_SERVER_IDL = VISU_Gen.idl SALOME_Component.idl \ SALOME_Exception.idl SALOME_GenericObj.idl \ SALOME_Session.idl MED.idl -LIB_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl +LIB_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Comm.idl # Executables targets BIN = diff --git a/src/ENGINE/VISU_Engine_i.cc b/src/ENGINE/VISU_Engine_i.cc index fd0c065e..0edb9acc 100644 --- a/src/ENGINE/VISU_Engine_i.cc +++ b/src/ENGINE/VISU_Engine_i.cc @@ -294,6 +294,16 @@ namespace VISU{ } + void VISU_Gen_i::DeleteResult(Result_ptr theResult){ + myVisuGen->DeleteResult(theResult); + } + + + void VISU_Gen_i::DeletePrs3d(Prs3d_ptr thePrs3d){ + myVisuGen->DeletePrs3d(thePrs3d); + } + + void VISU_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent){ myVisuGen->Close(theComponent); } @@ -341,18 +351,4 @@ namespace VISU{ return myVisuGen->PasteInto(theStream,theObjectID,theObject); } - - /*! SAN & VSR : Test QT_EVENT - >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - */ - void VISU_Gen_i::CreateTestView() { - myVisuGen->CreateTestView(); - } - void VISU_Gen_i::ShowTestObject() { - myVisuGen->ShowTestObject(); - } - /*! SAN & VSR : Test QT_EVENT - <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - */ - }; diff --git a/src/ENGINE/VISU_Engine_i.hh b/src/ENGINE/VISU_Engine_i.hh index 10f96e14..8ad9db0f 100644 --- a/src/ENGINE/VISU_Engine_i.hh +++ b/src/ENGINE/VISU_Engine_i.hh @@ -87,6 +87,9 @@ namespace VISU{ virtual Container_ptr CreateContainer(); virtual Animation_ptr CreateAnimation(View3D_ptr theView3d); + virtual void DeleteResult(Result_ptr theResult); + virtual void DeletePrs3d(Prs3d_ptr thePrs3d); + // inherited methods from SALOMEDS::Driver virtual SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent, const char* theURL, @@ -128,14 +131,6 @@ namespace VISU{ SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream, CORBA::Long theObjectID, SALOMEDS::SObject_ptr theObject); - /*! SAN & VSR : Test QT_EVENT - >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - */ - virtual void CreateTestView(); - virtual void ShowTestObject(); - /*! SAN & VSR : Test QT_EVENT - <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - */ }; }; diff --git a/src/OBJECT/VISU_Actor.cxx b/src/OBJECT/VISU_Actor.cxx index a3f440c7..74036d0c 100644 --- a/src/OBJECT/VISU_Actor.cxx +++ b/src/OBJECT/VISU_Actor.cxx @@ -28,16 +28,28 @@ #include "VISU_Actor.h" #include "VISU_PipeLine.hxx" +#include "SALOME_ShrinkFilter.h" +#include "SALOME_GeometryFilter.h" #include "SALOME_PassThroughFilter.h" -#include "utilities.h" +#include + // VTK Includes #include -#include + +#include +#include +#include + +#include #include + +#include #include #include +#include "utilities.h" + using namespace std; static int MYVTKDEBUG = 0; @@ -64,23 +76,16 @@ VISU_Actor::VISU_Actor(){ myIsShrunk = false; myIsShrinkable = false; - myShrinkFilter = vtkShrinkPolyData::New(); + myShrinkFilter = SALOME_ShrinkFilter::New(); + myShrinkFilter->SetStoreMapping(true); + SetShrinkFactor(); + + myMapper = vtkDataSetMapper::New(); myIO = NULL; myName = ""; - ishighlighted = false; - IsHighlighting = true; - HighlightProperty = vtkProperty::New(); - HighlightProperty->SetAmbient(0.5); - HighlightProperty->SetDiffuse(0.3); - HighlightProperty->SetSpecular(0.2); - HighlightProperty->SetRepresentationToSurface(); - HighlightProperty->SetAmbientColor(1, 1, 1); - HighlightProperty->SetDiffuseColor(1, 1, 1); - HighlightProperty->SetSpecularColor(0.5, 0.5, 0.5); - - vtkProperty* aProperty = this->GetProperty(); + vtkProperty* aProperty = GetProperty(); aProperty->SetAmbient(0.5); aProperty->SetDiffuse(0.2); aProperty->SetSpecular(0.2); @@ -92,8 +97,12 @@ VISU_Actor::VISU_Actor(){ VISU_Actor::~VISU_Actor(){ SALOME_Actor::SetProperty(NULL); - HighlightProperty->Delete(); - if(myPipeLine) myPipeLine->UnRegister(this); + + myMapper->RemoveAllInputs(); + myMapper->Delete(); + + if(myPipeLine) + myPipeLine->UnRegister(this); myShrinkFilter->UnRegisterAllOutputs(); myShrinkFilter->Delete(); @@ -130,10 +139,8 @@ void VISU_Actor::SetPipeLine(VISU_PipeLine* thePipeLine) { //Now, we use vtkShrinkPolyData (not vtkShrinkFilter), //and the class there is no such limitation. - vtkDataSetMapper* aNewMapper = vtkDataSetMapper::New(); - aNewMapper->SetInput(aDataSet); - SetMapper(aNewMapper); - aNewMapper->Delete(); + myMapper->SetInput(aDataSet); + SetMapper(myMapper); } } @@ -143,6 +150,8 @@ void VISU_Actor::SetParent(VISU_Actor* theParent){ void VISU_Actor::SetRepresentation(int theMode) { SALOME_Actor::SetRepresentation(theMode); + if(myRepresentation == VTK_POINTS) + UnShrink(); } void VISU_Actor::SetOpacity(float theValue){ @@ -153,34 +162,41 @@ float VISU_Actor::GetOpacity(){ return GetProperty()->GetOpacity(); } -void VISU_Actor::SetShrinkable(bool theIsShrinkable){ - myIsShrinkable = theIsShrinkable; -} -void VISU_Actor::SetShrink(float theFactor){ +void VISU_Actor::SetShrink(){ if(!myIsShrinkable) return; - //_CS_PhB operator [] if(vtkPolyData* aDataSet = myPassFilter.at(1)->GetPolyDataOutput()){ - if(vtkPolyData* aDataSet = myPassFilter[1]->GetPolyDataOutput()){ - myShrinkFilter->SetShrinkFactor(theFactor); + if(vtkDataSet* aDataSet = myPassFilter[0]->GetOutput()){ myShrinkFilter->SetInput(aDataSet); - //_CS_PhB operator [] myPassFilter.at(2)->SetInput(myShrinkFilter->GetOutput()); - myPassFilter[2]->SetInput(myShrinkFilter->GetOutput()); + myPassFilter[1]->SetInput(myShrinkFilter->GetOutput()); myIsShrunk = true; } } void VISU_Actor::UnShrink(){ if(!myIsShrunk) return; - //_CS_PhB operator [] if(vtkPolyData* aDataSet = myPassFilter.at(1)->GetPolyDataOutput()){ - if(vtkPolyData* aDataSet = myPassFilter[1]->GetPolyDataOutput()){ - //_CS_PhB operator [] myPassFilter.at(2)->SetInput(aDataSet); - //_CS_PhB operator [] myPassFilter.at(2)->Modified(); - myPassFilter[2]->SetInput(aDataSet); - myPassFilter[2]->Modified(); + if(vtkDataSet* aDataSet = myPassFilter[0]->GetOutput()){ + myPassFilter[1]->SetInput(aDataSet); + myPassFilter[1]->Modified(); myIsShrunk = false; + Modified(); } } +void VISU_Actor::SetShrinkable(bool theIsShrinkable){ + myIsShrinkable = theIsShrinkable; +} + +void VISU_Actor::SetShrinkFactor(float theValue){ + myShrinkFilter->SetShrinkFactor(theValue); + Modified(); +} + +float VISU_Actor::GetShrinkFactor(){ + return myShrinkFilter->GetShrinkFactor(); +} + + +//---------------------------------------------------------------------------- void VISU_Actor::SetVisibility(int theMode){ SALOME_Actor::SetVisibility(theMode); } @@ -205,6 +221,7 @@ float VISU_Actor::GetLineWidth(){ return GetProperty()->GetLineWidth(); } +//---------------------------------------------------------------------------- void VISU_Actor::ShallowCopy(vtkProp *prop){ VISU_Actor *anActor = VISU_Actor::SafeDownCast(prop); if(anActor != NULL){ @@ -214,21 +231,13 @@ void VISU_Actor::ShallowCopy(vtkProp *prop){ SALOME_Actor::ShallowCopy(prop); } -void VISU_Actor::highlight(Standard_Boolean highlight) { - if (this->IsHighlighting) { - if(highlight && !ishighlighted) { - ishighlighted=true; - this->SetProperty(HighlightProperty); - }else if (!highlight) - if(ishighlighted) ishighlighted=false; - } -} - -int VISU_Actor::GetObjId(int theVtkID){ - if (GetRepresentation() == 0) return -1; // points - return myGeomFilter->GetObjId(theVtkID); +//---------------------------------------------------------------------------- +int VISU_Actor::GetNodeObjId(int theVtkID){ + if ( myIsShrunk ) + return myShrinkFilter->GetNodeObjId(theVtkID); + return theVtkID; } -VISU_Actor::TVectorId VISU_Actor::GetVtkId(int theObjID){ - return myGeomFilter->GetVtkId(theObjID); +int VISU_Actor::GetElemObjId(int theVtkID){ + return myGeomFilter->GetElemObjId(theVtkID); } diff --git a/src/OBJECT/VISU_Actor.h b/src/OBJECT/VISU_Actor.h index b6925202..83b8e75c 100644 --- a/src/OBJECT/VISU_Actor.h +++ b/src/OBJECT/VISU_Actor.h @@ -30,15 +30,14 @@ #define VISU_ACTOR_H #include "SALOME_Actor.h" -#include "SALOME_GeometryFilter.h" -#include #include class vtkProp; class vtkProperty; -class vtkShrinkPolyData; +class vtkDataSetMapper; +class SALOME_ShrinkFilter; class VISU_PipeLine; namespace VISU { @@ -56,7 +55,7 @@ class VTKOCC_EXPORT VISU_Actor : public SALOME_Actor { vtkTypeMacro(VISU_Actor,SALOME_Actor); void ShallowCopy(vtkProp *prop); static VISU_Actor* New(); - ~VISU_Actor(); + virtual ~VISU_Actor(); virtual void setIO(const Handle(SALOME_InteractiveObject)& theIO); @@ -69,21 +68,22 @@ class VTKOCC_EXPORT VISU_Actor : public SALOME_Actor { VISU_Actor* GetParent(){ return myParent;} virtual void SetParent(VISU_Actor* theParent); - virtual void highlight(Standard_Boolean highlight); - Standard_Boolean isHighlighted() { return true; }; - virtual void SetOpacity(float theValue); virtual float GetOpacity(); - virtual void SetShrinkable(bool theIsShrinkable); - virtual bool GetShrinkable() { return myIsShrinkable;} - virtual void SetRepresentation(int theMode); + + virtual bool IsShrunkable() { return myIsShrinkable;} virtual bool IsShrunk() { return myIsShrunk;} - virtual void SetShrink(float theFactor = 0.8); + virtual void SetShrink(); virtual void UnShrink(); + virtual void SetShrinkable(bool theIsShrinkable); + virtual void SetShrinkFactor(float theFactor = 0.8); + virtual float GetShrinkFactor(); + + virtual void SetVisibility(int theMode); virtual int GetVisibility(); @@ -93,10 +93,11 @@ class VTKOCC_EXPORT VISU_Actor : public SALOME_Actor { virtual void SetLineWidth(float theLineWidth); virtual float GetLineWidth(); - int GetObjId(int theVtkID); - TVectorId GetVtkId(int theObjID); - bool IsHighlighting; + virtual int GetNodeObjId(int theVtkID); + virtual int GetElemObjId(int theVtkID); + + std::string myFieldName; protected: @@ -105,9 +106,9 @@ class VTKOCC_EXPORT VISU_Actor : public SALOME_Actor { VISU_Actor* myParent; VISU::Prs3d_i* myPrs3d; VISU_PipeLine* myPipeLine; - vtkProperty* HighlightProperty; + vtkDataSetMapper* myMapper; - vtkShrinkPolyData* myShrinkFilter; + SALOME_ShrinkFilter* myShrinkFilter; bool myIsShrinkable; bool myIsShrunk; }; diff --git a/src/OBJECT/VISU_MeshAct.cxx b/src/OBJECT/VISU_MeshAct.cxx index 51ad8259..ac262e52 100644 --- a/src/OBJECT/VISU_MeshAct.cxx +++ b/src/OBJECT/VISU_MeshAct.cxx @@ -29,6 +29,10 @@ #include "VISU_MeshAct.h" #include "SALOME_PassThroughFilter.h" +#include +#include +#include + #include #include #include @@ -123,8 +127,14 @@ void VISU_MeshAct::SetShrinkable(bool theIsShrinkable){ myNodeActor->SetShrinkable(theIsShrinkable); } +void VISU_MeshAct::SetShrinkFactor(float theValue){ + VISU_Actor::SetShrinkFactor(theValue); + mySurfaceActor->SetShrinkFactor(theValue); + myEdgeActor->SetShrinkFactor(theValue); +} + vtkProperty* VISU_MeshAct::GetSurfaceProperty(){ - mySurfaceActor->GetProperty(); + return mySurfaceActor->GetProperty(); } void VISU_MeshAct::SetSurfaceProperty(vtkProperty* theProperty){ @@ -132,7 +142,7 @@ void VISU_MeshAct::SetSurfaceProperty(vtkProperty* theProperty){ } vtkProperty* VISU_MeshAct::GetEdgeProperty(){ - myEdgeActor->GetProperty(); + return myEdgeActor->GetProperty(); } void VISU_MeshAct::SetEdgeProperty(vtkProperty* theProperty){ @@ -140,20 +150,13 @@ void VISU_MeshAct::SetEdgeProperty(vtkProperty* theProperty){ } vtkProperty* VISU_MeshAct::GetNodeProperty(){ - myNodeActor->GetProperty(); + return myNodeActor->GetProperty(); } void VISU_MeshAct::SetNodeProperty(vtkProperty* theProperty){ myNodeActor->SetProperty(theProperty); } -void VISU_MeshAct::highlight(Standard_Boolean highlight){ - VISU_Actor::highlight(highlight); - mySurfaceActor->highlight(highlight); - myEdgeActor->highlight(highlight); - myNodeActor->highlight(highlight); -} - void VISU_MeshAct::SetOpacity(float theValue){ GetSurfaceProperty()->SetOpacity(theValue); } @@ -170,18 +173,20 @@ float VISU_MeshAct::GetLineWidth(){ return GetEdgeProperty()->GetLineWidth(); } -void VISU_MeshAct::SetShrink(float theFactor){ - VISU_Actor::SetShrink(theFactor); - mySurfaceActor->SetShrink(theFactor); - myEdgeActor->SetShrink(theFactor); - SetRepresentation(GetRepresentation()); +void VISU_MeshAct::SetShrink(){ + if(myRepresentation == VTK_POINTS) + return; + VISU_Actor::SetShrink(); + mySurfaceActor->SetShrink(); + myEdgeActor->SetShrink(); + //SetRepresentation(GetRepresentation()); } void VISU_MeshAct::UnShrink(){ VISU_Actor::UnShrink(); mySurfaceActor->UnShrink(); myEdgeActor->UnShrink(); - SetRepresentation(GetRepresentation()); + //SetRepresentation(GetRepresentation()); } void VISU_MeshAct::SetRepresentation(int theMode){ @@ -192,16 +197,16 @@ void VISU_MeshAct::SetRepresentation(int theMode){ myEdgeActor->PickableOff(); myNodeActor->PickableOff(); switch(theMode){ - case 0: //POINTS + case VTK_POINTS: myNodeActor->VisibilityOn(); myNodeActor->PickableOn(); break; - case 1: //WIREFRAME + case VTK_WIREFRAME: myEdgeActor->VisibilityOn(); myEdgeActor->SetRepresentation(1); myEdgeActor->PickableOn(); break; - case 2: //SURFACE + case VTK_SURFACE: mySurfaceActor->VisibilityOn(); break; case 3: //INSIDEFRAME @@ -215,6 +220,8 @@ void VISU_MeshAct::SetRepresentation(int theMode){ mySurfaceActor->VisibilityOn(); break; } + if(myRepresentation == VTK_POINTS) + UnShrink(); } void VISU_MeshAct::SetVisibility(int theMode){ diff --git a/src/OBJECT/VISU_MeshAct.h b/src/OBJECT/VISU_MeshAct.h index 38b45dc3..6530c7a2 100644 --- a/src/OBJECT/VISU_MeshAct.h +++ b/src/OBJECT/VISU_MeshAct.h @@ -47,8 +47,6 @@ class VTKOCC_EXPORT VISU_MeshAct : public VISU_Actor { virtual void SetPipeLine(VISU_PipeLine* thePipeLine) ; virtual void SetTransform(SALOME_Transform* theTransform); - virtual void highlight(Standard_Boolean highlight); - virtual vtkProperty* GetSurfaceProperty(); virtual void SetSurfaceProperty(vtkProperty* theProperty); @@ -69,8 +67,9 @@ class VTKOCC_EXPORT VISU_MeshAct : public VISU_Actor { virtual void SetVisibility(int theMode); virtual void SetShrinkable(bool theIsShrinkable); + virtual void SetShrinkFactor(float theFactor = 0.8); - virtual void SetShrink(float theFactor = 0.8); + virtual void SetShrink(); virtual void UnShrink(); virtual void Render(vtkRenderer *, vtkMapper *); diff --git a/src/OBJECT/VISU_ScalarMapAct.cxx b/src/OBJECT/VISU_ScalarMapAct.cxx index 30a7c4a7..0a138e2c 100644 --- a/src/OBJECT/VISU_ScalarMapAct.cxx +++ b/src/OBJECT/VISU_ScalarMapAct.cxx @@ -30,6 +30,9 @@ #include "VISU_LookupTable.hxx" #include "VISU_ScalarBarActor.hxx" +#include +#include + vtkStandardNewMacro(VISU_ScalarMapAct); VISU_ScalarMapAct::VISU_ScalarMapAct(){ diff --git a/src/OBJECT/VISU_VectorsAct.cxx b/src/OBJECT/VISU_VectorsAct.cxx index 30de9bae..8f055d25 100644 --- a/src/OBJECT/VISU_VectorsAct.cxx +++ b/src/OBJECT/VISU_VectorsAct.cxx @@ -32,6 +32,9 @@ // VTK Includes #include +#include +#include +#include using namespace std; @@ -47,7 +50,7 @@ VISU_VectorsAct::~VISU_VectorsAct(){} void VISU_VectorsAct::SetPipeLine(VISU_PipeLine* thePipeLine) { - if(myPipeLine = dynamic_cast(thePipeLine)){ + if((myPipeLine = dynamic_cast(thePipeLine))){ VISU_Actor::SetPipeLine(myPipeLine); myPipeLine->Delete(); } diff --git a/src/PIPELINE/VISUPipeLine.cxx b/src/PIPELINE/VISUPipeLine.cxx index f89dc7ef..7f0b646b 100644 --- a/src/PIPELINE/VISUPipeLine.cxx +++ b/src/PIPELINE/VISUPipeLine.cxx @@ -45,6 +45,8 @@ typedef VISU_ScalarMapPL TPresent; #include #include +#include "utilities.h" + using namespace std; static int isOnlyMesh = false; @@ -131,10 +133,10 @@ int main(int argc, char** argv){ } } } - }catch(std::runtime_error& exc){ - cout<<"Follow exception was accured :\n"< +#include #include +#include // Open CASCADE Include #include @@ -165,7 +170,20 @@ private: QFont font; }; -static VisuGUI MYVISUGUI(""); + +inline bool IsSObjectTable(SALOMEDS::SObject_ptr theSObject){ + if(!theSObject->_is_nil()) { + SALOMEDS::GenericAttribute_var anAttr; + if(theSObject->FindAttribute( anAttr, "AttributeTableOfInteger" )) + return true; + if(theSObject->FindAttribute( anAttr, "AttributeTableOfReal" )) + return true; + } + return false; +} + + +static VisuGUI MYVISUGUI; VisuGUI *visuGUI = &MYVISUGUI; VISU::VISU_Gen_i* VisuGUI::GetVisuGen(){ @@ -240,6 +258,7 @@ VisuGUI::CameraOrient VisuGUI::SetFitAll(VTKViewer_ViewFrame* theViewFrame){ } theViewFrame->getRenderer()->ResetCameraClippingRange(); theViewFrame->onViewFitAll(); + return aCameraOrient; } QAD_Desktop* VisuGUI::GetDesktop(){ @@ -920,41 +939,43 @@ void VisuGUI::DisplayOnlyPrs() { // function : ErasePrs() // purpose : //===================================================================================== -void VisuGUI::ErasePrs() { - if(MYDEBUG) MESSAGE("VisuGUI::ErasePrs"); - CORBA::Object_var anObject = GetSelectedObj(); - if ( !CORBA::is_nil( anObject ) ) { - // is it Prs3d object ? - VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(anObject).in()); - if(aPrsObject){ - if(MYDEBUG) MESSAGE("VisuGUI::ErasePrs : Prs3d object"); - ErasePrs(aPrsObject); - VTKViewer_ViewFrame* vf = GetVtkViewFrame(); - if (vf) { - vf->Repaint(); - } - } - // is it Curve ? - VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(anObject).in()); - if(aCurve){ - if(MYDEBUG) MESSAGE("VisuGUI::ErasePrs : Curve object"); - PlotCurve(aCurve, VISU::eErase ); +static void ErasePrs(CORBA::Object_ptr theObject) { + if(MYDEBUG) MESSAGE("ErasePrs"); + if ( !CORBA::is_nil( theObject ) ) { + VISU::Base_var aBase = VISU::Base::_narrow(theObject); + if ( CORBA::is_nil( aBase ) ) return; + VISU::VISUType aType = aBase->GetType(); + switch (aType){ + case VISU::TCURVE:{ + if(VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(aBase).in())) + VisuGUI::PlotCurve(aCurve, VISU::eErase ); + break; } - // is it Container ? - VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(anObject).in()); - if(aContainer){ - if(MYDEBUG) MESSAGE("VisuGUI::ErasePrs : Container object"); - PlotContainer(aContainer, VISU::eErase ); + case VISU::TCONTAINER:{ + if(VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(aBase).in())) + VisuGUI::PlotContainer(aContainer, VISU::eErase ); + break; } - // is it Table ? - VISU::Table_i* aTable = dynamic_cast(VISU::GetServant(anObject).in()); - if(aTable){ - if(MYDEBUG) MESSAGE("VisuGUI::ErasePrs : Table object"); - PlotTable(aTable, VISU::eErase ); + case VISU::TTABLE:{ + if(VISU::Table_i* aTable = dynamic_cast(VISU::GetServant(aBase).in())) + VisuGUI::PlotTable(aTable, VISU::eErase ); + break; } + default:{ + if(VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(aBase).in())){ + VisuGUI::ErasePrs(aPrsObject); + if (VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame()) + vf->Repaint(); + } + }} } } +void VisuGUI::ErasePrs() { + ::ErasePrs(GetSelectedObj()); +} + + //===================================================================================== // function : DisplayManyPrs() // purpose : @@ -1393,7 +1414,7 @@ void VisuGUI::CreateMesh() { } #ifdef CHECKTIME timer.Stop(); - cout<<"VisuGUI::CreateMesh() - CREATE MESH\n"; + MESSAGE("VisuGUI::CreateMesh() - CREATE MESH"); timer.Show(); #endif @@ -1419,7 +1440,7 @@ void VisuGUI::CreateMesh() { SetFitAll(vf); #ifdef CHECKTIME timer.Stop(); - cout<<"VisuGUI::CreateMesh() - DISPLAY MESH\n"; + MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH"); timer.Show(); #endif //GetActiveStudy()->updateObjBrowser(); //not necessary @@ -1506,7 +1527,7 @@ static void ShrinkMesh(VISU_Actor *theActor){ if(theActor->IsShrunk()) theActor->UnShrink(); else - theActor->SetShrink(0.8); + theActor->SetShrink(); } void VisuGUI::ChangeRepresentation(VISU::PresentationType theType) { @@ -1636,19 +1657,25 @@ void VisuGUI::PlotTable( VISU::Table_i* table, int theDisplaying ) } else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) { if ( plotCurve ) { - plotCurve->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) ); - //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) ); - plotCurve->setVerTitle( strdup( theCurve->GetName() ) ); - plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) ); - plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) ); + plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() ); + //plotCurve->setVerTitle( theCurve->GetVerTitle().c_str() ); + plotCurve->setVerTitle( theCurve->GetName() ); + plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() ); + plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() ); /* - DATA NOT UPDATED */ - if ( !plotCurve->isAutoAssign() ) { + double* xList = 0; + double* yList = 0; + int nbPoints = theCurve->GetData( xList, yList ); + if ( nbPoints > 0 && xList && yList ) { + plotCurve->setData( xList, yList, nbPoints ); + } + if ( !theCurve->IsAuto() ) { plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() ); plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() ); SALOMEDS::Color color = theCurve->GetColor(); plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) ); - plotCurve->setAutoAssign( theCurve->IsAuto() ); } + plotCurve->setAutoAssign( theCurve->IsAuto() ); aPlot->displayCurve( plotCurve, false ); } else { @@ -1662,6 +1689,7 @@ void VisuGUI::PlotTable( VISU::Table_i* table, int theDisplaying ) newColor.G = crv->getColor().green()/255.; newColor.B = crv->getColor().blue()/255.; theCurve->SetColor( newColor ); + crv->setAutoAssign( theCurve->IsAuto() ); } } } @@ -1695,19 +1723,24 @@ void VisuGUI::PlotCurve( VISU::Curve_i* theCurve, int theDisplaying ) } else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) { if ( plotCurve ) { - plotCurve->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) ); - //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) ); - plotCurve->setVerTitle( strdup( theCurve->GetName() ) ); - plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) ); - plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) ); - /* DATA NOT UPDATED */ - if ( !plotCurve->isAutoAssign() ) { + plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() ); + //plotCurve->setVerTitle( ( theCurve->GetVerTitle().c_str() ) ); + plotCurve->setVerTitle( theCurve->GetName() ); + plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() ); + plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() ); + double* xList = 0; + double* yList = 0; + int nbPoints = theCurve->GetData( xList, yList ); + if ( nbPoints > 0 && xList && yList ) { + plotCurve->setData( xList, yList, nbPoints ); + } + if ( !theCurve->IsAuto() ) { plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() ); plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() ); SALOMEDS::Color color = theCurve->GetColor(); plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) ); - plotCurve->setAutoAssign( theCurve->IsAuto() ); } + plotCurve->setAutoAssign( theCurve->IsAuto() ); aPlot->displayCurve( plotCurve, false ); } else { @@ -1721,6 +1754,7 @@ void VisuGUI::PlotCurve( VISU::Curve_i* theCurve, int theDisplaying ) newColor.G = crv->getColor().green()/255.; newColor.B = crv->getColor().blue()/255.; theCurve->SetColor( newColor ); + crv->setAutoAssign( theCurve->IsAuto() ); } } } @@ -1740,7 +1774,7 @@ void VisuGUI::PlotContainer( VISU::Container_i* container, int theDisplaying ) for ( int k = 1; k <= nbCurves; k++ ) { VISU::Curve_i* theCurve = container->GetCurve( k ); if ( theCurve && theCurve->IsValid() ) { - Plot2d_Curve* plotCurve = aPlot->getCurveByIO( new SALOME_InteractiveObject( strdup(theCurve->GetEntry()), "", "" ) ); + Plot2d_Curve* plotCurve = aPlot->getCurveByIO( new SALOME_InteractiveObject( theCurve->GetEntry(), "", "" ) ); // for ( int i = 0; i < clist.count(); i++ ) { // if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) { // plotCurve = clist.at( i ); @@ -1755,19 +1789,24 @@ void VisuGUI::PlotContainer( VISU::Container_i* container, int theDisplaying ) } else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) { if ( plotCurve ) { - plotCurve->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) ); - //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) ); - plotCurve->setVerTitle( strdup( theCurve->GetName() ) ); - plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) ); - plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) ); - /* - DATA NOT UPDATED */ - if ( !plotCurve->isAutoAssign() ) { + plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() ); + //plotCurve->setVerTitle( ( theCurve->GetVerTitle().c_str() ) ); + plotCurve->setVerTitle( theCurve->GetName() ); + plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() ); + plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() ); + double* xList = 0; + double* yList = 0; + int nbPoints = theCurve->GetData( xList, yList ); + if ( nbPoints > 0 && xList && yList ) { + plotCurve->setData( xList, yList, nbPoints ); + } + if ( !theCurve->IsAuto() ) { plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() ); plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() ); SALOMEDS::Color color = theCurve->GetColor(); plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) ); - plotCurve->setAutoAssign( theCurve->IsAuto() ); } + plotCurve->setAutoAssign( theCurve->IsAuto() ); aPlot->displayCurve( plotCurve, false ); } else { @@ -1781,6 +1820,7 @@ void VisuGUI::PlotContainer( VISU::Container_i* container, int theDisplaying ) newColor.G = crv->getColor().green()/255.; newColor.B = crv->getColor().blue()/255.; theCurve->SetColor( newColor ); + crv->setAutoAssign( theCurve->IsAuto() ); } } } @@ -1816,10 +1856,10 @@ void VisuGUI::ShowTable() { // possibly this is Table SObject SO = GetActiveStudy()->getStudyDocument()->FindObjectID( anIO->getEntry() ); } - SALOMEDS::GenericAttribute_var anAttr; - if ( SO->_is_nil() || ( !SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) - && !SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) + + if(!IsSObjectTable(SO)) return; + SALOMEGUI_TableDlg* dlg = new SALOMEGUI_TableDlg( QAD_Application::getDesktop(), SO, false, @@ -1845,10 +1885,7 @@ void VisuGUI::CreateTable() { if(!aSObject->_is_nil()) { CORBA::Object_var anObject = VISU::SObjectToObject(aSObject); VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject ); - SALOMEDS::GenericAttribute_var anAttr; - if(!aCutLines->_is_nil() || - aSObject->FindAttribute( anAttr, "AttributeTableOfInteger") || - aSObject->FindAttribute( anAttr, "AttributeTableOfReal" )) { + if(!aCutLines->_is_nil() || IsSObjectTable(aSObject)) { GetVisuGen()->CreateTable(aSObject->GetID()); GetActiveStudy()->updateObjBrowser(); } @@ -1871,6 +1908,12 @@ void VisuGUI::DeleteObject() { if (anIO->hasEntry()){ SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry()); if(!aSObject->_is_nil()){ + SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject); + for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){ + SALOMEDS::SObject_var aChildSObject = aChildIter->Value(); + CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject); + ::ErasePrs(aChildObj); + } SALOMEDS::StudyBuilder_var aStudyBuilder = VisuGUI::NewBuilder(); // There is a transaction aStudyBuilder->NewCommand(); @@ -1936,12 +1979,11 @@ void VisuGUI::PlotData() { SALOMEDS::AttributeName_var aName; QString SOName; SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() ); - if ( !SO->_is_nil() && ( SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) || - SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) { + if ( IsSObjectTable(SO) ) { // get name of SObject if ( SO->FindAttribute( anAttr, "AttributeName" ) ) { aName = SALOMEDS::AttributeName::_narrow( anAttr ); - SOName = strdup( aName->Value() ); + SOName = aName->Value(); } Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() ); if ( dlg->exec() == QDialog::Accepted ) { @@ -2006,13 +2048,11 @@ void VisuGUI::PlotData() { // check if Table SObject is selected SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() ); - if ( !SO->_is_nil() && - ( SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) || - SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) { + if ( IsSObjectTable(SO) ) { // get name of SObject if ( SO->FindAttribute( anAttr, "AttributeName" ) ) { aName = SALOMEDS::AttributeName::_narrow( anAttr ); - SOName = strdup( aName->Value() ); + SOName = aName->Value(); } Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() ); if ( dlg->exec() == QDialog::Accepted ) { @@ -2077,9 +2117,7 @@ void VisuGUI::CreatePlot(SALOMEDS::SObject_var theTableSO) { SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeName_var aName; - if ( !theTableSO->_is_nil() && - ( theTableSO->FindAttribute( anAttr, "AttributeTableOfInteger" ) || - theTableSO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) { + if ( IsSObjectTable(theTableSO) ) { CORBA::Object_var aTable = VISU::SObjectToObject(theTableSO); CORBA::Object_var aContainer = GetVisuGen()->CreateContainer(); if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) { @@ -2318,9 +2356,9 @@ void VisuGUI::Sweep() { } } }catch(std::exception& exc){ - INFOS("Follow exception was accured :\n"<getStudyDocument() ); bool isVTKViewer = (GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK); - thePopup->clear(); SALOME_Selection* aSelection = SALOME_Selection::Selection(GetActiveStudy()->getSelection()); - if ( aSelection->IObjectCount() == 0 ) { + QString aParentComponent = ((SALOMEGUI_Desktop*)parent)->getComponentFromSelection(); + int nbSel = aSelection->IObjectCount(); + + thePopup->clear(); + + if ( nbSel == 0 ) { if ( theParent == "Viewer" && isVTKViewer && !aIsLocked) thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) ); return false; } - if( aSelection->IObjectCount() > 1 ) { + if( nbSel > 1 ) { int selMode = checkHomoSelection(); if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup: multiple selection : selMode = "<insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe())); break; } - if(anVISUActor->GetShrinkable()) + if(anVISUActor->IsShrunkable()) if(aType != VISU::TVECTORS && aType != VISU::TSTREAMLINES){ if (anVISUActor->IsShrunk()) aPresMenu->insertItem("Unshrink", visuGUI, SLOT(MakeShrink())); @@ -2989,6 +3031,15 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject ); if(!CORBA::is_nil(aField)) thePopup->insertItem( "Import TimeStamp", visuGUI, SLOT( ImportMedField() ) ); + if ( aParentComponent != parent->getActiveComponent() ) { + //insert pre-defined Display/Erase items + if ( thePopup->count() > 0 ) { + thePopup->insertSeparator(); + } + thePopup->insertItem (tr ("MEN_APP_DISPLAY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_Display_Popup_ID); + thePopup->insertItem (tr ("MEN_APP_DISPLAY_ONLY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_DisplayOnly_Popup_ID); + thePopup->insertItem (tr ("MEN_APP_ERASE"), GetActiveStudy()->getApp(), SLOT(onErase()), 0, QAD_Erase_Popup_ID); + } return false; } }else{ @@ -3042,16 +3093,26 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri } return false; }else{ - SALOMEDS::GenericAttribute_var anAttr; - if(aSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ) || - aSObject->FindAttribute( anAttr, "AttributeTableOfReal" )){ + + if(IsSObjectTable(aSObject)){ thePopup->insertItem( "Show Table", visuGUI, SLOT(ShowTable())); thePopup->insertItem( "Create Curves", visuGUI, SLOT(PlotData())); thePopup->insertItem( "Export Table", visuGUI, SLOT( ExportTableToFile() ) ); + thePopup->insertSeparator(); + thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) ); return false; } + + CORBA::Long aTag = 1; + SALOMEDS::SObject_var aSubObject; + if(aSObject->FindSubObject(aTag,aSubObject) && IsSObjectTable(aSubObject)) { + thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) ); + return false; + } + aSObject = aSObject->GetFather(); if(aSObject->_is_nil()) return false; + SALOMEDS::GenericAttribute_var anAttr; aSObject->FindAttribute(anAttr, "AttributeName"); SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); if(aName->_is_nil()) return false; @@ -3060,16 +3121,27 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri // thePopup->insertItem( "Import MED", visuGUI, SLOT( ImportMedField() ) ); if(strcmp(aValue.in(),"MEDFIELD") == 0) thePopup->insertItem( "Import Field", visuGUI, SLOT( ImportMedField() ) ); + if ( aParentComponent != parent->getActiveComponent() ) { + //insert pre-defined Display/Erase items + if ( thePopup->count() > 0 ) { + thePopup->insertSeparator(); + } + thePopup->insertItem (tr ("MEN_APP_DISPLAY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_Display_Popup_ID); + thePopup->insertItem (tr ("MEN_APP_DISPLAY_ONLY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_DisplayOnly_Popup_ID); + thePopup->insertItem (tr ("MEN_APP_ERASE"), GetActiveStudy()->getApp(), SLOT(onErase()), 0, QAD_Erase_Popup_ID); + } return false; } } } + return false; } //=========================================================================== // BuildPresentation //=========================================================================== -void VisuGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO) +void VisuGUI::BuildPresentation( const Handle(SALOME_InteractiveObject)& theIO, + QAD_ViewFrame* ) { BEGIN_OF("VisuGUI::BuildPresentation"); @@ -3431,7 +3503,7 @@ bool FNAME(SALOMEDS::SObject_var theField) { \ TYPE* pPresent = FCREATE(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toInt()); \ if(MYCHECKTIME) { \ timer.Stop(); \ - cout<<"BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT\n"; \ + MESSAGE("BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT"); \ timer.Show(); \ } \ if (pPresent) { \ @@ -3481,7 +3553,7 @@ bool VisuGUI::CreateCutPlanes(SALOMEDS::SObject_var theField) { CreateCutPlanesPrs(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toInt()); if(MYCHECKTIME) { timer.Stop(); - cout<<"BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT\n"; + MESSAGE("BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT"); timer.Show(); } if (pPresent) { @@ -3524,7 +3596,7 @@ try { aFieldName,aTimeStampId.toInt()); if(MYCHECKTIME) { timer.Stop(); - cout<<"BUILDPRS(VISU::CutLines_i, CreateCutLinesPrs, VisuGUI::CreateCutLines, VisuGUI_CutLinesDlg) - CREATE PRSOBJECT\n"; + MESSAGE("BUILDPRS(VISU::CutLines_i, CreateCutLinesPrs, VisuGUI::CreateCutLines, VisuGUI_CutLinesDlg) - CREATE PRSOBJECT"); timer.Show(); } if (pPresent) { @@ -3603,7 +3675,7 @@ void VisuGUI::ImportTablesFromFile(){ #ifdef CHECKTIME timer.Stop(); - cout<<"VisuGUI::ImportTablesFromFile() - IMPORT FILE\n"; + MESSAGE("VisuGUI::ImportTablesFromFile() - IMPORT FILE"); timer.Show(); #endif @@ -3748,7 +3820,7 @@ void VisuGUI::ImportFromFile(TImportFun theImportFun){ } #ifdef CHECKTIME timer.Stop(); - cout<<"VisuGUI::ImportFromFile() - IMPORT FILE\n"; + MESSAGE("VisuGUI::ImportFromFile() - IMPORT FILE"); timer.Show(); #endif @@ -3865,7 +3937,11 @@ VISU_Actor* VisuGUI::UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly){ } else if (theDispOnly) { anVISUActor->GetParent()->VisibilityOff(); + } else { } + } else if (theDispOnly && anActor->GetVisibility()) { + anActor->VisibilityOff(); + } else { } } if (aResActor) return aResActor; @@ -3948,7 +4024,7 @@ void VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) { tr ("VISU_BUT_OK") ); throw exc; } catch (...) { - cout<<" Unknown exception"< #include +#include #include #include diff --git a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx index 8eed6ade..7758df1e 100644 --- a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx +++ b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx @@ -46,6 +46,7 @@ #include #include +#include #include #include diff --git a/src/VISUGUI/VisuGUI_EditContainerDlg.cxx b/src/VISUGUI/VisuGUI_EditContainerDlg.cxx index 50a1571b..0ab0238d 100644 --- a/src/VISUGUI/VisuGUI_EditContainerDlg.cxx +++ b/src/VISUGUI/VisuGUI_EditContainerDlg.cxx @@ -361,7 +361,7 @@ QString VisuGUI_EditContainerDlg::getSObjectName(SALOMEDS::SObject_var theSObjec SALOMEDS::AttributeName_var aName; if ( theSObject->FindAttribute(anAttr, "AttributeName") ) { aName = SALOMEDS::AttributeName::_narrow( anAttr ); - return QString(strdup( aName->Value() )); + return QString(aName->Value()); } return QString(""); } diff --git a/src/VISUGUI/VisuGUI_InitMeshDlg.cxx b/src/VISUGUI/VisuGUI_InitMeshDlg.cxx index af7232f2..784a158d 100644 --- a/src/VISUGUI/VisuGUI_InitMeshDlg.cxx +++ b/src/VISUGUI/VisuGUI_InitMeshDlg.cxx @@ -370,7 +370,6 @@ void VisuGUI_InitMeshDlg::closeEvent( QCloseEvent* e ) void VisuGUI_InitMeshDlg::TextChangedInLineEdit(const QString& newText) { QLineEdit* send = (QLineEdit*)sender(); - QString newT = strdup(newText) ; if (send == LineEdit_NameMesh) { myNameMesh = newText; diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx index 019d436c..2e2ab54e 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx @@ -1020,6 +1020,7 @@ int VisuGUI_TextPrefDlg::FuncName() \ case 1: return VTK_COURIER; \ case 2: return VTK_TIMES; \ } \ + return VTK_ARIAL; \ } #define SETFONT(FuncName, Control) \ diff --git a/src/VISUGUI/VisuGUI_Selection.cxx b/src/VISUGUI/VisuGUI_Selection.cxx index cacf63f3..68b15a96 100644 --- a/src/VISUGUI/VisuGUI_Selection.cxx +++ b/src/VISUGUI/VisuGUI_Selection.cxx @@ -39,8 +39,7 @@ #include "QAD_RightFrame.h" #include "VTKViewer_ViewFrame.h" -#include -#include +#include #include @@ -51,11 +50,14 @@ #include #include #include +#include #include +#include #include +#include +#include #include -#include #include "utilities.h" @@ -313,20 +315,19 @@ void VisuGUI_SelectionDlg::onSelectionEvent() { myDZLbl->setText(QString::number( ABS(aCoord[5]-aCoord[4]) )); } - TColStd_MapOfInteger aMapIndex; + TColStd_IndexedMapOfInteger aMapIndex; typedef map PointsMap; PointsMap aPointsMap; mySelection->GetIndex(anIO, aMapIndex); - TColStd_MapIteratorOfMapOfInteger anIter(aMapIndex); VISU_Actor* anActor = visuGUI->GetActor(aPrs3d); if(!anActor) return; - vtkDataSet* aDataSet = anActor->GetMapper()->GetInput(); + vtkDataSet* aDataSet = anActor->GetInput(); vtkPointData* aPntData = aDataSet->GetPointData(); - for (;anIter.More();anIter.Next()){ - int aID = anIter.Key(); + for ( int ind = 1; ind <= aMapIndex.Extent(); ind++){ + int aID = aMapIndex( ind ); switch (aType) { case 0: @@ -356,9 +357,7 @@ void VisuGUI_SelectionDlg::onSelectionEvent() { clearFields(); } else { - int aDSId = anActor->GetObjId(aID); - if (aDSId==-1) aDSId = aID; - myCellIDValLbl->setText( QString::number(aDSId) ); + myCellIDValLbl->setText( QString::number(aID) ); myCellScalarValLbl->setText(getValue(aData, aID)); myCellVectorValLbl->setText(getVector(aData, aID)); @@ -437,26 +436,17 @@ bool onIdEdit(const QString& theText, QString theValue, QLabel* theFieldName) { - int anId = theText.toInt(); Handle(SALOME_InteractiveObject) anIO; if(VISU::Prs3d_i* aPrs3d = visuGUI->GetSelectedPrs3d(&anIO)){ + int anId = theText.toInt(); vtkDataSet* aDataSet = aPrs3d->GetPL()->GetMapper()->GetInput(); int aMaxId = (aDataSet->*theMethod)(); if(anId < 0) anId = 0; - if(aMaxId <= anId) anId = aMaxId-1; + if(anId >= aMaxId) anId = aMaxId-1; theSelection->ClearIObjects(); theSelection->AddIObject(anIO); - VISU_Actor* anVISUActor = visuGUI->GetActor(aPrs3d); - if(theIsCell){ - VISU_Actor::TVectorId aVec = anVISUActor->GetVtkId(anId); - if(!aVec.empty()){ - theSelection->AddOrRemoveIndex( anIO, aVec, false ); - return true; - } - }else{ - theSelection->AddOrRemoveIndex(anIO, anId, false); - return true; - } + theSelection->AddOrRemoveIndex( anIO, anId, false ); + return true; }else{ theMeshName->setText(theValue); theFieldName->setText(""); diff --git a/src/VISU_I/Makefile.in b/src/VISU_I/Makefile.in index 93df0b42..057a12f3 100644 --- a/src/VISU_I/Makefile.in +++ b/src/VISU_I/Makefile.in @@ -30,7 +30,8 @@ LIB_MOC = VISU_TimeAnimation.h LIB_SERVER_IDL = VISU_Gen.idl SALOME_Component.idl \ SALOME_Exception.idl SALOME_GenericObj.idl MED.idl -LIB_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl +LIB_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl \ + SALOME_Comm.idl # Executables targets BIN = diff --git a/src/VISU_I/VISUConfig.cc b/src/VISU_I/VISUConfig.cc index 353cfdf7..c137e26f 100644 --- a/src/VISU_I/VISUConfig.cc +++ b/src/VISU_I/VISUConfig.cc @@ -150,9 +150,9 @@ namespace VISU{ return (i->second)(theSObject,thePrefix,aMap); } }catch(std::logic_error& exc){ - INFOS("Follow exception was accured :\n"<reference_to_servant(theObject); return aServant; } catch (...) { - INFOS("GetServant - Unknown exception was accured!!!"); + INFOS("GetServant - Unknown exception was occured!!!"); return NULL; } } @@ -199,7 +199,7 @@ namespace VISU{ anObj = anORB->string_to_object(aValue); } }catch(...){ - INFOS("SObjectToObject - Unknown exception was accured!!!"); + INFOS("SObjectToObject - Unknown exception was occured!!!"); } return anObj; } diff --git a/src/VISU_I/VISUConfig.hh b/src/VISU_I/VISUConfig.hh index ba38a0ee..ca83125f 100644 --- a/src/VISU_I/VISUConfig.hh +++ b/src/VISU_I/VISUConfig.hh @@ -103,7 +103,7 @@ namespace VISU{ typedef std::map TRestoringMap; typedef Storable* (*TStorableEngine)(SALOMEDS::SObject_ptr theSObject, const std::string& thePrefix, const TRestoringMap& theMap); - typedef std::map TCallbackMap; + typedef std::map TCallbackMap; static void Registry(const char* theComment, TStorableEngine theEngine); static Storable* Create(SALOMEDS::SObject_ptr, const std::string& thePrefix, const std::string& theString); static const QString& FindValue(const TRestoringMap& theMap, const std::string& theArg, bool* isFind = NULL); @@ -117,7 +117,7 @@ namespace VISU{ //=========================================================================== const CORBA::Boolean IsMultifile(); - QString GenerateName(const string& theFmt, int theId); + QString GenerateName(const std::string& theFmt, int theId); PortableServer::ServantBase_var GetServant(CORBA::Object_ptr theObject); CORBA::Object_var SObjectToObject(SALOMEDS::SObject_ptr theSObject); @@ -134,4 +134,5 @@ namespace VISU{ const char* theComment, int IsAllLevels = true); } + #endif diff --git a/src/VISU_I/VISU_CorbaMedConvertor.cxx b/src/VISU_I/VISU_CorbaMedConvertor.cxx index 50acfbe1..2c1d3a0f 100644 --- a/src/VISU_I/VISU_CorbaMedConvertor.cxx +++ b/src/VISU_I/VISU_CorbaMedConvertor.cxx @@ -261,6 +261,7 @@ VISU_Convertor* VISU_MEDFieldConvertor::Build() { VISU::TMesh &aMesh = myMeshMap[aMeshName.in()]; aMesh.myDim = aMEDMesh->getSpaceDimension(); + aMesh.myPointsDim.resize(aMesh.myDim); aMesh.myName = aMeshName.in(); VISUMED::TMesh &aMesh2 = myMeshMap2[aMeshName.in()]; aMesh2.myMesh = aMEDMesh; @@ -296,7 +297,7 @@ VISU_Convertor* VISU_MEDFieldConvertor::Build() { VISUMED::TField::TValForTime& aValForTime2 = aField2.myValField[iTimeStamp]; aValForTime2.myField = myField; if(MYDEBUG) - MESSAGE("VISU_MEDConvertor::Build - aFieldName = '"<> Cann't find MEDMESH label !!!"); - if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - MEDMESH found."); - SALOMEDS::ChildIterator_var aMeshIterator = aStudy->NewChildIterator(aMeshSObj); - for(; aMeshIterator->More(); aMeshIterator->Next()){ - aMeshSObj = aMeshIterator->Value(); - if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshSObj = '"<<::GetName(aMeshSObj)<<"'"); - CORBA::Object_var aMedMesh = SObjectToObject(aMeshSObj); - if(CORBA::is_nil(aMedMesh)) continue; - SALOME_MED::MESH_var aMEDMesh = SALOME_MED::MESH::_narrow(aMedMesh); - if(aMEDMesh->_is_nil()) continue; - CORBA::String_var aMeshName = aMEDMesh->getName(); - VISU::TMesh &aMesh = myMeshMap[aMeshName.in()]; - aMesh.myDim = aMEDMesh->getSpaceDimension(); - aMesh.myName = aMeshName.in(); - aMesh.myPointsDim.resize(aMesh.myDim); - VISUMED::TMesh &aMesh2 = myMeshMap2[aMeshName.in()]; - aMesh2.myMesh = aMEDMesh; - if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshName = "<second; - const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap; - if(aFamilyMap.empty()) continue; - VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); - for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ - const VISU::TFamily& aFamily = aFamilyMapIter->second; - const VISU::TBindGroups& aBindGroups = aFamily.myGroups; - if(aBindGroups.empty()) continue; - VISU::TBindGroups::const_iterator aBindGroupsIter = aBindGroups.begin(); - for(; aBindGroupsIter != aBindGroups.end(); aBindGroupsIter++){ - const string& aGroupName = *aBindGroupsIter; - VISU::TGroup& aGroup = aGroupMap[aGroupName]; - aGroup.myName = aGroupName; - aGroup.myMeshName = aMesh.myName; - aGroup.myNbCells += aFamily.myNbCells; - aGroup.myCellsSize += aFamily.myCellsSize; - VISU::TFamilyAndEntity aFamilyAndEntity(aFamily.myName,aFamily.myEntity); - aGroup.myFamilyAndEntitySet.insert(aFamilyAndEntity); - } - } - } - } - SALOMEDS::SObject_var aFieldSObj; - if(aMedCompSObj->FindSubObject(aTag+2,aFieldSObj)){ - if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - MEDFIELD found."); - SALOMEDS::ChildIterator_var aFieldIterator = aStudy->NewChildIterator(aFieldSObj); - for(int iField = 0; aFieldIterator->More(); aFieldIterator->Next(), iField++){ - aFieldSObj = aFieldIterator->Value(); - if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aFieldName = '"<<::GetName(aFieldSObj)<<"'"); - SALOMEDS::ChildIterator_var aTimeStampIterator = aStudy->NewChildIterator(aFieldSObj); - for(int iTimeStamp = 1; aTimeStampIterator->More(); aTimeStampIterator->Next(), iTimeStamp++){ - SALOMEDS::SObject_var aTimeStampSObj = aTimeStampIterator->Value(); - if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aTimeStampSObj = '"<<::GetName(aTimeStampSObj)<<"'"); - CORBA::Object_var aMedField = SObjectToObject(aTimeStampSObj); - if(CORBA::is_nil(aMedField)) continue; - SALOME_MED::FIELD_var aMEDField = SALOME_MED::FIELD::_narrow(aMedField); - if(aMEDField->_is_nil()) continue; - SALOME_MED::SUPPORT_var aMEDSupport = aMEDField->getSupport(); - if(aMEDSupport->_is_nil()) continue; - SALOME_MED::medEntityMesh aMEDEntity = aMEDSupport->getEntity(); - VISU::TEntity anEntity = aMed2VisuEntity[aMEDEntity]; - SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh(); - if(aMEDMesh->_is_nil()) continue; - CORBA::String_var aMeshName = aMEDMesh->getName(); - CORBA::String_var aFieldName = aMEDField->getName(); - - VISU::TMesh &aMesh = myMeshMap[aMeshName.in()]; - aMesh.myDim = aMEDMesh->getSpaceDimension(); - aMesh.myName = aMeshName.in(); - VISUMED::TMesh &aMesh2 = myMeshMap2[aMeshName.in()]; - aMesh2.myMesh = aMEDMesh; + return Build(aMED); + } + + SALOMEDS::ChildIterator_var aTimeStampIterator = aStudy->NewChildIterator(mySObject); + return Build(aTimeStampIterator); +} + +VISU_Convertor* VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED) +{ + if(theMED->_is_nil()) return NULL; + CORBA::Short aTag = mySObject->Tag(); + SALOMEDS::SObject_var aMedCompSObj = mySObject->GetFather(); + SALOMEDS::SObject_var aMeshSObj; + if(!aMedCompSObj->FindSubObject(aTag+1,aMeshSObj)) + throw std::runtime_error("VISU_MEDConvertor::Build >> Cann't find MEDMESH label !!!"); + if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - MEDMESH found."); + SALOMEDS::Study_var aStudy = mySObject->GetStudy(); + SALOMEDS::ChildIterator_var aMeshIterator = aStudy->NewChildIterator(aMeshSObj); + for(; aMeshIterator->More(); aMeshIterator->Next()){ + aMeshSObj = aMeshIterator->Value(); + if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshSObj = '"<<::GetName(aMeshSObj)<<"'"); + CORBA::Object_var aMedMesh = SObjectToObject(aMeshSObj); + if(CORBA::is_nil(aMedMesh)) continue; + SALOME_MED::MESH_var aMEDMesh = SALOME_MED::MESH::_narrow(aMedMesh); + if(aMEDMesh->_is_nil()) continue; + CORBA::String_var aMeshName = aMEDMesh->getName(); + VISU::TMesh &aMesh = myMeshMap[aMeshName.in()]; + aMesh.myDim = aMEDMesh->getSpaceDimension(); + aMesh.myName = aMeshName.in(); + aMesh.myPointsDim.resize(aMesh.myDim); + VISUMED::TMesh &aMesh2 = myMeshMap2[aMeshName.in()]; + aMesh2.myMesh = aMEDMesh; + if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshName = "<second; + const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap; + if(aFamilyMap.empty()) continue; + VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); + for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ + const VISU::TFamily& aFamily = aFamilyMapIter->second; + const VISU::TBindGroups& aBindGroups = aFamily.myGroups; + if(aBindGroups.empty()) continue; + VISU::TBindGroups::const_iterator aBindGroupsIter = aBindGroups.begin(); + for(; aBindGroupsIter != aBindGroups.end(); aBindGroupsIter++){ + const string& aGroupName = *aBindGroupsIter; + VISU::TGroup& aGroup = aGroupMap[aGroupName]; + aGroup.myName = aGroupName; + aGroup.myMeshName = aMesh.myName; + aGroup.myNbCells += aFamily.myNbCells; + aGroup.myCellsSize += aFamily.myCellsSize; + VISU::TFamilyAndEntity aFamilyAndEntity(aFamily.myName,aFamily.myEntity); + aGroup.myFamilyAndEntitySet.insert(aFamilyAndEntity); + } } - return this; } - return NULL; } - SALOMEDS::ChildIterator_var aTimeStampIterator = aStudy->NewChildIterator(mySObject); - for(int iTimeStamp = 1; aTimeStampIterator->More(); aTimeStampIterator->Next(), iTimeStamp++){ - SALOMEDS::SObject_var aTimeStampSObj = aTimeStampIterator->Value(); + SALOMEDS::SObject_var aFieldSObj; + if(aMedCompSObj->FindSubObject(aTag+2,aFieldSObj)){ + if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - MEDFIELD found."); + SALOMEDS::ChildIterator_var aFieldIterator = aStudy->NewChildIterator(aFieldSObj); + for(int iField = 0; aFieldIterator->More(); aFieldIterator->Next(), iField++){ + aFieldSObj = aFieldIterator->Value(); + if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aFieldName = '"<<::GetName(aFieldSObj)<<"'"); + SALOMEDS::ChildIterator_var aTimeStampIterator = aStudy->NewChildIterator(aFieldSObj); + for(int iTimeStamp = 1; aTimeStampIterator->More(); aTimeStampIterator->Next(), iTimeStamp++){ + SALOMEDS::SObject_var aTimeStampSObj = aTimeStampIterator->Value(); + if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aTimeStampSObj = '"<<::GetName(aTimeStampSObj)<<"'"); + CORBA::Object_var aMedField = SObjectToObject(aTimeStampSObj); + if(CORBA::is_nil(aMedField)) continue; + SALOME_MED::FIELD_var aMEDField = SALOME_MED::FIELD::_narrow(aMedField); + if(aMEDField->_is_nil()) continue; + SALOME_MED::SUPPORT_var aMEDSupport = aMEDField->getSupport(); + if(aMEDSupport->_is_nil()) continue; + SALOME_MED::medEntityMesh aMEDEntity = aMEDSupport->getEntity(); + VISU::TEntity anEntity = aMed2VisuEntity[aMEDEntity]; + SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh(); + if(aMEDMesh->_is_nil()) continue; + CORBA::String_var aMeshName = aMEDMesh->getName(); + CORBA::String_var aFieldName = aMEDField->getName(); + + VISU::TMesh &aMesh = myMeshMap[aMeshName.in()]; + aMesh.myDim = aMEDMesh->getSpaceDimension(); + aMesh.myName = aMeshName.in(); + VISUMED::TMesh &aMesh2 = myMeshMap2[aMeshName.in()]; + aMesh2.myMesh = aMEDMesh; + + VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity]; + aMeshOnEntity.myEntity = anEntity; + aMeshOnEntity.myMeshName = aMeshName.in(); + VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[anEntity]; + aMeshOnEntity2.mySupport = aMEDSupport; + if(anEntity == VISU::NODE_ENTITY) + aMesh2.myMeshOnEntityMap[VISU::CELL_ENTITY].mySupport = aMEDSupport; + GetCellsSize(aMesh,aMEDMesh,anEntity); + + VISU::TField& aField = aMeshOnEntity.myFieldMap[aFieldName.in()]; + aField.myId = iField; + aField.myName = aFieldName.in(); + aField.myEntity = anEntity; + aField.myMeshName = aMeshName.in(); + aField.myNbComp = aMEDField->getNumberOfComponents(); + aField.myNbValField = iTimeStamp; + aField.myDataSize = aMeshOnEntity.myNbCells * aField.myNbComp; + if(MYDEBUG && !iTimeStamp) + MESSAGE("VISU_MEDConvertor::Build - aMeshOnEntity.myNbCells = "<getIterationNumber(); + VISU::TField::TValForTime& aValForTime = aField.myValField[anId]; + aValForTime.myId = anId; + aValForTime.myTime = VISU::TField::TTime(aMEDField->getTime(),""); + VISUMED::TField& aField2 = aMeshOnEntity2.myFieldMap[aFieldName.in()]; + VISUMED::TField::TValForTime& aValForTime2 = aField2.myValField[anId]; + aValForTime2.myField = aMEDField; + if(MYDEBUG) + MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<getSpaceDimension(); + aMesh.myPointsDim.resize(aMesh.myDim); aMesh.myName = aMeshName.in(); aMesh.myNbPoints = aMEDMesh->getNumberOfNodes(); VISUMED::TMesh &aMesh2 = myMeshMap2[aMeshName.in()]; @@ -561,6 +576,7 @@ VISU_Convertor* VISU_MEDConvertor::Build() { return this; } + int VISU_MEDConvertor::LoadMeshOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, const string& theFamilyName) { diff --git a/src/VISU_I/VISU_CorbaMedConvertor.hxx b/src/VISU_I/VISU_CorbaMedConvertor.hxx index 5a86fc7d..53bd83ad 100644 --- a/src/VISU_I/VISU_CorbaMedConvertor.hxx +++ b/src/VISU_I/VISU_CorbaMedConvertor.hxx @@ -33,6 +33,8 @@ #include "VISUConfig.hh" #include "VISU_Convertor_impl.hxx" +#include + extern "C"{ #include } @@ -50,12 +52,12 @@ namespace VISUMED{ typedef std::map TValField; TValField myValField; }; - typedef map TFieldMap; + typedef std::map TFieldMap; struct TMeshOnEntity{ SALOME_MED::SUPPORT_var mySupport; - typedef pair TIndexAndSize; - typedef map TCellsFirstIndex; + typedef std::pair TIndexAndSize; + typedef std::map TCellsFirstIndex; TCellsFirstIndex myCellsFirstIndex; TFamilyMap myFamilyMap; TFieldMap myFieldMap; @@ -81,12 +83,18 @@ class VISU_MEDConvertor: public VISU_Convertor_impl{ VISUMED::TMeshMap myMeshMap2; SALOMEDS::SObject_var mySObject; VISU_MEDConvertor() {}; + public: VISU_MEDConvertor(SALOMEDS::SObject_ptr theMedSObject) : mySObject(SALOMEDS::SObject::_duplicate(theMedSObject)) {} - virtual VISU_Convertor* Build() ; + virtual VISU_Convertor* Build(); + protected: + + VISU_Convertor* Build(SALOME_MED::MED_ptr theMED); + VISU_Convertor* Build(SALOMEDS::ChildIterator_ptr theTimeStampIterator); + virtual int LoadMeshOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, - const string& theFamilyName = ""); + const std::string& theFamilyName = ""); virtual int LoadMeshOnGroup(VISU::TMesh& theMesh, const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet); @@ -96,9 +104,9 @@ class VISU_MEDConvertor: public VISU_Convertor_impl{ VISU::TField& theField, VISU::TField::TValForTime& theValForTime); - int LoadPoints(VISU::TMesh& theMesh, const string& theFamilyName = "") ; + int LoadPoints(VISU::TMesh& theMesh, const std::string& theFamilyName = "") ; - int LoadCellsOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, const string& theFamilyName = ""); + int LoadCellsOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, const std::string& theFamilyName = ""); int LoadField(const VISU::TMeshOnEntity& theMeshOnEntity, const VISU::TField& theField, VISU::TField::TValForTime& theValForTime); diff --git a/src/VISU_I/VISU_CutLines_i.cc b/src/VISU_I/VISU_CutLines_i.cc index 76b54bca..4021956f 100644 --- a/src/VISU_I/VISU_CutLines_i.cc +++ b/src/VISU_I/VISU_CutLines_i.cc @@ -376,9 +376,9 @@ void VISU::CutLines_i::BuildTableOfReal(SALOMEDS::SObject_ptr theSObject){ aTableOfReal->SetRowUnit(iLineId+2,aUnitName.latin1()); } } - }catch(std::runtime_error& exc){ - INFOS("Follow exception was accured :\n"< + using namespace VISU; using namespace std; @@ -47,10 +49,10 @@ int VISU::DeformedShape_i::IsPossible(Result_i* theResult, const char* theMeshNa if(!VISU::ScalarMap_i::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration,isMemoryCheck)) return 0; const VISU::TField& aField = theResult->GetInput()->GetField(theMeshName,(VISU::TEntity)theEntity,theFieldName); return aField.myNbComp > 1; - }catch(std::runtime_error& exc){ - INFOS("Follow exception was accured :\n"<GetStudy(); SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - TCollection_AsciiString aTmpDir = - isMultiFile?TCollection_AsciiString((char*)theURL):SALOMEDS_Tool::GetTmpDir(); + const char* aDir = isMultiFile? theURL: SALOMEDS_Tool::GetTmpDir().c_str(); + TCollection_AsciiString aTmpDir(const_cast(aDir)); VisuTmpDir = aTmpDir.ToCString(); SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir.ToCString(),isMultiFile); @@ -212,7 +212,8 @@ namespace VISU{ bool isMultiFile) { Mutex mt(myMutex); - TCollection_AsciiString aTmpDir = isMultiFile? strdup(theURL): SALOMEDS_Tool::GetTmpDir(); + const char* aDir = isMultiFile? theURL: SALOMEDS_Tool::GetTmpDir().c_str(); + TCollection_AsciiString aTmpDir(const_cast(aDir)); if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - "<GetFileInfo(); QString aPrefix(""); - if (isMultiFile) aPrefix = SALOMEDS_Tool::GetNameFromPath(aStudy->URL()); + if (isMultiFile) aPrefix = SALOMEDS_Tool::GetNameFromPath(aStudy->URL()).c_str(); QString aFileName = aPrefix + "_" + (pResult->GetName()).c_str(); static QString aCommand; aCommand.sprintf("cp %s %s%s",aFileInfo.filePath().latin1(),aTmpDir.ToCString(),aFileName.latin1()); @@ -263,8 +264,8 @@ namespace VISU{ bool isMultiFile) { Mutex mt(myMutex); - CORBA::String_var aString = SALOMEDS_Tool::GetTmpDir(); - TCollection_AsciiString aTmpDir = isMultiFile? (const Standard_CString)theURL: (const Standard_CString)aString.in(); + const char* aDir = isMultiFile? theURL: SALOMEDS_Tool::GetTmpDir().c_str(); + TCollection_AsciiString aTmpDir(const_cast(aDir)); if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - "<GetFileInfo(); QString aPrefix(""); - if (isMultiFile) aPrefix = SALOMEDS_Tool::GetNameFromPath(aStudy->URL()); + if (isMultiFile) aPrefix = SALOMEDS_Tool::GetNameFromPath(aStudy->URL()).c_str(); QString aFileName = aPrefix + "_" + (pResult->GetName()).c_str(); static QString aCommand; aCommand.sprintf("cp %s %s%s",aFileInfo.filePath().latin1(),aTmpDir.ToCString(),aFileName.latin1()); @@ -436,9 +437,9 @@ namespace VISU{ return aPresent->_this(); else{ aPresent->_remove_ref(); - return VISU::Mesh::_nil(); } } + return VISU::Mesh::_nil(); } Mesh_ptr VISU_Gen_i::FamilyMeshOnEntity(Result_ptr theResult, @@ -455,9 +456,9 @@ namespace VISU{ return aPresent->_this(); else{ aPresent->_remove_ref(); - return VISU::Mesh::_nil(); } } + return VISU::Mesh::_nil(); } Mesh_ptr VISU_Gen_i::GroupMesh(Result_ptr theResult, @@ -473,9 +474,9 @@ namespace VISU{ return aPresent->_this(); else{ aPresent->_remove_ref(); - return VISU::Mesh::_nil(); } } + return VISU::Mesh::_nil(); } ScalarMap_ptr VISU_Gen_i::ScalarMapOnField(Result_ptr theResult, @@ -647,8 +648,10 @@ namespace VISU{ } } } + }catch(std::exception& exc){ + INFOS("Follow exception was occured :\n"<ToString().c_str(); - ofstream stmOut2((string(aTmpDir) + string("copy_persistent")).c_str(),ios::out); stmOut2<(aPOA->reference_to_servant(aCorbaObj))) { string aFileName = string(SALOMEDS_Tool::GetNameFromPath(theObject->GetStudy()->URL())) + "_"; + if(strlen(aFileName.c_str()) == 1) aFileName=""; const QFileInfo& aFileInfo = aResultObj->GetFileInfo(); aFileName += aFileInfo.fileName().latin1(); static QString aCommand; + string aFullFileName = aTmpDir + aFileName; aCommand.sprintf("cp %s %s", aFileInfo.filePath().latin1(), - (string(aTmpDir) + aFileName).c_str()); + aFullFileName.c_str()); if(system(aCommand) == -1) { if(MYDEBUG) MESSAGE("VISU_Gen_i::Copy - Cann't execute the command :"<length(2); aSeq[0] = "copy_persistent"; aSeq[1] = aFileName.c_str(); @@ -707,8 +713,9 @@ namespace VISU{ aSeq->length(1); aSeq[0] = "copy_persistent"; } - aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir, aSeq.in(), false); - SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aSeq.in(), true); + + aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.c_str(), aSeq.in(), false); + SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true); // Assign an ID = 1 the the type VISU::Result theObjectID = 1; @@ -734,11 +741,11 @@ namespace VISU{ SALOMEDS::SObject_var aResultSO; if (theObjectID != 1) return aResultSO._retn(); + + string aTmpDir = SALOMEDS_Tool::GetTmpDir(); + SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir.c_str(), false); - CORBA::String_var aTmpDir = (const char*)SALOMEDS_Tool::GetTmpDir(); - SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir, false); - - ifstream stmIn((string(aTmpDir) + string("copy_persistent")).c_str()); + ifstream stmIn((aTmpDir + string("copy_persistent")).c_str()); stmIn.seekg(0, ios::end); int aLength = stmIn.tellg(); stmIn.seekg(0, ios::beg); @@ -747,9 +754,13 @@ namespace VISU{ aString[aLength] = 0; myIsMultiFile = false; - string aFileName(aTmpDir.in()); - if(aSeq->length() > 1) aFileName += aSeq[1].in(); - + string aFileName(aTmpDir); + string aBasicFileName; + if(aSeq->length() > 1) { + aBasicFileName = aSeq[1].in(); + aFileName += aBasicFileName; + } + SALOMEDS::SComponent_var aComponent = theObject->GetFatherComponent(); SALOMEDS::Study_var aStudy = theObject->GetStudy(); SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); @@ -768,7 +779,8 @@ namespace VISU{ SALOMEDS::ListOfFileNames_var aSeqToRm = new SALOMEDS::ListOfFileNames; aSeqToRm->length(1); aSeqToRm[0] = "copy_persistent"; - SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aSeqToRm.in(), true); + + SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeqToRm.in(), true); anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR"); SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); @@ -777,4 +789,4 @@ namespace VISU{ return aResultSO._retn(); } -}; +} diff --git a/src/VISU_I/VISU_Gen_i.hh b/src/VISU_I/VISU_Gen_i.hh index 99572fae..7869cd6c 100644 --- a/src/VISU_I/VISU_Gen_i.hh +++ b/src/VISU_I/VISU_Gen_i.hh @@ -95,6 +95,9 @@ namespace VISU{ virtual Container_ptr CreateContainer(); virtual Animation_ptr CreateAnimation(View3D_ptr theView3d); + virtual void DeleteResult(Result_ptr theResult); + virtual void DeletePrs3d(Prs3d_ptr thePrs3d); + // inherited methods from SALOMEDS::Driver virtual SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent, const char* theURL, @@ -136,14 +139,6 @@ namespace VISU{ SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream, CORBA::Long theObjectID, SALOMEDS::SObject_ptr theObject); - /*! SAN & VSR : Test QT_EVENT - >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - */ - virtual void CreateTestView(); - virtual void ShowTestObject(); - /*! SAN & VSR : Test QT_EVENT - <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - */ }; } #endif diff --git a/src/VISU_I/VISU_Mesh_i.cc b/src/VISU_I/VISU_Mesh_i.cc index c556d173..d5f6e584 100644 --- a/src/VISU_I/VISU_Mesh_i.cc +++ b/src/VISU_I/VISU_Mesh_i.cc @@ -77,10 +77,10 @@ int VISU::Mesh_i::IsPossible(Result_i* theResult, const char* theMeshName, Entit bool aResult = VISU_PipeLine::CheckAvailableMemory(aSize); MESSAGE("Mesh_i::IsPossible - CheckAvailableMemory = "<NewBuilder(); aStudyBuilder->NewCommand(); // There is a transaction - try{ + //try{ if(myResult->GetInput() == NULL) throw std::runtime_error("Mesh_i::Build - myResult->GetInput() == NULL !!!"); if(!theRestoring){ @@ -228,13 +228,13 @@ VISU::Storable* VISU::Mesh_i::Build(int theRestoring){ CORBA::String_var aString = GetID(); anIOR->SetValue(aString); } - }catch(std::runtime_error& exc){ - INFOS("Follow exception was accured :\n"<CommitCommand(); return this; } diff --git a/src/VISU_I/VISU_Prs3d_i.cc b/src/VISU_I/VISU_Prs3d_i.cc index 9a71122e..5220a788 100644 --- a/src/VISU_I/VISU_Prs3d_i.cc +++ b/src/VISU_I/VISU_Prs3d_i.cc @@ -30,6 +30,7 @@ #include "VISU_Actor.h" #include +#include using namespace VISU; using namespace std; @@ -73,8 +74,7 @@ void VISU::Prs3d_i::CreateActor(VISU_Actor* theActor, const Handle(SALOME_Intera if(myAddToStudy){ Handle(SALOME_InteractiveObject) anIO = theIO; if(anIO.IsNull()){ - CORBA::String_var anEntry = mySObject->GetID(); - anIO = new SALOME_InteractiveObject(strdup(anEntry.in()),"VISU",strdup(GetName())); + anIO = new SALOME_InteractiveObject(mySObject->GetID(),"VISU",GetName()); } theActor->setIO(anIO); } diff --git a/src/VISU_I/VISU_Result_i.cc b/src/VISU_I/VISU_Result_i.cc index 3fcdc2b1..dc8b0903 100644 --- a/src/VISU_I/VISU_Result_i.cc +++ b/src/VISU_I/VISU_Result_i.cc @@ -150,10 +150,10 @@ int VISU::Result_i::IsPossible(){ bool aResult = VISU_PipeLine::CheckAvailableMemory(aSize); MESSAGE("Result_i::IsPossible - CheckAvailableMemory = "<first; try{ myInput->GetTimeStampOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp); - }catch(std::runtime_error& exc){ - INFOS("Follow exception was accured :\n"<first; try{ myInput->GetMeshOnGroup(aMeshName,aGroupName); - }catch(std::runtime_error& exc){ - INFOS("Follow exception was accured :\n"<first; try{ myInput->GetMeshOnEntity(aMeshName,anEntity,aFamilyName); - }catch(std::runtime_error& exc){ - INFOS("Follow exception was accured :\n"<GetMeshOnEntity(aMeshName,anEntity); - }catch(std::runtime_error& exc){ - INFOS("Follow exception was accured :\n"<getSetting("Visu:BuildResult"); bool isBuildAll = aIsBuild.isEmpty()? 0 : aIsBuild.toInt(); if(isBuildAll) BuildAll(); - }catch(std::runtime_error& exc){ - INFOS("Follow exception was accured :\n"<CommitCommand(); @@ -393,7 +393,7 @@ VISU::Storable* VISU::Result_i::Create(const char* theFileName){ myInitFileName = myFileInfo.filePath().latin1(); myName = ::GenerateName(myFileInfo.fileName()).latin1(); if(GetSourceId() == eRestoredFile){ - auto_ptr aTmpDir(SALOMEDS_Tool::GetTmpDir()); + auto_ptr aTmpDir((char*)SALOMEDS_Tool::GetTmpDir().c_str()); static QString aCommand; aCommand.sprintf("cp %s %s",myFileInfo.absFilePath().latin1(),aTmpDir.get()); if(system(aCommand) == -1){ @@ -405,12 +405,11 @@ VISU::Storable* VISU::Result_i::Create(const char* theFileName){ } myInput = CreateConvertor(myFileInfo.absFilePath().latin1()); if(!myInput) - throw std::runtime_error("Create - Cannot create a Convertor for this file!!!"); - return Build(); - }catch(std::runtime_error& exc){ - INFOS("Follow exception was accured :\n"<ConvertObjectToIOR(theField); + SALOMEDS::SObject_var aFieldSObject = myStudyDocument->FindObjectIOR(anIOR); + VISU::Storable* aStorable = Build(aFieldSObject); return aStorable; - }catch(std::runtime_error& exc){ - INFOS("Follow exception was accured :\n"< +#include + using namespace VISU; using namespace std; @@ -55,10 +58,10 @@ int VISU::ScalarMap_i::IsPossible(Result_i* theResult, const char* theMeshName, MESSAGE("ScalarMap_i::IsPossible - CheckAvailableMemory = "<FindObjectIOR(anIOR); } - }catch(std::runtime_error& exc){ - INFOS("Follow exception was accured :\n"<CommitCommand(); diff --git a/src/VISU_I/VISU_StreamLines_i.cc b/src/VISU_I/VISU_StreamLines_i.cc index 85fd5da7..66a2305f 100644 --- a/src/VISU_I/VISU_StreamLines_i.cc +++ b/src/VISU_I/VISU_StreamLines_i.cc @@ -29,6 +29,7 @@ #include "VISU_StreamLines_i.hh" #include "VISU_Actor.h" +#include #include using namespace VISU; @@ -52,10 +53,10 @@ int VISU::StreamLines_i::IsPossible(Result_i* theResult, const char* theMeshName bool aResult = VISU_StreamLinesPL::IsPossible(anOutput); MESSAGE("StreamLines_i::IsPossible - aResult = "<_is_nil()) - if(aPrs3di = dynamic_cast(VISU::GetServant(thePrs3d).in())){ + if((aPrs3di = dynamic_cast(VISU::GetServant(thePrs3d).in()))){ for(int i = myAppendFilter->GetNumberOfInputs()-1; i >= 0; i--) myAppendFilter->RemoveInput(myAppendFilter->GetInput(i)); myAppendFilter->AddInput(aPrs3di->GetPL()->GetMapper()->GetInput()); diff --git a/src/VISU_I/VISU_Table_i.cc b/src/VISU_I/VISU_Table_i.cc index 0c683dc3..1607524c 100644 --- a/src/VISU_I/VISU_Table_i.cc +++ b/src/VISU_I/VISU_Table_i.cc @@ -37,6 +37,7 @@ #include #include +#include #include using namespace std; @@ -388,14 +389,14 @@ string VISU::Curve_i::GetHorTitle() anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr ); SALOMEDS::StringSeq_var rowTitles = anInt->GetRowTitles(); if ( rowTitles->length() > 0 && myHRow > 0 && myHRow <= anInt->GetNbRows() ) { - title = strdup( rowTitles[ myHRow-1 ] ); + title = rowTitles[ myHRow-1 ]; } } else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) { aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr ); SALOMEDS::StringSeq_var rowTitles = aReal->GetRowTitles(); if ( rowTitles->length() > 0 && myHRow > 0 && myHRow <= aReal->GetNbRows() ) { - title = strdup( rowTitles[ myHRow-1 ] ); + title = rowTitles[ myHRow-1 ]; } } } @@ -418,13 +419,13 @@ string VISU::Curve_i::GetVerTitle() anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr ); SALOMEDS::StringSeq_var rowTitles = anInt->GetRowTitles(); if ( rowTitles->length() > 0 && myVRow > 0 && myVRow <= anInt->GetNbRows() ) - title = strdup( rowTitles[ myVRow-1 ] ); + title = rowTitles[ myVRow-1 ]; } else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) { aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr ); SALOMEDS::StringSeq_var rowTitles = aReal->GetRowTitles(); if ( rowTitles->length() > 0 && myVRow > 0 && myVRow <= aReal->GetNbRows() ) - title = strdup( rowTitles[ myVRow-1 ] ); + title = rowTitles[ myVRow-1 ]; } } return title; @@ -446,13 +447,13 @@ string VISU::Curve_i::GetHorUnits() anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr ); SALOMEDS::StringSeq_var rowUnits = anInt->GetRowUnits(); if ( rowUnits->length() > 0 && myHRow > 0 && myHRow <= anInt->GetNbRows() ) - units = strdup( rowUnits[ myHRow-1 ] ); + units = rowUnits[ myHRow-1 ]; } else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) { aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr ); SALOMEDS::StringSeq_var rowUnits = aReal->GetRowUnits(); if ( rowUnits->length() > 0 && myHRow > 0 && myHRow <= aReal->GetNbRows() ) - units = strdup( rowUnits[ myHRow-1 ] ); + units = rowUnits[ myHRow-1 ]; } } return units; @@ -474,13 +475,13 @@ string VISU::Curve_i::GetVerUnits() anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr ); SALOMEDS::StringSeq_var rowUnits = anInt->GetRowUnits(); if ( rowUnits->length() > 0 && myVRow > 0 && myVRow <= anInt->GetNbRows() ) - units = strdup( rowUnits[ myVRow-1] ); + units = rowUnits[ myVRow-1]; } else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) { aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr ); SALOMEDS::StringSeq_var rowUnits = aReal->GetRowUnits(); if ( rowUnits->length() > 0 && myVRow > 0 && myVRow <= aReal->GetNbRows() ) - units = strdup( rowUnits[ myVRow-1 ] ); + units = rowUnits[ myVRow-1 ]; } } return units; @@ -579,9 +580,9 @@ Plot2d_Curve* VISU::Curve_i::CreatePresentation() SALOMEDS::Color color = GetColor(); crv->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) ); crv->setAutoAssign( IsAuto() ); - crv->setIO(new SALOME_InteractiveObject(strdup(mySObj->GetID()),"VISU",strdup(GetName()))); + crv->setIO(new SALOME_InteractiveObject(mySObj->GetID(),"VISU",GetName())); if ( myTable ) - crv->setTableIO(new SALOME_InteractiveObject(strdup(myTable->GetObjectEntry()),"VISU",strdup(myTable->GetName()))); + crv->setTableIO(new SALOME_InteractiveObject(myTable->GetObjectEntry(),"VISU",myTable->GetName())); return crv; } /*! @@ -623,7 +624,7 @@ void VISU::Curve_i::ToStream( std::ostringstream& theStr ) Gets reference table's entry */ const char* VISU::Curve_i::GetTableID() { - return CORBA::string_dup(myTable->GetObjectEntry()); + return myTable->GetObjectEntry(); } /*! Called from engine to restore curve from the file @@ -904,7 +905,7 @@ VISU::Storable* VISU::Container_i::Restore(SALOMEDS::SObject_ptr theSObject, //------------------------------------------------------------- // Implementation of reading from file //------------------------------------------------------------- -typedef double TValue; +typedef string TValue; typedef vector TValues; struct TRow{ @@ -976,82 +977,126 @@ int getLine(ifstream& theStmIn, QString& theString){ void ImportTables(const char* theFileName, TTableCont& theTableCont){ static int STRPRECISION = 12; ifstream aStmIn; - QFileInfo aFileInfo(theFileName); - if(!aFileInfo.isFile() || !aFileInfo.isReadable() || !aFileInfo.size()) return; - aStmIn.open(theFileName); + QFileInfo aFileInfo( theFileName ); + if( !aFileInfo.isFile() || !aFileInfo.isReadable() || !aFileInfo.size() ) + return; + aStmIn.open( theFileName ); QString aTmp; - do{ - //Find beginning of Table - while(getLine(aStmIn,aTmp) && aTmp == "\n"); - if(MYDEBUG) cout<<"\n There is new Table2D with Title = "; + do { + // find beginning of table (tables are separated by empty lines) + while( getLine( aStmIn, aTmp ) && aTmp.stripWhiteSpace() == ""); TTable2D aTable2D; - while(!aStmIn.eof() && aTmp != "\n"){ - if(aTmp.find("#TITLE:") == 0){ - int aLen = aTmp.find(":") + 1; - aTmp.remove(0,aLen); - QString aTitle = aTmp.stripWhiteSpace(); - aTable2D.myTitle = aTitle.latin1(); - if(MYDEBUG) cout<= 0 ) { + data = aTmp.left( index ).stripWhiteSpace(); + cmt = aTmp.mid( index+1 ).stripWhiteSpace(); + } + // if comment is not empty, try to get keyword from it (separated by ':' symbol) + if ( !cmt.isEmpty() ) { + int index1 = cmt.find( ":" ); + if ( index1 >= 0 ) { + QString tmpstr = cmt.left( index1 ).stripWhiteSpace(); + if ( tmpstr == QString( "TITLE" ) || + tmpstr == QString( "COLUMN_TITLES" ) || + tmpstr == QString( "COLUMN_UNITS" ) || + tmpstr == QString( "COMMENT" ) ) { + keyword = tmpstr; + cmt = cmt.mid( index1+1 ).stripWhiteSpace(); + } + } + } + // if data is empty, process only comment + if ( data.isEmpty() ) { + // if keyword is found, try to process it + // elsewise it is a simple comment, just ignore it + if ( !keyword.isEmpty() ) { + if ( keyword == QString( "TITLE" ) ) { + QString title = cmt; + if ( aTable2D.myTitle != "" ) + title = QString( aTable2D.myTitle.c_str() ) + QString( " " ) + title; + if(MYDEBUG) cout << "...Table TITLE is: " << title.latin1() << endl; + aTable2D.myTitle = title.latin1(); + } + else if ( keyword == QString( "COLUMN_TITLES" ) ) { + // comment may contain column headers + QStringList aStrList = QStringList::split( "|", cmt ); + if(MYDEBUG) cout << "...Column TITLES are: "; + for ( int i = 0; i < aStrList.count(); i++ ) { + QString tmpstr = aStrList[ i ].stripWhiteSpace(); + if(MYDEBUG) cout << tmpstr.latin1() << " "; + aTable2D.myColumnTitles.push_back( tmpstr.latin1() ); + } + if(MYDEBUG) cout << endl; + } + else if ( keyword == QString( "COLUMN_UNITS" ) ) { + // comment may contain column units + QStringList aStrList = QStringList::split( " ", cmt ); + if(MYDEBUG) cout << "...Column UNITS are: "; + for ( int i = 0; i < aStrList.count(); i++ ) { + QString tmpstr = aStrList[ i ].stripWhiteSpace(); + if(MYDEBUG) cout << tmpstr.latin1() << " "; + aTable2D.myColumnUnits.push_back( tmpstr.latin1() ); + } + if(MYDEBUG) cout << endl; + } + else if ( keyword == QString( "COMMENT" ) ) { + // keyword 'COMMENT' processing can be here + // currently it is ignored + if(MYDEBUG) cout << "...COMMENT: " << cmt.latin1() << endl; + } } - if(MYDEBUG) cout< 0){ - QStringList aStrList = QStringList::split("#TITLE:",aTmp); - QString aTitle = aStrList[1].stripWhiteSpace(); + } + // if data is not empty, try to process it + else { TRow aRow; - aRow.myTitle = aTitle.latin1(); - if(MYDEBUG) cout< 0 ) + aTable2D.myRows.push_back( aRow ); + // ************** OLD CODE ****************** + /* TValue aVal; - istrstream aStream(aTmp); - aStream.precision(STRPRECISION); - while(aStream>>aVal){ - aRow.myValues.push_back(aVal); - if(MYDEBUG) cout<<"\t"<> aVal ) { + aRow.myValues.push_back( aVal ); } - if(aRow.myValues.size() > 0) - aTable2D.myRows.push_back(aRow); - if(MYDEBUG) cout< 0 ) + aTable2D.myRows.push_back( aRow ); + */ + // ************** OLD CODE ****************** } - getLine(aStmIn,aTmp); + getLine( aStmIn, aTmp ); } - if(aTable2D.Check()){ - if(MYDEBUG) cout<<"aTable2D checked "<SetNbColumns(kEnd); for(int j = 0, jEnd = aNewTable2D.myRows.size(); j < jEnd; j++){ - if(MYDEBUG) cout<<"j = "<length(kEnd); - if(MYDEBUG) cout<<"kEnd = "<AddRow(aDoubleSeq.in()); + if(MYDEBUG) cout<<"j = "<PutValue(aValue,j+1,k+1); + } + aTableOfReal->SetRowTitle(j+1,aNewTable2D.myRows[j].myTitle.c_str()); aTableOfReal->SetRowUnit(j+1,aNewTable2D.myRows[j].myUnit.c_str()); } diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index 13d2f6b1..e1245e97 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -93,10 +93,6 @@ void VISU_TimeAnimation::clearData(FieldData& theData) { vtkRenderer* aRen = myView->getRenderer(); if (!theData.myActors.empty()) { for (int i = 0, iEnd = theData.myActors.size(); i < iEnd; i++) { - //_CS_PhB if (theData.myActors.at(i) != 0) { - //_CS_PhB theData.myActors.at(i)->RemoveFromRender(aRen); - //_CS_PhB theData.myActors.at(i)->Delete(); - //_CS_PhB } if (theData.myActors[i] != 0) { theData.myActors[i]->RemoveFromRender(aRen); theData.myActors[i]->Delete(); @@ -106,9 +102,6 @@ void VISU_TimeAnimation::clearData(FieldData& theData) { } if (!theData.myPrs.empty()) { for (int i = 0, iEnd = theData.myPrs.size(); i < iEnd; i++) - //_CS_PhB if (theData.myPrs.at(i) != 0) { - //_CS_PhB theData.myPrs.at(i)->_remove_ref(); - //_CS_PhB } if (theData.myPrs[i] != 0) { theData.myPrs[i]->_remove_ref(); } @@ -147,11 +140,6 @@ void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) { aTimeStamp = anIter->Value(); if (aTimeStamp->_is_nil()) continue; - //_CS_PhB aData.myTiming.at(i) = getTimeValue(aTimeStamp); - //_CS_PhB if (isRangeDefined()) { - //_CS_PhB if (aData.myTiming.at(i) < myMinVal) continue; - //_CS_PhB if (aData.myTiming.at(i) > myMaxVal) break; - //_CS_PhB } aData.myTiming[i] = getTimeValue(aTimeStamp); if (isRangeDefined()) { if (aData.myTiming[i] < myMinVal) continue; @@ -172,7 +160,6 @@ void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) { aFieldName.latin1(), aTimeStampId); //VISU::ScalarMap_var aTmp = aPresent->_this(); //aPresent->_remove_ref(); - //_CS_PhB aData.myPrs.at(i) = aPresent; aData.myPrs[i] = aPresent; } break; @@ -184,7 +171,6 @@ void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) { aFieldName.latin1(), aTimeStampId); //VISU::IsoSurfaces_var aTmp = aPresent->_this(); //aPresent->_remove_ref(); - //_CS_PhB aData.myPrs.at(i) = aPresent; aData.myPrs[i] = aPresent; } break; @@ -196,7 +182,6 @@ void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) { aFieldName.latin1(), aTimeStampId); //VISU::CutPlanes_var aTmp = aPresent->_this(); //aPresent->_remove_ref(); - //_CS_PhB aData.myPrs.at(i) = aPresent; aData.myPrs[i] = aPresent; } break; @@ -208,7 +193,6 @@ void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) { aFieldName.latin1(), aTimeStampId); //VISU::DeformedShape_var aTmp = aPresent->_this(); //aPresent->_remove_ref(); - //_CS_PhB aData.myPrs.at(i) = aPresent; aData.myPrs[i] = aPresent; } break; @@ -220,7 +204,6 @@ void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) { aFieldName.latin1(), aTimeStampId); //VISU::Vectors_var aTmp = aPresent->_this(); //aPresent->_remove_ref(); - //_CS_PhB aData.myPrs.at(i) = aPresent; aData.myPrs[i] = aPresent; } break; @@ -232,13 +215,10 @@ void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) { aFieldName.latin1(), aTimeStampId); //VISU::StreamLines_var aTmp = aPresent->_this(); //aPresent->_remove_ref(); - //_CS_PhB aData.myPrs.at(i) = aPresent; aData.myPrs[i] = aPresent; } break; } - //_CS_PhB if (aData.myPrs.at(i)->GetMin() < aMin) aMin = aData.myPrs.at(i)->GetMin(); - //_CS_PhB if (aData.myPrs.at(i)->GetMax() > aMax) aMax = aData.myPrs.at(i)->GetMax(); if (aData.myPrs[i]->GetMin() < aMin) aMin = aData.myPrs[i]->GetMin(); if (aData.myPrs[i]->GetMax() > aMax) aMax = aData.myPrs[i]->GetMax(); i++; @@ -247,11 +227,9 @@ void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) { QString aFixRange = QAD_CONFIG->getSetting("Visu:SBImposeRange"); if (aFixRange.compare("true") != 0) { for (i = 0; i < aData.myNbFrames; i++) - //_CS_PhB aData.myPrs.at(i)->SetRange(aMin, aMax); aData.myPrs[i]->SetRange(aMin, aMax); if(aData.myPrsType == VISU::TISOSURFACE) for (i = 0; i < aData.myNbFrames; i++) - //_CS_PhB if(VISU::IsoSurfaces_i* aPrs = dynamic_cast(aData.myPrs.at(i))) if(VISU::IsoSurfaces_i* aPrs = dynamic_cast(aData.myPrs[i])) aPrs->SetSubRange(aMin, aMax); } @@ -277,7 +255,6 @@ CORBA::Boolean VISU_TimeAnimation::generateFrames() { for (long j = 0; j < aData.myNbFrames; j++) { VISU_Actor* aActor = NULL; try{ - //_CS_PhB aActor = aData.myPrs.at(j)->CreateActor(); aActor = aData.myPrs[j]->CreateActor(); myView->AddActor(aActor); if(j == 0) @@ -286,16 +263,13 @@ CORBA::Boolean VISU_TimeAnimation::generateFrames() { aActor->VisibilityOff(); }catch(...){ //catch(std::runtime_error& exc){ aNoError = false; - //_CS_PhB myLastError += QString("%1 ").arg(aData.myTiming.at(j)); myLastError += QString("%1 ").arg(aData.myTiming[j]); } - //_CS_PhB aData.myActors.at(j) = aActor; aData.myActors[j] = aActor; } } myFrame = 0; - myLastError += QString(" timestamp(s) cannot /local/salome/SALOME2/VISU/V1_4_1a/VISU_SRC/src/VISU_I/VISU_TimeAnimation.cxxbe created."); - //_CS_PhB emit frameChanged(myFrame, myFieldsLst[0].myTiming.at(myFrame)); + myLastError += QString(" timestamp(s) cannot be created."); emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]); myView->Repaint(); return aNoError; @@ -307,16 +281,11 @@ void VISU_TimeAnimation::clearView() { MESSAGE("Viewer is nod defined for animation"); return; } - //_CS_PhB : "mt" ne sert pas dans cette methode VISU::Mutex mt(myMutex,qApp,MYDELAY); vtkRenderer* aRen = myView->getRenderer(); for (int i = 0; i < getNbFields(); i++) { FieldData& aData = myFieldsLst[i]; if (!aData.myActors.empty()) { for (int i = 0, iEnd = aData.myActors.size(); i < iEnd; i++) { -//_CS_PhB if (aData.myActors.at(i) != 0) { -//_CS_PhB aData.myActors.at(i)->RemoveFromRender(aRen); -//_CS_PhB aData.myActors.at(i)->Delete(); -//_CS_PhB } if (aData.myActors[i] != 0) { aData.myActors[i]->RemoveFromRender(aRen); aData.myActors[i]->Delete(); @@ -325,7 +294,7 @@ void VISU_TimeAnimation::clearView() { aData.myActors.clear(); } } - myView->getRW()->getRenderWindow()->Render(); + VISU::RepaintView(myView); //myView->update(); } @@ -348,19 +317,14 @@ void VISU_TimeAnimation::nextFrame() { if (myFrame < (myFieldsLst[0].myNbFrames-1)) { int i; for (i = 0; i < getNbFields(); i++) - -//_CS_PhB if (myFieldsLst[i].myActors.at(myFrame) != 0) -//_CS_PhB myFieldsLst[i].myActors.at(myFrame)->VisibilityOff(); if (myFieldsLst[i].myActors[myFrame] != 0) myFieldsLst[i].myActors[myFrame]->VisibilityOff(); + myFrame++; for (i = 0; i < getNbFields(); i++) -//_CS_PhB if (myFieldsLst[i].myActors.at(myFrame) != 0) -//_CS_PhB myFieldsLst[i].myActors.at(myFrame)->VisibilityOn(); if (myFieldsLst[i].myActors[myFrame] != 0) myFieldsLst[i].myActors[myFrame]->VisibilityOn(); -//_CS_PhB emit frameChanged(myFrame, myFieldsLst[0].myTiming.at(myFrame)); emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]); myView->Repaint(); } @@ -372,19 +336,14 @@ void VISU_TimeAnimation::prevFrame() { if (myFrame > 0) { int i; for (i = 0; i < getNbFields(); i++) - //_CS_PhB if (myFieldsLst[i].myActors.at(myFrame) != 0) -//_CS_PhB myFieldsLst[i].myActors.at(myFrame)->VisibilityOff(); if (myFieldsLst[i].myActors[myFrame] != 0) myFieldsLst[i].myActors[myFrame]->VisibilityOff(); myFrame--; for (i = 0; i < getNbFields(); i++) - //_CS_PhB if (myFieldsLst[i].myActors.at(myFrame) != 0) -//_CS_PhB myFieldsLst[i].myActors.at(myFrame)->VisibilityOn(); if (myFieldsLst[i].myActors[myFrame] != 0) myFieldsLst[i].myActors[myFrame]->VisibilityOn(); - //_CS_PhB emit frameChanged(myFrame, myFieldsLst[0].myTiming.at(myFrame)); emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]); myView->Repaint(); } @@ -396,19 +355,14 @@ void VISU_TimeAnimation::firstFrame() { int i; for (i = 0; i < getNbFields(); i++) if(!myFieldsLst[i].myActors.empty()) - //_CS_PhB if (myFieldsLst[i].myActors.at(myFrame) != 0) -//_CS_PhB myFieldsLst[i].myActors.at(myFrame)->VisibilityOff(); if (myFieldsLst[i].myActors[myFrame] != 0) myFieldsLst[i].myActors[myFrame]->VisibilityOff(); myFrame = 0; for (i = 0; i < getNbFields(); i++) if(!myFieldsLst[i].myActors.empty()) - //_CS_PhB if (myFieldsLst[i].myActors.at(myFrame) != 0) -//_CS_PhB myFieldsLst[i].myActors.at(myFrame)->VisibilityOn(); if (myFieldsLst[i].myActors[myFrame] != 0) myFieldsLst[i].myActors[myFrame]->VisibilityOn(); if(!myFieldsLst[0].myTiming.empty()){ - //_CS_PhB emit frameChanged(myFrame, myFieldsLst[0].myTiming.at(myFrame)); emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]); myView->Repaint(); } @@ -419,18 +373,14 @@ void VISU_TimeAnimation::lastFrame() { stopAnimation(); int i; for (i = 0; i < getNbFields(); i++) - //_CS_PhB if (myFieldsLst[i].myActors.at(myFrame) != 0) - //_CS_PhB myFieldsLst[i].myActors.at(myFrame)->VisibilityOff(); if (myFieldsLst[i].myActors[myFrame] != 0) myFieldsLst[i].myActors[myFrame]->VisibilityOff(); + myFrame = myFieldsLst[0].myNbFrames-1; for (i = 0; i < getNbFields(); i++) -//_CS_PhB if (myFieldsLst[i].myActors.at(myFrame) != 0) -//_CS_PhB myFieldsLst[i].myActors.at(myFrame)->VisibilityOn(); if (myFieldsLst[i].myActors[myFrame] != 0) myFieldsLst[i].myActors[myFrame]->VisibilityOn(); -//_CS_PhB emit frameChanged(myFrame, myFieldsLst[0].myTiming.at(myFrame)); emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]); myView->Repaint(); } @@ -446,19 +396,14 @@ void VISU_TimeAnimation::gotoFrame(CORBA::Long theFrame) { qApp->syncX(); int i; for (i = 0; i < getNbFields(); i++) -//_CS_PhB if (myFieldsLst[i].myActors.at(myFrame) != 0) -//_CS_PhB myFieldsLst[i].myActors.at(myFrame)->VisibilityOff(); if (myFieldsLst[i].myActors[myFrame] != 0) myFieldsLst[i].myActors[myFrame]->VisibilityOff(); myFrame = theFrame; for (i = 0; i < getNbFields(); i++) -//_CS_PhB if (myFieldsLst[i].myActors.at(myFrame) != 0) -//_CS_PhB myFieldsLst[i].myActors.at(myFrame)->VisibilityOn(); if (myFieldsLst[i].myActors[myFrame] != 0) myFieldsLst[i].myActors[myFrame]->VisibilityOn(); -//_CS_PhB emit frameChanged(myFrame, myFieldsLst[0].myTiming.at(myFrame)); emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]); myView->Repaint(); qApp->flushX(); @@ -473,7 +418,6 @@ VISU::ScalarMap_ptr VISU_TimeAnimation::getPresentation(CORBA::Long theField, CO return VISU::ScalarMap::_nil(); if ((theFrame < 0) || (theFrame > (myFieldsLst[theField].myNbFrames - 1))) return VISU::ScalarMap::_nil(); -//_CS_PhB return myFieldsLst[theField].myPrs.at(theFrame)->_this(); return myFieldsLst[theField].myPrs[theFrame]->_this(); } @@ -494,27 +438,19 @@ void VISU_TimeAnimation::run() { double aOneVal; bool isDumping = !myDumpPath.isEmpty(); aOneVal = (myFieldsLst[0].myNbFrames > 2) ? - //_CS_PhB myFieldsLst[0].myTiming.at(1) - myFieldsLst[0].myTiming.at(0) : 1; myFieldsLst[0].myTiming[1] - myFieldsLst[0].myTiming[0] : 1; qApp->lock(); while (myIsActive) { - //_CS_PhB emit frameChanged(myFrame, myFieldsLst[0].myTiming.at(myFrame)); emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]); for (int i = 0; i < getNbFields(); i++) { FieldData& aData = myFieldsLst[i]; if (myFrame > 0) { -//_CS_PhB if (aData.myActors.at(myFrame-1) != 0) -//_CS_PhB aData.myActors.at(myFrame-1)->VisibilityOff(); if (aData.myActors[myFrame-1] != 0) aData.myActors[myFrame-1]->VisibilityOff(); } else { -//_CS_PhB if (aData.myActors.at(aData.myNbFrames-1) != 0) -//_CS_PhB aData.myActors.at(aData.myNbFrames-1)->VisibilityOff(); if (aData.myActors[aData.myNbFrames-1] != 0) aData.myActors[aData.myNbFrames-1]->VisibilityOff(); } -//_CS_PhB if (aData.myActors.at(myFrame) != 0) { -//_CS_PhB aData.myActors.at(myFrame)->VisibilityOn(); if (aData.myActors[myFrame] != 0) { aData.myActors[myFrame]->VisibilityOn(); } @@ -523,7 +459,6 @@ void VISU_TimeAnimation::run() { if (isDumping) { QPixmap px = QPixmap::grabWindow(myView->getViewWidget()->winId()); QString aFile(myDumpPath); -//_CS_PhB QString aName = QString("%1").arg(myFieldsLst[0].myTiming.at(myFrame)); QString aName = QString("%1").arg(myFieldsLst[0].myTiming[myFrame]); int aPos = -1; while ((aPos = aName.find(".")) > -1 ) @@ -531,7 +466,7 @@ void VISU_TimeAnimation::run() { aFile += aName; aFile += ".jpeg"; px.save(aFile, "JPEG"); - }//_CS_PhB + } if (!isDumping) { if (myProportional) { switch (myFrame) { @@ -540,14 +475,12 @@ void VISU_TimeAnimation::run() { break; case 1: if (myFieldsLst[0].myNbFrames > 2) -//_CS_PhB k = (myFieldsLst[0].myTiming.at(myFrame+1) - myFieldsLst[0].myTiming.at(myFrame))/aOneVal; k = (myFieldsLst[0].myTiming[myFrame+1] - myFieldsLst[0].myTiming[myFrame])/aOneVal; else k = 1; break; default: k = (myFrame < (myFieldsLst[0].myNbFrames-1))? -//_CS_PhB (myFieldsLst[0].myTiming.at(myFrame+1) - myFieldsLst[0].myTiming.at(myFrame))/aOneVal : 1; (myFieldsLst[0].myTiming[myFrame+1] - myFieldsLst[0].myTiming[myFrame])/aOneVal : 1; } } else @@ -611,6 +544,7 @@ double VISU_TimeAnimation::getTimeValue(SALOMEDS::SObject_var theTimeStamp) { QString aNameString(aName->Value()); return aNameString.toDouble(); } + return -1.0; } //************************************************************************ diff --git a/src/VISU_I/VISU_Vectors_i.cc b/src/VISU_I/VISU_Vectors_i.cc index 4cb92b29..b7ac3c0a 100644 --- a/src/VISU_I/VISU_Vectors_i.cc +++ b/src/VISU_I/VISU_Vectors_i.cc @@ -54,10 +54,10 @@ int VISU::Vectors_i::IsPossible(Result_i* theResult, const char* theMeshName, VI aResult = VISU_PipeLine::CheckAvailableMemory(aSize); MESSAGE("Vectors_i::IsPossible - CheckAvailableMemory = "< #include -#include -#include #include #include @@ -76,7 +78,6 @@ static int MYDEBUG = 0; #endif static QFileInfo aFileInfo; -static int MYDELAY = 1; namespace VISU{ //=========================================================================== @@ -100,6 +101,233 @@ namespace VISU{ } }; + class TSetViewRepresentation: public SALOME_Event{ + VISU::View::ViewRepresentation myViewRepr; + View_i* myView; + CORBA::Boolean myState; + public: + TSetViewRepresentation( View_i* aView, + VISU::View::ViewRepresentation ViewRepr, + CORBA::Boolean State ): + SALOME_Event(), myViewRepr( ViewRepr ), myView( aView ), myState( State ) + {} + virtual void Execute(){ + + bool old = myView->IsPartShown( myViewRepr ); + + QAD_RightFrame* fr = myView->myStudyFrame->getRightFrame(); + + if( myView->myStudyFrame != NULL ){ + switch( myViewRepr ) + { + case VISU::View::OBJECTBROWSER: + if( myState!=old ) + if( myState ) + myView->myStudyFrame->unCompressLeft(); + else + myView->myStudyFrame->compressLeft(); + break; + case VISU::View::VIEWER: + if( myState!=old ) + if( myState ) + fr->unCompressUp(); + else + fr->compressUp(); + break; + case VISU::View::PYTHON: + if( myState!=old ) + if( myState ) + fr->unCompressLeft(); + else + fr->compressLeft(); + break; + case VISU::View::MESSAGES: + if( myState!=old ) + if( myState ) + fr->unCompressRight(); + else + fr->compressRight(); + break; + }; + } + } +}; + + class TGetViewRepresentation: public SALOME_Event + { + public: + typedef CORBA::Boolean TResult; + TResult myResult; + VISU::View::ViewRepresentation myPart; + View_i* myView; + + TGetViewRepresentation( View_i* aView, VISU::View::ViewRepresentation Part ): + SALOME_Event(), myResult( false ), myPart( Part ), myView( aView ) + { + } + virtual void Execute(){ + switch( myPart ) + { + case VISU::View::OBJECTBROWSER: + myResult = !myView->myStudyFrame->isCompressedLeft(); + break; + case VISU::View::VIEWER: + myResult = !myView->myStudyFrame->getRightFrame()->isCompressedViewFrame(); + break; + case VISU::View::PYTHON: + myResult = !myView->myStudyFrame->getRightFrame()->isCompressedPython(); + break; + case VISU::View::MESSAGES: + myResult = !myView->myStudyFrame->getRightFrame()->isCompressedMessage(); + } + } + }; + + class TSetViewWidthHeight: public SALOME_Event{ + CORBA::Long mySize; + bool myIsWidth; + View_i* myView; + public: + TSetViewWidthHeight( View_i* aView, CORBA::Long Size, bool IsWidth ): + SALOME_Event(), mySize( Size ), myView( aView ), myIsWidth( IsWidth ) + {} + virtual void Execute(){ + if( myView->myStudyFrame != NULL ){ + QWidget* aStudyParent = myView->myStudyFrame->parentWidget(true); + int aleft = aStudyParent->frameGeometry().left(); + int atop = aStudyParent->frameGeometry().top(); + int aheight = aStudyParent->frameGeometry().height(); + int awidth = aStudyParent->frameGeometry().width(); + QRect aQRect; + if( myIsWidth ) + aQRect = QRect( aleft, atop, mySize, aheight ); + else + aQRect = QRect( aleft, atop, awidth, mySize ); + + aStudyParent->setGeometry(aQRect); + } + } + }; + + class TGetViewWidthHeight: public SALOME_Event{ + public: + typedef CORBA::Long TResult; + TResult myResult; + bool myIsWidth; + View_i* myView; + public: + TGetViewWidthHeight( View_i* aView, bool IsWidth ): + SALOME_Event(), myView( aView ), myIsWidth( IsWidth ) + {} + + virtual void Execute() + { + if( myView ) { + QWidget* aStudyParent = myView->myStudyFrame->parentWidget(true); + if( myIsWidth ) + myResult = aStudyParent->frameGeometry().width(); + else + myResult = aStudyParent->frameGeometry().height(); + } + } + }; + + class TSetViewPositionHorizontal: public SALOME_Event{ + VISU::View::ViewPosition myViewPos; + View_i* myView; + public: + TSetViewPositionHorizontal ( View_i* aView, + VISU::View::ViewPosition ViewPos ): + SALOME_Event(), myView( aView ), myViewPos(ViewPos) + {} + virtual void Execute(){ + QWidget* aWorkspace = dynamic_cast (myView->myStudy->getApp()->getDesktop()->getMainFrame()); + QWidget* aStudy = dynamic_cast (myView->myStudyFrame); + QWidget* aStudyParent = aStudy->parentWidget(true); + if ( aStudyParent != 0 ) + if ( aWorkspace!=NULL || aStudy != NULL ) + switch(myViewPos){ + case VISU::View::LEFT: + QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignLeft); + break; + case VISU::View::CENTER: + QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignHCenter); + break; + case VISU::View::RIGHT: + QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignRight); + break; + } + } + }; + + class TSetViewPositionVertical: public SALOME_Event{ + VISU::View::ViewPosition myViewPos; + View_i* myView; + public: + TSetViewPositionVertical ( View_i* aView, + VISU::View::ViewPosition ViewPos ): + SALOME_Event(), myView( aView ), myViewPos(ViewPos) + {} + virtual void Execute(){ + QWidget* aWorkspace = dynamic_cast (myView->myStudy->getApp()->getDesktop()->getMainFrame()); + QWidget* aStudy = dynamic_cast (myView->myStudyFrame); + QWidget* aStudyParent = aStudy->parentWidget(true); + if ( aStudyParent != 0 ) + if ( aWorkspace!=NULL || aStudy != NULL ) + switch(myViewPos){ + case VISU::View::TOP: + QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignTop); + break; + case VISU::View::CENTER: + QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignVCenter); + break; + case VISU::View::BOTTOM: + QAD_Tools::alignWidget(aStudyParent,aWorkspace,Qt::AlignBottom); + break; + } + } + }; + + class TSetRelativePosition : public SALOME_Event + { + View_i* myView; + CORBA::Double myX, myY; + public: + TSetRelativePosition ( View_i* aView, CORBA::Double X, CORBA::Double Y ): + SALOME_Event(), myView( aView ), myX( X ), myY( Y ) + {} + virtual void Execute(){ + QWidget* aWorkspace = dynamic_cast (myView->myStudy->getApp()->getDesktop()->getMainFrame()); + if( aWorkspace ) + { + QAD_StudyFrame* aFrame = myView->myStudyFrame; + QWidget* aStudyParent = aFrame->parentWidget(true); + aStudyParent->move( int( myX * aWorkspace->width() ), int( myY * aWorkspace->height() ) ); + } + } + }; + + class TSetRelativeSize : public SALOME_Event + { + View_i* myView; + CORBA::Double myX, myY; + public: + TSetRelativeSize ( View_i* aView, CORBA::Double X, CORBA::Double Y ): + SALOME_Event(), myView( aView ), myX( X ), myY( Y ) + {} + virtual void Execute(){ + QWidget* aWorkspace = dynamic_cast (myView->myStudy->getApp()->getDesktop()->getMainFrame()); + if( aWorkspace ) + { + QAD_StudyFrame* aFrame = myView->myStudyFrame; + QWidget* aStudyParent = aFrame->parentWidget(true); + aStudyParent->setGeometry( aStudyParent->x(), aStudyParent->y(), + int( myX * aWorkspace->width() ), int( myY * aWorkspace->height() ) ); + } + } + }; + + class TSavePictureEvent: public SALOME_Event{ QWidget* myWidget; @@ -152,12 +380,16 @@ namespace VISU{ } - void RepaintView(QAD_StudyFrame* theStudyFrame){ - GetRenderer(theStudyFrame)->ResetCameraClippingRange(); - GetViewFrame(theStudyFrame)->getRW()->getRenderWindow()->Render(); + void RepaintView(VTKViewer_ViewFrame* theViewFrame){ + theViewFrame->getRenderer()->ResetCameraClippingRange(); + theViewFrame->getRW()->getRenderWindow()->Render(); //GetViewFrame(theStudyFrame)->Repaint(); } + void RepaintView(QAD_StudyFrame* theStudyFrame){ + RepaintView(GetViewFrame(theStudyFrame)); + } + VISU_Actor* UpdateViewer(QAD_StudyFrame* theStudyFrame, int theDisplaing, Prs3d_i* thePrs){ VTKViewer_ViewFrame* vf = GetViewFrame(theStudyFrame); @@ -225,18 +457,23 @@ namespace VISU{ for ( int i = 0; i < clist.count(); i++ ) { if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) { if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve - "<setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) ); - clist.at( i )->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) ); - clist.at( i )->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) ); - clist.at( i )->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) ); - /* - DATA NOT UPDATED */ - if ( !clist.at( i )->isAutoAssign() ) { + clist.at( i )->setHorTitle( theCurve->GetHorTitle().c_str() ); + clist.at( i )->setVerTitle( theCurve->GetVerTitle().c_str() ); + clist.at( i )->setHorUnits( theCurve->GetHorUnits().c_str() ); + clist.at( i )->setVerUnits( theCurve->GetVerUnits().c_str() ); + double* xList = 0; + double* yList = 0; + int nbPoints = theCurve->GetData( xList, yList ); + if ( nbPoints > 0 && xList && yList ) { + clist.at( i )->setData( xList, yList, nbPoints ); + } + if ( !theCurve->IsAuto() ) { clist.at( i )->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() ); clist.at( i )->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() ); SALOMEDS::Color color = theCurve->GetColor(); clist.at( i )->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) ); - clist.at( i )->setAutoAssign( theCurve->IsAuto() ); } + clist.at( i )->setAutoAssign( theCurve->IsAuto() ); theView->displayCurve( clist.at( i ) ); bFound = true; } @@ -244,8 +481,17 @@ namespace VISU{ if ( !bFound ) { Plot2d_Curve* crv = theCurve->CreatePresentation(); if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve (new) - "<displayCurve( crv ); + theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() ); + theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker()); + SALOMEDS::Color newColor; + newColor.R = crv->getColor().red()/255.; + newColor.G = crv->getColor().green()/255.; + newColor.B = crv->getColor().blue()/255.; + theCurve->SetColor( newColor ); + crv->setAutoAssign( theCurve->IsAuto() ); + } } } else if ( theDisplaying == eDisplayOnly ) { @@ -253,18 +499,23 @@ namespace VISU{ for ( int i = 0; i < clist.count(); i++ ) { if ( theCurve && clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) { if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve - "<setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) ); - clist.at( i )->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) ); - clist.at( i )->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) ); - clist.at( i )->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) ); - /* - DATA NOT UPDATED */ - if ( !clist.at( i )->isAutoAssign() ) { + clist.at( i )->setHorTitle( theCurve->GetHorTitle().c_str() ); + clist.at( i )->setVerTitle( theCurve->GetVerTitle().c_str() ); + clist.at( i )->setHorUnits( theCurve->GetHorUnits().c_str() ); + clist.at( i )->setVerUnits( theCurve->GetVerUnits().c_str() ); + double* xList = 0; + double* yList = 0; + int nbPoints = theCurve->GetData( xList, yList ); + if ( nbPoints > 0 && xList && yList ) { + clist.at( i )->setData( xList, yList, nbPoints ); + } + if ( !theCurve->IsAuto() ) { clist.at( i )->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() ); clist.at( i )->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() ); SALOMEDS::Color color = theCurve->GetColor(); clist.at( i )->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) ); - clist.at( i )->setAutoAssign( theCurve->IsAuto() ); } + clist.at( i )->setAutoAssign( theCurve->IsAuto() ); theView->displayCurve( clist.at( i ) ); bFound = true; } @@ -275,8 +526,17 @@ namespace VISU{ if ( !bFound ) { Plot2d_Curve* crv = theCurve->CreatePresentation(); if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve (new) - "<displayCurve( crv ); + theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() ); + theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker()); + SALOMEDS::Color newColor; + newColor.R = crv->getColor().red()/255.; + newColor.G = crv->getColor().green()/255.; + newColor.B = crv->getColor().blue()/255.; + theCurve->SetColor( newColor ); + crv->setAutoAssign( theCurve->IsAuto() ); + } } } } @@ -304,38 +564,36 @@ namespace VISU{ } - VISU::View_ptr ViewManager_i::GetCurrentView(){ - class TEvent: public SALOME_Event{ - SALOMEDS::Study_ptr myStudyDocument; - public: - TEvent( SALOMEDS::Study_ptr theStudy): - myStudyDocument(theStudy) - {} - virtual void Execute(){ - if(QAD_Study* aStudy = QAD_Application::getDesktop()->findStudy( myStudyDocument )){ - if ( QAD_StudyFrame* aStudyFrame = aStudy->getActiveStudyFrame() ) { - if(MYDEBUG) - MESSAGE("GetCurrentView::Execute - TypeView = "<getTypeView()); - if ( aStudyFrame->getTypeView() == VIEW_VTK ) { - VISU::View3D_i* pView = new View3D_i(myStudyDocument); - if(pView->Create(0)) - myResult = pView->_this(); - } else if ( aStudyFrame->getTypeView() == VIEW_PLOT2D ) { - VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument); - if(pView->Create(0)) - myResult = pView->_this(); - } + class TGetCurrentViewEvent: public SALOME_Event{ + SALOMEDS::Study_ptr myStudyDocument; + public: + TGetCurrentViewEvent( SALOMEDS::Study_ptr theStudy): + myStudyDocument(theStudy), + myResult(VISU::View::_nil()) + {} + virtual void Execute(){ + if(QAD_Study* aStudy = QAD_Application::getDesktop()->findStudy( myStudyDocument )){ + if ( QAD_StudyFrame* aStudyFrame = aStudy->getActiveStudyFrame() ) { + if(MYDEBUG) + MESSAGE("GetCurrentView::Execute - TypeView = "<getTypeView()); + if ( aStudyFrame->getTypeView() == VIEW_VTK ) { + VISU::View3D_i* pView = new View3D_i(myStudyDocument); + if(pView->Create(0)) + myResult = pView->_this(); + } else if ( aStudyFrame->getTypeView() == VIEW_PLOT2D ) { + VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument); + if(pView->Create(0)) + myResult = pView->_this(); } } } - typedef VISU::View_var TResult; - TResult myResult; - }; - TEvent* ve = new TEvent( myStudyDocument ); - ve->process(); - TEvent::TResult aResult = ve->myResult; - ve->release(); - return aResult._retn(); + } + typedef VISU::View_ptr TResult; + TResult myResult; + }; + + VISU::View_ptr ViewManager_i::GetCurrentView(){ + return ProcessEvent(new TGetCurrentViewEvent( myStudyDocument )); } @@ -381,31 +639,29 @@ namespace VISU{ } - VISU::TableView_ptr ViewManager_i::CreateTableView(VISU::Table_ptr theTable){ - class TEvent: public TCreateViewEvent{ - Table_ptr myTable; - public: - TEvent(SALOMEDS::Study_ptr theStudy, - Table_ptr theTable): - TCreateViewEvent(theStudy), - myTable(theTable) - {} - virtual void Execute(){ - if ( CheckStudy( myStudyDocument ) ) { - VISU::TableView_i* pView = new TableView_i(myStudyDocument); - if(pView->Create(myTable) != NULL) - myResult = pView->_this(); - } + class TCreateTableViewEvent: public TCreateViewEvent{ + Table_ptr myTable; + public: + TCreateTableViewEvent(SALOMEDS::Study_ptr theStudy, + Table_ptr theTable): + TCreateViewEvent(theStudy), + myTable(theTable), + myResult(VISU::TableView::_nil()) + {} + virtual void Execute(){ + if ( CheckStudy( myStudyDocument ) ) { + VISU::TableView_i* pView = new TableView_i(myStudyDocument); + if(pView->Create(myTable) != NULL) + myResult = pView->_this(); } - typedef VISU::TableView_var TResult; - TResult myResult; - }; + } + typedef VISU::TableView_ptr TResult; + TResult myResult; + }; + + VISU::TableView_ptr ViewManager_i::CreateTableView(VISU::Table_ptr theTable){ if(MYDEBUG) MESSAGE("ViewManager_i::CreateTableView"); - TEvent* ve = new TEvent(myStudyDocument,theTable); - ve->process(); - TEvent::TResult aResult = ve->myResult; - ve->release(); - return aResult._retn(); + return ProcessEvent(new TCreateTableViewEvent(myStudyDocument,theTable)); } @@ -432,6 +688,7 @@ namespace VISU{ //=========================================================================== View_i::View_i(SALOMEDS::Study_ptr theStudy) { + myStudyFrame = NULL; if(MYDEBUG) MESSAGE("View_i::View_i"); CORBA::String_var aName = theStudy->Name(); myStudy = CheckStudy(theStudy); @@ -741,11 +998,7 @@ namespace VISU{ CORBA::Boolean XYPlot_i::SavePicture(const char* theFileName) { - TSavePictureEvent* ve = new TSavePictureEvent(myView->getViewWidget(),theFileName); - ve->process(); - TSavePictureEvent::TResult aResult = ve->myResult; - ve->release(); - return aResult; + return ProcessEvent(new TSavePictureEvent(myView->getViewWidget(),theFileName)); } @@ -829,9 +1082,8 @@ namespace VISU{ vtkRenderer* Renderer = vf->getRenderer(); vtkActorCollection* theActors = Renderer->GetActors(); theActors->InitTraversal(); - vtkActor *actor; - while(actor = theActors->GetNextActor()){ - if(VISU_Actor* anActor = dynamic_cast(actor)){ + while(vtkActor *anAct = theActors->GetNextActor()){ + if(VISU_Actor* anActor = dynamic_cast(anAct)){ VISU::Prs3d_i* aPrs3d = anActor->GetPrs3d(); if(anActor->GetVisibility() && aPrs3d){ aPrs3d->Update(); @@ -847,11 +1099,7 @@ namespace VISU{ CORBA::Boolean View3D_i::SavePicture(const char* theFileName) { - TSavePictureEvent* ve = new TSavePictureEvent(myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget(),theFileName); - ve->process(); - TSavePictureEvent::TResult aResult = ve->myResult; - ve->release(); - return aResult; + return ProcessEvent(new TSavePictureEvent(myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget(),theFileName)); } @@ -918,27 +1166,24 @@ namespace VISU{ } + class TRestoreViewParamsEvent: public SALOME_Event{ + QAD_StudyFrame* myStudyFrame; + const char* myName; + public: + TRestoreViewParamsEvent(QAD_StudyFrame* theStudyFrame, + const char* theName): + myStudyFrame(theStudyFrame), + myName(theName) + {} + virtual void Execute(){ + myResult = View3D_i::RestoreViewParams(myStudyFrame,myName); + } + typedef CORBA::Boolean TResult; + TResult myResult; + }; + CORBA::Boolean View3D_i::RestoreViewParams(const char* theName){ - class TEvent: public SALOME_Event{ - QAD_StudyFrame* myStudyFrame; - const char* myName; - public: - TEvent(QAD_StudyFrame* theStudyFrame, - const char* theName): - myStudyFrame(theStudyFrame), - myName(theName) - {} - virtual void Execute(){ - myResult = RestoreViewParams(myStudyFrame,myName); - } - typedef CORBA::Boolean TResult; - TResult myResult; - }; - TEvent* ve = new TEvent(myStudyFrame,theName); - ve->process(); - TEvent::TResult aResult = ve->myResult; - ve->release(); - return aResult; + return ProcessEvent(new TRestoreViewParamsEvent(myStudyFrame,theName)); } @@ -1038,6 +1283,56 @@ namespace VISU{ } //-------------------- View interface -------------------- + + void View_i::ShowPart( VISU::View::ViewRepresentation ViewRepr, CORBA::Boolean state ) { + ProcessVoidEvent( new TSetViewRepresentation( this, ViewRepr, state ) ); + Update(); + } + + CORBA::Boolean View_i::IsPartShown( VISU::View::ViewRepresentation Part ) + { + return ProcessEvent( new TGetViewRepresentation( this, Part ) ); + } + + void View_i::SetViewWidth(CORBA::Long Width){ + ProcessVoidEvent( new TSetViewWidthHeight( this, Width, true ) ); + } + + void View_i::SetViewHeight(CORBA::Long Height){ + ProcessVoidEvent( new TSetViewWidthHeight( this, Height, false ) ); + } + + CORBA::Long View_i::GetViewWidth() + { + return ProcessEvent( new TGetViewWidthHeight( this, true ) ); + } + + CORBA::Long View_i::GetViewHeight() + { + return ProcessEvent( new TGetViewWidthHeight( this, false ) ); + } + + void View_i::SetViewPositionHorizontal( VISU::View::ViewPosition ViewPosHor ){ + ProcessVoidEvent( new TSetViewPositionHorizontal( this, ViewPosHor ) ); + } + + void View_i::SetViewPositionVertical( VISU::View::ViewPosition ViewPosVer ){ + ProcessVoidEvent( new TSetViewPositionVertical( this, ViewPosVer ) ); + } + + void View_i::SetRelativePosition( CORBA::Double x, CORBA::Double y ) + { + ProcessVoidEvent( new TSetRelativePosition( this, x, y ) ); + } + + void View_i::SetRelativeSize( CORBA::Double x, CORBA::Double y ) + { + ProcessVoidEvent( new TSetRelativeSize( this, x, y ) ); + } + + + + void View3D_i::SetTitle(const char* theTitle){ ProcessVoidEvent(new TVoidMemFun1ArgEvent (myStudyFrame,&QAD_StudyFrame::setTitle,QString(theTitle))); @@ -1309,92 +1604,97 @@ namespace VISU{ ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,myStudyFrame,aScale)); } //=========================================================================== -}; -/*! SAN & VSR : Test QT_EVENT - >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -*/ -#include "VISU_Gen_i.hh" -#include "QAD_Config.h" -#include -#include -#include + VISU_Actor* GetActor(VISU::Prs3d_i* thePrs3d, VTKViewer_ViewFrame* theVTKFrame){ + vtkActor *anActor; + vtkActorCollection *anActColl = theVTKFrame->getRenderer()->GetActors(); + anActColl->InitTraversal(); + while(vtkActor *anActor = anActColl->GetNextActor()) + if(VISU_Actor* anVISUActor = dynamic_cast(anActor)) + if(thePrs3d == anVISUActor->GetPrs3d()) + return anVISUActor->GetParent(); + return NULL; + } -namespace VISU{ - class TestViewEvent : public SALOME_Event { - public: - virtual void Execute(){ - QAD_Desktop* desktop = QAD_Application::getDesktop(); - QAD_Study* aStudy = desktop->getActiveStudy(); - if ( !aStudy ) { - QString defViewer = QAD_CONFIG->getSetting( "Viewer::DefaultViewer" ); - int dv = defViewer.toInt(); - QAD_CONFIG->addSetting( "Viewer::DefaultViewer", QString::number( VIEW_VTK ) ); - desktop->createStudy(); - if ( !defViewer.isEmpty() ) { - QAD_CONFIG->addSetting( "Viewer::DefaultViewer", QString::number( dv ) ); + + void DeletePrs3d(Prs3d_ptr thePrs3d){ + if(Prs3d_i* aPrs3d = dynamic_cast(GetServant(thePrs3d).in())){ + SALOMEDS::SObject_var aSObject = aPrs3d->GetSObject(); + SALOMEDS::Study_var aStudyDocument = aSObject->GetStudy(); + if(QAD_Desktop* aDesktop = QAD_Application::getDesktop()){ + if(QAD_Study* aStudy = aDesktop->findStudy(aStudyDocument)){ + aStudy->unHighlightAll(); + int aNbStudyFrames = aStudy->getStudyFramesCount(); + for(int aFrameId = 0; aFrameId < aNbStudyFrames; aFrameId++){ + if(QAD_StudyFrame* aFrame = aStudy->getStudyFrame(aFrameId)){ + QAD_ViewFrame* aViewFrame = aFrame->getRightFrame()->getViewFrame(); + if(VTKViewer_ViewFrame* aVTKFrame = dynamic_cast(aViewFrame)){ + if(VISU_Actor* anActor = VISU::GetActor(aPrs3d,aVTKFrame)){ + aVTKFrame->RemoveActor(anActor); + anActor->Delete(); + } + aVTKFrame->unHighlightAll(); + } + } + } + + aPrs3d->RemoveFromStudy(); + aPrs3d->Destroy(); + + aStudy->updateObjBrowser(); //update Object browser } } - else { - aStudy->newWindow3d( "", VIEW_VTK ); - } } - }; + } + - void VISU_Gen_i::CreateTestView() { - TestViewEvent* ve = new TestViewEvent(); - ve->process(); - ve->release(); + void VISU_Gen_i::DeleteResult(Result_ptr theResult) + { + class TEvent: public SALOME_Event{ + Result_ptr myResult; + public: + TEvent(Result_ptr theResult): myResult(theResult) {} + virtual void Execute(){ + if(Result_i* aResult = dynamic_cast(GetServant(myResult).in())){ + SALOMEDS::SObject_var aSObject = aResult->GetSObject(); + SALOMEDS::Study_var aStudyDocument = aSObject->GetStudy(); + SALOMEDS::ChildIterator_var aChildIter = aStudyDocument->NewChildIterator(aSObject); + 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::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aChildObj); + if(CORBA::is_nil(aPrs3d)) continue; + VISU::DeletePrs3d(aPrs3d); + } + + aResult->RemoveFromStudy(); + aResult->Destroy(); + + if(QAD_Desktop* aDesktop = QAD_Application::getDesktop()) + if(QAD_Study* aStudy = aDesktop->findStudy(aStudyDocument)) + aStudy->updateObjBrowser(); //update Object browser + } + } + }; + + ProcessVoidEvent(new TEvent(theResult)); } - class TestObjectEvent : public SALOME_Event { - public: - virtual void Execute(){ - float aRadius = 150.0 * random() / RAND_MAX + 10.; - float aX = 1000.0 * random() / RAND_MAX - 500.; - float aY = 1000.0 * random() / RAND_MAX - 500.; - float aZ = 1000.0 * random() / RAND_MAX - 500.; - float aR = (float)random() / RAND_MAX; - float aG = (float)random() / RAND_MAX; - float aB = (float)random() / RAND_MAX; - - vtkSphereSource* aSource = vtkSphereSource::New(); - aSource->SetRadius( aRadius ); - aSource->SetCenter( aX, aY, aZ ); - - vtkProperty* prop = vtkProperty::New(); - prop->SetColor( aR, aG, aB ); - - vtkPolyDataMapper* aMapper = vtkPolyDataMapper::New(); - aMapper->SetInput( aSource->GetOutput() ); - - vtkActor* sphere = vtkActor::New(); - sphere->SetMapper( aMapper ); - sphere->SetProperty( prop ); - - QAD_Desktop* desktop = QAD_Application::getDesktop(); - QAD_Study* aStudy = desktop->getActiveStudy(); - if ( !aStudy ) - return ; - QAD_StudyFrame* sf = desktop->getActiveStudy()->getActiveStudyFrame(); - VTKViewer_ViewFrame* vf = GetViewFrame( sf ); - if ( !vf ) - return; - sphere->SetVisibility( true ); - vf->getRenderer()->AddActor(sphere); - vf->Repaint(); - } - }; + void VISU_Gen_i::DeletePrs3d(Prs3d_ptr thePrs3d) + { + class TEvent: public SALOME_Event{ + Prs3d_ptr myPrs3d; + public: + TEvent(Prs3d_ptr thePrs3d): myPrs3d(thePrs3d) {} + virtual void Execute(){ + VISU::DeletePrs3d(myPrs3d); + } + }; - void VISU_Gen_i::ShowTestObject() { - TestObjectEvent* ve = new TestObjectEvent(); - ve->process(); - ve->release(); - return; + ProcessVoidEvent(new TEvent(thePrs3d)); } - /*! SAN & VSR : Test QT_EVENT - <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - */ -}; + +} diff --git a/src/VISU_I/VISU_ViewManager_i.hh b/src/VISU_I/VISU_ViewManager_i.hh index b399434d..c647ea6d 100644 --- a/src/VISU_I/VISU_ViewManager_i.hh +++ b/src/VISU_I/VISU_ViewManager_i.hh @@ -65,9 +65,23 @@ namespace VISU{ class View_i : public virtual POA_VISU::View, public virtual Storable { - protected: - QAD_Study* myStudy; public: + QAD_Study* myStudy; + QAD_StudyFrame* myStudyFrame; + + public: + virtual void ShowPart( VISU::View::ViewRepresentation ViewRepr, CORBA::Boolean state ); + virtual CORBA::Boolean IsPartShown( VISU::View::ViewRepresentation ViewRepr ); + virtual void SetViewWidth(CORBA::Long Width); + virtual void SetViewHeight(CORBA::Long Height); + virtual CORBA::Long GetViewWidth(); + virtual CORBA::Long GetViewHeight(); + virtual void SetViewPositionHorizontal(VISU::View::ViewPosition ViewPosHor); + virtual void SetViewPositionVertical(VISU::View::ViewPosition ViewPosVer); + + virtual void SetRelativePosition( CORBA::Double x, CORBA::Double y ); + virtual void SetRelativeSize( CORBA::Double x, CORBA::Double y ); + View_i(SALOMEDS::Study_ptr theStudy); virtual ~View_i(); virtual void SetBackground(const SALOMEDS::Color& theColor); @@ -87,6 +101,7 @@ namespace VISU{ virtual void Close() = 0; virtual void ToStream(std::ostringstream& theStr); virtual const char* GetComment() const; + public: virtual std::string View_i::GetEntry(); }; @@ -148,7 +163,6 @@ namespace VISU{ virtual void Close(); protected: - QAD_StudyFrame* myStudyFrame; Plot2d_ViewFrame* myView; public: virtual Storable* Create(int theNew); @@ -251,20 +265,21 @@ namespace VISU{ virtual void Close(); protected: - QAD_StudyFrame* myStudyFrame; static int myNbViewParams; public: virtual Storable* Create(int theNew); virtual void ToStream(std::ostringstream& theStr); virtual const char* GetComment() const; - static const string myComment; + static const std::string myComment; QAD_StudyFrame* GetStudyFrame() const { return myStudyFrame;} }; VTKViewer_ViewFrame* GetViewFrame(QAD_StudyFrame* theStudyFrame); vtkRenderer* GetRenderer(QAD_StudyFrame* theStudyFrame); vtkCamera* GetCamera(QAD_StudyFrame* theStudyFrame); + + void RepaintView(VTKViewer_ViewFrame* theViewFrame); void RepaintView(QAD_StudyFrame* theStudyFrame); enum Displaing {eDisplayAll, eDisplay, eDisplayOnly, eErase, eEraseAll}; diff --git a/src/VISU_SWIG/Makefile.in b/src/VISU_SWIG/Makefile.in index d4b0ac36..8474ef9e 100644 --- a/src/VISU_SWIG/Makefile.in +++ b/src/VISU_SWIG/Makefile.in @@ -43,7 +43,7 @@ SWIG_FLAGS += SWIG_DEF = libVISU_Swig.i EXPORT_PYSCRIPTS = libVISU_Swig.py batchmode_visu.py batchmode_visu_table.py batchmode_visu_view3d.py \ visu_med.py visu_view3d.py visu.py visu_gui.py visu_prs_example.py\ - visu_table.py visu_big_table.py visu_view.py \ + visu_table.py visu_big_table.py visu_view.py visu_delete.py\ visu_swig_test.py test_events.py batch_test_events.py EXPORT_SHAREDPYSCRIPTS = VISU_shared_modules.py diff --git a/src/VISU_SWIG/visu.py b/src/VISU_SWIG/visu.py index 840c61ea..fc023764 100644 --- a/src/VISU_SWIG/visu.py +++ b/src/VISU_SWIG/visu.py @@ -38,7 +38,8 @@ def Initialize(theORB, theNamingService, theLifeCycleCORBA, theStudyManager, the myNamingService = theNamingService myLifeCycleCORBA = theLifeCycleCORBA myLocalStudyManager = theStudyManager - mySession = myNamingService.Resolve("/Kernel/Session") + while mySession == None: + mySession = myNamingService.Resolve("/Kernel/Session") mySession = mySession._narrow(SALOME.Session) mySession.GetInterface() myDelay = theDelay diff --git a/src/VISU_SWIG/visu_delete.py b/src/VISU_SWIG/visu_delete.py new file mode 100644 index 00000000..b73173ca --- /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('KERNEL_ROOT_DIR') + '/examples/' + 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)