2009-02-13 17:16:39 +05:00
|
|
|
// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
|
2004-01-07 20:46:21 +05:00
|
|
|
//
|
2009-02-13 17:16:39 +05: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
|
|
|
//
|
2009-02-13 17:16:39 +05: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
|
|
|
|
// version 2.1 of the License.
|
2004-01-07 20:46:21 +05:00
|
|
|
//
|
2009-02-13 17:16:39 +05: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.
|
|
|
|
//
|
|
|
|
// 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 : EntityGUI_SubShapeDlg.cxx
|
|
|
|
// Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
|
2004-01-07 20:46:21 +05:00
|
|
|
//
|
|
|
|
#include "EntityGUI_SubShapeDlg.h"
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
#include <DlgRef.h>
|
|
|
|
#include <GeometryGUI.h>
|
|
|
|
#include <GEOMBase.h>
|
|
|
|
|
|
|
|
#include <SUIT_Desktop.h>
|
|
|
|
#include <SUIT_ResourceMgr.h>
|
|
|
|
#include <SUIT_Session.h>
|
|
|
|
#include <SUIT_ViewManager.h>
|
|
|
|
#include <SUIT_ViewWindow.h>
|
|
|
|
#include <OCCViewer_ViewModel.h>
|
|
|
|
#include <SalomeApp_Application.h>
|
|
|
|
#include <LightApp_SelectionMgr.h>
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
#include <TColStd_IndexedMapOfInteger.hxx>
|
|
|
|
#include <TopoDS_Iterator.hxx>
|
2004-01-07 20:46:21 +05:00
|
|
|
#include <TopExp_Explorer.hxx>
|
|
|
|
#include <TopTools_MapOfShape.hxx>
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
#include <QMessageBox>
|
2004-01-07 20:46:21 +05:00
|
|
|
|
|
|
|
//=================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
// class : EntityGUI_SubShapeDlg
|
2004-01-07 20:46:21 +05:00
|
|
|
// purpose : Constructs a EntityGUI_SubShapeDlg 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.
|
|
|
|
//=================================================================================
|
2009-02-13 17:16:39 +05:00
|
|
|
EntityGUI_SubShapeDlg::EntityGUI_SubShapeDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
|
|
|
|
bool modal, Qt::WindowFlags fl )
|
|
|
|
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
2009-02-13 17:16:39 +05:00
|
|
|
QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_SUBSHAPE" ) ) );
|
|
|
|
QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
setWindowTitle( tr( "GEOM_SUBSHAPE_TITLE" ) );
|
2004-01-07 20:46:21 +05:00
|
|
|
|
|
|
|
/***************************************************************/
|
2009-02-13 17:16:39 +05:00
|
|
|
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_SUB_SHAPE" ) );
|
|
|
|
mainFrame()->RadioButton1->setIcon( image0 );
|
|
|
|
mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose );
|
|
|
|
mainFrame()->RadioButton2->close();
|
|
|
|
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
|
|
|
|
mainFrame()->RadioButton3->close();
|
|
|
|
|
|
|
|
GroupPoints = new DlgRef_1Sel1Check1List( centralWidget() );
|
|
|
|
|
|
|
|
GroupPoints->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) );
|
|
|
|
GroupPoints->TextLabel1->setText( tr( "GEOM_MAIN_OBJECT" ) );
|
|
|
|
GroupPoints->TextLabel2->setText( tr( "GEOM_SUBSHAPE_TYPE" ) );
|
|
|
|
GroupPoints->CheckButton1->setText( tr( "GEOM_SUBSHAPE_SELECT" ) );
|
|
|
|
GroupPoints->PushButton1->setIcon( image1 );
|
2004-12-01 15:39:14 +05:00
|
|
|
GroupPoints->LineEdit1->setReadOnly( true );
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
|
|
|
|
layout->setMargin( 0 ); layout->setSpacing( 6 );
|
|
|
|
layout->addWidget( GroupPoints );
|
2004-01-07 20:46:21 +05:00
|
|
|
/***************************************************************/
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
setHelpFileName( "create_explode_page.html" );
|
|
|
|
|
|
|
|
mainFrame()->GroupBoxName->hide();
|
2006-05-06 14:44:32 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
Init();
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ~EntityGUI_SubShapeDlg()
|
|
|
|
// purpose : Destroys the object and frees any allocated resources
|
|
|
|
//=================================================================================
|
|
|
|
EntityGUI_SubShapeDlg::~EntityGUI_SubShapeDlg()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : Init()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
void EntityGUI_SubShapeDlg::Init()
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
|
|
|
/* init variables */
|
|
|
|
myEditCurrentArgument = GroupPoints->LineEdit1;
|
2004-12-01 15:39:14 +05:00
|
|
|
myObject = GEOM::GEOM_Object::_nil();
|
2004-01-07 20:46:21 +05:00
|
|
|
|
|
|
|
myWithShape = true;
|
|
|
|
|
|
|
|
/* type for sub shape selection */
|
2009-02-13 17:16:39 +05:00
|
|
|
GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Compound" );
|
|
|
|
GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Compsolid" );
|
|
|
|
GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Solid" );
|
|
|
|
GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Shell" );
|
|
|
|
GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Face" );
|
|
|
|
GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Wire" );
|
|
|
|
GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Edge" );
|
|
|
|
GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Vertex" );
|
|
|
|
GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Shape" );
|
|
|
|
|
|
|
|
if ( SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType()
|
|
|
|
!= OCCViewer_Viewer::Type() )
|
|
|
|
GroupPoints->CheckButton1->setEnabled( false );
|
2004-01-07 20:46:21 +05:00
|
|
|
|
|
|
|
/* signals and slots connections */
|
2009-02-13 17:16:39 +05:00
|
|
|
connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
|
|
|
|
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
|
|
|
|
connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
connect( GroupPoints->ComboBox1, SIGNAL( activated( int ) ), this, SLOT( ComboTextChanged() ) );
|
|
|
|
connect( GroupPoints->CheckButton1, SIGNAL( stateChanged( int ) ), this, SLOT( SubShapeToggled() ) );
|
2006-05-06 14:44:32 +06:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
connect( myGeomGUI->getApp()->selectionMgr(),
|
|
|
|
SIGNAL( currentSelectionChanged( )), this, SLOT( SelectionIntoArgument() ) );
|
2006-05-06 14:44:32 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
updateButtonState();
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
SelectionIntoArgument();
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnOk()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SubShapeDlg::ClickOnOk()
|
|
|
|
{
|
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 EntityGUI_SubShapeDlg::ClickOnApply()
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
2009-02-13 17:16:39 +05:00
|
|
|
SUIT_Session::session()->activeApplication()->putInfo( "" );
|
|
|
|
|
2004-01-07 20:46:21 +05:00
|
|
|
/* Explode all sub shapes */
|
2009-02-13 17:16:39 +05:00
|
|
|
if ( isAllSubShapes() ) {
|
2004-01-07 20:46:21 +05:00
|
|
|
/* More than 30 subshapes : ask confirmation */
|
2009-02-13 17:16:39 +05:00
|
|
|
unsigned int nb = NumberOfSubShapes( myShape, shapeType() );
|
|
|
|
if ( nb > 30 ) {
|
|
|
|
const QString caption = tr( "GEOM_CONFIRM" );
|
|
|
|
const QString text = tr( "GEOM_CONFIRM_INFO" ).arg( nb );
|
|
|
|
const QString button0 = tr( "GEOM_BUT_EXPLODE" );
|
|
|
|
const QString button1 = tr( "GEOM_BUT_CANCEL" );
|
|
|
|
|
|
|
|
if ( QMessageBox::warning( this, caption, text, button0, button1 ) != 0 )
|
2004-12-01 15:39:14 +05:00
|
|
|
return false; /* aborted */
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
bool isOk = onAccept();
|
|
|
|
|
|
|
|
// restore selection, corresponding to current selection mode
|
|
|
|
SubShapeToggled();
|
|
|
|
|
|
|
|
return isOk;
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : SelectionIntoArgument()
|
|
|
|
// purpose : Called when selection as changed or other case
|
|
|
|
// : used only by SelectButtonC1A1 (LineEditC1A1)
|
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SubShapeDlg::SelectionIntoArgument()
|
|
|
|
{
|
2009-02-13 17:16:39 +05:00
|
|
|
if (!isAllSubShapes())
|
2004-12-01 15:39:14 +05:00
|
|
|
return;
|
|
|
|
|
|
|
|
ResetStateOfDialog();
|
|
|
|
|
2004-01-07 20:46:21 +05:00
|
|
|
QString aString = ""; /* name of selection */
|
|
|
|
|
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);
|
|
|
|
if (nbSel != 1)
|
2004-01-07 20:46:21 +05:00
|
|
|
return;
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2004-01-07 20:46:21 +05:00
|
|
|
TopoDS_Shape S;
|
2009-02-13 17:16:39 +05:00
|
|
|
Handle(SALOME_InteractiveObject) IO = aSelList.First();
|
|
|
|
if ( !IO->hasEntry() ) {
|
2005-06-02 13:17:09 +06:00
|
|
|
SUIT_Session::session()->activeApplication()->putInfo( tr( "GEOM_PRP_SHAPE_IN_STUDY" ) );
|
2004-12-01 15:39:14 +05:00
|
|
|
updateButtonState();
|
2004-01-07 20:46:21 +05:00
|
|
|
return;
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
if (!GEOMBase::GetTopoFromSelection(aSelList, S) ||
|
|
|
|
S.IsNull() ||
|
|
|
|
S.ShapeType() == TopAbs_VERTEX) {
|
|
|
|
myObject = GEOM::GEOM_Object::_nil();
|
2004-12-01 15:39:14 +05:00
|
|
|
updateButtonState();
|
2004-01-07 20:46:21 +05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
Standard_Boolean testResult;
|
2009-02-13 17:16:39 +05:00
|
|
|
myObject = GEOMBase::ConvertIOinGEOMObject(IO, testResult);
|
|
|
|
if (!testResult || myObject->_is_nil()) {
|
2004-12-01 15:39:14 +05:00
|
|
|
updateButtonState();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
myShape = S;
|
2009-02-13 17:16:39 +05:00
|
|
|
GroupPoints->LineEdit1->setText(aString);
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
int SelectedShapeType = GroupPoints->ComboBox1->currentIndex();
|
2004-12-01 15:39:14 +05:00
|
|
|
int count = GroupPoints->ComboBox1->count();
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
if (myWithShape)
|
2004-12-01 15:39:14 +05:00
|
|
|
count = count - 1;
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
int i = 0;
|
|
|
|
// Solving PAL5590
|
2009-02-13 17:16:39 +05:00
|
|
|
if (myShape.ShapeType() == TopAbs_COMPOUND) {
|
2004-12-01 15:39:14 +05:00
|
|
|
unsigned int nb = NumberOfSubShapes(myShape, TopAbs_COMPOUND);
|
2009-02-13 17:16:39 +05:00
|
|
|
if ( nb > 0 )
|
2004-01-07 20:46:21 +05:00
|
|
|
i++;
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
while (i <= myShape.ShapeType()) {
|
|
|
|
GroupPoints->ComboBox1->removeItem(0);
|
2004-12-01 15:39:14 +05:00
|
|
|
i++;
|
|
|
|
}
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
if (myShape.ShapeType() == TopAbs_COMPOUND) {
|
|
|
|
if (myWithShape == false) {
|
|
|
|
GroupPoints->ComboBox1->insertItem(GroupPoints->ComboBox1->count(), "Shape");
|
2004-12-01 15:39:14 +05:00
|
|
|
myWithShape = true;
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
else {
|
|
|
|
if ( myWithShape == true ) {
|
2004-12-01 15:39:14 +05:00
|
|
|
GroupPoints->ComboBox1->removeItem( GroupPoints->ComboBox1->count() - 1 );
|
|
|
|
myWithShape = false;
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
int count1 = GroupPoints->ComboBox1->count();
|
|
|
|
if ( myWithShape )
|
|
|
|
count1 = count1 - 1;
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
if ( SelectedShapeType > myShape.ShapeType() ) {
|
|
|
|
if ( SelectedShapeType == 8 ) {
|
|
|
|
if ( myShape.ShapeType() != TopAbs_COMPOUND ) {
|
|
|
|
GroupPoints->ComboBox1->setCurrentIndex( 0 );
|
2004-12-01 15:39:14 +05:00
|
|
|
ComboTextChanged();
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
else
|
2009-02-13 17:16:39 +05:00
|
|
|
GroupPoints->ComboBox1->setCurrentIndex( count1 - count + SelectedShapeType );
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
else {
|
|
|
|
GroupPoints->ComboBox1->setCurrentIndex( 0 );
|
2004-12-01 15:39:14 +05:00
|
|
|
ComboTextChanged();
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
updateButtonState();
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : SetEditCurrentArgument()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SubShapeDlg::SetEditCurrentArgument()
|
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
GroupPoints->LineEdit1->setFocus();
|
|
|
|
myEditCurrentArgument = GroupPoints->LineEdit1;
|
2009-02-13 17:16:39 +05:00
|
|
|
|
|
|
|
GroupPoints->CheckButton1->setChecked( false );
|
2004-12-01 15:39:14 +05:00
|
|
|
SubShapeToggled();
|
|
|
|
SelectionIntoArgument();
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : LineEditReturnPressed()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SubShapeDlg::LineEditReturnPressed()
|
2009-02-13 17:16:39 +05:00
|
|
|
{
|
2004-01-07 20:46:21 +05:00
|
|
|
QLineEdit* send = (QLineEdit*)sender();
|
2009-02-13 17:16:39 +05:00
|
|
|
if ( send == GroupPoints->LineEdit1 )
|
2004-12-01 15:39:14 +05:00
|
|
|
SetEditCurrentArgument();
|
2004-01-07 20:46:21 +05:00
|
|
|
else
|
|
|
|
return;
|
|
|
|
|
|
|
|
GEOMBase_Skeleton::LineEditReturnPressed();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : DeactivateActiveDialog()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SubShapeDlg::DeactivateActiveDialog()
|
|
|
|
{
|
2009-02-13 17:16:39 +05:00
|
|
|
if ( mainFrame()->GroupConstructors->isEnabled() ) {
|
2004-01-07 20:46:21 +05:00
|
|
|
GEOMBase_Skeleton::DeactivateActiveDialog();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ActivateThisDialog()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SubShapeDlg::ActivateThisDialog()
|
|
|
|
{
|
|
|
|
GEOMBase_Skeleton::ActivateThisDialog();
|
2009-02-13 17:16:39 +05:00
|
|
|
connect( myGeomGUI->getApp()->selectionMgr(),
|
|
|
|
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
|
2004-12-01 15:39:14 +05:00
|
|
|
SubShapeToggled();
|
|
|
|
updateButtonState();
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : enterEvent()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2009-02-13 17:16:39 +05:00
|
|
|
void EntityGUI_SubShapeDlg::enterEvent( QEvent* )
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
2009-02-13 17:16:39 +05:00
|
|
|
if ( !mainFrame()->GroupConstructors->isEnabled() )
|
2006-05-06 14:44:32 +06:00
|
|
|
ActivateThisDialog();
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ResetStateOfDialog()
|
|
|
|
// purpose : Completely reset the state of method including local context
|
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SubShapeDlg::ResetStateOfDialog()
|
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
myObject = GEOM::GEOM_Object::_nil();
|
|
|
|
myShape.Nullify();
|
2009-02-13 17:16:39 +05:00
|
|
|
myEditCurrentArgument->setText( "" );
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
int SelectedShapeType = GroupPoints->ComboBox1->currentIndex();
|
2004-01-07 20:46:21 +05:00
|
|
|
int count = GroupPoints->ComboBox1->count();
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( myWithShape )
|
2004-01-07 20:46:21 +05:00
|
|
|
count = count - 1;
|
|
|
|
|
|
|
|
/* type for sub shape selection */
|
|
|
|
GroupPoints->ComboBox1->clear();
|
2009-02-13 17:16:39 +05:00
|
|
|
GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Compound" );
|
|
|
|
GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Compsolid" );
|
|
|
|
GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Solid" );
|
|
|
|
GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Shell" );
|
|
|
|
GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Face" );
|
|
|
|
GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Wire" );
|
|
|
|
GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Edge" );
|
|
|
|
GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Vertex" );
|
|
|
|
GroupPoints->ComboBox1->insertItem( GroupPoints->ComboBox1->count(), "Shape" );
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
myWithShape = true;
|
2009-02-13 17:16:39 +05:00
|
|
|
|
|
|
|
GroupPoints->ComboBox1->setCurrentIndex( 8 - count + SelectedShapeType );
|
2004-12-01 15:39:14 +05:00
|
|
|
ComboTextChanged();
|
|
|
|
|
|
|
|
updateButtonState();
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
// function : SubShapeToggled()
|
2004-01-07 20:46:21 +05:00
|
|
|
// purpose : Allow user selection of all or only selected sub shapes
|
|
|
|
// : Called when 'CheckButton1' state change
|
|
|
|
//=================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
void EntityGUI_SubShapeDlg::SubShapeToggled()
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
2008-03-07 12:45:34 +05:00
|
|
|
globalSelection( GEOM_ALLSHAPES );
|
|
|
|
|
|
|
|
if ( !isAllSubShapes() )
|
2004-12-01 15:39:14 +05:00
|
|
|
localSelection( myObject, shapeType() );
|
|
|
|
}
|
2004-01-07 20:46:21 +05:00
|
|
|
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
//=================================================================================
|
|
|
|
// function : ComboTextChanged()
|
2009-02-13 17:16:39 +05:00
|
|
|
// purpose :
|
2004-12-01 15:39:14 +05:00
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SubShapeDlg::ComboTextChanged()
|
|
|
|
{
|
|
|
|
/* Select sub shapes mode not checked */
|
|
|
|
updateButtonState();
|
2009-02-13 17:16:39 +05:00
|
|
|
SubShapeToggled();
|
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 : NumberOfSubShapes()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2009-02-13 17:16:39 +05:00
|
|
|
unsigned int EntityGUI_SubShapeDlg::NumberOfSubShapes( const TopoDS_Shape& S,
|
|
|
|
const int shapeType ) const
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
2009-02-13 17:16:39 +05:00
|
|
|
if ( S.IsNull() )
|
2004-12-01 15:39:14 +05:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
unsigned int index = 0;
|
|
|
|
TopTools_MapOfShape M;
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
if ( S.ShapeType() == TopAbs_COMPOUND &&
|
|
|
|
( TopAbs_ShapeEnum(shapeType) == TopAbs_SHAPE ||
|
|
|
|
TopAbs_ShapeEnum(shapeType) == TopAbs_COMPSOLID ||
|
|
|
|
TopAbs_ShapeEnum(shapeType) == TopAbs_COMPOUND ) ) {
|
|
|
|
TopoDS_Iterator It( S, Standard_True, Standard_True );
|
|
|
|
for ( ; It.More(); It.Next() ) {
|
|
|
|
if ( M.Add( It.Value() ) ) {
|
|
|
|
if ( TopAbs_ShapeEnum( shapeType ) == TopAbs_SHAPE ||
|
|
|
|
TopAbs_ShapeEnum( shapeType ) == It.Value().ShapeType() ) {
|
2004-12-01 15:39:14 +05:00
|
|
|
index++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
TopExp_Explorer Exp ( S, TopAbs_ShapeEnum( shapeType ) );
|
|
|
|
for ( ; Exp.More(); Exp.Next() ) {
|
|
|
|
if ( M.Add( Exp.Current() ) ) {
|
2004-12-01 15:39:14 +05:00
|
|
|
index++;
|
|
|
|
}
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
M.Clear();
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : updateButtonState
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SubShapeDlg::updateButtonState()
|
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
if ( SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType() != OCCViewer_Viewer::Type() ||
|
2004-12-01 15:39:14 +05:00
|
|
|
myObject->_is_nil() || shapeType() == TopAbs_SHAPE || shapeType() == TopAbs_COMPOUND ) {
|
2009-02-13 17:16:39 +05:00
|
|
|
GroupPoints->CheckButton1->setChecked( false );
|
|
|
|
GroupPoints->CheckButton1->setEnabled( false );
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else
|
2009-02-13 17:16:39 +05:00
|
|
|
GroupPoints->CheckButton1->setEnabled( true );
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
//=================================================================================
|
|
|
|
// function : isAllSubShapes
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
bool EntityGUI_SubShapeDlg::isAllSubShapes() const
|
|
|
|
{
|
|
|
|
return !GroupPoints->CheckButton1->isChecked() || !GroupPoints->CheckButton1->isEnabled();
|
|
|
|
}
|
2004-01-07 20:46:21 +05:00
|
|
|
|
|
|
|
//=================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
// function : shapeType
|
|
|
|
// purpose :
|
2004-01-07 20:46:21 +05:00
|
|
|
//=================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
int EntityGUI_SubShapeDlg::shapeType() const
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
2009-02-13 17:16:39 +05:00
|
|
|
int type = GroupPoints->ComboBox1->currentIndex();
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
if ( myObject->_is_nil() )
|
2004-12-01 15:39:14 +05:00
|
|
|
return type;
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
// Solving PAL5590
|
|
|
|
type += myShape.ShapeType() + 1;
|
2009-02-13 17:16:39 +05:00
|
|
|
if ( myShape.ShapeType() == TopAbs_COMPOUND &&
|
|
|
|
NumberOfSubShapes( myShape, TopAbs_COMPOUND ) > 0 ) {
|
2004-12-01 15:39:14 +05:00
|
|
|
type--;
|
|
|
|
}
|
|
|
|
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : createOperation
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
GEOM::GEOM_IOperations_ptr EntityGUI_SubShapeDlg::createOperation()
|
|
|
|
{
|
|
|
|
return getGeomEngine()->GetIShapesOperations( getStudyId() );
|
|
|
|
}
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
//=================================================================================
|
|
|
|
// function : isValid
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2009-02-13 17:16:39 +05:00
|
|
|
bool EntityGUI_SubShapeDlg::isValid (QString& msg)
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
|
|
|
bool isOk = false;
|
2009-02-13 17:16:39 +05:00
|
|
|
|
|
|
|
if (myObject->_is_nil()) {
|
2008-03-07 12:45:34 +05:00
|
|
|
updateButtonState();
|
|
|
|
return isOk;
|
|
|
|
}
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
if (isAllSubShapes())
|
|
|
|
isOk = true;
|
|
|
|
else {
|
|
|
|
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
|
|
|
|
SALOME_ListIO aSelList;
|
|
|
|
aSelMgr->selectedObjects(aSelList);
|
|
|
|
|
|
|
|
if (aSelList.Extent() == 1) {
|
|
|
|
Standard_Boolean testResult;
|
|
|
|
GEOM::GEOM_Object_var anObj = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
|
|
|
|
if (testResult && !anObj->_is_nil()) {
|
|
|
|
TColStd_IndexedMapOfInteger aMapIndex;
|
|
|
|
aSelMgr->GetIndexes(aSelList.First(), aMapIndex);
|
|
|
|
isOk = aMapIndex.Extent() > 0;
|
|
|
|
if (!isOk)
|
|
|
|
msg += tr("NO_SUBSHAPES_SELECTED");
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
return isOk;
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
// function : execute
|
2004-01-07 20:46:21 +05:00
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2009-02-13 17:16:39 +05:00
|
|
|
bool EntityGUI_SubShapeDlg::execute (ObjectList& objects)
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
2009-02-13 17:16:39 +05:00
|
|
|
GEOM::ListOfGO_var aList = GEOM::GEOM_IShapesOperations::_narrow(getOperation())->
|
|
|
|
MakeExplode(myObject, shapeType(), true);
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
if (!aList->length())
|
2004-12-01 15:39:14 +05:00
|
|
|
return false;
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
// Throw away sub-shapes not selected by user if not in preview mode
|
2004-12-01 15:39:14 +05:00
|
|
|
// and manual selection is active
|
2009-02-13 17:16:39 +05:00
|
|
|
if (!isAllSubShapes()) {
|
|
|
|
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
|
|
|
|
SALOME_ListIO aSelList;
|
|
|
|
aSelMgr->selectedObjects(aSelList);
|
|
|
|
|
|
|
|
if (aSelList.Extent() == 1) {
|
2004-12-01 15:39:14 +05:00
|
|
|
Standard_Boolean aResult = Standard_False;
|
|
|
|
GEOM::GEOM_Object_var anObj =
|
2009-02-13 17:16:39 +05:00
|
|
|
GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult);
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
if (aResult && !anObj->_is_nil()) {
|
2004-12-01 15:39:14 +05:00
|
|
|
TColStd_IndexedMapOfInteger aMapIndex;
|
2009-02-13 17:16:39 +05:00
|
|
|
aSelMgr->GetIndexes(aSelList.First(), aMapIndex);
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
GEOM::GEOM_ILocalOperations_var aLocOp =
|
|
|
|
getGeomEngine()->GetILocalOperations(getStudyId());
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
for (int i = 0, n = aList->length(); i < n; i++)
|
|
|
|
if (aMapIndex.Contains(aLocOp->GetSubShapeIndex(myObject, aList[i])))
|
|
|
|
objects.push_back(GEOM::GEOM_Object::_duplicate(aList[i]));
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
}
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else
|
2009-02-13 17:16:39 +05:00
|
|
|
for (int i = 0, n = aList->length(); i < n; i++)
|
|
|
|
objects.push_back(GEOM::GEOM_Object::_duplicate(aList[i]));
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
return objects.size();
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
//================================================================
|
|
|
|
// Function : getFather
|
|
|
|
// Purpose : Get father object for object to be added in study
|
|
|
|
// ( called with addInStudy method )
|
|
|
|
//================================================================
|
|
|
|
GEOM::GEOM_Object_ptr EntityGUI_SubShapeDlg::getFather( GEOM::GEOM_Object_ptr )
|
|
|
|
{
|
|
|
|
return myObject;
|
|
|
|
}
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
QString EntityGUI_SubShapeDlg::getNewObjectName() const
|
2005-06-03 16:39:50 +06:00
|
|
|
{
|
2009-02-13 17:16:39 +05:00
|
|
|
return QString::null;
|
2005-06-03 16:39:50 +06:00
|
|
|
}
|