From: ouv Date: Wed, 5 Aug 2009 12:59:08 +0000 (+0000) Subject: Issue 0020336: [CEA 339] specifying a cut line with 2 points X-Git-Tag: V5_1_main_20090812~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a647cea48dc31162d36d1f86aea990e4cd49bc89;p=modules%2Fvisu.git Issue 0020336: [CEA 339] specifying a cut line with 2 points --- diff --git a/doc/salome/gui/VISU/images/cutsegment.png b/doc/salome/gui/VISU/images/cutsegment.png new file mode 100644 index 00000000..c75bf7e7 Binary files /dev/null and b/doc/salome/gui/VISU/images/cutsegment.png differ diff --git a/doc/salome/gui/VISU/images/cutsegmenticon.jpg b/doc/salome/gui/VISU/images/cutsegmenticon.jpg new file mode 100755 index 00000000..fb551c90 Binary files /dev/null and b/doc/salome/gui/VISU/images/cutsegmenticon.jpg differ diff --git a/doc/salome/gui/VISU/images/cutsegmentprsnt.png b/doc/salome/gui/VISU/images/cutsegmentprsnt.png new file mode 100755 index 00000000..51cde704 Binary files /dev/null and b/doc/salome/gui/VISU/images/cutsegmentprsnt.png differ diff --git a/doc/salome/gui/VISU/input/cut_segment.doc b/doc/salome/gui/VISU/input/cut_segment.doc new file mode 100644 index 00000000..c3133f9f --- /dev/null +++ b/doc/salome/gui/VISU/input/cut_segment.doc @@ -0,0 +1,66 @@ +/*! + +\page cut_segment_page Cut Segment presentation +\image html cutsegmentprsnt.png "Example of Cut Segment presentation" + +\n Cut Segment is a simplified variant of +\ref cut_lines_page "Cut Lines" presentation, which is used to +display a single line instead of set of them. Axis of this line is +defined by coordinates of two points in 3D space. + +To create a Cut Segment presentation: +\par +– Right-click on one of the time stamps of the field in the +Object browser and from the pop-up menu choose Cut Segment, or +\n – Click on one of the time stamps of the field in the Object +browser and select from the main menu Visualization > Cut +Segment, or click "Cut Segment" icon in the Visualization +Toolbar. + +\image html cutsegmenticon.jpg +
"Cut Segment" icon
+ +\image html cutsegment.png + +\par +Cut Segment: this tab of the dialog box contains the +parameters of the cut segment. + +See more about table presentations and curve lines +\ref table_presentations_page "here". + +\par +Scalar Bar tab allows to define the parameters of the scalar bar +displayed with this presentation (\ref scalar_map_page "see also"). + +After you have finished with setting these parameters, click \b +OK. Your presentation with scalar bar will be immediately displayed in +the viewer: + +Tip: From Cut Segment presentation you can create a +data table. This table will consist of the field scalar values +located on the cut line of the constructed presentation. After that +your data table can be used for construction of a 2d plot of curves +based on the scalar values from the table (see also: +\ref creating_curves_page "Creating curves" and +\ref creating_plot2d_page "Creating Plot 2D presentation"). + +*/ \ No newline at end of file diff --git a/doc/salome/gui/VISU/input/field_presentations.doc b/doc/salome/gui/VISU/input/field_presentations.doc index 2755401b..45724ebf 100644 --- a/doc/salome/gui/VISU/input/field_presentations.doc +++ b/doc/salome/gui/VISU/input/field_presentations.doc @@ -8,6 +8,7 @@ presentations:
  • \subpage scalar_map_page
  • \subpage iso_surfaces_page
  • \subpage cut_lines_page
  • +
  • \subpage cut_segment_page
  • \subpage cut_planes_page
  • \subpage deformed_shape_page
  • \subpage vectors_page
  • diff --git a/doc/salome/gui/VISU/input/table_presentations.doc b/doc/salome/gui/VISU/input/table_presentations.doc index ee162476..3a57a993 100644 --- a/doc/salome/gui/VISU/input/table_presentations.doc +++ b/doc/salome/gui/VISU/input/table_presentations.doc @@ -15,8 +15,9 @@ from properly defined ACSII files. \note Alternatively, it is possible to create a table from the scalar values applied to the cells forming a \ref cut_lines_page "Cut Lines" -presentation. Simply right-click on the presentation in the Object -Browser or in the viewer and select Create Table from the pop-up menu. +or a \ref cut_segment_page "Cut Segment" presentation. Simply right-click on the +presentation in the Object Browser or in the viewer and select Create Table +from the pop-up menu. Tables are not displayed automatically. To view the imported table, right-click on it in the Object Brower and select Show Table diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index 2e98fc19..1d7e7640 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -98,6 +98,7 @@ module VISU { TPOINTMAP3D, /*!< 3D presentation for table object */ TCUTPLANES, /*!< Cut planes 3D presentation object */ TCUTLINES, /*!< Cut lines 3D presentation object */ + TCUTSEGMENT, /*!< Cut segment 3D presentation object */ TVECTORS, /*!< Vectors 3D presentation object */ TSTREAMLINES, /*!< Streamlines 3D presentation object */ TVISUGEN, /*!< %VISU generator used for performing operations with different %VISU objects */ @@ -1352,6 +1353,42 @@ module VISU { long GetNbPlanes(); }; + //------------------------------------------------------- + /*! \brief Base interface for Cut Lines and Cut Segment tools + * + */ + interface CutLinesBase : ScalarMap { + /*! + * Sets the number of cut lines. + * \param theNb The number of cut lines. + */ + void SetNbLines(in long theNb); + + /*! + * Gets the number of cut lines. + */ + long GetNbLines(); + + /*! Invert all curves of corresponding table + * \param theInvert - Invert all curves, if value is TRUE, else not. + */ + void SetAllCurvesInverted(in boolean theInvert); + + /*! Checks the orientation of all curves + * \retval TRUE - if all curves are inverted, else FALSE + */ + boolean IsAllCurvesInverted(); + + /*! Sets values which cutlines would be shown: aboslute or relative values + * \param theAbsLength - boolean value, TRUE or false. + */ + void SetUseAbsoluteLength(in boolean theAbsLength); + + /*! Checks values of cutlines: using aboslute or relative values + */ + boolean IsUseAbsoluteLength(); + }; + //------------------------------------------------------- /*! \brief Cut lines presentation. * @@ -1367,7 +1404,7 @@ module VISU { * operation is a regular array of lines in space, belonging to the same plane * and having the same orientation. They are located inside or on the mesh. */ - interface CutLines : ScalarMap { + interface CutLines : CutLinesBase { /*! * Sets the type of orientation in 3D space of the base plane of a cut lines presentation. * \param theOrientation The orientation of the base plane in 3D space. @@ -1487,36 +1524,48 @@ module VISU { * \return True if this cutting plane has default position. */ boolean IsDefaultPosition(in long thePlaneNumber); + }; + //------------------------------------------------------- + /*! \brief Cut segment presentation. + * + * Presentation parameters of a Cut segment presentation. + * Cut Segment is a simplified variant of Cut Lines presentation, which is used + * to display a single line instead of set of them. Axis of this line is defined + * by coordinates of two points in 3D space. + */ + interface CutSegment : CutLinesBase { /*! - * Sets the number of cut lines. - * \param theNb The number of cut lines. + * Sets coordinates of the first point of axis of the segment. + * \param theX X coordinate of the point + * \param theY Y coordinate of the point + * \param theZ Z coordinate of the point */ - void SetNbLines(in long theNb); + void SetPoint1(in double theX, in double theY, in double theZ); /*! - * Gets the number of cut lines. - */ - long GetNbLines(); - - /*! Invert all curves of corresponding table - * \param theInvert - Invert all curves, if value is TRUE, else not. - */ - void SetAllCurvesInverted(in boolean theInvert); - - /*! Checks the orientation of all curves - * \retval TRUE - if all curves are inverted, else FALSE + * Gets coordinates of the first point of axis of the segment. + * \param theX X coordinate of the point + * \param theY Y coordinate of the point + * \param theZ Z coordinate of the point */ - boolean IsAllCurvesInverted(); + void GetPoint1(out double theX, out double theY, out double theZ); - /*! Sets values which cutlines would be shown: aboslute or relative values - * \param theAbsLength - boolean value, TRUE or false. + /*! + * Sets coordinates of the second point of axis of the segment. + * \param theX X coordinate of the point + * \param theY Y coordinate of the point + * \param theZ Z coordinate of the point */ - void SetUseAbsoluteLength(in boolean theAbsLength); + void SetPoint2(in double theX, in double theY, in double theZ); - /*! Checks values of cutlines: using aboslute or relative values + /*! + * Gets coordinates of the second point of axis of the segment. + * \param theX X coordinate of the point + * \param theY Y coordinate of the point + * \param theZ Z coordinate of the point */ - boolean IsUseAbsoluteLength(); + void GetPoint2(out double theX, out double theY, out double theZ); }; /*! \brief Interface of the stream lines representation @@ -2275,6 +2324,18 @@ module VISU { in Entity theEntity, in string theFieldName, in long theTimeStampNumber); + /*! + * Creates a presentation of cut segment. + * \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 theTimeStampNumber Number of iteration on the field + */ + CutSegment CutSegmentOnField(in Result theResult, in string theMeshName, + in Entity theEntity, in string theFieldName, + in long theTimeStampNumber); + /*! * Creates a Plot3D presentation. * \param theResult Data generated in other sources. (MED object or file) diff --git a/resources/Makefile.am b/resources/Makefile.am index ae592ccd..c9ae4291 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -43,6 +43,7 @@ Visu_cell_selection.png \ Visu_close.png \ VISU.config \ Visu_cutlines.png \ +Visu_cutsegment.png \ Visu_cutplanes.png \ Visu_deformed_anim.png \ Visu_deformed.png \ @@ -88,6 +89,8 @@ Visu_tree_container.png \ Visu_tree_curve.png \ Visu_tree_cutlines_gr.png \ Visu_tree_cutlines.png \ +Visu_tree_cutsegment_gr.png \ +Visu_tree_cutsegment.png \ Visu_tree_cutplanes_gr.png \ Visu_tree_cutplanes.png \ Visu_tree_deformed_gr.png \ diff --git a/resources/SalomeApp.xml b/resources/SalomeApp.xml index 48c8051b..d168f5b7 100644 --- a/resources/SalomeApp.xml +++ b/resources/SalomeApp.xml @@ -42,6 +42,7 @@ + diff --git a/resources/VISU_en.xml b/resources/VISU_en.xml index db3d178f..7e7e28c6 100644 --- a/resources/VISU_en.xml +++ b/resources/VISU_en.xml @@ -53,6 +53,7 @@ + @@ -116,6 +117,7 @@ + diff --git a/resources/VISU_fr.xml b/resources/VISU_fr.xml index a7c3b3d5..decdc38b 100644 --- a/resources/VISU_fr.xml +++ b/resources/VISU_fr.xml @@ -53,6 +53,7 @@ + @@ -114,6 +115,7 @@ + diff --git a/resources/Visu_cutsegment.png b/resources/Visu_cutsegment.png new file mode 100644 index 00000000..bff1ebcd Binary files /dev/null and b/resources/Visu_cutsegment.png differ diff --git a/resources/Visu_tree_cutsegment.png b/resources/Visu_tree_cutsegment.png new file mode 100644 index 00000000..0aea43f3 Binary files /dev/null and b/resources/Visu_tree_cutsegment.png differ diff --git a/resources/Visu_tree_cutsegment_gr.png b/resources/Visu_tree_cutsegment_gr.png new file mode 100644 index 00000000..2c629190 Binary files /dev/null and b/resources/Visu_tree_cutsegment_gr.png differ diff --git a/src/ENGINE/VISU_Engine_i.cc b/src/ENGINE/VISU_Engine_i.cc index 887f2da1..7f8731e6 100644 --- a/src/ENGINE/VISU_Engine_i.cc +++ b/src/ENGINE/VISU_Engine_i.cc @@ -361,6 +361,18 @@ namespace VISU{ } + CutSegment_ptr + VISU_Gen_i + ::CutSegmentOnField(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + CORBA::Long theIteration) + { + return myVisuGen->CutSegmentOnField(theResult,theMeshName,theEntity,theFieldName,theIteration); + } + + Plot3D_ptr VISU_Gen_i ::Plot3DOnField(Result_ptr theResult, diff --git a/src/ENGINE/VISU_Engine_i.hh b/src/ENGINE/VISU_Engine_i.hh index 93847a27..bf44466e 100644 --- a/src/ENGINE/VISU_Engine_i.hh +++ b/src/ENGINE/VISU_Engine_i.hh @@ -138,6 +138,14 @@ namespace VISU const char* theFieldName, CORBA::Long theIteration); + virtual + CutSegment_ptr + CutSegmentOnField(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + CORBA::Long theIteration); + virtual StreamLines_ptr StreamLinesOnField(Result_ptr theResult, diff --git a/src/PIPELINE/Makefile.am b/src/PIPELINE/Makefile.am index d918d23a..133fa81a 100644 --- a/src/PIPELINE/Makefile.am +++ b/src/PIPELINE/Makefile.am @@ -40,7 +40,9 @@ salomeinclude_HEADERS= \ VISU_MeshPL.hxx \ VISU_ScalarMapPL.hxx \ VISU_CutPlanesPL.hxx \ + VISU_CutLinesBasePL.hxx \ VISU_CutLinesPL.hxx \ + VISU_CutSegmentPL.hxx \ VISU_IsoSurfacesPL.hxx \ VISU_DeformedShapePL.hxx \ VISU_VectorsPL.hxx \ @@ -84,7 +86,9 @@ dist_libVisuPipeLine_la_SOURCES= \ VISU_MeshPL.cxx \ VISU_ScalarMapPL.cxx \ VISU_CutPlanesPL.cxx \ + VISU_CutLinesBasePL.cxx \ VISU_CutLinesPL.cxx \ + VISU_CutSegmentPL.cxx \ VISU_IsoSurfacesPL.cxx \ VISU_DeformedShapePL.cxx \ VISU_VectorsPL.cxx \ diff --git a/src/PIPELINE/VISU_CutLinesBasePL.cxx b/src/PIPELINE/VISU_CutLinesBasePL.cxx new file mode 100644 index 00000000..13370909 --- /dev/null +++ b/src/PIPELINE/VISU_CutLinesBasePL.cxx @@ -0,0 +1,40 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File: VISU_CutLinesBasePL.cxx +// Author: Oleg UVAROV +// Module : VISU +// +#include "VISU_CutLinesBasePL.hxx" + +#include + +//---------------------------------------------------------------------------- +vtkStandardNewMacro(VISU_CutLinesBasePL); + + +//---------------------------------------------------------------------------- +VISU_CutLinesBasePL +::VISU_CutLinesBasePL() +{ + SetIsShrinkable(false); + SetIsFeatureEdgesAllowed(false); +} diff --git a/src/PIPELINE/VISU_CutLinesBasePL.hxx b/src/PIPELINE/VISU_CutLinesBasePL.hxx new file mode 100644 index 00000000..d3ed3d0f --- /dev/null +++ b/src/PIPELINE/VISU_CutLinesBasePL.hxx @@ -0,0 +1,98 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File: VISU_CutLinesBasePL.hxx +// Author: Oleg UVAROV +// Module : VISU +// +#ifndef VISU_CutLinesBasePL_HeaderFile +#define VISU_CutLinesBasePL_HeaderFile + +#include "VISUPipeline.hxx" +#include "VISU_CutPlanesPL.hxx" + +//---------------------------------------------------------------------------- +class VISU_PIPELINE_EXPORT VISU_CutLinesBasePL : public VISU_CutPlanesPL +{ +public: + vtkTypeMacro(VISU_CutLinesBasePL,VISU_CutPlanesPL); + + static + VISU_CutLinesBasePL* + New(); + +public: + //! Returns direction that is defined by position & orientation of the basic and tool planes + const vtkFloatingPointType* + GetRealDirLn() + { + return myRealDirLn; + } + + /*! + Returns direction that corresponds to the myRealDirLn, + but has the same direction as main axis. + */ + const vtkFloatingPointType* + GetDirLn() + { + return myDirLn; + } + + /*! + Returns coordinates of 3D point that shows + where is the first intersection of the given mesh. + with the defined direction. + */ + const vtkFloatingPointType* + GetBasePnt() + { + return myBasePnt; + } + + /*! + Returns three floating point numbers that defines the following values: + 1. Distance between the initial point of intersection and origin of coordinates; + 2. Distance between the last point of intersection and origin of coordinates; + 3. Distance between the last point and initial points of intersection. + with the defined direction. + */ + const vtkFloatingPointType* + GetBoundPrjLn() + { + return myBoundPrjLn; + } + +protected: + VISU_CutLinesBasePL(); + + vtkFloatingPointType myDirLn[3]; + vtkFloatingPointType myRealDirLn[3]; + vtkFloatingPointType myBoundPrjLn[3]; + vtkFloatingPointType myBasePnt[3]; + +private: + VISU_CutLinesBasePL(const VISU_CutLinesBasePL&); // Not implemented. + void operator=(const VISU_CutLinesBasePL&); // Not implemented. +}; + + +#endif diff --git a/src/PIPELINE/VISU_CutLinesPL.cxx b/src/PIPELINE/VISU_CutLinesPL.cxx index 7fcfb1fd..f6980dd5 100644 --- a/src/PIPELINE/VISU_CutLinesPL.cxx +++ b/src/PIPELINE/VISU_CutLinesPL.cxx @@ -39,9 +39,6 @@ vtkStandardNewMacro(VISU_CutLinesPL); VISU_CutLinesPL ::VISU_CutLinesPL() { - SetIsShrinkable(false); - SetIsFeatureEdgesAllowed(false); - myCondition = 1; myPosition = 0; } diff --git a/src/PIPELINE/VISU_CutLinesPL.hxx b/src/PIPELINE/VISU_CutLinesPL.hxx index 5607bf3a..afe46a3c 100644 --- a/src/PIPELINE/VISU_CutLinesPL.hxx +++ b/src/PIPELINE/VISU_CutLinesPL.hxx @@ -28,16 +28,16 @@ #define VISU_CutLinesPL_HeaderFile #include "VISUPipeline.hxx" -#include "VISU_CutPlanesPL.hxx" +#include "VISU_CutLinesBasePL.hxx" class vtkAppendPolyData; //---------------------------------------------------------------------------- -class VISU_PIPELINE_EXPORT VISU_CutLinesPL : public VISU_CutPlanesPL +class VISU_PIPELINE_EXPORT VISU_CutLinesPL : public VISU_CutLinesBasePL { public: - vtkTypeMacro(VISU_CutLinesPL,VISU_CutPlanesPL); + vtkTypeMacro(VISU_CutLinesPL,VISU_CutLinesBasePL); static VISU_CutLinesPL* @@ -82,47 +82,6 @@ public: int thePlaneCondition, vtkFloatingPointType theDisplacement); - //! Returns direction that is defined by position & orientation of the basic and tool planes - const vtkFloatingPointType* - GetRealDirLn() - { - return myRealDirLn; - } - - /*! - Returns direction that corresponds to the myRealDirLn, - but has the same direction as main axis. - */ - const vtkFloatingPointType* - GetDirLn() - { - return myDirLn; - } - - /*! - Returns coordinates of 3D point that shows - where is the first intersection of the given mesh. - with the defined direction. - */ - const vtkFloatingPointType* - GetBasePnt() - { - return myBasePnt; - } - - /*! - Returns three floating point numbers that defines the following values: - 1. Distance between the initial point of intersection and origin of coordinates; - 2. Distance between the last point of intersection and origin of coordinates; - 3. Distance between the last point and initial points of intersection. - with the defined direction. - */ - const vtkFloatingPointType* - GetBoundPrjLn() - { - return myBoundPrjLn; - } - protected: VISU_CutLinesPL(); @@ -131,10 +90,6 @@ protected: DoShallowCopy(VISU_PipeLine *thePipeLine, bool theIsCopyInput); - vtkFloatingPointType myDirLn[3]; - vtkFloatingPointType myRealDirLn[3]; - vtkFloatingPointType myBoundPrjLn[3]; - vtkFloatingPointType myBasePnt[3]; vtkFloatingPointType myPosition; int myCondition; diff --git a/src/PIPELINE/VISU_CutSegmentPL.cxx b/src/PIPELINE/VISU_CutSegmentPL.cxx new file mode 100644 index 00000000..2e1fcfe1 --- /dev/null +++ b/src/PIPELINE/VISU_CutSegmentPL.cxx @@ -0,0 +1,216 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File: VISU_CutSegmentPL.hxx +// Author: Oleg UVAROV +// Module : VISU +// +#include "VISU_CutSegmentPL.hxx" +#include "VISU_PipeLineUtils.hxx" + +#include + +//---------------------------------------------------------------------------- +vtkStandardNewMacro(VISU_CutSegmentPL); + + +//---------------------------------------------------------------------------- +VISU_CutSegmentPL +::VISU_CutSegmentPL() +{ +} + +//---------------------------------------------------------------------------- +void +VISU_CutSegmentPL +::DoShallowCopy(VISU_PipeLine *thePipeLine, + bool theIsCopyInput) +{ + Superclass::DoShallowCopy(thePipeLine, theIsCopyInput); + + if(VISU_CutSegmentPL *aPipeLine = dynamic_cast(thePipeLine)){ + vtkFloatingPointType x, y, z; + aPipeLine->GetPoint1(x, y, z); + SetPoint1(x, y, z); + aPipeLine->GetPoint2(x, y, z); + SetPoint2(x, y, z); + } +} + +//---------------------------------------------------------------------------- +void +VISU_CutSegmentPL +::Init() +{ + Superclass::Init(); + + vtkFloatingPointType aBounds[6]; + GetMergedInput()->GetBounds(aBounds); + + for( int i = 0; i < 3; i++ ) { + vtkFloatingPointType min = aBounds[ 2*i ]; + vtkFloatingPointType max = aBounds[ 2*i+1 ]; + myPoint1[ i ] = i == 1 ? min : ( min + max ) / 2; + myPoint2[ i ] = i == 1 ? max : ( min + max ) / 2; + } +} + +//---------------------------------------------------------------------------- +void +VISU_CutSegmentPL +::SetPoint1(vtkFloatingPointType theX, + vtkFloatingPointType theY, + vtkFloatingPointType theZ ) +{ + myPoint1[0] = theX; + myPoint1[1] = theY; + myPoint1[2] = theZ; +} + +//---------------------------------------------------------------------------- +void +VISU_CutSegmentPL +::GetPoint1(vtkFloatingPointType& theX, + vtkFloatingPointType& theY, + vtkFloatingPointType& theZ ) +{ + theX = myPoint1[0]; + theY = myPoint1[1]; + theZ = myPoint1[2]; +} + +//---------------------------------------------------------------------------- +void +VISU_CutSegmentPL +::SetPoint2(vtkFloatingPointType theX, + vtkFloatingPointType theY, + vtkFloatingPointType theZ ) +{ + myPoint2[0] = theX; + myPoint2[1] = theY; + myPoint2[2] = theZ; +} + +//---------------------------------------------------------------------------- +void +VISU_CutSegmentPL +::GetPoint2(vtkFloatingPointType& theX, + vtkFloatingPointType& theY, + vtkFloatingPointType& theZ ) +{ + theX = myPoint2[0]; + theY = myPoint2[1]; + theZ = myPoint2[2]; +} + +//---------------------------------------------------------------------------- +vtkDataSet* +VISU_CutSegmentPL +::InsertCustomPL() +{ + return myAppendPolyData->GetOutput(); +} + +//---------------------------------------------------------------------------- +void +VISU_CutSegmentPL +::Update() +{ + vtkDataSet* aMergedInput = GetMergedInput(); + if(VISU::IsQuadraticData(aMergedInput)) // Bug 0020123, note 0005343 + throw std::runtime_error("Impossible to build presentation"); + + vtkFloatingPointType aVector12[3], aVector21[3]; + VISU::Sub( myPoint2, myPoint1, aVector12 ); + VISU::Sub( myPoint1, myPoint2, aVector21 ); + + double aPrecision = 1.0 / VTK_LARGE_FLOAT; + double aNorm = vtkMath::Normalize( aVector12 ); + if( aNorm < aPrecision ) + return; + + // compute two vectors which are orthogonal to the line between the input points + // these vectors could be used as normals of two planes, intersected exactly at this line + // origin of these planes should be places at one of the input points + vtkFloatingPointType aVector1[3], aVector2[3]; + vtkMath::Perpendiculars( aVector12, aVector1, aVector2, 0 ); + + ClearAppendPolyData(myAppendPolyData); + + SetPartPosition(1); + + vtkFloatingPointType aBounds[6]; + GetMergedInput()->GetBounds(aBounds); + + // check if the input is planar - in this case one cut plane will be enough + // (besides, the second cut corrupts the resulting output, splitting it to points) + bool isPlanar = true; + vtkFloatingPointType aNormal[3] = { 0.0, 0.0, 0.0 }; + if( fabs( aBounds[0] - aBounds[1] ) < aPrecision ) + aNormal[0] = 1.0; + else if( fabs( aBounds[2] - aBounds[3] ) < aPrecision ) + aNormal[1] = 1.0; + else if( fabs( aBounds[4] - aBounds[5] ) < aPrecision ) + aNormal[2] = 1.0; + else + isPlanar = false; + + if( isPlanar ) { + // choose a vector which is not collinear with normal of the plane + vtkFloatingPointType aCross[3]; + vtkMath::Cross( aVector1, aNormal, aCross ); + bool isFirst = vtkMath::Norm( aCross ) > aPrecision; + VISU_CutPlanesPL::CutWithPlane(myAppendPolyData, GetMergedInput(), isFirst ? aVector1 : aVector2, myPoint1); + myAppendPolyData->Update(); + } + else { + vtkAppendPolyData *anAppendPolyData = vtkAppendPolyData::New(); + + VISU_CutPlanesPL::CutWithPlane(anAppendPolyData, GetMergedInput(), aVector1, myPoint1); + vtkDataSet *aDataSet = anAppendPolyData->GetOutput(); + aDataSet->Update(); + + VISU_CutPlanesPL::CutWithPlane(myAppendPolyData, aDataSet, aVector2, myPoint1); + myAppendPolyData->Update(); + + anAppendPolyData->Delete(); + } + + // calculate values for building of table + for (int i = 0; i<3 ; i++) { + myRealDirLn[i] = myDirLn[i] = aVector12[i]; + if(myDirLn[i] < 0.0) + myDirLn[i] = -1.0*myDirLn[i]; //enk:: correction of bug Bug PAL10401 + } + + GetBoundProject(myBoundPrjLn, + aBounds, + myDirLn); + + VISU::Mul(myDirLn, + myBoundPrjLn[0], + myBasePnt); + + CorrectPnt(myBasePnt, + aBounds); + + VISU_ScalarMapPL::Update(); +} diff --git a/src/PIPELINE/VISU_CutSegmentPL.hxx b/src/PIPELINE/VISU_CutSegmentPL.hxx new file mode 100644 index 00000000..9ead72e3 --- /dev/null +++ b/src/PIPELINE/VISU_CutSegmentPL.hxx @@ -0,0 +1,96 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File: VISU_CutSegmentPL.hxx +// Author: Oleg UVAROV +// Module : VISU +// +#ifndef VISU_CutSegmentPL_HeaderFile +#define VISU_CutSegmentPL_HeaderFile + +#include "VISUPipeline.hxx" +#include "VISU_CutLinesBasePL.hxx" + + +//---------------------------------------------------------------------------- +class VISU_PIPELINE_EXPORT VISU_CutSegmentPL : public VISU_CutLinesBasePL +{ +public: + vtkTypeMacro(VISU_CutSegmentPL,VISU_CutLinesBasePL); + + static + VISU_CutSegmentPL* + New(); + + virtual + void + SetPoint1(vtkFloatingPointType theX, + vtkFloatingPointType theY, + vtkFloatingPointType theZ); + + virtual + void + GetPoint1(vtkFloatingPointType& theX, + vtkFloatingPointType& theY, + vtkFloatingPointType& theZ); + + virtual + void + SetPoint2(vtkFloatingPointType theX, + vtkFloatingPointType theY, + vtkFloatingPointType theZ); + + virtual + void + GetPoint2(vtkFloatingPointType& theX, + vtkFloatingPointType& theY, + vtkFloatingPointType& theZ); + +public: + virtual + void + Init(); + + vtkDataSet* + InsertCustomPL(); + + virtual + void + Update(); + +protected: + VISU_CutSegmentPL(); + + virtual + void + DoShallowCopy(VISU_PipeLine *thePipeLine, + bool theIsCopyInput); + + vtkFloatingPointType myPoint1[3]; + vtkFloatingPointType myPoint2[3]; + +private: + VISU_CutSegmentPL(const VISU_CutSegmentPL&); // Not implemented. + void operator=(const VISU_CutSegmentPL&); // Not implemented. +}; + + +#endif diff --git a/src/VISUGUI/Makefile.am b/src/VISUGUI/Makefile.am index 29cb40ee..ab4caa67 100644 --- a/src/VISUGUI/Makefile.am +++ b/src/VISUGUI/Makefile.am @@ -56,6 +56,7 @@ salomeinclude_HEADERS= \ VisuGUI_DeformedShapeDlg.h \ VisuGUI_IsoSurfacesDlg.h \ VisuGUI_CutLinesDlg.h \ + VisuGUI_CutSegmentDlg.h \ VisuGUI_CutPlanesDlg.h \ VisuGUI_StreamLinesDlg.h \ VisuGUI_VectorsDlg.h \ @@ -101,6 +102,7 @@ dist_libVISU_la_SOURCES= \ VisuGUI_DeformedShapeDlg.cxx \ VisuGUI_IsoSurfacesDlg.cxx \ VisuGUI_CutLinesDlg.cxx \ + VisuGUI_CutSegmentDlg.cxx \ VisuGUI_CutPlanesDlg.cxx \ VisuGUI_StreamLinesDlg.cxx \ VisuGUI_VectorsDlg.cxx \ @@ -148,6 +150,7 @@ MOC_FILES= \ VisuGUI_DeformedShapeDlg_moc.cxx \ VisuGUI_IsoSurfacesDlg_moc.cxx \ VisuGUI_CutLinesDlg_moc.cxx \ + VisuGUI_CutSegmentDlg_moc.cxx \ VisuGUI_CutPlanesDlg_moc.cxx \ VisuGUI_StreamLinesDlg_moc.cxx \ VisuGUI_VectorsDlg_moc.cxx \ diff --git a/src/VISUGUI/VISU_images.ts b/src/VISUGUI/VISU_images.ts index 143e7563..a5b74650 100644 --- a/src/VISUGUI/VISU_images.ts +++ b/src/VISUGUI/VISU_images.ts @@ -53,6 +53,10 @@ ICON_CUT_LINES Visu_cutlines.png + + ICON_CUT_SEGMENT + Visu_cutsegment.png + ICON_CUT_PLANES Visu_cutplanes.png @@ -231,6 +235,14 @@ ICON_TREE_CUT_LINES_GROUPS Visu_tree_cutlines_gr.png + + ICON_TREE_CUT_SEGMENT + Visu_tree_cutsegment.png + + + ICON_TREE_CUT_SEGMENT_GROUPS + Visu_tree_cutsegment_gr.png + ICON_TREE_CUT_PLANES Visu_tree_cutplanes.png diff --git a/src/VISUGUI/VISU_msg_en.ts b/src/VISUGUI/VISU_msg_en.ts index 6e63b378..16a5edf9 100644 --- a/src/VISUGUI/VISU_msg_en.ts +++ b/src/VISUGUI/VISU_msg_en.ts @@ -133,14 +133,22 @@ number of time stamps or number of components is not the same! VISU_COS_SWEEP Cosinusoidal ( (1 - cos(t))/2 ) - - VISU_CUT_LINES_PREF - Cut Lines preferences - VISU_CUT_LINES Cut Lines + + VISU_CUT_LINES_SEGMENT + Cut Lines/Segment + + + VISU_CUT_LINES_SEGMENT_PREF + Cut Lines/Segment preferences + + + VISU_CUT_SEGMENT + Cut Segment + VISU_CUT_PLANES Cut Planes @@ -1037,6 +1045,10 @@ Please, refer to the documentation. MEN_CUT_LINES Cut Lines + + MEN_CUT_SEGMENT + Cut Segment + MEN_CUT_PLANES Cut Planes @@ -1780,6 +1792,57 @@ Please, provide non-empty resulting presentation. Orientation + + VisuGUI_CutSegmentDlg + + LBL_ABSOLUTE_LENGTH + Use absolute length + + + LBL_CUT_SEGMENT + Cut Segment + + + LBL_GENERATE_CURVES + Generate Curve + + + LBL_GENERATE_TABLE + Generate Data Table + + + LBL_INVERT_CURVES + Invert curve + + + LBL_POINT_1 + Point 1: + + + LBL_POINT_2 + Point 2: + + + LBL_SEGMENT + Segment + + + LBL_SHOW_PREVIEW + Show preview + + + LBL_X + X + + + LBL_Y + Y + + + LBL_Z + Z + + VisuGUI_CutPlanesDlg diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index afaa6c43..bbaaa4e7 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -139,6 +139,9 @@ #include "VISU_CutLines_i.hh" #include "VisuGUI_CutLinesDlg.h" +#include "VISU_CutSegment_i.hh" +#include "VisuGUI_CutSegmentDlg.h" + #include "VISU_StreamLines_i.hh" #include "VisuGUI_StreamLinesDlg.h" @@ -599,14 +602,26 @@ void VisuGUI::OnLoadComponentData() void CreateCurves( SalomeApp_Module* theModule, - VISU::CutLines_i* thePrs, + VISU::CutLinesBase_i* thePrs, QDialog* theDlg, const bool theCreate = true ) { if ( !thePrs ) return; - VisuGUI_CutLinesDlg* aCutDlg = dynamic_cast( theDlg ); - if ( !aCutDlg ) + + // temporary code, to be revised (VisuGUI_CutLinesDlg and VisuGUI_CutSegmentDlg classes + // should have common intermediate interface with at least two methods called below) + bool isGenerateTable = false; + bool isGenerateCurves = false; + if ( VisuGUI_CutLinesDlg* aCutDlg = dynamic_cast( theDlg ) ) { + isGenerateTable = aCutDlg->isGenerateTable(); + isGenerateCurves = aCutDlg->isGenerateCurves(); + } + else if ( VisuGUI_CutSegmentDlg* aCutDlg = dynamic_cast( theDlg ) ) { + isGenerateTable = aCutDlg->isGenerateTable(); + isGenerateCurves = aCutDlg->isGenerateCurves(); + } + else return; _PTR(Study) aStudy = GetCStudy( GetAppStudy( theModule ) ); @@ -650,9 +665,9 @@ CreateCurves( SalomeApp_Module* theModule, } } - if ( aCutDlg->isGenerateTable() ) { + if ( isGenerateTable ) { GetVisuGen( theModule )->CreateTable( thePrs->GetEntry().c_str() ); - if ( aCutDlg->isGenerateCurves() ) { + if ( isGenerateCurves ) { if ( aSObject ) { _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder(); _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject); @@ -795,6 +810,15 @@ VisuGUI emit presentationCreated(aPrs); } +void +VisuGUI +::OnCreateCutSegment() +{ + Prs3d_i* aPrs = CreatePrs3d(this); + if (aPrs) + emit presentationCreated(aPrs); +} + void VisuGUI ::OnCreateStreamLines() @@ -1080,6 +1104,16 @@ VisuGUI EditPrs3d(this, anIO, aPrs3d); } +//---------------------------------------------------------------------------- +void +VisuGUI +::OnEditCutSegment() +{ + Handle(SALOME_InteractiveObject) anIO; + if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO)) + EditPrs3d(this, anIO, aPrs3d); +} + //---------------------------------------------------------------------------- void VisuGUI @@ -1464,7 +1498,9 @@ VisuGUI _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject; VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase; - if((aBase && aBase->GetType() == VISU::TCUTLINES) || IsSObjectTable(aSObject)) { + if(aBase && + (aBase->GetType() == VISU::TCUTLINES || aBase->GetType() == VISU::TCUTSEGMENT) || + IsSObjectTable(aSObject)) { GetVisuGen( this )->CreateTable( aSObject->GetID().c_str() ); UpdateObjBrowser(this); } @@ -1884,7 +1920,7 @@ VisuGUI QString aStr = aSel.parameter(i, "type" ).toString(); if (aStr == "VISU::TSCALARMAP" || aStr == "VISU::TISOSURFACES" || aStr == "VISU::TDEFORMEDSHAPE" || aStr == "VISU::TCUTPLANES" || - aStr == "VISU::TCUTLINES" || aStr == "VISU::TVECTORS" || + aStr == "VISU::TCUTLINES" || aStr == "VISU::TCUTSEGMENT" || aStr == "VISU::TVECTORS" || aStr == "VISU::TSTREAMLINES" || aStr == "VISU::TPLOT3D" || aStr == "VISU::TSCALARMAPONDEFORMEDSHAPE" || aStr == "VISU::TCOLOREDPRS3DHOLDER" || aStr == "VISU::TTABLE" || aStr == "VISU::TCURVE" || aStr == "VISU::TCONTAINER" || @@ -2097,6 +2133,9 @@ VisuGUI case VISU::TCUTLINES: TSameAsFactory().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp, false); break; + case VISU::TCUTSEGMENT: + TSameAsFactory().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp, false); + break; case VISU::TISOSURFACES: TSameAsFactory().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp, false); break; @@ -2380,6 +2419,11 @@ VisuGUI tr("MEN_CUT_LINES"), "", 0, aParent, false, this, SLOT(OnCreateCutLines())); + aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_SEGMENT")); + createAction( VISU_CUT_SEGMENT, tr("MEN_CUT_SEGMENT"), QIcon(aPixmap), + tr("MEN_CUT_SEGMENT"), "", 0, aParent, false, + this, SLOT(OnCreateCutSegment())); + aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT_3D")); createAction( VISU_PLOT_3D, tr("MEN_PLOT_3D"), QIcon(aPixmap), tr("MEN_PLOT_3D"), "", 0, aParent, false, @@ -2585,6 +2629,10 @@ VisuGUI tr("MEN_EDIT_PRS"), "", 0, aParent, false, this, SLOT(OnEditCutLines())); + createAction( VISU_EDIT_CUTSEGMENT, tr("MEN_EDIT_PRS"), QIcon(), + tr("MEN_EDIT_PRS"), "", 0, aParent, false, + this, SLOT(OnEditCutSegment())); + createAction( VISU_EDIT_ISOSURFACES, tr("MEN_EDIT_PRS"), QIcon(), tr("MEN_EDIT_PRS"), "", 0, aParent, false, this, SLOT(OnEditIsoSurfaces())); @@ -2745,6 +2793,7 @@ VisuGUI createMenu( VISU_ISO_SURFACES, aMenuId, 10 ); // iso surfaces createMenu( VISU_CUT_PLANES, aMenuId, 10 ); // cut planes createMenu( VISU_CUT_LINES, aMenuId, 10 ); // cut lines + createMenu( VISU_CUT_SEGMENT, aMenuId, 10 ); // cut segment createMenu( VISU_STREAM_LINES, aMenuId, 10 ); // stream lines createMenu( VISU_PLOT_3D, aMenuId, 10 ); // Plot3d createMenu( VISU_DEFORMED_SHAPE_AND_SCALAR_MAP, aMenuId, 10 ); // scalar map on deformed shape @@ -2777,6 +2826,7 @@ VisuGUI createTool( VISU_ISO_SURFACES, aToolId ); createTool( VISU_CUT_PLANES, aToolId ); createTool( VISU_CUT_LINES, aToolId ); + createTool( VISU_CUT_SEGMENT, aToolId ); createTool( VISU_STREAM_LINES, aToolId ); createTool( VISU_PLOT_3D, aToolId ); createTool( VISU_DEFORMED_SHAPE_AND_SCALAR_MAP, aToolId ); @@ -2820,6 +2870,7 @@ VisuGUI mgr->insert( action( VISU_ISO_SURFACES ), -1, -1, -1 ); // iso surface mgr->insert( action( VISU_CUT_PLANES ), -1, -1, -1 ); // cut planes mgr->insert( action( VISU_CUT_LINES ), -1, -1, -1 ); // cut lines + mgr->insert( action( VISU_CUT_SEGMENT ), -1, -1, -1 ); // cut segment mgr->insert( action( VISU_DEFORMED_SHAPE ), -1, -1, -1 ); // deformed shape mgr->insert( action( VISU_VECTORS ), -1, -1, -1 ); // vectors mgr->insert( action( VISU_STREAM_LINES ), -1, -1, -1 ); // stream lines @@ -2836,6 +2887,7 @@ VisuGUI mgr->insert( action( VISU_EDIT_DEFORMEDSHAPE ), -1, -1, -1 ); mgr->insert( action( VISU_EDIT_CUTPLANES ), -1, -1, -1 ); mgr->insert( action( VISU_EDIT_CUTLINES ), -1, -1, -1 ); + mgr->insert( action( VISU_EDIT_CUTSEGMENT ), -1, -1, -1 ); mgr->insert( action( VISU_EDIT_ISOSURFACES ), -1, -1, -1 ); mgr->insert( action( VISU_EDIT_VECTORS ), -1, -1, -1 ); mgr->insert( action( VISU_EDIT_STREAMLINES ), -1, -1, -1 ); @@ -2938,10 +2990,10 @@ VisuGUI // Rules QString aPrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACES' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' " - "'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' " + "'VISU::TCUTLINES' 'VISU::TCUTSEGMENT' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' " "'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP' 'VISU::TCOLOREDPRS3DHOLDER'"); QString aSimplePrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACES' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' " - "'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' " + "'VISU::TCUTLINES' 'VISU::TCUTSEGMENT' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' " "'VISU::TSCALARMAPONDEFORMEDSHAPE'"); // VISU root commands @@ -2956,6 +3008,7 @@ VisuGUI mgr->setRule( action( VISU_ISO_SURFACES ), aRule ); mgr->setRule( action( VISU_CUT_PLANES ), aRule ); mgr->setRule( action( VISU_CUT_LINES ), aRule ); + mgr->setRule( action( VISU_CUT_SEGMENT ), aRule ); mgr->setRule( action( VISU_PLOT_3D ), aRule ); aRule += " and nbComponents>1"; mgr->setRule( action( VISU_DEFORMED_SHAPE ), aRule ); @@ -3039,7 +3092,7 @@ VisuGUI " 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP' 'VISU::TPOINTMAP3D'}"; QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE' 'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP' 'VISU::TPOINTMAP3D'}"; QString aLineType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TSCALARMAP' 'VISU::TISOSURFACES' 'VISU::TDEFORMEDSHAPE' " - "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP' 'VISU::TPOINTMAP3D'}"; + "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TCUTSEGMENT' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TDEFORMEDSHAPEANDSCALARMAP' 'VISU::TPOINTMAP3D'}"; QString aFeatureEdgesType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP''VISU::TDEFORMEDSHAPE' 'VISU::TSCALARMAPONDEFORMEDSHAPE'}"; @@ -3112,6 +3165,8 @@ VisuGUI "selcount=1 and type='VISU::TCUTPLANES'" ); mgr->setRule( action( VISU_EDIT_CUTLINES ), "selcount=1 and type='VISU::TCUTLINES'" ); + mgr->setRule( action( VISU_EDIT_CUTSEGMENT ), + "selcount=1 and type='VISU::TCUTSEGMENT'" ); mgr->setRule( action( VISU_EDIT_ISOSURFACES ), "selcount=1 and type='VISU::TISOSURFACES'" ); mgr->setRule( action( VISU_EDIT_VECTORS ), @@ -3123,7 +3178,7 @@ VisuGUI mgr->setRule( action( VISU_EDIT_POINTMAP3D ), "selcount=1 and type='VISU::TPOINTMAP3D'" ); - aRule = "selcount=1 and type='VISU::TCUTLINES' and nbNamedChildren=0"; + aRule = "selcount=1 and $type in {'VISU::TCUTLINES' 'VISU::TCUTSEGMENT'} and nbNamedChildren=0"; mgr->setRule( action( VISU_CREATE_TABLE ), aRule ); aRule = "selcount=1 and ($type in {" + aSimplePrsAll + "})"; @@ -3686,10 +3741,10 @@ void VisuGUI::createPreferences() setPreferenceProperty( bhh, "max", 100 ); // TAB: "CutLines" - int cutLineTab = addPreference( tr( "VISU_CUT_LINES" ) ); + int cutLineTab = addPreference( tr( "VISU_CUT_LINES_SEGMENT" ) ); // group: "CutLines preferences" - int cutLineGr = addPreference( tr( "VISU_CUT_LINES_PREF" ), cutLineTab ); + int cutLineGr = addPreference( tr( "VISU_CUT_LINES_SEGMENT_PREF" ), cutLineTab ); setPreferenceProperty( cutLineGr, "columns", 1 ); addPreference( tr( "Show preview" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "show_preview" ); addPreference( tr( "Invert all curves" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "invert_all_curves" ); @@ -3851,6 +3906,13 @@ void VisuGUI::createPreferences() setPreferenceProperty( sp, "hstretch", 0 ); setPreferenceProperty( sp, "vstretch", 0 ); + int cut_segment_represent = addPreference( tr( "VISU_CUT_SEGMENT" ), representGr, LightApp_Preferences::Selector, "VISU", "cut_segment_represent" ); + setPreferenceProperty( cut_segment_represent, "strings", modes3 ); + setPreferenceProperty( cut_segment_represent, "indexes", indices3 ); + sp = addPreference( "", representGr, LightApp_Preferences::Space ); + setPreferenceProperty( sp, "hstretch", 0 ); + setPreferenceProperty( sp, "vstretch", 0 ); + int deformed_shape_represent = addPreference( tr( "VISU_DEFORMED_SHAPE" ), representGr, LightApp_Preferences::Selector, "VISU", "deformed_shape_represent" ); setPreferenceProperty( deformed_shape_represent, "strings", modes0 ); setPreferenceProperty( deformed_shape_represent, "indexes", indices0 ); diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index 58d8f2ce..dff83e2f 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -110,6 +110,7 @@ protected slots: void OnCreateIsoSurfaces(); void OnCreateCutPlanes(); void OnCreateCutLines(); + void OnCreateCutSegment(); void OnCreateStreamLines(); void OnCreatePlot3D(); void OnCreateManyMesh(); @@ -120,6 +121,7 @@ protected slots: void OnEditDeformedShape(); void OnEditCutPlanes(); void OnEditCutLines(); + void OnEditCutSegment(); void OnEditIsoSurfaces(); void OnEditVectors(); void OnEditStreamLines(); diff --git a/src/VISUGUI/VisuGUI_ActionsDef.h b/src/VISUGUI/VisuGUI_ActionsDef.h index 184aee88..e0bc6e7b 100644 --- a/src/VISUGUI/VisuGUI_ActionsDef.h +++ b/src/VISUGUI/VisuGUI_ActionsDef.h @@ -39,6 +39,7 @@ #define VISU_CUT_PLANES 4015 #define VISU_STREAM_LINES 4016 #define VISU_CUT_LINES 4017 +#define VISU_CUT_SEGMENT 40181 // like in VISU_en.xml #define VISU_PLOT2D 4018 #define VISU_PLOT_3D 4019 #define VISU_DEFORMED_SHAPE_AND_SCALAR_MAP 40110 @@ -96,6 +97,7 @@ #define VISU_EDIT_DEFORMEDSHAPE 40621 #define VISU_EDIT_CUTPLANES 40622 #define VISU_EDIT_CUTLINES 40623 +#define VISU_EDIT_CUTSEGMENT 406231 #define VISU_EDIT_ISOSURFACES 40624 #define VISU_EDIT_VECTORS 40625 #define VISU_EDIT_STREAMLINES 40626 diff --git a/src/VISUGUI/VisuGUI_CutSegmentDlg.cxx b/src/VISUGUI/VisuGUI_CutSegmentDlg.cxx new file mode 100644 index 00000000..764f8104 --- /dev/null +++ b/src/VISUGUI/VisuGUI_CutSegmentDlg.cxx @@ -0,0 +1,514 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : VisuGUI_CutSegmentDlg.cxx +// Author : Oleg UVAROV +// Module : VISU +// +#include "VisuGUI_CutSegmentDlg.h" + +#include "VisuGUI.h" +#include "VisuGUI_Tools.h" +#include "VisuGUI_ViewTools.h" +#include "VisuGUI_InputPane.h" + +#include "VISU_Gen_i.hh" +#include "VISU_CutSegment_i.hh" +#include "VISU_ColoredPrs3dFactory.hh" + +#include "VISU_PipeLine.hxx" +#include "VISU_CutSegmentPL.hxx" + +#include "SVTK_ViewWindow.h" + +#include "LightApp_Application.h" +#include "SalomeApp_Study.h" + +#include "SUIT_ResourceMgr.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +VisuGUI_CutSegmentDlg::VisuGUI_CutSegmentDlg (SalomeApp_Module* theModule) + : VisuGUI_ScalarBarBaseDlg(theModule), + myPreviewActor(0), + myPreviewActorGlyphs(0), + myPreviewActorPoints(0) +{ + setWindowTitle("Cut Segment Definition"); + setSizeGripEnabled(true); + + QVBoxLayout* aMainLayout = new QVBoxLayout (this); + aMainLayout->setMargin( 7 ); + aMainLayout->setSpacing(5); + + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + hasInit = false; + + // Tab pane + myTabBox = new QTabWidget(this); + + // Cut Segment + QFrame* aCutSegmentPane = new QFrame( this ); + + QGroupBox* aSegmentBox = new QGroupBox( tr( "LBL_SEGMENT" ), aCutSegmentPane ); + + QLabel* aPoint1Label = new QLabel( tr( "LBL_POINT_1" ), aSegmentBox ); + QLabel* aPoint1XLabel = new QLabel( tr( "LBL_X" ), aSegmentBox ); + QLabel* aPoint1YLabel = new QLabel( tr( "LBL_Y" ), aSegmentBox ); + QLabel* aPoint1ZLabel = new QLabel( tr( "LBL_Z" ), aSegmentBox ); + QLabel* aPoint2Label = new QLabel( tr( "LBL_POINT_2" ), aSegmentBox ); + QLabel* aPoint2XLabel = new QLabel( tr( "LBL_X" ), aSegmentBox ); + QLabel* aPoint2YLabel = new QLabel( tr( "LBL_Y" ), aSegmentBox ); + QLabel* aPoint2ZLabel = new QLabel( tr( "LBL_Z" ), aSegmentBox ); + for( int i = 0; i < 3; i++ ) { + myPoint1.append( new QtxDoubleSpinBox( aSegmentBox ) ); + myPoint2.append( new QtxDoubleSpinBox( aSegmentBox ) ); + } + + QListIterator anIter( myPoint1 + myPoint2 ); + while( anIter.hasNext() ) { + QtxDoubleSpinBox* aSpinBox = anIter.next(); + aSpinBox->setDecimals( 6 ); + aSpinBox->setMinimumWidth( 100 ); + } + + QGridLayout* aSegmentBoxLayout = new QGridLayout( aSegmentBox ); + aSegmentBoxLayout->addWidget( aPoint1Label, 0, 0 ); + aSegmentBoxLayout->addWidget( aPoint1XLabel, 0, 1 ); + aSegmentBoxLayout->addWidget( myPoint1[0], 0, 2 ); + aSegmentBoxLayout->addWidget( aPoint1YLabel, 0, 3 ); + aSegmentBoxLayout->addWidget( myPoint1[1], 0, 4 ); + aSegmentBoxLayout->addWidget( aPoint1ZLabel, 0, 5 ); + aSegmentBoxLayout->addWidget( myPoint1[2], 0, 6 ); + aSegmentBoxLayout->addWidget( aPoint2Label, 1, 0 ); + aSegmentBoxLayout->addWidget( aPoint2XLabel, 1, 1 ); + aSegmentBoxLayout->addWidget( myPoint2[0], 1, 2 ); + aSegmentBoxLayout->addWidget( aPoint2YLabel, 1, 3 ); + aSegmentBoxLayout->addWidget( myPoint2[1], 1, 4 ); + aSegmentBoxLayout->addWidget( aPoint2ZLabel, 1, 5 ); + aSegmentBoxLayout->addWidget( myPoint2[2], 1, 6 ); + + myPreviewCheck = new QCheckBox( tr( "LBL_SHOW_PREVIEW" ), aCutSegmentPane ); + myPreviewCheck->setChecked( aResourceMgr->booleanValue( "VISU", "show_preview", false ) ); + + myAllCurvesInvertedCheck = new QCheckBox( tr( "LBL_INVERT_CURVES" ), aCutSegmentPane ); + myAllCurvesInvertedCheck->setChecked( false ); + + myUseAbsoluteLengthCheck = new QCheckBox( tr( "LBL_ABSOLUTE_LENGTH" ), aCutSegmentPane ); + myUseAbsoluteLengthCheck->setChecked( false ); + + myCreateTable = new QCheckBox( tr("LBL_GENERATE_TABLE"), aCutSegmentPane ); + myCreateTable->setChecked( aResourceMgr->booleanValue( "VISU", "generate_data_table", true ) ); + + QWidget* aCheckPane = new QWidget( aCutSegmentPane ); + myCurvesCheck = new QCheckBox( tr( "LBL_GENERATE_CURVES" ), aCheckPane ); + myCurvesCheck->setChecked( aResourceMgr->booleanValue( "VISU", "generate_curves", true ) ); + myCurvesCheck->setEnabled( aResourceMgr->booleanValue( "VISU", "generate_data_table", true ) ); + + QHBoxLayout* aCheckLayout = new QHBoxLayout( aCheckPane ); + aCheckLayout->setMargin( 0 ); + aCheckLayout->setSpacing( 0 ); + aCheckLayout->insertSpacing( 0, 20 ); + aCheckLayout->addWidget( myCurvesCheck ); + + QVBoxLayout* aCutSegmentLayout = new QVBoxLayout( aCutSegmentPane ); + aCutSegmentLayout->setMargin( 5 ); + aCutSegmentLayout->setSpacing( 6 ); + aCutSegmentLayout->addWidget( aSegmentBox ); + aCutSegmentLayout->addWidget( myPreviewCheck ); + aCutSegmentLayout->addWidget( myAllCurvesInvertedCheck ); + aCutSegmentLayout->addWidget( myUseAbsoluteLengthCheck ); + aCutSegmentLayout->addWidget( myCreateTable ); + aCutSegmentLayout->addWidget( aCheckPane ); + aCutSegmentLayout->addStretch(); + + myTabBox->addTab( aCutSegmentPane, tr("LBL_CUT_SEGMENT") ); + + myInputPane = new VisuGUI_InputPane(VISU::TCUTSEGMENT, theModule, this); + myTabBox->addTab(GetScalarPane(), "Scalar Bar"); + myTabBox->addTab(myInputPane, "Input"); + + aMainLayout->addWidget(myTabBox); + + // Dialog buttons + QFrame* aBtnBox = new QFrame(this); + QHBoxLayout* aHBLay = new QHBoxLayout( aBtnBox ); + aBtnBox->setFrameStyle(QFrame::Box | QFrame::Sunken); + aBtnBox->setLineWidth( 1 ); + aHBLay->setSpacing( 5 ); + aHBLay->setMargin( 11 ); + + QPushButton* aOkBtn = new QPushButton (tr("BUT_OK"), aBtnBox); + aOkBtn->setAutoDefault( TRUE ); + aOkBtn->setDefault( true ); + aHBLay->addWidget(aOkBtn); + + aHBLay->addStretch(); + + QPushButton* aCloseBtn = new QPushButton(tr("BUT_CANCEL"), aBtnBox); + aHBLay->addWidget(aCloseBtn); + + QPushButton* aHelpBtn = new QPushButton(tr("BUT_HELP"), aBtnBox); + aHBLay->addWidget(aHelpBtn); + + aMainLayout->addWidget(aBtnBox); + + // signals and slots connections + connect(myPreviewCheck, SIGNAL(toggled(bool)) , this, SLOT(onPreviewCheck(bool))); + connect(myAllCurvesInvertedCheck, SIGNAL(toggled(bool)),this, SLOT(onAllCurvesInvertedCheck(bool))); + for( int i = 0; i < 3; i++ ) { + connect(myPoint1[ i ], SIGNAL(valueChanged(double)), this, SLOT(onPointModified())); + connect(myPoint2[ i ], SIGNAL(valueChanged(double)), this, SLOT(onPointModified())); + } + connect(myCreateTable , SIGNAL(toggled(bool)), myCurvesCheck, SLOT(setEnabled(bool))); + + connect(aOkBtn, SIGNAL(clicked()), this, SLOT(accept())); + connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(reject())); + connect(aHelpBtn, SIGNAL(clicked()), this, SLOT(onHelp())); +} + +/*! + Destructor +*/ +VisuGUI_CutSegmentDlg::~VisuGUI_CutSegmentDlg() +{ + deletePlanes(); + if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow()) + vf->Repaint(); +} + +//------------------------------------------------------------------------------ +void VisuGUI_CutSegmentDlg::initFromPrsObject ( VISU::ColoredPrs3d_i* thePrs, + bool theInit ) +{ + if( theInit ) + myPrsCopy = VISU::TSameAsFactory().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish); + + VisuGUI_ScalarBarBaseDlg::initFromPrsObject(myPrsCopy, theInit); + + hasInit = true; + myCutSegment = VISU::TSameAsFactory().Create(myPrsCopy, VISU::ColoredPrs3d_i::EDoNotPublish); + myCutSegment->CopyCurvesInverted(myPrsCopy->GetCurvesInverted()); + myAllCurvesInvertedCheck->setChecked( myCutSegment->IsAllCurvesInverted() ); + myUseAbsoluteLengthCheck->setChecked( myCutSegment->IsUseAbsoluteLength() ); + + vtkDataSet* anInput = myCutSegment->GetPipeLine()->GetInput(); + anInput->Update(); + + vtkFloatingPointType bounds[6]; + anInput->GetBounds( bounds ); + + for( int i = 0; i < 3; i++ ) { + double min = bounds[ 2*i ], max = bounds[ 2*i+1 ]; + myPoint1[ i ]->setRange( min, max ); + myPoint2[ i ]->setRange( min, max ); + + myPoint1[ i ]->setSingleStep( ( max - min ) / 10 ); + myPoint2[ i ]->setSingleStep( ( max - min ) / 10 ); + } + + double p1[3], p2[3]; + myPrsCopy->GetPoint1( p1[0], p1[1], p1[2] ); + myPrsCopy->GetPoint2( p2[0], p2[1], p2[2] ); + + for( int i = 0; i < 3; i++ ) { + myPoint1[i]->setValue( p1[i] ); + myPoint2[i]->setValue( p2[i] ); + } + + // Draw Preview + if (myPreviewCheck->isChecked()) { + createPlanes(); + } + + if( !theInit ) + return; + + myInputPane->initFromPrsObject( myPrsCopy ); + myTabBox->setCurrentIndex( 0 ); +} + +//------------------------------------------------------------------------------ +int VisuGUI_CutSegmentDlg::storeToPrsObject (VISU::ColoredPrs3d_i* thePrs) +{ + if(!myInputPane->check() || !GetScalarPane()->check()) + return 0; + + int anIsOk = myInputPane->storeToPrsObject( myPrsCopy ); + anIsOk &= GetScalarPane()->storeToPrsObject( myPrsCopy ); + + myPrsCopy->SetAllCurvesInverted( myAllCurvesInvertedCheck->isChecked() ); + myPrsCopy->SetUseAbsoluteLength( myUseAbsoluteLengthCheck->isChecked() ); + + double p1[3], p2[3]; + for( int i = 0; i < 3; i++ ) { + p1[i] = myPoint1[i]->value(); + p2[i] = myPoint2[i]->value(); + } + myPrsCopy->SetPoint1( p1[0], p1[1], p1[2] ); + myPrsCopy->SetPoint2( p2[0], p2[1], p2[2] ); + + VISU::TSameAsFactory().Copy(myPrsCopy, thePrs); + + return anIsOk; +} + +//------------------------------------------------------------------------------ +void VisuGUI_CutSegmentDlg::createPlanes() +{ + SVTK_ViewWindow* aView = VISU::GetActiveViewWindow(); + if (aView == NULL) return; + if (!(bool)myCutSegment) return; + if (myPreviewActor != 0) return; + + storeToPrsObject(myCutSegment); + myCutSegment->GetPipeLine()->Update(); + vtkAppendPolyData* aPolyData = myCutSegment->GetSpecificPL()->GetAppendPolyData(); + vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New(); + aPlaneMapper->SetInput(aPolyData->GetOutput()); + aPlaneMapper->ScalarVisibilityOff(); + + myPreviewActorGlyphs = SALOME_Actor::New(); + myPreviewActorGlyphs->PickableOff(); + updateGlyphs(false); + + myPreviewActorPoints = SALOME_Actor::New(); + myPreviewActorPoints->PickableOff(); + updatePoints(false); + + myPreviewActor = SALOME_Actor::New(); + myPreviewActor->PickableOff(); + myPreviewActor->SetMapper(aPlaneMapper); + aPlaneMapper->Delete(); + aView->AddActor(myPreviewActor); + aView->AddActor(myPreviewActorGlyphs); + aView->AddActor(myPreviewActorPoints); + aView->getRenderer()->Render(); + aView->onFitAll(); +} + +//------------------------------------------------------------------------------ +void VisuGUI_CutSegmentDlg::deletePlanes() +{ + if (myPreviewActor == 0) return; + vtkRenderer* aRend = myPreviewActor->GetRenderer(); + vtkRenderer* aRendGlyphs = myPreviewActorGlyphs->GetRenderer(); + vtkRenderer* aRendPoints = myPreviewActorPoints->GetRenderer(); + + vtkRenderWindow* aWnd1 = aRend->GetRenderWindow(); + vtkRenderWindow* aWnd2 = aRendGlyphs->GetRenderWindow(); + vtkRenderWindow* aWnd3 = aRendPoints->GetRenderWindow(); + if(aRend && aWnd1) + myPreviewActor->RemoveFromRender(aRend); + if(aRendGlyphs && aWnd2) + myPreviewActorGlyphs->RemoveFromRender(aRendGlyphs); + if(aRendPoints && aWnd3) + myPreviewActorPoints->RemoveFromRender(aRendPoints); + + myPreviewActor->Delete(); + myPreviewActorGlyphs->Delete(); + myPreviewActorPoints->Delete(); + myPreviewActor = 0; + myPreviewActorGlyphs = 0; + myPreviewActorPoints = 0; +} + +//------------------------------------------------------------------------------ +void VisuGUI_CutSegmentDlg::updateGlyphs(bool update){ + if (myPreviewActorGlyphs == 0 ) return; + const vtkFloatingPointType *aDirLn = myCutSegment->GetSpecificPL()->GetRealDirLn(); + vtkFloatingPointType aSecondPnt[3]; + vtkFloatingPointType aBoundCenter[3]; + + vtkAppendPolyData* aPolyData = myCutSegment->GetSpecificPL()->GetAppendPolyData(); + vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New(); + aPlaneMapper->SetInput(aPolyData->GetOutput()); + vtkFloatingPointType bounds[6]; + aPlaneMapper->GetBounds(bounds); + + for(int i=0; i<3; i++) aBoundCenter[i] = (bounds[i*2] + bounds[i*2+1])/2.0; + for(int i=0; i<3; i++){ + if (!myAllCurvesInvertedCheck->isChecked()) + aSecondPnt[i] = aDirLn[i]; + else + aSecondPnt[i] = - aDirLn[i]; + } + + vtkFloatingPointType max_bound = 0; + max_bound < bounds[1]-bounds[0] ? max_bound = bounds[1] - bounds[0] : max_bound = max_bound; + max_bound < bounds[3]-bounds[2] ? max_bound = bounds[3] - bounds[2] : max_bound = max_bound; + max_bound < bounds[5]-bounds[4] ? max_bound = bounds[5] - bounds[4] : max_bound = max_bound; + + vtkPolyData* profile = vtkPolyData::New(); + vtkPoints* aPoints = vtkPoints::New(); + vtkGlyph3D* glyphs = vtkGlyph3D::New(); + vtkFloatArray *aFloatArray = vtkFloatArray::New(); + vtkGlyphSource2D* source = vtkGlyphSource2D::New(); + + source->FilledOn(); + source->SetGlyphTypeToArrow(); + + aPoints->InsertNextPoint(aBoundCenter); + profile->SetPoints(aPoints); + + aFloatArray->SetNumberOfComponents(3); + for(int i=0; i<3 ;i++) + aFloatArray->InsertNextValue(aSecondPnt[i]); + + vtkDataSetAttributes* aDataSetAttributes; + aDataSetAttributes = profile->GetPointData(); + aDataSetAttributes->SetVectors(aFloatArray); + + glyphs->SetScaleFactor(0.25*max_bound); + glyphs->SetVectorModeToUseVector(); + glyphs->SetScaleModeToScaleByVector(); + glyphs->SetInput(profile); + glyphs->SetSource(source->GetOutput()); + + vtkPolyDataMapper* aGlyphsMapper = vtkPolyDataMapper::New(); + aGlyphsMapper->ScalarVisibilityOff(); + aGlyphsMapper->SetInput(glyphs->GetOutput()); + + myPreviewActorGlyphs->SetMapper(aGlyphsMapper); + + profile->Delete(); + glyphs->Delete(); + aPoints->Delete(); + aGlyphsMapper->Delete(); + aFloatArray->Delete(); + source->Delete(); + aPlaneMapper->Delete(); + + if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow()) + if (update) + vf->Repaint(); +} + +//------------------------------------------------------------------------------ +void VisuGUI_CutSegmentDlg::updatePoints( bool update ) +{ + if( !myPreviewActorPoints ) + return; + + vtkFloatingPointType aPoint1[3], aPoint2[3]; + myCutSegment->GetSpecificPL()->GetPoint1( aPoint1[0], aPoint1[1], aPoint1[2] ); + myCutSegment->GetSpecificPL()->GetPoint2( aPoint2[0], aPoint2[1], aPoint2[2] ); + + vtkPoints* aPoints = vtkPoints::New(); + aPoints->InsertNextPoint( aPoint1 ); + aPoints->InsertNextPoint( aPoint2 ); + + vtkCellArray* aVerts = vtkCellArray::New(); + for( int i = 0, n = aPoints->GetNumberOfPoints(); i < n; i++ ) + aVerts->InsertNextCell( 1, &i ); + + vtkPolyData* aProfile = vtkPolyData::New(); + aProfile->SetPoints( aPoints ); + aProfile->SetVerts( aVerts ); + + vtkPolyDataMapper* aPointsMapper = vtkPolyDataMapper::New(); + aPointsMapper->ScalarVisibilityOff(); + aPointsMapper->SetInput( aProfile ); + + myPreviewActorPoints->SetMapper( aPointsMapper ); + myPreviewActorPoints->GetProperty()->SetRepresentationToPoints(); + myPreviewActorPoints->GetProperty()->SetPointSize( 5 ); + + aProfile->Delete(); + aPoints->Delete(); + aVerts->Delete(); + + if( SVTK_ViewWindow* vf = VISU::GetActiveViewWindow() ) + if( update ) + vf->Repaint(); +} + +//------------------------------------------------------------------------------ +void VisuGUI_CutSegmentDlg::accept() +{ + VisuGUI_ScalarBarBaseDlg::accept(); +} + +//------------------------------------------------------------------------------ +void VisuGUI_CutSegmentDlg::reject() +{ + VisuGUI_ScalarBarBaseDlg::reject(); +} + +//------------------------------------------------------------------------------ +void VisuGUI_CutSegmentDlg::onPreviewCheck (bool thePreview) +{ + if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow()) { + if (thePreview) { + createPlanes(); + } else { + deletePlanes(); + vf->Repaint(); + } + } +} + +//------------------------------------------------------------------------------ +void VisuGUI_CutSegmentDlg::onAllCurvesInvertedCheck(bool theInvert) +{ + bool anIsAllCurvesInverted = myAllCurvesInvertedCheck->isChecked(); + + myCutSegment->SetAllCurvesInverted( anIsAllCurvesInverted ); + myPrsCopy->SetAllCurvesInverted( anIsAllCurvesInverted ); + + updateGlyphs(true); + updatePoints(true); +} + +//------------------------------------------------------------------------------ +void VisuGUI_CutSegmentDlg::onPointModified () +{ + if (!(bool)myCutSegment) return; + SVTK_ViewWindow* aView = VISU::GetActiveViewWindow(); + if (aView) { + if (myPreviewCheck->isChecked()) { + deletePlanes(); + createPlanes(); + } + } +} + +//------------------------------------------------------------------------------ +QString VisuGUI_CutSegmentDlg::GetContextHelpFilePath() +{ + return "cut_segment_page.html"; +} diff --git a/src/VISUGUI/VisuGUI_CutSegmentDlg.h b/src/VISUGUI/VisuGUI_CutSegmentDlg.h new file mode 100644 index 00000000..b57762f1 --- /dev/null +++ b/src/VISUGUI/VisuGUI_CutSegmentDlg.h @@ -0,0 +1,101 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : VisuGUI_CutSegmentDlg.h +// Author : Oleg UVAROV +// Module : VISU +// +#ifndef VISUGUI_CUTSEGMENTDLG_H +#define VISUGUI_CUTSEGMENTDLG_H + +#include "VisuGUI_CutPlanesDlg.h" + +#include +#include + +class QTabWidget; + +class SalomeApp_Module; +class VisuGUI_InputPane; + +namespace VISU +{ + class CutSegment_i; +} + +class VisuGUI_CutSegmentDlg: public VisuGUI_ScalarBarBaseDlg +{ + Q_OBJECT + +public: + VisuGUI_CutSegmentDlg (SalomeApp_Module* theModule); + ~VisuGUI_CutSegmentDlg(); + + virtual void initFromPrsObject( VISU::ColoredPrs3d_i* thePrs, + bool theInit ); + + virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs); + + bool isGenerateTable() { return myCreateTable->isChecked(); } + bool isGenerateCurves() { return myCreateTable->isChecked() && myCurvesCheck->isChecked(); } + +protected: + virtual QString GetContextHelpFilePath(); + +protected slots: + void accept(); + void reject(); + +private slots: + void onPreviewCheck(bool thePreview); + void onAllCurvesInvertedCheck(bool theInvert); + void onPointModified(); + +private: + void createPlanes(); + void deletePlanes(); + void updateGlyphs(bool update); + void updatePoints(bool update); + + QCheckBox* myCreateTable; + QCheckBox* myCurvesCheck; + + bool hasInit; + + QList myPoint1; + QList myPoint2; + + SALOME::GenericObjPtr myCutSegment; + + QTabWidget* myTabBox; + VisuGUI_InputPane* myInputPane; + + SALOME_Actor* myPreviewActor; + SALOME_Actor* myPreviewActorGlyphs; + SALOME_Actor* myPreviewActorPoints; + QCheckBox* myPreviewCheck; + QCheckBox* myAllCurvesInvertedCheck; + QCheckBox* myUseAbsoluteLengthCheck; + + SALOME::GenericObjPtr myPrsCopy; +}; + +#endif // VISUGUI_CUTSEGMENTDLG_H diff --git a/src/VISUGUI/VisuGUI_Module.cxx b/src/VISUGUI/VisuGUI_Module.cxx index 86299587..1e9b560c 100644 --- a/src/VISUGUI/VisuGUI_Module.cxx +++ b/src/VISUGUI/VisuGUI_Module.cxx @@ -68,7 +68,7 @@ #include "VISU_Gen_i.hh" #include "VISU_Result_i.hh" -#include "VISU_CutLines_i.hh" +#include "VISU_CutLinesBase_i.hh" #include "VISU_Actor.h" #include "VISU_ScalarMapAct.h" @@ -151,7 +151,7 @@ using namespace std; void CreateCurves( SalomeApp_Module* theModule, - VISU::CutLines_i* thePrs, + VISU::CutLinesBase_i* thePrs, QDialog* theDlg, const bool theCreate = true ); diff --git a/src/VISUGUI/VisuGUI_Prs3dTools.h b/src/VISUGUI/VisuGUI_Prs3dTools.h index c9864171..96aab243 100644 --- a/src/VISUGUI/VisuGUI_Prs3dTools.h +++ b/src/VISUGUI/VisuGUI_Prs3dTools.h @@ -81,7 +81,7 @@ namespace VISU // Optionally, create table and curves for cut lines QApplication::setOverrideCursor(Qt::WaitCursor); CreateCurves( theModule, - dynamic_cast( aPrs3d ), + dynamic_cast( aPrs3d ), aDlg, false ); // in edition mode QApplication::restoreOverrideCursor(); @@ -245,7 +245,7 @@ namespace VISU // Optionally, create table and curves for cut lines QApplication::setOverrideCursor(Qt::WaitCursor); CreateCurves( theModule, - dynamic_cast( aPrs3d ), + dynamic_cast( aPrs3d ), aDlg, true ); // in creation mode UpdateObjBrowser(theModule,true,theTimeStamp); diff --git a/src/VISUGUI/VisuGUI_Selection.cxx b/src/VISUGUI/VisuGUI_Selection.cxx index 3828a0ca..381ad9bc 100644 --- a/src/VISUGUI/VisuGUI_Selection.cxx +++ b/src/VISUGUI/VisuGUI_Selection.cxx @@ -122,6 +122,7 @@ QString VisuGUI_Selection::type( const int ind ) const ENUM2STRING( aResStr, VISU::TSCALARMAPONDEFORMEDSHAPE ); ENUM2STRING( aResStr, VISU::TCUTPLANES ); ENUM2STRING( aResStr, VISU::TCUTLINES ); + ENUM2STRING( aResStr, VISU::TCUTSEGMENT ); ENUM2STRING( aResStr, VISU::TVECTORS ); ENUM2STRING( aResStr, VISU::TSTREAMLINES ); ENUM2STRING( aResStr, VISU::TPLOT3D ); diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index 48022226..c0a9c0e5 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -32,6 +32,7 @@ #include "VisuGUI_DeformedShapeDlg.h" #include "VisuGUI_CutPlanesDlg.h" #include "VisuGUI_CutLinesDlg.h" +#include "VisuGUI_CutSegmentDlg.h" #include "VisuGUI_Plot3DDlg.h" #include "VisuGUI_VectorsDlg.h" #include "VisuGUI_IsoSurfacesDlg.h" @@ -47,6 +48,7 @@ #include "VISU_CutPlanes_i.hh" #include "VISU_Plot3D_i.hh" #include "VISU_CutLines_i.hh" +#include "VISU_CutSegment_i.hh" #include "VISU_Vectors_i.hh" #include "VISU_StreamLines_i.hh" #include "VISU_DeformedShapeAndScalarMap_i.hh" @@ -903,12 +905,13 @@ enum PrsComboItem { TISOSURFACES_ITEM = 1, // VISU::TISOSURFACES TCUTPLANES_ITEM = 2, // VISU::TCUTPLANES TCUTLINES_ITEM = 3, // VISU::TCUTLINES - TPLOT3D_ITEM = 4, // VISU::TPLOT3D - TDEFORMEDSHAPE_ITEM = 5, // VISU::TDEFORMEDSHAPE - TVECTORS_ITEM = 6, // VISU::TVECTORS - TSTREAMLINES_ITEM = 7, // VISU::TSTREAMLINES - TGAUSSPOINTS_ITEM = 8, // VISU::TGAUSSPOINTS - TDEFORMEDSHAPEANDSCALARMAP_ITEM = 9 // VISU::TDEFORMEDSHAPEANDSCALARMAP + TCUTSEGMENT_ITEM = 4, // VISU::TCUTSEGMENT + TPLOT3D_ITEM = 5, // VISU::TPLOT3D + TDEFORMEDSHAPE_ITEM = 6, // VISU::TDEFORMEDSHAPE + TVECTORS_ITEM = 7, // VISU::TVECTORS + TSTREAMLINES_ITEM = 8, // VISU::TSTREAMLINES + TGAUSSPOINTS_ITEM = 9, // VISU::TGAUSSPOINTS + TDEFORMEDSHAPEANDSCALARMAP_ITEM = 10 // VISU::TDEFORMEDSHAPEANDSCALARMAP }; //------------------------------------------------------------------------ @@ -956,7 +959,11 @@ void SetupDlg::onFieldChange (int theIndex) myTypeId2ComboId[TCUTLINES_ITEM] = myComboId2TypeId.size(); myComboId2TypeId.push_back(TCUTLINES_ITEM);; - myTypeCombo->addItem("Plot 3D"); // item 4 + myTypeCombo->addItem("Cut Segment"); // item 4 + myTypeId2ComboId[TCUTSEGMENT_ITEM] = myComboId2TypeId.size(); + myComboId2TypeId.push_back(TCUTSEGMENT_ITEM);; + + myTypeCombo->addItem("Plot 3D"); // item 5 myTypeId2ComboId[TPLOT3D_ITEM] = myComboId2TypeId.size(); myComboId2TypeId.push_back(TPLOT3D_ITEM);; @@ -996,25 +1003,25 @@ void SetupDlg::onFieldChange (int theIndex) } if (anEnableItems) { - myTypeCombo->addItem("Deformed Shape"); // item 5 + myTypeCombo->addItem("Deformed Shape"); // item 6 myTypeId2ComboId[TDEFORMEDSHAPE_ITEM] = myComboId2TypeId.size(); myComboId2TypeId.push_back(TDEFORMEDSHAPE_ITEM);; - myTypeCombo->addItem("Vectors"); // item 6 + myTypeCombo->addItem("Vectors"); // item 7 myTypeId2ComboId[TVECTORS_ITEM] = myComboId2TypeId.size(); myComboId2TypeId.push_back(TVECTORS_ITEM);; - myTypeCombo->addItem("Stream Lines"); // item 7 + myTypeCombo->addItem("Stream Lines"); // item 8 myTypeId2ComboId[TSTREAMLINES_ITEM] = myComboId2TypeId.size(); myComboId2TypeId.push_back(TSTREAMLINES_ITEM);; - myTypeCombo->addItem("Deformed shape and Scalar map"); // item 9 + myTypeCombo->addItem("Deformed shape and Scalar map"); // item 10 myTypeId2ComboId[TDEFORMEDSHAPEANDSCALARMAP_ITEM] = myComboId2TypeId.size(); myComboId2TypeId.push_back(TDEFORMEDSHAPEANDSCALARMAP_ITEM);; } if(anEnableGP){ - myTypeCombo->addItem("Gauss Points"); // item 8 + myTypeCombo->addItem("Gauss Points"); // item 9 myTypeId2ComboId[TGAUSSPOINTS_ITEM] = myComboId2TypeId.size(); myComboId2TypeId.push_back(TGAUSSPOINTS_ITEM);; } @@ -1032,6 +1039,9 @@ void SetupDlg::onFieldChange (int theIndex) case VISU::TCUTLINES: //Cut Lines myTypeCombo->setCurrentIndex(myTypeId2ComboId[TCUTLINES_ITEM]); break; + case VISU::TCUTSEGMENT: //Cut Segment + myTypeCombo->setCurrentIndex(myTypeId2ComboId[TCUTSEGMENT_ITEM]); + break; case VISU::TPLOT3D: //Plot 3D myTypeCombo->setCurrentIndex(myTypeId2ComboId[TPLOT3D_ITEM]); break; @@ -1078,6 +1088,9 @@ void SetupDlg::onTypeChanged (int theIndex) case TCUTLINES_ITEM: //Cut Lines aData.myPrsType = VISU::TCUTLINES; break; + case TCUTSEGMENT_ITEM: //Cut Segment + aData.myPrsType = VISU::TCUTSEGMENT; + break; case TPLOT3D_ITEM: //Plot 3D aData.myPrsType = VISU::TPLOT3D; break; @@ -1195,6 +1208,10 @@ void SetupDlg::onPreferencesDlg() c.suspend(); EditPrs(myModule,aData,myAnimator); break; + case TCUTSEGMENT_ITEM: //Cut Segment + c.suspend(); + EditPrs(myModule,aData,myAnimator); + break; case TPLOT3D_ITEM: //Plot 3D c.suspend(); EditPrs(myModule,aData,myAnimator); diff --git a/src/VISUGUI/VisuGUI_Tools.cxx b/src/VISUGUI/VisuGUI_Tools.cxx index dc16a187..4748228c 100644 --- a/src/VISUGUI/VisuGUI_Tools.cxx +++ b/src/VISUGUI/VisuGUI_Tools.cxx @@ -1355,6 +1355,7 @@ namespace VISU case VISU::TDEFORMEDSHAPE: case VISU::TCUTPLANES: case VISU::TCUTLINES: + case VISU::TCUTSEGMENT: case VISU::TVECTORS: case VISU::TSTREAMLINES: case VISU::TPLOT3D: diff --git a/src/VISU_I/Makefile.am b/src/VISU_I/Makefile.am index 56aad839..960e39b7 100644 --- a/src/VISU_I/Makefile.am +++ b/src/VISU_I/Makefile.am @@ -47,7 +47,9 @@ salomeinclude_HEADERS = \ VISU_DeformedShape_i.hh \ VISU_Plot3D_i.hh \ VISU_CutPlanes_i.hh \ + VISU_CutLinesBase_i.hh \ VISU_CutLines_i.hh \ + VISU_CutSegment_i.hh \ VISU_Prs3dUtils.hh \ VISU_Vectors_i.hh \ VISU_StreamLines_i.hh \ @@ -83,7 +85,9 @@ libVISUEngineImpl_la_SOURCES = \ VISU_DeformedShape_i.cc \ VISU_Plot3D_i.cc \ VISU_CutPlanes_i.cc \ + VISU_CutLinesBase_i.cc \ VISU_CutLines_i.cc \ + VISU_CutSegment_i.cc \ VISU_Vectors_i.cc \ VISU_StreamLines_i.cc \ VISU_DeformedShapeAndScalarMap_i.cc \ diff --git a/src/VISU_I/VISUConfig.cc b/src/VISU_I/VISUConfig.cc index 88234240..84739c38 100644 --- a/src/VISU_I/VISUConfig.cc +++ b/src/VISU_I/VISUConfig.cc @@ -223,8 +223,8 @@ namespace VISU return VISU::TPLOT3D; if ( theComment == "CUTPLANES" ) return VISU::TCUTPLANES; - if ( theComment == "CUTLINES" ) - return VISU::TCUTLINES; + if ( theComment == "CUTSEGMENT" ) + return VISU::TCUTSEGMENT; if ( theComment == "VECTORS" ) return VISU::TVECTORS; if ( theComment == "STREAMLINES" ) diff --git a/src/VISU_I/VISU_ColoredPrs3dFactory.cc b/src/VISU_I/VISU_ColoredPrs3dFactory.cc index bb3a816a..26327b58 100644 --- a/src/VISU_I/VISU_ColoredPrs3dFactory.cc +++ b/src/VISU_I/VISU_ColoredPrs3dFactory.cc @@ -110,6 +110,8 @@ namespace VISU return VISU::CreatePrs3dByEnum(theStudy, thePublishInStudyMode); case TCUTLINES: return VISU::CreatePrs3dByEnum(theStudy, thePublishInStudyMode); + case TCUTSEGMENT: + return VISU::CreatePrs3dByEnum(theStudy, thePublishInStudyMode); case TVECTORS: return VISU::CreatePrs3dByEnum(theStudy, thePublishInStudyMode); } @@ -221,6 +223,9 @@ namespace VISU case TCUTLINES: aMemory = CheckIsPossible(theInput, theMemoryCheck); break; + case TCUTSEGMENT: + aMemory = CheckIsPossible(theInput, theMemoryCheck); + break; case TVECTORS: aMemory = CheckIsPossible(theInput, theMemoryCheck); break; diff --git a/src/VISU_I/VISU_ColoredPrs3dFactory.hh b/src/VISU_I/VISU_ColoredPrs3dFactory.hh index 4b5c2b41..e3633e40 100644 --- a/src/VISU_I/VISU_ColoredPrs3dFactory.hh +++ b/src/VISU_I/VISU_ColoredPrs3dFactory.hh @@ -39,6 +39,7 @@ #include "VISU_StreamLines_i.hh" #include "VISU_Vectors_i.hh" #include "VISU_CutLines_i.hh" +#include "VISU_CutSegment_i.hh" #include "VISU_CutPlanes_i.hh" #include "VISU_DeformedShape_i.hh" #include "VISU_IsoSurfaces_i.hh" @@ -61,9 +62,10 @@ namespace VISU TList > > > > > > > > > > + TList > > > > > > > > > > > TColoredPrs3dTypeList; @@ -76,9 +78,10 @@ namespace VISU TList, TList, TList, - TList, - TList, - TNullType> > > > > > > > > > > + TList, + TList, + TList, + TNullType> > > > > > > > > > > > TColoredPrs3dEnumList; diff --git a/src/VISU_I/VISU_CutLinesBase_i.cc b/src/VISU_I/VISU_CutLinesBase_i.cc new file mode 100644 index 00000000..5c474f90 --- /dev/null +++ b/src/VISU_I/VISU_CutLinesBase_i.cc @@ -0,0 +1,468 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : VISU_CutLinesBase_i.cc +// Author : Oleg UVAROV +// Module : VISU +// +#include "VISU_CutLinesBase_i.hh" +#include "VISU_Prs3dUtils.hh" +#include "VISU_Result_i.hh" + +#include "VISU_Actor.h" +#include "VISU_CutLinesBasePL.hxx" +#include "VISU_Convertor.hxx" +#include "VISU_PipeLineUtils.hxx" + +#include "SUIT_ResourceMgr.h" + +#include + +static vtkFloatingPointType EPS_machine = 1.0E-7; + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +using namespace std; + +//--------------------------------------------------------------- +VISU::CutLinesBase_i:: +CutLinesBase_i(EPublishInStudyMode thePublishInStudyMode) : + ColoredPrs3d_i(thePublishInStudyMode), + ScalarMap_i(thePublishInStudyMode), + myUseAbsLength( false ), + myCutLinesBasePL(NULL) +{} + + +//--------------------------------------------------------------- +void +VISU::CutLinesBase_i +::SameAs(const Prs3d_i* theOrigin) +{ + TSuperClass::SameAs(theOrigin); + + if(const CutLinesBase_i* aPrs3d = dynamic_cast(theOrigin)){ + CutLinesBase_i* anOrigin = const_cast(aPrs3d); + myUseAbsLength = anOrigin->IsUseAbsoluteLength(); + CopyCurvesInverted(anOrigin->GetCurvesInverted()); + } +} + + +//--------------------------------------------------------------- +/*! Copy map to /a myMapCurvesInverted. + * \param theCurves - map + */ +void +VISU::CutLinesBase_i +::CopyCurvesInverted(const TCurvesInv& theCurves) +{ + myMapCurvesInverted = theCurves; +} + + +//--------------------------------------------------------------- +VISU::Storable* +VISU::CutLinesBase_i +::Create(const std::string& theMeshName, + VISU::Entity theEntity, + const std::string& theFieldName, + CORBA::Long theTimeStampNumber) +{ + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + SetUseAbsoluteLength( aResourceMgr->booleanValue( "VISU", "use_absolute_length", false ) ); + SetAllCurvesInverted( aResourceMgr->booleanValue( "VISU", "invert_all_curves", false ) ); + return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber); +} + + +//--------------------------------------------------------------- +VISU::Storable* +VISU::CutLinesBase_i +::Restore(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap) +{ + if(!TSuperClass::Restore(theSObject, theMap)) + return NULL; + + SetNbLines(VISU::Storable::FindValue(theMap,"myNbLines").toInt()); + + SetUseAbsoluteLength(VISU::Storable::FindValue(theMap,"myUseAbsLength").toInt()); + + // Restoring the map - \a myMapCurvesInverted + QStringList aMapCurvesInverted = VISU::Storable::FindValue(theMap,"myMapCurvesInverted").split("|",QString::SkipEmptyParts ); + if (aMapCurvesInverted.count() == GetNbLines()){ + for(int i = 0, iEnd = GetNbLines(); i < iEnd ; i++){ + if(aMapCurvesInverted[i].toInt()) + SetCurveInverted(i,true); + else + SetCurveInverted(i,false); + } + } else { + for(int i = 0, iEnd = GetNbLines(); i < iEnd ; i++) + SetCurveInverted(i,false); + } + + return this; +} + + +//--------------------------------------------------------------- +void +VISU::CutLinesBase_i +::ToStream(std::ostringstream& theStr) +{ + TSuperClass::ToStream(theStr); + + Storable::DataToStream( theStr, "myNbLines", GetNbLines() ); + + Storable::DataToStream( theStr, "myUseAbsLength", IsUseAbsoluteLength()); + + // Storing the map - \a myMapCurvesInverted + QString aStrCurvesInverted; + for(int i = 0, iEnd = GetNbLines(); i < iEnd; i++) + aStrCurvesInverted.append(QString::number(IsCurveInverted(i)) + "|"); + Storable::DataToStream( theStr, "myMapCurvesInverted", (const char*)aStrCurvesInverted.toLatin1()); +} + + +//--------------------------------------------------------------- +VISU::CutLinesBase_i +::~CutLinesBase_i() +{ + if(MYDEBUG) MESSAGE("CutLinesBase_i::~CutLinesBase_i()"); +} + + +//--------------------------------------------------------------- +void +VISU::CutLinesBase_i +::SetNbLines(CORBA::Long theNb) +{ + VISU::TSetModified aModified(this); + + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (GetSpecificPL(), &VISU_CutLinesBasePL::SetNbParts, theNb)); +} + +//--------------------------------------------------------------- +CORBA::Long +VISU::CutLinesBase_i +::GetNbLines() +{ + return myCutLinesBasePL->GetNbParts(); +} + +//--------------------------------------------------------------- +/*! Invert all curves of corresponding table + * see void VISU::CutLinesBase_i::SetCurveInverted(CORBA::Long theCurveNumber,CORBA::Boolean theInvert) + * \param theInvert - Invert all curves, if value is TRUE, else not. + */ +void +VISU::CutLinesBase_i +::SetAllCurvesInverted(CORBA::Boolean theInvert) +{ + for(int i=0; i < GetNbLines(); i++) + SetCurveInverted(i, theInvert); +} + +//--------------------------------------------------------------- +/*! Checks the orientation of all curves + * \retval TRUE - if all curves are inverted, else FALSE + */ +CORBA::Boolean +VISU::CutLinesBase_i +::IsAllCurvesInverted() +{ + for (int i=0; i(thePipeLine); + + TSuperClass::CreatePipeLine(myCutLinesBasePL); +} + + +//--------------------------------------------------------------- +void +VISU::CutLinesBase_i +::BuildTableOfReal(SALOMEDS::SObject_var theSObject) +{ + try{ + if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal"); + Update(); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::StudyBuilder_var aStudyBuilder = GetStudyDocument()->NewBuilder(); + anAttr = aStudyBuilder->FindOrCreateAttribute(theSObject, "AttributeTableOfReal"); + SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr); + + typedef set TXCont; + typedef map TXYMap; + typedef map TXYMapCont; + typedef map TLineIdCont; + + QString aTitle( GetScalarBarTitle().c_str() ); + aTitle = aTitle.simplified(); + aTableOfReal->SetTitle( aTitle.toLatin1().data() ); + + int iLineEnd = myCutLinesBasePL->GetAppendPolyData()->GetNumberOfInputConnections(0); + if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal iLineEnd = "<GetDirLn(); + const vtkFloatingPointType *aBasePnt = myCutLinesBasePL->GetBasePnt(); + const vtkFloatingPointType *aBoundPrjLn = myCutLinesBasePL->GetBoundPrjLn(); + for(int iLine = 0, jLine = 0; iLine < iLineEnd; iLine++){ + vtkDataSet *aDataSet = myCutLinesBasePL->GetAppendPolyData()->GetInput(iLine); + aDataSet->Update(); + int aNbPoints = aDataSet->GetNumberOfPoints(); + if(!aNbPoints) continue; + vtkPointData *aPointData = aDataSet->GetPointData(); + vtkDataArray *aScalars = aPointData->GetScalars(); + vtkCellDataToPointData *aFilter = NULL; + if(!aScalars) { + aFilter = vtkCellDataToPointData::New(); + aFilter->SetInput(aDataSet); + aFilter->PassCellDataOn(); + aDataSet = aFilter->GetOutput(); + aDataSet->Update(); + } + aPointData = aDataSet->GetPointData(); + aScalars = aPointData->GetScalars(); + if(!aScalars) continue; + if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal iLine = "< XKeys; + for (;aXYMapIter != aXYMap.end() ; aXYMapIter++) XKeys.push_back(aXYMapIter->first); + XKeys.sort(); + if (XKeys.size() > 1) { + vtkFloatingPointType a_first_indx = XKeys.front(); + vtkFloatingPointType a_last_indx = XKeys.back(); + if (a_first_indx > a_last_indx){ + XKeys.reverse(); + vtkFloatingPointType tmp = a_first_indx; + a_first_indx = a_last_indx; + a_last_indx = tmp; + } + std::list::const_iterator aIter = XKeys.begin(); + for (int k=0;k= 0 and aDist<=1.0 + vtkFloatingPointType aTopBnd = aBoundPrjLn[2]; + if( !IsUseAbsoluteLength() ){ + aTopBnd = 1.0; + } + aNewXYMap[aTopBnd - *aIter] = aXYMap[*aIter]; + } + TXYMap::const_iterator aNewXYMapIter = aNewXYMap.begin(); + aXYMap.clear(); + for (;aNewXYMapIter != aNewXYMap.end();aNewXYMapIter++) { + aXYMap[aNewXYMapIter->first] = aNewXYMapIter->second; + } + } + } + } + //Resorting of theXYMap + TXYMapCont::iterator aXYMapContIter = aXYMapCont.begin(); + for(; aXYMapContIter != aXYMapCont.end(); aXYMapContIter++){ + TXYMap& aXYMap = aXYMapContIter->second, aNewXYMap; + if(aXYMap.size() > 2){ + // Try to smooth the values of the line by applying linear approximation + TXYMap::const_iterator aXYMapIter[2] = {aXYMap.begin(), ++aXYMap.begin()}; + aNewXYMap[aXYMapIter[0]->first] = aXYMapIter[0]->second; + aXCont.insert(aXYMapIter[0]->first); + for(; aXYMapIter[1] != aXYMap.end(); aXYMapIter[0]++, aXYMapIter[1]++){ + vtkFloatingPointType aY[3] = {aXYMapIter[0]->second, aXYMapIter[1]->second, 0.0}; + aY[2] = (aY[0] + aY[1])/2.0; + vtkFloatingPointType aX[3] = {aXYMapIter[0]->first, aXYMapIter[1]->first, 0.0}; + aX[2] = (aX[0] + aX[1])/2.0; + aNewXYMap[aX[2]] = aY[2]; + aXCont.insert(aX[2]); + } + aNewXYMap[aXYMapIter[0]->first] = aXYMapIter[0]->second; + aXCont.insert(aXYMapIter[0]->first); + aXYMap = aNewXYMap; + }else{ + TXYMap::const_iterator aXYMapIter = aXYMap.begin(); + for(; aXYMapIter != aXYMap.end(); aXYMapIter++) + aXCont.insert(aXYMapIter->first); + } + } + if(aXCont.size() == 0) + throw std::runtime_error("CutPlanes_i::BuildTableOfReal aXCont.size() == 0 !!!"); + QString aString; + int iEnd = aXCont.size(); + aTableOfReal->SetNbColumns(iEnd); + TXCont::const_iterator aXContIter = aXCont.begin(); + for(long i = 0; aXContIter != aXCont.end(); aXContIter++, i++){ + vtkFloatingPointType aDist = *aXContIter; + aTableOfReal->PutValue(aDist,1,i+1); + aString.sprintf("%d",i); + aTableOfReal->SetColumnTitle(i+1,(const char*)aString.toLatin1()); + if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal aDist = "<first; + long iLineId = aLineIdCont[iLine]; + const TXYMap& aXYMap = aXYMapCont[iLine]; + TXYMap::const_iterator aXYMapIter = aXYMap.find(aDist); + // Can we find some value that belong to the line and have the same X coordinate? + if(aXYMapIter == aXYMap.end()) continue; + vtkFloatingPointType aVal = aXYMapIter->second; + aTableOfReal->PutValue(aVal,iLineId+2,i+1); + } + } + { + aTableOfReal->SetRowTitle(1,"X"); + aTableOfReal->SetRowUnit(1,"-"); + QString aUnitName = GetField()->myUnitNames[0].c_str(); + int aScalarMode = myCutLinesBasePL->GetScalarMode(); + if(aScalarMode != 0) + aUnitName = GetField()->myUnitNames[aScalarMode-1].c_str(); + aUnitName = aUnitName.simplified(); + if(aUnitName.isEmpty()) aUnitName = "-"; + TXYMapCont::const_iterator aXYMapContIter = aXYMapCont.begin(); + for(; aXYMapContIter != aXYMapCont.end(); aXYMapContIter++){ + long iLine = aXYMapContIter->first; + long iLineId = aLineIdCont[iLine]; + aString.sprintf("Y%d",iLine); + if(MYDEBUG) + MESSAGE("CutPlanes_i::BuildTableOfReal - SetRowTitle("<SetRowTitle(iLineId+2,(const char*)aString.toLatin1()); + aTableOfReal->SetRowUnit(iLineId+2,(const char*)aUnitName.toLatin1()); + } + } + }catch(std::exception& exc){ + INFOS("Follow exception was occured :\n"< TCurvesInv; + TCurvesInv + GetCurvesInverted() + { + return myMapCurvesInverted; + } + + void + CopyCurvesInverted(const TCurvesInv& theCurves); + + VISU_CutLinesBasePL* + GetSpecificPL() const + { + return myCutLinesBasePL; + } + + protected: + //! Extends VISU_ColoredPrs3d_i::CreatePipeLine + virtual + void + CreatePipeLine(VISU_PipeLine* thePipeLine); + + VISU_CutLinesBasePL *myCutLinesBasePL; + TCurvesInv myMapCurvesInverted; + CORBA::Boolean myUseAbsLength; + + public: + //! Extends VISU_ColoredPrs3d_i::Create + virtual + Storable* + Create(const std::string& theMeshName, + VISU::Entity theEntity, + const std::string& theFieldName, + CORBA::Long theTimeStampNumber); + + //! Extends VISU_ColoredPrs3d_i::ToStream + virtual + void + ToStream(std::ostringstream& theStr); + + //! Extends VISU_ColoredPrs3d_i::Restore + virtual + Storable* + Restore(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap); + + virtual + void + SameAs(const Prs3d_i* theOrigin); + + void BuildTableOfReal(SALOMEDS::SObject_var theSObject); + }; +} + +#endif diff --git a/src/VISU_I/VISU_CutLines_i.cc b/src/VISU_I/VISU_CutLines_i.cc index 76dfaab6..a1dccb01 100644 --- a/src/VISU_I/VISU_CutLines_i.cc +++ b/src/VISU_I/VISU_CutLines_i.cc @@ -38,8 +38,6 @@ #include -static vtkFloatingPointType EPS_machine = 1.0E-7; - #ifdef _DEBUG_ static int MYDEBUG = 0; #else @@ -103,7 +101,7 @@ VISU::CutLines_i:: CutLines_i(EPublishInStudyMode thePublishInStudyMode) : ColoredPrs3d_i(thePublishInStudyMode), ScalarMap_i(thePublishInStudyMode), - myUseAbsLength( false ), + CutLinesBase_i(thePublishInStudyMode), myCutLinesPL(NULL) {} @@ -114,24 +112,6 @@ VISU::CutLines_i ::SameAs(const Prs3d_i* theOrigin) { TSuperClass::SameAs(theOrigin); - - if(const CutLines_i* aPrs3d = dynamic_cast(theOrigin)){ - CutLines_i* anOrigin = const_cast(aPrs3d); - myUseAbsLength = anOrigin->IsUseAbsoluteLength(); - CopyCurvesInverted(anOrigin->GetCurvesInverted()); - } -} - - -//--------------------------------------------------------------- -/*! Copy map to /a myMapCurvesInverted. - * \param theCurves - map - */ -void -VISU::CutLines_i -::CopyCurvesInverted(const TCurvesInv& theCurves) -{ - myMapCurvesInverted = theCurves; } @@ -143,9 +123,6 @@ VISU::CutLines_i const std::string& theFieldName, CORBA::Long theTimeStampNumber) { - SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); - SetUseAbsoluteLength( aResourceMgr->booleanValue( "VISU", "use_absolute_length", false ) ); - SetAllCurvesInverted( aResourceMgr->booleanValue( "VISU", "invert_all_curves", false ) ); return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber); } @@ -159,7 +136,6 @@ VISU::CutLines_i if(!TSuperClass::Restore(theSObject, theMap)) return NULL; - SetNbLines(VISU::Storable::FindValue(theMap,"myNbLines").toInt()); SetDisplacement(VISU::Storable::FindValue(theMap,"myDisplacement[0]").toDouble()); SetDisplacement2(VISU::Storable::FindValue(theMap,"myDisplacement[1]").toDouble()); SetOrientation(CutPlanes::Orientation(VISU::Storable::FindValue(theMap,"myBasePlane[0]").toInt()), @@ -168,7 +144,6 @@ VISU::CutLines_i SetOrientation2(CutPlanes::Orientation(VISU::Storable::FindValue(theMap,"myBasePlane[1]").toInt()), Storable::FindValue(theMap,"aRot[1][0]").toDouble(), Storable::FindValue(theMap,"aRot[1][1]").toDouble()); - SetUseAbsoluteLength(VISU::Storable::FindValue(theMap,"myUseAbsLength").toInt()); if (VISU::Storable::FindValue(theMap,"myBasePlaneCondition").toInt()) SetDefault(); @@ -181,20 +156,6 @@ VISU::CutLines_i if(aCondList[i].toInt() == 0) SetLinePosition(i,aPosList[i].toDouble()); - // Restoring the map - \a myMapCurvesInverted - QStringList aMapCurvesInverted = VISU::Storable::FindValue(theMap,"myMapCurvesInverted").split("|",QString::SkipEmptyParts ); - if (aMapCurvesInverted.count() == GetNbLines()){ - for(int i = 0, iEnd = GetNbLines(); i < iEnd ; i++){ - if(aMapCurvesInverted[i].toInt()) - SetCurveInverted(i,true); - else - SetCurveInverted(i,false); - } - } else { - for(int i = 0, iEnd = GetNbLines(); i < iEnd ; i++) - SetCurveInverted(i,false); - } - return this; } @@ -206,9 +167,6 @@ VISU::CutLines_i { TSuperClass::ToStream(theStr); - int aNbLines = GetNbLines(); - - Storable::DataToStream( theStr, "myNbLines", aNbLines ); Storable::DataToStream( theStr, "myDisplacement[0]", GetDisplacement() ); Storable::DataToStream( theStr, "myDisplacement[1]", GetDisplacement2() ); Storable::DataToStream( theStr, "myBasePlane[0]", int(GetOrientationType()) ); @@ -228,13 +186,6 @@ VISU::CutLines_i Storable::DataToStream( theStr, "myLinePosition", (const char*)aStrPos.toLatin1()); Storable::DataToStream( theStr, "myLineCondition", (const char*)aStrCon.toLatin1()); - Storable::DataToStream( theStr,"myUseAbsLength", IsUseAbsoluteLength()); - - // Storing the map - \a myMapCurvesInverted - QString aStrCurvesInverted; - for(int i = 0, iEnd = GetNbLines(); i < iEnd; i++) - aStrCurvesInverted.append(QString::number(IsCurveInverted(i)) + "|"); - Storable::DataToStream( theStr, "myMapCurvesInverted", (const char*)aStrCurvesInverted.toLatin1()); } @@ -489,107 +440,6 @@ VISU::CutLines_i return myCutLinesPL->IsPartDefault(thePlaneNumber); } -//--------------------------------------------------------------- -/*! Invert all curves of corresponding table - * see void VISU::CutLines_i::SetCurveInverted(CORBA::Long theCurveNumber,CORBA::Boolean theInvert) - * \param theInvert - Invert all curves, if value is TRUE, else not. - */ -void -VISU::CutLines_i -::SetAllCurvesInverted(CORBA::Boolean theInvert) -{ - for(int i=0; i < GetNbLines(); i++) - SetCurveInverted(i, theInvert); -} - -//--------------------------------------------------------------- -/*! Checks the orientation of all curves - * \retval TRUE - if all curves are inverted, else FALSE - */ -CORBA::Boolean -VISU::CutLines_i -::IsAllCurvesInverted() -{ - for (int i=0; i - (GetSpecificPL(), &VISU_CutLinesPL::SetNbParts, theNb)); -} - -//--------------------------------------------------------------- -CORBA::Long -VISU::CutLines_i -::GetNbLines() -{ - return myCutLinesPL->GetNbParts(); -} - - //--------------------------------------------------------------- void VISU::CutLines_i @@ -627,199 +477,3 @@ VISU::CutLines_i } return NULL; } - -//--------------------------------------------------------------- -void -VISU::CutLines_i -::BuildTableOfReal(SALOMEDS::SObject_var theSObject) -{ - try{ - if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal"); - Update(); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::StudyBuilder_var aStudyBuilder = GetStudyDocument()->NewBuilder(); - anAttr = aStudyBuilder->FindOrCreateAttribute(theSObject, "AttributeTableOfReal"); - SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr); - - typedef set TXCont; - typedef map TXYMap; - typedef map TXYMapCont; - typedef map TLineIdCont; - - QString aTitle( GetScalarBarTitle().c_str() ); - aTitle = aTitle.simplified(); - aTableOfReal->SetTitle( aTitle.toLatin1().data() ); - - int iLineEnd = myCutLinesPL->GetAppendPolyData()->GetNumberOfInputConnections(0); - if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal iLineEnd = "<GetDirLn(); - const vtkFloatingPointType *aBasePnt = myCutLinesPL->GetBasePnt(); - const vtkFloatingPointType *aBoundPrjLn = myCutLinesPL->GetBoundPrjLn(); - for(int iLine = 0, jLine = 0; iLine < iLineEnd; iLine++){ - vtkDataSet *aDataSet = myCutLinesPL->GetAppendPolyData()->GetInput(iLine); - aDataSet->Update(); - int aNbPoints = aDataSet->GetNumberOfPoints(); - if(!aNbPoints) continue; - vtkPointData *aPointData = aDataSet->GetPointData(); - vtkDataArray *aScalars = aPointData->GetScalars(); - vtkCellDataToPointData *aFilter = NULL; - if(!aScalars) { - aFilter = vtkCellDataToPointData::New(); - aFilter->SetInput(aDataSet); - aFilter->PassCellDataOn(); - aDataSet = aFilter->GetOutput(); - aDataSet->Update(); - } - aPointData = aDataSet->GetPointData(); - aScalars = aPointData->GetScalars(); - if(!aScalars) continue; - if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal iLine = "< XKeys; - for (;aXYMapIter != aXYMap.end() ; aXYMapIter++) XKeys.push_back(aXYMapIter->first); - XKeys.sort(); - if (XKeys.size() > 1) { - vtkFloatingPointType a_first_indx = XKeys.front(); - vtkFloatingPointType a_last_indx = XKeys.back(); - if (a_first_indx > a_last_indx){ - XKeys.reverse(); - vtkFloatingPointType tmp = a_first_indx; - a_first_indx = a_last_indx; - a_last_indx = tmp; - } - std::list::const_iterator aIter = XKeys.begin(); - for (int k=0;k= 0 and aDist<=1.0 - vtkFloatingPointType aTopBnd = aBoundPrjLn[2]; - if( !IsUseAbsoluteLength() ){ - aTopBnd = 1.0; - } - aNewXYMap[aTopBnd - *aIter] = aXYMap[*aIter]; - } - TXYMap::const_iterator aNewXYMapIter = aNewXYMap.begin(); - aXYMap.clear(); - for (;aNewXYMapIter != aNewXYMap.end();aNewXYMapIter++) { - aXYMap[aNewXYMapIter->first] = aNewXYMapIter->second; - } - } - } - } - //Resorting of theXYMap - TXYMapCont::iterator aXYMapContIter = aXYMapCont.begin(); - for(; aXYMapContIter != aXYMapCont.end(); aXYMapContIter++){ - TXYMap& aXYMap = aXYMapContIter->second, aNewXYMap; - if(aXYMap.size() > 2){ - // Try to smooth the values of the line by applying linear approximation - TXYMap::const_iterator aXYMapIter[2] = {aXYMap.begin(), ++aXYMap.begin()}; - aNewXYMap[aXYMapIter[0]->first] = aXYMapIter[0]->second; - aXCont.insert(aXYMapIter[0]->first); - for(; aXYMapIter[1] != aXYMap.end(); aXYMapIter[0]++, aXYMapIter[1]++){ - vtkFloatingPointType aY[3] = {aXYMapIter[0]->second, aXYMapIter[1]->second, 0.0}; - aY[2] = (aY[0] + aY[1])/2.0; - vtkFloatingPointType aX[3] = {aXYMapIter[0]->first, aXYMapIter[1]->first, 0.0}; - aX[2] = (aX[0] + aX[1])/2.0; - aNewXYMap[aX[2]] = aY[2]; - aXCont.insert(aX[2]); - } - aNewXYMap[aXYMapIter[0]->first] = aXYMapIter[0]->second; - aXCont.insert(aXYMapIter[0]->first); - aXYMap = aNewXYMap; - }else{ - TXYMap::const_iterator aXYMapIter = aXYMap.begin(); - for(; aXYMapIter != aXYMap.end(); aXYMapIter++) - aXCont.insert(aXYMapIter->first); - } - } - if(aXCont.size() == 0) - throw std::runtime_error("CutPlanes_i::BuildTableOfReal aXCont.size() == 0 !!!"); - QString aString; - int iEnd = aXCont.size(); - aTableOfReal->SetNbColumns(iEnd); - TXCont::const_iterator aXContIter = aXCont.begin(); - for(long i = 0; aXContIter != aXCont.end(); aXContIter++, i++){ - vtkFloatingPointType aDist = *aXContIter; - aTableOfReal->PutValue(aDist,1,i+1); - aString.sprintf("%d",i); - aTableOfReal->SetColumnTitle(i+1,(const char*)aString.toLatin1()); - if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal aDist = "<first; - long iLineId = aLineIdCont[iLine]; - const TXYMap& aXYMap = aXYMapCont[iLine]; - TXYMap::const_iterator aXYMapIter = aXYMap.find(aDist); - // Can we find some value that belong to the line and have the same X coordinate? - if(aXYMapIter == aXYMap.end()) continue; - vtkFloatingPointType aVal = aXYMapIter->second; - aTableOfReal->PutValue(aVal,iLineId+2,i+1); - } - } - { - aTableOfReal->SetRowTitle(1,"X"); - aTableOfReal->SetRowUnit(1,"-"); - QString aUnitName = GetField()->myUnitNames[0].c_str(); - int aScalarMode = myCutLinesPL->GetScalarMode(); - if(aScalarMode != 0) - aUnitName = GetField()->myUnitNames[aScalarMode-1].c_str(); - aUnitName = aUnitName.simplified(); - if(aUnitName.isEmpty()) aUnitName = "-"; - TXYMapCont::const_iterator aXYMapContIter = aXYMapCont.begin(); - for(; aXYMapContIter != aXYMapCont.end(); aXYMapContIter++){ - long iLine = aXYMapContIter->first; - long iLineId = aLineIdCont[iLine]; - aString.sprintf("Y%d",iLine); - if(MYDEBUG) - MESSAGE("CutPlanes_i::BuildTableOfReal - SetRowTitle("<SetRowTitle(iLineId+2,(const char*)aString.toLatin1()); - aTableOfReal->SetRowUnit(iLineId+2,(const char*)aUnitName.toLatin1()); - } - } - }catch(std::exception& exc){ - INFOS("Follow exception was occured :\n"< TCurvesInv; - TCurvesInv - GetCurvesInverted() - { - return myMapCurvesInverted; - } - - void - CopyCurvesInverted(const TCurvesInv& theCurves); - VISU_CutLinesPL* GetSpecificPL() const { @@ -209,8 +166,6 @@ namespace VISU GetIconName(); VISU_CutLinesPL *myCutLinesPL; - TCurvesInv myMapCurvesInverted; - CORBA::Boolean myUseAbsLength; public: //! Extends VISU_ColoredPrs3d_i::IsPossible @@ -251,8 +206,6 @@ namespace VISU VISU_Actor* CreateActor(); - void BuildTableOfReal(SALOMEDS::SObject_var theSObject); - static const std::string myComment; virtual diff --git a/src/VISU_I/VISU_CutSegment_i.cc b/src/VISU_I/VISU_CutSegment_i.cc new file mode 100644 index 00000000..4e01b20b --- /dev/null +++ b/src/VISU_I/VISU_CutSegment_i.cc @@ -0,0 +1,305 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : VISU_CutSegment_i.cc +// Author : Oleg UVAROV +// Module : VISU +// +#include "VISU_CutSegment_i.hh" +#include "VISU_Prs3dUtils.hh" +#include "VISU_Result_i.hh" + +#include "VISU_Actor.h" +#include "VISU_CutSegmentPL.hxx" +#include "VISU_Convertor.hxx" +#include "VISU_PipeLineUtils.hxx" + +#include "SUIT_ResourceMgr.h" +#include "SALOME_Event.h" + +#include + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +using namespace std; + +//--------------------------------------------------------------- +size_t +VISU::CutSegment_i +::IsPossible(Result_i* theResult, + const std::string& theMeshName, + VISU::Entity theEntity, + const std::string& theFieldName, + CORBA::Long theTimeStampNumber, + bool theIsMemoryCheck) +{ + return TSuperClass::IsPossible(theResult, + theMeshName, + theEntity, + theFieldName, + theTimeStampNumber, + theIsMemoryCheck); +} + +//--------------------------------------------------------------- +int VISU::CutSegment_i::myNbPresent = 0; + +//--------------------------------------------------------------- +QString +VISU::CutSegment_i::GenerateName() +{ + return VISU::GenerateName("CutSegment",myNbPresent++); +} + +//--------------------------------------------------------------- +const string VISU::CutSegment_i::myComment = "CUTSEGMENT"; + +//--------------------------------------------------------------- +const char* +VISU::CutSegment_i +::GetComment() const +{ + return myComment.c_str(); +} + +//---------------------------------------------------------------------------- +const char* +VISU::CutSegment_i +::GetIconName() +{ + if (!IsGroupsUsed()) + return "ICON_TREE_CUT_SEGMENT"; + else + return "ICON_TREE_CUT_SEGMENT_GROUPS"; +} + +//--------------------------------------------------------------- +VISU::CutSegment_i:: +CutSegment_i(EPublishInStudyMode thePublishInStudyMode) : + ColoredPrs3d_i(thePublishInStudyMode), + ScalarMap_i(thePublishInStudyMode), + CutLinesBase_i(thePublishInStudyMode), + myCutSegmentPL(NULL) +{} + + +//--------------------------------------------------------------- +void +VISU::CutSegment_i +::SameAs(const Prs3d_i* theOrigin) +{ + TSuperClass::SameAs(theOrigin); +} + + +//--------------------------------------------------------------- +VISU::Storable* +VISU::CutSegment_i +::Create(const std::string& theMeshName, + VISU::Entity theEntity, + const std::string& theFieldName, + CORBA::Long theTimeStampNumber) +{ + return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber); +} + + +//--------------------------------------------------------------- +VISU::Storable* +VISU::CutSegment_i +::Restore(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap) +{ + if(!TSuperClass::Restore(theSObject, theMap)) + return NULL; + + SetPoint1(VISU::Storable::FindValue(theMap,"myPoint1[0]").toDouble(), + VISU::Storable::FindValue(theMap,"myPoint1[1]").toDouble(), + VISU::Storable::FindValue(theMap,"myPoint1[2]").toDouble()); + SetPoint2(VISU::Storable::FindValue(theMap,"myPoint2[0]").toDouble(), + VISU::Storable::FindValue(theMap,"myPoint2[1]").toDouble(), + VISU::Storable::FindValue(theMap,"myPoint2[2]").toDouble()); + + return this; +} + + +//--------------------------------------------------------------- +void +VISU::CutSegment_i +::ToStream(std::ostringstream& theStr) +{ + TSuperClass::ToStream(theStr); + + double aCoord[3]; + GetPoint1( aCoord[0], aCoord[1], aCoord[2] ); + Storable::DataToStream( theStr, "myPoint1[0]", aCoord[0] ); + Storable::DataToStream( theStr, "myPoint1[1]", aCoord[1] ); + Storable::DataToStream( theStr, "myPoint1[2]", aCoord[2] ); + + GetPoint2( aCoord[0], aCoord[1], aCoord[2] ); + Storable::DataToStream( theStr, "myPoint2[0]", aCoord[0] ); + Storable::DataToStream( theStr, "myPoint2[1]", aCoord[1] ); + Storable::DataToStream( theStr, "myPoint2[2]", aCoord[2] ); +} + + +//--------------------------------------------------------------- +VISU::CutSegment_i +::~CutSegment_i() +{ + if(MYDEBUG) MESSAGE("CutSegment_i::~CutSegment_i()"); +} + + +//--------------------------------------------------------------- +struct TSetPoint1Event: public SALOME_Event +{ + VISU_CutSegmentPL* myCutSegmentPL; + CORBA::Double myX, myY, myZ; + TSetPoint1Event(VISU_CutSegmentPL* theCutSegment, + CORBA::Double theX, + CORBA::Double theY, + CORBA::Double theZ): + myCutSegmentPL(theCutSegment), + myX(theX), + myY(theY), + myZ(theZ) + {} + + virtual + void + Execute() + { + myCutSegmentPL->SetPoint1(myX, myY, myZ); + } +}; + +void +VISU::CutSegment_i +::SetPoint1(CORBA::Double theX, + CORBA::Double theY, + CORBA::Double theZ) +{ + VISU::TSetModified aModified(this); + + ProcessVoidEvent(new TSetPoint1Event(myCutSegmentPL, theX, theY, theZ)); +} + + +//--------------------------------------------------------------- +void +VISU::CutSegment_i +::GetPoint1(CORBA::Double& theX, + CORBA::Double& theY, + CORBA::Double& theZ) +{ + myCutSegmentPL->GetPoint1(theX, theY, theZ); +} + + +//--------------------------------------------------------------- +struct TSetPoint2Event: public SALOME_Event +{ + VISU_CutSegmentPL* myCutSegmentPL; + CORBA::Double myX, myY, myZ; + TSetPoint2Event(VISU_CutSegmentPL* theCutSegment, + CORBA::Double theX, + CORBA::Double theY, + CORBA::Double theZ): + myCutSegmentPL(theCutSegment), + myX(theX), + myY(theY), + myZ(theZ) + {} + + virtual + void + Execute() + { + myCutSegmentPL->SetPoint2(myX, myY, myZ); + } +}; + +void +VISU::CutSegment_i +::SetPoint2(CORBA::Double theX, + CORBA::Double theY, + CORBA::Double theZ) +{ + VISU::TSetModified aModified(this); + + ProcessVoidEvent(new TSetPoint2Event(myCutSegmentPL, theX, theY, theZ)); +} + + +//--------------------------------------------------------------- +void +VISU::CutSegment_i +::GetPoint2(CORBA::Double& theX, + CORBA::Double& theY, + CORBA::Double& theZ) +{ + myCutSegmentPL->GetPoint2(theX, theY, theZ); +} + + +//--------------------------------------------------------------- +void +VISU::CutSegment_i +::CreatePipeLine(VISU_PipeLine* thePipeLine) +{ + if(!thePipeLine){ + myCutSegmentPL = VISU_CutSegmentPL::New(); + }else + myCutSegmentPL = dynamic_cast(thePipeLine); + + TSuperClass::CreatePipeLine(myCutSegmentPL); +} + + +//---------------------------------------------------------------------------- +bool +VISU::CutSegment_i +::CheckIsPossible() +{ + return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true); +} + + +//--------------------------------------------------------------- +VISU_Actor* +VISU::CutSegment_i +::CreateActor() +{ + if(VISU_Actor* anActor = TSuperClass::CreateActor()){ + anActor->SetVTKMapping(true); + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + int aDispMode = aResourceMgr->integerValue("VISU", "cut_segment_represent", 2); + anActor->SetRepresentation(aDispMode); + return anActor; + } + return NULL; +} diff --git a/src/VISU_I/VISU_CutSegment_i.hh b/src/VISU_I/VISU_CutSegment_i.hh new file mode 100644 index 00000000..6f7abdc2 --- /dev/null +++ b/src/VISU_I/VISU_CutSegment_i.hh @@ -0,0 +1,159 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : VISU_CutSegment_i.hh +// Author : Oleg UVAROV +// Module : VISU +// +#ifndef VISU_CutSegment_i_HeaderFile +#define VISU_CutSegment_i_HeaderFile + +#include "VISU_I.hxx" +#include "VISU_CutLinesBase_i.hh" + +class VISU_CutSegmentPL; + +namespace VISU +{ + //---------------------------------------------------------------------------- + class VISU_I_EXPORT CutSegment_i : public virtual POA_VISU::CutSegment, + public virtual CutLinesBase_i + { + static int myNbPresent; + CutSegment_i(const CutSegment_i&); + + public: + //---------------------------------------------------------------------------- + typedef CutLinesBase_i TSuperClass; + typedef VISU::CutSegment TInterface; + + explicit + CutSegment_i(EPublishInStudyMode thePublishInStudyModep); + + virtual + ~CutSegment_i(); + + virtual + VISU::VISUType + GetType() + { + return VISU::TCUTSEGMENT; + } + + virtual + void + SetPoint1(CORBA::Double theX, + CORBA::Double theY, + CORBA::Double theZ ); + + virtual + void + GetPoint1(CORBA::Double& theX, + CORBA::Double& theY, + CORBA::Double& theZ ); + + virtual + void + SetPoint2(CORBA::Double theX, + CORBA::Double theY, + CORBA::Double theZ ); + + virtual + void + GetPoint2(CORBA::Double& theX, + CORBA::Double& theY, + CORBA::Double& theZ ); + + VISU_CutSegmentPL* + GetSpecificPL() const + { + return myCutSegmentPL; + } + + protected: + //! Extends VISU_ColoredPrs3d_i::CreatePipeLine + virtual + void + CreatePipeLine(VISU_PipeLine* thePipeLine); + + //! Extends VISU_ColoredPrs3d_i::CheckIsPossible + virtual + bool + CheckIsPossible(); + + virtual + const char* + GetIconName(); + + VISU_CutSegmentPL *myCutSegmentPL; + + public: + //! Extends VISU_ColoredPrs3d_i::IsPossible + static + size_t + IsPossible(Result_i* theResult, + const std::string& theMeshName, + VISU::Entity theEntity, + const std::string& theFieldName, + CORBA::Long theTimeStampNumber, + bool theIsMemoryCheck); + + //! Extends VISU_ColoredPrs3d_i::Create + virtual + Storable* + Create(const std::string& theMeshName, + VISU::Entity theEntity, + const std::string& theFieldName, + CORBA::Long theTimeStampNumber); + + //! Extends VISU_ColoredPrs3d_i::ToStream + virtual + void + ToStream(std::ostringstream& theStr); + + //! Extends VISU_ColoredPrs3d_i::Restore + virtual + Storable* + Restore(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap); + + virtual + void + SameAs(const Prs3d_i* theOrigin); + + //! Extends VISU_ColoredPrs3d_i::CreateActor + virtual + VISU_Actor* + CreateActor(); + + static const std::string myComment; + + virtual + const char* + GetComment() const; + + virtual + QString + GenerateName(); + }; +} + +#endif diff --git a/src/VISU_I/VISU_DumpPython.cc b/src/VISU_I/VISU_DumpPython.cc index 14e0e6f3..4d008943 100644 --- a/src/VISU_I/VISU_DumpPython.cc +++ b/src/VISU_I/VISU_DumpPython.cc @@ -35,6 +35,7 @@ #include "VISU_DeformedShape_i.hh" #include "VISU_CutPlanes_i.hh" #include "VISU_CutLines_i.hh" +#include "VISU_CutSegment_i.hh" #include "VISU_Vectors_i.hh" #include "VISU_StreamLines_i.hh" #include "VISU_Plot3D_i.hh" @@ -782,6 +783,31 @@ namespace VISU } + //--------------------------------------------------------------------------- + std::string + CutSegmentToPython(SALOMEDS::SObject_ptr theSObject, + VISU::CutSegment_i* theServant, + std::ostream& theStr, + const std::string& theName, + TColoredPrs3dFactory& thePrsFactory, + std::string thePrefix) + { + thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix); + theStr<GetPoint1(x1, y1, z1); + theServant->GetPoint2(x2, y2, z2); + theStr<IsUseAbsoluteLength(); + theStr<(GetServant(anObj).in())){ + TCreateFromResult aPrsFactory(theSObject, aServant, aName, "CutSegmentOnField", theArgumentName); + thePrefix = CutSegmentToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix); + + theArgumentName = aName; + DumpChildrenToPython(theStudy, + theIsPublished, + theIsValidScript, + theSObject, + theStr, + theName2EntryMap, + theEntry2NameMap, + theArgumentName, + thePrefix); + + theStr<(GetServant(anObj).in())) { TCreateFromResult aPrsFactory(theSObject, aServant, aName, "Plot3DOnField", theArgumentName); @@ -1916,6 +1961,11 @@ namespace VISU CutLinesToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3); break; } + case VISU::TCUTSEGMENT: + if(CutSegment_i* aServant = dynamic_cast(aDevice)){ + CutSegmentToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3); + break; + } case VISU::TPLOT3D: if(Plot3D_i* aServant = dynamic_cast(aDevice)){ Plot3DToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3); diff --git a/src/VISU_I/VISU_Gen_i.cc b/src/VISU_I/VISU_Gen_i.cc index 9862db83..0dd7a7b5 100644 --- a/src/VISU_I/VISU_Gen_i.cc +++ b/src/VISU_I/VISU_Gen_i.cc @@ -210,6 +210,7 @@ namespace VISU Storable::RegistryStorableEngine(DeformedShape_i::myComment.c_str(),&(StorableEngine)); Storable::RegistryStorableEngine(CutPlanes_i::myComment.c_str(),&(StorableEngine)); Storable::RegistryStorableEngine(CutLines_i::myComment.c_str(),&(StorableEngine)); + Storable::RegistryStorableEngine(CutSegment_i::myComment.c_str(),&(StorableEngine)); Storable::RegistryStorableEngine(IsoSurfaces_i::myComment.c_str(),&(StorableEngine)); Storable::RegistryStorableEngine(StreamLines_i::myComment.c_str(),&(StorableEngine)); Storable::RegistryStorableEngine(Plot3D_i::myComment.c_str(),&(StorableEngine)); @@ -1109,6 +1110,22 @@ namespace VISU theIteration)._retn(); } + //--------------------------------------------------------------- + CutSegment_ptr + VISU_Gen_i + ::CutSegmentOnField(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + CORBA::Long theIteration) + { + return Prs3dOnField(theResult, + theMeshName, + theEntity, + theFieldName, + theIteration)._retn(); + } + //--------------------------------------------------------------- struct CreateTableEvent: public SALOME_Event { diff --git a/src/VISU_I/VISU_Gen_i.hh b/src/VISU_I/VISU_Gen_i.hh index baee2831..26a42a5b 100644 --- a/src/VISU_I/VISU_Gen_i.hh +++ b/src/VISU_I/VISU_Gen_i.hh @@ -231,6 +231,14 @@ namespace VISU const char* theFieldName, CORBA::Long theIteration); + virtual + CutSegment_ptr + CutSegmentOnField(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + CORBA::Long theIteration); + virtual StreamLines_ptr StreamLinesOnField(Result_ptr theResult, diff --git a/src/VISU_I/VISU_I.cxx b/src/VISU_I/VISU_I.cxx index 825aec9f..49d32432 100644 --- a/src/VISU_I/VISU_I.cxx +++ b/src/VISU_I/VISU_I.cxx @@ -39,6 +39,7 @@ #include "VISU_Plot3D_i.hh" #include "VISU_CutPlanes_i.hh" #include "VISU_CutLines_i.hh" +#include "VISU_CutSegment_i.hh" #include "VISU_Vectors_i.hh" #include "VISU_StreamLines_i.hh" #include "VISU_GaussPoints_i.hh" diff --git a/src/VISU_I/VISU_PointMap3d_i.cc b/src/VISU_I/VISU_PointMap3d_i.cc index f03b72ca..aebf5c9c 100644 --- a/src/VISU_I/VISU_PointMap3d_i.cc +++ b/src/VISU_I/VISU_PointMap3d_i.cc @@ -26,7 +26,7 @@ // #include "VISU_PointMap3d_i.hh" -#include "VISU_CutLines_i.hh" +#include "VISU_CutLinesBase_i.hh" #include "VISU_Result_i.hh" #include "VISU_ViewManager_i.hh" #include "VISU_ScalarBarActor.hxx" @@ -174,12 +174,12 @@ VISU::Storable* VISU::PointMap3d_i::Create() if ( GetName() == "" ) { if ( !mySObj->_is_nil() ) { - CutLines_i* pCutLines = NULL; + CutLinesBase_i* pCutLines = NULL; CORBA::Object_var anObj = SObjectToObject(mySObj); if(!CORBA::is_nil(anObj)){ - VISU::CutLines_var aCutLines = VISU::CutLines::_narrow(anObj); + VISU::CutLinesBase_var aCutLines = VISU::CutLinesBase::_narrow(anObj); if(!aCutLines->_is_nil()) - pCutLines = dynamic_cast(GetServant(aCutLines).in()); + pCutLines = dynamic_cast(GetServant(aCutLines).in()); } if (!pCutLines) if (mySObj->GetName()) SetName(mySObj->GetName(), false); @@ -487,12 +487,12 @@ VISU::Storable* VISU::PointMap3d_i::Build( int theRestoring ) SALOMEDS::SObject_var SO = mySObj; if ( !SO->_is_nil() ) { - CutLines_i* pCutLines = NULL; + CutLinesBase_i* pCutLines = NULL; CORBA::Object_var anObj = SObjectToObject(SO); if(!CORBA::is_nil(anObj)){ - VISU::CutLines_var aCutLines = VISU::CutLines::_narrow(anObj); + VISU::CutLinesBase_var aCutLines = VISU::CutLinesBase::_narrow(anObj); if(!aCutLines->_is_nil()) - pCutLines = dynamic_cast(GetServant(aCutLines).in()); + pCutLines = dynamic_cast(GetServant(aCutLines).in()); } SALOMEDS::Study_var aStudy = GetStudyDocument(); SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder(); diff --git a/src/VISU_I/VISU_Table_i.cc b/src/VISU_I/VISU_Table_i.cc index 2516a24d..cf044b28 100644 --- a/src/VISU_I/VISU_Table_i.cc +++ b/src/VISU_I/VISU_Table_i.cc @@ -26,7 +26,7 @@ // #include "VISU_Table_i.hh" -#include "VISU_CutLines_i.hh" +#include "VISU_CutLinesBase_i.hh" #include "VISU_Result_i.hh" #include "VISU_ViewManager_i.hh" @@ -183,12 +183,12 @@ VISU::Storable* VISU::Table_i::Create() // mpv (PAL 5357): if name attribute already exist at this label, use it as name of table if ( GetName() == "" ) if ( !mySObj->_is_nil() ) { - CutLines_i* pCutLines = NULL; + CutLinesBase_i* pCutLines = NULL; CORBA::Object_var anObj = SObjectToObject(mySObj); if(!CORBA::is_nil(anObj)){ - VISU::CutLines_var aCutLines = VISU::CutLines::_narrow(anObj); + VISU::CutLinesBase_var aCutLines = VISU::CutLinesBase::_narrow(anObj); if(!aCutLines->_is_nil()) - pCutLines = dynamic_cast(GetServant(aCutLines).in()); + pCutLines = dynamic_cast(GetServant(aCutLines).in()); } if (!pCutLines) if (mySObj->GetName()) SetName(mySObj->GetName(), false); @@ -209,12 +209,12 @@ VISU::Storable* VISU::Table_i::Build( int theRestoring ) SALOMEDS::SObject_var SO = mySObj; if ( !SO->_is_nil() ) { - CutLines_i* pCutLines = NULL; + CutLinesBase_i* pCutLines = NULL; CORBA::Object_var anObj = SObjectToObject(SO); if(!CORBA::is_nil(anObj)){ - VISU::CutLines_var aCutLines = VISU::CutLines::_narrow(anObj); + VISU::CutLinesBase_var aCutLines = VISU::CutLinesBase::_narrow(anObj); if(!aCutLines->_is_nil()) - pCutLines = dynamic_cast(GetServant(aCutLines).in()); + pCutLines = dynamic_cast(GetServant(aCutLines).in()); } SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder(); SALOMEDS::GenericAttribute_var anAttr; diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index 3437df86..20fb195c 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -42,6 +42,7 @@ #include "VISU_CutPlanes_i.hh" #include "VISU_Plot3D_i.hh" #include "VISU_CutLines_i.hh" +#include "VISU_CutSegment_i.hh" #include "VISU_Vectors_i.hh" #include "VISU_StreamLines_i.hh" #include "VISU_GaussPoints_i.hh" @@ -567,6 +568,15 @@ void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) myTimeMaxVal, aSequence); break; + case VISU::TCUTSEGMENT: // Cut Segment + GeneratePresentations(myStudy, + aData, + aResult, + isRangeDefined(), + myTimeMinVal, + myTimeMaxVal, + aSequence); + break; case VISU::TPLOT3D: // Plot3d GeneratePresentations(myStudy, aData, @@ -1688,6 +1698,9 @@ std::string GetPresentationComment (VISU::VISUType thePrsType) case VISU::TCUTLINES: aPrsCmt = VISU::CutLines_i::myComment; break; + case VISU::TCUTSEGMENT: + aPrsCmt = VISU::CutSegment_i::myComment; + break; case VISU::TPLOT3D: aPrsCmt = VISU::Plot3D_i::myComment; break; @@ -1910,6 +1923,8 @@ void VISU_TimeAnimation::restoreFromStudy(_PTR(SObject) theField) aData.myPrsType = VISU::TCUTPLANES; else if (strName == VISU::CutLines_i::myComment.c_str()) aData.myPrsType = VISU::TCUTLINES; + else if (strName == VISU::CutSegment_i::myComment.c_str()) + aData.myPrsType = VISU::TCUTSEGMENT; else if (strName == VISU::Plot3D_i::myComment.c_str()) aData.myPrsType = VISU::TPLOT3D; else if (strName == VISU::DeformedShape_i::myComment.c_str()) diff --git a/src/VISU_SWIG/batchmode_visu_view3d.py b/src/VISU_SWIG/batchmode_visu_view3d.py index 3bab3fb3..77dbab75 100644 --- a/src/VISU_SWIG/batchmode_visu_view3d.py +++ b/src/VISU_SWIG/batchmode_visu_view3d.py @@ -248,6 +248,49 @@ myView.Display(aContainer) +myView = myViewManager.Create3DView(); +myView.SetTitle("The viewer for CutSegment") +print "myViewManager.Create3DView()" +time.sleep(aDelay) + +print "myView.SetBackground(...)" +aColor = SALOMEDS.Color(0.0,0.7,0.3) +myView.SetBackground(aColor); +time.sleep(aDelay) + +aCutSegment = myVisu.CutSegmentOnField(myResult, aMeshName, anEntity, myFieldName, aTimeStampId) +aCutSegment.SetPoint1(0.0,0.0,0.0) +aCutSegment.SetPoint2(0.4,0.05,1.0) + +myView.DisplayOnly(aCutSegment); +myView.FitAll(); +print "myView.DisplayOnly(aCutSegment)" +time.sleep(aDelay) + +aSObj = myStudy.FindObjectIOR(aCutSegment.GetID()) +aTable = myVisu.CreateTable( aSObj.GetID() ) +print "myVisu.CreateTable(...)" + +aTableView = myViewManager.CreateTableView(aTable) +aTableView.SetTitle('Changed Title') + +aContainer = myVisu.CreateContainer() +print "myVisu.CreateContainer(...)" + +aCurve = myVisu.CreateCurve( aTable, 1, 2 ) +print aCurve +aContainer.AddCurve(aCurve) + + +myView = myViewManager.CreateXYPlot(); +myView.SetTitle("The viewer for Curve from CutSegment") +print "myViewManager.CreateXYPlot()" +time.sleep(aDelay) + +myView.Display(aContainer) + + + myView = myViewManager.Create3DView(); myView.SetTitle("The viewer for Animation") print "myViewManager.Create3DView()" diff --git a/src/VISU_SWIG/visu.py b/src/VISU_SWIG/visu.py index 42fead87..14c06e43 100644 --- a/src/VISU_SWIG/visu.py +++ b/src/VISU_SWIG/visu.py @@ -559,6 +559,22 @@ def CreatePrsForResult(theVisu, theResult, theView, thePrsTypeList, thePictureDi else : aVISUObjList.append(aPrsObj) + if HasValue(thePrsTypeList,VISU.TCUTSEGMENT) : + print " Creating CutSegmentOnField", + aPrsObj = theVisu.CutSegmentOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId) + if aPrsObj is None : print "Error" + else : + print ",OK" + theView.DisplayOnly(aPrsObj) + theView.FitAll() + aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TCUTSEGMENT." + thePictureExt + aPictureName = re.sub("\s+","_", aPictureName) + theView.SavePicture(aPictureName) + if theIsAutoDelete : + aPrsObj.RemoveFromStudy() + else : + aVISUObjList.append(aPrsObj) + if HasValue(thePrsTypeList,VISU.TPLOT3D) : print " Creating Plot3DOnField", aPrsObj = theVisu.Plot3DOnField(theResult,aMeshName,anEntity, @@ -900,6 +916,36 @@ def dump_cutlines_parameters(theObject): print "GetRotateY() = ", str(theObject.GetRotateY()) print "GetRotateY2() = ", str(theObject.GetRotateY2()) +# ---------------------- +# CUT SEGMENT +# ---------------------- +def try_cutsegment_parameters(thePattern): + + if thePattern is None : return None + import copy + import random + + anObj = try_scalarmap_parameters(thePattern) + + anObj.SetPoint1(random.randint(-100,100)*random.random(), + random.randint(-100,100)*random.random(), + random.randint(-100,100)*random.random()) + anObj.SetPoint2(random.randint(-100,100)*random.random(), + random.randint(-100,100)*random.random(), + random.randint(-100,100)*random.random()) + + return anObj + +def dump_cutsegment_parameters(theObject): + dump_scalarmap_parameters(theObject) + + x1 = y1 = z1 = 0 + x2 = y2 = z2 = 0 + theObject.GetPoint1(x1, y1, z1) + theObject.GetPoint1(x2, y2, z2) + print "GetPoint1() = " + str(x1) + ", " + str(y1) + ", " + str(z1) + print "GetPoint2() = " + str(x2) + ", " + str(y2) + ", " + str(z2) + # ---------------------- # STREAM LINES # ---------------------- diff --git a/src/VISU_SWIG/visu_cache.py b/src/VISU_SWIG/visu_cache.py index 432a14fa..6bb81639 100644 --- a/src/VISU_SWIG/visu_cache.py +++ b/src/VISU_SWIG/visu_cache.py @@ -72,6 +72,7 @@ PRS3D_TYPE_LIST.append(VISU.TSCALARMAP) PRS3D_TYPE_LIST.append(VISU.TISOSURFACES) PRS3D_TYPE_LIST.append(VISU.TCUTPLANES) PRS3D_TYPE_LIST.append(VISU.TCUTLINES) +PRS3D_TYPE_LIST.append(VISU.TCUTSEGMENT) PRS3D_TYPE_LIST.append(VISU.TPLOT3D) PRS3D_TYPE_LIST.append(VISU.TDEFORMEDSHAPE) PRS3D_TYPE_LIST.append(VISU.TVECTORS) diff --git a/src/VISU_SWIG/visu_view3d.py b/src/VISU_SWIG/visu_view3d.py index fa68e6f8..bc95a9e6 100644 --- a/src/VISU_SWIG/visu_view3d.py +++ b/src/VISU_SWIG/visu_view3d.py @@ -255,6 +255,49 @@ myView.Display(aContainer) +myView = myViewManager.Create3DView(); +myView.SetTitle("The viewer for CutSegment") +print "myViewManager.Create3DView()" +time.sleep(aDelay) + +print "myView.SetBackground(...)" +aColor = SALOMEDS.Color(0.0,0.7,0.3) +myView.SetBackground(aColor); +time.sleep(aDelay) + +aCutSegment = myVisu.CutSegmentOnField(myResult, aMeshName, anEntity, myFieldName, aTimeStampId) +aCutSegment.SetPoint1(0.0,0.0,0.0) +aCutSegment.SetPoint2(0.4,0.05,1.0) + +myView.DisplayOnly(aCutSegment); +myView.FitAll(); +print "myView.DisplayOnly(aCutSegment)" +time.sleep(aDelay) + +aSObj = myStudy.FindObjectIOR(aCutSegment.GetID()) +aTable = myVisu.CreateTable( aSObj.GetID() ) +print "myVisu.CreateTable(...)" + +aTableView = myViewManager.CreateTableView(aTable) +aTableView.SetTitle('Changed Title') + +aContainer = myVisu.CreateContainer() +print "myVisu.CreateContainer(...)" + +aCurve = myVisu.CreateCurve( aTable, 1, 2 ) +print aCurve +aContainer.AddCurve(aCurve) + + +myView = myViewManager.CreateXYPlot(); +myView.SetTitle("The viewer for Curve from CutSegment") +print "myViewManager.CreateXYPlot()" +time.sleep(aDelay) + +myView.Display(aContainer) + + + myView = myViewManager.Create3DView(); myView.SetTitle("The viewer for Animation") print "myViewManager.Create3DView()"