From e0a7fdcd537cce743ae448ed0ce842a8bfeca3a6 Mon Sep 17 00:00:00 2001 From: nri Date: Thu, 10 Jul 2003 13:40:28 +0000 Subject: [PATCH] sources v1.2 --- src/Makefile.in | 35 +- src/OBJECT/Makefile.in | 41 +- src/OBJECT/VISU_Actor.cxx | 414 +++- src/OBJECT/VISU_Actor.h | 207 +- src/OBJECT/VISU_LookupTable.cxx | 49 + src/OBJECT/VISU_LookupTable.hxx | 33 + src/OBJECT/VISU_ScalarBarActor.cxx | 575 +++++ src/OBJECT/VISU_ScalarBarActor.hxx | 135 + src/VISUGUI/Makefile.in | 54 +- src/VISUGUI/VisuGUI.cxx | 2716 +++++++++------------ src/VISUGUI/VisuGUI.h | 422 ++-- src/VISUGUI/VisuGUI.py | 9 + src/VISUGUI/VisuGUI_CellsResultsDlg.cxx | 34 +- src/VISUGUI/VisuGUI_CellsResultsDlg.h | 32 +- src/VISUGUI/VisuGUI_CursorDlg.cxx | 34 +- src/VISUGUI/VisuGUI_CursorDlg.h | 32 +- src/VISUGUI/VisuGUI_CutLinesDlg.cxx | 253 ++ src/VISUGUI/VisuGUI_CutLinesDlg.h | 51 + src/VISUGUI/VisuGUI_CutPlanesDlg.cxx | 337 +-- src/VISUGUI/VisuGUI_CutPlanesDlg.h | 50 +- src/VISUGUI/VisuGUI_InitMeshDlg.cxx | 35 +- src/VISUGUI/VisuGUI_InitMeshDlg.h | 33 +- src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx | 62 +- src/VISUGUI/VisuGUI_IsoSurfacesDlg.h | 41 +- src/VISUGUI/VisuGUI_MagnitudeDlg.cxx | 34 +- src/VISUGUI/VisuGUI_MagnitudeDlg.h | 32 +- src/VISUGUI/VisuGUI_NonIsometricDlg.cxx | 530 +--- src/VISUGUI/VisuGUI_NonIsometricDlg.h | 47 +- src/VISUGUI/VisuGUI_PartialScaDlg.cxx | 34 +- src/VISUGUI/VisuGUI_PartialScaDlg.h | 32 +- src/VISUGUI/VisuGUI_PhaseDlg.cxx | 34 +- src/VISUGUI/VisuGUI_PhaseDlg.h | 32 +- src/VISUGUI/VisuGUI_PhaseMagnitudeDlg.cxx | 34 +- src/VISUGUI/VisuGUI_PhaseMagnitudeDlg.h | 32 +- src/VISUGUI/VisuGUI_PointsResultsDlg.cxx | 34 +- src/VISUGUI/VisuGUI_PointsResultsDlg.h | 32 +- src/VISUGUI/VisuGUI_ScalarBarDlg.cxx | 178 +- src/VISUGUI/VisuGUI_ScalarBarDlg.h | 43 +- src/VISUGUI/VisuGUI_SelVectCompDlg.cxx | 34 +- src/VISUGUI/VisuGUI_SelVectCompDlg.h | 32 +- src/VISUGUI/VisuGUI_Selection.cxx | 431 +--- src/VISUGUI/VisuGUI_Selection.h | 90 +- src/VISUGUI/VisuGUI_StreamLinesDlg.cxx | 158 +- src/VISUGUI/VisuGUI_StreamLinesDlg.h | 24 +- src/VISUGUI/VisuGUI_SweepPrefDlg.cxx | 34 +- src/VISUGUI/VisuGUI_SweepPrefDlg.h | 32 +- src/VISUGUI/VisuGUI_TimeAnimation.cxx | 162 +- src/VISUGUI/VisuGUI_TimeAnimation.h | 20 +- src/VISUGUI/VisuGUI_VectorsDlg.cxx | 57 +- src/VISUGUI/VisuGUI_VectorsDlg.h | 32 +- src/VISUGUI/VisuGUI_VisuAsDlg.cxx | 73 +- src/VISUGUI/VisuGUI_VisuAsDlg.h | 32 +- src/VISUGUI/VisuGUI_icons.po | 58 + src/VISUGUI/VisuGUI_msg_en.po | 347 +++ src/VISU_I/Makefile.in | 33 +- src/VISU_I/VISUConfig.hh | 29 +- src/VISU_I/VISU_Convertor.cxx | 442 +++- src/VISU_I/VISU_Convertor.hxx | 15 +- src/VISU_I/VISU_Convertor_impl.cxx | 27 +- src/VISU_I/VISU_Convertor_impl.hxx | 12 +- src/VISU_I/VISU_CorbaMedConvertor.cxx | 485 ++-- src/VISU_I/VISU_CorbaMedConvertor.hxx | 27 +- src/VISU_I/VISU_DatConvertor.cxx | 17 +- src/VISU_I/VISU_DatConvertor.hxx | 12 +- src/VISU_I/VISU_Extractor.cxx | 28 +- src/VISU_I/VISU_Extractor.hxx | 14 +- src/VISU_I/VISU_FieldTransform.cxx | 104 +- src/VISU_I/VISU_FieldTransform.hxx | 16 +- src/VISU_I/VISU_Gen_i.cc | 231 +- src/VISU_I/VISU_Gen_i.hh | 32 +- src/VISU_I/VISU_MedConvertor.cxx | 362 +-- src/VISU_I/VISU_MedConvertor.hxx | 12 +- src/VISU_I/VISU_PrsObject_i.cc | 1379 +++++++---- src/VISU_I/VISU_PrsObject_i.hh | 208 +- src/VISU_I/VISU_Result_i.cc | 135 +- src/VISU_I/VISU_Result_i.hh | 14 +- src/VISU_I/VISU_Table_i.cc | 155 +- src/VISU_I/VISU_Table_i.hh | 26 +- src/VISU_I/VISU_TimeAnimation.cxx | 235 +- src/VISU_I/VISU_TimeAnimation.h | 82 +- src/VISU_I/VISU_ViewManager_i.cc | 712 +++--- src/VISU_I/VISU_ViewManager_i.hh | 47 +- src/VISU_SWIG/Makefile.in | 46 +- src/VISU_SWIG/batchmode_visu.py | 84 +- src/VISU_SWIG/batchmode_visu_table.py | 67 + src/VISU_SWIG/batchmode_visu_view3d.py | 70 +- src/VISU_SWIG/libVISU_Swig.i | 35 +- src/VISU_SWIG/visu.py | 522 +++- src/VISU_SWIG/visu_big_table.py | 24 +- src/VISU_SWIG/visu_gui.py | 23 + src/VISU_SWIG/visu_med.py | 11 +- src/VISU_SWIG/visu_prs_example.py | 71 + src/VISU_SWIG/visu_table.py | 23 +- src/VISU_SWIG/visu_view.py | 18 +- src/VISU_SWIG/visu_view3d.py | 65 +- 95 files changed, 8956 insertions(+), 5422 deletions(-) create mode 100644 src/OBJECT/VISU_LookupTable.cxx create mode 100644 src/OBJECT/VISU_LookupTable.hxx create mode 100644 src/OBJECT/VISU_ScalarBarActor.cxx create mode 100644 src/OBJECT/VISU_ScalarBarActor.hxx create mode 100644 src/VISUGUI/VisuGUI_CutLinesDlg.cxx create mode 100644 src/VISUGUI/VisuGUI_CutLinesDlg.h create mode 100644 src/VISUGUI/VisuGUI_icons.po create mode 100644 src/VISUGUI/VisuGUI_msg_en.po create mode 100644 src/VISU_SWIG/batchmode_visu_table.py create mode 100644 src/VISU_SWIG/visu_gui.py create mode 100644 src/VISU_SWIG/visu_prs_example.py diff --git a/src/Makefile.in b/src/Makefile.in index d01b6f40..ec6a891e 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,18 +1,35 @@ -#============================================================================== -# File : Makefile.in -# Created : ven déc 7 13:32:20 CET 2001 -# Author : Paul RASCLE, EDF -# Project : SALOME -# Copyright : EDF 2001 +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Laurent CORNABE PRINCIPIA +# Module : VISU # $Header$ -#============================================================================== -# source path top_srcdir=@top_srcdir@ -top_builddir=.. +top_builddir=../.. srcdir=@srcdir@ VPATH=.:@srcdir@ + @COMMENCE@ SUBDIRS = OBJECT VISU_I VISUGUI VISU_SWIG diff --git a/src/OBJECT/Makefile.in b/src/OBJECT/Makefile.in index 54a6cbcf..3e7a4fea 100644 --- a/src/OBJECT/Makefile.in +++ b/src/OBJECT/Makefile.in @@ -1,19 +1,44 @@ -# source path +# VISU OBJECT : interactive object for VISU entities implementation +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Module : VISU + top_srcdir=@top_srcdir@ -top_builddir=../.. +top_builddir=../../.. srcdir=@srcdir@ -VPATH=.:$(srcdir):$(top_srcdir)/idl:$(top_builddir)/idl +VPATH=.:@srcdir@:@top_srcdir@/idl @COMMENCE@ -EXPORT_HEADERS = VISU_Actor.h +EXPORT_HEADERS = VISU_Actor.h VISU_LookupTable.hxx VISU_ScalarBarActor.hxx # Libraries targets LIB = libVisuObject.la -LIB_SRC = VISU_Actor.cxx +LIB_SRC = VISU_Actor.cxx VISU_LookupTable.cxx VISU_ScalarBarActor.cxx LIB_CLIENT_IDL = @@ -21,10 +46,8 @@ LIB_CLIENT_IDL = BIN = BIN_SRC = -CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) \ - $(OGL_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -LDFLAGS+=$(QT_MT_LIBS) $(OCC_LIBS) $(VTK_LIBS) $(OGL_LIBS) $(PYTHON_LIBS) \ - -lSalomeObject -L${KERNEL_ROOT_DIR}/lib/salome +CPPFLAGS+= $(OCC_INCLUDES) $(VTK_INCLUDES) +LDFLAGS+= $(OCC_LIBS) $(VTK_LIBS) -lSalomeObject %_moc.cxx: %.h $(MOC) $< -o $@ diff --git a/src/OBJECT/VISU_Actor.cxx b/src/OBJECT/VISU_Actor.cxx index a94fb9df..814ef814 100644 --- a/src/OBJECT/VISU_Actor.cxx +++ b/src/OBJECT/VISU_Actor.cxx @@ -1,82 +1,158 @@ -using namespace std; -// File : VISU_Actor.cxx -// Created : Wed Feb 20 18:04:42 CET 2002 -// Author : Laurent CORNABE with help of Nicolas REJNERI -// Project : SALOME -// Module : VISU -// Copyright : PRINCIPIA RD +// VISU OBJECT : interactive object for VISU entities implementation +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VISU_Actor.cxx +// Author : Laurent CORNABE with help of Nicolas REJNERI +// Module : VISU // $Header$ +using namespace std; #include "VISU_Actor.h" -#include "utilities.h" +#include "VISU_LookupTable.hxx" +#include "VISU_ScalarBarActor.hxx" // VTK Includes +#include +#include +#include +#include #include +static int VISU_POINT_SIZE = 3; + +//======================================================================= + VISU_Actor* VISU_Actor::New(){ vtkObject* ret = vtkObjectFactory::CreateInstance("VISU_Actor"); if(ret) return (VISU_Actor*)ret; return new VISU_Actor; } + VISU_Actor::VISU_Actor(){ - this->Device = vtkActor::New(); - - this->EdgeDevice = NULL; - //this->EdgeDevice = SALOME_Actor::New(); - //EdgeDevice->VisibilityOff(); - //EdgeDevice->PickableOff(); - - this->DataSource = NULL; - myScalarBar = NULL; - this->myIO = NULL; - this->myName = ""; - this->IsDefined = false; - this->IsShrunk = false; - this->IsShrinkable = false; - this->VisuActorType = 0; - this->Presentation = NULL; - myHasScalarBar = false; - this->HighlightProperty = NULL; - this->ishighlighted = false; - this->IsHighlighting = true; - this->ResultAtNode = false; - this->VectorComponent = -1; - for (int i=0; i<6; i++) - this->VABounds[i] = 0.; - strcpy(this->FieldName,""); -} - - -VISU_Actor::~VISU_Actor() -{ - if (EdgeDevice != NULL) - this->EdgeDevice->Delete(); -} - - -void VISU_Actor::setScalarBar(VISU_ScalarBarActor* theBar) { - if (theBar) { - myScalarBar = theBar; - myHasScalarBar = true; - } else { - myScalarBar = NULL; - myHasScalarBar = false; - } + myIsShrunk = false; + myIsShrinkable = false; + myParent = this; + myPrs3d = NULL; + + 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); +} + +VISU_Actor::~VISU_Actor(){ + HighlightProperty->Delete(); +} + +void VISU_Actor::setIO(const Handle(SALOME_InteractiveObject)& theIO){ + SALOME_Actor::setIO(theIO); + myName = theIO->getName(); +} + +void VISU_Actor::setPrs3d(VISU::Prs3d_i* thePrs3d){ + myPrs3d = thePrs3d; +} + +void VISU_Actor::SetParent(VISU_Actor* theParent){ + myParent = theParent; +} + +void VISU_Actor::SetMapper(vtkMapper* theMapper){ + SALOME_Actor::SetMapper(theMapper); +} + +void VISU_Actor::SetShrinkable(bool theIsShrinkable){ + myIsShrinkable = theIsShrinkable; +} + +void VISU_Actor::setShrink(float theFactor){ + if(!myIsShrinkable || myIsShrunk) return; + vtkShrinkPolyData *aShrinkFilter = vtkShrinkPolyData::New(); + aShrinkFilter->SetShrinkFactor(theFactor); + // use for post-filtering + aShrinkFilter->SetInput(myPassFilter[2]->GetPolyDataOutput()); + myPassFilter[3]->SetInput(aShrinkFilter->GetOutput()); + myPassFilter[3]->Modified(); + aShrinkFilter->Delete(); + myIsShrunk = true; +} + +void VISU_Actor::unShrink(){ + if(!myIsShrunk) return; + myPassFilter[3]->SetInput(myPassFilter[2]->GetPolyDataOutput()); + myPassFilter[3]->Modified(); + myIsShrunk = false; } +void VISU_Actor::SetVisibility(int theMode){ + SALOME_Actor::SetVisibility(theMode); +} + +int VISU_Actor::GetVisibility(){ + return SALOME_Actor::GetVisibility(); +} + +void VISU_Actor::SetProperty(vtkProperty* theProperty){ + SALOME_Actor::SetProperty(theProperty); +} + +vtkProperty* VISU_Actor::GetProperty(){ + return SALOME_Actor::GetProperty(); +} + +void VISU_Actor::SetLineWidth(float theLineWidth){ + GetProperty()->SetLineWidth(theLineWidth); +} + +float VISU_Actor::GetLineWidth(){ + return GetProperty()->GetLineWidth(); +} + +void VISU_Actor::SetRepresentation(int theMode) { + GetProperty()->SetRepresentation(theMode); + if(theMode == 0) + GetProperty()->SetPointSize(VISU_POINT_SIZE); +} -void VISU_Actor::setActor(vtkActor *Actor){ - this->Device=Actor; +int VISU_Actor::GetRepresentation(){ + return GetProperty()->GetRepresentation(); } void VISU_Actor::ShallowCopy(vtkProp *prop){ - VISU_Actor *f = VISU_Actor::SafeDownCast(prop); - if ( f != NULL ) - { - setName( f->getName() ); - if ( f->hasIO() ) - setIO( f->getIO() ); - } + VISU_Actor *anActor = VISU_Actor::SafeDownCast(prop); + if(anActor != NULL){ + setName(anActor->getName()); + if(anActor->hasIO()) setIO(anActor->getIO()); + } SALOME_Actor::ShallowCopy(prop); } @@ -84,35 +160,207 @@ void VISU_Actor::highlight(Standard_Boolean highlight) { if (this->IsHighlighting) { if(highlight && !ishighlighted) { ishighlighted=true; - // build highlight property is necessary - if(HighlightProperty==NULL) { - 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); - } - this->Property = HighlightProperty; - }else if (!highlight) { - if(ishighlighted) { - ishighlighted=false; - } - } + this->SetProperty(HighlightProperty); + }else if (!highlight) + if(ishighlighted) ishighlighted=false; } } +//======================================================================= + +VISUScalarMap_Actor* VISUScalarMap_Actor::New(){ + vtkObject* ret = vtkObjectFactory::CreateInstance("VISUScalarMap_Actor"); + if(ret) return (VISUScalarMap_Actor*)ret; + return new VISUScalarMap_Actor; +} + +VISUScalarMap_Actor::VISUScalarMap_Actor(){ + myScalarBar = VISU_ScalarBarActor::New(); + GetProperty()->FrontfaceCullingOff(); + GetProperty()->BackfaceCullingOff(); +} + +VISUScalarMap_Actor::~VISUScalarMap_Actor(){ + myScalarBar->Delete(); +} + +void VISUScalarMap_Actor::AddToRender(vtkRenderer* theRenderer){ + SALOME_Actor::AddToRender(theRenderer); + if(myScalarBar) + theRenderer->AddActor2D(myScalarBar); +} -void VISU_Actor::setVABounds(const float bounds[6]){ - for (int i=0; i<6; i++) - VABounds[i] = bounds[i]; +void VISUScalarMap_Actor::RemoveFromRender(vtkRenderer* theRenderer){ + SALOME_Actor::RemoveFromRender(theRenderer); + if(myScalarBar) + theRenderer->RemoveActor(myScalarBar); } +void VISUScalarMap_Actor::SetVisibility(int theMode){ + SALOME_Actor::SetVisibility(theMode); + if(myScalarBar) myScalarBar->SetVisibility(*myBarVisibility && theMode); +} -void VISU_Actor::getVABounds(float bounds[6]){ - for (int i=0; i<6; i++) - bounds[i] = VABounds[i]; +int VISUScalarMap_Actor::GetVisibility(){ + return SALOME_Actor::GetVisibility(); } +void VISUScalarMap_Actor::SetBarVisibility(const bool* theMode){ + myBarVisibility = theMode; + if(myScalarBar) myScalarBar->SetVisibility(*myBarVisibility); +} + +//======================================================================= + +VISUMesh_Actor* VISUMesh_Actor::New(){ + vtkObject* ret = vtkObjectFactory::CreateInstance("VISUMesh_Actor"); + if(ret) return (VISUMesh_Actor*)ret; + return new VISUMesh_Actor; +} + +VISUMesh_Actor::VISUMesh_Actor(){ + myEdgeMapper = vtkPolyDataMapper::New(); + mySurfaceActor = VISU_Actor::New(); + mySurfaceActor->SetParent(this); + mySurfaceActor->GetProperty()->SetPointSize(VISU_POINT_SIZE); + mySurfaceActor->GetProperty()->FrontfaceCullingOff(); + mySurfaceActor->GetProperty()->BackfaceCullingOff(); + mySurfaceActor->SetRepresentation(2); + + myEdgeActor = VISU_Actor::New(); + myEdgeActor->SetParent(this); + myEdgeActor->PickableOff(); + myEdgeActor->GetProperty()->SetPointSize(VISU_POINT_SIZE); + myEdgeActor->GetProperty()->FrontfaceCullingOff(); + myEdgeActor->GetProperty()->BackfaceCullingOff(); + myEdgeActor->SetRepresentation(2); + + myRepresentation = 2; //SURFACE + myVisibility = 1; //On +} + +VISUMesh_Actor::~VISUMesh_Actor(){ + myEdgeMapper->Delete(); + mySurfaceActor->Delete(); + myEdgeActor->Delete(); +} + +void VISUMesh_Actor::setIO(const Handle(SALOME_InteractiveObject)& theIO){ + mySurfaceActor->setIO(theIO); + myEdgeActor->setIO(theIO); +} + +void VISUMesh_Actor::setPrs3d(VISU::Prs3d_i* thePrs3d){ + if(thePrs3d){ + VISU_Actor::setPrs3d(thePrs3d); + mySurfaceActor->setPrs3d(thePrs3d); + myEdgeActor->setPrs3d(thePrs3d); + } +} + +void VISUMesh_Actor::AddToRender(vtkRenderer* theRenderer){ + theRenderer->AddActor(mySurfaceActor); + theRenderer->AddActor(myEdgeActor); +} + +void VISUMesh_Actor::RemoveFromRender(vtkRenderer* theRenderer){ + theRenderer->RemoveActor(mySurfaceActor); + theRenderer->RemoveActor(myEdgeActor); +} + +void VISUMesh_Actor::SetMapper(vtkMapper* theMapper){ + VISU_Actor::SetMapper(theMapper); + SALOME_PassThroughFilter* aPassFilter = SALOME_PassThroughFilter::New(); + aPassFilter->SetInput(theMapper->GetInput()); + vtkFeatureEdges *aFeatureEdges = vtkFeatureEdges::New(); + aFeatureEdges->SetInput(aPassFilter->GetPolyDataOutput()); + aFeatureEdges->BoundaryEdgesOn(); + aFeatureEdges->ManifoldEdgesOn(); + myEdgeMapper->SetInput(aFeatureEdges->GetOutput()); + aFeatureEdges->Delete(); + myEdgeMapper->ScalarVisibilityOff(); + myEdgeActor->SetMapper(myEdgeMapper); + mySurfaceActor->SetMapper(theMapper); +} + +void VISUMesh_Actor::SetTransform(SALOME_Transform* theTransform){ + mySurfaceActor->SetTransform(theTransform); + myEdgeActor->SetTransform(theTransform); +} + +void VISUMesh_Actor::SetShrinkable(bool theIsShrinkable){ + myIsShrinkable = theIsShrinkable; + myEdgeActor->SetShrinkable(myIsShrinkable); + mySurfaceActor->SetShrinkable(myIsShrinkable); +} + +vtkProperty* VISUMesh_Actor::GetProperty(){ + mySurfaceActor->GetProperty(); +} + +void VISUMesh_Actor::SetProperty(vtkProperty* theProperty){ + mySurfaceActor->SetProperty(theProperty); +} + +vtkProperty* VISUMesh_Actor::GetEdgeProperty(){ + myEdgeActor->GetProperty(); +} + +void VISUMesh_Actor::SetEdgeProperty(vtkProperty* theProperty){ + myEdgeActor->SetProperty(theProperty); +} + +void VISUMesh_Actor::SetLineWidth(float theLineWidth){ + GetProperty()->SetLineWidth(theLineWidth); + GetEdgeProperty()->SetLineWidth(theLineWidth); +} + +float VISUMesh_Actor::GetLineWidth(){ + return GetProperty()->GetLineWidth(); +} + +void VISUMesh_Actor::setShrink(float theFactor){ + if(!myIsShrinkable || myIsShrunk || myRepresentation == 0) return; + mySurfaceActor->setShrink(theFactor); + myIsShrunk = true; + SetRepresentation(myRepresentation); +} + +void VISUMesh_Actor::unShrink(){ + if(!myIsShrunk) return; + mySurfaceActor->unShrink(); + myIsShrunk = false; + SetRepresentation(myRepresentation); +} + +void VISUMesh_Actor::SetRepresentation(int theMode){ + if(theMode < 0 || theMode >2) return; + myRepresentation = theMode; + myEdgeActor->SetRepresentation(2); + mySurfaceActor->SetRepresentation(myRepresentation); + switch(theMode){ + case 0: //POINTS + myEdgeActor->VisibilityOff(); + mySurfaceActor->VisibilityOn(); + break; + case 1: //WIREFRAME + myEdgeActor->VisibilityOff(); + mySurfaceActor->VisibilityOn(); + break; + case 2: //SURFACE + myEdgeActor->SetVisibility(!myIsShrunk); + mySurfaceActor->VisibilityOn(); + break; + } + myRepresentation = theMode; +} + +void VISUMesh_Actor::SetVisibility(int theMode){ + SetRepresentation(myRepresentation); + myEdgeActor->SetVisibility(theMode); + mySurfaceActor->SetVisibility(theMode); + myVisibility = theMode; +} + +//======================================================================= + diff --git a/src/OBJECT/VISU_Actor.h b/src/OBJECT/VISU_Actor.h index 298f25cb..641a9442 100644 --- a/src/OBJECT/VISU_Actor.h +++ b/src/OBJECT/VISU_Actor.h @@ -1,110 +1,181 @@ -// File : VISU_Actor.h -// Created : Wed Feb 20 18:04:42 CET 2002 -// Author : Laurent CORNABE with the help of Nicolas REJNERI -// Project : SALOME -// Module : VISU -// Copyright : PRINCIPIA RD +// VISU OBJECT : interactive object for VISU entities implementation +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VISU_Actor.h +// Author : Laurent CORNABE with the help of Nicolas REJNERI +// Module : VISU // $Header$ +using namespace std; #ifndef VISU_ACTOR_H #define VISU_ACTOR_H #include "SALOME_Actor.h" - #include -// VTK Includes -#include -#include -#include -#include -#include - -#ifdef _WIN_32 -#define VTKOCC_EXPORT __declspec (dllexport) -#else -#define VTKOCC_EXPORT -#endif - -#define VisuActorType_Mesh 1 -#define VisuActorType_BoundingBox 2 -#define VisuActorType_DeformedShape 3 -#define VisuActorType_Vectors 4 -#define VisuActorType_ScalarMap 5 -#define VisuActorType_IsoSurfaces 6 -#define VisuActorType_CutPlanes 7 -#define VisuActorType_Plot2D 8 -#define VisuActorType_StreamLines 9 - +class vtkProp; +class vtkPolyData; +class vtkProperty; +class vtkPolyDataMapper; namespace VISU { class Prs3d_i; } - class VISU_ScalarBarActor; +#ifdef _WIN_32 +#define VTKOCC_EXPORT __declspec (dllexport) +#else +#define VTKOCC_EXPORT VTK_EXPORT +#endif + class VTKOCC_EXPORT VISU_Actor : public SALOME_Actor { - friend class VISU::Prs3d_i; public: vtkTypeMacro(VISU_Actor,SALOME_Actor); - - Standard_Boolean IsHighlighting; - + void ShallowCopy(vtkProp *prop); static VISU_Actor* New(); + ~VISU_Actor(); - void setActor(vtkActor *Actor); + virtual void setIO(const Handle(SALOME_InteractiveObject)& theIO); - void ShallowCopy(vtkProp *prop); + VISU::Prs3d_i* getPrs3d(){ return myPrs3d;} + virtual void setPrs3d(VISU::Prs3d_i* thePrs3d); + + VISU_Actor* GetParent(){ return myParent;} + virtual void SetParent(VISU_Actor* theParent); void highlight(Standard_Boolean highlight); Standard_Boolean isHighlighted() { return true; }; void SetOpacity(float opa) {}; - float GetOpacity() - { return 0;}; + float GetOpacity() { return 0;}; - Standard_Boolean HasScalarBar() - { return myHasScalarBar; } + virtual void SetMapper(vtkMapper* theMapper); - void setScalarBar(VISU_ScalarBarActor* theBar); - VISU_ScalarBarActor* getScalarBar() - { return myScalarBar; } + virtual void SetShrinkable(bool theIsShrinkable); + virtual bool GetShrinkable() { return myIsShrinkable;} + virtual bool isShrunk() { return myIsShrunk;} + virtual void setShrink(float theFactor = 0.8); + virtual void unShrink(); - void setIO(const Handle(SALOME_InteractiveObject)& io) - { SALOME_Actor::setIO(io); myName = io->getName(); } - + virtual void SetVisibility(int theMode); + virtual int GetVisibility(); - VISU::Prs3d_i* getPrs3d() { return Presentation; } - void setPrs3d(VISU::Prs3d_i* thePrs) { Presentation = thePrs; } + virtual void SetProperty(vtkProperty* theProperty); + virtual vtkProperty* GetProperty(); + + virtual void SetLineWidth(float theLineWidth); + virtual float GetLineWidth(); + + virtual void SetRepresentation(int theMode); + virtual int GetRepresentation(); - vtkDataSet *DataSource; - VISU_Actor* EdgeDevice; + bool IsHighlighting; + std::string myFieldName; - Standard_Boolean IsShrinkable; - Standard_Boolean IsShrunk; - int VisuActorType; - Standard_Boolean ResultAtNode; - int VectorComponent; - char FieldName[40]; + protected: + VISU_Actor(); + + VISU_Actor* myParent; + VISU::Prs3d_i* myPrs3d; + vtkProperty* HighlightProperty; + bool myIsShrinkable; + bool myIsShrunk; +}; - Standard_Boolean IsDefined; +//======================================================================= - float VABounds[6]; - void setVABounds(const float bounds[6]); - void getVABounds(float bounds[6]); +class VTKOCC_EXPORT VISUScalarMap_Actor : public VISU_Actor { + public: + vtkTypeMacro(VISUScalarMap_Actor,VISU_Actor); + static VISUScalarMap_Actor* New(); + ~VISUScalarMap_Actor(); + + virtual void AddToRender(vtkRenderer* theRenderer); + virtual void RemoveFromRender(vtkRenderer* theRenderer); + + virtual void SetVisibility(int theMode); + virtual int GetVisibility(); + + virtual VISU_ScalarBarActor* GetScalarBar(){ return myScalarBar;} + + virtual void SetBarVisibility(const bool* theMode); + virtual bool GetBarVisibility(){ return *myBarVisibility;} - ~VISU_Actor(); protected: - VISU_Actor(); - - Standard_Boolean myHasScalarBar; + VISUScalarMap_Actor(); + const bool* myBarVisibility; VISU_ScalarBarActor* myScalarBar; - VISU::Prs3d_i* Presentation; +}; - private: - vtkProperty* HighlightProperty; +//======================================================================= + +class VTKOCC_EXPORT VISUMesh_Actor : public VISU_Actor { + public: + vtkTypeMacro(VISUMesh_Actor,VISU_Actor); + static VISUMesh_Actor* New(); + ~VISUMesh_Actor(); + + virtual void setIO(const Handle(SALOME_InteractiveObject)& theIO); + virtual void setPrs3d(VISU::Prs3d_i* thePrs3d); + + virtual void AddToRender(vtkRenderer* theRenderer); + virtual void RemoveFromRender(vtkRenderer* theRenderer); + virtual void SetMapper(vtkMapper* theMapper); + virtual void SetTransform(SALOME_Transform* theTransform); + + virtual vtkProperty* GetProperty(); + virtual void SetProperty(vtkProperty* theProperty); + + virtual vtkProperty* GetEdgeProperty(); + virtual void SetEdgeProperty(vtkProperty* theProperty); + + virtual void SetLineWidth(float theLineWidth); + virtual float GetLineWidth(); + + virtual void SetRepresentation(int theMode); + virtual int GetRepresentation() { return myRepresentation;}; + + virtual void SetVisibility(int theMode); + virtual int GetVisibility() { return myVisibility;} + + virtual void SetShrinkable(bool theIsShrinkable); + + virtual void setShrink(float theFactor = 0.8); + virtual void unShrink(); + + protected: + VISUMesh_Actor(); + int myRepresentation, myVisibility; + vtkPolyDataMapper* myEdgeMapper; + VISU_Actor *mySurfaceActor, *myEdgeActor; }; + +//======================================================================= + #endif //VISU_ACTOR_H + + diff --git a/src/OBJECT/VISU_LookupTable.cxx b/src/OBJECT/VISU_LookupTable.cxx new file mode 100644 index 00000000..be0f137b --- /dev/null +++ b/src/OBJECT/VISU_LookupTable.cxx @@ -0,0 +1,49 @@ +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_LookupTable.cxx +// Author : Vitaliy Smetannikov +// Module : VISU + +using namespace std; +#include "VISU_LookupTable.hxx" + +VISU_LookupTable *VISU_LookupTable::New() { + vtkObject* ret = vtkObjectFactory::CreateInstance("VISU_LookupTable"); + if(ret) + return (VISU_LookupTable*)ret; + return new VISU_LookupTable; +} + +VISU_LookupTable::VISU_LookupTable(int sze, int ext) + : vtkLookupTable(sze, ext), myScale(1.0) {} + +int VISU_LookupTable::ComputeLogRange(float inRange[2], float outRange[2]){ + if(inRange[0] >= inRange[1]) + return -1; + if(0.0 <= inRange[0] && 0.0 < inRange[1]){ + if(inRange[0] != 0.0) + outRange[0] = log10((double)inRange[0]); + else + outRange[0] = log10((double)inRange[1]*1.0E-6); + outRange[1] = log10((double)inRange[1]); + return 0; + }else if(inRange[0] < 0.0 && inRange[1] <= 0.0){ + outRange[0] = log10((double)-inRange[0]); + outRange[1] = log10((double)-inRange[1]); + return 1; + }else + return -1; +} + +unsigned char* VISU_LookupTable::MapValue(float v) { + if(GetScale() == VTK_SCALE_LOG10) { + float aLowBound = log10(this->TableRange[0]); + v = pow(10.0f,aLowBound + (v - aLowBound)*myScale); + return vtkLookupTable::MapValue(v); + }else{ + v = this->TableRange[0] + (v - this->TableRange[0])*myScale; + return vtkLookupTable::MapValue(v); + } +} diff --git a/src/OBJECT/VISU_LookupTable.hxx b/src/OBJECT/VISU_LookupTable.hxx new file mode 100644 index 00000000..960b9d55 --- /dev/null +++ b/src/OBJECT/VISU_LookupTable.hxx @@ -0,0 +1,33 @@ +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_LookupTable.h +// Author : Vitaliy Smetannikov +// Module : VISU + +#ifndef VISU_LookupTable_H +#define VISU_LookupTable_H + +//#include +#include "VTKViewer_Common.h" +#include + +class VISU_LookupTable: public vtkLookupTable { + public: + vtkTypeMacro(VISU_LookupTable,vtkLogLookupTable); + static VISU_LookupTable *New(); + + float GetMapScale() { return myScale; } + void SetMapScale(float theScale) { myScale = theScale; Modified(); } + + static int ComputeLogRange(float inRange[2], float outRange[2]); + unsigned char *MapValue(float v); + + protected: + VISU_LookupTable(int sze=256, int ext=256); + ~VISU_LookupTable() {}; + + float myScale; +}; +#endif // VISU_LookupTable_H diff --git a/src/OBJECT/VISU_ScalarBarActor.cxx b/src/OBJECT/VISU_ScalarBarActor.cxx new file mode 100644 index 00000000..78591002 --- /dev/null +++ b/src/OBJECT/VISU_ScalarBarActor.cxx @@ -0,0 +1,575 @@ +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_ScalarBarActor.cxx +// Author : Alexey PETROV +// Module : VISU + +using namespace std; +#include "VISU_ScalarBarActor.hxx" + +vtkCxxRevisionMacro(VISU_ScalarBarActor, "$Revision$"); + +vtkCxxSetObjectMacro(VISU_ScalarBarActor,LookupTable,VISU_LookupTable); +vtkCxxSetObjectMacro(VISU_ScalarBarActor,LabelTextProperty,vtkTextProperty); +vtkCxxSetObjectMacro(VISU_ScalarBarActor,TitleTextProperty,vtkTextProperty); + +//------------------------------------------------------------------------------ +VISU_ScalarBarActor* VISU_ScalarBarActor::New(){ + vtkObject* ret = vtkObjectFactory::CreateInstance("VISU_ScalarBarActor"); + if(ret) + return (VISU_ScalarBarActor*)ret; + return new VISU_ScalarBarActor; +} + +VISU_ScalarBarActor::VISU_ScalarBarActor() +{ + this->LookupTable = NULL; + this->Position2Coordinate->SetValue(0.17, 0.8); + + this->PositionCoordinate->SetCoordinateSystemToNormalizedViewport(); + this->PositionCoordinate->SetValue(0.82,0.1); + + this->MaximumNumberOfColors = 64; + this->NumberOfLabels = 5; + this->NumberOfLabelsBuilt = 0; + this->Orientation = VTK_ORIENT_VERTICAL; + this->Title = NULL; + + this->LabelTextProperty = vtkTextProperty::New(); + this->LabelTextProperty->SetFontSize(12); + this->LabelTextProperty->SetBold(1); + this->LabelTextProperty->SetItalic(1); + this->LabelTextProperty->SetShadow(1); + this->LabelTextProperty->SetFontFamilyToArial(); + + this->TitleTextProperty = vtkTextProperty::New(); + this->TitleTextProperty->ShallowCopy(this->LabelTextProperty); + + this->LabelFormat = new char[8]; + sprintf(this->LabelFormat,"%s","%-#6.3g"); + + this->TitleMapper = vtkTextMapper::New(); + this->TitleActor = vtkActor2D::New(); + this->TitleActor->SetMapper(this->TitleMapper); + this->TitleActor->GetPositionCoordinate()-> + SetReferenceCoordinate(this->PositionCoordinate); + + this->TextMappers = NULL; + this->TextActors = NULL; + + this->ScalarBar = vtkPolyData::New(); + this->ScalarBarMapper = vtkPolyDataMapper2D::New(); + this->ScalarBarMapper->SetInput(this->ScalarBar); + this->ScalarBarActor = vtkActor2D::New(); + this->ScalarBarActor->SetMapper(this->ScalarBarMapper); + this->ScalarBarActor->GetPositionCoordinate()-> + SetReferenceCoordinate(this->PositionCoordinate); + this->LastOrigin[0] = 0; + this->LastOrigin[1] = 0; + this->LastSize[0] = 0; + this->LastSize[1] = 0; +} + +void VISU_ScalarBarActor::ReleaseGraphicsResources(vtkWindow *win) +{ + this->TitleActor->ReleaseGraphicsResources(win); + if (this->TextMappers != NULL ) + { + for (int i=0; i < this->NumberOfLabelsBuilt; i++) + { + this->TextActors[i]->ReleaseGraphicsResources(win); + } + } + this->ScalarBarActor->ReleaseGraphicsResources(win); +} + +VISU_ScalarBarActor::~VISU_ScalarBarActor() +{ + if (this->LabelFormat) + { + delete [] this->LabelFormat; + this->LabelFormat = NULL; + } + + this->TitleMapper->Delete(); + this->TitleActor->Delete(); + + if (this->TextMappers != NULL ) + { + for (int i=0; i < this->NumberOfLabelsBuilt; i++) + { + this->TextMappers[i]->Delete(); + this->TextActors[i]->Delete(); + } + delete [] this->TextMappers; + delete [] this->TextActors; + } + + this->ScalarBar->Delete(); + this->ScalarBarMapper->Delete(); + this->ScalarBarActor->Delete(); + + if (this->Title) + { + delete [] this->Title; + this->Title = NULL; + } + + this->SetLookupTable(NULL); + this->SetLabelTextProperty(NULL); + this->SetTitleTextProperty(NULL); +} + +int VISU_ScalarBarActor::RenderOverlay(vtkViewport *viewport) +{ + int renderedSomething = 0; + int i; + + // Everything is built, just have to render + if (this->Title != NULL) + { + renderedSomething += this->TitleActor->RenderOverlay(viewport); + } + this->ScalarBarActor->RenderOverlay(viewport); + if( this->TextActors == NULL) + { + vtkWarningMacro(<<"Need a mapper to render a scalar bar"); + return renderedSomething; + } + + for (i=0; iNumberOfLabels; i++) + { + renderedSomething += this->TextActors[i]->RenderOverlay(viewport); + } + + renderedSomething = (renderedSomething > 0)?(1):(0); + + return renderedSomething; +} + +int VISU_ScalarBarActor::RenderOpaqueGeometry(vtkViewport *viewport) +{ + int renderedSomething = 0; + int i; + int size[2]; + + if (!this->LookupTable) + { + vtkWarningMacro(<<"Need a mapper to render a scalar bar"); + return 0; + } + + if (!this->TitleTextProperty) + { + vtkErrorMacro(<<"Need title text property to render a scalar bar"); + return 0; + } + + if (!this->LabelTextProperty) + { + vtkErrorMacro(<<"Need label text property to render a scalar bar"); + return 0; + } + + // Check to see whether we have to rebuild everything + int positionsHaveChanged = 0; + if (viewport->GetMTime() > this->BuildTime || + (viewport->GetVTKWindow() && + viewport->GetVTKWindow()->GetMTime() > this->BuildTime)) + { + // if the viewport has changed we may - or may not need + // to rebuild, it depends on if the projected coords chage + int *barOrigin; + barOrigin = this->PositionCoordinate->GetComputedViewportValue(viewport); + size[0] = + this->Position2Coordinate->GetComputedViewportValue(viewport)[0] - + barOrigin[0]; + size[1] = + this->Position2Coordinate->GetComputedViewportValue(viewport)[1] - + barOrigin[1]; + if (this->LastSize[0] != size[0] || + this->LastSize[1] != size[1] || + this->LastOrigin[0] != barOrigin[0] || + this->LastOrigin[1] != barOrigin[1]) + { + positionsHaveChanged = 1; + } + } + + // Check to see whether we have to rebuild everything + if (positionsHaveChanged || + this->GetMTime() > this->BuildTime || + this->LookupTable->GetMTime() > this->BuildTime || + this->LabelTextProperty->GetMTime() > this->BuildTime || + this->TitleTextProperty->GetMTime() > this->BuildTime) + { + + // Delete previously constructed objects + // + if (this->TextMappers != NULL ) + { + for (i=0; i < this->NumberOfLabelsBuilt; i++) + { + this->TextMappers[i]->Delete(); + this->TextActors[i]->Delete(); + } + delete [] this->TextMappers; + delete [] this->TextActors; + } + + // Build scalar bar object; determine its type + // + VISU_LookupTable *lut = this->LookupTable; //SALOME specific + int isLogTable = lut->GetScale() == VTK_SCALE_LOG10; + + // we hard code how many steps to display + int numColors = this->MaximumNumberOfColors; + float *range = lut->GetRange(); + + int numPts = 2*(numColors + 1); + vtkPoints *pts = vtkPoints::New(); + pts->SetNumberOfPoints(numPts); + vtkCellArray *polys = vtkCellArray::New(); + polys->Allocate(polys->EstimateSize(numColors,4)); + vtkUnsignedCharArray *colors = vtkUnsignedCharArray::New(); + colors->SetNumberOfComponents(3); + colors->SetNumberOfTuples(numColors); + + this->ScalarBarActor->SetProperty(this->GetProperty()); + this->ScalarBar->Initialize(); + this->ScalarBar->SetPoints(pts); + this->ScalarBar->SetPolys(polys); + this->ScalarBar->GetCellData()->SetScalars(colors); + pts->Delete(); polys->Delete(); colors->Delete(); + + // get the viewport size in display coordinates + int *barOrigin, barWidth, barHeight; + barOrigin = this->PositionCoordinate->GetComputedViewportValue(viewport); + size[0] = + this->Position2Coordinate->GetComputedViewportValue(viewport)[0] - + barOrigin[0]; + size[1] = + this->Position2Coordinate->GetComputedViewportValue(viewport)[1] - + barOrigin[1]; + this->LastOrigin[0] = barOrigin[0]; + this->LastOrigin[1] = barOrigin[1]; + this->LastSize[0] = size[0]; + this->LastSize[1] = size[1]; + + // Update all the composing objects + this->TitleActor->SetProperty(this->GetProperty()); + this->TitleMapper->SetInput(this->Title); + if (this->TitleTextProperty->GetMTime() > this->BuildTime) + { + // Shallow copy here so that the size of the title prop is not affected + // by the automatic adjustment of its text mapper's size (i.e. its + // mapper's text property is identical except for the font size + // which will be modified later). This allows text actors to + // share the same text property, and in that case specifically allows + // the title and label text prop to be the same. + this->TitleMapper->GetTextProperty()->ShallowCopy(this->TitleTextProperty); + this->TitleMapper->GetTextProperty()->SetJustificationToCentered(); + } + + // find the best size for the title font + int titleSize[2]; + this->SizeTitle(titleSize, size, viewport); + + // find the best size for the ticks + int labelSize[2]; + this->AllocateAndSizeLabels(labelSize, size, viewport,range); + this->NumberOfLabelsBuilt = this->NumberOfLabels; + + // generate points + float x[3]; x[2] = 0.0; + float delta, val; + if ( this->Orientation == VTK_ORIENT_VERTICAL ) + { + barWidth = size[0] - 4 - labelSize[0]; + barHeight = (int)(0.86*size[1]); + delta=(float)barHeight/numColors; + for (i=0; iSetPoint(2*i,x); + x[0] = barWidth; + pts->SetPoint(2*i+1,x); + } + } + else + { + barWidth = size[0]; + barHeight = (int)(0.4*size[1]); + delta=(float)barWidth/numColors; + for (i=0; iSetPoint(2*i,x); + x[1] = 0; + pts->SetPoint(2*i+1,x); + } + } + + //polygons & cell colors + unsigned char *rgba, *rgb; + vtkIdType ptIds[4]; + for (i=0; iInsertNextCell(4,ptIds); + + if ( isLogTable ){ //SALOME specific + float rgbval = log10(range[0]) + + i*(log10(range[1])-log10(range[0]))/(numColors -1); + rgba = lut->MapValue(rgbval); + }else{ + rgba = lut->MapValue(range[0] + (range[1] - range[0])* + ((float)i /(numColors-1.0))); + } + + rgb = colors->GetPointer(3*i); //write into array directly + rgb[0] = rgba[0]; + rgb[1] = rgba[1]; + rgb[2] = rgba[2]; + } + + // Now position everything properly + // + if (this->Orientation == VTK_ORIENT_VERTICAL) + { + int sizeTextData[2]; + + // center the title + this->TitleActor->SetPosition(size[0]/2, 0.9*size[1]); + + for (i=0; i < this->NumberOfLabels; i++) + { + val = (float)i/(this->NumberOfLabels-1) *barHeight; + this->TextMappers[i]->GetSize(viewport,sizeTextData); + this->TextMappers[i]->GetTextProperty()->SetJustificationToLeft(); + this->TextActors[i]->SetPosition(barWidth+3, + val - sizeTextData[1]/2); + } + } + else + { + this->TitleActor->SetPosition(size[0]/2, + barHeight + labelSize[1] + 0.1*size[1]); + for (i=0; i < this->NumberOfLabels; i++) + { + this->TextMappers[i]->GetTextProperty()->SetJustificationToCentered(); + val = (float)i/(this->NumberOfLabels-1) * barWidth; + this->TextActors[i]->SetPosition(val, barHeight + 0.05*size[1]); + } + } + + this->BuildTime.Modified(); + } + + // Everything is built, just have to render + if (this->Title != NULL) + { + renderedSomething += this->TitleActor->RenderOpaqueGeometry(viewport); + } + this->ScalarBarActor->RenderOpaqueGeometry(viewport); + for (i=0; iNumberOfLabels; i++) + { + renderedSomething += this->TextActors[i]->RenderOpaqueGeometry(viewport); + } + + renderedSomething = (renderedSomething > 0)?(1):(0); + + return renderedSomething; +} + +void VISU_ScalarBarActor::PrintSelf(ostream& os, vtkIndent indent) +{ + this->Superclass::PrintSelf(os,indent); + + if ( this->LookupTable ) + { + os << indent << "Lookup Table:\n"; + this->LookupTable->PrintSelf(os,indent.GetNextIndent()); + } + else + { + os << indent << "Lookup Table: (none)\n"; + } + + if (this->TitleTextProperty) + { + os << indent << "Title Text Property:\n"; + this->TitleTextProperty->PrintSelf(os,indent.GetNextIndent()); + } + else + { + os << indent << "Title Text Property: (none)\n"; + } + + if (this->LabelTextProperty) + { + os << indent << "Label Text Property:\n"; + this->LabelTextProperty->PrintSelf(os,indent.GetNextIndent()); + } + else + { + os << indent << "Label Text Property: (none)\n"; + } + + os << indent << "Title: " << (this->Title ? this->Title : "(none)") << "\n"; + os << indent << "Maximum Number Of Colors: " + << this->MaximumNumberOfColors << "\n"; + os << indent << "Number Of Labels: " << this->NumberOfLabels << "\n"; + os << indent << "Number Of Labels Built: " << this->NumberOfLabelsBuilt << "\n"; + + os << indent << "Orientation: "; + if ( this->Orientation == VTK_ORIENT_HORIZONTAL ) + { + os << "Horizontal\n"; + } + else + { + os << "Vertical\n"; + } + + os << indent << "Label Format: " << this->LabelFormat << "\n"; +} + +void VISU_ScalarBarActor::ShallowCopy(vtkProp *prop) +{ + VISU_ScalarBarActor *a = VISU_ScalarBarActor::SafeDownCast(prop); + if ( a != NULL ) + { + this->SetPosition2(a->GetPosition2()); + this->SetLookupTable(a->GetLookupTable()); + this->SetMaximumNumberOfColors(a->GetMaximumNumberOfColors()); + this->SetOrientation(a->GetOrientation()); + this->SetLabelTextProperty(a->GetLabelTextProperty()); + this->SetTitleTextProperty(a->GetTitleTextProperty()); + this->SetLabelFormat(a->GetLabelFormat()); + this->SetTitle(a->GetTitle()); + this->GetPositionCoordinate()->SetCoordinateSystem( + a->GetPositionCoordinate()->GetCoordinateSystem()); + this->GetPositionCoordinate()->SetValue( + a->GetPositionCoordinate()->GetValue()); + this->GetPosition2Coordinate()->SetCoordinateSystem( + a->GetPosition2Coordinate()->GetCoordinateSystem()); + this->GetPosition2Coordinate()->SetValue( + a->GetPosition2Coordinate()->GetValue()); + } + + // Now do superclass + this->vtkActor2D::ShallowCopy(prop); +} + +void VISU_ScalarBarActor::AllocateAndSizeLabels(int *labelSize, int *size, + vtkViewport *viewport, + float *range) +{ + labelSize[0] = labelSize[1] = 0; + + this->TextMappers = new vtkTextMapper * [this->NumberOfLabels]; + this->TextActors = new vtkActor2D * [this->NumberOfLabels]; + + char string[512]; + + float val; + int i; + + // TODO: this should be optimized, maybe by keeping a list of + // allocated mappers, in order to avoid creation/destruction of + // their underlying text properties (i.e. each time a mapper is + // created, text properties are created and shallow-assigned a font size + // which value might be "far" from the target font size). + + VISU_LookupTable *lut = this->LookupTable; //SALOME specific + int isLogTable = lut->GetScale() == VTK_SCALE_LOG10; + + for (i=0; i < this->NumberOfLabels; i++) + { + this->TextMappers[i] = vtkTextMapper::New(); + + if(isLogTable && 0 < i && i < this->NumberOfLabels - 1){ // SALOME specific + float lval = log10(range[0]) + (float)i/(this->NumberOfLabels-1) * + (log10(range[1])-log10(range[0])); + val = pow(10,lval); + }else{ + val = range[0] + (float)i/(this->NumberOfLabels-1) * (range[1]-range[0]); + } + sprintf(string, this->LabelFormat, val); + this->TextMappers[i]->SetInput(string); + + // Shallow copy here so that the size of the label prop is not affected + // by the automatic adjustment of its text mapper's size (i.e. its + // mapper's text property is identical except for the font size + // which will be modified later). This allows text actors to + // share the same text property, and in that case specifically allows + // the title and label text prop to be the same. + this->TextMappers[i]->GetTextProperty()->ShallowCopy( + this->LabelTextProperty); + + this->TextActors[i] = vtkActor2D::New(); + this->TextActors[i]->SetMapper(this->TextMappers[i]); + this->TextActors[i]->SetProperty(this->GetProperty()); + this->TextActors[i]->GetPositionCoordinate()-> + SetReferenceCoordinate(this->PositionCoordinate); + } + + if (this->NumberOfLabels) + { + int targetWidth, targetHeight; + + if ( this->Orientation == VTK_ORIENT_VERTICAL ) + { + targetWidth = (int)(0.6*size[0]); + targetHeight = (int)(0.86*size[1]/this->NumberOfLabels); + } + else + { + targetWidth = (int)(size[0]*0.8/this->NumberOfLabels); + targetHeight = (int)(0.25*size[1]); + } + + vtkTextMapper::SetMultipleConstrainedFontSize(viewport, + targetWidth, + targetHeight, + this->TextMappers, + this->NumberOfLabels, + labelSize); + } +} + +void VISU_ScalarBarActor::SizeTitle(int *titleSize, int *size, + vtkViewport *viewport) +{ + titleSize[0] = titleSize[1] = 0; + + if (this->Title == NULL || !strlen(this->Title)) + { + return; + } + + int targetWidth, targetHeight; + + targetWidth = size[0]; + if ( this->Orientation == VTK_ORIENT_VERTICAL ) + { + targetHeight = (int)(0.1*size[1]); + } + else + { + targetHeight = (int)(0.25*size[1]); + } + + this->TitleMapper->SetConstrainedFontSize( + viewport, targetWidth, targetHeight); + + this->TitleMapper->GetSize(viewport, titleSize); +} diff --git a/src/OBJECT/VISU_ScalarBarActor.hxx b/src/OBJECT/VISU_ScalarBarActor.hxx new file mode 100644 index 00000000..6852b8c4 --- /dev/null +++ b/src/OBJECT/VISU_ScalarBarActor.hxx @@ -0,0 +1,135 @@ +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_ScalarBarActor.hxx +// Author : Alexey PETROV +// Module : VISU + +#ifndef VISU_ScalarBarActor_HeaderFile +#define VISU_ScalarBarActor_HeaderFile + +#include "VTKViewer_Common.h" +#include "VISU_LookupTable.hxx" +#include + +#define VTK_ORIENT_HORIZONTAL 0 +#define VTK_ORIENT_VERTICAL 1 + +class VISU_ScalarBarActor : public vtkActor2D +{ +public: + vtkTypeRevisionMacro(VISU_ScalarBarActor,vtkActor2D); + void PrintSelf(ostream& os, vtkIndent indent); + + // Description: + // Instantiate object with 64 maximum colors; 5 labels; %%-#6.3g label + // format, no title, and vertical orientation. The initial scalar bar + // size is (0.05 x 0.8) of the viewport size. + static VISU_ScalarBarActor *New(); + + // Description: + // Draw the scalar bar and annotation text to the screen. + int RenderOpaqueGeometry(vtkViewport* viewport); + int RenderTranslucentGeometry(vtkViewport*) { return 0; }; + int RenderOverlay(vtkViewport* viewport); + + // Description: + // Release any graphics resources that are being consumed by this actor. + // The parameter window could be used to determine which graphic + // resources to release. + virtual void ReleaseGraphicsResources(vtkWindow *); + + // Description: + // Set/Get the vtkLookupTable to use. The lookup table specifies the number + // of colors to use in the table (if not overridden), as well as the scalar + // range. + virtual void SetLookupTable(VISU_LookupTable*); + vtkGetObjectMacro(LookupTable,VISU_LookupTable); + + // Description: + // Set/Get the maximum number of scalar bar segments to show. This may + // differ from the number of colors in the lookup table, in which case + // the colors are samples from the lookup table. + vtkSetClampMacro(MaximumNumberOfColors, int, 2, VTK_LARGE_INTEGER); + vtkGetMacro(MaximumNumberOfColors, int); + + // Description: + // Set/Get the number of annotation labels to show. + vtkSetClampMacro(NumberOfLabels, int, 0, 64); + vtkGetMacro(NumberOfLabels, int); + + // Description: + // Control the orientation of the scalar bar. + vtkSetClampMacro(Orientation,int,VTK_ORIENT_HORIZONTAL, VTK_ORIENT_VERTICAL); + vtkGetMacro(Orientation, int); + void SetOrientationToHorizontal() + {this->SetOrientation(VTK_ORIENT_HORIZONTAL);}; + void SetOrientationToVertical() {this->SetOrientation(VTK_ORIENT_VERTICAL);}; + + // Description: + // Set/Get the title text property. + virtual void SetTitleTextProperty(vtkTextProperty *p); + vtkGetObjectMacro(TitleTextProperty,vtkTextProperty); + + // Description: + // Set/Get the labels text property. + virtual void SetLabelTextProperty(vtkTextProperty *p); + vtkGetObjectMacro(LabelTextProperty,vtkTextProperty); + + // Description: + // Set/Get the format with which to print the labels on the scalar + // bar. + vtkSetStringMacro(LabelFormat); + vtkGetStringMacro(LabelFormat); + + // Description: + // Set/Get the title of the scalar bar actor, + vtkSetStringMacro(Title); + vtkGetStringMacro(Title); + + // Description: + // Shallow copy of a scalar bar actor. Overloads the virtual vtkProp method. + void ShallowCopy(vtkProp *prop); + +protected: + VISU_ScalarBarActor(); + ~VISU_ScalarBarActor(); + + VISU_LookupTable *LookupTable; + vtkTextProperty *TitleTextProperty; + vtkTextProperty *LabelTextProperty; + + int MaximumNumberOfColors; + int NumberOfLabels; + int NumberOfLabelsBuilt; + int Orientation; + char *Title; + char *LabelFormat; + + vtkTextMapper **TextMappers; + virtual void AllocateAndSizeLabels(int *labelSize, int *size, + vtkViewport *viewport, float *range); + +private: + vtkTextMapper *TitleMapper; + vtkActor2D *TitleActor; + + vtkActor2D **TextActors; + + vtkPolyData *ScalarBar; + vtkPolyDataMapper2D *ScalarBarMapper; + vtkActor2D *ScalarBarActor; + + vtkTimeStamp BuildTime; + int LastSize[2]; + int LastOrigin[2]; + + void SizeTitle(int *titleSize, int *size, vtkViewport *viewport); + +private: + VISU_ScalarBarActor(const VISU_ScalarBarActor&); // Not implemented. + void operator=(const VISU_ScalarBarActor&); // Not implemented. +}; + +#endif diff --git a/src/VISUGUI/Makefile.in b/src/VISUGUI/Makefile.in index e134bef1..61fe864a 100644 --- a/src/VISUGUI/Makefile.in +++ b/src/VISUGUI/Makefile.in @@ -1,15 +1,35 @@ -# -* Makefile *- +# VISU VISUGUI : GUI of VISU component # -# Author : Marc Tajchman (CEA) -# Date : 5/07/2001 -# $Header$ +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org # - -# source path +# +# +# File : Makefile.in +# Author : Marc Tajchman (CEA) +# Module : VISU +# $Header$ + top_srcdir=@top_srcdir@ -top_builddir=../.. +top_builddir=../../.. srcdir=@srcdir@ -VPATH=.:@srcdir@:$(top_srcdir)/idl:$(top_builddir)/idl +VPATH=.:@srcdir@ @COMMENCE@ @@ -22,10 +42,10 @@ EXPORT_HEADERS= \ # .po files to transform in .qm PO_FILES = \ - VISU_msg_en.po VISU_icons.po + VisuGUI_msg_en.po VisuGUI_icons.po # Libraries targets -LIB = libVISUGUI.la +LIB = libVisuGUI.la LIB_SRC = VisuGUI.cxx \ VisuGUI_CellsResultsDlg.cxx \ VisuGUI_PointsResultsDlg.cxx \ @@ -44,7 +64,8 @@ LIB_SRC = VisuGUI.cxx \ VisuGUI_VisuAsDlg.cxx \ VisuGUI_NonIsometricDlg.cxx \ VisuGUI_StreamLinesDlg.cxx \ - VisuGUI_TimeAnimation.cxx + VisuGUI_TimeAnimation.cxx \ + VisuGUI_CutLinesDlg.cxx LIB_MOC = \ VisuGUI.h \ @@ -64,7 +85,8 @@ LIB_MOC = \ VisuGUI_VisuAsDlg.h \ VisuGUI_NonIsometricDlg.h \ VisuGUI_StreamLinesDlg.h \ - VisuGUI_TimeAnimation.h + VisuGUI_TimeAnimation.h \ + VisuGUI_CutLinesDlg.h LIB_CLIENT_IDL = SALOME_Exception.idl \ VISU_Gen.idl \ @@ -79,13 +101,11 @@ LIB_SERVER_IDL = # additionnal information to compil and link file -CPPFLAGS += -ftemplate-depth-32 $(QT_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) \ - $(MED2_INCLUDES) $(HDF5_INCLUDES) $(QWT_INCLUDES) \ - -I${KERNEL_ROOT_DIR}/include/salome -CXXFLAGS += -ftemplate-depth-32 $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome +CPPFLAGS += -ftemplate-depth-32 $(QT_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES) $(QWT_INCLUDES) +CXXFLAGS += -ftemplate-depth-32 $(OCC_CXXFLAGS) LDFLAGS += $(OCC_LIBS) $(MED2_LIBS) $(HDF5_LIBS) $(VTK_LIBS) $(QWT_LIBS) -lSalomeGUI -lSalomeNS \ - -lVisuObject -lVISUEngine -lmed -lVTKViewer -L${KERNEL_ROOT_DIR}/lib/salome + -lVisuObject -lVisuEngine -lmed -lVTKViewer @CONCLUDE@ diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 573f74b5..104eb6f3 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -1,12 +1,32 @@ -using namespace std; -// File : VisuGUI.cxx -// Created : Wed Aug 01 10:20:18 2001 -// Author : Laurent CORNABE -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI.cxx +// Author : Laurent CORNABE +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI.h" #include "VisuGUI_PhaseDlg.h" #include "VisuGUI_MagnitudeDlg.h" @@ -16,6 +36,7 @@ using namespace std; #include "VisuGUI_ScalarBarDlg.h" #include "VisuGUI_SweepPrefDlg.h" #include "VisuGUI_CutPlanesDlg.h" +#include "VisuGUI_CutLinesDlg.h" #include "VisuGUI_VectorsDlg.h" #include "VisuGUI_IsoSurfacesDlg.h" #include "VisuGUI_StreamLinesDlg.h" @@ -51,6 +72,7 @@ using namespace std; #include "QAD_Resource.h" #include "QAD_ResourceMgr.h" #include "QAD_FileDlg.h" +#include "QAD_WaitCursor.h" #include "SALOME_Selection.h" #include "SALOMEGUI_NameDlg.h" #include "SALOMEGUI_TableDlg.h" @@ -87,51 +109,28 @@ using namespace std; #include CORBA_CLIENT_HEADER(Med_Gen) #include -#include -//#include #include -#include -#include -#include -#include -#include // Open CASCADE Include #include -//#define CHECKTIME +//#define CHECKTIME #ifdef CHECKTIME -#include +static int MYCHECKTIME = 1; +#else +static int MYCHECKTIME = 0; #endif +#include #ifdef DEBUG -static int MYDEBUG = 1; +static int MYDEBUG = 0; static int MYDEBUGWITHFILES = 0; #else static int MYDEBUG = 0; static int MYDEBUGWITHFILES = 0; #endif -// unique name visu entity -//static bool localContext = false; -static VisuGUI_Selection *Selection; -static int VISU_POINT_SIZE = 5; - -QAD_Study* VisuGUI::myActiveStudy = NULL; -VISU::VISU_Gen_var VisuGUI::myComponent = VISU::VISU_Gen::_nil(); -SALOMEDS::Study_var VisuGUI::myStudy = SALOMEDS::Study::_nil(); -SALOMEDS::StudyBuilder_var VisuGUI::myStudyBuilder = SALOMEDS::StudyBuilder::_nil(); -QAD_Desktop* VisuGUI::myDesktop = NULL; - -QAD_Study* MYActiveStudy = NULL; -SALOMEDS::StudyBuilder_var MYStudyBuilder = SALOMEDS::StudyBuilder::_nil(); -SALOMEDS::Study_var MYStudyDocument = SALOMEDS::Study::_nil(); - -const QString ObjectTypes("FIELD VIEW3D MESH TIMESTAMP ENTITY FAMILY GROUP"); - - -class CustomItem : public QCustomMenuItem -{ +class CustomItem : public QCustomMenuItem{ public: CustomItem( const QString& s, const QFont& f ) : string( s ), font( f ){}; @@ -152,16 +151,39 @@ private: QFont font; }; -static VisuGUI *visuGUI = 0; -static QString PREFIX = QString(getenv("USER")) + "-VISU-"; +static VisuGUI MYVISUGUI; +static VisuGUI *visuGUI = &MYVISUGUI; + +VISU::VISU_Gen_i* VisuGUI::GetVisuGen(){ + VISU::VISU_Gen_i::GetVisuGenImpl()->SetCurrentStudy(GetStudyDocument()); + return VISU::VISU_Gen_i::GetVisuGenImpl(); +} + +QAD_Desktop* VisuGUI::GetDesktop(){ + return QAD_Application::getDesktop() ; +} + +QAD_Study* VisuGUI::GetActiveStudy(){ + return GetDesktop()->getActiveStudy() ; +} +vtkRenderer* VisuGUI::GetRenderer(){ + if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame()) + return aViewFrame->getRenderer(); + return NULL; +} +VTKViewer_ViewFrame* VisuGUI::GetVtkViewFrame(){ + QAD_ViewFrame* aViewFrame = GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame(); + return dynamic_cast(aViewFrame); +} -vtkRenderer* VisuGUI::GetRenderer(QAD_Study* theStudy){ - if (theStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) - return NULL; +SALOMEDS::Study_var VisuGUI::GetStudyDocument(){ + return GetActiveStudy()->getStudyDocument(); +} - return ((VTKViewer_ViewFrame*)theStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); +SALOMEDS::StudyBuilder_var VisuGUI::NewBuilder(){ + return GetStudyDocument()->NewBuilder(); } @@ -192,51 +214,15 @@ QString VisuGUI::getValue(SALOMEDS::SObject_var theSObject, QString theKey) { } -CORBA::Object_var GetSelectedObj(string& theComment, Handle(SALOME_InteractiveObject)& theIO, QAD_Study* theStudy){ - SALOME_Selection* Sel = SALOME_Selection::Selection(theStudy->getSelection()); - if( Sel->IObjectCount() > 0 ) { - theIO = Sel->firstIObject(); - if (theIO->hasEntry()){ - SALOMEDS::SObject_var aSObject = MYStudyDocument->FindObjectID(theIO->getEntry()); - if(!aSObject->_is_nil()){ - SALOMEDS::GenericAttribute_var anAttr; - if (aSObject->FindAttribute(anAttr, "AttributeComment")) { - SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr); - theComment = aComment->Value(); - QString strIn(theComment.c_str()); - VISU::Storable::TRestoringMap aMap; - VISU::Storable::StrToMap(strIn,aMap); - bool isExist; - theComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1(); - if(!isExist) theComment = "NONE"; - } else { - theComment = "NONE"; - } - aSObject->FindAttribute(anAttr, "AttributeIOR"); - if(!anAttr->_is_nil()){ - SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - if(!anIOR->_is_nil()){ - CORBA::String_var aValue = anIOR->Value(); - if(strcmp(aValue,"") != 0){ - CORBA::ORB_ptr anORB = VISU::Base_i::GetORB(); - CORBA::Object_var anObject = anORB->string_to_object(aValue); - return anObject; - } - } - } - } - } - } - return CORBA::Object::_nil(); -} - -CORBA::Object_var GetSelectedObj(QAD_Study* theStudy, Handle(SALOME_InteractiveObject)* pIO = NULL, +CORBA::Object_var GetSelectedObj(Handle(SALOME_InteractiveObject)* pIO = NULL, QAD_Study* theStudy = NULL, VISU::Storable::TRestoringMap* pMap = NULL) { - SALOME_Selection* Sel = SALOME_Selection::Selection(theStudy->getSelection()); - if( Sel->IObjectCount() > 0 ) { - Handle(SALOME_InteractiveObject)& anIO = (*pIO) = Sel->firstIObject(); - if (anIO->hasEntry()){ + if(theStudy == NULL) theStudy = VisuGUI::GetActiveStudy(); + SALOME_Selection* aSel = SALOME_Selection::Selection(theStudy->getSelection()); + if(aSel->IObjectCount() > 0){ + const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject(); + if(pIO != NULL) *pIO = anIO; + if(anIO->hasEntry()){ SALOMEDS::Study_var aStudy = theStudy->getStudyDocument(); SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry()); if(!aSObject->_is_nil()){ @@ -254,69 +240,16 @@ CORBA::Object_var GetSelectedObj(QAD_Study* theStudy, Handle(SALOME_InteractiveO return CORBA::Object::_nil(); } -int IsTrihedronDisplayed(){ - QAD_ViewFrame* aViewFrame = MYActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame(); - VTKViewer_ViewFrame* aVTKViewFrame = dynamic_cast(aViewFrame); - return aVTKViewFrame->isTrihedronDisplayed(); -} - -VTKViewer_ViewFrame* VisuGUI::GetVtkViewFrame(){ - QAD_ViewFrame* aViewFrame = myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame(); - return dynamic_cast(aViewFrame); +int IsTrihedronDisplayed(){ + if(VTKViewer_ViewFrame* aVTKViewFrame = VisuGUI::GetVtkViewFrame()) + return aVTKViewFrame->isTrihedronDisplayed(); + return 1; } void RepaintCurrentView(){ - VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame(); - if (vf) - vf->Repaint(); -} - - -VISU_Actor* GetActorByIO(const Handle(SALOME_InteractiveObject)& theIO, vtkRenderer* theRen) { - vtkActorCollection* aActors = theRen->GetActors(); - vtkActor* anActor; - VISU_Actor* aVisuActor; - for (aActors->InitTraversal(); (anActor = aActors->GetNextActor())!=NULL;) { - if (anActor->IsA("VISU_Actor")) { - aVisuActor = VISU_Actor::SafeDownCast(anActor); - if (aVisuActor->hasIO()) { - if (theIO->isSame(aVisuActor->getIO())) - return aVisuActor; - } - } - } - return 0; -} - -VISU::Base_i* GetSelectedVisuObj(){ - SALOME_Selection* Sel = SALOME_Selection::Selection(MYActiveStudy->getSelection()); - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - if(It.More()){ - Handle(SALOME_InteractiveObject) IObject = It.Value(); - if (IObject->hasEntry()){ - SALOMEDS::SObject_var aSObject = MYStudyDocument->FindObjectID(IObject->getEntry()); - if(!aSObject->_is_nil()){ - SALOMEDS::SComponent_var comp = aSObject->GetFatherComponent(); - if ( !comp->_is_nil() ) { - SALOMEDS::GenericAttribute_var anAttr; - if (comp->FindAttribute(anAttr, "AttributeName")) { - SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); - if (QString(aName->Value()) == QString("Visu")) { - CORBA::Object_var aObject = VISU::SObjectToObject(aSObject); - if(!CORBA::is_nil(aObject)) { - PortableServer::Servant aServant = VISU::GetServant(aObject); - if (aServant) - return dynamic_cast(aServant); - } - } - } - } - } - } - } - return NULL; + if(VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame()) vf->Repaint(); } /** @@ -338,27 +271,14 @@ int GetScalarMode(VISU::Result_i* theResult, const char* theFieldName){ } -VisuGUI::VisuGUI(){ -} +VisuGUI::VisuGUI(){} VisuGUI* VisuGUI::GetOrCreateVisuGUI( QAD_Desktop* desktop ){ if(!visuGUI){ static VisuGUI VISUGUI; visuGUI = &VISUGUI; - Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Visu"); - myComponent = VISU::VISU_Gen::_narrow(comp); - } - /* study may have changed */ - myDesktop = desktop; - myActiveStudy = myDesktop->getActiveStudy(); - myStudy = myActiveStudy->getStudyDocument(); //Document OCAF de l'etude active - myComponent->SetCurrentStudy(myStudy); - myStudyBuilder = myStudy->NewBuilder(); - - MYActiveStudy = myActiveStudy; - MYStudyDocument = myStudy; - MYStudyBuilder = myStudyBuilder; + } return visuGUI; } @@ -397,20 +317,11 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) { try{ VisuGUI::GetOrCreateVisuGUI(parent); -// get Visu directories from configuration file. Default values are enabled. -/* if (visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) { // BugID: SAL931 - QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), - tr ("Not available in Non-VTK viewers"), - tr ("VISU_BUT_OK") ); - }*/ QString VisuInputDir = getVisuInputDir(); QString VisuOutputDir = getVisuOutputDir(); - vtkRenderer *theRenderer = GetRenderer(visuGUI->myActiveStudy); + vtkRenderer *theRenderer = GetRenderer(); - //vtkActorCollection* aActors = theRenderer->GetActors(); - //cout<<"### Actors Nb="<GetNumberOfItems()<myActiveStudy->getStudyDocument(); //Document OCAF de l'etude active + SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument(); //Document OCAF de l'etude active SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeName_var aName; @@ -464,34 +375,6 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) break; } - /* ========================================================================================================================= */ - /* Print to printer (132) or in file (131) */ - /* ========================================================================================================================= */ - - case 131 : - case 132 : - { - QString prFile; - if (theCommandID == 131) { // save the file - prFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), - VisuOutputDir, - filters[9], - tr("TIFF File"), - false); - if ( prFile.isEmpty() ) - break; - - VisuOutputDir = QAD_Tools::getDirFromPath(prFile); // set VisuOutputDir - QAD_CONFIG->addSetting("Visu:OutputDir",VisuOutputDir); - - visuGUI->PrintRW(prFile, false); - } else { - prFile=VisuOutputDir+"SalomeVisu.tif"; - visuGUI->PrintRW(prFile, true); - } - break; - } - /* ========================================================================== */ /* Visualization of Results : */ /* 4011 : Scalar Map */ @@ -517,6 +400,9 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) case 4015 : visuGUI->CreateCutPlanes(); break; + case 4018 : + visuGUI->CreateCutLines(); + break; case 4016 : visuGUI->CreateStreamLines(); break; @@ -535,120 +421,32 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) /* ========================================================================================================================= */ case 4111 : - { - visuGUI->SelectCell(); - break; -/* VSR 12/03/03: see VisuGUI::SelectCell() - int TypeMode; - VISU_Actor *ActorTmp; - string aComment; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj(aComment,anIO,visuGUI->myActiveStudy); - //srn: Added check if anObject is Null, then break -// if(CORBA::is_nil(anObject)) break; - - VISU::ScalarMap_i* aPrsObject = NULL; - if(!CORBA::is_nil(anObject)) - aPrsObject = dynamic_cast(VISU::GetServant(anObject)); - if(aPrsObject){ - //aPrsObject->SetIO(anIO); - //ActorTmp = aPrsObject->GetActor(); - //UpdateViewer(ActorTmp); - ActorTmp = visuGUI->UpdateViewer(aPrsObject); - } else { - ActorTmp = ActorSelected(parent,true,&TypeMode); - } - if (ActorTmp==NULL) - break; - - bool ok=FALSE; - vtkDataSetMapper *Mapper = (vtkDataSetMapper*) (ActorTmp->GetMapper()); - Mapper->SetInput(ActorTmp->DataSource); - vtkDataSet *Data=Mapper->GetInput(); - int nbCells=Data->GetNumberOfCells(); - int selectedCell = QInputDialog::getInteger( tr( "Please choose a cell number" ), tr("Cell selection"), 0, 0, (int)(nbCells), 1, &ok, parent ,""); - if (ok && theRenderer) - Selection->HighlightCell(selectedCell , ActorTmp , theRenderer); - break; -*/ - } + visuGUI->SelectCell(); + break; /* ========================================================================================================================= */ /* Selection - Cell - information attribute */ /* ========================================================================================================================= */ case 4112 : - { - visuGUI->InfoOnCell(); - break; -/* VSR 12/03/03: see VisuGUI::InfoOnCell() - int TypeMode; - VISU_Actor *ActorTmp; - ActorTmp = ActorSelected(parent,true,&TypeMode); - if (ActorTmp==NULL) - break; - - if ((TypeMode == SelectionCell) || (TypeMode == SelectionEdge)) - Selection->PickingResults(visuGUI->myActiveStudy,TypeMode,ActorTmp); - else - QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("WARNING"), - tr ("Not Selected View - Cell Selection Mode"), - tr ("VISU_BUT_OK") ); - break; -*/ - } + visuGUI->InfoOnCell(); + break; /* ========================================================================================================================= */ /* Selection - Point - information number */ /* ========================================================================================================================= */ case 4121 : - { - visuGUI->SelectPoint(); - break; -/* VSR 12/03/03: see VisuGUI::SelectPoint() - int TypeMode; - VISU_Actor *ActorTmp; - ActorTmp = ActorSelected(parent,true,&TypeMode); - if (ActorTmp==NULL) - break; - - bool ok=FALSE; - vtkDataSetMapper *Mapper = (vtkDataSetMapper*) (ActorTmp->GetMapper()); - Mapper->SetInput(ActorTmp->DataSource); - vtkDataSet *Data=Mapper->GetInput(); - int nbPoints=Data->GetNumberOfPoints(); - int selectedPoint = QInputDialog::getInteger( tr( "Please choose a Point number" ), tr("Point selection"), 0, 0, (int)(nbPoints-1), 1, &ok, parent ,""); - if (ok && theRenderer) - Selection->HighlightPoint(selectedPoint , nbPoints, ActorTmp , theRenderer); - break; -*/ - } + visuGUI->SelectPoint(); + break; /* ========================================================================================================================= */ /* Selection - Point - information attribute */ /* ========================================================================================================================= */ case 4122 : - { - visuGUI->InfoOnPoint(); - break; -/* VSR 12/03/03: see VisuGUI::InfoOnPoint() - int TypeMode; - VISU_Actor *ActorTmp; - ActorTmp = ActorSelected(parent,true,&TypeMode); - if (ActorTmp==NULL) - break; - - if (TypeMode == SelectionPoint) - Selection->PickingResults(visuGUI->myActiveStudy,TypeMode,ActorTmp); - else - QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("WARNING"), - tr ("Not Selected View - Point Selection Mode"), - tr ("VISU_BUT_OK") ); - break; -*/ - } + visuGUI->InfoOnPoint(); + break; /* ========================================================================================================================= */ /* Selection - Shape */ @@ -661,7 +459,7 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) /* ========================================================================================================================= */ case 4211 : - ChangeViewer(parent, theRenderer, true, 1); + ChangeViewer(1); break; /* ========================================================================================================================= */ @@ -669,7 +467,7 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) /* ========================================================================================================================= */ case 4212 : - ChangeViewer(parent, theRenderer, true, 2); + ChangeViewer(2); break; /* ========================================================================================================================= */ @@ -677,7 +475,7 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) /* ========================================================================================================================= */ case 4213 : - ChangeViewer(parent, theRenderer, true, 0); + ChangeViewer(0); break; /* ========================================================================================================================= */ @@ -685,8 +483,7 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) /* ========================================================================================================================= */ case 422 : - if (visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) - ClearViewer(parent, theRenderer, -1); + ChangeViewer(-1); break; /* ========================================================================================================================= */ @@ -773,72 +570,12 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) visuGUI->Sweep(); break; - case 807 : // Modify visualization - case 809 : // Return Cell Id - case 810 : // Highlight Cell parameter - // ---------------- For Popup in ObjectBrowser - case 907 : // Modify visualization - - { - int TypeMode; - bool InViewer; - VISU_Actor *ActorTmp; - string aComment; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj(aComment,anIO,visuGUI->myActiveStudy); - VISU::ScalarMap_i* aPrsObject = dynamic_cast(VISU::GetServant(anObject)); - if(aPrsObject){ - ActorTmp = visuGUI->UpdateViewer(aPrsObject); - } else { - if ( ((theCommandID >= 801) && (theCommandID <= 809)) || ((theCommandID >= 8041) && (theCommandID <= 8059)) ) - InViewer= true; - else if ( ((theCommandID >= 901) && (theCommandID <= 909)) || ((theCommandID >= 9041) && (theCommandID <= 9059)) ) - InViewer = false; - - ActorTmp = ActorSelected(parent,InViewer,&TypeMode); - } - if (ActorTmp==NULL) - break; - - - if (theCommandID == 809) // return results of object picked, in the message box - { - Selection->PickingResults(visuGUI->myActiveStudy,TypeMode,ActorTmp); - MESSAGE("Valeur : " << Selection->getId()) - } - - if (theCommandID == 810) // Highlight Cell or point with parameter - { - bool ok=FALSE; - vtkDataSetMapper *Mapper = (vtkDataSetMapper*) (ActorTmp->GetMapper()); - Mapper->SetInput(ActorTmp->DataSource); - vtkDataSet *Data=Mapper->GetInput(); - if (TypeMode == SelectionPoint) - { - int nbPoints=Data->GetNumberOfPoints(); - int selectedPoint = QInputDialog::getInteger( tr( "Please choose a Point number" ), tr("Point selection"), 0, 0, (int)(nbPoints-1), 1, &ok, parent ,""); - if (ok) - Selection->HighlightPoint(selectedPoint , nbPoints, ActorTmp , theRenderer); - } - if ( (TypeMode == SelectionCell) || (TypeMode == SelectionEdge) ) - { - int nbCells=Data->GetNumberOfCells()-1; - int selectedCell = QInputDialog::getInteger( tr( "Please choose a cell number" ), tr("Cell selection"), 0, 0, (int)(nbCells), 1, &ok, parent ,""); - if (ok) - Selection->HighlightCell(selectedCell , ActorTmp , theRenderer); - } - } - - break; - } - /* ======================================================================================== */ /* Preferences for Scalar Bar */ /* ======================================================================================== */ case 51: { ChangeScalarBar(); - break; } @@ -854,9 +591,9 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) case 113: // Load MED using MED component { - if (checkLock(myStudy)) break; + if (checkLock(GetStudyDocument())) break; - Engines::Component_var aMedComp = myDesktop->getEngine("FactoryServer", "Med"); + Engines::Component_var aMedComp = GetDesktop()->getEngine("FactoryServer", "Med"); if (CORBA::is_nil(aMedComp)) return false; Engines::Med_Gen_var aMedGen = Engines::Med_Gen::_narrow(aMedComp); if (CORBA::is_nil(aMedGen)) return false; @@ -865,15 +602,15 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) filtersList.append( tr("MED_MEN_IMPORT_MED") ); filtersList.append( tr("MED_MEN_ALL_FILES") ) ; - QString aFileName = QAD_FileDlg::getFileName(myDesktop, + QString aFileName = QAD_FileDlg::getFileName(GetDesktop(), "", filtersList, tr("MED_MEN_IMPORT"), true); if (!aFileName.isEmpty()) { QApplication::setOverrideCursor( Qt::waitCursor ); - aMedGen->readStructFileWithFieldType(aFileName.latin1(), myActiveStudy->getTitle()); - myActiveStudy->updateObjBrowser(); + aMedGen->readStructFileWithFieldType(aFileName.latin1(), GetActiveStudy()->getTitle()); + GetActiveStudy()->updateObjBrowser(); QApplication::restoreOverrideCursor(); } } @@ -881,27 +618,17 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) default: QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), - tr ("Not Yet Implemented"), + tr ("MSG_NOT_IMPLEMENTED"), tr ("VISU_BUT_OK") ); break; - } - } -/* - catch(SALOMEDS::GenericAttribute::LockProtection&) { - QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(), - QObject::tr("WARNING"), - QObject::tr("WRN_STUDY_LOCKED"), - QObject::tr("BUT_OK") ); - return false; - } -*/ - catch (const SALOME::SALOME_Exception& S_ex) { + } + }catch (const SALOME::SALOME_Exception& S_ex) { QtCatchCorbaException(S_ex); return false; } catch(...) { QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"), - tr("Unknown exception was caught in VISU module"), + tr("ERR_UNKNOWN_EXCEPTION"), tr("VISU_BUT_OK") ); return false; } @@ -909,238 +636,25 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) } -/* ********************************************************************************* */ -/* Function to find Actor in ObjectBrowser */ -/* ********************************************************************************* */ - -VISU_Actor *VisuGUI::GetActorObjBrowser(SALOMEDS::SObject_var objVisu, vtkRenderer *ren) -{ - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - if ( objVisu->FindAttribute(anAttr, "AttributeName") ) { - aName = SALOMEDS::AttributeName::_narrow(anAttr); - - MESSAGE("GetActor == > Name : " << aName->Value()); - - vtkActorCollection *ac; - vtkActor *actor; - ac = ren->GetActors(); - - for(ac->InitTraversal();(actor = ac->GetNextActor())!=NULL;) { - if (actor->IsA("VISU_Actor")) { - VISU_Actor *VISUActor = VISU_Actor::SafeDownCast(actor); - if (strcmp(VISUActor->getName(), aName->Value()) == 0) - return VISUActor; - } - } - } - return NULL; -} - - /* ********************************************************************************* */ /* Function to find Actor in Viewer */ /* ********************************************************************************* */ -VISU_Actor *VisuGUI::GetActor(QAD_Desktop* parent, Handle_SALOME_InteractiveObject IO, vtkRenderer *ren) -{ - VisuGUI::GetOrCreateVisuGUI(parent); - - QString theEntry = IO->getEntry(); - Standard_CString aComment; - Standard_CString Persistent; - //Standard_CString aName = IO->getName(); - VISU_Actor *anActor; - result Test; - - SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument(); - - SALOMEDS::SObject_var objlocal = aStudy->FindObjectID(theEntry.latin1()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeComment_var aCmnt; - SALOMEDS::AttributePersistentRef_var aPRef; - - if (objlocal->FindAttribute(anAttr, "AttributeComment")) { - aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr); - aComment = aCmnt->Value(); - } - if (objlocal->FindAttribute(anAttr, "AttributePersistentRef")) { - aPRef = SALOMEDS::AttributePersistentRef::_narrow(anAttr); - Persistent = aPRef->Value(); - } - - vtkActorCollection *aclocal; - vtkActor *actorlocal; - aclocal = ren->GetActors(); - - // ============================================================================= - // Test if Actor exists in theRenderer - for (aclocal->InitTraversal();(actorlocal = aclocal->GetNextActor())!=NULL;) - { - if (actorlocal->IsA("VISU_Actor")) - { - anActor = VISU_Actor::SafeDownCast(actorlocal); - MESSAGE(" getIO de anActor : " << anActor->getIO()) - if (anActor->hasIO()) - { - if (IO->isSame(anActor->getIO())) - { - MESSAGE("isSame IO") - return anActor; - } - } - } - } - - // ============================================================================= - // If Actor doesn't exist in theRenderer => create same actor in new renderer - /* int nbSf = visuGUI->myActiveStudy->getStudyFramesCount(); - SALOMEDS::SObject_var TheMeshObject= objlocal->GetFather(); - for ( int i = 0; i < nbSf; i++ ) - { - QAD_StudyFrame* sf = visuGUI->myActiveStudy->getStudyFrame(i); - if ( sf->getTypeView() == VIEW_VTK ) - { - vtkRenderer* aRenderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer(); - vtkActorCollection* ac = aRenderer->GetActors(); - vtkActor *actor; - for(ac->InitTraversal();(actor = ac->GetNextActor())!=NULL;) - { - if (actor->IsA("VISU_Actor")) - { - anActor = VISU_Actor::SafeDownCast(actor); - if (anActor->hasIO()) - { - if (IO->isSame(anActor->getIO())) - { - if (aRenderer != ren) - { - return(visuGUI->DuplicateActor(anActor,IO,objlocal,aComment)); - } - } - } - } - } - } - }*/ - return NULL; - //return(visuGUI->DuplicateActor(anActor,IO,objlocal,aComment)); -} - -/* ********************************************************************************** */ -/* Function ActorSelected */ -/* To return the Actor selected in Viewer or in ObjectBrowser */ -/* ********************************************************************************** */ +VISU_Actor *VisuGUI::GetActor(int* theSelectionType){ + VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d(); + if (!aPrs3d) return NULL; -VISU_Actor *VisuGUI::ActorSelected(QAD_Desktop* parent, bool InViewer, int *Mode) -{ - VisuGUI::GetOrCreateVisuGUI(parent); - SALOME_Selection *Sel; - QAD_ObjectBrowserItem* item; - VISU_Actor *ActorTmp; - Standard_CString PersRef = ""; - Sel = SALOME_Selection::Selection(visuGUI->myActiveStudy->getSelection()); - vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); - - - - *Mode=Sel->SelectionMode(); - - SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument(); //Document OCAF de l'etude active - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - //SALOMEDS::SComponent_var father = aStudy->FindComponent("VISU"); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributePersistentRef_var aPRef; - if ( InViewer ) - { - if (Sel->IObjectCount()==0) - return NULL; - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - Handle(SALOME_InteractiveObject) IObject = It.Value(); - ActorTmp=GetActor(parent,IObject,theRenderer); - } - else - { - item = (QAD_ObjectBrowserItem*)(visuGUI->myActiveStudy->getActiveStudyFrame()->getLeftFrame()->getObjectBrowser()->getListView()->currentItem()); - if ( item != NULL ) - { - // Test if a selected visu object - QString theEntry = item->getEntry(); - - MESSAGE("==================== TheEntry : " << theEntry) - if ( theEntry.isEmpty() ) - { - QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), - tr ("Bad Type for Selected Item in Popup Menu"), - tr ("VISU_BUT_OK") ); - return NULL; - } - - SALOMEDS::SObject_var objVisu = aStudy->FindObjectID(theEntry.latin1()); - if (objVisu->FindAttribute(anAttr, "AttributePersistentRef")) { - aPRef = SALOMEDS::AttributePersistentRef::_narrow(anAttr); - PersRef = aPRef->Value(); - } + VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame(); + if(!vf) return NULL; - if ( objVisu->_is_nil() ) - { - QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), - tr ("nil object"), - tr ("VISU_BUT_OK") ); - return NULL; - } - ActorTmp=GetActorObjBrowser(objVisu,theRenderer); - } - else - return NULL; + if(theSelectionType){ + QAD_Study *aStudy = QAD_Application::getDesktop()->getActiveStudy(); + SALOME_Selection *aSel = SALOME_Selection::Selection(aStudy->getSelection()); + *theSelectionType = aSel->SelectionMode(); } - return (ActorTmp); -} - -/* ********************************************************************************** */ -/* Function ClearViewer - Erase the actors displayed on the viewer */ -/* ********************************************************************************** */ -void VisuGUI::ClearViewer(QAD_Desktop* parent, vtkRenderer *ren, int TypeOfActor) -{ - // TypeOfActor = -1 : All - // = 1 : VisuActor - // = 2 : ScalarBarActor - // = 4 : Other Actor2D - - vtkActorCollection *ac; - vtkActor2DCollection *ac2D; - vtkActor *actor; - vtkActor2D *actor2D; - ac = ren->GetActors(); - ac2D = ren->GetActors2D(); - - if(TypeOfActor == -1 || TypeOfActor == 1) { - bool TrhVisible = ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy-> - getActiveStudyFrame()->getRightFrame()->getViewFrame())->isTrihedronDisplayed(); - for(ac->InitTraversal();(actor = ac->GetNextActor())!=NULL;) { - if (actor->IsA("VISU_Actor") || actor->IsA("vtkActor") ) - actor->VisibilityOff(); - } - if (TrhVisible) ShowTrihedron(false); - } - - if(TypeOfActor == -1 || TypeOfActor == 2) { - for(ac2D->InitTraversal();(actor2D = ac2D->GetNextActor2D())!=NULL;) - if (actor2D->IsA("vtkScalarBarActor")) - actor2D->VisibilityOff(); - } - - if(TypeOfActor == -1 || TypeOfActor == 4) { - for(ac2D->InitTraversal();(actor2D = ac2D->GetNextActor2D())!=NULL;) - if (!(actor2D->IsA("vtkScalarBarActor"))) // it's a plot2d - { - actor2D->VisibilityOff(); - //actor2D->Delete(); - } - } + return GetActor(aPrs3d,vf); } /* ********************************************************************************** */ @@ -1150,9 +664,9 @@ void VisuGUI::ClearViewer(QAD_Desktop* parent, vtkRenderer *ren, int TypeOfActor void VisuGUI::ShowTrihedron(bool ShowThd){ bool ThdIsVisible = true; if( ShowThd && !ThdIsVisible) - ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron(); + ((VTKViewer_ViewFrame*)visuGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron(); if( !ShowThd && ThdIsVisible) - ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron(); + ((VTKViewer_ViewFrame*)visuGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron(); } /* ********************************************************************************** */ @@ -1169,16 +683,25 @@ VisuGUI::~VisuGUI(){ /* Change representation of all actors */ /* ********************************************************************************** */ -void VisuGUI::ChangeViewer(QAD_Desktop* parent, vtkRenderer *ren, bool ScalarBar, int Type) -{ - if (!ren) return; - VisuGUI::GetOrCreateVisuGUI(parent); - vtkActorCollection *ac; - vtkActor *actor; - ac = ren->GetActors(); +void VisuGUI::ChangeViewer(int theType){ + VTKViewer_ViewFrame* vf = GetVtkViewFrame(); + if (!vf) return; - for(ac->InitTraversal();(actor = ac->GetNextActor())!=NULL;) - actor->GetProperty()->SetRepresentation(Type); + vtkActor *anActor; + vtkRenderer *aRen = vf->getRenderer(); + vtkActorCollection *anActColl = aRen->GetActors(); + for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){ + if(anActor->IsA("VISU_Actor")){ + VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor); + if(anVISUActor->GetVisibility() > 0) + if(theType > 0) + anVISUActor->SetRepresentation(theType); + else if(theType == -1) + anVISUActor->VisibilityOff(); + else + anVISUActor->VisibilityOn(); + } + } } @@ -1205,7 +728,7 @@ bool VisuGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* bool VisuGUI::OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) { VisuGUI::GetOrCreateVisuGUI(parent); - if (visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) // true = Viewer OCC + if (GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK) // true = Viewer OCC return false; MESSAGE ( "VisuGUI::onKeyPress : " << pe->key() ) @@ -1233,12 +756,12 @@ bool VisuGUI::OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* st #define CREATEPRESENTATION(FunctionName) \ void FunctionName() { \ - if (checkLock(myStudy)) return; \ + if (checkLock(GetStudyDocument())) return; \ SALOMEDS::SObject_var objVisu; \ - if (!TestObjectBrowser(&objVisu)) return; \ + if (!TestObjectBrowser(objVisu)) return; \ if(!FunctionName(objVisu)) return; \ - visuGUI->myActiveStudy->updateObjBrowser(); \ - myDesktop->putInfo("Ready"); \ + GetActiveStudy()->updateObjBrowser(); \ + GetDesktop()->putInfo("Ready"); \ VTKViewer_ViewFrame* vf = GetVtkViewFrame(); \ if (vf) { \ /*vf->getRenderer()->ResetCameraClippingRange();*/ \ @@ -1252,6 +775,7 @@ CREATEPRESENTATION(VisuGUI::CreateDeformedShape); CREATEPRESENTATION(VisuGUI::CreateVectors); CREATEPRESENTATION(VisuGUI::CreateIsoSurfaces); CREATEPRESENTATION(VisuGUI::CreateCutPlanes); +CREATEPRESENTATION(VisuGUI::CreateCutLines); CREATEPRESENTATION(VisuGUI::CreateStreamLines); @@ -1273,29 +797,18 @@ bool VisuGUI::setSettings(QAD_Desktop* parent) //===================================================================================== void VisuGUI::DisplayPrs() { MESSAGE("VisuGUI::DisplayPrs"); - string aComment; Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj(aComment, anIO, myActiveStudy); + CORBA::Object_var anObject = GetSelectedObj(&anIO); if ( !CORBA::is_nil( anObject ) ) { // is it Prs3d object ? VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(anObject)); if(aPrsObject){ MESSAGE("VisuGUI::DisplayPrs : Prs3d object"); UpdateViewer(aPrsObject); - VTKViewer_ViewFrame* vf = GetVtkViewFrame(); - if (vf) { + if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) { vf->getRenderer()->ResetCameraClippingRange(); -#ifdef CHECKTIME - OSD_Timer timer; - timer.Start(); -#endif vf->Repaint(); vf->highlight(anIO, 1); -#ifdef CHECKTIME - timer.Stop(); - MESSAGE("Check time on VisuGUI::DisplayPrs - vf->Repaint + vf->highlight"); - timer.Show(); -#endif } return; } @@ -1329,13 +842,11 @@ void VisuGUI::DisplayPrs() { //===================================================================================== void VisuGUI::DisplayOnlyPrs() { MESSAGE("VisuGUI::DisplayOnlyPrs"); - string aComment; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj(aComment, anIO, myActiveStudy); + CORBA::Object_var anObject = GetSelectedObj(); if ( !CORBA::is_nil( anObject ) ) { // is it Prs3d object ? - VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(anObject)); - if(aPrsObject){ + PortableServer::Servant aServant = VISU::GetServant(anObject); + if(VISU::Prs3d_i* aPrsObject = dynamic_cast(aServant)){ MESSAGE("VisuGUI::DisplayOnlyPrs : Prs3d object"); UpdateViewer(aPrsObject, true); VTKViewer_ViewFrame* vf = GetVtkViewFrame(); @@ -1343,28 +854,15 @@ void VisuGUI::DisplayOnlyPrs() { vf->getRenderer()->ResetCameraClippingRange(); vf->Repaint(); } - return; - } - // is it Curve ? - VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(anObject)); - if(aCurve){ + }else if(VISU::Curve_i* aCurve = dynamic_cast(aServant)){ MESSAGE("VisuGUI::DisplayOnlyPrs : Curve object"); PlotCurve(aCurve, VISU::eDisplayOnly ); - return; - } - // is it Container ? - VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(anObject)); - if(aContainer){ + }else if(VISU::Container_i* aContainer = dynamic_cast(aServant)){ MESSAGE("VisuGUI::DisplayOnlyPrs : Container object"); PlotContainer(aContainer, VISU::eDisplayOnly ); - return; - } - // is it Table ? - VISU::Table_i* aTable = dynamic_cast(VISU::GetServant(anObject)); - if(aTable){ + }else if(VISU::Table_i* aTable = dynamic_cast(aServant)){ MESSAGE("VisuGUI::DisplayOnlyPrs : Table object"); PlotTable(aTable, VISU::eDisplayOnly ); - return; } } } @@ -1375,9 +873,7 @@ void VisuGUI::DisplayOnlyPrs() { //===================================================================================== void VisuGUI::ErasePrs() { MESSAGE("VisuGUI::ErasePrs"); - string aComment; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj(aComment, anIO, myActiveStudy); + CORBA::Object_var anObject = GetSelectedObj(); if ( !CORBA::is_nil( anObject ) ) { // is it Prs3d object ? VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(anObject)); @@ -1410,61 +906,136 @@ void VisuGUI::ErasePrs() { } } - //===================================================================================== -// function : RecreateActor() +// function : DisplayManyPrs() // purpose : //===================================================================================== -void VisuGUI::RecreateActor(VISU::Prs3d_i* thePrs) { - /* BEGIN_OF("VisuGUI::RecreateActor"); - - VTKViewer_ViewFrame* vf = GetVtkViewFrame(); - if (!vf) return; - QApplication::setOverrideCursor( Qt::waitCursor ); - vtkRenderer *aRen = vf->getRenderer(); - VISU_Actor* anVISUActor = GetActor(thePrs); - - if(anVISUActor == NULL){ - anVISUActor= thePrs->CreateActor(); - anVISUActor->SetVisibility(true); - vf->AddActor(anVISUActor); - if (anVISUActor->HasScalarBar()) { - anVISUActor->getScalarBar()->SetVisibility(true); - aRen->AddActor2D(anVISUActor->getScalarBar()); +void VisuGUI::DisplayManyPrs() +{ + MESSAGE("VisuGUI::DisplayManyPrs"); + SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + for ( ; It.More(); It.Next() ) { + Handle(SALOME_InteractiveObject)& anIO = It.Value(); + if ( anIO->hasEntry() ) { + SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); + SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() ); + VISU::Storable::TRestoringMap pMap; + if( !aSObject->_is_nil() ) { + CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject); + if ( !CORBA::is_nil( aCORBAObject ) ) { + // is it Prs3d object ? + VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(aCORBAObject)); + if(aPrsObject){ + MESSAGE("VisuGUI::DisplayManyPrs : Prs3d object"); + UpdateViewer(aPrsObject); + VTKViewer_ViewFrame* vf = GetVtkViewFrame(); + if (vf) { + vf->getRenderer()->ResetCameraClippingRange(); + vf->Repaint(); + vf->highlight(anIO, 1); + } + continue; + } + // is it Curve ? + VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(aCORBAObject)); + if(aCurve){ + MESSAGE("VisuGUI::DisplayManyPrs: Curve object"); + PlotCurve(aCurve, VISU::eDisplay ); + continue; + } + // is it Container ? + VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(aCORBAObject)); + if(aContainer){ + MESSAGE("VisuGUI::DisplayManyPrs : Container object"); + PlotContainer(aContainer, VISU::eDisplay ); + continue; + } + // is it Table ? + VISU::Table_i* aTable = dynamic_cast(VISU::GetServant(aCORBAObject)); + if(aTable){ + MESSAGE("VisuGUI::DisplayManyPrs : Table object"); + PlotTable(aTable, VISU::eDisplay ); + continue; + } + } + } } } - vf->Repaint(); - - QApplication::restoreOverrideCursor(); - - END_OF("VisuGUI::RecreateActor") */ - VTKViewer_ViewFrame* vf = GetVtkViewFrame(); - if (!vf) return; +} - VISU_Actor* anVISUActor = GetActor(thePrs); - int isVisible = false; +//===================================================================================== +// function : EraseManyPrs() +// purpose : +//===================================================================================== +void VisuGUI::EraseManyPrs() +{ + MESSAGE("VisuGUI::EraseManyPrs"); + SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); + SALOME_ListIO LIO; LIO = Sel->StoredIObjects(); + SALOME_ListIteratorOfListIO It( LIO ); + for ( ; It.More(); It.Next() ) { + Handle(SALOME_InteractiveObject)& anIO = It.Value(); + if ( anIO->hasEntry() ) { + SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); + SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() ); + VISU::Storable::TRestoringMap pMap; + if( !aSObject->_is_nil() ) { + CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject); + if ( !CORBA::is_nil( aCORBAObject ) ) { + // is it Prs3d object ? + VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(aCORBAObject)); + if(aPrsObject){ + MESSAGE("VisuGUI::EraseManyPrs : Prs3d object"); + ErasePrs(aPrsObject); + VTKViewer_ViewFrame* vf = GetVtkViewFrame(); + if (vf) { + vf->Repaint(); + } + continue; + } + // is it Curve ? + VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(aCORBAObject)); + if(aCurve){ + MESSAGE("VisuGUI::EraseManyPrs : Curve object"); + PlotCurve(aCurve, VISU::eErase ); + continue; + } + // is it Container ? + VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(aCORBAObject)); + if(aContainer){ + MESSAGE("VisuGUI::EraseManyPrs : Container object"); + PlotContainer(aContainer, VISU::eErase ); + continue; + } + // is it Table ? + VISU::Table_i* aTable = dynamic_cast(VISU::GetServant(aCORBAObject)); + if(aTable){ + MESSAGE("VisuGUI::EraseManyPrs : Table object"); + PlotTable(aTable, VISU::eErase ); + continue; + } + } + } + } + } +} - QApplication::setOverrideCursor( Qt::waitCursor ); - vtkRenderer *aRen = vf->getRenderer(); - if (anVISUActor) { - isVisible = anVISUActor->GetVisibility(); - Handle(SALOME_InteractiveObject) anIO = anVISUActor->getIO(); - if (anVISUActor->HasScalarBar()) - aRen->RemoveActor(anVISUActor->getScalarBar()); - aRen->RemoveActor(anVISUActor); - anVISUActor->Delete(); - anVISUActor = thePrs->CreateActor(anIO); - } else - anVISUActor = thePrs->CreateActor(); +//===================================================================================== +// function : RecreateActor() +// purpose : +//===================================================================================== +void VisuGUI::RecreateActor(VISU::Prs3d_i* thePrs) { + QApplication::setOverrideCursor(Qt::waitCursor); + thePrs->Update(); + for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++) + if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){ + QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame(); + if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast(aVFrame)) + if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame)) + thePrs->UpdateActor(anActor); + } QApplication::restoreOverrideCursor(); - - if (!anVISUActor) return; - anVISUActor->SetVisibility(isVisible); - aRen->AddActor(anVISUActor); - if (anVISUActor->HasScalarBar()) { - anVISUActor->getScalarBar()->SetVisibility(isVisible); - aRen->AddActor2D(anVISUActor->getScalarBar()); - } } @@ -1487,6 +1058,7 @@ void VisuGUI::RecreateActor(VISU::Prs3d_i* thePrs) { if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) { \ vf->getRenderer()->ResetCameraClippingRange(); \ vf->onViewFitAll(); \ + vf->Repaint(); \ }\ } \ } \ @@ -1496,7 +1068,7 @@ void VisuGUI::RecreateActor(VISU::Prs3d_i* thePrs) { void VisuGUI::EditPrs() { - VISU::Prs3d_i* aPrs3d = GetSelectedPrs(); + VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d(); switch (aPrs3d->GetType()) { case VISU::TMESH: // Mesh 13 @@ -1514,6 +1086,10 @@ void VisuGUI::EditPrs() { EDITPRS(VISU::CutPlanes_i, VisuGUI_CutPlanesDlg); break; + case VISU::TCUTLINES: // Cut planes 42 + EDITPRS(VISU::CutLines_i, VisuGUI_CutLinesDlg); + break; + case VISU::TISOSURFACE: // Iso surfaces EDITPRS(VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg); break; @@ -1532,7 +1108,7 @@ void VisuGUI::EditPrs() { // purpose : //===================================================================================== void VisuGUI::EditScalarBar() { - VISU::Prs3d_i* aPrs3d = GetSelectedPrs(); + VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d(); VISU::ScalarMap_i* aPrsObject = dynamic_cast(aPrs3d); if (aPrsObject) { VisuGUI_ScalarBarDlg* aDlg = new VisuGUI_ScalarBarDlg(false); @@ -1559,14 +1135,10 @@ void VisuGUI::EditScalarBar() { // purpose : //===================================================================================== void VisuGUI::CreateMesh() { + SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection()); + SALOMEDS::SObject_var aSObject = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() ); - //string aComment; - //Handle(SALOME_InteractiveObject) anIO; - //CORBA::Object_var anObject = GetSelectedObj(aComment,anIO, VisuGUI::myActiveStudy); - SALOME_Selection* Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - SALOMEDS::SObject_var aSObject = myActiveStudy->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() ); - - if (checkLock(myStudy)) return; + if (checkLock(GetStudyDocument())) return; SALOMEDS::SObject_var aSObj = aSObject->GetFather(); aSObj = aSObj->GetFather(); @@ -1575,10 +1147,17 @@ void VisuGUI::CreateMesh() { if(CORBA::is_nil(anObject)) { aSObj = aSObj->GetFather(); anObject = VISU::SObjectToObject(aSObj); - if(CORBA::is_nil(anObject)) return; } - VISU::Result_var aResult = VISU::Result::_narrow(anObject); - if(CORBA::is_nil(aResult)) return; + VISU::Result_var aResult; + if (!CORBA::is_nil(anObject)) { + aResult = VISU::Result::_narrow(anObject); + } + if(CORBA::is_nil(aResult)) { + QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"), + tr ("WRN_NO_AVAILABLE_DATA"), + tr ("VISU_BUT_OK")); + return; + } VISU::Storable::TRestoringMap aMap; SALOMEDS::GenericAttribute_var anAttr; @@ -1593,134 +1172,156 @@ void VisuGUI::CreateMesh() { if(!isExist) return; CORBA::Object_var aMesh; string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1(); +#ifdef CHECKTIME + Utils_Timer timer; + timer.Start(); +#endif if(aComment == "ENTITY"){ VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt(); - aMesh = myComponent->MeshOnEntity(aResult,aMeshName.c_str(),anEntity); + aMesh = GetVisuGen()->MeshOnEntity(aResult,aMeshName.c_str(),anEntity); }else if(aComment == "FAMILY"){ VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt(); string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1(); - aMesh = myComponent->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str()); + aMesh = GetVisuGen()->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str()); }else if(aComment == "GROUP"){ string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1(); - aMesh = myComponent->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str()); + aMesh = GetVisuGen()->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str()); } - QApplication::restoreOverrideCursor(); - if(CORBA::is_nil(aMesh)) return; - - VISU::Mesh_i* pPresent = dynamic_cast(VISU::GetServant(aMesh)); -#ifdef CHECKTIME - OSD_Timer timer; - timer.Start(); -#endif - VISU_Actor *anActor = pPresent->CreateActor(); - if (! anActor ) return; #ifdef CHECKTIME timer.Stop(); - MESSAGE("Check time on VisuGUI::CreateMesh - pPresent->CreateActor"); + MESSAGE("VisuGUI::CreateMesh() - CREATE MESH"); timer.Show(); #endif + + QApplication::restoreOverrideCursor(); + VISU::Mesh_i* pPresent = NULL; + if(!CORBA::is_nil(aMesh)) + pPresent = dynamic_cast(VISU::GetServant(aMesh)); + if (pPresent == NULL) { + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), + tr ("ERR_CANT_BUILD_PRESENTATION"), + tr ("VISU_BUT_OK") ); + return; + } + if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){ - //vtkRenderer *aRenderer = vf->getRenderer(); - //visuGUI->ClearViewer(QAD_Application::getDesktop(), aRenderer, -1); - //visuGUI->ShowTrihedron(true); + VISU_Actor *anActor = pPresent->CreateActor(); + if (! anActor ) { + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), + tr ("ERR_CANT_CREATE_ACTOR"), + tr ("VISU_BUT_OK") ); + return; + } #ifdef CHECKTIME - OSD_Timer timer; + Utils_Timer timer; timer.Start(); #endif vf->AddActor(anActor); - vf->AddActor(anActor->EdgeDevice); - // vf->getRenderer()->AddActor(anActor->EdgeDevice); vf->getRenderer()->ResetCameraClippingRange(); vf->onViewFitAll(); #ifdef CHECKTIME timer.Stop(); - MESSAGE("Check time on VisuGUI::CreateMesh - vf->AddActor + vf->onViewFitAll"); + MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH"); timer.Show(); #endif } - //myActiveStudy->updateObjBrowser(); //not necessary - myDesktop->putInfo("Ready"); + //GetActiveStudy()->updateObjBrowser(); //not necessary + GetDesktop()->putInfo("Ready"); } +//===================================================================================== +// function : CreateManyMesh() +// purpose : +//===================================================================================== +void VisuGUI::CreateManyMesh() +{ + if (checkLock(GetStudyDocument())) return; + + SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection()); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + for ( ; It.More(); It.Next() ) { + SALOMEDS::SObject_var aSObject = GetActiveStudy()->getStudyDocument()->FindObjectID( It.Value()->getEntry() ); + + SALOMEDS::SObject_var aSObj = aSObject->GetFather(); + aSObj = aSObj->GetFather(); + aSObj = aSObj->GetFather(); + CORBA::Object_var anObject = VISU::SObjectToObject(aSObj); + if(CORBA::is_nil(anObject)) { + aSObj = aSObj->GetFather(); + anObject = VISU::SObjectToObject(aSObj); + if(CORBA::is_nil(anObject)) return; + } + VISU::Result_var aResult = VISU::Result::_narrow(anObject); + if(CORBA::is_nil(aResult)) return; + + VISU::Storable::TRestoringMap aMap; + SALOMEDS::GenericAttribute_var anAttr; + if(aSObject->FindAttribute(anAttr, "AttributeComment")) { + SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr); + string aComm = aComment->Value(); + QString strIn(aComm.c_str()); + VISU::Storable::StrToMap(strIn,aMap); + } + bool isExist; + string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1(); + if(!isExist) return; + CORBA::Object_var aMesh; + string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1(); + if(aComment == "ENTITY"){ + VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt(); + aMesh = GetVisuGen()->MeshOnEntity(aResult,aMeshName.c_str(),anEntity); + }else if(aComment == "FAMILY"){ + VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt(); + string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1(); + aMesh = GetVisuGen()->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str()); + }else if(aComment == "GROUP"){ + string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1(); + aMesh = GetVisuGen()->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str()); + } + QApplication::restoreOverrideCursor(); + if(CORBA::is_nil(aMesh)) return; + + VISU::Mesh_i* pPresent = dynamic_cast(VISU::GetServant(aMesh)); + VISU_Actor *anActor = pPresent->CreateActor(); + if (! anActor ) return; + if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){ + vf->AddActor(anActor); + vf->getRenderer()->ResetCameraClippingRange(); + vf->onViewFitAll(); + } + } + GetDesktop()->putInfo("Ready"); +} //===================================================================================== // function : ChangeRepresentation() // purpose : //===================================================================================== -static void ShrinkMesh(VISU_Actor *Actor){ - if (!(Actor->IsShrunk)){ - vtkDataSetMapper *mapper = (vtkDataSetMapper*) (Actor->GetMapper()); - vtkShrinkFilter *shrink = vtkShrinkFilter::New(); - shrink->SetInput(mapper->GetInput()); - shrink->SetShrinkFactor(0.8); - mapper->SetInput(shrink->GetOutput()); - Actor->IsShrunk = true; - shrink->Delete(); - Actor->EdgeDevice->VisibilityOff(); - }else{ - vtkDataSetMapper* aMapper = vtkDataSetMapper::SafeDownCast(Actor->GetInitialMapper()); - if (aMapper) { - vtkTransformPolyDataFilter *aTransformFilter = vtkTransformPolyDataFilter::New(); - aTransformFilter->SetInput(aMapper->GetPolyDataMapper()->GetInput()); - aTransformFilter->SetTransform (VisuGUI::GetVtkViewFrame()->getNonIsometricTransform()); - - //create new mapper - aMapper = vtkDataSetMapper::New(); - aMapper->SetInput (aTransformFilter->GetOutput()); - aMapper->ShallowCopy ( Actor->GetMapper()); - Actor->SetMapper (aMapper); - - aTransformFilter->Delete(); - aMapper->Delete(); - } else { - vtkDataSetMapper *mapper = (vtkDataSetMapper*) (Actor->GetMapper()); - mapper->SetInput(Actor->DataSource); - } - //Actor->GetMapper()->Update(); - Actor->IsShrunk = false; - if ( Actor->GetProperty()->GetRepresentation() == 2 ) - Actor->EdgeDevice->VisibilityOn(); - } +static void ShrinkMesh(VISU_Actor *theActor){ + if(theActor->isShrunk()) + theActor->unShrink(); + else + theActor->setShrink(0.8); } void VisuGUI::ChangeRepresentation(RepresentType theType) { - VISU::Prs3d_i* aPrsObject = GetSelectedPrs(); - if(!aPrsObject) return; - -#ifdef CHECKTIME - OSD_Timer timer; - timer.Start(); -#endif - VISU_Actor* anActor = GetActor(aPrsObject); - if (!anActor) return; - switch (theType) { - case POINTS: - anActor->EdgeDevice->VisibilityOff(); - anActor->GetProperty()->SetRepresentation(0); - anActor->GetProperty()->SetPointSize(VISU_POINT_SIZE); - break; - case WIREFRAME: - anActor->EdgeDevice->VisibilityOff(); - anActor->GetProperty()->SetRepresentation(1); - break; - case SURFACE: - if ( !anActor->IsShrunk ) - anActor->EdgeDevice->VisibilityOn(); - anActor->GetProperty()->SetRepresentation(2); - break; - case SHRINK: - ShrinkMesh(anActor); - break; + if(VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d()){ + if(VISU_Actor* anActor = GetActor(aPrsObject)){ + switch (theType) { + case POINTS: + case WIREFRAME: + case SURFACE: + anActor->SetRepresentation(theType); + break; + case SHRINK: + ShrinkMesh(anActor); + break; + } + if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) + vf->Repaint(); + } } - VTKViewer_ViewFrame* vf = GetVtkViewFrame(); - if (vf) - vf->Repaint(); -#ifdef CHECKTIME - timer.Stop(); - MESSAGE("Cheking time in VisuGUI::ChangeRepresentation - anActor->GetProperty()->SetRepresentation + vf->Repaint"); - timer.Show(); -#endif } void VisuGUI::MakeWireframe() { @@ -1748,15 +1349,14 @@ void VisuGUI::MakeShrink() { // functions : Change Propertise // purpose : //===================================================================================== -VISU::Prs3d_i* VisuGUI::GetSelectedPrs() { - string aComment; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj(aComment, anIO, myActiveStudy); +VISU::Prs3d_i* VisuGUI::GetSelectedPrs3d(Handle(SALOME_InteractiveObject)* theIO) { + CORBA::Object_var anObject = GetSelectedObj(theIO); + if(CORBA::is_nil(anObject)) return NULL; return dynamic_cast(VISU::GetServant(anObject)); } void VisuGUI::ChageColor() { - VISU::Prs3d_i* aPrsObject = GetSelectedPrs(); + VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d(); if(!aPrsObject) return; VISU_Actor* anActor = GetActor(aPrsObject); @@ -1765,17 +1365,17 @@ void VisuGUI::ChageColor() { } void VisuGUI::ChangeOutlineColor() { - VISU::Prs3d_i* aPrsObject = GetSelectedPrs(); + VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d(); if(!aPrsObject) return; - VISU_Actor* anActor = GetActor(aPrsObject); + VISUMesh_Actor* anActor = dynamic_cast(GetActor(aPrsObject)); if (!anActor) return; NewOutlineColor(anActor); } void VisuGUI::ChangeOpacity() { - VISU::Prs3d_i* aPrsObject = GetSelectedPrs(); + VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d(); if(!aPrsObject) return; VISU_Actor* anActor = GetActor(aPrsObject); @@ -1785,7 +1385,7 @@ void VisuGUI::ChangeOpacity() { void VisuGUI::ChangeLines() { - VISU::Prs3d_i* aPrsObject = GetSelectedPrs(); + VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d(); if(!aPrsObject) return; VISU_Actor* anActor = GetActor(aPrsObject); @@ -1795,15 +1395,15 @@ void VisuGUI::ChangeLines() { void VisuGUI::PlotTable( VISU::Table_i* table, int theDisplaying ) { VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - if ( table && visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { - Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame(); + if ( table && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { + Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame(); if ( theDisplaying == VISU::eDisplayOnly ) aPlot->EraseAll(); QList clist; aPlot->getCurves( clist ); - SALOMEDS::SObject_var TableSO = visuGUI->myActiveStudy->getStudyDocument()->FindObjectID( table->GetEntry() ); + SALOMEDS::SObject_var TableSO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetEntry() ); if ( !TableSO->_is_nil() ) { - SALOMEDS::ChildIterator_var Iter = visuGUI->myActiveStudy->getStudyDocument()->NewChildIterator( TableSO ); + SALOMEDS::ChildIterator_var Iter = GetActiveStudy()->getStudyDocument()->NewChildIterator( TableSO ); for ( ; Iter->More(); Iter->Next() ) { CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() ); if( !CORBA::is_nil( childObject ) ) { @@ -1842,8 +1442,16 @@ void VisuGUI::PlotTable( VISU::Table_i* table, int theDisplaying ) } else { Plot2d_Curve* crv = theCurve->CreatePresentation(); - if ( crv ) + if ( crv ) { aPlot->displayCurve( crv, false ); + theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() ); + theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker()); + SALOMEDS::Color newColor; + newColor.R = crv->getColor().red()/255.; + newColor.G = crv->getColor().green()/255.; + newColor.B = crv->getColor().blue()/255.; + theCurve->SetColor( newColor ); + } } } } @@ -1856,8 +1464,8 @@ void VisuGUI::PlotTable( VISU::Table_i* table, int theDisplaying ) void VisuGUI::PlotCurve( VISU::Curve_i* theCurve, int theDisplaying ) { VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - if ( theCurve && visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { - Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame(); + if ( theCurve && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { + Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame(); // if ( theDisplaying == VISU::eDisplayOnly ) // aPlot->EraseAll(); QList clist; @@ -1896,6 +1504,13 @@ void VisuGUI::PlotCurve( VISU::Curve_i* theCurve, int theDisplaying ) Plot2d_Curve* crv = theCurve->CreatePresentation(); if ( crv ) { aPlot->displayCurve( crv, false ); + theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() ); + theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker()); + SALOMEDS::Color newColor; + newColor.R = crv->getColor().red()/255.; + newColor.G = crv->getColor().green()/255.; + newColor.B = crv->getColor().blue()/255.; + theCurve->SetColor( newColor ); } } } @@ -1905,8 +1520,8 @@ void VisuGUI::PlotCurve( VISU::Curve_i* theCurve, int theDisplaying ) void VisuGUI::PlotContainer( VISU::Container_i* container, int theDisplaying ) { VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - if ( container && visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { - Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame(); + if ( container && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { + Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame(); if ( theDisplaying == VISU::eDisplayOnly ) aPlot->EraseAll(); QList clist; @@ -1948,8 +1563,16 @@ void VisuGUI::PlotContainer( VISU::Container_i* container, int theDisplaying ) } else { Plot2d_Curve* crv = theCurve->CreatePresentation(); - if ( crv ) + if ( crv ) { aPlot->displayCurve( crv, false ); + theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() ); + theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker()); + SALOMEDS::Color newColor; + newColor.R = crv->getColor().red()/255.; + newColor.G = crv->getColor().green()/255.; + newColor.B = crv->getColor().blue()/255.; + theCurve->SetColor( newColor ); + } } } } @@ -1958,17 +1581,17 @@ void VisuGUI::PlotContainer( VISU::Container_i* container, int theDisplaying ) aPlot->Repaint(); } } + /*! Slot : opens Table view : for Table object or SObject with table attribute selected */ void VisuGUI::ShowTable() { VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); + SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); if( Sel->IObjectCount() !=1 ) return; - string aComment; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy ); + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj(&anIO); SALOMEDS::SObject_var SO; if ( !CORBA::is_nil( anObject ) ) { VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject); @@ -1977,13 +1600,13 @@ void VisuGUI::ShowTable() { if( !CORBA::is_nil( aTable ) ) { VISU::Table_i* table = dynamic_cast( VISU::GetServant( aTable ) ); if ( table ) { - SO = VisuGUI::myActiveStudy->getStudyDocument()->FindObjectID( table->GetObjectEntry() ); + SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() ); } } } } else { // possibly this is Table SObject - SO = VisuGUI::myActiveStudy->getStudyDocument()->FindObjectID( anIO->getEntry() ); + SO = GetActiveStudy()->getStudyDocument()->FindObjectID( anIO->getEntry() ); } SALOMEDS::GenericAttribute_var anAttr; if ( SO->_is_nil() || ( !SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) @@ -1991,20 +1614,49 @@ void VisuGUI::ShowTable() { return; SALOMEGUI_TableDlg* dlg = new SALOMEGUI_TableDlg( QAD_Application::getDesktop(), SO, - false ); + false, + //SAL2670 Orientation of show tables + SALOMEGUI_TableDlg::ttAuto, + Qt::Vertical ); dlg->show(); } + +/*! + Slot : opens Table view : for Table object or SObject with table attribute selected +*/ +void VisuGUI::CreateTable() { + VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); + SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); + if( aSel->IObjectCount() !=1 ) + return; + + Handle(SALOME_InteractiveObject) anIO = aSel->firstIObject(); + if (anIO->hasEntry()){ + SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument(); + SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry()); + 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" ) ){ + GetVisuGen()->CreateTable(aSObject->GetID()); + GetActiveStudy()->updateObjBrowser(); + } + } + } +} + /*! Opens dialog box for curves creation. Acts only for selected SObject with table attribute. */ void VisuGUI::PlotData() { VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); + SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); if( Sel->IObjectCount() !=1 ) return; - string aComment; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy ); + CORBA::Object_var anObject = GetSelectedObj(); SALOMEDS::SObject_var SO; if ( !CORBA::is_nil( anObject ) ) { VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject); @@ -2017,7 +1669,7 @@ void VisuGUI::PlotData() { SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeName_var aName; QString SOName; - SALOMEDS::SObject_var SO = VisuGUI::myActiveStudy->getStudyDocument()->FindObjectID( table->GetObjectEntry() ); + SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() ); if ( !SO->_is_nil() && ( SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) || SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) { // get name of SObject @@ -2027,19 +1679,19 @@ void VisuGUI::PlotData() { } Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() ); if ( dlg->exec() == QDialog::Accepted ) { - if ( !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) { + if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) { // if study is not locked - create new container, create curves // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type int horIndex; QValueList verIndices; dlg->getCurvesSource( horIndex, verIndices ); if ( horIndex >= 0 && verIndices.count() > 0 ) { - CORBA::Object_var aContainer = myComponent->CreateContainer(); + CORBA::Object_var aContainer = GetVisuGen()->CreateContainer(); if( !CORBA::is_nil( aContainer ) ) { VISU::Container_i* pContainer = dynamic_cast( VISU::GetServant( aContainer ) ); if ( pContainer ) { for ( int i = 0; i < verIndices.count(); i++ ) { - CORBA::Object_var aNewCurve = myComponent->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 ); + CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 ); if( !CORBA::is_nil( aNewCurve ) ) { VISU::Curve_i* pCrv = dynamic_cast( VISU::GetServant( aNewCurve ) ); if ( pCrv ) { @@ -2056,7 +1708,7 @@ void VisuGUI::PlotData() { } } } - VisuGUI::myActiveStudy->updateObjBrowser( true ); + GetActiveStudy()->updateObjBrowser( true ); PlotContainer( pContainer, VISU::eDisplay ); } } @@ -2067,9 +1719,9 @@ void VisuGUI::PlotData() { Plot2d_CurveContainer container; dlg->getCurves( container ); if ( !container.isEmpty() ) { - ((Plot2d_ViewFrame*)(visuGUI->myActiveStudy->getActiveStudyFrame()-> + ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()-> getRightFrame()->getViewFrame()))->displayCurves( container, true ); - ((Plot2d_ViewFrame*)(visuGUI->myActiveStudy->getActiveStudyFrame()-> + ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()-> getRightFrame()->getViewFrame()))->setTitle( SOName ); } } @@ -2087,7 +1739,7 @@ void VisuGUI::PlotData() { QString SOName; // check if Table SObject is selected - SALOMEDS::SObject_var SO = VisuGUI::myActiveStudy->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() ); + SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() ); if ( !SO->_is_nil() && ( SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) || SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) { // get name of SObject @@ -2097,22 +1749,22 @@ void VisuGUI::PlotData() { } Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() ); if ( dlg->exec() == QDialog::Accepted ) { - if ( !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) { + if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) { // if study is not locked - create new table and container objects, create curves // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type int horIndex; QValueList verIndices; dlg->getCurvesSource( horIndex, verIndices ); if ( horIndex >= 0 && verIndices.count() > 0 ) { - CORBA::Object_var aTable = myComponent->CreateTable( SO->GetID() ); - CORBA::Object_var aContainer = myComponent->CreateContainer(); + CORBA::Object_var aTable = GetVisuGen()->CreateTable( SO->GetID() ); + CORBA::Object_var aContainer = GetVisuGen()->CreateContainer(); if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) { VISU::Table_i* pTable = dynamic_cast( VISU::GetServant( aTable ) ); VISU::Container_i* pContainer = dynamic_cast( VISU::GetServant( aContainer ) ); if ( pContainer && pTable ) { for ( int i = 0; i < verIndices.count(); i++ ) { - CORBA::Object_var aNewCurve = myComponent->CreateCurve( pTable->_this(), horIndex+1, verIndices[i]+1 ); + CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( pTable->_this(), horIndex+1, verIndices[i]+1 ); if( !CORBA::is_nil( aNewCurve ) ) { VISU::Curve_i* pCrv = dynamic_cast( VISU::GetServant( aNewCurve ) ); if ( pCrv ) { @@ -2129,7 +1781,7 @@ void VisuGUI::PlotData() { } } } - VisuGUI::myActiveStudy->updateObjBrowser( true ); + GetActiveStudy()->updateObjBrowser( true ); PlotContainer( pContainer, VISU::eDisplay ); } } @@ -2137,13 +1789,13 @@ void VisuGUI::PlotData() { } else { // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type - if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { + if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { Plot2d_CurveContainer container; dlg->getCurves( container ); if ( !container.isEmpty() ) { - ((Plot2d_ViewFrame*)(visuGUI->myActiveStudy->getActiveStudyFrame()-> + ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()-> getRightFrame()->getViewFrame()))->displayCurves( container, true ); - ((Plot2d_ViewFrame*)(visuGUI->myActiveStudy->getActiveStudyFrame()-> + ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()-> getRightFrame()->getViewFrame()))->setTitle( SOName ); } } @@ -2158,12 +1810,10 @@ void VisuGUI::PlotData() { */ void VisuGUI::CurveProperties() { VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); + SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); if( Sel->IObjectCount() !=1 ) return; - string aComment; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy ); + CORBA::Object_var anObject = GetSelectedObj(); SALOMEDS::SObject_var SO; if (CORBA::is_nil( anObject )) return; @@ -2173,7 +1823,7 @@ void VisuGUI::CurveProperties() { CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject ); if( !CORBA::is_nil( aCurve ) ) { VISU::Curve_i* curve = dynamic_cast( VISU::GetServant( aCurve ) ); - if ( curve && !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) { + if ( curve && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) { SALOMEGUI_SetupCurveDlg* dlg = new SALOMEGUI_SetupCurveDlg( QAD_Application::getDesktop() ); dlg->setLine( (int)curve->GetLine(), curve->GetLineWidth() ); dlg->setMarker( (int)curve->GetMarker() ); @@ -2187,7 +1837,7 @@ void VisuGUI::CurveProperties() { newColor.G = dlg->getColor().green()/255.; newColor.B = dlg->getColor().blue()/255.; curve->SetColor( newColor ); - QList sfList = VisuGUI::myActiveStudy->getStudyFrames(); + QList sfList = GetActiveStudy()->getStudyFrames(); if ( sfList.count() > 0 ) { QListIterator it( sfList ); for ( ; it.current(); ++it ) { @@ -2218,13 +1868,11 @@ void VisuGUI::CurveProperties() { */ void VisuGUI::ClearContainer() { VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); + SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); if( Sel->IObjectCount() !=1 ) return; - - string aComment; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy ); + + CORBA::Object_var anObject = GetSelectedObj(); SALOMEDS::SObject_var SO; if (CORBA::is_nil( anObject )) return; @@ -2234,9 +1882,9 @@ void VisuGUI::ClearContainer() { CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject ); if( !CORBA::is_nil( aCnt ) ) { VISU::Container_i* container = dynamic_cast( VISU::GetServant( aCnt ) ); - if ( container && container->GetNbCurves() > 0 && !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) { + if ( container && container->GetNbCurves() > 0 && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) { container->Clear(); - VisuGUI::myActiveStudy->updateObjBrowser(); + GetActiveStudy()->updateObjBrowser(); } } } @@ -2244,76 +1892,63 @@ void VisuGUI::ClearContainer() { void VisuGUI::DeletePrs() { - DeletePresentation(GetSelectedPrs()); + DeletePresentation(GetSelectedPrs3d()); } + void VisuGUI::SaveViewParams() { - if (checkLock(myStudy)) return; + if (checkLock(GetStudyDocument())) return; VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); - if ( Sel->IObjectCount() > 1 || VisuGUI::myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) - return; - // getting view manager - CORBA::Object_var aVM = VisuGUI::myComponent->GetViewManager(); - if( CORBA::is_nil( aVM ) ) - return; - VISU::ViewManager_i* pVM = dynamic_cast( VISU::GetServant( aVM ) ); - if ( !pVM ) + SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); + if ( Sel->IObjectCount() > 1 || GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) return; - // getting current 3d view - CORBA::Object_var aView = pVM->GetCurrentView(); - if( CORBA::is_nil( aView ) ) - return; - VISU::View3D_i* pView = dynamic_cast( VISU::GetServant( aView ) ); - if ( !pView ) - return; - if ( Sel->IObjectCount() == 0 ) { - // Save view parameters by new name - pView->SaveViewParams( 0 ); - VisuGUI::myActiveStudy->updateObjBrowser( true ); - } - else { - // Try to save view parameters by selected object's name - string aComment; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy ); -// QString strIn( aComment.c_str() ); -// VISU::Storable::RestoringMapType aMap; -// VISU::Storable::StrToMap( strIn,aMap ); -// QString aCmt = VISU::Storable::FindValue( aMap, "myComment" ); - if (ObjectTypes.find( aComment.c_str() ) == 6 ) { - pView->SaveViewParams( anIO->getName() ); - VisuGUI::myActiveStudy->updateObjBrowser( true ); + VISU::ViewManager_var aVM = GetVisuGen()->GetViewManager(); + if(!CORBA::is_nil(aVM.in())){ + VISU::View_var aView = aVM->GetCurrentView(); + if(!CORBA::is_nil(aView.in())){ + VISU::View3D_var aView3D = VISU::View3D::_narrow(aView); + if(CORBA::is_nil(aView3D.in())) return; + if ( Sel->IObjectCount() == 0 ) { + // Save view parameters by new name + aView3D->SaveViewParams( 0 ); + GetActiveStudy()->updateObjBrowser( true ); + }else{ + bool isExist; + VISU::Storable::TRestoringMap aMap; + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap); + VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt(); + if(isExist && aType == VISU::TVIEW3D){ + aView3D->SaveViewParams( anIO->getName() ); + GetActiveStudy()->updateObjBrowser( true ); + } + } } } } + + void VisuGUI::RestoreViewParams() { VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); - if ( Sel->IObjectCount() > 1 || VisuGUI::myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) + SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); + if ( Sel->IObjectCount() > 1 || GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) return; - // getting view manager - CORBA::Object_var aVM = VisuGUI::myComponent->GetViewManager(); - if( CORBA::is_nil( aVM ) ) - return; - VISU::ViewManager_i* pVM = dynamic_cast( VISU::GetServant( aVM ) ); - if ( !pVM ) - return; - // getting current 3d view - CORBA::Object_var aView = pVM->GetCurrentView(); - if( CORBA::is_nil( aView ) ) - return; - VISU::View3D_i* pView = dynamic_cast( VISU::GetServant( aView ) ); - if ( !pView ) - return; - string aComment; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy ); - QString aCmt = aComment.c_str(); - if ( !aCmt.isEmpty() && ObjectTypes.find( aCmt ) == 6 ) { - pView->RestoreViewParams( anIO->getName() ); + VISU::ViewManager_var aVM = GetVisuGen()->GetViewManager(); + if(!CORBA::is_nil(aVM.in())){ + VISU::View_var aView = aVM->GetCurrentView(); + if(!CORBA::is_nil(aView.in())){ + VISU::View3D_var aView3D = VISU::View3D::_narrow(aView); + if(CORBA::is_nil(aView3D.in())) return; + bool isExist; + VISU::Storable::TRestoringMap aMap; + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap); + VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt(); + if(isExist && aType == VISU::TVIEW3D) + aView3D->RestoreViewParams( anIO->getName() ); + } } } @@ -2322,37 +1957,21 @@ void VisuGUI::RestoreViewParams() // purpose : //===================================================================================== void VisuGUI::DeleteViewParams() { - VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - SALOME_Selection* Sel = SALOME_Selection::Selection(VisuGUI::myActiveStudy->getSelection()); - if( Sel->IObjectCount() > 0 ) { - SALOME_ListIteratorOfListIO aSelectionIterator(Sel->StoredIObjects()); - for(;aSelectionIterator.More(); aSelectionIterator.Next()) { - Handle(SALOME_InteractiveObject) anIO = aSelectionIterator.Value(); - if (anIO->hasEntry()){ - SALOMEDS::SObject_var aSObject = MYStudyDocument->FindObjectID(anIO->getEntry()); - if(!aSObject->_is_nil()){ - SALOMEDS::GenericAttribute_var anAttr; - if (aSObject->FindAttribute(anAttr, "AttributeComment")) { - SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr); - int aType; - // possibly this is view params - QString strIn(aComment->Value()); - VISU::Storable::TRestoringMap aMap; - VISU::Storable::StrToMap( strIn, aMap ); - QString aCmt; - bool isExist; - aCmt = VISU::Storable::FindValue( aMap, "myComment", &isExist ); - if ( isExist ) aType = ObjectTypes.find( aCmt ); - if (aType == 6) { - MYStudyDocument->NewBuilder()->RemoveObject(aSObject); - Sel->RemoveIObject(anIO, 0); - } - } - } - } - } + bool isExist; + VISU::Storable::TRestoringMap aMap; + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap); + VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt(); + if(isExist && aType == VISU::TVIEW3D){ + SALOMEDS::Study_var aStudy = GetStudyDocument(); + SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry()); + aStudy->NewBuilder()->RemoveObject(aSObject); + + SALOME_Selection* aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection()); + aSel->RemoveIObject(anIO, 0); + + GetActiveStudy()->updateObjBrowser( true ); } - VisuGUI::myActiveStudy->updateObjBrowser( true ); } @@ -2361,9 +1980,12 @@ void VisuGUI::DeleteViewParams() { // purpose : //===================================================================================== void VisuGUI::Sweep() { - VISU::ScalarMap_i* aPrsObject = dynamic_cast(GetSelectedPrs()); + VISU::ScalarMap_i* aPrsObject = dynamic_cast(GetSelectedPrs3d()); if (!aPrsObject) return; + VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame(); + if(!vf) return; + int aTemp=100000; QString aTempoStr = QAD_CONFIG->getSetting("Visu:SweepTempo"); if ( !aTempoStr.isEmpty() ) @@ -2384,87 +2006,17 @@ void VisuGUI::Sweep() { if (!aActor->GetVisibility()) { aActor->VisibilityOn(); - if (aActor->HasScalarBar()) - aActor->getScalarBar()->VisibilityOn(); } - vtkDataSetMapper* aMapper = (vtkDataSetMapper*) aActor->GetMapper(); - VISU_LookupTable* aLookupTbl = (VISU_LookupTable*) aMapper->GetLookupTable(); QApplication::setOverrideCursor( Qt::waitCursor ); - - switch (aPrsObject->GetType()) { - case VISU::TCUTPLANES: // Cut planes 42 - case VISU::TSCALARMAP: // ScalarMap 18 - for (int j=0 ; jSetMapScale(float(i)/float(aSteps)); - RepaintCurrentView(); - usleep(aTemp); - } - } - break; - - case VISU::TDEFORMEDSHAPE: // Deformed Shape 28 - { - VISU::DeformedShape_i* aDefPrs = dynamic_cast(aPrsObject); - if (aDefPrs) { - float aScale = aDefPrs->GetScale(); - bool isColored = aDefPrs->isColored(); - vtkWarpVector* aWarp = vtkWarpVector::New(); - if((VISU::Entity)aDefPrs->GetField()->myEntity == VISU::CELL) { - vtkCellDataToPointData *aFilter = vtkCellDataToPointData::New(); - aFilter->SetInput(aDefPrs->GetInput()->GetUnstructuredGridOutput()); - aFilter->PassCellDataOn(); - aWarp->SetInput(aFilter->GetUnstructuredGridOutput()); - aFilter->Delete(); - } else - aWarp->SetInput(aDefPrs->GetInput()->GetUnstructuredGridOutput()); - for (int j=0 ; jSetScaleFactor(aScale*float(i)/float(aSteps)); - aMapper->SetInput(aWarp->GetOutput()); - - if (isColored) - aLookupTbl->SetMapScale(float(i)/float(aSteps)); - RepaintCurrentView(); - usleep(aTemp); - } - } - aWarp->Delete(); - } + for (int j=0 ; jSetMapScale(aPercents); + aPrsObject->UpdateActor(aActor); + vf->getRW()->getRenderWindow()->Render(); + usleep(aTemp); } - break; - - case VISU::TISOSURFACE: // Iso surfaces - { - VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast(aPrsObject); - if (aIsoPrs) { - int nbIso = aIsoPrs->GetNbSurfaces(); - if (nbIso <= 1) break; - vtkContourFilter* aContourFilter = vtkContourFilter::New(); - if ((VISU::Entity)aIsoPrs->GetField()->myEntity == VISU::CELL) { - vtkCellDataToPointData *aFilter = vtkCellDataToPointData::New(); - aFilter->SetInput(aIsoPrs->GetInput()->GetUnstructuredGridOutput()); - aFilter->PassCellDataOn(); - aContourFilter->SetInput(aFilter->GetOutput()); - aFilter->Delete(); - } else - aContourFilter->SetInput(aIsoPrs->GetInput()->GetUnstructuredGridOutput()); - float aMul; - for (int j=0 ; jSetMapScale(aMul); - aContourFilter->GenerateValues(nbIso*(i+1)/aSteps,aIsoPrs->GetRangeMin(),aIsoPrs->GetRangeMax()); - aMapper->SetInput(aContourFilter->GetOutput()); - RepaintCurrentView(); - usleep(aTemp); - } - } - aContourFilter->Delete(); - } - } - break; } QApplication::restoreOverrideCursor(); } @@ -2472,14 +2024,14 @@ void VisuGUI::Sweep() { void VisuGUI::TimeAnimation() { - VisuGUI_TimeAnimationDlg* aAnimationDlg = new VisuGUI_TimeAnimationDlg(myStudy); - SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); + VisuGUI_TimeAnimationDlg* aAnimationDlg = new VisuGUI_TimeAnimationDlg(GetStudyDocument()); + SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); bool isDefined = false; long aNbTimes = 0; SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); for (; It.More(); It.Next()) { - SALOMEDS::SObject_var aSObject = myStudy->FindObjectID( It.Value()->getEntry() ); + SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID( It.Value()->getEntry() ); if (aSObject->_is_nil()) continue; if (getValue(aSObject, "myComment") == QString("FIELD")) { long aNumber = getValue(aSObject, "myNbTimeStamps").toLong(); @@ -2499,62 +2051,59 @@ void VisuGUI::TimeAnimation() { } - void VisuGUI::ImportMedField() { - if (checkLock(myStudy)) return; - + if (checkLock(GetStudyDocument())) return; VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); + SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); QApplication::setOverrideCursor( Qt::waitCursor ); for(;It.More();It.Next()) { Handle(SALOME_InteractiveObject) anIO = It.Value(); - SALOMEDS::SObject_var aSObject = MYStudyDocument->FindObjectID(anIO->getEntry()); - if(!aSObject->_is_nil()){ - SALOMEDS::GenericAttribute_var anAttr; - aSObject->FindAttribute(anAttr, "AttributeIOR"); - if(!anAttr->_is_nil()){ - SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - if(!anIOR->_is_nil()){ - CORBA::String_var aValue = anIOR->Value(); - if(strcmp(aValue,"") != 0){ - CORBA::ORB_ptr anORB = VISU::Base_i::GetORB(); - CORBA::Object_var anObject = anORB->string_to_object(aValue); - if ( !CORBA::is_nil( anObject ) ) { - //SALOME_MED::FIELD_ptr aField = SALOME_MED::FIELD::_narrow( anObject ); - SALOME_MED::MED_ptr aMED = SALOME_MED::MED::_narrow( anObject ); - if( !CORBA::is_nil( aMED ) ) { - VisuGUI::myComponent->ImportMed( aSObject ); - continue; - } - } - } - } + SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry()); + if(!aSObject->_is_nil()){ + CORBA::Object_var anObject = VISU::SObjectToObject(aSObject); + if(!CORBA::is_nil(anObject)){ + SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow( anObject ); + if(!CORBA::is_nil(aMED.in())) + GetVisuGen()->ImportMed( aSObject ); + SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject ); + if(!CORBA::is_nil(aField.in())) + GetVisuGen()->ImportMedField( aField ); + }else{ + SALOMEDS::SObject_var aSFather = aSObject->GetFather(); + SALOMEDS::GenericAttribute_var anAttr; + aSFather->FindAttribute(anAttr, "AttributeName"); + SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); + CORBA::String_var aValue = aName->Value(); + if(strcmp(aValue.in(),"MEDFIELD") == 0) + GetVisuGen()->ImportMed(aSObject); + //if(strcmp(aValue.in(),"MEDMESH") == 0) + // VisuGUI::myComponent->ImportMed(aSObject); } } } - VisuGUI::myActiveStudy->updateObjBrowser( true ); + GetActiveStudy()->updateObjBrowser( true ); QApplication::restoreOverrideCursor(); } /* void VisuGUI::ImportMedMesh() { VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); + SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); if ( Sel->IObjectCount() != 1 ) return; string aComment; Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj( aComment,anIO, VisuGUI::myActiveStudy); + CORBA::Object_var anObject = GetSelectedObj( aComment,anIO, GetActiveStudy()); if ( !CORBA::is_nil( anObject ) ) { SALOME_MED::MESH_ptr aMesh = SALOME_MED::MESH::_narrow( anObject ); if( !CORBA::is_nil( aMesh ) ) { - VisuGUI::myComponent->ImportMedMesh( aMesh ); - VisuGUI::myActiveStudy->updateObjBrowser( true ); + GetVisuGen->ImportMedMesh( aMesh ); + GetActiveStudy()->updateObjBrowser( true ); } SALOME_MED::SUPPORT_ptr aSupport = SALOME_MED::SUPPORT::_narrow( anObject ); if( !CORBA::is_nil( aSupport ) ) { - VisuGUI::myComponent->ImportMedSupport( aSupport ); - VisuGUI::myActiveStudy->updateObjBrowser( true ); + GetVisuGen->ImportMedSupport( aSupport ); + GetActiveStudy()->updateObjBrowser( true ); } } } @@ -2564,14 +2113,27 @@ void VisuGUI::ImportMedMesh() { // purpose : //===================================================================================== void VisuGUI::Rename() { - if (checkLock(myStudy)) return; + if (checkLock(GetStudyDocument())) return; VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); + SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); if ( Sel->IObjectCount() != 1 ) return; - SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( Sel->firstIObject()->getEntry() ); + SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() ); if( aSObj->_is_nil() ) return; + VISU::Curve_i* curve = 0; + CORBA::Object_var anObject = GetSelectedObj(); + if ( !CORBA::is_nil( anObject )) { + VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject); + if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) { + // Curve object + CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject ); + if( !CORBA::is_nil( aCurve ) ) { + curve = dynamic_cast( VISU::GetServant( aCurve ) ); + } + } + } + //TEST DU PARENT == VISU SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeName_var aName; @@ -2580,7 +2142,9 @@ void VisuGUI::Rename() { QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() ); if ( !Name.isEmpty() ) { QApplication::setOverrideCursor( Qt::waitCursor ); - VisuGUI::myActiveStudy->renameIObject( Sel->firstIObject(), Name ); + if ( curve ) + curve->SetName( Name.latin1() ); + GetActiveStudy()->renameIObject( Sel->firstIObject(), Name ); QApplication::restoreOverrideCursor(); //int TypeMode; bool InViewer; @@ -2596,8 +2160,8 @@ void VisuGUI::Rename() { // purpose : //===================================================================================== void VisuGUI::CopyPresentation(){ - if (checkLock(myStudy)) return; - VISU::Prs3d_i* aPrsObject = GetSelectedPrs(); + if (checkLock(GetStudyDocument())) return; + VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d(); if (!aPrsObject) return; switch (aPrsObject->GetType()) { case VISU::TMESH: @@ -2605,7 +2169,7 @@ void VisuGUI::CopyPresentation(){ VISU::Mesh_i* aMeshPrs = dynamic_cast(aPrsObject); VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult()); aSameMesh->SameAs(aMeshPrs); - UpdateViewer(aSameMesh, true); + UpdateViewer(aSameMesh); } break; case VISU::TSCALARMAP: @@ -2613,7 +2177,7 @@ void VisuGUI::CopyPresentation(){ VISU::ScalarMap_i* aScalarPrs = dynamic_cast(aPrsObject); VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult()); aSameScalar->SameAs(aScalarPrs); - UpdateViewer(aSameScalar, true); + UpdateViewer(aSameScalar); } break; case VISU::TDEFORMEDSHAPE: @@ -2621,7 +2185,7 @@ void VisuGUI::CopyPresentation(){ VISU::DeformedShape_i* aDefPrs = dynamic_cast(aPrsObject); VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult()); aSameDeformed->SameAs(aDefPrs); - UpdateViewer(aSameDeformed, true); + UpdateViewer(aSameDeformed); } break; case VISU::TCUTPLANES: @@ -2629,15 +2193,23 @@ void VisuGUI::CopyPresentation(){ VISU::CutPlanes_i* aCutPrs = dynamic_cast(aPrsObject); VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult()); aSameCut->SameAs(aCutPrs); - UpdateViewer(aSameCut, true); + UpdateViewer(aSameCut); + } + break; + case VISU::TCUTLINES: + { + VISU::CutLines_i* aCutPrs = dynamic_cast(aPrsObject); + VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult()); + aSameCut->SameAs(aCutPrs); + UpdateViewer(aSameCut); } break; - case VISU::TISOSURFACE: + case VISU::TISOSURFACE: { VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast(aPrsObject); VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult()); aSameIso->SameAs(aIsoPrs); - UpdateViewer(aSameIso, true); + UpdateViewer(aSameIso); } break; case VISU::TSTREAMLINES: @@ -2645,7 +2217,7 @@ void VisuGUI::CopyPresentation(){ VISU::StreamLines_i* aLinesPrs = dynamic_cast(aPrsObject); VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult()); aSameLines->SameAs(aLinesPrs); - UpdateViewer(aSameLines, true); + UpdateViewer(aSameLines); } break; case VISU::TVECTORS: @@ -2653,33 +2225,29 @@ void VisuGUI::CopyPresentation(){ VISU::Vectors_i* aVectorsPrs = dynamic_cast(aPrsObject); VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult()); aSameVectors->SameAs(aVectorsPrs); - UpdateViewer(aSameVectors, true); + UpdateViewer(aSameVectors); } break; } - myActiveStudy->updateObjBrowser(); + GetActiveStudy()->updateObjBrowser(); } //===================================================================================== // function : InfoOnPoint() [ slot ] // purpose : //===================================================================================== -void VisuGUI::InfoOnPoint() -{ - VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop()); - if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) - return; - int TypeMode; - VISU_Actor* ActorTmp = ActorSelected( visuGUI->myDesktop, true, &TypeMode ); - if ( !ActorTmp ) - return; - - if ( TypeMode == SelectionPoint ) - Selection->PickingResults( visuGUI->myActiveStudy, TypeMode, ActorTmp ); - else - QAD_MessageBox::warn1( visuGUI->myDesktop, +void VisuGUI::InfoOnPoint(){ + SALOME_Selection *aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection()); + int aTypeMode = aSel->SelectionMode(); + if ( aTypeMode == SelectionPoint ){ + if(VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d()){ + vtkDataSet* aDataSet = aPrs3d->GetMapper()->GetInput(); + VisuGUI_Selection::PickingPoint( GetActiveStudy(), aDataSet); + } + }else + QAD_MessageBox::warn1( GetDesktop(), tr ("WARNING"), - tr ("Not Point selection mode"), + tr ("ERR_WRONG_SELECTION_MODE"), tr ("VISU_BUT_OK") ); } @@ -2687,22 +2255,18 @@ void VisuGUI::InfoOnPoint() // function : InfoOnCell() [ slot ] // purpose : //===================================================================================== -void VisuGUI::InfoOnCell() -{ - VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop()); - if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) - return; - int TypeMode; - VISU_Actor* ActorTmp = ActorSelected( visuGUI->myDesktop, true, &TypeMode ); - if ( !ActorTmp ) - return; - - if ( TypeMode == SelectionCell || TypeMode == SelectionEdge ) - Selection->PickingResults( visuGUI->myActiveStudy, TypeMode, ActorTmp ); - else - QAD_MessageBox::warn1( visuGUI->myDesktop, +void VisuGUI::InfoOnCell(){ + SALOME_Selection *aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection()); + int aTypeMode = aSel->SelectionMode(); + if( aTypeMode == SelectionCell){ + if(VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d()){ + vtkDataSet* aDataSet = aPrs3d->GetMapper()->GetInput(); + VisuGUI_Selection::PickingCell( GetActiveStudy(), aDataSet); + } + }else + QAD_MessageBox::warn1( GetDesktop(), tr ("WARNING"), - tr ("Not Cell/Edge selection mode"), + tr ("ERR_WRONG_SELECTION_MODE"), tr ("VISU_BUT_OK") ); } @@ -2710,91 +2274,56 @@ void VisuGUI::InfoOnCell() // function : SelectPoint() [ slot ] // purpose : //===================================================================================== -void VisuGUI::SelectPoint() -{ - VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop()); - if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) - return; - vtkRenderer* theRenderer = GetRenderer( visuGUI->myActiveStudy ); - int TypeMode; - VISU_Actor* ActorTmp = ActorSelected( visuGUI->myDesktop, true, &TypeMode ); - if ( !ActorTmp ) - return; - if ( TypeMode != SelectionPoint ) { - QAD_MessageBox::warn1( visuGUI->myDesktop, +void VisuGUI::SelectPoint(){ + SALOME_Selection *aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection()); + if ( aSel->SelectionMode() != SelectionPoint ) { + QAD_MessageBox::warn1( GetDesktop(), tr ("WARNING"), - tr ("Not Point selection mode"), + tr ("ERR_WRONG_SELECTION_MODE"), tr ("VISU_BUT_OK") ); return; } - - bool ok = FALSE; - vtkDataSetMapper* Mapper = (vtkDataSetMapper*) (ActorTmp->GetMapper()); - Mapper->SetInput(ActorTmp->DataSource); - vtkDataSet *Data=Mapper->GetInput(); - int nbPoints=Data->GetNumberOfPoints(); - int selectedPoint = SALOMEGUI_SetValueDlg::getInteger( tr("Point selection"), - tr("Point number:" ), - 0, - &ok, - visuGUI->myDesktop ); - if ( ok && theRenderer && selectedPoint > 0 && selectedPoint <= nbPoints ) - Selection->HighlightPoint( selectedPoint, nbPoints, ActorTmp, theRenderer ); + Handle(SALOME_InteractiveObject) anIO; + if(VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d(&anIO)){ + bool ok = FALSE; + int anId = SALOMEGUI_SetValueDlg::getInteger( tr("Point selection"), + tr("Point number:" ), + 0, + &ok, + GetDesktop()); + vtkDataSet *aDataSet = aPrs3d->GetMapper()->GetInput(); + int aMaxId = aDataSet->GetNumberOfPoints(); + if (ok && 0 < anId && anId <= aMaxId ) + VisuGUI_Selection::Highlight( GetActiveStudy(), anIO, anId ); + } } //===================================================================================== // function : SelectCell() [ slot ] // purpose : //===================================================================================== -void VisuGUI::SelectCell() -{ - VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop()); - SALOME_Selection* Sel = SALOME_Selection::Selection(visuGUI->myActiveStudy->getSelection()); - if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) - return; - vtkRenderer* theRenderer = GetRenderer( visuGUI->myActiveStudy ); - int TypeMode=Sel->SelectionMode(); - if ( TypeMode != SelectionCell && TypeMode != SelectionEdge ) { - QAD_MessageBox::warn1( visuGUI->myDesktop, +void VisuGUI::SelectCell(){ + SALOME_Selection *aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection()); + if ( aSel->SelectionMode() != SelectionCell) { + QAD_MessageBox::warn1( GetDesktop(), tr ("WARNING"), - tr ("Not Cell/Edge selection mode"), + tr ("ERR_WRONG_SELECTION_MODE"), tr ("VISU_BUT_OK") ); return; } - VISU_Actor* ActorTmp; - string aComment; Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj(aComment,anIO,visuGUI->myActiveStudy); - //srn: Added check if anObject is Null, then break -// if(CORBA::is_nil(anObject)) break; - - VISU::Prs3d_i* aPrsObject = NULL; - if(!CORBA::is_nil(anObject)) - aPrsObject = dynamic_cast(VISU::GetServant(anObject)); - if(aPrsObject){ - //aPrsObject->SetIO(anIO); - //ActorTmp = aPrsObject->GetActor(); - //UpdateViewer(ActorTmp); - ActorTmp = visuGUI->UpdateViewer(aPrsObject); - } else { - ActorTmp = ActorSelected(visuGUI->myDesktop,true,&TypeMode); + if(VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d(&anIO)){ + bool ok = FALSE; + int anId = SALOMEGUI_SetValueDlg::getInteger( tr("Cell selection"), + tr("Cell number:" ), + 0, + &ok, + GetDesktop()); + vtkDataSet *aDataSet = aPrs3d->GetMapper()->GetInput(); + int aMaxId = aDataSet->GetNumberOfCells(); + if (ok && 0 < anId && anId <= aMaxId ) + VisuGUI_Selection::Highlight( GetActiveStudy(), anIO, anId ); } - if (ActorTmp==NULL) - return; - - bool ok=FALSE; - vtkDataSetMapper *Mapper = (vtkDataSetMapper*) (ActorTmp->GetMapper()); - Mapper->SetInput(ActorTmp->DataSource); - vtkDataSet *Data=Mapper->GetInput(); - int nbCells=Data->GetNumberOfCells(); - int selectedCell = SALOMEGUI_SetValueDlg::getInteger( tr("Cell selection"), - tr("Cell number:" ), - 0, - &ok, - visuGUI->myDesktop ); - if ( ok && theRenderer && selectedCell > 0 && selectedCell <= nbCells ) - if (ok && theRenderer ) - Selection->HighlightCell(selectedCell , ActorTmp , theRenderer); } //===================================================================================== @@ -2809,6 +2338,109 @@ void VisuGUI::DefinePopup( QString & theContext, QString & theParent, QString & } +//===================================================================================== +// function : checkHomoSelection() +// purpose : +//===================================================================================== +enum { homoNone=0, homoCurves, homoPresentations, homoPresentable, homoAnimatable, homoOther }; +int VisuGUI::checkHomoSelection() +{ + int selMode = homoNone; + SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection()); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + for ( ; It.More(); It.Next() ) { + int selNext = homoOther; + Handle(SALOME_InteractiveObject)& anIO = It.Value(); + if ( anIO->hasEntry() ) { + SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument(); + SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() ); + VISU::Storable::TRestoringMap pMap; + if( !aSObject->_is_nil() ) { + CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject); + if ( !CORBA::is_nil( aCORBAObject ) ) { + VISU::Base_var aVisuObj = VISU::Base::_narrow( aCORBAObject ); + if ( !CORBA::is_nil( aVisuObj ) ) { + VISU::VISUType aType = aVisuObj->GetType(); + switch( aType ) { + case VISU::TTABLE: + case VISU::TCURVE: + case VISU::TCONTAINER: + selNext = homoCurves; break; + case VISU::TMESH: + case VISU::TSCALARMAP: + case VISU::TISOSURFACE: + case VISU::TDEFORMEDSHAPE: + case VISU::TCUTPLANES: + case VISU::TCUTLINES: + case VISU::TVECTORS: + case VISU::TSTREAMLINES: + selNext = homoPresentations; break; + case VISU::TFIELD: + if (getValue(aSObject, "myNbTimeStamps").toLong() > 1) { + selNext = homoAnimatable; break; + } + selNext = homoOther; break; + default: + selNext = homoOther; + } + } + } + else { + SALOMEDS::GenericAttribute_var anAttr; + if ( aSObject->FindAttribute( anAttr, "AttributeComment") ) { + SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow( anAttr ); + string aComm = aComment->Value(); + QString strIn( aComm.c_str() ); + VISU::Storable::StrToMap( strIn, pMap ); + bool isExist; + VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt(); + if( isExist ) { + switch ( aType ) { + case VISU::TENTITY: + case VISU::TFAMILY: + case VISU::TGROUP: + selNext = homoPresentable; break; + case VISU::TFIELD: + if (getValue(aSObject, "myNbTimeStamps").toLong() > 1) { + selNext = homoAnimatable; break; + } + selNext = homoOther; break; + default: + selNext = homoOther; + } + } + } + } + } + } + if ( selMode == homoNone ) + selMode = selNext; + else { + if ( selMode != selNext ) + return homoNone; + } + } + return selMode; +} + +//===================================================================================== +// function : GetNbChildren() [ static ] +// purpose : get number of children +//===================================================================================== +int GetNbChildren( SALOMEDS::SObject_var SO, bool refToo ) +{ + if ( SO->_is_nil() ) + return 0; + int cnt = 0; + SALOMEDS::ChildIterator_var Iter = SO->GetStudy()->NewChildIterator( SO ); + for ( ; Iter->More(); Iter->Next() ) { + SALOMEDS::SObject_var refSO; + if ( !Iter->Value()->ReferencedObject( refSO ) || refToo ) + cnt++; + } + return cnt; +} + //===================================================================================== // function : CustomPopup() // purpose : @@ -2820,10 +2452,10 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri VisuGUI::GetOrCreateVisuGUI(parent); QAD_ResourceMgr* rmgr = parent->createResourceManager(); - bool isVTKViewer = (visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK); + bool isVTKViewer = (GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK); thePopup->clear(); - SALOME_Selection* Sel = SALOME_Selection::Selection(VisuGUI::myActiveStudy->getSelection()); + SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection()); if ( Sel->IObjectCount() == 0 ) { if ( theParent == "Viewer" && isVTKViewer) // Available only for VTK viewer @@ -2831,19 +2463,37 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri return false; } + if( Sel->IObjectCount() > 1 ) { + int selMode = checkHomoSelection(); + MESSAGE( "VisuGUI::CustomPopup: multiple selection : selMode = "<getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { + thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) ); + thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) ); + } + } + else if ( selMode == homoPresentations ) { + if (isVTKViewer) { + thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) ); + thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) ); + } + } + else if ( selMode == homoPresentable ) { + thePopup->insertItem("Create Presentations", visuGUI, SLOT(CreateManyMesh())); + } + else if ( selMode == homoAnimatable ) { + thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) ); + } + return true; + } + VISU::Storable::TRestoringMap aMap; Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj(VisuGUI::myActiveStudy,&anIO,&aMap); - bool isExist; - string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1(); - if(!isExist) aComment = "NONE"; - SALOMEDS::GenericAttribute_var anAttr; - + CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap); if (!CORBA::is_nil(anObject)) { + SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry()); VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject); if (!CORBA::is_nil(aVisuObj)) { - if( Sel->IObjectCount() > 1) return false; - VISU::VISUType aType = aVisuObj->GetType(); MESSAGE("VisuGUI::CustomPopup - VISU object :: "<insertItem( "Show Table", visuGUI, SLOT( ShowTable() ) ); thePopup->insertItem( "Create Curves", visuGUI, SLOT( PlotData() ) ); - if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { - thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) ); - thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) ); - thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) ); + if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { + if ( GetNbChildren( aSObject, false ) > 0 ) { + thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) ); + thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) ); + thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) ); + } } break; case VISU::TCURVE: - if ( !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) + if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) { thePopup->insertItem( "Properties", visuGUI, SLOT( CurveProperties() ) ); - if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { - if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->isVisible( anIO ) ) + thePopup->insertItem( "Rename...", visuGUI, SLOT(Rename())); + } + if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { + if ( GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame()->isVisible( anIO ) ) thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) ); else thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) ); @@ -2885,9 +2539,9 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri if( !CORBA::is_nil( aCnt ) ) { VISU::Container_i* container = dynamic_cast( VISU::GetServant( aCnt ) ); if ( container && container->GetNbCurves() > 0 ) { - if ( !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) + if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) thePopup->insertItem( "Clear", visuGUI, SLOT( ClearContainer() ) ); - if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { + if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) ); thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) ); thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) ); @@ -2905,12 +2559,24 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri if (isVTKViewer) { // Add Presentation menu if ((aType != VISU::TSTREAMLINES) && anVISUActor) { - QPopupMenu* aPresMenu = new QPopupMenu(VisuGUI::myDesktop); - aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe())); - aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface())); - aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints())); - if (anVISUActor->IsShrinkable) { - if (anVISUActor->IsShrunk) + QPopupMenu* aPresMenu = new QPopupMenu(GetDesktop()); + int aRepresent = anVISUActor->GetRepresentation(); + switch(aRepresent){ + case 0: //POINTS + aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe())); + aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface())); + break; + case 1: //WIREFRAME + aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface())); + aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints())); + break; + case 2: //SURFACE + aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe())); + aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints())); + break; + } + if (anVISUActor->GetShrinkable()) { + if (anVISUActor->isShrunk()) aPresMenu->insertItem("Unshrink", visuGUI, SLOT(MakeShrink())); else aPresMenu->insertItem("Shrink", visuGUI, SLOT(MakeShrink())); @@ -2919,11 +2585,11 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri } // Add Properties - QPopupMenu* aPropMenu = new QPopupMenu(VisuGUI::myDesktop); + QPopupMenu* aPropMenu = new QPopupMenu(GetDesktop()); if ((aType == VISU::TMESH) || (aType == VISU::TDEFORMEDSHAPE) || (aType == VISU::TVECTORS) || - (aType == VISU::TSTREAMLINES)) // Mesh, deformed shape, vectors + (aType == VISU::TSTREAMLINES)) aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor())); if (aType == VISU::TMESH) aPropMenu->insertItem("Outline Color", visuGUI, SLOT(ChangeOutlineColor())); @@ -2941,8 +2607,12 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri thePopup->insertItem("Edit...", visuGUI, SLOT(EditPrs())); thePopup->insertItem("Edit Scalar Bar...", visuGUI, SLOT(EditScalarBar())); - if ((aType != VISU::TVECTORS) && (aType != VISU::TSTREAMLINES) && isVTKViewer) + if ((aType != VISU::TVECTORS) && (aType != VISU::TSTREAMLINES) + && (aType != VISU::TCUTLINES) && isVTKViewer) thePopup->insertItem("Sweep", visuGUI, SLOT(Sweep())); + + if (aType == VISU::TCUTLINES) + thePopup->insertItem( "Create Table", visuGUI, SLOT( CreateTable() ) ); } if (isVTKViewer) { if ( theParent == "Viewer" && @@ -2954,23 +2624,24 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri thePopup->insertItem("Results at Point", visuGUI, SLOT(InfoOnPoint())); thePopup->insertItem("Select a Point", visuGUI, SLOT(SelectPoint())); } - else if ( Sel->SelectionMode() == SelectionCell || Sel->SelectionMode() == SelectionEdge ) { + else if ( Sel->SelectionMode() == SelectionCell) { thePopup->insertItem("Results on Cell", visuGUI, SLOT(InfoOnCell())); thePopup->insertItem("Select a Cell", visuGUI, SLOT(SelectCell())); } } thePopup->insertSeparator(); if (visuGUI->IsDisplayed(aPrsObject) ) - thePopup->insertItem("Hide", visuGUI, SLOT(ErasePrs())); + thePopup->insertItem("Erase", visuGUI, SLOT(ErasePrs())); else thePopup->insertItem("Display", visuGUI, SLOT(DisplayPrs())); thePopup->insertItem("Display Only", visuGUI, SLOT(DisplayOnlyPrs())); } - if (aType != VISU::TMESH) + if (aType != VISU::TMESH) { thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs())); - thePopup->insertSeparator(); - thePopup->insertItem("Same As", visuGUI, SLOT(CopyPresentation())); + thePopup->insertSeparator(); + thePopup->insertItem("Same As", visuGUI, SLOT(CopyPresentation())); + } } } } @@ -2979,92 +2650,80 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri else { // possibly this is the MED field/mesh and suppot objects SALOME_MED::MED_ptr aMED = SALOME_MED::MED::_narrow( anObject ); - if( !CORBA::is_nil( aMED ) ) { - thePopup->insertItem( "Import MED", visuGUI, SLOT( ImportMedField() ) ); - return false; - } - /*CORBA::Object_var anObj = SALOME_MED::FIELD::_narrow( anObject ); - if( !CORBA::is_nil( anObj ) ) { - thePopup->insertItem( "Import Field", visuGUI, SLOT( ImportMedField() ) ); - return false; - } - anObj = SALOME_MED::MESH::_narrow( anObject ); - if( !CORBA::is_nil( anObj ) ) { - thePopup->insertItem( "Import Mesh", visuGUI, SLOT( ImportMedField() ) ); - return false; - } - anObj = SALOME_MED::GROUP::_narrow( anObject ); - if( !CORBA::is_nil( anObj ) ) { - thePopup->insertItem( "Import Group", visuGUI, SLOT( ImportMedField() ) ); + if(!CORBA::is_nil(aMED)) + thePopup->insertItem( "Import Structure", visuGUI, SLOT( ImportMedField() ) ); + SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject ); + if(!CORBA::is_nil(aField)) + thePopup->insertItem( "Import TimeStamp", visuGUI, SLOT( ImportMedField() ) ); + return false; + } + }else{ + SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry()); + if(!aSObject->_is_nil()){ + bool isExist; + VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt(); + if(isExist){ + switch (aType) { + case VISU::TENTITY: + case VISU::TFAMILY: + case VISU::TGROUP: + thePopup->insertItem("Create Presentation", visuGUI, SLOT(CreateMesh())); + break; + case VISU::TVIEW3D: + if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + // Available only for VTK viewer + thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) ); + thePopup->insertItem( "Restore view parameters", visuGUI, SLOT( RestoreViewParams() ) ); + } + thePopup->insertItem( "Rename...", visuGUI, SLOT( Rename() ) ); + thePopup->insertItem("Delete", visuGUI, SLOT(DeleteViewParams())); + break; + case VISU::TFIELD: + if ((getValue(aSObject, "myNbTimeStamps").toLong() > 1) && isVTKViewer) + thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) ); + break; + case VISU::TTIMESTAMP: { + int aNunComponent = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist).toInt(); + thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_SCALAR_MAP") ), + "Scalar Map...", visuGUI, SLOT(CreateScalarMap())); + thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_ISO_SURFACES") ), + "Iso Surfaces...", visuGUI, SLOT(CreateIsoSurfaces())); + thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_CUT_PLANES") ), + "Cut Planes...", visuGUI, SLOT(CreateCutPlanes())); + thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_CUT_LINES") ), + "Cut Lines...", visuGUI, SLOT(CreateCutLines())); + if(aNunComponent > 1){ + thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_DEFORMED_SHAPE") ), + "Deformed Shape...", visuGUI, SLOT(CreateDeformedShape())); + thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_VECTORS") ), + "Vectors...", visuGUI, SLOT(CreateVectors())); + thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_STREAM_LINES") ), + "Stream lines...", visuGUI, SLOT(CreateStreamLines())); + } + break; + } + } return false; - } - anObj = SALOME_MED::FAMILY::_narrow( anObject ); - if( !CORBA::is_nil( anObj ) ) { - thePopup->insertItem( "Import Family", visuGUI, SLOT( ImportMedField() ) ); + }else{ + SALOMEDS::GenericAttribute_var anAttr; + if(aSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ) || + aSObject->FindAttribute( anAttr, "AttributeTableOfReal" )){ + thePopup->insertItem( "Show Table", visuGUI, SLOT(ShowTable())); + thePopup->insertItem( "Create Curves", visuGUI, SLOT(PlotData())); + return false; + } + aSObject = aSObject->GetFather(); + aSObject->FindAttribute(anAttr, "AttributeName"); + SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); + CORBA::String_var aValue = aName->Value(); + //if(strcmp(aValue.in(),"MEDMESH") == 0) + // thePopup->insertItem( "Import MED", visuGUI, SLOT( ImportMedField() ) ); + if(strcmp(aValue.in(),"MEDFIELD") == 0) + thePopup->insertItem( "Import Field", visuGUI, SLOT( ImportMedField() ) ); return false; } - anObj = SALOME_MED::SUPPORT::_narrow( anObject ); - if( !CORBA::is_nil( anObj ) ) { - thePopup->insertItem( "Import Support", visuGUI, SLOT( ImportMedField() ) ); - return false; - }*/ - } - } - int aType = ObjectTypes.find( aComment.c_str() ); - if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup - aComment = "<FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) { - thePopup->insertItem( "Show Table", visuGUI, SLOT( ShowTable() ) ); - thePopup->insertItem( "Create Curves", visuGUI, SLOT( PlotData() ) ); - } - return false; - } - if(aComment == "ENTITY" || aComment == "FAMILY" || aComment == "GROUP") - thePopup->insertItem("Create Presentation", visuGUI, SLOT(CreateMesh())); - switch (aType) { - case 0: // Field - if (getValue(obj, "myNbTimeStamps").toLong() > 1) - thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) ); - break; - - case 6: // VIEW3D node - if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - // Available only for VTK viewer - thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) ); - thePopup->insertItem( "Restore view parameters", visuGUI, SLOT( RestoreViewParams() ) ); - } - thePopup->insertItem( "Rename...", visuGUI, SLOT( Rename() ) ); - thePopup->insertItem("Delete", visuGUI, SLOT(DeleteViewParams())); - break; - - //case 13: // Mesh node - //thePopup->insertItem("Create Presentation", visuGUI, SLOT(CreateMesh())); - //break; - - case 18: { // Timestamp -// if( isStudyLocked(VisuGUI::myActiveStudy->getStudyDocument())) -// return false; - int aNunComponent = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist).toInt(); - thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_SCALAR_MAP") ), - "Scalar Map...", visuGUI, SLOT(CreateScalarMap())); - thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_ISO_SURFACES") ), - "Iso Surfaces...", visuGUI, SLOT(CreateIsoSurfaces())); - thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_CUT_PLANES") ), - "Cut Planes...", visuGUI, SLOT(CreateCutPlanes())); - if(aNunComponent > 1){ - thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_DEFORMED_SHAPE") ), - "Deformed Shape...", visuGUI, SLOT(CreateDeformedShape())); - thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_VECTORS") ), - "Vectors...", visuGUI, SLOT(CreateVectors())); - thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_STREAM_LINES") ), - "Stream lines...", visuGUI, SLOT(CreateStreamLines())); } } - } - return false; } //=========================================================================== @@ -3083,12 +2742,12 @@ void VisuGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO) VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop()); - SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument(); + SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument(); SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) return; + if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) return; - vtkRenderer *Renderer = GetRenderer(visuGUI->myActiveStudy); + vtkRenderer *Renderer = GetRenderer(); SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID ( theIO->getEntry() ); SCRUTE(aSObj); @@ -3115,9 +2774,6 @@ void VisuGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO) } VTKViewer_ViewFrame* vf = GetVtkViewFrame(); vf->AddActor(SelectedActor); - if(SelectedActor->HasScalarBar()){ - Renderer->AddActor2D(SelectedActor->getScalarBar()); - } } else { MESSAGE("CORBA::is_nil(anObject) = true"); @@ -3178,80 +2834,65 @@ extern "C" VisuGUI::BuildPresentation(theIO); } -} - -// ==================================================================================================================== -// =================================================================================================================== - -bool VisuGUI::getObjectRef( QAD_Desktop* parent, SALOMEDS::SObject_ptr obj, - _CORBA_ObjRef_OUT_arg< SALOMEDS::_objref_SObject, SALOMEDS::SObject_Helper > objres, - const char* Type) { - - VisuGUI::GetOrCreateVisuGUI(parent); - SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument(); - SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(obj); - SALOMEDS::SObject_var RefObj; - - for (; it->More();it->Next()) { - SALOMEDS::SObject_var Fils = it->Value(); - - if ( Fils->ReferencedObject( RefObj ) ) { - SALOMEDS::SComponent_var theComponent = RefObj->GetFatherComponent(); - Standard_CString nameComponent = theComponent->ComponentDataType(); + void supportedViewType(int* buffer, int bufferSize) + { + if (!buffer || !bufferSize) return; + buffer[0] = (int)VIEW_VTK; + if (--bufferSize) buffer[1] = (int)VIEW_PLOT2D; + } - if ( TCollection_AsciiString(nameComponent).IsEqual(strdup(Type)) ) { - objres = SALOMEDS::SObject::_narrow(RefObj); - return true; - } - } - } - return false; } ////////////////////////////////////////////////////////////////////////////////// //////////////// CHANGE ACTOR COLOR //////////////////////// ////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////// +///////////////// ///////////////////////////////////////////////////////////////// // change actor color // In : Name of Actor // // -void VisuGUI::NewColor(VISU_Actor *Actor) -{ - float oldcolor[3],newcolor[3]; - Actor->GetProperty()->GetColor(oldcolor); - QColor colorold; - colorold = QColor(oldcolor[0]*255, oldcolor[1]*255, oldcolor[2]*255); - QColor colornew = QColorDialog::getColor( colorold, QAD_Application::getDesktop() ); - - if (!colornew.isValid()) return; - - newcolor[0]=colornew.red()/255.; - newcolor[1]=colornew.green()/255.; - newcolor[2]=colornew.blue()/255.; - Actor->GetProperty()->SetColor(newcolor); - if (Actor->getPrs3d()) - Actor->getPrs3d()->SetColor(newcolor); +void VisuGUI::NewColor(VISU_Actor *theActor){ + if(VISU::Prs3d_i* aPrs3d = theActor->getPrs3d()){ + SALOMEDS::Color anOldColor = aPrs3d->GetColor(), aNewColor; + QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B)); + QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop()); + if(aColorNew.isValid()){ + aNewColor.R = aColorNew.red()/255.; + aNewColor.G = aColorNew.green()/255.; + aNewColor.B = aColorNew.blue()/255.; + aPrs3d->SetColor(aNewColor); + aPrs3d->Update(); + for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++) + if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){ + QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame(); + if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast(aVFrame)) + if(VISU_Actor* anActor = GetActor(aPrs3d,aViewFrame)) + aPrs3d->UpdateActor(anActor); + } + } + } } -void VisuGUI::NewOutlineColor(VISU_Actor *Actor) -{ - float oldcolor[3],newcolor[3]; - Actor->EdgeDevice->GetProperty()->GetColor(oldcolor); - QColor colorold; - colorold = QColor(oldcolor[0]*255, oldcolor[1]*255, oldcolor[2]*255); - QColor colornew = QColorDialog::getColor( colorold, QAD_Application::getDesktop() ); - - if (!colornew.isValid()) return; - - SALOMEDS::Color aColor; - aColor.R = newcolor[0]=colornew.red()/255.; - aColor.G = newcolor[1]=colornew.green()/255.; - aColor.B = newcolor[2]=colornew.blue()/255.; - Actor->EdgeDevice->GetProperty()->SetColor(newcolor); - if (Actor->getPrs3d()) - dynamic_cast(Actor->getPrs3d())->SetLinkColor(aColor); +void VisuGUI::NewOutlineColor(VISUMesh_Actor *theActor){ + if(VISU::Mesh_i* aPrs3d = dynamic_cast(theActor->getPrs3d())){ + SALOMEDS::Color anOldColor = aPrs3d->GetColor(), aNewColor; + QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B)); + QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop()); + if(aColorNew.isValid()){ + aNewColor.R = aColorNew.red()/255.; + aNewColor.G = aColorNew.green()/255.; + aNewColor.B = aColorNew.blue()/255.; + aPrs3d->SetLinkColor(aNewColor); + for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++) + if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){ + QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame(); + if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast(aVFrame)) + if(VISU_Actor* anActor = GetActor(aPrs3d,aViewFrame)) + aPrs3d->UpdateActor(anActor); + } + } + } } ////////////////////////////////////////////////////////////////////////////////// @@ -3308,7 +2949,7 @@ void VisuGUI::NewLinewidth(VISU_Actor *Actor) int intlwid; CursorDlg->Comment1->setText("Set value between"); CursorDlg->Comment2->setText("1 (thin) and 10 (thick)"); - oldlwid=Actor->GetProperty()->GetLineWidth(); + oldlwid=Actor->GetLineWidth(); intlwid=int(oldlwid); CursorDlg->SpinBox1->setMinValue(1); CursorDlg->SpinBox1->setMaxValue(10); @@ -3318,7 +2959,7 @@ void VisuGUI::NewLinewidth(VISU_Actor *Actor) if (ret == 1) { intlwid = CursorDlg->SpinBox1->value() ; newlwid = intlwid; - Actor->GetProperty()->SetLineWidth(newlwid); + Actor->SetLineWidth(newlwid); } delete CursorDlg; } @@ -3414,17 +3055,18 @@ QString VisuGUI::getVisuOutputDir() VISU::Result_i* VisuGUI::CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult){ if(MYDEBUG) MESSAGE("VisuGUI::CreatePresent"); VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - SALOMEDS::SObject_var aSObj = theField->GetFather(); - aSObj = aSObj->GetFather(); - aSObj = aSObj->GetFather(); - aSObj = aSObj->GetFather(); + SALOMEDS::SObject_var aSObj = theField->GetFather(); + if (CORBA::is_nil(aSObj)) return NULL; + aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL; + aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL; + aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL; CORBA::Object_var anObject = VISU::SObjectToObject(aSObj); if(CORBA::is_nil(anObject)) return NULL; theResult = VISU::Result::_narrow(anObject); VISU::Result_i* pResult = dynamic_cast(VISU::GetServant(anObject)); if(pResult == NULL) QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"), - tr ("No Available data in selection"), + tr ("WRN_NO_AVAILABLE_DATA"), tr ("VISU_BUT_OK")); return pResult; } @@ -3435,21 +3077,19 @@ PRSTYPE* FNAME(SALOMEDS::SObject_var theField, \ const char* theFieldName, double theTimeId) {\ VISU::Result_var aResult; \ VISU::Result_i* pResult = CreatePresent(theField,aResult); \ - if(pResult){ \ + if(pResult != NULL){ \ if(PRSTYPE::IsPossible(pResult,theMeshName,(VISU::Entity)theEntity,theFieldName,theTimeId)){ \ QApplication::setOverrideCursor( Qt::waitCursor ); \ - VISU::VISU_Gen_var aVisuGen = VISU::Base_i::GetVisuGenInter(); \ CORBA::Object_var anObject = \ - aVisuGen->FCREATE(aResult,theMeshName,theEntity,theFieldName,theTimeId); \ + GetVisuGen()->FCREATE(aResult,theMeshName,theEntity,theFieldName,theTimeId); \ QApplication::restoreOverrideCursor(); \ - if(CORBA::is_nil(anObject)) return NULL; \ - return dynamic_cast(VISU::GetServant(anObject)); \ + if(!CORBA::is_nil(anObject)) \ + return dynamic_cast(VISU::GetServant(anObject)); \ } \ - } else { \ - QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), \ - tr ("The presentation can't be built."), \ - tr ("VISU_BUT_OK") ); \ } \ + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), \ + tr ("ERR_CANT_BUILD_PRESENTATION"), \ + tr ("VISU_BUT_OK") ); \ return NULL; \ } @@ -3458,6 +3098,7 @@ CREATEPRS(VISU::DeformedShape_i, VisuGUI::CreateDeformedShapePrs, DeformedShapeO CREATEPRS(VISU::Vectors_i, VisuGUI::CreateVectorsPrs, VectorsOnField); CREATEPRS(VISU::IsoSurfaces_i, VisuGUI::CreateIsoSurfacesPrs, IsoSurfacesOnField); CREATEPRS(VISU::CutPlanes_i, VisuGUI::CreateCutPlanesPrs, CutPlanesOnField); +CREATEPRS(VISU::CutLines_i, VisuGUI::CreateCutLinesPrs, CutLinesOnField); CREATEPRS(VISU::StreamLines_i, VisuGUI::CreateStreamLinesPrs, StreamLinesOnField); @@ -3466,12 +3107,19 @@ bool FNAME(SALOMEDS::SObject_var theField) { \ VISU::Storable::TRestoringMap aMap = getMapOfValue(theField); \ bool isExist; \ QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist); \ - if(!isExist && aType.toInt() != VISU::TTIMESTAMP) return false; \ + if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false; \ QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1(); \ QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1(); \ QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1(); \ QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1(); \ + Utils_Timer timer; \ + if(MYCHECKTIME) timer.Start(); \ TYPE* pPresent = FCREATE(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toDouble()); \ + if(MYCHECKTIME) { \ + timer.Stop(); \ + MESSAGE("BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT"); \ + timer.Show(); \ + } \ if (pPresent) { \ DLGNAME* aDlg = new DLGNAME(); \ aDlg->initFromPrsObject(pPresent); \ @@ -3494,6 +3142,7 @@ BUILDPRS(VISU::DeformedShape_i, CreateDeformedShapePrs, VisuGUI::CreateDeformedS BUILDPRS(VISU::Vectors_i, CreateVectorsPrs, VisuGUI::CreateVectors, VisuGUI_VectorsDlg); BUILDPRS(VISU::IsoSurfaces_i, CreateIsoSurfacesPrs, VisuGUI::CreateIsoSurfaces, VisuGUI_IsoSurfacesDlg); BUILDPRS(VISU::CutPlanes_i, CreateCutPlanesPrs, VisuGUI::CreateCutPlanes, VisuGUI_CutPlanesDlg); +BUILDPRS(VISU::CutLines_i, CreateCutLinesPrs, VisuGUI::CreateCutLines, VisuGUI_CutLinesDlg); BUILDPRS(VISU::StreamLines_i, CreateStreamLinesPrs, VisuGUI::CreateStreamLines, VisuGUI_StreamLinesDlg); @@ -3513,7 +3162,7 @@ void VisuGUI::ImportTablesFromFile(){ aDir = QAD_Tools::getDirFromPath(aFile); QAD_CONFIG->addSetting("Visu:InputDir",aDir); QApplication::setOverrideCursor( Qt::waitCursor ); - QAD_PyInterp* myPyInterp = myActiveStudy->get_PyInterp(); + QAD_PyInterp* myPyInterp = GetActiveStudy()->get_PyInterp(); myPyInterp->run("import VisuGUI"); myPyInterp->run("reload(VisuGUI)"); myPyInterp->run("VisuGUI.AddTablesInStudyFromFile('"+aFile+"')"); @@ -3524,7 +3173,7 @@ void VisuGUI::ImportTablesFromFile(){ // tr ("VISU_BUT_OK") ); // else // QAD_Application::getDesktop()->putInfo(aFile+" imported."); - myActiveStudy->updateObjBrowser(); //update Object browser + GetActiveStudy()->updateObjBrowser(); //update Object browser QApplication::restoreOverrideCursor(); } } @@ -3533,7 +3182,7 @@ void VisuGUI::ImportTablesFromFile(){ /* Global Method to import mesh results in MED and DAT format */ /* ======================================================================================== */ void VisuGUI::ImportFromFile(){ - if (checkLock(myActiveStudy->getStudyDocument())) return; + if (checkLock(GetActiveStudy()->getStudyDocument())) return; QStringList flt; //flt.append( "Exportable Files (*.med *.dat)" ); //flt.append( "Dat Files (*.dat)" ); @@ -3546,28 +3195,41 @@ void VisuGUI::ImportFromFile(){ QAD_Application::getDesktop()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." ); aDir = QAD_Tools::getDirFromPath(aFileInfo.filePath()); QAD_CONFIG->addSetting("Visu:InputDir",aDir); - QApplication::setOverrideCursor( Qt::waitCursor ); + QAD_WaitCursor wc; CORBA::Object_var anObject; +#ifdef CHECKTIME + Utils_Timer timer; + timer.Start(); +#endif if(aFileInfo.extension(false) == "med") - anObject = myComponent->ImportFile(aFileInfo.filePath()); + anObject = GetVisuGen()->ImportFile(aFileInfo.filePath()); else if(aFileInfo.extension(false) == "xls") - anObject = myComponent->ImportTables(aFileInfo.filePath()); + anObject = GetVisuGen()->ImportTables(aFileInfo.filePath()); +#ifdef CHECKTIME + timer.Stop(); + MESSAGE("VisuGUI::ImportFromFile() - IMPORT FILE"); + timer.Show(); +#endif - if(CORBA::is_nil(anObject)) + if(CORBA::is_nil(anObject)) { + wc.stop(); QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), - tr ("There is an error in imported file"), + tr ("ERR_ERROR_IN_THE_FILE"), tr ("VISU_BUT_OK") ); - else + wc.start(); + } + else { QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported."); - - myActiveStudy->updateObjBrowser(); //update Object browser - QApplication::restoreOverrideCursor(); + } + GetActiveStudy()->updateObjBrowser(); //update Object browser } } void VisuGUI::ExportToFile(){ - VISU::Base_i* aBase = GetSelectedVisuObj(); + CORBA::Object_var anObject = GetSelectedObj(); + if(CORBA::is_nil(anObject)) return; + VISU::Base_i* aBase = dynamic_cast(VISU::GetServant(anObject)); if(aBase != NULL && aBase->GetType() == VISU::TRESULT){ QStringList flt; flt.append( "Dat Files (*.dat)" ); @@ -3585,166 +3247,47 @@ void VisuGUI::ExportToFile(){ QAD_Application::getDesktop()->putInfo(aFile+" exported."); }catch(...){ QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), - tr ("There is an error during exporting to file"), + tr ("ERR_ERROR_DURING_EXPORT"), tr ("VISU_BUT_OK") ); } } } }else QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"), - tr ("No Available data in selection"), + tr ("WRN_NO_AVAILABLE_DATA"), tr ("VISU_BUT_OK")); } - -/* ======================================================================================== */ -/* Find an Actor to be the reference for a new visualization */ -/* ======================================================================================== */ -VISU_Actor *VisuGUI::ReferenceActor(QAD_Desktop* parent) -{ - bool exiDS = false, exiVE = false, exiSM = false, exiIS = false, exiCP = false; - int nbSf = visuGUI->myActiveStudy->getStudyFramesCount(); - int nbObj = 0; - for ( int i = 0; i < nbSf; i++ ) { - QAD_StudyFrame* sf = visuGUI->myActiveStudy->getStudyFrame(i); - if ( sf->getTypeView() == VIEW_VTK ) { - vtkRenderer* aRenderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer(); - vtkActorCollection* ac = aRenderer->GetActors(); - vtkActor *anActor; - for( ac->InitTraversal(); (anActor = ac->GetNextActor()) != NULL; ) { - if ( anActor->IsA( "VISU_Actor" ) ) { - VISU_Actor *VISUActor = VISU_Actor::SafeDownCast(anActor); - if (VisuGUI_VisuAsDlg::ActorTypeIsValid(VISUActor,-1)) { - // VisuAs->ListObjects->insertItem(VISUActor->getName()); - nbObj++; - int test = VISUActor->VisuActorType; - if(test == VisuActorType_DeformedShape) - exiDS=true; - else if(test == VisuActorType_Vectors) - exiVE=true; - else if(test == VisuActorType_ScalarMap) - exiSM=true; - else if(test == VisuActorType_IsoSurfaces) - exiIS=true; - else if(test == VisuActorType_CutPlanes) - exiCP=true; - } - } - } - } - } - - if ( nbObj > 0 ) { - VisuGUI_VisuAsDlg * VisuAs = new VisuGUI_VisuAsDlg(QAD_Application::getDesktop(), 0, true, 0 ); - - if(exiDS) - VisuAs->addType( tr( "Deformed Shape" ) ); - if(exiVE) - VisuAs->addType( tr( "Vectors" ) ); - if(exiSM) - VisuAs->addType( tr( "Scalar Map" ) ); - if(exiIS) - VisuAs->addType( tr( "Iso-Surfaces" ) ); - if(exiCP) - VisuAs->addType( tr( "Cut Planes" ) ); - - if ( VisuAs->exec() ) { - QString nameActor = VisuAs->getObject(); - if ( !nameActor.isNull() ) { - MESSAGE("Actor --> "<myActiveStudy->getStudyFrame(i); - if ( sf->getTypeView() == VIEW_VTK ) { - vtkRenderer* aRenderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer(); - vtkActorCollection* ac = aRenderer->GetActors(); - vtkActor *anActor; - for( ac->InitTraversal(); (anActor = ac->GetNextActor()) != NULL; ) { - if ( anActor->IsA( "VISU_Actor" ) ) { - VISU_Actor *VISUActor = VISU_Actor::SafeDownCast(anActor); - if (strcmp(VISUActor->getName(),nameActor) == 0) - return VISUActor; - } - } - } - } - } - } - } - return NULL; -} - /* ======================================================================================== */ /* Test and Read Object Browser before display */ /* ======================================================================================== */ -bool VisuGUI::TestObjectBrowser(SALOMEDS::SObject_var *objVisu ){ +bool VisuGUI::TestObjectBrowser(SALOMEDS::SObject_var& objVisu ){ if(MYDEBUG) MESSAGE("VisuGUI::TestObjectBrowser"); - SALOME_Selection* Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - if(It.More()){ - Handle(SALOME_InteractiveObject) IObject = It.Value(); - SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument(); //Document OCAF de l'etude active - if (IObject->hasEntry()){ - *objVisu = aStudy->FindObjectID(IObject->getEntry()); - if(!(*objVisu)->_is_nil()) return true; - } + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj(&anIO); + if(anIO->hasEntry()){ + objVisu = GetStudyDocument()->FindObjectID(anIO->getEntry()); + QString aValue = getValue(objVisu,"myType"); + if((VISU::VISUType)aValue.toInt() == VISU::TTIMESTAMP) return true; } QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"), - tr("No Available data in selection"), + tr("WRN_NO_AVAILABLE_DATA"), tr("VISU_BUT_OK") ); return false; } -/* ======================================================================================== */ -/* Print the render window */ -/* ======================================================================================== */ -void VisuGUI::PrintRW( QString prFile, bool toPrinter) -{ - ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->Repaint(); - - vtkRenderWindow *renwin = vtkRenderWindow::New(); - vtkRenderWindowInteractor *theInteractor = vtkRenderWindowInteractor::New(); - theInteractor = ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - //visuGUI->myActiveStudy->getActiveStudyFrame()->getVTKRWInteractor(); - - renwin=theInteractor->GetRenderWindow(); - vtkWindowToImageFilter *w2if = vtkWindowToImageFilter::New(); - vtkTIFFWriter *rttiffw = vtkTIFFWriter::New(); - w2if->SetInput(renwin); - rttiffw->SetInput(w2if->GetOutput()); - rttiffw->SetFileName(prFile); - rttiffw->Write(); - - if (toPrinter) // print the file - { - QString printer = QAD_CONFIG->getSetting("Visu:Printer"); - if (printer.isEmpty()) - printer="kprinter"; - system(printer + " " + prFile); - } -} - /** * Returns Actor of presentation if it exists */ -VISU_Actor* VisuGUI::GetActor(VISU::Prs3d_i* thePrs){ - VTKViewer_ViewFrame* vf = GetVtkViewFrame(); +VISU_Actor* VisuGUI::GetActor(VISU::Prs3d_i* thePrs, VTKViewer_ViewFrame* theViewFrame){ + VTKViewer_ViewFrame* vf = theViewFrame? theViewFrame: GetVtkViewFrame(); if (!vf) return NULL; - - vtkRenderer *aRen = vf->getRenderer(); - vtkActorCollection *anActColl = aRen->GetActors(); vtkActor *anActor; - VISU_Actor* anVISUActor = NULL; - VISU_Actor* aResActor = NULL; - long aSrcAddr = (long) thePrs; - for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){ - if(anActor->IsA("VISU_Actor")){ - anVISUActor = VISU_Actor::SafeDownCast(anActor); - long aCurrAddr = (long) anVISUActor->getPrs3d(); - if (aSrcAddr == aCurrAddr) { - return anVISUActor; - } - } - } + vtkActorCollection *anActColl = vf->getRenderer()->GetActors(); + for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;) + if(VISU_Actor* anVISUActor = dynamic_cast(anActor)) + if(thePrs == anVISUActor->getPrs3d()) + return anVISUActor->GetParent(); return NULL; } @@ -3762,53 +3305,30 @@ VISU_Actor* VisuGUI::UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly){ vtkActor *anActor; VISU_Actor* anVISUActor = NULL; VISU_Actor* aResActor = NULL; - long aSrcAddr = (long) thePrs; + VISU::Prs3d_i* aSrcAddr = thePrs; for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){ if(anActor->IsA("VISU_Actor")){ anVISUActor = VISU_Actor::SafeDownCast(anActor); - long aCurrAddr = (long) anVISUActor->getPrs3d(); - if (aSrcAddr == aCurrAddr) { - aResActor = anVISUActor; + VISU::Prs3d_i* aPrs = anVISUActor->getPrs3d(); + if(aPrs == NULL) continue; + if (thePrs == aPrs) { + aResActor = anVISUActor->GetParent(); + thePrs->UpdateActor(aResActor); aResActor->VisibilityOn(); - if ( aResActor->VisuActorType == VisuActorType_Mesh ) { - if ( aResActor->GetProperty()->GetRepresentation() == 2 && !aResActor->IsShrunk ) - aResActor->EdgeDevice->VisibilityOn(); - else - aResActor->EdgeDevice->VisibilityOff(); - } - if (aResActor->HasScalarBar()) - aResActor->getScalarBar()->VisibilityOn(); } else if (theDispOnly) { anVISUActor->VisibilityOff(); - if ( anVISUActor->VisuActorType == VisuActorType_Mesh) { - anVISUActor->EdgeDevice->VisibilityOff(); - } - if (anVISUActor->HasScalarBar()) - anVISUActor->getScalarBar()->VisibilityOff(); } } } if (aResActor) return aResActor; -#ifdef CHECKTIME - OSD_Timer timer; - timer.Start(); -#endif anVISUActor = thePrs->CreateActor(); MESSAGE("UpdateViewer - thePrs->CreateActor() = "<AddActor(anVISUActor); - if(anVISUActor->HasScalarBar()){ - aRen->AddActor2D(anVISUActor->getScalarBar()); - } } else QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), - tr ("Can't visulize current object"), + tr ("ERR_CANT_VISUALIZE_OBJECT"), tr ("VISU_BUT_OK") ); -#ifdef CHECKTIME - timer.Stop(); - MESSAGE("Cheking time in VisuGUI::UpdateViewer - thePrs->CreateActor + vf->AddActor + aRen->AddActor2D"); - timer.Show(); -#endif return anVISUActor; } @@ -3825,14 +3345,10 @@ bool VisuGUI::IsDisplayed(VISU::Prs3d_i* thePrs) { * Erases Presentation */ void VisuGUI::ErasePrs(VISU::Prs3d_i* thePrs) { - myActiveStudy->unHighlightAll(); + GetActiveStudy()->unHighlightAll(); VISU_Actor* anVISUActor = GetActor(thePrs); if (anVISUActor) { anVISUActor->VisibilityOff(); - if ( anVISUActor->VisuActorType == VisuActorType_Mesh ) - anVISUActor->EdgeDevice->VisibilityOff(); - if (anVISUActor->HasScalarBar()) - anVISUActor->getScalarBar()->VisibilityOff(); } } @@ -3840,41 +3356,19 @@ void VisuGUI::ErasePrs(VISU::Prs3d_i* thePrs) { * Deletes given presentation from Data structure */ void VisuGUI::DeletePresentation(VISU::Prs3d_i* thePrs) { - if (checkLock(myStudy)) return; - if (!thePrs) return; - - myActiveStudy->unHighlightAll(); - - vtkActor *anActor; - VISU_Actor* aVISUActor = NULL; - long aSrcAddr = (long) thePrs; - int nbFrames = myActiveStudy->getStudyFramesCount(); - QAD_StudyFrame* aFrame; - - for(int i=0; igetStudyFrame(i); - if(!aFrame || aFrame->getTypeView() != VIEW_VTK) continue; - vtkRenderer* aRen = ((VTKViewer_ViewFrame*)aFrame->getRightFrame()->getViewFrame())->getRenderer(); - vtkActorCollection *anActColl = aRen->GetActors(); - - for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){ - if(anActor->IsA("VISU_Actor")) { - aVISUActor = VISU_Actor::SafeDownCast(anActor); - if (aSrcAddr == ((long) aVISUActor->getPrs3d())) { - if (aVISUActor->HasScalarBar()) - aRen->RemoveActor(aVISUActor->getScalarBar()); - aRen->RemoveActor(aVISUActor); - aVISUActor->EdgeDevice->Delete(); - aVISUActor->Delete(); - aVISUActor = NULL; + if(checkLock(GetStudyDocument()) || !thePrs) return; + GetActiveStudy()->unHighlightAll(); + for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++) + if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){ + QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame(); + if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast(aVFrame)) + if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame)){ + aViewFrame->RemoveActor(anActor); + anActor->Delete(); } - } } - } - SALOMEDS::SObject_var aSObj = myStudy->FindObjectID(thePrs->GetEntry()); - if(aSObj->_is_nil()) return; - myStudyBuilder->RemoveObject(aSObj); - myActiveStudy->updateObjBrowser(); //update Object browser + thePrs->Destroy(); + GetActiveStudy()->updateObjBrowser(); //update Object browser } /** @@ -3886,36 +3380,22 @@ void VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) { VTKViewer_ViewFrame* vf = GetVtkViewFrame(); if (vf) { #ifdef CHECKTIME - OSD_Timer timer; - timer.Start(); + Utils_Timer timer; + timer.Start(); #endif VISU_Actor* aActor = thePrs->CreateActor(); if ( ! aActor ) { QApplication::restoreOverrideCursor(); QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), - tr ("The presentation can't be visualized.\n Null actor is created."), + tr ("WRN_CANT_VISUALIZE_PRS"), tr ("VISU_BUT_OK") ); return; } -#ifdef CHECKTIME - timer.Stop(); - MESSAGE("Cheking time in VisuGUI::CreateActor - thePrs->CreateActor"); - timer.Show(); -#endif - vtkRenderer *aRenderer = vf->getRenderer(); - //visuGUI->ClearViewer(QAD_Application::getDesktop(), aRenderer, -1); - //visuGUI->ShowTrihedron(true); -#ifdef CHECKTIME - timer.Reset(); - timer.Start(); -#endif vf->AddActor(aActor); - if (aActor->HasScalarBar()) - aRenderer->AddActor2D(aActor->getScalarBar()); #ifdef CHECKTIME - timer.Stop(); - MESSAGE("Cheking time in VisuGUI::CreateActor - vf->AddActor"); - timer.Show(); + timer.Stop(); + MESSAGE("VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) - DISPLAY ACTOR"); + timer.Show(); #endif } QApplication::restoreOverrideCursor(); @@ -3962,13 +3442,3 @@ void VisuGUI::SetActiveDialogBox(QDialog* aDlg) this->myActiveDialogBox = (QDialog*)aDlg ; return ; } - -QAD_Study* VisuGUI::GetActiveStudy() -{ - return this->myActiveStudy ; -} - -QAD_Desktop* VisuGUI::GetDesktop() -{ - return this->myDesktop ; -} diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index 8af43519..ad52d84f 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -1,9 +1,29 @@ -// File : VisuGUI.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VisuGUI_HeaderFile @@ -28,30 +48,7 @@ #include #include "SALOME_ListIteratorOfListIO.hxx" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static QString filters[] = { "DAT Files (*.dat)", - "Pressures Files (*.pre)", - "Displacements Files (*.dis)", - "Scalars Files (*.sca)", - "Vectors Files (*.vec)", - "Data Files (*.dat )", - "Vtk Files (*.vtk )", - "Med Files (*.med)", - "Results Files (*.res )", - "Print Files (*.tif)", - "Plot Files (*.plt)", - "Test Files (*.tst)" }; - -typedef enum {SOLVER,DAT_FILE,VTK_FILE,RES_FILE,MED_FILE,SMESH_FILE,VISU_FILE,SCALAR_FILE,ERROR} result ; +class vtkRenderer; enum RepresentType { POINTS, WIREFRAME, SURFACE, SHRINK }; @@ -61,218 +58,185 @@ enum RepresentType { POINTS, WIREFRAME, SURFACE, SHRINK }; // CLASS VIUSGUI // ====================================================================== // -class VisuGUI : public QObject -{ - Q_OBJECT - -public : -VisuGUI(); -~VisuGUI(); - -// Methods PUBLIC for Visualization -// - static SALOMEDS::Study_var GetCurrentStudy() { return myStudy; } - static QAD_Study* GetGUICurrentStudy() { return myActiveStudy; } - static VTKViewer_ViewFrame* GetVtkViewFrame(); - static SALOMEDS::StudyBuilder_var GetStudyBuilder() { return myStudyBuilder;} - static VISU::Storable::TRestoringMap getMapOfValue(SALOMEDS::SObject_var theSObject); - - static vtkRenderer* GetRenderer(QAD_Study* theStudy); - - -static VisuGUI* GetOrCreateVisuGUI( QAD_Desktop* desktop ); -static VisuGUI* GetVisuGUI() ; -static VISU::Result_i* CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult); - -bool CreateScalarMap(SALOMEDS::SObject_var theField); -static VISU::ScalarMap_i* CreateScalarMapPrs(SALOMEDS::SObject_var theField, +class VisuGUI : public QObject{ + Q_OBJECT; + public: + VisuGUI(); + ~VisuGUI(); + + static VISU::VISU_Gen_i* GetVisuGen(); + + static QAD_Desktop* GetDesktop(); + static QAD_Study* GetActiveStudy(); + static vtkRenderer* GetRenderer(); + static VTKViewer_ViewFrame* GetVtkViewFrame(); + static SALOMEDS::Study_var GetStudyDocument(); + static SALOMEDS::StudyBuilder_var NewBuilder(); + static VISU::Storable::TRestoringMap getMapOfValue(SALOMEDS::SObject_var theSObject); + + static VisuGUI* GetOrCreateVisuGUI(QAD_Desktop* desktop); + static VisuGUI* GetVisuGUI() ; + + static VISU::Result_i* CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult); + + bool CreateScalarMap(SALOMEDS::SObject_var theField); + static VISU::ScalarMap_i* CreateScalarMapPrs(SALOMEDS::SObject_var theField, + const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, double theTimeId); + bool CreateDeformedShape(SALOMEDS::SObject_var theField); + static VISU::DeformedShape_i* CreateDeformedShapePrs(SALOMEDS::SObject_var theField, + const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, double theTimeId); + bool CreateVectors(SALOMEDS::SObject_var theField); + static VISU::Vectors_i* CreateVectorsPrs(SALOMEDS::SObject_var theField, + const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, double theTimeId); + bool CreateIsoSurfaces(SALOMEDS::SObject_var theField); + static VISU::IsoSurfaces_i* CreateIsoSurfacesPrs(SALOMEDS::SObject_var theField, + const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, double theTimeId); + bool CreateCutPlanes(SALOMEDS::SObject_var theField); + static VISU::CutPlanes_i* CreateCutPlanesPrs(SALOMEDS::SObject_var theField, + const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, double theTimeId); + bool CreateCutLines(SALOMEDS::SObject_var theField); + static VISU::CutLines_i* CreateCutLinesPrs(SALOMEDS::SObject_var theField, const char* theMeshName, VISU::Entity theEntity, const char* theFieldName, double theTimeId); -bool CreateDeformedShape(SALOMEDS::SObject_var theField); -static VISU::DeformedShape_i* CreateDeformedShapePrs(SALOMEDS::SObject_var theField, - const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, double theTimeId); -bool CreateVectors(SALOMEDS::SObject_var theField); -static VISU::Vectors_i* CreateVectorsPrs(SALOMEDS::SObject_var theField, - const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, double theTimeId); -bool CreateIsoSurfaces(SALOMEDS::SObject_var theField); -static VISU::IsoSurfaces_i* CreateIsoSurfacesPrs(SALOMEDS::SObject_var theField, - const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, double theTimeId); -bool CreateCutPlanes(SALOMEDS::SObject_var theField); -static VISU::CutPlanes_i* CreateCutPlanesPrs(SALOMEDS::SObject_var theField, - const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, double theTimeId); -bool CreateStreamLines(SALOMEDS::SObject_var theField); -static VISU::StreamLines_i* CreateStreamLinesPrs(SALOMEDS::SObject_var theField, - const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, double theTimeId); -bool TestObjectBrowser(SALOMEDS::SObject_var *objVisu); - -static void ClearViewer(QAD_Desktop* parent, vtkRenderer *ren, int TypeOfActor); -static void ShowTrihedron(bool Show); -static void ChangeViewer(QAD_Desktop* parent, vtkRenderer *ren, bool ScalarBar, int Type); - -static void NewColor(VISU_Actor *Actor); -static void NewOutlineColor(VISU_Actor *Actor); -static void NewOpacity(VISU_Actor *Actor); -static void NewLinewidth(VISU_Actor *Actor); - -static void ChangeScalarBar(); -static void SetSweepingPreferences(); -static VISU_Actor *ReferenceActor(QAD_Desktop* parent); - -static void PlotTable( VISU::Table_i* table, int theDisplaying ); -static void PlotCurve( VISU::Curve_i* curve, int theDisplaying ); -static void PlotContainer( VISU::Container_i* container, int theDisplaying ); - -void PrintRW(QString prFile, bool toPrinter); - -static QString getVisuInputDir(); -static QString getVisuOutputDir(); - -static VISU_Actor *ActorSelected(QAD_Desktop* parent, bool InViewer, int *Mode); -static VISU_Actor *GetActorObjBrowser(SALOMEDS::SObject_var objVisu, vtkRenderer *ren); -static VISU_Actor *GetActor(QAD_Desktop* parent, Handle_SALOME_InteractiveObject IO, vtkRenderer *ren); - - static QString getValue(SALOMEDS::SObject_var theSObject, QString theKey); - - -VISU_Actor* UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly=false); -bool IsDisplayed(VISU::Prs3d_i* thePrs); -void ErasePrs(VISU::Prs3d_i* thePrs); - -VISU_Actor* GetActor(VISU::Prs3d_i* thePrs); -static VISU::Prs3d_i* GetSelectedPrs(); -void RecreateActor(VISU::Prs3d_i* thePrs); -static void CreateActor(VISU::Prs3d_i* thePrs); - -void VisuGUI::ChangeRepresentation(RepresentType theType); -void DeletePresentation(VISU::Prs3d_i* thePrs); - - -void SetState(int aState ); -void ResetState(); -void EmitSignalDeactivateDialog(); -void EmitSignalCloseAllDialogs(); -QDialog* GetActiveDialogBox(); -void SetActiveDialogBox(QDialog* aDlg); -QAD_Study* GetActiveStudy(); -QAD_Desktop* GetDesktop(); - + bool CreateStreamLines(SALOMEDS::SObject_var theField); + static VISU::StreamLines_i* CreateStreamLinesPrs(SALOMEDS::SObject_var theField, + const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, double theTimeId); + bool TestObjectBrowser(SALOMEDS::SObject_var& objVisu); + + static void ShowTrihedron(bool Show); + static void ChangeViewer(int theType); + + static void NewColor(VISU_Actor *Actor); + static void NewOutlineColor(VISUMesh_Actor *Actor); + static void NewOpacity(VISU_Actor *Actor); + static void NewLinewidth(VISU_Actor *Actor); + + static void ChangeScalarBar(); + static void SetSweepingPreferences(); + + static void PlotTable( VISU::Table_i* table, int theDisplaying ); + static void PlotCurve( VISU::Curve_i* curve, int theDisplaying ); + static void PlotContainer( VISU::Container_i* container, int theDisplaying ); + + static QString getVisuInputDir(); + static QString getVisuOutputDir(); + + static QString getValue(SALOMEDS::SObject_var theSObject, QString theKey); + static int checkHomoSelection(); + + VISU_Actor* UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly=false); + bool IsDisplayed(VISU::Prs3d_i* thePrs); + void ErasePrs(VISU::Prs3d_i* thePrs); + + static VISU::Prs3d_i* GetSelectedPrs3d(Handle(SALOME_InteractiveObject)* theIO = NULL); + void RecreateActor(VISU::Prs3d_i* thePrs); + static void CreateActor(VISU::Prs3d_i* thePrs); + static VISU_Actor *GetActor(int* theSelectionType = NULL); + static VISU_Actor* GetActor(VISU::Prs3d_i* thePrs, VTKViewer_ViewFrame* theViewFrame = NULL); + + void VisuGUI::ChangeRepresentation(RepresentType theType); + void DeletePresentation(VISU::Prs3d_i* thePrs); + + void SetState(int aState ); + void ResetState(); + void EmitSignalDeactivateDialog(); + void EmitSignalCloseAllDialogs(); + QDialog* GetActiveDialogBox(); + void SetActiveDialogBox(QDialog* aDlg); + // ---------------------------------------- // All method of standard EXPORT // ---------------------------------------- -// -Standard_EXPORT static bool OnGUIEvent (int theCommandID, QAD_Desktop* parent); - -Standard_EXPORT static bool setSettings (QAD_Desktop* parent); - -Standard_EXPORT static void DefinePopup(QString & theContext, - QString & theParent, - QString & theObject ) ; - -Standard_EXPORT static bool CustomPopup (QAD_Desktop* parent, - QPopupMenu* popup, - const QString & theContext, - const QString & theParent, - const QString & theObject); - -Standard_EXPORT static void BuildPresentation(const Handle(SALOME_InteractiveObject)&); - -Standard_EXPORT static bool OnMousePress (QMouseEvent* pe , + Standard_EXPORT static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + Standard_EXPORT static bool setSettings(QAD_Desktop* parent); + Standard_EXPORT static void DefinePopup(QString & theContext, + QString & theParent, + QString & theObject ) ; + Standard_EXPORT static bool CustomPopup(QAD_Desktop* parent, + QPopupMenu* popup, + const QString & theContext, + const QString & theParent, + const QString & theObject); + Standard_EXPORT static void BuildPresentation(const Handle(SALOME_InteractiveObject)&); + Standard_EXPORT static bool OnMousePress(QMouseEvent* pe , + QAD_Desktop* parent, + QAD_StudyFrame* studyFrame); + Standard_EXPORT static bool OnMouseMove(QMouseEvent* pe , QAD_Desktop* parent, QAD_StudyFrame* studyFrame); - -Standard_EXPORT static bool OnMouseMove (QMouseEvent* pe , - QAD_Desktop* parent, + Standard_EXPORT static bool OnKeyPress(QKeyEvent* pe, + QAD_Desktop* parent, QAD_StudyFrame* studyFrame); - -Standard_EXPORT static bool OnKeyPress (QKeyEvent* pe, - QAD_Desktop* parent, - QAD_StudyFrame* studyFrame); - -Standard_EXPORT static bool APIreaderVTK (QString FileMesh, QString FileResultat); - -Standard_EXPORT static bool getObjectRef(QAD_Desktop* parent, SALOMEDS::SObject_ptr obj, - _CORBA_ObjRef_OUT_arg< SALOMEDS::_objref_SObject, SALOMEDS::SObject_Helper > objres, - const char* Type); - -public slots: - void ImportTablesFromFile(); - void ImportFromFile(); - void ExportToFile(); - void CreateMesh(); - void CreateScalarMap(); - void CreateDeformedShape(); - void CreateVectors(); - void CreateIsoSurfaces(); - void CreateCutPlanes(); - void CreateStreamLines(); - - void DisplayPrs(); - void DisplayOnlyPrs(); - void ErasePrs(); - void EditPrs(); - void EditScalarBar(); - - void MakeWireframe(); - void MakeSurface(); - void MakePoints(); - void MakeShrink(); - - void ChageColor(); - void ChangeOutlineColor(); - void ChangeOpacity(); - void ChangeLines(); - - void ShowTable(); - void PlotData(); - void CurveProperties(); - void ClearContainer(); - - void SaveViewParams(); - void RestoreViewParams(); - - void DeletePrs(); - void Rename(); - void Sweep(); - void TimeAnimation(); - - void ImportMedField(); - //void ImportMedMesh(); - - void DeleteViewParams(); - void CopyPresentation(); - - void InfoOnPoint(); - void InfoOnCell(); - void SelectPoint(); - void SelectCell(); - -protected: + public slots: + void ImportTablesFromFile(); + void ImportFromFile(); + void ExportToFile(); + void CreateMesh(); + void CreateScalarMap(); + void CreateDeformedShape(); + void CreateVectors(); + void CreateIsoSurfaces(); + void CreateCutPlanes(); + void CreateCutLines(); + void CreateStreamLines(); + void CreateManyMesh(); - // Methods PROTECTED - // - + void DisplayPrs(); + void DisplayOnlyPrs(); + void ErasePrs(); + void EditPrs(); + void EditScalarBar(); + void DisplayManyPrs(); + void EraseManyPrs(); + + void MakeWireframe(); + void MakeSurface(); + void MakePoints(); + void MakeShrink(); + + void ChageColor(); + void ChangeOutlineColor(); + void ChangeOpacity(); + void ChangeLines(); + + void ShowTable(); + void CreateTable(); + void PlotData(); + void CurveProperties(); + void ClearContainer(); + + void SaveViewParams(); + void RestoreViewParams(); + + void DeletePrs(); + void Rename(); + void Sweep(); + void TimeAnimation(); + + void ImportMedField(); + //void ImportMedMesh(); + + void DeleteViewParams(); + void CopyPresentation(); - // Fields PROTECTED - // + void InfoOnPoint(); + void InfoOnCell(); + void SelectPoint(); + void SelectCell(); private : - static VISU::VISU_Gen_var myComponent; - static SALOMEDS::Study_var myStudy; - static SALOMEDS::StudyBuilder_var myStudyBuilder; - static QAD_Desktop* myDesktop; - static QAD_Study* myActiveStudy; - QDialog* myActiveDialogBox; - int myState ; - int myStudyId; - + QDialog* myActiveDialogBox; + int myState ; + signals: - void SignalDeactivateActiveDialog(); - void SignalCloseAllDialogs(); + void SignalDeactivateActiveDialog(); + void SignalCloseAllDialogs(); }; #endif diff --git a/src/VISUGUI/VisuGUI.py b/src/VISUGUI/VisuGUI.py index 83c96fb4..9593748a 100644 --- a/src/VISUGUI/VisuGUI.py +++ b/src/VISUGUI/VisuGUI.py @@ -1,3 +1,12 @@ +# VISU VISUGUI : GUI of VISU component +# +# Copyright (C) 2003 CEA/DEN, EDF R&D +# +# +# +# File : VisuGUI.py +# Module : VISU + class Row: def __init__(self): self.title = "" diff --git a/src/VISUGUI/VisuGUI_CellsResultsDlg.cxx b/src/VISUGUI/VisuGUI_CellsResultsDlg.cxx index b95055fc..5ee37e60 100644 --- a/src/VISUGUI/VisuGUI_CellsResultsDlg.cxx +++ b/src/VISUGUI/VisuGUI_CellsResultsDlg.cxx @@ -1,12 +1,32 @@ -using namespace std; -// File : VisuGUI_CellsResultsDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_CellsResultsDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_CellsResultsDlg.h" #include #include diff --git a/src/VISUGUI/VisuGUI_CellsResultsDlg.h b/src/VISUGUI/VisuGUI_CellsResultsDlg.h index 65e1a849..e937e91c 100644 --- a/src/VISUGUI/VisuGUI_CellsResultsDlg.h +++ b/src/VISUGUI/VisuGUI_CellsResultsDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_CellsResultsDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_CellsResultsDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_CELLSRESULTSDLG_H diff --git a/src/VISUGUI/VisuGUI_CursorDlg.cxx b/src/VISUGUI/VisuGUI_CursorDlg.cxx index bb29dc65..c3c83227 100644 --- a/src/VISUGUI/VisuGUI_CursorDlg.cxx +++ b/src/VISUGUI/VisuGUI_CursorDlg.cxx @@ -1,12 +1,32 @@ -using namespace std; -// File : VisuGUI_CursorDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_CursorDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_CursorDlg.h" #include diff --git a/src/VISUGUI/VisuGUI_CursorDlg.h b/src/VISUGUI/VisuGUI_CursorDlg.h index 0668aa6f..72958e42 100644 --- a/src/VISUGUI/VisuGUI_CursorDlg.h +++ b/src/VISUGUI/VisuGUI_CursorDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_CursorDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_CursorDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_CURSORDLG_H diff --git a/src/VISUGUI/VisuGUI_CutLinesDlg.cxx b/src/VISUGUI/VisuGUI_CutLinesDlg.cxx new file mode 100644 index 00000000..ee1298cf --- /dev/null +++ b/src/VISUGUI/VisuGUI_CutLinesDlg.cxx @@ -0,0 +1,253 @@ +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VisuGUI_CutLinesDlg.cxx +// Author : VSV +// Module : VISU + +#include "VisuGUI_CutLinesDlg.h" +#include +#include +#include + +#include "QAD_Application.h" +#include "QAD_Desktop.h" + + +VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg() + : QDialog( QAD_Application::getDesktop(), "VisuGUI_CutLinesDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + setCaption( "Cut Lines Definition" ); + setSizeGripEnabled( true ); + + QVBoxLayout* aMainLayout = new QVBoxLayout(this, 7, 6); + aMainLayout->setSpacing(5); + + // Tab pane + QTabWidget* aTabPane = new QTabWidget(this); + + // Plane of lines + QFrame* aPlanePane = new QFrame(this); + QVBoxLayout* aPlaneLayout = new QVBoxLayout( aPlanePane, 5, 6 ); + aPlaneLayout->addStretch(); + + mySelPlane = new QHButtonGroup( tr( "TXT_ORIENTATION" ), aPlanePane); + mySelPlane->setInsideSpacing( 5 ); + mySelPlane->setInsideMargin( 5 ); + connect(mySelPlane, SIGNAL(clicked(int)), this, SLOT(onPlaneSelect(int))); + + QRadioButton* aBxy = new QRadioButton( tr( "|| X-Y" ), mySelPlane); // 0 + QRadioButton* aByz = new QRadioButton( tr( "|| Y-Z" ), mySelPlane); // 1 + QRadioButton* aBzx = new QRadioButton( tr( "|| Z-X" ), mySelPlane); // 2 + aBzx->setChecked(true); + + aPlaneLayout->addWidget( mySelPlane ); + aPlaneLayout->addStretch(); + + QGroupBox* aRotBox = new QGroupBox( tr( "LBL_ROTATION" ), aPlanePane ); + aRotBox->setColumnLayout(2, Qt::Horizontal ); + + myRotXLbl = new QLabel( tr( "LBL_ROT_X" ), aRotBox); + myRotXSpn = new QAD_SpinBoxDbl( aRotBox, -45, 45, 5 ); + myRotXSpn->setValue( 0 ); + myRotYLbl = new QLabel( tr( "LBL_ROT_Y" ), aRotBox ); + myRotYSpn = new QAD_SpinBoxDbl( aRotBox, -45, 45, 5 ); + myRotYSpn->setValue( 0 ); + + aPlaneLayout->addWidget( aRotBox ); + aPlaneLayout->addStretch(); + + QHBox* aPosBox = new QHBox(aPlanePane); + aPosBox->setSpacing(5); + QLabel* aPosLbl = new QLabel( tr( "LBL_POS" ), aPosBox ); + myPosSpn = new QAD_SpinBoxDbl( aPosBox, 0, 1, 0.1 ); + myPosSpn->setValue( 0.5 ); + aPlaneLayout->addWidget( aPosBox ); + + + aTabPane->addTab( aPlanePane, tr("LBL_LINES_PLANE") ); + + + // Number of lines + QFrame* aLinesPane = new QFrame(this); + QVBoxLayout* aLinesLayout = new QVBoxLayout( aLinesPane, 5, 6 ); + + mySelPlane2 = new QHButtonGroup( tr( "TXT_ORIENTATION" ), aLinesPane); + mySelPlane2->setInsideSpacing( 5 ); + mySelPlane2->setInsideMargin( 5 ); + connect(mySelPlane2, SIGNAL(clicked(int)), this, SLOT(onCutSelect(int))); + + QRadioButton* aBxy2 = new QRadioButton( tr( "|| X-Y" ), mySelPlane2); // 0 + QRadioButton* aByz2 = new QRadioButton( tr( "|| Y-Z" ), mySelPlane2); // 1 + QRadioButton* aBzx2 = new QRadioButton( tr( "|| Z-X" ), mySelPlane2); // 2 + aBzx2->setEnabled(false); + aByz2->setChecked(true); + aLinesLayout->addWidget( mySelPlane2 ); + + QHBox* aNbBox = new QHBox(aLinesPane); + aNbBox->setSpacing(5); + QLabel* aNbLbl = new QLabel( tr( "LBL_NB_PLANS" ), aNbBox ); + myNbSpn = new QAD_SpinBoxDbl( aNbBox, 1, 100, 1 ); + myNbSpn->setValue( 10 ); + aLinesLayout->addWidget( aNbBox ); + + QGroupBox* aRotBox2 = new QGroupBox( tr( "LBL_ROTATION" ), aLinesPane ); + aRotBox2->setColumnLayout(2, Qt::Horizontal ); + + myRotXLbl2 = new QLabel( tr( "LBL_ROT_X" ), aRotBox2); + myRotXSpn2 = new QAD_SpinBoxDbl( aRotBox2, -45, 45, 5 ); + myRotXSpn2->setValue( 0 ); + myRotYLbl2 = new QLabel( tr( "LBL_ROT_Y" ), aRotBox2 ); + myRotYSpn2 = new QAD_SpinBoxDbl( aRotBox2, -45, 45, 5 ); + myRotYSpn2->setValue( 0 ); + + aLinesLayout->addWidget( aRotBox2 ); + + QHBox* aPosBox2 = new QHBox(aLinesPane); + aPosBox2->setSpacing(5); + QLabel* aPosLbl2 = new QLabel( tr( "LBL_POS" ), aPosBox2 ); + myPosSpn2 = new QAD_SpinBoxDbl( aPosBox2, 0, 1, 0.1 ); + myPosSpn2->setValue( 0.5 ); + aLinesLayout->addWidget( aPosBox2 ); + + aTabPane->addTab( aLinesPane, tr("LBL_LINES_CUT") ); + + aMainLayout->addWidget(aTabPane); + + // Dialog buttons + QHBox* aBtnBox = new QHBox(this); + QHBoxLayout* aBtnLayout = (QHBoxLayout*) aBtnBox->layout(); + aBtnLayout->setAutoAdd( false ); + aBtnLayout->setSpacing( 5 ); + + QPushButton* aOkBtn = new QPushButton(tr( "VISU_BUT_OK" ), aBtnBox); + aOkBtn->setAutoDefault( TRUE ); + aOkBtn->setDefault( true ); + aBtnLayout->addWidget(aOkBtn); + connect(aOkBtn, SIGNAL(clicked()), this, SLOT(accept())); + + aBtnLayout->addStretch(); + + QPushButton* aCloseBtn = new QPushButton(tr("BUT_CLOSE"), aBtnBox); + aBtnLayout->addWidget(aCloseBtn); + connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(reject())); + + aMainLayout->addWidget(aBtnBox); +} + +//------------------------------------------------------------------------------ +void VisuGUI_CutLinesDlg::initFromPrsObject(VISU::CutLines_i* thePrs) { + switch (thePrs->GetOrientationType()) { + case VISU::CutPlanes::XY: + ((QRadioButton*)mySelPlane->find(0))->setChecked(true); + onPlaneSelect(0); + break; + case VISU::CutPlanes::YZ: + ((QRadioButton*)mySelPlane->find(1))->setChecked(true); + onPlaneSelect(1); + break; + case VISU::CutPlanes::ZX: + ((QRadioButton*)mySelPlane->find(2))->setChecked(true); + onPlaneSelect(2); + } + myRotXSpn->setValue(thePrs->GetRotateX()*180./PI); + myRotYSpn->setValue(thePrs->GetRotateY()*180./PI); + myPosSpn->setValue(thePrs->GetDisplacement()); + + myNbSpn->setValue( thePrs->GetNbLines() ); + switch (thePrs->GetOrientationType2()) { + case VISU::CutPlanes::XY: + ((QRadioButton*)mySelPlane2->find(0))->setChecked(true); + break; + case VISU::CutPlanes::YZ: + ((QRadioButton*)mySelPlane2->find(1))->setChecked(true); + break; + case VISU::CutPlanes::ZX: + ((QRadioButton*)mySelPlane2->find(2))->setChecked(true); + } + myRotXSpn2->setValue(thePrs->GetRotateX2()*180./PI); + myRotYSpn2->setValue(thePrs->GetRotateY2()*180./PI); + myPosSpn2->setValue(thePrs->GetDisplacement2()); +} + + +//------------------------------------------------------------------------------ +void VisuGUI_CutLinesDlg::storeToPrsObject(VISU::CutLines_i* thePrs) { + switch (mySelPlane->id(mySelPlane->selected())) { + case 0: + thePrs->SetOrientationType(VISU::CutPlanes::XY); + break; + case 1: + thePrs->SetOrientationType(VISU::CutPlanes::YZ); + break; + case 2: + thePrs->SetOrientationType(VISU::CutPlanes::ZX); + } + thePrs->SetRotateX(myRotXSpn->value()*PI/180.); + thePrs->SetRotateY(myRotYSpn->value()*PI/180.); + thePrs->SetDisplacement(myPosSpn->value()); + + thePrs->SetNbLines((int)myNbSpn->value()); + switch (mySelPlane2->id(mySelPlane2->selected())) { + case 0: + thePrs->SetOrientationType2(VISU::CutPlanes::XY); + break; + case 1: + thePrs->SetOrientationType2(VISU::CutPlanes::YZ); + break; + case 2: + thePrs->SetOrientationType2(VISU::CutPlanes::ZX); + } + thePrs->SetRotateX2(myRotXSpn2->value()*PI/180.); + thePrs->SetRotateY2(myRotYSpn2->value()*PI/180.); + thePrs->SetDisplacement2(myPosSpn2->value()); +} + + +//------------------------------------------------------------------------------ +void VisuGUI_CutLinesDlg::onPlaneSelect(int theId) { + for (int i = 0; i < mySelPlane2->count(); i++) + mySelPlane2->find(i)->setEnabled(true); + QButton* aBtn = mySelPlane2->find(theId); + aBtn->setEnabled(false); + switch (theId) { + case 0: + myRotXLbl->setText( tr("LBL_ROT_X")); + myRotYLbl->setText( tr("LBL_ROT_Y")); + ((QRadioButton*)mySelPlane2->find(1))->setChecked(true); + onCutSelect(1); + break; + case 1: + myRotXLbl->setText( tr("LBL_ROT_Y")); + myRotYLbl->setText( tr("LBL_ROT_Z")); + ((QRadioButton*)mySelPlane2->find(2))->setChecked(true); + onCutSelect(2); + break; + case 2: + myRotXLbl->setText( tr("LBL_ROT_Z")); + myRotYLbl->setText( tr("LBL_ROT_X")); + ((QRadioButton*)mySelPlane2->find(0))->setChecked(true); + onCutSelect(0); + } +} + + +//------------------------------------------------------------------------------ +void VisuGUI_CutLinesDlg::onCutSelect(int theId) { + switch (theId) { + case 0: + myRotXLbl2->setText( tr("LBL_ROT_X")); + myRotYLbl2->setText( tr("LBL_ROT_Y")); + break; + case 1: + myRotXLbl2->setText( tr("LBL_ROT_Y")); + myRotYLbl2->setText( tr("LBL_ROT_Z")); + break; + case 2: + myRotXLbl2->setText( tr("LBL_ROT_Z")); + myRotYLbl2->setText( tr("LBL_ROT_X")); + } +} diff --git a/src/VISUGUI/VisuGUI_CutLinesDlg.h b/src/VISUGUI/VisuGUI_CutLinesDlg.h new file mode 100644 index 00000000..fd2fdc64 --- /dev/null +++ b/src/VISUGUI/VisuGUI_CutLinesDlg.h @@ -0,0 +1,51 @@ +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VisuGUI_CutLinesDlg.h +// Author : VSV +// Module : VISU + +#ifndef VISUGUI_CUTLINESDLG_H +#define VISUGUI_CUTLINESDLG_H + +#include +#include +#include "VISU_PrsObject_i.hh" +#include "VisuGUI_ScalarBarDlg.h" + +class VisuGUI_CutLinesDlg: public QDialog +{ + Q_OBJECT + +public: + VisuGUI_CutLinesDlg(); + ~VisuGUI_CutLinesDlg() {}; + + void initFromPrsObject(VISU::CutLines_i* thePrs); + void storeToPrsObject(VISU::CutLines_i* thePrs); + +private slots: + void onPlaneSelect(int theId); + void onCutSelect(int theId); + + +private: + QHButtonGroup* mySelPlane; + QAD_SpinBoxDbl* myRotXSpn; + QAD_SpinBoxDbl* myRotYSpn; + QLabel* myRotXLbl; + QLabel* myRotYLbl; + QAD_SpinBoxDbl* myPosSpn; + + QHButtonGroup* mySelPlane2; + QAD_SpinBoxDbl* myNbSpn; + QAD_SpinBoxDbl* myRotXSpn2; + QAD_SpinBoxDbl* myRotYSpn2; + QLabel* myRotXLbl2; + QLabel* myRotYLbl2; + QAD_SpinBoxDbl* myPosSpn2; +}; +#endif // VISUGUI_CUTLINESDLG_H diff --git a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx index fc0d175d..0e87bf97 100644 --- a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx +++ b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx @@ -1,12 +1,32 @@ -using namespace std; -// File : VisuGUI_CutPlanesDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_CutPlanesDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_CutPlanesDlg.h" #include #include "QAD_Application.h" @@ -24,56 +44,7 @@ VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg() QGridLayout* TopLayout = new QGridLayout( this ); TopLayout->setSpacing( 6 ); TopLayout->setMargin( 11 ); - /* - QGridLayout* CommentLayout = new QGridLayout; - CommentLayout->setMargin( 0 ); - CommentLayout->setSpacing( 6 ); - - QLabel* Comment1 = new QLabel( tr( "Enter plane position between" ), this, "Comment1" ); - Comment1->setText( tr( "Enter plane position between" ) ); - Comment1->setAlignment( AlignCenter ); - - Comment2_1 = new QLabel( tr( "v1" ), this, "Comment2_1" ); - Comment2_1->setMinimumSize( QSize( 70, 0 ) ); - Comment2_1->setAlignment( AlignCenter); - - QLabel* Comment2 = new QLabel( tr( " and " ), this, "Comment2" ); - Comment2->setAlignment( AlignCenter ); - - Comment2_2 = new QLabel( tr( "v2" ), this, "Comment2_2" ); - Comment2_2->setMinimumSize( QSize( 70, 0 ) ); - Comment2_2->setAlignment( AlignCenter ); - - QLabel* Comment3 = new QLabel( tr( "or in fraction between" ), this, "Comment3" ); - Comment3->setAlignment( AlignCenter ); - - QLabel* Commento4 = new QLabel( tr( " and " ), this, "Comment4" ); - Comment4->setAlignment( AlignCenter ); - - QLabel* Comment4_1 = new QLabel( tr( "0" ), this, "Comment4_1" ); - Comment4_1->setMinimumSize( QSize( 70, 0 ) ); - Comment4_1->setAlignment( AlignCenter ); - - QLabel* Comment4_2 = new QLabel( tr( "100" ), this, "Comment4_2" ); - Comment4_2->setMinimumSize( QSize( 70, 0 ) ); - Comment4_2->setAlignment( AlignCenter ); - QFont font = Comment3->font(); font.setBold( true ); - Comment2_1->setFont( font ); - Comment2_2->setFont( font ); - Comment4_1->setFont( font ); - Comment4_2->setFont( font ); - - CommentLayout->addMultiCellWidget( Comment1, 0, 0, 0, 2 ); - CommentLayout->addWidget( Comment2_1, 1, 0 ); - CommentLayout->addWidget( Comment2, 1, 1 ); - CommentLayout->addWidget( Comment2_2, 1, 2 ); - CommentLayout->addMultiCellWidget( Comment3, 2, 2, 0, 2 ); - CommentLayout->addWidget( Comment4_1, 3, 0 ); - CommentLayout->addWidget( Comment4, 3, 1 ); - CommentLayout->addWidget( Comment4_2, 3, 2 ); - CommentLayout->setColStretch( 0 , 5 ); - CommentLayout->setColStretch( 2 , 5 ); - */ + QButtonGroup* SelPlane = new QButtonGroup( tr( "Orientation" ), this, "SelPlane" ); SelPlane->setTitle( tr( "Orientation" ) ); SelPlane->setColumnLayout(0, Qt::Vertical ); @@ -96,57 +67,7 @@ VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg() nbPlan = new QSpinBox( 1, 100, 1, this, "nbPlan" ); nbPlan->setValue( 1 ); nbPlan->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - /* - GBplan1 = new QGroupBox( tr( "First plane" ), this, "GBplan1" ); - GBplan1->setColumnLayout(0, Qt::Vertical ); - GBplan1->layout()->setSpacing( 0 ); - GBplan1->layout()->setMargin( 0 ); - QGridLayout* GBplan1Layout = new QGridLayout( GBplan1->layout() ); - GBplan1Layout->setAlignment( Qt::AlignTop ); - GBplan1Layout->setSpacing( 6 ); - GBplan1Layout->setMargin( 11 ); - - QLabel* LabelPos = new QLabel( tr( "Plane position (value):" ), GBplan1, "LabelPos" ); - GBplan1Layout->addWidget( LabelPos, 0, 0 ); - - PosPlan1 = new QAD_SpinBoxDbl( GBplan1, -999.999, 999.999, 0.1 ); - PosPlan1->setValue( 0 ); - PosPlan1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - GBplan1Layout->addWidget( PosPlan1, 0, 1 ); - - QLabel* LabelPosi = new QLabel( tr( "Plane position (fraction):" ), GBplan1, "LabelPosi" ); - GBplan1Layout->addWidget( LabelPosi, 1, 0 ); - - PosFrac1 = new QAD_SpinBoxDbl( GBplan1, 0, 100, 0.1 ); - PosFrac1->setValue( 0 ); - PosFrac1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - GBplan1Layout->addWidget( PosFrac1, 1, 1 ); - - GBplan2 = new QGroupBox( tr( "Second plane" ), this, "GBplan2" ); - GBplan2->setColumnLayout(0, Qt::Vertical ); - GBplan2->layout()->setSpacing( 0 ); - GBplan2->layout()->setMargin( 0 ); - QGridLayout* GBplan2Layout = new QGridLayout( GBplan2->layout() ); - GBplan2Layout->setAlignment( Qt::AlignTop ); - GBplan2Layout->setSpacing( 6 ); - GBplan2Layout->setMargin( 11 ); - - QLabel* LabelPos_5 = new QLabel( tr( "Plane position (value):" ), GBplan2, "LabelPos_5" ); - GBplan2Layout->addWidget( LabelPos_5, 0, 0); - - PosPlan2 = new QAD_SpinBoxDbl( GBplan2, -999.999, 999.999, 0.1 ); - PosPlan2->setValue( 0 ); - PosPlan2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - GBplan2Layout->addWidget( PosPlan2, 0, 1 ); - - QLabel* LabelPosi_6 = new QLabel( tr( "Plane position (fraction):" ), GBplan2, "LabelPosi_6" ); - GBplan2Layout->addWidget( LabelPosi_6, 1, 0); - - PosFrac2 = new QAD_SpinBoxDbl( GBplan2, 0, 100, 0.1 ); - PosFrac2->setValue( 100 ); - PosFrac2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - GBplan2Layout->addWidget( PosFrac2, 1, 1 ); - */ + QGroupBox* GBrot = new QGroupBox( tr( "Rotations" ), this, "GBrot" ); GBrot->setColumnLayout(0, Qt::Vertical ); GBrot->layout()->setSpacing( 0 ); @@ -193,23 +114,20 @@ VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg() buttonCancel->setAutoDefault( TRUE ); GroupButtonsLayout->addWidget( buttonCancel, 0, 2 ); + QLabel* aPosLbl = new QLabel(tr( "LBL_POS" ), this); + myPosSpn = new QAD_SpinBoxDbl( this, 0, 1, 0.1 ); + // layouting TopLayout->addMultiCellWidget( SelPlane, 0, 0, 0, 1 ); - // TopLayout->addLayout( CommentLayout, 0, 1 ); TopLayout->addWidget( LabelPosi_3, 1, 0 ); TopLayout->addWidget( nbPlan, 1, 1 ); - //TopLayout->addMultiCellWidget( GBplan1, 2, 2, 0, 1 ); - //TopLayout->addMultiCellWidget( GBplan2, 3, 3, 0, 1 ); TopLayout->addMultiCellWidget( GBrot, 2, 2, 0, 1 ); - TopLayout->addMultiCellWidget( GroupButtons, 3, 3, 0, 1 ); + TopLayout->addWidget(aPosLbl, 3, 0 ); + TopLayout->addWidget(myPosSpn, 3, 1 ); + TopLayout->addMultiCellWidget( GroupButtons, 4, 4, 0, 1 ); // signals and slots connections - connect( SelPlane, SIGNAL( clicked( int ) ), this, SLOT( orientationChanged( int ) ) ); - //connect( PosPlan1, SIGNAL( valueChanged( double ) ), this, SLOT( posChanged( double ) ) ); - //connect( PosPlan2, SIGNAL( valueChanged( double ) ), this, SLOT( posChanged( double ) ) ); - //connect( PosFrac1, SIGNAL( valueChanged( double ) ), this, SLOT( fracChanged( double ) ) ); - //connect( PosFrac2, SIGNAL( valueChanged( double ) ), this, SLOT( fracChanged( double ) ) ); - //connect( nbPlan, SIGNAL( valueChanged( int ) ), this, SLOT( nbPlanChanged( int ) ) ); + connect( SelPlane, SIGNAL( clicked( int )), this, SLOT( orientationChanged( int ) ) ); connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); @@ -218,10 +136,8 @@ VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg() X1 = 0; X2 = 0; Y1 = 0; Y2 = 0; Z1 = 0; Z2 = 0; - //nbPold = 0; RBxy->setChecked( true ); orientationChanged( 0 ); - //nbPlanChanged( 1 ); } /*! @@ -236,6 +152,7 @@ void VisuGUI_CutPlanesDlg::initFromPrsObject(VISU::CutPlanes_i* thePrs) { setNbPlanes(thePrs->GetNbPlanes()); setRotation(thePrs->GetRotateX()*180./PI, thePrs->GetRotateY()*180./PI); setPlanePos(thePrs->GetOrientationType()); + myPosSpn->setValue(thePrs->GetDisplacement()); } void VisuGUI_CutPlanesDlg::storeToPrsObject(VISU::CutPlanes_i* thePrs) { @@ -243,6 +160,7 @@ void VisuGUI_CutPlanesDlg::storeToPrsObject(VISU::CutPlanes_i* thePrs) { thePrs->SetRotateX(getRotation1()*PI/180.); thePrs->SetRotateY(getRotation2()*PI/180.); thePrs->SetOrientationType(getOrientaion()); + thePrs->SetDisplacement(myPosSpn->value()); thePrs->Update(); } @@ -254,159 +172,16 @@ void VisuGUI_CutPlanesDlg::orientationChanged( int ) if ( RBxy->isChecked() ) { LabelRot1->setText( tr( "Rotation around X (Y to Z):" ) ); LabelRot2->setText( tr( "Rotation around Y (Z to X):" ) ); - //Comment2_1->setText( QString::number( Z1 ) ); - //Comment2_2->setText( QString::number( Z2 ) ); - //PosPlan1->setMinValue( Z1 ); - //PosPlan1->setMaxValue( Z2 ); - //PosPlan2->setMinValue( Z1 ); - //PosPlan2->setMaxValue( Z2 ); - /* - if( nbPlan->value() == 1 ) { -// PosFrac1->setValue( 50 ); - PosPlan1->setValue( ( Z1 + Z2 ) / 2 ); -// PosFrac2->setValue( 50 ); - PosPlan2->setValue( ( Z1 + Z2 ) / 2 ); - } - else { -// PosFrac1->setValue( 0 ); - //PosPlan1->setValue( Z1 ); -// PosFrac2->setValue(100); - PosPlan2->setValue( Z2 ); - }*/ - } - else if ( RByz->isChecked() ) { + } else if ( RByz->isChecked() ) { LabelRot1->setText( tr( "Rotation around Y (Z to X):" ) ); LabelRot2->setText( tr( "Rotation around Z (X to Y):" ) ); - //Comment2_1->setText( QString::number( X1 ) ); - //Comment2_2->setText( QString::number( X2 ) ); - //PosPlan1->setMinValue( X1 ); - //PosPlan1->setMaxValue( X2 ); - //PosPlan2->setMinValue( X1 ); - //PosPlan2->setMaxValue( X2 ); - /* - if( nbPlan->value() == 1 ) { -// PosFrac1->setValue( 50 ); - PosPlan1->setValue( ( X1 + X2 ) / 2 ); -// PosFrac2->setValue( 50 ); - PosPlan2->setValue( ( X1 + X2 ) / 2 ); - } - else { -// PosFrac1->setValue( 0 ); - PosPlan1->setValue( X1 ); -// PosFrac2->setValue( 100 ); - PosPlan2->setValue( X2 ); - }*/ - } - else { // RBzx->isChecked() - //Comment2_1->setText( QString::number( Y1 ) ); - //Comment2_2->setText( QString::number( Y2 ) ); - //PosPlan1->setMinValue( Y1 ); - //PosPlan1->setMaxValue( Y2 ); - //PosPlan2->setMinValue( Y1 ); - //PosPlan2->setMaxValue( Y2 ); + } else { LabelRot1->setText( tr( "Rotation around Z (X to Y):" ) ); LabelRot2->setText( tr( "Rotation around X (Y to Z):" ) ); - /* - if( (nbPlan->value()) == 1 ) { -// PosFrac1->setValue( 50 ); - PosPlan1->setValue( ( Y1 + Y2 ) / 2 ); -// PosFrac2->setValue( 50 ); - PosPlan2->setValue( ( Y1 + Y2 ) / 2 ); - } - else { -// PosFrac1->setValue( 0 ); - PosPlan1->setValue( Y1 ); -// PosFrac2->setValue( 100 ); - PosPlan2->setValue( Y2 ); - }*/ } } -/*! - Called when nb of planes is changed -*/ -/*void VisuGUI_CutPlanesDlg::nbPlanChanged( int nb ) -{ - int nold = ( nbPold == 0 ? 0 : ( nbPold > 1 ? 2 : 1 ) ); - int nnew = ( nb == 0 ? 0 : ( nb > 1 ? 2 : 1 ) ); - - if( nold != nnew ) - orientationChanged( 0 ); - //GBplan1->setEnabled( nnew != 0 ); - //GBplan2->setEnabled( nnew > 1 && nnew != 0 ); - nbPold = nb; - }*/ -/*! - Called when position ( fraction ) is changed -*/ -/*void VisuGUI_CutPlanesDlg::fracChanged( double value ) -{ - if ( signalsBlocked() ) - return; - QAD_SpinBoxDbl* spin = 0; - double V1, V2; - if ( sender() == PosFrac1 ) - spin = PosPlan1; - if ( sender() == PosFrac2 ) - spin = PosPlan2; - if( RBxy->isChecked() ) { - V1 = Z1; V2 = Z2; - } - else if( RByz->isChecked() ) { - V1 = X1; V2 = X2; - } - else { - V1 = Y1; V2 = Y2; - } - if ( spin ) { - blockSignals( true ); - spin->setValue( V1 + ( V2 - V1 ) * value / 100 ); - blockSignals( false ); - } - }*/ - -/*! - Called when position ( value ) is changed -*/ -/*void VisuGUI_CutPlanesDlg::posChanged( double value ) -{ - if ( signalsBlocked() ) - return; - QAD_SpinBoxDbl* spin = 0; - double V; - if ( sender() == PosPlan1 ) - spin = PosFrac1; - if ( sender() == PosPlan2 ) - spin = PosFrac2; - if( RBxy->isChecked() ) { - if ( value <= Z1 ) - V = 0; - else if ( value >= Z2 ) - V = 100; - else - V = ( value - Z1 ) / ( Z2 - Z1 ) * 100; - } - else if( RByz->isChecked() ) - if ( value <= X1 ) - V = 0; - else if ( value >= X2 ) - V = 100; - else - V = ( value - X1 ) / ( X2 - X1 ) * 100; - else - if ( value <= Y1 ) - V = 0; - else if ( value >= Y2 ) - V = 100; - else - V = ( value - Y1 ) / ( Y2 - Y1 ) * 100; - if ( spin ) { - blockSignals( true ); - spin->setValue( V ); - blockSignals( false ); - } - }*/ /*! Sets bounds ( must be called first ) @@ -449,25 +224,8 @@ void VisuGUI_CutPlanesDlg::setPlanePos( const VISU::CutPlanes::Orientation orie else // zx RBzx->setChecked( true ); orientationChanged( 0 ); - //PosPlan1->setValue( pos1 ); - //PosPlan2->setValue( pos2 ); } -/*! - Sets planes orientation and position ( fraction ) -*/ -/*void VisuGUI_CutPlanesDlg::setPlanePosFrac( const int orient, const double frac1, const double frac2 ) -{ - if ( orient == 1 ) // xy - RBxy->setChecked( true ); - else if ( orient == 2) // yz - RByz->setChecked( true ); - else // zx - RBzx->setChecked( true ); - orientationChanged( 0 ); - PosFrac1->setValue( frac1 ); - PosFrac2->setValue( frac2 ); - }*/ /*! Gets planes orientation @@ -484,21 +242,6 @@ VISU::CutPlanes::Orientation VisuGUI_CutPlanesDlg::getOrientaion() return orient; } -/*! - Gets planes position 1 -*/ -/*double VisuGUI_CutPlanesDlg::getPlanePos1() -{ - return PosPlan1->value(); - }*/ - -/*! - Gets planes position 2 -*/ -/*double VisuGUI_CutPlanesDlg::getPlanePos2() -{ - return PosPlan2->value(); - }*/ /*! Sets planes rotation diff --git a/src/VISUGUI/VisuGUI_CutPlanesDlg.h b/src/VISUGUI/VisuGUI_CutPlanesDlg.h index 16968782..9432108f 100644 --- a/src/VISUGUI/VisuGUI_CutPlanesDlg.h +++ b/src/VISUGUI/VisuGUI_CutPlanesDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_CutPlanesDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_CutPlanesDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_CUTPLANESDLG_H @@ -35,10 +55,7 @@ public: void setNbPlanes( const int nbp ); int getNbPlanes(); void setPlanePos( const VISU::CutPlanes::Orientation orient/*, const double pos1, const double pos2 */); - //void setPlanePosFrac( const int orient, const double frac1, const double frac2 ); VISU::CutPlanes::Orientation getOrientaion(); - //double getPlanePos1(); - //double getPlanePos2(); void setRotation( const double r1, const double r2 ); double getRotation1(); double getRotation2(); @@ -46,39 +63,26 @@ public: void initFromPrsObject(VISU::CutPlanes_i* thePrs); void storeToPrsObject(VISU::CutPlanes_i* thePrs); -protected slots: - private: - //QLabel* Comment2_1; - //QLabel* Comment2_2; QLabel* LabelRot1; QLabel* LabelRot2; QSpinBox* nbPlan; - //QAD_SpinBoxDbl* PosPlan1; - //QAD_SpinBoxDbl* PosFrac1; - //QAD_SpinBoxDbl* PosPlan2; - //QAD_SpinBoxDbl* PosFrac2; QAD_SpinBoxDbl* Rot1; QAD_SpinBoxDbl* Rot2; QRadioButton* RBzx; QRadioButton* RByz; QRadioButton* RBxy; - //QGroupBox* GBplan1; - //QGroupBox* GBplan2; + QAD_SpinBoxDbl* myPosSpn; double X1, X2; double Y1, Y2; double Z1, Z2; - //int nbPold; private slots: void editScalarBar(); void orientationChanged( int ); - //void nbPlanChanged( int ); - //void fracChanged( double ); - //void posChanged( double ); }; #endif // VISUGUI_CUTPLANESDLG_H diff --git a/src/VISUGUI/VisuGUI_InitMeshDlg.cxx b/src/VISUGUI/VisuGUI_InitMeshDlg.cxx index 251ff08e..e19c55bb 100644 --- a/src/VISUGUI/VisuGUI_InitMeshDlg.cxx +++ b/src/VISUGUI/VisuGUI_InitMeshDlg.cxx @@ -1,13 +1,32 @@ -using namespace std; -// File : VisuGUI_InitMeshDlg.cxx -// Created : Mon May 27 10:20:11 2002 -// Author : Nicolas REJNERI - -// Project : SALOME -// Module : Visu -// Copyright : Open CASCADE 2002 +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_InitMeshDlg.cxx +// Author : Nicolas REJNERI +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_InitMeshDlg.h" #include "VisuGUI.h" diff --git a/src/VISUGUI/VisuGUI_InitMeshDlg.h b/src/VISUGUI/VisuGUI_InitMeshDlg.h index bd32536d..a5525828 100644 --- a/src/VISUGUI/VisuGUI_InitMeshDlg.h +++ b/src/VISUGUI/VisuGUI_InitMeshDlg.h @@ -1,10 +1,29 @@ -// File : VisuGUI_InitMeshDlg.h -// Created : Mon May 27 10:23:17 2002 -// Author : Nicolas REJNERI - -// Project : SALOME -// Module : Visu -// Copyright : Open CASCADE 2002 +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_InitMeshDlg.h +// Author : Nicolas REJNERI +// Module : VISU // $Header$ #ifndef DIALOGBOX_INIT_MESH_H diff --git a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx index 3e8222a9..3b3f8e3e 100644 --- a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx +++ b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx @@ -1,17 +1,40 @@ -using namespace std; -// File : VisuGUI_IsoSurfacesDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_IsoSurfacesDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_IsoSurfacesDlg.h" #include #include #include "QAD_Application.h" #include "QAD_Desktop.h" +#include +#include "QAD_MessageBox.h" + /*! Constructor @@ -37,16 +60,22 @@ VisuGUI_IsoSurfacesDlg::VisuGUI_IsoSurfacesDlg() QLabel* LabelMin = new QLabel( tr( "Minimum value:" ), TopGroup, "LabelMin" ); TopGroupLayout->addWidget( LabelMin, 0, 0 ); - MinIso = new QAD_SpinBoxDbl( TopGroup, -DBL_MAX, DBL_MAX, 0.1 ); + //MinIso = new QAD_SpinBoxDbl( TopGroup, -DBL_MAX, DBL_MAX, 0.1 ); + MinIso = new QLineEdit( TopGroup ); + MinIso->setValidator( new QDoubleValidator(this) ); MinIso->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); MinIso->setMinimumSize( 70, 0 ); + LabelMin->setBuddy(MinIso); TopGroupLayout->addWidget( MinIso, 0, 1 ); QLabel* LabelMax = new QLabel( tr( "Maximum value:" ), TopGroup, "LabelMax" ); TopGroupLayout->addWidget( LabelMax, 1, 0 ); - MaxIso = new QAD_SpinBoxDbl( TopGroup, -DBL_MAX, DBL_MAX, 0.1); + //MaxIso = new QAD_SpinBoxDbl( TopGroup, -DBL_MAX, DBL_MAX, 0.1); + MaxIso = new QLineEdit( TopGroup ); + MaxIso->setValidator( new QDoubleValidator(this) ); MaxIso->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); MaxIso->setMinimumSize( 70, 0 ); + LabelMax->setBuddy(MaxIso); TopGroupLayout->addWidget( MaxIso, 1, 1 ); QLabel* LabelNbr = new QLabel( tr( "Number of surfaces:" ), TopGroup, "LabelNbr" ); @@ -92,13 +121,22 @@ VisuGUI_IsoSurfacesDlg::~VisuGUI_IsoSurfacesDlg() void VisuGUI_IsoSurfacesDlg::initFromPrsObject(VISU::IsoSurfaces_i* thePrs) { NbrIso->setValue(thePrs->GetNbSurfaces()); - MinIso->setValue(thePrs->GetRangeMin()); - MaxIso->setValue(thePrs->GetRangeMax()); + MinIso->setText(QString::number(thePrs->GetRangeMin())); + MaxIso->setText(QString::number(thePrs->GetRangeMax())); } void VisuGUI_IsoSurfacesDlg::storeToPrsObject(VISU::IsoSurfaces_i* thePrs) { thePrs->SetNbSurfaces(NbrIso->value()); - thePrs->SetRange(MinIso->value(), MaxIso->value()); + thePrs->SetRange(MinIso->text().toDouble(), MaxIso->text().toDouble()); thePrs->Update(); } + +void VisuGUI_IsoSurfacesDlg::accept() { + if (MinIso->text().toDouble() >= MaxIso->text().toDouble()) + QAD_MessageBox::warn1( this,tr("VISU_WARNING"), + tr("MSG_MINMAX_VALUES"), + tr("VISU_BUT_OK")); + else + QDialog::accept(); +} diff --git a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.h b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.h index 68ca04cd..b6658369 100644 --- a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.h +++ b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_IsoSurfacesDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_IsoSurfacesDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_ISOSURFACESDLG_H @@ -14,8 +34,8 @@ #include #include #include -#include "QAD_SpinBoxDbl.h" #include "VISU_PrsObject_i.hh" +#include class VisuGUI_IsoSurfacesDlg : public QDialog @@ -29,9 +49,12 @@ public: void initFromPrsObject(VISU::IsoSurfaces_i* thePrs); void storeToPrsObject(VISU::IsoSurfaces_i* thePrs); +protected slots: + void accept(); + private: - QAD_SpinBoxDbl* MinIso; - QAD_SpinBoxDbl* MaxIso; + QLineEdit* MinIso; + QLineEdit* MaxIso; QSpinBox* NbrIso; }; diff --git a/src/VISUGUI/VisuGUI_MagnitudeDlg.cxx b/src/VISUGUI/VisuGUI_MagnitudeDlg.cxx index d1b60b60..28c0f1af 100644 --- a/src/VISUGUI/VisuGUI_MagnitudeDlg.cxx +++ b/src/VISUGUI/VisuGUI_MagnitudeDlg.cxx @@ -1,12 +1,32 @@ -using namespace std; -// File : VisuGUI_MagnitudeDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_MagnitudeDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_MagnitudeDlg.h" #include #include "QAD_Application.h" diff --git a/src/VISUGUI/VisuGUI_MagnitudeDlg.h b/src/VISUGUI/VisuGUI_MagnitudeDlg.h index 2ae11299..c1436aea 100644 --- a/src/VISUGUI/VisuGUI_MagnitudeDlg.h +++ b/src/VISUGUI/VisuGUI_MagnitudeDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_MagnitudeDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_MagnitudeDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_MAGNITUDEDLG_H diff --git a/src/VISUGUI/VisuGUI_NonIsometricDlg.cxx b/src/VISUGUI/VisuGUI_NonIsometricDlg.cxx index ab983f84..df3f1c27 100644 --- a/src/VISUGUI/VisuGUI_NonIsometricDlg.cxx +++ b/src/VISUGUI/VisuGUI_NonIsometricDlg.cxx @@ -1,35 +1,33 @@ -using namespace std; -// File : SALOMEGUI_NonIsometricDlg.cxx -// Created : Thu Dec 18 12:01:00 2002 -// Author : Vasily Rusyaev -// Project : SALOME PRO -// Module : SALOMEGUI -// Copyright : Open CASCADE +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : SALOMEGUI_NonIsometricDlg.cxx +// Author : Vasily Rusyaev +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_NonIsometricDlg.h" #include #include #include -#include -#include #include -#include -//#include - #include "QAD_SpinBoxDbl.h" -#include "utilities.h" - #include "QAD_Application.h" #include "QAD_Desktop.h" #include "QAD_StudyFrame.h" #include "QAD_RightFrame.h" #include "VTKViewer_ViewFrame.h" #include "VISU_Actor.h" +#include "utilities.h" -#include -#include +#include "SALOME_Selection.h" +#include "SALOME_ListIteratorOfListIO.hxx" +#include "SALOME_ListIO.hxx" /*! Constructor @@ -39,190 +37,99 @@ VisuGUI_NonIsometricDlg::VisuGUI_NonIsometricDlg( QWidget* parent, const char* n { QAD_StudyFrame* sf = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame(); - VTKViewer_NonIsometricTransform *aTransform = NULL; - if ( sf->getTypeView() == VIEW_VTK ) - { - VTKViewer_ViewFrame* vf = (VTKViewer_ViewFrame*) ( sf->getRightFrame()->getViewFrame() ); - aTransform = vf->getNonIsometricTransform(); - } - - if ( !name ) - setName( "NonIsometricDlg" ); - setCaption( tr( "Scaling" ) ); - setSizeGripEnabled( TRUE ); - - // Create layout for this dialog - QGridLayout* layoutDlg = new QGridLayout( this ); - layoutDlg->setSpacing(6); - layoutDlg->setMargin(11); - - // Create croup box with grid layout - QGroupBox* GroupBox = new QGroupBox( this, "GroupBox" ); - - QGridLayout* glGroupBox = new QGridLayout( GroupBox ); - glGroupBox->setMargin(11); - glGroupBox->setSpacing(6); - - //Create font: 14pnts, bold, italic - //It will be used for all labels in this group box - QFont m_font14bi = font(); - m_font14bi.setPointSize((int)(m_font14bi.pointSize()*1.4)); -// m_font14bi.setItalic( TRUE ); - m_font14bi.setBold( TRUE ); - - // Create "Choose function" label - QLabel* TextLabel1 = new QLabel( tr( "Choose function:" ), GroupBox, "TextLabel1" ); - glGroupBox->addWidget ( TextLabel1, 1, 0 ); - - // Create "Type the coefficient" label - QLabel* TextLabel2 = new QLabel( tr( "Coefficient:" ), GroupBox, "TextLabel2" ); - glGroupBox->addWidget ( TextLabel2, 2, 0 ); - - // Create "Applying function" label - QLabel* TextLabel3 = new QLabel( tr( "Applying function:" ), GroupBox, "TextLabel3" ); - glGroupBox->addWidget ( TextLabel3, 3, 0 ); - - glGroupBox->addColSpacing ( 1, 10 ); - - // Create "X" label - QLabel* TextLabelX = new QLabel( "X", GroupBox, "TextLabelX" ); - TextLabelX->setAlignment( int( QLabel::AlignCenter ) ); - //NRI TextLabelX->setFont( m_font14bi ); - glGroupBox->addWidget ( TextLabelX, 0, 2 ); - - // Create combobox for selecting scaling function on a X axis - m_cbXfunction = new QComboBox( FALSE, GroupBox, "m_cbXFunction"); - m_cbXfunction->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); - m_cbXfunction->setMinimumWidth( 80 ); - glGroupBox->addWidget(m_cbXfunction, 1, 2 ); - - // Create double spinbox for changing coef. in the scaling function on a X axis - m_sbXcoeff = new QAD_SpinBoxDbl( GroupBox, "m_sbXcoeff" ); - m_sbXcoeff->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); - m_sbXcoeff->setMinimumWidth( 80 ); - glGroupBox->addWidget(m_sbXcoeff, 2, 2 ); - - // Create informative label about the applying scaling function on a X axis - m_lXFunction = new QLabel( GroupBox, "m_lXFunction" ); - //NRI m_lXFunction->setFont( m_font14bi ); - m_lXFunction->setAlignment( int( QLabel::AlignCenter ) ); - glGroupBox->addWidget(m_lXFunction, 3, 2 ); - - FillComboBox( m_cbXfunction ); - - // Create "Y" label - QLabel* TextLabelY = new QLabel( "Y", GroupBox, "TextLabelY" ); - TextLabelY->setAlignment( int( QLabel::AlignCenter ) ); - //NRI TextLabelY->setFont( m_font14bi ); - glGroupBox->addWidget ( TextLabelY, 0, 3 ); - - // Create combobox for selecting scaling function on a Y axis - m_cbYfunction = new QComboBox( FALSE, GroupBox, "m_cbYFunction"); - m_cbYfunction->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); - m_cbYfunction->setMinimumWidth( 80 ); - glGroupBox->addWidget(m_cbYfunction, 1, 3 ); - - // Create double spinbox for changing coef. in the scaling function on a Y axis - m_sbYcoeff = new QAD_SpinBoxDbl( GroupBox, "m_sbYcoeff" ); - m_sbYcoeff->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); - m_sbYcoeff->setMinimumWidth( 80 ); - glGroupBox->addWidget(m_sbYcoeff, 2, 3 ); - - // Create informative label about the applying scaling function on a Y axis - m_lYFunction = new QLabel( GroupBox, "m_lYFunction" ); - m_lYFunction->setAlignment( int( QLabel::AlignCenter ) ); - //NRI m_lYFunction->setFont( m_font14bi ); - glGroupBox->addWidget(m_lYFunction, 3, 3 ); - - FillComboBox( m_cbYfunction ); - - // Create "Z" label - QLabel* TextLabelZ = new QLabel( "Z", GroupBox, "TextLabelZ" ); - TextLabelZ->setAlignment( int( QLabel::AlignCenter ) ); - //NRI TextLabelZ->setFont( m_font14bi ); - glGroupBox->addWidget ( TextLabelZ, 0, 4 ); - - // Create combobox for selecting scaling function on a Z axis - m_cbZfunction = new QComboBox( FALSE, GroupBox, "m_cbZFunction"); - m_cbZfunction->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); - m_cbZfunction->setMinimumWidth( 80 ); - glGroupBox->addWidget(m_cbZfunction, 1, 4 ); - - // Create double spinbox for changing coef. in the scaling function on a Z axis - m_sbZcoeff = new QAD_SpinBoxDbl( GroupBox, "m_sbZcoeff" ); - m_sbZcoeff->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); - m_sbZcoeff->setMinimumWidth( 80 ); - glGroupBox->addWidget(m_sbZcoeff, 2, 4 ); - - // Create informative label about the applying scaling function on a Z axis - m_lZFunction = new QLabel( GroupBox, "m_lZFunction" ); - m_lZFunction->setAlignment( int( QLabel::AlignCenter ) ); - //NRI m_lZFunction->setFont( m_font14bi ); - glGroupBox->addWidget(m_lZFunction, 3, 4 ); - - FillComboBox( m_cbZfunction ); - - if ( aTransform ) { - int item = aTransform->GetFunctionType(AxisFunction::XAxis); - m_cbXfunction->setCurrentItem(item); - if (item) { - m_sbXcoeff ->setEnabled (TRUE); - FunctionChanged( m_cbXfunction); - } - item = aTransform->GetFunctionType(AxisFunction::YAxis); - m_cbYfunction->setCurrentItem(item); - if (item) { - m_sbYcoeff ->setEnabled (TRUE); - FunctionChanged( m_cbYfunction ); - } - item = aTransform->GetFunctionType(AxisFunction::ZAxis); - m_cbZfunction->setCurrentItem(item); - if (item) { - m_sbZcoeff ->setEnabled (TRUE); - FunctionChanged( m_cbZfunction); - } - m_sbXcoeff -> setValue(aTransform->GetCoeff(AxisFunction::XAxis)); - m_sbYcoeff -> setValue(aTransform->GetCoeff(AxisFunction::YAxis)); - m_sbZcoeff -> setValue(aTransform->GetCoeff(AxisFunction::ZAxis)); - } - - // Create button - QPushButton* m_bReset = new QPushButton( tr( "&Reset" ), GroupBox, "m_bReset" ); - glGroupBox->addWidget( m_bReset, 4, 4 ); - - layoutDlg->addWidget(GroupBox,0,0); - - // OK, CANCEL, Apply button - QGroupBox* aWgt = new QGroupBox( this ); - QHBoxLayout* aHBoxLayout = new QHBoxLayout( aWgt ); - aHBoxLayout->setMargin(11); - aHBoxLayout->setSpacing(6); - - // Create button - QPushButton* m_bOk = new QPushButton( tr( "O&K" ), aWgt, "m_bOk" ); - m_bOk->setDefault( TRUE ); - m_bOk->setAutoDefault( TRUE ); - aHBoxLayout->addWidget( m_bOk ); - aHBoxLayout->addStretch(); - - // Create button - QPushButton* m_bApply = new QPushButton( tr( "&Apply" ), aWgt, "m_bApply" ); - m_bApply->setAutoDefault( TRUE ); - aHBoxLayout->addWidget( m_bApply ); - aHBoxLayout->addStretch(); + VTKViewer_ViewFrame* aViewFrame = dynamic_cast(sf->getRightFrame()->getViewFrame()); - // Create button - QPushButton* m_bCancel = new QPushButton( tr( "&Cancel" ), aWgt, "m_bCancel" ); - m_bCancel->setAutoDefault( TRUE ); - aHBoxLayout->addWidget( m_bCancel ); - - layoutDlg->addWidget(aWgt,1,0); - - // signals and slots connections - connect( m_bCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); - connect( m_bOk, SIGNAL( clicked() ), this, SLOT( onClickOk( ) ) ); - connect( m_bApply, SIGNAL( clicked() ), this, SLOT( onClickApply( ) ) ); - connect( m_bReset, SIGNAL( clicked() ), this, SLOT( onClickReset( ) ) ); + if ( !name ) + setName( "NonIsometricDlg" ); + setCaption( tr( "Scaling" ) ); + setSizeGripEnabled( TRUE ); + + // Create layout for this dialog + QGridLayout* layoutDlg = new QGridLayout( this ); + layoutDlg->setSpacing(6); + layoutDlg->setMargin(11); + + // Create croup box with grid layout + QGroupBox* GroupBox = new QGroupBox( this, "GroupBox" ); + QGridLayout* glGroupBox = new QGridLayout( GroupBox ); + glGroupBox->setMargin(11); + glGroupBox->setSpacing(6); + + // "X" scaling + QLabel* TextLabelX = new QLabel( "X: ", GroupBox, "TextLabelX" ); + m_sbXcoeff = new QAD_SpinBoxDbl( GroupBox, -DBL_MAX, DBL_MAX, 0.1 ); +//m_sbXcoeff->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); + m_sbXcoeff->setMinimumWidth( 80 ); + m_sbXcoeff->setValue( 1.0 ); + + // "Y" scaling + QLabel* TextLabelY = new QLabel( "Y", GroupBox, "TextLabelY" ); + m_sbYcoeff = new QAD_SpinBoxDbl( GroupBox, -DBL_MAX, DBL_MAX, 0.1 ); +//m_sbYcoeff->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); + m_sbYcoeff->setMinimumWidth( 80 ); + m_sbYcoeff->setValue( 1.0 ); + + // "Z" scaling + QLabel* TextLabelZ = new QLabel( "Z", GroupBox, "TextLabelZ" ); + m_sbZcoeff = new QAD_SpinBoxDbl( GroupBox, -DBL_MAX, DBL_MAX, 0.1 ); +//m_sbZcoeff->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); + m_sbZcoeff->setMinimumWidth( 80 ); + m_sbZcoeff->setValue( 1.0 ); + + // Get initial values from the current VTK viewer + if ( aViewFrame ) { + double aScaleFactor[3]; + aViewFrame->GetScale(aScaleFactor); + m_sbXcoeff -> setValue(aScaleFactor[0]); + m_sbYcoeff -> setValue(aScaleFactor[1]); + m_sbZcoeff -> setValue(aScaleFactor[2]); + } + + // Create button + m_bReset = new QPushButton( tr( "&Reset" ), GroupBox, "m_bReset" ); + + // Layout widgets in the group box + glGroupBox->addWidget( TextLabelX, 0, 0 ); + glGroupBox->addWidget( m_sbXcoeff, 0, 1 ); + glGroupBox->addWidget( TextLabelY, 0, 2 ); + glGroupBox->addWidget( m_sbYcoeff, 0, 3 ); + glGroupBox->addWidget( TextLabelZ, 0, 4 ); + glGroupBox->addWidget( m_sbZcoeff, 0, 5 ); + glGroupBox->addWidget( m_bReset, 0, 6 ); + + // OK, CANCEL, Apply button + QGroupBox* aWgt = new QGroupBox( this ); + QHBoxLayout* aHBoxLayout = new QHBoxLayout( aWgt ); + aHBoxLayout->setMargin(11); + aHBoxLayout->setSpacing(6); + // Create button + QPushButton* m_bOk = new QPushButton( tr( "O&K" ), aWgt, "m_bOk" ); + m_bOk->setDefault( TRUE ); + m_bOk->setAutoDefault( TRUE ); + // Create button + QPushButton* m_bApply = new QPushButton( tr( "&Apply" ), aWgt, "m_bApply" ); + m_bApply->setAutoDefault( TRUE ); + // Create button + QPushButton* m_bCancel = new QPushButton( tr( "&Cancel" ), aWgt, "m_bCancel" ); + m_bCancel->setAutoDefault( TRUE ); + + // Layout buttons + aHBoxLayout->addWidget( m_bOk ); + aHBoxLayout->addWidget( m_bApply ); + aHBoxLayout->addStretch(); + aHBoxLayout->addWidget( m_bCancel ); + + // Layout top level widgets + layoutDlg->addWidget(GroupBox,0,0); + layoutDlg->addWidget(aWgt,1,0); + + // signals and slots connections + connect( m_bCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); + connect( m_bOk, SIGNAL( clicked() ), this, SLOT( onClickOk( ) ) ); + connect( m_bApply, SIGNAL( clicked() ), this, SLOT( onClickApply( ) ) ); + connect( m_bReset, SIGNAL( clicked() ), this, SLOT( onClickReset( ) ) ); + + this->resize( 100, this->sizeHint().height() ); } /* @@ -241,224 +148,27 @@ void VisuGUI_NonIsometricDlg::onClickOk() accept(); } -void VisuGUI_NonIsometricDlg::onClickApply() -{ - bool changed = false; +void VisuGUI_NonIsometricDlg::onClickApply(){ QAD_StudyFrame* sf = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame(); - if ( sf->getTypeView() == VIEW_VTK ) - { - int Xfunction = m_cbXfunction->currentItem(); - int Yfunction = m_cbYfunction->currentItem(); - int Zfunction = m_cbZfunction->currentItem(); - - - VTKViewer_ViewFrame* vf = (VTKViewer_ViewFrame*) ( sf->getRightFrame()->getViewFrame() ); - VTKViewer_NonIsometricTransform *aTransform = vf->getNonIsometricTransform(); - - vtkRenderer* Renderer = vf->getRenderer(); - vtkActorCollection* theActors = Renderer->GetActors(); - theActors->InitTraversal(); - vtkActor *actor = theActors->GetNextActor(); - - aTransform->SetFunction( AxisFunction::XAxis, - (VTKViewer_NonIsometricTransform::Function) Xfunction, - m_sbXcoeff->value() ); - - aTransform->SetFunction( AxisFunction::YAxis, - (VTKViewer_NonIsometricTransform::Function) Yfunction, - m_sbYcoeff->value() ); - - aTransform->SetFunction( AxisFunction::ZAxis, - (VTKViewer_NonIsometricTransform::Function) Zfunction, - m_sbZcoeff->value() ); + SALOME_Selection* Sel = SALOME_Selection::Selection( sf->getStudy()->getSelection() ); - while( actor ) - { - //SALOME_Actor* pSA = dynamic_cast (actor); - SALOME_Actor* pSA = dynamic_cast (actor); - if (pSA) - { - //MESSAGE (actor->GetMapper()->GetClassName ()) - vtkPolyDataMapper* mapper = NULL; - vtkMapper* initialMapper = pSA->GetInitialMapper(); - if ( initialMapper == NULL ) - initialMapper = actor->GetMapper(); - if ( initialMapper->IsA("vtkDataSetMapper") ) - mapper = vtkDataSetMapper::SafeDownCast( initialMapper )->GetPolyDataMapper (); - else - mapper = vtkPolyDataMapper::SafeDownCast( initialMapper ); - //MESSAGE (mapper->GetClassName ()) - if (mapper) - { - //create transformation + if( VTKViewer_ViewFrame* vf = dynamic_cast(sf->getRightFrame()->getViewFrame())){ + double aScale[3] = {m_sbXcoeff->value(), m_sbYcoeff->value(), m_sbZcoeff->value()}; + vf->SetScale(aScale); + } - //create Filter - vtkTransformPolyDataFilter *aTransformFilter = vtkTransformPolyDataFilter::New(); - aTransformFilter->SetInput ( mapper->GetInput() ); - aTransformFilter->SetTransform (aTransform); - - //create new mapper - vtkDataSetMapper *aMapper = vtkDataSetMapper::New(); - aMapper->SetInput (aTransformFilter->GetOutput()); - aMapper->ShallowCopy ( actor->GetMapper()); - - //set new mapper - actor->SetMapper (aMapper); - - aTransformFilter->Delete(); - aMapper->Delete(); - changed = true; - } - } - actor = theActors->GetNextActor(); - } - if (changed) - vf->Repaint(); - //in order to improve perfomance - if ( !Xfunction && !Yfunction && !Zfunction ) - vf->setNonIsometricTransform( NULL ); - } + SALOME_ListIteratorOfListIO Itinit( Sel->StoredIObjects() ); + for (; Itinit.More(); Itinit.Next()) { + sf->getStudy()->highlight(Itinit.Value(), true); + } } void VisuGUI_NonIsometricDlg::onClickReset() { - //it's workaround for QComboBox - it doesn't send activated signal using setCurrentItem function - //therefore we connect on highlighted signal, use setCurrentItem() and disconnect highlighted signal - - connect (m_cbXfunction, SIGNAL( highlighted ( const QString& ) ), this, SLOT( onFunctionChanged ( ) ) ); - - m_cbXfunction->setCurrentItem ( 0 ); - m_cbXfunction->disconnect( SIGNAL( highlighted ( const QString& ) ) ); - - connect (m_cbYfunction, SIGNAL( highlighted ( const QString& ) ), this, SLOT( onFunctionChanged ( ) ) ); - m_cbYfunction->setCurrentItem ( 0 ); - m_cbYfunction->disconnect( SIGNAL( highlighted ( const QString& ) ) ); - - connect (m_cbZfunction, SIGNAL( highlighted ( const QString& ) ), this, SLOT( onFunctionChanged ( ) ) ); - m_cbZfunction->setCurrentItem ( 0 ); - m_cbZfunction->disconnect( SIGNAL( highlighted ( const QString& ) ) ); -} - -//Populates combobox and makes all needed connects -void VisuGUI_NonIsometricDlg::FillComboBox(QComboBox* cb) -{ - cb->insertItem( tr ("None") ); - cb->insertItem ( tr ("Linear") ); -// cb->insertItem ( tr ("Logarithmic") ); - - - connect (cb, SIGNAL( activated ( const QString& ) ), this, SLOT( onFunctionChanged ( ) ) ); - - //it's workaround for QComboBox - it doesn't send activated signal using setCurrentItem function - //therefore we connect on highlighted signal, use setCurrentItem() and disconnect highlighted signal - cb->setCurrentItem ( 1 ); - connect (cb, SIGNAL( highlighted ( const QString& ) ), this, SLOT( onFunctionChanged ( ) ) ); - cb->setCurrentItem ( 0 ); - cb->disconnect( SIGNAL( highlighted ( const QString& ) ) ); - + m_bReset->setFocus(); + m_sbXcoeff->setValue( 1.0 ); + m_sbYcoeff->setValue( 1.0 ); + m_sbZcoeff->setValue( 1.0 ); } -void VisuGUI_NonIsometricDlg::onFunctionChanged() -{ - //TODO - const QComboBox* cbFunction = (const QComboBox* ) sender(); - FunctionChanged(cbFunction); -} - -void VisuGUI_NonIsometricDlg::FunctionChanged(const QComboBox* cbFunction ) -{ - //TODO - const QString & function = cbFunction-> currentText(); - QAD_SpinBoxDbl* sbCoeff; - QLabel* lFunction; - QString axis; - QString formula; - //this variable stores index in bounds array for vtkRenderer - // 0 - xmin, xmax - // 2 - ymin, ymax - // 4 - zmin, zmax - int boundIndex; - - if (cbFunction == m_cbXfunction) - { - sbCoeff = m_sbXcoeff; - lFunction = m_lXFunction; - axis = "x"; - boundIndex = 0; - } - else - if (cbFunction == m_cbYfunction) - { - sbCoeff = m_sbYcoeff; - lFunction = m_lYFunction; - axis = "y"; - boundIndex = 2; - } - else - if (cbFunction == m_cbZfunction) - { - sbCoeff = m_sbZcoeff; - lFunction = m_lZFunction; - axis = "z"; - boundIndex = 4; - } - else - return ; - - sbCoeff->setEnabled (TRUE); - formula = axis; - - if ( function == tr ("None") ) - { - sbCoeff->setMinValue( 1.0 ); - sbCoeff->setMaxValue( 1.0 ); - sbCoeff->setValue( 1.0 ); - sbCoeff->setEnabled ( FALSE ); - formula += QString(" = "); - formula += axis; - lFunction->setText( formula ); - } - else - if ( function == tr ("Linear") ) - { - sbCoeff->setMinValue( -1.7E308 ); - sbCoeff->setMaxValue( 1.7E+308 ); - // sbCoeff->setValue( 1.0 ); - formula += QString(" = k"); - formula += axis; - lFunction->setText( formula ); - } - else - if ( function == tr ("Logarithmic") ) - { - // TODO - QAD_StudyFrame* sf = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame(); - if ( sf->getTypeView() == VIEW_VTK ) - { - vtkRenderer* Renderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer(); - float bounds[6]; - Renderer->ComputeVisiblePropBounds (bounds); - //we use following formula lg (x+a) and x+a >= 1 - //therefore a >= 1-x - double minValue; - if ( bounds[boundIndex] > 0 && bounds[boundIndex+1] > 0 ) - minValue = 1 - bounds[boundIndex+1]; - else - minValue = 1 - bounds[boundIndex]; - MESSAGE ( "Bounds " << bounds[0] << " " << bounds[1] << " " << bounds[2] << " " << bounds[3] << " " << bounds[4] << " " << bounds[5] << " " ) - sbCoeff->setMinValue( minValue ); - sbCoeff->setMaxValue( 1.7E+308 ); - sbCoeff->setValue( minValue ); - formula += QString(" = lg("); - formula += axis; - formula += QString("+a), a >= %1").arg( minValue ); - } - else - { - sbCoeff->setEnabled (FALSE); - formula = ""; - } - lFunction->setText( formula ); - } -} diff --git a/src/VISUGUI/VisuGUI_NonIsometricDlg.h b/src/VISUGUI/VisuGUI_NonIsometricDlg.h index 074b5b3c..1169a5e3 100644 --- a/src/VISUGUI/VisuGUI_NonIsometricDlg.h +++ b/src/VISUGUI/VisuGUI_NonIsometricDlg.h @@ -1,51 +1,40 @@ -// File : VisuGUI_NonIsometricDlg.h -// Created : Thu Dec 18 12:01:00 2002 -// Author : Vasily Rusyaev -// Project : SALOME PRO -// Module : SALOMEGUI -// Copyright : Open CASCADE +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VisuGUI_NonIsometricDlg.h +// Author : Vasily Rusyaev +// Module : VISU // $Header$ #ifndef VisuGUI_NONISOMETRICDLG_H #define VisuGUI_NONISOMETRICDLG_H #include -class QLabel; class QAD_SpinBoxDbl; -class QComboBox; +class QPushButton; class VisuGUI_NonIsometricDlg : public QDialog { Q_OBJECT - public: +public: VisuGUI_NonIsometricDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); ~VisuGUI_NonIsometricDlg(); - private: - - QComboBox* m_cbXfunction; +private: QAD_SpinBoxDbl* m_sbXcoeff; - QLabel* m_lXFunction; - - QComboBox* m_cbYfunction; QAD_SpinBoxDbl* m_sbYcoeff; - QLabel* m_lYFunction; - - QComboBox* m_cbZfunction; QAD_SpinBoxDbl* m_sbZcoeff; - QLabel* m_lZFunction; - - //Populates combobox and makes all needed connects - void FillComboBox(QComboBox* cb); - - void FunctionChanged( const QComboBox* cbox); + QPushButton* m_bReset ; - private slots: - void onClickApply(); - void onClickReset(); - void onClickOk(); - void onFunctionChanged(); +private slots: + void onClickApply(); + void onClickReset(); + void onClickOk(); + void onFunctionChanged(); }; #endif // VisuGUI_NONISOMETRICDLG_H diff --git a/src/VISUGUI/VisuGUI_PartialScaDlg.cxx b/src/VISUGUI/VisuGUI_PartialScaDlg.cxx index e3e8557c..24dc6c65 100644 --- a/src/VISUGUI/VisuGUI_PartialScaDlg.cxx +++ b/src/VISUGUI/VisuGUI_PartialScaDlg.cxx @@ -1,12 +1,32 @@ -using namespace std; -// File : VisuGUI_PartialScaDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_PartialScaDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_PartialScaDlg.h" #include diff --git a/src/VISUGUI/VisuGUI_PartialScaDlg.h b/src/VISUGUI/VisuGUI_PartialScaDlg.h index b1ec05de..00342e43 100644 --- a/src/VISUGUI/VisuGUI_PartialScaDlg.h +++ b/src/VISUGUI/VisuGUI_PartialScaDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_PartialScaDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_PartialScaDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_PARTIALSCADLG_H diff --git a/src/VISUGUI/VisuGUI_PhaseDlg.cxx b/src/VISUGUI/VisuGUI_PhaseDlg.cxx index 74746811..a677d481 100644 --- a/src/VISUGUI/VisuGUI_PhaseDlg.cxx +++ b/src/VISUGUI/VisuGUI_PhaseDlg.cxx @@ -1,12 +1,32 @@ -using namespace std; -// File : VisuGUI_PhaseDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_PhaseDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_PhaseDlg.h" #include diff --git a/src/VISUGUI/VisuGUI_PhaseDlg.h b/src/VISUGUI/VisuGUI_PhaseDlg.h index 1a0933c2..428c813e 100644 --- a/src/VISUGUI/VisuGUI_PhaseDlg.h +++ b/src/VISUGUI/VisuGUI_PhaseDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_PhaseDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_PhaseDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_PHASEDLG_H diff --git a/src/VISUGUI/VisuGUI_PhaseMagnitudeDlg.cxx b/src/VISUGUI/VisuGUI_PhaseMagnitudeDlg.cxx index b3d6ece2..dc94dc2e 100644 --- a/src/VISUGUI/VisuGUI_PhaseMagnitudeDlg.cxx +++ b/src/VISUGUI/VisuGUI_PhaseMagnitudeDlg.cxx @@ -1,12 +1,32 @@ -using namespace std; -// File : VisuGUI_PhaseMagnitudeDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_PhaseMagnitudeDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_PhaseMagnitudeDlg.h" #include diff --git a/src/VISUGUI/VisuGUI_PhaseMagnitudeDlg.h b/src/VISUGUI/VisuGUI_PhaseMagnitudeDlg.h index 0c9baa48..fae0c39d 100644 --- a/src/VISUGUI/VisuGUI_PhaseMagnitudeDlg.h +++ b/src/VISUGUI/VisuGUI_PhaseMagnitudeDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_PhaseMagnitudeDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_PhaseMagnitudeDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_PHASEMAGNITUDEDLG_H diff --git a/src/VISUGUI/VisuGUI_PointsResultsDlg.cxx b/src/VISUGUI/VisuGUI_PointsResultsDlg.cxx index 7231f86f..06bd3ebb 100644 --- a/src/VISUGUI/VisuGUI_PointsResultsDlg.cxx +++ b/src/VISUGUI/VisuGUI_PointsResultsDlg.cxx @@ -1,12 +1,32 @@ -using namespace std; -// File : VisuGUI_PointsResultsDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_PointsResultsDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_PointsResultsDlg.h" #include diff --git a/src/VISUGUI/VisuGUI_PointsResultsDlg.h b/src/VISUGUI/VisuGUI_PointsResultsDlg.h index 76be17c8..9adc0f80 100644 --- a/src/VISUGUI/VisuGUI_PointsResultsDlg.h +++ b/src/VISUGUI/VisuGUI_PointsResultsDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_PointsResultsDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_PointsResultsDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_POINTSRESULTSDLG_H diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx index 26be0c44..1694a48d 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx @@ -1,21 +1,42 @@ -using namespace std; -// File : VisuGUI_ScalarBarDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_ScalarBarDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_ScalarBarDlg.h" #include #include +#include #include "QAD_Application.h" #include "QAD_Desktop.h" #include "QAD_Config.h" +#include "QAD_MessageBox.h" #include "VISU_Convertor.hxx" - /*! Constructor */ @@ -28,13 +49,15 @@ VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg(bool SetPref) myVerX = 0.01; myVerY = 0.10; myVerW = 0.10; myVerH = 0.80; myHorX = 0.20; myHorY = 0.01; myHorW = 0.60; myHorH = 0.12; + Imin = 0.0; Imax = 0.0; Fmin = 0.0; Fmax = 0.0; Rmin = 0.0; Rmax = 0.0; + myRangeMode = -1; QVBoxLayout* TopLayout = new QVBoxLayout( this ); TopLayout->setSpacing( 6 ); TopLayout->setMargin( 11 ); // Range ============================================================ - QButtonGroup* RangeGroup = new QButtonGroup( tr( "Scalar range" ), this, "RangeGroup" ); + RangeGroup = new QButtonGroup( tr( "Scalar range" ), this, "RangeGroup" ); RangeGroup->setColumnLayout(0, Qt::Vertical ); RangeGroup->layout()->setSpacing( 0 ); RangeGroup->layout()->setMargin( 0 ); @@ -56,21 +79,23 @@ VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg(bool SetPref) RBFrange = new QRadioButton( tr( "Use field range" ), RangeGroup, "RBFrange" ); RBIrange = new QRadioButton( tr( "Use imposed range" ), RangeGroup, "RBIrange" ); - RBIrange->setChecked( true ); + RBFrange->setChecked( true ); - MinSpin = new QAD_SpinBoxDbl( RangeGroup, -DBL_MAX, DBL_MAX, 0.1 ); - MinSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - MinSpin->setMinimumWidth( 70 ); - MinSpin->setValue( 0 ); + MinEdit = new QLineEdit( RangeGroup, "MinEdit" ); + MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + MinEdit->setMinimumWidth( 70 ); + MinEdit->setValidator( new QDoubleValidator(this) ); + MinEdit->setText( "0.0" ); QLabel* MinLabel = new QLabel( tr( "Min:" ), RangeGroup, "MinLabel" ); - MinLabel->setBuddy(MinSpin); + MinLabel->setBuddy(MinEdit); - MaxSpin = new QAD_SpinBoxDbl( RangeGroup, -DBL_MAX, DBL_MAX, 0.1 ); - MaxSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - MaxSpin->setMinimumWidth( 70 ); - MaxSpin->setValue( 0 ); + MaxEdit = new QLineEdit( RangeGroup, "MaxEdit" ); + MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + MaxEdit->setMinimumWidth( 70 ); + MaxEdit->setValidator( new QDoubleValidator(this) ); + MaxEdit->setText( "0.0" ); QLabel* MaxLabel = new QLabel( tr( "Max:" ), RangeGroup, "MaxLabel" ); - MaxLabel->setBuddy(MaxSpin); + MaxLabel->setBuddy(MaxEdit); RangeGroupLayout->addWidget( myModeLbl, 0, 0 ); RangeGroupLayout->addMultiCellWidget( myModeCombo, 0, 0, 1, 3); @@ -78,9 +103,9 @@ VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg(bool SetPref) RangeGroupLayout->addMultiCellWidget( RBFrange, 2, 2, 0, 1); RangeGroupLayout->addMultiCellWidget( RBIrange, 2, 2, 2, 3); RangeGroupLayout->addWidget( MinLabel, 3, 0 ); - RangeGroupLayout->addWidget( MinSpin, 3, 1 ); + RangeGroupLayout->addWidget( MinEdit, 3, 1 ); RangeGroupLayout->addWidget( MaxLabel, 3, 2 ); - RangeGroupLayout->addWidget( MaxSpin, 3, 3 ); + RangeGroupLayout->addWidget( MaxEdit, 3, 3 ); TopLayout->addWidget( RangeGroup ); @@ -95,7 +120,7 @@ VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg(bool SetPref) ColLabGroupLayout->setMargin( 11 ); QLabel* ColorLabel = new QLabel( tr( "Nb. of colors:" ), ColLabGroup, "ColorLabel" ); - ColorSpin = new QSpinBox( 2, 64, 1, ColLabGroup ); + ColorSpin = new QSpinBox( 2, 256, 1, ColLabGroup ); ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); ColorSpin->setMinimumWidth( 70 ); ColorSpin->setValue( 64 ); @@ -361,8 +386,8 @@ void VisuGUI_ScalarBarDlg::storeToResources() { } bool sbRange = RBIrange->isChecked(); - float sbVmin = MinSpin->value(); - float sbVmax = MaxSpin->value(); + float sbVmin = (float)(MinEdit->text().toDouble()); + float sbVmax = (float)(MaxEdit->text().toDouble()); if(sbVmin > sbVmax) { sbVmin=0.; @@ -406,6 +431,9 @@ void VisuGUI_ScalarBarDlg::initFromPrsObject(VISU::ScalarMap_i* thePrs) { default: setLogarithmic(false); } + float aRange[2]; + thePrs->GetFieldRange(aRange); + Rmin = aRange[0]; Rmax = aRange[1]; setRange( thePrs->GetMin(), thePrs->GetMax(), 0.0, 0.0, thePrs->isRangeFixed() ); setScalarBarData( thePrs->GetNbColors(), thePrs->GetLabels() ); @@ -423,15 +451,15 @@ void VisuGUI_ScalarBarDlg::storeToPrsObject(VISU::ScalarMap_i* thePrs) { thePrs->SetPosition(XSpin->value(), YSpin->value()); thePrs->SetSize(WidthSpin->value(), HeightSpin->value()); thePrs->SetOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL); - if(isLogarithmic()) - thePrs->SetScaling(VISU::LOGARITHMIC); - else - thePrs->SetScaling(VISU::LINEAR); if (RBFrange->isChecked()) { thePrs->CalculateRange(); } else { - thePrs->SetRange(MinSpin->value(), MaxSpin->value()); + thePrs->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble()); } + if(isLogarithmic()) + thePrs->SetScaling(VISU::LOGARITHMIC); + else + thePrs->SetScaling(VISU::LINEAR); thePrs->SetNbColors(ColorSpin->value()); thePrs->SetLabels(LabelSpin->value()); thePrs->Update(); @@ -465,24 +493,36 @@ void VisuGUI_ScalarBarDlg::changeDefaults( int ) */ void VisuGUI_ScalarBarDlg::changeRange( int ) { + int mode = -1; + if ( RBFrange->isChecked() ) + mode = 0; + if ( RBIrange->isChecked() ) + mode = 1; + if ( myRangeMode == mode ) + return; //MinSpin->setMaxValue( Fmin ); //MaxSpin->setMinValue( Fmax ); if ( RBFrange->isChecked() ) { //MinLabel->setEnabled( false ); - MinSpin->setEnabled( false ); + MinEdit->setEnabled( false ); //MaxLabel->setEnabled( false ); - MaxSpin->setEnabled( false ); - MinSpin->setValue( Fmin ); - MaxSpin->setValue( Fmax ); + MaxEdit->setEnabled( false ); + if ( mode != -1 ) { + Imin = MinEdit->text().toDouble(); + Imax = MaxEdit->text().toDouble(); + } + MinEdit->setText( QString::number( Rmin ) ); + MaxEdit->setText( QString::number( Rmax ) ); } else { //MinLabel->setEnabled( true ); - MinSpin->setEnabled( true ); + MinEdit->setEnabled( true ); //MaxLabel->setEnabled( true ); - MaxSpin->setEnabled( true ); - MinSpin->setValue( Imin ); - MaxSpin->setValue( Imax ); + MaxEdit->setEnabled( true ); + MinEdit->setText( QString::number( Imin ) ); + MaxEdit->setText( QString::number( Imax ) ); } + myRangeMode = mode; } /*! @@ -505,6 +545,15 @@ void VisuGUI_ScalarBarDlg::XYChanged( double ) void VisuGUI_ScalarBarDlg::setRange( double imin, double imax, double fmin, double fmax, bool sbRange ) { Imin = imin; Imax = imax; Fmin = fmin; Fmax = fmax; + if ( RBIrange->isChecked() ) { + MinEdit->setText( QString::number( Imin ) ); + MaxEdit->setText( QString::number( Imax ) ); + } + else { + MinEdit->setText( QString::number( Rmin ) ); + MaxEdit->setText( QString::number( Rmax ) ); + } + myRangeMode = -1; if( sbRange ) RBIrange->setChecked( true ); else @@ -615,7 +664,7 @@ bool VisuGUI_ScalarBarDlg::isIRange() */ double VisuGUI_ScalarBarDlg::getMin() { - return MinSpin->value(); + return MinEdit->text().toDouble(); } /*! @@ -623,7 +672,7 @@ double VisuGUI_ScalarBarDlg::getMin() */ double VisuGUI_ScalarBarDlg::getMax() { - return MaxSpin->value(); + return MaxEdit->text().toDouble(); } /*! @@ -649,3 +698,52 @@ void VisuGUI_ScalarBarDlg::setLogarithmic( bool on ) { CBLog->setChecked( on ); } + +/*! + Called when button is clicked, validates data and closes dialog +*/ +void VisuGUI_ScalarBarDlg::accept() +{ + double minVal = MinEdit->text().toDouble(); + double maxVal = MaxEdit->text().toDouble(); + if ( RBIrange->isChecked() ) { + if (minVal >= maxVal) { + QAD_MessageBox::warn1( this,tr("VISU_WARNING"), + tr("MSG_MINMAX_VALUES"), + tr("VISU_BUT_OK")); + return; + } + } + // check if logarithmic mode is on and check imposed range to not contain negative values + if ( CBLog->isChecked() ) { + if ( RBIrange->isChecked() ) { + if ( (minVal > 0) && (maxVal > 0) ) { + // nothing to do + } + else { + QAD_MessageBox::warn1( this, + tr("VISU_WARNING"), + tr("WRN_LOGARITHMIC_RANGE"), + tr("VISU_BUT_OK")); + return; + } + } + else { + if ( Rmin > 0 && Rmax > 0 ) { + // nothing to do + } + else { + QAD_MessageBox::warn1( this, + tr("VISU_WARNING"), + tr("WRN_LOGARITHMIC_FIELD_RANGE"), + tr("VISU_BUT_OK")); + RBIrange->setChecked(1); + changeRange(1); + //MinEdit->setText( QString::number( Rmin ) ); + //MaxEdit->setText( QString::number( Rmax ) ); + return; + } + } + } + QDialog::accept(); +} diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.h b/src/VISUGUI/VisuGUI_ScalarBarDlg.h index ec665bb8..a1706e82 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.h +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_ScalarBarDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_ScalarBarDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_SCALARBARDLG_H @@ -57,10 +77,11 @@ public: protected: + QButtonGroup* RangeGroup; QRadioButton* RBFrange; QRadioButton* RBIrange; - QAD_SpinBoxDbl* MinSpin; - QAD_SpinBoxDbl* MaxSpin; + QLineEdit* MinEdit; + QLineEdit* MaxEdit; QRadioButton* RBhori; QRadioButton* RBvert; @@ -79,9 +100,13 @@ protected: QLabel* myModeLbl; QComboBox* myModeCombo; - double Imin, Imax, Fmin, Fmax; + double Imin, Imax, Fmin, Fmax, Rmin, Rmax; double myHorX, myHorY, myHorW, myHorH; double myVerX, myVerY, myVerW, myVerH; + int myRangeMode; + +protected slots: + void accept(); private slots: void changeDefaults( int ); diff --git a/src/VISUGUI/VisuGUI_SelVectCompDlg.cxx b/src/VISUGUI/VisuGUI_SelVectCompDlg.cxx index 9644578d..adf9eb69 100644 --- a/src/VISUGUI/VisuGUI_SelVectCompDlg.cxx +++ b/src/VISUGUI/VisuGUI_SelVectCompDlg.cxx @@ -1,12 +1,32 @@ -using namespace std; -// File : VisuGUI_SelVectCompDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_SelVectCompDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_SelVectCompDlg.h" #include diff --git a/src/VISUGUI/VisuGUI_SelVectCompDlg.h b/src/VISUGUI/VisuGUI_SelVectCompDlg.h index f11ad40d..2f11bed0 100644 --- a/src/VISUGUI/VisuGUI_SelVectCompDlg.h +++ b/src/VISUGUI/VisuGUI_SelVectCompDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_SelVectCompDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_SelVectCompDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_SELVECTCOMPDLG_H diff --git a/src/VISUGUI/VisuGUI_Selection.cxx b/src/VISUGUI/VisuGUI_Selection.cxx index 8e72c078..ff359e22 100644 --- a/src/VISUGUI/VisuGUI_Selection.cxx +++ b/src/VISUGUI/VisuGUI_Selection.cxx @@ -1,175 +1,126 @@ -using namespace std; -// File : VisuGUI_Selection.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_Selection.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "utilities.h" -#include -#include #include "SALOME_ListIteratorOfListIO.hxx" - #include "SALOME_Selection.h" #include "VISU_Actor.h" +#include "VISU_PrsObject_i.hh" + +#include +#include #include -#include -#include -#include #include #include #include -#include -#include -#include -#include -#include #include #include -#include -#include #include "VisuGUI_CellsResultsDlg.h" #include "VisuGUI_PointsResultsDlg.h" #include "VisuGUI_Selection.h" - int mode=0; - int scal=0; - int vect=0; - char Msg[80]=""; - - int id=0; - char Msg_1[150]=""; - char Msg_2[150]=""; - float Coord[3]; - float ScalarValue=0; - float VectorValue[3]; - -int VisuGUI_Selection::PickViewer(QAD_Study *ActiveStudy, int mode) -{ - SALOME_Selection *Sel = SALOME_Selection::Selection(ActiveStudy->getSelection()); - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - for(;It.More();It.Next()) - { - Handle(SALOME_InteractiveObject)IObject = It.Value(); - if (Sel->SelectionMode() == mode ) // Selection MODE - { - if (Sel->HasIndex(IObject)) - { - TColStd_MapOfInteger MapIndex ; - Sel->GetIndex(IObject, MapIndex) ; - TColStd_MapIteratorOfMapOfInteger ite(MapIndex); - for (;ite.More(); ite.Next()) - { - MESSAGE("Cell ID =" << ite.Key()) - return (ite.Key()); - } - } +int PickViewer(QAD_Study *theActiveStudy, int theSelectionMode){ + SALOME_Selection *aSel = SALOME_Selection::Selection(theActiveStudy->getSelection()); + SALOME_ListIteratorOfListIO It(aSel->StoredIObjects()); + for(;It.More(); It.Next()){ + Handle(SALOME_InteractiveObject) IObject = It.Value(); + if (aSel->SelectionMode() == theSelectionMode ){ + if (aSel->HasIndex(IObject)) { + TColStd_MapOfInteger MapIndex ; + aSel->GetIndex(IObject, MapIndex) ; + TColStd_MapIteratorOfMapOfInteger ite(MapIndex); + for(;ite.More(); ite.Next()) + return ite.Key(); } + } } - return (-1); + return -1; } -void VisuGUI_Selection::PickingResults(QAD_Study *ActiveStudy, int mode, VISU_Actor *Actor) -{ - - if ( (mode == SelectionCell) || (mode == SelectionEdge) ) // Cell mode - { - PickingCell(ActiveStudy, Actor); - } - - else if (mode == SelectionPoint) // Point Mode - { - PickingPoint(ActiveStudy, Actor); - } +template void SetMessage(TData* theData, int theId, TDialog* theDialog){ + // Scalar result + QString Msg_1; + if (vtkDataArray *Scalar = theData->GetScalars()){ + float aVal = Scalar->GetTuple1(theId); + Msg_1.sprintf("%6.3g",aVal); + }else + Msg_1.sprintf("NO DATA"); + theDialog->ScalValue->setText( Msg_1.latin1() ); + + // Vector result + QString Msg_2; + if (vtkDataArray *Vector = theData->GetVectors()){ + float *aVal = Vector->GetTuple3(theId); + Msg_2.sprintf("%6.3g; %6.3g; %6.3g",aVal[0],aVal[1],aVal[2]); + }else + Msg_2.sprintf("NO DATA"); + theDialog->VectTxt->setText( Msg_2.latin1() ); } // ============================================================================================ // // PICKING CELL // // ============================================================================================ // -void VisuGUI_Selection::PickingCell(QAD_Study *ActiveStudy, VISU_Actor *Actor) -{ - vtkDataSet *Data ; - vtkScalars *Scalar; - vtkVectors *Vector; - vtkCell *Cell; - vtkIdList *PointList; - vtkCellData *CellData; - vtkPointData *PointData; - vtkPoints *Points = vtkPoints::New(); - float Point_Coord[12][3]; - float CoordCurrent[3]; - int idCurrent; - - mode = SelectionCell; - - vtkActor* anActor = vtkActor::SafeDownCast( Actor ); - id=PickViewer(ActiveStudy,mode); - if (id >= 0) // Cell exist - { - VisuGUI_CellsResultsDlg *ResultsDlg = new VisuGUI_CellsResultsDlg(QAD_Application::getDesktop(), 0, TRUE, 0); - - vtkDataSetMapper *Mapper = (vtkDataSetMapper*) (anActor->GetMapper()); - Mapper->SetInput(anActor->GetMapper()->GetInput()); - Data=Mapper->GetInput(); - Cell=Data->GetCell(id); - CellData=Data->GetCellData(); - int NbOfPoints=Cell->GetNumberOfPoints(); - PointList=Cell->GetPointIds(); - QListViewItem* item = 0; - for(int i=0; iGetId(i); - Data->GetPoint(idCurrent,CoordCurrent); - for (int j=0; j<3; j++) - Point_Coord[i][j]=CoordCurrent[j]; - item = new QListViewItem(ResultsDlg->ListPoints, - item, - QString::number( idCurrent ), - QString::number( Point_Coord[i][0] ), - QString::number( Point_Coord[i][1] ), - QString::number( Point_Coord[i][2] )); - } - - // Scalar result - Scalar=CellData->GetScalars(); - if (Scalar!=NULL) - { - scal = 1; - ScalarValue=Scalar->GetScalar(id); - sprintf(Msg_1,"( %s ) %4f",Actor->FieldName,ScalarValue); - } - else - { - scal = 2; - sprintf(Msg_1,"No scalar on Cell"); - } - - // Vector result - Vector=CellData->GetVectors(); - if (Vector!=NULL) - { - vect = 1; - Vector->GetVector(id,VectorValue); - sprintf(Msg_2,"( %s ) %.4f %.4f %.4f",Actor->FieldName,VectorValue[0],VectorValue[1],VectorValue[2]); - } - else - { - vect = 2; - sprintf(Msg_2,"No Vector on Cell"); - } - - ResultsDlg->IdCell->setText( QString::number( id ) ); - ResultsDlg->NbPoint->setText( QString::number( NbOfPoints ) ); - ResultsDlg->ScalValue->setText( Msg_1 ); - ResultsDlg->VectTxt->setText( Msg_2 ); - ResultsDlg->exec(); - delete ResultsDlg; +void VisuGUI_Selection::PickingCell(QAD_Study *theActiveStudy, vtkDataSet *theDataSet){ + int id = PickViewer(theActiveStudy,SelectionCell); + if(id >= 0){ + VisuGUI_CellsResultsDlg *aResultsDlg = new VisuGUI_CellsResultsDlg(QAD_Application::getDesktop(), 0, TRUE, 0); + vtkCellData *aData = theDataSet->GetCellData(); + vtkCell *aCell = theDataSet->GetCell(id); + + float aPntCoord[12][3]; + int aNbOfPoints = aCell->GetNumberOfPoints(); + vtkIdList *aPointList = aCell->GetPointIds(); + QListViewItem* anItem = NULL; + for(int i = 0; i < aNbOfPoints; i++){ + float aCoord[3]; + int idCurrent = aPointList->GetId(i); + theDataSet->GetPoint(idCurrent,aCoord); + for (int j=0; j<3; j++) + aPntCoord[i][j]=aCoord[j]; + anItem = new QListViewItem(aResultsDlg->ListPoints, + anItem, + QString::number( idCurrent ), + QString::number( aPntCoord[i][0] ), + QString::number( aPntCoord[i][1] ), + QString::number( aPntCoord[i][2] )); + } + + SetMessage(aData,id,aResultsDlg); + + aResultsDlg->IdCell->setText( QString::number( id ) ); + aResultsDlg->NbPoint->setText( QString::number( aNbOfPoints ) ); + aResultsDlg->exec(); + delete aResultsDlg; } } @@ -178,179 +129,29 @@ void VisuGUI_Selection::PickingCell(QAD_Study *ActiveStudy, VISU_Actor *Actor) // PICKING POINT // // ============================================================================================ // -void VisuGUI_Selection::PickingPoint(QAD_Study *ActiveStudy, VISU_Actor *Actor) -{ - vtkDataSet *Data ; - vtkScalars *Scalar; - vtkVectors *Vector; - vtkPointData *PointData; - - mode = SelectionPoint; - - id=PickViewer(ActiveStudy,mode); - if (id >= 0) - { - VisuGUI_PointsResultsDlg *ResultsDlg = new VisuGUI_PointsResultsDlg(QAD_Application::getDesktop(), 0, TRUE, 0); - vtkDataSetMapper *Mapper = (vtkDataSetMapper*) (Actor->GetMapper()); - Data=Mapper->GetInput(); - PointData=Data->GetPointData(); - - Data->GetPoint(id,Coord); - ResultsDlg->CoordX->setText( QString::number( Coord[0] ) ); - ResultsDlg->CoordY->setText( QString::number( Coord[1] ) ); - ResultsDlg->CoordZ->setText( QString::number( Coord[2] ) ); -// ActiveStudy->setMessage(Msg); - - Scalar=PointData->GetScalars(); - if (Scalar!=NULL) - { - scal = 1; - ScalarValue=Scalar->GetScalar(id); - sprintf(Msg_1,"( %s ) %4f",Actor->FieldName,ScalarValue); - } - else - { - scal = 2; - sprintf(Msg_1,"No scalar at Point"); - } -// ActiveStudy->setMessage(Msg_1); - - // Vector result - Vector=PointData->GetVectors(); - if (Vector!=NULL) - { - vect = 1; - Vector->GetVector(id,VectorValue); - sprintf(Msg_2,"( %s ) %.4f %.4f %.4f",Actor->FieldName,VectorValue[0],VectorValue[1],VectorValue[2]); - } - else - { - vect = 2; - sprintf(Msg_2,"No Vector at Point"); - } - ResultsDlg->IdPoint->setText( QString::number(id) ); - ResultsDlg->ScalValue->setText(Msg_1); - ResultsDlg->VectTxt->setText(Msg_2); - ResultsDlg->exec(); - delete ResultsDlg; - -// ActiveStudy->setMessage( Msg_2 ) ; +void VisuGUI_Selection::PickingPoint(QAD_Study *theActiveStudy, vtkDataSet *theDataSet){ + int id = PickViewer(theActiveStudy,SelectionPoint); + if(id >= 0){ + VisuGUI_PointsResultsDlg *aResultsDlg = new VisuGUI_PointsResultsDlg(QAD_Application::getDesktop(), 0, TRUE, 0); + vtkPointData *aData = theDataSet->GetPointData(); + + float Coord[3]; + theDataSet->GetPoint(id,Coord); + aResultsDlg->CoordX->setText( QString::number( Coord[0] ) ); + aResultsDlg->CoordY->setText( QString::number( Coord[1] ) ); + aResultsDlg->CoordZ->setText( QString::number( Coord[2] ) ); + aResultsDlg->IdPoint->setText( QString::number(id) ); + + SetMessage(aData,id,aResultsDlg); + + aResultsDlg->exec(); + delete aResultsDlg; } } -// ============================================================================================ // -// HIGHLIGHT CELL // -// ============================================================================================ // -// -void VisuGUI_Selection::HighlightCell(int idCell, VISU_Actor *Actor, vtkRenderer *ren) -{ - MESSAGE("HighlightCell") - vtkActor *Cell_Actor = vtkActor::New(); - - vtkUnstructuredGrid* Cell_UGrid = vtkUnstructuredGrid::New(); - if ( Actor->GetMapper()->GetInput()->IsA("vtkUnstructuredGrid") ) { - vtkUnstructuredGrid* UGrid = vtkUnstructuredGrid::SafeDownCast( Actor->GetMapper()->GetInput() ); -// if (UGrid != NULL) // LCO 1707 -// { - vtkIdList *ptIds = vtkIdList::New(); ptIds->Allocate(12); - vtkDataSetMapper* Cell_Mapper = vtkDataSetMapper::New(); - - Cell_UGrid->SetPoints( UGrid->GetPoints() ); - UGrid->GetCellPoints( idCell, ptIds ); - Cell_UGrid->InsertNextCell(Actor->GetMapper()->GetInput()->GetCellType( idCell ), ptIds); - - Cell_Mapper->SetInput(Cell_UGrid); - Cell_Actor->SetMapper(Cell_Mapper); - - ren->AddActor( Cell_Actor ); - - Cell_Actor->GetProperty()->SetColor(1,1,0); - Cell_Actor->GetProperty()->SetRepresentationToSurface(); - Cell_Actor->VisibilityOn(); - - ren->Render(); - } // LCO - Cell_Actor->Delete(); -} - -// ============================================================================================ // -// HIGHLIGHT POINT // -// ============================================================================================ // -// -void VisuGUI_Selection::HighlightPoint(int idPoint, int nbPoints, VISU_Actor *Actor, vtkRenderer *ren) -{ - vtkActor *Point_Actor = vtkActor::New(); - - MESSAGE("HighlightPoint") - if ( Actor->GetMapper()->GetInput()->IsA("vtkUnstructuredGrid") ) { - vtkUnstructuredGrid* UGrid = vtkUnstructuredGrid::SafeDownCast( Actor->GetMapper()->GetInput() ); -// if (UGrid != NULL) // LCO 1707 -// { - vtkUnstructuredGrid* Point_UGrid = vtkUnstructuredGrid::New(); - float pts[3]; - - vtkPoints *Points = vtkPoints::New(); - vtkMaskPoints* verts = vtkMaskPoints::New(); - vtkPolyDataMapper* vertMapper = vtkPolyDataMapper::New(); - Points->SetNumberOfPoints(nbPoints); - - UGrid->GetPoint( idPoint, pts) ; - // Points->SetPoint(idPoint, 0., 0., 0. ); - Points->SetPoint(idPoint, pts); - Point_UGrid->SetPoints(Points); - verts->SetInput(Point_UGrid); - verts->SetGenerateVertices(1); - verts->SetOnRatio(1); - vertMapper->SetInput(verts->GetOutput()); - Point_Actor->SetMapper(vertMapper); - ren->AddActor( Point_Actor ); - Point_Actor->GetProperty()->SetColor(1,1,0); - Point_Actor->GetProperty()->SetRepresentationToSurface(); - Point_Actor->VisibilityOn(); - ren->Render(); - } //LCO - Point_Actor->Delete(); +void VisuGUI_Selection::Highlight(QAD_Study *theActiveStudy, const Handle(SALOME_InteractiveObject)& theIO, int theId){ + MESSAGE("HighlightCell"); + SALOME_Selection *aSel = SALOME_Selection::Selection(theActiveStudy->getSelection()); + aSel->AddIObject( theIO, false ); + aSel->AddOrRemoveIndex( theIO, theId, false, true ); } - -// ============================================================================================ // -// Function to return results individual // -// ============================================================================================ // - -int VisuGUI_Selection::getId() -{ - return (id); -} - -char *VisuGUI_Selection::getMsg(int nb) -{ - if (nb==1) - return (Msg_1); - else - return (Msg_2); -} - -float *VisuGUI_Selection::getCoord() -{ - return (Coord); -} - -float VisuGUI_Selection::getScalar() -{ - if (scal == 1) - return (ScalarValue); - else - return (0); -} - -float *VisuGUI_Selection::getVector() -{ - if (vect == 1) - return (VectorValue); - else - return (0); -} - -int VisuGUI_Selection::getMode() -{ - return (mode ); -} diff --git a/src/VISUGUI/VisuGUI_Selection.h b/src/VISUGUI/VisuGUI_Selection.h index c4aeed1b..09e43574 100644 --- a/src/VISUGUI/VisuGUI_Selection.h +++ b/src/VISUGUI/VisuGUI_Selection.h @@ -1,73 +1,49 @@ -// File : VisuGUI_Selection.h -// Created : Wed Apr 03 10:23:06 2002 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_Selection.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VisuGUI_Selection_HeaderFile #define VisuGUI_Selection_HeaderFile -#ifndef _Standard_HeaderFile -#include -#endif - +#include "SALOMEconfig.h" #include "QAD_Desktop.h" -#include -#include - -#include #include "VISU_Actor.h" +#include + #define SelectionPoint 1 #define SelectionEdge 2 #define SelectionCell 3 #define SelectionActor 4 -class VisuGUI_Selection -{ - -public : - -// Methods PUBLIC -// -// - -int PickViewer(QAD_Study *ActiveStudy, int mode); -void PickingResults(QAD_Study *ActiveStudy, int mode, VISU_Actor *Actor); - -void PickingCell(QAD_Study *ActiveStudy, VISU_Actor *Actor); -void PickingPoint(QAD_Study *ActiveStudy, VISU_Actor *Actor); -void HighlightCell(int idCell, VISU_Actor *Actor, vtkRenderer *ren); -void HighlightPoint(int idPoint, int nbPoints, VISU_Actor *Actor, vtkRenderer *ren); - -int getId(); -char *getMsg(int nb); -float *getCoord(); -float getScalar(); -float *getVector(); -int getMode(); - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // - +namespace VisuGUI_Selection{ + void PickingCell(QAD_Study *theActiveStudy, vtkDataSet *theDataSet); + void PickingPoint(QAD_Study *theActiveStudy, vtkDataSet *theDataSet); + void Highlight(QAD_Study *theActiveStudy, const Handle(SALOME_InteractiveObject)& theIO, int theId); }; #endif diff --git a/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx b/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx index aaa91c6f..44e46939 100644 --- a/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx +++ b/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx @@ -1,22 +1,29 @@ -// File : VisuGUI_StreamLinesDlg.cxx -// Created : 06 / 03 / 2003 -// Author : Vitaly SMETANNIKOV -// Project : SALOME -// Module : VISUGUI -// Copyright : Open CASCADE - +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VisuGUI_StreamLinesDlg.cxx +// Author : Vitaly SMETANNIKOV +// Module : VISU #include "VisuGUI_StreamLinesDlg.h" +#include #include #include #include #include "QAD_Application.h" #include "QAD_Desktop.h" #include "QAD_Config.h" +#include "VisuGUI.h" +#include "SALOME_Selection.h" + +extern VisuGUI *visuGUI; VisuGUI_StreamLinesDlg::VisuGUI_StreamLinesDlg() - : QDialog( QAD_Application::getDesktop(), "VisuGUI_StreamLinesDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) + : QDialog( QAD_Application::getDesktop(), "VisuGUI_StreamLinesDlg", false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) { setCaption("Stream lines Preferences"); setSizeGripEnabled( TRUE ); @@ -25,40 +32,96 @@ VisuGUI_StreamLinesDlg::VisuGUI_StreamLinesDlg() TopLayout->setSpacing( 6 ); TopLayout->setMargin( 11 ); + // Source box + QGroupBox* aSourceBox = new QGroupBox(tr("Source"), this); + aSourceBox->setColumnLayout(0, Qt::Vertical); + QGridLayout* aSrcLayout = new QGridLayout( aSourceBox->layout() ); + aSrcLayout->setSpacing( 6 ); + aSrcLayout->setMargin( 0 ); + + myUseSrcChk = new QCheckBox(tr("Use source presentation"), aSourceBox); + aSrcLayout->addMultiCellWidget(myUseSrcChk, 0, 0, 0, 1); + + mySrcCombo = new QComboBox(aSourceBox); + mySrcCombo->setEnabled(myUseSrcChk->isChecked()); + + // Find All prs obj + QAD_Study* aActiveStudy = VisuGUI::GetActiveStudy(); + SALOME_Selection* aSel = SALOME_Selection::Selection( aActiveStudy->getSelection() ); + if( aSel->IObjectCount() > 0 ) { + Handle(SALOME_InteractiveObject) aIO = aSel->firstIObject(); + if (aIO->hasEntry()){ + SALOMEDS::SObject_var aSObject = VisuGUI::GetStudyDocument()->FindObjectID(aIO->getEntry()); + SALOMEDS::SComponent_var aComp = aSObject->GetFatherComponent(); + SALOMEDS::ChildIterator_var aIter = VisuGUI::GetStudyDocument()->NewChildIterator( aComp ); + + for (aIter->InitEx(true); aIter->More(); aIter->Next() ) { + SALOMEDS::SObject_var aChildSObj = aIter->Value(); + CORBA::Object_var aChildObject = VISU::SObjectToObject( aChildSObj ); + if(!CORBA::is_nil( aChildObject ) ) { + VISU::Prs3d_var aPrsObj = VISU::Prs3d::_narrow( aChildObject ); + if( !CORBA::is_nil( aPrsObj ) ) { + if (aPrsObj->GetType() != VISU::TSTREAMLINES) { + SALOMEDS::GenericAttribute_var anAttr; + if ( aChildSObj->FindAttribute(anAttr, "AttributeName") ) { + SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); + mySrcCombo->insertItem(QString(aName->Value())); + myPrsList.append(aPrsObj); + } + } + } + } + } + } + } + + connect(myUseSrcChk, SIGNAL(toggled(bool)), mySrcCombo, SLOT(setEnabled(bool))); + aSrcLayout->addMultiCellWidget(mySrcCombo, 1, 1, 0, 1); + + QLabel* aPercentLbl = new QLabel( tr( "Used points (0..1)" ), aSourceBox); + aSrcLayout->addWidget(aPercentLbl, 2, 0); + + myPntPercent = new QAD_SpinBoxDbl( aSourceBox, 0, 1, 0.1); + aSrcLayout->addWidget(myPntPercent, 2, 1); + + TopLayout->addMultiCellWidget(aSourceBox, 0, 0, 0, 1); + + QLabel* aStepLenLbl = new QLabel( tr( "Step Length" ), this); - TopLayout->addWidget(aStepLenLbl, 0, 0); - myStepLen = new QAD_SpinBoxDbl( this); + TopLayout->addWidget(aStepLenLbl, 1, 0); + myStepLen = new QAD_SpinBoxDbl( this, DBL_MIN, DBL_MAX, 0.1); myStepLen->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - TopLayout->addWidget(myStepLen, 0, 1); + TopLayout->addWidget(myStepLen, 1, 1); QLabel* aIntegStepLenLbl = new QLabel( tr( "Integration Step" ), this); - TopLayout->addWidget(aIntegStepLenLbl, 1, 0); - myIntegStepLen = new QAD_SpinBoxDbl( this); + TopLayout->addWidget(aIntegStepLenLbl, 2, 0); + myIntegStepLen = new QAD_SpinBoxDbl( this, DBL_MIN, DBL_MAX, 0.1); myIntegStepLen->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - TopLayout->addWidget(myIntegStepLen, 1, 1); + TopLayout->addWidget(myIntegStepLen, 2, 1); QLabel* aPropagationLbl = new QLabel( tr( "Propagation Time" ), this); - TopLayout->addWidget(aPropagationLbl, 2, 0); - myPropTime = new QAD_SpinBoxDbl( this, 0, 1000, 10); + TopLayout->addWidget(aPropagationLbl, 3, 0); + myPropTime = new QAD_SpinBoxDbl( this, DBL_MIN, DBL_MAX, 1); myPropTime->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - TopLayout->addWidget(myPropTime, 2, 1); + TopLayout->addWidget(myPropTime, 3, 1); + + connect(myPropTime, SIGNAL(valueChanged(double)), this, SLOT(PropagationTimeChanged(double))); QLabel* aDirLbl = new QLabel( tr( "Direction" ), this); - TopLayout->addWidget(aDirLbl, 3, 0); + TopLayout->addWidget(aDirLbl, 4, 0); myDirCombo = new QComboBox(this); myDirCombo->insertItem("Forward"); myDirCombo->insertItem("Backward"); myDirCombo->insertItem("Both"); - TopLayout->addWidget(myDirCombo, 3, 1); + TopLayout->addWidget(myDirCombo, 4, 1); myUseScalar = new QCheckBox( tr( "Magnitude coloring" ), this, "UseMagn" ); - // TopLayout->addMultiCellWidget(myUseScalar, 4, 4, 0, 1); connect( myUseScalar, SIGNAL( clicked() ), this, SLOT( enableSetColor() ) ); - TopLayout->addWidget(myUseScalar, 4, 0); + TopLayout->addWidget(myUseScalar, 5, 0); SelColor = new QPushButton( tr( "Use Color" ), this, "SelColor" ); connect( SelColor, SIGNAL( clicked() ), this, SLOT( setVColor() ) ); - TopLayout->addWidget( SelColor, 4, 1); + TopLayout->addWidget( SelColor, 5, 1); QGroupBox* aGroupButtons = new QGroupBox( this, "GroupButtons" ); aGroupButtons->setColumnLayout(0, Qt::Vertical ); @@ -81,7 +144,7 @@ VisuGUI_StreamLinesDlg::VisuGUI_StreamLinesDlg() aGroupButtonsLayout->addWidget( aCancelBtn, 0, 2 ); connect( aOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) ); connect( aCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); - TopLayout->addMultiCellWidget( aGroupButtons, 5, 5, 0, 1 ); + TopLayout->addMultiCellWidget( aGroupButtons, 6, 6, 0, 1 ); enableSetColor(); } @@ -102,11 +165,30 @@ void VisuGUI_StreamLinesDlg::initFromPrsObject(VISU::StreamLines_i* thePrs) { myDirCombo->setCurrentItem(2); } myUseScalar->setChecked(thePrs->isColored()); + myPntPercent->setValue(thePrs->GetUsedPoints()); - setColor(QColor(thePrs->GetColor()[0]*255, - thePrs->GetColor()[1]*255, - thePrs->GetColor()[2]*255)); + myUseSrcChk->setChecked(false); + QString aSrcEntry = thePrs->GetSourceEntry(); + if (!aSrcEntry.isEmpty()) { + for (int i = 0; i < myPrsList.count(); i++) { + VISU::Prs3d_i* aPrs = dynamic_cast(VISU::GetServant(myPrsList[i])); + if (aSrcEntry == aPrs->GetEntry()) { + myUseSrcChk->setChecked(true); + mySrcCombo->setCurrentItem(i); + break; + } + } + } + + SALOMEDS::Color anOldColor = thePrs->GetColor(); + QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B)); + setColor(aColor); enableSetColor(); + + myIntegStepLen->setMaxValue(thePrs->GetMaxIntegrationStep()); + myIntegStepLen->setMinValue(thePrs->GetMinIntegrationStep()); + myStepLen->setMaxValue(myPropTime->value()); + myStepLen->setMinValue(myPropTime->value()/10000.); } @@ -126,13 +208,18 @@ void VisuGUI_StreamLinesDlg::storeToPrsObject(VISU::StreamLines_i* thePrs) { thePrs->SetDirection(VISU::StreamLines::BOTH); } thePrs->setColored(myUseScalar->isChecked()); - - float aColor[3]; - aColor[0] = myColor.red()/255.; - aColor[1] = myColor.green()/255.; - aColor[2] = myColor.blue()/255.; - - thePrs->SetColor(aColor); + if(!thePrs->isColored()){ + SALOMEDS::Color aColor; + aColor.R = myColor.red()/255.; + aColor.G = myColor.green()/255.; + aColor.B = myColor.blue()/255.; + thePrs->SetColor(aColor); + } + if (myUseSrcChk->isChecked() && (myPrsList.count() > 0)) { + thePrs->SetSource(myPrsList[mySrcCombo->currentItem()]); + } else + thePrs->SetSource(VISU::Prs3d::_nil()); + thePrs->SetUsedPoints(myPntPercent->value()); } /*! @@ -173,3 +260,8 @@ void VisuGUI_StreamLinesDlg::enableSetColor() SelColor->setEnabled(!myUseScalar->isChecked() ); } +void VisuGUI_StreamLinesDlg::PropagationTimeChanged(double theValue) { + myStepLen->setMaxValue(theValue); + myStepLen->setMinValue(theValue/1000000.); +} + diff --git a/src/VISUGUI/VisuGUI_StreamLinesDlg.h b/src/VISUGUI/VisuGUI_StreamLinesDlg.h index 94a6a1b0..1e1d9788 100644 --- a/src/VISUGUI/VisuGUI_StreamLinesDlg.h +++ b/src/VISUGUI/VisuGUI_StreamLinesDlg.h @@ -1,10 +1,12 @@ -// File : VisuGUI_StreamLinesDlg.h -// Created : 06 / 03 / 2003 -// Author : Vitaly SMETANNIKOV -// Project : SALOME -// Module : VISUGUI -// Copyright : Open CASCADE - +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VisuGUI_StreamLinesDlg.h +// Author : Vitaly SMETANNIKOV +// Module : VISU #ifndef VISUGUI_STREAMLINESDLG_H #define VISUGUI_STREAMLINESDLG_H @@ -28,6 +30,10 @@ public: void setColor( QColor color ); void enableMagnColor( bool enable ); +private slots: + void onSelectionActive(bool theActive); + void PropagationTimeChanged(double theValue); + private: QAD_SpinBoxDbl* myStepLen; QAD_SpinBoxDbl* myIntegStepLen; @@ -36,6 +42,10 @@ private: QCheckBox* myUseScalar; QPushButton* SelColor; QColor myColor; + QCheckBox* myUseSrcChk; + QAD_SpinBoxDbl* myPntPercent; + QComboBox* mySrcCombo; + QValueList myPrsList; private slots: void setVColor(); diff --git a/src/VISUGUI/VisuGUI_SweepPrefDlg.cxx b/src/VISUGUI/VisuGUI_SweepPrefDlg.cxx index afce7cfc..26d08600 100644 --- a/src/VISUGUI/VisuGUI_SweepPrefDlg.cxx +++ b/src/VISUGUI/VisuGUI_SweepPrefDlg.cxx @@ -1,12 +1,32 @@ -using namespace std; -// File : VisuGUI_SweepPrefDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_SweepPrefDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_SweepPrefDlg.h" #include diff --git a/src/VISUGUI/VisuGUI_SweepPrefDlg.h b/src/VISUGUI/VisuGUI_SweepPrefDlg.h index 5e3c3fd5..d6d5056f 100644 --- a/src/VISUGUI/VisuGUI_SweepPrefDlg.h +++ b/src/VISUGUI/VisuGUI_SweepPrefDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_SweepPrefDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_SweepPrefDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_SWEEPPREFDLG_H diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index b7a04f4c..2c971c41 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -1,10 +1,12 @@ -// File : VisuGUI_TimeAnimation.cxx -// Created : 28 / 03 / 2003 -// Author : Vitaly SMETANNIKOV -// Project : SALOME -// Module : VISUGUI -// Copyright : Open CASCADE - +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VisuGUI_TimeAnimation.cxx +// Author : Vitaly SMETANNIKOV +// Module : VISU #include "VisuGUI_TimeAnimation.h" #include "VisuGUI.h" @@ -17,7 +19,7 @@ #include #include #include - +#include #include "QAD_Application.h" #include "QAD_Desktop.h" @@ -61,9 +63,14 @@ SetupDlg::SetupDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator) QLabel* aMinLbl = new QLabel("From", aRangeGrp); aMinLbl->setEnabled(myUseRangeChk->isChecked()); aRangeLayout->addWidget(aMinLbl, 1, 0); - myMinVal = new QAD_SpinBoxDbl(aRangeGrp, -MAXVALUE, MAXVALUE, 0.1 ); + double aStep = (myAnimator->getMaxTime() - myAnimator->getMinTime())/(theAnimator->getFieldData(0).myNbTimes - 1); + myMinVal = new QAD_SpinBoxDbl(aRangeGrp, myAnimator->getMinTime(), myAnimator->getMaxTime(), aStep ); myMinVal->setEnabled(myUseRangeChk->isChecked()); - myMinVal->setValue( myAnimator->getMinRange() ); + if (myUseRangeChk->isChecked()) + myMinVal->setValue( myAnimator->getMinRange() ); + else + myMinVal->setValue( myAnimator->getMinTime() ); + connect(myMinVal, SIGNAL( valueChanged(double)), this, SLOT( onMinValue(double) )); aRangeLayout->addWidget(myMinVal, 1, 1); @@ -71,9 +78,13 @@ SetupDlg::SetupDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator) QLabel* aMaxLbl = new QLabel("To", aRangeGrp); aMaxLbl->setEnabled(myUseRangeChk->isChecked()); aRangeLayout->addWidget(aMaxLbl, 1, 2); - myMaxVal = new QAD_SpinBoxDbl(aRangeGrp, -MAXVALUE, MAXVALUE, 0.1 ); + myMaxVal = new QAD_SpinBoxDbl(aRangeGrp, myAnimator->getMinTime(), myAnimator->getMaxTime(), aStep ); myMaxVal->setEnabled(myUseRangeChk->isChecked()); - myMaxVal->setValue( myAnimator->getMaxRange() ); + if (myUseRangeChk->isChecked()) + myMaxVal->setValue( myAnimator->getMaxRange() ); + else + myMaxVal->setValue( myAnimator->getMaxTime() ); + connect(myMaxVal, SIGNAL( valueChanged(double)), this, SLOT( onMaxValue(double) )); aRangeLayout->addWidget(myMaxVal, 1, 3); @@ -211,7 +222,7 @@ void SetupDlg::onScalarBarDlg() { VisuGUI_ScalarBarDlg* aScalarBarDlg = new VisuGUI_ScalarBarDlg(); aScalarBarDlg->initFromPrsObject(aData.myPrs[0]); if (aScalarBarDlg->exec()) { - for (int i = 0; i < aData.myNbTimes; i++) + for (int i = 0; i < aData.myNbFrames; i++) aScalarBarDlg->storeToPrsObject(aData.myPrs[i]); } } @@ -230,7 +241,7 @@ void SetupDlg::onPreferencesDlg() { VisuGUI_IsoSurfacesDlg* aDlg = new VisuGUI_IsoSurfacesDlg(); aDlg->initFromPrsObject(dynamic_cast(aData.myPrs[0])); if (aDlg->exec()) { - for (int i = 0; i < aData.myNbTimes; i++) + for (int i = 0; i < aData.myNbFrames; i++) aDlg->storeToPrsObject(dynamic_cast(aData.myPrs[i])); } } @@ -240,7 +251,7 @@ void SetupDlg::onPreferencesDlg() { VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg(); aDlg->initFromPrsObject(dynamic_cast(aData.myPrs[0])); if (aDlg->exec()) { - for (int i = 0; i < aData.myNbTimes; i++) + for (int i = 0; i < aData.myNbFrames; i++) aDlg->storeToPrsObject(dynamic_cast(aData.myPrs[i])); } } @@ -250,7 +261,7 @@ void SetupDlg::onPreferencesDlg() { VisuGUI_MagnitudeDlg* aDlg = new VisuGUI_MagnitudeDlg(); aDlg->initFromPrsObject(dynamic_cast(aData.myPrs[0])); if (aDlg->exec()) { - for (int i = 0; i < aData.myNbTimes; i++) + for (int i = 0; i < aData.myNbFrames; i++) aDlg->storeToPrsObject(dynamic_cast(aData.myPrs[i])); } } @@ -260,7 +271,7 @@ void SetupDlg::onPreferencesDlg() { VisuGUI_VectorsDlg* aDlg = new VisuGUI_VectorsDlg(); aDlg->initFromPrsObject(dynamic_cast(aData.myPrs[0])); if (aDlg->exec()) { - for (int i = 0; i < aData.myNbTimes; i++) + for (int i = 0; i < aData.myNbFrames; i++) aDlg->storeToPrsObject(dynamic_cast(aData.myPrs[i])); } } @@ -270,7 +281,7 @@ void SetupDlg::onPreferencesDlg() { VisuGUI_StreamLinesDlg* aDlg = new VisuGUI_StreamLinesDlg(); aDlg->initFromPrsObject(dynamic_cast(aData.myPrs[0])); if (aDlg->exec()) { - for (int i = 0; i < aData.myNbTimes; i++) + for (int i = 0; i < aData.myNbFrames; i++) aDlg->storeToPrsObject(dynamic_cast(aData.myPrs[i])); } } @@ -288,10 +299,23 @@ void SetupDlg::onRangeCheck(bool theCheck) { if (!theCheck) myAnimator->setAnimationRange(0, 0); + else { + // if (myMinVal->value() < myMaxVal->value()) + myAnimator->setAnimationRange(myMinVal->value(), myMaxVal->value()); +// else if (myMinVal->value() > myMaxVal->value()) +// myAnimator->setAnimationRange(myMaxVal->value(), myMinVal->value()); +// else // equal case +// myAnimator->setAnimationRange(0, 0); + } } //************************************************************************ void SetupDlg::onMinValue(double theVal) { + if (theVal > myAnimator->getMaxRange()) { + myMinVal->setValue( myAnimator->getMinTime() ); + myMinVal->setFocus(); + return; + } for (int i = 0; i < myAnimator->getNbFields(); i++) myAnimator->clearData(myAnimator->getFieldData(i)); myAnimator->setAnimationRange(theVal, myAnimator->getMaxRange()); @@ -299,6 +323,11 @@ void SetupDlg::onMinValue(double theVal) { //************************************************************************ void SetupDlg::onMaxValue(double theVal) { + if (theVal < myAnimator->getMinRange()) { + myMaxVal->setValue( myAnimator->getMaxTime() ); + myMaxVal->setFocus(); + return; + } for (int i = 0; i < myAnimator->getNbFields(); i++) myAnimator->clearData(myAnimator->getFieldData(i)); myAnimator->setAnimationRange(myAnimator->getMinRange(), theVal); @@ -418,26 +447,29 @@ VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg(SALOMEDS::Study_var theStudy) { setCaption("Animation"); setSizeGripEnabled( TRUE ); - myStudy = theStudy; + isClosing = false; + myAnimator = new VISU_TimeAnimation(theStudy); myAnimator->setSpeed(1); myAnimator->setViewer(VisuGUI::GetVtkViewFrame()); connect( myAnimator, SIGNAL( frameChanged(long, double) ), this, SLOT( onExecution(long, double) ) ); + connect( myAnimator, SIGNAL( stopped() ), + this, SLOT( onStop() ) ); QVBoxLayout* aMainLayout = new QVBoxLayout(this, 7, 6); aMainLayout->setSpacing(5); - QPushButton* aSetupBtn = new QPushButton("Setup Animation...", this); - connect( aSetupBtn, SIGNAL( clicked() ), + mySetupBtn = new QPushButton("Setup Animation...", this); + connect( mySetupBtn, SIGNAL( clicked() ), this, SLOT( onSetupDlg() ) ); - aMainLayout->addWidget(aSetupBtn); + aMainLayout->addWidget(mySetupBtn); - QPushButton* aGenBtn = new QPushButton("Generate frames", this); - connect( aGenBtn, SIGNAL( clicked() ), + myGenBtn = new QPushButton("Generate frames", this); + connect( myGenBtn, SIGNAL( clicked() ), this, SLOT( createFrames() ) ); - aMainLayout->addWidget(aGenBtn); + aMainLayout->addWidget(myGenBtn); myPlayFrame = new QFrame(this); myPlayFrame->setFrameStyle(QFrame::WinPanel | QFrame::Sunken); @@ -510,32 +542,47 @@ VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg(SALOMEDS::Study_var theStudy) this, SLOT(onSpeedChange(double)) ); TopLayout->addMultiCellWidget(aWheel, 1, 3, 3, 3, Qt::AlignRight); + QCheckBox* aCycleCheck = new QCheckBox("Cycled animation",myPlayFrame); + aCycleCheck->setChecked(myAnimator->isCycling()); + connect(aCycleCheck, SIGNAL(toggled(bool)), myAnimator, SLOT(setCyclingSlot(bool))); + TopLayout->addMultiCellWidget(aCycleCheck, 5, 5, 0, 3); + QCheckBox* aPropCheck = new QCheckBox("Use proportional timing",myPlayFrame); aPropCheck->setChecked(myAnimator->isProportional()); - connect(aPropCheck, SIGNAL(toggled(bool)), myAnimator, SLOT(setProportional(bool))); - TopLayout->addMultiCellWidget(aPropCheck, 5, 5, 0, 3); + connect(aPropCheck, SIGNAL(toggled(bool)), myAnimator, SLOT(setProportionalSlot(bool))); + TopLayout->addMultiCellWidget(aPropCheck, 6, 6, 0, 3); + + QGroupBox* aSaveBox = new QGroupBox( "Saving", myPlayFrame ); + aSaveBox->setColumnLayout(0, Qt::Horizontal ); + QGridLayout* aSaveLay = new QGridLayout(aSaveBox->layout()); + aSaveLay->setSpacing( 5 ); + aSaveLay->setMargin( 5 ); - mySaveCheck = new QCheckBox("Save pictures to directory",myPlayFrame); - TopLayout->addMultiCellWidget(mySaveCheck, 6, 6, 0, 3); + mySaveCheck = new QCheckBox("Save pictures to directory", aSaveBox); + aSaveLay->addMultiCellWidget(mySaveCheck, 0, 0, 0, 2); - QLabel* aPathLbl = new QLabel("Path:", myPlayFrame); + QLabel* aPathLbl = new QLabel("Path:", aSaveBox); + aPathLbl->setEnabled(false); connect(mySaveCheck, SIGNAL( toggled(bool)), aPathLbl, SLOT( setEnabled(bool) )); - TopLayout->addWidget(aPathLbl, 7, 0); + aSaveLay->addWidget(aPathLbl, 1, 0); - myPathEdit = new QLineEdit(myPlayFrame); + myPathEdit = new QLineEdit(aSaveBox); + myPathEdit->setEnabled(false); connect(mySaveCheck, SIGNAL( toggled(bool)), myPathEdit, SLOT( setEnabled(bool) )); - TopLayout->addMultiCellWidget(myPathEdit, 7, 7, 1, 2); + aSaveLay->addWidget(myPathEdit, 1, 1); - QPushButton* aBrowseBtn = new QPushButton("Browse...", myPlayFrame); + QPushButton* aBrowseBtn = new QPushButton("Browse...", aSaveBox); + aBrowseBtn->setEnabled(false); connect(mySaveCheck, SIGNAL( toggled(bool)), aBrowseBtn, SLOT( setEnabled(bool) )); connect(aBrowseBtn, SIGNAL( clicked()), this, SLOT( onBrowse() )); - mySaveCheck->setChecked(false); - TopLayout->addWidget(aBrowseBtn, 7, 3); + aSaveLay->addWidget(aBrowseBtn, 1, 2); + + TopLayout->addMultiCellWidget(aSaveBox, 7, 7, 0, 3); aMainLayout->addWidget(myPlayFrame); @@ -554,9 +601,7 @@ VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg(SALOMEDS::Study_var theStudy) //************************************************************************ VisuGUI_TimeAnimationDlg::~VisuGUI_TimeAnimationDlg() { - VTKViewer_ViewFrame* aView = myAnimator->getViewer(); delete myAnimator; - aView->Repaint(); } @@ -588,12 +633,14 @@ void VisuGUI_TimeAnimationDlg::createFrames() { myAnimator->generatePresentations(i); } mySlider->setMaxValue(myAnimator->getNbFrames()-1); + myPlayFrame->setEnabled(true); if (!myAnimator->generateFrames()) { QApplication::restoreOverrideCursor(); - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), "Defined presentation can not be created"); + //myPlayFrame->setEnabled(false); + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), myAnimator->getLastErrorMsg()); return; } - myPlayFrame->setEnabled(true); + //myPlayFrame->setEnabled(true); QApplication::restoreOverrideCursor(); } @@ -607,37 +654,38 @@ void VisuGUI_TimeAnimationDlg::onPlayPressed() { myAnimator->dumpTo(myPathEdit->text()); else myAnimator->dumpTo(""); + mySetupBtn->setEnabled(false); + myGenBtn->setEnabled(false); myAnimator->startAnimation(); } else { myPlayBtn->setIconSet(MYplayPixmap); myAnimator->stopAnimation(); + mySetupBtn->setEnabled(true); + myGenBtn->setEnabled(true); } } //************************************************************************ void VisuGUI_TimeAnimationDlg::onBackPressed() { - stopAnimation(); + //stopAnimation(); myAnimator->prevFrame(); } //************************************************************************ void VisuGUI_TimeAnimationDlg::onForvardPressed() { - stopAnimation(); myAnimator->nextFrame(); } //************************************************************************ void VisuGUI_TimeAnimationDlg::onLastPressed() { - stopAnimation(); myAnimator->lastFrame(); } //************************************************************************ void VisuGUI_TimeAnimationDlg::onFirstPressed() { - stopAnimation(); myAnimator->firstFrame(); } @@ -651,9 +699,13 @@ void VisuGUI_TimeAnimationDlg::clearView() { //************************************************************************ void VisuGUI_TimeAnimationDlg::closeEvent(QCloseEvent* theEvent) { - stopAnimation(); - clearView(); - QDialog::closeEvent(theEvent); + myAnimator->stopAnimation(); + if (myAnimator->running() && (! myAnimator->finished())) { + isClosing = true; + myEvent = theEvent; + } else { + QDialog::closeEvent(theEvent); + } } @@ -675,6 +727,8 @@ void VisuGUI_TimeAnimationDlg::stopAnimation() { myAnimator->stopAnimation(); myPlayBtn->setOn(false); myPlayBtn->setIconSet(MYplayPixmap); + mySetupBtn->setEnabled(true); + myGenBtn->setEnabled(true); } //************************************************************************ @@ -688,6 +742,7 @@ void VisuGUI_TimeAnimationDlg::onExecution(long theNewFrame, double theTime) { void VisuGUI_TimeAnimationDlg::onSetupDlg() { SetupDlg* aDlg = new SetupDlg(this, myAnimator); aDlg->exec(); + myPlayFrame->setEnabled(false); delete aDlg; } @@ -695,3 +750,16 @@ void VisuGUI_TimeAnimationDlg::onSetupDlg() { void VisuGUI_TimeAnimationDlg::onBrowse() { myPathEdit->setText(QAD_FileDlg::getExistingDirectory(this, "/","Select path")); } + + +//************************************************************************ +void VisuGUI_TimeAnimationDlg::onStop() { + if (isClosing) { + QDialog::closeEvent(myEvent); + } else { + myPlayBtn->setOn(false); + myPlayBtn->setIconSet(MYplayPixmap); + mySetupBtn->setEnabled(true); + myGenBtn->setEnabled(true); + } +} diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.h b/src/VISUGUI/VisuGUI_TimeAnimation.h index 5299cb42..9ae881e7 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.h +++ b/src/VISUGUI/VisuGUI_TimeAnimation.h @@ -1,9 +1,12 @@ -// File : VisuGUI_TimeAnimation.h -// Created : 28 / 03 / 2003 -// Author : Vitaly SMETANNIKOV -// Project : SALOME -// Module : VISUGUI -// Copyright : Open CASCADE +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VisuGUI_TimeAnimation.h +// Author : Vitaly SMETANNIKOV +// Module : VISU #ifndef VISUGUI_TIMEANIMATION_H #define VISUGUI_TIMEANIMATION_H @@ -77,6 +80,7 @@ class VisuGUI_TimeAnimationDlg: public QDialog void onSpeedChange(double theSpeed); void onExecution(long theNewFrame, double theTime); void onBrowse(); + void onStop(); private: QSlider* mySlider; @@ -84,6 +88,8 @@ class VisuGUI_TimeAnimationDlg: public QDialog QPushButton* myPropBtn; QToolButton* myPlayBtn; QLabel* myTimeLbl; + QPushButton* mySetupBtn; + QPushButton* myGenBtn; QFrame* myPlayFrame; SALOMEDS::Study_var myStudy; @@ -91,5 +97,7 @@ class VisuGUI_TimeAnimationDlg: public QDialog VISU_TimeAnimation* myAnimator; QCheckBox* mySaveCheck; QLineEdit* myPathEdit; + bool isClosing; + QCloseEvent* myEvent; }; #endif //VISUGUI_TIMEANIMATION_H diff --git a/src/VISUGUI/VisuGUI_VectorsDlg.cxx b/src/VISUGUI/VisuGUI_VectorsDlg.cxx index 9771df6f..174ee491 100644 --- a/src/VISUGUI/VisuGUI_VectorsDlg.cxx +++ b/src/VISUGUI/VisuGUI_VectorsDlg.cxx @@ -1,12 +1,32 @@ -using namespace std; -// File : VisuGUI_VectorsDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_VectorsDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_VectorsDlg.h" #include #include @@ -157,11 +177,11 @@ VisuGUI_VectorsDlg::~VisuGUI_VectorsDlg() void VisuGUI_VectorsDlg::initFromPrsObject(VISU::Vectors_i* thePrs) { setScaleFactor(thePrs->GetScale()); - setLineWidth(thePrs->GetLineWidth()); + setLineWidth((int)thePrs->GetLineWidth()); setUseMagnColor(thePrs->isColored()); - setColor(QColor(thePrs->GetColor()[0]*255, - thePrs->GetColor()[1]*255, - thePrs->GetColor()[2]*255)); + SALOMEDS::Color anOldColor = thePrs->GetColor(); + QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B)); + setColor(aColor); if (thePrs->GetGlyphType() != VISU::Vectors::NONE) { setUseGlyphs(true); @@ -178,14 +198,13 @@ void VisuGUI_VectorsDlg::storeToPrsObject(VISU::Vectors_i* thePrs) { thePrs->SetScale(getScaleFactor()); thePrs->SetLineWidth(getLineWidth()); thePrs->setColored(getUseMagnColor()); - - float aColor[3]; - aColor[0] = myColor.red()/255.; - aColor[1] = myColor.green()/255.; - aColor[2] = myColor.blue()/255.; - - thePrs->SetColor(aColor); - + if(!thePrs->isColored()){ + SALOMEDS::Color aColor; + aColor.R = myColor.red()/255.; + aColor.G = myColor.green()/255.; + aColor.B = myColor.blue()/255.; + thePrs->SetColor(aColor); + } if (getUseGlyphs()) { thePrs->SetGlyphPos(getGlyphPos()); thePrs->SetGlyphType(getGlyphType()); diff --git a/src/VISUGUI/VisuGUI_VectorsDlg.h b/src/VISUGUI/VisuGUI_VectorsDlg.h index 0cebbaa7..68f560f8 100644 --- a/src/VISUGUI/VisuGUI_VectorsDlg.h +++ b/src/VISUGUI/VisuGUI_VectorsDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_VectorsDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_VectorsDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_VECTORSDLG_H diff --git a/src/VISUGUI/VisuGUI_VisuAsDlg.cxx b/src/VISUGUI/VisuGUI_VisuAsDlg.cxx index b61b507f..3de24794 100644 --- a/src/VISUGUI/VisuGUI_VisuAsDlg.cxx +++ b/src/VISUGUI/VisuGUI_VisuAsDlg.cxx @@ -1,13 +1,34 @@ -using namespace std; -// File : VisuGUI_VisuAsDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_VisuAsDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_VisuAsDlg.h" +#include "VISU_PrsObject_i.hh" #include "QAD_Application.h" #include "QAD_Desktop.h" #include "QAD_RightFrame.h" @@ -115,15 +136,15 @@ void VisuGUI_VisuAsDlg::RefreshListActors( const QString &VAType ) if ( VAType == QString( "All" ) ) test = -1; else if ( VAType == QString( "Deformed Shape" ) ) - test = VisuActorType_DeformedShape; + test = VISU::TDEFORMEDSHAPE; else if ( VAType == QString( "Vectors" ) ) - test = VisuActorType_Vectors; + test = VISU::TVECTORS; else if ( VAType == QString( "Scalar Map" ) ) - test = VisuActorType_ScalarMap; + test = VISU::TSCALARMAP; else if ( VAType == QString( "Iso-Surfaces" ) ) - test = VisuActorType_IsoSurfaces; + test = VISU::TISOSURFACE; else if ( VAType == QString( "Cut Planes" ) ) - test = VisuActorType_CutPlanes; + test = VISU::TCUTPLANES; else return; @@ -154,23 +175,23 @@ void VisuGUI_VisuAsDlg::RefreshListActors( const QString &VAType ) */ bool VisuGUI_VisuAsDlg::ActorTypeIsValid( VISU_Actor* Actor, int test ) { - if( test == -1 ) { - if( Actor->VisuActorType < VisuActorType_DeformedShape || - Actor->VisuActorType > VisuActorType_CutPlanes ) - return false; - else + VISU::Prs3d_i* aPrs3d = Actor->getPrs3d(); + if(!aPrs3d) return false; + if(test == -1) { + switch(aPrs3d->GetType()){ + case VISU::TSCALARMAP: + case VISU::TISOSURFACE: + case VISU::TDEFORMEDSHAPE: + case VISU::TCUTPLANES: + case VISU::TCUTLINES: + case VISU::TVECTORS: + case VISU::TSTREAMLINES: return true; - } - else { - if( test < VisuActorType_DeformedShape || - test > VisuActorType_CutPlanes ) + default: return false; - else { - if( Actor->VisuActorType == test) - return true; - else - return false; } + }else{ + return aPrs3d->GetType() == test; } } diff --git a/src/VISUGUI/VisuGUI_VisuAsDlg.h b/src/VISUGUI/VisuGUI_VisuAsDlg.h index ff48404f..62fa0ff7 100644 --- a/src/VISUGUI/VisuGUI_VisuAsDlg.h +++ b/src/VISUGUI/VisuGUI_VisuAsDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_VisuAsDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_VisuAsDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_VISUASDLG_H diff --git a/src/VISUGUI/VisuGUI_icons.po b/src/VISUGUI/VisuGUI_icons.po new file mode 100644 index 00000000..4422d48d --- /dev/null +++ b/src/VISUGUI/VisuGUI_icons.po @@ -0,0 +1,58 @@ +# VISU VISUGUI : GUI of VISU component +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : VisuGUI_icons.po +# Module : VISU + +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"POT-Creation-Date: 2002-05-28 10:57:43 AM CEST\n" +"PO-Revision-Date: YYYY-MM-DD\n" +"Last-Translator: FULLNAME \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + + +msgid "ICON_OBJBROWSER_Visu" +msgstr "Visu_tree_visu.png" + +msgid "ICON_SCALAR_MAP" +msgstr "Visu_scalars.png" + +msgid "ICON_DEFORMED_SHAPE" +msgstr "Visu_deformed.png" + +msgid "ICON_VECTORS" +msgstr "Visu_vectors.png" + +msgid "ICON_ISO_SURFACES" +msgstr "Visu_isosurfaces.png" + +msgid "ICON_CUT_PLANES" +msgstr "Visu_cutplane.png" + +msgid "ICON_CUT_LINES" +msgstr "Visu_cutlines.png" + +msgid "ICON_STREAM_LINES" +msgstr "Visu_streamlines.png" diff --git a/src/VISUGUI/VisuGUI_msg_en.po b/src/VISUGUI/VisuGUI_msg_en.po new file mode 100644 index 00000000..7dfa1d8a --- /dev/null +++ b/src/VISUGUI/VisuGUI_msg_en.po @@ -0,0 +1,347 @@ +# VISU VISUGUI : GUI of VISU component +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : VisuGUI_msg_en.po +# Module : VISU + +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"POT-Creation-Date: 2002-02-22 16:56:46 CET\n" +"PO-Revision-Date: YYYY-MM-DD\n" +"Last-Translator: FULLNAME \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + +msgid "VISU_BUT_OK" +msgstr "OK" + +msgid "VISU_WARNING" +msgstr "Visu Warning" + +msgid "WARNING" +msgstr "Warning" + +#: isodlg.cxx:20 +msgid "::VISU_MEN_ISOSURFDLG" +msgstr "Iso Surface" + +#: VisuGUI.cxx:1351 +msgid "VisuGUI::BT" +msgstr "Bad Type for Selected Item" + +#: VisuGUI.cxx:1263 +msgid "VisuGUI::II" +msgstr "Input Information not selected" + +#: VisuGUI.cxx:1636 +msgid "VisuGUI::ND" +msgstr "No Data in file selected" + +#: VisuGUI.cxx:1290 +msgid "VisuGUI::NI" +msgstr "No Data in file selected" + +#: VisuGUI.cxx:1644 +msgid "VisuGUI::NO" +msgstr "Nil Objetc" + +#: VisuGUI.cxx:1164 +msgid "VisuGUI::NR" +msgstr "No Results in file selected" + +#: VisuGUI_CursorDlg.cxx:43 +msgid "VisuGUI_CursorDlg::&Cancel" +msgstr "Cancel" + +#: VisuGUI_CursorDlg.cxx:30 +msgid "VisuGUI_CursorDlg::&Help" +msgstr "Help" + +#: VisuGUI_CursorDlg.cxx:37 +msgid "VisuGUI_CursorDlg::&OK" +msgstr "OK" + +#: VisuGUI_CursorDlg.cxx:49 +msgid "VisuGUI_CursorDlg::Choose a value" +msgstr "Choose a Value" + +#: VisuGUI_CursorDlg.cxx:20 +msgid "VisuGUI_CursorDlg::MyDialog" +msgstr "Change Cursor" + +#: VisuGUI_IsoSurfacesDlg.cxx:87 +msgid "VisuGUI_IsoSurfacesDlg::&Cancel" +msgstr "Cancel" + +#: VisuGUI_IsoSurfacesDlg.cxx:74 +msgid "VisuGUI_IsoSurfacesDlg::&Help" +msgstr "Help" + +#: VisuGUI_IsoSurfacesDlg.cxx:81 +msgid "VisuGUI_IsoSurfacesDlg::&OK" +msgstr "OK" + +#: VisuGUI_IsoSurfacesDlg.cxx:26 +msgid "VisuGUI_IsoSurfacesDlg::Iso Surfaces Representation" +msgstr "" + +#: VisuGUI_IsoSurfacesDlg.cxx:40 +msgid "VisuGUI_IsoSurfacesDlg::Maximum value" +msgstr "" + +#: VisuGUI_IsoSurfacesDlg.cxx:35 +msgid "VisuGUI_IsoSurfacesDlg::Minimum value" +msgstr "" + +#: VisuGUI_IsoSurfacesDlg.cxx:21 +msgid "VisuGUI_IsoSurfacesDlg::MyDialog" +msgstr "Iso Surface" + +#: VisuGUI_IsoSurfacesDlg.cxx:44 +msgid "VisuGUI_IsoSurfacesDlg::Number of surfaces" +msgstr "" + +#: VisuGUI_MagnitudeDlg.cxx:43 +msgid "VisuGUI_MagnitudeDlg::VISU_BUT_CANCEL" +msgstr "Cancel" + +#: VisuGUI_MagnitudeDlg.cxx:30 +msgid "VisuGUI_MagnitudeDlg::VISU_BUT_HELP" +msgstr "Help" + +#: VisuGUI_MagnitudeDlg.cxx:37 +msgid "VisuGUI_MagnitudeDlg::VISU_BUT_OK" +msgstr "OK" + +#: VisuGUI_MagnitudeDlg.cxx:54 +msgid "VisuGUI_MagnitudeDlg::VISU_MEN_PHASE" +msgstr "Magnitude" + +#: VisuGUI_PartialScaDlg.cxx:43 +msgid "VisuGUI_PartialScaDlg::&Cancel" +msgstr "Cancel" + +#: VisuGUI_PartialScaDlg.cxx:30 +msgid "VisuGUI_PartialScaDlg::&Help" +msgstr "Help" + +#: VisuGUI_PartialScaDlg.cxx:37 +msgid "VisuGUI_PartialScaDlg::&OK" +msgstr "OK" + +#: VisuGUI_PartialScaDlg.cxx:76 +msgid "VisuGUI_PartialScaDlg::Max :" +msgstr "" + +#: VisuGUI_PartialScaDlg.cxx:81 +msgid "VisuGUI_PartialScaDlg::Min :" +msgstr "" + +#: VisuGUI_PartialScaDlg.cxx:49 +msgid "VisuGUI_PartialScaDlg::Min an Max limits of scalar Display" +msgstr "" + +#: VisuGUI_PartialScaDlg.cxx:20 +msgid "VisuGUI_PartialScaDlg::MyDialog" +msgstr "Partial Scalar" + +#: VisuGUI_PhaseDlg.cxx:43 +msgid "VisuGUI_PhaseDlg::VISU_BUT_CANCEL" +msgstr "Cancel" + +#: VisuGUI_PhaseDlg.cxx:30 +msgid "VisuGUI_PhaseDlg::VISU_BUT_HELP" +msgstr "Help" + +#: VisuGUI_PhaseDlg.cxx:37 +msgid "VisuGUI_PhaseDlg::VISU_BUT_OK" +msgstr "OK" + +#: VisuGUI_PhaseDlg.cxx:54 +msgid "VisuGUI_PhaseDlg::VISU_MEN_PHASE" +msgstr "Phase" + +#: VisuGUI_PhaseMagnitudeDlg.cxx:83 +msgid "VisuGUI_PhaseMagnitudeDlg::&Cancel" +msgstr "Cancel" + +#: VisuGUI_PhaseMagnitudeDlg.cxx:70 +msgid "VisuGUI_PhaseMagnitudeDlg::&Help" +msgstr "Help" + +#: VisuGUI_PhaseMagnitudeDlg.cxx:77 +msgid "VisuGUI_PhaseMagnitudeDlg::&OK" +msgstr "OK" + +#: VisuGUI_PhaseMagnitudeDlg.cxx:57 +msgid "VisuGUI_PhaseMagnitudeDlg::Magnitude :" +msgstr "" + +#: VisuGUI_PhaseMagnitudeDlg.cxx:52 +msgid "VisuGUI_PhaseMagnitudeDlg::Phase :" +msgstr "" + +#: VisuGUI_VectorsDlg.cxx:47 +msgid "VisuGUI_VectorsDlg::&Cancel" +msgstr "Cancel" + +#: VisuGUI_VectorsDlg.cxx:34 +msgid "VisuGUI_VectorsDlg::&Help" +msgstr "Help" + +#: VisuGUI_VectorsDlg.cxx:41 +msgid "VisuGUI_VectorsDlg::&OK" +msgstr "OK" + +#: VisuGUI_VectorsDlg.cxx:68 +msgid "VisuGUI_VectorsDlg::0.1" +msgstr "" + +#: VisuGUI_VectorsDlg.cxx:129 +msgid "VisuGUI_VectorsDlg::Arrows" +msgstr "" + +#: VisuGUI_VectorsDlg.cxx:124 +msgid "VisuGUI_VectorsDlg::Cones (2)" +msgstr "" + +#: VisuGUI_VectorsDlg.cxx:119 +msgid "VisuGUI_VectorsDlg::Cones (6)" +msgstr "" + +#: VisuGUI_VectorsDlg.cxx:109 +msgid "VisuGUI_VectorsDlg::Glyph type" +msgstr "" + +#: VisuGUI_VectorsDlg.cxx:84 +msgid "VisuGUI_VectorsDlg::Line width" +msgstr "" + +#: VisuGUI_VectorsDlg.cxx:97 +msgid "VisuGUI_VectorsDlg::Magnitude coloring" +msgstr "" + +#: VisuGUI_VectorsDlg.cxx:24 +msgid "VisuGUI_VectorsDlg::MyDialog" +msgstr "Vectors" + +#: VisuGUI_VectorsDlg.cxx:63 +msgid "VisuGUI_VectorsDlg::Scale factor" +msgstr "" + +#: VisuGUI_VectorsDlg.cxx:103 +msgid "VisuGUI_VectorsDlg::Use glyphs" +msgstr "" + +#: VisuGUI_VectorsDlg.cxx:53 +msgid "VisuGUI_VectorsDlg::Vectors Representation" +msgstr "" + +msgid "VisuGUI_BAD_MEDFILE" +msgstr "Med file is not correct" + +msgid "VisuGUI_IMPORT_FROM_MED" +msgstr "Import from med file" + +msgid "MED_MEN_IMPORT" +msgstr "Import" + +msgid "MED_MEN_ALL_FILES" +msgstr "All Files ( * )" + +msgid "MED_MEN_IMPORT_MED" +msgstr "MED Files ( *.med )" + +msgid "BUT_CLOSE" +msgstr "Close" + +msgid "VisuGUI_ScalarBarDlg::WRN_LOGARITHMIC_RANGE" +msgstr "Logarithmic scaling: use imposed range values > 0" + +msgid "VisuGUI_ScalarBarDlg::WRN_LOGARITHMIC_FIELD_RANGE" +msgstr "Logarithmic scaling: field range contains negative values, use imposed range instead"======= +msgid "TXT_ORIENTATION" +msgstr "Orientation" + +msgid "LBL_NB_PLANS" +msgstr "Number of planes:" + +msgid "LBL_ROTATION" +msgstr "Rotations" + +msgid "LBL_LINES_PLANE" +msgstr "Plane of lines" + +msgid "LBL_LINES_CUT" +msgstr "Cut planes" + +msgid "LBL_ROT_X" +msgstr "Rotation around X (Y to Z):" + +msgid "LBL_ROT_Y" +msgstr "Rotation around Y (Z to X):" + +msgid "LBL_ROT_Z" +msgstr "Rotation around Z (X to Y):" + +msgid "LBL_POS" +msgstr "Displacement (0...1):" + +msgid "MSG_MINMAX_VALUES" +msgstr "Min value can not be higher or equal to Max value" + +msgid "MSG_NOT_IMPLEMENTED" +msgstr "Not Yet Implemented" + +msgid "ERR_UNKNOWN_EXCEPTION" +msgstr "Unknown exception was caught in VISU module" + +msgid "ERR_BAD_TYPE_POPUP" +msgstr "Bad Type for Selected Item in Popup Menu" + +msgid "ERR_NIL_OBJECT" +msgstr "nil object" + +msgid "WRN_NO_AVAILABLE_DATA" +msgstr "No Available data in selection" + +msgid "ERR_CANT_BUILD_PRESENTATION" +msgstr "The presentation can't be built" + +msgid "ERR_CANT_CREATE_ACTOR" +msgstr "Can't create actor for this presentation" + +msgid "ERR_WRONG_SELECTION_MODE" +msgstr "Wrong selection mode" + +msgid "ERR_ERROR_IN_THE_FILE" +msgstr "There is an error in imported file" + +msgid "ERR_ERROR_DURING_EXPORT" +msgstr "Error has been occured during exporting to file" + +msgid "ERR_CANT_VISUALIZE_OBJECT" +msgstr "Can't visualize current object" + +msgid "WRN_CANT_VISUALIZE_PRS" +msgstr "The presentation can't be visualized.\nNull actor is created." diff --git a/src/VISU_I/Makefile.in b/src/VISU_I/Makefile.in index f1180d0e..a26747c3 100644 --- a/src/VISU_I/Makefile.in +++ b/src/VISU_I/Makefile.in @@ -1,27 +1,27 @@ -# -* Makefile *- +# Copyright (C) 2003 CEA/DEN, EDF R&D # -# Author : Alexey Petrov -# Date : -# $Header: # +# +# File : Makefile.in +# Author : Alexey Petrov +# Module : VISU +# $Header: -# source path top_srcdir=@top_srcdir@ -top_builddir=../.. +top_builddir=../../.. srcdir=@srcdir@ -VPATH=.:$(srcdir):$(top_srcdir)/idl:$(top_builddir)/idl +VPATH=.:@srcdir@:@top_srcdir@/idl @COMMENCE@ # Libraries targets -LIB = libVISUEngine.la +LIB = libVisuEngine.la LIB_SRC = VISU_Gen_i.cc VISU_Result_i.cc \ VISU_PrsObject_i.cc VISU_ViewManager_i.cc VISU_Table_i.cc \ VISU_Extractor.cxx VISU_FieldTransform.cxx \ VISU_Convertor.cxx VISU_MedConvertor.cxx VISU_DatConvertor.cxx \ VISU_Convertor_impl.cxx VISU_CorbaMedConvertor.cxx \ - VISU_LookupTable.cxx VISU_ScalarBarActor.cxx \ VISU_TimeAnimation.cxx LIB_MOC = VISU_TimeAnimation.h @@ -32,10 +32,6 @@ LIB_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl # Executables targets BIN = VISU_Convertor BIN_SRC = VISU_Convertor_impl.cxx VISU_MedConvertor.cxx -#BIN_SRC = VISU_Convertor_impl.cxx VISU_MedConvertor.cxx VISU_DatConvertor.cxx -#BIN = VISU_Convertor -#BIN_SRC = VISU_Convertor_impl.cxx VISU_MedConvertor.cxx VISU_DatConvertor.cxx \ -# VISU_LookupTable.cxx VISU_ScalarBarActor.cxx BIN_CLIENT_IDL = BIN_SERVER_IDL = @@ -43,16 +39,13 @@ BIN_SERVER_IDL = EXPORT_HEADERS = VISUConfig.hh VISU_Gen_i.hh VISU_Result_i.hh \ VISU_PrsObject_i.hh VISU_ViewManager_i.hh VISU_Table_i.hh \ VISU_Extractor.hxx VISU_FieldTransform.hxx VISU_Convertor.hxx \ - VISU_LookupTable.hxx VISU_ScalarBarActor.hxx \ VISU_TimeAnimation.h # additionnal information to compil and link file CPPFLAGS += -ftemplate-depth-32 $(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) \ - $(MED2_INCLUDES) $(HDF5_INCLUDES) $(QWT_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -LDFLAGS += $(QT_MT_LIBS) $(OCC_LIBS) $(VTK_LIBS) $(QWT_LIBS) -lSalomeNS -lSalomeDS \ - -lSalomeContainer -lOpUtil -lSalomeGUI -lVTKViewer -lVisuObject \ - -L${KERNEL_ROOT_DIR}/lib/salome - -LIBS+= $(PYTHON_LIBS) $(MED2_LIBS) $(HDF5_LIBS) -lPlot2d -lSalomeHDFPersist -lSalomeLoggerServer -lRegistry -lqsplitterP -lSalomeLifeCycleCORBA -lSalomeObject -lSalomeNotification -L${KERNEL_ROOT_DIR}/lib/salome + $(MED2_INCLUDES) $(HDF5_INCLUDES) $(QWT_INCLUDES) +LDFLAGS += $(QT_MT_LIBS) $(VTK_LIBS) $(QWT_LIBS) -lSalomeNS -lTOOLSDS \ + -lSalomeContainer -lOpUtil -lSalomeGUI -lVTKViewer -lVisuObject -lSalomeHDFPersist +LIBS+= $(PYTHON_LIBS) $(MED2_LIBS) $(HDF5_LIBS) -lPlot2d # additional file to be cleaned MOSTLYCLEAN = diff --git a/src/VISU_I/VISUConfig.hh b/src/VISU_I/VISUConfig.hh index 9b73f059..3b5dcd8d 100644 --- a/src/VISU_I/VISUConfig.hh +++ b/src/VISU_I/VISUConfig.hh @@ -1,14 +1,17 @@ -// File: VISU_Common.hh -// Created: Tue Dec 24 17:13:35 2002 -// Author: Alexey PETROV -// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_Common.hh +// Author : Alexey PETROV +// Module : VISU #ifndef __VISU_CONFIG_H__ #define __VISU_CONFIG_H__ // standard C++ headers #include -#include +#include #include #include #include @@ -29,7 +32,7 @@ using namespace std; #include "utilities.h" #include -#include +#include namespace VISU{ //=========================================================================== @@ -40,7 +43,7 @@ namespace VISU{ public: virtual ~Base_i(); virtual char* GetID(); - virtual VISU::VISUType GetType()=0; + virtual VISU::VISUType GetType() = 0; protected: static QMutex* myMutex; static CORBA::ORB_var myOrb; @@ -60,15 +63,15 @@ namespace VISU{ class Mutex{ QMutex* myMutex; QApplication* myQApp; - int isQAppLocked, isSessionLocked; + int isQAppLocked, isSessionLocked, myDelay; public: - Mutex(QMutex* theMutex, QApplication* theQApp); + Mutex(QMutex* theMutex, QApplication* theQApp, int theDelay = 0); ~Mutex(); }; //=========================================================================== class Storable : public virtual Base_i { protected: - virtual void ToStream(ostrstream& theStr) = 0; + virtual void ToStream(std::ostringstream& theStr) = 0; public: string ToString(); virtual const char* GetComment() const = 0; @@ -84,9 +87,9 @@ namespace VISU{ throw(std::logic_error&); static void StrToMap(const QString& theStr, VISU::Storable::TRestoringMap& theMap); static SALOMEDS::SObject_ptr GetResultSO(SALOMEDS::SObject_ptr theSObject); - static void DataToStream(ostrstream& theStr, const QString& theName, const QString& theVal); - static void DataToStream(ostrstream& theStr, const QString& theName, const int theVal); - static void DataToStream(ostrstream& theStr, const QString& theName, const double theVal); + static void DataToStream(std::ostringstream& theStr, const QString& theName, const QString& theVal); + static void DataToStream(std::ostringstream& theStr, const QString& theName, const int theVal); + static void DataToStream(std::ostringstream& theStr, const QString& theName, const double theVal); }; //=========================================================================== const CORBA::Boolean IsMultifile(); diff --git a/src/VISU_I/VISU_Convertor.cxx b/src/VISU_I/VISU_Convertor.cxx index 46a36f9c..c0d655c6 100644 --- a/src/VISU_I/VISU_Convertor.cxx +++ b/src/VISU_I/VISU_Convertor.cxx @@ -1,11 +1,12 @@ -using namespace std; - -// File: VISU_Convertor.cxx -// Created: Wed Jan 15 17:43:32 2003 -// Author: Alexey PETROV -// - +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_Convertor.cxx +// Author : Alexey PETROV +// Module : VISU +using namespace std; #include "VISU_Convertor.hxx" #include #include @@ -153,7 +154,7 @@ string VISU_Convertor::GenerateName(const VISU::TField::TTime& aTime){ static QString aName; const string aUnits = aTime.second, tmp(aUnits.size(),' '); if(aUnits == "" || aUnits == tmp) - aName.sprintf("%g, ---",aTime.first); + aName.sprintf("%g, -",aTime.first); else aName.sprintf("%g, %s",aTime.first,aTime.second.c_str()); aName = aName.simplifyWhiteSpace(); @@ -177,6 +178,7 @@ string VISU_Convertor::GenerateName(const string& theName, unsigned int theTimeI return aName.latin1(); } +/* void parseFile(const char* theFileName) throw(std::runtime_error&){ try{ auto_ptr aCon(CreateConvertor(theFileName)); @@ -239,6 +241,34 @@ void parseFile(const char* theFileName) throw(std::runtime_error&){ } } +int main(int argc, char** argv){ + try{ + if(argc > 1){ + for(int i = 0; i < 1; i++){ + QFileInfo fi(argv[1]); + if ( fi.exists() ) { + if ( fi.isDir() ) { + QDir aDir(fi.absFilePath()); + cout< #include -int main(int argc, char** argv){ - vtkRenderWindow *renWin = vtkRenderWindow::New(); - vtkRenderer *ren = vtkRenderer::New(); - renWin->AddRenderer(ren); - ren->GetActiveCamera()->ParallelProjectionOn(); - vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New(); - iren->SetRenderWindow(renWin); - VISU_Convertor* aConvertor = CreateConvertor(argv[1]); - float aScalarRange[2]; - int aFieldIndex = 1, aNumberOfColors = 64, aNumberOfLabels = 5; - FieldInfo aFieldInfo = *(aConvertor->GetFieldInfo(aFieldIndex)); - VISU_Extractor *anExtractor = VISU_Extractor::New(); - anExtractor->Extract(aConvertor->GetOutput(),aFieldInfo.myName.c_str(),0, - aFieldInfo.myNumComponent,aFieldInfo.myType); - vtkUnstructuredGrid *aDataSet = anExtractor->GetUnstructuredGridOutput(); - VISU_FieldTransform* aFieldTransform = VISU_FieldTransform::New(); - aFieldTransform->SetInput(aDataSet); - if(argc > 2) - aFieldTransform->SetTransformFunction(&log10); - vtkDataSetMapper *aMapper = vtkDataSetMapper::New(); - aMapper->SetInput(aFieldTransform->GetUnstructuredGridOutput()); - aMapper->ScalarVisibilityOn(); - anExtractor->GetUnstructuredGridOutput()->GetScalarRange(aScalarRange); - - VISU_LookupTable* aActorLookupTbl = VISU_LookupTable::New(); - cout<<"aActorLookupTbl = "< 2) - aActorLookupTbl->SetLog(true); - aActorLookupTbl->SetHueRange(0.667,0.0); - aActorLookupTbl->SetNumberOfColors(aNumberOfColors); - aActorLookupTbl->SetTableRange(aScalarRange[0],aScalarRange[1]); // - aActorLookupTbl->SetMapScale(1.); - aActorLookupTbl->Build(); - aMapper->SetLookupTable(aActorLookupTbl); - aMapper->SetScalarRange(aScalarRange); - aActorLookupTbl->Delete(); - - vtkActor* aActor = vtkActor::New(); - aActor->SetMapper(aMapper); - - VISU_ScalarBarActor* aBar = VISU_ScalarBarActor::New(); - VISU_LookupTable* aBarLookupTbl = VISU_LookupTable::New(); - cout<<"aBarLookupTbl = "< 2) - aBarLookupTbl->SetLog(true); - aBarLookupTbl->SetHueRange(0.667,0.0); - aBarLookupTbl->SetNumberOfColors(aNumberOfColors); - aBarLookupTbl->SetTableRange(aScalarRange[0],aScalarRange[1]); // - aBarLookupTbl->Build(); - aBar->SetLookupTable(aBarLookupTbl); - aBarLookupTbl->Delete(); - - aBar->SetTitle((aFieldInfo.myName).c_str()); - aBar->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport(); - aBar->SetNumberOfLabels(aNumberOfLabels); - - vtkProperty* aProperty = aActor->GetProperty(); - aProperty->SetSpecularColor( 1, 1, 1); - aProperty->SetSpecular( 0.3 ); - aProperty->SetSpecularPower( 20 ); - aProperty->SetAmbient( 0.2); - aProperty->SetDiffuse( 0.8 ); - aProperty->EdgeVisibilityOn(); - - ren->AddActor(aActor); - ren->AddActor2D(aBar); - - renWin->Render(); - iren->Start(); - return 0; +#include +#include +#include +#include +#include + +static float EPS = 1.0E-3; +const float PI = 3.1415; +extern float* GetIdent(float theR[3][3]); +extern float* GetRx(float theRx[3][3], float thaAng); +extern float* GetRy(float theRy[3][3], float thaAng); +extern float* GetRz(float theRz[3][3], float thaAng); +extern void MulMatrix(float C[3][3], const float A[3][3], const float B[3][3]); // C = A*B; +extern void Sub(float C[3], const float A[3], float B[3]); // AxB +extern float DotMul(const float A[3], const float B[3]); // A*B; +extern void Mul(float C[3], const float A[3], float B[3]); // AxB +extern void Mul(float C[3], const float A[3], float B); // A*B; +extern void CorrectPnt(float thePnt[3], const float BoundPrj[3]); +extern void GetBoundProject(float BoundPrj[3], const float BoundBox[6], const float Dir[3]); + +typedef map TXYMap; +typedef vector TCurveVect; + +void FillCurveXYMap(float theBasePnt[3], float theDir[3], float theBndDist, + vtkPolyData* thePolyData, TXYMap& theXYMap) +{ + int aNbPoints = thePolyData->GetNumberOfPoints(); + //cout<<"aNbPoints = "<GetPointData(); + vtkScalars *aScalars = aPointData->GetScalars(); + float aPnt[3], aVect[3], aDist; + for(int i = 0; i < aNbPoints; i++){ + thePolyData->GetPoint(i,aPnt); + Sub(aVect,theBasePnt,aPnt); + aDist = DotMul(aVect,theDir) / theBndDist; + // the workaround + if(aDist < 0.0) aDist = 0.0; + if(aDist > 1.0) aDist = 1.0; + theXYMap[aDist] = aScalars->GetScalar(i); + //cout< -#include +void PrintTable(const TCurveVect& theCurveVect){ + ofstream aStm; + QString aFileName; + for(int i = 0, iEnd = theCurveVect.size(); i < iEnd; i++){ + aFileName.sprintf("/users/%s/aCurve_%d.xls",getenv("USER"),i); + aStm.open(aFileName.latin1()); + const TXYMap& aXYMap = theCurveVect[i]; + TXYMap::const_iterator aXYMapIter = aXYMap.begin(); + for(; aXYMapIter != aXYMap.end(); aXYMapIter++){ + float aX = aXYMapIter->first, aY = aXYMapIter->second; + aStm< 1){ - int iEnd = 1; - if(argc > 2) iEnd = atoi(argv[2]); - string aFileName("/tmp/AAA"); - ofstream stmOut(aFileName.c_str(),ios::out); - for(int i = 0; i < iEnd; i++){ - MESSAGE("\n--------------------------- "<ToString(); + vtkRenderWindow *renWin = vtkRenderWindow::New(); + vtkRenderer *ren = vtkRenderer::New(); + renWin->AddRenderer(ren); + ren->GetActiveCamera()->ParallelProjectionOn(); + vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New(); + iren->SetRenderWindow(renWin); + VISU_Convertor* aConvertor = CreateConvertor(argv[1]); + const VISU::TMeshMap& aMeshMap = aConvertor->GetMeshMap(); + VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); + if(aMeshMapIter == aMeshMap.end()) return 0; + const string& aMeshName = aMeshMapIter->first; + const VISU::TMesh& aMesh = aMeshMapIter->second; + const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap; + VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter; + //Import fields + aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); + for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ + const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; + const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; + const VISU::TFieldMap& aFieldMap = aMeshOnEntity.myFieldMap; + VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin(); + if(aFieldMapIter == aFieldMap.end()) return 0; + const string& aFieldName = aFieldMapIter->first; + const VISU::TField& aField = aFieldMapIter->second; + const VISU::TField::TValField& aValField = aField.myValField; + VISU::TField::TValField::const_iterator aValFieldIter = aValField.begin(); + if(aValFieldIter == aValField.end()) return 0; + int aTimeStamp = aValFieldIter->first; + vtkUnstructuredGridReader* aReader = + aConvertor->GetFieldOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp); + VISU_Extractor *anExtractor = VISU_Extractor::New(); + anExtractor->Extract(aReader,aFieldName,0,aField.myNbComp,anEntity); + vtkUnstructuredGrid *aDataSet = anExtractor->GetUnstructuredGridOutput(); + VISU_FieldTransform* aFieldTransform = VISU_FieldTransform::New(); + aFieldTransform->SetInput(aDataSet); + //if(argc > 2) aFieldTransform->SetTransformFunction(&log10); + vtkDataSetMapper *aMapper = vtkDataSetMapper::New(); + float aScalarRange[2], myBounds[6]; + anExtractor->GetUnstructuredGridOutput()->GetScalarRange(aScalarRange); + int aNumberOfColors = 64, aNumberOfLabels = 5; + aDataSet->GetBounds(myBounds); + cout<<"myBounds : \n"; + cout< 2) myBasePlane = atoi(argv[2]); + vtkAppendPolyData *myAppendPolyData = vtkAppendPolyData::New(); + + float aRx[3][3], aRy[3][3], aRz[3][3]; + int iPlane = 0; + if(myBasePlane == 0){ // X-Y + if(fabs(myAng[0]) > EPS) ::GetRx(aRx,myAng[0]); else ::GetIdent(aRx); + if(fabs(myAng[1]) > EPS) ::GetRy(aRy,myAng[1]); else ::GetIdent(aRy); + ::MulMatrix(myRotation,aRx,aRy); + iPlane = 2; + }else if(myBasePlane == 1){ // Y-Z + if(fabs(myAng[1]) > EPS) ::GetRy(aRy,myAng[1]); else ::GetIdent(aRy); + if(fabs(myAng[2]) > EPS) ::GetRz(aRz,myAng[2]); else ::GetIdent(aRz); + ::MulMatrix(myRotation,aRy,aRz); + iPlane = 0; + }else if(myBasePlane == 2){ // Z-X + if(fabs(myAng[2]) > EPS) ::GetRz(aRz,myAng[2]); else ::GetIdent(aRz); + if(fabs(myAng[0]) > EPS) ::GetRx(aRx,myAng[0]); else ::GetIdent(aRx); + ::MulMatrix(myRotation,aRz,aRx); + iPlane = 1; + } + for(int i = 0; i < 3; i++) myDir[i] = myRotation[i][iPlane]; + ::Mul(myInvDir,myDir,-1.0); + ::GetBoundProject(myBoundPrj, myBounds, myDir); + if(MYDEBUG) MESSAGE("myDir "<SetInput(aFieldTransform->GetUnstructuredGridOutput()); + vtkPlane *aPlane = vtkPlane::New(); + int i = 1; + float aOrig[3]; + Mul(aOrig,myDir,myBoundPrj[0] + i*myDBPrj); + if(0 && MYDEBUG) MESSAGE("aOrig["<SetOrigin(aOrig); + if(i == 0) aPlane->SetNormal(myInvDir); + else aPlane->SetNormal(myDir); + aCutPlane->SetCutFunction(aPlane); + aPlane->Delete(); + myAppendPolyData->AddInput(aCutPlane->GetOutput()); + aCutPlane->Delete(); + + //CutLines specific + //--------------------------------------------------------------------- + float myDirPln[3], myDirLn[3], myBoundPrjLn[3], myBasePnt[3]; + if(argc > 3) myBasePlane = atoi(argv[3]); + else myBasePlane = myBasePlane + 1; + if(argc > 4) myNbPlanes = atoi(argv[4]); + TCurveVect aCurveVect(myNbPlanes); //Declaration of Curve container + vtkAppendPolyData *anAppendPolyData = vtkAppendPolyData::New(); + if(myBasePlane == 0){ // X-Y + if(fabs(myAng[0]) > EPS) ::GetRx(aRx,myAng[0]); else ::GetIdent(aRx); + if(fabs(myAng[1]) > EPS) ::GetRy(aRy,myAng[1]); else ::GetIdent(aRy); + ::MulMatrix(myRotation,aRx,aRy); + iPlane = 2; + }else if(myBasePlane == 1){ // Y-Z + if(fabs(myAng[1]) > EPS) ::GetRy(aRy,myAng[1]); else ::GetIdent(aRy); + if(fabs(myAng[2]) > EPS) ::GetRz(aRz,myAng[2]); else ::GetIdent(aRz); + ::MulMatrix(myRotation,aRy,aRz); + iPlane = 0; + }else if(myBasePlane == 2){ // Z-X + if(fabs(myAng[2]) > EPS) ::GetRz(aRz,myAng[2]); else ::GetIdent(aRz); + if(fabs(myAng[0]) > EPS) ::GetRx(aRx,myAng[0]); else ::GetIdent(aRx); + ::MulMatrix(myRotation,aRz,aRx); + iPlane = 1; + } + for(int i = 0; i < 3; i++) myDirPln[i] = myRotation[i][iPlane]; + // Get Direction of CutLines and its Bounds + ::Mul(myDirLn,myDirPln,myDir); + ::GetBoundProject(myBoundPrjLn, myBounds, myDirLn); + Mul(myBasePnt,myDirLn,myBoundPrjLn[0]); + CorrectPnt(myBasePnt,myBounds); + cout<<"myBasePnt : "< 1 ) { + myDBPrj = myBoundPrj[2]/(aNbPlanes - 1); + for (int i = 0; i < aNbPlanes; i++){ + vtkCutter *aCutPlane = vtkCutter::New(); + aCutPlane->SetInput(myAppendPolyData->GetOutput()); + vtkPlane *aPlane = vtkPlane::New(); + float aOrig[3]; + Mul(aOrig,myDirPln,myBoundPrj[0] + i*myDBPrj); + if(0 && MYDEBUG) MESSAGE("aOrig["<SetOrigin(aOrig); + if(i == 0) aPlane->SetNormal(myInvDir); + else aPlane->SetNormal(myDirPln); + aCutPlane->SetCutFunction(aPlane); + aPlane->Delete(); + vtkPolyData *aPolyData = aCutPlane->GetOutput(); + aPolyData->Update(); + anAppendPolyData->AddInput(aPolyData); + FillCurveXYMap(myBasePnt,myDirLn,myBoundPrjLn[2],aPolyData,aCurveVect[i]); + aCutPlane->Delete(); + string aFileName("/users/"); + aFileName = aFileName + getenv("USER") + "/" + "CutLine" + dtos("-%d.vtk",i); + vtkPolyDataWriter* aWriter = vtkPolyDataWriter::New(); + aWriter->SetFileName(aFileName.c_str()); + aWriter->SetInput(anAppendPolyData->GetInput(i)); + //aWriter->SetInput(aCutPlane->GetOutput()); + aWriter->Write(); + aWriter->Delete(); + } + }else{ + myDBPrj = myBoundPrj[2]/2.0; + int i = 1; + vtkCutter *aCutPlane = vtkCutter::New(); + aCutPlane->SetInput(myAppendPolyData->GetOutput()); + vtkPlane *aPlane = vtkPlane::New(); + float aOrig[3]; + Mul(aOrig,myDirPln,myBoundPrj[0] + i*myDBPrj); + if(0 && MYDEBUG) MESSAGE("aOrig["<SetOrigin(aOrig); + if(i == 0) aPlane->SetNormal(myInvDir); + else aPlane->SetNormal(myDirPln); + aCutPlane->SetCutFunction(aPlane); + aPlane->Delete(); + vtkPolyData *aPolyData = aCutPlane->GetOutput(); + aPolyData->Update(); + anAppendPolyData->AddInput(aPolyData); + FillCurveXYMap(myBasePnt,myDirLn,myBoundPrjLn[2],aPolyData,aCurveVect[i]); + aCutPlane->Delete(); + } + + PrintTable(aCurveVect); + aMapper->SetInput(anAppendPolyData->GetOutput()); + + vtkPolyDataWriter* aWriter = vtkPolyDataWriter::New(); + string aFileName("/users/"); + aFileName = aFileName + getenv("USER") + "/" + "CutLines.vtk"; + aWriter->SetFileName(aFileName.c_str()); + aWriter->SetInput(anAppendPolyData->GetOutput()); + aWriter->Write(); + aWriter->Delete(); + + //aMapper->SetInput(myAppendPolyData->GetOutput()); + + //aMapper->SetInput(aFieldTransform->GetUnstructuredGridOutput()); + aMapper->ScalarVisibilityOn(); + VISU_LookupTable* aActorLookupTbl = VISU_LookupTable::New(); + //if(argc > 2) aActorLookupTbl->SetLog(true); + aActorLookupTbl->SetHueRange(0.667,0.0); + aActorLookupTbl->SetNumberOfColors(aNumberOfColors); + aActorLookupTbl->SetTableRange(aScalarRange[0],aScalarRange[1]); // + aActorLookupTbl->SetMapScale(1.); + aActorLookupTbl->Build(); + aMapper->SetLookupTable(aActorLookupTbl); + aMapper->SetScalarRange(aScalarRange); + aActorLookupTbl->Delete(); + + vtkActor* aActor = vtkActor::New(); + aActor->SetMapper(aMapper); + + VISU_ScalarBarActor* aBar = VISU_ScalarBarActor::New(); + VISU_LookupTable* aBarLookupTbl = VISU_LookupTable::New(); + //if(argc > 2) aBarLookupTbl->SetLog(true); + aBarLookupTbl->SetHueRange(0.667,0.0); + aBarLookupTbl->SetNumberOfColors(aNumberOfColors); + aBarLookupTbl->SetTableRange(aScalarRange[0],aScalarRange[1]); // + aBarLookupTbl->Build(); + aBar->SetLookupTable(aBarLookupTbl); + aBarLookupTbl->Delete(); + + aBar->SetTitle(aFieldName.c_str()); + aBar->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport(); + aBar->SetNumberOfLabels(aNumberOfLabels); + + vtkProperty* aProperty = aActor->GetProperty(); + aProperty->SetSpecularColor( 1, 1, 1); + aProperty->SetSpecular( 0.3 ); + aProperty->SetSpecularPower( 20 ); + aProperty->SetAmbient( 0.2); + aProperty->SetDiffuse( 0.8 ); + aProperty->EdgeVisibilityOn(); + + ren->AddActor(aActor); + ren->AddActor2D(aBar); + + renWin->Render(); + iren->Start(); + return 1; } } - return 0; }catch(std::runtime_error& exc){ - MESSAGE("Follow exception was accured :\n"< +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_Convertor.hxx +// Author : Alexey PETROV +// Module : VISU #ifndef VISU_Convertor_HeaderFile #define VISU_Convertor_HeaderFile @@ -103,6 +106,8 @@ namespace VISU{ typedef std::vector TValForCellsWithType; typedef std::map TValForCells; typedef std::pair TTime; + typedef std::vector TCompNames; + typedef std::vector TUnitNames; struct TValForTime{ TVTKReader myStorage; int myId; @@ -111,6 +116,8 @@ namespace VISU{ }; typedef std::map TValField; TValField myValField; + TCompNames myCompNames; + TUnitNames myUnitNames; void ShallowCopy(const TField& aField); }; typedef map TFieldMap; diff --git a/src/VISU_I/VISU_Convertor_impl.cxx b/src/VISU_I/VISU_Convertor_impl.cxx index a8f0dcb1..353b12c0 100644 --- a/src/VISU_I/VISU_Convertor_impl.cxx +++ b/src/VISU_I/VISU_Convertor_impl.cxx @@ -1,11 +1,12 @@ -using namespace std; - -// File: VISU_Convertor_impl.cxx -// Created: Fri Jan 10 11:44:54 2003 -// Author: Alexey PETROV -// - +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_Convertor_impl.cxx +// Author : Alexey PETROV +// Module : VISU +using namespace std; #include "VISU_Convertor_impl.hxx" #include @@ -17,7 +18,7 @@ using namespace std; using namespace std; #ifdef DEBUG -static int MYDEBUG = 1; +static int MYDEBUG = 0; static int MYDEBUGWITHFILES = 0; #else static int MYDEBUG = 0; @@ -241,8 +242,16 @@ VISU_Convertor::OutputType* VISU_Convertor_impl::GetFieldOnMesh(const string& th VISU::TVTKReader& aReader = aValForTime.myStorage; //Main part of code if(aReader.get() == NULL){ - LoadMeshOnEntity(aVtkMeshOnEntity); LoadFieldOnMesh(aMesh,aMeshOnEntity,aField,aValForTime); + try{ + LoadMeshOnEntity(aVtkMeshOnEntity); + }catch(std::runtime_error& exc){ + aVtkMeshOnEntity = aMeshOnEntity; + MESSAGE("Follow exception was accured :\n"< - +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_Convertor_impl.hxx +// Author : Alexey PETROV +// Module : VISU #ifndef VISU_Convertor_impl_HeaderFile #define VISU_Convertor_impl_HeaderFile diff --git a/src/VISU_I/VISU_CorbaMedConvertor.cxx b/src/VISU_I/VISU_CorbaMedConvertor.cxx index 46ccae6c..1b879710 100644 --- a/src/VISU_I/VISU_CorbaMedConvertor.cxx +++ b/src/VISU_I/VISU_CorbaMedConvertor.cxx @@ -1,10 +1,12 @@ -using namespace std; -// File: VISU_CorbaMedConvertor.cxx -// Created: Fri Jan 10 12:04:54 2003 -// Author: Alexey PETROV -// - +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_CorbaMedConvertor.cxx +// Author : Alexey PETROV +// Module : VISU +using namespace std; #include "VISU_CorbaMedConvertor.hxx" using namespace VISU; #include @@ -13,16 +15,20 @@ using namespace VISU; #define USER_INTERLACE MED_FULL_INTERLACE #ifdef DEBUG -static int MYDEBUG = 1; +static int MYDEBUG = 0; #else static int MYDEBUG = 0; #endif static med_err ret = 0; -extern "C" +extern "C" { VISU_Convertor* CreateMEDConvertor(SALOMEDS::SObject_ptr theMedSObject) throw(std::runtime_error&){ return new VISU_MEDConvertor(theMedSObject); } + VISU_Convertor* CreateMEDFieldConvertor(SALOME_MED::FIELD_ptr theField) throw(std::runtime_error&){ + return new VISU_MEDFieldConvertor(theField); + } +} typedef map TVisu2MedEntity; static TVisu2MedEntity aVisu2MedEntity; @@ -147,180 +153,319 @@ string GetName(SALOMEDS::SObject_ptr aSObject){ return ""; } +VISU_Convertor* VISU_MEDFieldConvertor::Build() throw (std::runtime_error&){ + if(myField->_is_nil()) + throw std::runtime_error("VISU_MEDFieldConvertor::Build >> myField->_is_nil() !!!"); + + SALOME_MED::SUPPORT_var aMEDSupport = myField->getSupport(); + if(aMEDSupport->_is_nil()) + throw std::runtime_error("VISU_MEDFieldConvertor::Build >> aMEDSupport->_is_nil() !!!"); + SALOME_MED::medEntityMesh aMEDEntity = aMEDSupport->getEntity(); + VISU::TEntity anEntity = aMed2VisuEntity[aMEDEntity]; + SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh(); + if(aMEDMesh->_is_nil()) + throw std::runtime_error("VISU_MEDFieldConvertor::Build >> aMEDMesh->_is_nil() !!!"); + CORBA::String_var aMeshName = aMEDMesh->getName(); + CORBA::String_var aFieldName = myField->getName(); + + VISU::TMesh &aMesh = myMeshMap[aMeshName.in()]; + aMesh.myDim = aMEDMesh->getSpaceDimension(); + aMesh.myName = aMeshName.in(); + VISUMED::TMesh &aMesh2 = myMeshMap2[aMeshName.in()]; + aMesh2.myMesh = aMEDMesh; + if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<> mySObject->_is_nil() !!!"); - myStudy = mySObject->GetStudy(); - CORBA::Short aTag = mySObject->Tag(); - SALOMEDS::SObject_var aMedCompSObj = mySObject->GetFather(); - SALOMEDS::SObject_var aMeshSObj; - CORBA::Boolean aBool = aMedCompSObj->FindSubObject(aTag+1,aMeshSObj); - if(!aBool) throw std::runtime_error("VISU_MEDConvertor::Build >> Cann't find MEDMESH label !!!"); - if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - MEDMESH found."); - SALOMEDS::ChildIterator_var aMeshIterator = myStudy->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); + SALOMEDS::Study_var aStudy = mySObject->GetStudy(); + + CORBA::Object_var aMedObject = SObjectToObject(mySObject); + if(!CORBA::is_nil(aMedObject)){ + SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(aMedObject); + if(!aMED->_is_nil()){ + CORBA::Short aTag = mySObject->Tag(); + SALOMEDS::SObject_var aMedCompSObj = mySObject->GetFather(); + SALOMEDS::SObject_var aMeshSObj; + CORBA::Boolean aBool = aMedCompSObj->FindSubObject(aTag+1,aMeshSObj); + if(!aBool) throw std::runtime_error("VISU_MEDConvertor::Build >> 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(); + VISUMED::TMesh &aMesh2 = myMeshMap2[aMeshName.in()]; + aMesh2.myMesh = aMEDMesh; + if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshName = "<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(; aTimeStampIterator->More(); aTimeStampIterator->Next()){ + 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){ + aMesh.myMeshOnEntityMap[VISU::CELL_ENTITY].myEntity = VISU::CELL_ENTITY; + aMesh.myMeshOnEntityMap[VISU::CELL_ENTITY].myMeshName = aMeshName.in(); + aMesh2.myMeshOnEntityMap[VISU::CELL_ENTITY].mySupport = aMEDSupport; + } + + 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.myCompNames.resize(aField.myNbComp); + aField.myUnitNames.resize(aField.myNbComp); + //int iTimeStamp = aMEDField->getOrderNumber(); + int iTimeStamp = aMEDField->getIterationNumber(); + VISU::TField::TValForTime& aValForTime = aField.myValField[iTimeStamp]; + aValForTime.myId = iTimeStamp; + double dt = aMEDField->getTime(); + aValForTime.myTime = VISU::TField::TTime(dt,""); + + VISUMED::TField& aField2 = aMeshOnEntity2.myFieldMap[aFieldName.in()]; + VISUMED::TField::TValForTime& aValForTime2 = aField2.myValField[iTimeStamp]; + aValForTime2.myField = aMEDField; + if(MYDEBUG) + MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<_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; if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshName = "<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 = myStudy->NewChildIterator(aFieldSObj); - for(; aTimeStampIterator->More(); aTimeStampIterator->Next()){ - 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()]; - VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[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(); - //int iTimeStamp = aMEDField->getOrderNumber(); - int iTimeStamp = aMEDField->getIterationNumber(); - VISU::TField::TValForTime& aValForTime = aField.myValField[iTimeStamp]; - aValForTime.myId = iTimeStamp; - double dt = aMEDField->getTime(); - aValForTime.myTime = VISU::TField::TTime(dt,""); - VISUMED::TMesh &aMesh2 = myMeshMap2[aMeshName.in()]; - VISUMED::TMeshOnEntity& aMeshOnEntity2 = aMesh2.myMeshOnEntityMap[anEntity]; - VISUMED::TField& aField2 = aMeshOnEntity2.myFieldMap[aFieldName.in()]; - VISUMED::TField::TValForTime& aValForTime2 = aField2.myValField[iTimeStamp]; - aValForTime2.myField = aMEDField; - if(MYDEBUG) - MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"< - +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_DatConvertor.cxx +// Author : Alexey PETROV +// Module : VISU +using namespace std; #include "VISU_DatConvertor.hxx" using namespace std; @@ -24,7 +25,7 @@ VISU_Convertor* CreateDatConvertor(const string& theFileName) throw(std::runtime } VISU_DatConvertor::VISU_DatConvertor(const string& theFileName) throw(std::runtime_error&){ myFileInfo.setFile(QString(theFileName.c_str())); - myName = myFileInfo.baseName(); + myName = (const char*)(myFileInfo.baseName()); } VISU_Convertor* VISU_DatConvertor::Build() throw (std::runtime_error&){ diff --git a/src/VISU_I/VISU_DatConvertor.hxx b/src/VISU_I/VISU_DatConvertor.hxx index d23a1814..f4a5ab6a 100644 --- a/src/VISU_I/VISU_DatConvertor.hxx +++ b/src/VISU_I/VISU_DatConvertor.hxx @@ -1,8 +1,10 @@ -// File: VISU_DatConvertor.hxx -// Created: Fri Jan 10 12:13:58 2003 -// Author: Alexey PETROV -// - +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_DatConvertor.hxx +// Author : Alexey PETROV +// Module : VISU #ifndef VISU_DatConvertor_HeaderFile #define VISU_DatConvertor_HeaderFile diff --git a/src/VISU_I/VISU_Extractor.cxx b/src/VISU_I/VISU_Extractor.cxx index 4ca6929d..58fc4844 100644 --- a/src/VISU_I/VISU_Extractor.cxx +++ b/src/VISU_I/VISU_Extractor.cxx @@ -1,9 +1,13 @@ +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_Extractor.cxx +// Module : VISU + using namespace std; #include "VISU_Extractor.hxx" -#include -#include -#include #include #ifdef DEBUG @@ -33,24 +37,30 @@ void VISU_Extractor::Extract(vtkUnstructuredGridReader* theReader, theReader->SetScalarsName(theFieldName.c_str()); else theReader->SetVectorsName(theFieldName.c_str()); - SetInput(theReader->GetOutput()); + SetInput((vtkDataSet*)(theReader->GetOutput())); + Modified(); Update(); } template void execute(int theNbComp, int theScalarMode, TypeData* theInputData, TypeData* theOutputData){ - vtkVectors *inVectors = theInputData->GetVectors(); +// mpv porting vtk 4.2.2 +// vtkVectors *inVectors = theInputData->GetVectors(); + vtkDataArray *inVectors = theInputData->GetVectors(); if ( !inVectors || theNbComp < 1 ) return; - vtkScalars *newScalars = vtkScalars::New(); - newScalars->SetNumberOfScalars(theNbComp); +// mpv porting vtk 4.2.2 +// vtkScalars *newScalars = vtkScalars::New(); + vtkFloatArray *newScalars = vtkFloatArray::New(); + newScalars->SetNumberOfComponents(1); + newScalars->SetNumberOfTuples(theNbComp); for (int ptId = 0; ptId < theNbComp; ptId++) { float v[3], s; - inVectors->GetVector(ptId,v); + inVectors->GetTuple(ptId,v); if ( theScalarMode < 1 || theScalarMode > 3) s = sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); else s = v[theScalarMode - 1]; - newScalars->SetScalar(ptId, s); + newScalars->SetTuple1(ptId, s); } theOutputData->SetScalars(newScalars); newScalars->Delete(); diff --git a/src/VISU_I/VISU_Extractor.hxx b/src/VISU_I/VISU_Extractor.hxx index ab6eaafb..699edaf9 100644 --- a/src/VISU_I/VISU_Extractor.hxx +++ b/src/VISU_I/VISU_Extractor.hxx @@ -1,13 +1,15 @@ -// File: VISU_Extractor.hxx -// Created: Fri Jan 10 16:37:54 2003 -// Author: Alexey PETROV -// - +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_Extractor.hxx +// Author : Alexey PETROV +// Module : VISU #ifndef VISU_Extractor_HeaderFile #define VISU_Extractor_HeaderFile -#include +#include "VTKViewer_Common.h" #include #include "VISU_Convertor.hxx" class vtkUnstructuredGridReader; diff --git a/src/VISU_I/VISU_FieldTransform.cxx b/src/VISU_I/VISU_FieldTransform.cxx index 58626521..f51a9172 100644 --- a/src/VISU_I/VISU_FieldTransform.cxx +++ b/src/VISU_I/VISU_FieldTransform.cxx @@ -1,16 +1,20 @@ +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_FieldTransform.cxx +// Module : VISU + using namespace std; #include "VISU_FieldTransform.hxx" #include "utilities.h" -#include -#include -#include #include #ifdef DEBUG -static int MYDEBUG = 1; +static int MYDEBUG = 0; #else -static int MYDEBUG = 1; +static int MYDEBUG = 0; #endif extern "C" { @@ -19,9 +23,9 @@ double Identical(double theArg) { } double Logarithmic10(double theArg) { - if(theArg == 0.0) return 0.0; - double aResult; - if(theArg < 0.0) return -log10(-theArg); + if(theArg <= 0.0) return -1.0E+38; + //if(theArg == 0.0) return 0.0; + //if(theArg < 0.0) return log10(-theArg); return log10(theArg); } @@ -40,71 +44,81 @@ VISU_FieldTransform* VISU_FieldTransform::New(){ } void VISU_FieldTransform::SetTransformFunction(TTransformFun theFunction) { - //if(MYDEBUG) MESSAGE("VISU_FieldTransform::SetTransformFunction"); myFunction = theFunction; if(myFunction == NULL) myFunction = &Identical; Modified(); } +void VISU_FieldTransform::SetScalarRange(float theScalarRange[2]) { + myScalarRange[0] = theScalarRange[0]; + myScalarRange[1] = theScalarRange[1]; + Modified(); +} + template void -ExecVectors(VISU_FieldTransform::TTransformFun theFunction, int theNbComponent, - TypeData* theInputData, TypeData* theOutputData) +ExecVectors(VISU_FieldTransform::TTransformFun theFunction, float theScalarRange[2], + int theNbComponent, TypeData* theInputData, TypeData* theOutputData) { - vtkVectors *inVectors = theInputData->GetVectors(); - if ( !inVectors || theNbComponent < 1 ) - return; - vtkVectors *newVectors = vtkVectors::New(); - newVectors->SetNumberOfVectors(theNbComponent); + vtkDataArray *inVectors = theInputData->GetVectors(); + if ( !inVectors || theNbComponent < 1 ) return; + vtkFloatArray *newVectors = vtkFloatArray::New(); + newVectors->SetNumberOfComponents(3); + newVectors->SetNumberOfTuples(theNbComponent); + float aScalarRange[2] = {(*theFunction)(theScalarRange[0]),(*theFunction)(theScalarRange[1])}; + float *V, v[3], vMag, aDelta = aScalarRange[1] - aScalarRange[0]; for (int ptId = 0; ptId < theNbComponent; ptId++) { - float v[3], val, res; - inVectors->GetVector(ptId,v); -// v[0] = (*theFunction)(v[0]); -// v[1] = (*theFunction)(v[1]); -// v[2] = (*theFunction)(v[2]); - val = sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); - res = (*theFunction)(val); - if(val > 1.0) res /= val; else res *= val; - v[0] *= res; - v[1] *= res; - v[2] *= res; - newVectors->SetVector(ptId, v); + V = inVectors->GetTuple3(ptId); + vMag = vtkMath::Norm(V); + vMag = ((*theFunction)(vMag) - aScalarRange[0]) / aDelta * theScalarRange[1] / vMag; + if(vMag <= 0.0) vMag = 0.0; + v[0] = V[0]*vMag; + v[1] = V[1]*vMag; + v[2] = V[2]*vMag; + newVectors->SetTuple3(ptId, v[0], v[1], v[2]); } theOutputData->SetVectors(newVectors); newVectors->Delete(); } template void -ExecScalars(VISU_FieldTransform::TTransformFun theFunction, int theNbComponent, - TypeData* theInputData, TypeData* theOutputData) +ExecScalars(VISU_FieldTransform::TTransformFun theFunction, float theScalarRange[2], + int theNbComponent, TypeData* theInputData, TypeData* theOutputData) { - vtkScalars *inScalars = theInputData->GetScalars(); + vtkDataArray *inScalars = theInputData->GetScalars(); if ( !inScalars || theNbComponent < 1 ) return; - vtkScalars *newScalars = vtkScalars::New(); - newScalars->SetNumberOfScalars(theNbComponent); + vtkFloatArray *newScalars = vtkFloatArray::New(); + newScalars->SetNumberOfComponents(1); + newScalars->SetNumberOfTuples(theNbComponent); + float aScalarRange[2] = {(*theFunction)(theScalarRange[0]),(*theFunction)(theScalarRange[1])}; for (int ptId = 0; ptId < theNbComponent; ptId++) { - float s = inScalars->GetScalar(ptId ); - s = (*theFunction)(s); - newScalars->SetScalar(ptId, s); + float s = (*theFunction)(inScalars->GetTuple1(ptId )); + if(s < aScalarRange[0]) s = aScalarRange[0]; + newScalars->SetTuple1(ptId, s); } theOutputData->SetScalars(newScalars); newScalars->Delete(); } void VISU_FieldTransform::Execute(){ - //if(MYDEBUG) MESSAGE("VISU_FieldTransform::Execute"); vtkDataSet *input = this->GetInput(), *output = this->GetOutput(); output->CopyStructure(input); - output->GetPointData()->CopyAllOff(); - output->GetCellData()->CopyAllOff(); + if(myFunction != &Identical){ + output->GetPointData()->CopyAllOff(); + output->GetCellData()->CopyAllOff(); + + ExecScalars(myFunction,myScalarRange,input->GetNumberOfPoints(),input->GetPointData(),output->GetPointData()); + ExecVectors(myFunction,myScalarRange,input->GetNumberOfPoints(),input->GetPointData(),output->GetPointData()); - ExecScalars(myFunction,input->GetNumberOfPoints(),input->GetPointData(),output->GetPointData()); - ExecVectors(myFunction,input->GetNumberOfPoints(),input->GetPointData(),output->GetPointData()); - //output->GetPointData()->PassData(input->GetPointData()); + ExecScalars(myFunction,myScalarRange,input->GetNumberOfCells(),input->GetCellData(),output->GetCellData()); + ExecVectors(myFunction,myScalarRange,input->GetNumberOfCells(),input->GetCellData(),output->GetCellData()); + }else{ + output->GetPointData()->CopyAllOn(); + output->GetCellData()->CopyAllOn(); - ExecScalars(myFunction,input->GetNumberOfCells(),input->GetCellData(),output->GetCellData()); - ExecVectors(myFunction,input->GetNumberOfCells(),input->GetCellData(),output->GetCellData()); - //output->GetCellData()->PassData(input->GetCellData()); + output->GetPointData()->PassData(input->GetPointData()); + output->GetCellData()->PassData(input->GetCellData()); + } } diff --git a/src/VISU_I/VISU_FieldTransform.hxx b/src/VISU_I/VISU_FieldTransform.hxx index 71e9cfc2..511299b4 100644 --- a/src/VISU_I/VISU_FieldTransform.hxx +++ b/src/VISU_I/VISU_FieldTransform.hxx @@ -1,13 +1,15 @@ -// File: VISU_Extractor.hxx -// Created: Fri Jan 10 16:37:54 2003 -// Author: Alexey PETROV -// - +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_Extractor.hxx +// Author : Alexey PETROV +// Module : VISU #ifndef VISU_FieldTransform_HeaderFile #define VISU_FieldTransform_HeaderFile -#include +#include "VTKViewer_Common.h" #include class VTK_EXPORT VISU_FieldTransform : public vtkDataSetToDataSetFilter{ @@ -16,6 +18,7 @@ public: static VISU_FieldTransform *New(); typedef double (*TTransformFun)(double); void SetTransformFunction(TTransformFun theFunction); + void SetScalarRange(float theScalarRange[2]); protected: VISU_FieldTransform(); virtual ~VISU_FieldTransform(); @@ -24,6 +27,7 @@ protected: void Execute(); TTransformFun myFunction; + float myScalarRange[2]; }; extern "C" { double Identical(double theArg); diff --git a/src/VISU_I/VISU_Gen_i.cc b/src/VISU_I/VISU_Gen_i.cc index 037e0d51..3ec2cab5 100644 --- a/src/VISU_I/VISU_Gen_i.cc +++ b/src/VISU_I/VISU_Gen_i.cc @@ -1,21 +1,22 @@ -using namespace std; -// File : VISU_Gen_i.cc file -// Created : -// Author : Alexey Petrov -// Project : SALOME -// Copyright : OPEN CASCADE -// $Header: +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_Gen_i.cc file +// Author : Alexey Petrov +// Module : VISU +// $Header: +using namespace std; #include "VISU_Gen_i.hh" #include "VISU_Result_i.hh" #include "VISU_Convertor.hxx" #include "VISU_PrsObject_i.hh" #include "VISU_ViewManager_i.hh" +#include "VISU_TimeAnimation.h" #include "VISU_Table_i.hh" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_Study.h" +#include "HDFascii.hxx" #include "SALOMEDS_Tool.hxx" #include @@ -32,7 +33,7 @@ using namespace std; static QFileInfo aFileInfo; #ifdef DEBUG -static int MYDEBUG = 1; +static int MYDEBUG = 0; #else static int MYDEBUG = 0; #endif @@ -49,20 +50,21 @@ extern "C" { VISU::VISU_Gen_i * pVISU_Gen = new VISU::VISU_Gen_i(orb, poa, contId, instanceName, interfaceName); return pVISU_Gen->getId() ; } - Engines::Component_ptr + VISU::VISU_Gen_ptr GetVisuGen(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA, SALOME_NamingService* theNamingService, QMutex* theMutex) { if(MYDEBUG) MESSAGE("extern \"C\" GetVisuGen"); VISU::VISU_Gen_i *aVISU_Gen = new VISU::VISU_Gen_i(theORB,thePOA,theNamingService,theMutex); - return Engines::Component::_narrow( VISU::VISU_Gen::_duplicate(aVISU_Gen->_this())); + return VISU::VISU_Gen::_duplicate(aVISU_Gen->_this()); //return aVISU_Gen->_this(); } } namespace VISU{ //=========================================================================== - QMutex* Base_i::myMutex = NULL; + //apo - static QMutex VISUMutex; + QMutex* Base_i::myMutex = NULL; //apo - &VISUMutex; CORBA::ORB_var Base_i::myOrb; PortableServer::POA_var Base_i::myPOA; SALOME_NamingService* Base_i::myNamingService; @@ -78,34 +80,46 @@ namespace VISU{ //=========================================================================== static int mySCnt = 0; static int myQCnt = 0; - Mutex::Mutex(QMutex* theMutex, QApplication* theQApp) : - myQApp(theQApp), isQAppLocked(theQApp->locked()), + static int myIsBatchMode = 0; + + static int QApp_Counter = 0; + static int Session_Counter = 0; + static int COUNTER = 0; + + Mutex::Mutex(QMutex* theMutex, QApplication* theQApp, int theDelay) : + myQApp(theQApp), isQAppLocked(theQApp->locked()), myDelay(theDelay), myMutex(theMutex), isSessionLocked(theMutex->locked()) { - if(MYDEBUG) MESSAGE("Mutex::Mutex : "<lock(); mySCnt++; } - if(!isQAppLocked) { myQApp->lock(); myQCnt++; } - //myQApp->syncX(); - //if(MYDEBUG) MESSAGE("Mutex::Mutex - "<lock();}; mySCnt++; + if(!isQAppLocked && !myQCnt) { + myQApp->lock(); + myQApp->syncX(); + }; + myQCnt++; } Mutex::~Mutex(){ - if(MYDEBUG) MESSAGE("Mutex::~Mutex : "<syncX(); - if(!isQAppLocked) { myQApp->unlock(); myQCnt--; } - if(!isSessionLocked) { myMutex->unlock(); mySCnt--; } - //if(MYDEBUG) MESSAGE("Mutex::~Mutex - "<processEvents(); myQApp->processEvents(); myQApp->processEvents(); + myQCnt--; + if(!isQAppLocked && !myQCnt) { + myQApp->flushX(); + //if(myDelay > 0) + myQApp->processEvents(myDelay+3); + myQApp->unlock(); + } + mySCnt--; if(!isSessionLocked && !mySCnt) { myMutex->unlock();} + if(MYDEBUG) MESSAGE("Mutex::~Mutex : "<<(!isQAppLocked && !myQCnt)<<" "<<(!isSessionLocked && !mySCnt)); } //=========================================================================== static Storable::TCallbackMap VisuStoreMap; string Storable::ToString(){ - ostrstream strOut; + ostringstream strOut; Storable::DataToStream( strOut, "myComment", GetComment() ); ToStream(strOut); strOut< aRet(strOut.str()); - return aRet.get(); + //apo - auto_ptr aRet(strOut.str()); + return strOut.str(); } void Storable::Registry(const char* theComment, TStorableEngine theEngine) @@ -124,6 +138,7 @@ namespace VISU{ Storable::Registry(ScalarMap_i::myComment.c_str(),&ScalarMapRestore); Storable::Registry(DeformedShape_i::myComment.c_str(),&DeformedShapeRestore); Storable::Registry(CutPlanes_i::myComment.c_str(),&CutPlanesRestore); + Storable::Registry(CutLines_i::myComment.c_str(),&CutLinesRestore); Storable::Registry(IsoSurfaces_i::myComment.c_str(),&IsoSurfacesRestore); Storable::Registry(StreamLines_i::myComment.c_str(),&StreamLinesRestore); Storable::Registry(Vectors_i::myComment.c_str(),&VectorsRestore); @@ -153,19 +168,19 @@ namespace VISU{ theMap.insert( TRestoringMap::value_type( aName.latin1(), aValue ) ); } } - void Storable::DataToStream(ostrstream& theStr, const QString& theName, const QString& theVal) { + void Storable::DataToStream(ostringstream& theStr, const QString& theName, const QString& theVal) { QString output = ( !theName.isNull() ? theName : QString("") ) + QString( "=" ) + ( !theVal.isNull() ? theVal : QString("") ); theStr<GetInterface(); - myVisuGen = VISU::VISU_Gen::_narrow( aSession->GetVisuComponent() ); + Engines::Component_var aComponent = aSession->GetVisuGen(); + myVisuGen = VISU::VISU_Gen::_narrow(aComponent); } VISU_Gen_i::VISU_Gen_i(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA, @@ -352,7 +368,7 @@ namespace VISU{ { if(MYDEBUG) MESSAGE("VISU_Gen_i::VISU_Gen_i : "<getActiveStudy()) - QAD_Application::getDesktop()->createStudy(); - myStudyDocument = - QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); + + CORBA::Object_var anObj = myNamingService->Resolve("/myStudyManager"); + SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(anObj); + SALOMEDS::ListOfOpenStudies_var aListOfOpenStudies = aStudyManager->GetOpenStudies(); + if(aListOfOpenStudies->length() > 0) { + CORBA::String_var aStudyName = aListOfOpenStudies[0]; + aFileInfo.setFile(aStudyName.in()); + myStudyDocument = aStudyManager->GetStudyByName(aFileInfo.baseName()); + }else{ + if(MYDEBUG) MESSAGE("VISU_Gen_i::VISU_Gen_i : there is no opened study in StudyManager !!!"); + } + Base_i::myPOA->activate_object(this); } @@ -393,9 +417,17 @@ namespace VISU{ return myVisuGen->Load(theComponent,theStream,theURL,isMultiFile); } + bool VISU_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent, + const SALOMEDS::TMPFile & theStream, + const char* theURL, + bool isMultiFile) { + return Load(theComponent, theStream, theURL, isMultiFile); + } + char* VISU_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, const char* aLocalPersistentID, - CORBA::Boolean isMultiFile) { + CORBA::Boolean isMultiFile, + CORBA::Boolean isASCII) { if(myMutex){ CORBA::String_var aString(""); if(strcmp(aLocalPersistentID,"") != 0) { @@ -406,7 +438,7 @@ namespace VISU{ } return aString._retn(); } - return myVisuGen->LocalPersistentIDToIOR(theSObject, aLocalPersistentID, isMultiFile); + return myVisuGen->LocalPersistentIDToIOR(theSObject, aLocalPersistentID, isMultiFile, isASCII); } //=========================================================================== SALOMEDS::TMPFile* VISU_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent, @@ -459,9 +491,63 @@ namespace VISU{ return myVisuGen->Save(theComponent,theURL,isMultiFile); } + SALOMEDS::TMPFile* VISU_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent, + const char* theURL, + bool isMultiFile) { + if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - myMutex = "<GetStudy(); + SALOMEDS::ChildIterator_var itBig = aStudy->NewChildIterator(theComponent); + for (; itBig->More(); itBig->Next()) { + SALOMEDS::SObject_var gotBranch = itBig->Value(); + CORBA::Object_var anObj = SObjectToObject(gotBranch); + if(CORBA::is_nil(anObj)) continue; + Result_i* pResult = dynamic_cast(GetServant(anObj)); + if(pResult && abs(pResult->GetSourceId()) == Result_i::eFile){ + const QFileInfo& aFileInfo = pResult->GetFileInfo(); + QString aPrefix = SALOMEDS_Tool::GetNameFromPath(aStudy->URL()); + QString aFileName = aPrefix + "_" + (pResult->GetName()).c_str(); + static QString aCommand; + aCommand.sprintf("cp %s %s%s",aFileInfo.filePath().latin1(),aTmpDir.ToCString(),aFileName.latin1()); + + if(system(aCommand) == -1){ + if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - Cann't execute the command :"< 0){ + SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; + aSeq->length(aFileNames.Length()); + for(aCounter = aFileNames.Length(); aCounter > 0; aCounter--) + aSeq[aCounter-1] = CORBA::string_dup(aFileNames.Value(aCounter).ToCString()); + aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.ToCString(), aSeq.in(), isMultiFile); + if(!isMultiFile) + SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true); + } + return aStreamFile._retn(); + } + return myVisuGen->Save(theComponent,theURL,isMultiFile); + } + char* VISU_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, const char* IORString, - CORBA::Boolean isMultiFile) { + CORBA::Boolean isMultiFile, + CORBA::Boolean isASCII) { if(MYDEBUG) MESSAGE("VISU_Gen_i::IORToLocalPersistentID - myMutex = "<IORToLocalPersistentID(theSObject, IORString, isMultiFile); + return myVisuGen->IORToLocalPersistentID(theSObject, IORString, isMultiFile, isASCII); } void VISU_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy){ @@ -543,6 +629,19 @@ namespace VISU{ return myVisuGen->ImportMed(theMedSObject); } + Result_ptr VISU_Gen_i::ImportMedField(SALOME_MED::FIELD_ptr theField){ + if(MYDEBUG) MESSAGE("VISU_Gen_i::ImportMedField : "<GetProperties()->IsLocked()) return Result::_nil(); + Mutex mt(myMutex,qApp); + Result_i* pResult = new Result_i(myStudyDocument); + if(pResult->Create(theField) != NULL) + return Result::_duplicate(pResult->_this()); + return Result::_nil(); + } + return myVisuGen->ImportMedField(theField); + } + Mesh_ptr VISU_Gen_i::MeshOnEntity(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity){ if(MYDEBUG) MESSAGE("VISU_Gen_i::MeshOnEntity : "<(GetServant(theResult)); if(ScalarMap_i::IsPossible(pResult,theMeshName,theEntity,theFieldName,theIteration)){ ScalarMap_i* aPresent = new ScalarMap_i(pResult); - if(aPresent->Create(theMeshName,theEntity,theFieldName,theIteration) != NULL) - return ScalarMap::_duplicate(aPresent->_this()); + if(aPresent->Create(theMeshName,theEntity,theFieldName,theIteration) != NULL){ + //Base_i::myPOA->activate_object(aPresent); + //aPresent->_remove_ref(); + return aPresent->_this(); + } } return ScalarMap::_nil(); } @@ -607,7 +709,7 @@ namespace VISU{ DeformedShape_ptr VISU_Gen_i::DeformedShapeOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, const char* theFieldName, CORBA::Double theIteration){ - if(MYDEBUG) MESSAGE("VISU_Gen_i::ScalarMapOnField : "<GetProperties()->IsLocked()) return DeformedShape::_nil(); Mutex mt(myMutex,qApp); @@ -624,7 +726,7 @@ namespace VISU{ Vectors_ptr VISU_Gen_i::VectorsOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, const char* theFieldName, CORBA::Double theIteration){ - if(MYDEBUG) MESSAGE("VISU_Gen_i::ScalarMapOnField : "<GetProperties()->IsLocked()) return Vectors::_nil(); Mutex mt(myMutex,qApp); @@ -641,7 +743,7 @@ namespace VISU{ IsoSurfaces_ptr VISU_Gen_i::IsoSurfacesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, const char* theFieldName, CORBA::Double theIteration){ - if(MYDEBUG) MESSAGE("VISU_Gen_i::ScalarMapOnField : "<GetProperties()->IsLocked()) return IsoSurfaces::_nil(); Mutex mt(myMutex,qApp); @@ -658,7 +760,7 @@ namespace VISU{ StreamLines_ptr VISU_Gen_i::StreamLinesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, const char* theFieldName, CORBA::Double theIteration){ - if(MYDEBUG) MESSAGE("VISU_Gen_i::ScalarMapOnField : "<GetProperties()->IsLocked()) return StreamLines::_nil(); Mutex mt(myMutex,qApp); @@ -675,7 +777,7 @@ namespace VISU{ CutPlanes_ptr VISU_Gen_i::CutPlanesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, const char* theFieldName, CORBA::Double theIteration){ - if(MYDEBUG) MESSAGE("VISU_Gen_i::ScalarMapOnField : "<GetProperties()->IsLocked()) return CutPlanes::_nil(); Mutex mt(myMutex,qApp); @@ -690,6 +792,23 @@ namespace VISU{ return myVisuGen->CutPlanesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration); } + CutLines_ptr VISU_Gen_i::CutLinesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, CORBA::Double theIteration){ + if(MYDEBUG) MESSAGE("VISU_Gen_i::CutLinesOnField : "<GetProperties()->IsLocked()) return CutLines::_nil(); + Mutex mt(myMutex,qApp); + Result_i* pResult = dynamic_cast(GetServant(theResult)); + if(CutLines_i::IsPossible(pResult,theMeshName,theEntity,theFieldName,theIteration)){ + CutLines_i* aPresent = new CutLines_i(pResult); + if(aPresent->Create(theMeshName,theEntity,theFieldName,theIteration) != NULL) + return CutLines::_duplicate(aPresent->_this()); + } + return CutLines::_nil(); + } + return myVisuGen->CutLinesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration); + } + Table_ptr VISU_Gen_i::CreateTable(const char* theTableEntry){ if(MYDEBUG) MESSAGE("VISU_Gen_i::CreateTable : "<CreateContainer(); } + Animation_ptr VISU_Gen_i::CreateAnimation(View3D_ptr theView3D){ + if(myMutex){ + if(myStudyDocument->GetProperties()->IsLocked()) return Animation::_nil(); + Mutex mt(myMutex,qApp); + if(MYDEBUG) MESSAGE("VISU_Gen_i::CreateAnimation : "<_this()); + } + return myVisuGen->CreateAnimation(theView3D); + } + void VISU_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent){ if(MYDEBUG) MESSAGE("VISU_Gen_i::Close : "<(GetServant(anObj)); + if(!pResult) continue; if(pResult->GetSourceId() == Result_i::eRestoredFile){ //Try remove its file and directory const QFileInfo& aFileInfo = pResult->GetFileInfo(); static QString aCommand; diff --git a/src/VISU_I/VISU_Gen_i.hh b/src/VISU_I/VISU_Gen_i.hh index 3b5e2386..9604f498 100644 --- a/src/VISU_I/VISU_Gen_i.hh +++ b/src/VISU_I/VISU_Gen_i.hh @@ -1,10 +1,11 @@ -// File : VISU_GEN_i.h file -// Created : -// Author : Alexey Petrov -// Project : SALOME -// Copyright : OPEN CASCADE -// $Header: - +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_GEN_i.h file +// Author : Alexey Petrov +// Module : VISU +// $Header: #ifndef __VISU_GEN_I_H__ #define __VISU_GEN_I_H__ @@ -43,6 +44,7 @@ namespace VISU{ //Create Result virtual Result_ptr ImportFile(const char* theFileName); virtual Result_ptr ImportMed(SALOMEDS::SObject_ptr theMedSObject); + virtual Result_ptr ImportMedField(SALOME_MED::FIELD_ptr theField); //Create Presentation Of Submeshes virtual Mesh_ptr MeshOnEntity(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity); @@ -61,21 +63,31 @@ namespace VISU{ const char* theFieldName, CORBA::Double theIteration); virtual CutPlanes_ptr CutPlanesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, const char* theFieldName, CORBA::Double theIteration); + virtual CutLines_ptr CutLinesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, CORBA::Double theIteration); virtual StreamLines_ptr StreamLinesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, const char* theFieldName, CORBA::Double theIteration); //Create Digital Presentation virtual Table_ptr CreateTable(const char* theTableEntry); virtual Curve_ptr CreateCurve(Table_ptr theTable, CORBA::Long theHRow, CORBA::Long theVRow); virtual Container_ptr CreateContainer(); + virtual Animation_ptr CreateAnimation(View3D_ptr theView3d); // inherited methods from SALOMEDS::Driver virtual SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent, const char* theURL, bool isMultiFile); + virtual SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent, + const char* theURL, + bool isMultiFile); virtual bool Load(SALOMEDS::SComponent_ptr, const SALOMEDS::TMPFile &, const char* theURL, bool isMultiFile); + virtual bool LoadASCII(SALOMEDS::SComponent_ptr, + const SALOMEDS::TMPFile &, + const char* theURL, + bool isMultiFile); virtual void Close(SALOMEDS::SComponent_ptr IORSComponent); @@ -83,10 +95,12 @@ namespace VISU{ virtual char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, const char* IORString, - CORBA::Boolean isMultiFile); + CORBA::Boolean isMultiFile, + CORBA::Boolean isASCII); virtual char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, const char* aLocalPersistentID, - CORBA::Boolean isMultiFile); + CORBA::Boolean isMultiFile, + CORBA::Boolean isASCII); virtual bool CanPublishInStudy(CORBA::Object_ptr theIOR); virtual SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy, diff --git a/src/VISU_I/VISU_MedConvertor.cxx b/src/VISU_I/VISU_MedConvertor.cxx index 2ae5ff24..eb442ab9 100644 --- a/src/VISU_I/VISU_MedConvertor.cxx +++ b/src/VISU_I/VISU_MedConvertor.cxx @@ -1,11 +1,12 @@ -using namespace std; - -// File: VISU_MedConvertor.cxx -// Created: Fri Jan 10 12:04:54 2003 -// Author: Alexey PETROV -// - +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_MedConvertor.cxx +// Author : Alexey PETROV +// Module : VISU +using namespace std; #include "VISU_MedConvertor.hxx" #include #include @@ -13,9 +14,9 @@ using namespace std; using namespace std; #ifdef DEBUG -static int MYDEBUG = 1; +static int MYDEBUG = 0; #else -static int MYDEBUG = 1; +static int MYDEBUG = 0; #endif static med_err ret = 0; @@ -96,7 +97,7 @@ public: VISU_MedConvertor::VISU_MedConvertor(const string& theFileName) throw (std::runtime_error&) { myFileInfo.setFile(QString(theFileName.c_str())); - myName = myFileInfo.baseName(); + myName = (const char*)(myFileInfo.baseName()); } VISU_Convertor* VISU_MedConvertor::Build() throw (std::runtime_error&) { @@ -194,7 +195,10 @@ VISU_Convertor* VISU_MedConvertor::Build() throw (std::runtime_error&) { if(ret < 0) throw std::runtime_error("ImportInfo >> MEDfamInfo"); if(0 && MYDEBUG) MESSAGE("ImportInfo - aFamilyNum = "<> MEDnChamp(fid,i)"); - valarray comp('\0',ncomp*MED_TAILLE_PNOM + 1); - valarray unit('\0',ncomp*MED_TAILLE_PNOM + 1); + valarray aCompNames('\0',ncomp*MED_TAILLE_PNOM + 1); + valarray aUnitNames('\0',ncomp*MED_TAILLE_PNOM + 1); char name_field[MED_TAILLE_NOM + 1] = ""; med_type_champ type_field; - if(MEDchampInfo(fid,iField,name_field,&type_field,&comp[0],&unit[0],ncomp) < 0) + if(MEDchampInfo(fid,iField,name_field,&type_field,&aCompNames[0],&aUnitNames[0],ncomp) < 0) throw std::runtime_error(string("ImportInfo >> MEDchampInfo(...)")); //if(type_field != MED_REEL64) continue; //There is some problem in reading INTXX values TVisu2MedEntity::const_iterator aVisu2MedEntityIter = aVisu2MedEntity.begin(); @@ -304,6 +308,22 @@ VISU_Convertor* VISU_MedConvertor::Build() throw (std::runtime_error&) { aField.myEntity = anEntity; aField.myMeshName = aMeshName; aField.myNbComp = ncomp; + aField.myCompNames.resize(ncomp); + aField.myUnitNames.resize(ncomp); + for(int iComp = 0, iPos = 0; iComp < ncomp; iComp++, iPos += MED_TAILLE_PNOM){ + char aCompName[MED_TAILLE_PNOM+1], aUnitName[MED_TAILLE_PNOM+1]; + strncpy(aCompName,&aCompNames[iPos],MED_TAILLE_PNOM); + aCompName[MED_TAILLE_PNOM] = '\0'; + aField.myCompNames[iComp] = aCompName; + strncpy(aUnitName,&aUnitNames[iPos],MED_TAILLE_PNOM); + aUnitName[MED_TAILLE_PNOM] = '\0'; + aField.myUnitNames[iComp] = aUnitName; + if(MYDEBUG){ + MESSAGE("ImportInfo - aCompName["<> MEDnEntMaa(...)"); - if(MYDEBUG) MESSAGE("LoadPoints - iNumElemEnd = "< num_elem(iNumElemEnd), num_fam_elem(iNumElemEnd); - valarray name_elem('\0',iNumElemEnd*MED_TAILLE_PNOM+1); - valarray name_coord('\0',theMesh.myDim*MED_TAILLE_PNOM+1); - valarray unit_coord('\0',theMesh.myDim*MED_TAILLE_PNOM+1); - valarray coord(theMesh.myDim*iNumElemEnd); - ret = MEDnoeudsLire(fid,aMeshName,theMesh.myDim,&coord[0],MED_FULL_INTERLACE,&rep, - &name_coord[0],&unit_coord[0],&name_elem[0],&iname_elem, - &num_elem[0],&inum_elem,&num_fam_elem[0],iNumElemEnd); - if(ret < 0) throw std::runtime_error("LoadPoints >> MEDnoeudsLire(...)"); - if(!isPointsLoaded){ - VISU::TMesh::TPointsCoord& aPointsCoord = theMesh.myPointsCoord; - aPointsCoord.resize(iNumElemEnd*theMesh.myDim); - if(MYDEBUG) MESSAGE("LoadPoints - Filling coordinates of the mesh - inum_elem = "<> MEDnEntMaa(...)"); + if(MYDEBUG) MESSAGE("LoadPoints - iNumElemEnd = "< num_elem(iNumElemEnd), num_fam_elem(iNumElemEnd); + valarray name_elem('\0',iNumElemEnd*MED_TAILLE_PNOM+1); + valarray name_coord('\0',theMesh.myDim*MED_TAILLE_PNOM+1); + valarray unit_coord('\0',theMesh.myDim*MED_TAILLE_PNOM+1); + valarray coord(theMesh.myDim*iNumElemEnd); + ret = MEDnoeudsLire(fid,aMeshName,theMesh.myDim,&coord[0],MED_FULL_INTERLACE,&rep, + &name_coord[0],&unit_coord[0],&name_elem[0],&iname_elem, + &num_elem[0],&inum_elem,&num_fam_elem[0],iNumElemEnd); + if(ret < 0) throw std::runtime_error("LoadPoints >> MEDnoeudsLire(...)"); + if(!isPointsLoaded){ + VISU::TMesh::TPointsCoord& aPointsCoord = theMesh.myPointsCoord; + aPointsCoord.resize(iNumElemEnd*theMesh.myDim); + if(MYDEBUG) MESSAGE("LoadPoints - Filling coordinates of the mesh - inum_elem = "< 0){ + if(MYDEBUG) MESSAGE("LoadPoints - Filling aFamily SubMesh"); + VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aFamily.mySubMesh[VTK_VERTEX]; for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) - for(int iDim = 0, iNumElem2Dim = iNumElem*theMesh.myDim; iDim < theMesh.myDim; iDim++, iNumElem2Dim++) - aPointsCoord[num_elem[iNumElem2Dim]] = coord[iNumElem2Dim]; - if(MYDEBUG) MESSAGE("LoadPoints - Filling aMeshOnEntity with type NODE_ENTITY"); - VISU::TMeshOnEntity::TConnForCellType& aConnForCellType = aMeshOnEntity.myCellsConn[VTK_VERTEX]; - aConnForCellType.resize(iNumElemEnd); - for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) - aConnForCellType[iNumElem] = VISU::TMeshOnEntity::TConnect(1,iNumElem); - } - if(isFamilyPresent && iNumElemEnd > 0){ - if(MYDEBUG) MESSAGE("LoadPoints - Filling aFamily SubMesh"); - VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aFamily.mySubMesh[VTK_VERTEX]; - for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) - if(num_fam_elem[iNumElem] == aFamily.myId) - aSubMeshOnCellType.insert(iNumElem); + if(num_fam_elem[iNumElem] == aFamily.myId) + aSubMeshOnCellType.insert(iNumElem); + } + return 1; + }catch(std::runtime_error& exc){ + theMesh.myPointsCoord.clear(); + throw std::runtime_error(exc.what()); + }catch(...){ + theMesh.myPointsCoord.clear(); + throw std::runtime_error("Unknown exception !!!"); } - return 1; + return 0; } int VISU_MedConvertor::LoadCellsOnEntity(const med_idt& fid, VISU::TMeshOnEntity& theMeshOnEntity, const string& theFamilyName) throw (std::runtime_error&) { - //Check on existing family - VISU::TFamily* pFamily = VISU::GetFamily(theMeshOnEntity,theFamilyName); - bool isFamilyPresent = (pFamily != NULL); - VISU::TFamily& aFamily = *pFamily; - //Check on loading already done - bool isCellsLoaded = !theMeshOnEntity.myCellsConn.empty(); - if(isCellsLoaded) - if(!isFamilyPresent) return 0; - else if(!aFamily.mySubMesh.empty()) return 0; - if(MYDEBUG) { - MESSAGE("LoadCellsOnEntity - theFamilyName = '"< 0) { - med_booleen iname_elem, inum_elem; - valarray num_elem(iNumElemEnd), num_fam_elem(iNumElemEnd); - valarray name_elem('\0',iNumElemEnd*MED_TAILLE_PNOM+1); - med_int aNbConnForElem = getNbMedConnect(aMedType,anEntity,aMesh.myDim); - if(MYDEBUG) MESSAGE("LoadCellsOnEntity - medName = "<> MEDelementsLire(...)"); - if(!isCellsLoaded){ - VISU::TMeshOnEntity::TConnForCellType& aConnForCellType = theMeshOnEntity.myCellsConn[aVtkType]; - aConnForCellType.resize(iNumElemEnd); - valarray aConnect(nbMedNodes); - for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) { - VISU::TMeshOnEntity::TConnect& anArray = aConnForCellType[iNumElem]; - anArray.resize(nbVtkNodes); - for (int k = 0, kj = iNumElem*aNbConnForElem; k < nbMedNodes; k++) { - aConnect[k] = conn[kj+k] - 1; - } - switch(aMedType){ - case MED_TETRA4 : - case MED_TETRA10 : - anArray[0] = aConnect[0]; - anArray[1] = aConnect[1]; - anArray[2] = aConnect[3]; - anArray[3] = aConnect[2]; - break; - case MED_PYRA5 : - case MED_PYRA13 : - anArray[0] = aConnect[0]; - anArray[1] = aConnect[3]; - anArray[2] = aConnect[2]; - anArray[3] = aConnect[1]; - anArray[4] = aConnect[4]; - break; - default: - for (int k = 0; k < nbVtkNodes; k++) - anArray[k] = aConnect[k]; - } - for (int k = 0; k < nbVtkNodes; k++) - if(anArray[k] < 0 || aNbPoints <= anArray[k]){ - static QString aString; - aString.sprintf("ImportCells >> aNbPoints(%d) <= anArray[%d][%d](%d) < 0",aNbPoints,iNumElem,k,anArray[k]); - throw std::runtime_error(aString.latin1()); - } - } - } - //Filling aFamily SubMesh - if(isFamilyPresent){ - VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aFamily.mySubMesh[aVtkType]; - for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) - if(num_fam_elem[iNumElem] == aFamily.myId) - aSubMeshOnCellType.insert(iNumElem); + try{ + //Check on existing family + VISU::TFamily* pFamily = VISU::GetFamily(theMeshOnEntity,theFamilyName); + bool isFamilyPresent = (pFamily != NULL); + VISU::TFamily& aFamily = *pFamily; + //Check on loading already done + bool isCellsLoaded = !theMeshOnEntity.myCellsConn.empty(); + if(isCellsLoaded) + if(!isFamilyPresent) return 0; + else if(!aFamily.mySubMesh.empty()) return 0; + if(MYDEBUG) { + MESSAGE("LoadCellsOnEntity - theFamilyName = '"< 0) { + med_booleen iname_elem, inum_elem; + valarray num_elem(iNumElemEnd), num_fam_elem(iNumElemEnd); + valarray name_elem('\0',iNumElemEnd*MED_TAILLE_PNOM+1); + med_int aNbConnForElem = getNbMedConnect(aMedType,anEntity,aMesh.myDim); + if(MYDEBUG) MESSAGE("LoadCellsOnEntity - medName = "<> MEDelementsLire(...)"); + if(!isCellsLoaded){ + VISU::TMeshOnEntity::TConnForCellType& aConnForCellType = theMeshOnEntity.myCellsConn[aVtkType]; + aConnForCellType.resize(iNumElemEnd); + valarray aConnect(nbMedNodes); + for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) { + VISU::TMeshOnEntity::TConnect& anArray = aConnForCellType[iNumElem]; + anArray.resize(nbVtkNodes); + for (int k = 0, kj = iNumElem*aNbConnForElem; k < nbMedNodes; k++) { + aConnect[k] = conn[kj+k] - 1; + } + switch(aMedType){ + case MED_TETRA4 : + case MED_TETRA10 : + anArray[0] = aConnect[0]; + anArray[1] = aConnect[1]; + anArray[2] = aConnect[3]; + anArray[3] = aConnect[2]; + break; + case MED_PYRA5 : + case MED_PYRA13 : + anArray[0] = aConnect[0]; + anArray[1] = aConnect[3]; + anArray[2] = aConnect[2]; + anArray[3] = aConnect[1]; + anArray[4] = aConnect[4]; + break; + default: + for (int k = 0; k < nbVtkNodes; k++) + anArray[k] = aConnect[k]; + } + for (int k = 0; k < nbVtkNodes; k++) + if(anArray[k] < 0 || aNbPoints <= anArray[k]){ + static QString aString; + aString.sprintf("ImportCells >> aNbPoints(%d) <= anArray[%d][%d](%d) < 0",aNbPoints,iNumElem,k,anArray[k]); + throw std::runtime_error(aString.latin1()); + } + } + } + //Filling aFamily SubMesh + if(isFamilyPresent){ + VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aFamily.mySubMesh[aVtkType]; + for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) + if(num_fam_elem[iNumElem] == aFamily.myId) + aSubMeshOnCellType.insert(iNumElem); + } } } + return 1; + }catch(std::runtime_error& exc){ + theMeshOnEntity.myCellsConn.clear(); + throw std::runtime_error(exc.what()); + }catch(...){ + theMeshOnEntity.myCellsConn.clear(); + throw std::runtime_error("Unknown exception !!!"); } - return 1; + return 0; } int VISU_MedConvertor::LoadField(const med_idt& fid, const VISU::TMeshOnEntity& theMeshOnEntity, diff --git a/src/VISU_I/VISU_MedConvertor.hxx b/src/VISU_I/VISU_MedConvertor.hxx index 94ddd8fe..9b14cf1a 100644 --- a/src/VISU_I/VISU_MedConvertor.hxx +++ b/src/VISU_I/VISU_MedConvertor.hxx @@ -1,8 +1,10 @@ -// File: VISU_MedConvertor.hxx -// Created: Fri Jan 10 12:02:49 2003 -// Author: Alexey PETROV -// - +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_MedConvertor.hxx +// Author : Alexey PETROV +// Module : VISU #ifndef VISU_MedConvertor_HeaderFile #define VISU_MedConvertor_HeaderFile diff --git a/src/VISU_I/VISU_PrsObject_i.cc b/src/VISU_I/VISU_PrsObject_i.cc index 5faaa071..a021b42c 100644 --- a/src/VISU_I/VISU_PrsObject_i.cc +++ b/src/VISU_I/VISU_PrsObject_i.cc @@ -1,10 +1,12 @@ -using namespace std; -// File: VISU_PrsObject_i.cxx -// Created: Fri Jan 17 09:27:59 2003 -// Author: Alexey PETROV -// - +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_PrsObject_i.cxx +// Author : Alexey PETROV +// Module : VISU +using namespace std; #include "VISU_PrsObject_i.hh" #include "VISU_Extractor.hxx" #include "VISU_FieldTransform.hxx" @@ -13,16 +15,20 @@ using namespace std; #include "VISU_Actor.h" using namespace VISU; -//#include "QAD_Study.h" #include "QAD_Config.h" #include #include +#include #include #include #include +#include +#include +#include + #include #include #include @@ -38,18 +44,10 @@ using namespace VISU; #include #include #include -#include -#include -#include - - -//#define CHECKTIME -#ifdef CHECKTIME -#include -#endif +#include #ifdef DEBUG -static int MYDEBUG = 1; +static int MYDEBUG = 0; static int MYDEBUGWITHFILES = 0; #else static int MYDEBUG = 0; @@ -58,6 +56,14 @@ static int MYDEBUGWITHFILES = 0; static float EPS = 1.0E-3; const float PI2 = 2.0*PI; +void WriteToFile(vtkPolyData* theDataSet, const string& theFileName){ + vtkPolyDataWriter* aWriter = vtkPolyDataWriter::New(); + aWriter->SetFileName(theFileName.c_str()); + aWriter->SetInput(theDataSet); + aWriter->Write(); + aWriter->Delete(); +} + //============================================================================== void SetIOR(SALOMEDS::SObject_var& theSObject, const char* theIOR){ SALOMEDS::GenericAttribute_var anAttr; @@ -89,7 +95,20 @@ VISU::Result_i* GetResult(SALOMEDS::SObject_ptr theSObject){ } -//============================================================================== +//---------------------------------------------------------------- +// PrsObject +//---------------------------------------------------------------- +void VISU::PrsObject_i::SetName( const char* theName ) +{ + myName = theName; + SALOMEDS::SObject_var mySO = myStudy->FindObjectID( GetEntry() ); + if ( !mySO->_is_nil() ) { + SALOMEDS::StudyBuilder_var aBuilder = myStudy->NewBuilder(); + SALOMEDS::GenericAttribute_var anAttr = aBuilder->FindOrCreateAttribute( mySO, "AttributeName" ); + SALOMEDS::AttributeName_var aNameAttr = SALOMEDS::AttributeName::_narrow( anAttr ); + aNameAttr->SetValue( theName ); + } +} QString VISU::PrsObject_i::GetEntry() { CORBA::String_var anIOR = GetID(); SALOMEDS::SObject_var aSObject = myStudy->FindObjectIOR(anIOR); @@ -106,83 +125,101 @@ VISU::Prs3d_i::Prs3d_i(Result_i* theResult) : myResult(theResult) { myMapper = MapperType::New(); - myColor.R = myColorRGB[0] = 0.5; - myColor.G = myColorRGB[1] = 0.5; - myColor.B = myColorRGB[2] = 0.5; + myGeomFilter = vtkGeometryFilter::New(); + myGeomFilter->PointClippingOff(); + myGeomFilter->CellClippingOff(); + myGeomFilter->ExtentClippingOff(); + myGeomFilter->MergingOff(); + myColor.R = 0.5; + myColor.G = 0.5; + myColor.B = 0.5; myAddToStudy = true; } void VISU::Prs3d_i::SameAs(const Prs3d_i* theOrigin) { - SetColor(theOrigin->GetColor()); - myMapper = MapperType::New(); - myMapper->ShallowCopy(theOrigin->GetMapper()); + Prs3d_i* aOrigin = const_cast(theOrigin); + SetColor(aOrigin->GetColor()); + myMapper->ShallowCopy(aOrigin->GetMapper()); +} + +void VISU::Prs3d_i::SetColor(const SALOMEDS::Color& theColor){ + myColor = theColor; } VISU::Prs3d_i::~Prs3d_i() { + CORBA::release(myStudy); myMapper->Delete(); + myGeomFilter->Delete(); +} + +void VISU::Prs3d_i::Destroy() { + CORBA::Object_var anObj = _this(); + PortableServer::POA_ptr aPOA = Base_i::GetPOA(); + PortableServer::ObjectId_var anId = aPOA->reference_to_id(anObj); + aPOA->deactivate_object(anId.in()); + //this->_remove_ref(); } /** * Create Actor referred on existing IO */ -VISU_Actor* VISU::Prs3d_i::CreateActor(const Handle(SALOME_InteractiveObject)& theIO){ +bool VISU::Prs3d_i::CreateActor(VISU_Actor* theActor, const Handle(SALOME_InteractiveObject)& theIO){ + //MESSAGE("Prs3d_i::CreateActor"); Update(); - float bounds[6]; + myMapper->Update(); static float eps = VTK_LARGE_FLOAT * 0.1 ; - myMapper->GetBounds(bounds); - for (int i = 0; i < 6; ++i) { - if (fabs (bounds[i] - myBounds[i]) > eps ) { - MESSAGE("Prs3d_i::CreateActor >> Boundaries of actor do not coincide with boundaries of initial shape !!!"); - return NULL; - } + float aLength = myMapper->GetInput()->GetLength(); + if(aLength > eps){ + MESSAGE("Prs3d_i::CreateActor >> Diagonal of the actor is too large : "<GetInput()->GetNumberOfCells() < 10) - aActor->IsShrinkable = false; //Bug SAL2011 Crash on shrink view - else - aActor->IsShrinkable = true; - aActor->SetMapper(myMapper); + theActor->SetShrinkable(myMapper->GetInput()->GetNumberOfCells() > 10); + myMapper->SetResolveCoincidentTopologyToShiftZBuffer(); + myMapper->SetResolveCoincidentTopologyZShift(0.02); + theActor->SetMapper(myMapper); if (myAddToStudy) { if (theIO.IsNull()){ //Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(GetEntry(),"VISU",GetName()); //There is a bug in gcc compiler - const Standard_CString is mapping as char * const not as const char * //(where Standard_CString is defined as typedef char* Standard_CString) - Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(strdup(GetEntry()),"VISU", - (const Standard_CString)GetName()); - aActor->setIO(anIO); + Handle(SALOME_InteractiveObject) anIO = + new SALOME_InteractiveObject(strdup(GetEntry()),"VISU",(const Standard_CString)GetName()); + theActor->setIO(anIO); }else - aActor->setIO(theIO); + theActor->setIO(theIO); } - aActor->DataSource = myMapper->GetInput(); - aActor->Presentation = this; - vtkProperty* aProperty = aActor->GetProperty(); - aProperty->SetColor(myColorRGB); - return aActor; + theActor->setPrs3d(this); + return true; +} + +void VISU::Prs3d_i::UpdateActor(VISU_Actor* theActor) { + if(MYDEBUG) MESSAGE("Prs3d_i::UpdateActor"); + myMapper->Update(); + theActor->Modified(); } VISU::Storable* VISU::Prs3d_i::Restore(const Storable::TRestoringMap& theMap, int theBuilding) throw(std::logic_error&) { if(MYDEBUG) MESSAGE(GetComment()); - myName = VISU::Storable::FindValue(theMap,"myName"); - myColorRGB[0] = myColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble(); - myColorRGB[1] = myColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble(); - myColorRGB[2] = myColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble(); + myName = (const char*)(VISU::Storable::FindValue(theMap,"myName")); + myColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble(); + myColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble(); + myColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble(); return this; } -void VISU::Prs3d_i::ToStream(ostrstream& theStr){ +void VISU::Prs3d_i::ToStream(std::ostringstream& theStr){ Storable::DataToStream( theStr, "myName", myName.c_str() ); Storable::DataToStream( theStr, "myColor.R", myColor.R ); Storable::DataToStream( theStr, "myColor.G", myColor.G ); Storable::DataToStream( theStr, "myColor.B", myColor.B ); } -void VISU::Prs3d_i::Update() -{ - myMapper->Update(); +void VISU::Prs3d_i::Update(){ + myMapper->Modified(); } @@ -212,14 +249,23 @@ VISU::Mesh_i::Mesh_i(Result_i* theResult) : void VISU::Mesh_i::SameAs(const Mesh_i* theOrigin) { - VISU::Prs3d_i::SameAs(theOrigin); - Mesh_i* aMesh = (Mesh_i*) theOrigin; - SetCellColor(aMesh->GetCellColor()); - SetNodeColor(aMesh->GetNodeColor()); - SetLinkColor(aMesh->GetLinkColor()); - SetPresentationType(aMesh->GetPresentationType()); - //myName = string("Copy of ") + theOrigin->GetName(); - Build(false); + return; // Same as command for mesh is not valid in current architecture +// VISU::Prs3d_i::SameAs(theOrigin); +// Mesh_i* aMesh = (Mesh_i*) theOrigin; +// SetCellColor(aMesh->GetCellColor()); +// SetNodeColor(aMesh->GetNodeColor()); +// SetLinkColor(aMesh->GetLinkColor()); +// SetPresentationType(aMesh->GetPresentationType()); +// Build(false); +} + +void VISU::Mesh_i::Destroy(){ + SALOMEDS::SObject_var aSObj = myStudy->FindObjectID(GetEntry()); + if(!aSObj->_is_nil()){ + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + aStudyBuilder->RemoveAttribute(aSObj,"AttributeIOR"); + } + Prs3d_i::Destroy(); } VISU::Storable* VISU::Mesh_i::Create(const char* theMeshName, int theEntity){ @@ -251,9 +297,9 @@ VISU::Storable* VISU::Mesh_i::Restore(const Storable::TRestoringMap& theMap, int myEntity = VISU::Storable::FindValue(theMap,"myEntity").toInt(); mySubMeshName = VISU::Storable::FindValue(theMap,"mySubMeshName").latin1(); - myCellColor.R = VISU::Storable::FindValue(theMap,"myCellColor.R").toDouble(); - myCellColor.G = VISU::Storable::FindValue(theMap,"myCellColor.G").toDouble(); - myCellColor.B = VISU::Storable::FindValue(theMap,"myCellColor.B").toDouble(); + myColor.R = VISU::Storable::FindValue(theMap,"myCellColor.R").toDouble(); + myColor.G = VISU::Storable::FindValue(theMap,"myCellColor.G").toDouble(); + myColor.B = VISU::Storable::FindValue(theMap,"myCellColor.B").toDouble(); myNodeColor.R = VISU::Storable::FindValue(theMap,"myNodeColor.R").toDouble(); myNodeColor.G = VISU::Storable::FindValue(theMap,"myNodeColor.G").toDouble(); @@ -268,16 +314,16 @@ VISU::Storable* VISU::Mesh_i::Restore(const Storable::TRestoringMap& theMap, int return NULL; } -void VISU::Mesh_i::ToStream(ostrstream& theStr){ +void VISU::Mesh_i::ToStream(std::ostringstream& theStr){ Prs3d_i::ToStream(theStr); Storable::DataToStream( theStr, "myMeshName", myMeshName.c_str() ); Storable::DataToStream( theStr, "myEntity", myEntity ); Storable::DataToStream( theStr, "mySubMeshName", mySubMeshName.c_str() ); - Storable::DataToStream( theStr, "myCellColor.R", myCellColor.R ); - Storable::DataToStream( theStr, "myCellColor.G", myCellColor.G ); - Storable::DataToStream( theStr, "myCellColor.B", myCellColor.B ); + Storable::DataToStream( theStr, "myCellColor.R", myColor.R ); + Storable::DataToStream( theStr, "myCellColor.G", myColor.G ); + Storable::DataToStream( theStr, "myCellColor.B", myColor.B ); Storable::DataToStream( theStr, "myNodeColor.R", myNodeColor.R ); Storable::DataToStream( theStr, "myNodeColor.G", myNodeColor.G ); @@ -308,13 +354,9 @@ VISU::Mesh_i::~Mesh_i(){ VISU::Storable* VISU::Mesh_i::Build(int theRestoring){ try{ -#ifdef CHECKTIME - OSD_Timer timer; - timer.Start(); -#endif if(myResult->GetInput() == NULL) throw std::runtime_error("Mesh_i::Build - myResult->GetInput() == NULL !!!"); - if(!theRestoring) myName = GenerateName(); + if(!theRestoring) myName = (const char*)(GenerateName()); if(myEntity >= 0) if(mySubMeshName == "") myType = VISU::TENTITY; @@ -346,12 +388,8 @@ VISU::Storable* VISU::Mesh_i::Build(int theRestoring){ //Binding pipeline vtkUnstructuredGrid *aDataSet = myInput->GetOutput(); //Avoid selection points that don't belong any of cells - vtkGeometryFilter *aGeomFilter = vtkGeometryFilter::New(); - aGeomFilter->SetInput(aDataSet); - vtkTriangleFilter *aTriangleFilter = vtkTriangleFilter::New(); - aTriangleFilter->SetInput(aGeomFilter->GetOutput()); - myMapper->SetInput(aTriangleFilter->GetOutput()); - // myMapper->SetInput(aDataSet); + myGeomFilter->SetInput(aDataSet); + myMapper->SetInput(myGeomFilter->GetOutput()); myMapper->ScalarVisibilityOff(); //Setting IOR on the label if(!theRestoring) { @@ -365,11 +403,12 @@ VISU::Storable* VISU::Mesh_i::Build(int theRestoring){ CORBA::String_var aString = GetID(); anIOR->SetValue(aString); } -#ifdef CHECKTIME - timer.Stop(); - timer.Show(); -#endif aDataSet->GetBounds(myBounds); + if(MYDEBUGWITHFILES){ + string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER"); + aFileName += "-Mesh.vtk"; + ::WriteToFile(myGeomFilter->GetOutput(),aFileName.c_str()); + } return this; }catch(std::runtime_error& exc){ MESSAGE("Follow exception was accured :\n"<VisuActorType = VisuActorType_Mesh; - - vtkProperty* aProperty = aActor->GetProperty(); - //aProperty->SetRepresentation(TypeRepresentation); - aProperty->BackfaceCullingOff(); - aProperty->EdgeVisibilityOn(); - - vtkGeometryFilter *gf = vtkGeometryFilter::New(); - gf->SetInput(aActor->DataSource); - vtkFeatureEdges *edges = vtkFeatureEdges::New(); - edges->SetInput(gf->GetOutput()); - edges->BoundaryEdgesOn(); - edges->ManifoldEdgesOn(); - - vtkPolyDataMapper *edgeMapper = vtkPolyDataMapper::New(); - edgeMapper->SetInput(edges->GetOutput()); - edgeMapper->ScalarVisibilityOff(); - - aActor->GetMapper()->SetResolveCoincidentTopologyToShiftZBuffer(); - aActor->GetMapper()->SetResolveCoincidentTopologyZShift(0.02); - - aActor->EdgeDevice = VISU_Actor::New(); - aActor->EdgeDevice->PickableOff(); - - aActor->EdgeDevice->SetMapper(edgeMapper); - edgeMapper->Update(); - - aActor->EdgeDevice->GetProperty()->SetColor(myLinkColor.R, myLinkColor.G, myLinkColor.B); - - aActor->EdgeDevice->VisibilityOn(); - - return aActor; + VISUMesh_Actor* anActor = VISUMesh_Actor::New(); + if(MYDEBUG) MESSAGE("Prs3d_i::CreateActor"); + if(VISU::Prs3d_i::CreateActor(anActor,theIO)){ + UpdateActor(anActor); + return anActor; + }else{ + anActor->Delete(); + return NULL; + } } +void VISU::Mesh_i::UpdateActor(VISU_Actor* theActor) { + if(VISUMesh_Actor* anActor = dynamic_cast(theActor)){ + if(MYDEBUG) MESSAGE("Mesh_i::UpdateActor"); + VISU::Prs3d_i::UpdateActor(theActor); + vtkProperty* aSurfaceProperty = anActor->GetProperty(); + aSurfaceProperty->SetColor(myColor.R, myColor.G, myColor.B); + vtkProperty* anEdgeProperty = anActor->GetEdgeProperty(); + anEdgeProperty->SetColor(myLinkColor.R, myLinkColor.G, myLinkColor.B); + } +} + //============================================================================== @@ -425,7 +450,9 @@ int VISU::ScalarMap_i::IsPossible(Result_i* theResult, const char* theMeshName, try{ const VISU::TField& aField = theResult->GetInput()->GetField(theMeshName,(VISU::TEntity)theEntity,theFieldName); const VISU::TField::TValField& aValField = aField.myValField; - return aValField.find((int)theIteration) != aValField.end(); + bool aRes = aValField.find((int)theIteration) != aValField.end(); + if(MYDEBUG) MESSAGE("ScalarMap_i::IsPossible = "<FindObjectID(GetEntry()); + if(!aSObj->_is_nil()){ + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + aStudyBuilder->RemoveObject(aSObj); + } + } + Prs3d_i::Destroy(); } void VISU::ScalarMap_i::SameAs(const ScalarMap_i* theOrigin) { - ScalarMap_i* aScalarMap = (ScalarMap_i*) theOrigin; + ScalarMap_i* aScalarMap = const_cast(theOrigin); VISU::Prs3d_i::SameAs(aScalarMap); myField = aScalarMap->GetField(); myMeshName = myField->myMeshName; @@ -460,7 +502,7 @@ void VISU::ScalarMap_i::SameAs(const ScalarMap_i* theOrigin) myFieldName = aScalarMap->GetFieldName(); SetScalarMode(aScalarMap->GetScalarMode()); - Build(false); + SetRange(aScalarMap->GetMin(), aScalarMap->GetMax()); SetScaling(aScalarMap->GetScaling()); SetOrientation(aScalarMap->GetOrientation()); SetPosition(aScalarMap->GetPosX(), aScalarMap->GetPosY()); @@ -468,12 +510,8 @@ void VISU::ScalarMap_i::SameAs(const ScalarMap_i* theOrigin) SetNbColors(aScalarMap->GetNbColors()); SetLabels(aScalarMap->GetLabels()); SetTitle(aScalarMap->GetTitle()); - //if (aScalarMap->isRangeFixed()) - SetRange(aScalarMap->GetMin(), aScalarMap->GetMax()); - //else - //CalculateRange(); - //myScalarMode = aScalarMap->GetScalarMode(); - //myName = string("Copy of ") + theOrigin->GetName(); + Build(-1); + Update(); } @@ -483,7 +521,6 @@ void VISU::ScalarMap_i::SameAs(const ScalarMap_i* theOrigin) VISU::Storable* VISU::ScalarMap_i::Create(const char* theMeshName, VISU::Entity theEntity, const char* theFieldName, CORBA::Double theIteration){ myIsFixedRange = false; - // Orientation QString aOrient = QAD_CONFIG->getSetting("Visu:SBOrientation"); if ( !aOrient.isEmpty() ) @@ -572,9 +609,11 @@ VISU::Storable* VISU::ScalarMap_i::Restore(const Storable::TRestoringMap& theMap { Prs3d_i::Restore(theMap,false); - myMeshName = VISU::Storable::FindValue(theMap,"myMeshName"); + myAddToStudy = false; //SRN Added 21/06/2003 SAL2983: to avoid addition of the new ScalarMap to study. + + myMeshName = (const char*)(VISU::Storable::FindValue(theMap,"myMeshName")); myEntity = VISU::Storable::FindValue(theMap,"myEntity").toInt(); - myFieldName = VISU::Storable::FindValue(theMap,"myFieldName"); + myFieldName = (const char*)(VISU::Storable::FindValue(theMap,"myFieldName")); myIteration = VISU::Storable::FindValue(theMap,"myIteration").toInt(); myScalarMode = VISU::Storable::FindValue(theMap,"myScalarMode").toInt(); @@ -583,7 +622,7 @@ VISU::Storable* VISU::ScalarMap_i::Restore(const Storable::TRestoringMap& theMap myIsFixedRange = VISU::Storable::FindValue(theMap,"myIsFixedRange").toInt(); myScaling = (VISU::Scaling)VISU::Storable::FindValue(theMap,"myScaling").toInt(); - myTitle = VISU::Storable::FindValue(theMap,"myTitle"); + myTitle = (const char*)(VISU::Storable::FindValue(theMap,"myTitle")); myOrientation = (VISU::ScalarMap::Orientation)VISU::Storable::FindValue(theMap,"myOrientation").toInt(); myNumberOfColors = VISU::Storable::FindValue(theMap,"myNumberOfColors").toInt(); myNumberOfLabels = VISU::Storable::FindValue(theMap,"myNumberOfLabels").toInt(); @@ -597,7 +636,7 @@ VISU::Storable* VISU::ScalarMap_i::Restore(const Storable::TRestoringMap& theMap return NULL; } -void VISU::ScalarMap_i::ToStream(ostrstream& theStr){ +void VISU::ScalarMap_i::ToStream(std::ostringstream& theStr){ Prs3d_i::ToStream(theStr); Storable::DataToStream( theStr, "myMeshName", myMeshName.c_str() ); @@ -632,9 +671,15 @@ void VISU::ScalarMap_i::SetScaling(VISU::Scaling theScaling){ aFun = &Identical; } myScaling = theScaling; + vtkUnstructuredGrid *aDataSet = myInput->GetUnstructuredGridOutput(); + myFieldTransform->SetInput(aDataSet); myFieldTransform->SetTransformFunction(aFun); - if(MYDEBUGWITHFILES) - WriteToFile(myFieldTransform->GetUnstructuredGridOutput(),(string("/tmp/")+getenv("USER")+"-PrsScaling").c_str()); + myFieldTransform->SetScalarRange(myScalarRange); + if(MYDEBUGWITHFILES){ + string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER"); + aFileName += "-PrsScaling.vtk"; + WriteToFile(myFieldTransform->GetUnstructuredGridOutput(),aFileName.c_str()); + } } VISU::Scaling VISU::ScalarMap_i::GetScaling(){ @@ -643,30 +688,37 @@ VISU::Scaling VISU::ScalarMap_i::GetScaling(){ void VISU::ScalarMap_i::SetRange(CORBA::Double theMin, CORBA::Double theMax) { + if(theMin > theMax) return; myScalarRange[0] = theMin; myScalarRange[1] = theMax; + myFieldTransform->SetScalarRange(myScalarRange); myIsFixedRange = true; - if(MYDEBUG) - MESSAGE("ScalarMap_i::SetRange - myScalarRange[0] = "<GetUnstructuredGridOutput()->GetScalarRange(myScalarRange); - if(MYDEBUG) - MESSAGE("ScalarMap_i::CalculateRange - myScalarRange[0] = "<GetUnstructuredGridOutput(),aFileName.c_str()); + } } } @@ -687,12 +739,8 @@ VISU::ScalarMap_i::~ScalarMap_i(){ if(MYDEBUG) MESSAGE("ScalarMap_i::~ScalarMap_i()"); myInput->Delete(); myFieldTransform->Delete(); -} - - -void VISU::ScalarMap_i::Update() { - VISU::Prs3d_i::Update(); - if (!myIsFixedRange) CalculateRange(); + myMapperTable->Delete(); + myBarTable->Delete(); } @@ -700,10 +748,6 @@ VISU::Storable* VISU::ScalarMap_i::Build(int theRestoring){ if(MYDEBUG) MESSAGE("ScalarMap_i::Build - "<GetInput() == NULL !!!"); myField = &(myResult->GetInput()->GetField(myMeshName,(VISU::TEntity)myEntity,myFieldName)); @@ -711,44 +755,41 @@ VISU::Storable* VISU::ScalarMap_i::Build(int theRestoring){ SetScalarMode(myScalarMode); if(myInput->GetInput() == NULL) throw std::runtime_error("Can't build build vtk representation !!!"); vtkUnstructuredGrid *aDataSet = myInput->GetUnstructuredGridOutput(); - myFieldTransform->SetInput(aDataSet); SetScaling(myScaling); aDataSet->GetBounds(myBounds); - if(!theRestoring){ + CORBA::String_var anIOR = GetID(); + const VISU::TField::TValField& aValField = myField->myValField; + const VISU::TField::TValForTime& aValForTime = aValField.find((int)myIteration)->second; + const VISU::TField::TTime& aTime = aValForTime.myTime; + QString aComment; + myName = "NoName"; + if(theRestoring == 0){ if (!myIsFixedRange) aDataSet->GetScalarRange(myScalarRange); - myName = "NoName"; - CORBA::String_var anIOR = GetID(); - const VISU::TField::TValField& aValField = myField->myValField; - const VISU::TField::TValForTime& aValForTime = aValField.find((int)myIteration)->second; - const VISU::TField::TTime& aTime = aValForTime.myTime; - QString aComment; - aComment.sprintf("%s, %g",myFieldName.c_str(),aTime.first); - myTitle = aComment.simplifyWhiteSpace(); - if (myAddToStudy) { - myName = GenerateName(); - aComment.sprintf("myComment=TIMESTAMP;myType=%d;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d", - VISU::TTIMESTAMP,myMeshName.c_str(),myEntity,myFieldName.c_str(),(int)myIteration,myField->myNbComp); - string aResultEntry = myResult->GetEntry(); - string aRefFatherEntry = myResult->GetRefFatherEntry(); - string anEntry = FindEntryWithComment(myStudy,aResultEntry.c_str(),aComment.latin1()); - if(anEntry == "") throw std::runtime_error("There is no Entry for binding the presentation !!!"); - aComment.sprintf("myComment=%s;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d;myComponentId=%d", - GetComment(),myMeshName.c_str(),myEntity,myFieldName.c_str(),(int)myIteration,myField->myNbComp,myScalarMode); - CreateAttributes(myStudy,anEntry.c_str(),aRefFatherEntry.c_str(), - anIOR,myName.c_str(),"",aComment.latin1(),true); - } + aComment.sprintf("%s %s",myFieldName.c_str(),VISU_Convertor::GenerateName(aValForTime.myTime).c_str()); + //aComment.sprintf("%s, %g",myFieldName.c_str(),aTime.first); + myTitle = (const char*)(aComment.simplifyWhiteSpace()); + } + if (myAddToStudy) { + myName = (const char*)(GenerateName()); + aComment.sprintf("myComment=TIMESTAMP;myType=%d;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d", + VISU::TTIMESTAMP,myMeshName.c_str(),myEntity,myFieldName.c_str(),(int)myIteration,myField->myNbComp); + string aResultEntry = myResult->GetEntry(); + string aRefFatherEntry = myResult->GetRefFatherEntry(); + string anEntry = FindEntryWithComment(myStudy,aResultEntry.c_str(),aComment.latin1()); + if(anEntry == "") throw std::runtime_error("There is no Entry for binding the presentation !!!"); + aComment.sprintf("myComment=%s;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d;myComponentId=%d", + GetComment(),myMeshName.c_str(),myEntity,myFieldName.c_str(),(int)myIteration,myField->myNbComp,myScalarMode); + CreateAttributes(myStudy,anEntry.c_str(),aRefFatherEntry.c_str(), + anIOR,myName.c_str(),"",aComment.latin1(),true); } if(MYDEBUG) MESSAGE("ScalarMap_i::Build - myFieldName = "<ScalarVisibilityOn(); + Update(); return myFieldTransform->GetUnstructuredGridOutput(); } +void VISU::ScalarMap_i::Update() { + if (!myIsFixedRange) CalculateRange(); + + int aScaling = GetScaling() == VISU::LOGARITHMIC? VTK_SCALE_LOG10: VTK_SCALE_LINEAR; + float aScalarRange[2] = {myScalarRange[0], myScalarRange[1]}; + myMapperTable->SetScale(VTK_SCALE_LINEAR); + if(aScaling == VTK_SCALE_LOG10) + VISU_LookupTable::ComputeLogRange(myScalarRange,aScalarRange); + myMapperTable->SetRange(aScalarRange); + myMapper->SetScalarRange(aScalarRange); + myMapperTable->SetHueRange(0.667,0.0); + myMapperTable->SetNumberOfColors(myNumberOfColors); + myMapperTable->SetMapScale(myMapScale); + myMapperTable->Build(); + myMapper->SetLookupTable(myMapperTable); + myMapper->MapScalars(1.0f); + + myBarTable->SetHueRange(0.667,0.0); + myBarTable->SetNumberOfColors(myNumberOfColors); + myBarTable->SetRange(myScalarRange); + myBarTable->SetScale(aScaling); + myBarTable->Build(); + + VISU::Prs3d_i::Update(); +} +void VISU::ScalarMap_i::SetMapScale(double theMapScale){ + if(MYDEBUG) MESSAGE("ScalarMap_i::SetMapScale() - theMapScale = "<SetLog(true); - aActorLookupTbl->SetHueRange(0.667,0.0); - aActorLookupTbl->SetNumberOfColors(myNumberOfColors); - aActorLookupTbl->SetRange(myScalarRange); - aActorLookupTbl->SetMapScale(1.); - aActorLookupTbl->Build(); - myMapper->SetLookupTable(aActorLookupTbl); -// if(GetScaling() == VISU::ScalarMap::LOGARITHMIC){ -// float* aLogScalarRange = aActorLookupTbl->GetLogRange(); -// myMapper->SetScalarRange(aLogScalarRange); -// }else - myMapper->SetScalarRange(myScalarRange); - aActorLookupTbl->Delete(); - - - VISU_ScalarBarActor* aBar = VISU_ScalarBarActor::New(); - VISU_LookupTable* aBarLookupTbl = VISU_LookupTable::New(); - if(GetScaling() == VISU::LOGARITHMIC) - aBarLookupTbl->SetLog(true); - aBarLookupTbl->SetHueRange(0.667,0.0); - aBarLookupTbl->SetNumberOfColors(myNumberOfColors); - aBarLookupTbl->SetRange(myScalarRange); - aBarLookupTbl->Build(); - aBar->SetLookupTable(aBarLookupTbl); - aBarLookupTbl->Delete(); - - aBar->SetTitle(myTitle.c_str()); - aBar->SetOrientation(myOrientation); - aBar->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport(); - aBar->GetPositionCoordinate()->SetValue(myPosition[0], - myPosition[1]); - aBar->SetWidth(myWidth); - aBar->SetHeight(myHeight); - aBar->SetNumberOfLabels(myNumberOfLabels); - aActor->setScalarBar(aBar); - - aActor->VisuActorType = VisuActorType_ScalarMap; - strncpy(aActor->FieldName, myFieldName.c_str(), 40); - aActor->FieldName[39] = '\0'; - - vtkProperty* aProperty = aActor->GetProperty(); -// aProperty->SetSpecularColor( 1, 1, 1); -// aProperty->SetSpecular( 0.3 ); -// aProperty->SetSpecularPower( 20 ); -// aProperty->SetAmbient( 0.2); -// aProperty->SetDiffuse( 0.8 ); - aProperty->EdgeVisibilityOn(); - return aActor; + VISUScalarMap_Actor* anActor = VISUScalarMap_Actor::New(); + if(VISU::Prs3d_i::CreateActor(anActor,theIO)){ + anActor->SetBarVisibility(&myIsColored); + anActor->myFieldName = myFieldName; + anActor->GetProperty()->EdgeVisibilityOn(); + UpdateActor(anActor); + return anActor; + }else{ + anActor->Delete(); + return NULL; + } +} + +void VISU::ScalarMap_i::UpdateActor(VISU_Actor* theActor) { + if(VISUScalarMap_Actor* anActor = dynamic_cast(theActor)){ + VISU::Prs3d_i::UpdateActor(theActor); + theActor->SetVisibility(theActor->GetVisibility()); + VISU_ScalarBarActor * aScalarBar = anActor->GetScalarBar(); + aScalarBar->SetLookupTable(myBarTable); + aScalarBar->SetTitle(myTitle.c_str()); + aScalarBar->SetOrientation(myOrientation); + aScalarBar->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport(); + aScalarBar->GetPositionCoordinate()->SetValue(myPosition[0],myPosition[1]); + aScalarBar->SetWidth(myWidth); + aScalarBar->SetHeight(myHeight); + aScalarBar->SetNumberOfLabels(myNumberOfLabels); + aScalarBar->Modified(); + } } //============================================================================== @@ -853,13 +899,16 @@ VISU::DeformedShape_i::DeformedShape_i(Result_i* theResult, bool theAddToStudy) myWarpVector = vtkWarpVector::New(); } +void VISU::DeformedShape_i::Destroy(){ + ScalarMap_i::Destroy(); +} void VISU::DeformedShape_i::SameAs(const DeformedShape_i* theOrigin) { - DeformedShape_i* aDefShape = (DeformedShape_i*) theOrigin; + DeformedShape_i* aDefShape = const_cast(theOrigin); setColored(aDefShape->isColored()); - VISU::ScalarMap_i::SameAs(theOrigin); SetScale(aDefShape->GetScale()); + VISU::ScalarMap_i::SameAs(theOrigin); } @@ -882,7 +931,7 @@ VISU::Storable* VISU::DeformedShape_i::Restore(const Storable::TRestoringMap& th return NULL; } -void VISU::DeformedShape_i::ToStream(ostrstream& theStr){ +void VISU::DeformedShape_i::ToStream(std::ostringstream& theStr){ ScalarMap_i::ToStream(theStr); Storable::DataToStream( theStr, "myFactor", myFactor ); @@ -909,10 +958,22 @@ VISU::DeformedShape_i::~DeformedShape_i(){ VISU::ScalarMap_i::DataType* VISU::DeformedShape_i::DoHook(int theRestoring){ - if(!theRestoring) - myFactor = ScaleFactor(); - if(MYDEBUG) - MESSAGE("DeformedShape_i::DoHook() - myFactor = "<Delete(); } -VISU_Actor* VISU::CutPlanes_i::CreateActor(const Handle(SALOME_InteractiveObject)& theIO) { - VISU_Actor* aActor = VISU::ScalarMap_i::CreateActor(theIO); - if (! aActor ) return NULL; - aActor->VisuActorType = VisuActorType_CutPlanes; - return aActor; -} - - float* GetIdent(float theR[3][3]){ for(int i = 0; i < 3; i++) @@ -1094,17 +1143,32 @@ void MulMatrix(float C[3][3], const float A[3][3], const float B[3][3]){ // C = } +void Sub(float C[3], const float A[3], float B[3]){ // AxB; + for(int i = 0; i < 3; i++) C[i] = B[i] - A[i]; +} + float DotMul(const float A[3], const float B[3]){ // A*B; float C = 0.0; for(int i = 0; i < 3; i++) C += A[i]*B[i]; return C; } +void Mul(float C[3], const float A[3], float B[3]){ // AxB; + C[0] = A[1]*B[2] - A[2]*B[1]; + C[1] = A[2]*B[0] - A[0]*B[2]; + C[2] = A[0]*B[1] - A[1]*B[0]; +} void Mul(float C[3], const float A[3], float B){ // A*B; for(int i = 0; i < 3; i++) C[i] = A[i]*B; } +void CorrectPnt(float thePnt[3], const float BoundPrj[3]){ + for(int i = 0, j = 0; i < 3; ++i, j=2*i){ + if(thePnt[i] < BoundPrj[j]) thePnt[i] = BoundPrj[j]; + if(thePnt[i] > BoundPrj[j+1]) thePnt[i] = BoundPrj[j+1]; + } +} void GetBoundProject(float BoundPrj[3], const float BoundBox[6], const float Dir[3]){ float BoundPoints[8][3] = { {BoundBox[0],BoundBox[2],BoundBox[4]}, @@ -1164,80 +1228,450 @@ CORBA::Double VISU::CutPlanes_i::GetRotateY(){ return myAng[0]; } -VISU::ScalarMap_i::DataType* VISU::CutPlanes_i::DoHook(int theRestoring){ - if(!theRestoring){ - myAng[0] = myAng[1] = myAng[2] = 0.0; - myNbPlanes = 10; - myBasePlane = VISU::CutPlanes::XY; +void GetDir(float theDir[3], float theAng[3], + const VISU::CutPlanes::Orientation& theBasePlane) +{ + int iPlane = 0; + float aRx[3][3], aRy[3][3], aRz[3][3], aRotation[3][3]; + if(theBasePlane == VISU::CutPlanes::XY){ // X-Y + if(fabs(theAng[0]) > EPS) ::GetRx(aRx,theAng[0]); else ::GetIdent(aRx); + if(fabs(theAng[1]) > EPS) ::GetRy(aRy,theAng[1]); else ::GetIdent(aRy); + ::MulMatrix(aRotation,aRx,aRy); + iPlane = 2; + }else if(theBasePlane == VISU::CutPlanes::YZ){ // Y-Z + if(fabs(theAng[1]) > EPS) ::GetRy(aRy,theAng[1]); else ::GetIdent(aRy); + if(fabs(theAng[2]) > EPS) ::GetRz(aRz,theAng[2]); else ::GetIdent(aRz); + ::MulMatrix(aRotation,aRy,aRz); + iPlane = 0; + }else if(theBasePlane == VISU::CutPlanes::ZX){ // Z-X + if(fabs(theAng[2]) > EPS) ::GetRz(aRz,theAng[2]); else ::GetIdent(aRz); + if(fabs(theAng[0]) > EPS) ::GetRx(aRx,theAng[0]); else ::GetIdent(aRx); + ::MulMatrix(aRotation,aRz,aRx); + iPlane = 1; } - if(MYDEBUG) - MESSAGE("CutPlanes_i::DoHook() - myNbPlanes = "<SetOrigin(aOrig); - if(theId == 0) aPlane->SetNormal(myInvDir); - else aPlane->SetNormal(myDir); + aPlane->SetOrigin(theOrig); + + aPlane->SetNormal(theDir); aCutPlane->SetCutFunction(aPlane); aPlane->Delete(); - myAppendPolyData->AddInput(aCutPlane->GetOutput()); + theAppendPolyData->AddInput(aCutPlane->GetOutput()); aCutPlane->Delete(); } +void CutWithPlanes(vtkAppendPolyData* theAppendPolyData, vtkDataSet* theDataSet, + int theNbPlanes, float theDir[3], float theBounds[6], float theDisplacement) +{ + float aInvDir[3], aBoundPrj[3], aOrig[3], aPosition; + ::Mul(aInvDir,theDir,-1.0); + ::GetBoundProject(aBoundPrj, theBounds, theDir); + if(theNbPlanes > 1){ + float aDBoundPrj = aBoundPrj[2]/(theNbPlanes - 1); + float aDisplacement = aDBoundPrj*theDisplacement; + float aStartPosition = aBoundPrj[0] - 0.5*aDBoundPrj + aDisplacement; + for (int i = 0; i < theNbPlanes; i++){ + aPosition = aStartPosition + i*aDBoundPrj; + float aDelta = (aBoundPrj[0] - aPosition) / aBoundPrj[2]; + if(aDelta > 0) + aPosition = aBoundPrj[0]; + //if(fabs(aDelta) < EPS) aPosition = aBoundPrj[0]; else continue; + aDelta = (aBoundPrj[2] - aPosition) / aBoundPrj[2]; + if(aDelta < 0) + aPosition = aBoundPrj[2]; + //if(fabs(aDelta) < EPS) aPosition = aBoundPrj[2]; else continue; + Mul(aOrig,theDir,aPosition); + if(i != 0) + CutWithPlane(theAppendPolyData,theDataSet,theDir,aOrig); + else + CutWithPlane(theAppendPolyData,theDataSet,aInvDir,aOrig); + } + }else{ + aPosition = aBoundPrj[0] + aBoundPrj[2]*theDisplacement; + Mul(aOrig,theDir,aPosition); + CutWithPlane(theAppendPolyData,theDataSet,theDir,aOrig); + } +} + +VISU::ScalarMap_i::DataType* VISU::CutPlanes_i::DoHook(int theRestoring){ + if(theRestoring == 0){ + myNbPlanes = 10; + myDisplacement = 0.5; + myBasePlane = VISU::CutPlanes::XY; + myAng[0] = myAng[1] = myAng[2] = 0.0; + } + if(MYDEBUG) + MESSAGE("CutPlanes_i::DoHook() - myNbPlanes = "<GetStudyDocument()), + Prs3d_i(theResult), + ScalarMap_i(theResult, theAddToStudy) +{ + if(MYDEBUG) MESSAGE("CutLines_i::CutLines_i"); + myAppendPolyData = vtkAppendPolyData::New(); +} + +void VISU::CutLines_i::Destroy(){ + ScalarMap_i::Destroy(); +} + +void VISU::CutLines_i::SameAs(const CutLines_i* theOrigin) +{ + CutLines_i* aCutLines = const_cast(theOrigin); + SetNbLines(aCutLines->GetNbLines()); + SetDisplacement(aCutLines->GetDisplacement()); + SetDisplacement2(aCutLines->GetDisplacement2()); + SetOrientationType(aCutLines->GetOrientationType()); + SetOrientationType2(aCutLines->GetOrientationType2()); + SetRotateX(aCutLines->GetRotateX()); + SetRotateY(aCutLines->GetRotateY()); + SetRotateX2(aCutLines->GetRotateX2()); + SetRotateY2(aCutLines->GetRotateY2()); + VISU::ScalarMap_i::SameAs(theOrigin); +} + +VISU::Storable* VISU::CutLines_i::Create(const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, double theIteration){ + return ScalarMap_i::Create(theMeshName,theEntity,theFieldName,theIteration); +} + +VISU::Storable* VISU::CutLines_i::Restore(const Storable::TRestoringMap& theMap, int theBuilding) + throw(std::logic_error&) +{ + ScalarMap_i::Restore(theMap,false); + myNbLines = VISU::Storable::FindValue(theMap,"myNbLines").toInt(); + myDisplacement[0] = VISU::Storable::FindValue(theMap,"myDisplacement[0]").toDouble(); + myDisplacement[1] = VISU::Storable::FindValue(theMap,"myDisplacement[1]").toDouble(); + myBasePlane[0] = (VISU::CutPlanes::Orientation)VISU::Storable::FindValue(theMap,"myBasePlane[0]").toInt(); + myBasePlane[1] = (VISU::CutPlanes::Orientation)VISU::Storable::FindValue(theMap,"myBasePlane[1]").toInt(); + SetOrientationType(myBasePlane[0]); + SetOrientationType2(myBasePlane[1]); + float aRot[2]; + aRot[0] = VISU::Storable::FindValue(theMap,"aRot[0][0]").toDouble(); + SetRotateX(aRot[0]); + aRot[1] = VISU::Storable::FindValue(theMap,"aRot[0][1]").toDouble(); + SetRotateY(aRot[1]); + aRot[0] = VISU::Storable::FindValue(theMap,"aRot[1][0]").toDouble(); + SetRotateX2(aRot[0]); + aRot[1] = VISU::Storable::FindValue(theMap,"aRot[1][1]").toDouble(); + SetRotateY2(aRot[1]); + if(theBuilding) + return Build(true); + return NULL; +} + +void VISU::CutLines_i::ToStream(std::ostringstream& theStr){ + ScalarMap_i::ToStream(theStr); + Storable::DataToStream( theStr, "myNbLines", myNbLines ); + Storable::DataToStream( theStr, "myDisplacement[0]", myDisplacement[0] ); + Storable::DataToStream( theStr, "myDisplacement[1]", myDisplacement[1] ); + Storable::DataToStream( theStr, "myBasePlane[0]", myBasePlane[0] ); + Storable::DataToStream( theStr, "myBasePlane[1]", myBasePlane[1] ); + Storable::DataToStream( theStr, "aRot[0][0]", GetRotateX() ); + Storable::DataToStream( theStr, "aRot[0][1]", GetRotateY() ); + Storable::DataToStream( theStr, "aRot[1][0]", GetRotateX2() ); + Storable::DataToStream( theStr, "aRot[1][1]", GetRotateY2() ); +} + +VISU::Storable* VISU::CutLinesRestore(SALOMEDS::SObject_ptr theSObject, + const string& thePrefix, const Storable::TRestoringMap& theMap) + throw(std::logic_error&) +{ + VISU::Result_i* pResult = GetResult(theSObject); + if(pResult != NULL){ + VISU::CutLines_i* pResent = new VISU::CutLines_i(pResult); + return pResent->Restore(theMap); } - for(int i = 0; i < 3; i++) myDir[i] = myRotation[i][iPlane]; - ::Mul(myInvDir,myDir,-1.0); - ::GetBoundProject(myBoundPrj, myBounds, myDir); - if(MYDEBUG) MESSAGE("myDir "< 1 ) { - myDBPrj = myBoundPrj[2]/(aNbPlanes - 1); - for (int i = 0; i < aNbPlanes; i++){ - SetPlane(i); - } + return NULL; +} + + +VISU::CutLines_i::~CutLines_i(){ + if(MYDEBUG) MESSAGE("CutLines_i::~CutLines_i()"); + myAppendPolyData->Delete(); +} + +void VISU::CutLines_i::SetRotateX(CORBA::Double theAng){ + if(myBasePlane[0] == VISU::CutPlanes::XY) + myAng[0][0] = theAng; + else if(myBasePlane[0] == VISU::CutPlanes::YZ) + myAng[0][1] = theAng; + else if(myBasePlane[0] == VISU::CutPlanes::ZX) + myAng[0][2] = theAng; +} + +CORBA::Double VISU::CutLines_i::GetRotateX(){ + if(myBasePlane[0] == VISU::CutPlanes::XY) + return myAng[0][0]; + else if(myBasePlane[0] == VISU::CutPlanes::YZ) + return myAng[0][1]; + else if(myBasePlane[0] == VISU::CutPlanes::ZX) + return myAng[0][2]; +} + +void VISU::CutLines_i::SetRotateY(CORBA::Double theAng){ + if(myBasePlane[0] == VISU::CutPlanes::XY) + myAng[0][1] = theAng; + else if(myBasePlane[0] == VISU::CutPlanes::YZ) + myAng[0][2] = theAng; + else if(myBasePlane[0] == VISU::CutPlanes::ZX) + myAng[0][0] = theAng; +} + +CORBA::Double VISU::CutLines_i::GetRotateY(){ + if(myBasePlane[0] == VISU::CutPlanes::XY) + return myAng[0][1]; + else if(myBasePlane[0] == VISU::CutPlanes::YZ) + return myAng[0][2]; + else if(myBasePlane[0] == VISU::CutPlanes::ZX) + return myAng[0][0]; +} + +void VISU::CutLines_i::SetRotateX2(CORBA::Double theAng){ + if(myBasePlane[1] == VISU::CutPlanes::XY) + myAng[1][0] = theAng; + else if(myBasePlane[1] == VISU::CutPlanes::YZ) + myAng[1][1] = theAng; + else if(myBasePlane[1] == VISU::CutPlanes::ZX) + myAng[1][2] = theAng; +} + +CORBA::Double VISU::CutLines_i::GetRotateX2(){ + if(myBasePlane[1] == VISU::CutPlanes::XY) + return myAng[1][0]; + else if(myBasePlane[1] == VISU::CutPlanes::YZ) + return myAng[1][1]; + else if(myBasePlane[1] == VISU::CutPlanes::ZX) + return myAng[1][2]; +} + +void VISU::CutLines_i::SetRotateY2(CORBA::Double theAng){ + if(myBasePlane[1] == VISU::CutPlanes::XY) + myAng[1][1] = theAng; + else if(myBasePlane[1] == VISU::CutPlanes::YZ) + myAng[1][2] = theAng; + else if(myBasePlane[1] == VISU::CutPlanes::ZX) + myAng[1][0] = theAng; +} + +CORBA::Double VISU::CutLines_i::GetRotateY2(){ + if(myBasePlane[1] == VISU::CutPlanes::XY) + return myAng[1][1]; + else if(myBasePlane[1] == VISU::CutPlanes::YZ) + return myAng[1][2]; + else if(myBasePlane[1] == VISU::CutPlanes::ZX) + return myAng[1][0]; +} + +VISU::ScalarMap_i::DataType* VISU::CutLines_i::DoHook(int theRestoring){ + if(theRestoring == 0){ + myNbLines = 10; + myDisplacement[0] = myDisplacement[1] = 0.5; + myAng[0][0] = myAng[0][1] = myAng[0][2] = 0.0; + myAng[1][0] = myAng[1][1] = myAng[1][2] = 0.0; + myBasePlane[0] = VISU::CutPlanes::ZX; + myBasePlane[1] = VISU::CutPlanes::XY; } - else { - myDBPrj = 0.5*myBoundPrj[2]; - SetPlane(1); - } + Update(); + return myAppendPolyData->GetOutput(); } +void ClearAppendPolyData(vtkAppendPolyData *theAppendPolyData){ + int iEnd = theAppendPolyData->GetNumberOfInputs(); + for(int i = iEnd-1; i >= 0; i--) + theAppendPolyData->RemoveInput(theAppendPolyData->GetInput(i)); +} + +void VISU::CutLines_i::Update(){ + ::ClearAppendPolyData(myAppendPolyData); + vtkAppendPolyData *anAppendPolyData = vtkAppendPolyData::New(); + //Build base plane + float aDir[2][3]; + ::GetDir(aDir[0],myAng[0],myBasePlane[0]); + ::CutWithPlanes(anAppendPolyData,myFieldTransform->GetUnstructuredGridOutput(),1,aDir[0],myBounds,myDisplacement[0]); + anAppendPolyData->Update(); + vtkPolyData *aPolyData = anAppendPolyData->GetOutput(); + if(MYDEBUG) MESSAGE("CutPlanes_i::Update - aPolyData->GetNumberOfCells() = "<GetNumberOfCells()); + if(aPolyData->GetNumberOfCells() == 0){ + ::ClearAppendPolyData(anAppendPolyData); + vtkGeometryFilter *aGeomFilter = vtkGeometryFilter::New(); + aGeomFilter->SetInput(myFieldTransform->GetUnstructuredGridOutput()); + anAppendPolyData->AddInput(aGeomFilter->GetOutput()); + aGeomFilter->Delete(); + anAppendPolyData->Update(); + } + //Build lines + float aBounds[6]; + aPolyData = anAppendPolyData->GetOutput(); + aPolyData->GetBounds(aBounds); + ::GetDir(aDir[1],myAng[1],myBasePlane[1]); + ::CutWithPlanes(myAppendPolyData,aPolyData,GetNbLines(),aDir[1],aBounds,myDisplacement[1]); + anAppendPolyData->Delete(); + //Calculate values for building of table + ::Mul(myDirLn,aDir[0],aDir[1]); + ::GetBoundProject(myBoundPrjLn, myBounds, myDirLn); + Mul(myBasePnt,myDirLn,myBoundPrjLn[0]); + CorrectPnt(myBasePnt,myBounds); + myMapper->ScalarVisibilityOn(); + VISU::ScalarMap_i::Update(); +} + +void VISU::CutLines_i::BuildTableOfReal(SALOMEDS::SObject_ptr theSObject){ + if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal"); + Update(); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + anAttr = aStudyBuilder->FindOrCreateAttribute(theSObject, "AttributeTableOfReal"); + SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr); + + typedef set TLineCont; + typedef map TXMap; + typedef map TXYMap; + typedef vector TCurveVect; + + const VISU::TField::TValField& aValField = myField->myValField; + const VISU::TField::TValForTime& aValForTime = aValField.find((int)myIteration)->second; + const VISU::TField::TTime& aTime = aValForTime.myTime; + QString aTitle; + //aTitle.sprintf("%s %s",myTitle.c_str(),aTime.second.c_str()); + aTitle.sprintf("%s",myTitle.c_str()); + aTitle = aTitle.simplifyWhiteSpace(); + aTableOfReal->SetTitle(aTitle.latin1()); + + myAppendPolyData->Update(); + int iLineEnd = myAppendPolyData->GetNumberOfInputs(); + if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal iLineEnd = "<GetInput(iLine); + aDataSet->Update(); + int aNbPoints = aDataSet->GetNumberOfPoints(); + if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal iLine = "< 2){ + TXYMap::const_iterator aXYMapIter[2] = {aXYMap.begin(), ++aXYMap.begin()}; + aNewXYMap[aXYMapIter[0]->first] = aXYMapIter[0]->second; + for(; aXYMapIter[1] != aXYMap.end(); aXYMapIter[0]++, aXYMapIter[1]++){ + float aY[3] = {aXYMapIter[0]->second, aXYMapIter[1]->second, 0.0}; + aY[2] = (aY[0] + aY[1])/2.0; + float aX[3] = {aXYMapIter[0]->first, aXYMapIter[1]->first, 0.0}; + aX[2] = (aX[0] + aX[1])/2.0; + aNewXYMap[aX[2]] = aY[2]; + aXMap[aX[2]].insert(iLine); + } + aNewXYMap[aXYMapIter[0]->first] = aXYMapIter[0]->second; + aXYMap = aNewXYMap; + } + } + QString aString; + aTableOfReal->SetNbColumns(aXMap.size()); + TXMap::const_iterator aXMapIter = aXMap.begin(); + for(long i = 0; aXMapIter != aXMap.end(); aXMapIter++, i++){ + float aDist = aXMapIter->first; + aTableOfReal->PutValue(aDist,1,i+1); + aString.sprintf("%d",i); + aTableOfReal->SetColumnTitle(i+1,aString.latin1()); + const TLineCont& aLineCont = aXMapIter->second; + long jEnd = aLineCont.size(); + if(0&& MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal aDist = "<myUnitNames[0].c_str(); + if(myScalarMode != 0) + aUnitName = myField->myUnitNames[myScalarMode-1].c_str(); + aUnitName = aUnitName.simplifyWhiteSpace(); + for(long i = 0; aLineContIter != aLineCont.end(); aLineContIter++, i++){ + long iLine = *aLineContIter; + aString.sprintf("Y%d",iLine); + aTableOfReal->SetRowTitle(i+2,aString.latin1()); + aTableOfReal->SetRowUnit(i+2,aUnitName.latin1()); + } +} //============================================================================== int VISU::IsoSurfaces_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, @@ -1260,8 +1694,12 @@ VISU::IsoSurfaces_i::IsoSurfaces_i(Result_i* theResult, bool theAddToStudy) : myContourFilter = vtkContourFilter::New(); } +void VISU::IsoSurfaces_i::Destroy(){ + ScalarMap_i::Destroy(); +} + void VISU::IsoSurfaces_i::SameAs(const IsoSurfaces_i* theOrigin) { - IsoSurfaces_i* aIsoSurfaces = (IsoSurfaces_i*) theOrigin; + IsoSurfaces_i* aIsoSurfaces = const_cast(theOrigin); SetNbSurfaces(aIsoSurfaces->GetNbSurfaces()); SetRange(aIsoSurfaces->GetRangeMin(), aIsoSurfaces->GetRangeMax()); VISU::ScalarMap_i::SameAs(theOrigin); @@ -1289,7 +1727,7 @@ VISU::Storable* VISU::IsoSurfaces_i::Restore(const Storable::TRestoringMap& theM return NULL; } -void VISU::IsoSurfaces_i::ToStream(ostrstream& theStr){ +void VISU::IsoSurfaces_i::ToStream(std::ostringstream& theStr){ ScalarMap_i::ToStream(theStr); Storable::DataToStream( theStr, "myNbSurface", myNbSurface ); @@ -1315,10 +1753,24 @@ VISU::IsoSurfaces_i::~IsoSurfaces_i(){ myContourFilter->Delete(); } +void VISU::IsoSurfaces_i::SetRange(float theMin, float theMax){ + if(theMin <= theMax){ + myRange[0] = theMin; myRange[1] = theMax; + } +} VISU::ScalarMap_i::DataType* VISU::IsoSurfaces_i::DoHook(int theRestoring){ - if(MYDEBUG) - MESSAGE("IsoSurfaces_i::DoHook() - myNbSurface = "<GenerateValues(myNbSurface, aLogRange); + myContourFilter->GenerateValues(aNbSurface,aLogRange); }else - myContourFilter->GenerateValues(myNbSurface, myRange); + myContourFilter->GenerateValues(aNbSurface,myRange); myMapper->ScalarVisibilityOn(); - return myContourFilter->GetOutput(); + VISU::ScalarMap_i::Update(); } - -void VISU::IsoSurfaces_i::Update(){ - if ((myRange[0]==0) && (myRange[1]==0)) { - myRange[0] = myScalarRange[0]; - myRange[1] = myScalarRange[1]; - } - if(GetScaling() == VISU::LOGARITHMIC){ - float aLogRange[2]; - VISU_LookupTable::ComputeLogRange(myRange,aLogRange); - if(MYDEBUG) - MESSAGE("IsoSurfaces_i::Update() - aLogRange = {"<GenerateValues(myNbSurface, aLogRange); - }else - myContourFilter->GenerateValues(myNbSurface, myRange); - myMapper->Update(); -} - - -VISU_Actor* VISU::IsoSurfaces_i::CreateActor(const Handle(SALOME_InteractiveObject)& theIO) { - VISU_Actor* aActor = VISU::ScalarMap_i::CreateActor(theIO); - if ( ! aActor ) return NULL; - aActor->VisuActorType = VisuActorType_IsoSurfaces; - return aActor; +void VISU::IsoSurfaces_i::SetMapScale(double theMapScale){ + myMapScale = theMapScale; + Update(); } //============================================================================== @@ -1391,22 +1818,25 @@ VISU::StreamLines_i::StreamLines_i(Result_i* theResult, bool theAddToStudy) : myStream = vtkStreamLine::New(); } +void VISU::StreamLines_i::Destroy(){ + DeformedShape_i::Destroy(); +} + VISU::Storable* VISU::StreamLines_i::Create(const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, double theIteration){ - myDirection = VISU::StreamLines::FORWARD; - myStepLength = 0.1; - myIntegrationStep = 0.1; - myPropagationTime = 100; - return ScalarMap_i::Create(theMeshName,theEntity,theFieldName,theIteration); + const char* theFieldName, double theIteration) +{ + return DeformedShape_i::Create(theMeshName,theEntity,theFieldName,theIteration); } void VISU::StreamLines_i::SameAs(const StreamLines_i* theOrigin) { - StreamLines_i* aIsoLines = (StreamLines_i*) theOrigin; + myPrs3di = NULL; + StreamLines_i* aIsoLines = const_cast(theOrigin); SetDirection(aIsoLines->GetDirection()); SetStepLength(aIsoLines->GetStepLength()); SetIntegrationStep(aIsoLines->GetIntegrationStep()); SetPropagationTime(aIsoLines->GetPropagationTime()); VISU::DeformedShape_i::SameAs(theOrigin); + SetUsedPoints(aIsoLines->GetUsedPoints()); } VISU::Storable* VISU::StreamLines_i::Restore(const Storable::TRestoringMap& theMap, int theBuilding) @@ -1418,19 +1848,24 @@ VISU::Storable* VISU::StreamLines_i::Restore(const Storable::TRestoringMap& theM myIntegrationStep = VISU::Storable::FindValue(theMap,"myIntegrationStep").toDouble(); myPropagationTime = VISU::Storable::FindValue(theMap,"myPropagationTime").toDouble(); myDirection = (VISU::StreamLines::Direction) VISU::Storable::FindValue(theMap,"myDirection").toInt(); + mySourceEntry = VISU::Storable::FindValue(theMap,"mySourceEntry").latin1(); + myPercents = VISU::Storable::FindValue(theMap,"myPercents").toDouble(); + myPrs3di = NULL; if(theBuilding) return Build(true); return NULL; } -void VISU::StreamLines_i::ToStream(ostrstream& theStr){ +void VISU::StreamLines_i::ToStream(std::ostringstream& theStr){ DeformedShape_i::ToStream(theStr); Storable::DataToStream( theStr, "myStepLength", myStepLength ); Storable::DataToStream( theStr, "myIntegrationStep", myIntegrationStep ); Storable::DataToStream( theStr, "myPropagationTime", myPropagationTime ); Storable::DataToStream( theStr, "myDirection", (int)myDirection ); + Storable::DataToStream( theStr, "mySourceEntry", mySourceEntry.c_str()); + Storable::DataToStream( theStr, "myPercents", myPercents ); } @@ -1452,34 +1887,135 @@ VISU::StreamLines_i::~StreamLines_i(){ myStream->Delete(); } +void VISU::StreamLines_i::SetSource(VISU::Prs3d_ptr thePrs3d){ + if(thePrs3d->_is_nil()) { + myPrs3di = NULL; + mySourceEntry = ""; + } else { + myPrs3di = dynamic_cast(GetServant(thePrs3d)); + CORBA::String_var aString = thePrs3d->GetID(); + SALOMEDS::SObject_var aSObject = myStudy->FindObjectIOR(aString); + aString = aSObject->GetID(); + mySourceEntry = aString.in(); + } +} + +VISU::Prs3d_ptr VISU::StreamLines_i::GetSource(){ + VISU::Prs3d_var aPrs3d; + if(MYDEBUG) MESSAGE("StreamLines_i::GetSource() mySourceEntry = '"<FindObjectID(mySourceEntry.c_str()); + CORBA::Object_var anObj = SObjectToObject(aSObject); + if(!CORBA::is_nil(anObj)){ + aPrs3d = VISU::Prs3d::_narrow(anObj); + if(!aPrs3d->_is_nil()) + myPrs3di = dynamic_cast(GetServant(aPrs3d.in())); + } + } + return aPrs3d._retn(); +} + +// in this method we calculate minimal width of the dataset +// at least three integration steps could be in this width +float VISU::StreamLines_i::GetMaxIntegrationStep() { + float aMaxSizeY = fabs(myBounds[2] - myBounds[3]); + float aMaxSizeZ = fabs(myBounds[4] - myBounds[5]); + float aMinMax = fabs(myBounds[0] - myBounds[1]); + if (aMinMax < 1.0e-20 || (aMaxSizeY < aMinMax && aMaxSizeY > 1.0e-20)) aMinMax = aMaxSizeY; + if (aMinMax < 1.0e-20 || (aMaxSizeZ < aMinMax && aMaxSizeZ > 1.0e-20)) aMinMax = aMaxSizeZ; + return aMinMax / 2.0; +} + +float VISU::StreamLines_i::GetMinIntegrationStep() { + float aVolume = 1; + float degree = 0; + if (fabs(myBounds[0] - myBounds[1]) > 1.0e-20 ) { + aVolume *= fabs(myBounds[0] - myBounds[1]); + degree+=1.0; + } + if (fabs(myBounds[2] - myBounds[3]) > 1.0e-20 ) { + aVolume *= fabs(myBounds[2] - myBounds[3]); + degree+=1.0; + } + if (fabs(myBounds[4] - myBounds[5]) > 1.0e-20 ) { + aVolume *= fabs(myBounds[4] - myBounds[5]); + degree+=1.0; + } + if (degree < 0.5) return 0.0; // absolutely empty object + float anAverageVolume = aVolume / 1.0e+8; // we have to use no more, than 1GB memory (approx) + return pow((double)(anAverageVolume), (double)(1.0 / degree)); +} + +float VISU::StreamLines_i::GetBasePropagationTime() { + return myFieldTransform->GetUnstructuredGridOutput()->GetLength() / (GetMax() + GetMin()) * 2.0; +} VISU::ScalarMap_i::DataType* VISU::StreamLines_i::DoHook(int theRestoring){ + if(theRestoring == 0){ + myDirection = VISU::StreamLines::BOTH; + vtkDataSet *aDataSet = myFieldTransform->GetUnstructuredGridOutput(); + aDataSet->Update(); + + myIntegrationStep = GetMaxIntegrationStep() / 10.0; + float aMinMax = aDataSet->GetLength() / + (sqrt((float)(aDataSet->GetNumberOfPoints() + aDataSet->GetNumberOfCells()))+1.0); + if (aMinMax > myIntegrationStep) myIntegrationStep = (myIntegrationStep * 9.0 + aMinMax) / 10.0; + if (myIntegrationStep < GetMinIntegrationStep()) myIntegrationStep = GetMinIntegrationStep(); + + myPropagationTime = GetBasePropagationTime(); + myStepLength = myPropagationTime / 20.; + if (myStepLength > myIntegrationStep * 2) myStepLength = myIntegrationStep * 2; + if (myStepLength < myPropagationTime / 100.) myStepLength = myPropagationTime / 100.; + + myPrs3di = NULL; + myPercents = 0.3; + } + Update(); return myStream->GetOutput(); } +void SetStreamerSource(vtkStreamer *theStreamer, vtkDataSet* theDataSet, + VISU::Prs3d_i* thePrs3di, float thePercents) +{ + if(thePrs3di) + theDataSet = thePrs3di->GetMapper()->GetInput(); + theDataSet->Modified(); + theDataSet->Update(); + vtkMaskPoints *aMaskPoints = vtkMaskPoints::New(); + aMaskPoints->SetInput(theDataSet); + //aMaskPoints->RandomModeOn(); + int aNbPoints = (int)(theDataSet->GetNumberOfPoints()*thePercents); + if(MYDEBUG) MESSAGE("SetStreamerSource aNbPoints = "<GetNumberOfPoints()<<";\t"<SetMaximumNumberOfPoints(aNbPoints); + theStreamer->SetSource(aMaskPoints->GetOutput()); + aMaskPoints->Delete(); +} + void VISU::StreamLines_i::Update(){ + //apo - myStream->DebugOn(); + VISU::Prs3d_var aPrs3d = GetSource(); if(myField->myNbComp > 1){ + myStream->SetStepLength(myStepLength); + myStream->SetIntegrationStepLength(myIntegrationStep); + myStream->SetMaximumPropagationTime(myPropagationTime); if(myField->myEntity == VISU::CELL_ENTITY){ - //myStream->DebugOn(); vtkCellDataToPointData *aFilter = vtkCellDataToPointData::New(); aFilter->SetInput(myFieldTransform->GetUnstructuredGridOutput()); aFilter->PassCellDataOn(); myStream->SetInput(aFilter->GetOutput()); aFilter->Delete(); - vtkCellCenters *centers = vtkCellCenters::New(); // for vectors on cells centers->SetInput(myFieldTransform->GetUnstructuredGridOutput()); centers->VertexCellsOn(); - myStream->SetSource(centers->GetOutput()); + //myStream->SetSource(centers->GetOutput()); + SetStreamerSource(myStream,centers->GetOutput(),myPrs3di,myPercents); centers->Delete(); }else{ myStream->SetInput(myFieldTransform->GetUnstructuredGridOutput()); - myStream->SetSource(myFieldTransform->GetUnstructuredGridOutput()); + //myStream->SetSource(myFieldTransform->GetUnstructuredGridOutput()); + SetStreamerSource(myStream,myFieldTransform->GetUnstructuredGridOutput(),myPrs3di,myPercents); } - myStream->SetStepLength(myStepLength); - myStream->SetIntegrationStepLength(myIntegrationStep); - myStream->SetMaximumPropagationTime(myPropagationTime); switch (myDirection) { case VISU::StreamLines::FORWARD: myStream->SetIntegrationDirectionToForward(); @@ -1490,17 +2026,9 @@ void VISU::StreamLines_i::Update(){ case VISU::StreamLines::BOTH: myStream->SetIntegrationDirectionToIntegrateBothDirections(); } - myStream->Update(); - myMapper->Update(); } -} - - -VISU_Actor* VISU::StreamLines_i::CreateActor(const Handle(SALOME_InteractiveObject)& theIO) { - VISU_Actor* aActor = VISU::DeformedShape_i::CreateActor(theIO); - if ( ! aActor ) return NULL; - aActor->VisuActorType = VisuActorType_StreamLines; - return aActor; + myStream->Modified(); + VISU::DeformedShape_i::Update(); } //============================================================================== @@ -1526,8 +2054,12 @@ VISU::Vectors_i::Vectors_i(Result_i* theResult, bool theAddToStudy) : myHog = vtkHedgeHog::New(); } +void VISU::Vectors_i::Destroy(){ + DeformedShape_i::Destroy(); +} + void VISU::Vectors_i::SameAs(const VISU::Vectors_i* theOrigin) { - Vectors_i* aVectors = (Vectors_i*) theOrigin; + Vectors_i* aVectors = const_cast(theOrigin); SetLineWidth(aVectors->GetLineWidth()); SetGlyphType(aVectors->GetGlyphType()); SetGlyphPos(aVectors->GetGlyphPos()); @@ -1556,7 +2088,7 @@ VISU::Storable* VISU::Vectors_i::Restore(const Storable::TRestoringMap& theMap, return NULL; } -void VISU::Vectors_i::ToStream(ostrstream& theStr){ +void VISU::Vectors_i::ToStream(std::ostringstream& theStr){ DeformedShape_i::ToStream(theStr); Storable::DataToStream( theStr, "myTypeGlyph", myTypeGlyph ); @@ -1578,12 +2110,16 @@ VISU::Storable* VISU::VectorsRestore(SALOMEDS::SObject_ptr theSObject, VISU::ScalarMap_i::DataType* VISU::Vectors_i::DoHook(int theRestoring){ - if(!theRestoring){ - myFactor = ScaleFactor(); + if(theRestoring == 0){ + myTypeGlyph = VISU::Vectors::ARROW; + myLineWidth = 1; + myPosGlyph = VISU::Vectors::TAIL; + myFactor = ScaleFactor()/GetMax(); } if(MYDEBUG) MESSAGE("Vectors_i::DoHook() - myFactor = "< #include @@ -23,7 +27,7 @@ using namespace VISU; using namespace std; #ifdef DEBUG -static int MYDEBUG = 1; +static int MYDEBUG = 0; static int MYDEBUGWITHFILES = 0; #else static int MYDEBUG = 0; @@ -79,6 +83,17 @@ QString GenerateName(const char* theName){ return tmp; } +QString GenerateFieldName(const string& theName, const string& theUnits){ + static QString aName; + const string tmp(theUnits.size(),' '); + if(theUnits == "" || theUnits == tmp) + aName.sprintf("%s, -",theName.c_str()); + else + aName.sprintf("%s, %s",theName.c_str(),theUnits.c_str()); + aName = aName.simplifyWhiteSpace(); + return aName.latin1(); +} + void CreateReference(SALOMEDS::Study_ptr theStudyDocument, const string& theFatherEntry, const string& theRefEntry) { @@ -109,22 +124,22 @@ VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject) throw (std::runtime_error&) { if(MYDEBUG) MESSAGE("Result_i::Build"); - mySComponent = FindOrCreateVisuComponent(myStudyDocument); - CORBA::String_var aSComponentEntry = mySComponent->GetID(), anIOR(GetID()); - string aRefFatherEntry = GetRefFatherEntry(); - QString aComment; - aComment.sprintf("myComment=%s;myType=%d;myFileName=%s", - GetComment(),VISU::TRESULT,myFileInfo.filePath().latin1()); - string aResultEntry = CreateAttributes(myStudyDocument,aSComponentEntry,aRefFatherEntry.c_str(), - anIOR,myName.c_str(),"",aComment.latin1(),true); - mySObject = myStudyDocument->FindObjectID(aResultEntry.c_str()); - if(mySObject->_is_nil()) throw std::runtime_error("Build - There is no SObject for the Result !!!"); - if(theSObject != NULL){ - CORBA::String_var aString = theSObject->GetID(); - CreateReference(myStudyDocument,aResultEntry,aString.in()); - } const TMeshMap& aMeshMap = myInput->GetMeshMap(); if(!aMeshMap.empty()) {//apo + mySComponent = FindOrCreateVisuComponent(myStudyDocument); + CORBA::String_var aSComponentEntry = mySComponent->GetID(), anIOR(GetID()); + string aRefFatherEntry = GetRefFatherEntry(); + QString aComment; + aComment.sprintf("myComment=%s;myType=%d;myFileName=%s", + GetComment(),VISU::TRESULT,myFileInfo.filePath().latin1()); + string aResultEntry = CreateAttributes(myStudyDocument,aSComponentEntry,aRefFatherEntry.c_str(), + anIOR,myName.c_str(),"",aComment.latin1(),true); + mySObject = myStudyDocument->FindObjectID(aResultEntry.c_str()); + if(mySObject->_is_nil()) throw std::runtime_error("Build - There is no SObject for the Result !!!"); + if(theSObject != NULL){ + CORBA::String_var aString = theSObject->GetID(); + CreateReference(myStudyDocument,aResultEntry,aString.in()); + } TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ const string& aMeshName = aMeshMapIter->first; @@ -215,10 +230,11 @@ VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject) const string& aFieldName = aFieldMapIter->first; const VISU::TField& aField = aFieldMapIter->second; const VISU::TField::TValField& aValField = aField.myValField; + QString aFieldNameWithUnit = ::GenerateFieldName(aFieldName,aField.myUnitNames[0]); aComment.sprintf("myComment=FIELD;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s;myNbTimeStamps=%d;myNumComponent=%d", VISU::TFIELD,aMeshName.c_str(),anEntity,aFieldName.c_str(),aValField.size(),aField.myNbComp); string aFieldEntry = CreateAttributes(myStudyDocument,aFieldsEntry.c_str(),aRefFatherEntry.c_str(), - "",aFieldName.c_str(),"",aComment.latin1(),true); + "",aFieldNameWithUnit.latin1(),"",aComment.latin1(),true); CreateReference(myStudyDocument,aFieldEntry,aEntity2Entry[anEntity]); VISU::TField::TValField::const_iterator aValFieldIter = aValField.begin(); for(; aValFieldIter != aValField.end(); aValFieldIter++){ @@ -243,8 +259,9 @@ VISU::Storable* VISU::Result_i::Create(const char* theFileName){ myInput = CreateConvertor(theFileName); if(myInput == NULL) return NULL; myFileInfo.setFile(theFileName); - myName = ::GenerateName(myFileInfo.fileName().latin1()); - return Build(); + myName = (const char*)(::GenerateName(myFileInfo.fileName().latin1())); + VISU::Storable* aStorable = Build(); + return aStorable; }catch(std::runtime_error& exc){ MESSAGE("Follow exception was accured :\n"<GetStudy(); mySComponent = mySObject->GetFatherComponent(); - myName = VISU::Storable::FindValue(theMap,"myName"); + myName = (const char*)(VISU::Storable::FindValue(theMap,"myName")); SALOMEDS::SObject_var aRefSObj, aTargetRefSObj; if(mySObject->FindSubObject(1,aRefSObj) && aRefSObj->ReferencedObject(aTargetRefSObj)){ mySourceId = eRestoredComponent; @@ -300,16 +337,45 @@ VISU::Storable* VISU::Result_i::Restore(SALOMEDS::SObject_ptr theSObject, }else throw std::runtime_error("GetInput - There is no convertor for the aDataType !!!"); }else{ - mySourceId = eRestoredFile; myFileInfo.setFile(thePrefix.c_str()); + string aStudyPrefix(SALOMEDS_Tool::GetNameFromPath(myStudyDocument->URL())); - string aTmpDir(SALOMEDS_Tool::GetDirFromPath(myStudyDocument->URL())); if(!myFileInfo.isFile()){ - string aFileName = thePrefix + aStudyPrefix + "_" + myName; + string aFileName = thePrefix + aStudyPrefix + "_" + myName; myFileInfo.setFile(aFileName.c_str()); } if(MYDEBUG) MESSAGE("Result_i::Restore - aFileName = "<SetValue(aComment.latin1()); - // remove temporary file, if it's not multifile mode - if (false || !IsMultifile()) { - SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; - aSeq->length(1); - aSeq[0]=(aStudyPrefix + myName).c_str(); - SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true); - } } return this; }catch(std::runtime_error& exc){ @@ -340,7 +399,7 @@ VISU::Result_i::InputType* VISU::Result_i::GetInput() { return myInput; } -void VISU::Result_i::ToStream(ostrstream& theStr){ +void VISU::Result_i::ToStream(std::ostringstream& theStr){ if(MYDEBUG) MESSAGE(GetComment()); Storable::DataToStream(theStr,"myName",myName.c_str()); } diff --git a/src/VISU_I/VISU_Result_i.hh b/src/VISU_I/VISU_Result_i.hh index 441e8260..d796d86c 100644 --- a/src/VISU_I/VISU_Result_i.hh +++ b/src/VISU_I/VISU_Result_i.hh @@ -1,7 +1,10 @@ -// File: VISU_Result_i.hh -// Created: Fri Jan 10 12:36:38 2003 -// Author: Alexey PETROV -// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_Result_i.hh +// Author : Alexey PETROV +// Module : VISU #ifndef __VISU_RESULT_I_H__ #define __VISU_RESULT_I_H__ @@ -40,10 +43,11 @@ namespace VISU{ public: virtual Storable* Create(const char* theFileName); virtual Storable* Create(SALOMEDS::SObject_ptr theMedSObject); + virtual Storable* Create(SALOME_MED::FIELD_ptr theField); virtual Storable* Restore(SALOMEDS::SObject_ptr theSObject, const string& thePrefix, const Storable::TRestoringMap& theMap) throw(std::logic_error&); - virtual void ToStream(ostrstream& theStr); + virtual void ToStream(std::ostringstream& theStr); virtual const char* GetComment() const; static const string myComment; InputType* GetInput(); diff --git a/src/VISU_I/VISU_Table_i.cc b/src/VISU_I/VISU_Table_i.cc index ba5dda37..5d01988c 100644 --- a/src/VISU_I/VISU_Table_i.cc +++ b/src/VISU_I/VISU_Table_i.cc @@ -1,9 +1,12 @@ -using namespace std; -// File: VISU_Table_i.cc -// Created: Thu Feb 13 17:57:39 2003 -// Author: Vadim SANDLER -// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_Table_i.cc +// Author : Vadim SANDLER +// Module : VISU +using namespace std; #include "VISU_Table_i.hh" #include "QAD_Application.h" @@ -101,7 +104,9 @@ CORBA::Long VISU::Table_i::GetNbColumns() VISU::Storable* VISU::Table_i::Create() { // generate name ... - myName = GenerateName(); + myName = GetTableTitle(); + if ( myName == "" ) + myName = GenerateName(); // ... and build the object return Build( false ); } @@ -113,10 +118,17 @@ VISU::Storable* VISU::Table_i::Build( int theRestoring ) // look for reference SObject with table attribute SALOMEDS::SObject_var SO = myStudy->FindObjectID( myObjectEntry.c_str() ); if ( !SO->_is_nil() ) { + CutLines_i* pCutLines = NULL; + CORBA::Object_var anObj = SObjectToObject(SO); + if(!CORBA::is_nil(anObj)){ + VISU::CutLines_var aCutLines = VISU::CutLines::_narrow(anObj); + if(!aCutLines->_is_nil()) + pCutLines = dynamic_cast(GetServant(aCutLines)); + } SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder(); SALOMEDS::GenericAttribute_var anAttr; if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) || - Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) { + Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) || pCutLines) { // look for component if ( !theRestoring ) { SALOMEDS::SComponent_var SComponent = VISU::FindOrCreateVisuComponent( myStudy ); @@ -133,6 +145,10 @@ VISU::Storable* VISU::Table_i::Build( int theRestoring ) true ); // create SObject referenced to real table object SALOMEDS::SObject_var newSO = myStudy->FindObjectID( anEntry.c_str() ); + if(pCutLines) { + pCutLines->BuildTableOfReal(newSO); + myObjectEntry = anEntry; + } SALOMEDS::SObject_var refSO = Builder->NewObject( newSO ); Builder->Addreference( refSO, SO ); } @@ -148,26 +164,21 @@ VISU::Storable* VISU::Table_i::Restore( const Storable::TRestoringMap& theMap ) throw( std::logic_error& ) { if(MYDEBUG) MESSAGE(GetComment()); - myName = VISU::Storable::FindValue(theMap,"myName"); - myObjectEntry = VISU::Storable::FindValue(theMap,"myObjectEntry"); - myTitle = VISU::Storable::FindValue(theMap,"myTitle"); + myName = (const char*)(VISU::Storable::FindValue(theMap,"myName")); + myObjectEntry = (const char *)(VISU::Storable::FindValue(theMap,"myObjectEntry")); + myTitle = (const char*)(VISU::Storable::FindValue(theMap,"myTitle")); myOrientation = ( VISU::Table::Orientation )( VISU::Storable::FindValue(theMap,"myOrientation").toInt() ); return Build( true ); } /*! Flushes table data into stream */ -void VISU::Table_i::ToStream( ostrstream& theStr ) +void VISU::Table_i::ToStream( std::ostringstream& theStr ) { Storable::DataToStream( theStr, "myName", myName.c_str() ); Storable::DataToStream( theStr, "myObjectEntry", myObjectEntry.c_str() ); Storable::DataToStream( theStr, "myTitle", myTitle.c_str() ); Storable::DataToStream( theStr, "myOrientation", myOrientation ); - -// theStr<<"\n myName ="<Restore( theMap ); } +/*! + Gets title for the original table object +*/ +const char* VISU::Table_i::GetTableTitle() +{ + SALOMEDS::SObject_var SO = myStudy->FindObjectID( GetObjectEntry() ); + SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder(); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeTableOfInteger_var anInt; + SALOMEDS::AttributeTableOfReal_var aReal; + if ( !SO->_is_nil() ) { + if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) { + anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr ); + return anInt->GetTitle(); + } + else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) { + aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr ); + return aReal->GetTitle(); + } + } + return ""; +} //---------------------------------------------------------------- // Curve Object @@ -239,7 +272,9 @@ VISU::Curve_i::~Curve_i() VISU::Storable* VISU::Curve_i::Create() { // generate name ... - myName = GenerateName(); + myName = GetVerTitle(); + if ( myName == "" ) + myName = GenerateName(); // ... and build the object return Build( false ); } @@ -440,10 +475,12 @@ int VISU::Curve_i::GetData( double*& theHorList, double*& theVerList ) if ( nbPoints > 0 ) { theHorList = new double[ nbPoints ]; theVerList = new double[ nbPoints ]; + int k = 0; for ( int j = 1; j <= nbCols; j++ ) { if ( anInt->HasValue( myHRow, j ) && anInt->HasValue( myVRow, j ) ) { - theHorList[j-1] = anInt->GetValue( myHRow, j ); - theVerList[j-1] = anInt->GetValue( myVRow, j ); + theHorList[k] = anInt->GetValue( myHRow, j ); + theVerList[k] = anInt->GetValue( myVRow, j ); + k++; } } } @@ -462,10 +499,12 @@ int VISU::Curve_i::GetData( double*& theHorList, double*& theVerList ) if ( nbPoints > 0 ) { theHorList = new double[ nbPoints ]; theVerList = new double[ nbPoints ]; + int k = 0; for ( int j = 1; j <= nbCols; j++ ) { if ( aReal->HasValue( myHRow, j ) && aReal->HasValue( myVRow, j ) ) { - theHorList[j-1] = aReal->GetValue( myHRow, j ); - theVerList[j-1] = aReal->GetValue( myVRow, j ); + theHorList[k] = aReal->GetValue( myHRow, j ); + theVerList[k] = aReal->GetValue( myVRow, j ); + k++; } } } @@ -481,23 +520,33 @@ int VISU::Curve_i::GetData( double*& theHorList, double*& theVerList ) Plot2d_Curve* VISU::Curve_i::CreatePresentation() { Plot2d_Curve* crv = new Plot2d_Curve(); - crv->setHorTitle( strdup( GetHorTitle().c_str() ) ); + crv->setHorTitle( GetHorTitle().c_str() ); + string tlt = GetTitle(); + if ( tlt.length() <= 0 ) + tlt = GetVerTitle(); //crv->setVerTitle( strdup( GetVerTitle().c_str() ) ); - crv->setVerTitle( strdup( GetName() ) ); - crv->setHorUnits( strdup( GetHorUnits().c_str() ) ); - crv->setVerUnits( strdup( GetVerUnits().c_str() ) ); + //crv->setVerTitle( strdup( GetName() ) ); + crv->setVerTitle( tlt.c_str() ); + crv->setHorUnits( GetHorUnits().c_str() ); + crv->setVerUnits( GetVerUnits().c_str() ); double* xList = 0; double* yList = 0; int nbPoints = GetData( xList, yList ); if ( nbPoints > 0 && xList && yList ) { crv->setData( xList, yList, nbPoints ); } + //cout << "********** Number of points: " << nbPoints <setLine( (Plot2d_Curve::LineType)GetLine(), GetLineWidth() ); crv->setMarker( (Plot2d_Curve::MarkerType)GetMarker() ); 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(GetEntry()),"VISU",strdup(GetName()))); + if ( myTable ) + crv->setTableIO(new SALOME_InteractiveObject(strdup(myTable->GetEntry()),"VISU",strdup(myTable->GetName()))); return crv; } /*! @@ -507,7 +556,7 @@ VISU::Storable* VISU::Curve_i::Restore( const Storable::TRestoringMap& theMap ) throw( std::logic_error& ) { if(MYDEBUG) MESSAGE(GetComment()); - myName = VISU::Storable::FindValue(theMap,"myName"); + myName = (const char*)(VISU::Storable::FindValue(theMap,"myName")); myHRow = VISU::Storable::FindValue(theMap,"myHRow").toInt(); myVRow = VISU::Storable::FindValue(theMap,"myVRow").toInt(); myColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble(); @@ -520,9 +569,9 @@ VISU::Storable* VISU::Curve_i::Restore( const Storable::TRestoringMap& theMap ) /*! Flushes curve data into stream */ -void VISU::Curve_i::ToStream( ostrstream& theStr ) +void VISU::Curve_i::ToStream( std::ostringstream& theStr ) { - Storable::DataToStream( theStr, "TableID", GetTableID() ); + Storable::DataToStream( theStr, "TableID", GetTableID()); Storable::DataToStream( theStr, "myName", myName.c_str() ); Storable::DataToStream( theStr, "myHRow", myHRow ); Storable::DataToStream( theStr, "myVRow", myVRow ); @@ -536,7 +585,7 @@ void VISU::Curve_i::ToStream( ostrstream& theStr ) Gets reference table's entry */ const char* VISU::Curve_i::GetTableID() { - return myTable->GetEntry(); + return CORBA::string_dup(myTable->GetEntry()); } /*! Called from engine to restore curve from the file @@ -596,7 +645,7 @@ void VISU::Container_i::AddCurve( Curve_ptr theCurve ) SALOMEDS::SObject_var mySO = myStudy->FindObjectID( GetEntry() ); if ( mySO->_is_nil() ) return; - PortableServer::POA_var aPOA = GetPOA(); + PortableServer::POA_ptr aPOA = GetPOA(); Curve_i* pCurve = dynamic_cast( aPOA->reference_to_servant( theCurve ) ); if( pCurve ) { QString entry = pCurve->GetEntry(); @@ -619,7 +668,7 @@ void VISU::Container_i::RemoveCurve( Curve_ptr theCurve ) SALOMEDS::SObject_var mySO = myStudy->FindObjectID( GetEntry() ); if ( mySO->_is_nil() ) return; - PortableServer::POA_var aPOA = GetPOA(); + PortableServer::POA_ptr aPOA = GetPOA(); Curve_i* pCurve = dynamic_cast( aPOA->reference_to_servant( theCurve ) ); if( pCurve ) { QString entry = pCurve->GetEntry(); @@ -787,7 +836,7 @@ VISU::Storable* VISU::Container_i::Restore( const Storable::TRestoringMap& theMa throw( std::logic_error& ) { if(MYDEBUG) MESSAGE(GetComment()); - myName = VISU::Storable::FindValue( theMap, "myName" ); + myName = (const char*)(VISU::Storable::FindValue( theMap, "myName" )); QString val = VISU::Storable::FindValue( theMap, "myCurves" ); myCurves = QStringList::split( QString( "*" ), val, false ); return Build( true ); @@ -795,7 +844,7 @@ VISU::Storable* VISU::Container_i::Restore( const Storable::TRestoringMap& theMa /*! Flushes container data into the stream */ -void VISU::Container_i::ToStream( ostrstream& theStr ) +void VISU::Container_i::ToStream( std::ostringstream& theStr ) { Storable::DataToStream( theStr, "myName", myName.c_str() ); Storable::DataToStream( theStr, "myCurves", myCurves.join( QString( "*" ) ) ); @@ -893,73 +942,73 @@ void ImportTables(const char* theFileName, TTableCont& theTableCont){ do{ //Find beginning of Table while(getLine(aStmIn,aTmp) && aTmp == "\n"); - cout<<"\n There is new Table2D with Title = "; + //cout<<"\n There is new Table2D with Title = "; 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; - cout< 0){ QStringList aStrList = QStringList::split("#TITLE:",aTmp); QString aTitle = aStrList[1].stripWhiteSpace(); TRow aRow; - aRow.myTitle = aTitle; - cout<NewObject(aFileObject); anAttr = aStudyBuilder->FindOrCreateAttribute(aRealObject, "AttributeName"); aName = SALOMEDS::AttributeName::_narrow(anAttr); - cout<<"aTable2D.myTitle = "<SetValue(aTable2D.myTitle.c_str()); else{ @@ -1035,10 +1084,10 @@ SALOMEDS::SObject_var VISU::ImportTables(const char* theFileName, SALOMEDS::Stud int kEnd = aNewTable2D.myRows[0].myValues.size(); aTableOfReal->SetNbColumns(kEnd); for(int j = 0, jEnd = aNewTable2D.myRows.size(); j < jEnd; j++){ - cout<<"j = "<(GetServant(theView3D)); + QAD_StudyFrame* aStudyFrame = pView->GetStudyFrame(); + myView = VISU::GetViewFrame(aStudyFrame); + } + myMaxVal = 0; myMinVal = 0; + myTimeMin = 0; + myTimeMax = 0; + myLastError = ""; + myCycling = false; } //************************************************************************ VISU_TimeAnimation::~VISU_TimeAnimation() { - for (int i = 0; i < getNbFields(); i++) + for (int i = 0; i < getNbFields(); i++) { clearData(myFieldsLst[i]); + } } //************************************************************************ -void VISU_TimeAnimation::addField(SALOMEDS::SObject_var theField) { +void VISU_TimeAnimation::addField(SALOMEDS::SObject_ptr theField) { FieldData aNewData; - aNewData.myField = theField; - aNewData.myNbTimes = 0; + aNewData.myField = SALOMEDS::SObject::_duplicate(theField); + aNewData.myNbFrames = 0; aNewData.myPrs = 0; aNewData.myActors = 0; aNewData.myTiming = 0; aNewData.myPrsType = VISU::TSCALARMAP; + VISU::Storable::TRestoringMap aMap = getMapOfValue(aNewData.myField); + aNewData.myNbTimes = VISU::Storable::FindValue(aMap,"myNbTimeStamps").toLong(); myFieldsLst.append(aNewData); + + //find Min/Max timestamps + if ((myTimeMin == 0) && (myTimeMax == 0)) { + SALOMEDS::ChildIterator_var anIter = myStudy->NewChildIterator(theField); + SALOMEDS::SObject_var aTimeStamp; + anIter->Next(); // First is reference on support + myTimeMin = getTimeValue(anIter->Value()); + for(; anIter->More(); anIter->Next()) { + myTimeMax = getTimeValue(anIter->Value()); + } + } } @@ -51,27 +78,28 @@ void VISU_TimeAnimation::clearData(FieldData& theData) { } vtkRenderer* aRen = myView->getRenderer(); if (theData.myActors) { - for (int i = 0; i < theData.myNbTimes; i++) { - if (theData.myActors[i]->HasScalarBar() && (i==0)) - aRen->RemoveActor2D(theData.myActors[i]->getScalarBar()); - aRen->RemoveActor(theData.myActors[i]); - theData.myActors[i]->Delete(); + for (int i = 0; i < theData.myNbFrames; i++) { + if (theData.myActors[i] != 0) { + theData.myActors[i]->RemoveFromRender(aRen); + theData.myActors[i]->Delete(); + } } free(theData.myActors); theData.myActors = 0; } if (theData.myPrs) { - for (int i = 0; i < theData.myNbTimes; i++) + for (int i = 0; i < theData.myNbFrames; i++) theData.myPrs[i]->_remove_ref(); free(theData.myPrs); theData.myPrs = 0; } - theData.myNbTimes = 0; + theData.myNbFrames = 0; + myView->update(); } //************************************************************************ -void VISU_TimeAnimation::generatePresentations(int theFieldNum) { +void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) { FieldData& aData = myFieldsLst[theFieldNum]; // Delete previous presentations @@ -79,7 +107,8 @@ void VISU_TimeAnimation::generatePresentations(int theFieldNum) { VISU::Result_i* pResult = createPresent(aData.myField); VISU::Storable::TRestoringMap aMap = getMapOfValue(aData.myField); - aData.myNbTimes = VISU::Storable::FindValue(aMap,"myNbTimeStamps").toLong(); + aData.myNbFrames = aData.myNbTimes; + //VISU::Storable::FindValue(aMap,"myNbTimeStamps").toLong(); aData.myPrs = (VISU::ScalarMap_i**) malloc(aData.myNbTimes * sizeof(VISU::ScalarMap_i*)); aData.myTiming = (double*) malloc(aData.myNbTimes * sizeof(double)); @@ -91,7 +120,7 @@ void VISU_TimeAnimation::generatePresentations(int theFieldNum) { double aMin = 0, aMax = 0; for(;anIter->More();anIter->Next()) { if (i == aData.myNbTimes) { - MESSAGE("Found extra timestamps in field"); + MESSAGE("There are extra timestamps in field"); return; } aTimeStamp = anIter->Value(); @@ -180,48 +209,47 @@ void VISU_TimeAnimation::generatePresentations(int theFieldNum) { if (aData.myPrs[i]->GetMax() > aMax) aMax = aData.myPrs[i]->GetMax(); i++; } - aData.myNbTimes = i; - for (i = 0; i < aData.myNbTimes; i++) + aData.myNbFrames = i; + for (i = 0; i < aData.myNbFrames; i++) aData.myPrs[i]->SetRange(aMin, aMax); } //************************************************************************ -bool VISU_TimeAnimation::generateFrames() { +CORBA::Boolean VISU_TimeAnimation::generateFrames() { if (!myView) { MESSAGE("Viewer is nod defined for animation"); return false; } + myLastError = QString("Frame(s) for "); + bool aNoError = true; + VISU::Mutex mt(myMutex,qApp,MYDELAY); clearView(); vtkRenderer* aRen = myView->getRenderer(); for (int i = 0; i < getNbFields(); i++) { FieldData& aData = myFieldsLst[i]; - aData.myActors = (VISU_Actor**) malloc(aData.myNbTimes * sizeof(VISU_Actor*)); - for (long j = 0; j < aData.myNbTimes; j++) { + aData.myActors = (VISU_Actor**) malloc(aData.myNbFrames * sizeof(VISU_Actor*)); + for (long j = 0; j < aData.myNbFrames; j++) { VISU_Actor* aActor = aData.myPrs[j]->CreateActor(); if (aActor == NULL) { - for (int k = 0; k < j; k++) { - aData.myActors[k]->Delete(); - } - free(aData.myActors); - aData.myActors = 0; - return false; + aNoError = false; + aActor = 0; + myLastError += QString("%1 ").arg(aData.myTiming[j]); + } else { + myView->AddActor(aActor); + if (j == 0) { + aActor->VisibilityOn(); + } else + aActor->VisibilityOff(); } - aRen->AddActor(aActor); - if (j == 0) { - aActor->VisibilityOn(); - if (aActor->HasScalarBar()) { - aRen->AddActor2D(aActor->getScalarBar()); - } - } else - aActor->VisibilityOff(); aData.myActors[j] = aActor; } } myFrame = 0; + myLastError += QString(" timestamp(s) cannot be created."); emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]); myView->Repaint(); - return true; + return aNoError; } //************************************************************************ @@ -230,20 +258,22 @@ void VISU_TimeAnimation::clearView() { MESSAGE("Viewer is nod defined for animation"); return; } + VISU::Mutex mt(myMutex,qApp,MYDELAY); vtkRenderer* aRen = myView->getRenderer(); for (int i = 0; i < getNbFields(); i++) { FieldData& aData = myFieldsLst[i]; if (aData.myActors) { - for (int i = 0; i < aData.myNbTimes; i++) { - if (aData.myActors[i]->HasScalarBar() && (i==0)) - aRen->RemoveActor2D(aData.myActors[i]->getScalarBar()); - aRen->RemoveActor(aData.myActors[i]); - aData.myActors[i]->Delete(); - } + for (int i = 0; i < aData.myNbFrames; i++) { + if (aData.myActors[i] != 0) { + aData.myActors[i]->RemoveFromRender(aRen); + aData.myActors[i]->Delete(); + } + } free(aData.myActors); aData.myActors = 0; } } + myView->update(); } //************************************************************************ @@ -262,13 +292,15 @@ void VISU_TimeAnimation::startAnimation() { //************************************************************************ void VISU_TimeAnimation::nextFrame() { stopAnimation(); - if (myFrame < (myFieldsLst[0].myNbTimes-1)) { + if (myFrame < (myFieldsLst[0].myNbFrames-1)) { int i; for (i = 0; i < getNbFields(); i++) - myFieldsLst[i].myActors[myFrame]->VisibilityOff(); + if (myFieldsLst[i].myActors[myFrame] != 0) + myFieldsLst[i].myActors[myFrame]->VisibilityOff(); myFrame++; for (i = 0; i < getNbFields(); i++) - myFieldsLst[i].myActors[myFrame]->VisibilityOn(); + if (myFieldsLst[i].myActors[myFrame] != 0) + myFieldsLst[i].myActors[myFrame]->VisibilityOn(); emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]); myView->Repaint(); @@ -281,10 +313,12 @@ void VISU_TimeAnimation::prevFrame() { if (myFrame > 0) { int i; for (i = 0; i < getNbFields(); i++) - myFieldsLst[i].myActors[myFrame]->VisibilityOff(); + if (myFieldsLst[i].myActors[myFrame] != 0) + myFieldsLst[i].myActors[myFrame]->VisibilityOff(); myFrame--; for (i = 0; i < getNbFields(); i++) - myFieldsLst[i].myActors[myFrame]->VisibilityOn(); + if (myFieldsLst[i].myActors[myFrame] != 0) + myFieldsLst[i].myActors[myFrame]->VisibilityOn(); emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]); myView->Repaint(); @@ -296,10 +330,12 @@ void VISU_TimeAnimation::firstFrame() { stopAnimation(); int i; for (i = 0; i < getNbFields(); i++) - myFieldsLst[i].myActors[myFrame]->VisibilityOff(); + if (myFieldsLst[i].myActors[myFrame] != 0) + myFieldsLst[i].myActors[myFrame]->VisibilityOff(); myFrame = 0; for (i = 0; i < getNbFields(); i++) - myFieldsLst[i].myActors[myFrame]->VisibilityOn(); + if (myFieldsLst[i].myActors[myFrame] != 0) + myFieldsLst[i].myActors[myFrame]->VisibilityOn(); emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]); myView->Repaint(); @@ -310,10 +346,12 @@ void VISU_TimeAnimation::lastFrame() { stopAnimation(); int i; for (i = 0; i < getNbFields(); i++) - myFieldsLst[i].myActors[myFrame]->VisibilityOff(); - myFrame = myFieldsLst[0].myNbTimes-1; + if (myFieldsLst[i].myActors[myFrame] != 0) + myFieldsLst[i].myActors[myFrame]->VisibilityOff(); + myFrame = myFieldsLst[0].myNbFrames-1; for (i = 0; i < getNbFields(); i++) - myFieldsLst[i].myActors[myFrame]->VisibilityOn(); + if (myFieldsLst[i].myActors[myFrame] != 0) + myFieldsLst[i].myActors[myFrame]->VisibilityOn(); emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]); myView->Repaint(); @@ -321,34 +359,42 @@ void VISU_TimeAnimation::lastFrame() { //************************************************************************ -void VISU_TimeAnimation::gotoFrame(long theFrame) { +// For Batchmode using +void VISU_TimeAnimation::gotoFrame(CORBA::Long theFrame) { if ((theFrame < 0) || (theFrame > (getNbFrames()-1))) return; stopAnimation(); + qApp->lock(); + qApp->syncX(); int i; for (i = 0; i < getNbFields(); i++) - myFieldsLst[i].myActors[myFrame]->VisibilityOff(); + if (myFieldsLst[i].myActors[myFrame] != 0) + myFieldsLst[i].myActors[myFrame]->VisibilityOff(); myFrame = theFrame; for (i = 0; i < getNbFields(); i++) - myFieldsLst[i].myActors[myFrame]->VisibilityOn(); + if (myFieldsLst[i].myActors[myFrame] != 0) + myFieldsLst[i].myActors[myFrame]->VisibilityOn(); emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]); myView->Repaint(); + qApp->flushX(); + qApp->processEvents(3); + qApp->unlock(); } //************************************************************************ -VISU::ScalarMap_i* VISU_TimeAnimation::getPresentation(int theField, long theFrame) { +VISU::ScalarMap_ptr VISU_TimeAnimation::getPresentation(CORBA::Long theField, CORBA::Long theFrame) { if ((theField > getNbFields()) || (theField < 0)) - return NULL; - if ((theFrame < 0) || (theFrame > (myFieldsLst[theField].myNbTimes - 1))) - return NULL; - return myFieldsLst[theField].myPrs[theFrame]; + return VISU::ScalarMap::_nil(); + if ((theFrame < 0) || (theFrame > (myFieldsLst[theField].myNbFrames - 1))) + return VISU::ScalarMap::_nil(); + return myFieldsLst[theField].myPrs[theFrame]->_this(); } //************************************************************************ -long VISU_TimeAnimation::getNbFrames() { - return (getNbFields() > 0)? myFieldsLst[0].myNbTimes : 0; +CORBA::Long VISU_TimeAnimation::getNbFrames() { + return (getNbFields() > 0)? myFieldsLst[0].myNbFrames : 0; } @@ -362,18 +408,24 @@ void VISU_TimeAnimation::run() { double k=1; double aOneVal; bool isDumping = !myDumpPath.isEmpty(); - aOneVal = (myFieldsLst[0].myNbTimes > 2) ? + aOneVal = (myFieldsLst[0].myNbFrames > 2) ? myFieldsLst[0].myTiming[1] - myFieldsLst[0].myTiming[0] : 1; - while (true) { - qApp->lock(); + qApp->lock(); + while (myIsActive) { emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]); for (int i = 0; i < getNbFields(); i++) { FieldData& aData = myFieldsLst[i]; - if (myFrame > 0) aData.myActors[myFrame-1]->VisibilityOff(); - else aData.myActors[aData.myNbTimes-1]->VisibilityOff(); - - aData.myActors[myFrame]->VisibilityOn(); + if (myFrame > 0) { + if (aData.myActors[myFrame-1] != 0) + aData.myActors[myFrame-1]->VisibilityOff(); + } else { + if (aData.myActors[aData.myNbFrames-1] != 0) + aData.myActors[aData.myNbFrames-1]->VisibilityOff(); + } + if (aData.myActors[myFrame] != 0) { + aData.myActors[myFrame]->VisibilityOn(); + } } myView->Repaint(); if (isDumping) { @@ -387,8 +439,6 @@ void VISU_TimeAnimation::run() { aFile += ".jpeg"; px.save(aFile, "JPEG"); } - qApp->unlock(); - if (!isDumping) { if (myProportional) { switch (myFrame) { @@ -396,26 +446,41 @@ void VISU_TimeAnimation::run() { k=1; break; case 1: - if (myFieldsLst[0].myNbTimes > 2) + if (myFieldsLst[0].myNbFrames > 2) k = (myFieldsLst[0].myTiming[myFrame+1] - myFieldsLst[0].myTiming[myFrame])/aOneVal; else k = 1; break; default: - k = (myFrame < (myFieldsLst[0].myNbTimes-1))? + k = (myFrame < (myFieldsLst[0].myNbFrames-1))? (myFieldsLst[0].myTiming[myFrame+1] - myFieldsLst[0].myTiming[myFrame])/aOneVal : 1; } } else k = 1; - msleep((int) 1000.*k/mySpeed); + qApp->unlock(); + msleep((int)(1000.*k/mySpeed)); + qApp->lock(); + } else { + qApp->unlock(); + msleep(100); + qApp->lock(); } - if (!myIsActive) QThread::exit(); - + if (!myIsActive) break; + myFrame++; - if (myFrame == myFieldsLst[0].myNbTimes) - myFrame = 0; + if (myFrame == myFieldsLst[0].myNbFrames) { + if (!myCycling) { + myIsActive = false; + myFrame--; + break; + } else + myFrame = 0; + } } + emit stopped(); + qApp->unlock(); + QThread::exit(); } //************************************************************************ @@ -455,6 +520,6 @@ double VISU_TimeAnimation::getTimeValue(SALOMEDS::SObject_var theTimeStamp) { } //************************************************************************ -void VISU_TimeAnimation::setSpeed(int theSpeed) { +void VISU_TimeAnimation::setSpeed(CORBA::Long theSpeed) { mySpeed = (theSpeed<1)? 1 : theSpeed; } diff --git a/src/VISU_I/VISU_TimeAnimation.h b/src/VISU_I/VISU_TimeAnimation.h index 87f08e6e..34af55dc 100644 --- a/src/VISU_I/VISU_TimeAnimation.h +++ b/src/VISU_I/VISU_TimeAnimation.h @@ -1,9 +1,10 @@ -// File : VISU_TimeAnimation.h -// Created : 10 / 04 / 2003 -// Author : Vitaly SMETANNIKOV -// Project : SALOME -// Module : VISU_I -// Copyright : Open CASCADE +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_TimeAnimation.h +// Author : Vitaly SMETANNIKOV +// Module : VISU #ifndef VISU_TIMEANIMATION_H #define VISU_TIMEANIMATION_H @@ -13,6 +14,7 @@ #include #include "VISU_Actor.h" #include "VISU_PrsObject_i.hh" +#include "VISU_ViewManager_i.hh" #include "VTKViewer_ViewFrame.h" @@ -21,28 +23,33 @@ struct FieldData VISU::VISUType myPrsType; SALOMEDS::SObject_var myField; // field label long myNbTimes; // number of Timestamps + long myNbFrames; // number of created Frames VISU::ScalarMap_i** myPrs; // Presentations VISU_Actor** myActors; // Actors double* myTiming; // time values }; -class VISU_TimeAnimation: public QObject, public QThread +class VISU_TimeAnimation: public QObject, public QThread, + public virtual POA_VISU::Animation, + public virtual VISU::Base_i { - Q_OBJECT + Q_OBJECT; public: static VISU::Result_i* createPresent(SALOMEDS::SObject_var theField); static VISU::Storable::TRestoringMap getMapOfValue(SALOMEDS::SObject_var theSObject); static double getTimeValue(SALOMEDS::SObject_var theTimestamp); - VISU_TimeAnimation(SALOMEDS::Study_var theStudy); + VISU_TimeAnimation(SALOMEDS::Study_var theStudy, VISU::View3D_ptr theView3D = VISU::View3D::_nil()); ~VISU_TimeAnimation(); - - void addField(SALOMEDS::SObject_var theField); + + virtual VISU::VISUType GetType() { return VISU::TNONE;}; + + void addField(SALOMEDS::SObject_ptr theField); FieldData& getFieldData(int theNum) { return myFieldsLst[theNum]; } - bool generateFrames(); - void generatePresentations(int theFieldNum); + CORBA::Boolean generateFrames(); + void generatePresentations(CORBA::Long theFieldNum); void setViewer(VTKViewer_ViewFrame* theView) { myView = theView; } VTKViewer_ViewFrame* getViewer() { return myView; } void clearView(); @@ -54,51 +61,66 @@ class VISU_TimeAnimation: public QObject, public QThread void prevFrame(); void firstFrame(); void lastFrame(); - void gotoFrame(long theFrame); + void gotoFrame(CORBA::Long theFrame); - int getNbFields() { return myFieldsLst.size(); } - long getNbFrames(); - bool isRunning() { return myIsActive; } - long getCurrentFrame() { return myFrame; } + CORBA::Long getNbFields() { return myFieldsLst.size(); } + CORBA::Long getNbFrames(); + CORBA::Boolean isRunning() { return myIsActive; } + CORBA::Long getCurrentFrame() { return myFrame; } - VISU::ScalarMap_i* getPresentation(int theField, long theFrame); + VISU::ScalarMap_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame); - void setPresentationType(int theFieldNum, VISU::VISUType theType) { myFieldsLst[theFieldNum].myPrsType = theType; } - VISU::VISUType getPresentationType(int theFieldNum) { return myFieldsLst[theFieldNum].myPrsType; } + void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType) { myFieldsLst[theFieldNum].myPrsType = theType; } + VISU::VISUType getPresentationType(CORBA::Long theFieldNum) { return myFieldsLst[theFieldNum].myPrsType; } - void setSpeed(int theSpeed); - int getSpeed() { return mySpeed; } + void setSpeed(CORBA::Long theSpeed); + CORBA::Long getSpeed() { return mySpeed; } - bool isProportional() { return myProportional; } + CORBA::Boolean isProportional() { return myProportional; } - void setAnimationRange(double theMin, double theMax) + void setAnimationRange(CORBA::Double theMin, CORBA::Double theMax) { myMaxVal = theMax; myMinVal = theMin; } - double getMinRange() { return myMinVal; } - double getMaxRange() { return myMaxVal; } - bool isRangeDefined() { return ((myMaxVal!=0) && (myMinVal != 0)); } + CORBA::Double getMinRange() { return myMinVal; } + CORBA::Double getMaxRange() { return myMaxVal; } + CORBA::Boolean isRangeDefined() { return !((myMaxVal==0) && (myMinVal == myMaxVal)); } + + void dumpTo(const char* thePath) { myDumpPath = thePath; } + + QString getLastErrorMsg() { return myLastError; } + + CORBA::Boolean isCycling() { return myCycling; } + + CORBA::Double getMinTime() { return myTimeMin;} + CORBA::Double getMaxTime() { return myTimeMax;} - void dumpTo(QString thePath) { myDumpPath = thePath; } + void setProportional(CORBA::Boolean theProp) { myProportional = theProp; } + void setCycling(CORBA::Boolean theCycle) { myCycling = theCycle; } public slots: - void setProportional(bool theProp) { myProportional = theProp; } + void setProportionalSlot(bool theProp) { myProportional = theProp; } + void setCyclingSlot(bool theCycle) { myCycling = theCycle; } signals: void frameChanged(long theNewFrame, double theTime); + void stopped(); protected: void run(); private: + QString myLastError; QValueList myFieldsLst; bool myIsActive; long myFrame; int mySpeed; bool myProportional; + bool myCycling; SALOMEDS::Study_var myStudy; double myMaxVal, myMinVal; + double myTimeMin, myTimeMax; QString myDumpPath; VTKViewer_ViewFrame* myView; }; diff --git a/src/VISU_I/VISU_ViewManager_i.cc b/src/VISU_I/VISU_ViewManager_i.cc index f7d2de23..f93106df 100644 --- a/src/VISU_I/VISU_ViewManager_i.cc +++ b/src/VISU_I/VISU_ViewManager_i.cc @@ -1,9 +1,12 @@ -using namespace std; -// File: VISU_ViewManager_i.cxx -// Created: Wed Jan 22 17:53:23 2003 -// Author: Alexey PETROV -// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_ViewManager_i.cxx +// Author : Alexey PETROV +// Module : VISU +using namespace std; #include "VISU_ViewManager_i.hh" #include "VISU_PrsObject_i.hh" #include "VISU_Table_i.hh" @@ -16,28 +19,32 @@ using namespace std; #include "QAD_Study.h" #include "QAD_RightFrame.h" #include "QAD_StudyFrame.h" +#include +#include -#include "VTKViewer_ViewFrame.h" #include "SALOMEGUI_TableDlg.h" #include "Plot2d_CurveContainer.h" #include "Plot2d_ViewFrame.h" //#include "SALOMEGUI_SetupCurveDlg.h" //#include "SALOMEGUI_SetupPlot2dDlg.h" +#include "VTKViewer_ViewFrame.h" #include #include #include #include #include -#include #ifdef DEBUG -static int MYDEBUG = 1; +static int MYDEBUG = 0; #else static int MYDEBUG = 0; #endif +static QFileInfo aFileInfo; +static int MYDELAY = 1; + namespace VISU{ //=========================================================================== VTKViewer_ViewFrame* GetViewFrame(QAD_StudyFrame* theStudyFrame){ @@ -51,7 +58,8 @@ namespace VISU{ } void RepaintView(QAD_StudyFrame* theStudyFrame){ GetRenderer(theStudyFrame)->ResetCameraClippingRange(); - GetViewFrame(theStudyFrame)->Repaint(); + GetViewFrame(theStudyFrame)->getRW()->getRenderWindow()->Render(); + //GetViewFrame(theStudyFrame)->Repaint(); } VISU_Actor* UpdateViewer(QAD_StudyFrame* theStudyFrame, int theDisplaing, Prs3d_i* thePrs){ VTKViewer_ViewFrame* vf = GetViewFrame(theStudyFrame); @@ -61,31 +69,20 @@ namespace VISU{ vtkActorCollection *anActColl = aRen->GetActors(); vtkActor *anActor; VISU_Actor *anVISUActor = NULL, *aResActor = NULL; - void *aSrcAddr = thePrs != NULL? (void*)thePrs->GetMapper(): NULL; - if(MYDEBUG) MESSAGE("UpdateViewer - aSrcAddr = "<InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){ + for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;){ if(anActor->IsA("VISU_Actor")){ anVISUActor = VISU_Actor::SafeDownCast(anActor); - void* aCurrAddr = (void*)anVISUActor->GetMapper(); - if(MYDEBUG) MESSAGE("UpdateViewer - aCurrAddr = "<getPrs3d()) { + aResActor = anVISUActor->GetParent(); + if(theDisplaing < eErase) aResActor->VisibilityOn(); - if (aResActor->HasScalarBar()) aResActor->getScalarBar()->VisibilityOn(); - }else{ + else aResActor->VisibilityOff(); - if (aResActor->HasScalarBar()) aResActor->getScalarBar()->VisibilityOff(); - } } else { - if(theDisplaing > eDisplay){ + if(theDisplaing > eDisplay) anVISUActor->VisibilityOff(); - if (anVISUActor->HasScalarBar()) anVISUActor->getScalarBar()->VisibilityOff(); - }else{ + else anVISUActor->VisibilityOn(); - if (anVISUActor->HasScalarBar()) anVISUActor->getScalarBar()->VisibilityOn(); - } } } } @@ -95,14 +92,9 @@ namespace VISU{ } if(thePrs != NULL && theDisplaing < eErase){ anVISUActor = thePrs->CreateActor(); - if (anVISUActor ) { - if(MYDEBUG) MESSAGE("UpdateViewer - thePrs->CreateActor() = "<GetMapper()); + if(anVISUActor) vf->AddActor(anVISUActor); - if(anVISUActor->HasScalarBar()){ - if(MYDEBUG) MESSAGE("UpdateViewer - anVISUActor->getScalarBar()"); - aRen->AddActor2D(anVISUActor->getScalarBar()); - } - } else { + else{ MESSAGE ("Null actor is created"); return NULL; } @@ -191,28 +183,61 @@ namespace VISU{ } } //=========================================================================== + /* + #include + class TViewManager: public QThread{ + public: + TViewManager(SALOMEDS::Study_ptr theStudy) : myStudyDocument(theStudy) {}; + virtual void run(){ + qApp->lock(); + QAD_Desktop* aDesktop = QAD_Application::getDesktop(); + QAD_Study* aStudy = aDesktop->findStudy(myStudyDocument); + if(!aStudy){ + CORBA::String_var aName = myStudyDocument->Name(); + aFileInfo.setFile(aName.in()); + aStudy = aDesktop->loadStudy(aFileInfo.baseName()); + } + qApp->unlock(); + } + SALOMEDS::Study_ptr myStudyDocument; + }; + */ ViewManager_i::ViewManager_i(SALOMEDS::Study_ptr theStudy) { if(MYDEBUG) MESSAGE("ViewManager_i::ViewManager_i"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); myStudyDocument = SALOMEDS::Study::_duplicate(theStudy); - /* - CORBA::String_var aName = myStudyDocument->Name(); - if(QAD_Application::getDesktop()->getActiveApp()->isStudyOpened(aName.in())) - QAD_Application::getDesktop()->getActiveApp()->loadStudy(aName.in()); - */ + //TViewManager* aTViewManager = new TViewManager(theStudy); + //aTViewManager->start(); + QAD_Desktop* aDesktop = QAD_Application::getDesktop(); + QAD_Study* aStudy = aDesktop->findStudy(theStudy); + if(!aStudy){ + CORBA::String_var aName = theStudy->Name(); + aFileInfo.setFile(aName.in()); + aStudy = aDesktop->loadStudy(aFileInfo.baseName()); + if (!aStudy) + MESSAGE("ViewManager_i::ERROR: Can't load study"); + } } + + VISU::View3D_ptr ViewManager_i::Create3DView(){ + Mutex mt(myMutex,qApp,MYDELAY); if(MYDEBUG) MESSAGE("ViewManager_i::Create3DView"); VISU::View3D_i* pView = new View3D_i(myStudyDocument); if(pView->Create(1) != NULL) return VISU::View3D::_duplicate(pView->_this()); return VISU::View3D::_nil(); } + + VISU::View_ptr ViewManager_i::GetCurrentView(){ - if(MYDEBUG) MESSAGE("ViewManager_i::GetCurrent3DView"); + Mutex mt(myMutex,qApp,MYDELAY); QAD_Study* Study = QAD_Application::getDesktop()->findStudy( myStudyDocument ); + if(MYDEBUG) MESSAGE("ViewManager_i::GetCurrent3DView - Study = "<getActiveStudyFrame() ) ) { + if(MYDEBUG) + MESSAGE("ViewManager_i::GetCurrent3DView - TypeView = "<getTypeView()); if ( StudyFrame->getTypeView() == VIEW_VTK ) { VISU::View3D_i* pView = new View3D_i(myStudyDocument); if(pView->Create(0) != NULL) @@ -226,20 +251,28 @@ namespace VISU{ } return VISU::View::_nil(); } + + VISU::XYPlot_ptr ViewManager_i::CreateXYPlot(){ if(MYDEBUG) MESSAGE("ViewManager_i::CreateXYPlot"); + Mutex mt(myMutex,qApp,MYDELAY); VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument); if(pView->Create(1) != NULL) return VISU::XYPlot::_duplicate(pView->_this()); return VISU::XYPlot::_nil(); } + + VISU::TableView_ptr ViewManager_i::CreateTableView(VISU::Table_ptr theTable){ if(MYDEBUG) MESSAGE("ViewManager_i::CreateTableView"); + Mutex mt(myMutex,qApp,MYDELAY); VISU::TableView_i* pView = new TableView_i(myStudyDocument); if(pView->Create(VISU::Table::_duplicate(theTable)) != NULL) return VISU::TableView::_duplicate(pView->_this()); return VISU::TableView::_nil(); } + + void ViewManager_i::Destroy(View_ptr theView){ if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - "<_is_nil()); if(theView->_is_nil()) return; @@ -259,13 +292,16 @@ namespace VISU{ //=========================================================================== View_i::View_i(SALOMEDS::Study_ptr theStudy) { if(MYDEBUG) MESSAGE("View_i::View_i"); - Mutex mt(myMutex,qApp); CORBA::String_var aName = theStudy->Name(); - myStudy = QAD_Application::getDesktop()->findStudy( theStudy ); - if(MYDEBUG) MESSAGE("View_i::View_i - isStudyOpened = "<getActiveApp()->loadStudy(aName.in()); + QAD_Desktop* aDesktop = QAD_Application::getDesktop(); + myStudy = aDesktop->findStudy(theStudy); + if(!myStudy){ + aFileInfo.setFile(aName.in()); + myStudy = aDesktop->loadStudy(aFileInfo.baseName()); + } + if(MYDEBUG) MESSAGE("View_i::View_i - isStudyOpened = "<getStudyDocument()->FindObjectIOR(GetID()); @@ -300,7 +336,7 @@ namespace VISU{ } Storable* XYPlot_i::Create(int theNew){ if(MYDEBUG) MESSAGE("XYPlot_i::Create"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); if(theNew) myStudyFrame = myStudy->newWindow3d("",VIEW_PLOT2D); else @@ -311,47 +347,47 @@ namespace VISU{ } void XYPlot_i::Update() { if(MYDEBUG) MESSAGE("XYPlot_i::Update"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); myName = myStudyFrame->title(); myView->Repaint(); } void XYPlot_i::Close(){ if(MYDEBUG) MESSAGE("XYPlot_i::Close"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); myStudyFrame->close(); } XYPlot_i::~XYPlot_i() { if(MYDEBUG) MESSAGE("XYPlot_i::~XYPlot_i"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); myStudyFrame->close(); } void XYPlot_i::SetTitle(const char* theTitle){ if(MYDEBUG) MESSAGE("XYPlot_i::SetTitle"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); myName = theTitle; myStudyFrame->setCaption(myName.c_str()); } char* XYPlot_i::GetTitle() { if(MYDEBUG) MESSAGE("XYPlot_i::GetTitle"); Mutex mt(myMutex,qApp); - myName = myStudyFrame->title(); + myName = (const char*)(myStudyFrame->title()); return CORBA::string_dup(myName.c_str()); } void XYPlot_i::SetSubTitle(const char* theTitle){ if(MYDEBUG) MESSAGE("XYPlot_i::SetSubTitle"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); myView->setTitle(theTitle); } char* XYPlot_i::GetSubTitle() { if(MYDEBUG) MESSAGE("XYPlot_i::GetSubTitle"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); return CORBA::string_dup(myView->getTitle()); } void XYPlot_i::SetCurveType(VISU::XYPlot::CurveType theType){ if(MYDEBUG) MESSAGE("XYPlot_i::SetCurveType"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); myView->setCurveType(theType); } VISU::XYPlot::CurveType XYPlot_i::GetCurveType(){ @@ -362,7 +398,7 @@ namespace VISU{ void XYPlot_i::SetMarkerSize(CORBA::Long theSize){ if(MYDEBUG) MESSAGE("XYPlot_i::SetMarkerSize"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); myView->setMarkerSize(theSize); } CORBA::Long XYPlot_i::GetMarkerSize(){ @@ -374,19 +410,19 @@ namespace VISU{ void XYPlot_i::EnableXGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor, CORBA::Boolean theMinor, CORBA::Long theNumMinor){ if(MYDEBUG) MESSAGE("XYPlot_i::EnableXGrid"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); myView->setXGrid(theMajor,theNumMajor,theMinor,theNumMinor); } void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor, CORBA::Boolean theMinor, CORBA::Long theNumMinor){ if(MYDEBUG) MESSAGE("XYPlot_i::EnableYGrid"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); myView->setYGrid(theMajor,theNumMajor,theMinor,theNumMinor); } void XYPlot_i::SetHorScaling(VISU::Scaling theScaling){ if(MYDEBUG) MESSAGE("XYPlot_i::SetHorScaling"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); if(theScaling == VISU::LOGARITHMIC) myView->setHorScaleMode(1); else @@ -394,13 +430,13 @@ namespace VISU{ } VISU::Scaling XYPlot_i::GetHorScaling(){ if(MYDEBUG) MESSAGE("XYPlot_i::GetHorScaling"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); return (VISU::Scaling)myView->getHorScaleMode(); } void XYPlot_i::SetVerScaling(VISU::Scaling theScaling){ if(MYDEBUG) MESSAGE("XYPlot_i::SetVerScaling"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); if(theScaling == VISU::LOGARITHMIC) myView->setVerScaleMode(1); else @@ -414,7 +450,7 @@ namespace VISU{ void XYPlot_i::SetXTitle(const char* theTitle){ if(MYDEBUG) MESSAGE("XYPlot_i::SetXTitle"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); myView->setXTitle(true,theTitle); } char* XYPlot_i::GetXTitle() { @@ -425,7 +461,7 @@ namespace VISU{ void XYPlot_i::SetYTitle(const char* theTitle){ if(MYDEBUG) MESSAGE("XYPlot_i::SetYTitle"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); myView->setYTitle(true,theTitle); } char* XYPlot_i::GetYTitle() { @@ -436,15 +472,19 @@ namespace VISU{ void XYPlot_i::ShowLegend(CORBA::Boolean theShowing){ if(MYDEBUG) MESSAGE("XYPlot_i::ShowLegend"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); myView->showLegend(theShowing); } void XYPlot_i::SetBackground(const SALOMEDS::Color& theColor){ if(MYDEBUG) MESSAGE("XYPlot_i::SetBackground"); - Mutex mt(myMutex,qApp); - QColor aColor(255.0*theColor.R,255.0*theColor.G,255.0*theColor.B); - myView->setBackgroundColor(aColor); + Mutex mt(myMutex,qApp,MYDELAY); + int aColor[3]; + aColor[0] = (int)(255.0*theColor.R); + aColor[1] = (int)(255.0*theColor.G); + aColor[2] = (int)(255.0*theColor.B); + QColor aNewColor(aColor[0],aColor[1],aColor[2]); + myView->setBackgroundColor(aNewColor); } SALOMEDS::Color XYPlot_i::GetBackground() { if(MYDEBUG) MESSAGE("XYPlot_i::GetBackground"); @@ -457,23 +497,23 @@ namespace VISU{ } void XYPlot_i::Minimize() { if(MYDEBUG) MESSAGE("XYPlot_i::Minimize"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); myStudyFrame->showMinimized(); } void XYPlot_i::Restore() { if(MYDEBUG) MESSAGE("XYPlot_i::Restore"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); myStudyFrame->showNormal(); } void XYPlot_i::Maximize() { if(MYDEBUG) MESSAGE("XYPlot_i::Maximize"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); myStudyFrame->showMaximized(); } void XYPlot_i::Display(PrsObject_ptr thePrsObj) { - if(MYDEBUG) MESSAGE("View3D_i::Display"); - Mutex mt(myMutex,qApp); - CORBA::Object_var anObj = thePrsObj; + if(MYDEBUG) MESSAGE("XYPlot_i::Display"); + Mutex mt(myMutex,qApp,MYDELAY); + CORBA::Object_ptr anObj = thePrsObj; // is it Curve ? if(Curve_i* aCurve = dynamic_cast(VISU::GetServant(anObj))) { UpdatePlot2d(myView,eDisplay,aCurve); @@ -507,9 +547,9 @@ namespace VISU{ } } void XYPlot_i::Erase(PrsObject_ptr thePrsObj) { - if(MYDEBUG) MESSAGE("View3D_i::Display"); - Mutex mt(myMutex,qApp); - CORBA::Object_var anObj = thePrsObj; + if(MYDEBUG) MESSAGE("XYPlot_i::Erase"); + Mutex mt(myMutex,qApp,MYDELAY); + CORBA::Object_ptr anObj = thePrsObj; // is it Curve ? if(Curve_i* aCurve = dynamic_cast(VISU::GetServant(anObj))) { UpdatePlot2d(myView,eErase,aCurve); @@ -544,13 +584,13 @@ namespace VISU{ } void XYPlot_i::EraseAll() { if(MYDEBUG) MESSAGE("XYPlot_i::EraseAll"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); myView->EraseAll(); } void XYPlot_i::DisplayOnly(PrsObject_ptr thePrsObj) { - if(MYDEBUG) MESSAGE("View3D_i::Display"); - Mutex mt(myMutex,qApp); - CORBA::Object_var anObj = thePrsObj; + if(MYDEBUG) MESSAGE("XYPlot_i::DisplayOnly"); + Mutex mt(myMutex,qApp,MYDELAY); + CORBA::Object_ptr anObj = thePrsObj; // is it Curve ? if(Curve_i* aCurve = dynamic_cast(VISU::GetServant(anObj))) { UpdatePlot2d(myView,eDisplayOnly,aCurve); @@ -585,12 +625,12 @@ namespace VISU{ } void XYPlot_i::FitAll() { if(MYDEBUG) MESSAGE("XYPlot_i::FitAll"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); myView->fitAll(); } CORBA::Boolean XYPlot_i::SavePicture(const char* theFileName) { if(MYDEBUG) MESSAGE("XYPlot_i::SavePicture"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); if (!myView->getViewWidget()) return false; @@ -616,14 +656,18 @@ namespace VISU{ TableView_i::TableView_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {} Storable* TableView_i::Create(VISU::Table_var theTable){ if(MYDEBUG) MESSAGE("TableView_i::Create - "<<(!theTable->_is_nil())); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); if(!theTable->_is_nil()){ VISU::Table_i* table = dynamic_cast(VISU::GetServant(theTable.in())); if(MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = "<getStudyDocument()->FindObjectID(table->GetObjectEntry()); if(!aSObject->_is_nil()) { - myView = new SALOMEGUI_TableDlg(QAD_Application::getDesktop(),aSObject); + myView = new SALOMEGUI_TableDlg(QAD_Application::getDesktop(), + aSObject, + false, + SALOMEGUI_TableDlg::ttAuto, + Qt::Vertical); myView->show(); myName = (myView->caption()).latin1(); return this; @@ -634,7 +678,7 @@ namespace VISU{ } void TableView_i::SetTitle(const char* theTitle){ if(MYDEBUG) MESSAGE("TableView_i::SetTitle"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); myName = theTitle; myView->setCaption(myName.c_str()); } @@ -646,12 +690,12 @@ namespace VISU{ } void TableView_i::Close(){ if(MYDEBUG) MESSAGE("TableView_i::Close"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); myView->close(); } TableView_i::~TableView_i() { if(MYDEBUG) MESSAGE("TableView_i::~TableView_i"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); Close(); delete myView; } @@ -659,7 +703,7 @@ namespace VISU{ int View3D_i::myNbViewParams = 0; const string View3D_i::myComment = "VIEW3D"; const char* View3D_i::GetComment() const { return myComment.c_str();} - const char* View3D_i::GenerateViewParamsName() { + QString View3D_i::GenerateViewParamsName() { return VISU::GenerateName( "ViewParams", ++myNbViewParams ); } @@ -669,64 +713,72 @@ namespace VISU{ Storable* View3D_i::Create(int theNew){ if(MYDEBUG) MESSAGE("View3D_i::Create"); - Mutex mt(myMutex,qApp); if(theNew) myStudyFrame = myStudy->newWindow3d("",VIEW_VTK); else myStudyFrame = myStudy->getActiveStudyFrame(); - VTKViewer_NonIsometricTransform *NITr = GetViewFrame(myStudyFrame)->getNonIsometricTransform(); - myScaleFactor[0] = NITr->GetCoeff(AxisFunction::XAxis); - myScaleFactor[1] = NITr->GetCoeff(AxisFunction::YAxis); - myScaleFactor[2] = NITr->GetCoeff(AxisFunction::ZAxis); - - return Build(false); - } - - Storable* View3D_i::Build(int theRestoring){ - if(MYDEBUG) MESSAGE("View3D_i::Build"); - if(theRestoring){ - myStudyFrame->setTitle(myName.c_str()); - SetBackground(myColor); - SetPointOfView(myPosition); - SetViewUp(myViewUp); - SetFocalPoint(myFocalPnt); - SetParallelScale(myParallelScale); - ScaleView(VISU::View3D::XAxis,myScaleFactor[0]); - ScaleView(VISU::View3D::YAxis,myScaleFactor[1]); - ScaleView(VISU::View3D::ZAxis,myScaleFactor[2]); - RepaintView(myStudyFrame); - }else{ - Update(); - /* - SALOMEDS::SComponent_var aSComponent = FindOrCreateVisuComponent(myStudyDocument); - CORBA::String_var aSComponentEntry = aSComponent->GetID(), anIOR(GetID()); - string anEntry = CreateAttributes(myStudyDocument,aSComponentEntry,"",anIOR,myName.c_str(),"",GetComment()); - */ - } - return this; + //GetViewFrame(myStudyFrame)->GetScale(myScaleFactor); + + return this; //Build(false); } +// Storable* View3D_i::Build(int theRestoring){ +// if(MYDEBUG) MESSAGE("View3D_i::Build"); +// if(theRestoring){ +// myStudyFrame->setTitle(myName.c_str()); +// SetBackground(myColor); +// SetPointOfView(myPosition); +// SetViewUp(myViewUp); +// SetFocalPoint(myFocalPnt); +// SetParallelScale(myParallelScale); +// ScaleView(VISU::View3D::XAxis,myScaleFactor[0]); +// ScaleView(VISU::View3D::YAxis,myScaleFactor[1]); +// ScaleView(VISU::View3D::ZAxis,myScaleFactor[2]); +// RepaintView(myStudyFrame); +// }else{ +// Update(); + +// SALOMEDS::SComponent_var aSComponent = FindOrCreateVisuComponent(myStudyDocument); +// CORBA::String_var aSComponentEntry = aSComponent->GetID(), anIOR(GetID()); +// string anEntry = CreateAttributes(myStudyDocument,aSComponentEntry,"",anIOR,myName.c_str(),"",GetComment()); + +// } +// return this; +// } + void View3D_i::Update(){ if(MYDEBUG) MESSAGE("View3D_i::Update"); - Mutex mt(myMutex,qApp); - myName = myStudyFrame->title(); - myColor = GetBackground(); - GetCamera(myStudyFrame)->GetPosition(myPosition); - GetCamera(myStudyFrame)->GetViewUp(myViewUp); - GetCamera(myStudyFrame)->GetFocalPoint(myFocalPnt); - myParallelScale = GetCamera(myStudyFrame)->GetParallelScale(); - RepaintView(myStudyFrame); + Mutex mt(myMutex,qApp,MYDELAY); + myName = (const char*)myStudyFrame->title(); +// myColor = GetBackground(); +// GetCamera(myStudyFrame)->GetPosition(myPosition); +// GetCamera(myStudyFrame)->GetViewUp(myViewUp); +// GetCamera(myStudyFrame)->GetFocalPoint(myFocalPnt); +// myParallelScale = GetCamera(myStudyFrame)->GetParallelScale(); + //RepaintView(myStudyFrame); - VTKViewer_NonIsometricTransform *NITr = GetViewFrame(myStudyFrame)->getNonIsometricTransform(); - myScaleFactor[0] = NITr->GetCoeff(AxisFunction::XAxis); - myScaleFactor[1] = NITr->GetCoeff(AxisFunction::YAxis); - myScaleFactor[2] = NITr->GetCoeff(AxisFunction::ZAxis); + //GetViewFrame(myStudyFrame)->GetScale(myScaleFactor); + + VTKViewer_ViewFrame* vf = GetViewFrame(myStudyFrame); + vtkRenderer* Renderer = vf->getRenderer(); + vtkActorCollection* theActors = Renderer->GetActors(); + theActors->InitTraversal(); + vtkActor *actor; + while(actor = theActors->GetNextActor()){ + if(VISU_Actor* anActor = dynamic_cast(actor)){ + VISU::Prs3d_i* aPrs3d = anActor->getPrs3d(); + if(anActor->GetVisibility() && aPrs3d){ + aPrs3d->Update(); + aPrs3d->UpdateActor(anActor); + } + } + } } CORBA::Boolean View3D_i::SavePicture(const char* theFileName) { if(MYDEBUG) MESSAGE("View3D_i::SavePicture"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); if (!myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget()) return false; @@ -750,7 +802,7 @@ namespace VISU{ CORBA::Boolean View3D_i::SaveViewParams(const char* theName){ if(MYDEBUG) MESSAGE("View3D_i::SaveViewPoint"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); if ( theName ) { SALOMEDS::Study::ListOfSObject_var aList = myStudy->getStudyDocument()->FindObjectByName(theName,"VISU"); @@ -787,7 +839,7 @@ namespace VISU{ CORBA::Boolean View3D_i::RestoreViewParams(const char* theName){ if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - "<getStudyDocument()->FindObjectByName(theName,"VISU"); SALOMEDS::GenericAttribute_var anAttr; @@ -813,178 +865,201 @@ namespace VISU{ return 0; } -#define RESTORE(MAP,ARG,FMT) ARG = VISU::Storable::FindValue(MAP,#ARG).FMT() - Storable* View3D_i::Restore(const Storable::TRestoringMap& theMap) throw(std::logic_error&) { - if(MYDEBUG) MESSAGE("View3D_i::Restore"); - //RESTORE(theMap,myName,latin1); - - RESTORE(theMap,myColor.R,toDouble); - RESTORE(theMap,myColor.G,toDouble); - RESTORE(theMap,myColor.B,toDouble); + // if(MYDEBUG) MESSAGE("View3D_i::Restore"); + //myName = VISU::Storable::FindValue(theMap,"myName").latin1(); - RESTORE(theMap,myPosition[0],toDouble); - RESTORE(theMap,myPosition[1],toDouble); - RESTORE(theMap,myPosition[2],toDouble); + SALOMEDS::Color aColor; + aColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble(); + aColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble(); + aColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble(); - RESTORE(theMap,myFocalPnt[0],toDouble); - RESTORE(theMap,myFocalPnt[1],toDouble); - RESTORE(theMap,myFocalPnt[2],toDouble); + double aPosition[3]; + aPosition[0] = VISU::Storable::FindValue(theMap,"myPosition[0]").toDouble(); + aPosition[1] = VISU::Storable::FindValue(theMap,"myPosition[1]").toDouble(); + aPosition[2] = VISU::Storable::FindValue(theMap,"myPosition[2]").toDouble(); - RESTORE(theMap,myViewUp[0],toDouble); - RESTORE(theMap,myViewUp[1],toDouble); - RESTORE(theMap,myViewUp[2],toDouble); + double aFocalPnt[3]; + aFocalPnt[0] = VISU::Storable::FindValue(theMap,"myFocalPnt[0]").toDouble(); + aFocalPnt[1] = VISU::Storable::FindValue(theMap,"myFocalPnt[1]").toDouble(); + aFocalPnt[2] = VISU::Storable::FindValue(theMap,"myFocalPnt[2]").toDouble(); - RESTORE(theMap,myParallelScale,toDouble); + double aViewUp[3]; + aViewUp[0] = VISU::Storable::FindValue(theMap,"myViewUp[0]").toDouble(); + aViewUp[1] = VISU::Storable::FindValue(theMap,"myViewUp[1]").toDouble(); + aViewUp[2] = VISU::Storable::FindValue(theMap,"myViewUp[2]").toDouble(); - RESTORE(theMap,myScaleFactor[0],toDouble); - RESTORE(theMap,myScaleFactor[1],toDouble); - RESTORE(theMap,myScaleFactor[2],toDouble); + double aParallelScale = VISU::Storable::FindValue(theMap,"myParallelScale").toDouble(); + + double aScaleFactor[3]; + aScaleFactor[0] = VISU::Storable::FindValue(theMap,"myScaleFactor[0]").toDouble(); + aScaleFactor[1] = VISU::Storable::FindValue(theMap,"myScaleFactor[1]").toDouble(); + aScaleFactor[2] = VISU::Storable::FindValue(theMap,"myScaleFactor[2]").toDouble(); - return Build(true); + myStudyFrame->setTitle(myName.c_str()); + SetBackground(aColor); + SetPointOfView(aPosition); + SetViewUp(aViewUp); + SetFocalPoint(aFocalPnt); + SetParallelScale(aParallelScale); + ScaleView(VISU::View3D::XAxis,aScaleFactor[0]); + ScaleView(VISU::View3D::YAxis,aScaleFactor[1]); + ScaleView(VISU::View3D::ZAxis,aScaleFactor[2]); + RepaintView(myStudyFrame); + return this; } -#undef RESTORE - void View3D_i::ToStream(ostrstream& theStr) { - if(MYDEBUG) MESSAGE(GetComment()); - Update(); + void View3D_i::ToStream(std::ostringstream& theStr) { Storable::DataToStream(theStr,"myType",VISU::TVIEW3D); - - Storable::DataToStream(theStr,"myColor.R",myColor.R); - Storable::DataToStream(theStr,"myColor.G",myColor.G); - Storable::DataToStream(theStr,"myColor.B",myColor.B); - - Storable::DataToStream(theStr,"myPosition[0]",myPosition[0]); - Storable::DataToStream(theStr,"myPosition[1]",myPosition[1]); - Storable::DataToStream(theStr,"myPosition[2]",myPosition[2]); - - Storable::DataToStream(theStr,"myFocalPnt[0]",myFocalPnt[0]); - Storable::DataToStream(theStr,"myFocalPnt[1]",myFocalPnt[1]); - Storable::DataToStream(theStr,"myFocalPnt[2]",myFocalPnt[2]); - - Storable::DataToStream(theStr,"myViewUp[0]",myViewUp[0]); - Storable::DataToStream(theStr,"myViewUp[1]",myViewUp[1]); - Storable::DataToStream(theStr,"myViewUp[2]",myViewUp[2]); - - Storable::DataToStream(theStr,"myParallelScale",myParallelScale); - - Storable::DataToStream(theStr,"myScaleFactor[0]",myScaleFactor[0]); - Storable::DataToStream(theStr,"myScaleFactor[1]",myScaleFactor[1]); - Storable::DataToStream(theStr,"myScaleFactor[2]",myScaleFactor[2]); + + float backint[3]; + GetRenderer(myStudyFrame)->GetBackground(backint); + Storable::DataToStream(theStr,"myColor.R",backint[0]); + Storable::DataToStream(theStr,"myColor.G",backint[1]); + Storable::DataToStream(theStr,"myColor.B",backint[2]); + + double aPosition[3]; + GetPointOfView(myStudyFrame,aPosition); + Storable::DataToStream(theStr,"myPosition[0]",aPosition[0]); + Storable::DataToStream(theStr,"myPosition[1]",aPosition[1]); + Storable::DataToStream(theStr,"myPosition[2]",aPosition[2]); + + double aFocalPnt[3]; + GetFocalPoint(myStudyFrame,aFocalPnt); + Storable::DataToStream(theStr,"myFocalPnt[0]",aFocalPnt[0]); + Storable::DataToStream(theStr,"myFocalPnt[1]",aFocalPnt[1]); + Storable::DataToStream(theStr,"myFocalPnt[2]",aFocalPnt[2]); + + double aViewUp[3]; + GetCamera(myStudyFrame)->GetViewUp(aViewUp); + Storable::DataToStream(theStr,"myViewUp[0]",aViewUp[0]); + Storable::DataToStream(theStr,"myViewUp[1]",aViewUp[1]); + Storable::DataToStream(theStr,"myViewUp[2]",aViewUp[2]); + + Storable::DataToStream(theStr,"myParallelScale",GetParallelScale(myStudyFrame)); + + double aScaleFactor[3]; + GetViewFrame(myStudyFrame)->GetScale(aScaleFactor); + Storable::DataToStream(theStr,"myScaleFactor[0]",aScaleFactor[0]); + Storable::DataToStream(theStr,"myScaleFactor[1]",aScaleFactor[1]); + Storable::DataToStream(theStr,"myScaleFactor[2]",aScaleFactor[2]); } - Storable* VISU::View3DRestore(SALOMEDS::SComponent_var& theSComponent, SALOMEDS::Study_var& theStudy, - const char* thePrefix, const Storable::TRestoringMap& theMap) - { - try{ - View3D_i* pView3D = new View3D_i(theStudy); - return pView3D->Restore(theMap); - }catch(std::logic_error& exc){ - MESSAGE("Follow exception was accured :\n"<Restore(theMap); +// }catch(std::logic_error& exc){ +// MESSAGE("Follow exception was accured :\n"<close(); } View3D_i::~View3D_i() { if(MYDEBUG) MESSAGE("View3D_i::~View3D_i"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); myStudyFrame->close(); } - + //-------------------- View interface -------------------- void View3D_i::SetTitle(const char* theTitle){ if(MYDEBUG) MESSAGE("View3D_i::SetTitle"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); myName = theTitle; - /* - SALOMEDS::SObject_var aSObject = - myStudy->getStudyDocument()->FindObjectID(GetEntry()); - SALOMEDS::GenericAttribute_var anAttr; - if(aSObject->FindAttribute(anAttr,"AttributeName")){ - SALOMEDS::AttributeName_ptr aName = SALOMEDS::AttributeName::_narrow(anAttr); - aName->SetValue(myName.c_str()); - } - */ myStudyFrame->setTitle(myName.c_str()); } char* View3D_i::GetTitle() { if(MYDEBUG) MESSAGE("View3D_i::GetTitle"); - Mutex mt(myMutex,qApp); - myName = myStudyFrame->title(); + Mutex mt(myMutex,qApp,MYDELAY); + myName = (const char*)myStudyFrame->title(); return CORBA::string_dup(myName.c_str()); } + + void View3D_i::SetBackground(QAD_StudyFrame* theStudyFrame, const SALOMEDS::Color& theColor) { + int aColor[3]; + aColor[0] = (int)(255.0*theColor.R); + aColor[1] = (int)(255.0*theColor.G); + aColor[2] = (int)(255.0*theColor.B); + QColor aNewColor(aColor[0],aColor[1],aColor[2]); + GetViewFrame(theStudyFrame)->setBackgroundColor(aNewColor); + } void View3D_i::SetBackground(const SALOMEDS::Color& theColor) { if(MYDEBUG) MESSAGE("View3D_i::SetBackground"); - Mutex mt(myMutex,qApp); - myColor.R = theColor.R; - myColor.G = theColor.G; - myColor.B = theColor.B; - QColor aColor(255.0*myColor.R,255.0*myColor.G,255.0*myColor.B); - GetViewFrame(myStudyFrame)->setBackgroundColor(aColor); + Mutex mt(myMutex,qApp,MYDELAY); + //myColor.R = theColor.R; myColor.G = theColor.G; myColor.B = theColor.B; + SetBackground(myStudyFrame,theColor); + } + + SALOMEDS::Color View3D_i::GetBackground(QAD_StudyFrame* theStudyFrame) { + SALOMEDS::Color aColor; + float backint[3]; + GetRenderer(theStudyFrame)->GetBackground(backint); + aColor.R = backint[0]; aColor.G = backint[1]; aColor.B = backint[2]; + return aColor; } SALOMEDS::Color View3D_i::GetBackground() { if(MYDEBUG) MESSAGE("View3D_i::GetBackground"); - Mutex mt(myMutex,qApp); - float backint[3]; - GetRenderer(myStudyFrame)->GetBackground(backint); - myColor.R = backint[0]; - myColor.G = backint[1]; - myColor.B = backint[2]; - return myColor; + Mutex mt(myMutex,qApp,MYDELAY); + //myColor = GetBackground(myStudyFrame); + return GetBackground(myStudyFrame); //myColor; } + void View3D_i::Minimize() { if(MYDEBUG) MESSAGE("View3D_i::Minimize"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); myStudyFrame->showMinimized(); } void View3D_i::Restore() { if(MYDEBUG) MESSAGE("View3D_i::Restore"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); myStudyFrame->showNormal(); } void View3D_i::Maximize() { if(MYDEBUG) MESSAGE("View3D_i::Maximize"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); myStudyFrame->showMaximized(); } //=========================================================================== void View3D_i::EraseAll() { if(MYDEBUG) MESSAGE("View3D_i::EraseAll"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); UpdateViewer(myStudyFrame,eEraseAll); } void View3D_i::DisplayAll() { if(MYDEBUG) MESSAGE("View3D_i::DisplayAll"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); UpdateViewer(myStudyFrame,eDisplayAll); } void View3D_i::Erase(PrsObject_ptr thePrsObj) { if(MYDEBUG) MESSAGE("View3D_i::Erase"); - Mutex mt(myMutex,qApp); - CORBA::Object_var anObj = thePrsObj; + Mutex mt(myMutex,qApp,MYDELAY); + CORBA::Object_ptr anObj = thePrsObj; if(Prs3d_i* aPrs = dynamic_cast(VISU::GetServant(anObj))) UpdateViewer(myStudyFrame,eErase,aPrs); } void View3D_i::Display(PrsObject_ptr thePrsObj) { if(MYDEBUG) MESSAGE("View3D_i::Display"); - Mutex mt(myMutex,qApp); - CORBA::Object_var anObj = thePrsObj; + Mutex mt(myMutex,qApp,MYDELAY); + CORBA::Object_ptr anObj = thePrsObj; if(Prs3d_i* aPrs = dynamic_cast(VISU::GetServant(anObj))) UpdateViewer(myStudyFrame,eDisplay,aPrs); } void View3D_i::DisplayOnly(PrsObject_ptr thePrsObj) { if(MYDEBUG) MESSAGE("View3D_i::DisplayOnly"); - Mutex mt(myMutex,qApp); - CORBA::Object_var anObj = thePrsObj; + Mutex mt(myMutex,qApp,MYDELAY); + CORBA::Object_ptr anObj = thePrsObj; if(Prs3d_i* aPrs = dynamic_cast(VISU::GetServant(anObj))) UpdateViewer(myStudyFrame,eDisplayOnly,aPrs); } @@ -992,13 +1067,13 @@ namespace VISU{ //-------------------- View3D interface -------------------- void View3D_i::FitAll() { if(MYDEBUG) MESSAGE("View3D_i::FitAll"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); GetViewFrame(myStudyFrame)->onViewFitAll(); Update(); } void View3D_i::SetView(VISU::View3D::ViewType theType) { if(MYDEBUG) MESSAGE("View3D_i::SetView"); - Mutex mt(myMutex,qApp); + Mutex mt(myMutex,qApp,MYDELAY); switch(theType){ case VISU::View3D::FRONT : GetViewFrame(myStudyFrame)->onViewFront(); break; case VISU::View3D::BACK : GetViewFrame(myStudyFrame)->onViewBack(); break; @@ -1010,138 +1085,107 @@ namespace VISU{ Update(); } + void View3D_i::SetPointOfView(QAD_StudyFrame* theStudyFrame, const CORBA::Double thePosition[3]) { + GetCamera(theStudyFrame)->SetPosition(thePosition); + } void View3D_i::SetPointOfView(const VISU::View3D::XYZ theCoord) { if(MYDEBUG) MESSAGE("View3D_i::SetPointOfView"); - Mutex mt(myMutex,qApp); - VISU::View3D::XYZ_copy(myPosition,theCoord); - GetCamera(myStudyFrame)->SetPosition(myPosition); + Mutex mt(myMutex,qApp,MYDELAY); + //VISU::View3D::XYZ_copy(myPosition,theCoord); + SetPointOfView(myStudyFrame, theCoord); + } + + void View3D_i::GetPointOfView(QAD_StudyFrame* theStudyFrame, CORBA::Double thePosition[3]) { + GetCamera(theStudyFrame)->GetPosition(thePosition); } VISU::View3D::XYZ_slice* View3D_i::GetPointOfView() { if(MYDEBUG) MESSAGE("View3D_i::GetPointOfView"); - Mutex mt(myMutex,qApp); - GetCamera(myStudyFrame)->GetPosition(myPosition); - return VISU::View3D::XYZ_dup(myPosition); + Mutex mt(myMutex,qApp,MYDELAY); + CORBA::Double aPosition[3]; + GetPointOfView(myStudyFrame,aPosition); + return VISU::View3D::XYZ_dup(aPosition); } + void View3D_i::SetViewUp(QAD_StudyFrame* theStudyFrame, const CORBA::Double theViewUp[3]) { + GetCamera(theStudyFrame)->SetViewUp(theViewUp); + } void View3D_i::SetViewUp(const VISU::View3D::XYZ theDir) { if(MYDEBUG) MESSAGE("View3D_i::SetViewUp"); - Mutex mt(myMutex,qApp); - VISU::View3D::XYZ_copy(myViewUp,theDir); - GetCamera(myStudyFrame)->SetViewUp(myViewUp); + Mutex mt(myMutex,qApp,MYDELAY); + //VISU::View3D::XYZ_copy(myViewUp,theDir); + SetViewUp(myStudyFrame, theDir); + } + + void View3D_i::GetViewUp(QAD_StudyFrame* theStudyFrame, CORBA::Double theViewUp[3]) { + GetCamera(theStudyFrame)->GetViewUp(theViewUp); } VISU::View3D::XYZ_slice* View3D_i::GetViewUp() { if(MYDEBUG) MESSAGE("View3D_i::GetViewUp"); - Mutex mt(myMutex,qApp); - GetCamera(myStudyFrame)->GetViewUp(myViewUp); - return VISU::View3D::XYZ_dup(myViewUp); + Mutex mt(myMutex,qApp,MYDELAY); + CORBA::Double aViewUp[3]; + GetCamera(myStudyFrame)->GetViewUp(aViewUp); + return VISU::View3D::XYZ_dup(aViewUp); } + void View3D_i::SetFocalPoint(QAD_StudyFrame* theStudyFrame, const CORBA::Double theFocalPnt[3]) { + GetCamera(theStudyFrame)->SetFocalPoint(theFocalPnt); + } void View3D_i::SetFocalPoint(const VISU::View3D::XYZ theCoord) { if(MYDEBUG) MESSAGE("View3D_i::SetFocalPoint"); - Mutex mt(myMutex,qApp); - VISU::View3D::XYZ_copy(myFocalPnt,theCoord); - GetCamera(myStudyFrame)->SetFocalPoint(myFocalPnt); + Mutex mt(myMutex,qApp,MYDELAY); + //VISU::View3D::XYZ_copy(myFocalPnt,theCoord); + SetFocalPoint(myStudyFrame,theCoord); + } + + void View3D_i::GetFocalPoint(QAD_StudyFrame* theStudyFrame, CORBA::Double theFocalPnt[3]) { + GetCamera(theStudyFrame)->GetFocalPoint(theFocalPnt); } VISU::View3D::XYZ_slice* View3D_i::GetFocalPoint() { if(MYDEBUG) MESSAGE("View3D_i::GetFocalPoint"); - Mutex mt(myMutex,qApp); - GetCamera(myStudyFrame)->GetFocalPoint(myFocalPnt); - return VISU::View3D::XYZ_dup(myFocalPnt); + Mutex mt(myMutex,qApp,MYDELAY); + CORBA::Double aFocalPnt[3]; + GetFocalPoint(myStudyFrame,aFocalPnt); + return VISU::View3D::XYZ_dup(aFocalPnt); } + void View3D_i::SetParallelScale(QAD_StudyFrame* theStudyFrame, CORBA::Double theScale) { + GetCamera(theStudyFrame)->SetParallelScale(theScale); + } void View3D_i::SetParallelScale(CORBA::Double theScale) { if(MYDEBUG) MESSAGE("View3D_i::SetParallelScale"); - Mutex mt(myMutex,qApp); - myParallelScale = theScale; - GetCamera(myStudyFrame)->SetParallelScale(myParallelScale); + Mutex mt(myMutex,qApp,MYDELAY); + //myParallelScale = theScale; + SetParallelScale(myStudyFrame, theScale); + } + + CORBA::Double View3D_i::GetParallelScale(QAD_StudyFrame* theStudyFrame) { + return GetCamera(theStudyFrame)->GetParallelScale(); } CORBA::Double View3D_i::GetParallelScale() { if(MYDEBUG) MESSAGE("View3D_i::GetParallelScale"); Mutex mt(myMutex,qApp); - return myParallelScale = GetCamera(myStudyFrame)->GetParallelScale(); + return GetParallelScale(myStudyFrame); } + void View3D_i::ScaleView(QAD_StudyFrame* theStudyFrame, VISU::View3D::Axis theAxis, CORBA::Double theParam) { + VTKViewer_ViewFrame* aViewFrame = GetViewFrame(theStudyFrame); + double aScaleFactor[3]; + aViewFrame->GetScale(aScaleFactor); + aScaleFactor[theAxis] = theParam; + aViewFrame->SetScale(aScaleFactor); + } void View3D_i::ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam) { + if(MYDEBUG) MESSAGE("View3D_i::ScaleView"); Mutex mt(myMutex,qApp); - bool changed = false; - VTKViewer_ViewFrame* vf = GetViewFrame(myStudyFrame); - VTKViewer_NonIsometricTransform *aTransform = vf->getNonIsometricTransform(); - static double EPS =1.0E-3; - VTKViewer_NonIsometricTransform::Function - aFunction = (fabs(theParam - 1.0) < EPS? - VTKViewer_NonIsometricTransform::Identical: - VTKViewer_NonIsometricTransform::Linear); - AxisFunction::Axis anAxis; - if(theAxis == VISU::View3D::XAxis){ - myScaleFactor[0] = theParam; - anAxis = AxisFunction::XAxis; - }else if(theAxis == VISU::View3D::YAxis){ - myScaleFactor[1] = theParam; - anAxis = AxisFunction::YAxis; - }else{ - myScaleFactor[2] = theParam; - anAxis = AxisFunction::ZAxis; - } - if(MYDEBUG) - MESSAGE("View3D_i::ScaleView - theParam = "<GetPolyDataMapper (); - else - mapper = vtkPolyDataMapper::SafeDownCast( initialMapper ); - if(mapper){ - //create transformation - if(MYDEBUG) MESSAGE("View3D_i::ScaleView - theActors->GetNextActor()"); - aTransform->SetFunction(anAxis,aFunction,theParam); - //create Filter - vtkTransformPolyDataFilter *aTransformFilter = vtkTransformPolyDataFilter::New(); - aTransformFilter->SetInput ( mapper->GetInput() ); - aTransformFilter->SetTransform (aTransform); - - //create new mapper - vtkMapper* aIMapper = pSA->GetInitialMapper(); - if ((aIMapper != NULL) && aIMapper->IsA("vtkDataSetMapper")) { - vtkDataSetMapper* aMapper = vtkDataSetMapper::New(); - aMapper->SetInput (aTransformFilter->GetOutput()); - aMapper->ShallowCopy ( actor->GetMapper()); - actor->SetMapper (aMapper); - aMapper->Delete(); - } else { - vtkPolyDataMapper *aMapper = vtkPolyDataMapper::New(); - aMapper->SetInput (aTransformFilter->GetOutput()); - aMapper->ShallowCopy ( actor->GetMapper()); - actor->SetMapper (aMapper); - aMapper->Delete(); - } - aTransformFilter->Delete(); - changed = true; - } - } - actor = theActors->GetNextActor(); - } - if(MYDEBUG) - MESSAGE("View3D_i::ScaleView - myScaleFactor = "<< - myScaleFactor[0]<<"; "<SetScale(aScaleFactor); } //=========================================================================== } diff --git a/src/VISU_I/VISU_ViewManager_i.hh b/src/VISU_I/VISU_ViewManager_i.hh index 6c847fae..0ba52167 100644 --- a/src/VISU_I/VISU_ViewManager_i.hh +++ b/src/VISU_I/VISU_ViewManager_i.hh @@ -1,8 +1,10 @@ -// File: VISU_ViewManager_i.hxx -// Created: Wed Jan 22 17:52:40 2003 -// Author: Alexey PETROV -// - +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_ViewManager_i.hxx +// Author : Alexey PETROV +// Module : VISU #ifndef VISU_ViewManager_i_HeaderFile #define VISU_ViewManager_i_HeaderFile @@ -62,7 +64,7 @@ namespace VISU{ virtual CORBA::Boolean SavePicture(const char* theFileName); virtual void Close() = 0; - virtual void ToStream(ostrstream& theStr); + virtual void ToStream(std::ostringstream& theStr); virtual const char* GetComment() const; public: virtual const char* View_i::GetEntry(); @@ -161,8 +163,13 @@ namespace VISU{ //View interface virtual void SetTitle(const char* theTitle); virtual char* GetTitle(); + + static void SetBackground(QAD_StudyFrame* theStudyFrame, const SALOMEDS::Color& theColor); virtual void SetBackground(const SALOMEDS::Color& theColor); + + static SALOMEDS::Color GetBackground(QAD_StudyFrame* theStudyFrame); virtual SALOMEDS::Color GetBackground(); + virtual void Minimize(); virtual void Restore(); virtual void Maximize(); @@ -179,43 +186,57 @@ namespace VISU{ virtual void FitAll(); virtual void SetView(VISU::View3D::ViewType theType); + static void SetPointOfView(QAD_StudyFrame* theStudyFrame, const CORBA::Double thePosition[3]); virtual void SetPointOfView(const VISU::View3D::XYZ theCoord); + + static void GetPointOfView(QAD_StudyFrame* theStudyFrame, CORBA::Double thePosition[3]); virtual VISU::View3D::XYZ_slice* GetPointOfView(); + static void SetViewUp(QAD_StudyFrame* theStudyFrame, const CORBA::Double theViewUp[3]); virtual void SetViewUp(const VISU::View3D::XYZ theDir); + + static void GetViewUp(QAD_StudyFrame* theStudyFrame, CORBA::Double theViewUp[3]); virtual VISU::View3D::XYZ_slice* GetViewUp(); + static void SetFocalPoint(QAD_StudyFrame* theStudyFrame, const CORBA::Double theFocalPnt[3]); virtual void SetFocalPoint(const VISU::View3D::XYZ theCoord); + + static void View3D_i::GetFocalPoint(QAD_StudyFrame* theStudyFrame, CORBA::Double theFocalPnt[3]); virtual VISU::View3D::XYZ_slice* GetFocalPoint(); + static void SetParallelScale(QAD_StudyFrame* theStudyFrame, CORBA::Double theScale); virtual void SetParallelScale(CORBA::Double theScale); + + static CORBA::Double GetParallelScale(QAD_StudyFrame* theStudyFrame); virtual CORBA::Double GetParallelScale(); + static void ScaleView(QAD_StudyFrame* theStudyFrame, VISU::View3D::Axis theAxis, CORBA::Double theParam); virtual void ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam); virtual void RemoveScale(); - virtual const char* GenerateViewParamsName(); + virtual QString GenerateViewParamsName(); virtual CORBA::Boolean SaveViewParams(const char* theName); virtual CORBA::Boolean RestoreViewParams(const char* theName); virtual void Close(); protected: QAD_StudyFrame* myStudyFrame; - SALOMEDS::Color myColor; - CORBA::Double myPosition[3], myFocalPnt[3], myViewUp[3], myParallelScale, myScaleFactor[3]; + //SALOMEDS::Color myColor; + //CORBA::Double myPosition[3], myFocalPnt[3], myViewUp[3], myParallelScale, myScaleFactor[3]; - Storable* Build(int theRestoring); + //Storable* Build(int theRestoring); static int myNbViewParams; public: virtual Storable* Create(int theNew); virtual Storable* Restore(const Storable::TRestoringMap& theMap) throw(std::logic_error&); - virtual void ToStream(ostrstream& theStr); + virtual void ToStream(std::ostringstream& theStr); virtual const char* GetComment() const; static const string myComment; + QAD_StudyFrame* GetStudyFrame() const { return myStudyFrame;} }; - Storable* View3DRestore(SALOMEDS::SComponent_var& theSComponent, SALOMEDS::Study_var& theStudy, - const char* thePrefix, const Storable::TRestoringMap& theMap); + //Storable* View3DRestore(SALOMEDS::SComponent_var& theSComponent, SALOMEDS::Study_var& theStudy, + // const char* thePrefix, const Storable::TRestoringMap& theMap); VTKViewer_ViewFrame* GetViewFrame(QAD_StudyFrame* theStudyFrame); vtkRenderer* GetRenderer(QAD_StudyFrame* theStudyFrame); diff --git a/src/VISU_SWIG/Makefile.in b/src/VISU_SWIG/Makefile.in index 6b950765..24f69da1 100644 --- a/src/VISU_SWIG/Makefile.in +++ b/src/VISU_SWIG/Makefile.in @@ -1,35 +1,53 @@ -#============================================================================== -# File : Makefile.in -# Created : mar nov 27 17:54:36 CET 2001 -# Author : Paul RASCLE, EDF -# Project : SALOME -# Copyright : EDF 2001 +# VISU VISU_SWIG : binding of C++ implementation and Python +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Paul RASCLE, EDF +# Module : VISU # $Header$ -#============================================================================== -# source path top_srcdir=@top_srcdir@ -top_builddir=../.. +top_builddir=../../.. srcdir=@srcdir@ -VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl +VPATH=.:@srcdir@:@top_srcdir@/idl @COMMENCE@ # Libraries targets -LIB = libVISU_Swigcmodule.la +LIB = libVisuGUI_Swigcmodule.la LIB_SRC = #SWIG_DEF = libVisuGUI_Swig.i #EXPORT_PYSCRIPTS = libVisuGUI_Swig.py visu.py visu_view3d.py batchmode_visu.py -EXPORT_PYSCRIPTS = batchmode_visu.py visu.py \ - visu_med.py visu_view3d.py batchmode_visu_view3d.py \ +EXPORT_PYSCRIPTS = 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 LIB_CLIENT_IDL = CPPFLAGS += $(PYTHON_INCLUDES) -DHAVE_CONFIG_H -LDFLAGS += $(PYTHON_LIBS) -lVISUGUI +LDFLAGS += $(PYTHON_LIBS) -lVisuGUI @CONCLUDE@ diff --git a/src/VISU_SWIG/batchmode_visu.py b/src/VISU_SWIG/batchmode_visu.py index 06dd539c..cc9f9552 100644 --- a/src/VISU_SWIG/batchmode_visu.py +++ b/src/VISU_SWIG/batchmode_visu.py @@ -1,70 +1,24 @@ +# VISU VISU_SWIG : binding of C++ implementation and Python +# +# Copyright (C) 2003 CEA/DEN, EDF R&D +# +# +# +# File : batchmode_visu.py +# Module : VISU + import os +import re +from time import sleep + +import VISU +import SALOMEDS import SALOME_MED -import batchmode_salome from omniORB import CORBA -import SALOMEDS - -mySession = batchmode_salome.naming_service.Resolve("/Kernel/Session") -mySession.GetInterface() -myVisu = batchmode_salome.lcc.FindOrLoadComponent("FactoryServer", "VISU") - -def getMedObjectFromStudy(): - mySO = batchmode_salome.myStudy.FindObject("Objet MED") - anAttr = mySO.FindAttribute("AttributeIOR")[1] - obj = batchmode_salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.MED) - return myObj - -def getFieldObjectFromStudy(number,subnumber): - mySO = batchmode_salome.myStudy.FindObject("MEDFIELD") - if mySO is None: - raise Runtime, "getFieldObjectFromStudy mySO is None" - mysub = mySO.FindSubObject(number)[1] - if mysub: - mysubsub = mysub.FindSubObject(subnumber)[1] - if mysubsub: - Builder = batchmode_salome.myStudy.NewBuilder() - anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeIOR") - obj = batchmode_salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.FIELDINT) - if (myObj == None): - myObj = obj._narrow(SALOME_MED.FIELDDOUBLE) - return myObj - else: - print "ERROR: No Field Object stored in this Study" - return None - - - -def SObjectToObject(theSObject) : - if theSObject is None : - print "SObjectToObject : argument is None" - anObj = None - res,Attr = theSObject.FindAttribute("AttributeIOR") - if (res != 0) and (Attr is not None) : - anIOR = Attr._narrow(SALOMEDS.AttributeIOR); - aValue = anIOR.Value(); - if(len(aValue) != 0) : - anObj = orb.string_to_object(aValue); - else: - print "SObjectToObject - IOR = ''" - return anObj; - -med_comp = batchmode_salome.lcc.FindOrLoadComponent("FactoryServer", "Med") - -#med_obj = getMedObjectFromStudy() +from batchmode_salome import * +import visu -#myBuilder = batchmode_salome.myStudy.NewBuilder() -#father = batchmode_salome.myStudy.FindComponent("VISU") -#myVisu.SetCurrentStudy(batchmode_salome.myStudy) -#father = batchmode_salome.myStudy.FindComponent("VISU") -#if father is None: -# father = myBuilder.NewComponent("VISU") -# A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName"); -# FName = A1._narrow(SALOMEDS.AttributeName) -# FName.SetValue("Visu") -# A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap"); -# aPixmap = A2._narrow(SALOMEDS.AttributePixMap); -# aPixmap.SetPixMap( "ICON_OBJBROWSER_Visu" ); -# myBuilder.DefineComponentInstance(father,myVisu) +myVisu = visu.Initialize(orb,naming_service,lcc,myStudyManager,myStudy,10) +if myVisu is None: + raise RuntimeError, "myVisu is none, VISU component is not loaded or found" diff --git a/src/VISU_SWIG/batchmode_visu_table.py b/src/VISU_SWIG/batchmode_visu_table.py new file mode 100644 index 00000000..e8c0afa7 --- /dev/null +++ b/src/VISU_SWIG/batchmode_visu_table.py @@ -0,0 +1,67 @@ +# VISU VISU_SWIG : binding of C++ implementation and Python +# +# Copyright (C) 2003 CEA/DEN, EDF R&D +# +# +# +# File : visu_big_table.py +# Author : Vadim SANDLER +# Module : VISU +# $Header$ + +from batchmode_salome import * +import batchmode_visu +import SALOMEDS +import VISU +import math + +# >>> Getting study builder ================================================== +myBuilder = myStudy.NewBuilder() + +# >>> Getting (loading) VISU component ======================================= +myVisu = lcc.FindOrLoadComponent("FactoryServer", "Visu") +myComponent = myStudy.FindComponent("VISU") +myVisu.SetCurrentStudy(myStudy) +if not myComponent: + myComponent = myBuilder.NewComponent("VISU") + aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName") + aName.SetValue("Visu") + myBuilder.DefineComponentInstance(myComponent,myVisu) + +# >>> Creating object with Table of real[ 200 * 20 ] ======================== +myTRealObject = myBuilder.NewObject(myComponent) +AName = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeName") +AName.SetValue("Table Of Real") +ARealTable = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeTableOfReal") +myHorNb = 10 +myVerNb = 200 + +k={} +for j in range(0,myHorNb): + k[j] = j*10+1 +ARealTable.AddRow(k.values()) +ARealTable.SetRowTitle(1, "Frequency") +ARealTable.SetRowUnit(1, "Hz") + +for i in range(1,myVerNb+1): + for j in range(0,myHorNb): + if j % 2 == 1: + k[j] = math.log10(j*30*math.pi/180) * 20 + i * 15 + j*5 + else: + k[j] = math.sin(j*30*math.pi/180) * 20 + i * 15 + j*5 + ARealTable.AddRow(k.values()) + ARealTable.SetRowTitle(i+1, "Power " + str(i)) + ARealTable.SetRowUnit(i+1, "Wt") +ARealTable.SetTitle("Very useful data") + +# >>> Create Visu table +myVisuTableReal = myVisu.CreateTable( myTRealObject.GetID() ) + +# >>> Create container and insert curves +myContainer = myVisu.CreateContainer() + +# >>> Create curves +for i in range(1,myVerNb+1): + myCurve = myVisu.CreateCurve( myVisuTableReal, 1, i+1 ) + myContainer.AddCurve(myCurve) +# ============================================================================ diff --git a/src/VISU_SWIG/batchmode_visu_view3d.py b/src/VISU_SWIG/batchmode_visu_view3d.py index 63842862..21468ec0 100644 --- a/src/VISU_SWIG/batchmode_visu_view3d.py +++ b/src/VISU_SWIG/batchmode_visu_view3d.py @@ -1,18 +1,25 @@ +# VISU VISU_SWIG : binding of C++ implementation and Python +# +# Copyright (C) 2003 CEA/DEN, EDF R&D +# +# +# +# File : batchmode_visu_view3d.py +# Module : VISU + import os -import batchmode_salome -from VISU import * +import batchmode_visu +import VISU import SALOMEDS -mySession = batchmode_salome.naming_service.Resolve("/Kernel/Session") -mySession.GetInterface() -myVisu = batchmode_salome.lcc.FindOrLoadComponent("FactoryServer", "VISU") -myVisu.SetCurrentStudy(batchmode_salome.myStudy); +#mySession = batchmode_visu.mySession +myVisu = batchmode_visu.myVisu -#medFile = "fra.med" -#myFieldName = "VITESSE"; +medFile = "fra.med" +myFieldName = "VITESSE"; -medFile = "minimail.dat" -myFieldName = "Pressures"; +#medFile = "minimail.dat" +#myFieldName = "Pressures"; #medFile = "brideResultats.dat" #myFieldName = "VM_Elem."; @@ -20,24 +27,42 @@ myFieldName = "Pressures"; medFile = os.getenv('SALOME_ROOT_DIR') + '/../SALOME_ROOT/data/' + medFile myResult = myVisu.ImportFile(medFile) -aMesh = myVisu.CreateMesh(myResult); -aScalarMap = myVisu.CreateScalarMap(myResult,myFieldName,0) -aScalarMap.SetScaling(LOGARITHMIC) -aCutPlanes = myVisu.CreateCutPlanes(myResult,myFieldName,0) -aCutPlanes.SetScaling(LOGARITHMIC) -aIsoSurfaces = myVisu.CreateIsoSurfaces(myResult,myFieldName,0) -aIsoSurfaces.SetScaling(LINEAR) + +aMeshName ="LE VOLUME" +anEntity = VISU.NODE +aMesh = myVisu.MeshOnEntity(myResult, aMeshName, anEntity) + +aTimeStampId = 1 + +# +aScalarMap = myVisu.ScalarMapOnField(myResult,aMeshName,anEntity,myFieldName,aTimeStampId) +if aScalarMap is not None: + aScalarMap.SetScaling(VISU.LOGARITHMIC) +else: + print "Null scalar map is created" + +# +aCutPlanes = myVisu.CutPlanesOnField(myResult,aMeshName,anEntity,myFieldName,aTimeStampId) +if aCutPlanes is not None: + aCutPlanes.SetScaling(VISU.LOGARITHMIC) +else: print "Null aCutPlanes is created" + +# +aIsoSurfaces = myVisu.IsoSurfacesOnField(myResult, aMeshName, anEntity, myFieldName, aTimeStampId) +if aIsoSurfaces is not None: + aIsoSurfaces.SetScaling(VISU.LINEAR) +else: print "Null aIsoSurfaces is created" myViewManager = myVisu.GetViewManager(); #myView = myViewManager.Create3DView(); -myView = myViewManager.GetCurrent3DView(); +myView = myViewManager.GetCurrentView(); myView.SetFocalPoint([0,0,0]); myView.SetParallelScale(2); aPoint = myView.GetPointOfView(); aPoint[0] = aPoint[0] + 10; myView.SetPointOfView(aPoint); -myView.ScaleView(View3D.YAxis,10.0); -myView.ScaleView(View3D.XAxis,3.0); +myView.ScaleView(VISU.View3D.YAxis,10.0); +myView.ScaleView(VISU.View3D.XAxis,3.0); aColor = SALOMEDS.Color(0.0,0.3,1.0) myView.SetBackground(aColor); myView.Update(); @@ -54,10 +79,7 @@ myView.SaveViewParams('BBB'); aColor = SALOMEDS.Color(1.0,1.0,1.0) myView.SetBackground(aColor); -myView.ScaleView(View3D.ZAxis,0.5); +myView.ScaleView(VISU.View3D.ZAxis,0.5); myView.SaveViewParams('CCC'); myView.RestoreViewParams('AAA'); - - - diff --git a/src/VISU_SWIG/libVISU_Swig.i b/src/VISU_SWIG/libVISU_Swig.i index 17ddcb26..ee17ad91 100644 --- a/src/VISU_SWIG/libVISU_Swig.i +++ b/src/VISU_SWIG/libVISU_Swig.i @@ -1,11 +1,30 @@ -//============================================================================= -// File : libVISU_Swig.i -// Created : mar nov 27 18:00:44 CET 2001 -// Author : Paul RASCLE, EDF -// Project : SALOME -// Copyright : EDF 2001 -// $Header$ -//============================================================================= +// VISU VISU_SWIG : binding of C++ implementation and Python +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : libVISU_Swig.i +// Author : Paul RASCLE, EDF +// Module : VISU +// $Header$ %module libVISU_Swig diff --git a/src/VISU_SWIG/visu.py b/src/VISU_SWIG/visu.py index fb33546e..73af65e1 100644 --- a/src/VISU_SWIG/visu.py +++ b/src/VISU_SWIG/visu.py @@ -1,31 +1,126 @@ -import sys +# VISU VISU_SWIG : binding of C++ implementation and Python +# +# Copyright (C) 2003 CEA/DEN, EDF R&D +# +# +# +# File : visu.py +# Module : VISU + import os -import salome +import re +from time import sleep + +import VISU import SALOMEDS -import SALOME import SALOME_MED +from omniORB import CORBA +from string import * +from time import sleep + +myORB = None +myNamingService = None +myLifeCycleCORBA = None +myNamingService = None +myLocalStudyManager = None +myLocalStudy = None +myLocalVisu = None +myDelay = None +mySession = None + +def Initialize(theORB, theNamingService, theLifeCycleCORBA, theStudyManager, theStudy, theDelay) : + global myORB, myNamingService, myLifeCycleCORBA, myLocalStudyManager, myLocalStudy + global mySession, myLocalVisu, myDelay + myDelay = theDelay + myORB = theORB + myNamingService = theNamingService + myLifeCycleCORBA = theLifeCycleCORBA + myLocalStudyManager = theStudyManager + mySession = myNamingService.Resolve("/Kernel/Session") + mySession.GetInterface() + myDelay = theDelay + sleep(myDelay) + myLocalVisu = myLifeCycleCORBA.FindOrLoadComponent("FactoryServer", "Visu") + myLocalStudy = theStudy + myLocalVisu.SetCurrentStudy(myLocalStudy) + return myLocalVisu + +def StrToMap(theString) : + aPairList = split(theString,";") + aMap = {} + iEnd = len(aPairList) + for i in range(iEnd) : + aPair = split(aPairList[i],"=") + aMap[aPair[0]] = aPair[1] + return aMap + +def IntToEntity(theInt) : + theInt = atoi(theInt) + if theInt == 0 : + return VISU.NODE; + elif theInt == 1 : + return VISU.EDGE; + elif theInt == 2 : + return VISU.FACE; + else : + return VISU.CELL; + +def HasValue(theList, theValue) : + try : + return theList.index(theValue) + 1 + except StandardError, e : + return 0 -from libSALOME_Swig import * -sg = SALOMEGUI_Swig() +def CreateStudyForMed(theVisu, theFileName) : + print "CreateStudyForMed ", theFileName, + if os.path.isfile(theFileName) : + if os.path.splitext(theFileName)[1] == '.med' : + print "OK" + aStudyName = os.path.basename(theFileName) + aStudyName = os.path.splitext(aStudyName)[0] + aStudyName = generateName(aStudyName) + print "myLocalStudyManager.NewStudy -", aStudyName, "...", + aStudy = myLocalStudyManager.NewStudy(aStudyName) + if aStudy is None : raise RuntimeError, "Error" + else : print "OK" + + print "CreateStudyForMed - Creating a 3D viewer...", + theVisu.SetCurrentStudy(aStudy) + myViewManager = theVisu.GetViewManager() + if myViewManager is None : raise RuntimeError, "Error - theVisu.GetViewManager" + myView = myViewManager.Create3DView() + if myView is None : raise RuntimeError, "Error - myViewManager.Create3DView" + myView.Maximize() + print "OK" -myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU") + return [aStudy, myViewManager, myView] + raise RuntimeError, "Error: There is no shuch file." -def getMedObjectFromStudy(): - mySO = salome.myStudy.FindObject("Objet MED") +def getMedObjectFromStudy(theStudy = myLocalStudy): + if theStudy is None: + theStudy = myLocalStudy + mySO = theStudy.FindObject("Objet MED") anAttr = mySO.FindAttribute("AttributeIOR")[1] - obj = salome.orb.string_to_object(anAttr.Value()) + obj = myORB.string_to_object(anAttr.Value()) myObj = obj._narrow(SALOME_MED.MED) return myObj -def getFieldObjectFromStudy(number,subnumber): - mySO = salome.myStudy.FindObject("MEDFIELD") +def getMedSObject(theStudy = myLocalStudy ): + return theStudy.FindObject("Objet MED") + +def getFieldObjectFromStudy(number, subnumber, theStudy = myLocalStudy): + if theStudy is None: + theStudy = myLocalStudy + mySO = theStudy.FindObject("MEDFIELD") + if mySO is None: + raise Runtime, "getFieldObjectFromStudy mySO is None" mysub = mySO.FindSubObject(number)[1] if mysub: mysubsub = mysub.FindSubObject(subnumber)[1] if mysubsub: - Builder = salome.myStudy.NewBuilder() + Builder = theStudy.NewBuilder() anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeIOR") - obj = salome.orb.string_to_object(anAttr.Value()) + obj = myORB.string_to_object(anAttr.Value()) myObj = obj._narrow(SALOME_MED.FIELDINT) if (myObj == None): myObj = obj._narrow(SALOME_MED.FIELDDOUBLE) @@ -34,45 +129,364 @@ def getFieldObjectFromStudy(number,subnumber): print "ERROR: No Field Object stored in this Study" return None -#medFile = "mixte.med" -#medFile = "fra.med" -medFile = "pointe.med" -#medFile = "carre_en_quad4_seg2.med" -#medFile = "cube_hexa8_quad4.med" - -medFile = os.getenv('SALOME_ROOT_DIR') + '/../SALOME_ROOT/data/' + medFile -print medFile -studyCurrent = salome.myStudyName -med_comp = salome.lcc.FindOrLoadComponent("FactoryServer", "Med") -try: - if os.access(medFile, os.R_OK) : - if os.access(medFile, os.W_OK) : - med_comp.readStructFileWithFieldType(medFile,studyCurrent) - med_obj = getMedObjectFromStudy() - print "med_obj - ", med_obj - - myField = getFieldObjectFromStudy(2,1) - myResult1 = myVisu.ImportMed(myField) - aMesh1 = myVisu.CreateMesh(myResult1); - aScalarMap1 = myVisu.CreateScalarMap(myResult1,myField.getName(),0) - if(myField.getNumberOfComponents() > 1) : - aVectors = myVisu.CreateVectors(myResult1,myField.getName(),0) - - myResult2 = myVisu.ImportFile(medFile) - aMesh2 = myVisu.CreateMesh(myResult2); - aScalarMap2 = myVisu.CreateScalarMap(myResult2,myField.getName(),0) - if(myField.getNumberOfComponents() > 1) : - aCutPlanes = myVisu.CreateCutPlanes(myResult2,myField.getName(),0) - - sg.updateObjBrowser(1) - else : print "We have no permission to rewrite medFile, so readStructFileWithFieldType can't open this file"; - else : print "We have no permission to read medFile, it will not be opened"; - -except: - if sys.exc_type == SALOME.SALOME_Exception : - print "There is no permission to read " + medFile - else : - print sys.exc_type - print sys.exc_value - print sys.exc_traceback +def SObjectToObject(theSObject) : + # global myORB + if theSObject is None : + print "SObjectToObject : argument is None" + anObj = None + res,Attr = theSObject.FindAttribute("AttributeIOR") + if (res != 0) and (Attr is not None) : + anIOR = Attr._narrow(SALOMEDS.AttributeIOR); + aValue = anIOR.Value(); + if(len(aValue) != 0) : + anObj = myORB.string_to_object(aValue); + else: + print "SObjectToObject - IOR = ''" + return anObj; + +def CreatePrsForMed(theVisu, theFileName, thePrsTypeList, thePictureDir, thePictureExt) : +# try: + global myLifeCycleCORBA + print "lcc.FindOrLoadComponent...", + aMedComp = myLifeCycleCORBA.FindOrLoadComponent("FactoryServer", "Med") + if aMedComp is None : print "Error" + else : print "OK" + + aVISUObjList = [myLocalStudy, myViewManager, myView] = CreateStudyForMed(theVisu, theFileName) + + print "aMedComp.readStructFileWithFieldType...", + aMedComp.readStructFileWithFieldType(theFileName,myLocalStudy._get_Name()) + aMedSObj = getMedSObject(myLocalStudy) + if aMedSObj is None : raise RuntimeError, "Error" + else : print "OK" + + print "theVisu.ImportMed...", + aResult = theVisu.ImportMed(aMedSObj) + if aResult is None : raise RuntimeError, "Error" + else : print "OK" + aVISUObjList.append(aResult) + aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt)) + + aFolderIter = myLocalStudy.NewChildIterator(aMedSObj); + while aFolderIter.More() : + aFolderSObj = aFolderIter.Value() + aFolderIter.Next() + anAttr = aFolderSObj.FindAttribute("AttributeName")[1] + anAttr = anAttr._narrow(SALOMEDS.AttributeName); + aFolderName = anAttr.Value() + print " ", aFolderName + + if aFolderName == 'MEDMESH' : + aMeshIter = myLocalStudy.NewChildIterator(aFolderSObj); + while aMeshIter.More() : + aMeshSObj = aMeshIter.Value() + aMeshIter.Next() + anAttr = aMeshSObj.FindAttribute("AttributeName")[1] + anAttr = anAttr._narrow(SALOMEDS.AttributeName); + aMeshName = anAttr.Value() + print " ", aMeshName + + aSupportIter = myLocalStudy.NewChildIterator(aMeshSObj); + while aSupportIter.More() : + aSupportSObj = aSupportIter.Value() + aSupportIter.Next() + anAttr = aSupportSObj.FindAttribute("AttributeName")[1] + anAttr = anAttr._narrow(SALOMEDS.AttributeName); + aSupportName = anAttr.Value() + print " ", aSupportName + if aFolderName == 'MEDFIELD' : + aFieldIter = myLocalStudy.NewChildIterator(aFolderSObj); + while aFieldIter.More() : + aFieldSObj = aFieldIter.Value() + aFieldIter.Next() + anAttr = aFieldSObj.FindAttribute("AttributeName")[1] + anAttr = anAttr._narrow(SALOMEDS.AttributeName); + aFieldName = anAttr.Value() + print " ", aFieldName + + print "theVisu.ImportMed...", + aResult = theVisu.ImportMed(aFieldSObj) + if aResult is None : raise RuntimeError, "Error" + else : print "OK" + aVISUObjList.append(aResult) + aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt)) + + aTimeStampIter = myLocalStudy.NewChildIterator(aFieldSObj); + if aTimeStampIter.More() : + aTimeStampIter.Next() + while aTimeStampIter.More() : + aTimeStampSObj = aTimeStampIter.Value() + aTimeStampIter.Next() + anAttr = aTimeStampSObj.FindAttribute("AttributeName")[1] + anAttr = anAttr._narrow(SALOMEDS.AttributeName); + aTimeStampName = anAttr.Value() + print " ", aTimeStampName + + print "theVisu.ImportMed...", + aMedField = SObjectToObject(aTimeStampSObj) + aResult = theVisu.ImportMedFiled(aMedField) + if aResult is None : raise RuntimeError, "Error" + else : print "OK" + aVISUObjList.append(aResult) + aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt)) + + return aVISUObjList + +# except Exception, e: +# print str(e) + +def CreatePrsForFile(theVisu, theFileName, thePrsTypeList, thePictureDir, thePictureExt) : + # try: + aVISUObjList = [myLocalStudy, myViewManager, myView] = CreateStudyForMed(theVisu, theFileName) + + print "theVisu.ImportMed..." + aResult = theVisu.ImportFile(theFileName) + if aResult is None : raise RuntimeError, "Error" + else : print "OK" + + aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt)) + + return aVISUObjList + +# except Exception, e: +# print str(e) + +def CreatePrsForResult(theVisu, theResult, theView, thePrsTypeList, thePictureDir, thePictureExt) : + aVISUObjList = [] + print "CreatePrsForResult - myLocalStudy.FindObjectIOR...", + myLocalStudy = theVisu.GetCurrentStudy() + aSObj = myLocalStudy.FindObjectIOR(theResult.GetID()) + if aSObj is None : raise RuntimeError, "Error" + else : print "OK" + aMeshIter = myLocalStudy.NewChildIterator(aSObj); + while aMeshIter.More() : + aMeshSObj = aMeshIter.Value() + aMeshIter.Next() + anAttr = aMeshSObj.FindAttribute("AttributeName")[1] + if anAttr is None : + aMeshSObj = aMeshIter.Value() + aMeshIter.Next() + anAttr = aMeshSObj.FindAttribute("AttributeName")[1] + anAttr = anAttr._narrow(SALOMEDS.AttributeName); + aMeshName = anAttr.Value() + print " ", aMeshName + + aFolderIter = myLocalStudy.NewChildIterator(aMeshSObj); + while aFolderIter.More() : + aFolderSObj = aFolderIter.Value() + aFolderIter.Next() + anAttr = aFolderSObj.FindAttribute("AttributeName")[1] + anAttr = anAttr._narrow(SALOMEDS.AttributeName); + aFolderName = anAttr.Value() + print " ", aFolderName + + if aFolderName == 'Families' : + anEntityIter = myLocalStudy.NewChildIterator(aFolderSObj); + while anEntityIter.More() : + anEntitySObj = anEntityIter.Value() + anEntityIter.Next() + anAttr = anEntitySObj.FindAttribute("AttributeName")[1] + anAttr = anAttr._narrow(SALOMEDS.AttributeName); + anEntityName = anAttr.Value() + + anEntityId = "3" + if anEntityName == 'onNodes' : + anEntity = VISU.NODE + anEntityId = "0" + if anEntityName == 'onEdges' : + anEntity = VISU.EDGE + anEntityId = "1" + if anEntityName == 'onFaces' : + anEntity = VISU.FACE + anEntityId = "2" + if anEntityName == 'onCells' : + anEntity = VISU.CELL + anEntityId = "3" + + if HasValue(thePrsTypeList,VISU.TMESH) : + print " ", anEntityName, + aMesh = theVisu.MeshOnEntity(theResult,aMeshName,anEntity) + if aMesh is None : print "Error" + else : print ",OK" + theView.DisplayOnly(aMesh) + theView.FitAll() + aPictureName = thePictureDir + aMeshName + "_" + anEntityId + "." + thePictureExt + aPictureName = re.sub("\s+","_", aPictureName); + theView.SavePicture(aPictureName) + aVISUObjList.append(aMesh) + + anFamilyIter = myLocalStudy.NewChildIterator(anEntitySObj); + while anFamilyIter.More() : + aFamilySObj = anFamilyIter.Value() + anFamilyIter.Next() + anAttr = aFamilySObj.FindAttribute("AttributeName")[1] + anAttr = anAttr._narrow(SALOMEDS.AttributeName); + anFamilyName = anAttr.Value() + if HasValue(thePrsTypeList,VISU.TMESH) : + print " ", anFamilyName, + aMesh = theVisu.FamilyMeshOnEntity(theResult,aMeshName,anEntity,anFamilyName) + if aMesh is None : print "Error" + else : print ",OK" + theView.DisplayOnly(aMesh) + theView.FitAll() + aPictureName = thePictureDir + aMeshName + "_" + anEntityId + "_" + anFamilyName + "." + thePictureExt + aPictureName = re.sub("\s+","_", aPictureName); + theView.SavePicture(aPictureName) + aVISUObjList.append(aMesh) + + if aFolderName == 'Groups' : + aGroupIter = myLocalStudy.NewChildIterator(aFolderSObj); + while aGroupIter.More() : + aGroupSObj = aGroupIter.Value() + aGroupIter.Next() + anAttr = aGroupSObj.FindAttribute("AttributeName")[1] + anAttr = anAttr._narrow(SALOMEDS.AttributeName); + aGroupName = anAttr.Value() + if HasValue(thePrsTypeList,VISU.TMESH) : + print " ", aGroupName, + aMesh = theVisu.GroupMesh(theResult,aMeshName,aGroupName) + if aMesh is None : print "Error" + else : print ",OK" + theView.DisplayOnly(aMesh) + theView.FitAll() + aPictureName = thePictureDir + aMeshName + "_" + aGroupName + "." + thePictureExt + aPictureName = re.sub("\s+","_", aPictureName); + theView.SavePicture(aPictureName) + aVISUObjList.append(aMesh) + + if aFolderName == 'Fields' : + aFieldIter = myLocalStudy.NewChildIterator(aFolderSObj); + while aFieldIter.More() : + aFieldSObj = aFieldIter.Value() + aFieldIter.Next() + anAttr = aFieldSObj.FindAttribute("AttributeName")[1] + anAttr = anAttr._narrow(SALOMEDS.AttributeName); + aFieldName = anAttr.Value() + print " ", aFieldName + + anAttr = aFieldSObj.FindAttribute("AttributeComment")[1] + anAttr = anAttr._narrow(SALOMEDS.AttributeComment); + aFieldComment = anAttr.Value() + aMap = StrToMap(aFieldComment) + + aTimeStampIter = myLocalStudy.NewChildIterator(aFieldSObj); + if aTimeStampIter.More() : + aTimeStampIter.Next() + while aTimeStampIter.More() : + aTimeStampSObj = aTimeStampIter.Value() + aTimeStampIter.Next() + anAttr = aTimeStampSObj.FindAttribute("AttributeName")[1] + anAttr = anAttr._narrow(SALOMEDS.AttributeName); + aTimeStampName = anAttr.Value() + print " ", aTimeStampName + + anAttr = aTimeStampSObj.FindAttribute("AttributeComment")[1] + anAttr = anAttr._narrow(SALOMEDS.AttributeComment); + aTimeStampComment = anAttr.Value() + aMap = StrToMap(aTimeStampComment) + aMeshName = aMap["myMeshName"] + aFieldName = aMap["myFieldName"] + aTimeStampId = atoi(aMap["myTimeStampId"]) + anEntity = IntToEntity(aMap["myEntityId"]) + anEntityId = str(aMap["myEntityId"]); + #print aMeshName, aFieldName, anEntity, aTimeStampId + if HasValue(thePrsTypeList,VISU.TSCALARMAP) : + print " Creating ScalarMapOnField", + aPrsObj = theVisu.ScalarMapOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId) + if aPrsObj is None : print "Error" + else : print ",OK" + theView.DisplayOnly(aPrsObj) + theView.FitAll() + aPictureName = thePictureDir + aMeshName + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TSCALARMAP." + thePictureExt + aPictureName = re.sub("\s+","_", aPictureName); + theView.SavePicture(aPictureName) + aVISUObjList.append(aPrsObj) + + if HasValue(thePrsTypeList,VISU.TISOSURFACE) : + print " Creating IsoSurfacesOnField", + aPrsObj = theVisu.IsoSurfacesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId) + if aPrsObj is None : print "Error" + else : print ",OK" + theView.DisplayOnly(aPrsObj) + theView.FitAll() + aPictureName = thePictureDir + aMeshName + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TISOSURFACE." + thePictureExt + aPictureName = re.sub("\s+","_", aPictureName); + theView.SavePicture(aPictureName) + aVISUObjList.append(aPrsObj) + + if HasValue(thePrsTypeList,VISU.TCUTPLANES) : + print " Creating CutPlanesOnField", + aPrsObj = theVisu.CutPlanesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId) + if aPrsObj is None : print "Error" + else : print ",OK" + aPrsObj.SetOrientationType(VISU.CutPlanes.ZX) + theView.DisplayOnly(aPrsObj) + theView.FitAll() + aPictureName = thePictureDir + aMeshName + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TCUTPLANES." + thePictureExt + aPictureName = re.sub("\s+","_", aPictureName) + theView.SavePicture(aPictureName) + aVISUObjList.append(aPrsObj) + + if HasValue(thePrsTypeList,VISU.TCUTLINES) : + print " Creating CutLinesOnField", + aPrsObj = theVisu.CutLinesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId) + if aPrsObj is None : print "Error" + else : print ",OK" + aPrsObj.SetOrientationType(VISU.CutPlanes.XY) + aPrsObj.SetOrientationType2(VISU.CutPlanes.ZX) + theView.DisplayOnly(aPrsObj) + theView.FitAll() + aPictureName = thePictureDir + aMeshName + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TCUTLINES." + thePictureExt + aPictureName = re.sub("\s+","_", aPictureName) + theView.SavePicture(aPictureName) + aVISUObjList.append(aPrsObj) + + aNumComponent = atoi(aMap["myNumComponent"]) + if aNumComponent > 1 : + if HasValue(thePrsTypeList,VISU.TDEFORMEDSHAPE) : + print " Creating DeformedShapeOnField", + aPrsObj = theVisu.DeformedShapeOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId) + if aPrsObj is None : print "Error" + else : print ",OK" + theView.DisplayOnly(aPrsObj) + theView.FitAll() + aPictureName = thePictureDir + aMeshName + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TDEFORMEDSHAPE." + thePictureExt + aPictureName = re.sub("\s+","_", aPictureName) + theView.SavePicture(aPictureName) + aVISUObjList.append(aPrsObj) + + if HasValue(thePrsTypeList,VISU.TVECTORS) : + print " Creating VectorsOnField", + aPrsObj = theVisu.VectorsOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId) + if aPrsObj is None : print "Error" + else : print ",OK" + theView.DisplayOnly(aPrsObj) + theView.FitAll() + aPictureName = thePictureDir + aMeshName + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TVECTORS." + thePictureExt + aPictureName = re.sub("\s+","_", aPictureName) + theView.SavePicture(aPictureName) + aVISUObjList.append(aPrsObj) + + if HasValue(thePrsTypeList,VISU.TSTREAMLINES) : + print " Creating StreamLinesOnField", + aPrsObj = theVisu.StreamLinesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId) + if aPrsObj is None : print "Error" + else : print ",OK" + theView.DisplayOnly(aPrsObj) + theView.FitAll() + aPictureName = thePictureDir + aMeshName + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TSTREAMLINES." + thePictureExt + aPictureName = re.sub("\s+","_", aPictureName) + theView.SavePicture(aPictureName) + aVISUObjList.append(aPrsObj) + + return aVISUObjList + + +def generateName(prefix = None): + import whrandom; + int = whrandom.randint(1,1000); + if prefix is None: + return "Study" + str(int) + else : + return prefix + str(int) diff --git a/src/VISU_SWIG/visu_big_table.py b/src/VISU_SWIG/visu_big_table.py index 0184c514..15d18205 100644 --- a/src/VISU_SWIG/visu_big_table.py +++ b/src/VISU_SWIG/visu_big_table.py @@ -1,15 +1,14 @@ -#============================================================================== -# File : visu_big_table.py -# Created : 20/01/03 -# Author : Vadim SANDLER -# Project : SALOME -# Copyright : Open CASCADE +# VISU VISU_SWIG : binding of C++ implementation and Python +# +# Copyright (C) 2003 CEA/DEN, EDF R&D +# +# +# +# File : visu_big_table.py +# Author : Vadim SANDLER +# Module : VISU # $Header$ -#============================================================================== -# ============================================================================ -# Test large tables : ~200 curves ( 100 points in each ) -# ============================================================================ import salome import math import SALOMEDS @@ -20,14 +19,13 @@ myStudy = salome.myStudy myBuilder = myStudy.NewBuilder() # >>> Getting (loading) VISU component ======================================= -myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU") +myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "Visu") myComponent = myStudy.FindComponent("VISU") myVisu.SetCurrentStudy(myStudy) if not myComponent: myComponent = myBuilder.NewComponent("VISU") aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName") -# aName.SetValue("Visu") - aName.SetValue( salome.sg.getComponentUserName("VISU") ) + aName.SetValue("Visu") myBuilder.DefineComponentInstance(myComponent,myVisu) # >>> Creating object with Table of real[ 200 * 20 ] ======================== diff --git a/src/VISU_SWIG/visu_gui.py b/src/VISU_SWIG/visu_gui.py new file mode 100644 index 00000000..d21a239f --- /dev/null +++ b/src/VISU_SWIG/visu_gui.py @@ -0,0 +1,23 @@ +# VISU VISU_SWIG : binding of C++ implementation and Python +# +# Copyright (C) 2003 CEA/DEN, EDF R&D +# +# +# +# File : visu_gui.py +# Module : VISU + +import sys +import os + +import SALOMEDS +import SALOME +import SALOME_MED +import VISU + +from salome import * +import visu + +myVisu = visu.Initialize(orb, naming_service,lcc,myStudyManager,myStudy, 2) +if myVisu is None: + raise RuntimeError, "myVisu is none, VISU component is not loaded or found" diff --git a/src/VISU_SWIG/visu_med.py b/src/VISU_SWIG/visu_med.py index d3a4813c..dbb195b6 100644 --- a/src/VISU_SWIG/visu_med.py +++ b/src/VISU_SWIG/visu_med.py @@ -1,3 +1,12 @@ +# VISU VISU_SWIG : binding of C++ implementation and Python +# +# Copyright (C) 2003 CEA/DEN, EDF R&D +# +# +# +# File : visu_med.py +# Module : VISU + import os import salome import SALOMEDS @@ -44,7 +53,7 @@ def importMed(medFile): importMedFrom(medDir,medFile) #med_obj = getMedObjectFromStudy() -myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU") +myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "Visu") print "Use importMed(medFile) or importMedFrom(medDir,medFile) functions !" #myField = getFieldObjectFromStudy(2,1) diff --git a/src/VISU_SWIG/visu_prs_example.py b/src/VISU_SWIG/visu_prs_example.py new file mode 100644 index 00000000..3ae0c6aa --- /dev/null +++ b/src/VISU_SWIG/visu_prs_example.py @@ -0,0 +1,71 @@ +# VISU VISU_SWIG : binding of C++ implementation and Python +# +# Copyright (C) 2003 CEA/DEN, EDF R&D +# +# +# +# File : visu_prs_exam.py +# Module : VISU + +import sys +import os +import salome +import SALOMEDS +import SALOME +import SALOME_MED +import VISU + +from libSALOME_Swig import * +sg = SALOMEGUI_Swig() + +import visu_gui +myVisu = visu_gui.myVisu + +medFile = "pointe.med" +medFile = os.getenv('SALOME_ROOT_DIR') + '/../SALOME_ROOT/data/' + medFile +print medFile + +studyCurrent = salome.myStudyName + +med_comp = salome.lcc.FindOrLoadComponent("FactoryServer", "Med") +#myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "Visu") + +try: + if os.access(medFile, os.R_OK) : + if os.access(medFile, os.W_OK) : + med_comp.readStructFileWithFieldType(medFile,studyCurrent) + med_obj = visu_gui.visu.getMedObjectFromStudy() + print "med_obj - ", med_obj + + myField = visu_gui.visu.getFieldObjectFromStudy(2,1) + aMeshName = "FILED_DOUBLE_MESH" + anEntity = VISU.NODE + aTimeStampId = 0 + + myResult1 = myVisu.ImportMedField(myField) + aMesh1 = myVisu.MeshOnEntity(myResult1, aMeshName, anEntity); + + aScalarMap1= myVisu.ScalarMapOnField(myResult1, aMeshName, anEntity, myField.getName(), aTimeStampId) + if(myField.getNumberOfComponents() > 1) : + aVectors = myVisu.VectorsOnField(myResult1, aMeshName, anEntity, myField.getName(), aTimeStampId) + + myResult2 = myVisu.ImportFile(medFile) + aMeshName = "maa1" + anEntity = VISU.NODE + aMesh2 = myVisu.MeshOnEntity(myResult2, aMeshName, anEntity) + + aScalarMap2 = myVisu.ScalarMapOnField(myResult2, aMeshName, anEntity, myField.getName(), aTimeStampId) + if(myField.getNumberOfComponents() > 1) : + aCutPlanes = myVisu.CutPlanesOnField(myResult2, aMeshName, anEntity, myField.getName(), aTimeStampId) + + sg.updateObjBrowser(0) + else : print "We have no permission to rewrite medFile, so readStructFileWithFieldType can't open this file"; + else : print "We have no permission to read medFile, it will not be opened"; +except: + if sys.exc_type == SALOME.SALOME_Exception : + print "There is no permission to read " + medFile + else : + print sys.exc_type + print sys.exc_value + print sys.exc_traceback + diff --git a/src/VISU_SWIG/visu_table.py b/src/VISU_SWIG/visu_table.py index b09b2901..d39beaf7 100644 --- a/src/VISU_SWIG/visu_table.py +++ b/src/VISU_SWIG/visu_table.py @@ -1,15 +1,14 @@ -#============================================================================== -# File : visu_table.py -# Created : 20/01/03 -# Author : Vadim SANDLER -# Project : SALOME -# Copyright : Open CASCADE +# VISU VISU_SWIG : binding of C++ implementation and Python +# +# Copyright (C) 2003 CEA/DEN, EDF R&D +# +# +# +# File : visu_table.py +# Author : Vadim SANDLER +# Module : VISU # $Header$ -#============================================================================== -# ============================================================================ -# Check attributes creation : Integer, Real, Comment, Tables -# ============================================================================ import salome import math import SALOMEDS @@ -20,13 +19,13 @@ myStudy = salome.myStudy myBuilder = myStudy.NewBuilder() # >>> Getting (loading) VISU component ======================================= -myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU") +myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "Visu") myComponent = myStudy.FindComponent("VISU") myVisu.SetCurrentStudy(myStudy) if not myComponent: myComponent = myBuilder.NewComponent("VISU") aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName") - aName.SetValue( salome.sg.getComponentUserName("VISU") ) + aName.SetValue("Visu") myBuilder.DefineComponentInstance(myComponent,myVisu) # >>> Creating object with Table of integer ================================== diff --git a/src/VISU_SWIG/visu_view.py b/src/VISU_SWIG/visu_view.py index 92ade37d..d301e592 100644 --- a/src/VISU_SWIG/visu_view.py +++ b/src/VISU_SWIG/visu_view.py @@ -1,11 +1,13 @@ -#============================================================================== -# File : test_table.py -# Created : 20/01/03 -# Author : Alexey Petrov -# Project : SALOME -# Copyright : Open CASCADE +# VISU VISU_SWIG : binding of C++ implementation and Python +# +# Copyright (C) 2003 CEA/DEN, EDF R&D +# +# +# +# File : test_table.py +# Author : Alexey Petrov +# Module : VISU # $Header: -#============================================================================== import SALOMEDS import VISU @@ -22,7 +24,7 @@ myTable = myViewMan.CreateTableView(myVisuTableReal) myTitle = myTable.GetTitle() myTable.SetTitle('Changed Title') -myPlot = myViewMan.CreateXYPlot(myContainer1) +myPlot = myViewMan.CreateXYPlot() myTitle = myPlot.GetTitle() myPlot.SetTitle('Change the title from python') diff --git a/src/VISU_SWIG/visu_view3d.py b/src/VISU_SWIG/visu_view3d.py index d584fdae..f94f29ee 100644 --- a/src/VISU_SWIG/visu_view3d.py +++ b/src/VISU_SWIG/visu_view3d.py @@ -1,42 +1,63 @@ +# VISU VISU_SWIG : binding of C++ implementation and Python +# +# Copyright (C) 2003 CEA/DEN, EDF R&D +# +# +# +# File : visu_view3d.py +# Module : VISU + +import visu_gui import os -import salome -from VISU import * +import VISU import SALOMEDS + from libSALOME_Swig import * sg = SALOMEGUI_Swig() -myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU") - -#medFile = "fra.med" -#myFieldName = "VITESSE"; - -medFile = "minimail.dat" -myFieldName = "Pressures"; +myVisu = visu_gui.myVisu -medFile = "brideResultats.dat" -myFieldName = "VM_Elem."; +medFile = "fra.med" +myFieldName = "VITESSE"; medFile = os.getenv('SALOME_ROOT_DIR') + '/../SALOME_ROOT/data/' + medFile myResult = myVisu.ImportFile(medFile) -aMesh = myVisu.CreateMesh(myResult); -aScalarMap = myVisu.CreateScalarMap(myResult,myFieldName,0) -aScalarMap.SetScaling(LOGARITHMIC) -aCutPlanes = myVisu.CreateCutPlanes(myResult,myFieldName,0) -aCutPlanes.SetScaling(LOGARITHMIC) -aIsoSurfaces = myVisu.CreateIsoSurfaces(myResult,myFieldName,0) -aIsoSurfaces.SetScaling(LINEAR) +aMeshName ="LE VOLUME" +anEntity = VISU.NODE +aMesh = myVisu.MeshOnEntity(myResult, aMeshName, anEntity) + +aTimeStampId = 1 + +# +aScalarMap = myVisu.ScalarMapOnField(myResult,aMeshName,anEntity,myFieldName,aTimeStampId) +if aScalarMap is not None: + aScalarMap.SetScaling(VISU.LOGARITHMIC) +else: + print "Null scalar map is created" + +# +aCutPlanes = myVisu.CutPlanesOnField(myResult,aMeshName,anEntity,myFieldName,aTimeStampId) +if aCutPlanes is not None: + aCutPlanes.SetScaling(VISU.LOGARITHMIC) +else: print "Null aCutPlanes is created" + +# +aIsoSurfaces = myVisu.IsoSurfacesOnField(myResult, aMeshName, anEntity, myFieldName, aTimeStampId) +if aIsoSurfaces is not None: + aIsoSurfaces.SetScaling(VISU.LINEAR) +else: print "Null aIsoSurfaces is created" myViewManager = myVisu.GetViewManager(); #myView = myViewManager.Create3DView(); -myView = myViewManager.GetCurrent3DView(); +myView = myViewManager.GetCurrentView(); myView.SetFocalPoint([0,0,0]); myView.SetParallelScale(2); aPoint = myView.GetPointOfView(); aPoint[0] = aPoint[0] + 10; myView.SetPointOfView(aPoint); -myView.ScaleView(View3D.YAxis,10.0); -myView.ScaleView(View3D.XAxis,3.0); +myView.ScaleView(VISU.View3D.YAxis,10.0); +myView.ScaleView(VISU.View3D.XAxis,3.0); aColor = SALOMEDS.Color(0.0,0.3,1.0) myView.SetBackground(aColor); myView.Update(); @@ -53,7 +74,7 @@ myView.SaveViewParams('BBB'); aColor = SALOMEDS.Color(1.0,1.0,1.0) myView.SetBackground(aColor); -myView.ScaleView(View3D.ZAxis,0.5); +myView.ScaleView(VISU.View3D.ZAxis,0.5); myView.SaveViewParams('CCC'); myView.RestoreViewParams('AAA'); -- 2.39.2