From 93fd01983467e9b194b575fd21dfecffabdf3bdc Mon Sep 17 00:00:00 2001 From: apo Date: Tue, 26 Apr 2005 06:43:03 +0000 Subject: [PATCH] PostPro 2005, T1.5: 2D fields displayed in 3D --- idl/VISU_Gen.idl | 36 ++--- src/PIPELINE/VISU_Plot3DPL.cxx | 24 ++++ src/PIPELINE/VISU_Plot3DPL.hxx | 6 + src/VISUGUI/Makefile.in | 2 + src/VISUGUI/VisuGUI_Plot3DDlg.cxx | 213 ++++++++++++++++++++++++++++++ src/VISUGUI/VisuGUI_Plot3DDlg.h | 98 ++++++++++++++ src/VISU_I/VISU_Plot3D_i.cc | 20 ++- src/VISU_I/VISU_Plot3D_i.hh | 4 +- 8 files changed, 373 insertions(+), 30 deletions(-) create mode 100644 src/VISUGUI/VisuGUI_Plot3DDlg.cxx create mode 100644 src/VISUGUI/VisuGUI_Plot3DDlg.h diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index 322c4e33..6c5f0d50 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -485,72 +485,74 @@ Gets the scale of the presentatable object. * \brief Plot3D interface * * Presentation parameters of Plot3D presentation. This type of presentation - * consists of cutting your initial mesh by a definite number of planes. As the - * result you will see these planes which will be cutted by the borders of the mesh. + * consists of deforming initial planar mesh according to values assigned to the mesh elements. + * If mesh not planar but volumic one, it is possible to generate intermediate planar mesh. */ interface Plot3D : ScalarMap { /*! * This enumeration contains a set of elements defining - * the type of orientation in 3D space of the cut planes. + * the type of orientation in 3D space of the cutting plane. */ enum Orientation { XY, /*!< The object is located in the plane formed by X and Y axis. */ YZ, /*!< The object is located in the plane formed by Y and Z axis. */ ZX }; /*!< The object is located in the plane formed by Z and X axis. */ /*! - * Sets the type of orientation in 3D space of cut planes presentation. - * \param theOrientation This parameter defines the type of orientation of cut planes + * Sets the orientation in 3D space of cutting plane for the presentation. + * \param theOrientation This parameter defines the type of orientation of cutting plane * in 3D space. It is taken from the Orientation enumeration. - * \param theXAngle The angle of rotation of the cut planes + * \param theXAngle The angle of rotation of the cutting plane * around the first axis of the chosen orientation. - * \param theXAngle The angle of rotation of the cut planes + * \param theXAngle The angle of rotation of the cutting plane * around the second axis of the chosen orientation. */ void SetOrientation (in Orientation theOrientation, in double theXAngle, in double theYAngle); /*! - * Gets the type of orientation in 3D space of cut planes presentation. + * Gets the type of orientation in 3D space of cutting plane. */ Orientation GetOrientationType(); /*! - * Gets rotation angle of the cut plane presentation + * Gets rotation angle of the cutting plane * around the first axis of the chosen orientation. */ - //double GetRotateX(); + double GetRotateX(); /*! - * Gets rotation angle of the cut plane presentation + * Gets rotation angle of the cutting plane * around the second axis of the chosen orientation. */ - //double GetRotateY(); + double GetRotateY(); /*! - * Sets the position of a cut plane. - * \param thePlanePosition The position of the cut plane. + * Sets the position of a cutting plane. + * \param thePlanePosition The position of the cutting plane. * \param theIsRelative Define, whether the input position is relative. */ void SetPlanePosition (in double thePlanePosition, in boolean theIsRelative); /*! - * Gets the position of the cut plane + * Gets the position of the cutting plane */ double GetPlanePosition(); /*! - * Returns true if a position of cut plane is relative + * Returns true if a position of cutting plane is relative */ boolean IsPositionRelative(); /*! - * Sets the scale factor for scalar values. + * Sets the scale factor for scalar values + * (how much corresponding mesh elements should be translated). * \param theScaleFactor The scaling factor. */ void SetScaleFactor (in double theScaleFactor); /*! * Gets the scale factor for scalar values. + * (how much corresponding mesh elements is translated) */ double GetScaleFactor(); diff --git a/src/PIPELINE/VISU_Plot3DPL.cxx b/src/PIPELINE/VISU_Plot3DPL.cxx index 0f4e02c9..2f78d530 100644 --- a/src/PIPELINE/VISU_Plot3DPL.cxx +++ b/src/PIPELINE/VISU_Plot3DPL.cxx @@ -247,6 +247,30 @@ GetPlaneOrientation() const return myOrientation; } + +float +VISU_Plot3DPL:: +GetRotateX() +{ + switch(myOrientation){ + case VISU_CutPlanesPL::XY: return myAngle[0]; + case VISU_CutPlanesPL::YZ: return myAngle[1]; + case VISU_CutPlanesPL::ZX: return myAngle[2]; + } + return 0; +} + +float +VISU_Plot3DPL:: +GetRotateY(){ + switch(myOrientation){ + case VISU_CutPlanesPL::XY: return myAngle[1]; + case VISU_CutPlanesPL::YZ: return myAngle[2]; + case VISU_CutPlanesPL::ZX: return myAngle[0]; + } + return 0; +} + void VISU_Plot3DPL:: SetOrientation(VISU_CutPlanesPL::PlaneOrientation theOrientation, diff --git a/src/PIPELINE/VISU_Plot3DPL.hxx b/src/PIPELINE/VISU_Plot3DPL.hxx index 7924c25c..1e406928 100644 --- a/src/PIPELINE/VISU_Plot3DPL.hxx +++ b/src/PIPELINE/VISU_Plot3DPL.hxx @@ -52,6 +52,12 @@ public: VISU_CutPlanesPL::PlaneOrientation GetPlaneOrientation() const; + float + GetRotateX(); + + float + GetRotateY(); + void SetOrientation(VISU_CutPlanesPL::PlaneOrientation theOrientation, float theXAngle = 0.0, diff --git a/src/VISUGUI/Makefile.in b/src/VISUGUI/Makefile.in index e5af114c..2ed8d01e 100644 --- a/src/VISUGUI/Makefile.in +++ b/src/VISUGUI/Makefile.in @@ -57,6 +57,7 @@ LIB_SRC = VisuGUI.cxx \ VisuGUI_TimeAnimation.cxx \ VisuGUI_CutLinesDlg.cxx \ VisuGUI_FileDlg.cxx \ + VisuGUI_Plot3DDlg.cxx \ VisuGUI_ClippingDlg.cxx \ VisuGUI_EditContainerDlg.cxx @@ -74,6 +75,7 @@ LIB_MOC = \ VisuGUI_TimeAnimation.h \ VisuGUI_CutLinesDlg.h \ VisuGUI_FileDlg.h \ + VisuGUI_Plot3DDlg.h \ VisuGUI_ClippingDlg.h \ VisuGUI_EditContainerDlg.h \ VisuGUI_Selection.h diff --git a/src/VISUGUI/VisuGUI_Plot3DDlg.cxx b/src/VISUGUI/VisuGUI_Plot3DDlg.cxx new file mode 100644 index 00000000..d3d0e070 --- /dev/null +++ b/src/VISUGUI/VisuGUI_Plot3DDlg.cxx @@ -0,0 +1,213 @@ +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_Plot3DDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU +// $Header$ + +#include "VisuGUI_Plot3DDlg.h" +#include "VISU_IsoSurfaces_i.hh" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" + +#include + +#include +#include +#include + + +using namespace std; + + +VisuGUI_Plot3DPane::VisuGUI_Plot3DPane(QWidget* parent) + : QVBox(parent) +{ + QFrame* TopGroup = new QFrame( this, "TopGroup" ); + TopGroup->setFrameStyle(QFrame::Box | QFrame::Sunken); + TopGroup->setLineWidth(1); + + QGridLayout* TopGroupLayout = new QGridLayout(TopGroup); + TopGroupLayout->setAlignment( Qt::AlignTop ); + TopGroupLayout->setSpacing( 6 ); + TopGroupLayout->setMargin( 11 ); + + QLabel* LabelNbr = new QLabel( tr( "Number of surfaces:" ), TopGroup, "LabelNbr" ); + TopGroupLayout->addWidget( LabelNbr, 0, 0 ); + NbrIso = new QSpinBox( 1, 100, 1, TopGroup, "NbrIso" ); + NbrIso->setValue( 1 ); + TopGroupLayout->addWidget( NbrIso, 0, 1 ); + + QLabel* LabelMin = new QLabel( tr( "Minimum value:" ), TopGroup, "LabelMin" ); + TopGroupLayout->addWidget( LabelMin, 1, 0 ); + //MinIso = new QAD_SpinBoxDbl( TopGroup, -DBL_MAX, DBL_MAX, 0.1 ); + MinIso = new QLineEdit( TopGroup ); + MinIso->setValidator( new QDoubleValidator(TopGroup) ); + MinIso->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + MinIso->setMinimumSize( 70, 0 ); + LabelMin->setBuddy(MinIso); + TopGroupLayout->addWidget( MinIso, 1, 1 ); + + QLabel* LabelMax = new QLabel( tr( "Maximum value:" ), TopGroup, "LabelMax" ); + TopGroupLayout->addWidget( LabelMax, 2, 0 ); + //MaxIso = new QAD_SpinBoxDbl( TopGroup, -DBL_MAX, DBL_MAX, 0.1); + MaxIso = new QLineEdit( TopGroup ); + MaxIso->setValidator( new QDoubleValidator(TopGroup) ); + MaxIso->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + MaxIso->setMinimumSize( 70, 0 ); + LabelMax->setBuddy(MaxIso); + TopGroupLayout->addWidget( MaxIso, 2, 1 ); + + +// CBUpdate = new QCheckBox ( tr( "Update scalar bar with these values" ), TopGroup); +// CBUpdate->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) ); +// TopGroupLayout->addMultiCellWidget( CBUpdate, 4, 4, 0, 1); +// CBUpdate->setChecked(false); + QPushButton* aUpdateBtn = new QPushButton( "Update scalar bar range with these values", TopGroup); + TopGroupLayout->addMultiCellWidget( aUpdateBtn, 3, 3, 0, 1); + connect( aUpdateBtn, SIGNAL( clicked() ), this, SLOT(onCBUpdate() ) ); + +// CBLog = new QCheckBox ( tr( "Logarithmic scaling" ), TopGroup); +// CBLog->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) ); +// TopGroupLayout->addMultiCellWidget( CBLog, 3, 3, 0, 1); + +} + + + +void VisuGUI_Plot3DPane::initFromPrsObject(VISU::IsoSurfaces_i* thePrs) { + NbrIso->setValue(thePrs->GetNbSurfaces()); + MinIso->setText(QString::number(thePrs->GetSubMin())); + MaxIso->setText(QString::number(thePrs->GetSubMax())); +// switch(thePrs->GetScaling()){ +// case VISU::LOGARITHMIC : +// CBLog->setChecked(true); +// break; +// default: +// CBLog->setChecked(false); +// } +} + +int VisuGUI_Plot3DPane::storeToPrsObject(VISU::IsoSurfaces_i* thePrs) { + thePrs->SetNbSurfaces(NbrIso->value()); + thePrs->SetSubRange(MinIso->text().toDouble(), MaxIso->text().toDouble()); + return 1; +// if (CBUpdate->isChecked()) +// { +// thePrs->SetRange(MinIso->text().toDouble(), MaxIso->text().toDouble()); +// if (CBLog->isChecked()) +// thePrs->SetScaling(VISU::LOGARITHMIC); +// else +// thePrs->SetScaling(VISU::LINEAR); +// } +} + +void VisuGUI_Plot3DPane::onCBUpdate() +{ + // if (CBUpdate->isChecked()) { + myScalarPane->setRange(MinIso->text().toDouble(), MaxIso->text().toDouble(), true); + // } +// CBLog->setDisabled(false); +// else CBLog->setDisabled(true); +} + + +bool VisuGUI_Plot3DPane::check() { + if (MinIso->text().toDouble() >= MaxIso->text().toDouble()) { + MESSAGE(tr("MSG_MINMAX_VALUES")); + QAD_MessageBox::warn1( this,tr("VISU_WARNING"), + tr("MSG_MINMAX_VALUES"), + tr("VISU_BUT_OK")); + return false; + } // else if (/* CBUpdate->isChecked() && CBLog->isChecked() && */ +// (MinIso->text().toDouble() <=0 || MaxIso->text().toDouble() <=0) ) { +// QAD_MessageBox::warn1( this, +// tr("VISU_WARNING"), +// tr("WRN_LOGARITHMIC_RANGE_ISOSURF"), +// tr("VISU_BUT_OK")); +// return false; +// } + return true; +} + + + + + +/*! + Constructor +*/ +VisuGUI_Plot3DDlg::VisuGUI_Plot3DDlg() + : QDialog( QAD_Application::getDesktop(), "VisuGUI_Plot3DDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + setCaption( tr( "Iso Surfaces Definition" ) ); + setSizeGripEnabled( TRUE ); + + QVBoxLayout* TopLayout = new QVBoxLayout(this); + TopLayout->setSpacing( 6 ); + TopLayout->setMargin(11); + + QTabWidget* aTabBox = new QTabWidget(this); + myIsoPane = new VisuGUI_Plot3DPane(this); + myIsoPane->setMargin( 5 ); + aTabBox->addTab(myIsoPane, "Iso Surface"); + myScalarPane = new VisuGUI_ScalarBarPane(this, false); + myIsoPane->setScalarBarPane(myScalarPane); + myScalarPane->setMargin( 5 ); + aTabBox->addTab(myScalarPane, "Scalar Bar"); + + TopLayout->addWidget(aTabBox); + + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 2 ); + + TopLayout->addWidget(GroupButtons); + + // signals and slots connections + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); +} + +void VisuGUI_Plot3DDlg::accept() { + if (myIsoPane->check() && myScalarPane->check()) QDialog::accept(); +} + diff --git a/src/VISUGUI/VisuGUI_Plot3DDlg.h b/src/VISUGUI/VisuGUI_Plot3DDlg.h new file mode 100644 index 00000000..caa7094e --- /dev/null +++ b/src/VISUGUI/VisuGUI_Plot3DDlg.h @@ -0,0 +1,98 @@ +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_Plot3DDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU +// $Header$ + +#ifndef VISUGUI_ISOSURFACESDLG_H +#define VISUGUI_ISOSURFACESDLG_H + +#include "VisuGUI_ScalarBarDlg.h" +#include "VISU_IsoSurfaces_i.hh" + +#include +#include +#include +#include +#include +#include +#include + + + +class VisuGUI_Plot3DPane : public QVBox +{ + Q_OBJECT + +public: + VisuGUI_Plot3DPane(QWidget* parent); + ~VisuGUI_Plot3DPane() {}; + + void initFromPrsObject(VISU::IsoSurfaces_i* thePrs); + int storeToPrsObject(VISU::IsoSurfaces_i* thePrs); + + void setScalarBarPane(VisuGUI_ScalarBarPane* theScalarPane) {myScalarPane = theScalarPane;} + VisuGUI_ScalarBarPane* getScalarBarPane() {return myScalarPane;} + + bool check(); + +protected slots: + void onCBUpdate(); + +private: + QLineEdit* MinIso; + QLineEdit* MaxIso; + QSpinBox* NbrIso; + //QCheckBox* CBUpdate; + VisuGUI_ScalarBarPane* myScalarPane; + // QCheckBox* CBLog; +}; + + + + +class VisuGUI_Plot3DDlg : public QDialog +{ + Q_OBJECT + +public: + VisuGUI_Plot3DDlg(); + ~VisuGUI_Plot3DDlg() {}; + + void initFromPrsObject(VISU::IsoSurfaces_i* thePrs) + {myScalarPane->initFromPrsObject(thePrs); myIsoPane->initFromPrsObject(thePrs);} + + int storeToPrsObject(VISU::IsoSurfaces_i* thePrs) + {return myScalarPane->storeToPrsObject(thePrs) && myIsoPane->storeToPrsObject(thePrs);} + +protected slots: + void accept(); + +private: + VisuGUI_Plot3DPane* myIsoPane; + VisuGUI_ScalarBarPane* myScalarPane; +}; + +#endif // VISUGUI_ISOSURFACESDLG_H diff --git a/src/VISU_I/VISU_Plot3D_i.cc b/src/VISU_I/VISU_Plot3D_i.cc index c7f25dca..6755db81 100644 --- a/src/VISU_I/VISU_Plot3D_i.cc +++ b/src/VISU_I/VISU_Plot3D_i.cc @@ -91,17 +91,15 @@ VISU::Plot3D::Orientation VISU::Plot3D_i::GetOrientationType() return VISU::Plot3D::Orientation(myPlot3DPL->GetPlaneOrientation()); } -//CORBA::Double VISU::Plot3D_i::GetRotateX() -//{ -// //return myPlot3DPL->GetRotateX(); -// return 0.0; -//} -// -//CORBA::Double VISU::Plot3D_i::GetRotateY() -//{ -// //return myPlot3DPL->GetRotateY(); -// return 0.0; -//} +CORBA::Double VISU::Plot3D_i::GetRotateX() +{ + return myPlot3DPL->GetRotateX(); +} + +CORBA::Double VISU::Plot3D_i::GetRotateY() +{ + return myPlot3DPL->GetRotateY(); +} void VISU::Plot3D_i::SetPlanePosition (CORBA::Double thePlanePosition, CORBA::Boolean theIsRelative) diff --git a/src/VISU_I/VISU_Plot3D_i.hh b/src/VISU_I/VISU_Plot3D_i.hh index e0548c79..adc45ff9 100644 --- a/src/VISU_I/VISU_Plot3D_i.hh +++ b/src/VISU_I/VISU_Plot3D_i.hh @@ -27,8 +27,8 @@ namespace VISU { virtual VISU::Plot3D::Orientation GetOrientationType(); - //virtual CORBA::Double GetRotateX(); - //virtual CORBA::Double GetRotateY(); + virtual CORBA::Double GetRotateX(); + virtual CORBA::Double GetRotateY(); virtual void SetPlanePosition (CORBA::Double thePlanePosition, CORBA::Boolean theIsRelative); -- 2.39.2