// 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
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : VisuGUI_CutPlanesDlg.cxx
-// Author : Laurent CORNABE & Hubert ROLLAND
+// Author : Laurent CORNABE & Hubert ROLLAND
// Module : VISU
// $Header$
#include "VisuGUI_CutPlanesDlg.h"
+
+#include "VisuGUI.h"
+#include "VisuGUI_Tools.h"
+
#include "VISU_CutPlanes_i.hh"
+#include "VISU_CutPlanesPL.hxx"
+
+#include "OB_Browser.h"
+
+#include "SVTK_ViewWindow.h"
+
+#include "SalomeApp_Application.h"
-#include "QAD_Application.h"
-#include "QAD_Desktop.h"
+#include "SUIT_Application.h"
+#include "SUIT_Desktop.h"
+#include "SUIT_ViewWindow.h"
+#include "SUIT_ViewManager.h"
#include <qlayout.h>
#include <qcheckbox.h>
#include <qstring.h>
#include <qvalidator.h>
#include <qlineedit.h>
+#include <qtabwidget.h>
+
+#include <vtkRenderer.h>
+#include <vtkPolyData.h>
+#include <vtkAppendPolyData.h>
+#include <vtkDataSetMapper.h>
using namespace std;
-/*!
- Constructor
-*/
-VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg()
- : QDialog( QAD_Application::getDesktop(), "VisuGUI_CutPlanesDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
-{
- setCaption( tr( "Cut Planes Definition" ) );
- setSizeGripEnabled( TRUE );
+//extern VisuGUI *visuGUI;
- QGridLayout* TopLayout = new QGridLayout( this );
+VisuGUI_CutPlanesPane::VisuGUI_CutPlanesPane (QWidget* theParent)
+ : QFrame(theParent), myPreviewActor(0)
+{
+ QGridLayout* TopLayout = new QGridLayout( this );
TopLayout->setSpacing( 6 );
- TopLayout->setMargin( 11 );
-
- QButtonGroup* SelPlane = new QButtonGroup( tr( "Orientation" ), this, "SelPlane" );
- SelPlane->setTitle( tr( "Orientation" ) );
- SelPlane->setColumnLayout(0, Qt::Vertical );
+ TopLayout->setMargin( 10 );
+
+ QButtonGroup* SelPlane = new QButtonGroup (tr("TXT_ORIENTATION"), this, "SelPlane");
+ //SelPlane->setTitle(tr("TXT_ORIENTATION"));
+ SelPlane->setColumnLayout(0, Qt::Vertical);
SelPlane->layout()->setSpacing( 0 );
SelPlane->layout()->setMargin( 0 );
QGridLayout* SelPlaneLayout = new QGridLayout( SelPlane->layout() );
SelPlaneLayout->setSpacing( 6 );
SelPlaneLayout->setMargin( 11 );
- RBzx = new QRadioButton( tr( "// Z-X" ), SelPlane, "RBzx" );
- RByz = new QRadioButton( tr( "// Y-Z" ), SelPlane, "RByz" );
- RBxy = new QRadioButton( tr( "// X-Y" ), SelPlane, "RBxy" );
+ RBxy = new QRadioButton (tr("PARALLEL_XOY"), SelPlane, "RBxy");
+ RByz = new QRadioButton (tr("PARALLEL_YOZ"), SelPlane, "RByz");
+ RBzx = new QRadioButton (tr("PARALLEL_ZOX"), SelPlane, "RBzx");
SelPlaneLayout->addWidget( RBxy, 0, 0 );
SelPlaneLayout->addWidget( RByz, 0, 1 );
SelPlaneLayout->addWidget( RBzx, 0, 2 );
- QLabel* LabelPosi_3 = new QLabel( tr( "Number of planes:" ), this, "LabelPosi_3" );
+ QLabel* LabelPosi_3 = new QLabel (tr("LBL_NB_PLANS"), this, "LabelPosi_3");
nbPlan = new QSpinBox( 1, 100, 1, this, "nbPlan" );
nbPlan->setValue( 1 );
nbPlan->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- myPosTable = new QTable(this, "Positions of planes" );
+ myPosTable = new QTable (this, "Positions of planes");
myPosTable->setMaximumHeight( 227 );
myPosTable->setMinimumWidth( 294 );
- //myPosTable->setGeometry( QRect( 11, 98, 289, 325 ) );
myPosTable->setNumCols(2);
myPosTable->setNumRows(0);
-
+ connect( myPosTable, SIGNAL(valueChanged(int, int)), this, SLOT(onValueChanged(int, int)) );
+
QHeader *th = myPosTable->horizontalHeader();
th->setLabel( 0, "Position" );
th->setLabel( 1, "Set default" );
-
- QGroupBox* GBrot = new QGroupBox( tr( "Rotations" ), this, "GBrot" );
- GBrot->setColumnLayout(0, Qt::Vertical );
+ th->setStyle("QStyle::CE_PushButton");
+
+ QGroupBox* GBrot = new QGroupBox (tr("LBL_ROTATION"), this, "GBrot");
+ GBrot->setColumnLayout(0, Qt::Vertical);
GBrot->layout()->setSpacing( 0 );
GBrot->layout()->setMargin( 0 );
QGridLayout* GBrotLayout = new QGridLayout( GBrot->layout() );
GBrotLayout->setSpacing( 6 );
GBrotLayout->setMargin( 11 );
- LabelRot1 = new QLabel( tr( "Rotation around X (Y to Z):" ), GBrot, "LabelRot1" );
+ LabelRot1 = new QLabel (tr("LBL_ROT_X"), GBrot, "LabelRot1");
GBrotLayout->addWidget( LabelRot1, 0, 0 );
- Rot1 = new QAD_SpinBoxDbl( GBrot, -180, 180, 10 );
+ Rot1 = new QtxDblSpinBox( -180, 180, 10, GBrot );
Rot1->setValue( 0 );
Rot1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ connect( Rot1, SIGNAL( valueChanged( double )), this, SLOT( onRotation( double ) ) );
GBrotLayout->addWidget( Rot1, 0, 1 );
- LabelRot2 = new QLabel( tr( "Rotation around Y (Z to X):" ), GBrot, "LabelRot2" );
+ LabelRot2 = new QLabel (tr("LBL_ROT_Y"), GBrot, "LabelRot2");
GBrotLayout->addWidget( LabelRot2, 1, 0 );
-
- Rot2 = new QAD_SpinBoxDbl( GBrot, -180, 180, 10 );
+
+ Rot2 = new QtxDblSpinBox( -180, 180, 10, GBrot );
Rot2->setValue( 0 );
Rot2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ connect( Rot2, SIGNAL( valueChanged( double )), this, SLOT( onRotation( double ) ) );
GBrotLayout->addWidget( Rot2, 1, 1 );
- QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
- GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
- GroupButtons->setTitle( tr( "" ) );
- 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 );
-
QLabel* aPosLbl = new QLabel(tr( "LBL_POS" ), this);
- myPosSpn = new QAD_SpinBoxDbl( this, 0, 1, 0.1 );
+ myPosSpn = new QtxDblSpinBox( 0, 1, 0.1, this );
- th->setStyle("QStyle::CE_PushButton");
+ myPreviewCheck = new QCheckBox(tr("LBL_SHOW_PREVIEW"), this);
+ myPreviewCheck->setChecked(false);
+ connect( myPreviewCheck, SIGNAL( toggled( bool )), this, SLOT( onPreviewCheck( bool ) ) );
- // layouting
TopLayout->addMultiCellWidget( SelPlane, 0, 0, 0, 1 );
TopLayout->addMultiCellWidget( GBrot, 1, 1, 0, 1 );
TopLayout->addWidget( LabelPosi_3, 2, 0 );
TopLayout->setRowStretch ( 3, 3 );
TopLayout->addWidget(aPosLbl, 4, 0 );
TopLayout->addWidget(myPosSpn, 4, 1 );
- TopLayout->addMultiCellWidget( GroupButtons, 5, 5, 0, 1 );
+ TopLayout->addMultiCellWidget( myPreviewCheck, 5, 5, 0, 1 );
// signals and slots connections
connect( SelPlane, SIGNAL( clicked( int )), this, SLOT( orientationChanged( int ) ) );
connect( nbPlan, SIGNAL( valueChanged( int )), this, SLOT( DrawTable( ) ) );
connect( myPosSpn, SIGNAL( valueChanged( double )), this, SLOT( DrawTable( ) ) );
- connect( RBzx, SIGNAL( toggled(bool)), this, SLOT( DrawTable( ) ) );
- connect( RByz, SIGNAL( toggled(bool)), this, SLOT( DrawTable( ) ) );
- connect( RBxy, SIGNAL( toggled(bool)), this, SLOT( DrawTable( ) ) );
connect( th, SIGNAL( clicked(int)), this, SLOT( setDefault(int) ) );
- connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
- connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
-
- myCutPlanes = NULL;
-
// default values
+ myCutPlanes = NULL;
hasInit = false;
X1 = 0; X2 = 0;
Y1 = 0; Y2 = 0;
Z1 = 0; Z2 = 0;
RByz->setChecked( true );
- orientationChanged( 0 );
-}
-/*!
- Destructor
-*/
-VisuGUI_CutPlanesDlg::~VisuGUI_CutPlanesDlg()
+} // End of Constructor
+
+VisuGUI_CutPlanesPane::~VisuGUI_CutPlanesPane()
{
- if(myCutPlanes) delete myCutPlanes;
+ cout<<"### VisuGUI_CutPlanesPane::~VisuGUI_CutPlanesPane"<<endl;
+ deletePlanes();
+ if (myCutPlanes)
+ myCutPlanes->Destroy();
+ if (SVTK_ViewWindow* vf = VISU::GetViewWindow())
+ vf->Repaint();
}
-
-void VisuGUI_CutPlanesDlg::initFromPrsObject(VISU::CutPlanes_i* thePrs) {
+void VisuGUI_CutPlanesPane::initFromPrsObject (VISU::CutPlanes_i* thePrs)
+{
setNbPlanes(thePrs->GetNbPlanes());
setRotation(thePrs->GetRotateX()*180./PI, thePrs->GetRotateY()*180./PI);
setPlanePos(thePrs->GetOrientationType());
myCutPlanes = new VISU::CutPlanes_i(thePrs->GetResult(),false);
myCutPlanes->SameAs(thePrs);
DrawTable();
-}
-void VisuGUI_CutPlanesDlg::storeToPrsObject(VISU::CutPlanes_i* thePrs) {
- thePrs->SetNbPlanes(getNbPlanes());
- thePrs->SetRotateX(getRotation1()*PI/180.);
- thePrs->SetRotateY(getRotation2()*PI/180.);
- thePrs->SetOrientationType(getOrientaion());
- thePrs->SetDisplacement(myPosSpn->value());
- for (int i = 0; i < getNbPlanes(); ++i)
- {
- if (!((QCheckBox*)myPosTable->cellWidget( i, 1 ))->isChecked())
- thePrs->SetPlanePosition( i, ((QLineEdit*)myPosTable->cellWidget( i, 0 ))->text().toDouble() );
- else thePrs->SetDefault(i);
- }
-}
-
-/*!
- Called when orientation is changed
-*/
-void VisuGUI_CutPlanesDlg::orientationChanged( int )
-{
- if ( RBxy->isChecked() ) {
- LabelRot1->setText( tr( "Rotation around X (Y to Z):" ) );
- LabelRot2->setText( tr( "Rotation around Y (Z to X):" ) );
- } else if ( RByz->isChecked() ) {
- LabelRot1->setText( tr( "Rotation around Y (Z to X):" ) );
- LabelRot2->setText( tr( "Rotation around Z (X to Y):" ) );
- } else {
- LabelRot1->setText( tr( "Rotation around Z (X to Y):" ) );
- LabelRot2->setText( tr( "Rotation around X (Y to Z):" ) );
+ // Draw Preview
+ if (myPreviewCheck->isChecked()) {
+ createPlanes();
}
}
-
-
-/*!
- Sets bounds ( must be called first )
-*/
-void VisuGUI_CutPlanesDlg::setBounds( const double x1, const double x2,
- const double y1, const double y2,
- const double z1, const double z2 )
+void VisuGUI_CutPlanesPane::createPlanes()
{
- X1 = min( x1, x2 ); X2 = max( x1, x2 );
- Y1 = min( y1, y2 ); Y2 = max( y1, y2 );
- Z1 = min( z1, z2 ); Z2 = max( z1, z2 );
- orientationChanged( 0 );
+ if (VISU::GetViewWindow() == NULL) return;
+ if (myCutPlanes == NULL) return;
+ if (myPreviewActor != 0) return;
+
+ vtkAppendPolyData* aPolyData = myCutPlanes->GetCutPlanesPL()->GetAppendPolyData();
+ if (!aPolyData->GetOutput()->GetNumberOfCells()) {
+ onPreviewCheck(false);
+ return;
+ }
+ vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New();
+ aPlaneMapper->SetInput(aPolyData->GetOutput());
+ aPlaneMapper->ScalarVisibilityOff();
+
+ myPreviewActor = SALOME_Actor::New();
+ myPreviewActor->PickableOff();
+ myPreviewActor->SetMapper(aPlaneMapper);
+ aPlaneMapper->Delete();
+ VISU::GetViewWindow()->AddActor(myPreviewActor);
}
-/*!
- Sets nb of planes
-*/
-void VisuGUI_CutPlanesDlg::setNbPlanes( const int nbp )
+int VisuGUI_CutPlanesPane::storeToPrsObject (VISU::CutPlanes_i* thePrs)
{
- nbPlan->setValue( nbp );
+ thePrs->SetOrientation(getOrientaion(), getRotation1()*PI/180., getRotation2()*PI/180.);
+ thePrs->SetNbPlanes(getNbPlanes());
+ thePrs->SetDisplacement(myPosSpn->value());
+ for (int i = 0; i < getNbPlanes(); ++i) {
+ QCheckTableItem* anItem = (QCheckTableItem*)myPosTable->item(i, 1);
+ if (!anItem)
+ break;
+ if (!anItem->isChecked())
+ thePrs->SetPlanePosition(i, myPosTable->text(i, 0).toDouble());
+ else
+ thePrs->SetDefault(i);
+ }
+ return 1;
}
/*!
- Gets nb of planes
+ Called when orientation is changed
*/
-int VisuGUI_CutPlanesDlg::getNbPlanes()
+void VisuGUI_CutPlanesPane::orientationChanged (int Id)
{
- return nbPlan->value();
+ if (Id == 0) { // RBxy->isChecked()
+ LabelRot1->setText(tr("LBL_ROT_X"));
+ LabelRot2->setText(tr("LBL_ROT_Y"));
+ } else if (Id == 1) { // RByz->isChecked()
+ LabelRot1->setText(tr("LBL_ROT_Y"));
+ LabelRot2->setText(tr("LBL_ROT_Z"));
+ } else {
+ LabelRot1->setText(tr("LBL_ROT_Z"));
+ LabelRot2->setText(tr("LBL_ROT_X"));
+ }
+ DrawTable();
}
/*!
Sets planes orientation and position
*/
-void VisuGUI_CutPlanesDlg::setPlanePos( const VISU::CutPlanes::Orientation orient/*, const double pos1, const double pos2 */)
+void VisuGUI_CutPlanesPane::setPlanePos (const VISU::CutPlanes::Orientation orient)
{
- if ( orient == VISU::CutPlanes::XY ) // xy
- RBxy->setChecked( true );
- else if ( orient == VISU::CutPlanes::YZ ) // yz
- RByz->setChecked( true );
+ if (orient == VISU::CutPlanes::XY) // xy
+ {
+ RBxy->setChecked( true );
+ orientationChanged( 0 );
+ }
+ else if (orient == VISU::CutPlanes::YZ) // yz
+ {
+ RByz->setChecked( true );
+ orientationChanged( 1 );
+ }
else // zx
- RBzx->setChecked( true );
- orientationChanged( 0 );
-}
+ {
+ RBzx->setChecked( true );
+ orientationChanged( 2 );
+ }
+}
/*!
Gets planes orientation
*/
-VISU::CutPlanes::Orientation VisuGUI_CutPlanesDlg::getOrientaion()
+VISU::CutPlanes::Orientation VisuGUI_CutPlanesPane::getOrientaion()
{
VISU::CutPlanes::Orientation orient;
if ( RBxy->isChecked() ) // xy
orient = VISU::CutPlanes::XY;
- if ( RByz->isChecked() ) // yz
+ else if ( RByz->isChecked() ) // yz
orient = VISU::CutPlanes::YZ;
- if ( RBzx->isChecked() ) // zx
+ else if ( RBzx->isChecked() ) // zx
orient = VISU::CutPlanes::ZX;
return orient;
}
-
/*!
Sets planes rotation
*/
-void VisuGUI_CutPlanesDlg::setRotation( const double r1, const double r2 )
+void VisuGUI_CutPlanesPane::setRotation (const double r1, const double r2)
{
Rot1->setValue( r1 );
Rot2->setValue( r2 );
}
-/*!
- Gets plane rotation 1
-*/
-double VisuGUI_CutPlanesDlg::getRotation1()
-{
- return Rot1->value();
-}
-
-/*!
- Gets plane rotation 2
-*/
-double VisuGUI_CutPlanesDlg::getRotation2()
-{
- return Rot2->value();
-}
-
/*!
Draw the table of planes positions
*/
-
-void VisuGUI_CutPlanesDlg::DrawTable()
+void VisuGUI_CutPlanesPane::DrawTable()
{
+ if (myCutPlanes == NULL) return;
if (!hasInit) return;
int aNbRows = myPosTable->numRows();
- int aNbPlanes = getNbPlanes();
-
- if (aNbRows>0)
- for (int i = 0; i < aNbRows; ++i)
- {
- if (!((QCheckBox*)myPosTable->cellWidget( i, 1 ))->isChecked())
- myCutPlanes->SetPlanePosition( i, ((QLineEdit*)myPosTable->cellWidget( i, 0 ))->text().toDouble() );
- }
-
+ int aNbPlanes = getNbPlanes();
+
+ myCutPlanes->SetOrientation(getOrientaion(),getRotation1()*PI/180.,getRotation2()*PI/180.);
myCutPlanes->SetNbPlanes(aNbPlanes);
myCutPlanes->SetDisplacement(myPosSpn->value());
- myCutPlanes->SetOrientationType(getOrientaion());
-
- if (aNbRows < aNbPlanes)
- {
- if (aNbRows == 0) myPosTable->setNumRows(aNbPlanes);
- else myPosTable->insertRows(aNbRows, aNbPlanes - aNbRows );
-
- QHeader *vh = myPosTable->verticalHeader();
- QString str;
-
- QDoubleValidator *dvalidator = new QDoubleValidator(myPosTable);
- dvalidator->setDecimals(32);
-
- for (int i = aNbRows; i < myPosTable->numRows(); ++i)
- {
- QLineEdit *editline = new QLineEdit( myPosTable );
- editline->setValidator(dvalidator);
- myPosTable->setCellWidget( i, 0, editline );
-
- QCheckBox *checkbox = new QCheckBox( myPosTable );
- myPosTable->setCellWidget(i, 1, checkbox );
- connect(checkbox , SIGNAL( clicked() ), this , SLOT( setDefault() ) );
-
- str = str.setNum(i+1);
- str.prepend ("Plane# ");
- vh->setLabel( i, str );
- }
+ if (aNbRows>0)
+ for (int i = 0; i < aNbRows; ++i) {
+ QCheckTableItem* aItem = (QCheckTableItem*)myPosTable->item( i, 1 );
+ if (aItem == 0) break;
+ if (!aItem->isChecked())
+ myCutPlanes->SetPlanePosition(i, myPosTable->text(i, 0).toDouble());
}
- else if (aNbRows > aNbPlanes)
- for (int i = aNbRows-1; myPosTable->numRows() != aNbPlanes; --i )
- myPosTable->removeRow(i);
-
- for (int i = 0; i < myPosTable->numRows(); ++i)
- {
- ((QLineEdit*)myPosTable->cellWidget( i, 0 ))->setText( QString::number(myCutPlanes->GetPlanePosition(i)) );
-
- if (myCutPlanes->IsDefault(i))
- {
- ((QCheckBox*)myPosTable->cellWidget( i, 1 ))->setChecked(true);
- ((QLineEdit*)myPosTable->cellWidget( i, 0 ))->setEnabled(false);
- }
+
+ if (aNbPlanes > aNbRows)
+ myPosTable->insertRows(aNbRows, aNbPlanes - aNbRows );
+ else if (aNbPlanes < aNbRows)
+ myPosTable->setNumRows(aNbPlanes);
+
+ int aMin = (aNbRows < aNbPlanes)? aNbRows : aNbPlanes;
+ for (int i = 0; i<aMin; i++) {
+ myPosTable->setText(i, 0, QString::number(myCutPlanes->GetPlanePosition(i)));
+ ((QCheckTableItem*)myPosTable->item( i, 1 ))->setChecked(myCutPlanes->IsDefault(i));
+ }
+
+ QHeader *vh = myPosTable->verticalHeader();
+ QString str("Plane# %1");
+ for (int i=aMin; i<aNbPlanes; i++) {
+ VisuGUI_NumEditItem* aEditItem = new VisuGUI_NumEditItem(myPosTable,
+ QTableItem::OnTyping,
+ QString::number(myCutPlanes->GetPlanePosition(i)));
+ aEditItem->setReplaceable(false);
+ aEditItem->setEnabled(!myCutPlanes->IsDefault(i));
+ myPosTable->setItem(i, 0, aEditItem);
+
+ QCheckTableItem* aCheck = new QCheckTableItem(myPosTable, 0);
+ aCheck->setChecked(myCutPlanes->IsDefault(i));
+ aCheck->setReplaceable(false);
+ myPosTable->setItem(i, 1, aCheck);
+
+ vh->setLabel( i, str.arg(i+1) );
+ }
+
+ // Update preview
+ if (myPreviewCheck->isChecked()) {
+ if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) {
+ myCutPlanes->GetPL()->Update();
+ deletePlanes();
+ createPlanes();
+ vf->Repaint();
}
+ }
}
-void VisuGUI_CutPlanesDlg::setDefault(int all)
+void VisuGUI_CutPlanesPane::setDefault (int all)
{
+ myPosTable->setCurrentCell(-1, 1);
+ myPosTable->clearSelection();
if (all == 0) return;
-
if (all == 1)
- for (int i = 0; i < getNbPlanes(); ++i)
- ((QCheckBox*)myPosTable->cellWidget( i, 1 ))->setChecked(true);
-
- for (int i = 0; i < getNbPlanes(); ++i)
- {
- if ( ((QCheckBox*)myPosTable->cellWidget( i, 1 ))->isChecked() )
- {
- myCutPlanes->SetDefault(i);
- ((QLineEdit*)myPosTable->cellWidget( i, 0 ))->setText( QString::number(myCutPlanes->GetPlanePosition(i)) );
- ((QLineEdit*)myPosTable->cellWidget( i, 0 ))->setEnabled(false);
+ for (int i = 0; i < getNbPlanes(); ++i)
+ ((QCheckTableItem*)myPosTable->item( i, 1 ))->setChecked(true);
+
+ for (int i = 0; i < getNbPlanes(); ++i) {
+ if ( ((QCheckTableItem*)myPosTable->item( i, 1 ))->isChecked() ) {
+ myCutPlanes->SetDefault(i);
+ myPosTable->setText( i, 0, QString::number(myCutPlanes->GetPlanePosition(i)));
+ myPosTable->item( i, 0 )->setEnabled(false);
+ } else
+ myPosTable->item( i, 0 )->setEnabled(true);
+ }
+}
+
+void VisuGUI_CutPlanesPane::onValueChanged (int theRow, int theCol)
+{
+ if (theCol == 0) {
+ QString aTxt = myPosTable->text(theRow, 0);
+ bool isChanged = !aTxt.isEmpty();
+ ((QCheckTableItem*)myPosTable->item(theRow, 1))->setChecked(!isChanged);
+
+ if (myPreviewCheck->isChecked()) {
+ //Update Preview
+ if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) {
+ myCutPlanes->SetPlanePosition( theRow, aTxt.toDouble());
+ myCutPlanes->GetPL()->Update();
+ deletePlanes();
+ createPlanes();
+ vf->Repaint();
+ }
+ }
+ } else {
+ bool isDefault = ((QCheckTableItem*)myPosTable->item(theRow, theCol))->isChecked();
+ if (isDefault) {
+ myCutPlanes->SetDefault(theRow);
+ myPosTable->setText(theRow, 0, QString::number(myCutPlanes->GetPlanePosition(theRow)));
+
+ if (myPreviewCheck->isChecked()) {
+ if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) {
+ //Update Preview
+ myCutPlanes->GetPL()->Update();
+ deletePlanes();
+ createPlanes();
+ vf->Repaint();
}
- else ((QLineEdit*)myPosTable->cellWidget( i, 0 ))->setEnabled(true);
+ }
+ }
+ myPosTable->item(theRow, 0)->setEnabled(!isDefault);
+ }
+}
+
+void VisuGUI_CutPlanesPane::deletePlanes()
+{
+ if (myPreviewActor == 0) return;
+ if (SVTK_ViewWindow* vf = VISU::GetViewWindow())
+ vf->RemoveActor(myPreviewActor);
+ myPreviewActor->Delete();
+ myPreviewActor = 0;
+}
+
+void VisuGUI_CutPlanesPane::onRotation (double theValue)
+{
+ if (myCutPlanes == NULL) return;
+ if (myPreviewCheck->isChecked()) {
+ if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) {
+ myCutPlanes->SetOrientation(getOrientaion(),getRotation1()*PI/180.,getRotation2()*PI/180.);
+ myCutPlanes->GetPL()->Update();
+ deletePlanes();
+ createPlanes();
+ vf->Repaint();
+ }
+ }
+}
+
+void VisuGUI_CutPlanesPane::onPreviewCheck (bool thePreview)
+{
+ if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) {
+ if (thePreview) {
+ storeToPrsObject(myCutPlanes);
+ myCutPlanes->GetPL()->Update();
+ createPlanes();
+ vf->onFitAll();
+ } else {
+ deletePlanes();
+ vf->Repaint();
}
+ }
+}
+
+//###################################################################
+
+
+/*!
+ Constructor
+*/
+VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg (SalomeApp_Module* theModule)
+ : QDialog(VISU::GetDesktop(theModule), "VisuGUI_CutPlanesDlg", false,
+ WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
+{
+ setCaption("Cut Planes Definition");
+ setSizeGripEnabled(true);
+
+ QVBoxLayout* TopLayout = new QVBoxLayout (this);
+ TopLayout->setSpacing(6);
+ TopLayout->setMargin(11);
+
+ // Tab pane
+ QTabWidget* aTabBox = new QTabWidget(this);
+ myCutPane = new VisuGUI_CutPlanesPane(this/*, myMgr*/);
+ aTabBox->addTab(myCutPane, "Cut Planes");
+ myScalarPane = new VisuGUI_ScalarBarPane(this, false);
+ 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->setTitle("");
+ 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);
+
+ connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
+ connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
+ //connect(myMgr, SIGNAL(closeAllViews()), this, SLOT(reject()));
+ //connect(VisuGUI::application()->desktop(),
+ // SIGNAL(windowActivated(SUIT_ViewWindow*)),
+ // this, SLOT(onWindowActivated(SUIT_ViewWindow*)));
+}
+
+void VisuGUI_CutPlanesDlg::initFromPrsObject (VISU::CutPlanes_i* thePrs)
+{
+ myPrs = thePrs;
+ myScalarPane->initFromPrsObject(thePrs);
+ myCutPane->initFromPrsObject(thePrs);
+}
+
+int VisuGUI_CutPlanesDlg::storeToPrsObject (VISU::CutPlanes_i* thePrs)
+{
+ return (myScalarPane->storeToPrsObject(thePrs) &&
+ myCutPane->storeToPrsObject(thePrs));
+}
+
+void VisuGUI_CutPlanesDlg::accept()
+{
+ //if ( !VisuGUI::CheckActiveStudyLock() ) {
+ // reject();
+ // return;
+ //}
+ if (myScalarPane->check())
+ QDialog::accept();
+}
+
+void VisuGUI_CutPlanesDlg::reject() {
+ QDialog::reject();
+}
+
+//void VisuGUI_CutPlanesDlg::onWindowActivated (SUIT_ViewWindow* theWnd)
+//{
+// if (theWnd != myStudyWnd)
+// reject();
+//}
+
+//###################################################################
+
+QWidget* VisuGUI_NumEditItem::createEditor() const
+{
+ QLineEdit *editline = new QLineEdit(text(), table()->viewport());
+ QDoubleValidator *dvalidator = new QDoubleValidator(table()->viewport());
+ dvalidator->setDecimals(32);
+ editline->setValidator(dvalidator);
+ return editline;
}