From cafa7b43bd370e22789fd5fb37af62caf1705fe5 Mon Sep 17 00:00:00 2001 From: nri Date: Thu, 10 Jul 2003 14:20:39 +0000 Subject: [PATCH] NRI : Merge from V1_2. --- idl/VISU_Gen.idl | 284 +++-- resources/VISU_en.xml | 6 +- resources/VISU_fr.xml | 4 +- resources/Visu_en.xml | 109 -- resources/Visu_fr.xml | 103 -- src/OBJECT/Makefile.in | 35 +- src/OBJECT/VISU_Actor.cxx | 412 +++++-- src/OBJECT/VISU_Actor.h | 207 ++-- src/VISUGUI/VISU_icons.po | 32 +- src/VISUGUI/VISU_msg_en.po | 103 +- src/VISUGUI/VisuGUI_icons.po | 58 - src/VISUGUI/VisuGUI_msg_en.po | 347 ------ src/VISU_I/Makefile.in | 23 +- src/VISU_I/VISUConfig.hh | 29 +- src/VISU_I/VISU_Convertor.cxx | 523 +++++++-- 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 | 388 ++++++- src/VISU_I/VISU_CorbaMedConvertor.hxx | 46 +- 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 | 305 ++++-- src/VISU_I/VISU_Gen_i.hh | 36 +- src/VISU_I/VISU_MedConvertor.cxx | 363 ++++--- src/VISU_I/VISU_MedConvertor.hxx | 12 +- src/VISU_I/VISU_PrsObject_i.cc | 1390 +++++++++++++++++------- src/VISU_I/VISU_PrsObject_i.hh | 208 +++- src/VISU_I/VISU_Result_i.cc | 375 ++++--- src/VISU_I/VISU_Result_i.hh | 16 +- 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 | 703 ++++++------ src/VISU_I/VISU_ViewManager_i.hh | 47 +- src/VISU_SWIG/Makefile.in | 44 +- src/VISU_SWIG/batchmode_visu.py | 84 +- 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_med.py | 11 +- src/VISU_SWIG/visu_table.py | 23 +- src/VISU_SWIG/visu_view.py | 18 +- src/VISU_SWIG/visu_view3d.py | 65 +- 50 files changed, 5000 insertions(+), 2803 deletions(-) delete mode 100644 resources/Visu_en.xml delete mode 100644 resources/Visu_fr.xml delete mode 100644 src/VISUGUI/VisuGUI_icons.po delete mode 100644 src/VISUGUI/VisuGUI_msg_en.po diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index f0f798c4..b04df244 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -1,9 +1,9 @@ -// File : VISU_Gen.idl -// Created : -// Author : Alexey Petrov -// Project : SALOME -// Copyright : OPEN CASCADE -// $HEADERS: +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VISU_Gen.idl +// Author : Alexey Petrov /*! \file VISU_Gen.idl This file conatins a set of interfaces of %VISU module. This module will provide various forms of data visualization in %SALOME application. @@ -28,7 +28,6 @@ */ module VISU { //------------------------------------------------------- - const string VISU__doc__ = "Module VISU provides various forms of data visualization in SALOME application.\nThese forms include data tables, XY plots,\n3d representations and combination of these forms."; typedef string IdType; enum Scaling{ LINEAR, LOGARITHMIC}; enum Entity{ NODE, EDGE, FACE, CELL}; @@ -37,7 +36,7 @@ module VISU { */ enum VISUType{ TNONE, TCURVE, TTABLE, TCONTAINER, TMESH, TSCALARMAP, - TISOSURFACE, TDEFORMEDSHAPE, TCUTPLANES, TVECTORS, TSTREAMLINES, + TISOSURFACE, TDEFORMEDSHAPE, TCUTPLANES, TCUTLINES, TVECTORS, TSTREAMLINES, TVISUGEN, TVIEWMANAGER, TRESULT, TXYPLOT, TTABLEVIEW, TVIEW3D, TENTITY, TFAMILY, TGROUP, TFIELD, TTIMESTAMP, @@ -47,12 +46,10 @@ module VISU { Returns ID of the object. */ IdType GetID(); - const string GetID__doc__ = "Returns ID of the object."; /*! Returns the type of the presentable object */ VISUType GetType(); - const string GetType__doc__ = "Returns the type of the module interface"; }; /*! \brief Presentable object interface @@ -60,7 +57,6 @@ Returns the type of the presentable object */ interface PrsObject : Base{ }; - const string PrsObject__doc__ = "It is the root class of all presentable objects."; //------------------------------------------------------- /*! \brief %Table representation interface @@ -71,12 +67,10 @@ Presentation parameters of the %Table view. Sets the title of the table. */ void SetTitle(in string theTitle); - const string SetTitle__doc__ = "Sets the title of the table."; /*! Gets the title of the table. */ string GetTitle(); - const string GetTitle__doc__ = "Gets the title of the table."; /*! This enumeration contains a set of elements defining the orientation of the table. */ @@ -87,24 +81,19 @@ Gets the title of the table. Sets orientation of the table. */ void SetOrientation(in Orientation theOrientation); - const string SetOrientation__doc__ = "Sets orientation of the table."; /*! Gets orientation of the table. */ Orientation GetOrientation(); - const string GetOrientation__doc__ = "Gets orientation of the table."; /*! Gets the number of rows of the table */ long GetNbRows(); - const string GetNbRows__doc__ = "Gets the number of rows of the table."; /*! Gets the number of columns of the table */ long GetNbColumns(); - const string GetNbColumns__doc__ ="Gets the number of columns of the table."; }; - const string Table__doc__ = "The Table interface contains presentation\nparameters of the %Table view."; //------------------------------------------------------- /*! \brief Interface of curve representation. @@ -116,22 +105,18 @@ It can be used for presentation of a set of curves using a combined presentation Sets the title of the curve. */ void SetTitle(in string theTitle); - const string SetTitle__doc__ = "Sets the title of the curve."; /*! Gets the title of the curve. */ string GetTitle(); - const string GetTitle__doc__ = "Gets the title of the curve."; /*! Sets the color of the curve. */ void SetColor(in SALOMEDS::Color theColor); - const string SetColor__doc__ = "Sets the color of the curve."; /*! Gets the color of the curve. */ SALOMEDS::Color GetColor(); - const string GetColor__doc__ = "Gets the color of the curve."; /*! This enumeration contains a set of elements defining the representation type of markers (data points) with help of which the curve is constructed on the graphics. @@ -144,13 +129,11 @@ Sets the representation type of markers (data points) with help of which the curve is constructed on the graphics. */ void SetMarker(in MarkerType theType); - const string SetMarker__doc__ = "Sets the representation type of markers\n(data points) with help of which\nthe curve is constructed on the graphics."; /*! Gets the representation type of markers (data points) with help of which the curve is constructed on the graphics. */ MarkerType GetMarker(); - const string GetMarker__doc__ = "Gets the representation type of markers\n(data points) with help of which the\ncurve is constructed on the graphics."; /*! This enumeration contains a set of elements defining the type of representation of curve lines on the graphics. @@ -160,20 +143,16 @@ which the curve is constructed on the graphics. Sets the type of representation of curve lines on the graphics. */ void SetLine(in LineType theType, in long theLineWidth); - const string SetLine__doc__ = "Sets the type of representation of curve\nlines on the graphics."; /*! Gets the type of representation of curve lines on the graphics. */ LineType GetLine(); - const string GetLine__doc__ = "Gets the type of representation of curve\nlines on the graphics."; /*! Gets the width of the curve line. */ long GetLineWidth(); - const string GetLineWidth__doc__ = "Gets the width of the curve line."; }; - const string Curve__doc__ = "The curve representation interface manages\npresentation parameters of one curve. It can be used\nfor presentation of a set of curves\nusing a combined presentation."; //------------------------------------------------------- /*! \brief The %Container presentable object interface This interface contains a set of methods used for management of a group of curves @@ -184,26 +163,24 @@ which are stored in the container. Adds a curve into the container. */ void AddCurve(in Curve theCurve); - const string AddCurve__doc__ = "Adds a curve into the container."; /*! Removes a curve from the container. */ void RemoveCurve(in Curve theCurve); - const string RemoveCurve__doc__ = "Removes a curve from the container."; /*! Gets the number of curves which are stored in the container. */ long GetNbCurves(); - const string GetNbCurves__doc__ = "Gets the number of curves which\nare stored in the container."; /*! Removes all curves from the container. */ void Clear(); - const string Clear__doc__ = "Removes all curves from the container."; }; - const string Container__doc__ = "The Container presentable object\ninterface contains a set of methods\nused for management of a group of curves which\nare stored in the container."; //------------------------------------------------------- + interface Prs3d : PrsObject{ + void Destroy(); + }; /*! This enumeration contains a set of elements defining the type of representation of the mesh. @@ -218,82 +195,68 @@ Removes all curves from the container. This interface manages the presentation parameters of the mesh. */ - interface Mesh : PrsObject{ + interface Mesh : Prs3d{ /*! Sets the color of mesh cells. */ void SetCellColor(in SALOMEDS::Color theColor); - const string SetCellColor__doc__ = "Sets the color of mesh cells."; /*! Gets the color of mesh cells. */ SALOMEDS::Color GetCellColor(); - const string GetCellColor__doc__ = "Gets the color of mesh cells."; /*! Sets the color of mesh nodes. */ void SetNodeColor(in SALOMEDS::Color theColor); - const string SetNodeColor__doc__ = "Sets the color of mesh nodes."; /*! Gets the color of mesh nodes. */ SALOMEDS::Color GetNodeColor(); - const string GetNodeColor__doc__ = "Gets the color of mesh nodes."; /*! Sets the color of mesh links. */ void SetLinkColor(in SALOMEDS::Color theColor); - const string SetLinkColor__doc__ = "Sets the color of mesh links."; /*! Gets the color of mesh links. */ SALOMEDS::Color GetLinkColor(); - const string GetLinkColor__doc__ = "Gets the color of mesh links."; /*! Sets the type of representation of the mesh. */ void SetPresentationType(in PresentationType theType); - const string SetPresentationType__doc__ = "Sets the type of representation of the mesh."; /*! Gets the type of representation of the mesh. */ PresentationType GetPresentationType(); - const string GetPresentationType__doc__ = "Gets the type of representation of the mesh."; }; - const string Mesh__doc__ = "The Mesh interface manages the presentation parameters\nof the mesh."; //------------------------------------------------------- /*! \brief Interface of the %Scalar Map presentation This interface contains presentation parameters of the ScalarMap presentation */ - interface ScalarMap : PrsObject{ + interface ScalarMap : Prs3d{ void SetScalarMode(in long theScaling); long GetScalarMode(); void SetScaling(in Scaling theScaling); - const string SetScaling__doc__ = "Sets the type of scaling of the values\nreflected by this presentation."; /*! Gets the type of scaling of the values reflected by this presentation. */ Scaling GetScaling(); - const string GetScaling__doc__ = "Gets the type of scaling of the values\nreflected by this presentation."; /*! Sets scalar range - min and max boundaries of this presentable object. \param theMin Min boundary of this presentable object. \param theMax Max boundary of this presentable object. */ void SetRange(in double theMin, in double theMax); - const string SetRange__doc__ = "Sets scalar range - min and max boundaries\nof this presentable object."; /*! Gets the min boundary of this presentable object. */ double GetMin(); - const string GetMin__doc__ = "Gets the min boundary of this presentable object."; /*! Gets the max boundary of this presentable object. */ double GetMax(); - const string GetMax__doc__ = "Gets the max boundary of this presentable object."; /*! %Orientation of this presentable object. */ enum Orientation{ @@ -304,12 +267,10 @@ Sets scalar range - min and max boundaries of this presentable object. Sets the type of orientation of this presentable object. */ void SetOrientation(in Orientation theOrientation); - const string SetOrientation__doc__ = "Sets the type of orientation of this presentable object."; /*! Gets the type of orientation of this presentable object. */ Orientation GetOrientation(); - const string GetOrientation__doc__ = "Gets the type of orientation of this presentable object."; /*! \brief Position of this presentable object. @@ -318,17 +279,14 @@ Sets the position of this presentable object origin on the screen. \param Y Vertical position. The value can be between 0 and 1. */ void SetPosition(in double X, in double Y); - const string SetPosition__doc__ = "Sets the position of this presentable object\norigin on the screen."; /*! Gets horizontal position of this presentable object origin. */ double GetPosX(); - const string GetPosX__doc__ = "Gets horizontal position of this presentable object origin."; /*! Gets vertical position of this presentable object origin. */ double GetPosY(); - const string GetPosY__doc__ = "Gets vertical position of this presentable object origin."; /*! \brief Size of this presentable object. Sets the size of the scalar bar. @@ -336,52 +294,41 @@ Sets the size of the scalar bar. \param theHeight Height of this presentable object. The value can be between 0 and 1. */ void SetSize(in double theWidth, in double theHeight); - const string SetSize__doc__ = "Sets the size of the scalar bar."; /*! Gets the width of this presentable object. */ double GetWidth(); - const string GetWidth__doc__ = "Gets the width of this presentable object."; /*! Gets the height of this presentable object. */ double GetHeight(); - const string GetHeight__doc__ = "Gets the height of this presentable object."; /*! Sets the number of colors which will be used for presentation of this presentable object. */ void SetNbColors(in long theNbColors); - const string SetNbColors__doc__ = "Sets the number of colors which will be\nused for presentation of this presentable object."; /*! Gets the number of colors which will be used for presentation of this presentable object. */ long GetNbColors(); - const string GetNbColors__doc__ = "Gets the number of colors which will be\nused for presentation of this presentable object."; /*! Sets the number of labels which will be used for indication of the gradation of this presentable object. */ void SetLabels(in long theNbLabels); - const string SetLabels__doc__ = "Sets the number of labels which will be used\nfor indication of the gradation of this presentable object."; /*! Gets the number of labels which will be used for indication of the gradation of this presentable object. */ long GetLabels(); - const string GetLabels__doc__ = "Gets the number of labels which will be used\nfor indication of the gradation of this presentable object."; - /*! Sets the title of this presentable object. For scalar bar by default - the name of the selected result is used. */ void SetTitle(in string theName); - const string SetTitle__doc__ = "Sets the title of this presentable object. For scalar bar by default - the name of the selected result is used."; /*! Gets the title of this presentable object. */ string GetTitle(); - const string GetTitle__doc__ = "Gets the title of this presentable object."; }; - const string ScalarMap__doc__ = "The scalarmap interface contains presentation\nparameters of the ScalarMap presentation."; //------------------------------------------------------- /*! \brief Deformed shape presentation interface @@ -392,14 +339,11 @@ Presentation parameters of the deformed shape presentation. Sets the scale of the presentatable object. */ void SetScale(in double theScale); - const string SetScale__doc__ = "Sets the scale of the deformed shape."; /*! Gets the scale of the presentatable object. */ double GetScale(); - const string GetScale__doc__ = "Gets the scale of the deformed shape"; }; - const string DeformedShape__doc__ = "The deformed shape interface contains\nthe presentation parameters of the deformed shape."; //------------------------------------------------------- /*! \brief Cut planes interface @@ -415,56 +359,100 @@ Presentation parameters of Cut planes presentation. Sets the type of orientation in 3D space of cut planes presentation. */ void SetOrientationType(in Orientation theNb); - const string SetOrientationType__doc__ = "Sets the type of orientation in 3D\nspace of cut planes presentation."; /*! Gets the type of orientation in 3D space of cut planes presentation. */ Orientation GetOrientationType(); - const string GetOrientationType__doc__ = "Gets the type of orientation in 3D\nspace of cut planes presentation."; + void SetDisplacement(in double theDisp); + double GetDisplacement(); /*! Sets the number of cut planes. */ void SetNbPlanes(in long theNb); - const string SetNbPlanes__doc__ = "Sets the number of cut planes."; /*! Gets the number of cut planes. */ long GetNbPlanes(); - const string GetNbPlanes__doc__ = "Gets the number of cut planes."; /*! Rotation around X-axis. Sets rotation angle of the cut plane presentation. */ void SetRotateX(in double theAngle); - const string SetRotateX__doc__ = "Rotation around X-axis.\nSets rotation angle of the cut plane presentation."; /*! Rotation around X-axis. Gets rotation angle of the cut plane presentation. */ double GetRotateX(); - const string GetRotateX__doc__ = "Rotation around X-axis.\nGets rotation angle of the cut plane presentation."; /*! Rotation around Y-axis. Sets rotation angle of the cut plane presentation. */ void SetRotateY(in double theAngle); - const string SetRotateY__doc__ = "Rotation around Y-axis.\nSets rotation angle of the cut plane presentation."; /*! Rotation around Y-axis. Sets rotation angle of the cut plane presentation. */ double GetRotateY(); - const string GetRotateY__doc__ = "Rotation around Y-axis.\nGets rotation angle of the cut plane presentation."; }; - const string CutPlanes__doc__ = "The cut planes interface contains\nthe presentation parameters of cut planes presentation."; //------------------------------------------------------- /*! \brief Interface of the stream lines representation This interface contains presentation parameters of stream lines presentations. */ +/*! \brief Cut lines interface + +Presentation parameters of Cut lines presentation. +*/ + interface CutLines : ScalarMap{ + + void SetOrientationType(in CutPlanes::Orientation theNb); + void SetOrientationType2(in CutPlanes::Orientation theNb); + + CutPlanes::Orientation GetOrientationType(); + CutPlanes::Orientation GetOrientationType2(); + + void SetDisplacement(in double theDisp); + void SetDisplacement2(in double theDisp); + + double GetDisplacement(); + double GetDisplacement2(); + + void SetNbLines(in long theNb); + long GetNbLines(); + + void SetRotateX(in double theAngle); + void SetRotateX2(in double theAngle); + + double GetRotateX(); + double GetRotateX2(); + + void SetRotateY(in double theAngle); + void SetRotateY2(in double theAngle); + + double GetRotateY(); + double GetRotateY2(); + }; + interface StreamLines : DeformedShape{ enum Direction{ FORWARD, BACKWARD, BOTH }; + + void SetDirection(in Direction theDirection); + Direction GetDirection(); + + void SetStepLength(in double theStep); + double GetStepLength(); + + void SetPropagationTime(in double theTime); + double GetPropagationTime(); + + void SetIntegrationStep(in double theStep); + double GetIntegrationStep(); + + void SetSource(in Prs3d thePrs3d); + Prs3d GetSource(); + + void SetUsedPoints(in double thePercents); + double GetUsedPoints(); }; - const string StreamLines__doc__ = ""; /*! \brief Interface of the isometric surface representation @@ -477,14 +465,11 @@ Sets rotation angle of the cut plane presentation. Sets the number of isometric surfaces. */ void SetNbSurfaces(in long theNb); - const string SetNbSurfaces__doc__ = "Sets the number of isometric surfaces."; /*! Gets the number of isometric surfaces */ long GetNbSurfaces(); - const string GetNbSurfaces__doc__ = "Gets the number of isometric surfaces."; }; - const string IsoSurfaces__doc__ = "The isometric surface interface contains\nthe presentation parameters of the isometric surface presentations."; //------------------------------------------------------- /*! \brief Interface of the vector presentation. @@ -495,12 +480,10 @@ This interface contains presentation parameters of the vector. Sets the width of the line of the vector. */ void SetLineWidth(in double theWidth); - const string SetLineWidth__doc__ = "Sets the width of the line of the vector."; /*! Gets the width of the line of the vector. */ double GetLineWidth(); - const string GetLineWidth__doc__ = "Gets the width of the line of the vector."; /*! This enumeration contains a set of elements defining the type of representation of the vector head. */ @@ -513,12 +496,10 @@ Gets the width of the line of the vector. Sets the type of representation of the vector head. */ void SetGlyphType(in GlyphType theType); - const string SetGlyphType__doc__ = "Sets the type of representation of the vector head."; /*! Gets the type of representation of the vector head. */ GlyphType GetGlyphType(); - const string GetGlyphType__doc__ = "Gets the type of representation of the vector head."; /*! This enumeration contains a set of elements defining the position of the vector head. */ @@ -531,15 +512,59 @@ Gets the type of representation of the vector head. Sets the position of the vector head. */ void SetGlyphPos(in GlyphPos thePos); - const string SetGlyphPos__doc__ = "Sets the position of the vector head."; /*! Gets the position of the vector head. */ GlyphPos GetGlyphPos(); - const string GetGlyphPos__doc__ = "Gets the position of the vector head."; }; - const string Vectors__doc__ = "Interface of the vector presentation contains\nthe presentation parameters of the vector."; //------------------------------------------------------- + interface Animation : Base{ + void addField(in SALOMEDS::SObject theObject); + + void generatePresentations(in long theFieldNum); + boolean generateFrames(); + void clearView(); + + void startAnimation(); + void stopAnimation(); + + void nextFrame(); + void prevFrame(); + void firstFrame(); + void lastFrame(); + void gotoFrame(in long theFrame); + + long getNbFields(); + long getNbFrames(); + boolean isRunning(); + long getCurrentFrame(); + + ScalarMap getPresentation(in long theField, in long theFrame); + + void setPresentationType(in long theFieldNum, in VISUType theType); + VISUType getPresentationType(in long theFieldNum); + + void setSpeed(in long theSpeed); + long getSpeed(); + + boolean isProportional(); + + void setAnimationRange(in double theMin, in double theMax); + double getMinRange(); + double getMaxRange(); + boolean isRangeDefined(); + + void dumpTo(in string thePath); + + boolean isCycling(); + + double getMinTime(); + double getMaxTime(); + + void setProportional(in boolean theProp); + void setCycling(in boolean theCycle); + }; + /*! \brief Interface %Result This interface serves for inner representation of data generated in other sources. (MED object or file) @@ -547,9 +572,9 @@ This data is needed for further construction of graphical presentations. */ interface Result : Base { }; - const string Result__doc__ = "This interface serves for inner representation\nof data generated in other sources. (MED object or file) This data is needed for further construction of graphical presentations."; //------------------------------------------------------- interface ViewManager; + interface View3D; /*! \brief %VISU_Gen interface This is the main interface of %VISU component. It is necessary for creation of @@ -564,7 +589,6 @@ provided by %ViewManager. post-processing presentations. */ ViewManager GetViewManager(); - const string GetViewManager__doc__ = "Gets the ViewManager which is used for creation\nof post-processing presentations."; /*! Imports tables from a file and create TableAttribute in Sudy @@ -574,28 +598,17 @@ Imports tables from a file and create TableAttribute in Sudy Imports data from a file. */ Result ImportFile(in string theFileName); - const string ImportFile__doc__ = "Imports data from a file."; -/*! -Imports data from a %MED object field. -*/ - Result ImportMed(in SALOME_MED::FIELD theField); - const string ImportMed__doc__ = "Imports data from a MED object field."; /*! -Imports data from a %MED object mesh. +Imports data from a %MED object. */ - Result ImportMedMesh(in SALOME_MED::MESH theMesh); - const string ImportMedMesh__doc__ = "Imports data from a MED object mesh."; - + Result ImportMed(in SALOMEDS::SObject theMedSObject); /*! -Imports data from a %MED object SUPPORT. +Imports data from a %MED field. */ - Result ImportMedSupport(in SALOME_MED::SUPPORT theSupport); - const string ImportMedSupport__doc__ = "Imports data from a MED support."; - + Result ImportMedField(in SALOME_MED::FIELD theField); /*! Creates a %Mesh on the basis of the data generated in other sources (MED object or file). */ - const string CreateMesh__doc__ = "Creates a Mesh on the basis of the data\ngenerated in other sources (MED object or file)."; Mesh MeshOnEntity(in Result theResult, in string theMeshName, in Entity theEntity); Mesh FamilyMeshOnEntity(in Result theResult, in string theMeshName, in Entity theEntity, in string theFamilyName); Mesh GroupMesh(in Result theResult, in string theMeshName, in string theGroupName); @@ -608,7 +621,6 @@ Creates a scalar bar presentation. \param theIteration Number of iteration on the field */ ScalarMap ScalarMapOnField(in Result theResult, in string theMeshName, in Entity theEntity, in string theFieldName, in double theIteration); - const string CreateScalarMap__doc__ = "Creates a scalar bar presentation."; /*! Creates a deformed shape presentation. \param theResult Data generated in other sources. (MED object or file) @@ -618,7 +630,6 @@ Creates a deformed shape presentation. \param theIteration Number of iteration on the field */ DeformedShape DeformedShapeOnField(in Result theResult, in string theMeshName, in Entity theEntity, in string theFieldName, in double theIteration); - const string CreateDeformedShape__doc__ = "Creates a deformed shape presentation."; /*! Creates a vector presentation. \param theResult Data generated in other sources. (MED object or file) @@ -629,7 +640,6 @@ Creates a vector presentation. */ Vectors VectorsOnField(in Result theResult, in string theMeshName, in Entity theEntity, in string theFieldName, in double theIteration); - const string CreateVectors__doc__ = "Creates a vector presentation."; /*! Creates an iso surface presentation. \param theResult Data generated in other sources. (MED object or file) @@ -640,7 +650,6 @@ Creates an iso surface presentation. */ IsoSurfaces IsoSurfacesOnField(in Result theResult, in string theMeshName, in Entity theEntity, in string theFieldName, in double theIteration); - const string CreateIsoSurfaces__doc__ = "Creates an iso surface presentation."; /*! Creates an stream lines presentation. \param theResult Data generated in other sources. (MED object or file) @@ -650,7 +659,6 @@ Creates an stream lines presentation. \param theIteration Number of iteration on the field */ StreamLines StreamLinesOnField(in Result theResult, in string theMeshName, in Entity theEntity, in string theFieldName, in double theIteration); - const string CreateStreamLines__doc__ = "Creates an stream lines presentation."; /*! Creates a presentation of cut planes. @@ -661,12 +669,21 @@ Creates a presentation of cut planes. \param theIteration Number of iteration on the field */ CutPlanes CutPlanesOnField(in Result theResult, in string theMeshName, in Entity theEntity, in string theFieldName, in double theIteration); - const string CreateCutPlanes__doc__ = "Creates a presentation of cut planes."; + +/*! +Creates a presentation of cut lines. +\param theResult Data generated in other sources. (MED object or file) +\param theMeshName One of the meshes presented in MED file +\param theEntity Type of entity where the field is defined +\param theFieldName Group of data attributed to the %MESH. The data can be scalar or vector. +\param theIteration Number of iteration on the field +*/ + CutLines CutLinesOnField(in Result theResult, in string theMeshName, in Entity theEntity, in string theFieldName, in double theIteration); + /*! Creates a table presentation. */ Table CreateTable(in string theTableEntry); - const string CreateTable__doc__ = "Creates a table prasentation containing the data."; /*! Creates a curve on the basis of points, whose values are taken from the table. \param theTable Table containing the data for construction of curves. @@ -674,14 +691,13 @@ Creates a curve on the basis of points, whose values are taken from the table. \param VRow Index of the row in the table: ordinate of the point. */ Curve CreateCurve(in Table theTable, in long theHRow, in long theVRow); - const string CreateCurve__doc__ = "Creates a curve on the basis of points, whose values\nare taken from the table."; /*! Creates a presentation form containing an array of references to the curves. */ Container CreateContainer(); - const string CreateContainer__doc__ = "Creates a presentation form containing an array\nof references to the curves."; + + Animation CreateAnimation(in View3D theView3d); }; - const string VISU_Gen__doc__ = "This is the main interface of the VISU component. It is\nnecessary for creation of post-processing presentations from given result and table object reference, using the views provided by the viewmanager."; /*! \brief %View interface Contains a set of methods used by the %View frame, which can be one of @@ -693,77 +709,62 @@ Creates a presentation form containing an array of references to the curves. Sets the title of the %View frame. */ void SetTitle(in string theTitle); - const string SetTitle__doc__ = "Sets the title of the view frame."; /*! Gets the title of the %View frame. */ string GetTitle(); - const string GetTitle__doc__ = "Gets the title of the view frame."; /*! Sets background color of the %View frame. */ void SetBackground(in SALOMEDS::Color theColor); - const string SetBackground__doc__ = "Sets background color of the view frame."; /*! Gets background color of the %View frame. */ SALOMEDS::Color GetBackground(); - const string GetBackground__doc__ = "Gets background color of the view frame."; /*! Minimizes to the task bar or to the bottom of the Desktop the %View frame. */ void Minimize(); - const string Minimize__doc__ = "Minimizes to the task bar or to the bottom of the\nDesktop the view frame."; /*! Restores the %View frame. */ void Restore(); - const string Restore__doc__ = "Restores the view frame."; /*! Maximizes the %View frame. */ void Maximize(); - const string Maximize__doc__ = "Maximizes the view frame."; /*! Removes all presentations (presentable objects) from the %view. */ void EraseAll(); - const string EraseAll__doc__ = "Removes all presentations (presentable objects) from the view."; /*! Displays all presentations (presentable objects) in the %view. */ void DisplayAll(); - const string DisplayAll__doc__ = "Displays all presentations (presentable objects) in the view."; /*! Removes a definite presentation (presentable object) from the %view. */ void Erase(in PrsObject thePrsObj); - const string Erase__doc__ = "Removes a definite presentation (presentable object) from the view."; /*! Displays a definite presentation (presentable object) in the %view. */ void Display(in PrsObject thePrsObj); - const string Display__doc__ = "Displays a definite presentation (presentable object) in the view."; /*! Allows to display only a definite presentation (presentable object) in the %view. All other presentations are removed from the %view. */ void DisplayOnly(in PrsObject thePrsObj); - const string DisplayOnly__doc__ = "Allows to display only a definite presentation\n(presentable object) in the view. All other presentations are\nremoved from the view."; /*! Updates the view. */ void Update(); - const string Update__doc__ = "Updates the view."; /*! Saves the view. */ boolean SavePicture(in string theFileName); - const string SavePicture__doc__ = "Saves the view contents into image file."; }; - const string View__doc__ = "Contains a set of methods used by the view frame,\nwhich can be one of the following types:\n3d, table, XY plot."; //------------------------------------------------------- /*! \brief 3D view interface @@ -790,84 +791,69 @@ Data type defining coordinates in 3D space. */ void FitAll(); - const string FitAll__doc__ = "Makes all presentations, which are currently present in the\nview, completely visible."; /*! Sets a predefined point of view (FRONT, BACK, LEFT, RIGHT, TOP, BOTTOM). (In other words it means a predefined position of the camera in 3D space with respect to the object which is represented.) */ void SetView(in ViewType theType); - const string SetView__doc__ = "Sets a predefined point of view\n(FRONT, BACK, LEFT, RIGHT, TOP, BOTTOM)."; /*! Sets the position of the camera in 3D space. This point is used as the first point of the vector defining the view direction of the camera. */ void SetPointOfView(in XYZ theCoord); - const string SetPointOfView__doc__ = "Sets the position of the camera in 3D space."; /*! Gets the position of the camera in 3D space.This point is used as the first point of the vector defining the view direction of the camera. */ XYZ GetPointOfView(); - const string GetPointOfView__doc__ = "Gets the position of the camera in 3D space."; /*! Sets the vertical line of the camera in 3D space. */ void SetViewUp(in XYZ theDir); - const string SetViewUp__doc__ = "Sets the vertical line of the camera in 3D space."; /*! Gets the vertical line of the camera in 3D space. */ XYZ GetViewUp(); - const string GetViewUp__doc__ = "Gets the vertical line of the camera in 3D space."; /*! Sets the point of sight of the camera. This point is used as the second point of the vector defining the view direction of the camera. */ void SetFocalPoint(in XYZ theDir); - const string SetFocalPoint__doc__ = "Sets the point of sight of the camera."; /*! Gets the point of sight of the camera. This point is used as the second point of the vector defining the view direction of the camera. */ XYZ GetFocalPoint(); - const string GetFocalPoint__doc__ = "Gets the point of sight of the camera."; /*! Zooming of the presentable object. Sets the scale. */ void SetParallelScale(in double theScale); - const string SetParallelScale__doc__ = "Zooming of the presentable object. Sets the scale."; /*! Zooming of the presentable object. Gets the scale. */ double GetParallelScale(); - const string GetParallelScale__doc__ = "Zooming of the presentable object. Gets the scale."; /*! Scaling of the view along a definite axis. \param theAxis The axis of the scaling \param theParam The coefficient of the scaling */ void ScaleView(in Axis theAxis, in double theParam); - const string ScaleView__doc__ = "Scaling of the view along a definite axis and with a\ndefinite coefficient of the scaling."; /*! Removes the scaling of the view. */ void RemoveScale(); - const string RemoveScale__doc__ = "Removes the scaling of the view."; /*! Returns True if the view parameters have been created, False if the parameters have been modified. */ boolean SaveViewParams(in string theName); - const string SaveViewParams__doc__ = "Returns True if the view parameters have been created,\nFalse if the parameters have been modified."; /*! Returns True if the view parameters have been found and applied to the view, False if the parameters with this name don't exist. */ boolean RestoreViewParams(in string theName); - const string RestoreViewParams__doc__ = "Returns True if the view parameters have been found and\napplied to the view, False if the parameters with this name don't exist."; }; - const string View3D__doc__ = "This interface contains a set of methods necessary for representation\nof objects in 3D space."; //------------------------------------------------------- @@ -922,27 +908,19 @@ False if the parameters with this name don't exist. */ View GetCurrentView(); - const string GetCurrentView__doc__ = "Getting an active View Frame.\nReturns an object reference to the active view frame."; /*! \brief Creation of a 3d %View. Returns an object reference to the newly created 3d %View. */ View3D Create3DView(); - const string Create3DView__doc__ = "Creation of a 3d view.\nReturns an object reference to the newly created 3d view."; TableView CreateTableView(in Table theTable); - const string CreateTableView__doc__ = "Creation of a table view.\nReturns an object reference to the newly created table view."; XYPlot CreateXYPlot(); - const string CreateXYPlot__doc__ = "Creation of a 2d view.\nReturns an object reference to the newly created XYPlot view."; void Destroy(in View theView); - const string Destroy__doc__ = "Destroying of the view"; - - }; - const string ViewManager__doc__ = "The ViewManager interface is necessary for work\nwith view windows (creation and deletion)."; }; #endif diff --git a/resources/VISU_en.xml b/resources/VISU_en.xml index 76f0ffce..4f3216ba 100644 --- a/resources/VISU_en.xml +++ b/resources/VISU_en.xml @@ -18,7 +18,7 @@ - + @@ -29,6 +29,7 @@ + @@ -86,12 +87,13 @@ - + + diff --git a/resources/VISU_fr.xml b/resources/VISU_fr.xml index 90faa06e..7ff81e22 100644 --- a/resources/VISU_fr.xml +++ b/resources/VISU_fr.xml @@ -16,7 +16,7 @@ - + @@ -83,7 +83,7 @@ - + diff --git a/resources/Visu_en.xml b/resources/Visu_en.xml deleted file mode 100644 index 4f3216ba..00000000 --- a/resources/Visu_en.xml +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - - - title="Visu component" - date="24/07/2001" - author="Laurent CORNABE" - appId="Visu for Salome" > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/Visu_fr.xml b/resources/Visu_fr.xml deleted file mode 100644 index 7ff81e22..00000000 --- a/resources/Visu_fr.xml +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - title="Visu component" - date="24/07/2001" - author="Laurent CORNABE" - appId="Visu for Salome" > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/OBJECT/Makefile.in b/src/OBJECT/Makefile.in index 54a6cbcf..66d61f25 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=../.. 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 = @@ -23,7 +48,7 @@ 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) \ +LDFLAGS+=$(QT_MT_LIBS) $(VTK_LIBS) $(OGL_LIBS) $(PYTHON_LIBS) \ -lSalomeObject -L${KERNEL_ROOT_DIR}/lib/salome %_moc.cxx: %.h diff --git a/src/OBJECT/VISU_Actor.cxx b/src/OBJECT/VISU_Actor.cxx index 1d5da42d..814ef814 100644 --- a/src/OBJECT/VISU_Actor.cxx +++ b/src/OBJECT/VISU_Actor.cxx @@ -1,80 +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 = vtkActor::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() -{ - 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); } @@ -82,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 437bb776..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; - vtkActor* 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/VISUGUI/VISU_icons.po b/src/VISUGUI/VISU_icons.po index 926d6c6f..4422d48d 100644 --- a/src/VISUGUI/VISU_icons.po +++ b/src/VISUGUI/VISU_icons.po @@ -1,6 +1,29 @@ -# This is a Qt message file in .po format. Each msgid starts with -# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" -# would be translated to "Pub", not "Foo::Pub". +# 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" @@ -28,5 +51,8 @@ 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/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po index 8df1a336..7dfa1d8a 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -1,7 +1,29 @@ -# This is a Qt message file in .po format. Each msgid starts with -# a scope. This scope should *NOT* be translated - eg. translating -# from French to English, "Foo::Bar" would be translated to "Pub", -# not "Foo::Pub". +# 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" @@ -16,6 +38,9 @@ msgstr "OK" msgid "VISU_WARNING" msgstr "Visu Warning" +msgid "WARNING" +msgstr "Warning" + #: isodlg.cxx:20 msgid "::VISU_MEN_ISOSURFDLG" msgstr "Iso Surface" @@ -250,3 +275,73 @@ 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/VISUGUI/VisuGUI_icons.po b/src/VISUGUI/VisuGUI_icons.po deleted file mode 100644 index 4422d48d..00000000 --- a/src/VISUGUI/VisuGUI_icons.po +++ /dev/null @@ -1,58 +0,0 @@ -# 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 deleted file mode 100644 index 7dfa1d8a..00000000 --- a/src/VISUGUI/VisuGUI_msg_en.po +++ /dev/null @@ -1,347 +0,0 @@ -# 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..3de2fe60 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=../.. 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,12 +39,11 @@ 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 \ +LDFLAGS += $(QT_MT_LIBS) $(VTK_LIBS) $(QWT_LIBS) -lSalomeNS -lSalomeDS \ -lSalomeContainer -lOpUtil -lSalomeGUI -lVTKViewer -lVisuObject \ -L${KERNEL_ROOT_DIR}/lib/salome diff --git a/src/VISU_I/VISUConfig.hh b/src/VISU_I/VISUConfig.hh index cb14bd17..c4810630 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 @@ -27,7 +30,7 @@ using namespace std; #include "utilities.h" #include -#include +#include namespace VISU{ //=========================================================================== @@ -37,7 +40,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; @@ -47,15 +50,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: const char* ToString(); virtual const char* GetComment() const = 0; @@ -71,9 +74,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); }; //=========================================================================== CORBA::ORB_var GetORB(); diff --git a/src/VISU_I/VISU_Convertor.cxx b/src/VISU_I/VISU_Convertor.cxx index 138d3cff..6f66024f 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 @@ -147,7 +148,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(); @@ -171,6 +172,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)); @@ -249,19 +251,118 @@ int main(int argc, char** argv){ }else parseFile(argv[1]); } - } - /* - aCon->ToString(); - aCon->ToFile((aDir+"a.med").c_str()); - aCon.reset(CreateConvertor((aDir+"a.med").c_str())); - aCon->ToFile((aDir+"a.dat").c_str()); - auto_ptr aCon(CreateConvertor(argv[1])); - aCon->ToFile((aDir+"a.med").c_str()); - aCon.reset(CreateConvertor((aDir+"a.med").c_str())); - aCon->ToFile((aDir+"a.med").c_str()); - aCon.reset(CreateConvertor((aDir+"b.med").c_str())); - aCon->ToFile((aDir+"c.dat").c_str()); - */ + } + return 0; + } + }catch(std::runtime_error& exc){ + cout<<"Follow exception was accured :\n"< myValues; +}; + +struct TTable2D{ + string myTitle; + vector myColumnUnits; + vector myColumnTitles; + vector myRows; +}; + +vector aTables; + +int GetLine(ifstream& theStmIn, QString& theString){ + char tmp; + ostrstream aStrOut; + while(theStmIn.get(tmp)){ + aStrOut< aRet(aStrOut.str()); + theString = aRet.get(); + return !theStmIn.eof(); +} + +int main(int argc, char** argv){ + try{ + if(argc > 1){ + ifstream aStmIn; + aStmIn.open(argv[1]); + QString aTmp; + while(!aStmIn.eof()){ + //Find beginning of Table + while(GetLine(aStmIn,aTmp) && aTmp.find("#TITLE:") != 0); + if(aStmIn.eof()) return 0; + 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< #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 @@ -102,6 +105,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; @@ -110,6 +115,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 308434d2..cca6e588 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; @@ -237,8 +238,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 29eab3d0..b23363db 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,12 +15,21 @@ 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" { + 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; static int INIT = ( @@ -135,10 +146,363 @@ void VISU_MedMeshConvertor::SetMedMesh(SALOME_MED::MESH_ptr theMedMesh) { myMedMesh = SALOME_MED::MESH::_duplicate(theMedMesh); } -void VISU_CorbaMedConvertor::SetMedField(SALOME_MED::FIELD_ptr theMedField) { - myMedField = SALOME_MED::FIELD::_duplicate(theMedField); - if(!myMedField->_is_nil()) - myMedMesh = myMedField->getSupport()->getMesh(); +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() !!!"); + 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 = "< - +// 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 000c07f6..c3e557ce 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 #include @@ -31,7 +32,7 @@ using namespace std; static QFileInfo aFileInfo; #ifdef DEBUG -static int MYDEBUG = 1; +static int MYDEBUG = 0; #else static int MYDEBUG = 0; #endif @@ -41,35 +42,28 @@ static int MYDEBUG = 0; //static int IS_LOADED = (cout<<"\n----------------- VisuEngine_factory is loaded -----------------\n", 1); extern "C" { PortableServer::ObjectId * - VISUEngine_factory(CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - PortableServer::ObjectId * contId, - const char *instanceName, - const char *interfaceName) - { - if(MYDEBUG) MESSAGE("VisuEngine_factory : "<getId() ; - } - - // VISU::VISU_Gen_ptr - // GetVisuGen(CORBA::ORB_var orb, PortableServer::POA_var poa, QMutex* theMutex){ - // if(MYDEBUG) MESSAGE("extern \"C\" GetVisuGen"); - // VISU::VISU_Gen_i * aVISU_Gen = new VISU::VISU_Gen_i(orb,poa,theMutex); - // return VISU::VISU_Gen::_duplicate(aVISU_Gen->_this()); - // } - - Engines::Component_ptr GetVisuGen(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA, QMutex* theMutex){ - if(MYDEBUG) MESSAGE("extern \"C\" GetVisuGen"); - VISU::VISU_Gen_i * aVISU_Gen = new VISU::VISU_Gen_i(theORB,thePOA,theMutex); - VISU::VISU_Gen_var aVisuGen = VISU::VISU_Gen::_duplicate(aVISU_Gen->_this()); - return Engines::Component::_narrow( aVisuGen ); - } + VisuEngine_factory(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, PortableServer::ObjectId * contId, + const char *instanceName, const char *interfaceName) + { + if(MYDEBUG) MESSAGE("VisuEngine_factory : "<getId() ; + } + 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 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; Base_i::~Base_i() {} @@ -81,32 +75,45 @@ 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; - const char* Storable::ToString(){ - ostrstream strOut; + string Storable::ToString(){ + ostringstream strOut; Storable::DataToStream( strOut, "myComment", GetComment() ); ToStream(strOut); strOut< aRet(strOut.str()); return strOut.str(); } void Storable::Registry(const char* theComment, TStorableEngine theEngine) @@ -124,6 +131,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); @@ -165,19 +173,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<activate_object(_thisObj); + SALOME_NamingService aNamingService(orb); + CORBA::Object_ptr anObject = aNamingService.Resolve("/Kernel/Session"); + SALOME::Session_var aSession = SALOME::Session::_narrow(anObject); + //aSession->GetInterface(); + 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, + SALOME_NamingService* theNamingService, QMutex* theMutex) : + Engines_Component_i() + { + if(MYDEBUG) MESSAGE("VISU_Gen_i::VISU_Gen_i : "<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); + } + + VISU_Gen_i::~VISU_Gen_i(){ + if(MYDEBUG) MESSAGE("VISU_Gen_i::~VISU_Gen_i"); } const CORBA::Boolean IsMultifile() { return myIsMultiFile;} //=========================================================================== @@ -375,9 +431,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){ Mutex mt(myMutex,qApp); CORBA::String_var aString(""); @@ -388,7 +452,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, @@ -441,9 +505,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); } //=========================================================================== @@ -588,6 +706,19 @@ namespace VISU{ return myVisuGen->ImportMedSupport(theSupport); } + 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(); } @@ -652,7 +786,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); @@ -669,7 +803,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); @@ -686,7 +820,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); @@ -703,7 +837,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); @@ -720,7 +854,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); @@ -735,6 +869,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->IsRestored()){ //Try remove its file and directory + if(!pResult) continue; + if(pResult->GetSourceId() == Result_i::eRestoredFile){ //Try remove its file and directory const QFileInfo& aFileInfo = pResult->GetFileInfo(); static QString aCommand; aCommand.sprintf("rm %s",aFileInfo.filePath().latin1()); diff --git a/src/VISU_I/VISU_Gen_i.hh b/src/VISU_I/VISU_Gen_i.hh index b421cc94..176f92b9 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__ @@ -41,9 +42,8 @@ namespace VISU{ //Create Result virtual Result_ptr ImportFile(const char* theFileName); - virtual Result_ptr ImportMed(SALOME_MED::FIELD_ptr theField); - virtual Result_ptr ImportMedMesh(SALOME_MED::MESH_ptr theMesh); - virtual Result_ptr ImportMedSupport(SALOME_MED::SUPPORT_ptr theSupport); + 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); @@ -62,21 +62,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); @@ -84,10 +94,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 ee9b2e02..a046a156 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; @@ -97,7 +98,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&) { @@ -181,7 +182,12 @@ VISU_Convertor* VISU_MedConvertor::Build() throw (std::runtime_error&) { &anAttId[0],&anAttVal[0],&anAttDesc[0],&aNbAttrib, &aGroupNames[0],&aNbGroup); 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(); @@ -289,6 +295,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){ - 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&) { - if(MYDEBUG) MESSAGE("LoadCellsOnEntity - beginning"); - //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 8803a71c..4595e48e 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(" Boundaries of actor do not coincide with boundaries of initial shape : \ - error finish of VISU::Prs3d_i::CreateActor"); - 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(); - return NULL; + 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,11 +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(!theRestoring) myName = GenerateName(); + if(myResult->GetInput() == NULL) + throw std::runtime_error("Mesh_i::Build - myResult->GetInput() == NULL !!!"); + if(!theRestoring) myName = (const char*)(GenerateName()); if(myEntity >= 0) if(mySubMeshName == "") myType = VISU::TENTITY; @@ -344,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) { @@ -363,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->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); + } +} + //============================================================================== int VISU::ScalarMap_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, const char* theFieldName, double theIteration){ - const VISU::TField* aField = theResult->GetInput()->GetField(theMeshName,(VISU::TEntity)theEntity,theFieldName); - if(aField == NULL) return 0; - const VISU::TField::TValField& aValField = aField->myValField; - if(aValField.find((int)theIteration) == aValField.end()) return 0; - return 1; + try{ + const VISU::TField& aField = theResult->GetInput()->GetField(theMeshName,(VISU::TEntity)theEntity,theFieldName); + const VISU::TField::TValField& aValField = aField.myValField; + 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; @@ -450,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()); @@ -458,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(); } @@ -473,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() ) @@ -562,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(); @@ -573,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(); @@ -587,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() ); @@ -622,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(){ @@ -633,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()); + } } } @@ -677,6 +739,8 @@ VISU::ScalarMap_i::~ScalarMap_i(){ if(MYDEBUG) MESSAGE("ScalarMap_i::~ScalarMap_i()"); myInput->Delete(); myFieldTransform->Delete(); + myMapperTable->Delete(); + myBarTable->Delete(); } @@ -684,53 +748,48 @@ 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)); if(myField == NULL) throw std::runtime_error("There is no Field with the parameters !!!"); 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;myResultName=%s;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d", - VISU::TTIMESTAMP,myResult->GetName(),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;myResultName=%s;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d;myComponentId=%d", - GetComment(),myResult->GetName(),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(); +} -VISU_Actor* VISU::ScalarMap_i::CreateActor(const Handle(SALOME_InteractiveObject)& theIO) { +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_Actor* aActor = VISU::Prs3d_i::CreateActor(theIO); - if ( !aActor ) return NULL; - - 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; +} + +VISU_Actor* VISU::ScalarMap_i::CreateActor(const Handle(SALOME_InteractiveObject)& theIO) { + 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(); + } } @@ -828,13 +893,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); } @@ -857,7 +925,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 ); @@ -884,10 +952,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++) @@ -1069,17 +1137,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]}, @@ -1139,80 +1222,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; + } + 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(); } - else { - myDBPrj = 0.5*myBoundPrj[2]; - SetPlane(1); - } + //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, @@ -1235,8 +1688,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); @@ -1264,7 +1721,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 ); @@ -1290,10 +1747,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(); } //============================================================================== @@ -1366,22 +1812,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) @@ -1393,19 +1842,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 ); } @@ -1427,34 +1881,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(); @@ -1465,17 +2020,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(); } //============================================================================== @@ -1501,8 +2048,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()); @@ -1531,7 +2082,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 ); @@ -1553,12 +2104,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) { @@ -100,62 +115,64 @@ VISU::Result_i::Result_i(SALOMEDS::Study_ptr theStudy) { VISU::Storable* VISU::Result_i::Build() { if(MYDEBUG) MESSAGE("Result_i::Build"); - try{ + 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;myName=%s;myFileName=%s", - GetComment(),VISU::TRESULT,myName.c_str(),myFileInfo.filePath().latin1()); + 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 hte Result !!!"); - const TMeshMap& aMeshMap = *(myInput->GetMeshMap()); - if( &aMeshMap != NULL) {//apo - TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); - for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ - const string& aMeshName = aMeshMapIter->first; - const VISU::TMesh& aMesh = aMeshMapIter->second; - const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap; - VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter; - aComment.sprintf("myComment=MESH;myResultName=%s;myName=%s;myDim=%d", - myName.c_str(),aMeshName.c_str(),aMesh.myDim); - string aMeshEntry = CreateAttributes(myStudyDocument,aResultEntry.c_str(),aRefFatherEntry.c_str(), - "",aMeshName.c_str(),"",aComment.latin1(),true); - if(aMeshOnEntityMap.empty()) continue; - aComment.sprintf("myComment=FAMILIES;myResultName=%s;myMeshName=%s",myName.c_str(),aMeshName.c_str()); - string aSubMeshesEntry = CreateAttributes(myStudyDocument,aMeshEntry.c_str(),aRefFatherEntry.c_str(), - "","Families","",aComment.latin1(),true); - //Import entities and according families - aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); - typedef map TEntity2Entry; - TEntity2Entry aEntity2Entry; - for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ - const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; - aComment.sprintf("myComment=ENTITY;myType=%d;myResultName=%s;myMeshName=%s;myId=%d", - VISU::TENTITY,myName.c_str(),aMeshName.c_str(),anEntity); - string anEntityName; - switch(anEntity){ - case VISU::NODE_ENTITY : anEntityName = "onNodes"; break; - case VISU::EDGE_ENTITY : anEntityName = "onEdges"; break; - case VISU::FACE_ENTITY : anEntityName = "onFaces"; break; - case VISU::CELL_ENTITY : anEntityName = "onCells"; break; - default: - throw std::runtime_error("Build >> Value of entity is incorrect!"); - } - aEntity2Entry[anEntity] = CreateAttributes(myStudyDocument,aSubMeshesEntry.c_str(),aRefFatherEntry.c_str(), - "",anEntityName.c_str(),"",aComment.latin1(),true); - const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; - const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap; - VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); - for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ - const string& aFamilyName = aFamilyMapIter->first; - aComment.sprintf("myComment=FAMILY;myType=%d;myResultName=%s;myMeshName=%s;myEntityId=%d;myName=%s", - VISU::TFAMILY,myName.c_str(),aMeshName.c_str(),anEntity,aFamilyName.c_str()); - CreateAttributes(myStudyDocument,aEntity2Entry[anEntity].c_str(),aRefFatherEntry.c_str(), - "",aFamilyName.c_str(),"",aComment.latin1(),true); - } + 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; + const VISU::TMesh& aMesh = aMeshMapIter->second; + const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap; + VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter; + aComment.sprintf("myComment=MESH;myName=%s;myDim=%d", + aMeshName.c_str(),aMesh.myDim); + string aMeshEntry = CreateAttributes(myStudyDocument,aResultEntry.c_str(),aRefFatherEntry.c_str(), + "",aMeshName.c_str(),"",aComment.latin1(),true); + if(aMeshOnEntityMap.empty()) continue; + aComment.sprintf("myComment=FAMILIES;myMeshName=%s",aMeshName.c_str()); + string aSubMeshesEntry = CreateAttributes(myStudyDocument,aMeshEntry.c_str(),aRefFatherEntry.c_str(), + "","Families","",aComment.latin1(),true); + //Import entities and according families + aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); + typedef map TEntity2Entry; + TEntity2Entry aEntity2Entry; + for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ + const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; + aComment.sprintf("myComment=ENTITY;myType=%d;myMeshName=%s;myId=%d", + VISU::TENTITY,aMeshName.c_str(),anEntity); + string anEntityName; + switch(anEntity){ + case VISU::NODE_ENTITY : anEntityName = "onNodes"; break; + case VISU::EDGE_ENTITY : anEntityName = "onEdges"; break; + case VISU::FACE_ENTITY : anEntityName = "onFaces"; break; + case VISU::CELL_ENTITY : anEntityName = "onCells"; break; + default: + throw std::runtime_error("Build >> Value of entity is incorrect!"); + } + aEntity2Entry[anEntity] = CreateAttributes(myStudyDocument,aSubMeshesEntry.c_str(),aRefFatherEntry.c_str(), + "",anEntityName.c_str(),"",aComment.latin1(),true); + const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; + const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap; + VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); + for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ + const string& aFamilyName = aFamilyMapIter->first; + aComment.sprintf("myComment=FAMILY;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s", + VISU::TFAMILY,aMeshName.c_str(),anEntity,aFamilyName.c_str()); + CreateAttributes(myStudyDocument,aEntity2Entry[anEntity].c_str(),aRefFatherEntry.c_str(), + "",aFamilyName.c_str(),"",aComment.latin1(),true); } //Importing groups const VISU::TGroupMap& aGroupMap = aMesh.myGroupMap; @@ -184,45 +201,58 @@ VISU::Storable* VISU::Result_i::Build() { } } } - //Import fields - string aFieldsEntry; - bool isFieldEntryCreated = 0; - 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(); - for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){ - if(!isFieldEntryCreated){ - aComment.sprintf("myComment=FIELDS;myResultName=%s;myMeshName=%s",myName.c_str(),aMeshName.c_str()); - aFieldsEntry = CreateAttributes(myStudyDocument,aMeshEntry.c_str(),aRefFatherEntry.c_str(), - "","Fields","",aComment.latin1(),true); - isFieldEntryCreated = true; - } - const string& aFieldName = aFieldMapIter->first; - const VISU::TField& aField = aFieldMapIter->second; - const VISU::TField::TValField& aValField = aField.myValField; - aComment.sprintf("myComment=FIELD;myType=%d;myResultName=%s;myMeshName=%s;myEntityId=%d;myName=%s;myNbTimeStamps=%d;myNumComponent=%d", - VISU::TFIELD,myName.c_str(),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); - CreateReference(myStudyDocument,aFieldEntry,aEntity2Entry[anEntity]); - VISU::TField::TValField::const_iterator aValFieldIter = aValField.begin(); - for(; aValFieldIter != aValField.end(); aValFieldIter++){ - int aTimeStamp = aValFieldIter->first; - const VISU::TField::TValForTime& aValForTime = aValFieldIter->second; - aComment.sprintf("myComment=TIMESTAMP;myType=%d;myResultName=%s;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d", - VISU::TTIMESTAMP,myName.c_str(),aMeshName.c_str(),anEntity,aFieldName.c_str(),aTimeStamp,aField.myNbComp); - string aTimeStampId = VISU_Convertor::GenerateName(aValForTime.myTime); - CreateAttributes(myStudyDocument,aFieldEntry.c_str(),aRefFatherEntry.c_str(), - "",aTimeStampId.c_str(),"",aComment.latin1(),true); - } + } + //Import fields + string aFieldsEntry; + bool isFieldEntryCreated = 0; + 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(); + for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){ + if(!isFieldEntryCreated){ + aComment.sprintf("myComment=FIELDS;myMeshName=%s",aMeshName.c_str()); + aFieldsEntry = CreateAttributes(myStudyDocument,aMeshEntry.c_str(),aRefFatherEntry.c_str(), + "","Fields","",aComment.latin1(),true); + isFieldEntryCreated = true; + } + 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(), + "",aFieldNameWithUnit.latin1(),"",aComment.latin1(),true); + CreateReference(myStudyDocument,aFieldEntry,aEntity2Entry[anEntity]); + VISU::TField::TValField::const_iterator aValFieldIter = aValField.begin(); + for(; aValFieldIter != aValField.end(); aValFieldIter++){ + int aTimeStamp = aValFieldIter->first; + const VISU::TField::TValForTime& aValForTime = aValFieldIter->second; + aComment.sprintf("myComment=TIMESTAMP;myType=%d;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d", + VISU::TTIMESTAMP,aMeshName.c_str(),anEntity,aFieldName.c_str(),aTimeStamp,aField.myNbComp); + string aTimeStampId = VISU_Convertor::GenerateName(aValForTime.myTime); + CreateAttributes(myStudyDocument,aFieldEntry.c_str(),aRefFatherEntry.c_str(), + "",aTimeStampId.c_str(),"",aComment.latin1(),true); } } } } - return this; + } + return this; +} + +VISU::Storable* VISU::Result_i::Create(const char* theFileName){ + try{ + mySourceId = eFile; + myInput = CreateConvertor(theFileName); + if(myInput == NULL) return NULL; + myFileInfo.setFile(theFileName); + myName = (const char*)(::GenerateName(myFileInfo.fileName().latin1())); + VISU::Storable* aStorable = Build(); + return aStorable; }catch(std::runtime_error& exc){ MESSAGE("Follow exception was accured :\n"<SetMedMesh(theMesh); - myInput = aInput; - //if(myInput->GetOutput() == NULL) return NULL; - TMeshMap::const_iterator aMeshMapIter = myInput->GetMeshMap()->begin(); - myName = ::GenerateName((aMeshMapIter->first).c_str()); - return Build(); -} - -VISU::Storable* VISU::Result_i::Create(SALOME_MED::SUPPORT_ptr theSupport){ - if(MYDEBUG) MESSAGE("Result_i::Create Mesh from MED::SUPPORT"); - VISU_CorbaMedSupportConvertor* aInput = new VISU_CorbaMedSupportConvertor(); - aInput->SetSupport(theSupport); - myInput = aInput; - //if(myInput->GetOutput() == NULL) return NULL; - TMeshMap::const_iterator aMeshMapIter = myInput->GetMeshMap()->begin(); - myName = ::GenerateName((aMeshMapIter->first).c_str()); - return Build(); +VISU::Storable* VISU::Result_i::Create(SALOMEDS::SObject_ptr theMedSObject){ + if(MYDEBUG) MESSAGE("Result_i::Create MedObject from SALOMEDS::SObject_ptr"); + try{ + mySourceId = eComponent; + myInput = CreateMEDConvertor(theMedSObject); + if(myInput == NULL) return NULL; + string aCompDataType = GetComponentDataType(theMedSObject); + myFileInfo.setFile(aCompDataType.c_str()); + myName = (const char*)(::GenerateName("aResult")); + VISU::Storable* aStorable = Build(theMedSObject); + return aStorable; + }catch(std::runtime_error& exc){ + MESSAGE("Follow exception was accured :\n"<SetMedField(theField); - myInput = aInput; - //if(myInput->GetOutput() == NULL) return NULL; - TMeshMap::const_iterator aMeshMapIter = myInput->GetMeshMap()->begin(); - myName = ::GenerateName((aMeshMapIter->first).c_str()); - return Build(); + if(MYDEBUG) MESSAGE("Result_i::Create MedObject from SALOME_MED::FIELD_ptr"); + try{ + mySourceId = eComponent; + myInput = CreateMEDFieldConvertor(theField); + if(myInput == NULL) return NULL; + string aCompDataType = "Med"; + myFileInfo.setFile(aCompDataType.c_str()); + myName = (const char*)(::GenerateName("aResult")); + 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"); - string aFileName(thePrefix); - string aStudyPrefix = SALOMEDS_Tool::GetNameFromPath(myStudyDocument->URL()); - aFileName += aStudyPrefix + "_" + myName; - if(MYDEBUG) MESSAGE("Result_i::Restore - aFileName = "<FindAttribute(anAttr, "AttributeComment")) - throw std::runtime_error("Build - There is no AttributeComment for the SObject !!!"); - SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr); - aCmnt->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(thePrefix.c_str(), aSeq.in(), true); + myName = (const char*)(VISU::Storable::FindValue(theMap,"myName")); + SALOMEDS::SObject_var aRefSObj, aTargetRefSObj; + if(mySObject->FindSubObject(1,aRefSObj) && aRefSObj->ReferencedObject(aTargetRefSObj)){ + mySourceId = eRestoredComponent; + if(MYDEBUG) MESSAGE("Result_i::GetInput - There is some reference."); + SALOMEDS::SComponent_var aCompRefSObj = aTargetRefSObj->GetFatherComponent(); + CORBA::String_var aDataType = aCompRefSObj->ComponentDataType(); + myFileInfo.setFile(aDataType.in()); + if(MYDEBUG) MESSAGE("Result_i::GetInput - aDataType = "<FindOrLoad_Component("FactoryServer", aDataType.in()); + if (CORBA::is_nil(aEngComp)) + throw std::runtime_error("Restore - There is no aEngComp for the aDataType !!!"); + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder(); + SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aEngComp); + aStudyBuilder->LoadWith(aCompRefSObj,aDriver); + if(strcmp(aDataType,"Med") == 0){ + myInput = CreateMEDConvertor(aTargetRefSObj); + }else + throw std::runtime_error("GetInput - There is no convertor for the aDataType !!!"); + }else{ + myFileInfo.setFile(thePrefix.c_str()); + + string aStudyPrefix(SALOMEDS_Tool::GetNameFromPath(myStudyDocument->URL())); + if(!myFileInfo.isFile()){ + string aFileName = thePrefix + aStudyPrefix + "_" + myName; + myFileInfo.setFile(aFileName.c_str()); + } + if(MYDEBUG) + MESSAGE("Result_i::Restore - aFileName = "<FindAttribute(anAttr, "AttributeComment")) + throw std::runtime_error("Build - There is no AttributeComment for the SObject !!!"); + SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr); + aCmnt->SetValue(aComment.latin1()); } return this; }catch(std::runtime_error& exc){ @@ -314,7 +387,11 @@ VISU::Storable* VISU::Result_i::Restore(SALOMEDS::SObject_ptr theSObject, return NULL; } -void VISU::Result_i::ToStream(ostrstream& theStr){ +VISU::Result_i::InputType* VISU::Result_i::GetInput() { + return myInput; +} + +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 4b5a30b1..9edaca12 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__ @@ -37,13 +40,12 @@ namespace VISU{ virtual Storable* Build(); public: virtual Storable* Create(const char* theFileName); + virtual Storable* Create(SALOMEDS::SObject_ptr theMedSObject); virtual Storable* Create(SALOME_MED::FIELD_ptr theField); - virtual Storable* Create(SALOME_MED::MESH_ptr theMesh); - virtual Storable* Create(SALOME_MED::SUPPORT_ptr theSupport); 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() { return myInput;} diff --git a/src/VISU_I/VISU_Table_i.cc b/src/VISU_I/VISU_Table_i.cc index 1aba7769..80ce8c10 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( "*" ) ) ); @@ -891,73 +940,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{ @@ -1033,10 +1082,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) { @@ -388,8 +440,6 @@ void VISU_TimeAnimation::run() { //cout<<"### save:"<unlock(); - if (!isDumping) { if (myProportional) { switch (myFrame) { @@ -397,26 +447,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(); } //************************************************************************ @@ -456,6 +521,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 82df8ba5..1306d5d1 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,129 +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 - vtkPolyDataMapper *aMapper = vtkPolyDataMapper::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(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..54b068d0 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=../.. 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 ae688cf2..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_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 335a643a..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_med.py b/src/VISU_SWIG/visu_med.py index cd120a6c..dda0c4e8 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_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