smesh/src/SMESHGUI/SMESHGUI.cxx

2694 lines
87 KiB
C++
Raw Normal View History

2003-07-10 18:28:26 +06:00
// SMESH SMESHGUI : GUI for SMESH component
//
// 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
//
2004-06-18 14:34:31 +06:00
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
2003-07-10 18:28:26 +06:00
//
// File : SMESHGUI.cxx
// Author : Nicolas REJNERI
// Module : SMESH
2003-05-19 20:07:00 +06:00
// $Header$
#include "SMESHGUI.h"
#include "SMESHGUI_InitMeshDlg.h"
#include "SMESHGUI_AddSubMeshDlg.h"
#include "SMESHGUI_NodesDlg.h"
#include "SMESHGUI_TransparencyDlg.h"
2004-12-01 15:48:31 +05:00
#include "SMESHGUI_ClippingDlg.h"
2004-06-18 14:34:31 +06:00
#include "SMESHGUI_GroupDlg.h"
2003-05-19 20:07:00 +06:00
#include "SMESHGUI_RemoveNodesDlg.h"
#include "SMESHGUI_RemoveElementsDlg.h"
#include "SMESHGUI_MeshInfosDlg.h"
2004-12-17 16:07:35 +05:00
#include "SMESHGUI_StandardMeshInfosDlg.h"
2003-05-19 20:07:00 +06:00
#include "SMESHGUI_Preferences_ColorDlg.h"
#include "SMESHGUI_Preferences_ScalarBarDlg.h"
2004-06-18 14:34:31 +06:00
#include "SMESHGUI_Preferences_SelectionDlg.h"
2004-12-01 15:48:31 +05:00
#include "SMESHGUI_Hypotheses.h"
#include "SMESHGUI_HypothesesUtils.h"
2003-05-19 20:07:00 +06:00
#include "SMESHGUI_MoveNodesDlg.h"
2004-12-01 15:48:31 +05:00
#include "SMESHGUI_AddMeshElementDlg.h"
2003-05-19 20:07:00 +06:00
#include "SMESHGUI_EditHypothesesDlg.h"
2004-06-18 14:34:31 +06:00
#include "SMESHGUI_CreateHypothesesDlg.h"
#include "SMESHGUI_FilterDlg.h"
2004-12-01 15:48:31 +05:00
#include "SMESHGUI_FilterLibraryDlg.h"
#include "SMESHGUI_SingleEditDlg.h"
#include "SMESHGUI_MultiEditDlg.h"
#include "SMESHGUI_GroupOpDlg.h"
#include "SMESHGUI_DeleteGroupDlg.h"
#include "SMESHGUI_SmoothingDlg.h"
#include "SMESHGUI_RenumberingDlg.h"
#include "SMESHGUI_ExtrusionDlg.h"
2005-01-20 11:25:54 +05:00
#include "SMESHGUI_ExtrusionAlongPathDlg.h"
2004-12-01 15:48:31 +05:00
#include "SMESHGUI_RevolutionDlg.h"
#include "SMESHGUI_TranslationDlg.h"
#include "SMESHGUI_RotationDlg.h"
#include "SMESHGUI_SymmetryDlg.h"
#include "SMESHGUI_SewingDlg.h"
#include "SMESHGUI_MergeNodesDlg.h"
#include "SMESHGUI_MeshPatternDlg.h"
#include "SMESHGUI_PrecisionDlg.h"
#include "VTKViewer_ViewFrame.h"
#include "VTKViewer_InteractorStyleSALOME.h"
#include "VTKViewer_RenderWindowInteractor.h"
2003-05-19 20:07:00 +06:00
2004-06-18 14:34:31 +06:00
#include "SMESH_Actor.h"
#include "SMESH_Object.h"
2003-05-19 20:07:00 +06:00
#include "QAD.h"
#include "QAD_Tools.h"
#include "QAD_Config.h"
#include "QAD_Settings.h"
#include "QAD_RightFrame.h"
2003-12-10 21:05:04 +05:00
#include "QAD_MessageBox.h"
2003-05-19 20:07:00 +06:00
#include "QAD_Resource.h"
#include "QAD_FileDlg.h"
2004-06-18 14:34:31 +06:00
#include "QAD_Desktop.h"
#include "QAD_ResourceMgr.h"
#include "QAD_WaitCursor.h"
2003-05-19 20:07:00 +06:00
#include "SALOME_NamingService.hxx"
#include "SALOME_ListIteratorOfListIO.hxx"
#include "SALOME_InteractiveObject.hxx"
2004-06-18 14:34:31 +06:00
#include "SALOMEGUI_Desktop.h"
#include "SALOMEGUI_NameDlg.h"
2003-05-19 20:07:00 +06:00
#include "SALOMEGUI_ImportOperation.h"
#include "SALOMEGUI_QtCatchCorbaException.hxx"
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_SMESHGenUtils.h"
#include "SMESHGUI_GEOMGenUtils.h"
#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_GroupUtils.h"
#include "SMESHGUI_FilterUtils.h"
#include "SMESHGUI_PatternUtils.h"
#include "SMESHGUI_VTKUtils.h"
#include "SALOMEconfig.h"
#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
2003-05-19 20:07:00 +06:00
// QT Includes
#define INCLUDE_MENUITEM_DEF
#include <qapplication.h>
#include <qlineedit.h>
#include <qmenudata.h>
#include <qmenubar.h>
#include <qpopupmenu.h>
#include <qfont.h>
#include <qstring.h>
2004-12-01 15:48:31 +05:00
#include <qpainter.h>
2003-05-19 20:07:00 +06:00
#include <qcheckbox.h>
#include <qcolordialog.h>
#include <qspinbox.h>
#include <qlist.h>
2003-12-10 21:05:04 +05:00
#include <qwidget.h>
#include <qevent.h>
#include <qradiobutton.h>
2003-05-19 20:07:00 +06:00
2004-12-01 15:48:31 +05:00
#include <boost/shared_ptr.hpp>
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkActorCollection.h>
2004-06-18 14:34:31 +06:00
#include <vtkScalarBarActor.h>
2005-02-03 18:24:46 +05:00
#include <vtkUnstructuredGrid.h>
2003-07-10 18:28:26 +06:00
2004-12-01 15:48:31 +05:00
#include "utilities.h"
2003-05-19 20:07:00 +06:00
2004-12-01 15:48:31 +05:00
using namespace std;
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
namespace{
// Decalarations
//=============================================================
void ImportMeshesFromFile(QAD_Desktop * parent,
SMESH::SMESH_Gen_ptr theComponentMesh,
int theCommandID);
2003-05-19 20:07:00 +06:00
2004-12-01 15:48:31 +05:00
void ExportMeshToFile(QAD_Desktop * parent, int theCommandID);
2004-06-18 14:34:31 +06:00
2005-01-20 11:25:54 +05:00
void SetDisplayMode(int theCommandID);
void SetDisplayEntity(int theCommandID);
2004-12-01 15:48:31 +05:00
void Control( int theCommandID );
void SetDisplaySettings();
// Definitions
//=============================================================
void ImportMeshesFromFile(QAD_Desktop * parent,
SMESH::SMESH_Gen_ptr theComponentMesh,
int theCommandID)
{
2005-01-20 11:25:54 +05:00
QStringList filter;
2004-12-01 15:48:31 +05:00
string myExtension;
if(theCommandID == 113){
2005-01-20 11:25:54 +05:00
filter.append(QObject::tr("MED files (*.med)"));
filter.append(QObject::tr("All files (*)"));
2004-12-01 15:48:31 +05:00
}else if (theCommandID == 112){
2005-01-20 11:25:54 +05:00
filter.append(QObject::tr("IDEAS files (*.unv)"));
2004-12-01 15:48:31 +05:00
}else if (theCommandID == 111){
2005-01-20 11:25:54 +05:00
filter.append(QObject::tr("DAT files (*.dat)"));
2004-12-01 15:48:31 +05:00
}
QString filename = QAD_FileDlg::getFileName(parent,
"",
filter,
QObject::tr("Import mesh"),
true);
if(!filename.isEmpty()) {
QAD_WaitCursor wc;
SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument();
try {
SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
switch ( theCommandID ) {
case 112:
{
aMeshes->length( 1 );
aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1());
break;
}
case 113:
{
SMESH::DriverMED_ReadStatus res;
aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res);
if ( res != SMESH::DRS_OK ) {
wc.stop();
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
QObject::tr("SMESH_WRN_WARNING"),
QObject::tr(QString("SMESH_DRS_%1").arg(res)),
QObject::tr("SMESH_BUT_OK"));
aMeshes->length( 0 );
wc.start();
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
break;
2004-06-18 14:34:31 +06:00
}
}
2004-12-01 15:48:31 +05:00
bool isEmpty = false;
for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
SALOMEDS::SObject_var aMeshSO = SMESH::FindSObject( aMeshes[i] );
if ( !aMeshSO->_is_nil() ) {
SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow( aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" ) );
aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED");
if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
} else
isEmpty = true;
}
if ( isEmpty ) {
wc.stop();
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
QObject::tr("SMESH_WRN_WARNING"),
QObject::tr("SMESH_DRS_EMPTY"),
QObject::tr("SMESH_BUT_OK"));
wc.start();
}
}
catch (const SALOME::SALOME_Exception& S_ex){
wc.stop();
QtCatchCorbaException(S_ex);
wc.start();
2004-06-18 14:34:31 +06:00
}
}
}
2004-12-01 15:48:31 +05:00
void ExportMeshToFile(QAD_Desktop * parent, int theCommandID)
{
SALOME_Selection *aSel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
if(aSel->IObjectCount()){
Handle(SALOME_InteractiveObject) anIObject = aSel->firstIObject();
SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
if ( !aMesh->_is_nil() ) {
QString aFilter, aTitle = QObject::tr("Export mesh");
2005-01-20 11:25:54 +05:00
QMap<QString, SMESH::MED_VERSION> aFilterMap;
2004-12-01 15:48:31 +05:00
switch ( theCommandID ) {
case 122:
2005-01-20 11:25:54 +05:00
aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 );
aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 );
2004-12-01 15:48:31 +05:00
break;
case 121:
aFilter = QObject::tr("DAT files (*.dat)");
break;
case 123: {
if(aMesh->NbPyramids()){
int aRet = QAD_MessageBox::warn2(QAD_Application::getDesktop(),
QObject::tr("SMESH_WRN_WARNING"),
QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()),
QObject::tr("SMESH_BUT_YES"),
QObject::tr("SMESH_BUT_NO"),
0,1,0);
if(aRet)
return;
}
aFilter = QObject::tr("IDEAS files (*.unv)");
break;
default:
return;
}}
2005-01-20 11:25:54 +05:00
QString aFilename;
SMESH::MED_VERSION aFormat;
if ( theCommandID != 122)
aFilename = QAD_FileDlg::getFileName(parent, "", aFilter, aTitle, false);
else
{
QStringList filters;
for ( QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin(); it != aFilterMap.end(); ++it )
filters.push_back( it.key() );
QAD_FileDlg* fd = new QAD_FileDlg( parent, false, true, true );
fd->setCaption( aTitle );
fd->setFilters( filters );
fd->exec();
aFilename = fd->selectedFile();
aFormat = aFilterMap[fd->selectedFilter()];
delete fd;
}
2004-12-01 15:48:31 +05:00
if ( !aFilename.isEmpty() ) {
// Check whether the file already exists and delete it if yes
QFile aFile( aFilename );
if ( aFile.exists() )
aFile.remove();
QAD_WaitCursor wc;
switch ( theCommandID ) {
case 122:
2005-01-20 11:25:54 +05:00
aMesh->ExportToMED( aFilename.latin1(), false, aFormat ); // currently, automatic groups are never created
2004-12-01 15:48:31 +05:00
break;
case 121:
aMesh->ExportDAT( aFilename.latin1() );
break;
case 123:
aMesh->ExportUNV( aFilename.latin1() );
break;
default:
break;
}
2004-06-18 14:34:31 +06:00
}
}
2004-12-01 15:48:31 +05:00
}
}
2005-01-20 11:25:54 +05:00
inline void InverseEntityMode(unsigned int& theOutputMode,
unsigned int theMode)
{
bool anIsNotPresent = ~theOutputMode & theMode;
if(anIsNotPresent)
theOutputMode |= theMode;
else
theOutputMode &= ~theMode;
}
void SetDisplayEntity(int theCommandID){
SALOME_Selection *Sel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
if(Sel->IObjectCount() >= 1){
SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
for(; It.More(); It.Next()){
Handle(SALOME_InteractiveObject) IObject = It.Value();
if(IObject->hasEntry()){
if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
unsigned int aMode = anActor->GetEntityMode();
switch(theCommandID){
case 217:
InverseEntityMode(aMode,SMESH_Actor::eEdges);
break;
case 218:
InverseEntityMode(aMode,SMESH_Actor::eFaces);
break;
case 219:
InverseEntityMode(aMode,SMESH_Actor::eVolumes);
break;
case 220:
aMode = SMESH_Actor::eAllEntity;
break;
}
if(aMode)
anActor->SetEntityMode(aMode);
}
}
}
}
}
void SetDisplayMode(int theCommandID){
2004-12-01 15:48:31 +05:00
SALOME_Selection *Sel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection());
if(Sel->IObjectCount() >= 1){
switch(theCommandID){
case 1134:{
SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
2005-01-20 11:25:54 +05:00
new SMESHGUI_ClippingDlg(QAD_Application::getDesktop(),"",false);
2004-12-01 15:48:31 +05:00
return;
}
case 1133:{
SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
2005-01-20 11:25:54 +05:00
new SMESHGUI_TransparencyDlg(QAD_Application::getDesktop(),"",false);
2004-12-01 15:48:31 +05:00
return;
}}
SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
for(; It.More(); It.Next()){
Handle(SALOME_InteractiveObject) IObject = It.Value();
if(IObject->hasEntry()){
if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
switch(theCommandID){
case 211:
anActor->SetRepresentation(SMESH_Actor::eEdge);
break;
case 212:
anActor->SetRepresentation(SMESH_Actor::eSurface);
break;
case 213:
if(anActor->IsShrunk())
anActor->UnShrink();
else
anActor->SetShrink();
break;
case 215:
anActor->SetRepresentation(SMESH_Actor::ePoint);
break;
case 1132:{
float color[3];
anActor->GetSufaceColor(color[0], color[1], color[2]);
int c0 = int (color[0] * 255);
int c1 = int (color[1] * 255);
int c2 = int (color[2] * 255);
QColor c(c0, c1, c2);
float edgecolor[3];
anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
c0 = int (edgecolor[0] * 255);
c1 = int (edgecolor[1] * 255);
c2 = int (edgecolor[2] * 255);
QColor e(c0, c1, c2);
float backfacecolor[3];
anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]);
c0 = int (backfacecolor[0] * 255);
c1 = int (backfacecolor[1] * 255);
c2 = int (backfacecolor[2] * 255);
QColor b(c0, c1, c2);
float nodecolor[3];
anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
c0 = int (nodecolor[0] * 255);
c1 = int (nodecolor[1] * 255);
c2 = int (nodecolor[2] * 255);
QColor n(c0, c1, c2);
int Edgewidth = (int)anActor->GetLineWidth();
if(Edgewidth == 0)
Edgewidth = 1;
int intValue = int(anActor->GetNodeSize());
float Shrink = anActor->GetShrinkFactor();
SMESHGUI_Preferences_ColorDlg *aDlg =
new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(),"");
aDlg->SetColor(1, c);
aDlg->SetColor(2, e);
aDlg->SetColor(3, n);
aDlg->SetColor(4, b);
aDlg->SetIntValue(1, Edgewidth);
aDlg->SetIntValue(2, intValue);
aDlg->SetIntValue(3, int(Shrink*100.));
if(aDlg->exec()){
QColor color = aDlg->GetColor(1);
QColor edgecolor = aDlg->GetColor(2);
QColor nodecolor = aDlg->GetColor(3);
QColor backfacecolor = aDlg->GetColor(4);
/* actor color and backface color */
anActor->SetSufaceColor(float (color.red()) / 255.,
float (color.green()) / 255.,
float (color.blue()) / 255.);
anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255.,
float (backfacecolor.green()) / 255.,
float (backfacecolor.blue()) / 255.);
/* edge color */
anActor->SetEdgeColor(float (edgecolor.red()) / 255.,
float (edgecolor.green()) / 255.,
float (edgecolor.blue()) / 255.);
/* Shrink factor and size edges */
anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.);
anActor->SetLineWidth(aDlg->GetIntValue(1));
/* Nodes color and size */
anActor->SetNodeColor(float (nodecolor.red()) / 255.,
float (nodecolor.green()) / 255.,
float (nodecolor.blue()) / 255.);
anActor->SetNodeSize(aDlg->GetIntValue(2));
delete aDlg;
}
break;
}}
}
2004-06-18 14:34:31 +06:00
}
}
2004-12-01 15:48:31 +05:00
SMESH::RepaintCurrentView();
2004-06-18 14:34:31 +06:00
}
}
2004-12-01 15:48:31 +05:00
void SetDisplaySettings()
{
SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
SMESHGUI_Preferences_ColorDlg *aDlg =
new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(), "");
QColor color;
QString SCr, SCg, SCb;
SCr = QAD_CONFIG->getSetting("SMESH:SettingsFillColorRed");
SCg = QAD_CONFIG->getSetting("SMESH:SettingsFillColorGreen");
SCb = QAD_CONFIG->getSetting("SMESH:SettingsFillColorBlue");
if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
else color = QColor(0, 170, 255);
aDlg->SetColor(1, color);
SCr = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorRed");
SCg = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen");
SCb = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue");
if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
else color = QColor(0, 170, 255);
aDlg->SetColor(2, color);
SCr = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorRed");
SCg = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorGreen");
SCb = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorBlue");
if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
else color = Qt::red;
aDlg->SetColor(3, color);
QString SBr = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorRed");
QString SBg = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorGreen");
QString SBb = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorBlue");
if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
color = QColor(SBr.toInt(), SBg.toInt(), SBb.toInt());
else color = Qt::blue;
aDlg->SetColor(4, color);
QString intValue = QAD_CONFIG->getSetting("SMESH:SettingsWidth");
if (intValue.isEmpty()) intValue = "1";
aDlg->SetIntValue(1, intValue.toInt());
intValue = QAD_CONFIG->getSetting("SMESH:SettingsNodesSize");
if (intValue.isEmpty()) intValue = "3";
aDlg->SetIntValue(2, intValue.toInt());
intValue = QAD_CONFIG->getSetting("SMESH:SettingsShrinkCoeff");
if (intValue.isEmpty()) intValue = "75";
aDlg->SetIntValue(3, intValue.toInt());
if (aDlg->exec()) {
QColor colorFill = aDlg->GetColor(1);
QAD_CONFIG->addSetting("SMESH:SettingsFillColorRed", colorFill.red());
QAD_CONFIG->addSetting("SMESH:SettingsFillColorGreen", colorFill.green());
QAD_CONFIG->addSetting("SMESH:SettingsFillColorBlue", colorFill.blue());
QColor colorOutline = aDlg->GetColor(2);
QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorRed", colorOutline.red());
QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorGreen", colorOutline.green());
QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorBlue", colorOutline.blue());
QColor colorNode = aDlg->GetColor(3);
QAD_CONFIG->addSetting("SMESH:SettingsNodeColorRed", colorNode.red());
QAD_CONFIG->addSetting("SMESH:SettingsNodeColorGreen", colorNode.green());
QAD_CONFIG->addSetting("SMESH:SettingsNodeColorBlue", colorNode.blue());
QColor colorBackFace = aDlg->GetColor(4);
QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorRed", colorBackFace.red());
QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorGreen", colorBackFace.green());
QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorBlue", colorBackFace.blue());
int width = aDlg->GetIntValue(1);
QAD_CONFIG->addSetting("SMESH:SettingsWidth", width);
int nodes_size = aDlg->GetIntValue(2);
QAD_CONFIG->addSetting("SMESH:SettingsNodesSize", nodes_size);
int shrink_coeff = aDlg->GetIntValue(3);
QAD_CONFIG->addSetting("SMESH:SettingsShrinkCoeff", shrink_coeff);
}
delete aDlg;
}
void Control( int theCommandID )
{
SALOME_Selection *Sel = SALOME_Selection::Selection( SMESH::GetActiveStudy()->getSelection() );
if(Sel){
Handle(SALOME_InteractiveObject) anIO = Sel->firstIObject();
if(!anIO.IsNull()){
QString aTitle;
SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){
switch ( theCommandID ){
case 6001:
aTitle = QObject::tr( "LENGTH_EDGES" );
2005-01-20 11:25:54 +05:00
aControl = SMESH_Actor::eLength;
break;
case 6018:
aTitle = QObject::tr( "LENGTH2D_EDGES" );
aControl = SMESH_Actor::eLength2D;
2004-12-01 15:48:31 +05:00
break;
case 6002:
aTitle = QObject::tr( "FREE_EDGES" );
aControl = SMESH_Actor::eFreeEdges;
break;
case 6003:
aTitle = QObject::tr( "FREE_BORDERS" );
aControl = SMESH_Actor::eFreeBorders;
break;
case 6004:
aTitle = QObject::tr( "MULTI_BORDERS" );
aControl = SMESH_Actor::eMultiConnection;
break;
2005-01-20 11:25:54 +05:00
case 6019:
aTitle = QObject::tr( "MULTI2D_BORDERS" );
aControl = SMESH_Actor::eMultiConnection2D;
break;
2004-12-01 15:48:31 +05:00
case 6011:
aTitle = QObject::tr( "AREA_ELEMENTS" );
aControl = SMESH_Actor::eArea;
break;
case 6012:
aTitle = QObject::tr( "TAPER_ELEMENTS" );
aControl = SMESH_Actor::eTaper;
break;
case 6013:
aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" );
aControl = SMESH_Actor::eAspectRatio;
break;
2005-01-20 11:25:54 +05:00
case 6017:
aTitle = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
aControl = SMESH_Actor::eAspectRatio3D;
break;
2004-12-01 15:48:31 +05:00
case 6014:
aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
aControl = SMESH_Actor::eMinimumAngle;
break;
case 6015:
aTitle = QObject::tr( "WARP_ELEMENTS" );
aControl = SMESH_Actor::eWarping;
break;
case 6016:
aTitle = QObject::tr( "SKEW_ELEMENTS" );
aControl = SMESH_Actor::eSkew;
break;
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
anActor->SetControlMode(aControl);
anActor->GetScalarBarActor()->SetTitle(aTitle.latin1());
2004-06-18 14:34:31 +06:00
}
}
}
}
2004-12-01 15:48:31 +05:00
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO,
MeshObjectType theType,
const QString theInTypeName,
QString & theOutTypeName)
{
SMESH_TypeFilter aTypeFilter( theType );
if ( aTypeFilter.IsOk( theIO )) {
theOutTypeName = theInTypeName;
return true;
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
return false;
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO)
{
SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument();
SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(theIO->getEntry());
if (!aSObj->_is_nil()) {
SALOMEDS::SComponent_var aSComp = aSObj->GetFatherComponent();
CORBA::String_var anID = aSComp->GetID();
if (!strcmp(anID.in(),theIO->getEntry()))
return "Component";
}
QString aTypeName;
if (
CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) ||
CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) ||
CheckOIType ( theIO, MESH, "Mesh", aTypeName ) ||
CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) ||
CheckOIType ( theIO, GROUP, "Group", aTypeName )
)
return aTypeName;
return "NoType";
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
QString CheckHomogeneousSelection()
{
QAD_Study* aStudy = SMESH::GetActiveStudy();
SALOME_Selection *aSel = SALOME_Selection::Selection(aStudy->getSelection());
/* copy the list */
SALOME_ListIO List;
SALOME_ListIteratorOfListIO Itinit(aSel->StoredIObjects());
for (; Itinit.More(); Itinit.Next())
{
List.Append(Itinit.Value());
}
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
QString RefType = CheckTypeObject(aSel->firstIObject());
SALOME_ListIteratorOfListIO It(List);
for (; It.More(); It.Next())
{
Handle(SALOME_InteractiveObject) IObject = It.Value();
QString Type = CheckTypeObject(IObject);
if (Type.compare(RefType) != 0)
return "Heterogeneous Selection";
}
aSel->ClearIObjects();
SALOME_ListIteratorOfListIO It1(List);
for (; It1.More(); It1.Next())
{
int res = aSel->AddIObject(It1.Value());
if (res == -1)
aStudy->highlight(It1.Value(), false);
if (res == 0)
aStudy->highlight(It1.Value(), true);
}
return RefType;
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
void OnEditDelete()
{
2004-12-17 16:07:35 +05:00
// VSR 17/11/04: check if all objects selected belong to SMESH component --> start
QString aParentComponent = ((SALOMEGUI_Desktop*)QAD_Application::getDesktop())->getComponentFromSelection();
if ( aParentComponent != QAD_Application::getDesktop()->getActiveComponent() ) {
QAD_MessageBox::warn1 ( QAD_Application::getDesktop(),
QObject::tr("ERR_ERROR"),
QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg(QAD_Application::getDesktop()->getComponentUserName( "SMESH" )),
QObject::tr("BUT_OK") );
return;
}
// VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
2004-12-01 15:48:31 +05:00
if (QAD_MessageBox::warn2
(QAD_Application::getDesktop(),
QObject::tr("SMESH_WRN_WARNING"),
QObject::tr("SMESH_REALLY_DELETE"),
QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
return;
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
QAD_Study* anActiveStudy = SMESH::GetActiveStudy();
int nbSf = anActiveStudy->getStudyFramesCount();
SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument();
SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeIOR_var anIOR;
SALOME_Selection *Sel = SALOME_Selection::Selection(anActiveStudy->getSelection());
SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
for(; It.More(); It.Next()){
Handle(SALOME_InteractiveObject) IObject = It.Value();
if(IObject->hasEntry()){
SALOMEDS::SObject_var SO = aStudy->FindObjectID(IObject->getEntry());
/* Erase child graphical objects */
SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SO);
for(; it->More(); it->Next()){
SALOMEDS::SObject_var CSO = it->Value();
if(CSO->FindAttribute(anAttr, "AttributeIOR")){
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
for(int i = 0; i < nbSf; i++){
QAD_StudyFrame *sf = anActiveStudy->getStudyFrame(i);
CORBA::String_var anEntry = CSO->GetID();
if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
SMESH::RemoveActor(sf,anActor);
}
}
2004-06-18 14:34:31 +06:00
}
}
2004-12-01 15:48:31 +05:00
/* Erase main graphical object */
for(int i = 0; i < nbSf; i++){
QAD_StudyFrame *sf = anActiveStudy->getStudyFrame(i);
if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
SMESH::RemoveActor(sf,anActor);
2004-06-18 14:34:31 +06:00
}
}
2004-12-01 15:48:31 +05:00
// Remove object(s) from data structures
SALOMEDS::SObject_var obj = aStudy->FindObjectID(IObject->getEntry());
if(!obj->_is_nil()){
SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(obj->GetObject());
SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(obj->GetObject());
if ( !aGroup->_is_nil() ) { // DELETE GROUP
SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
aMesh->RemoveGroup( aGroup );
}
else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
aMesh->RemoveSubMesh( aSubMesh );
}
else {// default action: remove SObject from the study
// san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
//QAD_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
//op->start();
aStudyBuilder->RemoveObjectWithChildren( obj );
//op->finish();
2004-06-18 14:34:31 +06:00
}
}
2004-12-01 15:48:31 +05:00
} /* IObject->hasEntry() */
} /* more/next */
/* Clear any previous selection */
Sel->ClearIObjects();
anActiveStudy->updateObjBrowser();
2004-06-18 14:34:31 +06:00
}
}
2003-05-19 20:07:00 +06:00
//=============================================================================
/*!
*
*/
//=============================================================================
2004-12-17 16:07:35 +05:00
class CustomItem : public QCustomMenuItem
2003-05-19 20:07:00 +06:00
{
2004-12-17 16:07:35 +05:00
public:
CustomItem(const QString& s, const QFont& f) : myString(s), myFont(f) {}
~CustomItem() {}
void paint(QPainter* p, const QColorGroup& cg, bool act, bool /*enabled*/, int x, int y, int w, int h)
2004-06-18 14:34:31 +06:00
{
2004-12-17 16:07:35 +05:00
p->save();
p->fillRect( x, y, w, h, act ? cg.highlight() : cg.mid() );
p->setPen( act ? cg.highlightedText() : cg.buttonText() );
p->setFont( myFont );
p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
p->restore();
2004-06-18 14:34:31 +06:00
}
2004-12-17 16:07:35 +05:00
QSize sizeHint()
2004-06-18 14:34:31 +06:00
{
2004-12-17 16:07:35 +05:00
return QFontMetrics( myFont ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
2004-06-18 14:34:31 +06:00
}
2004-12-17 16:07:35 +05:00
bool fullSpan() const
2004-06-18 14:34:31 +06:00
{
2004-12-17 16:07:35 +05:00
return true;
2004-06-18 14:34:31 +06:00
}
2004-12-17 16:07:35 +05:00
private:
QString myString;
QFont myFont;
2003-05-19 20:07:00 +06:00
};
//=============================================================================
/*!
*
*/
//=============================================================================
2004-06-18 14:34:31 +06:00
SMESHGUI::SMESHGUI( const QString& theName, QObject* theParent ) :
SALOMEGUI( theName, theParent )
2003-05-19 20:07:00 +06:00
{
2004-12-01 15:48:31 +05:00
myActiveDialogBox = 0 ;
myState = -1 ;
SMESH::GetSMESHGen();
SMESH::GetFilterManager();
SMESH::GetPattern();
/* load resources for all available meshers */
SMESH::InitAvailableHypotheses();
2003-05-19 20:07:00 +06:00
}
//=============================================================================
/*!
*
*/
//=============================================================================
SMESHGUI::~SMESHGUI()
{
2004-12-01 15:48:31 +05:00
SMESH::GetFilterManager()->Destroy();
2003-05-19 20:07:00 +06:00
}
//=============================================================================
/*!
*
*/
//=============================================================================
2004-06-18 14:34:31 +06:00
SMESHGUI* SMESHGUI::GetSMESHGUI()
2003-05-19 20:07:00 +06:00
{
2004-12-01 15:48:31 +05:00
static SMESHGUI aSMESHGUI;
aSMESHGUI.myActiveStudy = SMESH::GetActiveStudy();
SMESH::GetSMESHGen()->SetCurrentStudy( SMESH::GetActiveStudyDocument() );
/* Automatic Update flag */
aSMESHGUI.myAutomaticUpdate = ( QAD_CONFIG->getSetting( "SMESH:AutomaticUpdate" ).compare( "true" ) == 0 );
return &aSMESHGUI;
2003-05-19 20:07:00 +06:00
}
2004-06-18 14:34:31 +06:00
extern "C"
{
Standard_EXPORT SALOMEGUI* GetComponentGUI() {
return SMESHGUI::GetSMESHGUI();
}
}
2004-12-01 15:48:31 +05:00
2003-05-19 20:07:00 +06:00
//=============================================================================
/*!
*
*/
//=============================================================================
2004-12-01 15:48:31 +05:00
void SMESHGUI::SetState(int aState)
2003-05-19 20:07:00 +06:00
{
2004-12-01 15:48:31 +05:00
this->myState = aState;
return;
2003-05-19 20:07:00 +06:00
}
//=============================================================================
/*!
*
*/
//=============================================================================
2004-12-01 15:48:31 +05:00
void SMESHGUI::ResetState()
2003-12-10 21:05:04 +05:00
{
2004-12-01 15:48:31 +05:00
this->myState = -1;
2004-06-18 14:34:31 +06:00
return;
2003-12-10 21:05:04 +05:00
}
2003-05-19 20:07:00 +06:00
//=============================================================================
/*!
*
*/
//=============================================================================
2004-12-01 15:48:31 +05:00
void SMESHGUI::EmitSignalDeactivateDialog()
2003-12-10 21:05:04 +05:00
{
2004-12-01 15:48:31 +05:00
emit this->SignalDeactivateActiveDialog();
2004-06-18 14:34:31 +06:00
return;
2003-12-10 21:05:04 +05:00
}
2003-05-19 20:07:00 +06:00
//=============================================================================
/*!
*
*/
//=============================================================================
2004-12-01 15:48:31 +05:00
void SMESHGUI::EmitSignalStudyFrameChanged()
2003-05-19 20:07:00 +06:00
{
2004-12-01 15:48:31 +05:00
emit this->SignalStudyFrameChanged();
2004-06-18 14:34:31 +06:00
return;
2003-05-19 20:07:00 +06:00
}
//=============================================================================
/*!
*
*/
//=============================================================================
void SMESHGUI::EmitSignalCloseAllDialogs()
{
2004-06-18 14:34:31 +06:00
emit SignalCloseAllDialogs();
return;
2003-05-19 20:07:00 +06:00
}
//=============================================================================
/*!
*
*/
//=============================================================================
2003-12-10 21:05:04 +05:00
QDialog *SMESHGUI::GetActiveDialogBox()
2003-05-19 20:07:00 +06:00
{
2004-06-18 14:34:31 +06:00
return this->myActiveDialogBox;
2003-05-19 20:07:00 +06:00
}
//=============================================================================
/*!
*
*/
//=============================================================================
2003-12-10 21:05:04 +05:00
void SMESHGUI::SetActiveDialogBox(QDialog * aDlg)
2003-05-19 20:07:00 +06:00
{
2004-06-18 14:34:31 +06:00
this->myActiveDialogBox = (QDialog *) aDlg;
return;
2003-05-19 20:07:00 +06:00
}
//=============================================================================
/*!
*
*/
//=============================================================================
2003-12-10 21:05:04 +05:00
QAD_Study *SMESHGUI::GetActiveStudy()
2003-05-19 20:07:00 +06:00
{
2004-06-18 14:34:31 +06:00
return this->myActiveStudy;
2003-05-19 20:07:00 +06:00
}
//=============================================================================
/*!
*
*/
//=============================================================================
2003-12-10 21:05:04 +05:00
QAD_Desktop *SMESHGUI::GetDesktop()
2003-05-19 20:07:00 +06:00
{
2004-12-01 15:48:31 +05:00
return QAD_Application::getDesktop();
2003-05-19 20:07:00 +06:00
}
//=============================================================================
/*!
*
*/
//=============================================================================
2004-06-18 14:34:31 +06:00
bool SMESHGUI::ActiveStudyChanged(QAD_Desktop* parent)
2003-05-19 20:07:00 +06:00
{
2004-06-18 14:34:31 +06:00
MESSAGE("SMESHGUI::activeStudyChanged init.");
2004-12-01 15:48:31 +05:00
QAD_Study* prevStudy = myActiveStudy;
2004-06-18 14:34:31 +06:00
/* Create or retrieve an object SMESHGUI */
MESSAGE("Active study changed : prev study =" << prevStudy);
2004-12-01 15:48:31 +05:00
SMESHGUI::GetSMESHGUI();
EmitSignalStudyFrameChanged();
MESSAGE("Active study changed : active study =" << myActiveStudy);
if ( prevStudy != myActiveStudy ) {
EmitSignalCloseAllDialogs();
2004-06-18 14:34:31 +06:00
MESSAGE("Active study changed : SMESHGUI nullified" << endl);
//smeshGUI = 0;
2004-12-01 15:48:31 +05:00
SMESH::UpdateSelectionProp();
2004-06-18 14:34:31 +06:00
}
MESSAGE("SMESHGUI::activeStudyChanged done.");
return true;
2003-05-19 20:07:00 +06:00
}
//=============================================================================
/*!
*
*/
//=============================================================================
2004-06-18 14:34:31 +06:00
bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y)
2003-05-19 20:07:00 +06:00
{
2004-06-18 14:34:31 +06:00
/* Here the position is on the bottom right corner - 10 */
// aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
aDlg->adjustSize();
QAD_Desktop *PP = QAD_Application::getDesktop();
x = abs(PP->x() + PP->size().width() - aDlg->size().width() - 10);
y = abs(PP->y() + PP->size().height() - aDlg->size().height() - 10);
return true;
2003-05-19 20:07:00 +06:00
}
//=============================================================================
/*!
*
*/
//=============================================================================
2004-12-01 15:48:31 +05:00
static int isStudyLocked(const SALOMEDS::Study_var& theStudy){
return theStudy->GetProperties()->IsLocked();
}
static bool checkLock(const SALOMEDS::Study_var& theStudy) {
if (isStudyLocked(theStudy)) {
QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
QObject::tr("WRN_WARNING"),
QObject::tr("WRN_STUDY_LOCKED"),
QObject::tr("BUT_OK") );
return true;
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
return false;
2003-05-19 20:07:00 +06:00
}
2004-12-01 15:48:31 +05:00
//=======================================================================
//function : CheckActiveStudyLocked
//purpose :
//=======================================================================
2003-05-19 20:07:00 +06:00
2004-12-01 15:48:31 +05:00
bool SMESHGUI::ActiveStudyLocked()
2003-05-19 20:07:00 +06:00
{
2004-12-01 15:48:31 +05:00
SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
return checkLock( aStudy );
2003-05-19 20:07:00 +06:00
}
//=============================================================================
/*!
*
*/
//=============================================================================
2004-12-01 15:48:31 +05:00
bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent)
2004-06-18 14:34:31 +06:00
{
2004-12-01 15:48:31 +05:00
SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active
2003-05-19 20:07:00 +06:00
2004-12-01 15:48:31 +05:00
switch (theCommandID) {
case 33: // DELETE
if(checkLock(aStudy)) break;
::OnEditDelete();
break;
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
case 113: // IMPORT
case 112:
case 111:
2004-06-18 14:34:31 +06:00
{
2004-12-01 15:48:31 +05:00
if(checkLock(aStudy)) break;
::ImportMeshesFromFile(parent,SMESH::GetSMESHGen(),theCommandID);
break;
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
case 122: // EXPORT MED
case 121:
case 123:
2004-06-18 14:34:31 +06:00
{
2004-12-01 15:48:31 +05:00
::ExportMeshToFile(parent, theCommandID);
break;
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
case 200: // SCALAR BAR
2004-06-18 14:34:31 +06:00
{
2004-12-01 15:48:31 +05:00
SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
if( Sel && Sel->IObjectCount() ) {
Handle(SALOME_InteractiveObject) anIO = Sel->firstIObject();
if( anIO->hasEntry() ) {
if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) {
anActor->SetControlMode( SMESH_Actor::eNone );
}
}
}
break;
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
case 201:
2004-06-18 14:34:31 +06:00
{
2004-12-01 15:48:31 +05:00
SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( parent, Sel );
break;
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
case 1134: // Clipping
case 1133: // Tranparency
case 1132: // Colors / Size
2005-01-20 11:25:54 +05:00
// Display Mode
case 215: // Nodes
case 213: // Nodes
case 212: // Nodes
case 211: // Nodes
::SetDisplayMode(theCommandID);
break;
// Display Entity
case 217: // Edges
case 218: // Faces
case 219: // Volumes
case 220: // All Entity
::SetDisplayEntity(theCommandID);
break;
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
case 214: // UPDATE
2004-06-18 14:34:31 +06:00
{
2004-12-01 15:48:31 +05:00
if(checkLock(aStudy)) break;
SMESH::UpdateView();
break;
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
case 300: // ERASE
case 301: // DISPLAY
case 302: // DISPLAY ONLY
2004-06-18 14:34:31 +06:00
{
2004-12-01 15:48:31 +05:00
SMESH::EDisplaing anAction;
switch(theCommandID){
case 300: anAction = SMESH::eErase; break;
case 301: anAction = SMESH::eDisplay; break;
case 302: anAction = SMESH::eDisplayOnly; break;
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
for (; It.More(); It.Next()) {
Handle(SALOME_InteractiveObject) IOS = It.Value();
if (IOS->hasEntry()) {
SMESH::UpdateView(anAction,IOS->getEntry());
}
}
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
Sel->ClearIObjects();
break;
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
case 400: // NODES
2004-06-18 14:34:31 +06:00
{
2004-12-01 15:48:31 +05:00
if(checkLock(aStudy)) break;
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2005-01-20 11:25:54 +05:00
new SMESHGUI_NodesDlg(parent, "", Sel);
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
else {
2004-06-18 14:34:31 +06:00
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2004-12-01 15:48:31 +05:00
tr("SMESH_WRN_WARNING"),
tr("SMESH_WRN_VIEWER_VTK"),
2004-06-18 14:34:31 +06:00
tr("SMESH_BUT_OK"));
}
2004-12-01 15:48:31 +05:00
break;
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
case 2151: // FILTER
2004-06-18 14:34:31 +06:00
{
2004-12-01 15:48:31 +05:00
if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
{
EmitSignalDeactivateDialog();
2005-01-20 11:25:54 +05:00
new SMESHGUI_FilterDlg( parent, SMESH::EDGE );
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
break;
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
case 406: // MOVE NODE
{
if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
{
QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ),
tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
break;
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
if(checkLock(aStudy)) break;
SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
2005-01-20 11:25:54 +05:00
new SMESHGUI_MoveNodesDlg( parent, Sel );
2004-12-01 15:48:31 +05:00
break;
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
case 701: // COMPUTE MESH
{
if(checkLock(aStudy)) break;
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
int nbSel = Sel->IObjectCount();
if (nbSel != 1){
break;
}
2003-05-19 20:07:00 +06:00
2004-12-01 15:48:31 +05:00
SMESH::SMESH_Mesh_var aMesh;
SMESH::SMESH_subMesh_var aSubMesh;
Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
if (IObject->hasEntry()){
SALOMEDS::SObject_var aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
if ( aShapeObject->_is_nil() ) {
// imported mesh
break;
}
if(!aMeshSObj->_is_nil()) {
SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
if (!aMesh->_is_nil()){
GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
if (!refShapeObject->_is_nil()) {
if(!SMESH::GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
tr("SMESH_WRN_WARNING"),
tr("SMESH_WRN_MISSING_PARAMETERS"),
tr("SMESH_BUT_OK"));
break;
}
try{
if (SMESH::GetSMESHGen()->Compute(aMesh,refShapeObject))
SMESH::ModifiedMesh(aMeshSObj,true);
// TO Do : change icon of all submeshes
else
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
tr("SMESH_WRN_WARNING"),
tr("SMESH_WRN_COMPUTE_FAILED"),
tr("SMESH_BUT_OK"));
}
catch(const SALOME::SALOME_Exception & S_ex){
QtCatchCorbaException(S_ex);
}
}
}else if(!aSubMesh->_is_nil()){
aMesh = aSubMesh->GetFather();
GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj);
if(!refShapeObject->_is_nil()){
bool compute = SMESH::GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject);
if(!compute){
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
tr("SMESH_WRN_WARNING"),
tr("SMESH_WRN_MISSING_PARAMETERS"),
tr("SMESH_BUT_OK"));
break;
}
try{
if ( SMESH::GetSMESHGen()->Compute(aMesh,refShapeObject) )
SMESH::ModifiedMesh(aMeshSObj,true);
// TO Do : change icon of all submeshes
else
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
tr("SMESH_WRN_WARNING"),
tr("SMESH_WRN_COMPUTE_FAILED"),
tr("SMESH_BUT_OK"));
}catch(const SALOME::SALOME_Exception & S_ex){
QtCatchCorbaException(S_ex);
}
}
}
}
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
CORBA::Long anId = aStudy->StudyId();
TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry());
if(myAutomaticUpdate && aVisualObj){
aVisualObj->Update();
SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
if(!anActor){
anActor = SMESH::CreateActor(aStudy,IObject->getEntry());
if(anActor){
SMESH::DisplayActor(myActiveStudy->getActiveStudyFrame(),anActor); //apo
SMESH::FitAll();
}
}
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
}else{
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
tr("SMESH_WRN_WARNING"),
tr("SMESH_WRN_VIEWER_VTK"),
tr("SMESH_BUT_OK"));
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
break;
2004-06-18 14:34:31 +06:00
}
2003-05-19 20:07:00 +06:00
2004-12-01 15:48:31 +05:00
case 702: // ADD SUB MESH
{
if(checkLock(aStudy)) break;
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2005-01-20 11:25:54 +05:00
new SMESHGUI_AddSubMeshDlg(parent, "", Sel);
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
else {
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
tr("SMESH_BUT_OK"));
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
break;
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
case 703: // INIT MESH
{
if(checkLock(aStudy)) break;
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2005-01-20 11:25:54 +05:00
new SMESHGUI_InitMeshDlg(parent, "", Sel);
2004-12-01 15:48:31 +05:00
break;
2004-06-18 14:34:31 +06:00
}
2003-12-10 21:05:04 +05:00
2004-12-01 15:48:31 +05:00
case 704: // EDIT Hypothesis
{
if(checkLock(aStudy)) break;
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2005-01-20 11:25:54 +05:00
new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
2004-12-01 15:48:31 +05:00
break;
2004-06-18 14:34:31 +06:00
}
2003-05-19 20:07:00 +06:00
2004-12-01 15:48:31 +05:00
case 705: // EDIT Global Hypothesis
{
if(checkLock(aStudy)) break;
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2005-01-20 11:25:54 +05:00
new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
2004-12-01 15:48:31 +05:00
break;
2004-06-18 14:34:31 +06:00
}
2003-05-19 20:07:00 +06:00
2004-12-01 15:48:31 +05:00
case 706: // EDIT Local Hypothesis
{
if(checkLock(aStudy)) break;
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2005-01-20 11:25:54 +05:00
new SMESHGUI_EditHypothesesDlg(parent, "", Sel);
2004-12-01 15:48:31 +05:00
break;
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
case 407: // DIAGONAL INVERSION
case 408: // Delete diagonal
2004-06-18 14:34:31 +06:00
{
2004-12-01 15:48:31 +05:00
if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
2004-06-18 14:34:31 +06:00
{
2004-12-01 15:48:31 +05:00
QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ),
tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
break;
}
if ( checkLock( aStudy ) )
break;
SALOME_Selection *aSel =
SALOME_Selection::Selection( myActiveStudy->getSelection() );
/*Standard_Boolean aRes;
SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
if ( aMesh->_is_nil() )
{
QAD_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ),
tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) );
break;
}
*/
EmitSignalDeactivateDialog();
if ( theCommandID == 407 )
new SMESHGUI_TrianglesInversionDlg( parent, aSel );
else
new SMESHGUI_UnionOfTwoTrianglesDlg( parent, aSel );
break;
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
case 409: // Change orientation
case 410: // Union of triangles
case 411: // Cutting of quadrangles
2004-06-18 14:34:31 +06:00
{
2004-12-01 15:48:31 +05:00
if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
2004-06-18 14:34:31 +06:00
{
2004-12-01 15:48:31 +05:00
QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ),
tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
break;
2004-06-18 14:34:31 +06:00
}
2003-05-19 20:07:00 +06:00
2004-12-01 15:48:31 +05:00
if ( checkLock( aStudy ) )
break;
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
SALOME_Selection *aSel =
SALOME_Selection::Selection( myActiveStudy->getSelection() );
2003-05-19 20:07:00 +06:00
2004-12-01 15:48:31 +05:00
EmitSignalDeactivateDialog();
SMESHGUI_MultiEditDlg* aDlg;
if ( theCommandID == 409 )
aDlg = new SMESHGUI_ChangeOrientationDlg( parent, aSel );
else if ( theCommandID == 410 )
aDlg = new SMESHGUI_UnionOfTrianglesDlg( parent, aSel );
else
aDlg = new SMESHGUI_CuttingOfQuadsDlg( parent, aSel );
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
int x, y ;
DefineDlgPosition( aDlg, x, y );
aDlg->move( x, y );
aDlg->show();
break;
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
case 412: // Smoothing
{
if(checkLock(aStudy)) break;
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2005-01-20 11:25:54 +05:00
new SMESHGUI_SmoothingDlg(parent, "", Sel);
2004-12-01 15:48:31 +05:00
}
else {
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
tr("SMESH_BUT_OK"));
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
break;
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
case 413: // Extrusion
{
if(checkLock(aStudy)) break;
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2005-01-20 11:25:54 +05:00
new SMESHGUI_ExtrusionDlg(parent, "", Sel);
2004-12-01 15:48:31 +05:00
}
else {
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
tr("SMESH_BUT_OK"));
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
break;
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
case 414: // Revolution
{
if(checkLock(aStudy)) break;
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2005-01-20 11:25:54 +05:00
new SMESHGUI_RevolutionDlg(parent, "", Sel);
2004-12-01 15:48:31 +05:00
}
else {
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
tr("SMESH_BUT_OK"));
}
break;
}
case 415: // Pattern mapping
{
if ( checkLock( aStudy ) )
break;
if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
{
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(
myActiveStudy->getSelection() );
new SMESHGUI_MeshPatternDlg( parent, Sel );
}
else {
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
tr("SMESH_BUT_OK"));
}
break;
}
2005-01-20 11:25:54 +05:00
case 416: // Extrusion along a path
{
if(checkLock(aStudy)) break;
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
new SMESHGUI_ExtrusionAlongPathDlg(parent, Sel);
}
else {
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
tr("SMESH_BUT_OK"));
}
break;
}
2004-12-01 15:48:31 +05:00
case 801: // CREATE GROUP
{
if(checkLock(aStudy)) break;
EmitSignalDeactivateDialog();
SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
int nbSel = Sel->IObjectCount();
if (nbSel == 1) {
// check if mesh is selected
aMesh = SMESH::GetMeshByIO(Sel->firstIObject());
}
SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, aMesh);
aDlg->show();
break;
2004-06-18 14:34:31 +06:00
}
2003-05-19 20:07:00 +06:00
2004-12-01 15:48:31 +05:00
case 802: // CONSTRUCT GROUP
{
if(checkLock(aStudy)) break;
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
int nbSel = Sel->IObjectCount();
if (nbSel == 1) {
// check if submesh is selected
Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
if (IObject->hasEntry()) {
SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(IObject->getEntry());
if(!aSObj->_is_nil()) {
SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(aSObj->GetObject());
if (!aSubMesh->_is_nil()) {
try {
SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
// get submesh elements list by types
SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE);
SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE);
SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE);
SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
// create group for each type o elements
QString aName = IObject->getName();
if (aNodes->length() > 0) {
SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName);
aGroup->Add(aNodes.inout());
}
if (aEdges->length() > 0) {
SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName);
aGroup->Add(aEdges.inout());
}
if (aFaces->length() > 0) {
SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName);
aGroup->Add(aFaces.inout());
}
if (aVolumes->length() > 0) {
SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName);
aGroup->Add(aVolumes.inout());
}
myActiveStudy->updateObjBrowser(true);
}catch(const SALOME::SALOME_Exception & S_ex){
QtCatchCorbaException(S_ex);
}
}
}
2003-12-10 21:05:04 +05:00
}
2004-12-01 15:48:31 +05:00
}
break;
}
2003-05-19 20:07:00 +06:00
2004-12-01 15:48:31 +05:00
case 803: // EDIT GROUP
{
if(checkLock(aStudy)) break;
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy
SALOME_ListIteratorOfListIO It (IOs);
int nbSelectedGroups = 0;
for ( ; It.More(); It.Next() )
{
SMESH::SMESH_Group_var aGroup =
SMESH::IObjectToInterface<SMESH::SMESH_Group>(It.Value());
if (!aGroup->_is_nil()) {
nbSelectedGroups++;
SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, aGroup);
aDlg->show();
2003-12-10 21:05:04 +05:00
}
2004-12-01 15:48:31 +05:00
}
if (nbSelectedGroups == 0)
2003-12-10 21:05:04 +05:00
{
2004-12-01 15:48:31 +05:00
SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, SMESH::SMESH_Group::_nil());
aDlg->show();
2003-12-10 21:05:04 +05:00
}
2004-12-01 15:48:31 +05:00
break;
}
2003-05-19 20:07:00 +06:00
2004-12-01 15:48:31 +05:00
case 804: // Add elements to group
{
if(checkLock(aStudy)) break;
if (myState == 800) {
SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
if (aDlg) aDlg->onAdd();
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
break;
}
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
case 805: // Remove elements from group
{
if(checkLock(aStudy)) break;
if (myState == 800) {
SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox;
if (aDlg) aDlg->onRemove();
}
break;
}
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
case 810: // Union Groups
case 811: // Intersect groups
case 812: // Cut groups
{
if ( checkLock( aStudy ) )
break;
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(
myActiveStudy->getSelection() );
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
int aMode;
if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
else aMode = SMESHGUI_GroupOpDlg::CUT;
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
( new SMESHGUI_GroupOpDlg( parent, Sel, aMode ) )->show();
break;
}
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
case 813: // Delete groups with their contents
{
if ( checkLock( aStudy ) )
break;
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(
myActiveStudy->getSelection() );
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
( new SMESHGUI_DeleteGroupDlg( parent, Sel ) )->show();
break;
}
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
case 900: // MESH INFOS
{
EmitSignalDeactivateDialog();
SALOME_Selection *Sel =
SALOME_Selection::Selection(myActiveStudy->getSelection());
if ( Sel->IObjectCount() > 1 ) { // a dlg for each IO
SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy
SALOME_ListIteratorOfListIO It (IOs);
for ( ; It.More(); It.Next() ) {
Sel->ClearIObjects();
Sel->AddIObject( It.Value() );
2005-01-20 11:25:54 +05:00
new SMESHGUI_MeshInfosDlg(parent, "", false);
2004-12-01 15:48:31 +05:00
}
// restore selection
Sel->ClearIObjects();
for (It.Initialize( IOs ) ; It.More(); It.Next() )
Sel->AddIObject( It.Value() );
}
else
2005-01-20 11:25:54 +05:00
new SMESHGUI_MeshInfosDlg(parent, "", false);
2004-12-01 15:48:31 +05:00
break;
}
2004-06-18 14:34:31 +06:00
2004-12-17 16:07:35 +05:00
case 902: // STANDARD MESH INFOS
{
EmitSignalDeactivateDialog();
SALOME_Selection *Sel =
SALOME_Selection::Selection(myActiveStudy->getSelection());
if ( Sel->IObjectCount() > 1 ) { // a dlg for each IO
SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy
SALOME_ListIteratorOfListIO It (IOs);
for ( ; It.More(); It.Next() ) {
Sel->ClearIObjects();
Sel->AddIObject( It.Value() );
2005-01-20 11:25:54 +05:00
new SMESHGUI_StandardMeshInfosDlg(parent, "", false);
2004-12-17 16:07:35 +05:00
}
// restore selection
Sel->ClearIObjects();
for (It.Initialize( IOs ) ; It.More(); It.Next() )
Sel->AddIObject( It.Value() );
}
else
2005-01-20 11:25:54 +05:00
new SMESHGUI_StandardMeshInfosDlg(parent, "", false);
2004-12-17 16:07:35 +05:00
break;
}
2004-12-01 15:48:31 +05:00
case 1001: // AUTOMATIC UPDATE PREFERENCES
{
parent->menuBar()->setItemChecked(1001, !parent->menuBar()->isItemChecked(1001));
if (parent->menuBar()->isItemChecked(1001)) {
QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "true");
myAutomaticUpdate = true;
}
else {
QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "false");
myAutomaticUpdate = false;
}
break;
}
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
case 1003: // MESH PREFERENCES
{
::SetDisplaySettings();
break;
}
2003-05-19 20:07:00 +06:00
2004-12-01 15:48:31 +05:00
case 1005:
{
SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( parent );
break;
}
2003-05-19 20:07:00 +06:00
2005-01-20 11:25:54 +05:00
case 10070:
2004-12-01 15:48:31 +05:00
{
( new SMESHGUI_PrecisionDlg( parent ) )->exec();
break;
}
2003-05-19 20:07:00 +06:00
2005-01-20 11:25:54 +05:00
case 10071:
{
parent->menuBar()->setItemChecked(10071, !parent->menuBar()->isItemChecked(10071));
if (parent->menuBar()->isItemChecked(10071)) {
QAD_CONFIG->addSetting("SMESH:DispayEntity","true");
}
else {
QAD_CONFIG->addSetting("SMESH:DispayEntity","false");
}
break;
}
2004-12-01 15:48:31 +05:00
case 1006:
{
SMESHGUI_Preferences_SelectionDlg* aDlg =
new SMESHGUI_Preferences_SelectionDlg(parent);
2003-05-19 20:07:00 +06:00
2004-12-01 15:48:31 +05:00
QColor aColor;
QString SCr, SCg, SCb;
SCr = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorRed");
SCg = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorGreen");
SCb = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorBlue");
if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
else aColor = Qt::cyan;
aDlg->SetColor(1, aColor);
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
SCr = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorRed");
SCg = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorGreen");
SCb = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorBlue");
if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
else aColor = Qt::yellow;
aDlg->SetColor(2, aColor);
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
SCr = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorRed");
SCg = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorGreen");
SCb = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorBlue");
if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty())
aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt());
else aColor = Qt::white;
aDlg->SetColor(3, aColor);
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
QString SW1 = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectWidth");
if (SW1.isEmpty()) SW1 = "5";
aDlg->SetWidth(1, SW1.toInt());
QString SW2 = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectWidth");
if (SW2.isEmpty()) SW2 = "5";
aDlg->SetWidth(2, SW2.toInt());
QString SP1 = QAD_CONFIG->getSetting("SMESH:SettingsNodeSelectTol");
if (SP1.isEmpty()) SP1 = "0.025";
aDlg->SetPrecision(1, SP1.toDouble());
QString SP2 = QAD_CONFIG->getSetting("SMESH:SettingsElementsSelectTol");
if (SP2.isEmpty()) SP2 = "0.001";
aDlg->SetPrecision(2, SP2.toDouble());
if (aDlg->exec()) {
QColor aPreColor = aDlg->GetColor(1);
QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorRed", aPreColor.red());
QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorGreen", aPreColor.green());
QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorBlue", aPreColor.blue());
QColor aSelColor = aDlg->GetColor(2);
QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorRed", aSelColor.red());
QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorGreen", aSelColor.green());
QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorBlue", aSelColor.blue());
QColor aHiColor = aDlg->GetColor(3);
QAD_CONFIG->addSetting("SMESH:SettingsSelectColorRed", aHiColor.red());
QAD_CONFIG->addSetting("SMESH:SettingsSelectColorGreen", aHiColor.green());
QAD_CONFIG->addSetting("SMESH:SettingsSelectColorBlue", aHiColor.blue());
int aPreWidth = aDlg->GetWidth(1);
QAD_CONFIG->addSetting("SMESH:SettingsPreSelectWidth", aPreWidth);
int aSelWidth = aDlg->GetWidth(2);
QAD_CONFIG->addSetting("SMESH:SettingsItemSelectWidth", aSelWidth);
double aTolNodes = aDlg->GetPrecision(1);
QAD_CONFIG->addSetting("SMESH:SettingsNodeSelectTol", aTolNodes);
double aTolItems = aDlg->GetPrecision(2);
QAD_CONFIG->addSetting("SMESH:SettingsElementsSelectTol", aTolItems);
// update current study settings
SMESH::UpdateSelectionProp();
QAD_StudyFrame* studyFrame = myActiveStudy->getActiveStudyFrame();
if (studyFrame->getTypeView() == VIEW_VTK) {
VTKViewer_ViewFrame* aViewFrame = SMESH::GetVtkViewFrame(studyFrame);
// update VTK viewer properties
VTKViewer_RenderWindowInteractor* anInteractor = aViewFrame->getRWInteractor();
if (anInteractor) {
anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255.,
aSelColor.blue()/255., aSelWidth);
anInteractor->SetSelectionTolerance(aTolNodes, aTolItems);
VTKViewer_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
if (aStyle)
aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255.,
aPreColor.blue()/255., aPreWidth);
}
// update actors
vtkRenderer* aRenderer = aViewFrame->getRenderer();
vtkActorCollection *aCollection = aRenderer->GetActors();
aCollection->InitTraversal();
while(vtkActor *anAct = aCollection->GetNextActor()){
if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255.,
aHiColor.blue()/255.);
anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255.,
aPreColor.blue()/255.);
}
2004-06-18 14:34:31 +06:00
}
}
}
2004-12-01 15:48:31 +05:00
2004-06-18 14:34:31 +06:00
break;
}
2004-12-01 15:48:31 +05:00
case 1100: // EDIT HYPOTHESIS
2004-06-18 14:34:31 +06:00
{
2004-12-01 15:48:31 +05:00
if(checkLock(aStudy)) break;
SALOME_Selection *Sel =
SALOME_Selection::Selection(myActiveStudy->getSelection());
int nbSel = Sel->IObjectCount();
if (nbSel == 1) {
SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(Sel->firstIObject());
/* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */
/* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */
/* Warning : however by internal mechanism all subMeshes icons are changed ! */
if ( !Hyp->_is_nil() )
{
char* sName = Hyp->GetName();
SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
if (aCreator)
{
aCreator->EditHypothesis(Hyp);
}
else
{
// report error
}
}
}
2004-06-18 14:34:31 +06:00
break;
}
2004-12-01 15:48:31 +05:00
case 1101: // RENAME
2004-06-18 14:34:31 +06:00
{
2004-12-01 15:48:31 +05:00
if ( checkLock( aStudy ) )
break;
SALOME_Selection *Sel =
SALOME_Selection::Selection( myActiveStudy->getSelection() );
SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
for ( ; It.More(); It.Next() )
{
Handle(SALOME_InteractiveObject) IObject = It.Value();
SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
if ( !obj->_is_nil() )
{
if ( obj->FindAttribute(anAttr, "AttributeName") )
{
aName = SALOMEDS::AttributeName::_narrow( anAttr );
QString newName = QString(aName->Value());
newName = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), newName );
if ( !newName.isEmpty() )
{
myActiveStudy->renameIObject( IObject, newName );
// if current object is group update group's name
SMESH::SMESH_GroupBase_var aGroup =
SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
if (!aGroup->_is_nil() )
aGroup->SetName( newName.latin1() );
}
}
}
}
2004-06-18 14:34:31 +06:00
break;
}
2004-12-01 15:48:31 +05:00
case 1102: // REMOVE HYPOTHESIS / ALGORITHMS
2004-06-18 14:34:31 +06:00
{
if(checkLock(aStudy)) break;
2004-12-01 15:48:31 +05:00
QAD_WaitCursor wc;
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
for (int i = 0; It.More(); It.Next(), i++) {
Handle(SALOME_InteractiveObject) IObject = It.Value();
SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject);
}
Sel->ClearIObjects();
myActiveStudy->updateObjBrowser(true);
2004-06-18 14:34:31 +06:00
break;
}
2004-12-01 15:48:31 +05:00
case 401: // GEOM::EDGE
case 4021: // TRIANGLE
case 4022: // QUAD
case 4031: // TETRA
case 4032: // HEXA
2004-06-18 14:34:31 +06:00
{
2004-12-01 15:48:31 +05:00
if(checkLock(aStudy)) break;
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
SMDSAbs_ElementType type = SMDSAbs_Edge;
int nbNodes = 2;
switch (theCommandID) {
case 4021: // TRIANGLE
type = SMDSAbs_Face; nbNodes = 3; break;
case 4022: // QUAD
type = SMDSAbs_Face; nbNodes = 4; break;
case 4031: // TETRA
type = SMDSAbs_Volume; nbNodes = 4; break;
case 4032: // HEXA
type = SMDSAbs_Volume; nbNodes = 8; break;
default:;
}
2005-01-20 11:25:54 +05:00
new SMESHGUI_AddMeshElementDlg(parent, "", Sel, type, nbNodes);
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
else {
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
tr("SMESH_BUT_OK"));
2004-06-18 14:34:31 +06:00
}
break;
}
2004-12-01 15:48:31 +05:00
case 4041: // REMOVES NODES
2004-06-18 14:34:31 +06:00
{
if(checkLock(aStudy)) break;
2004-12-01 15:48:31 +05:00
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2005-01-20 11:25:54 +05:00
new SMESHGUI_RemoveNodesDlg(parent, "", Sel);
2004-06-18 14:34:31 +06:00
}
else {
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2004-12-01 15:48:31 +05:00
tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
2004-06-18 14:34:31 +06:00
tr("SMESH_BUT_OK"));
}
break;
}
2004-12-01 15:48:31 +05:00
case 4042: // REMOVES ELEMENTS
2004-06-18 14:34:31 +06:00
{
2004-12-01 15:48:31 +05:00
if(checkLock(aStudy)) break;
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2005-01-20 11:25:54 +05:00
new SMESHGUI_RemoveElementsDlg(parent, "", Sel);
2004-12-01 15:48:31 +05:00
}
else
{
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
tr("SMESH_BUT_OK"));
}
break;
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
case 4051: // RENUMBERING NODES
2004-06-18 14:34:31 +06:00
{
if(checkLock(aStudy)) break;
2004-12-01 15:48:31 +05:00
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2005-01-20 11:25:54 +05:00
new SMESHGUI_RenumberingDlg(parent, "", Sel, 0);
2004-12-01 15:48:31 +05:00
}
else
{
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
tr("SMESH_BUT_OK"));
}
2004-06-18 14:34:31 +06:00
break;
}
2004-12-01 15:48:31 +05:00
case 4052: // RENUMBERING ELEMENTS
2004-06-18 14:34:31 +06:00
{
if(checkLock(aStudy)) break;
2004-12-01 15:48:31 +05:00
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2005-01-20 11:25:54 +05:00
new SMESHGUI_RenumberingDlg(parent, "", Sel, 1);
2004-12-01 15:48:31 +05:00
}
else
{
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
tr("SMESH_BUT_OK"));
2003-12-10 21:05:04 +05:00
}
2004-06-18 14:34:31 +06:00
break;
}
2004-12-01 15:48:31 +05:00
case 4061: // TRANSLATION
2004-06-18 14:34:31 +06:00
{
if(checkLock(aStudy)) break;
2004-12-01 15:48:31 +05:00
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2005-01-20 11:25:54 +05:00
new SMESHGUI_TranslationDlg(parent, "", Sel);
2004-06-18 14:34:31 +06:00
}
else {
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
tr("SMESH_BUT_OK"));
}
break;
}
2004-12-01 15:48:31 +05:00
case 4062: // ROTATION
2004-06-18 14:34:31 +06:00
{
if(checkLock(aStudy)) break;
2004-12-01 15:48:31 +05:00
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2005-01-20 11:25:54 +05:00
new SMESHGUI_RotationDlg(parent, "", Sel);
2004-12-01 15:48:31 +05:00
}
else {
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
tr("SMESH_BUT_OK"));
}
2004-06-18 14:34:31 +06:00
break;
}
2004-12-01 15:48:31 +05:00
case 4063: // SYMMETRY
2004-06-18 14:34:31 +06:00
{
if(checkLock(aStudy)) break;
2004-12-01 15:48:31 +05:00
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2005-01-20 11:25:54 +05:00
new SMESHGUI_SymmetryDlg(parent, "", Sel);
2004-12-01 15:48:31 +05:00
}
else {
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
tr("SMESH_BUT_OK"));
2004-06-18 14:34:31 +06:00
}
break;
}
2004-12-01 15:48:31 +05:00
case 4064: // SEWING
2004-06-18 14:34:31 +06:00
{
if(checkLock(aStudy)) break;
2004-12-01 15:48:31 +05:00
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2005-01-20 11:25:54 +05:00
new SMESHGUI_SewingDlg(parent, "", Sel);
2004-12-01 15:48:31 +05:00
}
else {
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
tr("SMESH_BUT_OK"));
2004-06-18 14:34:31 +06:00
}
break;
}
2004-12-01 15:48:31 +05:00
case 4065: // MERGE NODES
2004-06-18 14:34:31 +06:00
{
if(checkLock(aStudy)) break;
2004-12-01 15:48:31 +05:00
if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
EmitSignalDeactivateDialog();
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
2005-01-20 11:25:54 +05:00
new SMESHGUI_MergeNodesDlg(parent, "", Sel);
2004-12-01 15:48:31 +05:00
}
else {
QAD_MessageBox::warn1(QAD_Application::getDesktop(),
tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
tr("SMESH_BUT_OK"));
2004-06-18 14:34:31 +06:00
}
break;
}
2004-12-01 15:48:31 +05:00
2004-06-18 14:34:31 +06:00
2004-12-01 15:48:31 +05:00
case 5000: // HYPOTHESIS
2004-06-18 14:34:31 +06:00
{
if(checkLock(aStudy)) break;
2004-12-01 15:48:31 +05:00
EmitSignalDeactivateDialog();
2005-01-20 11:25:54 +05:00
new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, false);
2004-06-18 14:34:31 +06:00
break;
}
2004-12-01 15:48:31 +05:00
case 5010: // ALGO
2004-06-18 14:34:31 +06:00
{
if(checkLock(aStudy)) break;
2004-12-01 15:48:31 +05:00
EmitSignalDeactivateDialog();
2005-01-20 11:25:54 +05:00
new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, true);
2004-06-18 14:34:31 +06:00
break;
}
2004-12-01 15:48:31 +05:00
case 5105: // Library of selection filters
{
static QValueList<int> aTypes;
if ( aTypes.isEmpty() )
2004-06-18 14:34:31 +06:00
{
2004-12-01 15:48:31 +05:00
aTypes.append( SMESH::NODE );
aTypes.append( SMESH::EDGE );
aTypes.append( SMESH::FACE );
aTypes.append( SMESH::VOLUME );
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
new SMESHGUI_FilterLibraryDlg( parent, aTypes, SMESHGUI_FilterLibraryDlg::EDIT );
}
break;
2004-06-18 14:34:31 +06:00
2005-01-20 11:25:54 +05:00
case 6017: // CONTROLS
case 6016:
2004-12-01 15:48:31 +05:00
case 6015:
case 6014:
case 6013:
case 6012:
case 6011:
case 6001:
2005-01-20 11:25:54 +05:00
case 6018:
case 6019:
2004-12-01 15:48:31 +05:00
case 6002:
case 6003:
case 6004:
if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
if ( Sel->IObjectCount() == 1 && Sel->firstIObject()->hasEntry() ) {
SALOMEDS::SObject_var SO = aStudy->FindObjectID( Sel->firstIObject()->getEntry() );
if ( !SO->_is_nil() ) {
CORBA::Object_var aObject = SO->GetObject();
SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject );
SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject );
SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject );
if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) {
::Control( theCommandID );
break;
}
}
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
QAD_MessageBox::warn1(GetDesktop(),
tr( "SMESH_WRN_WARNING" ),
tr( "SMESH_BAD_SELECTION" ),
tr( "SMESH_BUT_OK" ) );
2004-06-18 14:34:31 +06:00
break;
}
else {
2004-12-01 15:48:31 +05:00
QAD_MessageBox::warn1(GetDesktop(),
2004-06-18 14:34:31 +06:00
tr( "SMESH_WRN_WARNING" ),
tr( "NOT_A_VTK_VIEWER" ),
2004-12-01 15:48:31 +05:00
tr( "SMESH_BUT_OK" ) );
}
break;
case 9010:
{
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
if (Sel->IObjectCount() == 1) {
Handle(SALOME_InteractiveObject) anIObject = Sel->firstIObject();
if(anIObject->hasEntry())
if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2004-06-18 14:34:31 +06:00
}
}
2004-12-01 15:48:31 +05:00
break;
}
case 9011:
{
SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection());
if (Sel->IObjectCount() == 1) {
Handle(SALOME_InteractiveObject) anIObject = Sel->firstIObject();
if(anIObject->hasEntry())
if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
anActor->SetCellsLabeled( !anActor->GetCellsLabeled() );
}
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
break;
}
case 10001: // DISPLAY MODE PREFERENCE
{
// Wireframe
parent->menuBar()->setItemChecked(10001, true);
parent->menuBar()->setItemChecked(10002, false);
parent->menuBar()->setItemChecked(10004, false);
parent->menuBar()->setItemEnabled(10003, true);
QAD_CONFIG->addSetting("SMESH:DisplayMode", "Wireframe");
break;
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
case 10002:
{
parent->menuBar()->setItemChecked(10002, true);
parent->menuBar()->setItemChecked(10001, false);
parent->menuBar()->setItemChecked(10004, false);
parent->menuBar()->setItemEnabled(10003, true);
QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading");
break;
}
case 10003:
{
parent->menuBar()->setItemChecked(10003,!parent->menuBar()->isItemChecked(10003));
QAD_CONFIG->addSetting("SMESH:Shrink", parent->menuBar()->isItemChecked(10003) ? "yes" : "no");
break;
}
case 10004:
{
parent->menuBar()->setItemChecked(10001, false);
parent->menuBar()->setItemChecked(10004, true);
parent->menuBar()->setItemChecked(10002, false);
parent->menuBar()->setItemEnabled(10003, false);
QAD_CONFIG->addSetting("SMESH:DisplayMode", "Nodes");
break;
}
2004-06-18 14:34:31 +06:00
}
2003-12-10 21:05:04 +05:00
2004-12-01 15:48:31 +05:00
myActiveStudy->updateObjBrowser(true);
return true;
2003-05-19 20:07:00 +06:00
}
//=============================================================================
/*!
*
*/
//=============================================================================
2004-12-01 15:48:31 +05:00
bool SMESHGUI::OnMousePress(QMouseEvent * pe, QAD_Desktop * parent,
QAD_StudyFrame * studyFrame)
2003-05-19 20:07:00 +06:00
{
2004-12-01 15:48:31 +05:00
return false;
2003-12-10 21:05:04 +05:00
}
2003-05-19 20:07:00 +06:00
//=============================================================================
/*!
*
*/
//=============================================================================
2004-12-01 15:48:31 +05:00
bool SMESHGUI::OnMouseMove(QMouseEvent * pe, QAD_Desktop * parent,
QAD_StudyFrame * studyFrame)
2003-05-19 20:07:00 +06:00
{
2004-12-01 15:48:31 +05:00
return true;
2003-12-10 21:05:04 +05:00
}
2003-05-19 20:07:00 +06:00
//=============================================================================
/*!
*
*/
//=============================================================================
2004-12-01 15:48:31 +05:00
bool SMESHGUI::OnKeyPress(QKeyEvent * pe, QAD_Desktop * parent,
QAD_StudyFrame * studyFrame)
2003-05-19 20:07:00 +06:00
{
2004-12-01 15:48:31 +05:00
return true;
2003-12-10 21:05:04 +05:00
}
2003-05-19 20:07:00 +06:00
//=============================================================================
/*!
*
*/
//=============================================================================
2004-12-01 15:48:31 +05:00
bool SMESHGUI::SetSettings(QAD_Desktop * parent)
2003-05-19 20:07:00 +06:00
{
2004-12-01 15:48:31 +05:00
MESSAGE("SMESHGUI::SetSettings.");
SMESHGUI::GetSMESHGUI();
2003-12-10 21:05:04 +05:00
2004-12-01 15:48:31 +05:00
/* Display mode */
QString DisplayMode = "Shading";
if ( QAD_CONFIG->hasSetting("SMESH:DisplayMode") )
DisplayMode = QAD_CONFIG->getSetting("SMESH:DisplayMode");
else
QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading");
2003-12-10 21:05:04 +05:00
2004-12-01 15:48:31 +05:00
bool Shrink = false;
if ( QAD_CONFIG->hasSetting("SMESH:Shrink") )
Shrink = QAD_CONFIG->getSetting("SMESH:Shrink") == "yes";
2003-12-10 21:05:04 +05:00
2004-12-01 15:48:31 +05:00
if (DisplayMode == "Wireframe") {
// wireframe
parent->menuBar()->setItemChecked(10004, false);
parent->menuBar()->setItemChecked(10002, false);
parent->menuBar()->setItemChecked(10001, true);
parent->menuBar()->setItemEnabled(10003, true);
}
else if (DisplayMode == "Nodes") {
// poins
parent->menuBar()->setItemChecked(10004, true);
parent->menuBar()->setItemChecked(10002, false);
parent->menuBar()->setItemChecked(10001, false);
parent->menuBar()->setItemEnabled(10003, false);
}
else {
// default is shading
parent->menuBar()->setItemChecked(10004, false);
parent->menuBar()->setItemChecked(10002, true);
parent->menuBar()->setItemChecked(10001, false);
parent->menuBar()->setItemEnabled(10003, true);
}
parent->menuBar()->setItemChecked(10003, Shrink);
2003-05-19 20:07:00 +06:00
2004-12-01 15:48:31 +05:00
/* Automatic Update */
QString AutoUpdate = QAD_CONFIG->getSetting("SMESH:AutomaticUpdate");
if (AutoUpdate.compare("true") == 0) {
parent->menuBar()->setItemChecked(1001, true);
myAutomaticUpdate = true;
}
else {
parent->menuBar()->setItemChecked(1001, false);
myAutomaticUpdate = false;
}
2003-12-10 21:05:04 +05:00
2005-01-20 11:25:54 +05:00
QString anIsDisplayEntity = QAD_CONFIG->getSetting("SMESH:DispayEntity");
if(anIsDisplayEntity.compare("true") == 0)
parent->menuBar()->setItemChecked(10071,true);
else
parent->menuBar()->setItemChecked(10071,false);
2004-12-01 15:48:31 +05:00
/* Selection */
SMESH::UpdateSelectionProp();
2003-05-19 20:07:00 +06:00
2004-12-01 15:48:31 +05:00
/* menus disable */
parent->menuBar()->setItemEnabled(111, false); // IMPORT DAT
//parent->menuBar()->setItemEnabled(112, false); // IMPORT UNV
2003-05-19 20:07:00 +06:00
2004-12-01 15:48:31 +05:00
return true;
2003-12-10 21:05:04 +05:00
}
2003-05-19 20:07:00 +06:00
//=============================================================================
/*!
*
*/
//=============================================================================
2004-12-01 15:48:31 +05:00
void SMESHGUI::DefinePopup(QString & theContext, QString & theParent, QString & theObject)
2003-05-19 20:07:00 +06:00
{
2004-12-01 15:48:31 +05:00
// NRI : Temporary added
// if ( myStudy->GetProperties()->IsLocked() ) {
// theObject = "NothingSelected";
// theContext = "NothingSelected";
// }
// NRI
2003-05-19 20:07:00 +06:00
2004-12-01 15:48:31 +05:00
SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
int nbSel = Sel->IObjectCount();
switch ( nbSel ) {
case 0:
theObject = "NothingSelected";
theContext = "NothingSelected";
break;
case 1:
if ( myState == 800 && Sel->HasIndex( Sel->firstIObject() ) )
theObject = "Elements";
else
theObject = ::CheckTypeObject( Sel->firstIObject() );
theContext = "";
break;
default:
theObject = ::CheckHomogeneousSelection();
theContext = "";
2004-06-18 14:34:31 +06:00
}
2003-12-10 21:05:04 +05:00
}
2003-05-19 20:07:00 +06:00
//=============================================================================
/*!
*
*/
//=============================================================================
2004-12-01 15:48:31 +05:00
bool SMESHGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext,
const QString& theParent, const QString& theObject)
2003-12-10 21:05:04 +05:00
{
2004-12-01 15:48:31 +05:00
// get active study frame
QAD_StudyFrame* studyFrame = myActiveStudy->getActiveStudyFrame();
// get parent component which selected object(s) belongs to
QString parentComp = ( (SALOMEGUI_Desktop*)parent )->getComponentFromSelection();
// get selection
SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
int nbSel = Sel->IObjectCount();
if ( nbSel == 0 ) {
popup->clear();
}
else if ( nbSel == 1 ) {
if ( parentComp != parent->getActiveComponent() ) {
// object not belongs to SMESH module - remove all commands except common Display/Erase...
while ( 1 ) {
int id = popup->idAt( 0 );
if ( id <= QAD_TopLabel_Popup_ID )
popup->removeItemAt( 0 );
else
break;
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
}
else {
// get selected interactive object
Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
SALOMEDS::SObject_var SO = SMESH::GetActiveStudyDocument()->FindObjectID( IObject->getEntry() );
// find popup menu's TopLabel item
int topItem = popup->indexOf( QAD_TopLabel_Popup_ID );
if ( topItem >= 0 ) {
if ( theParent == "Viewer" ) {
// set bold font for popup menu's TopLabel item (Viewer popup)
2004-12-17 16:07:35 +05:00
QFont fnt = popup->font(); fnt.setBold( TRUE );
2004-12-01 15:48:31 +05:00
popup->removeItem( QAD_TopLabel_Popup_ID );
popup->insertItem( new CustomItem( QString( IObject->getName() ), fnt ), QAD_TopLabel_Popup_ID, topItem );
}
else if ( theParent == "ObjectBrowser" ) {
// remove popup menu's TopLabel item (Object Browser popup)
popup->removeItem( QAD_TopLabel_Popup_ID );
2004-06-18 14:34:31 +06:00
}
}
2004-12-01 15:48:31 +05:00
if ( theObject == "Hypothesis" || theObject == "Algorithm" ) {
// remove Display/Erase commands
popup->removeItem( QAD_Display_Popup_ID );
popup->removeItem( QAD_DisplayOnly_Popup_ID );
popup->removeItem( QAD_Erase_Popup_ID );
// remove "Unassign ..." command if hyp/algo is not assigned
if ( SO->_is_nil() || !IObject->hasReference()/* !IsReferencedObject( SO ) */)
popup->removeItem( 1102 );
2004-06-18 14:34:31 +06:00
}
2004-12-01 15:48:31 +05:00
else if ( theObject == "Mesh" || theObject == "SubMesh" || theObject == "Group" ) {
// get actor
GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( SO );
if ( aShapeObject->_is_nil() ) {
// imported mesh
popup->removeItem( 701 ); // Compute
popup->removeItem( 705 ); // Edit hypothesis
popup->removeItem( 706 ); // ...
}
SMESH::SMESH_GroupOnGeom_var aGeomGroup =
SMESH::SMESH_GroupOnGeom::_narrow( SO->GetObject() );
if ( !aGeomGroup->_is_nil() ) // group linked on geometry
popup->removeItem( 803 ); // EDIT GROUP
2005-01-20 11:25:54 +05:00
SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
2004-12-01 15:48:31 +05:00
// if object has actor
2005-01-20 11:25:54 +05:00
if ( anActor && studyFrame->getTypeView() == VIEW_VTK ) {
2004-12-01 15:48:31 +05:00
VTKViewer_RenderWindowInteractor* myRenderInter = SMESH::GetCurrentVtkView()->getRWInteractor();
if ( myRenderInter->isVisible( IObject ) ) {
popup->removeItem( QAD_Display_Popup_ID );
2005-01-20 11:25:54 +05:00
popup->setItemChecked( 9010, anActor->GetPointsLabeled() ); // Numbering / Display Nodes #
popup->setItemChecked( 9011, anActor->GetCellsLabeled() ); // Numbering / Display Elements #
TVisualObjPtr aVisualObj = anActor->GetObject();
int aNbEdges = aVisualObj->GetNbEntities(SMDSAbs_Edge);
int aNbFaces = aVisualObj->GetNbEntities(SMDSAbs_Face);
int aNbVolumes = aVisualObj->GetNbEntities(SMDSAbs_Volume);
2004-12-01 15:48:31 +05:00
QMenuItem* mi = popup->findItem( 1131 );
if ( mi && mi->popup() ) {
2005-01-20 11:25:54 +05:00
int prType = anActor->GetRepresentation();
2004-12-01 15:48:31 +05:00
// Display Mode / Wireframe
2005-01-20 11:25:54 +05:00
if(aNbVolumes == 0 && aNbFaces == 0 && aNbEdges == 0){
2004-12-01 15:48:31 +05:00
mi->popup()->removeItem( 211 );
}else{
mi->popup()->setItemChecked( 211, prType == SMESH_Actor::eEdge );
}
// Display Mode / Shading
2005-01-20 11:25:54 +05:00
if(aNbFaces == 0 && aNbVolumes == 0){
2004-12-01 15:48:31 +05:00
mi->popup()->removeItem( 212 );
}else{
mi->popup()->setItemChecked( 212, prType == SMESH_Actor::eSurface );
}
// Display Mode / Points
mi->popup()->setItemChecked( 215, prType == SMESH_Actor::ePoint );
// Display Mode / Shrink
2005-01-20 11:25:54 +05:00
bool isShrunk = anActor->IsShrunk();
bool isShrunkable = anActor->IsShrunkable();
2004-12-01 15:48:31 +05:00
mi->popup()->setItemChecked( 213, isShrunk );
mi->popup()->setItemEnabled( 213, prType != SMESH_Actor::ePoint && isShrunkable);
}
2005-01-20 11:25:54 +05:00
// Display Entity
mi = popup->findItem( 1135 );
int aIsSomething=0;
if (aNbVolumes>0) aIsSomething++;
if (aNbFaces>0) aIsSomething++;
if (aNbEdges>0) aIsSomething++;
if ( mi && (aIsSomething <= 1)){
popup->removeItem(1135);
}else if ( mi && mi->popup() ) {
QPopupMenu* aPopup = mi->popup();
unsigned int aMode = anActor->GetEntityMode();
bool aIsVolumesMode = aMode & SMESH_Actor::eVolumes;
bool aIsFacesMode = aMode & SMESH_Actor::eFaces;
bool aIsEdgesMode = aMode & SMESH_Actor::eEdges;
if(aNbVolumes == 0)
aPopup->removeItem( 219 );
else
aPopup->setItemChecked( 219, aIsVolumesMode );
if(aNbFaces == 0)
aPopup->removeItem( 218 );
else
aPopup->setItemChecked( 218, aIsFacesMode );
if(aNbEdges == 0)
aPopup->removeItem( 217 );
else
aPopup->setItemChecked( 217, aIsEdgesMode );
bool aIsRemove = (aNbVolumes == 0 || aIsVolumesMode);
aIsRemove &= (aNbFaces == 0 || aIsFacesMode);
aIsRemove &= (aNbEdges == 0 || aIsEdgesMode);
if(aIsRemove)
aPopup->removeItem( 220 );
}
// Controls
2004-12-01 15:48:31 +05:00
mi = popup->findItem( 2000 );
if ( mi && mi->popup() ) {
2005-01-20 11:25:54 +05:00
SMESH_Actor::eControl cMode = anActor->GetControlMode();
2004-12-01 15:48:31 +05:00
switch ( cMode ) {
2005-01-20 11:25:54 +05:00
case SMESH_Actor::eLength:
2004-12-01 15:48:31 +05:00
mi->popup()->setItemChecked( 6001, true ); break;
2005-01-20 11:25:54 +05:00
case SMESH_Actor::eLength2D:
mi->popup()->setItemChecked( 6018, true ); break;
2004-12-01 15:48:31 +05:00
case SMESH_Actor::eFreeEdges:
mi->popup()->setItemChecked( 6002, true );
mi->popup()->removeItem( 201 );
break;
case SMESH_Actor::eFreeBorders:
mi->popup()->setItemChecked( 6003, true );
mi->popup()->removeItem( 201 );
break;
case SMESH_Actor::eMultiConnection:
mi->popup()->setItemChecked( 6004, true ); break;
2005-01-20 11:25:54 +05:00
case SMESH_Actor::eMultiConnection2D:
mi->popup()->setItemChecked( 6019, true ); break;
2004-12-01 15:48:31 +05:00
case SMESH_Actor::eArea:
mi->popup()->setItemChecked( 6011, true ); break;
case SMESH_Actor::eTaper:
mi->popup()->setItemChecked( 6012, true ); break;
case SMESH_Actor::eAspectRatio:
mi->popup()->setItemChecked( 6013, true ); break;
2005-01-20 11:25:54 +05:00
case SMESH_Actor::eAspectRatio3D:
mi->popup()->setItemChecked( 6017, true ); break;
2004-12-01 15:48:31 +05:00
case SMESH_Actor::eMinimumAngle:
mi->popup()->setItemChecked( 6014, true ); break;
case SMESH_Actor::eWarping:
mi->popup()->setItemChecked( 6015, true ); break;
case SMESH_Actor::eSkew:
mi->popup()->setItemChecked( 6016, true ); break;
case SMESH_Actor::eNone:
default:
mi->popup()->removeItem( 200 );
mi->popup()->removeItem( 201 );
break;
}
2005-01-20 11:25:54 +05:00
TVisualObjPtr aVisualObj = anActor->GetObject();
if(aNbEdges == 0){
2004-12-01 15:48:31 +05:00
mi->popup()->removeItem( 6001 );
mi->popup()->removeItem( 6003 );
mi->popup()->removeItem( 6004 );
}
2005-01-20 11:25:54 +05:00
if(aNbFaces == 0){
mi->popup()->removeItem( 6018 );
2004-12-01 15:48:31 +05:00
mi->popup()->removeItem( 6002 );
mi->popup()->removeItem( 6011 );
mi->popup()->removeItem( 6012 );
mi->popup()->removeItem( 6013 );
mi->popup()->removeItem( 6014 );
mi->popup()->removeItem( 6015 );
mi->popup()->removeItem( 6016 );
2005-01-20 11:25:54 +05:00
mi->popup()->removeItem( 6019 );
}
if(aNbVolumes == 0){
mi->popup()->removeItem( 6017 );
2004-12-01 15:48:31 +05:00
}
2005-01-20 11:25:54 +05:00
if(aNbFaces == 0 && aNbEdges == 0 && aNbVolumes == 0)
2004-12-01 15:48:31 +05:00
popup->removeItem( 2000 ); // Scalar Bar
}
}
else {
popup->removeItem( QAD_Erase_Popup_ID );
popup->removeItem( 114 ); // Numbering popup menu
popup->removeItem( 1131 ); // Display mode
popup->removeItem( 1132 ); // Color / size
popup->removeItem( 1133 ); // Transparency
popup->removeItem( 1134 ); // Clipping
popup->removeItem( 2000 ); // Scalar Bar
}
2005-02-03 18:24:46 +05:00
// VSR 03/02/05 - check if actor is empty ----- start -----
vtkUnstructuredGrid* vtkGrid = anActor->GetUnstructuredGrid();
if ( vtkGrid->GetNumberOfPoints() + vtkGrid->GetNumberOfCells() == 0 ) {
popup->removeItem( QAD_Display_Popup_ID );
popup->removeItem( QAD_DisplayOnly_Popup_ID );
popup->removeItem( QAD_Erase_Popup_ID );
}
// VSR 03/02/05 - check if actor is empty ----- finish -----
2004-12-01 15:48:31 +05:00
}
else {
// object doesn't have actor
CORBA::Object_var anObject = SO->GetObject();
bool bDisplay = false;
if ( !CORBA::is_nil( anObject ) ) {
SMESH::SMESH_Mesh_var aMeshObj = SMESH::SMESH_Mesh::_narrow( anObject );
if ( !aMeshObj->_is_nil() && ( aMeshObj->NbNodes() > 0 || aMeshObj->NbFaces() > 0 || aMeshObj->NbVolumes() > 0 ) )
bDisplay = true;
SMESH::SMESH_subMesh_var aSubMeshObj = SMESH::SMESH_subMesh::_narrow( anObject );
if ( !aSubMeshObj->_is_nil() && ( aSubMeshObj->GetNumberOfNodes(false) > 0 || aSubMeshObj->GetNumberOfElements() > 0 ) )
bDisplay = true;
SMESH::SMESH_GroupBase_var aGroupObj = SMESH::SMESH_GroupBase::_narrow( anObject );
if ( !aGroupObj->_is_nil() && aGroupObj->Size() > 0 )
bDisplay = true;
}
if ( !bDisplay ) {
popup->removeItem( QAD_Display_Popup_ID );
popup->removeItem( QAD_DisplayOnly_Popup_ID );
}
popup->removeItem( QAD_Erase_Popup_ID );
popup->removeItem( 114 ); // Numbering popup menu
popup->removeItem( 1131 ); // Display mode
popup->removeItem( 1132 ); // Color / size
popup->removeItem( 1133 ); // Transparency
popup->removeItem( 1134 ); // Clipping
popup->removeItem( 2000 ); // Scalar Bar
2004-06-18 14:34:31 +06:00
}
}
2004-12-01 15:48:31 +05:00
else if( theObject!="Component" ) {
// another SMESH object
popup->removeItem( QAD_Display_Popup_ID );
popup->removeItem( QAD_DisplayOnly_Popup_ID );
popup->removeItem( QAD_Erase_Popup_ID );
}
2004-06-18 14:34:31 +06:00
}
}
2004-12-01 15:48:31 +05:00
else {
// multiple selection
if ( parentComp != parent->getActiveComponent() ) {
// object not belongs to SMESH module - remove all commands except common Display/Erase...
while ( 1 ) {
int id = popup->idAt( 0 );
if ( id <= QAD_TopLabel_Popup_ID )
popup->removeItemAt( 0 );
else
break;
}
if ( parentComp.isNull() ) {
// objects from different components are selected
popup->removeItem( QAD_DisplayOnly_Popup_ID );
popup->removeItem( QAD_Display_Popup_ID );
popup->removeItem( QAD_Erase_Popup_ID );
}
}
else {
QString type = ::CheckHomogeneousSelection();
if ( type != "Heterogeneous Selection" ) {
int topItem = popup->indexOf( QAD_TopLabel_Popup_ID );
if ( topItem >= 0 ) {
// set bold font for popup menu's TopLabel item
2004-12-17 16:07:35 +05:00
QFont fnt = popup->font(); fnt.setBold( TRUE );
2004-12-01 15:48:31 +05:00
popup->removeItem( QAD_TopLabel_Popup_ID );
popup->insertItem( new CustomItem( QString("%1 ").arg( nbSel ) + type + "(s) ", fnt ), QAD_TopLabel_Popup_ID, topItem );
2004-06-18 14:34:31 +06:00
}
}
}
}
2004-12-01 15:48:31 +05:00
return false;
2003-05-19 20:07:00 +06:00
}
2004-12-01 15:48:31 +05:00
2003-05-19 20:07:00 +06:00
//=============================================================================
2004-12-01 15:48:31 +05:00
/*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
* Purpose: ensures that the actor for the given <theIO> exists in the active VTK view
2003-05-19 20:07:00 +06:00
*/
//=============================================================================
2004-12-01 15:48:31 +05:00
void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO,
QAD_ViewFrame* )
2003-05-19 20:07:00 +06:00
{
2004-12-01 15:48:31 +05:00
if(theIO->hasEntry()){
QAD_Study* aStudy = SMESHGUI::GetSMESHGUI()->GetActiveStudy();
QAD_StudyFrame *aStudyFrame = aStudy->getActiveStudyFrame();
SMESH::UpdateView(aStudyFrame,SMESH::eDisplay,theIO->getEntry());
}
2003-05-19 20:07:00 +06:00
}
2004-12-01 15:48:31 +05:00
void SMESHGUI::SupportedViewType(int *buffer, int bufferSize)
2003-05-19 20:07:00 +06:00
{
2004-12-01 15:48:31 +05:00
if (!buffer || !bufferSize)
2004-06-18 14:34:31 +06:00
return;
2004-12-01 15:48:31 +05:00
buffer[0] = (int)VIEW_VTK;
2004-06-18 14:34:31 +06:00
}
2003-12-10 21:05:04 +05:00
2004-12-01 15:48:31 +05:00
void SMESHGUI::Deactivate()
2004-06-18 14:34:31 +06:00
{
2004-12-01 15:48:31 +05:00
if ( SMESHGUI::GetSMESHGUI() ) {
SMESHGUI::GetSMESHGUI()->EmitSignalCloseAllDialogs();
}
2003-05-19 20:07:00 +06:00
}