geom/src/OperationGUI/OperationGUI_PartitionDlg.cxx

554 lines
21 KiB
C++
Raw Normal View History

2014-02-18 12:44:41 +06:00
// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
2004-01-07 20:46:21 +05:00
//
2012-08-09 13:58:02 +06:00
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
2004-01-07 20:46:21 +05:00
//
2012-08-09 13:58:02 +06:00
// 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
2014-02-18 12:44:41 +06:00
// version 2.1 of the License, or (at your option) any later version.
2004-01-07 20:46:21 +05:00
//
2012-08-09 13:58:02 +06:00
// 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.
2009-02-13 17:16:39 +05:00
//
2012-08-09 13:58:02 +06:00
// 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
2009-02-13 17:16:39 +05:00
//
2012-08-09 13:58:02 +06:00
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
2009-02-13 17:16:39 +05:00
//
2012-08-09 13:58:02 +06:00
2009-02-13 17:16:39 +05:00
// GEOM GEOMGUI : GUI for Geometry component
// File : OperationGUI_PartitionDlg.cxx
// Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
2012-08-09 13:58:02 +06:00
2004-01-07 20:46:21 +05:00
#include "OperationGUI_PartitionDlg.h"
2004-12-01 15:39:14 +05:00
2009-02-13 17:16:39 +05:00
#include <DlgRef.h>
#include <GeometryGUI.h>
#include <GEOMBase.h>
2004-12-01 15:39:14 +05:00
2009-02-13 17:16:39 +05:00
#include <GEOMImpl_Types.hxx>
2004-12-01 15:39:14 +05:00
2009-02-13 17:16:39 +05:00
#include <SUIT_Desktop.h>
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
2012-08-09 13:58:02 +06:00
#include <SUIT_MessageBox.h>
2009-02-13 17:16:39 +05:00
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
2004-01-07 20:46:21 +05:00
2012-08-09 13:58:02 +06:00
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Shape.hxx>
2012-10-08 17:16:36 +06:00
// VSR 22/08/2012: issue 0021787: remove "Preview" button from BOP and Partition operations
// Comment next line to enable preview in Partition dialog box
#define NO_PREVIEW
2004-01-07 20:46:21 +05:00
//=================================================================================
// class : OperationGUI_PartitionDlg()
2012-08-09 13:58:02 +06:00
// purpose : Constructs a OperationGUI_PartitionDlg which is a child of 'parent', with the
2004-01-07 20:46:21 +05:00
// 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.
//=================================================================================
2009-02-13 17:16:39 +05:00
OperationGUI_PartitionDlg::OperationGUI_PartitionDlg( GeometryGUI* theGeometryGUI, QWidget* parent )
: GEOMBase_Skeleton( theGeometryGUI, parent, false )
2004-01-07 20:46:21 +05:00
{
SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
2009-02-13 17:16:39 +05:00
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" ) ) );
2004-01-07 20:46:21 +05:00
2009-02-13 17:16:39 +05:00
setWindowTitle( tr( "GEOM_PARTITION_TITLE" ) );
2004-01-07 20:46:21 +05:00
/***************************************************************/
2009-02-13 17:16:39 +05:00
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_PARTITION" ) );
mainFrame()->RadioButton1->setIcon( image0 );
mainFrame()->RadioButton2->setIcon( image1 );
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
mainFrame()->RadioButton3->close();
2004-01-07 20:46:21 +05:00
2004-12-01 15:39:14 +05:00
// Full partition (contains half-space partition)
2012-08-09 13:58:02 +06:00
GroupPoints = new DlgRef_2Sel1List2Check( centralWidget() );
2009-02-13 17:16:39 +05:00
GroupPoints->GroupBox1->setTitle( tr( "GEOM_PARTITION" ) );
GroupPoints->TextLabel1->setText( tr( "GEOM_OBJECTS" ) );
2012-08-09 13:58:02 +06:00
GroupPoints->TextLabel2->setText( tr( "GEOM_TOOL_OBJECTS" ) );
2009-02-13 17:16:39 +05:00
GroupPoints->TextLabel3->setText( tr( "GEOM_RECONSTRUCTION_LIMIT" ) );
GroupPoints->PushButton1->setIcon( image2 );
GroupPoints->PushButton2->setIcon( image2 );
2004-12-01 15:39:14 +05:00
GroupPoints->LineEdit1->setReadOnly( true );
GroupPoints->LineEdit2->setReadOnly( true );
2012-08-09 13:58:02 +06:00
GroupPoints->LineEdit1->setEnabled( true );
GroupPoints->LineEdit2->setEnabled( false );
2009-02-13 17:16:39 +05:00
GroupPoints->CheckButton1->setText( tr( "GEOM_KEEP_NONLIMIT_SHAPES" ) );
2012-08-09 13:58:02 +06:00
GroupPoints->CheckButton2->setText( tr( "GEOM_NO_SELF_INTERSECTION" ) );
2004-12-01 15:39:14 +05:00
mySelfInte = new QCheckBox(GroupPoints->GroupBox1);
mySelfInte->setText(tr("GEOM_CHECK_SELF_INTERSECTIONS"));
GroupPoints->gridLayout1->addWidget(mySelfInte, 5, 0, 1, 3);
2009-02-13 17:16:39 +05:00
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
layout->setMargin( 0 ); layout->setSpacing( 6 );
layout->addWidget( GroupPoints );
2009-02-13 17:16:39 +05:00
/***************************************************************/
2009-02-13 17:16:39 +05:00
setHelpFileName( "partition_page.html" );
2012-08-09 13:58:02 +06:00
2012-10-08 17:16:36 +06:00
#ifdef NO_PREVIEW
mainFrame()->CheckBoxPreview->setChecked( false );
mainFrame()->CheckBoxPreview->hide();
#endif
2004-01-07 20:46:21 +05:00
Init();
}
//=================================================================================
// function : ~OperationGUI_PartitionDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
OperationGUI_PartitionDlg::~OperationGUI_PartitionDlg()
{
// no need to delete child widgets, Qt does it all for us
}
2009-02-13 17:16:39 +05:00
void OperationGUI_PartitionDlg::SetListMaterials( GEOM::ListOfLong ListMaterials )
{
2012-08-09 13:58:02 +06:00
myListMaterials = ListMaterials;
2009-02-13 17:16:39 +05:00
}
2012-08-09 13:58:02 +06:00
2009-02-13 17:16:39 +05:00
GEOM::ListOfLong OperationGUI_PartitionDlg::GetListMaterials()
2012-08-09 13:58:02 +06:00
{
return myListMaterials;
2009-02-13 17:16:39 +05:00
}
2004-01-07 20:46:21 +05:00
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void OperationGUI_PartitionDlg::Init()
{
2012-08-09 13:58:02 +06:00
/* type for sub-shape selection */
2009-02-13 17:16:39 +05:00
GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_SOLID" ) );
2012-08-09 13:58:02 +06:00
GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::SOLID);
2009-02-13 17:16:39 +05:00
GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_SHELL" ) );
2012-08-09 13:58:02 +06:00
GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::SHELL);
2009-02-13 17:16:39 +05:00
GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_FACE" ) );
2012-08-09 13:58:02 +06:00
GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::FACE);
2009-02-13 17:16:39 +05:00
GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_WIRE" ) );
2012-08-09 13:58:02 +06:00
GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::WIRE);
2009-02-13 17:16:39 +05:00
GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_EDGE" ) );
2012-08-09 13:58:02 +06:00
GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::EDGE);
2009-02-13 17:16:39 +05:00
GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_VERTEX" ) );
2012-08-09 13:58:02 +06:00
GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::VERTEX);
2009-02-13 17:16:39 +05:00
GroupPoints->CheckButton1->setChecked( false );
mySelfInte->setChecked(false);
2012-08-09 13:58:02 +06:00
2009-02-13 17:16:39 +05:00
mainFrame()->GroupBoxPublish->show();
2004-01-07 20:46:21 +05:00
/* signals and slots connections */
2009-02-13 17:16:39 +05:00
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
2012-08-09 13:58:02 +06:00
2009-02-13 17:16:39 +05:00
connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
2012-08-09 13:58:02 +06:00
2009-02-13 17:16:39 +05:00
connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
2012-08-09 13:58:02 +06:00
2009-02-13 17:16:39 +05:00
connect( GroupPoints->ComboBox1, SIGNAL( activated( int ) ), this, SLOT( ComboTextChanged() ) );
2009-02-13 17:16:39 +05:00
connect( myGeomGUI->getApp()->selectionMgr(),
2012-08-09 13:58:02 +06:00
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
connect( GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(processPreview()) );
connect( GroupPoints->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(processPreview()) );
connect( GroupPoints->CheckButton2, SIGNAL(toggled(bool)), mySelfInte, SLOT(setEnabled(bool)) );
connect( mySelfInte, SIGNAL(toggled(bool)), this, SLOT(processPreview()) );
2012-08-09 13:58:02 +06:00
mySelfInte->setEnabled(GroupPoints->CheckButton2->isChecked());
2004-12-01 15:39:14 +05:00
initName( tr( "GEOM_PARTITION" ) );
2009-02-13 17:16:39 +05:00
2004-12-01 15:39:14 +05:00
ConstructorsClicked( 0 );
2009-02-13 17:16:39 +05:00
GroupPoints->PushButton1->click();
2004-12-01 15:39:14 +05:00
}
2004-01-07 20:46:21 +05:00
2004-12-01 15:39:14 +05:00
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
2009-02-13 17:16:39 +05:00
void OperationGUI_PartitionDlg::ConstructorsClicked( int constructorId )
2004-12-01 15:39:14 +05:00
{
2009-02-13 17:16:39 +05:00
disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
2004-12-01 15:39:14 +05:00
globalSelection();
2012-08-09 13:58:02 +06:00
//myListShapes.length( 0 );
//myListTools.length( 0 );
//myListKeepInside.length( 0 ); // obsolete
//myListRemoveInside.length( 0 ); // obsolete
//myListMaterials.length( 0 ); // obsolete
2009-02-13 17:16:39 +05:00
switch ( constructorId ) {
case 0: /*Full partition */
GroupPoints->GroupBox1->setTitle( tr( "GEOM_PARTITION" ) );
2012-08-09 13:58:02 +06:00
GroupPoints->TextLabel1->setText( tr( "GEOM_OBJECTS" ) );
GroupPoints->TextLabel2->setText( tr( "GEOM_TOOL_OBJECTS" ) );
2009-02-13 17:16:39 +05:00
GroupPoints->TextLabel3->show();
GroupPoints->ComboBox1->show();
GroupPoints->ComboBox1->setCurrentIndex( 0 );
GroupPoints->CheckButton1->show();
2012-08-09 13:58:02 +06:00
GroupPoints->CheckButton2->show();
mySelfInte->show();
2009-02-13 17:16:39 +05:00
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();
2012-08-09 13:58:02 +06:00
GroupPoints->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
2009-02-13 17:16:39 +05:00
GroupPoints->TextLabel2->setText( tr( "GEOM_PLANE" ) );
GroupPoints->CheckButton1->hide();
2012-08-09 13:58:02 +06:00
GroupPoints->CheckButton2->hide();
mySelfInte->hide();
2009-02-13 17:16:39 +05:00
GroupPoints->PushButton1->setDown( true );
GroupPoints->LineEdit1->setEnabled(true);
break;
2012-08-09 13:58:02 +06:00
}
2004-12-01 15:39:14 +05:00
myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->LineEdit1->clear();
GroupPoints->LineEdit2->clear();
2009-02-13 17:16:39 +05:00
qApp->processEvents();
updateGeometry();
resize( minimumSizeHint() );
2004-12-01 15:39:14 +05:00
myEditCurrentArgument->setFocus();
2012-08-09 13:58:02 +06:00
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
SelectionIntoArgument();
2004-01-07 20:46:21 +05:00
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void OperationGUI_PartitionDlg::ClickOnOk()
{
2012-08-09 13:58:02 +06:00
setIsApplyAndClose( true );
2004-12-01 15:39:14 +05:00
if ( ClickOnApply() )
ClickOnCancel();
2004-01-07 20:46:21 +05:00
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
2004-12-01 15:39:14 +05:00
bool OperationGUI_PartitionDlg::ClickOnApply()
2004-01-07 20:46:21 +05:00
{
2004-12-01 15:39:14 +05:00
if ( !onAccept() )
return false;
2012-08-09 13:58:02 +06:00
2004-12-01 15:39:14 +05:00
initName();
2012-08-09 13:58:02 +06:00
// 0020854: EDF 1398 GEOM: Ergonomy of Partition GUI window
// ConstructorsClicked( getConstructorId() );
2004-12-01 15:39:14 +05:00
return true;
}
2004-01-07 20:46:21 +05:00
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void OperationGUI_PartitionDlg::SelectionIntoArgument()
{
2004-12-01 15:39:14 +05:00
myEditCurrentArgument->setText( "" );
QString aString = "";
2012-08-09 13:58:02 +06:00
2009-02-13 17:16:39 +05:00
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true);
2012-08-09 13:58:02 +06:00
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;
}
2004-01-28 19:08:37 +05:00
}
2004-12-01 15:39:14 +05:00
}
2012-08-09 13:58:02 +06:00
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;
}
}
2004-01-07 20:46:21 +05:00
}
2012-08-09 13:58:02 +06:00
2009-02-13 17:16:39 +05:00
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
GEOMBase::ConvertListOfIOInListOfGO(aSelList, myListShapes, true);
2012-08-09 13:58:02 +06:00
//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 );
2004-12-01 15:39:14 +05:00
if ( !myListShapes.length() )
return;
2004-01-07 20:46:21 +05:00
}
2009-02-13 17:16:39 +05:00
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
GEOMBase::ConvertListOfIOInListOfGO(aSelList, myListTools, true);
2004-12-01 15:39:14 +05:00
if ( !myListTools.length() )
return;
2012-08-09 13:58:02 +06:00
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;
}
}
2004-01-07 20:46:21 +05:00
}
2012-08-09 13:58:02 +06:00
2004-12-01 15:39:14 +05:00
myEditCurrentArgument->setText( aString );
2012-08-09 13:58:02 +06:00
processPreview();
2004-01-07 20:46:21 +05:00
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void OperationGUI_PartitionDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
2012-08-09 13:58:02 +06:00
2009-02-13 17:16:39 +05:00
if ( send == GroupPoints->PushButton1 ) {
2004-01-07 20:46:21 +05:00
myEditCurrentArgument = GroupPoints->LineEdit1;
2009-02-13 17:16:39 +05:00
GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit1->setEnabled(true);
GroupPoints->LineEdit2->setEnabled(false);
}
else if ( send == GroupPoints->PushButton2 ) {
myGeomGUI->getApp()->selectionMgr()->clearSelected(); //clear prewious selection
2004-01-07 20:46:21 +05:00
myEditCurrentArgument = GroupPoints->LineEdit2;
2009-02-13 17:16:39 +05:00
GroupPoints->PushButton1->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
GroupPoints->LineEdit2->setEnabled(true);
if ( getConstructorId() == 1 )
2004-12-01 15:39:14 +05:00
globalSelection( GEOM_PLANE );
2004-01-07 20:46:21 +05:00
}
2012-08-09 13:58:02 +06:00
2004-12-01 15:39:14 +05:00
globalSelection( GEOM_ALLSHAPES );
2012-08-09 13:58:02 +06:00
2004-12-01 15:39:14 +05:00
myEditCurrentArgument->setFocus();
SelectionIntoArgument();
2009-02-13 17:16:39 +05:00
send->setDown(true);
2012-08-09 13:58:02 +06:00
processPreview();
2004-01-07 20:46:21 +05:00
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void OperationGUI_PartitionDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
2012-08-09 13:58:02 +06:00
if ( send == GroupPoints->LineEdit1 ||
2009-02-13 17:16:39 +05:00
send == GroupPoints->LineEdit2 ) {
2004-12-01 15:39:14 +05:00
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
2009-02-13 17:16:39 +05:00
}
2004-01-07 20:46:21 +05:00
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void OperationGUI_PartitionDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
2012-08-09 13:58:02 +06:00
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
2004-12-01 15:39:14 +05:00
2012-08-09 13:58:02 +06:00
ConstructorsClicked( getConstructorId() );
processPreview();
2004-12-01 15:39:14 +05:00
}
2004-01-07 20:46:21 +05:00
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
2009-02-13 17:16:39 +05:00
void OperationGUI_PartitionDlg::enterEvent( QEvent* )
2004-01-07 20:46:21 +05:00
{
2009-02-13 17:16:39 +05:00
if ( !mainFrame()->GroupConstructors->isEnabled() )
2004-12-01 15:39:14 +05:00
this->ActivateThisDialog();
}
//=================================================================================
// function : createOperation
// purpose :
//=================================================================================
GEOM::GEOM_IOperations_ptr OperationGUI_PartitionDlg::createOperation()
{
return getGeomEngine()->GetIBooleanOperations( getStudyId() );
}
//=================================================================================
// function : isValid
// purpose :
//=================================================================================
2012-08-09 13:58:02 +06:00
bool OperationGUI_PartitionDlg::isValid (QString& )
2004-12-01 15:39:14 +05:00
{
2012-08-09 13:58:02 +06:00
return (getConstructorId() == 0 ?
myListShapes.length() :
myListShapes.length() && myListTools.length());
2004-12-01 15:39:14 +05:00
}
//=================================================================================
// function : execute
// purpose :
//=================================================================================
2012-08-09 13:58:02 +06:00
bool OperationGUI_PartitionDlg::execute (ObjectList& objects)
2004-12-01 15:39:14 +05:00
{
bool res = false;
GEOM::GEOM_Object_var anObj;
2012-08-09 13:58:02 +06:00
GEOM::GEOM_IBooleanOperations_var anOper = GEOM::GEOM_IBooleanOperations::_narrow(getOperation());
switch ( getConstructorId() ) {
case 0:
{
bool isDetectSelfInte = mySelfInte->isChecked();
2012-08-09 13:58:02 +06:00
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,
isDetectSelfInte) :
2012-08-09 13:58:02 +06:00
anOper->MakePartition(myListShapes, myListTools,
myListKeepInside, myListRemoveInside,
aLimit, false, myListMaterials, aKeepNonlimitShapes);
2012-08-09 13:58:02 +06:00
res = true;
}
2012-08-09 13:58:02 +06:00
break;
case 1:
{
anObj = anOper->MakeHalfPartition(myListShapes[0].in(), myListTools[0].in());
2012-08-09 13:58:02 +06:00
res = true;
}
2012-08-09 13:58:02 +06:00
break;
}
2012-08-09 13:58:02 +06:00
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" ) );
}
2004-12-01 15:39:14 +05:00
return res;
}
//=================================================================================
2009-02-13 17:16:39 +05:00
// function : restoreSubShapes
2004-12-01 15:39:14 +05:00
// purpose :
//=================================================================================
2009-02-13 17:16:39 +05:00
void OperationGUI_PartitionDlg::restoreSubShapes( SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theSObject )
2004-12-01 15:39:14 +05:00
{
2009-02-13 17:16:39 +05:00
if ( mainFrame()->CheckBoxRestoreSS->isChecked() ) {
// empty list of arguments means that all arguments should be restored
getGeomEngine()->RestoreSubShapesSO( theStudy, theSObject, GEOM::ListOfGO(),
2012-08-09 13:58:02 +06:00
/*theFindMethod=*/GEOM::FSM_GetInPlaceByHistory,
/*theInheritFirstArg=*/myListShapes.length() == 1 && myListTools.length() == 0,
2012-08-09 13:58:02 +06:00
mainFrame()->CheckBoxAddPrefix->isChecked() ); // ? false
2009-02-13 17:16:39 +05:00
}
2004-01-07 20:46:21 +05:00
}
//=======================================================================
//function : ComboTextChanged
2012-08-09 13:58:02 +06:00
//purpose :
2004-01-07 20:46:21 +05:00
//=======================================================================
void OperationGUI_PartitionDlg::ComboTextChanged()
{
2009-02-13 17:16:39 +05:00
//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);
2012-08-09 13:58:02 +06:00
processPreview();
2004-12-01 15:39:14 +05:00
}
//=================================================================================
// function : GetLimit()
2012-08-09 13:58:02 +06:00
// purpose :
2004-12-01 15:39:14 +05:00
//=================================================================================
int OperationGUI_PartitionDlg::GetLimit() const
{
2009-02-13 17:16:39 +05:00
int aLimit = GroupPoints->ComboBox1->currentIndex();
2009-02-13 17:16:39 +05:00
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 ;
}
2004-12-01 15:39:14 +05:00
return aLimit;
2004-01-07 20:46:21 +05:00
}