-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012 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.
-//
+
#include "OperationGUI_PartitionDlg.h"
#include <DlgRef.h>
//=================================================================================
// 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.
/***************************************************************/
setHelpFileName( "partition_page.html" );
-
+
Init();
}
void OperationGUI_PartitionDlg::SetListMaterials( GEOM::ListOfLong ListMaterials )
{
- myListMaterials = ListMaterials;
+ myListMaterials = ListMaterials;
}
-
+
GEOM::ListOfLong OperationGUI_PartitionDlg::GetListMaterials()
-{
- return myListMaterials;
+{
+ return myListMaterials;
}
//=================================================================================
//=================================================================================
void OperationGUI_PartitionDlg::Init()
{
- /* type for sub shape selection */
+ /* 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->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_VERTEX" ) );
GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::VERTEX);
GroupPoints->CheckButton1->setChecked( false );
-
+
mainFrame()->GroupBoxPublish->show();
/* signals and slots connections */
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
-
+
connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
-
+
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 );
{
disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
globalSelection();
-
+
//myListShapes.length( 0 );
- //myListTools.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->PushButton1->setDown( true );
GroupPoints->LineEdit1->setEnabled(true);
break;
- }
+ }
myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->LineEdit1->clear();
resize( minimumSizeHint() );
myEditCurrentArgument->setFocus();
- connect( myGeomGUI->getApp()->selectionMgr(),
+ connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
SelectionIntoArgument();
}
//=================================================================================
void OperationGUI_PartitionDlg::ClickOnOk()
{
+ setIsApplyAndClose( true );
if ( ClickOnApply() )
ClickOnCancel();
}
{
if ( !onAccept() )
return false;
-
initName();
- // 0020854: EDF 1398 GEOM: Ergonomy of Partition GUI window
+ // 0020854: EDF 1398 GEOM: Ergonomy of Partition GUI window
// ConstructorsClicked( getConstructorId() );
return 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 ( 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() );
}
myEditCurrentArgument->setText( aString );
+ processPreview();
}
void OperationGUI_PartitionDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
-
+
if ( send == GroupPoints->PushButton1 ) {
myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->PushButton2->setDown(false);
if ( getConstructorId() == 1 )
globalSelection( GEOM_PLANE );
}
-
+
globalSelection( GEOM_ALLSHAPES );
-
+
myEditCurrentArgument->setFocus();
SelectionIntoArgument();
send->setDown(true);
+ processPreview();
}
{
QLineEdit* send = (QLineEdit*)sender();
- if ( send == GroupPoints->LineEdit1 ||
+ if ( send == GroupPoints->LineEdit1 ||
send == GroupPoints->LineEdit2 ) {
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
void OperationGUI_PartitionDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
- connect( myGeomGUI->getApp()->selectionMgr(),
+ connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
- ConstructorsClicked( getConstructorId() );
+ ConstructorsClicked( getConstructorId() );
+ processPreview();
}
// function : isValid
// purpose :
//=================================================================================
-bool OperationGUI_PartitionDlg::isValid( QString& )
+bool OperationGUI_PartitionDlg::isValid (QString& )
{
- return ( myListShapes.length() || myListTools.length() ); // || myListKeepInside.length() || myListRemoveInside.length() // obsolete
+ return (getConstructorId() == 0 ?
+ myListShapes.length() :
+ myListShapes.length() && myListTools.length());
}
// function : execute
// purpose :
//=================================================================================
-bool OperationGUI_PartitionDlg::execute( ObjectList& objects )
+bool OperationGUI_PartitionDlg::execute (ObjectList& objects)
{
bool res = false;
GEOM::GEOM_Object_var anObj;
- int aLimit = GetLimit();
- int aKeepNonlimitShapes = GroupPoints->CheckButton1->isChecked();
- bool aNoSelfIntersection = GroupPoints->CheckButton2->isChecked();
-
- GEOM::GEOM_IBooleanOperations_var anOper = GEOM::GEOM_IBooleanOperations::_narrow( getOperation() );
+ 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;
+ {
+ 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;
+ {
+ anObj = anOper->MakeHalfPartition( myListShapes[0].in(), myListTools[0].in() );
+ res = true;
+ }
break;
}
GEOMBase::GetShape( anObj, aShape, TopAbs_SHAPE );
TopoDS_Iterator It( aShape, Standard_True, Standard_True );
int nbSubshapes = 0;
- for ( ; It.More(); It.Next() )
+ for (; It.More(); It.Next())
nbSubshapes++;
if ( nbSubshapes )
QObject::tr( "GEOM_ERROR" ),
QObject::tr( "GEOM_WRN_PARTITION_RESULT_EMPTY" ) );
}
-
+
return res;
}
//=======================================================================
//function : ComboTextChanged
-//purpose :
+//purpose :
//=======================================================================
void OperationGUI_PartitionDlg::ComboTextChanged()
{
//GroupPoints->TextLabel5->setEnabled(IsEnabled);
//GroupPoints->PushButton3->setEnabled(IsEnabled);
//GroupPoints->PushButton4->setEnabled(IsEnabled);
+ processPreview();
}
//=================================================================================
// function : GetLimit()
-// purpose :
+// purpose :
//=================================================================================
int OperationGUI_PartitionDlg::GetLimit() const
{