X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FOperationGUI%2FOperationGUI_PartitionDlg.cxx;h=45871a7db05a1762baa7f50ac7f5f911ad111731;hb=6c5c2bd009df3635175f57855c5dfd3299736b6f;hp=e52df271c4f2bf71e5cdbf5ff4c4ad22a1506ef1;hpb=392885c1a8d50369708bbe5e6b44033ed8b8ba51;p=modules%2Fgeom.git diff --git a/src/OperationGUI/OperationGUI_PartitionDlg.cxx b/src/OperationGUI/OperationGUI_PartitionDlg.cxx index e52df271c..45871a7db 100644 --- a/src/OperationGUI/OperationGUI_PartitionDlg.cxx +++ b/src/OperationGUI/OperationGUI_PartitionDlg.cxx @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2011 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 +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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. +// 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 +// 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // GEOM GEOMGUI : GUI for Geometry component // File : OperationGUI_PartitionDlg.cxx // Author : Lucien PIGNOLONI, Open CASCADE S.A.S. @@ -34,9 +35,13 @@ #include #include #include +#include #include #include +#include +#include + //================================================================================= // class : OperationGUI_PartitionDlg() // purpose : Constructs a OperationGUI_PartitionDlg which is a child of 'parent', with the @@ -62,18 +67,19 @@ OperationGUI_PartitionDlg::OperationGUI_PartitionDlg( GeometryGUI* theGeometryGU mainFrame()->RadioButton3->close(); // Full partition (contains half-space partition) - GroupPoints = new DlgRef_2Sel1List1Check( centralWidget() ); + GroupPoints = new DlgRef_2Sel1List2Check( centralWidget() ); GroupPoints->GroupBox1->setTitle( tr( "GEOM_PARTITION" ) ); GroupPoints->TextLabel1->setText( tr( "GEOM_OBJECTS" ) ); - GroupPoints->TextLabel2->setText( tr( "GEOM_TOOL_OBJECT" ) ); + GroupPoints->TextLabel2->setText( tr( "GEOM_TOOL_OBJECTS" ) ); GroupPoints->TextLabel3->setText( tr( "GEOM_RECONSTRUCTION_LIMIT" ) ); GroupPoints->PushButton1->setIcon( image2 ); GroupPoints->PushButton2->setIcon( image2 ); GroupPoints->LineEdit1->setReadOnly( true ); GroupPoints->LineEdit2->setReadOnly( true ); - GroupPoints->LineEdit1->setEnabled(true); - GroupPoints->LineEdit2->setEnabled(false); + GroupPoints->LineEdit1->setEnabled( true ); + GroupPoints->LineEdit2->setEnabled( false ); GroupPoints->CheckButton1->setText( tr( "GEOM_KEEP_NONLIMIT_SHAPES" ) ); + GroupPoints->CheckButton2->setText( tr( "GEOM_NO_SELF_INTERSECTION" ) ); QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); layout->setMargin( 0 ); layout->setSpacing( 6 ); @@ -114,11 +120,17 @@ void OperationGUI_PartitionDlg::Init() { /* type for sub shape selection */ GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_SOLID" ) ); + GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::SOLID); GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_SHELL" ) ); + GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::SHELL); GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_FACE" ) ); + GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::FACE); GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_WIRE" ) ); + GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::WIRE); GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_EDGE" ) ); + GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::EDGE); GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_VERTEX" ) ); + GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::VERTEX); GroupPoints->CheckButton1->setChecked( false ); mainFrame()->GroupBoxPublish->show(); @@ -138,7 +150,10 @@ void OperationGUI_PartitionDlg::Init() connect( GroupPoints->ComboBox1, SIGNAL( activated( int ) ), this, SLOT( ComboTextChanged() ) ); connect( myGeomGUI->getApp()->selectionMgr(), - SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + + connect( GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(processPreview()) ); + connect( GroupPoints->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(processPreview()) ); initName( tr( "GEOM_PARTITION" ) ); @@ -156,20 +171,22 @@ void OperationGUI_PartitionDlg::ConstructorsClicked( int constructorId ) disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 ); globalSelection(); - myListShapes.length( 0 ); - myListTools.length( 0 ); - myListKeepInside.length( 0 ); - myListRemoveInside.length( 0 ); - myListMaterials.length( 0 ); + //myListShapes.length( 0 ); + //myListTools.length( 0 ); + //myListKeepInside.length( 0 ); // obsolete + //myListRemoveInside.length( 0 ); // obsolete + //myListMaterials.length( 0 ); // obsolete switch ( constructorId ) { case 0: /*Full partition */ GroupPoints->GroupBox1->setTitle( tr( "GEOM_PARTITION" ) ); - GroupPoints->TextLabel2->setText( tr( "GEOM_TOOL_OBJECT" ) ); + GroupPoints->TextLabel1->setText( tr( "GEOM_OBJECTS" ) ); + GroupPoints->TextLabel2->setText( tr( "GEOM_TOOL_OBJECTS" ) ); GroupPoints->TextLabel3->show(); GroupPoints->ComboBox1->show(); GroupPoints->ComboBox1->setCurrentIndex( 0 ); GroupPoints->CheckButton1->show(); + GroupPoints->CheckButton2->show(); GroupPoints->PushButton1->setDown( true ); GroupPoints->PushButton2->setDown( false ); GroupPoints->LineEdit1->setEnabled(true); @@ -179,8 +196,10 @@ void OperationGUI_PartitionDlg::ConstructorsClicked( int constructorId ) GroupPoints->GroupBox1->setTitle( tr( "GEOM_PARTITION_HALFSPACE" ) ); GroupPoints->TextLabel3->hide(); GroupPoints->ComboBox1->hide(); + GroupPoints->TextLabel1->setText( tr( "GEOM_OBJECT" ) ); GroupPoints->TextLabel2->setText( tr( "GEOM_PLANE" ) ); GroupPoints->CheckButton1->hide(); + GroupPoints->CheckButton2->hide(); GroupPoints->PushButton1->setDown( true ); GroupPoints->LineEdit1->setEnabled(true); break; @@ -196,7 +215,8 @@ void OperationGUI_PartitionDlg::ConstructorsClicked( int constructorId ) myEditCurrentArgument->setFocus(); connect( myGeomGUI->getApp()->selectionMgr(), - SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + SelectionIntoArgument(); } @@ -206,6 +226,7 @@ void OperationGUI_PartitionDlg::ConstructorsClicked( int constructorId ) //================================================================================= void OperationGUI_PartitionDlg::ClickOnOk() { + setIsApplyAndClose( true ); if ( ClickOnApply() ) ClickOnCancel(); } @@ -220,8 +241,10 @@ bool OperationGUI_PartitionDlg::ClickOnApply() if ( !onAccept() ) return false; + initName(); - ConstructorsClicked( getConstructorId() ); + // 0020854: EDF 1398 GEOM: Ergonomy of Partition GUI window + // ConstructorsClicked( getConstructorId() ); return true; } @@ -241,27 +264,45 @@ void OperationGUI_PartitionDlg::SelectionIntoArgument() int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true); - if ( nbSel < 1 ) { - if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { - myListShapes.length( 0 ); - myListMaterials.length( 0 ); + if ( getConstructorId() == 1 ) { + // for half-selection, only one shape can be selected as an object + // and only one plane as a tool + if ( nbSel != 1 ) { + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { + myListShapes.length( 0 ); + // myListMaterials.length( 0 ); // obsolete + return; + } + else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) { + myListTools.length( 0 ); + return; + } } - else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) - myListTools.length( 0 ); } - - // One and only one plane can be selected - - if ( getConstructorId() == 1 && - myEditCurrentArgument == GroupPoints->LineEdit2 && - nbSel != 1 ) { - myListTools.length( 0 ); - return; + else { + if ( nbSel < 1 ) { + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { + myListShapes.length( 0 ); + //myListMaterials.length( 0 ); // obsolete + return; + } + else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) { + myListTools.length( 0 ); + return; + } + } } if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { GEOMBase::ConvertListOfIOInListOfGO(aSelList, myListShapes, true); - myListMaterials.length( 0 ); + //myListMaterials.length( 0 ); // obsolete + + GEOM::shape_type type = GEOM::SHAPE; + for (int i = 0; i < myListShapes.length(); i++) + type = qMin( type, myListShapes[i]->GetMaxShapeType() ); + int idx = qMax( 0, GroupPoints->ComboBox1->findData( type ) ); + GroupPoints->ComboBox1->setCurrentIndex( idx ); + if ( !myListShapes.length() ) return; } @@ -269,9 +310,21 @@ void OperationGUI_PartitionDlg::SelectionIntoArgument() GEOMBase::ConvertListOfIOInListOfGO(aSelList, myListTools, true); if ( !myListTools.length() ) return; + else if ( myListTools.length() == 1 && getConstructorId() == 1 ) { + GEOM::GEOM_IMeasureOperations_var mOp = getGeomEngine()->GetIMeasureOperations( getStudyId() ); + GEOM::ListOfLong_var intList; + GEOM::ListOfDouble_var dblList; + GEOM::GEOM_IKindOfShape::shape_kind kind = mOp->KindOfShape( myListTools[0].in(), intList.out(), dblList.out() ); + mOp->UnRegister(); + if ( kind < GEOM::GEOM_IKindOfShape::DISK_CIRCLE || kind > GEOM::GEOM_IKindOfShape::PLANAR ) { + myListTools.length( 0 ); + return; + } + } } myEditCurrentArgument->setText( aString ); + processPreview(); } @@ -304,6 +357,7 @@ void OperationGUI_PartitionDlg::SetEditCurrentArgument() myEditCurrentArgument->setFocus(); SelectionIntoArgument(); send->setDown(true); + processPreview(); } @@ -331,9 +385,10 @@ void OperationGUI_PartitionDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect( myGeomGUI->getApp()->selectionMgr(), - SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); ConstructorsClicked( getConstructorId() ); + processPreview(); } @@ -364,8 +419,7 @@ GEOM::GEOM_IOperations_ptr OperationGUI_PartitionDlg::createOperation() //================================================================================= bool OperationGUI_PartitionDlg::isValid( QString& ) { - return ( myListShapes.length() || myListTools.length() || - myListKeepInside.length() || myListRemoveInside.length() ); + return ( myListShapes.length() || myListTools.length() ); // || myListKeepInside.length() || myListRemoveInside.length() // obsolete } @@ -376,37 +430,47 @@ bool OperationGUI_PartitionDlg::isValid( QString& ) bool OperationGUI_PartitionDlg::execute( ObjectList& objects ) { bool res = false; - GEOM::GEOM_Object_var anObj; - QString msg; - int aLimit = GetLimit(); - int aConstructorId = getConstructorId(); - int aKeepNonlimitShapes = 0; - - if ( aConstructorId == 1 ) { - aLimit = GEOM::SHAPE; - } - else { - if ( GroupPoints->CheckButton1->isChecked() ) { - aKeepNonlimitShapes = 1; - } - else { - aKeepNonlimitShapes = 0; - } - } - - if ( isValid( msg ) ) { - anObj = GEOM::GEOM_IBooleanOperations::_narrow( getOperation() )-> - MakePartition( myListShapes, myListTools, - myListKeepInside, myListRemoveInside, - aLimit, false, myListMaterials, aKeepNonlimitShapes ); + int aLimit = GetLimit(); + int aKeepNonlimitShapes = GroupPoints->CheckButton1->isChecked(); + bool aNoSelfIntersection = GroupPoints->CheckButton2->isChecked(); + + GEOM::GEOM_IBooleanOperations_var anOper = GEOM::GEOM_IBooleanOperations::_narrow( getOperation() ); + + switch ( getConstructorId() ) { + case 0: + anObj = aNoSelfIntersection ? + anOper->MakePartitionNonSelfIntersectedShape( myListShapes, myListTools, + myListKeepInside, myListRemoveInside, + aLimit, false, myListMaterials, aKeepNonlimitShapes ) : + anOper->MakePartition( myListShapes, myListTools, + myListKeepInside, myListRemoveInside, + aLimit, false, myListMaterials, aKeepNonlimitShapes ); res = true; + break; + case 1: + anObj = anOper->MakeHalfPartition( myListShapes[0].in(), myListTools[0].in() ); + res = true; + break; } - if ( !anObj->_is_nil() ) - objects.push_back( anObj._retn() ); - + if ( !anObj->_is_nil() ) { + TopoDS_Shape aShape; + GEOMBase::GetShape( anObj, aShape, TopAbs_SHAPE ); + TopoDS_Iterator It( aShape, Standard_True, Standard_True ); + int nbSubshapes = 0; + for ( ; It.More(); It.Next() ) + nbSubshapes++; + + if ( nbSubshapes ) + objects.push_back( anObj._retn() ); + else + SUIT_MessageBox::warning( this, + QObject::tr( "GEOM_ERROR" ), + QObject::tr( "GEOM_WRN_PARTITION_RESULT_EMPTY" ) ); + } + return res; } @@ -420,8 +484,9 @@ void OperationGUI_PartitionDlg::restoreSubShapes( SALOMEDS::Study_ptr theStudy if ( mainFrame()->CheckBoxRestoreSS->isChecked() ) { // empty list of arguments means that all arguments should be restored getGeomEngine()->RestoreSubShapesSO( theStudy, theSObject, GEOM::ListOfGO(), - /*theFindMethod=*/GEOM::FSM_GetInPlaceByHistory, - /*theInheritFirstArg=*/myListShapes.length() == 1 ); // ? false + /*theFindMethod=*/GEOM::FSM_GetInPlaceByHistory, + /*theInheritFirstArg=*/myListShapes.length() == 1, + mainFrame()->CheckBoxAddPrefix->isChecked() ); // ? false } } @@ -438,6 +503,7 @@ void OperationGUI_PartitionDlg::ComboTextChanged() //GroupPoints->TextLabel5->setEnabled(IsEnabled); //GroupPoints->PushButton3->setEnabled(IsEnabled); //GroupPoints->PushButton4->setEnabled(IsEnabled); + processPreview(); } //=================================================================================