-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2013 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
#include "SMESHGUI.h"
#include "SMESHGUI_Utils.h"
+#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_VTKUtils.h"
#include <SMESH_TypeFilter.hxx>
#include <QKeyEvent>
#include <utilities.h>
+#include <SALOMEDSClient_SObject.hxx>
// IDL includes
#include <SALOMEconfig.h>
SUIT_ResourceMgr* aResMgr = SMESH::GetResourceMgr( mySMESHGUI );
QPixmap iconWithoutElem (aResMgr->loadPixmap("SMESH", tr("ICON_SMESH_DUPLICATE_NODES")));
QPixmap iconWithElem (aResMgr->loadPixmap("SMESH", tr("ICON_SMESH_DUPLICATE_NODES_WITH_ELEM")));
+ QPixmap iconElemOnly (aResMgr->loadPixmap("SMESH", tr("ICON_SMESH_DUPLICATE_ELEM_ONLY")));
QPixmap iconSelect (aResMgr->loadPixmap("SMESH", tr("ICON_SELECT")));
// Main layout
aRadioButton1->setIcon(iconWithoutElem);
QRadioButton* aRadioButton2 = new QRadioButton(aConstructorsBox);
aRadioButton2->setIcon(iconWithElem);
+ QRadioButton* aRadioButton3 = new QRadioButton(aConstructorsBox);
+ aRadioButton3->setIcon(iconElemOnly);
aConstructorsBoxLayout->addWidget(aRadioButton1);
aConstructorsBoxLayout->addWidget(aRadioButton2);
+ aConstructorsBoxLayout->addWidget(aRadioButton3);
myGroupConstructors->addButton(aRadioButton1, 0);
myGroupConstructors->addButton(aRadioButton2, 1);
+ myGroupConstructors->addButton(aRadioButton3, 2);
// Arguments
myGroupArguments = new QGroupBox(this);
aMainLayout->addWidget(myGroupArguments);
aMainLayout->addWidget(aGroupButtons);
+ myCheckBoxNewElemGroup->setChecked(true);
+ myCheckBoxNewNodeGroup->setChecked(true);
+
// Initialize the dialog
Init();
connect(mySelectButton3, SIGNAL (clicked()), this, SLOT(onEditCurrentArgument()));
connect(myButtonOk, SIGNAL(clicked()), this, SLOT(onOk()));
- connect(myButtonClose, SIGNAL(clicked()), this, SLOT(onClose()));
+ connect(myButtonClose, SIGNAL(clicked()), this, SLOT(reject()));
connect(myButtonApply, SIGNAL(clicked()), this, SLOT(onApply()));
connect(myButtonHelp, SIGNAL(clicked()), this, SLOT(onHelp()));
connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionChanged()));
connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(onDeactivate()));
- connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(onClose()));
+ connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(reject()));
}
/*!
void SMESHGUI_DuplicateNodesDlg::Init()
{
mySMESHGUI->SetActiveDialogBox((QDialog*)this);
- myCheckBoxNewElemGroup->setChecked(true);
- myCheckBoxNewNodeGroup->setChecked(true);
// Set initial parameters
myBusy = false;
myGroups3.clear();
// Set selection mode
- mySelectionMgr->installFilter(new SMESH_TypeFilter(GROUP));
+ mySelectionMgr->installFilter(new SMESH_TypeFilter(SMESH::GROUP));
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(ActorSelection);
myCheckBoxNewNodeGroup->show();
// Hide the third field
+ myTextLabel2->show();
+ mySelectButton2->show();
+ myLineEdit2->show();
myTextLabel3->hide();
mySelectButton3->hide();
myLineEdit3->hide();
myCheckBoxNewNodeGroup->show();
// Show the third field
+ myTextLabel2->show();
+ mySelectButton2->show();
+ myLineEdit2->show();
myTextLabel3->show();
mySelectButton3->show();
myLineEdit3->show();
+ break;
+ }
+ case 2:
+ {
+ // Set text to the group of arguments and to all the labels
+ myGroupArguments->setTitle(tr("DUPLICATION_ONLY_ELEMS"));
+ myTextLabel1->setText(tr("GROUP_ELEMS_TO_DUPLICATE"));
+
+ myCheckBoxNewElemGroup->show();
+ myCheckBoxNewNodeGroup->hide();
+
+ // Hide the second and the third field
+ myTextLabel2->hide();
+ mySelectButton2->hide();
+ myLineEdit2->hide();
+ myTextLabel3->hide();
+ mySelectButton3->hide();
+ myLineEdit3->hide();
+
break;
}
}
bool toCreateElemGroup = myCheckBoxNewElemGroup->isChecked();
bool toCreateNodeGroup = myCheckBoxNewNodeGroup->isChecked();
- int operationMode = myGroupConstructors->checkedId();
+ int operationMode = myGroupConstructors->checkedId();
// Apply changes
bool result = false;
SUIT_OverrideCursor aWaitCursor;
+ QStringList anEntryList;
try {
SMESH::SMESH_Mesh_var aMesh = myGroups1[0]->GetMesh();
SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
- if ( operationMode == 0 ) {
+ switch ( operationMode ) {
+ case 0:
+ {
SMESH::ListOfGroups_var g1 = new SMESH::ListOfGroups();
g1->length( myGroups1.count() );
for ( int i = 0; i < myGroups1.count(); i++ )
else {
result = aMeshEditor->DoubleNodeGroups( g1.in(), g2.in() );
}
+ break;
}
- else {
+ case 1:
+ {
SMESH::ListOfGroups_var g1 = new SMESH::ListOfGroups();
g1->length( myGroups1.count() );
for ( int i = 0; i < myGroups1.count(); i++ )
else {
result = aMeshEditor->DoubleNodeElemGroups( g1.in(), g2.in(), g3.in() );
}
+ break;
+ }
+ case 2:
+ {
+ result = true;
+ QString groupName;
+ if ( toCreateElemGroup )
+ groupName = SMESH::UniqueName("DoubleElements");
+ for ( int i = 0; i < myGroups1.count(); i++ )
+ {
+ SMESH::SMESH_Group_var group =
+ aMeshEditor->DoubleElements( myGroups1[i], groupName.toLatin1().data() );
+ if ( group->_is_nil() )
+ {
+ if ( toCreateElemGroup )
+ result = false;
+ }
+ else
+ {
+ if ( _PTR(SObject) so = SMESH::FindSObject( group ))
+ anEntryList.append( so->GetID().c_str() );
+ }
+ }
+ break;
+ }
}
}
catch (const SALOME::SALOME_Exception& S_ex) {
catch ( const std::exception& exc ) {
INFOS( "Follow exception was cought:\n\t" << exc.what() );
}
- catch (...){
+ catch (...) {
INFOS( "Unknown exception was cought !!!" );
}
SMESHGUI::Modified();
mySMESHGUI->updateObjBrowser(true);
+ if ( !anEntryList.isEmpty())
+ if( LightApp_Application* anApp =
+ dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ))
+ anApp->browseObjects( anEntryList, true, false );
+
// Reinitialize the dialog
Init();
-
+
return true;
}
void SMESHGUI_DuplicateNodesDlg::onOk()
{
if (onApply())
- onClose();
+ reject();
}
/*!
\brief SLOT called to close the dialog.
*/
-void SMESHGUI_DuplicateNodesDlg::onClose()
+void SMESHGUI_DuplicateNodesDlg::reject()
{
disconnect(mySelectionMgr, 0, this, 0);
disconnect(mySMESHGUI, 0, this, 0);
mySMESHGUI->ResetState();
mySelectionMgr->clearFilters();
- reject();
+ QDialog::reject();
}
/*!
// check group of proper type is selected
if ( ok ) {
SMESH::ElementType aGroupType = aGroup->GetType();
- if ( operationMode == 0 ) {
+ switch ( operationMode ) {
+ case 0:
ok = ( myCurrentLineEdit == myLineEdit1 && aGroupType == SMESH::NODE ) ||
( myCurrentLineEdit == myLineEdit2 && aGroupType != SMESH::NODE );
- }
- else {
+ break;
+ case 1:
ok = ( myCurrentLineEdit == myLineEdit1 && ( aGroupType == SMESH::EDGE ||
aGroupType == SMESH::FACE ) ) ||
( myCurrentLineEdit == myLineEdit2 && aGroupType == SMESH::NODE ) ||
( myCurrentLineEdit == myLineEdit3 && aGroupType != SMESH::NODE );
+ break;
+ case 2:
+ ok = ( aGroupType != SMESH::NODE );
+ break;
}
}
if ( ok ) aGroups << aGroup;
/*!
\brief Check if the input data is valid.
- \return \c true id the data is valid
+ \return \c true if the data is valid
*/
bool SMESHGUI_DuplicateNodesDlg::isValid()
{
// Set selection mode
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(ActorSelection);
- mySelectionMgr->installFilter(new SMESH_TypeFilter (GROUP));
+ mySelectionMgr->installFilter(new SMESH_TypeFilter (SMESH::GROUP));
}
}
-/*!
- \brief Receive close events.
- Reimplemented from QWidget class.
-*/
-void SMESHGUI_DuplicateNodesDlg::closeEvent (QCloseEvent*)
-{
- onClose();
-}
-
/*!
\brief Receive key press events.
Reimplemented from QWidget class.