X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FOperationGUI%2FOperationGUI_PartitionDlg.cxx;h=9649e3a9174eeb7e9d48ece66d7e89cd9aaf5a87;hb=a46ed42b20faee8edeaf0002ba7af44c39cce93c;hp=bedc631806594561823729d45198cfd1cd8802f9;hpb=732211808796539fcf1de34e06038e7fb015ece9;p=modules%2Fgeom.git diff --git a/src/OperationGUI/OperationGUI_PartitionDlg.cxx b/src/OperationGUI/OperationGUI_PartitionDlg.cxx index bedc63180..9649e3a91 100644 --- a/src/OperationGUI/OperationGUI_PartitionDlg.cxx +++ b/src/OperationGUI/OperationGUI_PartitionDlg.cxx @@ -17,7 +17,7 @@ // 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -34,7 +34,7 @@ #include "SUIT_Desktop.h" #include "SUIT_Session.h" #include "SalomeApp_Application.h" -#include "SalomeApp_SelectionMgr.h" +#include "LightApp_SelectionMgr.h" #include #include @@ -49,12 +49,14 @@ // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -OperationGUI_PartitionDlg::OperationGUI_PartitionDlg(QWidget* parent, const char* name, bool modal, WFlags fl) - :GEOMBase_Skeleton(parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +OperationGUI_PartitionDlg::OperationGUI_PartitionDlg(GeometryGUI* theGeometryGUI, QWidget* parent) + :GEOMBase_Skeleton(theGeometryGUI, parent, "OperationGUI_PartitionDlg", false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { - QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_PARTITION"))); - QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_PARTITION_PLANE"))); - QPixmap image2(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT"))); + SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr(); + QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_PARTITION"))); + QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_PARTITION_PLANE"))); + QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT"))); setCaption(tr("GEOM_PARTITION_TITLE")); @@ -65,27 +67,21 @@ OperationGUI_PartitionDlg::OperationGUI_PartitionDlg(QWidget* parent, const char RadioButton3->close(TRUE); // Full partition (contains half-space partition) - GroupPoints = new DlgRef_4Sel1List1Check_QTD(this, "GroupPoints"); + GroupPoints = new DlgRef_2Sel1List1Check_QTD(this, "GroupPoints"); GroupPoints->GroupBox1->setTitle(tr("GEOM_PARTITION")); - GroupPoints->GroupBox2->setTitle(tr("SUPPRESS_RESULT")); GroupPoints->TextLabel1->setText(tr("GEOM_OBJECTS")); GroupPoints->TextLabel2->setText(tr("GEOM_TOOL_OBJECT")); GroupPoints->TextLabel3->setText(tr("GEOM_RECONSTRUCTION_LIMIT")); - GroupPoints->TextLabel4->setText(tr("GEOM_SUPPRESS_RESULT_INSIDE")); - GroupPoints->TextLabel5->setText(tr("GEOM_SUPPRESS_RESULT_OUTSIDE")); - GroupPoints->CheckBox1->setText(tr("GEOM_REMOVE_WEBS")); GroupPoints->PushButton1->setPixmap(image2); GroupPoints->PushButton2->setPixmap(image2); - GroupPoints->PushButton3->setPixmap(image2); - GroupPoints->PushButton4->setPixmap(image2); - GroupPoints->PushButton5->setText(tr("GEOM_SET_MATERIALS")); GroupPoints->LineEdit1->setReadOnly( true ); GroupPoints->LineEdit2->setReadOnly( true ); - GroupPoints->LineEdit3->setReadOnly( true ); - GroupPoints->LineEdit4->setReadOnly( true ); + GroupPoints->radioButton4->setText(tr("GEOM_KEEP_NONLIMIT_SHAPES")); Layout1->addWidget(GroupPoints, 2, 0); /***************************************************************/ + + setHelpFileName("partition.htm"); Init(); } @@ -114,6 +110,7 @@ void OperationGUI_PartitionDlg::Init() GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_WIRE")); GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_EDGE")); GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_VERTEX")); + GroupPoints->radioButton4->setChecked(FALSE); /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); @@ -122,20 +119,15 @@ void OperationGUI_PartitionDlg::Init() connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->PushButton4, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->PushButton5, SIGNAL(clicked()), this, SLOT(SetMaterials())); connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->LineEdit4, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - - connect(GroupPoints->CheckBox1, SIGNAL(toggled(bool)), this, SLOT(onRemoveWebs(bool))); connect(GroupPoints->ComboBox1, SIGNAL(activated(int)), this, SLOT(ComboTextChanged())); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(GroupPoints->radioButton4, SIGNAL(stateChanged(int)), this, SLOT(ReverseSense(int))); + + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); initName( tr( "GEOM_PARTITION" ) ); @@ -149,7 +141,7 @@ void OperationGUI_PartitionDlg::Init() //================================================================================= void OperationGUI_PartitionDlg::ConstructorsClicked(int constructorId) { - disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0); + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); globalSelection(); myListShapes.length(0); @@ -157,7 +149,7 @@ void OperationGUI_PartitionDlg::ConstructorsClicked(int constructorId) myListKeepInside.length(0); myListRemoveInside.length(0); myListMaterials.length(0); - + switch (constructorId) { case 0: /*Full partition */ @@ -167,33 +159,29 @@ void OperationGUI_PartitionDlg::ConstructorsClicked(int constructorId) resize(0, 0); GroupPoints->TextLabel3->show(); GroupPoints->ComboBox1->show(); - GroupPoints->GroupBox2->show(); - GroupPoints->ComboBox1->setCurrentItem(0); - GroupPoints->LineEdit3->clear(); - GroupPoints->LineEdit4->clear(); + GroupPoints->radioButton4->show(); break; } case 1: /*Half-space partition */ { GroupPoints->GroupBox1->setTitle(tr("GEOM_PARTITION_HALFSPACE")); - GroupPoints->GroupBox2->hide(); GroupPoints->TextLabel3->hide(); GroupPoints->ComboBox1->hide(); GroupPoints->TextLabel2->setText(tr("GEOM_PLANE")); + GroupPoints->radioButton4->hide(); resize(0, 0); break; } } - + myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->clear(); GroupPoints->LineEdit2->clear(); - onRemoveWebs(false); myEditCurrentArgument->setFocus(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); MESSAGE(width()<<" "<LineEdit2 ) myListTools.length( 0 ); - else if ( myEditCurrentArgument == GroupPoints->LineEdit3 ) - myListRemoveInside.length( 0 ); - else if ( myEditCurrentArgument == GroupPoints->LineEdit4 ) - myListKeepInside.length( 0 ); } // One and only one plane can be selected @@ -282,18 +256,6 @@ void OperationGUI_PartitionDlg::SelectionIntoArgument() if ( !myListTools.length() ) return; } - else if(myEditCurrentArgument == GroupPoints->LineEdit3) - { - GEOMBase::ConvertListOfIOInListOfGO( selectedIO(), myListRemoveInside, true ); - if (!myListRemoveInside.length()) - return; - } - else if(myEditCurrentArgument == GroupPoints->LineEdit4) - { - GEOMBase::ConvertListOfIOInListOfGO( selectedIO(), myListKeepInside, true ); - if ( !myListKeepInside.length() ) - return; - } myEditCurrentArgument->setText( aString ); } @@ -315,10 +277,6 @@ void OperationGUI_PartitionDlg::SetEditCurrentArgument() if( getConstructorId()==1 ) globalSelection( GEOM_PLANE ); } - else if(send == GroupPoints->PushButton3) - myEditCurrentArgument = GroupPoints->LineEdit3; - else if(send == GroupPoints->PushButton4) - myEditCurrentArgument = GroupPoints->LineEdit4; globalSelection( GEOM_ALLSHAPES ); @@ -334,11 +292,9 @@ void OperationGUI_PartitionDlg::SetEditCurrentArgument() void OperationGUI_PartitionDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); - + if(send == GroupPoints->LineEdit1 || - send == GroupPoints->LineEdit2 || - send == GroupPoints->LineEdit3 || - send == GroupPoints->LineEdit4 ) + send == GroupPoints->LineEdit2 ) { myEditCurrentArgument = send; GEOMBase_Skeleton::LineEditReturnPressed(); @@ -353,30 +309,20 @@ void OperationGUI_PartitionDlg::LineEditReturnPressed() void OperationGUI_PartitionDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); ConstructorsClicked( getConstructorId() ); } -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : public slot to deactivate if active -//================================================================================= -void OperationGUI_PartitionDlg::DeactivateActiveDialog() -{ - GEOMBase_Skeleton::DeactivateActiveDialog(); -} - - //================================================================================= // function : enterEvent() // purpose : //================================================================================= void OperationGUI_PartitionDlg::enterEvent(QEvent* e) { - if(!GroupConstructors->isEnabled()) + if (!GroupConstructors->isEnabled()) this->ActivateThisDialog(); } @@ -397,8 +343,8 @@ GEOM::GEOM_IOperations_ptr OperationGUI_PartitionDlg::createOperation() //================================================================================= bool OperationGUI_PartitionDlg::isValid( QString& msg ) { - return (myListShapes.length() || myListTools.length() || - myListKeepInside.length() || myListRemoveInside.length()); + return (myListShapes.length() || myListTools.length() || + myListKeepInside.length() || myListRemoveInside.length()); } @@ -409,35 +355,38 @@ bool OperationGUI_PartitionDlg::isValid( QString& msg ) bool OperationGUI_PartitionDlg::execute( ObjectList& objects ) { bool res = false; - + GEOM::GEOM_Object_var anObj; QString msg; - + int aLimit = GetLimit(); int aConstructorId = getConstructorId(); - - if (aConstructorId==1) + + int aKeepNonlimitShapes = 0; + if (aConstructorId == 1) { aLimit = GEOM::SHAPE; - - if (isValid( msg )) - { - - if ( aConstructorId==0 && !toRemoveWebs() ) - myListMaterials.length(0); - - anObj = GEOM::GEOM_IBooleanOperations::_narrow( getOperation() )->MakePartition(myListShapes, - myListTools, - myListKeepInside, - myListRemoveInside, - aLimit, - toRemoveWebs(), - myListMaterials); - res = true; + } + else { + if(GroupPoints->radioButton4->isChecked()) { + aKeepNonlimitShapes = 1; } - - if ( !anObj->_is_nil() ) + else { + aKeepNonlimitShapes = 0; + } + } + + if (isValid( msg )) { + + anObj = GEOM::GEOM_IBooleanOperations::_narrow(getOperation())-> + MakePartition(myListShapes, myListTools, + myListKeepInside, myListRemoveInside, + aLimit, false, myListMaterials, aKeepNonlimitShapes); + res = true; + } + + if (!anObj->_is_nil()) objects.push_back( anObj._retn() ); - + return res; } @@ -456,53 +405,15 @@ void OperationGUI_PartitionDlg::closeEvent( QCloseEvent* e ) //function : ComboTextChanged //purpose : //======================================================================= - void OperationGUI_PartitionDlg::ComboTextChanged() { bool IsEnabled = GroupPoints->ComboBox1->currentItem() < 3; - GroupPoints->LineEdit3->setEnabled(IsEnabled); - GroupPoints->LineEdit4->setEnabled(IsEnabled); - GroupPoints->TextLabel4->setEnabled(IsEnabled); - GroupPoints->TextLabel5->setEnabled(IsEnabled); - GroupPoints->PushButton3->setEnabled(IsEnabled); - GroupPoints->PushButton4->setEnabled(IsEnabled); -} - - -//================================================================================= -// function : SetMaterials() -// purpose : -//================================================================================= -void OperationGUI_PartitionDlg::SetMaterials() -{ - MESSAGE("OperationGUI_MaterialDlg ..."); - OperationGUI_MaterialDlg *aDlg = - new OperationGUI_MaterialDlg(this, "", myListShapes, true); - MESSAGE("OperationGUI_MaterialDlg"); - return; -} - - -//================================================================================= -// function : onRemoveWebs() -// purpose : -//================================================================================= -void OperationGUI_PartitionDlg::onRemoveWebs(bool isChecked) -{ - if (GroupPoints->CheckBox1->isChecked() != isChecked) - GroupPoints->CheckBox1->setChecked(isChecked); - - GroupPoints->PushButton5->setEnabled(isChecked); -} - - -//================================================================================= -// function : toRemoveWebs() -// purpose : -//================================================================================= -bool OperationGUI_PartitionDlg::toRemoveWebs() const -{ - return GroupPoints->CheckBox1->isChecked(); + //GroupPoints->LineEdit3->setEnabled(IsEnabled); + //GroupPoints->LineEdit4->setEnabled(IsEnabled); + //GroupPoints->TextLabel4->setEnabled(IsEnabled); + //GroupPoints->TextLabel5->setEnabled(IsEnabled); + //GroupPoints->PushButton3->setEnabled(IsEnabled); + //GroupPoints->PushButton4->setEnabled(IsEnabled); } @@ -513,42 +424,17 @@ bool OperationGUI_PartitionDlg::toRemoveWebs() const int OperationGUI_PartitionDlg::GetLimit() const { int aLimit = GroupPoints->ComboBox1->currentItem(); - + switch(aLimit) - { - case 0 : - { - aLimit = GEOM::SOLID; - break; - } - case 1 : - { - aLimit = GEOM::SHELL; - break; - } - case 2 : - { - aLimit = GEOM::FACE; - break; - } - case 3 : - { - aLimit = GEOM::WIRE; - break; - } - case 4 : - { - aLimit = GEOM::EDGE; - break; - } - case 5 : - { - aLimit = GEOM::VERTEX; - break; - } - default : - aLimit = GEOM::SHAPE; - } - + { + case 0: aLimit = GEOM::SOLID ; break; + case 1: aLimit = GEOM::SHELL ; break; + case 2: aLimit = GEOM::FACE ; break; + case 3: aLimit = GEOM::WIRE ; break; + case 4: aLimit = GEOM::EDGE ; break; + case 5: aLimit = GEOM::VERTEX; break; + default: aLimit = GEOM::SHAPE ; + } + return aLimit; }