-// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#include <SUIT_ResourceMgr.h>
#include <SUIT_MessageBox.h>
#include <SALOME_ListIO.hxx>
+#include "utilities.h"
#include <Basics_Utils.hxx>
+#include "utilities.h"
#include <TCollection_AsciiString.hxx>
#include <TColStd_MapOfInteger.hxx>
// layout the two group boxes in the middle, add a list of operations
QGroupBox* anOperGr = new QGroupBox( tr( "GEOM_OPERATIONS" ), centralWidget() );
+ // "select all" button
+ mySelectAll = new QCheckBox( tr( "SELECT_ALL" ), anOperGr );
+ mySelectAll->setTristate( true );
+
// operations list widget
myOpList = new QListWidget( anOperGr );
myOpList->setSortingEnabled( false );
QVBoxLayout* aOperLay = new QVBoxLayout( anOperGr );
aOperLay->setMargin( 9 );
+ aOperLay->addWidget( mySelectAll );
aOperLay->addWidget( myOpList );
QGroupBox* aParamsGr = new QGroupBox( tr( "GEOM_PARAMETERS" ), centralWidget() );
myDropSmallSolidsVolChk = new QCheckBox( tr("VOLUME_TOL"), w );
myDropSmallSolidsWidTol = new SalomeApp_DoubleSpinBox( w );
myDropSmallSolidsVolTol = new SalomeApp_DoubleSpinBox( w );
- initSpinBox( myDropSmallSolidsWidTol, 0., 100., 1e-7, "len_tol_precision" );
- initSpinBox( myDropSmallSolidsVolTol, 0., 100., 1e-7, "len_tol_precision" );
- myDropSmallSolidsWidTol->setValue( 1e-7 );
- myDropSmallSolidsVolTol->setValue( 1e-7 );
+ 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 );
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 );
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->setCurrentRow( myOpList->findItem( 0 );
reset();
- myStack->setCurrentIndex( 0 );
+ myOpList->setCurrentRow(0);
initName( tr( "PROCESS_SHAPE_NEW_OBJ_NAME" ));
selectionChanged();
+ updateSelectAll();
}
//=================================================================================
QString RepairGUI_ShapeProcessDlg::getValue( QWidget* theControl ) const
{
if ( theControl ) {
- if ( qobject_cast<SalomeApp_DoubleSpinBox*>( theControl ))
+ if ( qobject_cast<SalomeApp_DoubleSpinBox*>( 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<SalomeApp_DoubleSpinBox*>( theControl )->value() );
- else if ( qobject_cast<SalomeApp_IntSpinBox*>( theControl ))
+ }
+ else if ( qobject_cast<SalomeApp_IntSpinBox*>( theControl )) {
return QString::number( qobject_cast<SalomeApp_IntSpinBox*>( theControl )->value() );
- else if ( qobject_cast<QComboBox*>( theControl ))
+ }
+ else if ( qobject_cast<QComboBox*>( theControl )) {
return qobject_cast<QComboBox*>( theControl )->currentText();
- else if ( qobject_cast<QCheckBox*>( theControl ))
+ }
+ else if ( qobject_cast<QCheckBox*>( theControl )) {
return qobject_cast<QCheckBox*>( theControl )->isChecked() ? "1" : "0";
+ }
}
return 0;
}
GEOM::string_array* RepairGUI_ShapeProcessDlg::getActiveOperators()
{
GEOM::string_array_var anOperators = new GEOM::string_array();
- QStringList aCheckedList;
- for ( int i = 0; i < myOpList->count(); i++ ) {
+ int j = 0, n = myOpList->count();
+ anOperators->length( n );
+ for ( int i = 0; i < n; i++ ) {
if ( myOpList->item( i )->checkState() == Qt::Checked )
- aCheckedList << myOpList->item( i )->text();
+ anOperators[j++] = myOpList->item( i )->text().toLatin1().constData();
}
-
- anOperators->length( aCheckedList.count() );
-
- for ( int i = 0; i < aCheckedList.count(); i++ )
- anOperators[i] = aCheckedList[i].toLatin1().constData();
+ anOperators->length( j );
return anOperators._retn();
}
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 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;
// calculate the length of parameters
for ( i = 0, j = 0; i < theOperators.length(); i++ )
- j += myValMap[ QString( theOperators[i] ) ].size();
+ 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 aValLst = myValMap[ QString( theOperators[i] ) ];
- for ( QStringList::Iterator it = aValLst.begin(); it != aValLst.end(); ++it )
- aParams[j++] = CORBA::string_dup( (*it).toLatin1().constData() );
+ QStringList aParamLst = myValMap[ QString( theOperators[i].in() ) ];
+ foreach ( QString aParam, aParamLst ) {
+ aParams[j++] = CORBA::string_dup( aParam.toLatin1().constData() );
+ }
}
+ aParams->length( j );
+
return aParams._retn();
}
for ( int i = 0; i < theParams.length(); i++ ) {
QWidget* aCtrl = getControl( (const char*)theParams[i] );
- if ( aCtrl && aCtrl->isEnabled() )
+ if ( aCtrl )
aValues[i] = get_convert( (const char*)theParams[i], getValue( aCtrl ));
}
{
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<GEOM::GeomObjPtr> RepairGUI_ShapeProcessDlg::getSourceObjects()
+{
+ QList<GEOM::GeomObjPtr> res;
+ GEOM::ListOfGO aListPtr(myObjects);
+ for (int i = 0; i < aListPtr.length(); i++) {
+ GEOM::GeomObjPtr aGeomObjPtr(aListPtr[i]);
+ res << aGeomObjPtr;
+ }
+ return res;
}