-// GEOM GEOMGUI : GUI for Geometry component
+// Copyright (C) 2007-2012 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.
//
+// 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 : OperationGUI_PartitionDlg.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 : OperationGUI_PartitionDlg.cxx
+// Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
-using namespace std;
#include "OperationGUI_PartitionDlg.h"
+#include <DlgRef.h>
+#include <GeometryGUI.h>
+#include <GEOMBase.h>
+
+#include <GEOMImpl_Types.hxx>
+
+#include <SUIT_Desktop.h>
+#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_MessageBox.h>
+#include <SalomeApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Shape.hxx>
+
//=================================================================================
// class : OperationGUI_PartitionDlg()
-// purpose : Constructs a OperationGUI_PartitionDlg which is a child of 'parent', with the
+// purpose : Constructs a OperationGUI_PartitionDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'.
// 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, OperationGUI* theOperationGUI, SALOME_Selection* Sel, bool modal, WFlags fl)
- :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
+OperationGUI_PartitionDlg::OperationGUI_PartitionDlg( GeometryGUI* theGeometryGUI, QWidget* parent )
+ : GEOMBase_Skeleton( theGeometryGUI, parent, false )
{
- QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_PARTITION")));
- QPixmap image1(QAD_Desktop::getResourceManager()->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"));
+ setWindowTitle( tr( "GEOM_PARTITION_TITLE" ) );
/***************************************************************/
- GroupConstructors->setTitle(tr("GEOM_PARTITION"));
- RadioButton1->setPixmap(image0);
- RadioButton2->close(TRUE);
- RadioButton3->close(TRUE);
-
- GroupPoints = new DlgRef_4Sel1List_QTD(this, "GroupPoints");
- GroupPoints->GroupBox1->setTitle(tr("GEOM_PARTITION"));
- 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->PushButton1->setPixmap(image1);
- GroupPoints->PushButton2->setPixmap(image1);
- GroupPoints->PushButton3->setPixmap(image1);
- GroupPoints->PushButton4->setPixmap(image1);
-
- Layout1->addWidget(GroupPoints, 1, 0);
+ mainFrame()->GroupConstructors->setTitle( tr( "GEOM_PARTITION" ) );
+ mainFrame()->RadioButton1->setIcon( image0 );
+ mainFrame()->RadioButton2->setIcon( image1 );
+ mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
+ mainFrame()->RadioButton3->close();
+
+ // Full partition (contains half-space partition)
+ GroupPoints = new DlgRef_2Sel1List2Check( centralWidget() );
+ GroupPoints->GroupBox1->setTitle( tr( "GEOM_PARTITION" ) );
+ GroupPoints->TextLabel1->setText( tr( "GEOM_OBJECTS" ) );
+ 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->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 );
+ layout->addWidget( GroupPoints );
+
/***************************************************************/
- /* Initialisations */
- myOperationGUI = theOperationGUI;
+ setHelpFileName( "partition_page.html" );
+
Init();
}
// no need to delete child widgets, Qt does it all for us
}
+void OperationGUI_PartitionDlg::SetListMaterials( GEOM::ListOfLong ListMaterials )
+{
+ myListMaterials = ListMaterials;
+}
+
+GEOM::ListOfLong OperationGUI_PartitionDlg::GetListMaterials()
+{
+ return myListMaterials;
+}
//=================================================================================
// function : Init()
//=================================================================================
void OperationGUI_PartitionDlg::Init()
{
- /* init variables */
- myEditCurrentArgument = GroupPoints->LineEdit1;
+ /* 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();
- myOkListShapes = myOkListTools = myOkKeepShape = myOkRemoveShape = false;
+ /* signals and slots connections */
+ connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
+ connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
- /* type for sub shape selection */
- GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_SOLID"));
- GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_SHELL"));
- GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_FACE"));
- GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_WIRE"));
- GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_EDGE"));
- GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_VERTEX"));
+ connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
- /* Current item is 'Shape' */
- GroupPoints->ComboBox1->setCurrentItem(0);
- myLimit = GroupPoints->ComboBox1->currentItem();
+ connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+ connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
- /* signals and slots connections */
- connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
- connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
+ connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
+ connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
+
+ connect( GroupPoints->ComboBox1, SIGNAL( activated( int ) ), this, SLOT( ComboTextChanged() ) );
+
+ connect( myGeomGUI->getApp()->selectionMgr(),
+ 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" ) );
+
+ ConstructorsClicked( 0 );
+ GroupPoints->PushButton1->click();
+}
- 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->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()));
+//=================================================================================
+// function : ConstructorsClicked()
+// purpose : Radio button management
+//=================================================================================
+void OperationGUI_PartitionDlg::ConstructorsClicked( int constructorId )
+{
+ disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
+ globalSelection();
+
+ //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->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);
+ GroupPoints->LineEdit2->setEnabled(false);
+ break;
+ case 1: /*Half-space partition */
+ 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;
+ }
- connect(GroupPoints->ComboBox1, SIGNAL(activated(int)), this, SLOT(ComboTextChanged()));
-
- connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+ myEditCurrentArgument = GroupPoints->LineEdit1;
+ GroupPoints->LineEdit1->clear();
+ GroupPoints->LineEdit2->clear();
- /* displays Dialog */
- GroupPoints->show();
- this->show();
+ qApp->processEvents();
+ updateGeometry();
+ resize( minimumSizeHint() );
- return;
+ myEditCurrentArgument->setFocus();
+ connect( myGeomGUI->getApp()->selectionMgr(),
+ SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ SelectionIntoArgument();
}
//=================================================================================
void OperationGUI_PartitionDlg::ClickOnOk()
{
- this->ClickOnApply();
- ClickOnCancel();
- return;
+ setIsApplyAndClose( true );
+ if ( ClickOnApply() )
+ ClickOnCancel();
}
// function : ClickOnApply()
// purpose :
//=================================================================================
-void OperationGUI_PartitionDlg::ClickOnApply()
+bool OperationGUI_PartitionDlg::ClickOnApply()
{
- QAD_Application::getDesktop()->putInfo(tr(""));
-
- if(myOkListShapes || myOkListTools || myOkKeepShape || myOkRemoveShape) {
- GEOM::shape_type limit;
- switch(myLimit)
- {
- case 0 :
- {
- limit = GEOM::SHAPE;
- break;
- }
- case 1 :
- {
- limit = GEOM::SHELL;
- break;
- }
- case 2 :
- {
- limit = GEOM::FACE;
- break;
- }
- case 3 :
- {
- limit = GEOM::WIRE;
- break;
- }
- case 4 :
- {
- limit = GEOM::EDGE;
- break;
- }
- case 5 :
- {
- limit = GEOM::VERTEX;
- break;
- }
- default :
- limit = GEOM::SHAPE;
- }
+ if ( !onAccept() )
+ return false;
- myOperationGUI->MakePartitionAndDisplay(myListShapes, myListTools, myListKeepInside, myListRemoveInside, limit);
- }
- return;
+ initName();
+ // 0020854: EDF 1398 GEOM: Ergonomy of Partition GUI window
+ // ConstructorsClicked( getConstructorId() );
+ return true;
}
//=================================================================================
void OperationGUI_PartitionDlg::SelectionIntoArgument()
{
- myEditCurrentArgument->setText("");
- QString aString = ""; /* name of selection */
-
- int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString);
- if(nbSel < 1) {
- if(myEditCurrentArgument == GroupPoints->LineEdit1)
- myOkListShapes = false;
- else if(myEditCurrentArgument == GroupPoints->LineEdit2)
- myOkListTools = false;
- else if(myEditCurrentArgument == GroupPoints->LineEdit3)
- myOkKeepShape = false;
- else if(myEditCurrentArgument == GroupPoints->LineEdit4)
- myOkRemoveShape = false;
- return;
- }
-
- if(myEditCurrentArgument == GroupPoints->LineEdit1) {
- myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes);
- myEditCurrentArgument->setText(aString);
- myOkListShapes = true;
+ myEditCurrentArgument->setText( "" );
+ QString aString = "";
+
+ LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
+ SALOME_ListIO aSelList;
+ aSelMgr->selectedObjects(aSelList);
+
+ int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true);
+
+ 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) {
- myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListTools);
- myEditCurrentArgument->setText(aString);
- myOkListTools = true;
+ 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;
+ }
+ }
}
- else if(myEditCurrentArgument == GroupPoints->LineEdit3) {
- myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListRemoveInside);
- myEditCurrentArgument->setText(aString);
- myOkKeepShape = true;
+
+ if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
+ GEOMBase::ConvertListOfIOInListOfGO(aSelList, myListShapes, true);
+ //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;
}
- else if(myEditCurrentArgument == GroupPoints->LineEdit4) {
- myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListKeepInside);
- myEditCurrentArgument->setText(aString);
- myOkRemoveShape = true;
+ else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
+ 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;
+ }
+ }
}
- /* no simulation */
- return;
+ myEditCurrentArgument->setText( aString );
+ processPreview();
}
{
QPushButton* send = (QPushButton*)sender();
- if(send == GroupPoints->PushButton1) {
- GroupPoints->LineEdit1->setFocus();
+ if ( send == GroupPoints->PushButton1 ) {
myEditCurrentArgument = GroupPoints->LineEdit1;
+ GroupPoints->PushButton2->setDown(false);
+ GroupPoints->LineEdit1->setEnabled(true);
+ GroupPoints->LineEdit2->setEnabled(false);
}
- else if(send == GroupPoints->PushButton2) {
- GroupPoints->LineEdit2->setFocus();
+ else if ( send == GroupPoints->PushButton2 ) {
+ myGeomGUI->getApp()->selectionMgr()->clearSelected(); //clear prewious selection
myEditCurrentArgument = GroupPoints->LineEdit2;
+ GroupPoints->PushButton1->setDown(false);
+ GroupPoints->LineEdit1->setEnabled(false);
+ GroupPoints->LineEdit2->setEnabled(true);
+ if ( getConstructorId() == 1 )
+ globalSelection( GEOM_PLANE );
}
- else if(send == GroupPoints->PushButton3) {
- GroupPoints->LineEdit3->setFocus();
- myEditCurrentArgument = GroupPoints->LineEdit3;
- }
- else if(send == GroupPoints->PushButton4) {
- GroupPoints->LineEdit4->setFocus();
- myEditCurrentArgument = GroupPoints->LineEdit4;
- }
- this->SelectionIntoArgument();
- return;
+ globalSelection( GEOM_ALLSHAPES );
+
+ myEditCurrentArgument->setFocus();
+ SelectionIntoArgument();
+ send->setDown(true);
+ processPreview();
}
void OperationGUI_PartitionDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
- if(send == GroupPoints->LineEdit1)
- myEditCurrentArgument = GroupPoints->LineEdit1;
- else if (send == GroupPoints->LineEdit2)
- myEditCurrentArgument = GroupPoints->LineEdit2;
- else if (send == GroupPoints->LineEdit3)
- myEditCurrentArgument = GroupPoints->LineEdit3;
- else if (send == GroupPoints->LineEdit4)
- myEditCurrentArgument = GroupPoints->LineEdit4;
- else
- return;
-
- GEOMBase_Skeleton::LineEditReturnPressed();
- return;
+
+ if ( send == GroupPoints->LineEdit1 ||
+ send == GroupPoints->LineEdit2 ) {
+ myEditCurrentArgument = send;
+ GEOMBase_Skeleton::LineEditReturnPressed();
+ }
}
void OperationGUI_PartitionDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
- connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
- return;
+ connect( myGeomGUI->getApp()->selectionMgr(),
+ SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+
+ ConstructorsClicked( getConstructorId() );
+ processPreview();
}
// function : enterEvent()
// purpose :
//=================================================================================
-void OperationGUI_PartitionDlg::enterEvent(QEvent* e)
+void OperationGUI_PartitionDlg::enterEvent( QEvent* )
+{
+ if ( !mainFrame()->GroupConstructors->isEnabled() )
+ this->ActivateThisDialog();
+}
+
+
+//=================================================================================
+// function : createOperation
+// purpose :
+//=================================================================================
+GEOM::GEOM_IOperations_ptr OperationGUI_PartitionDlg::createOperation()
+{
+ return getGeomEngine()->GetIBooleanOperations( getStudyId() );
+}
+
+
+//=================================================================================
+// function : isValid
+// purpose :
+//=================================================================================
+bool OperationGUI_PartitionDlg::isValid (QString& )
+{
+ return (getConstructorId() == 0 ?
+ myListShapes.length() :
+ myListShapes.length() && myListTools.length());
+}
+
+
+//=================================================================================
+// function : execute
+// purpose :
+//=================================================================================
+bool OperationGUI_PartitionDlg::execute (ObjectList& objects)
{
- if(GroupConstructors->isEnabled())
- return;
- this->ActivateThisDialog();
- return;
+ bool res = false;
+ GEOM::GEOM_Object_var anObj;
+
+ GEOM::GEOM_IBooleanOperations_var anOper = GEOM::GEOM_IBooleanOperations::_narrow(getOperation());
+
+ switch ( getConstructorId() ) {
+ case 0:
+ {
+ int aLimit = GetLimit();
+ int aKeepNonlimitShapes = GroupPoints->CheckButton1->isChecked();
+ bool aNoSelfIntersection = GroupPoints->CheckButton2->isChecked();
+
+ 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() ) {
+ 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;
}
+//=================================================================================
+// function : restoreSubShapes
+// purpose :
+//=================================================================================
+void OperationGUI_PartitionDlg::restoreSubShapes( SALOMEDS::Study_ptr theStudy,
+ SALOMEDS::SObject_ptr theSObject )
+{
+ 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,
+ mainFrame()->CheckBoxAddPrefix->isChecked() ); // ? false
+ }
+}
//=======================================================================
//function : ComboTextChanged
-//purpose :
+//purpose :
//=======================================================================
-
void OperationGUI_PartitionDlg::ComboTextChanged()
{
- myLimit = GroupPoints->ComboBox1->currentItem();
-
- 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);
- return;
+ //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);
+ processPreview();
+}
+
+//=================================================================================
+// function : GetLimit()
+// purpose :
+//=================================================================================
+int OperationGUI_PartitionDlg::GetLimit() const
+{
+ int aLimit = GroupPoints->ComboBox1->currentIndex();
+
+ 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 ;
+ }
+
+ return aLimit;
}