X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FRepairGUI%2FRepairGUI_ShapeProcessDlg.cxx;h=71d3ce0f2cfc476c1eb4772ca4a10b106dff07b8;hb=09added4b04aab5affc5c928ac47ebdd06d5ff5a;hp=cb30f82dcf714f5f717da09c8561fb21b75183cd;hpb=e22560c4dc95da9e877275ed2b8a30dba569712d;p=modules%2Fgeom.git diff --git a/src/RepairGUI/RepairGUI_ShapeProcessDlg.cxx b/src/RepairGUI/RepairGUI_ShapeProcessDlg.cxx index cb30f82dc..71d3ce0f2 100755 --- a/src/RepairGUI/RepairGUI_ShapeProcessDlg.cxx +++ b/src/RepairGUI/RepairGUI_ShapeProcessDlg.cxx @@ -1,49 +1,55 @@ -// GEOM GEOMGUI : GUI for Geometry component +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE // -// 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 +// 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, or (at your option) any later version. // +// 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. // -// File : RepairGUI_ShapeProcessDlg.cxx -// Author : Lucien PIGNOLONI -// Module : GEOM -// $Header$ +// 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 +// + +// GEOM GEOMGUI : GUI for Geometry component +// File : RepairGUI_ShapeProcessDlg.cxx +// Author : Lucien PIGNOLONI, Open CASCADE S.A.S. #include "RepairGUI_ShapeProcessDlg.h" +#include "DlgRef.h" +#include "GeometryGUI.h" +#include "GEOMBase.h" #include "GEOMImpl_Types.hxx" +#include "RepairGUI.h" -#include "SalomeApp_Application.h" -#include "SalomeApp_SelectionMgr.h" -#include "SUIT_Session.h" -#include "SALOME_ListIteratorOfListIO.hxx" -#include "SALOME_ListIO.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include "utilities.h" + +#include +#include "utilities.h" #include #include -#include -#include -#include - -using namespace std; +#include +#include //================================================================================= // class : RepairGUI_ShapeProcessDlg() @@ -52,13 +58,14 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -RepairGUI_ShapeProcessDlg::RepairGUI_ShapeProcessDlg(QWidget* parent, const char* name, bool modal, WFlags fl) - :GEOMBase_Skeleton(parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +RepairGUI_ShapeProcessDlg::RepairGUI_ShapeProcessDlg( GeometryGUI* theGeometryGUI, QWidget* parent, + bool modal ) + : GEOMBase_Skeleton( theGeometryGUI, parent, modal ) { + setHelpFileName( "shape_processing_operation_page.html" ); init(); } - //================================================================================= // function : ~RepairGUI_ShapeProcessDlg() // purpose : Destroys the object and frees any allocated resources @@ -67,7 +74,6 @@ RepairGUI_ShapeProcessDlg::~RepairGUI_ShapeProcessDlg() { } - //================================================================================= // function : Init() // purpose : @@ -78,261 +84,288 @@ void RepairGUI_ShapeProcessDlg::init() initParamsValues(); initSelection(); - - setCaption(tr("GEOM_SHAPEPROCESS_TITLE")); + + setWindowTitle( tr( "GEOM_SHAPEPROCESS_TITLE" )); - GroupConstructors->hide(); + mainFrame()->GroupConstructors->hide(); // select widget on the top - mySelectWdgt = new DlgRef_1Sel_QTD( this, "SelectedObjects" ); - mySelectWdgt->GroupBox1->setTitle( tr("GEOM_SHAPE") ); - mySelectWdgt->TextLabel1->setText( tr("GEOM_SELECTED_OBJECTS") ); - mySelectWdgt->PushButton1->setPixmap( SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")) ); + mySelectWdgt = new DlgRef_1Sel( centralWidget() ); + mySelectWdgt->GroupBox1->setTitle( tr( "GEOM_SHAPE" )); + mySelectWdgt->TextLabel1->setText( tr( "GEOM_SELECTED_OBJECTS" )); + mySelectWdgt->PushButton1->setIcon( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ))); mySelectWdgt->LineEdit1->setReadOnly( true ); - Layout1->addWidget( mySelectWdgt, 0, 0 ); - // layout the two group boxes in the middle, add a list of operations - QFrame* aMidFrame = new QFrame( this ); - QGridLayout* aMidLay = new QGridLayout( aMidFrame, 1, 3, 0, 5 ); - QGroupBox* anOperGr = new QGroupBox( tr("GEOM_OPERATIONS"), aMidFrame ); - QVBoxLayout* aOperLay = new QVBoxLayout( anOperGr, 0, 0 ); - - myOpList = new QListView( anOperGr ); - myOpList->setSorting( -1 ); - myOpList->addColumn( "Operations" ); - myOpList->header()->hide(); - aOperLay->addWidget( myOpList ); - QStringList::ConstIterator it = myOpLst.end(); - do // iterating from end to begin so to keep the order of items in the listview. - new QCheckListItem ( myOpList, *(--it), QCheckListItem::CheckBox ); - while ( it != myOpLst.begin() ); + QGroupBox* anOperGr = new QGroupBox( tr( "GEOM_OPERATIONS" ), centralWidget() ); - QGroupBox* aParamsGr = new QGroupBox( tr("GEOM_PARAMETERS"), aMidFrame ); - aMidLay->addWidget( anOperGr, 0, 0 ); - aMidLay->addMultiCellWidget( aParamsGr, 0, 0, 1, 3 ); - aMidLay->setColStretch( 0, 1 ); - aMidLay->setColStretch( 1, 2 ); + // "select all" button + mySelectAll = new QCheckBox( tr( "SELECT_ALL" ), anOperGr ); + mySelectAll->setTristate( true ); + + // operations list widget + myOpList = new QListWidget( anOperGr ); + myOpList->setSortingEnabled( false ); + myOpList->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding )); + + QVBoxLayout* aOperLay = new QVBoxLayout( anOperGr ); + aOperLay->setMargin( 9 ); + aOperLay->addWidget( mySelectAll ); + aOperLay->addWidget( myOpList ); - Layout1->addWidget( aMidFrame, 2, 0 ); - Layout1->setRowStretch( 0, 0 ); - Layout1->setRowStretch( 1, 1 ); + QGroupBox* aParamsGr = new QGroupBox( tr( "GEOM_PARAMETERS" ), centralWidget() ); // add a widget stack to the parameters group box - myStack = new QWidgetStack( aParamsGr ); - QVBoxLayout* aVParamsLay = new QVBoxLayout( aParamsGr ); - aVParamsLay->addWidget( myStack ); + myStack = new QStackedLayout( aParamsGr ); // continueties values.. - QStringList aContinueties = QStringList::split( ",", "C0,G1,C1,G2,C2,C3,CN" ); - - // FixShape - QFrame* aFrame = new QFrame( myStack ); - QGridLayout* aLay = new QGridLayout( aFrame, 10, 2, 0, 5 ); - - myFixShapeTol3D = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 ); - myFixShapeTol3D->setPrecision( 10 ); - myFixShapeMaxTol3D = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 ); - myFixShapeMaxTol3D->setPrecision( 10 ); - - aLay->addWidget( new QLabel( tr("GEOM_3D_TOLERANCE"), aFrame ), 0, 0 ); - aLay->addWidget( myFixShapeTol3D, 0, 1 ); - aLay->addWidget( new QLabel( tr("GEOM_MAX_3D_TOLERANCE"), aFrame ), 1, 0 ); - aLay->addWidget( myFixShapeMaxTol3D, 1, 1 ); - aLay->setRowStretch( 9, 2 ); - - myStack->addWidget( aFrame, myOpLst.findIndex( "FixShape" ) ); - - // FixFaceSize - aFrame = new QFrame( myStack ); - aLay = new QGridLayout( aFrame, 10, 2, 0, 5 ); - - myFixFaceSizeTol = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 ); - myFixFaceSizeTol->setPrecision( 10 ); - - aLay->addWidget( new QLabel( tr("GEOM_TOLERANCE"), aFrame ), 0, 0 ); - aLay->addWidget( myFixFaceSizeTol, 0, 1 ); - aLay->setRowStretch( 9, 2 ); - - myStack->addWidget( aFrame, myOpLst.findIndex( "FixFaceSize" ) ); - - // DropSmallEdges - aFrame = new QFrame( myStack ); - aLay = new QGridLayout( aFrame, 10, 2, 0, 5 ); - - myDropSmallEdgesTol3D = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 ); - myDropSmallEdgesTol3D->setPrecision( 10 ); + QStringList aContinueties = QString( "C0,G1,C1,G2,C2,C3,CN" ).split( "," ); + + // fill in the widgets + for ( int i = 0; i < myOpLst.count(); i++ ) { + QListWidgetItem* item = new QListWidgetItem( myOpLst[i] ); + item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable ); + item->setCheckState( Qt::Unchecked ); + myOpList->addItem( item ); + + QWidget* w; + if ( myOpLst[i] == "FixShape" ) { + // FixShape + w = new QWidget( aParamsGr ); + QGridLayout* aLay = new QGridLayout( w ); + aLay->setMargin( 9 ); aLay->setSpacing( 6 ); + + myFixShapeTol3D = new SalomeApp_DoubleSpinBox( w ); + initSpinBox( myFixShapeTol3D, 0., 100., 1e-7, "len_tol_precision" ); + myFixShapeMaxTol3D = new SalomeApp_DoubleSpinBox( w ); + initSpinBox( myFixShapeMaxTol3D, 0., 100., 1e-7, "len_tol_precision" ); + + aLay->addWidget( new QLabel( tr( "GEOM_3D_TOLERANCE" ), w ), 0, 0 ); + aLay->addWidget( myFixShapeTol3D, 0, 1 ); + aLay->addWidget( new QLabel( tr( "GEOM_MAX_3D_TOLERANCE" ), w ), 1, 0 ); + aLay->addWidget( myFixShapeMaxTol3D, 1, 1 ); + aLay->setRowStretch( aLay->rowCount(), 5 ); + } + else if ( myOpLst[i] == "FixFaceSize" ) { + // FixFaceSize + w = new QWidget( aParamsGr ); + QGridLayout* aLay = new QGridLayout( w ); + aLay->setMargin( 9 ); aLay->setSpacing( 6 ); + + myFixFaceSizeTol = new SalomeApp_DoubleSpinBox( w ); + initSpinBox( myFixFaceSizeTol, 0., 100., 1e-7, "len_tol_precision" ); + + aLay->addWidget( new QLabel( tr( "GEOM_TOLERANCE" ), w ), 0, 0 ); + aLay->addWidget( myFixFaceSizeTol, 0, 1 ); + aLay->setRowStretch( aLay->rowCount(), 5 ); + } + else if ( myOpLst[i] == "DropSmallSolids" ) { + // DropSmallSolids + w = new QWidget( aParamsGr ); + QGridLayout* aLay = new QGridLayout( w ); + aLay->setMargin( 9 ); aLay->setSpacing( 6 ); + + myDropSmallSolidsWidChk = new QCheckBox( tr("WIDTH_FACTOR_TOL"), w ); + myDropSmallSolidsVolChk = new QCheckBox( tr("VOLUME_TOL"), w ); + myDropSmallSolidsWidTol = new SalomeApp_DoubleSpinBox( w ); + myDropSmallSolidsVolTol = new SalomeApp_DoubleSpinBox( w ); + initSpinBox( myDropSmallSolidsWidTol, 0., 1e3, 1., "len_tol_precision" ); + initSpinBox( myDropSmallSolidsVolTol, 0., 1e9, 1., "len_tol_precision" ); + myDropSmallSolidsWidTol->setValue( 1 ); + myDropSmallSolidsVolTol->setValue( 1e3 ); + myDropSmallSolidsVolChk->setChecked( true ); + myDropSmallSolidsWidTol->setEnabled( false ); + myDropSmallSolidsMergeChk = new QCheckBox( tr("TO_MERGE_SOLIDS"), w ); - aLay->addWidget( new QLabel( tr("GEOM_3D_TOLERANCE"), aFrame ), 0, 0 ); - aLay->addWidget( myDropSmallEdgesTol3D, 0, 1 ); - aLay->setRowStretch( 9, 2 ); - - myStack->addWidget( aFrame, myOpLst.findIndex( "DropSmallEdges" ) ); - - // SplitAngle - aFrame = new QFrame( myStack ); - aLay = new QGridLayout( aFrame, 10, 2, 0, 5 ); - - mySplitAngleAngle = new QtxDblSpinBox( 0, 360, 1, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 360, 1 ); - mySplitAngleMaxTol = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 ); - mySplitAngleMaxTol->setPrecision( 10 ); + aLay->addWidget( myDropSmallSolidsWidChk, 0, 0 ); + aLay->addWidget( myDropSmallSolidsWidTol, 0, 1 ); + aLay->addWidget( myDropSmallSolidsVolChk, 1, 0 ); + aLay->addWidget( myDropSmallSolidsVolTol, 1, 1 ); + aLay->addWidget( myDropSmallSolidsMergeChk, 2, 0, 1, 2 ); - aLay->addWidget( new QLabel( tr("GEOM_ANGLE_1"), aFrame ), 0, 0 ); - aLay->addWidget( mySplitAngleAngle, 0, 1 ); - aLay->addWidget( new QLabel( tr("GEOM_MAX_TOLERANCE"), aFrame ), 1, 0 ); - aLay->addWidget( mySplitAngleMaxTol, 1, 1 ); - aLay->setRowStretch( 9, 2 ); - - myStack->addWidget( aFrame, myOpLst.findIndex( "SplitAngle" ) ); - - // SplitClosedFaces - aFrame = new QFrame( myStack ); - aLay = new QGridLayout( aFrame, 10, 2, 0, 5 ); - - mySplitClosedFacesNum = new QSpinBox( aFrame ); - - aLay->addWidget( new QLabel( tr("GEOM_NUM_SPLIT_POINTS"), aFrame ), 0, 0 ); - aLay->addWidget( mySplitClosedFacesNum, 0, 1 ); - aLay->setRowStretch( 9, 2 ); - - myStack->addWidget( aFrame, myOpLst.findIndex( "SplitClosedFaces" ) ); - - // SplitContinuity - aFrame = new QFrame( myStack ); - aLay = new QGridLayout( aFrame, 10, 2, 0, 5 ); - - mySplitContTol3D = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 ); - mySplitContTol3D->setPrecision( 10 ); - mySplitContSurfCont = new QComboBox( aFrame ); - mySplitContSurfCont->insertStringList( aContinueties ); - mySplitContCurvCont = new QComboBox( aFrame ); - mySplitContCurvCont->insertStringList( aContinueties ); - - aLay->addWidget( new QLabel( tr("GEOM_3D_TOLERANCE"), aFrame ), 0, 0 ); - aLay->addWidget( mySplitContTol3D, 0, 1 ); - aLay->addWidget( new QLabel( tr("GEOM_SURFACE_CONTINUTY"), aFrame ), 1, 0 ); - aLay->addWidget( mySplitContSurfCont, 1, 1 ); - aLay->addWidget( new QLabel( tr("GEOM_CURVE_CONTINUTY"), aFrame ), 2, 0 ); - aLay->addWidget( mySplitContCurvCont, 2, 1 ); - aLay->setRowStretch( 9, 2 ); - - myStack->addWidget( aFrame, myOpLst.findIndex( "SplitContinuity" ) ); - - // BSplineRestriction - aFrame = new QFrame( myStack ); - aLay = new QGridLayout( aFrame, 10, 2, 0, 5 ); - - myBSplineSurfModeChk = new QCheckBox( tr("GEOM_SURFACE_MODE"), aFrame ); - myBSpline3DCurveChk = new QCheckBox( tr("GEOM_3D_CURVE_MODE"), aFrame ); - myBSpline2DCurveChk = new QCheckBox( tr("GEOM_2D_CURVE_MODE"), aFrame ); - - myBSplineTol3D = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 ); - myBSplineTol3D->setPrecision( 10 ); - - myBSplineTol2D = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 ); - myBSplineTol2D->setPrecision( 10 ); - - myBSplineDegree = new QSpinBox( aFrame ); - myBSplineSegments = new QSpinBox( aFrame ); - myBSpline2DCont = new QComboBox( aFrame ); - myBSpline2DCont->insertStringList( aContinueties ); - myBSpline3DCont = new QComboBox( aFrame ); - myBSpline3DCont->insertStringList( aContinueties ); - - myBSplineSurfModeChk->setChecked( true ); - myBSpline3DCurveChk->setChecked( true ); - myBSpline2DCurveChk->setChecked( true ); - - aLay->addWidget( myBSplineSurfModeChk, 0, 0 ); - aLay->addWidget( myBSpline3DCurveChk, 1, 0 ); - aLay->addWidget( myBSpline2DCurveChk, 2, 0 ); - aLay->addWidget( new QLabel( tr("GEOM_3D_TOLERANCE"), aFrame), 3, 0 ); - aLay->addWidget( myBSplineTol3D, 3, 1 ); - aLay->addWidget( new QLabel( tr("GEOM_2D_TOLERANCE"), aFrame), 4, 0 ); - aLay->addWidget( myBSplineTol2D, 4, 1 ); - aLay->addWidget( new QLabel( tr("GEOM_REQUIRED_DEGREE"), aFrame), 5, 0 ); - aLay->addWidget( myBSplineDegree, 5, 1 ); - aLay->addWidget( new QLabel( tr("GEOM_REQUIRED_NUM_SEGMENTS"), aFrame), 6, 0 ); - aLay->addWidget( myBSplineSegments, 6, 1 ); - aLay->addWidget( new QLabel( tr("GEOM_3D_CONTINUTY"), aFrame), 7, 0 ); - aLay->addWidget( myBSpline3DCont, 7, 1 ); - aLay->addWidget( new QLabel( tr("GEOM_2D_CONTINUTY"), aFrame), 8, 0 ); - aLay->addWidget( myBSpline2DCont, 8, 1 ); - aLay->setRowStretch( 9, 2 ); + aLay->setRowStretch( aLay->rowCount(), 5 ); + } + else if ( myOpLst[i] == "DropSmallEdges" ) { + // DropSmallEdges + w = new QWidget( aParamsGr ); + QGridLayout* aLay = new QGridLayout( w ); + aLay->setMargin( 9 ); aLay->setSpacing( 6 ); + + myDropSmallEdgesTol3D = new SalomeApp_DoubleSpinBox( w ); + initSpinBox( myDropSmallEdgesTol3D, 0., 100., 1e-7, "len_tol_precision" ); - myStack->addWidget( aFrame, myOpLst.findIndex( "BSplineRestriction" ) ); - - // ToBezier - aFrame = new QFrame( myStack ); - aLay = new QGridLayout( aFrame, 10, 2, 0, 5 ); - - myToBezierSurfModeChk = new QCheckBox( tr("GEOM_SURFACE_MODE"), aFrame ); - myToBezier3DCurveChk = new QCheckBox( tr("GEOM_3D_CURVE_MODE"), aFrame ); - myToBezier2DCurveChk = new QCheckBox( tr("GEOM_2D_CURVE_MODE"), aFrame ); + aLay->addWidget( new QLabel( tr( "GEOM_3D_TOLERANCE" ), w ), 0, 0 ); + aLay->addWidget( myDropSmallEdgesTol3D, 0, 1 ); + aLay->setRowStretch( aLay->rowCount(), 5 ); + } + else if ( myOpLst[i] == "SplitAngle" ) { + // SplitAngle + w = new QWidget( aParamsGr ); + QGridLayout* aLay = new QGridLayout( w ); + aLay->setMargin( 9 ); aLay->setSpacing( 6 ); + + mySplitAngleAngle = new SalomeApp_DoubleSpinBox( w ); + initSpinBox( mySplitAngleAngle, 0, 360, 1, "angle_precision" ); + mySplitAngleMaxTol = new SalomeApp_DoubleSpinBox( w ); + initSpinBox( mySplitAngleMaxTol, 0., 100., 1e-7, "ang_tol_precision" ); + + aLay->addWidget( new QLabel( tr( "GEOM_ANGLE_1" ), w ), 0, 0 ); + aLay->addWidget( mySplitAngleAngle, 0, 1 ); + aLay->addWidget( new QLabel( tr( "GEOM_MAX_TOLERANCE" ), w ), 1, 0 ); + aLay->addWidget( mySplitAngleMaxTol, 1, 1 ); + aLay->setRowStretch( aLay->rowCount(), 5 ); + } + else if ( myOpLst[i] == "SplitClosedFaces" ) { + // SplitClosedFaces + w = new QWidget( aParamsGr ); + QGridLayout* aLay = new QGridLayout( w ); + aLay->setMargin( 9 ); aLay->setSpacing( 6 ); + + mySplitClosedFacesNum = new SalomeApp_IntSpinBox( w ); - myToBezierMaxTol = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 ); - myToBezierMaxTol->setPrecision( 10 ); - - aLay->addWidget( myToBezierSurfModeChk, 0, 0 ); - aLay->addWidget( myToBezier3DCurveChk, 1, 0 ); - aLay->addWidget( myToBezier2DCurveChk, 2, 0 ); - aLay->addWidget( new QLabel( tr("GEOM_MAX_TOLERANCE"), aFrame), 3, 0 ); - aLay->addWidget( myToBezierMaxTol, 3, 1 ); - aLay->setRowStretch( 9, 2 ); + aLay->addWidget( new QLabel( tr( "GEOM_NUM_SPLIT_POINTS" ), w ), 0, 0 ); + aLay->addWidget( mySplitClosedFacesNum, 0, 1 ); + aLay->setRowStretch( aLay->rowCount(), 5 ); + } + else if ( myOpLst[i] == "SplitContinuity" ) { + // SplitContinuity + w = new QWidget( aParamsGr ); + QGridLayout* aLay = new QGridLayout( w ); + aLay->setMargin( 9 ); aLay->setSpacing( 6 ); + + mySplitContTol3D = new SalomeApp_DoubleSpinBox( w ); + initSpinBox( mySplitContTol3D, 0., 100., 1e-7, "len_tol_precision" ); + mySplitContSurfCont = new QComboBox( w ); + mySplitContSurfCont->addItems( aContinueties ); + mySplitContCurvCont = new QComboBox( w ); + mySplitContCurvCont->addItems( aContinueties ); + + aLay->addWidget( new QLabel( tr( "GEOM_3D_TOLERANCE" ), w ), 0, 0 ); + aLay->addWidget( mySplitContTol3D, 0, 1 ); + aLay->addWidget( new QLabel( tr( "GEOM_SURFACE_CONTINUTY" ), w ), 1, 0 ); + aLay->addWidget( mySplitContSurfCont, 1, 1 ); + aLay->addWidget( new QLabel( tr( "GEOM_CURVE_CONTINUTY" ), w ), 2, 0 ); + aLay->addWidget( mySplitContCurvCont, 2, 1 ); + aLay->setRowStretch( aLay->rowCount(), 5 ); + } + else if ( myOpLst[i] == "BSplineRestriction" ) { + // BSplineRestriction + w = new QWidget( aParamsGr ); + QGridLayout* aLay = new QGridLayout( w ); + aLay->setMargin( 9 ); aLay->setSpacing( 6 ); + + myBSplineSurfModeChk = new QCheckBox( tr("GEOM_SURFACE_MODE"), w ); + myBSpline3DCurveChk = new QCheckBox( tr("GEOM_3D_CURVE_MODE"), w ); + myBSpline2DCurveChk = new QCheckBox( tr("GEOM_2D_CURVE_MODE"), w ); + + myBSplineTol3D = new SalomeApp_DoubleSpinBox( w ); + initSpinBox( myBSplineTol3D, 0., 100., 1e-7, "len_tol_precision" ); + + myBSplineTol2D = new SalomeApp_DoubleSpinBox( w ); + initSpinBox( myBSplineTol2D, 0., 100., 1e-7, "param_tol_precision" ); + + myBSplineDegree = new SalomeApp_IntSpinBox( w ); + myBSplineSegments = new SalomeApp_IntSpinBox( w ); + initSpinBox( myBSplineSegments, 1, 1000, 1); + myBSpline2DCont = new QComboBox( w ); + myBSpline2DCont->addItems( aContinueties ); + myBSpline3DCont = new QComboBox( w ); + myBSpline3DCont->addItems( aContinueties ); + + myBSplineSurfModeChk->setChecked( true ); + myBSpline3DCurveChk->setChecked( true ); + myBSpline2DCurveChk->setChecked( true ); + + aLay->addWidget( myBSplineSurfModeChk, 0, 0 ); + aLay->addWidget( myBSpline3DCurveChk, 1, 0 ); + aLay->addWidget( myBSpline2DCurveChk, 2, 0 ); + aLay->addWidget( new QLabel( tr( "GEOM_3D_TOLERANCE" ), w ), 3, 0 ); + aLay->addWidget( myBSplineTol3D, 3, 1 ); + aLay->addWidget( new QLabel( tr( "GEOM_2D_TOLERANCE" ), w ), 4, 0 ); + aLay->addWidget( myBSplineTol2D, 4, 1 ); + aLay->addWidget( new QLabel( tr( "GEOM_REQUIRED_DEGREE" ), w ), 5, 0 ); + aLay->addWidget( myBSplineDegree, 5, 1 ); + aLay->addWidget( new QLabel( tr( "GEOM_REQUIRED_NUM_SEGMENTS" ), w ), 6, 0 ); + aLay->addWidget( myBSplineSegments, 6, 1 ); + aLay->addWidget( new QLabel( tr( "GEOM_3D_CONTINUTY" ), w ), 7, 0 ); + aLay->addWidget( myBSpline3DCont, 7, 1 ); + aLay->addWidget( new QLabel( tr( "GEOM_2D_CONTINUTY" ), w ), 8, 0 ); + aLay->addWidget( myBSpline2DCont, 8, 1 ); + aLay->setRowStretch( aLay->rowCount(), 5 ); + } + else if ( myOpLst[i] == "ToBezier" ) { + // ToBezier + w = new QWidget( aParamsGr ); + QGridLayout* aLay = new QGridLayout( w ); + aLay->setMargin( 9 ); aLay->setSpacing( 6 ); + + myToBezierSurfModeChk = new QCheckBox( tr("GEOM_SURFACE_MODE"), w ); + myToBezier3DCurveChk = new QCheckBox( tr("GEOM_3D_CURVE_MODE"), w ); + myToBezier2DCurveChk = new QCheckBox( tr("GEOM_2D_CURVE_MODE"), w ); - myStack->addWidget( aFrame, myOpLst.findIndex( "ToBezier" ) ); - - // SameParameter - aFrame = new QFrame( myStack ); - aLay = new QGridLayout( aFrame, 10, 2, 0, 5 ); - - mySameParameterTol3D = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 ); - mySameParameterTol3D->setPrecision( 10 ); + myToBezierMaxTol = new SalomeApp_DoubleSpinBox( w ); + initSpinBox( myToBezierMaxTol, 0., 100., 1e-7, "len_tol_precision" ); + + aLay->addWidget( myToBezierSurfModeChk, 0, 0 ); + aLay->addWidget( myToBezier3DCurveChk, 1, 0 ); + aLay->addWidget( myToBezier2DCurveChk, 2, 0 ); + aLay->addWidget( new QLabel( tr( "GEOM_MAX_TOLERANCE" ), w ), 3, 0 ); + aLay->addWidget( myToBezierMaxTol, 3, 1 ); + aLay->setRowStretch( aLay->rowCount(), 5 ); + } + else if ( myOpLst[i] == "SameParameter" ) { + // SameParameter + w = new QWidget( aParamsGr ); + QGridLayout* aLay = new QGridLayout( w ); + aLay->setMargin( 9 ); aLay->setSpacing( 6 ); + + mySameParameterTol3D = new SalomeApp_DoubleSpinBox( w ); + initSpinBox( mySameParameterTol3D, 0., 100., 1e-7, "len_tol_precision" ); + + aLay->addWidget( new QLabel( tr( "GEOM_3D_TOLERANCE" ), w ), 0, 0 ); + aLay->addWidget( mySameParameterTol3D, 0, 1 ); + aLay->setRowStretch( aLay->rowCount(), 5 ); + } + else { + w = new QWidget( aParamsGr ); // dumb widget + } + myStack->insertWidget( i, w ); + } - aLay->addWidget( new QLabel( tr("GEOM_3D_TOLERANCE"), aFrame ), 0, 0 ); - aLay->addWidget( mySameParameterTol3D, 0, 1 ); - aLay->setRowStretch( 9, 2 ); - - myStack->addWidget( aFrame, myOpLst.findIndex( "SameParameter" ) ); + QGridLayout* layout = new QGridLayout( centralWidget() ); + layout->setMargin( 0 ); layout->setSpacing( 6 ); + layout->addWidget( mySelectWdgt, 0, 0, 1, 2 ); + layout->addWidget( anOperGr, 1, 0 ); + layout->addWidget( aParamsGr, 1, 1 ); // signals and slots connections - connect( myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(deactivate()) ); - connect( myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(onCancel()) ); + connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( onOk() )); + connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( onApply() )); - connect( buttonCancel, SIGNAL(clicked()), this, SLOT(onCancel()) ); - connect( buttonOk, SIGNAL(clicked()), this, SLOT(onOk()) ); - connect( buttonApply, SIGNAL(clicked()), this, SLOT(onApply()) ); + connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ))->selectionMgr(), + SIGNAL( currentSelectionChanged() ), this, SLOT( selectionChanged() )); - connect( ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(selectionChanged()) ); - connect( myOpList, SIGNAL(selectionChanged()), this, SLOT(operationChanged()) ); + connect( mySelectWdgt->PushButton1, SIGNAL( clicked() ), this, SLOT( selectClicked() )); + connect( mySelectWdgt->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( lineEditReturnPressed() )); - connect( mySelectWdgt->PushButton1, SIGNAL(clicked()), this, SLOT(selectClicked()) ); - connect( mySelectWdgt->LineEdit1, SIGNAL(returnPressed()), this, SLOT(lineEditReturnPressed()) ); + connect( myToBezierSurfModeChk, SIGNAL( toggled( bool )), this, SLOT( advOptionToggled( bool ))); + connect( myDropSmallSolidsWidChk, SIGNAL( toggled( bool )), this, SLOT( advOptionToggled( bool ))); + connect( myDropSmallSolidsVolChk, SIGNAL( toggled( bool )), this, SLOT( advOptionToggled( bool ))); - connect( myToBezierSurfModeChk, SIGNAL(toggled(bool)), SLOT(advOptionToggled(bool)) ); + connect( myOpList, SIGNAL( currentRowChanged( int )), myStack, SLOT( setCurrentIndex( int ))); + connect( myOpList, SIGNAL( itemChanged( QListWidgetItem* )), this, SLOT( operatorChecked( QListWidgetItem* ))); + connect( mySelectAll, SIGNAL( stateChanged( int ) ), this, SLOT( onSelectAll( int ))); adjustSize(); loadDefaults(); // init dialog fields with values from resource file - myOpList->setSelected( myOpList->findItem( "FixShape", 0 ), true ); + //myOpList->setCurrentRow( myOpList->findItem( 0 ); reset(); - initName( tr( "PROCESS_SHAPE_NEW_OBJ_NAME" ) ); -} + myOpList->setCurrentRow(0); -//================================================================================= -// function : operationChanged() -// purpose : -//================================================================================= -void RepairGUI_ShapeProcessDlg::operationChanged() -{ - QListViewItem* anItem = myOpList->selectedItem(); - if ( anItem ) - { - int id = myOpLst.findIndex( anItem->text(0) ); - if ( id > -1 ) - myStack->raiseWidget( id ); - } + initName( tr( "PROCESS_SHAPE_NEW_OBJ_NAME" )); + selectionChanged(); + updateSelectAll(); } //================================================================================= @@ -341,12 +374,11 @@ void RepairGUI_ShapeProcessDlg::operationChanged() //================================================================================= void RepairGUI_ShapeProcessDlg::onOk() { + setIsApplyAndClose( true ); if ( onApply() ) - onCancel(); + ClickOnCancel(); } - - //================================================================================= // function : onApply() // purpose : @@ -365,16 +397,6 @@ bool RepairGUI_ShapeProcessDlg::onApply() } -//================================================================================= -// function : onCancel() -// purpose : -//================================================================================= -void RepairGUI_ShapeProcessDlg::onCancel() -{ - GEOMBase_Skeleton::ClickOnCancel(); -} - - //================================================================================= // function : selectionChanged() // purpose : Called when selection as changed or other case @@ -382,22 +404,24 @@ void RepairGUI_ShapeProcessDlg::onCancel() //================================================================================= void RepairGUI_ShapeProcessDlg::selectionChanged() { - reset(); - - Standard_Boolean aRes = Standard_False; + reset(); + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + SALOME_ListIO aSelList; + aSelMgr->selectedObjects(aSelList); + int i = 0; - myObjects->length( IObjectCount() ); - for ( SALOME_ListIteratorOfListIO anIt( selectedIO() ); anIt.More(); anIt.Next() ) - { - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIt.Value(), aRes ); - if ( !CORBA::is_nil( aSelectedObject ) && aRes ) - myObjects[i++] = aSelectedObject; + myObjects->length(aSelList.Extent()); + for (SALOME_ListIteratorOfListIO anIt (aSelList); anIt.More(); anIt.Next()) { + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIt.Value() ); + if ( !CORBA::is_nil( aSelectedObject )) + myObjects[i++] = aSelectedObject; } myObjects->length( i ); if ( i == 1 ) - mySelectWdgt->LineEdit1->setText( GEOMBase::GetName( myObjects[0] ) ); + mySelectWdgt->LineEdit1->setText( GEOMBase::GetName( myObjects[0] )); else if ( i > 0 ) - mySelectWdgt->LineEdit1->setText( QString::number( i ) + "_" + tr( "GEOM_OBJECTS" ) ); + mySelectWdgt->LineEdit1->setText( QString::number( i ) + "_" + tr( "GEOM_OBJECTS" )); } @@ -423,17 +447,6 @@ void RepairGUI_ShapeProcessDlg::lineEditReturnPressed() } -//================================================================================= -// function : deactivate() -// purpose : -//================================================================================= -void RepairGUI_ShapeProcessDlg::deactivate() -{ - //myGeomGUI->SetState( -1 ); - GEOMBase_Skeleton::DeactivateActiveDialog(); -} - - //================================================================================= // function : activate() // purpose : @@ -441,9 +454,9 @@ void RepairGUI_ShapeProcessDlg::deactivate() void RepairGUI_ShapeProcessDlg::activate() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), - SIGNAL(currentSelectionChanged()), this, SLOT(selectionChanged())); - + connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication( )))->selectionMgr(), + SIGNAL( currentSelectionChanged() ), this, SLOT( selectionChanged() )); + reset(); //myGeomGUI->SetState( 0 ); initSelection(); @@ -454,24 +467,13 @@ void RepairGUI_ShapeProcessDlg::activate() // function : enterEvent() // purpose : Mouse enter onto the dialog to activate it //================================================================================= -void RepairGUI_ShapeProcessDlg::enterEvent(QEvent* e) +void RepairGUI_ShapeProcessDlg::enterEvent( QEvent* ) { - if ( !GroupConstructors->isEnabled() ) + if ( !mainFrame()->GroupBoxName->isEnabled() ) activate(); } -//================================================================================= -// function : closeEvent() -// purpose : same than click on cancel button -//================================================================================= -void RepairGUI_ShapeProcessDlg::closeEvent(QCloseEvent* e) -{ - //myGeomGUI->SetState( -1 ); - GEOMBase_Skeleton::closeEvent( e ); -} - - //================================================================================= // function : reset() // purpose : Completely reset the state of method including local context @@ -479,8 +481,8 @@ void RepairGUI_ShapeProcessDlg::closeEvent(QCloseEvent* e) void RepairGUI_ShapeProcessDlg::reset() { myObjects = new GEOM::ListOfGO(); - myObjects->length( 0 ); - mySelectWdgt->LineEdit1->setText(""); + myObjects->length( 0 ); + mySelectWdgt->LineEdit1->setText( "" ); } @@ -488,30 +490,27 @@ void RepairGUI_ShapeProcessDlg::reset() // function : get_convert // purpose : conversion of angle values to radians (non-angle values are not converted) //================================================================================= -const char* get_convert( const char* theParam, const char* theValue ) +const char* get_convert( const char* theParam, const QString& theValue ) { - if ( !strcmp( theParam, "SplitAngle.Angle" ) ) - { - double doubleValue = atof( theValue ) * PI / 180; - TCollection_AsciiString str( doubleValue ); - return CORBA::string_dup( str.ToCString() ); + if ( !strcmp( theParam, "SplitAngle.Angle" )) { + double doubleValue = theValue.toDouble() * M_PI / 180.; + return CORBA::string_dup( QString::number( doubleValue ).toLatin1().constData() ); } - return CORBA::string_dup( theValue ); + return CORBA::string_dup( theValue.toLatin1().constData() ); } //================================================================================= // function : set_convert // purpose : conversion of angle values to degrees (non-angle values are not converted) //================================================================================= -const char* set_convert( const char* theParam, const char* theValue ) +QString set_convert( const char* theParam, const char* theValue ) { - if ( !strcmp( theParam, "SplitAngle.Angle" ) ) - { - double doubleValue = atof( theValue ) * 180 / PI; - TCollection_AsciiString str( doubleValue ); - return CORBA::string_dup( str.ToCString() ); + if ( !strcmp( theParam, "SplitAngle.Angle" )) { + Kernel_Utils::Localizer loc; + double doubleValue = atof( theValue ) * 180. / M_PI; + return QString::number( doubleValue ); } - return CORBA::string_dup( theValue ); + return QString( theValue ); } //================================================================================= @@ -525,27 +524,26 @@ void RepairGUI_ShapeProcessDlg::loadDefaults() anOp->GetShapeProcessParameters( anOperators, aParams, aValues ); // check the default items-operators - int i; - for ( i = 0; i < anOperators->length(); i++ ) - { + for ( int i = 0; i < anOperators->length(); i++ ) { //MESSAGE("-->"<<(const char*)anOperators[i]); - QListViewItem* anItem = myOpList->findItem( (const char*)anOperators[i], 0 ); - if ( anItem /*&& anItem->inherits( "QCheckListItem" )*/ ) - ((QCheckListItem*) anItem)->setOn( true ); + QList items = myOpList->findItems ( (const char*)anOperators[i], Qt::MatchFixedString ); + if ( items.count() ) + ( items[0] )->setCheckState( Qt::Checked ); } // Retrieve default parameters for ALL operators - for ( QListViewItemIterator it(myOpList); it.current(); ++it ) { - CORBA::String_var anOperator = CORBA::string_dup( it.current()->text( 0 ).latin1() ); - anOp->GetOperatorParameters( anOperator.in(), aParams, aValues ); + for ( int i = 0; i < myOpList->count(); i++ ) + { + QString anOperator = myOpList->item( i )->text(); + anOp->GetOperatorParameters( anOperator.toLatin1().constData(), aParams, aValues ); // set default values of parameters if ( aParams->length() != aValues->length() ) continue; - for ( i = 0; i < aParams->length(); i++ ) { - QWidget* aCtrl = getControl( (const char*)aParams[i] ); - const char* aValue = set_convert( (const char*)aParams[i], aValues[i] ); - setValue( aCtrl, aValue ); + + for ( int j = 0; j < aParams->length(); j++ ) { + QWidget* aCtrl = getControl( (const char*)aParams[j] ); + setValue( aCtrl, set_convert( (const char*)aParams[j], aValues[j] )); } } } @@ -554,40 +552,61 @@ void RepairGUI_ShapeProcessDlg::loadDefaults() // function : setValue() // purpose : set value in the proper way //================================================================================= -void RepairGUI_ShapeProcessDlg::setValue( QWidget* theControl, const char* theValue ) +void RepairGUI_ShapeProcessDlg::setValue( QWidget* theControl, const QString& theValue ) { - if ( theControl == NULL || theValue == NULL ) - return; - - if ( theControl->isA( "QtxDblSpinBox" ) ) - ((QtxDblSpinBox*)theControl)->setValue( QString( theValue ).toDouble() ); - else if ( theControl->isA( "QSpinBox" ) ) - ((QSpinBox*)theControl)->setValue( QString( theValue ).toInt() ); - else if ( theControl->isA( "QComboBox" ) ) - ((QComboBox*)theControl)->setCurrentText( QString( theValue ) ); - else if ( theControl->isA( "QCheckBox" ) ) - ((QCheckBox*)theControl)->setChecked( QString( theValue ).toInt() != 0 ); + if ( theControl && !theValue.isNull() ) { + if ( qobject_cast( theControl )) + qobject_cast( theControl )->setValue( theValue.toDouble() ); + else if ( qobject_cast( theControl )) + qobject_cast( theControl )->setValue( theValue.toInt() ); + else if ( qobject_cast( theControl )) + qobject_cast( theControl )->setEditText( theValue ); + else if ( qobject_cast( theControl )) + qobject_cast( theControl )->setChecked( theValue.toInt() != 0 ); + } } //================================================================================= // function : getValue() // purpose : get value in the proper way //================================================================================= -const char* RepairGUI_ShapeProcessDlg::getValue( QWidget* theControl ) const +QString RepairGUI_ShapeProcessDlg::getValue( QWidget* theControl ) const { - if ( theControl == NULL ) - return ""; + if ( theControl ) { + if ( qobject_cast( theControl )) { + if ( ( theControl == myDropSmallSolidsWidTol || theControl == myDropSmallSolidsVolTol ) && !theControl->isEnabled() ) { + // VSR: stupid workaround about ShapeProcessAPI: + // specific processing for optional parameters of DropSmallSolids operator + return QString::number( Precision::Infinite() ); + } + return QString::number( qobject_cast( theControl )->value() ); + } + else if ( qobject_cast( theControl )) { + return QString::number( qobject_cast( theControl )->value() ); + } + else if ( qobject_cast( theControl )) { + return qobject_cast( theControl )->currentText(); + } + else if ( qobject_cast( theControl )) { + return qobject_cast( theControl )->isChecked() ? "1" : "0"; + } + } + return 0; +} - if ( theControl->isA( "QtxDblSpinBox" ) ) - return ((QtxDblSpinBox*)theControl)->text().latin1(); - else if ( theControl->isA( "QSpinBox" ) ) - return ((QSpinBox*)theControl)->text().latin1(); - else if ( theControl->isA( "QComboBox" ) ) - return ((QComboBox*)theControl)->currentText().latin1(); - else if ( theControl->isA( "QCheckBox" ) ) - return ((QCheckBox*)theControl)->isChecked() ? "1" : "0"; - - return ""; +//================================================================================= +// function : getText() +// purpose : get text in the proper way +//================================================================================= +QString RepairGUI_ShapeProcessDlg::getText( QWidget* theControl ) const +{ + if ( theControl ) { + if ( qobject_cast( theControl )) + return qobject_cast( theControl )->text(); + else if ( qobject_cast( theControl )) + return qobject_cast( theControl )->text(); + } + return QString::null; } //================================================================================= @@ -605,21 +624,36 @@ GEOM::GEOM_IOperations_ptr RepairGUI_ShapeProcessDlg::createOperation() //================================================================================= bool RepairGUI_ShapeProcessDlg::isValid( QString& msg ) { + bool ok = true; + QMapIterator aMapIter( myValMap ); + while( aMapIter.hasNext() ) { + aMapIter.next(); + const QStringList& aList = aMapIter.value(); + QListIterator aListIter( aList ); + while( aListIter.hasNext() ) { + const QString& aParam = aListIter.next(); + QWidget* aControl = getControl( aParam ); + if ( !aControl->isEnabled() ) continue; + if ( qobject_cast( aControl )) + ok = qobject_cast( aControl )->isValid( msg, !IsPreview() ) && ok; + else if ( qobject_cast( aControl )) + ok = qobject_cast( aControl )->isValid( msg, !IsPreview() ) && ok; + } + } + bool error = false; GEOM::string_array_var anOperators = getActiveOperators(); - if ( !myObjects->length() ) - { + if ( !myObjects->length() ) { msg += tr( "ERROR_NO_OBJECTS" ); error = true; } - if ( !anOperators->length() ) - { + if ( !anOperators->length() ) { if ( error ) msg += "\n"; msg += tr( "ERROR_NO_OPERATORS" ); error = true; } - return !error; + return !error && ok; } //================================================================================= @@ -634,35 +668,51 @@ bool RepairGUI_ShapeProcessDlg::execute( ObjectList& objects ) /*//-- check -- int z; - MESSAGE("Objects : "); - for ( z = 0; z < myObjects->length(); z++ ) - MESSAGE(myObjects[z]->GetName() << " "); - MESSAGE("\nOperators : "); - for ( z = 0; z < anOperators->length(); z++ ) - MESSAGE(anOperators[z] << " "); - MESSAGE("\nParameters : "); - for ( z = 0; z < aParams->length(); z++ ) - MESSAGE(aParams[z] << " "); - MESSAGE("\nValues : "); - for ( z = 0; z < aValues->length(); z ++ ) - MESSAGE(aValues[z] << " "); - MESSAGE("\n"); + MESSAGE("Objects : "); + for ( z = 0; z < myObjects->length(); z++ ) + MESSAGE(myObjects[z]->GetName() << " "); + MESSAGE("\nOperators : "); + for ( z = 0; z < anOperators->length(); z++ ) + MESSAGE(anOperators[z] << " "); + MESSAGE("\nParameters : "); + for ( z = 0; z < aParams->length(); z++ ) + MESSAGE(aParams[z] << " "); + MESSAGE("\nValues : "); + for ( z = 0; z < aValues->length(); z ++ ) + MESSAGE(aValues[z] << " "); + MESSAGE("\n"); */// ----------- QStringList anErrorObjNames; - for ( int i = 0; i < myObjects->length(); i++ ) - { + for ( int i = 0; i < myObjects->length(); i++ ) { GEOM::GEOM_Object_var obj = myObjects[i]; - GEOM::GEOM_Object_var anObj = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )->ProcessShape( - obj, anOperators, aParams, aValues ); + GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow( getOperation() ); + GEOM::GEOM_Object_var anObj = anOper->ProcessShape( obj, anOperators, aParams, aValues ); if ( anObj->_is_nil() ) anErrorObjNames << GEOMBase::GetName( obj ); else + { + if ( !IsPreview() ) + { + QStringList aParameters; + + for ( int i = 0; i < anOperators->length(); i++ ) + aParameters << QString( anOperators[i] ); + + for ( int i = 0; i < aParams->length(); i++ ) + aParameters << QString( aParams[i] ); + + aParameters << getTexts( aParams ); + anObj->SetParameters(aParameters.join(":").toLatin1().constData()); + + RepairGUI::ShowStatistics( anOper, this ); + } objects.push_back( anObj._retn() ); + } } if ( !anErrorObjNames.empty() ) - MESSAGE("ERRORS occured while processing the following objects: " << anErrorObjNames.join( " " )); + MESSAGE( "ERRORS occured while processing the following objects: " << anErrorObjNames.join( " " ).toLatin1().data() ); return anErrorObjNames.size() < myObjects->length(); // true if at least one object was OK, false if ALL objects were nil after Healing. } @@ -674,16 +724,15 @@ bool RepairGUI_ShapeProcessDlg::execute( ObjectList& objects ) GEOM::string_array* RepairGUI_ShapeProcessDlg::getActiveOperators() { GEOM::string_array_var anOperators = new GEOM::string_array(); - QStringList aCheckedList; - QStringList::Iterator it; - for ( it = myOpLst.begin(); it != myOpLst.end(); ++it ) - if ( ((QCheckListItem*)myOpList->findItem( *it, 0 ))->isOn() ) - aCheckedList << *it; - anOperators->length( aCheckedList.size() ); - int i = 0; - for ( it = aCheckedList.begin(); it != aCheckedList.end(); ++it ) - anOperators[i++] = CORBA::string_dup( (*it).latin1() ); - + + int j = 0, n = myOpList->count(); + anOperators->length( n ); + for ( int i = 0; i < n; i++ ) { + if ( myOpList->item( i )->checkState() == Qt::Checked ) + anOperators[j++] = myOpList->item( i )->text().toLatin1().constData(); + } + anOperators->length( j ); + return anOperators._retn(); } @@ -691,34 +740,36 @@ GEOM::string_array* RepairGUI_ShapeProcessDlg::getActiveOperators() // function : getcontrol // purpose : //================================================================================= -QWidget* RepairGUI_ShapeProcessDlg::getControl( const char* theParam ) -{ - string aParam = theParam; - if ( aParam == "SplitAngle.Angle" ) return mySplitAngleAngle; - else if ( aParam == "SplitAngle.MaxTolerance" ) return mySplitAngleMaxTol; - else if ( aParam == "SplitClosedFaces.NbSplitPoints" ) return mySplitClosedFacesNum; - else if ( aParam == "FixFaceSize.Tolerance" ) return myFixFaceSizeTol; - else if ( aParam == "DropSmallEdges.Tolerance3d" ) return myDropSmallEdgesTol3D; - else if ( aParam == "BSplineRestriction.SurfaceMode" ) return myBSplineSurfModeChk; - else if ( aParam == "BSplineRestriction.Curve3dMode" ) return myBSpline3DCurveChk; - else if ( aParam == "BSplineRestriction.Curve2dMode" ) return myBSpline2DCurveChk; - else if ( aParam == "BSplineRestriction.Tolerance3d" ) return myBSplineTol3D; - else if ( aParam == "BSplineRestriction.Tolerance2d" ) return myBSplineTol2D; - else if ( aParam == "BSplineRestriction.RequiredDegree" ) return myBSplineDegree; - else if ( aParam == "BSplineRestriction.RequiredNbSegments" ) return myBSplineSegments; - else if ( aParam == "BSplineRestriction.Continuity3d" ) return myBSpline3DCont; - else if ( aParam == "BSplineRestriction.Continuity2d" ) return myBSpline2DCont; - else if ( aParam == "SplitContinuity.Tolerance3d" ) return mySplitContTol3D; - else if ( aParam == "SplitContinuity.SurfaceContinuity" ) return mySplitContSurfCont; - else if ( aParam == "SplitContinuity.CurveContinuity" ) return mySplitContCurvCont; - else if ( aParam == "ToBezier.SurfaceMode" ) return myToBezierSurfModeChk; - else if ( aParam == "ToBezier.Curve3dMode" ) return myToBezier3DCurveChk; - else if ( aParam == "ToBezier.Curve2dMode" ) return myToBezier2DCurveChk; - else if ( aParam == "ToBezier.MaxTolerance" ) return myToBezierMaxTol; - else if ( aParam == "SameParameter.Tolerance3d" ) return mySameParameterTol3D; - else if ( aParam == "FixShape.Tolerance3d" ) return myFixShapeTol3D; - else if ( aParam == "FixShape.MaxTolerance3d" ) return myFixShapeMaxTol3D; - return NULL; +QWidget* RepairGUI_ShapeProcessDlg::getControl( const QString& theParam ) +{ + if ( theParam == "SplitAngle.Angle" ) return mySplitAngleAngle; + else if ( theParam == "SplitAngle.MaxTolerance" ) return mySplitAngleMaxTol; + else if ( theParam == "SplitClosedFaces.NbSplitPoints" ) return mySplitClosedFacesNum; + else if ( theParam == "FixFaceSize.Tolerance" ) return myFixFaceSizeTol; + else if ( theParam == "DropSmallEdges.Tolerance3d" ) return myDropSmallEdgesTol3D; + else if ( theParam == "DropSmallSolids.WidthFactorThreshold" ) return myDropSmallSolidsWidTol; + else if ( theParam == "DropSmallSolids.VolumeThreshold" ) return myDropSmallSolidsVolTol; + else if ( theParam == "DropSmallSolids.MergeSolids" ) return myDropSmallSolidsMergeChk; + else if ( theParam == "BSplineRestriction.SurfaceMode" ) return myBSplineSurfModeChk; + else if ( theParam == "BSplineRestriction.Curve3dMode" ) return myBSpline3DCurveChk; + else if ( theParam == "BSplineRestriction.Curve2dMode" ) return myBSpline2DCurveChk; + else if ( theParam == "BSplineRestriction.Tolerance3d" ) return myBSplineTol3D; + else if ( theParam == "BSplineRestriction.Tolerance2d" ) return myBSplineTol2D; + else if ( theParam == "BSplineRestriction.RequiredDegree" ) return myBSplineDegree; + else if ( theParam == "BSplineRestriction.RequiredNbSegments" ) return myBSplineSegments; + else if ( theParam == "BSplineRestriction.Continuity3d" ) return myBSpline3DCont; + else if ( theParam == "BSplineRestriction.Continuity2d" ) return myBSpline2DCont; + else if ( theParam == "SplitContinuity.Tolerance3d" ) return mySplitContTol3D; + else if ( theParam == "SplitContinuity.SurfaceContinuity" ) return mySplitContSurfCont; + else if ( theParam == "SplitContinuity.CurveContinuity" ) return mySplitContCurvCont; + else if ( theParam == "ToBezier.SurfaceMode" ) return myToBezierSurfModeChk; + else if ( theParam == "ToBezier.Curve3dMode" ) return myToBezier3DCurveChk; + else if ( theParam == "ToBezier.Curve2dMode" ) return myToBezier2DCurveChk; + else if ( theParam == "ToBezier.MaxTolerance" ) return myToBezierMaxTol; + else if ( theParam == "SameParameter.Tolerance3d" ) return mySameParameterTol3D; + else if ( theParam == "FixShape.Tolerance3d" ) return myFixShapeTol3D; + else if ( theParam == "FixShape.MaxTolerance3d" ) return myFixShapeMaxTol3D; + return 0; } //================================================================================= @@ -727,6 +778,9 @@ QWidget* RepairGUI_ShapeProcessDlg::getControl( const char* theParam ) //================================================================================= void RepairGUI_ShapeProcessDlg::initParamsValues() { + if ( myOpLst.count() ) + return; // already filled + myOpLst << "FixShape"; myValMap["FixShape"] << "FixShape.Tolerance3d"; myValMap["FixShape"] << "FixShape.MaxTolerance3d"; @@ -737,6 +791,11 @@ void RepairGUI_ShapeProcessDlg::initParamsValues() myOpLst << "DropSmallEdges"; myValMap["DropSmallEdges"] << "DropSmallEdges.Tolerance3d"; + myOpLst << "DropSmallSolids"; + myValMap["DropSmallSolids"] << "DropSmallSolids.WidthFactorThreshold"; + myValMap["DropSmallSolids"] << "DropSmallSolids.VolumeThreshold"; + myValMap["DropSmallSolids"] << "DropSmallSolids.MergeSolids"; + myOpLst << "SplitAngle"; myValMap["SplitAngle"] << "SplitAngle.Angle"; myValMap["SplitAngle"] << "SplitAngle.MaxTolerance"; @@ -776,25 +835,27 @@ void RepairGUI_ShapeProcessDlg::initParamsValues() //================================================================================= GEOM::string_array* RepairGUI_ShapeProcessDlg::getParameters( const GEOM::string_array& theOperators ) { - GEOM::string_array_var aParams = new GEOM::string_array(); - int i( 0 ), j( 0 ); - - // calculate the length of parameters - for ( i = 0, j = 0; i < theOperators.length(); i++ ) - j+= myValMap[QString((const char*)theOperators[i])].size(); + GEOM::string_array_var aParams = new GEOM::string_array(); + int i = 0, j = 0; - // set the new length of paremeters - aParams->length( j ); + // calculate the length of parameters + for ( i = 0, j = 0; i < theOperators.length(); i++ ) + j += myValMap[ QString( theOperators[i].in() ) ].size(); + + // set the new length of paremeters + aParams->length( j ); + + // fill the parameters + for ( i = 0, j = 0; i < theOperators.length(); i++ ) { + QStringList aParamLst = myValMap[ QString( theOperators[i].in() ) ]; + foreach ( QString aParam, aParamLst ) { + aParams[j++] = CORBA::string_dup( aParam.toLatin1().constData() ); + } + } - // fill the parameters - for ( i = 0, j = 0; i < theOperators.length(); i++ ) - { - QStringList aValLst = myValMap[QString( (const char*)theOperators[i] )]; - for ( QStringList::Iterator it = aValLst.begin(); it != aValLst.end(); ++it ) - aParams[j++] = CORBA::string_dup( (*it).latin1() ); - } + aParams->length( j ); - return aParams._retn(); + return aParams._retn(); } @@ -806,15 +867,35 @@ GEOM::string_array* RepairGUI_ShapeProcessDlg::getValues( const GEOM::string_arr { GEOM::string_array_var aValues = new GEOM::string_array(); aValues->length( theParams.length() ); + + for ( int i = 0; i < theParams.length(); i++ ) { + QWidget* aCtrl = getControl( (const char*)theParams[i] ); + if ( aCtrl ) + aValues[i] = get_convert( (const char*)theParams[i], getValue( aCtrl )); + } + + return aValues._retn(); +} + +//================================================================================= +// function : getTexts +// purpose : +//================================================================================= +QStringList RepairGUI_ShapeProcessDlg::getTexts( const GEOM::string_array& theParams ) +{ + QStringList aTexts; - for ( int i = 0; i < theParams.length(); i++ ) - { + for ( int i = 0; i < theParams.length(); i++ ) { QWidget* aCtrl = getControl( (const char*)theParams[i] ); if ( aCtrl ) - aValues[i] = get_convert( (const char*)theParams[i], getValue( aCtrl ) ); + { + QString aText = getText( aCtrl ); + if( !aText.isNull() ) + aTexts.append( aText ); + } } - return aValues._retn(); + return aTexts; } //================================================================================= @@ -840,8 +921,88 @@ void RepairGUI_ShapeProcessDlg::initSelection() //================================================================================= void RepairGUI_ShapeProcessDlg::advOptionToggled( bool on ) { - QButton* btn = (QButton*)sender(); - if ( on && btn->isToggleButton() && - QMessageBox::warning( SUIT_Session::session()->activeApplication()->desktop(), tr( "GEOM_WRN_WARNING" ), tr( "TIME_CONSUMING" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) - btn->toggle(); + QAbstractButton* btn = (QAbstractButton*)sender(); + if ( btn == myToBezierSurfModeChk ) + { + if ( on && btn->isCheckable() && + SUIT_MessageBox::warning( this, + tr( "GEOM_WRN_WARNING" ), tr( "TIME_CONSUMING" ), + SUIT_MessageBox::Yes | SUIT_MessageBox::No ) == SUIT_MessageBox::No ) + btn->toggle(); + } + + // either myDropSmallSolidsWidChk or myDropSmallSolidsVolChk must be checked + if ( btn == myDropSmallSolidsWidChk ) + { + myDropSmallSolidsWidTol->setEnabled( on ); + if ( !on ) { + myDropSmallSolidsVolChk->setChecked( true ); + myDropSmallSolidsVolTol->setEnabled( true ); + } + } + if ( btn == myDropSmallSolidsVolChk ) + { + myDropSmallSolidsVolTol->setEnabled( on ); + if ( !on ) { + myDropSmallSolidsWidChk->setChecked( true ); + myDropSmallSolidsWidTol->setEnabled( true ); + } + } +} + +//======================================================================= +//function : operatorChecked +//purpose : show parameters of a selected operator +//======================================================================= + +void RepairGUI_ShapeProcessDlg::operatorChecked( QListWidgetItem * item ) +{ + if ( item && item->checkState() == Qt::Checked ) + { + item->setSelected(true); + myStack->setCurrentIndex( myOpList->row( item )); + } + updateSelectAll(); +} + +void RepairGUI_ShapeProcessDlg::updateSelectAll() +{ + Qt::CheckState state = myOpList->count() > 0 ? myOpList->item(0)->checkState() : Qt::Unchecked; + for ( int i = 1; i < myOpList->count(); i++ ) { + if ( myOpList->item(i)->checkState() != state ) { + state = Qt::PartiallyChecked; + break; + } + } + mySelectAll->blockSignals( true ); + mySelectAll->setCheckState( state ); + mySelectAll->blockSignals( false ); +} + +void RepairGUI_ShapeProcessDlg::onSelectAll( int state ) +{ + if ( state == Qt::PartiallyChecked ) { + mySelectAll->setCheckState( Qt::Checked ); + return; + } + myOpList->blockSignals( true ); + for ( int i = 0; i < myOpList->count(); i++ ) { + myOpList->item(i)->setCheckState( (Qt::CheckState)state ); + } + myOpList->blockSignals( false ); +} + +//================================================================================= +// function : getSourceObjects +// purpose : virtual method to get source objects +//================================================================================= +QList RepairGUI_ShapeProcessDlg::getSourceObjects() +{ + QList res; + GEOM::ListOfGO aListPtr(myObjects); + for (int i = 0; i < aListPtr.length(); i++) { + GEOM::GeomObjPtr aGeomObjPtr(aListPtr[i]); + res << aGeomObjPtr; + } + return res; }