#include "SMESHGUI_RotationDlg.h"
#include "SMESHGUI_SymmetryDlg.h"
#include "SMESHGUI_SewingDlg.h"
-#include "SMESHGUI_MergeNodesDlg.h"
#include "SMESHGUI_EditMeshDlg.h"
#include "SMESHGUI_MeshPatternDlg.h"
#include "SMESHGUI_Selection.h"
#include "SMESHGUI_Displayer.h"
#include "SMESHGUI_MakeNodeAtPointDlg.h"
#include "SMESHGUI_BuildCompoundDlg.h"
+#include "SMESHGUI_ComputeDlg.h"
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_GEOMGenUtils.h"
#include "SALOMEDSClient_StudyBuilder.hxx"
#include "SALOMEDSClient_SComponent.hxx"
+#include <Standard_ErrorHandler.hxx>
+
using namespace std;
//namespace{
if ( !aMesh->_is_nil() ) {
QString aFilter, aTitle = QObject::tr("Export mesh");
QMap<QString, SMESH::MED_VERSION> aFilterMap;
+ QMap<QString, int> aFilterMapSTL;
switch ( theCommandID ) {
case 125:
case 122:
aFilter = QObject::tr("IDEAS files (*.unv)");
}
break;
+ case 140:
+ case 141:
+ {
+ // export STL
+ /*
+ there must be check on others mesh elements not equal triangles
+ */
+ if (aMesh->NbTriangles() < 1) {
+ SUIT_MessageBox::warn1
+ (SMESHGUI::desktop(),
+ QObject::tr("SMESH_WRN_WARNING"),
+ QObject::tr("SMESH_EXPORT_STL1").arg(anIObject->getName()),
+ QObject::tr("SMESH_BUT_OK"));
+ return;
+ }
+ if (!(aMesh->NbElements() - aMesh->NbTriangles())) {
+ int aRet = SUIT_MessageBox::warn2
+ (SMESHGUI::desktop(),
+ QObject::tr("SMESH_WRN_WARNING"),
+ QObject::tr("SMESH_EXPORT_STL2").arg(anIObject->getName()),
+ QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
+ 0, 1, 0);
+ if (aRet)
+ return;
+ }
+
+ aFilterMapSTL.insert( QObject::tr("STL ASCII (*.stl)"), 1 ); // 1 - ASCII mode
+ aFilterMapSTL.insert( QObject::tr("STL Binary (*.stl)"), 0 ); // 0 - Binary mode
+ }
+ break;
default:
return;
}
QString aFilename;
SMESH::MED_VERSION aFormat;
// Init the parameter with the default value
+ bool aIsASCII_STL = true;
bool toCreateGroups = false;
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
if ( resMgr )
toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
- if ( theCommandID != 122 && theCommandID != 125 )
+ if ( theCommandID != 122 && theCommandID != 125 && theCommandID != 140 && theCommandID != 141)
+
aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false);
+
+ else if(theCommandID == 140 || theCommandID == 141) { // Export to STL
+ QStringList filters;
+ QMap<QString, int>::const_iterator it = aFilterMapSTL.begin();
+ for ( ; it != aFilterMapSTL.end(); ++it )
+ filters.push_back( it.key() );
+
+ SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
+ fd->setCaption( aTitle );
+ fd->setFilters( filters );
+ fd->setSelectedFilter( QObject::tr("STL ASCII (*.stl)") );
+ bool is_ok = false;
+ while (!is_ok) {
+ fd->exec();
+ aFilename = fd->selectedFile();
+ aIsASCII_STL = (aFilterMapSTL[fd->selectedFilter()]) == 1 ? true: false;
+ is_ok = true;
+ }
+ delete fd;
+ }
else {
QStringList filters;
QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
case 123:
aMesh->ExportUNV( aFilename.latin1() );
break;
+ case 140:
+ case 141:
+ aMesh->ExportSTL( aFilename.latin1(), aIsASCII_STL );
+ break;
default:
break;
}
_PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh);
if (aMeshSO)
- SMESH::ModifiedMesh(aMeshSO, false);
+ SMESH::ModifiedMesh(aMeshSO, false, aMesh->NbNodes()==0);
}
else {
IObject = new SALOME_InteractiveObject
case 124:
case 125:
case 126:
+ case 140:
+ case 141:
{
::ExportMeshToFile(theCommandID);
break;
case 214: // UPDATE
{
if(checkLock(aStudy)) break;
- SMESH::UpdateView();
+ try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
+ SMESH::UpdateView();
+ }
+ catch (std::bad_alloc) { // PAL16774 (Crash after display of many groups)
+ SMESH::OnVisuException();
+ }
+ catch (...) { // PAL16774 (Crash after display of many groups)
+ SMESH::OnVisuException();
+ }
SALOME_ListIO l;
LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
extractContainers( sel_objects, to_process );
- if (vtkwnd) {
- SALOME_ListIteratorOfListIO It( to_process );
- for (; It.More(); It.Next()) {
- Handle(SALOME_InteractiveObject) IOS = It.Value();
- if (IOS->hasEntry()) {
- SMESH::UpdateView(anAction, IOS->getEntry());
- if (anAction == SMESH::eDisplayOnly)
- anAction = SMESH::eDisplay;
- }
- }
- }
+ try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
+ if (vtkwnd) {
+ SALOME_ListIteratorOfListIO It( to_process );
+ for (; It.More(); It.Next()) {
+ Handle(SALOME_InteractiveObject) IOS = It.Value();
+ if (IOS->hasEntry()) {
+ if (!SMESH::UpdateView(anAction, IOS->getEntry()))
+ break; // PAL16774 (Crash after display of many groups)
+ if (anAction == SMESH::eDisplayOnly)
+ anAction = SMESH::eDisplay;
+ }
+ }
+ }
- // PAL13338 + PAL15161 -->
- if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy) /*&& !automaticUpdate()*/ )
- SMESH::UpdateView();
- // PAL13338 + PAL15161 <--
+ // PAL13338 + PAL15161 -->
+ if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy))
+ SMESH::UpdateView();
+ // PAL13338 + PAL15161 <--
+ }
+ catch (...) { // PAL16774 (Crash after display of many groups)
+ SMESH::OnVisuException();
+ }
if (anAction == SMESH::eErase) {
SALOME_ListIO l1;
{
if (checkLock(aStudy)) break;
- LightApp_SelectionMgr *Sel = selectionMgr();
- SALOME_ListIO selected; Sel->selectedObjects( selected );
-
- int nbSel = selected.Extent();
- if (nbSel != 1) {
- SUIT_MessageBox::warn1(desktop(),
- tr("SMESH_WRN_WARNING"),
- tr("SMESH_WRN_NO_AVAILABLE_DATA"),
- tr("SMESH_BUT_OK"));
- break;
- }
-
- SMESH::SMESH_Mesh_var aMesh;
- SMESH::SMESH_subMesh_var aSubMesh;
- Handle(SALOME_InteractiveObject) IObject = selected.First();
- if (IObject->hasEntry()) {
- _PTR(SObject) aMeshSObj = aStudy->FindObjectID(IObject->getEntry());
- GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj );
- if ( aShapeObject->_is_nil() ) {
- // imported mesh
- break;
- }
- if ( aMeshSObj ) {
- aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(aMeshSObj);
- aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(aMeshSObj);
- if ( !aSubMesh->_is_nil() )
- aMesh = aSubMesh->GetFather();
-
- if (!aMesh->_is_nil()) {
- SMESH::algo_error_array_var errors = GetSMESHGen()->GetAlgoState(aMesh,aShapeObject);
- if ( errors->length() > 0 ) {
- SUIT_MessageBox::warn1(desktop(),
- tr("SMESH_WRN_WARNING"),
- SMESH::GetMessageOnAlgoStateErrors( errors.in() ),
- tr("SMESH_BUT_OK"));
- break;
- }
-
- try {
- if (GetSMESHGen()->Compute(aMesh, aShapeObject))
- SMESH::ModifiedMesh(aMeshSObj, true);
- else
- SUIT_MessageBox::warn1(desktop(),
- tr("SMESH_WRN_WARNING"),
- tr("SMESH_WRN_COMPUTE_FAILED"),
- tr("SMESH_BUT_OK"));
- }
- catch(const SALOME::SALOME_Exception & S_ex){
- SalomeApp_Tools::QtCatchCorbaException(S_ex);
- }
-
- updateObjBrowser();
-
- if (automaticUpdate()) {
- SVTK_ViewWindow* aVTKView = SMESH::GetViewWindow(this, /*create*/true);
- if (aVTKView) {
- CORBA::Long anId = aStudy->StudyId();
- TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId, IObject->getEntry());
- if (aVisualObj) {
- aVisualObj->Update();
- SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry());
- if (!anActor) {
- anActor = SMESH::CreateActor(aStudy, IObject->getEntry());
- if (anActor) {
- SMESH::DisplayActor(aVTKView, anActor); //apo
- SMESH::FitAll();
- }
- }
- SMESH::RepaintCurrentView();
- Sel->setSelectedObjects( selected );
- }
- }
- }
- }
- }
- }
+ startOperation( 701 );
}
break;
int nbSel = selected.Extent();
if (nbSel == 1) {
- SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(selected.First());
+ Handle(SALOME_InteractiveObject) anIObject = selected.First();
+ SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::IObjectToInterface<SMESH::SMESH_Hypothesis>(anIObject);
/* 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() )
+ if ( !aHypothesis->_is_nil() )
{
- char* sName = Hyp->GetName();
- SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName);
+ CORBA::String_var aHypType = aHypothesis->GetName();
+ SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypType);
if (aCreator)
- aCreator->edit( Hyp.in(), desktop() );
+ aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
else
{
// report error
if(checkLock(aStudy)) break;
if(vtkwnd) {
EmitSignalDeactivateDialog();
- new SMESHGUI_MergeNodesDlg( this );
+ new SMESHGUI_EditMeshDlg( this, 0 );
}
else {
SUIT_MessageBox::warn1(desktop(),
}
break;
}
- case 4066: // MERGE EQUAL ELEMENTS
+ case 4066: // MERGE EQUAL ELEMENTS
{
if (checkLock(aStudy)) break;
if (vtkwnd) {
EmitSignalDeactivateDialog();
- new SMESHGUI_EditMeshDlg(this,
- "SMESH_MERGE_ELEMENTS_TITLE",
- "ICON_DLG_MERGE_ELEMENTS",
- 1); // MergeEqualElemets
+ new SMESHGUI_EditMeshDlg( this, 1 );
} else {
SUIT_MessageBox::warn1(desktop(),
tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
createSMESHAction( 121, "DAT" );
createSMESHAction( 122, "MED" );
createSMESHAction( 123, "UNV" );
+ createSMESHAction( 140, "STL" );
createSMESHAction( 124, "EXPORT_DAT" );
createSMESHAction( 125, "EXPORT_MED" );
createSMESHAction( 126, "EXPORT_UNV" );
- createSMESHAction( 33, "DELETE", "ICON_DELETE" );
+ createSMESHAction( 141, "EXPORT_STL" );
+ createSMESHAction( 33, "DELETE", "ICON_DELETE", Key_Delete );
createSMESHAction( 5105, "SEL_FILTER_LIB" );
createSMESHAction( 701, "COMPUTE", "ICON_COMPUTE" );
createSMESHAction( 702, "CREATE_MESH", "ICON_DLG_INIT_MESH" );
createSMESHAction( 219, "VOLUMES", "ICON_DLG_TETRAS", 0, true );
createSMESHAction( 220, "ALL" );
createSMESHAction( 1100, "EDIT_HYPO" );
- createSMESHAction( 1101, "RENAME" );
+ createSMESHAction( 1101, "RENAME", "", Key_F2 );
createSMESHAction( 1102, "UNASSIGN" );
createSMESHAction( 9010, "NUM_NODES", "", 0, true );
createSMESHAction( 9011, "NUM_ELEMENTS", "", 0, true );
createMenu( 121, exportId, -1 );
createMenu( 122, exportId, -1 );
createMenu( 123, exportId, -1 );
+ createMenu( 140, exportId, -1 ); // export to stl STL
createMenu( separator(), fileId, 10 );
popupMgr()->insert( separator(), -1, 0 );
QString only_one_non_empty = QString( " && %1=1 && numberOfNodes>0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
- createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
- createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
- createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
+ createPopupItem( 125, OB, mesh, only_one_non_empty ); // EXPORT_MED
+ createPopupItem( 126, OB, mesh, only_one_non_empty ); // EXPORT_UNV
+ createPopupItem( 141, OB, mesh, only_one_non_empty ); // EXPORT_STL
+ //createPopupItem( 33, OB, subMesh + " " + group ); // DELETE
+ createPopupItem( 33, OB, mesh_group + " " + hyp_alg ); // DELETE
popupMgr()->insert( separator(), -1, 0 );
// popup for viewer
return SalomeApp_Module::deactivateModule( study );
}
+void SMESHGUI::studyClosed( SUIT_Study* s )
+{
+ SMESH::RemoveVisuData( s->id() );
+ SalomeApp_Module::studyClosed( s );
+}
+
void SMESHGUI::OnGUIEvent()
{
const QObject* obj = sender();
int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
- int renumber=addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
+ addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
+ addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
if( name=="selection_object_color" || name=="selection_element_color" ||
name=="selection_width" || name=="highlight_color" || name=="highlight_width" ||
- name=="selection_precision_node" || name=="selection_precision_element" )
+ name=="selection_precision_node" || name=="selection_precision_element" ||
+ name=="selection_precision_object")
SMESH::UpdateSelectionProp( this );
else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
// to do : create operation here
switch( id )
{
+ case 701: // Compute mesh
+ op = new SMESHGUI_ComputeOp();
+ break;
case 702: // Create mesh
op = new SMESHGUI_MeshOp( true, true );
break;